From 53dab3fd09ff4b1b91bad0273c204b586fd5f865 Mon Sep 17 00:00:00 2001 From: syui Date: Thu, 19 Jun 2025 17:12:44 +0900 Subject: [PATCH] fix ailog stream server --- .gitignore | 1 + .../oauth/assets/comment-atproto-BQKPMV57.js | 147 ------------------ .../oauth/assets/comment-atproto-BUFiApUA.css | 1 - 3 files changed, 1 insertion(+), 148 deletions(-) delete mode 100644 my-blog/static/oauth/assets/comment-atproto-BQKPMV57.js delete mode 100644 my-blog/static/oauth/assets/comment-atproto-BUFiApUA.css diff --git a/.gitignore b/.gitignore index 4d64041..7b738a5 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ cloudflared-config.yml atproto oauth_old oauth_example +my-blog/static/oauth/assets/comment-atproto* diff --git a/my-blog/static/oauth/assets/comment-atproto-BQKPMV57.js b/my-blog/static/oauth/assets/comment-atproto-BQKPMV57.js deleted file mode 100644 index 29a290d..0000000 --- a/my-blog/static/oauth/assets/comment-atproto-BQKPMV57.js +++ /dev/null @@ -1,147 +0,0 @@ -var uK=Object.defineProperty;var tx=t=>{throw TypeError(t)};var cK=(t,e,r)=>e in t?uK(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var De=(t,e,r)=>cK(t,typeof e!="symbol"?e+"":e,r),Vm=(t,e,r)=>e.has(t)||tx("Cannot "+r);var R=(t,e,r)=>(Vm(t,e,"read from private field"),r?r.call(t):e.get(t)),me=(t,e,r)=>e.has(t)?tx("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Z=(t,e,r,n)=>(Vm(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),z=(t,e,r)=>(Vm(t,e,"access private method"),r);var up=(t,e,r,n)=>({set _(i){Z(t,e,i,r)},get _(){return R(t,e,n)}});(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=r(i);fetch(i.href,o)}})();var S=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bh(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}var UA={exports:{}},vh={},$A={exports:{}},he={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Lc=Symbol.for("react.element"),dK=Symbol.for("react.portal"),pK=Symbol.for("react.fragment"),fK=Symbol.for("react.strict_mode"),hK=Symbol.for("react.profiler"),yK=Symbol.for("react.provider"),mK=Symbol.for("react.context"),gK=Symbol.for("react.forward_ref"),bK=Symbol.for("react.suspense"),vK=Symbol.for("react.memo"),EK=Symbol.for("react.lazy"),rx=Symbol.iterator;function wK(t){return t===null||typeof t!="object"?null:(t=rx&&t[rx]||t["@@iterator"],typeof t=="function"?t:null)}var OA={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},KA=Object.assign,VA={};function $a(t,e,r){this.props=t,this.context=e,this.refs=VA,this.updater=r||OA}$a.prototype.isReactComponent={};$a.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};$a.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function MA(){}MA.prototype=$a.prototype;function pv(t,e,r){this.props=t,this.context=e,this.refs=VA,this.updater=r||OA}var fv=pv.prototype=new MA;fv.constructor=pv;KA(fv,$a.prototype);fv.isPureReactComponent=!0;var nx=Array.isArray,NA=Object.prototype.hasOwnProperty,hv={current:null},zA={key:!0,ref:!0,__self:!0,__source:!0};function FA(t,e,r){var n,i={},o=null,s=null;if(e!=null)for(n in e.ref!==void 0&&(s=e.ref),e.key!==void 0&&(o=""+e.key),e)NA.call(e,n)&&!zA.hasOwnProperty(n)&&(i[n]=e[n]);var l=arguments.length-2;if(l===1)i.children=r;else if(1>>1,lt=q[ze];if(0>>1;zei(Km,ce))Zoi(lp,Km)?(q[ze]=lp,q[Zo]=ce,ze=Zo):(q[ze]=Km,q[Jo]=ce,ze=Jo);else if(Zoi(lp,ce))q[ze]=lp,q[Zo]=ce,ze=Zo;else break e}}return ne}function i(q,ne){var ce=q.sortIndex-ne.sortIndex;return ce!==0?ce:q.id-ne.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var s=Date,l=s.now();t.unstable_now=function(){return s.now()-l}}var u=[],c=[],d=1,f=null,h=3,g=!1,b=!1,w=!1,C=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,m=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(q){for(var ne=r(c);ne!==null;){if(ne.callback===null)n(c);else if(ne.startTime<=q)n(c),ne.sortIndex=ne.expirationTime,e(u,ne);else break;ne=r(c)}}function A(q){if(w=!1,E(q),!b)if(r(u)!==null)b=!0,$m(L);else{var ne=r(c);ne!==null&&Om(A,ne.startTime-q)}}function L(q,ne){b=!1,w&&(w=!1,y(j),j=-1),g=!0;var ce=h;try{for(E(ne),f=r(u);f!==null&&(!(f.expirationTime>ne)||q&&!Zt());){var ze=f.callback;if(typeof ze=="function"){f.callback=null,h=f.priorityLevel;var lt=ze(f.expirationTime<=ne);ne=t.unstable_now(),typeof lt=="function"?f.callback=lt:f===r(u)&&n(u),E(ne)}else n(u);f=r(u)}if(f!==null)var ap=!0;else{var Jo=r(c);Jo!==null&&Om(A,Jo.startTime-ne),ap=!1}return ap}finally{f=null,h=ce,g=!1}}var D=!1,B=null,j=-1,pe=5,ee=-1;function Zt(){return!(t.unstable_now()-eeq||125ze?(q.sortIndex=ce,e(c,q),r(u)===null&&q===r(c)&&(w?(y(j),j=-1):w=!0,Om(A,ce-ze))):(q.sortIndex=lt,e(u,q),b||g||(b=!0,$m(L))),q},t.unstable_shouldYield=Zt,t.unstable_wrapCallback=function(q){var ne=h;return function(){var ce=h;h=ne;try{return q.apply(this,arguments)}finally{h=ce}}}})(WA);XA.exports=WA;var DK=XA.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var BK=ye,wr=DK;function I(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,r=1;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Xg=Object.prototype.hasOwnProperty,IK=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,ox={},sx={};function jK(t){return Xg.call(sx,t)?!0:Xg.call(ox,t)?!1:IK.test(t)?sx[t]=!0:(ox[t]=!0,!1)}function UK(t,e,r,n){if(r!==null&&r.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return n?!1:r!==null?!r.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function $K(t,e,r,n){if(e===null||typeof e>"u"||UK(t,e,r,n))return!0;if(n)return!1;if(r!==null)switch(r.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Ht(t,e,r,n,i,o,s){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=n,this.attributeNamespace=i,this.mustUseProperty=r,this.propertyName=t,this.type=e,this.sanitizeURL=o,this.removeEmptyString=s}var xt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){xt[t]=new Ht(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];xt[e]=new Ht(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){xt[t]=new Ht(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){xt[t]=new Ht(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){xt[t]=new Ht(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){xt[t]=new Ht(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){xt[t]=new Ht(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){xt[t]=new Ht(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){xt[t]=new Ht(t,5,!1,t.toLowerCase(),null,!1,!1)});var mv=/[\-:]([a-z])/g;function gv(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(mv,gv);xt[e]=new Ht(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(mv,gv);xt[e]=new Ht(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(mv,gv);xt[e]=new Ht(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){xt[t]=new Ht(t,1,!1,t.toLowerCase(),null,!1,!1)});xt.xlinkHref=new Ht("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){xt[t]=new Ht(t,1,!1,t.toLowerCase(),null,!0,!0)});function bv(t,e,r,n){var i=xt.hasOwnProperty(e)?xt[e]:null;(i!==null?i.type!==0:n||!(2l||i[s]!==o[l]){var u=` -`+i[s].replace(" at new "," at ");return t.displayName&&u.includes("")&&(u=u.replace("",t.displayName)),u}while(1<=s&&0<=l);break}}}finally{zm=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?ku(t):""}function OK(t){switch(t.tag){case 5:return ku(t.type);case 16:return ku("Lazy");case 13:return ku("Suspense");case 19:return ku("SuspenseList");case 0:case 2:case 15:return t=Fm(t.type,!1),t;case 11:return t=Fm(t.type.render,!1),t;case 1:return t=Fm(t.type,!0),t;default:return""}}function Qg(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ta:return"Fragment";case ea:return"Portal";case Wg:return"Profiler";case vv:return"StrictMode";case Jg:return"Suspense";case Zg:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case QA:return(t.displayName||"Context")+".Consumer";case ZA:return(t._context.displayName||"Context")+".Provider";case Ev:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case wv:return e=t.displayName||null,e!==null?e:Qg(t.type)||"Memo";case qi:e=t._payload,t=t._init;try{return Qg(t(e))}catch{}}return null}function KK(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qg(e);case 8:return e===vv?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function po(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function eS(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function VK(t){var e=eS(t)?"checked":"value",r=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),n=""+t[e];if(!t.hasOwnProperty(e)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var i=r.get,o=r.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(s){n=""+s,o.call(this,s)}}),Object.defineProperty(t,e,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(s){n=""+s},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function pp(t){t._valueTracker||(t._valueTracker=VK(t))}function tS(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var r=e.getValue(),n="";return t&&(n=eS(t)?t.checked?"true":"false":t.value),t=n,t!==r?(e.setValue(t),!0):!1}function Af(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Yg(t,e){var r=e.checked;return Ve({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function lx(t,e){var r=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;r=po(e.value!=null?e.value:r),t._wrapperState={initialChecked:n,initialValue:r,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function rS(t,e){e=e.checked,e!=null&&bv(t,"checked",e,!1)}function eb(t,e){rS(t,e);var r=po(e.value),n=e.type;if(r!=null)n==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+r):t.value!==""+r&&(t.value=""+r);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?tb(t,e.type,r):e.hasOwnProperty("defaultValue")&&tb(t,e.type,po(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function ux(t,e,r){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var n=e.type;if(!(n!=="submit"&&n!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,r||e===t.value||(t.value=e),t.defaultValue=e}r=t.name,r!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,r!==""&&(t.name=r)}function tb(t,e,r){(e!=="number"||Af(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var Lu=Array.isArray;function pa(t,e,r,n){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=fp.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Ju(t,e){if(e){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=e;return}}t.textContent=e}var Iu={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},MK=["Webkit","ms","Moz","O"];Object.keys(Iu).forEach(function(t){MK.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Iu[e]=Iu[t]})});function sS(t,e,r){return e==null||typeof e=="boolean"||e===""?"":r||typeof e!="number"||e===0||Iu.hasOwnProperty(t)&&Iu[t]?(""+e).trim():e+"px"}function aS(t,e){t=t.style;for(var r in e)if(e.hasOwnProperty(r)){var n=r.indexOf("--")===0,i=sS(r,e[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,i):t[r]=i}}var NK=Ve({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ib(t,e){if(e){if(NK[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(I(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(I(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(I(61))}if(e.style!=null&&typeof e.style!="object")throw Error(I(62))}}function ob(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var sb=null;function _v(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var ab=null,fa=null,ha=null;function px(t){if(t=Bc(t)){if(typeof ab!="function")throw Error(I(280));var e=t.stateNode;e&&(e=Rh(e),ab(t.stateNode,t.type,e))}}function lS(t){fa?ha?ha.push(t):ha=[t]:fa=t}function uS(){if(fa){var t=fa,e=ha;if(ha=fa=null,px(t),e)for(t=0;t>>=0,t===0?32:31-(YK(t)/eV|0)|0}var hp=64,yp=4194304;function Pu(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function kf(t,e){var r=t.pendingLanes;if(r===0)return 0;var n=0,i=t.suspendedLanes,o=t.pingedLanes,s=r&268435455;if(s!==0){var l=s&~i;l!==0?n=Pu(l):(o&=s,o!==0&&(n=Pu(o)))}else s=r&~i,s!==0?n=Pu(s):o!==0&&(n=Pu(o));if(n===0)return 0;if(e!==0&&e!==n&&!(e&i)&&(i=n&-n,o=e&-e,i>=o||i===16&&(o&4194240)!==0))return e;if(n&4&&(n|=r&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=n;0r;r++)e.push(t);return e}function Pc(t,e,r){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-hn(e),t[e]=r}function iV(t,e){var r=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var n=t.eventTimes;for(t=t.expirationTimes;0=Uu),wx=" ",_x=!1;function kS(t,e){switch(t){case"keyup":return DV.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function LS(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ra=!1;function IV(t,e){switch(t){case"compositionend":return LS(e);case"keypress":return e.which!==32?null:(_x=!0,wx);case"textInput":return t=e.data,t===wx&&_x?null:t;default:return null}}function jV(t,e){if(ra)return t==="compositionend"||!Lv&&kS(t,e)?(t=CS(),rf=Cv=Zi=null,ra=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:r,offset:e-t};t=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=Sx(r)}}function IS(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?IS(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function jS(){for(var t=window,e=Af();e instanceof t.HTMLIFrameElement;){try{var r=typeof e.contentWindow.location.href=="string"}catch{r=!1}if(r)t=e.contentWindow;else break;e=Af(t.document)}return e}function Pv(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function FV(t){var e=jS(),r=t.focusedElem,n=t.selectionRange;if(e!==r&&r&&r.ownerDocument&&IS(r.ownerDocument.documentElement,r)){if(n!==null&&Pv(r)){if(e=n.start,t=n.end,t===void 0&&(t=e),"selectionStart"in r)r.selectionStart=e,r.selectionEnd=Math.min(t,r.value.length);else if(t=(e=r.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=r.textContent.length,o=Math.min(n.start,i);n=n.end===void 0?o:Math.min(n.end,i),!t.extend&&o>n&&(i=n,n=o,o=i),i=Cx(r,o);var s=Cx(r,n);i&&s&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==s.node||t.focusOffset!==s.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),o>n?(t.addRange(e),t.extend(s.node,s.offset)):(e.setEnd(s.node,s.offset),t.addRange(e)))}}for(e=[],t=r;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r=document.documentMode,na=null,fb=null,Ou=null,hb=!1;function Tx(t,e,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;hb||na==null||na!==Af(n)||(n=na,"selectionStart"in n&&Pv(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),Ou&&rc(Ou,n)||(Ou=n,n=Df(fb,"onSelect"),0sa||(t.current=Eb[sa],Eb[sa]=null,sa--)}function Se(t,e){sa++,Eb[sa]=t.current,t.current=e}var fo={},It=ko(fo),or=ko(!1),xs=fo;function Ra(t,e){var r=t.type.contextTypes;if(!r)return fo;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===e)return n.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in r)i[o]=e[o];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function sr(t){return t=t.childContextTypes,t!=null}function If(){Pe(or),Pe(It)}function jx(t,e,r){if(It.current!==fo)throw Error(I(168));Se(It,e),Se(or,r)}function FS(t,e,r){var n=t.stateNode;if(e=e.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var i in n)if(!(i in e))throw Error(I(108,KK(t)||"Unknown",i));return Ve({},r,n)}function jf(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||fo,xs=It.current,Se(It,t),Se(or,or.current),!0}function Ux(t,e,r){var n=t.stateNode;if(!n)throw Error(I(169));r?(t=FS(t,e,xs),n.__reactInternalMemoizedMergedChildContext=t,Pe(or),Pe(It),Se(It,t)):Pe(or),Se(or,r)}var li=null,Ah=!1,ig=!1;function qS(t){li===null?li=[t]:li.push(t)}function rM(t){Ah=!0,qS(t)}function Lo(){if(!ig&&li!==null){ig=!0;var t=0,e=xe;try{var r=li;for(xe=1;t>=s,i-=s,fi=1<<32-hn(e)+i|r<j?(pe=B,B=null):pe=B.sibling;var ee=h(y,B,E[j],A);if(ee===null){B===null&&(B=pe);break}t&&B&&ee.alternate===null&&e(y,B),m=o(ee,m,j),D===null?L=ee:D.sibling=ee,D=ee,B=pe}if(j===E.length)return r(y,B),Be&&os(y,j),L;if(B===null){for(;jj?(pe=B,B=null):pe=B.sibling;var Zt=h(y,B,ee.value,A);if(Zt===null){B===null&&(B=pe);break}t&&B&&Zt.alternate===null&&e(y,B),m=o(Zt,m,j),D===null?L=Zt:D.sibling=Zt,D=Zt,B=pe}if(ee.done)return r(y,B),Be&&os(y,j),L;if(B===null){for(;!ee.done;j++,ee=E.next())ee=f(y,ee.value,A),ee!==null&&(m=o(ee,m,j),D===null?L=ee:D.sibling=ee,D=ee);return Be&&os(y,j),L}for(B=n(y,B);!ee.done;j++,ee=E.next())ee=g(B,y,j,ee.value,A),ee!==null&&(t&&ee.alternate!==null&&B.delete(ee.key===null?j:ee.key),m=o(ee,m,j),D===null?L=ee:D.sibling=ee,D=ee);return t&&B.forEach(function(Li){return e(y,Li)}),Be&&os(y,j),L}function C(y,m,E,A){if(typeof E=="object"&&E!==null&&E.type===ta&&E.key===null&&(E=E.props.children),typeof E=="object"&&E!==null){switch(E.$$typeof){case dp:e:{for(var L=E.key,D=m;D!==null;){if(D.key===L){if(L=E.type,L===ta){if(D.tag===7){r(y,D.sibling),m=i(D,E.props.children),m.return=y,y=m;break e}}else if(D.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===qi&&Kx(L)===D.type){r(y,D.sibling),m=i(D,E.props),m.ref=hu(y,D,E),m.return=y,y=m;break e}r(y,D);break}else e(y,D);D=D.sibling}E.type===ta?(m=Es(E.props.children,y.mode,A,E.key),m.return=y,y=m):(A=df(E.type,E.key,E.props,null,y.mode,A),A.ref=hu(y,m,E),A.return=y,y=A)}return s(y);case ea:e:{for(D=E.key;m!==null;){if(m.key===D)if(m.tag===4&&m.stateNode.containerInfo===E.containerInfo&&m.stateNode.implementation===E.implementation){r(y,m.sibling),m=i(m,E.children||[]),m.return=y,y=m;break e}else{r(y,m);break}else e(y,m);m=m.sibling}m=pg(E,y.mode,A),m.return=y,y=m}return s(y);case qi:return D=E._init,C(y,m,D(E._payload),A)}if(Lu(E))return b(y,m,E,A);if(uu(E))return w(y,m,E,A);_p(y,E)}return typeof E=="string"&&E!==""||typeof E=="number"?(E=""+E,m!==null&&m.tag===6?(r(y,m.sibling),m=i(m,E),m.return=y,y=m):(r(y,m),m=dg(E,y.mode,A),m.return=y,y=m),s(y)):r(y,m)}return C}var Sa=WS(!0),JS=WS(!1),Of=ko(null),Kf=null,ua=null,jv=null;function Uv(){jv=ua=Kf=null}function $v(t){var e=Of.current;Pe(Of),t._currentValue=e}function xb(t,e,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,n!==null&&(n.childLanes|=e)):n!==null&&(n.childLanes&e)!==e&&(n.childLanes|=e),t===r)break;t=t.return}}function ma(t,e){Kf=t,jv=ua=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(ir=!0),t.firstContext=null)}function Or(t){var e=t._currentValue;if(jv!==t)if(t={context:t,memoizedValue:e,next:null},ua===null){if(Kf===null)throw Error(I(308));ua=t,Kf.dependencies={lanes:0,firstContext:t}}else ua=ua.next=t;return e}var hs=null;function Ov(t){hs===null?hs=[t]:hs.push(t)}function ZS(t,e,r,n){var i=e.interleaved;return i===null?(r.next=r,Ov(e)):(r.next=i.next,i.next=r),e.interleaved=r,_i(t,n)}function _i(t,e){t.lanes|=e;var r=t.alternate;for(r!==null&&(r.lanes|=e),r=t,t=t.return;t!==null;)t.childLanes|=e,r=t.alternate,r!==null&&(r.childLanes|=e),r=t,t=t.return;return r.tag===3?r.stateNode:null}var Gi=!1;function Kv(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function QS(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function yi(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function oo(t,e,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,ve&2){var i=n.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),n.pending=e,_i(t,r)}return i=n.interleaved,i===null?(e.next=e,Ov(n)):(e.next=i.next,i.next=e),n.interleaved=e,_i(t,r)}function of(t,e,r){if(e=e.updateQueue,e!==null&&(e=e.shared,(r&4194240)!==0)){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,Rv(t,r)}}function Vx(t,e){var r=t.updateQueue,n=t.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var i=null,o=null;if(r=r.firstBaseUpdate,r!==null){do{var s={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};o===null?i=o=s:o=o.next=s,r=r.next}while(r!==null);o===null?i=o=e:o=o.next=e}else i=o=e;r={baseState:n.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:n.shared,effects:n.effects},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=e:t.next=e,r.lastBaseUpdate=e}function Vf(t,e,r,n){var i=t.updateQueue;Gi=!1;var o=i.firstBaseUpdate,s=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var u=l,c=u.next;u.next=null,s===null?o=c:s.next=c,s=u;var d=t.alternate;d!==null&&(d=d.updateQueue,l=d.lastBaseUpdate,l!==s&&(l===null?d.firstBaseUpdate=c:l.next=c,d.lastBaseUpdate=u))}if(o!==null){var f=i.baseState;s=0,d=c=u=null,l=o;do{var h=l.lane,g=l.eventTime;if((n&h)===h){d!==null&&(d=d.next={eventTime:g,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var b=t,w=l;switch(h=e,g=r,w.tag){case 1:if(b=w.payload,typeof b=="function"){f=b.call(g,f,h);break e}f=b;break e;case 3:b.flags=b.flags&-65537|128;case 0:if(b=w.payload,h=typeof b=="function"?b.call(g,f,h):b,h==null)break e;f=Ve({},f,h);break e;case 2:Gi=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,h=i.effects,h===null?i.effects=[l]:h.push(l))}else g={eventTime:g,lane:h,tag:l.tag,payload:l.payload,callback:l.callback,next:null},d===null?(c=d=g,u=f):d=d.next=g,s|=h;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;h=l,l=h.next,h.next=null,i.lastBaseUpdate=h,i.shared.pending=null}}while(!0);if(d===null&&(u=f),i.baseState=u,i.firstBaseUpdate=c,i.lastBaseUpdate=d,e=i.shared.interleaved,e!==null){i=e;do s|=i.lane,i=i.next;while(i!==e)}else o===null&&(i.shared.lanes=0);Ss|=s,t.lanes=s,t.memoizedState=f}}function Mx(t,e,r){if(t=e.effects,e.effects=null,t!==null)for(e=0;er?r:4,t(!0);var n=sg.transition;sg.transition={};try{t(!1),e()}finally{xe=r,sg.transition=n}}function y1(){return Kr().memoizedState}function sM(t,e,r){var n=ao(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},m1(t))g1(e,r);else if(r=ZS(t,e,r,n),r!==null){var i=qt();yn(r,t,n,i),b1(r,e,n)}}function aM(t,e,r){var n=ao(t),i={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(m1(t))g1(e,i);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var s=e.lastRenderedState,l=o(s,r);if(i.hasEagerState=!0,i.eagerState=l,gn(l,s)){var u=e.interleaved;u===null?(i.next=i,Ov(e)):(i.next=u.next,u.next=i),e.interleaved=i;return}}catch{}finally{}r=ZS(t,e,i,n),r!==null&&(i=qt(),yn(r,t,n,i),b1(r,e,n))}}function m1(t){var e=t.alternate;return t===Ke||e!==null&&e===Ke}function g1(t,e){Ku=Nf=!0;var r=t.pending;r===null?e.next=e:(e.next=r.next,r.next=e),t.pending=e}function b1(t,e,r){if(r&4194240){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,Rv(t,r)}}var zf={readContext:Or,useCallback:At,useContext:At,useEffect:At,useImperativeHandle:At,useInsertionEffect:At,useLayoutEffect:At,useMemo:At,useReducer:At,useRef:At,useState:At,useDebugValue:At,useDeferredValue:At,useTransition:At,useMutableSource:At,useSyncExternalStore:At,useId:At,unstable_isNewReconciler:!1},lM={readContext:Or,useCallback:function(t,e){return Rn().memoizedState=[t,e===void 0?null:e],t},useContext:Or,useEffect:zx,useImperativeHandle:function(t,e,r){return r=r!=null?r.concat([t]):null,af(4194308,4,c1.bind(null,e,t),r)},useLayoutEffect:function(t,e){return af(4194308,4,t,e)},useInsertionEffect:function(t,e){return af(4,2,t,e)},useMemo:function(t,e){var r=Rn();return e=e===void 0?null:e,t=t(),r.memoizedState=[t,e],t},useReducer:function(t,e,r){var n=Rn();return e=r!==void 0?r(e):e,n.memoizedState=n.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},n.queue=t,t=t.dispatch=sM.bind(null,Ke,t),[n.memoizedState,t]},useRef:function(t){var e=Rn();return t={current:t},e.memoizedState=t},useState:Nx,useDebugValue:Hv,useDeferredValue:function(t){return Rn().memoizedState=t},useTransition:function(){var t=Nx(!1),e=t[0];return t=oM.bind(null,t[1]),Rn().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,r){var n=Ke,i=Rn();if(Be){if(r===void 0)throw Error(I(407));r=r()}else{if(r=e(),yt===null)throw Error(I(349));As&30||r1(n,e,r)}i.memoizedState=r;var o={value:r,getSnapshot:e};return i.queue=o,zx(i1.bind(null,n,o,t),[t]),n.flags|=2048,cc(9,n1.bind(null,n,o,r,e),void 0,null),r},useId:function(){var t=Rn(),e=yt.identifierPrefix;if(Be){var r=hi,n=fi;r=(n&~(1<<32-hn(n)-1)).toString(32)+r,e=":"+e+"R"+r,r=lc++,0<\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=s.createElement(r,{is:n.is}):(t=s.createElement(r),r==="select"&&(s=t,n.multiple?s.multiple=!0:n.size&&(s.size=n.size))):t=s.createElementNS(t,r),t[Sn]=e,t[oc]=n,T1(t,e,!1,!1),e.stateNode=t;e:{switch(s=ob(r,n),r){case"dialog":Ce("cancel",t),Ce("close",t),i=n;break;case"iframe":case"object":case"embed":Ce("load",t),i=n;break;case"video":case"audio":for(i=0;ika&&(e.flags|=128,n=!0,yu(o,!1),e.lanes=4194304)}else{if(!n)if(t=Mf(s),t!==null){if(e.flags|=128,n=!0,r=t.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),yu(o,!0),o.tail===null&&o.tailMode==="hidden"&&!s.alternate&&!Be)return St(e),null}else 2*Fe()-o.renderingStartTime>ka&&r!==1073741824&&(e.flags|=128,n=!0,yu(o,!1),e.lanes=4194304);o.isBackwards?(s.sibling=e.child,e.child=s):(r=o.last,r!==null?r.sibling=s:e.child=s,o.last=s)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=Fe(),e.sibling=null,r=$e.current,Se($e,n?r&1|2:r&1),e):(St(e),null);case 22:case 23:return Yv(),n=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?gr&1073741824&&(St(e),e.subtreeFlags&6&&(e.flags|=8192)):St(e),null;case 24:return null;case 25:return null}throw Error(I(156,e.tag))}function mM(t,e){switch(Bv(e),e.tag){case 1:return sr(e.type)&&If(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ca(),Pe(or),Pe(It),Nv(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Mv(e),null;case 13:if(Pe($e),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(I(340));Aa()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Pe($e),null;case 4:return Ca(),null;case 10:return $v(e.type._context),null;case 22:case 23:return Yv(),null;case 24:return null;default:return null}}var Rp=!1,Dt=!1,gM=typeof WeakSet=="function"?WeakSet:Set,M=null;function ca(t,e){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){Me(t,e,n)}else r.current=null}function Db(t,e,r){try{r()}catch(n){Me(t,e,n)}}var eR=!1;function bM(t,e){if(yb=Lf,t=jS(),Pv(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var i=n.anchorOffset,o=n.focusNode;n=n.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break e}var s=0,l=-1,u=-1,c=0,d=0,f=t,h=null;t:for(;;){for(var g;f!==r||i!==0&&f.nodeType!==3||(l=s+i),f!==o||n!==0&&f.nodeType!==3||(u=s+n),f.nodeType===3&&(s+=f.nodeValue.length),(g=f.firstChild)!==null;)h=f,f=g;for(;;){if(f===t)break t;if(h===r&&++c===i&&(l=s),h===o&&++d===n&&(u=s),(g=f.nextSibling)!==null)break;f=h,h=f.parentNode}f=g}r=l===-1||u===-1?null:{start:l,end:u}}else r=null}r=r||{start:0,end:0}}else r=null;for(mb={focusedElem:t,selectionRange:r},Lf=!1,M=e;M!==null;)if(e=M,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,M=t;else for(;M!==null;){e=M;try{var b=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(b!==null){var w=b.memoizedProps,C=b.memoizedState,y=e.stateNode,m=y.getSnapshotBeforeUpdate(e.elementType===e.type?w:Yr(e.type,w),C);y.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var E=e.stateNode.containerInfo;E.nodeType===1?E.textContent="":E.nodeType===9&&E.documentElement&&E.removeChild(E.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(I(163))}}catch(A){Me(e,e.return,A)}if(t=e.sibling,t!==null){t.return=e.return,M=t;break}M=e.return}return b=eR,eR=!1,b}function Vu(t,e,r){var n=e.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&t)===t){var o=i.destroy;i.destroy=void 0,o!==void 0&&Db(e,r,o)}i=i.next}while(i!==n)}}function Th(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var r=e=e.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==e)}}function Bb(t){var e=t.ref;if(e!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof e=="function"?e(t):e.current=t}}function P1(t){var e=t.alternate;e!==null&&(t.alternate=null,P1(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Sn],delete e[oc],delete e[vb],delete e[eM],delete e[tM])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function D1(t){return t.tag===5||t.tag===3||t.tag===4}function tR(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||D1(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Ib(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.nodeType===8?r.parentNode.insertBefore(t,e):r.insertBefore(t,e):(r.nodeType===8?(e=r.parentNode,e.insertBefore(t,r)):(e=r,e.appendChild(t)),r=r._reactRootContainer,r!=null||e.onclick!==null||(e.onclick=Bf));else if(n!==4&&(t=t.child,t!==null))for(Ib(t,e,r),t=t.sibling;t!==null;)Ib(t,e,r),t=t.sibling}function jb(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.insertBefore(t,e):r.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(jb(t,e,r),t=t.sibling;t!==null;)jb(t,e,r),t=t.sibling}var wt=null,un=!1;function Di(t,e,r){for(r=r.child;r!==null;)B1(t,e,r),r=r.sibling}function B1(t,e,r){if(Tn&&typeof Tn.onCommitFiberUnmount=="function")try{Tn.onCommitFiberUnmount(Eh,r)}catch{}switch(r.tag){case 5:Dt||ca(r,e);case 6:var n=wt,i=un;wt=null,Di(t,e,r),wt=n,un=i,wt!==null&&(un?(t=wt,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):wt.removeChild(r.stateNode));break;case 18:wt!==null&&(un?(t=wt,r=r.stateNode,t.nodeType===8?ng(t.parentNode,r):t.nodeType===1&&ng(t,r),ec(t)):ng(wt,r.stateNode));break;case 4:n=wt,i=un,wt=r.stateNode.containerInfo,un=!0,Di(t,e,r),wt=n,un=i;break;case 0:case 11:case 14:case 15:if(!Dt&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){i=n=n.next;do{var o=i,s=o.destroy;o=o.tag,s!==void 0&&(o&2||o&4)&&Db(r,e,s),i=i.next}while(i!==n)}Di(t,e,r);break;case 1:if(!Dt&&(ca(r,e),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(l){Me(r,e,l)}Di(t,e,r);break;case 21:Di(t,e,r);break;case 22:r.mode&1?(Dt=(n=Dt)||r.memoizedState!==null,Di(t,e,r),Dt=n):Di(t,e,r);break;default:Di(t,e,r)}}function rR(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new gM),e.forEach(function(n){var i=CM.bind(null,t,n);r.has(n)||(r.add(n),n.then(i,i))})}}function Jr(t,e){var r=e.deletions;if(r!==null)for(var n=0;ni&&(i=s),n&=~o}if(n=i,n=Fe()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*EM(n/1960))-n,10t?16:t,Qi===null)var n=!1;else{if(t=Qi,Qi=null,Gf=0,ve&6)throw Error(I(331));var i=ve;for(ve|=4,M=t.current;M!==null;){var o=M,s=o.child;if(M.flags&16){var l=o.deletions;if(l!==null){for(var u=0;uFe()-Zv?vs(t,0):Jv|=r),ar(t,e)}function M1(t,e){e===0&&(t.mode&1?(e=yp,yp<<=1,!(yp&130023424)&&(yp=4194304)):e=1);var r=qt();t=_i(t,e),t!==null&&(Pc(t,e,r),ar(t,r))}function SM(t){var e=t.memoizedState,r=0;e!==null&&(r=e.retryLane),M1(t,r)}function CM(t,e){var r=0;switch(t.tag){case 13:var n=t.stateNode,i=t.memoizedState;i!==null&&(r=i.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(I(314))}n!==null&&n.delete(e),M1(t,r)}var N1;N1=function(t,e,r){if(t!==null)if(t.memoizedProps!==e.pendingProps||or.current)ir=!0;else{if(!(t.lanes&r)&&!(e.flags&128))return ir=!1,hM(t,e,r);ir=!!(t.flags&131072)}else ir=!1,Be&&e.flags&1048576&&GS(e,$f,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;lf(t,e),t=e.pendingProps;var i=Ra(e,It.current);ma(e,r),i=Fv(null,e,n,t,i,r);var o=qv();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,sr(n)?(o=!0,jf(e)):o=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Kv(e),i.updater=Ch,e.stateNode=i,i._reactInternals=e,Ab(e,n,t,r),e=Tb(null,e,n,!0,o,r)):(e.tag=0,Be&&o&&Dv(e),Nt(null,e,i,r),e=e.child),e;case 16:n=e.elementType;e:{switch(lf(t,e),t=e.pendingProps,i=n._init,n=i(n._payload),e.type=n,i=e.tag=kM(n),t=Yr(n,t),i){case 0:e=Cb(null,e,n,t,r);break e;case 1:e=Zx(null,e,n,t,r);break e;case 11:e=Wx(null,e,n,t,r);break e;case 14:e=Jx(null,e,n,Yr(n.type,t),r);break e}throw Error(I(306,n,""))}return e;case 0:return n=e.type,i=e.pendingProps,i=e.elementType===n?i:Yr(n,i),Cb(t,e,n,i,r);case 1:return n=e.type,i=e.pendingProps,i=e.elementType===n?i:Yr(n,i),Zx(t,e,n,i,r);case 3:e:{if(A1(e),t===null)throw Error(I(387));n=e.pendingProps,o=e.memoizedState,i=o.element,QS(t,e),Vf(e,n,null,r);var s=e.memoizedState;if(n=s.element,o.isDehydrated)if(o={element:n,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){i=Ta(Error(I(423)),e),e=Qx(t,e,n,r,i);break e}else if(n!==i){i=Ta(Error(I(424)),e),e=Qx(t,e,n,r,i);break e}else for(vr=io(e.stateNode.containerInfo.firstChild),Er=e,Be=!0,cn=null,r=JS(e,null,n,r),e.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(Aa(),n===i){e=xi(t,e,r);break e}Nt(t,e,n,r)}e=e.child}return e;case 5:return YS(e),t===null&&_b(e),n=e.type,i=e.pendingProps,o=t!==null?t.memoizedProps:null,s=i.children,gb(n,i)?s=null:o!==null&&gb(n,o)&&(e.flags|=32),R1(t,e),Nt(t,e,s,r),e.child;case 6:return t===null&&_b(e),null;case 13:return S1(t,e,r);case 4:return Vv(e,e.stateNode.containerInfo),n=e.pendingProps,t===null?e.child=Sa(e,null,n,r):Nt(t,e,n,r),e.child;case 11:return n=e.type,i=e.pendingProps,i=e.elementType===n?i:Yr(n,i),Wx(t,e,n,i,r);case 7:return Nt(t,e,e.pendingProps,r),e.child;case 8:return Nt(t,e,e.pendingProps.children,r),e.child;case 12:return Nt(t,e,e.pendingProps.children,r),e.child;case 10:e:{if(n=e.type._context,i=e.pendingProps,o=e.memoizedProps,s=i.value,Se(Of,n._currentValue),n._currentValue=s,o!==null)if(gn(o.value,s)){if(o.children===i.children&&!or.current){e=xi(t,e,r);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var l=o.dependencies;if(l!==null){s=o.child;for(var u=l.firstContext;u!==null;){if(u.context===n){if(o.tag===1){u=yi(-1,r&-r),u.tag=2;var c=o.updateQueue;if(c!==null){c=c.shared;var d=c.pending;d===null?u.next=u:(u.next=d.next,d.next=u),c.pending=u}}o.lanes|=r,u=o.alternate,u!==null&&(u.lanes|=r),xb(o.return,r,e),l.lanes|=r;break}u=u.next}}else if(o.tag===10)s=o.type===e.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(I(341));s.lanes|=r,l=s.alternate,l!==null&&(l.lanes|=r),xb(s,r,e),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===e){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Nt(t,e,i.children,r),e=e.child}return e;case 9:return i=e.type,n=e.pendingProps.children,ma(e,r),i=Or(i),n=n(i),e.flags|=1,Nt(t,e,n,r),e.child;case 14:return n=e.type,i=Yr(n,e.pendingProps),i=Yr(n.type,i),Jx(t,e,n,i,r);case 15:return _1(t,e,e.type,e.pendingProps,r);case 17:return n=e.type,i=e.pendingProps,i=e.elementType===n?i:Yr(n,i),lf(t,e),e.tag=1,sr(n)?(t=!0,jf(e)):t=!1,ma(e,r),v1(e,n,i),Ab(e,n,i,r),Tb(null,e,n,!0,t,r);case 19:return C1(t,e,r);case 22:return x1(t,e,r)}throw Error(I(156,e.tag))};function z1(t,e){return mS(t,e)}function TM(t,e,r,n){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pr(t,e,r,n){return new TM(t,e,r,n)}function t0(t){return t=t.prototype,!(!t||!t.isReactComponent)}function kM(t){if(typeof t=="function")return t0(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Ev)return 11;if(t===wv)return 14}return 2}function lo(t,e){var r=t.alternate;return r===null?(r=Pr(t.tag,e,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=e,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,e=t.dependencies,r.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function df(t,e,r,n,i,o){var s=2;if(n=t,typeof t=="function")t0(t)&&(s=1);else if(typeof t=="string")s=5;else e:switch(t){case ta:return Es(r.children,i,o,e);case vv:s=8,i|=8;break;case Wg:return t=Pr(12,r,e,i|2),t.elementType=Wg,t.lanes=o,t;case Jg:return t=Pr(13,r,e,i),t.elementType=Jg,t.lanes=o,t;case Zg:return t=Pr(19,r,e,i),t.elementType=Zg,t.lanes=o,t;case YA:return Lh(r,i,o,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case ZA:s=10;break e;case QA:s=9;break e;case Ev:s=11;break e;case wv:s=14;break e;case qi:s=16,n=null;break e}throw Error(I(130,t==null?t:typeof t,""))}return e=Pr(s,r,e,i),e.elementType=t,e.type=n,e.lanes=o,e}function Es(t,e,r,n){return t=Pr(7,t,n,e),t.lanes=r,t}function Lh(t,e,r,n){return t=Pr(22,t,n,e),t.elementType=YA,t.lanes=r,t.stateNode={isHidden:!1},t}function dg(t,e,r){return t=Pr(6,t,null,e),t.lanes=r,t}function pg(t,e,r){return e=Pr(4,t.children!==null?t.children:[],t.key,e),e.lanes=r,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function LM(t,e,r,n,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Gm(0),this.expirationTimes=Gm(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Gm(0),this.identifierPrefix=n,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function r0(t,e,r,n,i,o,s,l,u){return t=new LM(t,e,r,l,u),e===1?(e=1,o===!0&&(e|=8)):e=0,o=Pr(3,null,null,e),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},Kv(o),t}function PM(t,e,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(H1)}catch(t){console.error(t)}}H1(),HA.exports=_r;var UM=HA.exports,cR=UM;Hg.createRoot=cR.createRoot,Hg.hydrateRoot=cR.hydrateRoot;var Vb={};Symbol.dispose??(Symbol.dispose=Symbol("@@dispose"));Symbol.asyncDispose??(Symbol.asyncDispose=Symbol("@@asyncDispose"));var jh={},X1={},G={},Mb={},Nb={},Po={},Uh={},Ln={},jc={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getParsedType=t.ZodParsedType=t.objectUtil=t.util=void 0;var e;(function(i){i.assertEqual=u=>{};function o(u){}i.assertIs=o;function s(u){throw new Error}i.assertNever=s,i.arrayToEnum=u=>{const c={};for(const d of u)c[d]=d;return c},i.getValidEnumValues=u=>{const c=i.objectKeys(u).filter(f=>typeof u[u[f]]!="number"),d={};for(const f of c)d[f]=u[f];return i.objectValues(d)},i.objectValues=u=>i.objectKeys(u).map(function(c){return u[c]}),i.objectKeys=typeof Object.keys=="function"?u=>Object.keys(u):u=>{const c=[];for(const d in u)Object.prototype.hasOwnProperty.call(u,d)&&c.push(d);return c},i.find=(u,c)=>{for(const d of u)if(c(d))return d},i.isInteger=typeof Number.isInteger=="function"?u=>Number.isInteger(u):u=>typeof u=="number"&&Number.isFinite(u)&&Math.floor(u)===u;function l(u,c=" | "){return u.map(d=>typeof d=="string"?`'${d}'`:d).join(c)}i.joinValues=l,i.jsonStringifyReplacer=(u,c)=>typeof c=="bigint"?c.toString():c})(e||(t.util=e={}));var r;(function(i){i.mergeShapes=(o,s)=>({...o,...s})})(r||(t.objectUtil=r={})),t.ZodParsedType=e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);const n=i=>{switch(typeof i){case"undefined":return t.ZodParsedType.undefined;case"string":return t.ZodParsedType.string;case"number":return Number.isNaN(i)?t.ZodParsedType.nan:t.ZodParsedType.number;case"boolean":return t.ZodParsedType.boolean;case"function":return t.ZodParsedType.function;case"bigint":return t.ZodParsedType.bigint;case"symbol":return t.ZodParsedType.symbol;case"object":return Array.isArray(i)?t.ZodParsedType.array:i===null?t.ZodParsedType.null:i.then&&typeof i.then=="function"&&i.catch&&typeof i.catch=="function"?t.ZodParsedType.promise:typeof Map<"u"&&i instanceof Map?t.ZodParsedType.map:typeof Set<"u"&&i instanceof Set?t.ZodParsedType.set:typeof Date<"u"&&i instanceof Date?t.ZodParsedType.date:t.ZodParsedType.object;default:return t.ZodParsedType.unknown}};t.getParsedType=n})(jc);Object.defineProperty(Ln,"__esModule",{value:!0});Ln.ZodError=Ln.quotelessJson=Ln.ZodIssueCode=void 0;const W1=jc;Ln.ZodIssueCode=W1.util.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);const $M=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");Ln.quotelessJson=$M;class pc extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(o){return o.message},n={_errors:[]},i=o=>{for(const s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let l=n,u=0;for(;ur.message){const r={},n=[];for(const i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}Ln.ZodError=pc;pc.create=t=>new pc(t);Object.defineProperty(Uh,"__esModule",{value:!0});const Ct=Ln,Qo=jc,OM=(t,e)=>{let r;switch(t.code){case Ct.ZodIssueCode.invalid_type:t.received===Qo.ZodParsedType.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case Ct.ZodIssueCode.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Qo.util.jsonStringifyReplacer)}`;break;case Ct.ZodIssueCode.unrecognized_keys:r=`Unrecognized key(s) in object: ${Qo.util.joinValues(t.keys,", ")}`;break;case Ct.ZodIssueCode.invalid_union:r="Invalid input";break;case Ct.ZodIssueCode.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Qo.util.joinValues(t.options)}`;break;case Ct.ZodIssueCode.invalid_enum_value:r=`Invalid enum value. Expected ${Qo.util.joinValues(t.options)}, received '${t.received}'`;break;case Ct.ZodIssueCode.invalid_arguments:r="Invalid function arguments";break;case Ct.ZodIssueCode.invalid_return_type:r="Invalid function return type";break;case Ct.ZodIssueCode.invalid_date:r="Invalid date";break;case Ct.ZodIssueCode.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Qo.util.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case Ct.ZodIssueCode.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case Ct.ZodIssueCode.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case Ct.ZodIssueCode.custom:r="Invalid input";break;case Ct.ZodIssueCode.invalid_intersection_types:r="Intersection results could not be merged";break;case Ct.ZodIssueCode.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case Ct.ZodIssueCode.not_finite:r="Number must be finite";break;default:r=e.defaultError,Qo.util.assertNever(t)}return{message:r}};Uh.default=OM;var KM=S&&S.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Po,"__esModule",{value:!0});Po.defaultErrorMap=void 0;Po.setErrorMap=VM;Po.getErrorMap=MM;const J1=KM(Uh);Po.defaultErrorMap=J1.default;let Z1=J1.default;function VM(t){Z1=t}function MM(){return Z1}var s0={};(function(t){var e=S&&S.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(t,"__esModule",{value:!0}),t.isAsync=t.isValid=t.isDirty=t.isAborted=t.OK=t.DIRTY=t.INVALID=t.ParseStatus=t.EMPTY_PATH=t.makeIssue=void 0,t.addIssueToContext=o;const r=Po,n=e(Uh),i=g=>{const{data:b,path:w,errorMaps:C,issueData:y}=g,m=[...w,...y.path||[]],E={...y,path:m};if(y.message!==void 0)return{...y,path:m,message:y.message};let A="";const L=C.filter(D=>!!D).slice().reverse();for(const D of L)A=D(E,{data:b,defaultError:A}).message;return{...y,path:m,message:A}};t.makeIssue=i,t.EMPTY_PATH=[];function o(g,b){const w=(0,r.getErrorMap)(),C=(0,t.makeIssue)({issueData:b,data:g.data,path:g.path,errorMaps:[g.common.contextualErrorMap,g.schemaErrorMap,w,w===n.default?void 0:n.default].filter(y=>!!y)});g.common.issues.push(C)}class s{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(b,w){const C=[];for(const y of w){if(y.status==="aborted")return t.INVALID;y.status==="dirty"&&b.dirty(),C.push(y.value)}return{status:b.value,value:C}}static async mergeObjectAsync(b,w){const C=[];for(const y of w){const m=await y.key,E=await y.value;C.push({key:m,value:E})}return s.mergeObjectSync(b,C)}static mergeObjectSync(b,w){const C={};for(const y of w){const{key:m,value:E}=y;if(m.status==="aborted"||E.status==="aborted")return t.INVALID;m.status==="dirty"&&b.dirty(),E.status==="dirty"&&b.dirty(),m.value!=="__proto__"&&(typeof E.value<"u"||y.alwaysSet)&&(C[m.value]=E.value)}return{status:b.value,value:C}}}t.ParseStatus=s,t.INVALID=Object.freeze({status:"aborted"});const l=g=>({status:"dirty",value:g});t.DIRTY=l;const u=g=>({status:"valid",value:g});t.OK=u;const c=g=>g.status==="aborted";t.isAborted=c;const d=g=>g.status==="dirty";t.isDirty=d;const f=g=>g.status==="valid";t.isValid=f;const h=g=>typeof Promise<"u"&&g instanceof Promise;t.isAsync=h})(s0);var Q1={};Object.defineProperty(Q1,"__esModule",{value:!0});var T={},$h={};Object.defineProperty($h,"__esModule",{value:!0});$h.errorUtil=void 0;var dR;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(dR||($h.errorUtil=dR={}));Object.defineProperty(T,"__esModule",{value:!0});T.discriminatedUnion=T.date=T.boolean=T.bigint=T.array=T.any=T.coerce=T.ZodFirstPartyTypeKind=T.late=T.ZodSchema=T.Schema=T.ZodReadonly=T.ZodPipeline=T.ZodBranded=T.BRAND=T.ZodNaN=T.ZodCatch=T.ZodDefault=T.ZodNullable=T.ZodOptional=T.ZodTransformer=T.ZodEffects=T.ZodPromise=T.ZodNativeEnum=T.ZodEnum=T.ZodLiteral=T.ZodLazy=T.ZodFunction=T.ZodSet=T.ZodMap=T.ZodRecord=T.ZodTuple=T.ZodIntersection=T.ZodDiscriminatedUnion=T.ZodUnion=T.ZodObject=T.ZodArray=T.ZodVoid=T.ZodNever=T.ZodUnknown=T.ZodAny=T.ZodNull=T.ZodUndefined=T.ZodSymbol=T.ZodDate=T.ZodBoolean=T.ZodBigInt=T.ZodNumber=T.ZodString=T.ZodType=void 0;T.NEVER=T.void=T.unknown=T.union=T.undefined=T.tuple=T.transformer=T.symbol=T.string=T.strictObject=T.set=T.record=T.promise=T.preprocess=T.pipeline=T.ostring=T.optional=T.onumber=T.oboolean=T.object=T.number=T.nullable=T.null=T.never=T.nativeEnum=T.nan=T.map=T.literal=T.lazy=T.intersection=T.instanceof=T.function=T.enum=T.effect=void 0;T.datetimeRegex=tC;T.custom=nC;const $=Ln,Cp=Po,X=$h,k=s0,K=jc;class Un{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const pR=(t,e)=>{if((0,k.isValid)(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new $.ZodError(t.common.issues);return this._error=r,this._error}}};function re(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,l)=>{const{message:u}=t;return s.code==="invalid_enum_value"?{message:u??l.defaultError}:typeof l.data>"u"?{message:u??n??l.defaultError}:s.code!=="invalid_type"?{message:l.defaultError}:{message:u??r??l.defaultError}},description:i}}class oe{get description(){return this._def.description}_getType(e){return(0,K.getParsedType)(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:(0,K.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new k.ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:(0,K.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if((0,k.isAsync)(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){const n={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,K.getParsedType)(e)},i=this._parseSync({data:e,path:n.path,parent:n});return pR(n,i)}"~validate"(e){var n,i;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,K.getParsedType)(e)};if(!this["~standard"].async)try{const o=this._parseSync({data:e,path:[],parent:r});return(0,k.isValid)(o)?{value:o.value}:{issues:r.common.issues}}catch(o){(i=(n=o==null?void 0:o.message)==null?void 0:n.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(o=>(0,k.isValid)(o)?{value:o.value}:{issues:r.common.issues})}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,K.getParsedType)(e)},i=this._parse({data:e,path:n.path,parent:n}),o=await((0,k.isAsync)(i)?i:Promise.resolve(i));return pR(n,o)}refine(e,r){const n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,o)=>{const s=e(i),l=()=>o.addIssue({code:$.ZodIssueCode.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(l(),!1)):s?!0:(l(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new bn({schema:this,typeName:Y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Pn.create(this,this._def)}nullable(){return go.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return mn.create(this)}promise(){return Pa.create(this,this._def)}or(e){return mc.create([this,e],this._def)}and(e){return gc.create(this,e,this._def)}transform(e){return new bn({...re(this._def),schema:this,typeName:Y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new _c({...re(this._def),innerType:this,defaultValue:r,typeName:Y.ZodDefault})}brand(){return new a0({typeName:Y.ZodBranded,type:this,...re(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new xc({...re(this._def),innerType:this,catchValue:r,typeName:Y.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Uc.create(this,e)}readonly(){return Rc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}T.ZodType=oe;T.Schema=oe;T.ZodSchema=oe;const NM=/^c[^\s-]{8,}$/i,zM=/^[0-9a-z]+$/,FM=/^[0-9A-HJKMNP-TV-Z]{26}$/i,qM=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,GM=/^[a-z0-9_-]{21}$/i,HM=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,XM=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,WM=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,JM="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let fg;const ZM=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,QM=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,YM=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,eN=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,tN=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,rN=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Y1="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",nN=new RegExp(`^${Y1}$`);function eC(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function iN(t){return new RegExp(`^${eC(t)}$`)}function tC(t){let e=`${Y1}T${eC(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function oN(t,e){return!!((e==="v4"||!e)&&ZM.test(t)||(e==="v6"||!e)&&YM.test(t))}function sN(t,e){if(!HM.test(t))return!1;try{const[r]=t.split("."),n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function aN(t,e){return!!((e==="v4"||!e)&&QM.test(t)||(e==="v6"||!e)&&eN.test(t))}class pn extends oe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==K.ZodParsedType.string){const o=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(o,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.string,received:o.parsedType}),k.INVALID}const n=new k.ParseStatus;let i;for(const o of this._def.checks)if(o.kind==="min")e.data.lengtho.value&&(i=this._getOrReturnCtx(e,i),(0,k.addIssueToContext)(i,{code:$.ZodIssueCode.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){const s=e.data.length>o.value,l=e.data.lengthe.test(i),{validation:r,code:$.ZodIssueCode.invalid_string,...X.errorUtil.errToObj(n)})}_addCheck(e){return new pn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...X.errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:"url",...X.errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...X.errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...X.errorUtil.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...X.errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...X.errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...X.errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...X.errorUtil.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...X.errorUtil.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...X.errorUtil.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...X.errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...X.errorUtil.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...X.errorUtil.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...X.errorUtil.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...X.errorUtil.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...X.errorUtil.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...X.errorUtil.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...X.errorUtil.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...X.errorUtil.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...X.errorUtil.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...X.errorUtil.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...X.errorUtil.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...X.errorUtil.errToObj(r)})}nonempty(e){return this.min(1,X.errorUtil.errToObj(e))}trim(){return new pn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new pn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new pn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew pn({checks:[],typeName:Y.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...re(t)});function lN(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(t.toFixed(i).replace(".","")),s=Number.parseInt(e.toFixed(i).replace(".",""));return o%s/10**i}class ho extends oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==K.ZodParsedType.number){const o=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(o,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.number,received:o.parsedType}),k.INVALID}let n;const i=new k.ParseStatus;for(const o of this._def.checks)o.kind==="int"?K.util.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?e.datao.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?lN(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.not_finite,message:o.message}),i.dirty()):K.util.assertNever(o);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,X.errorUtil.toString(r))}gt(e,r){return this.setLimit("min",e,!1,X.errorUtil.toString(r))}lte(e,r){return this.setLimit("max",e,!0,X.errorUtil.toString(r))}lt(e,r){return this.setLimit("max",e,!1,X.errorUtil.toString(r))}setLimit(e,r,n,i){return new ho({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:X.errorUtil.toString(i)}]})}_addCheck(e){return new ho({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:X.errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:X.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:X.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:X.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:X.errorUtil.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:X.errorUtil.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:X.errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:X.errorUtil.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:X.errorUtil.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.valuee.kind==="int"||e.kind==="multipleOf"&&K.util.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.valuenew ho({checks:[],typeName:Y.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...re(t)});class yo extends oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==K.ZodParsedType.bigint)return this._getInvalidInput(e);let n;const i=new k.ParseStatus;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?e.datao.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):K.util.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(r,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.bigint,received:r.parsedType}),k.INVALID}gte(e,r){return this.setLimit("min",e,!0,X.errorUtil.toString(r))}gt(e,r){return this.setLimit("min",e,!1,X.errorUtil.toString(r))}lte(e,r){return this.setLimit("max",e,!0,X.errorUtil.toString(r))}lt(e,r){return this.setLimit("max",e,!1,X.errorUtil.toString(r))}setLimit(e,r,n,i){return new yo({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:X.errorUtil.toString(i)}]})}_addCheck(e){return new yo({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:X.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:X.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:X.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:X.errorUtil.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:X.errorUtil.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew yo({checks:[],typeName:Y.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...re(t)});class fc extends oe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==K.ZodParsedType.boolean){const n=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.boolean,received:n.parsedType}),k.INVALID}return(0,k.OK)(e.data)}}T.ZodBoolean=fc;fc.create=t=>new fc({typeName:Y.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...re(t)});class Ts extends oe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==K.ZodParsedType.date){const o=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(o,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.date,received:o.parsedType}),k.INVALID}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(o,{code:$.ZodIssueCode.invalid_date}),k.INVALID}const n=new k.ParseStatus;let i;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()o.value&&(i=this._getOrReturnCtx(e,i),(0,k.addIssueToContext)(i,{code:$.ZodIssueCode.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):K.util.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ts({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:X.errorUtil.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:X.errorUtil.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew Ts({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Y.ZodDate,...re(t)});class Wf extends oe{_parse(e){if(this._getType(e)!==K.ZodParsedType.symbol){const n=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.symbol,received:n.parsedType}),k.INVALID}return(0,k.OK)(e.data)}}T.ZodSymbol=Wf;Wf.create=t=>new Wf({typeName:Y.ZodSymbol,...re(t)});class hc extends oe{_parse(e){if(this._getType(e)!==K.ZodParsedType.undefined){const n=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.undefined,received:n.parsedType}),k.INVALID}return(0,k.OK)(e.data)}}T.ZodUndefined=hc;hc.create=t=>new hc({typeName:Y.ZodUndefined,...re(t)});class yc extends oe{_parse(e){if(this._getType(e)!==K.ZodParsedType.null){const n=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.null,received:n.parsedType}),k.INVALID}return(0,k.OK)(e.data)}}T.ZodNull=yc;yc.create=t=>new yc({typeName:Y.ZodNull,...re(t)});class La extends oe{constructor(){super(...arguments),this._any=!0}_parse(e){return(0,k.OK)(e.data)}}T.ZodAny=La;La.create=t=>new La({typeName:Y.ZodAny,...re(t)});class ws extends oe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return(0,k.OK)(e.data)}}T.ZodUnknown=ws;ws.create=t=>new ws({typeName:Y.ZodUnknown,...re(t)});class Ri extends oe{_parse(e){const r=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(r,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.never,received:r.parsedType}),k.INVALID}}T.ZodNever=Ri;Ri.create=t=>new Ri({typeName:Y.ZodNever,...re(t)});class Jf extends oe{_parse(e){if(this._getType(e)!==K.ZodParsedType.undefined){const n=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.void,received:n.parsedType}),k.INVALID}return(0,k.OK)(e.data)}}T.ZodVoid=Jf;Jf.create=t=>new Jf({typeName:Y.ZodVoid,...re(t)});class mn extends oe{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==K.ZodParsedType.array)return(0,k.addIssueToContext)(r,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.array,received:r.parsedType}),k.INVALID;if(i.exactLength!==null){const s=r.data.length>i.exactLength.value,l=r.data.lengthi.maxLength.value&&((0,k.addIssueToContext)(r,{code:$.ZodIssueCode.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,l)=>i.type._parseAsync(new Un(r,s,r.path,l)))).then(s=>k.ParseStatus.mergeArray(n,s));const o=[...r.data].map((s,l)=>i.type._parseSync(new Un(r,s,r.path,l)));return k.ParseStatus.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new mn({...this._def,minLength:{value:e,message:X.errorUtil.toString(r)}})}max(e,r){return new mn({...this._def,maxLength:{value:e,message:X.errorUtil.toString(r)}})}length(e,r){return new mn({...this._def,exactLength:{value:e,message:X.errorUtil.toString(r)}})}nonempty(e){return this.min(1,e)}}T.ZodArray=mn;mn.create=(t,e)=>new mn({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Y.ZodArray,...re(e)});function Js(t){if(t instanceof Ue){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=Pn.create(Js(n))}return new Ue({...t._def,shape:()=>e})}else return t instanceof mn?new mn({...t._def,type:Js(t.element)}):t instanceof Pn?Pn.create(Js(t.unwrap())):t instanceof go?go.create(Js(t.unwrap())):t instanceof $n?$n.create(t.items.map(e=>Js(e))):t}class Ue extends oe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=K.util.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==K.ZodParsedType.object){const c=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(c,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.object,received:c.parsedType}),k.INVALID}const{status:n,ctx:i}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),l=[];if(!(this._def.catchall instanceof Ri&&this._def.unknownKeys==="strip"))for(const c in i.data)s.includes(c)||l.push(c);const u=[];for(const c of s){const d=o[c],f=i.data[c];u.push({key:{status:"valid",value:c},value:d._parse(new Un(i,f,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Ri){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of l)u.push({key:{status:"valid",value:d},value:{status:"valid",value:i.data[d]}});else if(c==="strict")l.length>0&&((0,k.addIssueToContext)(i,{code:$.ZodIssueCode.unrecognized_keys,keys:l}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of l){const f=i.data[d];u.push({key:{status:"valid",value:d},value:c._parse(new Un(i,f,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of u){const f=await d.key,h=await d.value;c.push({key:f,value:h,alwaysSet:d.alwaysSet})}return c}).then(c=>k.ParseStatus.mergeObjectSync(n,c)):k.ParseStatus.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return X.errorUtil.errToObj,new Ue({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var o,s;const i=((s=(o=this._def).errorMap)==null?void 0:s.call(o,r,n).message)??n.defaultError;return r.code==="unrecognized_keys"?{message:X.errorUtil.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new Ue({...this._def,unknownKeys:"strip"})}passthrough(){return new Ue({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ue({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ue({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Y.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Ue({...this._def,catchall:e})}pick(e){const r={};for(const n of K.util.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Ue({...this._def,shape:()=>r})}omit(e){const r={};for(const n of K.util.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new Ue({...this._def,shape:()=>r})}deepPartial(){return Js(this)}partial(e){const r={};for(const n of K.util.objectKeys(this.shape)){const i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}return new Ue({...this._def,shape:()=>r})}required(e){const r={};for(const n of K.util.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Pn;)o=o._def.innerType;r[n]=o}return new Ue({...this._def,shape:()=>r})}keyof(){return rC(K.util.objectKeys(this.shape))}}T.ZodObject=Ue;Ue.create=(t,e)=>new Ue({shape:()=>t,unknownKeys:"strip",catchall:Ri.create(),typeName:Y.ZodObject,...re(e)});Ue.strictCreate=(t,e)=>new Ue({shape:()=>t,unknownKeys:"strict",catchall:Ri.create(),typeName:Y.ZodObject,...re(e)});Ue.lazycreate=(t,e)=>new Ue({shape:t,unknownKeys:"strip",catchall:Ri.create(),typeName:Y.ZodObject,...re(e)});class mc extends oe{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function i(o){for(const l of o)if(l.result.status==="valid")return l.result;for(const l of o)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;const s=o.map(l=>new $.ZodError(l.ctx.common.issues));return(0,k.addIssueToContext)(r,{code:$.ZodIssueCode.invalid_union,unionErrors:s}),k.INVALID}if(r.common.async)return Promise.all(n.map(async o=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let o;const s=[];for(const u of n){const c={...r,common:{...r.common,issues:[]},parent:null},d=u._parseSync({data:r.data,path:r.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!o&&(o={result:d,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;const l=s.map(u=>new $.ZodError(u));return(0,k.addIssueToContext)(r,{code:$.ZodIssueCode.invalid_union,unionErrors:l}),k.INVALID}}get options(){return this._def.options}}T.ZodUnion=mc;mc.create=(t,e)=>new mc({options:t,typeName:Y.ZodUnion,...re(e)});const ni=t=>t instanceof vc?ni(t.schema):t instanceof bn?ni(t.innerType()):t instanceof Ec?[t.value]:t instanceof mo?t.options:t instanceof wc?K.util.objectValues(t.enum):t instanceof _c?ni(t._def.innerType):t instanceof hc?[void 0]:t instanceof yc?[null]:t instanceof Pn?[void 0,...ni(t.unwrap())]:t instanceof go?[null,...ni(t.unwrap())]:t instanceof a0||t instanceof Rc?ni(t.unwrap()):t instanceof xc?ni(t._def.innerType):[];class Oh extends oe{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==K.ZodParsedType.object)return(0,k.addIssueToContext)(r,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.object,received:r.parsedType}),k.INVALID;const n=this.discriminator,i=r.data[n],o=this.optionsMap.get(i);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):((0,k.addIssueToContext)(r,{code:$.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),k.INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const i=new Map;for(const o of r){const s=ni(o.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const l of s){if(i.has(l))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(l)}`);i.set(l,o)}}return new Oh({typeName:Y.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...re(n)})}}T.ZodDiscriminatedUnion=Oh;function zb(t,e){const r=(0,K.getParsedType)(t),n=(0,K.getParsedType)(e);if(t===e)return{valid:!0,data:t};if(r===K.ZodParsedType.object&&n===K.ZodParsedType.object){const i=K.util.objectKeys(e),o=K.util.objectKeys(t).filter(l=>i.indexOf(l)!==-1),s={...t,...e};for(const l of o){const u=zb(t[l],e[l]);if(!u.valid)return{valid:!1};s[l]=u.data}return{valid:!0,data:s}}else if(r===K.ZodParsedType.array&&n===K.ZodParsedType.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let o=0;o{if((0,k.isAborted)(o)||(0,k.isAborted)(s))return k.INVALID;const l=zb(o.value,s.value);return l.valid?(((0,k.isDirty)(o)||(0,k.isDirty)(s))&&r.dirty(),{status:r.value,value:l.data}):((0,k.addIssueToContext)(n,{code:$.ZodIssueCode.invalid_intersection_types}),k.INVALID)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,s])=>i(o,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}T.ZodIntersection=gc;gc.create=(t,e,r)=>new gc({left:t,right:e,typeName:Y.ZodIntersection,...re(r)});class $n extends oe{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==K.ZodParsedType.array)return(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.array,received:n.parsedType}),k.INVALID;if(n.data.lengththis._def.items.length&&((0,k.addIssueToContext)(n,{code:$.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const o=[...n.data].map((s,l)=>{const u=this._def.items[l]||this._def.rest;return u?u._parse(new Un(n,s,n.path,l)):null}).filter(s=>!!s);return n.common.async?Promise.all(o).then(s=>k.ParseStatus.mergeArray(r,s)):k.ParseStatus.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new $n({...this._def,rest:e})}}T.ZodTuple=$n;$n.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new $n({items:t,typeName:Y.ZodTuple,rest:null,...re(e)})};class bc extends oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==K.ZodParsedType.object)return(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.object,received:n.parsedType}),k.INVALID;const i=[],o=this._def.keyType,s=this._def.valueType;for(const l in n.data)i.push({key:o._parse(new Un(n,l,n.path,l)),value:s._parse(new Un(n,n.data[l],n.path,l)),alwaysSet:l in n.data});return n.common.async?k.ParseStatus.mergeObjectAsync(r,i):k.ParseStatus.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof oe?new bc({keyType:e,valueType:r,typeName:Y.ZodRecord,...re(n)}):new bc({keyType:pn.create(),valueType:e,typeName:Y.ZodRecord,...re(r)})}}T.ZodRecord=bc;class Zf extends oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==K.ZodParsedType.map)return(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.map,received:n.parsedType}),k.INVALID;const i=this._def.keyType,o=this._def.valueType,s=[...n.data.entries()].map(([l,u],c)=>({key:i._parse(new Un(n,l,n.path,[c,"key"])),value:o._parse(new Un(n,u,n.path,[c,"value"]))}));if(n.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const u of s){const c=await u.key,d=await u.value;if(c.status==="aborted"||d.status==="aborted")return k.INVALID;(c.status==="dirty"||d.status==="dirty")&&r.dirty(),l.set(c.value,d.value)}return{status:r.value,value:l}})}else{const l=new Map;for(const u of s){const c=u.key,d=u.value;if(c.status==="aborted"||d.status==="aborted")return k.INVALID;(c.status==="dirty"||d.status==="dirty")&&r.dirty(),l.set(c.value,d.value)}return{status:r.value,value:l}}}}T.ZodMap=Zf;Zf.create=(t,e,r)=>new Zf({valueType:e,keyType:t,typeName:Y.ZodMap,...re(r)});class ks extends oe{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==K.ZodParsedType.set)return(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.set,received:n.parsedType}),k.INVALID;const i=this._def;i.minSize!==null&&n.data.sizei.maxSize.value&&((0,k.addIssueToContext)(n,{code:$.ZodIssueCode.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const o=this._def.valueType;function s(u){const c=new Set;for(const d of u){if(d.status==="aborted")return k.INVALID;d.status==="dirty"&&r.dirty(),c.add(d.value)}return{status:r.value,value:c}}const l=[...n.data.values()].map((u,c)=>o._parse(new Un(n,u,n.path,c)));return n.common.async?Promise.all(l).then(u=>s(u)):s(l)}min(e,r){return new ks({...this._def,minSize:{value:e,message:X.errorUtil.toString(r)}})}max(e,r){return new ks({...this._def,maxSize:{value:e,message:X.errorUtil.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}T.ZodSet=ks;ks.create=(t,e)=>new ks({valueType:t,minSize:null,maxSize:null,typeName:Y.ZodSet,...re(e)});class ba extends oe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==K.ZodParsedType.function)return(0,k.addIssueToContext)(r,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.function,received:r.parsedType}),k.INVALID;function n(l,u){return(0,k.makeIssue)({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,(0,Cp.getErrorMap)(),Cp.defaultErrorMap].filter(c=>!!c),issueData:{code:$.ZodIssueCode.invalid_arguments,argumentsError:u}})}function i(l,u){return(0,k.makeIssue)({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,(0,Cp.getErrorMap)(),Cp.defaultErrorMap].filter(c=>!!c),issueData:{code:$.ZodIssueCode.invalid_return_type,returnTypeError:u}})}const o={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Pa){const l=this;return(0,k.OK)(async function(...u){const c=new $.ZodError([]),d=await l._def.args.parseAsync(u,o).catch(g=>{throw c.addIssue(n(u,g)),c}),f=await Reflect.apply(s,this,d);return await l._def.returns._def.type.parseAsync(f,o).catch(g=>{throw c.addIssue(i(f,g)),c})})}else{const l=this;return(0,k.OK)(function(...u){const c=l._def.args.safeParse(u,o);if(!c.success)throw new $.ZodError([n(u,c.error)]);const d=Reflect.apply(s,this,c.data),f=l._def.returns.safeParse(d,o);if(!f.success)throw new $.ZodError([i(d,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ba({...this._def,args:$n.create(e).rest(ws.create())})}returns(e){return new ba({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new ba({args:e||$n.create([]).rest(ws.create()),returns:r||ws.create(),typeName:Y.ZodFunction,...re(n)})}}T.ZodFunction=ba;class vc extends oe{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}T.ZodLazy=vc;vc.create=(t,e)=>new vc({getter:t,typeName:Y.ZodLazy,...re(e)});class Ec extends oe{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(r,{received:r.data,code:$.ZodIssueCode.invalid_literal,expected:this._def.value}),k.INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}}T.ZodLiteral=Ec;Ec.create=(t,e)=>new Ec({value:t,typeName:Y.ZodLiteral,...re(e)});function rC(t,e){return new mo({values:t,typeName:Y.ZodEnum,...re(e)})}class mo extends oe{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return(0,k.addIssueToContext)(r,{expected:K.util.joinValues(n),received:r.parsedType,code:$.ZodIssueCode.invalid_type}),k.INVALID}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return(0,k.addIssueToContext)(r,{received:r.data,code:$.ZodIssueCode.invalid_enum_value,options:n}),k.INVALID}return(0,k.OK)(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return mo.create(e,{...this._def,...r})}exclude(e,r=this._def){return mo.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}T.ZodEnum=mo;mo.create=rC;class wc extends oe{_parse(e){const r=K.util.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==K.ZodParsedType.string&&n.parsedType!==K.ZodParsedType.number){const i=K.util.objectValues(r);return(0,k.addIssueToContext)(n,{expected:K.util.joinValues(i),received:n.parsedType,code:$.ZodIssueCode.invalid_type}),k.INVALID}if(this._cache||(this._cache=new Set(K.util.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=K.util.objectValues(r);return(0,k.addIssueToContext)(n,{received:n.data,code:$.ZodIssueCode.invalid_enum_value,options:i}),k.INVALID}return(0,k.OK)(e.data)}get enum(){return this._def.values}}T.ZodNativeEnum=wc;wc.create=(t,e)=>new wc({values:t,typeName:Y.ZodNativeEnum,...re(e)});class Pa extends oe{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==K.ZodParsedType.promise&&r.common.async===!1)return(0,k.addIssueToContext)(r,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.promise,received:r.parsedType}),k.INVALID;const n=r.parsedType===K.ZodParsedType.promise?r.data:Promise.resolve(r.data);return(0,k.OK)(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}T.ZodPromise=Pa;Pa.create=(t,e)=>new Pa({type:t,typeName:Y.ZodPromise,...re(e)});class bn extends oe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,o={addIssue:s=>{(0,k.addIssueToContext)(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){const s=i.transform(n.data,o);if(n.common.async)return Promise.resolve(s).then(async l=>{if(r.value==="aborted")return k.INVALID;const u=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return u.status==="aborted"?k.INVALID:u.status==="dirty"||r.value==="dirty"?(0,k.DIRTY)(u.value):u});{if(r.value==="aborted")return k.INVALID;const l=this._def.schema._parseSync({data:s,path:n.path,parent:n});return l.status==="aborted"?k.INVALID:l.status==="dirty"||r.value==="dirty"?(0,k.DIRTY)(l.value):l}}if(i.type==="refinement"){const s=l=>{const u=i.refinement(l,o);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(n.common.async===!1){const l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return l.status==="aborted"?k.INVALID:(l.status==="dirty"&&r.dirty(),s(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>l.status==="aborted"?k.INVALID:(l.status==="dirty"&&r.dirty(),s(l.value).then(()=>({status:r.value,value:l.value}))))}if(i.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!(0,k.isValid)(s))return k.INVALID;const l=i.transform(s.value,o);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>(0,k.isValid)(s)?Promise.resolve(i.transform(s.value,o)).then(l=>({status:r.value,value:l})):k.INVALID);K.util.assertNever(i)}}T.ZodEffects=bn;T.ZodTransformer=bn;bn.create=(t,e,r)=>new bn({schema:t,typeName:Y.ZodEffects,effect:e,...re(r)});bn.createWithPreprocess=(t,e,r)=>new bn({schema:e,effect:{type:"preprocess",transform:t},typeName:Y.ZodEffects,...re(r)});class Pn extends oe{_parse(e){return this._getType(e)===K.ZodParsedType.undefined?(0,k.OK)(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}T.ZodOptional=Pn;Pn.create=(t,e)=>new Pn({innerType:t,typeName:Y.ZodOptional,...re(e)});class go extends oe{_parse(e){return this._getType(e)===K.ZodParsedType.null?(0,k.OK)(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}T.ZodNullable=go;go.create=(t,e)=>new go({innerType:t,typeName:Y.ZodNullable,...re(e)});class _c extends oe{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===K.ZodParsedType.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}T.ZodDefault=_c;_c.create=(t,e)=>new _c({innerType:t,typeName:Y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...re(e)});class xc extends oe{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return(0,k.isAsync)(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new $.ZodError(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new $.ZodError(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}T.ZodCatch=xc;xc.create=(t,e)=>new xc({innerType:t,typeName:Y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...re(e)});class Qf extends oe{_parse(e){if(this._getType(e)!==K.ZodParsedType.nan){const n=this._getOrReturnCtx(e);return(0,k.addIssueToContext)(n,{code:$.ZodIssueCode.invalid_type,expected:K.ZodParsedType.nan,received:n.parsedType}),k.INVALID}return{status:"valid",value:e.data}}}T.ZodNaN=Qf;Qf.create=t=>new Qf({typeName:Y.ZodNaN,...re(t)});T.BRAND=Symbol("zod_brand");class a0 extends oe{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}T.ZodBranded=a0;class Uc extends oe{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?k.INVALID:o.status==="dirty"?(r.dirty(),(0,k.DIRTY)(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?k.INVALID:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new Uc({in:e,out:r,typeName:Y.ZodPipeline})}}T.ZodPipeline=Uc;class Rc extends oe{_parse(e){const r=this._def.innerType._parse(e),n=i=>((0,k.isValid)(i)&&(i.value=Object.freeze(i.value)),i);return(0,k.isAsync)(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}}T.ZodReadonly=Rc;Rc.create=(t,e)=>new Rc({innerType:t,typeName:Y.ZodReadonly,...re(e)});function fR(t,e){const r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function nC(t,e={},r){return t?La.create().superRefine((n,i)=>{const o=t(n);if(o instanceof Promise)return o.then(s=>{if(!s){const l=fR(e,n),u=l.fatal??r??!0;i.addIssue({code:"custom",...l,fatal:u})}});if(!o){const s=fR(e,n),l=s.fatal??r??!0;i.addIssue({code:"custom",...s,fatal:l})}}):La.create()}T.late={object:Ue.lazycreate};var Y;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Y||(T.ZodFirstPartyTypeKind=Y={}));const uN=(t,e={message:`Input not instance of ${t.name}`})=>nC(r=>r instanceof t,e);T.instanceof=uN;const iC=pn.create;T.string=iC;const oC=ho.create;T.number=oC;const cN=Qf.create;T.nan=cN;const dN=yo.create;T.bigint=dN;const sC=fc.create;T.boolean=sC;const pN=Ts.create;T.date=pN;const fN=Wf.create;T.symbol=fN;const hN=hc.create;T.undefined=hN;const yN=yc.create;T.null=yN;const mN=La.create;T.any=mN;const gN=ws.create;T.unknown=gN;const bN=Ri.create;T.never=bN;const vN=Jf.create;T.void=vN;const EN=mn.create;T.array=EN;const wN=Ue.create;T.object=wN;const _N=Ue.strictCreate;T.strictObject=_N;const xN=mc.create;T.union=xN;const RN=Oh.create;T.discriminatedUnion=RN;const AN=gc.create;T.intersection=AN;const SN=$n.create;T.tuple=SN;const CN=bc.create;T.record=CN;const TN=Zf.create;T.map=TN;const kN=ks.create;T.set=kN;const LN=ba.create;T.function=LN;const PN=vc.create;T.lazy=PN;const DN=Ec.create;T.literal=DN;const BN=mo.create;T.enum=BN;const IN=wc.create;T.nativeEnum=IN;const jN=Pa.create;T.promise=jN;const aC=bn.create;T.effect=aC;T.transformer=aC;const UN=Pn.create;T.optional=UN;const $N=go.create;T.nullable=$N;const ON=bn.createWithPreprocess;T.preprocess=ON;const KN=Uc.create;T.pipeline=KN;const VN=()=>iC().optional();T.ostring=VN;const MN=()=>oC().optional();T.onumber=MN;const NN=()=>sC().optional();T.oboolean=NN;T.coerce={string:t=>pn.create({...t,coerce:!0}),number:t=>ho.create({...t,coerce:!0}),boolean:t=>fc.create({...t,coerce:!0}),bigint:t=>yo.create({...t,coerce:!0}),date:t=>Ts.create({...t,coerce:!0})};T.NEVER=k.INVALID;(function(t){var e=S&&S.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=S&&S.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&e(i,n,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(Po,t),r(s0,t),r(Q1,t),r(jc,t),r(T,t),r(Ln,t)})(Nb);(function(t){var e=S&&S.__createBinding||(Object.create?function(s,l,u,c){c===void 0&&(c=u);var d=Object.getOwnPropertyDescriptor(l,u);(!d||("get"in d?!l.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return l[u]}}),Object.defineProperty(s,c,d)}:function(s,l,u,c){c===void 0&&(c=u),s[c]=l[u]}),r=S&&S.__setModuleDefault||(Object.create?function(s,l){Object.defineProperty(s,"default",{enumerable:!0,value:l})}:function(s,l){s.default=l}),n=S&&S.__importStar||function(s){if(s&&s.__esModule)return s;var l={};if(s!=null)for(var u in s)u!=="default"&&Object.prototype.hasOwnProperty.call(s,u)&&e(l,s,u);return r(l,s),l},i=S&&S.__exportStar||function(s,l){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(l,u)&&e(l,s,u)};Object.defineProperty(t,"__esModule",{value:!0}),t.z=void 0;const o=n(Nb);t.z=o,i(Nb,t),t.default=o})(Mb);(function(t){var e=S&&S.__createBinding||(Object.create?function(o,s,l,u){u===void 0&&(u=l);var c=Object.getOwnPropertyDescriptor(s,l);(!c||("get"in c?!s.__esModule:c.writable||c.configurable))&&(c={enumerable:!0,get:function(){return s[l]}}),Object.defineProperty(o,u,c)}:function(o,s,l,u){u===void 0&&(u=l),o[u]=s[l]}),r=S&&S.__exportStar||function(o,s){for(var l in o)l!=="default"&&!Object.prototype.hasOwnProperty.call(s,l)&&e(s,o,l)},n=S&&S.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(Mb);r(Mb,t),t.default=i.default})(G);var Si={},Kh={},Va={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.JwtVerifyError=t.JwtCreateError=t.JwkError=t.ERR_JWT_VERIFY=t.ERR_JWT_CREATE=t.ERR_JWT_INVALID=t.ERR_JWK_NOT_FOUND=t.ERR_JWK_INVALID=t.ERR_JWKS_NO_MATCHING_KEY=void 0,t.ERR_JWKS_NO_MATCHING_KEY="ERR_JWKS_NO_MATCHING_KEY",t.ERR_JWK_INVALID="ERR_JWK_INVALID",t.ERR_JWK_NOT_FOUND="ERR_JWK_NOT_FOUND",t.ERR_JWT_INVALID="ERR_JWT_INVALID",t.ERR_JWT_CREATE="ERR_JWT_CREATE",t.ERR_JWT_VERIFY="ERR_JWT_VERIFY";class e extends TypeError{constructor(o="JWK error",s=t.ERR_JWK_INVALID,l){super(o,l),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:s})}}t.JwkError=e;class r extends Error{constructor(o="Unable to create JWT",s=t.ERR_JWT_CREATE,l){super(o,l),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:s})}static from(o,s,l){return o instanceof r?o:o instanceof e?new r(l,o.code,{cause:o}):new r(l,s,{cause:o})}}t.JwtCreateError=r;class n extends Error{constructor(o="Invalid JWT",s=t.ERR_JWT_VERIFY,l){super(o,l),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:s})}static from(o,s,l){return o instanceof n?o:o instanceof e?new n(l,o.code,{cause:o}):new n(l,s,{cause:o})}}t.JwtVerifyError=n})(Va);Object.defineProperty(Kh,"__esModule",{value:!0});Kh.jwkAlgorithms=zN;const hg=Va,{process:Tp}=globalThis;var kA;const hR=typeof Tp<"u"&&typeof((kA=Tp==null?void 0:Tp.versions)==null?void 0:kA.node)=="string";function*zN(t){if(t.alg){yield t.alg;return}switch(t.kty){case"EC":{if((t.use==="enc"||t.use===void 0)&&(yield"ECDH-ES",yield"ECDH-ES+A128KW",yield"ECDH-ES+A192KW",yield"ECDH-ES+A256KW"),t.use==="sig"||t.use===void 0){const e="crv"in t?t.crv:void 0;switch(e){case"P-256":case"P-384":yield`ES${e.slice(-3)}`;break;case"P-521":yield"ES512";break;case"secp256k1":hR&&(yield"ES256K");break;default:throw new hg.JwkError(`Unsupported crv "${e}"`)}}return}case"OKP":{if(!t.use)throw new hg.JwkError('Missing "use" Parameter value');yield"ECDH-ES",yield"ECDH-ES+A128KW",yield"ECDH-ES+A192KW",yield"ECDH-ES+A256KW";return}case"RSA":{(t.use==="enc"||t.use===void 0)&&(yield"RSA-OAEP",yield"RSA-OAEP-256",yield"RSA-OAEP-384",yield"RSA-OAEP-512",hR&&(yield"RSA1_5")),(t.use==="sig"||t.use===void 0)&&(yield"PS256",yield"PS384",yield"PS512",yield"RS256",yield"RS384",yield"RS512");return}case"oct":{(t.use==="enc"||t.use===void 0)&&(yield"A128GCMKW",yield"A192GCMKW",yield"A256GCMKW",yield"A128KW",yield"A192KW",yield"A256KW"),(t.use==="sig"||t.use===void 0)&&(yield"HS256",yield"HS384",yield"HS512");return}default:throw new hg.JwkError(`Unsupported kty "${t.kty}"`)}}var $c={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.jwkPubSchema=t.jwkValidator=t.jwkSchema=t.jwkUnknownKeySchema=t.jwkSymKeySchema=t.jwkOkpKeySchema=t.jwkEcSecp256k1KeySchema=t.jwkEcKeySchema=t.jwkRsaKeySchema=t.jwkBaseSchema=t.keyUsageSchema=void 0;const e=G;t.keyUsageSchema=e.z.enum(["sign","verify","encrypt","decrypt","wrapKey","unwrapKey","deriveKey","deriveBits"]),t.jwkBaseSchema=e.z.object({kty:e.z.string().min(1),alg:e.z.string().min(1).optional(),kid:e.z.string().min(1).optional(),ext:e.z.boolean().optional(),use:e.z.enum(["sig","enc"]).optional(),key_ops:e.z.array(t.keyUsageSchema).optional(),x5c:e.z.array(e.z.string()).optional(),x5t:e.z.string().min(1).optional(),"x5t#S256":e.z.string().min(1).optional(),x5u:e.z.string().url().optional()}),t.jwkRsaKeySchema=t.jwkBaseSchema.extend({kty:e.z.literal("RSA"),alg:e.z.enum(["RS256","RS384","RS512","PS256","PS384","PS512"]).optional(),n:e.z.string().min(1),e:e.z.string().min(1),d:e.z.string().min(1).optional(),p:e.z.string().min(1).optional(),q:e.z.string().min(1).optional(),dp:e.z.string().min(1).optional(),dq:e.z.string().min(1).optional(),qi:e.z.string().min(1).optional(),oth:e.z.array(e.z.object({r:e.z.string().optional(),d:e.z.string().optional(),t:e.z.string().optional()})).nonempty().optional()}),t.jwkEcKeySchema=t.jwkBaseSchema.extend({kty:e.z.literal("EC"),alg:e.z.enum(["ES256","ES384","ES512"]).optional(),crv:e.z.enum(["P-256","P-384","P-521"]),x:e.z.string().min(1),y:e.z.string().min(1),d:e.z.string().min(1).optional()}),t.jwkEcSecp256k1KeySchema=t.jwkBaseSchema.extend({kty:e.z.literal("EC"),alg:e.z.enum(["ES256K"]).optional(),crv:e.z.enum(["secp256k1"]),x:e.z.string().min(1),y:e.z.string().min(1),d:e.z.string().min(1).optional()}),t.jwkOkpKeySchema=t.jwkBaseSchema.extend({kty:e.z.literal("OKP"),alg:e.z.enum(["EdDSA"]).optional(),crv:e.z.enum(["Ed25519","Ed448"]),x:e.z.string().min(1),d:e.z.string().min(1).optional()}),t.jwkSymKeySchema=t.jwkBaseSchema.extend({kty:e.z.literal("oct"),alg:e.z.enum(["HS256","HS384","HS512"]).optional(),k:e.z.string()}),t.jwkUnknownKeySchema=t.jwkBaseSchema.extend({kty:e.z.string().refine(r=>r!=="RSA"&&r!=="EC"&&r!=="OKP"&&r!=="oct")}),t.jwkSchema=e.z.union([t.jwkUnknownKeySchema,t.jwkRsaKeySchema,t.jwkEcKeySchema,t.jwkEcSecp256k1KeySchema,t.jwkOkpKeySchema,t.jwkSymKeySchema]),t.jwkValidator=t.jwkSchema.refine(r=>r.use!=null||r.key_ops!=null,"use or key_ops required").refine(r=>!r.use||!r.key_ops||r.key_ops.every(n=>r.use==="sig"?n==="sign"||n==="verify":n==="encrypt"||n==="decrypt"),"use and key_ops must be consistent"),t.jwkPubSchema=t.jwkValidator.refine(r=>r.kid!=null,"kid is required").refine(r=>!("k"in r)&&!("d"in r),"private key not allowed")})($c);var Da={};Object.defineProperty(Da,"__esModule",{value:!0});Da.jwksPubSchema=Da.jwksSchema=void 0;const Yf=G,lC=$c;Da.jwksSchema=Yf.z.object({keys:Yf.z.array(lC.jwkSchema)});Da.jwksPubSchema=Yf.z.object({keys:Yf.z.array(lC.jwkPubSchema)});var Vh={},l0={},ht={};function FN(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,A=new Uint8Array(E);y!==m;){for(var L=b[y],D=0,B=E-1;(L!==0||D>>0,A[B]=L%l>>>0,L=L/l>>>0;if(L!==0)throw new Error("Non-zero carry");C=D,y++}for(var j=E-C;j!==E&&A[j]===0;)j++;for(var pe=u.repeat(w);j>>0,E=new Uint8Array(m);b[w];){var A=r[b.charCodeAt(w)];if(A===255)return;for(var L=0,D=m-1;(A!==0||L>>0,E[D]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");y=L,w++}if(b[w]!==" "){for(var B=m-y;B!==m&&E[B]===0;)B++;for(var j=new Uint8Array(C+(m-B)),pe=C;B!==m;)j[pe++]=E[B++];return j}}}function g(b){var w=h(b);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:h,decode:g}}var qN=FN,GN=qN;const HN=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},XN=t=>new TextEncoder().encode(t),WN=t=>new TextDecoder().decode(t);class JN{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class ZN{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return uC(this,e)}}class QN{constructor(e){this.decoders=e}or(e){return uC(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const uC=(t,e)=>new QN({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class YN{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new JN(e,r,n),this.decoder=new ZN(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Mh=({name:t,prefix:e,encode:r,decode:n})=>new YN(t,e,r,n),Oc=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=GN(r,e);return Mh({prefix:t,name:e,encode:n,decode:o=>u0(i(o))})},e2=(t,e,r,n)=>{const i={};for(let d=0;d=8&&(l-=8,s[c++]=255&u>>l)}if(l>=r||255&u<<8-l)throw new SyntaxError("Unexpected end of data");return s},t2=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<r;)s-=r,o+=e[i&l>>s];if(s&&(o+=e[i&l<Mh({prefix:e,name:t,encode(i){return t2(i,n,r)},decode(i){return e2(i,n,r,t)}}),r2=Rt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),n2=Rt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),i2=Rt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),o2=Rt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),cC=Object.freeze(Object.defineProperty({__proto__:null,base64:r2,base64pad:n2,base64url:i2,base64urlpad:o2},Symbol.toStringTag,{value:"Module"})),c0=bh(cC);Object.defineProperty(ht,"__esModule",{value:!0});ht.segmentedStringRefinementFactory=ht.jwtCharsRefinement=ht.cachedGetter=ht.preferredOrderCmp=ht.isDefined=void 0;ht.matchesAny=u2;ht.parseB64uJson=p2;const s2=c0,Zs=G,a2=t=>t!==void 0;ht.isDefined=a2;const l2=t=>(e,r)=>{const n=t.indexOf(e),i=t.indexOf(r);return n===i?0:n===-1?1:i===-1?-1:n-i};ht.preferredOrderCmp=l2;function u2(t){return t==null?e=>!0:Array.isArray(t)?e=>t.includes(e):e=>e===t}const c2=(t,e)=>function(){const r=t.call(this);return Object.defineProperty(this,t.name,{get:()=>r,enumerable:!0,configurable:!0}),r};ht.cachedGetter=c2;const d2=new TextDecoder;function p2(t){const e=s2.base64url.baseDecode(t),r=d2.decode(e);return JSON.parse(r)}const f2=(t,e)=>{let r;for(let n=0;n{if(!Number.isFinite(t)||t<1||(t|0)!==t)throw new TypeError(`Count must be a natural number (got ${t})`);const r=t*e+(t-1),n="Invalid JWT format";return(i,o)=>{if(i.lengtht.signedJwtSchema.safeParse(s).success;t.isSignedJwt=i,t.unsignedJwtSchema=e.z.string().superRefine(n.jwtCharsRefinement).superRefine((0,n.segmentedStringRefinementFactory)(2));const o=s=>t.unsignedJwtSchema.safeParse(s).success;t.isUnsignedJwt=o,t.jwtHeaderSchema=e.z.object({alg:e.z.string(),jku:e.z.string().url().optional(),jwk:e.z.object({kty:e.z.string(),crv:e.z.string().optional(),x:e.z.string().optional(),y:e.z.string().optional(),e:e.z.string().optional(),n:e.z.string().optional()}).optional(),kid:e.z.string().optional(),x5u:e.z.string().optional(),x5c:e.z.array(e.z.string()).optional(),x5t:e.z.string().optional(),"x5t#S256":e.z.string().optional(),typ:e.z.string().optional(),cty:e.z.string().optional(),crit:e.z.array(e.z.string()).optional()}).passthrough(),t.htuSchema=e.z.string().superRefine((s,l)=>{try{const u=new URL(s);u.protocol!=="http:"&&u.protocol!=="https:"&&l.addIssue({code:e.z.ZodIssueCode.custom,message:"Only http: and https: protocols are allowed"}),(u.username||u.password)&&l.addIssue({code:e.z.ZodIssueCode.custom,message:"Credentials not allowed"}),u.search&&l.addIssue({code:e.z.ZodIssueCode.custom,message:"Query string not allowed"}),u.hash&&l.addIssue({code:e.z.ZodIssueCode.custom,message:"Fragment not allowed"})}catch{l.addIssue({code:e.z.ZodIssueCode.invalid_string,validation:"url"})}return s}),t.jwtPayloadSchema=e.z.object({iss:e.z.string().optional(),aud:e.z.union([e.z.string(),e.z.array(e.z.string()).nonempty()]).optional(),sub:e.z.string().optional(),exp:e.z.number().int().optional(),nbf:e.z.number().int().optional(),iat:e.z.number().int().optional(),jti:e.z.string().optional(),htm:e.z.string().optional(),htu:t.htuSchema.optional(),ath:e.z.string().optional(),acr:e.z.string().optional(),azp:e.z.string().optional(),amr:e.z.array(e.z.string()).optional(),cnf:e.z.object({kid:e.z.string().optional(),jwk:r.jwkPubSchema.optional(),jwe:e.z.string().optional(),jku:e.z.string().url().optional(),jkt:e.z.string().optional(),"x5t#S256":e.z.string().optional(),osc:e.z.string().optional()}).optional(),client_id:e.z.string().optional(),scope:e.z.string().optional(),nonce:e.z.string().optional(),at_hash:e.z.string().optional(),c_hash:e.z.string().optional(),s_hash:e.z.string().optional(),auth_time:e.z.number().int().optional(),name:e.z.string().optional(),family_name:e.z.string().optional(),given_name:e.z.string().optional(),middle_name:e.z.string().optional(),nickname:e.z.string().optional(),preferred_username:e.z.string().optional(),gender:e.z.string().optional(),picture:e.z.string().url().optional(),profile:e.z.string().url().optional(),website:e.z.string().url().optional(),birthdate:e.z.string().regex(/\d{4}-\d{2}-\d{2}/).optional(),zoneinfo:e.z.string().regex(/^[A-Za-z0-9_/]+$/).optional(),locale:e.z.string().regex(/^[a-z]{2,3}(-[A-Z]{2})?$/).optional(),updated_at:e.z.number().int().optional(),email:e.z.string().optional(),email_verified:e.z.boolean().optional(),phone_number:e.z.string().optional(),phone_number_verified:e.z.boolean().optional(),address:e.z.object({formatted:e.z.string().optional(),street_address:e.z.string().optional(),locality:e.z.string().optional(),region:e.z.string().optional(),postal_code:e.z.string().optional(),country:e.z.string().optional()}).optional(),authorization_details:e.z.array(e.z.object({type:e.z.string(),locations:e.z.array(e.z.string()).optional(),actions:e.z.array(e.z.string()).optional(),datatypes:e.z.array(e.z.string()).optional(),identifier:e.z.string().optional(),privileges:e.z.array(e.z.string()).optional()}).passthrough()).optional()}).passthrough()})(l0);Object.defineProperty(Vh,"__esModule",{value:!0});Vh.unsafeDecodeJwt=y2;const kp=Va,yR=l0,mR=ht;function y2(t){const{0:e,1:r,length:n}=t.split(".");if(n>3||n<2)throw new kp.JwtVerifyError(void 0,kp.ERR_JWT_INVALID);const i=yR.jwtHeaderSchema.parse((0,mR.parseB64uJson)(e));if(n===2&&(i==null?void 0:i.alg)!=="none")throw new kp.JwtVerifyError(void 0,kp.ERR_JWT_INVALID);const o=yR.jwtPayloadSchema.parse((0,mR.parseB64uJson)(r));return{header:i,payload:o}}var dC={};Object.defineProperty(dC,"__esModule",{value:!0});var Nh={},m2=S&&S.__runInitializers||function(t,e,r){for(var n=arguments.length>2,i=0;i=0;g--){var b={};for(var w in n)b[w]=w==="access"?{}:n[w];for(var w in n.access)b.access[w]=n.access[w];b.addInitializer=function(y){if(h)throw new TypeError("Cannot add initializers after decoration has completed");o.push(s(y||null))};var C=(0,r[g])(l==="accessor"?{get:d.get,set:d.set}:d[u],b);if(l==="accessor"){if(C===void 0)continue;if(C===null||typeof C!="object")throw new TypeError("Object expected");(f=s(C.get))&&(d.get=f),(f=s(C.set))&&(d.set=f),(f=s(C.init))&&i.unshift(f)}else(f=s(C))&&(l==="field"?i.unshift(f):d[u]=f)}c&&Object.defineProperty(c,n.name,d),h=!0};Object.defineProperty(Nh,"__esModule",{value:!0});Nh.Key=void 0;const g2=Kh,b2=Va,v2=$c,mg=ht,gR=v2.jwkSchema.readonly();let E2=(()=>{var t;let e=[],r,n,i;return t=class{constructor(s){if(Object.defineProperty(this,"jwk",{enumerable:!0,configurable:!0,writable:!0,value:(m2(this,e),s)}),!s.use)throw new b2.JwkError('Missing "use" Parameter value')}get isPrivate(){const{jwk:s}=this;return"d"in s&&s.d!==void 0||"k"in s&&s.k!==void 0}get isSymetric(){const{jwk:s}=this;return"k"in s&&s.k!==void 0}get privateJwk(){return this.isPrivate?this.jwk:void 0}get publicJwk(){if(!this.isSymetric)return gR.parse({...this.jwk,d:void 0,k:void 0})}get bareJwk(){if(this.isSymetric)return;const{kty:s,crv:l,e:u,n:c,x:d,y:f}=this.jwk;return gR.parse({crv:l,e:u,kty:s,n:c,x:d,y:f})}get use(){return this.jwk.use}get alg(){return this.jwk.alg}get kid(){return this.jwk.kid}get crv(){return this.jwk.crv}get algorithms(){return Object.freeze(Array.from((0,g2.jwkAlgorithms)(this.jwk)))}},(()=>{const o=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;r=[mg.cachedGetter],n=[mg.cachedGetter],i=[mg.cachedGetter],yg(t,null,r,{kind:"getter",name:"publicJwk",static:!1,private:!1,access:{has:s=>"publicJwk"in s,get:s=>s.publicJwk},metadata:o},null,e),yg(t,null,n,{kind:"getter",name:"bareJwk",static:!1,private:!1,access:{has:s=>"bareJwk"in s,get:s=>s.bareJwk},metadata:o},null,e),yg(t,null,i,{kind:"getter",name:"algorithms",static:!1,private:!1,access:{has:s=>"algorithms"in s,get:s=>s.algorithms},metadata:o},null,e),o&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o})})(),t})();Nh.Key=E2;var zh={},w2=S&&S.__runInitializers||function(t,e,r){for(var n=arguments.length>2,i=0;i=0;g--){var b={};for(var w in n)b[w]=w==="access"?{}:n[w];for(var w in n.access)b.access[w]=n.access[w];b.addInitializer=function(y){if(h)throw new TypeError("Cannot add initializers after decoration has completed");o.push(s(y||null))};var C=(0,r[g])(l==="accessor"?{get:d.get,set:d.set}:d[u],b);if(l==="accessor"){if(C===void 0)continue;if(C===null||typeof C!="object")throw new TypeError("Object expected");(f=s(C.get))&&(d.get=f),(f=s(C.set))&&(d.set=f),(f=s(C.init))&&i.unshift(f)}else(f=s(C))&&(l==="field"?i.unshift(f):d[u]=f)}c&&Object.defineProperty(c,n.name,d),h=!0};Object.defineProperty(zh,"__esModule",{value:!0});zh.Keyset=void 0;const Sr=Va,_2=Vh,Yo=ht,x2=t=>t.privateJwk,R2=t=>t.publicJwk;let A2=(()=>{var t;let e=[],r,n,i;return t=class{constructor(s,l=s instanceof t?[...s.preferredSigningAlgorithms]:["EdDSA","ES256K","ES256","PS256","PS384","PS512","HS256","HS384","HS512"]){Object.defineProperty(this,"preferredSigningAlgorithms",{enumerable:!0,configurable:!0,writable:!0,value:(w2(this,e),l)}),Object.defineProperty(this,"keys",{enumerable:!0,configurable:!0,writable:!0,value:void 0});const u=[],c=new Set;for(const d of s)if(d&&(u.push(d),d.kid)){if(c.has(d.kid))throw new Sr.JwkError(`Duplicate key: ${d.kid}`);c.add(d.kid)}this.keys=Object.freeze(u)}get size(){return this.keys.length}get signAlgorithms(){const s=new Set;for(const l of this)if(l.use==="sig")for(const u of l.algorithms)s.add(u);return Object.freeze([...s].sort((0,Yo.preferredOrderCmp)(this.preferredSigningAlgorithms)))}get publicJwks(){return{keys:Array.from(this,R2).filter(Yo.isDefined)}}get privateJwks(){return{keys:Array.from(this,x2).filter(Yo.isDefined)}}has(s){return this.keys.some(l=>l.kid===s)}get(s){for(const l of this.list(s))return l;throw new Sr.JwkError(`Key not found ${s.kid||s.alg||""}`,Sr.ERR_JWK_NOT_FOUND)}*list(s){var l,u;if(((l=s.kid)==null?void 0:l.length)!==0&&((u=s.alg)==null?void 0:u.length)!==0){for(const c of this)if(!(s.use&&c.use!==s.use)){if(Array.isArray(s.kid)){if(!c.kid||!s.kid.includes(c.kid))continue}else if(s.kid&&c.kid!==s.kid)continue;if(Array.isArray(s.alg)){if(!s.alg.some(d=>c.algorithms.includes(d)))continue}else if(typeof s.alg=="string"&&!c.algorithms.includes(s.alg))continue;yield c}}}findPrivateKey({kid:s,alg:l,use:u}){const c=[];for(const h of this.list({kid:s,alg:l,use:u}))if(h.isPrivate){if(typeof l=="string")return[h,l];c.push(h)}const d=(0,Yo.matchesAny)(l),f=c.map(h=>[h,h.algorithms.filter(d)]);for(const h of this.preferredSigningAlgorithms)for(const[g,b]of f)if(b.includes(h))return[g,h];for(const[h,g]of f)for(const b of g)return[h,b];throw new Sr.JwkError(`No private key found for ${s||l||u||""}`,Sr.ERR_JWK_NOT_FOUND)}[(r=[Yo.cachedGetter],n=[Yo.cachedGetter],i=[Yo.cachedGetter],Symbol.iterator)](){return this.keys.values()}async createJwt({alg:s,kid:l,...u},c){try{const[d,f]=this.findPrivateKey({alg:s,kid:l,use:"sig"}),h={...u,alg:f,kid:d.kid};return typeof c=="function"&&(c=await c(h,d)),await d.createJwt(h,c)}catch(d){throw Sr.JwtCreateError.from(d)}}async verifyJwt(s,l){const{header:u}=(0,_2.unsafeDecodeJwt)(s),{kid:c,alg:d}=u,f=[];for(const h of this.list({kid:c,alg:d}))try{return{...await h.verifyJwt(s,l),key:h}}catch(g){f.push(g)}switch(f.length){case 0:throw new Sr.JwtVerifyError("No key matched",Sr.ERR_JWKS_NO_MATCHING_KEY);case 1:throw Sr.JwtVerifyError.from(f[0],Sr.ERR_JWT_INVALID);default:throw Sr.JwtVerifyError.from(f,Sr.ERR_JWT_INVALID)}}toJSON(){return structuredClone(this.publicJwks)}},(()=>{const o=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;gg(t,null,r,{kind:"getter",name:"signAlgorithms",static:!1,private:!1,access:{has:s=>"signAlgorithms"in s,get:s=>s.signAlgorithms},metadata:o},null,e),gg(t,null,n,{kind:"getter",name:"publicJwks",static:!1,private:!1,access:{has:s=>"publicJwks"in s,get:s=>s.publicJwks},metadata:o},null,e),gg(t,null,i,{kind:"getter",name:"privateJwks",static:!1,private:!1,access:{has:s=>"privateJwks"in s,get:s=>s.privateJwks},metadata:o},null,e),o&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o})})(),t})();zh.Keyset=A2;(function(t){var e=S&&S.__createBinding||(Object.create?function(i,o,s,l){l===void 0&&(l=s);var u=Object.getOwnPropertyDescriptor(o,s);(!u||("get"in u?!o.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return o[s]}}),Object.defineProperty(i,l,u)}:function(i,o,s,l){l===void 0&&(l=s),i[l]=o[s]}),r=S&&S.__exportStar||function(i,o){for(var s in i)s!=="default"&&!Object.prototype.hasOwnProperty.call(o,s)&&e(o,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),t.ValidationError=void 0;var n=G;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return n.ZodError}}),r(Kh,t),r(Va,t),r($c,t),r(Da,t),r(Vh,t),r(dC,t),r(l0,t),r(Nh,t),r(zh,t),r(ht,t)})(Si);var pC={},Fh={};const ie=crypto,lr=t=>t instanceof CryptoKey,fC=async(t,e)=>{const r=`SHA-${t.slice(-3)}`;return new Uint8Array(await ie.subtle.digest(r,e))},He=new TextEncoder,Vr=new TextDecoder,eh=2**32;function Vn(...t){const e=t.reduce((i,{length:o})=>i+o,0),r=new Uint8Array(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function S2(t,e){return Vn(He.encode(t),new Uint8Array([0]),e)}function Fb(t,e,r){if(e<0||e>=eh)throw new RangeError(`value must be >= 0 and <= ${eh-1}. Received ${e}`);t.set([e>>>24,e>>>16,e>>>8,e&255],r)}function hC(t){const e=Math.floor(t/eh),r=t%eh,n=new Uint8Array(8);return Fb(n,e,0),Fb(n,r,4),n}function d0(t){const e=new Uint8Array(4);return Fb(e,t),e}function bg(t){return Vn(d0(t.length),t)}async function C2(t,e,r){const n=Math.ceil((e>>3)/32),i=new Uint8Array(n*32);for(let o=0;o>3)}const p0=t=>{let e=t;typeof e=="string"&&(e=He.encode(e));const r=32768,n=[];for(let i=0;ip0(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),yC=t=>{const e=atob(t),r=new Uint8Array(e.length);for(let n=0;n{let e=t;e instanceof Uint8Array&&(e=Vr.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return yC(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};let mt=class extends Error{constructor(e,r){var n;super(e,r),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};mt.code="ERR_JOSE_GENERIC";class Mt extends mt{constructor(e,r,n="unspecified",i="unspecified"){super(e,{cause:{claim:n,reason:i,payload:r}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=n,this.reason=i,this.payload=r}}Mt.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class th extends mt{constructor(e,r,n="unspecified",i="unspecified"){super(e,{cause:{claim:n,reason:i,payload:r}}),this.code="ERR_JWT_EXPIRED",this.claim=n,this.reason=i,this.payload=r}}th.code="ERR_JWT_EXPIRED";class Ac extends mt{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}Ac.code="ERR_JOSE_ALG_NOT_ALLOWED";class we extends mt{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}we.code="ERR_JOSE_NOT_SUPPORTED";class Ba extends mt{constructor(e="decryption operation failed",r){super(e,r),this.code="ERR_JWE_DECRYPTION_FAILED"}}Ba.code="ERR_JWE_DECRYPTION_FAILED";class F extends mt{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}F.code="ERR_JWE_INVALID";class _e extends mt{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}_e.code="ERR_JWS_INVALID";class zt extends mt{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}zt.code="ERR_JWT_INVALID";class f0 extends mt{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}f0.code="ERR_JWK_INVALID";class qh extends mt{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}qh.code="ERR_JWKS_INVALID";class Gh extends mt{constructor(e="no applicable key found in the JSON Web Key Set",r){super(e,r),this.code="ERR_JWKS_NO_MATCHING_KEY"}}Gh.code="ERR_JWKS_NO_MATCHING_KEY";class h0 extends mt{constructor(e="multiple matching keys found in the JSON Web Key Set",r){super(e,r),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}h0.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class y0 extends mt{constructor(e="request timed out",r){super(e,r),this.code="ERR_JWKS_TIMEOUT"}}y0.code="ERR_JWKS_TIMEOUT";class Hh extends mt{constructor(e="signature verification failed",r){super(e,r),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}Hh.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";const T2=Object.freeze(Object.defineProperty({__proto__:null,JOSEAlgNotAllowed:Ac,JOSEError:mt,JOSENotSupported:we,JWEDecryptionFailed:Ba,JWEInvalid:F,JWKInvalid:f0,JWKSInvalid:qh,JWKSMultipleMatchingKeys:h0,JWKSNoMatchingKey:Gh,JWKSTimeout:y0,JWSInvalid:_e,JWSSignatureVerificationFailed:Hh,JWTClaimValidationFailed:Mt,JWTExpired:th,JWTInvalid:zt},Symbol.toStringTag,{value:"Module"})),Xh=ie.getRandomValues.bind(ie);function mC(t){switch(t){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new we(`Unsupported JWE Algorithm: ${t}`)}}const k2=t=>Xh(new Uint8Array(mC(t)>>3)),gC=(t,e)=>{if(e.length<<3!==mC(t))throw new F("Invalid Initialization Vector length")},rh=(t,e)=>{const r=t.byteLength<<3;if(r!==e)throw new F(`Invalid Content Encryption Key length. Expected ${e} bits, got ${r} bits`)},L2=(t,e)=>{if(!(t instanceof Uint8Array))throw new TypeError("First argument must be a buffer");if(!(e instanceof Uint8Array))throw new TypeError("Second argument must be a buffer");if(t.length!==e.length)throw new TypeError("Input buffers must have the same length");const r=t.length;let n=0,i=-1;for(;++it.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(e.length>2){const n=e.pop();r+=`one of ${e.join(", ")}, or ${n}.`}else e.length===2?r+=`one of ${e[0]} or ${e[1]}.`:r+=`${e[0]}.`;throw new TypeError(r)}}function D2(t,e,...r){switch(e){case"HS256":case"HS384":case"HS512":{if(!pi(t.algorithm,"HMAC"))throw dt("HMAC");const n=parseInt(e.slice(2),10);if(pf(t.algorithm.hash)!==n)throw dt(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!pi(t.algorithm,"RSASSA-PKCS1-v1_5"))throw dt("RSASSA-PKCS1-v1_5");const n=parseInt(e.slice(2),10);if(pf(t.algorithm.hash)!==n)throw dt(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!pi(t.algorithm,"RSA-PSS"))throw dt("RSA-PSS");const n=parseInt(e.slice(2),10);if(pf(t.algorithm.hash)!==n)throw dt(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(t.algorithm.name!=="Ed25519"&&t.algorithm.name!=="Ed448")throw dt("Ed25519 or Ed448");break}case"Ed25519":{if(!pi(t.algorithm,"Ed25519"))throw dt("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!pi(t.algorithm,"ECDSA"))throw dt("ECDSA");const n=P2(e);if(t.algorithm.namedCurve!==n)throw dt(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}bC(t,r)}function bo(t,e,...r){switch(e){case"A128GCM":case"A192GCM":case"A256GCM":{if(!pi(t.algorithm,"AES-GCM"))throw dt("AES-GCM");const n=parseInt(e.slice(1,4),10);if(t.algorithm.length!==n)throw dt(n,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!pi(t.algorithm,"AES-KW"))throw dt("AES-KW");const n=parseInt(e.slice(1,4),10);if(t.algorithm.length!==n)throw dt(n,"algorithm.length");break}case"ECDH":{switch(t.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw dt("ECDH, X25519, or X448")}break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!pi(t.algorithm,"PBKDF2"))throw dt("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!pi(t.algorithm,"RSA-OAEP"))throw dt("RSA-OAEP");const n=parseInt(e.slice(9),10)||1;if(pf(t.algorithm.hash)!==n)throw dt(`SHA-${n}`,"algorithm.hash");break}default:throw new TypeError("CryptoKey does not support this operation")}bC(t,r)}function vC(t,e,...r){var n;if(r=r.filter(Boolean),r.length>2){const i=r.pop();t+=`one of type ${r.join(", ")}, or ${i}.`}else r.length===2?t+=`one of type ${r[0]} or ${r[1]}.`:t+=`of type ${r[0]}.`;return e==null?t+=` Received ${e}`:typeof e=="function"&&e.name?t+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&(n=e.constructor)!=null&&n.name&&(t+=` Received an instance of ${e.constructor.name}`),t}const jt=(t,...e)=>vC("Key must be ",t,...e);function EC(t,e,...r){return vC(`Key for the ${t} algorithm must be `,e,...r)}const wC=t=>lr(t)?!0:(t==null?void 0:t[Symbol.toStringTag])==="KeyObject",Ut=["CryptoKey"];async function B2(t,e,r,n,i,o){if(!(e instanceof Uint8Array))throw new TypeError(jt(e,"Uint8Array"));const s=parseInt(t.slice(1,4),10),l=await ie.subtle.importKey("raw",e.subarray(s>>3),"AES-CBC",!1,["decrypt"]),u=await ie.subtle.importKey("raw",e.subarray(0,s>>3),{hash:`SHA-${s<<1}`,name:"HMAC"},!1,["sign"]),c=Vn(o,n,r,hC(o.length<<3)),d=new Uint8Array((await ie.subtle.sign("HMAC",u,c)).slice(0,s>>3));let f;try{f=L2(i,d)}catch{}if(!f)throw new Ba;let h;try{h=new Uint8Array(await ie.subtle.decrypt({iv:n,name:"AES-CBC"},l,r))}catch{}if(!h)throw new Ba;return h}async function I2(t,e,r,n,i,o){let s;e instanceof Uint8Array?s=await ie.subtle.importKey("raw",e,"AES-GCM",!1,["decrypt"]):(bo(e,t,"decrypt"),s=e);try{return new Uint8Array(await ie.subtle.decrypt({additionalData:o,iv:n,name:"AES-GCM",tagLength:128},s,Vn(r,i)))}catch{throw new Ba}}const _C=async(t,e,r,n,i,o)=>{if(!lr(e)&&!(e instanceof Uint8Array))throw new TypeError(jt(e,...Ut,"Uint8Array"));if(!n)throw new F("JWE Initialization Vector missing");if(!i)throw new F("JWE Authentication Tag missing");switch(gC(t,n),t){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return e instanceof Uint8Array&&rh(e,parseInt(t.slice(-3),10)),B2(t,e,r,n,i,o);case"A128GCM":case"A192GCM":case"A256GCM":return e instanceof Uint8Array&&rh(e,parseInt(t.slice(1,4),10)),I2(t,e,r,n,i,o);default:throw new we("Unsupported JWE Content Encryption Algorithm")}},Kc=(...t)=>{const e=t.filter(Boolean);if(e.length===0||e.length===1)return!0;let r;for(const n of e){const i=Object.keys(n);if(!r||r.size===0){r=new Set(i);continue}for(const o of i){if(r.has(o))return!1;r.add(o)}}return!0};function j2(t){return typeof t=="object"&&t!==null}function Xe(t){if(!j2(t)||Object.prototype.toString.call(t)!=="[object Object]")return!1;if(Object.getPrototypeOf(t)===null)return!0;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}const Wh=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function xC(t,e){if(t.algorithm.length!==parseInt(e.slice(1,4),10))throw new TypeError(`Invalid key size for alg: ${e}`)}function RC(t,e,r){if(lr(t))return bo(t,e,r),t;if(t instanceof Uint8Array)return ie.subtle.importKey("raw",t,"AES-KW",!0,[r]);throw new TypeError(jt(t,...Ut,"Uint8Array"))}const qb=async(t,e,r)=>{const n=await RC(e,t,"wrapKey");xC(n,t);const i=await ie.subtle.importKey("raw",r,...Wh);return new Uint8Array(await ie.subtle.wrapKey("raw",i,n,"AES-KW"))},Gb=async(t,e,r)=>{const n=await RC(e,t,"unwrapKey");xC(n,t);const i=await ie.subtle.unwrapKey("raw",r,n,"AES-KW",...Wh);return new Uint8Array(await ie.subtle.exportKey("raw",i))};async function AC(t,e,r,n,i=new Uint8Array(0),o=new Uint8Array(0)){if(!lr(t))throw new TypeError(jt(t,...Ut));if(bo(t,"ECDH"),!lr(e))throw new TypeError(jt(e,...Ut));bo(e,"ECDH","deriveBits");const s=Vn(bg(He.encode(r)),bg(i),bg(o),d0(n));let l;t.algorithm.name==="X25519"?l=256:t.algorithm.name==="X448"?l=448:l=Math.ceil(parseInt(t.algorithm.namedCurve.substr(-3),10)/8)<<3;const u=new Uint8Array(await ie.subtle.deriveBits({name:t.algorithm.name,public:t},e,l));return C2(u,n,s)}async function U2(t){if(!lr(t))throw new TypeError(jt(t,...Ut));return ie.subtle.generateKey(t.algorithm,!0,["deriveBits"])}function SC(t){if(!lr(t))throw new TypeError(jt(t,...Ut));return["P-256","P-384","P-521"].includes(t.algorithm.namedCurve)||t.algorithm.name==="X25519"||t.algorithm.name==="X448"}function $2(t){if(!(t instanceof Uint8Array)||t.length<8)throw new F("PBES2 Salt Input must be 8 or more octets")}function O2(t,e){if(t instanceof Uint8Array)return ie.subtle.importKey("raw",t,"PBKDF2",!1,["deriveBits"]);if(lr(t))return bo(t,e,"deriveBits","deriveKey"),t;throw new TypeError(jt(t,...Ut,"Uint8Array"))}async function CC(t,e,r,n){$2(t);const i=S2(e,t),o=parseInt(e.slice(13,16),10),s={hash:`SHA-${e.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:i},l={length:o,name:"AES-KW"},u=await O2(n,e);if(u.usages.includes("deriveBits"))return new Uint8Array(await ie.subtle.deriveBits(s,u,o));if(u.usages.includes("deriveKey"))return ie.subtle.deriveKey(s,u,l,!1,["wrapKey","unwrapKey"]);throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}const K2=async(t,e,r,n=2048,i=Xh(new Uint8Array(16)))=>{const o=await CC(i,t,n,e);return{encryptedKey:await qb(t.slice(-6),o,r),p2c:n,p2s:Ze(i)}},V2=async(t,e,r,n,i)=>{const o=await CC(i,t,n,e);return Gb(t.slice(-6),o,r)};function nh(t){switch(t){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new we(`alg ${t} is not supported either by JOSE or your javascript runtime`)}}const Jh=(t,e)=>{if(t.startsWith("RS")||t.startsWith("PS")){const{modulusLength:r}=e.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}},M2=async(t,e,r)=>{if(!lr(e))throw new TypeError(jt(e,...Ut));if(bo(e,t,"encrypt","wrapKey"),Jh(t,e),e.usages.includes("encrypt"))return new Uint8Array(await ie.subtle.encrypt(nh(t),e,r));if(e.usages.includes("wrapKey")){const n=await ie.subtle.importKey("raw",r,...Wh);return new Uint8Array(await ie.subtle.wrapKey("raw",n,e,nh(t)))}throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')},N2=async(t,e,r)=>{if(!lr(e))throw new TypeError(jt(e,...Ut));if(bo(e,t,"decrypt","unwrapKey"),Jh(t,e),e.usages.includes("decrypt"))return new Uint8Array(await ie.subtle.decrypt(nh(t),e,r));if(e.usages.includes("unwrapKey")){const n=await ie.subtle.unwrapKey("raw",r,e,nh(t),...Wh);return new Uint8Array(await ie.subtle.exportKey("raw",n))}throw new TypeError('RSA-OAEP key "usages" must include "decrypt" or "unwrapKey" for this operation')};function Ma(t){return Xe(t)&&typeof t.kty=="string"}function z2(t){return t.kty!=="oct"&&typeof t.d=="string"}function F2(t){return t.kty!=="oct"&&typeof t.d>"u"}function q2(t){return Ma(t)&&t.kty==="oct"&&typeof t.k=="string"}function G2(t){let e,r;switch(t.kty){case"RSA":{switch(t.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(t.alg.slice(-3),10)||1}`},r=t.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new we('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(t.alg){case"ES256":e={name:"ECDSA",namedCurve:"P-256"},r=t.d?["sign"]:["verify"];break;case"ES384":e={name:"ECDSA",namedCurve:"P-384"},r=t.d?["sign"]:["verify"];break;case"ES512":e={name:"ECDSA",namedCurve:"P-521"},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new we('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(t.alg){case"Ed25519":e={name:"Ed25519"},r=t.d?["sign"]:["verify"];break;case"EdDSA":e={name:t.crv},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new we('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new we('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:e,keyUsages:r}}const TC=async t=>{if(!t.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:e,keyUsages:r}=G2(t),n=[e,t.ext??!1,t.key_ops??r],i={...t};return delete i.alg,delete i.use,ie.subtle.importKey("jwk",i,...n)},kC=t=>qe(t);let Fs,qs;const LC=t=>(t==null?void 0:t[Symbol.toStringTag])==="KeyObject",ih=async(t,e,r,n,i=!1)=>{let o=t.get(e);if(o!=null&&o[n])return o[n];const s=await TC({...r,alg:n});return i&&Object.freeze(e),o?o[n]=s:t.set(e,{[n]:s}),s},H2=(t,e)=>{if(LC(t)){let r=t.export({format:"jwk"});return delete r.d,delete r.dp,delete r.dq,delete r.p,delete r.q,delete r.qi,r.k?kC(r.k):(qs||(qs=new WeakMap),ih(qs,t,r,e))}return Ma(t)?t.k?qe(t.k):(qs||(qs=new WeakMap),ih(qs,t,t,e,!0)):t},X2=(t,e)=>{if(LC(t)){let r=t.export({format:"jwk"});return r.k?kC(r.k):(Fs||(Fs=new WeakMap),ih(Fs,t,r,e))}return Ma(t)?t.k?qe(t.k):(Fs||(Fs=new WeakMap),ih(Fs,t,t,e,!0)):t},uo={normalizePublicKey:H2,normalizePrivateKey:X2};function m0(t){switch(t){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new we(`Unsupported JWE Algorithm: ${t}`)}}const ds=t=>Xh(new Uint8Array(m0(t)>>3)),PC=(t,e)=>{const r=(t.match(/.{1,64}/g)||[]).join(` -`);return`-----BEGIN ${e}----- -${r} ------END ${e}-----`},DC=async(t,e,r)=>{if(!lr(r))throw new TypeError(jt(r,...Ut));if(!r.extractable)throw new TypeError("CryptoKey is not extractable");if(r.type!==t)throw new TypeError(`key is not a ${t} key`);return PC(p0(new Uint8Array(await ie.subtle.exportKey(e,r))),`${t.toUpperCase()} KEY`)},W2=t=>DC("public","spki",t),J2=t=>DC("private","pkcs8",t),Oi=(t,e,r=0)=>{r===0&&(e.unshift(e.length),e.unshift(6));const n=t.indexOf(e[0],r);if(n===-1)return!1;const i=t.subarray(n,n+e.length);return i.length!==e.length?!1:i.every((o,s)=>o===e[s])||Oi(t,e,n+1)},bR=t=>{switch(!0){case Oi(t,[42,134,72,206,61,3,1,7]):return"P-256";case Oi(t,[43,129,4,0,34]):return"P-384";case Oi(t,[43,129,4,0,35]):return"P-521";case Oi(t,[43,101,110]):return"X25519";case Oi(t,[43,101,111]):return"X448";case Oi(t,[43,101,112]):return"Ed25519";case Oi(t,[43,101,113]):return"Ed448";default:throw new we("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},BC=async(t,e,r,n,i)=>{let o,s;const l=new Uint8Array(atob(r.replace(t,"")).split("").map(c=>c.charCodeAt(0))),u=e==="spki";switch(n){case"PS256":case"PS384":case"PS512":o={name:"RSA-PSS",hash:`SHA-${n.slice(-3)}`},s=u?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":o={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${n.slice(-3)}`},s=u?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":o={name:"RSA-OAEP",hash:`SHA-${parseInt(n.slice(-3),10)||1}`},s=u?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":o={name:"ECDSA",namedCurve:"P-256"},s=u?["verify"]:["sign"];break;case"ES384":o={name:"ECDSA",namedCurve:"P-384"},s=u?["verify"]:["sign"];break;case"ES512":o={name:"ECDSA",namedCurve:"P-521"},s=u?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{const c=bR(l);o=c.startsWith("P-")?{name:"ECDH",namedCurve:c}:{name:c},s=u?[]:["deriveBits"];break}case"Ed25519":o={name:"Ed25519"},s=u?["verify"]:["sign"];break;case"EdDSA":o={name:bR(l)},s=u?["verify"]:["sign"];break;default:throw new we('Invalid or unsupported "alg" (Algorithm) value')}return ie.subtle.importKey(e,l,o,(i==null?void 0:i.extractable)??!1,s)},Z2=(t,e,r)=>BC(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",t,e,r),IC=(t,e,r)=>BC(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,"spki",t,e,r);function vR(t){const e=[];let r=0;for(;r=128;)r=r*128+t[e]-128,e++;r=r*128+t[e]-128,e++}let n=0;if(t[e]<128)n=t[e],e++;else if(n===128){for(n=0;t[e+n]!==0||t[e+n+1]!==0;){if(n>t.byteLength)throw new TypeError("invalid indefinite form length");n++}const o=e+n+2;return{byteLength:o,contents:t.subarray(e,e+n),raw:t.subarray(0,o)}}else{const o=t[e]&127;e++,n=0;for(let s=0;s{let n;try{n=Y2(t)}catch(i){throw new TypeError("Failed to parse the X.509 certificate",{cause:i})}return IC(n,e,r)};async function t3(t,e,r){if(typeof t!="string"||t.indexOf("-----BEGIN PUBLIC KEY-----")!==0)throw new TypeError('"spki" must be SPKI formatted string');return IC(t,e,r)}async function r3(t,e,r){if(typeof t!="string"||t.indexOf("-----BEGIN CERTIFICATE-----")!==0)throw new TypeError('"x509" must be X.509 formatted string');return e3(t,e,r)}async function n3(t,e,r){if(typeof t!="string"||t.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return Z2(t,e,r)}async function Vc(t,e){if(!Xe(t))throw new TypeError("JWK must be an object");switch(e||(e=t.alg),t.kty){case"oct":if(typeof t.k!="string"||!t.k)throw new TypeError('missing "k" (Key Value) Parameter value');return qe(t.k);case"RSA":if("oth"in t&&t.oth!==void 0)throw new we('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return TC({...t,alg:e});default:throw new we('Unsupported "kty" (Key Type) Parameter value')}}const Qs=t=>t==null?void 0:t[Symbol.toStringTag],Hb=(t,e,r)=>{var n,i;if(e.use!==void 0&&e.use!=="sig")throw new TypeError("Invalid key for this operation, when present its use must be sig");if(e.key_ops!==void 0&&((i=(n=e.key_ops).includes)==null?void 0:i.call(n,r))!==!0)throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${r}`);if(e.alg!==void 0&&e.alg!==t)throw new TypeError(`Invalid key for this operation, when present its alg must be ${t}`);return!0},i3=(t,e,r,n)=>{if(!(e instanceof Uint8Array)){if(n&&Ma(e)){if(q2(e)&&Hb(t,e,r))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!wC(e))throw new TypeError(EC(t,e,...Ut,"Uint8Array",n?"JSON Web Key":null));if(e.type!=="secret")throw new TypeError(`${Qs(e)} instances for symmetric algorithms must be of type "secret"`)}},o3=(t,e,r,n)=>{if(n&&Ma(e))switch(r){case"sign":if(z2(e)&&Hb(t,e,r))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"verify":if(F2(e)&&Hb(t,e,r))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!wC(e))throw new TypeError(EC(t,e,...Ut,n?"JSON Web Key":null));if(e.type==="secret")throw new TypeError(`${Qs(e)} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&e.type==="public")throw new TypeError(`${Qs(e)} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&e.type==="public")throw new TypeError(`${Qs(e)} instances for asymmetric algorithm decryption must be of type "private"`);if(e.algorithm&&r==="verify"&&e.type==="private")throw new TypeError(`${Qs(e)} instances for asymmetric algorithm verifying must be of type "public"`);if(e.algorithm&&r==="encrypt"&&e.type==="private")throw new TypeError(`${Qs(e)} instances for asymmetric algorithm encryption must be of type "public"`)};function UC(t,e,r,n){e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?i3(e,r,n,t):o3(e,r,n,t)}const $C=UC.bind(void 0,!1),Xb=UC.bind(void 0,!0);async function s3(t,e,r,n,i){if(!(r instanceof Uint8Array))throw new TypeError(jt(r,"Uint8Array"));const o=parseInt(t.slice(1,4),10),s=await ie.subtle.importKey("raw",r.subarray(o>>3),"AES-CBC",!1,["encrypt"]),l=await ie.subtle.importKey("raw",r.subarray(0,o>>3),{hash:`SHA-${o<<1}`,name:"HMAC"},!1,["sign"]),u=new Uint8Array(await ie.subtle.encrypt({iv:n,name:"AES-CBC"},s,e)),c=Vn(i,n,u,hC(i.length<<3)),d=new Uint8Array((await ie.subtle.sign("HMAC",l,c)).slice(0,o>>3));return{ciphertext:u,tag:d,iv:n}}async function a3(t,e,r,n,i){let o;r instanceof Uint8Array?o=await ie.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(bo(r,t,"encrypt"),o=r);const s=new Uint8Array(await ie.subtle.encrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},o,e)),l=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:l,iv:n}}const OC=async(t,e,r,n,i)=>{if(!lr(r)&&!(r instanceof Uint8Array))throw new TypeError(jt(r,...Ut,"Uint8Array"));switch(n?gC(t,n):n=k2(t),t){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&rh(r,parseInt(t.slice(-3),10)),s3(t,e,r,n,i);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&rh(r,parseInt(t.slice(1,4),10)),a3(t,e,r,n,i);default:throw new we("Unsupported JWE Content Encryption Algorithm")}};async function l3(t,e,r,n){const i=t.slice(0,7),o=await OC(i,r,e,n,new Uint8Array(0));return{encryptedKey:o.ciphertext,iv:Ze(o.iv),tag:Ze(o.tag)}}async function u3(t,e,r,n,i){const o=t.slice(0,7);return _C(o,e,r,n,i,new Uint8Array(0))}async function c3(t,e,r,n,i){var o;switch($C(t,e,"decrypt"),e=await((o=uo.normalizePrivateKey)==null?void 0:o.call(uo,e,t))||e,t){case"dir":{if(r!==void 0)throw new F("Encountered unexpected JWE Encrypted Key");return e}case"ECDH-ES":if(r!==void 0)throw new F("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!Xe(n.epk))throw new F('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(!SC(e))throw new we("ECDH with the provided key is not allowed or not supported by your javascript runtime");const s=await Vc(n.epk,t);let l,u;if(n.apu!==void 0){if(typeof n.apu!="string")throw new F('JOSE Header "apu" (Agreement PartyUInfo) invalid');try{l=qe(n.apu)}catch{throw new F("Failed to base64url decode the apu")}}if(n.apv!==void 0){if(typeof n.apv!="string")throw new F('JOSE Header "apv" (Agreement PartyVInfo) invalid');try{u=qe(n.apv)}catch{throw new F("Failed to base64url decode the apv")}}const c=await AC(s,e,t==="ECDH-ES"?n.enc:t,t==="ECDH-ES"?m0(n.enc):parseInt(t.slice(-5,-2),10),l,u);if(t==="ECDH-ES")return c;if(r===void 0)throw new F("JWE Encrypted Key missing");return Gb(t.slice(-6),c,r)}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(r===void 0)throw new F("JWE Encrypted Key missing");return N2(t,e,r)}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{if(r===void 0)throw new F("JWE Encrypted Key missing");if(typeof n.p2c!="number")throw new F('JOSE Header "p2c" (PBES2 Count) missing or invalid');const s=(i==null?void 0:i.maxPBES2Count)||1e4;if(n.p2c>s)throw new F('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if(typeof n.p2s!="string")throw new F('JOSE Header "p2s" (PBES2 Salt) missing or invalid');let l;try{l=qe(n.p2s)}catch{throw new F("Failed to base64url decode the p2s")}return V2(t,e,r,n.p2c,l)}case"A128KW":case"A192KW":case"A256KW":{if(r===void 0)throw new F("JWE Encrypted Key missing");return Gb(t,e,r)}case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{if(r===void 0)throw new F("JWE Encrypted Key missing");if(typeof n.iv!="string")throw new F('JOSE Header "iv" (Initialization Vector) missing or invalid');if(typeof n.tag!="string")throw new F('JOSE Header "tag" (Authentication Tag) missing or invalid');let s;try{s=qe(n.iv)}catch{throw new F("Failed to base64url decode the iv")}let l;try{l=qe(n.tag)}catch{throw new F("Failed to base64url decode the tag")}return u3(t,e,r,s,l)}default:throw new we('Invalid or unsupported "alg" (JWE Algorithm) header value')}}function Mc(t,e,r,n,i){if(i.crit!==void 0&&(n==null?void 0:n.crit)===void 0)throw new t('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(s=>typeof s!="string"||s.length===0))throw new t('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let o;r!==void 0?o=new Map([...Object.entries(r),...e.entries()]):o=e;for(const s of n.crit){if(!o.has(s))throw new we(`Extension Header Parameter "${s}" is not recognized`);if(i[s]===void 0)throw new t(`Extension Header Parameter "${s}" is missing`);if(o.get(s)&&n[s]===void 0)throw new t(`Extension Header Parameter "${s}" MUST be integrity protected`)}return new Set(n.crit)}const Wb=(t,e)=>{if(e!==void 0&&(!Array.isArray(e)||e.some(r=>typeof r!="string")))throw new TypeError(`"${t}" option must be an array of strings`);if(e)return new Set(e)};async function g0(t,e,r){if(!Xe(t))throw new F("Flattened JWE must be an object");if(t.protected===void 0&&t.header===void 0&&t.unprotected===void 0)throw new F("JOSE Header missing");if(t.iv!==void 0&&typeof t.iv!="string")throw new F("JWE Initialization Vector incorrect type");if(typeof t.ciphertext!="string")throw new F("JWE Ciphertext missing or incorrect type");if(t.tag!==void 0&&typeof t.tag!="string")throw new F("JWE Authentication Tag incorrect type");if(t.protected!==void 0&&typeof t.protected!="string")throw new F("JWE Protected Header incorrect type");if(t.encrypted_key!==void 0&&typeof t.encrypted_key!="string")throw new F("JWE Encrypted Key incorrect type");if(t.aad!==void 0&&typeof t.aad!="string")throw new F("JWE AAD incorrect type");if(t.header!==void 0&&!Xe(t.header))throw new F("JWE Shared Unprotected Header incorrect type");if(t.unprotected!==void 0&&!Xe(t.unprotected))throw new F("JWE Per-Recipient Unprotected Header incorrect type");let n;if(t.protected)try{const E=qe(t.protected);n=JSON.parse(Vr.decode(E))}catch{throw new F("JWE Protected Header is invalid")}if(!Kc(n,t.header,t.unprotected))throw new F("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");const i={...n,...t.header,...t.unprotected};if(Mc(F,new Map,r==null?void 0:r.crit,n,i),i.zip!==void 0)throw new we('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:o,enc:s}=i;if(typeof o!="string"||!o)throw new F("missing JWE Algorithm (alg) in JWE Header");if(typeof s!="string"||!s)throw new F("missing JWE Encryption Algorithm (enc) in JWE Header");const l=r&&Wb("keyManagementAlgorithms",r.keyManagementAlgorithms),u=r&&Wb("contentEncryptionAlgorithms",r.contentEncryptionAlgorithms);if(l&&!l.has(o)||!l&&o.startsWith("PBES2"))throw new Ac('"alg" (Algorithm) Header Parameter value not allowed');if(u&&!u.has(s))throw new Ac('"enc" (Encryption Algorithm) Header Parameter value not allowed');let c;if(t.encrypted_key!==void 0)try{c=qe(t.encrypted_key)}catch{throw new F("Failed to base64url decode the encrypted_key")}let d=!1;typeof e=="function"&&(e=await e(n,t),d=!0);let f;try{f=await c3(o,e,c,i,r)}catch(E){if(E instanceof TypeError||E instanceof F||E instanceof we)throw E;f=ds(s)}let h,g;if(t.iv!==void 0)try{h=qe(t.iv)}catch{throw new F("Failed to base64url decode the iv")}if(t.tag!==void 0)try{g=qe(t.tag)}catch{throw new F("Failed to base64url decode the tag")}const b=He.encode(t.protected??"");let w;t.aad!==void 0?w=Vn(b,He.encode("."),He.encode(t.aad)):w=b;let C;try{C=qe(t.ciphertext)}catch{throw new F("Failed to base64url decode the ciphertext")}const m={plaintext:await _C(s,f,C,h,g,w)};if(t.protected!==void 0&&(m.protectedHeader=n),t.aad!==void 0)try{m.additionalAuthenticatedData=qe(t.aad)}catch{throw new F("Failed to base64url decode the aad")}return t.unprotected!==void 0&&(m.sharedUnprotectedHeader=t.unprotected),t.header!==void 0&&(m.unprotectedHeader=t.header),d?{...m,key:e}:m}async function KC(t,e,r){if(t instanceof Uint8Array&&(t=Vr.decode(t)),typeof t!="string")throw new F("Compact JWE must be a string or Uint8Array");const{0:n,1:i,2:o,3:s,4:l,length:u}=t.split(".");if(u!==5)throw new F("Invalid Compact JWE");const c=await g0({ciphertext:s,iv:o||void 0,protected:n,tag:l||void 0,encrypted_key:i||void 0},e,r),d={plaintext:c.plaintext,protectedHeader:c.protectedHeader};return typeof e=="function"?{...d,key:c.key}:d}async function d3(t,e,r){if(!Xe(t))throw new F("General JWE must be an object");if(!Array.isArray(t.recipients)||!t.recipients.every(Xe))throw new F("JWE Recipients missing or incorrect type");if(!t.recipients.length)throw new F("JWE Recipients has no members");for(const n of t.recipients)try{return await g0({aad:t.aad,ciphertext:t.ciphertext,encrypted_key:n.encrypted_key,header:n.header,iv:t.iv,protected:t.protected,tag:t.tag,unprotected:t.unprotected},e,r)}catch{}throw new Ba}const VC=Symbol(),p3=async t=>{if(t instanceof Uint8Array)return{kty:"oct",k:Ze(t)};if(!lr(t))throw new TypeError(jt(t,...Ut,"Uint8Array"));if(!t.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");const{ext:e,key_ops:r,alg:n,use:i,...o}=await ie.subtle.exportKey("jwk",t);return o};async function f3(t){return W2(t)}async function h3(t){return J2(t)}async function MC(t){return p3(t)}async function NC(t,e,r,n,i={}){var u;let o,s,l;switch($C(t,r,"encrypt"),r=await((u=uo.normalizePublicKey)==null?void 0:u.call(uo,r,t))||r,t){case"dir":{l=r;break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!SC(r))throw new we("ECDH with the provided key is not allowed or not supported by your javascript runtime");const{apu:c,apv:d}=i;let{epk:f}=i;f||(f=(await U2(r)).privateKey);const{x:h,y:g,crv:b,kty:w}=await MC(f),C=await AC(r,f,t==="ECDH-ES"?e:t,t==="ECDH-ES"?m0(e):parseInt(t.slice(-5,-2),10),c,d);if(s={epk:{x:h,crv:b,kty:w}},w==="EC"&&(s.epk.y=g),c&&(s.apu=Ze(c)),d&&(s.apv=Ze(d)),t==="ECDH-ES"){l=C;break}l=n||ds(e);const y=t.slice(-6);o=await qb(y,C,l);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{l=n||ds(e),o=await M2(t,r,l);break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{l=n||ds(e);const{p2c:c,p2s:d}=i;({encryptedKey:o,...s}=await K2(t,r,l,c,d));break}case"A128KW":case"A192KW":case"A256KW":{l=n||ds(e),o=await qb(t,r,l);break}case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{l=n||ds(e);const{iv:c}=i;({encryptedKey:o,...s}=await l3(t,r,l,c));break}default:throw new we('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:l,encryptedKey:o,parameters:s}}class oh{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("plaintext must be an instance of Uint8Array");this._plaintext=e}setKeyManagementParameters(e){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._sharedUnprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._sharedUnprotectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}setContentEncryptionKey(e){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=e,this}async encrypt(e,r){if(!this._protectedHeader&&!this._unprotectedHeader&&!this._sharedUnprotectedHeader)throw new F("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!Kc(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new F("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const n={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if(Mc(F,new Map,r==null?void 0:r.crit,this._protectedHeader,n),n.zip!==void 0)throw new we('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:i,enc:o}=n;if(typeof i!="string"||!i)throw new F('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(typeof o!="string"||!o)throw new F('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');let s;if(this._cek&&(i==="dir"||i==="ECDH-ES"))throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${i}`);let l;{let w;({cek:l,encryptedKey:s,parameters:w}=await NC(i,o,e,this._cek,this._keyManagementParameters)),w&&(r&&VC in r?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...w}:this.setUnprotectedHeader(w):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...w}:this.setProtectedHeader(w))}let u,c,d;this._protectedHeader?c=He.encode(Ze(JSON.stringify(this._protectedHeader))):c=He.encode(""),this._aad?(d=Ze(this._aad),u=Vn(c,He.encode("."),He.encode(d))):u=c;const{ciphertext:f,tag:h,iv:g}=await OC(o,this._plaintext,l,this._iv,u),b={ciphertext:Ze(f)};return g&&(b.iv=Ze(g)),h&&(b.tag=Ze(h)),s&&(b.encrypted_key=Ze(s)),d&&(b.aad=d),this._protectedHeader&&(b.protected=Vr.decode(c)),this._sharedUnprotectedHeader&&(b.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(b.header=this._unprotectedHeader),b}}class y3{constructor(e,r,n){this.parent=e,this.key=r,this.options=n}setUnprotectedHeader(e){if(this.unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this.unprotectedHeader=e,this}addRecipient(...e){return this.parent.addRecipient(...e)}encrypt(...e){return this.parent.encrypt(...e)}done(){return this.parent}}class m3{constructor(e){this._recipients=[],this._plaintext=e}addRecipient(e,r){const n=new y3(this,e,{crit:r==null?void 0:r.crit});return this._recipients.push(n),n}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}async encrypt(){var i,o,s;if(!this._recipients.length)throw new F("at least one recipient must be added");if(this._recipients.length===1){const[l]=this._recipients,u=await new oh(this._plaintext).setAdditionalAuthenticatedData(this._aad).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(l.unprotectedHeader).encrypt(l.key,{...l.options}),c={ciphertext:u.ciphertext,iv:u.iv,recipients:[{}],tag:u.tag};return u.aad&&(c.aad=u.aad),u.protected&&(c.protected=u.protected),u.unprotected&&(c.unprotected=u.unprotected),u.encrypted_key&&(c.recipients[0].encrypted_key=u.encrypted_key),u.header&&(c.recipients[0].header=u.header),c}let e;for(let l=0;l>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:e.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:e.name};default:throw new we(`alg ${t} is not supported either by JOSE or your javascript runtime`)}}async function FC(t,e,r){if(r==="sign"&&(e=await uo.normalizePrivateKey(e,t)),r==="verify"&&(e=await uo.normalizePublicKey(e,t)),lr(e))return D2(e,t,r),e;if(e instanceof Uint8Array){if(!t.startsWith("HS"))throw new TypeError(jt(e,...Ut));return ie.subtle.importKey("raw",e,{hash:`SHA-${t.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError(jt(e,...Ut,"Uint8Array","JSON Web Key"))}const g3=async(t,e,r,n)=>{const i=await FC(t,e,"verify");Jh(t,i);const o=zC(t,i.algorithm);try{return await ie.subtle.verify(o,i,r,n)}catch{return!1}};async function b0(t,e,r){if(!Xe(t))throw new _e("Flattened JWS must be an object");if(t.protected===void 0&&t.header===void 0)throw new _e('Flattened JWS must have either of the "protected" or "header" members');if(t.protected!==void 0&&typeof t.protected!="string")throw new _e("JWS Protected Header incorrect type");if(t.payload===void 0)throw new _e("JWS Payload missing");if(typeof t.signature!="string")throw new _e("JWS Signature missing or incorrect type");if(t.header!==void 0&&!Xe(t.header))throw new _e("JWS Unprotected Header incorrect type");let n={};if(t.protected)try{const w=qe(t.protected);n=JSON.parse(Vr.decode(w))}catch{throw new _e("JWS Protected Header is invalid")}if(!Kc(n,t.header))throw new _e("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const i={...n,...t.header},o=Mc(_e,new Map([["b64",!0]]),r==null?void 0:r.crit,n,i);let s=!0;if(o.has("b64")&&(s=n.b64,typeof s!="boolean"))throw new _e('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:l}=i;if(typeof l!="string"||!l)throw new _e('JWS "alg" (Algorithm) Header Parameter missing or invalid');const u=r&&Wb("algorithms",r.algorithms);if(u&&!u.has(l))throw new Ac('"alg" (Algorithm) Header Parameter value not allowed');if(s){if(typeof t.payload!="string")throw new _e("JWS Payload must be a string")}else if(typeof t.payload!="string"&&!(t.payload instanceof Uint8Array))throw new _e("JWS Payload must be a string or an Uint8Array instance");let c=!1;typeof e=="function"?(e=await e(n,t),c=!0,Xb(l,e,"verify"),Ma(e)&&(e=await Vc(e,l))):Xb(l,e,"verify");const d=Vn(He.encode(t.protected??""),He.encode("."),typeof t.payload=="string"?He.encode(t.payload):t.payload);let f;try{f=qe(t.signature)}catch{throw new _e("Failed to base64url decode the signature")}if(!await g3(l,e,f,d))throw new Hh;let g;if(s)try{g=qe(t.payload)}catch{throw new _e("Failed to base64url decode the payload")}else typeof t.payload=="string"?g=He.encode(t.payload):g=t.payload;const b={payload:g};return t.protected!==void 0&&(b.protectedHeader=n),t.header!==void 0&&(b.unprotectedHeader=t.header),c?{...b,key:e}:b}async function qC(t,e,r){if(t instanceof Uint8Array&&(t=Vr.decode(t)),typeof t!="string")throw new _e("Compact JWS must be a string or Uint8Array");const{0:n,1:i,2:o,length:s}=t.split(".");if(s!==3)throw new _e("Invalid Compact JWS");const l=await b0({payload:i,protected:n,signature:o},e,r),u={payload:l.payload,protectedHeader:l.protectedHeader};return typeof e=="function"?{...u,key:l.key}:u}async function b3(t,e,r){if(!Xe(t))throw new _e("General JWS must be an object");if(!Array.isArray(t.signatures)||!t.signatures.every(Xe))throw new _e("JWS Signatures missing or incorrect type");for(const n of t.signatures)try{return await b0({header:n.header,payload:t.payload,protected:n.protected,signature:n.signature},e,r)}catch{}throw new Hh}const Ki=t=>Math.floor(t.getTime()/1e3),GC=60,HC=GC*60,v0=HC*24,v3=v0*7,E3=v0*365.25,w3=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,zu=t=>{const e=w3.exec(t);if(!e||e[4]&&e[1])throw new TypeError("Invalid time period format");const r=parseFloat(e[2]),n=e[3].toLowerCase();let i;switch(n){case"sec":case"secs":case"second":case"seconds":case"s":i=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":i=Math.round(r*GC);break;case"hour":case"hours":case"hr":case"hrs":case"h":i=Math.round(r*HC);break;case"day":case"days":case"d":i=Math.round(r*v0);break;case"week":case"weeks":case"w":i=Math.round(r*v3);break;default:i=Math.round(r*E3);break}return e[1]==="-"||e[4]==="ago"?-i:i},ER=t=>t.toLowerCase().replace(/^application\//,""),_3=(t,e)=>typeof t=="string"?e.includes(t):Array.isArray(t)?e.some(Set.prototype.has.bind(new Set(t))):!1,E0=(t,e,r={})=>{let n;try{n=JSON.parse(Vr.decode(e))}catch{}if(!Xe(n))throw new zt("JWT Claims Set must be a top-level JSON object");const{typ:i}=r;if(i&&(typeof t.typ!="string"||ER(t.typ)!==ER(i)))throw new Mt('unexpected "typ" JWT header value',n,"typ","check_failed");const{requiredClaims:o=[],issuer:s,subject:l,audience:u,maxTokenAge:c}=r,d=[...o];c!==void 0&&d.push("iat"),u!==void 0&&d.push("aud"),l!==void 0&&d.push("sub"),s!==void 0&&d.push("iss");for(const b of new Set(d.reverse()))if(!(b in n))throw new Mt(`missing required "${b}" claim`,n,b,"missing");if(s&&!(Array.isArray(s)?s:[s]).includes(n.iss))throw new Mt('unexpected "iss" claim value',n,"iss","check_failed");if(l&&n.sub!==l)throw new Mt('unexpected "sub" claim value',n,"sub","check_failed");if(u&&!_3(n.aud,typeof u=="string"?[u]:u))throw new Mt('unexpected "aud" claim value',n,"aud","check_failed");let f;switch(typeof r.clockTolerance){case"string":f=zu(r.clockTolerance);break;case"number":f=r.clockTolerance;break;case"undefined":f=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:h}=r,g=Ki(h||new Date);if((n.iat!==void 0||c)&&typeof n.iat!="number")throw new Mt('"iat" claim must be a number',n,"iat","invalid");if(n.nbf!==void 0){if(typeof n.nbf!="number")throw new Mt('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>g+f)throw new Mt('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(n.exp!==void 0){if(typeof n.exp!="number")throw new Mt('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=g-f)throw new th('"exp" claim timestamp check failed',n,"exp","check_failed")}if(c){const b=g-n.iat,w=typeof c=="number"?c:zu(c);if(b-f>w)throw new th('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(b<0-f)throw new Mt('"iat" claim timestamp check failed (it should be in the past)',n,"iat","check_failed")}return n};async function x3(t,e,r){var s;const n=await qC(t,e,r);if((s=n.protectedHeader.crit)!=null&&s.includes("b64")&&n.protectedHeader.b64===!1)throw new zt("JWTs MUST NOT use unencoded payload");const o={payload:E0(n.protectedHeader,n.payload,r),protectedHeader:n.protectedHeader};return typeof e=="function"?{...o,key:n.key}:o}async function R3(t,e,r){const n=await KC(t,e,r),i=E0(n.protectedHeader,n.plaintext,r),{protectedHeader:o}=n;if(o.iss!==void 0&&o.iss!==i.iss)throw new Mt('replicated "iss" claim header parameter mismatch',i,"iss","mismatch");if(o.sub!==void 0&&o.sub!==i.sub)throw new Mt('replicated "sub" claim header parameter mismatch',i,"sub","mismatch");if(o.aud!==void 0&&JSON.stringify(o.aud)!==JSON.stringify(i.aud))throw new Mt('replicated "aud" claim header parameter mismatch',i,"aud","mismatch");const s={payload:i,protectedHeader:o};return typeof e=="function"?{...s,key:n.key}:s}class XC{constructor(e){this._flattened=new oh(e)}setContentEncryptionKey(e){return this._flattened.setContentEncryptionKey(e),this}setInitializationVector(e){return this._flattened.setInitializationVector(e),this}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}setKeyManagementParameters(e){return this._flattened.setKeyManagementParameters(e),this}async encrypt(e,r){const n=await this._flattened.encrypt(e,r);return[n.protected,n.encrypted_key,n.iv,n.ciphertext,n.tag].join(".")}}const A3=async(t,e,r)=>{const n=await FC(t,e,"sign");Jh(t,n);const i=await ie.subtle.sign(zC(t,n.algorithm),n,r);return new Uint8Array(i)};class w0{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=e}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}async sign(e,r){if(!this._protectedHeader&&!this._unprotectedHeader)throw new _e("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!Kc(this._protectedHeader,this._unprotectedHeader))throw new _e("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const n={...this._protectedHeader,...this._unprotectedHeader},i=Mc(_e,new Map([["b64",!0]]),r==null?void 0:r.crit,this._protectedHeader,n);let o=!0;if(i.has("b64")&&(o=this._protectedHeader.b64,typeof o!="boolean"))throw new _e('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:s}=n;if(typeof s!="string"||!s)throw new _e('JWS "alg" (Algorithm) Header Parameter missing or invalid');Xb(s,e,"sign");let l=this._payload;o&&(l=He.encode(Ze(l)));let u;this._protectedHeader?u=He.encode(Ze(JSON.stringify(this._protectedHeader))):u=He.encode("");const c=Vn(u,He.encode("."),l),d=await A3(s,e,c),f={signature:Ze(d),payload:""};return o&&(f.payload=Vr.decode(l)),this._unprotectedHeader&&(f.header=this._unprotectedHeader),this._protectedHeader&&(f.protected=Vr.decode(u)),f}}class WC{constructor(e){this._flattened=new w0(e)}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}async sign(e,r){const n=await this._flattened.sign(e,r);if(n.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${n.protected}.${n.payload}.${n.signature}`}}class S3{constructor(e,r,n){this.parent=e,this.key=r,this.options=n}setProtectedHeader(e){if(this.protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this.protectedHeader=e,this}setUnprotectedHeader(e){if(this.unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this.unprotectedHeader=e,this}addSignature(...e){return this.parent.addSignature(...e)}sign(...e){return this.parent.sign(...e)}done(){return this.parent}}class C3{constructor(e){this._signatures=[],this._payload=e}addSignature(e,r){const n=new S3(this,e,r);return this._signatures.push(n),n}async sign(){if(!this._signatures.length)throw new _e("at least one signature must be added");const e={signatures:[],payload:""};for(let r=0;r"u"?this._payload={...this._payload,iat:Ki(new Date)}:e instanceof Date?this._payload={...this._payload,iat:es("setIssuedAt",Ki(e))}:typeof e=="string"?this._payload={...this._payload,iat:es("setIssuedAt",Ki(new Date)+zu(e))}:this._payload={...this._payload,iat:es("setIssuedAt",e)},this}}class T3 extends _0{setProtectedHeader(e){return this._protectedHeader=e,this}async sign(e,r){var i;const n=new WC(He.encode(JSON.stringify(this._payload)));if(n.setProtectedHeader(this._protectedHeader),Array.isArray((i=this._protectedHeader)==null?void 0:i.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===!1)throw new zt("JWTs MUST NOT use unencoded payload");return n.sign(e,r)}}class k3 extends _0{setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setKeyManagementParameters(e){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setContentEncryptionKey(e){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=e,this}replicateIssuerAsHeader(){return this._replicateIssuerAsHeader=!0,this}replicateSubjectAsHeader(){return this._replicateSubjectAsHeader=!0,this}replicateAudienceAsHeader(){return this._replicateAudienceAsHeader=!0,this}async encrypt(e,r){const n=new XC(He.encode(JSON.stringify(this._payload)));return this._replicateIssuerAsHeader&&(this._protectedHeader={...this._protectedHeader,iss:this._payload.iss}),this._replicateSubjectAsHeader&&(this._protectedHeader={...this._protectedHeader,sub:this._payload.sub}),this._replicateAudienceAsHeader&&(this._protectedHeader={...this._protectedHeader,aud:this._payload.aud}),n.setProtectedHeader(this._protectedHeader),this._iv&&n.setInitializationVector(this._iv),this._cek&&n.setContentEncryptionKey(this._cek),this._keyManagementParameters&&n.setKeyManagementParameters(this._keyManagementParameters),n.encrypt(e,r)}}const Bi=(t,e)=>{if(typeof t!="string"||!t)throw new f0(`${e} missing or invalid`)};async function JC(t,e){if(!Xe(t))throw new TypeError("JWK must be an object");if(e??(e="sha256"),e!=="sha256"&&e!=="sha384"&&e!=="sha512")throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');let r;switch(t.kty){case"EC":Bi(t.crv,'"crv" (Curve) Parameter'),Bi(t.x,'"x" (X Coordinate) Parameter'),Bi(t.y,'"y" (Y Coordinate) Parameter'),r={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case"OKP":Bi(t.crv,'"crv" (Subtype of Key Pair) Parameter'),Bi(t.x,'"x" (Public Key) Parameter'),r={crv:t.crv,kty:t.kty,x:t.x};break;case"RSA":Bi(t.e,'"e" (Exponent) Parameter'),Bi(t.n,'"n" (Modulus) Parameter'),r={e:t.e,kty:t.kty,n:t.n};break;case"oct":Bi(t.k,'"k" (Key Value) Parameter'),r={k:t.k,kty:t.kty};break;default:throw new we('"kty" (Key Type) Parameter missing or unsupported')}const n=He.encode(JSON.stringify(r));return Ze(await fC(e,n))}async function L3(t,e){e??(e="sha256");const r=await JC(t,e);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${e.slice(-3)}:${r}`}async function P3(t,e){const r={...t,...e==null?void 0:e.header};if(!Xe(r.jwk))throw new _e('"jwk" (JSON Web Key) Header Parameter must be a JSON object');const n=await Vc({...r.jwk,ext:!0},r.alg);if(n instanceof Uint8Array||n.type!=="public")throw new _e('"jwk" (JSON Web Key) Header Parameter must be a public key');return n}function D3(t){switch(typeof t=="string"&&t.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new we('Unsupported "alg" value for a JSON Web Key Set')}}function B3(t){return t&&typeof t=="object"&&Array.isArray(t.keys)&&t.keys.every(I3)}function I3(t){return Xe(t)}function ZC(t){return typeof structuredClone=="function"?structuredClone(t):JSON.parse(JSON.stringify(t))}class j3{constructor(e){if(this._cached=new WeakMap,!B3(e))throw new qh("JSON Web Key Set malformed");this._jwks=ZC(e)}async getKey(e,r){const{alg:n,kid:i}={...e,...r==null?void 0:r.header},o=D3(n),s=this._jwks.keys.filter(c=>{let d=o===c.kty;if(d&&typeof i=="string"&&(d=i===c.kid),d&&typeof c.alg=="string"&&(d=n===c.alg),d&&typeof c.use=="string"&&(d=c.use==="sig"),d&&Array.isArray(c.key_ops)&&(d=c.key_ops.includes("verify")),d)switch(n){case"ES256":d=c.crv==="P-256";break;case"ES256K":d=c.crv==="secp256k1";break;case"ES384":d=c.crv==="P-384";break;case"ES512":d=c.crv==="P-521";break;case"Ed25519":d=c.crv==="Ed25519";break;case"EdDSA":d=c.crv==="Ed25519"||c.crv==="Ed448";break}return d}),{0:l,length:u}=s;if(u===0)throw new Gh;if(u!==1){const c=new h0,{_cached:d}=this;throw c[Symbol.asyncIterator]=async function*(){for(const f of s)try{yield await wR(d,f,n)}catch{}},c}return wR(this._cached,l,n)}}async function wR(t,e,r){const n=t.get(e)||t.set(e,{}).get(e);if(n[r]===void 0){const i=await Vc({...e,ext:!0},r);if(i instanceof Uint8Array||i.type!=="public")throw new qh("JSON Web Key Set members must be public keys");n[r]=i}return n[r]}function Jb(t){const e=new j3(t),r=async(n,i)=>e.getKey(n,i);return Object.defineProperties(r,{jwks:{value:()=>ZC(e._jwks),enumerable:!0,configurable:!1,writable:!1}}),r}const U3=async(t,e,r)=>{let n,i,o=!1;typeof AbortController=="function"&&(n=new AbortController,i=setTimeout(()=>{o=!0,n.abort()},e));const s=await fetch(t.href,{signal:n?n.signal:void 0,redirect:"manual",headers:r.headers}).catch(l=>{throw o?new y0:l});if(i!==void 0&&clearTimeout(i),s.status!==200)throw new mt("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await s.json()}catch{throw new mt("Failed to parse the JSON Web Key Set HTTP response as JSON")}};function $3(){return typeof WebSocketPair<"u"||typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime<"u"&&EdgeRuntime==="vercel"}let Zb;var Qp,LA;(typeof navigator>"u"||!((LA=(Qp=navigator.userAgent)==null?void 0:Qp.startsWith)!=null&&LA.call(Qp,"Mozilla/5.0 ")))&&(Zb="jose/v5.10.0");const Fu=Symbol();function O3(t,e){return!(typeof t!="object"||t===null||!("uat"in t)||typeof t.uat!="number"||Date.now()-t.uat>=e||!("jwks"in t)||!Xe(t.jwks)||!Array.isArray(t.jwks.keys)||!Array.prototype.every.call(t.jwks.keys,Xe))}class K3{constructor(e,r){if(!(e instanceof URL))throw new TypeError("url must be an instance of URL");this._url=new URL(e.href),this._options={agent:r==null?void 0:r.agent,headers:r==null?void 0:r.headers},this._timeoutDuration=typeof(r==null?void 0:r.timeoutDuration)=="number"?r==null?void 0:r.timeoutDuration:5e3,this._cooldownDuration=typeof(r==null?void 0:r.cooldownDuration)=="number"?r==null?void 0:r.cooldownDuration:3e4,this._cacheMaxAge=typeof(r==null?void 0:r.cacheMaxAge)=="number"?r==null?void 0:r.cacheMaxAge:6e5,(r==null?void 0:r[Fu])!==void 0&&(this._cache=r==null?void 0:r[Fu],O3(r==null?void 0:r[Fu],this._cacheMaxAge)&&(this._jwksTimestamp=this._cache.uat,this._local=Jb(this._cache.jwks)))}coolingDown(){return typeof this._jwksTimestamp=="number"?Date.now(){this._local=Jb(r),this._cache&&(this._cache.uat=Date.now(),this._cache.jwks=r),this._jwksTimestamp=Date.now(),this._pendingFetch=void 0}).catch(r=>{throw this._pendingFetch=void 0,r})),await this._pendingFetch}}function V3(t,e){const r=new K3(t,e),n=async(i,o)=>r.getKey(i,o);return Object.defineProperties(n,{coolingDown:{get:()=>r.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>r.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>r.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>!!r._pendingFetch,enumerable:!0,configurable:!1},jwks:{value:()=>{var i;return(i=r._local)==null?void 0:i.jwks()},enumerable:!0,configurable:!1,writable:!1}}),n}const M3=Fu;class N3 extends _0{encode(){const e=Ze(JSON.stringify({alg:"none"})),r=Ze(JSON.stringify(this._payload));return`${e}.${r}.`}static decode(e,r){if(typeof e!="string")throw new zt("Unsecured JWT must be a string");const{0:n,1:i,2:o,length:s}=e.split(".");if(s!==3||o!=="")throw new zt("Invalid Unsecured JWT");let l;try{if(l=JSON.parse(Vr.decode(qe(n))),l.alg!=="none")throw new Error}catch{throw new zt("Invalid Unsecured JWT")}return{payload:E0(l,qe(i),r),header:l}}}const z3=Ze,x0=qe,F3=Object.freeze(Object.defineProperty({__proto__:null,decode:x0,encode:z3},Symbol.toStringTag,{value:"Module"}));function q3(t){let e;if(typeof t=="string"){const r=t.split(".");(r.length===3||r.length===5)&&([e]=r)}else if(typeof t=="object"&&t)if("protected"in t)e=t.protected;else throw new TypeError("Token does not contain a Protected Header");try{if(typeof e!="string"||!e)throw new Error;const r=JSON.parse(Vr.decode(x0(e)));if(!Xe(r))throw new Error;return r}catch{throw new TypeError("Invalid Token or Protected Header formatting")}}function G3(t){if(typeof t!="string")throw new zt("JWTs must use Compact JWS serialization, JWT must be a string");const{1:e,length:r}=t.split(".");if(r===5)throw new zt("Only JWTs using Compact JWS serialization can be decoded");if(r!==3)throw new zt("Invalid JWT");if(!e)throw new zt("JWTs must contain a payload");let n;try{n=x0(e)}catch{throw new zt("Failed to base64url decode the payload")}let i;try{i=JSON.parse(Vr.decode(n))}catch{throw new zt("Failed to parse the decoded payload as JSON")}if(!Xe(i))throw new zt("Invalid JWT Claims Set");return i}async function H3(t,e){let r,n,i;switch(t){case"HS256":case"HS384":case"HS512":r=parseInt(t.slice(-3),10),n={name:"HMAC",hash:`SHA-${r}`,length:r},i=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r=parseInt(t.slice(-3),10),Xh(new Uint8Array(r>>3));case"A128KW":case"A192KW":case"A256KW":r=parseInt(t.slice(1,4),10),n={name:"AES-KW",length:r},i=["wrapKey","unwrapKey"];break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":r=parseInt(t.slice(1,4),10),n={name:"AES-GCM",length:r},i=["encrypt","decrypt"];break;default:throw new we('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return ie.subtle.generateKey(n,(e==null?void 0:e.extractable)??!1,i)}function vg(t){const e=(t==null?void 0:t.modulusLength)??2048;if(typeof e!="number"||e<2048)throw new we("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return e}async function X3(t,e){let r,n;switch(t){case"PS256":case"PS384":case"PS512":r={name:"RSA-PSS",hash:`SHA-${t.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:vg(e)},n=["sign","verify"];break;case"RS256":case"RS384":case"RS512":r={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:vg(e)},n=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":r={name:"RSA-OAEP",hash:`SHA-${parseInt(t.slice(-3),10)||1}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:vg(e)},n=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":r={name:"ECDSA",namedCurve:"P-256"},n=["sign","verify"];break;case"ES384":r={name:"ECDSA",namedCurve:"P-384"},n=["sign","verify"];break;case"ES512":r={name:"ECDSA",namedCurve:"P-521"},n=["sign","verify"];break;case"Ed25519":r={name:"Ed25519"},n=["sign","verify"];break;case"EdDSA":{n=["sign","verify"];const i=(e==null?void 0:e.crv)??"Ed25519";switch(i){case"Ed25519":case"Ed448":r={name:i};break;default:throw new we("Invalid or unsupported crv option provided")}break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{n=["deriveKey","deriveBits"];const i=(e==null?void 0:e.crv)??"P-256";switch(i){case"P-256":case"P-384":case"P-521":{r={name:"ECDH",namedCurve:i};break}case"X25519":case"X448":r={name:i};break;default:throw new we("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}break}default:throw new we('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return ie.subtle.generateKey(r,(e==null?void 0:e.extractable)??!1,n)}async function W3(t,e){return X3(t,e)}async function J3(t,e){return H3(t,e)}const Z3="WebCryptoAPI",Q3=Object.freeze(Object.defineProperty({__proto__:null,CompactEncrypt:XC,CompactSign:WC,EmbeddedJWK:P3,EncryptJWT:k3,FlattenedEncrypt:oh,FlattenedSign:w0,GeneralEncrypt:m3,GeneralSign:C3,SignJWT:T3,UnsecuredJWT:N3,base64url:F3,calculateJwkThumbprint:JC,calculateJwkThumbprintUri:L3,compactDecrypt:KC,compactVerify:qC,createLocalJWKSet:Jb,createRemoteJWKSet:V3,cryptoRuntime:Z3,decodeJwt:G3,decodeProtectedHeader:q3,errors:T2,experimental_jwksCache:M3,exportJWK:MC,exportPKCS8:h3,exportSPKI:f3,flattenedDecrypt:g0,flattenedVerify:b0,generalDecrypt:d3,generalVerify:b3,generateKeyPair:W3,generateSecret:J3,importJWK:Vc,importPKCS8:n3,importSPKI:t3,importX509:r3,jwksCache:Fu,jwtDecrypt:R3,jwtVerify:x3},Symbol.toStringTag,{value:"Module"})),Y3=bh(Q3);var R0={};Object.defineProperty(R0,"__esModule",{value:!0});R0.either=ez;function ez(t,e){if(t!=null&&e!=null&&t!==e)throw new TypeError(`Expected "${e}", got "${t}"`);return t??e??void 0}Object.defineProperty(Fh,"__esModule",{value:!0});Fh.JoseKey=void 0;const as=Y3,We=Si,tz=R0,{JOSEError:_R}=as.errors;class A0 extends We.Key{async getKeyObj(e){if(!this.algorithms.includes(e))throw new We.JwkError(`Key cannot be used with algorithm "${e}"`);try{return await(0,as.importJWK)(this.jwk,e)}catch(r){throw new We.JwkError("Failed to import JWK",void 0,{cause:r})}}async createJwt(e,r){try{const{kid:n}=e;if(n&&n!==this.kid)throw new We.JwtCreateError(`Invalid "kid" (${n}) used to sign with key "${this.kid}"`);const{alg:i}=e;if(!i)throw new We.JwtCreateError('Missing "alg" in JWT header');const o=await this.getKeyObj(i);return await new as.SignJWT(r).setProtectedHeader({...e,alg:i,kid:this.kid}).sign(o)}catch(n){throw n instanceof _R?new We.JwtCreateError(n.message,n.code,{cause:n}):We.JwtCreateError.from(n)}}async verifyJwt(e,r){try{const n=await(0,as.jwtVerify)(e,async({alg:s})=>this.getKeyObj(s),{...r,algorithms:this.algorithms}),i=We.jwtHeaderSchema.safeParse(n.protectedHeader);if(!i.success)throw new We.JwtVerifyError("Invalid JWT header",void 0,{cause:i.error});const o=We.jwtPayloadSchema.safeParse(n.payload);if(!o.success)throw new We.JwtVerifyError("Invalid JWT payload",void 0,{cause:o.error});return{protectedHeader:i.data,payload:o.data}}catch(n){throw n instanceof _R?new We.JwtVerifyError(n.message,n.code,{cause:n}):We.JwtVerifyError.from(n)}}static async generateKeyPair(e=["ES256"],r){if(!e.length)throw new We.JwkError("No algorithms provided for key generation");const n=[];for(const i of e)try{return await(0,as.generateKeyPair)(i,r)}catch(o){n.push(o)}throw new We.JwkError("Failed to generate key pair",void 0,{cause:new AggregateError(n,"None of the algorithms worked")})}static async generate(e=["ES256"],r,n){const i=await this.generateKeyPair(e,{...n,extractable:!0});return this.fromImportable(i.privateKey,r)}static async fromImportable(e,r){if(typeof e=="string"){if(e.startsWith("-----"))return this.fromPKCS8(e,"",r);if(e.startsWith("{"))return this.fromJWK(e,r);throw new We.JwkError("Invalid input")}if(typeof e=="object")return"kty"in e||"alg"in e?this.fromJWK(e,r):this.fromKeyLike(e,r);throw new We.JwkError("Invalid input")}static async fromKeyLike(e,r,n){const i=await(0,as.exportJWK)(e);if(n){if(!i.alg)i.alg=n;else if(i.alg!==n)throw new We.JwkError('Invalid "alg" in JWK')}return this.fromJWK(i,r)}static async fromPKCS8(e,r,n){const i=await(0,as.importPKCS8)(e,r,{extractable:!0});return this.fromKeyLike(i,n)}static async fromJWK(e,r){const n=typeof e=="string"?JSON.parse(e):e;if(!n||typeof n!="object")throw new We.JwkError("Invalid JWK");const i=(0,tz.either)(n.kid,r),o=n.use||"sig";return new A0(We.jwkValidator.parse({...n,kid:i,use:o}))}}Fh.JoseKey=A0;(function(t){var e=S&&S.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=S&&S.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&e(i,n,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(Fh,t)})(pC);var Nc={};Object.defineProperty(Nc,"__esModule",{value:!0});Nc.toSubtleAlgorithm=rz;Nc.fromSubtleAlgorithm=nz;Nc.isCryptoKeyPair=iz;function rz(t,e,r){switch(t){case"PS256":case"PS384":case"PS512":return{name:"RSA-PSS",hash:`SHA-${t.slice(-3)}`,modulusLength:(r==null?void 0:r.modulusLength)??2048,publicExponent:new Uint8Array([1,0,1])};case"RS256":case"RS384":case"RS512":return{name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.slice(-3)}`,modulusLength:(r==null?void 0:r.modulusLength)??2048,publicExponent:new Uint8Array([1,0,1])};case"ES256":case"ES384":return{name:"ECDSA",namedCurve:`P-${t.slice(-3)}`};case"ES512":return{name:"ECDSA",namedCurve:"P-521"};default:throw new TypeError(`Unsupported alg "${t}"`)}}function nz(t){switch(t.name){case"RSA-PSS":case"RSASSA-PKCS1-v1_5":{const e=t.hash.name;switch(e){case"SHA-256":case"SHA-384":case"SHA-512":return`${t.name==="RSA-PSS"?"PS":"RS"}${e.slice(-3)}`;default:throw new TypeError("unsupported RsaHashedKeyAlgorithm hash")}}case"ECDSA":{const e=t.namedCurve;switch(e){case"P-256":case"P-384":case"P-512":return`ES${e.slice(-3)}`;case"P-521":return"ES512";default:throw new TypeError("unsupported EcKeyAlgorithm namedCurve")}}case"Ed448":case"Ed25519":return"EdDSA";default:throw new TypeError(`Unexpected algorithm "${t.name}"`)}}function iz(t,e){return typeof t=="object"&&t!==null&&"privateKey"in t&&t.privateKey instanceof CryptoKey&&t.privateKey.type==="private"&&(e==null||t.privateKey.extractable===e)&&t.privateKey.usages.includes("sign")&&"publicKey"in t&&t.publicKey instanceof CryptoKey&&t.publicKey.type==="public"&&t.publicKey.extractable===!0&&t.publicKey.usages.includes("verify")}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.WebcryptoKey=t.jwkWithAlgSchema=void 0;const e=G,r=Si,n=pC,i=Nc;t.jwkWithAlgSchema=e.z.intersection(r.jwkSchema,e.z.object({alg:e.z.string()}));class o extends n.JoseKey{static async generate(l=["ES256"],u=crypto.randomUUID(),c){const d=await this.generateKeyPair(l,c);if(!(0,i.isCryptoKeyPair)(d))throw new TypeError("Invalid CryptoKeyPair");return this.fromKeypair(d,u)}static async fromKeypair(l,u){const{key_ops:c,use:d,alg:f=(0,i.fromSubtleAlgorithm)(l.privateKey.algorithm),...h}=await crypto.subtle.exportKey("jwk",l.privateKey.extractable?l.privateKey:l.publicKey);if(d&&d!=="sig")throw new TypeError(`Unsupported JWK use "${d}"`);if(c&&!c.some(g=>g==="sign"||g==="verify"))throw new TypeError(`Invalid key_ops "${c}" for "sig" use`);return new o(t.jwkWithAlgSchema.parse({...h,kid:u,alg:f,use:"sig"}),l)}constructor(l,u){super(l),Object.defineProperty(this,"cryptoKeyPair",{enumerable:!0,configurable:!0,writable:!0,value:u})}get isPrivate(){return!0}get privateJwk(){if(super.isPrivate)return this.jwk;throw new Error("Private Webcrypto Key not exportable")}async getKeyObj(l){if(this.jwk.alg!==l)throw new r.JwkError(`Key cannot be used with algorithm "${l}"`);return this.cryptoKeyPair.privateKey}}t.WebcryptoKey=o})(X1);(function(t){var e=S&&S.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=S&&S.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&e(i,n,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(X1,t)})(jh);var S0={},C0={},Do={},Ci={},On={};Object.defineProperty(On,"__esModule",{value:!0});On.InvalidDidError=On.DidError=void 0;class Sc extends Error{constructor(e,r,n,i=400,o){super(r,{cause:o}),Object.defineProperty(this,"did",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:i})}get statusCode(){return this.status}toString(){return`${this.constructor.name} ${this.code} (${this.did}): ${this.message}`}static from(e,r){if(e instanceof Sc)return e;const n=e instanceof Error?e.message:typeof e=="string"?e:"An unknown error occurred",i=(typeof(e==null?void 0:e.statusCode)=="number"?e.statusCode:void 0)??(typeof(e==null?void 0:e.status)=="number"?e.status:void 0);return new Sc(r,n,"did-unknown-error",i,e)}}On.DidError=Sc;let oz=class extends Sc{constructor(e,r,n){super(e,r,"did-invalid",400,n)}};On.InvalidDidError=oz;var T0={},Is={};Object.defineProperty(Is,"__esModule",{value:!0});Is.DID_PLC_PREFIX=void 0;Is.isDidPlc=sz;Is.asDidPlc=az;Is.assertDidPlc=YC;const Lp=On,Zh="did:plc:";Is.DID_PLC_PREFIX=Zh;const QC=Zh.length,qu=32;function sz(t){if(typeof t!="string"||t.length!==qu||!t.startsWith(Zh))return!1;for(let e=QC;et>=97&&t<=122||t>=50&&t<=55;var tT={},ur={};Object.defineProperty(ur,"__esModule",{value:!0});ur.didSchema=ur.DID_PREFIX=void 0;ur.assertDidMethod=rT;ur.extractDidMethod=lz;ur.assertDidMsid=nT;ur.assertDid=Qh;ur.isDid=uz;ur.asDid=cz;const xR=G,br=On,sh="did:";ur.DID_PREFIX=sh;const ah=sh.length;function rT(t,e=0,r=t.length){if(!Number.isFinite(r)||!Number.isFinite(e)||rt.length)throw new TypeError("Invalid start or end position");if(r===e)throw new br.InvalidDidError(t,"Empty method name");let n;for(let i=e;i122)&&(n<48||n>57))throw new br.InvalidDidError(t,`Invalid character at position ${i} in DID method name`)}function lz(t){const e=t.indexOf(":",ah);return t.slice(ah,e)}function nT(t,e=0,r=t.length){if(!Number.isFinite(r)||!Number.isFinite(e)||rt.length)throw new TypeError("Invalid start or end position");if(r===e)throw new br.InvalidDidError(t,"DID method-specific id must not be empty");let n;for(let i=e;i122)&&(n<65||n>90)&&(n<48||n>57)&&n!==46&&n!==45&&n!==95){if(n===58){if(i===r-1)throw new br.InvalidDidError(t,'DID cannot end with ":"');continue}if(n===37){if(n=t.charCodeAt(++i),(n<48||n>57)&&(n<65||n>70))throw new br.InvalidDidError(t,`Invalid pct-encoded character at position ${i}`);if(n=t.charCodeAt(++i),(n<48||n>57)&&(n<65||n>70))throw new br.InvalidDidError(t,`Invalid pct-encoded character at position ${i}`);if(i>=r)throw new br.InvalidDidError(t,`Incomplete pct-encoded character at position ${i-2}`);continue}throw new br.InvalidDidError(t,`Disallowed character in DID at position ${i}`)}}function Qh(t){if(typeof t!="string")throw new br.InvalidDidError(typeof t,"DID must be a string");const{length:e}=t;if(e>2048)throw new br.InvalidDidError(t,"DID is too long (2048 chars max)");if(!t.startsWith(sh))throw new br.InvalidDidError(t,`DID requires "${sh}" prefix`);const r=t.indexOf(":",ah);if(r===-1)throw new br.InvalidDidError(t,"Missing colon after method name");rT(t,ah,r),nT(t,r+1,e)}function uz(t){try{return Qh(t),!0}catch(e){if(e instanceof br.DidError)return!1;throw e}}function cz(t){return Qh(t),t}ur.didSchema=xR.z.string().superRefine((t,e)=>{try{return Qh(t),!0}catch(r){return e.addIssue({code:xR.z.ZodIssueCode.custom,message:r instanceof Error?r.message:"Unexpected error"}),!1}});(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DID_WEB_PREFIX=void 0,t.isDidWeb=n,t.asDidWeb=i,t.assertDidWeb=o,t.didWebToUrl=s,t.urlToDidWeb=l;const e=On,r=ur;t.DID_WEB_PREFIX="did:web:";function n(u){if(typeof u!="string"||!u.startsWith(t.DID_WEB_PREFIX)||u.charAt(t.DID_WEB_PREFIX.length)===":")return!1;try{return s(u),!0}catch{return!1}}function i(u){return o(u),u}function o(u){if(typeof u!="string")throw new e.InvalidDidError(typeof u,"DID must be a string");if(!u.startsWith(t.DID_WEB_PREFIX))throw new e.InvalidDidError(u,"Invalid did:web prefix");if(u.charAt(t.DID_WEB_PREFIX.length)===":")throw new e.InvalidDidError(u,"did:web MSID must not start with a colon");s(u)}function s(u){(0,r.assertDidMsid)(u,t.DID_WEB_PREFIX.length);const c=t.DID_WEB_PREFIX.length,d=u.indexOf(":",c),f=d===-1?u.slice(c):u.slice(c,d),h=d===-1?"":u.slice(d);try{const g=new URL(`https://${f.replaceAll("%3A",":")}${h.replaceAll(":","/")}`);return g.hostname==="localhost"&&(g.protocol="http:"),g}catch(g){throw new e.InvalidDidError(u,"Invalid Web DID",g)}}function l(u){const c=u.port?`%3A${u.port}`:"",d=u.pathname==="/"?"":u.pathname.replaceAll("/",":");return`did:web:${u.hostname}${c}${d}`}})(tT);(function(t){var e=S&&S.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=S&&S.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&e(i,n,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(Is,t),r(tT,t)})(T0);Object.defineProperty(Ci,"__esModule",{value:!0});Ci.atprotoDidSchema=void 0;Ci.isAtprotoDid=iT;Ci.asAtprotoDid=pz;Ci.assertAtprotoDid=oT;Ci.assertAtprotoDidWeb=k0;Ci.isAtprotoDidWeb=sT;const dz=G,lh=On,mi=T0;Ci.atprotoDidSchema=dz.z.string().refine(iT,'Atproto only allows "plc" and "web" DID methods');function iT(t){return typeof t!="string"?!1:t.startsWith(mi.DID_PLC_PREFIX)?(0,mi.isDidPlc)(t):t.startsWith(mi.DID_WEB_PREFIX)?sT(t):!1}function pz(t){return oT(t),t}function oT(t){if(typeof t!="string")throw new lh.InvalidDidError(typeof t,"DID must be a string");if(t.startsWith(mi.DID_PLC_PREFIX))(0,mi.assertDidPlc)(t);else if(t.startsWith(mi.DID_WEB_PREFIX))k0(t);else throw new lh.InvalidDidError(t,'Atproto only allows "plc" and "web" DID methods')}function k0(t){if((0,mi.assertDidWeb)(t),t.includes(":",mi.DID_WEB_PREFIX.length))throw new lh.InvalidDidError(t,"Atproto does not allow path components in Web DIDs");if(t.includes("%3A",mi.DID_WEB_PREFIX.length)&&!t.startsWith("did:web:localhost%3A"))throw new lh.InvalidDidError(t,"Atproto does not allow port numbers in Web DIDs, except for localhost")}function sT(t){try{return k0(t),!0}catch{return!1}}var aT={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.didDocumentValidator=t.didDocumentSchema=void 0;const e=G,r=ur,n=e.z.string().refine(h=>{try{return new URL(h),!0}catch{return!1}},"RFC3968 compliant URI"),i=e.z.union([r.didSchema,e.z.array(r.didSchema)]),o=e.z.union([n,e.z.string().regex(/^#[^#]+$/)]),s=e.z.object({id:o,type:e.z.string().min(1),controller:i,publicKeyJwk:e.z.record(e.z.string(),e.z.unknown()).optional(),publicKeyMultibase:e.z.string().optional()}),l=o,u=e.z.union([e.z.string(),e.z.array(e.z.string())]),c=e.z.union([n,e.z.record(e.z.string(),n),e.z.array(e.z.union([n,e.z.record(e.z.string(),n)])).nonempty()]),d=e.z.object({id:l,type:u,serviceEndpoint:c}),f=e.z.union([o,s]);t.didDocumentSchema=e.z.object({"@context":e.z.union([e.z.literal("https://www.w3.org/ns/did/v1"),e.z.array(e.z.string().url()).nonempty().refine(h=>h[0]==="https://www.w3.org/ns/did/v1",{message:"First @context must be https://www.w3.org/ns/did/v1"})]),id:r.didSchema,controller:i.optional(),alsoKnownAs:e.z.array(n).optional(),service:e.z.array(d).optional(),authentication:e.z.array(f).optional(),verificationMethod:e.z.array(e.z.union([s,o])).optional()}),t.didDocumentValidator=t.didDocumentSchema.superRefine(({id:h,service:g},b)=>{if(g){const w=new Set;for(let C=0;C{typeof Qb.emitWarning=="function"?Qb.emitWarning(t,e,r,n):console.error(`[${r}] ${e}: ${t}`)};let uh=globalThis.AbortController,RR=globalThis.AbortSignal;var PA;if(typeof uh>"u"){RR=class{constructor(){De(this,"onabort");De(this,"_onabort",[]);De(this,"reason");De(this,"aborted",!1)}addEventListener(n,i){this._onabort.push(i)}},uh=class{constructor(){De(this,"signal",new RR);e()}abort(n){var i,o;if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(const s of this.signal._onabort)s(n);(o=(i=this.signal).onabort)==null||o.call(i,n)}}};let t=((PA=Qb.env)==null?void 0:PA.LRU_CACHE_IGNORE_AC_WARNING)!=="1";const e=()=>{t&&(t=!1,uT("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}const fz=t=>!lT.has(t),Vi=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),cT=t=>Vi(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?ff:null:null;class ff extends Array{constructor(e){super(e),this.fill(0)}}var va;const ps=class ps{constructor(e,r){De(this,"heap");De(this,"length");if(!R(ps,va))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(e),this.length=0}static create(e){const r=cT(e);if(!r)return[];Z(ps,va,!0);const n=new ps(e,r);return Z(ps,va,!1),n}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}};va=new WeakMap,me(ps,va,!1);let Yb=ps;var DA,BA,en,fr,tn,rn,Ea,wa,rt,nn,Je,ke,te,Kt,hr,Lt,ut,on,ct,sn,an,yr,ln,Ji,Vt,V,tv,gs,di,Tc,mr,dT,bs,_a,kc,Mi,Ni,rv,hf,yf,Te,nv,Bu,zi,iv;const Y_=class Y_{constructor(e){me(this,V);me(this,en);me(this,fr);me(this,tn);me(this,rn);me(this,Ea);me(this,wa);De(this,"ttl");De(this,"ttlResolution");De(this,"ttlAutopurge");De(this,"updateAgeOnGet");De(this,"updateAgeOnHas");De(this,"allowStale");De(this,"noDisposeOnSet");De(this,"noUpdateTTL");De(this,"maxEntrySize");De(this,"sizeCalculation");De(this,"noDeleteOnFetchRejection");De(this,"noDeleteOnStaleGet");De(this,"allowStaleOnFetchAbort");De(this,"allowStaleOnFetchRejection");De(this,"ignoreFetchAbort");me(this,rt);me(this,nn);me(this,Je);me(this,ke);me(this,te);me(this,Kt);me(this,hr);me(this,Lt);me(this,ut);me(this,on);me(this,ct);me(this,sn);me(this,an);me(this,yr);me(this,ln);me(this,Ji);me(this,Vt);me(this,gs,()=>{});me(this,di,()=>{});me(this,Tc,()=>{});me(this,mr,()=>!1);me(this,bs,e=>{});me(this,_a,(e,r,n)=>{});me(this,kc,(e,r,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});De(this,DA,"LRUCache");const{max:r=0,ttl:n,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:s,updateAgeOnHas:l,allowStale:u,dispose:c,disposeAfter:d,noDisposeOnSet:f,noUpdateTTL:h,maxSize:g=0,maxEntrySize:b=0,sizeCalculation:w,fetchMethod:C,memoMethod:y,noDeleteOnFetchRejection:m,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:L,ignoreFetchAbort:D}=e;if(r!==0&&!Vi(r))throw new TypeError("max option must be a nonnegative integer");const B=r?cT(r):Array;if(!B)throw new Error("invalid max value: "+r);if(Z(this,en,r),Z(this,fr,g),this.maxEntrySize=b||R(this,fr),this.sizeCalculation=w,this.sizeCalculation){if(!R(this,fr)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(y!==void 0&&typeof y!="function")throw new TypeError("memoMethod must be a function if defined");if(Z(this,wa,y),C!==void 0&&typeof C!="function")throw new TypeError("fetchMethod must be a function if specified");if(Z(this,Ea,C),Z(this,Ji,!!C),Z(this,Je,new Map),Z(this,ke,new Array(r).fill(void 0)),Z(this,te,new Array(r).fill(void 0)),Z(this,Kt,new B(r)),Z(this,hr,new B(r)),Z(this,Lt,0),Z(this,ut,0),Z(this,on,Yb.create(r)),Z(this,rt,0),Z(this,nn,0),typeof c=="function"&&Z(this,tn,c),typeof d=="function"?(Z(this,rn,d),Z(this,ct,[])):(Z(this,rn,void 0),Z(this,ct,void 0)),Z(this,ln,!!R(this,tn)),Z(this,Vt,!!R(this,rn)),this.noDisposeOnSet=!!f,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!m,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!L,this.ignoreFetchAbort=!!D,this.maxEntrySize!==0){if(R(this,fr)!==0&&!Vi(R(this,fr)))throw new TypeError("maxSize must be a positive integer if specified");if(!Vi(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");z(this,V,dT).call(this)}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!l,this.ttlResolution=Vi(i)||i===0?i:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!Vi(this.ttl))throw new TypeError("ttl must be a positive integer if specified");z(this,V,tv).call(this)}if(R(this,en)===0&&this.ttl===0&&R(this,fr)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!R(this,en)&&!R(this,fr)){const j="LRU_CACHE_UNBOUNDED";fz(j)&&(lT.add(j),uT("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",j,Y_))}}static unsafeExposeInternals(e){return{starts:R(e,an),ttls:R(e,yr),sizes:R(e,sn),keyMap:R(e,Je),keyList:R(e,ke),valList:R(e,te),next:R(e,Kt),prev:R(e,hr),get head(){return R(e,Lt)},get tail(){return R(e,ut)},free:R(e,on),isBackgroundFetch:r=>{var n;return z(n=e,V,Te).call(n,r)},backgroundFetch:(r,n,i,o)=>{var s;return z(s=e,V,yf).call(s,r,n,i,o)},moveToTail:r=>{var n;return z(n=e,V,Bu).call(n,r)},indexes:r=>{var n;return z(n=e,V,Mi).call(n,r)},rindexes:r=>{var n;return z(n=e,V,Ni).call(n,r)},isStale:r=>{var n;return R(n=e,mr).call(n,r)}}}get max(){return R(this,en)}get maxSize(){return R(this,fr)}get calculatedSize(){return R(this,nn)}get size(){return R(this,rt)}get fetchMethod(){return R(this,Ea)}get memoMethod(){return R(this,wa)}get dispose(){return R(this,tn)}get disposeAfter(){return R(this,rn)}getRemainingTTL(e){return R(this,Je).has(e)?1/0:0}*entries(){for(const e of z(this,V,Mi).call(this))R(this,te)[e]!==void 0&&R(this,ke)[e]!==void 0&&!z(this,V,Te).call(this,R(this,te)[e])&&(yield[R(this,ke)[e],R(this,te)[e]])}*rentries(){for(const e of z(this,V,Ni).call(this))R(this,te)[e]!==void 0&&R(this,ke)[e]!==void 0&&!z(this,V,Te).call(this,R(this,te)[e])&&(yield[R(this,ke)[e],R(this,te)[e]])}*keys(){for(const e of z(this,V,Mi).call(this)){const r=R(this,ke)[e];r!==void 0&&!z(this,V,Te).call(this,R(this,te)[e])&&(yield r)}}*rkeys(){for(const e of z(this,V,Ni).call(this)){const r=R(this,ke)[e];r!==void 0&&!z(this,V,Te).call(this,R(this,te)[e])&&(yield r)}}*values(){for(const e of z(this,V,Mi).call(this))R(this,te)[e]!==void 0&&!z(this,V,Te).call(this,R(this,te)[e])&&(yield R(this,te)[e])}*rvalues(){for(const e of z(this,V,Ni).call(this))R(this,te)[e]!==void 0&&!z(this,V,Te).call(this,R(this,te)[e])&&(yield R(this,te)[e])}[(BA=Symbol.iterator,DA=Symbol.toStringTag,BA)](){return this.entries()}find(e,r={}){for(const n of z(this,V,Mi).call(this)){const i=R(this,te)[n],o=z(this,V,Te).call(this,i)?i.__staleWhileFetching:i;if(o!==void 0&&e(o,R(this,ke)[n],this))return this.get(R(this,ke)[n],r)}}forEach(e,r=this){for(const n of z(this,V,Mi).call(this)){const i=R(this,te)[n],o=z(this,V,Te).call(this,i)?i.__staleWhileFetching:i;o!==void 0&&e.call(r,o,R(this,ke)[n],this)}}rforEach(e,r=this){for(const n of z(this,V,Ni).call(this)){const i=R(this,te)[n],o=z(this,V,Te).call(this,i)?i.__staleWhileFetching:i;o!==void 0&&e.call(r,o,R(this,ke)[n],this)}}purgeStale(){let e=!1;for(const r of z(this,V,Ni).call(this,{allowStale:!0}))R(this,mr).call(this,r)&&(z(this,V,zi).call(this,R(this,ke)[r],"expire"),e=!0);return e}info(e){const r=R(this,Je).get(e);if(r===void 0)return;const n=R(this,te)[r],i=z(this,V,Te).call(this,n)?n.__staleWhileFetching:n;if(i===void 0)return;const o={value:i};if(R(this,yr)&&R(this,an)){const s=R(this,yr)[r],l=R(this,an)[r];if(s&&l){const u=s-(Gs.now()-l);o.ttl=u,o.start=Date.now()}}return R(this,sn)&&(o.size=R(this,sn)[r]),o}dump(){const e=[];for(const r of z(this,V,Mi).call(this,{allowStale:!0})){const n=R(this,ke)[r],i=R(this,te)[r],o=z(this,V,Te).call(this,i)?i.__staleWhileFetching:i;if(o===void 0||n===void 0)continue;const s={value:o};if(R(this,yr)&&R(this,an)){s.ttl=R(this,yr)[r];const l=Gs.now()-R(this,an)[r];s.start=Math.floor(Date.now()-l)}R(this,sn)&&(s.size=R(this,sn)[r]),e.unshift([n,s])}return e}load(e){this.clear();for(const[r,n]of e){if(n.start){const i=Date.now()-n.start;n.start=Gs.now()-i}this.set(r,n.value,n)}}set(e,r,n={}){var h,g,b,w,C;if(r===void 0)return this.delete(e),this;const{ttl:i=this.ttl,start:o,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:u}=n;let{noUpdateTTL:c=this.noUpdateTTL}=n;const d=R(this,kc).call(this,e,r,n.size||0,l);if(this.maxEntrySize&&d>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=!0),z(this,V,zi).call(this,e,"set"),this;let f=R(this,rt)===0?void 0:R(this,Je).get(e);if(f===void 0)f=R(this,rt)===0?R(this,ut):R(this,on).length!==0?R(this,on).pop():R(this,rt)===R(this,en)?z(this,V,hf).call(this,!1):R(this,rt),R(this,ke)[f]=e,R(this,te)[f]=r,R(this,Je).set(e,f),R(this,Kt)[R(this,ut)]=f,R(this,hr)[f]=R(this,ut),Z(this,ut,f),up(this,rt)._++,R(this,_a).call(this,f,d,u),u&&(u.set="add"),c=!1;else{z(this,V,Bu).call(this,f);const y=R(this,te)[f];if(r!==y){if(R(this,Ji)&&z(this,V,Te).call(this,y)){y.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:m}=y;m!==void 0&&!s&&(R(this,ln)&&((h=R(this,tn))==null||h.call(this,m,e,"set")),R(this,Vt)&&((g=R(this,ct))==null||g.push([m,e,"set"])))}else s||(R(this,ln)&&((b=R(this,tn))==null||b.call(this,y,e,"set")),R(this,Vt)&&((w=R(this,ct))==null||w.push([y,e,"set"])));if(R(this,bs).call(this,f),R(this,_a).call(this,f,d,u),R(this,te)[f]=r,u){u.set="replace";const m=y&&z(this,V,Te).call(this,y)?y.__staleWhileFetching:y;m!==void 0&&(u.oldValue=m)}}else u&&(u.set="update")}if(i!==0&&!R(this,yr)&&z(this,V,tv).call(this),R(this,yr)&&(c||R(this,Tc).call(this,f,i,o),u&&R(this,di).call(this,u,f)),!s&&R(this,Vt)&&R(this,ct)){const y=R(this,ct);let m;for(;m=y==null?void 0:y.shift();)(C=R(this,rn))==null||C.call(this,...m)}return this}pop(){var e;try{for(;R(this,rt);){const r=R(this,te)[R(this,Lt)];if(z(this,V,hf).call(this,!0),z(this,V,Te).call(this,r)){if(r.__staleWhileFetching)return r.__staleWhileFetching}else if(r!==void 0)return r}}finally{if(R(this,Vt)&&R(this,ct)){const r=R(this,ct);let n;for(;n=r==null?void 0:r.shift();)(e=R(this,rn))==null||e.call(this,...n)}}}has(e,r={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=r,o=R(this,Je).get(e);if(o!==void 0){const s=R(this,te)[o];if(z(this,V,Te).call(this,s)&&s.__staleWhileFetching===void 0)return!1;if(R(this,mr).call(this,o))i&&(i.has="stale",R(this,di).call(this,i,o));else return n&&R(this,gs).call(this,o),i&&(i.has="hit",R(this,di).call(this,i,o)),!0}else i&&(i.has="miss");return!1}peek(e,r={}){const{allowStale:n=this.allowStale}=r,i=R(this,Je).get(e);if(i===void 0||!n&&R(this,mr).call(this,i))return;const o=R(this,te)[i];return z(this,V,Te).call(this,o)?o.__staleWhileFetching:o}async fetch(e,r={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:u=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:g=this.ignoreFetchAbort,allowStaleOnFetchAbort:b=this.allowStaleOnFetchAbort,context:w,forceRefresh:C=!1,status:y,signal:m}=r;if(!R(this,Ji))return y&&(y.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:y});const E={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:s,noDisposeOnSet:l,size:u,sizeCalculation:c,noUpdateTTL:d,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:b,ignoreFetchAbort:g,status:y,signal:m};let A=R(this,Je).get(e);if(A===void 0){y&&(y.fetch="miss");const L=z(this,V,yf).call(this,e,A,E,w);return L.__returned=L}else{const L=R(this,te)[A];if(z(this,V,Te).call(this,L)){const ee=n&&L.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",ee&&(y.returnedStale=!0)),ee?L.__staleWhileFetching:L.__returned=L}const D=R(this,mr).call(this,A);if(!C&&!D)return y&&(y.fetch="hit"),z(this,V,Bu).call(this,A),i&&R(this,gs).call(this,A),y&&R(this,di).call(this,y,A),L;const B=z(this,V,yf).call(this,e,A,E,w),pe=B.__staleWhileFetching!==void 0&&n;return y&&(y.fetch=D?"stale":"refresh",pe&&D&&(y.returnedStale=!0)),pe?B.__staleWhileFetching:B.__returned=B}}async forceFetch(e,r={}){const n=await this.fetch(e,r);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,r={}){const n=R(this,wa);if(!n)throw new Error("no memoMethod provided to constructor");const{context:i,forceRefresh:o,...s}=r,l=this.get(e,s);if(!o&&l!==void 0)return l;const u=n(e,l,{options:s,context:i});return this.set(e,u,s),u}get(e,r={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:s}=r,l=R(this,Je).get(e);if(l!==void 0){const u=R(this,te)[l],c=z(this,V,Te).call(this,u);return s&&R(this,di).call(this,s,l),R(this,mr).call(this,l)?(s&&(s.get="stale"),c?(s&&n&&u.__staleWhileFetching!==void 0&&(s.returnedStale=!0),n?u.__staleWhileFetching:void 0):(o||z(this,V,zi).call(this,e,"expire"),s&&n&&(s.returnedStale=!0),n?u:void 0)):(s&&(s.get="hit"),c?u.__staleWhileFetching:(z(this,V,Bu).call(this,l),i&&R(this,gs).call(this,l),u))}else s&&(s.get="miss")}delete(e){return z(this,V,zi).call(this,e,"delete")}clear(){return z(this,V,iv).call(this,"delete")}};en=new WeakMap,fr=new WeakMap,tn=new WeakMap,rn=new WeakMap,Ea=new WeakMap,wa=new WeakMap,rt=new WeakMap,nn=new WeakMap,Je=new WeakMap,ke=new WeakMap,te=new WeakMap,Kt=new WeakMap,hr=new WeakMap,Lt=new WeakMap,ut=new WeakMap,on=new WeakMap,ct=new WeakMap,sn=new WeakMap,an=new WeakMap,yr=new WeakMap,ln=new WeakMap,Ji=new WeakMap,Vt=new WeakMap,V=new WeakSet,tv=function(){const e=new ff(R(this,en)),r=new ff(R(this,en));Z(this,yr,e),Z(this,an,r),Z(this,Tc,(o,s,l=Gs.now())=>{if(r[o]=s!==0?l:0,e[o]=s,s!==0&&this.ttlAutopurge){const u=setTimeout(()=>{R(this,mr).call(this,o)&&z(this,V,zi).call(this,R(this,ke)[o],"expire")},s+1);u.unref&&u.unref()}}),Z(this,gs,o=>{r[o]=e[o]!==0?Gs.now():0}),Z(this,di,(o,s)=>{if(e[s]){const l=e[s],u=r[s];if(!l||!u)return;o.ttl=l,o.start=u,o.now=n||i();const c=o.now-u;o.remainingTTL=l-c}});let n=0;const i=()=>{const o=Gs.now();if(this.ttlResolution>0){n=o;const s=setTimeout(()=>n=0,this.ttlResolution);s.unref&&s.unref()}return o};this.getRemainingTTL=o=>{const s=R(this,Je).get(o);if(s===void 0)return 0;const l=e[s],u=r[s];if(!l||!u)return 1/0;const c=(n||i())-u;return l-c},Z(this,mr,o=>{const s=r[o],l=e[o];return!!l&&!!s&&(n||i())-s>l})},gs=new WeakMap,di=new WeakMap,Tc=new WeakMap,mr=new WeakMap,dT=function(){const e=new ff(R(this,en));Z(this,nn,0),Z(this,sn,e),Z(this,bs,r=>{Z(this,nn,R(this,nn)-e[r]),e[r]=0}),Z(this,kc,(r,n,i,o)=>{if(z(this,V,Te).call(this,n))return 0;if(!Vi(i))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(i=o(n,r),!Vi(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),Z(this,_a,(r,n,i)=>{if(e[r]=n,R(this,fr)){const o=R(this,fr)-e[r];for(;R(this,nn)>o;)z(this,V,hf).call(this,!0)}Z(this,nn,R(this,nn)+e[r]),i&&(i.entrySize=n,i.totalCalculatedSize=R(this,nn))})},bs=new WeakMap,_a=new WeakMap,kc=new WeakMap,Mi=function*({allowStale:e=this.allowStale}={}){if(R(this,rt))for(let r=R(this,ut);!(!z(this,V,rv).call(this,r)||((e||!R(this,mr).call(this,r))&&(yield r),r===R(this,Lt)));)r=R(this,hr)[r]},Ni=function*({allowStale:e=this.allowStale}={}){if(R(this,rt))for(let r=R(this,Lt);!(!z(this,V,rv).call(this,r)||((e||!R(this,mr).call(this,r))&&(yield r),r===R(this,ut)));)r=R(this,Kt)[r]},rv=function(e){return e!==void 0&&R(this,Je).get(R(this,ke)[e])===e},hf=function(e){var o,s;const r=R(this,Lt),n=R(this,ke)[r],i=R(this,te)[r];return R(this,Ji)&&z(this,V,Te).call(this,i)?i.__abortController.abort(new Error("evicted")):(R(this,ln)||R(this,Vt))&&(R(this,ln)&&((o=R(this,tn))==null||o.call(this,i,n,"evict")),R(this,Vt)&&((s=R(this,ct))==null||s.push([i,n,"evict"]))),R(this,bs).call(this,r),e&&(R(this,ke)[r]=void 0,R(this,te)[r]=void 0,R(this,on).push(r)),R(this,rt)===1?(Z(this,Lt,Z(this,ut,0)),R(this,on).length=0):Z(this,Lt,R(this,Kt)[r]),R(this,Je).delete(n),up(this,rt)._--,r},yf=function(e,r,n,i){const o=r===void 0?void 0:R(this,te)[r];if(z(this,V,Te).call(this,o))return o;const s=new uh,{signal:l}=n;l==null||l.addEventListener("abort",()=>s.abort(l.reason),{signal:s.signal});const u={signal:s.signal,options:n,context:i},c=(w,C=!1)=>{const{aborted:y}=s.signal,m=n.ignoreFetchAbort&&w!==void 0;if(n.status&&(y&&!C?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,m&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),y&&!m&&!C)return f(s.signal.reason);const E=g;return R(this,te)[r]===g&&(w===void 0?E.__staleWhileFetching?R(this,te)[r]=E.__staleWhileFetching:z(this,V,zi).call(this,e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,w,u.options))),w},d=w=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=w),f(w)),f=w=>{const{aborted:C}=s.signal,y=C&&n.allowStaleOnFetchAbort,m=y||n.allowStaleOnFetchRejection,E=m||n.noDeleteOnFetchRejection,A=g;if(R(this,te)[r]===g&&(!E||A.__staleWhileFetching===void 0?z(this,V,zi).call(this,e,"fetch"):y||(R(this,te)[r]=A.__staleWhileFetching)),m)return n.status&&A.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),A.__staleWhileFetching;if(A.__returned===A)throw w},h=(w,C)=>{var m;const y=(m=R(this,Ea))==null?void 0:m.call(this,e,o,u);y&&y instanceof Promise&&y.then(E=>w(E===void 0?void 0:E),C),s.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(w(void 0),n.allowStaleOnFetchAbort&&(w=E=>c(E,!0)))})};n.status&&(n.status.fetchDispatched=!0);const g=new Promise(h).then(c,d),b=Object.assign(g,{__abortController:s,__staleWhileFetching:o,__returned:void 0});return r===void 0?(this.set(e,b,{...u.options,status:void 0}),r=R(this,Je).get(e)):R(this,te)[r]=b,b},Te=function(e){if(!R(this,Ji))return!1;const r=e;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof uh},nv=function(e,r){R(this,hr)[r]=e,R(this,Kt)[e]=r},Bu=function(e){e!==R(this,ut)&&(e===R(this,Lt)?Z(this,Lt,R(this,Kt)[e]):z(this,V,nv).call(this,R(this,hr)[e],R(this,Kt)[e]),z(this,V,nv).call(this,R(this,ut),e),Z(this,ut,e))},zi=function(e,r){var i,o,s,l;let n=!1;if(R(this,rt)!==0){const u=R(this,Je).get(e);if(u!==void 0)if(n=!0,R(this,rt)===1)z(this,V,iv).call(this,r);else{R(this,bs).call(this,u);const c=R(this,te)[u];if(z(this,V,Te).call(this,c)?c.__abortController.abort(new Error("deleted")):(R(this,ln)||R(this,Vt))&&(R(this,ln)&&((i=R(this,tn))==null||i.call(this,c,e,r)),R(this,Vt)&&((o=R(this,ct))==null||o.push([c,e,r]))),R(this,Je).delete(e),R(this,ke)[u]=void 0,R(this,te)[u]=void 0,u===R(this,ut))Z(this,ut,R(this,hr)[u]);else if(u===R(this,Lt))Z(this,Lt,R(this,Kt)[u]);else{const d=R(this,hr)[u];R(this,Kt)[d]=R(this,Kt)[u];const f=R(this,Kt)[u];R(this,hr)[f]=R(this,hr)[u]}up(this,rt)._--,R(this,on).push(u)}}if(R(this,Vt)&&((s=R(this,ct))!=null&&s.length)){const u=R(this,ct);let c;for(;c=u==null?void 0:u.shift();)(l=R(this,rn))==null||l.call(this,...c)}return n},iv=function(e){var r,n,i;for(const o of z(this,V,Ni).call(this,{allowStale:!0})){const s=R(this,te)[o];if(z(this,V,Te).call(this,s))s.__abortController.abort(new Error("deleted"));else{const l=R(this,ke)[o];R(this,ln)&&((r=R(this,tn))==null||r.call(this,s,l,e)),R(this,Vt)&&((n=R(this,ct))==null||n.push([s,l,e]))}}if(R(this,Je).clear(),R(this,te).fill(void 0),R(this,ke).fill(void 0),R(this,yr)&&R(this,an)&&(R(this,yr).fill(0),R(this,an).fill(0)),R(this,sn)&&R(this,sn).fill(0),Z(this,Lt,0),Z(this,ut,0),R(this,on).length=0,Z(this,nn,0),Z(this,rt,0),R(this,Vt)&&R(this,ct)){const o=R(this,ct);let s;for(;s=o==null?void 0:o.shift();)(i=R(this,rn))==null||i.call(this,...s)}};let ev=Y_;Yh.LRUCache=ev;var L0={};Object.defineProperty(L0,"__esModule",{value:!0});L0.roughSizeOfObject=hz;const Eg=new WeakMap;function hz(t){const e=new Set,r=[t];let n=0;for(;r.length;){const i=r.pop();switch(typeof i){case"string":n+=12+4*Math.ceil(i.length/4);break;case"number":n+=12;break;case"boolean":n+=4;break;case"object":if(n+=4,i===null)break;if(Eg.has(i)){n+=Eg.get(i);break}if(e.has(i))continue;if(e.add(i),Array.isArray(i))n+=4,r.push(...i);else{n+=8;const o=Object.getOwnPropertyNames(i);for(let s=0;st===null?pT:t,AR=t=>t===pT?null:t;class vz{constructor({sizeCalculation:e,...r}){ls.set(this,void 0),yz(this,ls,new mz.LRUCache({...r,allowStale:!1,updateAgeOnGet:!1,updateAgeOnHas:!1,sizeCalculation:e?(n,i)=>e(AR(n),i):r.maxEntrySize!=null||r.maxSize!=null?gz.roughSizeOfObject:void 0}),"f")}get(e){const r=Pp(this,ls,"f").get(e);if(r!==void 0)return AR(r)}set(e,r){Pp(this,ls,"f").set(e,bz(r))}del(e){Pp(this,ls,"f").delete(e)}clear(){Pp(this,ls,"f").clear()}}Na.SimpleStoreMemory=vz;ls=new WeakMap;Object.defineProperty(zc,"__esModule",{value:!0});zc.DidCacheMemory=void 0;const Ez=Na,SR=3600*1e3,wz=50*1024*1024;class _z extends Ez.SimpleStoreMemory{constructor(e){super((e==null?void 0:e.max)==null?{ttl:SR,maxSize:wz,...e}:{ttl:SR,...e})}}zc.DidCacheMemory=_z;var ey={},za={},ty={};Object.defineProperty(ty,"__esModule",{value:!0});ty.CachedGetter=void 0;const xz=()=>!0,Rz=()=>!1;class Az{constructor(e,r,n){Object.defineProperty(this,"getter",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"store",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"pending",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}async get(e,r={}){var u,c,d;(u=r.signal)==null||u.throwIfAborted();const n=(c=this.options)==null?void 0:c.isStale,i=r.noCache?Rz:r.allowStale||n==null?xz:async f=>!await n(e,f);let o;for(;o=this.pending.get(e);){try{const{isFresh:f,value:h}=await o;if(f||await i(h))return h}catch{}(d=r.signal)==null||d.throwIfAborted()}const s=Promise.resolve().then(async()=>{const f=await this.getStored(e,r);return f!==void 0&&await i(f)?{isFresh:!1,value:f}:Promise.resolve().then(async()=>(0,this.getter)(e,r,f)).catch(async h=>{var g;if(f!==void 0)try{const b=(g=this.options)==null?void 0:g.deleteOnError;await(b==null?void 0:b(h,e,f))&&await this.delStored(e,h)}catch(b){throw new AggregateError([h,b],"Error while deleting stored value")}throw h}).then(async h=>(await this.setStored(e,h),{isFresh:!0,value:h}))}).finally(()=>{this.pending.delete(e)});if(this.pending.has(e))throw new Error("Concurrent request for the same key");this.pending.set(e,s);const{value:l}=await s;return l}async getStored(e,r){try{return await this.store.get(e,r)}catch{return}}async setStored(e,r){var n;try{await this.store.set(e,r)}catch(i){const o=(n=this.options)==null?void 0:n.onStoreError;await(o==null?void 0:o(i,e,r))}}async delStored(e,r){await this.store.del(e)}}ty.CachedGetter=Az;var fT={};Object.defineProperty(fT,"__esModule",{value:!0});(function(t){var e=S&&S.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=S&&S.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&e(i,n,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(ty,t),r(fT,t)})(za);Object.defineProperty(ey,"__esModule",{value:!0});ey.DidResolverCached=void 0;const Sz=za,Cz=zc;class Tz{constructor(e,r=new Cz.DidCacheMemory){Object.defineProperty(this,"getter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.getter=new Sz.CachedGetter((n,i)=>e.resolve(n,i),r)}async resolve(e,r){return this.getter.get(e,r)}}ey.DidResolverCached=Tz;var hT={};Object.defineProperty(hT,"__esModule",{value:!0});var ry={},ny={},Mn={},Fa={};Object.defineProperty(Fa,"__esModule",{value:!0});Fa.FetchError=void 0;class kz extends Error{constructor(e,r,n){super(r,n),Object.defineProperty(this,"statusCode",{enumerable:!0,configurable:!0,writable:!0,value:e})}get expose(){return!0}}Fa.FetchError=kz;var P0={},qa={};Object.defineProperty(qa,"__esModule",{value:!0});qa.toRequestTransformer=Lz;qa.asRequest=yT;function Lz(t){return function(e,r){return t.call(this,yT(e,r))}}function yT(t,e){return!e&&t instanceof Request?t:new Request(t,e)}var Bt={};Object.defineProperty(Bt,"__esModule",{value:!0});Bt.extractUrl=Bt.MaxBytesTransformStream=Bt.ifString=void 0;Bt.isIp=Pz;Bt.padLines=jz;Bt.cancelBody=mT;Bt.logCancellationError=gT;Bt.stringifyMessage=Uz;function Pz(t){return!!(t.match(/^\d+\.\d+\.\d+\.\d+$/)||t.startsWith("[")&&t.endsWith("]"))}const Dz=t=>typeof t=="string"?t:void 0;Bt.ifString=Dz;class Bz extends TransformStream{constructor(e){if(!(e>=0))throw new TypeError("maxBytes must be a non-negative number");let r=0;super({transform:(n,i)=>{(r+=n.length)<=e?i.enqueue(n):i.error(new Error("Response too large"))}})}}Bt.MaxBytesTransformStream=Bz;const Iz=/\r?\n/g;function jz(t,e){return t&&e+t.replace(Iz,`$&${e}`)}async function mT(t,e){t.body&&!t.bodyUsed&&!t.body.locked&&typeof t.body.cancel=="function"&&(typeof e=="function"?t.body.cancel().catch(e):e==="log"?t.body.cancel().catch(gT):await t.body.cancel())}function gT(t){console.warn("Failed to cancel response body",t)}async function Uz(t){try{const e=$z(t.headers),r=await Oz(t);return e&&r?`${e} -${r}`:e||r}finally{mT(t,"log")}}function $z(t){return Array.from(t).map(([e,r])=>`${e}: ${r}`).join(` -`)}async function Oz(t){var e;try{const r=await t.blob();if((e=r.type)!=null&&e.startsWith("text/")){const n=await r.text();return JSON.stringify(n)}if(/application\/(?:\w+\+)?json/.test(r.type)){const n=await r.text();return n.includes(` -`)?JSON.stringify(JSON.parse(n)):n}return`[Body size: ${r.size}, type: ${JSON.stringify(r.type)} ]`}catch{return"[Body could not be read]"}}const Kz=t=>typeof t=="string"?new URL(t):t instanceof URL?t:new URL(t.url);Bt.extractUrl=Kz;(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_FORBIDDEN_DOMAIN_NAMES=t.FetchRequestError=void 0,t.protocolCheckRequestTransform=l,t.explicitRedirectCheckRequestTransform=u,t.requireHostHeaderTransform=c,t.forbiddenDomainNameRequestTransform=d;const e=Fa,r=qa,n=Bt;class i extends e.FetchError{constructor(h,g,b,w){if(g==null||!b){const C=s(o(w==null?void 0:w.cause));g??(g=C[0]),b||(b=C[1])}super(g,b,w),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:h})}get expose(){return this.statusCode!==500}static from(h,g){return g instanceof i?g:new i(h,void 0,void 0,{cause:g})}}t.FetchRequestError=i;function o(f){return f instanceof TypeError&&f.message==="fetch failed"&&f.cause!==void 0?f.cause:f}function s(f){if(typeof f=="string"&&f.length>0)return[500,f];if(!(f instanceof Error))return[500,"Failed to fetch"];switch(f.message){case"failed to fetch the data URL":return[400,f.message];case"unexpected redirect":case"cors failure":case"blocked":case"proxy authentication required":return[502,f.message]}const h=f.code;if(typeof h=="string")switch(!0){case h==="ENOTFOUND":return[400,"Invalid hostname"];case h==="ECONNREFUSED":return[502,"Connection refused"];case h==="DEPTH_ZERO_SELF_SIGNED_CERT":return[502,"Self-signed certificate"];case h.startsWith("ERR_TLS"):return[502,"TLS error"];case h.startsWith("ECONN"):return[502,"Connection error"];default:return[500,`${h} error`]}return[500,f.message]}function l(f){return(h,g)=>{const{protocol:b,port:w}=(0,n.extractUrl)(h),C=(0,r.asRequest)(h,g),y=Object.hasOwn(f,b)?f[b]:void 0;if(y){if(y!==!0){if(!y.allowCustomPort&&w!=="")throw new i(C,400,`Custom ${b} ports not allowed`)}}else throw new i(C,400,`Forbidden protocol "${b}"`);return C}}function u(){return(f,h)=>{const g=(0,r.asRequest)(f,h);if((h==null?void 0:h.redirect)!=null)return g;if(g.redirect==="follow")throw new i(g,500,'Request redirect must be "error" or "manual"');return g}}function c(){return(f,h)=>{const{protocol:g,hostname:b}=(0,n.extractUrl)(f),w=(0,r.asRequest)(f,h);if(g!=="http:"&&g!=="https:")throw new i(w,400,`"${g}" requests are not allowed`);if(!b||(0,n.isIp)(b))throw new i(w,400,"Invalid hostname");return w}}t.DEFAULT_FORBIDDEN_DOMAIN_NAMES=["example.com","*.example.com","example.org","*.example.org","example.net","*.example.net","googleusercontent.com","*.googleusercontent.com"];function d(f=t.DEFAULT_FORBIDDEN_DOMAIN_NAMES){const h=new Set(f);return h.size===0?r.asRequest:async(g,b)=>{const{hostname:w}=(0,n.extractUrl)(g),C=(0,r.asRequest)(g,b);if(h.has(w))throw new i(C,403,"Forbidden hostname");let y=w.indexOf(".");for(;y!==-1;){const m=w.slice(y+1);if(h.has(`*.${m}`))throw new i(C,403,"Forbidden hostname");y=w.indexOf(".",y+1)}return C}}})(P0);var Ye={},iy={},oy={};Object.defineProperty(oy,"__esModule",{value:!0});oy.pipe=Vz;oy.pipeTwo=bT;function Vz(...t){return t.reduce(bT)}function bT(t,e){return async(...r)=>e(await t(...r))}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.pipeTwo=t.pipe=void 0;var e=oy;Object.defineProperty(t,"pipe",{enumerable:!0,get:function(){return e.pipe}}),Object.defineProperty(t,"pipeTwo",{enumerable:!0,get:function(){return e.pipeTwo}})})(iy);var Fc={},Mz=S&&S.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Dp=S&&S.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},us;Object.defineProperty(Fc,"__esModule",{value:!0});Fc.TransformedResponse=void 0;class Nz extends Response{constructor(e,r){if(!e.body)throw new TypeError("Response body is not available");if(e.bodyUsed)throw new TypeError("Response body is already used");super(e.body.pipeThrough(r),{status:e.status,statusText:e.statusText,headers:e.headers}),us.set(this,void 0),Mz(this,us,e,"f")}get url(){return Dp(this,us,"f").url}get redirected(){return Dp(this,us,"f").redirected}get type(){return Dp(this,us,"f").type}get statusText(){return Dp(this,us,"f").statusText}}Fc.TransformedResponse=Nz;us=new WeakMap;Object.defineProperty(Ye,"__esModule",{value:!0});Ye.fetchJsonZodProcessor=Ye.FetchResponseError=void 0;Ye.peekJson=Gz;Ye.checkLength=D0;Ye.extractLength=wT;Ye.extractMime=sy;Ye.cancelBodyOnError=qc;Ye.fetchOkProcessor=Hz;Ye.fetchOkTransformer=_T;Ye.fetchMaxSizeProcessor=Xz;Ye.fetchResponseMaxSizeChecker=xT;Ye.fetchTypeProcessor=RT;Ye.fetchResponseTypeChecker=AT;Ye.fetchResponseJsonTransformer=ST;Ye.fetchJsonProcessor=Wz;Ye.fetchJsonValidatorProcessor=CT;const zz=iy,Fz=Fa,vT=Fc,_s=Bt,ET=/^application\/(?:[^()<>@,;:/[\]\\?={} \t]+\+)?json$/i;class Kn extends Fz.FetchError{constructor(e,r=e.status,n=e.statusText,i){super(r,n,i),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:e})}static async from(e,r=qz,n=e.status,i){const o=typeof r=="string"?r:typeof r=="function"?await r(e):void 0;return new Kn(e,n,o,i)}}Ye.FetchResponseError=Kn;const qz=async t=>{const e=sy(t);if(e)try{if(e==="text/plain")return await t.text();if(ET.test(e)){const r=await t.json();if(typeof r=="string")return r;if(typeof r=="object"&&r!=null){const n=(0,_s.ifString)(r.error_description);if(n)return n;const i=(0,_s.ifString)(r.error);if(i)return i;const o=(0,_s.ifString)(r.message);if(o)return o}}}catch{}};async function Gz(t,e=1/0){if(sy(t)!=="application/json")return;D0(t,e);const n=t.clone();return(t.body&&e<1/0?new vT.TransformedResponse(n,new _s.MaxBytesTransformStream(e)):n).json()}function D0(t,e){if(!(e>=0))throw new TypeError("maxBytes must be a non-negative number");const r=wT(t);if(r!=null&&r>e)throw new Kn(t,502,"Response too large");return r}function wT(t){const e=t.headers.get("Content-Length");if(e==null)return;if(!/^\d+$/.test(e))throw new Kn(t,502,"Invalid Content-Length");const r=Number(e);if(!Number.isSafeInteger(r))throw new Kn(t,502,"Content-Length too large");return r}function sy(t){const e=t.headers.get("Content-Type");if(e!=null)return e.split(";",1)[0].trim()}function qc(t,e=_s.logCancellationError){return async r=>{try{return await t(r)}catch(n){throw await(0,_s.cancelBody)(r,e??void 0),n}}}function Hz(t){return qc(e=>_T(e,t))}async function _T(t,e){if(t.ok)return t;throw await Kn.from(t,e)}function Xz(t){if(t===1/0)return e=>e;if(!Number.isFinite(t)||t<0)throw new TypeError("maxBytes must be a 0, Infinity or a positive number");return qc(e=>xT(e,t))}function xT(t,e){if(e===1/0||(D0(t,e),!t.body))return t;const r=new _s.MaxBytesTransformStream(e);return new vT.TransformedResponse(t,r)}function RT(t,e=!0){const r=typeof t=="string"?n=>n===t:t instanceof RegExp?n=>t.test(n):t;return qc(n=>AT(n,r,e))}async function AT(t,e,r=!0){const n=sy(t);if(n){if(!e(n.toLowerCase()))throw await Kn.from(t,`Unexpected response Content-Type (${n})`,502)}else if(r)throw await Kn.from(t,"Missing response Content-Type header",502);return t}async function ST(t){try{const e=await t.json();return{response:t,json:e}}catch(e){throw new Kn(t,502,"Unable to parse response as JSON",{cause:e})}}function Wz(t=ET,e=!0){return(0,zz.pipe)(RT(t,e),qc(ST))}function CT(t,e){if("parseAsync"in t&&typeof t.parseAsync=="function")return async r=>t.parseAsync(r.json,e);if("parse"in t&&typeof t.parse=="function")return async r=>t.parse(r.json,e);throw new TypeError("Invalid schema")}Ye.fetchJsonZodProcessor=CT;var Ga={};Object.defineProperty(Ga,"__esModule",{value:!0});Ga.timedFetch=void 0;Ga.loggedFetch=Qz;Ga.bindFetch=e4;const Jz=P0,B0=qa,Zz=Fc,Bp=Bt;function Qz({fetch:t=globalThis.fetch,logRequest:e=!0,logResponse:r=!0,logError:n=!0}){const i=e===!0?async l=>{const u=await(0,Bp.stringifyMessage)(l);console.info(`> ${l.method} ${l.url} -${(0,Bp.padLines)(u," ")}`)}:e||void 0,o=r===!0?async l=>{const u=await(0,Bp.stringifyMessage)(l.clone());console.info(`< HTTP/1.1 ${l.status} ${l.statusText} -${(0,Bp.padLines)(u," ")}`)}:r||void 0,s=n===!0?async l=>{console.error("< Error:",l)}:n||void 0;return!i&&!o&&!s?t:(0,B0.toRequestTransformer)(async function(l){i&&await i(l);try{const u=await t.call(this,l);return o&&await o(u,l),u}catch(u){throw s&&await s(u,l),u}})}const Yz=(t=6e4,e=globalThis.fetch)=>{if(t===1/0)return e;if(!Number.isFinite(t)||t<=0)throw new TypeError("Timeout must be positive");return(0,B0.toRequestTransformer)(async function(r){var c,d;const n=new AbortController,i=n.signal,o=()=>{n.abort()},s=()=>{var f;clearTimeout(l),(f=r.signal)==null||f.removeEventListener("abort",o)},l=setTimeout(o,t);typeof l=="object"&&((c=l.unref)==null||c.call(l)),(d=r.signal)==null||d.addEventListener("abort",o),i.addEventListener("abort",s);const u=await e.call(this,r,{signal:i});if(u.body){const f=new TransformStream({flush:s});return new Zz.TransformedResponse(u,f)}else return s(),u})};Ga.timedFetch=Yz;function e4(t=globalThis.fetch,e=globalThis){return(0,B0.toRequestTransformer)(async r=>{try{return await t.call(e,r)}catch(n){throw Jz.FetchRequestError.from(r,n)}})}(function(t){var e=S&&S.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=S&&S.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&e(i,n,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(Fa,t),r(P0,t),r(Ye,t),r(Ga,t),r(qa,t),r(Bt,t)})(Mn);Object.defineProperty(ny,"__esModule",{value:!0});ny.DidResolverBase=void 0;const t4=G,ts=Do,CR=Mn;class r4{constructor(e){Object.defineProperty(this,"methods",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.methods=new Map(Object.entries(e))}async resolve(e,r){var o;(o=r==null?void 0:r.signal)==null||o.throwIfAborted();const n=(0,ts.extractDidMethod)(e),i=this.methods.get(n);if(!i)throw new ts.DidError(e,"Unsupported DID method","did-method-invalid",400);try{const s=await i.resolve(e,r);if(s.id!==e)throw new ts.DidError(e,`DID document id (${s.id}) does not match DID`,"did-document-id-mismatch",400);return s}catch(s){if(s instanceof CR.FetchResponseError){const l=s.response.status>=500?502:s.response.status;throw new ts.DidError(e,s.message,"did-fetch-error",l,s)}throw s instanceof CR.FetchError?new ts.DidError(e,s.message,"did-fetch-error",400,s):s instanceof t4.ZodError?new ts.DidError(e,s.message,"did-document-format-error",503,s):ts.DidError.from(s,e)}}}ny.DidResolverBase=r4;var Gc={};Object.defineProperty(Gc,"__esModule",{value:!0});Gc.DidPlcMethod=void 0;const TT=Do,mf=Mn,n4=iy,i4=(0,n4.pipe)((0,mf.fetchOkProcessor)(),(0,mf.fetchJsonProcessor)(/^application\/(did\+ld\+)?json$/),(0,mf.fetchJsonZodProcessor)(TT.didDocumentValidator));class o4{constructor(e){Object.defineProperty(this,"fetch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"plcDirectoryUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.plcDirectoryUrl=new URL((e==null?void 0:e.plcDirectoryUrl)||"https://plc.directory/"),this.fetch=(0,mf.bindFetch)(e==null?void 0:e.fetch)}async resolve(e,r){(0,TT.assertDidPlc)(e);const n=new URL(`/${encodeURIComponent(e)}`,this.plcDirectoryUrl);return this.fetch(n,{redirect:"error",headers:{accept:"application/did+ld+json,application/json"},signal:r==null?void 0:r.signal}).then(i4)}}Gc.DidPlcMethod=o4;var Ha={};Object.defineProperty(Ha,"__esModule",{value:!0});Ha.DidWebMethod=void 0;Ha.buildDidWebDocumentUrl=kT;const I0=Do,gf=Mn,s4=iy,a4=(0,s4.pipe)((0,gf.fetchOkProcessor)(),(0,gf.fetchJsonProcessor)(/^application\/(did\+ld\+)?json$/),(0,gf.fetchJsonZodProcessor)(I0.didDocumentValidator));class l4{constructor({fetch:e=globalThis.fetch,allowHttp:r=!0}={}){Object.defineProperty(this,"fetch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowHttp",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.fetch=(0,gf.bindFetch)(e),this.allowHttp=r}async resolve(e,r){const n=kT(e);if(!this.allowHttp&&n.protocol==="http:")throw new I0.DidError(e,'Resolution of "http" did:web is not allowed',"did-web-http-not-allowed");return this.fetch(n,{redirect:"error",headers:{accept:"application/did+ld+json,application/json"},signal:r==null?void 0:r.signal}).then(a4)}}Ha.DidWebMethod=l4;function kT(t){const e=(0,I0.didWebToUrl)(t);return e.pathname==="/"?new URL("/.well-known/did.json",e):new URL(`${e.pathname}/did.json`,e)}Object.defineProperty(ry,"__esModule",{value:!0});ry.DidResolverCommon=void 0;const u4=ny,c4=Gc,d4=Ha;class p4 extends u4.DidResolverBase{constructor(e){super({plc:new c4.DidPlcMethod(e),web:new d4.DidWebMethod(e)})}}ry.DidResolverCommon=p4;var LT={};Object.defineProperty(LT,"__esModule",{value:!0});var PT={};(function(t){var e=S&&S.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=S&&S.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&e(i,n,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(Gc,t),r(Ha,t)})(PT);var DT={};Object.defineProperty(DT,"__esModule",{value:!0});(function(t){var e=S&&S.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=S&&S.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&e(i,n,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(Do,t),r(zc,t),r(ey,t),r(hT,t),r(ry,t),r(LT,t),r(PT,t),r(DT,t)})(C0);var ay={},Xa={};Object.defineProperty(Xa,"__esModule",{value:!0});Xa.isResolvedHandle=h4;const f4=Do;function h4(t){return t===null||(0,f4.isAtprotoDid)(t)}var BT={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.AppViewHandleResolver=t.xrpcErrorSchema=void 0;const e=G,r=Xa;t.xrpcErrorSchema=e.z.object({error:e.z.string(),message:e.z.string().optional()});class n{static from(o,s){return typeof o=="string"||o instanceof URL?new n(o,s):o}constructor(o,s){Object.defineProperty(this,"serviceUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fetch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.serviceUrl=new URL(o),this.fetch=(s==null?void 0:s.fetch)??globalThis.fetch}async resolve(o,s){const l=new URL("/xrpc/com.atproto.identity.resolveHandle",this.serviceUrl);l.searchParams.set("handle",o);const u=await this.fetch.call(null,l,{cache:s!=null&&s.noCache?"no-cache":void 0,signal:s==null?void 0:s.signal,redirect:"error"}),c=await u.json();if(u.status===400){const f=t.xrpcErrorSchema.parse(c);if(f.error==="InvalidRequest"&&f.message==="Unable to resolve handle")return null}if(!u.ok)throw new TypeError("Invalid response from resolveHandle method");const d=c==null?void 0:c.did;if(!(0,r.isResolvedHandle)(d))throw new TypeError("Invalid DID returned from resolveHandle method");return d}}t.AppViewHandleResolver=n})(BT);var ly={},Hc={},uy={};Object.defineProperty(uy,"__esModule",{value:!0});uy.DnsHandleResolver=void 0;const y4=Xa,m4="_atproto",wg="did=";class g4{constructor(e){Object.defineProperty(this,"resolveTxt",{enumerable:!0,configurable:!0,writable:!0,value:e})}async resolve(e){const r=await this.resolveTxt.call(null,`${m4}.${e}`);if(!r)return null;for(let n=0;n{};class _4{constructor(e){Object.defineProperty(this,"httpResolver",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dnsResolver",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dnsResolverFallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.httpResolver=new E4.WellKnownHandleResolver(e),this.dnsResolver=new TR.DnsHandleResolver(e.resolveTxt),this.dnsResolverFallback=e.resolveTxtFallback?new TR.DnsHandleResolver(e.resolveTxtFallback):void 0}async resolve(e,r){var s,l,u;(s=r==null?void 0:r.signal)==null||s.throwIfAborted();const n=new AbortController,{signal:i}=n;(l=r==null?void 0:r.signal)==null||l.addEventListener("abort",()=>n.abort(),{signal:i});const o={...r,signal:i};try{const c=this.dnsResolver.resolve(e,o),d=this.httpResolver.resolve(e,o);d.catch(w4);const f=await c;if(f)return f;i.throwIfAborted();const h=await d;return h||(i.throwIfAborted(),((u=this.dnsResolverFallback)==null?void 0:u.resolve(e,o))??null)}finally{n.abort()}}}Hc.AtprotoHandleResolver=_4;Object.defineProperty(ly,"__esModule",{value:!0});ly.AtprotoDohHandleResolver=void 0;const x4=Hc;class R4 extends x4.AtprotoHandleResolver{constructor(e){super({...e,resolveTxt:A4(e),resolveTxtFallback:void 0})}}ly.AtprotoDohHandleResolver=R4;function A4({dohEndpoint:t,fetch:e=globalThis.fetch}){return async r=>{var o,s,l;const n=new URL(t);n.searchParams.set("type","TXT"),n.searchParams.set("name",r);const i=await e(n,{method:"GET",headers:{accept:"application/dns-json"},redirect:"follow"});try{const u=(o=i.headers.get("content-type"))==null?void 0:o.trim();if(i.ok){if((u==null?void 0:u.match(/application\/(dns-)?json/i))==null)throw new TypeError("Unexpected response from DoH server")}else{const d=u!=null&&u.startsWith("text/plain")?await i.text():`Failed to resolve ${r}`;throw new TypeError(d)}return((s=T4(await i.json()).Answer)==null?void 0:s.filter(P4).map(D4))??null}finally{i.bodyUsed===!1&&((l=i.body)==null||l.cancel().catch(S4))}}}function S4(t){(!(t instanceof DOMException)||t.name!=="AbortError")&&console.error("An error occurred while cancelling the response body:",t)}function C4(t){return!(typeof t!="object"||t===null||!("Status"in t)||typeof t.Status!="number"||"Answer"in t&&!k4(t.Answer,L4))}function T4(t){if(C4(t))return t;throw new TypeError("Invalid DoH response")}function k4(t,e){return Array.isArray(t)&&t.every(e)}function L4(t){return typeof t=="object"&&t!==null&&"name"in t&&typeof t.name=="string"&&"type"in t&&typeof t.type=="number"&&"data"in t&&typeof t.data=="string"&&"TTL"in t&&typeof t.TTL=="number"}function P4(t){return t.type===16}function D4(t){return t.data.replace(/^"|"$/g,"").replace(/\\"/g,'"')}var dy={};Object.defineProperty(dy,"__esModule",{value:!0});dy.CachedHandleResolver=void 0;const B4=za,I4=Na;class j4{constructor(e,r=new I4.SimpleStoreMemory({max:1e3,ttl:10*6e4})){Object.defineProperty(this,"getter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.getter=new B4.CachedGetter((n,i)=>e.resolve(n,i),r)}async resolve(e,r){return this.getter.get(e,r)}}dy.CachedHandleResolver=j4;(function(t){var e=S&&S.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=S&&S.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&e(i,n,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(Xa,t),r(BT,t),r(ly,t),r(Hc,t),r(dy,t)})(ay);var Rr={},Xc={};Object.defineProperty(Xc,"__esModule",{value:!0});Xc.CLIENT_ASSERTION_TYPE_JWT_BEARER=void 0;Xc.CLIENT_ASSERTION_TYPE_JWT_BEARER="urn:ietf:params:oauth:client-assertion-type:jwt-bearer";var Ti={},cr={};Object.defineProperty(cr,"__esModule",{value:!0});cr.numberPreprocess=cr.jsonObjectPreprocess=void 0;cr.isHostnameIP=U4;cr.isLoopbackHost=IT;cr.isLoopbackUrl=$4;cr.safeUrl=O4;cr.extractUrlPath=K4;function U4(t){return!!(t.match(/^\d+\.\d+\.\d+\.\d+$/)||t.startsWith("[")&&t.endsWith("]"))}function IT(t){return t==="localhost"||t==="127.0.0.1"||t==="[::1]"}function $4(t){const e=typeof t=="string"?new URL(t):t;return IT(e.hostname)}function O4(t){try{return new URL(t)}catch{return null}}function K4(t){const e=t.startsWith("https://")?8:t.startsWith("http://")?7:-1;if(e===-1)throw new TypeError('URL must use the "https:" or "http:" protocol');const r=t.indexOf("#",e),n=t.indexOf("?",e),i=n!==-1&&(r===-1||no?o:s;if(e===l)throw new TypeError("URL must contain a host");return t.substring(l,o)}const V4=t=>{if(typeof t=="string"&&t.startsWith("{")&&t.endsWith("}"))try{return JSON.parse(t)}catch{return t}return t};cr.jsonObjectPreprocess=V4;const M4=t=>{if(typeof t=="string"){const e=Number(t);if(!Number.isNaN(e))return e}return t};cr.numberPreprocess=M4;(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.privateUseUriSchema=t.webUriSchema=t.httpsUriSchema=t.loopbackUriSchema=t.dangerousUriSchema=void 0;const e=G,r=cr,n=URL.canParse??(i=>{try{return new URL(i),!0}catch{return!1}});t.dangerousUriSchema=e.z.string().refine(i=>i.includes(":")&&n(i),{message:"Invalid URL"}),t.loopbackUriSchema=t.dangerousUriSchema.superRefine((i,o)=>{if(!i.startsWith("http://"))return o.addIssue({code:e.ZodIssueCode.custom,message:'URL must use the "http:" protocol'}),!1;const s=new URL(i);return(0,r.isLoopbackHost)(s.hostname)?!0:(o.addIssue({code:e.ZodIssueCode.custom,message:'URL must use "localhost", "127.0.0.1" or "[::1]" as hostname'}),!1)}),t.httpsUriSchema=t.dangerousUriSchema.superRefine((i,o)=>{if(!i.startsWith("https://"))return o.addIssue({code:e.ZodIssueCode.custom,message:'URL must use the "https:" protocol'}),!1;const s=new URL(i);if((0,r.isLoopbackHost)(s.hostname))return o.addIssue({code:e.ZodIssueCode.custom,message:"https: URL must not use a loopback host"}),!1;if(!(0,r.isHostnameIP)(s.hostname)){if(!s.hostname.includes("."))return o.addIssue({code:e.ZodIssueCode.custom,message:"Domain name must contain at least two segments"}),!1;if(s.hostname.endsWith(".local"))return o.addIssue({code:e.ZodIssueCode.custom,message:'Domain name must not end with ".local"'}),!1}return!0}),t.webUriSchema=e.z.string().superRefine((i,o)=>{if(i.startsWith("http://")){const s=t.loopbackUriSchema.safeParse(i);return s.success||s.error.issues.forEach(o.addIssue,o),s.success}if(i.startsWith("https://")){const s=t.httpsUriSchema.safeParse(i);return s.success||s.error.issues.forEach(o.addIssue,o),s.success}return o.addIssue({code:e.ZodIssueCode.custom,message:'URL must use the "http:" or "https:" protocol'}),!1}),t.privateUseUriSchema=t.dangerousUriSchema.superRefine((i,o)=>{const s=i.indexOf("."),l=i.indexOf(":");if(s===-1||l===-1||s>l)return o.addIssue({code:e.ZodIssueCode.custom,message:'Private-use URI scheme requires a "." as part of the protocol'}),!1;const u=new URL(i);return u.protocol.includes(".")?u.hostname?(o.addIssue({code:e.ZodIssueCode.custom,message:'Private-use URI schemes must not include a hostname (only one "/" is allowed after the protocol, as per RFC 8252)'}),!1):!0:(o.addIssue({code:e.ZodIssueCode.custom,message:"Invalid private-use URI scheme"}),!1)})})(Ti);var j0={},Bo={},ki={};Object.defineProperty(ki,"__esModule",{value:!0});ki.oauthClientIdSchema=void 0;const N4=G;ki.oauthClientIdSchema=N4.z.string().min(1);var Wa={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.oauthRedirectUriSchema=t.oauthPrivateUseRedirectURISchema=t.oauthHttpsRedirectURISchema=t.oauthLoopbackRedirectURISchema=void 0;const e=G,r=Ti;t.oauthLoopbackRedirectURISchema=r.loopbackUriSchema.superRefine((n,i)=>n.startsWith("http://localhost")?(i.addIssue({code:e.ZodIssueCode.custom,message:'Use of "localhost" hostname is not allowed (RFC 8252), use a loopback IP such as "127.0.0.1" instead'}),!1):!0),t.oauthHttpsRedirectURISchema=r.httpsUriSchema,t.oauthPrivateUseRedirectURISchema=r.privateUseUriSchema,t.oauthRedirectUriSchema=e.z.union([t.oauthLoopbackRedirectURISchema,t.oauthHttpsRedirectURISchema,t.oauthPrivateUseRedirectURISchema],{message:'URL must use the "https:" or "http:" protocol, or a private-use URI scheme (RFC 8252)'})})(Wa);var js={};Object.defineProperty(js,"__esModule",{value:!0});js.oauthScopeSchema=void 0;const z4=G;js.oauthScopeSchema=z4.z.string().regex(/^[\x21\x23-\x5B\x5D-\x7E]+(?: [\x21\x23-\x5B\x5D-\x7E]+)*$/);Object.defineProperty(Bo,"__esModule",{value:!0});Bo.oauthClientIdLoopbackSchema=void 0;Bo.isOAuthClientIdLoopback=X4;Bo.assertOAuthLoopbackClientId=jT;Bo.parseOAuthLoopbackClientId=U0;const F4=G,q4=ki,G4=Wa,H4=js,rs="http://localhost";Bo.oauthClientIdLoopbackSchema=q4.oauthClientIdSchema.superRefine((t,e)=>{try{return jT(t),!0}catch(r){return e.addIssue({code:F4.ZodIssueCode.custom,message:r instanceof TypeError?r.message:"Invalid loopback client ID"}),!1}});function X4(t){try{return U0(t),!0}catch{return!1}}function jT(t){U0(t)}function U0(t){if(t.startsWith(rs)){if(t.includes("#",rs.length))throw new TypeError("Loopback ClientID must not contain a hash component")}else throw new TypeError(`Loopback ClientID must start with "${rs}"`);const e=t.length>rs.length&&t[rs.length]==="/"?rs.length+1:rs.length;if(t.length===e)return{};if(t[e]!=="?")throw new TypeError("Loopback ClientID must not contain a path component");const r=new URLSearchParams(t.slice(e+1));for(const o of r.keys())if(o!=="redirect_uri"&&o!=="scope")throw new TypeError(`Invalid query parameter "${o}" in client ID`);const n=r.get("scope")??void 0;if(n!=null){if(r.getAll("scope").length>1)throw new TypeError("Loopback ClientID must contain at most one scope query parameter");if(!H4.oauthScopeSchema.safeParse(n).success)throw new TypeError("Invalid scope query parameter in client ID")}const i=r.has("redirect_uri")?r.getAll("redirect_uri").map(o=>G4.oauthLoopbackRedirectURISchema.parse(o)):void 0;return{scope:n,redirect_uris:i}}Object.defineProperty(j0,"__esModule",{value:!0});j0.atprotoLoopbackClientMetadata=J4;const W4=Bo;function J4(t){const{scope:e="atproto",redirect_uris:r=["http://127.0.0.1/","http://[::1]/"]}=(0,W4.parseOAuthLoopbackClientId)(t);return{client_id:t,scope:e,redirect_uris:r,response_types:["code"],grant_types:["authorization_code","refresh_token"],token_endpoint_auth_method:"none",application_type:"native",dpop_bound_access_tokens:!0}}var Wc={};Object.defineProperty(Wc,"__esModule",{value:!0});Wc.oauthAccessTokenSchema=void 0;const Z4=G;Wc.oauthAccessTokenSchema=Z4.z.string().min(1);var py={};Object.defineProperty(py,"__esModule",{value:!0});py.oauthAuthenticationErrorResponseSchema=void 0;const Q4=G;py.oauthAuthenticationErrorResponseSchema=Q4.z.enum(["invalid_request","unauthorized_client","access_denied","unsupported_response_type","invalid_scope","server_error","temporarily_unavailable"]);var Jc={};Object.defineProperty(Jc,"__esModule",{value:!0});Jc.oauthAuthorizationCodeGrantTokenRequestSchema=void 0;const Ip=G,Y4=Wa;Jc.oauthAuthorizationCodeGrantTokenRequestSchema=Ip.z.object({grant_type:Ip.z.literal("authorization_code"),code:Ip.z.string().min(1),redirect_uri:Y4.oauthRedirectUriSchema,code_verifier:Ip.z.string().min(43).max(128).regex(/^[a-zA-Z0-9-._~]+$/).optional()});var fy={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.oauthAuthorizationDetailsSchema=t.oauthAuthorizationDetailSchema=void 0;const e=G,r=Ti;t.oauthAuthorizationDetailSchema=e.z.object({type:e.z.string(),locations:e.z.array(r.dangerousUriSchema).optional(),actions:e.z.array(e.z.string()).optional(),datatypes:e.z.array(e.z.string()).optional(),identifier:e.z.string().optional(),privileges:e.z.array(e.z.string()).optional()}),t.oauthAuthorizationDetailsSchema=e.z.array(t.oauthAuthorizationDetailSchema)})(fy);var Ja={};Object.defineProperty(Ja,"__esModule",{value:!0});Ja.oauthAuthorizationRequestJarSchema=void 0;const kR=G,LR=Si;Ja.oauthAuthorizationRequestJarSchema=kR.z.object({request:kR.z.union([LR.signedJwtSchema,LR.unsignedJwtSchema])});var hy={},Za={},Zc={};Object.defineProperty(Zc,"__esModule",{value:!0});Zc.oauthCodeChallengeMethodSchema=void 0;const e8=G;Zc.oauthCodeChallengeMethodSchema=e8.z.enum(["S256","plain"]);var Qc={};Object.defineProperty(Qc,"__esModule",{value:!0});Qc.oauthResponseModeSchema=void 0;const t8=G;Qc.oauthResponseModeSchema=t8.z.enum(["query","fragment","form_post"]);var Qa={};Object.defineProperty(Qa,"__esModule",{value:!0});Qa.oauthResponseTypeSchema=void 0;const r8=G;Qa.oauthResponseTypeSchema=r8.z.enum(["code","token","none","code id_token token","code id_token","code token","id_token token","id_token"]);var Yc={};Object.defineProperty(Yc,"__esModule",{value:!0});Yc.oidcClaimsParameterSchema=void 0;const n8=G;Yc.oidcClaimsParameterSchema=n8.z.enum(["auth_time","nonce","acr","name","family_name","given_name","middle_name","nickname","preferred_username","gender","picture","profile","website","birthdate","zoneinfo","locale","updated_at","email","email_verified","phone_number","phone_number_verified","address"]);var ed={};Object.defineProperty(ed,"__esModule",{value:!0});ed.oidcClaimsPropertiesSchema=void 0;const ms=G,PR=ms.z.union([ms.z.string(),ms.z.number(),ms.z.boolean()]);ed.oidcClaimsPropertiesSchema=ms.z.object({essential:ms.z.boolean().optional(),value:PR.optional(),values:ms.z.array(PR).optional()});var td={};Object.defineProperty(td,"__esModule",{value:!0});td.oidcEntityTypeSchema=void 0;const i8=G;td.oidcEntityTypeSchema=i8.z.enum(["userinfo","id_token"]);Object.defineProperty(Za,"__esModule",{value:!0});Za.oauthAuthorizationRequestParametersSchema=void 0;const Et=G,o8=Si,s8=fy,a8=ki,l8=Zc,u8=Wa,c8=Qc,d8=Qa,p8=js,f8=Yc,h8=ed,y8=td,_g=cr;Za.oauthAuthorizationRequestParametersSchema=Et.z.object({client_id:a8.oauthClientIdSchema,state:Et.z.string().optional(),redirect_uri:u8.oauthRedirectUriSchema.optional(),scope:p8.oauthScopeSchema.optional(),response_type:d8.oauthResponseTypeSchema,code_challenge:Et.z.string().optional(),code_challenge_method:l8.oauthCodeChallengeMethodSchema.optional(),dpop_jkt:Et.z.string().optional(),response_mode:c8.oauthResponseModeSchema.optional(),nonce:Et.z.string().optional(),max_age:Et.z.preprocess(_g.numberPreprocess,Et.z.number().int().min(0)).optional(),claims:Et.z.preprocess(_g.jsonObjectPreprocess,Et.z.record(y8.oidcEntityTypeSchema,Et.z.record(f8.oidcClaimsParameterSchema,Et.z.union([Et.z.literal(null),h8.oidcClaimsPropertiesSchema])))).optional(),login_hint:Et.z.string().min(1).optional(),ui_locales:Et.z.string().regex(/^[a-z]{2,3}(-[A-Z]{2})?( [a-z]{2,3}(-[A-Z]{2})?)*$/).optional(),id_token_hint:o8.signedJwtSchema.optional(),display:Et.z.enum(["page","popup","touch","wap"]).optional(),prompt:Et.z.enum(["none","login","consent","select_account"]).optional(),authorization_details:Et.z.preprocess(_g.jsonObjectPreprocess,s8.oauthAuthorizationDetailsSchema).optional()});Object.defineProperty(hy,"__esModule",{value:!0});hy.oauthAuthorizationRequestParSchema=void 0;const m8=G,g8=Ja,b8=Za;hy.oauthAuthorizationRequestParSchema=m8.z.union([b8.oauthAuthorizationRequestParametersSchema,g8.oauthAuthorizationRequestJarSchema]);var yy={},rd={},nd={};Object.defineProperty(nd,"__esModule",{value:!0});nd.oauthRequestUriSchema=void 0;const v8=G;nd.oauthRequestUriSchema=v8.z.string();Object.defineProperty(rd,"__esModule",{value:!0});rd.oauthAuthorizationRequestUriSchema=void 0;const E8=G,w8=nd;rd.oauthAuthorizationRequestUriSchema=E8.z.object({request_uri:w8.oauthRequestUriSchema});Object.defineProperty(yy,"__esModule",{value:!0});yy.oauthAuthorizationRequestQuerySchema=void 0;const _8=G,x8=Ja,R8=Za,A8=rd;yy.oauthAuthorizationRequestQuerySchema=_8.z.union([R8.oauthAuthorizationRequestParametersSchema,x8.oauthAuthorizationRequestJarSchema,A8.oauthAuthorizationRequestUriSchema]);var UT={},Ya={};Object.defineProperty(Ya,"__esModule",{value:!0});Ya.oauthIssuerIdentifierSchema=void 0;const jp=G,S8=Ti;Ya.oauthIssuerIdentifierSchema=S8.webUriSchema.superRefine((t,e)=>{if(t.endsWith("/"))return e.addIssue({code:jp.z.ZodIssueCode.custom,message:"Issuer URL must not end with a slash"}),!1;const r=new URL(t);if(r.username||r.password)return e.addIssue({code:jp.z.ZodIssueCode.custom,message:"Issuer URL must not contain a username or password"}),!1;if(r.hash||r.search)return e.addIssue({code:jp.z.ZodIssueCode.custom,message:"Issuer URL must not contain a query or fragment"}),!1;const n=r.pathname==="/"?r.origin:r.href;return t!==n?(e.addIssue({code:jp.z.ZodIssueCode.custom,message:"Issuer URL must be in the canonical form"}),!1):!0});(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.oauthAuthorizationServerMetadataValidator=t.oauthAuthorizationServerMetadataSchema=void 0;const e=G,r=Zc,n=Ya,i=Ti;t.oauthAuthorizationServerMetadataSchema=e.z.object({issuer:n.oauthIssuerIdentifierSchema,claims_supported:e.z.array(e.z.string()).optional(),claims_locales_supported:e.z.array(e.z.string()).optional(),claims_parameter_supported:e.z.boolean().optional(),request_parameter_supported:e.z.boolean().optional(),request_uri_parameter_supported:e.z.boolean().optional(),require_request_uri_registration:e.z.boolean().optional(),scopes_supported:e.z.array(e.z.string()).optional(),subject_types_supported:e.z.array(e.z.string()).optional(),response_types_supported:e.z.array(e.z.string()).optional(),response_modes_supported:e.z.array(e.z.string()).optional(),grant_types_supported:e.z.array(e.z.string()).optional(),code_challenge_methods_supported:e.z.array(r.oauthCodeChallengeMethodSchema).min(1).optional(),ui_locales_supported:e.z.array(e.z.string()).optional(),id_token_signing_alg_values_supported:e.z.array(e.z.string()).optional(),display_values_supported:e.z.array(e.z.string()).optional(),request_object_signing_alg_values_supported:e.z.array(e.z.string()).optional(),authorization_response_iss_parameter_supported:e.z.boolean().optional(),authorization_details_types_supported:e.z.array(e.z.string()).optional(),request_object_encryption_alg_values_supported:e.z.array(e.z.string()).optional(),request_object_encryption_enc_values_supported:e.z.array(e.z.string()).optional(),jwks_uri:i.webUriSchema.optional(),authorization_endpoint:i.webUriSchema,token_endpoint:i.webUriSchema,token_endpoint_auth_methods_supported:e.z.array(e.z.string()).default(["client_secret_basic"]),token_endpoint_auth_signing_alg_values_supported:e.z.array(e.z.string()).optional(),revocation_endpoint:i.webUriSchema.optional(),introspection_endpoint:i.webUriSchema.optional(),pushed_authorization_request_endpoint:i.webUriSchema.optional(),require_pushed_authorization_requests:e.z.boolean().optional(),userinfo_endpoint:i.webUriSchema.optional(),end_session_endpoint:i.webUriSchema.optional(),registration_endpoint:i.webUriSchema.optional(),dpop_signing_alg_values_supported:e.z.array(e.z.string()).optional(),protected_resources:e.z.array(i.webUriSchema).optional(),client_id_metadata_document_supported:e.z.boolean().optional()}),t.oauthAuthorizationServerMetadataValidator=t.oauthAuthorizationServerMetadataSchema.superRefine((o,s)=>{o.require_pushed_authorization_requests&&!o.pushed_authorization_request_endpoint&&s.addIssue({code:e.z.ZodIssueCode.custom,message:'"pushed_authorization_request_endpoint" required when "require_pushed_authorization_requests" is true'})}).superRefine((o,s)=>{o.response_types_supported&&(o.response_types_supported.includes("code")||s.addIssue({code:e.z.ZodIssueCode.custom,message:'Response type "code" is required'}))}).superRefine((o,s)=>{var l;(l=o.token_endpoint_auth_signing_alg_values_supported)!=null&&l.includes("none")&&s.addIssue({code:e.z.ZodIssueCode.custom,message:'Client authentication method "none" is not allowed'})})})(UT);var id={};Object.defineProperty(id,"__esModule",{value:!0});id.oauthClientCredentialsGrantTokenRequestSchema=void 0;const DR=G;id.oauthClientCredentialsGrantTokenRequestSchema=DR.z.object({grant_type:DR.z.literal("client_credentials")});var $T={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.oauthClientCredentialsSchema=t.oauthClientCredentialsNoneSchema=t.oauthClientCredentialsSecretPostSchema=t.oauthClientCredentialsJwtBearerSchema=void 0;const e=G,r=Si,n=Xc,i=ki;t.oauthClientCredentialsJwtBearerSchema=e.z.object({client_id:i.oauthClientIdSchema,client_assertion_type:e.z.literal(n.CLIENT_ASSERTION_TYPE_JWT_BEARER),client_assertion:r.signedJwtSchema}),t.oauthClientCredentialsSecretPostSchema=e.z.object({client_id:i.oauthClientIdSchema,client_secret:e.z.string()}),t.oauthClientCredentialsNoneSchema=e.z.object({client_id:i.oauthClientIdSchema}),t.oauthClientCredentialsSchema=e.z.union([t.oauthClientCredentialsJwtBearerSchema,t.oauthClientCredentialsSecretPostSchema,t.oauthClientCredentialsNoneSchema])})($T);var OT={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.conventionalOAuthClientIdSchema=t.oauthClientIdDiscoverableSchema=void 0,t.isOAuthClientIdDiscoverable=o,t.isConventionalOAuthClientId=s,t.assertOAuthDiscoverableClientId=l,t.parseOAuthDiscoverableClientId=u;const e=G,r=ki,n=Ti,i=cr;t.oauthClientIdDiscoverableSchema=e.z.intersection(r.oauthClientIdSchema,n.httpsUriSchema).superRefine((c,d)=>{const f=new URL(c);return f.username||f.password?(d.addIssue({code:e.z.ZodIssueCode.custom,message:"ClientID must not contain credentials"}),!1):f.hash?(d.addIssue({code:e.z.ZodIssueCode.custom,message:"ClientID must not contain a fragment"}),!1):f.pathname==="/"?(d.addIssue({code:e.z.ZodIssueCode.custom,message:'ClientID must contain a path component (e.g. "/client-metadata.json")'}),!1):f.pathname.endsWith("/")?(d.addIssue({code:e.z.ZodIssueCode.custom,message:"ClientID path must not end with a trailing slash"}),!1):(0,i.isHostnameIP)(f.hostname)?(d.addIssue({code:e.z.ZodIssueCode.custom,message:"ClientID hostname must not be an IP address"}),!1):(0,i.extractUrlPath)(c)!==f.pathname?(d.addIssue({code:e.z.ZodIssueCode.custom,message:`ClientID must be in canonical form ("${f.href}", got "${c}")`}),!1):!0});function o(c){return t.oauthClientIdDiscoverableSchema.safeParse(c).success}t.conventionalOAuthClientIdSchema=t.oauthClientIdDiscoverableSchema.superRefine((c,d)=>{const f=new URL(c);return f.port?(d.addIssue({code:e.z.ZodIssueCode.custom,message:"ClientID must not contain a port"}),!1):f.search?(d.addIssue({code:e.z.ZodIssueCode.custom,message:"ClientID must not contain a query string"}),!1):f.pathname!=="/oauth-client-metadata.json"?(d.addIssue({code:e.z.ZodIssueCode.custom,message:'ClientID must be "/oauth-client-metadata.json"'}),!1):!0});function s(c){return t.conventionalOAuthClientIdSchema.safeParse(c).success}function l(c){t.oauthClientIdDiscoverableSchema.parse(c)}function u(c){return new URL(t.oauthClientIdDiscoverableSchema.parse(c))}})(OT);var my={},od={};Object.defineProperty(od,"__esModule",{value:!0});od.oauthEndpointAuthMethod=void 0;const C8=G;od.oauthEndpointAuthMethod=C8.z.enum(["client_secret_basic","client_secret_jwt","client_secret_post","none","private_key_jwt","self_signed_tls_client_auth","tls_client_auth"]);var sd={};Object.defineProperty(sd,"__esModule",{value:!0});sd.oauthGrantTypeSchema=void 0;const T8=G;sd.oauthGrantTypeSchema=T8.z.enum(["authorization_code","implicit","refresh_token","password","client_credentials","urn:ietf:params:oauth:grant-type:jwt-bearer","urn:ietf:params:oauth:grant-type:saml2-bearer"]);Object.defineProperty(my,"__esModule",{value:!0});my.oauthClientMetadataSchema=void 0;const je=G,k8=Si,L8=ki,P8=od,D8=sd,B8=Wa,I8=Qa,j8=js,gu=Ti;my.oauthClientMetadataSchema=je.z.object({redirect_uris:je.z.array(B8.oauthRedirectUriSchema).nonempty(),response_types:je.z.array(I8.oauthResponseTypeSchema).nonempty().default(["code"]),grant_types:je.z.array(D8.oauthGrantTypeSchema).nonempty().default(["authorization_code"]),scope:j8.oauthScopeSchema.optional(),token_endpoint_auth_method:P8.oauthEndpointAuthMethod.default("client_secret_basic"),token_endpoint_auth_signing_alg:je.z.string().optional(),userinfo_signed_response_alg:je.z.string().optional(),userinfo_encrypted_response_alg:je.z.string().optional(),jwks_uri:gu.webUriSchema.optional(),jwks:k8.jwksPubSchema.optional(),application_type:je.z.enum(["web","native"]).default("web"),subject_type:je.z.enum(["public","pairwise"]).default("public"),request_object_signing_alg:je.z.string().optional(),id_token_signed_response_alg:je.z.string().optional(),authorization_signed_response_alg:je.z.string().default("RS256"),authorization_encrypted_response_enc:je.z.enum(["A128CBC-HS256"]).optional(),authorization_encrypted_response_alg:je.z.string().optional(),client_id:L8.oauthClientIdSchema.optional(),client_name:je.z.string().optional(),client_uri:gu.webUriSchema.optional(),policy_uri:gu.webUriSchema.optional(),tos_uri:gu.webUriSchema.optional(),logo_uri:gu.webUriSchema.optional(),default_max_age:je.z.number().optional(),require_auth_time:je.z.boolean().optional(),contacts:je.z.array(je.z.string().email()).optional(),tls_client_certificate_bound_access_tokens:je.z.boolean().optional(),dpop_bound_access_tokens:je.z.boolean().optional(),authorization_details_types:je.z.array(je.z.string()).optional()});var gy={};Object.defineProperty(gy,"__esModule",{value:!0});gy.OAUTH_ENDPOINT_NAMES=void 0;gy.OAUTH_ENDPOINT_NAMES=["token","revocation","introspection","pushed_authorization_request"];var KT={};Object.defineProperty(KT,"__esModule",{value:!0});var by={};Object.defineProperty(by,"__esModule",{value:!0});by.oauthParResponseSchema=void 0;const xg=G;by.oauthParResponseSchema=xg.z.object({request_uri:xg.z.string(),expires_in:xg.z.number().int().positive()});var ad={};Object.defineProperty(ad,"__esModule",{value:!0});ad.oauthPasswordGrantTokenRequestSchema=void 0;const Up=G;ad.oauthPasswordGrantTokenRequestSchema=Up.z.object({grant_type:Up.z.literal("password"),username:Up.z.string(),password:Up.z.string()});var vy={};Object.defineProperty(vy,"__esModule",{value:!0});vy.oauthProtectedResourceMetadataSchema=void 0;const Ii=G,U8=Ya,bu=Ti;vy.oauthProtectedResourceMetadataSchema=Ii.z.object({resource:bu.webUriSchema.refine(t=>!t.includes("?"),{message:"Resource URL must not contain query parameters"}).refine(t=>!t.includes("#"),{message:"Resource URL must not contain a fragment"}),authorization_servers:Ii.z.array(U8.oauthIssuerIdentifierSchema).optional(),jwks_uri:bu.webUriSchema.optional(),scopes_supported:Ii.z.array(Ii.z.string()).optional(),bearer_methods_supported:Ii.z.array(Ii.z.enum(["header","body","query"])).optional(),resource_signing_alg_values_supported:Ii.z.array(Ii.z.string()).optional(),resource_documentation:bu.webUriSchema.optional(),resource_policy_uri:bu.webUriSchema.optional(),resource_tos_uri:bu.webUriSchema.optional()});var ld={},el={};Object.defineProperty(el,"__esModule",{value:!0});el.oauthRefreshTokenSchema=void 0;const $8=G;el.oauthRefreshTokenSchema=$8.z.string().min(1);Object.defineProperty(ld,"__esModule",{value:!0});ld.oauthRefreshTokenGrantTokenRequestSchema=void 0;const BR=G,O8=el;ld.oauthRefreshTokenGrantTokenRequestSchema=BR.z.object({grant_type:BR.z.literal("refresh_token"),refresh_token:O8.oauthRefreshTokenSchema});var Ey={};Object.defineProperty(Ey,"__esModule",{value:!0});Ey.oauthTokenIdentificationSchema=void 0;const Rg=G,K8=Wc,V8=el;Ey.oauthTokenIdentificationSchema=Rg.z.object({token:Rg.z.union([K8.oauthAccessTokenSchema,V8.oauthRefreshTokenSchema]),token_type_hint:Rg.z.enum(["access_token","refresh_token"]).optional()});var wy={};Object.defineProperty(wy,"__esModule",{value:!0});wy.oauthTokenRequestSchema=void 0;const M8=G,N8=Jc,z8=id,F8=ad,q8=ld;wy.oauthTokenRequestSchema=M8.z.discriminatedUnion("grant_type",[N8.oauthAuthorizationCodeGrantTokenRequestSchema,q8.oauthRefreshTokenGrantTokenRequestSchema,F8.oauthPasswordGrantTokenRequestSchema,z8.oauthClientCredentialsGrantTokenRequestSchema]);var _y={},ud={};Object.defineProperty(ud,"__esModule",{value:!0});ud.oauthTokenTypeSchema=void 0;const Ag=G;ud.oauthTokenTypeSchema=Ag.z.union([Ag.z.string().regex(/^DPoP$/i).transform(()=>"DPoP"),Ag.z.string().regex(/^Bearer$/i).transform(()=>"Bearer")]);Object.defineProperty(_y,"__esModule",{value:!0});_y.oauthTokenResponseSchema=void 0;const vu=G,G8=Si,H8=fy,X8=ud;_y.oauthTokenResponseSchema=vu.z.object({access_token:vu.z.string(),token_type:X8.oauthTokenTypeSchema,scope:vu.z.string().optional(),refresh_token:vu.z.string().optional(),expires_in:vu.z.number().optional(),id_token:G8.signedJwtSchema.optional(),authorization_details:H8.oauthAuthorizationDetailsSchema.optional()}).passthrough();var xy={};Object.defineProperty(xy,"__esModule",{value:!0});xy.oidcAuthenticationErrorResponseSchema=void 0;const W8=G;xy.oidcAuthenticationErrorResponseSchema=W8.z.enum(["interaction_required","login_required","account_selection_required","consent_required","invalid_request_uri","invalid_request_object","request_not_supported","request_uri_not_supported","registration_not_supported"]);var Ry={};Object.defineProperty(Ry,"__esModule",{value:!0});Ry.oidcUserinfoSchema=void 0;const Cr=G;Ry.oidcUserinfoSchema=Cr.z.object({sub:Cr.z.string(),iss:Cr.z.string().url().optional(),aud:Cr.z.union([Cr.z.string(),Cr.z.array(Cr.z.string()).min(1)]).optional(),email:Cr.z.string().email().optional(),email_verified:Cr.z.boolean().optional(),name:Cr.z.string().optional(),preferred_username:Cr.z.string().optional(),picture:Cr.z.string().url().optional()});(function(t){var e=S&&S.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=S&&S.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&e(i,n,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(Xc,t),r(Ti,t),r(cr,t),r(j0,t),r(Wc,t),r(py,t),r(Jc,t),r(fy,t),r(Ja,t),r(hy,t),r(Za,t),r(yy,t),r(rd,t),r(UT,t),r(id,t),r($T,t),r(OT,t),r(Bo,t),r(ki,t),r(my,t),r(od,t),r(gy,t),r(sd,t),r(KT,t),r(Ya,t),r(by,t),r(ad,t),r(vy,t),r(Wa,t),r(ld,t),r(el,t),r(nd,t),r(Qc,t),r(Qa,t),r(js,t),r(Ey,t),r(wy,t),r(_y,t),r(ud,t),r(xy,t),r(Yc,t),r(ed,t),r(td,t),r(Ry,t)})(Rr);var cd={},Io={};(function(t){var e=S&&S.__classPrivateFieldSet||function(c,d,f,h,g){if(h==="m")throw new TypeError("Private method is not writable");if(h==="a"&&!g)throw new TypeError("Private accessor was defined without a setter");if(typeof d=="function"?c!==d||!g:!d.has(c))throw new TypeError("Cannot write private member to an object whose class did not declare it");return h==="a"?g.call(c,f):g?g.value=f:d.set(c,f),f},r=S&&S.__classPrivateFieldGet||function(c,d,f,h){if(f==="a"&&!h)throw new TypeError("Private accessor was defined without a getter");if(typeof d=="function"?c!==d||!h:!d.has(c))throw new TypeError("Cannot read private member from an object whose class did not declare it");return f==="m"?h:f==="a"?h.call(c):h?h.value:d.get(c)};Object.defineProperty(t,"__esModule",{value:!0}),t.includesSpaceSeparatedValue=t.CustomEventTarget=t.CustomEvent=t.timeoutSignal=t.ifString=void 0,t.contentMime=o,t.combineSignals=u,Symbol.dispose??(Symbol.dispose=Symbol("@@dispose"));const n=c=>typeof c=="string"?c:void 0;t.ifString=n;const i=(c,d)=>{var b,w,C;if(!Number.isInteger(c)||c<0)throw new TypeError("Expected a positive integer");(b=d==null?void 0:d.signal)==null||b.throwIfAborted();const f=new AbortController,{signal:h}=f;(w=d==null?void 0:d.signal)==null||w.addEventListener("abort",y=>f.abort(y),{once:!0,signal:h});const g=setTimeout(y=>f.abort(y),c,new Error("Timeout"));return(C=g==null?void 0:g.unref)==null||C.call(g),h.addEventListener("abort",()=>clearTimeout(g),{once:!0,signal:h}),Object.defineProperty(h,Symbol.dispose,{value:()=>f.abort()}),h};t.timeoutSignal=i;function o(c){var d;return(d=c.get("content-type"))==null?void 0:d.split(";")[0].trim()}t.CustomEvent=globalThis.CustomEvent??(()=>{var c;class d extends Event{constructor(h,g){if(!arguments.length)throw new TypeError("type argument is required");super(h,g),c.set(this,void 0),e(this,c,(g==null?void 0:g.detail)??null,"f")}get detail(){return r(this,c,"f")}}return c=new WeakMap,Object.defineProperties(d.prototype,{[Symbol.toStringTag]:{writable:!1,enumerable:!1,configurable:!0,value:"CustomEvent"},detail:{enumerable:!0}}),d})();class s{constructor(){Object.defineProperty(this,"eventTarget",{enumerable:!0,configurable:!0,writable:!0,value:new EventTarget})}addEventListener(d,f,h){this.eventTarget.addEventListener(d,f,h)}removeEventListener(d,f,h){this.eventTarget.removeEventListener(d,f,h)}dispatchCustomEvent(d,f,h){return this.eventTarget.dispatchEvent(new t.CustomEvent(d,{...h,detail:f}))}}t.CustomEventTarget=s;const l=(c,d)=>{if(d.length===0)throw new TypeError("Value cannot be empty");if(d.includes(" "))throw new TypeError("Value cannot contain spaces");const f=c.length,h=d.length;if(f{const h=new Error("AbortController was disposed");d.abort(h)},d}})(Io);Object.defineProperty(cd,"__esModule",{value:!0});cd.OAuthAuthorizationServerMetadataResolver=void 0;const IR=Rr,Eu=Mn,J8=za,Z8=Io;class Q8 extends J8.CachedGetter{constructor(e,r,n){super(async(i,o)=>this.fetchMetadata(i,o),e),Object.defineProperty(this,"fetch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowHttpIssuer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.fetch=(0,Eu.bindFetch)(r),this.allowHttpIssuer=(n==null?void 0:n.allowHttpIssuer)===!0}async get(e,r){const n=IR.oauthIssuerIdentifierSchema.parse(e);if(!this.allowHttpIssuer&&n.startsWith("http:"))throw new TypeError("Unsecure issuer URL protocol only allowed in development and test environments");return super.get(n,r)}async fetchMetadata(e,r){const n=new URL("/.well-known/oauth-authorization-server",e),i=new Request(n,{headers:{accept:"application/json"},cache:r!=null&&r.noCache?"no-cache":void 0,signal:r==null?void 0:r.signal,redirect:"manual"}),o=await this.fetch(i);if(o.status!==200)throw await(0,Eu.cancelBody)(o,"log"),await Eu.FetchResponseError.from(o,`Unexpected status code ${o.status} for "${n}"`,void 0,{cause:i});if((0,Z8.contentMime)(o.headers)!=="application/json")throw await(0,Eu.cancelBody)(o,"log"),await Eu.FetchResponseError.from(o,`Unexpected content type for "${n}"`,void 0,{cause:i});const s=IR.oauthAuthorizationServerMetadataValidator.parse(await o.json());if(s.issuer!==e)throw new TypeError(`Invalid issuer ${s.issuer}`);if(s.client_id_metadata_document_supported!==!0)throw new TypeError(`Authorization server "${e}" does not support client_id_metadata_document`);return s}}cd.OAuthAuthorizationServerMetadataResolver=Q8;var dd={};Object.defineProperty(dd,"__esModule",{value:!0});dd.OAuthCallbackError=void 0;class ch extends Error{static from(e,r,n){if(e instanceof ch)return e;const i=e instanceof Error?e.message:void 0;return new ch(r,i,n,e)}constructor(e,r=e.get("error_description")||"OAuth callback error",n,i){super(r,{cause:i}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:n})}}dd.OAuthCallbackError=ch;var Ay={},VT={},Sy={},jo={},$0={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DisallowedDomainError=t.UnsupportedDomainError=t.ReservedHandleError=t.InvalidHandleError=t.isValidTld=t.isValidHandle=t.normalizeAndEnsureValidHandle=t.normalizeHandle=t.ensureValidHandleRegex=t.ensureValidHandle=t.DISALLOWED_TLDS=t.INVALID_HANDLE=void 0,t.INVALID_HANDLE="handle.invalid",t.DISALLOWED_TLDS=[".local",".arpa",".invalid",".localhost",".internal",".example",".alt",".onion"];const e=f=>{if(!/^[a-zA-Z0-9.-]*$/.test(f))throw new l("Disallowed characters in handle (ASCII letters, digits, dashes, periods only)");if(f.length>253)throw new l("Handle is too long (253 chars max)");const h=f.split(".");if(h.length<2)throw new l("Handle domain needs at least two parts");for(let g=0;g63)throw new l("Handle part too long (max 63 chars)");if(b.endsWith("-")||b.startsWith("-"))throw new l("Handle parts can not start or end with hyphens");if(g+1===h.length&&!/^[a-zA-Z]/.test(b))throw new l("Handle final component (TLD) must start with ASCII letter")}};t.ensureValidHandle=e;const r=f=>{if(!/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/.test(f))throw new l("Handle didn't validate via regex");if(f.length>253)throw new l("Handle is too long (253 chars max)")};t.ensureValidHandleRegex=r;const n=f=>f.toLowerCase();t.normalizeHandle=n;const i=f=>{const h=(0,t.normalizeHandle)(f);return(0,t.ensureValidHandle)(h),h};t.normalizeAndEnsureValidHandle=i;const o=f=>{try{(0,t.ensureValidHandle)(f)}catch(h){if(h instanceof l)return!1;throw h}return!0};t.isValidHandle=o;const s=f=>!t.DISALLOWED_TLDS.some(h=>f.endsWith(h));t.isValidTld=s;class l extends Error{}t.InvalidHandleError=l;class u extends Error{}t.ReservedHandleError=u;class c extends Error{}t.UnsupportedDomainError=c;class d extends Error{}t.DisallowedDomainError=d})($0);var gi={};Object.defineProperty(gi,"__esModule",{value:!0});gi.InvalidDidError=gi.ensureValidDidRegex=gi.ensureValidDid=void 0;const Y8=t=>{if(!t.startsWith("did:"))throw new ui('DID requires "did:" prefix');if(!/^[a-zA-Z0-9._:%-]*$/.test(t))throw new ui("Disallowed characters in DID (ASCII letters, digits, and a couple other characters only)");const{length:e,1:r}=t.split(":");if(e<3)throw new ui("DID requires prefix, method, and method-specific content");if(!/^[a-z]+$/.test(r))throw new ui("DID method must be lower-case letters");if(t.endsWith(":")||t.endsWith("%"))throw new ui('DID can not end with ":" or "%"');if(t.length>2*1024)throw new ui("DID is too long (2048 chars max)")};gi.ensureValidDid=Y8;const e5=t=>{if(!/^did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$/.test(t))throw new ui("DID didn't validate via regex");if(t.length>2*1024)throw new ui("DID is too long (2048 chars max)")};gi.ensureValidDidRegex=e5;class ui extends Error{}gi.InvalidDidError=ui;var O0={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidNsidError=t.ensureValidNsidRegex=t.ensureValidNsid=t.NSID=void 0;class e{static parse(s){return new e(s)}static create(s,l){const u=[...s.split(".").reverse(),l].join(".");return new e(u)}static isValid(s){try{return e.parse(s),!0}catch{return!1}}constructor(s){Object.defineProperty(this,"segments",{enumerable:!0,configurable:!0,writable:!0,value:[]}),(0,t.ensureValidNsid)(s),this.segments=s.split(".")}get authority(){return this.segments.slice(0,this.segments.length-1).reverse().join(".")}get name(){return this.segments.at(this.segments.length-1)}toString(){return this.segments.join(".")}}t.NSID=e;const r=o=>{const s=o;if(!/^[a-zA-Z0-9.-]*$/.test(s))throw new i("Disallowed characters in NSID (ASCII letters, digits, dashes, periods only)");if(s.length>317)throw new i("NSID is too long (317 chars max)");const l=s.split(".");if(l.length<3)throw new i("NSID needs at least three parts");for(let u=0;u63)throw new i("NSID part too long (max 63 chars)");if(c.endsWith("-")||c.startsWith("-"))throw new i("NSID parts can not start or end with hyphen");if(/^[0-9]/.test(c)&&u===0)throw new i("NSID first part may not start with a digit");if(!/^[a-zA-Z][a-zA-Z0-9]*$/.test(c)&&u+1===l.length)throw new i("NSID name part must be only letters and digits (and no leading digit)")}};t.ensureValidNsid=r;const n=o=>{if(!/^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\.[a-zA-Z]([a-zA-Z0-9]{0,62})?)$/.test(o))throw new i("NSID didn't validate via regex");if(o.length>317)throw new i("NSID is too long (317 chars max)")};t.ensureValidNsidRegex=n;class i extends Error{}t.InvalidNsidError=i})(O0);var MT={},Ia={};Object.defineProperty(Ia,"__esModule",{value:!0});Ia.ensureValidAtUriRegex=Ia.ensureValidAtUri=void 0;const NT=gi,zT=$0,FT=O0,t5=t=>{const e=t.split("#");if(e.length>2)throw new Error('ATURI can have at most one "#", separating fragment out');const r=e[1]||null;if(t=e[0],!/^[a-zA-Z0-9._~:@!$&')(*+,;=%/-]*$/.test(t))throw new Error("Disallowed characters in ATURI (ASCII)");const n=t.split("/");if(n.length>=3&&(n[0]!=="at:"||n[1].length!==0))throw new Error('ATURI must start with "at://"');if(n.length<3)throw new Error("ATURI requires at least method and authority sections");try{n[2].startsWith("did:")?(0,NT.ensureValidDid)(n[2]):(0,zT.ensureValidHandle)(n[2])}catch{throw new Error("ATURI authority must be a valid handle or DID")}if(n.length>=4){if(n[3].length===0)throw new Error("ATURI can not have a slash after authority without a path segment");try{(0,FT.ensureValidNsid)(n[3])}catch{throw new Error("ATURI requires first path segment (if supplied) to be valid NSID")}}if(n.length>=5&&n[4].length===0)throw new Error("ATURI can not have a slash after collection, unless record key is provided");if(n.length>=6)throw new Error("ATURI path can have at most two parts, and no trailing slash");if(e.length>=2&&r==null)throw new Error("ATURI fragment must be non-empty and start with slash");if(r!=null){if(r.length===0||r[0]!=="/")throw new Error("ATURI fragment must be non-empty and start with slash");if(!/^\/[a-zA-Z0-9._~:@!$&')(*+,;=%[\]/-]*$/.test(r))throw new Error("Disallowed characters in ATURI fragment (ASCII)")}if(t.length>8*1024)throw new Error("ATURI is far too long")};Ia.ensureValidAtUri=t5;const r5=t=>{const e=/^at:\/\/(?[a-zA-Z0-9._:%-]+)(\/(?[a-zA-Z0-9-.]+)(\/(?[a-zA-Z0-9._~:@!$&%')(*+,;=-]+))?)?(#(?\/[a-zA-Z0-9._~:@!$&%')(*+,;=\-[\]/\\]*))?$/,r=t.match(e);if(!r||!r.groups)throw new Error("ATURI didn't validate via regex");const n=r.groups;try{(0,zT.ensureValidHandleRegex)(n.authority)}catch{try{(0,NT.ensureValidDidRegex)(n.authority)}catch{throw new Error("ATURI authority must be a valid handle or DID")}}if(n.collection)try{(0,FT.ensureValidNsidRegex)(n.collection)}catch{throw new Error("ATURI collection path segment must be a valid NSID")}if(t.length>8*1024)throw new Error("ATURI is far too long")};Ia.ensureValidAtUriRegex=r5;(function(t){var e=S&&S.__createBinding||(Object.create?function(l,u,c,d){d===void 0&&(d=c);var f=Object.getOwnPropertyDescriptor(u,c);(!f||("get"in f?!u.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return u[c]}}),Object.defineProperty(l,d,f)}:function(l,u,c,d){d===void 0&&(d=c),l[d]=u[c]}),r=S&&S.__exportStar||function(l,u){for(var c in l)c!=="default"&&!Object.prototype.hasOwnProperty.call(u,c)&&e(u,l,c)};Object.defineProperty(t,"__esModule",{value:!0}),t.AtUri=t.ATP_URI_REGEX=void 0,r(Ia,t),t.ATP_URI_REGEX=/^(at:\/\/)?((?:did:[a-z0-9:%-]+)|(?:[a-z0-9][a-z0-9.:-]*))(\/[^?#\s]*)?(\?[^#\s]+)?(#[^\s]+)?$/i;const n=/^(\/[^?#\s]*)?(\?[^#\s]+)?(#[^\s]+)?$/i;class i{constructor(u,c){Object.defineProperty(this,"hash",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"host",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathname",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"searchParams",{enumerable:!0,configurable:!0,writable:!0,value:void 0});let d;if(c){if(d=o(c),!d)throw new Error(`Invalid at uri: ${c}`);const f=s(u);if(!f)throw new Error(`Invalid path: ${u}`);Object.assign(d,f)}else if(d=o(u),!d)throw new Error(`Invalid at uri: ${u}`);this.hash=d.hash,this.host=d.host,this.pathname=d.pathname,this.searchParams=d.searchParams}static make(u,c,d){let f=u;return c&&(f+="/"+c),d&&(f+="/"+d),new i(f)}get protocol(){return"at:"}get origin(){return`at://${this.host}`}get hostname(){return this.host}set hostname(u){this.host=u}get search(){return this.searchParams.toString()}set search(u){this.searchParams=new URLSearchParams(u)}get collection(){return this.pathname.split("/").filter(Boolean)[0]||""}set collection(u){const c=this.pathname.split("/").filter(Boolean);c[0]=u,this.pathname=c.join("/")}get rkey(){return this.pathname.split("/").filter(Boolean)[1]||""}set rkey(u){const c=this.pathname.split("/").filter(Boolean);c[0]||(c[0]="undefined"),c[1]=u,this.pathname=c.join("/")}get href(){return this.toString()}toString(){let u=this.pathname||"/";u.startsWith("/")||(u=`/${u}`);let c=this.searchParams.toString();c&&!c.startsWith("?")&&(c=`?${c}`);let d=this.hash;return d&&!d.startsWith("#")&&(d=`#${d}`),`at://${this.host}${u}${c}${d}`}}t.AtUri=i;function o(l){const u=t.ATP_URI_REGEX.exec(l);if(u)return{hash:u[5]||"",host:u[2]||"",pathname:u[3]||"",searchParams:new URLSearchParams(u[4]||"")}}function s(l){const u=n.exec(l);if(u)return{hash:u[3]||"",pathname:u[1]||"",searchParams:new URLSearchParams(u[2]||"")}}})(MT);var co={};Object.defineProperty(co,"__esModule",{value:!0});co.InvalidTidError=co.isValidTid=co.ensureValidTid=void 0;const ov=13,qT=/^[234567abcdefghij][234567abcdefghijklmnopqrstuvwxyz]{12}$/,n5=t=>{if(t.length!==ov)throw new sv(`TID must be ${ov} characters`);if(!qT.test(t))throw new sv("TID syntax not valid (regex)")};co.ensureValidTid=n5;const i5=t=>t.length===ov&&qT.test(t);co.isValidTid=i5;class sv extends Error{}co.InvalidTidError=sv;var GT={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidRecordKeyError=t.isValidRecordKey=t.ensureValidRecordKey=void 0;const e=i=>{if(i.length>512||i.length<1)throw new n("record key must be 1 to 512 characters");if(!/^[a-zA-Z0-9_~.:-]{1,512}$/.test(i))throw new n("record key syntax not valid (regex)");if(i==="."||i==="..")throw new n('record key can not be "." or ".."')};t.ensureValidRecordKey=e;const r=i=>{try{(0,t.ensureValidRecordKey)(i)}catch(o){if(o instanceof n)return!1;throw o}return!0};t.isValidRecordKey=r;class n extends Error{}t.InvalidRecordKeyError=n})(GT);var HT={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidDatetimeError=t.normalizeDatetimeAlways=t.normalizeDatetime=t.isValidDatetime=t.ensureValidDatetime=void 0;const e=s=>{const l=new Date(s);if(isNaN(l.getTime()))throw new o("datetime did not parse as ISO 8601");if(l.toISOString().startsWith("-"))throw new o("datetime normalized to a negative time");if(!/^[0-9]{4}-[01][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](.[0-9]{1,20})?(Z|([+-][0-2][0-9]:[0-5][0-9]))$/.test(s))throw new o("datetime didn't validate via regex");if(s.length>64)throw new o("datetime is too long (64 chars max)");if(s.endsWith("-00:00"))throw new o('datetime can not use "-00:00" for UTC timezone');if(s.startsWith("000"))throw new o("datetime so close to year zero not allowed")};t.ensureValidDatetime=e;const r=s=>{try{(0,t.ensureValidDatetime)(s)}catch(l){if(l instanceof o)return!1;throw l}return!0};t.isValidDatetime=r;const n=s=>{if((0,t.isValidDatetime)(s)){const c=new Date(s).toISOString();if((0,t.isValidDatetime)(c))return c}if(!/.*(([+-]\d\d:?\d\d)|[a-zA-Z])$/.test(s)){const c=new Date(s+"Z");if(!isNaN(c.getTime())){const d=c.toISOString();if((0,t.isValidDatetime)(d))return d}}const l=new Date(s);if(isNaN(l.getTime()))throw new o("datetime did not parse as any timestamp format");const u=l.toISOString();if((0,t.isValidDatetime)(u))return u;throw new o("datetime normalized to invalid timestamp string")};t.normalizeDatetime=n;const i=s=>{try{return(0,t.normalizeDatetime)(s)}catch(l){if(l instanceof o)return new Date(0).toISOString();throw l}};t.normalizeDatetimeAlways=i;class o extends Error{}t.InvalidDatetimeError=o})(HT);(function(t){var e=S&&S.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=S&&S.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&e(i,n,o)};Object.defineProperty(t,"__esModule",{value:!0}),r($0,t),r(gi,t),r(O0,t),r(MT,t),r(co,t),r(GT,t),r(HT,t)})(jo);Object.defineProperty(Sy,"__esModule",{value:!0});Sy.IdentityResolver=void 0;const XT=jo,o5=ay;class s5{constructor(e,r){Object.defineProperty(this,"didResolver",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"handleResolver",{enumerable:!0,configurable:!0,writable:!0,value:r})}async resolve(e,r){var o;const n=(0,o5.isResolvedHandle)(e)?await this.getDocumentFromDid(e,r):await this.getDocumentFromHandle(e,r),i=(o=n.service)==null?void 0:o.find(l5,n);if(!i)throw new TypeError(`No valid "AtprotoPersonalDataServer" service found in "${n.id}" DID document`);return{did:n.id,pds:new URL(i.serviceEndpoint),handle:a5(n)}}async getDocumentFromDid(e,r){return this.didResolver.resolve(e,r)}async getDocumentFromHandle(e,r){var s,l;const n=(0,XT.normalizeAndEnsureValidHandle)(e),i=await this.handleResolver.resolve(n,r);if(!i)throw new TypeError(`Handle "${n}" does not resolve to a DID`);(s=r==null?void 0:r.signal)==null||s.throwIfAborted();const o=await this.didResolver.resolve(i,r);if(!((l=o.alsoKnownAs)!=null&&l.includes(`at://${n}`)))throw new TypeError(`Did document for "${i}" does not include the handle "${n}"`);return o}}Sy.IdentityResolver=s5;function a5(t){if(t.alsoKnownAs){for(const e of t.alsoKnownAs)if(e.startsWith("at://")){const r=e.slice(5);if((0,XT.isValidHandle)(r))return r}}}function l5(t){return typeof t.serviceEndpoint=="string"&&t.type==="AtprotoPersonalDataServer"&&(t.id.startsWith("#")?t.id==="#atproto_pds":t.id===`${this.id}#atproto_pds`)}(function(t){var e=S&&S.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=S&&S.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&e(i,n,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(Sy,t)})(VT);var tl={};Object.defineProperty(tl,"__esModule",{value:!0});tl.FALLBACK_ALG=void 0;tl.FALLBACK_ALG="ES256";var rl={};Object.defineProperty(rl,"__esModule",{value:!0});rl.AuthMethodUnsatisfiableError=void 0;class u5 extends Error{}rl.AuthMethodUnsatisfiableError=u5;var Us={};Object.defineProperty(Us,"__esModule",{value:!0});Us.TokenRevokedError=void 0;class c5 extends Error{constructor(e,r=`The session for "${e}" was successfully revoked`,n){super(r,n),Object.defineProperty(this,"sub",{enumerable:!0,configurable:!0,writable:!0,value:e})}}Us.TokenRevokedError=c5;var nl={};Object.defineProperty(nl,"__esModule",{value:!0});nl.negotiateClientAuthMethod=p5;nl.createClientCredentialsFactory=f5;const d5=Rr,bf=tl,Sg=rl;function p5(t,e,r){const n=e.token_endpoint_auth_method,i=WT(t);if(!i.includes(n))throw new Error(`The server does not support "${n}" authentication. Supported methods are: ${i.join(", ")}.`);if(n==="private_key_jwt"){if(!r)throw new Error("A keyset is required for private_key_jwt");const o=JT(t);for(const s of r.list({use:"sig",alg:o}))if(s.isPrivate&&s.kid)return{method:"private_key_jwt",kid:s.kid};throw new Error(o.includes(bf.FALLBACK_ALG)?`Client authentication method "${n}" requires at least one "${bf.FALLBACK_ALG}" signing key with a "kid" property`:`Authorization server requires "${n}" authentication method, but does not support "${bf.FALLBACK_ALG}" algorithm.`)}if(n==="none")return{method:"none"};throw new Error('The ATProto OAuth spec requires that client use either "none" or "private_key_jwt" authentication method.'+(n==="client_secret_basic"?' You might want to explicitly set "token_endpoint_auth_method" to one of those values in the client metadata document.':` You set "${n}" which is not allowed.`))}function f5(t,e,r,n,i){if(!WT(e).includes(t.method))throw new Sg.AuthMethodUnsatisfiableError(`Client authentication method "${t.method}" no longer supported`);if(t.method==="none")return()=>({payload:{client_id:r.client_id}});if(t.method==="private_key_jwt")try{if(!i)throw new Error("A keyset is required for private_key_jwt");const[o,s]=i.findPrivateKey({use:"sig",kid:t.kid,alg:JT(e)});return async()=>({payload:{client_id:r.client_id,client_assertion_type:d5.CLIENT_ASSERTION_TYPE_JWT_BEARER,client_assertion:await o.createJwt({alg:s},{iss:r.client_id,sub:r.client_id,aud:e.issuer,jti:await n.generateNonce(),iat:Math.floor(Date.now()/1e3),exp:Math.floor(Date.now()/1e3)+60})}})}catch(o){throw new Sg.AuthMethodUnsatisfiableError("Failed to load private key",{cause:o})}throw new Sg.AuthMethodUnsatisfiableError(`Unsupported auth method ${t.method}`)}function WT(t){return t.token_endpoint_auth_methods_supported}function JT(t){return t.token_endpoint_auth_signing_alg_values_supported??[bf.FALLBACK_ALG]}var pd={};Object.defineProperty(pd,"__esModule",{value:!0});pd.OAuthProtectedResourceMetadataResolver=void 0;const h5=Rr,wu=Mn,y5=za,m5=Io;class g5 extends y5.CachedGetter{constructor(e,r=globalThis.fetch,n){super(async(i,o)=>this.fetchMetadata(i,o),e),Object.defineProperty(this,"fetch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowHttpResource",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.fetch=(0,wu.bindFetch)(r),this.allowHttpResource=(n==null?void 0:n.allowHttpResource)===!0}async get(e,r){const{protocol:n,origin:i}=new URL(e);if(n!=="https:"&&n!=="http:")throw new TypeError(`Invalid protected resource metadata URL protocol: ${n}`);if(n==="http:"&&!this.allowHttpResource)throw new TypeError(`Unsecure resource metadata URL (${n}) only allowed in development and test environments`);return super.get(i,r)}async fetchMetadata(e,r){const n=new URL("/.well-known/oauth-protected-resource",e),i=new Request(n,{signal:r==null?void 0:r.signal,headers:{accept:"application/json"},cache:r!=null&&r.noCache?"no-cache":void 0,redirect:"manual"}),o=await this.fetch(i);if(o.status!==200)throw await(0,wu.cancelBody)(o,"log"),await wu.FetchResponseError.from(o,`Unexpected status code ${o.status} for "${n}"`,void 0,{cause:i});if((0,m5.contentMime)(o.headers)!=="application/json")throw await(0,wu.cancelBody)(o,"log"),await wu.FetchResponseError.from(o,`Unexpected content type for "${n}"`,void 0,{cause:i});const s=h5.oauthProtectedResourceMetadataSchema.parse(await o.json());if(s.resource!==e)throw new TypeError(`Invalid issuer ${s.resource}`);return s}}pd.OAuthProtectedResourceMetadataResolver=g5;var Cy={},fd={};Object.defineProperty(fd,"__esModule",{value:!0});fd.OAuthResolverError=void 0;const b5=G;class dh extends Error{constructor(e,r){super(e,r)}static from(e,r){if(e instanceof dh)return e;const n=e instanceof b5.ZodError?`${e.errors[0].path} ${e.errors[0].message}`:null,i=(r??"Unable to resolve identity")+(n?` (${n})`:"");return new dh(i,{cause:e})}}fd.OAuthResolverError=dh;Object.defineProperty(Cy,"__esModule",{value:!0});Cy.OAuthResolver=void 0;const v5=Rr,Hs=fd;class E5{constructor(e,r,n){Object.defineProperty(this,"identityResolver",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"protectedResourceMetadataResolver",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"authorizationServerMetadataResolver",{enumerable:!0,configurable:!0,writable:!0,value:n})}async resolve(e,r){return/^https?:\/\//.test(e)?this.resolveFromService(e,r):this.resolveFromIdentity(e,r)}async resolveFromService(e,r){var n;try{return{metadata:await this.getResourceServerMetadata(e,r)}}catch(i){if(!((n=r==null?void 0:r.signal)!=null&&n.aborted)&&i instanceof Hs.OAuthResolverError)try{const o=v5.oauthIssuerIdentifierSchema.safeParse(e);if(o.success)return{metadata:await this.getAuthorizationServerMetadata(o.data,r)}}catch{}throw i}}async resolveFromIdentity(e,r){var o;const n=await this.resolveIdentity(e,r);(o=r==null?void 0:r.signal)==null||o.throwIfAborted();const i=await this.getResourceServerMetadata(n.pds,r);return{identity:n,metadata:i}}async resolveIdentity(e,r){try{return await this.identityResolver.resolve(e,r)}catch(n){throw Hs.OAuthResolverError.from(n,`Failed to resolve identity: ${e}`)}}async getAuthorizationServerMetadata(e,r){try{return await this.authorizationServerMetadataResolver.get(e,r)}catch(n){throw Hs.OAuthResolverError.from(n,`Failed to resolve OAuth server metadata for issuer: ${e}`)}}async getResourceServerMetadata(e,r){var n,i,o;try{const s=await this.protectedResourceMetadataResolver.get(e,r);if(((n=s.authorization_servers)==null?void 0:n.length)!==1)throw new Hs.OAuthResolverError((i=s.authorization_servers)!=null&&i.length?`Unable to determine authorization server for PDS: ${e}`:`No authorization servers found for PDS: ${e}`);const l=s.authorization_servers[0];(o=r==null?void 0:r.signal)==null||o.throwIfAborted();const u=await this.getAuthorizationServerMetadata(l,r);if(u.protected_resources&&!u.protected_resources.includes(s.resource))throw new Hs.OAuthResolverError(`PDS "${e}" not protected by issuer "${l}"`);return u}catch(s){throw Hs.OAuthResolverError.from(s,`Failed to resolve OAuth server metadata for resource: ${e}`)}}}Cy.OAuthResolver=E5;var hd={},yd={},ZT={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.atprotoTokenResponseSchema=t.atprotoScopeSchema=t.isAtprotoScope=void 0;const e=G,r=Do,n=Rr,i=Io,o=s=>(0,i.includesSpaceSeparatedValue)(s,"atproto");t.isAtprotoScope=o,t.atprotoScopeSchema=e.z.string().refine(t.isAtprotoScope,'The "atproto" scope is required'),t.atprotoTokenResponseSchema=n.oauthTokenResponseSchema.extend({token_type:e.z.literal("DPoP"),sub:r.atprotoDidSchema,scope:t.atprotoScopeSchema,id_token:e.z.never().optional()})})(ZT);var il={};Object.defineProperty(il,"__esModule",{value:!0});il.TokenRefreshError=void 0;class w5 extends Error{constructor(e,r,n){super(r,n),Object.defineProperty(this,"sub",{enumerable:!0,configurable:!0,writable:!0,value:e})}}il.TokenRefreshError=w5;var Ty={};Object.defineProperty(Ty,"__esModule",{value:!0});Ty.dpopFetchWrapper=x5;const _5=c0,QT=Mn;var IA;const av=(IA=globalThis.crypto)==null?void 0:IA.subtle,jR=globalThis.ReadableStream;function x5({key:t,supportedAlgs:e,nonces:r,sha256:n=typeof av<"u"?C5:void 0,isAuthServer:i,fetch:o=globalThis.fetch}){if(!n)throw new TypeError("crypto.subtle is not available in this environment. Please provide a sha256 function.");const s=S5(t,e);return async function(l,u){const c=u==null&&l instanceof Request?l:new Request(l,u),d=c.headers.get("Authorization"),f=d!=null&&d.startsWith("DPoP ")?await n(d.slice(5)):void 0,{origin:h}=new URL(c.url),g=c.method,b=R5(c.url);let w;try{w=await r.get(h)}catch{}const C=await UR(t,s,g,b,w,f);c.headers.set("DPoP",C);const y=await o.call(this,c),m=y.headers.get("DPoP-Nonce");if(!m||m===w)return y;try{await r.set(h,m)}catch{}if(!await A5(y,i)||l===c||jR&&(u==null?void 0:u.body)instanceof jR)return y;await(0,QT.cancelBody)(y,"log");const A=await UR(t,s,g,b,m,f),L=new Request(l,u);L.headers.set("DPoP",A);const D=await o.call(this,L),B=D.headers.get("DPoP-Nonce");if(!B||B===w)return D;try{await r.set(h,B)}catch{}return D}}function R5(t){const e=t.indexOf("#"),r=t.indexOf("?"),n=e===-1?r:r===-1?e:Math.min(e,r);return n===-1?t:t.slice(0,n)}async function UR(t,e,r,n,i,o){const s=t.bareJwk;if(!s)throw new Error("Only asymmetric keys can be used as DPoP proofs");const l=Math.floor(Date.now()/1e3);return t.createJwt({alg:e,typ:"dpop+jwt",jwk:s},{iat:l,jti:Math.random().toString(36).slice(2),htm:r,htu:n,nonce:i,ath:o})}async function A5(t,e){if((e===void 0||e===!1)&&t.status===401){const r=t.headers.get("WWW-Authenticate");if(r!=null&&r.startsWith("DPoP"))return r.includes('error="use_dpop_nonce"')}if((e===void 0||e===!0)&&t.status===400)try{const r=await(0,QT.peekJson)(t,10240);return typeof r=="object"&&(r==null?void 0:r.error)==="use_dpop_nonce"}catch{return!1}return!1}function S5(t,e){if(e){const r=e.find(n=>t.algorithms.includes(n));if(r)return r}else{const[r]=t.algorithms;if(r)return r}throw new Error("Key does not match any alg supported by the server")}async function C5(t){if(av==null)throw new Error("crypto.subtle is not available in this environment. Please provide a sha256 function.");const e=new TextEncoder().encode(t),r=await av.digest("SHA-256",e),n=new Uint8Array(r);return _5.base64url.baseEncode(n)}var ol={};Object.defineProperty(ol,"__esModule",{value:!0});ol.OAuthResponseError=void 0;const $R=Io;class T5 extends Error{constructor(e,r){const n=typeof r=="object"?r:void 0,i=(0,$R.ifString)(n==null?void 0:n.error),o=(0,$R.ifString)(n==null?void 0:n.error_description),s=i?`"${i}"`:"unknown",l=o?`: ${o}`:"",u=`OAuth ${s} error${l}`;super(u),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"payload",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"error",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"errorDescription",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.error=i,this.errorDescription=o}get status(){return this.response.status}get headers(){return this.response.headers}}ol.OAuthResponseError=T5;var k5=S&&S.__addDisposableResource||function(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,i;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],r&&(i=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");i&&(n=function(){try{i.call(this)}catch(o){return Promise.reject(o)}}),t.stack.push({value:e,dispose:n,async:r})}else r&&t.stack.push({async:!0});return e},L5=S&&S.__disposeResources||function(t){return function(e){function r(s){e.error=e.hasError?new t(s,e.error,"An error was suppressed during disposal."):s,e.hasError=!0}var n,i=0;function o(){for(;n=e.stack.pop();)try{if(!n.async&&i===1)return i=0,e.stack.push(n),Promise.resolve().then(o);if(n.dispose){var s=n.dispose.call(n.value);if(n.async)return i|=2,Promise.resolve(s).then(o,function(l){return r(l),o()})}else i|=1}catch(l){r(l)}if(i===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return o()}}(typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var n=new Error(r);return n.name="SuppressedError",n.error=t,n.suppressed=e,n});Object.defineProperty(yd,"__esModule",{value:!0});yd.OAuthServerAgent=void 0;const P5=Rr,OR=Mn,D5=ZT,B5=il,I5=Ty,j5=nl,U5=ol,$5=Io;class O5{constructor(e,r,n,i,o,s,l,u,c){Object.defineProperty(this,"authMethod",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"dpopKey",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"serverMetadata",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"clientMetadata",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"dpopNonces",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"oauthResolver",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"keyset",{enumerable:!0,configurable:!0,writable:!0,value:u}),Object.defineProperty(this,"dpopFetch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientCredentialsFactory",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.clientCredentialsFactory=(0,j5.createClientCredentialsFactory)(e,n,i,l,u),this.dpopFetch=(0,I5.dpopFetchWrapper)({fetch:(0,OR.bindFetch)(c),key:r,supportedAlgs:n.dpop_signing_alg_values_supported,sha256:async d=>l.sha256(d),nonces:o,isAuthServer:!0})}get issuer(){return this.serverMetadata.issuer}async revoke(e){try{await this.request("revocation",{token:e})}catch{}}async exchangeCode(e,r){const n=Date.now(),i=await this.request("token",{grant_type:"authorization_code",redirect_uri:this.clientMetadata.redirect_uris[0],code:e,code_verifier:r});try{return{aud:await this.verifyIssuer(i.sub),sub:i.sub,iss:this.issuer,scope:i.scope,refresh_token:i.refresh_token,access_token:i.access_token,token_type:i.token_type,expires_at:typeof i.expires_in=="number"?new Date(n+i.expires_in*1e3).toISOString():void 0}}catch(o){throw await this.revoke(i.access_token),o}}async refresh(e){if(!e.refresh_token)throw new B5.TokenRefreshError(e.sub,"No refresh token available");const r=await this.verifyIssuer(e.sub),n=Date.now(),i=await this.request("token",{grant_type:"refresh_token",refresh_token:e.refresh_token});return{aud:r,sub:e.sub,iss:this.issuer,scope:i.scope,refresh_token:i.refresh_token,access_token:i.access_token,token_type:i.token_type,expires_at:typeof i.expires_in=="number"?new Date(n+i.expires_in*1e3).toISOString():void 0}}async verifyIssuer(e){const r={stack:[],error:void 0,hasError:!1};try{const n=k5(r,(0,$5.timeoutSignal)(1e4),!1),i=await this.oauthResolver.resolveFromIdentity(e,{noCache:!0,allowStale:!1,signal:n});if(this.issuer!==i.metadata.issuer)throw new TypeError("Issuer mismatch");return i.identity.pds.href}catch(n){r.error=n,r.hasError=!0}finally{L5(r)}}async request(e,r){const n=this.serverMetadata[`${e}_endpoint`];if(!n)throw new Error(`No ${e} endpoint available`);const i=await this.clientCredentialsFactory(),{response:o,json:s}=await this.dpopFetch(n,{method:"POST",headers:{...i.headers,"Content-Type":"application/x-www-form-urlencoded"},body:K5({...r,...i.payload})}).then((0,OR.fetchJsonProcessor)());if(o.ok)switch(e){case"token":return D5.atprotoTokenResponseSchema.parse(s);case"pushed_authorization_request":return P5.oauthParResponseSchema.parse(s);default:return s}else throw new U5.OAuthResponseError(o,s)}}yd.OAuthServerAgent=O5;function K5(t){return new URLSearchParams(Object.entries(t).filter(V5).map(M5)).toString()}function V5(t){return t[1]!==void 0}function M5(t){const e=t[0],r=t[1];switch(typeof r){case"string":return[e,r];case"number":case"boolean":return[e,String(r)];default:{const n=JSON.stringify(r);if(n===void 0)throw new Error(`Unsupported value type for ${e}: ${String(r)}`);return[e,n]}}}Object.defineProperty(hd,"__esModule",{value:!0});hd.OAuthServerFactory=void 0;const N5=nl,z5=yd;class F5{constructor(e,r,n,i,o,s){Object.defineProperty(this,"clientMetadata",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"resolver",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"fetch",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"keyset",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"dpopNonceCache",{enumerable:!0,configurable:!0,writable:!0,value:s})}async fromIssuer(e,r,n,i){const o=await this.resolver.getAuthorizationServerMetadata(e,i);return r==="legacy"&&(r=(0,N5.negotiateClientAuthMethod)(o,this.clientMetadata,this.keyset)),this.fromMetadata(o,r,n)}async fromMetadata(e,r,n){return new z5.OAuthServerAgent(r,n,e,this.clientMetadata,this.dpopNonceCache,this.resolver,this.runtime,this.keyset,this.fetch)}}hd.OAuthServerFactory=F5;var md={},sl={};Object.defineProperty(sl,"__esModule",{value:!0});sl.TokenInvalidError=void 0;class q5 extends Error{constructor(e,r=`The session for "${e}" is invalid`,n){super(r,n),Object.defineProperty(this,"sub",{enumerable:!0,configurable:!0,writable:!0,value:e})}}sl.TokenInvalidError=q5;Object.defineProperty(md,"__esModule",{value:!0});md.OAuthSession=void 0;const G5=Mn,H5=sl,X5=Us,W5=Ty,KR=globalThis.ReadableStream;class J5{constructor(e,r,n,i=globalThis.fetch){Object.defineProperty(this,"server",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"sub",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"sessionGetter",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"dpopFetch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.dpopFetch=(0,W5.dpopFetchWrapper)({fetch:(0,G5.bindFetch)(i),key:e.dpopKey,supportedAlgs:e.serverMetadata.dpop_signing_alg_values_supported,sha256:async o=>e.runtime.sha256(o),nonces:e.dpopNonces,isAuthServer:!1})}get did(){return this.sub}get serverMetadata(){return this.server.serverMetadata}async getTokenSet(e){const{tokenSet:r}=await this.sessionGetter.get(this.sub,{noCache:e===!0,allowStale:e===!1});return r}async getTokenInfo(e="auto"){const r=await this.getTokenSet(e),n=r.expires_at==null?void 0:new Date(r.expires_at);return{expiresAt:n,get expired(){return n==null?void 0:n.getTime(){const n=($p.get(t)??Promise.resolve()).then(()=>new Promise(i=>{e(()=>{$p.get(t)===n&&$p.delete(t),i()})}));$p.set(t,n)})}const Q5=(t,e)=>Z5(t).then(async r=>{try{return await e()}finally{r()}});Ly.requestLocalLock=Q5;Object.defineProperty(ky,"__esModule",{value:!0});ky.Runtime=void 0;const Cg=c0,Y5=Ly;class eF{constructor(e){Object.defineProperty(this,"implementation",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"hasImplementationLock",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"usingLock",{enumerable:!0,configurable:!0,writable:!0,value:void 0});const{requestLock:r}=e;this.hasImplementationLock=r!=null,this.usingLock=(r==null?void 0:r.bind(e))||Y5.requestLocalLock}async generateKey(e){const r=Array.from(e).sort(rF);return this.implementation.createKey(r)}async sha256(e){const r=new TextEncoder().encode(e),n=await this.implementation.digest(r,{name:"sha256"});return Cg.base64url.baseEncode(n)}async generateNonce(e=16){const r=await this.implementation.getRandomValues(e);return Cg.base64url.baseEncode(r)}async generatePKCE(e){const r=await this.generateVerifier(e);return{verifier:r,challenge:await this.sha256(r),method:"S256"}}async calculateJwkThumbprint(e){const r=tF(e),n=JSON.stringify(r);return this.sha256(n)}async generateVerifier(e=32){if(e<32||e>96)throw new TypeError("Invalid code_verifier length");const r=await this.implementation.getRandomValues(e);return Cg.base64url.baseEncode(r)}}ky.Runtime=eF;function tF(t){const e=r=>{const n=t[r];if(typeof n!="string"||!n)throw new TypeError(`"${r}" Parameter missing or invalid`);return n};switch(t.kty){case"EC":return{crv:e("crv"),kty:e("kty"),x:e("x"),y:e("y")};case"OKP":return{crv:e("crv"),kty:e("kty"),x:e("x")};case"RSA":return{e:e("e"),kty:e("kty"),n:e("n")};case"oct":return{k:e("k"),kty:e("kty")};default:throw new TypeError('"kty" (Key Type) Parameter missing or unsupported')}}function rF(t,e){if(t==="ES256K")return-1;if(e==="ES256K")return 1;for(const r of["ES","PS","RS"])if(t.startsWith(r)){if(e.startsWith(r)){const n=parseInt(t.slice(2,5)),i=parseInt(e.slice(2,5));return n-i}return-1}else if(e.startsWith(r))return 1;return 0}var gd={},MR=S&&S.__addDisposableResource||function(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,i;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],r&&(i=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");i&&(n=function(){try{i.call(this)}catch(o){return Promise.reject(o)}}),t.stack.push({value:e,dispose:n,async:r})}else r&&t.stack.push({async:!0});return e},nF=S&&S.__disposeResources||function(t){return function(e){function r(s){e.error=e.hasError?new t(s,e.error,"An error was suppressed during disposal."):s,e.hasError=!0}var n,i=0;function o(){for(;n=e.stack.pop();)try{if(!n.async&&i===1)return i=0,e.stack.push(n),Promise.resolve().then(o);if(n.dispose){var s=n.dispose.call(n.value);if(n.async)return i|=2,Promise.resolve(s).then(o,function(l){return r(l),o()})}else i|=1}catch(l){r(l)}if(i===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return o()}}(typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var n=new Error(r);return n.name="SuppressedError",n.error=t,n.suppressed=e,n});Object.defineProperty(gd,"__esModule",{value:!0});gd.SessionGetter=void 0;const iF=za,NR=rl,oF=sl,ns=il,sF=Us,aF=ol,Tg=Io;class lF extends iF.CachedGetter{constructor(e,r,n){super(async(i,o,s)=>{var f;if(s===void 0){const h="The session was deleted by another process",g=new ns.TokenRefreshError(i,h);throw this.dispatchEvent("deleted",{sub:i,cause:g}),g}const{dpopKey:l,authMethod:u="legacy",tokenSet:c}=s;if(i!==c.sub)throw new ns.TokenRefreshError(i,"Stored session sub mismatch");if(!c.refresh_token)throw new ns.TokenRefreshError(i,"No refresh token available");const d=await r.fromIssuer(c.iss,u,l);(f=o==null?void 0:o.signal)==null||f.throwIfAborted();try{const h=await d.refresh(c);if(i!==h.sub)throw new ns.TokenRefreshError(i,"Token set sub mismatch");return{dpopKey:l,tokenSet:h,authMethod:d.authMethod}}catch(h){if(h instanceof aF.OAuthResponseError&&h.status===400&&h.error==="invalid_grant"){if(!n.hasImplementationLock){await new Promise(w=>setTimeout(w,1e3));const b=await this.getStored(i);if(b===void 0){const w="The session was deleted by another process";throw new ns.TokenRefreshError(i,w,{cause:h})}else if(b.tokenSet.access_token!==c.access_token||b.tokenSet.refresh_token!==c.refresh_token)return b}const g=h.errorDescription??"The session was revoked";throw new ns.TokenRefreshError(i,g,{cause:h})}throw h}},e,{isStale:(i,{tokenSet:o})=>o.expires_at!=null&&new Date(o.expires_at).getTime(){if(!(i instanceof NR.AuthMethodUnsatisfiableError))try{await(await r.fromIssuer(s.iss,u,l)).revoke(s.refresh_token??s.access_token)}catch{}throw i},deleteOnError:async i=>i instanceof ns.TokenRefreshError||i instanceof sF.TokenRevokedError||i instanceof oF.TokenInvalidError||i instanceof NR.AuthMethodUnsatisfiableError}),Object.defineProperty(this,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"eventTarget",{enumerable:!0,configurable:!0,writable:!0,value:new Tg.CustomEventTarget})}addEventListener(e,r,n){this.eventTarget.addEventListener(e,r,n)}removeEventListener(e,r,n){this.eventTarget.removeEventListener(e,r,n)}dispatchEvent(e,r){return this.eventTarget.dispatchCustomEvent(e,r)}async setStored(e,r){if(e!==r.tokenSet.sub)throw new TypeError("Token set does not match the expected sub");await super.setStored(e,r),this.dispatchEvent("updated",{sub:e,...r})}async delStored(e,r){await super.delStored(e,r),this.dispatchEvent("deleted",{sub:e,cause:r})}async getSession(e,r){return this.get(e,{noCache:r===!0,allowStale:r===!1})}async get(e,r){const n=await this.runtime.usingLock(`@atproto-oauth-client-${e}`,async()=>{const i={stack:[],error:void 0,hasError:!1};try{const o=MR(i,(0,Tg.timeoutSignal)(3e4,r),!1),s=MR(i,(0,Tg.combineSignals)([r==null?void 0:r.signal,o]),!1);return await super.get(e,{...r,signal:s.signal})}catch(o){i.error=o,i.hasError=!0}finally{nF(i)}});if(e!==n.tokenSet.sub)throw new Error("Token set does not match the expected sub");return n}}gd.SessionGetter=lF;var K0={},bd={};Object.defineProperty(bd,"__esModule",{value:!0});bd.clientMetadataSchema=void 0;const uF=G,kg=Rr;bd.clientMetadataSchema=kg.oauthClientMetadataSchema.extend({client_id:uF.z.union([kg.oauthClientIdDiscoverableSchema,kg.oauthClientIdLoopbackSchema])});Object.defineProperty(K0,"__esModule",{value:!0});K0.validateClientMetadata=dF;const zR=Rr,FR=tl,cF=bd;function dF(t,e){var s;!t.jwks&&!t.jwks_uri&&(e!=null&&e.size)&&(t={...t,jwks:e.toJSON()});const r=cF.clientMetadataSchema.parse(t);r.client_id.startsWith("http:")?(0,zR.assertOAuthLoopbackClientId)(r.client_id):(0,zR.assertOAuthDiscoverableClientId)(r.client_id);const n=(s=r.scope)==null?void 0:s.split(" ");if(!(n!=null&&n.includes("atproto")))throw new TypeError('Client metadata must include the "atproto" scope');if(!r.response_types.includes("code"))throw new TypeError('"response_types" must include "code"');if(!r.grant_types.includes("authorization_code"))throw new TypeError('"grant_types" must include "authorization_code"');const i=r.token_endpoint_auth_method,o=r.token_endpoint_auth_signing_alg;switch(i){case"none":if(o)throw new TypeError(`"token_endpoint_auth_signing_alg" must not be provided when "token_endpoint_auth_method" is "${i}"`);break;case"private_key_jwt":{if(!o)throw new TypeError(`"token_endpoint_auth_signing_alg" must be provided when "token_endpoint_auth_method" is "${i}"`);const l=e?Array.from(e.list({use:"sig"})).filter(u=>u.isPrivate&&u.kid):null;if(!(l!=null&&l.some(u=>u.algorithms.includes(FR.FALLBACK_ALG))))throw new TypeError(`Client authentication method "${i}" requires at least one "${FR.FALLBACK_ALG}" signing key with a "kid" property`);if(r.jwks){for(const u of l)if(!r.jwks.keys.some(c=>c.kid===u.kid))throw new TypeError(`Key with kid "${u.kid}" not found in jwks`)}else if(!r.jwks_uri)throw new TypeError(`Client authentication method "${i}" requires a JWKS`);break}default:throw new TypeError(`Unsupported "token_endpoint_auth_method" value: ${i}`)}return r}Object.defineProperty(Ay,"__esModule",{value:!0});Ay.OAuthClient=void 0;const qR=Si,pF=Rr,Op=C0,GR=ay,fF=VT,Lg=Na,hF=tl,yF=rl,mF=Us,gF=cd,ei=dd,bF=nl,vF=pd,EF=Cy,wF=hd,_F=md,xF=ky,RF=gd,AF=Io,SF=K0;class CF extends AF.CustomEventTarget{static async fetchMetadata({clientId:e,fetch:r=globalThis.fetch,signal:n}){var u,c,d,f,h;n==null||n.throwIfAborted();const i=new Request(e,{redirect:"error",signal:n}),o=await r(i);if(o.status!==200)throw(c=(u=o.body)==null?void 0:u.cancel)==null||c.call(u),new TypeError(`Failed to fetch client metadata: ${o.status}`);const s=(d=o.headers.get("content-type"))==null?void 0:d.split(";")[0].trim();if(s!=="application/json")throw(h=(f=o.body)==null?void 0:f.cancel)==null||h.call(f),new TypeError(`Invalid client metadata content type: ${s}`);const l=await o.json();return n==null||n.throwIfAborted(),pF.oauthClientMetadataSchema.parse(l)}constructor({fetch:e=globalThis.fetch,allowHttp:r=!1,stateStore:n,sessionStore:i,didCache:o=void 0,dpopNonceCache:s=new Lg.SimpleStoreMemory({ttl:6e4,max:100}),handleCache:l=void 0,authorizationServerMetadataCache:u=new Lg.SimpleStoreMemory({ttl:6e4,max:100}),protectedResourceMetadataCache:c=new Lg.SimpleStoreMemory({ttl:6e4,max:100}),responseMode:d,clientMetadata:f,handleResolver:h,plcDirectoryUrl:g,runtimeImplementation:b,keyset:w}){super(),Object.defineProperty(this,"clientMetadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"responseMode",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"keyset",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fetch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"oauthResolver",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"serverFactory",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sessionGetter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"stateStore",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.keyset=w?w instanceof qR.Keyset?w:new qR.Keyset(w):void 0,this.clientMetadata=(0,SF.validateClientMetadata)(f,this.keyset),this.responseMode=d,this.runtime=new xF.Runtime(b),this.fetch=e,this.oauthResolver=new EF.OAuthResolver(new fF.IdentityResolver(new Op.DidResolverCached(new Op.DidResolverCommon({fetch:e,plcDirectoryUrl:g,allowHttp:r}),o),new GR.CachedHandleResolver(GR.AppViewHandleResolver.from(h,{fetch:e}),l)),new vF.OAuthProtectedResourceMetadataResolver(c,e,{allowHttpResource:r}),new gF.OAuthAuthorizationServerMetadataResolver(u,e,{allowHttpIssuer:r})),this.serverFactory=new wF.OAuthServerFactory(this.clientMetadata,this.runtime,this.oauthResolver,this.fetch,this.keyset,s),this.sessionGetter=new RF.SessionGetter(i,this.serverFactory,this.runtime),this.stateStore=n;for(const C of["deleted","updated"])this.sessionGetter.addEventListener(C,y=>{this.dispatchCustomEvent(C,y.detail)||y.preventDefault()})}get identityResolver(){return this.oauthResolver.identityResolver}get didResolver(){return this.identityResolver.didResolver}get handleResolver(){return this.identityResolver.handleResolver}get jwks(){var e;return((e=this.keyset)==null?void 0:e.publicJwks)??{keys:[]}}async authorize(e,{signal:r,...n}={}){const i=(n==null?void 0:n.redirect_uri)??this.clientMetadata.redirect_uris[0];if(!this.clientMetadata.redirect_uris.includes(i))throw new TypeError("Invalid redirect_uri");const{identity:o,metadata:s}=await this.oauthResolver.resolve(e,{signal:r}),l=await this.runtime.generatePKCE(),u=await this.runtime.generateKey(s.dpop_signing_alg_values_supported||[hF.FALLBACK_ALG]),c=(0,bF.negotiateClientAuthMethod)(s,this.clientMetadata,this.keyset),d=await this.runtime.generateNonce();await this.stateStore.set(d,{iss:s.issuer,dpopKey:u,authMethod:c,verifier:l.verifier,appState:n==null?void 0:n.state});const f={...n,client_id:this.clientMetadata.client_id,redirect_uri:i,code_challenge:l.challenge,code_challenge_method:l.method,state:d,login_hint:(o==null?void 0:o.handle)??(o==null?void 0:o.did),response_mode:this.responseMode,response_type:"code",scope:(n==null?void 0:n.scope)??this.clientMetadata.scope},h=new URL(s.authorization_endpoint);if(h.protocol!=="https:"&&h.protocol!=="http:")throw new TypeError(`Invalid authorization endpoint protocol: ${h.protocol}`);if(s.pushed_authorization_request_endpoint){const b=await(await this.serverFactory.fromMetadata(s,c,u)).request("pushed_authorization_request",f);return h.searchParams.set("client_id",this.clientMetadata.client_id),h.searchParams.set("request_uri",b.request_uri),h}else{if(s.require_pushed_authorization_requests)throw new Error("Server requires pushed authorization requests (PAR) but no PAR endpoint is available");for(const[b,w]of Object.entries(f))w&&h.searchParams.set(b,String(w));if(h.pathname.length+h.search.length<2048)return h;if(!s.pushed_authorization_request_endpoint)throw new Error("Login URL too long")}throw new Error("Server does not support pushed authorization requests (PAR)")}async abortRequest(e){e.searchParams.get("request_uri")}async callback(e){if(e.get("response")!=null)throw new ei.OAuthCallbackError(e,"JARM not supported");const n=e.get("iss"),i=e.get("state"),o=e.get("error"),s=e.get("code");if(!i)throw new ei.OAuthCallbackError(e,'Missing "state" parameter');const l=await this.stateStore.get(i);if(l)await this.stateStore.del(i);else throw new ei.OAuthCallbackError(e,`Unknown authorization session "${i}"`);try{if(o!=null)throw new ei.OAuthCallbackError(e,void 0,l.appState);if(!s)throw new ei.OAuthCallbackError(e,'Missing "code" query param',l.appState);const u=await this.serverFactory.fromIssuer(l.iss,l.authMethod??"legacy",l.dpopKey);if(n!=null){if(!u.issuer)throw new ei.OAuthCallbackError(e,"Issuer not found in metadata",l.appState);if(u.issuer!==n)throw new ei.OAuthCallbackError(e,"Issuer mismatch",l.appState)}else if(u.serverMetadata.authorization_response_iss_parameter_supported)throw new ei.OAuthCallbackError(e,"iss missing from the response",l.appState);const c=await u.exchangeCode(s,l.verifier);try{return await this.sessionGetter.setStored(c.sub,{dpopKey:l.dpopKey,authMethod:u.authMethod,tokenSet:c}),{session:this.createSession(u,c.sub),state:l.appState??null}}catch(d){throw await u.revoke(c.refresh_token||c.access_token),d}}catch(u){throw ei.OAuthCallbackError.from(u,e,l.appState)}}async restore(e,r="auto"){(0,Op.assertAtprotoDid)(e);const{dpopKey:n,authMethod:i="legacy",tokenSet:o}=await this.sessionGetter.get(e,{noCache:r===!0,allowStale:r===!1});try{const s=await this.serverFactory.fromIssuer(o.iss,i,n,{noCache:r===!0,allowStale:r===!1});return this.createSession(s,e)}catch(s){throw s instanceof yF.AuthMethodUnsatisfiableError&&await this.sessionGetter.delStored(e,s),s}}async revoke(e){(0,Op.assertAtprotoDid)(e);const{dpopKey:r,authMethod:n="legacy",tokenSet:i}=await this.sessionGetter.get(e,{allowStale:!0});try{await(await this.serverFactory.fromIssuer(i.iss,n,r)).revoke(i.access_token)}finally{await this.sessionGetter.delStored(e,new mF.TokenRevokedError(e))}}createSession(e,r){return new _F.OAuthSession(e,r,this.sessionGetter,this.fetch)}}Ay.OAuthClient=CF;var YT={};Object.defineProperty(YT,"__esModule",{value:!0});var ek={};Object.defineProperty(ek,"__esModule",{value:!0});(function(t){var e=S&&S.__createBinding||(Object.create?function(i,o,s,l){l===void 0&&(l=s);var u=Object.getOwnPropertyDescriptor(o,s);(!u||("get"in u?!o.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return o[s]}}),Object.defineProperty(i,l,u)}:function(i,o,s,l){l===void 0&&(l=s),i[l]=o[s]}),r=S&&S.__exportStar||function(i,o){for(var s in i)s!=="default"&&!Object.prototype.hasOwnProperty.call(o,s)&&e(o,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),t.FetchResponseError=t.FetchRequestError=t.FetchError=void 0,r(C0,t);var n=Mn;Object.defineProperty(t,"FetchError",{enumerable:!0,get:function(){return n.FetchError}}),Object.defineProperty(t,"FetchRequestError",{enumerable:!0,get:function(){return n.FetchRequestError}}),Object.defineProperty(t,"FetchResponseError",{enumerable:!0,get:function(){return n.FetchResponseError}}),r(ay,t),r(Do,t),r(Rr,t),r(cd,t),r(dd,t),r(Ay,t),r(pd,t),r(fd,t),r(ol,t),r(yd,t),r(hd,t),r(md,t),r(YT,t),r(gd,t),r(ek,t),r(bd,t),r(sl,t),r(il,t),r(Us,t)})(S0);var Py={},Dy={},tk={},By={},vd={},Ed={},wd={},_d={};Object.defineProperty(_d,"__esModule",{value:!0});_d.handleRequest=rk;_d.promisify=TF;function rk(t,e,r){const n=()=>{t.removeEventListener("success",i),t.removeEventListener("error",o)},i=()=>{e(t.result),n()},o=()=>{r(t.error||new Error("Unknown error")),n()};t.addEventListener("success",i),t.addEventListener("error",o)}function TF(t){return new Promise((e,r)=>{rk(t,e,r)})}Object.defineProperty(wd,"__esModule",{value:!0});wd.DBIndex=void 0;const _u=_d;class kF{constructor(e){Object.defineProperty(this,"idbIndex",{enumerable:!0,configurable:!0,writable:!0,value:e})}count(e){return(0,_u.promisify)(this.idbIndex.count(e))}get(e){return(0,_u.promisify)(this.idbIndex.get(e))}getKey(e){return(0,_u.promisify)(this.idbIndex.getKey(e))}getAll(e,r){return(0,_u.promisify)(this.idbIndex.getAll(e,r))}getAllKeys(e,r){return(0,_u.promisify)(this.idbIndex.getAllKeys(e,r))}deleteAll(e){return new Promise((r,n)=>{const i=this.idbIndex.openCursor(e);i.onsuccess=function(o){const s=o.target.result;s?(s.delete(),s.continue()):r()},i.onerror=function(o){var s;n(((s=o.target)==null?void 0:s.error)||new Error("Unexpected error"))}})}}wd.DBIndex=kF;Object.defineProperty(Ed,"__esModule",{value:!0});Ed.DBObjectStore=void 0;const LF=wd,ji=_d;class PF{constructor(e){Object.defineProperty(this,"idbObjStore",{enumerable:!0,configurable:!0,writable:!0,value:e})}get name(){return this.idbObjStore.name}index(e){return new LF.DBIndex(this.idbObjStore.index(e))}get(e){return(0,ji.promisify)(this.idbObjStore.get(e))}getKey(e){return(0,ji.promisify)(this.idbObjStore.getKey(e))}getAll(e,r){return(0,ji.promisify)(this.idbObjStore.getAll(e,r))}getAllKeys(e,r){return(0,ji.promisify)(this.idbObjStore.getAllKeys(e,r))}add(e,r){return(0,ji.promisify)(this.idbObjStore.add(e,r))}put(e,r){return(0,ji.promisify)(this.idbObjStore.put(e,r))}delete(e){return(0,ji.promisify)(this.idbObjStore.delete(e))}clear(){return(0,ji.promisify)(this.idbObjStore.clear())}}Ed.DBObjectStore=PF;var Kp=S&&S.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Pg=S&&S.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ti;Object.defineProperty(vd,"__esModule",{value:!0});vd.DBTransaction=void 0;const DF=Ed;class BF{constructor(e){ti.set(this,void 0),Kp(this,ti,e,"f");const r=()=>{i()},n=()=>{i()},i=()=>{Kp(this,ti,null,"f"),e.removeEventListener("abort",r),e.removeEventListener("complete",n)};e.addEventListener("abort",r),e.addEventListener("complete",n)}get tx(){if(!Pg(this,ti,"f"))throw new Error("Transaction already ended");return Pg(this,ti,"f")}async abort(){const{tx:e}=this;Kp(this,ti,null,"f"),e.abort()}async commit(){var r;const{tx:e}=this;Kp(this,ti,null,"f"),(r=e.commit)==null||r.call(e)}objectStore(e){const r=this.tx.objectStore(e);return new DF.DBObjectStore(r)}[(ti=new WeakMap,Symbol.dispose)](){Pg(this,ti,"f")&&this.commit()}}vd.DBTransaction=BF;var Dg=S&&S.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Bg=S&&S.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ui;Object.defineProperty(By,"__esModule",{value:!0});By.DB=void 0;const IF=vd;class V0{static async open(e,r,n){const i=await new Promise((o,s)=>{const l=indexedDB.open(e,r.length);l.onerror=()=>s(l.error),l.onsuccess=()=>o(l.result),l.onupgradeneeded=({oldVersion:u,newVersion:c})=>{const d=l.result;try{for(let f=u;f<(c??r.length);++f){const h=r[f];if(h)h(d);else throw new Error(`Missing migration for version ${f}`)}}catch(f){d.close(),s(f)}}});return new V0(i,n)}constructor(e,r){Object.defineProperty(this,"txOptions",{enumerable:!0,configurable:!0,writable:!0,value:r}),Ui.set(this,void 0),Dg(this,Ui,e,"f");const n=()=>{Dg(this,Ui,null,"f"),e.removeEventListener("versionchange",n),e.removeEventListener("close",n),e.close()};e.addEventListener("versionchange",n),e.addEventListener("close",n)}get db(){if(!Bg(this,Ui,"f"))throw new Error("Database closed");return Bg(this,Ui,"f")}get name(){return this.db.name}get objectStoreNames(){return this.db.objectStoreNames}get version(){return this.db.version}async transaction(e,r,n){return new Promise(async(i,o)=>{try{const s=this.db.transaction(e,r,this.txOptions);let l={done:!1};s.oncomplete=()=>{l.done?i(l.value):o(new Error("Transaction completed without result"))},s.onerror=()=>o(s.error),s.onabort=()=>o(s.error||new Error("Transaction aborted"));try{l={done:!0,value:await n(new IF.DBTransaction(s))},s.commit()}catch(u){throw s.abort(),u}}catch(s){o(s)}})}close(){const{db:e}=this;Dg(this,Ui,null,"f"),e.close()}[(Ui=new WeakMap,Symbol.dispose)](){if(Bg(this,Ui,"f"))return this.close()}}By.DB=V0;(function(t){var e=S&&S.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=S&&S.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&e(i,n,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(By,t),r(wd,t),r(Ed,t),r(vd,t)})(tk);var Vp=S&&S.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},xu=S&&S.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},$i,Ru;Object.defineProperty(Dy,"__esModule",{value:!0});Dy.BrowserOAuthDatabase=void 0;const nk=jh,jF=tk;function HR(t){if(!(t instanceof nk.WebcryptoKey)||!t.kid)throw new Error("Invalid key object");return{keyId:t.kid,keyPair:t.cryptoKeyPair}}async function XR(t){return nk.WebcryptoKey.fromKeypair(t.keyPair,t.keyId)}const WR=["state","session","didCache","dpopNonceCache","handleCache","authorizationServerMetadataCache","protectedResourceMetadataCache"];class UF{constructor(e){$i.set(this,void 0),Ru.set(this,void 0),Vp(this,$i,jF.DB.open((e==null?void 0:e.name)??"@atproto-oauth-client",[r=>{for(const n of WR)r.createObjectStore(n,{autoIncrement:!0}).createIndex("expiresAt","expiresAt",{unique:!1})}],{durability:(e==null?void 0:e.durability)??"strict"}),"f"),Vp(this,Ru,setInterval(()=>{this.cleanup()},(e==null?void 0:e.cleanupInterval)??3e4),"f")}async run(e,r,n){return await(await xu(this,$i,"f")).transaction([e],r,o=>n(o.objectStore(e)))}createStore(e,{encode:r,decode:n,expiresAt:i}){return{get:async o=>{const s=await this.run(e,"readonly",l=>l.get(o));if(s!==void 0){if(s.expiresAt!=null&&new Date(s.expiresAt)l.delete(o));return}return n(s.value)}},set:async(o,s)=>{var u;const l={value:await r(s),expiresAt:(u=i(s))==null?void 0:u.toISOString()};await this.run(e,"readwrite",c=>c.put(l,o))},del:async o=>{await this.run(e,"readwrite",s=>s.delete(o))}}}getSessionStore(){return this.createStore("session",{expiresAt:({tokenSet:e})=>e.refresh_token||e.expires_at==null?null:new Date(e.expires_at),encode:({dpopKey:e,...r})=>({...r,dpopKey:HR(e)}),decode:async({dpopKey:e,...r})=>({...r,dpopKey:await XR(e)})})}getStateStore(){return this.createStore("state",{expiresAt:e=>new Date(Date.now()+10*6e4),encode:({dpopKey:e,...r})=>({...r,dpopKey:HR(e)}),decode:async({dpopKey:e,...r})=>({...r,dpopKey:await XR(e)})})}getDpopNonceCache(){return this.createStore("dpopNonceCache",{expiresAt:e=>new Date(Date.now()+6e5),encode:e=>e,decode:e=>e})}getDidCache(){return this.createStore("didCache",{expiresAt:e=>new Date(Date.now()+6e4),encode:e=>e,decode:e=>e})}getHandleCache(){return this.createStore("handleCache",{expiresAt:e=>new Date(Date.now()+6e4),encode:e=>e,decode:e=>e})}getAuthorizationServerMetadataCache(){return this.createStore("authorizationServerMetadataCache",{expiresAt:e=>new Date(Date.now()+6e4),encode:e=>e,decode:e=>e})}getProtectedResourceMetadataCache(){return this.createStore("protectedResourceMetadataCache",{expiresAt:e=>new Date(Date.now()+6e4),encode:e=>e,decode:e=>e})}async cleanup(){const e=await xu(this,$i,"f");for(const r of WR)await e.transaction([r],"readwrite",n=>n.objectStore(r).index("expiresAt").deleteAll(IDBKeyRange.upperBound(Date.now())))}async[($i=new WeakMap,Ru=new WeakMap,Symbol.asyncDispose)](){clearInterval(xu(this,Ru,"f")),Vp(this,Ru,void 0,"f");const e=xu(this,$i,"f");Vp(this,$i,Promise.reject(new Error("Database has been disposed")),"f"),xu(this,$i,"f").catch(()=>null);const r=await e.catch(()=>null);r&&await(r[Symbol.asyncDispose]||r[Symbol.dispose]).call(r)}}Dy.BrowserOAuthDatabase=UF;var Iy={};Object.defineProperty(Iy,"__esModule",{value:!0});Iy.BrowserRuntimeImplementation=void 0;const $F=jh;var jA;const OF=(jA=navigator.locks)!=null&&jA.request?(t,e)=>navigator.locks.request(t,{mode:"exclusive"},async()=>e()):void 0;class KF{constructor(){if(Object.defineProperty(this,"requestLock",{enumerable:!0,configurable:!0,writable:!0,value:OF}),typeof crypto!="object"||!(crypto!=null&&crypto.subtle))throw new Error("Crypto with CryptoSubtle is required. If running in a browser, make sure the current page is loaded over HTTPS.");this.requestLock||console.warn("Locks API not available. You should consider using a more recent browser.")}async createKey(e){return $F.WebcryptoKey.generate(e)}getRandomValues(e){return crypto.getRandomValues(new Uint8Array(e))}async digest(e,{name:r}){switch(r){case"sha256":case"sha384":case"sha512":{const n=await crypto.subtle.digest(`SHA-${r.slice(3)}`,e);return new Uint8Array(n)}default:throw new Error(`Unsupported digest algorithm: ${r}`)}}}Iy.BrowserRuntimeImplementation=KF;var xd={};Object.defineProperty(xd,"__esModule",{value:!0});xd.LoginContinuedInParentWindowError=void 0;class VF extends Error{constructor(){super("Login complete, please close the popup window."),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:"LOGIN_CONTINUED_IN_PARENT_WINDOW"})}}xd.LoginContinuedInParentWindowError=VF;var jy={};Object.defineProperty(jy,"__esModule",{value:!0});jy.buildLoopbackClientId=NF;const MF=Rr;function NF(t,e="127.0.0.1"){if(!(0,MF.isLoopbackHost)(t.hostname))throw new TypeError(`Expected a loopback host, got ${t.hostname}`);const r=`http://${t.hostname==="localhost"?e:t.hostname}${t.port&&!t.port.startsWith(":")?`:${t.port}`:t.port}${t.pathname}`;return`http://localhost${t.pathname==="/"?"":t.pathname}?redirect_uri=${encodeURIComponent(r)}`}var ik;Object.defineProperty(Py,"__esModule",{value:!0});Py.BrowserOAuthClient=void 0;const Mp=S0,vf=Rr,zF=Dy,FF=Iy,Ig=xd,qF=jy,An="@@atproto/oauth-client-browser",JR=`${An}(popup-channel)`,Au=`${An}(popup-state):`,ZR=new BroadcastChannel(`${An}(synchronization-channel)`);class ph extends Mp.OAuthClient{static async load({clientId:e,...r}){if(e.startsWith("http:")){const n=(0,vf.atprotoLoopbackClientMetadata)(e);return new ph({clientMetadata:n,...r})}else if(e.startsWith("https:")){(0,vf.assertOAuthDiscoverableClientId)(e);const n=await Mp.OAuthClient.fetchMetadata({clientId:e,...r});return new ph({clientMetadata:n,...r})}else throw new TypeError(`Invalid client id: ${e}`)}constructor({clientMetadata:e=(0,vf.atprotoLoopbackClientMetadata)((0,qF.buildLoopbackClientId)(window.location)),responseMode:r="fragment",...n}){var l;if(!((l=globalThis.crypto)!=null&&l.subtle))throw new Error("WebCrypto API is required");if(!["query","fragment"].includes(r))throw new TypeError(`Invalid response mode: ${r}`);const i=new zF.BrowserOAuthDatabase;super({...n,clientMetadata:e,responseMode:r,keyset:void 0,runtimeImplementation:new FF.BrowserRuntimeImplementation,sessionStore:i.getSessionStore(),stateStore:i.getStateStore(),didCache:i.getDidCache(),handleCache:i.getHandleCache(),dpopNonceCache:i.getDpopNonceCache(),authorizationServerMetadataCache:i.getAuthorizationServerMetadataCache(),protectedResourceMetadataCache:i.getProtectedResourceMetadataCache()}),Object.defineProperty(this,ik,{enumerable:!0,configurable:!0,writable:!0,value:void 0});const o=new AbortController,{signal:s}=o;this[Symbol.dispose]=()=>o.abort(),s.addEventListener("abort",()=>i[Symbol.asyncDispose](),{once:!0}),this.addEventListener("deleted",({detail:{sub:u}})=>{localStorage.getItem(`${An}(sub)`)===u&&localStorage.removeItem(`${An}(sub)`)});for(const u of["deleted","updated"])this.sessionGetter.addEventListener(u,({detail:c})=>{ZR.postMessage([u,c])});ZR.addEventListener("message",u=>{if(u.source!==window){const[c,d]=u.data;this.dispatchCustomEvent(c,d)}},{signal:s})}async init(e){await GF(this.clientMetadata);const r=await this.signInCallback();if(r)return localStorage.setItem(`${An}(sub)`,r.session.sub),r;const n=localStorage.getItem(`${An}(sub)`);if(n)try{return{session:await this.restore(n,e)}}catch(i){throw localStorage.removeItem(`${An}(sub)`),i}}async restore(e,r){const n=await super.restore(e,r);return localStorage.setItem(`${An}(sub)`,n.sub),n}async revoke(e){return localStorage.removeItem(`${An}(sub)`),super.revoke(e)}async signIn(e,r){return(r==null?void 0:r.display)==="popup"?this.signInPopup(e,r):this.signInRedirect(e,r)}async signInRedirect(e,r){const n=await this.authorize(e,r);return window.location.href=n.href,new Promise((i,o)=>{setTimeout(s=>{this.abortRequest(n).then(()=>o(s),l=>o(new AggregateError([s,l])))},5e3,new Error("User navigated back"))})}async signInPopup(e,r){var l;const n="width=600,height=600,menubar=no,toolbar=no";let i=window.open("about:blank","_blank",n);const o=`${Math.random().toString(36).slice(2)}`,s=await this.authorize(e,{...r,state:`${Au}${o}`,display:(r==null?void 0:r.display)??"popup"});return(l=r==null?void 0:r.signal)==null||l.throwIfAborted(),i?i.window.location.href=s.href:i=window.open(s.href,"_blank",n),i==null||i.focus(),new Promise((u,c)=>{var w;const d=new BroadcastChannel(JR),f=()=>{var C;clearTimeout(g),d.removeEventListener("message",b),d.close(),(C=r==null?void 0:r.signal)==null||C.removeEventListener("abort",h),i==null||i.close()},h=()=>{var C;c(new Error((C=r==null?void 0:r.signal)!=null&&C.aborted?"Aborted":"Timeout")),f()};(w=r==null?void 0:r.signal)==null||w.addEventListener("abort",h);const g=setTimeout(h,5*6e4),b=async({data:C})=>{var m;if(C.key!==o||!("result"in C))return;d.postMessage({key:o,ack:!0}),f();const{result:y}=C;if(y.status==="fulfilled"){const E=y.value;try{(m=r==null?void 0:r.signal)==null||m.throwIfAborted(),u(await this.restore(E,!1))}catch(A){c(A),this.revoke(E)}}else{const{message:E,params:A}=y.reason;c(new Mp.OAuthCallbackError(new URLSearchParams(A),E))}};d.addEventListener("message",b)})}readCallbackParams(){const e=this.responseMode==="fragment"?new URLSearchParams(location.hash.slice(1)):new URLSearchParams(location.search);if(!e.has("state")||!(e.has("code")||e.has("error")))return null;const r=i=>location.origin===i.origin&&location.pathname===i.pathname;return this.clientMetadata.redirect_uris.map(i=>new URL(i)).some(r)?e:null}async signInCallback(){const e=this.readCallbackParams();if(!e)return null;this.responseMode==="fragment"?history.replaceState(null,"",location.pathname+location.search):this.responseMode==="query"&&history.replaceState(null,"",location.pathname);const r=n=>{const i=new BroadcastChannel(JR);return new Promise(o=>{const s=c=>{clearTimeout(u),i.removeEventListener("message",l),i.close(),o(c)},l=({data:c})=>{"ack"in c&&n.key===c.key&&s(!0)};i.addEventListener("message",l),i.postMessage(n);const u=setTimeout(s,500,!1)})};return this.callback(e).then(async n=>{var i;if((i=n.state)!=null&&i.startsWith(Au))throw await r({key:n.state.slice(Au.length),result:{status:"fulfilled",value:n.session.sub}})||await n.session.signOut(),new Ig.LoginContinuedInParentWindowError;return n}).catch(async n=>{var i;throw n instanceof Mp.OAuthCallbackError&&((i=n.state)!=null&&i.startsWith(Au))?(await r({key:n.state.slice(Au.length),result:{status:"rejected",reason:{message:n.message,params:Array.from(n.params.entries())}}}),new Ig.LoginContinuedInParentWindowError):n}).catch(n=>{throw n instanceof Ig.LoginContinuedInParentWindowError&&window.close(),n})}dispose(){this[Symbol.dispose]()}}Py.BrowserOAuthClient=ph;ik=Symbol.dispose;function GF(t){if(!(0,vf.isOAuthClientIdLoopback)(t.client_id)||window.location.hostname!=="localhost")return;const e=new URL(window.location.href);for(const r of t.redirect_uris){const n=new URL(r);if((n.hostname==="127.0.0.1"||n.hostname==="[::1]")&&(!n.port||n.port===e.port)&&n.protocol===e.protocol&&n.pathname===e.pathname)throw n.port=e.port,window.location.href=n.href,new Error("Redirecting to loopback IP...")}throw new Error(`Please use the loopback IP address instead of ${e}`)}(function(t){var e=S&&S.__createBinding||(Object.create?function(i,o,s,l){l===void 0&&(l=s);var u=Object.getOwnPropertyDescriptor(o,s);(!u||("get"in u?!o.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return o[s]}}),Object.defineProperty(i,l,u)}:function(i,o,s,l){l===void 0&&(l=s),i[l]=o[s]}),r=S&&S.__exportStar||function(i,o){for(var s in i)s!=="default"&&!Object.prototype.hasOwnProperty.call(o,s)&&e(o,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),t.buildLoopbackClientId=void 0,r(jh,t),r(S0,t),r(Py,t),r(xd,t);var n=jy;Object.defineProperty(t,"buildLoopbackClientId",{enumerable:!0,get:function(){return n.buildLoopbackClientId}})})(Vb);var Ef={},Ls={},Uo={},al={};Object.defineProperty(al,"__esModule",{value:!0});al.toLexUri=HF;al.requiredPropertiesRefinement=XF;const jg=G;function HF(t,e){if(t.split("#").length>2)throw new Error("Uri can only have one hash segment");if(t.startsWith("lex:"))return t;if(t.startsWith("#")){if(!e)throw new Error(`Unable to resolve uri without anchor: ${t}`);return`${e}${t}`}return`lex:${t}`}function XF(t,e){if(t.required!==void 0){if(!Array.isArray(t.required)){e.addIssue({code:jg.z.ZodIssueCode.invalid_type,received:typeof t.required,expected:"array"});return}if(t.properties===void 0){t.required.length>0&&e.addIssue({code:jg.z.ZodIssueCode.custom,message:"Required fields defined but no properties defined"});return}for(const r of t.required)t.properties[r]===void 0&&e.addIssue({code:jg.z.ZodIssueCode.custom,message:`Required field "${r}" not defined`})}}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.LexiconDefNotFoundError=t.InvalidLexiconError=t.ValidationError=t.lexiconDoc=t.lexUserType=t.lexRecord=t.lexXrpcSubscription=t.lexXrpcProcedure=t.lexXrpcQuery=t.lexXrpcError=t.lexXrpcSubscriptionMessage=t.lexXrpcBody=t.lexXrpcParameters=t.lexObject=t.lexToken=t.lexPrimitiveArray=t.lexArray=t.lexBlob=t.lexRefVariant=t.lexRefUnion=t.lexRef=t.lexIpldType=t.lexCidLink=t.lexBytes=t.lexPrimitive=t.lexUnknown=t.lexString=t.lexStringFormat=t.lexInteger=t.lexBoolean=void 0,t.isValidLexiconDoc=i,t.isObj=o,t.isDiscriminatedObject=s,t.parseLexiconDoc=l;const e=G,r=jo,n=al;t.lexBoolean=e.z.object({type:e.z.literal("boolean"),description:e.z.string().optional(),default:e.z.boolean().optional(),const:e.z.boolean().optional()}).strict(),t.lexInteger=e.z.object({type:e.z.literal("integer"),description:e.z.string().optional(),default:e.z.number().int().optional(),minimum:e.z.number().int().optional(),maximum:e.z.number().int().optional(),enum:e.z.number().int().array().optional(),const:e.z.number().int().optional()}).strict(),t.lexStringFormat=e.z.enum(["datetime","uri","at-uri","did","handle","at-identifier","nsid","cid","language","tid","record-key"]),t.lexString=e.z.object({type:e.z.literal("string"),format:t.lexStringFormat.optional(),description:e.z.string().optional(),default:e.z.string().optional(),minLength:e.z.number().int().optional(),maxLength:e.z.number().int().optional(),minGraphemes:e.z.number().int().optional(),maxGraphemes:e.z.number().int().optional(),enum:e.z.string().array().optional(),const:e.z.string().optional(),knownValues:e.z.string().array().optional()}).strict(),t.lexUnknown=e.z.object({type:e.z.literal("unknown"),description:e.z.string().optional()}).strict(),t.lexPrimitive=e.z.discriminatedUnion("type",[t.lexBoolean,t.lexInteger,t.lexString,t.lexUnknown]),t.lexBytes=e.z.object({type:e.z.literal("bytes"),description:e.z.string().optional(),maxLength:e.z.number().optional(),minLength:e.z.number().optional()}).strict(),t.lexCidLink=e.z.object({type:e.z.literal("cid-link"),description:e.z.string().optional()}).strict(),t.lexIpldType=e.z.discriminatedUnion("type",[t.lexBytes,t.lexCidLink]),t.lexRef=e.z.object({type:e.z.literal("ref"),description:e.z.string().optional(),ref:e.z.string()}).strict(),t.lexRefUnion=e.z.object({type:e.z.literal("union"),description:e.z.string().optional(),refs:e.z.string().array(),closed:e.z.boolean().optional()}).strict(),t.lexRefVariant=e.z.discriminatedUnion("type",[t.lexRef,t.lexRefUnion]),t.lexBlob=e.z.object({type:e.z.literal("blob"),description:e.z.string().optional(),accept:e.z.string().array().optional(),maxSize:e.z.number().optional()}).strict(),t.lexArray=e.z.object({type:e.z.literal("array"),description:e.z.string().optional(),items:e.z.discriminatedUnion("type",[t.lexBoolean,t.lexInteger,t.lexString,t.lexUnknown,t.lexBytes,t.lexCidLink,t.lexRef,t.lexRefUnion,t.lexBlob]),minLength:e.z.number().int().optional(),maxLength:e.z.number().int().optional()}).strict(),t.lexPrimitiveArray=t.lexArray.merge(e.z.object({items:t.lexPrimitive}).strict()),t.lexToken=e.z.object({type:e.z.literal("token"),description:e.z.string().optional()}).strict(),t.lexObject=e.z.object({type:e.z.literal("object"),description:e.z.string().optional(),required:e.z.string().array().optional(),nullable:e.z.string().array().optional(),properties:e.z.record(e.z.discriminatedUnion("type",[t.lexArray,t.lexBoolean,t.lexInteger,t.lexString,t.lexUnknown,t.lexBytes,t.lexCidLink,t.lexRef,t.lexRefUnion,t.lexBlob]))}).strict().superRefine(n.requiredPropertiesRefinement),t.lexXrpcParameters=e.z.object({type:e.z.literal("params"),description:e.z.string().optional(),required:e.z.string().array().optional(),properties:e.z.record(e.z.discriminatedUnion("type",[t.lexPrimitiveArray,t.lexBoolean,t.lexInteger,t.lexString,t.lexUnknown]))}).strict().superRefine(n.requiredPropertiesRefinement),t.lexXrpcBody=e.z.object({description:e.z.string().optional(),encoding:e.z.string(),schema:e.z.union([t.lexRefVariant,t.lexObject]).optional()}).strict(),t.lexXrpcSubscriptionMessage=e.z.object({description:e.z.string().optional(),schema:e.z.union([t.lexRefVariant,t.lexObject]).optional()}).strict(),t.lexXrpcError=e.z.object({name:e.z.string(),description:e.z.string().optional()}).strict(),t.lexXrpcQuery=e.z.object({type:e.z.literal("query"),description:e.z.string().optional(),parameters:t.lexXrpcParameters.optional(),output:t.lexXrpcBody.optional(),errors:t.lexXrpcError.array().optional()}).strict(),t.lexXrpcProcedure=e.z.object({type:e.z.literal("procedure"),description:e.z.string().optional(),parameters:t.lexXrpcParameters.optional(),input:t.lexXrpcBody.optional(),output:t.lexXrpcBody.optional(),errors:t.lexXrpcError.array().optional()}).strict(),t.lexXrpcSubscription=e.z.object({type:e.z.literal("subscription"),description:e.z.string().optional(),parameters:t.lexXrpcParameters.optional(),message:t.lexXrpcSubscriptionMessage.optional(),errors:t.lexXrpcError.array().optional()}).strict(),t.lexRecord=e.z.object({type:e.z.literal("record"),description:e.z.string().optional(),key:e.z.string().optional(),record:t.lexObject}).strict(),t.lexUserType=e.z.custom(f=>{if(!(!f||typeof f!="object")&&f.type!==void 0)switch(f.type){case"record":return t.lexRecord.parse(f);case"query":return t.lexXrpcQuery.parse(f);case"procedure":return t.lexXrpcProcedure.parse(f);case"subscription":return t.lexXrpcSubscription.parse(f);case"blob":return t.lexBlob.parse(f);case"array":return t.lexArray.parse(f);case"token":return t.lexToken.parse(f);case"object":return t.lexObject.parse(f);case"boolean":return t.lexBoolean.parse(f);case"integer":return t.lexInteger.parse(f);case"string":return t.lexString.parse(f);case"bytes":return t.lexBytes.parse(f);case"cid-link":return t.lexCidLink.parse(f);case"unknown":return t.lexUnknown.parse(f)}},f=>!f||typeof f!="object"?{message:"Must be an object",fatal:!0}:f.type===void 0?{message:"Must have a type",fatal:!0}:typeof f.type!="string"?{message:"Type property must be a string",fatal:!0}:{message:`Invalid type: ${f.type} must be one of: record, query, procedure, subscription, blob, array, token, object, boolean, integer, string, bytes, cid-link, unknown`,fatal:!0}),t.lexiconDoc=e.z.object({lexicon:e.z.literal(1),id:e.z.string().refine(f=>r.NSID.isValid(f),{message:"Must be a valid NSID"}),revision:e.z.number().optional(),description:e.z.string().optional(),defs:e.z.record(t.lexUserType)}).strict().superRefine((f,h)=>{for(const g in f.defs){const b=f.defs[g];g!=="main"&&(b.type==="record"||b.type==="procedure"||b.type==="query"||b.type==="subscription")&&h.addIssue({code:e.z.ZodIssueCode.custom,message:"Records, procedures, queries, and subscriptions must be the main definition."})}});function i(f){return t.lexiconDoc.safeParse(f).success}function o(f){return f!=null&&typeof f=="object"}function s(f){return o(f)&&"$type"in f&&typeof f.$type=="string"}function l(f){return t.lexiconDoc.parse(f),f}class u extends Error{}t.ValidationError=u;class c extends Error{}t.InvalidLexiconError=c;class d extends Error{}t.LexiconDefNotFoundError=d})(Uo);var Uy={},$s={},$o={},M0={},$y={},WF=ok,QR=128,JF=-128,ZF=Math.pow(2,31);function ok(t,e,r){e=e||[],r=r||0;for(var n=r;t>=ZF;)e[r++]=t&255|QR,t/=128;for(;t&JF;)e[r++]=t&255|QR,t>>>=7;return e[r]=t|0,ok.bytes=r-n+1,e}var QF=lv,YF=128,YR=127;function lv(t,n){var r=0,n=n||0,i=0,o=n,s,l=t.length;do{if(o>=l)throw lv.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&YR)<=YF);return lv.bytes=o-n,r}var eq=Math.pow(2,7),tq=Math.pow(2,14),rq=Math.pow(2,21),nq=Math.pow(2,28),iq=Math.pow(2,35),oq=Math.pow(2,42),sq=Math.pow(2,49),aq=Math.pow(2,56),lq=Math.pow(2,63),uq=function(t){return t[fh.decode(t,e),fh.decode.bytes],hh=(t,e,r=0)=>(fh.encode(t,e,r),e),yh=t=>fh.encodingLength(t),dq=(t,e)=>{const r=e.byteLength,n=yh(t),i=n+yh(r),o=new Uint8Array(i+r);return hh(t,o,0),hh(r,o,n),o.set(e,i),new N0(t,r,e,o)},pq=t=>{const e=u0(t),[r,n]=uv(e),[i,o]=uv(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new N0(r,i,s,e)},fq=(t,e)=>t===e?!0:t.code===e.code&&t.size===e.size&&HN(t.bytes,e.bytes);class N0{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const ci=Oc({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),hq=Oc({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),yq=Object.freeze(Object.defineProperty({__proto__:null,base58btc:ci,base58flickr:hq},Symbol.toStringTag,{value:"Module"})),Gu=Rt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mq=Rt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gq=Rt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),bq=Rt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),vq=Rt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Eq=Rt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),wq=Rt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),_q=Rt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xq=Rt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Rq=Object.freeze(Object.defineProperty({__proto__:null,base32:Gu,base32hex:vq,base32hexpad:wq,base32hexpadupper:_q,base32hexupper:Eq,base32pad:gq,base32padupper:bq,base32upper:mq,base32z:xq},Symbol.toStringTag,{value:"Module"}));class Tt{constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:zp,byteLength:zp,code:Np,version:Np,multihash:Np,bytes:Np,_baseCache:zp,asCID:zp})}toV0(){switch(this.version){case 0:return this;default:{const{code:e,multihash:r}=this;if(e!==Su)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Tq)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return Tt.createV0(r)}}}toV1(){switch(this.version){case 0:{const{code:e,digest:r}=this.multihash,n=dq(e,r);return Tt.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&fq(this.multihash,e.multihash)}toString(e){const{bytes:r,version:n,_baseCache:i}=this;switch(n){case 0:return Sq(r,i,e||ci.encoder);default:return Cq(r,i,e||Gu.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return Lq(/^0\.0/,Pq),!!(e&&(e[tA]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof Tt)return e;if(e!=null&&e.asCID===e){const{version:r,code:n,multihash:i,bytes:o}=e;return new Tt(r,n,i,o||eA(r,n,i.bytes))}else if(e!=null&&e[tA]===!0){const{version:r,multihash:n,code:i}=e,o=pq(n);return Tt.create(r,i,o)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(r!==Su)throw new Error(`Version 0 CID must use dag-pb (code: ${Su}) block encoding`);return new Tt(e,r,n,n.bytes)}case 1:{const i=eA(e,r,n.bytes);return new Tt(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return Tt.create(0,Su,e)}static createV1(e,r){return Tt.create(1,e,r)}static decode(e){const[r,n]=Tt.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){const r=Tt.inspectBytes(e),n=r.size-r.multihashSize,i=u0(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");const o=i.subarray(r.multihashSize-r.digestSize),s=new N0(r.multihashCode,r.digestSize,o,i);return[r.version===0?Tt.createV0(s):Tt.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0;const n=()=>{const[f,h]=uv(e.subarray(r));return r+=h,f};let i=n(),o=Su;if(i===18?(i=0,r=0):i===1&&(o=n()),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);const s=r,l=n(),u=n(),c=r+u,d=c-s;return{version:i,codec:o,multihashCode:l,digestSize:u,multihashSize:d,size:c}}static parse(e,r){const[n,i]=Aq(e,r),o=Tt.decode(i);return o._baseCache.set(n,e),o}}const Aq=(t,e)=>{switch(t[0]){case"Q":{const r=e||ci;return[ci.prefix,r.decode(`${ci.prefix}${t}`)]}case ci.prefix:{const r=e||ci;return[ci.prefix,r.decode(t)]}case Gu.prefix:{const r=e||Gu;return[Gu.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Sq=(t,e,r)=>{const{prefix:n}=r;if(n!==ci.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const i=e.get(n);if(i==null){const o=r.encode(t).slice(1);return e.set(n,o),o}else return i},Cq=(t,e,r)=>{const{prefix:n}=r,i=e.get(n);if(i==null){const o=r.encode(t);return e.set(n,o),o}else return i},Su=112,Tq=18,eA=(t,e,r)=>{const n=yh(t),i=n+yh(e),o=new Uint8Array(i+r.byteLength);return hh(t,o,0),hh(e,o,n),o.set(r,i),o},tA=Symbol.for("@ipld/js-cid/CID"),Np={writable:!1,configurable:!1,enumerable:!0},zp={writable:!1,enumerable:!1,configurable:!1},kq="0.0.0-dev",Lq=(t,e)=>{if(t.test(kq))console.warn(e);else throw new Error(e)},Pq=`CID.isCID(v) is deprecated and will be removed in the next major release. -Following code pattern: - -if (CID.isCID(value)) { - doSomethingWithCID(value) -} - -Is replaced with: - -const cid = CID.asCID(value) -if (cid) { - // Make sure to use cid instead of value - doSomethingWithCID(cid) -} -`,Dq=Object.freeze(Object.defineProperty({__proto__:null,CID:Tt},Symbol.toStringTag,{value:"Module"})),ll=bh(Dq);var Nn={},Cn={};Object.defineProperty(Cn,"__esModule",{value:!0});Cn.isObject=Cn.assure=Cn.create=Cn.is=void 0;const Bq=(t,e)=>e.safeParse(t).success;Cn.is=Bq;const Iq=t=>e=>t.safeParse(e).success;Cn.create=Iq;const jq=(t,e)=>t.parse(e);Cn.assure=jq;const Uq=t=>typeof t=="object"&&t!==null;Cn.isObject=Uq;var ja={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.parseIntWithFallback=t.dedupeStrs=t.range=t.chunkArray=t.errHasMsg=t.isErrnoException=t.asyncFilter=t.s32decode=t.s32encode=t.streamToBuffer=t.flattenUint8Arrays=t.bailableWait=t.wait=t.jitter=t.noUndefinedVals=void 0,t.omit=r;const e=m=>(Object.keys(m).forEach(E=>{m[E]===void 0&&delete m[E]}),m);t.noUndefinedVals=e;function r(m,E){if(!m)return m;const A={},L=Object.keys(m);for(let D=0;DMath.round((Math.random()-.5)*m*2);t.jitter=n;const i=m=>new Promise(E=>setTimeout(E,m));t.wait=i;const o=m=>{let E;const A=new Promise(L=>{const D=setTimeout(L,m);E=()=>{clearTimeout(D),L()}});return{bail:E,wait:()=>A}};t.bailableWait=o;const s=m=>{const E=m.reduce((D,B)=>D+B.length,0),A=new Uint8Array(E);let L=0;return m.forEach(D=>{A.set(D,L),L+=D.length}),A};t.flattenUint8Arrays=s;const l=async m=>{const E=[];for await(const A of m)E.push(A);return(0,t.flattenUint8Arrays)(E)};t.streamToBuffer=l;const u="234567abcdefghijklmnopqrstuvwxyz",c=m=>{let E="";for(;m;){const A=m%32;m=Math.floor(m/32),E=u.charAt(A)+E}return E};t.s32encode=c;const d=m=>{let E=0;for(const A of m)E=E*32+u.indexOf(A);return E};t.s32decode=d;const f=async(m,E)=>{const A=await Promise.all(m.map(L=>E(L)));return m.filter((L,D)=>A[D])};t.asyncFilter=f;const h=m=>!!m&&m.code;t.isErrnoException=h;const g=(m,E)=>!!m&&typeof m=="object"&&m.message===E;t.errHasMsg=g;const b=(m,E)=>m.reduce((A,L,D)=>{const B=Math.floor(D/E);return A[B]||(A[B]=[]),A[B].push(L),A},[]);t.chunkArray=b;const w=m=>{const E=[];for(let A=0;A[...new Set(m)];t.dedupeStrs=C;const y=(m,E)=>{const A=parseInt(m||"",10);return isNaN(A)?E:A};t.parseIntWithFallback=y})(ja);var Rd={};Object.defineProperty(Rd,"__esModule",{value:!0});Rd.mapDefined=void 0;Rd.keyBy=$q;function $q(t,e){return t.reduce((r,n)=>(r.set(n[e],n),r),new Map)}const Oq=(t,e)=>{const r=[];for(const n of t){const i=e(n);i!==void 0&&r.push(i)}return r};Rd.mapDefined=Oq;var sk={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncBufferFullError=t.AsyncBuffer=t.allComplete=t.createDeferrables=t.createDeferrable=t.readFromGenerator=void 0,t.allFulfilled=u,t.handleAllSettledErrors=c,t.isRejectedResult=d,t.isFulfilledResult=h;const e=ja,r=async(w,C,y=Promise.resolve(),m=Number.MAX_SAFE_INTEGER)=>{const E=[];let A,L=!1;const D=async()=>{if(await C(E.at(-1)))return!0;const j=(0,e.bailableWait)(20);return await j.wait(),A=j.bail,L?!1:await D()},B=new Promise(j=>{y.then(()=>{D().then(()=>j())})});try{for(;E.length{let w;const C=new Promise(y=>{w=()=>y()});return{resolve:w,complete:C}};t.createDeferrable=n;const i=w=>{const C=[];for(let y=0;y{await Promise.all(w.map(C=>C.complete))};t.allComplete=o;class s{constructor(C){Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:C}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"promise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"resolve",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"closed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"toThrow",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.promise=Promise.resolve(),this.resolve=()=>null,this.resetPromise()}get curr(){return this.buffer}get size(){return this.buffer.length}get isClosed(){return this.closed}resetPromise(){this.promise=new Promise(C=>this.resolve=C)}push(C){this.buffer.push(C),this.resolve()}pushMany(C){C.forEach(y=>this.buffer.push(y)),this.resolve()}async*events(){for(;;){if(this.closed&&this.buffer.length===0){if(this.toThrow)throw this.toThrow;return}if(await this.promise,this.toThrow)throw this.toThrow;if(this.maxSize&&this.size>this.maxSize)throw new l(this.maxSize);const[C,...y]=this.buffer;C?(this.buffer=y,yield C):this.resetPromise()}}throw(C){this.toThrow=C,this.closed=!0,this.resolve()}close(){this.closed=!0,this.resolve()}}t.AsyncBuffer=s;class l extends Error{constructor(C){super(`ReachedMaxBufferSize: ${C}`)}}t.AsyncBufferFullError=l;function u(w){return Promise.allSettled(w).then(c)}function c(w){const C=w.filter(d).map(f);if(C.length===0)return w.map(g);throw C.length===1?C[0]:new AggregateError(C,`Multiple errors: ${C.map(b).join(` -`)}`)}function d(w){return w.status==="rejected"}function f(w){return w.reason}function h(w){return w.status==="fulfilled"}function g(w){return w.value}function b(w){return w instanceof Error?w.message:String(w)}})(sk);var Oy={};Object.defineProperty(Oy,"__esModule",{value:!0});Oy.TID=void 0;const Fp=ja,rA=13;let Ug=0,nA=0,qp=null;function iA(t){return t.replaceAll("-","")}class Hi{constructor(e){Object.defineProperty(this,"str",{enumerable:!0,configurable:!0,writable:!0,value:void 0});const r=iA(e);if(r.length!==rA)throw new Error(`Poorly formatted TID: ${r.length} length`);this.str=r}static next(e){const r=Math.max(Date.now(),Ug);r===Ug&&nA++,Ug=r;const n=r*1e3+nA;qp===null&&(qp=Math.floor(Math.random()*32));const i=Hi.fromTime(n,qp);return!e||i.newerThan(e)?i:Hi.fromTime(e.timestamp()+1,qp)}static nextStr(e){return Hi.next(e?new Hi(e):void 0).toString()}static fromTime(e,r){const n=`${(0,Fp.s32encode)(e)}${(0,Fp.s32encode)(r).padStart(2,"2")}`;return new Hi(n)}static fromStr(e){return new Hi(e)}static oldestFirst(e,r){return e.compareTo(r)}static newestFirst(e,r){return r.compareTo(e)}static is(e){return iA(e).length===rA}timestamp(){return(0,Fp.s32decode)(this.str.slice(0,11))}clockid(){return(0,Fp.s32decode)(this.str.slice(11,13))}formatted(){const e=this.toString();return`${e.slice(0,4)}-${e.slice(4,7)}-${e.slice(7,11)}-${e.slice(11,13)}`}toString(){return this.str}compareTo(e){return this.str>e.str?1:this.str0}olderThan(e){return this.compareTo(e)<0}}Oy.TID=Hi;var ak={};function Kq(t,e){for(let r=0;re[r])return 1}return t.byteLength>e.byteLength?1:t.byteLengthi+o.length,0));const r=new Uint8Array(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function Mq(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;rWN(t),decode:t=>XN(t)}),zq=Object.freeze(Object.defineProperty({__proto__:null,identity:Nq},Symbol.toStringTag,{value:"Module"})),Fq=Rt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),qq=Object.freeze(Object.defineProperty({__proto__:null,base2:Fq},Symbol.toStringTag,{value:"Module"})),Gq=Rt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Hq=Object.freeze(Object.defineProperty({__proto__:null,base8:Gq},Symbol.toStringTag,{value:"Module"})),Xq=Oc({prefix:"9",name:"base10",alphabet:"0123456789"}),Wq=Object.freeze(Object.defineProperty({__proto__:null,base10:Xq},Symbol.toStringTag,{value:"Module"})),Jq=Rt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Zq=Rt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Qq=Object.freeze(Object.defineProperty({__proto__:null,base16:Jq,base16upper:Zq},Symbol.toStringTag,{value:"Module"})),Yq=Oc({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),eG=Oc({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),tG=Object.freeze(Object.defineProperty({__proto__:null,base36:Yq,base36upper:eG},Symbol.toStringTag,{value:"Module"})),lk=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),rG=lk.reduce((t,e,r)=>(t[r]=e,t),[]),nG=lk.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function iG(t){return t.reduce((e,r)=>(e+=rG[r],e),"")}function oG(t){const e=[];for(const r of t){const n=nG[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const sG=Mh({prefix:"🚀",name:"base256emoji",encode:iG,decode:oG}),aG=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:sG},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const oA={...zq,...qq,...Hq,...Wq,...Qq,...Rq,...tG,...yq,...cC,...aG};function uk(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const sA=uk("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),$g=uk("ascii","a",t=>{let e="a";for(let r=0;r{t=t.substring(1);const e=new Uint8Array(t.length);for(let r=0;r{if(Array.isArray(c))return c.map(d=>(0,t.jsonToIpld)(d));if(c&&typeof c=="object"){if(typeof c.$link=="string"&&Object.keys(c).length===1)return i.CID.parse(c.$link);if(typeof c.$bytes=="string"&&Object.keys(c).length===1)return o.fromString(c.$bytes,"base64");const d={};for(const f of Object.keys(c))d[f]=(0,t.jsonToIpld)(c[f]);return d}return c};t.jsonToIpld=s;const l=c=>{if(Array.isArray(c))return c.map(d=>(0,t.ipldToJson)(d));if(c&&typeof c=="object"){if(c instanceof Uint8Array)return{$bytes:o.toString(c,"base64")};if(i.CID.asCID(c))return{$link:c.toString()};const d={};for(const f of Object.keys(c))d[f]=(0,t.ipldToJson)(c[f]);return d}return c};t.ipldToJson=l;const u=(c,d)=>{var f;if(Array.isArray(c)&&Array.isArray(d)){if(c.length!==d.length)return!1;for(let h=0;h!0,getWaitMs:i=fk}=e;let o=0,s;for(;!s;)try{return await t()}catch(l){const u=i(o);opk(e,{...r,retryable:t})}function fk(t,e=100,r=1e3){const n=Math.pow(2,t)*e,i=Math.min(n,r);return hG(i)}function hG(t){const e=t*.15;return t+yG(-e,e)}function yG(t,e){return Math.random()*(e-t)+t}var hk={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.def=t.schema=void 0;const e=ll,r=G,n=r.z.unknown().transform((o,s)=>{const l=e.CID.asCID(o);return l??(s.addIssue({code:r.z.ZodIssueCode.custom,message:"Not a valid CID"}),r.z.NEVER)}),i=r.z.object({version:r.z.literal(1),roots:r.z.array(n)});t.schema={cid:n,carHeader:i,bytes:r.z.instanceof(Uint8Array),string:r.z.string(),array:r.z.array(r.z.unknown()),map:r.z.record(r.z.string(),r.z.unknown()),unknown:r.z.unknown()},t.def={cid:{name:"cid",schema:t.schema.cid},carHeader:{name:"CAR header",schema:t.schema.carHeader},bytes:{name:"bytes",schema:t.schema.bytes},string:{name:"string",schema:t.schema.string},map:{name:"map",schema:t.schema.map},unknown:{name:"unknown",schema:t.schema.unknown}}})(hk);var yk={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.addHoursToDate=t.lessThanAgoMs=t.DAY=t.HOUR=t.MINUTE=t.SECOND=void 0,t.SECOND=1e3,t.MINUTE=t.SECOND*60,t.HOUR=t.MINUTE*60,t.DAY=t.HOUR*24;const e=(n,i)=>Date.now(){const o=i?new Date(i):new Date;return o.setHours(o.getHours()+n),o};t.addHoursToDate=r})(yk);var er={},z0={},F0={},q0={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.EXTENDED_PICTOGRAPHIC=t.CLUSTER_BREAK=void 0,function(e){e[e.CR=0]="CR",e[e.LF=1]="LF",e[e.CONTROL=2]="CONTROL",e[e.EXTEND=3]="EXTEND",e[e.REGIONAL_INDICATOR=4]="REGIONAL_INDICATOR",e[e.SPACINGMARK=5]="SPACINGMARK",e[e.L=6]="L",e[e.V=7]="V",e[e.T=8]="T",e[e.LV=9]="LV",e[e.LVT=10]="LVT",e[e.OTHER=11]="OTHER",e[e.PREPEND=12]="PREPEND",e[e.E_BASE=13]="E_BASE",e[e.E_MODIFIER=14]="E_MODIFIER",e[e.ZWJ=15]="ZWJ",e[e.GLUE_AFTER_ZWJ=16]="GLUE_AFTER_ZWJ",e[e.E_BASE_GAZ=17]="E_BASE_GAZ"}(t.CLUSTER_BREAK||(t.CLUSTER_BREAK={})),t.EXTENDED_PICTOGRAPHIC=101})(q0);var G0={};Object.defineProperty(G0,"__esModule",{value:!0});const fe=q0,ri=0,Og=1,mG=2,gG=3,bG=4;class vG{static isSurrogate(e,r){return 55296<=e.charCodeAt(r)&&e.charCodeAt(r)<=56319&&56320<=e.charCodeAt(r+1)&&e.charCodeAt(r+1)<=57343}static codePointAt(e,r){r===void 0&&(r=0);const n=e.charCodeAt(r);if(55296<=n&&n<=56319&&r=1){const i=e.charCodeAt(r-1),o=n;return 55296<=i&&i<=56319?(i-55296)*1024+(o-56320)+65536:o}return n}static shouldBreak(e,r,n,i,o,s){const l=[e].concat(r).concat([n]),u=[i].concat(o).concat([s]),c=l[l.length-2],d=n,f=s,h=l.lastIndexOf(fe.CLUSTER_BREAK.REGIONAL_INDICATOR);if(h>0&&l.slice(1,h).every(function(b){return b===fe.CLUSTER_BREAK.REGIONAL_INDICATOR})&&[fe.CLUSTER_BREAK.PREPEND,fe.CLUSTER_BREAK.REGIONAL_INDICATOR].indexOf(c)===-1)return l.filter(function(b){return b===fe.CLUSTER_BREAK.REGIONAL_INDICATOR}).length%2===1?gG:bG;if(c===fe.CLUSTER_BREAK.CR&&d===fe.CLUSTER_BREAK.LF)return ri;if(c===fe.CLUSTER_BREAK.CONTROL||c===fe.CLUSTER_BREAK.CR||c===fe.CLUSTER_BREAK.LF)return Og;if(d===fe.CLUSTER_BREAK.CONTROL||d===fe.CLUSTER_BREAK.CR||d===fe.CLUSTER_BREAK.LF)return Og;if(c===fe.CLUSTER_BREAK.L&&(d===fe.CLUSTER_BREAK.L||d===fe.CLUSTER_BREAK.V||d===fe.CLUSTER_BREAK.LV||d===fe.CLUSTER_BREAK.LVT))return ri;if((c===fe.CLUSTER_BREAK.LV||c===fe.CLUSTER_BREAK.V)&&(d===fe.CLUSTER_BREAK.V||d===fe.CLUSTER_BREAK.T))return ri;if((c===fe.CLUSTER_BREAK.LVT||c===fe.CLUSTER_BREAK.T)&&d===fe.CLUSTER_BREAK.T)return ri;if(d===fe.CLUSTER_BREAK.EXTEND||d===fe.CLUSTER_BREAK.ZWJ)return ri;if(d===fe.CLUSTER_BREAK.SPACINGMARK)return ri;if(c===fe.CLUSTER_BREAK.PREPEND)return ri;const g=u.slice(0,-1).lastIndexOf(fe.EXTENDED_PICTOGRAPHIC);return g!==-1&&u[g]===fe.EXTENDED_PICTOGRAPHIC&&l.slice(g+1,-2).every(function(b){return b===fe.CLUSTER_BREAK.EXTEND})&&c===fe.CLUSTER_BREAK.ZWJ&&f===fe.EXTENDED_PICTOGRAPHIC?ri:r.indexOf(fe.CLUSTER_BREAK.REGIONAL_INDICATOR)!==-1?mG:c===fe.CLUSTER_BREAK.REGIONAL_INDICATOR&&d===fe.CLUSTER_BREAK.REGIONAL_INDICATOR?ri:Og}}G0.default=vG;var H0={};Object.defineProperty(H0,"__esModule",{value:!0});class EG{constructor(e,r){this._index=0,this._str=e,this._nextBreak=r}[Symbol.iterator](){return this}next(){let e;if((e=this._nextBreak(this._str,this._index))=e.length-1)return e.length;const n=Gp.default.codePointAt(e,r),i=ai.getGraphemeBreakProperty(n),o=ai.getEmojiProperty(n),s=[],l=[];for(let u=r+1;unew TextEncoder().encode(t).byteLength;er.utf8Len=kG;const LG=t=>new TG.default().countGraphemes(t);er.graphemeLen=LG;const PG=t=>mh.toString(mh.fromString(t,"utf8"),"base64url");er.utf8ToB64Url=PG;const DG=t=>mh.toString(mh.fromString(t,"base64url"),"utf8");er.b64UrlToUtf8=DG;const BG=t=>{const e=t.match(gk);if(!(e!=null&&e.groups))return null;const r=e.groups;return{grandfathered:r.grandfathered,language:r.language,extlang:r.extlang,script:r.script,region:r.region,variant:r.variant,extension:r.extension,privateUse:r.privateUseA||r.privateUseB}};er.parseLanguage=BG;const IG=t=>gk.test(t);er.validateLanguage=IG;const gk=/^((?(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?([A-Za-z]{2,3}(-(?[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?