@opensecret/react 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -0
- package/dist/opensecret-react.es.js +15182 -0
- package/dist/opensecret-react.umd.js +154 -0
- package/package.json +52 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
(function(Je,Xe){typeof exports=="object"&&typeof module<"u"?Xe(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],Xe):(Je=typeof globalThis<"u"?globalThis:Je||self,Xe(Je.OpenSecretReact={},Je.React))})(this,function(Je,Xe){"use strict";var W1=Object.defineProperty;var Dy=Je=>{throw TypeError(Je)};var q1=(Je,Xe,Bt)=>Xe in Je?W1(Je,Xe,{enumerable:!0,configurable:!0,writable:!0,value:Bt}):Je[Xe]=Bt;var Ge=(Je,Xe,Bt)=>q1(Je,typeof Xe!="symbol"?Xe+"":Xe,Bt),wf=(Je,Xe,Bt)=>Xe.has(Je)||Dy("Cannot "+Bt);var M=(Je,Xe,Bt)=>(wf(Je,Xe,"read from private field"),Bt?Bt.call(Je):Xe.get(Je)),or=(Je,Xe,Bt)=>Xe.has(Je)?Dy("Cannot add the same private member more than once"):Xe instanceof WeakSet?Xe.add(Je):Xe.set(Je,Bt),Nt=(Je,Xe,Bt,Ki)=>(wf(Je,Xe,"write to private field"),Ki?Ki.call(Je,Bt):Xe.set(Je,Bt),Bt),Pe=(Je,Xe,Bt)=>(wf(Je,Xe,"access private method"),Bt);var $y=(Je,Xe,Bt,Ki)=>({set _(Rc){Nt(Je,Xe,Rc,Bt)},get _(){return M(Je,Xe,Ki)}});var Co,Pn,un,ni,Jt,Ar,Dt,ii,et,zi,jc,bf,vn,mn,kr,qr,Xt,Ur,Qt,Zi,xf,To,fn,fr,hn,Nc,Ly,Py,Uy;var Bt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ki(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Rc(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}var Pc={exports:{}},Es={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Af;function Hy(){if(Af)return Es;Af=1;var r=Xe,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(c,u,d){var x,I={},J=null,j=null;d!==void 0&&(J=""+d),u.key!==void 0&&(J=""+u.key),u.ref!==void 0&&(j=u.ref);for(x in u)n.call(u,x)&&!s.hasOwnProperty(x)&&(I[x]=u[x]);if(c&&c.defaultProps)for(x in u=c.defaultProps,u)I[x]===void 0&&(I[x]=u[x]);return{$$typeof:e,type:c,key:J,ref:j,props:I,_owner:i.current}}return Es.Fragment=t,Es.jsx=a,Es.jsxs=a,Es}var Is={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var _f;function Fy(){return _f||(_f=1,process.env.NODE_ENV!=="production"&&function(){var r=Xe,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),j=Symbol.for("react.offscreen"),w=Symbol.iterator,A="@@iterator";function C(h){if(h===null||typeof h!="object")return null;var m=w&&h[w]||h[A];return typeof m=="function"?m:null}var k=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function P(h){{for(var m=arguments.length,S=new Array(m>1?m-1:0),N=1;N<m;N++)S[N-1]=arguments[N];$("error",h,S)}}function $(h,m,S){{var N=k.ReactDebugCurrentFrame,K=N.getStackAddendum();K!==""&&(m+="%s",S=S.concat([K]));var F=S.map(function(fe){return String(fe)});F.unshift("Warning: "+m),Function.prototype.apply.call(console[h],console,F)}}var Ae=!1,tt=!1,Ze=!1,Re=!1,Ke=!1,ft;ft=Symbol.for("react.module.reference");function ht(h){return!!(typeof h=="string"||typeof h=="function"||h===n||h===s||Ke||h===i||h===d||h===x||Re||h===j||Ae||tt||Ze||typeof h=="object"&&h!==null&&(h.$$typeof===J||h.$$typeof===I||h.$$typeof===a||h.$$typeof===c||h.$$typeof===u||h.$$typeof===ft||h.getModuleId!==void 0))}function _t(h,m,S){var N=h.displayName;if(N)return N;var K=m.displayName||m.name||"";return K!==""?S+"("+K+")":S}function St(h){return h.displayName||"Context"}function ct(h){if(h==null)return null;if(typeof h.tag=="number"&&P("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof h=="function")return h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case n:return"Fragment";case t:return"Portal";case s:return"Profiler";case i:return"StrictMode";case d:return"Suspense";case x:return"SuspenseList"}if(typeof h=="object")switch(h.$$typeof){case c:var m=h;return St(m)+".Consumer";case a:var S=h;return St(S._context)+".Provider";case u:return _t(h,h.render,"ForwardRef");case I:var N=h.displayName||null;return N!==null?N:ct(h.type)||"Memo";case J:{var K=h,F=K._payload,fe=K._init;try{return ct(fe(F))}catch{return null}}}return null}var pt=Object.assign,qe=0,He,se,Ce,dt,It,kt,ce;function Qe(){}Qe.__reactDisabledLog=!0;function yt(){{if(qe===0){He=console.log,se=console.info,Ce=console.warn,dt=console.error,It=console.group,kt=console.groupCollapsed,ce=console.groupEnd;var h={configurable:!0,enumerable:!0,value:Qe,writable:!0};Object.defineProperties(console,{info:h,log:h,warn:h,error:h,group:h,groupCollapsed:h,groupEnd:h})}qe++}}function Q(){{if(qe--,qe===0){var h={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:pt({},h,{value:He}),info:pt({},h,{value:se}),warn:pt({},h,{value:Ce}),error:pt({},h,{value:dt}),group:pt({},h,{value:It}),groupCollapsed:pt({},h,{value:kt}),groupEnd:pt({},h,{value:ce})})}qe<0&&P("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var st=k.ReactCurrentDispatcher,Ct;function dn(h,m,S){{if(Ct===void 0)try{throw Error()}catch(K){var N=K.stack.trim().match(/\n( *(at )?)/);Ct=N&&N[1]||""}return`
|
|
18
|
+
`+Ct+h}}var pn=!1,Ht;{var Mi=typeof WeakMap=="function"?WeakMap:Map;Ht=new Mi}function Dr(h,m){if(!h||pn)return"";{var S=Ht.get(h);if(S!==void 0)return S}var N;pn=!0;var K=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var F;F=st.current,st.current=null,yt();try{if(m){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(be){N=be}Reflect.construct(h,[],fe)}else{try{fe.call()}catch(be){N=be}h.call(fe.prototype)}}else{try{throw Error()}catch(be){N=be}h()}}catch(be){if(be&&N&&typeof be.stack=="string"){for(var L=be.stack.split(`
|
|
19
|
+
`),ge=N.stack.split(`
|
|
20
|
+
`),he=L.length-1,ve=ge.length-1;he>=1&&ve>=0&&L[he]!==ge[ve];)ve--;for(;he>=1&&ve>=0;he--,ve--)if(L[he]!==ge[ve]){if(he!==1||ve!==1)do if(he--,ve--,ve<0||L[he]!==ge[ve]){var Ee=`
|
|
21
|
+
`+L[he].replace(" at new "," at ");return h.displayName&&Ee.includes("<anonymous>")&&(Ee=Ee.replace("<anonymous>",h.displayName)),typeof h=="function"&&Ht.set(h,Ee),Ee}while(he>=1&&ve>=0);break}}}finally{pn=!1,st.current=F,Q(),Error.prepareStackTrace=K}var Ie=h?h.displayName||h.name:"",ke=Ie?dn(Ie):"";return typeof h=="function"&&Ht.set(h,ke),ke}function Vi(h,m,S){return Dr(h,!1)}function Bo(h){var m=h.prototype;return!!(m&&m.isReactComponent)}function yn(h,m,S){if(h==null)return"";if(typeof h=="function")return Dr(h,Bo(h));if(typeof h=="string")return dn(h);switch(h){case d:return dn("Suspense");case x:return dn("SuspenseList")}if(typeof h=="object")switch(h.$$typeof){case u:return Vi(h.render);case I:return yn(h.type,m,S);case J:{var N=h,K=N._payload,F=N._init;try{return yn(F(K),m,S)}catch{}}}return""}var gn=Object.prototype.hasOwnProperty,oi={},ai=k.ReactDebugCurrentFrame;function hr(h){if(h){var m=h._owner,S=yn(h.type,h._source,m?m.type:null);ai.setExtraStackFrame(S)}else ai.setExtraStackFrame(null)}function Un(h,m,S,N,K){{var F=Function.call.bind(gn);for(var fe in h)if(F(h,fe)){var L=void 0;try{if(typeof h[fe]!="function"){var ge=Error((N||"React class")+": "+S+" type `"+fe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof h[fe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ge.name="Invariant Violation",ge}L=h[fe](m,fe,N,S,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(he){L=he}L&&!(L instanceof Error)&&(hr(K),P("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",N||"React class",S,fe,typeof L),hr(null)),L instanceof Error&&!(L.message in oi)&&(oi[L.message]=!0,hr(K),P("Failed %s type: %s",S,L.message),hr(null))}}}var ci=Array.isArray;function Dn(h){return ci(h)}function Li(h){{var m=typeof Symbol=="function"&&Symbol.toStringTag,S=m&&h[Symbol.toStringTag]||h.constructor.name||"Object";return S}}function li(h){try{return ui(h),!1}catch{return!0}}function ui(h){return""+h}function Cr(h){if(li(h))return P("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Li(h)),ui(h)}var Yr=k.ReactCurrentOwner,Hi={key:!0,ref:!0,__self:!0,__source:!0},Fi,fi,E;E={};function B(h){if(gn.call(h,"ref")){var m=Object.getOwnPropertyDescriptor(h,"ref").get;if(m&&m.isReactWarning)return!1}return h.ref!==void 0}function R(h){if(gn.call(h,"key")){var m=Object.getOwnPropertyDescriptor(h,"key").get;if(m&&m.isReactWarning)return!1}return h.key!==void 0}function W(h,m){if(typeof h.ref=="string"&&Yr.current&&m&&Yr.current.stateNode!==m){var S=ct(Yr.current.type);E[S]||(P('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',ct(Yr.current.type),h.ref),E[S]=!0)}}function xe(h,m){{var S=function(){Fi||(Fi=!0,P("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",m))};S.isReactWarning=!0,Object.defineProperty(h,"key",{get:S,configurable:!0})}}function bt(h,m){{var S=function(){fi||(fi=!0,P("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",m))};S.isReactWarning=!0,Object.defineProperty(h,"ref",{get:S,configurable:!0})}}var xt=function(h,m,S,N,K,F,fe){var L={$$typeof:e,type:h,key:m,ref:S,props:fe,_owner:F};return L._store={},Object.defineProperty(L._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(L,"_self",{configurable:!1,enumerable:!1,writable:!1,value:N}),Object.defineProperty(L,"_source",{configurable:!1,enumerable:!1,writable:!1,value:K}),Object.freeze&&(Object.freeze(L.props),Object.freeze(L)),L};function Ne(h,m,S,N,K){{var F,fe={},L=null,ge=null;S!==void 0&&(Cr(S),L=""+S),R(m)&&(Cr(m.key),L=""+m.key),B(m)&&(ge=m.ref,W(m,K));for(F in m)gn.call(m,F)&&!Hi.hasOwnProperty(F)&&(fe[F]=m[F]);if(h&&h.defaultProps){var he=h.defaultProps;for(F in he)fe[F]===void 0&&(fe[F]=he[F])}if(L||ge){var ve=typeof h=="function"?h.displayName||h.name||"Unknown":h;L&&xe(fe,ve),ge&&bt(fe,ve)}return xt(h,L,ge,K,N,Yr.current,fe)}}var Y=k.ReactCurrentOwner,ee=k.ReactDebugCurrentFrame;function te(h){if(h){var m=h._owner,S=yn(h.type,h._source,m?m.type:null);ee.setExtraStackFrame(S)}else ee.setExtraStackFrame(null)}var pe;pe=!1;function De(h){return typeof h=="object"&&h!==null&&h.$$typeof===e}function Ye(){{if(Y.current){var h=ct(Y.current.type);if(h)return`
|
|
22
|
+
|
|
23
|
+
Check the render method of \``+h+"`."}return""}}function gt(h){return""}var $t={};function hi(h){{var m=Ye();if(!m){var S=typeof h=="string"?h:h.displayName||h.name;S&&(m=`
|
|
24
|
+
|
|
25
|
+
Check the top-level render call using <`+S+">.")}return m}}function di(h,m){{if(!h._store||h._store.validated||h.key!=null)return;h._store.validated=!0;var S=hi(m);if($t[S])return;$t[S]=!0;var N="";h&&h._owner&&h._owner!==Y.current&&(N=" It was passed a child from "+ct(h._owner.type)+"."),te(h),P('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',S,N),te(null)}}function Gi(h,m){{if(typeof h!="object")return;if(Dn(h))for(var S=0;S<h.length;S++){var N=h[S];De(N)&&di(N,m)}else if(De(h))h._store&&(h._store.validated=!0);else if(h){var K=C(h);if(typeof K=="function"&&K!==h.entries)for(var F=K.call(h),fe;!(fe=F.next()).done;)De(fe.value)&&di(fe.value,m)}}}function mf(h){{var m=h.type;if(m==null||typeof m=="string")return;var S;if(typeof m=="function")S=m.propTypes;else if(typeof m=="object"&&(m.$$typeof===u||m.$$typeof===I))S=m.propTypes;else return;if(S){var N=ct(m);Un(S,h.props,"prop",N,h)}else if(m.PropTypes!==void 0&&!pe){pe=!0;var K=ct(m);P("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",K||"Unknown")}typeof m.getDefaultProps=="function"&&!m.getDefaultProps.isReactClassApproved&&P("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function dr(h){{for(var m=Object.keys(h.props),S=0;S<m.length;S++){var N=m[S];if(N!=="children"&&N!=="key"){te(h),P("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",N),te(null);break}}h.ref!==null&&(te(h),P("Invalid attribute `ref` supplied to `React.Fragment`."),te(null))}}var Oo={};function l(h,m,S,N,K,F){{var fe=ht(h);if(!fe){var L="";(h===void 0||typeof h=="object"&&h!==null&&Object.keys(h).length===0)&&(L+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ge=gt();ge?L+=ge:L+=Ye();var he;h===null?he="null":Dn(h)?he="array":h!==void 0&&h.$$typeof===e?(he="<"+(ct(h.type)||"Unknown")+" />",L=" Did you accidentally export a JSX literal instead of a component?"):he=typeof h,P("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",he,L)}var ve=Ne(h,m,S,K,F);if(ve==null)return ve;if(fe){var Ee=m.children;if(Ee!==void 0)if(N)if(Dn(Ee)){for(var Ie=0;Ie<Ee.length;Ie++)Gi(Ee[Ie],h);Object.freeze&&Object.freeze(Ee)}else P("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Gi(Ee,h)}if(gn.call(m,"key")){var ke=ct(h),be=Object.keys(m).filter(function(ie){return ie!=="key"}),le=be.length>0?"{key: someKey, "+be.join(": ..., ")+": ...}":"{key: someKey}";if(!Oo[ke+le]){var _e=be.length>0?"{"+be.join(": ..., ")+": ...}":"{}";P(`A props object containing a "key" prop is being spread into JSX:
|
|
26
|
+
let props = %s;
|
|
27
|
+
<%s {...props} />
|
|
28
|
+
React keys must be passed directly to JSX without using spread:
|
|
29
|
+
let props = %s;
|
|
30
|
+
<%s key={someKey} {...props} />`,le,ke,_e,ke),Oo[ke+le]=!0}}return h===n?dr(ve):mf(ve),ve}}function y(h,m,S){return l(h,m,S,!0)}function p(h,m,S){return l(h,m,S,!1)}var o=p,v=y;Is.Fragment=n,Is.jsx=o,Is.jsxs=v}()),Is}process.env.NODE_ENV==="production"?Pc.exports=Hy():Pc.exports=Fy();var Gy=Pc.exports;function Zt(r,e=new Uint8Array(4),t=0){return e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}function Sf(r,e=new Uint8Array(8),t=0){return Zt(r>>>0,e,t),Zt(r/4294967296>>>0,e,t+4),e}function Br(r){for(let e=0;e<r.length;e++)r[e]=0;return r}const zy=20;function Zy(r,e,t){let n=1634760805,i=857760878,s=2036477234,a=1797285236,c=t[3]<<24|t[2]<<16|t[1]<<8|t[0],u=t[7]<<24|t[6]<<16|t[5]<<8|t[4],d=t[11]<<24|t[10]<<16|t[9]<<8|t[8],x=t[15]<<24|t[14]<<16|t[13]<<8|t[12],I=t[19]<<24|t[18]<<16|t[17]<<8|t[16],J=t[23]<<24|t[22]<<16|t[21]<<8|t[20],j=t[27]<<24|t[26]<<16|t[25]<<8|t[24],w=t[31]<<24|t[30]<<16|t[29]<<8|t[28],A=e[3]<<24|e[2]<<16|e[1]<<8|e[0],C=e[7]<<24|e[6]<<16|e[5]<<8|e[4],k=e[11]<<24|e[10]<<16|e[9]<<8|e[8],P=e[15]<<24|e[14]<<16|e[13]<<8|e[12],$=n,Ae=i,tt=s,Ze=a,Re=c,Ke=u,ft=d,ht=x,_t=I,St=J,ct=j,pt=w,qe=A,He=C,se=k,Ce=P;for(let dt=0;dt<zy;dt+=2)$=$+Re|0,qe^=$,qe=qe>>>16|qe<<16,_t=_t+qe|0,Re^=_t,Re=Re>>>20|Re<<12,Ae=Ae+Ke|0,He^=Ae,He=He>>>16|He<<16,St=St+He|0,Ke^=St,Ke=Ke>>>20|Ke<<12,tt=tt+ft|0,se^=tt,se=se>>>16|se<<16,ct=ct+se|0,ft^=ct,ft=ft>>>20|ft<<12,Ze=Ze+ht|0,Ce^=Ze,Ce=Ce>>>16|Ce<<16,pt=pt+Ce|0,ht^=pt,ht=ht>>>20|ht<<12,tt=tt+ft|0,se^=tt,se=se>>>24|se<<8,ct=ct+se|0,ft^=ct,ft=ft>>>25|ft<<7,Ze=Ze+ht|0,Ce^=Ze,Ce=Ce>>>24|Ce<<8,pt=pt+Ce|0,ht^=pt,ht=ht>>>25|ht<<7,Ae=Ae+Ke|0,He^=Ae,He=He>>>24|He<<8,St=St+He|0,Ke^=St,Ke=Ke>>>25|Ke<<7,$=$+Re|0,qe^=$,qe=qe>>>24|qe<<8,_t=_t+qe|0,Re^=_t,Re=Re>>>25|Re<<7,$=$+Ke|0,Ce^=$,Ce=Ce>>>16|Ce<<16,ct=ct+Ce|0,Ke^=ct,Ke=Ke>>>20|Ke<<12,Ae=Ae+ft|0,qe^=Ae,qe=qe>>>16|qe<<16,pt=pt+qe|0,ft^=pt,ft=ft>>>20|ft<<12,tt=tt+ht|0,He^=tt,He=He>>>16|He<<16,_t=_t+He|0,ht^=_t,ht=ht>>>20|ht<<12,Ze=Ze+Re|0,se^=Ze,se=se>>>16|se<<16,St=St+se|0,Re^=St,Re=Re>>>20|Re<<12,tt=tt+ht|0,He^=tt,He=He>>>24|He<<8,_t=_t+He|0,ht^=_t,ht=ht>>>25|ht<<7,Ze=Ze+Re|0,se^=Ze,se=se>>>24|se<<8,St=St+se|0,Re^=St,Re=Re>>>25|Re<<7,Ae=Ae+ft|0,qe^=Ae,qe=qe>>>24|qe<<8,pt=pt+qe|0,ft^=pt,ft=ft>>>25|ft<<7,$=$+Ke|0,Ce^=$,Ce=Ce>>>24|Ce<<8,ct=ct+Ce|0,Ke^=ct,Ke=Ke>>>25|Ke<<7;Zt($+n|0,r,0),Zt(Ae+i|0,r,4),Zt(tt+s|0,r,8),Zt(Ze+a|0,r,12),Zt(Re+c|0,r,16),Zt(Ke+u|0,r,20),Zt(ft+d|0,r,24),Zt(ht+x|0,r,28),Zt(_t+I|0,r,32),Zt(St+J|0,r,36),Zt(ct+j|0,r,40),Zt(pt+w|0,r,44),Zt(qe+A|0,r,48),Zt(He+C|0,r,52),Zt(se+k|0,r,56),Zt(Ce+P|0,r,60)}function Uc(r,e,t,n,i=0){if(r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<t.length)throw new Error("ChaCha: destination is shorter than source");let s,a;if(i===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),a=s.length-e.length,s.set(e,a)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,a=i}const c=new Uint8Array(64);for(let u=0;u<t.length;u+=64){Zy(c,s,r);for(let d=u;d<u+64&&d<t.length;d++)n[d]=t[d]^c[d-u];Ky(s,0,a)}return Br(c),i===0&&Br(s),n}function Ef(r,e,t,n=0){return Br(t),Uc(r,e,t,t,n)}function Ky(r,e,t){let n=1;for(;t--;)n=n+(r[e]&255)|0,r[e]=n&255,n>>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}function Wy(r,e){if(r.length!==e.length)return 0;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return 1&t-1>>>8}function qy(r,e){return r.length===0||e.length===0?!1:Wy(r,e)!==0}const Yy=16;class Jy{constructor(e){Ge(this,"digestLength",Yy);Ge(this,"_buffer",new Uint8Array(16));Ge(this,"_r",new Uint16Array(10));Ge(this,"_h",new Uint16Array(10));Ge(this,"_pad",new Uint16Array(8));Ge(this,"_leftover",0);Ge(this,"_fin",0);Ge(this,"_finished",!1);let t=e[0]|e[1]<<8;this._r[0]=t&8191;let n=e[2]|e[3]<<8;this._r[1]=(t>>>13|n<<3)&8191;let i=e[4]|e[5]<<8;this._r[2]=(n>>>10|i<<6)&7939;let s=e[6]|e[7]<<8;this._r[3]=(i>>>7|s<<9)&8191;let a=e[8]|e[9]<<8;this._r[4]=(s>>>4|a<<12)&255,this._r[5]=a>>>1&8190;let c=e[10]|e[11]<<8;this._r[6]=(a>>>14|c<<2)&8191;let u=e[12]|e[13]<<8;this._r[7]=(c>>>11|u<<5)&8065;let d=e[14]|e[15]<<8;this._r[8]=(u>>>8|d<<8)&8191,this._r[9]=d>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}_blocks(e,t,n){let i=this._fin?0:2048,s=this._h[0],a=this._h[1],c=this._h[2],u=this._h[3],d=this._h[4],x=this._h[5],I=this._h[6],J=this._h[7],j=this._h[8],w=this._h[9],A=this._r[0],C=this._r[1],k=this._r[2],P=this._r[3],$=this._r[4],Ae=this._r[5],tt=this._r[6],Ze=this._r[7],Re=this._r[8],Ke=this._r[9];for(;n>=16;){let ft=e[t+0]|e[t+1]<<8;s+=ft&8191;let ht=e[t+2]|e[t+3]<<8;a+=(ft>>>13|ht<<3)&8191;let _t=e[t+4]|e[t+5]<<8;c+=(ht>>>10|_t<<6)&8191;let St=e[t+6]|e[t+7]<<8;u+=(_t>>>7|St<<9)&8191;let ct=e[t+8]|e[t+9]<<8;d+=(St>>>4|ct<<12)&8191,x+=ct>>>1&8191;let pt=e[t+10]|e[t+11]<<8;I+=(ct>>>14|pt<<2)&8191;let qe=e[t+12]|e[t+13]<<8;J+=(pt>>>11|qe<<5)&8191;let He=e[t+14]|e[t+15]<<8;j+=(qe>>>8|He<<8)&8191,w+=He>>>5|i;let se=0,Ce=se;Ce+=s*A,Ce+=a*(5*Ke),Ce+=c*(5*Re),Ce+=u*(5*Ze),Ce+=d*(5*tt),se=Ce>>>13,Ce&=8191,Ce+=x*(5*Ae),Ce+=I*(5*$),Ce+=J*(5*P),Ce+=j*(5*k),Ce+=w*(5*C),se+=Ce>>>13,Ce&=8191;let dt=se;dt+=s*C,dt+=a*A,dt+=c*(5*Ke),dt+=u*(5*Re),dt+=d*(5*Ze),se=dt>>>13,dt&=8191,dt+=x*(5*tt),dt+=I*(5*Ae),dt+=J*(5*$),dt+=j*(5*P),dt+=w*(5*k),se+=dt>>>13,dt&=8191;let It=se;It+=s*k,It+=a*C,It+=c*A,It+=u*(5*Ke),It+=d*(5*Re),se=It>>>13,It&=8191,It+=x*(5*Ze),It+=I*(5*tt),It+=J*(5*Ae),It+=j*(5*$),It+=w*(5*P),se+=It>>>13,It&=8191;let kt=se;kt+=s*P,kt+=a*k,kt+=c*C,kt+=u*A,kt+=d*(5*Ke),se=kt>>>13,kt&=8191,kt+=x*(5*Re),kt+=I*(5*Ze),kt+=J*(5*tt),kt+=j*(5*Ae),kt+=w*(5*$),se+=kt>>>13,kt&=8191;let ce=se;ce+=s*$,ce+=a*P,ce+=c*k,ce+=u*C,ce+=d*A,se=ce>>>13,ce&=8191,ce+=x*(5*Ke),ce+=I*(5*Re),ce+=J*(5*Ze),ce+=j*(5*tt),ce+=w*(5*Ae),se+=ce>>>13,ce&=8191;let Qe=se;Qe+=s*Ae,Qe+=a*$,Qe+=c*P,Qe+=u*k,Qe+=d*C,se=Qe>>>13,Qe&=8191,Qe+=x*A,Qe+=I*(5*Ke),Qe+=J*(5*Re),Qe+=j*(5*Ze),Qe+=w*(5*tt),se+=Qe>>>13,Qe&=8191;let yt=se;yt+=s*tt,yt+=a*Ae,yt+=c*$,yt+=u*P,yt+=d*k,se=yt>>>13,yt&=8191,yt+=x*C,yt+=I*A,yt+=J*(5*Ke),yt+=j*(5*Re),yt+=w*(5*Ze),se+=yt>>>13,yt&=8191;let Q=se;Q+=s*Ze,Q+=a*tt,Q+=c*Ae,Q+=u*$,Q+=d*P,se=Q>>>13,Q&=8191,Q+=x*k,Q+=I*C,Q+=J*A,Q+=j*(5*Ke),Q+=w*(5*Re),se+=Q>>>13,Q&=8191;let st=se;st+=s*Re,st+=a*Ze,st+=c*tt,st+=u*Ae,st+=d*$,se=st>>>13,st&=8191,st+=x*P,st+=I*k,st+=J*C,st+=j*A,st+=w*(5*Ke),se+=st>>>13,st&=8191;let Ct=se;Ct+=s*Ke,Ct+=a*Re,Ct+=c*Ze,Ct+=u*tt,Ct+=d*Ae,se=Ct>>>13,Ct&=8191,Ct+=x*$,Ct+=I*P,Ct+=J*k,Ct+=j*C,Ct+=w*A,se+=Ct>>>13,Ct&=8191,se=(se<<2)+se|0,se=se+Ce|0,Ce=se&8191,se=se>>>13,dt+=se,s=Ce,a=dt,c=It,u=kt,d=ce,x=Qe,I=yt,J=Q,j=st,w=Ct,t+=16,n-=16}this._h[0]=s,this._h[1]=a,this._h[2]=c,this._h[3]=u,this._h[4]=d,this._h[5]=x,this._h[6]=I,this._h[7]=J,this._h[8]=j,this._h[9]=w}finish(e,t=0){const n=new Uint16Array(10);let i,s,a,c;if(this._leftover){for(c=this._leftover,this._buffer[c++]=1;c<16;c++)this._buffer[c]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(i=this._h[1]>>>13,this._h[1]&=8191,c=2;c<10;c++)this._h[c]+=i,i=this._h[c]>>>13,this._h[c]&=8191;for(this._h[0]+=i*5,i=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=i,i=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=i,n[0]=this._h[0]+5,i=n[0]>>>13,n[0]&=8191,c=1;c<10;c++)n[c]=this._h[c]+i,i=n[c]>>>13,n[c]&=8191;for(n[9]-=8192,s=(i^1)-1,c=0;c<10;c++)n[c]&=s;for(s=~s,c=0;c<10;c++)this._h[c]=this._h[c]&s|n[c];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,a=this._h[0]+this._pad[0],this._h[0]=a&65535,c=1;c<8;c++)a=(this._h[c]+this._pad[c]|0)+(a>>>16)|0,this._h[c]=a&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this}update(e){let t=0,n=e.length,i;if(this._leftover){i=16-this._leftover,i>n&&(i=n);for(let s=0;s<i;s++)this._buffer[this._leftover+s]=e[t+s];if(n-=i,t+=i,this._leftover+=i,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(n>=16&&(i=n-n%16,this._blocks(e,t,i),t+=i,n-=i),n){for(let s=0;s<n;s++)this._buffer[this._leftover+s]=e[t+s];this._leftover+=n}return this}digest(){if(this._finished)throw new Error("Poly1305 was finished");let e=new Uint8Array(16);return this.finish(e),e}clean(){return Br(this._buffer),Br(this._r),Br(this._h),Br(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this}}const Xy=32,Qy=12,e0=16,If=new Uint8Array(16);class Dc{constructor(e){Ge(this,"nonceLength",Qy);Ge(this,"tagLength",e0);Ge(this,"_key");if(e.length!==Xy)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}seal(e,t,n,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");const s=new Uint8Array(16);s.set(e,s.length-e.length);const a=new Uint8Array(32);Ef(this._key,s,a,4);const c=t.length+this.tagLength;let u;if(i){if(i.length!==c)throw new Error("ChaCha20Poly1305: incorrect destination length");u=i}else u=new Uint8Array(c);return Uc(this._key,s,t,u,4),this._authenticate(u.subarray(u.length-this.tagLength,u.length),a,u.subarray(0,u.length-this.tagLength),n),Br(s),u}open(e,t,n,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length<this.tagLength)return null;const s=new Uint8Array(16);s.set(e,s.length-e.length);const a=new Uint8Array(32);Ef(this._key,s,a,4);const c=new Uint8Array(this.tagLength);if(this._authenticate(c,a,t.subarray(0,t.length-this.tagLength),n),!qy(c,t.subarray(t.length-this.tagLength,t.length)))return null;const u=t.length-this.tagLength;let d;if(i){if(i.length!==u)throw new Error("ChaCha20Poly1305: incorrect destination length");d=i}else d=new Uint8Array(u);return Uc(this._key,s,t.subarray(0,t.length-this.tagLength),d,4),Br(s),d}clean(){return Br(this._key),this}_authenticate(e,t,n,i){const s=new Jy(t);i&&(s.update(i),i.length%16>0&&s.update(If.subarray(i.length%16))),s.update(n),n.length%16>0&&s.update(If.subarray(n.length%16));const a=new Uint8Array(8);i&&Sf(i.length,a),s.update(a),Sf(n.length,a),s.update(a);const c=s.digest();for(let u=0;u<c.length;u++)e[u]=c[u];s.clean(),Br(c),Br(a)}}const kf=65536;class t0{constructor(){Ge(this,"isAvailable",!1);Ge(this,"isInstantiated",!1);typeof crypto<"u"&&"getRandomValues"in crypto&&(this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");const t=new Uint8Array(e);for(let n=0;n<t.length;n+=kf)crypto.getRandomValues(t.subarray(n,n+Math.min(t.length-n,kf)));return t}}const r0=new t0;function n0(r,e=r0){return e.randomBytes(r)}const pr=256;class i0{constructor(e="="){Ge(this,"_paddingCharacter");this._paddingCharacter=e}encodedLength(e){return this._paddingCharacter?(e+2)/3*4|0:(e*8+5)/6|0}encode(e){let t="",n=0;for(;n<e.length-2;n+=3){let s=e[n]<<16|e[n+1]<<8|e[n+2];t+=this._encodeByte(s>>>3*6&63),t+=this._encodeByte(s>>>2*6&63),t+=this._encodeByte(s>>>1*6&63),t+=this._encodeByte(s>>>0*6&63)}const i=e.length-n;if(i>0){let s=e[n]<<16|(i===2?e[n+1]<<8:0);t+=this._encodeByte(s>>>3*6&63),t+=this._encodeByte(s>>>2*6&63),i===2?t+=this._encodeByte(s>>>1*6&63):t+=this._paddingCharacter||"",t+=this._paddingCharacter||""}return t}maxDecodedLength(e){return this._paddingCharacter?e/4*3|0:(e*6+7)/8|0}decodedLength(e){return this.maxDecodedLength(e.length-this._getPaddingLength(e))}decode(e){if(e.length===0)return new Uint8Array(0);const t=this._getPaddingLength(e),n=e.length-t,i=new Uint8Array(this.maxDecodedLength(n));let s=0,a=0,c=0,u=0,d=0,x=0,I=0;for(;a<n-4;a+=4)u=this._decodeChar(e.charCodeAt(a+0)),d=this._decodeChar(e.charCodeAt(a+1)),x=this._decodeChar(e.charCodeAt(a+2)),I=this._decodeChar(e.charCodeAt(a+3)),i[s++]=u<<2|d>>>4,i[s++]=d<<4|x>>>2,i[s++]=x<<6|I,c|=u&pr,c|=d&pr,c|=x&pr,c|=I≺if(a<n-1&&(u=this._decodeChar(e.charCodeAt(a)),d=this._decodeChar(e.charCodeAt(a+1)),i[s++]=u<<2|d>>>4,c|=u&pr,c|=d&pr),a<n-2&&(x=this._decodeChar(e.charCodeAt(a+2)),i[s++]=d<<4|x>>>2,c|=x&pr),a<n-3&&(I=this._decodeChar(e.charCodeAt(a+3)),i[s++]=x<<6|I,c|=I&pr),c!==0)throw new Error("Base64Coder: incorrect characters for decoding");return i}_encodeByte(e){let t=e;return t+=65,t+=25-e>>>8&6,t+=51-e>>>8&-75,t+=61-e>>>8&-15,t+=62-e>>>8&3,String.fromCharCode(t)}_decodeChar(e){let t=pr;return t+=(42-e&e-44)>>>8&-pr+e-43+62,t+=(46-e&e-48)>>>8&-pr+e-47+63,t+=(47-e&e-58)>>>8&-pr+e-48+52,t+=(64-e&e-91)>>>8&-pr+e-65+0,t+=(96-e&e-123)>>>8&-pr+e-97+26,t}_getPaddingLength(e){let t=0;if(this._paddingCharacter){for(let n=e.length-1;n>=0&&e[n]===this._paddingCharacter;n--)t++;if(e.length<4||t>2)throw new Error("Base64Coder: incorrect padding")}return t}}const Cf=new i0;function wn(r){return Cf.encode(r)}function No(r){return Cf.decode(r)}function s0(r,e){const t=new Dc(r),n=n0(12),s=new TextEncoder().encode(e),a=t.seal(n,s),c=new Uint8Array(n.length+a.length);return c.set(n),c.set(a,n.length),wn(c)}function o0(r,e){const t=new Dc(r),n=No(e),i=12,s=n.slice(0,i),a=n.slice(i),c=t.open(s,a);if(!c)throw new Error("Decryption failed");return new TextDecoder().decode(c)}/*! *****************************************************************************
|
|
31
|
+
Copyright (C) Microsoft. All rights reserved.
|
|
32
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
33
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
34
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
35
|
+
|
|
36
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
37
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
38
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
39
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
40
|
+
|
|
41
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
42
|
+
and limitations under the License.
|
|
43
|
+
***************************************************************************** */var Bf;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof Bt=="object"?Bt:typeof self=="object"?self:typeof this=="object"?this:c(),n=i(r);typeof t.Reflect<"u"&&(n=i(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function i(u,d){return function(x,I){Object.defineProperty(u,x,{configurable:!0,writable:!0,value:I}),d&&d(x,I)}}function s(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||a()}})(function(e,t){var n=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",u={__proto__:[]}instanceof Array,d=!c&&!u,x={create:c?function(){return fi(Object.create(null))}:u?function(){return fi({__proto__:null})}:function(){return fi({})},has:d?function(E,B){return n.call(E,B)}:function(E,B){return B in E},get:d?function(E,B){return n.call(E,B)?E[B]:void 0}:function(E,B){return E[B]}},I=Object.getPrototypeOf(Function),J=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Yr(),j=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Hi(),w=typeof WeakMap=="function"?WeakMap:Fi(),A=i?Symbol.for("@reflect-metadata:registry"):void 0,C=Li(),k=li(C);function P(E,B,R,W){if(ce(R)){if(!Mi(E))throw new TypeError;if(!Vi(B))throw new TypeError;return St(E,B)}else{if(!Mi(E))throw new TypeError;if(!Q(B))throw new TypeError;if(!Q(W)&&!ce(W)&&!Qe(W))throw new TypeError;return Qe(W)&&(W=void 0),R=Ht(R),ct(E,B,R,W)}}e("decorate",P);function $(E,B){function R(W,xe){if(!Q(W))throw new TypeError;if(!ce(xe)&&!Bo(xe))throw new TypeError;Ce(E,B,W,xe)}return R}e("metadata",$);function Ae(E,B,R,W){if(!Q(R))throw new TypeError;return ce(W)||(W=Ht(W)),Ce(E,B,R,W)}e("defineMetadata",Ae);function tt(E,B,R){if(!Q(B))throw new TypeError;return ce(R)||(R=Ht(R)),pt(E,B,R)}e("hasMetadata",tt);function Ze(E,B,R){if(!Q(B))throw new TypeError;return ce(R)||(R=Ht(R)),qe(E,B,R)}e("hasOwnMetadata",Ze);function Re(E,B,R){if(!Q(B))throw new TypeError;return ce(R)||(R=Ht(R)),He(E,B,R)}e("getMetadata",Re);function Ke(E,B,R){if(!Q(B))throw new TypeError;return ce(R)||(R=Ht(R)),se(E,B,R)}e("getOwnMetadata",Ke);function ft(E,B){if(!Q(E))throw new TypeError;return ce(B)||(B=Ht(B)),dt(E,B)}e("getMetadataKeys",ft);function ht(E,B){if(!Q(E))throw new TypeError;return ce(B)||(B=Ht(B)),It(E,B)}e("getOwnMetadataKeys",ht);function _t(E,B,R){if(!Q(B))throw new TypeError;if(ce(R)||(R=Ht(R)),!Q(B))throw new TypeError;ce(R)||(R=Ht(R));var W=Cr(B,R,!1);return ce(W)?!1:W.OrdinaryDeleteMetadata(E,B,R)}e("deleteMetadata",_t);function St(E,B){for(var R=E.length-1;R>=0;--R){var W=E[R],xe=W(B);if(!ce(xe)&&!Qe(xe)){if(!Vi(xe))throw new TypeError;B=xe}}return B}function ct(E,B,R,W){for(var xe=E.length-1;xe>=0;--xe){var bt=E[xe],xt=bt(B,R,W);if(!ce(xt)&&!Qe(xt)){if(!Q(xt))throw new TypeError;W=xt}}return W}function pt(E,B,R){var W=qe(E,B,R);if(W)return!0;var xe=ci(B);return Qe(xe)?!1:pt(E,xe,R)}function qe(E,B,R){var W=Cr(B,R,!1);return ce(W)?!1:dn(W.OrdinaryHasOwnMetadata(E,B,R))}function He(E,B,R){var W=qe(E,B,R);if(W)return se(E,B,R);var xe=ci(B);if(!Qe(xe))return He(E,xe,R)}function se(E,B,R){var W=Cr(B,R,!1);if(!ce(W))return W.OrdinaryGetOwnMetadata(E,B,R)}function Ce(E,B,R,W){var xe=Cr(R,W,!0);xe.OrdinaryDefineOwnMetadata(E,B,R,W)}function dt(E,B){var R=It(E,B),W=ci(E);if(W===null)return R;var xe=dt(W,B);if(xe.length<=0)return R;if(R.length<=0)return xe;for(var bt=new j,xt=[],Ne=0,Y=R;Ne<Y.length;Ne++){var ee=Y[Ne],te=bt.has(ee);te||(bt.add(ee),xt.push(ee))}for(var pe=0,De=xe;pe<De.length;pe++){var ee=De[pe],te=bt.has(ee);te||(bt.add(ee),xt.push(ee))}return xt}function It(E,B){var R=Cr(E,B,!1);return R?R.OrdinaryOwnMetadataKeys(E,B):[]}function kt(E){if(E===null)return 1;switch(typeof E){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return E===null?1:6;default:return 6}}function ce(E){return E===void 0}function Qe(E){return E===null}function yt(E){return typeof E=="symbol"}function Q(E){return typeof E=="object"?E!==null:typeof E=="function"}function st(E,B){switch(kt(E)){case 0:return E;case 1:return E;case 2:return E;case 3:return E;case 4:return E;case 5:return E}var R="string",W=gn(E,s);if(W!==void 0){var xe=W.call(E,R);if(Q(xe))throw new TypeError;return xe}return Ct(E)}function Ct(E,B){var R,W;{var xe=E.toString;if(Dr(xe)){var W=xe.call(E);if(!Q(W))return W}var R=E.valueOf;if(Dr(R)){var W=R.call(E);if(!Q(W))return W}}throw new TypeError}function dn(E){return!!E}function pn(E){return""+E}function Ht(E){var B=st(E);return yt(B)?B:pn(B)}function Mi(E){return Array.isArray?Array.isArray(E):E instanceof Object?E instanceof Array:Object.prototype.toString.call(E)==="[object Array]"}function Dr(E){return typeof E=="function"}function Vi(E){return typeof E=="function"}function Bo(E){switch(kt(E)){case 3:return!0;case 4:return!0;default:return!1}}function yn(E,B){return E===B||E!==E&&B!==B}function gn(E,B){var R=E[B];if(R!=null){if(!Dr(R))throw new TypeError;return R}}function oi(E){var B=gn(E,a);if(!Dr(B))throw new TypeError;var R=B.call(E);if(!Q(R))throw new TypeError;return R}function ai(E){return E.value}function hr(E){var B=E.next();return B.done?!1:B}function Un(E){var B=E.return;B&&B.call(E)}function ci(E){var B=Object.getPrototypeOf(E);if(typeof E!="function"||E===I||B!==I)return B;var R=E.prototype,W=R&&Object.getPrototypeOf(R);if(W==null||W===Object.prototype)return B;var xe=W.constructor;return typeof xe!="function"||xe===E?B:xe}function Dn(){var E;!ce(A)&&typeof t.Reflect<"u"&&!(A in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(E=ui(t.Reflect));var B,R,W,xe=new w,bt={registerProvider:xt,getProvider:Y,setProvider:te};return bt;function xt(pe){if(!Object.isExtensible(bt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case E===pe:break;case ce(B):B=pe;break;case B===pe:break;case ce(R):R=pe;break;case R===pe:break;default:W===void 0&&(W=new j),W.add(pe);break}}function Ne(pe,De){if(!ce(B)){if(B.isProviderFor(pe,De))return B;if(!ce(R)){if(R.isProviderFor(pe,De))return B;if(!ce(W))for(var Ye=oi(W);;){var gt=hr(Ye);if(!gt)return;var $t=ai(gt);if($t.isProviderFor(pe,De))return Un(Ye),$t}}}if(!ce(E)&&E.isProviderFor(pe,De))return E}function Y(pe,De){var Ye=xe.get(pe),gt;return ce(Ye)||(gt=Ye.get(De)),ce(gt)&&(gt=Ne(pe,De),ce(gt)||(ce(Ye)&&(Ye=new J,xe.set(pe,Ye)),Ye.set(De,gt))),gt}function ee(pe){if(ce(pe))throw new TypeError;return B===pe||R===pe||!ce(W)&&W.has(pe)}function te(pe,De,Ye){if(!ee(Ye))throw new Error("Metadata provider not registered.");var gt=Y(pe,De);if(gt!==Ye){if(!ce(gt))return!1;var $t=xe.get(pe);ce($t)&&($t=new J,xe.set(pe,$t)),$t.set(De,Ye)}return!0}}function Li(){var E;return!ce(A)&&Q(t.Reflect)&&Object.isExtensible(t.Reflect)&&(E=t.Reflect[A]),ce(E)&&(E=Dn()),!ce(A)&&Q(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,A,{enumerable:!1,configurable:!1,writable:!1,value:E}),E}function li(E){var B=new w,R={isProviderFor:function(ee,te){var pe=B.get(ee);return ce(pe)?!1:pe.has(te)},OrdinaryDefineOwnMetadata:xt,OrdinaryHasOwnMetadata:xe,OrdinaryGetOwnMetadata:bt,OrdinaryOwnMetadataKeys:Ne,OrdinaryDeleteMetadata:Y};return C.registerProvider(R),R;function W(ee,te,pe){var De=B.get(ee),Ye=!1;if(ce(De)){if(!pe)return;De=new J,B.set(ee,De),Ye=!0}var gt=De.get(te);if(ce(gt)){if(!pe)return;if(gt=new J,De.set(te,gt),!E.setProvider(ee,te,R))throw De.delete(te),Ye&&B.delete(ee),new Error("Wrong provider for target.")}return gt}function xe(ee,te,pe){var De=W(te,pe,!1);return ce(De)?!1:dn(De.has(ee))}function bt(ee,te,pe){var De=W(te,pe,!1);if(!ce(De))return De.get(ee)}function xt(ee,te,pe,De){var Ye=W(pe,De,!0);Ye.set(ee,te)}function Ne(ee,te){var pe=[],De=W(ee,te,!1);if(ce(De))return pe;for(var Ye=De.keys(),gt=oi(Ye),$t=0;;){var hi=hr(gt);if(!hi)return pe.length=$t,pe;var di=ai(hi);try{pe[$t]=di}catch(Gi){try{Un(gt)}finally{throw Gi}}$t++}}function Y(ee,te,pe){var De=W(te,pe,!1);if(ce(De)||!De.delete(ee))return!1;if(De.size===0){var Ye=B.get(te);ce(Ye)||(Ye.delete(pe),Ye.size===0&&B.delete(Ye))}return!0}}function ui(E){var B=E.defineMetadata,R=E.hasOwnMetadata,W=E.getOwnMetadata,xe=E.getOwnMetadataKeys,bt=E.deleteMetadata,xt=new w,Ne={isProviderFor:function(Y,ee){var te=xt.get(Y);return!ce(te)&&te.has(ee)?!0:xe(Y,ee).length?(ce(te)&&(te=new j,xt.set(Y,te)),te.add(ee),!0):!1},OrdinaryDefineOwnMetadata:B,OrdinaryHasOwnMetadata:R,OrdinaryGetOwnMetadata:W,OrdinaryOwnMetadataKeys:xe,OrdinaryDeleteMetadata:bt};return Ne}function Cr(E,B,R){var W=C.getProvider(E,B);if(!ce(W))return W;if(R){if(C.setProvider(E,B,k))return k;throw new Error("Illegal state.")}}function Yr(){var E={},B=[],R=function(){function Ne(Y,ee,te){this._index=0,this._keys=Y,this._values=ee,this._selector=te}return Ne.prototype["@@iterator"]=function(){return this},Ne.prototype[a]=function(){return this},Ne.prototype.next=function(){var Y=this._index;if(Y>=0&&Y<this._keys.length){var ee=this._selector(this._keys[Y],this._values[Y]);return Y+1>=this._keys.length?(this._index=-1,this._keys=B,this._values=B):this._index++,{value:ee,done:!1}}return{value:void 0,done:!0}},Ne.prototype.throw=function(Y){throw this._index>=0&&(this._index=-1,this._keys=B,this._values=B),Y},Ne.prototype.return=function(Y){return this._index>=0&&(this._index=-1,this._keys=B,this._values=B),{value:Y,done:!0}},Ne}(),W=function(){function Ne(){this._keys=[],this._values=[],this._cacheKey=E,this._cacheIndex=-2}return Object.defineProperty(Ne.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Ne.prototype.has=function(Y){return this._find(Y,!1)>=0},Ne.prototype.get=function(Y){var ee=this._find(Y,!1);return ee>=0?this._values[ee]:void 0},Ne.prototype.set=function(Y,ee){var te=this._find(Y,!0);return this._values[te]=ee,this},Ne.prototype.delete=function(Y){var ee=this._find(Y,!1);if(ee>=0){for(var te=this._keys.length,pe=ee+1;pe<te;pe++)this._keys[pe-1]=this._keys[pe],this._values[pe-1]=this._values[pe];return this._keys.length--,this._values.length--,yn(Y,this._cacheKey)&&(this._cacheKey=E,this._cacheIndex=-2),!0}return!1},Ne.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=E,this._cacheIndex=-2},Ne.prototype.keys=function(){return new R(this._keys,this._values,xe)},Ne.prototype.values=function(){return new R(this._keys,this._values,bt)},Ne.prototype.entries=function(){return new R(this._keys,this._values,xt)},Ne.prototype["@@iterator"]=function(){return this.entries()},Ne.prototype[a]=function(){return this.entries()},Ne.prototype._find=function(Y,ee){if(!yn(this._cacheKey,Y)){this._cacheIndex=-1;for(var te=0;te<this._keys.length;te++)if(yn(this._keys[te],Y)){this._cacheIndex=te;break}}return this._cacheIndex<0&&ee&&(this._cacheIndex=this._keys.length,this._keys.push(Y),this._values.push(void 0)),this._cacheIndex},Ne}();return W;function xe(Ne,Y){return Ne}function bt(Ne,Y){return Y}function xt(Ne,Y){return[Ne,Y]}}function Hi(){var E=function(){function B(){this._map=new J}return Object.defineProperty(B.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),B.prototype.has=function(R){return this._map.has(R)},B.prototype.add=function(R){return this._map.set(R,R),this},B.prototype.delete=function(R){return this._map.delete(R)},B.prototype.clear=function(){this._map.clear()},B.prototype.keys=function(){return this._map.keys()},B.prototype.values=function(){return this._map.keys()},B.prototype.entries=function(){return this._map.entries()},B.prototype["@@iterator"]=function(){return this.keys()},B.prototype[a]=function(){return this.keys()},B}();return E}function Fi(){var E=16,B=x.create(),R=W();return function(){function Y(){this._key=W()}return Y.prototype.has=function(ee){var te=xe(ee,!1);return te!==void 0?x.has(te,this._key):!1},Y.prototype.get=function(ee){var te=xe(ee,!1);return te!==void 0?x.get(te,this._key):void 0},Y.prototype.set=function(ee,te){var pe=xe(ee,!0);return pe[this._key]=te,this},Y.prototype.delete=function(ee){var te=xe(ee,!1);return te!==void 0?delete te[this._key]:!1},Y.prototype.clear=function(){this._key=W()},Y}();function W(){var Y;do Y="@@WeakMap@@"+Ne();while(x.has(B,Y));return B[Y]=!0,Y}function xe(Y,ee){if(!n.call(Y,R)){if(!ee)return;Object.defineProperty(Y,R,{value:x.create()})}return Y[R]}function bt(Y,ee){for(var te=0;te<ee;++te)Y[te]=Math.random()*255|0;return Y}function xt(Y){if(typeof Uint8Array=="function"){var ee=new Uint8Array(Y);return typeof crypto<"u"?crypto.getRandomValues(ee):typeof msCrypto<"u"?msCrypto.getRandomValues(ee):bt(ee,Y),ee}return bt(new Array(Y),Y)}function Ne(){var Y=xt(E);Y[6]=Y[6]&79|64,Y[8]=Y[8]&191|128;for(var ee="",te=0;te<E;++te){var pe=Y[te];(te===4||te===6||te===8)&&(ee+="-"),pe<16&&(ee+="0"),ee+=pe.toString(16).toLowerCase()}return ee}}function fi(E){return E.__=void 0,delete E.__,E}})})(Bf||(Bf={}));/*!
|
|
44
|
+
* MIT License
|
|
45
|
+
*
|
|
46
|
+
* Copyright (c) 2017-2022 Peculiar Ventures, LLC
|
|
47
|
+
*
|
|
48
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
49
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
50
|
+
* in the Software without restriction, including without limitation the rights
|
|
51
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
52
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
53
|
+
* furnished to do so, subject to the following conditions:
|
|
54
|
+
*
|
|
55
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
56
|
+
* copies or substantial portions of the Software.
|
|
57
|
+
*
|
|
58
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
59
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
60
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
61
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
62
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
63
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
64
|
+
* SOFTWARE.
|
|
65
|
+
*
|
|
66
|
+
*/const a0="[object ArrayBuffer]";class X{static isArrayBuffer(e){return Object.prototype.toString.call(e)===a0}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){const n=X.toUint8Array(e),i=X.toUint8Array(t);if(n.length!==i.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==i[s])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(const a of t)n+=a.byteLength;const i=new Uint8Array(n);let s=0;for(const a of t){const c=this.toUint8Array(a);i.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const $c="string",c0=/^[0-9a-f]+$/i,l0=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,u0=/^[a-zA-Z0-9-_]+$/;class Of{static fromString(e){const t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n.buffer}static toString(e){const t=X.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}}class Jr{static toString(e,t=!1){const n=X.toArrayBuffer(e),i=new DataView(n);let s="";for(let a=0;a<n.byteLength;a+=2){const c=i.getUint16(a,t);s+=String.fromCharCode(c)}return s}static fromString(e,t=!1){const n=new ArrayBuffer(e.length*2),i=new DataView(n);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),t);return n}}class de{static isHex(e){return typeof e===$c&&c0.test(e)}static isBase64(e){return typeof e===$c&&l0.test(e)}static isBase64Url(e){return typeof e===$c&&u0.test(e)}static ToString(e,t="utf8"){const n=X.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Jr.toString(n,!0);case"utf16":case"utf16be":return Jr.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Jr.fromString(e,!0);case"utf16":case"utf16be":return Jr.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=X.toUint8Array(e);if(typeof btoa<"u"){const n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!de.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!de.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=de.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Of.fromString(e);case"utf16":case"utf16be":return Jr.fromString(e);case"utf16le":case"usc2":return Jr.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=de.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Of.toString(e);case"utf16":case"utf16be":return Jr.toString(e);case"utf16le":case"usc2":return Jr.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,n=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);return n.buffer}static ToBinary(e){const t=X.toUint8Array(e);let n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return n}static ToHex(e){const t=X.toUint8Array(e);let n="";const i=t.length;for(let s=0;s<i;s++){const a=t[s];a<16&&(n+="0"),n+=a.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!de.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const n=new Uint8Array(t.length/2);for(let i=0;i<t.length;i=i+2){const s=t.slice(i,i+2);n[i/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return Jr.toString(e,t)}static FromUtf16String(e,t=!1){return Jr.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}de.DEFAULT_UTF8_ENCODING="utf8";function f0(...r){const e=r.map(i=>i.byteLength).reduce((i,s)=>i+s),t=new Uint8Array(e);let n=0;return r.map(i=>new Uint8Array(i)).forEach(i=>{for(const s of i)t[n++]=s}),t.buffer}function jo(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}/*!
|
|
67
|
+
Copyright (c) Peculiar Ventures, LLC
|
|
68
|
+
*/function Wi(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function pi(r,e,t=-1){const n=t;let i=r,s=0,a=Math.pow(2,e);for(let c=1;c<8;c++){if(r<a){let u;if(n<0)u=new ArrayBuffer(c),s=c;else{if(n<c)return new ArrayBuffer(0);u=new ArrayBuffer(n),s=n}const d=new Uint8Array(u);for(let x=c-1;x>=0;x--){const I=Math.pow(2,x*e);d[s-x-1]=Math.floor(i/I),i-=d[s-x-1]*I}return u}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function Mc(...r){let e=0,t=0;for(const s of r)e+=s.length;const n=new ArrayBuffer(e),i=new Uint8Array(n);for(const s of r)i.set(s,t),t+=s.length;return i}function Tf(){const r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=r[0]===255&&r[1]&128,u=r[0]===0&&(r[1]&128)===0;(c||u)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let c=0;c<this.valueHex.byteLength;c++)t[c]=0;t[0]=r[0]&128;const n=Wi(t,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=r[c];return s[0]&=127,Wi(s,8)-n}function h0(r){const e=r<0?r*-1:r;let t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){const a=t-e,c=pi(a,8,n),u=new Uint8Array(c);return u[0]|=128,c}let i=pi(e,8,n),s=new Uint8Array(i);if(s[0]&128){const a=i.slice(0),c=new Uint8Array(a);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let u=0;u<a.byteLength;u++)s[u+1]=c[u];s[0]=0}return i}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function d0(r,e){if(r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]!==n[i])return!1;return!0}function _r(r,e){const t=r.toString(10);if(e<t.length)return"";const n=e-t.length,i=new Array(n);for(let a=0;a<n;a++)i[a]="0";return i.join("").concat(t)}/*!
|
|
69
|
+
* Copyright (c) 2014, GMO GlobalSign
|
|
70
|
+
* Copyright (c) 2015-2022, Peculiar Ventures
|
|
71
|
+
* All rights reserved.
|
|
72
|
+
*
|
|
73
|
+
* Author 2014-2019, Yury Strozhevsky
|
|
74
|
+
*
|
|
75
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
|
76
|
+
* are permitted provided that the following conditions are met:
|
|
77
|
+
*
|
|
78
|
+
* * Redistributions of source code must retain the above copyright notice, this
|
|
79
|
+
* list of conditions and the following disclaimer.
|
|
80
|
+
*
|
|
81
|
+
* * Redistributions in binary form must reproduce the above copyright notice, this
|
|
82
|
+
* list of conditions and the following disclaimer in the documentation and/or
|
|
83
|
+
* other materials provided with the distribution.
|
|
84
|
+
*
|
|
85
|
+
* * Neither the name of the copyright holder nor the names of its
|
|
86
|
+
* contributors may be used to endorse or promote products derived from
|
|
87
|
+
* this software without specific prior written permission.
|
|
88
|
+
*
|
|
89
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
90
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
91
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
92
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
93
|
+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
94
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
95
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
96
|
+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
97
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
98
|
+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
99
|
+
*
|
|
100
|
+
*/function Ro(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Vc(r){let e=0,t=0;for(let i=0;i<r.length;i++){const s=r[i];e+=s.byteLength}const n=new Uint8Array(e);for(let i=0;i<r.length;i++){const s=r[i];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function bn(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class Po{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Vc(this.items)}}const ks=[new Uint8Array([1])],Nf="0123456789",Lc="name",jf="valueHexView",p0="isHexOnly",y0="idBlock",g0="tagClass",v0="tagNumber",m0="isConstructed",w0="fromBER",b0="toBER",x0="local",yr="",$r=new ArrayBuffer(0),Uo=new Uint8Array(0),Cs="EndOfContent",Rf="OCTET STRING",Pf="BIT STRING";function Xr(r){var e;return e=class extends r{constructor(...n){var i;super(...n);const s=n[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?X.toUint8Array(s.valueHex):Uo}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,i,s){const a=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!bn(this,a,i,s))return-1;const c=i+s;return this.valueHexView=a.subarray(i,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),i)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",$r)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:de.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class yi{constructor({blockLength:e=0,error:t=yr,warnings:n=[],valueBeforeDecode:i=Uo}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=X.toUint8Array(i)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:de.ToHex(this.valueBeforeDecodeView)}}}yi.NAME="baseBlock";class ar extends yi{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}ar.NAME="valueBlock";class Uf extends Xr(yi){constructor({idBlock:e={}}={}){var t,n,i,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?X.toUint8Array(e.valueHex):Uo,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",$r}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,i[0]=t}return i.buffer}if(!this.isHexOnly){const i=pi(this.tagNumber,7),s=new Uint8Array(i),a=i.byteLength,c=new Uint8Array(a+1);if(c[0]=t|31,!e){for(let u=0;u<a-1;u++)c[u+1]=s[u]|128;c[a]=s[a-1]}return c.buffer}const n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)n[s+1]=i[s]|128;n[this.valueHexView.byteLength]=i[i.length-1]}return n.buffer}fromBER(e,t,n){const i=X.toUint8Array(e);if(!bn(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;const c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let u=1,d=this.valueHexView=new Uint8Array(255),x=255;for(;s[u]&128;){if(d[u-1]=s[u]&127,u++,u>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(u===x){x+=255;const J=new Uint8Array(x);for(let j=0;j<d.length;j++)J[j]=d[j];d=this.valueHexView=new Uint8Array(x)}}this.blockLength=u+1,d[u-1]=s[u]&127;const I=new Uint8Array(u);for(let J=0;J<u;J++)I[J]=d[J];d=this.valueHexView=new Uint8Array(u),d.set(I),this.blockLength<=9?this.tagNumber=Wi(d,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}Uf.NAME="identificationBlock";class Df extends yi{constructor({lenBlock:e={}}={}){var t,n,i;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,t,n){const i=X.toUint8Array(e);if(!bn(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;const a=s[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=t+1,u=i.subarray(c,c+a);return u[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Wi(u,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){const i=pi(this.length,8);if(i.byteLength>127)return this.error="Too big length",$r;if(t=new ArrayBuffer(i.byteLength+1),e)return t;const s=new Uint8Array(i);n=new Uint8Array(t),n[0]=i.byteLength|128;for(let a=0;a<i.byteLength;a++)n[a+1]=s[a];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}Df.NAME="lengthBlock";const ue={};class Kt extends yi{constructor({name:e=yr,optional:t=!1,primitiveSchema:n,...i}={},s){super(i),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Uf(i),this.lenBlock=new Df(i),this.valueBlock=s?new s(i):new ar(i)}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,t){const n=t||new Po;t||$f(this);const i=this.idBlock.toBER(e);if(n.write(i),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const a=this.lenBlock.toBER(e);n.write(a),n.write(s)}return t?$r:n.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():de.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${de.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const t=this.toBER(),n=e.toBER();return d0(t,n)}}Kt.NAME="BaseBlock";function $f(r){if(r instanceof ue.Constructed)for(const e of r.valueBlock.value)$f(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class Hc extends Kt{constructor({value:e=yr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}Hc.NAME="BaseStringBlock";class Mf extends Xr(ar){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}Mf.NAME="PrimitiveValueBlock";var Vf;class Bs extends Kt{constructor(e={}){super(e,Mf),this.idBlock.isConstructed=!1}}Vf=Bs,ue.Primitive=Vf,Bs.NAME="PRIMITIVE";function A0(r,e){if(r instanceof e)return r;const t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function qi(r,e=0,t=r.length){const n=e;let i=new Kt({},ar);const s=new yi;if(!bn(s,r,e,t))return i.error=s.error,{offset:-1,result:i};if(!r.subarray(e,e+t).length)return i.error="Zero buffer length",{offset:-1,result:i};let c=i.idBlock.fromBER(r,e,t);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),c===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=c,t-=i.idBlock.blockLength,c=i.lenBlock.fromBER(r,e,t),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),c===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=c,t-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let u=Kt;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};u=ue.EndOfContent;break;case 1:u=ue.Boolean;break;case 2:u=ue.Integer;break;case 3:u=ue.BitString;break;case 4:u=ue.OctetString;break;case 5:u=ue.Null;break;case 6:u=ue.ObjectIdentifier;break;case 10:u=ue.Enumerated;break;case 12:u=ue.Utf8String;break;case 13:u=ue.RelativeObjectIdentifier;break;case 14:u=ue.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:u=ue.Sequence;break;case 17:u=ue.Set;break;case 18:u=ue.NumericString;break;case 19:u=ue.PrintableString;break;case 20:u=ue.TeletexString;break;case 21:u=ue.VideotexString;break;case 22:u=ue.IA5String;break;case 23:u=ue.UTCTime;break;case 24:u=ue.GeneralizedTime;break;case 25:u=ue.GraphicString;break;case 26:u=ue.VisibleString;break;case 27:u=ue.GeneralString;break;case 28:u=ue.UniversalString;break;case 29:u=ue.CharacterString;break;case 30:u=ue.BmpString;break;case 31:u=ue.DATE;break;case 32:u=ue.TimeOfDay;break;case 33:u=ue.DateTime;break;case 34:u=ue.Duration;break;default:{const d=i.idBlock.isConstructed?new ue.Constructed:new ue.Primitive;d.idBlock=i.idBlock,d.lenBlock=i.lenBlock,d.warnings=i.warnings,i=d}}break;case 2:case 3:case 4:default:u=i.idBlock.isConstructed?ue.Constructed:ue.Primitive}return i=A0(i,u),c=i.fromBER(r,e,i.lenBlock.isIndefiniteForm?t:i.lenBlock.length),i.valueBeforeDecodeView=r.subarray(n,n+i.blockLength),{offset:c,result:i}}function Yi(r){if(!r.byteLength){const e=new Kt({},ar);return e.error="Input buffer has zero length",{offset:-1,result:e}}return qi(X.toUint8Array(r).slice(),0,r.byteLength)}function _0(r,e){return r?1:e}class $n extends ar{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const i=X.toUint8Array(e);if(!bn(this,i,t,n))return-1;if(this.valueBeforeDecodeView=i.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let s=t;for(;_0(this.isIndefiniteForm,n)>0;){const a=qi(i,s,n);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(s=a.offset,this.blockLength+=a.result.blockLength,n-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===Cs)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Cs?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){const n=t||new Po;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,n);return t?$r:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}$n.NAME="ConstructedValueBlock";var Lf;class gr extends Kt{constructor(e={}){super(e,$n),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){const e=[];for(const n of this.valueBlock.value)e.push(n.toString("ascii").split(`
|
|
101
|
+
`).map(i=>` ${i}`).join(`
|
|
102
|
+
`));const t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
|
|
103
|
+
${e.join(`
|
|
104
|
+
`)}`:`${t} :`}}Lf=gr,ue.Constructed=Lf,gr.NAME="CONSTRUCTED";class Hf extends ar{fromBER(e,t,n){return t}toBER(e){return $r}}Hf.override="EndOfContentValueBlock";var Ff;class Fc extends Kt{constructor(e={}){super(e,Hf),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Ff=Fc,ue.EndOfContent=Ff,Fc.NAME=Cs;var Gf;class gi extends Kt{constructor(e={}){super(e,ar),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){const n=new ArrayBuffer(2);if(!e){const i=new Uint8Array(n);i[0]=5,i[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}}Gf=gi,ue.Null=Gf,gi.NAME="NULL";class zf extends Xr(ar){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=X.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){const i=X.toUint8Array(e);return bn(this,i,t,n)?(this.valueHexView=i.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Tf.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}zf.NAME="BooleanValueBlock";var Zf;let Do=class extends Kt{constructor(e={}){super(e,zf),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Zf=Do,ue.Boolean=Zf,Do.NAME="BOOLEAN";class Kf extends Xr($n){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=$n.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(let s=0;s<this.value.length;s++){const a=this.value[s].constructor.NAME;if(a===Cs){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==Rf)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,n),this.blockLength=n;return i}toBER(e,t){return this.isConstructed?$n.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Kf.NAME="OctetStringValueBlock";var Wf;let vi=class My extends Kt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Kf),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(s.byteLength){const a=qi(s,0,s.byteLength);a.offset!==-1&&a.offset===n&&(this.valueBlock.value=[a.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?gr.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${de.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof My&&e.push(t.valueBlock.valueHexView);return X.concat(e)}};Wf=vi,ue.OctetString=Wf,vi.NAME=Rf;class qf extends Xr($n){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let i=-1;if(this.isConstructed){if(i=$n.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(const c of this.value){const u=c.constructor.NAME;if(u===Cs){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(u!==Pf)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const d=c.valueBlock;if(this.unusedBits>0&&d.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=d.unusedBits}return i}const s=X.toUint8Array(e);if(!bn(this,s,t,n))return-1;const a=s.subarray(t,t+n);if(this.unusedBits=a[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=a.subarray(1);try{if(c.byteLength){const u=qi(c,0,c.byteLength);u.offset!==-1&&u.offset===n-1&&(this.value=[u.result])}}catch{}}return this.valueHexView=a.subarray(1),this.blockLength=a.length,t+n}toBER(e,t){if(this.isConstructed)return $n.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return $r;const n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}qf.NAME="BitStringValueBlock";var Yf;let mi=class extends Kt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},qf),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return gr.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const i of t)e.push(i.toString(2).padStart(8,"0"));const n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};Yf=mi,ue.BitString=Yf,mi.NAME=Pf;var Jf;function S0(r,e){const t=new Uint8Array([0]),n=new Uint8Array(r),i=new Uint8Array(e);let s=n.slice(0);const a=s.length-1,c=i.slice(0),u=c.length-1;let d=0;const x=u<a?a:u;let I=0;for(let J=x;J>=0;J--,I++){switch(!0){case I<c.length:d=s[a-I]+c[u-I]+t[0];break;default:d=s[a-I]+t[0]}switch(t[0]=d/10,!0){case I>=s.length:s=Mc(new Uint8Array([d%10]),s);break;default:s[a-I]=d%10}}return t[0]>0&&(s=Mc(t,s)),s}function Xf(r){if(r>=ks.length)for(let e=ks.length;e<=r;e++){const t=new Uint8Array([0]);let n=ks[e-1].slice(0);for(let i=n.length-1;i>=0;i--){const s=new Uint8Array([(n[i]<<1)+t[0]]);t[0]=s[0]/10,n[i]=s[0]%10}t[0]>0&&(n=Mc(t,n)),ks.push(n)}return ks[r]}function E0(r,e){let t=0;const n=new Uint8Array(r),i=new Uint8Array(e),s=n.slice(0),a=s.length-1,c=i.slice(0),u=c.length-1;let d,x=0;for(let I=u;I>=0;I--,x++)switch(d=s[a-x]-c[u-x]-t,!0){case d<0:t=1,s[a-x]=d+10;break;default:t=0,s[a-x]=d}if(t>0)for(let I=a-u+1;I>=0;I--,x++)if(d=s[a-x]-t,d<0)t=1,s[a-x]=d+10;else{t=0,s[a-x]=d;break}return s.slice()}class Gc extends Xr(ar){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Tf.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(h0(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,i=0){const s=this.fromBER(e,t,n);if(s===-1)return s;const a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):i!==0&&a.length<i&&(i-a.length>1&&(i=a.length+1),this.valueHexView=a.subarray(i-a.length)),s}toDER(e=!1){const t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{const n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){const i=super.fromBER(e,t,n);return i===-1||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=this.valueHexView.length*8-1;let t=new Uint8Array(this.valueHexView.length*8/3),n=0,i;const s=this.valueHexView;let a="",c=!1;for(let u=s.byteLength-1;u>=0;u--){i=s[u];for(let d=0;d<8;d++){if((i&1)===1)switch(n){case e:t=E0(Xf(n),t),a="-";break;default:t=S0(t,Xf(n))}n++,i>>=1}}for(let u=0;u<t.length;u++)t[u]&&(c=!0),c&&(a+=Nf.charAt(t[u]));return c===!1&&(a+=Nf.charAt(0)),a}}Jf=Gc,Gc.NAME="IntegerValueBlock",Object.defineProperty(Jf.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Qf;class Qr extends Kt{constructor(e={}){super(e,Gc),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Ro(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Ro();const t=BigInt(e),n=new Po,i=t.toString(16).replace(/^-/,""),s=new Uint8Array(de.FromHex(i));if(t<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const d=BigInt(`0x${de.ToHex(c)}`)+t,x=X.toUint8Array(de.FromHex(d.toString(16)));x[0]|=128,n.write(x)}else s[0]&128&&n.write(new Uint8Array([0])),n.write(s);return new Qr({valueHex:n.final()})}convertToDER(){const e=new Qr({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Qr({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}Qf=Qr,ue.Integer=Qf,Qr.NAME="INTEGER";var eh;class $o extends Qr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}eh=$o,ue.Enumerated=eh,$o.NAME="ENUMERATED";class zc extends Xr(ar){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;const i=X.toUint8Array(e);if(!bn(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Wi(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Ro();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const n=new Uint8Array(t.length/7);for(let i=0;i<n.length;i++)n[i]=parseInt(t.slice(i*7,i*7+7),2)+(i+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=pi(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",$r;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let a=0;a<s;a++)n[a]=i[a]|128;n[s]=i[s]}return n}toString(){let e="";if(this.isHexOnly)e=de.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}zc.NAME="sidBlock";class th extends ar{constructor({value:e=yr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new zc;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e){const t=[];for(let n=0;n<this.value.length;n++){const i=this.value[n].toBER(e);if(i.byteLength===0)return this.error=this.value[n].error,$r;t.push(i)}return Vc(t)}fromString(e){this.value=[];let t=0,n=0,i="",s=!1;do if(n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1,s){const a=this.value[0];let c=0;switch(a.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const u=parseInt(i,10);if(isNaN(u))return;a.valueDec=u+c,s=!1}else{const a=new zc;if(i>Number.MAX_SAFE_INTEGER){Ro();const c=BigInt(i);a.valueBigInt=c}else if(a.valueDec=parseInt(i,10),isNaN(a.valueDec))return;this.value.length||(a.isFirstSid=!0,s=!0),this.value.push(a)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t?(i=`{${i}}`,this.value[n].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}th.NAME="ObjectIdentifierValueBlock";var rh;class Mo extends Kt{constructor(e={}){super(e,th),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}rh=Mo,ue.ObjectIdentifier=rh,Mo.NAME="OBJECT IDENTIFIER";class Zc extends Xr(yi){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const i=X.toUint8Array(e);if(!bn(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Wi(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=pi(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",$r;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let a=0;a<s;a++)n[a]=i[a]|128;n[s]=i[s]}return n.buffer}toString(){let e="";return this.isHexOnly?e=de.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Zc.NAME="relativeSidBlock";class nh extends ar{constructor({value:e=yr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Zc;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e,t){const n=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,$r;n.push(s)}return Vc(n)}fromString(e){this.value=[];let t=0,n=0,i="";do{n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1;const s=new Zc;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(i=`{${i}}`),e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}nh.NAME="RelativeObjectIdentifierValueBlock";var ih;class Kc extends Kt{constructor(e={}){super(e,nh),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}ih=Kc,ue.RelativeObjectIdentifier=ih,Kc.NAME="RelativeObjectIdentifier";var sh;class xn extends gr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}sh=xn,ue.Sequence=sh,xn.NAME="SEQUENCE";var oh;let An=class extends gr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};oh=An,ue.Set=oh,An.NAME="SET";class ah extends Xr(ar){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=yr}toJSON(){return{...super.toJSON(),value:this.value}}}ah.NAME="StringValueBlock";class ch extends ah{}ch.NAME="SimpleStringValueBlock";class Sr extends Hc{constructor({...e}={}){super(e,ch)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,X.toUint8Array(e))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);this.valueBlock.value=e}}Sr.NAME="SIMPLE STRING";class lh extends Sr{fromBuffer(e){this.valueBlock.valueHexView=X.toUint8Array(e);try{this.valueBlock.value=de.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=de.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(de.FromUtf8String(e)),this.valueBlock.value=e}}lh.NAME="Utf8StringValueBlock";var uh;class _n extends lh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}uh=_n,ue.Utf8String=uh,_n.NAME="UTF8String";class fh extends Sr{fromBuffer(e){this.valueBlock.value=de.ToUtf16String(e),this.valueBlock.valueHexView=X.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(de.FromUtf16String(e))}}fh.NAME="BmpStringValueBlock";var hh;class Vo extends fh{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}hh=Vo,ue.BmpString=hh,Vo.NAME="BMPString";class dh extends Sr{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let i=0;i<n.length;i+=4)n[i]=n[i+3],n[i+1]=n[i+2],n[i+2]=0,n[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let i=0;i<t;i++){const s=pi(e.charCodeAt(i),8),a=new Uint8Array(s);if(a.length>4)continue;const c=4-a.length;for(let u=a.length-1;u>=0;u--)n[i*4+u+c]=a[u]}this.valueBlock.value=e}}dh.NAME="UniversalStringValueBlock";var ph;class Lo extends dh{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}ph=Lo,ue.UniversalString=ph,Lo.NAME="UniversalString";var yh;class Ho extends Sr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}yh=Ho,ue.NumericString=yh,Ho.NAME="NumericString";var gh;class Fo extends Sr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}gh=Fo,ue.PrintableString=gh,Fo.NAME="PrintableString";var vh;class Go extends Sr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}vh=Go,ue.TeletexString=vh,Go.NAME="TeletexString";var mh;class zo extends Sr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}mh=zo,ue.VideotexString=mh,zo.NAME="VideotexString";var wh;class Zo extends Sr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}wh=Zo,ue.IA5String=wh,Zo.NAME="IA5String";var bh;class Ko extends Sr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}bh=Ko,ue.GraphicString=bh,Ko.NAME="GraphicString";var xh;class Os extends Sr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}xh=Os,ue.VisibleString=xh,Os.NAME="VisibleString";var Ah;class Wo extends Sr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Ah=Wo,ue.GeneralString=Ah,Wo.NAME="GeneralString";var _h;class qo extends Sr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}_h=qo,ue.CharacterString=_h,qo.NAME="CharacterString";var Sh;class Ts extends Os{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,X.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}const i=parseInt(n[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=_r(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=_r(this.month,2),t[2]=_r(this.day,2),t[3]=_r(this.hour,2),t[4]=_r(this.minute,2),t[5]=_r(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}Sh=Ts,ue.UTCTime=Sh,Ts.NAME="UTCTime";var Eh;class Yo extends Ts{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",i="",s=0,a,c=0,u=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{const I=new Number(e[e.length-1]);if(isNaN(I.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let I=1,J=n.indexOf("+"),j="";if(J===-1&&(J=n.indexOf("-"),I=-1),J!==-1){if(j=n.substring(J+1),n=n.substring(0,J),j.length!==2&&j.length!==4)throw new Error("Wrong input string for conversion");let w=parseInt(j.substring(0,2),10);if(isNaN(w.valueOf()))throw new Error("Wrong input string for conversion");if(c=I*w,j.length===4){if(w=parseInt(j.substring(2,4),10),isNaN(w.valueOf()))throw new Error("Wrong input string for conversion");u=I*w}}}let d=n.indexOf(".");if(d===-1&&(d=n.indexOf(",")),d!==-1){const I=new Number(`0${n.substring(d)}`);if(isNaN(I.valueOf()))throw new Error("Wrong input string for conversion");s=I.valueOf(),i=n.substring(0,d)}else i=n;switch(!0){case i.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,d!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,d!==-1){let I=60*s;this.minute=Math.floor(I),I=60*(I-this.minute),this.second=Math.floor(I),I=1e3*(I-this.second),this.millisecond=Math.floor(I)}break;case i.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,d!==-1){let I=60*s;this.second=Math.floor(I),I=1e3*(I-this.second),this.millisecond=Math.floor(I)}break;case i.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,d!==-1){const I=1e3*s;this.millisecond=Math.floor(I)}break;default:throw new Error("Wrong input string for conversion")}const x=a.exec(i);if(x===null)throw new Error("Wrong input string for conversion");for(let I=1;I<x.length;I++)switch(I){case 1:this.year=parseInt(x[I],10);break;case 2:this.month=parseInt(x[I],10);break;case 3:this.day=parseInt(x[I],10);break;case 4:this.hour=parseInt(x[I],10)+c;break;case 5:this.minute=parseInt(x[I],10)+u;break;case 6:this.second=parseInt(x[I],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const I=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=I.getUTCFullYear(),this.month=I.getUTCMonth(),this.day=I.getUTCDay(),this.hour=I.getUTCHours(),this.minute=I.getUTCMinutes(),this.second=I.getUTCSeconds(),this.millisecond=I.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(_r(this.year,4)),t.push(_r(this.month,2)),t.push(_r(this.day,2)),t.push(_r(this.hour,2)),t.push(_r(this.minute,2)),t.push(_r(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(_r(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Eh=Yo,ue.GeneralizedTime=Eh,Yo.NAME="GeneralizedTime";var Ih;class Wc extends _n{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Ih=Wc,ue.DATE=Ih,Wc.NAME="DATE";var kh;class qc extends _n{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}kh=qc,ue.TimeOfDay=kh,qc.NAME="TimeOfDay";var Ch;class Yc extends _n{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Ch=Yc,ue.DateTime=Ch,Yc.NAME="DateTime";var Bh;class Jc extends _n{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Bh=Jc,ue.Duration=Bh,Jc.NAME="Duration";var Oh;class Xc extends _n{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Oh=Xc,ue.TIME=Oh,Xc.NAME="TIME";class wi{constructor({name:e=yr,optional:t=!1}={}){this.name=e,this.optional=t}}class Qc extends wi{constructor({value:e=[],...t}={}){super(t),this.value=e}}class Jo extends wi{constructor({value:e=new wi,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class I0{constructor({data:e=Uo}={}){this.dataView=X.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=X.toUint8Array(e)}fromBER(e,t,n){const i=t+n;return this.dataView=X.toUint8Array(e).subarray(t,i),i}toBER(e){return this.dataView.slice().buffer}}function bi(r,e,t){if(t instanceof Qc){for(let s=0;s<t.value.length;s++)if(bi(r,e,t.value[s]).verified)return{verified:!0,result:r};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(Lc)&&(s.name=t.name),s}}if(t instanceof wi)return t.hasOwnProperty(Lc)&&(r[t.name]=e),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(y0 in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(w0 in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(b0 in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const n=t.idBlock.toBER(!1);if(n.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(n,0,n.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(g0)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(v0)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(m0)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(p0 in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:r};if(t.idBlock.isHexOnly){if(!(jf in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=t.idBlock.valueHexView,a=e.idBlock.valueHexView;if(s.length!==a.length)return{verified:!1,result:r};for(let c=0;c<s.length;c++)if(s[c]!==a[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&(r[t.name]=e)),t instanceof ue.Constructed){let s=0,a={verified:!1,result:{error:"Unknown error"}},c=t.valueBlock.value.length;if(c>0&&t.valueBlock.value[0]instanceof Jo&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let u=!0;for(let d=0;d<t.valueBlock.value.length;d++)u=u&&(t.valueBlock.value[d].optional||!1);return u?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let u=0;u<c;u++)if(u-s>=e.valueBlock.value.length){if(t.valueBlock.value[u].optional===!1){const d={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&(delete r[t.name],d.name=t.name)),d}}else if(t.valueBlock.value[0]instanceof Jo){if(a=bi(r,e.valueBlock.value[u],t.valueBlock.value[0].value),a.verified===!1)if(t.valueBlock.value[0].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&delete r[t.name]),a;if(Lc in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let d={};x0 in t.valueBlock.value[0]&&t.valueBlock.value[0].local?d=e:d=r,typeof d[t.valueBlock.value[0].name]>"u"&&(d[t.valueBlock.value[0].name]=[]),d[t.valueBlock.value[0].name].push(e.valueBlock.value[u])}}else if(a=bi(r,e.valueBlock.value[u-s],t.valueBlock.value[u]),a.verified===!1)if(t.valueBlock.value[u].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&delete r[t.name]),a;if(a.verified===!1){const u={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&(delete r[t.name],u.name=t.name)),u}return{verified:!0,result:r}}if(t.primitiveSchema&&jf in e.valueBlock){const s=qi(e.valueBlock.valueHexView);if(s.offset===-1){const a={verified:!1,result:s.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,yr),t.name&&(delete r[t.name],a.name=t.name)),a}return bi(r,s.result,t.primitiveSchema)}return{verified:!0,result:r}}function k0(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=qi(X.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:bi(t.result,t.result,e)}const Th=Object.freeze(Object.defineProperty({__proto__:null,Any:wi,BaseBlock:Kt,BaseStringBlock:Hc,BitString:mi,BmpString:Vo,Boolean:Do,CharacterString:qo,Choice:Qc,Constructed:gr,DATE:Wc,DateTime:Yc,Duration:Jc,EndOfContent:Fc,Enumerated:$o,GeneralString:Wo,GeneralizedTime:Yo,GraphicString:Ko,HexBlock:Xr,IA5String:Zo,Integer:Qr,Null:gi,NumericString:Ho,ObjectIdentifier:Mo,OctetString:vi,Primitive:Bs,PrintableString:Fo,RawData:I0,RelativeObjectIdentifier:Kc,Repeated:Jo,Sequence:xn,Set:An,TIME:Xc,TeletexString:Go,TimeOfDay:qc,UTCTime:Ts,UniversalString:Lo,Utf8String:_n,ValueBlock:ar,VideotexString:zo,ViewWriter:Po,VisibleString:Os,compareSchema:bi,fromBER:Yi,verifySchema:k0},Symbol.toStringTag,{value:"Module"}));var V;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(V||(V={}));var _;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(_||(_={}));class Xo{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(X.isBufferSource(e))this.unusedBits=t,this.value=X.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof mi))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new mi({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new mi({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const n of t)e+=n.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2);const n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;const i=new Uint8Array(n);t=t.padStart(n<<3,"0").split("").reverse().join("");let s=0;for(;s<n;)i[s]=parseInt(t.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class rt{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):X.isBufferSource(e)?this.buffer=X.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof vi))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new vi({valueHex:this.buffer})}toSchema(e){return new vi({name:e})}}const C0={fromASN:r=>r instanceof gi?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new gi;const e=Yi(r);if(e.result.error)throw new Error(e.result.error);return e.result}},B0={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new Qr({value:+r})},O0={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new $o({value:r})},At={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Qr({valueHex:r})},T0={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new mi({valueHex:r})},N0={fromASN:r=>r.valueBlock.toString(),toASN:r=>new Mo({value:r})},j0={fromASN:r=>r.valueBlock.value,toASN:r=>new Do({value:r})},Qo={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new vi({valueHex:r})},R0={fromASN:r=>new rt(r.getValue()),toASN:r=>r.toASN()};function Or(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const Nh=Or(_n),P0=Or(Vo),U0=Or(Lo),D0=Or(Ho),$0=Or(Fo),M0=Or(Go),V0=Or(zo),L0=Or(Zo),H0=Or(Ko),F0=Or(Os),G0=Or(Wo),z0=Or(qo),Z0={fromASN:r=>r.toDate(),toASN:r=>new Ts({valueDate:r})},K0={fromASN:r=>r.toDate(),toASN:r=>new Yo({valueDate:r})},W0={fromASN:()=>null,toASN:()=>new gi};function el(r){switch(r){case _.Any:return C0;case _.BitString:return T0;case _.BmpString:return P0;case _.Boolean:return j0;case _.CharacterString:return z0;case _.Enumerated:return O0;case _.GeneralString:return G0;case _.GeneralizedTime:return K0;case _.GraphicString:return H0;case _.IA5String:return L0;case _.Integer:return B0;case _.Null:return W0;case _.NumericString:return D0;case _.ObjectIdentifier:return N0;case _.OctetString:return Qo;case _.PrintableString:return $0;case _.TeletexString:return M0;case _.UTCTime:return Z0;case _.UniversalString:return U0;case _.Utf8String:return Nh;case _.VideotexString:return V0;case _.VisibleString:return F0;default:return null}}function Sn(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:Sn(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function jh(r){var e;if(r){const t=Object.getPrototypeOf(r);return((e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:jh(t)}return!1}function q0(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}class Y0{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const n=this.items.get(e);if(!n)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:V.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){const n=this.items.get(e)||this.createDefault(e),i=[];for(const s in n.items){const a=n.items[s],c=t?s:"";let u;if(typeof a.type=="number"){const x=_[a.type],I=Th[x];if(!I)throw new Error(`Cannot get ASN1 class by name '${x}'`);u=new I({name:c})}else Sn(a.type)?u=new a.type().toSchema(c):a.optional?this.get(a.type).type===V.Choice?u=new wi({name:c}):(u=this.create(a.type,!1),u.name=c):u=new wi({name:c});const d=!!a.optional||a.defaultValue!==void 0;if(a.repeated){u.name="";const x=a.repeated==="set"?An:xn;u=new x({name:"",value:[new Jo({name:c,value:u})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||Sn(a.type)){const x=a.repeated?gr:Bs;i.push(new x({name:c,optional:d,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);const x=!!a.repeated;let I=x?u:this.get(a.type,!0).schema;I="valueBlock"in I?I.valueBlock.value:I.value,i.push(new gr({name:x?"":c,optional:d,idBlock:{tagClass:3,tagNumber:a.context},value:I}))}else i.push(new gr({optional:d,idBlock:{tagClass:3,tagNumber:a.context},value:[u]}));else u.optional=d,i.push(u)}switch(n.type){case V.Sequence:return new xn({value:i,name:""});case V.Set:return new An({value:i,name:""});case V.Choice:return new Qc({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}const Tr=new Y0,z=r=>e=>{let t;Tr.has(e)?t=Tr.get(e):(t=Tr.createDefault(e),Tr.set(e,t)),Object.assign(t,r)},g=r=>(e,t)=>{let n;Tr.has(e.constructor)?n=Tr.get(e.constructor):(n=Tr.createDefault(e.constructor),Tr.set(e.constructor,n));const i=Object.assign({},r);if(typeof i.type=="number"&&!i.converter){const s=el(r.type);if(!s)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);i.converter=s}n.items[t]=i};class Rh extends Error{constructor(){super(...arguments),this.schemas=[]}}class J0{static parse(e,t){const n=Yi(e);if(n.result.error)throw new Error(n.result.error);return this.fromASN(n.result,t)}static fromASN(e,t){var n;try{if(Sn(t))return new t().fromASN(e);const i=Tr.get(t);Tr.cache(t);let s=i.schema;if(e.constructor===gr&&i.type!==V.Choice){s=new gr({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const u in i.items)delete e[u]}const a=bi({},e,s);if(!a.verified)throw new Rh(`Data does not match to ${t.name} ASN1 schema. ${a.result.error}`);const c=new t;if(jh(t)){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const u=i.itemType;if(typeof u=="number"){const d=el(u);if(!d)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,x=>d.fromASN(x))}else return t.from(e.valueBlock.value,d=>this.fromASN(d,u))}for(const u in i.items){const d=a.result[u];if(!d)continue;const x=i.items[u],I=x.type;if(typeof I=="number"||Sn(I)){const J=(n=x.converter)!==null&&n!==void 0?n:Sn(I)?new I:null;if(!J)throw new Error("Converter is empty");if(x.repeated)if(x.implicit){const j=x.repeated==="sequence"?xn:An,w=new j;w.valueBlock=d.valueBlock;const A=Yi(w.toBER(!1));if(A.offset===-1)throw new Error(`Cannot parse the child item. ${A.result.error}`);if(!("value"in A.result.valueBlock&&Array.isArray(A.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const C=A.result.valueBlock.value;c[u]=Array.from(C,k=>J.fromASN(k))}else c[u]=Array.from(d,j=>J.fromASN(j));else{let j=d;if(x.implicit){let w;if(Sn(I))w=new I().toSchema("");else{const A=_[I],C=Th[A];if(!C)throw new Error(`Cannot get '${A}' class from asn1js module`);w=new C}w.valueBlock=j.valueBlock,j=Yi(w.toBER(!1)).result}c[u]=J.fromASN(j)}}else if(x.repeated){if(!Array.isArray(d))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[u]=Array.from(d,J=>this.fromASN(J,I))}else c[u]=this.fromASN(d,I)}return c}catch(i){throw i instanceof Rh&&i.schemas.push(t.name),i}}}class tl{static serialize(e){return e instanceof Kt?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Sn(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=Tr.get(t);Tr.cache(t);let i=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){const a=el(n.itemType);if(!a)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);i=e.map(c=>a.toASN(c))}else i=e.map(a=>this.toAsnItem({type:n.itemType},"[]",t,a))}else for(const a in n.items){const c=n.items[a],u=e[a];if(u===void 0||c.defaultValue===u||typeof c.defaultValue=="object"&&typeof u=="object"&&q0(this.serialize(c.defaultValue),this.serialize(u)))continue;const d=tl.toAsnItem(c,a,t,u);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||Sn(c.type))){const x={};x.valueHex=d instanceof gi?d.valueBeforeDecodeView:d.valueBlock.toBER(),i.push(new Bs({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...x}))}else i.push(new gr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:d.valueBlock.value}));else i.push(new gr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[d]}));else c.repeated?i=i.concat(d):i.push(d)}let s;switch(n.type){case V.Sequence:s=new xn({value:i});break;case V.Set:s=new An({value:i});break;case V.Choice:if(!i[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,t,n,i){let s;if(typeof e.type=="number"){const a=e.converter;if(!a)throw new Error(`Property '${t}' doesn't have converter for type ${_[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(i,d=>a.toASN(d)),u=e.repeated==="sequence"?xn:An;s=new u({value:c})}else s=a.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const a=Array.from(i,u=>this.toASN(u)),c=e.repeated==="sequence"?xn:An;s=new c({value:a})}else s=this.toASN(i);return s}}class vt extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class q{static serialize(e){return tl.serialize(e)}static parse(e,t){return J0.parse(e,t)}static toString(e){const t=X.isBufferSource(e)?X.toArrayBuffer(e):q.serialize(e),n=Yi(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}}function f(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(a=r[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}typeof SuppressedError=="function"&&SuppressedError;var Ph={exports:{}};(function(r){(function(e){const t="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),a="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",u={zoneIndex:new RegExp(a,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${a})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${a})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${t}\\.${t}\\.${t}\\.${t}(${a})?$`,"i")};function d(w,A){if(w.indexOf("::")!==w.lastIndexOf("::"))return null;let C=0,k=-1,P=(w.match(u.zoneIndex)||[])[0],$,Ae;for(P&&(P=P.substring(1),w=w.replace(/%.+$/,""));(k=w.indexOf(":",k+1))>=0;)C++;if(w.substr(0,2)==="::"&&C--,w.substr(-2,2)==="::"&&C--,C>A)return null;for(Ae=A-C,$=":";Ae--;)$+="0:";return w=w.replace("::",$),w[0]===":"&&(w=w.slice(1)),w[w.length-1]===":"&&(w=w.slice(0,-1)),A=function(){const tt=w.split(":"),Ze=[];for(let Re=0;Re<tt.length;Re++)Ze.push(parseInt(tt[Re],16));return Ze}(),{parts:A,zoneId:P}}function x(w,A,C,k){if(w.length!==A.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let P=0,$;for(;k>0;){if($=C-k,$<0&&($=0),w[P]>>$!==A[P]>>$)return!1;k-=C,P+=1}return!0}function I(w){if(s.test(w))return parseInt(w,16);if(w[0]==="0"&&!isNaN(parseInt(w[1],10))){if(i.test(w))return parseInt(w,8);throw new Error(`ipaddr: cannot parse ${w} as octal`)}return parseInt(w,10)}function J(w,A){for(;w.length<A;)w=`0${w}`;return w}const j={};j.IPv4=function(){function w(A){if(A.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let C,k;for(C=0;C<A.length;C++)if(k=A[C],!(0<=k&&k<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=A}return w.prototype.SpecialRanges={unspecified:[[new w([0,0,0,0]),8]],broadcast:[[new w([255,255,255,255]),32]],multicast:[[new w([224,0,0,0]),4]],linkLocal:[[new w([169,254,0,0]),16]],loopback:[[new w([127,0,0,0]),8]],carrierGradeNat:[[new w([100,64,0,0]),10]],private:[[new w([10,0,0,0]),8],[new w([172,16,0,0]),12],[new w([192,168,0,0]),16]],reserved:[[new w([192,0,0,0]),24],[new w([192,0,2,0]),24],[new w([192,88,99,0]),24],[new w([198,18,0,0]),15],[new w([198,51,100,0]),24],[new w([203,0,113,0]),24],[new w([240,0,0,0]),4]],as112:[[new w([192,175,48,0]),24],[new w([192,31,196,0]),24]],amt:[[new w([192,52,193,0]),24]]},w.prototype.kind=function(){return"ipv4"},w.prototype.match=function(A,C){let k;if(C===void 0&&(k=A,A=k[0],C=k[1]),A.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return x(this.octets,A.octets,8,C)},w.prototype.prefixLengthFromSubnetMask=function(){let A=0,C=!1;const k={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let P,$,Ae;for(P=3;P>=0;P-=1)if($=this.octets[P],$ in k){if(Ae=k[$],C&&Ae!==0)return null;Ae!==8&&(C=!0),A+=Ae}else return null;return 32-A},w.prototype.range=function(){return j.subnetMatch(this,this.SpecialRanges)},w.prototype.toByteArray=function(){return this.octets.slice(0)},w.prototype.toIPv4MappedAddress=function(){return j.IPv6.parse(`::ffff:${this.toString()}`)},w.prototype.toNormalizedString=function(){return this.toString()},w.prototype.toString=function(){return this.octets.join(".")},w}(),j.IPv4.broadcastAddressFromCIDR=function(w){try{const A=this.parseCIDR(w),C=A[0].toByteArray(),k=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[];let $=0;for(;$<4;)P.push(parseInt(C[$],10)|parseInt(k[$],10)^255),$++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},j.IPv4.isIPv4=function(w){return this.parser(w)!==null},j.IPv4.isValid=function(w){try{return new this(this.parser(w)),!0}catch{return!1}},j.IPv4.isValidCIDR=function(w){try{return this.parseCIDR(w),!0}catch{return!1}},j.IPv4.isValidFourPartDecimal=function(w){return!!(j.IPv4.isValid(w)&&w.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},j.IPv4.networkAddressFromCIDR=function(w){let A,C,k,P,$;try{for(A=this.parseCIDR(w),k=A[0].toByteArray(),$=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[],C=0;C<4;)P.push(parseInt(k[C],10)&parseInt($[C],10)),C++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},j.IPv4.parse=function(w){const A=this.parser(w);if(A===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(A)},j.IPv4.parseCIDR=function(w){let A;if(A=w.match(/^(.+)\/(\d+)$/)){const C=parseInt(A[2]);if(C>=0&&C<=32){const k=[this.parse(A[1]),C];return Object.defineProperty(k,"toString",{value:function(){return this.join("/")}}),k}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},j.IPv4.parser=function(w){let A,C,k;if(A=w.match(n.fourOctet))return function(){const P=A.slice(1,6),$=[];for(let Ae=0;Ae<P.length;Ae++)C=P[Ae],$.push(I(C));return $}();if(A=w.match(n.longValue)){if(k=I(A[1]),k>4294967295||k<0)throw new Error("ipaddr: address outside defined range");return function(){const P=[];let $;for($=0;$<=24;$+=8)P.push(k>>$&255);return P}().reverse()}else return(A=w.match(n.twoOctet))?function(){const P=A.slice(1,4),$=[];if(k=I(P[1]),k>16777215||k<0)throw new Error("ipaddr: address outside defined range");return $.push(I(P[0])),$.push(k>>16&255),$.push(k>>8&255),$.push(k&255),$}():(A=w.match(n.threeOctet))?function(){const P=A.slice(1,5),$=[];if(k=I(P[2]),k>65535||k<0)throw new Error("ipaddr: address outside defined range");return $.push(I(P[0])),$.push(I(P[1])),$.push(k>>8&255),$.push(k&255),$}():null},j.IPv4.subnetMaskFromPrefixLength=function(w){if(w=parseInt(w),w<0||w>32)throw new Error("ipaddr: invalid IPv4 prefix length");const A=[0,0,0,0];let C=0;const k=Math.floor(w/8);for(;C<k;)A[C]=255,C++;return k<4&&(A[k]=Math.pow(2,w%8)-1<<8-w%8),new this(A)},j.IPv6=function(){function w(A,C){let k,P;if(A.length===16)for(this.parts=[],k=0;k<=14;k+=2)this.parts.push(A[k]<<8|A[k+1]);else if(A.length===8)this.parts=A;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(k=0;k<this.parts.length;k++)if(P=this.parts[k],!(0<=P&&P<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");C&&(this.zoneId=C)}return w.prototype.SpecialRanges={unspecified:[new w([0,0,0,0,0,0,0,0]),128],linkLocal:[new w([65152,0,0,0,0,0,0,0]),10],multicast:[new w([65280,0,0,0,0,0,0,0]),8],loopback:[new w([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new w([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new w([0,0,0,0,0,65535,0,0]),96],discard:[new w([256,0,0,0,0,0,0,0]),64],rfc6145:[new w([0,0,0,0,65535,0,0,0]),96],rfc6052:[new w([100,65435,0,0,0,0,0,0]),96],"6to4":[new w([8194,0,0,0,0,0,0,0]),16],teredo:[new w([8193,0,0,0,0,0,0,0]),32],benchmarking:[new w([8193,2,0,0,0,0,0,0]),48],amt:[new w([8193,3,0,0,0,0,0,0]),32],as112v6:[[new w([8193,4,274,0,0,0,0,0]),48],[new w([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new w([8193,16,0,0,0,0,0,0]),28],orchid2:[new w([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new w([8193,48,0,0,0,0,0,0]),28],reserved:[[new w([8193,0,0,0,0,0,0,0]),23],[new w([8193,3512,0,0,0,0,0,0]),32]]},w.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},w.prototype.kind=function(){return"ipv6"},w.prototype.match=function(A,C){let k;if(C===void 0&&(k=A,A=k[0],C=k[1]),A.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return x(this.parts,A.parts,16,C)},w.prototype.prefixLengthFromSubnetMask=function(){let A=0,C=!1;const k={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let P,$;for(let Ae=7;Ae>=0;Ae-=1)if(P=this.parts[Ae],P in k){if($=k[P],C&&$!==0)return null;$!==16&&(C=!0),A+=$}else return null;return 128-A},w.prototype.range=function(){return j.subnetMatch(this,this.SpecialRanges)},w.prototype.toByteArray=function(){let A;const C=[],k=this.parts;for(let P=0;P<k.length;P++)A=k[P],C.push(A>>8),C.push(A&255);return C},w.prototype.toFixedLengthString=function(){const A=(function(){const k=[];for(let P=0;P<this.parts.length;P++)k.push(J(this.parts[P].toString(16),4));return k}).call(this).join(":");let C="";return this.zoneId&&(C=`%${this.zoneId}`),A+C},w.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const A=this.parts.slice(-2),C=A[0],k=A[1];return new j.IPv4([C>>8,C&255,k>>8,k&255])},w.prototype.toNormalizedString=function(){const A=(function(){const k=[];for(let P=0;P<this.parts.length;P++)k.push(this.parts[P].toString(16));return k}).call(this).join(":");let C="";return this.zoneId&&(C=`%${this.zoneId}`),A+C},w.prototype.toRFC5952String=function(){const A=/((^|:)(0(:|$)){2,})/g,C=this.toNormalizedString();let k=0,P=-1,$;for(;$=A.exec(C);)$[0].length>P&&(k=$.index,P=$[0].length);return P<0?C:`${C.substring(0,k)}::${C.substring(k+P)}`},w.prototype.toString=function(){return this.toRFC5952String()},w}(),j.IPv6.broadcastAddressFromCIDR=function(w){try{const A=this.parseCIDR(w),C=A[0].toByteArray(),k=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[];let $=0;for(;$<16;)P.push(parseInt(C[$],10)|parseInt(k[$],10)^255),$++;return new this(P)}catch(A){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${A})`)}},j.IPv6.isIPv6=function(w){return this.parser(w)!==null},j.IPv6.isValid=function(w){if(typeof w=="string"&&w.indexOf(":")===-1)return!1;try{const A=this.parser(w);return new this(A.parts,A.zoneId),!0}catch{return!1}},j.IPv6.isValidCIDR=function(w){if(typeof w=="string"&&w.indexOf(":")===-1)return!1;try{return this.parseCIDR(w),!0}catch{return!1}},j.IPv6.networkAddressFromCIDR=function(w){let A,C,k,P,$;try{for(A=this.parseCIDR(w),k=A[0].toByteArray(),$=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[],C=0;C<16;)P.push(parseInt(k[C],10)&parseInt($[C],10)),C++;return new this(P)}catch(Ae){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${Ae})`)}},j.IPv6.parse=function(w){const A=this.parser(w);if(A.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(A.parts,A.zoneId)},j.IPv6.parseCIDR=function(w){let A,C,k;if((C=w.match(/^(.+)\/(\d+)$/))&&(A=parseInt(C[2]),A>=0&&A<=128))return k=[this.parse(C[1]),A],Object.defineProperty(k,"toString",{value:function(){return this.join("/")}}),k;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},j.IPv6.parser=function(w){let A,C,k,P,$,Ae;if(k=w.match(u.deprecatedTransitional))return this.parser(`::ffff:${k[1]}`);if(u.native.test(w))return d(w,8);if((k=w.match(u.transitional))&&(Ae=k[6]||"",A=k[1],k[1].endsWith("::")||(A=A.slice(0,-1)),A=d(A+Ae,6),A.parts)){for($=[parseInt(k[2]),parseInt(k[3]),parseInt(k[4]),parseInt(k[5])],C=0;C<$.length;C++)if(P=$[C],!(0<=P&&P<=255))return null;return A.parts.push($[0]<<8|$[1]),A.parts.push($[2]<<8|$[3]),{parts:A.parts,zoneId:A.zoneId}}return null},j.IPv6.subnetMaskFromPrefixLength=function(w){if(w=parseInt(w),w<0||w>128)throw new Error("ipaddr: invalid IPv6 prefix length");const A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let C=0;const k=Math.floor(w/8);for(;C<k;)A[C]=255,C++;return k<16&&(A[k]=Math.pow(2,w%8)-1<<8-w%8),new this(A)},j.fromByteArray=function(w){const A=w.length;if(A===4)return new j.IPv4(w);if(A===16)return new j.IPv6(w);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},j.isValid=function(w){return j.IPv6.isValid(w)||j.IPv4.isValid(w)},j.isValidCIDR=function(w){return j.IPv6.isValidCIDR(w)||j.IPv4.isValidCIDR(w)},j.parse=function(w){if(j.IPv6.isValid(w))return j.IPv6.parse(w);if(j.IPv4.isValid(w))return j.IPv4.parse(w);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},j.parseCIDR=function(w){try{return j.IPv6.parseCIDR(w)}catch{try{return j.IPv4.parseCIDR(w)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},j.process=function(w){const A=this.parse(w);return A.kind()==="ipv6"&&A.isIPv4MappedAddress()?A.toIPv4Address():A},j.subnetMatch=function(w,A,C){let k,P,$,Ae;C==null&&(C="unicast");for(P in A)if(Object.prototype.hasOwnProperty.call(A,P)){for($=A[P],$[0]&&!($[0]instanceof Array)&&($=[$]),k=0;k<$.length;k++)if(Ae=$[k],w.kind()===Ae[0].kind()&&w.match.apply(w,Ae))return P}return C},r.exports?r.exports=j:e.ipaddr=j})(Bt)})(Ph);var Uh=Ph.exports;class Dh{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0);let n=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const t=new Uint8Array(e);return Uh.fromByteArray(Array.from(t)).toString()}return this.decodeIP(de.ToHex(e))}static fromString(e){const t=Uh.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var rl,nl,il;let Wt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};f([g({type:_.TeletexString})],Wt.prototype,"teletexString",void 0),f([g({type:_.PrintableString})],Wt.prototype,"printableString",void 0),f([g({type:_.UniversalString})],Wt.prototype,"universalString",void 0),f([g({type:_.Utf8String})],Wt.prototype,"utf8String",void 0),f([g({type:_.BmpString})],Wt.prototype,"bmpString",void 0),Wt=f([z({type:V.Choice})],Wt);let Ji=class extends Wt{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?de.ToHex(this.anyValue):super.toString())}};f([g({type:_.IA5String})],Ji.prototype,"ia5String",void 0),f([g({type:_.Any})],Ji.prototype,"anyValue",void 0),Ji=f([z({type:V.Choice})],Ji);class ea{constructor(e={}){this.type="",this.value=new Ji,Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],ea.prototype,"type",void 0),f([g({type:Ji})],ea.prototype,"value",void 0);let Xi=rl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,rl.prototype)}};Xi=rl=f([z({type:V.Set,itemType:ea})],Xi);let sl=nl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,nl.prototype)}};sl=nl=f([z({type:V.Sequence,itemType:Xi})],sl);let Ft=il=class extends sl{constructor(e){super(e),Object.setPrototypeOf(this,il.prototype)}};Ft=il=f([z({type:V.Sequence})],Ft);const X0={fromASN:r=>Dh.toString(Qo.fromASN(r)),toASN:r=>Qo.toASN(Dh.fromString(r))};class Ns{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],Ns.prototype,"typeId",void 0),f([g({type:_.Any,context:0})],Ns.prototype,"value",void 0);class ol{constructor(e={}){this.partyName=new Wt,Object.assign(this,e)}}f([g({type:Wt,optional:!0,context:0,implicit:!0})],ol.prototype,"nameAssigner",void 0),f([g({type:Wt,context:1,implicit:!0})],ol.prototype,"partyName",void 0);let je=class{constructor(e={}){Object.assign(this,e)}};f([g({type:Ns,context:0,implicit:!0})],je.prototype,"otherName",void 0),f([g({type:_.IA5String,context:1,implicit:!0})],je.prototype,"rfc822Name",void 0),f([g({type:_.IA5String,context:2,implicit:!0})],je.prototype,"dNSName",void 0),f([g({type:_.Any,context:3,implicit:!0})],je.prototype,"x400Address",void 0),f([g({type:Ft,context:4,implicit:!1})],je.prototype,"directoryName",void 0),f([g({type:ol,context:5})],je.prototype,"ediPartyName",void 0),f([g({type:_.IA5String,context:6,implicit:!0})],je.prototype,"uniformResourceIdentifier",void 0),f([g({type:_.OctetString,context:7,implicit:!0,converter:X0})],je.prototype,"iPAddress",void 0),f([g({type:_.ObjectIdentifier,context:8,implicit:!0})],je.prototype,"registeredID",void 0),je=f([z({type:V.Choice})],je);const al="1.3.6.1.5.5.7",Q0=`${al}.1`,Qi=`${al}.3`,ta=`${al}.48`,$h=`${ta}.1`,Mh=`${ta}.2`,Vh=`${ta}.3`,Lh=`${ta}.5`,Mn="2.5.29";var cl;const ll=`${Q0}.1`;class js{constructor(e={}){this.accessMethod="",this.accessLocation=new je,Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],js.prototype,"accessMethod",void 0),f([g({type:je})],js.prototype,"accessLocation",void 0);let es=cl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,cl.prototype)}};es=cl=f([z({type:V.Sequence,itemType:js})],es);const ra=`${Mn}.35`;class ul extends rt{}class xi{constructor(e={}){e&&Object.assign(this,e)}}f([g({type:ul,context:0,optional:!0,implicit:!0})],xi.prototype,"keyIdentifier",void 0),f([g({type:je,context:1,optional:!0,implicit:!0,repeated:"sequence"})],xi.prototype,"authorityCertIssuer",void 0),f([g({type:_.Integer,context:2,optional:!0,implicit:!0,converter:At})],xi.prototype,"authorityCertSerialNumber",void 0);const Hh=`${Mn}.19`;class na{constructor(e={}){this.cA=!1,Object.assign(this,e)}}f([g({type:_.Boolean,defaultValue:!1})],na.prototype,"cA",void 0),f([g({type:_.Integer,optional:!0})],na.prototype,"pathLenConstraint",void 0);var fl;let cr=fl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,fl.prototype)}};cr=fl=f([z({type:V.Sequence,itemType:je})],cr);var hl;let Fh=hl=class extends cr{constructor(e){super(e),Object.setPrototypeOf(this,hl.prototype)}};Fh=hl=f([z({type:V.Sequence})],Fh);var dl;const Gh=`${Mn}.32`;let En=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};f([g({type:_.IA5String})],En.prototype,"ia5String",void 0),f([g({type:_.VisibleString})],En.prototype,"visibleString",void 0),f([g({type:_.BmpString})],En.prototype,"bmpString",void 0),f([g({type:_.Utf8String})],En.prototype,"utf8String",void 0),En=f([z({type:V.Choice})],En);class pl{constructor(e={}){this.organization=new En,this.noticeNumbers=[],Object.assign(this,e)}}f([g({type:En})],pl.prototype,"organization",void 0),f([g({type:_.Integer,repeated:"sequence"})],pl.prototype,"noticeNumbers",void 0);class yl{constructor(e={}){Object.assign(this,e)}}f([g({type:pl,optional:!0})],yl.prototype,"noticeRef",void 0),f([g({type:En,optional:!0})],yl.prototype,"explicitText",void 0);let ia=class{constructor(e={}){Object.assign(this,e)}};f([g({type:_.IA5String})],ia.prototype,"cPSuri",void 0),f([g({type:yl})],ia.prototype,"userNotice",void 0),ia=f([z({type:V.Choice})],ia);class gl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],gl.prototype,"policyQualifierId",void 0),f([g({type:_.Any})],gl.prototype,"qualifier",void 0);class sa{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],sa.prototype,"policyIdentifier",void 0),f([g({type:gl,repeated:"sequence",optional:!0})],sa.prototype,"policyQualifiers",void 0);let oa=dl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,dl.prototype)}};oa=dl=f([z({type:V.Sequence,itemType:sa})],oa);let aa=class{constructor(e=0){this.value=e}};f([g({type:_.Integer})],aa.prototype,"value",void 0),aa=f([z({type:V.Choice})],aa);let zh=class extends aa{};zh=f([z({type:V.Choice})],zh);var vl;const ml=`${Mn}.31`;var Mr;(function(r){r[r.unused=1]="unused",r[r.keyCompromise=2]="keyCompromise",r[r.cACompromise=4]="cACompromise",r[r.affiliationChanged=8]="affiliationChanged",r[r.superseded=16]="superseded",r[r.cessationOfOperation=32]="cessationOfOperation",r[r.certificateHold=64]="certificateHold",r[r.privilegeWithdrawn=128]="privilegeWithdrawn",r[r.aACompromise=256]="aACompromise"})(Mr||(Mr={}));class Zh extends Xo{toJSON(){const e=[],t=this.toNumber();return t&Mr.aACompromise&&e.push("aACompromise"),t&Mr.affiliationChanged&&e.push("affiliationChanged"),t&Mr.cACompromise&&e.push("cACompromise"),t&Mr.certificateHold&&e.push("certificateHold"),t&Mr.cessationOfOperation&&e.push("cessationOfOperation"),t&Mr.keyCompromise&&e.push("keyCompromise"),t&Mr.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&Mr.superseded&&e.push("superseded"),t&Mr.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let Ai=class{constructor(e={}){Object.assign(this,e)}};f([g({type:je,context:0,repeated:"sequence",implicit:!0})],Ai.prototype,"fullName",void 0),f([g({type:Xi,context:1,implicit:!0})],Ai.prototype,"nameRelativeToCRLIssuer",void 0),Ai=f([z({type:V.Choice})],Ai);class ts{constructor(e={}){Object.assign(this,e)}}f([g({type:Ai,context:0,optional:!0})],ts.prototype,"distributionPoint",void 0),f([g({type:Zh,context:1,optional:!0,implicit:!0})],ts.prototype,"reasons",void 0),f([g({type:je,context:2,optional:!0,repeated:"sequence",implicit:!0})],ts.prototype,"cRLIssuer",void 0);let rs=vl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,vl.prototype)}};rs=vl=f([z({type:V.Sequence,itemType:ts})],rs);var wl;let Kh=wl=class extends rs{constructor(e){super(e),Object.setPrototypeOf(this,wl.prototype)}};Kh=wl=f([z({type:V.Sequence,itemType:ts})],Kh);class er{constructor(e={}){this.onlyContainsUserCerts=er.ONLY,this.onlyContainsCACerts=er.ONLY,this.indirectCRL=er.ONLY,this.onlyContainsAttributeCerts=er.ONLY,Object.assign(this,e)}}er.ONLY=!1,f([g({type:Ai,context:0,optional:!0})],er.prototype,"distributionPoint",void 0),f([g({type:_.Boolean,context:1,defaultValue:er.ONLY,implicit:!0})],er.prototype,"onlyContainsUserCerts",void 0),f([g({type:_.Boolean,context:2,defaultValue:er.ONLY,implicit:!0})],er.prototype,"onlyContainsCACerts",void 0),f([g({type:Zh,context:3,optional:!0,implicit:!0})],er.prototype,"onlySomeReasons",void 0),f([g({type:_.Boolean,context:4,defaultValue:er.ONLY,implicit:!0})],er.prototype,"indirectCRL",void 0),f([g({type:_.Boolean,context:5,defaultValue:er.ONLY,implicit:!0})],er.prototype,"onlyContainsAttributeCerts",void 0);var Rs;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(Rs||(Rs={}));let bl=class{constructor(e=Rs.unspecified){this.reason=Rs.unspecified,this.reason=e}toJSON(){return Rs[this.reason]}toString(){return this.toJSON()}};f([g({type:_.Enumerated})],bl.prototype,"reason",void 0),bl=f([z({type:V.Choice})],bl);var xl;const Wh=`${Mn}.37`;let ca=xl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,xl.prototype)}};ca=xl=f([z({type:V.Sequence,itemType:_.ObjectIdentifier})],ca);const eg=`${Qi}.1`,tg=`${Qi}.2`,rg=`${Qi}.3`,ng=`${Qi}.4`,ig=`${Qi}.8`,sg=`${Qi}.9`;let Al=class{constructor(e=new ArrayBuffer(0)){this.value=e}};f([g({type:_.Integer,converter:At})],Al.prototype,"value",void 0),Al=f([z({type:V.Choice})],Al);let _l=class{constructor(e){this.value=new Date,e&&(this.value=e)}};f([g({type:_.GeneralizedTime})],_l.prototype,"value",void 0),_l=f([z({type:V.Choice})],_l);var Sl;let qh=Sl=class extends cr{constructor(e){super(e),Object.setPrototypeOf(this,Sl.prototype)}};qh=Sl=f([z({type:V.Sequence})],qh);const Yh=`${Mn}.15`;var Vr;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Vr||(Vr={}));class El extends Xo{toJSON(){const e=this.toNumber(),t=[];return e&Vr.cRLSign&&t.push("crlSign"),e&Vr.dataEncipherment&&t.push("dataEncipherment"),e&Vr.decipherOnly&&t.push("decipherOnly"),e&Vr.digitalSignature&&t.push("digitalSignature"),e&Vr.encipherOnly&&t.push("encipherOnly"),e&Vr.keyAgreement&&t.push("keyAgreement"),e&Vr.keyCertSign&&t.push("keyCertSign"),e&Vr.keyEncipherment&&t.push("keyEncipherment"),e&Vr.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var Il;class la{constructor(e={}){this.base=new je,this.minimum=0,Object.assign(this,e)}}f([g({type:je})],la.prototype,"base",void 0),f([g({type:_.Integer,context:0,defaultValue:0,implicit:!0})],la.prototype,"minimum",void 0),f([g({type:_.Integer,context:1,optional:!0,implicit:!0})],la.prototype,"maximum",void 0);let ua=Il=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Il.prototype)}};ua=Il=f([z({type:V.Sequence,itemType:la})],ua);class Jh{constructor(e={}){Object.assign(this,e)}}f([g({type:ua,context:0,optional:!0,implicit:!0})],Jh.prototype,"permittedSubtrees",void 0),f([g({type:ua,context:1,optional:!0,implicit:!0})],Jh.prototype,"excludedSubtrees",void 0);class Xh{constructor(e={}){Object.assign(this,e)}}f([g({type:_.Integer,context:0,implicit:!0,optional:!0,converter:At})],Xh.prototype,"requireExplicitPolicy",void 0),f([g({type:_.Integer,context:1,implicit:!0,optional:!0,converter:At})],Xh.prototype,"inhibitPolicyMapping",void 0);var kl;class Cl{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],Cl.prototype,"issuerDomainPolicy",void 0),f([g({type:_.ObjectIdentifier})],Cl.prototype,"subjectDomainPolicy",void 0);let Qh=kl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,kl.prototype)}};Qh=kl=f([z({type:V.Sequence,itemType:Cl})],Qh);var Bl;const Ol=`${Mn}.17`;let Tl=Bl=class extends cr{constructor(e){super(e),Object.setPrototypeOf(this,Bl.prototype)}};Tl=Bl=f([z({type:V.Sequence})],Tl);let In=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};f([g({type:_.ObjectIdentifier})],In.prototype,"type",void 0),f([g({type:_.Any,repeated:"set"})],In.prototype,"values",void 0);var Nl;let ed=Nl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Nl.prototype)}};ed=Nl=f([z({type:V.Sequence,itemType:In})],ed);const jl=`${Mn}.14`;class Vn extends ul{}class td{constructor(e={}){Object.assign(this,e)}}f([g({type:_.GeneralizedTime,context:0,implicit:!0,optional:!0})],td.prototype,"notBefore",void 0),f([g({type:_.GeneralizedTime,context:1,implicit:!0,optional:!0})],td.prototype,"notAfter",void 0);var Ps;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Ps||(Ps={}));class rd extends Xo{toJSON(){const e=[],t=this.toNumber();return t&Ps.pKIXCertificate&&e.push("pKIXCertificate"),t&Ps.newExtensions&&e.push("newExtensions"),t&Ps.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class nd{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new rd,Object.assign(this,e)}}f([g({type:_.GeneralString})],nd.prototype,"entrustVers",void 0),f([g({type:rd})],nd.prototype,"entrustInfoFlags",void 0);var Rl;let id=Rl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Rl.prototype)}};id=Rl=f([z({type:V.Sequence,itemType:js})],id);class oe{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof oe&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&jo(e.parameters,this.parameters)||e.parameters===this.parameters)}}f([g({type:_.ObjectIdentifier})],oe.prototype,"algorithm",void 0),f([g({type:_.Any,optional:!0})],oe.prototype,"parameters",void 0);class en{constructor(e={}){this.algorithm=new oe,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:oe})],en.prototype,"algorithm",void 0),f([g({type:_.BitString})],en.prototype,"subjectPublicKey",void 0);let qt=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};f([g({type:_.UTCTime})],qt.prototype,"utcTime",void 0),f([g({type:_.GeneralizedTime})],qt.prototype,"generalTime",void 0),qt=f([z({type:V.Choice})],qt);class fa{constructor(e){this.notBefore=new qt(new Date),this.notAfter=new qt(new Date),e&&(this.notBefore=new qt(e.notBefore),this.notAfter=new qt(e.notAfter))}}f([g({type:qt})],fa.prototype,"notBefore",void 0),f([g({type:qt})],fa.prototype,"notAfter",void 0);var Pl;let Lr=class Vy{constructor(e={}){this.extnID="",this.critical=Vy.CRITICAL,this.extnValue=new rt,Object.assign(this,e)}};Lr.CRITICAL=!1,f([g({type:_.ObjectIdentifier})],Lr.prototype,"extnID",void 0),f([g({type:_.Boolean,defaultValue:Lr.CRITICAL})],Lr.prototype,"critical",void 0),f([g({type:rt})],Lr.prototype,"extnValue",void 0);let _i=Pl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Pl.prototype)}};_i=Pl=f([z({type:V.Sequence,itemType:Lr})],_i);var ns;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(ns||(ns={}));class Nr{constructor(e={}){this.version=ns.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new oe,this.issuer=new Ft,this.validity=new fa,this.subject=new Ft,this.subjectPublicKeyInfo=new en,Object.assign(this,e)}}f([g({type:_.Integer,context:0,defaultValue:ns.v1})],Nr.prototype,"version",void 0),f([g({type:_.Integer,converter:At})],Nr.prototype,"serialNumber",void 0),f([g({type:oe})],Nr.prototype,"signature",void 0),f([g({type:Ft})],Nr.prototype,"issuer",void 0),f([g({type:fa})],Nr.prototype,"validity",void 0),f([g({type:Ft})],Nr.prototype,"subject",void 0),f([g({type:en})],Nr.prototype,"subjectPublicKeyInfo",void 0),f([g({type:_.BitString,context:1,implicit:!0,optional:!0})],Nr.prototype,"issuerUniqueID",void 0),f([g({type:_.BitString,context:2,implicit:!0,optional:!0})],Nr.prototype,"subjectUniqueID",void 0),f([g({type:_i,context:3,optional:!0})],Nr.prototype,"extensions",void 0);class Si{constructor(e={}){this.tbsCertificate=new Nr,this.signatureAlgorithm=new oe,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:Nr})],Si.prototype,"tbsCertificate",void 0),f([g({type:oe})],Si.prototype,"signatureAlgorithm",void 0),f([g({type:_.BitString})],Si.prototype,"signatureValue",void 0);class ha{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new qt,Object.assign(this,e)}}f([g({type:_.Integer,converter:At})],ha.prototype,"userCertificate",void 0),f([g({type:qt})],ha.prototype,"revocationDate",void 0),f([g({type:Lr,optional:!0,repeated:"sequence"})],ha.prototype,"crlEntryExtensions",void 0);class kn{constructor(e={}){this.signature=new oe,this.issuer=new Ft,this.thisUpdate=new qt,Object.assign(this,e)}}f([g({type:_.Integer,optional:!0})],kn.prototype,"version",void 0),f([g({type:oe})],kn.prototype,"signature",void 0),f([g({type:Ft})],kn.prototype,"issuer",void 0),f([g({type:qt})],kn.prototype,"thisUpdate",void 0),f([g({type:qt,optional:!0})],kn.prototype,"nextUpdate",void 0),f([g({type:ha,repeated:"sequence",optional:!0})],kn.prototype,"revokedCertificates",void 0),f([g({type:Lr,optional:!0,context:0,repeated:"sequence"})],kn.prototype,"crlExtensions",void 0);class Ul{constructor(e={}){this.tbsCertList=new kn,this.signatureAlgorithm=new oe,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:kn})],Ul.prototype,"tbsCertList",void 0),f([g({type:oe})],Ul.prototype,"signatureAlgorithm",void 0),f([g({type:_.BitString})],Ul.prototype,"signature",void 0);class is{constructor(e={}){this.issuer=new Ft,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:Ft})],is.prototype,"issuer",void 0),f([g({type:_.Integer,converter:At})],is.prototype,"serialNumber",void 0);let ss=class{constructor(e={}){Object.assign(this,e)}};f([g({type:Vn,context:0,implicit:!0})],ss.prototype,"subjectKeyIdentifier",void 0),f([g({type:is})],ss.prototype,"issuerAndSerialNumber",void 0),ss=f([z({type:V.Choice})],ss);var tn;(function(r){r[r.v0=0]="v0",r[r.v1=1]="v1",r[r.v2=2]="v2",r[r.v3=3]="v3",r[r.v4=4]="v4",r[r.v5=5]="v5"})(tn||(tn={}));let Us=class extends oe{};Us=f([z({type:V.Sequence})],Us);let da=class extends oe{};da=f([z({type:V.Sequence})],da);let rn=class extends oe{};rn=f([z({type:V.Sequence})],rn);let pa=class extends oe{};pa=f([z({type:V.Sequence})],pa);let sd=class extends oe{};sd=f([z({type:V.Sequence})],sd);let Dl=class extends oe{};Dl=f([z({type:V.Sequence})],Dl);let os=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};f([g({type:_.ObjectIdentifier})],os.prototype,"attrType",void 0),f([g({type:_.Any,repeated:"set"})],os.prototype,"attrValues",void 0);var $l;class nn{constructor(e={}){this.version=tn.v0,this.sid=new ss,this.digestAlgorithm=new Us,this.signatureAlgorithm=new da,this.signature=new rt,Object.assign(this,e)}}f([g({type:_.Integer})],nn.prototype,"version",void 0),f([g({type:ss})],nn.prototype,"sid",void 0),f([g({type:Us})],nn.prototype,"digestAlgorithm",void 0),f([g({type:os,repeated:"set",context:0,implicit:!0,optional:!0})],nn.prototype,"signedAttrs",void 0),f([g({type:da})],nn.prototype,"signatureAlgorithm",void 0),f([g({type:rt})],nn.prototype,"signature",void 0),f([g({type:os,repeated:"set",context:1,implicit:!0,optional:!0})],nn.prototype,"unsignedAttrs",void 0);let ya=$l=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,$l.prototype)}};ya=$l=f([z({type:V.Set,itemType:nn})],ya);let od=class extends qt{};od=f([z({type:V.Choice})],od);let ad=class extends nn{};ad=f([z({type:V.Sequence})],ad);class Ml{constructor(e={}){this.acIssuer=new je,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}f([g({type:je})],Ml.prototype,"acIssuer",void 0),f([g({type:_.Integer})],Ml.prototype,"acSerial",void 0),f([g({type:In,repeated:"sequence"})],Ml.prototype,"attrs",void 0);var Vl;let ga=Vl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Vl.prototype)}};ga=Vl=f([z({type:V.Sequence,itemType:_.ObjectIdentifier})],ga);class va{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}f([g({type:_.Integer,optional:!0})],va.prototype,"pathLenConstraint",void 0),f([g({type:ga,implicit:!0,context:0,optional:!0})],va.prototype,"permittedAttrs",void 0),f([g({type:ga,implicit:!0,context:1,optional:!0})],va.prototype,"excludedAttrs",void 0),f([g({type:_.Boolean,defaultValue:!0})],va.prototype,"permitUnSpecified",void 0);class Ei{constructor(e={}){this.issuer=new cr,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:cr})],Ei.prototype,"issuer",void 0),f([g({type:_.Integer,converter:At})],Ei.prototype,"serial",void 0),f([g({type:_.BitString,optional:!0})],Ei.prototype,"issuerUID",void 0);var Ll;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(Ll||(Ll={}));class Ii{constructor(e={}){this.digestedObjectType=Ll.publicKey,this.digestAlgorithm=new oe,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.Enumerated})],Ii.prototype,"digestedObjectType",void 0),f([g({type:_.ObjectIdentifier,optional:!0})],Ii.prototype,"otherObjectTypeID",void 0),f([g({type:oe})],Ii.prototype,"digestAlgorithm",void 0),f([g({type:_.BitString})],Ii.prototype,"objectDigest",void 0);class ma{constructor(e={}){Object.assign(this,e)}}f([g({type:cr,optional:!0})],ma.prototype,"issuerName",void 0),f([g({type:Ei,context:0,implicit:!0,optional:!0})],ma.prototype,"baseCertificateID",void 0),f([g({type:Ii,context:1,implicit:!0,optional:!0})],ma.prototype,"objectDigestInfo",void 0);let as=class{constructor(e={}){Object.assign(this,e)}};f([g({type:je,repeated:"sequence"})],as.prototype,"v1Form",void 0),f([g({type:ma,context:0,implicit:!0})],as.prototype,"v2Form",void 0),as=f([z({type:V.Choice})],as);class wa{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}f([g({type:_.GeneralizedTime})],wa.prototype,"notBeforeTime",void 0),f([g({type:_.GeneralizedTime})],wa.prototype,"notAfterTime",void 0);class Ds{constructor(e={}){Object.assign(this,e)}}f([g({type:Ei,implicit:!0,context:0,optional:!0})],Ds.prototype,"baseCertificateID",void 0),f([g({type:cr,implicit:!0,context:1,optional:!0})],Ds.prototype,"entityName",void 0),f([g({type:Ii,implicit:!0,context:2,optional:!0})],Ds.prototype,"objectDigestInfo",void 0);var Hl;(function(r){r[r.v2=1]="v2"})(Hl||(Hl={}));class Hr{constructor(e={}){this.version=Hl.v2,this.holder=new Ds,this.issuer=new as,this.signature=new oe,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new wa,this.attributes=[],Object.assign(this,e)}}f([g({type:_.Integer})],Hr.prototype,"version",void 0),f([g({type:Ds})],Hr.prototype,"holder",void 0),f([g({type:as})],Hr.prototype,"issuer",void 0),f([g({type:oe})],Hr.prototype,"signature",void 0),f([g({type:_.Integer,converter:At})],Hr.prototype,"serialNumber",void 0),f([g({type:wa})],Hr.prototype,"attrCertValidityPeriod",void 0),f([g({type:In,repeated:"sequence"})],Hr.prototype,"attributes",void 0),f([g({type:_.BitString,optional:!0})],Hr.prototype,"issuerUniqueID",void 0),f([g({type:_i,optional:!0})],Hr.prototype,"extensions",void 0);class ba{constructor(e={}){this.acinfo=new Hr,this.signatureAlgorithm=new oe,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:Hr})],ba.prototype,"acinfo",void 0),f([g({type:oe})],ba.prototype,"signatureAlgorithm",void 0),f([g({type:_.BitString})],ba.prototype,"signatureValue",void 0);var xa;(function(r){r[r.unmarked=1]="unmarked",r[r.unclassified=2]="unclassified",r[r.restricted=4]="restricted",r[r.confidential=8]="confidential",r[r.secret=16]="secret",r[r.topSecret=32]="topSecret"})(xa||(xa={}));class Fl extends Xo{}class Gl{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.ObjectIdentifier,implicit:!0,context:0})],Gl.prototype,"type",void 0),f([g({type:_.Any,implicit:!0,context:1})],Gl.prototype,"value",void 0);class zl{constructor(e={}){this.policyId="",this.classList=new Fl(xa.unclassified),Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],zl.prototype,"policyId",void 0),f([g({type:Fl,defaultValue:new Fl(xa.unclassified)})],zl.prototype,"classList",void 0),f([g({type:Gl,repeated:"set"})],zl.prototype,"securityCategories",void 0);class Aa{constructor(e={}){Object.assign(this,e)}}f([g({type:rt})],Aa.prototype,"cotets",void 0),f([g({type:_.ObjectIdentifier})],Aa.prototype,"oid",void 0),f([g({type:_.Utf8String})],Aa.prototype,"string",void 0);class cd{constructor(e={}){this.values=[],Object.assign(this,e)}}f([g({type:cr,implicit:!0,context:0,optional:!0})],cd.prototype,"policyAuthority",void 0),f([g({type:Aa,repeated:"sequence"})],cd.prototype,"values",void 0);var Zl;class _a{constructor(e={}){this.targetCertificate=new Ei,Object.assign(this,e)}}f([g({type:Ei})],_a.prototype,"targetCertificate",void 0),f([g({type:je,optional:!0})],_a.prototype,"targetName",void 0),f([g({type:Ii,optional:!0})],_a.prototype,"certDigestInfo",void 0);let cs=class{constructor(e={}){Object.assign(this,e)}};f([g({type:je,context:0,implicit:!0})],cs.prototype,"targetName",void 0),f([g({type:je,context:1,implicit:!0})],cs.prototype,"targetGroup",void 0),f([g({type:_a,context:2,implicit:!0})],cs.prototype,"targetCert",void 0),cs=f([z({type:V.Choice})],cs);let Kl=Zl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Zl.prototype)}};Kl=Zl=f([z({type:V.Sequence,itemType:cs})],Kl);var Wl;let ld=Wl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Wl.prototype)}};ld=Wl=f([z({type:V.Sequence,itemType:Kl})],ld);class ud{constructor(e={}){Object.assign(this,e)}}f([g({type:cr,implicit:!0,context:0,optional:!0})],ud.prototype,"roleAuthority",void 0),f([g({type:je,implicit:!0,context:1})],ud.prototype,"roleName",void 0);class ql{constructor(e={}){this.service=new je,this.ident=new je,Object.assign(this,e)}}f([g({type:je})],ql.prototype,"service",void 0),f([g({type:je})],ql.prototype,"ident",void 0),f([g({type:rt,optional:!0})],ql.prototype,"authInfo",void 0);var Yl;class Jl{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],Jl.prototype,"otherCertFormat",void 0),f([g({type:_.Any})],Jl.prototype,"otherCert",void 0);let ki=class{constructor(e={}){Object.assign(this,e)}};f([g({type:Si})],ki.prototype,"certificate",void 0),f([g({type:ba,context:2,implicit:!0})],ki.prototype,"v2AttrCert",void 0),f([g({type:Jl,context:3,implicit:!0})],ki.prototype,"other",void 0),ki=f([z({type:V.Choice})],ki);let $s=Yl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Yl.prototype)}};$s=Yl=f([z({type:V.Set,itemType:ki})],$s);class Cn{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],Cn.prototype,"contentType",void 0),f([g({type:_.Any,context:0})],Cn.prototype,"content",void 0);let ls=class{constructor(e={}){Object.assign(this,e)}};f([g({type:rt})],ls.prototype,"single",void 0),f([g({type:_.Any})],ls.prototype,"any",void 0),ls=f([z({type:V.Choice})],ls);class Sa{constructor(e={}){this.eContentType="",Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],Sa.prototype,"eContentType",void 0),f([g({type:ls,context:0,optional:!0})],Sa.prototype,"eContent",void 0);let Ms=class{constructor(e={}){Object.assign(this,e)}};f([g({type:rt,context:0,implicit:!0,optional:!0})],Ms.prototype,"value",void 0),f([g({type:rt,converter:R0,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Ms.prototype,"constructedValue",void 0),Ms=f([z({type:V.Choice})],Ms);class Vs{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new pa,Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],Vs.prototype,"contentType",void 0),f([g({type:pa})],Vs.prototype,"contentEncryptionAlgorithm",void 0),f([g({type:Ms,optional:!0})],Vs.prototype,"encryptedContent",void 0);class Ea{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],Ea.prototype,"keyAttrId",void 0),f([g({type:_.Any,optional:!0})],Ea.prototype,"keyAttr",void 0);var Xl;class Ia{constructor(e={}){this.subjectKeyIdentifier=new Vn,Object.assign(this,e)}}f([g({type:Vn})],Ia.prototype,"subjectKeyIdentifier",void 0),f([g({type:_.GeneralizedTime,optional:!0})],Ia.prototype,"date",void 0),f([g({type:Ea,optional:!0})],Ia.prototype,"other",void 0);let us=class{constructor(e={}){Object.assign(this,e)}};f([g({type:Ia,context:0,implicit:!0,optional:!0})],us.prototype,"rKeyId",void 0),f([g({type:is,optional:!0})],us.prototype,"issuerAndSerialNumber",void 0),us=f([z({type:V.Choice})],us);class Ql{constructor(e={}){this.rid=new us,this.encryptedKey=new rt,Object.assign(this,e)}}f([g({type:us})],Ql.prototype,"rid",void 0),f([g({type:rt})],Ql.prototype,"encryptedKey",void 0);let ka=Xl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Xl.prototype)}};ka=Xl=f([z({type:V.Sequence,itemType:Ql})],ka);class eu{constructor(e={}){this.algorithm=new oe,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:oe})],eu.prototype,"algorithm",void 0),f([g({type:_.BitString})],eu.prototype,"publicKey",void 0);let Ci=class{constructor(e={}){Object.assign(this,e)}};f([g({type:Vn,context:0,implicit:!0,optional:!0})],Ci.prototype,"subjectKeyIdentifier",void 0),f([g({type:eu,context:1,implicit:!0,optional:!0})],Ci.prototype,"originatorKey",void 0),f([g({type:is,optional:!0})],Ci.prototype,"issuerAndSerialNumber",void 0),Ci=f([z({type:V.Choice})],Ci);class fs{constructor(e={}){this.version=tn.v3,this.originator=new Ci,this.keyEncryptionAlgorithm=new rn,this.recipientEncryptedKeys=new ka,Object.assign(this,e)}}f([g({type:_.Integer})],fs.prototype,"version",void 0),f([g({type:Ci,context:0})],fs.prototype,"originator",void 0),f([g({type:rt,context:1,optional:!0})],fs.prototype,"ukm",void 0),f([g({type:rn})],fs.prototype,"keyEncryptionAlgorithm",void 0),f([g({type:ka})],fs.prototype,"recipientEncryptedKeys",void 0);let hs=class{constructor(e={}){Object.assign(this,e)}};f([g({type:Vn,context:0,implicit:!0})],hs.prototype,"subjectKeyIdentifier",void 0),f([g({type:is})],hs.prototype,"issuerAndSerialNumber",void 0),hs=f([z({type:V.Choice})],hs);class Ls{constructor(e={}){this.version=tn.v0,this.rid=new hs,this.keyEncryptionAlgorithm=new rn,this.encryptedKey=new rt,Object.assign(this,e)}}f([g({type:_.Integer})],Ls.prototype,"version",void 0),f([g({type:hs})],Ls.prototype,"rid",void 0),f([g({type:rn})],Ls.prototype,"keyEncryptionAlgorithm",void 0),f([g({type:rt})],Ls.prototype,"encryptedKey",void 0);class Hs{constructor(e={}){this.keyIdentifier=new rt,Object.assign(this,e)}}f([g({type:rt})],Hs.prototype,"keyIdentifier",void 0),f([g({type:_.GeneralizedTime,optional:!0})],Hs.prototype,"date",void 0),f([g({type:Ea,optional:!0})],Hs.prototype,"other",void 0);class Fs{constructor(e={}){this.version=tn.v4,this.kekid=new Hs,this.keyEncryptionAlgorithm=new rn,this.encryptedKey=new rt,Object.assign(this,e)}}f([g({type:_.Integer})],Fs.prototype,"version",void 0),f([g({type:Hs})],Fs.prototype,"kekid",void 0),f([g({type:rn})],Fs.prototype,"keyEncryptionAlgorithm",void 0),f([g({type:rt})],Fs.prototype,"encryptedKey",void 0);class Gs{constructor(e={}){this.version=tn.v0,this.keyEncryptionAlgorithm=new rn,this.encryptedKey=new rt,Object.assign(this,e)}}f([g({type:_.Integer})],Gs.prototype,"version",void 0),f([g({type:Dl,context:0,optional:!0})],Gs.prototype,"keyDerivationAlgorithm",void 0),f([g({type:rn})],Gs.prototype,"keyEncryptionAlgorithm",void 0),f([g({type:rt})],Gs.prototype,"encryptedKey",void 0);class tu{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],tu.prototype,"oriType",void 0),f([g({type:_.Any})],tu.prototype,"oriValue",void 0);let Ln=class{constructor(e={}){Object.assign(this,e)}};f([g({type:Ls,optional:!0})],Ln.prototype,"ktri",void 0),f([g({type:fs,context:1,implicit:!0,optional:!0})],Ln.prototype,"kari",void 0),f([g({type:Fs,context:2,implicit:!0,optional:!0})],Ln.prototype,"kekri",void 0),f([g({type:Gs,context:3,implicit:!0,optional:!0})],Ln.prototype,"pwri",void 0),f([g({type:tu,context:4,implicit:!0,optional:!0})],Ln.prototype,"ori",void 0),Ln=f([z({type:V.Choice})],Ln);var ru;let Ca=ru=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,ru.prototype)}};Ca=ru=f([z({type:V.Set,itemType:Ln})],Ca);var nu;class Ba{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],Ba.prototype,"otherRevInfoFormat",void 0),f([g({type:_.Any})],Ba.prototype,"otherRevInfo",void 0);let Oa=class{constructor(e={}){this.other=new Ba,Object.assign(this,e)}};f([g({type:Ba,context:1,implicit:!0})],Oa.prototype,"other",void 0),Oa=f([z({type:V.Choice})],Oa);let Ta=nu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,nu.prototype)}};Ta=nu=f([z({type:V.Set,itemType:Oa})],Ta);class iu{constructor(e={}){Object.assign(this,e)}}f([g({type:$s,context:0,implicit:!0,optional:!0})],iu.prototype,"certs",void 0),f([g({type:Ta,context:1,implicit:!0,optional:!0})],iu.prototype,"crls",void 0);var su;let ou=su=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,su.prototype)}};ou=su=f([z({type:V.Set,itemType:os})],ou);class zs{constructor(e={}){this.version=tn.v0,this.recipientInfos=new Ca,this.encryptedContentInfo=new Vs,Object.assign(this,e)}}f([g({type:_.Integer})],zs.prototype,"version",void 0),f([g({type:iu,context:0,implicit:!0,optional:!0})],zs.prototype,"originatorInfo",void 0),f([g({type:Ca})],zs.prototype,"recipientInfos",void 0),f([g({type:Vs})],zs.prototype,"encryptedContentInfo",void 0),f([g({type:ou,context:1,implicit:!0,optional:!0})],zs.prototype,"unprotectedAttrs",void 0);const og="1.2.840.113549.1.7.1",au="1.2.840.113549.1.7.2";var cu;let Na=cu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,cu.prototype)}};Na=cu=f([z({type:V.Set,itemType:Us})],Na);class Bn{constructor(e={}){this.version=tn.v0,this.digestAlgorithms=new Na,this.encapContentInfo=new Sa,this.signerInfos=new ya,Object.assign(this,e)}}f([g({type:_.Integer})],Bn.prototype,"version",void 0),f([g({type:Na})],Bn.prototype,"digestAlgorithms",void 0),f([g({type:Sa})],Bn.prototype,"encapContentInfo",void 0),f([g({type:$s,context:0,implicit:!0,optional:!0})],Bn.prototype,"certificates",void 0),f([g({type:Ta,context:1,implicit:!0,optional:!0})],Bn.prototype,"crls",void 0),f([g({type:ya})],Bn.prototype,"signerInfos",void 0);const Zs="1.2.840.10045.2.1",lu="1.2.840.10045.4.1",fd="1.2.840.10045.4.3.1",uu="1.2.840.10045.4.3.2",fu="1.2.840.10045.4.3.3",hu="1.2.840.10045.4.3.4",hd="1.2.840.10045.3.1.7",dd="1.3.132.0.34",pd="1.3.132.0.35";function Ks(r){return new oe({algorithm:r})}const ag=Ks(lu);Ks(fd);const cg=Ks(uu),lg=Ks(fu),ug=Ks(hu);let Ws=class{constructor(e={}){Object.assign(this,e)}};f([g({type:_.ObjectIdentifier})],Ws.prototype,"fieldType",void 0),f([g({type:_.Any})],Ws.prototype,"parameters",void 0),Ws=f([z({type:V.Sequence})],Ws);class fg extends rt{}let ds=class{constructor(e={}){Object.assign(this,e)}};f([g({type:_.OctetString})],ds.prototype,"a",void 0),f([g({type:_.OctetString})],ds.prototype,"b",void 0),f([g({type:_.BitString,optional:!0})],ds.prototype,"seed",void 0),ds=f([z({type:V.Sequence})],ds);var du;(function(r){r[r.ecpVer1=1]="ecpVer1"})(du||(du={}));let On=class{constructor(e={}){this.version=du.ecpVer1,Object.assign(this,e)}};f([g({type:_.Integer})],On.prototype,"version",void 0),f([g({type:Ws})],On.prototype,"fieldID",void 0),f([g({type:ds})],On.prototype,"curve",void 0),f([g({type:fg})],On.prototype,"base",void 0),f([g({type:_.Integer,converter:At})],On.prototype,"order",void 0),f([g({type:_.Integer,optional:!0})],On.prototype,"cofactor",void 0),On=f([z({type:V.Sequence})],On);let Hn=class{constructor(e={}){Object.assign(this,e)}};f([g({type:_.ObjectIdentifier})],Hn.prototype,"namedCurve",void 0),f([g({type:_.Null})],Hn.prototype,"implicitCurve",void 0),f([g({type:On})],Hn.prototype,"specifiedCurve",void 0),Hn=f([z({type:V.Choice})],Hn);class ja{constructor(e={}){this.version=1,this.privateKey=new rt,Object.assign(this,e)}}f([g({type:_.Integer})],ja.prototype,"version",void 0),f([g({type:rt})],ja.prototype,"privateKey",void 0),f([g({type:Hn,context:0,optional:!0})],ja.prototype,"parameters",void 0),f([g({type:_.BitString,context:1,optional:!0})],ja.prototype,"publicKey",void 0);class Ra{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.Integer,converter:At})],Ra.prototype,"r",void 0),f([g({type:_.Integer,converter:At})],Ra.prototype,"s",void 0);const vr="1.2.840.113549.1.1",Bi=`${vr}.1`,hg=`${vr}.7`,dg=`${vr}.9`,qs=`${vr}.10`,pg=`${vr}.2`,yg=`${vr}.4`,Pa=`${vr}.5`,gg=`${vr}.14`,pu=`${vr}.11`,Ua=`${vr}.12`,Da=`${vr}.13`,yd=`${vr}.15`,gd=`${vr}.16`,$a="1.3.14.3.2.26",vd="2.16.840.1.101.3.4.2.4",Ma="2.16.840.1.101.3.4.2.1",Va="2.16.840.1.101.3.4.2.2",La="2.16.840.1.101.3.4.2.3",vg="2.16.840.1.101.3.4.2.5",mg="2.16.840.1.101.3.4.2.6",wg="1.2.840.113549.2.2",bg="1.2.840.113549.2.5",Ha=`${vr}.8`;function Gt(r){return new oe({algorithm:r,parameters:null})}Gt(wg),Gt(bg);const Oi=Gt($a);Gt(vd),Gt(Ma),Gt(Va),Gt(La),Gt(vg),Gt(mg);const md=new oe({algorithm:Ha,parameters:q.serialize(Oi)}),wd=new oe({algorithm:dg,parameters:q.serialize(Qo.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Gt(Bi),Gt(pg),Gt(yg),Gt(Pa),Gt(yd),Gt(gd),Gt(Ua),Gt(Da),Gt(yd),Gt(gd);class Fa{constructor(e={}){this.hashAlgorithm=new oe(Oi),this.maskGenAlgorithm=new oe({algorithm:Ha,parameters:q.serialize(Oi)}),this.pSourceAlgorithm=new oe(wd),Object.assign(this,e)}}f([g({type:oe,context:0,defaultValue:Oi})],Fa.prototype,"hashAlgorithm",void 0),f([g({type:oe,context:1,defaultValue:md})],Fa.prototype,"maskGenAlgorithm",void 0),f([g({type:oe,context:2,defaultValue:wd})],Fa.prototype,"pSourceAlgorithm",void 0),new oe({algorithm:hg,parameters:q.serialize(new Fa)});class Ti{constructor(e={}){this.hashAlgorithm=new oe(Oi),this.maskGenAlgorithm=new oe({algorithm:Ha,parameters:q.serialize(Oi)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}f([g({type:oe,context:0,defaultValue:Oi})],Ti.prototype,"hashAlgorithm",void 0),f([g({type:oe,context:1,defaultValue:md})],Ti.prototype,"maskGenAlgorithm",void 0),f([g({type:_.Integer,context:2,defaultValue:20})],Ti.prototype,"saltLength",void 0),f([g({type:_.Integer,context:3,defaultValue:1})],Ti.prototype,"trailerField",void 0),new oe({algorithm:qs,parameters:q.serialize(new Ti)});class Ga{constructor(e={}){this.digestAlgorithm=new oe,this.digest=new rt,Object.assign(this,e)}}f([g({type:oe})],Ga.prototype,"digestAlgorithm",void 0),f([g({type:rt})],Ga.prototype,"digest",void 0);var yu;class za{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.Integer,converter:At})],za.prototype,"prime",void 0),f([g({type:_.Integer,converter:At})],za.prototype,"exponent",void 0),f([g({type:_.Integer,converter:At})],za.prototype,"coefficient",void 0);let gu=yu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,yu.prototype)}};gu=yu=f([z({type:V.Sequence,itemType:za})],gu);class sn{constructor(e={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.Integer})],sn.prototype,"version",void 0),f([g({type:_.Integer,converter:At})],sn.prototype,"modulus",void 0),f([g({type:_.Integer,converter:At})],sn.prototype,"publicExponent",void 0),f([g({type:_.Integer,converter:At})],sn.prototype,"privateExponent",void 0),f([g({type:_.Integer,converter:At})],sn.prototype,"prime1",void 0),f([g({type:_.Integer,converter:At})],sn.prototype,"prime2",void 0),f([g({type:_.Integer,converter:At})],sn.prototype,"exponent1",void 0),f([g({type:_.Integer,converter:At})],sn.prototype,"exponent2",void 0),f([g({type:_.Integer,converter:At})],sn.prototype,"coefficient",void 0),f([g({type:gu,optional:!0})],sn.prototype,"otherPrimeInfos",void 0);class vu{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.Integer,converter:At})],vu.prototype,"modulus",void 0),f([g({type:_.Integer,converter:At})],vu.prototype,"publicExponent",void 0);var mu;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(mu||(mu={}));const mr=mu;/*! *****************************************************************************
|
|
105
|
+
Copyright (c) Microsoft Corporation.
|
|
106
|
+
|
|
107
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
108
|
+
purpose with or without fee is hereby granted.
|
|
109
|
+
|
|
110
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
111
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
112
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
113
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
114
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
115
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
116
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
117
|
+
***************************************************************************** */var wu=function(r,e){return wu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])},wu(r,e)};function bu(r,e){wu(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function xg(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function c(x){try{d(n.next(x))}catch(I){a(I)}}function u(x){try{d(n.throw(x))}catch(I){a(I)}}function d(x){x.done?s(x.value):i(x.value).then(c,u)}d((n=n.apply(r,[])).next())})}function Ag(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(d){return function(x){return u([d,x])}}function u(d){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=d[0]&2?i.return:d[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,d[1])).done)return s;switch(i=0,s&&(d=[d[0]&2,s.value]),d[0]){case 0:case 1:s=d;break;case 4:return t.label++,{value:d[1],done:!1};case 5:t.label++,i=d[1],d=[0];continue;case 7:d=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(d[0]===6||d[0]===2)){t=0;continue}if(d[0]===3&&(!s||d[1]>s[0]&&d[1]<s[3])){t.label=d[1];break}if(d[0]===6&&t.label<s[1]){t.label=s[1],s=d;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(d);break}s[2]&&t.ops.pop(),t.trys.pop();continue}d=e.call(r,t)}catch(x){d=[6,x],i=0}finally{n=s=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function Za(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ka(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){a={error:c}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s}function Ni(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(Ka(arguments[e]));return r}var _g="injectionTokens";function Sg(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(_g,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function bd(r){return!!r.useClass}function xu(r){return!!r.useFactory}var xd=function(){function r(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return r.prototype.createProxy=function(e){var t=this,n={},i=!1,s,a=function(){return i||(s=e(t.wrap()),i=!0),s};return new Proxy(n,this.createHandler(a))},r.prototype.createHandler=function(e){var t={},n=function(i){t[i]=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];s[0]=e();var c=Reflect[i];return c.apply(void 0,Ni(s))}};return this.reflectMethods.forEach(n),t},r}();function ps(r){return typeof r=="string"||typeof r=="symbol"}function Eg(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function Ad(r){return typeof r=="object"&&"token"in r&&"transform"in r}function Ig(r){return typeof r=="function"||r instanceof xd}function Wa(r){return!!r.useToken}function qa(r){return r.useValue!=null}function kg(r){return bd(r)||qa(r)||Wa(r)||xu(r)}var Au=function(){function r(){this._registryMap=new Map}return r.prototype.entries=function(){return this._registryMap.entries()},r.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},r.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},r.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},r.prototype.setAll=function(e,t){this._registryMap.set(e,t)},r.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},r.prototype.clear=function(){this._registryMap.clear()},r.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},r}(),Cg=function(r){bu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Au),_d=function(){function r(){this.scopedResolutions=new Map}return r}();function Bg(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function Og(r,e,t){return t===void 0&&(t=" "),Ni([r],e.message.split(`
|
|
118
|
+
`).map(function(n){return t+n})).join(`
|
|
119
|
+
`)}function Tg(r,e,t){var n=Ka(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=n[1],s=i===void 0?null:i,a=Bg(s,e);return Og("Cannot inject the dependency "+a+' of "'+r.name+'" constructor. Reason:',t)}function Ng(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var jg=function(r){bu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Au),Rg=function(r){bu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Au),Pg=function(){function r(){this.preResolution=new jg,this.postResolution=new Rg}return r}(),Sd=new Map,Ug=function(){function r(e){this.parent=e,this._registry=new Cg,this.interceptors=new Pg,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:mr.Transient}),this.ensureNotDisposed();var i;if(kg(t)?i=t:i={useClass:t},Wa(i))for(var s=[e],a=i;a!=null;){var c=a.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+Ni(s,[c]).join(" -> "));s.push(c);var u=this._registry.get(c);u&&Wa(u.provider)?a=u.provider:a=null}if((n.lifecycle===mr.Singleton||n.lifecycle==mr.ContainerScoped||n.lifecycle==mr.ResolutionScoped)&&(qa(i)||xu(i)))throw new Error('Cannot use lifecycle "'+mr[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),ps(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},r.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},r.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),ps(e)){if(ps(t))return this.register(e,{useToken:t},{lifecycle:mr.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:mr.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!ps(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:mr.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new _d),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&ps(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),n){var i=this.resolveRegistration(n,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(Ig(e)){var i=this.construct(e,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},r.prototype.executePreResolutionInterceptor=function(e,t){var n,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var a=Za(this.interceptors.preResolution.getAll(e)),c=a.next();!c.done;c=a.next()){var u=c.value;u.options.frequency!="Once"&&s.push(u),u.callback(e,t)}}catch(d){n={error:d}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,s)}},r.prototype.executePostResolutionInterceptor=function(e,t,n){var i,s;if(this.interceptors.postResolution.has(e)){var a=[];try{for(var c=Za(this.interceptors.postResolution.getAll(e)),u=c.next();!u.done;u=c.next()){var d=u.value;d.options.frequency!="Once"&&a.push(d),d.callback(e,t,n)}}catch(x){i={error:x}}finally{try{u&&!u.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,a)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===mr.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===mr.Singleton,i=e.options.lifecycle===mr.ContainerScoped,s=n||i,a;return qa(e.provider)?a=e.provider.useValue:Wa(e.provider)?a=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):bd(e.provider)?a=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):xu(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,t),e.options.lifecycle===mr.ResolutionScoped&&t.scopedResolutions.set(e,a),a},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new _d),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&ps(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(c){return n.resolveRegistration(c,t)});return this.executePostResolutionInterceptor(e,s,"All"),s}var a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,"All"),a},r.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},r.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},r.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=Za(this._registry.entries()),i=n.next();!i.done;i=n.next()){var s=Ka(i.value,2),a=s[0],c=s[1];this._registry.setAll(a,c.filter(function(u){return!qa(u.provider)}).map(function(u){return u.instance=void 0,u}))}}catch(u){e={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},r.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var n=new r(this);try{for(var i=Za(this._registry.entries()),s=i.next();!s.done;s=i.next()){var a=Ka(s.value,2),c=a[0],u=a[1];u.some(function(d){var x=d.options;return x.lifecycle===mr.ContainerScoped})&&n._registry.setAll(c,u.map(function(d){return d.options.lifecycle===mr.ContainerScoped?{provider:d.provider,options:d.options}:d}))}}catch(d){e={error:d}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return n},r.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:n})},r.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:n})},r.prototype.dispose=function(){return xg(this,void 0,void 0,function(){var e;return Ag(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var i=n.dispose();i&&e.push(i)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},r.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},r.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},r.prototype.construct=function(e,t){var n=this;if(e instanceof xd)return e.createProxy(function(s){return n.resolve(s,t)});var i=function(){var s=Sd.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var a=s.map(n.resolveParams(t,e));return new(e.bind.apply(e,Ni([void 0],a)))}();return Ng(i)&&this.disposables.add(i),i},r.prototype.resolveParams=function(e,t){var n=this;return function(i,s){var a,c,u;try{return Eg(i)?Ad(i)?i.multiple?(a=n.resolve(i.transform)).transform.apply(a,Ni([n.resolveAll(i.token)],i.transformArgs)):(c=n.resolve(i.transform)).transform.apply(c,Ni([n.resolve(i.token,e)],i.transformArgs)):i.multiple?n.resolveAll(i.token):n.resolve(i.token,e):Ad(i)?(u=n.resolve(i.transform,e)).transform.apply(u,Ni([n.resolve(i.token,e)],i.transformArgs)):n.resolve(i,e)}catch(d){throw new Error(Tg(t,s,d))}}},r.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},r}(),lr=new Ug;function Ya(){return function(r){Sd.set(r,Sg(r))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var _u;class Ja{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}f([g({type:_.ObjectIdentifier})],Ja.prototype,"attrId",void 0),f([g({type:_.Any,repeated:"set"})],Ja.prototype,"attrValues",void 0);let Ed=_u=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,_u.prototype)}};Ed=_u=f([z({type:V.Sequence,itemType:Ja})],Ed);var Su;let Id=Su=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Su.prototype)}};Id=Su=f([z({type:V.Sequence,itemType:Cn})],Id);class kd{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],kd.prototype,"certId",void 0),f([g({type:_.Any,context:0})],kd.prototype,"certValue",void 0);class Cd{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],Cd.prototype,"crlId",void 0),f([g({type:_.Any,context:0})],Cd.prototype,"crltValue",void 0);class Bd extends rt{}let Xa=class{constructor(e={}){this.encryptionAlgorithm=new oe,this.encryptedData=new Bd,Object.assign(this,e)}};f([g({type:oe})],Xa.prototype,"encryptionAlgorithm",void 0),f([g({type:Bd})],Xa.prototype,"encryptedData",void 0);var Eu,Iu;(function(r){r[r.v1=0]="v1"})(Iu||(Iu={}));class Od extends rt{}let ku=Eu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Eu.prototype)}};ku=Eu=f([z({type:V.Sequence,itemType:In})],ku);class Ys{constructor(e={}){this.version=Iu.v1,this.privateKeyAlgorithm=new oe,this.privateKey=new Od,Object.assign(this,e)}}f([g({type:_.Integer})],Ys.prototype,"version",void 0),f([g({type:oe})],Ys.prototype,"privateKeyAlgorithm",void 0),f([g({type:Od})],Ys.prototype,"privateKey",void 0),f([g({type:ku,implicit:!0,context:0,optional:!0})],Ys.prototype,"attributes",void 0);let Td=class extends Ys{};Td=f([z({type:V.Sequence})],Td);let Nd=class extends Xa{};Nd=f([z({type:V.Sequence})],Nd);class jd{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],jd.prototype,"secretTypeId",void 0),f([g({type:_.Any,context:0})],jd.prototype,"secretValue",void 0);class Js{constructor(e={}){this.mac=new Ga,this.macSalt=new rt,this.iterations=1,Object.assign(this,e)}}f([g({type:Ga})],Js.prototype,"mac",void 0),f([g({type:rt})],Js.prototype,"macSalt",void 0),f([g({type:_.Integer,defaultValue:1})],Js.prototype,"iterations",void 0);class Qa{constructor(e={}){this.version=3,this.authSafe=new Cn,this.macData=new Js,Object.assign(this,e)}}f([g({type:_.Integer})],Qa.prototype,"version",void 0),f([g({type:Cn})],Qa.prototype,"authSafe",void 0),f([g({type:Js,optional:!0})],Qa.prototype,"macData",void 0);var Cu;class ec{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:_.ObjectIdentifier})],ec.prototype,"bagId",void 0),f([g({type:_.Any,context:0})],ec.prototype,"bagValue",void 0),f([g({type:Ja,repeated:"set",optional:!0})],ec.prototype,"bagAttributes",void 0);let Rd=Cu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Cu.prototype)}};Rd=Cu=f([z({type:V.Sequence,itemType:ec})],Rd);var Bu,Ou,Tu;const Pd="1.2.840.113549.1.9",Ud=`${Pd}.7`,Nu=`${Pd}.14`;let tc=class extends Wt{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};f([g({type:_.IA5String})],tc.prototype,"ia5String",void 0),tc=f([z({type:V.Choice})],tc);let Dd=class extends Cn{};Dd=f([z({type:V.Sequence})],Dd);let $d=class extends Qa{};$d=f([z({type:V.Sequence})],$d);let Md=class extends Xa{};Md=f([z({type:V.Sequence})],Md);let ju=class{constructor(e=""){this.value=e}toString(){return this.value}};f([g({type:_.IA5String})],ju.prototype,"value",void 0),ju=f([z({type:V.Choice})],ju);let Vd=class extends tc{};Vd=f([z({type:V.Choice})],Vd);let Ld=class extends Wt{};Ld=f([z({type:V.Choice})],Ld);let Ru=class{constructor(e=new Date){this.value=e}};f([g({type:_.GeneralizedTime})],Ru.prototype,"value",void 0),Ru=f([z({type:V.Choice})],Ru);let Hd=class extends Wt{};Hd=f([z({type:V.Choice})],Hd);let Pu=class{constructor(e="M"){this.value=e}toString(){return this.value}};f([g({type:_.PrintableString})],Pu.prototype,"value",void 0),Pu=f([z({type:V.Choice})],Pu);let rc=class{constructor(e=""){this.value=e}toString(){return this.value}};f([g({type:_.PrintableString})],rc.prototype,"value",void 0),rc=f([z({type:V.Choice})],rc);let Fd=class extends rc{};Fd=f([z({type:V.Choice})],Fd);let Gd=class extends Wt{};Gd=f([z({type:V.Choice})],Gd);let Uu=class{constructor(e=""){this.value=e}toString(){return this.value}};f([g({type:_.ObjectIdentifier})],Uu.prototype,"value",void 0),Uu=f([z({type:V.Choice})],Uu);let zd=class extends qt{};zd=f([z({type:V.Choice})],zd);let Du=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};f([g({type:_.Integer})],Du.prototype,"value",void 0),Du=f([z({type:V.Choice})],Du);let Zd=class extends nn{};Zd=f([z({type:V.Sequence})],Zd);let nc=class extends Wt{};nc=f([z({type:V.Choice})],nc);let Kd=Bu=class extends _i{constructor(e){super(e),Object.setPrototypeOf(this,Bu.prototype)}};Kd=Bu=f([z({type:V.Sequence})],Kd);let Wd=Ou=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Ou.prototype)}};Wd=Ou=f([z({type:V.Set,itemType:os})],Wd);let $u=class{constructor(e=""){this.value=e}toString(){return this.value}};f([g({type:_.BmpString})],$u.prototype,"value",void 0),$u=f([z({type:V.Choice})],$u);let Mu=class extends oe{};Mu=f([z({type:V.Sequence})],Mu);let qd=Tu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Tu.prototype)}};qd=Tu=f([z({type:V.Sequence,itemType:Mu})],qd);var Vu;let ic=Vu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Vu.prototype)}};ic=Vu=f([z({type:V.Sequence,itemType:In})],ic);class ys{constructor(e={}){this.version=0,this.subject=new Ft,this.subjectPKInfo=new en,this.attributes=new ic,Object.assign(this,e)}}f([g({type:_.Integer})],ys.prototype,"version",void 0),f([g({type:Ft})],ys.prototype,"subject",void 0),f([g({type:en})],ys.prototype,"subjectPKInfo",void 0),f([g({type:ic,implicit:!0,context:0})],ys.prototype,"attributes",void 0);class Xs{constructor(e={}){this.certificationRequestInfo=new ys,this.signatureAlgorithm=new oe,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:ys})],Xs.prototype,"certificationRequestInfo",void 0),f([g({type:oe})],Xs.prototype,"signatureAlgorithm",void 0),f([g({type:_.BitString})],Xs.prototype,"signature",void 0);/*!
|
|
120
|
+
* MIT License
|
|
121
|
+
*
|
|
122
|
+
* Copyright (c) Peculiar Ventures. All rights reserved.
|
|
123
|
+
*
|
|
124
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
125
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
126
|
+
* in the Software without restriction, including without limitation the rights
|
|
127
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
128
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
129
|
+
* furnished to do so, subject to the following conditions:
|
|
130
|
+
*
|
|
131
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
132
|
+
* copies or substantial portions of the Software.
|
|
133
|
+
*
|
|
134
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
135
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
136
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
137
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
138
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
139
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
140
|
+
* SOFTWARE.
|
|
141
|
+
*
|
|
142
|
+
*/const Qs="crypto.algorithm";class Dg{getAlgorithms(){return lr.resolveAll(Qs)}toAsnAlgorithm(e){({...e});for(const t of this.getAlgorithms()){const n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){const t=new oe({algorithm:e.name});if("parameters"in e){const n=e;t.parameters=n.parameters}return t}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const n of this.getAlgorithms()){const i=n.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}}const gs="crypto.algorithmProvider";lr.registerSingleton(gs,Dg);var sc;const wr="1.3.36.3.3.2.8.1.1",Yd=`${wr}.1`,Jd=`${wr}.2`,Xd=`${wr}.3`,Qd=`${wr}.4`,ep=`${wr}.5`,tp=`${wr}.6`,rp=`${wr}.7`,np=`${wr}.8`,ip=`${wr}.9`,sp=`${wr}.10`,op=`${wr}.11`,ap=`${wr}.12`,cp=`${wr}.13`,lp=`${wr}.14`,up="brainpoolP160r1",fp="brainpoolP160t1",hp="brainpoolP192r1",dp="brainpoolP192t1",pp="brainpoolP224r1",yp="brainpoolP224t1",gp="brainpoolP256r1",vp="brainpoolP256t1",mp="brainpoolP320r1",wp="brainpoolP320t1",bp="brainpoolP384r1",xp="brainpoolP384t1",Ap="brainpoolP512r1",_p="brainpoolP512t1",Ot="ECDSA";let eo=sc=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case Ot.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return ag;case"sha-256":return cg;case"sha-384":return lg;case"sha-512":return ug}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=hd;break;case"K-256":t=sc.SECP256K1;break;case"P-384":t=dd;break;case"P-521":t=pd;break;case up:t=Yd;break;case fp:t=Jd;break;case hp:t=Xd;break;case dp:t=Qd;break;case pp:t=ep;break;case yp:t=tp;break;case gp:t=rp;break;case vp:t=np;break;case mp:t=ip;break;case wp:t=sp;break;case bp:t=op;break;case xp:t=ap;break;case Ap:t=cp;break;case _p:t=lp;break}if(t)return new oe({algorithm:Zs,parameters:q.serialize(new Hn({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case lu:return{name:Ot,hash:{name:"SHA-1"}};case uu:return{name:Ot,hash:{name:"SHA-256"}};case fu:return{name:Ot,hash:{name:"SHA-384"}};case hu:return{name:Ot,hash:{name:"SHA-512"}};case Zs:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(q.parse(e.parameters,Hn).namedCurve){case hd:return{name:Ot,namedCurve:"P-256"};case sc.SECP256K1:return{name:Ot,namedCurve:"K-256"};case dd:return{name:Ot,namedCurve:"P-384"};case pd:return{name:Ot,namedCurve:"P-521"};case Yd:return{name:Ot,namedCurve:up};case Jd:return{name:Ot,namedCurve:fp};case Xd:return{name:Ot,namedCurve:hp};case Qd:return{name:Ot,namedCurve:dp};case ep:return{name:Ot,namedCurve:pp};case tp:return{name:Ot,namedCurve:yp};case rp:return{name:Ot,namedCurve:gp};case np:return{name:Ot,namedCurve:vp};case ip:return{name:Ot,namedCurve:mp};case sp:return{name:Ot,namedCurve:wp};case op:return{name:Ot,namedCurve:bp};case ap:return{name:Ot,namedCurve:xp};case cp:return{name:Ot,namedCurve:Ap};case lp:return{name:Ot,namedCurve:_p}}}}return null}};eo.SECP256K1="1.3.132.0.10",eo=sc=f([Ya()],eo),lr.registerSingleton(Qs,eo);const Sp=Symbol("name"),Ep=Symbol("value");class nt{constructor(e,t={},n=""){this[Sp]=e,this[Ep]=n;for(const i in t)this[i]=t[i]}}nt.NAME=Sp,nt.VALUE=Ep;class $g{static toTextObject(e){const t=new nt("Algorithm Identifier",{},Tn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case Zs:{const n=new eo().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class Tn{static toString(e){const t=this.items[e];return t||e}}Tn.items={[$a]:"sha1",[vd]:"sha224",[Ma]:"sha256",[Va]:"sha384",[La]:"sha512",[Bi]:"rsaEncryption",[Pa]:"sha1WithRSAEncryption",[gg]:"sha224WithRSAEncryption",[pu]:"sha256WithRSAEncryption",[Ua]:"sha384WithRSAEncryption",[Da]:"sha512WithRSAEncryption",[Zs]:"ecPublicKey",[lu]:"ecdsaWithSHA1",[fd]:"ecdsaWithSHA224",[uu]:"ecdsaWithSHA256",[fu]:"ecdsaWithSHA384",[hu]:"ecdsaWithSHA512",[eg]:"TLS WWW server authentication",[tg]:"TLS WWW client authentication",[rg]:"Code Signing",[ng]:"E-mail Protection",[ig]:"Time Stamping",[sg]:"OCSP Signing",[au]:"Signed Data"};class Fn{static serialize(e){return this.serializeObj(e).join(`
|
|
143
|
+
`)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let i=this.pad(t++),s="";const a=e[nt.VALUE];a&&(s=` ${a}`),n.push(`${i}${e[nt.NAME]}:${s}`),i=this.pad(t);for(const c in e){if(typeof c=="symbol")continue;const u=e[c],d=c?`${c}: `:"";if(typeof u=="string"||typeof u=="number"||typeof u=="boolean")n.push(`${i}${d}${u}`);else if(u instanceof Date)n.push(`${i}${d}${u.toUTCString()}`);else if(Array.isArray(u))for(const x of u)x[nt.NAME]=c,n.push(...this.serializeObj(x,t));else if(u instanceof nt)u[nt.NAME]=c,n.push(...this.serializeObj(u,t));else if(X.isBufferSource(u))c?(n.push(`${i}${d}`),n.push(...this.serializeBufferSource(u,t+1))):n.push(...this.serializeBufferSource(u,t));else if("toTextObject"in u){const x=u.toTextObject();x[nt.NAME]=c,n.push(...this.serializeObj(x,t))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return n}static serializeBufferSource(e,t=0){const n=this.pad(t),i=X.toUint8Array(e),s=[];for(let a=0;a<i.length;){const c=[];for(let u=0;u<16&&a<i.length;u++){u===8&&c.push("");const d=i[a++].toString(16).padStart(2,"0");c.push(d)}s.push(`${n}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}Fn.oidSerializer=Tn,Fn.algorithmSerializer=$g;class Gn{constructor(...e){if(e.length===1){const t=e[0];this.rawData=q.serialize(t),this.onInit(t)}else{const t=q.parse(e[0],e[1]);this.rawData=X.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof Gn?jo(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return q.toString(this.rawData);case"text":return Fn.serialize(this.toTextObject());case"hex":return de.ToHex(this.rawData);case"base64":return de.ToBase64(this.rawData);case"base64url":return de.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new nt(this.getTextName(),{},e)}}Gn.NAME="ASN";class jr extends Gn{constructor(...e){let t;X.isBufferSource(e[0])?t=X.toArrayBuffer(e[0]):t=q.serialize(new Lr({extnID:e[0],critical:e[1],extnValue:new rt(X.toArrayBuffer(e[2]))})),super(t,Lr)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[nt.NAME]===jr.NAME&&(e[nt.NAME]=Tn.toString(this.type)),e}}var Ip;class zn{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[Ip]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(zn.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(zn.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,t){return this.items.forEach(e,t)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=zn.DEFAULT){const t=this.items.get(e.toLowerCase());if(!t)throw new Error(`Cannot get Crypto by name '${e}'`);return t}set(e,t){if(typeof e=="string"){if(!t)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),t)}else this.items.set(zn.DEFAULT,e);return this}}Ip=Symbol.toStringTag,zn.DEFAULT="default";const Yt=new zn,Mg=/^[0-2](?:\.[1-9][0-9]*)+$/;function Vg(r){return new RegExp(Mg).test(r)}class kp{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return Vg(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const br=new kp;br.register("CN","2.5.4.3"),br.register("L","2.5.4.7"),br.register("ST","2.5.4.8"),br.register("O","2.5.4.10"),br.register("OU","2.5.4.11"),br.register("C","2.5.4.6"),br.register("DC","0.9.2342.19200300.100.1.25"),br.register("E","1.2.840.113549.1.9.1"),br.register("G","2.5.4.42"),br.register("I","2.5.4.43"),br.register("SN","2.5.4.4"),br.register("T","2.5.4.12");function Lg(r,e){return`\\${de.ToHex(de.FromUtf8String(e)).toUpperCase()}`}function Hg(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,Lg)}class Zn{static isASCII(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,t={}){this.extraNames=new kp,this.asn=new Ft;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const i=t[n];this.extraNames.register(n,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof Ft?this.asn=e:X.isBufferSource(e)?this.asn=q.parse(e,Ft):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||br.findId(e),n=[];for(const i of this.asn)for(const s of i)s.type===t&&n.push(s.value.toString());return n}getName(e){return this.extraNames.get(e)||br.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,i=t.value.anyValue?`#${de.ToHex(t.value.anyValue)}`:Hg(t.value.toString());return`${n}=${i}`}).join("+")).join(", ")}toJSON(){var e;const t=[];for(const n of this.asn){const i={};for(const s of n){const a=this.getName(s.type)||s.type;(e=i[a])!==null&&e!==void 0||(i[a]=[]),i[a].push(s.value.anyValue?`#${de.ToHex(s.value.anyValue)}`:s.value.toString())}t.push(i)}return t}fromString(e){const t=new Ft,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=n.exec(`${e},`);){let[,a,c]=i;const u=c[c.length-1];(u===","||u==="+")&&(c=c.slice(0,c.length-1),i[3]=u);const d=i[3];a=this.getTypeOid(a);const x=this.createAttribute(a,c);s==="+"?t[t.length-1].push(x):t.push(new Xi([x])),s=d}return t}fromJSON(e){const t=new Ft;for(const n of e){const i=new Xi;for(const s in n){const a=this.getTypeOid(s),c=n[s];for(const u of c){const d=this.createAttribute(a,u);i.push(d)}}t.push(i)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,t){const n=new ea({type:e});if(typeof t=="object")for(const i in t)switch(i){case"ia5String":n.value.ia5String=t[i];break;case"utf8String":n.value.utf8String=t[i];break;case"universalString":n.value.universalString=t[i];break;case"bmpString":n.value.bmpString=t[i];break;case"printableString":n.value.printableString=t[i];break}else if(t[0]==="#")n.value.anyValue=de.FromHex(t.slice(1));else{const i=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=i:Zn.isPrintableString(i)?n.value.printableString=i:n.value.utf8String=i}return n}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/ig,`
|
|
144
|
+
`).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return q.serialize(this.asn)}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||Yt.get()):n=e[0]||Yt.get(),await n.subtle.digest(i,this.toArrayBuffer())}}const Cp="Cannot initialize GeneralName from ASN.1 data.",Bp=`${Cp} Unsupported string format in use.`,Fg=`${Cp} Value doesn't match to GUID regular expression.`,Op=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Tp="1.3.6.1.4.1.311.25.1",Np="1.3.6.1.4.1.311.20.2.3",Lu="dns",Hu="dn",Fu="email",Gu="ip",zu="url",Zu="guid",Ku="upn",oc="id";class Kn extends Gn{constructor(...e){let t;if(e.length===2)switch(e[0]){case Hu:{const n=new Zn(e[1]).toArrayBuffer(),i=q.parse(n,Ft);t=new je({directoryName:i});break}case Lu:t=new je({dNSName:e[1]});break;case Fu:t=new je({rfc822Name:e[1]});break;case Zu:{const n=new RegExp(Op,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=n.slice(1).map((s,a)=>a<3?de.ToHex(new Uint8Array(de.FromHex(s)).reverse()):s).join("");t=new je({otherName:new Ns({typeId:Tp,value:q.serialize(new rt(de.FromHex(i)))})});break}case Gu:t=new je({iPAddress:e[1]});break;case oc:t=new je({registeredID:e[1]});break;case Ku:{t=new je({otherName:new Ns({typeId:Np,value:q.serialize(Nh.toASN(e[1]))})});break}case zu:t=new je({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else X.isBufferSource(e[0])?t=q.parse(e[0],je):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=Lu,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Fu,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=Gu,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=zu,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=oc,this.value=e.registeredID;else if(e.directoryName!=null)this.type=Hu,this.value=new Zn(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Tp){this.type=Zu;const t=q.parse(e.otherName.value,rt),n=new RegExp(Op,"i").exec(de.ToHex(t));if(!n)throw new Error(Fg);this.value=n.slice(1).map((i,s)=>s<3?de.ToHex(new Uint8Array(de.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===Np)this.type=Ku,this.value=q.parse(e.otherName.value,Wt).toString();else throw new Error(Bp);else throw new Error(Bp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case Hu:case Lu:case Zu:case Gu:case oc:case Ku:case zu:e=this.type.toUpperCase();break;case Fu:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===oc&&(t=Tn.toString(t)),new nt(e,void 0,t)}}class to extends Gn{constructor(e){let t;if(e instanceof cr)t=e;else if(Array.isArray(e)){const n=[];for(const i of e)if(i instanceof je)n.push(i);else{const s=q.parse(new Kn(i.type,i.value).rawData,je);n.push(s)}t=new cr(n)}else if(X.isBufferSource(e))t=q.parse(e,cr);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(t)}onInit(e){const t=[];for(const n of e){let i=null;try{i=new Kn(n)}catch{continue}t.push(i)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const t of this.items){const n=t.toTextObject();let i=e[n[nt.NAME]];Array.isArray(i)||(i=[],e[n[nt.NAME]]=i),i.push(n)}return e}}to.NAME="GeneralNames";const ro="-{5}",no="\\n",Gg=`[^${no}]+`,zg=`${ro}BEGIN (${Gg}(?=${ro}))${ro}`,Zg=`${ro}END \\1${ro}`,vs="\\n",Kg=`[^:${no}]+`,Wg=`(?:[^${no}]+${vs}(?: +[^${no}]+${vs})*)`,qg=`(?:[a-zA-Z0-9=+/]+${vs})+`,jp=`${zg}${vs}(?:((?:${Kg}: ${Wg})+))?${vs}?(${qg})${Zg}`;class xr{static isPem(e){return typeof e=="string"&&new RegExp(jp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(jp,"g"),n=[];let i=null;for(;i=t.exec(e);){const s=i[3].replace(new RegExp(`[${no}]+`,"g"),""),a={type:i[1],headers:[],rawData:de.FromBase64(s)},c=i[2];if(c){const u=c.split(new RegExp(vs,"g"));let d=null;for(const x of u){const[I,J]=x.split(/:(.*)/);if(J===void 0){if(!d)throw new Error("Cannot parse PEM string. Incorrect header value");d.value+=I.trim()}else d&&a.headers.push(d),d={key:I,value:J.trim()}}d&&a.headers.push(d)}n.push(a)}return n}static decode(e){return this.decodeWithHeaders(e).map(n=>n.rawData)}static decodeFirst(e){const t=this.decode(e);if(!t.length)throw new RangeError("PEM string doesn't contain any objects");return t[0]}static encode(e,t){if(Array.isArray(e)){const n=new Array;return t?e.forEach(i=>{if(!X.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");n.push(this.encodeStruct({type:t,rawData:X.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(i))}),n.join(`
|
|
145
|
+
`)}else{if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:X.toArrayBuffer(e)})}}static encodeStruct(e){var t;const n=e.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${n}-----`),!((t=e.headers)===null||t===void 0)&&t.length){for(const d of e.headers)i.push(`${d.key}: ${d.value}`);i.push("")}const s=de.ToBase64(e.rawData);let a,c=0;const u=Array();for(;c<s.length&&(s.length-c<64?a=s.substring(c):(a=s.substring(c,c+64),c+=64),a.length!==0);)if(u.push(a),a.length<64)break;return i.push(...u),i.push(`-----END ${n}-----`),i.join(`
|
|
146
|
+
`)}}xr.CertificateTag="CERTIFICATE",xr.CrlTag="CRL",xr.CertificateRequestTag="CERTIFICATE REQUEST",xr.PublicKeyTag="PUBLIC KEY",xr.PrivateKeyTag="PRIVATE KEY";class Fr extends Gn{static isAsnEncoded(e){return X.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(xr.isPem(e))return xr.decode(e)[0];if(de.isHex(e))return de.FromHex(e);if(de.isBase64(e))return de.FromBase64(e);if(de.isBase64Url(e))return de.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=de.ToBinary(e);return xr.isPem(t)?xr.decode(t)[0]:de.isHex(t)?de.FromHex(t):de.isBase64(t)?de.FromBase64(t):de.isBase64Url(t)?de.FromBase64Url(t):X.toArrayBuffer(e)}}constructor(...e){Fr.isAsnEncoded(e[0])?super(Fr.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return xr.encode(this.rawData,this.tag);default:return super.toString(e)}}}class on extends Fr{static async create(e,t=Yt.get()){if(e instanceof on)return e;if(zn.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new on(n)}else{if(e.publicKey)return e.publicKey;if(X.isBufferSource(e))return new on(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Fr.isAsnEncoded(e)?super(e,en):super(e),this.tag=xr.PublicKeyTag}async export(...e){let t,n=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,n=e[1]||n,t=e[2]||Yt.get()):t=e[0]||Yt.get();let s=this.rawData;const a=q.parse(this.rawData,en);return a.algorithm.algorithm===qs&&(s=Yg(a,s)),t.subtle.importKey("spki",s,i,!0,n)}onInit(e){const t=lr.resolve(gs),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Bi:{const i=q.parse(e.subjectPublicKey,vu),s=X.toUint8Array(i.modulus);n.publicExponent=X.toUint8Array(i.publicExponent),n.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||Yt.get()):n=e[0]||Yt.get(),await n.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=Yt.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=Yt.get();const i=q.parse(this.rawData,en);return await t.subtle.digest(n,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,en);switch(e.Algorithm=Fn.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case Zs:e["EC Point"]=t.subjectPublicKey;break;case Bi:default:e["Raw Data"]=t.subjectPublicKey}return e}}function Yg(r,e){return r.algorithm=new oe({algorithm:Bi,parameters:null}),e=q.serialize(r),e}class io extends jr{static async create(e,t=!1,n=Yt.get()){if("name"in e&&"serialNumber"in e)return new io(e,t);const s=await(await on.create(e,n)).getKeyIdentifier(n);return new io(de.ToHex(s),t)}constructor(...e){if(X.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new xi({keyIdentifier:new ul(de.FromHex(e[0]))});super(ra,e[1],q.serialize(t))}else{const t=e[0],n=t.name instanceof to?q.parse(t.name.rawData,cr):t.name,i=new xi({authorityCertIssuer:n,authorityCertSerialNumber:de.FromHex(t.serialNumber)});super(ra,e[1],q.serialize(i))}}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,xi);t.keyIdentifier&&(this.keyId=de.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?de.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,xi);return t.authorityCertIssuer&&(e["Authority Issuer"]=new to(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}io.NAME="Authority Key Identifier";class Rp extends jr{constructor(...e){if(X.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,na);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new na({cA:e[0],pathLenConstraint:e[1]});super(Hh,e[2],q.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}Rp.NAME="Basic Constraints";var Pp;(function(r){r.serverAuth="1.3.6.1.5.5.7.3.1",r.clientAuth="1.3.6.1.5.5.7.3.2",r.codeSigning="1.3.6.1.5.5.7.3.3",r.emailProtection="1.3.6.1.5.5.7.3.4",r.timeStamping="1.3.6.1.5.5.7.3.8",r.ocspSigning="1.3.6.1.5.5.7.3.9"})(Pp||(Pp={}));class Up extends jr{constructor(...e){if(X.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,ca);this.usages=t.map(n=>n)}else{const t=new ca(e[0]);super(Wh,e[1],q.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>Tn.toString(t)).join(", "),e}}Up.NAME="Extended Key Usages";var Dp;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Dp||(Dp={}));class $p extends jr{constructor(...e){if(X.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,El);this.usages=t.toNumber()}else{const t=new El(e[0]);super(Yh,e[1],q.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,El);return e[""]=t.toJSON().join(", "),e}}$p.NAME="Key Usages";class ac extends jr{static async create(e,t=!1,n=Yt.get()){const s=await(await on.create(e,n)).getKeyIdentifier(n);return new ac(de.ToHex(s),t)}constructor(...e){if(X.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,Vn);this.keyId=de.ToHex(t)}else{const t=typeof e[0]=="string"?de.FromHex(e[0]):e[0],n=new Vn(t);super(jl,e[1],q.serialize(n)),this.keyId=de.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,Vn);return e[""]=t,e}}ac.NAME="Subject Key Identifier";class Mp extends jr{constructor(...e){X.isBufferSource(e[0])?super(e[0]):super(Ol,e[1],new to(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,Tl);this.names=new to(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}Mp.NAME="Subject Alternative Name";class Rr{static register(e,t){this.items.set(e,t)}static create(e){const t=new jr(e),n=this.items.get(t.type);return n?new n(e):t}}Rr.items=new Map;class Vp extends jr{constructor(...e){var t;if(X.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,oa);this.policies=n.map(i=>i.policyIdentifier)}else{const n=e[0],i=(t=e[1])!==null&&t!==void 0?t:!1,s=new oa(n.map(a=>new sa({policyIdentifier:a})));super(Gh,i,q.serialize(s)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new nt("",{},Tn.toString(t))),e}}Vp.NAME="Certificate Policies",Rr.register(Gh,Vp);class Lp extends jr{constructor(...e){var t;if(X.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(a=>new ts({distributionPoint:new Ai({fullName:[new je({uniformResourceIdentifier:a})]})})),s=new rs(i);super(ml,e[1],q.serialize(s))}else{const n=new rs(e[0]);super(ml,e[1],q.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,rs);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;const i={};return t.distributionPoint&&(i[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(s=>new Kn(s).toString()).join(", ")),t.reasons&&(i.Reasons=t.reasons.toString()),t.cRLIssuer&&(i["CRL Issuer"]=t.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}Lp.NAME="CRL Distribution Points";class Hp extends jr{constructor(...e){var t,n,i,s;if(X.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof es){const a=new es(e[0]);super(ll,e[1],q.serialize(a))}else{const a=e[0],c=new es;lc(c,a,$h,"ocsp"),lc(c,a,Mh,"caIssuers"),lc(c,a,Vh,"timeStamping"),lc(c,a,Lh,"caRepository"),super(ll,e[1],q.serialize(c))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],q.parse(e.extnValue,es).forEach(n=>{switch(n.accessMethod){case $h:this.ocsp.push(new Kn(n.accessLocation));break;case Mh:this.caIssuers.push(new Kn(n.accessLocation));break;case Vh:this.timeStamping.push(new Kn(n.accessLocation));break;case Lh:this.caRepository.push(new Kn(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&cc(e,"OCSP",this.ocsp),this.caIssuers.length&&cc(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&cc(e,"Time Stamping",this.timeStamping),this.caRepository.length&&cc(e,"CA Repository",this.caRepository),e}}Hp.NAME="Authority Info Access";function cc(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new nt("");t.forEach((i,s)=>{const a=i.toTextObject(),c=`${a[nt.NAME]} ${s+1}`;let u=n[c];Array.isArray(u)||(u=[],n[c]=u),u.push(a)}),r[e]=n}}function lc(r,e,t,n){const i=e[n];i&&(Array.isArray(i)?i:[i]).forEach(a=>{typeof a=="string"&&(a=new Kn("url",a)),r.push(new js({accessMethod:t,accessLocation:q.parse(a.rawData,je)}))})}class ms extends Gn{constructor(...e){let t;if(X.isBufferSource(e[0]))t=X.toArrayBuffer(e[0]);else{const n=e[0],i=Array.isArray(e[1])?e[1].map(s=>X.toArrayBuffer(s)):[];t=q.serialize(new In({type:n,values:i}))}super(t,In)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new nt("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[nt.NAME]===ms.NAME&&(e[nt.NAME]=Tn.toString(this.type)),e}}ms.NAME="Attribute";class Fp extends ms{constructor(...e){var t;if(X.isBufferSource(e[0]))super(e[0]);else{const n=new nc({printableString:e[0]});super(Ud,[q.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=q.parse(this.values[0],nc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[nt.VALUE]=this.password,e}}Fp.NAME="Challenge Password";class Wu extends ms{constructor(...e){var t;if(X.isBufferSource(e[0]))super(e[0]);else{const n=e[0],i=new _i;for(const s of n)i.push(q.parse(s.rawData,Lr));super(Nu,[q.serialize(i)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=q.parse(this.values[0],_i);this.items=t.map(n=>Rr.create(q.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[nt.NAME]]=n;return e}}Wu.NAME="Extensions";class uc{static register(e,t){this.items.set(e,t)}static create(e){const t=new ms(e),n=this.items.get(t.type);return n?new n(e):t}}uc.items=new Map;const fc="crypto.signatureFormatter";class Jg{toAsnSignature(e,t){return X.toArrayBuffer(t)}toWebSignature(e,t){return X.toArrayBuffer(t)}}var hc;let qu=hc=class{static createPssParams(e,t){const n=hc.getHashAlgorithm(e);return n?new Ti({hashAlgorithm:n,maskGenAlgorithm:new oe({algorithm:Ha,parameters:q.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=lr.resolve(gs);return typeof e=="string"?t.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let t;if(typeof e.hash=="string")t=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")t=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(t.toLowerCase()){case"sha-1":return new oe({algorithm:Pa,parameters:null});case"sha-256":return new oe({algorithm:pu,parameters:null});case"sha-384":return new oe({algorithm:Ua,parameters:null});case"sha-512":return new oe({algorithm:Da,parameters:null})}}else return new oe({algorithm:Bi,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const t=hc.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new oe({algorithm:qs,parameters:q.serialize(t)})}else return new oe({algorithm:qs,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Bi:return{name:"RSASSA-PKCS1-v1_5"};case Pa:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case pu:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Ua:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Da:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case qs:if(e.parameters){const t=q.parse(e.parameters,Ti);return{name:"RSA-PSS",hash:lr.resolve(gs).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};qu=hc=f([Ya()],qu),lr.registerSingleton(Qs,qu);let Yu=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new oe({algorithm:$a});case"sha-256":return new oe({algorithm:Ma});case"sha-384":return new oe({algorithm:Va});case"sha-512":return new oe({algorithm:La})}return null}toWebAlgorithm(e){switch(e.algorithm){case $a:return{name:"SHA-1"};case Ma:return{name:"SHA-256"};case Va:return{name:"SHA-384"};case La:return{name:"SHA-512"}}return null}};Yu=f([Ya()],Yu),lr.registerSingleton(Qs,Yu);class Pr{addPadding(e,t){const n=X.toUint8Array(t),i=new Uint8Array(e);return i.set(n,e-n.length),i}removePadding(e,t=!1){let n=X.toUint8Array(e);for(let i=0;i<n.length;i++)if(n[i]){n=n.slice(i);break}if(t&&n[0]>127){const i=new Uint8Array(n.length+1);return i.set(n,1),i.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,i=Pr.namedCurveSize.get(n)||Pr.defaultNamedCurveSize,s=new Ra,a=X.toUint8Array(t);return s.r=this.removePadding(a.slice(0,i),!0),s.s=this.removePadding(a.slice(i,i+i),!0),q.serialize(s)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=q.parse(t,Ra),i=e.namedCurve,s=Pr.namedCurveSize.get(i)||Pr.defaultNamedCurveSize,a=this.addPadding(s,this.removePadding(n.r)),c=this.addPadding(s,this.removePadding(n.s));return f0(a,c)}return null}}Pr.namedCurveSize=new Map,Pr.defaultNamedCurveSize=32;const Ju="1.3.101.110",Gp="1.3.101.111",Xu="1.3.101.112",zp="1.3.101.113";let Qu=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=Xu;break;case"x25519":t=Ju;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=Xu;break;case"ed448":t=zp;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=Ju;break;case"x448":t=Gp;break}}return t?new oe({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case Xu:return{name:"Ed25519"};case zp:return{name:"EdDSA",namedCurve:"Ed448"};case Ju:return{name:"X25519"};case Gp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Qu=f([Ya()],Qu),lr.registerSingleton(Qs,Qu);class Xg extends Fr{constructor(e){Fr.isAsnEncoded(e)?super(e,Xs):super(e),this.tag=xr.CertificateRequestTag}onInit(e){this.tbs=q.serialize(e.certificationRequestInfo),this.publicKey=new on(e.certificationRequestInfo.subjectPKInfo);const t=lr.resolve(gs);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>uc.create(q.serialize(i)));const n=this.getAttribute(Nu);this.extensions=[],n instanceof Wu&&(this.extensions=n.items),this.subjectName=new Zn(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter(t=>t.type===e)}getExtension(e){for(const t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter(t=>t.type===e)}async verify(e=Yt.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),i=lr.resolveAll(fc).reverse();let s=null;for(const c of i)if(s=c.toWebSignature(t,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,Xs),n=t.certificationRequestInfo,i=new nt("",{Version:`${ns[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new nt("");for(const a of this.attributes){const c=a.toTextObject();s[c[nt.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new nt("",{Algorithm:Fn.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}Xg.NAME="PKCS#10 Certificate Request";class so extends Fr{constructor(e){Fr.isAsnEncoded(e)?super(e,Si):super(e),this.tag=xr.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=q.serialize(t),this.serialNumber=de.ToHex(t.serialNumber),this.subjectName=new Zn(t.subject),this.subject=new Zn(t.subject).toString(),this.issuerName=new Zn(t.issuer),this.issuer=this.issuerName.toString();const n=lr.resolve(gs);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const s=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(a=>Rr.create(q.serialize(a)))),this.publicKey=new on(t.subjectPublicKeyInfo)}getExtension(e){for(const t of this.extensions)if(typeof e=="string"){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e=="string"?t.type===e:t instanceof e)}async verify(e={},t=Yt.get()){let n,i;const s=e.publicKey;try{if(!s)n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,["verify"],t);else if("publicKey"in s)n={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(n,["verify"],t);else if(s instanceof on)n={...s.algorithm,...this.signatureAlgorithm},i=await s.export(n,["verify"],t);else if(X.isBufferSource(s)){const d=new on(s);n={...d.algorithm,...this.signatureAlgorithm},i=await d.export(n,["verify"],t)}else n={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const a=lr.resolveAll(fc).reverse();let c=null;for(const d of a)if(c=d.toWebSignature(n,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const u=await t.subtle.verify(this.signatureAlgorithm,i,c,this.tbs);if(e.signatureOnly)return u;{const x=(e.date||new Date).getTime();return u&&this.notBefore.getTime()<x&&x<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=Yt.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=Yt.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,Si),n=t.tbsCertificate,i=new nt("",{Version:`${ns[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":Fn.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new nt("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(i["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(i["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const s=new nt("");for(const a of this.extensions){const c=a.toTextObject();s[c[nt.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new nt("",{Algorithm:Fn.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}so.NAME="Certificate";class Qg extends Array{constructor(e){if(super(),Fr.isAsnEncoded(e))this.import(e);else if(e instanceof so)this.push(e);else if(Array.isArray(e))for(const t of e)this.push(t)}export(e){const t=new Bn;t.version=1,t.encapContentInfo.eContentType=og,t.encapContentInfo.eContent=new ls({single:new rt}),t.certificates=new $s(this.map(s=>new ki({certificate:q.parse(s.rawData,Si)})));const n=new Cn({contentType:au,content:q.serialize(t)}),i=q.serialize(n);return e==="raw"?i:this.toString(e)}import(e){const t=Fr.toArrayBuffer(e),n=q.parse(t,Cn);if(n.contentType!==au)throw new TypeError("Cannot parse CMS package. Incoming data is not a SignedData object.");const i=q.parse(n.content,Bn);this.clear();for(const s of i.certificates||[])s.certificate&&this.push(new so(s.certificate))}clear(){for(;this.pop(););}toString(e="pem"){const t=this.export("raw");switch(e){case"pem":return xr.encode(t,"CMS");case"pem-chain":return this.map(n=>n.toString("pem")).join(`
|
|
147
|
+
`);case"asn":return q.toString(t);case"hex":return de.ToHex(t);case"base64":return de.ToBase64(t);case"base64url":return de.ToBase64Url(t);case"text":return Fn.serialize(this.toTextObject());default:throw TypeError("Argument 'format' is unsupported value")}}toTextObject(){const e=q.parse(this.export("raw"),Cn),t=q.parse(e.content,Bn);return new nt("X509Certificates",{"Content Type":Tn.toString(e.contentType),Content:new nt("",{Version:`${tn[t.version]} (${t.version})`,Certificates:new nt("",{Certificate:this.map(i=>i.toTextObject())})})})}}class ev{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,t=Yt.get()){const n=new Qg(e);let i=e;for(;i=await this.findIssuer(i,t);){const s=await i.getThumbprint(t);for(const a of n){const c=await a.getThumbprint(t);if(jo(s,c))throw new Error("Cannot build a certificate chain. Circular dependency.")}n.push(i)}return n}async findIssuer(e,t=Yt.get()){if(!await e.isSelfSigned(t)){const n=e.getExtension(ra);for(const i of this.certificates)if(i.subject===e.issuer){if(n){if(n.keyId){const s=i.getExtension(jl);if(s&&s.keyId!==n.keyId)continue}else if(n.certId){const s=i.getExtension(Ol);if(s&&!(n.certId.serialNumber===i.serialNumber&&jo(q.serialize(n.certId.name),q.serialize(s))))continue}}try{const s={...i.publicKey.algorithm,...e.signatureAlgorithm},a=await i.publicKey.export(s,["verify"],t);if(!await e.verify({publicKey:a,signatureOnly:!0},t))continue}catch{continue}return i}}return null}}var Zp;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(Zp||(Zp={})),Rr.register(Hh,Rp),Rr.register(Wh,Up),Rr.register(Yh,$p),Rr.register(jl,ac),Rr.register(ra,io),Rr.register(Ol,Mp),Rr.register(ml,Lp),Rr.register(ll,Hp),uc.register(Ud,Fp),uc.register(Nu,Wu),lr.registerSingleton(fc,Jg),lr.registerSingleton(fc,Pr),Pr.namedCurveSize.set("P-256",32),Pr.namedCurveSize.set("K-256",32),Pr.namedCurveSize.set("P-384",48),Pr.namedCurveSize.set("P-521",66);const me={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},Et={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,MIME:36,SET:258,JSON:262,REGEXP:21066,SELF_DESCRIBED:55799,INVALID_16:65535,INVALID_32:4294967295,INVALID_64:0xffffffffffffffffn},wt={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},Wn={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};let Er=(Co=class{},Ge(Co,"BREAK",Symbol.for("github.com/hildjj/cbor2/break")),Ge(Co,"ENCODED",Symbol.for("github.com/hildjj/cbor2/cbor-encoded")),Ge(Co,"LENGTH",Symbol.for("github.com/hildjj/cbor2/length")),Co);const dc={MIN:-(2n**63n),MAX:2n**64n-1n};let ze=(Pn=class{constructor(e,t=void 0){Ge(this,"tag");Ge(this,"contents");this.tag=e,this.contents=t}get noChildren(){var e;return!!((e=M(Pn,un).get(this.tag))!=null&&e.noChildren)}static registerDecoder(e,t,n){const i=M(this,un).get(e);return M(this,un).set(e,t),i&&("comment"in t||(t.comment=i.comment),"noChildren"in t||(t.noChildren=i.noChildren)),n&&!t.comment&&(t.comment=()=>`(${n})`),i}static clearDecoder(e){const t=M(this,un).get(e);return M(this,un).delete(e),t}*[Symbol.iterator](){yield this.contents}push(e){return this.contents=e,1}decode(e){const t=M(Pn,un).get(this.tag);return t?t(this,e):this}comment(e,t){const n=M(Pn,un).get(this.tag);if(n!=null&&n.comment)return n.comment(this,e,t)}toCBOR(){return[this.tag,this.contents]}[Symbol.for("nodejs.util.inspect.custom")](e,t,n){return`${this.tag}(${n(this.contents,t)})`}},un=new WeakMap,or(Pn,un,new Map),Pn);function pc(r){if(r!=null&&typeof r=="object")return r[Er.ENCODED]}function tv(r){if(r!=null&&typeof r=="object")return r[Er.LENGTH]}function oo(r,e){Object.defineProperty(r,Er.ENCODED,{configurable:!0,enumerable:!1,value:e})}function ao(r,e){const t=Object(r);return oo(t,e),t}function Kp(r){let e=Math.ceil(r.length/2);const t=new Uint8Array(e);e--;for(let n=r.length,i=n-2;n>=0;n=i,i-=2,e--)t[e]=parseInt(r.substring(i,n),16);return t}function Gr(r){return r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),"")}function rv(r){const e=r.reduce((i,s)=>i+s.length,0),t=new Uint8Array(e);let n=0;for(const i of r)t.set(i,n),n+=i.length;return t}function ef(r){const e=atob(r);return Uint8Array.from(e,t=>t.codePointAt(0))}const nv={"-":"+",_:"/"};function iv(r){const e=r.replace(/[_-]/g,t=>nv[t]);return ef(e.padEnd(Math.ceil(e.length/4)*4,"="))}function sv(){const r=new Uint8Array(4),e=new Uint32Array(r.buffer);return!((e[0]=1)&r[0])}function Wp(r){var t;let e="";for(const n of r){const i=(t=n.codePointAt(0))==null?void 0:t.toString(16).padStart(4,"0");e&&(e+=", "),e+=`U+${i}`}return e}function qp(r,e){const[t,n,i]=r,[s,a,c]=e,u=Math.min(i.length,c.length);for(let d=0;d<u;d++){const x=i[d]-c[d];if(x!==0)return x}return 0}const Oc=class Oc{constructor(e={}){or(this,et);or(this,ni);or(this,Jt,[]);or(this,Ar,null);or(this,Dt,0);or(this,ii,0);if(Nt(this,ni,{...Oc.defaultOptions,...e}),M(this,ni).chunkSize<8)throw new RangeError(`Expected size >= 8, got ${M(this,ni).chunkSize}`);Pe(this,et,zi).call(this)}get length(){return M(this,ii)}read(){Pe(this,et,jc).call(this);const e=new Uint8Array(M(this,ii));let t=0;for(const n of M(this,Jt))e.set(n,t),t+=n.length;return Pe(this,et,zi).call(this),e}write(e){const t=e.length;t>Pe(this,et,bf).call(this)?(Pe(this,et,jc).call(this),t>M(this,ni).chunkSize?(M(this,Jt).push(e),Pe(this,et,zi).call(this)):(Pe(this,et,zi).call(this),M(this,Jt)[M(this,Jt).length-1].set(e),Nt(this,Dt,t))):(M(this,Jt)[M(this,Jt).length-1].set(e,M(this,Dt)),Nt(this,Dt,M(this,Dt)+t)),Nt(this,ii,M(this,ii)+t)}writeUint8(e){Pe(this,et,vn).call(this,1),M(this,Ar).setUint8(M(this,Dt),e),Pe(this,et,mn).call(this,1)}writeUint16(e,t=!1){Pe(this,et,vn).call(this,2),M(this,Ar).setUint16(M(this,Dt),e,t),Pe(this,et,mn).call(this,2)}writeUint32(e,t=!1){Pe(this,et,vn).call(this,4),M(this,Ar).setUint32(M(this,Dt),e,t),Pe(this,et,mn).call(this,4)}writeBigUint64(e,t=!1){Pe(this,et,vn).call(this,8),M(this,Ar).setBigUint64(M(this,Dt),e,t),Pe(this,et,mn).call(this,8)}writeInt16(e,t=!1){Pe(this,et,vn).call(this,2),M(this,Ar).setInt16(M(this,Dt),e,t),Pe(this,et,mn).call(this,2)}writeInt32(e,t=!1){Pe(this,et,vn).call(this,4),M(this,Ar).setInt32(M(this,Dt),e,t),Pe(this,et,mn).call(this,4)}writeBigInt64(e,t=!1){Pe(this,et,vn).call(this,8),M(this,Ar).setBigInt64(M(this,Dt),e,t),Pe(this,et,mn).call(this,8)}writeFloat32(e,t=!1){Pe(this,et,vn).call(this,4),M(this,Ar).setFloat32(M(this,Dt),e,t),Pe(this,et,mn).call(this,4)}writeFloat64(e,t=!1){Pe(this,et,vn).call(this,8),M(this,Ar).setFloat64(M(this,Dt),e,t),Pe(this,et,mn).call(this,8)}clear(){Nt(this,ii,0),Nt(this,Jt,[]),Pe(this,et,zi).call(this)}};ni=new WeakMap,Jt=new WeakMap,Ar=new WeakMap,Dt=new WeakMap,ii=new WeakMap,et=new WeakSet,zi=function(){const e=new Uint8Array(M(this,ni).chunkSize);M(this,Jt).push(e),Nt(this,Dt,0),Nt(this,Ar,new DataView(e.buffer,e.byteOffset,e.byteLength))},jc=function(){if(M(this,Dt)===0){M(this,Jt).pop();return}const e=M(this,Jt).length-1;M(this,Jt)[e]=M(this,Jt)[e].subarray(0,M(this,Dt)),Nt(this,Dt,0),Nt(this,Ar,null)},bf=function(){const e=M(this,Jt).length-1;return M(this,Jt)[e].length-M(this,Dt)},vn=function(e){Pe(this,et,bf).call(this)<e&&(Pe(this,et,jc).call(this),Pe(this,et,zi).call(this))},mn=function(e){Nt(this,Dt,M(this,Dt)+e),Nt(this,ii,M(this,ii)+e)},Ge(Oc,"defaultOptions",{chunkSize:4096});let yc=Oc;function Yp(r,e=0,t=!1){const n=r[e]&128?-1:1,i=(r[e]&124)>>2,s=(r[e]&3)<<8|r[e+1];if(i===0){if(t&&s!==0)throw new Error(`Unwanted subnormal: ${n*5960464477539063e-23*s}`);return n*5960464477539063e-23*s}else if(i===31)return s?NaN:n*(1/0);return n*2**(i-25)*(1024+s)}function ov(r){const e=new DataView(new ArrayBuffer(4));e.setFloat32(0,r,!1);const t=e.getUint32(0,!1);if(t&8191)return null;let n=t>>16&32768;const i=t>>23&255,s=t&8388607;if(!(i===0&&s===0))if(i>=113&&i<=142)n+=(i-112<<10)+(s>>13);else if(i>=103&&i<113){if(s&(1<<126-i)-1)return null;n+=s+8388608>>126-i}else if(i===255)n|=31744,n|=s>>13;else return null;return n}function av(r){if(r!==0){const e=new ArrayBuffer(8),t=new DataView(e);t.setFloat64(0,r,!1);const n=t.getBigUint64(0,!1);if((n&0x7ff0000000000000n)===0n)return n&0x8000000000000000n?-0:0}return r}function cv(r){switch(r.length){case 2:Yp(r,0,!0);break;case 4:{const e=new DataView(r.buffer,r.byteOffset,r.byteLength),t=e.getUint32(0,!1);if(!(t&2139095040)&&t&8388607)throw new Error(`Unwanted subnormal: ${e.getFloat32(0,!1)}`);break}case 8:{const e=new DataView(r.buffer,r.byteOffset,r.byteLength),t=e.getBigUint64(0,!1);if((t&0x7ff0000000000000n)===0n&&t&0x000fffffffffffn)throw new Error(`Unwanted subnormal: ${e.getFloat64(0,!1)}`);break}default:throw new TypeError(`Bad input to isSubnormal: ${r}`)}}const Jp=me.SIMPLE_FLOAT<<5|wt.TWO,lv=me.SIMPLE_FLOAT<<5|wt.FOUR,uv=me.SIMPLE_FLOAT<<5|wt.EIGHT,fv=me.SIMPLE_FLOAT<<5|Wn.TRUE,hv=me.SIMPLE_FLOAT<<5|Wn.FALSE,dv=me.SIMPLE_FLOAT<<5|Wn.UNDEFINED,pv=me.SIMPLE_FLOAT<<5|Wn.NULL,yv=new TextEncoder,gv={...yc.defaultOptions,avoidInts:!1,cde:!1,collapseBigInts:!0,dcbor:!1,float64:!1,flushToZero:!1,forceEndian:null,ignoreOriginalEncoding:!1,largeNegativeAsBigInt:!1,reduceUnsafeNumbers:!1,rejectBigInts:!1,rejectCustomSimples:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectUndefined:!1,simplifyNegativeZero:!1,sortKeys:null,stringNormalization:null},Xp={cde:!0,ignoreOriginalEncoding:!0,sortKeys:qp},vv={...Xp,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:"NFC"};function Qp(r){const e=r<0;return typeof r=="bigint"?[e?-r-1n:r,e]:[e?-r-1:r,e]}function tf(r,e,t){if(t.rejectFloats)throw new Error(`Attempt to encode an unwanted floating point number: ${r}`);if(isNaN(r))e.writeUint8(Jp),e.writeUint16(32256);else if(!t.float64&&Math.fround(r)===r){const n=ov(r);n===null?(e.writeUint8(lv),e.writeFloat32(r)):(e.writeUint8(Jp),e.writeUint16(n))}else e.writeUint8(uv),e.writeFloat64(r)}function zr(r,e,t){const[n,i]=Qp(r);if(i&&t)throw new TypeError(`Negative size: ${r}`);t??(t=i?me.NEG_INT:me.POS_INT),t<<=5,n<24?e.writeUint8(t|n):n<=255?(e.writeUint8(t|wt.ONE),e.writeUint8(n)):n<=65535?(e.writeUint8(t|wt.TWO),e.writeUint16(n)):n<=4294967295?(e.writeUint8(t|wt.FOUR),e.writeUint32(n)):(e.writeUint8(t|wt.EIGHT),e.writeBigUint64(BigInt(n)))}function gc(r,e,t){typeof r=="number"?zr(r,e,me.TAG):typeof r=="object"&&!t.ignoreOriginalEncoding&&Er.ENCODED in r?e.write(r[Er.ENCODED]):r<=Number.MAX_SAFE_INTEGER?zr(Number(r),e,me.TAG):(e.writeUint8(me.TAG<<5|wt.EIGHT),e.writeBigUint64(BigInt(r)))}function ey(r,e,t){const[n,i]=Qp(r);if(t.collapseBigInts&&(!t.largeNegativeAsBigInt||r>=-0x8000000000000000n)){if(n<=0xffffffffn){zr(Number(r),e);return}if(n<=0xffffffffffffffffn){const d=(i?me.NEG_INT:me.POS_INT)<<5;e.writeUint8(d|wt.EIGHT),e.writeBigUint64(n);return}}if(t.rejectBigInts)throw new Error(`Attempt to encode unwanted bigint: ${r}`);const s=i?Et.NEG_BIGINT:Et.POS_BIGINT,a=n.toString(16),c=a.length%2?"0":"";gc(s,e,t);const u=Kp(c+a);zr(u.length,e,me.BYTE_STRING),e.write(u)}function mv(r,e,t){t.flushToZero&&(r=av(r)),Object.is(r,-0)?t.simplifyNegativeZero?t.avoidInts?tf(0,e,t):zr(0,e):tf(r,e,t):!t.avoidInts&&Number.isSafeInteger(r)?zr(r,e):t.reduceUnsafeNumbers&&Math.floor(r)===r&&r>=dc.MIN&&r<=dc.MAX?ey(BigInt(r),e,t):tf(r,e,t)}function wv(r,e,t){const n=t.stringNormalization?r.normalize(t.stringNormalization):r,i=yv.encode(n);zr(i.length,e,me.UTF8_STRING),e.write(i)}function bv(r,e,t){const n=r;nf(n,n.length,me.ARRAY,e,t);for(const i of n)ji(i,e,t)}function xv(r,e){const t=r;zr(t.length,e,me.BYTE_STRING),e.write(t)}const rf=new Map([[Array,bv],[Uint8Array,xv]]);function jt(r,e){const t=rf.get(r);return rf.set(r,e),t}function nf(r,e,t,n,i){const s=tv(r);s&&!i.ignoreOriginalEncoding?n.write(s):zr(e,n,t)}function Av(r,e,t){if(r===null){e.writeUint8(pv);return}if(!t.ignoreOriginalEncoding&&Er.ENCODED in r){e.write(r[Er.ENCODED]);return}const n=rf.get(r.constructor);if(n){const s=n(r,e,t);s&&((typeof s[0]=="bigint"||isFinite(Number(s[0])))&&gc(s[0],e,t),ji(s[1],e,t));return}if(typeof r.toCBOR=="function"){const s=r.toCBOR(e,t);s&&((typeof s[0]=="bigint"||isFinite(Number(s[0])))&&gc(s[0],e,t),ji(s[1],e,t));return}if(typeof r.toJSON=="function"){ji(r.toJSON(),e,t);return}const i=Object.entries(r).map(s=>[s[0],s[1],vc(s[0],t)]);t.sortKeys&&i.sort(t.sortKeys),nf(r,i.length,me.MAP,e,t);for(const[s,a,c]of i)e.write(c),ji(a,e,t)}function ji(r,e,t){switch(typeof r){case"number":mv(r,e,t);break;case"bigint":ey(r,e,t);break;case"string":wv(r,e,t);break;case"boolean":e.writeUint8(r?fv:hv);break;case"undefined":if(t.rejectUndefined)throw new Error("Attempt to encode unwanted undefined.");e.writeUint8(dv);break;case"object":Av(r,e,t);break;case"symbol":throw new TypeError(`Unknown symbol: ${r.toString()}`);default:throw new TypeError(`Unknown type: ${typeof r}, ${String(r)}`)}}function vc(r,e={}){const t={...gv};e.dcbor?Object.assign(t,vv):e.cde&&Object.assign(t,Xp),Object.assign(t,e);const n=new yc(t);return ji(r,n,t),n.read()}var ty=(r=>(r[r.NEVER=-1]="NEVER",r[r.PREFERRED=0]="PREFERRED",r[r.ALWAYS=1]="ALWAYS",r))(ty||{});const si=class si{constructor(e){Ge(this,"value");this.value=e}static create(e){return si.KnownSimple.has(e)?si.KnownSimple.get(e):new si(e)}toCBOR(e,t){if(t.rejectCustomSimples)throw new Error(`Cannot encode non-standard Simple value: ${this.value}`);zr(this.value,e,me.SIMPLE_FLOAT)}toString(){return`simple(${this.value})`}decode(){return si.KnownSimple.has(this.value)?si.KnownSimple.get(this.value):this}[Symbol.for("nodejs.util.inspect.custom")](e,t,n){return`simple(${n(this.value,t)})`}};Ge(si,"KnownSimple",new Map([[Wn.FALSE,!1],[Wn.TRUE,!0],[Wn.NULL,null],[Wn.UNDEFINED,void 0]]));let co=si;const _v=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}),Tc=class Tc{constructor(e,t){or(this,Qt);or(this,kr);or(this,qr);or(this,Xt,0);or(this,Ur);if(Nt(this,Ur,{...Tc.defaultOptions,...t}),typeof e=="string")switch(M(this,Ur).encoding){case"hex":Nt(this,kr,Kp(e));break;case"base64":Nt(this,kr,ef(e));break;default:throw new TypeError(`Encoding not implemented: "${M(this,Ur).encoding}"`)}else Nt(this,kr,e);Nt(this,qr,new DataView(M(this,kr).buffer,M(this,kr).byteOffset,M(this,kr).byteLength))}toHere(e){return M(this,kr).subarray(e,M(this,Xt))}*[Symbol.iterator](){if(yield*Pe(this,Qt,Zi).call(this,0),M(this,Xt)!==M(this,kr).length)throw new Error("Extra data in input")}};kr=new WeakMap,qr=new WeakMap,Xt=new WeakMap,Ur=new WeakMap,Qt=new WeakSet,Zi=function*(e){if(e++>M(this,Ur).maxDepth)throw new Error(`Maximum depth ${M(this,Ur).maxDepth} exceeded`);const t=M(this,Xt),n=M(this,qr).getUint8($y(this,Xt)._++),i=n>>5,s=n&31;let a=s,c=!1,u=0;switch(s){case wt.ONE:if(u=1,a=M(this,qr).getUint8(M(this,Xt)),i===me.SIMPLE_FLOAT){if(a<32)throw new Error(`Invalid simple encoding in extra byte: ${a}`);c=!0}else if(M(this,Ur).requirePreferred&&a<24)throw new Error(`Unexpectedly long integer encoding (1) for ${a}`);break;case wt.TWO:if(u=2,i===me.SIMPLE_FLOAT)a=Yp(M(this,kr),M(this,Xt));else if(a=M(this,qr).getUint16(M(this,Xt),!1),M(this,Ur).requirePreferred&&a<=255)throw new Error(`Unexpectedly long integer encoding (2) for ${a}`);break;case wt.FOUR:if(u=4,i===me.SIMPLE_FLOAT)a=M(this,qr).getFloat32(M(this,Xt),!1);else if(a=M(this,qr).getUint32(M(this,Xt),!1),M(this,Ur).requirePreferred&&a<=65535)throw new Error(`Unexpectedly long integer encoding (4) for ${a}`);break;case wt.EIGHT:{if(u=8,i===me.SIMPLE_FLOAT)a=M(this,qr).getFloat64(M(this,Xt),!1);else if(a=M(this,qr).getBigUint64(M(this,Xt),!1),a<=Number.MAX_SAFE_INTEGER&&(a=Number(a)),M(this,Ur).requirePreferred&&a<=4294967295)throw new Error(`Unexpectedly long integer encoding (8) for ${a}`);break}case 28:case 29:case 30:throw new Error(`Additional info not implemented: ${s}`);case wt.INDEFINITE:switch(i){case me.POS_INT:case me.NEG_INT:case me.TAG:throw new Error(`Invalid indefinite encoding for MT ${i}`);case me.SIMPLE_FLOAT:yield[i,s,Er.BREAK,t,0];return}a=1/0;break;default:c=!0}switch(Nt(this,Xt,M(this,Xt)+u),i){case me.POS_INT:yield[i,s,a,t,u];break;case me.NEG_INT:yield[i,s,typeof a=="bigint"?-1n-a:-1-Number(a),t,u];break;case me.BYTE_STRING:a===1/0?yield*Pe(this,Qt,To).call(this,i,e,t):yield[i,s,Pe(this,Qt,xf).call(this,a),t,a];break;case me.UTF8_STRING:a===1/0?yield*Pe(this,Qt,To).call(this,i,e,t):yield[i,s,_v.decode(Pe(this,Qt,xf).call(this,a)),t,a];break;case me.ARRAY:if(a===1/0)yield*Pe(this,Qt,To).call(this,i,e,t,!1);else{const d=Number(a);yield[i,s,d,t,u];for(let x=0;x<d;x++)yield*Pe(this,Qt,Zi).call(this,e+1)}break;case me.MAP:if(a===1/0)yield*Pe(this,Qt,To).call(this,i,e,t,!1);else{const d=Number(a);yield[i,s,d,t,u];for(let x=0;x<d;x++)yield*Pe(this,Qt,Zi).call(this,e),yield*Pe(this,Qt,Zi).call(this,e)}break;case me.TAG:yield[i,s,a,t,u],yield*Pe(this,Qt,Zi).call(this,e);break;case me.SIMPLE_FLOAT:{const d=a;c&&(a=co.create(Number(a))),yield[i,s,a,t,d];break}}},xf=function(e){const t=M(this,kr).subarray(M(this,Xt),Nt(this,Xt,M(this,Xt)+e));if(t.length!==e)throw new Error(`Unexpected end of stream reading ${e} bytes, got ${t.length}`);return t},To=function*(e,t,n,i=!0){for(yield[e,wt.INDEFINITE,1/0,n,1/0];;){const s=Pe(this,Qt,Zi).call(this,t),a=s.next(),[c,u,d]=a.value;if(d===Er.BREAK){yield a.value,s.next();return}if(i){if(c!==e)throw new Error(`Unmatched major type. Expected ${e}, got ${c}.`);if(u===wt.INDEFINITE)throw new Error("New stream started in typed stream")}yield a.value,yield*s}},Ge(Tc,"defaultOptions",{maxDepth:1024,encoding:"hex",requirePreferred:!1});let lo=Tc;const Sv=new Map([[wt.ZERO,1],[wt.ONE,2],[wt.TWO,3],[wt.FOUR,5],[wt.EIGHT,9]]),Ev=new Uint8Array(0);let qn=(fn=class{constructor(e,t,n,i){or(this,Nc);Ge(this,"parent");Ge(this,"mt");Ge(this,"ai");Ge(this,"left");Ge(this,"offset");Ge(this,"count",0);Ge(this,"children",[]);Ge(this,"depth",0);or(this,fr);or(this,hn,null);if([this.mt,this.ai,,this.offset]=e,this.left=t,this.parent=n,Nt(this,fr,i),n&&(this.depth=n.depth+1),this.mt===me.MAP&&(M(this,fr).sortKeys||M(this,fr).rejectDuplicateKeys)&&Nt(this,hn,[]),M(this,fr).rejectStreaming&&this.ai===wt.INDEFINITE)throw new Error("Streaming not supported")}get isStreaming(){return this.left===1/0}get done(){return this.left===0}static create(e,t,n,i){const[s,a,c,u]=e;switch(s){case me.POS_INT:case me.NEG_INT:{if(n.rejectInts)throw new Error(`Unexpected integer: ${c}`);if(n.rejectLargeNegatives&&c<-0x8000000000000000n)throw new Error(`Invalid 65bit negative number: ${c}`);let d=c;return n.convertUnsafeIntsToFloat&&d>=dc.MIN&&d<=dc.MAX&&(d=Number(c)),n.boxed?ao(d,i.toHere(u)):d}case me.SIMPLE_FLOAT:if(a>wt.ONE){if(n.rejectFloats)throw new Error(`Decoding unwanted floating point number: ${c}`);if(n.rejectNegativeZero&&Object.is(c,-0))throw new Error("Decoding negative zero");if(n.rejectLongLoundNaN&&isNaN(c)){const d=i.toHere(u);if(d.length!==3||d[1]!==126||d[2]!==0)throw new Error(`Invalid NaN encoding: "${Gr(d)}"`)}if(n.rejectSubnormals&&cv(i.toHere(u+1)),n.rejectLongFloats){const d=vc(c,{chunkSize:9,reduceUnsafeNumbers:n.rejectUnsafeFloatInts});if(d[0]>>5!==s)throw new Error(`Should have been encoded as int, not float: ${c}`);if(d.length<Sv.get(a))throw new Error(`Number should have been encoded shorter: ${c}`)}if(typeof c=="number"&&n.boxed)return ao(c,i.toHere(u))}else{if(n.rejectSimple&&c instanceof co)throw new Error(`Invalid simple value: ${c}`);if(n.rejectUndefined&&c===void 0)throw new Error("Unexpected undefined")}return c;case me.BYTE_STRING:case me.UTF8_STRING:if(c===1/0)return new n.ParentType(e,1/0,t,n);if(n.rejectStringsNotNormalizedAs&&typeof c=="string"){const d=c.normalize(n.rejectStringsNotNormalizedAs);if(c!==d)throw new Error(`String not normalized as "${n.rejectStringsNotNormalizedAs}", got [${Wp(c)}] instead of [${Wp(d)}]`)}return n.boxed?ao(c,i.toHere(u)):c;case me.ARRAY:return new n.ParentType(e,c,t,n);case me.MAP:return new n.ParentType(e,c*2,t,n);case me.TAG:{const d=new n.ParentType(e,1,t,n);return d.children=new ze(c),d}}throw new TypeError(`Invalid major type: ${s}`)}push(e,t,n){if(this.children.push(e),M(this,hn)){const i=pc(e)||t.toHere(n);M(this,hn).push(i)}return--this.left}replaceLast(e,t,n){let i,s=-1/0;if(this.children instanceof ze?(s=0,i=this.children.contents,this.children.contents=e):(s=this.children.length-1,i=this.children[s],this.children[s]=e),M(this,hn)){const a=pc(e)||n.toHere(t.offset);M(this,hn)[s]=a}return i}convert(e){let t;switch(this.mt){case me.ARRAY:t=this.children;break;case me.MAP:{const n=Pe(this,Nc,Ly).call(this);if(M(this,fr).sortKeys){let i;for(const s of n){if(i&&M(this,fr).sortKeys(i,s)>=0)throw new Error(`Duplicate or out of order key: "0x${s[2]}"`);i=s}}else if(M(this,fr).rejectDuplicateKeys){const i=new Set;for(const[s,a,c]of n){const u=Gr(c);if(i.has(u))throw new Error(`Duplicate key: "0x${u}"`);i.add(u)}}t=!M(this,fr).boxed&&!M(this,fr).preferMap&&n.every(([i])=>typeof i=="string")?Object.fromEntries(n):new Map(n);break}case me.BYTE_STRING:return rv(this.children);case me.UTF8_STRING:{const n=this.children.join("");t=M(this,fr).boxed?ao(n,e.toHere(this.offset)):n;break}case me.TAG:t=this.children.decode(M(this,fr));break;default:throw new TypeError(`Invalid mt on convert: ${this.mt}`)}return M(this,fr).saveOriginal&&t&&typeof t=="object"&&oo(t,e.toHere(this.offset)),t}},fr=new WeakMap,hn=new WeakMap,Nc=new WeakSet,Ly=function(){const e=this.children,t=e.length;if(t%2)throw new Error("Missing map value");const n=new Array(t/2);if(M(this,hn))for(let i=0;i<t;i+=2)n[i>>1]=[e[i],e[i+1],M(this,hn)[i]];else for(let i=0;i<t;i+=2)n[i>>1]=[e[i],e[i+1],Ev];return n},Ge(fn,"defaultDecodeOptions",{...lo.defaultOptions,ParentType:fn,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:ty.PREFERRED,convertUnsafeIntsToFloat:!1,pretty:!1,preferMap:!1,rejectLargeNegatives:!1,rejectBigInts:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectInts:!1,rejectLongLoundNaN:!1,rejectLongFloats:!1,rejectNegativeZero:!1,rejectSimple:!1,rejectStreaming:!1,rejectStringsNotNormalizedAs:null,rejectSubnormals:!1,rejectUndefined:!1,rejectUnsafeFloatInts:!1,saveOriginal:!1,sortKeys:null}),Ge(fn,"cdeDecodeOptions",{cde:!0,rejectStreaming:!0,requirePreferred:!0,sortKeys:qp}),Ge(fn,"dcborDecodeOptions",{...fn.cdeDecodeOptions,dcbor:!0,convertUnsafeIntsToFloat:!0,rejectDuplicateKeys:!0,rejectLargeNegatives:!0,rejectLongLoundNaN:!0,rejectLongFloats:!0,rejectNegativeZero:!0,rejectSimple:!0,rejectUndefined:!0,rejectUnsafeFloatInts:!0,rejectStringsNotNormalizedAs:"NFC"}),fn);class sf extends(Uy=qn,Py=Er.ENCODED,Uy){constructor(t,n,i,s){super(t,n,i,s);Ge(this,"depth",0);Ge(this,"leaf",!1);Ge(this,"value");Ge(this,"length");Ge(this,Py);this.parent?this.depth=this.parent.depth+1:this.depth=s.initialDepth,[,,this.value,,this.length]=t}numBytes(){switch(this.ai){case wt.ONE:return 1;case wt.TWO:return 2;case wt.FOUR:return 4;case wt.EIGHT:return 8}return 0}}function ry(r){return r instanceof sf}function mc(r,e){return r===1/0?"Indefinite":e?`${r} ${e}${r!==1&&r!==1n?"s":""}`:String(r)}function of(r){return"".padStart(r," ")}function ny(r,e,t){let n="";n+=of(r.depth*2);const i=pc(r);n+=Gr(i.subarray(0,1));const s=r.numBytes();s&&(n+=" ",n+=Gr(i.subarray(1,s+1))),n=n.padEnd(e.minCol+1," "),n+="-- ",t!==void 0&&(n+=of(r.depth*2),t!==""&&(n+=`[${t}] `));let a=!1;const[c]=r.children;switch(r.mt){case me.POS_INT:n+=`Unsigned: ${c}`,typeof c=="bigint"&&(n+="n");break;case me.NEG_INT:n+=`Negative: ${c}`,typeof c=="bigint"&&(n+="n");break;case me.BYTE_STRING:n+=`Bytes (Length: ${mc(r.length)})`;break;case me.UTF8_STRING:n+=`UTF8 (Length: ${mc(r.length)})`,r.length!==1/0&&(n+=`: ${JSON.stringify(c)}`);break;case me.ARRAY:n+=`Array (Length: ${mc(r.value,"item")})`;break;case me.MAP:n+=`Map (Length: ${mc(r.value,"pair")})`;break;case me.TAG:{n+=`Tag #${r.value}`;const u=r.children,[d]=u.contents.children,x=new ze(u.tag,d);oo(x,i);const I=x.comment(e,r.depth);I&&(n+=": ",n+=I),a||(a=x.noChildren);break}case me.SIMPLE_FLOAT:c===Er.BREAK?n+="BREAK":r.ai>wt.ONE?Object.is(c,-0)?n+="Float: -0":n+=`Float: ${c}`:(n+="Simple: ",c instanceof co?n+=c.value:n+=c);break}if(!a)if(r.leaf){if(n+=`
|
|
148
|
+
`,i.length>s+1){const u=of((r.depth+1)*2);for(let d=s+1;d<i.length;d+=8)n+=u,n+=Gr(i.subarray(d,d+8)),n+=`
|
|
149
|
+
`}}else{n+=`
|
|
150
|
+
`;let u=0;for(const d of r.children){if(ry(d)){let x=String(u);r.mt===me.MAP?x=u%2?`val ${(u-1)/2}`:`key ${u/2}`:r.mt===me.TAG&&(x=""),n+=ny(d,e,x)}u++}}return n}const Iv={...qn.defaultDecodeOptions,initialDepth:0,noPrefixHex:!1,minCol:0};function kv(r,e){const t={...Iv,...e,ParentType:sf,saveOriginal:!0},n=new lo(r,t);let i,s;for(const c of n){if(s=qn.create(c,i,t,n),c[2]===Er.BREAK)if(i!=null&&i.isStreaming)i.left=1;else throw new Error("Unexpected BREAK");if(!ry(s)){const x=new sf(c,0,i,t);x.leaf=!0,x.children.push(s),oo(x,n.toHere(c[3])),s=x}let u=(s.depth+1)*2;const d=s.numBytes();for(d&&(u+=1,u+=d*2),t.minCol=Math.max(t.minCol,u),i&&i.push(s,n,c[3]),i=s;i!=null&&i.done;)s=i,s.leaf||oo(s,n.toHere(s.offset)),{parent:i}=i}e&&(e.minCol=t.minCol);let a=t.noPrefixHex?"":`0x${Gr(n.toHere(0))}
|
|
151
|
+
`;return a+=ny(s,t),a}const iy=!sv();function sy(r){if(typeof r=="object"&&r){if(r.constructor!==Number)throw new Error(`Expected number: ${r}`)}else if(typeof r!="number")throw new Error(`Expected number: ${r}`)}function Yn(r){if(typeof r=="object"&&r){if(r.constructor!==String)throw new Error(`Expected string: ${r}`)}else if(typeof r!="string")throw new Error(`Expected string: ${r}`)}function Ri(r){if(!(r instanceof Uint8Array))throw new Error(`Expected Uint8Array: ${r}`)}function oy(r){if(!Array.isArray(r))throw new Error(`Expected Array: ${r}`)}jt(Map,(r,e,t)=>{const n=[...r.entries()].map(i=>[i[0],i[1],vc(i[0],t)]);if(t.rejectDuplicateKeys){const i=new Set;for(const[s,a,c]of n){const u=Gr(c);if(i.has(u))throw new Error(`Duplicate map key: 0x${u}`);i.add(u)}}t.sortKeys&&n.sort(t.sortKeys),nf(r,r.size,me.MAP,e,t);for(const[i,s,a]of n)e.write(a),ji(s,e,t)});function ay(r){return Yn(r.contents),new Date(r.contents)}ay.comment=r=>(Yn(r.contents),`(String Date) ${new Date(r.contents).toISOString()}`),ze.registerDecoder(Et.DATE_STRING,ay);function cy(r){return sy(r.contents),new Date(r.contents*1e3)}cy.comment=r=>(sy(r.contents),`(Epoch Date) ${new Date(r.contents*1e3).toISOString()}`),ze.registerDecoder(Et.DATE_EPOCH,cy),jt(Date,r=>[Et.DATE_EPOCH,r.valueOf()/1e3]);function wc(r,e,t){if(Ri(e.contents),t.rejectBigInts)throw new Error(`Decoding unwanted big integer: ${e}(h'${Gr(e.contents)}')`);if(t.requirePreferred&&e.contents[0]===0)throw new Error(`Decoding overly-large bigint: ${e.tag}(h'${Gr(e.contents)})`);let n=e.contents.reduce((i,s)=>i<<8n|BigInt(s),0n);if(r&&(n=-1n-n),t.requirePreferred&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER)throw new Error(`Decoding bigint that could have been int: ${n}n`);return t.boxed?ao(n,e.contents):n}const ly=wc.bind(null,!1),uy=wc.bind(null,!0);ly.comment=(r,e)=>`(Positive BigInt) ${wc(!1,r,e)}n`,uy.comment=(r,e)=>`(Negative BigInt) ${wc(!0,r,e)}n`,ze.registerDecoder(Et.POS_BIGINT,ly),ze.registerDecoder(Et.NEG_BIGINT,uy);function af(r,e){return Ri(r.contents),r}af.comment=(r,e,t)=>{Ri(r.contents);const n={...e,initialDepth:t+2,noPrefixHex:!0},i=pc(r);let s=2**((i[0]&31)-24)+1;const a=i[s]&31;let c=Gr(i.subarray(s,++s));a>=24&&(c+=" ",c+=Gr(i.subarray(s,s+2**(a-24)))),n.minCol=Math.max(n.minCol,(t+1)*2+c.length);const u=kv(r.contents,n);let d=`Embedded CBOR
|
|
152
|
+
`;return d+=`${"".padStart((t+1)*2," ")}${c}`.padEnd(n.minCol+1," "),d+=`-- Bytes (Length: ${r.contents.length})
|
|
153
|
+
`,d+=u,d},af.noChildren=!0,ze.registerDecoder(Et.CBOR,af),ze.registerDecoder(Et.URI,r=>(Yn(r.contents),new URL(r.contents)),"URI"),jt(URL,r=>[Et.URI,r.toString()]),ze.registerDecoder(Et.BASE64URL,r=>(Yn(r.contents),iv(r.contents)),"Base64url-encoded"),ze.registerDecoder(Et.BASE64,r=>(Yn(r.contents),ef(r.contents)),"Base64-encoded"),ze.registerDecoder(35,r=>(Yn(r.contents),new RegExp(r.contents)),"RegExp"),ze.registerDecoder(21065,r=>{Yn(r.contents);let e=r.contents.replace(new RegExp("(?<!\\\\)(?<!\\[(?:[^\\]]|\\\\\\])*)\\.","g"),`[^
|
|
154
|
+
\r]`);return e=`^(?:${e})$`,new RegExp(e,"u")},"I-RegExp"),ze.registerDecoder(Et.REGEXP,r=>{if(oy(r.contents),r.contents.length<1||r.contents.length>2)throw new Error(`Invalid RegExp Array: ${r.contents}`);return new RegExp(r.contents[0],r.contents[1])},"RegExp"),jt(RegExp,r=>[Et.REGEXP,[r.source,r.flags]]),ze.registerDecoder(64,r=>(Ri(r.contents),r.contents),"uint8 Typed Array");function tr(r,e,t){Ri(r.contents);let n=r.contents.length;if(n%e.BYTES_PER_ELEMENT!==0)throw new Error(`Number of bytes must be divisible by ${e.BYTES_PER_ELEMENT}, got: ${n}`);n/=e.BYTES_PER_ELEMENT;const i=new e(n),s=new DataView(r.contents.buffer,r.contents.byteOffset,r.contents.byteLength),a=s[`get${e.name.replace(/Array/,"")}`].bind(s);for(let c=0;c<n;c++)i[c]=a(c*e.BYTES_PER_ELEMENT,t);return i}function Jn(r,e,t,n,i){const s=i.forceEndian??iy;if(gc(s?e:t,r,i),zr(n.byteLength,r,me.BYTE_STRING),iy===s)r.write(new Uint8Array(n.buffer,n.byteOffset,n.byteLength));else{const a=`write${n.constructor.name.replace(/Array/,"")}`,c=r[a].bind(r);for(const u of n)c(u,s)}}ze.registerDecoder(65,r=>tr(r,Uint16Array,!1),"uint16, big endian, Typed Array"),ze.registerDecoder(66,r=>tr(r,Uint32Array,!1),"uint32, big endian, Typed Array"),ze.registerDecoder(67,r=>tr(r,BigUint64Array,!1),"uint64, big endian, Typed Array"),ze.registerDecoder(68,r=>(Ri(r.contents),new Uint8ClampedArray(r.contents)),"uint8 Typed Array, clamped arithmetic"),jt(Uint8ClampedArray,r=>[68,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),ze.registerDecoder(69,r=>tr(r,Uint16Array,!0),"uint16, little endian, Typed Array"),jt(Uint16Array,(r,e,t)=>Jn(e,69,65,r,t)),ze.registerDecoder(70,r=>tr(r,Uint32Array,!0),"uint32, little endian, Typed Array"),jt(Uint32Array,(r,e,t)=>Jn(e,70,66,r,t)),ze.registerDecoder(71,r=>tr(r,BigUint64Array,!0),"uint64, little endian, Typed Array"),jt(BigUint64Array,(r,e,t)=>Jn(e,71,67,r,t)),ze.registerDecoder(72,r=>(Ri(r.contents),new Int8Array(r.contents)),"sint8 Typed Array"),jt(Int8Array,r=>[72,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),ze.registerDecoder(73,r=>tr(r,Int16Array,!1),"sint16, big endian, Typed Array"),ze.registerDecoder(74,r=>tr(r,Int32Array,!1),"sint32, big endian, Typed Array"),ze.registerDecoder(75,r=>tr(r,BigInt64Array,!1),"sint64, big endian, Typed Array"),ze.registerDecoder(77,r=>tr(r,Int16Array,!0),"sint16, little endian, Typed Array"),jt(Int16Array,(r,e,t)=>Jn(e,77,73,r,t)),ze.registerDecoder(78,r=>tr(r,Int32Array,!0),"sint32, little endian, Typed Array"),jt(Int32Array,(r,e,t)=>Jn(e,78,74,r,t)),ze.registerDecoder(79,r=>tr(r,BigInt64Array,!0),"sint64, little endian, Typed Array"),jt(BigInt64Array,(r,e,t)=>Jn(e,79,75,r,t)),ze.registerDecoder(81,r=>tr(r,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),ze.registerDecoder(82,r=>tr(r,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),ze.registerDecoder(85,r=>tr(r,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),jt(Float32Array,(r,e,t)=>Jn(e,85,81,r,t)),ze.registerDecoder(86,r=>tr(r,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),jt(Float64Array,(r,e,t)=>Jn(e,86,82,r,t)),ze.registerDecoder(Et.SET,r=>(oy(r.contents),new Set(r.contents)),"Set"),jt(Set,r=>[Et.SET,[...r]]),ze.registerDecoder(Et.JSON,r=>(Yn(r.contents),JSON.parse(r.contents)),"JSON-encoded"),ze.registerDecoder(Et.SELF_DESCRIBED,r=>r.contents,"Self-Described"),ze.registerDecoder(Et.INVALID_16,()=>{throw new Error(`Tag always invalid: ${Et.INVALID_16}`)},"Invalid"),ze.registerDecoder(Et.INVALID_32,()=>{throw new Error(`Tag always invalid: ${Et.INVALID_32}`)},"Invalid"),ze.registerDecoder(Et.INVALID_64,()=>{throw new Error(`Tag always invalid: ${Et.INVALID_64}`)},"Invalid");function cf(r){throw new Error(`Encoding ${r.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}jt(ArrayBuffer,cf),jt(DataView,cf),typeof SharedArrayBuffer<"u"&&jt(SharedArrayBuffer,cf);function bc(r){return[NaN,r.valueOf()]}jt(Boolean,bc),jt(Number,bc),jt(String,bc),jt(BigInt,bc);function fy(r,e={}){const t={...qn.defaultDecodeOptions};if(e.dcbor?Object.assign(t,qn.dcborDecodeOptions):e.cde&&Object.assign(t,qn.cdeDecodeOptions),Object.assign(t,e),Object.hasOwn(t,"rejectLongNumbers"))throw new TypeError("rejectLongNumbers has changed to requirePreferred");t.boxed&&(t.saveOriginal=!0);const n=new lo(r,t);let i,s;for(const a of n){if(s=qn.create(a,i,t,n),a[2]===Er.BREAK)if(i!=null&&i.isStreaming)i.left=0;else throw new Error("Unexpected BREAK");else i&&i.push(s,n,a[3]);for(s instanceof qn&&(i=s);i!=null&&i.done;){s=i.convert(n);const c=i.parent;c==null||c.replaceLast(s,i,n),i=c}}return s}new TextEncoder;var it;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),a={};for(const c of s)a[c]=i[c];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(it||(it={}));var lf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(lf||(lf={}));const ae=it.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Xn=r=>{switch(typeof r){case"undefined":return ae.undefined;case"string":return ae.string;case"number":return isNaN(r)?ae.nan:ae.number;case"boolean":return ae.boolean;case"function":return ae.function;case"bigint":return ae.bigint;case"symbol":return ae.symbol;case"object":return Array.isArray(r)?ae.array:r===null?ae.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ae.promise:typeof Map<"u"&&r instanceof Map?ae.map:typeof Set<"u"&&r instanceof Set?ae.set:typeof Date<"u"&&r instanceof Date?ae.date:ae.object;default:return ae.unknown}},Z=it.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"]),Cv=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Ir extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let c=n,u=0;for(;u<a.path.length;){const d=a.path[u];u===a.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(a))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}};return i(this),n}static assert(e){if(!(e instanceof Ir))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,it.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Ir.create=r=>new Ir(r);const ws=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===ae.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,it.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${it.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${it.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${it.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:it.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Z.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,it.assertNever(r)}return{message:t}};let hy=ws;function Bv(r){hy=r}function xc(){return hy}const Ac=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="";const u=n.filter(d=>!!d).slice().reverse();for(const d of u)c=d(a,{data:e,defaultError:c}).message;return{...i,path:s,message:c}},Ov=[];function ne(r,e){const t=xc(),n=Ac({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ws?void 0:ws].filter(i=>!!i)});r.common.issues.push(n)}class rr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return Te;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return rr.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return Te;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}}const Te=Object.freeze({status:"aborted"}),bs=r=>({status:"dirty",value:r}),ur=r=>({status:"valid",value:r}),uf=r=>r.status==="aborted",ff=r=>r.status==="dirty",uo=r=>r.status==="valid",fo=r=>typeof Promise<"u"&&r instanceof Promise;function _c(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function dy(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}typeof SuppressedError=="function"&&SuppressedError;var Se;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Se||(Se={}));var ho,po;class an{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const py=(r,e)=>{if(uo(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Ir(r.common.issues);return this._error=t,this._error}}};function Ue(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||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:(a,c)=>{var u,d;const{message:x}=r;return a.code==="invalid_enum_value"?{message:x??c.defaultError}:typeof c.data>"u"?{message:(u=x??n)!==null&&u!==void 0?u:c.defaultError}:a.code!=="invalid_type"?{message:c.defaultError}:{message:(d=x??t)!==null&&d!==void 0?d:c.defaultError}},description:i}}class Le{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)}get description(){return this._def.description}_getType(e){return Xn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Xn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new rr,ctx:{common:e.parent.common,data:e.data,parsedType:Xn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(fo(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return py(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(fo(i)?i:Promise.resolve(i));return py(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),c=()=>s.addIssue({code:Z.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(u=>u?!0:(c(),!1)):a?!0:(c(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new Wr({schema:this,typeName:Oe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ln.create(this,this._def)}nullable(){return ri.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Kr.create(this,this._def)}promise(){return Ss.create(this,this._def)}or(e){return mo.create([this,e],this._def)}and(e){return wo.create(this,e,this._def)}transform(e){return new Wr({...Ue(this._def),schema:this,typeName:Oe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new So({...Ue(this._def),innerType:this,defaultValue:t,typeName:Oe.ZodDefault})}brand(){return new pf({typeName:Oe.ZodBranded,type:this,...Ue(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Eo({...Ue(this._def),innerType:this,catchValue:t,typeName:Oe.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Io.create(this,e)}readonly(){return ko.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Tv=/^c[^\s-]{8,}$/i,Nv=/^[0-9a-z]+$/,jv=/^[0-9A-HJKMNP-TV-Z]{26}$/,Rv=/^[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,Pv=/^[a-z0-9_-]{21}$/i,Uv=/^[-+]?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)?)??$/,Dv=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$v="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let hf;const Mv=/^(?:(?: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])$/,Vv=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Lv=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yy="((\\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])))",Hv=new RegExp(`^${yy}$`);function gy(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Fv(r){return new RegExp(`^${gy(r)}$`)}function vy(r){let e=`${yy}T${gy(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Gv(r,e){return!!((e==="v4"||!e)&&Mv.test(r)||(e==="v6"||!e)&&Vv.test(r))}class Zr extends Le{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ae.string){const s=this._getOrReturnCtx(e);return ne(s,{code:Z.invalid_type,expected:ae.string,received:s.parsedType}),Te}const n=new rr;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),ne(i,{code:Z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),ne(i,{code:Z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,c=e.data.length<s.value;(a||c)&&(i=this._getOrReturnCtx(e,i),a?ne(i,{code:Z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&ne(i,{code:Z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")Dv.test(e.data)||(i=this._getOrReturnCtx(e,i),ne(i,{validation:"email",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")hf||(hf=new RegExp($v,"u")),hf.test(e.data)||(i=this._getOrReturnCtx(e,i),ne(i,{validation:"emoji",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Rv.test(e.data)||(i=this._getOrReturnCtx(e,i),ne(i,{validation:"uuid",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")Pv.test(e.data)||(i=this._getOrReturnCtx(e,i),ne(i,{validation:"nanoid",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")Tv.test(e.data)||(i=this._getOrReturnCtx(e,i),ne(i,{validation:"cuid",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Nv.test(e.data)||(i=this._getOrReturnCtx(e,i),ne(i,{validation:"cuid2",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")jv.test(e.data)||(i=this._getOrReturnCtx(e,i),ne(i,{validation:"ulid",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),ne(i,{validation:"url",code:Z.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),ne(i,{validation:"regex",code:Z.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),ne(i,{code:Z.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),ne(i,{code:Z.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),ne(i,{code:Z.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?vy(s).test(e.data)||(i=this._getOrReturnCtx(e,i),ne(i,{code:Z.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?Hv.test(e.data)||(i=this._getOrReturnCtx(e,i),ne(i,{code:Z.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Fv(s).test(e.data)||(i=this._getOrReturnCtx(e,i),ne(i,{code:Z.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?Uv.test(e.data)||(i=this._getOrReturnCtx(e,i),ne(i,{validation:"duration",code:Z.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Gv(e.data,s.version)||(i=this._getOrReturnCtx(e,i),ne(i,{validation:"ip",code:Z.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Lv.test(e.data)||(i=this._getOrReturnCtx(e,i),ne(i,{validation:"base64",code:Z.invalid_string,message:s.message}),n.dirty()):it.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:Z.invalid_string,...Se.errToObj(n)})}_addCheck(e){return new Zr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Se.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Se.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Se.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Se.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Se.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Se.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Se.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Se.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Se.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Se.errToObj(e)})}datetime(e){var t,n;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:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Se.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,...Se.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Se.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Se.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Se.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Se.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Se.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Se.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Se.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Se.errToObj(t)})}nonempty(e){return this.min(1,Se.errToObj(e))}trim(){return new Zr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Zr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Zr({...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 isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Zr.create=r=>{var e;return new Zr({checks:[],typeName:Oe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Ue(r)})};function zv(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}class Qn extends Le{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)!==ae.number){const s=this._getOrReturnCtx(e);return ne(s,{code:Z.invalid_type,expected:ae.number,received:s.parsedType}),Te}let n;const i=new rr;for(const s of this._def.checks)s.kind==="int"?it.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),ne(n,{code:Z.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),ne(n,{code:Z.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),ne(n,{code:Z.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?zv(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),ne(n,{code:Z.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),ne(n,{code:Z.not_finite,message:s.message}),i.dirty()):it.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Se.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Se.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Se.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Se.toString(t))}setLimit(e,t,n,i){return new Qn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Se.toString(i)}]})}_addCheck(e){return new Qn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Se.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Se.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Se.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Se.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Se.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Se.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&it.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Qn.create=r=>new Qn({checks:[],typeName:Oe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Ue(r)});class ei extends Le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==ae.bigint){const s=this._getOrReturnCtx(e);return ne(s,{code:Z.invalid_type,expected:ae.bigint,received:s.parsedType}),Te}let n;const i=new rr;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),ne(n,{code:Z.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),ne(n,{code:Z.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),ne(n,{code:Z.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):it.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Se.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Se.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Se.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Se.toString(t))}setLimit(e,t,n,i){return new ei({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Se.toString(i)}]})}_addCheck(e){return new ei({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Se.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Se.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ei.create=r=>{var e;return new ei({checks:[],typeName:Oe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Ue(r)})};class yo extends Le{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ae.boolean){const n=this._getOrReturnCtx(e);return ne(n,{code:Z.invalid_type,expected:ae.boolean,received:n.parsedType}),Te}return ur(e.data)}}yo.create=r=>new yo({typeName:Oe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Ue(r)});class Pi extends Le{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ae.date){const s=this._getOrReturnCtx(e);return ne(s,{code:Z.invalid_type,expected:ae.date,received:s.parsedType}),Te}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return ne(s,{code:Z.invalid_date}),Te}const n=new rr;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),ne(i,{code:Z.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),ne(i,{code:Z.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):it.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Pi({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Se.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Se.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Pi.create=r=>new Pi({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Oe.ZodDate,...Ue(r)});class Sc extends Le{_parse(e){if(this._getType(e)!==ae.symbol){const n=this._getOrReturnCtx(e);return ne(n,{code:Z.invalid_type,expected:ae.symbol,received:n.parsedType}),Te}return ur(e.data)}}Sc.create=r=>new Sc({typeName:Oe.ZodSymbol,...Ue(r)});class go extends Le{_parse(e){if(this._getType(e)!==ae.undefined){const n=this._getOrReturnCtx(e);return ne(n,{code:Z.invalid_type,expected:ae.undefined,received:n.parsedType}),Te}return ur(e.data)}}go.create=r=>new go({typeName:Oe.ZodUndefined,...Ue(r)});class vo extends Le{_parse(e){if(this._getType(e)!==ae.null){const n=this._getOrReturnCtx(e);return ne(n,{code:Z.invalid_type,expected:ae.null,received:n.parsedType}),Te}return ur(e.data)}}vo.create=r=>new vo({typeName:Oe.ZodNull,...Ue(r)});class xs extends Le{constructor(){super(...arguments),this._any=!0}_parse(e){return ur(e.data)}}xs.create=r=>new xs({typeName:Oe.ZodAny,...Ue(r)});class Ui extends Le{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ur(e.data)}}Ui.create=r=>new Ui({typeName:Oe.ZodUnknown,...Ue(r)});class Nn extends Le{_parse(e){const t=this._getOrReturnCtx(e);return ne(t,{code:Z.invalid_type,expected:ae.never,received:t.parsedType}),Te}}Nn.create=r=>new Nn({typeName:Oe.ZodNever,...Ue(r)});class Ec extends Le{_parse(e){if(this._getType(e)!==ae.undefined){const n=this._getOrReturnCtx(e);return ne(n,{code:Z.invalid_type,expected:ae.void,received:n.parsedType}),Te}return ur(e.data)}}Ec.create=r=>new Ec({typeName:Oe.ZodVoid,...Ue(r)});class Kr extends Le{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ae.array)return ne(t,{code:Z.invalid_type,expected:ae.array,received:t.parsedType}),Te;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,c=t.data.length<i.exactLength.value;(a||c)&&(ne(t,{code:a?Z.too_big:Z.too_small,minimum:c?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(ne(t,{code:Z.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(ne(t,{code:Z.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,c)=>i.type._parseAsync(new an(t,a,t.path,c)))).then(a=>rr.mergeArray(n,a));const s=[...t.data].map((a,c)=>i.type._parseSync(new an(t,a,t.path,c)));return rr.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Kr({...this._def,minLength:{value:e,message:Se.toString(t)}})}max(e,t){return new Kr({...this._def,maxLength:{value:e,message:Se.toString(t)}})}length(e,t){return new Kr({...this._def,exactLength:{value:e,message:Se.toString(t)}})}nonempty(e){return this.min(1,e)}}Kr.create=(r,e)=>new Kr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Oe.ZodArray,...Ue(e)});function As(r){if(r instanceof Tt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=ln.create(As(n))}return new Tt({...r._def,shape:()=>e})}else return r instanceof Kr?new Kr({...r._def,type:As(r.element)}):r instanceof ln?ln.create(As(r.unwrap())):r instanceof ri?ri.create(As(r.unwrap())):r instanceof cn?cn.create(r.items.map(e=>As(e))):r}class Tt extends Le{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(),t=it.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ae.object){const d=this._getOrReturnCtx(e);return ne(d,{code:Z.invalid_type,expected:ae.object,received:d.parsedType}),Te}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof Nn&&this._def.unknownKeys==="strip"))for(const d in i.data)a.includes(d)||c.push(d);const u=[];for(const d of a){const x=s[d],I=i.data[d];u.push({key:{status:"valid",value:d},value:x._parse(new an(i,I,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof Nn){const d=this._def.unknownKeys;if(d==="passthrough")for(const x of c)u.push({key:{status:"valid",value:x},value:{status:"valid",value:i.data[x]}});else if(d==="strict")c.length>0&&(ne(i,{code:Z.unrecognized_keys,keys:c}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const x of c){const I=i.data[x];u.push({key:{status:"valid",value:x},value:d._parse(new an(i,I,i.path,x)),alwaysSet:x in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const d=[];for(const x of u){const I=await x.key,J=await x.value;d.push({key:I,value:J,alwaysSet:x.alwaysSet})}return d}).then(d=>rr.mergeObjectSync(n,d)):rr.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Se.errToObj,new Tt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,c;const u=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(c=Se.errToObj(e).message)!==null&&c!==void 0?c:u}:{message:u}}}:{}})}strip(){return new Tt({...this._def,unknownKeys:"strip"})}passthrough(){return new Tt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Tt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Tt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Oe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Tt({...this._def,catchall:e})}pick(e){const t={};return it.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Tt({...this._def,shape:()=>t})}omit(e){const t={};return it.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Tt({...this._def,shape:()=>t})}deepPartial(){return As(this)}partial(e){const t={};return it.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Tt({...this._def,shape:()=>t})}required(e){const t={};return it.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof ln;)s=s._def.innerType;t[n]=s}}),new Tt({...this._def,shape:()=>t})}keyof(){return my(it.objectKeys(this.shape))}}Tt.create=(r,e)=>new Tt({shape:()=>r,unknownKeys:"strip",catchall:Nn.create(),typeName:Oe.ZodObject,...Ue(e)}),Tt.strictCreate=(r,e)=>new Tt({shape:()=>r,unknownKeys:"strict",catchall:Nn.create(),typeName:Oe.ZodObject,...Ue(e)}),Tt.lazycreate=(r,e)=>new Tt({shape:r,unknownKeys:"strip",catchall:Nn.create(),typeName:Oe.ZodObject,...Ue(e)});class mo extends Le{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const c of s)if(c.result.status==="valid")return c.result;for(const c of s)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const a=s.map(c=>new Ir(c.ctx.common.issues));return ne(t,{code:Z.invalid_union,unionErrors:a}),Te}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const u of n){const d={...t,common:{...t.common,issues:[]},parent:null},x=u._parseSync({data:t.data,path:t.path,parent:d});if(x.status==="valid")return x;x.status==="dirty"&&!s&&(s={result:x,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const c=a.map(u=>new Ir(u));return ne(t,{code:Z.invalid_union,unionErrors:c}),Te}}get options(){return this._def.options}}mo.create=(r,e)=>new mo({options:r,typeName:Oe.ZodUnion,...Ue(e)});const jn=r=>r instanceof xo?jn(r.schema):r instanceof Wr?jn(r.innerType()):r instanceof Ao?[r.value]:r instanceof ti?r.options:r instanceof _o?it.objectValues(r.enum):r instanceof So?jn(r._def.innerType):r instanceof go?[void 0]:r instanceof vo?[null]:r instanceof ln?[void 0,...jn(r.unwrap())]:r instanceof ri?[null,...jn(r.unwrap())]:r instanceof pf||r instanceof ko?jn(r.unwrap()):r instanceof Eo?jn(r._def.innerType):[];class Ic extends Le{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ae.object)return ne(t,{code:Z.invalid_type,expected:ae.object,received:t.parsedType}),Te;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(ne(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Te)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=jn(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of a){if(i.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);i.set(c,s)}}return new Ic({typeName:Oe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Ue(n)})}}function df(r,e){const t=Xn(r),n=Xn(e);if(r===e)return{valid:!0,data:r};if(t===ae.object&&n===ae.object){const i=it.objectKeys(e),s=it.objectKeys(r).filter(c=>i.indexOf(c)!==-1),a={...r,...e};for(const c of s){const u=df(r[c],e[c]);if(!u.valid)return{valid:!1};a[c]=u.data}return{valid:!0,data:a}}else if(t===ae.array&&n===ae.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],c=e[s],u=df(a,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===ae.date&&n===ae.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class wo extends Le{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(uf(s)||uf(a))return Te;const c=df(s.value,a.value);return c.valid?((ff(s)||ff(a))&&t.dirty(),{status:t.value,value:c.data}):(ne(n,{code:Z.invalid_intersection_types}),Te)};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(([s,a])=>i(s,a)):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}))}}wo.create=(r,e,t)=>new wo({left:r,right:e,typeName:Oe.ZodIntersection,...Ue(t)});class cn extends Le{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ae.array)return ne(n,{code:Z.invalid_type,expected:ae.array,received:n.parsedType}),Te;if(n.data.length<this._def.items.length)return ne(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Te;!this._def.rest&&n.data.length>this._def.items.length&&(ne(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,c)=>{const u=this._def.items[c]||this._def.rest;return u?u._parse(new an(n,a,n.path,c)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>rr.mergeArray(t,a)):rr.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new cn({...this._def,rest:e})}}cn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new cn({items:r,typeName:Oe.ZodTuple,rest:null,...Ue(e)})};class bo extends Le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ae.object)return ne(n,{code:Z.invalid_type,expected:ae.object,received:n.parsedType}),Te;const i=[],s=this._def.keyType,a=this._def.valueType;for(const c in n.data)i.push({key:s._parse(new an(n,c,n.path,c)),value:a._parse(new an(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?rr.mergeObjectAsync(t,i):rr.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Le?new bo({keyType:e,valueType:t,typeName:Oe.ZodRecord,...Ue(n)}):new bo({keyType:Zr.create(),valueType:e,typeName:Oe.ZodRecord,...Ue(t)})}}class kc extends Le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ae.map)return ne(n,{code:Z.invalid_type,expected:ae.map,received:n.parsedType}),Te;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([c,u],d)=>({key:i._parse(new an(n,c,n.path,[d,"key"])),value:s._parse(new an(n,u,n.path,[d,"value"]))}));if(n.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const u of a){const d=await u.key,x=await u.value;if(d.status==="aborted"||x.status==="aborted")return Te;(d.status==="dirty"||x.status==="dirty")&&t.dirty(),c.set(d.value,x.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const u of a){const d=u.key,x=u.value;if(d.status==="aborted"||x.status==="aborted")return Te;(d.status==="dirty"||x.status==="dirty")&&t.dirty(),c.set(d.value,x.value)}return{status:t.value,value:c}}}}kc.create=(r,e,t)=>new kc({valueType:e,keyType:r,typeName:Oe.ZodMap,...Ue(t)});class Di extends Le{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ae.set)return ne(n,{code:Z.invalid_type,expected:ae.set,received:n.parsedType}),Te;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(ne(n,{code:Z.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(ne(n,{code:Z.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(u){const d=new Set;for(const x of u){if(x.status==="aborted")return Te;x.status==="dirty"&&t.dirty(),d.add(x.value)}return{status:t.value,value:d}}const c=[...n.data.values()].map((u,d)=>s._parse(new an(n,u,n.path,d)));return n.common.async?Promise.all(c).then(u=>a(u)):a(c)}min(e,t){return new Di({...this._def,minSize:{value:e,message:Se.toString(t)}})}max(e,t){return new Di({...this._def,maxSize:{value:e,message:Se.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Di.create=(r,e)=>new Di({valueType:r,minSize:null,maxSize:null,typeName:Oe.ZodSet,...Ue(e)});class _s extends Le{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ae.function)return ne(t,{code:Z.invalid_type,expected:ae.function,received:t.parsedType}),Te;function n(c,u){return Ac({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xc(),ws].filter(d=>!!d),issueData:{code:Z.invalid_arguments,argumentsError:u}})}function i(c,u){return Ac({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xc(),ws].filter(d=>!!d),issueData:{code:Z.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ss){const c=this;return ur(async function(...u){const d=new Ir([]),x=await c._def.args.parseAsync(u,s).catch(j=>{throw d.addIssue(n(u,j)),d}),I=await Reflect.apply(a,this,x);return await c._def.returns._def.type.parseAsync(I,s).catch(j=>{throw d.addIssue(i(I,j)),d})})}else{const c=this;return ur(function(...u){const d=c._def.args.safeParse(u,s);if(!d.success)throw new Ir([n(u,d.error)]);const x=Reflect.apply(a,this,d.data),I=c._def.returns.safeParse(x,s);if(!I.success)throw new Ir([i(x,I.error)]);return I.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new _s({...this._def,args:cn.create(e).rest(Ui.create())})}returns(e){return new _s({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new _s({args:e||cn.create([]).rest(Ui.create()),returns:t||Ui.create(),typeName:Oe.ZodFunction,...Ue(n)})}}class xo extends Le{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}xo.create=(r,e)=>new xo({getter:r,typeName:Oe.ZodLazy,...Ue(e)});class Ao extends Le{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return ne(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),Te}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ao.create=(r,e)=>new Ao({value:r,typeName:Oe.ZodLiteral,...Ue(e)});function my(r,e){return new ti({values:r,typeName:Oe.ZodEnum,...Ue(e)})}class ti extends Le{constructor(){super(...arguments),ho.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return ne(t,{expected:it.joinValues(n),received:t.parsedType,code:Z.invalid_type}),Te}if(_c(this,ho)||dy(this,ho,new Set(this._def.values)),!_c(this,ho).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return ne(t,{received:t.data,code:Z.invalid_enum_value,options:n}),Te}return ur(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ti.create(e,{...this._def,...t})}exclude(e,t=this._def){return ti.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}ho=new WeakMap,ti.create=my;class _o extends Le{constructor(){super(...arguments),po.set(this,void 0)}_parse(e){const t=it.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ae.string&&n.parsedType!==ae.number){const i=it.objectValues(t);return ne(n,{expected:it.joinValues(i),received:n.parsedType,code:Z.invalid_type}),Te}if(_c(this,po)||dy(this,po,new Set(it.getValidEnumValues(this._def.values))),!_c(this,po).has(e.data)){const i=it.objectValues(t);return ne(n,{received:n.data,code:Z.invalid_enum_value,options:i}),Te}return ur(e.data)}get enum(){return this._def.values}}po=new WeakMap,_o.create=(r,e)=>new _o({values:r,typeName:Oe.ZodNativeEnum,...Ue(e)});class Ss extends Le{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ae.promise&&t.common.async===!1)return ne(t,{code:Z.invalid_type,expected:ae.promise,received:t.parsedType}),Te;const n=t.parsedType===ae.promise?t.data:Promise.resolve(t.data);return ur(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ss.create=(r,e)=>new Ss({type:r,typeName:Oe.ZodPromise,...Ue(e)});class Wr extends Le{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Oe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{ne(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async c=>{if(t.value==="aborted")return Te;const u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?Te:u.status==="dirty"||t.value==="dirty"?bs(u.value):u});{if(t.value==="aborted")return Te;const c=this._def.schema._parseSync({data:a,path:n.path,parent:n});return c.status==="aborted"?Te:c.status==="dirty"||t.value==="dirty"?bs(c.value):c}}if(i.type==="refinement"){const a=c=>{const u=i.refinement(c,s);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 c};if(n.common.async===!1){const c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?Te:(c.status==="dirty"&&t.dirty(),a(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?Te:(c.status==="dirty"&&t.dirty(),a(c.value).then(()=>({status:t.value,value:c.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!uo(a))return a;const c=i.transform(a.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>uo(a)?Promise.resolve(i.transform(a.value,s)).then(c=>({status:t.value,value:c})):a);it.assertNever(i)}}Wr.create=(r,e,t)=>new Wr({schema:r,typeName:Oe.ZodEffects,effect:e,...Ue(t)}),Wr.createWithPreprocess=(r,e,t)=>new Wr({schema:e,effect:{type:"preprocess",transform:r},typeName:Oe.ZodEffects,...Ue(t)});class ln extends Le{_parse(e){return this._getType(e)===ae.undefined?ur(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ln.create=(r,e)=>new ln({innerType:r,typeName:Oe.ZodOptional,...Ue(e)});class ri extends Le{_parse(e){return this._getType(e)===ae.null?ur(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ri.create=(r,e)=>new ri({innerType:r,typeName:Oe.ZodNullable,...Ue(e)});class So extends Le{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ae.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}So.create=(r,e)=>new So({innerType:r,typeName:Oe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ue(e)});class Eo extends Le{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return fo(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ir(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ir(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Eo.create=(r,e)=>new Eo({innerType:r,typeName:Oe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Ue(e)});class Cc extends Le{_parse(e){if(this._getType(e)!==ae.nan){const n=this._getOrReturnCtx(e);return ne(n,{code:Z.invalid_type,expected:ae.nan,received:n.parsedType}),Te}return{status:"valid",value:e.data}}}Cc.create=r=>new Cc({typeName:Oe.ZodNaN,...Ue(r)});const Zv=Symbol("zod_brand");class pf extends Le{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Io extends Le{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Te:s.status==="dirty"?(t.dirty(),bs(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Te:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new Io({in:e,out:t,typeName:Oe.ZodPipeline})}}class ko extends Le{_parse(e){const t=this._def.innerType._parse(e),n=i=>(uo(i)&&(i.value=Object.freeze(i.value)),i);return fo(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}ko.create=(r,e)=>new ko({innerType:r,typeName:Oe.ZodReadonly,...Ue(e)});function wy(r,e={},t){return r?xs.create().superRefine((n,i)=>{var s,a;if(!r(n)){const c=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(a=(s=c.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,d=typeof c=="string"?{message:c}:c;i.addIssue({code:"custom",...d,fatal:u})}}):xs.create()}const Kv={object:Tt.lazycreate};var Oe;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(Oe||(Oe={}));const Wv=(r,e={message:`Input not instance of ${r.name}`})=>wy(t=>t instanceof r,e),by=Zr.create,xy=Qn.create,qv=Cc.create,Yv=ei.create,Ay=yo.create,Jv=Pi.create,Xv=Sc.create,Qv=go.create,e1=vo.create,t1=xs.create,r1=Ui.create,n1=Nn.create,i1=Ec.create,s1=Kr.create,o1=Tt.create,a1=Tt.strictCreate,c1=mo.create,l1=Ic.create,u1=wo.create,f1=cn.create,h1=bo.create,d1=kc.create,p1=Di.create,y1=_s.create,g1=xo.create,v1=Ao.create,m1=ti.create,w1=_o.create,b1=Ss.create,_y=Wr.create,x1=ln.create,A1=ri.create,_1=Wr.createWithPreprocess,S1=Io.create;var Vt=Object.freeze({__proto__:null,defaultErrorMap:ws,setErrorMap:Bv,getErrorMap:xc,makeIssue:Ac,EMPTY_PATH:Ov,addIssueToContext:ne,ParseStatus:rr,INVALID:Te,DIRTY:bs,OK:ur,isAborted:uf,isDirty:ff,isValid:uo,isAsync:fo,get util(){return it},get objectUtil(){return lf},ZodParsedType:ae,getParsedType:Xn,ZodType:Le,datetimeRegex:vy,ZodString:Zr,ZodNumber:Qn,ZodBigInt:ei,ZodBoolean:yo,ZodDate:Pi,ZodSymbol:Sc,ZodUndefined:go,ZodNull:vo,ZodAny:xs,ZodUnknown:Ui,ZodNever:Nn,ZodVoid:Ec,ZodArray:Kr,ZodObject:Tt,ZodUnion:mo,ZodDiscriminatedUnion:Ic,ZodIntersection:wo,ZodTuple:cn,ZodRecord:bo,ZodMap:kc,ZodSet:Di,ZodFunction:_s,ZodLazy:xo,ZodLiteral:Ao,ZodEnum:ti,ZodNativeEnum:_o,ZodPromise:Ss,ZodEffects:Wr,ZodTransformer:Wr,ZodOptional:ln,ZodNullable:ri,ZodDefault:So,ZodCatch:Eo,ZodNaN:Cc,BRAND:Zv,ZodBranded:pf,ZodPipeline:Io,ZodReadonly:ko,custom:wy,Schema:Le,ZodSchema:Le,late:Kv,get ZodFirstPartyTypeKind(){return Oe},coerce:{string:r=>Zr.create({...r,coerce:!0}),number:r=>Qn.create({...r,coerce:!0}),boolean:r=>yo.create({...r,coerce:!0}),bigint:r=>ei.create({...r,coerce:!0}),date:r=>Pi.create({...r,coerce:!0})},any:t1,array:s1,bigint:Yv,boolean:Ay,date:Jv,discriminatedUnion:l1,effect:_y,enum:m1,function:y1,instanceof:Wv,intersection:u1,lazy:g1,literal:v1,map:d1,nan:qv,nativeEnum:w1,never:n1,null:e1,nullable:A1,number:xy,object:o1,oboolean:()=>Ay().optional(),onumber:()=>xy().optional(),optional:x1,ostring:()=>by().optional(),pipeline:S1,preprocess:_1,promise:b1,record:h1,set:p1,strictObject:a1,string:by,symbol:Xv,transformer:_y,tuple:f1,undefined:Qv,union:c1,unknown:r1,void:i1,NEVER:Te,ZodIssueCode:Z,quotelessJson:Cv,ZodError:Ir});const yf=new Uint8Array([48,130,2,17,48,130,1,150,160,3,2,1,2,2,17,0,249,49,117,104,27,144,175,225,29,70,204,180,228,231,248,86,48,10,6,8,42,134,72,206,61,4,3,3,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,30,23,13,49,57,49,48,50,56,49,51,50,56,48,53,90,23,13,52,57,49,48,50,56,49,52,50,56,48,53,90,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,118,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,98,0,4,252,2,84,235,166,8,193,243,104,112,226,154,218,144,190,70,56,50,146,115,110,137,75,255,246,114,217,137,68,75,80,81,229,52,164,177,246,219,227,192,188,88,26,50,183,177,118,7,14,222,18,214,154,63,234,33,27,102,231,82,207,125,209,221,9,95,111,19,112,244,23,8,67,217,220,16,1,33,228,207,99,1,40,9,102,68,135,201,121,98,132,48,77,197,63,244,163,66,48,64,48,15,6,3,85,29,19,1,1,255,4,5,48,3,1,1,255,48,29,6,3,85,29,14,4,22,4,20,144,37,181,13,217,5,71,231,150,195,150,250,114,157,207,153,169,223,75,150,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,134,48,10,6,8,42,134,72,206,61,4,3,3,3,105,0,48,102,2,49,0,163,127,47,145,161,201,189,94,231,184,98,124,22,152,210,85,3,142,31,3,67,249,91,99,169,98,140,61,57,128,149,69,161,30,188,191,46,59,85,216,174,238,113,180,195,214,173,243,2,49,0,162,243,155,22,5,178,112,40,165,221,75,160,105,181,1,110,101,180,251,222,143,224,6,29,106,83,25,127,156,218,245,217,67,188,97,252,43,235,3,203,111,238,141,35,2,243,223,246]);if(!yf||yf.length===0)throw new Error("AWS root certificate is empty or not loaded correctly");const E1=Vt.object({module_id:Vt.string().min(1),digest:Vt.literal("SHA384"),timestamp:Vt.number().min(1677721600),pcrs:Vt.map(Vt.number(),Vt.instanceof(Uint8Array)),certificate:Vt.instanceof(Uint8Array),cabundle:Vt.array(Vt.instanceof(Uint8Array)),public_key:Vt.nullable(Vt.instanceof(Uint8Array)),user_data:Vt.nullable(Vt.instanceof(Uint8Array)),nonce:Vt.nullable(Vt.instanceof(Uint8Array))}),I1=Vt.object({protected:Vt.instanceof(Uint8Array),payload:Vt.instanceof(Uint8Array),signature:Vt.instanceof(Uint8Array)});async function k1(r){try{if(!r)throw new Error("Attestation document is empty.");const e=No(r),t=fy(e),n=t[0],i=t[2],s=t[3];return I1.parse({protected:n,payload:i,signature:s})}catch(e){throw console.error("Error parsing document data:",e),new Error("Failed to parse document data.")}}async function C1(r){try{const e=fy(r);return E1.parse(e)}catch(e){throw console.error("Error parsing document payload:",e),new Error("Failed to parse document payload.")}}function B1(r,e){const t=["Signature1",r,new Uint8Array(0),e];return vc(t)}async function O1(r,e){try{console.log("SIGNATURE:"),console.log(wn(r.signature));const t=B1(r.protected,r.payload),n=await crypto.subtle.digest("SHA-384",t);return console.log("SIGNATURE STRUCTURE DIGEST:"),console.log(wn(new Uint8Array(n))),await crypto.subtle.verify({name:"ECDSA",hash:"SHA-384"},e,r.signature,t)}catch(t){throw console.error("Error verifying signature:",t),t instanceof Error?new Error(`Signature verification failed: ${t.message}`):new Error(`Signature verification failed: ${t}`)}}async function T1(r,e,t){try{const n=await k1(r),i=await C1(n.payload);if(!i.nonce)throw new Error("Attestation document does not have a nonce.");const a=new TextDecoder("utf-8").decode(i.nonce);if(t!==a)throw console.log("Nonce mismatch"),console.log("Provided nonce:",t),console.log("Attestation document nonce:",a),new Error("Attestation document's nonce does not match the provided nonce.");const c=[],u=wn(i.cabundle[0]);if(u!==wn(e))throw console.error("Root cert doesn't match first cert"),console.log("First cert base64:",u),console.log("Trusted root cert base64:",wn(e)),new Error("Root cert does not match first cert in attestation document.");for(let k=0;k<i.cabundle.length;k++){const P=new so(i.cabundle[k]);c.push(P)}const d=new so(i.certificate),I=await new ev({certificates:c}).build(d);console.log("Chain items:",I);const j=new Date().getTime();for(let k=0;k<I.length;k++){const P=I[k];if(console.log("CERT: ",k),console.log(P.subject),console.log("Not before:",P.notBefore),console.log("Not after:",P.notAfter),console.log(P.toString("pem")),P.notBefore.getTime()>j||P.notAfter.getTime()<j)throw new Error("Certificate is expired.");console.log(`Certificate ${k} is not expired.`)}if(I.length!==i.cabundle.length+1)throw new Error("Certificate chain length does not match length of cabundle.");const w=d.publicKey;console.log("PUBLIC KEY:"),console.log(wn(new Uint8Array(w.rawData)));const A=await w.export(),C=await O1(n,A);if(console.log("Signature verified:",C),!C)throw new Error("Signature verification failed.");return i}catch(n){throw console.error("Error verifying attestation document:",n),n}}async function N1(r){try{const e=await V1(r);return await T1(e,yf,r)}catch(e){throw e instanceof Error?(console.error("Error verifying attestation document:",e),new Error(`Couldn't process attestation document: ${e.message}`)):(console.error("Error verifying attestation document:",e),new Error("Couldn't process attestation document."))}}function j1(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Sy={exports:{}};const R1=Rc(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e){var t=function(l){var y,p=new Float64Array(16);if(l)for(y=0;y<l.length;y++)p[y]=l[y];return p},n=function(){throw new Error("no PRNG")},i=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var a=t(),c=t([1]),u=t([56129,1]),d=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),x=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),I=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),J=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),j=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function w(l,y,p,o){l[y]=p>>24&255,l[y+1]=p>>16&255,l[y+2]=p>>8&255,l[y+3]=p&255,l[y+4]=o>>24&255,l[y+5]=o>>16&255,l[y+6]=o>>8&255,l[y+7]=o&255}function A(l,y,p,o,v){var h,m=0;for(h=0;h<v;h++)m|=l[y+h]^p[o+h];return(1&m-1>>>8)-1}function C(l,y,p,o){return A(l,y,p,o,16)}function k(l,y,p,o){return A(l,y,p,o,32)}function P(l,y,p,o){for(var v=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,h=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,m=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,S=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,N=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,K=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,F=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,fe=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,L=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,ge=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,he=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,ve=p[16]&255|(p[17]&255)<<8|(p[18]&255)<<16|(p[19]&255)<<24,Ee=p[20]&255|(p[21]&255)<<8|(p[22]&255)<<16|(p[23]&255)<<24,Ie=p[24]&255|(p[25]&255)<<8|(p[26]&255)<<16|(p[27]&255)<<24,ke=p[28]&255|(p[29]&255)<<8|(p[30]&255)<<16|(p[31]&255)<<24,be=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,le=v,_e=h,ie=m,ye=S,we=N,re=K,O=F,T=fe,H=L,U=ge,D=he,G=ve,Be=Ee,$e=Ie,Ve=ke,Me=be,b,We=0;We<20;We+=2)b=le+Be|0,we^=b<<7|b>>>25,b=we+le|0,H^=b<<9|b>>>23,b=H+we|0,Be^=b<<13|b>>>19,b=Be+H|0,le^=b<<18|b>>>14,b=re+_e|0,U^=b<<7|b>>>25,b=U+re|0,$e^=b<<9|b>>>23,b=$e+U|0,_e^=b<<13|b>>>19,b=_e+$e|0,re^=b<<18|b>>>14,b=D+O|0,Ve^=b<<7|b>>>25,b=Ve+D|0,ie^=b<<9|b>>>23,b=ie+Ve|0,O^=b<<13|b>>>19,b=O+ie|0,D^=b<<18|b>>>14,b=Me+G|0,ye^=b<<7|b>>>25,b=ye+Me|0,T^=b<<9|b>>>23,b=T+ye|0,G^=b<<13|b>>>19,b=G+T|0,Me^=b<<18|b>>>14,b=le+ye|0,_e^=b<<7|b>>>25,b=_e+le|0,ie^=b<<9|b>>>23,b=ie+_e|0,ye^=b<<13|b>>>19,b=ye+ie|0,le^=b<<18|b>>>14,b=re+we|0,O^=b<<7|b>>>25,b=O+re|0,T^=b<<9|b>>>23,b=T+O|0,we^=b<<13|b>>>19,b=we+T|0,re^=b<<18|b>>>14,b=D+U|0,G^=b<<7|b>>>25,b=G+D|0,H^=b<<9|b>>>23,b=H+G|0,U^=b<<13|b>>>19,b=U+H|0,D^=b<<18|b>>>14,b=Me+Ve|0,Be^=b<<7|b>>>25,b=Be+Me|0,$e^=b<<9|b>>>23,b=$e+Be|0,Ve^=b<<13|b>>>19,b=Ve+$e|0,Me^=b<<18|b>>>14;le=le+v|0,_e=_e+h|0,ie=ie+m|0,ye=ye+S|0,we=we+N|0,re=re+K|0,O=O+F|0,T=T+fe|0,H=H+L|0,U=U+ge|0,D=D+he|0,G=G+ve|0,Be=Be+Ee|0,$e=$e+Ie|0,Ve=Ve+ke|0,Me=Me+be|0,l[0]=le>>>0&255,l[1]=le>>>8&255,l[2]=le>>>16&255,l[3]=le>>>24&255,l[4]=_e>>>0&255,l[5]=_e>>>8&255,l[6]=_e>>>16&255,l[7]=_e>>>24&255,l[8]=ie>>>0&255,l[9]=ie>>>8&255,l[10]=ie>>>16&255,l[11]=ie>>>24&255,l[12]=ye>>>0&255,l[13]=ye>>>8&255,l[14]=ye>>>16&255,l[15]=ye>>>24&255,l[16]=we>>>0&255,l[17]=we>>>8&255,l[18]=we>>>16&255,l[19]=we>>>24&255,l[20]=re>>>0&255,l[21]=re>>>8&255,l[22]=re>>>16&255,l[23]=re>>>24&255,l[24]=O>>>0&255,l[25]=O>>>8&255,l[26]=O>>>16&255,l[27]=O>>>24&255,l[28]=T>>>0&255,l[29]=T>>>8&255,l[30]=T>>>16&255,l[31]=T>>>24&255,l[32]=H>>>0&255,l[33]=H>>>8&255,l[34]=H>>>16&255,l[35]=H>>>24&255,l[36]=U>>>0&255,l[37]=U>>>8&255,l[38]=U>>>16&255,l[39]=U>>>24&255,l[40]=D>>>0&255,l[41]=D>>>8&255,l[42]=D>>>16&255,l[43]=D>>>24&255,l[44]=G>>>0&255,l[45]=G>>>8&255,l[46]=G>>>16&255,l[47]=G>>>24&255,l[48]=Be>>>0&255,l[49]=Be>>>8&255,l[50]=Be>>>16&255,l[51]=Be>>>24&255,l[52]=$e>>>0&255,l[53]=$e>>>8&255,l[54]=$e>>>16&255,l[55]=$e>>>24&255,l[56]=Ve>>>0&255,l[57]=Ve>>>8&255,l[58]=Ve>>>16&255,l[59]=Ve>>>24&255,l[60]=Me>>>0&255,l[61]=Me>>>8&255,l[62]=Me>>>16&255,l[63]=Me>>>24&255}function $(l,y,p,o){for(var v=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,h=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,m=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,S=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,N=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,K=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,F=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,fe=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,L=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,ge=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,he=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,ve=p[16]&255|(p[17]&255)<<8|(p[18]&255)<<16|(p[19]&255)<<24,Ee=p[20]&255|(p[21]&255)<<8|(p[22]&255)<<16|(p[23]&255)<<24,Ie=p[24]&255|(p[25]&255)<<8|(p[26]&255)<<16|(p[27]&255)<<24,ke=p[28]&255|(p[29]&255)<<8|(p[30]&255)<<16|(p[31]&255)<<24,be=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,le=v,_e=h,ie=m,ye=S,we=N,re=K,O=F,T=fe,H=L,U=ge,D=he,G=ve,Be=Ee,$e=Ie,Ve=ke,Me=be,b,We=0;We<20;We+=2)b=le+Be|0,we^=b<<7|b>>>25,b=we+le|0,H^=b<<9|b>>>23,b=H+we|0,Be^=b<<13|b>>>19,b=Be+H|0,le^=b<<18|b>>>14,b=re+_e|0,U^=b<<7|b>>>25,b=U+re|0,$e^=b<<9|b>>>23,b=$e+U|0,_e^=b<<13|b>>>19,b=_e+$e|0,re^=b<<18|b>>>14,b=D+O|0,Ve^=b<<7|b>>>25,b=Ve+D|0,ie^=b<<9|b>>>23,b=ie+Ve|0,O^=b<<13|b>>>19,b=O+ie|0,D^=b<<18|b>>>14,b=Me+G|0,ye^=b<<7|b>>>25,b=ye+Me|0,T^=b<<9|b>>>23,b=T+ye|0,G^=b<<13|b>>>19,b=G+T|0,Me^=b<<18|b>>>14,b=le+ye|0,_e^=b<<7|b>>>25,b=_e+le|0,ie^=b<<9|b>>>23,b=ie+_e|0,ye^=b<<13|b>>>19,b=ye+ie|0,le^=b<<18|b>>>14,b=re+we|0,O^=b<<7|b>>>25,b=O+re|0,T^=b<<9|b>>>23,b=T+O|0,we^=b<<13|b>>>19,b=we+T|0,re^=b<<18|b>>>14,b=D+U|0,G^=b<<7|b>>>25,b=G+D|0,H^=b<<9|b>>>23,b=H+G|0,U^=b<<13|b>>>19,b=U+H|0,D^=b<<18|b>>>14,b=Me+Ve|0,Be^=b<<7|b>>>25,b=Be+Me|0,$e^=b<<9|b>>>23,b=$e+Be|0,Ve^=b<<13|b>>>19,b=Ve+$e|0,Me^=b<<18|b>>>14;l[0]=le>>>0&255,l[1]=le>>>8&255,l[2]=le>>>16&255,l[3]=le>>>24&255,l[4]=re>>>0&255,l[5]=re>>>8&255,l[6]=re>>>16&255,l[7]=re>>>24&255,l[8]=D>>>0&255,l[9]=D>>>8&255,l[10]=D>>>16&255,l[11]=D>>>24&255,l[12]=Me>>>0&255,l[13]=Me>>>8&255,l[14]=Me>>>16&255,l[15]=Me>>>24&255,l[16]=O>>>0&255,l[17]=O>>>8&255,l[18]=O>>>16&255,l[19]=O>>>24&255,l[20]=T>>>0&255,l[21]=T>>>8&255,l[22]=T>>>16&255,l[23]=T>>>24&255,l[24]=H>>>0&255,l[25]=H>>>8&255,l[26]=H>>>16&255,l[27]=H>>>24&255,l[28]=U>>>0&255,l[29]=U>>>8&255,l[30]=U>>>16&255,l[31]=U>>>24&255}function Ae(l,y,p,o){P(l,y,p,o)}function tt(l,y,p,o){$(l,y,p,o)}var Ze=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Re(l,y,p,o,v,h,m){var S=new Uint8Array(16),N=new Uint8Array(64),K,F;for(F=0;F<16;F++)S[F]=0;for(F=0;F<8;F++)S[F]=h[F];for(;v>=64;){for(Ae(N,S,m,Ze),F=0;F<64;F++)l[y+F]=p[o+F]^N[F];for(K=1,F=8;F<16;F++)K=K+(S[F]&255)|0,S[F]=K&255,K>>>=8;v-=64,y+=64,o+=64}if(v>0)for(Ae(N,S,m,Ze),F=0;F<v;F++)l[y+F]=p[o+F]^N[F];return 0}function Ke(l,y,p,o,v){var h=new Uint8Array(16),m=new Uint8Array(64),S,N;for(N=0;N<16;N++)h[N]=0;for(N=0;N<8;N++)h[N]=o[N];for(;p>=64;){for(Ae(m,h,v,Ze),N=0;N<64;N++)l[y+N]=m[N];for(S=1,N=8;N<16;N++)S=S+(h[N]&255)|0,h[N]=S&255,S>>>=8;p-=64,y+=64}if(p>0)for(Ae(m,h,v,Ze),N=0;N<p;N++)l[y+N]=m[N];return 0}function ft(l,y,p,o,v){var h=new Uint8Array(32);tt(h,o,v,Ze);for(var m=new Uint8Array(8),S=0;S<8;S++)m[S]=o[S+16];return Ke(l,y,p,m,h)}function ht(l,y,p,o,v,h,m){var S=new Uint8Array(32);tt(S,h,m,Ze);for(var N=new Uint8Array(8),K=0;K<8;K++)N[K]=h[K+16];return Re(l,y,p,o,v,N,S)}var _t=function(l){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var y,p,o,v,h,m,S,N;y=l[0]&255|(l[1]&255)<<8,this.r[0]=y&8191,p=l[2]&255|(l[3]&255)<<8,this.r[1]=(y>>>13|p<<3)&8191,o=l[4]&255|(l[5]&255)<<8,this.r[2]=(p>>>10|o<<6)&7939,v=l[6]&255|(l[7]&255)<<8,this.r[3]=(o>>>7|v<<9)&8191,h=l[8]&255|(l[9]&255)<<8,this.r[4]=(v>>>4|h<<12)&255,this.r[5]=h>>>1&8190,m=l[10]&255|(l[11]&255)<<8,this.r[6]=(h>>>14|m<<2)&8191,S=l[12]&255|(l[13]&255)<<8,this.r[7]=(m>>>11|S<<5)&8065,N=l[14]&255|(l[15]&255)<<8,this.r[8]=(S>>>8|N<<8)&8191,this.r[9]=N>>>5&127,this.pad[0]=l[16]&255|(l[17]&255)<<8,this.pad[1]=l[18]&255|(l[19]&255)<<8,this.pad[2]=l[20]&255|(l[21]&255)<<8,this.pad[3]=l[22]&255|(l[23]&255)<<8,this.pad[4]=l[24]&255|(l[25]&255)<<8,this.pad[5]=l[26]&255|(l[27]&255)<<8,this.pad[6]=l[28]&255|(l[29]&255)<<8,this.pad[7]=l[30]&255|(l[31]&255)<<8};_t.prototype.blocks=function(l,y,p){for(var o=this.fin?0:2048,v,h,m,S,N,K,F,fe,L,ge,he,ve,Ee,Ie,ke,be,le,_e,ie,ye=this.h[0],we=this.h[1],re=this.h[2],O=this.h[3],T=this.h[4],H=this.h[5],U=this.h[6],D=this.h[7],G=this.h[8],Be=this.h[9],$e=this.r[0],Ve=this.r[1],Me=this.r[2],b=this.r[3],We=this.r[4],lt=this.r[5],ut=this.r[6],Fe=this.r[7],ot=this.r[8],at=this.r[9];p>=16;)v=l[y+0]&255|(l[y+1]&255)<<8,ye+=v&8191,h=l[y+2]&255|(l[y+3]&255)<<8,we+=(v>>>13|h<<3)&8191,m=l[y+4]&255|(l[y+5]&255)<<8,re+=(h>>>10|m<<6)&8191,S=l[y+6]&255|(l[y+7]&255)<<8,O+=(m>>>7|S<<9)&8191,N=l[y+8]&255|(l[y+9]&255)<<8,T+=(S>>>4|N<<12)&8191,H+=N>>>1&8191,K=l[y+10]&255|(l[y+11]&255)<<8,U+=(N>>>14|K<<2)&8191,F=l[y+12]&255|(l[y+13]&255)<<8,D+=(K>>>11|F<<5)&8191,fe=l[y+14]&255|(l[y+15]&255)<<8,G+=(F>>>8|fe<<8)&8191,Be+=fe>>>5|o,L=0,ge=L,ge+=ye*$e,ge+=we*(5*at),ge+=re*(5*ot),ge+=O*(5*Fe),ge+=T*(5*ut),L=ge>>>13,ge&=8191,ge+=H*(5*lt),ge+=U*(5*We),ge+=D*(5*b),ge+=G*(5*Me),ge+=Be*(5*Ve),L+=ge>>>13,ge&=8191,he=L,he+=ye*Ve,he+=we*$e,he+=re*(5*at),he+=O*(5*ot),he+=T*(5*Fe),L=he>>>13,he&=8191,he+=H*(5*ut),he+=U*(5*lt),he+=D*(5*We),he+=G*(5*b),he+=Be*(5*Me),L+=he>>>13,he&=8191,ve=L,ve+=ye*Me,ve+=we*Ve,ve+=re*$e,ve+=O*(5*at),ve+=T*(5*ot),L=ve>>>13,ve&=8191,ve+=H*(5*Fe),ve+=U*(5*ut),ve+=D*(5*lt),ve+=G*(5*We),ve+=Be*(5*b),L+=ve>>>13,ve&=8191,Ee=L,Ee+=ye*b,Ee+=we*Me,Ee+=re*Ve,Ee+=O*$e,Ee+=T*(5*at),L=Ee>>>13,Ee&=8191,Ee+=H*(5*ot),Ee+=U*(5*Fe),Ee+=D*(5*ut),Ee+=G*(5*lt),Ee+=Be*(5*We),L+=Ee>>>13,Ee&=8191,Ie=L,Ie+=ye*We,Ie+=we*b,Ie+=re*Me,Ie+=O*Ve,Ie+=T*$e,L=Ie>>>13,Ie&=8191,Ie+=H*(5*at),Ie+=U*(5*ot),Ie+=D*(5*Fe),Ie+=G*(5*ut),Ie+=Be*(5*lt),L+=Ie>>>13,Ie&=8191,ke=L,ke+=ye*lt,ke+=we*We,ke+=re*b,ke+=O*Me,ke+=T*Ve,L=ke>>>13,ke&=8191,ke+=H*$e,ke+=U*(5*at),ke+=D*(5*ot),ke+=G*(5*Fe),ke+=Be*(5*ut),L+=ke>>>13,ke&=8191,be=L,be+=ye*ut,be+=we*lt,be+=re*We,be+=O*b,be+=T*Me,L=be>>>13,be&=8191,be+=H*Ve,be+=U*$e,be+=D*(5*at),be+=G*(5*ot),be+=Be*(5*Fe),L+=be>>>13,be&=8191,le=L,le+=ye*Fe,le+=we*ut,le+=re*lt,le+=O*We,le+=T*b,L=le>>>13,le&=8191,le+=H*Me,le+=U*Ve,le+=D*$e,le+=G*(5*at),le+=Be*(5*ot),L+=le>>>13,le&=8191,_e=L,_e+=ye*ot,_e+=we*Fe,_e+=re*ut,_e+=O*lt,_e+=T*We,L=_e>>>13,_e&=8191,_e+=H*b,_e+=U*Me,_e+=D*Ve,_e+=G*$e,_e+=Be*(5*at),L+=_e>>>13,_e&=8191,ie=L,ie+=ye*at,ie+=we*ot,ie+=re*Fe,ie+=O*ut,ie+=T*lt,L=ie>>>13,ie&=8191,ie+=H*We,ie+=U*b,ie+=D*Me,ie+=G*Ve,ie+=Be*$e,L+=ie>>>13,ie&=8191,L=(L<<2)+L|0,L=L+ge|0,ge=L&8191,L=L>>>13,he+=L,ye=ge,we=he,re=ve,O=Ee,T=Ie,H=ke,U=be,D=le,G=_e,Be=ie,y+=16,p-=16;this.h[0]=ye,this.h[1]=we,this.h[2]=re,this.h[3]=O,this.h[4]=T,this.h[5]=H,this.h[6]=U,this.h[7]=D,this.h[8]=G,this.h[9]=Be},_t.prototype.finish=function(l,y){var p=new Uint16Array(10),o,v,h,m;if(this.leftover){for(m=this.leftover,this.buffer[m++]=1;m<16;m++)this.buffer[m]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(o=this.h[1]>>>13,this.h[1]&=8191,m=2;m<10;m++)this.h[m]+=o,o=this.h[m]>>>13,this.h[m]&=8191;for(this.h[0]+=o*5,o=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=o,o=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=o,p[0]=this.h[0]+5,o=p[0]>>>13,p[0]&=8191,m=1;m<10;m++)p[m]=this.h[m]+o,o=p[m]>>>13,p[m]&=8191;for(p[9]-=8192,v=(o^1)-1,m=0;m<10;m++)p[m]&=v;for(v=~v,m=0;m<10;m++)this.h[m]=this.h[m]&v|p[m];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,h=this.h[0]+this.pad[0],this.h[0]=h&65535,m=1;m<8;m++)h=(this.h[m]+this.pad[m]|0)+(h>>>16)|0,this.h[m]=h&65535;l[y+0]=this.h[0]>>>0&255,l[y+1]=this.h[0]>>>8&255,l[y+2]=this.h[1]>>>0&255,l[y+3]=this.h[1]>>>8&255,l[y+4]=this.h[2]>>>0&255,l[y+5]=this.h[2]>>>8&255,l[y+6]=this.h[3]>>>0&255,l[y+7]=this.h[3]>>>8&255,l[y+8]=this.h[4]>>>0&255,l[y+9]=this.h[4]>>>8&255,l[y+10]=this.h[5]>>>0&255,l[y+11]=this.h[5]>>>8&255,l[y+12]=this.h[6]>>>0&255,l[y+13]=this.h[6]>>>8&255,l[y+14]=this.h[7]>>>0&255,l[y+15]=this.h[7]>>>8&255},_t.prototype.update=function(l,y,p){var o,v;if(this.leftover){for(v=16-this.leftover,v>p&&(v=p),o=0;o<v;o++)this.buffer[this.leftover+o]=l[y+o];if(p-=v,y+=v,this.leftover+=v,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(p>=16&&(v=p-p%16,this.blocks(l,y,v),y+=v,p-=v),p){for(o=0;o<p;o++)this.buffer[this.leftover+o]=l[y+o];this.leftover+=p}};function St(l,y,p,o,v,h){var m=new _t(h);return m.update(p,o,v),m.finish(l,y),0}function ct(l,y,p,o,v,h){var m=new Uint8Array(16);return St(m,0,p,o,v,h),C(l,y,m,0)}function pt(l,y,p,o,v){var h;if(p<32)return-1;for(ht(l,0,y,0,p,o,v),St(l,16,l,32,p-32,l),h=0;h<16;h++)l[h]=0;return 0}function qe(l,y,p,o,v){var h,m=new Uint8Array(32);if(p<32||(ft(m,0,32,o,v),ct(y,16,y,32,p-32,m)!==0))return-1;for(ht(l,0,y,0,p,o,v),h=0;h<32;h++)l[h]=0;return 0}function He(l,y){var p;for(p=0;p<16;p++)l[p]=y[p]|0}function se(l){var y,p,o=1;for(y=0;y<16;y++)p=l[y]+o+65535,o=Math.floor(p/65536),l[y]=p-o*65536;l[0]+=o-1+37*(o-1)}function Ce(l,y,p){for(var o,v=~(p-1),h=0;h<16;h++)o=v&(l[h]^y[h]),l[h]^=o,y[h]^=o}function dt(l,y){var p,o,v,h=t(),m=t();for(p=0;p<16;p++)m[p]=y[p];for(se(m),se(m),se(m),o=0;o<2;o++){for(h[0]=m[0]-65517,p=1;p<15;p++)h[p]=m[p]-65535-(h[p-1]>>16&1),h[p-1]&=65535;h[15]=m[15]-32767-(h[14]>>16&1),v=h[15]>>16&1,h[14]&=65535,Ce(m,h,1-v)}for(p=0;p<16;p++)l[2*p]=m[p]&255,l[2*p+1]=m[p]>>8}function It(l,y){var p=new Uint8Array(32),o=new Uint8Array(32);return dt(p,l),dt(o,y),k(p,0,o,0)}function kt(l){var y=new Uint8Array(32);return dt(y,l),y[0]&1}function ce(l,y){var p;for(p=0;p<16;p++)l[p]=y[2*p]+(y[2*p+1]<<8);l[15]&=32767}function Qe(l,y,p){for(var o=0;o<16;o++)l[o]=y[o]+p[o]}function yt(l,y,p){for(var o=0;o<16;o++)l[o]=y[o]-p[o]}function Q(l,y,p){var o,v,h=0,m=0,S=0,N=0,K=0,F=0,fe=0,L=0,ge=0,he=0,ve=0,Ee=0,Ie=0,ke=0,be=0,le=0,_e=0,ie=0,ye=0,we=0,re=0,O=0,T=0,H=0,U=0,D=0,G=0,Be=0,$e=0,Ve=0,Me=0,b=p[0],We=p[1],lt=p[2],ut=p[3],Fe=p[4],ot=p[5],at=p[6],Mt=p[7],mt=p[8],Rt=p[9],Pt=p[10],Ut=p[11],zt=p[12],nr=p[13],ir=p[14],sr=p[15];o=y[0],h+=o*b,m+=o*We,S+=o*lt,N+=o*ut,K+=o*Fe,F+=o*ot,fe+=o*at,L+=o*Mt,ge+=o*mt,he+=o*Rt,ve+=o*Pt,Ee+=o*Ut,Ie+=o*zt,ke+=o*nr,be+=o*ir,le+=o*sr,o=y[1],m+=o*b,S+=o*We,N+=o*lt,K+=o*ut,F+=o*Fe,fe+=o*ot,L+=o*at,ge+=o*Mt,he+=o*mt,ve+=o*Rt,Ee+=o*Pt,Ie+=o*Ut,ke+=o*zt,be+=o*nr,le+=o*ir,_e+=o*sr,o=y[2],S+=o*b,N+=o*We,K+=o*lt,F+=o*ut,fe+=o*Fe,L+=o*ot,ge+=o*at,he+=o*Mt,ve+=o*mt,Ee+=o*Rt,Ie+=o*Pt,ke+=o*Ut,be+=o*zt,le+=o*nr,_e+=o*ir,ie+=o*sr,o=y[3],N+=o*b,K+=o*We,F+=o*lt,fe+=o*ut,L+=o*Fe,ge+=o*ot,he+=o*at,ve+=o*Mt,Ee+=o*mt,Ie+=o*Rt,ke+=o*Pt,be+=o*Ut,le+=o*zt,_e+=o*nr,ie+=o*ir,ye+=o*sr,o=y[4],K+=o*b,F+=o*We,fe+=o*lt,L+=o*ut,ge+=o*Fe,he+=o*ot,ve+=o*at,Ee+=o*Mt,Ie+=o*mt,ke+=o*Rt,be+=o*Pt,le+=o*Ut,_e+=o*zt,ie+=o*nr,ye+=o*ir,we+=o*sr,o=y[5],F+=o*b,fe+=o*We,L+=o*lt,ge+=o*ut,he+=o*Fe,ve+=o*ot,Ee+=o*at,Ie+=o*Mt,ke+=o*mt,be+=o*Rt,le+=o*Pt,_e+=o*Ut,ie+=o*zt,ye+=o*nr,we+=o*ir,re+=o*sr,o=y[6],fe+=o*b,L+=o*We,ge+=o*lt,he+=o*ut,ve+=o*Fe,Ee+=o*ot,Ie+=o*at,ke+=o*Mt,be+=o*mt,le+=o*Rt,_e+=o*Pt,ie+=o*Ut,ye+=o*zt,we+=o*nr,re+=o*ir,O+=o*sr,o=y[7],L+=o*b,ge+=o*We,he+=o*lt,ve+=o*ut,Ee+=o*Fe,Ie+=o*ot,ke+=o*at,be+=o*Mt,le+=o*mt,_e+=o*Rt,ie+=o*Pt,ye+=o*Ut,we+=o*zt,re+=o*nr,O+=o*ir,T+=o*sr,o=y[8],ge+=o*b,he+=o*We,ve+=o*lt,Ee+=o*ut,Ie+=o*Fe,ke+=o*ot,be+=o*at,le+=o*Mt,_e+=o*mt,ie+=o*Rt,ye+=o*Pt,we+=o*Ut,re+=o*zt,O+=o*nr,T+=o*ir,H+=o*sr,o=y[9],he+=o*b,ve+=o*We,Ee+=o*lt,Ie+=o*ut,ke+=o*Fe,be+=o*ot,le+=o*at,_e+=o*Mt,ie+=o*mt,ye+=o*Rt,we+=o*Pt,re+=o*Ut,O+=o*zt,T+=o*nr,H+=o*ir,U+=o*sr,o=y[10],ve+=o*b,Ee+=o*We,Ie+=o*lt,ke+=o*ut,be+=o*Fe,le+=o*ot,_e+=o*at,ie+=o*Mt,ye+=o*mt,we+=o*Rt,re+=o*Pt,O+=o*Ut,T+=o*zt,H+=o*nr,U+=o*ir,D+=o*sr,o=y[11],Ee+=o*b,Ie+=o*We,ke+=o*lt,be+=o*ut,le+=o*Fe,_e+=o*ot,ie+=o*at,ye+=o*Mt,we+=o*mt,re+=o*Rt,O+=o*Pt,T+=o*Ut,H+=o*zt,U+=o*nr,D+=o*ir,G+=o*sr,o=y[12],Ie+=o*b,ke+=o*We,be+=o*lt,le+=o*ut,_e+=o*Fe,ie+=o*ot,ye+=o*at,we+=o*Mt,re+=o*mt,O+=o*Rt,T+=o*Pt,H+=o*Ut,U+=o*zt,D+=o*nr,G+=o*ir,Be+=o*sr,o=y[13],ke+=o*b,be+=o*We,le+=o*lt,_e+=o*ut,ie+=o*Fe,ye+=o*ot,we+=o*at,re+=o*Mt,O+=o*mt,T+=o*Rt,H+=o*Pt,U+=o*Ut,D+=o*zt,G+=o*nr,Be+=o*ir,$e+=o*sr,o=y[14],be+=o*b,le+=o*We,_e+=o*lt,ie+=o*ut,ye+=o*Fe,we+=o*ot,re+=o*at,O+=o*Mt,T+=o*mt,H+=o*Rt,U+=o*Pt,D+=o*Ut,G+=o*zt,Be+=o*nr,$e+=o*ir,Ve+=o*sr,o=y[15],le+=o*b,_e+=o*We,ie+=o*lt,ye+=o*ut,we+=o*Fe,re+=o*ot,O+=o*at,T+=o*Mt,H+=o*mt,U+=o*Rt,D+=o*Pt,G+=o*Ut,Be+=o*zt,$e+=o*nr,Ve+=o*ir,Me+=o*sr,h+=38*_e,m+=38*ie,S+=38*ye,N+=38*we,K+=38*re,F+=38*O,fe+=38*T,L+=38*H,ge+=38*U,he+=38*D,ve+=38*G,Ee+=38*Be,Ie+=38*$e,ke+=38*Ve,be+=38*Me,v=1,o=h+v+65535,v=Math.floor(o/65536),h=o-v*65536,o=m+v+65535,v=Math.floor(o/65536),m=o-v*65536,o=S+v+65535,v=Math.floor(o/65536),S=o-v*65536,o=N+v+65535,v=Math.floor(o/65536),N=o-v*65536,o=K+v+65535,v=Math.floor(o/65536),K=o-v*65536,o=F+v+65535,v=Math.floor(o/65536),F=o-v*65536,o=fe+v+65535,v=Math.floor(o/65536),fe=o-v*65536,o=L+v+65535,v=Math.floor(o/65536),L=o-v*65536,o=ge+v+65535,v=Math.floor(o/65536),ge=o-v*65536,o=he+v+65535,v=Math.floor(o/65536),he=o-v*65536,o=ve+v+65535,v=Math.floor(o/65536),ve=o-v*65536,o=Ee+v+65535,v=Math.floor(o/65536),Ee=o-v*65536,o=Ie+v+65535,v=Math.floor(o/65536),Ie=o-v*65536,o=ke+v+65535,v=Math.floor(o/65536),ke=o-v*65536,o=be+v+65535,v=Math.floor(o/65536),be=o-v*65536,o=le+v+65535,v=Math.floor(o/65536),le=o-v*65536,h+=v-1+37*(v-1),v=1,o=h+v+65535,v=Math.floor(o/65536),h=o-v*65536,o=m+v+65535,v=Math.floor(o/65536),m=o-v*65536,o=S+v+65535,v=Math.floor(o/65536),S=o-v*65536,o=N+v+65535,v=Math.floor(o/65536),N=o-v*65536,o=K+v+65535,v=Math.floor(o/65536),K=o-v*65536,o=F+v+65535,v=Math.floor(o/65536),F=o-v*65536,o=fe+v+65535,v=Math.floor(o/65536),fe=o-v*65536,o=L+v+65535,v=Math.floor(o/65536),L=o-v*65536,o=ge+v+65535,v=Math.floor(o/65536),ge=o-v*65536,o=he+v+65535,v=Math.floor(o/65536),he=o-v*65536,o=ve+v+65535,v=Math.floor(o/65536),ve=o-v*65536,o=Ee+v+65535,v=Math.floor(o/65536),Ee=o-v*65536,o=Ie+v+65535,v=Math.floor(o/65536),Ie=o-v*65536,o=ke+v+65535,v=Math.floor(o/65536),ke=o-v*65536,o=be+v+65535,v=Math.floor(o/65536),be=o-v*65536,o=le+v+65535,v=Math.floor(o/65536),le=o-v*65536,h+=v-1+37*(v-1),l[0]=h,l[1]=m,l[2]=S,l[3]=N,l[4]=K,l[5]=F,l[6]=fe,l[7]=L,l[8]=ge,l[9]=he,l[10]=ve,l[11]=Ee,l[12]=Ie,l[13]=ke,l[14]=be,l[15]=le}function st(l,y){Q(l,y,y)}function Ct(l,y){var p=t(),o;for(o=0;o<16;o++)p[o]=y[o];for(o=253;o>=0;o--)st(p,p),o!==2&&o!==4&&Q(p,p,y);for(o=0;o<16;o++)l[o]=p[o]}function dn(l,y){var p=t(),o;for(o=0;o<16;o++)p[o]=y[o];for(o=250;o>=0;o--)st(p,p),o!==1&&Q(p,p,y);for(o=0;o<16;o++)l[o]=p[o]}function pn(l,y,p){var o=new Uint8Array(32),v=new Float64Array(80),h,m,S=t(),N=t(),K=t(),F=t(),fe=t(),L=t();for(m=0;m<31;m++)o[m]=y[m];for(o[31]=y[31]&127|64,o[0]&=248,ce(v,p),m=0;m<16;m++)N[m]=v[m],F[m]=S[m]=K[m]=0;for(S[0]=F[0]=1,m=254;m>=0;--m)h=o[m>>>3]>>>(m&7)&1,Ce(S,N,h),Ce(K,F,h),Qe(fe,S,K),yt(S,S,K),Qe(K,N,F),yt(N,N,F),st(F,fe),st(L,S),Q(S,K,S),Q(K,N,fe),Qe(fe,S,K),yt(S,S,K),st(N,S),yt(K,F,L),Q(S,K,u),Qe(S,S,F),Q(K,K,S),Q(S,F,L),Q(F,N,v),st(N,fe),Ce(S,N,h),Ce(K,F,h);for(m=0;m<16;m++)v[m+16]=S[m],v[m+32]=K[m],v[m+48]=N[m],v[m+64]=F[m];var ge=v.subarray(32),he=v.subarray(16);return Ct(ge,ge),Q(he,he,ge),dt(l,he),0}function Ht(l,y){return pn(l,y,s)}function Mi(l,y){return n(y,32),Ht(l,y)}function Dr(l,y,p){var o=new Uint8Array(32);return pn(o,p,y),tt(l,i,o,Ze)}var Vi=pt,Bo=qe;function yn(l,y,p,o,v,h){var m=new Uint8Array(32);return Dr(m,v,h),Vi(l,y,p,o,m)}function gn(l,y,p,o,v,h){var m=new Uint8Array(32);return Dr(m,v,h),Bo(l,y,p,o,m)}var oi=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function ai(l,y,p,o){for(var v=new Int32Array(16),h=new Int32Array(16),m,S,N,K,F,fe,L,ge,he,ve,Ee,Ie,ke,be,le,_e,ie,ye,we,re,O,T,H,U,D,G,Be=l[0],$e=l[1],Ve=l[2],Me=l[3],b=l[4],We=l[5],lt=l[6],ut=l[7],Fe=y[0],ot=y[1],at=y[2],Mt=y[3],mt=y[4],Rt=y[5],Pt=y[6],Ut=y[7],zt=0;o>=128;){for(we=0;we<16;we++)re=8*we+zt,v[we]=p[re+0]<<24|p[re+1]<<16|p[re+2]<<8|p[re+3],h[we]=p[re+4]<<24|p[re+5]<<16|p[re+6]<<8|p[re+7];for(we=0;we<80;we++)if(m=Be,S=$e,N=Ve,K=Me,F=b,fe=We,L=lt,ge=ut,he=Fe,ve=ot,Ee=at,Ie=Mt,ke=mt,be=Rt,le=Pt,_e=Ut,O=ut,T=Ut,H=T&65535,U=T>>>16,D=O&65535,G=O>>>16,O=(b>>>14|mt<<18)^(b>>>18|mt<<14)^(mt>>>9|b<<23),T=(mt>>>14|b<<18)^(mt>>>18|b<<14)^(b>>>9|mt<<23),H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,O=b&We^~b<,T=mt&Rt^~mt&Pt,H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,O=oi[we*2],T=oi[we*2+1],H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,O=v[we%16],T=h[we%16],H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,ie=D&65535|G<<16,ye=H&65535|U<<16,O=ie,T=ye,H=T&65535,U=T>>>16,D=O&65535,G=O>>>16,O=(Be>>>28|Fe<<4)^(Fe>>>2|Be<<30)^(Fe>>>7|Be<<25),T=(Fe>>>28|Be<<4)^(Be>>>2|Fe<<30)^(Be>>>7|Fe<<25),H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,O=Be&$e^Be&Ve^$e&Ve,T=Fe&ot^Fe&at^ot&at,H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,ge=D&65535|G<<16,_e=H&65535|U<<16,O=K,T=Ie,H=T&65535,U=T>>>16,D=O&65535,G=O>>>16,O=ie,T=ye,H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,K=D&65535|G<<16,Ie=H&65535|U<<16,$e=m,Ve=S,Me=N,b=K,We=F,lt=fe,ut=L,Be=ge,ot=he,at=ve,Mt=Ee,mt=Ie,Rt=ke,Pt=be,Ut=le,Fe=_e,we%16===15)for(re=0;re<16;re++)O=v[re],T=h[re],H=T&65535,U=T>>>16,D=O&65535,G=O>>>16,O=v[(re+9)%16],T=h[(re+9)%16],H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,ie=v[(re+1)%16],ye=h[(re+1)%16],O=(ie>>>1|ye<<31)^(ie>>>8|ye<<24)^ie>>>7,T=(ye>>>1|ie<<31)^(ye>>>8|ie<<24)^(ye>>>7|ie<<25),H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,ie=v[(re+14)%16],ye=h[(re+14)%16],O=(ie>>>19|ye<<13)^(ye>>>29|ie<<3)^ie>>>6,T=(ye>>>19|ie<<13)^(ie>>>29|ye<<3)^(ye>>>6|ie<<26),H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,v[re]=D&65535|G<<16,h[re]=H&65535|U<<16;O=Be,T=Fe,H=T&65535,U=T>>>16,D=O&65535,G=O>>>16,O=l[0],T=y[0],H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[0]=Be=D&65535|G<<16,y[0]=Fe=H&65535|U<<16,O=$e,T=ot,H=T&65535,U=T>>>16,D=O&65535,G=O>>>16,O=l[1],T=y[1],H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[1]=$e=D&65535|G<<16,y[1]=ot=H&65535|U<<16,O=Ve,T=at,H=T&65535,U=T>>>16,D=O&65535,G=O>>>16,O=l[2],T=y[2],H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[2]=Ve=D&65535|G<<16,y[2]=at=H&65535|U<<16,O=Me,T=Mt,H=T&65535,U=T>>>16,D=O&65535,G=O>>>16,O=l[3],T=y[3],H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[3]=Me=D&65535|G<<16,y[3]=Mt=H&65535|U<<16,O=b,T=mt,H=T&65535,U=T>>>16,D=O&65535,G=O>>>16,O=l[4],T=y[4],H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[4]=b=D&65535|G<<16,y[4]=mt=H&65535|U<<16,O=We,T=Rt,H=T&65535,U=T>>>16,D=O&65535,G=O>>>16,O=l[5],T=y[5],H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[5]=We=D&65535|G<<16,y[5]=Rt=H&65535|U<<16,O=lt,T=Pt,H=T&65535,U=T>>>16,D=O&65535,G=O>>>16,O=l[6],T=y[6],H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[6]=lt=D&65535|G<<16,y[6]=Pt=H&65535|U<<16,O=ut,T=Ut,H=T&65535,U=T>>>16,D=O&65535,G=O>>>16,O=l[7],T=y[7],H+=T&65535,U+=T>>>16,D+=O&65535,G+=O>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[7]=ut=D&65535|G<<16,y[7]=Ut=H&65535|U<<16,zt+=128,o-=128}return o}function hr(l,y,p){var o=new Int32Array(8),v=new Int32Array(8),h=new Uint8Array(256),m,S=p;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,v[0]=4089235720,v[1]=2227873595,v[2]=4271175723,v[3]=1595750129,v[4]=2917565137,v[5]=725511199,v[6]=4215389547,v[7]=327033209,ai(o,v,y,p),p%=128,m=0;m<p;m++)h[m]=y[S-p+m];for(h[p]=128,p=256-128*(p<112?1:0),h[p-9]=0,w(h,p-8,S/536870912|0,S<<3),ai(o,v,h,p),m=0;m<8;m++)w(l,8*m,o[m],v[m]);return 0}function Un(l,y){var p=t(),o=t(),v=t(),h=t(),m=t(),S=t(),N=t(),K=t(),F=t();yt(p,l[1],l[0]),yt(F,y[1],y[0]),Q(p,p,F),Qe(o,l[0],l[1]),Qe(F,y[0],y[1]),Q(o,o,F),Q(v,l[3],y[3]),Q(v,v,x),Q(h,l[2],y[2]),Qe(h,h,h),yt(m,o,p),yt(S,h,v),Qe(N,h,v),Qe(K,o,p),Q(l[0],m,S),Q(l[1],K,N),Q(l[2],N,S),Q(l[3],m,K)}function ci(l,y,p){var o;for(o=0;o<4;o++)Ce(l[o],y[o],p)}function Dn(l,y){var p=t(),o=t(),v=t();Ct(v,y[2]),Q(p,y[0],v),Q(o,y[1],v),dt(l,o),l[31]^=kt(p)<<7}function Li(l,y,p){var o,v;for(He(l[0],a),He(l[1],c),He(l[2],c),He(l[3],a),v=255;v>=0;--v)o=p[v/8|0]>>(v&7)&1,ci(l,y,o),Un(y,l),Un(l,l),ci(l,y,o)}function li(l,y){var p=[t(),t(),t(),t()];He(p[0],I),He(p[1],J),He(p[2],c),Q(p[3],I,J),Li(l,p,y)}function ui(l,y,p){var o=new Uint8Array(64),v=[t(),t(),t(),t()],h;for(p||n(y,32),hr(o,y,32),o[0]&=248,o[31]&=127,o[31]|=64,li(v,o),Dn(l,v),h=0;h<32;h++)y[h+32]=l[h];return 0}var Cr=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Yr(l,y){var p,o,v,h;for(o=63;o>=32;--o){for(p=0,v=o-32,h=o-12;v<h;++v)y[v]+=p-16*y[o]*Cr[v-(o-32)],p=Math.floor((y[v]+128)/256),y[v]-=p*256;y[v]+=p,y[o]=0}for(p=0,v=0;v<32;v++)y[v]+=p-(y[31]>>4)*Cr[v],p=y[v]>>8,y[v]&=255;for(v=0;v<32;v++)y[v]-=p*Cr[v];for(o=0;o<32;o++)y[o+1]+=y[o]>>8,l[o]=y[o]&255}function Hi(l){var y=new Float64Array(64),p;for(p=0;p<64;p++)y[p]=l[p];for(p=0;p<64;p++)l[p]=0;Yr(l,y)}function Fi(l,y,p,o){var v=new Uint8Array(64),h=new Uint8Array(64),m=new Uint8Array(64),S,N,K=new Float64Array(64),F=[t(),t(),t(),t()];hr(v,o,32),v[0]&=248,v[31]&=127,v[31]|=64;var fe=p+64;for(S=0;S<p;S++)l[64+S]=y[S];for(S=0;S<32;S++)l[32+S]=v[32+S];for(hr(m,l.subarray(32),p+32),Hi(m),li(F,m),Dn(l,F),S=32;S<64;S++)l[S]=o[S];for(hr(h,l,p+64),Hi(h),S=0;S<64;S++)K[S]=0;for(S=0;S<32;S++)K[S]=m[S];for(S=0;S<32;S++)for(N=0;N<32;N++)K[S+N]+=h[S]*v[N];return Yr(l.subarray(32),K),fe}function fi(l,y){var p=t(),o=t(),v=t(),h=t(),m=t(),S=t(),N=t();return He(l[2],c),ce(l[1],y),st(v,l[1]),Q(h,v,d),yt(v,v,l[2]),Qe(h,l[2],h),st(m,h),st(S,m),Q(N,S,m),Q(p,N,v),Q(p,p,h),dn(p,p),Q(p,p,v),Q(p,p,h),Q(p,p,h),Q(l[0],p,h),st(o,l[0]),Q(o,o,h),It(o,v)&&Q(l[0],l[0],j),st(o,l[0]),Q(o,o,h),It(o,v)?-1:(kt(l[0])===y[31]>>7&&yt(l[0],a,l[0]),Q(l[3],l[0],l[1]),0)}function E(l,y,p,o){var v,h=new Uint8Array(32),m=new Uint8Array(64),S=[t(),t(),t(),t()],N=[t(),t(),t(),t()];if(p<64||fi(N,o))return-1;for(v=0;v<p;v++)l[v]=y[v];for(v=0;v<32;v++)l[v+32]=o[v];if(hr(m,l,p),Hi(m),Li(S,N,m),li(N,y.subarray(32)),Un(S,N),Dn(h,S),p-=64,k(y,0,h,0)){for(v=0;v<p;v++)l[v]=0;return-1}for(v=0;v<p;v++)l[v]=y[v+64];return p}var B=32,R=24,W=32,xe=16,bt=32,xt=32,Ne=32,Y=32,ee=32,te=R,pe=W,De=xe,Ye=64,gt=32,$t=64,hi=32,di=64;e.lowlevel={crypto_core_hsalsa20:tt,crypto_stream_xor:ht,crypto_stream:ft,crypto_stream_salsa20_xor:Re,crypto_stream_salsa20:Ke,crypto_onetimeauth:St,crypto_onetimeauth_verify:ct,crypto_verify_16:C,crypto_verify_32:k,crypto_secretbox:pt,crypto_secretbox_open:qe,crypto_scalarmult:pn,crypto_scalarmult_base:Ht,crypto_box_beforenm:Dr,crypto_box_afternm:Vi,crypto_box:yn,crypto_box_open:gn,crypto_box_keypair:Mi,crypto_hash:hr,crypto_sign:Fi,crypto_sign_keypair:ui,crypto_sign_open:E,crypto_secretbox_KEYBYTES:B,crypto_secretbox_NONCEBYTES:R,crypto_secretbox_ZEROBYTES:W,crypto_secretbox_BOXZEROBYTES:xe,crypto_scalarmult_BYTES:bt,crypto_scalarmult_SCALARBYTES:xt,crypto_box_PUBLICKEYBYTES:Ne,crypto_box_SECRETKEYBYTES:Y,crypto_box_BEFORENMBYTES:ee,crypto_box_NONCEBYTES:te,crypto_box_ZEROBYTES:pe,crypto_box_BOXZEROBYTES:De,crypto_sign_BYTES:Ye,crypto_sign_PUBLICKEYBYTES:gt,crypto_sign_SECRETKEYBYTES:$t,crypto_sign_SEEDBYTES:hi,crypto_hash_BYTES:di,gf:t,D:d,L:Cr,pack25519:dt,unpack25519:ce,M:Q,A:Qe,S:st,Z:yt,pow2523:dn,add:Un,set25519:He,modL:Yr,scalarmult:Li,scalarbase:li};function Gi(l,y){if(l.length!==B)throw new Error("bad key size");if(y.length!==R)throw new Error("bad nonce size")}function mf(l,y){if(l.length!==Ne)throw new Error("bad public key size");if(y.length!==Y)throw new Error("bad secret key size")}function dr(){for(var l=0;l<arguments.length;l++)if(!(arguments[l]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Oo(l){for(var y=0;y<l.length;y++)l[y]=0}e.randomBytes=function(l){var y=new Uint8Array(l);return n(y,l),y},e.secretbox=function(l,y,p){dr(l,y,p),Gi(p,y);for(var o=new Uint8Array(W+l.length),v=new Uint8Array(o.length),h=0;h<l.length;h++)o[h+W]=l[h];return pt(v,o,o.length,y,p),v.subarray(xe)},e.secretbox.open=function(l,y,p){dr(l,y,p),Gi(p,y);for(var o=new Uint8Array(xe+l.length),v=new Uint8Array(o.length),h=0;h<l.length;h++)o[h+xe]=l[h];return o.length<32||qe(v,o,o.length,y,p)!==0?null:v.subarray(W)},e.secretbox.keyLength=B,e.secretbox.nonceLength=R,e.secretbox.overheadLength=xe,e.scalarMult=function(l,y){if(dr(l,y),l.length!==xt)throw new Error("bad n size");if(y.length!==bt)throw new Error("bad p size");var p=new Uint8Array(bt);return pn(p,l,y),p},e.scalarMult.base=function(l){if(dr(l),l.length!==xt)throw new Error("bad n size");var y=new Uint8Array(bt);return Ht(y,l),y},e.scalarMult.scalarLength=xt,e.scalarMult.groupElementLength=bt,e.box=function(l,y,p,o){var v=e.box.before(p,o);return e.secretbox(l,y,v)},e.box.before=function(l,y){dr(l,y),mf(l,y);var p=new Uint8Array(ee);return Dr(p,l,y),p},e.box.after=e.secretbox,e.box.open=function(l,y,p,o){var v=e.box.before(p,o);return e.secretbox.open(l,y,v)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var l=new Uint8Array(Ne),y=new Uint8Array(Y);return Mi(l,y),{publicKey:l,secretKey:y}},e.box.keyPair.fromSecretKey=function(l){if(dr(l),l.length!==Y)throw new Error("bad secret key size");var y=new Uint8Array(Ne);return Ht(y,l),{publicKey:y,secretKey:new Uint8Array(l)}},e.box.publicKeyLength=Ne,e.box.secretKeyLength=Y,e.box.sharedKeyLength=ee,e.box.nonceLength=te,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(l,y){if(dr(l,y),y.length!==$t)throw new Error("bad secret key size");var p=new Uint8Array(Ye+l.length);return Fi(p,l,l.length,y),p},e.sign.open=function(l,y){if(dr(l,y),y.length!==gt)throw new Error("bad public key size");var p=new Uint8Array(l.length),o=E(p,l,l.length,y);if(o<0)return null;for(var v=new Uint8Array(o),h=0;h<v.length;h++)v[h]=p[h];return v},e.sign.detached=function(l,y){for(var p=e.sign(l,y),o=new Uint8Array(Ye),v=0;v<o.length;v++)o[v]=p[v];return o},e.sign.detached.verify=function(l,y,p){if(dr(l,y,p),y.length!==Ye)throw new Error("bad signature size");if(p.length!==gt)throw new Error("bad public key size");var o=new Uint8Array(Ye+l.length),v=new Uint8Array(Ye+l.length),h;for(h=0;h<Ye;h++)o[h]=y[h];for(h=0;h<l.length;h++)o[h+Ye]=l[h];return E(v,o,o.length,p)>=0},e.sign.keyPair=function(){var l=new Uint8Array(gt),y=new Uint8Array($t);return ui(l,y),{publicKey:l,secretKey:y}},e.sign.keyPair.fromSecretKey=function(l){if(dr(l),l.length!==$t)throw new Error("bad secret key size");for(var y=new Uint8Array(gt),p=0;p<y.length;p++)y[p]=l[32+p];return{publicKey:y,secretKey:new Uint8Array(l)}},e.sign.keyPair.fromSeed=function(l){if(dr(l),l.length!==hi)throw new Error("bad seed size");for(var y=new Uint8Array(gt),p=new Uint8Array($t),o=0;o<32;o++)p[o]=l[o];return ui(y,p,!0),{publicKey:y,secretKey:p}},e.sign.publicKeyLength=gt,e.sign.secretKeyLength=$t,e.sign.seedLength=hi,e.sign.signatureLength=Ye,e.hash=function(l){dr(l);var y=new Uint8Array(di);return hr(y,l,l.length),y},e.hash.hashLength=di,e.verify=function(l,y){return dr(l,y),l.length===0||y.length===0||l.length!==y.length?!1:A(l,0,y,0,l.length)===0},e.setPRNG=function(l){n=l},function(){var l=typeof self<"u"?self.crypto||self.msCrypto:null;if(l&&l.getRandomValues){var y=65536;e.setPRNG(function(p,o){var v,h=new Uint8Array(o);for(v=0;v<o;v+=y)l.getRandomValues(h.subarray(v,v+Math.min(o-v,y)));for(v=0;v<o;v++)p[v]=h[v];Oo(h)})}else typeof j1<"u"&&(l=R1,l&&l.randomBytes&&e.setPRNG(function(p,o){var v,h=l.randomBytes(o);for(v=0;v<o;v++)p[v]=h[v];Oo(h)}))}()})(r.exports?r.exports:self.nacl=self.nacl||{})})(Sy);var P1=Sy.exports;const Ey=Ki(P1);async function Iy(r){const e=sessionStorage.getItem("sessionKey"),t=sessionStorage.getItem("sessionId");console.groupCollapsed("Attestation");try{if(e&&t&&!r){const s=No(e);return console.log("Using existing attestation from session storage."),{sessionKey:s,sessionId:t}}const n=window.crypto.randomUUID();console.log("Generated attestation nonce:",n);const i=await N1(n);if(i&&i.public_key){console.log("Attestation document verification succeeded");const s=Ey.box.keyPair();console.log("Generated client key pair");const a=new Uint8Array(i.public_key),{encrypted_session_key:c,session_id:u}=await L1(wn(s.publicKey),n);console.log("Key exchange completed.");const d=Ey.scalarMult(s.secretKey,a),x=No(c),I=12,J=x.slice(0,I),j=x.slice(I),A=new Dc(d).open(J,j);if(A)return console.log("Session key decrypted successfully"),window.sessionStorage.setItem("sessionKey",wn(A)),window.sessionStorage.setItem("sessionId",u),{sessionKey:A,sessionId:u};throw new Error("Failed to decrypt session key")}else throw new Error("Invalid attestation document")}catch(n){throw console.error("Error verifying attestation:",n),n}finally{console.groupEnd()}}async function $i(r,e,t,n){const i=async(s=!1)=>{try{s&&(console.log("Refreshing access token"),await gf());const a=window.localStorage.getItem("access_token");if(!a)throw new Error("No access token available");const c=await ky(r,e,t,a,n);if(c.status===401&&!s)return console.log("Received 401, attempting to refresh token"),i(!0);if(c.error)throw new Error(c.error);if(!c.data)throw new Error("No data received from the server");return c.data}catch(a){throw console.error(a),a}};return i()}async function ky(r,e,t,n,i){let{sessionKey:s,sessionId:a}=await Iy();const c=async(d,x=!1)=>{if(x||!s||!a){const C=await Iy(!0);s=C.sessionKey,a=C.sessionId}if(!s||!a)throw new Error("Failed to make encrypted API call, no attestation available.");const I=t?JSON.stringify(t):void 0,J=I?s0(s,I):void 0,j={"Content-Type":"application/json","x-session-id":a};d&&(j.Authorization=`Bearer ${d}`);const w=await fetch(r,{method:e,headers:j,body:J?JSON.stringify({encrypted:J}):void 0}),A={status:w.status};if(w.ok)try{const C=await w.json(),k=o0(s,C.encrypted);A.data=JSON.parse(k)}catch(C){console.error("Error decrypting or parsing response:",C),A.status=500,A.error="Failed to decrypt or parse the response"}else try{const C=await w.json();A.error=C.message||i||`HTTP error! Status: ${w.status}`}catch{A.error=i||`HTTP error! Status: ${w.status}`}return A},u=async(d,x=!1)=>{var I;try{const J=await c(d,x);return(J.status===400||(I=J.error)!=null&&I.includes("Encryption error"))&&!x?(console.log("Encryption error or Bad Request, attempting to renew attestation"),u(d,!0)):J}catch(J){return{status:500,error:J instanceof Error?J.message:"Unknown error occurred"}}};return u(n)}async function Rn(r,e,t,n,i){const s=await ky(r,e,t,n,i);if(s.error)throw new Error(s.error);if(!s.data)throw new Error("No data received from the server");return s.data}let Lt="http://localhost:3000";console.log("API_URL:",Lt);function Cy(r){Lt=r}async function U1(r,e){const t={email:r,password:e};return Rn(`${Lt}/login`,"POST",t)}async function D1(r,e,t,n){const i={name:r,email:e,password:t,inviteCode:n.toLowerCase()};return Rn(`${Lt}/register`,"POST",i)}async function gf(){const r=window.localStorage.getItem("refresh_token");if(!r)throw new Error("No refresh token available");const e={refresh_token:r};try{const t=await Rn(`${Lt}/refresh`,"POST",e,void 0,"Failed to refresh token");return window.localStorage.setItem("access_token",t.access_token),window.localStorage.setItem("refresh_token",t.refresh_token),t}catch(t){throw console.error("Error refreshing token:",t),t}}async function $1(){return $i(`${Lt}/protected/user`,"GET",void 0,"Failed to fetch user")}async function By(r,e){return $i(`${Lt}/protected/kv/${r}`,"PUT",e,"Failed to put key-value pair")}async function Oy(r){return $i(`${Lt}/protected/kv/${r}`,"DELETE",void 0,"Failed to delete key-value pair")}async function Ty(r){try{return await $i(`${Lt}/protected/kv/${r}`,"GET",void 0,"Failed to get key-value pair")}catch(e){console.error(`Error fetching key "${r}":`,e);return}}async function Ny(){return $i(`${Lt}/protected/kv`,"GET",void 0,"Failed to list key-value pairs")}async function M1(r){const e={refresh_token:r};return Rn(`${Lt}/logout`,"POST",e)}async function jy(r){return Rn(`${Lt}/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Bc(){return $i(`${Lt}/protected/request_verification`,"POST",void 0,"Failed to request new verification code")}async function V1(r){const e=await fetch(`${Lt}/attestation/${r}`);if(!e.ok)throw new Error(`Request failed with status ${e.status}`);return(await e.json()).attestation_document}async function L1(r,e){const t=await fetch(`${Lt}/key_exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_public_key:r,nonce:e})});if(!t.ok)throw new Error("Key exchange failed");return t.json()}async function Ry(r,e){const t={current_password:r,new_password:e};return $i(`${Lt}/protected/change_password`,"POST",t,"Failed to change password")}async function H1(r){try{return await Rn(`${Lt}/auth/github`,"POST",r?{invite_code:r}:{},void 0,"Failed to initiate GitHub auth")}catch(e){throw e instanceof Error&&e.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):e}}async function F1(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Rn(`${Lt}/auth/github/callback`,"POST",n,void 0,"GitHub callback failed")}catch(i){throw console.error("Detailed GitHub callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with GitHub."):new Error("Failed to authenticate with GitHub. Please try again."):i}}async function G1(r){try{return await Rn(`${Lt}/auth/google`,"POST",r?{invite_code:r}:{},void 0,"Failed to initiate Google auth")}catch(e){throw e instanceof Error&&e.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):e}}async function z1(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Rn(`${Lt}/auth/google/callback`,"POST",n,void 0,"Google callback failed")}catch(i){throw console.error("Detailed Google callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with Google."):new Error("Failed to authenticate with Google. Please try again."):i}}const vf=Xe.createContext({auth:{loading:!0,user:void 0},signIn:async()=>{},signUp:async()=>{},signOut:async()=>{},get:Ty,put:By,list:Ny,del:Oy,verifyEmail:jy,requestNewVerificationCode:Bc,requestNewVerificationEmail:Bc,refetchUser:async()=>{},changePassword:Ry,refreshAccessToken:gf,initiateGitHubAuth:async()=>({auth_url:"",csrf_token:""}),handleGitHubCallback:async()=>{},initiateGoogleAuth:async()=>({auth_url:"",csrf_token:""}),handleGoogleCallback:async()=>{}});function Z1({children:r,apiUrl:e}){const[t,n]=Xe.useState({loading:!0,user:void 0});Xe.useEffect(()=>{if(!e||e.trim()==="")throw new Error("OpenSecretProvider requires a non-empty apiUrl. Please provide a valid API endpoint URL.");Cy(e)},[e]);async function i(){const j=window.localStorage.getItem("access_token"),w=window.localStorage.getItem("refresh_token");if(!j||!w){n({loading:!1,user:void 0});return}try{const A=await $1();n({loading:!1,user:A})}catch(A){console.error("Failed to fetch user:",A),n({loading:!1,user:void 0})}}Xe.useEffect(()=>{i()},[]);async function s(j,w){console.log("Signing in");try{const{access_token:A,refresh_token:C}=await U1(j,w);window.localStorage.setItem("access_token",A),window.localStorage.setItem("refresh_token",C),await i()}catch(A){throw console.error(A),A}}async function a(j,w,A,C){try{const{access_token:k,refresh_token:P}=await D1(j,w,A,C);window.localStorage.setItem("access_token",k),window.localStorage.setItem("refresh_token",P),await i()}catch(k){throw console.error(k),k}}async function c(){const j=window.localStorage.getItem("refresh_token");if(j)try{await M1(j)}catch(w){console.error("Error during logout:",w)}localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),sessionStorage.removeItem("sessionKey"),sessionStorage.removeItem("sessionId"),n({loading:!1,user:void 0})}const J={auth:t,signIn:s,signOut:c,signUp:a,get:Ty,put:By,list:Ny,del:Oy,refetchUser:i,verifyEmail:jy,requestNewVerificationCode:Bc,requestNewVerificationEmail:Bc,changePassword:Ry,refreshAccessToken:gf,initiateGitHubAuth:async j=>{try{return await H1(j)}catch(w){throw console.error("Failed to initiate GitHub auth:",w),w}},handleGitHubCallback:async(j,w,A)=>{try{const{access_token:C,refresh_token:k}=await F1(j,w,A);window.localStorage.setItem("access_token",C),window.localStorage.setItem("refresh_token",k),await i()}catch(C){throw console.error("GitHub callback error:",C),C}},initiateGoogleAuth:async j=>{try{return await G1(j)}catch(w){throw console.error("Failed to initiate Google auth:",w),w}},handleGoogleCallback:async(j,w,A)=>{try{const{access_token:C,refresh_token:k}=await z1(j,w,A);window.localStorage.setItem("access_token",C),window.localStorage.setItem("refresh_token",k),await i()}catch(C){throw console.error("Google callback error:",C),C}}};return Gy.jsx(vf.Provider,{value:J,children:r})}function K1(){const r=Xe.useContext(vf);if(!r)throw new Error("useOpenSecret must be used within an OpenSecretProvider");return r}Je.OpenSecretContext=vf,Je.OpenSecretProvider=Z1,Je.setApiUrl=Cy,Je.useOpenSecret=K1,Object.defineProperty(Je,Symbol.toStringTag,{value:"Module"})});
|