authhero 9.44.2 → 9.44.3

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.
@@ -293,21 +293,21 @@ type ActionAPI = {
293
293
  };`};function is(e){let t=e===`post-login`?`post-user-login`:e;if(!Object.hasOwn(rs,t))throw Error(`Unsupported action trigger: ${e}`);return rs[t]}var as=f.z.enum([`verify_email`,`verify_email_by_code`,`reset_email`,`reset_email_by_code`,`welcome_email`,`verification_code`,`mfa_oob_code`,`enrollment_email`,`blocked_account`,`stolen_credentials`,`try_provider_configuration_email`,`organization_invitation`]),os=f.z.enum([`otp_verify`,`otp_enroll`,`blocked_account`,`change_password`,`password_breach`]),ss=`message_types`;function cs(e){let t=e?.[ss];if(!Array.isArray(t))return;let n=t.filter(e=>typeof e==`string`);return n.length>0?n:void 0}var ls=`pre-screen`,us=[{name:`login-id`,prompt:`login-id`,auth0:!0,description:`Identifier step of identifier-first login`},{name:`login`,prompt:`login`,auth0:!0,description:`Combined identifier and password login`},{name:`login-password`,prompt:`login-password`,auth0:!0,description:`Password step after the identifier`},{name:`login-passwordless-identifier`,prompt:`login-passwordless`,auth0:!1,description:`Identifier step of a passwordless-only login`},{name:`login-passwordless-email-code`,prompt:`login-passwordless`,auth0:!0,description:`Enter the code sent by email`},{name:`login-passwordless-sms-otp`,prompt:`login-passwordless`,auth0:!0,description:`Enter the code sent by text message`},{name:`magic-link-sent`,prompt:`login-passwordless`,auth0:!1,description:`Sign-in link sent by email`},{name:`passkey-challenge`,prompt:`passkeys`,auth0:!1,description:`Sign in with a passkey`},{name:`email-verification-code`,prompt:`email-verification`,auth0:!1,description:`Verify the email address with a code during login`},{name:`email-verification-link-sent`,prompt:`email-verification`,auth0:!1,description:`Verification link sent during login`},{name:`impersonate`,prompt:`impersonate`,auth0:!1,description:`Choose a user to impersonate`},{name:`signup`,prompt:`signup`,auth0:!0,description:`Sign-up form`},{name:`reset-password-request`,prompt:`reset-password`,auth0:!0,description:`Ask for a password reset`},{name:`reset-password-code`,prompt:`reset-password`,auth0:!1,description:`Enter the password reset code`},{name:`reset-password`,prompt:`reset-password`,auth0:!0,description:`Choose a new password`},{name:`mfa-login-options`,prompt:`mfa`,auth0:!0,description:`Choose an MFA method`},{name:`mfa-otp-challenge`,prompt:`mfa-otp`,auth0:!0,description:`Enter an authenticator app code`},{name:`mfa-otp-enrollment-qr`,prompt:`mfa-otp`,auth0:!0,description:`Enroll an authenticator app`},{name:`mfa-phone-challenge`,prompt:`mfa-phone`,auth0:!0,description:`Enter a code sent to the phone`},{name:`mfa-phone-enrollment`,prompt:`mfa-phone`,auth0:!0,description:`Enroll a phone number`},{name:`passkey-enrollment`,prompt:`passkeys`,auth0:!0,description:`Create a passkey`},{name:`passkey-enrollment-nudge`,prompt:`passkeys`,auth0:!1,description:`Offer to create a passkey after login`},{name:`consent`,prompt:`consent`,auth0:!0,description:`Consent to the requested scopes`},{name:`device-code-activation`,prompt:`device-flow`,auth0:!0,description:`Enter the device code`},{name:`device-code-confirmation`,prompt:`device-flow`,auth0:!0,description:`Confirm the device`},{name:`device-code-activation-allowed`,prompt:`device-flow`,auth0:!0,description:`Device activated`},{name:`accept-invitation`,prompt:`invitation`,auth0:!0,description:`Accept an organization invitation`},{name:`account`,prompt:`account`,auth0:!1,description:`Account overview`},{name:`account-profile`,prompt:`account`,auth0:!1,description:`Edit profile`},{name:`account-change-email`,prompt:`account`,auth0:!1,description:`Change email address`},{name:`account-change-email-verify`,prompt:`account`,auth0:!1,description:`Verify the new email address`},{name:`account-security`,prompt:`account`,auth0:!1,description:`MFA factors (remove a factor)`},{name:`account-mfa-totp-enrollment`,prompt:`account`,auth0:!1,description:`Enroll an authenticator app from the account page`},{name:`account-mfa-phone-enrollment`,prompt:`account`,auth0:!1,description:`Enroll a phone from the account page`},{name:`account-linked`,prompt:`account`,auth0:!1,description:`Linked identities (unlink an identity)`},{name:`account-passkeys`,prompt:`account`,auth0:!1,description:`Passkeys (add or remove a passkey)`},{name:`account-delete`,prompt:`account`,auth0:!1,description:`Delete the account`},{name:`connect-consent`,prompt:`connect`,auth0:!1,description:`Approve connecting an application`},{name:`connect-tenant-select`,prompt:`connect`,auth0:!1,description:`Choose the tenant to connect`},{name:`self-service-app`,prompt:`self-service`,auth0:!1,description:`Self-service application setup`},{name:`invalid-session`,prompt:`status`,auth0:!1,description:`Login session expired or invalid`},{name:`try-connection-result`,prompt:`status`,auth0:!1,description:`Result of testing a connection`}];function ds(e){return us.find(t=>t.name===e)}var fs=[`change-email`,`update-profile`,`reset-password`,`enroll-mfa`,`remove-mfa`,`enroll-passkey`,`remove-passkey`,`unlink-identity`,`delete-account`],ps=`screens`,ms=`fail_closed`;function hs(e){let t=e?.[ps];if(!Array.isArray(t))return;let n=t.filter(e=>typeof e==`string`);return n.length>0?n:void 0}function gs(e){let t=e?.[ms];return t===!0||t===`true`}function _s(e){let t=e?.[ps];return t==null?[]:Array.isArray(t)?t.filter(e=>typeof e!=`string`||!ds(e)).map(e=>typeof e==`string`?e:JSON.stringify(e)):[String(t)]}var vs=[`pre-account-action`];function ys(e){return typeof e==`string`&&vs.includes(e)}function bs(e){let t=e.indexOf(`|`),n=e.slice(0,t),r=e.slice(t+1);if(t===-1||!n||!r)throw Error(`Invalid user_id: ${e}`);return{connection:n,id:r}}var xs=`x-authhero-preserve-location`,Ss={updateIfStateDataUnchanged:([e,t,,n])=>({method:`update`,args:[e,t,n]})};function Cs(e){let{primary:t,secondaries:n,syncMethods:r=[`create`,`rawCreate`,`update`,`remove`,`delete`,`set`,`consumeTotpStep`],conditionalSyncMethods:i=Ss}=e;return new Proxy(t,{get(e,t){if(typeof t==`symbol`)return e[t];let a=e[t];if(typeof a!=`function`)return a;let o=Object.prototype.hasOwnProperty.call(i,t)?i[t]:void 0;return!o&&!r.includes(t)?a.bind(e):async(...r)=>{let i=await a.apply(e,r);if(o&&i!==!0)return i;let s=o?o(r):{method:t,args:r},c=[];for(let e of n){let n=e.adapter[s.method];if(typeof n!=`function`)continue;let i=(async()=>{try{await n.apply(e.adapter,s.args)}catch(n){try{e.onError?e.onError(n,t,r):console.error(`Passthrough adapter: secondary write failed for ${t}:`,n)}catch(e){console.error(`Passthrough adapter: onError handler threw for ${t}:`,e)}}})();e.blocking&&c.push(i)}return c.length>0&&await Promise.all(c),i}}})}function ws(e){return e}function Ts(e){let t=e?.options;if(!t)return{usernameIdentifierActive:!1,emailIdentifierActive:!0,usernameMinLength:1,usernameMaxLength:15};let n=t.attributes;return n?{usernameIdentifierActive:n.username?.identifier?.active===!0,emailIdentifierActive:n.email?.identifier?.active!==!1,usernameMinLength:n.username?.validation?.min_length??1,usernameMaxLength:n.username?.validation?.max_length??15}:{usernameIdentifierActive:t.requires_username===!0,emailIdentifierActive:!0,usernameMinLength:t.validation?.username?.min??1,usernameMaxLength:t.validation?.username?.max??15}}function Es(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ds(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function Os(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}function ks(e){return Ds(new TextEncoder().encode(e))}function As(e){return new TextDecoder().decode(Os(e))}function js(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function Ms(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var Ns=`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`;function Ps(e){let t=``,n=0,r=0;for(let i of e)for(n=n<<8|i,r+=8;r>=5;)r-=5,t+=Ns[n>>r&31];return r>0&&(t+=Ns[n<<5-r&31]),t}function Fs(e){let t=e.replace(/=+$/,``).toUpperCase(),n=t.length%8;if(n===1||n===3||n===6)throw Error(`Invalid base32 length: ${t.length}`);let r=[],i=0,a=0;for(let e of t){let t=Ns.indexOf(e);if(t===-1)throw Error(`Invalid base32 character: ${e}`);i=i<<5|t,a+=5,a>=8&&(a-=8,r.push(i>>a&255))}if(a>0&&i&(1<<a)-1)throw Error(`Invalid base32: non-zero trailing bits`);return new Uint8Array(r)}function Is(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=``;for(let e of t)n+=e.toString(16).padStart(2,`0`);return n}function Ls(e){return ks(JSON.stringify(e))}function Rs(e){try{let t=JSON.parse(As(e));return t&&typeof t==`object`&&typeof t.i==`string`?t:null}catch{return null}}function zs(e){let t=[],n=``,r=!1;for(let i=0;i<e.length;i++){let a=e[i];a===`\\`&&i+1<e.length?(n+=a+e[i+1],i++):a===`"`?(r=!r,n+=a):a===` `&&!r?(n.trim()&&t.push(n.trim()),n=``):n+=a}return n.trim()&&t.push(n.trim()),t}function Bs(e){return e.replace(/\\([\\"+\-!(){}[\]^~*?:/&|])/g,`$1`)}function D(e){return`"${e.replace(/([\\"])/g,`\\$1`)}"`}function Vs(e){let t=e.trim();return Bs(t.length>1&&t.startsWith(`"`)&&t.endsWith(`"`)?t.slice(1,-1):t)}function Hs(e){let t=[],n=[];for(let r of zs(e))/^or$/i.test(r)?(t.push(n),n=[]):n.push(r);return t.push(n),t.filter(e=>e.length>0)}function Us(e,t){let n=new Set(t),r=e=>{let t=e.replace(/^([^:]+)=/,`$1:`),r=t.startsWith(`-`)?t.slice(1):t;if(r.startsWith(`_exists_:`))return n.has(r.slice(9));let i=r.indexOf(`:`);return i>0?n.has(r.slice(0,i)):!0};return Hs(e).map(e=>e.filter(r).join(` `)).filter(e=>e.length>0).join(` OR `)}var Ws=/^[^\s@%_*?"'()[\]{}^~:\\/]+@[^\s@%_*?"'()[\]{}^~:\\/]+\.[^\s@%_*?"'()[\]{}^~:\\/]+$/;function Gs(e){return Ws.test(e)}var Ks=10080*60*1e3,qs=4320*60*1e3;function Js(e){return Math.floor((e+qs)/Ks)}function Ys(e){return e*Ks-qs}function Xs(e,t=Date.now()){let n=Js(t),r=n-e+1;return{currentWeek:n,firstWeek:r,sinceMs:Ys(r)}}function Zs(e,t,n=Date.now()){let{currentWeek:r,firstWeek:i,sinceMs:a}=Xs(t,n),o=new Map;for(let t of e){if(t.created_week<i||t.created_week>r)continue;let e=Math.min(Math.max(0,t.used_week-t.created_week),r-t.created_week),n=o.get(t.created_week);n||(n=new Map,o.set(t.created_week,n)),n.set(e,(n.get(e)??0)+t.count)}let s=[];for(let e=i;e<=r;e++){let t=o.get(e),n=r-e,i=[],a=0;for(let e=n;e>=0;e--)a+=t?.get(e)??0,i[e]=a;s.push({cohort:new Date(Ys(e)).toISOString().slice(0,10),sessions:i[0]??0,active:i})}return{interval:`week`,from:new Date(a).toISOString(),to:new Date(n).toISOString(),cohorts:s}}function Qs(e,t,n=Date.now()){let r=Zs(e,t,n);return{interval:r.interval,from:r.from,to:r.to,cohorts:r.cohorts.map(({cohort:e,sessions:t,active:n})=>({cohort:e,tokens:t,active:n}))}}var $s=/^[A-Za-z0-9_+\-.!#$'^`~]+$/,ec=`Username can only contain alphanumeric characters and the following characters: '_', '+', '-', '.', '!', '#', '$', "'", '^', '\`', '~'`,tc=`Usernames must not contain "@". Use the email field for email addresses.`;function nc(e){return $s.test(e)}function rc(e){return e.toLowerCase()}function ic(e,t){if(e.includes(`@`))return tc;if(!nc(e))return ec;if(t){let n=[...e].length;if(n<t.min)return`Username must be at least ${t.min} characters`;if(n>t.max)return`Username must be at most ${t.max} characters`}return null}var ac=class extends Error{feature;adapter;constructor(e,t,n){super(`${e} is not supported by the ${t} adapter.`+(n?` ${n}`:``)),this.name=`FeatureNotSupportedError`,this.feature=e,this.adapter=t}};function oc(e){return e instanceof Error&&e.name===`FeatureNotSupportedError`}function sc(e){return/^https?:\/\//i.test(e)}var cc=new Set([`SQLITE_CONSTRAINT_UNIQUE`,`SQLITE_CONSTRAINT_PRIMARYKEY`,`ER_DUP_ENTRY`,1062,`23505`]),lc=[`UNIQUE constraint failed`,`Duplicate entry`,`AlreadyExists`,`duplicate key`];function uc(e){let t=e;for(let e=0;e<5;e++){if(typeof t!=`object`||!t)return!1;if(`code`in t&&cc.has(t.code)||`errno`in t&&t.errno===1062)return!0;let e=`message`in t&&typeof t.message==`string`?t.message:``;if(!(`query`in t&&`params`in t||e.startsWith(`Failed query:`))&&lc.some(t=>e.includes(t)))return!0;t=`cause`in t?t.cause:void 0}return!1}function dc(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function fc(e,t){if(e)try{let n=t.safeParse(JSON.parse(e));return n.success?n.data:void 0}catch{return}}function pc(e){return e==null?null:JSON.stringify(e)}function mc(e){if(e===null)return;let t;try{t=JSON.parse(e)}catch{return[]}return Array.isArray(t)?t.flatMap(e=>{let t=va.safeParse(e);return t.success?[t.data]:[]}):[]}function hc(e){let t={id:e.id,name:e.name,created_at:e.created_at,updated_at:e.updated_at};e.description!==null&&(t.description=e.description);let n=mc(e.allowed_strategies);n&&(t.allowed_strategies=n);let r=fc(e.user_attributes,f.z.array(ya));r&&(t.user_attributes=r);let i=fc(e.branding,ba);return i&&(t.branding=i),t}function gc(e,t){let n={updated_at:t};return e.name!==void 0&&(n.name=e.name),e.description!==void 0&&(n.description=e.description),e.allowed_strategies!==void 0&&(n.allowed_strategies=pc(e.allowed_strategies)),e.user_attributes!==void 0&&(n.user_attributes=pc(e.user_attributes)),e.branding!==void 0&&(n.branding=pc(e.branding)),n}var _c=f.z.record(f.z.string(),f.z.record(f.z.string(),Ta));function vc(e,t,n){return fc(e,_c)?.[t]?.[n]??{}}function yc(e,t,n,r){let i=fc(e,_c)??{};return i[t]={...i[t],[n]:r},JSON.stringify(i)}function bc(e,t,n,r){return{id:t,tenant_id:e,profile_id:n.profile_id,ticket_hash:n.ticket_hash,connection_id:n.connection_id??null,connection_config:pc(n.connection_config),enabled_clients:JSON.stringify(n.enabled_clients??[]),enabled_organizations:JSON.stringify(n.enabled_organizations??[]),domain_verification:n.domain_verification,expires_at:n.expires_at,revoked_at:null,completed_at:null,created_at:r,updated_at:r}}function xc(e){let t=Da.safeParse(e.domain_verification),n={id:e.id,profile_id:e.profile_id,enabled_clients:fc(e.enabled_clients,f.z.array(f.z.string()))??[],enabled_organizations:fc(e.enabled_organizations,f.z.array(Aa))??[],domain_verification:t.success?t.data:`required`,expires_at:e.expires_at,created_at:e.created_at,updated_at:e.updated_at};e.connection_id!==null&&(n.connection_id=e.connection_id);let r=fc(e.connection_config,ka);return r&&(n.connection_config=r),e.revoked_at!==null&&(n.revoked_at=e.revoked_at),e.completed_at!==null&&(n.completed_at=e.completed_at),n}function Sc(e){return e.trim().toLowerCase()}function Cc(e,t){return t?`https://${t}/`:e.ISSUER}function wc(e,t,n=`u2`){let r=n.replace(/^\/+|\/+$/g,``)||`u2`;return t?`https://${t}/${r}/`:e.UNIVERSAL_LOGIN_URL?`${new URL(e.UNIVERSAL_LOGIN_URL).origin}/${r}/`:`${e.ISSUER}${r}/`}function Tc(e,t){return[`${wc(e,t,`u`)}info`,`${wc(e,t,`u2`)}info`]}function Ec(e,t){return t?`https://${t}/`:e.OAUTH_API_URL||e.ISSUER}function Dc(){return Ds(crypto.getRandomValues(new Uint8Array(32)))}async function Oc(e){return Is(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))}var kc=`u2/self-service/app`,Ac=10080*60,jc=720*60*60,Mc=`ticket`;function Nc(e,t,n,r){let i=new URL(t,Cc(e.env,e.var.custom_domain));return i.searchParams.set(Mc,n),e.var.custom_domain||i.searchParams.set(`tenant_id`,r),i.toString()}var Pc=`[redacted]`;function Fc(e){return`ticket`in e?{...e,[Mc]:Pc}:e}var Ic=432e3,Lc=720*60*60;function Rc(){return Dc()}async function zc(e){return Oc(e)}var Bc=`u2/self-service`,Vc=/(\/self-service-profiles\/[^/]+\/sso-ticket\/)[^/]+(\/revoke\/?)$/;function Hc(e){return e.replace(Vc,`$1[redacted]$2`)}function Uc(e,t){if((0,m.getRuntimeKey)()===`workerd`)try{e.executionCtx.waitUntil(t);return}catch{}let n=t.then(()=>void 0,e=>{console.error(`waitUntil promise error:`,e)}),r;try{r=e.var?.backgroundPromises}catch{r=void 0}if(!Array.isArray(r)){if(typeof e.set!=`function`)return;r=[],e.set(`backgroundPromises`,r)}r.push(n)}async function Wc(e){let t=e.var.backgroundPromises;if(!Array.isArray(t)||t.length===0)return;let n=t.splice(0,t.length);await Promise.all(n)}function Gc(e){return[...e].reduce((e,[t,n])=>({...e,[t]:n}),{})}function Kc(e){return e.loginSession?.auth_connection||e.authConnection||e.ctxConnection||e.user?.connection||void 0}async function qc(e,t,n,r){if(n)try{let{connections:i}=await e.env.data.connections.list(t),a=i.find(e=>e.name===n)??i.find(e=>e.name.toLowerCase()===n.toLowerCase());if(!a&&n===Go.USERNAME_PASSWORD){let e=i.filter(e=>Jo(e.strategy));e.length===1&&(a=e[0])}return a?{id:a.id||a.name,name:a.name,strategy:a.strategy||r?.provider||`auth0`,metadata:a.options||{}}:void 0}catch(e){console.error(`Error fetching connection info:`,e);return}}var Jc=new Set([`user`,`identity`]);function Yc(e){return e.target&&Jc.has(e.target.type)?e.target.id||e.actor.id||``:e.actor.id||``}function Xc(e){return Yc(e)===(e.actor.id||``)?e.actor.email:void 0}var Zc=`urn:auth0:params:oauth:token-type:session_transfer_token`,Qc=`session_transfer_token`,$c=`auth0_session_transfer_token`,el=`session_transfer_token`,tl=`auth0-forwarded-for`,nl=32;function rl(e){return!!e&&e.startsWith(`urn:`)&&e.endsWith(`:session_transfer`)&&e.length>21}function il(){let e=new Uint8Array(nl);return crypto.getRandomValues(e),Ds(e)}async function al(e){return Is(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))}var ol=`request`,sl=`[REDACTED]`;function cl(e){let t=e.split(`.`)[1];if(!t)return!1;try{let e=JSON.parse(As(t));return typeof e==`object`&&!!e&&`session_transfer_token`in e}catch{return!1}}function ll(e){if(!e||!e.includes(`session_transfer_token`)&&!e.includes(ol)&&!e.includes(`%`))return e;try{let t=new URL(e),n=t.searchParams.has(Qc),r=t.searchParams.getAll(ol).some(cl);return!n&&!r?e:(t.searchParams.delete(Qc),r&&t.searchParams.delete(ol),t.toString())}catch{return ul(e)}}function ul(e){let t=e.indexOf(`#`),n=t===-1?e:e.slice(0,t),r=n.indexOf(`?`);if(r===-1)return e;let i=n.slice(r+1).split(`&`),a=i.filter(e=>!dl(e));if(a.length===i.length)return e;let o=a.length>0?`?${a.join(`&`)}`:``,s=t===-1?``:e.slice(t);return`${n.slice(0,r)}${o}${s}`}function dl(e){let t=e.indexOf(`=`),n=fl(t===-1?e:e.slice(0,t));return n===`session_transfer_token`?!0:n===ol&&t!==-1&&cl(fl(e.slice(t+1)))}function fl(e){let t=e.replace(/\+/g,` `);try{return decodeURIComponent(t)}catch{return t}}function pl(e){let t=Qc in e,n=ml(e[ol]);if(!t&&!n)return e;let r={...e};return t&&(r[Qc]=sl),n&&(r[ol]=sl),r}function ml(e){return typeof e==`string`?e.split(`,`).some(cl):Array.isArray(e)&&e.some(ml)}function hl(e){let t=e?.trim();if(!t||t.length>45)return;if(/^\d{1,3}(\.\d{1,3}){3}$/.test(t)){let e=t.split(`.`).map(Number);return e.every(e=>e<=255)?e.join(`.`):void 0}if(!t.includes(`:`)||/[^0-9a-fA-F:.]/.test(t))return;let n;try{n=new URL(`http://[${t}]/`).hostname.replace(/^\[/,``).replace(/\]$/,``).toLowerCase()}catch{return}let r=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(n);if(r?.[1]&&r[2]){let e=parseInt(r[1],16),t=parseInt(r[2],16);return[e>>8,e&255,t>>8,t&255].join(`.`)}return n}var gl=new Set([`password`,`password_hash`,`client_secret`,`client_assertion`,`code_verifier`,`device_code`,`user_code`,`otp`,`signing_keys`,`credentials`,`encryption_key`,`otp_secret`,`http_authorization`,`httpAuthorization`,`datadog_api_key`,`datadogApiKey`,`splunk_token`,`splunkToken`,`aws_secret_access_key`,`awsSecretAccessKey`,`session_transfer_token`]),_l=new Set([`code`,`refresh_token`,`subject_token`,`actor_token`]);function vl(e,t=3){return e.length<=t?`*`.repeat(e.length):`*`.repeat(e.length-t)+e.slice(-t)}function yl(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date)}function bl(e,t=!1){if(!e)return;let n={};for(let[r,i]of Object.entries(e))gl.has(r)?n[r]=`[REDACTED]`:t&&_l.has(r)&&typeof i==`string`?n[r]=vl(i):yl(i)?n[r]=bl(i,t):n[r]=i;return n}function xl(e){return e&&typeof e==`object`&&!Array.isArray(e)?bl(e,!0):e}function Sl(e,t){return e.targetType&&Jc.has(e.targetType)&&e.targetId?e.targetId:e.userId||t.var.user_id||t.var.sessionAuth?.user?.user_id||``}function Cl(e,t){if(!e||!t)return;let n={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let i of r){let r=e[i],a=t[i];JSON.stringify(r)!==JSON.stringify(a)&&(n[i]={old:r,new:a})}return Object.keys(n).length>0?n:void 0}function wl(e,t){return e.var.user_id||t.actorUserId?`admin_action`:e.var.sessionAuth?.user||t.userId?`user_action`:e.var.client_id?`api`:`system`}async function Tl(e,t,n){let r=e.var.user;if(!r?.sub)return{request_auth:e.var.sessionAuth};let i=r.scope?r.scope.split(` `).filter(Boolean):[],a={...typeof r.jti==`string`?{jti:r.jti}:{},...i.length?{scopes:i}:{}},o={strategy:`jwt`,credentials:a},s=r.tenant_id||t;if(r.sub.endsWith(`@clients`)||r.azp&&r.sub===r.azp||r.gty)return{request_auth:o,caller_client_id:r.azp||r.sub.replace(/@clients$/,``)};try{let t=await n(s,r.sub);if(t)return{request_auth:{user:{user_id:r.sub,...t.name?{name:t.name}:{},...t.email?{email:t.email}:{}},strategy:`jwt`,credentials:a}};if(!r.azp&&await e.env.data.clients.get(s,r.sub))return{request_auth:o,caller_client_id:r.sub}}catch{}return{request_auth:{user:{user_id:r.sub},strategy:`jwt`,credentials:a}}}async function El(e,t,n){let r=n.connection||e.var.connection||``,i=e.var.client_id,a=Sl(n,e),o=!!n.targetType&&Jc.has(n.targetType)&&!!n.targetId,s=new Map,c=(t,n)=>{let r=JSON.stringify([t,n]),i=s.get(r);return i||(i=e.env.data.users.get(t,n),s.set(r,i)),i},[l,u,d,f]=await Promise.all([(async()=>{if(r)return qc(e,t,r)})(),(async()=>{if(n.client_name)return n.client_name;if(!i)return``;try{return(await e.env.data.clients.get(t,i))?.name||``}catch{return``}})(),(async()=>{if(!o){let t=e.var.username||n.username;if(t)return t}let r=e.var.sessionAuth?.user;if(a&&a===r?.user_id)return r.email||r.name||``;if(!a)return``;try{let e=await c(t,a);return e?.email||e?.phone_number||e?.name||``}catch{return``}})(),Tl(e,t,c)]),p=r===Go.USERNAME_PASSWORD&&l?.name||``;return{connection_id:n.connection_id||l?.id||``,connection:p,client_name:u,user_name:d,...f}}function Dl(e,t){return t.login_session_id??e.var.loginSession?.id}function Ol(e,t,n,r){let i=e.env.outbox?.captureEntityState!==!1,a=Dl(e,n),o=i?bl(n.beforeState):void 0,s=i?bl(n.afterState):void 0,c=Sl(n,e),l=e.var.sessionAuth?.user,u=e.var.user_id||n.actorUserId||l?.user_id||n.userId,d=r&&c&&c===u?r.user_name:void 0;return{tenant_id:t,event_type:n.targetType?`${n.targetType}.${kl(e.req.method)}`:n.type,log_type:n.type,description:n.description,category:wl(e,n),actor:{type:e.var.user_id||n.actorUserId?`admin`:l||n.userId?`user`:e.var.client_id?`client_credentials`:`system`,id:u||void 0,email:e.var.username||n.username||(u===l?.user_id?l?.email:void 0)||d||void 0,org_id:e.var.organization_id||e.var.user?.org_id||void 0,org_name:e.var.org_name||e.var.user?.org_name||void 0,scopes:e.var.user?.scope?e.var.user.scope.split(` `):void 0,client_id:e.var.client_id||r?.caller_client_id||void 0},target:{type:n.targetType||`unknown`,id:n.targetId||n.userId||e.var.user_id||``,before:o,after:s,diff:Cl(o,s)},request:{method:e.req.method,path:Hc(e.req.path),query:e.req.queries()?Fc(pl(Object.fromEntries(Object.entries(e.req.queries()).map(([e,t])=>[e,Array.isArray(t)?t.join(`,`):t])))):void 0,body:xl(n.body||e.var.body||void 0),ip:e.var.ip||``,user_agent:e.var.useragent||void 0,...n.redirect_uri?{redirect_uri:n.redirect_uri}:{},...n.authorization_url?{authorization_url:n.authorization_url}:{},...r?.request_auth?{auth:r.request_auth}:{}},response:n.response?{status_code:n.response.statusCode,body:n.response.body}:void 0,connection:r?.connection||n.connection||e.var.connection||void 0,connection_id:n.connection_id||r?.connection_id||void 0,client_name:n.client_name||r?.client_name||void 0,strategy:n.strategy||void 0,strategy_type:n.strategy_type||void 0,audience:n.audience||void 0,scope:n.scope||void 0,hostname:e.var.host||``,is_mobile:!1,auth0_client:e.var.auth0_client,...n.execution_id?{execution_id:n.execution_id}:{},...a?{login_session_id:a}:{},...n.details||n.diagnostics?{details:{...n.details,...n.diagnostics}}:{},timestamp:new Date().toISOString()}}function kl(e){switch(e){case`POST`:return`created`;case`PATCH`:case`PUT`:return`updated`;case`DELETE`:return`deleted`;default:return`accessed`}}async function O(e,t,n){let r={};if(e.req.raw?.headers){let t=Gc(e.req.raw.headers);for(let[e,n]of Object.entries(t))r[e.toLowerCase()]=n}if(e.env.outbox?.enabled&&e.env.data.outbox){let r=e.env.data.outbox,i=(async()=>{let i=Ol(e,t,n,await El(e,t,n));return r.create(t,i)})(),a=e.var.outboxEventPromises||[];a.push(i),e.set(`outboxEventPromises`,a);return}let i=Dl(e,n),a=async()=>{let[a,o]=await Promise.all([(async()=>{if(e.env.data.geo)try{return await e.env.data.geo.getGeoInfo(r)||void 0}catch(e){console.warn(`Failed to get geo information:`,e);return}})(),El(e,t,n)]),s=n.details?{...n.details}:{request:{method:e.req.method,path:Hc(e.req.path),qs:Fc(pl(e.req.queries())),body:xl(n.body||e.var.body||``),...n.redirect_uri?{redirect_uri:n.redirect_uri}:{}},...n.response&&{response:n.response}};o.request_auth&&(s.request={...yl(s.request)?s.request:{},auth:o.request_auth});let c={type:n.type,description:n.description||``,ip:e.var.ip,user_agent:e.var.useragent||``,auth0_client:e.var.auth0_client,date:new Date().toISOString(),details:{...s,...n.execution_id?{execution_id:n.execution_id}:{},...i?{login_session_id:i}:{},...n.diagnostics},isMobile:!1,client_id:e.var.client_id||o.caller_client_id,client_name:o.client_name,user_id:Sl(n,e),hostname:e.var.host||``,user_name:o.user_name,connection_id:o.connection_id,connection:o.connection||n.connection||e.var.connection||``,strategy:n.strategy||``,strategy_type:n.strategy_type||``,audience:n.audience||``,scope:n.scope||``,location_info:a};await e.env.data.logs.create(t,c)};n.waitForCompletion?await a():Uc(e,a())}var k=class extends p.HTTPException{constructor(e,t){super(e,{message:JSON.stringify(t),res:new Response(JSON.stringify(t),{status:e,headers:{"Content-Type":`application/json`}})})}},Al={400:`Bad Request`,401:`Unauthorized`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,409:`Conflict`,422:`Unprocessable Entity`,429:`Too Many Requests`};function jl(e,t,n){return{statusCode:e,error:Al[e]??`Error`,message:t,...n?{errorCode:n}:{}}}function Ml(e,t,n){return new k(e,jl(e,t,n))}var A=(e,t)=>()=>Ml(404,e,t),Nl={user:A(`The user does not exist.`,`inexistent_user`),users:A(`One or more of the users do not exist.`,`inexistent_user`),client:A(`The client does not exist`,`inexistent_client`),clientOnUpdate:A(`The client does not exist.`,`inexistent_client`),connection:A(`The connection does not exist`,`inexistent_connection`),resourceServer:A(`The resource server does not exist`,`inexistent_resource_server`),resourceServerByIdentifier:e=>Ml(404,`No resource with identifier ${e}`,`inexistent_resource_server`),clientGrant:A(`The grant does not exist.`,`inexistent_client_grant`),log:A(`The log does not exist.`,`inexistent_log`),job:A(`The job does not exist`,`inexistent_job`),customDomain:e=>Ml(404,`The custom domain ${e} does not exist`,`inexistent_custom_domain`),key:e=>Ml(404,`The key with key ID "${e}" was not found.`,`inexistent_tenant_key`),hook:A(`Error: Hook does not exist`,`HookDoesNotExist`),enrollment:A(`Enrollment not found`,`enrollment_not_found`),role:A(`The role does not exist.`,`inexistent_role`),roleOnUpdate:A(`No such role.`,`inexistent_role`),organization:A(`No organization found by that id or name`,`inexistent_organization`),action:A(`That action does not exist.`,`inexistent_action`),tenant:A(`The tenant does not exist.`,`inexistent_tenant`),invitation:A(`The invitation does not exist.`,`inexistent_invitation`),member:A(`The member does not exist.`,`inexistent_member`),identity:A(`The identity does not exist.`,`inexistent_identity`),session:A(`The session does not exist.`,`inexistent_session`),refreshToken:A(`The refresh token does not exist.`,`inexistent_refresh_token`),grant:A(`The grant does not exist.`,`inexistent_grant`),logStream:A(`The log stream does not exist.`,`inexistent_log_stream`),form:A(`The form does not exist.`,`inexistent_form`),flow:A(`The flow does not exist.`,`inexistent_flow`),emailTemplate:A(`The email template does not exist.`,`inexistent_email_template`),emailProvider:A(`The email provider does not exist.`,`inexistent_email_provider`),authenticationMethod:A(`The authentication method does not exist.`,`inexistent_authentication_method`),actionExecution:A(`The action execution does not exist.`,`inexistent_action_execution`),actionVersion:A(`The action version does not exist.`,`inexistent_action_version`),hookCode:A(`The hook code does not exist.`,`inexistent_hook_code`),failedEvent:A(`The failed event does not exist.`,`inexistent_failed_event`),migrationSource:A(`The migration source does not exist.`,`inexistent_migration_source`),proxyRoute:A(`The proxy route does not exist.`,`inexistent_proxy_route`),scimConfiguration:A(`The SCIM configuration does not exist.`,`inexistent_scim_configuration`),scimToken:A(`The SCIM token does not exist.`,`inexistent_scim_token`),tenantOperation:A(`The tenant operation does not exist.`,`inexistent_tenant_operation`),rollout:A(`The rollout does not exist.`,`inexistent_rollout`),tokenExchangeProfile:A(`The token exchange profile does not exist.`,`inexistent_token_exchange_profile`),selfServiceProfile:A(`Self-service profile not found.`,`inexistent_self_service_profile`)},Pl={userExists:()=>Ml(409,`The user already exists.`,`auth0_idp_error`),resourceServer:e=>Ml(409,`A resource server already exists with identifer ${e}`,`resource_server_conflict`),organizationName:()=>Ml(409,`An organization with this name already exists.`,`organization_conflict`),selfServiceProfileLimit:()=>Ml(409,`No more profiles can be created for this tenant.`,`self_service_profile_limit`),connectionName:()=>Ml(409,`A connection with this name already exists.`,`connection_conflict`),other:e=>Ml(409,e,`conflict`)},Fl={missingAuthentication:()=>Ml(401,`Missing authentication`,`missing_authentication`),invalidToken:(e=`Invalid token`)=>Ml(401,e,`invalid_token`),insufficientScope:e=>Ml(403,`Insufficient scope, expected any of: ${e.join(`,`)}`,`insufficient_scope`)},Il={json:{prefix:`Payload validation error`,code:`invalid_body`},form:{prefix:`Payload validation error`,code:`invalid_body`},query:{prefix:`Query validation error`,code:`invalid_query_string`},param:{prefix:`Path validation error`,code:`invalid_uri`},header:{prefix:`Header validation error`,code:`invalid_headers`}};function Ll(e){return typeof e==`object`&&!!e}function Rl(e,t){let n=e;for(let e of t){if(!Ll(n))return;n=n[e]}return n}function zl(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function Bl(e,t){let n=(e.path??[]).map(String),r=Rl(t,e.path??[]);switch(e.code){case`invalid_type`:return t===void 0?{detail:e.message??`Invalid value`,path:n}:r===void 0?{detail:`Missing required property: ${n[n.length-1]??`root`}`,path:n.slice(0,-1)}:{detail:`Expected type ${e.expected} but found type ${zl(r)}`,path:n};case`unrecognized_keys`:return{detail:`Additional properties not allowed: ${(e.keys??[]).join(`,`)}`,path:n};case`invalid_value`:case`invalid_enum_value`:return{detail:`Invalid value ${JSON.stringify(r)}`,path:n};case`too_big`:return{detail:e.origin===`string`?`String is too long (${String(r).length} chars), maximum ${e.maximum}`:`Value ${Array.isArray(r)?JSON.stringify(r):String(r)} is greater than maximum ${e.maximum}`,path:n};case`too_small`:return{detail:e.origin===`string`?`String is too short (${String(r).length} chars), minimum ${e.minimum}`:`Value ${Array.isArray(r)?JSON.stringify(r):String(r)} is less than minimum ${e.minimum}`,path:n};case`invalid_format`:return{detail:`Object didn't pass validation for format ${e.format}: ${String(r)}`,path:n};default:return{detail:e.message??`Invalid value`,path:n}}}function Vl(e,t,n){let{prefix:r,code:i}=Il[e]??{prefix:`Payload validation error`,code:`invalid_body`};return jl(400,t.filter(Hl).map(e=>{let{detail:t,path:i}=Bl(e,n);return`${r}: '${t}'${i.length?` on property ${i.join(`.`)}`:``}.`}).join(` (also) `)||r,i)}function Hl(e){return Ll(e)}function Ul(e){return Ll(e)&&Array.isArray(e.issues)?e.issues:[]}function Wl(e,t){if(!e.success)return t.json(Vl(e.target,Ul(e.error),e.data),400)}var Gl=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,Kl=e=>crypto.getRandomValues(new Uint8Array(e)),ql=(e,t,n)=>{let r=256-256%e.length;if(r===256){let r=e.length-1;return(i=t)=>{if(!i)return``;let a=``;for(;;){let t=n(i),o=i;for(;o--;)if(a+=e[t[o]&r],a.length>=i)return a}}}let i=Math.ceil(1.6*256*t/r);return(a=t)=>{if(!a)return``;let o=``;for(;;){let t=n(i),s=i;for(;s--;)if(t[s]<r&&(o+=e[t[s]%e.length],o.length>=a))return o}}},Jl=(e,t=21)=>ql(e,t|0,Kl),Yl=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Gl[n[e]&63];return t},Xl=24;function Zl(){return Jl(`0123456789abcdef`,Xl)()}function Ql(e){let t=e.indexOf(`|`);return t===-1?(console.error(`Invalid user_id format`),e):e.slice(t+1)}function $l(e,t){return e.startsWith(`${t}|`)?e.slice(t.length+1):e}function eu(e){let{self_service:t,...n}=e;return n}function tu(e){if(!e)return;let t=e.lastIndexOf(`@`);if(!(t<0))return e.slice(t+1).trim().toLowerCase()||void 0}function nu(e,t){let n=tu(t);return n?(e.domains??[]).some(e=>e.status===`verified`&&e.domain.trim().toLowerCase()===n):!1}function ru(e,t){return!!e&&!nu(e,t)}async function iu(e,t){let n=new Map;for(let r=0;;r++){let i=await e.list(t,{page:r,per_page:100});for(let e of i.connections)e.self_service&&n.set(e.name,e.self_service);if(i.connections.length<100)break}return n}async function au(e,t,n){if(n.length===0)return n;let r=await iu(e,t);return r.size===0?n:n.filter(e=>!ru(e.connection?r.get(e.connection):void 0,e.email))}function ou(e,t){return!t||!e.connection||e.connection===t.name?!0:!t.databaseConnectionNames.has(e.connection)}function su(e){let t=t=>t.connection===e.name?0:1;return(e,n)=>t(e)-t(n)}async function cu(e,t,n){if(!n)return;let r=await du(e,t),i=new Set(r.filter(e=>Jo(e.strategy)).map(e=>e.name));if(!(i.size<2||!i.has(n)))return{name:n,databaseConnectionNames:i}}var lu=50,uu=100;async function du(e,t){let n=await e.list(t),r=typeof n.limit==`number`&&n.limit>0?n.limit:lu;if(n.connections.length<r)return n.connections;let i=[];for(let n=0;;n++){let{connections:r}=await e.list(t,{page:n,per_page:uu,include_totals:!1});if(i.push(...r),r.length<uu)return i}}function fu(e,t){let n=e.connections.filter(e=>Jo(e.strategy));if(t){let e=n.find(e=>e.name===t);if(e)return e;if(t!==Go.USERNAME_PASSWORD)throw mu(t)}return n[0]}function pu(e,t){return fu(e,t)?.name??Go.USERNAME_PASSWORD}function mu(e){return new k(400,{error:`invalid_request`,error_description:`The connection ${e} is not enabled for this client.`})}function hu(e){let t=e.filter(e=>Jo(e.strategy)).sort(gu);if(t.length<2)return e;let n=0;return e.map(e=>Jo(e.strategy)?t[n++]??e:e)}function gu(e,t){if(!!e.created_at!=!!t.created_at)return e.created_at?-1:1;let n=_u(e.created_at,t.created_at);return n===0?(e.id||e.name).localeCompare(t.id||t.name):n}function _u(e=``,t=``){let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?e.localeCompare(t):n-r}var vu=`auth2`,yu=`auth0`,bu=[vu,yu];async function xu(e,t){return e.usernamePasswordProvider?e.usernamePasswordProvider({tenant_id:t}):yu}function Su(e){return e===vu||e===yu}async function Cu({env:e,tenant_id:t,username:n,connection:r}){let i=await cu(e.data.connections,t,r),a=r=>Pu({userAdapter:e.data.users,tenant_id:t,username:n,provider:r,connection:i}),o=await a(vu);if(o&&(!i||o.connection===i.name))return o;let s=await a(yu);return!i||s&&s.connection===i.name?s:o??s}async function wu(e){let t=await Cu(e);return t?Hu(e.env.data.users,e.tenant_id,t):null}async function Tu(e,t){let{client:n,username:r,connection:i,ip:a}=t;return await Cu({env:e.env,tenant_id:n.tenant.id,username:r,connection:i})||rd(e,{client:n,username:r,provider:await xu(e.env,n.tenant.id),connection:i,isSocial:!1,ip:a})}var Eu=/^[^\s@.]+(\.[^\s@.]+)*@[^\s@.]+(\.[^\s@.]+)*\.[A-Za-z]{2,}$/;function Du(e){return Eu.test(e)}function Ou(e){return e.trim().toLowerCase()}function ku(e){if(!e.email)return e;let t=Ou(e.email);return t===e.email?e:{...e,email:t}}async function Au(e,t,n){return(await e.list(t,{page:0,per_page:10,include_totals:!1,q:`email:${D(n)}`})).users}async function ju(e,t,n){return Nu(e,t,`email:${D(n)}`)}async function Mu(e,t,n){return Nu(e,t,`username:${D(n)}`)}async function Nu(e,t,n){let r=[],i=0;for(;;){let a=await e.list(t,{page:i,per_page:100,include_totals:!1,q:n});if(r.push(...a.users),a.users.length<100)break;i++}return r}async function Pu({userAdapter:e,tenant_id:t,username:n,provider:r,connection:i}){let a;a=r===`sms`?`phone_number:${D(n)}`:n.includes(`@`)?`email:${D(n)}`:`username:${D(n)}`;let{users:o}=await e.list(t,{page:0,per_page:10,include_totals:!1,q:`${a} provider:${D(r)}`}),s=i?o.filter(e=>ou(e,i)).sort(su(i)):o;return!i&&s.length>1&&console.error(`More than one user found for same username and provider`),s[0]||null}function Fu(e,t){let n=e.created_at?new Date(e.created_at).getTime():2**53-1,r=t.created_at?new Date(t.created_at).getTime():2**53-1;return n===r?(e.user_id||``).localeCompare(t.user_id||``):n-r}function Iu(e,t){let n=e=>{if(!e)return 0;let t=new Date(e).getTime();return Number.isNaN(t)?0:t},r=n(e.last_login),i=n(t.last_login);return r===i?Fu(e,t):i-r}async function Lu({userAdapter:e,tenant_id:t,email:n}){let{users:r}=await e.list(t,{page:0,per_page:1,include_totals:!1,q:`email:${D(n)}`});return r.length>0}async function Ru({userAdapter:e,tenant_id:t,email:n,warnOnMultiplePrimaries:r=!1,filterCandidates:i}){let{users:a}=await e.list(t,{page:0,per_page:10,include_totals:!1,q:`email:${D(n)}`});if(a.length===0)return;let o=a.filter(e=>!e.linked_to);if(o.length>0){let e=i?await i(o):o;return e.length===0?void 0:(r&&e.length>1&&console.error(`More than one primary user found for same email`),[...e].sort(Fu)[0])}let s=await Vu(e,t,a[0].linked_to),c=await e.get(t,s);if(!c)throw Error(`Primary account not found`);if(i){let[e]=await i([c]);return e}return c}async function zu({userAdapter:e,tenant_id:t,email:n}){let{users:r}=await e.list(t,{page:0,per_page:10,include_totals:!1,q:`email:${D(n)}`});if(r.length===0)return;let i=r.filter(e=>!e.linked_to);if(i.length>0)return[...i].sort(Iu)[0];let a=r[0]?.linked_to;if(!a)return;let o=await Vu(e,t,a);return await e.get(t,o)??void 0}var Bu=5;async function Vu(e,t,n){let r=n,i=new Set([n]);for(let a=0;a<Bu;a++){let o=await e.get(t,r);if(!o?.linked_to)return r;if(i.has(o.linked_to))return console.error(`linked_to cycle detected resolving ${n}; stopping at ${r}`),r;a>0&&console.error(`linked_to chain deeper than one hop resolving ${n} (at ${o.linked_to}); the cluster needs flattening`),i.add(o.linked_to),r=o.linked_to}return console.error(`linked_to chain exceeded ${Bu} hops resolving ${n}; stopping at ${r}`),r}async function Hu(e,t,n){if(!n.linked_to)return n;let r=await Vu(e,t,n.linked_to);return await e.get(t,r)??n}async function Uu({userAdapter:e,tenant_id:t,userId:n,primaryId:r}){if(n===r)throw new k(400,{message:`Cannot link a user to itself`});let i=await Vu(e,t,r);if(i===n){let i=await e.get(t,r),a=r.indexOf(`|`);if(i?.linked_to===n&&a>0)return await e.unlink(t,n,r.slice(0,a),r.slice(a+1)),await Wu(e,t,n,r),await e.update(t,n,{linked_to:r}),r;throw new k(400,{message:`Cannot link a user to itself`})}return await Wu(e,t,n,i),await e.update(t,n,{linked_to:i}),i}async function Wu(e,t,n,r){for(;;){let{users:i}=await e.list(t,{page:0,per_page:100,include_totals:!1,q:`linked_to:${D(n)}`});if(i.length===0)break;let a=0;for(let n of i)n.user_id!==r&&(await e.update(t,n.user_id,{linked_to:r}),a++);if(a===0)break}}function Gu(e){return Su(e.provider)?!0:e.provider===`email`||e.connection===`email`}function Ku({candidates:e,target:t,clusterRootId:n,connectionScope:r}){let i=e=>Su(e.provider)&&Su(t.provider);return e.find(e=>e.user_id===t.user_id?!1:e.provider===t.provider?!0:e.user_id===n||e.linked_to===n?!1:r&&i(e)?ou(e,r):e.connection===t.connection)}async function qu({userAdapter:e,tenant_id:t,primaryUserId:n,sourceUserId:r,email:i,email_verified:a}){let o=Ou(i),s=async n=>{n.user_id!==r&&Gu(n)&&(n.email===o&&n.email_verified===a||await e.update(t,n.user_id,{email:o,email_verified:a}))};if(n!==r){let r=await e.get(t,n);r&&await s(r)}let c=0;for(;;){let{users:r}=await e.list(t,{page:c,per_page:100,include_totals:!1,q:`linked_to:${D(n)}`});if(r.length===0)break;for(let e of r)await s(e);if(r.length<100)break;c++}}async function Ju({userAdapter:e,tenant_id:t,username:n,provider:r,connection:i}){let a=await Pu({userAdapter:e,tenant_id:t,username:n,provider:r,connection:i});return a?Hu(e,t,a):null}function Yu(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Xu=[[`middle_name`,100],[`gender`,50],[`zoneinfo`,100],[`locale`,64],[`profile`,2048],[`website`,2048]],Zu=/^\d{4}(-\d{2}-\d{2})?$/;function Qu(e){if(!Zu.test(e))return!1;if(e.length===4)return!0;let t=Number(e.slice(0,4))||2e3,n=Number(e.slice(5,7)),r=Number(e.slice(8,10));if(n<1||n>12||r<1)return!1;let i=new Date(0);return i.setUTCFullYear(t,n,0),r<=i.getUTCDate()}var $u=[`formatted`,`street_address`,`locality`,`region`,`postal_code`,`country`];function ed(e){if(!Yu(e))return;let t={};for(let n of $u){let r=e[n];typeof r==`string`&&r&&(t[n]=r)}return Object.keys(t).length>0?t:void 0}function td(e,t){return Yu(e)&&Yu(t)?[...new Set([...Object.keys(e),...Object.keys(t)])].every(n=>td(e[n],t[n])):e===t}function nd(e){let t={};typeof e.name==`string`&&(t.name=e.name),typeof e.given_name==`string`&&(t.given_name=e.given_name),typeof e.family_name==`string`&&(t.family_name=e.family_name),typeof e.nickname==`string`&&(t.nickname=e.nickname),typeof e.picture==`string`&&(t.picture=e.picture),typeof e.email_verified==`boolean`&&(t.email_verified=e.email_verified),typeof e.phone_number==`string`&&(t.phone_number=e.phone_number),typeof e.phone_number_verified==`boolean`?t.phone_verified=e.phone_number_verified:typeof e.phone_verified==`boolean`&&(t.phone_verified=e.phone_verified);for(let[n,r]of Xu){let i=e[n];typeof i==`string`&&i&&i.length<=r&&(t[n]=i)}typeof e.birthdate==`string`&&Qu(e.birthdate)&&(t.birthdate=e.birthdate);let n=ed(e.address);return n&&(t.address=n),t}async function rd(e,t){let{provider:n,connection:r,client:i,userId:a,isSocial:o,profileData:s={},ip:c=``,set_user_root_attributes:l,selfService:u}=t,d=t.username.includes(`@`)?Ou(t.username):t.username,f=l||`on_each_login`,p=f===`never_on_login`?{}:nd(s),m=ru(u,d),h=a?`${n}|${a}`:void 0,g=Su(n)?await cu(e.env.data.connections,i.tenant.id,r):void 0,_=n===`samlp`&&h!==void 0,v=async()=>{if(h){let t=await e.env.data.users.get(i.tenant.id,h);if(t||_)return t}return Pu({userAdapter:e.env.data.users,tenant_id:i.tenant.id,username:d,provider:n,connection:g})},y=t=>Hu(e.env.data.users,i.tenant.id,t),b=await v(),x=b?await y(b):null,S=!1;if(!x){let t={user_id:h??`${n}|${Zl()}`,email:r!==`sms`&&d.includes(`@`)?d:void 0,phone_number:r===`sms`?d:p.phone_number,username:!d.includes(`@`)&&r!==`sms`?d:void 0,name:p.name||d,given_name:p.given_name,family_name:p.family_name,nickname:p.nickname,picture:p.picture,phone_verified:p.phone_verified,middle_name:p.middle_name,profile:p.profile,website:p.website,gender:p.gender,birthdate:p.birthdate,zoneinfo:p.zoneinfo,locale:p.locale,address:p.address,provider:n,connection:r,email_verified:m?!1:p.email_verified??(o||r===`email`),last_ip:c,is_social:o,last_login:new Date().toISOString(),profileData:JSON.stringify(s)};try{x=await e.env.data.users.create(i.tenant.id,t),S=!0}catch(e){if(e?.status!==409||(b=await v(),!b))throw e;x=await y(b)}e.set(`user_id`,x.user_id)}let ee=f===`on_each_login`,te=!!u&&!!b&&b.user_id!==x.user_id,ne=!te&&(m||ru(u,x.email));if(!S&&(ee||ne)){let t;ne?t=!1:!te&&(!u||x.email&&Ou(x.email)===d)&&(t=p.email_verified);let n={...ee?{...p,profileData:JSON.stringify(s)}:{},email_verified:t},r={...x},a=Object.fromEntries(Object.entries(n).filter(([e,t])=>t!==void 0&&!td(r[e],t)));if(Object.keys(a).length>0){let t=x.user_id,n=e.env.data.users.update(i.tenant.id,t,a);try{e.executionCtx.waitUntil(n.catch(e=>{console.error(`Deferred profile sync failed for ${t}`,e)}))}catch{await n}x={...x,...a}}}return x}async function id(e,t,n,r){let i=await e.refreshTokens.revokeBySession(t,n.id,r);return n.login_session_id&&(i+=await e.refreshTokens.revokeByLoginSession(t,n.login_session_id,r)),i}var ad=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parse=s,e.stringifySetCookie=c,e.serialize=c,e.stringifySetCookie=c,e.serialize=c;var t=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,n=/^[\u0021-\u003A\u003C-\u007E]*$/,r=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,i=/^[\u0020-\u003A\u003D-\u007E]*$/,a=Object.prototype.toString,o=(()=>{let e=function(){};return e.prototype=Object.create(null),e})();function s(e,t){let n=new o,r=e.length;if(r<2)return n;let i=t?.decode||f,a=0;do{let t=u(e,a,r);if(t===-1)break;let o=l(e,a,r);if(t>o){a=e.lastIndexOf(`;`,t-1)+1;continue}let s=d(e,a,t);n[s]===void 0&&(n[s]=i(d(e,t+1,o))),a=o+1}while(a<r);return n}function c(e,a,o){let s=typeof e==`object`?e:{...o,name:e,value:String(a)},c=(typeof a==`object`?a:o)?.encode||encodeURIComponent;if(!t.test(s.name))throw TypeError(`argument name is invalid: ${s.name}`);let l=s.value?c(s.value):``;if(!n.test(l))throw TypeError(`argument val is invalid: ${s.value}`);let u=s.name+`=`+l;if(s.maxAge!==void 0){if(!Number.isInteger(s.maxAge))throw TypeError(`option maxAge is invalid: ${s.maxAge}`);u+=`; Max-Age=`+s.maxAge}if(s.domain){if(!r.test(s.domain))throw TypeError(`option domain is invalid: ${s.domain}`);u+=`; Domain=`+s.domain}if(s.path){if(!i.test(s.path))throw TypeError(`option path is invalid: ${s.path}`);u+=`; Path=`+s.path}if(s.expires){if(!p(s.expires)||!Number.isFinite(s.expires.valueOf()))throw TypeError(`option expires is invalid: ${s.expires}`);u+=`; Expires=`+s.expires.toUTCString()}if(s.httpOnly&&(u+=`; HttpOnly`),s.secure&&(u+=`; Secure`),s.partitioned&&(u+=`; Partitioned`),s.priority)switch(typeof s.priority==`string`?s.priority.toLowerCase():void 0){case`low`:u+=`; Priority=Low`;break;case`medium`:u+=`; Priority=Medium`;break;case`high`:u+=`; Priority=High`;break;default:throw TypeError(`option priority is invalid: ${s.priority}`)}if(s.sameSite)switch(typeof s.sameSite==`string`?s.sameSite.toLowerCase():s.sameSite){case!0:case`strict`:u+=`; SameSite=Strict`;break;case`lax`:u+=`; SameSite=Lax`;break;case`none`:u+=`; SameSite=None`;break;default:throw TypeError(`option sameSite is invalid: ${s.sameSite}`)}return u}function l(e,t,n){let r=e.indexOf(`;`,t);return r===-1?n:r}function u(e,t,n){let r=e.indexOf(`=`,t);return r<n?r:-1}function d(e,t,n){let r=t,i=n;do{let t=e.charCodeAt(r);if(t!==32&&t!==9)break}while(++r<i);for(;i>r;){let t=e.charCodeAt(i-1);if(t!==32&&t!==9)break;i--}return e.slice(r,i)}function f(e){if(e.indexOf(`%`)===-1)return e;try{return decodeURIComponent(e)}catch{return e}}function p(e){return a.call(e)===`[object Date]`}})),od=`auth0`,sd=5*365,cd=720*60*60,ld=1440*60,ud=`auth-token`,dd=`last-used-connection`,fd=365*24*60*60,pd=`mfa-remember-browser`,md=1800*1e3,hd=10080*60*1e3,gd=1800*1e3,_d=1800*1e3,vd=1440*60*1e3,yd=`authhero-try-connection-`;function bd(e){return`${yd}${e}`}function xd(e){return e.startsWith(yd)}var Sd=ad();function Cd(e){return`${e}-${ud}`}function wd(e){return`${e}-${dd}`}function Td(e){if(!e)return!1;let t;if(e.startsWith(`[`)){let n=e.indexOf(`]`);if(n===-1)return!1;t=e.slice(1,n)}else t=e.split(`:`)[0]??``;return t?t===`localhost`||t===`host.docker.internal`||t===`::1`||/^127(?:\.\d{1,3}){3}$/.test(t):!1}function Ed(e){if(!e)return;let[t]=e.split(`:`);if(!t||t===`localhost`||/^(\d{1,3}\.){3}\d{1,3}$/.test(t))return;let n=t.split(`.`);return n.length>2?`.${n.slice(-2).join(`.`)}`:`.${t}`}function Dd(e,t){return t?Od(Cd(e),t):[]}function Od(e,t){let n=[],r=t.split(`;`);for(let t of r){let[r,...i]=t.trim().split(`=`);r===e&&i.length>0&&n.push(i.join(`=`))}return n}function kd(e){return`${e}-${pd}`}var Ad=`.`,jd=/^[A-Za-z0-9_-]{43}$/,Md=10;function Nd(e,t){if(!t)return[];let n=[];for(let r of Od(kd(e),t))for(let e of r.split(Ad)){if(n.length>=Md)return n;jd.test(e)&&!n.includes(e)&&n.push(e)}return n}function Pd(e,t,n,r){let i=kd(e),a=Td(r),o={path:`/`,httpOnly:!0,secure:!a,sameSite:a?`lax`:`none`,domain:r?Ed(r):void 0,maxAge:n},s=t.join(Ad);return a?[(0,Sd.serialize)(i,s,o)]:[(0,Sd.serialize)(i,s,o),(0,Sd.serialize)(i,s,{...o,partitioned:!0})]}function Fd(e,t){if(t)return(0,Sd.parse)(t)[Cd(e)]}function Id(e,t){let n=Cd(e),r=Td(t),i={path:`/`,httpOnly:!0,secure:!r,maxAge:0,sameSite:r?`lax`:`none`,domain:t?Ed(t):void 0};return r?[(0,Sd.serialize)(n,``,i)]:[(0,Sd.serialize)(n,``,i),(0,Sd.serialize)(n,``,{...i,partitioned:!0})]}function Ld(e,t,n){let r=Cd(e),i=Td(n),a={path:`/`,httpOnly:!0,secure:!i,sameSite:i?`lax`:`none`,domain:n?Ed(n):void 0,maxAge:cd};return i?[(0,Sd.serialize)(r,t,a)]:[(0,Sd.serialize)(r,t,a),(0,Sd.serialize)(r,t,{...a,partitioned:!0})]}function Rd(e,t,n,r){let i=t.header(`cookie`),a,o=t.header(`referer`);if(o)try{a=new URL(o).host}catch{a=void 0}return{received:n,result:r,cookies:i?i.split(`;`).filter(e=>e.trim()).length:0,last_used:!!Vd(e,i),fetch_site:t.header(`sec-fetch-site`),fetch_dest:t.header(`sec-fetch-dest`),storage_access:t.header(`sec-fetch-storage-access`),referrer:a}}var zd=`authhero-private-browsing`;function Bd(e){if(!e)return;let t=(0,Sd.parse)(e)[zd];if(t===`1`)return!0;if(t===`0`)return!1}function Vd(e,t){if(t)return(0,Sd.parse)(t)[wd(e)]}function Hd(e,t,n){let r=Td(n);return(0,Sd.serialize)(wd(e),t,{path:`/`,httpOnly:!0,secure:!r,sameSite:`lax`,maxAge:fd,domain:n?Ed(n):void 0})}function Ud(e){if(e)return(0,Sd.parse)(e).auth0_session_transfer_token||void 0}function Wd(e){let t={path:`/`,secure:!Td(e),maxAge:0},n=e?Ed(e):void 0,r=[(0,Sd.serialize)($c,``,t)];return n&&r.push((0,Sd.serialize)($c,``,{...t,domain:n})),r}function Gd(){if(typeof globalThis<`u`)return globalThis;if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(typeof global<`u`)return global}function Kd(){let e=Gd();if(e.__xstate__)return e.__xstate__}var qd=e=>{if(typeof window>`u`)return;let t=Kd();t&&t.register(e)},Jd=class{constructor(e){this._process=e,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(e){let t={value:e,next:null};if(this._current){this._last.next=t,this._last=t;return}this._current=t,this._last=t,this._active&&this.flush()}flush(){for(;this._current;){let e=this._current;this._process(e.value),this._current=e.next}this._last=null}},Yd=``,Xd=`#`,Zd=`*`,Qd=`xstate.init`,$d=`xstate.stop`;function ef(e,t){return{type:`xstate.after.${e}.${t}`}}function tf(e,t){return{type:`xstate.done.state.${e}`,output:t}}function nf(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function rf(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function af(e){return{type:Qd,input:e}}function of(e){setTimeout(()=>{throw e})}var sf=typeof Symbol==`function`&&Symbol.observable||`@@observable`;function cf(e,t){let n=uf(e),r=uf(t);return typeof r==`string`?typeof n==`string`?r===n:!1:typeof n==`string`?n in r:Object.keys(n).every(e=>e in r?cf(n[e],r[e]):!1)}function lf(e){if(gf(e))return e;let t=[],n=``;for(let r=0;r<e.length;r++){switch(e.charCodeAt(r)){case 92:n+=e[r+1],r++;continue;case 46:t.push(n),n=``;continue}n+=e[r]}return t.push(n),t}function uf(e){return Wp(e)?e.value:typeof e==`string`?df(lf(e)):e}function df(e){if(e.length===1)return e[0];let t={},n=t;for(let t=0;t<e.length-1;t++)if(t===e.length-2)n[e[t]]=e[t+1];else{let r=n;n={},r[e[t]]=n}return t}function ff(e,t){let n={},r=Object.keys(e);for(let i=0;i<r.length;i++){let a=r[i];n[a]=t(e[a],a,e,i)}return n}function pf(e){return gf(e)?e:[e]}function mf(e){return e===void 0?[]:pf(e)}function hf(e,t,n,r){return typeof e==`function`?e({context:t,event:n,self:r}):e}function gf(e){return Array.isArray(e)}function _f(e){return e.type.startsWith(`xstate.error.actor`)}function vf(e){return pf(e).map(e=>e===void 0||typeof e==`string`?{target:e}:e)}function yf(e){if(!(e===void 0||e===Yd))return mf(e)}function bf(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}function xf(e,t){return`${t}.${e}`}function Sf(e,t){let n=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return e.implementations.actors[t];let[,r,i]=n,a=e.getStateNodeById(i).config.invoke;return(Array.isArray(a)?a[r]:a).src}function Cf(e,t){if(t===e||t===Zd)return!0;if(!t.endsWith(`.*`))return!1;let n=t.split(`.`),r=e.split(`.`);for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t===`*`)return e===n.length-1;if(t!==i)return!1}return!0}function wf(e,t){return`${e.sessionId}.${t}`}var Tf=0;function Ef(e,t){let n=new Map,r=new Map,i=new WeakMap,a=new Set,o={},{clock:s,logger:c}=t,l={schedule:(e,t,n,r,i=Math.random().toString(36).slice(2))=>{let a={source:e,target:t,event:n,delay:r,id:i,startedAt:Date.now()},c=wf(e,i);u._snapshot._scheduledEvents[c]=a,o[c]=s.setTimeout(()=>{delete o[c],delete u._snapshot._scheduledEvents[c],u._relay(e,t,n)},r)},cancel:(e,t)=>{let n=wf(e,t),r=o[n];delete o[n],delete u._snapshot._scheduledEvents[n],r!==void 0&&s.clearTimeout(r)},cancelAll:e=>{for(let t in u._snapshot._scheduledEvents){let n=u._snapshot._scheduledEvents[t];n.source===e&&l.cancel(e,n.id)}}},u={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${Tf++}`,_register:(e,t)=>(n.set(e,t),e),_unregister:e=>{n.delete(e.sessionId);let t=i.get(e);t!==void 0&&(r.delete(t),i.delete(e))},get:e=>r.get(e),getAll:()=>Object.fromEntries(r.entries()),_set:(e,t)=>{let n=r.get(e);if(n&&n!==t)throw Error(`Actor with system ID '${e}' already exists.`);r.set(e,t),i.set(t,e)},inspect:e=>{let t=bf(e);return a.add(t),{unsubscribe(){a.delete(t)}}},_sendInspectionEvent:t=>{if(!a.size)return;let n={...t,rootId:e.sessionId};a.forEach(e=>e.next?.(n))},_relay:(e,t,n)=>{u._sendInspectionEvent({type:`@xstate.event`,sourceRef:e,actorRef:t,event:n}),t._send(n)},scheduler:l,getSnapshot:()=>({_scheduledEvents:{...u._snapshot._scheduledEvents}}),start:()=>{let e=u._snapshot._scheduledEvents;u._snapshot._scheduledEvents={};for(let t in e){let{source:n,target:r,event:i,delay:a,id:o}=e[t];l.schedule(n,r,i,a,o)}},_clock:s,_logger:c};return u}var Df=!1,Of=function(e){return e[e.NotStarted=0]=`NotStarted`,e[e.Running=1]=`Running`,e[e.Stopped=2]=`Stopped`,e}({}),kf={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1},Af=class{constructor(e,t){this.logic=e,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new Jd(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=Of.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];let n={...kf,...t},{clock:r,logger:i,parent:a,syncSnapshot:o,id:s,systemId:c,inspect:l}=n;this.system=a?a.system:Ef(this,{clock:r,logger:i}),l&&!a&&this.system.inspect(bf(l)),this.sessionId=this.system._bookId(),this.id=s??this.sessionId,this.logger=t?.logger??this.system._logger,this.clock=t?.clock??this.system._clock,this._parent=a,this._syncSnapshot=o,this.options=n,this.src=n.src??e,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:e=>{this._deferred.push(e)},system:this.system,stopChild:e=>{if(e._parent!==this)throw Error(`Cannot stop child actor ${e.id} of ${this.id} because it is not a child`);e._stop()},emit:e=>{let t=this.eventListeners.get(e.type),n=this.eventListeners.get(`*`);if(!t&&!n)return;let r=[...t?t.values():[],...n?n.values():[]];for(let t of r)try{t(e)}catch(e){of(e)}},actionExecutor:e=>{let t=()=>{if(this._actorScope.system._sendInspectionEvent({type:`@xstate.action`,actorRef:this,action:{type:e.type,params:e.params}}),!e.exec)return;let t=Df;try{Df=!0,e.exec(e.info,e.params)}finally{Df=t}};this._processingStatus===Of.Running?t():this._deferred.push(t)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:`@xstate.actor`,actorRef:this}),c&&(this.systemId=c,this.system._set(c,this)),this._initState(t?.snapshot??t?.state),c&&this._snapshot.status!==`active`&&this.system._unregister(this)}_initState(e){try{this._snapshot=e?this.logic.restoreSnapshot?this.logic.restoreSnapshot(e,this._actorScope):e:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(e){this._snapshot={status:`error`,output:void 0,error:e}}}update(e,t){this._snapshot=e;let n;for(;n=this._deferred.shift();)try{n()}catch(t){this._deferred.length=0,this._snapshot={...e,status:`error`,error:t}}switch(this._snapshot.status){case`active`:for(let t of this.observers)try{t.next?.(e)}catch(e){of(e)}break;case`done`:for(let t of this.observers)try{t.next?.(e)}catch(e){of(e)}this._stopProcedure(),this._complete(),this._doneEvent=nf(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case`error`:this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:`@xstate.snapshot`,actorRef:this,event:t,snapshot:e})}subscribe(e,t,n){let r=bf(e,t,n);if(this._processingStatus!==Of.Stopped)this.observers.add(r);else switch(this._snapshot.status){case`done`:try{r.complete?.()}catch(e){of(e)}break;case`error`:{let e=this._snapshot.error;if(!r.error)of(e);else try{r.error(e)}catch(e){of(e)}break}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(e,t){let n=this.eventListeners.get(e);n||(n=new Set,this.eventListeners.set(e,n));let r=t.bind(void 0);return n.add(r),{unsubscribe:()=>{n.delete(r)}}}select(e,t=Object.is){return{subscribe:n=>{let r=bf(n),i=e(this.getSnapshot());return this.subscribe(n=>{let a=e(n);t(i,a)||(i=a,r.next?.(a))})},get:()=>e(this.getSnapshot())}}start(){if(this._processingStatus===Of.Running)return this;this._syncSnapshot&&this.subscribe({next:e=>{e.status===`active`&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:e})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=Of.Running;let e=af(this.options.input);switch(this.system._sendInspectionEvent({type:`@xstate.event`,sourceRef:this._parent,actorRef:this,event:e}),this._snapshot.status){case`done`:return this.update(this._snapshot,e),this;case`error`:return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(e){return this._snapshot={...this._snapshot,status:`error`,error:e},this._error(e),this}return this.update(this._snapshot,e),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(e){let t,n;try{t=this.logic.transition(this._snapshot,e,this._actorScope)}catch(e){n={err:e}}if(n){let{err:e}=n;this._snapshot={...this._snapshot,status:`error`,error:e},this._error(e);return}this.update(t,e),e.type===`xstate.stop`&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===Of.Stopped?this:(this.mailbox.clear(),this._processingStatus===Of.NotStarted?(this._processingStatus=Of.Stopped,this):(this.mailbox.enqueue({type:$d}),this))}stop(){if(this._parent)throw Error(`A non-root actor cannot be stopped directly.`);return this._stop()}_complete(){for(let e of this.observers)try{e.complete?.()}catch(e){of(e)}this.observers.clear(),this.eventListeners.clear()}_reportError(e){if(!this.observers.size){this._parent||of(e),this.eventListeners.clear();return}let t=!1;for(let n of this.observers){let r=n.error;t||=!r;try{r?.(e)}catch(e){of(e)}}this.observers.clear(),this.eventListeners.clear(),t&&of(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,rf(this.id,e))}_stopProcedure(){return this._processingStatus===Of.Running?(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new Jd(this._process.bind(this)),this._processingStatus=Of.Stopped,this.system._unregister(this),this):this}_send(e){this._processingStatus!==Of.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}attachDevTools(){let{devTools:e}=this.options;e&&(typeof e==`function`?e:qd)(this)}toJSON(){return{xstate$$type:1,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[sf](){return this}getSnapshot(){return this._snapshot}};function jf(e,...[t]){return new Af(e,t)}function Mf(e,t,n,r,{sendId:i}){return[t,{sendId:typeof i==`function`?i(n,r):i},void 0]}function Nf(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function Pf(e){function t(e,t){}return t.type=`xstate.cancel`,t.sendId=e,t.resolve=Mf,t.execute=Nf,t}function Ff(e,t,n,r,{id:i,systemId:a,src:o,input:s,syncSnapshot:c}){let l=typeof o==`string`?Sf(t.machine,o):o,u=typeof i==`function`?i(n):i,d,f;return l&&(f=typeof s==`function`?s({context:t.context,event:n.event,self:e.self}):s,d=jf(l,{id:u,src:o,parent:e.self,syncSnapshot:c,systemId:a,input:f})),[Zp(t,{children:{...t.children,[u]:d}}),{id:i,systemId:a,actorRef:d,src:o,input:f},void 0]}function If(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==Of.Stopped&&t.start()})}function Lf(...[e,{id:t,systemId:n,input:r,syncSnapshot:i=!1}={}]){function a(e,t){}return a.type=`xstate.spawnChild`,a.id=t,a.systemId=n,a.src=e,a.input=r,a.syncSnapshot=i,a.resolve=Ff,a.execute=If,a}function Rf(e,t,n,r,{actorRef:i}){let a=typeof i==`function`?i(n,r):i,o=typeof a==`string`?t.children[a]:a,s=t.children;return o&&(s={...s},delete s[o.id]),[Zp(t,{children:s}),o,void 0]}function zf(e,t){let n=t.getSnapshot();if(n&&`children`in n)for(let t of Object.values(n.children))zf(e,t);e.system._unregister(t)}function Bf(e,t){if(t){if(zf(e,t),t._processingStatus!==Of.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function Vf(e){function t(e,t){}return t.type=`xstate.stopChild`,t.actorRef=e,t.resolve=Rf,t.execute=Bf,t}function Hf(e,{context:t,event:n},{guards:r}){return r.every(r=>Wf(r,t,n,e))}function Uf(e){function t(e,t){return!1}return t.check=Hf,t.guards=e,t}function Wf(e,t,n,r){let{machine:i}=r,a=typeof e==`function`,o=a?e:i.implementations.guards[typeof e==`string`?e:e.type];if(!a&&!o)throw Error(`Guard '${typeof e==`string`?e:e.type}' is not implemented.'.`);if(typeof o!=`function`)return Wf(o,t,n,r);let s={context:t,event:n},c=a||typeof e==`string`?void 0:`params`in e?typeof e.params==`function`?e.params({context:t,event:n}):e.params:void 0;return`check`in o?o.check(r,s,o):o(s,c)}function Gf(e){return e.type===`atomic`||e.type===`final`}function Kf(e){return Object.values(e.states).filter(e=>e.type!==`history`)}function qf(e,t){let n=[];if(t===e)return n;let r=e.parent;for(;r&&r!==t;)n.push(r),r=r.parent;return n}function Jf(e){let t=new Set(e),n=Xf(t);for(let e of t)if(e.type===`compound`&&(!n.get(e)||!n.get(e).length))lp(e).forEach(e=>t.add(e));else if(e.type===`parallel`){for(let n of Kf(e))if(n.type!==`history`&&!t.has(n)){let e=lp(n);for(let n of e)t.add(n)}}for(let e of t){let n=e.parent;for(;n;)t.add(n),n=n.parent}return t}function Yf(e,t){let n=t.get(e);if(!n)return{};if(e.type===`compound`){let e=n[0];if(e){if(Gf(e))return e.key}else return{}}let r={};for(let e of n)r[e.key]=Yf(e,t);return r}function Xf(e){let t=new Map;for(let n of e)t.has(n)||t.set(n,[]),n.parent&&(t.has(n.parent)||t.set(n.parent,[]),t.get(n.parent).push(n));return t}function Zf(e,t){return Yf(e,Xf(Jf(t)))}function Qf(e,t){return t.type===`compound`?Kf(t).some(t=>t.type===`final`&&e.has(t)):t.type===`parallel`?Kf(t).every(t=>Qf(e,t)):t.type===`final`}var $f=e=>e[0]===Xd;function ep(e,t){return e.transitions.get(t)||[...e.transitions.keys()].filter(e=>Cf(t,e)).sort((e,t)=>t.length-e.length).flatMap(t=>e.transitions.get(t))}function tp(e){let t=e.config.after;if(!t)return[];let n=t=>{let n=ef(t,e.id),r=n.type;return e.entry.push(rm(n,{id:r,delay:t})),e.exit.push(Pf(r)),r};return Object.keys(t).flatMap(e=>{let r=t[e],i=typeof r==`string`?{target:r}:r,a=Number.isNaN(+e)?e:+e,o=n(a);return mf(i).map(e=>({...e,event:o,delay:a}))}).map(t=>{let{delay:n}=t;return{...np(e,t.event,t),delay:n}})}function np(e,t,n){let r=yf(n.target),i=n.reenter??!1,a=op(e,r),o={...n,actions:mf(n.actions),guard:n.guard,target:a,source:e,reenter:i,eventType:t,toJSON:()=>({...o,source:`#${e.id}`,target:a?a.map(e=>`#${e.id}`):void 0})};return o}function rp(e){let t=new Map;if(e.config.on)for(let n of Object.keys(e.config.on)){if(n===``)throw Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let r=e.config.on[n];t.set(n,vf(r).map(t=>np(e,n,t)))}if(e.config.onDone){let n=`xstate.done.state.${e.id}`;t.set(n,vf(e.config.onDone).map(t=>np(e,n,t)))}for(let n of e.invoke){if(n.onDone){let r=`xstate.done.actor.${n.id}`;t.set(r,vf(n.onDone).map(t=>np(e,r,t)))}if(n.onError){let r=`xstate.error.actor.${n.id}`;t.set(r,vf(n.onError).map(t=>np(e,r,t)))}if(n.onSnapshot){let r=`xstate.snapshot.${n.id}`;t.set(r,vf(n.onSnapshot).map(t=>np(e,r,t)))}}for(let n of e.after){let e=t.get(n.eventType);e||(e=[],t.set(n.eventType,e)),e.push(n)}return t}function ip(e){let t=[],n=r=>{Object.values(r).forEach(r=>{if(r.config.route&&r.config.id){let n=r.config.id,i=r.config.route.guard,a=({event:e})=>e.to===`#${n}`,o={...r.config.route,guard:i?Uf([a,i]):a,target:`#${n}`};t.push(np(e,`xstate.route`,o))}r.states&&n(r.states)})};n(e.states),t.length>0&&e.transitions.set(`xstate.route`,t)}function ap(e,t){let n=typeof t==`string`?e.states[t]:t?e.states[t.target]:void 0;if(!n&&t)throw Error(`Initial state node "${t}" not found on parent state node #${e.id}`);let r={source:e,actions:!t||typeof t==`string`?[]:mf(t.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...r,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return r}function op(e,t){if(t!==void 0)return t.map(t=>{if(typeof t!=`string`)return t;if($f(t))return e.machine.getStateNodeById(t);let n=t[0]===`.`;if(n&&!e.parent)return fp(e,t.slice(1));let r=n?e.key+t:t;if(e.parent)try{return fp(e.parent,r)}catch(t){throw Error(`Invalid transition definition for state node '${e.id}':\n${t.message}`)}else throw Error(`Invalid target: "${t}" is not a valid target from the root node. Did you mean ".${t}"?`)})}function sp(e){let t=yf(e.config.target);return t?{target:t.map(t=>typeof t==`string`?fp(e.parent,t):t)}:e.parent.initial}function cp(e){return e.type===`history`}function lp(e){let t=up(e);for(let n of t)for(let r of qf(n,e))t.add(r);return t}function up(e){let t=new Set;function n(e){if(!t.has(e)){if(t.add(e),e.type===`compound`)n(e.initial.target[0]);else if(e.type===`parallel`)for(let t of Kf(e))n(t)}}return n(e),t}function dp(e,t){if($f(t))return e.machine.getStateNodeById(t);if(!e.states)throw Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);let n=e.states[t];if(!n)throw Error(`Child state '${t}' does not exist on '${e.id}'`);return n}function fp(e,t){if(typeof t==`string`&&$f(t))try{return e.machine.getStateNodeById(t)}catch{}let n=lf(t).slice(),r=e;for(;n.length;){let e=n.shift();if(!e.length)break;r=dp(r,e)}return r}function pp(e,t){if(typeof t==`string`){let n=e.states[t];if(!n)throw Error(`State '${t}' does not exist on '${e.id}'`);return[e,n]}let n=Object.keys(t),r=n.map(t=>dp(e,t)).filter(Boolean);return[e.machine.root,e].concat(r,n.reduce((n,r)=>{let i=dp(e,r);if(!i)return n;let a=pp(i,t[r]);return n.concat(a)},[]))}function mp(e,t,n,r){let i=dp(e,t).next(n,r);return!i||!i.length?e.next(n,r):i}function hp(e,t,n,r){let i=Object.keys(t),a=_p(dp(e,i[0]),t[i[0]],n,r);return!a||!a.length?e.next(n,r):a}function gp(e,t,n,r){let i=[];for(let a of Object.keys(t)){let o=t[a];if(!o)continue;let s=_p(dp(e,a),o,n,r);s&&i.push(...s)}return i.length?i:e.next(n,r)}function _p(e,t,n,r){return typeof t==`string`?mp(e,t,n,r):Object.keys(t).length===1?hp(e,t,n,r):gp(e,t,n,r)}function vp(e){return Object.keys(e.states).map(t=>e.states[t]).filter(e=>e.type===`history`)}function yp(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function bp(e,t){let n=new Set(e),r=new Set(t);for(let e of n)if(r.has(e))return!0;for(let e of r)if(n.has(e))return!0;return!1}function xp(e,t,n){let r=new Set;for(let i of e){let e=!1,a=new Set;for(let o of r)if(bp(Tp([i],t,n),Tp([o],t,n)))if(yp(i.source,o.source))a.add(o);else{e=!0;break}if(!e){for(let e of a)r.delete(e);r.add(i)}}return Array.from(r)}function Sp(e){let[t,...n]=e;for(let e of qf(t,void 0))if(n.every(t=>yp(t,e)))return e}function Cp(e,t){if(!e.target)return[];let n=new Set;for(let r of e.target)if(cp(r))if(t[r.id])for(let e of t[r.id])n.add(e);else for(let e of Cp(sp(r),t))n.add(e);else n.add(r);return[...n]}function wp(e,t){let n=Cp(e,t);if(!n)return;if(!e.reenter&&n.every(t=>t===e.source||yp(t,e.source)))return e.source;let r=Sp(n.concat(e.source));if(r)return r;if(!e.reenter)return e.source.machine.root}function Tp(e,t,n){let r=new Set;for(let i of e)if(i.target?.length){let e=wp(i,n);i.reenter&&i.source===e&&r.add(e);for(let n of t)yp(n,e)&&r.add(n)}return[...r]}function Ep(e,t){if(e.length!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Dp(e,t,n,r,i){return Op([{target:[...up(e)],source:e,reenter:!0,actions:[],eventType:null,toJSON:null}],t,n,r,!0,i)}function Op(e,t,n,r,i,a){let o=[];if(!e.length)return[t,o];let s=n.actionExecutor;n.actionExecutor=e=>{o.push(e),s(e)};try{let s=new Set(t._nodes),c=t.historyValue,l=xp(e,s,c),u=t;i||([u,c]=Fp(u,r,n,l,s,c,a,n.actionExecutor)),u=Rp(u,r,n,l.flatMap(e=>e.actions),a,void 0),u=Ap(u,r,n,l,s,a,c,i);let d=[...s];u.status===`done`&&(u=Rp(u,r,n,d.sort((e,t)=>t.order-e.order).flatMap(e=>e.exit),a,void 0));try{return c===t.historyValue&&Ep(t._nodes,s)?[u,o]:[Zp(u,{_nodes:d,historyValue:c}),o]}catch(e){throw e}}finally{n.actionExecutor=s}}function kp(e,t,n,r,i){if(r.output===void 0)return;let a=tf(i.id,i.output!==void 0&&i.parent?hf(i.output,e.context,t,n.self):void 0);return hf(r.output,e.context,a,n.self)}function Ap(e,t,n,r,i,a,o,s){let c=e,l=new Set,u=new Set;jp(r,o,u,l),s&&u.add(e.machine.root);let d=new Set;for(let e of[...l].sort((e,t)=>e.order-t.order)){i.add(e);let r=[];r.push(...e.entry);for(let t of e.invoke)r.push(Lf(t.src,{...t,syncSnapshot:!!t.onSnapshot}));if(u.has(e)){let t=e.initial.actions;r.push(...t)}if(c=Rp(c,t,n,r,a,e.invoke.map(e=>e.id)),e.type===`final`){let r=e.parent,o=r?.type===`parallel`?r:r?.parent,s=o||e;for(r?.type===`compound`&&a.push(tf(r.id,e.output===void 0?void 0:hf(e.output,c.context,t,n.self)));o?.type===`parallel`&&!d.has(o)&&Qf(i,o);)d.add(o),a.push(tf(o.id)),s=o,o=o.parent;if(o)continue;c=Zp(c,{status:`done`,output:kp(c,t,n,c.machine.root,s)})}}return c}function jp(e,t,n,r){for(let i of e){let e=wp(i,t);for(let a of i.target||[])!cp(a)&&(i.source!==a||i.source!==e||i.reenter)&&(r.add(a),n.add(a)),Mp(a,t,n,r);let a=Cp(i,t);for(let o of a){let a=qf(o,e);e?.type===`parallel`&&a.push(e),Np(r,t,n,a,!i.source.parent&&i.reenter?void 0:e)}}}function Mp(e,t,n,r){if(cp(e))if(t[e.id]){let i=t[e.id];for(let e of i)r.add(e),Mp(e,t,n,r);for(let a of i)Pp(a,e.parent,r,t,n)}else{let i=sp(e);for(let a of i.target)r.add(a),i===e.parent?.initial&&n.add(e.parent),Mp(a,t,n,r);for(let a of i.target)Pp(a,e.parent,r,t,n)}else if(e.type===`compound`){let[i]=e.initial.target;cp(i)||(r.add(i),n.add(i)),Mp(i,t,n,r),Pp(i,e,r,t,n)}else if(e.type===`parallel`)for(let i of Kf(e).filter(e=>!cp(e)))[...r].some(e=>yp(e,i))||(cp(i)||(r.add(i),n.add(i)),Mp(i,t,n,r))}function Np(e,t,n,r,i){for(let a of r)if((!i||yp(a,i))&&e.add(a),a.type===`parallel`)for(let r of Kf(a).filter(e=>!cp(e)))[...e].some(e=>yp(e,r))||(e.add(r),Mp(r,t,n,e))}function Pp(e,t,n,r,i){Np(n,r,i,qf(e,t))}function Fp(e,t,n,r,i,a,o,s){let c=e,l=Tp(r,i,a);l.sort((e,t)=>t.order-e.order);let u;for(let e of l)for(let t of vp(e)){let n;n=t.history===`deep`?t=>Gf(t)&&yp(t,e):t=>t.parent===e,u??={...a},u[t.id]=Array.from(i).filter(n)}for(let e of l)c=Rp(c,t,n,[...e.exit,...e.invoke.map(e=>Vf(e.id))],o,void 0),i.delete(e);return[c,u||a]}function Ip(e,t){return e.implementations.actions[t]}function Lp(e,t,n,r,i,a){let{machine:o}=e,s=e;for(let e of r){let r=typeof e==`function`,c=r?e:Ip(o,typeof e==`string`?e:e.type),l={context:s.context,event:t,self:n.self,system:n.system},u=r||typeof e==`string`?void 0:`params`in e?typeof e.params==`function`?e.params({context:s.context,event:t}):e.params:void 0;if(!c||!(`resolve`in c)){n.actionExecutor({type:typeof e==`string`?e:typeof e==`object`?e.type:e.name||`(anonymous)`,info:l,params:u,exec:c});continue}let d=c,[f,p,m]=d.resolve(n,s,l,u,c,i);s=f,`retryResolve`in d&&a?.push([d,p]),`execute`in d&&n.actionExecutor({type:d.type,info:l,params:p,exec:d.execute.bind(null,n,p)}),m&&(s=Lp(s,t,n,m,i,a))}return s}function Rp(e,t,n,r,i,a){let o=a?[]:void 0,s=Lp(e,t,n,r,{internalQueue:i,deferredActorIds:a},o);return o?.forEach(([e,t])=>{e.retryResolve(n,s,t)}),s}function zp(e,t,n,r){let i=e,a=[];function o(e,t,r){n.system._sendInspectionEvent({type:`@xstate.microstep`,actorRef:n.self,event:t,snapshot:e[0],_transitions:r}),a.push(e)}if(t.type===`xstate.stop`)return i=Zp(Bp(i,t,n),{status:`stopped`}),o([i,[]],t,[]),{snapshot:i,microsteps:a};let s=t;if(s.type!==Qd){let t=s,c=_f(t),l=Vp(t,i);if(c&&!l.length)return i=Zp(e,{status:`error`,error:t.error}),o([i,[]],t,[]),{snapshot:i,microsteps:a};let u=Op(l,e,n,s,!1,r);i=u[0],o(u,t,l)}let c=!0,l=e.machine.options?.maxIterations??1/0,u=0;for(;i.status===`active`;){if(u++,u>l)throw Error(`Infinite loop detected: the machine has processed more than ${l} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let e=c?Hp(i,s):[],t=e.length?i:void 0;if(!e.length){if(!r.length)break;s=r.shift(),e=Vp(s,i)}let a=Op(e,i,n,s,!1,r);i=a[0],c=i!==t,o(a,s,e)}return i.status!==`active`&&Bp(i,s,n),{snapshot:i,microsteps:a}}function Bp(e,t,n){return Rp(e,t,n,Object.values(e.children).map(e=>Vf(e)),[],void 0)}function Vp(e,t){return t.machine.getTransitionData(t,e)}function Hp(e,t){let n=new Set,r=e._nodes.filter(Gf);for(let i of r)loop:for(let r of[i].concat(qf(i,void 0)))if(r.always){for(let i of r.always)if(i.guard===void 0||Wf(i.guard,e.context,t,e)){n.add(i);break loop}}return xp(Array.from(n),new Set(e._nodes),e.historyValue)}function Up(e,t){return Zf(e,[...Jf(pp(e,t))])}function Wp(e){return!!e&&typeof e==`object`&&`machine`in e&&`value`in e}var Gp=function(e){return cf(e,this.value)},Kp=function(e){return this.tags.has(e)},qp=function(e){let t=this.machine.getTransitionData(this,e);return!!t?.length&&t.some(e=>e.target!==void 0||e.actions.length)},Jp=function(){let{_nodes:e,tags:t,machine:n,getMeta:r,toJSON:i,can:a,hasTag:o,matches:s,...c}=this;return{...c,tags:Array.from(t)}},Yp=function(){return this._nodes.reduce((e,t)=>(t.meta!==void 0&&(e[t.id]=t.meta),e),{})};function Xp(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:Zf(t.root,e._nodes),tags:new Set(e._nodes.flatMap(e=>e.tags)),children:e.children,historyValue:e.historyValue||{},matches:Gp,hasTag:Kp,can:qp,getMeta:Yp,toJSON:Jp}}function Zp(e,t={}){return Xp({...e,...t},e.machine)}function Qp(e){if(typeof e!=`object`||!e)return{};let t={};for(let n in e){let r=e[n];Array.isArray(r)&&(t[n]=r.map(e=>({id:e.id})))}return t}function $p(e,t){let{_nodes:n,tags:r,machine:i,children:a,context:o,can:s,hasTag:c,matches:l,getMeta:u,toJSON:d,...f}=e,p={};for(let e in a){let n=a[e];p[e]={snapshot:n.getPersistedSnapshot(t),src:n.src,systemId:n.systemId,syncSnapshot:n._syncSnapshot}}return{...f,context:em(o),children:p,historyValue:Qp(f.historyValue)}}function em(e){let t;for(let n in e){let r=e[n];if(r&&typeof r==`object`)if(`sessionId`in r&&`send`in r&&`ref`in r)t??=Array.isArray(e)?e.slice():{...e},t[n]={xstate$$type:1,id:r.id};else{let i=em(r);i!==r&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=i)}}return t??e}function tm(e,t,n,r,{event:i,id:a,delay:o},{internalQueue:s}){let c=t.machine.implementations.delays;if(typeof i==`string`)throw Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);let l=typeof i==`function`?i(n,r):i,u;if(typeof o==`string`){let e=c&&c[o];u=typeof e==`function`?e(n,r):e}else u=typeof o==`function`?o(n,r):o;return typeof u!=`number`&&s.push(l),[t,{event:l,id:a,delay:u},void 0]}function nm(e,t){let{event:n,delay:r,id:i}=t;if(typeof r==`number`){e.defer(()=>{let t=e.self;e.system.scheduler.schedule(t,t,n,r,i)});return}}function rm(e,t){function n(e,t){}return n.type=`xstate.raise`,n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=tm,n.execute=nm,n}function im(e,{machine:t,context:n},r,i){let a=(a,o)=>{if(typeof a==`string`){let s=Sf(t,a);if(!s)throw Error(`Actor logic '${a}' not implemented in machine '${t.id}'`);let c=jf(s,{id:o?.id,parent:e.self,syncSnapshot:o?.syncSnapshot,input:typeof o?.input==`function`?o.input({context:n,event:r,self:e.self}):o?.input,src:a,systemId:o?.systemId});return i[c.id]=c,c}else return jf(a,{id:o?.id,parent:e.self,syncSnapshot:o?.syncSnapshot,input:o?.input,src:a,systemId:o?.systemId})};return(t,n)=>{let r=a(t,n);return i[r.id]=r,e.defer(()=>{r._processingStatus!==Of.Stopped&&r.start()}),r}}function am(e,t,n,r,{assignment:i}){if(!t.context)throw Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let a={},o={context:t.context,event:n.event,spawn:im(e,t,n.event,a),self:e.self,system:e.system},s={};if(typeof i==`function`)s=i(o,r);else for(let e of Object.keys(i)){let t=i[e];s[e]=typeof t==`function`?t(o,r):t}return[Zp(t,{context:Object.assign({},t.context,s),children:Object.keys(a).length?{...t.children,...a}:t.children}),void 0,void 0]}function om(e){function t(e,t){}return t.type=`xstate.assign`,t.assignment=e,t.resolve=am,t}var sm=new WeakMap;function cm(e,t,n){let r=sm.get(e);return r?t in r||(r[t]=n()):(r={[t]:n()},sm.set(e,r)),r[t]}var lm={},um=e=>typeof e==`string`?{type:e}:typeof e==`function`?`resolve`in e?{type:e.type}:{type:e.name}:e,dm=class e{constructor(t,n){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(`.`),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?`compound`:this.config.history?`history`:`atomic`),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?ff(this.config.states,(t,n)=>new e(t,{_parent:this,_key:n,_machine:this.machine})):lm,this.type===`compound`&&!this.config.initial)throw Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?`shallow`:this.config.history||!1,this.entry=mf(this.config.entry).slice(),this.exit=mf(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type===`final`||!this.parent?this.config.output:void 0,this.tags=mf(t.tags).slice()}_initialize(){this.transitions=rp(this),this.config.always&&(this.always=vf(this.config.always).map(e=>np(this,``,e))),Object.keys(this.states).forEach(e=>{this.states[e]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(um),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(e=>`#${e.id}`),source:`#${this.id}`,actions:this.initial.actions.map(um),eventType:null})}:void 0,history:this.history,states:ff(this.states,e=>e.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(e=>({...e,actions:e.actions.map(um)})),entry:this.entry.map(um),exit:this.exit.map(um),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return cm(this,`invoke`,()=>mf(this.config.invoke).map((e,t)=>{let{src:n,systemId:r}=e,i=e.id??xf(this.id,t),a=typeof n==`string`?n:`xstate.invoke.${xf(this.id,t)}`;return{...e,src:a,id:i,systemId:r,toJSON(){let{onDone:t,onError:n,...r}=e;return{...r,type:`xstate.invoke`,src:a,id:i}}}}))}get on(){return cm(this,`on`,()=>[...this.transitions].flatMap(([e,t])=>t.map(t=>[e,t])).reduce((e,[t,n])=>(e[t]=e[t]||[],e[t].push(n),e),{}))}get after(){return cm(this,`delayedTransitions`,()=>tp(this))}get initial(){return cm(this,`initial`,()=>ap(this,this.config.initial))}next(e,t){let n=t.type,r=[],i,a=cm(this,`candidates-${n}`,()=>ep(this,n));for(let o of a){let{guard:a}=o,s=e.context,c=!1;try{c=!a||Wf(a,s,t,e)}catch(e){let t=typeof a==`string`?a:typeof a==`object`?a.type:void 0;throw Error(`Unable to evaluate guard ${t?`'${t}' `:``}in transition for event '${n}' in state node '${this.id}':\n${e.message}`)}if(c){r.push(...o.actions),i=o;break}}return i?[i]:void 0}get events(){return cm(this,`events`,()=>{let{states:e}=this,t=new Set(this.ownEvents);if(e)for(let n of Object.keys(e)){let r=e[n];if(r.states)for(let e of r.events)t.add(`${e}`)}return Array.from(t)})}get ownEvents(){let e=Object.keys(Object.fromEntries(this.transitions)),t=new Set(e.filter(e=>this.transitions.get(e).some(e=>!(!e.target&&!e.actions.length&&!e.reenter))));return Array.from(t)}},fm=class e{constructor(e,t){this.config=e,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=e.id||`(machine)`,this.implementations={actors:t?.actors??{},actions:t?.actions??{},delays:t?.delays??{},guards:t?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new dm(e,{_key:this.id,_machine:this}),this.root._initialize(),ip(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:n,guards:r,actors:i,delays:a}=this.implementations;return new e(this.config,{actions:{...n,...t.actions},guards:{...r,...t.guards},actors:{...i,...t.actors},delays:{...a,...t.delays}})}resolveState(e){let t=Up(this.root,e.value),n=Jf(pp(this.root,t));return Xp({_nodes:[...n],context:e.context||{},children:{},status:Qf(n,this.root)?`done`:e.status||`active`,output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,t,n){return zp(e,t,n,[]).snapshot}microstep(e,t,n){return zp(e,t,n,[]).microsteps.map(([e])=>e)}getTransitionData(e,t){return _p(this.root,e.value,e,t)||[]}_getPreInitialState(e,t,n){let{context:r}=this.config,i=Xp({context:typeof r!=`function`&&r?r:{},_nodes:[this.root],children:{},status:`active`},this);return typeof r==`function`?Rp(i,t,e,[om(({spawn:e,event:t,self:n})=>r({spawn:e,input:t.input,self:n}))],n,void 0):i}getInitialSnapshot(e,t){let n=af(t),r=[],i=this._getPreInitialState(e,n,r),[a]=Dp(this.root,i,e,n,r),{snapshot:o}=zp(a,n,e,r);return o}start(e){Object.values(e.children).forEach(e=>{e.getSnapshot().status===`active`&&e.start()})}getStateNodeById(e){let t=lf(e),n=t.slice(1),r=$f(t[0])?t[0].slice(1):t[0],i=this.idMap.get(r);if(!i)throw Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);return fp(i,n)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,t){return $p(e,t)}restoreSnapshot(e,t){let n={},r=e.children;Object.keys(r).forEach(e=>{let i=r[e],a=i.snapshot,o=i.src,s=typeof o==`string`?Sf(this,o):o;s&&(n[e]=jf(s,{id:e,parent:t.self,syncSnapshot:i.syncSnapshot,snapshot:a,src:o,systemId:i.systemId}))});function i(e,t){if(t instanceof dm)return t;try{return e.machine.getStateNodeById(t.id)}catch{}}function a(e,t){if(!t||typeof t!=`object`)return{};let n={};for(let r in t){let a=t[r];for(let t of a){let a=i(e,t);a&&(n[r]??=[],n[r].push(a))}}return n}let o=a(this.root,e.historyValue),s=Xp({...e,children:n,_nodes:Array.from(Jf(pp(this.root,e.value))),historyValue:o},this),c=new Set;function l(e,t){if(!c.has(e)){c.add(e);for(let n in e){let r=e[n];if(r&&typeof r==`object`){if(`xstate$$type`in r&&r.xstate$$type===1){e[n]=t[r.id];continue}l(r,t)}}}}return l(s.context,n),s}};function pm(e,t,n,r,{event:i}){return[t,{event:typeof i==`function`?i(n,r):i},void 0]}function mm(e,{event:t}){e.defer(()=>e.emit(t))}function hm(e){function t(e,t){}return t.type=`xstate.emit`,t.event=e,t.resolve=pm,t.execute=mm,t}var gm=function(e){return e.Parent=`#_parent`,e.Internal=`#_internal`,e}({});function _m(e,t,n,r,{to:i,event:a,id:o,delay:s},c){let l=t.machine.implementations.delays;if(typeof a==`string`)throw Error(`Only event objects may be used with sendTo; use sendTo({ type: "${a}" }) instead`);let u=typeof a==`function`?a(n,r):a,d;if(typeof s==`string`){let e=l&&l[s];d=typeof e==`function`?e(n,r):e}else d=typeof s==`function`?s(n,r):s;let f=typeof i==`function`?i(n,r):i,p;if(typeof f==`string`){if(p=f===gm.Parent?e.self._parent:f===gm.Internal?e.self:f.startsWith(`#_`)?t.children[f.slice(2)]:c.deferredActorIds?.includes(f)?f:t.children[f],!p)throw Error(`Unable to send event to actor '${f}' from machine '${t.machine.id}'.`)}else p=f||e.self;return[t,{to:p,targetId:typeof f==`string`?f:void 0,event:u,id:o,delay:d},void 0]}function vm(e,t,n){typeof n.to==`string`&&(n.to=t.children[n.to])}function ym(e,t){e.defer(()=>{let{to:n,event:r,delay:i,id:a}=t;if(typeof i==`number`){e.system.scheduler.schedule(e.self,n,r,i,a);return}e.system._relay(e.self,n,r.type===`xstate.error`?rf(e.self.id,r.data):r)})}function bm(e,t,n){function r(e,t){}return r.type=`xstate.sendTo`,r.to=e,r.event=t,r.id=n?.id,r.delay=n?.delay,r.resolve=_m,r.retryResolve=vm,r.execute=ym,r}function xm(e,t){return bm(gm.Parent,e,t)}function Sm(e,t,n,r,{collect:i}){let a=[],o=function(e){a.push(e)};return o.assign=(...e)=>{a.push(om(...e))},o.cancel=(...e)=>{a.push(Pf(...e))},o.raise=(...e)=>{a.push(rm(...e))},o.sendTo=(...e)=>{a.push(bm(...e))},o.sendParent=(...e)=>{a.push(xm(...e))},o.spawnChild=(...e)=>{a.push(Lf(...e))},o.stopChild=(...e)=>{a.push(Vf(...e))},o.emit=(...e)=>{a.push(hm(...e))},i({context:n.context,event:n.event,enqueue:o,check:e=>Wf(e,t.context,n.event,t),self:e.self,system:e.system},r),[t,void 0,a]}function Cm(e){function t(e,t){}return t.type=`xstate.enqueueActions`,t.collect=e,t.resolve=Sm,t}function wm(e,t,n,r,{value:i,label:a}){return[t,{value:typeof i==`function`?i(n,r):i,label:a},void 0]}function Tm({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function Em(e=({context:e,event:t})=>({context:e,event:t}),t){function n(e,t){}return n.type=`xstate.log`,n.value=e,n.label=t,n.resolve=wm,n.execute=Tm,n}function Dm(e,t){return new fm(e,t)}function Om(e){let t=jf(e);return{self:t,defer:()=>{},id:``,logger:()=>{},sessionId:``,stopChild:()=>{},system:t.system,emit:()=>{},actionExecutor:()=>{}}}function km({schemas:e,actors:t,actions:n,guards:r,delays:i}){return{assign:om,sendTo:bm,raise:rm,log:Em,cancel:Pf,stopChild:Vf,enqueueActions:Cm,emit:hm,spawnChild:Lf,createStateConfig:e=>e,createAction:e=>e,createMachine:a=>Dm({...a,schemas:e},{actors:t,actions:n,guards:r,delays:i}),extend:a=>km({schemas:e,actors:t,actions:{...n,...a.actions},guards:{...r,...a.guards},delays:{...i,...a.delays}})}}function Am(e,t,n){let r=[],i=Om(e);return i.actionExecutor=e=>{r.push(e)},[e.transition(t,n,i),r]}var jm=km({types:{context:{},events:{}},actions:{setUsername:om(({event:e})=>e.type===`COMPLETE`?{}:{username:e.username,requestId:e.requestId})}}).createMachine({id:`passwordReset`,initial:`idle`,context:{},on:{REQUEST_CODE:{target:`.awaiting_code`,actions:`setUsername`},REQUEST_LINK:{target:`.awaiting_link`,actions:`setUsername`}},states:{idle:{},awaiting_code:{on:{COMPLETE:`completed`}},awaiting_link:{on:{COMPLETE:`completed`}},completed:{}}});function Mm(e,t){let[n]=Am(jm,jm.resolveState({value:e?.state??`idle`,context:{username:e?.username,requestId:e?.requestId}}),t);if(!(n.value===`idle`||!n.context.username||!n.context.requestId))return{state:n.value,username:n.context.username,requestId:n.context.requestId}}function Nm(e,t){return!!e&&(t?e.state===`awaiting_${t}`:e.state===`awaiting_code`||e.state===`awaiting_link`)}function Pm(e){if(!e)return{};try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}var j=function(e){return e.PASSWORD_RESET_REQUESTED=`PASSWORD_RESET_REQUESTED`,e.PASSWORD_RESET_COMPLETED=`PASSWORD_RESET_COMPLETED`,e.UPDATE_CONTEXT=`UPDATE_CONTEXT`,e.AUTHENTICATE=`AUTHENTICATE`,e.REQUIRE_EMAIL_VERIFICATION=`REQUIRE_EMAIL_VERIFICATION`,e.REQUIRE_MFA=`REQUIRE_MFA`,e.COMPLETE_MFA=`COMPLETE_MFA`,e.REQUIRE_CONSENT=`REQUIRE_CONSENT`,e.COMPLETE_CONSENT=`COMPLETE_CONSENT`,e.START_HOOK=`START_HOOK`,e.COMPLETE_HOOK=`COMPLETE_HOOK`,e.START_CONTINUATION=`START_CONTINUATION`,e.COMPLETE_CONTINUATION=`COMPLETE_CONTINUATION`,e.COMPLETE=`COMPLETE`,e.FAIL=`FAIL`,e.EXPIRE=`EXPIRE`,e}({}),Fm=km({types:{context:{},events:{}},guards:{passwordResetRequested:({context:e,event:t})=>t.type===`PASSWORD_RESET_COMPLETED`&&Nm(e.stateData?.passwordReset)&&e.stateData.passwordReset.requestId===t.requestId},actions:{requestPasswordReset:om(({context:e,event:t})=>t.type===`PASSWORD_RESET_REQUESTED`?{stateData:{...e.stateData,notice:void 0,passwordReset:Mm(e.stateData?.passwordReset,{type:t.method===`code`?`REQUEST_CODE`:`REQUEST_LINK`,username:t.username,requestId:t.requestId})}}:{}),completePasswordReset:om(({context:e})=>({stateData:{...e.stateData,passwordReset:Mm(e.stateData?.passwordReset,{type:`COMPLETE`}),notice:`password_reset_success`}})),updateContext:om(({context:e,event:t})=>{if(t.type!==`UPDATE_CONTEXT`)return{};let{passwordReset:n,...r}=t.data,i={...e.stateData,...r};for(let e of Object.keys(i))i[e]===void 0&&delete i[e];return{stateData:i}}),setUserId:om(({event:e})=>e.type===`AUTHENTICATE`?{userId:e.userId}:{}),setHookId:om(({event:e})=>e.type===`START_HOOK`?{hookId:e.hookId}:{}),clearHookId:om({hookId:void 0}),setContinuationScope:om(({event:e})=>e.type===`START_CONTINUATION`?{continuationScope:e.scope}:{}),clearContinuationScope:om({continuationScope:void 0}),setFailureReason:om(({event:e})=>e.type===`FAIL`?{failureReason:e.reason}:{})}}).createMachine({id:`loginSession`,initial:`pending`,context:{},states:{pending:{on:{UPDATE_CONTEXT:{actions:`updateContext`},PASSWORD_RESET_REQUESTED:{actions:`requestPasswordReset`},PASSWORD_RESET_COMPLETED:{guard:`passwordResetRequested`,actions:`completePasswordReset`},AUTHENTICATE:{target:`authenticated`,actions:`setUserId`},FAIL:{target:`failed`,actions:`setFailureReason`},EXPIRE:{target:`expired`}}},authenticated:{on:{UPDATE_CONTEXT:{actions:`updateContext`},PASSWORD_RESET_REQUESTED:{actions:`requestPasswordReset`},PASSWORD_RESET_COMPLETED:{guard:`passwordResetRequested`,actions:`completePasswordReset`},REQUIRE_EMAIL_VERIFICATION:{target:`awaiting_email_verification`},REQUIRE_MFA:{target:`awaiting_mfa`},REQUIRE_CONSENT:{target:`awaiting_consent`},START_HOOK:{target:`awaiting_hook`,actions:`setHookId`},START_CONTINUATION:{target:`awaiting_continuation`,actions:`setContinuationScope`},COMPLETE:{target:`completed`},FAIL:{target:`failed`,actions:`setFailureReason`},EXPIRE:{target:`expired`}}},awaiting_email_verification:{on:{UPDATE_CONTEXT:{actions:`updateContext`},PASSWORD_RESET_REQUESTED:{actions:`requestPasswordReset`},PASSWORD_RESET_COMPLETED:{guard:`passwordResetRequested`,actions:`completePasswordReset`},COMPLETE:{target:`authenticated`},FAIL:{target:`failed`,actions:`setFailureReason`},EXPIRE:{target:`expired`}}},awaiting_mfa:{on:{UPDATE_CONTEXT:{actions:`updateContext`},PASSWORD_RESET_REQUESTED:{actions:`requestPasswordReset`},PASSWORD_RESET_COMPLETED:{guard:`passwordResetRequested`,actions:`completePasswordReset`},COMPLETE_MFA:{target:`authenticated`},FAIL:{target:`failed`,actions:`setFailureReason`},EXPIRE:{target:`expired`}}},awaiting_consent:{on:{UPDATE_CONTEXT:{actions:`updateContext`},PASSWORD_RESET_REQUESTED:{actions:`requestPasswordReset`},PASSWORD_RESET_COMPLETED:{guard:`passwordResetRequested`,actions:`completePasswordReset`},COMPLETE_CONSENT:{target:`authenticated`},FAIL:{target:`failed`,actions:`setFailureReason`},EXPIRE:{target:`expired`}}},awaiting_hook:{on:{UPDATE_CONTEXT:{actions:`updateContext`},PASSWORD_RESET_REQUESTED:{actions:`requestPasswordReset`},PASSWORD_RESET_COMPLETED:{guard:`passwordResetRequested`,actions:`completePasswordReset`},COMPLETE_HOOK:{target:`authenticated`,actions:`clearHookId`},START_CONTINUATION:{target:`awaiting_continuation`,actions:`setContinuationScope`},FAIL:{target:`failed`,actions:`setFailureReason`},EXPIRE:{target:`expired`}}},awaiting_continuation:{on:{UPDATE_CONTEXT:{actions:`updateContext`},PASSWORD_RESET_REQUESTED:{actions:`requestPasswordReset`},PASSWORD_RESET_COMPLETED:{guard:`passwordResetRequested`,actions:`completePasswordReset`},COMPLETE_CONTINUATION:{target:`authenticated`,actions:`clearContinuationScope`},FAIL:{target:`failed`,actions:`setFailureReason`},EXPIRE:{target:`expired`}}},completed:{type:`final`},failed:{type:`final`},expired:{type:`final`}}});function Im(e,t={}){return Fm.resolveState({value:e,context:t})}function Lm(e,t,n={}){let[r]=Am(Fm,Im(e,n),t),i={},a=r.context,o=n;return a.stateData!==o.stateData&&(i.stateData=a.stateData),a.userId!==o.userId&&(i.userId=a.userId),a.hookId!==o.hookId&&(i.hookId=a.hookId),a.continuationScope!==o.continuationScope&&(i.continuationScope=a.continuationScope),a.failureReason!==o.failureReason&&(i.failureReason=a.failureReason),{state:r.value,context:i}}function Rm(e,t,n={}){let r;switch(t){case`PASSWORD_RESET_COMPLETED`:r={type:t,requestId:n.stateData?.passwordReset?.requestId??``};break;case`PASSWORD_RESET_REQUESTED`:r={type:t,username:`test@example.com`,requestId:`request`,method:`code`};break;case`UPDATE_CONTEXT`:r={type:t,data:{}};break;case`AUTHENTICATE`:r={type:t,userId:``};break;case`START_CONTINUATION`:r={type:t,scope:[]};break;case`FAIL`:r={type:t,reason:``};break;default:r={type:t}}let i=Im(e,n),[a]=Am(Fm,i,r);return a.value!==e||a.context!==i.context}var zm=s((()=>{var e;(function(e){(function(t){var n=typeof globalThis==`object`?globalThis:typeof global==`object`?global:typeof self==`object`?self:typeof this==`object`?this:s(),r=i(e);n.Reflect!==void 0&&(r=i(n.Reflect,r)),t(r,n),n.Reflect===void 0&&(n.Reflect=e);function i(e,t){return function(n,r){Object.defineProperty(e,n,{configurable:!0,writable:!0,value:r}),t&&t(n,r)}}function a(){try{return Function(`return this;`)()}catch{}}function o(){try{return(0,eval)(`(function() { return this; })()`)}catch{}}function s(){return a()||o()}})(function(e,t){var n=Object.prototype.hasOwnProperty,r=typeof Symbol==`function`,i=r&&Symbol.toPrimitive!==void 0?Symbol.toPrimitive:`@@toPrimitive`,a=r&&Symbol.iterator!==void 0?Symbol.iterator:`@@iterator`,o=typeof Object.create==`function`,s={__proto__:[]}instanceof Array,c=!o&&!s,l={create:o?function(){return Be(Object.create(null))}:s?function(){return Be({__proto__:null})}:function(){return Be({})},has:c?function(e,t){return n.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return n.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),d=typeof Map==`function`&&typeof Map.prototype.entries==`function`?Map:Le(),f=typeof Set==`function`&&typeof Set.prototype.entries==`function`?Set:Re(),p=typeof WeakMap==`function`?WeakMap:ze(),m=r?Symbol.for(`@reflect-metadata:registry`):void 0,h=Ne(),g=Pe(h);function _(e,t,n,r){if(C(n)){if(!xe(e)||!Ce(t))throw TypeError();return ie(e,t)}else{if(!xe(e)||!w(t)||!w(r)&&!C(r)&&!me(r))throw TypeError();return me(r)&&(r=void 0),n=be(n),ae(e,t,n,r)}}e(`decorate`,_);function v(e,t){function n(n,r){if(!w(n)||!C(r)&&!we(r))throw TypeError();ue(e,t,n,r)}return n}e(`metadata`,v);function y(e,t,n,r){if(!w(n))throw TypeError();return C(r)||(r=be(r)),ue(e,t,n,r)}e(`defineMetadata`,y);function b(e,t,n){if(!w(t))throw TypeError();return C(n)||(n=be(n)),oe(e,t,n)}e(`hasMetadata`,b);function x(e,t,n){if(!w(t))throw TypeError();return C(n)||(n=be(n)),se(e,t,n)}e(`hasOwnMetadata`,x);function S(e,t,n){if(!w(t))throw TypeError();return C(n)||(n=be(n)),ce(e,t,n)}e(`getMetadata`,S);function ee(e,t,n){if(!w(t))throw TypeError();return C(n)||(n=be(n)),le(e,t,n)}e(`getOwnMetadata`,ee);function te(e,t){if(!w(e))throw TypeError();return C(t)||(t=be(t)),de(e,t)}e(`getMetadataKeys`,te);function ne(e,t){if(!w(e))throw TypeError();return C(t)||(t=be(t)),fe(e,t)}e(`getOwnMetadataKeys`,ne);function re(e,t,n){if(!w(t)||(C(n)||(n=be(n)),!w(t)))throw TypeError();C(n)||(n=be(n));var r=Ie(t,n,!1);return C(r)?!1:r.OrdinaryDeleteMetadata(e,t,n)}e(`deleteMetadata`,re);function ie(e,t){for(var n=e.length-1;n>=0;--n){var r=e[n],i=r(t);if(!C(i)&&!me(i)){if(!Ce(i))throw TypeError();t=i}}return t}function ae(e,t,n,r){for(var i=e.length-1;i>=0;--i){var a=e[i],o=a(t,n,r);if(!C(o)&&!me(o)){if(!w(o))throw TypeError();r=o}}return r}function oe(e,t,n){if(se(e,t,n))return!0;var r=je(t);return me(r)?!1:oe(e,r,n)}function se(e,t,n){var r=Ie(t,n,!1);return C(r)?!1:ve(r.OrdinaryHasOwnMetadata(e,t,n))}function ce(e,t,n){if(se(e,t,n))return le(e,t,n);var r=je(t);if(!me(r))return ce(e,r,n)}function le(e,t,n){var r=Ie(t,n,!1);if(!C(r))return r.OrdinaryGetOwnMetadata(e,t,n)}function ue(e,t,n,r){Ie(n,r,!0).OrdinaryDefineOwnMetadata(e,t,n,r)}function de(e,t){var n=fe(e,t),r=je(e);if(r===null)return n;var i=de(r,t);if(i.length<=0)return n;if(n.length<=0)return i;for(var a=new f,o=[],s=0,c=n;s<c.length;s++){var l=c[s],u=a.has(l);u||(a.add(l),o.push(l))}for(var d=0,p=i;d<p.length;d++){var l=p[d],u=a.has(l);u||(a.add(l),o.push(l))}return o}function fe(e,t){var n=Ie(e,t,!1);return n?n.OrdinaryOwnMetadataKeys(e,t):[]}function pe(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 C(e){return e===void 0}function me(e){return e===null}function he(e){return typeof e==`symbol`}function w(e){return typeof e==`object`?e!==null:typeof e==`function`}function ge(e,t){switch(pe(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 n=t===3?`string`:t===5?`number`:`default`,r=Ee(e,i);if(r!==void 0){var a=r.call(e,n);if(w(a))throw TypeError();return a}return _e(e,n===`default`?`number`:n)}function _e(e,t){if(t===`string`){var n=e.toString;if(Se(n)){var r=n.call(e);if(!w(r))return r}var i=e.valueOf;if(Se(i)){var r=i.call(e);if(!w(r))return r}}else{var i=e.valueOf;if(Se(i)){var r=i.call(e);if(!w(r))return r}var a=e.toString;if(Se(a)){var r=a.call(e);if(!w(r))return r}}throw TypeError()}function ve(e){return!!e}function ye(e){return``+e}function be(e){var t=ge(e,3);return he(t)?t:ye(t)}function xe(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:Object.prototype.toString.call(e)===`[object Array]`}function Se(e){return typeof e==`function`}function Ce(e){return typeof e==`function`}function we(e){switch(pe(e)){case 3:return!0;case 4:return!0;default:return!1}}function Te(e,t){return e===t||e!==e&&t!==t}function Ee(e,t){var n=e[t];if(n!=null){if(!Se(n))throw TypeError();return n}}function De(e){var t=Ee(e,a);if(!Se(t))throw TypeError();var n=t.call(e);if(!w(n))throw TypeError();return n}function Oe(e){return e.value}function ke(e){var t=e.next();return t.done?!1:t}function Ae(e){var t=e.return;t&&t.call(e)}function je(e){var t=Object.getPrototypeOf(e);if(typeof e!=`function`||e===u||t!==u)return t;var n=e.prototype,r=n&&Object.getPrototypeOf(n);if(r==null||r===Object.prototype)return t;var i=r.constructor;return typeof i!=`function`||i===e?t:i}function Me(){var e;!C(m)&&t.Reflect!==void 0&&!(m in t.Reflect)&&typeof t.Reflect.defineMetadata==`function`&&(e=Fe(t.Reflect));var n,r,i,a=new p,o={registerProvider:s,getProvider:l,setProvider:h};return o;function s(t){if(!Object.isExtensible(o))throw Error(`Cannot add provider to a frozen registry.`);switch(!0){case e===t:break;case C(n):n=t;break;case n===t:break;case C(r):r=t;break;case r===t:break;default:i===void 0&&(i=new f),i.add(t);break}}function c(t,a){if(!C(n)){if(n.isProviderFor(t,a))return n;if(!C(r)){if(r.isProviderFor(t,a))return n;if(!C(i))for(var o=De(i);;){var s=ke(o);if(!s)return;var c=Oe(s);if(c.isProviderFor(t,a))return Ae(o),c}}}if(!C(e)&&e.isProviderFor(t,a))return e}function l(e,t){var n=a.get(e),r;return C(n)||(r=n.get(t)),C(r)?(r=c(e,t),C(r)||(C(n)&&(n=new d,a.set(e,n)),n.set(t,r)),r):r}function u(e){if(C(e))throw TypeError();return n===e||r===e||!C(i)&&i.has(e)}function h(e,t,n){if(!u(n))throw Error(`Metadata provider not registered.`);var r=l(e,t);if(r!==n){if(!C(r))return!1;var i=a.get(e);C(i)&&(i=new d,a.set(e,i)),i.set(t,n)}return!0}}function Ne(){var e;return!C(m)&&w(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[m]),C(e)&&(e=Me()),!C(m)&&w(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,m,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function Pe(e){var t=new p,n={isProviderFor:function(e,n){var r=t.get(e);return C(r)?!1:r.has(n)},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:i,OrdinaryGetOwnMetadata:a,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return h.registerProvider(n),n;function r(r,i,a){var o=t.get(r),s=!1;if(C(o)){if(!a)return;o=new d,t.set(r,o),s=!0}var c=o.get(i);if(C(c)){if(!a)return;if(c=new d,o.set(i,c),!e.setProvider(r,i,n))throw o.delete(i),s&&t.delete(r),Error(`Wrong provider for target.`)}return c}function i(e,t,n){var i=r(t,n,!1);return C(i)?!1:ve(i.has(e))}function a(e,t,n){var i=r(t,n,!1);if(!C(i))return i.get(e)}function o(e,t,n,i){r(n,i,!0).set(e,t)}function s(e,t){var n=[],i=r(e,t,!1);if(C(i))return n;for(var a=De(i.keys()),o=0;;){var s=ke(a);if(!s)return n.length=o,n;var c=Oe(s);try{n[o]=c}catch(e){try{Ae(a)}finally{throw e}}o++}}function c(e,n,i){var a=r(n,i,!1);if(C(a)||!a.delete(e))return!1;if(a.size===0){var o=t.get(n);C(o)||(o.delete(i),o.size===0&&t.delete(o))}return!0}}function Fe(e){var t=e.defineMetadata,n=e.hasOwnMetadata,r=e.getOwnMetadata,i=e.getOwnMetadataKeys,a=e.deleteMetadata,o=new p;return{isProviderFor:function(e,t){var n=o.get(e);return!C(n)&&n.has(t)?!0:i(e,t).length?(C(n)&&(n=new f,o.set(e,n)),n.add(t),!0):!1},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:r,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:a}}function Ie(e,t,n){var r=h.getProvider(e,t);if(!C(r))return r;if(n){if(h.setProvider(e,t,g))return g;throw Error(`Illegal state.`)}}function Le(){var e={},t=[],n=function(){function e(e,t,n){this._index=0,this._keys=e,this._values=t,this._selector=n}return e.prototype[`@@iterator`]=function(){return this},e.prototype[a]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var n=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:n,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}();return function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var n=this._find(e,!0);return this._values[n]=t,this},t.prototype.delete=function(t){var n=this._find(t,!1);if(n>=0){for(var r=this._keys.length,i=n+1;i<r;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,Te(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new n(this._keys,this._values,r)},t.prototype.values=function(){return new n(this._keys,this._values,i)},t.prototype.entries=function(){return new n(this._keys,this._values,o)},t.prototype[`@@iterator`]=function(){return this.entries()},t.prototype[a]=function(){return this.entries()},t.prototype._find=function(e,t){if(!Te(this._cacheKey,e)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(Te(this._keys[n],e)){this._cacheIndex=n;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();function r(e,t){return e}function i(e,t){return t}function o(e,t){return[e,t]}}function Re(){return function(){function e(){this._map=new d}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype[`@@iterator`]=function(){return this.keys()},e.prototype[a]=function(){return this.keys()},e}()}function ze(){var e=16,t=l.create(),r=i();return function(){function e(){this._key=i()}return e.prototype.has=function(e){var t=a(e,!1);return t===void 0?!1:l.has(t,this._key)},e.prototype.get=function(e){var t=a(e,!1);return t===void 0?void 0:l.get(t,this._key)},e.prototype.set=function(e,t){var n=a(e,!0);return n[this._key]=t,this},e.prototype.delete=function(e){var t=a(e,!1);return t===void 0?!1:delete t[this._key]},e.prototype.clear=function(){this._key=i()},e}();function i(){var e;do e=`@@WeakMap@@`+c();while(l.has(t,e));return t[e]=!0,e}function a(e,t){if(!n.call(e,r)){if(!t)return;Object.defineProperty(e,r,{value:l.create()})}return e[r]}function o(e,t){for(var n=0;n<t;++n)e[n]=Math.random()*255|0;return e}function s(e){if(typeof Uint8Array==`function`){var t=new Uint8Array(e);return typeof crypto<`u`?crypto.getRandomValues(t):typeof msCrypto<`u`?msCrypto.getRandomValues(t):o(t,e),t}return o(Array(e),e)}function c(){var t=s(e);t[6]=t[6]&79|64,t[8]=t[8]&191|128;for(var n=``,r=0;r<e;++r){var i=t[r];(r===4||r===6||r===8)&&(n+=`-`),i<16&&(n+=`0`),n+=i.toString(16).toLowerCase()}return n}}function Be(e){return e.__=void 0,delete e.__,e}})})(e||={})})),Bm=s((e=>{var t=`[object ArrayBuffer]`,n=class e{static isArrayBuffer(e){return Object.prototype.toString.call(e)===t}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 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(t,n){let r=e.toUint8Array(t),i=e.toUint8Array(n);if(r.length!==i.byteLength)return!1;for(let e=0;e<r.length;e++)if(r[e]!==i[e])return!1;return!0}static concat(...e){let t;t=Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?e[0]:e[e.length-1]instanceof Function?e.slice(0,e.length-1):e;let n=0;for(let e of t)n+=e.byteLength;let r=new Uint8Array(n),i=0;for(let e of t){let t=this.toUint8Array(e);r.set(t,i),i+=t.length}return e[e.length-1]instanceof Function?this.toView(r,e[e.length-1]):r.buffer}},r=`string`,i=/^[0-9a-f\s]+$/i,a=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,o=/^[a-zA-Z0-9-_]+$/,s=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n.buffer}static toString(e){let t=n.toUint8Array(e),r=``;for(let e=0;e<t.length;e++)r+=String.fromCharCode(t[e]);return decodeURIComponent(escape(r))}},c=class{static toString(e,t=!1){let r=n.toArrayBuffer(e),i=new DataView(r),a=``;for(let e=0;e<r.byteLength;e+=2){let n=i.getUint16(e,t);a+=String.fromCharCode(n)}return a}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),r=new DataView(n);for(let n=0;n<e.length;n++)r.setUint16(n*2,e.charCodeAt(n),t);return n}},l=class e{static isHex(e){return typeof e===r&&i.test(e)}static isBase64(e){return typeof e===r&&a.test(e)}static isBase64Url(e){return typeof e===r&&o.test(e)}static ToString(e,t=`utf8`){let r=n.toUint8Array(e);switch(t.toLowerCase()){case`utf8`:return this.ToUtf8String(r);case`binary`:return this.ToBinary(r);case`hex`:return this.ToHex(r);case`base64`:return this.ToBase64(r);case`base64url`:return this.ToBase64Url(r);case`utf16le`:return c.toString(r,!0);case`utf16`:case`utf16be`:return c.toString(r);default:throw 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 c.fromString(e,!0);case`utf16`:case`utf16be`:return c.fromString(e);default:throw Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=n.toUint8Array(e);if(typeof btoa<`u`){let e=this.ToString(t,`binary`);return btoa(e)}else return Buffer.from(t).toString(`base64`)}static FromBase64(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isBase64(n))throw TypeError(`Argument 'base64Text' is not Base64 encoded`);return typeof atob<`u`?this.FromBinary(atob(n)):new Uint8Array(Buffer.from(n,`base64`)).buffer}static FromBase64Url(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isBase64Url(n))throw TypeError(`Argument 'base64url' is not Base64Url encoded`);return this.FromBase64(this.Base64Padding(n.replace(/\-/g,`+`).replace(/\_/g,`/`)))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/\=/g,``)}static FromUtf8String(t,n=e.DEFAULT_UTF8_ENCODING){switch(n){case`ascii`:return this.FromBinary(t);case`utf8`:return s.fromString(t);case`utf16`:case`utf16be`:return c.fromString(t);case`utf16le`:case`usc2`:return c.fromString(t,!0);default:throw Error(`Unknown type of encoding '${n}'`)}}static ToUtf8String(t,n=e.DEFAULT_UTF8_ENCODING){switch(n){case`ascii`:return this.ToBinary(t);case`utf8`:return s.toString(t);case`utf16`:case`utf16be`:return c.toString(t);case`utf16le`:case`usc2`:return c.toString(t,!0);default:throw Error(`Unknown type of encoding '${n}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);return n.buffer}static ToBinary(e){let t=n.toUint8Array(e),r=``;for(let e=0;e<t.length;e++)r+=String.fromCharCode(t[e]);return r}static ToHex(e){let t=n.toUint8Array(e),r=``,i=t.length;for(let e=0;e<i;e++){let n=t[e];n<16&&(r+=`0`),r+=n.toString(16)}return r}static FromHex(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isHex(n))throw TypeError(`Argument 'hexString' is not HEX encoded`);n.length%2&&(n=`0${n}`);let r=new Uint8Array(n.length/2);for(let e=0;e<n.length;e+=2){let t=n.slice(e,e+2);r[e/2]=parseInt(t,16)}return r.buffer}static ToUtf16String(e,t=!1){return c.toString(e,t)}static FromUtf16String(e,t=!1){return c.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+=`=`;return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,``)||``}};l.DEFAULT_UTF8_ENCODING=`utf8`;function u(...e){let t=e.map(e=>e.byteLength).reduce((e,t)=>e+t),n=new Uint8Array(t),r=0;return e.map(e=>new Uint8Array(e)).forEach(e=>{for(let t of e)n[r++]=t}),n.buffer}function d(e,t){if(!(e&&t)||e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(n[t]!==r[t])return!1;return!0}e.BufferSourceConverter=n,e.Convert=l,e.combine=u,e.isEqual=d}));zm();var M=u(Bm());function Vm(e,t){let n=0;if(e.length===1)return e[0];for(let r=e.length-1;r>=0;r--)n+=e[e.length-1-r]*2**(t*r);return n}function Hm(e,t,n=-1){let r=n,i=e,a=0,o=2**t;for(let n=1;n<8;n++){if(e<o){let e;if(r<0)e=new ArrayBuffer(n),a=n;else{if(r<n)return new ArrayBuffer(0);e=new ArrayBuffer(r),a=r}let o=new Uint8Array(e);for(let e=n-1;e>=0;e--){let n=2**(e*t);o[a-e-1]=Math.floor(i/n),i-=o[a-e-1]*n}return e}o*=2**t}return new ArrayBuffer(0)}function Um(...e){let t=0,n=0;for(let n of e)t+=n.length;let r=new ArrayBuffer(t),i=new Uint8Array(r);for(let t of e)i.set(t,n),n+=t.length;return i}function Wm(){let e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let t=e[0]===255&&e[1]&128,n=e[0]===0&&(e[1]&128)==0;(t||n)&&this.warnings.push(`Needlessly long format`)}let t=new ArrayBuffer(this.valueHex.byteLength),n=new Uint8Array(t);for(let e=0;e<this.valueHex.byteLength;e++)n[e]=0;n[0]=e[0]&128;let r=Vm(n,8),i=new ArrayBuffer(this.valueHex.byteLength),a=new Uint8Array(i);for(let t=0;t<this.valueHex.byteLength;t++)a[t]=e[t];return a[0]&=127,Vm(a,8)-r}function Gm(e){let t=e<0?e*-1:e,n=128;for(let r=1;r<8;r++){if(t<=n){if(e<0){let e=Hm(n-t,8,r),i=new Uint8Array(e);return i[0]|=128,e}let i=Hm(t,8,r),a=new Uint8Array(i);if(a[0]&128){let e=i.slice(0),t=new Uint8Array(e);i=new ArrayBuffer(i.byteLength+1),a=new Uint8Array(i);for(let n=0;n<e.byteLength;n++)a[n+1]=t[n];a[0]=0}return i}n*=2**8}return new ArrayBuffer(0)}function Km(e,t){if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function qm(e,t){let n=e.toString(10);if(t<n.length)return``;let r=t-n.length,i=Array(r);for(let e=0;e<r;e++)i[e]=`0`;return i.join(``).concat(n)}var Jm=c({Any:()=>o_,BaseBlock:()=>Sh,BaseStringBlock:()=>wh,BitString:()=>Jh,BmpString:()=>wg,Boolean:()=>Hh,CharacterString:()=>Gg,Choice:()=>s_,Constructed:()=>Ph,DATE:()=>Zg,DateTime:()=>t_,Duration:()=>r_,EndOfContent:()=>Lh,Enumerated:()=>rg,GeneralString:()=>Ug,GeneralizedTime:()=>Yg,GraphicString:()=>zg,HexBlock:()=>_h,IA5String:()=>Lg,Integer:()=>tg,Null:()=>zh,NumericString:()=>kg,ObjectIdentifier:()=>sg,OctetString:()=>Gh,Primitive:()=>Dh,PrintableString:()=>jg,RawData:()=>l_,RelativeObjectIdentifier:()=>dg,Repeated:()=>c_,Sequence:()=>pg,Set:()=>hg,TIME:()=>a_,TeletexString:()=>Ng,TimeOfDay:()=>$g,UTCTime:()=>qg,UniversalString:()=>Dg,Utf8String:()=>xg,ValueBlock:()=>yh,VideotexString:()=>Fg,ViewWriter:()=>Qm,VisibleString:()=>Vg,compareSchema:()=>u_,fromBER:()=>Ah,verifySchema:()=>d_});function Ym(){if(typeof BigInt>`u`)throw Error(`BigInt is not defined. Your environment doesn't implement BigInt.`)}function Xm(e){let t=0,n=0;for(let n=0;n<e.length;n++){let r=e[n];t+=r.byteLength}let r=new Uint8Array(t);for(let t=0;t<e.length;t++){let i=e[t];r.set(new Uint8Array(i),n),n+=i.byteLength}return r.buffer}function Zm(e,t,n,r){return t instanceof Uint8Array?t.byteLength?n<0?(e.error=`Wrong parameter: inputOffset less than zero`,!1):r<0?(e.error=`Wrong parameter: inputLength less than zero`,!1):t.byteLength-n-r<0?(e.error=`End of input reached before message was fully decoded (inconsistent offset and length values)`,!1):!0:(e.error=`Wrong parameter: inputBuffer has zero length`,!1):(e.error=`Wrong parameter: inputBuffer must be 'Uint8Array'`,!1)}var Qm=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Xm(this.items)}},$m=[new Uint8Array([1])],eh=`0123456789`,th=`name`,nh=`valueHexView`,rh=`isHexOnly`,ih=`idBlock`,ah=`tagClass`,oh=`tagNumber`,sh=`isConstructed`,ch=`fromBER`,lh=`toBER`,uh=`local`,dh=``,fh=new ArrayBuffer(0),ph=new Uint8Array,mh=`EndOfContent`,hh=`OCTET STRING`,gh=`BIT STRING`;function _h(e){var t;return t=class extends e{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(e){this.valueHexView=new Uint8Array(e)}constructor(...e){super(...e);let t=e[0]||{};this.isHexOnly=t.isHexOnly??!1,this.valueHexView=t.valueHex?M.BufferSourceConverter.toUint8Array(t.valueHex):ph}fromBER(e,t,n){let r=e instanceof ArrayBuffer?new Uint8Array(e):e;if(!Zm(this,r,t,n))return-1;let i=t+n;return this.valueHexView=r.subarray(t,i),this.valueHexView.length?(this.blockLength=n,i):(this.warnings.push(`Zero buffer length`),t)}toBER(e=!1){return this.isHexOnly?e?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`,fh)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:M.Convert.ToHex(this.valueHexView)}}},t.NAME=`hexBlock`,t}var vh=class{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:t=dh,warnings:n=[],valueBeforeDecode:r=ph}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=M.BufferSourceConverter.toUint8Array(r)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:M.Convert.ToHex(this.valueBeforeDecodeView)}}};vh.NAME=`baseBlock`;var yh=class extends vh{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'`)}};yh.NAME=`valueBlock`;var bh=class extends _h(vh){constructor({idBlock:e={}}={}){super(),e?(this.isHexOnly=e.isHexOnly??!1,this.valueHexView=e.valueHex?M.BufferSourceConverter.toUint8Array(e.valueHex):ph,this.tagClass=e.tagClass??-1,this.tagNumber=e.tagNumber??-1,this.isConstructed=e.isConstructed??!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`,fh}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let n=new Uint8Array(1);if(!e){let e=this.tagNumber;e&=31,t|=e,n[0]=t}return n.buffer}if(!this.isHexOnly){let n=Hm(this.tagNumber,7),r=new Uint8Array(n),i=n.byteLength,a=new Uint8Array(i+1);if(a[0]=t|31,!e){for(let e=0;e<i-1;e++)a[e+1]=r[e]|128;a[i]=r[i-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let e=this.valueHexView;for(let t=0;t<e.length-1;t++)n[t+1]=e[t]|128;n[this.valueHexView.byteLength]=e[e.length-1]}return n.buffer}fromBER(e,t,n){let r=M.BufferSourceConverter.toUint8Array(e);if(!Zm(this,r,t,n))return-1;let i=r.subarray(t,t+n);if(i.length===0)return this.error=`Zero buffer length`,-1;switch(i[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=(i[0]&32)==32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let e=1,t=this.valueHexView=new Uint8Array(255),n=255;for(;i[e]&128;){if(t[e-1]=i[e]&127,e++,e>=i.length)return this.error=`End of input reached before message was fully decoded`,-1;if(e===n){n+=255;let e=new Uint8Array(n);for(let n=0;n<t.length;n++)e[n]=t[n];t=this.valueHexView=new Uint8Array(n)}}this.blockLength=e+1,t[e-1]=i[e]&127;let r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=t[n];t=this.valueHexView=new Uint8Array(e),t.set(r),this.blockLength<=9?this.tagNumber=Vm(t,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}}};bh.NAME=`identificationBlock`;var xh=class extends vh{constructor({lenBlock:e={}}={}){super(),this.isIndefiniteForm=e.isIndefiniteForm??!1,this.longFormUsed=e.longFormUsed??!1,this.length=e.length??0}fromBER(e,t,n){let r=M.BufferSourceConverter.toUint8Array(e);if(!Zm(this,r,t,n))return-1;let i=r.subarray(t,t+n);if(i.length===0)return this.error=`Zero buffer length`,-1;if(i[0]===255)return this.error=`Length block 0xFF is reserved by standard`,-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;let a=i[0]&127;if(a>8)return this.error=`Too big integer`,-1;if(a+1>i.length)return this.error=`End of input reached before message was fully decoded`,-1;let o=t+1,s=r.subarray(o,o+a);return s[a-1]===0&&this.warnings.push(`Needlessly long encoded length`),this.length=Vm(s,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){let r=Hm(this.length,8);if(r.byteLength>127)return this.error=`Too big length`,fh;if(t=new ArrayBuffer(r.byteLength+1),e)return t;let i=new Uint8Array(r);n=new Uint8Array(t),n[0]=r.byteLength|128;for(let e=0;e<r.byteLength;e++)n[e+1]=i[e];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}}};xh.NAME=`lengthBlock`;var N={},Sh=class extends vh{constructor({name:e=dh,optional:t=!1,primitiveSchema:n,...r}={},i){super(r),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new bh(r),this.lenBlock=new xh(r),this.valueBlock=i?new i(r):new yh(r)}fromBER(e,t,n){let r=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return r===-1?(this.error=this.valueBlock.error,r):(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),r)}toBER(e,t){let n=t||new Qm;t||Ch(this);let r=this.idBlock.toBER(e);if(n.write(r),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let t=this.valueBlock.toBER(e);this.lenBlock.length=t.byteLength;let r=this.lenBlock.toBER(e);n.write(r),n.write(t)}return t?fh:n.final()}toJSON(){let 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():M.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${M.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){return this===e?!0:e instanceof this.constructor?Km(this.toBER(),e.toBER()):!1}};Sh.NAME=`BaseBlock`;function Ch(e){if(e instanceof N.Constructed)for(let t of e.valueBlock.value)Ch(t)&&(e.lenBlock.isIndefiniteForm=!0);return!!e.lenBlock?.isIndefiniteForm}var wh=class extends Sh{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e=dh,...t}={},n){super(t,n),e&&this.fromString(e)}fromBER(e,t,n){let r=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return r===-1?(this.error=this.valueBlock.error,r):(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),r)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};wh.NAME=`BaseStringBlock`;var Th=class extends _h(yh){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};Th.NAME=`PrimitiveValueBlock`;var Eh,Dh=class extends Sh{constructor(e={}){super(e,Th),this.idBlock.isConstructed=!1}};Eh=Dh,N.Primitive=Eh,Dh.NAME=`PRIMITIVE`;function Oh(e,t){if(e instanceof t)return e;let n=new t;return n.idBlock=e.idBlock,n.lenBlock=e.lenBlock,n.warnings=e.warnings,n.valueBeforeDecodeView=e.valueBeforeDecodeView,n}function kh(e,t=0,n=e.length){let r=t,i=new Sh({},yh),a=new vh;if(!Zm(a,e,t,n))return i.error=a.error,{offset:-1,result:i};if(!e.subarray(t,t+n).length)return i.error=`Zero buffer length`,{offset:-1,result:i};let o=i.idBlock.fromBER(e,t,n);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),o===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(t=o,n-=i.idBlock.blockLength,o=i.lenBlock.fromBER(e,t,n),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),o===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(t=o,n-=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 s=Sh;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};s=N.EndOfContent;break;case 1:s=N.Boolean;break;case 2:s=N.Integer;break;case 3:s=N.BitString;break;case 4:s=N.OctetString;break;case 5:s=N.Null;break;case 6:s=N.ObjectIdentifier;break;case 10:s=N.Enumerated;break;case 12:s=N.Utf8String;break;case 13:s=N.RelativeObjectIdentifier;break;case 14:s=N.TIME;break;case 15:return i.error=`[UNIVERSAL 15] is reserved by ASN.1 standard`,{offset:-1,result:i};case 16:s=N.Sequence;break;case 17:s=N.Set;break;case 18:s=N.NumericString;break;case 19:s=N.PrintableString;break;case 20:s=N.TeletexString;break;case 21:s=N.VideotexString;break;case 22:s=N.IA5String;break;case 23:s=N.UTCTime;break;case 24:s=N.GeneralizedTime;break;case 25:s=N.GraphicString;break;case 26:s=N.VisibleString;break;case 27:s=N.GeneralString;break;case 28:s=N.UniversalString;break;case 29:s=N.CharacterString;break;case 30:s=N.BmpString;break;case 31:s=N.DATE;break;case 32:s=N.TimeOfDay;break;case 33:s=N.DateTime;break;case 34:s=N.Duration;break;default:{let e=i.idBlock.isConstructed?new N.Constructed:new N.Primitive;e.idBlock=i.idBlock,e.lenBlock=i.lenBlock,e.warnings=i.warnings,i=e}}break;default:s=i.idBlock.isConstructed?N.Constructed:N.Primitive}return i=Oh(i,s),o=i.fromBER(e,t,i.lenBlock.isIndefiniteForm?n:i.lenBlock.length),i.valueBeforeDecodeView=e.subarray(r,r+i.blockLength),{offset:o,result:i}}function Ah(e){if(!e.byteLength){let e=new Sh({},yh);return e.error=`Input buffer has zero length`,{offset:-1,result:e}}return kh(M.BufferSourceConverter.toUint8Array(e).slice(),0,e.byteLength)}function jh(e,t){return e?1:t}var Mh=class extends yh{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let r=M.BufferSourceConverter.toUint8Array(e);if(!Zm(this,r,t,n))return-1;if(this.valueBeforeDecodeView=r.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push(`Zero buffer length`),t;let i=t;for(;jh(this.isIndefiniteForm,n)>0;){let e=kh(r,i,n);if(e.offset===-1)return this.error=e.result.error,this.warnings.concat(e.result.warnings),-1;if(i=e.offset,this.blockLength+=e.result.blockLength,n-=e.result.blockLength,this.value.push(e.result),this.isIndefiniteForm&&e.result.constructor.NAME===mh)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===mh?this.value.pop():this.warnings.push(`No EndOfContent block encoded`)),i}toBER(e,t){let n=t||new Qm;for(let t=0;t<this.value.length;t++)this.value[t].toBER(e,n);return t?fh:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};Mh.NAME=`ConstructedValueBlock`;var Nh,Ph=class extends Sh{constructor(e={}){super(e,Mh),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let r=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return r===-1?(this.error=this.valueBlock.error,r):(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),r)}onAsciiEncoding(){let e=[];for(let t of this.valueBlock.value)e.push(t.toString(`ascii`).split(`
294
294
  `).map(e=>` ${e}`).join(`
295
295
  `));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :\n${e.join(`
296
- `)}`:`${t} :`}};Nh=Ph,N.Constructed=Nh,Ph.NAME=`CONSTRUCTED`;var Fh=class extends yh{fromBER(e,t,n){return t}toBER(e){return fh}};Fh.override=`EndOfContentValueBlock`;var Ih,Lh=class extends Sh{constructor(e={}){super(e,Fh),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Ih=Lh,N.EndOfContent=Ih,Lh.NAME=mh;var Rh,zh=class extends Sh{constructor(e={}){super(e,yh),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){let n=new ArrayBuffer(2);if(!e){let e=new Uint8Array(n);e[0]=5,e[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Rh=zh,N.Null=Rh,zh.NAME=`NULL`;var Bh=class extends _h(yh){get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=M.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,n){let r=M.BufferSourceConverter.toUint8Array(e);return Zm(this,r,t,n)?(this.valueHexView=r.subarray(t,t+n),n>1&&this.warnings.push(`Boolean value encoded in more then 1 octet`),this.isHexOnly=!0,Wm.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Bh.NAME=`BooleanValueBlock`;var Vh,Hh=class extends Sh{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,Bh),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Vh=Hh,N.Boolean=Vh,Hh.NAME=`BOOLEAN`;var Uh=class extends _h(Mh){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let r=0;if(this.isConstructed){if(this.isHexOnly=!1,r=Mh.prototype.fromBER.call(this,e,t,n),r===-1)return r;for(let e=0;e<this.value.length;e++){let t=this.value[e].constructor.NAME;if(t===mh){if(this.isIndefiniteForm)break;return this.error=`EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only`,-1}if(t!==hh)return this.error=`OCTET STRING may consists of OCTET STRINGs only`,-1}}else this.isHexOnly=!0,r=super.fromBER(e,t,n),this.blockLength=n;return r}toBER(e,t){return this.isConstructed?Mh.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Uh.NAME=`OctetStringValueBlock`;var Wh,Gh=class extends Sh{constructor({idBlock:e={},lenBlock:t={},...n}={}){n.isConstructed??=!!n.value?.length,super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Uh),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){let r=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(r.byteLength){let e=kh(r,0,r.byteLength);e.offset!==-1&&e.offset===n&&(this.valueBlock.value=[e.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ph.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${M.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof Wh&&e.push(t.valueBlock.valueHexView);return M.BufferSourceConverter.concat(e)}};Wh=Gh,N.OctetString=Wh,Gh.NAME=hh;var Kh=class extends _h(Mh){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 r=-1;if(this.isConstructed){if(r=Mh.prototype.fromBER.call(this,e,t,n),r===-1)return r;for(let e of this.value){let t=e.constructor.NAME;if(t===mh){if(this.isIndefiniteForm)break;return this.error=`EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only`,-1}if(t!==gh)return this.error=`BIT STRING may consists of BIT STRINGs only`,-1;let n=e.valueBlock;if(this.unusedBits>0&&n.unusedBits>0)return this.error=`Using of "unused bits" inside constructive BIT STRING allowed for least one only`,-1;this.unusedBits=n.unusedBits}return r}let i=M.BufferSourceConverter.toUint8Array(e);if(!Zm(this,i,t,n))return-1;let a=i.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){let e=a.subarray(1);try{if(e.byteLength){let t=kh(e,0,e.byteLength);t.offset!==-1&&t.offset===n-1&&(this.value=[t.result])}}catch{}}return this.valueHexView=a.subarray(1),this.blockLength=a.length,t+n}toBER(e,t){if(this.isConstructed)return Mh.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength){let e=new Uint8Array(1);return e[0]=0,e.buffer}let 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}}};Kh.NAME=`BitStringValueBlock`;var qh,Jh=class extends Sh{constructor({idBlock:e={},lenBlock:t={},...n}={}){n.isConstructed??=!!n.value?.length,super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Kh),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 Ph.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let n of t)e.push(n.toString(2).padStart(8,`0`));let n=e.join(``);return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};qh=Jh,N.BitString=qh,Jh.NAME=gh;var Yh;function Xh(e,t){let n=new Uint8Array([0]),r=new Uint8Array(e),i=new Uint8Array(t),a=r.slice(0),o=a.length-1,s=i.slice(0),c=s.length-1,l=0,u=c<o?o:c,d=0;for(let e=u;e>=0;e--,d++){switch(!0){case d<s.length:l=a[o-d]+s[c-d]+n[0];break;default:l=a[o-d]+n[0]}switch(n[0]=l/10,!0){case d>=a.length:a=Um(new Uint8Array([l%10]),a);break;default:a[o-d]=l%10}}return n[0]>0&&(a=Um(n,a)),a}function Zh(e){if(e>=$m.length)for(let t=$m.length;t<=e;t++){let e=new Uint8Array([0]),n=$m[t-1].slice(0);for(let t=n.length-1;t>=0;t--){let r=new Uint8Array([(n[t]<<1)+e[0]]);e[0]=r[0]/10,n[t]=r[0]%10}e[0]>0&&(n=Um(e,n)),$m.push(n)}return $m[e]}function Qh(e,t){let n=0,r=new Uint8Array(e),i=new Uint8Array(t),a=r.slice(0),o=a.length-1,s=i.slice(0),c=s.length-1,l,u=0;for(let e=c;e>=0;e--,u++)switch(l=a[o-u]-s[c-u]-n,!0){case l<0:n=1,a[o-u]=l+10;break;default:n=0,a[o-u]=l}if(n>0)for(let e=o-c+1;e>=0;e--,u++)if(l=a[o-u]-n,l<0)n=1,a[o-u]=l+10;else{n=0,a[o-u]=l;break}return a.slice()}var $h=class extends _h(yh){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=Wm.call(this)))}constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Gm(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,r=0){let i=this.fromBER(e,t,n);if(i===-1)return i;let a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):r!==0&&a.length<r&&(r-a.length>1&&(r=a.length+1),this.valueHexView=a.subarray(r-a.length)),i}toDER(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!=0:{let e=new Uint8Array(this.valueHexView.length+1);e[0]=0,e.set(t,1),this.valueHexView=e}break;case t[0]===0&&(t[1]&128)==0:this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let r=super.fromBER(e,t,n);return r===-1||this.setValueHex(),r}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,r,i=this.valueHexView,a=``,o=!1;for(let o=i.byteLength-1;o>=0;o--){r=i[o];for(let i=0;i<8;i++){if((r&1)==1)switch(n){case e:t=Qh(Zh(n),t),a=`-`;break;default:t=Xh(t,Zh(n))}n++,r>>=1}}for(let e=0;e<t.length;e++)t[e]&&(o=!0),o&&(a+=eh.charAt(t[e]));return o===!1&&(a+=eh.charAt(0)),a}};Yh=$h,$h.NAME=`IntegerValueBlock`,Object.defineProperty(Yh.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var eg,tg=class extends Sh{constructor(e={}){super(e,$h),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Ym(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Ym();let t=BigInt(e),n=new Qm,r=t.toString(16).replace(/^-/,``),i=new Uint8Array(M.Convert.FromHex(r));if(t<0){let e=new Uint8Array(i.length+(i[0]&128?1:0));e[0]|=128;let r=BigInt(`0x${M.Convert.ToHex(e)}`)+t,a=M.BufferSourceConverter.toUint8Array(M.Convert.FromHex(r.toString(16)));a[0]|=128,n.write(a)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new eg({valueHex:n.final()})}convertToDER(){let e=new eg({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new eg({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};eg=tg,N.Integer=eg,tg.NAME=`INTEGER`;var ng,rg=class extends tg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};ng=rg,N.Enumerated=ng,rg.NAME=`ENUMERATED`;var ig=class extends _h(yh){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let r=M.BufferSourceConverter.toUint8Array(e);if(!Zm(this,r,t,n))return-1;let i=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let e=0;e<n&&(this.valueHexView[e]=i[e]&127,this.blockLength++,i[e]&128);e++);let a=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)a[e]=this.valueHexView[e];return this.valueHexView=a,i[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=Vm(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push(`Too big SID for decoding, hex only`)),t+this.blockLength)}set valueBigInt(e){Ym();let t=BigInt(e).toString(2);for(;t.length%7;)t=`0`+t;let n=new Uint8Array(t.length/7);for(let e=0;e<n.length;e++)n[e]=parseInt(t.slice(e*7,e*7+7),2)+(e+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);let t=this.valueHexView,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=t[e]|128;return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}let t=Hm(this.valueDec,7);if(t.byteLength===0)return this.error=`Error during encoding SID value`,fh;let n=new Uint8Array(t.byteLength);if(!e){let e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=e[t]|128;n[r]=e[r]}return n}toString(){let e=``;if(this.isHexOnly)e=M.Convert.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}}};ig.NAME=`sidBlock`;var ag=class extends yh{constructor({value:e=dh,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){let t=new ig;if(r=t.fromBER(e,r,n),r===-1)return this.blockLength=0,this.error=t.error,r;this.value.length===0&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e){let t=[];for(let n=0;n<this.value.length;n++){let r=this.value[n].toBER(e);if(r.byteLength===0)return this.error=this.value[n].error,fh;t.push(r)}return Xm(t)}fromString(e){this.value=[];let t=0,n=0,r=``,i=!1;do if(n=e.indexOf(`.`,t),r=n===-1?e.substring(t):e.substring(t,n),t=n+1,i){let e=this.value[0],t=0;switch(e.valueDec){case 0:break;case 1:t=40;break;case 2:t=80;break;default:this.value=[];return}let n=parseInt(r,10);if(isNaN(n))return;e.valueDec=n+t,i=!1}else{let e=new ig;if(r>2**53-1)Ym(),e.valueBigInt=BigInt(r);else if(e.valueDec=parseInt(r,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,i=!0),this.value.push(e)}while(n!==-1)}toString(){let e=``,t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let r=this.value[n].toString();n!==0&&(e=`${e}.`),t?(r=`{${r}}`,this.value[n].isFirstSid?e=`2.{${r} - 80}`:e+=r):e+=r}return e}toJSON(){let 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}};ag.NAME=`ObjectIdentifierValueBlock`;var og,sg=class extends Sh{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,ag),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||`empty`}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};og=sg,N.ObjectIdentifier=og,sg.NAME=`OBJECT IDENTIFIER`;var cg=class extends _h(vh){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let r=M.BufferSourceConverter.toUint8Array(e);if(!Zm(this,r,t,n))return-1;let i=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let e=0;e<n&&(this.valueHexView[e]=i[e]&127,this.blockLength++,i[e]&128);e++);let a=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)a[e]=this.valueHexView[e];return this.valueHexView=a,i[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=Vm(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);let t=this.valueHexView,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=t[e]|128;return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}let t=Hm(this.valueDec,7);if(t.byteLength===0)return this.error=`Error during encoding SID value`,fh;let n=new Uint8Array(t.byteLength);if(!e){let e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=e[t]|128;n[r]=e[r]}return n.buffer}toString(){let e=``;return e=this.isHexOnly?M.Convert.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};cg.NAME=`relativeSidBlock`;var lg=class extends yh{constructor({value:e=dh,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){let t=new cg;if(r=t.fromBER(e,r,n),r===-1)return this.blockLength=0,this.error=t.error,r;this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e,t){let n=[];for(let t=0;t<this.value.length;t++){let r=this.value[t].toBER(e);if(r.byteLength===0)return this.error=this.value[t].error,fh;n.push(r)}return Xm(n)}fromString(e){this.value=[];let t=0,n=0,r=``;do{n=e.indexOf(`.`,t),r=n===-1?e.substring(t):e.substring(t,n),t=n+1;let i=new cg;if(i.valueDec=parseInt(r,10),isNaN(i.valueDec))return!0;this.value.push(i)}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 r=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(r=`{${r}}`),e+=r}return e}toJSON(){let 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}};lg.NAME=`RelativeObjectIdentifierValueBlock`;var ug,dg=class extends Sh{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,lg),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||`empty`}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};ug=dg,N.RelativeObjectIdentifier=ug,dg.NAME=`RelativeObjectIdentifier`;var fg,pg=class extends Ph{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};fg=pg,N.Sequence=fg,pg.NAME=`SEQUENCE`;var mg,hg=class extends Ph{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};mg=hg,N.Set=mg,hg.NAME=`SET`;var gg=class extends _h(yh){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=dh}toJSON(){return{...super.toJSON(),value:this.value}}};gg.NAME=`StringValueBlock`;var _g=class extends gg{};_g.NAME=`SimpleStringValueBlock`;var vg=class extends wh{constructor({...e}={}){super(e,_g)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,M.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);this.valueBlock.value=e}};vg.NAME=`SIMPLE STRING`;var yg=class extends vg{fromBuffer(e){this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=M.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=M.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf8String(e)),this.valueBlock.value=e}};yg.NAME=`Utf8StringValueBlock`;var bg,xg=class extends yg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};bg=xg,N.Utf8String=bg,xg.NAME=`UTF8String`;var Sg=class extends vg{fromBuffer(e){this.valueBlock.value=M.Convert.ToUtf16String(e),this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf16String(e))}};Sg.NAME=`BmpStringValueBlock`;var Cg,wg=class extends Sg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Cg=wg,N.BmpString=Cg,wg.NAME=`BMPString`;var Tg=class extends vg{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let e=0;e<n.length;e+=4)n[e]=n[e+3],n[e+1]=n[e+2],n[e+2]=0,n[e+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let r=0;r<t;r++){let t=Hm(e.charCodeAt(r),8),i=new Uint8Array(t);if(i.length>4)continue;let a=4-i.length;for(let e=i.length-1;e>=0;e--)n[r*4+e+a]=i[e]}this.valueBlock.value=e}};Tg.NAME=`UniversalStringValueBlock`;var Eg,Dg=class extends Tg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Eg=Dg,N.UniversalString=Eg,Dg.NAME=`UniversalString`;var Og,kg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Og=kg,N.NumericString=Og,kg.NAME=`NumericString`;var Ag,jg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Ag=jg,N.PrintableString=Ag,jg.NAME=`PrintableString`;var Mg,Ng=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Mg=Ng,N.TeletexString=Mg,Ng.NAME=`TeletexString`;var Pg,Fg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Pg=Fg,N.VideotexString=Pg,Fg.NAME=`VideotexString`;var Ig,Lg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Ig=Lg,N.IA5String=Ig,Lg.NAME=`IA5String`;var Rg,zg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Rg=zg,N.GraphicString=Rg,zg.NAME=`GraphicString`;var Bg,Vg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Bg=Vg,N.VisibleString=Bg,Vg.NAME=`VisibleString`;var Hg,Ug=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Hg=Ug,N.GeneralString=Hg,Ug.NAME=`GeneralString`;var Wg,Gg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Wg=Gg,N.CharacterString=Wg,Gg.NAME=`CharacterString`;var Kg,qg=class extends Vg{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 t=0;t<e.length;t++)this.valueBlock.valueHexView[t]=e.charCodeAt(t)}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,M.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);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){let t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(t===null){this.error=`Wrong input string for conversion`;return}let n=parseInt(t[1],10);n>=50?this.year=1900+n:this.year=2e3+n,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(e=`iso`){if(e===`iso`){let e=Array(7);return e[0]=qm(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=qm(this.month,2),e[2]=qm(this.day,2),e[3]=qm(this.hour,2),e[4]=qm(this.minute,2),e[5]=qm(this.second,2),e[6]=`Z`,e.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}}};Kg=qg,N.UTCTime=Kg,qg.NAME=`UTCTime`;var Jg,Yg=class extends qg{constructor(e={}){super(e),this.millisecond??=0,this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){let e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let t=!1,n=``,r=``,i=0,a,o=0,s=0;if(e[e.length-1]===`Z`)n=e.substring(0,e.length-1),t=!0;else{let t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw Error(`Wrong input string for conversion`);n=e}if(t){if(n.indexOf(`+`)!==-1||n.indexOf(`-`)!==-1)throw Error(`Wrong input string for conversion`)}else{let e=1,t=n.indexOf(`+`),r=``;if(t===-1&&(t=n.indexOf(`-`),e=-1),t!==-1){if(r=n.substring(t+1),n=n.substring(0,t),r.length!==2&&r.length!==4)throw Error(`Wrong input string for conversion`);let i=parseInt(r.substring(0,2),10);if(isNaN(i.valueOf()))throw Error(`Wrong input string for conversion`);if(o=e*i,r.length===4){if(i=parseInt(r.substring(2,4),10),isNaN(i.valueOf()))throw Error(`Wrong input string for conversion`);s=e*i}}}let c=n.indexOf(`.`);if(c===-1&&(c=n.indexOf(`,`)),c!==-1){let e=new Number(`0${n.substring(c)}`);if(isNaN(e.valueOf()))throw Error(`Wrong input string for conversion`);i=e.valueOf(),r=n.substring(0,c)}else r=n;switch(!0){case r.length===8:if(a=/(\d{4})(\d{2})(\d{2})/gi,c!==-1)throw Error(`Wrong input string for conversion`);break;case r.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=60*i;this.minute=Math.floor(e),e=60*(e-this.minute),this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case r.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=60*i;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case r.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=1e3*i;this.millisecond=Math.floor(e)}break;default:throw Error(`Wrong input string for conversion`)}let l=a.exec(r);if(l===null)throw Error(`Wrong input string for conversion`);for(let e=1;e<l.length;e++)switch(e){case 1:this.year=parseInt(l[e],10);break;case 2:this.month=parseInt(l[e],10);break;case 3:this.day=parseInt(l[e],10);break;case 4:this.hour=parseInt(l[e],10)+o;break;case 5:this.minute=parseInt(l[e],10)+s;break;case 6:this.second=parseInt(l[e],10);break;default:throw Error(`Wrong input string for conversion`)}if(t===!1){let e=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=e.getUTCFullYear(),this.month=e.getUTCMonth(),this.day=e.getUTCDay(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds(),this.millisecond=e.getUTCMilliseconds()}}toString(e=`iso`){if(e===`iso`){let e=[];return e.push(qm(this.year,4)),e.push(qm(this.month,2)),e.push(qm(this.day,2)),e.push(qm(this.hour,2)),e.push(qm(this.minute,2)),e.push(qm(this.second,2)),this.millisecond!==0&&(e.push(`.`),e.push(qm(this.millisecond,3))),e.push(`Z`),e.join(``)}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Jg=Yg,N.GeneralizedTime=Jg,Yg.NAME=`GeneralizedTime`;var Xg,Zg=class extends xg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Xg=Zg,N.DATE=Xg,Zg.NAME=`DATE`;var Qg,$g=class extends xg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Qg=$g,N.TimeOfDay=Qg,$g.NAME=`TimeOfDay`;var e_,t_=class extends xg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};e_=t_,N.DateTime=e_,t_.NAME=`DateTime`;var n_,r_=class extends xg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};n_=r_,N.Duration=n_,r_.NAME=`Duration`;var i_,a_=class extends xg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};i_=a_,N.TIME=i_,a_.NAME=`TIME`;var o_=class{constructor({name:e=dh,optional:t=!1}={}){this.name=e,this.optional=t}},s_=class extends o_{constructor({value:e=[],...t}={}){super(t),this.value=e}},c_=class extends o_{constructor({value:e=new o_,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}},l_=class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=M.BufferSourceConverter.toUint8Array(e)}constructor({data:e=ph}={}){this.dataView=M.BufferSourceConverter.toUint8Array(e)}fromBER(e,t,n){let r=t+n;return this.dataView=M.BufferSourceConverter.toUint8Array(e).subarray(t,r),r}toBER(e){return this.dataView.slice().buffer}};function u_(e,t,n){if(n instanceof s_){for(let r of n.value)if(u_(e,t,r).verified)return{verified:!0,result:e};{let e={verified:!1,result:{error:`Wrong values for Choice type`}};return n.hasOwnProperty(th)&&(e.name=n.name),e}}if(n instanceof o_)return n.hasOwnProperty(th)&&(e[n.name]=t),{verified:!0,result:e};if(!(e instanceof Object))return{verified:!1,result:{error:`Wrong root object`}};if(!(t instanceof Object))return{verified:!1,result:{error:`Wrong ASN.1 data`}};if(!(n instanceof Object)||!(ih in n)||!(ch in n.idBlock)||!(lh in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};let r=n.idBlock.toBER(!1);if(r.byteLength===0)return{verified:!1,result:{error:`Error encoding idBlock for ASN.1 schema`}};if(n.idBlock.fromBER(r,0,r.byteLength)===-1)return{verified:!1,result:{error:`Error decoding idBlock for ASN.1 schema`}};if(n.idBlock.hasOwnProperty(ah)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.tagClass!==t.idBlock.tagClass)return{verified:!1,result:e};if(n.idBlock.hasOwnProperty(oh)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.tagNumber!==t.idBlock.tagNumber)return{verified:!1,result:e};if(n.idBlock.hasOwnProperty(sh)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.isConstructed!==t.idBlock.isConstructed)return{verified:!1,result:e};if(!(rh in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.isHexOnly!==t.idBlock.isHexOnly)return{verified:!1,result:e};if(n.idBlock.isHexOnly){if(!(nh in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};let r=n.idBlock.valueHexView,i=t.idBlock.valueHexView;if(r.length!==i.length)return{verified:!1,result:e};for(let t=0;t<r.length;t++)if(r[t]!==i[1])return{verified:!1,result:e}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&(e[n.name]=t)),n instanceof N.Constructed){let r=0,i={verified:!1,result:{error:`Unknown error`}},a=n.valueBlock.value.length;if(a>0&&n.valueBlock.value[0]instanceof c_&&(a=t.valueBlock.value.length),a===0)return{verified:!0,result:e};if(t.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let t=!0;for(let e=0;e<n.valueBlock.value.length;e++)t&&=n.valueBlock.value[e].optional||!1;return t?{verified:!0,result:e}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&delete e[n.name]),e.error=`Inconsistent object length`,{verified:!1,result:e})}for(let o=0;o<a;o++)if(o-r>=t.valueBlock.value.length){if(n.valueBlock.value[o].optional===!1){let t={verified:!1,result:e};return e.error=`Inconsistent length between ASN.1 data and schema`,n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&(delete e[n.name],t.name=n.name)),t}}else if(n.valueBlock.value[0]instanceof c_){if(i=u_(e,t.valueBlock.value[o],n.valueBlock.value[0].value),i.verified===!1)if(n.valueBlock.value[0].optional)r++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&delete e[n.name]),i;if(th in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let r={};r=uh in n.valueBlock.value[0]&&n.valueBlock.value[0].local?t:e,r[n.valueBlock.value[0].name]===void 0&&(r[n.valueBlock.value[0].name]=[]),r[n.valueBlock.value[0].name].push(t.valueBlock.value[o])}}else if(i=u_(e,t.valueBlock.value[o-r],n.valueBlock.value[o]),i.verified===!1)if(n.valueBlock.value[o].optional)r++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&delete e[n.name]),i;if(i.verified===!1){let t={verified:!1,result:e};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&(delete e[n.name],t.name=n.name)),t}return{verified:!0,result:e}}if(n.primitiveSchema&&nh in t.valueBlock){let r=kh(t.valueBlock.valueHexView);if(r.offset===-1){let t={verified:!1,result:r.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&(delete e[n.name],t.name=n.name)),t}return u_(e,r.result,n.primitiveSchema)}return{verified:!0,result:e}}function d_(e,t){if(!(t instanceof Object))return{verified:!1,result:{error:`Wrong ASN.1 schema type`}};let n=kh(M.BufferSourceConverter.toUint8Array(e));return n.offset===-1?{verified:!1,result:n.result}:u_(n.result,n.result,t)}var P;(function(e){e[e.Sequence=0]=`Sequence`,e[e.Set=1]=`Set`,e[e.Choice=2]=`Choice`})(P||={});var F;(function(e){e[e.Any=1]=`Any`,e[e.Boolean=2]=`Boolean`,e[e.OctetString=3]=`OctetString`,e[e.BitString=4]=`BitString`,e[e.Integer=5]=`Integer`,e[e.Enumerated=6]=`Enumerated`,e[e.ObjectIdentifier=7]=`ObjectIdentifier`,e[e.Utf8String=8]=`Utf8String`,e[e.BmpString=9]=`BmpString`,e[e.UniversalString=10]=`UniversalString`,e[e.NumericString=11]=`NumericString`,e[e.PrintableString=12]=`PrintableString`,e[e.TeletexString=13]=`TeletexString`,e[e.VideotexString=14]=`VideotexString`,e[e.IA5String=15]=`IA5String`,e[e.GraphicString=16]=`GraphicString`,e[e.VisibleString=17]=`VisibleString`,e[e.GeneralString=18]=`GeneralString`,e[e.CharacterString=19]=`CharacterString`,e[e.UTCTime=20]=`UTCTime`,e[e.GeneralizedTime=21]=`GeneralizedTime`,e[e.DATE=22]=`DATE`,e[e.TimeOfDay=23]=`TimeOfDay`,e[e.DateTime=24]=`DateTime`,e[e.Duration=25]=`Duration`,e[e.TIME=26]=`TIME`,e[e.Null=27]=`Null`})(F||={});var f_=class{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e==`number`)this.fromNumber(e);else if(M.BufferSourceConverter.isBufferSource(e))this.unusedBits=t,this.value=M.BufferSourceConverter.toArrayBuffer(e);else throw TypeError(`Unsupported type of 'params' argument for BitString`)}fromASN(e){if(!(e instanceof Jh))throw 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 Jh({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Jh({name:e})}toNumber(){let e=``,t=new Uint8Array(this.value);for(let 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),n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;let r=new Uint8Array(n);t=t.padStart(n<<3,`0`).split(``).reverse().join(``);let i=0;for(;i<n;)r[i]=parseInt(t.slice(i<<3,(i<<3)+8),2),i++;this.value=r.buffer}},I=class{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e==`number`?this.buffer=new ArrayBuffer(e):M.BufferSourceConverter.isBufferSource(e)?this.buffer=M.BufferSourceConverter.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof Gh))throw TypeError(`Argument 'asn' is not instance of ASN.1 OctetString`);return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Gh({valueHex:this.buffer})}toSchema(e){return new Gh({name:e})}},p_={fromASN:e=>e instanceof zh?null:e.valueBeforeDecodeView,toASN:e=>{if(e===null)return new zh;let t=Ah(e);if(t.result.error)throw Error(t.result.error);return t.result}},m_={fromASN:e=>e.valueBlock.valueHexView.byteLength>=4?e.valueBlock.toString():e.valueBlock.valueDec,toASN:e=>new tg({value:+e})},h_={fromASN:e=>e.valueBlock.valueDec,toASN:e=>new rg({value:e})},L={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new tg({valueHex:e})},g_={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new Jh({valueHex:e})},__={fromASN:e=>e.valueBlock.toString(),toASN:e=>new sg({value:e})},v_={fromASN:e=>e.valueBlock.value,toASN:e=>new Hh({value:e})},y_={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new Gh({valueHex:e})},b_={fromASN:e=>new I(e.getValue()),toASN:e=>e.toASN()};function x_(e){return{fromASN:e=>e.valueBlock.value,toASN:t=>new e({value:t})}}var S_=x_(xg),C_=x_(wg),w_=x_(Dg),T_=x_(kg),E_=x_(jg),D_=x_(Ng),O_=x_(Fg),k_=x_(Lg),A_=x_(zg),j_=x_(Vg),M_=x_(Ug),N_=x_(Gg),P_={fromASN:e=>e.toDate(),toASN:e=>new qg({valueDate:e})},F_={fromASN:e=>e.toDate(),toASN:e=>new Yg({valueDate:e})},I_={fromASN:()=>null,toASN:()=>new zh};function L_(e){switch(e){case F.Any:return p_;case F.BitString:return g_;case F.BmpString:return C_;case F.Boolean:return v_;case F.CharacterString:return N_;case F.Enumerated:return h_;case F.GeneralString:return M_;case F.GeneralizedTime:return F_;case F.GraphicString:return A_;case F.IA5String:return k_;case F.Integer:return m_;case F.Null:return I_;case F.NumericString:return T_;case F.ObjectIdentifier:return __;case F.OctetString:return y_;case F.PrintableString:return E_;case F.TeletexString:return D_;case F.UTCTime:return P_;case F.UniversalString:return w_;case F.Utf8String:return S_;case F.VideotexString:return O_;case F.VisibleString:return j_;default:return null}}function R_(e){return typeof e==`function`&&e.prototype?e.prototype.toASN&&e.prototype.fromASN?!0:R_(e.prototype):!!(e&&typeof e==`object`&&`toASN`in e&&`fromASN`in e)}function z_(e){if(e){let t=Object.getPrototypeOf(e);return t?.prototype?.constructor===Array?!0:z_(t)}return!1}function B_(e,t){if(!(e&&t)||e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(n[t]!==r[t])return!1;return!0}var V_=new class{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){let n=this.items.get(e);if(!n)throw Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){let t=this.get(e);t.schema||=this.create(e,!0)}createDefault(e){let t={type:P.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){let n=this.items.get(e)||this.createDefault(e),r=[];for(let e in n.items){let i=n.items[e],a=t?e:``,o;if(typeof i.type==`number`){let e=F[i.type],t=Jm[e];if(!t)throw Error(`Cannot get ASN1 class by name '${e}'`);o=new t({name:a})}else R_(i.type)?o=new i.type().toSchema(a):i.optional?this.get(i.type).type===P.Choice?o=new o_({name:a}):(o=this.create(i.type,!1),o.name=a):o=new o_({name:a});let s=!!i.optional||i.defaultValue!==void 0;if(i.repeated&&(o.name=``,o=new(i.repeated===`set`?hg:pg)({name:``,value:[new c_({name:a,value:o})]})),i.context!==null&&i.context!==void 0)if(i.implicit)if(typeof i.type==`number`||R_(i.type)){let e=i.repeated?Ph:Dh;r.push(new e({name:a,optional:s,idBlock:{tagClass:3,tagNumber:i.context}}))}else{this.cache(i.type);let e=!!i.repeated,t=e?o:this.get(i.type,!0).schema;t=`valueBlock`in t?t.valueBlock.value:t.value,r.push(new Ph({name:e?``:a,optional:s,idBlock:{tagClass:3,tagNumber:i.context},value:t}))}else r.push(new Ph({optional:s,idBlock:{tagClass:3,tagNumber:i.context},value:[o]}));else o.optional=s,r.push(o)}switch(n.type){case P.Sequence:return new pg({value:r,name:``});case P.Set:return new hg({value:r,name:``});case P.Choice:return new s_({value:r,name:``});default:throw Error(`Unsupported ASN1 type in use`)}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){let t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}},R=e=>t=>{let n;V_.has(t)?n=V_.get(t):(n=V_.createDefault(t),V_.set(t,n)),Object.assign(n,e)},z=e=>(t,n)=>{let r;V_.has(t.constructor)?r=V_.get(t.constructor):(r=V_.createDefault(t.constructor),V_.set(t.constructor,r));let i=Object.assign({},e);if(typeof i.type==`number`&&!i.converter){let r=L_(e.type);if(!r)throw Error(`Cannot get default converter for property '${n}' of ${t.constructor.name}`);i.converter=r}i.raw=e.raw,r.items[n]=i},H_=class extends Error{constructor(){super(...arguments),this.schemas=[]}},U_=class{static parse(e,t){let n=Ah(e);if(n.result.error)throw Error(n.result.error);return this.fromASN(n.result,t)}static fromASN(e,t){try{if(R_(t))return new t().fromASN(e);let n=V_.get(t);V_.cache(t);let r=n.schema,i=this.handleChoiceTypes(e,n,t,r);if(i?.result)return i.result;i?.targetSchema&&(r=i.targetSchema);let a=this.handleSequenceTypes(e,n,t,r),o=new t;return z_(t)?this.handleArrayTypes(e,n,t):(this.processSchemaItems(n,a,o),o)}catch(e){throw e instanceof H_&&e.schemas.push(t.name),e}}static handleChoiceTypes(e,t,n,r){if(e.constructor===Ph&&t.type===P.Choice&&e.idBlock.tagClass===3)for(let r in t.items){let i=t.items[r];if(i.context===e.idBlock.tagNumber&&i.implicit&&typeof i.type==`function`&&V_.has(i.type)){let t=V_.get(i.type);if(t&&t.type===P.Sequence){let t=new pg;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock){t.valueBlock.value=e.valueBlock.value;let a=this.fromASN(t,i.type),o=new n;return o[r]=a,{result:o}}}}}else if(e.constructor===Ph&&t.type!==P.Choice){let n=new Ph({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:t.schema.valueBlock.value});for(let n in t.items)delete e[n];return{targetSchema:n}}return null}static handleSequenceTypes(e,t,n,r){if(t.type===P.Sequence){let t=u_({},e,r);if(!t.verified)throw new H_(`Data does not match to ${n.name} ASN1 schema.${t.result.error?` ${t.result.error}`:``}`);return t}else{let t=u_({},e,r);if(!t.verified)throw new H_(`Data does not match to ${n.name} ASN1 schema.${t.result.error?` ${t.result.error}`:``}`);return t}}static processRepeatedField(e,t,n){let r=e.slice(t);if(r.length===1&&r[0].constructor.name===`Sequence`){let e=r[0];e.valueBlock&&e.valueBlock.value&&Array.isArray(e.valueBlock.value)&&(r=e.valueBlock.value)}if(typeof n.type==`number`){let e=L_(n.type);if(!e)throw Error(`No converter for ASN.1 type ${n.type}`);return r.filter(e=>e&&e.valueBlock).map(t=>{try{return e.fromASN(t)}catch{return}}).filter(e=>e!==void 0)}else return r.filter(e=>e&&e.valueBlock).map(e=>{try{return this.fromASN(e,n.type)}catch{return}}).filter(e=>e!==void 0)}static processPrimitiveField(e,t){let n=L_(t.type);if(!n)throw Error(`No converter for ASN.1 type ${t.type}`);return n.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type==`function`&&V_.has(e.type)&&V_.get(e.type).type===P.Choice}static processOptionalChoiceField(e,t){try{return{processed:!0,value:this.fromASN(e,t.type)}}catch(e){if(e instanceof H_&&/Wrong values for Choice type/.test(e.message))return{processed:!1};throw e}}static handleArrayTypes(e,t,n){if(!(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);let r=t.itemType;if(typeof r==`number`){let t=L_(r);if(!t)throw Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,e=>t.fromASN(e))}else return n.from(e.valueBlock.value,e=>this.fromASN(e,r))}static processSchemaItems(e,t,n){for(let r in e.items){let i=t.result[r];if(!i)continue;let a=e.items[r],o=a.type,s;s=typeof o==`number`||R_(o)?this.processPrimitiveSchemaItem(i,a,o):this.processComplexSchemaItem(i,a,o),s&&typeof s==`object`&&`value`in s&&`raw`in s?(n[r]=s.value,n[`${r}Raw`]=s.raw):n[r]=s}}static processPrimitiveSchemaItem(e,t,n){let r=t.converter??(R_(n)?new n:null);if(!r)throw Error(`Converter is empty`);return t.repeated?this.processRepeatedPrimitiveItem(e,t,r):this.processSinglePrimitiveItem(e,t,n,r)}static processRepeatedPrimitiveItem(e,t,n){if(t.implicit){let r=new(t.repeated===`sequence`?pg:hg);r.valueBlock=e.valueBlock;let i=Ah(r.toBER(!1));if(i.offset===-1)throw Error(`Cannot parse the child item. ${i.result.error}`);if(!(`value`in i.result.valueBlock&&Array.isArray(i.result.valueBlock.value)))throw Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);let a=i.result.valueBlock.value;return Array.from(a,e=>n.fromASN(e))}else return Array.from(e,e=>n.fromASN(e))}static processSinglePrimitiveItem(e,t,n,r){let i=e;if(t.implicit){let e;if(R_(n))e=new n().toSchema(``);else{let t=F[n],r=Jm[t];if(!r)throw Error(`Cannot get '${t}' class from asn1js module`);e=new r}e.valueBlock=i.valueBlock,i=Ah(e.toBER(!1)).result}return r.fromASN(i)}static processComplexSchemaItem(e,t,n){if(t.repeated){if(!Array.isArray(e))throw Error(`Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.`);return Array.from(e,e=>this.fromASN(e,n))}else{let r=this.handleImplicitTagging(e,t,n);if(this.isOptionalChoiceField(t))try{return this.fromASN(r,n)}catch(e){if(e instanceof H_&&/Wrong values for Choice type/.test(e.message))return;throw e}else{let i=this.fromASN(r,n);return t.raw?{value:i,raw:e.valueBeforeDecodeView}:i}}}static handleImplicitTagging(e,t,n){if(t.implicit&&typeof t.context==`number`){let t=V_.get(n);if(t.type===P.Sequence){let t=new pg;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}else if(t.type===P.Set){let t=new hg;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}}return e}},W_=class e{static serialize(e){return e instanceof Sh?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(t){if(t&&typeof t==`object`&&R_(t))return t.toASN();if(!(t&&typeof t==`object`))throw TypeError(`Parameter 1 should be type of Object.`);let n=t.constructor,r=V_.get(n);V_.cache(n);let i=[];if(r.itemType){if(!Array.isArray(t))throw TypeError(`Parameter 1 should be type of Array.`);if(typeof r.itemType==`number`){let e=L_(r.itemType);if(!e)throw Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);i=t.map(t=>e.toASN(t))}else i=t.map(e=>this.toAsnItem({type:r.itemType},`[]`,n,e))}else for(let a in r.items){let o=r.items[a],s=t[a];if(s===void 0||o.defaultValue===s||typeof o.defaultValue==`object`&&typeof s==`object`&&B_(this.serialize(o.defaultValue),this.serialize(s)))continue;let c=e.toAsnItem(o,a,n,s);if(typeof o.context==`number`)if(o.implicit)if(!o.repeated&&(typeof o.type==`number`||R_(o.type))){let e={};e.valueHex=c instanceof zh?c.valueBeforeDecodeView:c.valueBlock.toBER(),i.push(new Dh({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...e}))}else i.push(new Ph({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:c.valueBlock.value}));else i.push(new Ph({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:[c]}));else o.repeated?i=i.concat(c):i.push(c)}let a;switch(r.type){case P.Sequence:a=new pg({value:i});break;case P.Set:a=new hg({value:i});break;case P.Choice:if(!i[0])throw Error(`Schema '${n.name}' has wrong data. Choice cannot be empty.`);a=i[0];break}return a}static toAsnItem(e,t,n,r){let i;if(typeof e.type==`number`){let a=e.converter;if(!a)throw Error(`Property '${t}' doesn't have converter for type ${F[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(r))throw TypeError(`Parameter 'objProp' should be type of Array.`);let t=Array.from(r,e=>a.toASN(e));i=new(e.repeated===`sequence`?pg:hg)({value:t})}else i=a.toASN(r)}else if(e.repeated){if(!Array.isArray(r))throw TypeError(`Parameter 'objProp' should be type of Array.`);let t=Array.from(r,e=>this.toASN(e));i=new(e.repeated===`sequence`?pg:hg)({value:t})}else i=this.toASN(r);return i}},B=class extends Array{constructor(e=[]){if(typeof e==`number`)super(e);else{super();for(let t of e)this.push(t)}}},V=class e{static serialize(e){return W_.serialize(e)}static parse(e,t){return U_.parse(e,t)}static toString(t){let n=Ah(M.BufferSourceConverter.isBufferSource(t)?M.BufferSourceConverter.toArrayBuffer(t):e.serialize(t));if(n.offset===-1)throw Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}};function H(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function U(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function W(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var G_=class{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){let t=e.split(`.`);if(t.length!==4)throw Error(`Invalid IPv4 address`);return t.map(e=>{let t=parseInt(e,10);if(isNaN(t)||t<0||t>255)throw Error(`Invalid IPv4 address part`);return t})}static parseIPv6(e){let t=this.expandIPv6(e).split(`:`);if(t.length!==8)throw Error(`Invalid IPv6 address`);return t.reduce((e,t)=>{let n=parseInt(t,16);if(isNaN(n)||n<0||n>65535)throw Error(`Invalid IPv6 address part`);return e.push(n>>8&255),e.push(n&255),e},[])}static expandIPv6(e){if(!e.includes(`::`))return e;let t=e.split(`::`);if(t.length>2)throw Error(`Invalid IPv6 address`);let n=t[0]?t[0].split(`:`):[],r=t[1]?t[1].split(`:`):[],i=8-(n.length+r.length);if(i<0)throw Error(`Invalid IPv6 address`);return[...n,...Array(i).fill(`0`),...r].join(`:`)}static formatIPv6(e){let t=[];for(let n=0;n<16;n+=2)t.push((e[n]<<8|e[n+1]).toString(16));return this.compressIPv6(t.join(`:`))}static compressIPv6(e){let t=e.split(`:`),n=-1,r=0,i=-1,a=0;for(let e=0;e<t.length;e++)t[e]===`0`?(i===-1&&(i=e),a++):(a>r&&(n=i,r=a),i=-1,a=0);return a>r&&(n=i,r=a),r>1?`${t.slice(0,n).join(`:`)}::${t.slice(n+r).join(`:`)}`:e}static parseCIDR(e){let[t,n]=e.split(`/`),r=parseInt(n,10);if(this.isIPv4(t)){if(r<0||r>32)throw Error(`Invalid IPv4 prefix length`);return[this.parseIPv4(t),r]}else{if(r<0||r>128)throw Error(`Invalid IPv6 prefix length`);return[this.parseIPv6(t),r]}}static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return`::/0`;if(e.length!==16)return e;let t=parseInt(e.slice(8),16).toString(2).split(``).reduce((e,t)=>e+ +t,0),n=e.slice(0,8).replace(/(.{2})/g,e=>`${parseInt(e,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){let t=new Uint8Array(e);if(t.length===4)return Array.from(t).join(`.`);if(t.length===16)return this.formatIPv6(t);if(t.length===8||t.length===32){let e=t.length/2,n=t.slice(0,e),r=t.slice(e);if(t.every(e=>e===0))return t.length===8?`0.0.0.0/0`:`::/0`;let i=r.reduce((e,t)=>e+(t.toString(2).match(/1/g)||[]).length,0);return t.length===8?`${Array.from(n).join(`.`)}/${i}`:`${this.formatIPv6(n)}/${i}`}return this.decodeIP(M.Convert.ToHex(e))}static fromString(e){if(e.includes(`/`)){let[t,n]=this.parseCIDR(e),r=new Uint8Array(t.length),i=n;for(let e=0;e<r.length;e++)i>=8?(r[e]=255,i-=8):i>0&&(r[e]=255<<8-i,i=0);let a=new Uint8Array(t.length*2);return a.set(t,0),a.set(r,t.length),a.buffer}let t=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(t).buffer}},K_,q_,J_,Y_=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||``}};H([z({type:F.TeletexString})],Y_.prototype,`teletexString`,void 0),H([z({type:F.PrintableString})],Y_.prototype,`printableString`,void 0),H([z({type:F.UniversalString})],Y_.prototype,`universalString`,void 0),H([z({type:F.Utf8String})],Y_.prototype,`utf8String`,void 0),H([z({type:F.BmpString})],Y_.prototype,`bmpString`,void 0),Y_=H([R({type:P.Choice})],Y_);var X_=class extends Y_{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?M.Convert.ToHex(this.anyValue):super.toString())}};H([z({type:F.IA5String})],X_.prototype,`ia5String`,void 0),H([z({type:F.Any})],X_.prototype,`anyValue`,void 0),X_=H([R({type:P.Choice})],X_);var Z_=class{constructor(e={}){this.type=``,this.value=new X_,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Z_.prototype,`type`,void 0),H([z({type:X_})],Z_.prototype,`value`,void 0);var Q_=K_=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,K_.prototype)}};Q_=K_=H([R({type:P.Set,itemType:Z_})],Q_);var $_=q_=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,q_.prototype)}};$_=q_=H([R({type:P.Sequence,itemType:Q_})],$_);var G=J_=class extends $_{constructor(e){super(e),Object.setPrototypeOf(this,J_.prototype)}};G=J_=H([R({type:P.Sequence})],G);var ev={fromASN:e=>G_.toString(y_.fromASN(e)),toASN:e=>y_.toASN(G_.fromString(e))},tv=class{constructor(e={}){this.typeId=``,this.value=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],tv.prototype,`typeId`,void 0),H([z({type:F.Any,context:0})],tv.prototype,`value`,void 0);var nv=class{constructor(e={}){this.partyName=new Y_,Object.assign(this,e)}};H([z({type:Y_,optional:!0,context:0,implicit:!0})],nv.prototype,`nameAssigner`,void 0),H([z({type:Y_,context:1,implicit:!0})],nv.prototype,`partyName`,void 0);var K=class{constructor(e={}){Object.assign(this,e)}};H([z({type:tv,context:0,implicit:!0})],K.prototype,`otherName`,void 0),H([z({type:F.IA5String,context:1,implicit:!0})],K.prototype,`rfc822Name`,void 0),H([z({type:F.IA5String,context:2,implicit:!0})],K.prototype,`dNSName`,void 0),H([z({type:F.Any,context:3,implicit:!0})],K.prototype,`x400Address`,void 0),H([z({type:G,context:4,implicit:!1})],K.prototype,`directoryName`,void 0),H([z({type:nv,context:5})],K.prototype,`ediPartyName`,void 0),H([z({type:F.IA5String,context:6,implicit:!0})],K.prototype,`uniformResourceIdentifier`,void 0),H([z({type:F.OctetString,context:7,implicit:!0,converter:ev})],K.prototype,`iPAddress`,void 0),H([z({type:F.ObjectIdentifier,context:8,implicit:!0})],K.prototype,`registeredID`,void 0),K=H([R({type:P.Choice})],K);var rv=`1.3.6.1.5.5.7`,iv=`${rv}.1`,av=`${rv}.2`,ov=`${rv}.3`,sv=`${rv}.48`;`${av}`,`${av}`;var cv=`${sv}.1`,lv=`${sv}.2`,uv=`${sv}.3`,dv=`${sv}.5`,q=`2.5.29`,fv,pv=`${iv}.1`,mv=class{constructor(e={}){this.accessMethod=``,this.accessLocation=new K,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],mv.prototype,`accessMethod`,void 0),H([z({type:K})],mv.prototype,`accessLocation`,void 0);var hv=fv=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,fv.prototype)}};hv=fv=H([R({type:P.Sequence,itemType:mv})],hv);var gv=`${q}.35`,_v=class extends I{},vv=class{constructor(e={}){e&&Object.assign(this,e)}};H([z({type:_v,context:0,optional:!0,implicit:!0})],vv.prototype,`keyIdentifier`,void 0),H([z({type:K,context:1,optional:!0,implicit:!0,repeated:`sequence`})],vv.prototype,`authorityCertIssuer`,void 0),H([z({type:F.Integer,context:2,optional:!0,implicit:!0,converter:L})],vv.prototype,`authorityCertSerialNumber`,void 0);var yv=`${q}.19`,bv=class{constructor(e={}){this.cA=!1,Object.assign(this,e)}};H([z({type:F.Boolean,defaultValue:!1})],bv.prototype,`cA`,void 0),H([z({type:F.Integer,optional:!0})],bv.prototype,`pathLenConstraint`,void 0);var xv,Sv=xv=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,xv.prototype)}};Sv=xv=H([R({type:P.Sequence,itemType:K})],Sv);var Cv;`${q}`;var wv=Cv=class extends Sv{constructor(e){super(e),Object.setPrototypeOf(this,Cv.prototype)}};wv=Cv=H([R({type:P.Sequence})],wv);var Tv,Ev=`${q}.32`;`${Ev}`;var Dv=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||``}};H([z({type:F.IA5String})],Dv.prototype,`ia5String`,void 0),H([z({type:F.VisibleString})],Dv.prototype,`visibleString`,void 0),H([z({type:F.BmpString})],Dv.prototype,`bmpString`,void 0),H([z({type:F.Utf8String})],Dv.prototype,`utf8String`,void 0),Dv=H([R({type:P.Choice})],Dv);var Ov=class{constructor(e={}){this.organization=new Dv,this.noticeNumbers=[],Object.assign(this,e)}};H([z({type:Dv})],Ov.prototype,`organization`,void 0),H([z({type:F.Integer,repeated:`sequence`})],Ov.prototype,`noticeNumbers`,void 0);var kv=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Ov,optional:!0})],kv.prototype,`noticeRef`,void 0),H([z({type:Dv,optional:!0})],kv.prototype,`explicitText`,void 0);var Av=class{constructor(e={}){Object.assign(this,e)}};H([z({type:F.IA5String})],Av.prototype,`cPSuri`,void 0),H([z({type:kv})],Av.prototype,`userNotice`,void 0),Av=H([R({type:P.Choice})],Av);var jv=class{constructor(e={}){this.policyQualifierId=``,this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],jv.prototype,`policyQualifierId`,void 0),H([z({type:F.Any})],jv.prototype,`qualifier`,void 0);var Mv=class{constructor(e={}){this.policyIdentifier=``,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Mv.prototype,`policyIdentifier`,void 0),H([z({type:jv,repeated:`sequence`,optional:!0})],Mv.prototype,`policyQualifiers`,void 0);var Nv=Tv=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Tv.prototype)}};Nv=Tv=H([R({type:P.Sequence,itemType:Mv})],Nv),`${q}`;var Pv=class{constructor(e=0){this.value=e}};H([z({type:F.Integer})],Pv.prototype,`value`,void 0),Pv=H([R({type:P.Choice})],Pv),`${q}`;var Fv=class extends Pv{};Fv=H([R({type:P.Choice})],Fv);var Iv,Lv=`${q}.31`,Rv;(function(e){e[e.unused=1]=`unused`,e[e.keyCompromise=2]=`keyCompromise`,e[e.cACompromise=4]=`cACompromise`,e[e.affiliationChanged=8]=`affiliationChanged`,e[e.superseded=16]=`superseded`,e[e.cessationOfOperation=32]=`cessationOfOperation`,e[e.certificateHold=64]=`certificateHold`,e[e.privilegeWithdrawn=128]=`privilegeWithdrawn`,e[e.aACompromise=256]=`aACompromise`})(Rv||={});var zv=class extends f_{toJSON(){let e=[],t=this.toNumber();return t&Rv.aACompromise&&e.push(`aACompromise`),t&Rv.affiliationChanged&&e.push(`affiliationChanged`),t&Rv.cACompromise&&e.push(`cACompromise`),t&Rv.certificateHold&&e.push(`certificateHold`),t&Rv.cessationOfOperation&&e.push(`cessationOfOperation`),t&Rv.keyCompromise&&e.push(`keyCompromise`),t&Rv.privilegeWithdrawn&&e.push(`privilegeWithdrawn`),t&Rv.superseded&&e.push(`superseded`),t&Rv.unused&&e.push(`unused`),e}toString(){return`[${this.toJSON().join(`, `)}]`}},Bv=class{constructor(e={}){Object.assign(this,e)}};H([z({type:K,context:0,repeated:`sequence`,implicit:!0})],Bv.prototype,`fullName`,void 0),H([z({type:Q_,context:1,implicit:!0})],Bv.prototype,`nameRelativeToCRLIssuer`,void 0),Bv=H([R({type:P.Choice})],Bv);var Vv=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Bv,context:0,optional:!0})],Vv.prototype,`distributionPoint`,void 0),H([z({type:zv,context:1,optional:!0,implicit:!0})],Vv.prototype,`reasons`,void 0),H([z({type:K,context:2,optional:!0,repeated:`sequence`,implicit:!0})],Vv.prototype,`cRLIssuer`,void 0);var Hv=Iv=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Iv.prototype)}};Hv=Iv=H([R({type:P.Sequence,itemType:Vv})],Hv);var Uv;`${q}`;var Wv=Uv=class extends Hv{constructor(e){super(e),Object.setPrototypeOf(this,Uv.prototype)}};Wv=Uv=H([R({type:P.Sequence,itemType:Vv})],Wv),`${q}`;var Gv=class e{constructor(t={}){this.onlyContainsUserCerts=e.ONLY,this.onlyContainsCACerts=e.ONLY,this.indirectCRL=e.ONLY,this.onlyContainsAttributeCerts=e.ONLY,Object.assign(this,t)}};Gv.ONLY=!1,H([z({type:Bv,context:0,optional:!0})],Gv.prototype,`distributionPoint`,void 0),H([z({type:F.Boolean,context:1,defaultValue:Gv.ONLY,implicit:!0})],Gv.prototype,`onlyContainsUserCerts`,void 0),H([z({type:F.Boolean,context:2,defaultValue:Gv.ONLY,implicit:!0})],Gv.prototype,`onlyContainsCACerts`,void 0),H([z({type:zv,context:3,optional:!0,implicit:!0})],Gv.prototype,`onlySomeReasons`,void 0),H([z({type:F.Boolean,context:4,defaultValue:Gv.ONLY,implicit:!0})],Gv.prototype,`indirectCRL`,void 0),H([z({type:F.Boolean,context:5,defaultValue:Gv.ONLY,implicit:!0})],Gv.prototype,`onlyContainsAttributeCerts`,void 0);var Kv=`${q}.21`,qv;(function(e){e[e.unspecified=0]=`unspecified`,e[e.keyCompromise=1]=`keyCompromise`,e[e.cACompromise=2]=`cACompromise`,e[e.affiliationChanged=3]=`affiliationChanged`,e[e.superseded=4]=`superseded`,e[e.cessationOfOperation=5]=`cessationOfOperation`,e[e.certificateHold=6]=`certificateHold`,e[e.removeFromCRL=8]=`removeFromCRL`,e[e.privilegeWithdrawn=9]=`privilegeWithdrawn`,e[e.aACompromise=10]=`aACompromise`})(qv||={});var Jv=class{constructor(e=qv.unspecified){this.reason=qv.unspecified,this.reason=e}toJSON(){return qv[this.reason]}toString(){return this.toJSON()}};H([z({type:F.Enumerated})],Jv.prototype,`reason`,void 0),Jv=H([R({type:P.Choice})],Jv);var Yv,Xv=`${q}.37`,Zv=Yv=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Yv.prototype)}};Zv=Yv=H([R({type:P.Sequence,itemType:F.ObjectIdentifier})],Zv),`${Xv}`;var Qv=`${ov}.1`,$v=`${ov}.2`,ey=`${ov}.3`,ty=`${ov}.4`,ny=`${ov}.8`,ry=`${ov}.9`;`${q}`;var iy=class{constructor(e=new ArrayBuffer(0)){this.value=e}};H([z({type:F.Integer,converter:L})],iy.prototype,`value`,void 0),iy=H([R({type:P.Choice})],iy);var ay=`${q}.24`,oy=class{constructor(e){this.value=new Date,e&&(this.value=e)}};H([z({type:F.GeneralizedTime})],oy.prototype,`value`,void 0),oy=H([R({type:P.Choice})],oy);var sy,cy=`${q}.18`,ly=sy=class extends Sv{constructor(e){super(e),Object.setPrototypeOf(this,sy.prototype)}};ly=sy=H([R({type:P.Sequence})],ly);var uy=`${q}.15`,dy;(function(e){e[e.digitalSignature=1]=`digitalSignature`,e[e.nonRepudiation=2]=`nonRepudiation`,e[e.keyEncipherment=4]=`keyEncipherment`,e[e.dataEncipherment=8]=`dataEncipherment`,e[e.keyAgreement=16]=`keyAgreement`,e[e.keyCertSign=32]=`keyCertSign`,e[e.cRLSign=64]=`cRLSign`,e[e.encipherOnly=128]=`encipherOnly`,e[e.decipherOnly=256]=`decipherOnly`})(dy||={});var fy=class extends f_{toJSON(){let e=this.toNumber(),t=[];return e&dy.cRLSign&&t.push(`crlSign`),e&dy.dataEncipherment&&t.push(`dataEncipherment`),e&dy.decipherOnly&&t.push(`decipherOnly`),e&dy.digitalSignature&&t.push(`digitalSignature`),e&dy.encipherOnly&&t.push(`encipherOnly`),e&dy.keyAgreement&&t.push(`keyAgreement`),e&dy.keyCertSign&&t.push(`keyCertSign`),e&dy.keyEncipherment&&t.push(`keyEncipherment`),e&dy.nonRepudiation&&t.push(`nonRepudiation`),t}toString(){return`[${this.toJSON().join(`, `)}]`}},py;`${q}`;var my=class{constructor(e={}){this.base=new K,this.minimum=0,Object.assign(this,e)}};H([z({type:K})],my.prototype,`base`,void 0),H([z({type:F.Integer,context:0,defaultValue:0,implicit:!0})],my.prototype,`minimum`,void 0),H([z({type:F.Integer,context:1,optional:!0,implicit:!0})],my.prototype,`maximum`,void 0);var hy=py=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,py.prototype)}};hy=py=H([R({type:P.Sequence,itemType:my})],hy);var gy=class{constructor(e={}){Object.assign(this,e)}};H([z({type:hy,context:0,optional:!0,implicit:!0})],gy.prototype,`permittedSubtrees`,void 0),H([z({type:hy,context:1,optional:!0,implicit:!0})],gy.prototype,`excludedSubtrees`,void 0),`${q}`;var _y=class{constructor(e={}){Object.assign(this,e)}};H([z({type:F.Integer,context:0,implicit:!0,optional:!0,converter:L})],_y.prototype,`requireExplicitPolicy`,void 0),H([z({type:F.Integer,context:1,implicit:!0,optional:!0,converter:L})],_y.prototype,`inhibitPolicyMapping`,void 0);var vy;`${q}`;var yy=class{constructor(e={}){this.issuerDomainPolicy=``,this.subjectDomainPolicy=``,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],yy.prototype,`issuerDomainPolicy`,void 0),H([z({type:F.ObjectIdentifier})],yy.prototype,`subjectDomainPolicy`,void 0);var by=vy=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,vy.prototype)}};by=vy=H([R({type:P.Sequence,itemType:yy})],by);var xy,Sy=`${q}.17`,Cy=xy=class extends Sv{constructor(e){super(e),Object.setPrototypeOf(this,xy.prototype)}};Cy=xy=H([R({type:P.Sequence})],Cy);var wy=class{constructor(e={}){this.type=``,this.values=[],Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],wy.prototype,`type`,void 0),H([z({type:F.Any,repeated:`set`})],wy.prototype,`values`,void 0);var Ty;`${q}`;var Ey=Ty=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Ty.prototype)}};Ey=Ty=H([R({type:P.Sequence,itemType:wy})],Ey);var Dy=`${q}.14`,Oy=class extends _v{};`${q}`;var ky=class{constructor(e={}){Object.assign(this,e)}};H([z({type:F.GeneralizedTime,context:0,implicit:!0,optional:!0})],ky.prototype,`notBefore`,void 0),H([z({type:F.GeneralizedTime,context:1,implicit:!0,optional:!0})],ky.prototype,`notAfter`,void 0);var Ay;(function(e){e[e.keyUpdateAllowed=1]=`keyUpdateAllowed`,e[e.newExtensions=2]=`newExtensions`,e[e.pKIXCertificate=4]=`pKIXCertificate`})(Ay||={});var jy=class extends f_{toJSON(){let e=[],t=this.toNumber();return t&Ay.pKIXCertificate&&e.push(`pKIXCertificate`),t&Ay.newExtensions&&e.push(`newExtensions`),t&Ay.keyUpdateAllowed&&e.push(`keyUpdateAllowed`),e}toString(){return`[${this.toJSON().join(`, `)}]`}},My=class{constructor(e={}){this.entrustVers=``,this.entrustInfoFlags=new jy,Object.assign(this,e)}};H([z({type:F.GeneralString})],My.prototype,`entrustVers`,void 0),H([z({type:jy})],My.prototype,`entrustInfoFlags`,void 0);var Ny;`${iv}`;var Py=Ny=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Ny.prototype)}};Py=Ny=H([R({type:P.Sequence,itemType:mv})],Py);var J=class e{constructor(e={}){this.algorithm=``,Object.assign(this,e)}isEqual(t){return t instanceof e&&t.algorithm==this.algorithm&&(t.parameters&&this.parameters&&M.isEqual(t.parameters,this.parameters)||t.parameters===this.parameters)}};H([z({type:F.ObjectIdentifier})],J.prototype,`algorithm`,void 0),H([z({type:F.Any,optional:!0})],J.prototype,`parameters`,void 0);var Fy=class{constructor(e={}){this.algorithm=new J,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:J})],Fy.prototype,`algorithm`,void 0),H([z({type:F.BitString})],Fy.prototype,`subjectPublicKey`,void 0);var Iy=class{constructor(e){if(e)if(typeof e==`string`||typeof e==`number`||e instanceof Date){let t=new Date(e);t.setMilliseconds(0),t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){let e=this.utcTime||this.generalTime;if(!e)throw Error(`Cannot get time from CHOICE object`);return e}};H([z({type:F.UTCTime})],Iy.prototype,`utcTime`,void 0),H([z({type:F.GeneralizedTime})],Iy.prototype,`generalTime`,void 0),Iy=H([R({type:P.Choice})],Iy);var Ly=class{constructor(e){this.notBefore=new Iy(new Date),this.notAfter=new Iy(new Date),e&&(this.notBefore=new Iy(e.notBefore),this.notAfter=new Iy(e.notAfter))}};H([z({type:Iy})],Ly.prototype,`notBefore`,void 0),H([z({type:Iy})],Ly.prototype,`notAfter`,void 0);var Ry,zy=class e{constructor(t={}){this.extnID=``,this.critical=e.CRITICAL,this.extnValue=new I,Object.assign(this,t)}};zy.CRITICAL=!1,H([z({type:F.ObjectIdentifier})],zy.prototype,`extnID`,void 0),H([z({type:F.Boolean,defaultValue:zy.CRITICAL})],zy.prototype,`critical`,void 0),H([z({type:I})],zy.prototype,`extnValue`,void 0);var By=Ry=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Ry.prototype)}};By=Ry=H([R({type:P.Sequence,itemType:zy})],By);var Vy;(function(e){e[e.v1=0]=`v1`,e[e.v2=1]=`v2`,e[e.v3=2]=`v3`})(Vy||={});var Hy=class{constructor(e={}){this.version=Vy.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new J,this.issuer=new G,this.validity=new Ly,this.subject=new G,this.subjectPublicKeyInfo=new Fy,Object.assign(this,e)}};H([z({type:F.Integer,context:0,defaultValue:Vy.v1})],Hy.prototype,`version`,void 0),H([z({type:F.Integer,converter:L})],Hy.prototype,`serialNumber`,void 0),H([z({type:J})],Hy.prototype,`signature`,void 0),H([z({type:G})],Hy.prototype,`issuer`,void 0),H([z({type:Ly})],Hy.prototype,`validity`,void 0),H([z({type:G})],Hy.prototype,`subject`,void 0),H([z({type:Fy})],Hy.prototype,`subjectPublicKeyInfo`,void 0),H([z({type:F.BitString,context:1,implicit:!0,optional:!0})],Hy.prototype,`issuerUniqueID`,void 0),H([z({type:F.BitString,context:2,implicit:!0,optional:!0})],Hy.prototype,`subjectUniqueID`,void 0),H([z({type:By,context:3,optional:!0})],Hy.prototype,`extensions`,void 0);var Uy=class{constructor(e={}){this.tbsCertificate=new Hy,this.signatureAlgorithm=new J,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:Hy,raw:!0})],Uy.prototype,`tbsCertificate`,void 0),H([z({type:J})],Uy.prototype,`signatureAlgorithm`,void 0),H([z({type:F.BitString})],Uy.prototype,`signatureValue`,void 0);var Wy=class{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Iy,Object.assign(this,e)}};H([z({type:F.Integer,converter:L})],Wy.prototype,`userCertificate`,void 0),H([z({type:Iy})],Wy.prototype,`revocationDate`,void 0),H([z({type:zy,optional:!0,repeated:`sequence`})],Wy.prototype,`crlEntryExtensions`,void 0);var Gy=class{constructor(e={}){this.signature=new J,this.issuer=new G,this.thisUpdate=new Iy,Object.assign(this,e)}};H([z({type:F.Integer,optional:!0})],Gy.prototype,`version`,void 0),H([z({type:J})],Gy.prototype,`signature`,void 0),H([z({type:G})],Gy.prototype,`issuer`,void 0),H([z({type:Iy})],Gy.prototype,`thisUpdate`,void 0),H([z({type:Iy,optional:!0})],Gy.prototype,`nextUpdate`,void 0),H([z({type:Wy,repeated:`sequence`,optional:!0})],Gy.prototype,`revokedCertificates`,void 0),H([z({type:zy,optional:!0,context:0,repeated:`sequence`})],Gy.prototype,`crlExtensions`,void 0);var Ky=class{constructor(e={}){this.tbsCertList=new Gy,this.signatureAlgorithm=new J,this.signature=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:Gy,raw:!0})],Ky.prototype,`tbsCertList`,void 0),H([z({type:J})],Ky.prototype,`signatureAlgorithm`,void 0),H([z({type:F.BitString})],Ky.prototype,`signature`,void 0);var qy=class{constructor(e={}){this.issuer=new G,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:G})],qy.prototype,`issuer`,void 0),H([z({type:F.Integer,converter:L})],qy.prototype,`serialNumber`,void 0);var Jy=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Oy,context:0,implicit:!0})],Jy.prototype,`subjectKeyIdentifier`,void 0),H([z({type:qy})],Jy.prototype,`issuerAndSerialNumber`,void 0),Jy=H([R({type:P.Choice})],Jy);var Yy;(function(e){e[e.v0=0]=`v0`,e[e.v1=1]=`v1`,e[e.v2=2]=`v2`,e[e.v3=3]=`v3`,e[e.v4=4]=`v4`,e[e.v5=5]=`v5`})(Yy||={});var Xy=class extends J{};Xy=H([R({type:P.Sequence})],Xy);var Zy=class extends J{};Zy=H([R({type:P.Sequence})],Zy);var Qy=class extends J{};Qy=H([R({type:P.Sequence})],Qy);var $y=class extends J{};$y=H([R({type:P.Sequence})],$y);var eb=class extends J{};eb=H([R({type:P.Sequence})],eb);var tb=class extends J{};tb=H([R({type:P.Sequence})],tb);var nb=class{constructor(e={}){this.attrType=``,this.attrValues=[],Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],nb.prototype,`attrType`,void 0),H([z({type:F.Any,repeated:`set`})],nb.prototype,`attrValues`,void 0);var rb,ib=class{constructor(e={}){this.version=Yy.v0,this.sid=new Jy,this.digestAlgorithm=new Xy,this.signatureAlgorithm=new Zy,this.signature=new I,Object.assign(this,e)}};H([z({type:F.Integer})],ib.prototype,`version`,void 0),H([z({type:Jy})],ib.prototype,`sid`,void 0),H([z({type:Xy})],ib.prototype,`digestAlgorithm`,void 0),H([z({type:nb,repeated:`set`,context:0,implicit:!0,optional:!0,raw:!0})],ib.prototype,`signedAttrs`,void 0),H([z({type:Zy})],ib.prototype,`signatureAlgorithm`,void 0),H([z({type:I})],ib.prototype,`signature`,void 0),H([z({type:nb,repeated:`set`,context:1,implicit:!0,optional:!0})],ib.prototype,`unsignedAttrs`,void 0);var ab=rb=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,rb.prototype)}};ab=rb=H([R({type:P.Set,itemType:ib})],ab);var ob=class extends ib{};ob=H([R({type:P.Sequence})],ob);var sb=class extends Iy{};sb=H([R({type:P.Choice})],sb);var cb=class{constructor(e={}){this.acIssuer=new K,this.acSerial=0,this.attrs=[],Object.assign(this,e)}};H([z({type:K})],cb.prototype,`acIssuer`,void 0),H([z({type:F.Integer})],cb.prototype,`acSerial`,void 0),H([z({type:wy,repeated:`sequence`})],cb.prototype,`attrs`,void 0);var lb,ub=lb=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,lb.prototype)}};ub=lb=H([R({type:P.Sequence,itemType:F.ObjectIdentifier})],ub);var db=class{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}};H([z({type:F.Integer,optional:!0})],db.prototype,`pathLenConstraint`,void 0),H([z({type:ub,implicit:!0,context:0,optional:!0})],db.prototype,`permittedAttrs`,void 0),H([z({type:ub,implicit:!0,context:1,optional:!0})],db.prototype,`excludedAttrs`,void 0),H([z({type:F.Boolean,defaultValue:!0})],db.prototype,`permitUnSpecified`,void 0);var fb=class{constructor(e={}){this.issuer=new Sv,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:Sv})],fb.prototype,`issuer`,void 0),H([z({type:F.Integer,converter:L})],fb.prototype,`serial`,void 0),H([z({type:F.BitString,optional:!0})],fb.prototype,`issuerUID`,void 0);var pb;(function(e){e[e.publicKey=0]=`publicKey`,e[e.publicKeyCert=1]=`publicKeyCert`,e[e.otherObjectTypes=2]=`otherObjectTypes`})(pb||={});var mb=class{constructor(e={}){this.digestedObjectType=pb.publicKey,this.digestAlgorithm=new J,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.Enumerated})],mb.prototype,`digestedObjectType`,void 0),H([z({type:F.ObjectIdentifier,optional:!0})],mb.prototype,`otherObjectTypeID`,void 0),H([z({type:J})],mb.prototype,`digestAlgorithm`,void 0),H([z({type:F.BitString})],mb.prototype,`objectDigest`,void 0);var hb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Sv,optional:!0})],hb.prototype,`issuerName`,void 0),H([z({type:fb,context:0,implicit:!0,optional:!0})],hb.prototype,`baseCertificateID`,void 0),H([z({type:mb,context:1,implicit:!0,optional:!0})],hb.prototype,`objectDigestInfo`,void 0);var gb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:K,repeated:`sequence`})],gb.prototype,`v1Form`,void 0),H([z({type:hb,context:0,implicit:!0})],gb.prototype,`v2Form`,void 0),gb=H([R({type:P.Choice})],gb);var _b=class{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}};H([z({type:F.GeneralizedTime})],_b.prototype,`notBeforeTime`,void 0),H([z({type:F.GeneralizedTime})],_b.prototype,`notAfterTime`,void 0);var vb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:fb,implicit:!0,context:0,optional:!0})],vb.prototype,`baseCertificateID`,void 0),H([z({type:Sv,implicit:!0,context:1,optional:!0})],vb.prototype,`entityName`,void 0),H([z({type:mb,implicit:!0,context:2,optional:!0})],vb.prototype,`objectDigestInfo`,void 0);var yb;(function(e){e[e.v2=1]=`v2`})(yb||={});var bb=class{constructor(e={}){this.version=yb.v2,this.holder=new vb,this.issuer=new gb,this.signature=new J,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new _b,this.attributes=[],Object.assign(this,e)}};H([z({type:F.Integer})],bb.prototype,`version`,void 0),H([z({type:vb})],bb.prototype,`holder`,void 0),H([z({type:gb})],bb.prototype,`issuer`,void 0),H([z({type:J})],bb.prototype,`signature`,void 0),H([z({type:F.Integer,converter:L})],bb.prototype,`serialNumber`,void 0),H([z({type:_b})],bb.prototype,`attrCertValidityPeriod`,void 0),H([z({type:wy,repeated:`sequence`})],bb.prototype,`attributes`,void 0),H([z({type:F.BitString,optional:!0})],bb.prototype,`issuerUniqueID`,void 0),H([z({type:By,optional:!0})],bb.prototype,`extensions`,void 0);var xb=class{constructor(e={}){this.acinfo=new bb,this.signatureAlgorithm=new J,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:bb})],xb.prototype,`acinfo`,void 0),H([z({type:J})],xb.prototype,`signatureAlgorithm`,void 0),H([z({type:F.BitString})],xb.prototype,`signatureValue`,void 0);var Sb;(function(e){e[e.unmarked=1]=`unmarked`,e[e.unclassified=2]=`unclassified`,e[e.restricted=4]=`restricted`,e[e.confidential=8]=`confidential`,e[e.secret=16]=`secret`,e[e.topSecret=32]=`topSecret`})(Sb||={});var Cb=class extends f_{},wb=class{constructor(e={}){this.type=``,this.value=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier,implicit:!0,context:0})],wb.prototype,`type`,void 0),H([z({type:F.Any,implicit:!0,context:1})],wb.prototype,`value`,void 0);var Tb=class{constructor(e={}){this.policyId=``,this.classList=new Cb(Sb.unclassified),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Tb.prototype,`policyId`,void 0),H([z({type:Cb,defaultValue:new Cb(Sb.unclassified)})],Tb.prototype,`classList`,void 0),H([z({type:wb,repeated:`set`})],Tb.prototype,`securityCategories`,void 0);var Eb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:I})],Eb.prototype,`cotets`,void 0),H([z({type:F.ObjectIdentifier})],Eb.prototype,`oid`,void 0),H([z({type:F.Utf8String})],Eb.prototype,`string`,void 0);var Db=class{constructor(e={}){this.values=[],Object.assign(this,e)}};H([z({type:Sv,implicit:!0,context:0,optional:!0})],Db.prototype,`policyAuthority`,void 0),H([z({type:Eb,repeated:`sequence`})],Db.prototype,`values`,void 0),`${iv}`,`${iv}`,`${iv}`,`${q}`;var Ob=`${rv}.10`;`${Ob}`,`${Ob}`,`${Ob}`,`${Ob}`,`${Ob}`;var kb=`2.5.4`;`${kb}`;var Ab,jb=class{constructor(e={}){this.targetCertificate=new fb,Object.assign(this,e)}};H([z({type:fb})],jb.prototype,`targetCertificate`,void 0),H([z({type:K,optional:!0})],jb.prototype,`targetName`,void 0),H([z({type:mb,optional:!0})],jb.prototype,`certDigestInfo`,void 0);var Mb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:K,context:0,implicit:!0})],Mb.prototype,`targetName`,void 0),H([z({type:K,context:1,implicit:!0})],Mb.prototype,`targetGroup`,void 0),H([z({type:jb,context:2,implicit:!0})],Mb.prototype,`targetCert`,void 0),Mb=H([R({type:P.Choice})],Mb);var Nb=Ab=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Ab.prototype)}};Nb=Ab=H([R({type:P.Sequence,itemType:Mb})],Nb);var Pb,Fb=Pb=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Pb.prototype)}};Fb=Pb=H([R({type:P.Sequence,itemType:Nb})],Fb);var Ib=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Sv,implicit:!0,context:0,optional:!0})],Ib.prototype,`roleAuthority`,void 0),H([z({type:K,implicit:!0,context:1})],Ib.prototype,`roleName`,void 0);var Lb=class{constructor(e={}){this.service=new K,this.ident=new K,Object.assign(this,e)}};H([z({type:K})],Lb.prototype,`service`,void 0),H([z({type:K})],Lb.prototype,`ident`,void 0),H([z({type:I,optional:!0})],Lb.prototype,`authInfo`,void 0);var Rb,zb=class{constructor(e={}){this.otherCertFormat=``,this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],zb.prototype,`otherCertFormat`,void 0),H([z({type:F.Any})],zb.prototype,`otherCert`,void 0);var Bb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Uy})],Bb.prototype,`certificate`,void 0),H([z({type:xb,context:2,implicit:!0})],Bb.prototype,`v2AttrCert`,void 0),H([z({type:zb,context:3,implicit:!0})],Bb.prototype,`other`,void 0),Bb=H([R({type:P.Choice})],Bb);var Vb=Rb=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Rb.prototype)}};Vb=Rb=H([R({type:P.Set,itemType:Bb})],Vb);var Hb=class{constructor(e={}){this.contentType=``,this.content=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Hb.prototype,`contentType`,void 0),H([z({type:F.Any,context:0})],Hb.prototype,`content`,void 0);var Ub=class{constructor(e={}){Object.assign(this,e)}};H([z({type:I})],Ub.prototype,`single`,void 0),H([z({type:F.Any})],Ub.prototype,`any`,void 0),Ub=H([R({type:P.Choice})],Ub);var Wb=class{constructor(e={}){this.eContentType=``,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Wb.prototype,`eContentType`,void 0),H([z({type:Ub,context:0,optional:!0})],Wb.prototype,`eContent`,void 0);var Gb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:I,context:0,implicit:!0,optional:!0})],Gb.prototype,`value`,void 0),H([z({type:I,converter:b_,context:0,implicit:!0,optional:!0,repeated:`sequence`})],Gb.prototype,`constructedValue`,void 0),Gb=H([R({type:P.Choice})],Gb);var Kb=class{constructor(e={}){this.contentType=``,this.contentEncryptionAlgorithm=new $y,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Kb.prototype,`contentType`,void 0),H([z({type:$y})],Kb.prototype,`contentEncryptionAlgorithm`,void 0),H([z({type:Gb,optional:!0})],Kb.prototype,`encryptedContent`,void 0);var qb=class{constructor(e={}){this.keyAttrId=``,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],qb.prototype,`keyAttrId`,void 0),H([z({type:F.Any,optional:!0})],qb.prototype,`keyAttr`,void 0);var Jb,Yb=class{constructor(e={}){this.subjectKeyIdentifier=new Oy,Object.assign(this,e)}};H([z({type:Oy})],Yb.prototype,`subjectKeyIdentifier`,void 0),H([z({type:F.GeneralizedTime,optional:!0})],Yb.prototype,`date`,void 0),H([z({type:qb,optional:!0})],Yb.prototype,`other`,void 0);var Xb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Yb,context:0,implicit:!0,optional:!0})],Xb.prototype,`rKeyId`,void 0),H([z({type:qy,optional:!0})],Xb.prototype,`issuerAndSerialNumber`,void 0),Xb=H([R({type:P.Choice})],Xb);var Zb=class{constructor(e={}){this.rid=new Xb,this.encryptedKey=new I,Object.assign(this,e)}};H([z({type:Xb})],Zb.prototype,`rid`,void 0),H([z({type:I})],Zb.prototype,`encryptedKey`,void 0);var Qb=Jb=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Jb.prototype)}};Qb=Jb=H([R({type:P.Sequence,itemType:Zb})],Qb);var $b=class{constructor(e={}){this.algorithm=new J,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:J})],$b.prototype,`algorithm`,void 0),H([z({type:F.BitString})],$b.prototype,`publicKey`,void 0);var ex=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Oy,context:0,implicit:!0,optional:!0})],ex.prototype,`subjectKeyIdentifier`,void 0),H([z({type:$b,context:1,implicit:!0,optional:!0})],ex.prototype,`originatorKey`,void 0),H([z({type:qy,optional:!0})],ex.prototype,`issuerAndSerialNumber`,void 0),ex=H([R({type:P.Choice})],ex);var tx=class{constructor(e={}){this.version=Yy.v3,this.originator=new ex,this.keyEncryptionAlgorithm=new Qy,this.recipientEncryptedKeys=new Qb,Object.assign(this,e)}};H([z({type:F.Integer})],tx.prototype,`version`,void 0),H([z({type:ex,context:0})],tx.prototype,`originator`,void 0),H([z({type:I,context:1,optional:!0})],tx.prototype,`ukm`,void 0),H([z({type:Qy})],tx.prototype,`keyEncryptionAlgorithm`,void 0),H([z({type:Qb})],tx.prototype,`recipientEncryptedKeys`,void 0);var nx=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Oy,context:0,implicit:!0})],nx.prototype,`subjectKeyIdentifier`,void 0),H([z({type:qy})],nx.prototype,`issuerAndSerialNumber`,void 0),nx=H([R({type:P.Choice})],nx);var rx=class{constructor(e={}){this.version=Yy.v0,this.rid=new nx,this.keyEncryptionAlgorithm=new Qy,this.encryptedKey=new I,Object.assign(this,e)}};H([z({type:F.Integer})],rx.prototype,`version`,void 0),H([z({type:nx})],rx.prototype,`rid`,void 0),H([z({type:Qy})],rx.prototype,`keyEncryptionAlgorithm`,void 0),H([z({type:I})],rx.prototype,`encryptedKey`,void 0);var ix=class{constructor(e={}){this.keyIdentifier=new I,Object.assign(this,e)}};H([z({type:I})],ix.prototype,`keyIdentifier`,void 0),H([z({type:F.GeneralizedTime,optional:!0})],ix.prototype,`date`,void 0),H([z({type:qb,optional:!0})],ix.prototype,`other`,void 0);var ax=class{constructor(e={}){this.version=Yy.v4,this.kekid=new ix,this.keyEncryptionAlgorithm=new Qy,this.encryptedKey=new I,Object.assign(this,e)}};H([z({type:F.Integer})],ax.prototype,`version`,void 0),H([z({type:ix})],ax.prototype,`kekid`,void 0),H([z({type:Qy})],ax.prototype,`keyEncryptionAlgorithm`,void 0),H([z({type:I})],ax.prototype,`encryptedKey`,void 0);var ox=class{constructor(e={}){this.version=Yy.v0,this.keyEncryptionAlgorithm=new Qy,this.encryptedKey=new I,Object.assign(this,e)}};H([z({type:F.Integer})],ox.prototype,`version`,void 0),H([z({type:tb,context:0,optional:!0})],ox.prototype,`keyDerivationAlgorithm`,void 0),H([z({type:Qy})],ox.prototype,`keyEncryptionAlgorithm`,void 0),H([z({type:I})],ox.prototype,`encryptedKey`,void 0);var sx=class{constructor(e={}){this.oriType=``,this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],sx.prototype,`oriType`,void 0),H([z({type:F.Any})],sx.prototype,`oriValue`,void 0);var cx=class{constructor(e={}){Object.assign(this,e)}};H([z({type:rx,optional:!0})],cx.prototype,`ktri`,void 0),H([z({type:tx,context:1,implicit:!0,optional:!0})],cx.prototype,`kari`,void 0),H([z({type:ax,context:2,implicit:!0,optional:!0})],cx.prototype,`kekri`,void 0),H([z({type:ox,context:3,implicit:!0,optional:!0})],cx.prototype,`pwri`,void 0),H([z({type:sx,context:4,implicit:!0,optional:!0})],cx.prototype,`ori`,void 0),cx=H([R({type:P.Choice})],cx);var lx,ux=lx=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,lx.prototype)}};ux=lx=H([R({type:P.Set,itemType:cx})],ux);var dx,fx=`${rv}.16`;`${fx}`,`${fx}`;var px=class{constructor(e={}){this.otherRevInfoFormat=``,this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],px.prototype,`otherRevInfoFormat`,void 0),H([z({type:F.Any})],px.prototype,`otherRevInfo`,void 0);var mx=class{constructor(e={}){this.other=new px,Object.assign(this,e)}};H([z({type:px,context:1,implicit:!0})],mx.prototype,`other`,void 0),mx=H([R({type:P.Choice})],mx);var hx=dx=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,dx.prototype)}};hx=dx=H([R({type:P.Set,itemType:mx})],hx);var gx=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Vb,context:0,implicit:!0,optional:!0})],gx.prototype,`certs`,void 0),H([z({type:hx,context:1,implicit:!0,optional:!0})],gx.prototype,`crls`,void 0);var _x,vx=_x=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,_x.prototype)}};vx=_x=H([R({type:P.Set,itemType:nb})],vx);var yx=class{constructor(e={}){this.version=Yy.v0,this.recipientInfos=new ux,this.encryptedContentInfo=new Kb,Object.assign(this,e)}};H([z({type:F.Integer})],yx.prototype,`version`,void 0),H([z({type:gx,context:0,implicit:!0,optional:!0})],yx.prototype,`originatorInfo`,void 0),H([z({type:ux})],yx.prototype,`recipientInfos`,void 0),H([z({type:Kb})],yx.prototype,`encryptedContentInfo`,void 0),H([z({type:vx,context:1,implicit:!0,optional:!0})],yx.prototype,`unprotectedAttrs`,void 0);var bx=`1.2.840.113549.1.7.2`,xx,Sx=xx=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,xx.prototype)}};Sx=xx=H([R({type:P.Set,itemType:Xy})],Sx);var Cx=class{constructor(e={}){this.version=Yy.v0,this.digestAlgorithms=new Sx,this.encapContentInfo=new Wb,this.signerInfos=new ab,Object.assign(this,e)}};H([z({type:F.Integer})],Cx.prototype,`version`,void 0),H([z({type:Sx})],Cx.prototype,`digestAlgorithms`,void 0),H([z({type:Wb})],Cx.prototype,`encapContentInfo`,void 0),H([z({type:Vb,context:0,implicit:!0,optional:!0})],Cx.prototype,`certificates`,void 0),H([z({type:hx,context:1,implicit:!0,optional:!0})],Cx.prototype,`crls`,void 0),H([z({type:ab})],Cx.prototype,`signerInfos`,void 0);var wx=`1.2.840.10045.2.1`,Tx=`1.2.840.10045.4.1`,Ex=`1.2.840.10045.4.3.1`,Dx=`1.2.840.10045.4.3.2`,Ox=`1.2.840.10045.4.3.3`,kx=`1.2.840.10045.4.3.4`,Ax=`1.2.840.10045.3.1.7`,jx=`1.3.132.0.34`,Mx=`1.3.132.0.35`;function Nx(e){return new J({algorithm:e})}var Px=Nx(Tx);Nx(Ex);var Fx=Nx(Dx),Ix=Nx(Ox),Lx=Nx(kx),Rx=class{constructor(e={}){Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Rx.prototype,`fieldType`,void 0),H([z({type:F.Any})],Rx.prototype,`parameters`,void 0),Rx=H([R({type:P.Sequence})],Rx);var zx=class extends I{},Bx=class{constructor(e={}){Object.assign(this,e)}};H([z({type:F.OctetString})],Bx.prototype,`a`,void 0),H([z({type:F.OctetString})],Bx.prototype,`b`,void 0),H([z({type:F.BitString,optional:!0})],Bx.prototype,`seed`,void 0),Bx=H([R({type:P.Sequence})],Bx);var Vx;(function(e){e[e.ecpVer1=1]=`ecpVer1`})(Vx||={});var Hx=class{constructor(e={}){this.version=Vx.ecpVer1,Object.assign(this,e)}};H([z({type:F.Integer})],Hx.prototype,`version`,void 0),H([z({type:Rx})],Hx.prototype,`fieldID`,void 0),H([z({type:Bx})],Hx.prototype,`curve`,void 0),H([z({type:zx})],Hx.prototype,`base`,void 0),H([z({type:F.Integer,converter:L})],Hx.prototype,`order`,void 0),H([z({type:F.Integer,optional:!0})],Hx.prototype,`cofactor`,void 0),Hx=H([R({type:P.Sequence})],Hx);var Ux=class{constructor(e={}){Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Ux.prototype,`namedCurve`,void 0),H([z({type:F.Null})],Ux.prototype,`implicitCurve`,void 0),H([z({type:Hx})],Ux.prototype,`specifiedCurve`,void 0),Ux=H([R({type:P.Choice})],Ux);var Wx=class{constructor(e={}){this.version=1,this.privateKey=new I,Object.assign(this,e)}};H([z({type:F.Integer})],Wx.prototype,`version`,void 0),H([z({type:I})],Wx.prototype,`privateKey`,void 0),H([z({type:Ux,context:0,optional:!0})],Wx.prototype,`parameters`,void 0),H([z({type:F.BitString,context:1,optional:!0})],Wx.prototype,`publicKey`,void 0);var Gx=class{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.Integer,converter:L})],Gx.prototype,`r`,void 0),H([z({type:F.Integer,converter:L})],Gx.prototype,`s`,void 0);var Kx=`1.2.840.113549.1.1`,qx=`${Kx}.1`,Jx=`${Kx}.7`,Yx=`${Kx}.9`,Xx=`${Kx}.10`,Zx=`${Kx}.2`,Qx=`${Kx}.4`,$x=`${Kx}.5`,eS=`${Kx}.14`,tS=`${Kx}.11`,nS=`${Kx}.12`,rS=`${Kx}.13`,iS=`${Kx}.15`,aS=`${Kx}.16`,oS=`1.3.14.3.2.26`,sS=`2.16.840.1.101.3.4.2.4`,cS=`2.16.840.1.101.3.4.2.1`,lS=`2.16.840.1.101.3.4.2.2`,uS=`2.16.840.1.101.3.4.2.3`,dS=`2.16.840.1.101.3.4.2.5`,fS=`2.16.840.1.101.3.4.2.6`,pS=`1.2.840.113549.2.2`,mS=`1.2.840.113549.2.5`,hS=`${Kx}.8`;function gS(e){return new J({algorithm:e,parameters:null})}gS(pS),gS(mS);var _S=gS(oS);gS(sS),gS(cS),gS(lS),gS(uS),gS(dS),gS(fS);var vS=new J({algorithm:hS,parameters:V.serialize(_S)}),yS=new J({algorithm:Yx,parameters:V.serialize(y_.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});gS(qx),gS(Zx),gS(Qx),gS($x),gS(iS),gS(aS),gS(nS),gS(rS),gS(iS),gS(aS);var bS=class{constructor(e={}){this.hashAlgorithm=new J(_S),this.maskGenAlgorithm=new J({algorithm:hS,parameters:V.serialize(_S)}),this.pSourceAlgorithm=new J(yS),Object.assign(this,e)}};H([z({type:J,context:0,defaultValue:_S})],bS.prototype,`hashAlgorithm`,void 0),H([z({type:J,context:1,defaultValue:vS})],bS.prototype,`maskGenAlgorithm`,void 0),H([z({type:J,context:2,defaultValue:yS})],bS.prototype,`pSourceAlgorithm`,void 0),new J({algorithm:Jx,parameters:V.serialize(new bS)});var xS=class{constructor(e={}){this.hashAlgorithm=new J(_S),this.maskGenAlgorithm=new J({algorithm:hS,parameters:V.serialize(_S)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}};H([z({type:J,context:0,defaultValue:_S})],xS.prototype,`hashAlgorithm`,void 0),H([z({type:J,context:1,defaultValue:vS})],xS.prototype,`maskGenAlgorithm`,void 0),H([z({type:F.Integer,context:2,defaultValue:20})],xS.prototype,`saltLength`,void 0),H([z({type:F.Integer,context:3,defaultValue:1})],xS.prototype,`trailerField`,void 0),new J({algorithm:Xx,parameters:V.serialize(new xS)});var SS=class{constructor(e={}){this.digestAlgorithm=new J,this.digest=new I,Object.assign(this,e)}};H([z({type:J})],SS.prototype,`digestAlgorithm`,void 0),H([z({type:I})],SS.prototype,`digest`,void 0);var CS,wS=class{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.Integer,converter:L})],wS.prototype,`prime`,void 0),H([z({type:F.Integer,converter:L})],wS.prototype,`exponent`,void 0),H([z({type:F.Integer,converter:L})],wS.prototype,`coefficient`,void 0);var TS=CS=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,CS.prototype)}};TS=CS=H([R({type:P.Sequence,itemType:wS})],TS);var ES=class{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)}};H([z({type:F.Integer})],ES.prototype,`version`,void 0),H([z({type:F.Integer,converter:L})],ES.prototype,`modulus`,void 0),H([z({type:F.Integer,converter:L})],ES.prototype,`publicExponent`,void 0),H([z({type:F.Integer,converter:L})],ES.prototype,`privateExponent`,void 0),H([z({type:F.Integer,converter:L})],ES.prototype,`prime1`,void 0),H([z({type:F.Integer,converter:L})],ES.prototype,`prime2`,void 0),H([z({type:F.Integer,converter:L})],ES.prototype,`exponent1`,void 0),H([z({type:F.Integer,converter:L})],ES.prototype,`exponent2`,void 0),H([z({type:F.Integer,converter:L})],ES.prototype,`coefficient`,void 0),H([z({type:TS,optional:!0})],ES.prototype,`otherPrimeInfos`,void 0);var DS=class{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.Integer,converter:L})],DS.prototype,`modulus`,void 0),H([z({type:F.Integer,converter:L})],DS.prototype,`publicExponent`,void 0);var OS;(function(e){e[e.Transient=0]=`Transient`,e[e.Singleton=1]=`Singleton`,e[e.ResolutionScoped=2]=`ResolutionScoped`,e[e.ContainerScoped=3]=`ContainerScoped`})(OS||={});var kS=OS,AS=function(e,t){return AS=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},AS(e,t)};function jS(e,t){AS(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function MS(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function NS(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(o){if(r)throw TypeError(`Generator is already executing.`);for(;n;)try{if(r=1,i&&(a=o[0]&2?i.return:o[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;switch(i=0,a&&(o=[o[0]&2,a.value]),o[0]){case 0:case 1:a=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1],a=o;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(o);break}a[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e],i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}function PS(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function FS(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function IS(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(FS(arguments[t]));return e}function LS(e){var t=Reflect.getMetadata(`design:paramtypes`,e)||[],n=Reflect.getOwnMetadata(`injectionTokens`,e)||{};return Object.keys(n).forEach(function(e){t[+e]=n[e]}),t}function RS(e){return!!e.useClass}function zS(e){return!!e.useFactory}var BS=function(){function e(e){this.wrap=e,this.reflectMethods=[`get`,`getPrototypeOf`,`setPrototypeOf`,`getOwnPropertyDescriptor`,`defineProperty`,`has`,`set`,`deleteProperty`,`apply`,`construct`,`ownKeys`]}return e.prototype.createProxy=function(e){var t=this,n={},r=!1,i;return new Proxy(n,this.createHandler(function(){return r||=(i=e(t.wrap()),!0),i}))},e.prototype.createHandler=function(e){var t={};return this.reflectMethods.forEach(function(n){t[n]=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t[0]=e(),Reflect[n].apply(void 0,IS(t))}}),t},e}();function VS(e){return typeof e==`string`||typeof e==`symbol`}function HS(e){return typeof e==`object`&&`token`in e&&`multiple`in e}function US(e){return typeof e==`object`&&`token`in e&&`transform`in e}function WS(e){return typeof e==`function`||e instanceof BS}function GS(e){return!!e.useToken}function KS(e){return e.useValue!=null}function qS(e){return RS(e)||KS(e)||GS(e)||zS(e)}var JS=function(){function e(){this._registryMap=new Map}return e.prototype.entries=function(){return this._registryMap.entries()},e.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},e.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},e.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},e.prototype.setAll=function(e,t){this._registryMap.set(e,t)},e.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},e.prototype.clear=function(){this._registryMap.clear()},e.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},e}(),YS=function(e){jS(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(JS),XS=function(){function e(){this.scopedResolutions=new Map}return e}();function ZS(e,t){return e===null?`at position #`+t:`"`+e.split(`,`)[t].trim()+`" at position #`+t}function QS(e,t,n){return n===void 0&&(n=` `),IS([e],t.message.split(`
296
+ `)}`:`${t} :`}};Nh=Ph,N.Constructed=Nh,Ph.NAME=`CONSTRUCTED`;var Fh=class extends yh{fromBER(e,t,n){return t}toBER(e){return fh}};Fh.override=`EndOfContentValueBlock`;var Ih,Lh=class extends Sh{constructor(e={}){super(e,Fh),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Ih=Lh,N.EndOfContent=Ih,Lh.NAME=mh;var Rh,zh=class extends Sh{constructor(e={}){super(e,yh),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){let n=new ArrayBuffer(2);if(!e){let e=new Uint8Array(n);e[0]=5,e[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Rh=zh,N.Null=Rh,zh.NAME=`NULL`;var Bh=class extends _h(yh){get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=M.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,n){let r=M.BufferSourceConverter.toUint8Array(e);return Zm(this,r,t,n)?(this.valueHexView=r.subarray(t,t+n),n>1&&this.warnings.push(`Boolean value encoded in more then 1 octet`),this.isHexOnly=!0,Wm.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Bh.NAME=`BooleanValueBlock`;var Vh,Hh=class extends Sh{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,Bh),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Vh=Hh,N.Boolean=Vh,Hh.NAME=`BOOLEAN`;var Uh=class extends _h(Mh){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let r=0;if(this.isConstructed){if(this.isHexOnly=!1,r=Mh.prototype.fromBER.call(this,e,t,n),r===-1)return r;for(let e=0;e<this.value.length;e++){let t=this.value[e].constructor.NAME;if(t===mh){if(this.isIndefiniteForm)break;return this.error=`EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only`,-1}if(t!==hh)return this.error=`OCTET STRING may consists of OCTET STRINGs only`,-1}}else this.isHexOnly=!0,r=super.fromBER(e,t,n),this.blockLength=n;return r}toBER(e,t){return this.isConstructed?Mh.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Uh.NAME=`OctetStringValueBlock`;var Wh,Gh=class extends Sh{constructor({idBlock:e={},lenBlock:t={},...n}={}){n.isConstructed??=!!n.value?.length,super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Uh),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){let r=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(r.byteLength){let e=kh(r,0,r.byteLength);e.offset!==-1&&e.offset===n&&(this.valueBlock.value=[e.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ph.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${M.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof Wh&&e.push(t.valueBlock.valueHexView);return M.BufferSourceConverter.concat(e)}};Wh=Gh,N.OctetString=Wh,Gh.NAME=hh;var Kh=class extends _h(Mh){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 r=-1;if(this.isConstructed){if(r=Mh.prototype.fromBER.call(this,e,t,n),r===-1)return r;for(let e of this.value){let t=e.constructor.NAME;if(t===mh){if(this.isIndefiniteForm)break;return this.error=`EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only`,-1}if(t!==gh)return this.error=`BIT STRING may consists of BIT STRINGs only`,-1;let n=e.valueBlock;if(this.unusedBits>0&&n.unusedBits>0)return this.error=`Using of "unused bits" inside constructive BIT STRING allowed for least one only`,-1;this.unusedBits=n.unusedBits}return r}let i=M.BufferSourceConverter.toUint8Array(e);if(!Zm(this,i,t,n))return-1;let a=i.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){let e=a.subarray(1);try{if(e.byteLength){let t=kh(e,0,e.byteLength);t.offset!==-1&&t.offset===n-1&&(this.value=[t.result])}}catch{}}return this.valueHexView=a.subarray(1),this.blockLength=a.length,t+n}toBER(e,t){if(this.isConstructed)return Mh.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength){let e=new Uint8Array(1);return e[0]=0,e.buffer}let 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}}};Kh.NAME=`BitStringValueBlock`;var qh,Jh=class extends Sh{constructor({idBlock:e={},lenBlock:t={},...n}={}){n.isConstructed??=!!n.value?.length,super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Kh),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 Ph.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let n of t)e.push(n.toString(2).padStart(8,`0`));let n=e.join(``);return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};qh=Jh,N.BitString=qh,Jh.NAME=gh;var Yh;function Xh(e,t){let n=new Uint8Array([0]),r=new Uint8Array(e),i=new Uint8Array(t),a=r.slice(0),o=a.length-1,s=i.slice(0),c=s.length-1,l=0,u=c<o?o:c,d=0;for(let e=u;e>=0;e--,d++){switch(!0){case d<s.length:l=a[o-d]+s[c-d]+n[0];break;default:l=a[o-d]+n[0]}switch(n[0]=l/10,!0){case d>=a.length:a=Um(new Uint8Array([l%10]),a);break;default:a[o-d]=l%10}}return n[0]>0&&(a=Um(n,a)),a}function Zh(e){if(e>=$m.length)for(let t=$m.length;t<=e;t++){let e=new Uint8Array([0]),n=$m[t-1].slice(0);for(let t=n.length-1;t>=0;t--){let r=new Uint8Array([(n[t]<<1)+e[0]]);e[0]=r[0]/10,n[t]=r[0]%10}e[0]>0&&(n=Um(e,n)),$m.push(n)}return $m[e]}function Qh(e,t){let n=0,r=new Uint8Array(e),i=new Uint8Array(t),a=r.slice(0),o=a.length-1,s=i.slice(0),c=s.length-1,l,u=0;for(let e=c;e>=0;e--,u++)switch(l=a[o-u]-s[c-u]-n,!0){case l<0:n=1,a[o-u]=l+10;break;default:n=0,a[o-u]=l}if(n>0)for(let e=o-c+1;e>=0;e--,u++)if(l=a[o-u]-n,l<0)n=1,a[o-u]=l+10;else{n=0,a[o-u]=l;break}return a.slice()}var $h=class extends _h(yh){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=Wm.call(this)))}constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Gm(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,r=0){let i=this.fromBER(e,t,n);if(i===-1)return i;let a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):r!==0&&a.length<r&&(r-a.length>1&&(r=a.length+1),this.valueHexView=a.subarray(r-a.length)),i}toDER(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!=0:{let e=new Uint8Array(this.valueHexView.length+1);e[0]=0,e.set(t,1),this.valueHexView=e}break;case t[0]===0&&(t[1]&128)==0:this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let r=super.fromBER(e,t,n);return r===-1||this.setValueHex(),r}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,r,i=this.valueHexView,a=``,o=!1;for(let o=i.byteLength-1;o>=0;o--){r=i[o];for(let i=0;i<8;i++){if((r&1)==1)switch(n){case e:t=Qh(Zh(n),t),a=`-`;break;default:t=Xh(t,Zh(n))}n++,r>>=1}}for(let e=0;e<t.length;e++)t[e]&&(o=!0),o&&(a+=eh.charAt(t[e]));return o===!1&&(a+=eh.charAt(0)),a}};Yh=$h,$h.NAME=`IntegerValueBlock`,Object.defineProperty(Yh.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var eg,tg=class extends Sh{constructor(e={}){super(e,$h),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Ym(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Ym();let t=BigInt(e),n=new Qm,r=t.toString(16).replace(/^-/,``),i=new Uint8Array(M.Convert.FromHex(r));if(t<0){let e=new Uint8Array(i.length+(i[0]&128?1:0));e[0]|=128;let r=BigInt(`0x${M.Convert.ToHex(e)}`)+t,a=M.BufferSourceConverter.toUint8Array(M.Convert.FromHex(r.toString(16)));a[0]|=128,n.write(a)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new eg({valueHex:n.final()})}convertToDER(){let e=new eg({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new eg({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};eg=tg,N.Integer=eg,tg.NAME=`INTEGER`;var ng,rg=class extends tg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};ng=rg,N.Enumerated=ng,rg.NAME=`ENUMERATED`;var ig=class extends _h(yh){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let r=M.BufferSourceConverter.toUint8Array(e);if(!Zm(this,r,t,n))return-1;let i=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let e=0;e<n&&(this.valueHexView[e]=i[e]&127,this.blockLength++,i[e]&128);e++);let a=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)a[e]=this.valueHexView[e];return this.valueHexView=a,i[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=Vm(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push(`Too big SID for decoding, hex only`)),t+this.blockLength)}set valueBigInt(e){Ym();let t=BigInt(e).toString(2);for(;t.length%7;)t=`0`+t;let n=new Uint8Array(t.length/7);for(let e=0;e<n.length;e++)n[e]=parseInt(t.slice(e*7,e*7+7),2)+(e+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);let t=this.valueHexView,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=t[e]|128;return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}let t=Hm(this.valueDec,7);if(t.byteLength===0)return this.error=`Error during encoding SID value`,fh;let n=new Uint8Array(t.byteLength);if(!e){let e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=e[t]|128;n[r]=e[r]}return n}toString(){let e=``;if(this.isHexOnly)e=M.Convert.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}}};ig.NAME=`sidBlock`;var ag=class extends yh{constructor({value:e=dh,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){let t=new ig;if(r=t.fromBER(e,r,n),r===-1)return this.blockLength=0,this.error=t.error,r;this.value.length===0&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e){let t=[];for(let n=0;n<this.value.length;n++){let r=this.value[n].toBER(e);if(r.byteLength===0)return this.error=this.value[n].error,fh;t.push(r)}return Xm(t)}fromString(e){this.value=[];let t=0,n=0,r=``,i=!1;do if(n=e.indexOf(`.`,t),r=n===-1?e.substring(t):e.substring(t,n),t=n+1,i){let e=this.value[0],t=0;switch(e.valueDec){case 0:break;case 1:t=40;break;case 2:t=80;break;default:this.value=[];return}let n=parseInt(r,10);if(isNaN(n))return;e.valueDec=n+t,i=!1}else{let e=new ig;if(r>2**53-1)Ym(),e.valueBigInt=BigInt(r);else if(e.valueDec=parseInt(r,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,i=!0),this.value.push(e)}while(n!==-1)}toString(){let e=``,t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let r=this.value[n].toString();n!==0&&(e=`${e}.`),t?(r=`{${r}}`,this.value[n].isFirstSid?e=`2.{${r} - 80}`:e+=r):e+=r}return e}toJSON(){let 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}};ag.NAME=`ObjectIdentifierValueBlock`;var og,sg=class extends Sh{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,ag),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||`empty`}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};og=sg,N.ObjectIdentifier=og,sg.NAME=`OBJECT IDENTIFIER`;var cg=class extends _h(vh){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let r=M.BufferSourceConverter.toUint8Array(e);if(!Zm(this,r,t,n))return-1;let i=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let e=0;e<n&&(this.valueHexView[e]=i[e]&127,this.blockLength++,i[e]&128);e++);let a=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)a[e]=this.valueHexView[e];return this.valueHexView=a,i[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=Vm(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);let t=this.valueHexView,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=t[e]|128;return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}let t=Hm(this.valueDec,7);if(t.byteLength===0)return this.error=`Error during encoding SID value`,fh;let n=new Uint8Array(t.byteLength);if(!e){let e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=e[t]|128;n[r]=e[r]}return n.buffer}toString(){let e=``;return e=this.isHexOnly?M.Convert.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};cg.NAME=`relativeSidBlock`;var lg=class extends yh{constructor({value:e=dh,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){let t=new cg;if(r=t.fromBER(e,r,n),r===-1)return this.blockLength=0,this.error=t.error,r;this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e,t){let n=[];for(let t=0;t<this.value.length;t++){let r=this.value[t].toBER(e);if(r.byteLength===0)return this.error=this.value[t].error,fh;n.push(r)}return Xm(n)}fromString(e){this.value=[];let t=0,n=0,r=``;do{n=e.indexOf(`.`,t),r=n===-1?e.substring(t):e.substring(t,n),t=n+1;let i=new cg;if(i.valueDec=parseInt(r,10),isNaN(i.valueDec))return!0;this.value.push(i)}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 r=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(r=`{${r}}`),e+=r}return e}toJSON(){let 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}};lg.NAME=`RelativeObjectIdentifierValueBlock`;var ug,dg=class extends Sh{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,lg),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||`empty`}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};ug=dg,N.RelativeObjectIdentifier=ug,dg.NAME=`RelativeObjectIdentifier`;var fg,pg=class extends Ph{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};fg=pg,N.Sequence=fg,pg.NAME=`SEQUENCE`;var mg,hg=class extends Ph{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};mg=hg,N.Set=mg,hg.NAME=`SET`;var gg=class extends _h(yh){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=dh}toJSON(){return{...super.toJSON(),value:this.value}}};gg.NAME=`StringValueBlock`;var _g=class extends gg{};_g.NAME=`SimpleStringValueBlock`;var vg=class extends wh{constructor({...e}={}){super(e,_g)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,M.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);this.valueBlock.value=e}};vg.NAME=`SIMPLE STRING`;var yg=class extends vg{fromBuffer(e){this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=M.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=M.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf8String(e)),this.valueBlock.value=e}};yg.NAME=`Utf8StringValueBlock`;var bg,xg=class extends yg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};bg=xg,N.Utf8String=bg,xg.NAME=`UTF8String`;var Sg=class extends vg{fromBuffer(e){this.valueBlock.value=M.Convert.ToUtf16String(e),this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf16String(e))}};Sg.NAME=`BmpStringValueBlock`;var Cg,wg=class extends Sg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Cg=wg,N.BmpString=Cg,wg.NAME=`BMPString`;var Tg=class extends vg{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let e=0;e<n.length;e+=4)n[e]=n[e+3],n[e+1]=n[e+2],n[e+2]=0,n[e+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let r=0;r<t;r++){let t=Hm(e.charCodeAt(r),8),i=new Uint8Array(t);if(i.length>4)continue;let a=4-i.length;for(let e=i.length-1;e>=0;e--)n[r*4+e+a]=i[e]}this.valueBlock.value=e}};Tg.NAME=`UniversalStringValueBlock`;var Eg,Dg=class extends Tg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Eg=Dg,N.UniversalString=Eg,Dg.NAME=`UniversalString`;var Og,kg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Og=kg,N.NumericString=Og,kg.NAME=`NumericString`;var Ag,jg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Ag=jg,N.PrintableString=Ag,jg.NAME=`PrintableString`;var Mg,Ng=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Mg=Ng,N.TeletexString=Mg,Ng.NAME=`TeletexString`;var Pg,Fg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Pg=Fg,N.VideotexString=Pg,Fg.NAME=`VideotexString`;var Ig,Lg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Ig=Lg,N.IA5String=Ig,Lg.NAME=`IA5String`;var Rg,zg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Rg=zg,N.GraphicString=Rg,zg.NAME=`GraphicString`;var Bg,Vg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Bg=Vg,N.VisibleString=Bg,Vg.NAME=`VisibleString`;var Hg,Ug=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Hg=Ug,N.GeneralString=Hg,Ug.NAME=`GeneralString`;var Wg,Gg=class extends vg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Wg=Gg,N.CharacterString=Wg,Gg.NAME=`CharacterString`;var Kg,qg=class extends Vg{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 t=0;t<e.length;t++)this.valueBlock.valueHexView[t]=e.charCodeAt(t)}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,M.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);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){let t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(t===null){this.error=`Wrong input string for conversion`;return}let n=parseInt(t[1],10);n>=50?this.year=1900+n:this.year=2e3+n,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(e=`iso`){if(e===`iso`){let e=Array(7);return e[0]=qm(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=qm(this.month,2),e[2]=qm(this.day,2),e[3]=qm(this.hour,2),e[4]=qm(this.minute,2),e[5]=qm(this.second,2),e[6]=`Z`,e.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}}};Kg=qg,N.UTCTime=Kg,qg.NAME=`UTCTime`;var Jg,Yg=class extends qg{constructor(e={}){super(e),this.millisecond??=0,this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){let e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let t=!1,n=``,r=``,i=0,a,o=0,s=0;if(e[e.length-1]===`Z`)n=e.substring(0,e.length-1),t=!0;else{let t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw Error(`Wrong input string for conversion`);n=e}if(t){if(n.indexOf(`+`)!==-1||n.indexOf(`-`)!==-1)throw Error(`Wrong input string for conversion`)}else{let e=1,t=n.indexOf(`+`),r=``;if(t===-1&&(t=n.indexOf(`-`),e=-1),t!==-1){if(r=n.substring(t+1),n=n.substring(0,t),r.length!==2&&r.length!==4)throw Error(`Wrong input string for conversion`);let i=parseInt(r.substring(0,2),10);if(isNaN(i.valueOf()))throw Error(`Wrong input string for conversion`);if(o=e*i,r.length===4){if(i=parseInt(r.substring(2,4),10),isNaN(i.valueOf()))throw Error(`Wrong input string for conversion`);s=e*i}}}let c=n.indexOf(`.`);if(c===-1&&(c=n.indexOf(`,`)),c!==-1){let e=new Number(`0${n.substring(c)}`);if(isNaN(e.valueOf()))throw Error(`Wrong input string for conversion`);i=e.valueOf(),r=n.substring(0,c)}else r=n;switch(!0){case r.length===8:if(a=/(\d{4})(\d{2})(\d{2})/gi,c!==-1)throw Error(`Wrong input string for conversion`);break;case r.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=60*i;this.minute=Math.floor(e),e=60*(e-this.minute),this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case r.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=60*i;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case r.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=1e3*i;this.millisecond=Math.floor(e)}break;default:throw Error(`Wrong input string for conversion`)}let l=a.exec(r);if(l===null)throw Error(`Wrong input string for conversion`);for(let e=1;e<l.length;e++)switch(e){case 1:this.year=parseInt(l[e],10);break;case 2:this.month=parseInt(l[e],10);break;case 3:this.day=parseInt(l[e],10);break;case 4:this.hour=parseInt(l[e],10)+o;break;case 5:this.minute=parseInt(l[e],10)+s;break;case 6:this.second=parseInt(l[e],10);break;default:throw Error(`Wrong input string for conversion`)}if(t===!1){let e=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=e.getUTCFullYear(),this.month=e.getUTCMonth(),this.day=e.getUTCDay(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds(),this.millisecond=e.getUTCMilliseconds()}}toString(e=`iso`){if(e===`iso`){let e=[];return e.push(qm(this.year,4)),e.push(qm(this.month,2)),e.push(qm(this.day,2)),e.push(qm(this.hour,2)),e.push(qm(this.minute,2)),e.push(qm(this.second,2)),this.millisecond!==0&&(e.push(`.`),e.push(qm(this.millisecond,3))),e.push(`Z`),e.join(``)}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Jg=Yg,N.GeneralizedTime=Jg,Yg.NAME=`GeneralizedTime`;var Xg,Zg=class extends xg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Xg=Zg,N.DATE=Xg,Zg.NAME=`DATE`;var Qg,$g=class extends xg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Qg=$g,N.TimeOfDay=Qg,$g.NAME=`TimeOfDay`;var e_,t_=class extends xg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};e_=t_,N.DateTime=e_,t_.NAME=`DateTime`;var n_,r_=class extends xg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};n_=r_,N.Duration=n_,r_.NAME=`Duration`;var i_,a_=class extends xg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};i_=a_,N.TIME=i_,a_.NAME=`TIME`;var o_=class{constructor({name:e=dh,optional:t=!1}={}){this.name=e,this.optional=t}},s_=class extends o_{constructor({value:e=[],...t}={}){super(t),this.value=e}},c_=class extends o_{constructor({value:e=new o_,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}},l_=class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=M.BufferSourceConverter.toUint8Array(e)}constructor({data:e=ph}={}){this.dataView=M.BufferSourceConverter.toUint8Array(e)}fromBER(e,t,n){let r=t+n;return this.dataView=M.BufferSourceConverter.toUint8Array(e).subarray(t,r),r}toBER(e){return this.dataView.slice().buffer}};function u_(e,t,n){if(n instanceof s_){for(let r of n.value)if(u_(e,t,r).verified)return{verified:!0,result:e};{let e={verified:!1,result:{error:`Wrong values for Choice type`}};return n.hasOwnProperty(th)&&(e.name=n.name),e}}if(n instanceof o_)return n.hasOwnProperty(th)&&(e[n.name]=t),{verified:!0,result:e};if(!(e instanceof Object))return{verified:!1,result:{error:`Wrong root object`}};if(!(t instanceof Object))return{verified:!1,result:{error:`Wrong ASN.1 data`}};if(!(n instanceof Object)||!(ih in n)||!(ch in n.idBlock)||!(lh in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};let r=n.idBlock.toBER(!1);if(r.byteLength===0)return{verified:!1,result:{error:`Error encoding idBlock for ASN.1 schema`}};if(n.idBlock.fromBER(r,0,r.byteLength)===-1)return{verified:!1,result:{error:`Error decoding idBlock for ASN.1 schema`}};if(n.idBlock.hasOwnProperty(ah)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.tagClass!==t.idBlock.tagClass)return{verified:!1,result:e};if(n.idBlock.hasOwnProperty(oh)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.tagNumber!==t.idBlock.tagNumber)return{verified:!1,result:e};if(n.idBlock.hasOwnProperty(sh)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.isConstructed!==t.idBlock.isConstructed)return{verified:!1,result:e};if(!(rh in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.isHexOnly!==t.idBlock.isHexOnly)return{verified:!1,result:e};if(n.idBlock.isHexOnly){if(!(nh in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};let r=n.idBlock.valueHexView,i=t.idBlock.valueHexView;if(r.length!==i.length)return{verified:!1,result:e};for(let t=0;t<r.length;t++)if(r[t]!==i[1])return{verified:!1,result:e}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&(e[n.name]=t)),n instanceof N.Constructed){let r=0,i={verified:!1,result:{error:`Unknown error`}},a=n.valueBlock.value.length;if(a>0&&n.valueBlock.value[0]instanceof c_&&(a=t.valueBlock.value.length),a===0)return{verified:!0,result:e};if(t.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let t=!0;for(let e=0;e<n.valueBlock.value.length;e++)t&&=n.valueBlock.value[e].optional||!1;return t?{verified:!0,result:e}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&delete e[n.name]),e.error=`Inconsistent object length`,{verified:!1,result:e})}for(let o=0;o<a;o++)if(o-r>=t.valueBlock.value.length){if(n.valueBlock.value[o].optional===!1){let t={verified:!1,result:e};return e.error=`Inconsistent length between ASN.1 data and schema`,n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&(delete e[n.name],t.name=n.name)),t}}else if(n.valueBlock.value[0]instanceof c_){if(i=u_(e,t.valueBlock.value[o],n.valueBlock.value[0].value),i.verified===!1)if(n.valueBlock.value[0].optional)r++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&delete e[n.name]),i;if(th in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let r={};r=uh in n.valueBlock.value[0]&&n.valueBlock.value[0].local?t:e,r[n.valueBlock.value[0].name]===void 0&&(r[n.valueBlock.value[0].name]=[]),r[n.valueBlock.value[0].name].push(t.valueBlock.value[o])}}else if(i=u_(e,t.valueBlock.value[o-r],n.valueBlock.value[o]),i.verified===!1)if(n.valueBlock.value[o].optional)r++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&delete e[n.name]),i;if(i.verified===!1){let t={verified:!1,result:e};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&(delete e[n.name],t.name=n.name)),t}return{verified:!0,result:e}}if(n.primitiveSchema&&nh in t.valueBlock){let r=kh(t.valueBlock.valueHexView);if(r.offset===-1){let t={verified:!1,result:r.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,dh),n.name&&(delete e[n.name],t.name=n.name)),t}return u_(e,r.result,n.primitiveSchema)}return{verified:!0,result:e}}function d_(e,t){if(!(t instanceof Object))return{verified:!1,result:{error:`Wrong ASN.1 schema type`}};let n=kh(M.BufferSourceConverter.toUint8Array(e));return n.offset===-1?{verified:!1,result:n.result}:u_(n.result,n.result,t)}var P;(function(e){e[e.Sequence=0]=`Sequence`,e[e.Set=1]=`Set`,e[e.Choice=2]=`Choice`})(P||={});var F;(function(e){e[e.Any=1]=`Any`,e[e.Boolean=2]=`Boolean`,e[e.OctetString=3]=`OctetString`,e[e.BitString=4]=`BitString`,e[e.Integer=5]=`Integer`,e[e.Enumerated=6]=`Enumerated`,e[e.ObjectIdentifier=7]=`ObjectIdentifier`,e[e.Utf8String=8]=`Utf8String`,e[e.BmpString=9]=`BmpString`,e[e.UniversalString=10]=`UniversalString`,e[e.NumericString=11]=`NumericString`,e[e.PrintableString=12]=`PrintableString`,e[e.TeletexString=13]=`TeletexString`,e[e.VideotexString=14]=`VideotexString`,e[e.IA5String=15]=`IA5String`,e[e.GraphicString=16]=`GraphicString`,e[e.VisibleString=17]=`VisibleString`,e[e.GeneralString=18]=`GeneralString`,e[e.CharacterString=19]=`CharacterString`,e[e.UTCTime=20]=`UTCTime`,e[e.GeneralizedTime=21]=`GeneralizedTime`,e[e.DATE=22]=`DATE`,e[e.TimeOfDay=23]=`TimeOfDay`,e[e.DateTime=24]=`DateTime`,e[e.Duration=25]=`Duration`,e[e.TIME=26]=`TIME`,e[e.Null=27]=`Null`})(F||={});var f_=class{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e==`number`)this.fromNumber(e);else if(M.BufferSourceConverter.isBufferSource(e))this.unusedBits=t,this.value=M.BufferSourceConverter.toArrayBuffer(e);else throw TypeError(`Unsupported type of 'params' argument for BitString`)}fromASN(e){if(!(e instanceof Jh))throw 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 Jh({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Jh({name:e})}toNumber(){let e=``,t=new Uint8Array(this.value);for(let 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),n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;let r=new Uint8Array(n);t=t.padStart(n<<3,`0`).split(``).reverse().join(``);let i=0;for(;i<n;)r[i]=parseInt(t.slice(i<<3,(i<<3)+8),2),i++;this.value=r.buffer}},I=class{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e==`number`?this.buffer=new ArrayBuffer(e):M.BufferSourceConverter.isBufferSource(e)?this.buffer=M.BufferSourceConverter.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof Gh))throw TypeError(`Argument 'asn' is not instance of ASN.1 OctetString`);return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Gh({valueHex:this.buffer})}toSchema(e){return new Gh({name:e})}},p_={fromASN:e=>e instanceof zh?null:e.valueBeforeDecodeView,toASN:e=>{if(e===null)return new zh;let t=Ah(e);if(t.result.error)throw Error(t.result.error);return t.result}},m_={fromASN:e=>e.valueBlock.valueHexView.byteLength>=4?e.valueBlock.toString():e.valueBlock.valueDec,toASN:e=>new tg({value:+e})},h_={fromASN:e=>e.valueBlock.valueDec,toASN:e=>new rg({value:e})},L={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new tg({valueHex:e})},g_={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new Jh({valueHex:e})},__={fromASN:e=>e.valueBlock.toString(),toASN:e=>new sg({value:e})},v_={fromASN:e=>e.valueBlock.value,toASN:e=>new Hh({value:e})},y_={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new Gh({valueHex:e})},b_={fromASN:e=>new I(e.getValue()),toASN:e=>e.toASN()};function x_(e){return{fromASN:e=>e.valueBlock.value,toASN:t=>new e({value:t})}}var S_=x_(xg),C_=x_(wg),w_=x_(Dg),T_=x_(kg),E_=x_(jg),D_=x_(Ng),O_=x_(Fg),k_=x_(Lg),A_=x_(zg),j_=x_(Vg),M_=x_(Ug),N_=x_(Gg),P_={fromASN:e=>e.toDate(),toASN:e=>new qg({valueDate:e})},F_={fromASN:e=>e.toDate(),toASN:e=>new Yg({valueDate:e})},I_={fromASN:()=>null,toASN:()=>new zh};function L_(e){switch(e){case F.Any:return p_;case F.BitString:return g_;case F.BmpString:return C_;case F.Boolean:return v_;case F.CharacterString:return N_;case F.Enumerated:return h_;case F.GeneralString:return M_;case F.GeneralizedTime:return F_;case F.GraphicString:return A_;case F.IA5String:return k_;case F.Integer:return m_;case F.Null:return I_;case F.NumericString:return T_;case F.ObjectIdentifier:return __;case F.OctetString:return y_;case F.PrintableString:return E_;case F.TeletexString:return D_;case F.UTCTime:return P_;case F.UniversalString:return w_;case F.Utf8String:return S_;case F.VideotexString:return O_;case F.VisibleString:return j_;default:return null}}function R_(e){return typeof e==`function`&&e.prototype?e.prototype.toASN&&e.prototype.fromASN?!0:R_(e.prototype):!!(e&&typeof e==`object`&&`toASN`in e&&`fromASN`in e)}function z_(e){if(e){let t=Object.getPrototypeOf(e);return t?.prototype?.constructor===Array?!0:z_(t)}return!1}function B_(e,t){if(!(e&&t)||e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(n[t]!==r[t])return!1;return!0}var V_=new class{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){let n=this.items.get(e);if(!n)throw Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){let t=this.get(e);t.schema||=this.create(e,!0)}createDefault(e){let t={type:P.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){let n=this.items.get(e)||this.createDefault(e),r=[];for(let e in n.items){let i=n.items[e],a=t?e:``,o;if(typeof i.type==`number`){let e=F[i.type],t=Jm[e];if(!t)throw Error(`Cannot get ASN1 class by name '${e}'`);o=new t({name:a})}else R_(i.type)?o=new i.type().toSchema(a):i.optional?this.get(i.type).type===P.Choice?o=new o_({name:a}):(o=this.create(i.type,!1),o.name=a):o=new o_({name:a});let s=!!i.optional||i.defaultValue!==void 0;if(i.repeated&&(o.name=``,o=new(i.repeated===`set`?hg:pg)({name:``,value:[new c_({name:a,value:o})]})),i.context!==null&&i.context!==void 0)if(i.implicit)if(typeof i.type==`number`||R_(i.type)){let e=i.repeated?Ph:Dh;r.push(new e({name:a,optional:s,idBlock:{tagClass:3,tagNumber:i.context}}))}else{this.cache(i.type);let e=!!i.repeated,t=e?o:this.get(i.type,!0).schema;t=`valueBlock`in t?t.valueBlock.value:t.value,r.push(new Ph({name:e?``:a,optional:s,idBlock:{tagClass:3,tagNumber:i.context},value:t}))}else r.push(new Ph({optional:s,idBlock:{tagClass:3,tagNumber:i.context},value:[o]}));else o.optional=s,r.push(o)}switch(n.type){case P.Sequence:return new pg({value:r,name:``});case P.Set:return new hg({value:r,name:``});case P.Choice:return new s_({value:r,name:``});default:throw Error(`Unsupported ASN1 type in use`)}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){let t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}},R=e=>t=>{let n;V_.has(t)?n=V_.get(t):(n=V_.createDefault(t),V_.set(t,n)),Object.assign(n,e)},z=e=>(t,n)=>{let r;V_.has(t.constructor)?r=V_.get(t.constructor):(r=V_.createDefault(t.constructor),V_.set(t.constructor,r));let i=Object.assign({},e);if(typeof i.type==`number`&&!i.converter){let r=L_(e.type);if(!r)throw Error(`Cannot get default converter for property '${n}' of ${t.constructor.name}`);i.converter=r}i.raw=e.raw,r.items[n]=i},H_=class extends Error{constructor(){super(...arguments),this.schemas=[]}},U_=class{static parse(e,t){let n=Ah(e);if(n.result.error)throw Error(n.result.error);return this.fromASN(n.result,t)}static fromASN(e,t){try{if(R_(t))return new t().fromASN(e);let n=V_.get(t);V_.cache(t);let r=n.schema,i=this.handleChoiceTypes(e,n,t,r);if(i?.result)return i.result;i?.targetSchema&&(r=i.targetSchema);let a=this.handleSequenceTypes(e,n,t,r),o=new t;return z_(t)?this.handleArrayTypes(e,n,t):(this.processSchemaItems(n,a,o),o)}catch(e){throw e instanceof H_&&e.schemas.push(t.name),e}}static handleChoiceTypes(e,t,n,r){if(e.constructor===Ph&&t.type===P.Choice&&e.idBlock.tagClass===3)for(let r in t.items){let i=t.items[r];if(i.context===e.idBlock.tagNumber&&i.implicit&&typeof i.type==`function`&&V_.has(i.type)){let t=V_.get(i.type);if(t&&t.type===P.Sequence){let t=new pg;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock){t.valueBlock.value=e.valueBlock.value;let a=this.fromASN(t,i.type),o=new n;return o[r]=a,{result:o}}}}}else if(e.constructor===Ph&&t.type!==P.Choice){let n=new Ph({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:t.schema.valueBlock.value});for(let n in t.items)delete e[n];return{targetSchema:n}}return null}static handleSequenceTypes(e,t,n,r){if(t.type===P.Sequence){let t=u_({},e,r);if(!t.verified)throw new H_(`Data does not match to ${n.name} ASN1 schema.${t.result.error?` ${t.result.error}`:``}`);return t}else{let t=u_({},e,r);if(!t.verified)throw new H_(`Data does not match to ${n.name} ASN1 schema.${t.result.error?` ${t.result.error}`:``}`);return t}}static processRepeatedField(e,t,n){let r=e.slice(t);if(r.length===1&&r[0].constructor.name===`Sequence`){let e=r[0];e.valueBlock&&e.valueBlock.value&&Array.isArray(e.valueBlock.value)&&(r=e.valueBlock.value)}if(typeof n.type==`number`){let e=L_(n.type);if(!e)throw Error(`No converter for ASN.1 type ${n.type}`);return r.filter(e=>e&&e.valueBlock).map(t=>{try{return e.fromASN(t)}catch{return}}).filter(e=>e!==void 0)}else return r.filter(e=>e&&e.valueBlock).map(e=>{try{return this.fromASN(e,n.type)}catch{return}}).filter(e=>e!==void 0)}static processPrimitiveField(e,t){let n=L_(t.type);if(!n)throw Error(`No converter for ASN.1 type ${t.type}`);return n.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type==`function`&&V_.has(e.type)&&V_.get(e.type).type===P.Choice}static processOptionalChoiceField(e,t){try{return{processed:!0,value:this.fromASN(e,t.type)}}catch(e){if(e instanceof H_&&/Wrong values for Choice type/.test(e.message))return{processed:!1};throw e}}static handleArrayTypes(e,t,n){if(!(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);let r=t.itemType;if(typeof r==`number`){let t=L_(r);if(!t)throw Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,e=>t.fromASN(e))}else return n.from(e.valueBlock.value,e=>this.fromASN(e,r))}static processSchemaItems(e,t,n){for(let r in e.items){let i=t.result[r];if(!i)continue;let a=e.items[r],o=a.type,s;s=typeof o==`number`||R_(o)?this.processPrimitiveSchemaItem(i,a,o):this.processComplexSchemaItem(i,a,o),s&&typeof s==`object`&&`value`in s&&`raw`in s?(n[r]=s.value,n[`${r}Raw`]=s.raw):n[r]=s}}static processPrimitiveSchemaItem(e,t,n){let r=t.converter??(R_(n)?new n:null);if(!r)throw Error(`Converter is empty`);return t.repeated?this.processRepeatedPrimitiveItem(e,t,r):this.processSinglePrimitiveItem(e,t,n,r)}static processRepeatedPrimitiveItem(e,t,n){if(t.implicit){let r=new(t.repeated===`sequence`?pg:hg);r.valueBlock=e.valueBlock;let i=Ah(r.toBER(!1));if(i.offset===-1)throw Error(`Cannot parse the child item. ${i.result.error}`);if(!(`value`in i.result.valueBlock&&Array.isArray(i.result.valueBlock.value)))throw Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);let a=i.result.valueBlock.value;return Array.from(a,e=>n.fromASN(e))}else return Array.from(e,e=>n.fromASN(e))}static processSinglePrimitiveItem(e,t,n,r){let i=e;if(t.implicit){let e;if(R_(n))e=new n().toSchema(``);else{let t=F[n],r=Jm[t];if(!r)throw Error(`Cannot get '${t}' class from asn1js module`);e=new r}e.valueBlock=i.valueBlock,i=Ah(e.toBER(!1)).result}return r.fromASN(i)}static processComplexSchemaItem(e,t,n){if(t.repeated){if(!Array.isArray(e))throw Error(`Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.`);return Array.from(e,e=>this.fromASN(e,n))}else{let r=this.handleImplicitTagging(e,t,n);if(this.isOptionalChoiceField(t))try{return this.fromASN(r,n)}catch(e){if(e instanceof H_&&/Wrong values for Choice type/.test(e.message))return;throw e}else{let i=this.fromASN(r,n);return t.raw?{value:i,raw:e.valueBeforeDecodeView}:i}}}static handleImplicitTagging(e,t,n){if(t.implicit&&typeof t.context==`number`){let t=V_.get(n);if(t.type===P.Sequence){let t=new pg;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}else if(t.type===P.Set){let t=new hg;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}}return e}},W_=class e{static serialize(e){return e instanceof Sh?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(t){if(t&&typeof t==`object`&&R_(t))return t.toASN();if(!(t&&typeof t==`object`))throw TypeError(`Parameter 1 should be type of Object.`);let n=t.constructor,r=V_.get(n);V_.cache(n);let i=[];if(r.itemType){if(!Array.isArray(t))throw TypeError(`Parameter 1 should be type of Array.`);if(typeof r.itemType==`number`){let e=L_(r.itemType);if(!e)throw Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);i=t.map(t=>e.toASN(t))}else i=t.map(e=>this.toAsnItem({type:r.itemType},`[]`,n,e))}else for(let a in r.items){let o=r.items[a],s=t[a];if(s===void 0||o.defaultValue===s||typeof o.defaultValue==`object`&&typeof s==`object`&&B_(this.serialize(o.defaultValue),this.serialize(s)))continue;let c=e.toAsnItem(o,a,n,s);if(typeof o.context==`number`)if(o.implicit)if(!o.repeated&&(typeof o.type==`number`||R_(o.type))){let e={};e.valueHex=c instanceof zh?c.valueBeforeDecodeView:c.valueBlock.toBER(),i.push(new Dh({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...e}))}else i.push(new Ph({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:c.valueBlock.value}));else i.push(new Ph({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:[c]}));else o.repeated?i=i.concat(c):i.push(c)}let a;switch(r.type){case P.Sequence:a=new pg({value:i});break;case P.Set:a=new hg({value:i});break;case P.Choice:if(!i[0])throw Error(`Schema '${n.name}' has wrong data. Choice cannot be empty.`);a=i[0];break}return a}static toAsnItem(e,t,n,r){let i;if(typeof e.type==`number`){let a=e.converter;if(!a)throw Error(`Property '${t}' doesn't have converter for type ${F[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(r))throw TypeError(`Parameter 'objProp' should be type of Array.`);let t=Array.from(r,e=>a.toASN(e));i=new(e.repeated===`sequence`?pg:hg)({value:t})}else i=a.toASN(r)}else if(e.repeated){if(!Array.isArray(r))throw TypeError(`Parameter 'objProp' should be type of Array.`);let t=Array.from(r,e=>this.toASN(e));i=new(e.repeated===`sequence`?pg:hg)({value:t})}else i=this.toASN(r);return i}},B=class extends Array{constructor(e=[]){if(typeof e==`number`)super(e);else{super();for(let t of e)this.push(t)}}},V=class e{static serialize(e){return W_.serialize(e)}static parse(e,t){return U_.parse(e,t)}static toString(t){let n=Ah(M.BufferSourceConverter.isBufferSource(t)?M.BufferSourceConverter.toArrayBuffer(t):e.serialize(t));if(n.offset===-1)throw Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}};function H(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function U(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function W(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var G_=class{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){let t=e.split(`.`);if(t.length!==4)throw Error(`Invalid IPv4 address`);return t.map(e=>{let t=parseInt(e,10);if(isNaN(t)||t<0||t>255)throw Error(`Invalid IPv4 address part`);return t})}static parseIPv6(e){let t=this.expandIPv6(e).split(`:`);if(t.length!==8)throw Error(`Invalid IPv6 address`);return t.reduce((e,t)=>{let n=parseInt(t,16);if(isNaN(n)||n<0||n>65535)throw Error(`Invalid IPv6 address part`);return e.push(n>>8&255),e.push(n&255),e},[])}static expandIPv6(e){if(!e.includes(`::`))return e;let t=e.split(`::`);if(t.length>2)throw Error(`Invalid IPv6 address`);let n=t[0]?t[0].split(`:`):[],r=t[1]?t[1].split(`:`):[],i=8-(n.length+r.length);if(i<0)throw Error(`Invalid IPv6 address`);return[...n,...Array(i).fill(`0`),...r].join(`:`)}static formatIPv6(e){let t=[];for(let n=0;n<16;n+=2)t.push((e[n]<<8|e[n+1]).toString(16));return this.compressIPv6(t.join(`:`))}static compressIPv6(e){let t=e.split(`:`),n=-1,r=0,i=-1,a=0;for(let e=0;e<t.length;e++)t[e]===`0`?(i===-1&&(i=e),a++):(a>r&&(n=i,r=a),i=-1,a=0);return a>r&&(n=i,r=a),r>1?`${t.slice(0,n).join(`:`)}::${t.slice(n+r).join(`:`)}`:e}static parseCIDR(e){let[t,n]=e.split(`/`),r=parseInt(n,10);if(this.isIPv4(t)){if(r<0||r>32)throw Error(`Invalid IPv4 prefix length`);return[this.parseIPv4(t),r]}else{if(r<0||r>128)throw Error(`Invalid IPv6 prefix length`);return[this.parseIPv6(t),r]}}static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return`::/0`;if(e.length!==16)return e;let t=parseInt(e.slice(8),16).toString(2).split(``).reduce((e,t)=>e+ +t,0),n=e.slice(0,8).replace(/(.{2})/g,e=>`${parseInt(e,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){let t=new Uint8Array(e);if(t.length===4)return Array.from(t).join(`.`);if(t.length===16)return this.formatIPv6(t);if(t.length===8||t.length===32){let e=t.length/2,n=t.slice(0,e),r=t.slice(e);if(t.every(e=>e===0))return t.length===8?`0.0.0.0/0`:`::/0`;let i=r.reduce((e,t)=>e+(t.toString(2).match(/1/g)||[]).length,0);return t.length===8?`${Array.from(n).join(`.`)}/${i}`:`${this.formatIPv6(n)}/${i}`}return this.decodeIP(M.Convert.ToHex(e))}static fromString(e){if(e.includes(`/`)){let[t,n]=this.parseCIDR(e),r=new Uint8Array(t.length),i=n;for(let e=0;e<r.length;e++)i>=8?(r[e]=255,i-=8):i>0&&(r[e]=255<<8-i,i=0);let a=new Uint8Array(t.length*2);return a.set(t,0),a.set(r,t.length),a.buffer}let t=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(t).buffer}},K_,q_,J_,Y_=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||``}};H([z({type:F.TeletexString})],Y_.prototype,`teletexString`,void 0),H([z({type:F.PrintableString})],Y_.prototype,`printableString`,void 0),H([z({type:F.UniversalString})],Y_.prototype,`universalString`,void 0),H([z({type:F.Utf8String})],Y_.prototype,`utf8String`,void 0),H([z({type:F.BmpString})],Y_.prototype,`bmpString`,void 0),Y_=H([R({type:P.Choice})],Y_);var X_=class extends Y_{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?M.Convert.ToHex(this.anyValue):super.toString())}};H([z({type:F.IA5String})],X_.prototype,`ia5String`,void 0),H([z({type:F.Any})],X_.prototype,`anyValue`,void 0),X_=H([R({type:P.Choice})],X_);var Z_=class{constructor(e={}){this.type=``,this.value=new X_,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Z_.prototype,`type`,void 0),H([z({type:X_})],Z_.prototype,`value`,void 0);var Q_=K_=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,K_.prototype)}};Q_=K_=H([R({type:P.Set,itemType:Z_})],Q_);var $_=q_=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,q_.prototype)}};$_=q_=H([R({type:P.Sequence,itemType:Q_})],$_);var ev=J_=class extends $_{constructor(e){super(e),Object.setPrototypeOf(this,J_.prototype)}};ev=J_=H([R({type:P.Sequence})],ev);var tv={fromASN:e=>G_.toString(y_.fromASN(e)),toASN:e=>y_.toASN(G_.fromString(e))},nv=class{constructor(e={}){this.typeId=``,this.value=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],nv.prototype,`typeId`,void 0),H([z({type:F.Any,context:0})],nv.prototype,`value`,void 0);var rv=class{constructor(e={}){this.partyName=new Y_,Object.assign(this,e)}};H([z({type:Y_,optional:!0,context:0,implicit:!0})],rv.prototype,`nameAssigner`,void 0),H([z({type:Y_,context:1,implicit:!0})],rv.prototype,`partyName`,void 0);var G=class{constructor(e={}){Object.assign(this,e)}};H([z({type:nv,context:0,implicit:!0})],G.prototype,`otherName`,void 0),H([z({type:F.IA5String,context:1,implicit:!0})],G.prototype,`rfc822Name`,void 0),H([z({type:F.IA5String,context:2,implicit:!0})],G.prototype,`dNSName`,void 0),H([z({type:F.Any,context:3,implicit:!0})],G.prototype,`x400Address`,void 0),H([z({type:ev,context:4,implicit:!1})],G.prototype,`directoryName`,void 0),H([z({type:rv,context:5})],G.prototype,`ediPartyName`,void 0),H([z({type:F.IA5String,context:6,implicit:!0})],G.prototype,`uniformResourceIdentifier`,void 0),H([z({type:F.OctetString,context:7,implicit:!0,converter:tv})],G.prototype,`iPAddress`,void 0),H([z({type:F.ObjectIdentifier,context:8,implicit:!0})],G.prototype,`registeredID`,void 0),G=H([R({type:P.Choice})],G);var iv=`1.3.6.1.5.5.7`,av=`${iv}.1`,ov=`${iv}.2`,sv=`${iv}.3`,cv=`${iv}.48`;`${ov}`,`${ov}`;var lv=`${cv}.1`,uv=`${cv}.2`,dv=`${cv}.3`,fv=`${cv}.5`,K=`2.5.29`,pv,mv=`${av}.1`,hv=class{constructor(e={}){this.accessMethod=``,this.accessLocation=new G,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],hv.prototype,`accessMethod`,void 0),H([z({type:G})],hv.prototype,`accessLocation`,void 0);var gv=pv=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,pv.prototype)}};gv=pv=H([R({type:P.Sequence,itemType:hv})],gv);var _v=`${K}.35`,vv=class extends I{},yv=class{constructor(e={}){e&&Object.assign(this,e)}};H([z({type:vv,context:0,optional:!0,implicit:!0})],yv.prototype,`keyIdentifier`,void 0),H([z({type:G,context:1,optional:!0,implicit:!0,repeated:`sequence`})],yv.prototype,`authorityCertIssuer`,void 0),H([z({type:F.Integer,context:2,optional:!0,implicit:!0,converter:L})],yv.prototype,`authorityCertSerialNumber`,void 0);var bv=`${K}.19`,xv=class{constructor(e={}){this.cA=!1,Object.assign(this,e)}};H([z({type:F.Boolean,defaultValue:!1})],xv.prototype,`cA`,void 0),H([z({type:F.Integer,optional:!0})],xv.prototype,`pathLenConstraint`,void 0);var Sv,Cv=Sv=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Sv.prototype)}};Cv=Sv=H([R({type:P.Sequence,itemType:G})],Cv);var wv;`${K}`;var Tv=wv=class extends Cv{constructor(e){super(e),Object.setPrototypeOf(this,wv.prototype)}};Tv=wv=H([R({type:P.Sequence})],Tv);var Ev,Dv=`${K}.32`;`${Dv}`;var Ov=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||``}};H([z({type:F.IA5String})],Ov.prototype,`ia5String`,void 0),H([z({type:F.VisibleString})],Ov.prototype,`visibleString`,void 0),H([z({type:F.BmpString})],Ov.prototype,`bmpString`,void 0),H([z({type:F.Utf8String})],Ov.prototype,`utf8String`,void 0),Ov=H([R({type:P.Choice})],Ov);var kv=class{constructor(e={}){this.organization=new Ov,this.noticeNumbers=[],Object.assign(this,e)}};H([z({type:Ov})],kv.prototype,`organization`,void 0),H([z({type:F.Integer,repeated:`sequence`})],kv.prototype,`noticeNumbers`,void 0);var Av=class{constructor(e={}){Object.assign(this,e)}};H([z({type:kv,optional:!0})],Av.prototype,`noticeRef`,void 0),H([z({type:Ov,optional:!0})],Av.prototype,`explicitText`,void 0);var jv=class{constructor(e={}){Object.assign(this,e)}};H([z({type:F.IA5String})],jv.prototype,`cPSuri`,void 0),H([z({type:Av})],jv.prototype,`userNotice`,void 0),jv=H([R({type:P.Choice})],jv);var Mv=class{constructor(e={}){this.policyQualifierId=``,this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Mv.prototype,`policyQualifierId`,void 0),H([z({type:F.Any})],Mv.prototype,`qualifier`,void 0);var Nv=class{constructor(e={}){this.policyIdentifier=``,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Nv.prototype,`policyIdentifier`,void 0),H([z({type:Mv,repeated:`sequence`,optional:!0})],Nv.prototype,`policyQualifiers`,void 0);var Pv=Ev=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Ev.prototype)}};Pv=Ev=H([R({type:P.Sequence,itemType:Nv})],Pv),`${K}`;var Fv=class{constructor(e=0){this.value=e}};H([z({type:F.Integer})],Fv.prototype,`value`,void 0),Fv=H([R({type:P.Choice})],Fv),`${K}`;var Iv=class extends Fv{};Iv=H([R({type:P.Choice})],Iv);var Lv,Rv=`${K}.31`,zv;(function(e){e[e.unused=1]=`unused`,e[e.keyCompromise=2]=`keyCompromise`,e[e.cACompromise=4]=`cACompromise`,e[e.affiliationChanged=8]=`affiliationChanged`,e[e.superseded=16]=`superseded`,e[e.cessationOfOperation=32]=`cessationOfOperation`,e[e.certificateHold=64]=`certificateHold`,e[e.privilegeWithdrawn=128]=`privilegeWithdrawn`,e[e.aACompromise=256]=`aACompromise`})(zv||={});var Bv=class extends f_{toJSON(){let e=[],t=this.toNumber();return t&zv.aACompromise&&e.push(`aACompromise`),t&zv.affiliationChanged&&e.push(`affiliationChanged`),t&zv.cACompromise&&e.push(`cACompromise`),t&zv.certificateHold&&e.push(`certificateHold`),t&zv.cessationOfOperation&&e.push(`cessationOfOperation`),t&zv.keyCompromise&&e.push(`keyCompromise`),t&zv.privilegeWithdrawn&&e.push(`privilegeWithdrawn`),t&zv.superseded&&e.push(`superseded`),t&zv.unused&&e.push(`unused`),e}toString(){return`[${this.toJSON().join(`, `)}]`}},Vv=class{constructor(e={}){Object.assign(this,e)}};H([z({type:G,context:0,repeated:`sequence`,implicit:!0})],Vv.prototype,`fullName`,void 0),H([z({type:Q_,context:1,implicit:!0})],Vv.prototype,`nameRelativeToCRLIssuer`,void 0),Vv=H([R({type:P.Choice})],Vv);var Hv=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Vv,context:0,optional:!0})],Hv.prototype,`distributionPoint`,void 0),H([z({type:Bv,context:1,optional:!0,implicit:!0})],Hv.prototype,`reasons`,void 0),H([z({type:G,context:2,optional:!0,repeated:`sequence`,implicit:!0})],Hv.prototype,`cRLIssuer`,void 0);var Uv=Lv=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Lv.prototype)}};Uv=Lv=H([R({type:P.Sequence,itemType:Hv})],Uv);var Wv;`${K}`;var Gv=Wv=class extends Uv{constructor(e){super(e),Object.setPrototypeOf(this,Wv.prototype)}};Gv=Wv=H([R({type:P.Sequence,itemType:Hv})],Gv),`${K}`;var Kv=class e{constructor(t={}){this.onlyContainsUserCerts=e.ONLY,this.onlyContainsCACerts=e.ONLY,this.indirectCRL=e.ONLY,this.onlyContainsAttributeCerts=e.ONLY,Object.assign(this,t)}};Kv.ONLY=!1,H([z({type:Vv,context:0,optional:!0})],Kv.prototype,`distributionPoint`,void 0),H([z({type:F.Boolean,context:1,defaultValue:Kv.ONLY,implicit:!0})],Kv.prototype,`onlyContainsUserCerts`,void 0),H([z({type:F.Boolean,context:2,defaultValue:Kv.ONLY,implicit:!0})],Kv.prototype,`onlyContainsCACerts`,void 0),H([z({type:Bv,context:3,optional:!0,implicit:!0})],Kv.prototype,`onlySomeReasons`,void 0),H([z({type:F.Boolean,context:4,defaultValue:Kv.ONLY,implicit:!0})],Kv.prototype,`indirectCRL`,void 0),H([z({type:F.Boolean,context:5,defaultValue:Kv.ONLY,implicit:!0})],Kv.prototype,`onlyContainsAttributeCerts`,void 0);var qv=`${K}.21`,Jv;(function(e){e[e.unspecified=0]=`unspecified`,e[e.keyCompromise=1]=`keyCompromise`,e[e.cACompromise=2]=`cACompromise`,e[e.affiliationChanged=3]=`affiliationChanged`,e[e.superseded=4]=`superseded`,e[e.cessationOfOperation=5]=`cessationOfOperation`,e[e.certificateHold=6]=`certificateHold`,e[e.removeFromCRL=8]=`removeFromCRL`,e[e.privilegeWithdrawn=9]=`privilegeWithdrawn`,e[e.aACompromise=10]=`aACompromise`})(Jv||={});var Yv=class{constructor(e=Jv.unspecified){this.reason=Jv.unspecified,this.reason=e}toJSON(){return Jv[this.reason]}toString(){return this.toJSON()}};H([z({type:F.Enumerated})],Yv.prototype,`reason`,void 0),Yv=H([R({type:P.Choice})],Yv);var Xv,Zv=`${K}.37`,Qv=Xv=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Xv.prototype)}};Qv=Xv=H([R({type:P.Sequence,itemType:F.ObjectIdentifier})],Qv),`${Zv}`;var $v=`${sv}.1`,ey=`${sv}.2`,ty=`${sv}.3`,ny=`${sv}.4`,ry=`${sv}.8`,iy=`${sv}.9`;`${K}`;var ay=class{constructor(e=new ArrayBuffer(0)){this.value=e}};H([z({type:F.Integer,converter:L})],ay.prototype,`value`,void 0),ay=H([R({type:P.Choice})],ay);var oy=`${K}.24`,sy=class{constructor(e){this.value=new Date,e&&(this.value=e)}};H([z({type:F.GeneralizedTime})],sy.prototype,`value`,void 0),sy=H([R({type:P.Choice})],sy);var cy,ly=`${K}.18`,uy=cy=class extends Cv{constructor(e){super(e),Object.setPrototypeOf(this,cy.prototype)}};uy=cy=H([R({type:P.Sequence})],uy);var dy=`${K}.15`,fy;(function(e){e[e.digitalSignature=1]=`digitalSignature`,e[e.nonRepudiation=2]=`nonRepudiation`,e[e.keyEncipherment=4]=`keyEncipherment`,e[e.dataEncipherment=8]=`dataEncipherment`,e[e.keyAgreement=16]=`keyAgreement`,e[e.keyCertSign=32]=`keyCertSign`,e[e.cRLSign=64]=`cRLSign`,e[e.encipherOnly=128]=`encipherOnly`,e[e.decipherOnly=256]=`decipherOnly`})(fy||={});var py=class extends f_{toJSON(){let e=this.toNumber(),t=[];return e&fy.cRLSign&&t.push(`crlSign`),e&fy.dataEncipherment&&t.push(`dataEncipherment`),e&fy.decipherOnly&&t.push(`decipherOnly`),e&fy.digitalSignature&&t.push(`digitalSignature`),e&fy.encipherOnly&&t.push(`encipherOnly`),e&fy.keyAgreement&&t.push(`keyAgreement`),e&fy.keyCertSign&&t.push(`keyCertSign`),e&fy.keyEncipherment&&t.push(`keyEncipherment`),e&fy.nonRepudiation&&t.push(`nonRepudiation`),t}toString(){return`[${this.toJSON().join(`, `)}]`}},my;`${K}`;var hy=class{constructor(e={}){this.base=new G,this.minimum=0,Object.assign(this,e)}};H([z({type:G})],hy.prototype,`base`,void 0),H([z({type:F.Integer,context:0,defaultValue:0,implicit:!0})],hy.prototype,`minimum`,void 0),H([z({type:F.Integer,context:1,optional:!0,implicit:!0})],hy.prototype,`maximum`,void 0);var gy=my=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,my.prototype)}};gy=my=H([R({type:P.Sequence,itemType:hy})],gy);var _y=class{constructor(e={}){Object.assign(this,e)}};H([z({type:gy,context:0,optional:!0,implicit:!0})],_y.prototype,`permittedSubtrees`,void 0),H([z({type:gy,context:1,optional:!0,implicit:!0})],_y.prototype,`excludedSubtrees`,void 0),`${K}`;var vy=class{constructor(e={}){Object.assign(this,e)}};H([z({type:F.Integer,context:0,implicit:!0,optional:!0,converter:L})],vy.prototype,`requireExplicitPolicy`,void 0),H([z({type:F.Integer,context:1,implicit:!0,optional:!0,converter:L})],vy.prototype,`inhibitPolicyMapping`,void 0);var yy;`${K}`;var by=class{constructor(e={}){this.issuerDomainPolicy=``,this.subjectDomainPolicy=``,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],by.prototype,`issuerDomainPolicy`,void 0),H([z({type:F.ObjectIdentifier})],by.prototype,`subjectDomainPolicy`,void 0);var xy=yy=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,yy.prototype)}};xy=yy=H([R({type:P.Sequence,itemType:by})],xy);var Sy,Cy=`${K}.17`,wy=Sy=class extends Cv{constructor(e){super(e),Object.setPrototypeOf(this,Sy.prototype)}};wy=Sy=H([R({type:P.Sequence})],wy);var Ty=class{constructor(e={}){this.type=``,this.values=[],Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Ty.prototype,`type`,void 0),H([z({type:F.Any,repeated:`set`})],Ty.prototype,`values`,void 0);var Ey;`${K}`;var Dy=Ey=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Ey.prototype)}};Dy=Ey=H([R({type:P.Sequence,itemType:Ty})],Dy);var Oy=`${K}.14`,ky=class extends vv{};`${K}`;var Ay=class{constructor(e={}){Object.assign(this,e)}};H([z({type:F.GeneralizedTime,context:0,implicit:!0,optional:!0})],Ay.prototype,`notBefore`,void 0),H([z({type:F.GeneralizedTime,context:1,implicit:!0,optional:!0})],Ay.prototype,`notAfter`,void 0);var jy;(function(e){e[e.keyUpdateAllowed=1]=`keyUpdateAllowed`,e[e.newExtensions=2]=`newExtensions`,e[e.pKIXCertificate=4]=`pKIXCertificate`})(jy||={});var My=class extends f_{toJSON(){let e=[],t=this.toNumber();return t&jy.pKIXCertificate&&e.push(`pKIXCertificate`),t&jy.newExtensions&&e.push(`newExtensions`),t&jy.keyUpdateAllowed&&e.push(`keyUpdateAllowed`),e}toString(){return`[${this.toJSON().join(`, `)}]`}},Ny=class{constructor(e={}){this.entrustVers=``,this.entrustInfoFlags=new My,Object.assign(this,e)}};H([z({type:F.GeneralString})],Ny.prototype,`entrustVers`,void 0),H([z({type:My})],Ny.prototype,`entrustInfoFlags`,void 0);var Py;`${av}`;var Fy=Py=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Py.prototype)}};Fy=Py=H([R({type:P.Sequence,itemType:hv})],Fy);var q=class e{constructor(e={}){this.algorithm=``,Object.assign(this,e)}isEqual(t){return t instanceof e&&t.algorithm==this.algorithm&&(t.parameters&&this.parameters&&M.isEqual(t.parameters,this.parameters)||t.parameters===this.parameters)}};H([z({type:F.ObjectIdentifier})],q.prototype,`algorithm`,void 0),H([z({type:F.Any,optional:!0})],q.prototype,`parameters`,void 0);var Iy=class{constructor(e={}){this.algorithm=new q,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:q})],Iy.prototype,`algorithm`,void 0),H([z({type:F.BitString})],Iy.prototype,`subjectPublicKey`,void 0);var Ly=class{constructor(e){if(e)if(typeof e==`string`||typeof e==`number`||e instanceof Date){let t=new Date(e);t.setMilliseconds(0),t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){let e=this.utcTime||this.generalTime;if(!e)throw Error(`Cannot get time from CHOICE object`);return e}};H([z({type:F.UTCTime})],Ly.prototype,`utcTime`,void 0),H([z({type:F.GeneralizedTime})],Ly.prototype,`generalTime`,void 0),Ly=H([R({type:P.Choice})],Ly);var Ry=class{constructor(e){this.notBefore=new Ly(new Date),this.notAfter=new Ly(new Date),e&&(this.notBefore=new Ly(e.notBefore),this.notAfter=new Ly(e.notAfter))}};H([z({type:Ly})],Ry.prototype,`notBefore`,void 0),H([z({type:Ly})],Ry.prototype,`notAfter`,void 0);var zy,By=class e{constructor(t={}){this.extnID=``,this.critical=e.CRITICAL,this.extnValue=new I,Object.assign(this,t)}};By.CRITICAL=!1,H([z({type:F.ObjectIdentifier})],By.prototype,`extnID`,void 0),H([z({type:F.Boolean,defaultValue:By.CRITICAL})],By.prototype,`critical`,void 0),H([z({type:I})],By.prototype,`extnValue`,void 0);var Vy=zy=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,zy.prototype)}};Vy=zy=H([R({type:P.Sequence,itemType:By})],Vy);var Hy;(function(e){e[e.v1=0]=`v1`,e[e.v2=1]=`v2`,e[e.v3=2]=`v3`})(Hy||={});var Uy=class{constructor(e={}){this.version=Hy.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new q,this.issuer=new ev,this.validity=new Ry,this.subject=new ev,this.subjectPublicKeyInfo=new Iy,Object.assign(this,e)}};H([z({type:F.Integer,context:0,defaultValue:Hy.v1})],Uy.prototype,`version`,void 0),H([z({type:F.Integer,converter:L})],Uy.prototype,`serialNumber`,void 0),H([z({type:q})],Uy.prototype,`signature`,void 0),H([z({type:ev})],Uy.prototype,`issuer`,void 0),H([z({type:Ry})],Uy.prototype,`validity`,void 0),H([z({type:ev})],Uy.prototype,`subject`,void 0),H([z({type:Iy})],Uy.prototype,`subjectPublicKeyInfo`,void 0),H([z({type:F.BitString,context:1,implicit:!0,optional:!0})],Uy.prototype,`issuerUniqueID`,void 0),H([z({type:F.BitString,context:2,implicit:!0,optional:!0})],Uy.prototype,`subjectUniqueID`,void 0),H([z({type:Vy,context:3,optional:!0})],Uy.prototype,`extensions`,void 0);var Wy=class{constructor(e={}){this.tbsCertificate=new Uy,this.signatureAlgorithm=new q,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:Uy,raw:!0})],Wy.prototype,`tbsCertificate`,void 0),H([z({type:q})],Wy.prototype,`signatureAlgorithm`,void 0),H([z({type:F.BitString})],Wy.prototype,`signatureValue`,void 0);var Gy=class{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Ly,Object.assign(this,e)}};H([z({type:F.Integer,converter:L})],Gy.prototype,`userCertificate`,void 0),H([z({type:Ly})],Gy.prototype,`revocationDate`,void 0),H([z({type:By,optional:!0,repeated:`sequence`})],Gy.prototype,`crlEntryExtensions`,void 0);var Ky=class{constructor(e={}){this.signature=new q,this.issuer=new ev,this.thisUpdate=new Ly,Object.assign(this,e)}};H([z({type:F.Integer,optional:!0})],Ky.prototype,`version`,void 0),H([z({type:q})],Ky.prototype,`signature`,void 0),H([z({type:ev})],Ky.prototype,`issuer`,void 0),H([z({type:Ly})],Ky.prototype,`thisUpdate`,void 0),H([z({type:Ly,optional:!0})],Ky.prototype,`nextUpdate`,void 0),H([z({type:Gy,repeated:`sequence`,optional:!0})],Ky.prototype,`revokedCertificates`,void 0),H([z({type:By,optional:!0,context:0,repeated:`sequence`})],Ky.prototype,`crlExtensions`,void 0);var qy=class{constructor(e={}){this.tbsCertList=new Ky,this.signatureAlgorithm=new q,this.signature=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:Ky,raw:!0})],qy.prototype,`tbsCertList`,void 0),H([z({type:q})],qy.prototype,`signatureAlgorithm`,void 0),H([z({type:F.BitString})],qy.prototype,`signature`,void 0);var Jy=class{constructor(e={}){this.issuer=new ev,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:ev})],Jy.prototype,`issuer`,void 0),H([z({type:F.Integer,converter:L})],Jy.prototype,`serialNumber`,void 0);var Yy=class{constructor(e={}){Object.assign(this,e)}};H([z({type:ky,context:0,implicit:!0})],Yy.prototype,`subjectKeyIdentifier`,void 0),H([z({type:Jy})],Yy.prototype,`issuerAndSerialNumber`,void 0),Yy=H([R({type:P.Choice})],Yy);var Xy;(function(e){e[e.v0=0]=`v0`,e[e.v1=1]=`v1`,e[e.v2=2]=`v2`,e[e.v3=3]=`v3`,e[e.v4=4]=`v4`,e[e.v5=5]=`v5`})(Xy||={});var Zy=class extends q{};Zy=H([R({type:P.Sequence})],Zy);var Qy=class extends q{};Qy=H([R({type:P.Sequence})],Qy);var $y=class extends q{};$y=H([R({type:P.Sequence})],$y);var eb=class extends q{};eb=H([R({type:P.Sequence})],eb);var tb=class extends q{};tb=H([R({type:P.Sequence})],tb);var nb=class extends q{};nb=H([R({type:P.Sequence})],nb);var rb=class{constructor(e={}){this.attrType=``,this.attrValues=[],Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],rb.prototype,`attrType`,void 0),H([z({type:F.Any,repeated:`set`})],rb.prototype,`attrValues`,void 0);var ib,ab=class{constructor(e={}){this.version=Xy.v0,this.sid=new Yy,this.digestAlgorithm=new Zy,this.signatureAlgorithm=new Qy,this.signature=new I,Object.assign(this,e)}};H([z({type:F.Integer})],ab.prototype,`version`,void 0),H([z({type:Yy})],ab.prototype,`sid`,void 0),H([z({type:Zy})],ab.prototype,`digestAlgorithm`,void 0),H([z({type:rb,repeated:`set`,context:0,implicit:!0,optional:!0,raw:!0})],ab.prototype,`signedAttrs`,void 0),H([z({type:Qy})],ab.prototype,`signatureAlgorithm`,void 0),H([z({type:I})],ab.prototype,`signature`,void 0),H([z({type:rb,repeated:`set`,context:1,implicit:!0,optional:!0})],ab.prototype,`unsignedAttrs`,void 0);var ob=ib=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,ib.prototype)}};ob=ib=H([R({type:P.Set,itemType:ab})],ob);var sb=class extends ab{};sb=H([R({type:P.Sequence})],sb);var cb=class extends Ly{};cb=H([R({type:P.Choice})],cb);var lb=class{constructor(e={}){this.acIssuer=new G,this.acSerial=0,this.attrs=[],Object.assign(this,e)}};H([z({type:G})],lb.prototype,`acIssuer`,void 0),H([z({type:F.Integer})],lb.prototype,`acSerial`,void 0),H([z({type:Ty,repeated:`sequence`})],lb.prototype,`attrs`,void 0);var ub,db=ub=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,ub.prototype)}};db=ub=H([R({type:P.Sequence,itemType:F.ObjectIdentifier})],db);var fb=class{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}};H([z({type:F.Integer,optional:!0})],fb.prototype,`pathLenConstraint`,void 0),H([z({type:db,implicit:!0,context:0,optional:!0})],fb.prototype,`permittedAttrs`,void 0),H([z({type:db,implicit:!0,context:1,optional:!0})],fb.prototype,`excludedAttrs`,void 0),H([z({type:F.Boolean,defaultValue:!0})],fb.prototype,`permitUnSpecified`,void 0);var pb=class{constructor(e={}){this.issuer=new Cv,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:Cv})],pb.prototype,`issuer`,void 0),H([z({type:F.Integer,converter:L})],pb.prototype,`serial`,void 0),H([z({type:F.BitString,optional:!0})],pb.prototype,`issuerUID`,void 0);var mb;(function(e){e[e.publicKey=0]=`publicKey`,e[e.publicKeyCert=1]=`publicKeyCert`,e[e.otherObjectTypes=2]=`otherObjectTypes`})(mb||={});var hb=class{constructor(e={}){this.digestedObjectType=mb.publicKey,this.digestAlgorithm=new q,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.Enumerated})],hb.prototype,`digestedObjectType`,void 0),H([z({type:F.ObjectIdentifier,optional:!0})],hb.prototype,`otherObjectTypeID`,void 0),H([z({type:q})],hb.prototype,`digestAlgorithm`,void 0),H([z({type:F.BitString})],hb.prototype,`objectDigest`,void 0);var gb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Cv,optional:!0})],gb.prototype,`issuerName`,void 0),H([z({type:pb,context:0,implicit:!0,optional:!0})],gb.prototype,`baseCertificateID`,void 0),H([z({type:hb,context:1,implicit:!0,optional:!0})],gb.prototype,`objectDigestInfo`,void 0);var _b=class{constructor(e={}){Object.assign(this,e)}};H([z({type:G,repeated:`sequence`})],_b.prototype,`v1Form`,void 0),H([z({type:gb,context:0,implicit:!0})],_b.prototype,`v2Form`,void 0),_b=H([R({type:P.Choice})],_b);var vb=class{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}};H([z({type:F.GeneralizedTime})],vb.prototype,`notBeforeTime`,void 0),H([z({type:F.GeneralizedTime})],vb.prototype,`notAfterTime`,void 0);var yb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:pb,implicit:!0,context:0,optional:!0})],yb.prototype,`baseCertificateID`,void 0),H([z({type:Cv,implicit:!0,context:1,optional:!0})],yb.prototype,`entityName`,void 0),H([z({type:hb,implicit:!0,context:2,optional:!0})],yb.prototype,`objectDigestInfo`,void 0);var bb;(function(e){e[e.v2=1]=`v2`})(bb||={});var xb=class{constructor(e={}){this.version=bb.v2,this.holder=new yb,this.issuer=new _b,this.signature=new q,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new vb,this.attributes=[],Object.assign(this,e)}};H([z({type:F.Integer})],xb.prototype,`version`,void 0),H([z({type:yb})],xb.prototype,`holder`,void 0),H([z({type:_b})],xb.prototype,`issuer`,void 0),H([z({type:q})],xb.prototype,`signature`,void 0),H([z({type:F.Integer,converter:L})],xb.prototype,`serialNumber`,void 0),H([z({type:vb})],xb.prototype,`attrCertValidityPeriod`,void 0),H([z({type:Ty,repeated:`sequence`})],xb.prototype,`attributes`,void 0),H([z({type:F.BitString,optional:!0})],xb.prototype,`issuerUniqueID`,void 0),H([z({type:Vy,optional:!0})],xb.prototype,`extensions`,void 0);var Sb=class{constructor(e={}){this.acinfo=new xb,this.signatureAlgorithm=new q,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:xb})],Sb.prototype,`acinfo`,void 0),H([z({type:q})],Sb.prototype,`signatureAlgorithm`,void 0),H([z({type:F.BitString})],Sb.prototype,`signatureValue`,void 0);var Cb;(function(e){e[e.unmarked=1]=`unmarked`,e[e.unclassified=2]=`unclassified`,e[e.restricted=4]=`restricted`,e[e.confidential=8]=`confidential`,e[e.secret=16]=`secret`,e[e.topSecret=32]=`topSecret`})(Cb||={});var wb=class extends f_{},Tb=class{constructor(e={}){this.type=``,this.value=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier,implicit:!0,context:0})],Tb.prototype,`type`,void 0),H([z({type:F.Any,implicit:!0,context:1})],Tb.prototype,`value`,void 0);var Eb=class{constructor(e={}){this.policyId=``,this.classList=new wb(Cb.unclassified),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Eb.prototype,`policyId`,void 0),H([z({type:wb,defaultValue:new wb(Cb.unclassified)})],Eb.prototype,`classList`,void 0),H([z({type:Tb,repeated:`set`})],Eb.prototype,`securityCategories`,void 0);var Db=class{constructor(e={}){Object.assign(this,e)}};H([z({type:I})],Db.prototype,`cotets`,void 0),H([z({type:F.ObjectIdentifier})],Db.prototype,`oid`,void 0),H([z({type:F.Utf8String})],Db.prototype,`string`,void 0);var Ob=class{constructor(e={}){this.values=[],Object.assign(this,e)}};H([z({type:Cv,implicit:!0,context:0,optional:!0})],Ob.prototype,`policyAuthority`,void 0),H([z({type:Db,repeated:`sequence`})],Ob.prototype,`values`,void 0),`${av}`,`${av}`,`${av}`,`${K}`;var kb=`${iv}.10`;`${kb}`,`${kb}`,`${kb}`,`${kb}`,`${kb}`;var Ab=`2.5.4`;`${Ab}`;var jb,Mb=class{constructor(e={}){this.targetCertificate=new pb,Object.assign(this,e)}};H([z({type:pb})],Mb.prototype,`targetCertificate`,void 0),H([z({type:G,optional:!0})],Mb.prototype,`targetName`,void 0),H([z({type:hb,optional:!0})],Mb.prototype,`certDigestInfo`,void 0);var Nb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:G,context:0,implicit:!0})],Nb.prototype,`targetName`,void 0),H([z({type:G,context:1,implicit:!0})],Nb.prototype,`targetGroup`,void 0),H([z({type:Mb,context:2,implicit:!0})],Nb.prototype,`targetCert`,void 0),Nb=H([R({type:P.Choice})],Nb);var Pb=jb=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,jb.prototype)}};Pb=jb=H([R({type:P.Sequence,itemType:Nb})],Pb);var Fb,Ib=Fb=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Fb.prototype)}};Ib=Fb=H([R({type:P.Sequence,itemType:Pb})],Ib);var Lb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Cv,implicit:!0,context:0,optional:!0})],Lb.prototype,`roleAuthority`,void 0),H([z({type:G,implicit:!0,context:1})],Lb.prototype,`roleName`,void 0);var Rb=class{constructor(e={}){this.service=new G,this.ident=new G,Object.assign(this,e)}};H([z({type:G})],Rb.prototype,`service`,void 0),H([z({type:G})],Rb.prototype,`ident`,void 0),H([z({type:I,optional:!0})],Rb.prototype,`authInfo`,void 0);var zb,Bb=class{constructor(e={}){this.otherCertFormat=``,this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Bb.prototype,`otherCertFormat`,void 0),H([z({type:F.Any})],Bb.prototype,`otherCert`,void 0);var Vb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Wy})],Vb.prototype,`certificate`,void 0),H([z({type:Sb,context:2,implicit:!0})],Vb.prototype,`v2AttrCert`,void 0),H([z({type:Bb,context:3,implicit:!0})],Vb.prototype,`other`,void 0),Vb=H([R({type:P.Choice})],Vb);var Hb=zb=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,zb.prototype)}};Hb=zb=H([R({type:P.Set,itemType:Vb})],Hb);var Ub=class{constructor(e={}){this.contentType=``,this.content=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Ub.prototype,`contentType`,void 0),H([z({type:F.Any,context:0})],Ub.prototype,`content`,void 0);var Wb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:I})],Wb.prototype,`single`,void 0),H([z({type:F.Any})],Wb.prototype,`any`,void 0),Wb=H([R({type:P.Choice})],Wb);var Gb=class{constructor(e={}){this.eContentType=``,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Gb.prototype,`eContentType`,void 0),H([z({type:Wb,context:0,optional:!0})],Gb.prototype,`eContent`,void 0);var Kb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:I,context:0,implicit:!0,optional:!0})],Kb.prototype,`value`,void 0),H([z({type:I,converter:b_,context:0,implicit:!0,optional:!0,repeated:`sequence`})],Kb.prototype,`constructedValue`,void 0),Kb=H([R({type:P.Choice})],Kb);var qb=class{constructor(e={}){this.contentType=``,this.contentEncryptionAlgorithm=new eb,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],qb.prototype,`contentType`,void 0),H([z({type:eb})],qb.prototype,`contentEncryptionAlgorithm`,void 0),H([z({type:Kb,optional:!0})],qb.prototype,`encryptedContent`,void 0);var Jb=class{constructor(e={}){this.keyAttrId=``,Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Jb.prototype,`keyAttrId`,void 0),H([z({type:F.Any,optional:!0})],Jb.prototype,`keyAttr`,void 0);var Yb,Xb=class{constructor(e={}){this.subjectKeyIdentifier=new ky,Object.assign(this,e)}};H([z({type:ky})],Xb.prototype,`subjectKeyIdentifier`,void 0),H([z({type:F.GeneralizedTime,optional:!0})],Xb.prototype,`date`,void 0),H([z({type:Jb,optional:!0})],Xb.prototype,`other`,void 0);var Zb=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Xb,context:0,implicit:!0,optional:!0})],Zb.prototype,`rKeyId`,void 0),H([z({type:Jy,optional:!0})],Zb.prototype,`issuerAndSerialNumber`,void 0),Zb=H([R({type:P.Choice})],Zb);var Qb=class{constructor(e={}){this.rid=new Zb,this.encryptedKey=new I,Object.assign(this,e)}};H([z({type:Zb})],Qb.prototype,`rid`,void 0),H([z({type:I})],Qb.prototype,`encryptedKey`,void 0);var $b=Yb=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Yb.prototype)}};$b=Yb=H([R({type:P.Sequence,itemType:Qb})],$b);var ex=class{constructor(e={}){this.algorithm=new q,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:q})],ex.prototype,`algorithm`,void 0),H([z({type:F.BitString})],ex.prototype,`publicKey`,void 0);var tx=class{constructor(e={}){Object.assign(this,e)}};H([z({type:ky,context:0,implicit:!0,optional:!0})],tx.prototype,`subjectKeyIdentifier`,void 0),H([z({type:ex,context:1,implicit:!0,optional:!0})],tx.prototype,`originatorKey`,void 0),H([z({type:Jy,optional:!0})],tx.prototype,`issuerAndSerialNumber`,void 0),tx=H([R({type:P.Choice})],tx);var nx=class{constructor(e={}){this.version=Xy.v3,this.originator=new tx,this.keyEncryptionAlgorithm=new $y,this.recipientEncryptedKeys=new $b,Object.assign(this,e)}};H([z({type:F.Integer})],nx.prototype,`version`,void 0),H([z({type:tx,context:0})],nx.prototype,`originator`,void 0),H([z({type:I,context:1,optional:!0})],nx.prototype,`ukm`,void 0),H([z({type:$y})],nx.prototype,`keyEncryptionAlgorithm`,void 0),H([z({type:$b})],nx.prototype,`recipientEncryptedKeys`,void 0);var rx=class{constructor(e={}){Object.assign(this,e)}};H([z({type:ky,context:0,implicit:!0})],rx.prototype,`subjectKeyIdentifier`,void 0),H([z({type:Jy})],rx.prototype,`issuerAndSerialNumber`,void 0),rx=H([R({type:P.Choice})],rx);var ix=class{constructor(e={}){this.version=Xy.v0,this.rid=new rx,this.keyEncryptionAlgorithm=new $y,this.encryptedKey=new I,Object.assign(this,e)}};H([z({type:F.Integer})],ix.prototype,`version`,void 0),H([z({type:rx})],ix.prototype,`rid`,void 0),H([z({type:$y})],ix.prototype,`keyEncryptionAlgorithm`,void 0),H([z({type:I})],ix.prototype,`encryptedKey`,void 0);var ax=class{constructor(e={}){this.keyIdentifier=new I,Object.assign(this,e)}};H([z({type:I})],ax.prototype,`keyIdentifier`,void 0),H([z({type:F.GeneralizedTime,optional:!0})],ax.prototype,`date`,void 0),H([z({type:Jb,optional:!0})],ax.prototype,`other`,void 0);var ox=class{constructor(e={}){this.version=Xy.v4,this.kekid=new ax,this.keyEncryptionAlgorithm=new $y,this.encryptedKey=new I,Object.assign(this,e)}};H([z({type:F.Integer})],ox.prototype,`version`,void 0),H([z({type:ax})],ox.prototype,`kekid`,void 0),H([z({type:$y})],ox.prototype,`keyEncryptionAlgorithm`,void 0),H([z({type:I})],ox.prototype,`encryptedKey`,void 0);var sx=class{constructor(e={}){this.version=Xy.v0,this.keyEncryptionAlgorithm=new $y,this.encryptedKey=new I,Object.assign(this,e)}};H([z({type:F.Integer})],sx.prototype,`version`,void 0),H([z({type:nb,context:0,optional:!0})],sx.prototype,`keyDerivationAlgorithm`,void 0),H([z({type:$y})],sx.prototype,`keyEncryptionAlgorithm`,void 0),H([z({type:I})],sx.prototype,`encryptedKey`,void 0);var cx=class{constructor(e={}){this.oriType=``,this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],cx.prototype,`oriType`,void 0),H([z({type:F.Any})],cx.prototype,`oriValue`,void 0);var lx=class{constructor(e={}){Object.assign(this,e)}};H([z({type:ix,optional:!0})],lx.prototype,`ktri`,void 0),H([z({type:nx,context:1,implicit:!0,optional:!0})],lx.prototype,`kari`,void 0),H([z({type:ox,context:2,implicit:!0,optional:!0})],lx.prototype,`kekri`,void 0),H([z({type:sx,context:3,implicit:!0,optional:!0})],lx.prototype,`pwri`,void 0),H([z({type:cx,context:4,implicit:!0,optional:!0})],lx.prototype,`ori`,void 0),lx=H([R({type:P.Choice})],lx);var ux,dx=ux=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,ux.prototype)}};dx=ux=H([R({type:P.Set,itemType:lx})],dx);var fx,px=`${iv}.16`;`${px}`,`${px}`;var mx=class{constructor(e={}){this.otherRevInfoFormat=``,this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],mx.prototype,`otherRevInfoFormat`,void 0),H([z({type:F.Any})],mx.prototype,`otherRevInfo`,void 0);var hx=class{constructor(e={}){this.other=new mx,Object.assign(this,e)}};H([z({type:mx,context:1,implicit:!0})],hx.prototype,`other`,void 0),hx=H([R({type:P.Choice})],hx);var gx=fx=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,fx.prototype)}};gx=fx=H([R({type:P.Set,itemType:hx})],gx);var _x=class{constructor(e={}){Object.assign(this,e)}};H([z({type:Hb,context:0,implicit:!0,optional:!0})],_x.prototype,`certs`,void 0),H([z({type:gx,context:1,implicit:!0,optional:!0})],_x.prototype,`crls`,void 0);var vx,yx=vx=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,vx.prototype)}};yx=vx=H([R({type:P.Set,itemType:rb})],yx);var bx=class{constructor(e={}){this.version=Xy.v0,this.recipientInfos=new dx,this.encryptedContentInfo=new qb,Object.assign(this,e)}};H([z({type:F.Integer})],bx.prototype,`version`,void 0),H([z({type:_x,context:0,implicit:!0,optional:!0})],bx.prototype,`originatorInfo`,void 0),H([z({type:dx})],bx.prototype,`recipientInfos`,void 0),H([z({type:qb})],bx.prototype,`encryptedContentInfo`,void 0),H([z({type:yx,context:1,implicit:!0,optional:!0})],bx.prototype,`unprotectedAttrs`,void 0);var xx=`1.2.840.113549.1.7.2`,Sx,Cx=Sx=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,Sx.prototype)}};Cx=Sx=H([R({type:P.Set,itemType:Zy})],Cx);var wx=class{constructor(e={}){this.version=Xy.v0,this.digestAlgorithms=new Cx,this.encapContentInfo=new Gb,this.signerInfos=new ob,Object.assign(this,e)}};H([z({type:F.Integer})],wx.prototype,`version`,void 0),H([z({type:Cx})],wx.prototype,`digestAlgorithms`,void 0),H([z({type:Gb})],wx.prototype,`encapContentInfo`,void 0),H([z({type:Hb,context:0,implicit:!0,optional:!0})],wx.prototype,`certificates`,void 0),H([z({type:gx,context:1,implicit:!0,optional:!0})],wx.prototype,`crls`,void 0),H([z({type:ob})],wx.prototype,`signerInfos`,void 0);var Tx=`1.2.840.10045.2.1`,Ex=`1.2.840.10045.4.1`,Dx=`1.2.840.10045.4.3.1`,Ox=`1.2.840.10045.4.3.2`,kx=`1.2.840.10045.4.3.3`,Ax=`1.2.840.10045.4.3.4`,jx=`1.2.840.10045.3.1.7`,Mx=`1.3.132.0.34`,Nx=`1.3.132.0.35`;function Px(e){return new q({algorithm:e})}var Fx=Px(Ex);Px(Dx);var Ix=Px(Ox),Lx=Px(kx),Rx=Px(Ax),zx=class{constructor(e={}){Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],zx.prototype,`fieldType`,void 0),H([z({type:F.Any})],zx.prototype,`parameters`,void 0),zx=H([R({type:P.Sequence})],zx);var Bx=class extends I{},Vx=class{constructor(e={}){Object.assign(this,e)}};H([z({type:F.OctetString})],Vx.prototype,`a`,void 0),H([z({type:F.OctetString})],Vx.prototype,`b`,void 0),H([z({type:F.BitString,optional:!0})],Vx.prototype,`seed`,void 0),Vx=H([R({type:P.Sequence})],Vx);var Hx;(function(e){e[e.ecpVer1=1]=`ecpVer1`})(Hx||={});var Ux=class{constructor(e={}){this.version=Hx.ecpVer1,Object.assign(this,e)}};H([z({type:F.Integer})],Ux.prototype,`version`,void 0),H([z({type:zx})],Ux.prototype,`fieldID`,void 0),H([z({type:Vx})],Ux.prototype,`curve`,void 0),H([z({type:Bx})],Ux.prototype,`base`,void 0),H([z({type:F.Integer,converter:L})],Ux.prototype,`order`,void 0),H([z({type:F.Integer,optional:!0})],Ux.prototype,`cofactor`,void 0),Ux=H([R({type:P.Sequence})],Ux);var Wx=class{constructor(e={}){Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],Wx.prototype,`namedCurve`,void 0),H([z({type:F.Null})],Wx.prototype,`implicitCurve`,void 0),H([z({type:Ux})],Wx.prototype,`specifiedCurve`,void 0),Wx=H([R({type:P.Choice})],Wx);var Gx=class{constructor(e={}){this.version=1,this.privateKey=new I,Object.assign(this,e)}};H([z({type:F.Integer})],Gx.prototype,`version`,void 0),H([z({type:I})],Gx.prototype,`privateKey`,void 0),H([z({type:Wx,context:0,optional:!0})],Gx.prototype,`parameters`,void 0),H([z({type:F.BitString,context:1,optional:!0})],Gx.prototype,`publicKey`,void 0);var Kx=class{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.Integer,converter:L})],Kx.prototype,`r`,void 0),H([z({type:F.Integer,converter:L})],Kx.prototype,`s`,void 0);var qx=`1.2.840.113549.1.1`,Jx=`${qx}.1`,Yx=`${qx}.7`,Xx=`${qx}.9`,Zx=`${qx}.10`,Qx=`${qx}.2`,$x=`${qx}.4`,eS=`${qx}.5`,tS=`${qx}.14`,nS=`${qx}.11`,rS=`${qx}.12`,iS=`${qx}.13`,aS=`${qx}.15`,oS=`${qx}.16`,sS=`1.3.14.3.2.26`,cS=`2.16.840.1.101.3.4.2.4`,lS=`2.16.840.1.101.3.4.2.1`,uS=`2.16.840.1.101.3.4.2.2`,dS=`2.16.840.1.101.3.4.2.3`,fS=`2.16.840.1.101.3.4.2.5`,pS=`2.16.840.1.101.3.4.2.6`,mS=`1.2.840.113549.2.2`,hS=`1.2.840.113549.2.5`,gS=`${qx}.8`;function _S(e){return new q({algorithm:e,parameters:null})}_S(mS),_S(hS);var vS=_S(sS);_S(cS),_S(lS),_S(uS),_S(dS),_S(fS),_S(pS);var yS=new q({algorithm:gS,parameters:V.serialize(vS)}),bS=new q({algorithm:Xx,parameters:V.serialize(y_.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});_S(Jx),_S(Qx),_S($x),_S(eS),_S(aS),_S(oS),_S(rS),_S(iS),_S(aS),_S(oS);var xS=class{constructor(e={}){this.hashAlgorithm=new q(vS),this.maskGenAlgorithm=new q({algorithm:gS,parameters:V.serialize(vS)}),this.pSourceAlgorithm=new q(bS),Object.assign(this,e)}};H([z({type:q,context:0,defaultValue:vS})],xS.prototype,`hashAlgorithm`,void 0),H([z({type:q,context:1,defaultValue:yS})],xS.prototype,`maskGenAlgorithm`,void 0),H([z({type:q,context:2,defaultValue:bS})],xS.prototype,`pSourceAlgorithm`,void 0),new q({algorithm:Yx,parameters:V.serialize(new xS)});var SS=class{constructor(e={}){this.hashAlgorithm=new q(vS),this.maskGenAlgorithm=new q({algorithm:gS,parameters:V.serialize(vS)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}};H([z({type:q,context:0,defaultValue:vS})],SS.prototype,`hashAlgorithm`,void 0),H([z({type:q,context:1,defaultValue:yS})],SS.prototype,`maskGenAlgorithm`,void 0),H([z({type:F.Integer,context:2,defaultValue:20})],SS.prototype,`saltLength`,void 0),H([z({type:F.Integer,context:3,defaultValue:1})],SS.prototype,`trailerField`,void 0),new q({algorithm:Zx,parameters:V.serialize(new SS)});var CS=class{constructor(e={}){this.digestAlgorithm=new q,this.digest=new I,Object.assign(this,e)}};H([z({type:q})],CS.prototype,`digestAlgorithm`,void 0),H([z({type:I})],CS.prototype,`digest`,void 0);var wS,TS=class{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.Integer,converter:L})],TS.prototype,`prime`,void 0),H([z({type:F.Integer,converter:L})],TS.prototype,`exponent`,void 0),H([z({type:F.Integer,converter:L})],TS.prototype,`coefficient`,void 0);var ES=wS=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,wS.prototype)}};ES=wS=H([R({type:P.Sequence,itemType:TS})],ES);var DS=class{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)}};H([z({type:F.Integer})],DS.prototype,`version`,void 0),H([z({type:F.Integer,converter:L})],DS.prototype,`modulus`,void 0),H([z({type:F.Integer,converter:L})],DS.prototype,`publicExponent`,void 0),H([z({type:F.Integer,converter:L})],DS.prototype,`privateExponent`,void 0),H([z({type:F.Integer,converter:L})],DS.prototype,`prime1`,void 0),H([z({type:F.Integer,converter:L})],DS.prototype,`prime2`,void 0),H([z({type:F.Integer,converter:L})],DS.prototype,`exponent1`,void 0),H([z({type:F.Integer,converter:L})],DS.prototype,`exponent2`,void 0),H([z({type:F.Integer,converter:L})],DS.prototype,`coefficient`,void 0),H([z({type:ES,optional:!0})],DS.prototype,`otherPrimeInfos`,void 0);var OS=class{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.Integer,converter:L})],OS.prototype,`modulus`,void 0),H([z({type:F.Integer,converter:L})],OS.prototype,`publicExponent`,void 0);var kS;(function(e){e[e.Transient=0]=`Transient`,e[e.Singleton=1]=`Singleton`,e[e.ResolutionScoped=2]=`ResolutionScoped`,e[e.ContainerScoped=3]=`ContainerScoped`})(kS||={});var AS=kS,jS=function(e,t){return jS=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},jS(e,t)};function MS(e,t){jS(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function NS(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function PS(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(o){if(r)throw TypeError(`Generator is already executing.`);for(;n;)try{if(r=1,i&&(a=o[0]&2?i.return:o[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;switch(i=0,a&&(o=[o[0]&2,a.value]),o[0]){case 0:case 1:a=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1],a=o;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(o);break}a[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e],i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}function FS(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function IS(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function LS(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(IS(arguments[t]));return e}function RS(e){var t=Reflect.getMetadata(`design:paramtypes`,e)||[],n=Reflect.getOwnMetadata(`injectionTokens`,e)||{};return Object.keys(n).forEach(function(e){t[+e]=n[e]}),t}function zS(e){return!!e.useClass}function BS(e){return!!e.useFactory}var VS=function(){function e(e){this.wrap=e,this.reflectMethods=[`get`,`getPrototypeOf`,`setPrototypeOf`,`getOwnPropertyDescriptor`,`defineProperty`,`has`,`set`,`deleteProperty`,`apply`,`construct`,`ownKeys`]}return e.prototype.createProxy=function(e){var t=this,n={},r=!1,i;return new Proxy(n,this.createHandler(function(){return r||=(i=e(t.wrap()),!0),i}))},e.prototype.createHandler=function(e){var t={};return this.reflectMethods.forEach(function(n){t[n]=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t[0]=e(),Reflect[n].apply(void 0,LS(t))}}),t},e}();function HS(e){return typeof e==`string`||typeof e==`symbol`}function US(e){return typeof e==`object`&&`token`in e&&`multiple`in e}function WS(e){return typeof e==`object`&&`token`in e&&`transform`in e}function GS(e){return typeof e==`function`||e instanceof VS}function KS(e){return!!e.useToken}function qS(e){return e.useValue!=null}function JS(e){return zS(e)||qS(e)||KS(e)||BS(e)}var YS=function(){function e(){this._registryMap=new Map}return e.prototype.entries=function(){return this._registryMap.entries()},e.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},e.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},e.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},e.prototype.setAll=function(e,t){this._registryMap.set(e,t)},e.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},e.prototype.clear=function(){this._registryMap.clear()},e.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},e}(),XS=function(e){MS(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(YS),ZS=function(){function e(){this.scopedResolutions=new Map}return e}();function QS(e,t){return e===null?`at position #`+t:`"`+e.split(`,`)[t].trim()+`" at position #`+t}function $S(e,t,n){return n===void 0&&(n=` `),LS([e],t.message.split(`
297
297
  `).map(function(e){return n+e})).join(`
298
- `)}function $S(e,t,n){var r=FS(e.toString().match(/constructor\(([\w, ]+)\)/)||[],2)[1];return QS(`Cannot inject the dependency `+ZS(r===void 0?null:r,t)+` of "`+e.name+`" constructor. Reason:`,n)}function eC(e){return!(typeof e.dispose!=`function`||e.dispose.length>0)}var tC=function(e){jS(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(JS),nC=function(e){jS(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(JS),rC=function(){function e(){this.preResolution=new tC,this.postResolution=new nC}return e}(),iC=new Map,aC=new(function(){function e(e){this.parent=e,this._registry=new YS,this.interceptors=new rC,this.disposed=!1,this.disposables=new Set}return e.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:kS.Transient}),this.ensureNotDisposed();var r=qS(t)?t:{useClass:t};if(GS(r))for(var i=[e],a=r;a!=null;){var o=a.useToken;if(i.includes(o))throw Error(`Token registration cycle detected! `+IS(i,[o]).join(` -> `));i.push(o);var s=this._registry.get(o);a=s&&GS(s.provider)?s.provider:null}if((n.lifecycle===kS.Singleton||n.lifecycle==kS.ContainerScoped||n.lifecycle==kS.ResolutionScoped)&&(KS(r)||zS(r)))throw Error(`Cannot use lifecycle "`+kS[n.lifecycle]+`" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:r,options:n}),this},e.prototype.registerType=function(e,t){return this.ensureNotDisposed(),VS(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},e.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},e.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),VS(e)){if(VS(t))return this.register(e,{useToken:t},{lifecycle:kS.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:kS.Singleton});throw Error(`Cannot register a type name as a singleton without a "to" token`)}var n=e;return t&&!VS(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:kS.Singleton})},e.prototype.resolve=function(e,t,n){t===void 0&&(t=new XS),n===void 0&&(n=!1),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&VS(e)){if(n)return;throw Error(`Attempted to resolve unregistered dependency token: "`+e.toString()+`"`)}if(this.executePreResolutionInterceptor(e,`Single`),r){var i=this.resolveRegistration(r,t);return this.executePostResolutionInterceptor(e,i,`Single`),i}if(WS(e)){var i=this.construct(e,t);return this.executePostResolutionInterceptor(e,i,`Single`),i}throw Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},e.prototype.executePreResolutionInterceptor=function(e,t){var n,r;if(this.interceptors.preResolution.has(e)){var i=[];try{for(var a=PS(this.interceptors.preResolution.getAll(e)),o=a.next();!o.done;o=a.next()){var s=o.value;s.options.frequency!=`Once`&&i.push(s),s.callback(e,t)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,i)}},e.prototype.executePostResolutionInterceptor=function(e,t,n){var r,i;if(this.interceptors.postResolution.has(e)){var a=[];try{for(var o=PS(this.interceptors.postResolution.getAll(e)),s=o.next();!s.done;s=o.next()){var c=s.value;c.options.frequency!=`Once`&&a.push(c),c.callback(e,t,n)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}this.interceptors.postResolution.setAll(e,a)}},e.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===kS.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===kS.Singleton,r=e.options.lifecycle===kS.ContainerScoped,i=n||r,a=KS(e.provider)?e.provider.useValue:GS(e.provider)?i?e.instance||=this.resolve(e.provider.useToken,t):this.resolve(e.provider.useToken,t):RS(e.provider)?i?e.instance||=this.construct(e.provider.useClass,t):this.construct(e.provider.useClass,t):zS(e.provider)?e.provider.useFactory(this):this.construct(e.provider,t);return e.options.lifecycle===kS.ResolutionScoped&&t.scopedResolutions.set(e,a),a},e.prototype.resolveAll=function(e,t,n){var r=this;t===void 0&&(t=new XS),n===void 0&&(n=!1),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&VS(e)){if(n)return[];throw Error(`Attempted to resolve unregistered dependency token: "`+e.toString()+`"`)}if(this.executePreResolutionInterceptor(e,`All`),i){var a=i.map(function(e){return r.resolveRegistration(e,t)});return this.executePostResolutionInterceptor(e,a,`All`),a}var o=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,o,`All`),o},e.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)},e.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},e.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=PS(this._registry.entries()),r=n.next();!r.done;r=n.next()){var i=FS(r.value,2),a=i[0],o=i[1];this._registry.setAll(a,o.filter(function(e){return!KS(e.provider)}).map(function(e){return e.instance=void 0,e}))}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e.prototype.createChildContainer=function(){var t,n;this.ensureNotDisposed();var r=new e(this);try{for(var i=PS(this._registry.entries()),a=i.next();!a.done;a=i.next()){var o=FS(a.value,2),s=o[0],c=o[1];c.some(function(e){return e.options.lifecycle===kS.ContainerScoped})&&r._registry.setAll(s,c.map(function(e){return e.options.lifecycle===kS.ContainerScoped?{provider:e.provider,options:e.options}:e}))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},e.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:`Always`}),this.interceptors.preResolution.set(e,{callback:t,options:n})},e.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:`Always`}),this.interceptors.postResolution.set(e,{callback:t,options:n})},e.prototype.dispose=function(){return MS(this,void 0,void 0,function(){var e;return NS(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(t){var n=t.dispose();n&&e.push(n)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},e.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},e.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},e.prototype.construct=function(e,t){var n=this;if(e instanceof BS)return e.createProxy(function(e){return n.resolve(e,t)});var r=(function(){var r=iC.get(e);if(!r||r.length===0){if(e.length===0)return new e;throw Error(`TypeInfo not known for "`+e.name+`"`)}var i=r.map(n.resolveParams(t,e));return new(e.bind.apply(e,IS([void 0],i)))})();return eC(r)&&this.disposables.add(r),r},e.prototype.resolveParams=function(e,t){var n=this;return function(r,i){var a,o,s;try{return HS(r)?US(r)?r.multiple?(a=n.resolve(r.transform)).transform.apply(a,IS([n.resolveAll(r.token,new XS,r.isOptional)],r.transformArgs)):(o=n.resolve(r.transform)).transform.apply(o,IS([n.resolve(r.token,e,r.isOptional)],r.transformArgs)):r.multiple?n.resolveAll(r.token,new XS,r.isOptional):n.resolve(r.token,e,r.isOptional):US(r)?(s=n.resolve(r.transform,e)).transform.apply(s,IS([n.resolve(r.token,e)],r.transformArgs)):n.resolve(r,e)}catch(e){throw Error($S(t,i,e))}}},e.prototype.ensureNotDisposed=function(){if(this.disposed)throw Error(`This container has been disposed, you cannot interact with a disposed container`)},e}());function oC(e){return function(t){iC.set(t,LS(t)),e&&e.token&&(Array.isArray(e.token)?e.token.forEach(function(e){aC.register(e,t)}):aC.register(e.token,t))}}if(typeof Reflect>`u`||!Reflect.getMetadata)throw Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var sC,cC=class{constructor(e={}){this.attrId=``,this.attrValues=[],Object.assign(e)}};H([z({type:F.ObjectIdentifier})],cC.prototype,`attrId`,void 0),H([z({type:F.Any,repeated:`set`})],cC.prototype,`attrValues`,void 0);var lC=sC=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,sC.prototype)}};lC=sC=H([R({type:P.Sequence,itemType:cC})],lC);var uC,dC=uC=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,uC.prototype)}};dC=uC=H([R({type:P.Sequence,itemType:Hb})],dC);var fC=`1.2.840.113549.1.12`,pC=`${fC}.1`;`${pC}`,`${pC}`,`${pC}`,`${pC}`,`${pC}`,`${pC}`;var mC=`${fC}.10.1`;`${mC}`,`${mC}`,`${mC}`,`${mC}`,`${mC}`,`${mC}`;var hC=`1.2.840.113549.1.9`,gC=class{constructor(e={}){this.certId=``,this.certValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],gC.prototype,`certId`,void 0),H([z({type:F.Any,context:0})],gC.prototype,`certValue`,void 0);var _C=`${hC}.22`;`${_C}`,`${_C}`;var vC=class{constructor(e={}){this.crlId=``,this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],vC.prototype,`crlId`,void 0),H([z({type:F.Any,context:0})],vC.prototype,`crltValue`,void 0),`${hC}`;var yC=class extends I{},bC=class{constructor(e={}){this.encryptionAlgorithm=new J,this.encryptedData=new yC,Object.assign(this,e)}};H([z({type:J})],bC.prototype,`encryptionAlgorithm`,void 0),H([z({type:yC})],bC.prototype,`encryptedData`,void 0);var xC,SC;(function(e){e[e.v1=0]=`v1`})(SC||={});var CC=class extends I{},wC=xC=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,xC.prototype)}};wC=xC=H([R({type:P.Sequence,itemType:wy})],wC);var TC=class{constructor(e={}){this.version=SC.v1,this.privateKeyAlgorithm=new J,this.privateKey=new CC,Object.assign(this,e)}};H([z({type:F.Integer})],TC.prototype,`version`,void 0),H([z({type:J})],TC.prototype,`privateKeyAlgorithm`,void 0),H([z({type:CC})],TC.prototype,`privateKey`,void 0),H([z({type:wC,implicit:!0,context:0,optional:!0})],TC.prototype,`attributes`,void 0);var EC=class extends TC{};EC=H([R({type:P.Sequence})],EC);var DC=class extends bC{};DC=H([R({type:P.Sequence})],DC);var OC=class{constructor(e={}){this.secretTypeId=``,this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],OC.prototype,`secretTypeId`,void 0),H([z({type:F.Any,context:0})],OC.prototype,`secretValue`,void 0);var kC=class{constructor(e={}){this.mac=new SS,this.macSalt=new I,this.iterations=1,Object.assign(this,e)}};H([z({type:SS})],kC.prototype,`mac`,void 0),H([z({type:I})],kC.prototype,`macSalt`,void 0),H([z({type:F.Integer,defaultValue:1})],kC.prototype,`iterations`,void 0);var AC=class{constructor(e={}){this.version=3,this.authSafe=new Hb,this.macData=new kC,Object.assign(this,e)}};H([z({type:F.Integer})],AC.prototype,`version`,void 0),H([z({type:Hb})],AC.prototype,`authSafe`,void 0),H([z({type:kC,optional:!0})],AC.prototype,`macData`,void 0);var jC,MC=class{constructor(e={}){this.bagId=``,this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],MC.prototype,`bagId`,void 0),H([z({type:F.Any,context:0})],MC.prototype,`bagValue`,void 0),H([z({type:cC,repeated:`set`,optional:!0})],MC.prototype,`bagAttributes`,void 0);var NC=jC=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,jC.prototype)}};NC=jC=H([R({type:P.Sequence,itemType:MC})],NC);var PC,FC,IC,Y=`1.2.840.113549.1.9`;`${Y}`;var LC=`${Y}.24`,RC=`${Y}.25`,zC=`${Y}.26`,BC=`${Y}.27`;`${LC}`,`${LC}`,`${Y}`,`${Y}`,`${Y}`,`${Y}`,`${Y}`,`${Y}`;var VC=`${Y}.7`;`${Y}`,`${Y}`,`${Y}`;var HC=`${Y}.14`;`${Y}`,`${Y}`,`${Y}`,`${RC}`,`${RC}`,`${RC}`,`${RC}`,`${RC}`;var UC=`1.3.6.1.5.5.7.9`;`${UC}`,`${UC}`,`${UC}`,`${UC}`,`${UC}`,`${zC}`,`${zC}`,`${BC}`,`${BC}`,`${Y}`,`${Y}`,`${Y}`,`${kb}`;var WC=class extends Y_{constructor(e={}){super(e)}toString(){return{}.toString(),this.ia5String||super.toString()}};H([z({type:F.IA5String})],WC.prototype,`ia5String`,void 0),WC=H([R({type:P.Choice})],WC);var GC=class extends Hb{};GC=H([R({type:P.Sequence})],GC);var KC=class extends AC{};KC=H([R({type:P.Sequence})],KC);var qC=class extends bC{};qC=H([R({type:P.Sequence})],qC);var JC=class{constructor(e=``){this.value=e}toString(){return this.value}};H([z({type:F.IA5String})],JC.prototype,`value`,void 0),JC=H([R({type:P.Choice})],JC);var YC=class extends WC{};YC=H([R({type:P.Choice})],YC);var XC=class extends Y_{};XC=H([R({type:P.Choice})],XC);var ZC=class{constructor(e=new Date){this.value=e}};H([z({type:F.GeneralizedTime})],ZC.prototype,`value`,void 0),ZC=H([R({type:P.Choice})],ZC);var QC=class extends Y_{};QC=H([R({type:P.Choice})],QC);var $C=class{constructor(e=`M`){this.value=e}toString(){return this.value}};H([z({type:F.PrintableString})],$C.prototype,`value`,void 0),$C=H([R({type:P.Choice})],$C);var ew=class{constructor(e=``){this.value=e}toString(){return this.value}};H([z({type:F.PrintableString})],ew.prototype,`value`,void 0),ew=H([R({type:P.Choice})],ew);var tw=class extends ew{};tw=H([R({type:P.Choice})],tw);var nw=class extends Y_{};nw=H([R({type:P.Choice})],nw);var rw=class{constructor(e=``){this.value=e}toString(){return this.value}};H([z({type:F.ObjectIdentifier})],rw.prototype,`value`,void 0),rw=H([R({type:P.Choice})],rw);var iw=class extends Iy{};iw=H([R({type:P.Choice})],iw);var aw=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};H([z({type:F.Integer})],aw.prototype,`value`,void 0),aw=H([R({type:P.Choice})],aw);var ow=class extends ib{};ow=H([R({type:P.Sequence})],ow);var sw=class extends Y_{};sw=H([R({type:P.Choice})],sw);var cw=PC=class extends By{constructor(e){super(e),Object.setPrototypeOf(this,PC.prototype)}};cw=PC=H([R({type:P.Sequence})],cw);var lw=FC=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,FC.prototype)}};lw=FC=H([R({type:P.Set,itemType:nb})],lw);var uw=class{constructor(e=``){this.value=e}toString(){return this.value}};H([z({type:F.BmpString})],uw.prototype,`value`,void 0),uw=H([R({type:P.Choice})],uw);var dw=class extends J{};dw=H([R({type:P.Sequence})],dw);var fw=IC=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,IC.prototype)}};fw=IC=H([R({type:P.Sequence,itemType:dw})],fw);var pw,mw=pw=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,pw.prototype)}};mw=pw=H([R({type:P.Sequence,itemType:wy})],mw);var hw=class{constructor(e={}){this.version=0,this.subject=new G,this.subjectPKInfo=new Fy,this.attributes=new mw,Object.assign(this,e)}};H([z({type:F.Integer})],hw.prototype,`version`,void 0),H([z({type:G})],hw.prototype,`subject`,void 0),H([z({type:Fy})],hw.prototype,`subjectPKInfo`,void 0),H([z({type:mw,implicit:!0,context:0,optional:!0})],hw.prototype,`attributes`,void 0);var gw=class{constructor(e={}){this.certificationRequestInfo=new hw,this.signatureAlgorithm=new J,this.signature=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:hw,raw:!0})],gw.prototype,`certificationRequestInfo`,void 0),H([z({type:J})],gw.prototype,`signatureAlgorithm`,void 0),H([z({type:F.BitString})],gw.prototype,`signature`,void 0);var _w=`crypto.algorithm`,vw=class{getAlgorithms(){return aC.resolveAll(_w)}toAsnAlgorithm(e){({...e});for(let t of this.getAlgorithms()){let n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){let t=new J({algorithm:e.name});return`parameters`in e&&(t.parameters=e.parameters),t}throw Error(`Cannot convert WebCrypto algorithm to ASN.1 algorithm`)}toWebAlgorithm(e){for(let t of this.getAlgorithms()){let n=t.toWebAlgorithm(e);if(n)return n}return{name:e.algorithm,parameters:e.parameters}}},yw=`crypto.algorithmProvider`;aC.registerSingleton(yw,vw);var bw,xw=`1.3.36.3.3.2.8.1.1`,Sw=`${xw}.1`,Cw=`${xw}.2`,ww=`${xw}.3`,Tw=`${xw}.4`,Ew=`${xw}.5`,Dw=`${xw}.6`,Ow=`${xw}.7`,kw=`${xw}.8`,Aw=`${xw}.9`,jw=`${xw}.10`,Mw=`${xw}.11`,Nw=`${xw}.12`,Pw=`${xw}.13`,Fw=`${xw}.14`,Iw=`brainpoolP160r1`,Lw=`brainpoolP160t1`,Rw=`brainpoolP192r1`,zw=`brainpoolP192t1`,Bw=`brainpoolP224r1`,Vw=`brainpoolP224t1`,Hw=`brainpoolP256r1`,Uw=`brainpoolP256t1`,Ww=`brainpoolP320r1`,Gw=`brainpoolP320t1`,Kw=`brainpoolP384r1`,qw=`brainpoolP384t1`,Jw=`brainpoolP512r1`,Yw=`brainpoolP512t1`,X=`ECDSA`,Xw=bw=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case X.toLowerCase():if(`hash`in e)switch((typeof e.hash==`string`?e.hash:e.hash.name).toLowerCase()){case`sha-1`:return Px;case`sha-256`:return Fx;case`sha-384`:return Ix;case`sha-512`:return Lx}else if(`namedCurve`in e){let t=``;switch(e.namedCurve){case`P-256`:t=Ax;break;case`K-256`:t=bw.SECP256K1;break;case`P-384`:t=jx;break;case`P-521`:t=Mx;break;case Iw:t=Sw;break;case Lw:t=Cw;break;case Rw:t=ww;break;case zw:t=Tw;break;case Bw:t=Ew;break;case Vw:t=Dw;break;case Hw:t=Ow;break;case Uw:t=kw;break;case Ww:t=Aw;break;case Gw:t=jw;break;case Kw:t=Mw;break;case qw:t=Nw;break;case Jw:t=Pw;break;case Yw:t=Fw;break}if(t)return new J({algorithm:wx,parameters:V.serialize(new Ux({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Tx:return{name:X,hash:{name:`SHA-1`}};case Dx:return{name:X,hash:{name:`SHA-256`}};case Ox:return{name:X,hash:{name:`SHA-384`}};case kx:return{name:X,hash:{name:`SHA-512`}};case wx:if(!e.parameters)throw TypeError(`Cannot get required parameters from EC algorithm`);switch(V.parse(e.parameters,Ux).namedCurve){case Ax:return{name:X,namedCurve:`P-256`};case bw.SECP256K1:return{name:X,namedCurve:`K-256`};case jx:return{name:X,namedCurve:`P-384`};case Mx:return{name:X,namedCurve:`P-521`};case Sw:return{name:X,namedCurve:Iw};case Cw:return{name:X,namedCurve:Lw};case ww:return{name:X,namedCurve:Rw};case Tw:return{name:X,namedCurve:zw};case Ew:return{name:X,namedCurve:Bw};case Dw:return{name:X,namedCurve:Vw};case Ow:return{name:X,namedCurve:Hw};case kw:return{name:X,namedCurve:Uw};case Aw:return{name:X,namedCurve:Ww};case jw:return{name:X,namedCurve:Gw};case Mw:return{name:X,namedCurve:Kw};case Nw:return{name:X,namedCurve:qw};case Pw:return{name:X,namedCurve:Jw};case Fw:return{name:X,namedCurve:Yw}}}return null}};Xw.SECP256K1=`1.3.132.0.10`,Xw=bw=H([oC()],Xw),aC.registerSingleton(_w,Xw);var Zw=Symbol(`name`),Qw=Symbol(`value`),Z=class{constructor(e,t={},n=``){this[Zw]=e,this[Qw]=n;for(let e in t)this[e]=t[e]}};Z.NAME=Zw,Z.VALUE=Qw;var $w=class{static toTextObject(e){let t=new Z(`Algorithm Identifier`,{},eT.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case wx:{let n=new Xw().toWebAlgorithm(e);n&&`namedCurve`in n?t[`Named Curve`]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}},eT=class{static toString(e){return this.items[e]||e}};eT.items={[oS]:`sha1`,[sS]:`sha224`,[cS]:`sha256`,[lS]:`sha384`,[uS]:`sha512`,[qx]:`rsaEncryption`,[$x]:`sha1WithRSAEncryption`,[eS]:`sha224WithRSAEncryption`,[tS]:`sha256WithRSAEncryption`,[nS]:`sha384WithRSAEncryption`,[rS]:`sha512WithRSAEncryption`,[wx]:`ecPublicKey`,[Tx]:`ecdsaWithSHA1`,[Ex]:`ecdsaWithSHA224`,[Dx]:`ecdsaWithSHA256`,[Ox]:`ecdsaWithSHA384`,[kx]:`ecdsaWithSHA512`,[Qv]:`TLS WWW server authentication`,[$v]:`TLS WWW client authentication`,[ey]:`Code Signing`,[ty]:`E-mail Protection`,[ny]:`Time Stamping`,[ry]:`OCSP Signing`,[bx]:`Signed Data`};var tT=class{static serialize(e){return this.serializeObj(e).join(`
299
- `)}static pad(e=0){return``.padStart(2*e,` `)}static serializeObj(e,t=0){let n=[],r=this.pad(t++),i=``,a=e[Z.VALUE];a&&(i=` ${a}`),n.push(`${r}${e[Z.NAME]}:${i}`),r=this.pad(t);for(let i in e){if(typeof i==`symbol`)continue;let a=e[i],o=i?`${i}: `:``;if(typeof a==`string`||typeof a==`number`||typeof a==`boolean`)n.push(`${r}${o}${a}`);else if(a instanceof Date)n.push(`${r}${o}${a.toUTCString()}`);else if(Array.isArray(a))for(let e of a)e[Z.NAME]=i,n.push(...this.serializeObj(e,t));else if(a instanceof Z)a[Z.NAME]=i,n.push(...this.serializeObj(a,t));else if(M.BufferSourceConverter.isBufferSource(a))i?(n.push(`${r}${o}`),n.push(...this.serializeBufferSource(a,t+1))):n.push(...this.serializeBufferSource(a,t));else if(`toTextObject`in a){let e=a.toTextObject();e[Z.NAME]=i,n.push(...this.serializeObj(e,t))}else throw TypeError(`Cannot serialize data in text format. Unsupported type.`)}return n}static serializeBufferSource(e,t=0){let n=this.pad(t),r=M.BufferSourceConverter.toUint8Array(e),i=[];for(let e=0;e<r.length;){let t=[];for(let n=0;n<16&&e<r.length;n++){n===8&&t.push(``);let i=r[e++].toString(16).padStart(2,`0`);t.push(i)}i.push(`${n}${t.join(` `)}`)}return i}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}};tT.oidSerializer=eT,tT.algorithmSerializer=$w;var nT,rT=class e{get rawData(){return U(this,nT,`f`)||W(this,nT,V.serialize(this.asn),`f`),U(this,nT,`f`)}constructor(...e){nT.set(this,void 0),M.BufferSourceConverter.isBufferSource(e[0])?(this.asn=V.parse(e[0],e[1]),W(this,nT,M.BufferSourceConverter.toArrayBuffer(e[0]),`f`),this.onInit(this.asn)):(this.asn=e[0],this.onInit(this.asn))}equal(t){return t instanceof e?(0,M.isEqual)(t.rawData,this.rawData):!1}toString(e=`text`){switch(e){case`asn`:return V.toString(this.rawData);case`text`:return tT.serialize(this.toTextObject());case`hex`:return M.Convert.ToHex(this.rawData);case`base64`:return M.Convert.ToBase64(this.rawData);case`base64url`:return M.Convert.ToBase64Url(this.rawData);default:throw TypeError(`Argument 'format' is unsupported value`)}}getTextName(){return this.constructor.NAME}toTextObject(){let e=this.toTextObjectEmpty();return e[``]=this.rawData,e}toTextObjectEmpty(e){return new Z(this.getTextName(),{},e)}};nT=new WeakMap,rT.NAME=`ASN`;var iT=class e extends rT{constructor(...e){let t;t=M.BufferSourceConverter.isBufferSource(e[0])?M.BufferSourceConverter.toArrayBuffer(e[0]):V.serialize(new zy({extnID:e[0],critical:e[1],extnValue:new I(M.BufferSourceConverter.toArrayBuffer(e[2]))})),super(t,zy)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=this.value,e}toTextObjectWithoutValue(){let t=this.toTextObjectEmpty(this.critical?`critical`:void 0);return t[Z.NAME]===e.NAME&&(t[Z.NAME]=eT.toString(this.type)),t}},aT,oT=class e{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[aT]=`CryptoProvider`,typeof self<`u`&&typeof crypto<`u`?this.set(e.DEFAULT,crypto):typeof global<`u`&&global.crypto&&global.crypto.subtle&&this.set(e.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(t=e.DEFAULT){let n=this.items.get(t.toLowerCase());if(!n)throw Error(`Cannot get Crypto by name '${t}'`);return n}set(t,n){if(typeof t==`string`){if(!n)throw TypeError(`Argument 'value' is required`);this.items.set(t.toLowerCase(),n)}else this.items.set(e.DEFAULT,t);return this}};aT=Symbol.toStringTag,oT.DEFAULT=`default`;var sT=new oT,cT=/^[0-2](?:\.[1-9][0-9]*)+$/;function lT(e){return new RegExp(cT).test(e)}var uT=class{constructor(e={}){this.items={};for(let t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return lT(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}},dT=new uT;dT.register(`CN`,`2.5.4.3`),dT.register(`L`,`2.5.4.7`),dT.register(`ST`,`2.5.4.8`),dT.register(`O`,`2.5.4.10`),dT.register(`OU`,`2.5.4.11`),dT.register(`C`,`2.5.4.6`),dT.register(`DC`,`0.9.2342.19200300.100.1.25`),dT.register(`E`,`1.2.840.113549.1.9.1`),dT.register(`G`,`2.5.4.42`),dT.register(`I`,`2.5.4.43`),dT.register(`SN`,`2.5.4.4`),dT.register(`T`,`2.5.4.12`);function fT(e,t){return`\\${M.Convert.ToHex(M.Convert.FromUtf8String(t)).toUpperCase()}`}function pT(e){return e.replace(/([,+"\\<>;])/g,`\\$1`).replace(/^([ #])/,`\\$1`).replace(/([ ]$)/,`\\$1`).replace(/([\r\n\t])/,fT)}var mT=class e{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 uT,this.asn=new G;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let n=t[e];this.extraNames.register(e,n)}typeof e==`string`?this.asn=this.fromString(e):e instanceof G?this.asn=e:M.BufferSourceConverter.isBufferSource(e)?this.asn=V.parse(e,G):this.asn=this.fromJSON(e)}getField(e){let t=this.extraNames.findId(e)||dT.findId(e),n=[];for(let e of this.asn)for(let r of e)r.type===t&&n.push(r.value.toString());return n}getName(e){return this.extraNames.get(e)||dT.get(e)}toString(){return this.asn.map(e=>e.map(e=>`${this.getName(e.type)||e.type}=${e.value.anyValue?`#${M.Convert.ToHex(e.value.anyValue)}`:pT(e.value.toString())}`).join(`+`)).join(`, `)}toJSON(){let e=[];for(let t of this.asn){let n={};for(let e of t){let t=this.getName(e.type)||e.type;n[t]??(n[t]=[]),n[t].push(e.value.anyValue?`#${M.Convert.ToHex(e.value.anyValue)}`:e.value.toString())}e.push(n)}return e}fromString(e){let t=new G,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+"\\](?=[,+]|$))|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g,r=null,i=`,`;for(;r=n.exec(`${e},`);){let[,e,n]=r,a=n[n.length-1];(a===`,`||a===`+`)&&(n=n.slice(0,n.length-1),r[3]=a);let o=r[3];e=this.getTypeOid(e);let s=this.createAttribute(e,n);i===`+`?t[t.length-1].push(s):t.push(new Q_([s])),i=o}return t}fromJSON(e){let t=new G;for(let n of e){let e=new Q_;for(let t in n){let r=this.getTypeOid(t),i=n[t];for(let t of i){let n=this.createAttribute(r,t);e.push(n)}}t.push(e)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||``),!e)throw Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(t,n){let r=new Z_({type:t});if(typeof n==`object`)for(let e in n)switch(e){case`ia5String`:r.value.ia5String=n[e];break;case`utf8String`:r.value.utf8String=n[e];break;case`universalString`:r.value.universalString=n[e];break;case`bmpString`:r.value.bmpString=n[e];break;case`printableString`:r.value.printableString=n[e];break}else if(n[0]===`#`)r.value.anyValue=M.Convert.FromHex(n.slice(1));else{let i=this.processStringValue(n);t===this.getName(`E`)||t===this.getName(`DC`)?r.value.ia5String=i:e.isPrintableString(i)?r.value.printableString=i:r.value.utf8String=i}return r}processStringValue(e){let t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/gi,`
300
- `).replace(/\\0d/gi,`\r`).replace(/\\0g/gi,` `).replace(/\\(.)/g,`$1`)}toArrayBuffer(){return V.serialize(this.asn)}async getThumbprint(...e){let t,n=`SHA-1`;return e.length>=1&&!e[0]?.subtle?(n=e[0]||n,t=e[1]||sT.get()):t=e[0]||sT.get(),await t.subtle.digest(n,this.toArrayBuffer())}},hT=`Cannot initialize GeneralName from ASN.1 data.`,gT=`${hT} Unsupported string format in use.`,_T=`${hT} Value doesn't match to GUID regular expression.`,vT=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,yT=`1.3.6.1.4.1.311.25.1`,bT=`1.3.6.1.4.1.311.20.2.3`,xT=`email`,ST=`guid`,CT=class extends rT{constructor(...e){let t;if(e.length===2)switch(e[0]){case`dn`:{let n=new mT(e[1]).toArrayBuffer(),r=V.parse(n,G);t=new K({directoryName:r});break}case`dns`:t=new K({dNSName:e[1]});break;case xT:t=new K({rfc822Name:e[1]});break;case ST:{let n=new RegExp(vT,`i`).exec(e[1]);if(!n)throw Error(`Cannot parse GUID value. Value doesn't match to regular expression`);let r=n.slice(1).map((e,t)=>t<3?M.Convert.ToHex(new Uint8Array(M.Convert.FromHex(e)).reverse()):e).join(``);t=new K({otherName:new tv({typeId:yT,value:V.serialize(new I(M.Convert.FromHex(r)))})});break}case`ip`:t=new K({iPAddress:e[1]});break;case`id`:t=new K({registeredID:e[1]});break;case`upn`:t=new K({otherName:new tv({typeId:bT,value:V.serialize(S_.toASN(e[1]))})});break;case`url`:t=new K({uniformResourceIdentifier:e[1]});break;default:throw Error(`Cannot create GeneralName. Unsupported type of the name`)}else t=M.BufferSourceConverter.isBufferSource(e[0])?V.parse(e[0],K):e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=`dns`,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=xT,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=`ip`,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=`url`,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=`id`,this.value=e.registeredID;else if(e.directoryName!=null)this.type=`dn`,this.value=new mT(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===yT){this.type=ST;let t=V.parse(e.otherName.value,I),n=new RegExp(vT,`i`).exec(M.Convert.ToHex(t));if(!n)throw Error(_T);this.value=n.slice(1).map((e,t)=>t<3?M.Convert.ToHex(new Uint8Array(M.Convert.FromHex(e)).reverse()):e).join(`-`)}else if(e.otherName.typeId===bT)this.type=`upn`,this.value=V.parse(e.otherName.value,Y_).toString();else throw Error(gT);else throw Error(gT)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case`dn`:case`dns`:case ST:case`ip`:case`id`:case`upn`:case`url`:e=this.type.toUpperCase();break;case xT:e=`Email`;break;default:throw Error(`Unsupported GeneralName type`)}let t=this.value;return this.type===`id`&&(t=eT.toString(t)),new Z(e,void 0,t)}},wT=class extends rT{constructor(e){let t;if(e instanceof Sv)t=e;else if(Array.isArray(e)){let n=[];for(let t of e)if(t instanceof K)n.push(t);else{let e=V.parse(new CT(t.type,t.value).rawData,K);n.push(e)}t=new Sv(n)}else if(M.BufferSourceConverter.isBufferSource(e))t=V.parse(e,Sv);else throw Error(`Cannot initialize GeneralNames. Incorrect incoming arguments`);super(t)}onInit(e){let t=[];for(let n of e){let e=null;try{e=new CT(n)}catch{continue}t.push(e)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){let e=super.toTextObjectEmpty();for(let t of this.items){let n=t.toTextObject(),r=e[n[Z.NAME]];Array.isArray(r)||(r=[],e[n[Z.NAME]]=r),r.push(n)}return e}};wT.NAME=`GeneralNames`;var TT=`-{5}`,ET=`\\n`,DT=`${TT}BEGIN (${`[^${ET}]+`}(?=${TT}))${TT}`,OT=`${TT}END \\1${TT}`,kT=`\\n`,AT=`${DT}${kT}(?:((?:${`[^:${ET}]+`}: ${`(?:[^${ET}]+${kT}(?: +[^${ET}]+${kT})*)`})+))?${kT}?(${`(?:[a-zA-Z0-9=+/]+${kT})+`})${OT}`,jT=class{static isPem(e){return typeof e==`string`&&new RegExp(AT,`g`).test(e.replace(/\r/g,``))}static decodeWithHeaders(e){e=e.replace(/\r/g,``);let t=new RegExp(AT,`g`),n=[],r=null;for(;r=t.exec(e);){let e=r[3].replace(RegExp(`[${ET}]+`,`g`),``),t={type:r[1],headers:[],rawData:M.Convert.FromBase64(e)},i=r[2];if(i){let e=i.split(new RegExp(kT,`g`)),n=null;for(let r of e){let[e,i]=r.split(/:(.*)/);if(i===void 0){if(!n)throw Error(`Cannot parse PEM string. Incorrect header value`);n.value+=e.trim()}else n&&t.headers.push(n),n={key:e,value:i.trim()}}n&&t.headers.push(n)}n.push(t)}return n}static decode(e){return this.decodeWithHeaders(e).map(e=>e.rawData)}static decodeFirst(e){let t=this.decode(e);if(!t.length)throw RangeError(`PEM string doesn't contain any objects`);return t[0]}static encode(e,t){if(Array.isArray(e)){let n=[];return t?e.forEach(e=>{if(!M.BufferSourceConverter.isBufferSource(e))throw TypeError(`Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource`);n.push(this.encodeStruct({type:t,rawData:M.BufferSourceConverter.toArrayBuffer(e)}))}):e.forEach(e=>{if(!(`type`in e))throw TypeError(`Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut`);n.push(this.encodeStruct(e))}),n.join(`
298
+ `)}function eC(e,t,n){var r=IS(e.toString().match(/constructor\(([\w, ]+)\)/)||[],2)[1];return $S(`Cannot inject the dependency `+QS(r===void 0?null:r,t)+` of "`+e.name+`" constructor. Reason:`,n)}function tC(e){return!(typeof e.dispose!=`function`||e.dispose.length>0)}var nC=function(e){MS(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(YS),rC=function(e){MS(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(YS),iC=function(){function e(){this.preResolution=new nC,this.postResolution=new rC}return e}(),aC=new Map,oC=new(function(){function e(e){this.parent=e,this._registry=new XS,this.interceptors=new iC,this.disposed=!1,this.disposables=new Set}return e.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:AS.Transient}),this.ensureNotDisposed();var r=JS(t)?t:{useClass:t};if(KS(r))for(var i=[e],a=r;a!=null;){var o=a.useToken;if(i.includes(o))throw Error(`Token registration cycle detected! `+LS(i,[o]).join(` -> `));i.push(o);var s=this._registry.get(o);a=s&&KS(s.provider)?s.provider:null}if((n.lifecycle===AS.Singleton||n.lifecycle==AS.ContainerScoped||n.lifecycle==AS.ResolutionScoped)&&(qS(r)||BS(r)))throw Error(`Cannot use lifecycle "`+AS[n.lifecycle]+`" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:r,options:n}),this},e.prototype.registerType=function(e,t){return this.ensureNotDisposed(),HS(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},e.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},e.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),HS(e)){if(HS(t))return this.register(e,{useToken:t},{lifecycle:AS.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:AS.Singleton});throw Error(`Cannot register a type name as a singleton without a "to" token`)}var n=e;return t&&!HS(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:AS.Singleton})},e.prototype.resolve=function(e,t,n){t===void 0&&(t=new ZS),n===void 0&&(n=!1),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&HS(e)){if(n)return;throw Error(`Attempted to resolve unregistered dependency token: "`+e.toString()+`"`)}if(this.executePreResolutionInterceptor(e,`Single`),r){var i=this.resolveRegistration(r,t);return this.executePostResolutionInterceptor(e,i,`Single`),i}if(GS(e)){var i=this.construct(e,t);return this.executePostResolutionInterceptor(e,i,`Single`),i}throw Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},e.prototype.executePreResolutionInterceptor=function(e,t){var n,r;if(this.interceptors.preResolution.has(e)){var i=[];try{for(var a=FS(this.interceptors.preResolution.getAll(e)),o=a.next();!o.done;o=a.next()){var s=o.value;s.options.frequency!=`Once`&&i.push(s),s.callback(e,t)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,i)}},e.prototype.executePostResolutionInterceptor=function(e,t,n){var r,i;if(this.interceptors.postResolution.has(e)){var a=[];try{for(var o=FS(this.interceptors.postResolution.getAll(e)),s=o.next();!s.done;s=o.next()){var c=s.value;c.options.frequency!=`Once`&&a.push(c),c.callback(e,t,n)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}this.interceptors.postResolution.setAll(e,a)}},e.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===AS.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===AS.Singleton,r=e.options.lifecycle===AS.ContainerScoped,i=n||r,a=qS(e.provider)?e.provider.useValue:KS(e.provider)?i?e.instance||=this.resolve(e.provider.useToken,t):this.resolve(e.provider.useToken,t):zS(e.provider)?i?e.instance||=this.construct(e.provider.useClass,t):this.construct(e.provider.useClass,t):BS(e.provider)?e.provider.useFactory(this):this.construct(e.provider,t);return e.options.lifecycle===AS.ResolutionScoped&&t.scopedResolutions.set(e,a),a},e.prototype.resolveAll=function(e,t,n){var r=this;t===void 0&&(t=new ZS),n===void 0&&(n=!1),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&HS(e)){if(n)return[];throw Error(`Attempted to resolve unregistered dependency token: "`+e.toString()+`"`)}if(this.executePreResolutionInterceptor(e,`All`),i){var a=i.map(function(e){return r.resolveRegistration(e,t)});return this.executePostResolutionInterceptor(e,a,`All`),a}var o=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,o,`All`),o},e.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)},e.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},e.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=FS(this._registry.entries()),r=n.next();!r.done;r=n.next()){var i=IS(r.value,2),a=i[0],o=i[1];this._registry.setAll(a,o.filter(function(e){return!qS(e.provider)}).map(function(e){return e.instance=void 0,e}))}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e.prototype.createChildContainer=function(){var t,n;this.ensureNotDisposed();var r=new e(this);try{for(var i=FS(this._registry.entries()),a=i.next();!a.done;a=i.next()){var o=IS(a.value,2),s=o[0],c=o[1];c.some(function(e){return e.options.lifecycle===AS.ContainerScoped})&&r._registry.setAll(s,c.map(function(e){return e.options.lifecycle===AS.ContainerScoped?{provider:e.provider,options:e.options}:e}))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},e.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:`Always`}),this.interceptors.preResolution.set(e,{callback:t,options:n})},e.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:`Always`}),this.interceptors.postResolution.set(e,{callback:t,options:n})},e.prototype.dispose=function(){return NS(this,void 0,void 0,function(){var e;return PS(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(t){var n=t.dispose();n&&e.push(n)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},e.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},e.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},e.prototype.construct=function(e,t){var n=this;if(e instanceof VS)return e.createProxy(function(e){return n.resolve(e,t)});var r=(function(){var r=aC.get(e);if(!r||r.length===0){if(e.length===0)return new e;throw Error(`TypeInfo not known for "`+e.name+`"`)}var i=r.map(n.resolveParams(t,e));return new(e.bind.apply(e,LS([void 0],i)))})();return tC(r)&&this.disposables.add(r),r},e.prototype.resolveParams=function(e,t){var n=this;return function(r,i){var a,o,s;try{return US(r)?WS(r)?r.multiple?(a=n.resolve(r.transform)).transform.apply(a,LS([n.resolveAll(r.token,new ZS,r.isOptional)],r.transformArgs)):(o=n.resolve(r.transform)).transform.apply(o,LS([n.resolve(r.token,e,r.isOptional)],r.transformArgs)):r.multiple?n.resolveAll(r.token,new ZS,r.isOptional):n.resolve(r.token,e,r.isOptional):WS(r)?(s=n.resolve(r.transform,e)).transform.apply(s,LS([n.resolve(r.token,e)],r.transformArgs)):n.resolve(r,e)}catch(e){throw Error(eC(t,i,e))}}},e.prototype.ensureNotDisposed=function(){if(this.disposed)throw Error(`This container has been disposed, you cannot interact with a disposed container`)},e}());function sC(e){return function(t){aC.set(t,RS(t)),e&&e.token&&(Array.isArray(e.token)?e.token.forEach(function(e){oC.register(e,t)}):oC.register(e.token,t))}}if(typeof Reflect>`u`||!Reflect.getMetadata)throw Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var cC,lC=class{constructor(e={}){this.attrId=``,this.attrValues=[],Object.assign(e)}};H([z({type:F.ObjectIdentifier})],lC.prototype,`attrId`,void 0),H([z({type:F.Any,repeated:`set`})],lC.prototype,`attrValues`,void 0);var uC=cC=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,cC.prototype)}};uC=cC=H([R({type:P.Sequence,itemType:lC})],uC);var dC,fC=dC=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,dC.prototype)}};fC=dC=H([R({type:P.Sequence,itemType:Ub})],fC);var pC=`1.2.840.113549.1.12`,mC=`${pC}.1`;`${mC}`,`${mC}`,`${mC}`,`${mC}`,`${mC}`,`${mC}`;var hC=`${pC}.10.1`;`${hC}`,`${hC}`,`${hC}`,`${hC}`,`${hC}`,`${hC}`;var gC=`1.2.840.113549.1.9`,_C=class{constructor(e={}){this.certId=``,this.certValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],_C.prototype,`certId`,void 0),H([z({type:F.Any,context:0})],_C.prototype,`certValue`,void 0);var vC=`${gC}.22`;`${vC}`,`${vC}`;var yC=class{constructor(e={}){this.crlId=``,this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],yC.prototype,`crlId`,void 0),H([z({type:F.Any,context:0})],yC.prototype,`crltValue`,void 0),`${gC}`;var bC=class extends I{},xC=class{constructor(e={}){this.encryptionAlgorithm=new q,this.encryptedData=new bC,Object.assign(this,e)}};H([z({type:q})],xC.prototype,`encryptionAlgorithm`,void 0),H([z({type:bC})],xC.prototype,`encryptedData`,void 0);var SC,CC;(function(e){e[e.v1=0]=`v1`})(CC||={});var wC=class extends I{},TC=SC=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,SC.prototype)}};TC=SC=H([R({type:P.Sequence,itemType:Ty})],TC);var EC=class{constructor(e={}){this.version=CC.v1,this.privateKeyAlgorithm=new q,this.privateKey=new wC,Object.assign(this,e)}};H([z({type:F.Integer})],EC.prototype,`version`,void 0),H([z({type:q})],EC.prototype,`privateKeyAlgorithm`,void 0),H([z({type:wC})],EC.prototype,`privateKey`,void 0),H([z({type:TC,implicit:!0,context:0,optional:!0})],EC.prototype,`attributes`,void 0);var DC=class extends EC{};DC=H([R({type:P.Sequence})],DC);var OC=class extends xC{};OC=H([R({type:P.Sequence})],OC);var kC=class{constructor(e={}){this.secretTypeId=``,this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],kC.prototype,`secretTypeId`,void 0),H([z({type:F.Any,context:0})],kC.prototype,`secretValue`,void 0);var AC=class{constructor(e={}){this.mac=new CS,this.macSalt=new I,this.iterations=1,Object.assign(this,e)}};H([z({type:CS})],AC.prototype,`mac`,void 0),H([z({type:I})],AC.prototype,`macSalt`,void 0),H([z({type:F.Integer,defaultValue:1})],AC.prototype,`iterations`,void 0);var jC=class{constructor(e={}){this.version=3,this.authSafe=new Ub,this.macData=new AC,Object.assign(this,e)}};H([z({type:F.Integer})],jC.prototype,`version`,void 0),H([z({type:Ub})],jC.prototype,`authSafe`,void 0),H([z({type:AC,optional:!0})],jC.prototype,`macData`,void 0);var MC,NC=class{constructor(e={}){this.bagId=``,this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:F.ObjectIdentifier})],NC.prototype,`bagId`,void 0),H([z({type:F.Any,context:0})],NC.prototype,`bagValue`,void 0),H([z({type:lC,repeated:`set`,optional:!0})],NC.prototype,`bagAttributes`,void 0);var PC=MC=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,MC.prototype)}};PC=MC=H([R({type:P.Sequence,itemType:NC})],PC);var FC,IC,LC,J=`1.2.840.113549.1.9`;`${J}`;var RC=`${J}.24`,zC=`${J}.25`,BC=`${J}.26`,VC=`${J}.27`;`${RC}`,`${RC}`,`${J}`,`${J}`,`${J}`,`${J}`,`${J}`,`${J}`;var HC=`${J}.7`;`${J}`,`${J}`,`${J}`;var UC=`${J}.14`;`${J}`,`${J}`,`${J}`,`${zC}`,`${zC}`,`${zC}`,`${zC}`,`${zC}`;var WC=`1.3.6.1.5.5.7.9`;`${WC}`,`${WC}`,`${WC}`,`${WC}`,`${WC}`,`${BC}`,`${BC}`,`${VC}`,`${VC}`,`${J}`,`${J}`,`${J}`,`${Ab}`;var GC=class extends Y_{constructor(e={}){super(e)}toString(){return{}.toString(),this.ia5String||super.toString()}};H([z({type:F.IA5String})],GC.prototype,`ia5String`,void 0),GC=H([R({type:P.Choice})],GC);var KC=class extends Ub{};KC=H([R({type:P.Sequence})],KC);var qC=class extends jC{};qC=H([R({type:P.Sequence})],qC);var JC=class extends xC{};JC=H([R({type:P.Sequence})],JC);var YC=class{constructor(e=``){this.value=e}toString(){return this.value}};H([z({type:F.IA5String})],YC.prototype,`value`,void 0),YC=H([R({type:P.Choice})],YC);var XC=class extends GC{};XC=H([R({type:P.Choice})],XC);var ZC=class extends Y_{};ZC=H([R({type:P.Choice})],ZC);var QC=class{constructor(e=new Date){this.value=e}};H([z({type:F.GeneralizedTime})],QC.prototype,`value`,void 0),QC=H([R({type:P.Choice})],QC);var $C=class extends Y_{};$C=H([R({type:P.Choice})],$C);var ew=class{constructor(e=`M`){this.value=e}toString(){return this.value}};H([z({type:F.PrintableString})],ew.prototype,`value`,void 0),ew=H([R({type:P.Choice})],ew);var tw=class{constructor(e=``){this.value=e}toString(){return this.value}};H([z({type:F.PrintableString})],tw.prototype,`value`,void 0),tw=H([R({type:P.Choice})],tw);var nw=class extends tw{};nw=H([R({type:P.Choice})],nw);var rw=class extends Y_{};rw=H([R({type:P.Choice})],rw);var iw=class{constructor(e=``){this.value=e}toString(){return this.value}};H([z({type:F.ObjectIdentifier})],iw.prototype,`value`,void 0),iw=H([R({type:P.Choice})],iw);var aw=class extends Ly{};aw=H([R({type:P.Choice})],aw);var ow=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};H([z({type:F.Integer})],ow.prototype,`value`,void 0),ow=H([R({type:P.Choice})],ow);var sw=class extends ab{};sw=H([R({type:P.Sequence})],sw);var cw=class extends Y_{};cw=H([R({type:P.Choice})],cw);var lw=FC=class extends Vy{constructor(e){super(e),Object.setPrototypeOf(this,FC.prototype)}};lw=FC=H([R({type:P.Sequence})],lw);var uw=IC=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,IC.prototype)}};uw=IC=H([R({type:P.Set,itemType:rb})],uw);var dw=class{constructor(e=``){this.value=e}toString(){return this.value}};H([z({type:F.BmpString})],dw.prototype,`value`,void 0),dw=H([R({type:P.Choice})],dw);var fw=class extends q{};fw=H([R({type:P.Sequence})],fw);var pw=LC=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,LC.prototype)}};pw=LC=H([R({type:P.Sequence,itemType:fw})],pw);var mw,hw=mw=class extends B{constructor(e){super(e),Object.setPrototypeOf(this,mw.prototype)}};hw=mw=H([R({type:P.Sequence,itemType:Ty})],hw);var gw=class{constructor(e={}){this.version=0,this.subject=new ev,this.subjectPKInfo=new Iy,this.attributes=new hw,Object.assign(this,e)}};H([z({type:F.Integer})],gw.prototype,`version`,void 0),H([z({type:ev})],gw.prototype,`subject`,void 0),H([z({type:Iy})],gw.prototype,`subjectPKInfo`,void 0),H([z({type:hw,implicit:!0,context:0,optional:!0})],gw.prototype,`attributes`,void 0);var _w=class{constructor(e={}){this.certificationRequestInfo=new gw,this.signatureAlgorithm=new q,this.signature=new ArrayBuffer(0),Object.assign(this,e)}};H([z({type:gw,raw:!0})],_w.prototype,`certificationRequestInfo`,void 0),H([z({type:q})],_w.prototype,`signatureAlgorithm`,void 0),H([z({type:F.BitString})],_w.prototype,`signature`,void 0);var vw=`crypto.algorithm`,yw=class{getAlgorithms(){return oC.resolveAll(vw)}toAsnAlgorithm(e){({...e});for(let t of this.getAlgorithms()){let n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){let t=new q({algorithm:e.name});return`parameters`in e&&(t.parameters=e.parameters),t}throw Error(`Cannot convert WebCrypto algorithm to ASN.1 algorithm`)}toWebAlgorithm(e){for(let t of this.getAlgorithms()){let n=t.toWebAlgorithm(e);if(n)return n}return{name:e.algorithm,parameters:e.parameters}}},bw=`crypto.algorithmProvider`;oC.registerSingleton(bw,yw);var xw,Sw=`1.3.36.3.3.2.8.1.1`,Cw=`${Sw}.1`,ww=`${Sw}.2`,Tw=`${Sw}.3`,Ew=`${Sw}.4`,Dw=`${Sw}.5`,Ow=`${Sw}.6`,kw=`${Sw}.7`,Aw=`${Sw}.8`,jw=`${Sw}.9`,Mw=`${Sw}.10`,Nw=`${Sw}.11`,Pw=`${Sw}.12`,Fw=`${Sw}.13`,Iw=`${Sw}.14`,Lw=`brainpoolP160r1`,Rw=`brainpoolP160t1`,zw=`brainpoolP192r1`,Bw=`brainpoolP192t1`,Vw=`brainpoolP224r1`,Hw=`brainpoolP224t1`,Uw=`brainpoolP256r1`,Ww=`brainpoolP256t1`,Gw=`brainpoolP320r1`,Kw=`brainpoolP320t1`,qw=`brainpoolP384r1`,Jw=`brainpoolP384t1`,Yw=`brainpoolP512r1`,Xw=`brainpoolP512t1`,Y=`ECDSA`,Zw=xw=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case Y.toLowerCase():if(`hash`in e)switch((typeof e.hash==`string`?e.hash:e.hash.name).toLowerCase()){case`sha-1`:return Fx;case`sha-256`:return Ix;case`sha-384`:return Lx;case`sha-512`:return Rx}else if(`namedCurve`in e){let t=``;switch(e.namedCurve){case`P-256`:t=jx;break;case`K-256`:t=xw.SECP256K1;break;case`P-384`:t=Mx;break;case`P-521`:t=Nx;break;case Lw:t=Cw;break;case Rw:t=ww;break;case zw:t=Tw;break;case Bw:t=Ew;break;case Vw:t=Dw;break;case Hw:t=Ow;break;case Uw:t=kw;break;case Ww:t=Aw;break;case Gw:t=jw;break;case Kw:t=Mw;break;case qw:t=Nw;break;case Jw:t=Pw;break;case Yw:t=Fw;break;case Xw:t=Iw;break}if(t)return new q({algorithm:Tx,parameters:V.serialize(new Wx({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Ex:return{name:Y,hash:{name:`SHA-1`}};case Ox:return{name:Y,hash:{name:`SHA-256`}};case kx:return{name:Y,hash:{name:`SHA-384`}};case Ax:return{name:Y,hash:{name:`SHA-512`}};case Tx:if(!e.parameters)throw TypeError(`Cannot get required parameters from EC algorithm`);switch(V.parse(e.parameters,Wx).namedCurve){case jx:return{name:Y,namedCurve:`P-256`};case xw.SECP256K1:return{name:Y,namedCurve:`K-256`};case Mx:return{name:Y,namedCurve:`P-384`};case Nx:return{name:Y,namedCurve:`P-521`};case Cw:return{name:Y,namedCurve:Lw};case ww:return{name:Y,namedCurve:Rw};case Tw:return{name:Y,namedCurve:zw};case Ew:return{name:Y,namedCurve:Bw};case Dw:return{name:Y,namedCurve:Vw};case Ow:return{name:Y,namedCurve:Hw};case kw:return{name:Y,namedCurve:Uw};case Aw:return{name:Y,namedCurve:Ww};case jw:return{name:Y,namedCurve:Gw};case Mw:return{name:Y,namedCurve:Kw};case Nw:return{name:Y,namedCurve:qw};case Pw:return{name:Y,namedCurve:Jw};case Fw:return{name:Y,namedCurve:Yw};case Iw:return{name:Y,namedCurve:Xw}}}return null}};Zw.SECP256K1=`1.3.132.0.10`,Zw=xw=H([sC()],Zw),oC.registerSingleton(vw,Zw);var Qw=Symbol(`name`),$w=Symbol(`value`),X=class{constructor(e,t={},n=``){this[Qw]=e,this[$w]=n;for(let e in t)this[e]=t[e]}};X.NAME=Qw,X.VALUE=$w;var eT=class{static toTextObject(e){let t=new X(`Algorithm Identifier`,{},tT.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case Tx:{let n=new Zw().toWebAlgorithm(e);n&&`namedCurve`in n?t[`Named Curve`]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}},tT=class{static toString(e){return this.items[e]||e}};tT.items={[sS]:`sha1`,[cS]:`sha224`,[lS]:`sha256`,[uS]:`sha384`,[dS]:`sha512`,[Jx]:`rsaEncryption`,[eS]:`sha1WithRSAEncryption`,[tS]:`sha224WithRSAEncryption`,[nS]:`sha256WithRSAEncryption`,[rS]:`sha384WithRSAEncryption`,[iS]:`sha512WithRSAEncryption`,[Tx]:`ecPublicKey`,[Ex]:`ecdsaWithSHA1`,[Dx]:`ecdsaWithSHA224`,[Ox]:`ecdsaWithSHA256`,[kx]:`ecdsaWithSHA384`,[Ax]:`ecdsaWithSHA512`,[$v]:`TLS WWW server authentication`,[ey]:`TLS WWW client authentication`,[ty]:`Code Signing`,[ny]:`E-mail Protection`,[ry]:`Time Stamping`,[iy]:`OCSP Signing`,[xx]:`Signed Data`};var nT=class{static serialize(e){return this.serializeObj(e).join(`
299
+ `)}static pad(e=0){return``.padStart(2*e,` `)}static serializeObj(e,t=0){let n=[],r=this.pad(t++),i=``,a=e[X.VALUE];a&&(i=` ${a}`),n.push(`${r}${e[X.NAME]}:${i}`),r=this.pad(t);for(let i in e){if(typeof i==`symbol`)continue;let a=e[i],o=i?`${i}: `:``;if(typeof a==`string`||typeof a==`number`||typeof a==`boolean`)n.push(`${r}${o}${a}`);else if(a instanceof Date)n.push(`${r}${o}${a.toUTCString()}`);else if(Array.isArray(a))for(let e of a)e[X.NAME]=i,n.push(...this.serializeObj(e,t));else if(a instanceof X)a[X.NAME]=i,n.push(...this.serializeObj(a,t));else if(M.BufferSourceConverter.isBufferSource(a))i?(n.push(`${r}${o}`),n.push(...this.serializeBufferSource(a,t+1))):n.push(...this.serializeBufferSource(a,t));else if(`toTextObject`in a){let e=a.toTextObject();e[X.NAME]=i,n.push(...this.serializeObj(e,t))}else throw TypeError(`Cannot serialize data in text format. Unsupported type.`)}return n}static serializeBufferSource(e,t=0){let n=this.pad(t),r=M.BufferSourceConverter.toUint8Array(e),i=[];for(let e=0;e<r.length;){let t=[];for(let n=0;n<16&&e<r.length;n++){n===8&&t.push(``);let i=r[e++].toString(16).padStart(2,`0`);t.push(i)}i.push(`${n}${t.join(` `)}`)}return i}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}};nT.oidSerializer=tT,nT.algorithmSerializer=eT;var rT,iT=class e{get rawData(){return U(this,rT,`f`)||W(this,rT,V.serialize(this.asn),`f`),U(this,rT,`f`)}constructor(...e){rT.set(this,void 0),M.BufferSourceConverter.isBufferSource(e[0])?(this.asn=V.parse(e[0],e[1]),W(this,rT,M.BufferSourceConverter.toArrayBuffer(e[0]),`f`),this.onInit(this.asn)):(this.asn=e[0],this.onInit(this.asn))}equal(t){return t instanceof e?(0,M.isEqual)(t.rawData,this.rawData):!1}toString(e=`text`){switch(e){case`asn`:return V.toString(this.rawData);case`text`:return nT.serialize(this.toTextObject());case`hex`:return M.Convert.ToHex(this.rawData);case`base64`:return M.Convert.ToBase64(this.rawData);case`base64url`:return M.Convert.ToBase64Url(this.rawData);default:throw TypeError(`Argument 'format' is unsupported value`)}}getTextName(){return this.constructor.NAME}toTextObject(){let e=this.toTextObjectEmpty();return e[``]=this.rawData,e}toTextObjectEmpty(e){return new X(this.getTextName(),{},e)}};rT=new WeakMap,iT.NAME=`ASN`;var aT=class e extends iT{constructor(...e){let t;t=M.BufferSourceConverter.isBufferSource(e[0])?M.BufferSourceConverter.toArrayBuffer(e[0]):V.serialize(new By({extnID:e[0],critical:e[1],extnValue:new I(M.BufferSourceConverter.toArrayBuffer(e[2]))})),super(t,By)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=this.value,e}toTextObjectWithoutValue(){let t=this.toTextObjectEmpty(this.critical?`critical`:void 0);return t[X.NAME]===e.NAME&&(t[X.NAME]=tT.toString(this.type)),t}},oT,sT=class e{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[oT]=`CryptoProvider`,typeof self<`u`&&typeof crypto<`u`?this.set(e.DEFAULT,crypto):typeof global<`u`&&global.crypto&&global.crypto.subtle&&this.set(e.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(t=e.DEFAULT){let n=this.items.get(t.toLowerCase());if(!n)throw Error(`Cannot get Crypto by name '${t}'`);return n}set(t,n){if(typeof t==`string`){if(!n)throw TypeError(`Argument 'value' is required`);this.items.set(t.toLowerCase(),n)}else this.items.set(e.DEFAULT,t);return this}};oT=Symbol.toStringTag,sT.DEFAULT=`default`;var cT=new sT,lT=/^[0-2](?:\.[1-9][0-9]*)+$/;function uT(e){return new RegExp(lT).test(e)}var dT=class{constructor(e={}){this.items={};for(let t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return uT(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}},fT=new dT;fT.register(`CN`,`2.5.4.3`),fT.register(`L`,`2.5.4.7`),fT.register(`ST`,`2.5.4.8`),fT.register(`O`,`2.5.4.10`),fT.register(`OU`,`2.5.4.11`),fT.register(`C`,`2.5.4.6`),fT.register(`DC`,`0.9.2342.19200300.100.1.25`),fT.register(`E`,`1.2.840.113549.1.9.1`),fT.register(`G`,`2.5.4.42`),fT.register(`I`,`2.5.4.43`),fT.register(`SN`,`2.5.4.4`),fT.register(`T`,`2.5.4.12`);function pT(e,t){return`\\${M.Convert.ToHex(M.Convert.FromUtf8String(t)).toUpperCase()}`}function mT(e){return e.replace(/([,+"\\<>;])/g,`\\$1`).replace(/^([ #])/,`\\$1`).replace(/([ ]$)/,`\\$1`).replace(/([\r\n\t])/,pT)}var hT=class e{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 dT,this.asn=new ev;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let n=t[e];this.extraNames.register(e,n)}typeof e==`string`?this.asn=this.fromString(e):e instanceof ev?this.asn=e:M.BufferSourceConverter.isBufferSource(e)?this.asn=V.parse(e,ev):this.asn=this.fromJSON(e)}getField(e){let t=this.extraNames.findId(e)||fT.findId(e),n=[];for(let e of this.asn)for(let r of e)r.type===t&&n.push(r.value.toString());return n}getName(e){return this.extraNames.get(e)||fT.get(e)}toString(){return this.asn.map(e=>e.map(e=>`${this.getName(e.type)||e.type}=${e.value.anyValue?`#${M.Convert.ToHex(e.value.anyValue)}`:mT(e.value.toString())}`).join(`+`)).join(`, `)}toJSON(){let e=[];for(let t of this.asn){let n={};for(let e of t){let t=this.getName(e.type)||e.type;n[t]??(n[t]=[]),n[t].push(e.value.anyValue?`#${M.Convert.ToHex(e.value.anyValue)}`:e.value.toString())}e.push(n)}return e}fromString(e){let t=new ev,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+"\\](?=[,+]|$))|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g,r=null,i=`,`;for(;r=n.exec(`${e},`);){let[,e,n]=r,a=n[n.length-1];(a===`,`||a===`+`)&&(n=n.slice(0,n.length-1),r[3]=a);let o=r[3];e=this.getTypeOid(e);let s=this.createAttribute(e,n);i===`+`?t[t.length-1].push(s):t.push(new Q_([s])),i=o}return t}fromJSON(e){let t=new ev;for(let n of e){let e=new Q_;for(let t in n){let r=this.getTypeOid(t),i=n[t];for(let t of i){let n=this.createAttribute(r,t);e.push(n)}}t.push(e)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||``),!e)throw Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(t,n){let r=new Z_({type:t});if(typeof n==`object`)for(let e in n)switch(e){case`ia5String`:r.value.ia5String=n[e];break;case`utf8String`:r.value.utf8String=n[e];break;case`universalString`:r.value.universalString=n[e];break;case`bmpString`:r.value.bmpString=n[e];break;case`printableString`:r.value.printableString=n[e];break}else if(n[0]===`#`)r.value.anyValue=M.Convert.FromHex(n.slice(1));else{let i=this.processStringValue(n);t===this.getName(`E`)||t===this.getName(`DC`)?r.value.ia5String=i:e.isPrintableString(i)?r.value.printableString=i:r.value.utf8String=i}return r}processStringValue(e){let t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/gi,`
300
+ `).replace(/\\0d/gi,`\r`).replace(/\\0g/gi,` `).replace(/\\(.)/g,`$1`)}toArrayBuffer(){return V.serialize(this.asn)}async getThumbprint(...e){let t,n=`SHA-1`;return e.length>=1&&!e[0]?.subtle?(n=e[0]||n,t=e[1]||cT.get()):t=e[0]||cT.get(),await t.subtle.digest(n,this.toArrayBuffer())}},gT=`Cannot initialize GeneralName from ASN.1 data.`,_T=`${gT} Unsupported string format in use.`,vT=`${gT} Value doesn't match to GUID regular expression.`,yT=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,bT=`1.3.6.1.4.1.311.25.1`,xT=`1.3.6.1.4.1.311.20.2.3`,ST=`email`,CT=`guid`,wT=class extends iT{constructor(...e){let t;if(e.length===2)switch(e[0]){case`dn`:{let n=new hT(e[1]).toArrayBuffer(),r=V.parse(n,ev);t=new G({directoryName:r});break}case`dns`:t=new G({dNSName:e[1]});break;case ST:t=new G({rfc822Name:e[1]});break;case CT:{let n=new RegExp(yT,`i`).exec(e[1]);if(!n)throw Error(`Cannot parse GUID value. Value doesn't match to regular expression`);let r=n.slice(1).map((e,t)=>t<3?M.Convert.ToHex(new Uint8Array(M.Convert.FromHex(e)).reverse()):e).join(``);t=new G({otherName:new nv({typeId:bT,value:V.serialize(new I(M.Convert.FromHex(r)))})});break}case`ip`:t=new G({iPAddress:e[1]});break;case`id`:t=new G({registeredID:e[1]});break;case`upn`:t=new G({otherName:new nv({typeId:xT,value:V.serialize(S_.toASN(e[1]))})});break;case`url`:t=new G({uniformResourceIdentifier:e[1]});break;default:throw Error(`Cannot create GeneralName. Unsupported type of the name`)}else t=M.BufferSourceConverter.isBufferSource(e[0])?V.parse(e[0],G):e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=`dns`,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=ST,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=`ip`,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=`url`,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=`id`,this.value=e.registeredID;else if(e.directoryName!=null)this.type=`dn`,this.value=new hT(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===bT){this.type=CT;let t=V.parse(e.otherName.value,I),n=new RegExp(yT,`i`).exec(M.Convert.ToHex(t));if(!n)throw Error(vT);this.value=n.slice(1).map((e,t)=>t<3?M.Convert.ToHex(new Uint8Array(M.Convert.FromHex(e)).reverse()):e).join(`-`)}else if(e.otherName.typeId===xT)this.type=`upn`,this.value=V.parse(e.otherName.value,Y_).toString();else throw Error(_T);else throw Error(_T)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case`dn`:case`dns`:case CT:case`ip`:case`id`:case`upn`:case`url`:e=this.type.toUpperCase();break;case ST:e=`Email`;break;default:throw Error(`Unsupported GeneralName type`)}let t=this.value;return this.type===`id`&&(t=tT.toString(t)),new X(e,void 0,t)}},TT=class extends iT{constructor(e){let t;if(e instanceof Cv)t=e;else if(Array.isArray(e)){let n=[];for(let t of e)if(t instanceof G)n.push(t);else{let e=V.parse(new wT(t.type,t.value).rawData,G);n.push(e)}t=new Cv(n)}else if(M.BufferSourceConverter.isBufferSource(e))t=V.parse(e,Cv);else throw Error(`Cannot initialize GeneralNames. Incorrect incoming arguments`);super(t)}onInit(e){let t=[];for(let n of e){let e=null;try{e=new wT(n)}catch{continue}t.push(e)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){let e=super.toTextObjectEmpty();for(let t of this.items){let n=t.toTextObject(),r=e[n[X.NAME]];Array.isArray(r)||(r=[],e[n[X.NAME]]=r),r.push(n)}return e}};TT.NAME=`GeneralNames`;var ET=`-{5}`,DT=`\\n`,OT=`${ET}BEGIN (${`[^${DT}]+`}(?=${ET}))${ET}`,kT=`${ET}END \\1${ET}`,AT=`\\n`,jT=`${OT}${AT}(?:((?:${`[^:${DT}]+`}: ${`(?:[^${DT}]+${AT}(?: +[^${DT}]+${AT})*)`})+))?${AT}?(${`(?:[a-zA-Z0-9=+/]+${AT})+`})${kT}`,MT=class{static isPem(e){return typeof e==`string`&&new RegExp(jT,`g`).test(e.replace(/\r/g,``))}static decodeWithHeaders(e){e=e.replace(/\r/g,``);let t=new RegExp(jT,`g`),n=[],r=null;for(;r=t.exec(e);){let e=r[3].replace(RegExp(`[${DT}]+`,`g`),``),t={type:r[1],headers:[],rawData:M.Convert.FromBase64(e)},i=r[2];if(i){let e=i.split(new RegExp(AT,`g`)),n=null;for(let r of e){let[e,i]=r.split(/:(.*)/);if(i===void 0){if(!n)throw Error(`Cannot parse PEM string. Incorrect header value`);n.value+=e.trim()}else n&&t.headers.push(n),n={key:e,value:i.trim()}}n&&t.headers.push(n)}n.push(t)}return n}static decode(e){return this.decodeWithHeaders(e).map(e=>e.rawData)}static decodeFirst(e){let t=this.decode(e);if(!t.length)throw RangeError(`PEM string doesn't contain any objects`);return t[0]}static encode(e,t){if(Array.isArray(e)){let n=[];return t?e.forEach(e=>{if(!M.BufferSourceConverter.isBufferSource(e))throw TypeError(`Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource`);n.push(this.encodeStruct({type:t,rawData:M.BufferSourceConverter.toArrayBuffer(e)}))}):e.forEach(e=>{if(!(`type`in e))throw TypeError(`Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut`);n.push(this.encodeStruct(e))}),n.join(`
301
301
  `)}else{if(!t)throw Error(`Required argument 'tag' is missed`);return this.encodeStruct({type:t,rawData:M.BufferSourceConverter.toArrayBuffer(e)})}}static encodeStruct(e){let t=e.type.toLocaleUpperCase(),n=[];if(n.push(`-----BEGIN ${t}-----`),e.headers?.length){for(let t of e.headers)n.push(`${t.key}: ${t.value}`);n.push(``)}let r=M.Convert.ToBase64(e.rawData),i,a=0,o=[];for(;a<r.length&&(r.length-a<64?i=r.substring(a):(i=r.substring(a,a+64),a+=64),i.length!==0)&&(o.push(i),!(i.length<64)););return n.push(...o),n.push(`-----END ${t}-----`),n.join(`
302
- `)}};jT.CertificateTag=`CERTIFICATE`,jT.CrlTag=`CRL`,jT.CertificateRequestTag=`CERTIFICATE REQUEST`,jT.PublicKeyTag=`PUBLIC KEY`,jT.PrivateKeyTag=`PRIVATE KEY`;var MT=class e extends rT{static isAsnEncoded(e){return M.BufferSourceConverter.isBufferSource(e)||typeof e==`string`}static toArrayBuffer(e){if(typeof e==`string`){if(jT.isPem(e))return jT.decode(e)[0];if(M.Convert.isHex(e))return M.Convert.FromHex(e);if(M.Convert.isBase64(e))return M.Convert.FromBase64(e);if(M.Convert.isBase64Url(e))return M.Convert.FromBase64Url(e);throw TypeError(`Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url`)}else{let t=M.BufferSourceConverter.toUint8Array(e);if(t.length>0&&t[0]===48)return M.BufferSourceConverter.toArrayBuffer(e);let n=M.Convert.ToBinary(e);if(jT.isPem(n))return jT.decode(n)[0];if(M.Convert.isHex(n))return M.Convert.FromHex(n);if(M.Convert.isBase64(n))return M.Convert.FromBase64(n);if(M.Convert.isBase64Url(n))return M.Convert.FromBase64Url(n);throw TypeError(`Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url`)}}constructor(...t){e.isAsnEncoded(t[0])?super(e.toArrayBuffer(t[0]),t[1]):super(t[0])}toString(e=`pem`){switch(e){case`pem`:return jT.encode(this.rawData,this.tag);default:return super.toString(e)}}},NT=class e extends MT{static async create(t,n=sT.get()){if(t instanceof e)return t;if(oT.isCryptoKey(t)){if(t.type!==`public`)throw TypeError(`Public key is required`);return new e(await n.subtle.exportKey(`spki`,t))}else if(t.publicKey)return t.publicKey;else if(M.BufferSourceConverter.isBufferSource(t))return new e(t);else throw TypeError(`Unsupported PublicKeyType`)}constructor(e){MT.isAsnEncoded(e)?super(e,Fy):super(e),this.tag=jT.PublicKeyTag}async export(...e){let t,n=[`verify`],r={hash:`SHA-256`,...this.algorithm};e.length>1?(r=e[0]||r,n=e[1]||n,t=e[2]||sT.get()):t=e[0]||sT.get();let i=this.rawData,a=V.parse(this.rawData,Fy);return a.algorithm.algorithm===Xx&&(i=PT(a,i)),t.subtle.importKey(`spki`,i,r,!0,n)}onInit(e){let t=aC.resolve(yw),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case qx:{let t=V.parse(e.subjectPublicKey,DS),r=M.BufferSourceConverter.toUint8Array(t.modulus);n.publicExponent=M.BufferSourceConverter.toUint8Array(t.publicExponent),n.modulusLength=(r[0]?r:r.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){let t,n=`SHA-1`;return e.length>=1&&!e[0]?.subtle?(n=e[0]||n,t=e[1]||sT.get()):t=e[0]||sT.get(),await t.subtle.digest(n,this.rawData)}async getKeyIdentifier(...e){let t,n=`SHA-1`;e.length===1?typeof e[0]==`string`?(n=e[0],t=sT.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=sT.get();let r=V.parse(this.rawData,Fy);return await t.subtle.digest(n,r.subjectPublicKey)}toTextObject(){let e=this.toTextObjectEmpty(),t=V.parse(this.rawData,Fy);switch(e.Algorithm=tT.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case wx:e[`EC Point`]=t.subjectPublicKey;break;case qx:default:e[`Raw Data`]=t.subjectPublicKey}return e}};function PT(e,t){return e.algorithm=new J({algorithm:qx,parameters:null}),t=V.serialize(e),t}var FT=class e extends iT{static async create(t,n=!1,r=sT.get()){if(`name`in t&&`serialNumber`in t)return new e(t,n);let i=await(await NT.create(t,r)).getKeyIdentifier(r);return new e(M.Convert.ToHex(i),n)}constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]==`string`){let t=new vv({keyIdentifier:new _v(M.Convert.FromHex(e[0]))});super(gv,e[1],V.serialize(t))}else{let t=e[0],n=new vv({authorityCertIssuer:t.name instanceof wT?V.parse(t.name.rawData,Sv):t.name,authorityCertSerialNumber:M.Convert.FromHex(t.serialNumber)});super(gv,e[1],V.serialize(n))}}onInit(e){super.onInit(e);let t=V.parse(e.extnValue,vv);t.keyIdentifier&&(this.keyId=M.Convert.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?M.Convert.ToHex(t.authorityCertSerialNumber):``})}toTextObject(){let e=this.toTextObjectWithoutValue(),t=V.parse(this.value,vv);return t.authorityCertIssuer&&(e[`Authority Issuer`]=new wT(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e[`Authority Serial Number`]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[``]=t.keyIdentifier),e}};FT.NAME=`Authority Key Identifier`;var IT=class extends iT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=V.parse(this.value,bv);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{let t=new bv({cA:e[0],pathLenConstraint:e[1]});super(yv,e[2],V.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e[`Path Length`]=this.pathLength),e}};IT.NAME=`Basic Constraints`;var LT;(function(e){e.serverAuth=`1.3.6.1.5.5.7.3.1`,e.clientAuth=`1.3.6.1.5.5.7.3.2`,e.codeSigning=`1.3.6.1.5.5.7.3.3`,e.emailProtection=`1.3.6.1.5.5.7.3.4`,e.timeStamping=`1.3.6.1.5.5.7.3.8`,e.ocspSigning=`1.3.6.1.5.5.7.3.9`})(LT||={});var RT=class extends iT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=V.parse(this.value,Zv);this.usages=t.map(e=>e)}else{let t=new Zv(e[0]);super(Xv,e[1],V.serialize(t)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=this.usages.map(e=>eT.toString(e)).join(`, `),e}};RT.NAME=`Extended Key Usages`;var zT;(function(e){e[e.digitalSignature=1]=`digitalSignature`,e[e.nonRepudiation=2]=`nonRepudiation`,e[e.keyEncipherment=4]=`keyEncipherment`,e[e.dataEncipherment=8]=`dataEncipherment`,e[e.keyAgreement=16]=`keyAgreement`,e[e.keyCertSign=32]=`keyCertSign`,e[e.cRLSign=64]=`cRLSign`,e[e.encipherOnly=128]=`encipherOnly`,e[e.decipherOnly=256]=`decipherOnly`})(zT||={});var BT=class extends iT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=V.parse(this.value,fy);this.usages=t.toNumber()}else{let t=new fy(e[0]);super(uy,e[1],V.serialize(t)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=V.parse(this.value,fy).toJSON().join(`, `),e}};BT.NAME=`Key Usages`;var VT=class e extends iT{static async create(t,n=!1,r=sT.get()){let i=await(await NT.create(t,r)).getKeyIdentifier(r);return new e(M.Convert.ToHex(i),n)}constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=V.parse(this.value,Oy);this.keyId=M.Convert.ToHex(t)}else{let t=typeof e[0]==`string`?M.Convert.FromHex(e[0]):e[0],n=new Oy(t);super(Dy,e[1],V.serialize(n)),this.keyId=M.Convert.ToHex(t)}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=V.parse(this.value,Oy),e}};VT.NAME=`Subject Key Identifier`;var HT=class extends iT{constructor(...e){M.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(Sy,e[1],new wT(e[0]||[]).rawData)}onInit(e){super.onInit(e);let t=V.parse(e.extnValue,Cy);this.names=new wT(t)}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(let n in t)e[n]=t[n];return e}};HT.NAME=`Subject Alternative Name`;var UT=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new iT(e),n=this.items.get(t.type);return n?new n(e):t}};UT.items=new Map;var WT=class extends iT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=V.parse(this.value,Nv);this.policies=t.map(e=>e.policyIdentifier)}else{let t=e[0],n=e[1]??!1,r=new Nv(t.map(e=>new Mv({policyIdentifier:e})));super(Ev,n,V.serialize(r)),this.policies=t}}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(e=>new Z(``,{},eT.toString(e))),e}};WT.NAME=`Certificate Policies`,UT.register(Ev,WT);var GT=class extends iT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]==`string`){let t=e[0].map(e=>new Vv({distributionPoint:new Bv({fullName:[new K({uniformResourceIdentifier:e})]})})),n=new Hv(t);super(Lv,e[1],V.serialize(n))}else{let t=new Hv(e[0]);super(Lv,e[1],V.serialize(t))}this.distributionPoints??=[]}onInit(e){super.onInit(e);let t=V.parse(e.extnValue,Hv);this.distributionPoints=t}toTextObject(){let e=this.toTextObjectWithoutValue();return e[`Distribution Point`]=this.distributionPoints.map(e=>{let t={};return e.distributionPoint&&(t[``]=e.distributionPoint.fullName?.map(e=>new CT(e).toString()).join(`, `)),e.reasons&&(t.Reasons=e.reasons.toString()),e.cRLIssuer&&(t[`CRL Issuer`]=e.cRLIssuer.map(e=>e.toString()).join(`, `)),t}),e}};GT.NAME=`CRL Distribution Points`;var KT=class extends iT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof hv){let t=new hv(e[0]);super(pv,e[1],V.serialize(t))}else{let t=e[0],n=new hv;JT(n,t,cv,`ocsp`),JT(n,t,lv,`caIssuers`),JT(n,t,uv,`timeStamping`),JT(n,t,dv,`caRepository`),super(pv,e[1],V.serialize(n))}this.ocsp??=[],this.caIssuers??=[],this.timeStamping??=[],this.caRepository??=[]}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],V.parse(e.extnValue,hv).forEach(e=>{switch(e.accessMethod){case cv:this.ocsp.push(new CT(e.accessLocation));break;case lv:this.caIssuers.push(new CT(e.accessLocation));break;case uv:this.timeStamping.push(new CT(e.accessLocation));break;case dv:this.caRepository.push(new CT(e.accessLocation));break}})}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ocsp.length&&qT(e,`OCSP`,this.ocsp),this.caIssuers.length&&qT(e,`CA Issuers`,this.caIssuers),this.timeStamping.length&&qT(e,`Time Stamping`,this.timeStamping),this.caRepository.length&&qT(e,`CA Repository`,this.caRepository),e}};KT.NAME=`Authority Info Access`;function qT(e,t,n){if(n.length===1)e[t]=n[0].toTextObject();else{let r=new Z(``);n.forEach((e,t)=>{let n=e.toTextObject(),i=`${n[Z.NAME]} ${t+1}`,a=r[i];Array.isArray(a)||(a=[],r[i]=a),a.push(n)}),e[t]=r}}function JT(e,t,n,r){let i=t[r];i&&(Array.isArray(i)?i:[i]).forEach(t=>{typeof t==`string`&&(t=new CT(`url`,t)),e.push(new mv({accessMethod:n,accessLocation:V.parse(t.rawData,K)}))})}var YT=class extends iT{constructor(...e){M.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(cy,e[1],new wT(e[0]||[]).rawData)}onInit(e){super.onInit(e);let t=V.parse(e.extnValue,Sv);this.names=new wT(t)}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(let n in t)e[n]=t[n];return e}};YT.NAME=`Issuer Alternative Name`;var XT=class e extends rT{constructor(...e){let t;if(M.BufferSourceConverter.isBufferSource(e[0]))t=M.BufferSourceConverter.toArrayBuffer(e[0]);else{let n=e[0],r=Array.isArray(e[1])?e[1].map(e=>M.BufferSourceConverter.toArrayBuffer(e)):[];t=V.serialize(new wy({type:n,values:r}))}super(t,wy)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Value=this.values.map(e=>new Z(``,{"":e})),e}toTextObjectWithoutValue(){let t=this.toTextObjectEmpty();return t[Z.NAME]===e.NAME&&(t[Z.NAME]=eT.toString(this.type)),t}};XT.NAME=`Attribute`;var ZT=class extends XT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let t=new sw({printableString:e[0]});super(VC,[V.serialize(t)])}this.password??=``}onInit(e){if(super.onInit(e),this.values[0]){let e=V.parse(this.values[0],sw);this.password=e.toString()}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[Z.VALUE]=this.password,e}};ZT.NAME=`Challenge Password`;var QT=class extends XT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let t=e[0],n=new By;for(let e of t)n.push(V.parse(e.rawData,zy));super(HC,[V.serialize(n)])}this.items??=[]}onInit(e){if(super.onInit(e),this.values[0]){let e=V.parse(this.values[0],By);this.items=e.map(e=>UT.create(V.serialize(e)))}}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.items.map(e=>e.toTextObject());for(let n of t)e[n[Z.NAME]]=n;return e}};QT.NAME=`Extensions`;var $T=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new XT(e),n=this.items.get(t.type);return n?new n(e):t}};$T.items=new Map;var eE=`crypto.signatureFormatter`,tE=class{toAsnSignature(e,t){return M.BufferSourceConverter.toArrayBuffer(t)}toWebSignature(e,t){return M.BufferSourceConverter.toArrayBuffer(t)}},nE,rE=nE=class{static createPssParams(e,t){let n=nE.getHashAlgorithm(e);return n?new xS({hashAlgorithm:n,maskGenAlgorithm:new J({algorithm:hS,parameters:V.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){let t=aC.resolve(yw);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 Error(`Cannot get hash algorithm name`);switch(t.toLowerCase()){case`sha-1`:return new J({algorithm:$x,parameters:null});case`sha-256`:return new J({algorithm:tS,parameters:null});case`sha-384`:return new J({algorithm:nS,parameters:null});case`sha-512`:return new J({algorithm:rS,parameters:null})}}else return new J({algorithm:qx,parameters:null});break;case`rsa-pss`:if(`hash`in e){if(!(`saltLength`in e&&typeof e.saltLength==`number`))throw Error(`Cannot get 'saltLength' from 'alg' argument`);let t=nE.createPssParams(e.hash,e.saltLength);if(!t)throw Error(`Cannot create PSS parameters`);return new J({algorithm:Xx,parameters:V.serialize(t)})}else return new J({algorithm:Xx,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case qx:return{name:`RSASSA-PKCS1-v1_5`};case $x:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-1`}};case tS:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-256`}};case nS:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-384`}};case rS:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-512`}};case Xx:if(e.parameters){let t=V.parse(e.parameters,xS);return{name:`RSA-PSS`,hash:aC.resolve(yw).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:`RSA-PSS`}}return null}};rE=nE=H([oC()],rE),aC.registerSingleton(_w,rE);var iE=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case`sha-1`:return new J({algorithm:oS});case`sha-256`:return new J({algorithm:cS});case`sha-384`:return new J({algorithm:lS});case`sha-512`:return new J({algorithm:uS})}return null}toWebAlgorithm(e){switch(e.algorithm){case oS:return{name:`SHA-1`};case cS:return{name:`SHA-256`};case lS:return{name:`SHA-384`};case uS:return{name:`SHA-512`}}return null}};iE=H([oC()],iE),aC.registerSingleton(_w,iE);var aE=class e{addPadding(e,t){let n=M.BufferSourceConverter.toUint8Array(t),r=new Uint8Array(e);return r.set(n,e-n.length),r.buffer}removePadding(e,t=!1){let n=M.BufferSourceConverter.toUint8Array(e);for(let e=0;e<n.length;e++)if(n[e]){n=n.slice(e);break}if(t&&n[0]>127){let e=new Uint8Array(n.length+1);return e.set(n,1),e.buffer}return n.buffer}toAsnSignature(t,n){if(t.name===`ECDSA`){let r=t.namedCurve,i=e.namedCurveSize.get(r)||e.defaultNamedCurveSize,a=new Gx,o=M.BufferSourceConverter.toUint8Array(n);return a.r=this.removePadding(o.slice(0,i),!0),a.s=this.removePadding(o.slice(i,i+i),!0),V.serialize(a)}return null}toWebSignature(t,n){if(t.name===`ECDSA`){let r=V.parse(n,Gx),i=t.namedCurve,a=e.namedCurveSize.get(i)||e.defaultNamedCurveSize;return(0,M.combine)(this.addPadding(a,this.removePadding(r.r)),this.addPadding(a,this.removePadding(r.s)))}return null}};aE.namedCurveSize=new Map,aE.defaultNamedCurveSize=32;var oE=`1.3.101.110`,sE=`1.3.101.111`,cE=`1.3.101.112`,lE=`1.3.101.113`,uE=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case`ed25519`:t=cE;break;case`x25519`:t=oE;break;case`eddsa`:switch(e.namedCurve.toLowerCase()){case`ed25519`:t=cE;break;case`ed448`:t=lE;break}break;case`ecdh-es`:switch(e.namedCurve.toLowerCase()){case`x25519`:t=oE;break;case`x448`:t=sE;break}}return t?new J({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case cE:return{name:`Ed25519`};case lE:return{name:`EdDSA`,namedCurve:`Ed448`};case oE:return{name:`X25519`};case sE:return{name:`ECDH-ES`,namedCurve:`X448`}}return null}};uE=H([oC()],uE),aC.registerSingleton(_w,uE);var dE,fE,pE,mE,hE,gE,_E,vE,yE=class extends MT{get subjectName(){return U(this,fE,`f`)||W(this,fE,new mT(this.asn.certificationRequestInfo.subject),`f`),U(this,fE,`f`)}get subject(){return U(this,pE,`f`)||W(this,pE,this.subjectName.toString(),`f`),U(this,pE,`f`)}get signatureAlgorithm(){if(!U(this,mE,`f`)){let e=aC.resolve(yw);W(this,mE,e.toWebAlgorithm(this.asn.signatureAlgorithm),`f`)}return U(this,mE,`f`)}get signature(){return U(this,hE,`f`)||W(this,hE,this.asn.signature,`f`),U(this,hE,`f`)}get publicKey(){return U(this,gE,`f`)||W(this,gE,new NT(this.asn.certificationRequestInfo.subjectPKInfo),`f`),U(this,gE,`f`)}get attributes(){return U(this,_E,`f`)||W(this,_E,this.asn.certificationRequestInfo.attributes.map(e=>$T.create(V.serialize(e))),`f`),U(this,_E,`f`)}get extensions(){if(!U(this,vE,`f`)){W(this,vE,[],`f`);let e=this.getAttribute(HC);e instanceof QT&&W(this,vE,e.items,`f`)}return U(this,vE,`f`)}get tbs(){return U(this,dE,`f`)||W(this,dE,this.asn.certificationRequestInfoRaw||V.serialize(this.asn.certificationRequestInfo),`f`),U(this,dE,`f`)}constructor(e){let t=MT.isAsnEncoded(e)?[e,gw]:[e];super(t[0],t[1]),dE.set(this,void 0),fE.set(this,void 0),pE.set(this,void 0),mE.set(this,void 0),hE.set(this,void 0),gE.set(this,void 0),_E.set(this,void 0),vE.set(this,void 0),this.tag=jT.CertificateRequestTag}onInit(e){}getAttribute(e){for(let 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(let 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=sT.get()){let t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,[`verify`],e),r=aC.resolveAll(eE).reverse(),i=null;for(let e of r)if(i=e.toWebSignature(t,this.signature),i)break;if(!i)throw Error(`Cannot convert WebCrypto signature value to ASN.1 format`);return await e.subtle.verify(this.signatureAlgorithm,n,i,this.tbs)}toTextObject(){let e=this.toTextObjectEmpty(),t=V.parse(this.rawData,gw),n=t.certificationRequestInfo,r=new Z(``,{Version:`${Vy[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){let e=new Z(``);for(let t of this.attributes){let n=t.toTextObject();e[n[Z.NAME]]=n}r.Attributes=e}return e.Data=r,e.Signature=new Z(``,{Algorithm:tT.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}};dE=new WeakMap,fE=new WeakMap,pE=new WeakMap,mE=new WeakMap,hE=new WeakMap,gE=new WeakMap,_E=new WeakMap,vE=new WeakMap,yE.NAME=`PKCS#10 Certificate Request`;var bE,xE,SE,CE,wE,TE,EE,DE,OE,kE,AE,jE,ME=class extends MT{get publicKey(){return U(this,jE,`f`)||W(this,jE,new NT(this.asn.tbsCertificate.subjectPublicKeyInfo),`f`),U(this,jE,`f`)}get serialNumber(){if(!U(this,xE,`f`)){let e=this.asn.tbsCertificate,t=new Uint8Array(e.serialNumber);t.length>1&&t[0]===0&&t[1]>127&&(t=t.slice(1)),W(this,xE,M.Convert.ToHex(t),`f`)}return U(this,xE,`f`)}get subjectName(){return U(this,SE,`f`)||W(this,SE,new mT(this.asn.tbsCertificate.subject),`f`),U(this,SE,`f`)}get subject(){return U(this,CE,`f`)||W(this,CE,this.subjectName.toString(),`f`),U(this,CE,`f`)}get issuerName(){return U(this,wE,`f`)||W(this,wE,new mT(this.asn.tbsCertificate.issuer),`f`),U(this,wE,`f`)}get issuer(){return U(this,TE,`f`)||W(this,TE,this.issuerName.toString(),`f`),U(this,TE,`f`)}get notBefore(){if(!U(this,EE,`f`)){let e=this.asn.tbsCertificate.validity.notBefore.utcTime||this.asn.tbsCertificate.validity.notBefore.generalTime;if(!e)throw Error(`Cannot get 'notBefore' value`);W(this,EE,e,`f`)}return U(this,EE,`f`)}get notAfter(){if(!U(this,DE,`f`)){let e=this.asn.tbsCertificate.validity.notAfter.utcTime||this.asn.tbsCertificate.validity.notAfter.generalTime;if(!e)throw Error(`Cannot get 'notAfter' value`);W(this,DE,e,`f`)}return U(this,DE,`f`)}get signatureAlgorithm(){if(!U(this,OE,`f`)){let e=aC.resolve(yw);W(this,OE,e.toWebAlgorithm(this.asn.signatureAlgorithm),`f`)}return U(this,OE,`f`)}get signature(){return U(this,kE,`f`)||W(this,kE,this.asn.signatureValue,`f`),U(this,kE,`f`)}get extensions(){return U(this,AE,`f`)||(W(this,AE,[],`f`),this.asn.tbsCertificate.extensions&&W(this,AE,this.asn.tbsCertificate.extensions.map(e=>UT.create(V.serialize(e))),`f`)),U(this,AE,`f`)}get tbs(){return U(this,bE,`f`)||W(this,bE,this.asn.tbsCertificateRaw||V.serialize(this.asn.tbsCertificate),`f`),U(this,bE,`f`)}constructor(e){let t=MT.isAsnEncoded(e)?[e,Uy]:[e];super(t[0],t[1]),bE.set(this,void 0),xE.set(this,void 0),SE.set(this,void 0),CE.set(this,void 0),wE.set(this,void 0),TE.set(this,void 0),EE.set(this,void 0),DE.set(this,void 0),OE.set(this,void 0),kE.set(this,void 0),AE.set(this,void 0),jE.set(this,void 0),this.tag=jT.CertificateTag}onInit(e){}getExtension(e){for(let 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=sT.get()){let n,r,i=e.publicKey;try{if(!i)n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,[`verify`],t);else if(`publicKey`in i)n={...i.publicKey.algorithm,...this.signatureAlgorithm},r=await i.publicKey.export(n,[`verify`],t);else if(i instanceof NT)n={...i.algorithm,...this.signatureAlgorithm},r=await i.export(n,[`verify`],t);else if(M.BufferSourceConverter.isBufferSource(i)){let e=new NT(i);n={...e.algorithm,...this.signatureAlgorithm},r=await e.export(n,[`verify`],t)}else n={...i.algorithm,...this.signatureAlgorithm},r=i}catch{return!1}let a=aC.resolveAll(eE).reverse(),o=null;for(let e of a)if(o=e.toWebSignature(n,this.signature),o)break;if(!o)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);let s=await t.subtle.verify(this.signatureAlgorithm,r,o,this.tbs);if(e.signatureOnly)return s;{let t=(e.date||new Date).getTime();return s&&this.notBefore.getTime()<t&&t<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??=sT.get(),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=sT.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){let e=this.toTextObjectEmpty(),t=V.parse(this.rawData,Uy),n=t.tbsCertificate,r=new Z(``,{Version:`${Vy[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":tT.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new Z(``,{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(r[`Issuer Unique ID`]=n.issuerUniqueID),n.subjectUniqueID&&(r[`Subject Unique ID`]=n.subjectUniqueID),this.extensions.length){let e=new Z(``);for(let t of this.extensions){let n=t.toTextObject();e[n[Z.NAME]]=n}r.Extensions=e}return e.Data=r,e.Signature=new Z(``,{Algorithm:tT.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}};bE=new WeakMap,xE=new WeakMap,SE=new WeakMap,CE=new WeakMap,wE=new WeakMap,TE=new WeakMap,EE=new WeakMap,DE=new WeakMap,OE=new WeakMap,kE=new WeakMap,AE=new WeakMap,jE=new WeakMap,ME.NAME=`Certificate`;function NE(e,t=sT.get()){let n=M.BufferSourceConverter.toUint8Array(M.Convert.FromHex(e||``)),r=n&&n.length&&n.some(e=>e>0)?new Uint8Array(n):void 0;r||=t.getRandomValues(new Uint8Array(16));let i=0;for(;i<r.length-1&&r[i]===0;)i++;if(r=r.slice(i),r[0]>127){let e=new Uint8Array(r.length+1);e[0]=0,e.set(r,1),r=e}return r.buffer}var PE=class{static async createSelfSigned(e,t=sT.get()){if(!e.keys.privateKey)throw Error(`Bad field 'keys' in 'params' argument. 'privateKey' is empty`);if(!e.keys.publicKey)throw Error(`Bad field 'keys' in 'params' argument. 'publicKey' is empty`);return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,t=sT.get()){let n;n=e.publicKey instanceof NT?e.publicKey.rawData:`publicKey`in e.publicKey?e.publicKey.publicKey.rawData:M.BufferSourceConverter.isBufferSource(e.publicKey)?e.publicKey:await t.subtle.exportKey(`spki`,e.publicKey);let r=NE(e.serialNumber,t),i=e.notBefore||new Date,a=e.notAfter||new Date(i.getTime()+31536e6),o=new Uy({tbsCertificate:new Hy({version:Vy.v3,serialNumber:r,validity:new Ly({notBefore:i,notAfter:a}),extensions:new By(e.extensions?.map(e=>V.parse(e.rawData,zy))||[]),subjectPublicKeyInfo:V.parse(n,Fy)})});if(e.subject){let t=e.subject instanceof mT?e.subject:new mT(e.subject);o.tbsCertificate.subject=V.parse(t.toArrayBuffer(),G)}if(e.issuer){let t=e.issuer instanceof mT?e.issuer:new mT(e.issuer);o.tbsCertificate.issuer=V.parse(t.toArrayBuffer(),G)}let s={hash:`SHA-256`},c=`signingKey`in e?{...s,...e.signingAlgorithm,...e.signingKey.algorithm}:{...s,...e.signingAlgorithm},l=aC.resolve(yw);o.tbsCertificate.signature=o.signatureAlgorithm=l.toAsnAlgorithm(c);let u=V.serialize(o.tbsCertificate),d=`signingKey`in e?await t.subtle.sign(c,e.signingKey,u):e.signature,f=aC.resolveAll(eE).reverse(),p=null;for(let e of f)if(p=e.toAsnSignature(c,d),p)break;if(!p)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return o.signatureValue=p,new ME(V.serialize(o))}},FE,IE,LE,RE,zE,BE;(function(e){e[e.unspecified=0]=`unspecified`,e[e.keyCompromise=1]=`keyCompromise`,e[e.cACompromise=2]=`cACompromise`,e[e.affiliationChanged=3]=`affiliationChanged`,e[e.superseded=4]=`superseded`,e[e.cessationOfOperation=5]=`cessationOfOperation`,e[e.certificateHold=6]=`certificateHold`,e[e.removeFromCRL=8]=`removeFromCRL`,e[e.privilegeWithdrawn=9]=`privilegeWithdrawn`,e[e.aACompromise=10]=`aACompromise`})(BE||={});var VE=class extends rT{get serialNumber(){return U(this,FE,`f`)||W(this,FE,M.Convert.ToHex(this.asn.userCertificate),`f`),U(this,FE,`f`)}get revocationDate(){return U(this,IE,`f`)||W(this,IE,this.asn.revocationDate.getTime(),`f`),U(this,IE,`f`)}get reason(){return U(this,LE,`f`)===void 0&&this.extensions,U(this,LE,`f`)}get invalidity(){return U(this,RE,`f`)===void 0&&this.extensions,U(this,RE,`f`)}get extensions(){return U(this,zE,`f`)||(W(this,zE,[],`f`),this.asn.crlEntryExtensions&&W(this,zE,this.asn.crlEntryExtensions.map(e=>{let t=UT.create(V.serialize(e));switch(t.type){case Kv:U(this,LE,`f`)===void 0&&W(this,LE,V.parse(t.value,Jv).reason,`f`);break;case ay:U(this,RE,`f`)===void 0&&W(this,RE,V.parse(t.value,oy).value,`f`);break}return t}),`f`)),U(this,zE,`f`)}constructor(...e){let t;if(M.BufferSourceConverter.isBufferSource(e[0])?t=M.BufferSourceConverter.toArrayBuffer(e[0]):typeof e[0]==`string`?t=V.serialize(new Wy({userCertificate:NE(e[0]),revocationDate:new Iy(e[1]),crlEntryExtensions:e[2]})):e[0]instanceof Wy&&(t=e[0]),!t)throw TypeError(`Cannot create X509CrlEntry instance. Wrong constructor arguments.`);super(t,Wy),FE.set(this,void 0),IE.set(this,void 0),LE.set(this,void 0),RE.set(this,void 0),zE.set(this,void 0)}onInit(e){}};FE=new WeakMap,IE=new WeakMap,LE=new WeakMap,RE=new WeakMap,zE=new WeakMap;var HE,UE,WE,GE,KE,qE,JE,YE=class extends MT{get version(){return this.asn.tbsCertList.version}get signatureAlgorithm(){if(!U(this,UE,`f`)){let e=aC.resolve(yw);W(this,UE,e.toWebAlgorithm(this.asn.signatureAlgorithm),`f`)}return U(this,UE,`f`)}get signature(){return this.asn.signature}get issuer(){return this.issuerName.toString()}get issuerName(){return U(this,WE,`f`)||W(this,WE,new mT(this.asn.tbsCertList.issuer),`f`),U(this,WE,`f`)}get thisUpdate(){if(!U(this,GE,`f`)){let e=this.asn.tbsCertList.thisUpdate.getTime();if(!e)throw Error(`Cannot get 'thisUpdate' value`);W(this,GE,e,`f`)}return U(this,GE,`f`)}get nextUpdate(){return U(this,KE,`f`)===void 0&&W(this,KE,this.asn.tbsCertList.nextUpdate?.getTime()||void 0,`f`),U(this,KE,`f`)}get entries(){return U(this,qE,`f`)||W(this,qE,this.asn.tbsCertList.revokedCertificates?.map(e=>new VE(e))||[],`f`),U(this,qE,`f`)}get extensions(){return U(this,JE,`f`)||(W(this,JE,[],`f`),this.asn.tbsCertList.crlExtensions&&W(this,JE,this.asn.tbsCertList.crlExtensions.map(e=>UT.create(V.serialize(e))),`f`)),U(this,JE,`f`)}get tbs(){return U(this,HE,`f`)||W(this,HE,this.asn.tbsCertListRaw||V.serialize(this.asn.tbsCertList),`f`),U(this,HE,`f`)}get tbsCertListSignatureAlgorithm(){return this.asn.tbsCertList.signature}get certListSignatureAlgorithm(){return this.asn.signatureAlgorithm}constructor(e){super(e,MT.isAsnEncoded(e)?Ky:void 0),this.tag=jT.CrlTag,HE.set(this,void 0),UE.set(this,void 0),WE.set(this,void 0),GE.set(this,void 0),KE.set(this,void 0),qE.set(this,void 0),JE.set(this,void 0)}onInit(e){}getExtension(e){for(let 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=sT.get()){if(!this.certListSignatureAlgorithm.isEqual(this.tbsCertListSignatureAlgorithm))throw Error(`algorithm identifier in the sequence tbsCertList and CertificateList mismatch`);let n,r,i=e.publicKey;try{i instanceof ME?(n={...i.publicKey.algorithm,...i.signatureAlgorithm},r=await i.publicKey.export(n,[`verify`])):i instanceof NT?(n={...i.algorithm,...this.signatureAlgorithm},r=await i.export(n,[`verify`])):(n={...i.algorithm,...this.signatureAlgorithm},r=i)}catch{return!1}let a=aC.resolveAll(eE).reverse(),o=null;for(let e of a)if(o=e.toWebSignature(n,this.signature),o)break;if(!o)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return await t.subtle.verify(this.signatureAlgorithm,r,o,this.tbs)}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??=sT.get(),await t.subtle.digest(n,this.rawData)}findRevoked(e){let t=NE(typeof e==`string`?e:e.serialNumber);for(let e of this.asn.tbsCertList.revokedCertificates||[])if(M.BufferSourceConverter.isEqual(e.userCertificate,t))return new VE(V.serialize(e));return null}};HE=new WeakMap,UE=new WeakMap,WE=new WeakMap,GE=new WeakMap,KE=new WeakMap,qE=new WeakMap,JE=new WeakMap,UT.register(yv,IT),UT.register(Xv,RT),UT.register(uy,BT),UT.register(Dy,VT),UT.register(gv,FT),UT.register(Sy,HT),UT.register(Lv,GT),UT.register(pv,KT),UT.register(cy,YT),$T.register(VC,ZT),$T.register(HC,QT),aC.registerSingleton(eE,tE),aC.registerSingleton(eE,aE),aE.namedCurveSize.set(`P-256`,32),aE.namedCurveSize.set(`K-256`,32),aE.namedCurveSize.set(`P-384`,48),aE.namedCurveSize.set(`P-521`,66);var XE={"P-256":`ES256`,"P-384":`ES384`,"P-521":`ES512`},ZE={RS256:`SHA-256`,RS384:`SHA-384`,RS512:`SHA-512`},QE=new Set([`RS256`,`RS384`,`RS512`,`ES256`,`ES384`,`ES512`]);function $E(e){return typeof e==`string`&&QE.has(e)}function eD(e){if($E(e.alg)){if(e.kty===`RSA`&&e.alg.startsWith(`RS`))return e.alg;if(e.kty===`EC`&&e.alg.startsWith(`ES`)){let t=e.crv&&e.crv in XE?XE[e.crv]:void 0;if(t&&t!==e.alg)throw Error(`EC alg/curve mismatch: curve ${e.crv} requires ${t}, got ${e.alg}`);return e.alg}}if(e.kty===`RSA`)return`RS256`;if(e.kty===`EC`){if(!e.crv||!(e.crv in XE))throw Error(`Unsupported EC curve: ${e.crv??`(missing)`}`);return XE[e.crv]}throw Error(`Unsupported JWK kty: ${e.kty}`)}function tD(e,t){if(e.kty===`RSA`){let e=ZE[t];if(!e)throw Error(`Unsupported RSA alg: ${t}`);return{name:`RSASSA-PKCS1-v1_5`,hash:e}}if(e.kty===`EC`){if(!e.crv||!(e.crv in XE))throw Error(`Unsupported EC curve: ${e.crv??`(missing)`}`);let n=XE[e.crv];if(t!==n)throw Error(`EC alg/curve mismatch: curve ${e.crv} requires ${n}, got ${t}`);return{name:`ECDSA`,namedCurve:e.crv}}throw Error(`Unsupported JWK kty: ${e.kty}`)}var nD=[`RS256`,`ES256`,`ES384`,`ES512`];async function rD(e){let t=await new ME(e).publicKey.export();return eD(await crypto.subtle.exportKey(`jwk`,t))}function iD(e){try{let t=/-----BEGIN (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----([^-]*)-----END (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----/.exec(e);if(!t||!t[1])throw Error(`Invalid PEM format`);return Uint8Array.from(atob(t[1].replace(/\s/g,``)),e=>e.charCodeAt(0)).buffer}finally{e=e.replace(/./g,`\0`)}}function aD(){return Ds(crypto.getRandomValues(new Uint8Array(32)))}async function oD(e,t){if(t===`plain`)return e;let n=new TextEncoder().encode(e),r=await crypto.subtle.digest(`SHA-256`,n);return Ds(new Uint8Array(r))}var sD={RSA:[`e`,`kty`,`n`],EC:[`crv`,`kty`,`x`,`y`],oct:[`k`,`kty`],OKP:[`crv`,`kty`,`x`]};function cD(e){switch(e){case`RSA`:return{name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`,publicExponent:new Uint8Array([1,0,1]),modulusLength:2048};case`EC-P-256`:return{name:`ECDSA`,namedCurve:`P-256`};case`EC-P-384`:return{name:`ECDSA`,namedCurve:`P-384`};case`EC-P-521`:return{name:`ECDSA`,namedCurve:`P-521`}}}function lD(e){switch(e){case`RSA`:return{name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`,publicExponent:new Uint8Array([1,0,1]),modulusLength:2048};case`EC-P-256`:return{name:`ECDSA`,hash:`SHA-256`};case`EC-P-384`:return{name:`ECDSA`,hash:`SHA-384`};case`EC-P-521`:return{name:`ECDSA`,hash:`SHA-512`}}}var uD=1440*60*1e3,dD=3650;function fD(e){let t=e??365;if(!Number.isFinite(t)||t<1||t>3650)throw Error(`validityDays must be between 1 and ${dD}`);return new Date(Date.now()+t*uD)}async function pD(e){let t=e.keyType??`RSA`;if(t===`EC-P-521`&&(0,m.getRuntimeKey)()===`workerd`)throw Error(`EC-P-521 signing keys are not supported on Cloudflare Workers: workerd's WebCrypto implementation cannot generate the P-521 curve. Use RSA, EC-P-256, or EC-P-384 instead.`);let n=await crypto.subtle.generateKey(cD(t),!0,[`sign`,`verify`]),r=Yl(),i=Is(new TextEncoder().encode(r)),a=e.certificateAuthority?await yD(e.certificateAuthority,{publicKey:n.publicKey,name:e.name,validityDays:e.validityDays}):await PE.createSelfSigned({serialNumber:i,name:e.name,notBefore:new Date,notAfter:fD(e.validityDays),signingAlgorithm:lD(t),keys:n,extensions:[new IT(!0,2,!0),new RT([`1.3.6.1.5.5.7.3.1`],!0),new BT(zT.keyCertSign|zT.cRLSign,!0),await VT.create(n.publicKey)]}),o=await crypto.subtle.exportKey(`pkcs8`,n.privateKey),s=a.toString(`pem`),c=await xD(a);return{kid:c,cert:s,thumbprint:Is(await a.getThumbprint()),fingerprint:c,pkcs7:bD(`PRIVATE`,o),type:`jwt_signing`}}var mD=[`RSA`,`EC-P-256`,`EC-P-384`,`EC-P-521`];async function hD(e){let t=iD(e);for(let e of mD)try{return{key:await crypto.subtle.importKey(`pkcs8`,t,cD(e),!0,[`sign`]),keyType:e}}catch{}throw Error(`Unable to import the private key: not a supported RSA or EC key`)}function gD(e){let t=(e,t)=>{if(!e)throw Error(`JWK is missing required member '${t}'`);return e};switch(e.kty){case`RSA`:return{kty:`RSA`,n:t(e.n,`n`),e:t(e.e,`e`)};case`EC`:return{kty:`EC`,crv:t(e.crv,`crv`),x:t(e.x,`x`),y:t(e.y,`y`)};case`OKP`:return{kty:`OKP`,crv:t(e.crv,`crv`),x:t(e.x,`x`)};default:throw Error(`Unsupported JWK kty: ${e.kty}`)}}async function _D(e){let t=new ME(e.cert),{key:n,keyType:r}=await hD(e.pkcs7),i=gD(await crypto.subtle.exportKey(`jwk`,n)),a=await crypto.subtle.importKey(`jwk`,i,cD(r),!0,[`verify`]),o=await SD(i);if(o!==await xD(t))throw Error(`The stored private key does not match the stored certificate`);let s=Is(new TextEncoder().encode(Yl())),c=e.name||t.subject,l=e.certificateAuthority?await yD(e.certificateAuthority,{publicKey:a,name:c,validityDays:e.validityDays}):await PE.createSelfSigned({serialNumber:s,name:c,notBefore:new Date,notAfter:fD(e.validityDays),signingAlgorithm:lD(r),keys:{privateKey:n,publicKey:a},extensions:[new IT(!0,2,!0),new RT([`1.3.6.1.5.5.7.3.1`],!0),new BT(zT.keyCertSign|zT.cRLSign,!0),await VT.create(a)]});return{cert:l.toString(`pem`),thumbprint:Is(await l.getThumbprint()),fingerprint:o}}var vD=300*1e3;async function yD(e,t){let n=await crypto.subtle.exportKey(`spki`,t.publicKey),r=new Date,i=fD(t.validityDays),a=new ME(await e.issuer.issueCertificate({publicKey:bD(`PUBLIC`,n),subject:t.name,uri:e.uri,notBefore:r,notAfter:i})),o=a.getExtension(HT)?.names.items.filter(e=>e.type===`url`).map(e=>e.value)??[];if(o.length!==1||o[0]!==e.uri)throw Error(`The certificate authority returned a certificate for a different owner: expected SAN URI ${e.uri}`);if(a.getExtension(IT)?.ca)throw Error(`The certificate authority returned a CA certificate for a signing key`);let s=a.getExtension(BT)?.usages;if(s!==void 0&&(!(s&zT.digitalSignature)||s&(zT.keyCertSign|zT.cRLSign)))throw Error(`The certificate authority returned a certificate whose key usage doesn't permit signing tokens`);if(a.notBefore.getTime()<r.getTime()-vD||a.notAfter.getTime()>i.getTime()+vD||a.notAfter.getTime()<=Date.now())throw Error(`The certificate authority returned a certificate outside the requested validity window`);let c=SD(await crypto.subtle.exportKey(`jwk`,t.publicKey));if(await xD(a)!==await c)throw Error(`The certificate authority returned a certificate for a different key`);return a}function bD(e,t){let n=js(new Uint8Array(t)),r=`-----BEGIN ${e} KEY-----\r\n`,i=0;for(;i<n.length;)i+64<=n.length?r+=n.substr(i,64)+`\r
302
+ `)}};MT.CertificateTag=`CERTIFICATE`,MT.CrlTag=`CRL`,MT.CertificateRequestTag=`CERTIFICATE REQUEST`,MT.PublicKeyTag=`PUBLIC KEY`,MT.PrivateKeyTag=`PRIVATE KEY`;var NT=class e extends iT{static isAsnEncoded(e){return M.BufferSourceConverter.isBufferSource(e)||typeof e==`string`}static toArrayBuffer(e){if(typeof e==`string`){if(MT.isPem(e))return MT.decode(e)[0];if(M.Convert.isHex(e))return M.Convert.FromHex(e);if(M.Convert.isBase64(e))return M.Convert.FromBase64(e);if(M.Convert.isBase64Url(e))return M.Convert.FromBase64Url(e);throw TypeError(`Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url`)}else{let t=M.BufferSourceConverter.toUint8Array(e);if(t.length>0&&t[0]===48)return M.BufferSourceConverter.toArrayBuffer(e);let n=M.Convert.ToBinary(e);if(MT.isPem(n))return MT.decode(n)[0];if(M.Convert.isHex(n))return M.Convert.FromHex(n);if(M.Convert.isBase64(n))return M.Convert.FromBase64(n);if(M.Convert.isBase64Url(n))return M.Convert.FromBase64Url(n);throw TypeError(`Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url`)}}constructor(...t){e.isAsnEncoded(t[0])?super(e.toArrayBuffer(t[0]),t[1]):super(t[0])}toString(e=`pem`){switch(e){case`pem`:return MT.encode(this.rawData,this.tag);default:return super.toString(e)}}},PT=class e extends NT{static async create(t,n=cT.get()){if(t instanceof e)return t;if(sT.isCryptoKey(t)){if(t.type!==`public`)throw TypeError(`Public key is required`);return new e(await n.subtle.exportKey(`spki`,t))}else if(t.publicKey)return t.publicKey;else if(M.BufferSourceConverter.isBufferSource(t))return new e(t);else throw TypeError(`Unsupported PublicKeyType`)}constructor(e){NT.isAsnEncoded(e)?super(e,Iy):super(e),this.tag=MT.PublicKeyTag}async export(...e){let t,n=[`verify`],r={hash:`SHA-256`,...this.algorithm};e.length>1?(r=e[0]||r,n=e[1]||n,t=e[2]||cT.get()):t=e[0]||cT.get();let i=this.rawData,a=V.parse(this.rawData,Iy);return a.algorithm.algorithm===Zx&&(i=FT(a,i)),t.subtle.importKey(`spki`,i,r,!0,n)}onInit(e){let t=oC.resolve(bw),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Jx:{let t=V.parse(e.subjectPublicKey,OS),r=M.BufferSourceConverter.toUint8Array(t.modulus);n.publicExponent=M.BufferSourceConverter.toUint8Array(t.publicExponent),n.modulusLength=(r[0]?r:r.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){let t,n=`SHA-1`;return e.length>=1&&!e[0]?.subtle?(n=e[0]||n,t=e[1]||cT.get()):t=e[0]||cT.get(),await t.subtle.digest(n,this.rawData)}async getKeyIdentifier(...e){let t,n=`SHA-1`;e.length===1?typeof e[0]==`string`?(n=e[0],t=cT.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=cT.get();let r=V.parse(this.rawData,Iy);return await t.subtle.digest(n,r.subjectPublicKey)}toTextObject(){let e=this.toTextObjectEmpty(),t=V.parse(this.rawData,Iy);switch(e.Algorithm=nT.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case Tx:e[`EC Point`]=t.subjectPublicKey;break;case Jx:default:e[`Raw Data`]=t.subjectPublicKey}return e}};function FT(e,t){return e.algorithm=new q({algorithm:Jx,parameters:null}),t=V.serialize(e),t}var IT=class e extends aT{static async create(t,n=!1,r=cT.get()){if(`name`in t&&`serialNumber`in t)return new e(t,n);let i=await(await PT.create(t,r)).getKeyIdentifier(r);return new e(M.Convert.ToHex(i),n)}constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]==`string`){let t=new yv({keyIdentifier:new vv(M.Convert.FromHex(e[0]))});super(_v,e[1],V.serialize(t))}else{let t=e[0],n=new yv({authorityCertIssuer:t.name instanceof TT?V.parse(t.name.rawData,Cv):t.name,authorityCertSerialNumber:M.Convert.FromHex(t.serialNumber)});super(_v,e[1],V.serialize(n))}}onInit(e){super.onInit(e);let t=V.parse(e.extnValue,yv);t.keyIdentifier&&(this.keyId=M.Convert.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?M.Convert.ToHex(t.authorityCertSerialNumber):``})}toTextObject(){let e=this.toTextObjectWithoutValue(),t=V.parse(this.value,yv);return t.authorityCertIssuer&&(e[`Authority Issuer`]=new TT(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e[`Authority Serial Number`]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[``]=t.keyIdentifier),e}};IT.NAME=`Authority Key Identifier`;var LT=class extends aT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=V.parse(this.value,xv);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{let t=new xv({cA:e[0],pathLenConstraint:e[1]});super(bv,e[2],V.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e[`Path Length`]=this.pathLength),e}};LT.NAME=`Basic Constraints`;var RT;(function(e){e.serverAuth=`1.3.6.1.5.5.7.3.1`,e.clientAuth=`1.3.6.1.5.5.7.3.2`,e.codeSigning=`1.3.6.1.5.5.7.3.3`,e.emailProtection=`1.3.6.1.5.5.7.3.4`,e.timeStamping=`1.3.6.1.5.5.7.3.8`,e.ocspSigning=`1.3.6.1.5.5.7.3.9`})(RT||={});var zT=class extends aT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=V.parse(this.value,Qv);this.usages=t.map(e=>e)}else{let t=new Qv(e[0]);super(Zv,e[1],V.serialize(t)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=this.usages.map(e=>tT.toString(e)).join(`, `),e}};zT.NAME=`Extended Key Usages`;var BT;(function(e){e[e.digitalSignature=1]=`digitalSignature`,e[e.nonRepudiation=2]=`nonRepudiation`,e[e.keyEncipherment=4]=`keyEncipherment`,e[e.dataEncipherment=8]=`dataEncipherment`,e[e.keyAgreement=16]=`keyAgreement`,e[e.keyCertSign=32]=`keyCertSign`,e[e.cRLSign=64]=`cRLSign`,e[e.encipherOnly=128]=`encipherOnly`,e[e.decipherOnly=256]=`decipherOnly`})(BT||={});var VT=class extends aT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=V.parse(this.value,py);this.usages=t.toNumber()}else{let t=new py(e[0]);super(dy,e[1],V.serialize(t)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=V.parse(this.value,py).toJSON().join(`, `),e}};VT.NAME=`Key Usages`;var HT=class e extends aT{static async create(t,n=!1,r=cT.get()){let i=await(await PT.create(t,r)).getKeyIdentifier(r);return new e(M.Convert.ToHex(i),n)}constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=V.parse(this.value,ky);this.keyId=M.Convert.ToHex(t)}else{let t=typeof e[0]==`string`?M.Convert.FromHex(e[0]):e[0],n=new ky(t);super(Oy,e[1],V.serialize(n)),this.keyId=M.Convert.ToHex(t)}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=V.parse(this.value,ky),e}};HT.NAME=`Subject Key Identifier`;var UT=class extends aT{constructor(...e){M.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(Cy,e[1],new TT(e[0]||[]).rawData)}onInit(e){super.onInit(e);let t=V.parse(e.extnValue,wy);this.names=new TT(t)}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(let n in t)e[n]=t[n];return e}};UT.NAME=`Subject Alternative Name`;var WT=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new aT(e),n=this.items.get(t.type);return n?new n(e):t}};WT.items=new Map;var GT=class extends aT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=V.parse(this.value,Pv);this.policies=t.map(e=>e.policyIdentifier)}else{let t=e[0],n=e[1]??!1,r=new Pv(t.map(e=>new Nv({policyIdentifier:e})));super(Dv,n,V.serialize(r)),this.policies=t}}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(e=>new X(``,{},tT.toString(e))),e}};GT.NAME=`Certificate Policies`,WT.register(Dv,GT);var KT=class extends aT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]==`string`){let t=e[0].map(e=>new Hv({distributionPoint:new Vv({fullName:[new G({uniformResourceIdentifier:e})]})})),n=new Uv(t);super(Rv,e[1],V.serialize(n))}else{let t=new Uv(e[0]);super(Rv,e[1],V.serialize(t))}this.distributionPoints??=[]}onInit(e){super.onInit(e);let t=V.parse(e.extnValue,Uv);this.distributionPoints=t}toTextObject(){let e=this.toTextObjectWithoutValue();return e[`Distribution Point`]=this.distributionPoints.map(e=>{let t={};return e.distributionPoint&&(t[``]=e.distributionPoint.fullName?.map(e=>new wT(e).toString()).join(`, `)),e.reasons&&(t.Reasons=e.reasons.toString()),e.cRLIssuer&&(t[`CRL Issuer`]=e.cRLIssuer.map(e=>e.toString()).join(`, `)),t}),e}};KT.NAME=`CRL Distribution Points`;var qT=class extends aT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof gv){let t=new gv(e[0]);super(mv,e[1],V.serialize(t))}else{let t=e[0],n=new gv;YT(n,t,lv,`ocsp`),YT(n,t,uv,`caIssuers`),YT(n,t,dv,`timeStamping`),YT(n,t,fv,`caRepository`),super(mv,e[1],V.serialize(n))}this.ocsp??=[],this.caIssuers??=[],this.timeStamping??=[],this.caRepository??=[]}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],V.parse(e.extnValue,gv).forEach(e=>{switch(e.accessMethod){case lv:this.ocsp.push(new wT(e.accessLocation));break;case uv:this.caIssuers.push(new wT(e.accessLocation));break;case dv:this.timeStamping.push(new wT(e.accessLocation));break;case fv:this.caRepository.push(new wT(e.accessLocation));break}})}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ocsp.length&&JT(e,`OCSP`,this.ocsp),this.caIssuers.length&&JT(e,`CA Issuers`,this.caIssuers),this.timeStamping.length&&JT(e,`Time Stamping`,this.timeStamping),this.caRepository.length&&JT(e,`CA Repository`,this.caRepository),e}};qT.NAME=`Authority Info Access`;function JT(e,t,n){if(n.length===1)e[t]=n[0].toTextObject();else{let r=new X(``);n.forEach((e,t)=>{let n=e.toTextObject(),i=`${n[X.NAME]} ${t+1}`,a=r[i];Array.isArray(a)||(a=[],r[i]=a),a.push(n)}),e[t]=r}}function YT(e,t,n,r){let i=t[r];i&&(Array.isArray(i)?i:[i]).forEach(t=>{typeof t==`string`&&(t=new wT(`url`,t)),e.push(new hv({accessMethod:n,accessLocation:V.parse(t.rawData,G)}))})}var XT=class extends aT{constructor(...e){M.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(ly,e[1],new TT(e[0]||[]).rawData)}onInit(e){super.onInit(e);let t=V.parse(e.extnValue,Cv);this.names=new TT(t)}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(let n in t)e[n]=t[n];return e}};XT.NAME=`Issuer Alternative Name`;var ZT=class e extends iT{constructor(...e){let t;if(M.BufferSourceConverter.isBufferSource(e[0]))t=M.BufferSourceConverter.toArrayBuffer(e[0]);else{let n=e[0],r=Array.isArray(e[1])?e[1].map(e=>M.BufferSourceConverter.toArrayBuffer(e)):[];t=V.serialize(new Ty({type:n,values:r}))}super(t,Ty)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Value=this.values.map(e=>new X(``,{"":e})),e}toTextObjectWithoutValue(){let t=this.toTextObjectEmpty();return t[X.NAME]===e.NAME&&(t[X.NAME]=tT.toString(this.type)),t}};ZT.NAME=`Attribute`;var QT=class extends ZT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let t=new cw({printableString:e[0]});super(HC,[V.serialize(t)])}this.password??=``}onInit(e){if(super.onInit(e),this.values[0]){let e=V.parse(this.values[0],cw);this.password=e.toString()}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[X.VALUE]=this.password,e}};QT.NAME=`Challenge Password`;var $T=class extends ZT{constructor(...e){if(M.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let t=e[0],n=new Vy;for(let e of t)n.push(V.parse(e.rawData,By));super(UC,[V.serialize(n)])}this.items??=[]}onInit(e){if(super.onInit(e),this.values[0]){let e=V.parse(this.values[0],Vy);this.items=e.map(e=>WT.create(V.serialize(e)))}}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.items.map(e=>e.toTextObject());for(let n of t)e[n[X.NAME]]=n;return e}};$T.NAME=`Extensions`;var eE=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new ZT(e),n=this.items.get(t.type);return n?new n(e):t}};eE.items=new Map;var tE=`crypto.signatureFormatter`,nE=class{toAsnSignature(e,t){return M.BufferSourceConverter.toArrayBuffer(t)}toWebSignature(e,t){return M.BufferSourceConverter.toArrayBuffer(t)}},rE,iE=rE=class{static createPssParams(e,t){let n=rE.getHashAlgorithm(e);return n?new SS({hashAlgorithm:n,maskGenAlgorithm:new q({algorithm:gS,parameters:V.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){let t=oC.resolve(bw);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 Error(`Cannot get hash algorithm name`);switch(t.toLowerCase()){case`sha-1`:return new q({algorithm:eS,parameters:null});case`sha-256`:return new q({algorithm:nS,parameters:null});case`sha-384`:return new q({algorithm:rS,parameters:null});case`sha-512`:return new q({algorithm:iS,parameters:null})}}else return new q({algorithm:Jx,parameters:null});break;case`rsa-pss`:if(`hash`in e){if(!(`saltLength`in e&&typeof e.saltLength==`number`))throw Error(`Cannot get 'saltLength' from 'alg' argument`);let t=rE.createPssParams(e.hash,e.saltLength);if(!t)throw Error(`Cannot create PSS parameters`);return new q({algorithm:Zx,parameters:V.serialize(t)})}else return new q({algorithm:Zx,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Jx:return{name:`RSASSA-PKCS1-v1_5`};case eS:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-1`}};case nS:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-256`}};case rS:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-384`}};case iS:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-512`}};case Zx:if(e.parameters){let t=V.parse(e.parameters,SS);return{name:`RSA-PSS`,hash:oC.resolve(bw).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:`RSA-PSS`}}return null}};iE=rE=H([sC()],iE),oC.registerSingleton(vw,iE);var aE=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case`sha-1`:return new q({algorithm:sS});case`sha-256`:return new q({algorithm:lS});case`sha-384`:return new q({algorithm:uS});case`sha-512`:return new q({algorithm:dS})}return null}toWebAlgorithm(e){switch(e.algorithm){case sS:return{name:`SHA-1`};case lS:return{name:`SHA-256`};case uS:return{name:`SHA-384`};case dS:return{name:`SHA-512`}}return null}};aE=H([sC()],aE),oC.registerSingleton(vw,aE);var oE=class e{addPadding(e,t){let n=M.BufferSourceConverter.toUint8Array(t),r=new Uint8Array(e);return r.set(n,e-n.length),r.buffer}removePadding(e,t=!1){let n=M.BufferSourceConverter.toUint8Array(e);for(let e=0;e<n.length;e++)if(n[e]){n=n.slice(e);break}if(t&&n[0]>127){let e=new Uint8Array(n.length+1);return e.set(n,1),e.buffer}return n.buffer}toAsnSignature(t,n){if(t.name===`ECDSA`){let r=t.namedCurve,i=e.namedCurveSize.get(r)||e.defaultNamedCurveSize,a=new Kx,o=M.BufferSourceConverter.toUint8Array(n);return a.r=this.removePadding(o.slice(0,i),!0),a.s=this.removePadding(o.slice(i,i+i),!0),V.serialize(a)}return null}toWebSignature(t,n){if(t.name===`ECDSA`){let r=V.parse(n,Kx),i=t.namedCurve,a=e.namedCurveSize.get(i)||e.defaultNamedCurveSize;return(0,M.combine)(this.addPadding(a,this.removePadding(r.r)),this.addPadding(a,this.removePadding(r.s)))}return null}};oE.namedCurveSize=new Map,oE.defaultNamedCurveSize=32;var sE=`1.3.101.110`,cE=`1.3.101.111`,lE=`1.3.101.112`,uE=`1.3.101.113`,dE=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case`ed25519`:t=lE;break;case`x25519`:t=sE;break;case`eddsa`:switch(e.namedCurve.toLowerCase()){case`ed25519`:t=lE;break;case`ed448`:t=uE;break}break;case`ecdh-es`:switch(e.namedCurve.toLowerCase()){case`x25519`:t=sE;break;case`x448`:t=cE;break}}return t?new q({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case lE:return{name:`Ed25519`};case uE:return{name:`EdDSA`,namedCurve:`Ed448`};case sE:return{name:`X25519`};case cE:return{name:`ECDH-ES`,namedCurve:`X448`}}return null}};dE=H([sC()],dE),oC.registerSingleton(vw,dE);var fE,pE,mE,hE,gE,_E,vE,yE,bE=class extends NT{get subjectName(){return U(this,pE,`f`)||W(this,pE,new hT(this.asn.certificationRequestInfo.subject),`f`),U(this,pE,`f`)}get subject(){return U(this,mE,`f`)||W(this,mE,this.subjectName.toString(),`f`),U(this,mE,`f`)}get signatureAlgorithm(){if(!U(this,hE,`f`)){let e=oC.resolve(bw);W(this,hE,e.toWebAlgorithm(this.asn.signatureAlgorithm),`f`)}return U(this,hE,`f`)}get signature(){return U(this,gE,`f`)||W(this,gE,this.asn.signature,`f`),U(this,gE,`f`)}get publicKey(){return U(this,_E,`f`)||W(this,_E,new PT(this.asn.certificationRequestInfo.subjectPKInfo),`f`),U(this,_E,`f`)}get attributes(){return U(this,vE,`f`)||W(this,vE,this.asn.certificationRequestInfo.attributes.map(e=>eE.create(V.serialize(e))),`f`),U(this,vE,`f`)}get extensions(){if(!U(this,yE,`f`)){W(this,yE,[],`f`);let e=this.getAttribute(UC);e instanceof $T&&W(this,yE,e.items,`f`)}return U(this,yE,`f`)}get tbs(){return U(this,fE,`f`)||W(this,fE,this.asn.certificationRequestInfoRaw||V.serialize(this.asn.certificationRequestInfo),`f`),U(this,fE,`f`)}constructor(e){let t=NT.isAsnEncoded(e)?[e,_w]:[e];super(t[0],t[1]),fE.set(this,void 0),pE.set(this,void 0),mE.set(this,void 0),hE.set(this,void 0),gE.set(this,void 0),_E.set(this,void 0),vE.set(this,void 0),yE.set(this,void 0),this.tag=MT.CertificateRequestTag}onInit(e){}getAttribute(e){for(let 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(let 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=cT.get()){let t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,[`verify`],e),r=oC.resolveAll(tE).reverse(),i=null;for(let e of r)if(i=e.toWebSignature(t,this.signature),i)break;if(!i)throw Error(`Cannot convert WebCrypto signature value to ASN.1 format`);return await e.subtle.verify(this.signatureAlgorithm,n,i,this.tbs)}toTextObject(){let e=this.toTextObjectEmpty(),t=V.parse(this.rawData,_w),n=t.certificationRequestInfo,r=new X(``,{Version:`${Hy[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){let e=new X(``);for(let t of this.attributes){let n=t.toTextObject();e[n[X.NAME]]=n}r.Attributes=e}return e.Data=r,e.Signature=new X(``,{Algorithm:nT.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}};fE=new WeakMap,pE=new WeakMap,mE=new WeakMap,hE=new WeakMap,gE=new WeakMap,_E=new WeakMap,vE=new WeakMap,yE=new WeakMap,bE.NAME=`PKCS#10 Certificate Request`;var xE,SE,CE,wE,TE,EE,DE,OE,kE,AE,jE,ME,NE=class extends NT{get publicKey(){return U(this,ME,`f`)||W(this,ME,new PT(this.asn.tbsCertificate.subjectPublicKeyInfo),`f`),U(this,ME,`f`)}get serialNumber(){if(!U(this,SE,`f`)){let e=this.asn.tbsCertificate,t=new Uint8Array(e.serialNumber);t.length>1&&t[0]===0&&t[1]>127&&(t=t.slice(1)),W(this,SE,M.Convert.ToHex(t),`f`)}return U(this,SE,`f`)}get subjectName(){return U(this,CE,`f`)||W(this,CE,new hT(this.asn.tbsCertificate.subject),`f`),U(this,CE,`f`)}get subject(){return U(this,wE,`f`)||W(this,wE,this.subjectName.toString(),`f`),U(this,wE,`f`)}get issuerName(){return U(this,TE,`f`)||W(this,TE,new hT(this.asn.tbsCertificate.issuer),`f`),U(this,TE,`f`)}get issuer(){return U(this,EE,`f`)||W(this,EE,this.issuerName.toString(),`f`),U(this,EE,`f`)}get notBefore(){if(!U(this,DE,`f`)){let e=this.asn.tbsCertificate.validity.notBefore.utcTime||this.asn.tbsCertificate.validity.notBefore.generalTime;if(!e)throw Error(`Cannot get 'notBefore' value`);W(this,DE,e,`f`)}return U(this,DE,`f`)}get notAfter(){if(!U(this,OE,`f`)){let e=this.asn.tbsCertificate.validity.notAfter.utcTime||this.asn.tbsCertificate.validity.notAfter.generalTime;if(!e)throw Error(`Cannot get 'notAfter' value`);W(this,OE,e,`f`)}return U(this,OE,`f`)}get signatureAlgorithm(){if(!U(this,kE,`f`)){let e=oC.resolve(bw);W(this,kE,e.toWebAlgorithm(this.asn.signatureAlgorithm),`f`)}return U(this,kE,`f`)}get signature(){return U(this,AE,`f`)||W(this,AE,this.asn.signatureValue,`f`),U(this,AE,`f`)}get extensions(){return U(this,jE,`f`)||(W(this,jE,[],`f`),this.asn.tbsCertificate.extensions&&W(this,jE,this.asn.tbsCertificate.extensions.map(e=>WT.create(V.serialize(e))),`f`)),U(this,jE,`f`)}get tbs(){return U(this,xE,`f`)||W(this,xE,this.asn.tbsCertificateRaw||V.serialize(this.asn.tbsCertificate),`f`),U(this,xE,`f`)}constructor(e){let t=NT.isAsnEncoded(e)?[e,Wy]:[e];super(t[0],t[1]),xE.set(this,void 0),SE.set(this,void 0),CE.set(this,void 0),wE.set(this,void 0),TE.set(this,void 0),EE.set(this,void 0),DE.set(this,void 0),OE.set(this,void 0),kE.set(this,void 0),AE.set(this,void 0),jE.set(this,void 0),ME.set(this,void 0),this.tag=MT.CertificateTag}onInit(e){}getExtension(e){for(let 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=cT.get()){let n,r,i=e.publicKey;try{if(!i)n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,[`verify`],t);else if(`publicKey`in i)n={...i.publicKey.algorithm,...this.signatureAlgorithm},r=await i.publicKey.export(n,[`verify`],t);else if(i instanceof PT)n={...i.algorithm,...this.signatureAlgorithm},r=await i.export(n,[`verify`],t);else if(M.BufferSourceConverter.isBufferSource(i)){let e=new PT(i);n={...e.algorithm,...this.signatureAlgorithm},r=await e.export(n,[`verify`],t)}else n={...i.algorithm,...this.signatureAlgorithm},r=i}catch{return!1}let a=oC.resolveAll(tE).reverse(),o=null;for(let e of a)if(o=e.toWebSignature(n,this.signature),o)break;if(!o)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);let s=await t.subtle.verify(this.signatureAlgorithm,r,o,this.tbs);if(e.signatureOnly)return s;{let t=(e.date||new Date).getTime();return s&&this.notBefore.getTime()<t&&t<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??=cT.get(),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=cT.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){let e=this.toTextObjectEmpty(),t=V.parse(this.rawData,Wy),n=t.tbsCertificate,r=new X(``,{Version:`${Hy[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":nT.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new X(``,{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(r[`Issuer Unique ID`]=n.issuerUniqueID),n.subjectUniqueID&&(r[`Subject Unique ID`]=n.subjectUniqueID),this.extensions.length){let e=new X(``);for(let t of this.extensions){let n=t.toTextObject();e[n[X.NAME]]=n}r.Extensions=e}return e.Data=r,e.Signature=new X(``,{Algorithm:nT.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}};xE=new WeakMap,SE=new WeakMap,CE=new WeakMap,wE=new WeakMap,TE=new WeakMap,EE=new WeakMap,DE=new WeakMap,OE=new WeakMap,kE=new WeakMap,AE=new WeakMap,jE=new WeakMap,ME=new WeakMap,NE.NAME=`Certificate`;function PE(e,t=cT.get()){let n=M.BufferSourceConverter.toUint8Array(M.Convert.FromHex(e||``)),r=n&&n.length&&n.some(e=>e>0)?new Uint8Array(n):void 0;r||=t.getRandomValues(new Uint8Array(16));let i=0;for(;i<r.length-1&&r[i]===0;)i++;if(r=r.slice(i),r[0]>127){let e=new Uint8Array(r.length+1);e[0]=0,e.set(r,1),r=e}return r.buffer}var FE=class{static async createSelfSigned(e,t=cT.get()){if(!e.keys.privateKey)throw Error(`Bad field 'keys' in 'params' argument. 'privateKey' is empty`);if(!e.keys.publicKey)throw Error(`Bad field 'keys' in 'params' argument. 'publicKey' is empty`);return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,t=cT.get()){let n;n=e.publicKey instanceof PT?e.publicKey.rawData:`publicKey`in e.publicKey?e.publicKey.publicKey.rawData:M.BufferSourceConverter.isBufferSource(e.publicKey)?e.publicKey:await t.subtle.exportKey(`spki`,e.publicKey);let r=PE(e.serialNumber,t),i=e.notBefore||new Date,a=e.notAfter||new Date(i.getTime()+31536e6),o=new Wy({tbsCertificate:new Uy({version:Hy.v3,serialNumber:r,validity:new Ry({notBefore:i,notAfter:a}),extensions:new Vy(e.extensions?.map(e=>V.parse(e.rawData,By))||[]),subjectPublicKeyInfo:V.parse(n,Iy)})});if(e.subject){let t=e.subject instanceof hT?e.subject:new hT(e.subject);o.tbsCertificate.subject=V.parse(t.toArrayBuffer(),ev)}if(e.issuer){let t=e.issuer instanceof hT?e.issuer:new hT(e.issuer);o.tbsCertificate.issuer=V.parse(t.toArrayBuffer(),ev)}let s={hash:`SHA-256`},c=`signingKey`in e?{...s,...e.signingAlgorithm,...e.signingKey.algorithm}:{...s,...e.signingAlgorithm},l=oC.resolve(bw);o.tbsCertificate.signature=o.signatureAlgorithm=l.toAsnAlgorithm(c);let u=V.serialize(o.tbsCertificate),d=`signingKey`in e?await t.subtle.sign(c,e.signingKey,u):e.signature,f=oC.resolveAll(tE).reverse(),p=null;for(let e of f)if(p=e.toAsnSignature(c,d),p)break;if(!p)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return o.signatureValue=p,new NE(V.serialize(o))}},IE,LE,RE,zE,BE,VE;(function(e){e[e.unspecified=0]=`unspecified`,e[e.keyCompromise=1]=`keyCompromise`,e[e.cACompromise=2]=`cACompromise`,e[e.affiliationChanged=3]=`affiliationChanged`,e[e.superseded=4]=`superseded`,e[e.cessationOfOperation=5]=`cessationOfOperation`,e[e.certificateHold=6]=`certificateHold`,e[e.removeFromCRL=8]=`removeFromCRL`,e[e.privilegeWithdrawn=9]=`privilegeWithdrawn`,e[e.aACompromise=10]=`aACompromise`})(VE||={});var HE=class extends iT{get serialNumber(){return U(this,IE,`f`)||W(this,IE,M.Convert.ToHex(this.asn.userCertificate),`f`),U(this,IE,`f`)}get revocationDate(){return U(this,LE,`f`)||W(this,LE,this.asn.revocationDate.getTime(),`f`),U(this,LE,`f`)}get reason(){return U(this,RE,`f`)===void 0&&this.extensions,U(this,RE,`f`)}get invalidity(){return U(this,zE,`f`)===void 0&&this.extensions,U(this,zE,`f`)}get extensions(){return U(this,BE,`f`)||(W(this,BE,[],`f`),this.asn.crlEntryExtensions&&W(this,BE,this.asn.crlEntryExtensions.map(e=>{let t=WT.create(V.serialize(e));switch(t.type){case qv:U(this,RE,`f`)===void 0&&W(this,RE,V.parse(t.value,Yv).reason,`f`);break;case oy:U(this,zE,`f`)===void 0&&W(this,zE,V.parse(t.value,sy).value,`f`);break}return t}),`f`)),U(this,BE,`f`)}constructor(...e){let t;if(M.BufferSourceConverter.isBufferSource(e[0])?t=M.BufferSourceConverter.toArrayBuffer(e[0]):typeof e[0]==`string`?t=V.serialize(new Gy({userCertificate:PE(e[0]),revocationDate:new Ly(e[1]),crlEntryExtensions:e[2]})):e[0]instanceof Gy&&(t=e[0]),!t)throw TypeError(`Cannot create X509CrlEntry instance. Wrong constructor arguments.`);super(t,Gy),IE.set(this,void 0),LE.set(this,void 0),RE.set(this,void 0),zE.set(this,void 0),BE.set(this,void 0)}onInit(e){}};IE=new WeakMap,LE=new WeakMap,RE=new WeakMap,zE=new WeakMap,BE=new WeakMap;var UE,WE,GE,KE,qE,JE,YE,XE=class extends NT{get version(){return this.asn.tbsCertList.version}get signatureAlgorithm(){if(!U(this,WE,`f`)){let e=oC.resolve(bw);W(this,WE,e.toWebAlgorithm(this.asn.signatureAlgorithm),`f`)}return U(this,WE,`f`)}get signature(){return this.asn.signature}get issuer(){return this.issuerName.toString()}get issuerName(){return U(this,GE,`f`)||W(this,GE,new hT(this.asn.tbsCertList.issuer),`f`),U(this,GE,`f`)}get thisUpdate(){if(!U(this,KE,`f`)){let e=this.asn.tbsCertList.thisUpdate.getTime();if(!e)throw Error(`Cannot get 'thisUpdate' value`);W(this,KE,e,`f`)}return U(this,KE,`f`)}get nextUpdate(){return U(this,qE,`f`)===void 0&&W(this,qE,this.asn.tbsCertList.nextUpdate?.getTime()||void 0,`f`),U(this,qE,`f`)}get entries(){return U(this,JE,`f`)||W(this,JE,this.asn.tbsCertList.revokedCertificates?.map(e=>new HE(e))||[],`f`),U(this,JE,`f`)}get extensions(){return U(this,YE,`f`)||(W(this,YE,[],`f`),this.asn.tbsCertList.crlExtensions&&W(this,YE,this.asn.tbsCertList.crlExtensions.map(e=>WT.create(V.serialize(e))),`f`)),U(this,YE,`f`)}get tbs(){return U(this,UE,`f`)||W(this,UE,this.asn.tbsCertListRaw||V.serialize(this.asn.tbsCertList),`f`),U(this,UE,`f`)}get tbsCertListSignatureAlgorithm(){return this.asn.tbsCertList.signature}get certListSignatureAlgorithm(){return this.asn.signatureAlgorithm}constructor(e){super(e,NT.isAsnEncoded(e)?qy:void 0),this.tag=MT.CrlTag,UE.set(this,void 0),WE.set(this,void 0),GE.set(this,void 0),KE.set(this,void 0),qE.set(this,void 0),JE.set(this,void 0),YE.set(this,void 0)}onInit(e){}getExtension(e){for(let 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=cT.get()){if(!this.certListSignatureAlgorithm.isEqual(this.tbsCertListSignatureAlgorithm))throw Error(`algorithm identifier in the sequence tbsCertList and CertificateList mismatch`);let n,r,i=e.publicKey;try{i instanceof NE?(n={...i.publicKey.algorithm,...i.signatureAlgorithm},r=await i.publicKey.export(n,[`verify`])):i instanceof PT?(n={...i.algorithm,...this.signatureAlgorithm},r=await i.export(n,[`verify`])):(n={...i.algorithm,...this.signatureAlgorithm},r=i)}catch{return!1}let a=oC.resolveAll(tE).reverse(),o=null;for(let e of a)if(o=e.toWebSignature(n,this.signature),o)break;if(!o)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return await t.subtle.verify(this.signatureAlgorithm,r,o,this.tbs)}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??=cT.get(),await t.subtle.digest(n,this.rawData)}findRevoked(e){let t=PE(typeof e==`string`?e:e.serialNumber);for(let e of this.asn.tbsCertList.revokedCertificates||[])if(M.BufferSourceConverter.isEqual(e.userCertificate,t))return new HE(V.serialize(e));return null}};UE=new WeakMap,WE=new WeakMap,GE=new WeakMap,KE=new WeakMap,qE=new WeakMap,JE=new WeakMap,YE=new WeakMap,WT.register(bv,LT),WT.register(Zv,zT),WT.register(dy,VT),WT.register(Oy,HT),WT.register(_v,IT),WT.register(Cy,UT),WT.register(Rv,KT),WT.register(mv,qT),WT.register(ly,XT),eE.register(HC,QT),eE.register(UC,$T),oC.registerSingleton(tE,nE),oC.registerSingleton(tE,oE),oE.namedCurveSize.set(`P-256`,32),oE.namedCurveSize.set(`K-256`,32),oE.namedCurveSize.set(`P-384`,48),oE.namedCurveSize.set(`P-521`,66);var ZE={"P-256":`ES256`,"P-384":`ES384`,"P-521":`ES512`},QE={RS256:`SHA-256`,RS384:`SHA-384`,RS512:`SHA-512`},$E=new Set([`RS256`,`RS384`,`RS512`,`ES256`,`ES384`,`ES512`]);function eD(e){return typeof e==`string`&&$E.has(e)}function tD(e){if(eD(e.alg)){if(e.kty===`RSA`&&e.alg.startsWith(`RS`))return e.alg;if(e.kty===`EC`&&e.alg.startsWith(`ES`)){let t=e.crv&&e.crv in ZE?ZE[e.crv]:void 0;if(t&&t!==e.alg)throw Error(`EC alg/curve mismatch: curve ${e.crv} requires ${t}, got ${e.alg}`);return e.alg}}if(e.kty===`RSA`)return`RS256`;if(e.kty===`EC`){if(!e.crv||!(e.crv in ZE))throw Error(`Unsupported EC curve: ${e.crv??`(missing)`}`);return ZE[e.crv]}throw Error(`Unsupported JWK kty: ${e.kty}`)}function nD(e,t){if(e.kty===`RSA`){let e=QE[t];if(!e)throw Error(`Unsupported RSA alg: ${t}`);return{name:`RSASSA-PKCS1-v1_5`,hash:e}}if(e.kty===`EC`){if(!e.crv||!(e.crv in ZE))throw Error(`Unsupported EC curve: ${e.crv??`(missing)`}`);let n=ZE[e.crv];if(t!==n)throw Error(`EC alg/curve mismatch: curve ${e.crv} requires ${n}, got ${t}`);return{name:`ECDSA`,namedCurve:e.crv}}throw Error(`Unsupported JWK kty: ${e.kty}`)}var rD=[`RS256`,`ES256`,`ES384`,`ES512`];async function iD(e){let t=await new NE(e).publicKey.export();return tD(await crypto.subtle.exportKey(`jwk`,t))}function aD(e){try{let t=/-----BEGIN (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----([^-]*)-----END (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----/.exec(e);if(!t||!t[1])throw Error(`Invalid PEM format`);return Uint8Array.from(atob(t[1].replace(/\s/g,``)),e=>e.charCodeAt(0)).buffer}finally{e=e.replace(/./g,`\0`)}}function oD(){return Ds(crypto.getRandomValues(new Uint8Array(32)))}async function sD(e,t){if(t===`plain`)return e;let n=new TextEncoder().encode(e),r=await crypto.subtle.digest(`SHA-256`,n);return Ds(new Uint8Array(r))}var cD={RSA:[`e`,`kty`,`n`],EC:[`crv`,`kty`,`x`,`y`],oct:[`k`,`kty`],OKP:[`crv`,`kty`,`x`]};function lD(e){switch(e){case`RSA`:return{name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`,publicExponent:new Uint8Array([1,0,1]),modulusLength:2048};case`EC-P-256`:return{name:`ECDSA`,namedCurve:`P-256`};case`EC-P-384`:return{name:`ECDSA`,namedCurve:`P-384`};case`EC-P-521`:return{name:`ECDSA`,namedCurve:`P-521`}}}function uD(e){switch(e){case`RSA`:return{name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`,publicExponent:new Uint8Array([1,0,1]),modulusLength:2048};case`EC-P-256`:return{name:`ECDSA`,hash:`SHA-256`};case`EC-P-384`:return{name:`ECDSA`,hash:`SHA-384`};case`EC-P-521`:return{name:`ECDSA`,hash:`SHA-512`}}}var dD=1440*60*1e3,fD=3650;function pD(e){let t=e??365;if(!Number.isFinite(t)||t<1||t>3650)throw Error(`validityDays must be between 1 and ${fD}`);return new Date(Date.now()+t*dD)}async function mD(e){let t=e.keyType??`RSA`;if(t===`EC-P-521`&&(0,m.getRuntimeKey)()===`workerd`)throw Error(`EC-P-521 signing keys are not supported on Cloudflare Workers: workerd's WebCrypto implementation cannot generate the P-521 curve. Use RSA, EC-P-256, or EC-P-384 instead.`);let n=await crypto.subtle.generateKey(lD(t),!0,[`sign`,`verify`]),r=Yl(),i=Is(new TextEncoder().encode(r)),a=e.certificateAuthority?await bD(e.certificateAuthority,{publicKey:n.publicKey,name:e.name,validityDays:e.validityDays}):await FE.createSelfSigned({serialNumber:i,name:e.name,notBefore:new Date,notAfter:pD(e.validityDays),signingAlgorithm:uD(t),keys:n,extensions:[new LT(!0,2,!0),new zT([`1.3.6.1.5.5.7.3.1`],!0),new VT(BT.keyCertSign|BT.cRLSign,!0),await HT.create(n.publicKey)]}),o=await crypto.subtle.exportKey(`pkcs8`,n.privateKey),s=a.toString(`pem`),c=await SD(a);return{kid:c,cert:s,thumbprint:Is(await a.getThumbprint()),fingerprint:c,pkcs7:xD(`PRIVATE`,o),type:`jwt_signing`}}var hD=[`RSA`,`EC-P-256`,`EC-P-384`,`EC-P-521`];async function gD(e){let t=aD(e);for(let e of hD)try{return{key:await crypto.subtle.importKey(`pkcs8`,t,lD(e),!0,[`sign`]),keyType:e}}catch{}throw Error(`Unable to import the private key: not a supported RSA or EC key`)}function _D(e){let t=(e,t)=>{if(!e)throw Error(`JWK is missing required member '${t}'`);return e};switch(e.kty){case`RSA`:return{kty:`RSA`,n:t(e.n,`n`),e:t(e.e,`e`)};case`EC`:return{kty:`EC`,crv:t(e.crv,`crv`),x:t(e.x,`x`),y:t(e.y,`y`)};case`OKP`:return{kty:`OKP`,crv:t(e.crv,`crv`),x:t(e.x,`x`)};default:throw Error(`Unsupported JWK kty: ${e.kty}`)}}async function vD(e){let t=new NE(e.cert),{key:n,keyType:r}=await gD(e.pkcs7),i=_D(await crypto.subtle.exportKey(`jwk`,n)),a=await crypto.subtle.importKey(`jwk`,i,lD(r),!0,[`verify`]),o=await CD(i);if(o!==await SD(t))throw Error(`The stored private key does not match the stored certificate`);let s=Is(new TextEncoder().encode(Yl())),c=e.name||t.subject,l=e.certificateAuthority?await bD(e.certificateAuthority,{publicKey:a,name:c,validityDays:e.validityDays}):await FE.createSelfSigned({serialNumber:s,name:c,notBefore:new Date,notAfter:pD(e.validityDays),signingAlgorithm:uD(r),keys:{privateKey:n,publicKey:a},extensions:[new LT(!0,2,!0),new zT([`1.3.6.1.5.5.7.3.1`],!0),new VT(BT.keyCertSign|BT.cRLSign,!0),await HT.create(a)]});return{cert:l.toString(`pem`),thumbprint:Is(await l.getThumbprint()),fingerprint:o}}var yD=300*1e3;async function bD(e,t){let n=await crypto.subtle.exportKey(`spki`,t.publicKey),r=new Date,i=pD(t.validityDays),a=new NE(await e.issuer.issueCertificate({publicKey:xD(`PUBLIC`,n),subject:t.name,uri:e.uri,notBefore:r,notAfter:i})),o=a.getExtension(UT)?.names.items.filter(e=>e.type===`url`).map(e=>e.value)??[];if(o.length!==1||o[0]!==e.uri)throw Error(`The certificate authority returned a certificate for a different owner: expected SAN URI ${e.uri}`);if(a.getExtension(LT)?.ca)throw Error(`The certificate authority returned a CA certificate for a signing key`);let s=a.getExtension(VT)?.usages;if(s!==void 0&&(!(s&BT.digitalSignature)||s&(BT.keyCertSign|BT.cRLSign)))throw Error(`The certificate authority returned a certificate whose key usage doesn't permit signing tokens`);if(a.notBefore.getTime()<r.getTime()-yD||a.notAfter.getTime()>i.getTime()+yD||a.notAfter.getTime()<=Date.now())throw Error(`The certificate authority returned a certificate outside the requested validity window`);let c=CD(await crypto.subtle.exportKey(`jwk`,t.publicKey));if(await SD(a)!==await c)throw Error(`The certificate authority returned a certificate for a different key`);return a}function xD(e,t){let n=js(new Uint8Array(t)),r=`-----BEGIN ${e} KEY-----\r\n`,i=0;for(;i<n.length;)i+64<=n.length?r+=n.substr(i,64)+`\r
303
303
  `:r+=n.substr(i)+`\r
304
- `,i+=64;return r+=`-----END ${e} KEY-----\r\n`,r}async function xD(e){let t=await e.publicKey.export();return SD(await crypto.subtle.exportKey(`jwk`,t))}async function SD(e){if(!e.kty)throw Error(`JWK is missing required 'kty' member`);let t=sD[e.kty];if(!t)throw Error(`Unsupported JWK kty for thumbprint: ${e.kty}`);let n={};for(let r of t){let t=e[r];if(typeof t!=`string`||t.length===0)throw Error(`JWK is missing required member '${r}' for kty=${e.kty}`);n[r]=t}let r=JSON.stringify(n),i=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(r));return Ds(new Uint8Array(i))}var CD=30,wD=`urn:authhero:tenant:`,TD=`urn:authhero:control-plane`;function ED({tenant_id:e}){return e?`${wD}${e}`:TD}function DD(e,t){if(!e||t.type!==`jwt_signing`)return;let n=e.subjectUri??ED;return{issuer:e.issuer,uri:n({tenant_id:t.tenant_id})}}function OD(e){let t=new ME(e.certificate),n=hD(e.privateKey);return{async issueCertificate(e){let{key:r,keyType:i}=await n,a=new NT(e.publicKey),o=await a.export();return(await PE.create({serialNumber:kD(),subject:e.subject,issuer:t.subject,notBefore:e.notBefore,notAfter:e.notAfter,signingAlgorithm:lD(i),publicKey:a,signingKey:r,extensions:[new IT(!1,void 0,!0),new BT(zT.digitalSignature,!0),new HT([{type:`url`,value:e.uri}]),await VT.create(o),await FT.create(t.publicKey)]})).toString(`pem`)},async getIssuerCertificates(){return[e.certificate,...e.previousCertificates??[]]}}}function kD(){let e=crypto.getRandomValues(new Uint8Array(16));return e[0]=(e[0]??0)&127,Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}function AD(e){return e.issuer!==e.subject}async function jD(e,t){if(AD(e))for(let n of t){if(n.subject!==e.issuer||!await e.verify({publicKey:n.publicKey,signatureOnly:!0}))continue;let t=new Uint8Array(e.rawData),r=await crypto.subtle.digest(`SHA-256`,t);return{x5c:[js(t),js(new Uint8Array(n.rawData))],"x5t#S256":Ds(new Uint8Array(r))}}}function MD(e){let t=new Date;return e.filter(e=>!e.revoked_at||new Date(e.revoked_at)>t).sort((e,t)=>{let n=e.current_since?new Date(e.current_since).getTime():0,r=t.current_since?new Date(t.current_since).getTime():0;return r===n?t.kid.localeCompare(e.kid):r-n})}var ND=/^[A-Za-z0-9._-]+$/;function PD(e,t){if(!ND.test(e))throw Error(`Invalid ${t}: must match ${ND}`)}var FD=1e3;async function ID(e,t,n){PD(t,`tenant_id`),PD(n,`type`);let{signingKeys:r}=await e.list({q:`type:${n} AND tenant_id:${t}`,sort:{sort_by:`created_at`,sort_order:`desc`},per_page:FD});return MD(r)}async function LD(e,t=`jwt_signing`){PD(t,`type`);let{signingKeys:n}=await e.list({q:`type:${t} AND -_exists_:tenant_id`,sort:{sort_by:`created_at`,sort_order:`desc`},per_page:FD});return MD(n)}async function RD(e,t){return e?typeof e==`string`?e:e({tenant_id:t}):`control-plane`}function zD(e,t){return t===`saml_encryption`?`tenant`:e}async function BD(e,t,n,r){let i=r.type??`jwt_signing`;if(zD(await RD(n,t),i)===`control-plane`){let t=await LD(e,i);if(r.purpose===`sign`){let e=t.find(UD);return e?[e]:[]}return t}let[a,o]=await Promise.all([ID(e,t,i),LD(e,i)]);if(r.purpose===`sign`){let e=a.find(UD)??o.find(UD);return e?[e]:[]}let s=new Set,c=[];for(let e of[...a,...o])s.has(e.kid)||(s.add(e.kid),c.push(e));return c}function VD(e){return!!(e.pkcs7&&e.cert)}function HD(e,t=new Date){return!!(e.current_since&&new Date(e.current_since)>t)}function UD(e){return VD(e)&&!HD(e)}async function WD(e,t={}){let n=t.type??`jwt_signing`,r=(t.tenantId?await ID(e,t.tenantId,n):await LD(e,n)).find(UD);if(r)return{created:!1,key:r};let i=DD(t.certificateAuthority,{type:n,tenant_id:t.tenantId}),a={...await pD({name:`CN=${t.name||t.tenantId||`authhero`}`,certificateAuthority:i,...i?{validityDays:t.certificateAuthority?.validityDays??30}:{}}),type:n,current_since:new Date().toISOString(),...t.tenantId?{tenant_id:t.tenantId}:{}};return await e.create(a),{created:!0,key:a}}async function GD(e,t){let n,r=()=>(n??=t?t.getIssuerCertificates().then(e=>e.map(e=>new ME(e))).catch(e=>(console.warn(`[authhero] could not load signing CA certificates; publishing JWKS without x5c`,e),[])):Promise.resolve([]),n);return Promise.all(e.map(async e=>{let t=new ME(e.cert),n=await t.publicKey.export(),i=await crypto.subtle.exportKey(`jwk`,n),a=i.alg??eD(i),o=AD(t)?await jD(t,await r()):void 0;return Dr.parse({...i,alg:a,use:`sig`,kid:e.kid,...o})}))}async function KD(e,t,n,r){return GD(await BD(e.keys,t,n,{purpose:`publish`}),r)}async function qD(e,t,n){return t?KD(e,t,n):GD(await LD(e.keys))}var JD={ES256:`P-256`,ES384:`P-384`,ES512:`P-521`};function YD(e){if(!(e instanceof Uint8Array))return e;let t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(e),t}function XD(e){return`SHA-${e.slice(2)}`}async function ZD(e,t){let n=YD(t);if(e.startsWith(`HS`))return crypto.subtle.importKey(`raw`,n,{name:`HMAC`,hash:XD(e)},!1,[`sign`]);if(e.startsWith(`RS`))return crypto.subtle.importKey(`pkcs8`,n,{name:`RSASSA-PKCS1-v1_5`,hash:XD(e)},!1,[`sign`]);let r=JD[e];if(!r)throw Error(`Unsupported JWT signing alg: ${e}`);return crypto.subtle.importKey(`pkcs8`,n,{name:`ECDSA`,namedCurve:r},!1,[`sign`])}async function QD(e,t,n,r={}){let i={alg:e,typ:`JWT`,...r.headers},a={...n};r.expiresInSeconds!==void 0&&(a.exp=Math.floor(Date.now()/1e3)+r.expiresInSeconds),r.includeIssuedTimestamp===!0&&(a.iat=Math.floor(Date.now()/1e3));let o=new TextEncoder,s=Ds(o.encode(JSON.stringify(i))),c=Ds(o.encode(JSON.stringify(a))),l=o.encode(`${s}.${c}`),u=await ZD(e,t),d=await crypto.subtle.sign(e.startsWith(`ES`)?{name:`ECDSA`,hash:XD(e)}:u.algorithm.name,u,l);return`${s}.${c}.${Ds(new Uint8Array(d))}`}function $D(e){try{let{header:t,payload:n}=(0,h.decode)(e);return typeof t!=`object`||!t||typeof n!=`object`||!n?null:{header:t,payload:n}}catch{return null}}function eO(e){switch(e){case`RS256`:case`RS384`:case`RS512`:case`ES256`:case`ES384`:case`ES512`:return e;default:throw new k(401,{message:`Unsupported JWS alg: ${e??`(missing)`}`})}}var tO=class extends k{constructor(){super(403,{message:`Invalid JWT signature`}),this.name=`JwtExpiredError`}};async function nO(e,t,n={}){try{let{header:r}=(0,h.decode)(t),i=eO(r?.alg),a=(await qD(e.env.data,n.tenantId??e.var.tenant_id,e.env.signingKeyMode)).find(e=>e.kid===r.kid);if(!a)throw new k(401,{message:`No matching kid found`});if(a.alg!==i)throw new k(401,{message:`alg mismatch between token header and JWK`});let o=tD(a,i),s=await(0,h.verify)(t,await crypto.subtle.importKey(`jwk`,a,o,!1,[`verify`]),i);if(!n.skipIssuerCheck){let t=Cc(e.env,e.var.custom_domain),r=n.additionalIssuers??[];if(s.iss!==t&&!r.includes(s.iss))throw new k(401,{message:`Invalid issuer`})}return s}catch(e){throw e instanceof p.HTTPException?e:e instanceof Error&&e.name===`JwtTokenExpired`?new tO:new k(403,{message:`Invalid JWT signature`})}}var rO=[`iss`,`sub`,`aud`,`exp`,`nbf`,`iat`,`jti`],iO=[`client_id`,`azp`,`scope`,`auth_time`,`acr`,`amr`,`act`,`sid`,`permissions`,`tenant_id`,`org_id`,`org_name`,`requested_userinfo_claims`,`gty`],aO=[`nonce`,`at_hash`,`c_hash`,`s_hash`],oO=[...rO,...iO],sO={access_token:oO,id_token:[...oO,...aO],userinfo:[...rO],service_token:oO.filter(e=>e!==`azp`),client_service_token:[...oO]};function cO(e,t,n={}){return e===`azp`&&n.allowAzpOverride?!1:sO[t].includes(e)}function lO(e,t,n,r){let i=r.ctx?.env?.unsafeAllowAzpCustomClaim===!0;return cO(t,r.kind,{allowAzpOverride:i})?(dO(t,r),!1):(e[t]=n,!0)}function uO(e,t){if(!e)return;let n={};for(let[r,i]of Object.entries(e))lO(n,r,i,t);return n}function dO(e,t){let n=`Dropped custom claim '${e}' from ${t.kind}: the claim name is reserved by the authorization server (set by ${t.source})`,r=t.ctx,i=t.tenantId??r?.var.tenant_id;if(r&&i){O(r,i,{type:E.WARNING_DURING_LOGIN,description:n}).catch(()=>{});return}console.warn(`[reserved-claims] ${n}`)}var fO=`auth-service`,pO=3600;async function mO(e){let{tenants:t,keys:n,tenantId:r,scope:i,issuer:a}=e,o=await t.get(r);if(!o)throw Error(`Tenant not found: ${r}`);let s=e.audience??o.audience;if(!s)throw Error(`Cannot mint service token: tenant "${r}" has no default audience`);let c=uO(e.customClaims,{kind:`service_token`,source:`createServiceToken(customClaims)`,tenantId:r}),l=(await BD(n,r,e.signingKeyMode,{purpose:`sign`}))[0];if(!l?.pkcs7||!l.cert)throw Error(`No signing key available`);let u=iD(l.pkcs7),d=await rD(l.cert),f=e.expiresInSeconds??pO;return{access_token:await QD(d,u,{aud:s,scope:i,sub:fO,azp:fO,iss:a,tenant_id:r,...c},{includeIssuedTimestamp:!0,expiresInSeconds:f,headers:{kid:l.kid}}),token_type:`Bearer`,expires_in:f}}async function hO(e,t,n,r,i){let a=await e.env.data.tenants.get(t);if(!a)throw Error(`Tenant not found: ${t}`);let o=Cc(e.env,e.var.custom_domain),s=a.audience??a.default_audience??`${o}userinfo`;return mO({tenants:e.env.data.tenants,keys:e.env.data.keys,tenantId:t,scope:n,issuer:o,audience:s,expiresInSeconds:r,customClaims:i,signingKeyMode:e.env.signingKeyMode})}function gO(e){return async(t,n=`webhook`)=>(await mO({tenants:e.tenants,keys:e.keys,tenantId:t,scope:n,issuer:e.issuer,signingKeyMode:e.signingKeyMode})).access_token}async function _O(e,t){let n=e.env.data.multiTenancyConfig;return n?.resolveControlPlane?(await n.resolveControlPlane({tenant_id:t}))?.tenantId:n?.controlPlaneTenantId}async function vO(e,t,n,r){let{clientId:i,scope:a}=n;if(!await e.env.data.tenants.get(t))throw Error(`Tenant not found: ${t}`);let o=t,s=await e.env.data.clients.get(t,i);if(!s&&r?.allowControlPlaneFallback){let n=await _O(e,t);if(n&&n!==t){let t=await e.env.data.clients.get(n,i);t&&(s=t,o=n)}}if(!s)throw Error(`Client not found: ${i}`);let c=(await e.env.data.clientGrants.list(o,{q:`client_id:${D(i)}`})).client_grants;if(c.length===0)throw Error(`Client has no client_grant: ${i}`);let l,u;if(n.audience){if(u=c.find(e=>e.audience===n.audience),!u)throw Error(`Client ${i} has no client_grant for audience: ${n.audience}`);l=n.audience}else if(c.length===1)u=c[0],l=u.audience;else throw Error(`audience is required: client ${i} has multiple client_grants`);let d=u.scope||[],f=a.split(/\s+/).filter(Boolean),p=f.filter(e=>!d.includes(e));if(p.length>0)throw Error(`access_denied: Client is not authorized for scope(s): ${p.join(`, `)}`);let m=uO(n.customClaims,{kind:`client_service_token`,source:`createClientServiceToken(customClaims)`,ctx:e,tenantId:o}),h=(await BD(e.env.data.keys,o,e.env.signingKeyMode,{purpose:`sign`}))[0];if(!h?.pkcs7||!h.cert)throw Error(`No signing key available`);let g=iD(h.pkcs7),_=await rD(h.cert),v=n.expiresInSeconds??pO,y={aud:l,scope:f.join(` `),sub:i,azp:i,iss:Cc(e.env),tenant_id:o,gty:`client_credentials`};return{access_token:await QD(_,g,{...m,...y},{includeIssuedTimestamp:!0,expiresInSeconds:v,headers:{kid:h.kid}}),token_type:`Bearer`,expires_in:v}}var yO=class extends Error{constructor(e){super(`Cannot update context of finalized login session ${e}`),this.name=`FinalizedLoginSessionError`}};function bO(e){return[T.COMPLETED,T.FAILED,T.EXPIRED].includes(e.state)}function xO(e){let t=JSON.stringify(e);return t===`{}`?``:t}var SO=10,CO=class extends Error{constructor(e){super(`Login session ${e} context update lost to concurrent writes`),this.name=`LoginSessionContentionError`}};async function wO(e,t,n,r,i={}){for(let a=0;a<SO;a++){let a=await e.get(t,n);if(!a)throw Error(`Login session ${n} not found`);if(bO(a))throw new yO(n);let{context:o}=Lm(a.state||T.PENDING,r,{stateData:Pm(a.state_data)});if(!o.stateData)throw Error(`Invalid context event ${r.type} for finalized or unrequested login session ${n}`);let s=xO(o.stateData);if(s===(a.state_data||``)&&Object.keys(i).length===0)return!0;let c={...i,state_data:s};if(!e.updateIfStateDataUnchanged)return e.update(t,n,c);if(await e.updateIfStateDataUnchanged(t,n,a.state_data||void 0,c))return!0}throw new CO(n)}async function TO(e,t,n,r,i){for(let a=0;a<SO;a++){let a=await e.get(t,n);if(!a)return{status:`not_found`};if(bO(a))return{status:`finalized`,session:a};let o=Pm(a.state_data),s=o[r]??0;if(s>=i)return{status:`limit_reached`,session:a};let{context:c}=Lm(a.state||T.PENDING,{type:j.UPDATE_CONTEXT,data:{[r]:s+1}},{stateData:o});if(!c.stateData)return{status:`finalized`,session:a};let l={state_data:xO(c.stateData)};if(!e.updateIfStateDataUnchanged)return await e.update(t,n,l)?{status:`reserved`,session:a}:{status:`not_found`};if(await e.updateIfStateDataUnchanged(t,n,a.state_data||void 0,l))return{status:`reserved`,session:a}}return{status:`contended`}}function EO(e,t,n,r){let{context:i}=Lm(T.PENDING,{type:j.UPDATE_CONTEXT,data:r});return e.create(t,{...n,state_data:xO(i.stateData??{})})}var DO=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,OO=32,kO=10,AO=16;function jO(e){let t=``;for(let n=kO;n>0;n--)t=DO.charAt(e%OO)+t,e=Math.floor(e/OO);return t}function MO(){let e=new Uint8Array(AO);crypto.getRandomValues(e);let t=``;for(let n=0;n<AO;n++)t+=DO.charAt(e[n]%OO);return t}function NO(){return jO(Date.now())+MO()}var PO={notFound:`Single Sign-On failed: Session Transfer Token not found or expired. This may indicate token reuse or expiration.`,deviceBinding:`Single Sign-On failed: Session Transfer Token device binding validation failed due to IP/ASN mismatch.`,organization:`Single Sign-On failed: Session Transfer Token organization mismatch detected.`,userMismatch:`Single Sign-On failed: Session Transfer Token user mismatch detected.`,parentNotFound:`Single Sign-On failed: Parent refresh token not found. Session Transfer Token won't be used for session establishment.`,methodNotAllowed:`Single Sign-On failed: Session Transfer Token authentication method is not allowed for this client.`,connectionNotEnabled:`Single Sign-On failed: Session Transfer Token user's connection is not enabled for this client.`,userUnavailable:`Single Sign-On failed: Session Transfer Token user is blocked or no longer exists.`},FO=f.z.object({session_transfer:f.z.object({family_id:f.z.string(),cascade_revocation:f.z.boolean(),asn:f.z.string().optional(),authentication:oi.optional(),organization:f.z.object({id:f.z.string(),name:f.z.string()}).optional()})});function IO(e){return typeof e==`object`&&!!e}function LO(e){let t=e.req.raw;if(!IO(t)||!IO(t.cf))return;let n=t.cf.asn;if(typeof n==`number`&&Number.isFinite(n))return String(n);if(typeof n==`string`&&n.trim())return n.trim()}function RO(e){if(e)return new Date(Date.now()+e*60*60*1e3).toISOString()}function zO(e,t){let n=hl(e)??e,r=hl(t)??t;return!!n&&!!r&&n===r}function BO(e,t){let n=t.toLowerCase();return e.connections.some(e=>e.name.toLowerCase()===n||e.strategy===t)}async function VO(e,t){let{client:n,user:r,refreshToken:i}=t,a=e.env.data,o=n.tenant.id,s=Qe(n.session_transfer),c=i.session_transfer,l=c?.family_id??i.family_id??i.id,u=s.enforce_cascade_revocation||(c?.cascade_revocation??!1),d=s.trust_forwarded_ip&&t.clientAuthenticated&&n.token_endpoint_auth_method!==`none`?hl(e.req.header(tl)):void 0,f=d??hl(e.var.ip)??e.var.ip??``,p=d?void 0:LO(e),m=t.sessionId?await a.sessions.get(o,t.sessionId):null,h={family_id:l,cascade_revocation:u,asn:p,authentication:WO(m)?m.authentication:void 0,organization:t.organization},g=Date.now(),_=60*1e3,v=await EO(a.loginSessions,o,{csrf_token:Yl(),authParams:{client_id:n.client_id,organization:t.organization?.id,scope:i.resource_servers[0]?.scopes},expires_at:new Date(g+_+6e4).toISOString(),ip:f,useragent:e.var.useragent,state:T.COMPLETED,user_id:r.user_id,auth_connection:t.authConnection,auth_strategy:t.authStrategy,authenticated_at:m?.authenticated_at},{session_transfer:h}),y=il();return await a.codes.create(o,{code_id:await al(y),code_type:el,login_id:v.id,user_id:r.user_id,expires_at:new Date(g+_).toISOString()}),y}async function HO(e,t){let{client:n}=t,r=e.env.data,i=n.tenant.id,a=Qe(n.session_transfer),o=(t,n)=>(O(e,i,{type:E.WARNING_DURING_LOGIN,description:t,userId:n}),{outcome:`rejected`});if(!a.allowed_authentication_methods.includes(t.method))return o(PO.methodNotAllowed);let s=await al(t.token),c=await r.codes.get(i,s,el);if(!c||c.used_at||!c.login_id||new Date(c.expires_at).getTime()<=Date.now()||!await r.codes.consume(i,s))return o(PO.notFound);let l=await r.loginSessions.get(i,c.login_id),u=FO.safeParse(Pm(l?.state_data)),d=u.success?u.data.session_transfer:void 0;if(!l||!d||!l.user_id)return o(PO.notFound);let f=l.user_id,p=LO(e);if(a.enforce_device_binding===`ip`){if(!zO(l.ip,e.var.ip))return o(PO.deviceBinding,f)}else if(a.enforce_device_binding===`asn`&&(!d.asn||!p||d.asn!==p))return o(PO.deviceBinding,f);if(d.organization&&t.organization&&t.organization!==d.organization.id&&t.organization!==d.organization.name)return o(PO.organization,f);if(!await r.refreshTokens.isFamilyActive(i,d.family_id))return o(PO.parentNotFound,f);let m=await r.users.get(i,f);if(!m||m.blocked||m.linked_to)return o(PO.userUnavailable,f);if(!BO(n,l.auth_connection??m.connection))return o(PO.connectionNotEnabled,f);let{existingSession:h}=t;if(h){if(h.user_id===m.user_id)return{outcome:`session_kept`};let t=new Date().toISOString();return await r.sessions.update(i,h.id,{revoked_at:t}),await id(r,i,h,t),O(e,i,{type:E.WARNING_DURING_LOGIN,description:PO.userMismatch,userId:f}),{outcome:`session_revoked`}}let g=l.authParams.client_id,_=p??``,v={client_id:g,family_id:d.family_id,cascade_revocation:d.cascade_revocation},y=await r.sessions.create(i,{id:NO(),user_id:m.user_id,login_session_id:l.id,idle_expires_at:RO(n.tenant.idle_session_lifetime),expires_at:RO(n.tenant.session_lifetime),device:{last_ip:e.var.ip||``,initial_ip:e.var.ip||``,last_user_agent:e.var.useragent||``,initial_user_agent:e.var.useragent||``,initial_asn:_,last_asn:_},clients:[n.client_id],authentication:d.authentication,session_transfer:v});return l.authenticated_at&&(await r.sessions.update(i,y.id,{authenticated_at:l.authenticated_at}),y={...y,authenticated_at:l.authenticated_at}),e.set(`session_transfer_token`,{client_id:g,scope:l.authParams.scope,request:{ip:l.ip??``,asn:d.asn,user_agent:l.useragent}}),{outcome:`session_created`,session:y}}function UO(e,t,n){return e.refreshTokens.isFamilyActive(t,n.family_id)}function WO(e,t=Date.now()){return!(!e||e.revoked_at||e.expires_at&&new Date(e.expires_at).getTime()<=t||e.idle_expires_at&&new Date(e.idle_expires_at).getTime()<=t)}var GO=300*1e3;function KO(e,t,n=Date.now()){let r=e.tenant.idle_session_lifetime;if(!r||!t.idle_expires_at)return;let i=r*60*60*1e3,a=n+i;t.expires_at&&(a=Math.min(a,new Date(t.expires_at).getTime()));let o=Math.min(GO,i/2),s=new Date(t.idle_expires_at).getTime();if(!(a-s<o))return new Date(a).toISOString()}function qO(e,t){let n=t?.session_transfer;if(!n)return{allowed:!0};let r=Qe(e.session_transfer);return r.allow_refresh_token?{allowed:!0,session_transfer:n,max_expires_at:r.enforce_online_refresh_tokens?t?.expires_at:void 0}:{allowed:!1}}var JO=new Date(`2026-08-04T00:00:00.000Z`);function YO(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}function XO(){return{lookup:Ds(YO(7)),secret:Ds(YO(32))}}async function ZO(e){return Is(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))}function QO(e,t){return`rt_${e}.${t}`}function $O(e){if(e.startsWith(`rt_`)){let t=e.slice(3),n=t.indexOf(`.`);if(n>0&&n<t.length-1)return{kind:`new`,lookup:t.slice(0,n),secret:t.slice(n+1)}}return{kind:`legacy`,id:e}}function ek(e=new Date){return e<JO}var tk={RS256:`SHA-256`,RS384:`SHA-384`,RS512:`SHA-512`,ES256:`SHA-256`,ES384:`SHA-384`,ES512:`SHA-512`,HS256:`SHA-256`,HS384:`SHA-384`,HS512:`SHA-512`};async function nk(e,t){let n=tk[t];if(!n)throw Error(`Cannot compute id_token hash: unsupported signing alg ${t}`);let r=new TextEncoder().encode(e),i=await crypto.subtle.digest(n,r),a=new Uint8Array(i);return Ds(a.slice(0,a.length/2))}var rk=f.z.object({"#text":f.z.string()}),ik=f.z.object({"#text":f.z.string(),"@_xmlns:saml":f.z.string().optional()});f.z.object({"samlp:AuthnRequest":f.z.object({"saml:Issuer":ik,"@_xmlns:samlp":f.z.string(),"@_xmlns:saml":f.z.string().optional(),"@_ForceAuthn":f.z.string().transform(e=>e.toLowerCase()===`true`).optional(),"@_ID":f.z.string(),"@_IssueInstant":f.z.string().datetime(),"@_Destination":f.z.string().url(),"@_AssertionConsumerServiceURL":f.z.string().url().optional(),"@_ProtocolBinding":f.z.string().optional(),"@_Version":f.z.string()})});var ak=f.z.object({"samlp:LogoutRequest":f.z.object({"saml:Issuer":ik,"saml:NameID":f.z.object({"#text":f.z.string()}).optional(),"samlp:SessionIndex":f.z.object({"#text":f.z.string()}).optional(),"@_ID":f.z.string(),"@_Version":f.z.string().optional(),"@_Destination":f.z.string().optional()})});f.z.array(f.z.object({":@":f.z.object({"@_xmlns":f.z.string(),"@_entityID":f.z.string()}),EntityDescriptor:f.z.array(f.z.object({":@":f.z.object({"@_protocolSupportEnumeration":f.z.string()}),IDPSSODescriptor:f.z.array(f.z.union([f.z.object({KeyDescriptor:f.z.array(f.z.object({KeyInfo:f.z.array(f.z.object({X509Data:f.z.array(f.z.object({X509Certificate:f.z.array(rk)}))})),":@":f.z.object({"@_xmlns":f.z.string()})})),":@":f.z.object({"@_use":f.z.string()})}),f.z.object({SingleLogoutService:f.z.array(f.z.object({})),":@":f.z.object({"@_Binding":f.z.string(),"@_Location":f.z.string()})}),f.z.object({NameIDFormat:f.z.array(rk)}),f.z.object({SingleSignOnService:f.z.array(f.z.object({})),":@":f.z.object({"@_Binding":f.z.string(),"@_Location":f.z.string()})}),f.z.object({Attribute:f.z.array(f.z.object({})),":@":f.z.object({"@_Name":f.z.string(),"@_NameFormat":f.z.string(),"@_FriendlyName":f.z.string(),"@_xmlns":f.z.string()})})]))}))}));var ok=f.z.object({"saml:Attribute":f.z.array(f.z.object({"saml:AttributeValue":f.z.array(f.z.object({"#text":f.z.string()})),":@":f.z.object({"@_xmlns:xs":f.z.string().optional(),"@_xmlns:xsi":f.z.string(),"@_xsi:type":f.z.string()}).optional()})),":@":f.z.object({"@_Name":f.z.string(),"@_NameFormat":f.z.string(),"@_FriendlyName":f.z.string().optional()})}),sk=f.z.object({"ds:Transform":f.z.array(f.z.any()),":@":f.z.object({"@_Algorithm":f.z.string()})}),ck=f.z.object({"ds:Signature":f.z.array(f.z.union([f.z.object({"ds:SignedInfo":f.z.array(f.z.union([f.z.object({"ds:CanonicalizationMethod":f.z.array(f.z.object({":@":f.z.object({"@_Algorithm":f.z.string()})}))}),f.z.object({"ds:SignatureMethod":f.z.array(f.z.object({":@":f.z.object({"@_Algorithm":f.z.string()})}))}),f.z.object({"ds:Reference":f.z.array(f.z.union([f.z.object({"ds:Transforms":f.z.array(sk)}),f.z.object({"ds:DigestMethod":f.z.array(f.z.object({":@":f.z.object({"@_Algorithm":f.z.string()})}))}),f.z.object({"ds:DigestValue":f.z.array(rk)})])),":@":f.z.object({"@_URI":f.z.string().optional()}).optional()})]))}),f.z.object({"ds:SignatureValue":f.z.array(rk)}),f.z.object({"ds:KeyInfo":f.z.array(f.z.union([f.z.object({"ds:KeyValue":f.z.array(f.z.object({"ds:RSAKeyValue":f.z.array(f.z.union([f.z.object({"ds:Modulus":f.z.array(rk)}),f.z.object({"ds:Exponent":f.z.array(rk)})]))}))}),f.z.object({"ds:X509Data":f.z.array(f.z.object({"ds:X509Certificate":f.z.array(rk)}))}),f.z.object({"ds:KeyValue":f.z.array(f.z.object({"ds:RSAKeyValue":f.z.array(f.z.union([f.z.object({"ds:Modulus":f.z.array(rk)}),f.z.object({"ds:Exponent":f.z.array(rk)})]))})),"ds:X509Data":f.z.array(f.z.object({"ds:X509Certificate":f.z.array(rk)}))})]))})])),":@":f.z.object({"@_xmlns:ds":f.z.string().optional()}).optional()});f.z.array(f.z.object({"samlp:Response":f.z.array(f.z.union([f.z.object({"saml:Issuer":f.z.array(rk)}),ck,f.z.object({"samlp:Status":f.z.array(f.z.object({"samlp:StatusCode":f.z.array(rk),":@":f.z.object({"@_Value":f.z.string()})}))}),f.z.object({"saml:Assertion":f.z.array(f.z.union([f.z.object({"saml:Issuer":f.z.array(rk)}),ck,f.z.object({"saml:Subject":f.z.array(f.z.union([f.z.object({"saml:NameID":f.z.array(rk),":@":f.z.object({"@_Format":f.z.string()})}),f.z.object({"saml:SubjectConfirmation":f.z.array(f.z.object({"saml:SubjectConfirmationData":f.z.array(f.z.any()),":@":f.z.object({"@_InResponseTo":f.z.string(),"@_NotOnOrAfter":f.z.string(),"@_Recipient":f.z.string()})})),":@":f.z.object({"@_Method":f.z.string()})})]))}),f.z.object({"saml:Conditions":f.z.array(f.z.object({"saml:AudienceRestriction":f.z.array(f.z.object({"saml:Audience":f.z.array(rk)}))})),":@":f.z.object({"@_NotBefore":f.z.string(),"@_NotOnOrAfter":f.z.string()})}),f.z.object({"saml:AuthnStatement":f.z.array(f.z.object({"saml:AuthnContext":f.z.array(f.z.object({"saml:AuthnContextClassRef":f.z.array(rk)}))})),":@":f.z.object({"@_AuthnInstant":f.z.string(),"@_SessionIndex":f.z.string(),"@_SessionNotOnOrAfter":f.z.string()})}),f.z.object({"saml:AttributeStatement":f.z.array(ok)})])),":@":f.z.object({"@_xmlns":f.z.string(),"@_ID":f.z.string(),"@_IssueInstant":f.z.string(),"@_Version":f.z.string()})})])),":@":f.z.object({"@_xmlns:samlp":f.z.string(),"@_xmlns:saml":f.z.string(),"@_Destination":f.z.string(),"@_ID":f.z.string(),"@_InResponseTo":f.z.string(),"@_IssueInstant":f.z.string(),"@_Version":f.z.string()})}));var lk=RegExp(`^[:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`);function uk(e,t){let n=[],r=t.exec(e);for(;r;){let i=[];i.startIndex=t.lastIndex-r[0].length;let a=r.length;for(let e=0;e<a;e++)i.push(r[e]);n.push(i),r=t.exec(e)}return n}var dk=function(e){return lk.exec(e)!=null};function fk(e){return e!==void 0}var pk=[`hasOwnProperty`,`toString`,`valueOf`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`],mk=[`__proto__`,`constructor`,`prototype`],hk={allowBooleanAttributes:!1,unpairedTags:[]};function gk(e,t){t=Object.assign({},hk,t);let n=[],r=!1,i=!1;e[0]===``&&(e=e.substr(1));for(let a=0;a<e.length;a++)if(e[a]===`<`&&e[a+1]===`?`){if(a+=2,a=vk(e,a),a.err)return a}else if(e[a]===`<`){let o=a;if(a++,e[a]===`!`){a=yk(e,a);continue}else{let s=!1;e[a]===`/`&&(s=!0,a++);let c=``;for(;a<e.length&&e[a]!==`>`&&e[a]!==` `&&e[a]!==` `&&e[a]!==`
305
- `&&e[a]!==`\r`;a++)c+=e[a];if(c=c.trim(),c[c.length-1]===`/`&&(c=c.substring(0,c.length-1),a--),!kk(c)){let t;return t=c.trim().length===0?`Invalid space after '<'.`:`Tag '`+c+`' is an invalid name.`,Dk(`InvalidTag`,t,Ak(e,a))}let l=Sk(e,a);if(l===!1)return Dk(`InvalidAttr`,`Attributes for '`+c+`' have open quote.`,Ak(e,a));let u=l.value;if(a=l.index,u[u.length-1]===`/`){let n=a-u.length;u=u.substring(0,u.length-1);let i=wk(u,t);if(i===!0)r=!0;else return Dk(i.err.code,i.err.msg,Ak(e,n+i.err.line))}else if(s){if(!l.tagClosed)return Dk(`InvalidTag`,`Closing tag '`+c+`' doesn't have proper closing.`,Ak(e,a));if(u.trim().length>0)return Dk(`InvalidTag`,`Closing tag '`+c+`' can't have attributes or invalid starting.`,Ak(e,o));if(n.length===0)return Dk(`InvalidTag`,`Closing tag '`+c+`' has not been opened.`,Ak(e,o));{let t=n.pop();if(c!==t.tagName){let n=Ak(e,t.tagStartPos);return Dk(`InvalidTag`,`Expected closing tag '`+t.tagName+`' (opened in line `+n.line+`, col `+n.col+`) instead of closing tag '`+c+`'.`,Ak(e,o))}n.length==0&&(i=!0)}}else{let s=wk(u,t);if(s!==!0)return Dk(s.err.code,s.err.msg,Ak(e,a-u.length+s.err.line));if(i===!0)return Dk(`InvalidXml`,`Multiple possible root nodes found.`,Ak(e,a));t.unpairedTags.indexOf(c)!==-1||n.push({tagName:c,tagStartPos:o}),r=!0}for(a++;a<e.length;a++)if(e[a]===`<`)if(e[a+1]===`!`){a++,a=yk(e,a);continue}else if(e[a+1]===`?`){if(a=vk(e,++a),a.err)return a}else break;else if(e[a]===`&`){let t=Ek(e,a);if(t==-1)return Dk(`InvalidChar`,`char '&' is not expected.`,Ak(e,a));a=t}else if(i===!0&&!_k(e[a]))return Dk(`InvalidXml`,`Extra text at the end`,Ak(e,a));e[a]===`<`&&a--}}else{if(_k(e[a]))continue;return Dk(`InvalidChar`,`char '`+e[a]+`' is not expected.`,Ak(e,a))}return r?n.length==1?Dk(`InvalidTag`,`Unclosed tag '`+n[0].tagName+`'.`,Ak(e,n[0].tagStartPos)):n.length>0?Dk(`InvalidXml`,`Invalid '`+JSON.stringify(n.map(e=>e.tagName),null,4).replace(/\r?\n/g,``)+`' found.`,{line:1,col:1}):!0:Dk(`InvalidXml`,`Start tag expected.`,1)}function _k(e){return e===` `||e===` `||e===`
306
- `||e===`\r`}function vk(e,t){let n=t;for(;t<e.length;t++)if(e[t]==`?`||e[t]==` `){let r=e.substr(n,t-n);if(t>5&&r===`xml`)return Dk(`InvalidXml`,`XML declaration allowed only at the start of the document.`,Ak(e,t));if(e[t]==`?`&&e[t+1]==`>`){t++;break}else continue}return t}function yk(e,t){if(e.length>t+5&&e[t+1]===`-`&&e[t+2]===`-`){for(t+=3;t<e.length;t++)if(e[t]===`-`&&e[t+1]===`-`&&e[t+2]===`>`){t+=2;break}}else if(e.length>t+8&&e[t+1]===`D`&&e[t+2]===`O`&&e[t+3]===`C`&&e[t+4]===`T`&&e[t+5]===`Y`&&e[t+6]===`P`&&e[t+7]===`E`){let n=1;for(t+=8;t<e.length;t++)if(e[t]===`<`)n++;else if(e[t]===`>`&&(n--,n===0))break}else if(e.length>t+9&&e[t+1]===`[`&&e[t+2]===`C`&&e[t+3]===`D`&&e[t+4]===`A`&&e[t+5]===`T`&&e[t+6]===`A`&&e[t+7]===`[`){for(t+=8;t<e.length;t++)if(e[t]===`]`&&e[t+1]===`]`&&e[t+2]===`>`){t+=2;break}}return t}var bk=`"`,xk=`'`;function Sk(e,t){let n=``,r=``,i=!1;for(;t<e.length;t++){if(e[t]===bk||e[t]===xk)r===``?r=e[t]:r!==e[t]||(r=``);else if(e[t]===`>`&&r===``){i=!0;break}n+=e[t]}return r===``?{value:n,index:t,tagClosed:i}:!1}var Ck=RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,`g`);function wk(e,t){let n=uk(e,Ck),r={};for(let e=0;e<n.length;e++){if(n[e][1].length===0)return Dk(`InvalidAttr`,`Attribute '`+n[e][2]+`' has no space in starting.`,jk(n[e]));if(n[e][3]!==void 0&&n[e][4]===void 0)return Dk(`InvalidAttr`,`Attribute '`+n[e][2]+`' is without value.`,jk(n[e]));if(n[e][3]===void 0&&!t.allowBooleanAttributes)return Dk(`InvalidAttr`,`boolean attribute '`+n[e][2]+`' is not allowed.`,jk(n[e]));let i=n[e][2];if(!Ok(i))return Dk(`InvalidAttr`,`Attribute '`+i+`' is an invalid name.`,jk(n[e]));if(!Object.prototype.hasOwnProperty.call(r,i))r[i]=1;else return Dk(`InvalidAttr`,`Attribute '`+i+`' is repeated.`,jk(n[e]))}return!0}function Tk(e,t){let n=/\d/;for(e[t]===`x`&&(t++,n=/[\da-fA-F]/);t<e.length;t++){if(e[t]===`;`)return t;if(!e[t].match(n))break}return-1}function Ek(e,t){if(t++,e[t]===`;`)return-1;if(e[t]===`#`)return t++,Tk(e,t);let n=0;for(;t<e.length;t++,n++)if(!(e[t].match(/\w/)&&n<20)){if(e[t]===`;`)break;return-1}return t}function Dk(e,t,n){return{err:{code:e,msg:t,line:n.line||n,col:n.col}}}function Ok(e){return dk(e)}function kk(e){return dk(e)}function Ak(e,t){let n=e.substring(0,t).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function jk(e){return e.startIndex+e[1].length}var Mk={amp:`&`,AMP:`&`,lt:`<`,LT:`<`,gt:`>`,GT:`>`,quot:`"`,QUOT:`"`,apos:`'`,lsquo:`‘`,rsquo:`’`,ldquo:`“`,rdquo:`”`,lsquor:`‚`,rsquor:`’`,ldquor:`„`,bdquo:`„`,comma:`,`,period:`.`,colon:`:`,semi:`;`,excl:`!`,quest:`?`,num:`#`,dollar:`$`,percent:`%`,ast:`*`,commat:`@`,lowbar:`_`,verbar:`|`,vert:`|`,sol:`/`,bsol:`\\`,lbrace:`{`,rbrace:`}`,lbrack:`[`,rbrack:`]`,lpar:`(`,rpar:`)`,nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,COPY:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:`­`,reg:`®`,REG:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,half:`½`,frac34:`¾`,iquest:`¿`,times:`×`,div:`÷`,divide:`÷`},Nk={Agrave:`À`,agrave:`à`,Aacute:`Á`,aacute:`á`,Acirc:`Â`,acirc:`â`,Atilde:`Ã`,atilde:`ã`,Auml:`Ä`,auml:`ä`,Aring:`Å`,aring:`å`,AElig:`Æ`,aelig:`æ`,Ccedil:`Ç`,ccedil:`ç`,Egrave:`È`,egrave:`è`,Eacute:`É`,eacute:`é`,Ecirc:`Ê`,ecirc:`ê`,Euml:`Ë`,euml:`ë`,Igrave:`Ì`,igrave:`ì`,Iacute:`Í`,iacute:`í`,Icirc:`Î`,icirc:`î`,Iuml:`Ï`,iuml:`ï`,ETH:`Ð`,eth:`ð`,Ntilde:`Ñ`,ntilde:`ñ`,Ograve:`Ò`,ograve:`ò`,Oacute:`Ó`,oacute:`ó`,Ocirc:`Ô`,ocirc:`ô`,Otilde:`Õ`,otilde:`õ`,Ouml:`Ö`,ouml:`ö`,Oslash:`Ø`,oslash:`ø`,Ugrave:`Ù`,ugrave:`ù`,Uacute:`Ú`,uacute:`ú`,Ucirc:`Û`,ucirc:`û`,Uuml:`Ü`,uuml:`ü`,Yacute:`Ý`,yacute:`ý`,THORN:`Þ`,thorn:`þ`,szlig:`ß`,yuml:`ÿ`,Yuml:`Ÿ`},Pk={Amacr:`Ā`,amacr:`ā`,Abreve:`Ă`,abreve:`ă`,Aogon:`Ą`,aogon:`ą`,Cacute:`Ć`,cacute:`ć`,Ccirc:`Ĉ`,ccirc:`ĉ`,Cdot:`Ċ`,cdot:`ċ`,Ccaron:`Č`,ccaron:`č`,Dcaron:`Ď`,dcaron:`ď`,Dstrok:`Đ`,dstrok:`đ`,Emacr:`Ē`,emacr:`ē`,Ecaron:`Ě`,ecaron:`ě`,Edot:`Ė`,edot:`ė`,Eogon:`Ę`,eogon:`ę`,Gcirc:`Ĝ`,gcirc:`ĝ`,Gbreve:`Ğ`,gbreve:`ğ`,Gdot:`Ġ`,gdot:`ġ`,Gcedil:`Ģ`,Hcirc:`Ĥ`,hcirc:`ĥ`,Hstrok:`Ħ`,hstrok:`ħ`,Itilde:`Ĩ`,itilde:`ĩ`,Imacr:`Ī`,imacr:`ī`,Iogon:`Į`,iogon:`į`,Idot:`İ`,IJlig:`IJ`,ijlig:`ij`,Jcirc:`Ĵ`,jcirc:`ĵ`,Kcedil:`Ķ`,kcedil:`ķ`,kgreen:`ĸ`,Lacute:`Ĺ`,lacute:`ĺ`,Lcedil:`Ļ`,lcedil:`ļ`,Lcaron:`Ľ`,lcaron:`ľ`,Lmidot:`Ŀ`,lmidot:`ŀ`,Lstrok:`Ł`,lstrok:`ł`,Nacute:`Ń`,nacute:`ń`,Ncaron:`Ň`,ncaron:`ň`,Ncedil:`Ņ`,ncedil:`ņ`,ENG:`Ŋ`,eng:`ŋ`,Omacr:`Ō`,omacr:`ō`,Odblac:`Ő`,odblac:`ő`,OElig:`Œ`,oelig:`œ`,Racute:`Ŕ`,racute:`ŕ`,Rcaron:`Ř`,rcaron:`ř`,Rcedil:`Ŗ`,rcedil:`ŗ`,Sacute:`Ś`,sacute:`ś`,Scirc:`Ŝ`,scirc:`ŝ`,Scedil:`Ş`,scedil:`ş`,Scaron:`Š`,scaron:`š`,Tcedil:`Ţ`,tcedil:`ţ`,Tcaron:`Ť`,tcaron:`ť`,Tstrok:`Ŧ`,tstrok:`ŧ`,Utilde:`Ũ`,utilde:`ũ`,Umacr:`Ū`,umacr:`ū`,Ubreve:`Ŭ`,ubreve:`ŭ`,Uring:`Ů`,uring:`ů`,Udblac:`Ű`,udblac:`ű`,Uogon:`Ų`,uogon:`ų`,Wcirc:`Ŵ`,wcirc:`ŵ`,Ycirc:`Ŷ`,ycirc:`ŷ`,Zacute:`Ź`,zacute:`ź`,Zdot:`Ż`,zdot:`ż`,Zcaron:`Ž`,zcaron:`ž`},Fk={Alpha:`Α`,alpha:`α`,Beta:`Β`,beta:`β`,Gamma:`Γ`,gamma:`γ`,Delta:`Δ`,delta:`δ`,Epsilon:`Ε`,epsilon:`ε`,epsiv:`ϵ`,varepsilon:`ϵ`,Zeta:`Ζ`,zeta:`ζ`,Eta:`Η`,eta:`η`,Theta:`Θ`,theta:`θ`,thetasym:`ϑ`,vartheta:`ϑ`,Iota:`Ι`,iota:`ι`,Kappa:`Κ`,kappa:`κ`,kappav:`ϰ`,varkappa:`ϰ`,Lambda:`Λ`,lambda:`λ`,Mu:`Μ`,mu:`μ`,Nu:`Ν`,nu:`ν`,Xi:`Ξ`,xi:`ξ`,Omicron:`Ο`,omicron:`ο`,Pi:`Π`,pi:`π`,piv:`ϖ`,varpi:`ϖ`,Rho:`Ρ`,rho:`ρ`,rhov:`ϱ`,varrho:`ϱ`,Sigma:`Σ`,sigma:`σ`,sigmaf:`ς`,sigmav:`ς`,varsigma:`ς`,Tau:`Τ`,tau:`τ`,Upsilon:`Υ`,upsilon:`υ`,upsi:`υ`,Upsi:`ϒ`,upsih:`ϒ`,Phi:`Φ`,phi:`φ`,phiv:`ϕ`,varphi:`ϕ`,Chi:`Χ`,chi:`χ`,Psi:`Ψ`,psi:`ψ`,Omega:`Ω`,omega:`ω`,ohm:`Ω`,Gammad:`Ϝ`,gammad:`ϝ`,digamma:`ϝ`},Ik={Afr:`𝔄`,afr:`𝔞`,Acy:`А`,acy:`а`,Bcy:`Б`,bcy:`б`,Vcy:`В`,vcy:`в`,Gcy:`Г`,gcy:`г`,Dcy:`Д`,dcy:`д`,IEcy:`Е`,iecy:`е`,IOcy:`Ё`,iocy:`ё`,ZHcy:`Ж`,zhcy:`ж`,Zcy:`З`,zcy:`з`,Icy:`И`,icy:`и`,Jcy:`Й`,jcy:`й`,Kcy:`К`,kcy:`к`,Lcy:`Л`,lcy:`л`,Mcy:`М`,mcy:`м`,Ncy:`Н`,ncy:`н`,Ocy:`О`,ocy:`о`,Pcy:`П`,pcy:`п`,Rcy:`Р`,rcy:`р`,Scy:`С`,scy:`с`,Tcy:`Т`,tcy:`т`,Ucy:`У`,ucy:`у`,Fcy:`Ф`,fcy:`ф`,KHcy:`Х`,khcy:`х`,TScy:`Ц`,tscy:`ц`,CHcy:`Ч`,chcy:`ч`,SHcy:`Ш`,shcy:`ш`,SHCHcy:`Щ`,shchcy:`щ`,HARDcy:`Ъ`,hardcy:`ъ`,Ycy:`Ы`,ycy:`ы`,SOFTcy:`Ь`,softcy:`ь`,Ecy:`Э`,ecy:`э`,YUcy:`Ю`,yucy:`ю`,YAcy:`Я`,yacy:`я`,DJcy:`Ђ`,djcy:`ђ`,GJcy:`Ѓ`,gjcy:`ѓ`,Jukcy:`Є`,jukcy:`є`,DScy:`Ѕ`,dscy:`ѕ`,Iukcy:`І`,iukcy:`і`,YIcy:`Ї`,yicy:`ї`,Jsercy:`Ј`,jsercy:`ј`,LJcy:`Љ`,ljcy:`љ`,NJcy:`Њ`,njcy:`њ`,TSHcy:`Ћ`,tshcy:`ћ`,KJcy:`Ќ`,kjcy:`ќ`,Ubrcy:`Ў`,ubrcy:`ў`,DZcy:`Џ`,dzcy:`џ`},Lk={plus:`+`,pm:`±`,times:`×`,div:`÷`,divide:`÷`,sdot:`⋅`,star:`☆`,starf:`★`,bigstar:`★`,lowast:`∗`,ast:`*`,midast:`*`,compfn:`∘`,smallcircle:`∘`,bullet:`•`,bull:`•`,nbsp:`\xA0`,hellip:`…`,mldr:`…`,prime:`′`,Prime:`″`,tprime:`‴`,bprime:`‵`,backprime:`‵`,minus:`−`,minusd:`∸`,dotminus:`∸`,plusdo:`∔`,dotplus:`∔`,plusmn:`±`,minusplus:`∓`,mnplus:`∓`,mp:`∓`,setminus:`∖`,smallsetminus:`∖`,Backslash:`∖`,setmn:`∖`,ssetmn:`∖`,lowbar:`_`,verbar:`|`,vert:`|`,VerticalLine:`|`,colon:`:`,Colon:`∷`,Proportion:`∷`,ratio:`∶`,equals:`=`,ne:`≠`,nequiv:`≢`,equiv:`≡`,Congruent:`≡`,sim:`∼`,thicksim:`∼`,thksim:`∼`,sime:`≃`,simeq:`≃`,TildeEqual:`≃`,asymp:`≈`,approx:`≈`,thickapprox:`≈`,thkap:`≈`,TildeTilde:`≈`,ncong:`≇`,cong:`≅`,TildeFullEqual:`≅`,asympeq:`≍`,CupCap:`≍`,bump:`≎`,Bumpeq:`≎`,HumpDownHump:`≎`,bumpe:`≏`,bumpeq:`≏`,HumpEqual:`≏`,le:`≤`,LessEqual:`≤`,ge:`≥`,GreaterEqual:`≥`,lesseqgtr:`⋚`,lesseqqgtr:`⪋`,greater:`>`,less:`<`},Rk={alefsym:`ℵ`,aleph:`ℵ`,beth:`ℶ`,gimel:`ℷ`,daleth:`ℸ`,forall:`∀`,ForAll:`∀`,part:`∂`,PartialD:`∂`,exist:`∃`,Exists:`∃`,nexist:`∄`,nexists:`∄`,empty:`∅`,emptyset:`∅`,emptyv:`∅`,varnothing:`∅`,nabla:`∇`,Del:`∇`,isin:`∈`,isinv:`∈`,in:`∈`,Element:`∈`,notin:`∉`,notinva:`∉`,ni:`∋`,niv:`∋`,SuchThat:`∋`,ReverseElement:`∋`,notni:`∌`,notniva:`∌`,prod:`∏`,Product:`∏`,coprod:`∐`,Coproduct:`∐`,sum:`∑`,Sum:`∑`,minus:`−`,mp:`∓`,plusdo:`∔`,dotplus:`∔`,setminus:`∖`,lowast:`∗`,radic:`√`,Sqrt:`√`,prop:`∝`,propto:`∝`,Proportional:`∝`,varpropto:`∝`,infin:`∞`,infintie:`⧝`,ang:`∠`,angle:`∠`,angmsd:`∡`,measuredangle:`∡`,angsph:`∢`,mid:`∣`,VerticalBar:`∣`,nmid:`∤`,nsmid:`∤`,npar:`∦`,parallel:`∥`,spar:`∥`,nparallel:`∦`,nspar:`∦`,and:`∧`,wedge:`∧`,or:`∨`,vee:`∨`,cap:`∩`,cup:`∪`,int:`∫`,Integral:`∫`,conint:`∮`,ContourIntegral:`∮`,Conint:`∯`,DoubleContourIntegral:`∯`,Cconint:`∰`,there4:`∴`,therefore:`∴`,Therefore:`∴`,becaus:`∵`,because:`∵`,Because:`∵`,ratio:`∶`,Proportion:`∷`,minusd:`∸`,dotminus:`∸`,mDDot:`∺`,homtht:`∻`,sim:`∼`,bsimg:`∽`,backsim:`∽`,ac:`∾`,mstpos:`∾`,acd:`∿`,VerticalTilde:`≀`,wr:`≀`,wreath:`≀`,nsime:`≄`,nsimeq:`≄`,ncong:`≇`,simne:`≆`,ncongdot:`⩭̸`,ngsim:`≵`,nsim:`≁`,napprox:`≉`,nap:`≉`,ngeq:`≱`,nge:`≱`,nleq:`≰`,nle:`≰`,ngtr:`≯`,ngt:`≯`,nless:`≮`,nlt:`≮`,nprec:`⊀`,npr:`⊀`,nsucc:`⊁`,nsc:`⊁`},zk={larr:`←`,leftarrow:`←`,LeftArrow:`←`,uarr:`↑`,uparrow:`↑`,UpArrow:`↑`,rarr:`→`,rightarrow:`→`,RightArrow:`→`,darr:`↓`,downarrow:`↓`,DownArrow:`↓`,harr:`↔`,leftrightarrow:`↔`,LeftRightArrow:`↔`,varr:`↕`,updownarrow:`↕`,UpDownArrow:`↕`,nwarr:`↖`,nwarrow:`↖`,UpperLeftArrow:`↖`,nearr:`↗`,nearrow:`↗`,UpperRightArrow:`↗`,searr:`↘`,searrow:`↘`,LowerRightArrow:`↘`,swarr:`↙`,swarrow:`↙`,LowerLeftArrow:`↙`,lArr:`⇐`,Leftarrow:`⇐`,uArr:`⇑`,Uparrow:`⇑`,rArr:`⇒`,Rightarrow:`⇒`,dArr:`⇓`,Downarrow:`⇓`,hArr:`⇔`,Leftrightarrow:`⇔`,iff:`⇔`,vArr:`⇕`,Updownarrow:`⇕`,lAarr:`⇚`,Lleftarrow:`⇚`,rAarr:`⇛`,Rrightarrow:`⇛`,lrarr:`⇆`,leftrightarrows:`⇆`,rlarr:`⇄`,rightleftarrows:`⇄`,lrhar:`⇋`,leftrightharpoons:`⇋`,ReverseEquilibrium:`⇋`,rlhar:`⇌`,rightleftharpoons:`⇌`,Equilibrium:`⇌`,udarr:`⇅`,UpArrowDownArrow:`⇅`,duarr:`⇵`,DownArrowUpArrow:`⇵`,llarr:`⇇`,leftleftarrows:`⇇`,rrarr:`⇉`,rightrightarrows:`⇉`,ddarr:`⇊`,downdownarrows:`⇊`,har:`↽`,lhard:`↽`,leftharpoondown:`↽`,lharu:`↼`,leftharpoonup:`↼`,rhard:`⇁`,rightharpoondown:`⇁`,rharu:`⇀`,rightharpoonup:`⇀`,lsh:`↰`,Lsh:`↰`,rsh:`↱`,Rsh:`↱`,ldsh:`↲`,rdsh:`↳`,hookleftarrow:`↩`,hookrightarrow:`↪`,mapstoleft:`↤`,mapstoup:`↥`,map:`↦`,mapsto:`↦`,mapstodown:`↧`,crarr:`↵`,nleftarrow:`↚`,nleftrightarrow:`↮`,nrightarrow:`↛`,nrarr:`↛`,larrtl:`↢`,rarrtl:`↣`,leftarrowtail:`↢`,rightarrowtail:`↣`,twoheadleftarrow:`↞`,twoheadrightarrow:`↠`,Larr:`↞`,Rarr:`↠`,larrhk:`↩`,rarrhk:`↪`,larrlp:`↫`,looparrowleft:`↫`,rarrlp:`↬`,looparrowright:`↬`,harrw:`↭`,leftrightsquigarrow:`↭`,nrarrw:`↝̸`,rarrw:`↝`,rightsquigarrow:`↝`,larrbfs:`⤟`,rarrbfs:`⤠`,nvHarr:`⤄`,nvlArr:`⤂`,nvrArr:`⤃`,larrfs:`⤝`,rarrfs:`⤞`,Map:`⤅`,larrsim:`⥳`,rarrsim:`⥴`,harrcir:`⥈`,Uarrocir:`⥉`,lurdshar:`⥊`,ldrdhar:`⥧`,ldrushar:`⥋`,rdldhar:`⥩`,lrhard:`⥭`,uharr:`↾`,uharl:`↿`,dharr:`⇂`,dharl:`⇃`,Uarr:`↟`,Darr:`↡`,zigrarr:`⇝`,nwArr:`⇖`,neArr:`⇗`,seArr:`⇘`,swArr:`⇙`,nharr:`↮`,nhArr:`⇎`,nlarr:`↚`,nlArr:`⇍`,nrArr:`⇏`,larrb:`⇤`,LeftArrowBar:`⇤`,rarrb:`⇥`,RightArrowBar:`⇥`},Bk={square:`□`,Square:`□`,squ:`□`,squf:`▪`,squarf:`▪`,blacksquar:`▪`,blacksquare:`▪`,FilledVerySmallSquare:`▪`,blk34:`▓`,blk12:`▒`,blk14:`░`,block:`█`,srect:`▭`,rect:`▭`,sdot:`⋅`,sdotb:`⊡`,dotsquare:`⊡`,triangle:`▵`,tri:`▵`,trine:`▵`,utri:`▵`,triangledown:`▿`,dtri:`▿`,tridown:`▿`,triangleleft:`◃`,ltri:`◃`,triangleright:`▹`,rtri:`▹`,blacktriangle:`▴`,utrif:`▴`,blacktriangledown:`▾`,dtrif:`▾`,blacktriangleleft:`◂`,ltrif:`◂`,blacktriangleright:`▸`,rtrif:`▸`,loz:`◊`,lozenge:`◊`,blacklozenge:`⧫`,lozf:`⧫`,bigcirc:`◯`,xcirc:`◯`,circ:`ˆ`,Circle:`○`,cir:`○`,o:`○`,bullet:`•`,bull:`•`,hellip:`…`,mldr:`…`,nldr:`‥`,boxh:`─`,HorizontalLine:`─`,boxv:`│`,boxdr:`┌`,boxdl:`┐`,boxur:`└`,boxul:`┘`,boxvr:`├`,boxvl:`┤`,boxhd:`┬`,boxhu:`┴`,boxvh:`┼`,boxH:`═`,boxV:`║`,boxdR:`╒`,boxDr:`╓`,boxDR:`╔`,boxDl:`╕`,boxdL:`╖`,boxDL:`╗`,boxuR:`╘`,boxUr:`╙`,boxUR:`╚`,boxUl:`╜`,boxuL:`╛`,boxUL:`╝`,boxvR:`╞`,boxVr:`╟`,boxVR:`╠`,boxVl:`╢`,boxvL:`╡`,boxVL:`╣`,boxHd:`╤`,boxhD:`╥`,boxHD:`╦`,boxHu:`╧`,boxhU:`╨`,boxHU:`╩`,boxvH:`╪`,boxVh:`╫`,boxVH:`╬`},Vk={excl:`!`,iexcl:`¡`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:`­`,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,nbsp:`\xA0`,comma:`,`,period:`.`,colon:`:`,semi:`;`,vert:`|`,Verbar:`‖`,verbar:`|`,dblac:`˝`,circ:`ˆ`,caron:`ˇ`,breve:`˘`,dot:`˙`,ring:`˚`,ogon:`˛`,tilde:`˜`,DiacriticalGrave:"`",DiacriticalAcute:`´`,DiacriticalTilde:`˜`,DiacriticalDot:`˙`,DiacriticalDoubleAcute:`˝`,grave:"`"},Hk={cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,euro:`€`,dollar:`$`,fnof:`ƒ`,inr:`₹`,af:`؋`,birr:`ብር`,peso:`₱`,rub:`₽`,won:`₩`,yuan:`¥`,cedil:`¸`},Uk={frac12:`½`,half:`½`,frac13:`⅓`,frac14:`¼`,frac15:`⅕`,frac16:`⅙`,frac18:`⅛`,frac23:`⅔`,frac25:`⅖`,frac34:`¾`,frac35:`⅗`,frac38:`⅜`,frac45:`⅘`,frac56:`⅚`,frac58:`⅝`,frac78:`⅞`,frasl:`⁄`},Wk={trade:`™`,TRADE:`™`,telrec:`⌕`,target:`⌖`,ulcorn:`⌜`,ulcorner:`⌜`,urcorn:`⌝`,urcorner:`⌝`,dlcorn:`⌞`,llcorner:`⌞`,drcorn:`⌟`,lrcorner:`⌟`,intercal:`⊺`,intcal:`⊺`,oplus:`⊕`,CirclePlus:`⊕`,ominus:`⊖`,CircleMinus:`⊖`,otimes:`⊗`,CircleTimes:`⊗`,osol:`⊘`,odot:`⊙`,CircleDot:`⊙`,oast:`⊛`,circledast:`⊛`,odash:`⊝`,circleddash:`⊝`,ocirc:`⊚`,circledcirc:`⊚`,boxplus:`⊞`,plusb:`⊞`,boxminus:`⊟`,minusb:`⊟`,boxtimes:`⊠`,timesb:`⊠`,boxdot:`⊡`,sdotb:`⊡`,veebar:`⊻`,vee:`∨`,barvee:`⊽`,and:`∧`,wedge:`∧`,Cap:`⋒`,Cup:`⋓`,Fork:`⋔`,pitchfork:`⋔`,epar:`⋕`,ltlarr:`⥶`,nvap:`≍⃒`,nvsim:`∼⃒`,nvge:`≥⃒`,nvle:`≤⃒`,nvlt:`<⃒`,nvgt:`>⃒`,nvltrie:`⊴⃒`,nvrtrie:`⊵⃒`,Vdash:`⊩`,dashv:`⊣`,vDash:`⊨`,Vvdash:`⊪`,nvdash:`⊬`,nvDash:`⊭`,nVdash:`⊮`,nVDash:`⊯`};({...Mk,...Nk,...Pk,...Fk,...Ik,...Lk,...Rk,...zk,...Bk,...Vk,...Hk,...Uk,...Wk});var Gk={amp:`&`,apos:`'`,gt:`>`,lt:`<`,quot:`"`},Kk={nbsp:`\xA0`,copy:`©`,reg:`®`,trade:`™`,mdash:`—`,ndash:`–`,hellip:`…`,laquo:`«`,raquo:`»`,lsquo:`‘`,rsquo:`’`,ldquo:`“`,rdquo:`”`,bull:`•`,para:`¶`,sect:`§`,deg:`°`,frac12:`½`,frac14:`¼`,frac34:`¾`},qk=Object.freeze({ALLOW:`allow`,BLOCK:`block`,THROW:`throw`}),Jk=new Set(`!?\\\\/[]$%{}^&*()<>|+`);function Yk(e){if(e[0]===`#`)throw Error(`[EntityReplacer] Invalid character '#' in entity name: "${e}"`);for(let t of e)if(Jk.has(t))throw Error(`[EntityReplacer] Invalid character '${t}' in entity name: "${e}"`);return e}function Xk(...e){let t=Object.create(null);for(let n of e)if(n)for(let e of Object.keys(n)){let r=n[e];if(typeof r==`string`)t[e]=r;else if(r&&typeof r==`object`&&r.val!==void 0){let n=r.val;typeof n==`string`&&(t[e]=n)}}return t}var Zk=`external`,Qk=`base`,$k=`all`;function eA(e){return!e||e===Zk?new Set([Zk]):e===$k?new Set([$k]):e===Qk?new Set([Qk]):Array.isArray(e)?new Set(e):new Set([Zk])}var tA=Object.freeze({allow:0,leave:1,remove:2,throw:3}),nA=new Set([9,10,13]);function rA(e){if(!e)return{xmlVersion:1,onLevel:tA.allow,nullLevel:tA.remove};let t=e.xmlVersion===1.1?1.1:1,n=tA[e.onNCR]??tA.allow,r=tA[e.nullNCR]??tA.remove;return{xmlVersion:t,onLevel:n,nullLevel:Math.max(r,tA.remove)}}var iA=class{constructor(e={}){this._limit=e.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck=typeof e.postCheck==`function`?e.postCheck:e=>e,this._limitTiers=eA(this._limit.applyLimitsTo??Zk),this._numericAllowed=e.numericAllowed??!0,this._baseMap=Xk(Gk,e.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(e.remove&&Array.isArray(e.remove)?e.remove:[]),this._leaveSet=new Set(e.leave&&Array.isArray(e.leave)?e.leave:[]);let t=rA(e.ncr);this._ncrXmlVersion=t.xmlVersion,this._ncrOnLevel=t.onLevel,this._ncrNullLevel=t.nullLevel,this._onExternalEntity=typeof e.onExternalEntity==`function`?e.onExternalEntity:null,this._onInputEntity=typeof e.onInputEntity==`function`?e.onInputEntity:null}_applyRegistrationHook(e,t,n,r){if(!e)return!0;let i=e(t,n);if(i===qk.BLOCK)return!1;if(i===qk.THROW)throw Error(`[EntityDecoder] Registration of ${r} entity "&${t};" was rejected by hook`);return!0}setExternalEntities(e){if(e)for(let t of Object.keys(e))Yk(t);if(!this._onExternalEntity){this._externalMap=Xk(e);return}let t=Xk(e),n=Object.create(null);for(let[e,r]of Object.entries(t))this._applyRegistrationHook(this._onExternalEntity,e,r,`external`)&&(n[e]=r);this._externalMap=n}addExternalEntity(e,t){Yk(e),typeof t==`string`&&t.indexOf(`&`)===-1&&this._applyRegistrationHook(this._onExternalEntity,e,t,`external`)&&(this._externalMap[e]=t)}addInputEntities(e){if(this._totalExpansions=0,this._expandedLength=0,!this._onInputEntity){this._inputMap=Xk(e);return}let t=Xk(e),n=Object.create(null);for(let[e,r]of Object.entries(t))this._applyRegistrationHook(this._onInputEntity,e,r,`input`)&&(n[e]=r);this._inputMap=n}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(e){this._ncrXmlVersion=e===1.1?1.1:1}decode(e){if(typeof e!=`string`||e.length===0||e.indexOf(`&`)===-1)return e;let t=e,n=[],r=e.length,i=0,a=0,o=this._maxTotalExpansions>0,s=this._maxExpandedLength>0,c=o||s;for(;a<r;){if(e.charCodeAt(a)!==38){a++;continue}let t=a+1;for(;t<r&&e.charCodeAt(t)!==59&&t-a<=32;)t++;if(t>=r||e.charCodeAt(t)!==59){a++;continue}let l=e.slice(a+1,t);if(l.length===0){a++;continue}let u,d;if(this._removeSet.has(l))u=``,d===void 0&&(d=Zk);else if(this._leaveSet.has(l)){a++;continue}else if(l.charCodeAt(0)===35){let e=this._resolveNCR(l);if(e===void 0){a++;continue}u=e,d=Qk}else{let e=this._resolveName(l);u=e?.value,d=e?.tier}if(u===void 0){a++;continue}if(a>i&&n.push(e.slice(i,a)),n.push(u),i=t+1,a=i,c&&this._tierCounts(d)){if(o&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(s){let e=u.length-(l.length+2);if(e>0&&(this._expandedLength+=e,this._expandedLength>this._maxExpandedLength))throw Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}i<r&&n.push(e.slice(i));let l=n.length===0?e:n.join(``);return this._postCheck(l,t)}_tierCounts(e){return this._limitTiers.has($k)?!0:this._limitTiers.has(e)}_resolveName(e){if(e in this._inputMap)return{value:this._inputMap[e],tier:Zk};if(e in this._externalMap)return{value:this._externalMap[e],tier:Zk};if(e in this._baseMap)return{value:this._baseMap[e],tier:Qk}}_classifyNCR(e){return e===0?this._ncrNullLevel:e>=55296&&e<=57343||this._ncrXmlVersion===1&&e>=1&&e<=31&&!nA.has(e)?tA.remove:-1}_applyNCRAction(e,t,n){switch(e){case tA.allow:return String.fromCodePoint(n);case tA.remove:return``;case tA.leave:return;case tA.throw:throw Error(`[EntityDecoder] Prohibited numeric character reference &${t}; (U+${n.toString(16).toUpperCase().padStart(4,`0`)})`);default:return String.fromCodePoint(n)}}_resolveNCR(e){let t=e.charCodeAt(1),n;if(n=t===120||t===88?parseInt(e.slice(2),16):parseInt(e.slice(1),10),Number.isNaN(n)||n<0||n>1114111)return;let r=this._classifyNCR(n);if(!this._numericAllowed&&r<tA.remove)return;let i=r===-1?this._ncrOnLevel:Math.max(this._ncrOnLevel,r);return this._applyNCRAction(i,e,n)}},aA=e=>pk.includes(e)?`__`+e:e,oA={preserveOrder:!1,attributeNamePrefix:`@_`,attributesGroupName:!1,textNodeName:`#text`,ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0,unicode:!1},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,n){return e},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:aA};function sA(e,t){if(typeof e!=`string`)return;let n=e.toLowerCase();if(pk.some(e=>n===e.toLowerCase())||mk.some(e=>n===e.toLowerCase()))throw Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`)}function cA(e,t){return typeof e==`boolean`?{enabled:e,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:`all`}:typeof e==`object`&&e?{enabled:e.enabled!==!1,maxEntitySize:Math.max(1,e.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,e.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,e.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,e.maxExpandedLength??1e5),maxEntityCount:Math.max(1,e.maxEntityCount??1e3),allowedTags:e.allowedTags??null,tagFilter:e.tagFilter??null,appliesTo:e.appliesTo??`all`}:cA(!0)}var lA=function(e){let t=Object.assign({},oA,e),n=[{value:t.attributeNamePrefix,name:`attributeNamePrefix`},{value:t.attributesGroupName,name:`attributesGroupName`},{value:t.textNodeName,name:`textNodeName`},{value:t.cdataPropName,name:`cdataPropName`},{value:t.commentPropName,name:`commentPropName`}];for(let{value:e,name:t}of n)e&&sA(e,t);return t.onDangerousProperty===null&&(t.onDangerousProperty=aA),t.processEntities=cA(t.processEntities,t.htmlEntities),t.unpairedTagsSet=new Set(t.unpairedTags),t.stopNodes&&Array.isArray(t.stopNodes)&&(t.stopNodes=t.stopNodes.map(e=>typeof e==`string`&&e.startsWith(`*.`)?`..`+e.substring(2):e)),t},uA=typeof Symbol==`function`?Symbol(`XML Node Metadata`):`@@xmlMetadata`,dA=class{constructor(e){this.tagname=e,this.child=[],this[`:@`]=Object.create(null)}add(e,t){e===`__proto__`&&(e=`#__proto__`),this.child.push({[e]:t})}addChild(e,t){e.tagname===`__proto__`&&(e.tagname=`#__proto__`),e[`:@`]&&Object.keys(e[`:@`]).length>0?this.child.push({[e.tagname]:e.child,":@":e[`:@`]}):this.child.push({[e.tagname]:e.child}),t!==void 0&&(this.child[this.child.length-1][uA]={startIndex:t})}static getMetaDataSymbol(){return uA}},fA=`:A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�`,pA=`:A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�\\-\\.\\d·̀-ͯ‿-⁀`,mA=`:A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿`,hA=`:A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿\\-\\.\\d·̀-ͯ҇‿-⁀`,gA=(e,t,n=``)=>{let r=`[${e.replace(`:`,``)}][${t.replace(`:`,``)}]*`;return{name:RegExp(`^[${e}][${t}]*$`,n),ncName:RegExp(`^${r}$`,n),qName:RegExp(`^${r}(?::${r})?$`,n),nmToken:RegExp(`^[${t}]+$`,n),nmTokens:RegExp(`^[${t}]+(?:\\s+[${t}]+)*$`,n)}},_A=gA(fA,pA),vA=gA(mA,hA,`u`),yA=gA(`:A-Za-z_`,`:A-Za-z_\\-\\.\\d`),bA=(e=`1.0`,t=!1)=>t?yA:e===`1.1`?vA:_A,xA=(e,{xmlVersion:t=`1.0`,asciiOnly:n=!1}={})=>bA(t,n).qName.test(e),SA=[`name`,`ncName`,`qName`,`nmToken`,`nmTokens`],CA=(e,{xmlVersion:t=`1.0`,asciiOnly:n=!1,maxCacheSize:r=2048}={})=>{if(!SA.includes(e))throw TypeError(`Unknown production "${e}". Must be one of: ${SA.join(`, `)}`);let i=bA(t,n)[e],a=new Map,o=e=>{let t=a.get(e);if(t!==void 0)return t;let n=i.test(e);return a.size<r&&a.set(e,n),n};return o.reset=()=>{a=new Map},o},wA=class{constructor(e,t){this.suppressValidationErr=!e,this.options=e,this.xmlVersion=t||1}setXmlVersion(e=1){this.xmlVersion=e}readDocType(e,t){let n=Object.create(null),r=0;if(e[t+3]===`O`&&e[t+4]===`C`&&e[t+5]===`T`&&e[t+6]===`Y`&&e[t+7]===`P`&&e[t+8]===`E`){t+=9;let i=1,a=!1,o=!1,s=``;for(;t<e.length;t++)if(e[t]===`<`&&!o){if(a&&EA(e,`!ENTITY`,t)){t+=7;let i,a;if([i,a,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),a.indexOf(`&`)===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&r>=this.options.maxEntityCount)throw Error(`Entity count (${r+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);n[i]=a,r++}}else if(a&&EA(e,`!ELEMENT`,t)){t+=8;let{index:n}=this.readElementExp(e,t+1);t=n}else if(a&&EA(e,`!ATTLIST`,t))t+=8;else if(a&&EA(e,`!NOTATION`,t)){t+=9;let{index:n}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=n}else if(EA(e,`!--`,t))o=!0;else throw Error(`Invalid DOCTYPE`);i++,s=``}else if(e[t]===`>`){if(o?e[t-1]===`-`&&e[t-2]===`-`&&(o=!1,i--):i--,i===0)break}else e[t]===`[`?a=!0:s+=e[t];if(i!==0)throw Error(`Unclosed DOCTYPE`)}else throw Error(`Invalid Tag instead of DOCTYPE`);return{entities:n,i:t}}readEntityExp(e,t){t=TA(e,t);let n=t;for(;t<e.length&&!/\s/.test(e[t])&&e[t]!==`"`&&e[t]!==`'`;)t++;let r=e.substring(n,t);if(DA(r,{xmlVersion:this.xmlVersion}),t=TA(e,t),!this.suppressValidationErr){if(e.substring(t,t+6).toUpperCase()===`SYSTEM`)throw Error(`External entities are not supported`);if(e[t]===`%`)throw Error(`Parameter entities are not supported`)}let i=``;if([t,i]=this.readIdentifierVal(e,t,`entity`),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&i.length>this.options.maxEntitySize)throw Error(`Entity "${r}" size (${i.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return t--,[r,i,t]}readNotationExp(e,t){t=TA(e,t);let n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);!this.suppressValidationErr&&DA(r,{xmlVersion:this.xmlVersion}),t=TA(e,t);let i=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&i!==`SYSTEM`&&i!==`PUBLIC`)throw Error(`Expected SYSTEM or PUBLIC, found "${i}"`);t+=i.length,t=TA(e,t);let a=null,o=null;if(i===`PUBLIC`)[t,a]=this.readIdentifierVal(e,t,`publicIdentifier`),t=TA(e,t),(e[t]===`"`||e[t]===`'`)&&([t,o]=this.readIdentifierVal(e,t,`systemIdentifier`));else if(i===`SYSTEM`&&([t,o]=this.readIdentifierVal(e,t,`systemIdentifier`),!this.suppressValidationErr&&!o))throw Error(`Missing mandatory system identifier for SYSTEM notation`);return{notationName:r,publicIdentifier:a,systemIdentifier:o,index:--t}}readIdentifierVal(e,t,n){let r=``,i=e[t];if(i!==`"`&&i!==`'`)throw Error(`Expected quoted string, found "${i}"`);t++;let a=t;for(;t<e.length&&e[t]!==i;)t++;if(r=e.substring(a,t),e[t]!==i)throw Error(`Unterminated ${n} value`);return t++,[t,r]}readElementExp(e,t){t=TA(e,t);let n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);if(!this.suppressValidationErr&&!xA(r,{xmlVersion:this.xmlVersion}))throw Error(`Invalid element name: "${r}"`);t=TA(e,t);let i=``;if(e[t]===`E`&&EA(e,`MPTY`,t))t+=4;else if(e[t]===`A`&&EA(e,`NY`,t))t+=2;else if(e[t]===`(`){t++;let n=t;for(;t<e.length&&e[t]!==`)`;)t++;if(i=e.substring(n,t),e[t]!==`)`)throw Error(`Unterminated content model`)}else if(!this.suppressValidationErr)throw Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:r,contentModel:i.trim(),index:t}}readAttlistExp(e,t){t=TA(e,t);let n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);for(DA(r,{xmlVersion:this.xmlVersion}),t=TA(e,t),n=t;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(n,t);if(!DA(i,{xmlVersion:this.xmlVersion}))throw Error(`Invalid attribute name: "${i}"`);t=TA(e,t);let a=``;if(e.substring(t,t+8).toUpperCase()===`NOTATION`){if(a=`NOTATION`,t+=8,t=TA(e,t),e[t]!==`(`)throw Error(`Expected '(', found "${e[t]}"`);t++;let n=[];for(;t<e.length&&e[t]!==`)`;){let r=t;for(;t<e.length&&e[t]!==`|`&&e[t]!==`)`;)t++;let i=e.substring(r,t);if(i=i.trim(),!DA(i,{xmlVersion:this.xmlVersion}))throw Error(`Invalid notation name: "${i}"`);n.push(i),e[t]===`|`&&(t++,t=TA(e,t))}if(e[t]!==`)`)throw Error(`Unterminated list of notations`);t++,a+=` (`+n.join(`|`)+`)`}else{let n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;if(a+=e.substring(n,t),!this.suppressValidationErr&&![`CDATA`,`ID`,`IDREF`,`IDREFS`,`ENTITY`,`ENTITIES`,`NMTOKEN`,`NMTOKENS`].includes(a.toUpperCase()))throw Error(`Invalid attribute type: "${a}"`)}t=TA(e,t);let o=``;return e.substring(t,t+8).toUpperCase()===`#REQUIRED`?(o=`#REQUIRED`,t+=8):e.substring(t,t+7).toUpperCase()===`#IMPLIED`?(o=`#IMPLIED`,t+=7):[t,o]=this.readIdentifierVal(e,t,`ATTLIST`),{elementName:r,attributeName:i,attributeType:a,defaultValue:o,index:t}}},TA=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function EA(e,t,n){for(let r=0;r<t.length;r++)if(t[r]!==e[n+r+1])return!1;return!0}function DA(e,t){if(xA(e,{xmlVersion:t}))return e;throw Error(`Invalid entity name ${e}`)}var OA=[48,1632,1776,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,65296,120782,120792,120802,120812,120822,66720,68912,69734,69872,69942,70096,70384,70736,70864,71248,71360,71472,71904,72016,72688,72784,73040,73120,73552,92768,92864,93008,123200,123632,124144,125264,130032],kA=new Map,AA=65535,jA=1632,MA=new Uint8Array(63904).fill(255);for(let e of OA)for(let t=0;t<10;t++){let n=e+t;n<=AA?MA[n-jA]=t:kA.set(n,t)}var NA=48,PA=57,FA=45,IA=new Set([8722,65293,65123]);function LA(e){if(typeof e!=`string`)return e;let t=e.length;if(t===0)return e;let n=-1;for(let r=0;r<t;r++){let i=e.charCodeAt(r);if(!(i>=NA&&i<=PA||i===FA)){if(i<1632){if(IA.has(i)){n=r;break}continue}if(i>=55296&&i<=56319){if(r+1<t){let t=e.charCodeAt(r+1);if(t>=56320&&t<=57343){let e=65536+(i-55296<<10)+(t-56320);if(kA.has(e)){n=r;break}}}continue}if(MA[i-1632]!==255||IA.has(i)){n=r;break}}}if(n===-1)return e;let r=[];n>0&&r.push(e.slice(0,n));for(let i=n;i<t;i++){let n=e.charCodeAt(i);if(n>=NA&&n<=PA||n===FA){r.push(e[i]);continue}if(n<1632){r.push(IA.has(n)?`-`:e[i]);continue}if(n>=55296&&n<=56319){if(i+1<t){let t=e.charCodeAt(i+1);if(t>=56320&&t<=57343){let e=65536+(n-55296<<10)+(t-56320),a=kA.get(e);if(a!==void 0){r.push(String.fromCharCode(a+48)),i++;continue}}}r.push(e[i]);continue}if(IA.has(n)){r.push(`-`);continue}let a=MA[n-jA];r.push(a===255?e[i]:String.fromCharCode(a+48))}return r.join(``)}var RA=/^[-+]?0x[a-fA-F0-9]+$/,zA=/^0b[01]+$/,BA=/^0o[0-7]+$/,VA=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,HA={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:`.`,eNotation:!0,infinity:`original`,unicode:!1};function UA(e,t={}){if(t=Object.assign({},HA,t),!e||typeof e!=`string`)return e;let n=e.trim();if(n.length===0||t.skipLike!==void 0&&t.skipLike.test(n))return e;if(n===`0`||t.unicode&&(n=LA(n),n===`0`))return 0;if(t.hex&&RA.test(n))return qA(n,16);if(t.binary&&zA.test(n))return qA(n,2);if(t.octal&&BA.test(n))return qA(n,8);if(!isFinite(n))return JA(e,Number(n),t);if(n.includes(`e`)||n.includes(`E`))return GA(e,n,t);{let r=VA.exec(n);if(r){let i=r[1]||``,a=r[2],o=KA(r[3]),s=i?e[a.length+1]===`.`:e[a.length]===`.`;if(!t.leadingZeros&&(a.length>1||a.length===1&&!s))return e;{let r=Number(n),s=String(r);if(r===0)return r;if(s.search(/[eE]/)!==-1)return t.eNotation?r:e;if(n.indexOf(`.`)!==-1)return s===`0`||s===o||s===`${i}${o}`?r:e;let c=a?o:n;return a?c===s||i+c===s?r:e:c===s||c===i+s?r:e}}else return e}}var WA=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function GA(e,t,n){if(!n.eNotation)return e;let r=t.match(WA);if(r){let i=r[1]||``,a=r[3].indexOf(`e`)===-1?`E`:`e`,o=r[2],s=i?e[o.length+1]===a:e[o.length]===a;return o.length>1&&s?e:o.length===1&&(r[3].startsWith(`.${a}`)||r[3][0]===a)?Number(t):o.length>0?n.leadingZeros&&!s?(t=(r[1]||``)+r[3],Number(t)):e:Number(t)}else return e}function KA(e){return e&&e.indexOf(`.`)!==-1?(e=e.replace(/0+$/,``),e===`.`?e=`0`:e[0]===`.`?e=`0`+e:e[e.length-1]===`.`&&(e=e.substring(0,e.length-1)),e):e}function qA(e,t){let n=e.trim();if((t===2||t===8)&&(e=n.substring(2)),parseInt)return parseInt(e,t);if(Number.parseInt)return Number.parseInt(e,t);if(window&&window.parseInt)return window.parseInt(e,t);throw Error(`parseInt, Number.parseInt, window.parseInt are not supported`)}function JA(e,t,n){let r=t===1/0;switch(n.infinity.toLowerCase()){case`null`:return null;case`infinity`:return t;case`string`:return r?`Infinity`:`-Infinity`;default:return e}}function YA(e){return typeof e==`function`?e:Array.isArray(e)?t=>{for(let n of e)if(typeof n==`string`&&t===n||n instanceof RegExp&&n.test(t))return!0}:()=>!1}var XA=class{constructor(e,t={},n){this.pattern=e,this.separator=t.separator||`.`,this.segments=this._parse(e),this.data=n,this._hasDeepWildcard=this.segments.some(e=>e.type===`deep-wildcard`),this._hasAttributeCondition=this.segments.some(e=>e.attrName!==void 0),this._hasPositionSelector=this.segments.some(e=>e.position!==void 0)}_parse(e){let t=[],n=0,r=``;for(;n<e.length;)e[n]===this.separator?n+1<e.length&&e[n+1]===this.separator?(r.trim()&&(t.push(this._parseSegment(r.trim())),r=``),t.push({type:`deep-wildcard`}),n+=2):(r.trim()&&t.push(this._parseSegment(r.trim())),r=``,n++):(r+=e[n],n++);return r.trim()&&t.push(this._parseSegment(r.trim())),t}_parseSegment(e){let t={type:`tag`},n=null,r=e,i=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(i&&(r=i[1]+i[3],i[2])){let e=i[2].slice(1,-1);e&&(n=e)}let a,o=r;if(r.includes(`::`)){let t=r.indexOf(`::`);if(a=r.substring(0,t).trim(),o=r.substring(t+2).trim(),!a)throw Error(`Invalid namespace in pattern: ${e}`)}let s,c=null;if(o.includes(`:`)){let e=o.lastIndexOf(`:`),t=o.substring(0,e).trim(),n=o.substring(e+1).trim();[`first`,`last`,`odd`,`even`].includes(n)||/^nth\(\d+\)$/.test(n)?(s=t,c=n):s=o}else s=o;if(!s)throw Error(`Invalid segment pattern: ${e}`);if(t.tag=s,a&&(t.namespace=a),n)if(n.includes(`=`)){let e=n.indexOf(`=`);t.attrName=n.substring(0,e).trim(),t.attrValue=n.substring(e+1).trim()}else t.attrName=n.trim();if(c){let e=c.match(/^nth\((\d+)\)$/);e?(t.position=`nth`,t.positionValue=parseInt(e[1],10)):t.position=c}return t}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}},ZA=class{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._deepByTerminalTag=new Map,this._patterns=new Set,this._sealed=!1}add(e){if(this._sealed)throw TypeError(`ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.`);if(this._patterns.has(e.pattern))return this;if(this._patterns.add(e.pattern),e.hasDeepWildcard()){let t=e.segments[e.segments.length-1];if(t&&t.type!==`deep-wildcard`&&t.tag!==`*`){let n=t.tag;this._deepByTerminalTag.has(n)||this._deepByTerminalTag.set(n,[]),this._deepByTerminalTag.get(n).push(e)}else this._deepWildcards.push(e);return this}let t=e.length,n=e.segments[e.segments.length-1]?.tag;if(!n||n===`*`)this._wildcardByDepth.has(t)||this._wildcardByDepth.set(t,[]),this._wildcardByDepth.get(t).push(e);else{let r=`${t}:${n}`;this._byDepthAndTag.has(r)||this._byDepthAndTag.set(r,[]),this._byDepthAndTag.get(r).push(e)}return this}addAll(e){for(let t of e)this.add(t);return this}has(e){return this._patterns.has(e.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(e){return this.findMatch(e)!==null}findMatch(e){let t=e.getDepth(),n=e.getCurrentTag(),r=`${t}:${n}`,i=this._byDepthAndTag.get(r);if(i){for(let t=0;t<i.length;t++)if(e.matches(i[t]))return i[t]}let a=this._wildcardByDepth.get(t);if(a){for(let t=0;t<a.length;t++)if(e.matches(a[t]))return a[t]}let o=this._deepByTerminalTag.get(n);if(o){for(let t=0;t<o.length;t++)if(e.matches(o[t]))return o[t]}for(let t=0;t<this._deepWildcards.length;t++)if(e.matches(this._deepWildcards[t]))return this._deepWildcards[t];return null}},QA=class{constructor(e){this._matcher=e}get separator(){return this._matcher.separator}getCurrentTag(){let e=this._matcher.path;return e.length>0?e[e.length-1].tag:void 0}getCurrentNamespace(){let e=this._matcher.path;return e.length>0?e[e.length-1].namespace:void 0}getAttrValue(e){let t=this._matcher.path;if(t.length!==0)return t[t.length-1].values?.[e]}hasAttr(e){let t=this._matcher.path;if(t.length===0)return!1;let n=t[t.length-1];return n.values!==void 0&&e in n.values}getAnyParentAttr(e){return this._matcher.getAnyParentAttr(e)}hasAnyParentAttr(e){return this._matcher.hasAnyParentAttr(e)}getPosition(){let e=this._matcher.path;return e.length===0?-1:e[e.length-1].position??0}getCounter(){let e=this._matcher.path;return e.length===0?-1:e[e.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(e,t=!0){return this._matcher.toString(e,t)}toArray(){return this._matcher.path.map(e=>e.tag)}matches(e){return this._matcher.matches(e)}matchesAny(e){return e.matchesAny(this._matcher)}},$A=class{constructor(e={}){this.separator=e.separator||`.`,this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new QA(this),this._keptAttrs=[]}push(e,t=null,n=null,r=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);let i=this.path.length,a=this.siblingStacks[i];a||(a={counts:new Map,total:0},this.siblingStacks[i]=a);let o=n?`${n}:${e}`:e,s=a.counts.get(o)||0,c=a.total;a.counts.set(o,s+1),a.total++;let l={tag:e,position:c,counter:s};n!=null&&(l.namespace=n),t!=null&&(l.values=t),this.path.push(l);let u=this.path.length,d=r===null?null:r.keep;if(d!=null&&d.length>0&&t)for(let e=0;e<d.length;e++){let n=d[e];t[n]!==void 0&&this._keptAttrs.push({depth:u,name:n,value:t[n]})}}pop(){if(this.path.length===0)return;this._pathStringCache=null;let e=this.path.pop();this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1);let t=this.path.length+1;for(;this._keptAttrs.length>0&&this._keptAttrs[this._keptAttrs.length-1].depth>=t;)this._keptAttrs.pop();return e}updateCurrent(e){if(this.path.length>0){let t=this.path[this.path.length-1];e!=null&&(t.values=e)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){if(this.path.length!==0)return this.path[this.path.length-1].values?.[e]}hasAttr(e){if(this.path.length===0)return!1;let t=this.path[this.path.length-1];return t.values!==void 0&&e in t.values}getAnyParentAttr(e){let t=this._keptAttrs;for(let n=t.length-1;n>=0;n--)if(t[n].name===e)return t[n].value}hasAnyParentAttr(e){let t=this._keptAttrs;for(let n=t.length-1;n>=0;n--)if(t[n].name===e)return!0;return!1}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,t=!0){let n=e||this.separator;if(n===this.separator&&t===!0){if(this._pathStringCache!==null)return this._pathStringCache;let e=this.path.map(e=>e.namespace?`${e.namespace}:${e.tag}`:e.tag).join(n);return this._pathStringCache=e,e}return this.path.map(e=>t&&e.namespace?`${e.namespace}:${e.tag}`:e.tag).join(n)}toArray(){return this.path.map(e=>e.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[],this._keptAttrs=[]}matches(e){let t=e.segments;return t.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(t):this._matchSimple(t)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let t=0;t<e.length;t++)if(!this._matchSegment(e[t],this.path[t],t===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(e){let t=this.path.length-1,n=e.length-1;for(;n>=0&&t>=0;){let r=e[n];if(r.type===`deep-wildcard`){if(n--,n<0)return!0;let r=e[n],i=!1;for(let e=t;e>=0;e--)if(this._matchSegment(r,this.path[e],e===this.path.length-1)){t=e-1,n--,i=!0;break}if(!i)return!1}else{if(!this._matchSegment(r,this.path[t],t===this.path.length-1))return!1;t--,n--}}return n<0}_matchSegment(e,t,n){if(e.tag!==`*`&&e.tag!==t.tag||e.namespace!==void 0&&e.namespace!==`*`&&e.namespace!==t.namespace||e.attrName!==void 0&&(!n||!t.values||!(e.attrName in t.values)||e.attrValue!==void 0&&String(t.values[e.attrName])!==String(e.attrValue)))return!1;if(e.position!==void 0){if(!n)return!1;let r=t.counter??0;if(e.position===`first`&&r!==0||e.position===`odd`&&r%2!=1||e.position===`even`&&r%2!=0||e.position===`nth`&&r!==e.positionValue)return!1}return!0}matchesAny(e){return e.matchesAny(this)}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>e&&{counts:new Map(e.counts),total:e.total}),keptAttrs:this._keptAttrs.map(e=>({...e}))}}restore(e){this._pathStringCache=null,this.path=e.path.map(e=>({...e})),this.siblingStacks=e.siblingStacks.map(e=>e&&{counts:new Map(e.counts),total:e.total}),this._keptAttrs=(e.keptAttrs||[]).map(e=>({...e}))}readOnly(){return this._view}},ej=[{id:`html-script-open`,description:`<script opening tag`,pattern:/<script[\s>/]/i},{id:`html-script-close`,description:`<\/script closing tag`,pattern:/<\/script[\s>]/i},{id:`html-javascript-protocol`,description:`javascript: URI scheme (with optional whitespace/encoding)`,pattern:/j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i},{id:`html-vbscript-protocol`,description:`vbscript: URI scheme`,pattern:/vbscript[\t\n\r ]*:/i},{id:`html-data-html`,description:`data:text/html URI — can execute scripts in browsers`,pattern:/data[\t\n\r ]*:[\t\n\r ]*text\/html/i},{id:`html-data-xhtml`,description:`data:application/xhtml+xml URI`,pattern:/data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i},{id:`html-data-svg`,description:`data:image/svg+xml URI — can execute scripts`,pattern:/data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i},{id:`html-inline-event-handler`,description:`Inline event handler attributes: onclick=, onerror=, onload=, etc.`,pattern:/\bon\w{1,30}\s*=/i},{id:`html-entity-obfuscated-script`,description:`HTML-entity-encoded <script (e.g. &#x3C;script or &lt;script)`,pattern:/(?:&#x0*3[Cc];?|&#0*60;?|&lt;)\s*script/i},{id:`html-entity-obfuscated-javascript`,description:`HTML-entity-encoded javascript: (partial — catches common &#106; or &#x6a; for "j")`,pattern:/(?:&#x0*6[Aa];?|&#0*106;?)\s*(?:&#x0*61;?|a)[\s\S]{0,80}script\s*:/i},{id:`html-style-expression`,description:`CSS expression() — IE-era code execution in style attributes`,pattern:/style[\s\S]{0,20}expression\s*\(/i},{id:`html-object-embed`,description:`<object or <embed tags that can load active content`,pattern:/<(?:object|embed)[\s>/]/i},{id:`html-base-tag`,description:`<base href= — can hijack all relative URLs on a page`,pattern:/<base[\s>]/i},{id:`html-meta-refresh`,description:`<meta http-equiv="refresh" — can redirect users`,pattern:/<meta[\s\S]{0,40}http-equiv[\s\S]{0,20}refresh/i},{id:`html-srcdoc`,description:`srcdoc= attribute on iframes — embeds HTML that can run scripts`,pattern:/srcdoc\s*=/i},{id:`html-iframe`,description:`<iframe tag`,pattern:/<iframe[\s>/]/i},{id:`html-form`,description:`<form tag — can be used for phishing / credential harvesting injection`,pattern:/<form[\s>/]/i}],tj=[{id:`xml-cdata-injection`,description:`CDATA section injection: <![CDATA[ breaks out of text node context`,pattern:/<!\[CDATA\[/i},{id:`xml-cdata-close`,description:`CDATA close sequence: ]]> can terminate an enclosing CDATA section`,pattern:/\]\]>/},{id:`xml-processing-instruction`,description:`XML processing instruction: <?xml-stylesheet or <?php etc.`,pattern:/<\?(?:xml[\- ]|php|asp)/i},{id:`xml-doctype-injection`,description:`DOCTYPE declaration embedded in content — can define entities`,pattern:/<!DOCTYPE(?:[\s[]|$)/i},{id:`xml-entity-system`,description:`SYSTEM keyword — used in external entity declarations (XXE)`,pattern:/\bSYSTEM\s+["']/i},{id:`xml-entity-public`,description:`PUBLIC keyword — used in external entity declarations (XXE)`,pattern:/\bPUBLIC\s+["']/i},{id:`xml-entity-declaration`,description:`<!ENTITY declaration — defines entities, potential XXE or entity expansion`,pattern:/<!ENTITY[\s%]/i},{id:`xml-billion-laughs`,description:`Entity reference chaining / billion laughs: repeated &eX; style references`,pattern:/(?:&\w{1,20};){3,}/},{id:`xml-namespace-confusion`,description:`xmlns: attribute injection — can redefine namespaces to confuse parsers`,pattern:/\bxmlns\s*(?::\w{1,40})?\s*=/i},{id:`xml-comment-injection`,description:`<!-- comment injection — can hide content from some parsers`,pattern:/<!--/},{id:`xml-comment-close`,description:`--> closes an enclosing XML comment`,pattern:/-->/},{id:`xml-pi-close`,description:`?> closes an enclosing processing instruction`,pattern:/\?>/}],nj=[{id:`svg-script-element`,description:`<script element inside SVG executes JavaScript`,pattern:/<script[\s>/]/i},{id:`svg-xlink-href-javascript`,description:`xlink:href with javascript: — classic SVG XSS via <a> or <use>`,pattern:/xlink\s*:\s*href\s*=\s*["']?\s*javascript\s*:/i},{id:`svg-href-javascript`,description:`href= with javascript: in SVG context (<a>, <animate>, etc.)`,pattern:/href\s*=\s*["']?\s*javascript\s*:/i},{id:`svg-foreignobject`,description:`<foreignObject embeds HTML inside SVG — can execute scripts`,pattern:/<foreignObject[\s>/]/i},{id:`svg-use-external`,description:`<use xlink:href or href pointing to external resource (non-fragment URL)`,pattern:/<use[\s\S]{0,60}(?:xlink\s*:\s*)?href\s*=\s*(?:["'][^#]|[^"'#\s>])/i},{id:`svg-animate-href`,description:`<animate attributeName="href" — can dynamically change href to javascript:`,pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*href["']/i},{id:`svg-animate-xlinkhref`,description:`<animate attributeName="xlink:href"`,pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*xlink\s*:\s*href["']/i},{id:`svg-set-javascript`,description:`<set to="javascript:..." — sets an attribute to a javascript: URI`,pattern:/<set[\s\S]{0,80}to\s*=\s*["']?\s*javascript\s*:/i},{id:`svg-event-handler`,description:`SVG-specific event handler attributes: onload=, onerror=, onactivate=, etc.`,pattern:/\bon(?:load|error|activate|begin|end|repeat|focus|blur|click|mouse\w{1,20}|key\w{1,20})\s*=/i},{id:`svg-handler-generic`,description:`Generic on* handler catch-all for SVG attributes`,pattern:/\bon\w{1,30}\s*=/i},{id:`svg-filter-feimage`,description:`<feImage href= — filter primitive that can load external resources`,pattern:/<feImage[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=/i},{id:`svg-image-external`,description:`<image xlink:href with http/https or javascript protocol`,pattern:/<image[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=\s*["']?\s*(?:https?|javascript)\s*:/i},{id:`svg-style-javascript`,description:`style= attribute containing javascript: (e.g. background:url(javascript:...))`,pattern:/style\s*=[\s\S]{0,60}javascript\s*:/i}],rj=[{id:`sql-block-comment-open`,description:`SQL block comment open: /* ... */ — unusual in legitimate user text`,pattern:/\/\*/},{id:`sql-union-select`,description:`UNION SELECT — most common SQL injection aggregation attack`,pattern:/\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i},{id:`sql-drop-table`,description:`DROP TABLE — destructive DDL injection`,pattern:/\bDROP\s{1,20}TABLE\b/i},{id:`sql-drop-database`,description:`DROP DATABASE — destructive DDL injection`,pattern:/\bDROP\s{1,20}DATABASE\b/i},{id:`sql-insert-into`,description:`INSERT INTO — data injection`,pattern:/\bINSERT\s{1,20}INTO\b/i},{id:`sql-delete-from`,description:`DELETE FROM — data deletion injection`,pattern:/\bDELETE\s{1,20}FROM\b/i},{id:`sql-update-set`,description:`UPDATE ... SET — data modification injection`,pattern:/\bUPDATE\b[\s\S]{1,60}\bSET\b/i},{id:`sql-exec-xp`,description:`EXEC xp_ — MSSQL extended stored procedure execution`,pattern:/\bEXEC(?:UTE)?\s{1,20}xp_/i},{id:`sql-tautology-string`,description:`Classic string tautology: ' OR '1'='1 or " OR "1"="1"`,pattern:/'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i},{id:`sql-tautology-numeric`,description:`Numeric tautology: OR 1=1`,pattern:/\bOR\s{1,10}1\s*=\s*1\b/i},{id:`sql-always-true-zero`,description:`Numeric tautology: OR 0=0`,pattern:/\bOR\s{1,10}0\s*=\s*0\b/i},{id:`sql-sleep-benchmark`,description:`Time-based blind injection: SLEEP() or BENCHMARK()`,pattern:/\b(?:SLEEP|BENCHMARK)\s*\(/i},{id:`sql-waitfor-delay`,description:`MSSQL time-based blind injection: WAITFOR DELAY`,pattern:/\bWAITFOR\s{1,20}DELAY\b/i},{id:`sql-char-function`,description:`CHAR() function — used to obfuscate injected strings`,pattern:/\bCHAR\s*\(\s*\d{1,3}/i},{id:`sql-information-schema`,description:`INFORMATION_SCHEMA — reconnaissance query for table/column enumeration`,pattern:/\bINFORMATION_SCHEMA\b/i}],ij=[{id:`shell-path-traversal-unix`,description:`Unix path traversal: ../ — climbing the directory tree`,pattern:/\.\.\//},{id:`shell-path-traversal-windows`,description:`Windows path traversal: ..\\ — climbing the directory tree`,pattern:/\.\.\\/},{id:`shell-path-traversal-encoded`,description:`URL-encoded path traversal: %2e%2e or %2f variants`,pattern:/%2e%2e|%2f\.\.|\.\.%2f/i},{id:`shell-null-byte`,description:`Null byte injection: \\x00 or %00 — truncates strings in C-backed functions`,pattern:/\x00|%00/},{id:`shell-semicolon`,description:`Semicolon command separator: cmd1; cmd2`,pattern:/;/},{id:`shell-pipe`,description:`Pipe operator: cmd1 | cmd2`,pattern:/\|/},{id:`shell-and-operator`,description:`AND operator: cmd1 && cmd2`,pattern:/&&/},{id:`shell-or-operator`,description:`OR operator: cmd1 || cmd2`,pattern:/\|\|/},{id:`shell-backtick`,description:"Backtick command substitution: `cmd`",pattern:/`/},{id:`shell-dollar-paren`,description:`Dollar-paren command substitution: $(cmd)`,pattern:/\$\(/},{id:`shell-dollar-brace`,description:"Dollar-brace variable expansion: ${var} — can be abused for injection",pattern:/\$\{/},{id:`shell-redirect-out`,description:`Output redirection: cmd > file or cmd >> file`,pattern:/>{1,2}/},{id:`shell-redirect-in`,description:`Input redirection: cmd < file`,pattern:/</},{id:`shell-newline-injection`,description:`Newline injection: \\n or \\r — can inject new shell commands`,pattern:/[\n\r]/},{id:`shell-glob-star`,description:`Glob expansion: * or ? — can expand to unintended files`,pattern:/[/\\][*?]/},{id:`shell-absolute-root`,description:`Absolute root path injection: string starting with / or \\ (Windows UNC)`,pattern:/^(?:\/|\\\\)/},{id:`shell-windows-drive`,description:`Windows drive letter path injection: C:\\ or D:/`,pattern:/^[a-zA-Z]:[/\\]/},{id:`shell-curl-wget`,description:`curl/wget with URL or flags — can exfiltrate data or download payloads`,pattern:/\b(?:curl|wget)\s+(?:https?:\/\/|ftp:\/\/|-)/i}],aj=[{id:`redos-nested-quantifier-plus`,description:`Nested + quantifier inside a group with outer quantifier: (a+)+, (.+b)*, etc.`,pattern:/\([^)]*\+[^)]*\)[+*]/},{id:`redos-nested-quantifier-star`,description:`Nested * quantifier: (a*)* or (a*)+ — catastrophic backtracking`,pattern:/\([^)]*\*[^)]*\)[*+]/},{id:`redos-nested-groups`,description:`Doubly nested quantified groups: ((a+)+) — guaranteed catastrophic`,pattern:/\(\([^)]{0,40}\)[+*]\)[+*]/},{id:`redos-alternation-overlap`,description:`Overlapping alternation under quantifier: (a|a)+ — ambiguous NFA paths`,pattern:/\(([^|()]{1,20})\|(?:\1)(?:\|[^|()]{1,20}){0,5}\)[+*?]{1,2}/},{id:`redos-star-plus-concat`,description:`(x*x)+ pattern — triggers super-linear backtracking`,pattern:/\([^)]{0,10}\*[^)]{0,10}\)[+*]/},{id:`redos-dot-star-greedy`,description:`(.*){n,} or (.+){n,} — repeated greedy dot quantifiers`,pattern:/\(\.[*+]\)\{?\d/},{id:`redos-large-repetition`,description:`Very large fixed or range repetition count {1000,} or {1000,n} — denial of service via backtracking`,pattern:/\{\d{4,}(?:,\d*)?\}/},{id:`redos-catastrophic-alternation`,description:`Long alternation with many similar branches — polynomial backtracking risk`,pattern:/\([^)]{0,200}(?:\|[^|)]{0,50}){9,}\)/}],oj=`["'\\s]*:`,sj=[{id:`nosql-where-operator`,description:`$where — executes arbitrary JavaScript server-side in MongoDB`,pattern:RegExp(`\\$where${oj}`,`i`)},{id:`nosql-ne-operator`,description:`$ne — "not equal" operator used to bypass equality checks`,pattern:RegExp(`\\$ne${oj}`,`i`)},{id:`nosql-gt-operator`,description:`$gt — "greater than" used to bypass password/value checks`,pattern:RegExp(`\\$gte?${oj}`,`i`)},{id:`nosql-lt-operator`,description:`$lt / $lte — "less than" bypass variants`,pattern:RegExp(`\\$lte?${oj}`,`i`)},{id:`nosql-regex-operator`,description:`$regex — can be used to extract data character by character (blind injection)`,pattern:RegExp(`\\$regex${oj}`,`i`)},{id:`nosql-or-operator`,description:`$or — logical OR; used to create always-true conditions`,pattern:RegExp(`\\$or${oj}\\s*\\[`,`i`)},{id:`nosql-and-operator`,description:`$and — logical AND operator injection`,pattern:RegExp(`\\$and${oj}\\s*\\[`,`i`)},{id:`nosql-nor-operator`,description:`$nor — logical NOR operator injection`,pattern:RegExp(`\\$nor${oj}\\s*\\[`,`i`)},{id:`nosql-exists-operator`,description:`$exists — can enumerate fields to determine schema`,pattern:RegExp(`\\$exists${oj}`,`i`)},{id:`nosql-in-operator`,description:`$in — matches any value in a list; can enumerate values`,pattern:RegExp(`\\$in${oj}\\s*\\[`,`i`)},{id:`nosql-expr-operator`,description:`$expr — allows aggregation expressions in queries (MongoDB 3.6+)`,pattern:RegExp(`\\$expr${oj}`,`i`)},{id:`nosql-function-operator`,description:`$function — executes arbitrary JavaScript in MongoDB 4.4+`,pattern:RegExp(`\\$function${oj}`,`i`)},{id:`nosql-accumulator-operator`,description:`$accumulator — custom aggregation with arbitrary JS execution`,pattern:RegExp(`\\$accumulator${oj}`,`i`)},{id:`nosql-proto-pollution`,description:`__proto__ — prototype pollution via object key injection`,pattern:/__proto__/},{id:`nosql-constructor-prototype`,description:`constructor.prototype — alternative prototype pollution vector (dot notation or JSON key)`,pattern:/constructor[\s"':.,{\[]*prototype/i},{id:`nosql-proto-bracket`,description:`["__proto__"] — bracket-notation prototype pollution`,pattern:/\[["']__proto__["']\]/}],cj=[{id:`log-crlf-injection`,description:`CRLF injection: literal \\r or \\n embeds fake log lines`,pattern:/[\r\n]/},{id:`log-url-encoded-crlf`,description:`URL-encoded CRLF: %0d, %0a, %0D, %0A — decoded by some log parsers`,pattern:/%0[dDaA]/},{id:`log-unicode-newline`,description:`Unicode newline variants: U+2028 (line separator), U+2029 (paragraph separator)`,pattern:/[\u2028\u2029]/},{id:`log-log4shell-jndi`,description:"Log4Shell: ${jndi:...} triggers remote code execution in Apache Log4j",pattern:/\$\{jndi\s*:/i},{id:`log-log4shell-obfuscated`,description:"Obfuscated Log4Shell: ${::-j}... lookup-bypass prefix used to evade WAF detection",pattern:/\$\{::-/},{id:`log-log4j-lookup`,description:"Log4j lookup syntax: ${env:...}, ${sys:...}, ${ctx:...} — data exfiltration",pattern:/\$\{(?:env|sys|ctx|main|map|sd|web|docker|k8s|spring)\s*:/i},{id:`log-ssti-double-brace`,description:`SSTI double-brace: {{expression}} — Jinja2, Twig, Handlebars, etc.`,pattern:/\{\{[\s\S]{0,80}\}\}/},{id:`log-ssti-hash-brace`,description:`SSTI hash-brace: #{expression} — Thymeleaf, Velocity, Ruby ERB`,pattern:/#\{[\s\S]{0,80}\}/},{id:`log-ssti-dollar-brace`,description:"SSTI/EL injection: ${expression with operators or method calls} — JSP EL, Freemarker, SpEL",pattern:/\$\{[^}]*(?:\.|\(|\*|\+|\bclass\b|\bruntime\b|\bprocess\b|\bexec\b)[^}]{0,80}\}/i},{id:`log-ssti-percent-tag`,description:`SSTI ERB/ASP tag: <%= expression %> — Ruby ERB, ASP`,pattern:/<%=[\s\S]{0,80}%>/},{id:`log-null-byte`,description:`Null byte: \\x00 or %00 — can truncate log entries in C-backed loggers`,pattern:/\x00|%00/},{id:`log-ansi-escape`,description:`ANSI escape sequence: ESC[ — can manipulate terminal output when logs are tailed`,pattern:/\x1b\[/}],lj=[{id:`sql-line-comment`,description:`SQL line comment: -- followed by whitespace or end of string`,pattern:/--(?:\s|$)/},{id:`sql-stacked-query`,description:`Stacked queries: semicolon immediately followed by a SQL keyword`,pattern:/;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i},{id:`sql-hex-encoding`,description:`Hex-encoded string injection: 0x41414141 style (MySQL)`,pattern:/\b0x[0-9a-f]{4,}/i}],uj=[...rj,...lj];ej.label=`HTML`,tj.label=`XML`,nj.label=`SVG`,rj.label=`SQL`,uj.label=`SQL-STRICT`,ij.label=`SHELL`,aj.label=`REDOS`,sj.label=`NOSQL`,cj.label=`LOG`,Object.freeze({HTML:ej,XML:tj,SVG:nj,SQL:rj,"SQL-STRICT":uj,SHELL:ij,REDOS:aj,NOSQL:sj,LOG:cj});function dj(e){if(typeof e!=`string`)throw TypeError(`is-unsafe: first argument must be a string, got ${typeof e}`)}function fj(e){if(!(e instanceof RegExp)){if(Array.isArray(e)){if(e.length===0)throw TypeError(`is-unsafe: context must not be an empty array`);if(Array.isArray(e[0])){for(let t of e)if(!Array.isArray(t)||t.length===0)throw TypeError(`is-unsafe: each context in the array must be a non-empty pattern array (PatternList)`)}return}throw TypeError(`is-unsafe: second argument must be a PatternList (e.g. HTML), an array of PatternLists (e.g. [HTML, XML]), or a RegExp. Got: ${typeof e}`)}}function pj(e){return e instanceof RegExp?{lists:null,regex:e}:Array.isArray(e[0])?{lists:e,regex:null}:{lists:[e],regex:null}}function mj(e,t){let n=t.label??`CUSTOM`;for(let r of t)if(r.pattern.test(e))return{context:n,id:r.id,description:r.description,pattern:r.pattern};return null}function hj(e,t){dj(e),fj(t);let{lists:n,regex:r}=pj(t);if(r)return r.test(e);for(let t of n)if(mj(e,t)!==null)return!0;return!1}function gj(e,t){if(!e)return{};let n=t.attributesGroupName?e[t.attributesGroupName]:e;if(!n)return{};let r={};for(let e in n)if(e.startsWith(t.attributeNamePrefix)){let i=e.substring(t.attributeNamePrefix.length);r[i]=n[e]}else r[e]=n[e];return r}function _j(e){if(!e||typeof e!=`string`)return;let t=e.indexOf(`:`);if(t!==-1&&t>0){let n=e.substring(0,t);if(n!==`xmlns`)return n}}var vj=class{constructor(e,t){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=Cj,this.parseTextData=yj,this.resolveNameSpace=bj,this.buildAttributesMap=Sj,this.isItStopNode=Dj,this.replaceEntitiesValue=Tj,this.readStopNodeData=Mj,this.saveTextToParentTag=Ej,this.addChild=wj,this.ignoreAttributesFn=YA(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0;let n={...Gk};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:(typeof this.options.htmlEntities==`object`?n=this.options.htmlEntities:this.options.htmlEntities===!0&&(n={...Kk,...Hk}),this.entityDecoder=new iA({namedEntities:{...n,...t},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo},onInputEntity:(e,t)=>hj(t,[ej,tj])?qk.BLOCK:qk.ALLOW})),this.matcher=new $A,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new ZA;let r=this.options.stopNodes;if(r&&r.length>0){for(let e=0;e<r.length;e++){let t=r[e];typeof t==`string`?this.stopNodeExpressionsSet.add(new XA(t)):t instanceof XA&&this.stopNodeExpressionsSet.add(t)}this.stopNodeExpressionsSet.seal()}}};function yj(e,t,n,r,i,a,o){let s=this.options;if(e!==void 0&&(s.trimValues&&!r&&(e=e.trim()),e.length>0)){o||(e=this.replaceEntitiesValue(e,t,n));let r=s.jPath?n.toString():n,c=s.tagValueProcessor(t,e,r,i,a);return c==null?e:typeof c!=typeof e||c!==e?c:s.trimValues||e.trim()===e?Nj(e,s.parseTagValue,s.numberParseOptions):e}}function bj(e){if(this.options.removeNSPrefix){let t=e.split(`:`),n=e.charAt(0)===`/`?`/`:``;if(t[0]===`xmlns`)return``;t.length===2&&(e=n+t[1])}return e}var xj=RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,`gm`);function Sj(e,t,n,r=!1){let i=this.options;if(r===!0||i.ignoreAttributes!==!0&&typeof e==`string`){let r=uk(e,xj),a=r.length,o={},s=Array(a),c=!1,l={};for(let e=0;e<a;e++){let t=this.resolveNameSpace(r[e][1]),a=r[e][4];if(t.length&&a!==void 0){let r=a;i.trimValues&&(r=r.trim()),r=this.replaceEntitiesValue(r,n,this.readonlyMatcher),s[e]=r,l[t]=r,c=!0}}c&&typeof t==`object`&&t.updateCurrent&&t.updateCurrent(l);let u=i.jPath?t.toString():this.readonlyMatcher,d=!1;for(let e=0;e<a;e++){let t=this.resolveNameSpace(r[e][1]);if(this.ignoreAttributesFn(t,u))continue;let n=i.attributeNamePrefix+t;if(t.length)if(i.transformAttributeName&&(n=i.transformAttributeName(n)),n=Fj(n,i),r[e][4]!==void 0){let r=s[e],a=i.attributeValueProcessor(t,r,u);a==null?o[n]=r:typeof a!=typeof r||a!==r?o[n]=a:o[n]=Nj(r,i.parseAttributeValue,i.numberParseOptions),d=!0}else i.allowBooleanAttributes&&(o[n]=!0,d=!0)}if(!d)return;if(i.attributesGroupName&&!i.preserveOrder){let e={};return e[i.attributesGroupName]=o,e}return o}}var Cj=function(e){e=e.replace(/\r\n?/g,`
307
- `);let t=new dA(`!xml`),n=t,r=``;this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;let i=this.options,a=new wA(i.processEntities),o=e.length;for(let s=0;s<o;s++)if(e[s]===`<`){let c=e.charCodeAt(s+1);if(c===47){let t=kj(e,`>`,s,`Closing Tag is not closed.`),a=e.substring(s+2,t).trim();if(i.removeNSPrefix){let e=a.indexOf(`:`);e!==-1&&(a=a.substr(e+1))}a=Pj(i.transformTagName,a,``,i).tagName,n&&(r=this.saveTextToParentTag(r,n,this.readonlyMatcher));let o=this.matcher.getCurrentTag();if(a&&i.unpairedTagsSet.has(a))throw Error(`Unpaired tag can not be used as closing tag: </${a}>`);o&&i.unpairedTagsSet.has(o)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,n=this.tagsNodeStack.pop(),r=``,s=t}else if(c===63){let t=jj(e,s,!1,`?>`);if(!t)throw Error(`Pi Tag is not closed.`);r=this.saveTextToParentTag(r,n,this.readonlyMatcher);let o=this.buildAttributesMap(t.tagExp,this.matcher,t.tagName,!0);if(o){let e=o[this.options.attributeNamePrefix+`version`];this.entityDecoder.setXmlVersion(Number(e)||1),a.setXmlVersion(Number(e)||1)}if(!(i.ignoreDeclaration&&t.tagName===`?xml`||i.ignorePiTags)){let e=new dA(t.tagName);e.add(i.textNodeName,``),t.tagName!==t.tagExp&&t.attrExpPresent&&i.ignoreAttributes!==!0&&(e[`:@`]=o),this.addChild(n,e,this.readonlyMatcher,s)}s=t.closeIndex+1}else if(c===33&&e.charCodeAt(s+2)===45&&e.charCodeAt(s+3)===45){let t=kj(e,`-->`,s+4,`Comment is not closed.`);if(i.commentPropName){let a=e.substring(s+4,t-2);r=this.saveTextToParentTag(r,n,this.readonlyMatcher),n.add(i.commentPropName,[{[i.textNodeName]:a}])}s=t}else if(c===33&&e.charCodeAt(s+2)===68){let t=a.readDocType(e,s);this.entityDecoder.addInputEntities(t.entities),s=t.i}else if(c===33&&e.charCodeAt(s+2)===91){let t=kj(e,`]]>`,s,`CDATA is not closed.`)-2,a=e.substring(s+9,t);r=this.saveTextToParentTag(r,n,this.readonlyMatcher);let o=this.parseTextData(a,n.tagname,this.readonlyMatcher,!0,!1,!0,!0);o??=``,i.cdataPropName?n.add(i.cdataPropName,[{[i.textNodeName]:a}]):n.add(i.textNodeName,o),s=t+2}else{let a=jj(e,s,i.removeNSPrefix);if(!a){let t=e.substring(Math.max(0,s-50),Math.min(o,s+50));throw Error(`readTagExp returned undefined at position ${s}. Context: "${t}"`)}let c=a.tagName,l=a.rawTagName,u=a.tagExp,d=a.attrExpPresent,f=a.closeIndex;if({tagName:c,tagExp:u}=Pj(i.transformTagName,c,u,i),i.strictReservedNames&&(c===i.commentPropName||c===i.cdataPropName||c===i.textNodeName||c===i.attributesGroupName))throw Error(`Invalid tag name: ${c}`);n&&r&&n.tagname!==`!xml`&&(r=this.saveTextToParentTag(r,n,this.readonlyMatcher,!1));let p=n;p&&i.unpairedTagsSet.has(p.tagname)&&(n=this.tagsNodeStack.pop(),this.matcher.pop());let m=!1;u.length>0&&u.lastIndexOf(`/`)===u.length-1&&(m=!0,c[c.length-1]===`/`?(c=c.substr(0,c.length-1),u=c):u=u.substr(0,u.length-1),d=c!==u);let h=null,g;g=_j(l),c!==t.tagname&&this.matcher.push(c,{},g),c!==u&&d&&(h=this.buildAttributesMap(u,this.matcher,c),h&&gj(h,i)),c!==t.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());let _=s;if(this.isCurrentNodeStopNode){let t=``;if(m)s=a.closeIndex;else if(i.unpairedTagsSet.has(c))s=a.closeIndex;else{let n=this.readStopNodeData(e,l,f+1);if(!n)throw Error(`Unexpected end of ${l}`);s=n.i,t=n.tagContent}let r=new dA(c);h&&(r[`:@`]=h),r.add(i.textNodeName,t),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(n,r,this.readonlyMatcher,_)}else{if(m){({tagName:c,tagExp:u}=Pj(i.transformTagName,c,u,i));let e=new dA(c);h&&(e[`:@`]=h),this.addChild(n,e,this.readonlyMatcher,_),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(i.unpairedTagsSet.has(c)){let e=new dA(c);h&&(e[`:@`]=h),this.addChild(n,e,this.readonlyMatcher,_),this.matcher.pop(),this.isCurrentNodeStopNode=!1,s=a.closeIndex;continue}else{let e=new dA(c);if(this.tagsNodeStack.length>i.maxNestedTags)throw Error(`Maximum nested tags exceeded`);this.tagsNodeStack.push(n),h&&(e[`:@`]=h),this.addChild(n,e,this.readonlyMatcher,_),n=e}r=``,s=f}}}else r+=e[s];return t.child};function wj(e,t,n,r){this.options.captureMetaData||(r=void 0);let i=this.options.jPath?n.toString():n,a=this.options.updateTag(t.tagname,i,t[`:@`]);a===!1||(typeof a==`string`&&(t.tagname=a),e.addChild(t,r))}function Tj(e,t,n){let r=this.options.processEntities;if(!r||!r.enabled)return e;if(r.allowedTags){let i=this.options.jPath?n.toString():n;if(!(Array.isArray(r.allowedTags)?r.allowedTags.includes(t):r.allowedTags(t,i)))return e}if(r.tagFilter){let i=this.options.jPath?n.toString():n;if(!r.tagFilter(t,i))return e}return this.entityDecoder.decode(e)}function Ej(e,t,n,r){return e&&=(r===void 0&&(r=t.child.length===0),e=this.parseTextData(e,t.tagname,n,!1,t[`:@`]?Object.keys(t[`:@`]).length!==0:!1,r),e!==void 0&&e!==``&&t.add(this.options.textNodeName,e),``),e}function Dj(){return this.stopNodeExpressionsSet.size===0?!1:this.matcher.matchesAny(this.stopNodeExpressionsSet)}function Oj(e,t,n=`>`){let r=0,i=e.length,a=n.charCodeAt(0),o=n.length>1?n.charCodeAt(1):-1,s=``,c=t;for(let n=t;n<i;n++){let t=e.charCodeAt(n);if(r)t===r&&(r=0);else if(t===34||t===39)r=t;else if(t===a)if(o!==-1){if(e.charCodeAt(n+1)===o)return s+=e.substring(c,n),{data:s,index:n}}else return s+=e.substring(c,n),{data:s,index:n};else t===9&&!r&&(s+=e.substring(c,n)+` `,c=n+1)}}function kj(e,t,n,r){let i=e.indexOf(t,n);if(i===-1)throw Error(r);return i+t.length-1}function Aj(e,t,n,r){let i=e.indexOf(t,n);if(i===-1)throw Error(r);return i}function jj(e,t,n,r=`>`){let i=Oj(e,t+1,r);if(!i)return;let a=i.data,o=i.index,s=a.search(/\s/),c=a,l=!0;s!==-1&&(c=a.substring(0,s),a=a.substring(s+1).trimStart());let u=c;if(n){let e=c.indexOf(`:`);e!==-1&&(c=c.substr(e+1),l=c!==i.data.substr(e+1))}return{tagName:c,tagExp:a,closeIndex:o,attrExpPresent:l,rawTagName:u}}function Mj(e,t,n){let r=n,i=1,a=e.length;for(;n<a;n++)if(e[n]===`<`){let a=e.charCodeAt(n+1);if(a===47){let a=Aj(e,`>`,n,`${t} is not closed`);if(e.substring(n+2,a).trim()===t&&(i--,i===0))return{tagContent:e.substring(r,n),i:a};n=a}else if(a===63)n=kj(e,`?>`,n+1,`StopNode is not closed.`);else if(a===33&&e.charCodeAt(n+2)===45&&e.charCodeAt(n+3)===45)n=kj(e,`-->`,n+3,`StopNode is not closed.`);else if(a===33&&e.charCodeAt(n+2)===91)n=kj(e,`]]>`,n,`StopNode is not closed.`)-2;else{let r=jj(e,n,!1);r&&((r&&r.tagName)===t&&r.tagExp[r.tagExp.length-1]!==`/`&&i++,n=r.closeIndex)}}}function Nj(e,t,n){if(t&&typeof e==`string`){let t=e.trim();return t===`true`?!0:t===`false`?!1:UA(e,n)}else if(fk(e))return e;else return``}function Pj(e,t,n,r){if(e){let r=e(t);n===t&&(n=r),t=r}return t=Fj(t,r),{tagName:t,tagExp:n}}function Fj(e,t){if(mk.includes(e))throw Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);return pk.includes(e)?t.onDangerousProperty(e):e}var Ij=dA.getMetaDataSymbol();function Lj(e,t){if(!e||typeof e!=`object`)return{};if(!t)return e;let n={};for(let r in e)if(r.startsWith(t)){let i=r.substring(t.length);n[i]=e[r]}else n[r]=e[r];return n}function Rj(e,t,n,r){return zj(e,t,n,r)}function zj(e,t,n,r){let i,a={};for(let o=0;o<e.length;o++){let s=e[o],c=Bj(s);if(c!==void 0&&c!==t.textNodeName){let e=Lj(s[`:@`]||{},t.attributeNamePrefix);n.push(c,e)}if(c===t.textNodeName)i===void 0?i=s[c]:i+=``+s[c];else if(c===void 0)continue;else if(s[c]){let e=zj(s[c],t,n,r),i=Hj(e,t);if(Object.keys(e).length===0&&t.alwaysCreateTextNode&&(e[t.textNodeName]=``),s[`:@`]?Vj(e,s[`:@`],r,t):Object.keys(e).length===1&&e[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?e=e[t.textNodeName]:Object.keys(e).length===0&&(t.alwaysCreateTextNode?e[t.textNodeName]=``:e=``),s[Ij]!==void 0&&typeof e==`object`&&e&&(e[Ij]=s[Ij]),a[c]!==void 0&&Object.prototype.hasOwnProperty.call(a,c))Array.isArray(a[c])||(a[c]=[a[c]]),a[c].push(e);else{let n=t.jPath?r.toString():r;t.isArray(c,n,i)?a[c]=[e]:a[c]=e}c!==void 0&&c!==t.textNodeName&&n.pop()}}return typeof i==`string`?i.length>0&&(a[t.textNodeName]=i):i!==void 0&&(a[t.textNodeName]=i),a}function Bj(e){let t=Object.keys(e);for(let e=0;e<t.length;e++){let n=t[e];if(n!==`:@`)return n}}function Vj(e,t,n,r){if(t){let i=Object.keys(t),a=i.length;for(let o=0;o<a;o++){let a=i[o],s=a.startsWith(r.attributeNamePrefix)?a.substring(r.attributeNamePrefix.length):a,c=r.jPath?n.toString()+`.`+s:n;r.isArray(a,c,!0,!0)?e[a]=[t[a]]:e[a]=t[a]}}}function Hj(e,t){let{textNodeName:n}=t,r=Object.keys(e).length;return!!(r===0||r===1&&(e[n]||typeof e[n]==`boolean`||e[n]===0))}var Uj=class{constructor(e){this.externalEntities={},this.options=lA(e)}parse(e,t){if(typeof e!=`string`&&e.toString)e=e.toString();else if(typeof e!=`string`)throw Error(`XML data is accepted in String or Bytes[] form.`);if(t){t===!0&&(t={});let n=gk(e,t);if(n!==!0)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}let n=new vj(this.options,this.externalEntities),r=n.parseXml(e);return this.options.preserveOrder||r===void 0?r:Rj(r,this.options,n.matcher,n.readonlyMatcher)}addEntity(e,t){if(t.indexOf(`&`)!==-1)throw Error(`Entity value can't have '&'`);if(e.indexOf(`&`)!==-1||e.indexOf(`;`)!==-1)throw Error(`An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'`);if(t===`&`)throw Error(`An entity with value '&' is not permitted`);this.externalEntities[e]=t}static getMetaDataSymbol(){return dA.getMetaDataSymbol()}};function Wj(e){return String(e).replace(/--/g,`- -`).replace(/--/g,`- -`).replace(/-$/,`- `)}function Gj(e){return String(e).replace(/\]\]>/g,`]]]]><![CDATA[>`)}function Kj(e){return String(e).replace(/"/g,`&quot;`).replace(/'/g,`&apos;`)}var qj=`
304
+ `,i+=64;return r+=`-----END ${e} KEY-----\r\n`,r}async function SD(e){let t=await e.publicKey.export();return CD(await crypto.subtle.exportKey(`jwk`,t))}async function CD(e){if(!e.kty)throw Error(`JWK is missing required 'kty' member`);let t=cD[e.kty];if(!t)throw Error(`Unsupported JWK kty for thumbprint: ${e.kty}`);let n={};for(let r of t){let t=e[r];if(typeof t!=`string`||t.length===0)throw Error(`JWK is missing required member '${r}' for kty=${e.kty}`);n[r]=t}let r=JSON.stringify(n),i=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(r));return Ds(new Uint8Array(i))}var wD=30,TD=`urn:authhero:tenant:`,ED=`urn:authhero:control-plane`;function DD({tenant_id:e}){return e?`${TD}${e}`:ED}function OD(e,t){if(!e||t.type!==`jwt_signing`)return;let n=e.subjectUri??DD;return{issuer:e.issuer,uri:n({tenant_id:t.tenant_id})}}function kD(e){let t=new NE(e.certificate),n=gD(e.privateKey);return{async issueCertificate(e){let{key:r,keyType:i}=await n,a=new PT(e.publicKey),o=await a.export();return(await FE.create({serialNumber:AD(),subject:e.subject,issuer:t.subject,notBefore:e.notBefore,notAfter:e.notAfter,signingAlgorithm:uD(i),publicKey:a,signingKey:r,extensions:[new LT(!1,void 0,!0),new VT(BT.digitalSignature,!0),new UT([{type:`url`,value:e.uri}]),await HT.create(o),await IT.create(t.publicKey)]})).toString(`pem`)},async getIssuerCertificates(){return[e.certificate,...e.previousCertificates??[]]}}}function AD(){let e=crypto.getRandomValues(new Uint8Array(16));return e[0]=(e[0]??0)&127,Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}function jD(e){return e.issuer!==e.subject}async function MD(e,t){if(jD(e))for(let n of t){if(n.subject!==e.issuer||!await e.verify({publicKey:n.publicKey,signatureOnly:!0}))continue;let t=new Uint8Array(e.rawData),r=await crypto.subtle.digest(`SHA-256`,t);return{x5c:[js(t),js(new Uint8Array(n.rawData))],"x5t#S256":Ds(new Uint8Array(r))}}}function ND(e){let t=new Date;return e.filter(e=>!e.revoked_at||new Date(e.revoked_at)>t).sort((e,t)=>{let n=e.current_since?new Date(e.current_since).getTime():0,r=t.current_since?new Date(t.current_since).getTime():0;return r===n?t.kid.localeCompare(e.kid):r-n})}var PD=/^[A-Za-z0-9._-]+$/;function FD(e,t){if(!PD.test(e))throw Error(`Invalid ${t}: must match ${PD}`)}var ID=1e3;async function LD(e,t,n){FD(t,`tenant_id`),FD(n,`type`);let{signingKeys:r}=await e.list({q:`type:${n} AND tenant_id:${t}`,sort:{sort_by:`created_at`,sort_order:`desc`},per_page:ID});return ND(r)}async function RD(e,t=`jwt_signing`){FD(t,`type`);let{signingKeys:n}=await e.list({q:`type:${t} AND -_exists_:tenant_id`,sort:{sort_by:`created_at`,sort_order:`desc`},per_page:ID});return ND(n)}async function zD(e,t){return e?typeof e==`string`?e:e({tenant_id:t}):`control-plane`}function BD(e,t){return t===`saml_encryption`?`tenant`:e}async function VD(e,t,n,r){let i=r.type??`jwt_signing`;if(BD(await zD(n,t),i)===`control-plane`){let t=await RD(e,i);if(r.purpose===`sign`){let e=t.find(WD);return e?[e]:[]}return t}let[a,o]=await Promise.all([LD(e,t,i),RD(e,i)]);if(r.purpose===`sign`){let e=a.find(WD)??o.find(WD);return e?[e]:[]}let s=new Set,c=[];for(let e of[...a,...o])s.has(e.kid)||(s.add(e.kid),c.push(e));return c}function HD(e){return!!(e.pkcs7&&e.cert)}function UD(e,t=new Date){return!!(e.current_since&&new Date(e.current_since)>t)}function WD(e){return HD(e)&&!UD(e)}async function GD(e,t={}){let n=t.type??`jwt_signing`,r=(t.tenantId?await LD(e,t.tenantId,n):await RD(e,n)).find(WD);if(r)return{created:!1,key:r};let i=OD(t.certificateAuthority,{type:n,tenant_id:t.tenantId}),a={...await mD({name:`CN=${t.name||t.tenantId||`authhero`}`,certificateAuthority:i,...i?{validityDays:t.certificateAuthority?.validityDays??30}:{}}),type:n,current_since:new Date().toISOString(),...t.tenantId?{tenant_id:t.tenantId}:{}};return await e.create(a),{created:!0,key:a}}async function KD(e,t){let n,r=()=>(n??=t?t.getIssuerCertificates().then(e=>e.map(e=>new NE(e))).catch(e=>(console.warn(`[authhero] could not load signing CA certificates; publishing JWKS without x5c`,e),[])):Promise.resolve([]),n);return Promise.all(e.map(async e=>{let t=new NE(e.cert),n=await t.publicKey.export(),i=await crypto.subtle.exportKey(`jwk`,n),a=i.alg??tD(i),o=jD(t)?await MD(t,await r()):void 0;return Dr.parse({...i,alg:a,use:`sig`,kid:e.kid,...o})}))}async function qD(e,t,n,r){return KD(await VD(e.keys,t,n,{purpose:`publish`}),r)}async function JD(e,t,n){return t?qD(e,t,n):KD(await RD(e.keys))}var YD={ES256:`P-256`,ES384:`P-384`,ES512:`P-521`};function XD(e){if(!(e instanceof Uint8Array))return e;let t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(e),t}function ZD(e){return`SHA-${e.slice(2)}`}async function QD(e,t){let n=XD(t);if(e.startsWith(`HS`))return crypto.subtle.importKey(`raw`,n,{name:`HMAC`,hash:ZD(e)},!1,[`sign`]);if(e.startsWith(`RS`))return crypto.subtle.importKey(`pkcs8`,n,{name:`RSASSA-PKCS1-v1_5`,hash:ZD(e)},!1,[`sign`]);let r=YD[e];if(!r)throw Error(`Unsupported JWT signing alg: ${e}`);return crypto.subtle.importKey(`pkcs8`,n,{name:`ECDSA`,namedCurve:r},!1,[`sign`])}async function $D(e,t,n,r={}){let i={alg:e,typ:`JWT`,...r.headers},a={...n};r.expiresInSeconds!==void 0&&(a.exp=Math.floor(Date.now()/1e3)+r.expiresInSeconds),r.includeIssuedTimestamp===!0&&(a.iat=Math.floor(Date.now()/1e3));let o=new TextEncoder,s=Ds(o.encode(JSON.stringify(i))),c=Ds(o.encode(JSON.stringify(a))),l=o.encode(`${s}.${c}`),u=await QD(e,t),d=await crypto.subtle.sign(e.startsWith(`ES`)?{name:`ECDSA`,hash:ZD(e)}:u.algorithm.name,u,l);return`${s}.${c}.${Ds(new Uint8Array(d))}`}function eO(e){try{let{header:t,payload:n}=(0,h.decode)(e);return typeof t!=`object`||!t||typeof n!=`object`||!n?null:{header:t,payload:n}}catch{return null}}function tO(e){switch(e){case`RS256`:case`RS384`:case`RS512`:case`ES256`:case`ES384`:case`ES512`:return e;default:throw new k(401,{message:`Unsupported JWS alg: ${e??`(missing)`}`})}}var nO=class extends k{constructor(){super(403,{message:`Invalid JWT signature`}),this.name=`JwtExpiredError`}};async function rO(e,t,n={}){try{let{header:r}=(0,h.decode)(t),i=tO(r?.alg),a=(await JD(e.env.data,n.tenantId??e.var.tenant_id,e.env.signingKeyMode)).find(e=>e.kid===r.kid);if(!a)throw new k(401,{message:`No matching kid found`});if(a.alg!==i)throw new k(401,{message:`alg mismatch between token header and JWK`});let o=nD(a,i),s=await(0,h.verify)(t,await crypto.subtle.importKey(`jwk`,a,o,!1,[`verify`]),i);if(!n.skipIssuerCheck){let t=Cc(e.env,e.var.custom_domain),r=n.additionalIssuers??[];if(s.iss!==t&&!r.includes(s.iss))throw new k(401,{message:`Invalid issuer`})}return s}catch(e){throw e instanceof p.HTTPException?e:e instanceof Error&&e.name===`JwtTokenExpired`?new nO:new k(403,{message:`Invalid JWT signature`})}}var iO=[`iss`,`sub`,`aud`,`exp`,`nbf`,`iat`,`jti`],aO=[`client_id`,`azp`,`scope`,`auth_time`,`acr`,`amr`,`act`,`sid`,`permissions`,`tenant_id`,`org_id`,`org_name`,`requested_userinfo_claims`,`gty`],oO=[`nonce`,`at_hash`,`c_hash`,`s_hash`],sO=[...iO,...aO],cO={access_token:sO,id_token:[...sO,...oO],userinfo:[...iO],service_token:sO.filter(e=>e!==`azp`),client_service_token:[...sO]};function lO(e,t,n={}){return e===`azp`&&n.allowAzpOverride?!1:cO[t].includes(e)}function uO(e,t,n,r){let i=r.ctx?.env?.unsafeAllowAzpCustomClaim===!0;return lO(t,r.kind,{allowAzpOverride:i})?(fO(t,r),!1):(e[t]=n,!0)}function dO(e,t){if(!e)return;let n={};for(let[r,i]of Object.entries(e))uO(n,r,i,t);return n}function fO(e,t){let n=`Dropped custom claim '${e}' from ${t.kind}: the claim name is reserved by the authorization server (set by ${t.source})`,r=t.ctx,i=t.tenantId??r?.var.tenant_id;if(r&&i){O(r,i,{type:E.WARNING_DURING_LOGIN,description:n}).catch(()=>{});return}console.warn(`[reserved-claims] ${n}`)}var pO=`auth-service`,mO=3600;async function hO(e){let{tenants:t,keys:n,tenantId:r,scope:i,issuer:a}=e,o=await t.get(r);if(!o)throw Error(`Tenant not found: ${r}`);let s=e.audience??o.audience;if(!s)throw Error(`Cannot mint service token: tenant "${r}" has no default audience`);let c=dO(e.customClaims,{kind:`service_token`,source:`createServiceToken(customClaims)`,tenantId:r}),l=(await VD(n,r,e.signingKeyMode,{purpose:`sign`}))[0];if(!l?.pkcs7||!l.cert)throw Error(`No signing key available`);let u=aD(l.pkcs7),d=await iD(l.cert),f=e.expiresInSeconds??mO;return{access_token:await $D(d,u,{aud:s,scope:i,sub:pO,azp:pO,iss:a,tenant_id:r,...c},{includeIssuedTimestamp:!0,expiresInSeconds:f,headers:{kid:l.kid}}),token_type:`Bearer`,expires_in:f}}async function gO(e,t,n,r,i){let a=await e.env.data.tenants.get(t);if(!a)throw Error(`Tenant not found: ${t}`);let o=Cc(e.env,e.var.custom_domain),s=a.audience??a.default_audience??`${o}userinfo`;return hO({tenants:e.env.data.tenants,keys:e.env.data.keys,tenantId:t,scope:n,issuer:o,audience:s,expiresInSeconds:r,customClaims:i,signingKeyMode:e.env.signingKeyMode})}function _O(e){return async(t,n=`webhook`)=>(await hO({tenants:e.tenants,keys:e.keys,tenantId:t,scope:n,issuer:e.issuer,signingKeyMode:e.signingKeyMode})).access_token}async function vO(e,t){let n=e.env.data.multiTenancyConfig;return n?.resolveControlPlane?(await n.resolveControlPlane({tenant_id:t}))?.tenantId:n?.controlPlaneTenantId}async function yO(e,t,n,r){let{clientId:i,scope:a}=n;if(!await e.env.data.tenants.get(t))throw Error(`Tenant not found: ${t}`);let o=t,s=await e.env.data.clients.get(t,i);if(!s&&r?.allowControlPlaneFallback){let n=await vO(e,t);if(n&&n!==t){let t=await e.env.data.clients.get(n,i);t&&(s=t,o=n)}}if(!s)throw Error(`Client not found: ${i}`);let c=(await e.env.data.clientGrants.list(o,{q:`client_id:${D(i)}`})).client_grants;if(c.length===0)throw Error(`Client has no client_grant: ${i}`);let l,u;if(n.audience){if(u=c.find(e=>e.audience===n.audience),!u)throw Error(`Client ${i} has no client_grant for audience: ${n.audience}`);l=n.audience}else if(c.length===1)u=c[0],l=u.audience;else throw Error(`audience is required: client ${i} has multiple client_grants`);let d=u.scope||[],f=a.split(/\s+/).filter(Boolean),p=f.filter(e=>!d.includes(e));if(p.length>0)throw Error(`access_denied: Client is not authorized for scope(s): ${p.join(`, `)}`);let m=dO(n.customClaims,{kind:`client_service_token`,source:`createClientServiceToken(customClaims)`,ctx:e,tenantId:o}),h=(await VD(e.env.data.keys,o,e.env.signingKeyMode,{purpose:`sign`}))[0];if(!h?.pkcs7||!h.cert)throw Error(`No signing key available`);let g=aD(h.pkcs7),_=await iD(h.cert),v=n.expiresInSeconds??mO,y={aud:l,scope:f.join(` `),sub:i,azp:i,iss:Cc(e.env),tenant_id:o,gty:`client_credentials`};return{access_token:await $D(_,g,{...m,...y},{includeIssuedTimestamp:!0,expiresInSeconds:v,headers:{kid:h.kid}}),token_type:`Bearer`,expires_in:v}}var bO=class extends Error{constructor(e){super(`Cannot update context of finalized login session ${e}`),this.name=`FinalizedLoginSessionError`}};function xO(e){return[T.COMPLETED,T.FAILED,T.EXPIRED].includes(e.state)}function SO(e){let t=JSON.stringify(e);return t===`{}`?``:t}var CO=10,wO=class extends Error{constructor(e){super(`Login session ${e} context update lost to concurrent writes`),this.name=`LoginSessionContentionError`}};async function TO(e,t,n,r,i={}){for(let a=0;a<CO;a++){let a=await e.get(t,n);if(!a)throw Error(`Login session ${n} not found`);if(xO(a))throw new bO(n);let{context:o}=Lm(a.state||T.PENDING,r,{stateData:Pm(a.state_data)});if(!o.stateData)throw Error(`Invalid context event ${r.type} for finalized or unrequested login session ${n}`);let s=SO(o.stateData);if(s===(a.state_data||``)&&Object.keys(i).length===0)return!0;let c={...i,state_data:s};if(!e.updateIfStateDataUnchanged)return e.update(t,n,c);if(await e.updateIfStateDataUnchanged(t,n,a.state_data||void 0,c))return!0}throw new wO(n)}async function EO(e,t,n,r,i){for(let a=0;a<CO;a++){let a=await e.get(t,n);if(!a)return{status:`not_found`};if(xO(a))return{status:`finalized`,session:a};let o=Pm(a.state_data),s=o[r]??0;if(s>=i)return{status:`limit_reached`,session:a};let{context:c}=Lm(a.state||T.PENDING,{type:j.UPDATE_CONTEXT,data:{[r]:s+1}},{stateData:o});if(!c.stateData)return{status:`finalized`,session:a};let l={state_data:SO(c.stateData)};if(!e.updateIfStateDataUnchanged)return await e.update(t,n,l)?{status:`reserved`,session:a}:{status:`not_found`};if(await e.updateIfStateDataUnchanged(t,n,a.state_data||void 0,l))return{status:`reserved`,session:a}}return{status:`contended`}}function DO(e,t,n,r){let{context:i}=Lm(T.PENDING,{type:j.UPDATE_CONTEXT,data:r});return e.create(t,{...n,state_data:SO(i.stateData??{})})}var OO=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,kO=32,AO=10,jO=16;function MO(e){let t=``;for(let n=AO;n>0;n--)t=OO.charAt(e%kO)+t,e=Math.floor(e/kO);return t}function NO(){let e=new Uint8Array(jO);crypto.getRandomValues(e);let t=``;for(let n=0;n<jO;n++)t+=OO.charAt(e[n]%kO);return t}function PO(){return MO(Date.now())+NO()}var FO={notFound:`Single Sign-On failed: Session Transfer Token not found or expired. This may indicate token reuse or expiration.`,deviceBinding:`Single Sign-On failed: Session Transfer Token device binding validation failed due to IP/ASN mismatch.`,organization:`Single Sign-On failed: Session Transfer Token organization mismatch detected.`,userMismatch:`Single Sign-On failed: Session Transfer Token user mismatch detected.`,parentNotFound:`Single Sign-On failed: Parent refresh token not found. Session Transfer Token won't be used for session establishment.`,methodNotAllowed:`Single Sign-On failed: Session Transfer Token authentication method is not allowed for this client.`,connectionNotEnabled:`Single Sign-On failed: Session Transfer Token user's connection is not enabled for this client.`,userUnavailable:`Single Sign-On failed: Session Transfer Token user is blocked or no longer exists.`},IO=f.z.object({session_transfer:f.z.object({family_id:f.z.string(),cascade_revocation:f.z.boolean(),asn:f.z.string().optional(),authentication:oi.optional(),organization:f.z.object({id:f.z.string(),name:f.z.string()}).optional()})});function LO(e){return typeof e==`object`&&!!e}function RO(e){let t=e.req.raw;if(!LO(t)||!LO(t.cf))return;let n=t.cf.asn;if(typeof n==`number`&&Number.isFinite(n))return String(n);if(typeof n==`string`&&n.trim())return n.trim()}function zO(e){if(e)return new Date(Date.now()+e*60*60*1e3).toISOString()}function BO(e,t){let n=hl(e)??e,r=hl(t)??t;return!!n&&!!r&&n===r}function VO(e,t){let n=t.toLowerCase();return e.connections.some(e=>e.name.toLowerCase()===n||e.strategy===t)}async function HO(e,t){let{client:n,user:r,refreshToken:i}=t,a=e.env.data,o=n.tenant.id,s=Qe(n.session_transfer),c=i.session_transfer,l=c?.family_id??i.family_id??i.id,u=s.enforce_cascade_revocation||(c?.cascade_revocation??!1),d=s.trust_forwarded_ip&&t.clientAuthenticated&&n.token_endpoint_auth_method!==`none`?hl(e.req.header(tl)):void 0,f=d??hl(e.var.ip)??e.var.ip??``,p=d?void 0:RO(e),m=t.sessionId?await a.sessions.get(o,t.sessionId):null,h={family_id:l,cascade_revocation:u,asn:p,authentication:GO(m)?m.authentication:void 0,organization:t.organization},g=Date.now(),_=60*1e3,v=await DO(a.loginSessions,o,{csrf_token:Yl(),authParams:{client_id:n.client_id,organization:t.organization?.id,scope:i.resource_servers[0]?.scopes},expires_at:new Date(g+_+6e4).toISOString(),ip:f,useragent:e.var.useragent,state:T.COMPLETED,user_id:r.user_id,auth_connection:t.authConnection,auth_strategy:t.authStrategy,authenticated_at:m?.authenticated_at},{session_transfer:h}),y=il();return await a.codes.create(o,{code_id:await al(y),code_type:el,login_id:v.id,user_id:r.user_id,expires_at:new Date(g+_).toISOString()}),y}async function UO(e,t){let{client:n}=t,r=e.env.data,i=n.tenant.id,a=Qe(n.session_transfer),o=(t,n)=>(O(e,i,{type:E.WARNING_DURING_LOGIN,description:t,userId:n}),{outcome:`rejected`});if(!a.allowed_authentication_methods.includes(t.method))return o(FO.methodNotAllowed);let s=await al(t.token),c=await r.codes.get(i,s,el);if(!c||c.used_at||!c.login_id||new Date(c.expires_at).getTime()<=Date.now()||!await r.codes.consume(i,s))return o(FO.notFound);let l=await r.loginSessions.get(i,c.login_id),u=IO.safeParse(Pm(l?.state_data)),d=u.success?u.data.session_transfer:void 0;if(!l||!d||!l.user_id)return o(FO.notFound);let f=l.user_id,p=RO(e);if(a.enforce_device_binding===`ip`){if(!BO(l.ip,e.var.ip))return o(FO.deviceBinding,f)}else if(a.enforce_device_binding===`asn`&&(!d.asn||!p||d.asn!==p))return o(FO.deviceBinding,f);if(d.organization&&t.organization&&t.organization!==d.organization.id&&t.organization!==d.organization.name)return o(FO.organization,f);if(!await r.refreshTokens.isFamilyActive(i,d.family_id))return o(FO.parentNotFound,f);let m=await r.users.get(i,f);if(!m||m.blocked||m.linked_to)return o(FO.userUnavailable,f);if(!VO(n,l.auth_connection??m.connection))return o(FO.connectionNotEnabled,f);let{existingSession:h}=t;if(h){if(h.user_id===m.user_id)return{outcome:`session_kept`};let t=new Date().toISOString();return await r.sessions.update(i,h.id,{revoked_at:t}),await id(r,i,h,t),O(e,i,{type:E.WARNING_DURING_LOGIN,description:FO.userMismatch,userId:f}),{outcome:`session_revoked`}}let g=l.authParams.client_id,_=p??``,v={client_id:g,family_id:d.family_id,cascade_revocation:d.cascade_revocation},y=await r.sessions.create(i,{id:PO(),user_id:m.user_id,login_session_id:l.id,idle_expires_at:zO(n.tenant.idle_session_lifetime),expires_at:zO(n.tenant.session_lifetime),device:{last_ip:e.var.ip||``,initial_ip:e.var.ip||``,last_user_agent:e.var.useragent||``,initial_user_agent:e.var.useragent||``,initial_asn:_,last_asn:_},clients:[n.client_id],authentication:d.authentication,session_transfer:v});return l.authenticated_at&&(await r.sessions.update(i,y.id,{authenticated_at:l.authenticated_at}),y={...y,authenticated_at:l.authenticated_at}),e.set(`session_transfer_token`,{client_id:g,scope:l.authParams.scope,request:{ip:l.ip??``,asn:d.asn,user_agent:l.useragent}}),{outcome:`session_created`,session:y}}function WO(e,t,n){return e.refreshTokens.isFamilyActive(t,n.family_id)}function GO(e,t=Date.now()){return!(!e||e.revoked_at||e.expires_at&&new Date(e.expires_at).getTime()<=t||e.idle_expires_at&&new Date(e.idle_expires_at).getTime()<=t)}var KO=300*1e3;function qO(e,t,n=Date.now()){let r=e.tenant.idle_session_lifetime;if(!r||!t.idle_expires_at)return;let i=r*60*60*1e3,a=n+i;t.expires_at&&(a=Math.min(a,new Date(t.expires_at).getTime()));let o=Math.min(KO,i/2),s=new Date(t.idle_expires_at).getTime();if(!(a-s<o))return new Date(a).toISOString()}function JO(e,t){let n=t?.session_transfer;if(!n)return{allowed:!0};let r=Qe(e.session_transfer);return r.allow_refresh_token?{allowed:!0,session_transfer:n,max_expires_at:r.enforce_online_refresh_tokens?t?.expires_at:void 0}:{allowed:!1}}var YO=new Date(`2026-08-04T00:00:00.000Z`);function XO(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}function ZO(){return{lookup:Ds(XO(7)),secret:Ds(XO(32))}}async function QO(e){return Is(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))}function $O(e,t){return`rt_${e}.${t}`}function ek(e){if(e.startsWith(`rt_`)){let t=e.slice(3),n=t.indexOf(`.`);if(n>0&&n<t.length-1)return{kind:`new`,lookup:t.slice(0,n),secret:t.slice(n+1)}}return{kind:`legacy`,id:e}}function tk(e=new Date){return e<YO}var nk={RS256:`SHA-256`,RS384:`SHA-384`,RS512:`SHA-512`,ES256:`SHA-256`,ES384:`SHA-384`,ES512:`SHA-512`,HS256:`SHA-256`,HS384:`SHA-384`,HS512:`SHA-512`};async function rk(e,t){let n=nk[t];if(!n)throw Error(`Cannot compute id_token hash: unsupported signing alg ${t}`);let r=new TextEncoder().encode(e),i=await crypto.subtle.digest(n,r),a=new Uint8Array(i);return Ds(a.slice(0,a.length/2))}var ik=f.z.object({"#text":f.z.string()}),ak=f.z.object({"#text":f.z.string(),"@_xmlns:saml":f.z.string().optional()});f.z.object({"samlp:AuthnRequest":f.z.object({"saml:Issuer":ak,"@_xmlns:samlp":f.z.string(),"@_xmlns:saml":f.z.string().optional(),"@_ForceAuthn":f.z.string().transform(e=>e.toLowerCase()===`true`).optional(),"@_ID":f.z.string(),"@_IssueInstant":f.z.string().datetime(),"@_Destination":f.z.string().url(),"@_AssertionConsumerServiceURL":f.z.string().url().optional(),"@_ProtocolBinding":f.z.string().optional(),"@_Version":f.z.string()})});var ok=f.z.object({"samlp:LogoutRequest":f.z.object({"saml:Issuer":ak,"saml:NameID":f.z.object({"#text":f.z.string()}).optional(),"samlp:SessionIndex":f.z.object({"#text":f.z.string()}).optional(),"@_ID":f.z.string(),"@_Version":f.z.string().optional(),"@_Destination":f.z.string().optional()})});f.z.array(f.z.object({":@":f.z.object({"@_xmlns":f.z.string(),"@_entityID":f.z.string()}),EntityDescriptor:f.z.array(f.z.object({":@":f.z.object({"@_protocolSupportEnumeration":f.z.string()}),IDPSSODescriptor:f.z.array(f.z.union([f.z.object({KeyDescriptor:f.z.array(f.z.object({KeyInfo:f.z.array(f.z.object({X509Data:f.z.array(f.z.object({X509Certificate:f.z.array(ik)}))})),":@":f.z.object({"@_xmlns":f.z.string()})})),":@":f.z.object({"@_use":f.z.string()})}),f.z.object({SingleLogoutService:f.z.array(f.z.object({})),":@":f.z.object({"@_Binding":f.z.string(),"@_Location":f.z.string()})}),f.z.object({NameIDFormat:f.z.array(ik)}),f.z.object({SingleSignOnService:f.z.array(f.z.object({})),":@":f.z.object({"@_Binding":f.z.string(),"@_Location":f.z.string()})}),f.z.object({Attribute:f.z.array(f.z.object({})),":@":f.z.object({"@_Name":f.z.string(),"@_NameFormat":f.z.string(),"@_FriendlyName":f.z.string(),"@_xmlns":f.z.string()})})]))}))}));var sk=f.z.object({"saml:Attribute":f.z.array(f.z.object({"saml:AttributeValue":f.z.array(f.z.object({"#text":f.z.string()})),":@":f.z.object({"@_xmlns:xs":f.z.string().optional(),"@_xmlns:xsi":f.z.string(),"@_xsi:type":f.z.string()}).optional()})),":@":f.z.object({"@_Name":f.z.string(),"@_NameFormat":f.z.string(),"@_FriendlyName":f.z.string().optional()})}),ck=f.z.object({"ds:Transform":f.z.array(f.z.any()),":@":f.z.object({"@_Algorithm":f.z.string()})}),lk=f.z.object({"ds:Signature":f.z.array(f.z.union([f.z.object({"ds:SignedInfo":f.z.array(f.z.union([f.z.object({"ds:CanonicalizationMethod":f.z.array(f.z.object({":@":f.z.object({"@_Algorithm":f.z.string()})}))}),f.z.object({"ds:SignatureMethod":f.z.array(f.z.object({":@":f.z.object({"@_Algorithm":f.z.string()})}))}),f.z.object({"ds:Reference":f.z.array(f.z.union([f.z.object({"ds:Transforms":f.z.array(ck)}),f.z.object({"ds:DigestMethod":f.z.array(f.z.object({":@":f.z.object({"@_Algorithm":f.z.string()})}))}),f.z.object({"ds:DigestValue":f.z.array(ik)})])),":@":f.z.object({"@_URI":f.z.string().optional()}).optional()})]))}),f.z.object({"ds:SignatureValue":f.z.array(ik)}),f.z.object({"ds:KeyInfo":f.z.array(f.z.union([f.z.object({"ds:KeyValue":f.z.array(f.z.object({"ds:RSAKeyValue":f.z.array(f.z.union([f.z.object({"ds:Modulus":f.z.array(ik)}),f.z.object({"ds:Exponent":f.z.array(ik)})]))}))}),f.z.object({"ds:X509Data":f.z.array(f.z.object({"ds:X509Certificate":f.z.array(ik)}))}),f.z.object({"ds:KeyValue":f.z.array(f.z.object({"ds:RSAKeyValue":f.z.array(f.z.union([f.z.object({"ds:Modulus":f.z.array(ik)}),f.z.object({"ds:Exponent":f.z.array(ik)})]))})),"ds:X509Data":f.z.array(f.z.object({"ds:X509Certificate":f.z.array(ik)}))})]))})])),":@":f.z.object({"@_xmlns:ds":f.z.string().optional()}).optional()});f.z.array(f.z.object({"samlp:Response":f.z.array(f.z.union([f.z.object({"saml:Issuer":f.z.array(ik)}),lk,f.z.object({"samlp:Status":f.z.array(f.z.object({"samlp:StatusCode":f.z.array(ik),":@":f.z.object({"@_Value":f.z.string()})}))}),f.z.object({"saml:Assertion":f.z.array(f.z.union([f.z.object({"saml:Issuer":f.z.array(ik)}),lk,f.z.object({"saml:Subject":f.z.array(f.z.union([f.z.object({"saml:NameID":f.z.array(ik),":@":f.z.object({"@_Format":f.z.string()})}),f.z.object({"saml:SubjectConfirmation":f.z.array(f.z.object({"saml:SubjectConfirmationData":f.z.array(f.z.any()),":@":f.z.object({"@_InResponseTo":f.z.string(),"@_NotOnOrAfter":f.z.string(),"@_Recipient":f.z.string()})})),":@":f.z.object({"@_Method":f.z.string()})})]))}),f.z.object({"saml:Conditions":f.z.array(f.z.object({"saml:AudienceRestriction":f.z.array(f.z.object({"saml:Audience":f.z.array(ik)}))})),":@":f.z.object({"@_NotBefore":f.z.string(),"@_NotOnOrAfter":f.z.string()})}),f.z.object({"saml:AuthnStatement":f.z.array(f.z.object({"saml:AuthnContext":f.z.array(f.z.object({"saml:AuthnContextClassRef":f.z.array(ik)}))})),":@":f.z.object({"@_AuthnInstant":f.z.string(),"@_SessionIndex":f.z.string(),"@_SessionNotOnOrAfter":f.z.string()})}),f.z.object({"saml:AttributeStatement":f.z.array(sk)})])),":@":f.z.object({"@_xmlns":f.z.string(),"@_ID":f.z.string(),"@_IssueInstant":f.z.string(),"@_Version":f.z.string()})})])),":@":f.z.object({"@_xmlns:samlp":f.z.string(),"@_xmlns:saml":f.z.string(),"@_Destination":f.z.string(),"@_ID":f.z.string(),"@_InResponseTo":f.z.string(),"@_IssueInstant":f.z.string(),"@_Version":f.z.string()})}));var uk=RegExp(`^[:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`);function dk(e,t){let n=[],r=t.exec(e);for(;r;){let i=[];i.startIndex=t.lastIndex-r[0].length;let a=r.length;for(let e=0;e<a;e++)i.push(r[e]);n.push(i),r=t.exec(e)}return n}var fk=function(e){return uk.exec(e)!=null};function pk(e){return e!==void 0}var mk=[`hasOwnProperty`,`toString`,`valueOf`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`],hk=[`__proto__`,`constructor`,`prototype`],gk={allowBooleanAttributes:!1,unpairedTags:[]};function _k(e,t){t=Object.assign({},gk,t);let n=[],r=!1,i=!1;e[0]===``&&(e=e.substr(1));for(let a=0;a<e.length;a++)if(e[a]===`<`&&e[a+1]===`?`){if(a+=2,a=yk(e,a),a.err)return a}else if(e[a]===`<`){let o=a;if(a++,e[a]===`!`){a=bk(e,a);continue}else{let s=!1;e[a]===`/`&&(s=!0,a++);let c=``;for(;a<e.length&&e[a]!==`>`&&e[a]!==` `&&e[a]!==` `&&e[a]!==`
305
+ `&&e[a]!==`\r`;a++)c+=e[a];if(c=c.trim(),c[c.length-1]===`/`&&(c=c.substring(0,c.length-1),a--),!kk(c)){let t;return t=c.trim().length===0?`Invalid space after '<'.`:`Tag '`+c+`' is an invalid name.`,Z(`InvalidTag`,t,Ak(e,a))}let l=Ck(e,a);if(l===!1)return Z(`InvalidAttr`,`Attributes for '`+c+`' have open quote.`,Ak(e,a));let u=l.value;if(a=l.index,u[u.length-1]===`/`){let n=a-u.length;u=u.substring(0,u.length-1);let i=Tk(u,t);if(i===!0)r=!0;else return Z(i.err.code,i.err.msg,Ak(e,n+i.err.line))}else if(s){if(!l.tagClosed)return Z(`InvalidTag`,`Closing tag '`+c+`' doesn't have proper closing.`,Ak(e,a));if(u.trim().length>0)return Z(`InvalidTag`,`Closing tag '`+c+`' can't have attributes or invalid starting.`,Ak(e,o));if(n.length===0)return Z(`InvalidTag`,`Closing tag '`+c+`' has not been opened.`,Ak(e,o));{let t=n.pop();if(c!==t.tagName){let n=Ak(e,t.tagStartPos);return Z(`InvalidTag`,`Expected closing tag '`+t.tagName+`' (opened in line `+n.line+`, col `+n.col+`) instead of closing tag '`+c+`'.`,Ak(e,o))}n.length==0&&(i=!0)}}else{let s=Tk(u,t);if(s!==!0)return Z(s.err.code,s.err.msg,Ak(e,a-u.length+s.err.line));if(i===!0)return Z(`InvalidXml`,`Multiple possible root nodes found.`,Ak(e,a));t.unpairedTags.indexOf(c)!==-1||n.push({tagName:c,tagStartPos:o}),r=!0}for(a++;a<e.length;a++)if(e[a]===`<`)if(e[a+1]===`!`){a++,a=bk(e,a);continue}else if(e[a+1]===`?`){if(a=yk(e,++a),a.err)return a}else break;else if(e[a]===`&`){let t=Dk(e,a);if(t==-1)return Z(`InvalidChar`,`char '&' is not expected.`,Ak(e,a));a=t}else if(i===!0&&!vk(e[a]))return Z(`InvalidXml`,`Extra text at the end`,Ak(e,a));e[a]===`<`&&a--}}else{if(vk(e[a]))continue;return Z(`InvalidChar`,`char '`+e[a]+`' is not expected.`,Ak(e,a))}return r?n.length==1?Z(`InvalidTag`,`Unclosed tag '`+n[0].tagName+`'.`,Ak(e,n[0].tagStartPos)):n.length>0?Z(`InvalidXml`,`Invalid '`+JSON.stringify(n.map(e=>e.tagName),null,4).replace(/\r?\n/g,``)+`' found.`,{line:1,col:1}):!0:Z(`InvalidXml`,`Start tag expected.`,1)}function vk(e){return e===` `||e===` `||e===`
306
+ `||e===`\r`}function yk(e,t){let n=t;for(;t<e.length;t++)if(e[t]==`?`||e[t]==` `){let r=e.substr(n,t-n);if(t>5&&r===`xml`)return Z(`InvalidXml`,`XML declaration allowed only at the start of the document.`,Ak(e,t));if(e[t]==`?`&&e[t+1]==`>`){t++;break}else continue}return t}function bk(e,t){if(e.length>t+5&&e[t+1]===`-`&&e[t+2]===`-`){for(t+=3;t<e.length;t++)if(e[t]===`-`&&e[t+1]===`-`&&e[t+2]===`>`){t+=2;break}}else if(e.length>t+8&&e[t+1]===`D`&&e[t+2]===`O`&&e[t+3]===`C`&&e[t+4]===`T`&&e[t+5]===`Y`&&e[t+6]===`P`&&e[t+7]===`E`){let n=1;for(t+=8;t<e.length;t++)if(e[t]===`<`)n++;else if(e[t]===`>`&&(n--,n===0))break}else if(e.length>t+9&&e[t+1]===`[`&&e[t+2]===`C`&&e[t+3]===`D`&&e[t+4]===`A`&&e[t+5]===`T`&&e[t+6]===`A`&&e[t+7]===`[`){for(t+=8;t<e.length;t++)if(e[t]===`]`&&e[t+1]===`]`&&e[t+2]===`>`){t+=2;break}}return t}var xk=`"`,Sk=`'`;function Ck(e,t){let n=``,r=``,i=!1;for(;t<e.length;t++){if(e[t]===xk||e[t]===Sk)r===``?r=e[t]:r!==e[t]||(r=``);else if(e[t]===`>`&&r===``){i=!0;break}n+=e[t]}return r===``?{value:n,index:t,tagClosed:i}:!1}var wk=RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,`g`);function Tk(e,t){let n=dk(e,wk),r={};for(let e=0;e<n.length;e++){if(n[e][1].length===0)return Z(`InvalidAttr`,`Attribute '`+n[e][2]+`' has no space in starting.`,jk(n[e]));if(n[e][3]!==void 0&&n[e][4]===void 0)return Z(`InvalidAttr`,`Attribute '`+n[e][2]+`' is without value.`,jk(n[e]));if(n[e][3]===void 0&&!t.allowBooleanAttributes)return Z(`InvalidAttr`,`boolean attribute '`+n[e][2]+`' is not allowed.`,jk(n[e]));let i=n[e][2];if(!Ok(i))return Z(`InvalidAttr`,`Attribute '`+i+`' is an invalid name.`,jk(n[e]));if(!Object.prototype.hasOwnProperty.call(r,i))r[i]=1;else return Z(`InvalidAttr`,`Attribute '`+i+`' is repeated.`,jk(n[e]))}return!0}function Ek(e,t){let n=/\d/;for(e[t]===`x`&&(t++,n=/[\da-fA-F]/);t<e.length;t++){if(e[t]===`;`)return t;if(!e[t].match(n))break}return-1}function Dk(e,t){if(t++,e[t]===`;`)return-1;if(e[t]===`#`)return t++,Ek(e,t);let n=0;for(;t<e.length;t++,n++)if(!(e[t].match(/\w/)&&n<20)){if(e[t]===`;`)break;return-1}return t}function Z(e,t,n){return{err:{code:e,msg:t,line:n.line||n,col:n.col}}}function Ok(e){return fk(e)}function kk(e){return fk(e)}function Ak(e,t){let n=e.substring(0,t).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function jk(e){return e.startIndex+e[1].length}var Mk={amp:`&`,AMP:`&`,lt:`<`,LT:`<`,gt:`>`,GT:`>`,quot:`"`,QUOT:`"`,apos:`'`,lsquo:`‘`,rsquo:`’`,ldquo:`“`,rdquo:`”`,lsquor:`‚`,rsquor:`’`,ldquor:`„`,bdquo:`„`,comma:`,`,period:`.`,colon:`:`,semi:`;`,excl:`!`,quest:`?`,num:`#`,dollar:`$`,percent:`%`,ast:`*`,commat:`@`,lowbar:`_`,verbar:`|`,vert:`|`,sol:`/`,bsol:`\\`,lbrace:`{`,rbrace:`}`,lbrack:`[`,rbrack:`]`,lpar:`(`,rpar:`)`,nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,COPY:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:`­`,reg:`®`,REG:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,half:`½`,frac34:`¾`,iquest:`¿`,times:`×`,div:`÷`,divide:`÷`},Nk={Agrave:`À`,agrave:`à`,Aacute:`Á`,aacute:`á`,Acirc:`Â`,acirc:`â`,Atilde:`Ã`,atilde:`ã`,Auml:`Ä`,auml:`ä`,Aring:`Å`,aring:`å`,AElig:`Æ`,aelig:`æ`,Ccedil:`Ç`,ccedil:`ç`,Egrave:`È`,egrave:`è`,Eacute:`É`,eacute:`é`,Ecirc:`Ê`,ecirc:`ê`,Euml:`Ë`,euml:`ë`,Igrave:`Ì`,igrave:`ì`,Iacute:`Í`,iacute:`í`,Icirc:`Î`,icirc:`î`,Iuml:`Ï`,iuml:`ï`,ETH:`Ð`,eth:`ð`,Ntilde:`Ñ`,ntilde:`ñ`,Ograve:`Ò`,ograve:`ò`,Oacute:`Ó`,oacute:`ó`,Ocirc:`Ô`,ocirc:`ô`,Otilde:`Õ`,otilde:`õ`,Ouml:`Ö`,ouml:`ö`,Oslash:`Ø`,oslash:`ø`,Ugrave:`Ù`,ugrave:`ù`,Uacute:`Ú`,uacute:`ú`,Ucirc:`Û`,ucirc:`û`,Uuml:`Ü`,uuml:`ü`,Yacute:`Ý`,yacute:`ý`,THORN:`Þ`,thorn:`þ`,szlig:`ß`,yuml:`ÿ`,Yuml:`Ÿ`},Pk={Amacr:`Ā`,amacr:`ā`,Abreve:`Ă`,abreve:`ă`,Aogon:`Ą`,aogon:`ą`,Cacute:`Ć`,cacute:`ć`,Ccirc:`Ĉ`,ccirc:`ĉ`,Cdot:`Ċ`,cdot:`ċ`,Ccaron:`Č`,ccaron:`č`,Dcaron:`Ď`,dcaron:`ď`,Dstrok:`Đ`,dstrok:`đ`,Emacr:`Ē`,emacr:`ē`,Ecaron:`Ě`,ecaron:`ě`,Edot:`Ė`,edot:`ė`,Eogon:`Ę`,eogon:`ę`,Gcirc:`Ĝ`,gcirc:`ĝ`,Gbreve:`Ğ`,gbreve:`ğ`,Gdot:`Ġ`,gdot:`ġ`,Gcedil:`Ģ`,Hcirc:`Ĥ`,hcirc:`ĥ`,Hstrok:`Ħ`,hstrok:`ħ`,Itilde:`Ĩ`,itilde:`ĩ`,Imacr:`Ī`,imacr:`ī`,Iogon:`Į`,iogon:`į`,Idot:`İ`,IJlig:`IJ`,ijlig:`ij`,Jcirc:`Ĵ`,jcirc:`ĵ`,Kcedil:`Ķ`,kcedil:`ķ`,kgreen:`ĸ`,Lacute:`Ĺ`,lacute:`ĺ`,Lcedil:`Ļ`,lcedil:`ļ`,Lcaron:`Ľ`,lcaron:`ľ`,Lmidot:`Ŀ`,lmidot:`ŀ`,Lstrok:`Ł`,lstrok:`ł`,Nacute:`Ń`,nacute:`ń`,Ncaron:`Ň`,ncaron:`ň`,Ncedil:`Ņ`,ncedil:`ņ`,ENG:`Ŋ`,eng:`ŋ`,Omacr:`Ō`,omacr:`ō`,Odblac:`Ő`,odblac:`ő`,OElig:`Œ`,oelig:`œ`,Racute:`Ŕ`,racute:`ŕ`,Rcaron:`Ř`,rcaron:`ř`,Rcedil:`Ŗ`,rcedil:`ŗ`,Sacute:`Ś`,sacute:`ś`,Scirc:`Ŝ`,scirc:`ŝ`,Scedil:`Ş`,scedil:`ş`,Scaron:`Š`,scaron:`š`,Tcedil:`Ţ`,tcedil:`ţ`,Tcaron:`Ť`,tcaron:`ť`,Tstrok:`Ŧ`,tstrok:`ŧ`,Utilde:`Ũ`,utilde:`ũ`,Umacr:`Ū`,umacr:`ū`,Ubreve:`Ŭ`,ubreve:`ŭ`,Uring:`Ů`,uring:`ů`,Udblac:`Ű`,udblac:`ű`,Uogon:`Ų`,uogon:`ų`,Wcirc:`Ŵ`,wcirc:`ŵ`,Ycirc:`Ŷ`,ycirc:`ŷ`,Zacute:`Ź`,zacute:`ź`,Zdot:`Ż`,zdot:`ż`,Zcaron:`Ž`,zcaron:`ž`},Fk={Alpha:`Α`,alpha:`α`,Beta:`Β`,beta:`β`,Gamma:`Γ`,gamma:`γ`,Delta:`Δ`,delta:`δ`,Epsilon:`Ε`,epsilon:`ε`,epsiv:`ϵ`,varepsilon:`ϵ`,Zeta:`Ζ`,zeta:`ζ`,Eta:`Η`,eta:`η`,Theta:`Θ`,theta:`θ`,thetasym:`ϑ`,vartheta:`ϑ`,Iota:`Ι`,iota:`ι`,Kappa:`Κ`,kappa:`κ`,kappav:`ϰ`,varkappa:`ϰ`,Lambda:`Λ`,lambda:`λ`,Mu:`Μ`,mu:`μ`,Nu:`Ν`,nu:`ν`,Xi:`Ξ`,xi:`ξ`,Omicron:`Ο`,omicron:`ο`,Pi:`Π`,pi:`π`,piv:`ϖ`,varpi:`ϖ`,Rho:`Ρ`,rho:`ρ`,rhov:`ϱ`,varrho:`ϱ`,Sigma:`Σ`,sigma:`σ`,sigmaf:`ς`,sigmav:`ς`,varsigma:`ς`,Tau:`Τ`,tau:`τ`,Upsilon:`Υ`,upsilon:`υ`,upsi:`υ`,Upsi:`ϒ`,upsih:`ϒ`,Phi:`Φ`,phi:`φ`,phiv:`ϕ`,varphi:`ϕ`,Chi:`Χ`,chi:`χ`,Psi:`Ψ`,psi:`ψ`,Omega:`Ω`,omega:`ω`,ohm:`Ω`,Gammad:`Ϝ`,gammad:`ϝ`,digamma:`ϝ`},Ik={Afr:`𝔄`,afr:`𝔞`,Acy:`А`,acy:`а`,Bcy:`Б`,bcy:`б`,Vcy:`В`,vcy:`в`,Gcy:`Г`,gcy:`г`,Dcy:`Д`,dcy:`д`,IEcy:`Е`,iecy:`е`,IOcy:`Ё`,iocy:`ё`,ZHcy:`Ж`,zhcy:`ж`,Zcy:`З`,zcy:`з`,Icy:`И`,icy:`и`,Jcy:`Й`,jcy:`й`,Kcy:`К`,kcy:`к`,Lcy:`Л`,lcy:`л`,Mcy:`М`,mcy:`м`,Ncy:`Н`,ncy:`н`,Ocy:`О`,ocy:`о`,Pcy:`П`,pcy:`п`,Rcy:`Р`,rcy:`р`,Scy:`С`,scy:`с`,Tcy:`Т`,tcy:`т`,Ucy:`У`,ucy:`у`,Fcy:`Ф`,fcy:`ф`,KHcy:`Х`,khcy:`х`,TScy:`Ц`,tscy:`ц`,CHcy:`Ч`,chcy:`ч`,SHcy:`Ш`,shcy:`ш`,SHCHcy:`Щ`,shchcy:`щ`,HARDcy:`Ъ`,hardcy:`ъ`,Ycy:`Ы`,ycy:`ы`,SOFTcy:`Ь`,softcy:`ь`,Ecy:`Э`,ecy:`э`,YUcy:`Ю`,yucy:`ю`,YAcy:`Я`,yacy:`я`,DJcy:`Ђ`,djcy:`ђ`,GJcy:`Ѓ`,gjcy:`ѓ`,Jukcy:`Є`,jukcy:`є`,DScy:`Ѕ`,dscy:`ѕ`,Iukcy:`І`,iukcy:`і`,YIcy:`Ї`,yicy:`ї`,Jsercy:`Ј`,jsercy:`ј`,LJcy:`Љ`,ljcy:`љ`,NJcy:`Њ`,njcy:`њ`,TSHcy:`Ћ`,tshcy:`ћ`,KJcy:`Ќ`,kjcy:`ќ`,Ubrcy:`Ў`,ubrcy:`ў`,DZcy:`Џ`,dzcy:`џ`},Lk={plus:`+`,pm:`±`,times:`×`,div:`÷`,divide:`÷`,sdot:`⋅`,star:`☆`,starf:`★`,bigstar:`★`,lowast:`∗`,ast:`*`,midast:`*`,compfn:`∘`,smallcircle:`∘`,bullet:`•`,bull:`•`,nbsp:`\xA0`,hellip:`…`,mldr:`…`,prime:`′`,Prime:`″`,tprime:`‴`,bprime:`‵`,backprime:`‵`,minus:`−`,minusd:`∸`,dotminus:`∸`,plusdo:`∔`,dotplus:`∔`,plusmn:`±`,minusplus:`∓`,mnplus:`∓`,mp:`∓`,setminus:`∖`,smallsetminus:`∖`,Backslash:`∖`,setmn:`∖`,ssetmn:`∖`,lowbar:`_`,verbar:`|`,vert:`|`,VerticalLine:`|`,colon:`:`,Colon:`∷`,Proportion:`∷`,ratio:`∶`,equals:`=`,ne:`≠`,nequiv:`≢`,equiv:`≡`,Congruent:`≡`,sim:`∼`,thicksim:`∼`,thksim:`∼`,sime:`≃`,simeq:`≃`,TildeEqual:`≃`,asymp:`≈`,approx:`≈`,thickapprox:`≈`,thkap:`≈`,TildeTilde:`≈`,ncong:`≇`,cong:`≅`,TildeFullEqual:`≅`,asympeq:`≍`,CupCap:`≍`,bump:`≎`,Bumpeq:`≎`,HumpDownHump:`≎`,bumpe:`≏`,bumpeq:`≏`,HumpEqual:`≏`,le:`≤`,LessEqual:`≤`,ge:`≥`,GreaterEqual:`≥`,lesseqgtr:`⋚`,lesseqqgtr:`⪋`,greater:`>`,less:`<`},Rk={alefsym:`ℵ`,aleph:`ℵ`,beth:`ℶ`,gimel:`ℷ`,daleth:`ℸ`,forall:`∀`,ForAll:`∀`,part:`∂`,PartialD:`∂`,exist:`∃`,Exists:`∃`,nexist:`∄`,nexists:`∄`,empty:`∅`,emptyset:`∅`,emptyv:`∅`,varnothing:`∅`,nabla:`∇`,Del:`∇`,isin:`∈`,isinv:`∈`,in:`∈`,Element:`∈`,notin:`∉`,notinva:`∉`,ni:`∋`,niv:`∋`,SuchThat:`∋`,ReverseElement:`∋`,notni:`∌`,notniva:`∌`,prod:`∏`,Product:`∏`,coprod:`∐`,Coproduct:`∐`,sum:`∑`,Sum:`∑`,minus:`−`,mp:`∓`,plusdo:`∔`,dotplus:`∔`,setminus:`∖`,lowast:`∗`,radic:`√`,Sqrt:`√`,prop:`∝`,propto:`∝`,Proportional:`∝`,varpropto:`∝`,infin:`∞`,infintie:`⧝`,ang:`∠`,angle:`∠`,angmsd:`∡`,measuredangle:`∡`,angsph:`∢`,mid:`∣`,VerticalBar:`∣`,nmid:`∤`,nsmid:`∤`,npar:`∦`,parallel:`∥`,spar:`∥`,nparallel:`∦`,nspar:`∦`,and:`∧`,wedge:`∧`,or:`∨`,vee:`∨`,cap:`∩`,cup:`∪`,int:`∫`,Integral:`∫`,conint:`∮`,ContourIntegral:`∮`,Conint:`∯`,DoubleContourIntegral:`∯`,Cconint:`∰`,there4:`∴`,therefore:`∴`,Therefore:`∴`,becaus:`∵`,because:`∵`,Because:`∵`,ratio:`∶`,Proportion:`∷`,minusd:`∸`,dotminus:`∸`,mDDot:`∺`,homtht:`∻`,sim:`∼`,bsimg:`∽`,backsim:`∽`,ac:`∾`,mstpos:`∾`,acd:`∿`,VerticalTilde:`≀`,wr:`≀`,wreath:`≀`,nsime:`≄`,nsimeq:`≄`,ncong:`≇`,simne:`≆`,ncongdot:`⩭̸`,ngsim:`≵`,nsim:`≁`,napprox:`≉`,nap:`≉`,ngeq:`≱`,nge:`≱`,nleq:`≰`,nle:`≰`,ngtr:`≯`,ngt:`≯`,nless:`≮`,nlt:`≮`,nprec:`⊀`,npr:`⊀`,nsucc:`⊁`,nsc:`⊁`},zk={larr:`←`,leftarrow:`←`,LeftArrow:`←`,uarr:`↑`,uparrow:`↑`,UpArrow:`↑`,rarr:`→`,rightarrow:`→`,RightArrow:`→`,darr:`↓`,downarrow:`↓`,DownArrow:`↓`,harr:`↔`,leftrightarrow:`↔`,LeftRightArrow:`↔`,varr:`↕`,updownarrow:`↕`,UpDownArrow:`↕`,nwarr:`↖`,nwarrow:`↖`,UpperLeftArrow:`↖`,nearr:`↗`,nearrow:`↗`,UpperRightArrow:`↗`,searr:`↘`,searrow:`↘`,LowerRightArrow:`↘`,swarr:`↙`,swarrow:`↙`,LowerLeftArrow:`↙`,lArr:`⇐`,Leftarrow:`⇐`,uArr:`⇑`,Uparrow:`⇑`,rArr:`⇒`,Rightarrow:`⇒`,dArr:`⇓`,Downarrow:`⇓`,hArr:`⇔`,Leftrightarrow:`⇔`,iff:`⇔`,vArr:`⇕`,Updownarrow:`⇕`,lAarr:`⇚`,Lleftarrow:`⇚`,rAarr:`⇛`,Rrightarrow:`⇛`,lrarr:`⇆`,leftrightarrows:`⇆`,rlarr:`⇄`,rightleftarrows:`⇄`,lrhar:`⇋`,leftrightharpoons:`⇋`,ReverseEquilibrium:`⇋`,rlhar:`⇌`,rightleftharpoons:`⇌`,Equilibrium:`⇌`,udarr:`⇅`,UpArrowDownArrow:`⇅`,duarr:`⇵`,DownArrowUpArrow:`⇵`,llarr:`⇇`,leftleftarrows:`⇇`,rrarr:`⇉`,rightrightarrows:`⇉`,ddarr:`⇊`,downdownarrows:`⇊`,har:`↽`,lhard:`↽`,leftharpoondown:`↽`,lharu:`↼`,leftharpoonup:`↼`,rhard:`⇁`,rightharpoondown:`⇁`,rharu:`⇀`,rightharpoonup:`⇀`,lsh:`↰`,Lsh:`↰`,rsh:`↱`,Rsh:`↱`,ldsh:`↲`,rdsh:`↳`,hookleftarrow:`↩`,hookrightarrow:`↪`,mapstoleft:`↤`,mapstoup:`↥`,map:`↦`,mapsto:`↦`,mapstodown:`↧`,crarr:`↵`,nleftarrow:`↚`,nleftrightarrow:`↮`,nrightarrow:`↛`,nrarr:`↛`,larrtl:`↢`,rarrtl:`↣`,leftarrowtail:`↢`,rightarrowtail:`↣`,twoheadleftarrow:`↞`,twoheadrightarrow:`↠`,Larr:`↞`,Rarr:`↠`,larrhk:`↩`,rarrhk:`↪`,larrlp:`↫`,looparrowleft:`↫`,rarrlp:`↬`,looparrowright:`↬`,harrw:`↭`,leftrightsquigarrow:`↭`,nrarrw:`↝̸`,rarrw:`↝`,rightsquigarrow:`↝`,larrbfs:`⤟`,rarrbfs:`⤠`,nvHarr:`⤄`,nvlArr:`⤂`,nvrArr:`⤃`,larrfs:`⤝`,rarrfs:`⤞`,Map:`⤅`,larrsim:`⥳`,rarrsim:`⥴`,harrcir:`⥈`,Uarrocir:`⥉`,lurdshar:`⥊`,ldrdhar:`⥧`,ldrushar:`⥋`,rdldhar:`⥩`,lrhard:`⥭`,uharr:`↾`,uharl:`↿`,dharr:`⇂`,dharl:`⇃`,Uarr:`↟`,Darr:`↡`,zigrarr:`⇝`,nwArr:`⇖`,neArr:`⇗`,seArr:`⇘`,swArr:`⇙`,nharr:`↮`,nhArr:`⇎`,nlarr:`↚`,nlArr:`⇍`,nrArr:`⇏`,larrb:`⇤`,LeftArrowBar:`⇤`,rarrb:`⇥`,RightArrowBar:`⇥`},Bk={square:`□`,Square:`□`,squ:`□`,squf:`▪`,squarf:`▪`,blacksquar:`▪`,blacksquare:`▪`,FilledVerySmallSquare:`▪`,blk34:`▓`,blk12:`▒`,blk14:`░`,block:`█`,srect:`▭`,rect:`▭`,sdot:`⋅`,sdotb:`⊡`,dotsquare:`⊡`,triangle:`▵`,tri:`▵`,trine:`▵`,utri:`▵`,triangledown:`▿`,dtri:`▿`,tridown:`▿`,triangleleft:`◃`,ltri:`◃`,triangleright:`▹`,rtri:`▹`,blacktriangle:`▴`,utrif:`▴`,blacktriangledown:`▾`,dtrif:`▾`,blacktriangleleft:`◂`,ltrif:`◂`,blacktriangleright:`▸`,rtrif:`▸`,loz:`◊`,lozenge:`◊`,blacklozenge:`⧫`,lozf:`⧫`,bigcirc:`◯`,xcirc:`◯`,circ:`ˆ`,Circle:`○`,cir:`○`,o:`○`,bullet:`•`,bull:`•`,hellip:`…`,mldr:`…`,nldr:`‥`,boxh:`─`,HorizontalLine:`─`,boxv:`│`,boxdr:`┌`,boxdl:`┐`,boxur:`└`,boxul:`┘`,boxvr:`├`,boxvl:`┤`,boxhd:`┬`,boxhu:`┴`,boxvh:`┼`,boxH:`═`,boxV:`║`,boxdR:`╒`,boxDr:`╓`,boxDR:`╔`,boxDl:`╕`,boxdL:`╖`,boxDL:`╗`,boxuR:`╘`,boxUr:`╙`,boxUR:`╚`,boxUl:`╜`,boxuL:`╛`,boxUL:`╝`,boxvR:`╞`,boxVr:`╟`,boxVR:`╠`,boxVl:`╢`,boxvL:`╡`,boxVL:`╣`,boxHd:`╤`,boxhD:`╥`,boxHD:`╦`,boxHu:`╧`,boxhU:`╨`,boxHU:`╩`,boxvH:`╪`,boxVh:`╫`,boxVH:`╬`},Vk={excl:`!`,iexcl:`¡`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:`­`,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,nbsp:`\xA0`,comma:`,`,period:`.`,colon:`:`,semi:`;`,vert:`|`,Verbar:`‖`,verbar:`|`,dblac:`˝`,circ:`ˆ`,caron:`ˇ`,breve:`˘`,dot:`˙`,ring:`˚`,ogon:`˛`,tilde:`˜`,DiacriticalGrave:"`",DiacriticalAcute:`´`,DiacriticalTilde:`˜`,DiacriticalDot:`˙`,DiacriticalDoubleAcute:`˝`,grave:"`"},Hk={cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,euro:`€`,dollar:`$`,fnof:`ƒ`,inr:`₹`,af:`؋`,birr:`ብር`,peso:`₱`,rub:`₽`,won:`₩`,yuan:`¥`,cedil:`¸`},Uk={frac12:`½`,half:`½`,frac13:`⅓`,frac14:`¼`,frac15:`⅕`,frac16:`⅙`,frac18:`⅛`,frac23:`⅔`,frac25:`⅖`,frac34:`¾`,frac35:`⅗`,frac38:`⅜`,frac45:`⅘`,frac56:`⅚`,frac58:`⅝`,frac78:`⅞`,frasl:`⁄`},Wk={trade:`™`,TRADE:`™`,telrec:`⌕`,target:`⌖`,ulcorn:`⌜`,ulcorner:`⌜`,urcorn:`⌝`,urcorner:`⌝`,dlcorn:`⌞`,llcorner:`⌞`,drcorn:`⌟`,lrcorner:`⌟`,intercal:`⊺`,intcal:`⊺`,oplus:`⊕`,CirclePlus:`⊕`,ominus:`⊖`,CircleMinus:`⊖`,otimes:`⊗`,CircleTimes:`⊗`,osol:`⊘`,odot:`⊙`,CircleDot:`⊙`,oast:`⊛`,circledast:`⊛`,odash:`⊝`,circleddash:`⊝`,ocirc:`⊚`,circledcirc:`⊚`,boxplus:`⊞`,plusb:`⊞`,boxminus:`⊟`,minusb:`⊟`,boxtimes:`⊠`,timesb:`⊠`,boxdot:`⊡`,sdotb:`⊡`,veebar:`⊻`,vee:`∨`,barvee:`⊽`,and:`∧`,wedge:`∧`,Cap:`⋒`,Cup:`⋓`,Fork:`⋔`,pitchfork:`⋔`,epar:`⋕`,ltlarr:`⥶`,nvap:`≍⃒`,nvsim:`∼⃒`,nvge:`≥⃒`,nvle:`≤⃒`,nvlt:`<⃒`,nvgt:`>⃒`,nvltrie:`⊴⃒`,nvrtrie:`⊵⃒`,Vdash:`⊩`,dashv:`⊣`,vDash:`⊨`,Vvdash:`⊪`,nvdash:`⊬`,nvDash:`⊭`,nVdash:`⊮`,nVDash:`⊯`};({...Mk,...Nk,...Pk,...Fk,...Ik,...Lk,...Rk,...zk,...Bk,...Vk,...Hk,...Uk,...Wk});var Gk={amp:`&`,apos:`'`,gt:`>`,lt:`<`,quot:`"`},Kk={nbsp:`\xA0`,copy:`©`,reg:`®`,trade:`™`,mdash:`—`,ndash:`–`,hellip:`…`,laquo:`«`,raquo:`»`,lsquo:`‘`,rsquo:`’`,ldquo:`“`,rdquo:`”`,bull:`•`,para:`¶`,sect:`§`,deg:`°`,frac12:`½`,frac14:`¼`,frac34:`¾`},qk=Object.freeze({ALLOW:`allow`,BLOCK:`block`,THROW:`throw`}),Jk=new Set(`!?\\\\/[]$%{}^&*()<>|+`);function Yk(e){if(e[0]===`#`)throw Error(`[EntityReplacer] Invalid character '#' in entity name: "${e}"`);for(let t of e)if(Jk.has(t))throw Error(`[EntityReplacer] Invalid character '${t}' in entity name: "${e}"`);return e}function Xk(...e){let t=Object.create(null);for(let n of e)if(n)for(let e of Object.keys(n)){let r=n[e];if(typeof r==`string`)t[e]=r;else if(r&&typeof r==`object`&&r.val!==void 0){let n=r.val;typeof n==`string`&&(t[e]=n)}}return t}var Zk=`external`,Qk=`base`,$k=`all`;function eA(e){return!e||e===Zk?new Set([Zk]):e===$k?new Set([$k]):e===Qk?new Set([Qk]):Array.isArray(e)?new Set(e):new Set([Zk])}var tA=Object.freeze({allow:0,leave:1,remove:2,throw:3}),nA=new Set([9,10,13]);function rA(e){if(!e)return{xmlVersion:1,onLevel:tA.allow,nullLevel:tA.remove};let t=e.xmlVersion===1.1?1.1:1,n=tA[e.onNCR]??tA.allow,r=tA[e.nullNCR]??tA.remove;return{xmlVersion:t,onLevel:n,nullLevel:Math.max(r,tA.remove)}}var iA=class{constructor(e={}){this._limit=e.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck=typeof e.postCheck==`function`?e.postCheck:e=>e,this._limitTiers=eA(this._limit.applyLimitsTo??Zk),this._numericAllowed=e.numericAllowed??!0,this._baseMap=Xk(Gk,e.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(e.remove&&Array.isArray(e.remove)?e.remove:[]),this._leaveSet=new Set(e.leave&&Array.isArray(e.leave)?e.leave:[]);let t=rA(e.ncr);this._ncrXmlVersion=t.xmlVersion,this._ncrOnLevel=t.onLevel,this._ncrNullLevel=t.nullLevel,this._onExternalEntity=typeof e.onExternalEntity==`function`?e.onExternalEntity:null,this._onInputEntity=typeof e.onInputEntity==`function`?e.onInputEntity:null}_applyRegistrationHook(e,t,n,r){if(!e)return!0;let i=e(t,n);if(i===qk.BLOCK)return!1;if(i===qk.THROW)throw Error(`[EntityDecoder] Registration of ${r} entity "&${t};" was rejected by hook`);return!0}setExternalEntities(e){if(e)for(let t of Object.keys(e))Yk(t);if(!this._onExternalEntity){this._externalMap=Xk(e);return}let t=Xk(e),n=Object.create(null);for(let[e,r]of Object.entries(t))this._applyRegistrationHook(this._onExternalEntity,e,r,`external`)&&(n[e]=r);this._externalMap=n}addExternalEntity(e,t){Yk(e),typeof t==`string`&&t.indexOf(`&`)===-1&&this._applyRegistrationHook(this._onExternalEntity,e,t,`external`)&&(this._externalMap[e]=t)}addInputEntities(e){if(this._totalExpansions=0,this._expandedLength=0,!this._onInputEntity){this._inputMap=Xk(e);return}let t=Xk(e),n=Object.create(null);for(let[e,r]of Object.entries(t))this._applyRegistrationHook(this._onInputEntity,e,r,`input`)&&(n[e]=r);this._inputMap=n}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(e){this._ncrXmlVersion=e===1.1?1.1:1}decode(e){if(typeof e!=`string`||e.length===0||e.indexOf(`&`)===-1)return e;let t=e,n=[],r=e.length,i=0,a=0,o=this._maxTotalExpansions>0,s=this._maxExpandedLength>0,c=o||s;for(;a<r;){if(e.charCodeAt(a)!==38){a++;continue}let t=a+1;for(;t<r&&e.charCodeAt(t)!==59&&t-a<=32;)t++;if(t>=r||e.charCodeAt(t)!==59){a++;continue}let l=e.slice(a+1,t);if(l.length===0){a++;continue}let u,d;if(this._removeSet.has(l))u=``,d===void 0&&(d=Zk);else if(this._leaveSet.has(l)){a++;continue}else if(l.charCodeAt(0)===35){let e=this._resolveNCR(l);if(e===void 0){a++;continue}u=e,d=Qk}else{let e=this._resolveName(l);u=e?.value,d=e?.tier}if(u===void 0){a++;continue}if(a>i&&n.push(e.slice(i,a)),n.push(u),i=t+1,a=i,c&&this._tierCounts(d)){if(o&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(s){let e=u.length-(l.length+2);if(e>0&&(this._expandedLength+=e,this._expandedLength>this._maxExpandedLength))throw Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}i<r&&n.push(e.slice(i));let l=n.length===0?e:n.join(``);return this._postCheck(l,t)}_tierCounts(e){return this._limitTiers.has($k)?!0:this._limitTiers.has(e)}_resolveName(e){if(e in this._inputMap)return{value:this._inputMap[e],tier:Zk};if(e in this._externalMap)return{value:this._externalMap[e],tier:Zk};if(e in this._baseMap)return{value:this._baseMap[e],tier:Qk}}_classifyNCR(e){return e===0?this._ncrNullLevel:e>=55296&&e<=57343||this._ncrXmlVersion===1&&e>=1&&e<=31&&!nA.has(e)?tA.remove:-1}_applyNCRAction(e,t,n){switch(e){case tA.allow:return String.fromCodePoint(n);case tA.remove:return``;case tA.leave:return;case tA.throw:throw Error(`[EntityDecoder] Prohibited numeric character reference &${t}; (U+${n.toString(16).toUpperCase().padStart(4,`0`)})`);default:return String.fromCodePoint(n)}}_resolveNCR(e){let t=e.charCodeAt(1),n;if(n=t===120||t===88?parseInt(e.slice(2),16):parseInt(e.slice(1),10),Number.isNaN(n)||n<0||n>1114111)return;let r=this._classifyNCR(n);if(!this._numericAllowed&&r<tA.remove)return;let i=r===-1?this._ncrOnLevel:Math.max(this._ncrOnLevel,r);return this._applyNCRAction(i,e,n)}},aA=e=>mk.includes(e)?`__`+e:e,oA={preserveOrder:!1,attributeNamePrefix:`@_`,attributesGroupName:!1,textNodeName:`#text`,ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0,unicode:!1},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,n){return e},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:aA};function sA(e,t){if(typeof e!=`string`)return;let n=e.toLowerCase();if(mk.some(e=>n===e.toLowerCase())||hk.some(e=>n===e.toLowerCase()))throw Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`)}function cA(e,t){return typeof e==`boolean`?{enabled:e,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:`all`}:typeof e==`object`&&e?{enabled:e.enabled!==!1,maxEntitySize:Math.max(1,e.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,e.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,e.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,e.maxExpandedLength??1e5),maxEntityCount:Math.max(1,e.maxEntityCount??1e3),allowedTags:e.allowedTags??null,tagFilter:e.tagFilter??null,appliesTo:e.appliesTo??`all`}:cA(!0)}var lA=function(e){let t=Object.assign({},oA,e),n=[{value:t.attributeNamePrefix,name:`attributeNamePrefix`},{value:t.attributesGroupName,name:`attributesGroupName`},{value:t.textNodeName,name:`textNodeName`},{value:t.cdataPropName,name:`cdataPropName`},{value:t.commentPropName,name:`commentPropName`}];for(let{value:e,name:t}of n)e&&sA(e,t);return t.onDangerousProperty===null&&(t.onDangerousProperty=aA),t.processEntities=cA(t.processEntities,t.htmlEntities),t.unpairedTagsSet=new Set(t.unpairedTags),t.stopNodes&&Array.isArray(t.stopNodes)&&(t.stopNodes=t.stopNodes.map(e=>typeof e==`string`&&e.startsWith(`*.`)?`..`+e.substring(2):e)),t},uA=typeof Symbol==`function`?Symbol(`XML Node Metadata`):`@@xmlMetadata`,dA=class{constructor(e){this.tagname=e,this.child=[],this[`:@`]=Object.create(null)}add(e,t){e===`__proto__`&&(e=`#__proto__`),this.child.push({[e]:t})}addChild(e,t){e.tagname===`__proto__`&&(e.tagname=`#__proto__`),e[`:@`]&&Object.keys(e[`:@`]).length>0?this.child.push({[e.tagname]:e.child,":@":e[`:@`]}):this.child.push({[e.tagname]:e.child}),t!==void 0&&(this.child[this.child.length-1][uA]={startIndex:t})}static getMetaDataSymbol(){return uA}},fA=`:A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�`,pA=`:A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�\\-\\.\\d·̀-ͯ‿-⁀`,mA=`:A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿`,hA=`:A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿\\-\\.\\d·̀-ͯ҇‿-⁀`,gA=(e,t,n=``)=>{let r=`[${e.replace(`:`,``)}][${t.replace(`:`,``)}]*`;return{name:RegExp(`^[${e}][${t}]*$`,n),ncName:RegExp(`^${r}$`,n),qName:RegExp(`^${r}(?::${r})?$`,n),nmToken:RegExp(`^[${t}]+$`,n),nmTokens:RegExp(`^[${t}]+(?:\\s+[${t}]+)*$`,n)}},_A=gA(fA,pA),vA=gA(mA,hA,`u`),yA=gA(`:A-Za-z_`,`:A-Za-z_\\-\\.\\d`),bA=(e=`1.0`,t=!1)=>t?yA:e===`1.1`?vA:_A,xA=(e,{xmlVersion:t=`1.0`,asciiOnly:n=!1}={})=>bA(t,n).qName.test(e),SA=[`name`,`ncName`,`qName`,`nmToken`,`nmTokens`],CA=(e,{xmlVersion:t=`1.0`,asciiOnly:n=!1,maxCacheSize:r=2048}={})=>{if(!SA.includes(e))throw TypeError(`Unknown production "${e}". Must be one of: ${SA.join(`, `)}`);let i=bA(t,n)[e],a=new Map,o=e=>{let t=a.get(e);if(t!==void 0)return t;let n=i.test(e);return a.size<r&&a.set(e,n),n};return o.reset=()=>{a=new Map},o},wA=class{constructor(e,t){this.suppressValidationErr=!e,this.options=e,this.xmlVersion=t||1}setXmlVersion(e=1){this.xmlVersion=e}readDocType(e,t){let n=Object.create(null),r=0;if(e[t+3]===`O`&&e[t+4]===`C`&&e[t+5]===`T`&&e[t+6]===`Y`&&e[t+7]===`P`&&e[t+8]===`E`){t+=9;let i=1,a=!1,o=!1,s=``;for(;t<e.length;t++)if(e[t]===`<`&&!o){if(a&&EA(e,`!ENTITY`,t)){t+=7;let i,a;if([i,a,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),a.indexOf(`&`)===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&r>=this.options.maxEntityCount)throw Error(`Entity count (${r+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);n[i]=a,r++}}else if(a&&EA(e,`!ELEMENT`,t)){t+=8;let{index:n}=this.readElementExp(e,t+1);t=n}else if(a&&EA(e,`!ATTLIST`,t))t+=8;else if(a&&EA(e,`!NOTATION`,t)){t+=9;let{index:n}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=n}else if(EA(e,`!--`,t))o=!0;else throw Error(`Invalid DOCTYPE`);i++,s=``}else if(e[t]===`>`){if(o?e[t-1]===`-`&&e[t-2]===`-`&&(o=!1,i--):i--,i===0)break}else e[t]===`[`?a=!0:s+=e[t];if(i!==0)throw Error(`Unclosed DOCTYPE`)}else throw Error(`Invalid Tag instead of DOCTYPE`);return{entities:n,i:t}}readEntityExp(e,t){t=TA(e,t);let n=t;for(;t<e.length&&!/\s/.test(e[t])&&e[t]!==`"`&&e[t]!==`'`;)t++;let r=e.substring(n,t);if(DA(r,{xmlVersion:this.xmlVersion}),t=TA(e,t),!this.suppressValidationErr){if(e.substring(t,t+6).toUpperCase()===`SYSTEM`)throw Error(`External entities are not supported`);if(e[t]===`%`)throw Error(`Parameter entities are not supported`)}let i=``;if([t,i]=this.readIdentifierVal(e,t,`entity`),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&i.length>this.options.maxEntitySize)throw Error(`Entity "${r}" size (${i.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return t--,[r,i,t]}readNotationExp(e,t){t=TA(e,t);let n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);!this.suppressValidationErr&&DA(r,{xmlVersion:this.xmlVersion}),t=TA(e,t);let i=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&i!==`SYSTEM`&&i!==`PUBLIC`)throw Error(`Expected SYSTEM or PUBLIC, found "${i}"`);t+=i.length,t=TA(e,t);let a=null,o=null;if(i===`PUBLIC`)[t,a]=this.readIdentifierVal(e,t,`publicIdentifier`),t=TA(e,t),(e[t]===`"`||e[t]===`'`)&&([t,o]=this.readIdentifierVal(e,t,`systemIdentifier`));else if(i===`SYSTEM`&&([t,o]=this.readIdentifierVal(e,t,`systemIdentifier`),!this.suppressValidationErr&&!o))throw Error(`Missing mandatory system identifier for SYSTEM notation`);return{notationName:r,publicIdentifier:a,systemIdentifier:o,index:--t}}readIdentifierVal(e,t,n){let r=``,i=e[t];if(i!==`"`&&i!==`'`)throw Error(`Expected quoted string, found "${i}"`);t++;let a=t;for(;t<e.length&&e[t]!==i;)t++;if(r=e.substring(a,t),e[t]!==i)throw Error(`Unterminated ${n} value`);return t++,[t,r]}readElementExp(e,t){t=TA(e,t);let n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);if(!this.suppressValidationErr&&!xA(r,{xmlVersion:this.xmlVersion}))throw Error(`Invalid element name: "${r}"`);t=TA(e,t);let i=``;if(e[t]===`E`&&EA(e,`MPTY`,t))t+=4;else if(e[t]===`A`&&EA(e,`NY`,t))t+=2;else if(e[t]===`(`){t++;let n=t;for(;t<e.length&&e[t]!==`)`;)t++;if(i=e.substring(n,t),e[t]!==`)`)throw Error(`Unterminated content model`)}else if(!this.suppressValidationErr)throw Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:r,contentModel:i.trim(),index:t}}readAttlistExp(e,t){t=TA(e,t);let n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);for(DA(r,{xmlVersion:this.xmlVersion}),t=TA(e,t),n=t;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(n,t);if(!DA(i,{xmlVersion:this.xmlVersion}))throw Error(`Invalid attribute name: "${i}"`);t=TA(e,t);let a=``;if(e.substring(t,t+8).toUpperCase()===`NOTATION`){if(a=`NOTATION`,t+=8,t=TA(e,t),e[t]!==`(`)throw Error(`Expected '(', found "${e[t]}"`);t++;let n=[];for(;t<e.length&&e[t]!==`)`;){let r=t;for(;t<e.length&&e[t]!==`|`&&e[t]!==`)`;)t++;let i=e.substring(r,t);if(i=i.trim(),!DA(i,{xmlVersion:this.xmlVersion}))throw Error(`Invalid notation name: "${i}"`);n.push(i),e[t]===`|`&&(t++,t=TA(e,t))}if(e[t]!==`)`)throw Error(`Unterminated list of notations`);t++,a+=` (`+n.join(`|`)+`)`}else{let n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;if(a+=e.substring(n,t),!this.suppressValidationErr&&![`CDATA`,`ID`,`IDREF`,`IDREFS`,`ENTITY`,`ENTITIES`,`NMTOKEN`,`NMTOKENS`].includes(a.toUpperCase()))throw Error(`Invalid attribute type: "${a}"`)}t=TA(e,t);let o=``;return e.substring(t,t+8).toUpperCase()===`#REQUIRED`?(o=`#REQUIRED`,t+=8):e.substring(t,t+7).toUpperCase()===`#IMPLIED`?(o=`#IMPLIED`,t+=7):[t,o]=this.readIdentifierVal(e,t,`ATTLIST`),{elementName:r,attributeName:i,attributeType:a,defaultValue:o,index:t}}},TA=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function EA(e,t,n){for(let r=0;r<t.length;r++)if(t[r]!==e[n+r+1])return!1;return!0}function DA(e,t){if(xA(e,{xmlVersion:t}))return e;throw Error(`Invalid entity name ${e}`)}var OA=[48,1632,1776,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,65296,120782,120792,120802,120812,120822,66720,68912,69734,69872,69942,70096,70384,70736,70864,71248,71360,71472,71904,72016,72688,72784,73040,73120,73552,92768,92864,93008,123200,123632,124144,125264,130032],kA=new Map,AA=65535,jA=1632,MA=new Uint8Array(63904).fill(255);for(let e of OA)for(let t=0;t<10;t++){let n=e+t;n<=AA?MA[n-jA]=t:kA.set(n,t)}var NA=48,PA=57,FA=45,IA=new Set([8722,65293,65123]);function LA(e){if(typeof e!=`string`)return e;let t=e.length;if(t===0)return e;let n=-1;for(let r=0;r<t;r++){let i=e.charCodeAt(r);if(!(i>=NA&&i<=PA||i===FA)){if(i<1632){if(IA.has(i)){n=r;break}continue}if(i>=55296&&i<=56319){if(r+1<t){let t=e.charCodeAt(r+1);if(t>=56320&&t<=57343){let e=65536+(i-55296<<10)+(t-56320);if(kA.has(e)){n=r;break}}}continue}if(MA[i-1632]!==255||IA.has(i)){n=r;break}}}if(n===-1)return e;let r=[];n>0&&r.push(e.slice(0,n));for(let i=n;i<t;i++){let n=e.charCodeAt(i);if(n>=NA&&n<=PA||n===FA){r.push(e[i]);continue}if(n<1632){r.push(IA.has(n)?`-`:e[i]);continue}if(n>=55296&&n<=56319){if(i+1<t){let t=e.charCodeAt(i+1);if(t>=56320&&t<=57343){let e=65536+(n-55296<<10)+(t-56320),a=kA.get(e);if(a!==void 0){r.push(String.fromCharCode(a+48)),i++;continue}}}r.push(e[i]);continue}if(IA.has(n)){r.push(`-`);continue}let a=MA[n-jA];r.push(a===255?e[i]:String.fromCharCode(a+48))}return r.join(``)}var RA=/^[-+]?0x[a-fA-F0-9]+$/,zA=/^0b[01]+$/,BA=/^0o[0-7]+$/,VA=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,HA={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:`.`,eNotation:!0,infinity:`original`,unicode:!1};function UA(e,t={}){if(t=Object.assign({},HA,t),!e||typeof e!=`string`)return e;let n=e.trim();if(n.length===0||t.skipLike!==void 0&&t.skipLike.test(n))return e;if(n===`0`||t.unicode&&(n=LA(n),n===`0`))return 0;if(t.hex&&RA.test(n))return qA(n,16);if(t.binary&&zA.test(n))return qA(n,2);if(t.octal&&BA.test(n))return qA(n,8);if(!isFinite(n))return JA(e,Number(n),t);if(n.includes(`e`)||n.includes(`E`))return GA(e,n,t);{let r=VA.exec(n);if(r){let i=r[1]||``,a=r[2],o=KA(r[3]),s=i?e[a.length+1]===`.`:e[a.length]===`.`;if(!t.leadingZeros&&(a.length>1||a.length===1&&!s))return e;{let r=Number(n),s=String(r);if(r===0)return r;if(s.search(/[eE]/)!==-1)return t.eNotation?r:e;if(n.indexOf(`.`)!==-1)return s===`0`||s===o||s===`${i}${o}`?r:e;let c=a?o:n;return a?c===s||i+c===s?r:e:c===s||c===i+s?r:e}}else return e}}var WA=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function GA(e,t,n){if(!n.eNotation)return e;let r=t.match(WA);if(r){let i=r[1]||``,a=r[3].indexOf(`e`)===-1?`E`:`e`,o=r[2],s=i?e[o.length+1]===a:e[o.length]===a;return o.length>1&&s?e:o.length===1&&(r[3].startsWith(`.${a}`)||r[3][0]===a)?Number(t):o.length>0?n.leadingZeros&&!s?(t=(r[1]||``)+r[3],Number(t)):e:Number(t)}else return e}function KA(e){return e&&e.indexOf(`.`)!==-1?(e=e.replace(/0+$/,``),e===`.`?e=`0`:e[0]===`.`?e=`0`+e:e[e.length-1]===`.`&&(e=e.substring(0,e.length-1)),e):e}function qA(e,t){let n=e.trim();if((t===2||t===8)&&(e=n.substring(2)),parseInt)return parseInt(e,t);if(Number.parseInt)return Number.parseInt(e,t);if(window&&window.parseInt)return window.parseInt(e,t);throw Error(`parseInt, Number.parseInt, window.parseInt are not supported`)}function JA(e,t,n){let r=t===1/0;switch(n.infinity.toLowerCase()){case`null`:return null;case`infinity`:return t;case`string`:return r?`Infinity`:`-Infinity`;default:return e}}function YA(e){return typeof e==`function`?e:Array.isArray(e)?t=>{for(let n of e)if(typeof n==`string`&&t===n||n instanceof RegExp&&n.test(t))return!0}:()=>!1}var XA=class{constructor(e,t={},n){this.pattern=e,this.separator=t.separator||`.`,this.segments=this._parse(e),this.data=n,this._hasDeepWildcard=this.segments.some(e=>e.type===`deep-wildcard`),this._hasAttributeCondition=this.segments.some(e=>e.attrName!==void 0),this._hasPositionSelector=this.segments.some(e=>e.position!==void 0)}_parse(e){let t=[],n=0,r=``;for(;n<e.length;)e[n]===this.separator?n+1<e.length&&e[n+1]===this.separator?(r.trim()&&(t.push(this._parseSegment(r.trim())),r=``),t.push({type:`deep-wildcard`}),n+=2):(r.trim()&&t.push(this._parseSegment(r.trim())),r=``,n++):(r+=e[n],n++);return r.trim()&&t.push(this._parseSegment(r.trim())),t}_parseSegment(e){let t={type:`tag`},n=null,r=e,i=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(i&&(r=i[1]+i[3],i[2])){let e=i[2].slice(1,-1);e&&(n=e)}let a,o=r;if(r.includes(`::`)){let t=r.indexOf(`::`);if(a=r.substring(0,t).trim(),o=r.substring(t+2).trim(),!a)throw Error(`Invalid namespace in pattern: ${e}`)}let s,c=null;if(o.includes(`:`)){let e=o.lastIndexOf(`:`),t=o.substring(0,e).trim(),n=o.substring(e+1).trim();[`first`,`last`,`odd`,`even`].includes(n)||/^nth\(\d+\)$/.test(n)?(s=t,c=n):s=o}else s=o;if(!s)throw Error(`Invalid segment pattern: ${e}`);if(t.tag=s,a&&(t.namespace=a),n)if(n.includes(`=`)){let e=n.indexOf(`=`);t.attrName=n.substring(0,e).trim(),t.attrValue=n.substring(e+1).trim()}else t.attrName=n.trim();if(c){let e=c.match(/^nth\((\d+)\)$/);e?(t.position=`nth`,t.positionValue=parseInt(e[1],10)):t.position=c}return t}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}},ZA=class{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._deepByTerminalTag=new Map,this._patterns=new Set,this._sealed=!1}add(e){if(this._sealed)throw TypeError(`ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.`);if(this._patterns.has(e.pattern))return this;if(this._patterns.add(e.pattern),e.hasDeepWildcard()){let t=e.segments[e.segments.length-1];if(t&&t.type!==`deep-wildcard`&&t.tag!==`*`){let n=t.tag;this._deepByTerminalTag.has(n)||this._deepByTerminalTag.set(n,[]),this._deepByTerminalTag.get(n).push(e)}else this._deepWildcards.push(e);return this}let t=e.length,n=e.segments[e.segments.length-1]?.tag;if(!n||n===`*`)this._wildcardByDepth.has(t)||this._wildcardByDepth.set(t,[]),this._wildcardByDepth.get(t).push(e);else{let r=`${t}:${n}`;this._byDepthAndTag.has(r)||this._byDepthAndTag.set(r,[]),this._byDepthAndTag.get(r).push(e)}return this}addAll(e){for(let t of e)this.add(t);return this}has(e){return this._patterns.has(e.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(e){return this.findMatch(e)!==null}findMatch(e){let t=e.getDepth(),n=e.getCurrentTag(),r=`${t}:${n}`,i=this._byDepthAndTag.get(r);if(i){for(let t=0;t<i.length;t++)if(e.matches(i[t]))return i[t]}let a=this._wildcardByDepth.get(t);if(a){for(let t=0;t<a.length;t++)if(e.matches(a[t]))return a[t]}let o=this._deepByTerminalTag.get(n);if(o){for(let t=0;t<o.length;t++)if(e.matches(o[t]))return o[t]}for(let t=0;t<this._deepWildcards.length;t++)if(e.matches(this._deepWildcards[t]))return this._deepWildcards[t];return null}},QA=class{constructor(e){this._matcher=e}get separator(){return this._matcher.separator}getCurrentTag(){let e=this._matcher.path;return e.length>0?e[e.length-1].tag:void 0}getCurrentNamespace(){let e=this._matcher.path;return e.length>0?e[e.length-1].namespace:void 0}getAttrValue(e){let t=this._matcher.path;if(t.length!==0)return t[t.length-1].values?.[e]}hasAttr(e){let t=this._matcher.path;if(t.length===0)return!1;let n=t[t.length-1];return n.values!==void 0&&e in n.values}getAnyParentAttr(e){return this._matcher.getAnyParentAttr(e)}hasAnyParentAttr(e){return this._matcher.hasAnyParentAttr(e)}getPosition(){let e=this._matcher.path;return e.length===0?-1:e[e.length-1].position??0}getCounter(){let e=this._matcher.path;return e.length===0?-1:e[e.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(e,t=!0){return this._matcher.toString(e,t)}toArray(){return this._matcher.path.map(e=>e.tag)}matches(e){return this._matcher.matches(e)}matchesAny(e){return e.matchesAny(this._matcher)}},$A=class{constructor(e={}){this.separator=e.separator||`.`,this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new QA(this),this._keptAttrs=[]}push(e,t=null,n=null,r=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);let i=this.path.length,a=this.siblingStacks[i];a||(a={counts:new Map,total:0},this.siblingStacks[i]=a);let o=n?`${n}:${e}`:e,s=a.counts.get(o)||0,c=a.total;a.counts.set(o,s+1),a.total++;let l={tag:e,position:c,counter:s};n!=null&&(l.namespace=n),t!=null&&(l.values=t),this.path.push(l);let u=this.path.length,d=r===null?null:r.keep;if(d!=null&&d.length>0&&t)for(let e=0;e<d.length;e++){let n=d[e];t[n]!==void 0&&this._keptAttrs.push({depth:u,name:n,value:t[n]})}}pop(){if(this.path.length===0)return;this._pathStringCache=null;let e=this.path.pop();this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1);let t=this.path.length+1;for(;this._keptAttrs.length>0&&this._keptAttrs[this._keptAttrs.length-1].depth>=t;)this._keptAttrs.pop();return e}updateCurrent(e){if(this.path.length>0){let t=this.path[this.path.length-1];e!=null&&(t.values=e)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){if(this.path.length!==0)return this.path[this.path.length-1].values?.[e]}hasAttr(e){if(this.path.length===0)return!1;let t=this.path[this.path.length-1];return t.values!==void 0&&e in t.values}getAnyParentAttr(e){let t=this._keptAttrs;for(let n=t.length-1;n>=0;n--)if(t[n].name===e)return t[n].value}hasAnyParentAttr(e){let t=this._keptAttrs;for(let n=t.length-1;n>=0;n--)if(t[n].name===e)return!0;return!1}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,t=!0){let n=e||this.separator;if(n===this.separator&&t===!0){if(this._pathStringCache!==null)return this._pathStringCache;let e=this.path.map(e=>e.namespace?`${e.namespace}:${e.tag}`:e.tag).join(n);return this._pathStringCache=e,e}return this.path.map(e=>t&&e.namespace?`${e.namespace}:${e.tag}`:e.tag).join(n)}toArray(){return this.path.map(e=>e.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[],this._keptAttrs=[]}matches(e){let t=e.segments;return t.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(t):this._matchSimple(t)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let t=0;t<e.length;t++)if(!this._matchSegment(e[t],this.path[t],t===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(e){let t=this.path.length-1,n=e.length-1;for(;n>=0&&t>=0;){let r=e[n];if(r.type===`deep-wildcard`){if(n--,n<0)return!0;let r=e[n],i=!1;for(let e=t;e>=0;e--)if(this._matchSegment(r,this.path[e],e===this.path.length-1)){t=e-1,n--,i=!0;break}if(!i)return!1}else{if(!this._matchSegment(r,this.path[t],t===this.path.length-1))return!1;t--,n--}}return n<0}_matchSegment(e,t,n){if(e.tag!==`*`&&e.tag!==t.tag||e.namespace!==void 0&&e.namespace!==`*`&&e.namespace!==t.namespace||e.attrName!==void 0&&(!n||!t.values||!(e.attrName in t.values)||e.attrValue!==void 0&&String(t.values[e.attrName])!==String(e.attrValue)))return!1;if(e.position!==void 0){if(!n)return!1;let r=t.counter??0;if(e.position===`first`&&r!==0||e.position===`odd`&&r%2!=1||e.position===`even`&&r%2!=0||e.position===`nth`&&r!==e.positionValue)return!1}return!0}matchesAny(e){return e.matchesAny(this)}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>e&&{counts:new Map(e.counts),total:e.total}),keptAttrs:this._keptAttrs.map(e=>({...e}))}}restore(e){this._pathStringCache=null,this.path=e.path.map(e=>({...e})),this.siblingStacks=e.siblingStacks.map(e=>e&&{counts:new Map(e.counts),total:e.total}),this._keptAttrs=(e.keptAttrs||[]).map(e=>({...e}))}readOnly(){return this._view}},ej=[{id:`html-script-open`,description:`<script opening tag`,pattern:/<script[\s>/]/i},{id:`html-script-close`,description:`<\/script closing tag`,pattern:/<\/script[\s>]/i},{id:`html-javascript-protocol`,description:`javascript: URI scheme (with optional whitespace/encoding)`,pattern:/j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i},{id:`html-vbscript-protocol`,description:`vbscript: URI scheme`,pattern:/vbscript[\t\n\r ]*:/i},{id:`html-data-html`,description:`data:text/html URI — can execute scripts in browsers`,pattern:/data[\t\n\r ]*:[\t\n\r ]*text\/html/i},{id:`html-data-xhtml`,description:`data:application/xhtml+xml URI`,pattern:/data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i},{id:`html-data-svg`,description:`data:image/svg+xml URI — can execute scripts`,pattern:/data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i},{id:`html-inline-event-handler`,description:`Inline event handler attributes: onclick=, onerror=, onload=, etc.`,pattern:/\bon\w{1,30}\s*=/i},{id:`html-entity-obfuscated-script`,description:`HTML-entity-encoded <script (e.g. &#x3C;script or &lt;script)`,pattern:/(?:&#x0*3[Cc];?|&#0*60;?|&lt;)\s*script/i},{id:`html-entity-obfuscated-javascript`,description:`HTML-entity-encoded javascript: (partial — catches common &#106; or &#x6a; for "j")`,pattern:/(?:&#x0*6[Aa];?|&#0*106;?)\s*(?:&#x0*61;?|a)[\s\S]{0,80}script\s*:/i},{id:`html-style-expression`,description:`CSS expression() — IE-era code execution in style attributes`,pattern:/style[\s\S]{0,20}expression\s*\(/i},{id:`html-object-embed`,description:`<object or <embed tags that can load active content`,pattern:/<(?:object|embed)[\s>/]/i},{id:`html-base-tag`,description:`<base href= — can hijack all relative URLs on a page`,pattern:/<base[\s>]/i},{id:`html-meta-refresh`,description:`<meta http-equiv="refresh" — can redirect users`,pattern:/<meta[\s\S]{0,40}http-equiv[\s\S]{0,20}refresh/i},{id:`html-srcdoc`,description:`srcdoc= attribute on iframes — embeds HTML that can run scripts`,pattern:/srcdoc\s*=/i},{id:`html-iframe`,description:`<iframe tag`,pattern:/<iframe[\s>/]/i},{id:`html-form`,description:`<form tag — can be used for phishing / credential harvesting injection`,pattern:/<form[\s>/]/i}],tj=[{id:`xml-cdata-injection`,description:`CDATA section injection: <![CDATA[ breaks out of text node context`,pattern:/<!\[CDATA\[/i},{id:`xml-cdata-close`,description:`CDATA close sequence: ]]> can terminate an enclosing CDATA section`,pattern:/\]\]>/},{id:`xml-processing-instruction`,description:`XML processing instruction: <?xml-stylesheet or <?php etc.`,pattern:/<\?(?:xml[\- ]|php|asp)/i},{id:`xml-doctype-injection`,description:`DOCTYPE declaration embedded in content — can define entities`,pattern:/<!DOCTYPE(?:[\s[]|$)/i},{id:`xml-entity-system`,description:`SYSTEM keyword — used in external entity declarations (XXE)`,pattern:/\bSYSTEM\s+["']/i},{id:`xml-entity-public`,description:`PUBLIC keyword — used in external entity declarations (XXE)`,pattern:/\bPUBLIC\s+["']/i},{id:`xml-entity-declaration`,description:`<!ENTITY declaration — defines entities, potential XXE or entity expansion`,pattern:/<!ENTITY[\s%]/i},{id:`xml-billion-laughs`,description:`Entity reference chaining / billion laughs: repeated &eX; style references`,pattern:/(?:&\w{1,20};){3,}/},{id:`xml-namespace-confusion`,description:`xmlns: attribute injection — can redefine namespaces to confuse parsers`,pattern:/\bxmlns\s*(?::\w{1,40})?\s*=/i},{id:`xml-comment-injection`,description:`<!-- comment injection — can hide content from some parsers`,pattern:/<!--/},{id:`xml-comment-close`,description:`--> closes an enclosing XML comment`,pattern:/-->/},{id:`xml-pi-close`,description:`?> closes an enclosing processing instruction`,pattern:/\?>/}],nj=[{id:`svg-script-element`,description:`<script element inside SVG executes JavaScript`,pattern:/<script[\s>/]/i},{id:`svg-xlink-href-javascript`,description:`xlink:href with javascript: — classic SVG XSS via <a> or <use>`,pattern:/xlink\s*:\s*href\s*=\s*["']?\s*javascript\s*:/i},{id:`svg-href-javascript`,description:`href= with javascript: in SVG context (<a>, <animate>, etc.)`,pattern:/href\s*=\s*["']?\s*javascript\s*:/i},{id:`svg-foreignobject`,description:`<foreignObject embeds HTML inside SVG — can execute scripts`,pattern:/<foreignObject[\s>/]/i},{id:`svg-use-external`,description:`<use xlink:href or href pointing to external resource (non-fragment URL)`,pattern:/<use[\s\S]{0,60}(?:xlink\s*:\s*)?href\s*=\s*(?:["'][^#]|[^"'#\s>])/i},{id:`svg-animate-href`,description:`<animate attributeName="href" — can dynamically change href to javascript:`,pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*href["']/i},{id:`svg-animate-xlinkhref`,description:`<animate attributeName="xlink:href"`,pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*xlink\s*:\s*href["']/i},{id:`svg-set-javascript`,description:`<set to="javascript:..." — sets an attribute to a javascript: URI`,pattern:/<set[\s\S]{0,80}to\s*=\s*["']?\s*javascript\s*:/i},{id:`svg-event-handler`,description:`SVG-specific event handler attributes: onload=, onerror=, onactivate=, etc.`,pattern:/\bon(?:load|error|activate|begin|end|repeat|focus|blur|click|mouse\w{1,20}|key\w{1,20})\s*=/i},{id:`svg-handler-generic`,description:`Generic on* handler catch-all for SVG attributes`,pattern:/\bon\w{1,30}\s*=/i},{id:`svg-filter-feimage`,description:`<feImage href= — filter primitive that can load external resources`,pattern:/<feImage[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=/i},{id:`svg-image-external`,description:`<image xlink:href with http/https or javascript protocol`,pattern:/<image[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=\s*["']?\s*(?:https?|javascript)\s*:/i},{id:`svg-style-javascript`,description:`style= attribute containing javascript: (e.g. background:url(javascript:...))`,pattern:/style\s*=[\s\S]{0,60}javascript\s*:/i}],rj=[{id:`sql-block-comment-open`,description:`SQL block comment open: /* ... */ — unusual in legitimate user text`,pattern:/\/\*/},{id:`sql-union-select`,description:`UNION SELECT — most common SQL injection aggregation attack`,pattern:/\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i},{id:`sql-drop-table`,description:`DROP TABLE — destructive DDL injection`,pattern:/\bDROP\s{1,20}TABLE\b/i},{id:`sql-drop-database`,description:`DROP DATABASE — destructive DDL injection`,pattern:/\bDROP\s{1,20}DATABASE\b/i},{id:`sql-insert-into`,description:`INSERT INTO — data injection`,pattern:/\bINSERT\s{1,20}INTO\b/i},{id:`sql-delete-from`,description:`DELETE FROM — data deletion injection`,pattern:/\bDELETE\s{1,20}FROM\b/i},{id:`sql-update-set`,description:`UPDATE ... SET — data modification injection`,pattern:/\bUPDATE\b[\s\S]{1,60}\bSET\b/i},{id:`sql-exec-xp`,description:`EXEC xp_ — MSSQL extended stored procedure execution`,pattern:/\bEXEC(?:UTE)?\s{1,20}xp_/i},{id:`sql-tautology-string`,description:`Classic string tautology: ' OR '1'='1 or " OR "1"="1"`,pattern:/'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i},{id:`sql-tautology-numeric`,description:`Numeric tautology: OR 1=1`,pattern:/\bOR\s{1,10}1\s*=\s*1\b/i},{id:`sql-always-true-zero`,description:`Numeric tautology: OR 0=0`,pattern:/\bOR\s{1,10}0\s*=\s*0\b/i},{id:`sql-sleep-benchmark`,description:`Time-based blind injection: SLEEP() or BENCHMARK()`,pattern:/\b(?:SLEEP|BENCHMARK)\s*\(/i},{id:`sql-waitfor-delay`,description:`MSSQL time-based blind injection: WAITFOR DELAY`,pattern:/\bWAITFOR\s{1,20}DELAY\b/i},{id:`sql-char-function`,description:`CHAR() function — used to obfuscate injected strings`,pattern:/\bCHAR\s*\(\s*\d{1,3}/i},{id:`sql-information-schema`,description:`INFORMATION_SCHEMA — reconnaissance query for table/column enumeration`,pattern:/\bINFORMATION_SCHEMA\b/i}],ij=[{id:`shell-path-traversal-unix`,description:`Unix path traversal: ../ — climbing the directory tree`,pattern:/\.\.\//},{id:`shell-path-traversal-windows`,description:`Windows path traversal: ..\\ — climbing the directory tree`,pattern:/\.\.\\/},{id:`shell-path-traversal-encoded`,description:`URL-encoded path traversal: %2e%2e or %2f variants`,pattern:/%2e%2e|%2f\.\.|\.\.%2f/i},{id:`shell-null-byte`,description:`Null byte injection: \\x00 or %00 — truncates strings in C-backed functions`,pattern:/\x00|%00/},{id:`shell-semicolon`,description:`Semicolon command separator: cmd1; cmd2`,pattern:/;/},{id:`shell-pipe`,description:`Pipe operator: cmd1 | cmd2`,pattern:/\|/},{id:`shell-and-operator`,description:`AND operator: cmd1 && cmd2`,pattern:/&&/},{id:`shell-or-operator`,description:`OR operator: cmd1 || cmd2`,pattern:/\|\|/},{id:`shell-backtick`,description:"Backtick command substitution: `cmd`",pattern:/`/},{id:`shell-dollar-paren`,description:`Dollar-paren command substitution: $(cmd)`,pattern:/\$\(/},{id:`shell-dollar-brace`,description:"Dollar-brace variable expansion: ${var} — can be abused for injection",pattern:/\$\{/},{id:`shell-redirect-out`,description:`Output redirection: cmd > file or cmd >> file`,pattern:/>{1,2}/},{id:`shell-redirect-in`,description:`Input redirection: cmd < file`,pattern:/</},{id:`shell-newline-injection`,description:`Newline injection: \\n or \\r — can inject new shell commands`,pattern:/[\n\r]/},{id:`shell-glob-star`,description:`Glob expansion: * or ? — can expand to unintended files`,pattern:/[/\\][*?]/},{id:`shell-absolute-root`,description:`Absolute root path injection: string starting with / or \\ (Windows UNC)`,pattern:/^(?:\/|\\\\)/},{id:`shell-windows-drive`,description:`Windows drive letter path injection: C:\\ or D:/`,pattern:/^[a-zA-Z]:[/\\]/},{id:`shell-curl-wget`,description:`curl/wget with URL or flags — can exfiltrate data or download payloads`,pattern:/\b(?:curl|wget)\s+(?:https?:\/\/|ftp:\/\/|-)/i}],aj=[{id:`redos-nested-quantifier-plus`,description:`Nested + quantifier inside a group with outer quantifier: (a+)+, (.+b)*, etc.`,pattern:/\([^)]*\+[^)]*\)[+*]/},{id:`redos-nested-quantifier-star`,description:`Nested * quantifier: (a*)* or (a*)+ — catastrophic backtracking`,pattern:/\([^)]*\*[^)]*\)[*+]/},{id:`redos-nested-groups`,description:`Doubly nested quantified groups: ((a+)+) — guaranteed catastrophic`,pattern:/\(\([^)]{0,40}\)[+*]\)[+*]/},{id:`redos-alternation-overlap`,description:`Overlapping alternation under quantifier: (a|a)+ — ambiguous NFA paths`,pattern:/\(([^|()]{1,20})\|(?:\1)(?:\|[^|()]{1,20}){0,5}\)[+*?]{1,2}/},{id:`redos-star-plus-concat`,description:`(x*x)+ pattern — triggers super-linear backtracking`,pattern:/\([^)]{0,10}\*[^)]{0,10}\)[+*]/},{id:`redos-dot-star-greedy`,description:`(.*){n,} or (.+){n,} — repeated greedy dot quantifiers`,pattern:/\(\.[*+]\)\{?\d/},{id:`redos-large-repetition`,description:`Very large fixed or range repetition count {1000,} or {1000,n} — denial of service via backtracking`,pattern:/\{\d{4,}(?:,\d*)?\}/},{id:`redos-catastrophic-alternation`,description:`Long alternation with many similar branches — polynomial backtracking risk`,pattern:/\([^)]{0,200}(?:\|[^|)]{0,50}){9,}\)/}],oj=`["'\\s]*:`,sj=[{id:`nosql-where-operator`,description:`$where — executes arbitrary JavaScript server-side in MongoDB`,pattern:RegExp(`\\$where${oj}`,`i`)},{id:`nosql-ne-operator`,description:`$ne — "not equal" operator used to bypass equality checks`,pattern:RegExp(`\\$ne${oj}`,`i`)},{id:`nosql-gt-operator`,description:`$gt — "greater than" used to bypass password/value checks`,pattern:RegExp(`\\$gte?${oj}`,`i`)},{id:`nosql-lt-operator`,description:`$lt / $lte — "less than" bypass variants`,pattern:RegExp(`\\$lte?${oj}`,`i`)},{id:`nosql-regex-operator`,description:`$regex — can be used to extract data character by character (blind injection)`,pattern:RegExp(`\\$regex${oj}`,`i`)},{id:`nosql-or-operator`,description:`$or — logical OR; used to create always-true conditions`,pattern:RegExp(`\\$or${oj}\\s*\\[`,`i`)},{id:`nosql-and-operator`,description:`$and — logical AND operator injection`,pattern:RegExp(`\\$and${oj}\\s*\\[`,`i`)},{id:`nosql-nor-operator`,description:`$nor — logical NOR operator injection`,pattern:RegExp(`\\$nor${oj}\\s*\\[`,`i`)},{id:`nosql-exists-operator`,description:`$exists — can enumerate fields to determine schema`,pattern:RegExp(`\\$exists${oj}`,`i`)},{id:`nosql-in-operator`,description:`$in — matches any value in a list; can enumerate values`,pattern:RegExp(`\\$in${oj}\\s*\\[`,`i`)},{id:`nosql-expr-operator`,description:`$expr — allows aggregation expressions in queries (MongoDB 3.6+)`,pattern:RegExp(`\\$expr${oj}`,`i`)},{id:`nosql-function-operator`,description:`$function — executes arbitrary JavaScript in MongoDB 4.4+`,pattern:RegExp(`\\$function${oj}`,`i`)},{id:`nosql-accumulator-operator`,description:`$accumulator — custom aggregation with arbitrary JS execution`,pattern:RegExp(`\\$accumulator${oj}`,`i`)},{id:`nosql-proto-pollution`,description:`__proto__ — prototype pollution via object key injection`,pattern:/__proto__/},{id:`nosql-constructor-prototype`,description:`constructor.prototype — alternative prototype pollution vector (dot notation or JSON key)`,pattern:/constructor[\s"':.,{\[]*prototype/i},{id:`nosql-proto-bracket`,description:`["__proto__"] — bracket-notation prototype pollution`,pattern:/\[["']__proto__["']\]/}],cj=[{id:`log-crlf-injection`,description:`CRLF injection: literal \\r or \\n embeds fake log lines`,pattern:/[\r\n]/},{id:`log-url-encoded-crlf`,description:`URL-encoded CRLF: %0d, %0a, %0D, %0A — decoded by some log parsers`,pattern:/%0[dDaA]/},{id:`log-unicode-newline`,description:`Unicode newline variants: U+2028 (line separator), U+2029 (paragraph separator)`,pattern:/[\u2028\u2029]/},{id:`log-log4shell-jndi`,description:"Log4Shell: ${jndi:...} triggers remote code execution in Apache Log4j",pattern:/\$\{jndi\s*:/i},{id:`log-log4shell-obfuscated`,description:"Obfuscated Log4Shell: ${::-j}... lookup-bypass prefix used to evade WAF detection",pattern:/\$\{::-/},{id:`log-log4j-lookup`,description:"Log4j lookup syntax: ${env:...}, ${sys:...}, ${ctx:...} — data exfiltration",pattern:/\$\{(?:env|sys|ctx|main|map|sd|web|docker|k8s|spring)\s*:/i},{id:`log-ssti-double-brace`,description:`SSTI double-brace: {{expression}} — Jinja2, Twig, Handlebars, etc.`,pattern:/\{\{[\s\S]{0,80}\}\}/},{id:`log-ssti-hash-brace`,description:`SSTI hash-brace: #{expression} — Thymeleaf, Velocity, Ruby ERB`,pattern:/#\{[\s\S]{0,80}\}/},{id:`log-ssti-dollar-brace`,description:"SSTI/EL injection: ${expression with operators or method calls} — JSP EL, Freemarker, SpEL",pattern:/\$\{[^}]*(?:\.|\(|\*|\+|\bclass\b|\bruntime\b|\bprocess\b|\bexec\b)[^}]{0,80}\}/i},{id:`log-ssti-percent-tag`,description:`SSTI ERB/ASP tag: <%= expression %> — Ruby ERB, ASP`,pattern:/<%=[\s\S]{0,80}%>/},{id:`log-null-byte`,description:`Null byte: \\x00 or %00 — can truncate log entries in C-backed loggers`,pattern:/\x00|%00/},{id:`log-ansi-escape`,description:`ANSI escape sequence: ESC[ — can manipulate terminal output when logs are tailed`,pattern:/\x1b\[/}],lj=[{id:`sql-line-comment`,description:`SQL line comment: -- followed by whitespace or end of string`,pattern:/--(?:\s|$)/},{id:`sql-stacked-query`,description:`Stacked queries: semicolon immediately followed by a SQL keyword`,pattern:/;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i},{id:`sql-hex-encoding`,description:`Hex-encoded string injection: 0x41414141 style (MySQL)`,pattern:/\b0x[0-9a-f]{4,}/i}],uj=[...rj,...lj];ej.label=`HTML`,tj.label=`XML`,nj.label=`SVG`,rj.label=`SQL`,uj.label=`SQL-STRICT`,ij.label=`SHELL`,aj.label=`REDOS`,sj.label=`NOSQL`,cj.label=`LOG`,Object.freeze({HTML:ej,XML:tj,SVG:nj,SQL:rj,"SQL-STRICT":uj,SHELL:ij,REDOS:aj,NOSQL:sj,LOG:cj});function dj(e){if(typeof e!=`string`)throw TypeError(`is-unsafe: first argument must be a string, got ${typeof e}`)}function fj(e){if(!(e instanceof RegExp)){if(Array.isArray(e)){if(e.length===0)throw TypeError(`is-unsafe: context must not be an empty array`);if(Array.isArray(e[0])){for(let t of e)if(!Array.isArray(t)||t.length===0)throw TypeError(`is-unsafe: each context in the array must be a non-empty pattern array (PatternList)`)}return}throw TypeError(`is-unsafe: second argument must be a PatternList (e.g. HTML), an array of PatternLists (e.g. [HTML, XML]), or a RegExp. Got: ${typeof e}`)}}function pj(e){return e instanceof RegExp?{lists:null,regex:e}:Array.isArray(e[0])?{lists:e,regex:null}:{lists:[e],regex:null}}function mj(e,t){let n=t.label??`CUSTOM`;for(let r of t)if(r.pattern.test(e))return{context:n,id:r.id,description:r.description,pattern:r.pattern};return null}function hj(e,t){dj(e),fj(t);let{lists:n,regex:r}=pj(t);if(r)return r.test(e);for(let t of n)if(mj(e,t)!==null)return!0;return!1}function gj(e,t){if(!e)return{};let n=t.attributesGroupName?e[t.attributesGroupName]:e;if(!n)return{};let r={};for(let e in n)if(e.startsWith(t.attributeNamePrefix)){let i=e.substring(t.attributeNamePrefix.length);r[i]=n[e]}else r[e]=n[e];return r}function _j(e){if(!e||typeof e!=`string`)return;let t=e.indexOf(`:`);if(t!==-1&&t>0){let n=e.substring(0,t);if(n!==`xmlns`)return n}}var vj=class{constructor(e,t){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=Cj,this.parseTextData=yj,this.resolveNameSpace=bj,this.buildAttributesMap=Sj,this.isItStopNode=Dj,this.replaceEntitiesValue=Tj,this.readStopNodeData=Mj,this.saveTextToParentTag=Ej,this.addChild=wj,this.ignoreAttributesFn=YA(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0;let n={...Gk};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:(typeof this.options.htmlEntities==`object`?n=this.options.htmlEntities:this.options.htmlEntities===!0&&(n={...Kk,...Hk}),this.entityDecoder=new iA({namedEntities:{...n,...t},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo},onInputEntity:(e,t)=>hj(t,[ej,tj])?qk.BLOCK:qk.ALLOW})),this.matcher=new $A,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new ZA;let r=this.options.stopNodes;if(r&&r.length>0){for(let e=0;e<r.length;e++){let t=r[e];typeof t==`string`?this.stopNodeExpressionsSet.add(new XA(t)):t instanceof XA&&this.stopNodeExpressionsSet.add(t)}this.stopNodeExpressionsSet.seal()}}};function yj(e,t,n,r,i,a,o){let s=this.options;if(e!==void 0&&(s.trimValues&&!r&&(e=e.trim()),e.length>0)){o||(e=this.replaceEntitiesValue(e,t,n));let r=s.jPath?n.toString():n,c=s.tagValueProcessor(t,e,r,i,a);return c==null?e:typeof c!=typeof e||c!==e?c:s.trimValues||e.trim()===e?Nj(e,s.parseTagValue,s.numberParseOptions):e}}function bj(e){if(this.options.removeNSPrefix){let t=e.split(`:`),n=e.charAt(0)===`/`?`/`:``;if(t[0]===`xmlns`)return``;t.length===2&&(e=n+t[1])}return e}var xj=RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,`gm`);function Sj(e,t,n,r=!1){let i=this.options;if(r===!0||i.ignoreAttributes!==!0&&typeof e==`string`){let r=dk(e,xj),a=r.length,o={},s=Array(a),c=!1,l={};for(let e=0;e<a;e++){let t=this.resolveNameSpace(r[e][1]),a=r[e][4];if(t.length&&a!==void 0){let r=a;i.trimValues&&(r=r.trim()),r=this.replaceEntitiesValue(r,n,this.readonlyMatcher),s[e]=r,l[t]=r,c=!0}}c&&typeof t==`object`&&t.updateCurrent&&t.updateCurrent(l);let u=i.jPath?t.toString():this.readonlyMatcher,d=!1;for(let e=0;e<a;e++){let t=this.resolveNameSpace(r[e][1]);if(this.ignoreAttributesFn(t,u))continue;let n=i.attributeNamePrefix+t;if(t.length)if(i.transformAttributeName&&(n=i.transformAttributeName(n)),n=Fj(n,i),r[e][4]!==void 0){let r=s[e],a=i.attributeValueProcessor(t,r,u);a==null?o[n]=r:typeof a!=typeof r||a!==r?o[n]=a:o[n]=Nj(r,i.parseAttributeValue,i.numberParseOptions),d=!0}else i.allowBooleanAttributes&&(o[n]=!0,d=!0)}if(!d)return;if(i.attributesGroupName&&!i.preserveOrder){let e={};return e[i.attributesGroupName]=o,e}return o}}var Cj=function(e){e=e.replace(/\r\n?/g,`
307
+ `);let t=new dA(`!xml`),n=t,r=``;this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;let i=this.options,a=new wA(i.processEntities),o=e.length;for(let s=0;s<o;s++)if(e[s]===`<`){let c=e.charCodeAt(s+1);if(c===47){let t=kj(e,`>`,s,`Closing Tag is not closed.`),a=e.substring(s+2,t).trim();if(i.removeNSPrefix){let e=a.indexOf(`:`);e!==-1&&(a=a.substr(e+1))}a=Pj(i.transformTagName,a,``,i).tagName,n&&(r=this.saveTextToParentTag(r,n,this.readonlyMatcher));let o=this.matcher.getCurrentTag();if(a&&i.unpairedTagsSet.has(a))throw Error(`Unpaired tag can not be used as closing tag: </${a}>`);o&&i.unpairedTagsSet.has(o)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,n=this.tagsNodeStack.pop(),r=``,s=t}else if(c===63){let t=jj(e,s,!1,`?>`);if(!t)throw Error(`Pi Tag is not closed.`);r=this.saveTextToParentTag(r,n,this.readonlyMatcher);let o=this.buildAttributesMap(t.tagExp,this.matcher,t.tagName,!0);if(o){let e=o[this.options.attributeNamePrefix+`version`];this.entityDecoder.setXmlVersion(Number(e)||1),a.setXmlVersion(Number(e)||1)}if(!(i.ignoreDeclaration&&t.tagName===`?xml`||i.ignorePiTags)){let e=new dA(t.tagName);e.add(i.textNodeName,``),t.tagName!==t.tagExp&&t.attrExpPresent&&i.ignoreAttributes!==!0&&(e[`:@`]=o),this.addChild(n,e,this.readonlyMatcher,s)}s=t.closeIndex+1}else if(c===33&&e.charCodeAt(s+2)===45&&e.charCodeAt(s+3)===45){let t=kj(e,`-->`,s+4,`Comment is not closed.`);if(i.commentPropName){let a=e.substring(s+4,t-2);r=this.saveTextToParentTag(r,n,this.readonlyMatcher),n.add(i.commentPropName,[{[i.textNodeName]:a}])}s=t}else if(c===33&&e.charCodeAt(s+2)===68){let t=a.readDocType(e,s);this.entityDecoder.addInputEntities(t.entities),s=t.i}else if(c===33&&e.charCodeAt(s+2)===91){let t=kj(e,`]]>`,s,`CDATA is not closed.`)-2,a=e.substring(s+9,t);r=this.saveTextToParentTag(r,n,this.readonlyMatcher);let o=this.parseTextData(a,n.tagname,this.readonlyMatcher,!0,!1,!0,!0);o??=``,i.cdataPropName?n.add(i.cdataPropName,[{[i.textNodeName]:a}]):n.add(i.textNodeName,o),s=t+2}else{let a=jj(e,s,i.removeNSPrefix);if(!a){let t=e.substring(Math.max(0,s-50),Math.min(o,s+50));throw Error(`readTagExp returned undefined at position ${s}. Context: "${t}"`)}let c=a.tagName,l=a.rawTagName,u=a.tagExp,d=a.attrExpPresent,f=a.closeIndex;if({tagName:c,tagExp:u}=Pj(i.transformTagName,c,u,i),i.strictReservedNames&&(c===i.commentPropName||c===i.cdataPropName||c===i.textNodeName||c===i.attributesGroupName))throw Error(`Invalid tag name: ${c}`);n&&r&&n.tagname!==`!xml`&&(r=this.saveTextToParentTag(r,n,this.readonlyMatcher,!1));let p=n;p&&i.unpairedTagsSet.has(p.tagname)&&(n=this.tagsNodeStack.pop(),this.matcher.pop());let m=!1;u.length>0&&u.lastIndexOf(`/`)===u.length-1&&(m=!0,c[c.length-1]===`/`?(c=c.substr(0,c.length-1),u=c):u=u.substr(0,u.length-1),d=c!==u);let h=null,g;g=_j(l),c!==t.tagname&&this.matcher.push(c,{},g),c!==u&&d&&(h=this.buildAttributesMap(u,this.matcher,c),h&&gj(h,i)),c!==t.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());let _=s;if(this.isCurrentNodeStopNode){let t=``;if(m)s=a.closeIndex;else if(i.unpairedTagsSet.has(c))s=a.closeIndex;else{let n=this.readStopNodeData(e,l,f+1);if(!n)throw Error(`Unexpected end of ${l}`);s=n.i,t=n.tagContent}let r=new dA(c);h&&(r[`:@`]=h),r.add(i.textNodeName,t),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(n,r,this.readonlyMatcher,_)}else{if(m){({tagName:c,tagExp:u}=Pj(i.transformTagName,c,u,i));let e=new dA(c);h&&(e[`:@`]=h),this.addChild(n,e,this.readonlyMatcher,_),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(i.unpairedTagsSet.has(c)){let e=new dA(c);h&&(e[`:@`]=h),this.addChild(n,e,this.readonlyMatcher,_),this.matcher.pop(),this.isCurrentNodeStopNode=!1,s=a.closeIndex;continue}else{let e=new dA(c);if(this.tagsNodeStack.length>i.maxNestedTags)throw Error(`Maximum nested tags exceeded`);this.tagsNodeStack.push(n),h&&(e[`:@`]=h),this.addChild(n,e,this.readonlyMatcher,_),n=e}r=``,s=f}}}else r+=e[s];return t.child};function wj(e,t,n,r){this.options.captureMetaData||(r=void 0);let i=this.options.jPath?n.toString():n,a=this.options.updateTag(t.tagname,i,t[`:@`]);a===!1||(typeof a==`string`&&(t.tagname=a),e.addChild(t,r))}function Tj(e,t,n){let r=this.options.processEntities;if(!r||!r.enabled)return e;if(r.allowedTags){let i=this.options.jPath?n.toString():n;if(!(Array.isArray(r.allowedTags)?r.allowedTags.includes(t):r.allowedTags(t,i)))return e}if(r.tagFilter){let i=this.options.jPath?n.toString():n;if(!r.tagFilter(t,i))return e}return this.entityDecoder.decode(e)}function Ej(e,t,n,r){return e&&=(r===void 0&&(r=t.child.length===0),e=this.parseTextData(e,t.tagname,n,!1,t[`:@`]?Object.keys(t[`:@`]).length!==0:!1,r),e!==void 0&&e!==``&&t.add(this.options.textNodeName,e),``),e}function Dj(){return this.stopNodeExpressionsSet.size===0?!1:this.matcher.matchesAny(this.stopNodeExpressionsSet)}function Oj(e,t,n=`>`){let r=0,i=e.length,a=n.charCodeAt(0),o=n.length>1?n.charCodeAt(1):-1,s=``,c=t;for(let n=t;n<i;n++){let t=e.charCodeAt(n);if(r)t===r&&(r=0);else if(t===34||t===39)r=t;else if(t===a)if(o!==-1){if(e.charCodeAt(n+1)===o)return s+=e.substring(c,n),{data:s,index:n}}else return s+=e.substring(c,n),{data:s,index:n};else t===9&&!r&&(s+=e.substring(c,n)+` `,c=n+1)}}function kj(e,t,n,r){let i=e.indexOf(t,n);if(i===-1)throw Error(r);return i+t.length-1}function Aj(e,t,n,r){let i=e.indexOf(t,n);if(i===-1)throw Error(r);return i}function jj(e,t,n,r=`>`){let i=Oj(e,t+1,r);if(!i)return;let a=i.data,o=i.index,s=a.search(/\s/),c=a,l=!0;s!==-1&&(c=a.substring(0,s),a=a.substring(s+1).trimStart());let u=c;if(n){let e=c.indexOf(`:`);e!==-1&&(c=c.substr(e+1),l=c!==i.data.substr(e+1))}return{tagName:c,tagExp:a,closeIndex:o,attrExpPresent:l,rawTagName:u}}function Mj(e,t,n){let r=n,i=1,a=e.length;for(;n<a;n++)if(e[n]===`<`){let a=e.charCodeAt(n+1);if(a===47){let a=Aj(e,`>`,n,`${t} is not closed`);if(e.substring(n+2,a).trim()===t&&(i--,i===0))return{tagContent:e.substring(r,n),i:a};n=a}else if(a===63)n=kj(e,`?>`,n+1,`StopNode is not closed.`);else if(a===33&&e.charCodeAt(n+2)===45&&e.charCodeAt(n+3)===45)n=kj(e,`-->`,n+3,`StopNode is not closed.`);else if(a===33&&e.charCodeAt(n+2)===91)n=kj(e,`]]>`,n,`StopNode is not closed.`)-2;else{let r=jj(e,n,!1);r&&((r&&r.tagName)===t&&r.tagExp[r.tagExp.length-1]!==`/`&&i++,n=r.closeIndex)}}}function Nj(e,t,n){if(t&&typeof e==`string`){let t=e.trim();return t===`true`?!0:t===`false`?!1:UA(e,n)}else if(pk(e))return e;else return``}function Pj(e,t,n,r){if(e){let r=e(t);n===t&&(n=r),t=r}return t=Fj(t,r),{tagName:t,tagExp:n}}function Fj(e,t){if(hk.includes(e))throw Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);return mk.includes(e)?t.onDangerousProperty(e):e}var Ij=dA.getMetaDataSymbol();function Lj(e,t){if(!e||typeof e!=`object`)return{};if(!t)return e;let n={};for(let r in e)if(r.startsWith(t)){let i=r.substring(t.length);n[i]=e[r]}else n[r]=e[r];return n}function Rj(e,t,n,r){return zj(e,t,n,r)}function zj(e,t,n,r){let i,a={};for(let o=0;o<e.length;o++){let s=e[o],c=Bj(s);if(c!==void 0&&c!==t.textNodeName){let e=Lj(s[`:@`]||{},t.attributeNamePrefix);n.push(c,e)}if(c===t.textNodeName)i===void 0?i=s[c]:i+=``+s[c];else if(c===void 0)continue;else if(s[c]){let e=zj(s[c],t,n,r),i=Hj(e,t);if(Object.keys(e).length===0&&t.alwaysCreateTextNode&&(e[t.textNodeName]=``),s[`:@`]?Vj(e,s[`:@`],r,t):Object.keys(e).length===1&&e[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?e=e[t.textNodeName]:Object.keys(e).length===0&&(t.alwaysCreateTextNode?e[t.textNodeName]=``:e=``),s[Ij]!==void 0&&typeof e==`object`&&e&&(e[Ij]=s[Ij]),a[c]!==void 0&&Object.prototype.hasOwnProperty.call(a,c))Array.isArray(a[c])||(a[c]=[a[c]]),a[c].push(e);else{let n=t.jPath?r.toString():r;t.isArray(c,n,i)?a[c]=[e]:a[c]=e}c!==void 0&&c!==t.textNodeName&&n.pop()}}return typeof i==`string`?i.length>0&&(a[t.textNodeName]=i):i!==void 0&&(a[t.textNodeName]=i),a}function Bj(e){let t=Object.keys(e);for(let e=0;e<t.length;e++){let n=t[e];if(n!==`:@`)return n}}function Vj(e,t,n,r){if(t){let i=Object.keys(t),a=i.length;for(let o=0;o<a;o++){let a=i[o],s=a.startsWith(r.attributeNamePrefix)?a.substring(r.attributeNamePrefix.length):a,c=r.jPath?n.toString()+`.`+s:n;r.isArray(a,c,!0,!0)?e[a]=[t[a]]:e[a]=t[a]}}}function Hj(e,t){let{textNodeName:n}=t,r=Object.keys(e).length;return!!(r===0||r===1&&(e[n]||typeof e[n]==`boolean`||e[n]===0))}var Uj=class{constructor(e){this.externalEntities={},this.options=lA(e)}parse(e,t){if(typeof e!=`string`&&e.toString)e=e.toString();else if(typeof e!=`string`)throw Error(`XML data is accepted in String or Bytes[] form.`);if(t){t===!0&&(t={});let n=_k(e,t);if(n!==!0)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}let n=new vj(this.options,this.externalEntities),r=n.parseXml(e);return this.options.preserveOrder||r===void 0?r:Rj(r,this.options,n.matcher,n.readonlyMatcher)}addEntity(e,t){if(t.indexOf(`&`)!==-1)throw Error(`Entity value can't have '&'`);if(e.indexOf(`&`)!==-1||e.indexOf(`;`)!==-1)throw Error(`An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'`);if(t===`&`)throw Error(`An entity with value '&' is not permitted`);this.externalEntities[e]=t}static getMetaDataSymbol(){return dA.getMetaDataSymbol()}};function Wj(e){return String(e).replace(/--/g,`- -`).replace(/--/g,`- -`).replace(/-$/,`- `)}function Gj(e){return String(e).replace(/\]\]>/g,`]]]]><![CDATA[>`)}function Kj(e){return String(e).replace(/"/g,`&quot;`).replace(/'/g,`&apos;`)}var qj=`
308
308
  `;function Jj(e,t){if(!Array.isArray(e)||e.length===0)return`1.0`;let n=e[0];if(tM(n)===`?xml`){let e=n[`:@`];if(e){let n=t.attributeNamePrefix+`version`;if(e[n])return e[n]}}return`1.0`}function Yj(e,t,n,r,i){return!n.sanitizeName||i(e)?e:n.sanitizeName(e,{isAttribute:t,matcher:r.readOnly()})}function Xj(e,t){let n=``;t.format&&(n=qj);let r=[];if(t.stopNodes&&Array.isArray(t.stopNodes))for(let e=0;e<t.stopNodes.length;e++){let n=t.stopNodes[e];typeof n==`string`?r.push(new XA(n)):n instanceof XA&&r.push(n)}let i=CA(`qName`,{xmlVersion:Jj(e,t)}),a=new $A;return Zj(e,t,n,a,r,i)}function Zj(e,t,n,r,i,a){let o=``,s=!1;if(t.maxNestedTags&&r.getDepth()>t.maxNestedTags)throw Error(`Maximum nested tags exceeded`);if(!Array.isArray(e)){if(e!=null){let n=e.toString();return n=iM(n,t),n}return``}for(let c=0;c<e.length;c++){let l=e[c],u=tM(l);if(u===void 0)continue;let d=u===t.textNodeName||u===t.cdataPropName||u===t.commentPropName||u[0]===`?`?u:Yj(u,!1,t,r,a),f=Qj(l[`:@`],t);r.push(d,f);let p=rM(r,i);if(d===t.textNodeName){let e=l[u];p||(e=t.tagValueProcessor(d,e),e=iM(e,t)),s&&(o+=n),o+=e,s=!1,r.pop();continue}else if(d===t.cdataPropName){s&&(o+=n);let e=l[u][0][t.textNodeName],i=Gj(e);o+=`<![CDATA[${i}]]>`,s=!1,r.pop();continue}else if(d===t.commentPropName){let e=l[u][0][t.textNodeName],i=Wj(e);o+=n+`<!--${i}-->`,s=!0,r.pop();continue}else if(d[0]===`?`){let e=nM(l[`:@`],t,p,r,a);o+=(d===`?xml`?``:n)+`<${d}${e}?>`,s=!0,r.pop();continue}let m=n;m!==``&&(m+=t.indentBy);let h=n+`<${d}${nM(l[`:@`],t,p,r,a)}`,g;g=p?$j(l[u],t):Zj(l[u],t,m,r,i,a),t.unpairedTags.indexOf(d)===-1?(!g||g.length===0)&&t.suppressEmptyNode?o+=h+`/>`:g&&g.endsWith(`>`)?o+=h+`>${g}${n}</${d}>`:(o+=h+`>`,g&&n!==``&&(g.includes(`/>`)||g.includes(`</`))?o+=n+t.indentBy+g+n:o+=g,o+=`</${d}>`):t.suppressUnpairedNode?o+=h+`>`:o+=h+`/>`,s=!0,r.pop()}return o}function Qj(e,t){if(!e||t.ignoreAttributes)return null;let n={},r=!1;for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;let a=i.startsWith(t.attributeNamePrefix)?i.substr(t.attributeNamePrefix.length):i;n[a]=Kj(e[i]),r=!0}return r?n:null}function $j(e,t){if(!Array.isArray(e))return e==null?``:e.toString();let n=``;for(let r=0;r<e.length;r++){let i=e[r],a=tM(i);if(a===t.textNodeName)n+=i[a];else if(a===t.cdataPropName)n+=i[a][0][t.textNodeName];else if(a===t.commentPropName)n+=i[a][0][t.textNodeName];else if(a&&a[0]===`?`)continue;else if(a){let e=eM(i[`:@`],t),r=$j(i[a],t);!r||r.length===0?n+=`<${a}${e}/>`:n+=`<${a}${e}>${r}</${a}>`}}return n}function eM(e,t){let n=``;if(e&&!t.ignoreAttributes)for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=e[r];i===!0&&t.suppressBooleanAttributes?n+=` ${r.substr(t.attributeNamePrefix.length)}`:n+=` ${r.substr(t.attributeNamePrefix.length)}="${Kj(i)}"`}return n}function tM(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n];if(Object.prototype.hasOwnProperty.call(e,r)&&r!==`:@`)return r}}function nM(e,t,n,r,i){let a=``;if(e&&!t.ignoreAttributes)for(let o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;let s=o.substr(t.attributeNamePrefix.length),c=n?s:Yj(s,!0,t,r,i),l;n?l=e[o]:(l=t.attributeValueProcessor(o,e[o]),l=iM(l,t)),l===!0&&t.suppressBooleanAttributes?a+=` ${c}`:a+=` ${c}="${Kj(l)}"`}return a}function rM(e,t){if(!t||t.length===0)return!1;for(let n=0;n<t.length;n++)if(e.matches(t[n]))return!0;return!1}function iM(e,t){if(e&&e.length>0&&t.processEntities)for(let n=0;n<t.entities.length;n++){let r=t.entities[n];e=e.replace(r.regex,r.val)}return e}function aM(e){return typeof e==`function`?e:Array.isArray(e)?t=>{for(let n of e)if(typeof n==`string`&&t===n||n instanceof RegExp&&n.test(t))return!0}:()=>!1}var oM={attributeNamePrefix:`@_`,attributesGroupName:!1,textNodeName:`#text`,ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:` `,suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:RegExp(`&`,`g`),val:`&amp;`},{regex:RegExp(`>`,`g`),val:`&gt;`},{regex:RegExp(`<`,`g`),val:`&lt;`},{regex:RegExp(`'`,`g`),val:`&apos;`},{regex:RegExp(`"`,`g`),val:`&quot;`}],processEntities:!0,stopNodes:[],oneListGroup:!1,maxNestedTags:100,jPath:!0,sanitizeName:!1};function sM(e){if(this.options=Object.assign({},oM,e),this.options.stopNodes&&Array.isArray(this.options.stopNodes)&&(this.options.stopNodes=this.options.stopNodes.map(e=>typeof e==`string`&&e.startsWith(`*.`)?`..`+e.substring(2):e)),this.stopNodeExpressions=[],this.options.stopNodes&&Array.isArray(this.options.stopNodes))for(let e=0;e<this.options.stopNodes.length;e++){let t=this.options.stopNodes[e];typeof t==`string`?this.stopNodeExpressions.push(new XA(t)):t instanceof XA&&this.stopNodeExpressions.push(t)}this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=aM(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=fM),this.processTextOrObjNode=uM,this.options.format?(this.indentate=dM,this.tagEndChar=`>
309
309
  `,this.newLine=`
310
- `):(this.indentate=function(){return``},this.tagEndChar=`>`,this.newLine=``)}function cM(e,t){let n=e[`?xml`];if(n&&typeof n==`object`){if(t.attributesGroupName&&n[t.attributesGroupName]){let e=n[t.attributesGroupName][t.attributeNamePrefix+`version`];if(e)return e}let e=n[t.attributeNamePrefix+`version`];if(e)return e}return`1.0`}function lM(e,t,n,r,i){return!n.sanitizeName||i(e)?e:n.sanitizeName(e,{isAttribute:t,matcher:r.readOnly()})}sM.prototype.build=function(e){if(this.options.preserveOrder)return Xj(e,this.options);{Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e});let t=new $A,n=CA(`qName`,{xmlVersion:cM(e,this.options)});return this.j2x(e,0,t,n).val}},sM.prototype.j2x=function(e,t,n,r){let i=``,a=``;if(this.options.maxNestedTags&&n.getDepth()>=this.options.maxNestedTags)throw Error(`Maximum nested tags exceeded`);let o=this.options.jPath?n.toString():n,s=this.checkStopNode(n);for(let c in e){if(!Object.prototype.hasOwnProperty.call(e,c))continue;let l=c===this.options.textNodeName||c===this.options.cdataPropName||c===this.options.commentPropName||this.options.attributesGroupName&&c===this.options.attributesGroupName||this.isAttribute(c)||c[0]===`?`?c:lM(c,!1,this.options,n,r);if(e[c]===void 0)this.isAttribute(c)&&(a+=``);else if(e[c]===null)this.isAttribute(c)||l===this.options.cdataPropName||l===this.options.commentPropName?a+=``:l[0]===`?`?a+=this.indentate(t)+`<`+l+`?`+this.tagEndChar:a+=this.indentate(t)+`<`+l+`/`+this.tagEndChar;else if(e[c]instanceof Date)a+=this.buildTextValNode(e[c],l,``,t,n);else if(typeof e[c]!=`object`){let u=this.isAttribute(c);if(u&&!this.ignoreAttributesFn(u,o)){let t=lM(u,!0,this.options,n,r);i+=this.buildAttrPairStr(t,``+e[c],s)}else if(!u)if(c===this.options.textNodeName){let t=this.options.tagValueProcessor(c,``+e[c]);a+=this.replaceEntitiesValue(t)}else{n.push(l);let r=this.checkStopNode(n);if(n.pop(),r){let n=``+e[c];n===``?a+=this.indentate(t)+`<`+l+this.closeTag(l)+this.tagEndChar:a+=this.indentate(t)+`<`+l+`>`+n+`</`+l+this.tagEndChar}else a+=this.buildTextValNode(e[c],l,``,t,n)}}else if(Array.isArray(e[c])){let i=e[c].length,o=``,s=``;for(let u=0;u<i;u++){let i=e[c][u];if(i!==void 0)if(i===null)l[0]===`?`?a+=this.indentate(t)+`<`+l+`?`+this.tagEndChar:a+=this.indentate(t)+`<`+l+`/`+this.tagEndChar;else if(typeof i==`object`)if(this.options.oneListGroup){n.push(l);let e=this.j2x(i,t+1,n,r);n.pop(),o+=e.val,this.options.attributesGroupName&&i.hasOwnProperty(this.options.attributesGroupName)&&(s+=e.attrStr)}else o+=this.processTextOrObjNode(i,l,t,n,r);else if(this.options.oneListGroup){let e=this.options.tagValueProcessor(l,i);e=this.replaceEntitiesValue(e),o+=e}else{n.push(l);let e=this.checkStopNode(n);if(n.pop(),e){let e=``+i;e===``?o+=this.indentate(t)+`<`+l+this.closeTag(l)+this.tagEndChar:o+=this.indentate(t)+`<`+l+`>`+e+`</`+l+this.tagEndChar}else o+=this.buildTextValNode(i,l,``,t,n)}}this.options.oneListGroup&&(o=this.buildObjectNode(o,l,s,t)),a+=o}else if(this.options.attributesGroupName&&c===this.options.attributesGroupName){let t=Object.keys(e[c]),a=t.length;for(let o=0;o<a;o++){let a=lM(t[o],!0,this.options,n,r);i+=this.buildAttrPairStr(a,``+e[c][t[o]],s)}}else a+=this.processTextOrObjNode(e[c],l,t,n,r)}return{attrStr:i,val:a}},sM.prototype.buildAttrPairStr=function(e,t,n){return n||(t=this.options.attributeValueProcessor(e,``+t),t=this.replaceEntitiesValue(t)),this.options.suppressBooleanAttributes&&t===`true`?` `+e:` `+e+`="`+Kj(t)+`"`};function uM(e,t,n,r,i){let a=this.extractAttributes(e);if(r.push(t,a),this.checkStopNode(r)){let i=this.buildRawContent(e),a=this.buildAttributesForStopNode(e);return r.pop(),this.buildObjectNode(i,t,a,n)}let o=this.j2x(e,n+1,r,i);return r.pop(),t[0]===`?`?this.buildTextValNode(``,t,o.attrStr,n,r):e[this.options.textNodeName]!==void 0&&Object.keys(e).length===1?this.buildTextValNode(e[this.options.textNodeName],t,o.attrStr,n,r):this.buildObjectNode(o.val,t,o.attrStr,n)}sM.prototype.extractAttributes=function(e){if(!e||typeof e!=`object`)return null;let t={},n=!1;if(this.options.attributesGroupName&&e[this.options.attributesGroupName]){let r=e[this.options.attributesGroupName];for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e))continue;let i=e.startsWith(this.options.attributeNamePrefix)?e.substring(this.options.attributeNamePrefix.length):e;t[i]=Kj(r[e]),n=!0}}else for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=this.isAttribute(r);i&&(t[i]=Kj(e[r]),n=!0)}return n?t:null},sM.prototype.buildRawContent=function(e){if(typeof e==`string`)return e;if(typeof e!=`object`||!e)return String(e);if(e[this.options.textNodeName]!==void 0)return e[this.options.textNodeName];let t=``;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n)||this.isAttribute(n)||this.options.attributesGroupName&&n===this.options.attributesGroupName)continue;let r=e[n];if(n===this.options.textNodeName)t+=r;else if(Array.isArray(r)){for(let e of r)if(typeof e==`string`||typeof e==`number`)t+=`<${n}>${e}</${n}>`;else if(typeof e==`object`&&e){let r=this.buildRawContent(e),i=this.buildAttributesForStopNode(e);r===``?t+=`<${n}${i}/>`:t+=`<${n}${i}>${r}</${n}>`}}else if(typeof r==`object`&&r){let e=this.buildRawContent(r),i=this.buildAttributesForStopNode(r);e===``?t+=`<${n}${i}/>`:t+=`<${n}${i}>${e}</${n}>`}else t+=`<${n}>${r}</${n}>`}return t},sM.prototype.buildAttributesForStopNode=function(e){if(!e||typeof e!=`object`)return``;let t=``;if(this.options.attributesGroupName&&e[this.options.attributesGroupName]){let n=e[this.options.attributesGroupName];for(let e in n){if(!Object.prototype.hasOwnProperty.call(n,e))continue;let r=e.startsWith(this.options.attributeNamePrefix)?e.substring(this.options.attributeNamePrefix.length):e,i=n[e];i===!0&&this.options.suppressBooleanAttributes?t+=` `+r:t+=` `+r+`="`+Kj(i)+`"`}}else for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;let r=this.isAttribute(n);if(r){let i=e[n];i===!0&&this.options.suppressBooleanAttributes?t+=` `+r:t+=` `+r+`="`+Kj(i)+`"`}}return t},sM.prototype.buildObjectNode=function(e,t,n,r){if(e===``)return t[0]===`?`?this.indentate(r)+`<`+t+n+`?`+this.tagEndChar:this.indentate(r)+`<`+t+n+this.closeTag(t)+this.tagEndChar;if(t[0]===`?`)return this.indentate(r)+`<`+t+n+`?`+this.tagEndChar;{let i=`</`+t+this.tagEndChar,a=``;return t[0]===`?`&&(a=`?`,i=``),(n||n===``)&&e.indexOf(`<`)===-1?this.indentate(r)+`<`+t+n+a+`>`+e+i:this.options.commentPropName!==!1&&t===this.options.commentPropName&&a.length===0?this.indentate(r)+`<!--${Wj(e)}-->`+this.newLine:this.indentate(r)+`<`+t+n+a+this.tagEndChar+e+this.indentate(r)+i}},sM.prototype.closeTag=function(e){let t=``;return this.options.unpairedTags.indexOf(e)===-1?t=this.options.suppressEmptyNode?`/`:`></${e}`:this.options.suppressUnpairedNode||(t=`/`),t},sM.prototype.checkStopNode=function(e){if(!this.stopNodeExpressions||this.stopNodeExpressions.length===0)return!1;for(let t=0;t<this.stopNodeExpressions.length;t++)if(e.matches(this.stopNodeExpressions[t]))return!0;return!1},sM.prototype.buildTextValNode=function(e,t,n,r,i){if(this.options.cdataPropName!==!1&&t===this.options.cdataPropName){let t=Gj(e);return this.indentate(r)+`<![CDATA[${t}]]>`+this.newLine}else if(this.options.commentPropName!==!1&&t===this.options.commentPropName){let t=Wj(e);return this.indentate(r)+`<!--${t}-->`+this.newLine}else if(t[0]===`?`)return this.indentate(r)+`<`+t+n+`?`+this.tagEndChar;else{let i=this.options.tagValueProcessor(t,e);return i=this.replaceEntitiesValue(i),i===``?this.indentate(r)+`<`+t+n+this.closeTag(t)+this.tagEndChar:this.indentate(r)+`<`+t+n+`>`+i+`</`+t+this.tagEndChar}},sM.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){let n=this.options.entities[t];e=e.replace(n.regex,n.val)}return e};function dM(e){return this.options.indentBy.repeat(e)}function fM(e){return e.startsWith(this.options.attributeNamePrefix)&&e!==this.options.textNodeName?e.substr(this.attrPrefixLen):!1}var pM=sM,mM=f.z.object({created_at:f.z.string(),updated_at:f.z.string()}),hM=f.z.enum([`local`,`shared`,`platform`]),gM=f.z.enum([`none`,`secrets`,`fields`]),_M={scope:hM.optional(),override:gM.optional(),enforce:f.z.boolean().optional()},vM=f.z.object({id:f.z.string(),version:f.z.string().optional()}),yM=f.z.object({name:f.z.string(),version:f.z.string()}),bM=f.z.object({name:f.z.string(),value:f.z.string().optional()}),xM=f.z.object({name:f.z.string().max(255),code:f.z.string().max(1e5),supported_triggers:f.z.array(vM).optional(),runtime:f.z.string().max(50).optional(),dependencies:f.z.array(yM).optional(),secrets:f.z.array(bM).optional(),is_system:f.z.boolean().optional(),..._M,inherit:f.z.boolean().optional()});xM.partial().extend({status:f.z.enum([`draft`,`built`]).optional(),deployed_at:f.z.string().optional()});var SM=xM.extend({id:f.z.string(),tenant_id:f.z.string(),status:f.z.enum([`draft`,`built`]).default(`built`),deployed_at:f.z.string().optional(),secrets:f.z.array(f.z.object({name:f.z.string(),value:f.z.string().optional()})).optional()}).extend(mM.shape),CM=f.z.object({name:f.z.string()});SM.extend({secrets:f.z.array(CM).optional()});var wM=f.z.string(),TM=f.z.enum([`unspecified`,`pending`,`final`,`partial`,`canceled`,`suspended`]),EM=f.z.object({id:f.z.string(),msg:f.z.string(),url:f.z.string().optional()}),DM=f.z.object({action_name:f.z.string(),error:EM.nullable(),started_at:f.z.string(),ended_at:f.z.string()}),OM=f.z.object({level:f.z.enum([`log`,`info`,`warn`,`error`,`debug`]),message:f.z.string()}),kM=f.z.array(f.z.object({action_name:f.z.string(),lines:f.z.array(OM)}));f.z.object({id:f.z.string(),tenant_id:f.z.string(),trigger_id:wM,status:TM,results:f.z.array(DM),logs:kM.optional(),created_at:f.z.string(),updated_at:f.z.string()}).omit({tenant_id:!0,created_at:!0,updated_at:!0}),f.z.object({action_id:f.z.string(),code:f.z.string().max(1e5),runtime:f.z.string().max(50).optional(),dependencies:f.z.array(yM).optional(),secrets:f.z.array(bM).optional(),supported_triggers:f.z.array(vM).optional(),deployed:f.z.boolean().default(!0)}).extend({id:f.z.string(),tenant_id:f.z.string(),number:f.z.number().int()}).extend(mM.shape);var AM=f.z.enum([`user_action`,`admin_action`,`system`,`api`]),jM=f.z.object({type:f.z.enum([`user`,`admin`,`system`,`api_key`,`client_credentials`]),id:f.z.string().optional(),email:f.z.string().optional(),org_id:f.z.string().optional(),org_name:f.z.string().optional(),scopes:f.z.array(f.z.string()).optional(),client_id:f.z.string().optional()}),MM=f.z.object({type:f.z.string(),id:f.z.string(),before:f.z.record(f.z.string(),f.z.unknown()).optional(),after:f.z.record(f.z.string(),f.z.unknown()).optional(),diff:f.z.record(f.z.string(),f.z.object({old:f.z.unknown(),new:f.z.unknown()})).optional()}),NM=f.z.object({user:f.z.object({user_id:f.z.string(),name:f.z.string().optional(),email:f.z.string().optional()}).optional(),strategy:f.z.string(),credentials:f.z.object({jti:f.z.string().optional(),scopes:f.z.array(f.z.string()).optional()}).optional()}),PM=f.z.object({method:f.z.string(),path:f.z.string(),query:f.z.record(f.z.string(),f.z.string()).optional(),body:f.z.unknown().optional(),ip:f.z.string(),user_agent:f.z.string().optional(),correlation_id:f.z.string().optional(),redirect_uri:f.z.string().optional(),authorization_url:f.z.string().optional(),auth:NM.optional()}),FM=f.z.object({status_code:f.z.number(),body:f.z.unknown().optional()}),IM=f.z.object({country_code:f.z.string(),city_name:f.z.string(),latitude:f.z.string(),longitude:f.z.string(),time_zone:f.z.string(),continent_code:f.z.string()}),LM=f.z.object({name:f.z.string(),version:f.z.string(),env:f.z.record(f.z.string(),f.z.string()).optional()});f.z.object({tenant_id:f.z.string(),event_type:f.z.string(),log_type:f.z.string(),description:f.z.string().optional(),category:AM,actor:jM,target:MM,request:PM,response:FM.optional(),connection:f.z.string().optional(),connection_id:f.z.string().optional(),client_name:f.z.string().optional(),strategy:f.z.string().optional(),strategy_type:f.z.string().optional(),audience:f.z.string().optional(),scope:f.z.string().optional(),location:IM.optional(),auth0_client:LM.optional(),hostname:f.z.string(),is_mobile:f.z.boolean().optional(),execution_id:f.z.string().optional(),details:f.z.record(f.z.string(),f.z.unknown()).optional(),login_session_id:f.z.string().optional(),timestamp:f.z.string()}).extend({id:f.z.string()}),f.z.enum([`AUTH0`,`EMAIL`,`REDIRECT`]),f.z.enum([`CREATE_USER`,`GET_USER`,`UPDATE_USER`,`SEND_REQUEST`,`SEND_EMAIL`]),f.z.enum([`VERIFY_EMAIL`]);var RM=f.z.object({require_mx_record:f.z.boolean().optional(),block_aliases:f.z.boolean().optional(),block_free_emails:f.z.boolean().optional(),block_disposable_emails:f.z.boolean().optional(),blocklist:f.z.array(f.z.string()).optional(),allowlist:f.z.array(f.z.string()).optional()}),zM=f.z.object({id:f.z.string(),alias:f.z.string().max(100).optional(),type:f.z.literal(`AUTH0`),action:f.z.literal(`UPDATE_USER`),allow_failure:f.z.boolean().optional(),mask_output:f.z.boolean().optional(),params:f.z.object({connection_id:f.z.string().optional(),user_id:f.z.string(),changes:f.z.record(f.z.string(),f.z.any())})}),BM=f.z.object({id:f.z.string(),alias:f.z.string().max(100).optional(),type:f.z.literal(`EMAIL`),action:f.z.literal(`VERIFY_EMAIL`),allow_failure:f.z.boolean().optional(),mask_output:f.z.boolean().optional(),params:f.z.object({email:f.z.string(),rules:RM.optional()})}),VM=f.z.enum([`change-email`,`account`,`custom`]),HM=f.z.object({id:f.z.string(),alias:f.z.string().max(100).optional(),type:f.z.literal(`REDIRECT`),action:f.z.literal(`REDIRECT_USER`),allow_failure:f.z.boolean().optional(),mask_output:f.z.boolean().optional(),params:f.z.object({target:VM.openapi({description:`The predefined target to redirect to, or 'custom' for a custom URL`}),custom_url:f.z.string().optional().openapi({description:`Custom URL to redirect to when target is 'custom'`})})}),UM=f.z.union([zM,BM,HM]);f.z.object({name:f.z.string().min(1).max(150).openapi({description:`The name of the flow`}),actions:f.z.array(UM).optional().default([]).openapi({description:`The list of actions to execute in sequence`})}).extend(mM.shape).extend({id:f.z.string().openapi({description:`Unique identifier for the flow`,example:`af_12tMpdJ3iek7svMyZkSh5M`})}),f.z.object({page:f.z.string().min(0).optional().default(`0`).transform(e=>parseInt(e,10)).openapi({description:`The page number where 0 is the first page`}),per_page:f.z.string().min(1).optional().default(`50`).transform(e=>parseInt(e,10)).openapi({description:`The number of items per page. Defaults to 50.`}),include_totals:f.z.string().optional().default(`false`).transform(e=>e===`true`).openapi({description:`If the total number of items should be included in the response`}),sort:f.z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:`A property that should have the format 'string:-1' or 'string:1'`}),q:f.z.string().optional().openapi({description:`A lucene query string used to filter the results`})}),f.z.object({start:f.z.number(),limit:f.z.number(),length:f.z.number(),total:f.z.number().optional(),next:f.z.string().optional()});var WM=f.z.object({email:f.z.string().optional(),email_verified:f.z.boolean().optional(),name:f.z.string().optional(),username:f.z.string().optional(),given_name:f.z.string().optional(),phone_number:f.z.string().optional(),phone_verified:f.z.boolean().optional(),family_name:f.z.string().optional()}).catchall(f.z.any()),GM=f.z.object({connection:f.z.string(),user_id:f.z.string(),provider:f.z.string(),isSocial:f.z.boolean(),email:f.z.string().optional(),email_verified:f.z.boolean().optional(),phone_number:f.z.string().optional(),phone_verified:f.z.boolean().optional(),username:f.z.string().optional(),access_token:f.z.string().optional(),access_token_secret:f.z.string().optional(),refresh_token:f.z.string().optional(),profileData:WM.optional()}),KM=f.z.object({formatted:f.z.string().optional(),street_address:f.z.string().optional(),locality:f.z.string().optional(),region:f.z.string().optional(),postal_code:f.z.string().optional(),country:f.z.string().optional()}).optional(),qM=f.z.object({email:f.z.string().transform(e=>e.toLowerCase()).optional(),username:f.z.string().refine(e=>!e.includes(`@`),{message:`Usernames must not contain "@". Use the email field for email addresses.`}).optional(),phone_number:f.z.string().optional(),phone_verified:f.z.boolean().optional(),given_name:f.z.string().optional(),family_name:f.z.string().optional(),nickname:f.z.string().optional(),name:f.z.string().optional(),picture:f.z.string().optional(),locale:f.z.string().optional(),linked_to:f.z.string().optional(),profileData:f.z.string().optional(),user_id:f.z.string().optional(),app_metadata:f.z.any().default({}).optional(),user_metadata:f.z.any().default({}).optional(),middle_name:f.z.string().optional(),preferred_username:f.z.string().optional(),profile:f.z.string().optional(),website:f.z.string().optional(),gender:f.z.string().optional(),birthdate:f.z.string().optional(),zoneinfo:f.z.string().optional(),address:KM});qM.extend({email_verified:f.z.boolean().default(!1),verify_email:f.z.boolean().optional(),last_ip:f.z.string().optional(),last_login:f.z.string().optional(),user_id:f.z.string().optional(),provider:f.z.string().optional(),connection:f.z.string(),is_social:f.z.boolean().optional(),blocked:f.z.boolean().optional(),registration_completed_at:f.z.string().optional(),password:f.z.object({hash:f.z.string(),algorithm:f.z.string()}).optional()}).omit({password:!0}).extend(mM.shape).extend({user_id:f.z.string(),provider:f.z.string(),is_social:f.z.boolean(),email:f.z.string().optional(),login_count:f.z.number().default(0),identities:f.z.array(GM).optional()}).omit({registration_completed_at:!0}),qM.extend({login_count:f.z.number(),multifactor:f.z.array(f.z.string()).optional(),last_ip:f.z.string().optional(),last_login:f.z.string().optional(),user_id:f.z.string()}).catchall(f.z.any());function JM(){return f.z.string().trim()}var YM=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,XM=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=YM[n[e]&63];return t},ZM=f.z.enum([`cookie`,`query`]),QM=f.z.enum([`ip`,`asn`,`none`]),$M=f.z.object({can_create_session_transfer_token:f.z.boolean().optional().openapi({default:!1,description:`Whether this client may exchange a refresh token for a session_transfer_token.`}),enforce_cascade_revocation:f.z.boolean().optional().openapi({default:!0,description:`Whether revoking the refresh token a session_transfer_token was minted from also ends the sessions (and their refresh tokens) created with that token.`}),allowed_authentication_methods:f.z.array(ZM).optional().openapi({default:[],description:"How this client accepts a session_transfer_token at /authorize: as the `session_transfer_token` query parameter (`query`) and/or the `auth0_session_transfer_token` cookie (`cookie`). Empty means the client does not accept session transfer."}),enforce_device_binding:QM.optional().openapi({default:`ip`,description:"Whether the browser redeeming a session_transfer_token must come from the same IP address (`ip`) or autonomous system (`asn`) as the request that minted it. `none` disables the check."}),allow_refresh_token:f.z.boolean().optional().openapi({default:!1,description:`Whether a login established with a session_transfer_token may be issued a refresh token.`}),enforce_online_refresh_tokens:f.z.boolean().optional().openapi({default:!0,description:`Whether refresh tokens issued on a transferred session are bound to that session's lifetime.`}),allow_onward_transfer:f.z.boolean().optional().openapi({default:!1,description:`AuthHero extension. Whether this client may mint a session_transfer_token from a login that was itself established with one (A → B → C). The onward token stays tied to the original refresh token.`}),trust_forwarded_ip:f.z.boolean().optional().openapi({default:!1,description:"AuthHero extension. Whether an authenticated confidential client may pass the end user's IP address in the `auth0-forwarded-for` header when minting, so device binding compares against the browser rather than the client's backend. Ignored for requests without client authentication."})}).passthrough(),eN=f.z.object({client_id:f.z.string().describe(`The client that minted the session_transfer_token`),family_id:f.z.string().describe(`Rotation family of the refresh token the session_transfer_token was minted from. The family id is stable across rotation, the row id is not.`),cascade_revocation:f.z.boolean().describe(`Whether this session ends when the parent refresh token family is no longer active`)}),tN=f.z.object({client_id:f.z.string().optional().openapi({description:`ID of this client. Generated server-side if omitted (Auth0 behavior).`}),name:f.z.string().min(1).openapi({description:`Name of this client (min length: 1 character, does not allow < or >).`}),description:f.z.string().max(140).optional().openapi({description:`Free text description of this client (max length: 140 characters).`}),global:f.z.boolean().default(!1).openapi({description:`Whether this is your global 'All Applications' client representing legacy tenant settings (true) or a regular client (false).`}),client_secret:JM().default(()=>XM()).optional().openapi({description:`Client secret (which you must not make public).`}),app_type:f.z.enum([`native`,`spa`,`regular_web`,`non_interactive`,`resource_server`,`express_configuration`,`rms`,`box`,`cloudbees`,`concur`,`dropbox`,`mscrm`,`echosign`,`egnyte`,`newrelic`,`office365`,`salesforce`,`sentry`,`sharepoint`,`slack`,`springcm`,`zendesk`,`zoom`,`sso_integration`,`oag`]).default(`regular_web`).optional().openapi({description:`The type of application this client represents`}),logo_uri:f.z.string().url().optional().openapi({description:`URL of the logo to display for this client. Recommended size is 150x150 pixels.`}),is_first_party:f.z.boolean().default(!0).openapi({description:`Whether this client is a first party client (true) or not (false). First-party clients skip the consent screen; third-party clients require explicit user consent for non-basic scopes.`}),oidc_conformant:f.z.boolean().default(!0).openapi({description:`Whether this client conforms to strict OIDC specifications (true) or uses legacy features (false).`}),auth0_conformant:f.z.boolean().default(!0).openapi({description:`Whether this client follows Auth0-compatible behavior (true) or strict OIDC behavior (false). When true, profile/email claims are included in the ID token when scopes are requested. When false, these claims are only available from the userinfo endpoint (strict OIDC 5.4 compliance).`}),callbacks:f.z.array(f.z.string()).default([]).optional().openapi({description:`Comma-separated list of URLs whitelisted for Auth0 to use as a callback to the client after authentication.`}),allowed_origins:f.z.array(f.z.string()).default([]).optional().openapi({description:`Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level (e.g., https://*.contoso.com). Query strings and hash information are not taken into account when validating these URLs.`}),web_origins:f.z.array(f.z.string()).default([]).optional().openapi({description:`Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode.`}),client_aliases:f.z.array(f.z.string()).default([]).optional().openapi({description:`List of audiences/realms for SAML protocol. Used by the wsfed addon.`}),allowed_clients:f.z.array(f.z.string()).default([]).optional().openapi({description:`List of allow clients and API ids that are allowed to make delegation requests. Empty means all all your clients are allowed.`}),connections:f.z.array(f.z.string()).default([]).optional().openapi({description:`List of connection IDs enabled for this client. The order determines the display order on the login page.`}),allowed_logout_urls:f.z.array(f.z.string()).default([]).optional().openapi({description:`Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains.`}),session_transfer:$M.optional().openapi({description:`Session transfer (Auth0 Native to Web SSO) configuration: lets this client mint a session_transfer_token from a refresh token and/or accept one at /authorize.`}),oidc_logout:f.z.object({backchannel_logout_urls:f.z.array(f.z.string()).optional().openapi({description:`URLs that receive a signed OIDC Back-Channel Logout 1.0 logout token when a session this client participated in ends.`}),backchannel_logout_initiators:f.z.object({mode:f.z.enum([`all`,`custom`]).optional().openapi({description:`Whether all session-end events initiate a backchannel logout (all) or only the selected_initiators (custom).`}),selected_initiators:f.z.array(f.z.string()).optional().openapi({description:`Logout initiators that trigger a backchannel logout when mode is custom (e.g. rp-logout, idp-logout, password-changed).`})}).passthrough().optional().openapi({description:`Controls which session-end events initiate backchannel logout notifications. Stored for Auth0 compatibility; not yet enforced — all initiators currently notify.`})}).passthrough().default({}).optional().openapi({description:`Configuration for OIDC backchannel logout`}),grant_types:f.z.array(f.z.string()).default([]).optional().openapi({description:`List of grant types supported for this application. Can include authorization_code, implicit, refresh_token, client_credentials, password, http://auth0.com/oauth/grant-type/password-realm, http://auth0.com/oauth/grant-type/mfa-oob, http://auth0.com/oauth/grant-type/mfa-otp, http://auth0.com/oauth/grant-type/mfa-recovery-code, urn:openid:params:grant-type:ciba, and urn:ietf:params:oauth:grant-type:device_code.`}),jwt_configuration:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Configuration related to JWTs for the client.`}),signing_keys:f.z.array(f.z.record(f.z.string(),f.z.any())).default([]).optional().openapi({description:`Signing certificates associated with this client.`}),encryption_key:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Encryption used for WsFed responses with this client.`}),sso:f.z.boolean().default(!1).openapi({description:`Applies only to SSO clients and determines whether Auth0 will handle Single Sign On (true) or whether the Identity Provider will (false).`}),sso_disabled:f.z.boolean().default(!1).openapi({description:`Whether Single Sign On is disabled for this client. When true, existing SSO sessions will not be reused and users must authenticate every time.`}),cross_origin_authentication:f.z.boolean().default(!1).openapi({description:`Whether this client can be used to make cross-origin authentication requests (true) or it is not allowed to make such requests (false).`}),cross_origin_loc:f.z.string().url().optional().openapi({description:`URL of the location in your site where the cross origin verification takes place for the cross-origin auth flow when performing Auth in your own domain instead of Auth0 hosted login page.`}),custom_login_page_on:f.z.boolean().default(!1).openapi({description:`Whether a custom login page is to be used (true) or the default provided login page (false).`}),custom_login_page:f.z.string().optional().openapi({description:`The content (HTML, CSS, JS) of the custom login page.`}),custom_login_page_preview:f.z.string().optional().openapi({description:`The content (HTML, CSS, JS) of the custom login page. (Used on Previews)`}),form_template:f.z.string().optional().openapi({description:`HTML form template to be used for WS-Federation.`}),addons:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Addons enabled for this client and their associated configurations.`}),token_endpoint_auth_method:f.z.enum([`none`,`client_secret_post`,`client_secret_basic`,`client_secret_jwt`,`private_key_jwt`]).default(`client_secret_basic`).optional().openapi({description:"Defines the requested authentication method for the token endpoint. `none` (public client), `client_secret_post` / `client_secret_basic` (HTTP POST / Basic), `client_secret_jwt` (RFC 7523 HMAC assertion using client_secret), or `private_key_jwt` (RFC 7523 asymmetric assertion verified against the client's `jwks` / `jwks_uri`)."}),client_metadata:f.z.record(f.z.string(),f.z.string().max(255)).default({}).optional().openapi({description:`Metadata associated with the client, in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. Field names (max 255 chars) are alphanumeric and may only include the following special characters: :,-+=_*?"/()<>@ [Tab][Space]`}),hide_sign_up_disabled_error:f.z.boolean().default(!1).optional().openapi({description:"Enumeration-safe variant of the connection-level `disable_signup` flag. When a signup is blocked by the password connection and this is true, the identifier screen does not reveal that an email is unknown — it advances to the OTP/password challenge as if the account existed and fails at credential check. Mitigates email enumeration at the cost of UX: users without an account see a generic credential failure instead of an explicit signup-disabled message."}),mobile:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Additional configuration for native mobile apps.`}),initiate_login_uri:f.z.string().url().optional().openapi({description:`Initiate login uri, must be https`}),native_social_login:f.z.record(f.z.string(),f.z.any()).default({}).optional(),refresh_token:f.z.object({rotation_type:f.z.enum([`rotating`,`non-rotating`]).optional().openapi({description:`Whether refresh tokens for this client are rotated on every exchange (Auth0 'rotating' behavior) or kept stable (legacy non-rotating). Defaults to 'non-rotating' when unset.`}),leeway:f.z.number().int().min(0).max(600).optional().openapi({description:`Seconds after a parent token's first rotation during which presenting it again still mints a fresh sibling child instead of triggering reuse-detection. Defaults to 30s when unset.`}),expiration_type:f.z.enum([`expiring`,`non-expiring`]).optional().openapi({description:`Whether refresh tokens for this client expire at all. 'non-expiring' overrides both the absolute and the idle lifetime.`}),token_lifetime:f.z.number().int().min(0).optional().openapi({description:"Refresh-token absolute lifetime in seconds. Falls back to the tenant's `session_lifetime` when unset."}),infinite_token_lifetime:f.z.boolean().optional().openapi({description:"When true, refresh tokens have no absolute expiry (overrides `token_lifetime`)."}),idle_token_lifetime:f.z.number().int().min(0).optional().openapi({description:"Refresh-token idle (sliding) lifetime in seconds, refreshed on every exchange. Falls back to the tenant's `idle_session_lifetime` when unset."}),infinite_idle_token_lifetime:f.z.boolean().optional().openapi({description:"When true, refresh tokens have no idle expiry (overrides `idle_token_lifetime`)."})}).default({}).optional().openapi({description:`Refresh token configuration`}),default_organization:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Defines the default Organization ID and flows`}),organization_usage:f.z.enum([`deny`,`allow`,`require`]).default(`deny`).optional().openapi({description:`Defines how to proceed during an authentication transaction with regards an organization. Can be deny (default), allow or require.`}),organization_require_behavior:f.z.enum([`no_prompt`,`pre_login_prompt`,`post_login_prompt`]).default(`no_prompt`).optional().openapi({description:`Defines how to proceed during an authentication transaction when client.organization_usage: 'require'. Can be no_prompt (default), pre_login_prompt or post_login_prompt. post_login_prompt requires oidc_conformant: true.`}),client_authentication_methods:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Defines client authentication methods.`}),require_pushed_authorization_requests:f.z.boolean().default(!1).openapi({description:`Makes the use of Pushed Authorization Requests mandatory for this client`}),require_proof_of_possession:f.z.boolean().default(!1).openapi({description:`Makes the use of Proof-of-Possession mandatory for this client`}),signed_request_object:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`JWT-secured Authorization Requests (JAR) settings.`}),compliance_level:f.z.enum([`none`,`fapi1_adv_pkj_par`,`fapi1_adv_mtls_par`,`fapi2_sp_pkj_mtls`,`fapi2_sp_mtls_mtls`]).optional().openapi({description:`Defines the compliance level for this client, which may restrict it's capabilities`}),par_request_expiry:f.z.number().optional().openapi({description:`Specifies how long, in seconds, a Pushed Authorization Request URI remains valid`}),token_quota:f.z.record(f.z.string(),f.z.any()).default({}).optional(),owner_user_id:f.z.string().optional().openapi({description:`User ID of the consenting user when this client was created via IAT-gated Dynamic Client Registration. NULL for clients created via the Management API or open DCR.`}),registration_type:f.z.enum([`manual`,`open_dcr`,`iat_dcr`]).optional().openapi({description:"Provenance of this client. `manual` = Management API; `open_dcr` = RFC 7591 without IAT; `iat_dcr` = RFC 7591 with an Initial Access Token."}),registration_metadata:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:"Arbitrary metadata captured at Dynamic Client Registration time that isn't a first-class client field (e.g. integration_type, domain). Also stores `iat_constraints` for clients created via IAT so RFC 7592 PUT can enforce field immutability."}),token_exchange:f.z.object({allow_any_profile_of_type:f.z.array(f.z.literal(`custom_authentication`)).optional()}).optional().openapi({description:'Custom Token Exchange settings. Set `allow_any_profile_of_type` to `["custom_authentication"]` to let this client exchange subject tokens through the tenant\'s token exchange profiles.'}),user_linking_mode:f.z.enum([`builtin`,`off`]).optional().openapi({description:"Per-client override for the built-in email-based user-linking path. `builtin` runs the legacy in-process linking at user creation/email update. `off` disables the legacy path; linking only happens if the tenant has enabled the `account-linking` template hook. When unset, the service-level `userLinkingMode` default applies."})});f.z.object({created_at:f.z.string(),updated_at:f.z.string()}).extend(tN.shape).extend({client_id:f.z.string()});var nN=f.z.object({client_id:f.z.string().min(1).openapi({description:`ID of the client.`}),audience:f.z.string().min(1).openapi({description:`The audience (API identifier) of this client grant.`}),scope:f.z.array(f.z.string()).optional().openapi({description:`Scopes allowed for this client grant.`}),organization_usage:f.z.enum([`deny`,`allow`,`require`]).optional().openapi({description:`Defines whether organizations can be used with client credentials exchanges for this grant.`}),allow_any_organization:f.z.boolean().optional().openapi({description:`If enabled, any organization can be used with this grant. If disabled (default), the grant must be explicitly assigned to the desired organizations.`}),is_system:f.z.boolean().optional().openapi({description:`If enabled, this grant is a special grant created by Auth0. It cannot be modified or deleted directly.`}),subject_type:f.z.enum([`client`,`user`]).optional().openapi({description:`The type of application access the client grant allows. Use of this field is subject to the applicable Free Trial terms in Okta's Master Subscription Agreement.`}),authorization_details_types:f.z.array(f.z.string()).optional().openapi({description:`Types of authorization_details allowed for this client grant. Use of this field is subject to the applicable Free Trial terms in Okta's Master Subscription Agreement.`})}),rN=f.z.object({id:f.z.string().openapi({description:`ID of the client grant.`})}).extend(nN.shape).extend({created_at:f.z.string().optional(),updated_at:f.z.string().optional()});f.z.array(rN);var iN=f.z.enum([`iat`,`rat`]),aN=f.z.enum([`invite`,`edit_link`,`registration`,`connect`]),oN=f.z.object({id:f.z.string(),token_hash:f.z.string(),type:iN,client_id:f.z.string().optional(),sub:f.z.string().optional(),constraints:f.z.record(f.z.string(),f.z.unknown()).optional(),single_use:f.z.boolean().default(!1),expires_at:f.z.string().optional(),name:f.z.string().optional(),created_by:f.z.string().optional(),source:aN.optional()});f.z.object({created_at:f.z.string(),used_at:f.z.string().optional(),revoked_at:f.z.string().optional()}).extend(oN.shape);var sN=f.z.object({x:f.z.number(),y:f.z.number()}),cN=function(e){return e.RICH_TEXT=`RICH_TEXT`,e.NEXT_BUTTON=`NEXT_BUTTON`,e.BACK_BUTTON=`BACK_BUTTON`,e.SUBMIT_BUTTON=`SUBMIT_BUTTON`,e.DIVIDER=`DIVIDER`,e.TEXT=`TEXT`,e.EMAIL=`EMAIL`,e.PASSWORD=`PASSWORD`,e.NUMBER=`NUMBER`,e.PHONE=`PHONE`,e.DATE=`DATE`,e.CHECKBOX=`CHECKBOX`,e.RADIO=`RADIO`,e.SELECT=`SELECT`,e.HIDDEN=`HIDDEN`,e.LEGAL=`LEGAL`,e}({}),lN=function(e){return e.BLOCK=`BLOCK`,e.FIELD=`FIELD`,e}({}),uN=f.z.object({id:f.z.string(),category:f.z.nativeEnum(lN),type:f.z.nativeEnum(cN)}),dN=uN.extend({category:f.z.literal(`BLOCK`),type:f.z.literal(`RICH_TEXT`),config:f.z.object({content:f.z.string()}).passthrough()}),fN=uN.extend({category:f.z.literal(`BLOCK`),type:f.z.union([f.z.literal(`NEXT_BUTTON`),f.z.literal(`BACK_BUTTON`),f.z.literal(`SUBMIT_BUTTON`)]),config:f.z.object({text:f.z.string()}).passthrough()}),pN=uN.extend({category:f.z.literal(`FIELD`),type:f.z.literal(`LEGAL`),required:f.z.boolean().optional(),sensitive:f.z.boolean().optional(),config:f.z.object({text:f.z.string()}).passthrough()}),mN=uN.extend({category:f.z.literal(`FIELD`),type:f.z.union([f.z.literal(`TEXT`),f.z.literal(`EMAIL`),f.z.literal(`PASSWORD`),f.z.literal(`NUMBER`),f.z.literal(`PHONE`),f.z.literal(`DATE`),f.z.literal(`CHECKBOX`),f.z.literal(`RADIO`),f.z.literal(`SELECT`),f.z.literal(`HIDDEN`)]),required:f.z.boolean().optional(),sensitive:f.z.boolean().optional(),config:f.z.object({label:f.z.string().optional(),placeholder:f.z.string().optional()}).passthrough()}),hN=f.z.object({id:f.z.string(),category:f.z.string(),type:f.z.string()}).passthrough(),gN=f.z.union([dN,fN,pN,mN,hN]),_N=f.z.object({id:f.z.string(),type:f.z.literal(`STEP`),coordinates:sN,alias:f.z.string().optional(),config:f.z.object({components:f.z.array(gN),next_node:f.z.string()}).passthrough()}),vN=f.z.object({id:f.z.string(),type:f.z.literal(`FLOW`),coordinates:sN,alias:f.z.string().optional(),config:f.z.object({flow_id:f.z.string(),next_node:f.z.string()})}),yN=f.z.object({id:f.z.string(),type:f.z.literal(`ACTION`),coordinates:sN,alias:f.z.string().optional(),config:f.z.object({action_type:f.z.enum([`REDIRECT`]).openapi({description:`The type of action to perform`}),target:f.z.enum([`change-email`,`account`,`custom`]).openapi({description:`The predefined target to redirect to`}),custom_url:f.z.string().optional().openapi({description:`Custom URL when target is 'custom'`}),next_node:f.z.string().openapi({description:`The next node to navigate to after action (for non-redirect actions)`})}).passthrough()}),bN=f.z.object({id:f.z.string(),type:f.z.string(),coordinates:sN}).passthrough(),xN=f.z.union([_N,vN,yN,bN]),SN=f.z.object({next_node:f.z.string(),coordinates:sN}).passthrough(),CN=f.z.object({resume_flow:f.z.boolean().optional(),coordinates:sN}).passthrough();f.z.object({id:f.z.string(),name:f.z.string(),languages:f.z.object({primary:f.z.string()}).passthrough(),nodes:f.z.array(xN),start:SN,ending:CN,created_at:f.z.string(),updated_at:f.z.string(),links:f.z.object({sdkSrc:f.z.string().optional(),sdk_src:f.z.string().optional()}).passthrough()}).passthrough().omit({id:!0,created_at:!0,updated_at:!0});var wN=function(e){return e.TOKEN=`token`,e.ID_TOKEN=`id_token`,e.TOKEN_ID_TOKEN=`id_token token`,e.CODE=`code`,e.CODE_ID_TOKEN=`code id_token`,e.CODE_TOKEN=`code token`,e.CODE_ID_TOKEN_TOKEN=`code id_token token`,e}({}),TN=function(e){return e.QUERY=`query`,e.FRAGMENT=`fragment`,e.FORM_POST=`form_post`,e.WEB_MESSAGE=`web_message`,e.SAML_POST=`saml_post`,e}({}),EN=function(e){return e.S256=`S256`,e.Plain=`plain`,e}({}),DN=f.z.union([f.z.null(),f.z.object({essential:f.z.boolean().optional(),value:f.z.unknown().optional(),values:f.z.array(f.z.unknown()).optional()})]).nullable(),ON=f.z.object({userinfo:f.z.record(f.z.string(),DN).optional(),id_token:f.z.record(f.z.string(),DN).optional()}),kN=f.z.object({client_id:f.z.string(),act_as:f.z.string().optional(),response_type:f.z.nativeEnum(wN).optional(),response_mode:f.z.nativeEnum(TN).optional(),redirect_uri:f.z.string().optional(),audience:f.z.string().optional(),organization:f.z.string().optional(),state:f.z.string().optional(),nonce:f.z.string().optional(),scope:f.z.string().optional(),prompt:f.z.string().optional(),code_challenge_method:f.z.nativeEnum(EN).optional(),code_challenge:f.z.string().optional(),username:f.z.string().optional(),ui_locales:f.z.string().optional(),max_age:f.z.number().optional(),acr_values:f.z.string().optional(),claims:ON.optional(),connection:f.z.string().optional(),vendor_id:f.z.string().optional()});f.z.object({..._M,colors:f.z.object({primary:f.z.string(),page_background:f.z.union([f.z.string(),f.z.object({type:f.z.string().optional(),start:f.z.string().optional(),end:f.z.string().optional(),angle_deg:f.z.number().optional()})]).optional()}).optional(),logo_url:f.z.string().optional(),favicon_url:f.z.string().optional(),favicon_url_dark:f.z.string().optional(),powered_by_logo_url:f.z.string().optional(),font:f.z.object({url:f.z.string()}).optional(),dark_mode:f.z.enum([`dark`,`light`,`auto`]).optional(),dark_mode_toggle:f.z.boolean().optional(),terms_url:f.z.string().optional(),privacy_url:f.z.string().optional()});var AN=f.z.enum([`password_reset`,`email_verification`,`otp`,`mfa_otp`,`authorization_code`,`oauth2_state`,`ticket`,`client_assertion_jti`,`subject_token_jti`,`session_transfer_token`,`mfa_remember_browser`]);f.z.object({code_id:f.z.string().openapi({description:`The code that will be used in for instance an email verification flow`}),login_id:f.z.string().optional().openapi({description:`The id of the login session that the code is connected to`}),connection_id:f.z.string().optional().openapi({description:`The connection that the code is connected to`}),code_type:AN,code_verifier:f.z.string().optional().openapi({description:`The code verifier used in PKCE in outbound flows`}),code_challenge:f.z.string().optional().openapi({description:`The code challenge used in PKCE in outbound flows`}),code_challenge_method:f.z.enum([`plain`,`S256`]).optional().openapi({description:`The code challenge method used in PKCE in outbound flows`}),redirect_uri:f.z.string().optional().openapi({description:`The redirect URI associated with the code`}),otp:f.z.string().optional().openapi({description:`The one-time password value for OTP-based flows`}),nonce:f.z.string().optional().openapi({description:`The nonce value used for security in OIDC flows`}),state:f.z.string().optional().openapi({description:`The state parameter used for CSRF protection in OAuth flows`}),expires_at:f.z.string(),used_at:f.z.string().optional(),user_id:f.z.string().optional()}).extend({created_at:f.z.string()}),f.z.object({device_code_hash:f.z.string(),user_code_hash:f.z.string(),client_id:f.z.string(),scope:f.z.string().optional(),audience:f.z.string().optional(),status:f.z.enum([`pending`,`approved`,`denied`,`consumed`]),login_id:f.z.string().optional(),expires_at:f.z.string(),created_at:f.z.string(),last_polled_at:f.z.string().optional(),interval:f.z.number().int().positive(),version:f.z.number().int().nonnegative()});var jN=f.z.object({kid:f.z.string().optional(),team_id:f.z.string().optional(),realms:f.z.string().optional(),authentication_method:f.z.string().optional(),client_id:f.z.string().optional(),client_secret:JM().optional(),app_secret:JM().optional(),scope:f.z.string().optional(),client_secret_hint:f.z.string().optional(),app_secret_hint:f.z.string().optional(),twilio_token_hint:f.z.string().optional(),authorization_endpoint:f.z.string().optional(),token_endpoint:f.z.string().optional(),userinfo_endpoint:f.z.string().optional(),jwks_uri:f.z.string().optional(),discovery_url:f.z.string().optional(),issuer:f.z.string().optional(),token_endpoint_auth_method:f.z.enum([`client_secret_basic`,`client_secret_post`]).optional(),provider:f.z.string().optional(),from:f.z.string().optional(),twilio_sid:JM().optional(),twilio_token:JM().optional(),icon_url:f.z.string().optional(),domain_aliases:f.z.array(f.z.string()).optional(),callback_url:f.z.string().url().optional(),passwordPolicy:f.z.enum([`none`,`low`,`fair`,`good`,`excellent`]).optional(),password_complexity_options:f.z.object({min_length:f.z.number().optional()}).optional(),password_history:f.z.object({enable:f.z.boolean().optional(),size:f.z.number().optional()}).optional(),password_no_personal_info:f.z.object({enable:f.z.boolean().optional()}).optional(),password_dictionary:f.z.object({enable:f.z.boolean().optional(),dictionary:f.z.array(f.z.string()).optional()}).optional(),disable_signup:f.z.boolean().optional(),brute_force_protection:f.z.boolean().optional(),import_mode:f.z.boolean().optional(),configuration:f.z.object({token_endpoint:f.z.string().optional(),userinfo_endpoint:f.z.string().optional(),client_id:f.z.string().optional(),client_secret:JM().optional(),client_secret_hint:f.z.string().optional(),realm:f.z.string().optional()}).optional(),attributes:f.z.object({email:f.z.object({identifier:f.z.object({active:f.z.boolean().optional()}).optional(),signup:f.z.object({status:f.z.enum([`required`,`optional`,`disabled`]).optional(),verification:f.z.object({active:f.z.boolean().optional()}).optional()}).optional(),validation:f.z.object({allowed:f.z.boolean().optional()}).optional(),unique:f.z.boolean().optional(),profile_required:f.z.boolean().optional(),verification_method:f.z.enum([`link`,`code`]).optional()}).optional(),username:f.z.object({identifier:f.z.object({active:f.z.boolean().optional()}).optional(),signup:f.z.object({status:f.z.enum([`required`,`optional`,`disabled`]).optional()}).optional(),validation:f.z.object({max_length:f.z.number().optional(),min_length:f.z.number().optional(),allowed_types:f.z.object({email:f.z.boolean().optional(),phone_number:f.z.boolean().optional()}).optional()}).optional(),profile_required:f.z.boolean().optional()}).optional(),phone_number:f.z.object({identifier:f.z.object({active:f.z.boolean().optional()}).optional(),signup:f.z.object({status:f.z.enum([`required`,`optional`,`disabled`]).optional()}).optional()}).optional()}).optional(),authentication_methods:f.z.object({password:f.z.object({enabled:f.z.boolean().optional()}).optional(),passkey:f.z.object({enabled:f.z.boolean().optional()}).optional()}).optional(),passkey_options:f.z.object({challenge_ui:f.z.enum([`both`,`autofill`,`button`]).optional(),local_enrollment_enabled:f.z.boolean().optional(),progressive_enrollment_enabled:f.z.boolean().optional()}).optional(),requires_username:f.z.boolean().optional(),validation:f.z.object({username:f.z.object({min:f.z.number().optional(),max:f.z.number().optional()}).optional()}).optional(),allow_action_users:f.z.boolean().optional(),set_user_root_attributes:f.z.enum([`on_each_login`,`on_first_login`,`never_on_login`]).optional(),signInEndpoint:f.z.string().optional(),signOutEndpoint:f.z.string().optional(),signingCert:f.z.string().optional(),signingCerts:f.z.array(f.z.string()).optional(),metadataUrl:f.z.string().optional(),metadataXml:f.z.string().optional(),signSAMLRequest:f.z.boolean().optional(),signatureAlgorithm:f.z.enum([`rsa-sha256`,`rsa-sha1`]).optional(),digestAlgorithm:f.z.enum([`sha256`,`sha1`]).optional(),protocolBinding:f.z.enum([`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect`,`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`]).optional(),user_id_attribute:f.z.string().optional(),fieldsMap:f.z.record(f.z.string(),f.z.union([f.z.string(),f.z.array(f.z.string())])).optional(),entityId:f.z.string().optional()});function MN(e){if(e!==null){if(Array.isArray(e))return e.filter(e=>e!==null).map(MN);if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))r!==null&&(t[n]=MN(r));return t}return e}}var NN=f.z.object({id:f.z.string().optional(),name:f.z.string(),display_name:f.z.string().optional(),strategy:f.z.string(),options:f.z.preprocess(e=>e===null?{}:MN(e),jN).default({}),enabled_clients:f.z.array(f.z.string()).default([]).optional(),response_type:f.z.nativeEnum(wN).optional(),response_mode:f.z.nativeEnum(TN).optional(),is_domain_connection:f.z.boolean().optional(),show_as_button:f.z.boolean().optional(),metadata:f.z.record(f.z.string(),f.z.any()).optional(),is_system:f.z.boolean().optional(),..._M});f.z.object({id:f.z.string(),created_at:f.z.string().transform(e=>e===null?``:e),updated_at:f.z.string().transform(e=>e===null?``:e)}).extend(NN.shape);var PN=f.z.object({domain:f.z.string(),status:f.z.enum([`pending`,`verified`]),verified_at:f.z.string().optional()});f.z.object({profile_id:f.z.string().optional(),domains:f.z.array(PN).default([])});var FN=f.z.object({domain:f.z.string(),custom_domain_id:f.z.string().optional(),type:f.z.enum([`auth0_managed_certs`,`self_managed_certs`]),verification_method:f.z.enum([`txt`]).optional(),tls_policy:f.z.enum([`recommended`]).optional(),custom_client_ip_header:f.z.enum([`true-client-ip`,`cf-connecting-ip`,`x-forwarded-for`,`x-azure-clientip`,`null`]).optional(),domain_metadata:f.z.record(f.z.string(),f.z.string().max(255)).optional()}),IN=f.z.discriminatedUnion(`name`,[f.z.object({name:f.z.literal(`txt`),record:f.z.string(),domain:f.z.string()}),f.z.object({name:f.z.literal(`http`),http_body:f.z.string(),http_url:f.z.string()})]),LN=FN.extend({custom_domain_id:f.z.string(),primary:f.z.boolean(),status:f.z.enum([`disabled`,`pending`,`pending_verification`,`ready`]),origin_domain_name:f.z.string().optional(),verification:f.z.object({methods:f.z.array(IN)}).optional(),tls_policy:f.z.string().optional()});FN.pick({tls_policy:!0,custom_client_ip_header:!0,domain_metadata:!0}).strict(),LN.extend({tenant_id:f.z.string()}),f.z.object({certificate:f.z.string().regex(/^-----BEGIN CERTIFICATE-----[\s\S]+-----END CERTIFICATE-----\s*$/,`must be PEM-encoded; include the full certificate chain in leaf-first order`),private_key:f.z.string().regex(/-----BEGIN (RSA |EC |ENCRYPTED )?PRIVATE KEY-----[\s\S]+-----END \1PRIVATE KEY-----\s*$/,`must be a PEM-encoded private key`)});var RN=f.z.object({id:f.z.string(),order:f.z.number().optional(),visible:f.z.boolean().optional().default(!0)}),zN=RN.extend({category:f.z.literal(`BLOCK`).optional()}),BN=zN.extend({type:f.z.literal(`DIVIDER`),config:f.z.object({text:f.z.string().optional()}).optional()}),VN=zN.extend({type:f.z.literal(`HTML`),config:f.z.object({content:f.z.string().optional()}).optional()}),HN=zN.extend({type:f.z.literal(`IMAGE`),config:f.z.object({src:f.z.string().optional(),alt:f.z.string().optional(),width:f.z.number().optional(),height:f.z.number().optional()}).optional()}),UN=zN.extend({type:f.z.literal(`JUMP_BUTTON`),config:f.z.object({text:f.z.string().optional(),target_step:f.z.string().optional()})}),WN=zN.extend({type:f.z.literal(`RESEND_BUTTON`),config:f.z.object({text:f.z.string().optional(),resend_action:f.z.string().optional()})}),GN=zN.extend({type:f.z.literal(`NEXT_BUTTON`),config:f.z.object({text:f.z.string().optional(),variant:f.z.enum([`primary`,`secondary`]).optional(),skip_validation:f.z.boolean().optional()})}),KN=zN.extend({type:f.z.literal(`PREVIOUS_BUTTON`),config:f.z.object({text:f.z.string().optional()})}),qN=zN.extend({type:f.z.literal(`RICH_TEXT`),config:f.z.object({content:f.z.string().optional()}).optional()}),JN=RN.extend({category:f.z.literal(`WIDGET`).optional(),label:f.z.string().min(1).optional(),hint:f.z.string().min(1).max(500).optional(),required:f.z.boolean().optional(),sensitive:f.z.boolean().optional()}),YN=JN.extend({type:f.z.literal(`AUTH0_VERIFIABLE_CREDENTIALS`),config:f.z.object({credential_type:f.z.string().optional()})}),XN=JN.extend({type:f.z.literal(`GMAPS_ADDRESS`),config:f.z.object({api_key:f.z.string().optional()})}),ZN=JN.extend({type:f.z.literal(`RECAPTCHA`),config:f.z.object({site_key:f.z.string().optional()})}),QN=RN.extend({category:f.z.literal(`FIELD`).optional(),label:f.z.string().min(1).optional(),hint:f.z.string().min(1).max(500).optional(),messages:f.z.array(f.z.object({id:f.z.number().optional(),text:f.z.string(),type:f.z.enum([`info`,`error`,`success`,`warning`])})).optional(),required:f.z.boolean().optional(),sensitive:f.z.boolean().optional()}),$N=QN.extend({type:f.z.literal(`BOOLEAN`),config:f.z.object({default_value:f.z.boolean().optional()}).optional()}),eP=QN.extend({type:f.z.literal(`CARDS`),config:f.z.object({options:f.z.array(f.z.object({value:f.z.string(),label:f.z.string(),description:f.z.string().optional(),image:f.z.string().optional()})).optional(),multi_select:f.z.boolean().optional()}).optional()}),tP=QN.extend({type:f.z.literal(`CHOICE`),config:f.z.object({options:f.z.array(f.z.object({value:f.z.string(),label:f.z.string()})).optional(),display:f.z.enum([`radio`,`checkbox`]).optional(),multiple:f.z.boolean().optional(),default_value:f.z.union([f.z.string(),f.z.array(f.z.string())]).optional()}).optional()}),nP=QN.extend({type:f.z.literal(`CODE`),config:f.z.object({length:f.z.number().int().positive().max(100).optional(),mode:f.z.enum([`numeric`,`alphanumeric`]).optional(),auto_submit:f.z.boolean().optional(),group_size:f.z.number().int().min(0).max(100).optional(),separator:f.z.string().optional(),placeholder:f.z.string().optional(),default_value:f.z.string().optional()}).refine(e=>e.group_size===void 0||e.length===void 0||e.group_size<=e.length,{message:`group_size cannot exceed length`,path:[`group_size`]}).refine(e=>e.default_value===void 0||e.length===void 0||e.default_value.length<=e.length,{message:`default_value is longer than the configured length`,path:[`default_value`]}).optional()}),rP=QN.extend({type:f.z.literal(`CUSTOM`),config:f.z.object({component:f.z.string().optional(),props:f.z.record(f.z.string(),f.z.any()).optional(),schema:f.z.record(f.z.string(),f.z.any()).optional(),code:f.z.string().optional()})}),iP=QN.extend({type:f.z.literal(`DATE`),config:f.z.object({format:f.z.string().optional(),min:f.z.string().optional(),max:f.z.string().optional(),default_value:f.z.string().optional()}).optional()}),aP=QN.extend({type:f.z.literal(`DROPDOWN`),config:f.z.object({options:f.z.array(f.z.object({value:f.z.string(),label:f.z.string()})).optional(),placeholder:f.z.string().optional(),searchable:f.z.boolean().optional(),multiple:f.z.boolean().optional(),default_value:f.z.union([f.z.string(),f.z.array(f.z.string())]).optional()}).optional()}),oP=QN.extend({type:f.z.literal(`EMAIL`),config:f.z.object({placeholder:f.z.string().optional(),default_value:f.z.string().optional(),last_used:f.z.boolean().optional(),last_used_label:f.z.string().optional()}).optional()}),sP=QN.extend({type:f.z.literal(`FILE`),config:f.z.object({accept:f.z.string().optional(),max_size:f.z.number().optional(),multiple:f.z.boolean().optional()}).optional()}),cP=QN.extend({type:f.z.literal(`LEGAL`),config:f.z.object({text:f.z.string(),html:f.z.boolean().optional()}).optional()}),lP=QN.extend({type:f.z.literal(`NUMBER`),config:f.z.object({placeholder:f.z.string().optional(),min:f.z.number().optional(),max:f.z.number().optional(),step:f.z.number().optional(),default_value:f.z.string().optional()}).optional()}),uP=QN.extend({type:f.z.literal(`PASSWORD`),config:f.z.object({placeholder:f.z.string().optional(),min_length:f.z.number().optional(),show_toggle:f.z.boolean().optional(),forgot_password_link:f.z.string().optional(),default_value:f.z.string().optional(),autocomplete:f.z.enum([`current-password`,`new-password`]).optional()}).optional()}),dP=QN.extend({type:f.z.literal(`PAYMENT`),config:f.z.object({provider:f.z.string().optional(),currency:f.z.string().optional()}).optional()}),fP=QN.extend({type:f.z.literal(`SOCIAL`),config:f.z.object({providers:f.z.array(f.z.string()).optional(),provider_details:f.z.array(f.z.object({name:f.z.string(),strategy:f.z.string().optional(),display_name:f.z.string().optional(),short_name:f.z.string().optional(),icon_url:f.z.string().optional(),href:f.z.string().optional(),last_used:f.z.boolean().optional(),last_used_label:f.z.string().optional()})).optional()}).optional()}),pP=QN.extend({type:f.z.literal(`TEL`),config:f.z.object({placeholder:f.z.string().optional(),default_country:f.z.string().optional(),default_value:f.z.string().optional(),allow_email:f.z.boolean().optional()}).optional()}),mP=QN.extend({type:f.z.literal(`TEXT`),config:f.z.object({placeholder:f.z.string().optional(),multiline:f.z.boolean().optional(),max_length:f.z.number().optional(),default_value:f.z.string().optional(),autocomplete:f.z.string().optional(),input_mode:f.z.enum([`text`,`numeric`,`decimal`,`tel`,`email`,`url`,`search`]).optional(),last_used:f.z.boolean().optional(),last_used_label:f.z.string().optional()}).optional()}),hP=QN.extend({type:f.z.literal(`COUNTRY`),config:f.z.object({placeholder:f.z.string().optional(),default_value:f.z.string().optional()}).optional()}),gP=QN.extend({type:f.z.literal(`URL`),config:f.z.object({placeholder:f.z.string().optional(),default_value:f.z.string().optional()}).optional()}),_P=f.z.discriminatedUnion(`type`,[BN,VN,HN,UN,WN,GN,KN,qN]),vP=f.z.discriminatedUnion(`type`,[YN,XN,ZN]),yP=f.z.discriminatedUnion(`type`,[$N,eP,tP,nP,hP,rP,iP,aP,oP,sP,cP,lP,uP,dP,fP,pP,mP,gP]),bP=f.z.union([_P,vP,yP]);new Set([`BOOLEAN`,`CARDS`,`CHOICE`,`CODE`,`COUNTRY`,`DATE`,`DROPDOWN`,`EMAIL`,`LEGAL`,`NUMBER`,`PASSWORD`,`TEL`,`TEXT`,`URL`]),f.z.object({id:f.z.string(),type:f.z.literal(`submit`),label:f.z.string(),className:f.z.string().optional(),disabled:f.z.boolean().optional().default(!1),order:f.z.number().optional(),visible:f.z.boolean().optional().default(!0),customizations:f.z.record(f.z.string(),f.z.any()).optional()});var xP=f.z.object({x:f.z.number(),y:f.z.number()}),SP=f.z.object({id:f.z.string(),type:f.z.literal(`FLOW`),coordinates:xP,alias:f.z.string().min(1).max(150).optional(),config:f.z.object({flow_id:f.z.string().max(30),next_node:f.z.string().optional()})}),CP=f.z.object({id:f.z.string(),type:f.z.literal(`ROUTER`),coordinates:xP,alias:f.z.string().min(1).max(150),config:f.z.object({rules:f.z.array(f.z.object({id:f.z.string(),alias:f.z.string().min(1).max(150).optional(),condition:f.z.any(),next_node:f.z.string()})),fallback:f.z.string()})}),wP=f.z.object({id:f.z.string(),type:f.z.literal(`STEP`),coordinates:xP,alias:f.z.string().min(1).max(150).optional(),config:f.z.object({components:f.z.array(bP),next_node:f.z.string().optional()})}),TP=f.z.discriminatedUnion(`type`,[SP,CP,wP]),EP=f.z.object({name:f.z.string().openapi({description:`The name of the form`}),messages:f.z.object({errors:f.z.record(f.z.string(),f.z.any()).optional(),custom:f.z.record(f.z.string(),f.z.any()).optional()}).optional(),languages:f.z.object({primary:f.z.string().optional(),default:f.z.string().optional()}).optional(),translations:f.z.record(f.z.string(),f.z.any()).optional(),nodes:f.z.array(TP).optional(),start:f.z.object({hidden_fields:f.z.array(f.z.object({key:f.z.string(),value:f.z.string()})).optional(),next_node:f.z.string().optional(),coordinates:xP.optional()}).optional(),ending:f.z.object({redirection:f.z.object({delay:f.z.number().optional(),target:f.z.string().optional()}).optional(),after_submit:f.z.object({flow_id:f.z.string().optional()}).optional(),coordinates:xP.optional(),resume_flow:f.z.boolean().optional()}).optional(),style:f.z.object({css:f.z.string().optional()}).optional(),links:f.z.object({sdkSrc:f.z.string().optional(),sdk_src:f.z.string().optional()}).optional()}).openapi({description:`Schema for flow-based forms (matches Auth0 Forms structure)`});mM.extend(EP.shape).extend({id:f.z.string()});var DP=f.z.object({id:f.z.number().optional(),text:f.z.string(),type:f.z.enum([`info`,`error`,`success`,`warning`])}),OP=f.z.object({id:f.z.string().optional(),text:f.z.string(),href:f.z.string(),linkText:f.z.string().optional()}),kP=f.z.object({"form-content-start":f.z.string().optional(),"form-content-end":f.z.string().optional(),"form-footer-start":f.z.string().optional(),"form-footer-end":f.z.string().optional(),"secondary-actions-start":f.z.string().optional(),"secondary-actions-end":f.z.string().optional()}).strict();f.z.object({name:f.z.string().optional(),action:f.z.string(),method:f.z.enum([`POST`,`GET`]),title:f.z.string().optional(),description:f.z.string().optional(),components:f.z.array(bP),messages:f.z.array(DP).optional(),links:f.z.array(OP).optional(),partials:kP.optional(),footer:f.z.string().optional()});var AP=f.z.enum([`pre-user-registration`,`post-user-registration`,`post-user-login`,`post-user-update`,`validate-registration-username`,`pre-user-deletion`,`post-user-deletion`]),jP=f.z.enum([`post-user-login`]),MP=f.z.enum([`post-user-login`,`post-user-registration`,`post-user-update`,`credentials-exchange`]),NP=f.z.enum([`validate-registration-username`,`post-user-login`,`credentials-exchange`,`pre-user-registration`,`post-user-registration`,`pre-user-update`,`post-user-update`,`pre-user-deletion`,`post-user-deletion`,`pre-screen`,`custom-email-provider`,`custom-phone-provider`]),PP=f.z.enum([`post-user-login`]);AP.options,jP.options,MP.options,NP.options,PP.options;var FP=f.z.enum([`impersonate`]),IP=f.z.enum([`ensure-username`,`set-preferred-username`,`account-linking`]),LP={enabled:f.z.boolean().default(!1),synchronous:f.z.boolean().default(!1),priority:f.z.number().optional(),hook_id:f.z.string().optional(),metadata:f.z.record(f.z.string(),f.z.unknown()).optional(),..._M},RP=f.z.object({...LP,trigger_id:AP,url:f.z.string()}),zP=f.z.object({...LP,trigger_id:jP,form_id:f.z.string()}),BP=f.z.object({...LP,trigger_id:MP,template_id:IP}),VP=f.z.object({...LP,trigger_id:NP,code_id:f.z.string()}),HP=f.z.object({...LP,trigger_id:PP,page_id:FP,permission_required:f.z.string().optional()});f.z.union([RP,zP,BP,VP,HP]);var UP=f.z.object({...LP,trigger_id:AP}).extend(mM.shape).extend({hook_id:f.z.string(),url:f.z.string()}),WP=f.z.object({...LP,trigger_id:jP}).extend(mM.shape).extend({hook_id:f.z.string(),form_id:f.z.string()}),GP=f.z.object({...LP,trigger_id:MP}).extend(mM.shape).extend({hook_id:f.z.string(),template_id:IP}),KP=f.z.object({...LP,trigger_id:NP}).extend(mM.shape).extend({hook_id:f.z.string(),code_id:f.z.string()}),qP=f.z.object({...LP,trigger_id:PP}).extend(mM.shape).extend({hook_id:f.z.string(),page_id:FP,permission_required:f.z.string().optional()});f.z.union([UP,WP,GP,KP,qP]),f.z.object({code:f.z.string().max(1e5),secrets:f.z.record(f.z.string(),f.z.string()).optional()}).extend({id:f.z.string(),tenant_id:f.z.string()}).extend(mM.shape);var JP=f.z.object({name:f.z.string().optional()}),YP=f.z.object({email:f.z.string().optional()}),XP=f.z.object({id:f.z.string().optional(),organization_id:f.z.string().max(50),inviter:JP,invitee:YP,invitation_url:f.z.string().url(),client_id:f.z.string(),connection_id:f.z.string().optional(),app_metadata:f.z.record(f.z.string(),f.z.any()).default({}).optional(),user_metadata:f.z.record(f.z.string(),f.z.any()).default({}).optional(),ttl_sec:f.z.number().int().max(2592e3).default(604800).optional(),roles:f.z.array(f.z.string()).default([]).optional(),send_invitation_email:f.z.boolean().default(!0).optional()});f.z.object({id:f.z.string(),organization_id:f.z.string().max(50),created_at:f.z.string().datetime(),expires_at:f.z.string().datetime(),ticket_id:f.z.string().optional()}).extend(XP.omit({id:!0}).shape);var ZP=f.z.object({alg:f.z.enum([`RS256`,`RS384`,`RS512`,`ES256`,`ES384`,`ES512`,`HS256`,`HS384`,`HS512`]).optional(),kid:f.z.string().optional(),kty:f.z.enum([`RSA`,`EC`,`oct`]),use:f.z.enum([`sig`,`enc`]).optional(),n:f.z.string().optional(),e:f.z.string().optional(),crv:f.z.string().optional(),x:f.z.string().optional(),y:f.z.string().optional(),x5t:f.z.string().optional(),"x5t#S256":f.z.string().optional(),x5c:f.z.array(f.z.string()).optional()}).superRefine((e,t)=>{if(e.kty===`RSA`)for(let n of[`n`,`e`])e[n]||t.addIssue({code:f.z.ZodIssueCode.custom,path:[n],message:`RSA JWK is missing required member '${n}'`});else if(e.kty===`EC`)for(let n of[`crv`,`x`,`y`])e[n]||t.addIssue({code:f.z.ZodIssueCode.custom,path:[n],message:`EC JWK is missing required member '${n}'`})}),QP=f.z.object({keys:f.z.array(ZP)});f.z.object({issuer:f.z.string(),authorization_endpoint:f.z.string(),token_endpoint:f.z.string(),device_authorization_endpoint:f.z.string().optional(),userinfo_endpoint:f.z.string(),jwks_uri:f.z.string(),registration_endpoint:f.z.string().optional(),revocation_endpoint:f.z.string(),end_session_endpoint:f.z.string().optional(),scopes_supported:f.z.array(f.z.string()),response_types_supported:f.z.array(f.z.string()),grant_types_supported:f.z.array(f.z.string()).optional(),code_challenge_methods_supported:f.z.array(f.z.string()),response_modes_supported:f.z.array(f.z.string()),subject_types_supported:f.z.array(f.z.string()),id_token_signing_alg_values_supported:f.z.array(f.z.string()),token_endpoint_auth_methods_supported:f.z.array(f.z.string()),claims_supported:f.z.array(f.z.string()),request_uri_parameter_supported:f.z.boolean(),request_parameter_supported:f.z.boolean(),claims_parameter_supported:f.z.boolean().optional(),request_object_signing_alg_values_supported:f.z.array(f.z.string()).optional(),token_endpoint_auth_signing_alg_values_supported:f.z.array(f.z.string()),client_id_metadata_document_supported:f.z.boolean().optional(),backchannel_logout_supported:f.z.boolean().optional(),backchannel_logout_session_supported:f.z.boolean().optional()});var $P=function(e){return e.PENDING=`pending`,e.AUTHENTICATED=`authenticated`,e.AWAITING_EMAIL_VERIFICATION=`awaiting_email_verification`,e.AWAITING_MFA=`awaiting_mfa`,e.AWAITING_HOOK=`awaiting_hook`,e.AWAITING_CONTINUATION=`awaiting_continuation`,e.AWAITING_CONSENT=`awaiting_consent`,e.COMPLETED=`completed`,e.FAILED=`failed`,e.EXPIRED=`expired`,e}({}),eF=f.z.nativeEnum($P),tF=f.z.object({strategy:f.z.string(),strategy_type:f.z.string()});f.z.object({csrf_token:f.z.string(),auth0Client:f.z.string().optional(),authParams:kN,expires_at:f.z.string(),deleted_at:f.z.string().optional(),ip:f.z.string().optional(),useragent:f.z.string().optional(),session_id:f.z.string().optional(),authorization_url:f.z.string().optional(),state:eF.optional().default(`pending`),state_data:f.z.string().optional(),failure_reason:f.z.string().optional(),user_id:f.z.string().optional(),auth_connection:f.z.string().optional(),auth_strategy:tF.optional(),authenticated_at:f.z.string().optional()}).openapi({description:`This represents a login sesion`}).extend({id:f.z.string().openapi({description:`This is is used as the state in the universal login`}),created_at:f.z.string(),updated_at:f.z.string(),tenant_id:f.z.string().optional()});var Q={ACLS_SUMMARY:`acls_summary`,ACTIONS_EXECUTION_FAILED:`actions_execution_failed`,API_LIMIT:`api_limit`,API_LIMIT_WARNING:`api_limit_warning`,APPI:`appi`,CIBA_EXCHANGE_FAILED:`ciba_exchange_failed`,CIBA_EXCHANGE_SUCCEEDED:`ciba_exchange_succeeded`,CIBA_START_FAILED:`ciba_start_failed`,CIBA_START_SUCCEEDED:`ciba_start_succeeded`,CODE_LINK_SENT:`cls`,CODE_SENT:`cs`,DEPRECATION_NOTICE:`depnote`,CONFIG_INHERITANCE_DIFF:`cfgdiff`,CONFIG_DRIFT:`cfgdrift`,FAILED_LOGIN:`f`,FAILED_BY_CONNECTOR:`fc`,FAILED_CHANGE_EMAIL:`fce`,FAILED_BY_CORS:`fco`,FAILED_CROSS_ORIGIN_AUTHENTICATION:`fcoa`,FAILED_CHANGE_PASSWORD:`fcp`,FAILED_POST_CHANGE_PASSWORD_HOOK:`fcph`,FAILED_CHANGE_PHONE_NUMBER:`fcpn`,FAILED_CHANGE_PASSWORD_REQUEST:`fcpr`,FAILED_CONNECTOR_PROVISIONING:`fcpro`,FAILED_CHANGE_USERNAME:`fcu`,FAILED_DELEGATION:`fd`,FAILED_DEVICE_ACTIVATION:`fdeac`,FAILED_DEVICE_AUTHORIZATION_REQUEST:`fdeaz`,USER_CANCELED_DEVICE_CONFIRMATION:`fdecc`,FAILED_USER_DELETION:`fdu`,FAILED_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN:`feacft`,FAILED_EXCHANGE_ACCESS_TOKEN_FOR_CLIENT_CREDENTIALS:`feccft`,FAILED_EXCHANGE_CUSTOM_TOKEN:`fecte`,FAILED_EXCHANGE_DEVICE_CODE_FOR_ACCESS_TOKEN:`fede`,FAILED_FEDERATED_LOGOUT:`federated_logout_failed`,FAILED_EXCHANGE_NATIVE_SOCIAL_LOGIN:`fens`,FAILED_EXCHANGE_PASSWORD_OOB_FOR_ACCESS_TOKEN:`feoobft`,FAILED_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN:`feotpft`,FAILED_EXCHANGE_PASSWORD_FOR_ACCESS_TOKEN:`fepft`,FAILED_EXCHANGE_PASSWORDLESS_OTP_FOR_ACCESS_TOKEN:`fepotpft`,FAILED_EXCHANGE_PASSWORD_MFA_RECOVERY_FOR_ACCESS_TOKEN:`fercft`,FAILED_EXCHANGE_ROTATING_REFRESH_TOKEN:`ferrt`,FAILED_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN:`fertft`,FAILED_EXCHANGE_SUBJECT_TOKEN_FOR_ACCESS_TOKEN:`festft`,FAILED_HOOK:`fh`,FAILED_IMPERSONATION:`fimp`,FAILED_INVITE_ACCEPT:`fi`,FAILED_LOGOUT:`flo`,FLOWS_EXECUTION_COMPLETED:`flows_execution_completed`,FLOWS_EXECUTION_FAILED:`flows_execution_failed`,FAILED_SENDING_NOTIFICATION:`fn`,FORMS_SUBMISSION_FAILED:`forms_submission_failed`,FORMS_SUBMISSION_SUCCEEDED:`forms_submission_succeeded`,FAILED_LOGIN_INCORRECT_PASSWORD:`fp`,FAILED_PUSHED_AUTHORIZATION_REQUEST:`fpar`,FAILED_POST_USER_REGISTRATION_HOOK:`fpurh`,FAILED_SIGNUP:`fs`,FAILED_SILENT_AUTH:`fsa`,FAILED_LOGIN_INVALID_EMAIL_USERNAME:`fu`,FAILED_USERS_IMPORT:`fui`,FAILED_VERIFICATION_EMAIL:`fv`,FAILED_VERIFICATION_EMAIL_REQUEST:`fvr`,EMAIL_VERIFICATION_CONFIRMED:`gd_auth_email_verification`,EMAIL_VERIFICATION_FAILED:`gd_auth_fail_email_verification`,MFA_AUTH_FAILED:`gd_auth_failed`,MFA_AUTH_REJECTED:`gd_auth_rejected`,MFA_AUTH_SUCCESS:`gd_auth_succeed`,MFA_ENROLLMENT_COMPLETE:`gd_enrollment_complete`,TOO_MANY_MFA_FAILURES:`gd_otp_rate_limit_exceed`,MFA_RECOVERY_FAILED:`gd_recovery_failed`,MFA_RECOVERY_RATE_LIMIT_EXCEED:`gd_recovery_rate_limit_exceed`,MFA_RECOVERY_SUCCESS:`gd_recovery_succeed`,MFA_EMAIL_SENT:`gd_send_email`,EMAIL_VERIFICATION_SENT:`gd_send_email_verification`,EMAIL_VERIFICATION_SEND_FAILURE:`gd_send_email_verification_failure`,PUSH_NOTIFICATION_SENT:`gd_send_pn`,ERROR_SENDING_MFA_PUSH_NOTIFICATION:`gd_send_pn_failure`,MFA_SMS_SENT:`gd_send_sms`,ERROR_SENDING_MFA_SMS:`gd_send_sms_failure`,MFA_VOICE_CALL_SUCCESS:`gd_send_voice`,MFA_VOICE_CALL_FAILED:`gd_send_voice_failure`,SECOND_FACTOR_STARTED:`gd_start_auth`,MFA_ENROLL_STARTED:`gd_start_enroll`,MFA_ENROLLMENT_FAILED:`gd_start_enroll_failed`,GUARDIAN_TENANT_UPDATE:`gd_tenant_update`,UNENROLL_DEVICE_ACCOUNT:`gd_unenroll`,UPDATE_DEVICE_ACCOUNT:`gd_update_device_account`,WEBAUTHN_CHALLENGE_FAILED:`gd_webauthn_challenge_failed`,WEBAUTHN_ENROLLMENT_FAILED:`gd_webauthn_enrollment_failed`,FAILED_KMS_API_OPERATION:`kms_key_management_failure`,SUCCESS_KMS_API_OPERATION:`kms_key_management_success`,KMS_KEY_STATE_CHANGED:`kms_key_state_changed`,TOO_MANY_CALLS_TO_DELEGATION:`limit_delegation`,BLOCKED_IP_ADDRESS:`limit_mu`,BLOCKED_ACCOUNT_IP:`limit_sul`,BLOCKED_ACCOUNT_EMAIL:`limit_wc`,INFORMATION:`i`,MFA_REQUIRED:`mfar`,MANAGEMENT_API_READ_OPERATION:`mgmt_api_read`,FAILED_AUTHENTICATION_METHOD_OPERATION_MY_ACCOUNT:`my_account_authentication_method_failed`,SUCCESSFUL_AUTHENTICATION_METHOD_OPERATION_MY_ACCOUNT:`my_account_authentication_method_succeeded`,FAILED_OIDC_BACKCHANNEL_LOGOUT:`oidc_backchannel_logout_failed`,SUCCESSFUL_OIDC_BACKCHANNEL_LOGOUT:`oidc_backchannel_logout_succeeded`,ORGANIZATION_MEMBER_ADDED:`organization_member_added`,PASSKEY_CHALLENGE_FAILED:`passkey_challenge_failed`,PASSKEY_CHALLENGE_STARTED:`passkey_challenge_started`,PRE_LOGIN_ASSESSMENT:`pla`,BREACHED_PASSWORD:`pwd_leak`,BREACHED_PASSWORD_ON_RESET:`reset_pwd_leak`,SUCCESS_RESOURCE_CLEANUP:`resource_cleanup`,RICH_CONSENTS_ACCESS_ERROR:`rich_consents_access_error`,SUCCESS_LOGIN:`s`,SUCCESS_API_OPERATION:`sapi`,FAILED_API_OPERATION:`fapi`,SUCCESS_CHANGE_EMAIL:`sce`,SUCCESS_CROSS_ORIGIN_AUTHENTICATION:`scoa`,SUCCESS_CHANGE_PASSWORD:`scp`,SUCCESS_CHANGE_PHONE_NUMBER:`scpn`,SUCCESS_CHANGE_PASSWORD_REQUEST:`scpr`,SUCCESS_CHANGE_USERNAME:`scu`,SUCCESS_CREDENTIAL_VALIDATION:`scv`,SUCCESS_DELEGATION:`sd`,SUCCESS_USER_DELETION:`sdu`,SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN:`seacft`,SUCCESS_EXCHANGE_ACCESS_TOKEN_FOR_CLIENT_CREDENTIALS:`seccft`,SUCCESS_EXCHANGE_CUSTOM_TOKEN:`secte`,SUCCESS_EXCHANGE_DEVICE_CODE_FOR_ACCESS_TOKEN:`sede`,SUCCESS_EXCHANGE_NATIVE_SOCIAL_LOGIN:`sens`,SUCCESS_EXCHANGE_PASSWORD_OOB_FOR_ACCESS_TOKEN:`seoobft`,SUCCESS_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN:`seotpft`,SUCCESS_EXCHANGE_PASSWORDLESS_OTP_FOR_ACCESS_TOKEN:`sepotpft`,SUCCESS_EXCHANGE_PASSWORD_FOR_ACCESS_TOKEN:`sepft`,SUCCESS_EXCHANGE_PASSKEY_OOB_FOR_ACCESS_TOKEN:`sepkoobft`,SUCCESS_EXCHANGE_PASSKEY_OTP_FOR_ACCESS_TOKEN:`sepkotpft`,SUCCESS_EXCHANGE_PASSKEY_MFA_RECOVERY_FOR_ACCESS_TOKEN:`sepkrcft`,SUCCESS_EXCHANGE_PASSWORD_MFA_RECOVERY_FOR_ACCESS_TOKEN:`sercft`,SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN:`sertft`,SUCCESS_EXCHANGE_SUBJECT_TOKEN_FOR_ACCESS_TOKEN:`sestft`,SUCCESS_IMPERSONATION:`simp`,SUCCESSFULLY_ACCEPTED_USER_INVITE:`si`,BREACHED_PASSWORD_ON_SIGNUP:`signup_pwd_leak`,SUCCESS_LOGOUT:`slo`,SUCCESS_HOOK:`sh`,SUCCESS_PASSWORD_MIGRATION:`spm`,SUCCESS_REVOCATION:`srrt`,SUCCESS_SIGNUP:`ss`,FAILED_SS_SSO_OPERATION:`ss_sso_failure`,INFORMATION_FROM_SS_SSO_OPERATION:`ss_sso_info`,SUCCESS_SS_SSO_OPERATION:`ss_sso_success`,SUCCESS_SILENT_AUTH:`ssa`,SUCCESSFUL_SCIM_OPERATION:`sscim`,SUCCESSFULLY_IMPORTED_USERS:`sui`,SUCCESS_VERIFICATION_EMAIL:`sv`,SUCCESS_VERIFICATION_EMAIL_REQUEST:`svr`,MAX_AMOUNT_OF_AUTHENTICATORS:`too_many_records`,USER_LOGIN_BLOCK_RELEASED:`ublkdu`,FAILED_UNIVERSAL_LOGOUT:`universal_logout_failed`,SUCCESSFUL_UNIVERSAL_LOGOUT:`universal_logout_succeeded`,WARNING_DURING_LOGIN:`w`,WARNING_SENDING_NOTIFICATION:`wn`,WARNING_USER_MANAGEMENT:`wum`},nF=f.z.string().refine(e=>Object.values(Q).includes(e),{message:`Invalid log type`});Q.ACLS_SUMMARY,Q.ACTIONS_EXECUTION_FAILED,Q.API_LIMIT,Q.API_LIMIT_WARNING,Q.APPI,Q.CIBA_EXCHANGE_FAILED,Q.CIBA_EXCHANGE_SUCCEEDED,Q.CIBA_START_FAILED,Q.CIBA_START_SUCCEEDED,Q.CODE_LINK_SENT,Q.CODE_SENT,Q.DEPRECATION_NOTICE,Q.CONFIG_INHERITANCE_DIFF,Q.CONFIG_DRIFT,Q.FAILED_LOGIN,Q.FAILED_BY_CONNECTOR,Q.FAILED_CHANGE_EMAIL,Q.FAILED_BY_CORS,Q.FAILED_CROSS_ORIGIN_AUTHENTICATION,Q.FAILED_CHANGE_PASSWORD,Q.FAILED_POST_CHANGE_PASSWORD_HOOK,Q.FAILED_CHANGE_PHONE_NUMBER,Q.FAILED_CHANGE_PASSWORD_REQUEST,Q.FAILED_CONNECTOR_PROVISIONING,Q.FAILED_CHANGE_USERNAME,Q.FAILED_DELEGATION,Q.FAILED_DEVICE_ACTIVATION,Q.FAILED_DEVICE_AUTHORIZATION_REQUEST,Q.USER_CANCELED_DEVICE_CONFIRMATION,Q.FAILED_USER_DELETION,Q.FAILED_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_ACCESS_TOKEN_FOR_CLIENT_CREDENTIALS,Q.FAILED_EXCHANGE_CUSTOM_TOKEN,Q.FAILED_EXCHANGE_DEVICE_CODE_FOR_ACCESS_TOKEN,Q.FAILED_FEDERATED_LOGOUT,Q.FAILED_EXCHANGE_NATIVE_SOCIAL_LOGIN,Q.FAILED_EXCHANGE_PASSWORD_OOB_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_PASSWORD_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_PASSWORDLESS_OTP_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_PASSWORD_MFA_RECOVERY_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_ROTATING_REFRESH_TOKEN,Q.FAILED_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_SUBJECT_TOKEN_FOR_ACCESS_TOKEN,Q.FAILED_HOOK,Q.FAILED_IMPERSONATION,Q.FAILED_INVITE_ACCEPT,Q.FAILED_LOGOUT,Q.FLOWS_EXECUTION_COMPLETED,Q.FLOWS_EXECUTION_FAILED,Q.FAILED_SENDING_NOTIFICATION,Q.FORMS_SUBMISSION_FAILED,Q.FORMS_SUBMISSION_SUCCEEDED,Q.FAILED_LOGIN_INCORRECT_PASSWORD,Q.FAILED_PUSHED_AUTHORIZATION_REQUEST,Q.FAILED_POST_USER_REGISTRATION_HOOK,Q.FAILED_SIGNUP,Q.FAILED_SILENT_AUTH,Q.FAILED_LOGIN_INVALID_EMAIL_USERNAME,Q.FAILED_USERS_IMPORT,Q.FAILED_VERIFICATION_EMAIL,Q.FAILED_VERIFICATION_EMAIL_REQUEST,Q.EMAIL_VERIFICATION_CONFIRMED,Q.EMAIL_VERIFICATION_FAILED,Q.MFA_AUTH_FAILED,Q.MFA_AUTH_REJECTED,Q.MFA_AUTH_SUCCESS,Q.MFA_ENROLLMENT_COMPLETE,Q.TOO_MANY_MFA_FAILURES,Q.MFA_RECOVERY_FAILED,Q.MFA_RECOVERY_RATE_LIMIT_EXCEED,Q.MFA_RECOVERY_SUCCESS,Q.MFA_EMAIL_SENT,Q.EMAIL_VERIFICATION_SENT,Q.EMAIL_VERIFICATION_SEND_FAILURE,Q.PUSH_NOTIFICATION_SENT,Q.ERROR_SENDING_MFA_PUSH_NOTIFICATION,Q.MFA_SMS_SENT,Q.ERROR_SENDING_MFA_SMS,Q.MFA_VOICE_CALL_SUCCESS,Q.MFA_VOICE_CALL_FAILED,Q.SECOND_FACTOR_STARTED,Q.MFA_ENROLL_STARTED,Q.MFA_ENROLLMENT_FAILED,Q.GUARDIAN_TENANT_UPDATE,Q.UNENROLL_DEVICE_ACCOUNT,Q.UPDATE_DEVICE_ACCOUNT,Q.WEBAUTHN_CHALLENGE_FAILED,Q.WEBAUTHN_ENROLLMENT_FAILED,Q.FAILED_KMS_API_OPERATION,Q.SUCCESS_KMS_API_OPERATION,Q.KMS_KEY_STATE_CHANGED,Q.TOO_MANY_CALLS_TO_DELEGATION,Q.BLOCKED_IP_ADDRESS,Q.BLOCKED_ACCOUNT_IP,Q.BLOCKED_ACCOUNT_EMAIL,Q.INFORMATION,Q.MFA_REQUIRED,Q.MANAGEMENT_API_READ_OPERATION,Q.FAILED_AUTHENTICATION_METHOD_OPERATION_MY_ACCOUNT,Q.SUCCESSFUL_AUTHENTICATION_METHOD_OPERATION_MY_ACCOUNT,Q.FAILED_OIDC_BACKCHANNEL_LOGOUT,Q.SUCCESSFUL_OIDC_BACKCHANNEL_LOGOUT,Q.ORGANIZATION_MEMBER_ADDED,Q.PASSKEY_CHALLENGE_FAILED,Q.PASSKEY_CHALLENGE_STARTED,Q.PRE_LOGIN_ASSESSMENT,Q.BREACHED_PASSWORD,Q.BREACHED_PASSWORD_ON_RESET,Q.SUCCESS_RESOURCE_CLEANUP,Q.RICH_CONSENTS_ACCESS_ERROR,Q.SUCCESS_LOGIN,Q.SUCCESS_API_OPERATION,Q.FAILED_API_OPERATION,Q.SUCCESS_CHANGE_EMAIL,Q.SUCCESS_CROSS_ORIGIN_AUTHENTICATION,Q.SUCCESS_CHANGE_PASSWORD,Q.SUCCESS_CHANGE_PHONE_NUMBER,Q.SUCCESS_CHANGE_PASSWORD_REQUEST,Q.SUCCESS_CHANGE_USERNAME,Q.SUCCESS_CREDENTIAL_VALIDATION,Q.SUCCESS_DELEGATION,Q.SUCCESS_USER_DELETION,Q.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_ACCESS_TOKEN_FOR_CLIENT_CREDENTIALS,Q.SUCCESS_EXCHANGE_CUSTOM_TOKEN,Q.SUCCESS_EXCHANGE_DEVICE_CODE_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_NATIVE_SOCIAL_LOGIN,Q.SUCCESS_EXCHANGE_PASSWORD_OOB_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSWORDLESS_OTP_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSWORD_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSKEY_OOB_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSKEY_OTP_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSKEY_MFA_RECOVERY_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSWORD_MFA_RECOVERY_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_SUBJECT_TOKEN_FOR_ACCESS_TOKEN,Q.SUCCESS_IMPERSONATION,Q.SUCCESSFULLY_ACCEPTED_USER_INVITE,Q.BREACHED_PASSWORD_ON_SIGNUP,Q.SUCCESS_LOGOUT,Q.SUCCESS_HOOK,Q.SUCCESS_PASSWORD_MIGRATION,Q.SUCCESS_REVOCATION,Q.SUCCESS_SIGNUP,Q.FAILED_SS_SSO_OPERATION,Q.INFORMATION_FROM_SS_SSO_OPERATION,Q.SUCCESS_SS_SSO_OPERATION,Q.SUCCESS_SILENT_AUTH,Q.SUCCESSFUL_SCIM_OPERATION,Q.SUCCESSFULLY_IMPORTED_USERS,Q.SUCCESS_VERIFICATION_EMAIL,Q.SUCCESS_VERIFICATION_EMAIL_REQUEST,Q.MAX_AMOUNT_OF_AUTHENTICATORS,Q.USER_LOGIN_BLOCK_RELEASED,Q.FAILED_UNIVERSAL_LOGOUT,Q.SUCCESSFUL_UNIVERSAL_LOGOUT,Q.WARNING_DURING_LOGIN,Q.WARNING_SENDING_NOTIFICATION,Q.WARNING_USER_MANAGEMENT,(()=>{let e={};for(let[t,n]of Object.entries(Q))t.startsWith(`SUCCESS_`)||t.startsWith(`SUCCESSFUL_`)||t.startsWith(`SUCCESSFULLY_`)||t.endsWith(`_SUCCEEDED`)||t.endsWith(`_COMPLETED`)?e[n]=`success`:t.startsWith(`FAILED_`)||t.startsWith(`ERROR_`)||t.startsWith(`BREACHED_`)||t.startsWith(`BLOCKED_`)||t===`MFA_AUTH_FAILED`||t===`MFA_AUTH_REJECTED`||t===`MFA_RECOVERY_FAILED`||t===`MFA_ENROLLMENT_FAILED`||t===`EMAIL_VERIFICATION_FAILED`||t===`WEBAUTHN_CHALLENGE_FAILED`||t===`WEBAUTHN_ENROLLMENT_FAILED`||t===`PASSKEY_CHALLENGE_FAILED`||t===`FLOWS_EXECUTION_FAILED`||t===`FORMS_SUBMISSION_FAILED`||t===`CIBA_EXCHANGE_FAILED`||t===`CIBA_START_FAILED`||t===`ACTIONS_EXECUTION_FAILED`||t===`RICH_CONSENTS_ACCESS_ERROR`||t===`USER_CANCELED_DEVICE_CONFIRMATION`||t===`TOO_MANY_MFA_FAILURES`||t===`MFA_RECOVERY_RATE_LIMIT_EXCEED`||t===`API_LIMIT`||t===`MAX_AMOUNT_OF_AUTHENTICATORS`?e[n]=`failure`:t.startsWith(`WARNING_`)||t===`API_LIMIT_WARNING`||t===`DEPRECATION_NOTICE`||t===`PRE_LOGIN_ASSESSMENT`?e[n]=`warning`:t===`CODE_SENT`||t===`CODE_LINK_SENT`||t===`MFA_EMAIL_SENT`||t===`MFA_SMS_SENT`||t===`EMAIL_VERIFICATION_SENT`||t===`PUSH_NOTIFICATION_SENT`?e[n]=`code_sent`:t===`INFORMATION`||t===`INFORMATION_FROM_SS_SSO_OPERATION`||t===`MANAGEMENT_API_READ_OPERATION`||t===`APPI`||t===`CONFIG_INHERITANCE_DIFF`||t===`CONFIG_DRIFT`||t===`ACLS_SUMMARY`||t===`ORGANIZATION_MEMBER_ADDED`?e[n]=`info`:e[n]=`other`;return e})();var rF=f.z.object({name:f.z.string(),version:f.z.string(),env:f.z.object({node:f.z.string().optional()}).optional()}),iF=f.z.object({country_code:f.z.string().length(2),city_name:f.z.string(),latitude:f.z.string(),longitude:f.z.string(),time_zone:f.z.string(),continent_code:f.z.string()});f.z.object({type:nF,date:f.z.string(),description:f.z.string().optional(),ip:f.z.string().optional(),user_agent:f.z.string().optional(),details:f.z.any().optional(),isMobile:f.z.boolean(),user_id:f.z.string().optional(),user_name:f.z.string().optional(),connection:f.z.string().optional(),connection_id:f.z.string().optional(),client_id:f.z.string().optional(),client_name:f.z.string().optional(),audience:f.z.string().optional(),scope:f.z.string().optional(),strategy:f.z.string().optional(),strategy_type:f.z.string().optional(),hostname:f.z.string().optional(),auth0_client:rF.optional(),log_id:f.z.string().optional(),location_info:iF.optional()}).extend({log_id:f.z.string()});var aF=f.z.enum([`http`,`eventbridge`,`eventgrid`,`splunk`,`datadog`,`sumo`,`firehose`]),oF=f.z.enum([`active`,`paused`,`suspended`]),sF=f.z.object({type:f.z.string(),name:f.z.string()});f.z.object({name:f.z.string(),type:aF,status:oF.optional(),sink:f.z.record(f.z.string(),f.z.unknown()),filters:f.z.array(sF).optional(),isPriority:f.z.boolean().optional()}).extend({id:f.z.string(),status:oF,created_at:f.z.string().optional(),updated_at:f.z.string().optional()});var cF=f.z.enum([`auth0`,`cognito`,`okta`,`oidc`]),lF=f.z.object({domain:f.z.string(),client_id:f.z.string(),client_secret:JM(),audience:f.z.string().optional(),scope:f.z.string().optional()}),uF=f.z.object({id:f.z.string().optional(),name:f.z.string(),provider:cF,connection:f.z.string(),enabled:f.z.boolean().default(!0),credentials:lF});f.z.object({id:f.z.string(),created_at:f.z.string(),updated_at:f.z.string()}).extend(uF.shape);var dF=f.z.object({enabled:f.z.boolean().optional(),shields:f.z.array(f.z.string()).optional(),admin_notification_frequency:f.z.array(f.z.string()).optional(),method:f.z.string().optional(),stage:f.z.object({"pre-user-registration":f.z.object({shields:f.z.array(f.z.string()).optional()}).optional(),"pre-change-password":f.z.object({shields:f.z.array(f.z.string()).optional()}).optional()}).optional()}),fF=f.z.object({enabled:f.z.boolean().optional(),shields:f.z.array(f.z.string()).optional(),allowlist:f.z.array(f.z.string()).optional(),mode:f.z.string().optional(),max_attempts:f.z.number().optional()}),pF=f.z.object({enabled:f.z.boolean().optional(),shields:f.z.array(f.z.string()).optional(),allowlist:f.z.array(f.z.string()).optional(),stage:f.z.object({"pre-login":f.z.object({max_attempts:f.z.number().optional(),rate:f.z.number().optional()}).optional(),"pre-user-registration":f.z.object({max_attempts:f.z.number().optional(),rate:f.z.number().optional()}).optional()}).optional()}),mF=f.z.object({breached_password_detection:dF.optional(),brute_force_protection:fF.optional(),suspicious_ip_throttling:pF.optional()});f.z.object({id:f.z.string().optional(),user_id:f.z.string(),password:f.z.string(),algorithm:f.z.enum([`bcrypt`,`argon2id`]).default(`argon2id`),is_current:f.z.boolean().default(!0)}).extend({id:f.z.string(),created_at:f.z.string(),updated_at:f.z.string()});var hF=f.z.object({initial_user_agent:f.z.string().describe(`First user agent of the device from which this user logged in`),initial_ip:f.z.string().describe(`First IP address associated with this session`),initial_asn:f.z.string().describe(`First autonomous system number associated with this session`),last_user_agent:f.z.string().describe(`Last user agent of the device from which this user logged in`),last_ip:f.z.string().describe(`Last IP address from which this user logged in`),last_asn:f.z.string().describe(`Last autonomous system number from which this user logged in`)}),gF=f.z.object({name:f.z.string().describe(`Authentication method name, e.g. "mfa" for a completed second factor`),timestamp:f.z.string().describe(`When the method was completed (ISO 8601)`),type:f.z.string().optional().describe(`For "mfa": the authentication method type used, e.g. "totp", "phone", "passkey"`)}),_F=f.z.object({methods:f.z.array(gF)}),vF=f.z.object({id:f.z.string(),revoked_at:f.z.string().optional(),used_at:f.z.string().optional(),user_id:f.z.string().describe(`The user ID associated with the session`),expires_at:f.z.string().optional(),login_session_id:f.z.string(),idle_expires_at:f.z.string().optional(),device:hF.describe(`Metadata related to the device used in the session`),clients:f.z.array(f.z.string()).describe(`List of client details for the session`),authentication:_F.optional().describe(`Authentication methods completed in this session (currently MFA only)`),session_transfer:eN.optional().describe(`Set when the session was created by redeeming a session_transfer_token`)});f.z.object({created_at:f.z.string(),updated_at:f.z.string(),authenticated_at:f.z.string(),last_interaction_at:f.z.string()}).extend(vF.shape),f.z.object({kid:f.z.string().openapi({description:`The key id of the signing key`}),tenant_id:f.z.string().optional().openapi({description:`The tenant the key belongs to. Omitted means the key is shared / control-plane scoped.`}),cert:f.z.string().openapi({description:`The public certificate of the signing key`}),fingerprint:f.z.string().openapi({description:`The cert fingerprint`}),thumbprint:f.z.string().openapi({description:`The cert thumbprint`}),pkcs7:f.z.string().optional().openapi({description:`The private key in pkcs7 format`}),current:f.z.boolean().optional().openapi({description:`True if the key is the current key`}),next:f.z.boolean().optional().openapi({description:`True if the key is the next key`}),previous:f.z.boolean().optional().openapi({description:`True if the key is the previous key`}),current_since:f.z.string().optional().openapi({description:`The date and time when the key became the current key`}),current_until:f.z.string().optional().openapi({description:`The date and time when the current key was rotated`}),revoked:f.z.boolean().optional().openapi({description:`True if the key is revoked`}),revoked_at:f.z.string().optional().openapi({description:`The date and time when the key was revoked`}),connection:f.z.string().optional().openapi({description:`The connection identifier associated with the key`}),type:f.z.enum([`jwt_signing`,`saml_encryption`]).openapi({description:`The type of the signing key`})});var yF=f.z.enum([`never`,`always`,`all-applications`,`confidence-score`]),bF={allow_remember_browser:f.z.boolean().optional(),remember_browser_lifetime_in_days:f.z.number().int().min(1).max(365).optional()};f.z.object({idle_session_lifetime:f.z.number().default(72),session_lifetime:f.z.number().default(168),session_cookie:f.z.object({mode:f.z.enum([`persistent`,`non-persistent`]).optional()}).optional(),enable_client_connections:f.z.boolean().optional(),default_redirection_uri:f.z.string().optional(),enabled_locales:f.z.array(f.z.string()).optional(),default_directory:f.z.string().optional(),error_page:f.z.object({html:f.z.string().optional(),show_log_link:f.z.boolean().optional(),url:f.z.string().optional()}).optional(),flags:f.z.object({allow_legacy_delegation_grant_types:f.z.boolean().optional(),allow_legacy_ro_grant_types:f.z.boolean().optional(),allow_legacy_tokeninfo_endpoint:f.z.boolean().optional(),disable_clickjack_protection_headers:f.z.boolean().optional(),enable_apis_section:f.z.boolean().optional(),enable_client_connections:f.z.boolean().optional(),enable_custom_domain_in_emails:f.z.boolean().optional(),enable_dynamic_client_registration:f.z.boolean().optional(),enable_idtoken_api2:f.z.boolean().optional(),enable_legacy_logs_search_v2:f.z.boolean().optional(),enable_legacy_profile:f.z.boolean().optional(),enable_pipeline2:f.z.boolean().optional(),enable_public_signup_user_exists_error:f.z.boolean().optional(),use_scope_descriptions_for_consent:f.z.boolean().optional(),disable_management_api_sms_obfuscation:f.z.boolean().optional(),enable_adfs_waad_email_verification:f.z.boolean().optional(),revoke_refresh_token_grant:f.z.boolean().optional(),dashboard_log_streams_next:f.z.boolean().optional(),dashboard_insights_view:f.z.boolean().optional(),disable_fields_map_fix:f.z.boolean().optional(),mfa_show_factor_list_on_enrollment:f.z.boolean().optional()}).optional(),friendly_name:f.z.string().optional(),picture_url:f.z.string().optional(),support_email:f.z.string().optional(),support_url:f.z.string().optional(),sandbox_version:f.z.string().optional(),sandbox_versions_available:f.z.array(f.z.string()).optional(),change_password:f.z.object({enabled:f.z.boolean(),html:f.z.string()}).optional(),guardian_mfa_page:f.z.object({enabled:f.z.boolean(),html:f.z.string()}).optional(),default_audience:f.z.string().optional(),default_organization:f.z.string().optional(),sessions:f.z.object({oidc_logout_prompt_enabled:f.z.boolean().optional()}).optional(),mfa:f.z.object({policy:yF.default(`never`).optional(),...bF,factors:f.z.object({sms:f.z.boolean().default(!1),otp:f.z.boolean().default(!1),email:f.z.boolean().default(!1),push_notification:f.z.boolean().default(!1),webauthn_roaming:f.z.boolean().default(!1),webauthn_platform:f.z.boolean().default(!1),recovery_code:f.z.boolean().default(!1),duo:f.z.boolean().default(!1)}).optional(),sms_provider:f.z.object({provider:f.z.enum([`twilio`,`vonage`,`aws_sns`,`phone_message_hook`]).optional()}).optional(),twilio:f.z.object({sid:JM().optional(),auth_token:JM().optional(),from:f.z.string().optional(),messaging_service_sid:f.z.string().optional()}).optional(),phone_message:f.z.object({message:f.z.string().optional()}).optional()}).optional()});var xF=f.z.object({id:f.z.string().optional(),parent_tenant_id:f.z.string().nullish(),config_sync:f.z.enum([`inherit-on-read`,`synced`,`detached`]).nullish(),config_sync_hash:f.z.string().nullish(),config_synced_at:f.z.string().nullish(),audience:f.z.string().optional(),friendly_name:f.z.string(),picture_url:f.z.string().optional(),support_email:f.z.string().optional(),support_url:f.z.string().optional(),sender_email:f.z.string().email().nullish(),sender_name:f.z.string().optional(),session_lifetime:f.z.number().optional(),idle_session_lifetime:f.z.number().optional(),ephemeral_session_lifetime:f.z.number().optional(),idle_ephemeral_session_lifetime:f.z.number().optional(),session_cookie:f.z.object({mode:f.z.enum([`persistent`,`non-persistent`]).optional()}).optional(),allowed_logout_urls:f.z.array(f.z.string()).optional(),default_redirection_uri:f.z.string().optional(),default_client_id:f.z.string().optional(),enabled_locales:f.z.array(f.z.string()).optional(),default_directory:f.z.string().optional(),error_page:f.z.object({html:f.z.string().optional(),show_log_link:f.z.boolean().optional(),url:f.z.string().optional()}).nullish(),flags:f.z.object({allow_changing_enable_sso:f.z.boolean().optional(),allow_legacy_delegation_grant_types:f.z.boolean().optional(),allow_legacy_ro_grant_types:f.z.boolean().optional(),allow_legacy_tokeninfo_endpoint:f.z.boolean().optional(),change_pwd_flow_v1:f.z.boolean().optional(),client_id_metadata_document_registration:f.z.boolean().optional(),custom_domains_provisioning:f.z.boolean().optional(),dashboard_insights_view:f.z.boolean().optional(),dashboard_log_streams_next:f.z.boolean().optional(),disable_clickjack_protection_headers:f.z.boolean().optional(),disable_fields_map_fix:f.z.boolean().optional(),disable_impersonation:f.z.boolean().optional(),disable_management_api_sms_obfuscation:f.z.boolean().optional(),enable_adfs_waad_email_verification:f.z.boolean().optional(),enable_apis_section:f.z.boolean().optional(),enable_client_connections:f.z.boolean().optional(),enable_custom_domain_in_emails:f.z.boolean().optional(),enable_dynamic_client_registration:f.z.boolean().optional(),dcr_require_initial_access_token:f.z.boolean().optional(),dcr_allowed_grant_types:f.z.array(f.z.string()).optional(),allow_http_return_to:f.z.array(f.z.string().refine(e=>{try{let t=new URL(e);return t.protocol===`http:`&&(t.pathname===``||t.pathname===`/`)&&!t.search&&!t.hash&&e===t.origin}catch{return!1}},{message:`must be a fully-qualified http origin (scheme + host + port, no path)`})).optional(),enable_idtoken_api2:f.z.boolean().optional(),enable_legacy_logs_search_v2:f.z.boolean().optional(),enable_legacy_profile:f.z.boolean().optional(),enable_pipeline2:f.z.boolean().optional(),enable_public_signup_user_exists_error:f.z.boolean().optional(),enable_sso:f.z.boolean().optional(),enforce_client_authentication_on_passwordless_start:f.z.boolean().optional(),genai_trial:f.z.boolean().optional(),improved_signup_bot_detection_in_classic:f.z.boolean().optional(),mfa_show_factor_list_on_enrollment:f.z.boolean().optional(),no_disclose_enterprise_connections:f.z.boolean().optional(),remove_alg_from_jwks:f.z.boolean().optional(),revoke_refresh_token_grant:f.z.boolean().optional(),trust_azure_adfs_email_verified_connection_property:f.z.boolean().optional(),use_scope_descriptions_for_consent:f.z.boolean().optional(),inherit_global_permissions_in_organizations:f.z.boolean().optional(),restrict_undefined_scopes:f.z.boolean().optional(),universal_login_version:f.z.enum([`1`,`2`]).optional()}).optional(),sandbox_version:f.z.string().optional(),legacy_sandbox_version:f.z.string().optional(),sandbox_versions_available:f.z.array(f.z.string()).optional(),change_password:f.z.object({enabled:f.z.boolean().optional(),html:f.z.string().optional()}).optional(),guardian_mfa_page:f.z.object({enabled:f.z.boolean().optional(),html:f.z.string().optional()}).optional(),device_flow:f.z.object({charset:f.z.enum([`base20`,`digits`]).optional(),mask:f.z.string().max(20).optional()}).optional(),default_token_quota:f.z.object({clients:f.z.object({client_credentials:f.z.record(f.z.string(),f.z.any()).optional()}).optional(),organizations:f.z.object({client_credentials:f.z.record(f.z.string(),f.z.any()).optional()}).optional()}).nullish(),default_audience:f.z.string().optional(),default_organization:f.z.string().optional(),sessions:f.z.object({oidc_logout_prompt_enabled:f.z.boolean().optional()}).optional(),oidc_logout:f.z.object({rp_logout_end_session_endpoint_discovery:f.z.boolean().optional()}).optional(),allow_organization_name_in_authentication_api:f.z.boolean().optional(),customize_mfa_in_postlogin_action:f.z.boolean().optional(),acr_values_supported:f.z.array(f.z.string()).optional(),mtls:f.z.object({enable_endpoint_aliases:f.z.boolean().optional()}).nullish(),pushed_authorization_requests_supported:f.z.boolean().optional(),authorization_response_iss_parameter_supported:f.z.boolean().optional(),deployment_type:f.z.enum([`shared`,`wfp`]).default(`shared`).optional(),provisioning_state:f.z.enum([`pending`,`ready`,`failed`]).default(`ready`).optional(),provisioning_error:f.z.string().max(2048).optional(),provisioning_state_changed_at:f.z.string().optional(),bundle_configuration:f.z.string().max(64).optional(),worker_version:f.z.string().max(64).optional(),database_version:f.z.string().max(64).optional(),worker_script_name:f.z.string().max(255).optional(),storage_kind:f.z.enum([`own_d1`,`existing_d1`,`shared_planetscale`]).optional(),d1_database_id:f.z.string().max(64).optional(),attack_protection:mF.optional(),mfa:f.z.object({policy:yF.default(`never`).optional(),...bF,factors:f.z.object({sms:f.z.boolean().default(!1),otp:f.z.boolean().default(!1),email:f.z.boolean().default(!1),push_notification:f.z.boolean().default(!1),webauthn_roaming:f.z.boolean().default(!1),webauthn_platform:f.z.boolean().default(!1),recovery_code:f.z.boolean().default(!1),duo:f.z.boolean().default(!1)}).optional(),sms_provider:f.z.object({provider:f.z.enum([`twilio`,`vonage`,`aws_sns`,`phone_message_hook`]).optional()}).optional(),twilio:f.z.object({sid:JM().optional(),auth_token:JM().optional(),from:f.z.string().optional(),messaging_service_sid:f.z.string().optional()}).optional(),phone_message:f.z.object({message:f.z.string().optional()}).optional()}).optional()});f.z.object({created_at:f.z.string().nullable().transform(e=>e??``),updated_at:f.z.string().nullable().transform(e=>e??``)}).extend(xF.shape).extend({id:f.z.string(),is_control_plane:f.z.boolean().optional(),has_children:f.z.boolean().optional()});var SF=xF.shape.mfa.unwrap().shape,CF=f.z.object({...SF,policy:yF.optional(),factors:f.z.object({sms:f.z.boolean().optional(),otp:f.z.boolean().optional(),email:f.z.boolean().optional(),push_notification:f.z.boolean().optional(),webauthn_roaming:f.z.boolean().optional(),webauthn_platform:f.z.boolean().optional(),recovery_code:f.z.boolean().optional(),duo:f.z.boolean().optional()}).optional()});f.z.object(xF.shape).extend({deployment_type:f.z.enum([`shared`,`wfp`]),provisioning_state:f.z.enum([`pending`,`ready`,`failed`]),mfa:CF}).partial();var wF=f.z.enum([`provision`,`seed`,`upgrade`,`backup`,`deprovision`,`users_import`,`sync-defaults`,`detach`,`tenant-members-request`]),TF=f.z.enum([`pending`,`running`,`succeeded`,`failed`,`cancelled`]),EF=f.z.string().max(64);f.z.object({tenant_id:f.z.string().max(255).nullable().default(null),rollout_id:f.z.string().max(255).nullable().optional(),kind:wF,engine:EF,engine_instance_id:f.z.string().max(100).nullable().optional(),target_worker_version:f.z.string().max(255).nullable().optional(),target_database_version:f.z.string().max(255).nullable().optional(),initiated_by:f.z.string().max(255).nullable().optional(),input:f.z.record(f.z.string(),f.z.unknown()).nullable().optional()}).extend({id:f.z.string(),status:TF,current_step:f.z.string().max(255).nullable().optional(),error:f.z.string().nullable().optional(),result:f.z.record(f.z.string(),f.z.unknown()).nullable().optional(),claimed_by:f.z.string().max(255).nullable().optional(),claim_expires_at:f.z.string().nullable().optional(),created_at:f.z.string(),updated_at:f.z.string(),finished_at:f.z.string().nullable().optional()}).pick({status:!0,current_step:!0,engine_instance_id:!0,target_worker_version:!0,target_database_version:!0,error:!0,result:!0,claimed_by:!0,claim_expires_at:!0,finished_at:!0}).partial();var DF=f.z.enum([`started`,`succeeded`,`failed`,`retried`,`skipped`,`reconciled`]);f.z.object({operation_id:f.z.string().max(255),step:f.z.string().max(255),outcome:DF,detail:f.z.record(f.z.string(),f.z.unknown()).nullable().optional(),attempt:f.z.number().int().min(1).default(1)}).extend({id:f.z.string(),created_at:f.z.string()});var OF=f.z.enum([`pending`,`inserted`,`updated`,`failed`,`skipped`]);f.z.object({operation_id:f.z.string().max(255),seq:f.z.number().int().min(0),payload:f.z.record(f.z.string(),f.z.unknown()),status:OF.default(`pending`),error_code:f.z.string().max(64).nullable().optional(),error_message:f.z.string().nullable().optional(),error_path:f.z.string().max(255).nullable().optional(),entity_id:f.z.string().max(255).nullable().optional()}).extend({status:OF,created_at:f.z.string(),updated_at:f.z.string()}),f.z.object({seq:f.z.number().int().min(0),status:OF,error_code:f.z.string().max(64).nullable().optional(),error_message:f.z.string().nullable().optional(),error_path:f.z.string().max(255).nullable().optional(),entity_id:f.z.string().max(255).nullable().optional()});var kF=f.z.enum([`upgrade`,`reseed`,`backup`,`config-sync`]),AF=f.z.enum([`pending`,`canary`,`rolling`,`paused`,`done`,`failed`]);f.z.object({kind:kF,target_worker_version:f.z.string().max(255).nullable().optional(),target_database_version:f.z.string().max(255).nullable().optional(),wave_size:f.z.number().int().min(1).default(10),canary_tenant_ids:f.z.array(f.z.string()).nullable().optional(),filter:f.z.record(f.z.string(),f.z.unknown()).nullable().optional(),initiated_by:f.z.string().max(255).nullable().optional(),config:f.z.record(f.z.string(),f.z.unknown()).nullable().optional()}).extend({id:f.z.string(),status:AF,created_at:f.z.string(),updated_at:f.z.string(),finished_at:f.z.string().nullable().optional(),paused_reason:f.z.string().nullable().optional()}).pick({status:!0,wave_size:!0,canary_tenant_ids:!0,filter:!0,config:!0,paused_reason:!0,finished_at:!0}).partial();var jF=f.z.enum([`invite`,`add_members`,`remove_members`,`assign_roles`,`remove_roles`,`revoke_invitation`]),MF=f.z.enum([`pending`,`succeeded`,`failed`]);f.z.object({kind:jF,requested_by:f.z.string().min(1).max(255),payload:f.z.record(f.z.string(),f.z.unknown())}).extend({id:f.z.string(),tenant_id:f.z.string(),status:MF,result:f.z.record(f.z.string(),f.z.unknown()).nullable().optional(),error:f.z.string().nullable().optional(),notified_at:f.z.string().nullable().optional(),created_at:f.z.string(),updated_at:f.z.string(),finished_at:f.z.string().nullable().optional()}),f.z.object({status:MF.optional(),result:f.z.record(f.z.string(),f.z.unknown()).nullable().optional(),error:f.z.string().nullable().optional(),notified_at:f.z.string().nullable().optional(),finished_at:f.z.string().nullable().optional()}),f.z.object({access_token:f.z.string(),id_token:f.z.string().optional(),scope:f.z.string().optional(),state:f.z.string().optional(),refresh_token:f.z.string().optional(),token_type:f.z.string(),expires_in:f.z.number(),issued_token_type:f.z.string().optional()}),f.z.object({code:f.z.string(),state:f.z.string().optional()});var NF=f.z.object({button_border_radius:f.z.number(),button_border_weight:f.z.number(),buttons_style:f.z.enum([`pill`,`rounded`,`sharp`]),input_border_radius:f.z.number(),input_border_weight:f.z.number(),inputs_style:f.z.enum([`pill`,`rounded`,`sharp`]),show_widget_shadow:f.z.boolean(),widget_border_weight:f.z.number(),widget_corner_radius:f.z.number()}),PF=f.z.object({base_focus_color:f.z.string(),base_hover_color:f.z.string(),body_text:f.z.string(),captcha_widget_theme:f.z.enum([`auto`,`dark`,`light`]),error:f.z.string(),header:f.z.string(),icons:f.z.string(),input_background:f.z.string(),input_border:f.z.string(),input_filled_text:f.z.string(),input_labels_placeholders:f.z.string(),links_focused_components:f.z.string(),primary_button:f.z.string(),primary_button_label:f.z.string(),secondary_button_border:f.z.string(),secondary_button_label:f.z.string(),success:f.z.string(),widget_background:f.z.string(),widget_border:f.z.string()}),FF=PF.omit({captcha_widget_theme:!0}).partial(),IF=f.z.object({bold:f.z.boolean(),size:f.z.number()}),LF=f.z.object({body_text:IF,buttons_text:IF,font_url:f.z.string(),input_labels:IF,links:IF,links_style:f.z.enum([`normal`,`underlined`]),reference_text_size:f.z.number(),subtitle:IF,title:IF}),RF=f.z.object({background_color:f.z.string(),background_image_url:f.z.string(),background_color_dark:f.z.string().optional(),background_image_url_dark:f.z.string().optional(),page_layout:f.z.enum([`center`,`left`,`right`]),logo_placement:f.z.enum([`widget`,`chip`,`none`]).optional()}),zF=f.z.object({header_text_alignment:f.z.enum([`center`,`left`,`right`]),logo_height:f.z.number(),logo_position:f.z.enum([`center`,`left`,`none`,`right`]),logo_url:f.z.string(),logo_url_dark:f.z.string().optional(),social_buttons_layout:f.z.enum([`bottom`,`top`])});f.z.object({borders:NF,colors:PF,colors_dark:FF.optional(),displayName:f.z.string(),fonts:LF,page_background:RF,widget:zF}).extend({themeId:f.z.string()}),f.z.object({..._M,universal_login_experience:f.z.enum([`new`,`classic`]).default(`new`),identifier_first:f.z.boolean().default(!0),password_first:f.z.boolean().default(!1),show_last_used_connection:f.z.boolean().default(!1),webauthn_platform_first_factor:f.z.boolean()});var BF=f.z.object({hosts:f.z.array(f.z.string()).optional(),methods:f.z.array(f.z.string()).optional(),path:f.z.string().default(`/*`),headers:f.z.record(f.z.string(),f.z.string()).optional(),query:f.z.record(f.z.string(),f.z.string()).optional()}),VF=f.z.object({type:f.z.string(),options:f.z.record(f.z.string(),f.z.unknown()).default({})}),HF=f.z.object({id:f.z.string().optional(),custom_domain_id:f.z.string(),priority:f.z.number().int().default(100),match:BF,handlers:f.z.array(VF).min(1)});HF.extend({id:f.z.string(),tenant_id:f.z.string(),created_at:f.z.string(),updated_at:f.z.string()}),HF.partial().omit({id:!0,custom_domain_id:!0});var UF=`custom_authentication`,WF=[`urn:ietf:params:oauth:`,`urn:auth0`,`urn:okta`,`http://auth0.com`,`https://auth0.com`,`http://okta.com`,`https://okta.com`],GF=f.z.string().min(1).max(200).refine(e=>e.startsWith(`https://`)||e.startsWith(`urn:`),{message:`subject_token_type must be a URI starting with https:// or urn:`}).refine(e=>!WF.some(t=>e.toLowerCase().startsWith(t)),{message:`subject_token_type uses a reserved namespace`}),KF=f.z.enum([`RS256`,`RS384`,`RS512`,`ES256`,`ES384`,`ES512`]),qF=f.z.discriminatedUnion(`type`,[f.z.object({type:f.z.literal(`connection`),connection:f.z.string().min(1),create_if_not_exists:f.z.boolean().default(!0),trust_email_verified:f.z.boolean().default(!1)}),f.z.object({type:f.z.literal(`user_id`)})]),JF=f.z.object({issuer:f.z.string().min(1).max(2048),jwks:QP.optional(),jwks_uri:f.z.string().url().optional(),audience:f.z.array(f.z.string().min(1)).min(1).optional(),algorithms:f.z.array(KF).min(1).optional(),max_lifetime_seconds:f.z.number().int().min(1).max(3600).default(300),require_jti:f.z.boolean().default(!0),user_mapping:qF});f.z.object({name:f.z.string().min(1).max(255),subject_token_type:GF,action_id:f.z.string().min(1).optional(),type:f.z.literal(UF),jwt_verification:JF.optional()}).extend({id:f.z.string(),created_at:f.z.string(),updated_at:f.z.string()}),f.z.object({name:f.z.string().min(1).max(255).optional(),subject_token_type:GF.optional(),jwt_verification:JF.optional()});var YF=f.z.enum([`oidc`,`samlp`,`waad`,`google-apps`,`adfs`,`okta`,`auth0-samlp`,`okta-samlp`,`keycloak-samlp`,`pingfederate`]),XF=f.z.object({name:f.z.string(),description:f.z.string(),is_optional:f.z.boolean()}),ZF=f.z.object({logo_url:f.z.string().optional(),colors:f.z.object({primary:f.z.string()}).optional()});f.z.object({name:f.z.string(),description:f.z.string().optional(),allowed_strategies:f.z.array(YF).optional(),user_attributes:f.z.array(XF).optional(),branding:ZF.optional()}).extend({id:f.z.string(),created_at:f.z.string(),updated_at:f.z.string()});var QF=f.z.record(f.z.string(),f.z.string()),$F=f.z.enum([`none`,`optional`,`required`]),eI=f.z.object({icon_url:f.z.string().optional(),domain_aliases:f.z.array(f.z.string()).optional()}),tI=f.z.object({name:f.z.string(),display_name:f.z.string().optional(),is_domain_connection:f.z.boolean().optional(),show_as_button:f.z.boolean().optional(),metadata:f.z.record(f.z.string(),f.z.string()).optional(),options:eI.optional()}),nI=f.z.object({organization_id:f.z.string(),assign_membership_on_login:f.z.boolean().optional(),show_as_button:f.z.boolean().optional()});f.z.object({id:f.z.string(),profile_id:f.z.string(),connection_id:f.z.string().optional(),connection_config:tI.optional(),enabled_clients:f.z.array(f.z.string()),enabled_organizations:f.z.array(nI),domain_verification:$F,expires_at:f.z.string(),revoked_at:f.z.string().optional(),completed_at:f.z.string().optional(),created_at:f.z.string(),updated_at:f.z.string()});var rI=f.z.object({scim:f.z.string(),auth0:f.z.string()}),iI=f.z.object({connection_id:f.z.string(),user_id_attribute:f.z.string().default(`externalId`),mapping:f.z.array(rI).default([])});f.z.object({created_at:f.z.string(),updated_at:f.z.string()}).extend(iI.shape);var aI=f.z.object({token_id:f.z.string(),connection_id:f.z.string(),token_hash:f.z.string(),scopes:f.z.array(f.z.string()).default([]),valid_until:f.z.string().optional()});f.z.object({created_at:f.z.string(),last_used_at:f.z.string().optional()}).extend(aI.shape);var oI=f.z.object({connection_id:f.z.string(),external_id:f.z.string(),user_id:f.z.string()});f.z.object({created_at:f.z.string()}).extend(oI.shape),f.z.object({..._M,name:f.z.string(),enabled:f.z.boolean().optional().default(!0),default_from_address:f.z.string().optional(),credentials:f.z.record(f.z.string(),f.z.unknown()),settings:f.z.object({}).optional()});var sI=f.z.enum([`verify_email`,`verify_email_by_code`,`reset_email`,`reset_email_by_code`,`welcome_email`,`blocked_account`,`stolen_credentials`,`enrollment_email`,`mfa_oob_code`,`change_password`,`password_reset`,`user_invitation`]);f.z.object({template:sI,body:f.z.string(),from:f.z.string(),subject:f.z.string(),syntax:f.z.literal(`liquid`).default(`liquid`),resultUrl:f.z.string().optional(),urlLifetimeInSeconds:f.z.number().int().nonnegative().optional(),includeEmailInRedirect:f.z.boolean().default(!1),enabled:f.z.boolean().default(!0)}),f.z.object({id:f.z.string(),login_id:f.z.string(),session_id:f.z.string().optional(),organization:f.z.string().optional(),auth_connection:f.z.string().optional(),auth_strategy:tF.optional(),session_transfer:eN.optional(),user_id:f.z.string(),client_id:f.z.string(),expires_at:f.z.string().optional(),idle_expires_at:f.z.string().optional(),last_exchanged_at:f.z.string().optional(),device:hF,resource_servers:f.z.array(f.z.object({audience:f.z.string(),scopes:f.z.string()})),rotating:f.z.boolean(),token_lookup:f.z.string().optional(),token_hash:f.z.string().optional(),family_id:f.z.string().optional(),rotated_to:f.z.string().optional(),rotated_at:f.z.string().optional()}).extend({created_at:f.z.string(),revoked_at:f.z.string().optional()}),f.z.object({to:f.z.string(),message:f.z.string()}),f.z.object({name:f.z.string(),options:f.z.object({})});var cI=f.z.object({value:f.z.string(),description:f.z.string().optional()}),lI=f.z.object({token_dialect:f.z.enum([`access_token`,`access_token_authz`]).optional(),enforce_policies:f.z.boolean().optional(),allow_skipping_userinfo:f.z.boolean().optional(),skip_userinfo:f.z.boolean().optional(),persist_client_authorization:f.z.boolean().optional(),enable_introspection_endpoint:f.z.boolean().optional(),mtls:f.z.object({bound_access_tokens:f.z.boolean().optional()}).optional()}),uI=f.z.object({id:f.z.string().optional(),name:f.z.string(),identifier:f.z.string(),scopes:f.z.array(cI).optional(),signing_alg:f.z.string().optional(),signing_secret:JM().optional(),token_lifetime:f.z.number().default(86400),token_lifetime_for_web:f.z.number().default(7200),skip_consent_for_verifiable_first_party_clients:f.z.boolean().optional(),allow_offline_access:f.z.boolean().optional(),verificationKey:f.z.string().optional(),options:lI.optional(),is_system:f.z.boolean().optional(),..._M,metadata:f.z.record(f.z.string(),f.z.any()).optional()}).extend({created_at:f.z.string().optional(),updated_at:f.z.string().optional()});f.z.array(uI);var dI=f.z.object({role_id:f.z.string(),resource_server_identifier:f.z.string(),permission_name:f.z.string()}).extend({created_at:f.z.string()});f.z.array(dI),f.z.object({user_id:f.z.string().openapi({description:`The id of the user that granted the consent`}),clientID:f.z.string().openapi({description:`The id of the client the grant was issued to`}),audience:f.z.string().optional().openapi({description:`The audience the grant applies to`}),scope:f.z.array(f.z.string()).default([]).openapi({description:`The list of OAuth scopes the user has consented to`})}).extend({id:f.z.string()}),f.z.object({user_id:f.z.string(),last_login:f.z.string().optional(),last_ip:f.z.string().optional(),login_count:f.z.number().default(0),failed_logins:f.z.array(f.z.string()).optional(),last_password_reset:f.z.string().optional()});var fI=f.z.object({user_id:f.z.string(),resource_server_identifier:f.z.string(),permission_name:f.z.string(),organization_id:f.z.string().optional()}).extend({tenant_id:f.z.string(),created_at:f.z.string().optional()});f.z.array(fI);var pI=f.z.object({user_id:f.z.string(),resource_server_identifier:f.z.string(),resource_server_name:f.z.string(),permission_name:f.z.string(),description:f.z.string().nullable().optional(),created_at:f.z.string().optional(),organization_id:f.z.string().optional()});f.z.array(pI);var mI=f.z.object({user_id:f.z.string(),role_id:f.z.string(),organization_id:f.z.string().optional()}).extend({tenant_id:f.z.string(),created_at:f.z.string().optional()});f.z.array(mI);var hI=f.z.object({id:f.z.string().optional().openapi({description:`The unique identifier of the role. If not provided, one will be generated.`}),name:f.z.string().min(1).max(50).openapi({description:`The name of the role. Cannot include '<' or '>'`}),description:f.z.string().max(255).optional().openapi({description:`The description of the role`}),is_system:f.z.boolean().optional(),metadata:f.z.record(f.z.string(),f.z.any()).optional().openapi({description:`Metadata associated with the role. Can be used to control sync behavior in multi-tenancy scenarios.`})}).extend({id:f.z.string().openapi({description:`The unique identifier of the role`}),created_at:f.z.string().optional(),updated_at:f.z.string().optional()});f.z.array(hI);var gI=f.z.object({logo_url:f.z.string().optional().openapi({description:`URL of the organization's logo`}),colors:f.z.object({primary:f.z.string().optional().openapi({description:`Primary color in hex format (e.g., #FF0000)`}),page_background:f.z.string().optional().openapi({description:`Page background color in hex format (e.g., #FFFFFF)`})}).optional()}).optional(),_I=f.z.object({connection_id:f.z.string().openapi({description:`ID of the connection`}),assign_membership_on_login:f.z.boolean().default(!1).openapi({description:`Whether to assign membership to the organization on login`}),show_as_button:f.z.boolean().default(!0).openapi({description:`Whether to show this connection as a button in the login screen`}),is_signup_enabled:f.z.boolean().default(!0).openapi({description:`Whether signup is enabled for this connection`})}),vI=f.z.object({client_credentials:f.z.object({enforce:f.z.boolean().default(!1).openapi({description:`Whether to enforce token quota limits`}),per_day:f.z.number().min(0).default(0).openapi({description:`Maximum tokens per day (0 = unlimited)`}),per_hour:f.z.number().min(0).default(0).openapi({description:`Maximum tokens per hour (0 = unlimited)`})}).optional()}).optional();f.z.object({id:f.z.string().optional(),name:f.z.string().min(1).regex(/^[a-z0-9_-]+$/,{message:`Organization name must be lowercase and can only contain letters, numbers, hyphens, and underscores`}).openapi({description:`The name of the organization. Must be lowercase and can only contain letters, numbers, hyphens, and underscores.`}),display_name:f.z.string().optional().openapi({description:`The display name of the organization`}),branding:gI,metadata:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Custom metadata for the organization`}),enabled_connections:f.z.array(_I).default([]).optional().openapi({description:`List of enabled connections for the organization`}),token_quota:vI}).extend(mM.shape).extend({id:f.z.string(),name:f.z.string().min(1).openapi({description:`The name of the organization`})});var yI=f.z.object({connection_id:f.z.string().openapi({description:`ID of the tenant-level connection to enable for the org.`}),assign_membership_on_login:f.z.boolean().optional().default(!1),show_as_button:f.z.boolean().optional().default(!0),is_signup_enabled:f.z.boolean().optional().default(!0)}).extend({connection:f.z.object({name:f.z.string().optional(),strategy:f.z.string().optional()}).optional(),created_at:f.z.string().optional(),updated_at:f.z.string().optional()});f.z.array(yI),f.z.object({user_id:f.z.string().openapi({description:`ID of the user`}),organization_id:f.z.string().openapi({description:`ID of the organization`})}).extend(mM.shape).extend({id:f.z.string()}),f.z.object({date:f.z.string().openapi({description:`Date these events occurred in ISO 8601 format`,example:`2025-12-19`}),logins:f.z.number().openapi({description:`Number of logins on this date`,example:150}),signups:f.z.number().openapi({description:`Number of signups on this date`,example:25}),leaked_passwords:f.z.number().openapi({description:`Number of breached-password detections on this date (subscription required)`,example:0}),updated_at:f.z.string().openapi({description:`Date and time this stats entry was last updated in ISO 8601 format`,example:`2025-12-19T10:30:00.000Z`}),created_at:f.z.string().openapi({description:`Approximate date and time the first event occurred in ISO 8601 format`,example:`2025-12-19T00:00:00.000Z`})}),f.z.number().openapi({description:`Number of active users in the last 30 days`,example:1234}),f.z.enum([`active-users`,`logins`,`signups`,`refresh-tokens`,`sessions`,`logouts`,`password-changes`,`password-migrations`,`mfa`,`email-verifications`,`codes-sent`]),f.z.enum([`hour`,`day`,`week`,`month`]),f.z.enum([`time`,`connection`,`client_id`,`user_type`,`event`]),f.z.enum([`password`,`social`,`passwordless`,`enterprise`]);var bI=f.z.object({cohort:f.z.string(),sessions:f.z.number(),active:f.z.array(f.z.number())});f.z.object({interval:f.z.literal(`week`),from:f.z.string(),to:f.z.string(),cohorts:f.z.array(bI)});var xI=f.z.object({cohort:f.z.string(),tokens:f.z.number(),active:f.z.array(f.z.number())});f.z.object({interval:f.z.literal(`week`),from:f.z.string(),to:f.z.string(),cohorts:f.z.array(xI)});var SI=f.z.object({name:f.z.string(),type:f.z.string()}),CI=f.z.object({elapsed:f.z.number(),rows_read:f.z.number().optional(),bytes_read:f.z.number().optional()});f.z.object({meta:f.z.array(SI),data:f.z.array(f.z.record(f.z.string(),f.z.any())),rows:f.z.number(),rows_before_limit_at_least:f.z.number().optional(),statistics:CI.optional()});var wI=f.z.enum(`login.login-id.login-password.signup.signup-id.signup-password.reset-password.consent.mfa.mfa-push.mfa-otp.mfa-voice.mfa-phone.mfa-webauthn.mfa-email.mfa-recovery-code.status.device-flow.email-verification.email-otp-challenge.organizations.invitation.common.passkeys.captcha.custom-form.login-passwordless.mfa-login-options`.split(`.`)),TI=f.z.record(f.z.string(),f.z.record(f.z.string(),f.z.string())).openapi({type:`object`,additionalProperties:{type:`object`,additionalProperties:{type:`string`}}});f.z.object({prompt:wI,language:f.z.string(),custom_text:TI});var EI=f.z.object({"form-content-start":f.z.string().optional(),"form-content-end":f.z.string().optional(),"form-footer-start":f.z.string().optional(),"form-footer-end":f.z.string().optional(),"secondary-actions-start":f.z.string().optional(),"secondary-actions-end":f.z.string().optional()}).strict(),DI=f.z.record(f.z.string(),EI);f.z.object({prompt:f.z.string(),partials:DI});var OI=f.z.enum([`phone`,`totp`,`email`,`push`,`webauthn-roaming`,`webauthn-platform`,`passkey`]),kI=f.z.object({user_id:f.z.string(),type:OI,phone_number:f.z.string().optional(),totp_secret:f.z.string().optional(),totp_last_step:f.z.number().int().nonnegative().optional(),credential_id:f.z.string().optional(),public_key:f.z.string().optional(),sign_count:f.z.number().int().nonnegative().optional(),credential_backed_up:f.z.boolean().optional(),transports:f.z.array(f.z.string()).optional(),friendly_name:f.z.string().optional(),confirmed:f.z.boolean().default(!1)});function AI(e,t){e.type===`phone`&&!e.phone_number&&t.addIssue({code:f.z.ZodIssueCode.custom,message:`phone_number is required when type is 'phone'`,path:[`phone_number`]}),e.type===`totp`&&!e.totp_secret&&t.addIssue({code:f.z.ZodIssueCode.custom,message:`totp_secret is required when type is 'totp'`,path:[`totp_secret`]}),[`webauthn-roaming`,`webauthn-platform`,`passkey`].includes(e.type)&&(e.credential_id||t.addIssue({code:f.z.ZodIssueCode.custom,message:`credential_id is required when type is '${e.type}'`,path:[`credential_id`]}),e.public_key||t.addIssue({code:f.z.ZodIssueCode.custom,message:`public_key is required when type is '${e.type}'`,path:[`public_key`]}))}kI.superRefine(AI),kI.extend({id:f.z.string(),created_at:f.z.string(),updated_at:f.z.string()}).superRefine(AI),f.z.object({id:f.z.string().optional(),created_at:f.z.string().datetime({offset:!0}).optional(),updated_at:f.z.string().datetime({offset:!0}).optional()}),f.z.enum([`verify_email`,`verify_email_by_code`,`reset_email`,`reset_email_by_code`,`welcome_email`,`verification_code`,`mfa_oob_code`,`enrollment_email`,`blocked_account`,`stolen_credentials`,`try_provider_configuration_email`,`organization_invitation`]),f.z.enum([`otp_verify`,`otp_enroll`,`blocked_account`,`change_password`,`password_breach`]);function jI(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function MI(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}f.z.record(f.z.string(),f.z.record(f.z.string(),QF));var NI=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,PI=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=NI[n[e]&63];return t};async function FI(e){let t=new DecompressionStream(`deflate-raw`),n=new Uint8Array(e),r=new Blob([n]).stream().pipeThrough(t);return new Uint8Array(await new Response(r).arrayBuffer())}async function II(e){let t=MI(e.replace(/ /g,`+`));try{let e=await FI(t);return new TextDecoder().decode(e)}catch(e){return console.warn(`Decompression failed, assuming data is not compressed:`,e),new TextDecoder().decode(t)}}async function LI(e){let t=await II(e),n=new Uj({attributeNamePrefix:`@_`,alwaysCreateTextNode:!0,ignoreAttributes:!1});return ak.parse(n.parse(t))}async function RI(e){let t=e=>e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),n=e.success?`urn:oasis:names:tc:SAML:2.0:status:Success`:`urn:oasis:names:tc:SAML:2.0:status:Responder`,r=e.inResponseTo?` InResponseTo="${t(e.inResponseTo)}"`:``,i=!e.success&&e.statusMessage?`<samlp:StatusMessage>${t(e.statusMessage)}</samlp:StatusMessage>`:``,a=`<samlp:LogoutResponse xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_${PI()}" Version="2.0" IssueInstant="${new Date().toISOString()}" Destination="${t(e.destination)}"${r}><saml:Issuer>${t(e.issuer)}</saml:Issuer><samlp:Status><samlp:StatusCode Value="${n}"/>${i}</samlp:Status></samlp:LogoutResponse>`,o=new Blob([new TextEncoder().encode(a)]).stream().pipeThrough(new CompressionStream(`deflate-raw`)),s=new Uint8Array(await new Response(o).arrayBuffer()),c=``;for(let e of s)c+=String.fromCharCode(e);return btoa(c)}function zI(e){let t=e.certificates.map(e=>({"@_use":`signing`,KeyInfo:{"@_xmlns":`http://www.w3.org/2000/09/xmldsig#`,X509Data:{X509Certificate:e}}})),n={EntityDescriptor:{"@_entityID":e.entityId,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:metadata`,IDPSSODescriptor:{"@_protocolSupportEnumeration":`urn:oasis:names:tc:SAML:2.0:protocol`,KeyDescriptor:t,SingleLogoutService:[{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect`,"@_Location":e.singleLogoutServiceUrl},{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`,"@_Location":e.singleLogoutServiceUrl}],NameIDFormat:[`urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress`,`urn:oasis:names:tc:SAML:2.0:nameid-format:persistent`,`urn:oasis:names:tc:SAML:2.0:nameid-format:transient`],SingleSignOnService:[{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect`,"@_Location":e.assertionConsumerServiceUrl},{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`,"@_Location":e.assertionConsumerServiceUrl}],Attribute:[{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`E-Mail Address`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Given Name`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Name`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Surname`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Name ID`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`}]}}};return new pM({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!1,format:!0,attributeNamePrefix:`@_`}).build(n)}async function BI(e,t){let n=e.notBefore||new Date().toISOString(),r=e.notAfter||new Date(new Date(n).getTime()+600*1e3).toISOString(),i=e.issueInstant||n,a=e.sessionNotOnOrAfter||r,o=e.responseId||`_${PI()}`,s=e.assertionId||`_${PI()}`,c=[{"samlp:Response":[{"saml:Issuer":[{"#text":e.issuer}]},{"samlp:Status":[{"samlp:StatusCode":[],":@":{"@_Value":`urn:oasis:names:tc:SAML:2.0:status:Success`}}]},{"saml:Assertion":[{"saml:Issuer":[{"#text":e.issuer}]},{"saml:Subject":[{"saml:NameID":[{"#text":e.email}],":@":{"@_Format":`urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress`}},{"saml:SubjectConfirmation":[{"saml:SubjectConfirmationData":[],":@":{"@_InResponseTo":e.inResponseTo,"@_NotOnOrAfter":r,"@_Recipient":e.destination}}],":@":{"@_Method":`urn:oasis:names:tc:SAML:2.0:cm:bearer`}}]},{"saml:Conditions":[{"saml:AudienceRestriction":[{"saml:Audience":[{"#text":e.audience}]}]}],":@":{"@_NotBefore":n,"@_NotOnOrAfter":r}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":`urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified`}]}]}],":@":{"@_AuthnInstant":i,"@_SessionIndex":e.sessionIndex,"@_SessionNotOnOrAfter":a}},{"saml:AttributeStatement":[{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.userId}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_FriendlyName":`persistent`,"@_Name":`id`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.email}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`email`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`manage-account`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`default-roles-master`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`offline_access`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`view-profile`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`uma_authorization`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`manage-account-links`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}}]}],":@":{"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`,"@_ID":s,"@_IssueInstant":i,"@_Version":`2.0`}}],":@":{"@_xmlns:samlp":`urn:oasis:names:tc:SAML:2.0:protocol`,"@_xmlns:saml":`urn:oasis:names:tc:SAML:2.0:assertion`,"@_Destination":e.destination,"@_ID":o,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":i,"@_Version":`2.0`}}],l=new pM({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(c);return e.signature&&t&&(l=await t.signSAML(l,e.signature.privateKeyPem,e.signature.cert)),e.encode===!1?l:btoa(l)}var VI=`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect`,HI=`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`,UI={"rsa-sha256":`http://www.w3.org/2001/04/xmldsig-more#rsa-sha256`,"rsa-sha1":`http://www.w3.org/2000/09/xmldsig#rsa-sha1`},WI={"rsa-sha256":`SHA-256`,"rsa-sha1":`SHA-1`};function GI(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/'/g,`&apos;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}async function KI(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`deflate-raw`));return jI(new Uint8Array(await new Response(t).arrayBuffer()))}function qI(e){let t=e.id||`_${PI()}`,n=e.issueInstant||new Date().toISOString(),r=e.nameIdFormat||`urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified`,i=e.forceAuthn?` ForceAuthn="true"`:``;return{id:t,xml:`<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="${GI(t)}" Version="2.0" IssueInstant="${GI(n)}" Destination="${GI(e.destination)}" AssertionConsumerServiceURL="${GI(e.assertionConsumerServiceUrl)}" ProtocolBinding="${HI}"${i}><saml:Issuer>${GI(e.issuer)}</saml:Issuer><samlp:NameIDPolicy Format="${GI(r)}" AllowCreate="true"/></samlp:AuthnRequest>`}}function JI(e,t){let n=e.replace(RegExp(`-----(BEGIN|END) ${t}-----`,`g`),``).replace(/\s/g,``);return Uint8Array.from(MI(n))}async function YI(e){let t=e.parameter||`SAMLRequest`,n=await KI(e.xml),r=`${t}=${encodeURIComponent(n)}`;if(e.relayState&&(r+=`&RelayState=${encodeURIComponent(e.relayState)}`),e.signingKey){let t=e.signingKey.algorithm||`rsa-sha256`;r+=`&SigAlg=${encodeURIComponent(UI[t])}`;let n=await crypto.subtle.importKey(`pkcs8`,JI(e.signingKey.privateKeyPem,`PRIVATE KEY`),{name:`RSASSA-PKCS1-v1_5`,hash:WI[t]},!1,[`sign`]),i=await crypto.subtle.sign(`RSASSA-PKCS1-v1_5`,n,new TextEncoder().encode(r));r+=`&Signature=${encodeURIComponent(jI(new Uint8Array(i)))}`}let i=e.endpoint.indexOf(`#`),a=i===-1?e.endpoint:e.endpoint.slice(0,i),o=i===-1?``:e.endpoint.slice(i);return`${a}${a.includes(`?`)?`&`:`?`}${r}${o}`}function XI(e){let t=e.replace(/\\[rn]/g,`
310
+ `):(this.indentate=function(){return``},this.tagEndChar=`>`,this.newLine=``)}function cM(e,t){let n=e[`?xml`];if(n&&typeof n==`object`){if(t.attributesGroupName&&n[t.attributesGroupName]){let e=n[t.attributesGroupName][t.attributeNamePrefix+`version`];if(e)return e}let e=n[t.attributeNamePrefix+`version`];if(e)return e}return`1.0`}function lM(e,t,n,r,i){return!n.sanitizeName||i(e)?e:n.sanitizeName(e,{isAttribute:t,matcher:r.readOnly()})}sM.prototype.build=function(e){if(this.options.preserveOrder)return Xj(e,this.options);{Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e});let t=new $A,n=CA(`qName`,{xmlVersion:cM(e,this.options)});return this.j2x(e,0,t,n).val}},sM.prototype.j2x=function(e,t,n,r){let i=``,a=``;if(this.options.maxNestedTags&&n.getDepth()>=this.options.maxNestedTags)throw Error(`Maximum nested tags exceeded`);let o=this.options.jPath?n.toString():n,s=this.checkStopNode(n);for(let c in e){if(!Object.prototype.hasOwnProperty.call(e,c))continue;let l=c===this.options.textNodeName||c===this.options.cdataPropName||c===this.options.commentPropName||this.options.attributesGroupName&&c===this.options.attributesGroupName||this.isAttribute(c)||c[0]===`?`?c:lM(c,!1,this.options,n,r);if(e[c]===void 0)this.isAttribute(c)&&(a+=``);else if(e[c]===null)this.isAttribute(c)||l===this.options.cdataPropName||l===this.options.commentPropName?a+=``:l[0]===`?`?a+=this.indentate(t)+`<`+l+`?`+this.tagEndChar:a+=this.indentate(t)+`<`+l+`/`+this.tagEndChar;else if(e[c]instanceof Date)a+=this.buildTextValNode(e[c],l,``,t,n);else if(typeof e[c]!=`object`){let u=this.isAttribute(c);if(u&&!this.ignoreAttributesFn(u,o)){let t=lM(u,!0,this.options,n,r);i+=this.buildAttrPairStr(t,``+e[c],s)}else if(!u)if(c===this.options.textNodeName){let t=this.options.tagValueProcessor(c,``+e[c]);a+=this.replaceEntitiesValue(t)}else{n.push(l);let r=this.checkStopNode(n);if(n.pop(),r){let n=``+e[c];n===``?a+=this.indentate(t)+`<`+l+this.closeTag(l)+this.tagEndChar:a+=this.indentate(t)+`<`+l+`>`+n+`</`+l+this.tagEndChar}else a+=this.buildTextValNode(e[c],l,``,t,n)}}else if(Array.isArray(e[c])){let i=e[c].length,o=``,s=``;for(let u=0;u<i;u++){let i=e[c][u];if(i!==void 0)if(i===null)l[0]===`?`?a+=this.indentate(t)+`<`+l+`?`+this.tagEndChar:a+=this.indentate(t)+`<`+l+`/`+this.tagEndChar;else if(typeof i==`object`)if(this.options.oneListGroup){n.push(l);let e=this.j2x(i,t+1,n,r);n.pop(),o+=e.val,this.options.attributesGroupName&&i.hasOwnProperty(this.options.attributesGroupName)&&(s+=e.attrStr)}else o+=this.processTextOrObjNode(i,l,t,n,r);else if(this.options.oneListGroup){let e=this.options.tagValueProcessor(l,i);e=this.replaceEntitiesValue(e),o+=e}else{n.push(l);let e=this.checkStopNode(n);if(n.pop(),e){let e=``+i;e===``?o+=this.indentate(t)+`<`+l+this.closeTag(l)+this.tagEndChar:o+=this.indentate(t)+`<`+l+`>`+e+`</`+l+this.tagEndChar}else o+=this.buildTextValNode(i,l,``,t,n)}}this.options.oneListGroup&&(o=this.buildObjectNode(o,l,s,t)),a+=o}else if(this.options.attributesGroupName&&c===this.options.attributesGroupName){let t=Object.keys(e[c]),a=t.length;for(let o=0;o<a;o++){let a=lM(t[o],!0,this.options,n,r);i+=this.buildAttrPairStr(a,``+e[c][t[o]],s)}}else a+=this.processTextOrObjNode(e[c],l,t,n,r)}return{attrStr:i,val:a}},sM.prototype.buildAttrPairStr=function(e,t,n){return n||(t=this.options.attributeValueProcessor(e,``+t),t=this.replaceEntitiesValue(t)),this.options.suppressBooleanAttributes&&t===`true`?` `+e:` `+e+`="`+Kj(t)+`"`};function uM(e,t,n,r,i){let a=this.extractAttributes(e);if(r.push(t,a),this.checkStopNode(r)){let i=this.buildRawContent(e),a=this.buildAttributesForStopNode(e);return r.pop(),this.buildObjectNode(i,t,a,n)}let o=this.j2x(e,n+1,r,i);return r.pop(),t[0]===`?`?this.buildTextValNode(``,t,o.attrStr,n,r):e[this.options.textNodeName]!==void 0&&Object.keys(e).length===1?this.buildTextValNode(e[this.options.textNodeName],t,o.attrStr,n,r):this.buildObjectNode(o.val,t,o.attrStr,n)}sM.prototype.extractAttributes=function(e){if(!e||typeof e!=`object`)return null;let t={},n=!1;if(this.options.attributesGroupName&&e[this.options.attributesGroupName]){let r=e[this.options.attributesGroupName];for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e))continue;let i=e.startsWith(this.options.attributeNamePrefix)?e.substring(this.options.attributeNamePrefix.length):e;t[i]=Kj(r[e]),n=!0}}else for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=this.isAttribute(r);i&&(t[i]=Kj(e[r]),n=!0)}return n?t:null},sM.prototype.buildRawContent=function(e){if(typeof e==`string`)return e;if(typeof e!=`object`||!e)return String(e);if(e[this.options.textNodeName]!==void 0)return e[this.options.textNodeName];let t=``;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n)||this.isAttribute(n)||this.options.attributesGroupName&&n===this.options.attributesGroupName)continue;let r=e[n];if(n===this.options.textNodeName)t+=r;else if(Array.isArray(r)){for(let e of r)if(typeof e==`string`||typeof e==`number`)t+=`<${n}>${e}</${n}>`;else if(typeof e==`object`&&e){let r=this.buildRawContent(e),i=this.buildAttributesForStopNode(e);r===``?t+=`<${n}${i}/>`:t+=`<${n}${i}>${r}</${n}>`}}else if(typeof r==`object`&&r){let e=this.buildRawContent(r),i=this.buildAttributesForStopNode(r);e===``?t+=`<${n}${i}/>`:t+=`<${n}${i}>${e}</${n}>`}else t+=`<${n}>${r}</${n}>`}return t},sM.prototype.buildAttributesForStopNode=function(e){if(!e||typeof e!=`object`)return``;let t=``;if(this.options.attributesGroupName&&e[this.options.attributesGroupName]){let n=e[this.options.attributesGroupName];for(let e in n){if(!Object.prototype.hasOwnProperty.call(n,e))continue;let r=e.startsWith(this.options.attributeNamePrefix)?e.substring(this.options.attributeNamePrefix.length):e,i=n[e];i===!0&&this.options.suppressBooleanAttributes?t+=` `+r:t+=` `+r+`="`+Kj(i)+`"`}}else for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;let r=this.isAttribute(n);if(r){let i=e[n];i===!0&&this.options.suppressBooleanAttributes?t+=` `+r:t+=` `+r+`="`+Kj(i)+`"`}}return t},sM.prototype.buildObjectNode=function(e,t,n,r){if(e===``)return t[0]===`?`?this.indentate(r)+`<`+t+n+`?`+this.tagEndChar:this.indentate(r)+`<`+t+n+this.closeTag(t)+this.tagEndChar;if(t[0]===`?`)return this.indentate(r)+`<`+t+n+`?`+this.tagEndChar;{let i=`</`+t+this.tagEndChar,a=``;return t[0]===`?`&&(a=`?`,i=``),(n||n===``)&&e.indexOf(`<`)===-1?this.indentate(r)+`<`+t+n+a+`>`+e+i:this.options.commentPropName!==!1&&t===this.options.commentPropName&&a.length===0?this.indentate(r)+`<!--${Wj(e)}-->`+this.newLine:this.indentate(r)+`<`+t+n+a+this.tagEndChar+e+this.indentate(r)+i}},sM.prototype.closeTag=function(e){let t=``;return this.options.unpairedTags.indexOf(e)===-1?t=this.options.suppressEmptyNode?`/`:`></${e}`:this.options.suppressUnpairedNode||(t=`/`),t},sM.prototype.checkStopNode=function(e){if(!this.stopNodeExpressions||this.stopNodeExpressions.length===0)return!1;for(let t=0;t<this.stopNodeExpressions.length;t++)if(e.matches(this.stopNodeExpressions[t]))return!0;return!1},sM.prototype.buildTextValNode=function(e,t,n,r,i){if(this.options.cdataPropName!==!1&&t===this.options.cdataPropName){let t=Gj(e);return this.indentate(r)+`<![CDATA[${t}]]>`+this.newLine}else if(this.options.commentPropName!==!1&&t===this.options.commentPropName){let t=Wj(e);return this.indentate(r)+`<!--${t}-->`+this.newLine}else if(t[0]===`?`)return this.indentate(r)+`<`+t+n+`?`+this.tagEndChar;else{let i=this.options.tagValueProcessor(t,e);return i=this.replaceEntitiesValue(i),i===``?this.indentate(r)+`<`+t+n+this.closeTag(t)+this.tagEndChar:this.indentate(r)+`<`+t+n+`>`+i+`</`+t+this.tagEndChar}},sM.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){let n=this.options.entities[t];e=e.replace(n.regex,n.val)}return e};function dM(e){return this.options.indentBy.repeat(e)}function fM(e){return e.startsWith(this.options.attributeNamePrefix)&&e!==this.options.textNodeName?e.substr(this.attrPrefixLen):!1}var pM=sM,mM=f.z.object({created_at:f.z.string(),updated_at:f.z.string()}),hM=f.z.enum([`local`,`shared`,`platform`]),gM=f.z.enum([`none`,`secrets`,`fields`]),_M={scope:hM.optional(),override:gM.optional(),enforce:f.z.boolean().optional()},vM=f.z.object({id:f.z.string(),version:f.z.string().optional()}),yM=f.z.object({name:f.z.string(),version:f.z.string()}),bM=f.z.object({name:f.z.string(),value:f.z.string().optional()}),xM=f.z.object({name:f.z.string().max(255),code:f.z.string().max(1e5),supported_triggers:f.z.array(vM).optional(),runtime:f.z.string().max(50).optional(),dependencies:f.z.array(yM).optional(),secrets:f.z.array(bM).optional(),is_system:f.z.boolean().optional(),..._M,inherit:f.z.boolean().optional()});xM.partial().extend({status:f.z.enum([`draft`,`built`]).optional(),deployed_at:f.z.string().optional()});var SM=xM.extend({id:f.z.string(),tenant_id:f.z.string(),status:f.z.enum([`draft`,`built`]).default(`built`),deployed_at:f.z.string().optional(),secrets:f.z.array(f.z.object({name:f.z.string(),value:f.z.string().optional()})).optional()}).extend(mM.shape),CM=f.z.object({name:f.z.string()});SM.extend({secrets:f.z.array(CM).optional()});var wM=f.z.string(),TM=f.z.enum([`unspecified`,`pending`,`final`,`partial`,`canceled`,`suspended`]),EM=f.z.object({id:f.z.string(),msg:f.z.string(),url:f.z.string().optional()}),DM=f.z.object({action_name:f.z.string(),error:EM.nullable(),started_at:f.z.string(),ended_at:f.z.string()}),OM=f.z.object({level:f.z.enum([`log`,`info`,`warn`,`error`,`debug`]),message:f.z.string()}),kM=f.z.array(f.z.object({action_name:f.z.string(),lines:f.z.array(OM)}));f.z.object({id:f.z.string(),tenant_id:f.z.string(),trigger_id:wM,status:TM,results:f.z.array(DM),logs:kM.optional(),created_at:f.z.string(),updated_at:f.z.string()}).omit({tenant_id:!0,created_at:!0,updated_at:!0}),f.z.object({action_id:f.z.string(),code:f.z.string().max(1e5),runtime:f.z.string().max(50).optional(),dependencies:f.z.array(yM).optional(),secrets:f.z.array(bM).optional(),supported_triggers:f.z.array(vM).optional(),deployed:f.z.boolean().default(!0)}).extend({id:f.z.string(),tenant_id:f.z.string(),number:f.z.number().int()}).extend(mM.shape);var AM=f.z.enum([`user_action`,`admin_action`,`system`,`api`]),jM=f.z.object({type:f.z.enum([`user`,`admin`,`system`,`api_key`,`client_credentials`]),id:f.z.string().optional(),email:f.z.string().optional(),org_id:f.z.string().optional(),org_name:f.z.string().optional(),scopes:f.z.array(f.z.string()).optional(),client_id:f.z.string().optional()}),MM=f.z.object({type:f.z.string(),id:f.z.string(),before:f.z.record(f.z.string(),f.z.unknown()).optional(),after:f.z.record(f.z.string(),f.z.unknown()).optional(),diff:f.z.record(f.z.string(),f.z.object({old:f.z.unknown(),new:f.z.unknown()})).optional()}),NM=f.z.object({user:f.z.object({user_id:f.z.string(),name:f.z.string().optional(),email:f.z.string().optional()}).optional(),strategy:f.z.string(),credentials:f.z.object({jti:f.z.string().optional(),scopes:f.z.array(f.z.string()).optional()}).optional()}),PM=f.z.object({method:f.z.string(),path:f.z.string(),query:f.z.record(f.z.string(),f.z.string()).optional(),body:f.z.unknown().optional(),ip:f.z.string(),user_agent:f.z.string().optional(),correlation_id:f.z.string().optional(),redirect_uri:f.z.string().optional(),authorization_url:f.z.string().optional(),auth:NM.optional()}),FM=f.z.object({status_code:f.z.number(),body:f.z.unknown().optional()}),IM=f.z.object({country_code:f.z.string(),city_name:f.z.string(),latitude:f.z.string(),longitude:f.z.string(),time_zone:f.z.string(),continent_code:f.z.string()}),LM=f.z.object({name:f.z.string(),version:f.z.string(),env:f.z.record(f.z.string(),f.z.string()).optional()});f.z.object({tenant_id:f.z.string(),event_type:f.z.string(),log_type:f.z.string(),description:f.z.string().optional(),category:AM,actor:jM,target:MM,request:PM,response:FM.optional(),connection:f.z.string().optional(),connection_id:f.z.string().optional(),client_name:f.z.string().optional(),strategy:f.z.string().optional(),strategy_type:f.z.string().optional(),audience:f.z.string().optional(),scope:f.z.string().optional(),location:IM.optional(),auth0_client:LM.optional(),hostname:f.z.string(),is_mobile:f.z.boolean().optional(),execution_id:f.z.string().optional(),details:f.z.record(f.z.string(),f.z.unknown()).optional(),login_session_id:f.z.string().optional(),timestamp:f.z.string()}).extend({id:f.z.string()}),f.z.enum([`AUTH0`,`EMAIL`,`REDIRECT`]),f.z.enum([`CREATE_USER`,`GET_USER`,`UPDATE_USER`,`SEND_REQUEST`,`SEND_EMAIL`]),f.z.enum([`VERIFY_EMAIL`]);var RM=f.z.object({require_mx_record:f.z.boolean().optional(),block_aliases:f.z.boolean().optional(),block_free_emails:f.z.boolean().optional(),block_disposable_emails:f.z.boolean().optional(),blocklist:f.z.array(f.z.string()).optional(),allowlist:f.z.array(f.z.string()).optional()}),zM=f.z.object({id:f.z.string(),alias:f.z.string().max(100).optional(),type:f.z.literal(`AUTH0`),action:f.z.literal(`UPDATE_USER`),allow_failure:f.z.boolean().optional(),mask_output:f.z.boolean().optional(),params:f.z.object({connection_id:f.z.string().optional(),user_id:f.z.string(),changes:f.z.record(f.z.string(),f.z.any())})}),BM=f.z.object({id:f.z.string(),alias:f.z.string().max(100).optional(),type:f.z.literal(`EMAIL`),action:f.z.literal(`VERIFY_EMAIL`),allow_failure:f.z.boolean().optional(),mask_output:f.z.boolean().optional(),params:f.z.object({email:f.z.string(),rules:RM.optional()})}),VM=f.z.enum([`change-email`,`account`,`custom`]),HM=f.z.object({id:f.z.string(),alias:f.z.string().max(100).optional(),type:f.z.literal(`REDIRECT`),action:f.z.literal(`REDIRECT_USER`),allow_failure:f.z.boolean().optional(),mask_output:f.z.boolean().optional(),params:f.z.object({target:VM.openapi({description:`The predefined target to redirect to, or 'custom' for a custom URL`}),custom_url:f.z.string().optional().openapi({description:`Custom URL to redirect to when target is 'custom'`})})}),UM=f.z.union([zM,BM,HM]);f.z.object({name:f.z.string().min(1).max(150).openapi({description:`The name of the flow`}),actions:f.z.array(UM).optional().default([]).openapi({description:`The list of actions to execute in sequence`})}).extend(mM.shape).extend({id:f.z.string().openapi({description:`Unique identifier for the flow`,example:`af_12tMpdJ3iek7svMyZkSh5M`})}),f.z.object({page:f.z.string().min(0).optional().default(`0`).transform(e=>parseInt(e,10)).openapi({description:`The page number where 0 is the first page`}),per_page:f.z.string().min(1).optional().default(`50`).transform(e=>parseInt(e,10)).openapi({description:`The number of items per page. Defaults to 50.`}),include_totals:f.z.string().optional().default(`false`).transform(e=>e===`true`).openapi({description:`If the total number of items should be included in the response`}),sort:f.z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:`A property that should have the format 'string:-1' or 'string:1'`}),q:f.z.string().optional().openapi({description:`A lucene query string used to filter the results`})}),f.z.object({start:f.z.number(),limit:f.z.number(),length:f.z.number(),total:f.z.number().optional(),next:f.z.string().optional()});var WM=f.z.object({email:f.z.string().optional(),email_verified:f.z.boolean().optional(),name:f.z.string().optional(),username:f.z.string().optional(),given_name:f.z.string().optional(),phone_number:f.z.string().optional(),phone_verified:f.z.boolean().optional(),family_name:f.z.string().optional()}).catchall(f.z.any()),GM=f.z.object({connection:f.z.string(),user_id:f.z.string(),provider:f.z.string(),isSocial:f.z.boolean(),email:f.z.string().optional(),email_verified:f.z.boolean().optional(),phone_number:f.z.string().optional(),phone_verified:f.z.boolean().optional(),username:f.z.string().optional(),access_token:f.z.string().optional(),access_token_secret:f.z.string().optional(),refresh_token:f.z.string().optional(),profileData:WM.optional()}),KM=f.z.object({formatted:f.z.string().optional(),street_address:f.z.string().optional(),locality:f.z.string().optional(),region:f.z.string().optional(),postal_code:f.z.string().optional(),country:f.z.string().optional()}).optional(),qM=f.z.object({email:f.z.string().transform(e=>e.toLowerCase()).optional(),username:f.z.string().refine(e=>!e.includes(`@`),{message:`Usernames must not contain "@". Use the email field for email addresses.`}).optional(),phone_number:f.z.string().optional(),phone_verified:f.z.boolean().optional(),given_name:f.z.string().optional(),family_name:f.z.string().optional(),nickname:f.z.string().optional(),name:f.z.string().optional(),picture:f.z.string().optional(),locale:f.z.string().optional(),linked_to:f.z.string().optional(),profileData:f.z.string().optional(),user_id:f.z.string().optional(),app_metadata:f.z.any().default({}).optional(),user_metadata:f.z.any().default({}).optional(),middle_name:f.z.string().optional(),preferred_username:f.z.string().optional(),profile:f.z.string().optional(),website:f.z.string().optional(),gender:f.z.string().optional(),birthdate:f.z.string().optional(),zoneinfo:f.z.string().optional(),address:KM});qM.extend({email_verified:f.z.boolean().default(!1),verify_email:f.z.boolean().optional(),last_ip:f.z.string().optional(),last_login:f.z.string().optional(),user_id:f.z.string().optional(),provider:f.z.string().optional(),connection:f.z.string(),is_social:f.z.boolean().optional(),blocked:f.z.boolean().optional(),registration_completed_at:f.z.string().optional(),password:f.z.object({hash:f.z.string(),algorithm:f.z.string()}).optional()}).omit({password:!0}).extend(mM.shape).extend({user_id:f.z.string(),provider:f.z.string(),is_social:f.z.boolean(),email:f.z.string().optional(),login_count:f.z.number().default(0),identities:f.z.array(GM).optional()}).omit({registration_completed_at:!0}),qM.extend({login_count:f.z.number(),multifactor:f.z.array(f.z.string()).optional(),last_ip:f.z.string().optional(),last_login:f.z.string().optional(),user_id:f.z.string()}).catchall(f.z.any());function JM(){return f.z.string().trim()}var YM=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,XM=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=YM[n[e]&63];return t},ZM=f.z.enum([`cookie`,`query`]),QM=f.z.enum([`ip`,`asn`,`none`]),$M=f.z.object({can_create_session_transfer_token:f.z.boolean().optional().openapi({default:!1,description:`Whether this client may exchange a refresh token for a session_transfer_token.`}),enforce_cascade_revocation:f.z.boolean().optional().openapi({default:!0,description:`Whether revoking the refresh token a session_transfer_token was minted from also ends the sessions (and their refresh tokens) created with that token.`}),allowed_authentication_methods:f.z.array(ZM).optional().openapi({default:[],description:"How this client accepts a session_transfer_token at /authorize: as the `session_transfer_token` query parameter (`query`) and/or the `auth0_session_transfer_token` cookie (`cookie`). Empty means the client does not accept session transfer."}),enforce_device_binding:QM.optional().openapi({default:`ip`,description:"Whether the browser redeeming a session_transfer_token must come from the same IP address (`ip`) or autonomous system (`asn`) as the request that minted it. `none` disables the check."}),allow_refresh_token:f.z.boolean().optional().openapi({default:!1,description:`Whether a login established with a session_transfer_token may be issued a refresh token.`}),enforce_online_refresh_tokens:f.z.boolean().optional().openapi({default:!0,description:`Whether refresh tokens issued on a transferred session are bound to that session's lifetime.`}),allow_onward_transfer:f.z.boolean().optional().openapi({default:!1,description:`AuthHero extension. Whether this client may mint a session_transfer_token from a login that was itself established with one (A → B → C). The onward token stays tied to the original refresh token.`}),trust_forwarded_ip:f.z.boolean().optional().openapi({default:!1,description:"AuthHero extension. Whether an authenticated confidential client may pass the end user's IP address in the `auth0-forwarded-for` header when minting, so device binding compares against the browser rather than the client's backend. Ignored for requests without client authentication."})}).passthrough(),eN=f.z.object({client_id:f.z.string().describe(`The client that minted the session_transfer_token`),family_id:f.z.string().describe(`Rotation family of the refresh token the session_transfer_token was minted from. The family id is stable across rotation, the row id is not.`),cascade_revocation:f.z.boolean().describe(`Whether this session ends when the parent refresh token family is no longer active`)}),tN=f.z.object({client_id:f.z.string().optional().openapi({description:`ID of this client. Generated server-side if omitted (Auth0 behavior).`}),name:f.z.string().min(1).openapi({description:`Name of this client (min length: 1 character, does not allow < or >).`}),description:f.z.string().max(140).optional().openapi({description:`Free text description of this client (max length: 140 characters).`}),global:f.z.boolean().default(!1).openapi({description:`Whether this is your global 'All Applications' client representing legacy tenant settings (true) or a regular client (false).`}),client_secret:JM().default(()=>XM()).optional().openapi({description:`Client secret (which you must not make public).`}),app_type:f.z.enum([`native`,`spa`,`regular_web`,`non_interactive`,`resource_server`,`express_configuration`,`rms`,`box`,`cloudbees`,`concur`,`dropbox`,`mscrm`,`echosign`,`egnyte`,`newrelic`,`office365`,`salesforce`,`sentry`,`sharepoint`,`slack`,`springcm`,`zendesk`,`zoom`,`sso_integration`,`oag`]).default(`regular_web`).optional().openapi({description:`The type of application this client represents`}),logo_uri:f.z.string().url().optional().openapi({description:`URL of the logo to display for this client. Recommended size is 150x150 pixels.`}),is_first_party:f.z.boolean().default(!0).openapi({description:`Whether this client is a first party client (true) or not (false). First-party clients skip the consent screen; third-party clients require explicit user consent for non-basic scopes.`}),oidc_conformant:f.z.boolean().default(!0).openapi({description:`Whether this client conforms to strict OIDC specifications (true) or uses legacy features (false).`}),auth0_conformant:f.z.boolean().default(!0).openapi({description:`Whether this client follows Auth0-compatible behavior (true) or strict OIDC behavior (false). When true, profile/email claims are included in the ID token when scopes are requested. When false, these claims are only available from the userinfo endpoint (strict OIDC 5.4 compliance).`}),callbacks:f.z.array(f.z.string()).default([]).optional().openapi({description:`Comma-separated list of URLs whitelisted for Auth0 to use as a callback to the client after authentication.`}),allowed_origins:f.z.array(f.z.string()).default([]).optional().openapi({description:`Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level (e.g., https://*.contoso.com). Query strings and hash information are not taken into account when validating these URLs.`}),web_origins:f.z.array(f.z.string()).default([]).optional().openapi({description:`Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode.`}),client_aliases:f.z.array(f.z.string()).default([]).optional().openapi({description:`List of audiences/realms for SAML protocol. Used by the wsfed addon.`}),allowed_clients:f.z.array(f.z.string()).default([]).optional().openapi({description:`List of allow clients and API ids that are allowed to make delegation requests. Empty means all all your clients are allowed.`}),connections:f.z.array(f.z.string()).default([]).optional().openapi({description:`List of connection IDs enabled for this client. The order determines the display order on the login page.`}),allowed_logout_urls:f.z.array(f.z.string()).default([]).optional().openapi({description:`Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains.`}),session_transfer:$M.optional().openapi({description:`Session transfer (Auth0 Native to Web SSO) configuration: lets this client mint a session_transfer_token from a refresh token and/or accept one at /authorize.`}),oidc_logout:f.z.object({backchannel_logout_urls:f.z.array(f.z.string()).optional().openapi({description:`URLs that receive a signed OIDC Back-Channel Logout 1.0 logout token when a session this client participated in ends.`}),backchannel_logout_initiators:f.z.object({mode:f.z.enum([`all`,`custom`]).optional().openapi({description:`Whether all session-end events initiate a backchannel logout (all) or only the selected_initiators (custom).`}),selected_initiators:f.z.array(f.z.string()).optional().openapi({description:`Logout initiators that trigger a backchannel logout when mode is custom (e.g. rp-logout, idp-logout, password-changed).`})}).passthrough().optional().openapi({description:`Controls which session-end events initiate backchannel logout notifications. Stored for Auth0 compatibility; not yet enforced — all initiators currently notify.`})}).passthrough().default({}).optional().openapi({description:`Configuration for OIDC backchannel logout`}),grant_types:f.z.array(f.z.string()).default([]).optional().openapi({description:`List of grant types supported for this application. Can include authorization_code, implicit, refresh_token, client_credentials, password, http://auth0.com/oauth/grant-type/password-realm, http://auth0.com/oauth/grant-type/mfa-oob, http://auth0.com/oauth/grant-type/mfa-otp, http://auth0.com/oauth/grant-type/mfa-recovery-code, urn:openid:params:grant-type:ciba, and urn:ietf:params:oauth:grant-type:device_code.`}),jwt_configuration:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Configuration related to JWTs for the client.`}),signing_keys:f.z.array(f.z.record(f.z.string(),f.z.any())).default([]).optional().openapi({description:`Signing certificates associated with this client.`}),encryption_key:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Encryption used for WsFed responses with this client.`}),sso:f.z.boolean().default(!1).openapi({description:`Applies only to SSO clients and determines whether Auth0 will handle Single Sign On (true) or whether the Identity Provider will (false).`}),sso_disabled:f.z.boolean().default(!1).openapi({description:`Whether Single Sign On is disabled for this client. When true, existing SSO sessions will not be reused and users must authenticate every time.`}),cross_origin_authentication:f.z.boolean().default(!1).openapi({description:`Whether this client can be used to make cross-origin authentication requests (true) or it is not allowed to make such requests (false).`}),cross_origin_loc:f.z.string().url().optional().openapi({description:`URL of the location in your site where the cross origin verification takes place for the cross-origin auth flow when performing Auth in your own domain instead of Auth0 hosted login page.`}),custom_login_page_on:f.z.boolean().default(!1).openapi({description:`Whether a custom login page is to be used (true) or the default provided login page (false).`}),custom_login_page:f.z.string().optional().openapi({description:`The content (HTML, CSS, JS) of the custom login page.`}),custom_login_page_preview:f.z.string().optional().openapi({description:`The content (HTML, CSS, JS) of the custom login page. (Used on Previews)`}),form_template:f.z.string().optional().openapi({description:`HTML form template to be used for WS-Federation.`}),addons:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Addons enabled for this client and their associated configurations.`}),token_endpoint_auth_method:f.z.enum([`none`,`client_secret_post`,`client_secret_basic`,`client_secret_jwt`,`private_key_jwt`]).default(`client_secret_basic`).optional().openapi({description:"Defines the requested authentication method for the token endpoint. `none` (public client), `client_secret_post` / `client_secret_basic` (HTTP POST / Basic), `client_secret_jwt` (RFC 7523 HMAC assertion using client_secret), or `private_key_jwt` (RFC 7523 asymmetric assertion verified against the client's `jwks` / `jwks_uri`)."}),client_metadata:f.z.record(f.z.string(),f.z.string().max(255)).default({}).optional().openapi({description:`Metadata associated with the client, in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. Field names (max 255 chars) are alphanumeric and may only include the following special characters: :,-+=_*?"/()<>@ [Tab][Space]`}),hide_sign_up_disabled_error:f.z.boolean().default(!1).optional().openapi({description:"Enumeration-safe variant of the connection-level `disable_signup` flag. When a signup is blocked by the password connection and this is true, the identifier screen does not reveal that an email is unknown — it advances to the OTP/password challenge as if the account existed and fails at credential check. Mitigates email enumeration at the cost of UX: users without an account see a generic credential failure instead of an explicit signup-disabled message."}),mobile:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Additional configuration for native mobile apps.`}),initiate_login_uri:f.z.string().url().optional().openapi({description:`Initiate login uri, must be https`}),native_social_login:f.z.record(f.z.string(),f.z.any()).default({}).optional(),refresh_token:f.z.object({rotation_type:f.z.enum([`rotating`,`non-rotating`]).optional().openapi({description:`Whether refresh tokens for this client are rotated on every exchange (Auth0 'rotating' behavior) or kept stable (legacy non-rotating). Defaults to 'non-rotating' when unset.`}),leeway:f.z.number().int().min(0).max(600).optional().openapi({description:`Seconds after a parent token's first rotation during which presenting it again still mints a fresh sibling child instead of triggering reuse-detection. Defaults to 30s when unset.`}),expiration_type:f.z.enum([`expiring`,`non-expiring`]).optional().openapi({description:`Whether refresh tokens for this client expire at all. 'non-expiring' overrides both the absolute and the idle lifetime.`}),token_lifetime:f.z.number().int().min(0).optional().openapi({description:"Refresh-token absolute lifetime in seconds. Falls back to the tenant's `session_lifetime` when unset."}),infinite_token_lifetime:f.z.boolean().optional().openapi({description:"When true, refresh tokens have no absolute expiry (overrides `token_lifetime`)."}),idle_token_lifetime:f.z.number().int().min(0).optional().openapi({description:"Refresh-token idle (sliding) lifetime in seconds, refreshed on every exchange. Falls back to the tenant's `idle_session_lifetime` when unset."}),infinite_idle_token_lifetime:f.z.boolean().optional().openapi({description:"When true, refresh tokens have no idle expiry (overrides `idle_token_lifetime`)."})}).default({}).optional().openapi({description:`Refresh token configuration`}),default_organization:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Defines the default Organization ID and flows`}),organization_usage:f.z.enum([`deny`,`allow`,`require`]).default(`deny`).optional().openapi({description:`Defines how to proceed during an authentication transaction with regards an organization. Can be deny (default), allow or require.`}),organization_require_behavior:f.z.enum([`no_prompt`,`pre_login_prompt`,`post_login_prompt`]).default(`no_prompt`).optional().openapi({description:`Defines how to proceed during an authentication transaction when client.organization_usage: 'require'. Can be no_prompt (default), pre_login_prompt or post_login_prompt. post_login_prompt requires oidc_conformant: true.`}),client_authentication_methods:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Defines client authentication methods.`}),require_pushed_authorization_requests:f.z.boolean().default(!1).openapi({description:`Makes the use of Pushed Authorization Requests mandatory for this client`}),require_proof_of_possession:f.z.boolean().default(!1).openapi({description:`Makes the use of Proof-of-Possession mandatory for this client`}),signed_request_object:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`JWT-secured Authorization Requests (JAR) settings.`}),compliance_level:f.z.enum([`none`,`fapi1_adv_pkj_par`,`fapi1_adv_mtls_par`,`fapi2_sp_pkj_mtls`,`fapi2_sp_mtls_mtls`]).optional().openapi({description:`Defines the compliance level for this client, which may restrict it's capabilities`}),par_request_expiry:f.z.number().optional().openapi({description:`Specifies how long, in seconds, a Pushed Authorization Request URI remains valid`}),token_quota:f.z.record(f.z.string(),f.z.any()).default({}).optional(),owner_user_id:f.z.string().optional().openapi({description:`User ID of the consenting user when this client was created via IAT-gated Dynamic Client Registration. NULL for clients created via the Management API or open DCR.`}),registration_type:f.z.enum([`manual`,`open_dcr`,`iat_dcr`]).optional().openapi({description:"Provenance of this client. `manual` = Management API; `open_dcr` = RFC 7591 without IAT; `iat_dcr` = RFC 7591 with an Initial Access Token."}),registration_metadata:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:"Arbitrary metadata captured at Dynamic Client Registration time that isn't a first-class client field (e.g. integration_type, domain). Also stores `iat_constraints` for clients created via IAT so RFC 7592 PUT can enforce field immutability."}),token_exchange:f.z.object({allow_any_profile_of_type:f.z.array(f.z.literal(`custom_authentication`)).optional()}).optional().openapi({description:'Custom Token Exchange settings. Set `allow_any_profile_of_type` to `["custom_authentication"]` to let this client exchange subject tokens through the tenant\'s token exchange profiles.'}),user_linking_mode:f.z.enum([`builtin`,`off`]).optional().openapi({description:"Per-client override for the built-in email-based user-linking path. `builtin` runs the legacy in-process linking at user creation/email update. `off` disables the legacy path; linking only happens if the tenant has enabled the `account-linking` template hook. When unset, the service-level `userLinkingMode` default applies."})});f.z.object({created_at:f.z.string(),updated_at:f.z.string()}).extend(tN.shape).extend({client_id:f.z.string()});var nN=f.z.object({client_id:f.z.string().min(1).openapi({description:`ID of the client.`}),audience:f.z.string().min(1).openapi({description:`The audience (API identifier) of this client grant.`}),scope:f.z.array(f.z.string()).optional().openapi({description:`Scopes allowed for this client grant.`}),organization_usage:f.z.enum([`deny`,`allow`,`require`]).optional().openapi({description:`Defines whether organizations can be used with client credentials exchanges for this grant.`}),allow_any_organization:f.z.boolean().optional().openapi({description:`If enabled, any organization can be used with this grant. If disabled (default), the grant must be explicitly assigned to the desired organizations.`}),is_system:f.z.boolean().optional().openapi({description:`If enabled, this grant is a special grant created by Auth0. It cannot be modified or deleted directly.`}),subject_type:f.z.enum([`client`,`user`]).optional().openapi({description:`The type of application access the client grant allows. Use of this field is subject to the applicable Free Trial terms in Okta's Master Subscription Agreement.`}),authorization_details_types:f.z.array(f.z.string()).optional().openapi({description:`Types of authorization_details allowed for this client grant. Use of this field is subject to the applicable Free Trial terms in Okta's Master Subscription Agreement.`})}),rN=f.z.object({id:f.z.string().openapi({description:`ID of the client grant.`})}).extend(nN.shape).extend({created_at:f.z.string().optional(),updated_at:f.z.string().optional()});f.z.array(rN);var iN=f.z.enum([`iat`,`rat`]),aN=f.z.enum([`invite`,`edit_link`,`registration`,`connect`]),oN=f.z.object({id:f.z.string(),token_hash:f.z.string(),type:iN,client_id:f.z.string().optional(),sub:f.z.string().optional(),constraints:f.z.record(f.z.string(),f.z.unknown()).optional(),single_use:f.z.boolean().default(!1),expires_at:f.z.string().optional(),name:f.z.string().optional(),created_by:f.z.string().optional(),source:aN.optional()});f.z.object({created_at:f.z.string(),used_at:f.z.string().optional(),revoked_at:f.z.string().optional()}).extend(oN.shape);var sN=f.z.object({x:f.z.number(),y:f.z.number()}),cN=function(e){return e.RICH_TEXT=`RICH_TEXT`,e.NEXT_BUTTON=`NEXT_BUTTON`,e.BACK_BUTTON=`BACK_BUTTON`,e.SUBMIT_BUTTON=`SUBMIT_BUTTON`,e.DIVIDER=`DIVIDER`,e.TEXT=`TEXT`,e.EMAIL=`EMAIL`,e.PASSWORD=`PASSWORD`,e.NUMBER=`NUMBER`,e.PHONE=`PHONE`,e.DATE=`DATE`,e.CHECKBOX=`CHECKBOX`,e.RADIO=`RADIO`,e.SELECT=`SELECT`,e.HIDDEN=`HIDDEN`,e.LEGAL=`LEGAL`,e}({}),lN=function(e){return e.BLOCK=`BLOCK`,e.FIELD=`FIELD`,e}({}),uN=f.z.object({id:f.z.string(),category:f.z.nativeEnum(lN),type:f.z.nativeEnum(cN)}),dN=uN.extend({category:f.z.literal(`BLOCK`),type:f.z.literal(`RICH_TEXT`),config:f.z.object({content:f.z.string()}).passthrough()}),fN=uN.extend({category:f.z.literal(`BLOCK`),type:f.z.union([f.z.literal(`NEXT_BUTTON`),f.z.literal(`BACK_BUTTON`),f.z.literal(`SUBMIT_BUTTON`)]),config:f.z.object({text:f.z.string()}).passthrough()}),pN=uN.extend({category:f.z.literal(`FIELD`),type:f.z.literal(`LEGAL`),required:f.z.boolean().optional(),sensitive:f.z.boolean().optional(),config:f.z.object({text:f.z.string()}).passthrough()}),mN=uN.extend({category:f.z.literal(`FIELD`),type:f.z.union([f.z.literal(`TEXT`),f.z.literal(`EMAIL`),f.z.literal(`PASSWORD`),f.z.literal(`NUMBER`),f.z.literal(`PHONE`),f.z.literal(`DATE`),f.z.literal(`CHECKBOX`),f.z.literal(`RADIO`),f.z.literal(`SELECT`),f.z.literal(`HIDDEN`)]),required:f.z.boolean().optional(),sensitive:f.z.boolean().optional(),config:f.z.object({label:f.z.string().optional(),placeholder:f.z.string().optional()}).passthrough()}),hN=f.z.object({id:f.z.string(),category:f.z.string(),type:f.z.string()}).passthrough(),gN=f.z.union([dN,fN,pN,mN,hN]),_N=f.z.object({id:f.z.string(),type:f.z.literal(`STEP`),coordinates:sN,alias:f.z.string().optional(),config:f.z.object({components:f.z.array(gN),next_node:f.z.string()}).passthrough()}),vN=f.z.object({id:f.z.string(),type:f.z.literal(`FLOW`),coordinates:sN,alias:f.z.string().optional(),config:f.z.object({flow_id:f.z.string(),next_node:f.z.string()})}),yN=f.z.object({id:f.z.string(),type:f.z.literal(`ACTION`),coordinates:sN,alias:f.z.string().optional(),config:f.z.object({action_type:f.z.enum([`REDIRECT`]).openapi({description:`The type of action to perform`}),target:f.z.enum([`change-email`,`account`,`custom`]).openapi({description:`The predefined target to redirect to`}),custom_url:f.z.string().optional().openapi({description:`Custom URL when target is 'custom'`}),next_node:f.z.string().openapi({description:`The next node to navigate to after action (for non-redirect actions)`})}).passthrough()}),bN=f.z.object({id:f.z.string(),type:f.z.string(),coordinates:sN}).passthrough(),xN=f.z.union([_N,vN,yN,bN]),SN=f.z.object({next_node:f.z.string(),coordinates:sN}).passthrough(),CN=f.z.object({resume_flow:f.z.boolean().optional(),coordinates:sN}).passthrough();f.z.object({id:f.z.string(),name:f.z.string(),languages:f.z.object({primary:f.z.string()}).passthrough(),nodes:f.z.array(xN),start:SN,ending:CN,created_at:f.z.string(),updated_at:f.z.string(),links:f.z.object({sdkSrc:f.z.string().optional(),sdk_src:f.z.string().optional()}).passthrough()}).passthrough().omit({id:!0,created_at:!0,updated_at:!0});var wN=function(e){return e.TOKEN=`token`,e.ID_TOKEN=`id_token`,e.TOKEN_ID_TOKEN=`id_token token`,e.CODE=`code`,e.CODE_ID_TOKEN=`code id_token`,e.CODE_TOKEN=`code token`,e.CODE_ID_TOKEN_TOKEN=`code id_token token`,e}({}),TN=function(e){return e.QUERY=`query`,e.FRAGMENT=`fragment`,e.FORM_POST=`form_post`,e.WEB_MESSAGE=`web_message`,e.SAML_POST=`saml_post`,e}({}),EN=function(e){return e.S256=`S256`,e.Plain=`plain`,e}({}),DN=f.z.union([f.z.null(),f.z.object({essential:f.z.boolean().optional(),value:f.z.unknown().optional(),values:f.z.array(f.z.unknown()).optional()})]).nullable(),ON=f.z.object({userinfo:f.z.record(f.z.string(),DN).optional(),id_token:f.z.record(f.z.string(),DN).optional()}),kN=f.z.object({client_id:f.z.string(),act_as:f.z.string().optional(),response_type:f.z.nativeEnum(wN).optional(),response_mode:f.z.nativeEnum(TN).optional(),redirect_uri:f.z.string().optional(),audience:f.z.string().optional(),organization:f.z.string().optional(),state:f.z.string().optional(),nonce:f.z.string().optional(),scope:f.z.string().optional(),prompt:f.z.string().optional(),code_challenge_method:f.z.nativeEnum(EN).optional(),code_challenge:f.z.string().optional(),username:f.z.string().optional(),ui_locales:f.z.string().optional(),max_age:f.z.number().optional(),acr_values:f.z.string().optional(),claims:ON.optional(),connection:f.z.string().optional(),vendor_id:f.z.string().optional()});f.z.object({..._M,colors:f.z.object({primary:f.z.string(),page_background:f.z.union([f.z.string(),f.z.object({type:f.z.string().optional(),start:f.z.string().optional(),end:f.z.string().optional(),angle_deg:f.z.number().optional()})]).optional()}).optional(),logo_url:f.z.string().optional(),favicon_url:f.z.string().optional(),favicon_url_dark:f.z.string().optional(),powered_by_logo_url:f.z.string().optional(),font:f.z.object({url:f.z.string()}).optional(),dark_mode:f.z.enum([`dark`,`light`,`auto`]).optional(),dark_mode_toggle:f.z.boolean().optional(),terms_url:f.z.string().optional(),privacy_url:f.z.string().optional()});var AN=f.z.enum([`password_reset`,`email_verification`,`otp`,`mfa_otp`,`authorization_code`,`oauth2_state`,`ticket`,`client_assertion_jti`,`subject_token_jti`,`session_transfer_token`,`mfa_remember_browser`]);f.z.object({code_id:f.z.string().openapi({description:`The code that will be used in for instance an email verification flow`}),login_id:f.z.string().optional().openapi({description:`The id of the login session that the code is connected to`}),connection_id:f.z.string().optional().openapi({description:`The connection that the code is connected to`}),code_type:AN,code_verifier:f.z.string().optional().openapi({description:`The code verifier used in PKCE in outbound flows`}),code_challenge:f.z.string().optional().openapi({description:`The code challenge used in PKCE in outbound flows`}),code_challenge_method:f.z.enum([`plain`,`S256`]).optional().openapi({description:`The code challenge method used in PKCE in outbound flows`}),redirect_uri:f.z.string().optional().openapi({description:`The redirect URI associated with the code`}),otp:f.z.string().optional().openapi({description:`The one-time password value for OTP-based flows`}),nonce:f.z.string().optional().openapi({description:`The nonce value used for security in OIDC flows`}),state:f.z.string().optional().openapi({description:`The state parameter used for CSRF protection in OAuth flows`}),expires_at:f.z.string(),used_at:f.z.string().optional(),user_id:f.z.string().optional()}).extend({created_at:f.z.string()}),f.z.object({device_code_hash:f.z.string(),user_code_hash:f.z.string(),client_id:f.z.string(),scope:f.z.string().optional(),audience:f.z.string().optional(),status:f.z.enum([`pending`,`approved`,`denied`,`consumed`]),login_id:f.z.string().optional(),expires_at:f.z.string(),created_at:f.z.string(),last_polled_at:f.z.string().optional(),interval:f.z.number().int().positive(),version:f.z.number().int().nonnegative()});var jN=f.z.object({kid:f.z.string().optional(),team_id:f.z.string().optional(),realms:f.z.string().optional(),authentication_method:f.z.string().optional(),client_id:f.z.string().optional(),client_secret:JM().optional(),app_secret:JM().optional(),scope:f.z.string().optional(),client_secret_hint:f.z.string().optional(),app_secret_hint:f.z.string().optional(),twilio_token_hint:f.z.string().optional(),authorization_endpoint:f.z.string().optional(),token_endpoint:f.z.string().optional(),userinfo_endpoint:f.z.string().optional(),jwks_uri:f.z.string().optional(),discovery_url:f.z.string().optional(),issuer:f.z.string().optional(),token_endpoint_auth_method:f.z.enum([`client_secret_basic`,`client_secret_post`]).optional(),provider:f.z.string().optional(),from:f.z.string().optional(),twilio_sid:JM().optional(),twilio_token:JM().optional(),icon_url:f.z.string().optional(),domain_aliases:f.z.array(f.z.string()).optional(),callback_url:f.z.string().url().optional(),passwordPolicy:f.z.enum([`none`,`low`,`fair`,`good`,`excellent`]).optional(),password_complexity_options:f.z.object({min_length:f.z.number().optional()}).optional(),password_history:f.z.object({enable:f.z.boolean().optional(),size:f.z.number().optional()}).optional(),password_no_personal_info:f.z.object({enable:f.z.boolean().optional()}).optional(),password_dictionary:f.z.object({enable:f.z.boolean().optional(),dictionary:f.z.array(f.z.string()).optional()}).optional(),disable_signup:f.z.boolean().optional(),brute_force_protection:f.z.boolean().optional(),import_mode:f.z.boolean().optional(),configuration:f.z.object({token_endpoint:f.z.string().optional(),userinfo_endpoint:f.z.string().optional(),client_id:f.z.string().optional(),client_secret:JM().optional(),client_secret_hint:f.z.string().optional(),realm:f.z.string().optional()}).optional(),attributes:f.z.object({email:f.z.object({identifier:f.z.object({active:f.z.boolean().optional()}).optional(),signup:f.z.object({status:f.z.enum([`required`,`optional`,`disabled`]).optional(),verification:f.z.object({active:f.z.boolean().optional()}).optional()}).optional(),validation:f.z.object({allowed:f.z.boolean().optional()}).optional(),unique:f.z.boolean().optional(),profile_required:f.z.boolean().optional(),verification_method:f.z.enum([`link`,`code`]).optional()}).optional(),username:f.z.object({identifier:f.z.object({active:f.z.boolean().optional()}).optional(),signup:f.z.object({status:f.z.enum([`required`,`optional`,`disabled`]).optional()}).optional(),validation:f.z.object({max_length:f.z.number().optional(),min_length:f.z.number().optional(),allowed_types:f.z.object({email:f.z.boolean().optional(),phone_number:f.z.boolean().optional()}).optional()}).optional(),profile_required:f.z.boolean().optional()}).optional(),phone_number:f.z.object({identifier:f.z.object({active:f.z.boolean().optional()}).optional(),signup:f.z.object({status:f.z.enum([`required`,`optional`,`disabled`]).optional()}).optional()}).optional()}).optional(),authentication_methods:f.z.object({password:f.z.object({enabled:f.z.boolean().optional()}).optional(),passkey:f.z.object({enabled:f.z.boolean().optional()}).optional()}).optional(),passkey_options:f.z.object({challenge_ui:f.z.enum([`both`,`autofill`,`button`]).optional(),local_enrollment_enabled:f.z.boolean().optional(),progressive_enrollment_enabled:f.z.boolean().optional()}).optional(),requires_username:f.z.boolean().optional(),validation:f.z.object({username:f.z.object({min:f.z.number().optional(),max:f.z.number().optional()}).optional()}).optional(),allow_action_users:f.z.boolean().optional(),set_user_root_attributes:f.z.enum([`on_each_login`,`on_first_login`,`never_on_login`]).optional(),signInEndpoint:f.z.string().optional(),signOutEndpoint:f.z.string().optional(),signingCert:f.z.string().optional(),signingCerts:f.z.array(f.z.string()).optional(),metadataUrl:f.z.string().optional(),metadataXml:f.z.string().optional(),signSAMLRequest:f.z.boolean().optional(),signatureAlgorithm:f.z.enum([`rsa-sha256`,`rsa-sha1`]).optional(),digestAlgorithm:f.z.enum([`sha256`,`sha1`]).optional(),protocolBinding:f.z.enum([`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect`,`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`]).optional(),user_id_attribute:f.z.string().optional(),fieldsMap:f.z.record(f.z.string(),f.z.union([f.z.string(),f.z.array(f.z.string())])).optional(),entityId:f.z.string().optional()});function MN(e){if(e!==null){if(Array.isArray(e))return e.filter(e=>e!==null).map(MN);if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))r!==null&&(t[n]=MN(r));return t}return e}}var NN=f.z.object({id:f.z.string().optional(),name:f.z.string(),display_name:f.z.string().optional(),strategy:f.z.string(),options:f.z.preprocess(e=>e===null?{}:MN(e),jN).default({}),enabled_clients:f.z.array(f.z.string()).default([]).optional(),response_type:f.z.nativeEnum(wN).optional(),response_mode:f.z.nativeEnum(TN).optional(),is_domain_connection:f.z.boolean().optional(),show_as_button:f.z.boolean().optional(),metadata:f.z.record(f.z.string(),f.z.any()).optional(),is_system:f.z.boolean().optional(),..._M});f.z.object({id:f.z.string(),created_at:f.z.string().transform(e=>e===null?``:e),updated_at:f.z.string().transform(e=>e===null?``:e)}).extend(NN.shape);var PN=f.z.object({domain:f.z.string(),status:f.z.enum([`pending`,`verified`]),verified_at:f.z.string().optional()});f.z.object({profile_id:f.z.string().optional(),domains:f.z.array(PN).default([])});var FN=f.z.object({domain:f.z.string(),custom_domain_id:f.z.string().optional(),type:f.z.enum([`auth0_managed_certs`,`self_managed_certs`]),verification_method:f.z.enum([`txt`]).optional(),tls_policy:f.z.enum([`recommended`]).optional(),custom_client_ip_header:f.z.enum([`true-client-ip`,`cf-connecting-ip`,`x-forwarded-for`,`x-azure-clientip`,`null`]).optional(),domain_metadata:f.z.record(f.z.string(),f.z.string().max(255)).optional()}),IN=f.z.discriminatedUnion(`name`,[f.z.object({name:f.z.literal(`txt`),record:f.z.string(),domain:f.z.string()}),f.z.object({name:f.z.literal(`http`),http_body:f.z.string(),http_url:f.z.string()})]),LN=FN.extend({custom_domain_id:f.z.string(),primary:f.z.boolean(),status:f.z.enum([`disabled`,`pending`,`pending_verification`,`ready`]),origin_domain_name:f.z.string().optional(),verification:f.z.object({methods:f.z.array(IN)}).optional(),tls_policy:f.z.string().optional()});FN.pick({tls_policy:!0,custom_client_ip_header:!0,domain_metadata:!0}).strict(),LN.extend({tenant_id:f.z.string()}),f.z.object({certificate:f.z.string().regex(/^-----BEGIN CERTIFICATE-----[\s\S]+-----END CERTIFICATE-----\s*$/,`must be PEM-encoded; include the full certificate chain in leaf-first order`),private_key:f.z.string().regex(/-----BEGIN (RSA |EC |ENCRYPTED )?PRIVATE KEY-----[\s\S]+-----END \1PRIVATE KEY-----\s*$/,`must be a PEM-encoded private key`)});var RN=f.z.object({id:f.z.string(),order:f.z.number().optional(),visible:f.z.boolean().optional().default(!0)}),zN=RN.extend({category:f.z.literal(`BLOCK`).optional()}),BN=zN.extend({type:f.z.literal(`DIVIDER`),config:f.z.object({text:f.z.string().optional()}).optional()}),VN=zN.extend({type:f.z.literal(`HTML`),config:f.z.object({content:f.z.string().optional()}).optional()}),HN=zN.extend({type:f.z.literal(`IMAGE`),config:f.z.object({src:f.z.string().optional(),alt:f.z.string().optional(),width:f.z.number().optional(),height:f.z.number().optional()}).optional()}),UN=zN.extend({type:f.z.literal(`JUMP_BUTTON`),config:f.z.object({text:f.z.string().optional(),target_step:f.z.string().optional()})}),WN=zN.extend({type:f.z.literal(`RESEND_BUTTON`),config:f.z.object({text:f.z.string().optional(),resend_action:f.z.string().optional()})}),GN=zN.extend({type:f.z.literal(`NEXT_BUTTON`),config:f.z.object({text:f.z.string().optional(),variant:f.z.enum([`primary`,`secondary`]).optional(),skip_validation:f.z.boolean().optional()})}),KN=zN.extend({type:f.z.literal(`PREVIOUS_BUTTON`),config:f.z.object({text:f.z.string().optional()})}),qN=zN.extend({type:f.z.literal(`RICH_TEXT`),config:f.z.object({content:f.z.string().optional()}).optional()}),JN=RN.extend({category:f.z.literal(`WIDGET`).optional(),label:f.z.string().min(1).optional(),hint:f.z.string().min(1).max(500).optional(),required:f.z.boolean().optional(),sensitive:f.z.boolean().optional()}),YN=JN.extend({type:f.z.literal(`AUTH0_VERIFIABLE_CREDENTIALS`),config:f.z.object({credential_type:f.z.string().optional()})}),XN=JN.extend({type:f.z.literal(`GMAPS_ADDRESS`),config:f.z.object({api_key:f.z.string().optional()})}),ZN=JN.extend({type:f.z.literal(`RECAPTCHA`),config:f.z.object({site_key:f.z.string().optional()})}),QN=RN.extend({category:f.z.literal(`FIELD`).optional(),label:f.z.string().min(1).optional(),hint:f.z.string().min(1).max(500).optional(),messages:f.z.array(f.z.object({id:f.z.number().optional(),text:f.z.string(),type:f.z.enum([`info`,`error`,`success`,`warning`])})).optional(),required:f.z.boolean().optional(),sensitive:f.z.boolean().optional()}),$N=QN.extend({type:f.z.literal(`BOOLEAN`),config:f.z.object({default_value:f.z.boolean().optional()}).optional()}),eP=QN.extend({type:f.z.literal(`CARDS`),config:f.z.object({options:f.z.array(f.z.object({value:f.z.string(),label:f.z.string(),description:f.z.string().optional(),image:f.z.string().optional()})).optional(),multi_select:f.z.boolean().optional()}).optional()}),tP=QN.extend({type:f.z.literal(`CHOICE`),config:f.z.object({options:f.z.array(f.z.object({value:f.z.string(),label:f.z.string()})).optional(),display:f.z.enum([`radio`,`checkbox`]).optional(),multiple:f.z.boolean().optional(),default_value:f.z.union([f.z.string(),f.z.array(f.z.string())]).optional()}).optional()}),nP=QN.extend({type:f.z.literal(`CODE`),config:f.z.object({length:f.z.number().int().positive().max(100).optional(),mode:f.z.enum([`numeric`,`alphanumeric`]).optional(),auto_submit:f.z.boolean().optional(),group_size:f.z.number().int().min(0).max(100).optional(),separator:f.z.string().optional(),placeholder:f.z.string().optional(),default_value:f.z.string().optional()}).refine(e=>e.group_size===void 0||e.length===void 0||e.group_size<=e.length,{message:`group_size cannot exceed length`,path:[`group_size`]}).refine(e=>e.default_value===void 0||e.length===void 0||e.default_value.length<=e.length,{message:`default_value is longer than the configured length`,path:[`default_value`]}).optional()}),rP=QN.extend({type:f.z.literal(`CUSTOM`),config:f.z.object({component:f.z.string().optional(),props:f.z.record(f.z.string(),f.z.any()).optional(),schema:f.z.record(f.z.string(),f.z.any()).optional(),code:f.z.string().optional()})}),iP=QN.extend({type:f.z.literal(`DATE`),config:f.z.object({format:f.z.string().optional(),min:f.z.string().optional(),max:f.z.string().optional(),default_value:f.z.string().optional()}).optional()}),aP=QN.extend({type:f.z.literal(`DROPDOWN`),config:f.z.object({options:f.z.array(f.z.object({value:f.z.string(),label:f.z.string()})).optional(),placeholder:f.z.string().optional(),searchable:f.z.boolean().optional(),multiple:f.z.boolean().optional(),default_value:f.z.union([f.z.string(),f.z.array(f.z.string())]).optional()}).optional()}),oP=QN.extend({type:f.z.literal(`EMAIL`),config:f.z.object({placeholder:f.z.string().optional(),default_value:f.z.string().optional(),last_used:f.z.boolean().optional(),last_used_label:f.z.string().optional()}).optional()}),sP=QN.extend({type:f.z.literal(`FILE`),config:f.z.object({accept:f.z.string().optional(),max_size:f.z.number().optional(),multiple:f.z.boolean().optional()}).optional()}),cP=QN.extend({type:f.z.literal(`LEGAL`),config:f.z.object({text:f.z.string(),html:f.z.boolean().optional()}).optional()}),lP=QN.extend({type:f.z.literal(`NUMBER`),config:f.z.object({placeholder:f.z.string().optional(),min:f.z.number().optional(),max:f.z.number().optional(),step:f.z.number().optional(),default_value:f.z.string().optional()}).optional()}),uP=QN.extend({type:f.z.literal(`PASSWORD`),config:f.z.object({placeholder:f.z.string().optional(),min_length:f.z.number().optional(),show_toggle:f.z.boolean().optional(),forgot_password_link:f.z.string().optional(),default_value:f.z.string().optional(),autocomplete:f.z.enum([`current-password`,`new-password`]).optional()}).optional()}),dP=QN.extend({type:f.z.literal(`PAYMENT`),config:f.z.object({provider:f.z.string().optional(),currency:f.z.string().optional()}).optional()}),fP=QN.extend({type:f.z.literal(`SOCIAL`),config:f.z.object({providers:f.z.array(f.z.string()).optional(),provider_details:f.z.array(f.z.object({name:f.z.string(),strategy:f.z.string().optional(),display_name:f.z.string().optional(),short_name:f.z.string().optional(),icon_url:f.z.string().optional(),href:f.z.string().optional(),last_used:f.z.boolean().optional(),last_used_label:f.z.string().optional()})).optional()}).optional()}),pP=QN.extend({type:f.z.literal(`TEL`),config:f.z.object({placeholder:f.z.string().optional(),default_country:f.z.string().optional(),default_value:f.z.string().optional(),allow_email:f.z.boolean().optional()}).optional()}),mP=QN.extend({type:f.z.literal(`TEXT`),config:f.z.object({placeholder:f.z.string().optional(),multiline:f.z.boolean().optional(),max_length:f.z.number().optional(),default_value:f.z.string().optional(),autocomplete:f.z.string().optional(),input_mode:f.z.enum([`text`,`numeric`,`decimal`,`tel`,`email`,`url`,`search`]).optional(),last_used:f.z.boolean().optional(),last_used_label:f.z.string().optional()}).optional()}),hP=QN.extend({type:f.z.literal(`COUNTRY`),config:f.z.object({placeholder:f.z.string().optional(),default_value:f.z.string().optional()}).optional()}),gP=QN.extend({type:f.z.literal(`URL`),config:f.z.object({placeholder:f.z.string().optional(),default_value:f.z.string().optional()}).optional()}),_P=f.z.discriminatedUnion(`type`,[BN,VN,HN,UN,WN,GN,KN,qN]),vP=f.z.discriminatedUnion(`type`,[YN,XN,ZN]),yP=f.z.discriminatedUnion(`type`,[$N,eP,tP,nP,hP,rP,iP,aP,oP,sP,cP,lP,uP,dP,fP,pP,mP,gP]),bP=f.z.union([_P,vP,yP]);new Set([`BOOLEAN`,`CARDS`,`CHOICE`,`CODE`,`COUNTRY`,`DATE`,`DROPDOWN`,`EMAIL`,`LEGAL`,`NUMBER`,`PASSWORD`,`TEL`,`TEXT`,`URL`]),f.z.object({id:f.z.string(),type:f.z.literal(`submit`),label:f.z.string(),className:f.z.string().optional(),disabled:f.z.boolean().optional().default(!1),order:f.z.number().optional(),visible:f.z.boolean().optional().default(!0),customizations:f.z.record(f.z.string(),f.z.any()).optional()});var xP=f.z.object({x:f.z.number(),y:f.z.number()}),SP=f.z.object({id:f.z.string(),type:f.z.literal(`FLOW`),coordinates:xP,alias:f.z.string().min(1).max(150).optional(),config:f.z.object({flow_id:f.z.string().max(30),next_node:f.z.string().optional()})}),CP=f.z.object({id:f.z.string(),type:f.z.literal(`ROUTER`),coordinates:xP,alias:f.z.string().min(1).max(150),config:f.z.object({rules:f.z.array(f.z.object({id:f.z.string(),alias:f.z.string().min(1).max(150).optional(),condition:f.z.any(),next_node:f.z.string()})),fallback:f.z.string()})}),wP=f.z.object({id:f.z.string(),type:f.z.literal(`STEP`),coordinates:xP,alias:f.z.string().min(1).max(150).optional(),config:f.z.object({components:f.z.array(bP),next_node:f.z.string().optional()})}),TP=f.z.discriminatedUnion(`type`,[SP,CP,wP]),EP=f.z.object({name:f.z.string().openapi({description:`The name of the form`}),messages:f.z.object({errors:f.z.record(f.z.string(),f.z.any()).optional(),custom:f.z.record(f.z.string(),f.z.any()).optional()}).optional(),languages:f.z.object({primary:f.z.string().optional(),default:f.z.string().optional()}).optional(),translations:f.z.record(f.z.string(),f.z.any()).optional(),nodes:f.z.array(TP).optional(),start:f.z.object({hidden_fields:f.z.array(f.z.object({key:f.z.string(),value:f.z.string()})).optional(),next_node:f.z.string().optional(),coordinates:xP.optional()}).optional(),ending:f.z.object({redirection:f.z.object({delay:f.z.number().optional(),target:f.z.string().optional()}).optional(),after_submit:f.z.object({flow_id:f.z.string().optional()}).optional(),coordinates:xP.optional(),resume_flow:f.z.boolean().optional()}).optional(),style:f.z.object({css:f.z.string().optional()}).optional(),links:f.z.object({sdkSrc:f.z.string().optional(),sdk_src:f.z.string().optional()}).optional()}).openapi({description:`Schema for flow-based forms (matches Auth0 Forms structure)`});mM.extend(EP.shape).extend({id:f.z.string()});var DP=f.z.object({id:f.z.number().optional(),text:f.z.string(),type:f.z.enum([`info`,`error`,`success`,`warning`])}),OP=f.z.object({id:f.z.string().optional(),text:f.z.string(),href:f.z.string(),linkText:f.z.string().optional()}),kP=f.z.object({"form-content-start":f.z.string().optional(),"form-content-end":f.z.string().optional(),"form-footer-start":f.z.string().optional(),"form-footer-end":f.z.string().optional(),"secondary-actions-start":f.z.string().optional(),"secondary-actions-end":f.z.string().optional()}).strict();f.z.object({name:f.z.string().optional(),action:f.z.string(),method:f.z.enum([`POST`,`GET`]),title:f.z.string().optional(),description:f.z.string().optional(),components:f.z.array(bP),messages:f.z.array(DP).optional(),links:f.z.array(OP).optional(),partials:kP.optional(),footer:f.z.string().optional()});var AP=f.z.enum([`pre-user-registration`,`post-user-registration`,`post-user-login`,`post-user-update`,`validate-registration-username`,`pre-user-deletion`,`post-user-deletion`]),jP=f.z.enum([`post-user-login`]),MP=f.z.enum([`post-user-login`,`post-user-registration`,`post-user-update`,`credentials-exchange`]),NP=f.z.enum([`validate-registration-username`,`post-user-login`,`credentials-exchange`,`pre-user-registration`,`post-user-registration`,`pre-user-update`,`post-user-update`,`pre-user-deletion`,`post-user-deletion`,`pre-screen`,`custom-email-provider`,`custom-phone-provider`]),PP=f.z.enum([`post-user-login`]);AP.options,jP.options,MP.options,NP.options,PP.options;var FP=f.z.enum([`impersonate`]),IP=f.z.enum([`ensure-username`,`set-preferred-username`,`account-linking`]),LP={enabled:f.z.boolean().default(!1),synchronous:f.z.boolean().default(!1),priority:f.z.number().optional(),hook_id:f.z.string().optional(),metadata:f.z.record(f.z.string(),f.z.unknown()).optional(),..._M},RP=f.z.object({...LP,trigger_id:AP,url:f.z.string()}),zP=f.z.object({...LP,trigger_id:jP,form_id:f.z.string()}),BP=f.z.object({...LP,trigger_id:MP,template_id:IP}),VP=f.z.object({...LP,trigger_id:NP,code_id:f.z.string()}),HP=f.z.object({...LP,trigger_id:PP,page_id:FP,permission_required:f.z.string().optional()});f.z.union([RP,zP,BP,VP,HP]);var UP=f.z.object({...LP,trigger_id:AP}).extend(mM.shape).extend({hook_id:f.z.string(),url:f.z.string()}),WP=f.z.object({...LP,trigger_id:jP}).extend(mM.shape).extend({hook_id:f.z.string(),form_id:f.z.string()}),GP=f.z.object({...LP,trigger_id:MP}).extend(mM.shape).extend({hook_id:f.z.string(),template_id:IP}),KP=f.z.object({...LP,trigger_id:NP}).extend(mM.shape).extend({hook_id:f.z.string(),code_id:f.z.string()}),qP=f.z.object({...LP,trigger_id:PP}).extend(mM.shape).extend({hook_id:f.z.string(),page_id:FP,permission_required:f.z.string().optional()});f.z.union([UP,WP,GP,KP,qP]),f.z.object({code:f.z.string().max(1e5),secrets:f.z.record(f.z.string(),f.z.string()).optional()}).extend({id:f.z.string(),tenant_id:f.z.string()}).extend(mM.shape);var JP=f.z.object({name:f.z.string().optional()}),YP=f.z.object({email:f.z.string().optional()}),XP=f.z.object({id:f.z.string().optional(),organization_id:f.z.string().max(50),inviter:JP,invitee:YP,invitation_url:f.z.string().url(),client_id:f.z.string(),connection_id:f.z.string().optional(),app_metadata:f.z.record(f.z.string(),f.z.any()).default({}).optional(),user_metadata:f.z.record(f.z.string(),f.z.any()).default({}).optional(),ttl_sec:f.z.number().int().max(2592e3).default(604800).optional(),roles:f.z.array(f.z.string()).default([]).optional(),send_invitation_email:f.z.boolean().default(!0).optional()});f.z.object({id:f.z.string(),organization_id:f.z.string().max(50),created_at:f.z.string().datetime(),expires_at:f.z.string().datetime(),ticket_id:f.z.string().optional()}).extend(XP.omit({id:!0}).shape);var ZP=f.z.object({alg:f.z.enum([`RS256`,`RS384`,`RS512`,`ES256`,`ES384`,`ES512`,`HS256`,`HS384`,`HS512`]).optional(),kid:f.z.string().optional(),kty:f.z.enum([`RSA`,`EC`,`oct`]),use:f.z.enum([`sig`,`enc`]).optional(),n:f.z.string().optional(),e:f.z.string().optional(),crv:f.z.string().optional(),x:f.z.string().optional(),y:f.z.string().optional(),x5t:f.z.string().optional(),"x5t#S256":f.z.string().optional(),x5c:f.z.array(f.z.string()).optional()}).superRefine((e,t)=>{if(e.kty===`RSA`)for(let n of[`n`,`e`])e[n]||t.addIssue({code:f.z.ZodIssueCode.custom,path:[n],message:`RSA JWK is missing required member '${n}'`});else if(e.kty===`EC`)for(let n of[`crv`,`x`,`y`])e[n]||t.addIssue({code:f.z.ZodIssueCode.custom,path:[n],message:`EC JWK is missing required member '${n}'`})}),QP=f.z.object({keys:f.z.array(ZP)});f.z.object({issuer:f.z.string(),authorization_endpoint:f.z.string(),token_endpoint:f.z.string(),device_authorization_endpoint:f.z.string().optional(),userinfo_endpoint:f.z.string(),jwks_uri:f.z.string(),registration_endpoint:f.z.string().optional(),revocation_endpoint:f.z.string(),end_session_endpoint:f.z.string().optional(),scopes_supported:f.z.array(f.z.string()),response_types_supported:f.z.array(f.z.string()),grant_types_supported:f.z.array(f.z.string()).optional(),code_challenge_methods_supported:f.z.array(f.z.string()),response_modes_supported:f.z.array(f.z.string()),subject_types_supported:f.z.array(f.z.string()),id_token_signing_alg_values_supported:f.z.array(f.z.string()),token_endpoint_auth_methods_supported:f.z.array(f.z.string()),claims_supported:f.z.array(f.z.string()),request_uri_parameter_supported:f.z.boolean(),request_parameter_supported:f.z.boolean(),claims_parameter_supported:f.z.boolean().optional(),request_object_signing_alg_values_supported:f.z.array(f.z.string()).optional(),token_endpoint_auth_signing_alg_values_supported:f.z.array(f.z.string()),client_id_metadata_document_supported:f.z.boolean().optional(),backchannel_logout_supported:f.z.boolean().optional(),backchannel_logout_session_supported:f.z.boolean().optional()});var $P=function(e){return e.PENDING=`pending`,e.AUTHENTICATED=`authenticated`,e.AWAITING_EMAIL_VERIFICATION=`awaiting_email_verification`,e.AWAITING_MFA=`awaiting_mfa`,e.AWAITING_HOOK=`awaiting_hook`,e.AWAITING_CONTINUATION=`awaiting_continuation`,e.AWAITING_CONSENT=`awaiting_consent`,e.COMPLETED=`completed`,e.FAILED=`failed`,e.EXPIRED=`expired`,e}({}),eF=f.z.nativeEnum($P),tF=f.z.object({strategy:f.z.string(),strategy_type:f.z.string()});f.z.object({csrf_token:f.z.string(),auth0Client:f.z.string().optional(),authParams:kN,expires_at:f.z.string(),deleted_at:f.z.string().optional(),ip:f.z.string().optional(),useragent:f.z.string().optional(),session_id:f.z.string().optional(),authorization_url:f.z.string().optional(),state:eF.optional().default(`pending`),state_data:f.z.string().optional(),failure_reason:f.z.string().optional(),user_id:f.z.string().optional(),auth_connection:f.z.string().optional(),auth_strategy:tF.optional(),authenticated_at:f.z.string().optional()}).openapi({description:`This represents a login sesion`}).extend({id:f.z.string().openapi({description:`This is is used as the state in the universal login`}),created_at:f.z.string(),updated_at:f.z.string(),tenant_id:f.z.string().optional()});var Q={ACLS_SUMMARY:`acls_summary`,ACTIONS_EXECUTION_FAILED:`actions_execution_failed`,API_LIMIT:`api_limit`,API_LIMIT_WARNING:`api_limit_warning`,APPI:`appi`,CIBA_EXCHANGE_FAILED:`ciba_exchange_failed`,CIBA_EXCHANGE_SUCCEEDED:`ciba_exchange_succeeded`,CIBA_START_FAILED:`ciba_start_failed`,CIBA_START_SUCCEEDED:`ciba_start_succeeded`,CODE_LINK_SENT:`cls`,CODE_SENT:`cs`,DEPRECATION_NOTICE:`depnote`,CONFIG_INHERITANCE_DIFF:`cfgdiff`,CONFIG_DRIFT:`cfgdrift`,FAILED_LOGIN:`f`,FAILED_BY_CONNECTOR:`fc`,FAILED_CHANGE_EMAIL:`fce`,FAILED_BY_CORS:`fco`,FAILED_CROSS_ORIGIN_AUTHENTICATION:`fcoa`,FAILED_CHANGE_PASSWORD:`fcp`,FAILED_POST_CHANGE_PASSWORD_HOOK:`fcph`,FAILED_CHANGE_PHONE_NUMBER:`fcpn`,FAILED_CHANGE_PASSWORD_REQUEST:`fcpr`,FAILED_CONNECTOR_PROVISIONING:`fcpro`,FAILED_CHANGE_USERNAME:`fcu`,FAILED_DELEGATION:`fd`,FAILED_DEVICE_ACTIVATION:`fdeac`,FAILED_DEVICE_AUTHORIZATION_REQUEST:`fdeaz`,USER_CANCELED_DEVICE_CONFIRMATION:`fdecc`,FAILED_USER_DELETION:`fdu`,FAILED_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN:`feacft`,FAILED_EXCHANGE_ACCESS_TOKEN_FOR_CLIENT_CREDENTIALS:`feccft`,FAILED_EXCHANGE_CUSTOM_TOKEN:`fecte`,FAILED_EXCHANGE_DEVICE_CODE_FOR_ACCESS_TOKEN:`fede`,FAILED_FEDERATED_LOGOUT:`federated_logout_failed`,FAILED_EXCHANGE_NATIVE_SOCIAL_LOGIN:`fens`,FAILED_EXCHANGE_PASSWORD_OOB_FOR_ACCESS_TOKEN:`feoobft`,FAILED_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN:`feotpft`,FAILED_EXCHANGE_PASSWORD_FOR_ACCESS_TOKEN:`fepft`,FAILED_EXCHANGE_PASSWORDLESS_OTP_FOR_ACCESS_TOKEN:`fepotpft`,FAILED_EXCHANGE_PASSWORD_MFA_RECOVERY_FOR_ACCESS_TOKEN:`fercft`,FAILED_EXCHANGE_ROTATING_REFRESH_TOKEN:`ferrt`,FAILED_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN:`fertft`,FAILED_EXCHANGE_SUBJECT_TOKEN_FOR_ACCESS_TOKEN:`festft`,FAILED_HOOK:`fh`,FAILED_IMPERSONATION:`fimp`,FAILED_INVITE_ACCEPT:`fi`,FAILED_LOGOUT:`flo`,FLOWS_EXECUTION_COMPLETED:`flows_execution_completed`,FLOWS_EXECUTION_FAILED:`flows_execution_failed`,FAILED_SENDING_NOTIFICATION:`fn`,FORMS_SUBMISSION_FAILED:`forms_submission_failed`,FORMS_SUBMISSION_SUCCEEDED:`forms_submission_succeeded`,FAILED_LOGIN_INCORRECT_PASSWORD:`fp`,FAILED_PUSHED_AUTHORIZATION_REQUEST:`fpar`,FAILED_POST_USER_REGISTRATION_HOOK:`fpurh`,FAILED_SIGNUP:`fs`,FAILED_SILENT_AUTH:`fsa`,FAILED_LOGIN_INVALID_EMAIL_USERNAME:`fu`,FAILED_USERS_IMPORT:`fui`,FAILED_VERIFICATION_EMAIL:`fv`,FAILED_VERIFICATION_EMAIL_REQUEST:`fvr`,EMAIL_VERIFICATION_CONFIRMED:`gd_auth_email_verification`,EMAIL_VERIFICATION_FAILED:`gd_auth_fail_email_verification`,MFA_AUTH_FAILED:`gd_auth_failed`,MFA_AUTH_REJECTED:`gd_auth_rejected`,MFA_AUTH_SUCCESS:`gd_auth_succeed`,MFA_ENROLLMENT_COMPLETE:`gd_enrollment_complete`,TOO_MANY_MFA_FAILURES:`gd_otp_rate_limit_exceed`,MFA_RECOVERY_FAILED:`gd_recovery_failed`,MFA_RECOVERY_RATE_LIMIT_EXCEED:`gd_recovery_rate_limit_exceed`,MFA_RECOVERY_SUCCESS:`gd_recovery_succeed`,MFA_EMAIL_SENT:`gd_send_email`,EMAIL_VERIFICATION_SENT:`gd_send_email_verification`,EMAIL_VERIFICATION_SEND_FAILURE:`gd_send_email_verification_failure`,PUSH_NOTIFICATION_SENT:`gd_send_pn`,ERROR_SENDING_MFA_PUSH_NOTIFICATION:`gd_send_pn_failure`,MFA_SMS_SENT:`gd_send_sms`,ERROR_SENDING_MFA_SMS:`gd_send_sms_failure`,MFA_VOICE_CALL_SUCCESS:`gd_send_voice`,MFA_VOICE_CALL_FAILED:`gd_send_voice_failure`,SECOND_FACTOR_STARTED:`gd_start_auth`,MFA_ENROLL_STARTED:`gd_start_enroll`,MFA_ENROLLMENT_FAILED:`gd_start_enroll_failed`,GUARDIAN_TENANT_UPDATE:`gd_tenant_update`,UNENROLL_DEVICE_ACCOUNT:`gd_unenroll`,UPDATE_DEVICE_ACCOUNT:`gd_update_device_account`,WEBAUTHN_CHALLENGE_FAILED:`gd_webauthn_challenge_failed`,WEBAUTHN_ENROLLMENT_FAILED:`gd_webauthn_enrollment_failed`,FAILED_KMS_API_OPERATION:`kms_key_management_failure`,SUCCESS_KMS_API_OPERATION:`kms_key_management_success`,KMS_KEY_STATE_CHANGED:`kms_key_state_changed`,TOO_MANY_CALLS_TO_DELEGATION:`limit_delegation`,BLOCKED_IP_ADDRESS:`limit_mu`,BLOCKED_ACCOUNT_IP:`limit_sul`,BLOCKED_ACCOUNT_EMAIL:`limit_wc`,INFORMATION:`i`,MFA_REQUIRED:`mfar`,MANAGEMENT_API_READ_OPERATION:`mgmt_api_read`,FAILED_AUTHENTICATION_METHOD_OPERATION_MY_ACCOUNT:`my_account_authentication_method_failed`,SUCCESSFUL_AUTHENTICATION_METHOD_OPERATION_MY_ACCOUNT:`my_account_authentication_method_succeeded`,FAILED_OIDC_BACKCHANNEL_LOGOUT:`oidc_backchannel_logout_failed`,SUCCESSFUL_OIDC_BACKCHANNEL_LOGOUT:`oidc_backchannel_logout_succeeded`,ORGANIZATION_MEMBER_ADDED:`organization_member_added`,PASSKEY_CHALLENGE_FAILED:`passkey_challenge_failed`,PASSKEY_CHALLENGE_STARTED:`passkey_challenge_started`,PRE_LOGIN_ASSESSMENT:`pla`,BREACHED_PASSWORD:`pwd_leak`,BREACHED_PASSWORD_ON_RESET:`reset_pwd_leak`,SUCCESS_RESOURCE_CLEANUP:`resource_cleanup`,RICH_CONSENTS_ACCESS_ERROR:`rich_consents_access_error`,SUCCESS_LOGIN:`s`,SUCCESS_API_OPERATION:`sapi`,FAILED_API_OPERATION:`fapi`,SUCCESS_CHANGE_EMAIL:`sce`,SUCCESS_CROSS_ORIGIN_AUTHENTICATION:`scoa`,SUCCESS_CHANGE_PASSWORD:`scp`,SUCCESS_CHANGE_PHONE_NUMBER:`scpn`,SUCCESS_CHANGE_PASSWORD_REQUEST:`scpr`,SUCCESS_CHANGE_USERNAME:`scu`,SUCCESS_CREDENTIAL_VALIDATION:`scv`,SUCCESS_DELEGATION:`sd`,SUCCESS_USER_DELETION:`sdu`,SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN:`seacft`,SUCCESS_EXCHANGE_ACCESS_TOKEN_FOR_CLIENT_CREDENTIALS:`seccft`,SUCCESS_EXCHANGE_CUSTOM_TOKEN:`secte`,SUCCESS_EXCHANGE_DEVICE_CODE_FOR_ACCESS_TOKEN:`sede`,SUCCESS_EXCHANGE_NATIVE_SOCIAL_LOGIN:`sens`,SUCCESS_EXCHANGE_PASSWORD_OOB_FOR_ACCESS_TOKEN:`seoobft`,SUCCESS_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN:`seotpft`,SUCCESS_EXCHANGE_PASSWORDLESS_OTP_FOR_ACCESS_TOKEN:`sepotpft`,SUCCESS_EXCHANGE_PASSWORD_FOR_ACCESS_TOKEN:`sepft`,SUCCESS_EXCHANGE_PASSKEY_OOB_FOR_ACCESS_TOKEN:`sepkoobft`,SUCCESS_EXCHANGE_PASSKEY_OTP_FOR_ACCESS_TOKEN:`sepkotpft`,SUCCESS_EXCHANGE_PASSKEY_MFA_RECOVERY_FOR_ACCESS_TOKEN:`sepkrcft`,SUCCESS_EXCHANGE_PASSWORD_MFA_RECOVERY_FOR_ACCESS_TOKEN:`sercft`,SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN:`sertft`,SUCCESS_EXCHANGE_SUBJECT_TOKEN_FOR_ACCESS_TOKEN:`sestft`,SUCCESS_IMPERSONATION:`simp`,SUCCESSFULLY_ACCEPTED_USER_INVITE:`si`,BREACHED_PASSWORD_ON_SIGNUP:`signup_pwd_leak`,SUCCESS_LOGOUT:`slo`,SUCCESS_HOOK:`sh`,SUCCESS_PASSWORD_MIGRATION:`spm`,SUCCESS_REVOCATION:`srrt`,SUCCESS_SIGNUP:`ss`,FAILED_SS_SSO_OPERATION:`ss_sso_failure`,INFORMATION_FROM_SS_SSO_OPERATION:`ss_sso_info`,SUCCESS_SS_SSO_OPERATION:`ss_sso_success`,SUCCESS_SILENT_AUTH:`ssa`,SUCCESSFUL_SCIM_OPERATION:`sscim`,SUCCESSFULLY_IMPORTED_USERS:`sui`,SUCCESS_VERIFICATION_EMAIL:`sv`,SUCCESS_VERIFICATION_EMAIL_REQUEST:`svr`,MAX_AMOUNT_OF_AUTHENTICATORS:`too_many_records`,USER_LOGIN_BLOCK_RELEASED:`ublkdu`,FAILED_UNIVERSAL_LOGOUT:`universal_logout_failed`,SUCCESSFUL_UNIVERSAL_LOGOUT:`universal_logout_succeeded`,WARNING_DURING_LOGIN:`w`,WARNING_SENDING_NOTIFICATION:`wn`,WARNING_USER_MANAGEMENT:`wum`},nF=f.z.string().refine(e=>Object.values(Q).includes(e),{message:`Invalid log type`});Q.ACLS_SUMMARY,Q.ACTIONS_EXECUTION_FAILED,Q.API_LIMIT,Q.API_LIMIT_WARNING,Q.APPI,Q.CIBA_EXCHANGE_FAILED,Q.CIBA_EXCHANGE_SUCCEEDED,Q.CIBA_START_FAILED,Q.CIBA_START_SUCCEEDED,Q.CODE_LINK_SENT,Q.CODE_SENT,Q.DEPRECATION_NOTICE,Q.CONFIG_INHERITANCE_DIFF,Q.CONFIG_DRIFT,Q.FAILED_LOGIN,Q.FAILED_BY_CONNECTOR,Q.FAILED_CHANGE_EMAIL,Q.FAILED_BY_CORS,Q.FAILED_CROSS_ORIGIN_AUTHENTICATION,Q.FAILED_CHANGE_PASSWORD,Q.FAILED_POST_CHANGE_PASSWORD_HOOK,Q.FAILED_CHANGE_PHONE_NUMBER,Q.FAILED_CHANGE_PASSWORD_REQUEST,Q.FAILED_CONNECTOR_PROVISIONING,Q.FAILED_CHANGE_USERNAME,Q.FAILED_DELEGATION,Q.FAILED_DEVICE_ACTIVATION,Q.FAILED_DEVICE_AUTHORIZATION_REQUEST,Q.USER_CANCELED_DEVICE_CONFIRMATION,Q.FAILED_USER_DELETION,Q.FAILED_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_ACCESS_TOKEN_FOR_CLIENT_CREDENTIALS,Q.FAILED_EXCHANGE_CUSTOM_TOKEN,Q.FAILED_EXCHANGE_DEVICE_CODE_FOR_ACCESS_TOKEN,Q.FAILED_FEDERATED_LOGOUT,Q.FAILED_EXCHANGE_NATIVE_SOCIAL_LOGIN,Q.FAILED_EXCHANGE_PASSWORD_OOB_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_PASSWORD_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_PASSWORDLESS_OTP_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_PASSWORD_MFA_RECOVERY_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_ROTATING_REFRESH_TOKEN,Q.FAILED_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN,Q.FAILED_EXCHANGE_SUBJECT_TOKEN_FOR_ACCESS_TOKEN,Q.FAILED_HOOK,Q.FAILED_IMPERSONATION,Q.FAILED_INVITE_ACCEPT,Q.FAILED_LOGOUT,Q.FLOWS_EXECUTION_COMPLETED,Q.FLOWS_EXECUTION_FAILED,Q.FAILED_SENDING_NOTIFICATION,Q.FORMS_SUBMISSION_FAILED,Q.FORMS_SUBMISSION_SUCCEEDED,Q.FAILED_LOGIN_INCORRECT_PASSWORD,Q.FAILED_PUSHED_AUTHORIZATION_REQUEST,Q.FAILED_POST_USER_REGISTRATION_HOOK,Q.FAILED_SIGNUP,Q.FAILED_SILENT_AUTH,Q.FAILED_LOGIN_INVALID_EMAIL_USERNAME,Q.FAILED_USERS_IMPORT,Q.FAILED_VERIFICATION_EMAIL,Q.FAILED_VERIFICATION_EMAIL_REQUEST,Q.EMAIL_VERIFICATION_CONFIRMED,Q.EMAIL_VERIFICATION_FAILED,Q.MFA_AUTH_FAILED,Q.MFA_AUTH_REJECTED,Q.MFA_AUTH_SUCCESS,Q.MFA_ENROLLMENT_COMPLETE,Q.TOO_MANY_MFA_FAILURES,Q.MFA_RECOVERY_FAILED,Q.MFA_RECOVERY_RATE_LIMIT_EXCEED,Q.MFA_RECOVERY_SUCCESS,Q.MFA_EMAIL_SENT,Q.EMAIL_VERIFICATION_SENT,Q.EMAIL_VERIFICATION_SEND_FAILURE,Q.PUSH_NOTIFICATION_SENT,Q.ERROR_SENDING_MFA_PUSH_NOTIFICATION,Q.MFA_SMS_SENT,Q.ERROR_SENDING_MFA_SMS,Q.MFA_VOICE_CALL_SUCCESS,Q.MFA_VOICE_CALL_FAILED,Q.SECOND_FACTOR_STARTED,Q.MFA_ENROLL_STARTED,Q.MFA_ENROLLMENT_FAILED,Q.GUARDIAN_TENANT_UPDATE,Q.UNENROLL_DEVICE_ACCOUNT,Q.UPDATE_DEVICE_ACCOUNT,Q.WEBAUTHN_CHALLENGE_FAILED,Q.WEBAUTHN_ENROLLMENT_FAILED,Q.FAILED_KMS_API_OPERATION,Q.SUCCESS_KMS_API_OPERATION,Q.KMS_KEY_STATE_CHANGED,Q.TOO_MANY_CALLS_TO_DELEGATION,Q.BLOCKED_IP_ADDRESS,Q.BLOCKED_ACCOUNT_IP,Q.BLOCKED_ACCOUNT_EMAIL,Q.INFORMATION,Q.MFA_REQUIRED,Q.MANAGEMENT_API_READ_OPERATION,Q.FAILED_AUTHENTICATION_METHOD_OPERATION_MY_ACCOUNT,Q.SUCCESSFUL_AUTHENTICATION_METHOD_OPERATION_MY_ACCOUNT,Q.FAILED_OIDC_BACKCHANNEL_LOGOUT,Q.SUCCESSFUL_OIDC_BACKCHANNEL_LOGOUT,Q.ORGANIZATION_MEMBER_ADDED,Q.PASSKEY_CHALLENGE_FAILED,Q.PASSKEY_CHALLENGE_STARTED,Q.PRE_LOGIN_ASSESSMENT,Q.BREACHED_PASSWORD,Q.BREACHED_PASSWORD_ON_RESET,Q.SUCCESS_RESOURCE_CLEANUP,Q.RICH_CONSENTS_ACCESS_ERROR,Q.SUCCESS_LOGIN,Q.SUCCESS_API_OPERATION,Q.FAILED_API_OPERATION,Q.SUCCESS_CHANGE_EMAIL,Q.SUCCESS_CROSS_ORIGIN_AUTHENTICATION,Q.SUCCESS_CHANGE_PASSWORD,Q.SUCCESS_CHANGE_PHONE_NUMBER,Q.SUCCESS_CHANGE_PASSWORD_REQUEST,Q.SUCCESS_CHANGE_USERNAME,Q.SUCCESS_CREDENTIAL_VALIDATION,Q.SUCCESS_DELEGATION,Q.SUCCESS_USER_DELETION,Q.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_ACCESS_TOKEN_FOR_CLIENT_CREDENTIALS,Q.SUCCESS_EXCHANGE_CUSTOM_TOKEN,Q.SUCCESS_EXCHANGE_DEVICE_CODE_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_NATIVE_SOCIAL_LOGIN,Q.SUCCESS_EXCHANGE_PASSWORD_OOB_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSWORDLESS_OTP_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSWORD_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSKEY_OOB_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSKEY_OTP_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSKEY_MFA_RECOVERY_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_PASSWORD_MFA_RECOVERY_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN,Q.SUCCESS_EXCHANGE_SUBJECT_TOKEN_FOR_ACCESS_TOKEN,Q.SUCCESS_IMPERSONATION,Q.SUCCESSFULLY_ACCEPTED_USER_INVITE,Q.BREACHED_PASSWORD_ON_SIGNUP,Q.SUCCESS_LOGOUT,Q.SUCCESS_HOOK,Q.SUCCESS_PASSWORD_MIGRATION,Q.SUCCESS_REVOCATION,Q.SUCCESS_SIGNUP,Q.FAILED_SS_SSO_OPERATION,Q.INFORMATION_FROM_SS_SSO_OPERATION,Q.SUCCESS_SS_SSO_OPERATION,Q.SUCCESS_SILENT_AUTH,Q.SUCCESSFUL_SCIM_OPERATION,Q.SUCCESSFULLY_IMPORTED_USERS,Q.SUCCESS_VERIFICATION_EMAIL,Q.SUCCESS_VERIFICATION_EMAIL_REQUEST,Q.MAX_AMOUNT_OF_AUTHENTICATORS,Q.USER_LOGIN_BLOCK_RELEASED,Q.FAILED_UNIVERSAL_LOGOUT,Q.SUCCESSFUL_UNIVERSAL_LOGOUT,Q.WARNING_DURING_LOGIN,Q.WARNING_SENDING_NOTIFICATION,Q.WARNING_USER_MANAGEMENT,(()=>{let e={};for(let[t,n]of Object.entries(Q))t.startsWith(`SUCCESS_`)||t.startsWith(`SUCCESSFUL_`)||t.startsWith(`SUCCESSFULLY_`)||t.endsWith(`_SUCCEEDED`)||t.endsWith(`_COMPLETED`)?e[n]=`success`:t.startsWith(`FAILED_`)||t.startsWith(`ERROR_`)||t.startsWith(`BREACHED_`)||t.startsWith(`BLOCKED_`)||t===`MFA_AUTH_FAILED`||t===`MFA_AUTH_REJECTED`||t===`MFA_RECOVERY_FAILED`||t===`MFA_ENROLLMENT_FAILED`||t===`EMAIL_VERIFICATION_FAILED`||t===`WEBAUTHN_CHALLENGE_FAILED`||t===`WEBAUTHN_ENROLLMENT_FAILED`||t===`PASSKEY_CHALLENGE_FAILED`||t===`FLOWS_EXECUTION_FAILED`||t===`FORMS_SUBMISSION_FAILED`||t===`CIBA_EXCHANGE_FAILED`||t===`CIBA_START_FAILED`||t===`ACTIONS_EXECUTION_FAILED`||t===`RICH_CONSENTS_ACCESS_ERROR`||t===`USER_CANCELED_DEVICE_CONFIRMATION`||t===`TOO_MANY_MFA_FAILURES`||t===`MFA_RECOVERY_RATE_LIMIT_EXCEED`||t===`API_LIMIT`||t===`MAX_AMOUNT_OF_AUTHENTICATORS`?e[n]=`failure`:t.startsWith(`WARNING_`)||t===`API_LIMIT_WARNING`||t===`DEPRECATION_NOTICE`||t===`PRE_LOGIN_ASSESSMENT`?e[n]=`warning`:t===`CODE_SENT`||t===`CODE_LINK_SENT`||t===`MFA_EMAIL_SENT`||t===`MFA_SMS_SENT`||t===`EMAIL_VERIFICATION_SENT`||t===`PUSH_NOTIFICATION_SENT`?e[n]=`code_sent`:t===`INFORMATION`||t===`INFORMATION_FROM_SS_SSO_OPERATION`||t===`MANAGEMENT_API_READ_OPERATION`||t===`APPI`||t===`CONFIG_INHERITANCE_DIFF`||t===`CONFIG_DRIFT`||t===`ACLS_SUMMARY`||t===`ORGANIZATION_MEMBER_ADDED`?e[n]=`info`:e[n]=`other`;return e})();var rF=f.z.object({name:f.z.string(),version:f.z.string(),env:f.z.object({node:f.z.string().optional()}).optional()}),iF=f.z.object({country_code:f.z.string().length(2),city_name:f.z.string(),latitude:f.z.string(),longitude:f.z.string(),time_zone:f.z.string(),continent_code:f.z.string()});f.z.object({type:nF,date:f.z.string(),description:f.z.string().optional(),ip:f.z.string().optional(),user_agent:f.z.string().optional(),details:f.z.any().optional(),isMobile:f.z.boolean(),user_id:f.z.string().optional(),user_name:f.z.string().optional(),connection:f.z.string().optional(),connection_id:f.z.string().optional(),client_id:f.z.string().optional(),client_name:f.z.string().optional(),audience:f.z.string().optional(),scope:f.z.string().optional(),strategy:f.z.string().optional(),strategy_type:f.z.string().optional(),hostname:f.z.string().optional(),auth0_client:rF.optional(),log_id:f.z.string().optional(),location_info:iF.optional()}).extend({log_id:f.z.string()});var aF=f.z.enum([`http`,`eventbridge`,`eventgrid`,`splunk`,`datadog`,`sumo`,`firehose`]),oF=f.z.enum([`active`,`paused`,`suspended`]),sF=f.z.object({type:f.z.string(),name:f.z.string()});f.z.object({name:f.z.string(),type:aF,status:oF.optional(),sink:f.z.record(f.z.string(),f.z.unknown()),filters:f.z.array(sF).optional(),isPriority:f.z.boolean().optional()}).extend({id:f.z.string(),status:oF,created_at:f.z.string().optional(),updated_at:f.z.string().optional()});var cF=f.z.enum([`auth0`,`cognito`,`okta`,`oidc`]),lF=f.z.object({domain:f.z.string(),client_id:f.z.string(),client_secret:JM(),audience:f.z.string().optional(),scope:f.z.string().optional()}),uF=f.z.object({id:f.z.string().optional(),name:f.z.string(),provider:cF,connection:f.z.string(),enabled:f.z.boolean().default(!0),credentials:lF});f.z.object({id:f.z.string(),created_at:f.z.string(),updated_at:f.z.string()}).extend(uF.shape);var dF=f.z.object({enabled:f.z.boolean().optional(),shields:f.z.array(f.z.string()).optional(),admin_notification_frequency:f.z.array(f.z.string()).optional(),method:f.z.string().optional(),stage:f.z.object({"pre-user-registration":f.z.object({shields:f.z.array(f.z.string()).optional()}).optional(),"pre-change-password":f.z.object({shields:f.z.array(f.z.string()).optional()}).optional()}).optional()}),fF=f.z.object({enabled:f.z.boolean().optional(),shields:f.z.array(f.z.string()).optional(),allowlist:f.z.array(f.z.string()).optional(),mode:f.z.string().optional(),max_attempts:f.z.number().optional()}),pF=f.z.object({enabled:f.z.boolean().optional(),shields:f.z.array(f.z.string()).optional(),allowlist:f.z.array(f.z.string()).optional(),stage:f.z.object({"pre-login":f.z.object({max_attempts:f.z.number().optional(),rate:f.z.number().optional()}).optional(),"pre-user-registration":f.z.object({max_attempts:f.z.number().optional(),rate:f.z.number().optional()}).optional()}).optional()}),mF=f.z.object({breached_password_detection:dF.optional(),brute_force_protection:fF.optional(),suspicious_ip_throttling:pF.optional()});f.z.object({id:f.z.string().optional(),user_id:f.z.string(),password:f.z.string(),algorithm:f.z.enum([`bcrypt`,`argon2id`]).default(`argon2id`),is_current:f.z.boolean().default(!0)}).extend({id:f.z.string(),created_at:f.z.string(),updated_at:f.z.string()});var hF=f.z.object({initial_user_agent:f.z.string().describe(`First user agent of the device from which this user logged in`),initial_ip:f.z.string().describe(`First IP address associated with this session`),initial_asn:f.z.string().describe(`First autonomous system number associated with this session`),last_user_agent:f.z.string().describe(`Last user agent of the device from which this user logged in`),last_ip:f.z.string().describe(`Last IP address from which this user logged in`),last_asn:f.z.string().describe(`Last autonomous system number from which this user logged in`)}),gF=f.z.object({name:f.z.string().describe(`Authentication method name, e.g. "mfa" for a completed second factor`),timestamp:f.z.string().describe(`When the method was completed (ISO 8601)`),type:f.z.string().optional().describe(`For "mfa": the authentication method type used, e.g. "totp", "phone", "passkey"`)}),_F=f.z.object({methods:f.z.array(gF)}),vF=f.z.object({id:f.z.string(),revoked_at:f.z.string().optional(),used_at:f.z.string().optional(),user_id:f.z.string().describe(`The user ID associated with the session`),expires_at:f.z.string().optional(),login_session_id:f.z.string(),idle_expires_at:f.z.string().optional(),device:hF.describe(`Metadata related to the device used in the session`),clients:f.z.array(f.z.string()).describe(`List of client details for the session`),authentication:_F.optional().describe(`Authentication methods completed in this session (currently MFA only)`),session_transfer:eN.optional().describe(`Set when the session was created by redeeming a session_transfer_token`)});f.z.object({created_at:f.z.string(),updated_at:f.z.string(),authenticated_at:f.z.string(),last_interaction_at:f.z.string()}).extend(vF.shape),f.z.object({kid:f.z.string().openapi({description:`The key id of the signing key`}),tenant_id:f.z.string().optional().openapi({description:`The tenant the key belongs to. Omitted means the key is shared / control-plane scoped.`}),cert:f.z.string().openapi({description:`The public certificate of the signing key`}),fingerprint:f.z.string().openapi({description:`The cert fingerprint`}),thumbprint:f.z.string().openapi({description:`The cert thumbprint`}),pkcs7:f.z.string().optional().openapi({description:`The private key in pkcs7 format`}),current:f.z.boolean().optional().openapi({description:`True if the key is the current key`}),next:f.z.boolean().optional().openapi({description:`True if the key is the next key`}),previous:f.z.boolean().optional().openapi({description:`True if the key is the previous key`}),current_since:f.z.string().optional().openapi({description:`The date and time when the key became the current key`}),current_until:f.z.string().optional().openapi({description:`The date and time when the current key was rotated`}),revoked:f.z.boolean().optional().openapi({description:`True if the key is revoked`}),revoked_at:f.z.string().optional().openapi({description:`The date and time when the key was revoked`}),connection:f.z.string().optional().openapi({description:`The connection identifier associated with the key`}),type:f.z.enum([`jwt_signing`,`saml_encryption`]).openapi({description:`The type of the signing key`})});var yF=f.z.enum([`never`,`always`,`all-applications`,`confidence-score`]),bF={allow_remember_browser:f.z.boolean().optional(),remember_browser_lifetime_in_days:f.z.number().int().min(1).max(365).optional()};f.z.object({idle_session_lifetime:f.z.number().default(72),session_lifetime:f.z.number().default(168),session_cookie:f.z.object({mode:f.z.enum([`persistent`,`non-persistent`]).optional()}).optional(),enable_client_connections:f.z.boolean().optional(),default_redirection_uri:f.z.string().optional(),enabled_locales:f.z.array(f.z.string()).optional(),default_directory:f.z.string().optional(),error_page:f.z.object({html:f.z.string().optional(),show_log_link:f.z.boolean().optional(),url:f.z.string().optional()}).optional(),flags:f.z.object({allow_legacy_delegation_grant_types:f.z.boolean().optional(),allow_legacy_ro_grant_types:f.z.boolean().optional(),allow_legacy_tokeninfo_endpoint:f.z.boolean().optional(),disable_clickjack_protection_headers:f.z.boolean().optional(),enable_apis_section:f.z.boolean().optional(),enable_client_connections:f.z.boolean().optional(),enable_custom_domain_in_emails:f.z.boolean().optional(),enable_dynamic_client_registration:f.z.boolean().optional(),enable_idtoken_api2:f.z.boolean().optional(),enable_legacy_logs_search_v2:f.z.boolean().optional(),enable_legacy_profile:f.z.boolean().optional(),enable_pipeline2:f.z.boolean().optional(),enable_public_signup_user_exists_error:f.z.boolean().optional(),use_scope_descriptions_for_consent:f.z.boolean().optional(),disable_management_api_sms_obfuscation:f.z.boolean().optional(),enable_adfs_waad_email_verification:f.z.boolean().optional(),revoke_refresh_token_grant:f.z.boolean().optional(),dashboard_log_streams_next:f.z.boolean().optional(),dashboard_insights_view:f.z.boolean().optional(),disable_fields_map_fix:f.z.boolean().optional(),mfa_show_factor_list_on_enrollment:f.z.boolean().optional()}).optional(),friendly_name:f.z.string().optional(),picture_url:f.z.string().optional(),support_email:f.z.string().optional(),support_url:f.z.string().optional(),sandbox_version:f.z.string().optional(),sandbox_versions_available:f.z.array(f.z.string()).optional(),change_password:f.z.object({enabled:f.z.boolean(),html:f.z.string()}).optional(),guardian_mfa_page:f.z.object({enabled:f.z.boolean(),html:f.z.string()}).optional(),default_audience:f.z.string().optional(),default_organization:f.z.string().optional(),sessions:f.z.object({oidc_logout_prompt_enabled:f.z.boolean().optional()}).optional(),mfa:f.z.object({policy:yF.default(`never`).optional(),...bF,factors:f.z.object({sms:f.z.boolean().default(!1),otp:f.z.boolean().default(!1),email:f.z.boolean().default(!1),push_notification:f.z.boolean().default(!1),webauthn_roaming:f.z.boolean().default(!1),webauthn_platform:f.z.boolean().default(!1),recovery_code:f.z.boolean().default(!1),duo:f.z.boolean().default(!1)}).optional(),sms_provider:f.z.object({provider:f.z.enum([`twilio`,`vonage`,`aws_sns`,`phone_message_hook`]).optional()}).optional(),twilio:f.z.object({sid:JM().optional(),auth_token:JM().optional(),from:f.z.string().optional(),messaging_service_sid:f.z.string().optional()}).optional(),phone_message:f.z.object({message:f.z.string().optional()}).optional()}).optional()});var xF=f.z.object({id:f.z.string().optional(),parent_tenant_id:f.z.string().nullish(),config_sync:f.z.enum([`inherit-on-read`,`synced`,`detached`]).nullish(),config_sync_hash:f.z.string().nullish(),config_synced_at:f.z.string().nullish(),audience:f.z.string().optional(),friendly_name:f.z.string(),picture_url:f.z.string().optional(),support_email:f.z.string().optional(),support_url:f.z.string().optional(),sender_email:f.z.string().email().nullish(),sender_name:f.z.string().optional(),session_lifetime:f.z.number().optional(),idle_session_lifetime:f.z.number().optional(),ephemeral_session_lifetime:f.z.number().optional(),idle_ephemeral_session_lifetime:f.z.number().optional(),session_cookie:f.z.object({mode:f.z.enum([`persistent`,`non-persistent`]).optional()}).optional(),allowed_logout_urls:f.z.array(f.z.string()).optional(),default_redirection_uri:f.z.string().optional(),default_client_id:f.z.string().optional(),enabled_locales:f.z.array(f.z.string()).optional(),default_directory:f.z.string().optional(),error_page:f.z.object({html:f.z.string().optional(),show_log_link:f.z.boolean().optional(),url:f.z.string().optional()}).nullish(),flags:f.z.object({allow_changing_enable_sso:f.z.boolean().optional(),allow_legacy_delegation_grant_types:f.z.boolean().optional(),allow_legacy_ro_grant_types:f.z.boolean().optional(),allow_legacy_tokeninfo_endpoint:f.z.boolean().optional(),change_pwd_flow_v1:f.z.boolean().optional(),client_id_metadata_document_registration:f.z.boolean().optional(),custom_domains_provisioning:f.z.boolean().optional(),dashboard_insights_view:f.z.boolean().optional(),dashboard_log_streams_next:f.z.boolean().optional(),disable_clickjack_protection_headers:f.z.boolean().optional(),disable_fields_map_fix:f.z.boolean().optional(),disable_impersonation:f.z.boolean().optional(),disable_management_api_sms_obfuscation:f.z.boolean().optional(),enable_adfs_waad_email_verification:f.z.boolean().optional(),enable_apis_section:f.z.boolean().optional(),enable_client_connections:f.z.boolean().optional(),enable_custom_domain_in_emails:f.z.boolean().optional(),enable_dynamic_client_registration:f.z.boolean().optional(),dcr_require_initial_access_token:f.z.boolean().optional(),dcr_allowed_grant_types:f.z.array(f.z.string()).optional(),allow_http_return_to:f.z.array(f.z.string().refine(e=>{try{let t=new URL(e);return t.protocol===`http:`&&(t.pathname===``||t.pathname===`/`)&&!t.search&&!t.hash&&e===t.origin}catch{return!1}},{message:`must be a fully-qualified http origin (scheme + host + port, no path)`})).optional(),enable_idtoken_api2:f.z.boolean().optional(),enable_legacy_logs_search_v2:f.z.boolean().optional(),enable_legacy_profile:f.z.boolean().optional(),enable_pipeline2:f.z.boolean().optional(),enable_public_signup_user_exists_error:f.z.boolean().optional(),enable_sso:f.z.boolean().optional(),enforce_client_authentication_on_passwordless_start:f.z.boolean().optional(),genai_trial:f.z.boolean().optional(),improved_signup_bot_detection_in_classic:f.z.boolean().optional(),mfa_show_factor_list_on_enrollment:f.z.boolean().optional(),no_disclose_enterprise_connections:f.z.boolean().optional(),remove_alg_from_jwks:f.z.boolean().optional(),revoke_refresh_token_grant:f.z.boolean().optional(),trust_azure_adfs_email_verified_connection_property:f.z.boolean().optional(),use_scope_descriptions_for_consent:f.z.boolean().optional(),inherit_global_permissions_in_organizations:f.z.boolean().optional(),restrict_undefined_scopes:f.z.boolean().optional(),universal_login_version:f.z.enum([`1`,`2`]).optional()}).optional(),sandbox_version:f.z.string().optional(),legacy_sandbox_version:f.z.string().optional(),sandbox_versions_available:f.z.array(f.z.string()).optional(),change_password:f.z.object({enabled:f.z.boolean().optional(),html:f.z.string().optional()}).optional(),guardian_mfa_page:f.z.object({enabled:f.z.boolean().optional(),html:f.z.string().optional()}).optional(),device_flow:f.z.object({charset:f.z.enum([`base20`,`digits`]).optional(),mask:f.z.string().max(20).optional()}).optional(),default_token_quota:f.z.object({clients:f.z.object({client_credentials:f.z.record(f.z.string(),f.z.any()).optional()}).optional(),organizations:f.z.object({client_credentials:f.z.record(f.z.string(),f.z.any()).optional()}).optional()}).nullish(),default_audience:f.z.string().optional(),default_organization:f.z.string().optional(),sessions:f.z.object({oidc_logout_prompt_enabled:f.z.boolean().optional()}).optional(),oidc_logout:f.z.object({rp_logout_end_session_endpoint_discovery:f.z.boolean().optional()}).optional(),allow_organization_name_in_authentication_api:f.z.boolean().optional(),customize_mfa_in_postlogin_action:f.z.boolean().optional(),acr_values_supported:f.z.array(f.z.string()).optional(),mtls:f.z.object({enable_endpoint_aliases:f.z.boolean().optional()}).nullish(),pushed_authorization_requests_supported:f.z.boolean().optional(),authorization_response_iss_parameter_supported:f.z.boolean().optional(),deployment_type:f.z.enum([`shared`,`wfp`]).default(`shared`).optional(),provisioning_state:f.z.enum([`pending`,`ready`,`failed`]).default(`ready`).optional(),provisioning_error:f.z.string().max(2048).optional(),provisioning_state_changed_at:f.z.string().optional(),bundle_configuration:f.z.string().max(64).optional(),worker_version:f.z.string().max(64).optional(),database_version:f.z.string().max(64).optional(),worker_script_name:f.z.string().max(255).optional(),storage_kind:f.z.enum([`own_d1`,`existing_d1`,`shared_planetscale`]).optional(),d1_database_id:f.z.string().max(64).optional(),attack_protection:mF.optional(),mfa:f.z.object({policy:yF.default(`never`).optional(),...bF,factors:f.z.object({sms:f.z.boolean().default(!1),otp:f.z.boolean().default(!1),email:f.z.boolean().default(!1),push_notification:f.z.boolean().default(!1),webauthn_roaming:f.z.boolean().default(!1),webauthn_platform:f.z.boolean().default(!1),recovery_code:f.z.boolean().default(!1),duo:f.z.boolean().default(!1)}).optional(),sms_provider:f.z.object({provider:f.z.enum([`twilio`,`vonage`,`aws_sns`,`phone_message_hook`]).optional()}).optional(),twilio:f.z.object({sid:JM().optional(),auth_token:JM().optional(),from:f.z.string().optional(),messaging_service_sid:f.z.string().optional()}).optional(),phone_message:f.z.object({message:f.z.string().optional()}).optional()}).optional()});f.z.object({created_at:f.z.string().nullable().transform(e=>e??``),updated_at:f.z.string().nullable().transform(e=>e??``)}).extend(xF.shape).extend({id:f.z.string(),is_control_plane:f.z.boolean().optional(),has_children:f.z.boolean().optional()});var SF=xF.shape.mfa.unwrap().shape,CF=f.z.object({...SF,policy:yF.optional(),factors:f.z.object({sms:f.z.boolean().optional(),otp:f.z.boolean().optional(),email:f.z.boolean().optional(),push_notification:f.z.boolean().optional(),webauthn_roaming:f.z.boolean().optional(),webauthn_platform:f.z.boolean().optional(),recovery_code:f.z.boolean().optional(),duo:f.z.boolean().optional()}).optional()});f.z.object(xF.shape).extend({deployment_type:f.z.enum([`shared`,`wfp`]),provisioning_state:f.z.enum([`pending`,`ready`,`failed`]),mfa:CF}).partial();var wF=f.z.enum([`provision`,`seed`,`upgrade`,`backup`,`deprovision`,`users_import`,`sync-defaults`,`detach`,`tenant-members-request`]),TF=f.z.enum([`pending`,`running`,`succeeded`,`failed`,`cancelled`]),EF=f.z.string().max(64);f.z.object({tenant_id:f.z.string().max(255).nullable().default(null),rollout_id:f.z.string().max(255).nullable().optional(),kind:wF,engine:EF,engine_instance_id:f.z.string().max(100).nullable().optional(),target_worker_version:f.z.string().max(255).nullable().optional(),target_database_version:f.z.string().max(255).nullable().optional(),initiated_by:f.z.string().max(255).nullable().optional(),input:f.z.record(f.z.string(),f.z.unknown()).nullable().optional()}).extend({id:f.z.string(),status:TF,current_step:f.z.string().max(255).nullable().optional(),error:f.z.string().nullable().optional(),result:f.z.record(f.z.string(),f.z.unknown()).nullable().optional(),claimed_by:f.z.string().max(255).nullable().optional(),claim_expires_at:f.z.string().nullable().optional(),created_at:f.z.string(),updated_at:f.z.string(),finished_at:f.z.string().nullable().optional()}).pick({status:!0,current_step:!0,engine_instance_id:!0,target_worker_version:!0,target_database_version:!0,error:!0,result:!0,claimed_by:!0,claim_expires_at:!0,finished_at:!0}).partial();var DF=f.z.enum([`started`,`succeeded`,`failed`,`retried`,`skipped`,`reconciled`]);f.z.object({operation_id:f.z.string().max(255),step:f.z.string().max(255),outcome:DF,detail:f.z.record(f.z.string(),f.z.unknown()).nullable().optional(),attempt:f.z.number().int().min(1).default(1)}).extend({id:f.z.string(),created_at:f.z.string()});var OF=f.z.enum([`pending`,`inserted`,`updated`,`failed`,`skipped`]);f.z.object({operation_id:f.z.string().max(255),seq:f.z.number().int().min(0),payload:f.z.record(f.z.string(),f.z.unknown()),status:OF.default(`pending`),error_code:f.z.string().max(64).nullable().optional(),error_message:f.z.string().nullable().optional(),error_path:f.z.string().max(255).nullable().optional(),entity_id:f.z.string().max(255).nullable().optional()}).extend({status:OF,created_at:f.z.string(),updated_at:f.z.string()}),f.z.object({seq:f.z.number().int().min(0),status:OF,error_code:f.z.string().max(64).nullable().optional(),error_message:f.z.string().nullable().optional(),error_path:f.z.string().max(255).nullable().optional(),entity_id:f.z.string().max(255).nullable().optional()});var kF=f.z.enum([`upgrade`,`reseed`,`backup`,`config-sync`]),AF=f.z.enum([`pending`,`canary`,`rolling`,`paused`,`done`,`failed`]);f.z.object({kind:kF,target_worker_version:f.z.string().max(255).nullable().optional(),target_database_version:f.z.string().max(255).nullable().optional(),wave_size:f.z.number().int().min(1).default(10),canary_tenant_ids:f.z.array(f.z.string()).nullable().optional(),filter:f.z.record(f.z.string(),f.z.unknown()).nullable().optional(),initiated_by:f.z.string().max(255).nullable().optional(),config:f.z.record(f.z.string(),f.z.unknown()).nullable().optional()}).extend({id:f.z.string(),status:AF,created_at:f.z.string(),updated_at:f.z.string(),finished_at:f.z.string().nullable().optional(),paused_reason:f.z.string().nullable().optional()}).pick({status:!0,wave_size:!0,canary_tenant_ids:!0,filter:!0,config:!0,paused_reason:!0,finished_at:!0}).partial();var jF=f.z.enum([`invite`,`add_members`,`remove_members`,`assign_roles`,`remove_roles`,`revoke_invitation`]),MF=f.z.enum([`pending`,`succeeded`,`failed`]);f.z.object({kind:jF,requested_by:f.z.string().min(1).max(255),payload:f.z.record(f.z.string(),f.z.unknown())}).extend({id:f.z.string(),tenant_id:f.z.string(),status:MF,result:f.z.record(f.z.string(),f.z.unknown()).nullable().optional(),error:f.z.string().nullable().optional(),notified_at:f.z.string().nullable().optional(),created_at:f.z.string(),updated_at:f.z.string(),finished_at:f.z.string().nullable().optional()}),f.z.object({status:MF.optional(),result:f.z.record(f.z.string(),f.z.unknown()).nullable().optional(),error:f.z.string().nullable().optional(),notified_at:f.z.string().nullable().optional(),finished_at:f.z.string().nullable().optional()}),f.z.object({access_token:f.z.string(),id_token:f.z.string().optional(),scope:f.z.string().optional(),state:f.z.string().optional(),refresh_token:f.z.string().optional(),token_type:f.z.string(),expires_in:f.z.number(),issued_token_type:f.z.string().optional()}),f.z.object({code:f.z.string(),state:f.z.string().optional()});var NF=f.z.object({button_border_radius:f.z.number(),button_border_weight:f.z.number(),buttons_style:f.z.enum([`pill`,`rounded`,`sharp`]),input_border_radius:f.z.number(),input_border_weight:f.z.number(),inputs_style:f.z.enum([`pill`,`rounded`,`sharp`]),show_widget_shadow:f.z.boolean(),widget_border_weight:f.z.number(),widget_corner_radius:f.z.number()}),PF=f.z.object({base_focus_color:f.z.string(),base_hover_color:f.z.string(),body_text:f.z.string(),captcha_widget_theme:f.z.enum([`auto`,`dark`,`light`]),error:f.z.string(),header:f.z.string(),icons:f.z.string(),input_background:f.z.string(),input_border:f.z.string(),input_filled_text:f.z.string(),input_labels_placeholders:f.z.string(),links_focused_components:f.z.string(),primary_button:f.z.string(),primary_button_label:f.z.string(),secondary_button_border:f.z.string(),secondary_button_label:f.z.string(),success:f.z.string(),widget_background:f.z.string(),widget_border:f.z.string()}),FF=PF.omit({captcha_widget_theme:!0}).partial(),IF=f.z.object({bold:f.z.boolean(),size:f.z.number()}),LF=f.z.object({body_text:IF,buttons_text:IF,font_url:f.z.string(),input_labels:IF,links:IF,links_style:f.z.enum([`normal`,`underlined`]),reference_text_size:f.z.number(),subtitle:IF,title:IF}),RF=f.z.object({background_color:f.z.string(),background_image_url:f.z.string(),background_color_dark:f.z.string().optional(),background_image_url_dark:f.z.string().optional(),page_layout:f.z.enum([`center`,`left`,`right`]),logo_placement:f.z.enum([`widget`,`chip`,`none`]).optional()}),zF=f.z.object({header_text_alignment:f.z.enum([`center`,`left`,`right`]),logo_height:f.z.number(),logo_position:f.z.enum([`center`,`left`,`none`,`right`]),logo_url:f.z.string(),logo_url_dark:f.z.string().optional(),social_buttons_layout:f.z.enum([`bottom`,`top`])});f.z.object({borders:NF,colors:PF,colors_dark:FF.optional(),displayName:f.z.string(),fonts:LF,page_background:RF,widget:zF}).extend({themeId:f.z.string()}),f.z.object({..._M,universal_login_experience:f.z.enum([`new`,`classic`]).default(`new`),identifier_first:f.z.boolean().default(!0),password_first:f.z.boolean().default(!1),show_last_used_connection:f.z.boolean().default(!1),webauthn_platform_first_factor:f.z.boolean()});var BF=f.z.object({hosts:f.z.array(f.z.string()).optional(),methods:f.z.array(f.z.string()).optional(),path:f.z.string().default(`/*`),headers:f.z.record(f.z.string(),f.z.string()).optional(),query:f.z.record(f.z.string(),f.z.string()).optional()}),VF=f.z.object({type:f.z.string(),options:f.z.record(f.z.string(),f.z.unknown()).default({})}),HF=f.z.object({id:f.z.string().optional(),custom_domain_id:f.z.string(),priority:f.z.number().int().default(100),match:BF,handlers:f.z.array(VF).min(1)});HF.extend({id:f.z.string(),tenant_id:f.z.string(),created_at:f.z.string(),updated_at:f.z.string()}),HF.partial().omit({id:!0,custom_domain_id:!0});var UF=`custom_authentication`,WF=[`urn:ietf:params:oauth:`,`urn:auth0`,`urn:okta`,`http://auth0.com`,`https://auth0.com`,`http://okta.com`,`https://okta.com`],GF=f.z.string().min(1).max(200).refine(e=>e.startsWith(`https://`)||e.startsWith(`urn:`),{message:`subject_token_type must be a URI starting with https:// or urn:`}).refine(e=>!WF.some(t=>e.toLowerCase().startsWith(t)),{message:`subject_token_type uses a reserved namespace`}),KF=f.z.enum([`RS256`,`RS384`,`RS512`,`ES256`,`ES384`,`ES512`]),qF=f.z.discriminatedUnion(`type`,[f.z.object({type:f.z.literal(`connection`),connection:f.z.string().min(1),create_if_not_exists:f.z.boolean().default(!0),trust_email_verified:f.z.boolean().default(!1)}),f.z.object({type:f.z.literal(`user_id`)})]),JF=f.z.object({issuer:f.z.string().min(1).max(2048),jwks:QP.optional(),jwks_uri:f.z.string().url().optional(),audience:f.z.array(f.z.string().min(1)).min(1).optional(),algorithms:f.z.array(KF).min(1).optional(),max_lifetime_seconds:f.z.number().int().min(1).max(3600).default(300),require_jti:f.z.boolean().default(!0),user_mapping:qF});f.z.object({name:f.z.string().min(1).max(255),subject_token_type:GF,action_id:f.z.string().min(1).optional(),type:f.z.literal(UF),jwt_verification:JF.optional()}).extend({id:f.z.string(),created_at:f.z.string(),updated_at:f.z.string()}),f.z.object({name:f.z.string().min(1).max(255).optional(),subject_token_type:GF.optional(),jwt_verification:JF.optional()});var YF=f.z.enum([`oidc`,`samlp`,`waad`,`google-apps`,`adfs`,`okta`,`auth0-samlp`,`okta-samlp`,`keycloak-samlp`,`pingfederate`]),XF=f.z.object({name:f.z.string(),description:f.z.string(),is_optional:f.z.boolean()}),ZF=f.z.object({logo_url:f.z.string().optional(),colors:f.z.object({primary:f.z.string()}).optional()});f.z.object({name:f.z.string(),description:f.z.string().optional(),allowed_strategies:f.z.array(YF).optional(),user_attributes:f.z.array(XF).optional(),branding:ZF.optional()}).extend({id:f.z.string(),created_at:f.z.string(),updated_at:f.z.string()});var QF=f.z.record(f.z.string(),f.z.string()),$F=f.z.enum([`none`,`optional`,`required`]),eI=f.z.object({icon_url:f.z.string().optional(),domain_aliases:f.z.array(f.z.string()).optional()}),tI=f.z.object({name:f.z.string(),display_name:f.z.string().optional(),is_domain_connection:f.z.boolean().optional(),show_as_button:f.z.boolean().optional(),metadata:f.z.record(f.z.string(),f.z.string()).optional(),options:eI.optional()}),nI=f.z.object({organization_id:f.z.string(),assign_membership_on_login:f.z.boolean().optional(),show_as_button:f.z.boolean().optional()});f.z.object({id:f.z.string(),profile_id:f.z.string(),connection_id:f.z.string().optional(),connection_config:tI.optional(),enabled_clients:f.z.array(f.z.string()),enabled_organizations:f.z.array(nI),domain_verification:$F,expires_at:f.z.string(),revoked_at:f.z.string().optional(),completed_at:f.z.string().optional(),created_at:f.z.string(),updated_at:f.z.string()});var rI=f.z.object({scim:f.z.string(),auth0:f.z.string()}),iI=f.z.object({connection_id:f.z.string(),user_id_attribute:f.z.string().default(`externalId`),mapping:f.z.array(rI).default([])});f.z.object({created_at:f.z.string(),updated_at:f.z.string()}).extend(iI.shape);var aI=f.z.object({token_id:f.z.string(),connection_id:f.z.string(),token_hash:f.z.string(),scopes:f.z.array(f.z.string()).default([]),valid_until:f.z.string().optional()});f.z.object({created_at:f.z.string(),last_used_at:f.z.string().optional()}).extend(aI.shape);var oI=f.z.object({connection_id:f.z.string(),external_id:f.z.string(),user_id:f.z.string()});f.z.object({created_at:f.z.string()}).extend(oI.shape),f.z.object({..._M,name:f.z.string(),enabled:f.z.boolean().optional().default(!0),default_from_address:f.z.string().optional(),credentials:f.z.record(f.z.string(),f.z.unknown()),settings:f.z.object({}).optional()});var sI=f.z.enum([`verify_email`,`verify_email_by_code`,`reset_email`,`reset_email_by_code`,`welcome_email`,`blocked_account`,`stolen_credentials`,`enrollment_email`,`mfa_oob_code`,`change_password`,`password_reset`,`user_invitation`]);f.z.object({template:sI,body:f.z.string(),from:f.z.string(),subject:f.z.string(),syntax:f.z.literal(`liquid`).default(`liquid`),resultUrl:f.z.string().optional(),urlLifetimeInSeconds:f.z.number().int().nonnegative().optional(),includeEmailInRedirect:f.z.boolean().default(!1),enabled:f.z.boolean().default(!0)}),f.z.object({id:f.z.string(),login_id:f.z.string(),session_id:f.z.string().optional(),organization:f.z.string().optional(),auth_connection:f.z.string().optional(),auth_strategy:tF.optional(),session_transfer:eN.optional(),user_id:f.z.string(),client_id:f.z.string(),expires_at:f.z.string().optional(),idle_expires_at:f.z.string().optional(),last_exchanged_at:f.z.string().optional(),device:hF,resource_servers:f.z.array(f.z.object({audience:f.z.string(),scopes:f.z.string()})),rotating:f.z.boolean(),token_lookup:f.z.string().optional(),token_hash:f.z.string().optional(),family_id:f.z.string().optional(),rotated_to:f.z.string().optional(),rotated_at:f.z.string().optional()}).extend({created_at:f.z.string(),revoked_at:f.z.string().optional()}),f.z.object({to:f.z.string(),message:f.z.string()}),f.z.object({name:f.z.string(),options:f.z.object({})});var cI=f.z.object({value:f.z.string(),description:f.z.string().optional()}),lI=f.z.object({token_dialect:f.z.enum([`access_token`,`access_token_authz`]).optional(),enforce_policies:f.z.boolean().optional(),allow_skipping_userinfo:f.z.boolean().optional(),skip_userinfo:f.z.boolean().optional(),persist_client_authorization:f.z.boolean().optional(),enable_introspection_endpoint:f.z.boolean().optional(),mtls:f.z.object({bound_access_tokens:f.z.boolean().optional()}).optional()}),uI=f.z.object({id:f.z.string().optional(),name:f.z.string(),identifier:f.z.string(),scopes:f.z.array(cI).optional(),signing_alg:f.z.string().optional(),signing_secret:JM().optional(),token_lifetime:f.z.number().default(86400),token_lifetime_for_web:f.z.number().default(7200),skip_consent_for_verifiable_first_party_clients:f.z.boolean().optional(),allow_offline_access:f.z.boolean().optional(),verificationKey:f.z.string().optional(),options:lI.optional(),is_system:f.z.boolean().optional(),..._M,metadata:f.z.record(f.z.string(),f.z.any()).optional()}).extend({created_at:f.z.string().optional(),updated_at:f.z.string().optional()});f.z.array(uI);var dI=f.z.object({role_id:f.z.string(),resource_server_identifier:f.z.string(),permission_name:f.z.string()}).extend({created_at:f.z.string()});f.z.array(dI),f.z.object({user_id:f.z.string().openapi({description:`The id of the user that granted the consent`}),clientID:f.z.string().openapi({description:`The id of the client the grant was issued to`}),audience:f.z.string().optional().openapi({description:`The audience the grant applies to`}),scope:f.z.array(f.z.string()).default([]).openapi({description:`The list of OAuth scopes the user has consented to`})}).extend({id:f.z.string()}),f.z.object({user_id:f.z.string(),last_login:f.z.string().optional(),last_ip:f.z.string().optional(),login_count:f.z.number().default(0),failed_logins:f.z.array(f.z.string()).optional(),last_password_reset:f.z.string().optional()});var fI=f.z.object({user_id:f.z.string(),resource_server_identifier:f.z.string(),permission_name:f.z.string(),organization_id:f.z.string().optional()}).extend({tenant_id:f.z.string(),created_at:f.z.string().optional()});f.z.array(fI);var pI=f.z.object({user_id:f.z.string(),resource_server_identifier:f.z.string(),resource_server_name:f.z.string(),permission_name:f.z.string(),description:f.z.string().nullable().optional(),created_at:f.z.string().optional(),organization_id:f.z.string().optional()});f.z.array(pI);var mI=f.z.object({user_id:f.z.string(),role_id:f.z.string(),organization_id:f.z.string().optional()}).extend({tenant_id:f.z.string(),created_at:f.z.string().optional()});f.z.array(mI);var hI=f.z.object({id:f.z.string().optional().openapi({description:`The unique identifier of the role. If not provided, one will be generated.`}),name:f.z.string().min(1).max(50).openapi({description:`The name of the role. Cannot include '<' or '>'`}),description:f.z.string().max(255).optional().openapi({description:`The description of the role`}),is_system:f.z.boolean().optional(),metadata:f.z.record(f.z.string(),f.z.any()).optional().openapi({description:`Metadata associated with the role. Can be used to control sync behavior in multi-tenancy scenarios.`})}).extend({id:f.z.string().openapi({description:`The unique identifier of the role`}),created_at:f.z.string().optional(),updated_at:f.z.string().optional()});f.z.array(hI);var gI=f.z.object({logo_url:f.z.string().optional().openapi({description:`URL of the organization's logo`}),colors:f.z.object({primary:f.z.string().optional().openapi({description:`Primary color in hex format (e.g., #FF0000)`}),page_background:f.z.string().optional().openapi({description:`Page background color in hex format (e.g., #FFFFFF)`})}).optional()}).optional(),_I=f.z.object({connection_id:f.z.string().openapi({description:`ID of the connection`}),assign_membership_on_login:f.z.boolean().default(!1).openapi({description:`Whether to assign membership to the organization on login`}),show_as_button:f.z.boolean().default(!0).openapi({description:`Whether to show this connection as a button in the login screen`}),is_signup_enabled:f.z.boolean().default(!0).openapi({description:`Whether signup is enabled for this connection`})}),vI=f.z.object({client_credentials:f.z.object({enforce:f.z.boolean().default(!1).openapi({description:`Whether to enforce token quota limits`}),per_day:f.z.number().min(0).default(0).openapi({description:`Maximum tokens per day (0 = unlimited)`}),per_hour:f.z.number().min(0).default(0).openapi({description:`Maximum tokens per hour (0 = unlimited)`})}).optional()}).optional();f.z.object({id:f.z.string().optional(),name:f.z.string().min(1).regex(/^[a-z0-9_-]+$/,{message:`Organization name must be lowercase and can only contain letters, numbers, hyphens, and underscores`}).openapi({description:`The name of the organization. Must be lowercase and can only contain letters, numbers, hyphens, and underscores.`}),display_name:f.z.string().optional().openapi({description:`The display name of the organization`}),branding:gI,metadata:f.z.record(f.z.string(),f.z.any()).default({}).optional().openapi({description:`Custom metadata for the organization`}),enabled_connections:f.z.array(_I).default([]).optional().openapi({description:`List of enabled connections for the organization`}),token_quota:vI}).extend(mM.shape).extend({id:f.z.string(),name:f.z.string().min(1).openapi({description:`The name of the organization`})});var yI=f.z.object({connection_id:f.z.string().openapi({description:`ID of the tenant-level connection to enable for the org.`}),assign_membership_on_login:f.z.boolean().optional().default(!1),show_as_button:f.z.boolean().optional().default(!0),is_signup_enabled:f.z.boolean().optional().default(!0)}).extend({connection:f.z.object({name:f.z.string().optional(),strategy:f.z.string().optional()}).optional(),created_at:f.z.string().optional(),updated_at:f.z.string().optional()});f.z.array(yI),f.z.object({user_id:f.z.string().openapi({description:`ID of the user`}),organization_id:f.z.string().openapi({description:`ID of the organization`})}).extend(mM.shape).extend({id:f.z.string()}),f.z.object({date:f.z.string().openapi({description:`Date these events occurred in ISO 8601 format`,example:`2025-12-19`}),logins:f.z.number().openapi({description:`Number of logins on this date`,example:150}),signups:f.z.number().openapi({description:`Number of signups on this date`,example:25}),leaked_passwords:f.z.number().openapi({description:`Number of breached-password detections on this date (subscription required)`,example:0}),updated_at:f.z.string().openapi({description:`Date and time this stats entry was last updated in ISO 8601 format`,example:`2025-12-19T10:30:00.000Z`}),created_at:f.z.string().openapi({description:`Approximate date and time the first event occurred in ISO 8601 format`,example:`2025-12-19T00:00:00.000Z`})}),f.z.number().openapi({description:`Number of active users in the last 30 days`,example:1234}),f.z.enum([`active-users`,`logins`,`signups`,`refresh-tokens`,`sessions`,`logouts`,`password-changes`,`password-migrations`,`mfa`,`email-verifications`,`codes-sent`]),f.z.enum([`hour`,`day`,`week`,`month`]),f.z.enum([`time`,`connection`,`client_id`,`user_type`,`event`]),f.z.enum([`password`,`social`,`passwordless`,`enterprise`]);var bI=f.z.object({cohort:f.z.string(),sessions:f.z.number(),active:f.z.array(f.z.number())});f.z.object({interval:f.z.literal(`week`),from:f.z.string(),to:f.z.string(),cohorts:f.z.array(bI)});var xI=f.z.object({cohort:f.z.string(),tokens:f.z.number(),active:f.z.array(f.z.number())});f.z.object({interval:f.z.literal(`week`),from:f.z.string(),to:f.z.string(),cohorts:f.z.array(xI)});var SI=f.z.object({name:f.z.string(),type:f.z.string()}),CI=f.z.object({elapsed:f.z.number(),rows_read:f.z.number().optional(),bytes_read:f.z.number().optional()});f.z.object({meta:f.z.array(SI),data:f.z.array(f.z.record(f.z.string(),f.z.any())),rows:f.z.number(),rows_before_limit_at_least:f.z.number().optional(),statistics:CI.optional()});var wI=f.z.enum(`login.login-id.login-password.signup.signup-id.signup-password.reset-password.consent.mfa.mfa-push.mfa-otp.mfa-voice.mfa-phone.mfa-webauthn.mfa-email.mfa-recovery-code.status.device-flow.email-verification.email-otp-challenge.organizations.invitation.common.passkeys.captcha.custom-form.login-passwordless.mfa-login-options`.split(`.`)),TI=f.z.record(f.z.string(),f.z.record(f.z.string(),f.z.string())).openapi({type:`object`,additionalProperties:{type:`object`,additionalProperties:{type:`string`}}});f.z.object({prompt:wI,language:f.z.string(),custom_text:TI});var EI=f.z.object({"form-content-start":f.z.string().optional(),"form-content-end":f.z.string().optional(),"form-footer-start":f.z.string().optional(),"form-footer-end":f.z.string().optional(),"secondary-actions-start":f.z.string().optional(),"secondary-actions-end":f.z.string().optional()}).strict(),DI=f.z.record(f.z.string(),EI);f.z.object({prompt:f.z.string(),partials:DI});var OI=f.z.enum([`phone`,`totp`,`email`,`push`,`webauthn-roaming`,`webauthn-platform`,`passkey`]),kI=f.z.object({user_id:f.z.string(),type:OI,phone_number:f.z.string().optional(),totp_secret:f.z.string().optional(),totp_last_step:f.z.number().int().nonnegative().optional(),credential_id:f.z.string().optional(),public_key:f.z.string().optional(),sign_count:f.z.number().int().nonnegative().optional(),credential_backed_up:f.z.boolean().optional(),transports:f.z.array(f.z.string()).optional(),friendly_name:f.z.string().optional(),confirmed:f.z.boolean().default(!1)});function AI(e,t){e.type===`phone`&&!e.phone_number&&t.addIssue({code:f.z.ZodIssueCode.custom,message:`phone_number is required when type is 'phone'`,path:[`phone_number`]}),e.type===`totp`&&!e.totp_secret&&t.addIssue({code:f.z.ZodIssueCode.custom,message:`totp_secret is required when type is 'totp'`,path:[`totp_secret`]}),[`webauthn-roaming`,`webauthn-platform`,`passkey`].includes(e.type)&&(e.credential_id||t.addIssue({code:f.z.ZodIssueCode.custom,message:`credential_id is required when type is '${e.type}'`,path:[`credential_id`]}),e.public_key||t.addIssue({code:f.z.ZodIssueCode.custom,message:`public_key is required when type is '${e.type}'`,path:[`public_key`]}))}kI.superRefine(AI),kI.extend({id:f.z.string(),created_at:f.z.string(),updated_at:f.z.string()}).superRefine(AI),f.z.object({id:f.z.string().optional(),created_at:f.z.string().datetime({offset:!0}).optional(),updated_at:f.z.string().datetime({offset:!0}).optional()}),f.z.enum([`verify_email`,`verify_email_by_code`,`reset_email`,`reset_email_by_code`,`welcome_email`,`verification_code`,`mfa_oob_code`,`enrollment_email`,`blocked_account`,`stolen_credentials`,`try_provider_configuration_email`,`organization_invitation`]),f.z.enum([`otp_verify`,`otp_enroll`,`blocked_account`,`change_password`,`password_breach`]);function jI(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function MI(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}f.z.record(f.z.string(),f.z.record(f.z.string(),QF));var NI=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,PI=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=NI[n[e]&63];return t};async function FI(e){let t=new DecompressionStream(`deflate-raw`),n=new Uint8Array(e),r=new Blob([n]).stream().pipeThrough(t);return new Uint8Array(await new Response(r).arrayBuffer())}async function II(e){let t=MI(e.replace(/ /g,`+`));try{let e=await FI(t);return new TextDecoder().decode(e)}catch(e){return console.warn(`Decompression failed, assuming data is not compressed:`,e),new TextDecoder().decode(t)}}async function LI(e){let t=await II(e),n=new Uj({attributeNamePrefix:`@_`,alwaysCreateTextNode:!0,ignoreAttributes:!1});return ok.parse(n.parse(t))}async function RI(e){let t=e=>e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),n=e.success?`urn:oasis:names:tc:SAML:2.0:status:Success`:`urn:oasis:names:tc:SAML:2.0:status:Responder`,r=e.inResponseTo?` InResponseTo="${t(e.inResponseTo)}"`:``,i=!e.success&&e.statusMessage?`<samlp:StatusMessage>${t(e.statusMessage)}</samlp:StatusMessage>`:``,a=`<samlp:LogoutResponse xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_${PI()}" Version="2.0" IssueInstant="${new Date().toISOString()}" Destination="${t(e.destination)}"${r}><saml:Issuer>${t(e.issuer)}</saml:Issuer><samlp:Status><samlp:StatusCode Value="${n}"/>${i}</samlp:Status></samlp:LogoutResponse>`,o=new Blob([new TextEncoder().encode(a)]).stream().pipeThrough(new CompressionStream(`deflate-raw`)),s=new Uint8Array(await new Response(o).arrayBuffer()),c=``;for(let e of s)c+=String.fromCharCode(e);return btoa(c)}function zI(e){let t=e.certificates.map(e=>({"@_use":`signing`,KeyInfo:{"@_xmlns":`http://www.w3.org/2000/09/xmldsig#`,X509Data:{X509Certificate:e}}})),n={EntityDescriptor:{"@_entityID":e.entityId,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:metadata`,IDPSSODescriptor:{"@_protocolSupportEnumeration":`urn:oasis:names:tc:SAML:2.0:protocol`,KeyDescriptor:t,SingleLogoutService:[{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect`,"@_Location":e.singleLogoutServiceUrl},{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`,"@_Location":e.singleLogoutServiceUrl}],NameIDFormat:[`urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress`,`urn:oasis:names:tc:SAML:2.0:nameid-format:persistent`,`urn:oasis:names:tc:SAML:2.0:nameid-format:transient`],SingleSignOnService:[{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect`,"@_Location":e.assertionConsumerServiceUrl},{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`,"@_Location":e.assertionConsumerServiceUrl}],Attribute:[{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`E-Mail Address`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Given Name`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Name`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Surname`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Name ID`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`}]}}};return new pM({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!1,format:!0,attributeNamePrefix:`@_`}).build(n)}async function BI(e,t){let n=e.notBefore||new Date().toISOString(),r=e.notAfter||new Date(new Date(n).getTime()+600*1e3).toISOString(),i=e.issueInstant||n,a=e.sessionNotOnOrAfter||r,o=e.responseId||`_${PI()}`,s=e.assertionId||`_${PI()}`,c=[{"samlp:Response":[{"saml:Issuer":[{"#text":e.issuer}]},{"samlp:Status":[{"samlp:StatusCode":[],":@":{"@_Value":`urn:oasis:names:tc:SAML:2.0:status:Success`}}]},{"saml:Assertion":[{"saml:Issuer":[{"#text":e.issuer}]},{"saml:Subject":[{"saml:NameID":[{"#text":e.email}],":@":{"@_Format":`urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress`}},{"saml:SubjectConfirmation":[{"saml:SubjectConfirmationData":[],":@":{"@_InResponseTo":e.inResponseTo,"@_NotOnOrAfter":r,"@_Recipient":e.destination}}],":@":{"@_Method":`urn:oasis:names:tc:SAML:2.0:cm:bearer`}}]},{"saml:Conditions":[{"saml:AudienceRestriction":[{"saml:Audience":[{"#text":e.audience}]}]}],":@":{"@_NotBefore":n,"@_NotOnOrAfter":r}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":`urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified`}]}]}],":@":{"@_AuthnInstant":i,"@_SessionIndex":e.sessionIndex,"@_SessionNotOnOrAfter":a}},{"saml:AttributeStatement":[{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.userId}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_FriendlyName":`persistent`,"@_Name":`id`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.email}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`email`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`manage-account`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`default-roles-master`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`offline_access`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`view-profile`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`uma_authorization`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`manage-account-links`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}}]}],":@":{"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`,"@_ID":s,"@_IssueInstant":i,"@_Version":`2.0`}}],":@":{"@_xmlns:samlp":`urn:oasis:names:tc:SAML:2.0:protocol`,"@_xmlns:saml":`urn:oasis:names:tc:SAML:2.0:assertion`,"@_Destination":e.destination,"@_ID":o,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":i,"@_Version":`2.0`}}],l=new pM({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(c);return e.signature&&t&&(l=await t.signSAML(l,e.signature.privateKeyPem,e.signature.cert)),e.encode===!1?l:btoa(l)}var VI=`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect`,HI=`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`,UI={"rsa-sha256":`http://www.w3.org/2001/04/xmldsig-more#rsa-sha256`,"rsa-sha1":`http://www.w3.org/2000/09/xmldsig#rsa-sha1`},WI={"rsa-sha256":`SHA-256`,"rsa-sha1":`SHA-1`};function GI(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/'/g,`&apos;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}async function KI(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`deflate-raw`));return jI(new Uint8Array(await new Response(t).arrayBuffer()))}function qI(e){let t=e.id||`_${PI()}`,n=e.issueInstant||new Date().toISOString(),r=e.nameIdFormat||`urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified`,i=e.forceAuthn?` ForceAuthn="true"`:``;return{id:t,xml:`<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="${GI(t)}" Version="2.0" IssueInstant="${GI(n)}" Destination="${GI(e.destination)}" AssertionConsumerServiceURL="${GI(e.assertionConsumerServiceUrl)}" ProtocolBinding="${HI}"${i}><saml:Issuer>${GI(e.issuer)}</saml:Issuer><samlp:NameIDPolicy Format="${GI(r)}" AllowCreate="true"/></samlp:AuthnRequest>`}}function JI(e,t){let n=e.replace(RegExp(`-----(BEGIN|END) ${t}-----`,`g`),``).replace(/\s/g,``);return Uint8Array.from(MI(n))}async function YI(e){let t=e.parameter||`SAMLRequest`,n=await KI(e.xml),r=`${t}=${encodeURIComponent(n)}`;if(e.relayState&&(r+=`&RelayState=${encodeURIComponent(e.relayState)}`),e.signingKey){let t=e.signingKey.algorithm||`rsa-sha256`;r+=`&SigAlg=${encodeURIComponent(UI[t])}`;let n=await crypto.subtle.importKey(`pkcs8`,JI(e.signingKey.privateKeyPem,`PRIVATE KEY`),{name:`RSASSA-PKCS1-v1_5`,hash:WI[t]},!1,[`sign`]),i=await crypto.subtle.sign(`RSASSA-PKCS1-v1_5`,n,new TextEncoder().encode(r));r+=`&Signature=${encodeURIComponent(jI(new Uint8Array(i)))}`}let i=e.endpoint.indexOf(`#`),a=i===-1?e.endpoint:e.endpoint.slice(0,i),o=i===-1?``:e.endpoint.slice(i);return`${a}${a.includes(`?`)?`&`:`?`}${r}${o}`}function XI(e){let t=e.replace(/\\[rn]/g,`
311
311
  `).trim();if(!t)return;if(t.startsWith(`-----BEGIN`)){let e=t.match(/-----BEGIN CERTIFICATE-----([\s\S]+?)-----END CERTIFICATE-----/)?.[1]?.replace(/\s/g,``);return e&&XI(e)===e?e:void 0}let n=t.replace(/\s/g,``);if(!/^[A-Za-z0-9+/]+=*$/.test(n))return;let r;try{r=MI(n)}catch{return}return new TextDecoder().decode(r.slice(0,64)).trimStart().startsWith(`-----BEGIN`)?XI(new TextDecoder().decode(r)):r[0]===48?n:void 0}function ZI(e){return`-----BEGIN CERTIFICATE-----\n${(e.replace(/\s/g,``).match(/.{1,64}/g)||[]).join(`
312
312
  `)}\n-----END CERTIFICATE-----\n`}var QI=`urn:oasis:names:tc:SAML:2.0:protocol`,$I=new Set([`EntitiesDescriptor`,`EntityDescriptor`,`IDPSSODescriptor`,`X509Certificate`,`SingleSignOnService`,`SingleLogoutService`,`KeyDescriptor`]);function eL(e){if(/<!DOCTYPE|<!ENTITY/i.test(e))throw Error(`SAML documents must not contain a DOCTYPE`)}function tL(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function nL(e){if(Array.isArray(e))return e.map(e=>tL(e)).filter(e=>e!==void 0);let t=tL(e);return t?[t]:[]}function rL(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);let t=tL(e);if(!t)return;let n=t[`#text`];return typeof n==`string`?n:void 0}function iL(e,t){let n=e?.[`@_${t}`];return typeof n==`string`?n:void 0}function aL(e){return nL(e).flatMap(e=>{let t=iL(e,`Binding`),n=iL(e,`Location`);return t&&n?[{binding:t,location:n}]:[]})}function oL(e){eL(e);let t=new Uj({ignoreAttributes:!1,attributeNamePrefix:`@_`,removeNSPrefix:!0,parseTagValue:!1,parseAttributeValue:!1,isArray:e=>$I.has(e)}).parse(e),n=[],r=e=>{n.push(...nL(e.EntityDescriptor));for(let t of nL(e.EntitiesDescriptor))r(t)};r(t);let i=e=>nL(e.IDPSSODescriptor).find(e=>(iL(e,`protocolSupportEnumeration`)||``).split(/\s+/).includes(QI)),a=n.find(e=>i(e)),o=a&&i(a),s=iL(a,`entityID`);if(!a||!o||!s)throw Error(`Metadata does not describe a SAML 2.0 identity provider`);let c=nL(o.KeyDescriptor).filter(e=>{let t=iL(e,`use`);return!t||t===`signing`}).flatMap(e=>nL(tL(e.KeyInfo)?.X509Data).flatMap(e=>(Array.isArray(e.X509Certificate)?e.X509Certificate:[e.X509Certificate]).map(e=>rL(e)?.replace(/\s/g,``)).filter(e=>!!e)));return{entityId:s,singleSignOnServices:aL(o.SingleSignOnService),singleLogoutServices:aL(o.SingleLogoutService),signingCertificates:[...new Set(c)]}}function sL(e,t=VI){return e.find(e=>e.binding===t)||e.find(e=>e.binding===`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect`||e.binding===`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`)}function cL(e){let t={"@_protocolSupportEnumeration":`urn:oasis:names:tc:SAML:2.0:protocol`,"@_AuthnRequestsSigned":e.authnRequestsSigned?`true`:`false`,"@_WantAssertionsSigned":`true`};return e.signingCertificates?.length&&(t.KeyDescriptor=e.signingCertificates.map(e=>({"@_use":`signing`,KeyInfo:{"@_xmlns":`http://www.w3.org/2000/09/xmldsig#`,X509Data:{X509Certificate:e}}}))),t.NameIDFormat=e.nameIdFormats||[`urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress`,`urn:oasis:names:tc:SAML:2.0:nameid-format:persistent`,`urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified`],t.AssertionConsumerService={"@_Binding":HI,"@_Location":e.assertionConsumerServiceUrl,"@_index":`0`,"@_isDefault":`true`},new pM({ignoreAttributes:!1,attributeNamePrefix:`@_`,suppressEmptyNode:!0,suppressBooleanAttributes:!1,format:!0}).build({EntityDescriptor:{"@_xmlns":`urn:oasis:names:tc:SAML:2.0:metadata`,"@_entityID":e.entityId,SPSSODescriptor:t}})}var lL=`urn:oasis:names:tc:SAML:2.0:cm:bearer`,uL=`urn:oasis:names:tc:SAML:2.0:status:Success`,$=class extends Error{code;status;constructor(e,t,n){super(t),this.name=`SamlResponseError`,this.code=e,this.status=n}};function dL(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function fL(e){return(Array.isArray(e)?e:[e]).map(e=>dL(e)).filter(e=>e!==void 0)}function pL(e){if(typeof e==`string`)return e;let t=dL(e);if(!t)return;let n=t[`#text`];return typeof n==`string`?n:``}function mL(e,t){let n=e?.[`@_${t}`];return typeof n==`string`?n:void 0}var hL=new Set([`Assertion`,`EncryptedAssertion`,`AudienceRestriction`,`Audience`,`SubjectConfirmation`,`AuthnStatement`,`AttributeStatement`,`Attribute`,`AttributeValue`]);function gL(e){return eL(e),new Uj({ignoreAttributes:!1,attributeNamePrefix:`@_`,removeNSPrefix:!0,parseTagValue:!1,parseAttributeValue:!1,trimValues:!0,isArray:e=>hL.has(e)}).parse(e)}function _L(e,t){if(e===t)return!0;try{return new URL(e).href===new URL(t).href}catch{return!1}}function vL(e,t){if(e===void 0)return;let n=Date.parse(e);if(Number.isNaN(n))throw new $(`invalid_response`,`Invalid ${t}`);return n}function yL(e){try{return new TextDecoder().decode(MI(e.replace(/\s/g,``)))}catch{throw new $(`invalid_response`,`SAMLResponse is not valid base64`)}}function bL(e){let t=new Map;for(let n of fL(e.AttributeStatement))for(let e of fL(n.Attribute)){let n=mL(e,`Name`);if(!n)continue;let r=e.AttributeValue,i=(Array.isArray(r)?r:[r]).map(e=>pL(e)).filter(e=>e!==void 0);if(i.length===0)continue;let a=t.get(n),o=[...a===void 0?[]:Array.isArray(a)?a:[a],...i];t.set(n,o.length===1?o[0]:o)}return Object.fromEntries(t)}var xL=new Set([`AudienceRestriction`,`OneTimeUse`,`ProxyRestriction`]);async function SL(e){let t=(e.clockSkewSeconds??120)*1e3,n=yL(e.samlResponse),r;try{r=gL(n)}catch(e){throw new $(`invalid_response`,`SAMLResponse could not be parsed: ${e instanceof Error?e.message:String(e)}`)}let i=dL(r.Response);if(!i)throw new $(`invalid_response`,`SAMLResponse is not a samlp:Response`);let a=dL(i.Status),o=dL(a?.StatusCode),s=mL(o,`Value`);if(s!==uL){let e=mL(dL(o?.StatusCode),`Value`),t=pL(a?.StatusMessage)||void 0;throw new $(`idp_error`,`Identity provider returned ${e||s||`no status`}${t?`: ${t}`:``}`,{code:s,subCode:e,message:t})}if(fL(i.EncryptedAssertion).length>0)throw new $(`encrypted_assertion`,`Encrypted assertions are not supported; turn off assertion encryption at the identity provider`);let c=fL(i.Assertion);if(c.length!==1)throw new $(`invalid_response`,`SAMLResponse must contain exactly one assertion, found ${c.length}`);let l=e.idpCertificates.map(e=>XI(e)).filter(e=>!!e).map(e=>ZI(e));if(l.length===0)throw new $(`invalid_signature`,`No identity provider signing certificate is configured`);let u;try{u=await e.verifier.verifySignedReferences(n,l)}catch(e){throw new $(`invalid_signature`,`SAMLResponse signature is invalid: ${e instanceof Error?e.message:String(e)}`)}let d=(e.now??new Date).getTime(),f,p=new Map;for(let e of u){let t;try{t=gL(e)}catch{continue}let n=dL(t.Response);if(n){f=n;for(let e of fL(n.Assertion)){let t=mL(e,`ID`);t&&p.set(t,e)}}for(let e of fL(t.Assertion)){let t=mL(e,`ID`);t&&p.set(t,e)}}if(p.size===0)throw new $(`unsigned`,`Neither the SAMLResponse nor its assertion is signed`);if(p.size>1)throw new $(`invalid_response`,`Signed content contains more than one assertion`);let[[m,h]]=[...p.entries()];if(mL(c[0],`ID`)!==m)throw new $(`invalid_response`,`The signed assertion is not the assertion in the response`);let g=f??i,_=mL(g,`Destination`);if(_&&!_L(_,e.assertionConsumerServiceUrl))throw new $(`recipient_mismatch`,`Response Destination ${_} is not this connection's ACS URL`);let v=mL(g,`InResponseTo`);if(v!==void 0&&v!==e.inResponseTo)throw new $(`in_response_to_mismatch`,`Response InResponseTo does not match the authentication request`);let y=pL(h.Issuer)?.trim()||void 0;if(e.idpEntityId&&y!==e.idpEntityId)throw new $(`issuer_mismatch`,`Assertion Issuer ${y??`(none)`} is not the configured identity provider ${e.idpEntityId}`);let b=dL(h.Conditions),x=Object.keys(b??{}).find(e=>!e.startsWith(`@_`)&&e!==`#text`&&!xL.has(e));if(x)throw new $(`invalid_response`,`Assertion has a condition this service provider does not understand: ${x}`);if(fL(b?.ProxyRestriction).length>0)throw new $(`invalid_response`,`The identity provider restricts passing this login on (ProxyRestriction), which this service provider cannot honour`);let S=vL(mL(b,`NotBefore`),`NotBefore`),ee=mL(b,`NotOnOrAfter`),te=vL(ee,`NotOnOrAfter`);if(S!==void 0&&d+t<S)throw new $(`not_yet_valid`,`Assertion is not yet valid`);if(te!==void 0&&d-t>=te)throw new $(`expired`,`Assertion has expired`);let ne=fL(b?.AudienceRestriction);if(!(ne.length>0&&ne.every(t=>(Array.isArray(t.Audience)?t.Audience:[t.Audience]).some(t=>pL(t)?.trim()===e.spEntityId))))throw new $(`audience_mismatch`,`Assertion audience does not include ${e.spEntityId}`);let re=dL(h.Subject),ie=re?.NameID,ae=pL(ie)?.trim();if(!ae)throw new $(`missing_subject`,`Assertion has no NameID (encrypted NameIDs are not supported)`);let oe,se;if(!fL(re?.SubjectConfirmation).some(n=>{if(mL(n,`Method`)!==lL)return!1;let r=dL(n.SubjectConfirmationData),i=mL(r,`Recipient`),a=mL(r,`NotOnOrAfter`),o=mL(r,`InResponseTo`);try{let n=vL(a,`SubjectConfirmationData NotOnOrAfter`);if(n===void 0||d-t>=n)throw new $(`expired`,`Subject confirmation has expired`);if(!i||!_L(i,e.assertionConsumerServiceUrl))throw new $(`recipient_mismatch`,`Subject confirmation Recipient ${i??`(none)`} is not this connection's ACS URL`);if(o!==e.inResponseTo)throw new $(`in_response_to_mismatch`,e.inResponseTo?`Assertion does not answer this authentication request`:`Unsolicited response refers to an authentication request`)}catch(e){if(e instanceof $)return oe??=e,!1;throw e}return se=a,!0}))throw oe??new $(`invalid_response`,`Assertion has no bearer subject confirmation`);let ce=fL(h.AuthnStatement)[0];if(!ce)throw new $(`invalid_response`,`Assertion has no AuthnStatement`);let le=vL(mL(ce,`SessionNotOnOrAfter`),`SessionNotOnOrAfter`);if(le!==void 0&&d-t>=le)throw new $(`expired`,`Authentication session has expired`);return{assertionId:m,issuer:y,nameId:ae,nameIdFormat:mL(dL(ie),`Format`),sessionIndex:mL(ce,`SessionIndex`),authnInstant:mL(ce,`AuthnInstant`),inResponseTo:e.inResponseTo,attributes:bL(h),notOnOrAfter:se??ee}}function CL(e,t){let n=e[`@_${t}`];return typeof n==`string`?n:void 0}function wL(e){eL(e);let t=new Uj({ignoreAttributes:!1,attributeNamePrefix:`@_`,removeNSPrefix:!0,parseTagValue:!1,parseAttributeValue:!1,trimValues:!0}).parse(e).AuthnRequest;if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`SAMLRequest is not an AuthnRequest`);let n=t,r=CL(n,`ID`);if(!r)throw Error(`AuthnRequest has no ID`);let i=n.Issuer,a=typeof i==`string`?i:i&&typeof i==`object`?i[`#text`]:void 0;return{id:r,issuer:typeof a==`string`&&a?a:void 0,assertionConsumerServiceUrl:CL(n,`AssertionConsumerServiceURL`),destination:CL(n,`Destination`),protocolBinding:CL(n,`ProtocolBinding`),issueInstant:CL(n,`IssueInstant`),forceAuthn:[`true`,`1`].includes(CL(n,`ForceAuthn`)?.trim().toLowerCase()??``)}}function TL(e){return new TextDecoder().decode(MI(e.replace(/\s/g,``)))}var EL={"http://www.w3.org/2001/04/xmldsig-more#rsa-sha256":`SHA-256`,"http://www.w3.org/2001/04/xmldsig-more#rsa-sha512":`SHA-512`,"http://www.w3.org/2000/09/xmldsig#rsa-sha1":`SHA-1`};function DL(e){let t=new Map;for(let n of e.replace(/^\?/,``).split(`&`)){if(!n)continue;let e=n.indexOf(`=`),r=decodeURIComponent(e===-1?n:n.slice(0,e));if(t.has(r))throw Error(`Query parameter ${r} is repeated`);t.set(r,e===-1?``:n.slice(e+1))}return t}async function OL(e){let t=DL(e.rawQuery),n=t.get(e.parameter),r=t.get(`SigAlg`),i=t.get(`Signature`);if(n===void 0||!r||!i)throw Error(`The request is not signed`);let a=decodeURIComponent(r.replace(/\+/g,`%20`)),o=EL[a];if(!o)throw Error(`Unsupported SigAlg ${a}`);let s=t.get(`RelayState`),c=new TextEncoder().encode(`${e.parameter}=${n}`+(s===void 0?``:`&RelayState=${s}`)+`&SigAlg=${r}`),l;try{l=Uint8Array.from(MI(decodeURIComponent(i.replace(/\+/g,`%20`)).replace(/\s/g,``)))}catch{return!1}for(let t of e.spkiKeys){let e;try{e=await crypto.subtle.importKey(`spki`,Uint8Array.from(t),{name:`RSASSA-PKCS1-v1_5`,hash:o},!1,[`verify`])}catch{continue}if(await crypto.subtle.verify(`RSASSA-PKCS1-v1_5`,e,l,c))return!0}return!1}var kL=class{signUrl;constructor(e){this.signUrl=e}async signSAML(e,t,n){let r=await fetch(this.signUrl,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({xmlContent:e,privateKey:t,publicCert:n})});if(!r.ok)throw Error(`Failed to sign SAML via HTTP: ${r.status} ${r.statusText}`);return await r.text()}};function AL(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function jL(e,t,n){let r=`
313
313
  <!DOCTYPE html>
@@ -327,7 +327,7 @@ type ActionAPI = {
327
327
  }};
328
328
  <\/script>
329
329
  </body>
330
- </html>`;return new Response(r,{headers:{"Content-Type":`text/html`}})}async function ML(e,t,n,r,i,a){let o=i=>O(e,t.tenant.id,{type:E.FAILED_LOGIN,description:`SAML: ${i}`,userId:r?.user_id,username:r?.email,login_session_id:a,details:{client_id:t.client_id,reason:i,redirect_uri:n.redirect_uri}});function s(e,t){throw o(t),new k(e,{message:t})}n.redirect_uri||s(400,`Missing redirect_uri in authParams`),r.email||s(400,`Missing email in user`);let c;try{[c]=await BD(e.env.data.keys,t.tenant.id,e.env.signingKeyMode,{purpose:`sign`,type:`saml_encryption`})}catch(e){throw o(`Failed to resolve signing key`),e}c||s(500,`No signing key found`),t.addons?.samlp||s(400,`SAML Addon is not enabled for client ${t.client_id}`);let{recipient:l,audience:u}=t.addons.samlp,d=n.state||``;(!l||!d||!r||!n.state)&&s(400,`Missing recipient or inResponseTo`);let f,p;try{f=JSON.parse(n.state),p=new URL(n.redirect_uri)}catch(e){throw o(`Invalid state or redirect_uri: ${e instanceof Error?e.message:String(e)}`),e}let m=e.env.samlSigner||(e.env.SAML_SIGN_URL?new kL(e.env.SAML_SIGN_URL):void 0),h=r.app_metadata?.vimeo?.user_id,g=h||r.user_id,_=u||n.client_id,v;try{v=await BI({issuer:e.env.ISSUER,audience:_,destination:p.toString(),inResponseTo:f.requestId,userId:g,email:r.email,sessionIndex:i,signature:{privateKeyPem:c.pkcs7,cert:c.cert,kid:c.kid}},m)}catch(e){throw o(`Failed to create SAML response: ${e instanceof Error?e.message:String(e)}`),e}return O(e,t.tenant.id,{type:E.INFORMATION,description:`SAML assertion issued`,userId:r.user_id,username:r.email,audience:_,login_session_id:a,details:{client_id:t.client_id,name_id:r.email,id_attribute:g,id_attribute_source:h?`app_metadata.vimeo.user_id`:`user_id`,audience:_,destination:p.toString(),signing_key_kid:c.kid,in_response_to:f.requestId}}),jL(p.toString(),v,f.relayState)}var NL=[/^10\./,/^192\.168\./,/^172\.(1[6-9]|2\d|3[01])\./,/^169\.254\./,/^127\./,/^0\./,/^100\.(6[4-9]|[7-9]\d|1[01]\d|12[0-7])\./],PL=new Set([`localhost`,`ip6-localhost`,`ip6-loopback`,`broadcasthost`]);function FL(e){let t=e.replace(/^\[|\]$/g,``).toLowerCase();if(t===`::`||t===`::1`||t.startsWith(`fc`)||t.startsWith(`fd`))return!0;let n=t.split(`:`)[0];if(n&&/^[0-9a-f]+$/.test(n)){let e=parseInt(n,16);if(!Number.isNaN(e)&&e>=65152&&e<=65215)return!0}let r=IL(t);return!!(r&&LL(r))}function IL(e){let t=e.match(/^::(?:ffff:)?(\d+\.\d+\.\d+\.\d+)$/);if(t&&t[1])return t[1];let n=e.match(/^::(?:ffff:)?([0-9a-f]{1,4}):([0-9a-f]{1,4})$/);if(n&&n[1]&&n[2]){let e=parseInt(n[1],16),t=parseInt(n[2],16);if(!Number.isNaN(e)&&!Number.isNaN(t))return[e>>8,e&255,t>>8,t&255].join(`.`)}return null}function LL(e){return/^\d+\.\d+\.\d+\.\d+$/.test(e)?NL.some(t=>t.test(e)):!1}function RL(e){let t=e.ALLOW_PRIVATE_OUTBOUND_FETCH===!0;return{allowPrivateHosts:t,allowedSchemes:t?[`http:`,`https:`]:[`https:`]}}var zL=class extends Error{constructor(e){super(`SSRF check failed: ${e}`),this.name=`SsrfBlockedError`}};function BL(e,t={}){let n=t.allowedSchemes??[`https:`],r;try{r=new URL(e)}catch{throw new zL(`invalid URL`)}if(!n.includes(r.protocol))throw new zL(`scheme ${r.protocol} not allowed`);if(t.allowPrivateHosts)return r;let i=r.hostname.toLowerCase();if(PL.has(i))throw new zL(`hostname ${i} blocked`);if(LL(i))throw new zL(`IPv4 ${i} is in a blocked range`);if(i.includes(`:`)&&FL(i))throw new zL(`IPv6 ${i} is in a blocked range`);return r}async function VL(e,t={}){let n=BL(e,t),r=t.maxBytes??64*1024,i=t.timeoutMs??5e3,a=new AbortController,o=setTimeout(()=>a.abort(),i);try{let e=await fetch(n,{method:`GET`,redirect:`manual`,signal:a.signal,headers:{accept:t.accept??`application/json, application/jwt, text/plain`}});if(e.status>=300&&e.status<400)throw new zL(`redirect (status ${e.status}) not allowed`);if(!e.body)return{status:e.status,body:``,contentType:e.headers.get(`content-type`)};let i=e.body.getReader(),o=[],s=0;for(;;){let{value:e,done:t}=await i.read();if(t)break;if(e){if(s+=e.byteLength,s>r)throw await i.cancel(),new zL(`response body exceeds ${r} bytes`);o.push(e)}}let c=new Uint8Array(s),l=0;for(let e of o)c.set(e,l),l+=e.byteLength;return{status:e.status,body:new TextDecoder().decode(c),contentType:e.headers.get(`content-type`)}}finally{clearTimeout(o)}}var HL=120,UL=5*1024,WL=[`authorization_code`,`refresh_token`];function GL(e){if(!/^https?:\/\//i.test(e))return!1;try{return new URL(e),!0}catch{return!1}}function KL(e,t){return GL(e)&&t||void 0}var qL=f.z.object({client_id:f.z.string().url(),client_name:f.z.string().min(1),grant_types:f.z.array(f.z.string()).refine(e=>e.some(e=>WL.includes(e)),{message:`grant_types must include authorization_code or refresh_token`}),redirect_uris:f.z.array(f.z.string().url()).optional(),application_type:f.z.enum([`native`,`web`]).optional(),token_endpoint_auth_method:f.z.enum([`none`,`private_key_jwt`]).optional(),jwks_uri:f.z.string().url().optional()});function JL(e){throw new k(400,{message:`Invalid CIMD client: ${e}`})}function YL(e){Buffer.byteLength(e,`utf8`)>HL&&JL(`client_id exceeds ${HL} bytes`);let t;try{t=new URL(e)}catch{JL(`client_id is not a valid URL`)}return(t.username||t.password)&&JL(`URL must not contain credentials`),t.hash&&JL(`URL must not contain a fragment`),t.search&&JL(`URL must not contain a query string`),t.port===`0`&&JL(`URL must not use port 0`),(t.pathname===``||t.pathname===`/`)&&JL(`URL must contain a path`),t}function XL(e){return e===`native`?`native`:`regular_web`}async function ZL(e,t={}){YL(e);let n;try{n=await VL(e,{...t,maxBytes:UL})}catch(e){throw e instanceof zL&&JL(e.message),e}n.status!==200&&JL(`document fetch returned status ${n.status}`);let r;try{r=JSON.parse(n.body)}catch{JL(`document is not valid JSON`)}let i=qL.safeParse(r);i.success||JL(i.error.issues.map(e=>e.message).join(`; `));let a=i.data;a.client_id!==e&&JL(`document client_id does not match the requested URL`);let o=a.token_endpoint_auth_method??`none`;o===`private_key_jwt`&&!a.jwks_uri&&JL(`jwks_uri is required when token_endpoint_auth_method is private_key_jwt`);let s=a.grant_types.filter(e=>WL.includes(e)),c=new Date().toISOString();return{...tt.parse({client_id:e,name:a.client_name,app_type:XL(a.application_type),is_first_party:!1,token_endpoint_auth_method:o,grant_types:s,callbacks:a.redirect_uris??[],connections:[],...a.jwks_uri?{client_metadata:{jwks_uri:a.jwks_uri}}:{},created_at:c,updated_at:c}),client_secret:void 0}}tt.extend({tenant:hi,connections:f.z.array(Ut)});function QL(e,t){return[...new Set([...t||[],...e||[]])]}function $L(e,t){return{...e,callbacks:QL(e.callbacks,t.callbacks),web_origins:QL(e.web_origins,t.web_origins),allowed_logout_urls:QL(e.allowed_logout_urls,t.allowed_logout_urls),allowed_origins:QL(e.allowed_origins,t.allowed_origins)}}function eR(e,t,n,r){let i=wc(e,void 0,`u2`),a=wc(e,void 0,`u`);return{...t,web_origins:[...t.web_origins||[],`${i}login`,`${a}login`],allowed_logout_urls:[...t.allowed_logout_urls||[],e.ISSUER],callbacks:[...t.callbacks||[],`${i}info`,`${a}info`],tenant:n,connections:r.filter(e=>e.strategy!==Go.EXTERNAL)}}async function tR(e,t,n){if(!await e.data.clients.get(t,n.client_id))try{await e.data.clients.create(t,{client_id:n.client_id,name:n.name,app_type:n.app_type,is_first_party:!1,token_endpoint_auth_method:n.token_endpoint_auth_method,grant_types:n.grant_types,client_metadata:{cimd:`true`}})}catch(r){if(!await e.data.clients.get(t,n.client_id))throw r}}async function nR(e,t,n,r){if(GL(t)){let i=n;if(i||=(await e.data.clients.getByClientId(t))?.tenant_id,!i)throw new k(400,{message:`tenant_id is required to resolve a CIMD client`});let a=await e.data.tenants.get(i);if(!a)throw new k(404,{message:`Tenant not found`});if(a.flags?.client_id_metadata_document_registration!==!0)throw new k(403,{message:`Client not found`});let o=await ZL(t,r),s=await e.data.connections.list(i);return await tR(e,i,o),eR(e,o,a,hu(s.connections))}let i,a=n;if(!a){let n=await e.data.clients.getByClientId(t);if(!n)throw new k(403,{message:`Client not found`});let{tenant_id:r,...o}=n;i=o,a=r}let o=e.data.multiTenancyConfig,s=o?.controlPlaneTenantId,c=o?.controlPlaneClientId;if(o?.resolveControlPlane){let e=await o.resolveControlPlane({tenant_id:a});s=e?.tenantId,c=e?.clientId??c}let l=!!s&&!!c&&!(a===s&&t===c),[u,d,f,p,m]=await Promise.all([i?Promise.resolve(i):e.data.clients.get(a,t),e.data.tenants.get(a),e.data.clientConnections.listByClient(a,t),e.data.connections.list(a),l?e.data.clients.get(s,c):Promise.resolve(null)]),h=i||u;if(!h)throw new k(403,{message:`Client not found`});let g=m?$L(h,m):h;if(g.client_metadata?.status===`deleted`)throw new k(403,{message:`Client not found`});if(!d)throw new k(404,{message:`Tenant not found`});return eR(e,g,d,f.length>0?f:hu(p.connections||[]))}function rR(e){return iR(e)}function iR(e){let{registration_completed_at:t,password:n,password_hash:r,custom_password_hash:i,...a}=e;return a}function aR(e){let t=new Set,n=e;for(;n&&n!==Object.prototype;){for(let e of Object.getOwnPropertyNames(n))e!==`constructor`&&t.add(e);n=Object.getPrototypeOf(n)}return Array.from(t)}function oR(e){let t=Reflect.get(e,`webSocket`);return e.status===101||t!=null}function sR(e){return oR(e)?e:new Response(e.body,e)}function cR(e){e.res=sR(e.res)}function lR(e,t,n){let r=e.get(`serverTiming`);r?r.push({name:t,dur:n}):e.set(`serverTiming`,[{name:t,dur:n}])}function uR(e,t){return e?t.split(`,`).map(e=>e.trim()).filter(Boolean).includes(e):!1}var dR=async(e,t)=>{await t();let n=e.env.SERVER_TIMING??`off`;if(n===`off`)return;let r=e.get(`serverTiming`);if(!r||r.length===0)return;let i=r.map(e=>`${e.name};dur=${e.dur.toFixed(2)}`).join(`, `);if((n===`log`||n===`both`)&&console.log(JSON.stringify({msg:`server-timing`,method:e.req.method,path:e.req.path,ip:e.get(`ip`),tenant_id:e.get(`tenant_id`),timing:i})),n===`client`||n===`both`){if(e.res.status===101||`webSocket`in e.res)return;let t=e.env.SERVER_TIMING_IPS;if(!t||uR(e.get(`ip`),t)){cR(e);let t=e.res.headers.get(`Server-Timing`);e.res.headers.set(`Server-Timing`,t?`${t}, ${i}`:i)}}};function fR(e){if(!e)return`unknown`;let t=e.indexOf(`:`);return t===-1?e:e.slice(0,t)}function pR(e,t){let n=async(t,n)=>{let r=performance.now();try{return await n()}finally{lR(e,t,performance.now()-r)}};return{get(e){return n(`cache-get:${fR(e)}`,()=>t.get(e))},set(e,r,i){return n(`cache-set:${fR(e)}`,()=>t.set(e,r,i))},delete(e){return n(`cache-delete:${fR(e)}`,()=>t.delete(e))},deleteByPrefix(e){return n(`cache-deleteByPrefix:${fR(e)}`,()=>t.deleteByPrefix(e))},clear(){return n(`cache-clear`,()=>t.clear())}}}function mR(e,t){let n={};for(let[r,i]of Object.entries(t)){if(i==null)continue;if(typeof i==`function`){n[r]=i;continue}let t={};for(let n of aR(i)){let a=i[n];if(typeof a==`function`){let o=a.bind(i);t[n]=async(...t)=>{let i=performance.now();try{let a=await o(...t);return lR(e,`${r}-${n}`,performance.now()-i),a}catch(t){throw lR(e,`${r}-${n}-error`,performance.now()-i),t}}}else t[n]=a}n[r]=t}return n}function hR(e,t){e.set(`data`,t),e.env.data=t}function gR(e){return e.var.executorData??e.var.data??e.env.data}function _R(e,t){return e.var.baseData??t}async function vR(e,t,n){n?.user&&(n={...n,user:rR(n.user)});let r=e.env.webhookInvoker,i=async(t=`webhook`)=>(await hO(e,n.tenant_id,t)).access_token,a,o;try{let s=performance.now(),c=r?await r({hook:t,data:n,tenant_id:n.tenant_id,createServiceToken:i}):await fetch(t.url,{method:`POST`,headers:{Authorization:`Bearer ${await i()}`,"Content-Type":`application/json`},body:JSON.stringify(n)}),l=performance.now()-s;if(lR(e,`webhook-${t.hook_id}`,l),o=c.status,c.ok)await O(e,n.tenant_id,{type:E.SUCCESS_HOOK,description:`Invoked hook ${t.hook_id} - ${c.status}`,userId:n.user?.user_id,details:{trigger_id:n.trigger_id,hook_id:t.hook_id,hook_url:t.url,user_id:n.user?.user_id,user_name:n.user?.name||n.user?.email,connection:n.user?.connection,duration_ms:Math.round(l),response:{statusCode:o}},connection:n.user?.connection});else{try{a=await c.text()}catch{}let r=`Failed to invoke hook ${t.hook_id} - ${c.status} ${c.statusText}`;console.error(r,{hook_url:t.url,body:a?.substring(0,512)}),await O(e,n.tenant_id,{type:E.FAILED_HOOK,description:r,userId:n.user?.user_id,details:{trigger_id:n.trigger_id,hook_id:t.hook_id,hook_url:t.url,user_id:n.user?.user_id,user_name:n.user?.name||n.user?.email,connection:n.user?.connection,response:{statusCode:o,body:a?.substring(0,512)}},connection:n.user?.connection,waitForCompletion:!0})}return{ok:c.ok,status:o,body:a}}catch(r){let i=`Failed to invoke hook ${t.hook_id} - ${r instanceof Error?r.message:`Unknown error`}`;return console.error(i,r),await O(e,n.tenant_id,{type:E.FAILED_HOOK,description:i,userId:n.user?.user_id,details:{trigger_id:n.trigger_id,hook_id:t.hook_id,hook_url:t.url,user_id:n.user?.user_id,user_name:n.user?.name||n.user?.email,connection:n.user?.connection,error:r instanceof Error?r.message:String(r)},connection:n.user?.connection,waitForCompletion:!0}),{ok:!1,error:r instanceof Error?r.message:String(r)}}}async function yR(e,t,n){for(let r of t.filter(e=>`url`in e))await vR(e,r,n)}function bR(e){return async(t,n)=>{let{hooks:r}=await gR(e).hooks.list(t);await yR(e,r.filter(e=>e.trigger_id===`pre-user-registration`),{tenant_id:t,email:n,trigger_id:`pre-user-registration`})}}async function xR(e,t){let{hooks:n}=await gR(e).hooks.list(t);return n.find(e=>e.trigger_id===`validate-registration-username`&&`url`in e&&e.enabled)||null}function SR(e){return async(t,n)=>{let{hooks:r}=await gR(e).hooks.list(t);return await yR(e,r.filter(e=>e.trigger_id===`pre-user-deletion`),{tenant_id:t,user:n,trigger_id:`pre-user-deletion`}),n}}function CR(e){return e===`post-user-login`?`post-login`:e}function wR(e){return`code_id`in e}function TR(e,t){let{ctx:n,client:r,...i}=e;return{...i,client:r?{client_id:r.client_id,name:r.name,metadata:r.client_metadata}:void 0,secrets:t||{}}}async function ER(e,t){for(let n of e){let e=n.method.split(`.`);if(e.length!==2)continue;let r=e[0],i=e[1];t[r]&&typeof t[r][i]==`function`&&await t[r][i](...n.args)}}function DR(e){return e?e.reduce((e,t)=>(t.value!==void 0&&(e[t.name]=t.value),e),{}):{}}async function OR(e,t,n){let r=await e.actions.get(t,n);if(r){let n=e.multiTenancyConfig?.controlPlaneTenantId;if(r.inherit&&e.multiTenancyConfig?.resolveControlPlane&&(n=(await e.multiTenancyConfig.resolveControlPlane({tenant_id:t}))?.tenantId),r.inherit&&n&&n!==t){let{actions:t}=await e.actions.list(n,{q:`name:${D(r.name)}`,per_page:5}),i=t.find(e=>e.name===r.name&&e.is_system);if(i)return{code:i.code,name:r.name,secrets:{...DR(i.secrets),...DR(r.secrets)}}}return{code:r.code,name:r.name,secrets:DR(r.secrets)}}let i=await e.hookCode.get(t,n);return i?{code:i.code,name:n,secrets:i.secrets}:null}var kR=`fail_closed`;function AR(e){let t=e.metadata?.[kR];return t===!0||t===`true`}function jR(e,t,n=!1){let r=new Date().toISOString();return{result:{action_name:e,error:{id:n?`access_denied`:`execution_threw`,msg:t instanceof Error?t.message:String(t)},started_at:r,ended_at:r},logs:[],denied:n,...n?{}:{failure:`action_failed`}}}function MR(e){let t=new Date().toISOString();return{result:{action_name:e,error:{id:`execution_failed`,msg:`No code executor configured`},started_at:t,ended_at:t},logs:[],denied:!1,failure:`action_failed`}}async function NR(e){let{codeExecutor:t,data:n,tenantId:r,hook:i,event:a,triggerId:o,api:s}=e,c=await OR(n,r,i.code_id),l=new Date().toISOString();if(!c)return{result:{action_name:i.code_id,error:{id:`code_not_found`,msg:`code_id ${i.code_id} not found`},started_at:l,ended_at:new Date().toISOString()},logs:[],denied:!1,failure:`action_failed`};let u=TR(a,c.secrets);e.idempotencyKey&&(u.idempotency_key=e.idempotencyKey);let d=5e3,f,p=!1,m;try{m=await Promise.race([t.execute({code:c.code,hookCodeId:i.code_id,triggerId:o,event:u,timeoutMs:d}),new Promise(e=>{f=setTimeout(()=>{p=!0,e({success:!1,error:`Action execution timed out after ${d}ms`,durationMs:d,apiCalls:[]})},d)})])}finally{f!==void 0&&clearTimeout(f)}let h=new Date().toISOString();if(!m.success)return{result:{action_name:c.name,error:{id:`execution_failed`,msg:m.error||`Unknown error`},started_at:l,ended_at:h},logs:m.logs??[],denied:!1,failure:p?`action_timeout`:`action_failed`};await ER(m.apiCalls,s);let g=m.apiCalls.some(e=>e.method===`access.deny`);return{result:{action_name:c.name,error:null,started_at:l,ended_at:h},logs:m.logs??[],denied:g}}async function PR(e,t,n,r,i,a){let o=e.env.codeExecutor;if(!o)return null;let s=e.var.tenant_id||e.req.header(`tenant-id`);return s?NR({codeExecutor:o,data:t,tenantId:s,hook:n,event:r,triggerId:i,api:a}):null}function FR(e,t=256){let n=e.reduce((e,t)=>e+t.lines.reduce((e,t)=>e+t.message.length,0),0);if(n<=t)return e;let r=t,i=0,a=[];for(let t of e){let e=[];for(let n of t.lines){if(r<=0){i+=1;continue}n.message.length<=r?(e.push(n),r-=n.message.length):(e.push({...n,message:n.message.slice(0,r)}),r=0,i+=1)}e.length>0&&a.push({action_name:t.action_name,lines:e})}let o=a[a.length-1];return o&&o.lines.push({level:`warn`,message:`[authhero] console output truncated at ${t} characters (${n} captured, ${i} line(s) truncated or dropped)`}),a}function IR(e,t=`full`){return t===`full`?e:t===`errors`?e.filter(e=>e.denied||!!e.result.error):[]}async function LR(e,t,n,r,i={}){if(r.length===0)return null;let a=crypto.randomUUID(),o=r.some(e=>e.denied)?`canceled`:r.some(e=>e.result.error)?`partial`:`final`,s=FR(IR(r,i.logCapture).filter(e=>e.logs.length>0).map(e=>({action_name:e.result.action_name,lines:e.logs})));return await e.actionExecutions.create(t,{id:a,trigger_id:CR(n),status:o,results:r.map(e=>e.result),logs:s.length>0?s:void 0}),a}async function RR(e,t,n,r){let i=e.var.tenant_id||e.req.header(`tenant-id`);if(!i)return null;let a=t.filter(e=>!!e.enabled&&e.trigger_id===`credentials-exchange`&&wR(e)),o=[],s=()=>LR(e.env.data,i,`credentials-exchange`,o,{logCapture:e.env.actionExecutionLogs});for(let t of a){let i=AR(t),a;try{a=await PR(e,gR(e),t,n,`credentials-exchange`,r),!a&&i&&(a=MR(t.code_id))}catch(n){let r=n instanceof p.HTTPException;a=jR(t.code_id,n,r),r&&(o.push(a),await zR(e,s,n))}if(a&&(o.push(a),a.failure&&i)){a.denied=!0;try{r.access.deny(`access_denied`,a.failure)}catch(t){await zR(e,s,t)}}}return s()}async function zR(e,t,n){try{let n=await t();n&&e.set(`action_execution_id`,n)}catch(e){console.warn(`Failed to persist denied action execution:`,e)}throw n}var BR=`hook.`,VR=class{name=`code-hooks`;data;codeExecutor;logCapture;constructor(e,t,n={}){this.data=e,this.codeExecutor=t,this.logCapture=n.logCapture}accepts(e){return e.event_type.startsWith(BR)}transform(e){return{eventId:e.id,tenantId:e.tenant_id,triggerId:e.event_type.slice(5),user:e.target?.after,userId:e.target?.id,previousUser:e.target?.before,updates:e.details?.updates,request:e.request}}async deliver(e){let t=this.codeExecutor;for(let n of e){if(!t&&n.triggerId!==`post-user-update`&&n.triggerId!==`post-user-deletion`)continue;let e=(await this.listAllHooks(n.tenantId)).filter(e=>e.enabled&&e.trigger_id===n.triggerId&&wR(e)).sort((e,t)=>(t.priority??0)-(e.priority??0));if(e.length===0)continue;let r={user:n.user,user_id:n.userId,request:n.request,tenant:{id:n.tenantId},...n.previousUser!==void 0&&{previous_user:n.previousUser},...n.updates!==void 0&&{updates:n.updates}},i=[];for(let a of e)if(wR(a))try{if(!t)throw Error(`No code executor configured`);i.push(await NR({codeExecutor:t,data:this.data,tenantId:n.tenantId,hook:a,event:r,triggerId:n.triggerId,api:{user:{}},idempotencyKey:n.eventId}))}catch(e){let t=e instanceof Error?e.message:String(e);i.push({result:{action_name:a.code_id,error:{id:`execution_threw`,msg:t},started_at:new Date().toISOString(),ended_at:new Date().toISOString()},logs:[],denied:!1})}await LR(this.data,n.tenantId,n.triggerId,i,{logCapture:this.logCapture});let a=i.filter(e=>e.result.error);if(a.length>0){let e=a.map(e=>`${e.result.action_name}: ${e.result.error?.msg}`).join(`; `);throw Error(`${a.length} code hook(s) failed for ${n.triggerId}: ${e}`)}}}async listAllHooks(e){let t=[];for(let n=0;;n++){let{hooks:r}=await this.data.hooks.list(e,{page:n,per_page:100});if(t.push(...r),r.length<100)break}return t}};function HR(e){return!!(e.env.outbox?.enabled&&e.env.data.outbox)}function UR(e,t,n,r,i={}){if(HR(e))return WR(e,t,n,r,i)}function WR(e,t,n,r,i){return{tenant_id:t,event_type:`hook.${n}`,log_type:E.SUCCESS_API_OPERATION,description:`Enqueued ${n} hook dispatch`,category:`system`,actor:{type:e.var.user_id?`admin`:e.var.client_id?`client_credentials`:`system`,id:e.var.user_id||void 0,client_id:e.var.client_id||void 0},target:{type:`user`,id:r.user_id,...i.previousUser&&{before:rR(i.previousUser)},after:rR(r)},request:{method:e.req.method,path:e.req.path,ip:e.var.ip||``,user_agent:e.var.useragent||void 0},hostname:e.var.host||``,auth0_client:e.var.auth0_client,...i.updates&&{details:{updates:iR(i.updates)}},timestamp:new Date().toISOString(),id:Yl()}}function GR(e,t){let n=e.var.outboxEventPromises||[];n.push(Promise.resolve(t)),e.set(`outboxEventPromises`,n)}function KR(e,t,n,r,i={}){Uc(e,qR(e,t,n,r,i))}async function qR(e,t,n,r,i){let a=gR(e),{hooks:o}=await a.hooks.list(t),s=o.filter(e=>e.enabled&&e.trigger_id===n&&`url`in e);if(s.length>0&&await yR(e,s,{tenant_id:t,user:rR(r),trigger_id:n,...i.previousUser&&{previous_user:rR(i.previousUser)},...i.updates&&{updates:iR(i.updates)}}),n===`post-user-update`||n===`post-user-deletion`){let o=new VR(a,e.env.codeExecutor,{logCapture:e.env.actionExecutionLogs}),s=WR(e,t,n,r,i);try{await o.deliver([o.transform(s)])}catch(e){console.error(`Best-effort ${n} Action failed:`,e)}}if(n===`post-user-registration`&&r.user_id)try{await e.env.data.users.update(t,r.user_id,{registration_completed_at:new Date().toISOString()})}catch(e){console.error(`Failed to mark registration_completed_at on inline dispatch:`,e)}}function JR(e){return typeof e==`object`&&!!e&&e.status===409}function YR(e){return async(t,n,r={})=>{let{resolveEmailLinkedPrimary:i=!1,outboxEvents:a}=r;try{return{user:await e.transaction(async e=>{if(i&&!n.linked_to){let r=n.email?Ou(n.email):void 0;if(r&&n.email_verified){let i=await Ru({userAdapter:e.users,tenant_id:t,email:r,warnOnMultiplePrimaries:!0,filterCandidates:n=>au(e.connections,t,n)});i&&(n.linked_to=i.user_id)}}if(n.linked_to){let r=await Vu(e.users,t,n.linked_to);if(!await e.users.get(t,r))throw new k(400,{error:`invalid_request`,error_description:`Primary user does not exist`});n.linked_to=r}let r=await e.users.rawCreate(t,n,{outboxEvents:a});if(n.linked_to){let r=await e.users.get(t,n.linked_to);if(!r)throw new k(500,{error:`server_error`,error_description:`Failed to fetch primary user after linking`});return r}return r}),created:!0}}catch(r){if(JR(r)){let r=await XR(e,t,n);if(r)return{user:r,created:!1}}throw r}}}async function XR(e,t,n){let r=n.email?`email:${Ou(n.email)}`:n.phone_number?`phone_number:${n.phone_number}`:n.username?`username:${n.username.toLowerCase()}`:null;if(!r)return null;let{users:i}=await e.users.list(t,{page:0,per_page:10,include_totals:!1,q:r}),a=i.find(e=>e.provider===n.provider);if(!a)return null;if(a.linked_to){let n=await e.users.get(t,a.linked_to);if(!n)throw new k(500,{error:`server_error`,error_description:`Primary user does not exist for linked user`});return n}return a}function ZR(e){let t=e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``);return t.length>0?t:void 0}function QR(e){let t=[],n=e=>e.includes(`@`)?e.split(`@`)[0]??e:e;if(e.nickname&&t.push(ZR(n(e.nickname))),e.name&&t.push(ZR(n(e.name))),e.email){let n=e.email.split(`@`)[0];n&&t.push(ZR(n))}e.phone_number&&t.push(ZR(e.phone_number));let r=new Set,i=[];for(let e of t)e&&!r.has(e)&&(r.add(e),i.push(e));return i}async function $R(e,t,n,r){for(let i of r){let{users:r}=await e.list(t,{page:0,per_page:1,include_totals:!1,q:`username:${D(n)} provider:${D(i)}`});if(r.length>0)return!0}return!1}async function ez(e,t,n,r,i){for(let a of n){if(!await $R(e,t,a,r))return a;for(let n=2;n<=i+1;n++){let i=`${a}${n}`;if(!await $R(e,t,i,r))return i}}}function tz(e,t){return t(e.provider)&&e.username?!0:e.identities?e.identities.some(e=>t(e.provider)&&e.profileData?.username):!1}function nz(e){let t=e?.connection??Go.USERNAME_PASSWORD,n=e?.provider??`auth0`,r=e?.provider?t=>t===e.provider:Su,i=e?.provider?[e.provider]:bu,a=Math.max(0,Math.floor(e?.maxRetries??10));return async(e,o)=>{let{ctx:s,user:c}=e;if(!c||!s)return;let l=e.tenant?.id;if(!l)return;let u=s.env.data;if(tz(c,r))return;if(!r(c.provider))for(let e of i){let{users:t}=await u.users.list(l,{page:0,per_page:1,include_totals:!1,q:`linked_to:${D(c.user_id)} provider:${D(e)}`});if(t.length>0)return}let d=QR(c);if(d.length===0){console.warn(`[ensureUsername] No username candidates found for user ${c.user_id}`);return}for(let e=0;e<=a;e++){let o=await ez(u.users,l,d,i,a);if(!o){console.warn(`[ensureUsername] Could not find a unique username for user ${c.user_id} after ${a} retries`);return}try{if(r(c.provider))await u.users.update(l,c.user_id,{username:o});else{let e=`${n}|${Zl()}`;await u.users.create(l,{user_id:e,username:o,name:o,provider:n,connection:t,email_verified:!1,is_social:!1,linked_to:c.user_id})}return}catch(t){if(!JR(t))throw t;console.info(`[ensureUsername] Username "${o}" was claimed concurrently, retrying (attempt ${e+1}/${a})`)}}console.warn(`[ensureUsername] Could not allocate a username for user ${c.user_id} after ${a} conflict retries`)}}function rz(e){if(e.username)return e.username;if(e.preferred_username)return e.preferred_username;if(e.identities)for(let t of e.identities){if(t.username)return t.username;if(t.profileData?.username)return t.profileData.username}}function iz(){return async(e,t)=>{let{user:n}=e;if(!n)return;let r=rz(n);r&&(t.idToken.setCustomClaim(`preferred_username`,r),t.accessToken.setCustomClaim(`preferred_username`,r))}}async function az(e){let{userAdapter:t,connectionAdapter:n,tenantId:r,user:i}=e,a=async e=>{if(!n||e.length===0)return e;let t=await au(n,r,[i,...e]);return t[0]?.user_id===i.user_id?t.slice(1):[]};if(!i.email)return[];let o=Ou(i.email),s=[],c=0;for(;;){let{users:e}=await t.list(r,{page:c,per_page:100,include_totals:!1,q:`email:${D(o)}`});if(s.push(...e),e.length<100)break;c++}let l=s.filter(e=>e.user_id!==i.user_id);if(l.length===0)return[];let u=l.filter(e=>!e.linked_to);if(u.length>0)return(await a(u)).sort(Fu);let d=[],f=new Set;for(let e of l){if(!e.linked_to)continue;let n=await Vu(t,r,e.linked_to),a=await t.get(r,n);a&&a.user_id!==i.user_id&&!f.has(a.user_id)&&(f.add(a.user_id),d.push(a))}return(await a(d)).sort(Fu)}function oz(e){let t=e[0];return e.map(e=>({user_id:e.user_id,email:e.email??``,email_verified:e.email_verified??!1,provider:e.provider??``,connection:e.connection??``,created_at:e.created_at??``,is_primary:!e.linked_to,is_oldest:t?e.user_id===t.user_id:!1}))}function sz(e){if(!e)return{};if(typeof e==`string`)try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}return typeof e==`object`&&!Array.isArray(e)?e:{}}var cz=[`name`,`given_name`,`family_name`,`middle_name`,`nickname`,`preferred_username`,`picture`,`profile`,`website`,`gender`,`birthdate`,`zoneinfo`,`locale`,`phone_number`,`address`];function lz(e){return e==null||e===``}function uz(e){let t=e?.requireVerifiedEmail??!0,n=e?.copyUserMetadata??!1,r=e?.copyProfileFields??!1;return async e=>{let{ctx:i,user:a}=e;if(!a||!i)return;let o=e.tenant?.id;if(!o||a.linked_to||!a.email||t&&!a.email_verified)return;let s=i.env.data,c=(await az({userAdapter:s.users,connectionAdapter:s.connections,tenantId:o,user:a}))[0];if(!c)return;let l,u;if(Fu(a,c)<0?(l=a,u=c,await s.users.update(o,c.user_id,{linked_to:a.user_id})):(l=c,u=a,await s.users.update(o,a.user_id,{linked_to:c.user_id})),n){let e=sz(u.user_metadata),t=sz(l.user_metadata);if(e&&Object.keys(e).length>0){let n={...e,...t};Object.keys(n).some(e=>!(e in t)||t[e]!==n[e])&&await s.users.update(o,l.user_id,{user_metadata:n})}}if(r){let e=l,t=u,n={};for(let r of cz)lz(e[r])&&!lz(t[r])&&(n[r]=t[r]);Object.keys(n).length>0&&await s.users.update(o,l.user_id,n)}}}var dz=c({accountLinking:()=>uz,ensureUsername:()=>nz,setPreferredUsername:()=>iz});function fz(e){return typeof e==`object`&&!!e&&typeof e.template_id==`string`&&typeof e.enabled==`boolean`}var pz={prompt:{render:()=>{}},multifactor:{enable:()=>{}},redirect:{sendUserTo:()=>{},encodeToken:()=>``,validateToken:()=>null},token:{createServiceToken:async()=>``}};async function mz(e,t,n,r){return await r({ctx:e,user:n,tenant:{id:t},request:{ip:e.get(`ip`)||``,url:ll(e.req.url),method:e.req.method,user_agent:e.get(`useragent`)||``}},pz),await e.env.data.users.get(t,n.user_id)||n}async function hz(e,t,n,r){let i=e.var.tenant_id||e.req.header(`tenant-id`);if(!i)return n;switch(t){case`ensure-username`:return mz(e,i,n,nz());case`account-linking`:return mz(e,i,n,uz({copyUserMetadata:r?.copy_user_metadata===!0}));default:return console.warn(`[templatehooks] Unknown template_id: ${t}`),n}}async function gz(e,t,n,r){let i=e.var.tenant_id||e.req.header(`tenant-id`);if(!i)return;let a={ctx:e,user:n,tenant:{id:i},request:{ip:e.get(`ip`)||``,url:ll(e.req.url),method:e.req.method,user_agent:e.get(`useragent`)||``}};switch(t){case`set-preferred-username`:await iz()(a,r);break;default:console.warn(`[templatehooks] Unknown credentials-exchange template_id: ${t}`)}}function _z(e,t){return{createServiceToken:async n=>{if(`clientId`in n&&n.clientId!==void 0){if(typeof n.clientId!=`string`||n.clientId.length===0)throw Error("createServiceToken: `clientId` must be a non-empty string.");return(await vO(e,t,{clientId:n.clientId,scope:n.scope,audience:n.audience,expiresInSeconds:n.expiresInSeconds,customClaims:n.customClaims})).access_token}if(n.audience!==void 0)throw Error("createServiceToken: `audience` is only valid together with `clientId`.");return(await hO(e,t,n.scope,n.expiresInSeconds,n.customClaims)).access_token}}}var vz=new Set([...Object.values(Go),qo,`auth2`,`samlp`].map(e=>e.toLowerCase())),yz=[`email`,`phone_number`,`name`,`given_name`,`family_name`,`nickname`,`picture`];function bz(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xz(e){if(!bz(e))return{ok:!1,reason:`invalid_params`};let{connection:t,id:n,profile:r,app_metadata:i}=e;if(typeof t!=`string`||!t)return{ok:!1,reason:`invalid_params`};if(typeof n!=`string`||!n.trim()||n.includes(`|`))return{ok:!1,reason:`invalid_id`,connection:t,id:n};if(r!==void 0&&!bz(r)||i!==void 0&&!bz(i))return{ok:!1,reason:`invalid_params`,connection:t,id:n};let a={};if(r){for(let e of yz){let t=r[e];typeof t==`string`&&t.trim()&&(a[e]=e===`email`?Ou(t):t.trim())}typeof r.email_verified==`boolean`&&(a.email_verified=r.email_verified)}return{ok:!0,params:{connection:t,id:n,profile:a,app_metadata:i}}}var Sz=100,Cz=50;async function wz(e,t){let n=[];for(let r=0;r<Cz;r++){let{connections:i}=await e.connections.list(t,{page:r,per_page:Sz,include_totals:!1});if(n.push(...i),i.length<Sz)break}return n}function Tz(e,t,n=[]){let r=null,i=()=>(r||=wz(e,t).then(e=>{let t=new Set(vz);for(let e of n)t.add(e.toLowerCase());for(let n of e)n.strategy!==Go.EXTERNAL&&t.add(n.strategy.toLowerCase());return{external:e.filter(e=>e.strategy===Go.EXTERNAL),reserved:t}}),r);return{getActionUsersConnection:async e=>{let{external:t,reserved:n}=await i(),r=t.find(t=>t.name===e);if(!(!r||r.options?.allow_action_users!==!0||n.has(r.name.toLowerCase())))return r},isExternalUser:async e=>{let{external:t}=await i();return t.some(t=>t.name===e.connection&&t.name===e.provider)}}}function Ez(e){let{ctx:t,data:n,tenantId:r,triggerId:i,externalConnections:a}=e,o=new Set,s=0,c=(e,n,a={})=>{O(t,r,{type:E.FAILED_HOOK,description:n,details:{trigger_id:i,reason:e,...a}})};return{api:{users:{ensure:async e=>{if(s++,s>5){c(`too_many_users`,`${i} action called users.ensure more than 5 times`);return}let l=xz(e);if(!l.ok){c(l.reason,`${i} action passed invalid arguments to users.ensure`,{connection:l.connection});return}let{connection:u,id:d,profile:f,app_metadata:p}=l.params;if(!await a.getActionUsersConnection(u)){c(`connection_not_allowed`,`${i} action tried to ensure a user in connection ${u}, which does not allow action users`,{connection:u});return}let m=`${u}|${d}`,h=async(e,t)=>{let n={...f};return f.email!==void 0&&f.email!==t.email&&f.email_verified===void 0&&(n.email_verified=!1),p&&(n.app_metadata={...t.app_metadata??{},...p}),Object.keys(n).length===0?!0:e.update(r,m,n)},g=()=>n.transaction(async e=>{let t=await e.users.get(r,m);if(t&&await h(e.users,t))return`updated`;let n=new Date().toISOString(),i={...f,email_verified:f.email_verified??!1,user_id:m,provider:u,connection:u,is_social:!1,app_metadata:p??{},user_metadata:{},registration_completed_at:n};return await e.users.rawCreate(r,i),`created`}),_;try{_=await g()}catch(e){if(!JR(e))throw e;_=await g()}o.add(m),O(t,r,{type:E.SUCCESS_HOOK,description:`${i} action ${_} user ${m}`,userId:m,details:{trigger_id:i,operation:`users.ensure`,outcome:_,connection:u}})}}},ensuredUserIds:o}}async function Dz(e,t,n){let r=gR(e),i=[];for(let e=0;;e++){let a=await r.hooks.list(t,{page:e,per_page:100,q:`trigger_id:${n}`});if(i.push(...a.hooks),a.hooks.length<100)break}return i.filter(e=>e.enabled&&e.trigger_id===n).filter(wR).sort((e,t)=>(t.priority??0)-(e.priority??0))}async function Oz(e,t,n,r){let i=gR(e),a=await Dz(e,t,n),o=[],s=n===`validate-registration-username`?`Signup not allowed by Action`:`Operation denied by lifecycle Action`,c=async()=>{let r=await LR(i,t,n,o,{logCapture:e.env.actionExecutionLogs});r&&e.set(`action_execution_id`,r)};for(let l of a){let a,u;try{if(!e.env.codeExecutor)throw Error(`No code executor configured`);u=await NR({codeExecutor:e.env.codeExecutor,data:i,tenantId:t,hook:l,event:r,triggerId:n,api:{access:{deny:e=>{a=typeof e==`string`?e:void 0}}}}),u.denied&&(u.result.error={id:`access_denied`,msg:a||s})}catch(e){u={result:{action_name:l.code_id,error:{id:`execution_threw`,msg:e instanceof Error?e.message:String(e)},started_at:new Date().toISOString(),ended_at:new Date().toISOString()},denied:!1,logs:[]}}if(o.push(u),u.denied||u.result.error)return await c(),await O(e,t,{type:E.FAILED_HOOK,description:`${n} Action ${u.denied?`denied the operation`:`failed`}`,userId:typeof r.user_id==`string`?r.user_id:void 0}),{allowed:!1,reason:u.denied?a||s:`${n} Action failed`}}return await c(),{allowed:!0}}async function kz(e,t,n,r){let i=await Oz(e,t,n,r);if(!i.allowed)throw new k(400,{message:i.reason})}var Az=1e4;async function jz(e,t,n,r,i=`email`,a={}){let o=t.connections.find(e=>e.name===i);if(!o){let e=t.connections.filter(e=>e.strategy===i);if(e.length>1)return{allowed:!1,reason:`Ambiguous connection: client has ${e.length} connections with strategy "${i}" (${e.map(e=>e.name).join(`, `)}). Pass an explicit connection name.`};e.length===1&&(o=e[0],console.warn(`[validate-signup] resolved connection by strategy fallback: strategy="${i}" matched "${o.name}"`))}let s=(a.identifierPreflight===!0||e.var.is_lazy_migration===!0)&&o?.options?.import_mode===!0;if(o?.options?.disable_signup&&!s){let i=e.var.loginSession?.authorization_url;if(i&&new URL(i).searchParams.get(`screen_hint`)===`signup`)return{allowed:!0};if(!await Lu({userAdapter:n.users,tenant_id:t.tenant.id,email:r}))return{allowed:!1,reason:`User account does not exist`}}if(e.env.hooks?.onExecuteValidateRegistrationUsername){let n={method:e.req.method,ip:e.var.ip||e.get(`ip`)||``,user_agent:e.var.useragent||e.get(`useragent`)||``,url:ll(e.req.url)},a=!1,o;try{if(await e.env.hooks.onExecuteValidateRegistrationUsername({ctx:e,client:t,request:n,tenant:{id:t.tenant.id},user:{email:r,connection:i}},{deny:e=>{a=!0,o=e},token:_z(e,t.tenant.id)}),a)return{allowed:!1,reason:o}}catch{return{allowed:!1,reason:`Signup validation hook failed`}}}let c=await Oz(e,t.tenant.id,`validate-registration-username`,{client:t,tenant:{id:t.tenant.id},user:{email:r,connection:i},request:{method:e.req.method,ip:e.var.ip||``,user_agent:e.var.useragent||``,url:ll(e.req.url)}});if(!c.allowed)return c;let l=await xR(e,t.tenant.id);if(l&&`url`in l)try{let n=await hO(e,t.tenant.id,`webhook`),a=new AbortController,o=setTimeout(()=>a.abort(),Az),s;try{s=await fetch(l.url,{method:`POST`,headers:{Authorization:`Bearer ${n.access_token}`,"Content-Type":`application/json`},body:JSON.stringify({tenant_id:t.tenant.id,email:r,connection:i,client_id:t.client_id,trigger_id:`validate-registration-username`}),signal:a.signal})}finally{clearTimeout(o)}if(!s.ok)return{allowed:!1,reason:await s.text()||`Signup not allowed by webhook`};let c=await s.json();if(c.allowed===!1)return{allowed:!1,reason:c.reason||`Signup not allowed by webhook`}}catch{O(e,t.tenant.id,{type:E.FAILED_HOOK,description:`Validate signup email webhook failed`})}return{allowed:!0}}async function Mz(e,t,n,r,i){let a=await jz(e,t,n,r,i);if(!a.allowed)throw O(e,t.tenant.id,{type:E.FAILED_SIGNUP,description:a.reason||`Signup not allowed`}),new k(400,{message:a.reason||`Signups are disabled for this connection`});await bR(e)(t.tenant.id,r)}async function Nz(e,t,n){if(n){let r=await e.env.data.clients.get(t,n);if(r?.user_linking_mode)return r.user_linking_mode}let r=e.env.userLinkingMode;if(typeof r==`function`){let e=await r({tenant_id:t,client_id:n});return e===`builtin`||e===`off`?e:`builtin`}return r??`builtin`}async function Pz(e,t,n){return await Nz(e,t,n)===`builtin`}var Fz=class e extends p.HTTPException{code;constructor(t,n){super(400,{message:n,res:new Response(JSON.stringify({message:n}),{status:400,headers:{"Content-Type":`application/json`}})}),this.name=e.name,this.code=t}};function Iz(e,t,n,r){let i=e[t];e[t]={...i&&typeof i==`object`&&!Array.isArray(i)?i:{},[n]:r}}function Lz(e,t){return async(n,r)=>{if(e.var.client_id&&e.var.client_id_from_token!==!0){let n=await nR(e.env,e.var.client_id,e.var.tenant_id);r.email&&await Mz(e,n,t,r.email,r.connection)}let i={method:e.req.method,ip:e.req.query(`x-real-ip`)||``,user_agent:e.req.query(`user-agent`),url:e.var.loginSession?.authorization_url||ll(e.req.url),body:e.var.signup_body},{hooks:a}=await t.hooks.list(n),o=a.filter(e=>e.trigger_id===`pre-user-registration`&&e.enabled).filter(wR),s=(e,t)=>{Iz(r,`user_metadata`,e,t)},c=(e,t)=>{Iz(r,`app_metadata`,e,t)},l=r.linked_to,u,d=e=>{u=e,r.linked_to=e};if(e.env.hooks?.onExecutePreUserRegistration)try{await e.env.hooks.onExecutePreUserRegistration({ctx:e,user:r,request:i,tenant:{id:n}},{user:{setUserMetadata:s,setAppMetadata:c,setLinkedTo:d},access:{deny:(e,t)=>{throw new k(400,{message:t?`Registration denied: ${e} - ${t}`:`Registration denied: ${e}`})}},validation:{error:(e,t)=>{throw new Fz(e,t)}},token:_z(e,n)})}catch(t){if(t instanceof p.HTTPException)throw t;let i=t instanceof Error?t.message:String(t),a=t instanceof Error?t.stack:void 0,o=t instanceof Error?t.name:void 0;O(e,n,{type:E.FAILED_SIGNUP,description:`Pre user registration hook failed for ${r.email||r.phone_number||r.user_id}: ${i}`,userId:r.user_id,connection:r.connection,details:{error:i,error_name:o,error_stack:a,user_email:r.email,user_phone_number:r.phone_number,user_provider:r.provider,user_connection:r.connection}})}{let a=[],l=Ez({ctx:e,data:t,tenantId:n,triggerId:`pre-user-registration`,externalConnections:Tz(t,n,Object.keys(e.env.STRATEGIES??{}))}),u=()=>LR(t,n,`pre-user-registration`,a,{logCapture:e.env.actionExecutionLogs}),f=(e,t)=>{throw new k(400,{message:t?`Registration denied: ${e} - ${t}`:`Registration denied: ${e}`})};for(let n of o){let o=AR(n),m;try{m=await PR(e,t,n,{ctx:e,user:r,request:i},`pre-user-registration`,{user:{setUserMetadata:s,setAppMetadata:c,setLinkedTo:d},users:l.api.users,access:{deny:f},validation:{error:(e,t)=>{throw new Fz(e,t)}}}),!m&&o&&(m=MR(n.code_id))}catch(t){if(t instanceof p.HTTPException){let r=jR(n.code_id,t,!0);t instanceof Fz&&r.result.error&&(r.result.error.id=t.code),a.push(r),await zR(e,u,t)}m=jR(n.code_id,t)}if(m&&(a.push(m),m.failure&&o)){m.denied=!0;try{f(`access_denied`,m.failure)}catch(t){await zR(e,u,t)}}}let m=await u();m&&e.set(`action_execution_id`,m)}let f=!1;u!==void 0&&r.linked_to===u&&(await t.users.get(n,u)||(O(e,n,{type:E.FAILED_HOOK,description:`pre-user-registration hook tried to link ${r.user_id} to non-existent user ${u}`,userId:r.user_id,details:{trigger_id:`pre-user-registration`,reason:`primary_not_found`,primary_user_id:u}}),f=!0,l?r.linked_to=l:delete r.linked_to)),r=ku(r);let m=!f&&await Pz(e,n,e.var.client_id),h=UR(e,n,`post-user-registration`,r),g=await YR(t)(n,r,{resolveEmailLinkedPrimary:m,outboxEvents:h?[h]:void 0});if(!g.created)throw new k(409,{message:`User already exists`});let _=g.user;return await(async()=>{if(e.env.hooks?.onExecutePostUserRegistration)try{await e.env.hooks.onExecutePostUserRegistration({ctx:e,user:r,request:i,tenant:{id:n}},{user:{},token:_z(e,n)})}catch(t){let r=t instanceof Error?t.message:String(t),i=t instanceof Error?t.stack:void 0,a=t instanceof Error?t.name:void 0;O(e,n,{type:E.FAILED_SIGNUP,description:`Post user registration hook failed for ${_.email||_.phone_number||_.user_id}: ${r}`,userId:_.user_id,connection:_.connection,details:{error:r,error_name:a,error_stack:i,user_email:_.email,user_phone_number:_.phone_number,user_provider:_.provider,user_connection:_.connection}})}{let{hooks:t}=await gR(e).hooks.list(n),r=t.filter(e=>e.trigger_id===`post-user-registration`&&e.enabled&&fz(e));for(let t of r)if(fz(t))try{_=await hz(e,t.template_id,_,t.metadata)}catch(r){let i=r instanceof Error?r.message:String(r),a=r instanceof Error?r.stack:void 0,o=r instanceof Error?r.name:void 0;O(e,n,{type:E.FAILED_SIGNUP,description:`Post user registration template hook ${t.template_id} failed for ${_.email||_.phone_number||_.user_id}: ${i}`,userId:_.user_id,connection:_.connection,details:{template_id:t.template_id,trigger_id:`post-user-registration`,error:i,error_name:o,error_stack:a,user_email:_.email}})}}h?GR(e,h.id):KR(e,n,`post-user-registration`,_)})(),_}}function Rz(e,t){return async(n,r,i)=>{if(`linked_to`in i&&i.linked_to===r)throw new k(400,{message:`Cannot link a user to itself`});if(Object.keys(i).length===1&&`linked_to`in i){let{linked_to:e}=i;return e?t.transaction(async t=>(await Uu({userAdapter:t.users,tenant_id:n,userId:r,primaryId:e}),!0)):t.users.update(n,r,i)}let a=await t.users.get(n,r);if(!a)throw new k(404,{message:`User not found`});let o=structuredClone(a),s={method:e.req.method,ip:e.var.ip||e.get(`ip`)||``,user_agent:e.var.useragent||e.get(`useragent`)||``,url:ll(e.req.url)};if(e.env.hooks?.onExecutePreUserUpdate)try{await e.env.hooks.onExecutePreUserUpdate({ctx:e,tenant:{id:n},user_id:r,user:rR(a),updates:i,request:s},{user:{setUserMetadata:async(e,t)=>{i[e]=t}},cancel:()=>{throw new k(400,{message:`User update cancelled by pre-update hook`})},token:_z(e,n)})}catch(t){throw O(e,n,{type:E.ACTIONS_EXECUTION_FAILED,description:`Pre user update hook failed: ${t instanceof Error?t.message:`Unknown error`}`,userId:r}),new k(400,{message:`Pre user update hook failed`})}i=ku(i);let c={previousUser:o,updates:iR(i)};await kz(e,n,`pre-user-update`,{user:rR(o),previous_user:rR(o),updates:c.updates,user_id:r,tenant:{id:n},request:s});let l=await Pz(e,n,e.var.client_id),u=UR(e,n,`post-user-update`,{...a,...i},c);await t.transaction(async e=>{if(!await e.users.update(n,r,i,{outboxEvents:u?[u]:void 0}))throw new k(404,{message:`User not found`});if(l&&(i.email||i.email_verified)){let t=await e.users.get(n,r);if(t&&!t.linked_to&&t.email&&t.email_verified){let i=Ou(t.email),{users:a}=await e.users.list(n,{page:0,per_page:10,include_totals:!1,q:`email:${D(i)}`}),o=a.filter(e=>e.user_id!==r),s=o.filter(e=>!e.linked_to),c=s.length>0?[...s].sort(Fu)[0]:void 0;if(c)Fu(t,c)<0?await Uu({userAdapter:e.users,tenant_id:n,userId:c.user_id,primaryId:r}):await Uu({userAdapter:e.users,tenant_id:n,userId:r,primaryId:c.user_id});else if(o.some(e=>e.linked_to)){let i=[],a=new Set;for(let t of o){if(!t.linked_to)continue;let o=new Set([t.user_id]),s=await e.users.get(n,t.linked_to);for(;s&&s.linked_to;){if(o.has(s.user_id)){s=null;break}o.add(s.user_id),s=await e.users.get(n,s.linked_to)}s&&s.user_id!==r&&!a.has(s.user_id)&&(a.add(s.user_id),i.push(s))}let s=i.length>0?i.sort(Fu)[0]:void 0;s&&(Fu(t,s)<0?await Uu({userAdapter:e.users,tenant_id:n,userId:s.user_id,primaryId:r}):await Uu({userAdapter:e.users,tenant_id:n,userId:r,primaryId:s.user_id}))}}}}),u?GR(e,u.id):KR(e,n,`post-user-update`,{...a,...i},c);{let{hooks:i}=await t.hooks.list(n),a=i.filter(e=>e.trigger_id===`post-user-update`&&fz(e)&&e.enabled===!0);if(a.length>0){let i=await t.users.get(n,r);if(i){let t=i;for(let i of a)if(fz(i))try{t=await hz(e,i.template_id,t,i.metadata)}catch(t){let a=t instanceof Error?t.message:String(t),o=t instanceof Error?t.stack:void 0,s=t instanceof Error?t.name:void 0;O(e,n,{type:E.ACTIONS_EXECUTION_FAILED,description:`Post user update template hook ${i.template_id} failed: ${a}`,userId:r,details:{template_id:i.template_id,trigger_id:`post-user-update`,error:a,error_name:s,error_stack:o}})}}}}if(i.email&&O(e,n,{type:E.SUCCESS_CHANGE_EMAIL,description:`Email updated from ${a.email??`(none)`} to ${i.email}`,userId:r}),e.env.hooks?.onExecutePostUserUpdate)try{let a=await t.users.get(n,r);await e.env.hooks.onExecutePostUserUpdate({ctx:e,tenant:{id:n},user_id:r,user:a?rR(a):void 0,updates:i,request:s},{token:_z(e,n)})}catch(t){O(e,n,{type:E.ACTIONS_EXECUTION_FAILED,description:`Post user update hook failed: ${t instanceof Error?t.message:`Unknown error`}`,userId:r})}return!0}}function zz(e,t){return async(n,r)=>{let i=await Bz(e,t,n,r);return i?i():!1}}async function Bz(e,t,n,r){let i=await t.users.get(n,r);if(!i)return null;let a={method:e.req.method,ip:e.var.ip||e.get(`ip`)||``,user_agent:e.var.useragent||e.get(`useragent`)||``,url:e.req.url};if(e.env.hooks?.onExecutePreUserDeletion)try{await e.env.hooks.onExecutePreUserDeletion({ctx:e,user:rR(i),user_id:r,request:a,tenant:{id:n}},{cancel:()=>{throw new k(400,{message:`User deletion cancelled by pre-deletion hook`})},token:_z(e,n)})}catch(t){throw t instanceof p.HTTPException?t:(O(e,n,{type:E.FAILED_HOOK,description:`Pre user deletion hook failed: ${t instanceof Error?t.message:String(t)}`}),new k(400,{message:`Pre user deletion hook failed`}))}await kz(e,n,`pre-user-deletion`,{user:rR(i),user_id:r,tenant:{id:n},request:a});try{await SR(e)(n,i)}catch(t){throw O(e,n,{type:E.FAILED_HOOK,description:`Pre user deletion webhook failed: ${t instanceof Error?t.message:String(t)}`}),new k(400,{message:`Pre user deletion webhook failed`})}return async()=>{let o=UR(e,n,`post-user-deletion`,i),s=await t.transaction(async e=>{let t=await e.users.list(n,{q:`linked_to:${D(r)}`});for(let i of t.users){let[t,...a]=i.user_id.split(`|`);t&&await e.users.unlink(n,r,t,a.join(`|`))}return e.users.remove(n,r,{outboxEvents:o?[o]:void 0})});if(s&&O(e,n,{type:E.SUCCESS_USER_DELETION,description:`Deleted user: ${i.email||r}`,userId:r,strategy:i.provider||`auth0`,strategy_type:i.is_social?Ko.SOCIAL:Ko.DATABASE,connection:i.connection||``,body:{tenant:n,connection:i.connection||``}}),s&&(o?GR(e,o.id):KR(e,n,`post-user-deletion`,i),e.env.hooks?.onExecutePostUserDeletion))try{await e.env.hooks.onExecutePostUserDeletion({ctx:e,user:rR(i),user_id:r,request:a,tenant:{id:n}},{token:_z(e,n)})}catch(t){let a=t instanceof Error?t.message:String(t),o=t instanceof Error?t.stack:void 0,s=t instanceof Error?t.name:void 0;O(e,n,{type:E.FAILED_HOOK,description:`Post user deletion hook failed for ${i.email||i.phone_number||r}: ${a}`,userId:r,connection:i.connection,details:{error:a,error_name:s,error_stack:o,user_email:i.email,user_phone_number:i.phone_number,user_provider:i.provider,user_connection:i.connection}})}return s}}function Vz(e,t){let n=t,r=Lz(e,n),i=Rz(e,n);return{...t,users:{...t.users,create:(e,t)=>r(e,ku(t)),update:(e,t,n,r)=>i(e,t,ku(n),r),remove:zz(e,n)}}}function Hz(e){let t=e.client_metadata?.universal_login_version;return t===`2`?`/u2`:t===`1`?`/u`:e.tenant?.flags?.universal_login_version===`2`?`/u2`:`/u`}var Uz=new Set([`PASSWORD`,`CODE`]),Wz=`form_values`;function Gz(e){if(!e)return{};try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?{...t}:{}}catch{return{}}}function Kz(e){let t=e[Wz];if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`string`&&(n[e]=r);return n}async function qz(e,t,n,r,i){let a=await e.env.data.loginSessions.get(t,n),o=Kz(Gz(a?.state_data)),s={...o,...r};if(!a)return s;let c={...o};for(let e of i){let t=r[e.id];t!==void 0&&(Uz.has(e.type)||e.sensitive!==!0&&(c[e.id]=t))}if(Object.keys(c).length===Object.keys(o).length){let e=!1;for(let[t,n]of Object.entries(c))if(o[t]!==n){e=!0;break}if(!e)return s}return await wO(e.env.data.loginSessions,t,n,{type:j.UPDATE_CONTEXT,data:{[Wz]:c}},{}),s}function Jz(e){return typeof e.form_id==`string`}function Yz(e,t){let n=e.match(/^\{\{context\.user\.(.+)\}\}$/);if(n&&n[1])return Xz(t.user,n[1]);let r=e.match(/^\{\{user\.(.+)\}\}$/);if(r&&r[1])return Xz(t.user,r[1]);let i=e.match(/^\{\{(?:fields|\$form)\.(.+)\}\}$/);if(i&&i[1]&&t.submittedFields){let e=t.submittedFields[i[1]];return e===void 0?void 0:String(e)}return e}function Xz(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r&&typeof r==`object`&&e in r)r=r[e];else return;return typeof r==`string`?r:r==null?void 0:String(r)}function Zz(e,t){let n={};for(let[r,i]of Object.entries(e))if(typeof i==`string`){let e=Yz(i,t);e!==void 0&&(n[r]=e)}else i!=null&&(n[r]=String(i));return n}function Qz(e,t){let n=e.operator?.toLowerCase(),r=e.field??``,i=r?Yz(r,t):``;r&&i===r&&!r.startsWith(`{{`)&&(i=Xz(t.user,r));let a=e.value||``;switch(n){case`exists`:return i!=null&&i!==``;case`not_exists`:return i==null||i===``;case`ends_with`:return typeof i==`string`&&i.endsWith(a);case`starts_with`:return typeof i==`string`&&i.startsWith(a);case`contains`:return typeof i==`string`&&i.includes(a);case`not_contains`:return typeof i!=`string`||!i.includes(a);case`equals`:case`eq`:return i===a;case`not_equals`:case`neq`:return i!==a;default:if(e.operands&&Array.isArray(e.operands)){for(let n of e.operands)if(n.operator===`ENDS_WITH`&&Array.isArray(n.operands)&&n.operands.length>=2){let e=n.operands[0],r=n.operands[1];if(e&&r){let n=Yz(`{{context.user.${e}}}`,t);if(typeof n==`string`&&n.endsWith(r))return!0}}}return!1}}function $z(e,t){return Array.isArray(e.conditions)?e.conditions.every(e=>Qz(e,t)):Qz(e,t)}function eB(e,t){let n={};for(let[r,i]of Object.entries(e))if(r.startsWith(`user_metadata.`)||r.startsWith(`metadata.`)){let e=r.startsWith(`user_metadata.`)?r.slice(14):r.slice(9);n.user_metadata={...t.user_metadata||{},...n.user_metadata||{},[e]:i}}else if(r.startsWith(`address.`)){let e=r.slice(8);n.address={...t.address||{},...n.address||{},[e]:i}}else n[r]=i;return n}function tB(e){let t=new Map;for(let n of e){let e=t.get(n.user_id);e?e.changes={...e.changes,...n.changes}:t.set(n.user_id,{user_id:n.user_id,changes:{...n.changes}})}return Array.from(t.values())}function nB(e,t,n){switch(e){case`change-email`:return`/u2/account/change-email?state=${encodeURIComponent(n)}`;case`account`:return`/u2/account?state=${encodeURIComponent(n)}`;case`custom`:if(!t)throw new p.HTTPException(400,{message:`Custom URL is required for custom redirect target`});let r=new URL(t,`http://placeholder`);return r.searchParams.set(`state`,n),r.pathname+r.search;default:throw new p.HTTPException(400,{message:`Unknown redirect target: ${e}`})}}async function rB(e,t,n,r,i=10){let a=t,o=0,s=[];for(;o<i;){if(a===`$ending`)return{type:`end`,userUpdates:s.length>0?s:void 0};let t=e.find(e=>e.id===a);if(!t)return null;if(t.type===`STEP`)return{type:`step`,nodeId:t.id,userUpdates:s.length>0?s:void 0};if(t.type===`ACTION`){let e=t;if(e.config.action_type===`REDIRECT`)return{type:`redirect`,target:e.config.target,customUrl:e.config.custom_url,userUpdates:s.length>0?s:void 0};a=e.config.next_node,o++;continue}if(t.type===`ROUTER`){let e=t,r=null;for(let t of e.config.rules)if($z(t.condition,n)){r=t.next_node;break}if(r||=e.config.fallback,!r)return null;a=r,o++;continue}if(t.type===`FLOW`){let e=t;if(r&&e.config.flow_id){let t=await r(e.config.flow_id);if(t&&t.actions&&t.actions.length>0)for(let e of t.actions){if(e.type===`REDIRECT`&&e.action===`REDIRECT_USER`){let t=e.params?.target;if(t)return{type:`redirect`,target:t,customUrl:e.params?.custom_url,userUpdates:s.length>0?s:void 0}}if(e.type===`AUTH0`&&e.action===`UPDATE_USER`&&e.params){let t=e.params.user_id&&Yz(e.params.user_id,n)||n.user.user_id,r=e.params.changes?Zz(e.params.changes,n):{};Object.keys(r).length>0&&s.push({user_id:t,changes:r})}}}if(e.config.next_node){a=e.config.next_node,o++;continue}return{type:`end`,userUpdates:s.length>0?s:void 0}}return null}return null}async function iB(e,t,n,r,i){let a=e.env.data,o=e.var.tenant_id||e.req.header(`tenant-id`);if(!o)throw new p.HTTPException(400,{message:`Missing tenant_id in context`});let s=i?Hz(i):`/u`,c=await a.forms.get(o,t);if(!c)throw new p.HTTPException(404,{message:`Form not found for post-user-login hook`});let l=c.start?.next_node;if(!l&&c.nodes&&c.nodes.length>0&&(l=c.nodes.find(e=>e.type===`STEP`)?.id),!l)throw new p.HTTPException(400,{message:`No start node found in form`});if(r&&c.nodes){let i=await rB(c.nodes,l,{user:r},async e=>{let t=await a.flows.get(o,e);return t?{actions:t.actions?.map(e=>({type:e.type,action:e.action,params:`params`in e&&e.params?e.params:void 0}))}:null});if(i&&i.userUpdates&&i.userUpdates.length>0){let e=tB(i.userUpdates);for(let t of e){let e=eB(t.changes,r);await a.users.update(o,t.user_id,e)}}if(!i||i.type===`end`)return r;if(i.type===`redirect`){let r=i.target,a=nB(r,i.customUrl,n.id);if(r===`change-email`||r===`account`){let t=`${s}/continue?state=${encodeURIComponent(n.id)}`;await JV(e,o,n,[r],t)}else await GV(e,o,n,`form:${t}`);return new Response(null,{status:302,headers:{location:a}})}l=i.nodeId}await GV(e,o,n,`form:${t}`);let u=`${s}/forms/${c.id}/nodes/${l}?state=${encodeURIComponent(n.id)}`;return new Response(null,{status:302,headers:{location:u}})}function aB(e){return typeof e.page_id==`string`&&typeof e.enabled==`boolean`}async function oB(e,t,n,r,i,a){let o=e.env.data,s=e.var.tenant_id||e.req.header(`tenant-id`);if(!s)throw new p.HTTPException(400,{message:`Missing tenant_id in context`});if(i&&!(await o.userPermissions.list(s,r.user_id)).some(e=>e.permission_name===i))return r;await GV(e,s,n,`page:${t}`);let c=`/u`,l=a;if(!l&&n.authParams.client_id)try{l=await nR(e.env,n.authParams.client_id,s)}catch{}l&&(c=Hz(l));let u=`${c}/${t}?state=${encodeURIComponent(n.id)}`;return new Response(null,{status:302,headers:{location:u}})}function sB(e){let{ctx:t,data:n,tenantId:r,candidates:i,externalConnections:a}=e,o=e.requireVerifiedEmail??!0,s=e.ensuredUserIds??new Set,c=e.user,l=null,u=(e,n,i)=>{O(t,r,{type:E.FAILED_HOOK,description:n,userId:c.user_id,details:{trigger_id:`post-user-login`,reason:e,primary_user_id:i}})},d=async e=>!e.linked_to&&!!a&&await a.isExternalUser(e);return{api:{user:{setLinkedTo:async e=>{let t=s.has(e),a=t?await n.users.get(r,e):i.find(t=>t.user_id===e);if(!a){u(`not_a_link_candidate`,`post-user-login action tried to link ${c.user_id} to non-candidate ${e}`,e);return}if(c.user_id===a.user_id||c.linked_to===a.user_id){l=a.user_id;return}if(!t&&o&&(!c.email||!c.email_verified)){u(`unverified_email`,`post-user-login action link refused: ${c.user_id} has no verified email`,e);return}let f=c.linked_to?await n.users.get(r,c.linked_to)??c:c,p=a.linked_to?await n.users.get(r,a.linked_to)??a:a;if(p.user_id===f.user_id){l=f.user_id;return}let[m,h]=await Promise.all([d(f),d(p)]);if(m&&h){u(`already_anchored`,`post-user-login action link refused: ${c.user_id} is already anchored to ${f.user_id}`,e);return}let g=async e=>{await n.users.update(r,p.user_id,{linked_to:e}),l=e},_=async()=>{await n.users.update(r,f.user_id,{linked_to:a.user_id}),c={...c,linked_to:p.user_id},l=p.user_id;let e=await Vu(n.users,r,a.user_id);c={...c,linked_to:e},l=e};h?await _():m||Fu(f,p)<0?await g(f.user_id):await _()}}},getLinkedPrimaryId:()=>l}}function cB(e){let t=(e.authentication?.methods??[]).filter(e=>e.name===`mfa`&&!Number.isNaN(Date.parse(e.timestamp)));if(t.length===0)return;let n=t[0].timestamp;for(let e of t)Date.parse(e.timestamp)>Date.parse(n)&&(n=e.timestamp);let r=[];for(let e of t)e.type&&!r.includes(e.type)&&r.push(e.type);return{completed_at:n,types:r}}function lB(e,t){if(e.revoked_at||e.user_id!==t)return!1;let n=Date.now();return e.expires_at&&Date.parse(e.expires_at)<n||e.idle_expires_at&&Date.parse(e.idle_expires_at)<n?!1:cB(e)!==void 0}async function uB(e,t,n,r){let i=n.authentication?.methods??[];if(i.some(e=>e.name===`mfa`&&e.timestamp===r.timestamp))return;let a={name:`mfa`,timestamp:r.timestamp,...r.type?{type:r.type}:{}};await e.update(t,n.id,{authentication:{methods:[...i,a]}})}function dB(e){return typeof e.url==`string`}async function fB(e,t,n,r,i,a){let o=[];try{o=(await t.userRoles.list(n,r.user_id,void 0,``)).map(e=>e.name||e.id)}catch(e){console.error(`Error fetching user roles:`,e)}let s=a.connection,c=await qc(e,n,s,r),l;try{if(i.authParams?.organization){let e=await t.organizations.get(n,i.authParams.organization);e&&(l={id:e.id,name:e.name,display_name:e.display_name||e.name,metadata:e.metadata||{}})}}catch(e){console.error(`Error fetching organization info:`,e)}let u=e.var?.countryCode,d=e.var?.ip,f=e.var?.useragent;return{ctx:e,client:a.client,user:rR(r),request:{asn:void 0,ip:d||``,user_agent:f,method:e.req.method,url:i.authorization_url||ll(e.req.url),geoip:{cityName:void 0,continentCode:void 0,countryCode:u||void 0,countryName:void 0,latitude:void 0,longitude:void 0,timeZone:void 0}},transaction:{id:i.id,locale:i.authParams?.ui_locales||`en`,login_hint:void 0,prompt:i.authParams?.prompt,redirect_uri:i.authParams?.redirect_uri,requested_scopes:i.authParams?.scope?.split(` `)||[],response_mode:i.authParams?.response_mode,response_type:i.authParams?.response_type,state:i.authParams?.state,ui_locales:i.authParams?.ui_locales},scope:a.authParams?.scope||``,grant_type:a.authParams?.grant_type||``,audience:a.authParams?.audience,authentication:{methods:[{name:r.is_social?`federated`:`pwd`,timestamp:new Date().toISOString()}]},authorization:{roles:o},connection:c??{id:s||Go.USERNAME_PASSWORD,name:s||Go.USERNAME_PASSWORD,strategy:a.authStrategy?.strategy||r.provider||`auth0`},organization:l,resource_server:a.authParams?.audience?{identifier:a.authParams.audience}:void 0,stats:{logins_count:r.login_count||0},tenant:{id:n},session:{id:i.id,created_at:i.created_at,authenticated_at:new Date().toISOString(),clients:[{client_id:a.client.client_id}],device:{initial_ip:d,initial_user_agent:f,last_ip:r.last_ip||d,last_user_agent:f},session_transfer:e.var?.session_transfer?{client_id:e.var.session_transfer.client_id,parent_refresh_token:{id:e.var.session_transfer.family_id}}:void 0},session_transfer_token:e.var?.session_transfer_token}}function pB(e,t,n){let r=typeof t==`string`&&t?t:`any`;if(r===`none`)return e;let i=typeof n==`object`&&!!n&&`allowRememberBrowser`in n&&n.allowRememberBrowser===!0;return{provider:r,allow_remember_browser:e?e.allow_remember_browser&&i:i}}function mB(e){try{let t=JSON.parse(e.message);if(typeof t==`object`&&t){if(`error_description`in t&&typeof t.error_description==`string`)return t.error_description;if(`message`in t&&typeof t.message==`string`)return t.message}}catch{}return e.message||`access_denied`}async function hB(e,t,n,r){if(e.set(`post_login_action_claims`,r),!n)return;let i=!!(r.access_token||r.id_token),a=Pm(n.state_data).action_claims;if(!(!i&&!a))try{if(!await wO(e.env.data.loginSessions,t,n.id,{type:j.UPDATE_CONTEXT,data:{action_claims:i?r:void 0}}))throw Error(`Failed to store post-login action claims on login session ${n.id}`)}catch(e){if(!(e instanceof yO))throw e;console.warn(`Post-login action claims not stored:`,e.message)}}async function gB(e,t,n,r,i){i=await Hu(e.env.data.users,t,await e.env.data.users.get(t,i.user_id)??i),await wO(e.env.data.loginSessions,t,n.id,{type:j.UPDATE_CONTEXT,data:{mfa_required_by_action:r}},{user_id:i.user_id});let a=await e.env.data.loginSessions.get(t,n.id);if(!a||a.state!==T.AUTHENTICATED||Pm(a.state_data).mfa_verified)return;if(a.session_id){let n=await e.env.data.sessions.get(t,a.session_id);if(n&&lB(n,i.user_id))return}let o=await e.env.data.tenants.get(t);if(o){let{isBrowserRememberedForMfa:t}=await Promise.resolve().then(()=>require("./authhero.cjs")).then(e=>e.t);if(await t(e,{tenant:o,userId:i.user_id,actionRequest:r}))return}let s=`/u2/continue?state=${encodeURIComponent(n.id)}`;return await JV(e,t,a,[],s),new Response(null,{status:302,headers:{location:s}})}async function _B(e,t,n,r,i,a){let o=a?.authStrategy?.strategy_type?a.authStrategy.strategy_type:r.is_social?Ko.SOCIAL:Ko.DATABASE,s=a?.authStrategy?.strategy||r.connection||``,c=Kc({loginSession:i,authConnection:a?.authConnection,ctxConnection:e.var.connection,user:r})||``,l=null,u=[],d,f;try{let o=new Date().toISOString(),s=e.var.ip||``,l=r.login_count+1;t.userActivity?Uc(e,t.userActivity.upsert(n,r.user_id,{last_login:o,last_ip:s,login_count:l})):Uc(e,t.users.update(n,r.user_id,{last_login:o,last_ip:s,login_count:l}));let m=a?.client&&a?.authParams&&i?await fB(e,t,n,r,i,{client:a.client,authParams:a.authParams,authStrategy:a.authStrategy,connection:c}):null;if(e.env.hooks?.onExecutePostLogin&&m&&i){let r=null,a=new Date().toISOString(),o=null;try{await e.env.hooks.onExecutePostLogin(m,{prompt:{render:e=>{}},multifactor:{enable:(e,t)=>{d=pB(d,e,t)}},redirect:{sendUserTo:(t,n)=>{let a=new URL(t,e.req.url);n?.query&&Object.entries(n.query).forEach(([e,t])=>{a.searchParams.set(e,t)}),a.searchParams.set(`state`,i.id),r=a.toString()},encodeToken:e=>{throw Error(`redirect.encodeToken is not implemented`)},validateToken:e=>{throw Error(`redirect.validateToken is not implemented`)}},token:_z(e,n)})}catch(e){o=e}if(u.push({result:{action_name:`onExecutePostLogin`,error:o?{id:`execution_threw`,msg:o instanceof Error?o.message:String(o)}:null,started_at:a,ended_at:new Date().toISOString()},logs:[],denied:!1}),o)throw o;if(d&&await wO(t.loginSessions,n,i.id,{type:j.UPDATE_CONTEXT,data:{mfa_required_by_action:d}}),r)return await GV(e,n,i,`onExecutePostLogin`),new Response(null,{status:302,headers:{location:r}})}let{hooks:h}=await t.hooks.list(n),g=h.filter(e=>e.trigger_id===`post-user-login`),_=g.filter(e=>e.enabled&&fz(e));for(let t of _)if(fz(t))try{r=await hz(e,t.template_id,r,t.metadata)}catch(r){let i=r instanceof Error?r.message:String(r);O(e,n,{type:E.FAILED_HOOK,description:`Failed to execute template hook ${t.template_id}: ${i}`,details:{template_id:t.template_id,trigger_id:`post-user-login`,error:i}})}if(r=await Hu(t.users,n,r),i){let t=g.find(e=>e.enabled&&Jz(e));if(t&&Jz(t)){let n=await iB(e,t.form_id,i,r,a?.client);if(n instanceof Response)return n;r=n}let n=a?.sessionReused?void 0:g.find(e=>e.enabled&&aB(e));if(n&&aB(n)){let t=await oB(e,n.page_id,i,r,n.permission_required,a?.client);if(t instanceof Response)return t;r=t}}let v=g.filter(e=>e.enabled&&wR(e));if(m&&v.length>0){let a=v.some(e=>e.metadata?.resolve_link_candidates===!0),o=a?await az({userAdapter:t.users,connectionAdapter:t.connections,tenantId:n,user:r}):[],s=a?oz(o):[],c=Tz(t,n,Object.keys(e.env.STRATEGIES??{})),l=Ez({ctx:e,data:t,tenantId:n,triggerId:`post-user-login`,externalConnections:c}),h=sB({ctx:e,data:t,tenantId:n,user:r,candidates:o,ensuredUserIds:l.ensuredUserIds,externalConnections:c}),g={},_={},y=[],b=e=>()=>{y.push(e)},x=e=>(t,n)=>{typeof t==`string`&&t&&(e[t]=n)},S={...h.api,...l.api,multifactor:{enable:(e,t)=>{d=pB(d,e,t)}},accessToken:{setCustomClaim:x(g)},idToken:{setCustomClaim:x(_)},access:{deny:(e,t)=>{throw new k(403,{error:`access_denied`,error_description:[t,e].find(e=>typeof e==`string`&&e.trim()!==``)??`Access denied`})}},redirect:{sendUserTo:b(`redirect.sendUserTo`)},prompt:{render:b(`prompt.render`)}},ee=async(t,r)=>{if(f=t,i)try{await WV(e,n,i,`post_login_denied: ${t}`)}catch(e){console.warn(`Failed to mark denied login session:`,e)}throw r};for(let i of v){if(!wR(i))continue;let a=AR(i),o=i.metadata?.resolve_link_candidates===!0?{...m,link_candidates:s}:m;y=[];let c;try{c=await PR(e,t,i,o,`post-user-login`,S),!c&&a&&(c=MR(i.code_id))}catch(e){e instanceof p.HTTPException&&(u.push(jR(i.code_id,e,!0)),await ee(mB(e),e)),c=jR(i.code_id,e)}if(c){if(u.push(c),y.length>0&&!c.result.error){let t=[...new Set(y)].map(e=>`api.${e}`).join(`, `);c.result.error={id:`unsupported_api`,msg:`${t} is not supported in post-login actions and was ignored`},O(e,n,{type:E.FAILED_HOOK,description:`Post-login action ${c.result.action_name} called ${t}, which is not supported and was ignored`,userId:r.user_id})}c.failure&&a&&(c.denied=!0,await ee(c.failure,new k(403,{error:`access_denied`,error_description:c.failure})))}}let te=h.getLinkedPrimaryId(),ne=te&&te!==r.user_id?te:l.ensuredUserIds.has(r.user_id)?r.user_id:null;if(ne){let e=await t.users.get(n,ne);e&&(r=e)}await hB(e,n,i,{user_id:r.user_id,...Object.keys(g).length?{access_token:g}:{},...Object.keys(_).length?{id_token:_}:{}})}if(await yR(e,g.filter(e=>e.enabled&&dB(e)),{tenant_id:n,user:r,trigger_id:`post-user-login`,request:{url:i?.authorization_url||ll(e.req.url)}}),d&&i){let t=await gB(e,n,i,d,r);if(t)return t}return r}finally{if(u.length>0)try{let r=await LR(t,n,`post-user-login`,u,{logCapture:e.env.actionExecutionLogs});r&&(l=r,e.set(`action_execution_id`,r))}catch(e){console.warn(`Failed to persist post-login action execution:`,e)}let d=Pm(i?.state_data).session_cookie,p=Bd(e.req.header(`cookie`)),m={...d?{session_cookie:d}:{},...p===void 0?{}:{private_browsing:p}};O(e,n,{type:f?E.FAILED_LOGIN:E.SUCCESS_LOGIN,description:f?`Login for ${r.user_id} denied by a post-login action: ${f}`:`Successful login for ${r.user_id}`,userId:r.user_id,username:r.email||r.phone_number||r.name,client_name:a?.client?.name,strategy_type:o,strategy:s,connection:c,audience:a?.authParams?.audience,scope:a?.authParams?.scope,redirect_uri:a?.authParams?.redirect_uri,authorization_url:i?.authorization_url,login_session_id:i?.id,...l?{execution_id:l}:{},...Object.keys(m).length?{diagnostics:m}:{}})}}function vB(e,t,n,r){let i=new Headers(r);i.set(`Server-Timing`,`cf-nel=0; no-cloudflare-insights=1`);let a=`<!DOCTYPE html>
330
+ </html>`;return new Response(r,{headers:{"Content-Type":`text/html`}})}async function ML(e,t,n,r,i,a){let o=i=>O(e,t.tenant.id,{type:E.FAILED_LOGIN,description:`SAML: ${i}`,userId:r?.user_id,username:r?.email,login_session_id:a,details:{client_id:t.client_id,reason:i,redirect_uri:n.redirect_uri}});function s(e,t){throw o(t),new k(e,{message:t})}n.redirect_uri||s(400,`Missing redirect_uri in authParams`),r.email||s(400,`Missing email in user`);let c;try{[c]=await VD(e.env.data.keys,t.tenant.id,e.env.signingKeyMode,{purpose:`sign`,type:`saml_encryption`})}catch(e){throw o(`Failed to resolve signing key`),e}c||s(500,`No signing key found`),t.addons?.samlp||s(400,`SAML Addon is not enabled for client ${t.client_id}`);let{recipient:l,audience:u}=t.addons.samlp,d=n.state||``;(!l||!d||!r||!n.state)&&s(400,`Missing recipient or inResponseTo`);let f,p;try{f=JSON.parse(n.state),p=new URL(n.redirect_uri)}catch(e){throw o(`Invalid state or redirect_uri: ${e instanceof Error?e.message:String(e)}`),e}let m=e.env.samlSigner||(e.env.SAML_SIGN_URL?new kL(e.env.SAML_SIGN_URL):void 0),h=r.app_metadata?.vimeo?.user_id,g=h||r.user_id,_=u||n.client_id,v;try{v=await BI({issuer:e.env.ISSUER,audience:_,destination:p.toString(),inResponseTo:f.requestId,userId:g,email:r.email,sessionIndex:i,signature:{privateKeyPem:c.pkcs7,cert:c.cert,kid:c.kid}},m)}catch(e){throw o(`Failed to create SAML response: ${e instanceof Error?e.message:String(e)}`),e}return O(e,t.tenant.id,{type:E.INFORMATION,description:`SAML assertion issued`,userId:r.user_id,username:r.email,audience:_,login_session_id:a,details:{client_id:t.client_id,name_id:r.email,id_attribute:g,id_attribute_source:h?`app_metadata.vimeo.user_id`:`user_id`,audience:_,destination:p.toString(),signing_key_kid:c.kid,in_response_to:f.requestId}}),jL(p.toString(),v,f.relayState)}var NL=[/^10\./,/^192\.168\./,/^172\.(1[6-9]|2\d|3[01])\./,/^169\.254\./,/^127\./,/^0\./,/^100\.(6[4-9]|[7-9]\d|1[01]\d|12[0-7])\./],PL=new Set([`localhost`,`ip6-localhost`,`ip6-loopback`,`broadcasthost`]);function FL(e){let t=e.replace(/^\[|\]$/g,``).toLowerCase();if(t===`::`||t===`::1`||t.startsWith(`fc`)||t.startsWith(`fd`))return!0;let n=t.split(`:`)[0];if(n&&/^[0-9a-f]+$/.test(n)){let e=parseInt(n,16);if(!Number.isNaN(e)&&e>=65152&&e<=65215)return!0}let r=IL(t);return!!(r&&LL(r))}function IL(e){let t=e.match(/^::(?:ffff:)?(\d+\.\d+\.\d+\.\d+)$/);if(t&&t[1])return t[1];let n=e.match(/^::(?:ffff:)?([0-9a-f]{1,4}):([0-9a-f]{1,4})$/);if(n&&n[1]&&n[2]){let e=parseInt(n[1],16),t=parseInt(n[2],16);if(!Number.isNaN(e)&&!Number.isNaN(t))return[e>>8,e&255,t>>8,t&255].join(`.`)}return null}function LL(e){return/^\d+\.\d+\.\d+\.\d+$/.test(e)?NL.some(t=>t.test(e)):!1}function RL(e){let t=e.ALLOW_PRIVATE_OUTBOUND_FETCH===!0;return{allowPrivateHosts:t,allowedSchemes:t?[`http:`,`https:`]:[`https:`]}}var zL=class extends Error{constructor(e){super(`SSRF check failed: ${e}`),this.name=`SsrfBlockedError`}};function BL(e,t={}){let n=t.allowedSchemes??[`https:`],r;try{r=new URL(e)}catch{throw new zL(`invalid URL`)}if(!n.includes(r.protocol))throw new zL(`scheme ${r.protocol} not allowed`);if(t.allowPrivateHosts)return r;let i=r.hostname.toLowerCase();if(PL.has(i))throw new zL(`hostname ${i} blocked`);if(LL(i))throw new zL(`IPv4 ${i} is in a blocked range`);if(i.includes(`:`)&&FL(i))throw new zL(`IPv6 ${i} is in a blocked range`);return r}async function VL(e,t={}){let n=BL(e,t),r=t.maxBytes??64*1024,i=t.timeoutMs??5e3,a=new AbortController,o=setTimeout(()=>a.abort(),i);try{let e=await fetch(n,{method:`GET`,redirect:`manual`,signal:a.signal,headers:{accept:t.accept??`application/json, application/jwt, text/plain`}});if(e.status>=300&&e.status<400)throw new zL(`redirect (status ${e.status}) not allowed`);if(!e.body)return{status:e.status,body:``,contentType:e.headers.get(`content-type`)};let i=e.body.getReader(),o=[],s=0;for(;;){let{value:e,done:t}=await i.read();if(t)break;if(e){if(s+=e.byteLength,s>r)throw await i.cancel(),new zL(`response body exceeds ${r} bytes`);o.push(e)}}let c=new Uint8Array(s),l=0;for(let e of o)c.set(e,l),l+=e.byteLength;return{status:e.status,body:new TextDecoder().decode(c),contentType:e.headers.get(`content-type`)}}finally{clearTimeout(o)}}var HL=120,UL=5*1024,WL=[`authorization_code`,`refresh_token`];function GL(e){if(!/^https?:\/\//i.test(e))return!1;try{return new URL(e),!0}catch{return!1}}function KL(e,t){return GL(e)&&t||void 0}var qL=f.z.object({client_id:f.z.string().url(),client_name:f.z.string().min(1),grant_types:f.z.array(f.z.string()).refine(e=>e.some(e=>WL.includes(e)),{message:`grant_types must include authorization_code or refresh_token`}),redirect_uris:f.z.array(f.z.string().url()).optional(),application_type:f.z.enum([`native`,`web`]).optional(),token_endpoint_auth_method:f.z.enum([`none`,`private_key_jwt`]).optional(),jwks_uri:f.z.string().url().optional()});function JL(e){throw new k(400,{message:`Invalid CIMD client: ${e}`})}function YL(e){Buffer.byteLength(e,`utf8`)>HL&&JL(`client_id exceeds ${HL} bytes`);let t;try{t=new URL(e)}catch{JL(`client_id is not a valid URL`)}return(t.username||t.password)&&JL(`URL must not contain credentials`),t.hash&&JL(`URL must not contain a fragment`),t.search&&JL(`URL must not contain a query string`),t.port===`0`&&JL(`URL must not use port 0`),(t.pathname===``||t.pathname===`/`)&&JL(`URL must contain a path`),t}function XL(e){return e===`native`?`native`:`regular_web`}async function ZL(e,t={}){YL(e);let n;try{n=await VL(e,{...t,maxBytes:UL})}catch(e){throw e instanceof zL&&JL(e.message),e}n.status!==200&&JL(`document fetch returned status ${n.status}`);let r;try{r=JSON.parse(n.body)}catch{JL(`document is not valid JSON`)}let i=qL.safeParse(r);i.success||JL(i.error.issues.map(e=>e.message).join(`; `));let a=i.data;a.client_id!==e&&JL(`document client_id does not match the requested URL`);let o=a.token_endpoint_auth_method??`none`;o===`private_key_jwt`&&!a.jwks_uri&&JL(`jwks_uri is required when token_endpoint_auth_method is private_key_jwt`);let s=a.grant_types.filter(e=>WL.includes(e)),c=new Date().toISOString();return{...tt.parse({client_id:e,name:a.client_name,app_type:XL(a.application_type),is_first_party:!1,token_endpoint_auth_method:o,grant_types:s,callbacks:a.redirect_uris??[],connections:[],...a.jwks_uri?{client_metadata:{jwks_uri:a.jwks_uri}}:{},created_at:c,updated_at:c}),client_secret:void 0}}tt.extend({tenant:hi,connections:f.z.array(Ut)});function QL(e,t){return[...new Set([...t||[],...e||[]])]}function $L(e,t){return{...e,callbacks:QL(e.callbacks,t.callbacks),web_origins:QL(e.web_origins,t.web_origins),allowed_logout_urls:QL(e.allowed_logout_urls,t.allowed_logout_urls),allowed_origins:QL(e.allowed_origins,t.allowed_origins)}}function eR(e,t,n,r){let i=wc(e,void 0,`u2`),a=wc(e,void 0,`u`);return{...t,web_origins:[...t.web_origins||[],`${i}login`,`${a}login`],allowed_logout_urls:[...t.allowed_logout_urls||[],e.ISSUER],callbacks:[...t.callbacks||[],`${i}info`,`${a}info`],tenant:n,connections:r.filter(e=>e.strategy!==Go.EXTERNAL)}}async function tR(e,t,n){if(!await e.data.clients.get(t,n.client_id))try{await e.data.clients.create(t,{client_id:n.client_id,name:n.name,app_type:n.app_type,is_first_party:!1,token_endpoint_auth_method:n.token_endpoint_auth_method,grant_types:n.grant_types,client_metadata:{cimd:`true`}})}catch(r){if(!await e.data.clients.get(t,n.client_id))throw r}}async function nR(e,t,n,r){if(GL(t)){let i=n;if(i||=(await e.data.clients.getByClientId(t))?.tenant_id,!i)throw new k(400,{message:`tenant_id is required to resolve a CIMD client`});let a=await e.data.tenants.get(i);if(!a)throw new k(404,{message:`Tenant not found`});if(a.flags?.client_id_metadata_document_registration!==!0)throw new k(403,{message:`Client not found`});let o=await ZL(t,r),s=await e.data.connections.list(i);return await tR(e,i,o),eR(e,o,a,hu(s.connections))}let i,a=n;if(!a){let n=await e.data.clients.getByClientId(t);if(!n)throw new k(403,{message:`Client not found`});let{tenant_id:r,...o}=n;i=o,a=r}let o=e.data.multiTenancyConfig,s=o?.controlPlaneTenantId,c=o?.controlPlaneClientId;if(o?.resolveControlPlane){let e=await o.resolveControlPlane({tenant_id:a});s=e?.tenantId,c=e?.clientId??c}let l=!!s&&!!c&&!(a===s&&t===c),[u,d,f,p,m]=await Promise.all([i?Promise.resolve(i):e.data.clients.get(a,t),e.data.tenants.get(a),e.data.clientConnections.listByClient(a,t),e.data.connections.list(a),l?e.data.clients.get(s,c):Promise.resolve(null)]),h=i||u;if(!h)throw new k(403,{message:`Client not found`});let g=m?$L(h,m):h;if(g.client_metadata?.status===`deleted`)throw new k(403,{message:`Client not found`});if(!d)throw new k(404,{message:`Tenant not found`});return eR(e,g,d,f.length>0?f:hu(p.connections||[]))}function rR(e){return iR(e)}function iR(e){let{registration_completed_at:t,password:n,password_hash:r,custom_password_hash:i,...a}=e;return a}function aR(e){let t=new Set,n=e;for(;n&&n!==Object.prototype;){for(let e of Object.getOwnPropertyNames(n))e!==`constructor`&&t.add(e);n=Object.getPrototypeOf(n)}return Array.from(t)}function oR(e){let t=Reflect.get(e,`webSocket`);return e.status===101||t!=null}function sR(e){return oR(e)?e:new Response(e.body,e)}function cR(e){e.res=sR(e.res)}function lR(e,t,n){let r=e.get(`serverTiming`);r?r.push({name:t,dur:n}):e.set(`serverTiming`,[{name:t,dur:n}])}function uR(e,t){return e?t.split(`,`).map(e=>e.trim()).filter(Boolean).includes(e):!1}var dR=async(e,t)=>{await t();let n=e.env.SERVER_TIMING??`off`;if(n===`off`)return;let r=e.get(`serverTiming`);if(!r||r.length===0)return;let i=r.map(e=>`${e.name};dur=${e.dur.toFixed(2)}`).join(`, `);if((n===`log`||n===`both`)&&console.log(JSON.stringify({msg:`server-timing`,method:e.req.method,path:e.req.path,ip:e.get(`ip`),tenant_id:e.get(`tenant_id`),timing:i})),n===`client`||n===`both`){if(e.res.status===101||`webSocket`in e.res)return;let t=e.env.SERVER_TIMING_IPS;if(!t||uR(e.get(`ip`),t)){cR(e);let t=e.res.headers.get(`Server-Timing`);e.res.headers.set(`Server-Timing`,t?`${t}, ${i}`:i)}}};function fR(e){if(!e)return`unknown`;let t=e.indexOf(`:`);return t===-1?e:e.slice(0,t)}function pR(e,t){let n=async(t,n)=>{let r=performance.now();try{return await n()}finally{lR(e,t,performance.now()-r)}};return{get(e){return n(`cache-get:${fR(e)}`,()=>t.get(e))},set(e,r,i){return n(`cache-set:${fR(e)}`,()=>t.set(e,r,i))},delete(e){return n(`cache-delete:${fR(e)}`,()=>t.delete(e))},deleteByPrefix(e){return n(`cache-deleteByPrefix:${fR(e)}`,()=>t.deleteByPrefix(e))},clear(){return n(`cache-clear`,()=>t.clear())}}}function mR(e,t){let n={};for(let[r,i]of Object.entries(t)){if(i==null)continue;if(typeof i==`function`){n[r]=i;continue}let t={};for(let n of aR(i)){let a=i[n];if(typeof a==`function`){let o=a.bind(i);t[n]=async(...t)=>{let i=performance.now();try{let a=await o(...t);return lR(e,`${r}-${n}`,performance.now()-i),a}catch(t){throw lR(e,`${r}-${n}-error`,performance.now()-i),t}}}else t[n]=a}n[r]=t}return n}function hR(e,t){e.set(`data`,t),e.env.data=t}function gR(e){return e.var.executorData??e.var.data??e.env.data}function _R(e,t){return e.var.baseData??t}async function vR(e,t,n){n?.user&&(n={...n,user:rR(n.user)});let r=e.env.webhookInvoker,i=async(t=`webhook`)=>(await gO(e,n.tenant_id,t)).access_token,a,o;try{let s=performance.now(),c=r?await r({hook:t,data:n,tenant_id:n.tenant_id,createServiceToken:i}):await fetch(t.url,{method:`POST`,headers:{Authorization:`Bearer ${await i()}`,"Content-Type":`application/json`},body:JSON.stringify(n)}),l=performance.now()-s;if(lR(e,`webhook-${t.hook_id}`,l),o=c.status,c.ok)await O(e,n.tenant_id,{type:E.SUCCESS_HOOK,description:`Invoked hook ${t.hook_id} - ${c.status}`,userId:n.user?.user_id,details:{trigger_id:n.trigger_id,hook_id:t.hook_id,hook_url:t.url,user_id:n.user?.user_id,user_name:n.user?.name||n.user?.email,connection:n.user?.connection,duration_ms:Math.round(l),response:{statusCode:o}},connection:n.user?.connection});else{try{a=await c.text()}catch{}let r=`Failed to invoke hook ${t.hook_id} - ${c.status} ${c.statusText}`;console.error(r,{hook_url:t.url,body:a?.substring(0,512)}),await O(e,n.tenant_id,{type:E.FAILED_HOOK,description:r,userId:n.user?.user_id,details:{trigger_id:n.trigger_id,hook_id:t.hook_id,hook_url:t.url,user_id:n.user?.user_id,user_name:n.user?.name||n.user?.email,connection:n.user?.connection,response:{statusCode:o,body:a?.substring(0,512)}},connection:n.user?.connection,waitForCompletion:!0})}return{ok:c.ok,status:o,body:a}}catch(r){let i=`Failed to invoke hook ${t.hook_id} - ${r instanceof Error?r.message:`Unknown error`}`;return console.error(i,r),await O(e,n.tenant_id,{type:E.FAILED_HOOK,description:i,userId:n.user?.user_id,details:{trigger_id:n.trigger_id,hook_id:t.hook_id,hook_url:t.url,user_id:n.user?.user_id,user_name:n.user?.name||n.user?.email,connection:n.user?.connection,error:r instanceof Error?r.message:String(r)},connection:n.user?.connection,waitForCompletion:!0}),{ok:!1,error:r instanceof Error?r.message:String(r)}}}async function yR(e,t,n){for(let r of t.filter(e=>`url`in e))await vR(e,r,n)}function bR(e){return async(t,n)=>{let{hooks:r}=await gR(e).hooks.list(t);await yR(e,r.filter(e=>e.trigger_id===`pre-user-registration`),{tenant_id:t,email:n,trigger_id:`pre-user-registration`})}}async function xR(e,t){let{hooks:n}=await gR(e).hooks.list(t);return n.find(e=>e.trigger_id===`validate-registration-username`&&`url`in e&&e.enabled)||null}function SR(e){return async(t,n)=>{let{hooks:r}=await gR(e).hooks.list(t);return await yR(e,r.filter(e=>e.trigger_id===`pre-user-deletion`),{tenant_id:t,user:n,trigger_id:`pre-user-deletion`}),n}}function CR(e){return e===`post-user-login`?`post-login`:e}function wR(e){return`code_id`in e}function TR(e,t){let{ctx:n,client:r,...i}=e;return{...i,client:r?{client_id:r.client_id,name:r.name,metadata:r.client_metadata}:void 0,secrets:t||{}}}async function ER(e,t){for(let n of e){let e=n.method.split(`.`);if(e.length!==2)continue;let r=e[0],i=e[1];t[r]&&typeof t[r][i]==`function`&&await t[r][i](...n.args)}}function DR(e){return e?e.reduce((e,t)=>(t.value!==void 0&&(e[t.name]=t.value),e),{}):{}}async function OR(e,t,n){let r=await e.actions.get(t,n);if(r){let n=e.multiTenancyConfig?.controlPlaneTenantId;if(r.inherit&&e.multiTenancyConfig?.resolveControlPlane&&(n=(await e.multiTenancyConfig.resolveControlPlane({tenant_id:t}))?.tenantId),r.inherit&&n&&n!==t){let{actions:t}=await e.actions.list(n,{q:`name:${D(r.name)}`,per_page:5}),i=t.find(e=>e.name===r.name&&e.is_system);if(i)return{code:i.code,name:r.name,secrets:{...DR(i.secrets),...DR(r.secrets)}}}return{code:r.code,name:r.name,secrets:DR(r.secrets)}}let i=await e.hookCode.get(t,n);return i?{code:i.code,name:n,secrets:i.secrets}:null}var kR=`fail_closed`;function AR(e){let t=e.metadata?.[kR];return t===!0||t===`true`}function jR(e,t,n=!1){let r=new Date().toISOString();return{result:{action_name:e,error:{id:n?`access_denied`:`execution_threw`,msg:t instanceof Error?t.message:String(t)},started_at:r,ended_at:r},logs:[],denied:n,...n?{}:{failure:`action_failed`}}}function MR(e){let t=new Date().toISOString();return{result:{action_name:e,error:{id:`execution_failed`,msg:`No code executor configured`},started_at:t,ended_at:t},logs:[],denied:!1,failure:`action_failed`}}async function NR(e){let{codeExecutor:t,data:n,tenantId:r,hook:i,event:a,triggerId:o,api:s}=e,c=await OR(n,r,i.code_id),l=new Date().toISOString();if(!c)return{result:{action_name:i.code_id,error:{id:`code_not_found`,msg:`code_id ${i.code_id} not found`},started_at:l,ended_at:new Date().toISOString()},logs:[],denied:!1,failure:`action_failed`};let u=TR(a,c.secrets);e.idempotencyKey&&(u.idempotency_key=e.idempotencyKey);let d=5e3,f,p=!1,m;try{m=await Promise.race([t.execute({code:c.code,hookCodeId:i.code_id,triggerId:o,event:u,timeoutMs:d}),new Promise(e=>{f=setTimeout(()=>{p=!0,e({success:!1,error:`Action execution timed out after ${d}ms`,durationMs:d,apiCalls:[]})},d)})])}finally{f!==void 0&&clearTimeout(f)}let h=new Date().toISOString();if(!m.success)return{result:{action_name:c.name,error:{id:`execution_failed`,msg:m.error||`Unknown error`},started_at:l,ended_at:h},logs:m.logs??[],denied:!1,failure:p?`action_timeout`:`action_failed`};await ER(m.apiCalls,s);let g=m.apiCalls.some(e=>e.method===`access.deny`);return{result:{action_name:c.name,error:null,started_at:l,ended_at:h},logs:m.logs??[],denied:g}}async function PR(e,t,n,r,i,a){let o=e.env.codeExecutor;if(!o)return null;let s=e.var.tenant_id||e.req.header(`tenant-id`);return s?NR({codeExecutor:o,data:t,tenantId:s,hook:n,event:r,triggerId:i,api:a}):null}function FR(e,t=256){let n=e.reduce((e,t)=>e+t.lines.reduce((e,t)=>e+t.message.length,0),0);if(n<=t)return e;let r=t,i=0,a=[];for(let t of e){let e=[];for(let n of t.lines){if(r<=0){i+=1;continue}n.message.length<=r?(e.push(n),r-=n.message.length):(e.push({...n,message:n.message.slice(0,r)}),r=0,i+=1)}e.length>0&&a.push({action_name:t.action_name,lines:e})}let o=a[a.length-1];return o&&o.lines.push({level:`warn`,message:`[authhero] console output truncated at ${t} characters (${n} captured, ${i} line(s) truncated or dropped)`}),a}function IR(e,t=`full`){return t===`full`?e:t===`errors`?e.filter(e=>e.denied||!!e.result.error):[]}async function LR(e,t,n,r,i={}){if(r.length===0)return null;let a=crypto.randomUUID(),o=r.some(e=>e.denied)?`canceled`:r.some(e=>e.result.error)?`partial`:`final`,s=FR(IR(r,i.logCapture).filter(e=>e.logs.length>0).map(e=>({action_name:e.result.action_name,lines:e.logs})));return await e.actionExecutions.create(t,{id:a,trigger_id:CR(n),status:o,results:r.map(e=>e.result),logs:s.length>0?s:void 0}),a}async function RR(e,t,n,r){let i=e.var.tenant_id||e.req.header(`tenant-id`);if(!i)return null;let a=t.filter(e=>!!e.enabled&&e.trigger_id===`credentials-exchange`&&wR(e)),o=[],s=()=>LR(e.env.data,i,`credentials-exchange`,o,{logCapture:e.env.actionExecutionLogs});for(let t of a){let i=AR(t),a;try{a=await PR(e,gR(e),t,n,`credentials-exchange`,r),!a&&i&&(a=MR(t.code_id))}catch(n){let r=n instanceof p.HTTPException;a=jR(t.code_id,n,r),r&&(o.push(a),await zR(e,s,n))}if(a&&(o.push(a),a.failure&&i)){a.denied=!0;try{r.access.deny(`access_denied`,a.failure)}catch(t){await zR(e,s,t)}}}return s()}async function zR(e,t,n){try{let n=await t();n&&e.set(`action_execution_id`,n)}catch(e){console.warn(`Failed to persist denied action execution:`,e)}throw n}var BR=`hook.`,VR=class{name=`code-hooks`;data;codeExecutor;logCapture;constructor(e,t,n={}){this.data=e,this.codeExecutor=t,this.logCapture=n.logCapture}accepts(e){return e.event_type.startsWith(BR)}transform(e){return{eventId:e.id,tenantId:e.tenant_id,triggerId:e.event_type.slice(5),user:e.target?.after,userId:e.target?.id,previousUser:e.target?.before,updates:e.details?.updates,request:e.request}}async deliver(e){let t=this.codeExecutor;for(let n of e){if(!t&&n.triggerId!==`post-user-update`&&n.triggerId!==`post-user-deletion`)continue;let e=(await this.listAllHooks(n.tenantId)).filter(e=>e.enabled&&e.trigger_id===n.triggerId&&wR(e)).sort((e,t)=>(t.priority??0)-(e.priority??0));if(e.length===0)continue;let r={user:n.user,user_id:n.userId,request:n.request,tenant:{id:n.tenantId},...n.previousUser!==void 0&&{previous_user:n.previousUser},...n.updates!==void 0&&{updates:n.updates}},i=[];for(let a of e)if(wR(a))try{if(!t)throw Error(`No code executor configured`);i.push(await NR({codeExecutor:t,data:this.data,tenantId:n.tenantId,hook:a,event:r,triggerId:n.triggerId,api:{user:{}},idempotencyKey:n.eventId}))}catch(e){let t=e instanceof Error?e.message:String(e);i.push({result:{action_name:a.code_id,error:{id:`execution_threw`,msg:t},started_at:new Date().toISOString(),ended_at:new Date().toISOString()},logs:[],denied:!1})}await LR(this.data,n.tenantId,n.triggerId,i,{logCapture:this.logCapture});let a=i.filter(e=>e.result.error);if(a.length>0){let e=a.map(e=>`${e.result.action_name}: ${e.result.error?.msg}`).join(`; `);throw Error(`${a.length} code hook(s) failed for ${n.triggerId}: ${e}`)}}}async listAllHooks(e){let t=[];for(let n=0;;n++){let{hooks:r}=await this.data.hooks.list(e,{page:n,per_page:100});if(t.push(...r),r.length<100)break}return t}};function HR(e){return!!(e.env.outbox?.enabled&&e.env.data.outbox)}function UR(e,t,n,r,i={}){if(HR(e))return WR(e,t,n,r,i)}function WR(e,t,n,r,i){return{tenant_id:t,event_type:`hook.${n}`,log_type:E.SUCCESS_API_OPERATION,description:`Enqueued ${n} hook dispatch`,category:`system`,actor:{type:e.var.user_id?`admin`:e.var.client_id?`client_credentials`:`system`,id:e.var.user_id||void 0,client_id:e.var.client_id||void 0},target:{type:`user`,id:r.user_id,...i.previousUser&&{before:rR(i.previousUser)},after:rR(r)},request:{method:e.req.method,path:e.req.path,ip:e.var.ip||``,user_agent:e.var.useragent||void 0},hostname:e.var.host||``,auth0_client:e.var.auth0_client,...i.updates&&{details:{updates:iR(i.updates)}},timestamp:new Date().toISOString(),id:Yl()}}function GR(e,t){let n=e.var.outboxEventPromises||[];n.push(Promise.resolve(t)),e.set(`outboxEventPromises`,n)}function KR(e,t,n,r,i={}){Uc(e,qR(e,t,n,r,i))}async function qR(e,t,n,r,i){let a=gR(e),{hooks:o}=await a.hooks.list(t),s=o.filter(e=>e.enabled&&e.trigger_id===n&&`url`in e);if(s.length>0&&await yR(e,s,{tenant_id:t,user:rR(r),trigger_id:n,...i.previousUser&&{previous_user:rR(i.previousUser)},...i.updates&&{updates:iR(i.updates)}}),n===`post-user-update`||n===`post-user-deletion`){let o=new VR(a,e.env.codeExecutor,{logCapture:e.env.actionExecutionLogs}),s=WR(e,t,n,r,i);try{await o.deliver([o.transform(s)])}catch(e){console.error(`Best-effort ${n} Action failed:`,e)}}if(n===`post-user-registration`&&r.user_id)try{await e.env.data.users.update(t,r.user_id,{registration_completed_at:new Date().toISOString()})}catch(e){console.error(`Failed to mark registration_completed_at on inline dispatch:`,e)}}function JR(e){return typeof e==`object`&&!!e&&e.status===409}function YR(e){return async(t,n,r={})=>{let{resolveEmailLinkedPrimary:i=!1,outboxEvents:a}=r;try{return{user:await e.transaction(async e=>{if(i&&!n.linked_to){let r=n.email?Ou(n.email):void 0;if(r&&n.email_verified){let i=await Ru({userAdapter:e.users,tenant_id:t,email:r,warnOnMultiplePrimaries:!0,filterCandidates:n=>au(e.connections,t,n)});i&&(n.linked_to=i.user_id)}}if(n.linked_to){let r=await Vu(e.users,t,n.linked_to);if(!await e.users.get(t,r))throw new k(400,{error:`invalid_request`,error_description:`Primary user does not exist`});n.linked_to=r}let r=await e.users.rawCreate(t,n,{outboxEvents:a});if(n.linked_to){let r=await e.users.get(t,n.linked_to);if(!r)throw new k(500,{error:`server_error`,error_description:`Failed to fetch primary user after linking`});return r}return r}),created:!0}}catch(r){if(JR(r)){let r=await XR(e,t,n);if(r)return{user:r,created:!1}}throw r}}}async function XR(e,t,n){let r=n.email?`email:${Ou(n.email)}`:n.phone_number?`phone_number:${n.phone_number}`:n.username?`username:${n.username.toLowerCase()}`:null;if(!r)return null;let{users:i}=await e.users.list(t,{page:0,per_page:10,include_totals:!1,q:r}),a=i.find(e=>e.provider===n.provider);if(!a)return null;if(a.linked_to){let n=await e.users.get(t,a.linked_to);if(!n)throw new k(500,{error:`server_error`,error_description:`Primary user does not exist for linked user`});return n}return a}function ZR(e){let t=e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``);return t.length>0?t:void 0}function QR(e){let t=[],n=e=>e.includes(`@`)?e.split(`@`)[0]??e:e;if(e.nickname&&t.push(ZR(n(e.nickname))),e.name&&t.push(ZR(n(e.name))),e.email){let n=e.email.split(`@`)[0];n&&t.push(ZR(n))}e.phone_number&&t.push(ZR(e.phone_number));let r=new Set,i=[];for(let e of t)e&&!r.has(e)&&(r.add(e),i.push(e));return i}async function $R(e,t,n,r){for(let i of r){let{users:r}=await e.list(t,{page:0,per_page:1,include_totals:!1,q:`username:${D(n)} provider:${D(i)}`});if(r.length>0)return!0}return!1}async function ez(e,t,n,r,i){for(let a of n){if(!await $R(e,t,a,r))return a;for(let n=2;n<=i+1;n++){let i=`${a}${n}`;if(!await $R(e,t,i,r))return i}}}function tz(e,t){return t(e.provider)&&e.username?!0:e.identities?e.identities.some(e=>t(e.provider)&&e.profileData?.username):!1}function nz(e){let t=e?.connection??Go.USERNAME_PASSWORD,n=e?.provider??`auth0`,r=e?.provider?t=>t===e.provider:Su,i=e?.provider?[e.provider]:bu,a=Math.max(0,Math.floor(e?.maxRetries??10));return async(e,o)=>{let{ctx:s,user:c}=e;if(!c||!s)return;let l=e.tenant?.id;if(!l)return;let u=s.env.data;if(tz(c,r))return;if(!r(c.provider))for(let e of i){let{users:t}=await u.users.list(l,{page:0,per_page:1,include_totals:!1,q:`linked_to:${D(c.user_id)} provider:${D(e)}`});if(t.length>0)return}let d=QR(c);if(d.length===0){console.warn(`[ensureUsername] No username candidates found for user ${c.user_id}`);return}for(let e=0;e<=a;e++){let o=await ez(u.users,l,d,i,a);if(!o){console.warn(`[ensureUsername] Could not find a unique username for user ${c.user_id} after ${a} retries`);return}try{if(r(c.provider))await u.users.update(l,c.user_id,{username:o});else{let e=`${n}|${Zl()}`;await u.users.create(l,{user_id:e,username:o,name:o,provider:n,connection:t,email_verified:!1,is_social:!1,linked_to:c.user_id})}return}catch(t){if(!JR(t))throw t;console.info(`[ensureUsername] Username "${o}" was claimed concurrently, retrying (attempt ${e+1}/${a})`)}}console.warn(`[ensureUsername] Could not allocate a username for user ${c.user_id} after ${a} conflict retries`)}}function rz(e){if(e.username)return e.username;if(e.preferred_username)return e.preferred_username;if(e.identities)for(let t of e.identities){if(t.username)return t.username;if(t.profileData?.username)return t.profileData.username}}function iz(){return async(e,t)=>{let{user:n}=e;if(!n)return;let r=rz(n);r&&(t.idToken.setCustomClaim(`preferred_username`,r),t.accessToken.setCustomClaim(`preferred_username`,r))}}async function az(e){let{userAdapter:t,connectionAdapter:n,tenantId:r,user:i}=e,a=async e=>{if(!n||e.length===0)return e;let t=await au(n,r,[i,...e]);return t[0]?.user_id===i.user_id?t.slice(1):[]};if(!i.email)return[];let o=Ou(i.email),s=[],c=0;for(;;){let{users:e}=await t.list(r,{page:c,per_page:100,include_totals:!1,q:`email:${D(o)}`});if(s.push(...e),e.length<100)break;c++}let l=s.filter(e=>e.user_id!==i.user_id);if(l.length===0)return[];let u=l.filter(e=>!e.linked_to);if(u.length>0)return(await a(u)).sort(Fu);let d=[],f=new Set;for(let e of l){if(!e.linked_to)continue;let n=await Vu(t,r,e.linked_to),a=await t.get(r,n);a&&a.user_id!==i.user_id&&!f.has(a.user_id)&&(f.add(a.user_id),d.push(a))}return(await a(d)).sort(Fu)}function oz(e){let t=e[0];return e.map(e=>({user_id:e.user_id,email:e.email??``,email_verified:e.email_verified??!1,provider:e.provider??``,connection:e.connection??``,created_at:e.created_at??``,is_primary:!e.linked_to,is_oldest:t?e.user_id===t.user_id:!1}))}function sz(e){if(!e)return{};if(typeof e==`string`)try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}return typeof e==`object`&&!Array.isArray(e)?e:{}}var cz=[`name`,`given_name`,`family_name`,`middle_name`,`nickname`,`preferred_username`,`picture`,`profile`,`website`,`gender`,`birthdate`,`zoneinfo`,`locale`,`phone_number`,`address`];function lz(e){return e==null||e===``}function uz(e){let t=e?.requireVerifiedEmail??!0,n=e?.copyUserMetadata??!1,r=e?.copyProfileFields??!1;return async e=>{let{ctx:i,user:a}=e;if(!a||!i)return;let o=e.tenant?.id;if(!o||a.linked_to||!a.email||t&&!a.email_verified)return;let s=i.env.data,c=(await az({userAdapter:s.users,connectionAdapter:s.connections,tenantId:o,user:a}))[0];if(!c)return;let l,u;if(Fu(a,c)<0?(l=a,u=c,await s.users.update(o,c.user_id,{linked_to:a.user_id})):(l=c,u=a,await s.users.update(o,a.user_id,{linked_to:c.user_id})),n){let e=sz(u.user_metadata),t=sz(l.user_metadata);if(e&&Object.keys(e).length>0){let n={...e,...t};Object.keys(n).some(e=>!(e in t)||t[e]!==n[e])&&await s.users.update(o,l.user_id,{user_metadata:n})}}if(r){let e=l,t=u,n={};for(let r of cz)lz(e[r])&&!lz(t[r])&&(n[r]=t[r]);Object.keys(n).length>0&&await s.users.update(o,l.user_id,n)}}}var dz=c({accountLinking:()=>uz,ensureUsername:()=>nz,setPreferredUsername:()=>iz});function fz(e){return typeof e==`object`&&!!e&&typeof e.template_id==`string`&&typeof e.enabled==`boolean`}var pz={prompt:{render:()=>{}},multifactor:{enable:()=>{}},redirect:{sendUserTo:()=>{},encodeToken:()=>``,validateToken:()=>null},token:{createServiceToken:async()=>``}};async function mz(e,t,n,r){return await r({ctx:e,user:n,tenant:{id:t},request:{ip:e.get(`ip`)||``,url:ll(e.req.url),method:e.req.method,user_agent:e.get(`useragent`)||``}},pz),await e.env.data.users.get(t,n.user_id)||n}async function hz(e,t,n,r){let i=e.var.tenant_id||e.req.header(`tenant-id`);if(!i)return n;switch(t){case`ensure-username`:return mz(e,i,n,nz());case`account-linking`:return mz(e,i,n,uz({copyUserMetadata:r?.copy_user_metadata===!0}));default:return console.warn(`[templatehooks] Unknown template_id: ${t}`),n}}async function gz(e,t,n,r){let i=e.var.tenant_id||e.req.header(`tenant-id`);if(!i)return;let a={ctx:e,user:n,tenant:{id:i},request:{ip:e.get(`ip`)||``,url:ll(e.req.url),method:e.req.method,user_agent:e.get(`useragent`)||``}};switch(t){case`set-preferred-username`:await iz()(a,r);break;default:console.warn(`[templatehooks] Unknown credentials-exchange template_id: ${t}`)}}function _z(e,t){return{createServiceToken:async n=>{if(`clientId`in n&&n.clientId!==void 0){if(typeof n.clientId!=`string`||n.clientId.length===0)throw Error("createServiceToken: `clientId` must be a non-empty string.");return(await yO(e,t,{clientId:n.clientId,scope:n.scope,audience:n.audience,expiresInSeconds:n.expiresInSeconds,customClaims:n.customClaims})).access_token}if(n.audience!==void 0)throw Error("createServiceToken: `audience` is only valid together with `clientId`.");return(await gO(e,t,n.scope,n.expiresInSeconds,n.customClaims)).access_token}}}var vz=new Set([...Object.values(Go),qo,`auth2`,`samlp`].map(e=>e.toLowerCase())),yz=[`email`,`phone_number`,`name`,`given_name`,`family_name`,`nickname`,`picture`];function bz(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xz(e){if(!bz(e))return{ok:!1,reason:`invalid_params`};let{connection:t,id:n,profile:r,app_metadata:i}=e;if(typeof t!=`string`||!t)return{ok:!1,reason:`invalid_params`};if(typeof n!=`string`||!n.trim()||n.includes(`|`))return{ok:!1,reason:`invalid_id`,connection:t,id:n};if(r!==void 0&&!bz(r)||i!==void 0&&!bz(i))return{ok:!1,reason:`invalid_params`,connection:t,id:n};let a={};if(r){for(let e of yz){let t=r[e];typeof t==`string`&&t.trim()&&(a[e]=e===`email`?Ou(t):t.trim())}typeof r.email_verified==`boolean`&&(a.email_verified=r.email_verified)}return{ok:!0,params:{connection:t,id:n,profile:a,app_metadata:i}}}var Sz=100,Cz=50;async function wz(e,t){let n=[];for(let r=0;r<Cz;r++){let{connections:i}=await e.connections.list(t,{page:r,per_page:Sz,include_totals:!1});if(n.push(...i),i.length<Sz)break}return n}function Tz(e,t,n=[]){let r=null,i=()=>(r||=wz(e,t).then(e=>{let t=new Set(vz);for(let e of n)t.add(e.toLowerCase());for(let n of e)n.strategy!==Go.EXTERNAL&&t.add(n.strategy.toLowerCase());return{external:e.filter(e=>e.strategy===Go.EXTERNAL),reserved:t}}),r);return{getActionUsersConnection:async e=>{let{external:t,reserved:n}=await i(),r=t.find(t=>t.name===e);if(!(!r||r.options?.allow_action_users!==!0||n.has(r.name.toLowerCase())))return r},isExternalUser:async e=>{let{external:t}=await i();return t.some(t=>t.name===e.connection&&t.name===e.provider)}}}function Ez(e){let{ctx:t,data:n,tenantId:r,triggerId:i,externalConnections:a}=e,o=new Set,s=0,c=(e,n,a={})=>{O(t,r,{type:E.FAILED_HOOK,description:n,details:{trigger_id:i,reason:e,...a}})};return{api:{users:{ensure:async e=>{if(s++,s>5){c(`too_many_users`,`${i} action called users.ensure more than 5 times`);return}let l=xz(e);if(!l.ok){c(l.reason,`${i} action passed invalid arguments to users.ensure`,{connection:l.connection});return}let{connection:u,id:d,profile:f,app_metadata:p}=l.params;if(!await a.getActionUsersConnection(u)){c(`connection_not_allowed`,`${i} action tried to ensure a user in connection ${u}, which does not allow action users`,{connection:u});return}let m=`${u}|${d}`,h=async(e,t)=>{let n={...f};return f.email!==void 0&&f.email!==t.email&&f.email_verified===void 0&&(n.email_verified=!1),p&&(n.app_metadata={...t.app_metadata??{},...p}),Object.keys(n).length===0?!0:e.update(r,m,n)},g=()=>n.transaction(async e=>{let t=await e.users.get(r,m);if(t&&await h(e.users,t))return`updated`;let n=new Date().toISOString(),i={...f,email_verified:f.email_verified??!1,user_id:m,provider:u,connection:u,is_social:!1,app_metadata:p??{},user_metadata:{},registration_completed_at:n};return await e.users.rawCreate(r,i),`created`}),_;try{_=await g()}catch(e){if(!JR(e))throw e;_=await g()}o.add(m),O(t,r,{type:E.SUCCESS_HOOK,description:`${i} action ${_} user ${m}`,userId:m,details:{trigger_id:i,operation:`users.ensure`,outcome:_,connection:u}})}}},ensuredUserIds:o}}async function Dz(e,t,n){let r=gR(e),i=[];for(let e=0;;e++){let a=await r.hooks.list(t,{page:e,per_page:100,q:`trigger_id:${n}`});if(i.push(...a.hooks),a.hooks.length<100)break}return i.filter(e=>e.enabled&&e.trigger_id===n).filter(wR).sort((e,t)=>(t.priority??0)-(e.priority??0))}async function Oz(e,t,n,r){let i=gR(e),a=await Dz(e,t,n),o=[],s=n===`validate-registration-username`?`Signup not allowed by Action`:`Operation denied by lifecycle Action`,c=async()=>{let r=await LR(i,t,n,o,{logCapture:e.env.actionExecutionLogs});r&&e.set(`action_execution_id`,r)};for(let l of a){let a,u;try{if(!e.env.codeExecutor)throw Error(`No code executor configured`);u=await NR({codeExecutor:e.env.codeExecutor,data:i,tenantId:t,hook:l,event:r,triggerId:n,api:{access:{deny:e=>{a=typeof e==`string`?e:void 0}}}}),u.denied&&(u.result.error={id:`access_denied`,msg:a||s})}catch(e){u={result:{action_name:l.code_id,error:{id:`execution_threw`,msg:e instanceof Error?e.message:String(e)},started_at:new Date().toISOString(),ended_at:new Date().toISOString()},denied:!1,logs:[]}}if(o.push(u),u.denied||u.result.error)return await c(),await O(e,t,{type:E.FAILED_HOOK,description:`${n} Action ${u.denied?`denied the operation`:`failed`}`,userId:typeof r.user_id==`string`?r.user_id:void 0}),{allowed:!1,reason:u.denied?a||s:`${n} Action failed`}}return await c(),{allowed:!0}}async function kz(e,t,n,r){let i=await Oz(e,t,n,r);if(!i.allowed)throw new k(400,{message:i.reason})}var Az=1e4;async function jz(e,t,n,r,i=`email`,a={}){let o=t.connections.find(e=>e.name===i);if(!o){let e=t.connections.filter(e=>e.strategy===i);if(e.length>1)return{allowed:!1,reason:`Ambiguous connection: client has ${e.length} connections with strategy "${i}" (${e.map(e=>e.name).join(`, `)}). Pass an explicit connection name.`};e.length===1&&(o=e[0],console.warn(`[validate-signup] resolved connection by strategy fallback: strategy="${i}" matched "${o.name}"`))}let s=(a.identifierPreflight===!0||e.var.is_lazy_migration===!0)&&o?.options?.import_mode===!0;if(o?.options?.disable_signup&&!s){let i=e.var.loginSession?.authorization_url;if(i&&new URL(i).searchParams.get(`screen_hint`)===`signup`)return{allowed:!0};if(!await Lu({userAdapter:n.users,tenant_id:t.tenant.id,email:r}))return{allowed:!1,reason:`User account does not exist`}}if(e.env.hooks?.onExecuteValidateRegistrationUsername){let n={method:e.req.method,ip:e.var.ip||e.get(`ip`)||``,user_agent:e.var.useragent||e.get(`useragent`)||``,url:ll(e.req.url)},a=!1,o;try{if(await e.env.hooks.onExecuteValidateRegistrationUsername({ctx:e,client:t,request:n,tenant:{id:t.tenant.id},user:{email:r,connection:i}},{deny:e=>{a=!0,o=e},token:_z(e,t.tenant.id)}),a)return{allowed:!1,reason:o}}catch{return{allowed:!1,reason:`Signup validation hook failed`}}}let c=await Oz(e,t.tenant.id,`validate-registration-username`,{client:t,tenant:{id:t.tenant.id},user:{email:r,connection:i},request:{method:e.req.method,ip:e.var.ip||``,user_agent:e.var.useragent||``,url:ll(e.req.url)}});if(!c.allowed)return c;let l=await xR(e,t.tenant.id);if(l&&`url`in l)try{let n=await gO(e,t.tenant.id,`webhook`),a=new AbortController,o=setTimeout(()=>a.abort(),Az),s;try{s=await fetch(l.url,{method:`POST`,headers:{Authorization:`Bearer ${n.access_token}`,"Content-Type":`application/json`},body:JSON.stringify({tenant_id:t.tenant.id,email:r,connection:i,client_id:t.client_id,trigger_id:`validate-registration-username`}),signal:a.signal})}finally{clearTimeout(o)}if(!s.ok)return{allowed:!1,reason:await s.text()||`Signup not allowed by webhook`};let c=await s.json();if(c.allowed===!1)return{allowed:!1,reason:c.reason||`Signup not allowed by webhook`}}catch{O(e,t.tenant.id,{type:E.FAILED_HOOK,description:`Validate signup email webhook failed`})}return{allowed:!0}}async function Mz(e,t,n,r,i){let a=await jz(e,t,n,r,i);if(!a.allowed)throw O(e,t.tenant.id,{type:E.FAILED_SIGNUP,description:a.reason||`Signup not allowed`}),new k(400,{message:a.reason||`Signups are disabled for this connection`});await bR(e)(t.tenant.id,r)}async function Nz(e,t,n){if(n){let r=await e.env.data.clients.get(t,n);if(r?.user_linking_mode)return r.user_linking_mode}let r=e.env.userLinkingMode;if(typeof r==`function`){let e=await r({tenant_id:t,client_id:n});return e===`builtin`||e===`off`?e:`builtin`}return r??`builtin`}async function Pz(e,t,n){return await Nz(e,t,n)===`builtin`}var Fz=class e extends p.HTTPException{code;constructor(t,n){super(400,{message:n,res:new Response(JSON.stringify({message:n}),{status:400,headers:{"Content-Type":`application/json`}})}),this.name=e.name,this.code=t}};function Iz(e,t,n,r){let i=e[t];e[t]={...i&&typeof i==`object`&&!Array.isArray(i)?i:{},[n]:r}}function Lz(e,t){return async(n,r)=>{if(e.var.client_id&&e.var.client_id_from_token!==!0){let n=await nR(e.env,e.var.client_id,e.var.tenant_id);r.email&&await Mz(e,n,t,r.email,r.connection)}let i={method:e.req.method,ip:e.req.query(`x-real-ip`)||``,user_agent:e.req.query(`user-agent`),url:e.var.loginSession?.authorization_url||ll(e.req.url),body:e.var.signup_body},{hooks:a}=await t.hooks.list(n),o=a.filter(e=>e.trigger_id===`pre-user-registration`&&e.enabled).filter(wR),s=(e,t)=>{Iz(r,`user_metadata`,e,t)},c=(e,t)=>{Iz(r,`app_metadata`,e,t)},l=r.linked_to,u,d=e=>{u=e,r.linked_to=e};if(e.env.hooks?.onExecutePreUserRegistration)try{await e.env.hooks.onExecutePreUserRegistration({ctx:e,user:r,request:i,tenant:{id:n}},{user:{setUserMetadata:s,setAppMetadata:c,setLinkedTo:d},access:{deny:(e,t)=>{throw new k(400,{message:t?`Registration denied: ${e} - ${t}`:`Registration denied: ${e}`})}},validation:{error:(e,t)=>{throw new Fz(e,t)}},token:_z(e,n)})}catch(t){if(t instanceof p.HTTPException)throw t;let i=t instanceof Error?t.message:String(t),a=t instanceof Error?t.stack:void 0,o=t instanceof Error?t.name:void 0;O(e,n,{type:E.FAILED_SIGNUP,description:`Pre user registration hook failed for ${r.email||r.phone_number||r.user_id}: ${i}`,userId:r.user_id,connection:r.connection,details:{error:i,error_name:o,error_stack:a,user_email:r.email,user_phone_number:r.phone_number,user_provider:r.provider,user_connection:r.connection}})}{let a=[],l=Ez({ctx:e,data:t,tenantId:n,triggerId:`pre-user-registration`,externalConnections:Tz(t,n,Object.keys(e.env.STRATEGIES??{}))}),u=()=>LR(t,n,`pre-user-registration`,a,{logCapture:e.env.actionExecutionLogs}),f=(e,t)=>{throw new k(400,{message:t?`Registration denied: ${e} - ${t}`:`Registration denied: ${e}`})};for(let n of o){let o=AR(n),m;try{m=await PR(e,t,n,{ctx:e,user:r,request:i},`pre-user-registration`,{user:{setUserMetadata:s,setAppMetadata:c,setLinkedTo:d},users:l.api.users,access:{deny:f},validation:{error:(e,t)=>{throw new Fz(e,t)}}}),!m&&o&&(m=MR(n.code_id))}catch(t){if(t instanceof p.HTTPException){let r=jR(n.code_id,t,!0);t instanceof Fz&&r.result.error&&(r.result.error.id=t.code),a.push(r),await zR(e,u,t)}m=jR(n.code_id,t)}if(m&&(a.push(m),m.failure&&o)){m.denied=!0;try{f(`access_denied`,m.failure)}catch(t){await zR(e,u,t)}}}let m=await u();m&&e.set(`action_execution_id`,m)}let f=!1;u!==void 0&&r.linked_to===u&&(await t.users.get(n,u)||(O(e,n,{type:E.FAILED_HOOK,description:`pre-user-registration hook tried to link ${r.user_id} to non-existent user ${u}`,userId:r.user_id,details:{trigger_id:`pre-user-registration`,reason:`primary_not_found`,primary_user_id:u}}),f=!0,l?r.linked_to=l:delete r.linked_to)),r=ku(r);let m=!f&&await Pz(e,n,e.var.client_id),h=UR(e,n,`post-user-registration`,r),g=await YR(t)(n,r,{resolveEmailLinkedPrimary:m,outboxEvents:h?[h]:void 0});if(!g.created)throw new k(409,{message:`User already exists`});let _=g.user;return await(async()=>{if(e.env.hooks?.onExecutePostUserRegistration)try{await e.env.hooks.onExecutePostUserRegistration({ctx:e,user:r,request:i,tenant:{id:n}},{user:{},token:_z(e,n)})}catch(t){let r=t instanceof Error?t.message:String(t),i=t instanceof Error?t.stack:void 0,a=t instanceof Error?t.name:void 0;O(e,n,{type:E.FAILED_SIGNUP,description:`Post user registration hook failed for ${_.email||_.phone_number||_.user_id}: ${r}`,userId:_.user_id,connection:_.connection,details:{error:r,error_name:a,error_stack:i,user_email:_.email,user_phone_number:_.phone_number,user_provider:_.provider,user_connection:_.connection}})}{let{hooks:t}=await gR(e).hooks.list(n),r=t.filter(e=>e.trigger_id===`post-user-registration`&&e.enabled&&fz(e));for(let t of r)if(fz(t))try{_=await hz(e,t.template_id,_,t.metadata)}catch(r){let i=r instanceof Error?r.message:String(r),a=r instanceof Error?r.stack:void 0,o=r instanceof Error?r.name:void 0;O(e,n,{type:E.FAILED_SIGNUP,description:`Post user registration template hook ${t.template_id} failed for ${_.email||_.phone_number||_.user_id}: ${i}`,userId:_.user_id,connection:_.connection,details:{template_id:t.template_id,trigger_id:`post-user-registration`,error:i,error_name:o,error_stack:a,user_email:_.email}})}}h?GR(e,h.id):KR(e,n,`post-user-registration`,_)})(),_}}function Rz(e,t){return async(n,r,i)=>{if(`linked_to`in i&&i.linked_to===r)throw new k(400,{message:`Cannot link a user to itself`});if(Object.keys(i).length===1&&`linked_to`in i){let{linked_to:e}=i;return e?t.transaction(async t=>(await Uu({userAdapter:t.users,tenant_id:n,userId:r,primaryId:e}),!0)):t.users.update(n,r,i)}let a=await t.users.get(n,r);if(!a)throw new k(404,{message:`User not found`});let o=structuredClone(a),s={method:e.req.method,ip:e.var.ip||e.get(`ip`)||``,user_agent:e.var.useragent||e.get(`useragent`)||``,url:ll(e.req.url)};if(e.env.hooks?.onExecutePreUserUpdate)try{await e.env.hooks.onExecutePreUserUpdate({ctx:e,tenant:{id:n},user_id:r,user:rR(a),updates:i,request:s},{user:{setUserMetadata:async(e,t)=>{i[e]=t}},cancel:()=>{throw new k(400,{message:`User update cancelled by pre-update hook`})},token:_z(e,n)})}catch(t){throw O(e,n,{type:E.ACTIONS_EXECUTION_FAILED,description:`Pre user update hook failed: ${t instanceof Error?t.message:`Unknown error`}`,userId:r}),new k(400,{message:`Pre user update hook failed`})}i=ku(i);let c={previousUser:o,updates:iR(i)};await kz(e,n,`pre-user-update`,{user:rR(o),previous_user:rR(o),updates:c.updates,user_id:r,tenant:{id:n},request:s});let l=await Pz(e,n,e.var.client_id),u=UR(e,n,`post-user-update`,{...a,...i},c);await t.transaction(async e=>{if(!await e.users.update(n,r,i,{outboxEvents:u?[u]:void 0}))throw new k(404,{message:`User not found`});if(l&&(i.email||i.email_verified)){let t=await e.users.get(n,r);if(t&&!t.linked_to&&t.email&&t.email_verified){let i=Ou(t.email),{users:a}=await e.users.list(n,{page:0,per_page:10,include_totals:!1,q:`email:${D(i)}`}),o=a.filter(e=>e.user_id!==r),s=o.filter(e=>!e.linked_to),c=s.length>0?[...s].sort(Fu)[0]:void 0;if(c)Fu(t,c)<0?await Uu({userAdapter:e.users,tenant_id:n,userId:c.user_id,primaryId:r}):await Uu({userAdapter:e.users,tenant_id:n,userId:r,primaryId:c.user_id});else if(o.some(e=>e.linked_to)){let i=[],a=new Set;for(let t of o){if(!t.linked_to)continue;let o=new Set([t.user_id]),s=await e.users.get(n,t.linked_to);for(;s&&s.linked_to;){if(o.has(s.user_id)){s=null;break}o.add(s.user_id),s=await e.users.get(n,s.linked_to)}s&&s.user_id!==r&&!a.has(s.user_id)&&(a.add(s.user_id),i.push(s))}let s=i.length>0?i.sort(Fu)[0]:void 0;s&&(Fu(t,s)<0?await Uu({userAdapter:e.users,tenant_id:n,userId:s.user_id,primaryId:r}):await Uu({userAdapter:e.users,tenant_id:n,userId:r,primaryId:s.user_id}))}}}}),u?GR(e,u.id):KR(e,n,`post-user-update`,{...a,...i},c);{let{hooks:i}=await t.hooks.list(n),a=i.filter(e=>e.trigger_id===`post-user-update`&&fz(e)&&e.enabled===!0);if(a.length>0){let i=await t.users.get(n,r);if(i){let t=i;for(let i of a)if(fz(i))try{t=await hz(e,i.template_id,t,i.metadata)}catch(t){let a=t instanceof Error?t.message:String(t),o=t instanceof Error?t.stack:void 0,s=t instanceof Error?t.name:void 0;O(e,n,{type:E.ACTIONS_EXECUTION_FAILED,description:`Post user update template hook ${i.template_id} failed: ${a}`,userId:r,details:{template_id:i.template_id,trigger_id:`post-user-update`,error:a,error_name:s,error_stack:o}})}}}}if(i.email&&O(e,n,{type:E.SUCCESS_CHANGE_EMAIL,description:`Email updated from ${a.email??`(none)`} to ${i.email}`,userId:r}),e.env.hooks?.onExecutePostUserUpdate)try{let a=await t.users.get(n,r);await e.env.hooks.onExecutePostUserUpdate({ctx:e,tenant:{id:n},user_id:r,user:a?rR(a):void 0,updates:i,request:s},{token:_z(e,n)})}catch(t){O(e,n,{type:E.ACTIONS_EXECUTION_FAILED,description:`Post user update hook failed: ${t instanceof Error?t.message:`Unknown error`}`,userId:r})}return!0}}function zz(e,t){return async(n,r)=>{let i=await Bz(e,t,n,r);return i?i():!1}}async function Bz(e,t,n,r){let i=await t.users.get(n,r);if(!i)return null;let a={method:e.req.method,ip:e.var.ip||e.get(`ip`)||``,user_agent:e.var.useragent||e.get(`useragent`)||``,url:e.req.url};if(e.env.hooks?.onExecutePreUserDeletion)try{await e.env.hooks.onExecutePreUserDeletion({ctx:e,user:rR(i),user_id:r,request:a,tenant:{id:n}},{cancel:()=>{throw new k(400,{message:`User deletion cancelled by pre-deletion hook`})},token:_z(e,n)})}catch(t){throw t instanceof p.HTTPException?t:(O(e,n,{type:E.FAILED_HOOK,description:`Pre user deletion hook failed: ${t instanceof Error?t.message:String(t)}`}),new k(400,{message:`Pre user deletion hook failed`}))}await kz(e,n,`pre-user-deletion`,{user:rR(i),user_id:r,tenant:{id:n},request:a});try{await SR(e)(n,i)}catch(t){throw O(e,n,{type:E.FAILED_HOOK,description:`Pre user deletion webhook failed: ${t instanceof Error?t.message:String(t)}`}),new k(400,{message:`Pre user deletion webhook failed`})}return async()=>{let o=UR(e,n,`post-user-deletion`,i),s=await t.transaction(async e=>{let t=await e.users.list(n,{q:`linked_to:${D(r)}`});for(let i of t.users){let[t,...a]=i.user_id.split(`|`);t&&await e.users.unlink(n,r,t,a.join(`|`))}return e.users.remove(n,r,{outboxEvents:o?[o]:void 0})});if(s&&O(e,n,{type:E.SUCCESS_USER_DELETION,description:`Deleted user: ${i.email||r}`,userId:r,strategy:i.provider||`auth0`,strategy_type:i.is_social?Ko.SOCIAL:Ko.DATABASE,connection:i.connection||``,body:{tenant:n,connection:i.connection||``}}),s&&(o?GR(e,o.id):KR(e,n,`post-user-deletion`,i),e.env.hooks?.onExecutePostUserDeletion))try{await e.env.hooks.onExecutePostUserDeletion({ctx:e,user:rR(i),user_id:r,request:a,tenant:{id:n}},{token:_z(e,n)})}catch(t){let a=t instanceof Error?t.message:String(t),o=t instanceof Error?t.stack:void 0,s=t instanceof Error?t.name:void 0;O(e,n,{type:E.FAILED_HOOK,description:`Post user deletion hook failed for ${i.email||i.phone_number||r}: ${a}`,userId:r,connection:i.connection,details:{error:a,error_name:s,error_stack:o,user_email:i.email,user_phone_number:i.phone_number,user_provider:i.provider,user_connection:i.connection}})}return s}}function Vz(e,t){let n=t,r=Lz(e,n),i=Rz(e,n);return{...t,users:{...t.users,create:(e,t)=>r(e,ku(t)),update:(e,t,n,r)=>i(e,t,ku(n),r),remove:zz(e,n)}}}function Hz(e){let t=e.client_metadata?.universal_login_version;return t===`2`?`/u2`:t===`1`?`/u`:e.tenant?.flags?.universal_login_version===`2`?`/u2`:`/u`}var Uz=new Set([`PASSWORD`,`CODE`]),Wz=`form_values`;function Gz(e){if(!e)return{};try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?{...t}:{}}catch{return{}}}function Kz(e){let t=e[Wz];if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`string`&&(n[e]=r);return n}async function qz(e,t,n,r,i){let a=await e.env.data.loginSessions.get(t,n),o=Kz(Gz(a?.state_data)),s={...o,...r};if(!a)return s;let c={...o};for(let e of i){let t=r[e.id];t!==void 0&&(Uz.has(e.type)||e.sensitive!==!0&&(c[e.id]=t))}if(Object.keys(c).length===Object.keys(o).length){let e=!1;for(let[t,n]of Object.entries(c))if(o[t]!==n){e=!0;break}if(!e)return s}return await TO(e.env.data.loginSessions,t,n,{type:j.UPDATE_CONTEXT,data:{[Wz]:c}},{}),s}function Jz(e){return typeof e.form_id==`string`}function Yz(e,t){let n=e.match(/^\{\{context\.user\.(.+)\}\}$/);if(n&&n[1])return Xz(t.user,n[1]);let r=e.match(/^\{\{user\.(.+)\}\}$/);if(r&&r[1])return Xz(t.user,r[1]);let i=e.match(/^\{\{(?:fields|\$form)\.(.+)\}\}$/);if(i&&i[1]&&t.submittedFields){let e=t.submittedFields[i[1]];return e===void 0?void 0:String(e)}return e}function Xz(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r&&typeof r==`object`&&e in r)r=r[e];else return;return typeof r==`string`?r:r==null?void 0:String(r)}function Zz(e,t){let n={};for(let[r,i]of Object.entries(e))if(typeof i==`string`){let e=Yz(i,t);e!==void 0&&(n[r]=e)}else i!=null&&(n[r]=String(i));return n}function Qz(e,t){let n=e.operator?.toLowerCase(),r=e.field??``,i=r?Yz(r,t):``;r&&i===r&&!r.startsWith(`{{`)&&(i=Xz(t.user,r));let a=e.value||``;switch(n){case`exists`:return i!=null&&i!==``;case`not_exists`:return i==null||i===``;case`ends_with`:return typeof i==`string`&&i.endsWith(a);case`starts_with`:return typeof i==`string`&&i.startsWith(a);case`contains`:return typeof i==`string`&&i.includes(a);case`not_contains`:return typeof i!=`string`||!i.includes(a);case`equals`:case`eq`:return i===a;case`not_equals`:case`neq`:return i!==a;default:if(e.operands&&Array.isArray(e.operands)){for(let n of e.operands)if(n.operator===`ENDS_WITH`&&Array.isArray(n.operands)&&n.operands.length>=2){let e=n.operands[0],r=n.operands[1];if(e&&r){let n=Yz(`{{context.user.${e}}}`,t);if(typeof n==`string`&&n.endsWith(r))return!0}}}return!1}}function $z(e,t){return Array.isArray(e.conditions)?e.conditions.every(e=>Qz(e,t)):Qz(e,t)}function eB(e,t){let n={};for(let[r,i]of Object.entries(e))if(r.startsWith(`user_metadata.`)||r.startsWith(`metadata.`)){let e=r.startsWith(`user_metadata.`)?r.slice(14):r.slice(9);n.user_metadata={...t.user_metadata||{},...n.user_metadata||{},[e]:i}}else if(r.startsWith(`address.`)){let e=r.slice(8);n.address={...t.address||{},...n.address||{},[e]:i}}else n[r]=i;return n}function tB(e){let t=new Map;for(let n of e){let e=t.get(n.user_id);e?e.changes={...e.changes,...n.changes}:t.set(n.user_id,{user_id:n.user_id,changes:{...n.changes}})}return Array.from(t.values())}function nB(e,t,n){switch(e){case`change-email`:return`/u2/account/change-email?state=${encodeURIComponent(n)}`;case`account`:return`/u2/account?state=${encodeURIComponent(n)}`;case`custom`:if(!t)throw new p.HTTPException(400,{message:`Custom URL is required for custom redirect target`});let r=new URL(t,`http://placeholder`);return r.searchParams.set(`state`,n),r.pathname+r.search;default:throw new p.HTTPException(400,{message:`Unknown redirect target: ${e}`})}}async function rB(e,t,n,r,i=10){let a=t,o=0,s=[];for(;o<i;){if(a===`$ending`)return{type:`end`,userUpdates:s.length>0?s:void 0};let t=e.find(e=>e.id===a);if(!t)return null;if(t.type===`STEP`)return{type:`step`,nodeId:t.id,userUpdates:s.length>0?s:void 0};if(t.type===`ACTION`){let e=t;if(e.config.action_type===`REDIRECT`)return{type:`redirect`,target:e.config.target,customUrl:e.config.custom_url,userUpdates:s.length>0?s:void 0};a=e.config.next_node,o++;continue}if(t.type===`ROUTER`){let e=t,r=null;for(let t of e.config.rules)if($z(t.condition,n)){r=t.next_node;break}if(r||=e.config.fallback,!r)return null;a=r,o++;continue}if(t.type===`FLOW`){let e=t;if(r&&e.config.flow_id){let t=await r(e.config.flow_id);if(t&&t.actions&&t.actions.length>0)for(let e of t.actions){if(e.type===`REDIRECT`&&e.action===`REDIRECT_USER`){let t=e.params?.target;if(t)return{type:`redirect`,target:t,customUrl:e.params?.custom_url,userUpdates:s.length>0?s:void 0}}if(e.type===`AUTH0`&&e.action===`UPDATE_USER`&&e.params){let t=e.params.user_id&&Yz(e.params.user_id,n)||n.user.user_id,r=e.params.changes?Zz(e.params.changes,n):{};Object.keys(r).length>0&&s.push({user_id:t,changes:r})}}}if(e.config.next_node){a=e.config.next_node,o++;continue}return{type:`end`,userUpdates:s.length>0?s:void 0}}return null}return null}async function iB(e,t,n,r,i){let a=e.env.data,o=e.var.tenant_id||e.req.header(`tenant-id`);if(!o)throw new p.HTTPException(400,{message:`Missing tenant_id in context`});let s=i?Hz(i):`/u`,c=await a.forms.get(o,t);if(!c)throw new p.HTTPException(404,{message:`Form not found for post-user-login hook`});let l=c.start?.next_node;if(!l&&c.nodes&&c.nodes.length>0&&(l=c.nodes.find(e=>e.type===`STEP`)?.id),!l)throw new p.HTTPException(400,{message:`No start node found in form`});if(r&&c.nodes){let i=await rB(c.nodes,l,{user:r},async e=>{let t=await a.flows.get(o,e);return t?{actions:t.actions?.map(e=>({type:e.type,action:e.action,params:`params`in e&&e.params?e.params:void 0}))}:null});if(i&&i.userUpdates&&i.userUpdates.length>0){let e=tB(i.userUpdates);for(let t of e){let e=eB(t.changes,r);await a.users.update(o,t.user_id,e)}}if(!i||i.type===`end`)return r;if(i.type===`redirect`){let r=i.target,a=nB(r,i.customUrl,n.id);if(r===`change-email`||r===`account`){let t=`${s}/continue?state=${encodeURIComponent(n.id)}`;await ZV(e,o,n,[r],t)}else await JV(e,o,n,`form:${t}`);return new Response(null,{status:302,headers:{location:a}})}l=i.nodeId}await JV(e,o,n,`form:${t}`);let u=`${s}/forms/${c.id}/nodes/${l}?state=${encodeURIComponent(n.id)}`;return new Response(null,{status:302,headers:{location:u}})}function aB(e){return typeof e.page_id==`string`&&typeof e.enabled==`boolean`}async function oB(e,t,n,r,i,a){let o=e.env.data,s=e.var.tenant_id||e.req.header(`tenant-id`);if(!s)throw new p.HTTPException(400,{message:`Missing tenant_id in context`});if(i&&!(await o.userPermissions.list(s,r.user_id)).some(e=>e.permission_name===i))return r;await JV(e,s,n,`page:${t}`);let c=`/u`,l=a;if(!l&&n.authParams.client_id)try{l=await nR(e.env,n.authParams.client_id,s)}catch{}l&&(c=Hz(l));let u=`${c}/${t}?state=${encodeURIComponent(n.id)}`;return new Response(null,{status:302,headers:{location:u}})}function sB(e){let{ctx:t,data:n,tenantId:r,candidates:i,externalConnections:a}=e,o=e.requireVerifiedEmail??!0,s=e.ensuredUserIds??new Set,c=e.user,l=null,u=(e,n,i)=>{O(t,r,{type:E.FAILED_HOOK,description:n,userId:c.user_id,details:{trigger_id:`post-user-login`,reason:e,primary_user_id:i}})},d=async e=>!e.linked_to&&!!a&&await a.isExternalUser(e);return{api:{user:{setLinkedTo:async e=>{let t=s.has(e),a=t?await n.users.get(r,e):i.find(t=>t.user_id===e);if(!a){u(`not_a_link_candidate`,`post-user-login action tried to link ${c.user_id} to non-candidate ${e}`,e);return}if(c.user_id===a.user_id||c.linked_to===a.user_id){l=a.user_id;return}if(!t&&o&&(!c.email||!c.email_verified)){u(`unverified_email`,`post-user-login action link refused: ${c.user_id} has no verified email`,e);return}let f=c.linked_to?await n.users.get(r,c.linked_to)??c:c,p=a.linked_to?await n.users.get(r,a.linked_to)??a:a;if(p.user_id===f.user_id){l=f.user_id;return}let[m,h]=await Promise.all([d(f),d(p)]);if(m&&h){u(`already_anchored`,`post-user-login action link refused: ${c.user_id} is already anchored to ${f.user_id}`,e);return}let g=async e=>{await n.users.update(r,p.user_id,{linked_to:e}),l=e},_=async()=>{await n.users.update(r,f.user_id,{linked_to:a.user_id}),c={...c,linked_to:p.user_id},l=p.user_id;let e=await Vu(n.users,r,a.user_id);c={...c,linked_to:e},l=e};h?await _():m||Fu(f,p)<0?await g(f.user_id):await _()}}},getLinkedPrimaryId:()=>l}}function cB(e){let t=(e.authentication?.methods??[]).filter(e=>e.name===`mfa`&&!Number.isNaN(Date.parse(e.timestamp)));if(t.length===0)return;let n=t[0].timestamp;for(let e of t)Date.parse(e.timestamp)>Date.parse(n)&&(n=e.timestamp);let r=[];for(let e of t)e.type&&!r.includes(e.type)&&r.push(e.type);return{completed_at:n,types:r}}function lB(e,t){if(e.revoked_at||e.user_id!==t)return!1;let n=Date.now();return e.expires_at&&Date.parse(e.expires_at)<n||e.idle_expires_at&&Date.parse(e.idle_expires_at)<n?!1:cB(e)!==void 0}async function uB(e,t,n,r){let i=n.authentication?.methods??[];if(i.some(e=>e.name===`mfa`&&e.timestamp===r.timestamp))return;let a={name:`mfa`,timestamp:r.timestamp,...r.type?{type:r.type}:{}};await e.update(t,n.id,{authentication:{methods:[...i,a]}})}function dB(e){return typeof e.url==`string`}async function fB(e,t,n,r,i,a){let o=[];try{o=(await t.userRoles.list(n,r.user_id,void 0,``)).map(e=>e.name||e.id)}catch(e){console.error(`Error fetching user roles:`,e)}let s=a.connection,c=await qc(e,n,s,r),l;try{if(i.authParams?.organization){let e=await t.organizations.get(n,i.authParams.organization);e&&(l={id:e.id,name:e.name,display_name:e.display_name||e.name,metadata:e.metadata||{}})}}catch(e){console.error(`Error fetching organization info:`,e)}let u=e.var?.countryCode,d=e.var?.ip,f=e.var?.useragent;return{ctx:e,client:a.client,user:rR(r),request:{asn:void 0,ip:d||``,user_agent:f,method:e.req.method,url:i.authorization_url||ll(e.req.url),geoip:{cityName:void 0,continentCode:void 0,countryCode:u||void 0,countryName:void 0,latitude:void 0,longitude:void 0,timeZone:void 0}},transaction:{id:i.id,locale:i.authParams?.ui_locales||`en`,login_hint:void 0,prompt:i.authParams?.prompt,redirect_uri:i.authParams?.redirect_uri,requested_scopes:i.authParams?.scope?.split(` `)||[],response_mode:i.authParams?.response_mode,response_type:i.authParams?.response_type,state:i.authParams?.state,ui_locales:i.authParams?.ui_locales},scope:a.authParams?.scope||``,grant_type:a.authParams?.grant_type||``,audience:a.authParams?.audience,authentication:{methods:[{name:r.is_social?`federated`:`pwd`,timestamp:new Date().toISOString()}]},authorization:{roles:o},connection:c??{id:s||Go.USERNAME_PASSWORD,name:s||Go.USERNAME_PASSWORD,strategy:a.authStrategy?.strategy||r.provider||`auth0`},organization:l,resource_server:a.authParams?.audience?{identifier:a.authParams.audience}:void 0,stats:{logins_count:r.login_count||0},tenant:{id:n},session:{id:i.id,created_at:i.created_at,authenticated_at:new Date().toISOString(),clients:[{client_id:a.client.client_id}],device:{initial_ip:d,initial_user_agent:f,last_ip:r.last_ip||d,last_user_agent:f},session_transfer:e.var?.session_transfer?{client_id:e.var.session_transfer.client_id,parent_refresh_token:{id:e.var.session_transfer.family_id}}:void 0},session_transfer_token:e.var?.session_transfer_token}}function pB(e,t,n){let r=typeof t==`string`&&t?t:`any`;if(r===`none`)return e;let i=typeof n==`object`&&!!n&&`allowRememberBrowser`in n&&n.allowRememberBrowser===!0;return{provider:r,allow_remember_browser:e?e.allow_remember_browser&&i:i}}function mB(e){try{let t=JSON.parse(e.message);if(typeof t==`object`&&t){if(`error_description`in t&&typeof t.error_description==`string`)return t.error_description;if(`message`in t&&typeof t.message==`string`)return t.message}}catch{}return e.message||`access_denied`}async function hB(e,t,n,r){if(e.set(`post_login_action_claims`,r),!n)return;let i=!!(r.access_token||r.id_token),a=Pm(n.state_data).action_claims;if(!(!i&&!a))try{if(!await TO(e.env.data.loginSessions,t,n.id,{type:j.UPDATE_CONTEXT,data:{action_claims:i?r:void 0}}))throw Error(`Failed to store post-login action claims on login session ${n.id}`)}catch(e){if(!(e instanceof bO))throw e;console.warn(`Post-login action claims not stored:`,e.message)}}async function gB(e,t,n,r,i){if(n){let r=await e.env.data.sessions.get(t,n);if(r&&lB(r,i.user_id))return!0}let a=await e.env.data.tenants.get(t);if(a){let{isBrowserRememberedForMfa:t}=await Promise.resolve().then(()=>require("./authhero.cjs")).then(e=>e.t);if(await t(e,{tenant:a,userId:i.user_id,actionRequest:r}))return!0}return!1}async function _B(e,t,n,r,i){i=await Hu(e.env.data.users,t,await e.env.data.users.get(t,i.user_id)??i),await TO(e.env.data.loginSessions,t,n.id,{type:j.UPDATE_CONTEXT,data:{mfa_required_by_action:r}},{user_id:i.user_id});let a=await e.env.data.loginSessions.get(t,n.id);if(!a||a.state!==T.AUTHENTICATED||Pm(a.state_data).mfa_verified||await gB(e,t,a.session_id,r,i))return;let o=`/u2/continue?state=${encodeURIComponent(n.id)}`;return await ZV(e,t,a,[],o),new Response(null,{status:302,headers:{location:o}})}async function vB(e,t,n,r,i,a){return bB(e,t,n,r,i,a)}async function yB(e,t,n,r,i,a){if(!e.env.hooks?.onExecutePostLogin){let{hooks:e}=await t.hooks.list(n);if(!e.some(e=>e.trigger_id===`post-user-login`&&e.enabled&&wR(e)))return{status:`ok`,user:r}}let o={},s;try{s=await bB(e,t,n,r,i,a,o)}catch(e){if(o.deniedReason!==void 0)return{status:`access_denied`,description:o.deniedReason};throw e}if(o.interactionRequired!==void 0)return{status:`interaction_required`,description:o.interactionRequired};if(s instanceof Response)return{status:`interaction_required`,description:`Interaction required`};if(o.mfaRequest){let r=await Hu(t.users,n,await t.users.get(n,s.user_id)??s);if(!await gB(e,n,i.session_id,o.mfaRequest,r))return{status:`interaction_required`,description:`Multi-factor authentication required`}}return{status:`ok`,user:s}}async function bB(e,t,n,r,i,a,o){let s=a?.authStrategy?.strategy_type?a.authStrategy.strategy_type:r.is_social?Ko.SOCIAL:Ko.DATABASE,c=a?.authStrategy?.strategy||r.connection||``,l=Kc({loginSession:i,authConnection:a?.authConnection,ctxConnection:e.var.connection,user:r})||``,u=null,d=[],f,m;try{let s=new Date().toISOString(),c=e.var.ip||``,u=r.login_count+1;o||(t.userActivity?Uc(e,t.userActivity.upsert(n,r.user_id,{last_login:s,last_ip:c,login_count:u})):Uc(e,t.users.update(n,r.user_id,{last_login:s,last_ip:c,login_count:u})));let h=a?.client&&a?.authParams&&i?await fB(e,t,n,r,i,{client:a.client,authParams:a.authParams,authStrategy:a.authStrategy,connection:l}):null;if(e.env.hooks?.onExecutePostLogin&&h&&i){let a=null,s=new Date().toISOString(),c=null;try{await e.env.hooks.onExecutePostLogin(h,{prompt:{render:e=>{}},multifactor:{enable:(e,t)=>{f=pB(f,e,t)}},redirect:{sendUserTo:(t,n)=>{let r=new URL(t,e.req.url);n?.query&&Object.entries(n.query).forEach(([e,t])=>{r.searchParams.set(e,t)}),r.searchParams.set(`state`,i.id),a=r.toString()},encodeToken:e=>{throw Error(`redirect.encodeToken is not implemented`)},validateToken:e=>{throw Error(`redirect.validateToken is not implemented`)}},token:_z(e,n)})}catch(e){c=e}if(d.push({result:{action_name:`onExecutePostLogin`,error:c?{id:`execution_threw`,msg:c instanceof Error?c.message:String(c)}:null,started_at:s,ended_at:new Date().toISOString()},logs:[],denied:!1}),c)throw o&&c instanceof p.HTTPException&&c.status>=400&&c.status<500&&(o.deniedReason=mB(c)),c;if(f&&!o&&await TO(t.loginSessions,n,i.id,{type:j.UPDATE_CONTEXT,data:{mfa_required_by_action:f}}),a&&o)return o.interactionRequired=`A post-login action requires a redirect to complete the login`,r;if(a)return await JV(e,n,i,`onExecutePostLogin`),new Response(null,{status:302,headers:{location:a}})}let{hooks:g}=await t.hooks.list(n),_=g.filter(e=>e.trigger_id===`post-user-login`),v=o?[]:_.filter(e=>e.enabled&&fz(e));for(let t of v)if(fz(t))try{r=await hz(e,t.template_id,r,t.metadata)}catch(r){let i=r instanceof Error?r.message:String(r);O(e,n,{type:E.FAILED_HOOK,description:`Failed to execute template hook ${t.template_id}: ${i}`,details:{template_id:t.template_id,trigger_id:`post-user-login`,error:i}})}if(r=await Hu(t.users,n,r),i&&!o){let t=_.find(e=>e.enabled&&Jz(e));if(t&&Jz(t)){let n=await iB(e,t.form_id,i,r,a?.client);if(n instanceof Response)return n;r=n}let n=a?.sessionReused?void 0:_.find(e=>e.enabled&&aB(e));if(n&&aB(n)){let t=await oB(e,n.page_id,i,r,n.permission_required,a?.client);if(t instanceof Response)return t;r=t}}let y=_.filter(e=>e.enabled&&wR(e));if(h&&y.length>0){let a=y.some(e=>e.metadata?.resolve_link_candidates===!0),s=a?await az({userAdapter:t.users,connectionAdapter:t.connections,tenantId:n,user:r}):[],c=a?oz(s):[],l=Tz(t,n,Object.keys(e.env.STRATEGIES??{})),u=Ez({ctx:e,data:t,tenantId:n,triggerId:`post-user-login`,externalConnections:l}),g=sB({ctx:e,data:t,tenantId:n,user:r,candidates:s,ensuredUserIds:u.ensuredUserIds,externalConnections:l}),_={},v={},b=[],x=e=>()=>{b.push(e)},S=e=>(t,n)=>{typeof t==`string`&&t&&(e[t]=n)},ee={...g.api,...u.api,multifactor:{enable:(e,t)=>{f=pB(f,e,t)}},accessToken:{setCustomClaim:S(_)},idToken:{setCustomClaim:S(v)},access:{deny:(e,t)=>{throw new k(403,{error:`access_denied`,error_description:[t,e].find(e=>typeof e==`string`&&e.trim()!==``)??`Access denied`})}},redirect:{sendUserTo:x(`redirect.sendUserTo`)},prompt:{render:x(`prompt.render`)}},te=async(t,r)=>{if(m=t,o&&(o.deniedReason=t),i)try{await qV(e,n,i,`post_login_denied: ${t}`)}catch(e){console.warn(`Failed to mark denied login session:`,e)}throw r};for(let i of y){if(!wR(i))continue;let a=AR(i),o=i.metadata?.resolve_link_candidates===!0?{...h,link_candidates:c}:h;b=[];let s;try{s=await PR(e,t,i,o,`post-user-login`,ee),!s&&a&&(s=MR(i.code_id))}catch(e){e instanceof p.HTTPException&&(d.push(jR(i.code_id,e,!0)),await te(mB(e),e)),s=jR(i.code_id,e)}if(s){if(d.push(s),b.length>0&&!s.result.error){let t=[...new Set(b)].map(e=>`api.${e}`).join(`, `);s.result.error={id:`unsupported_api`,msg:`${t} is not supported in post-login actions and was ignored`},O(e,n,{type:E.FAILED_HOOK,description:`Post-login action ${s.result.action_name} called ${t}, which is not supported and was ignored`,userId:r.user_id})}s.failure&&a&&(s.denied=!0,await te(s.failure,new k(403,{error:`access_denied`,error_description:s.failure})))}}let ne=g.getLinkedPrimaryId(),re=ne&&ne!==r.user_id?ne:u.ensuredUserIds.has(r.user_id)?r.user_id:null;if(re){let e=await t.users.get(n,re);e&&(r=e)}await hB(e,n,i,{user_id:r.user_id,...Object.keys(_).length?{access_token:_}:{},...Object.keys(v).length?{id_token:v}:{}})}if(await yR(e,o?[]:_.filter(e=>e.enabled&&dB(e)),{tenant_id:n,user:r,trigger_id:`post-user-login`,request:{url:i?.authorization_url||ll(e.req.url)}}),f&&o)o.mfaRequest=f;else if(f&&i){let t=await _B(e,n,i,f,r);if(t)return t}return r}finally{if(d.length>0)try{let r=await LR(t,n,`post-user-login`,d,{logCapture:e.env.actionExecutionLogs});r&&(u=r,e.set(`action_execution_id`,r))}catch(e){console.warn(`Failed to persist post-login action execution:`,e)}let f=Pm(i?.state_data).session_cookie,p=Bd(e.req.header(`cookie`)),h={...f?{session_cookie:f}:{},...p===void 0?{}:{private_browsing:p}};o||O(e,n,{type:m?E.FAILED_LOGIN:E.SUCCESS_LOGIN,description:m?`Login for ${r.user_id} denied by a post-login action: ${m}`:`Successful login for ${r.user_id}`,userId:r.user_id,username:r.email||r.phone_number||r.name,client_name:a?.client?.name,strategy_type:s,strategy:c,connection:l,audience:a?.authParams?.audience,scope:a?.authParams?.scope,redirect_uri:a?.authParams?.redirect_uri,authorization_url:i?.authorization_url,login_session_id:i?.id,...u?{execution_id:u}:{},...Object.keys(h).length?{diagnostics:h}:{}})}}function xB(e,t,n,r){let i=new Headers(r);i.set(`Server-Timing`,`cf-nel=0; no-cloudflare-insights=1`);let a=`<!DOCTYPE html>
331
331
  <html>
332
332
 
333
333
  <head>
@@ -379,7 +379,7 @@ type ActionAPI = {
379
379
  <\/script>
380
380
  </body>
381
381
 
382
- </html>`;return e.html(a,{headers:i})}var yB={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`};function bB(e){return e.replace(/[&<>"']/g,e=>yB[e]??e)}function xB(e,t,n){let r=Object.entries(t).map(([e,t])=>`<input type="hidden" name="${bB(e)}" value="${bB(t)}" />`).join(`
382
+ </html>`;return e.html(a,{headers:i})}var SB={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`};function CB(e){return e.replace(/[&<>"']/g,e=>SB[e]??e)}function wB(e,t,n){let r=Object.entries(t).map(([e,t])=>`<input type="hidden" name="${CB(e)}" value="${CB(t)}" />`).join(`
383
383
  `),i=`<!DOCTYPE html>
384
384
  <html>
385
385
  <head><title>Submit This Form</title></head>
@@ -388,8 +388,8 @@ type ActionAPI = {
388
388
  <p>JavaScript is disabled. Click the button to continue.</p>
389
389
  <button type="submit" form="formpost">Continue</button>
390
390
  </noscript>
391
- <form id="formpost" method="post" action="${bB(e)}">
391
+ <form id="formpost" method="post" action="${CB(e)}">
392
392
  ${r}
393
393
  </form>
394
394
  </body>
395
- </html>`;return n.set(`content-type`,`text/html; charset=utf-8`),n.set(`cache-control`,`no-store`),n.set(`pragma`,`no-cache`),new Response(i,{status:200,headers:n})}function SB(e){if(!e)return;let[t,n]=e.split(` `);if(!(!t||t.toLowerCase()!==`bearer`))return n?.trim()||void 0}function CB(e){if(!e)return{};let[t,n]=e.split(` `);if(t?.toLowerCase()!==`basic`||!n)return{};try{let[e,t]=atob(n).split(`:`);return!e||!t?{}:{client_id:e,client_secret:t}}catch{return{}}}var wB=`urn:authhero:management`;function TB(e){return e===`/tenants`?!0:!e.startsWith(`/tenants/`)||/^\/tenants\/[^/]+\/(operations|config-sync)(\/|$)/.test(e)?!1:e!==`/tenants/settings`&&!e.startsWith(`/tenants/settings/`)}function EB(e){return e.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,`{$1}`)}function DB(e){let t=e.split(`:`);if(t.length!==2||!t[0]||!t[1])return[e];let n=`${t[1]}:${t[0]}`;return n===e?[e]:[e,n]}function OB(e,t={}){let n=t.requireManagementAudience??!1,r=t.relaxManagementAudience??!1,i=t.additionalManagementAudiences,a=t.additionalIssuers;return async(t,o)=>{let s=t.req.method===`HEAD`?`GET`:t.req.method,c=t.req.matchedRoutes.find(e=>e.method.toUpperCase()===s&&e.path!==`/*`);if(!c)return await o();let l=EB(c.path),u=l.startsWith(`/api/v2`)?l.slice(7)||`/`:l,d=e.openAPIRegistry.definitions.find(e=>`route`in e&&e.route.path===u&&e.route.method.toUpperCase()===s.toUpperCase());if(d&&`route`in d){let e=d.route.security?.[0]?.Bearer;if(e===void 0)return await o();let s=SB(t.req.header(`authorization`));if(!s)throw Fl.missingAuthentication();try{let o;if(a){let{payload:e}=(0,h.decode)(s);o=await a({tenant_id:typeof e?.tenant_id==`string`?e.tenant_id:void 0})}let c=await nO(t,s,{additionalIssuers:o});if(t.set(`user_id`,c.sub),t.set(`user`,c),c.azp&&(t.set(`client_id`,c.azp),t.set(`client_id_from_token`,!0)),c.org_name&&t.set(`org_name`,c.org_name),c.org_id&&t.set(`organization_id`,c.org_id),!t.var.tenant_id&&c.tenant_id&&t.set(`tenant_id`,c.tenant_id),n){let e=c.aud,n=Array.isArray(e)?e:e?[e]:[],a=typeof c.tenant_id==`string`?c.tenant_id:void 0,o=i?await i({tenant_id:a}):[],s=new Set([wB,...o]);if(!n.some(e=>s.has(e)))if(r)console.warn(`[authhero] management API accepted token without management audience (relaxManagementAudience=true): sub=${c.sub??`unknown`} aud=${JSON.stringify(e)}`);else throw new k(403,{message:`Invalid audience`});let l=typeof c.tenant_id==`string`?c.tenant_id:void 0,d=t.var.tenant_id;if(l&&d&&l!==d){let e=t.env.data?.multiTenancyConfig?.controlPlaneTenantId;if(!e||l!==e)throw new k(403,{message:`Cross-tenant management requires a control-plane token`});if(!await t.var.data.tenants.get(d).catch(e=>{throw new p.HTTPException(500,{message:`Failed to look up tenant`,cause:e})}))throw Nl.tenant()}let f=t.env.data?.multiTenancyConfig?.controlPlaneTenantId,m=typeof c.org_name==`string`?c.org_name:void 0,h=typeof c.org_id==`string`?c.org_id:void 0;if(f&&l===f&&d&&(m||h)){let e=m??(await t.env.data.organizations.get(f,h).catch(e=>{throw new p.HTTPException(500,{message:`Failed to look up organization`,cause:e})}))?.name,n=!!e&&e.toLowerCase()===d.toLowerCase(),r=d===f&&TB(u);if(r&&e&&!t.var.org_name&&t.set(`org_name`,e),!n&&(!r||!e))throw new k(403,{message:e?`This token is for another tenant's organization ("${e}"), not "${d}"`:`An organization token must belong to a tenant's organization`})}}let l=Array.isArray(c.permissions)?c.permissions:[],d=typeof c.scope==`string`?c.scope.split(` `):Array.isArray(c.scope)?c.scope:[];if(e.length){let t=e.flatMap(DB);if(!(t.some(e=>l.includes(e))||t.some(e=>d.includes(e))))throw Fl.insufficientScope(e)}}catch(e){throw e instanceof p.HTTPException?e:Fl.invalidToken()}}return await o()}}async function kB(e,t,n){if(n===`urn:authhero:management`)return!0;let r=e.env.additionalManagementAudiences;return r?(await r({tenant_id:t})).includes(n):!1}var AB=[`openid`,`profile`,`email`,`address`,`phone`,`offline_access`];async function jB(e,t,n,r){let i=[];if(!(await e.env.data.tenants.get(t))?.flags?.inherit_global_permissions_in_organizations)return[];let a=await e.env.data.userRoles.list(t,n,void 0,``),o=await Promise.all(a.map(n=>e.env.data.rolePermissions.list(t,n.id,{per_page:1e3})));for(let e of o)e.forEach(e=>{e.resource_server_identifier===r&&i.push(e.permission_name)});return[...new Set(i)]}var MB=`admin:organizations`,NB=`access:all_organizations`;async function PB(e,t,n,r){let i=new Set,a=e=>{for(let t of e)t.resource_server_identifier===`urn:authhero:management`&&r.includes(t.permission_name)&&i.add(t.permission_name)};if(a(await e.env.data.userPermissions.list(t,n,void 0,``)),i.size===r.length)return i;let o=await e.env.data.userRoles.list(t,n,void 0,``);for(let n of o)if(a(await e.env.data.rolePermissions.list(t,n.id,{per_page:1e3})),i.size===r.length)break;return i}async function FB(e,t,n,r){return(await PB(e,t,n,[r])).has(r)}async function IB(e,t,n,r){let i=(r===void 0?await e.env.data.tenants.get(t):r)?.flags?.inherit_global_permissions_in_organizations===!0,a=await PB(e,t,n,i?[NB,MB]:[NB]);return a.has(`access:all_organizations`)||i&&a.has(`admin:organizations`)}async function LB(e,t,n,r,i){return await IB(e,t,n,i)?!0:(await e.env.data.userOrganizations.list(t,{q:`user_id:${D(n)}`,per_page:1e3})).userOrganizations.some(e=>e.organization_id===r)}function RB(e){let t=e.granted.filter(t=>!e.definedScopes.includes(t));if(t.length===0)return;let n=e.userId?`, user_id=${e.userId}`:``;console.warn(`[scopes-permissions] Dropped scope(s) not defined on the resource server: ${t.join(`, `)} (source=${e.source}, tenant_id=${e.tenantId}, client_id=${e.clientId}, audience=${e.audience}${n})`)}async function zB(e,t){let{tenantId:n,audience:r,scopes:i}=t;if(i.length===0)return[];let{resource_servers:a}=await e.env.data.resourceServers.list(n),o=a.find(e=>e.identifier===r);if(!o)return[];let s=(o.scopes||[]).map(e=>e.value);return i.filter(e=>!s.includes(e))}async function BB(e,t){let{tenantId:n,clientId:r,audience:i,requestedScopes:a}=t,o=a.filter(e=>AB.includes(e)),s=a.filter(e=>!AB.includes(e)),c=(await e.env.data.resourceServers.list(n)).resource_servers.filter(e=>e.identifier===i);if(c.length===0)return{scopes:o,permissions:[],token_lifetime:86400,token_lifetime_for_web:7200};let l=c[0];if(!l)return{scopes:o,permissions:[],token_lifetime:86400,token_lifetime_for_web:7200};let u=l.options?.enforce_policies===!0,d=l.options?.token_dialect||`access_token`,f=(await e.env.data.clientGrants.list(n,{q:`client_id:${D(r)}`})).client_grants.find(e=>e.audience===i);if(!f)return{scopes:o,permissions:[],token_lifetime:l.token_lifetime,token_lifetime_for_web:l.token_lifetime_for_web};let p=f.scope||[],m=(l.scopes||[]).map(e=>e.value);if(s.length>0){let e=s.filter(e=>!p.includes(e));if(e.length>0)throw new k(403,{error:`access_denied`,error_description:`Client is not authorized for scope(s): ${e.join(`, `)}`})}let h=p.filter(e=>m.includes(e));RB({source:`client_grant`,tenantId:n,clientId:r,audience:i,granted:p,definedScopes:m});let g=a.length===0?h:s.filter(e=>h.includes(e)),_={token_lifetime:l.token_lifetime,token_lifetime_for_web:l.token_lifetime_for_web};if(!u)return{scopes:[...new Set([...o,...g])],permissions:[],..._};let v=g;return d===`access_token_authz`?{scopes:[...new Set([...o,...g])],permissions:v,..._}:{scopes:[...new Set([...o,...g])],permissions:[],..._}}async function VB(e,t){if(t.grantType===Wi.ClientCredential)return await BB(e,{tenantId:t.tenantId,clientId:t.clientId,audience:t.audience,requestedScopes:t.requestedScopes});let{tenantId:n,clientId:r,userId:i,audience:a,requestedScopes:o,organizationId:s}=t,c=await e.env.data.tenants.get(n),l=c?.flags?.restrict_undefined_scopes===!0;if(s&&!await LB(e,n,i,s,c))throw new k(403,{error:`access_denied`,error_description:`User is not a member of the specified organization`});let u=o.filter(e=>AB.includes(e)),d=(await e.env.data.resourceServers.list(n)).resource_servers.filter(e=>e.identifier===a)[0];if(!d){if(o.filter(e=>e&&!AB.includes(e)).length>0)throw new k(403,{error:`access_denied`,error_description:`Service not found: ${a}`});return{scopes:u,permissions:[],token_lifetime:86400,token_lifetime_for_web:7200}}let f=(d.scopes||[]).map(e=>e.value),p=await kB(e,n,a),m=d.options?.enforce_policies===!0||p,h=d.options?.token_dialect||`access_token`,g={token_lifetime:d.token_lifetime,token_lifetime_for_web:d.token_lifetime_for_web};if(!m){let e=l?o.filter(e=>f.includes(e)||AB.includes(e)):o;return{scopes:[...new Set(e)],permissions:[],...g}}let[_,v,y]=await Promise.all([e.env.data.userPermissions.list(n,i,void 0,s),e.env.data.userRoles.list(n,i,void 0,``),s?e.env.data.userRoles.list(n,i,void 0,s):Promise.resolve([])]),b=[...v,...y],x=s?await jB(e,n,i,a):[],S=await Promise.all(b.map(t=>e.env.data.rolePermissions.list(n,t.id,{per_page:1e3}))),ee=[];for(let e of S)e.forEach(e=>{e.resource_server_identifier===a&&ee.push(e.permission_name)});let te=new Set;_.forEach(e=>{e.resource_server_identifier===a&&te.add(e.permission_name)}),ee.forEach(e=>{te.add(e)}),x.forEach(e=>{te.add(e)});let ne=Array.from(te),re=ne.filter(e=>f.includes(e));RB({source:`user_permissions`,tenantId:n,clientId:r,audience:a,granted:ne,definedScopes:f,userId:i});let ie=l?[]:o.filter(e=>!f.includes(e)&&!AB.includes(e)&&(!p||te.has(e)));if(h===`access_token_authz`)return{scopes:[...new Set([...u,...ie])],permissions:re,...g};let ae=o.filter(e=>f.includes(e)&&ne.includes(e));return{scopes:[...new Set([...u,...ae,...ie])],permissions:[],...g}}var HB=new Set([`openid`,`profile`,`email`]);function UB(e,t){let n=new Set(t),r=[];for(let t of e)t&&(HB.has(t)||n.has(t)||r.push(t));return Array.from(new Set(r))}async function WB(e,t){if(!e.env.data.grants)return UB(t.requestedScopes,[]);let n=await e.env.data.grants.get(t.tenantId,t.userId,t.clientId);return UB(t.requestedScopes,n?.scope??[])}function GB(e,t){if(!e||!t||e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e.charCodeAt(r)^t.charCodeAt(r);return n===0}async function KB(e){return Is(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))}function qB(e){return e.replace(/[\s-]/g,``).toUpperCase()}function JB(e){if(!e.deviceCodes)throw new k(503,{error:`temporarily_unavailable`,error_description:`Device authorization storage is not configured`});return e.deviceCodes}function YB(e){if(!e.grant_types?.some(e=>e===Wi.DeviceCode||e===`device_code`))throw new k(400,{error:`unauthorized_client`,error_description:`Device authorization is not enabled for this client`})}function XB(e,t,n,r=!1){let i=t.token_endpoint_auth_method??(t.app_type===`native`||t.app_type===`spa`?`none`:`client_secret_post`);if(!e.var.client_authenticated_via_assertion&&!(i===`none`&&n===void 0)&&!((i===`client_secret_basic`&&r||i===`client_secret_post`&&!r)&&n&&GB(t.client_secret,n)))throw new k(401,{error:`invalid_client`,error_description:`Client authentication failed`})}async function ZB(e,t,n,r,i=e.var.ip||`unknown`){let a=300*1e3,o=Math.floor(Date.now()/a),s=`${n}:${await KB(i)}:${o}`;if(await JB(e.env.data).incrementAttempts(t,s,new Date((o+1)*a).toISOString())>r)throw new k(429,{error:`slow_down`,error_description:`Too many device authorization attempts. Try again later.`})}function QB(e){return Pm(e.state_data).deviceFlow}function $B(e){return!!Pm(e).deviceFlow?.deviceCodeHash}function eV(e){return`__Host-authhero_device_${e}`}function tV(e){return(0,Sd.serialize)(eV(e.id),e.csrf_token,{httpOnly:!0,secure:!0,sameSite:`lax`,path:`/`,maxAge:600})}function nV(e,t){let n=(0,Sd.parse)(e.req.header(`cookie`)||``)[eV(t.id)];if(!n||!GB(t.csrf_token,n))throw new k(403,{error:`access_denied`,error_description:`Start device activation again in this browser`})}function rV(e){if(!e)return!1;try{return!!JSON.parse(e)?.connect}catch{return!1}}function iV(e,t){switch(t){case`email`:return e.email||void 0;case`email_verified`:return e.email_verified===void 0?void 0:e.email_verified;case`name`:return e.name||void 0;case`family_name`:return e.family_name||void 0;case`given_name`:return e.given_name||void 0;case`middle_name`:return e.middle_name||void 0;case`nickname`:return e.nickname||void 0;case`preferred_username`:return e.preferred_username||e.username||void 0;case`profile`:return e.profile||void 0;case`picture`:return e.picture||void 0;case`website`:return e.website||void 0;case`gender`:return e.gender||void 0;case`birthdate`:return e.birthdate||void 0;case`zoneinfo`:return e.zoneinfo||void 0;case`locale`:return e.locale||void 0;case`updated_at`:{if(!e.updated_at)return;let t=new Date(e.updated_at).getTime();return Number.isFinite(t)?Math.floor(t/1e3):void 0}case`address`:return e.address||void 0;case`phone_number`:return e.phone_number||void 0;case`phone_number_verified`:return e.phone_verified===void 0?void 0:e.phone_verified;default:return}}var aV={email:[`email`,`email_verified`],profile:[`name`,`family_name`,`given_name`,`middle_name`,`nickname`,`preferred_username`,`profile`,`picture`,`website`,`gender`,`birthdate`,`zoneinfo`,`locale`,`updated_at`],address:[`address`],phone:[`phone_number`,`phone_number_verified`]};function oV(e,t){let n={};for(let r of t){let t=aV[r];if(t)for(let r of t){let t=iV(e,r);t!==void 0&&(n[r]=t)}}return n}function sV(e,t){let n={};for(let r of t){let t=iV(e,r);t!==void 0&&(n[r]=t)}return n}var cV=[`1F77B4`,`FF7F0E`,`2CA02C`,`D62728`,`9467BD`,`8C564B`,`E377C2`,`17BECF`,`BCBD22`,`7F7F7F`];function lV(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)}function uV(e){return e.email||e.name||e.user_id||`?`}function dV(e){return cV[lV(e.length>0?e:`?`)%cV.length]??`7F7F7F`}function fV(e){return e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])/g,``).replace(/(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,``)}function pV(e){let t=fV(e.name?.trim()||`${e.given_name??``} ${e.family_name??``}`.trim()||e.nickname?.trim()||e.email?.trim()||e.username?.trim()||``).split(/\s+/).filter(Boolean),n=t[0];if(!n)return`?`;if(t.length===1)return[...n].slice(0,2).join(``).toUpperCase()||`?`;let r=t[t.length-1]??n;return`${[...n][0]??``}${[...r][0]??``}`.toUpperCase()||`?`}function mV(e,t){return`${e.endsWith(`/`)?e:`${e}/`}${t}`}function hV(e,t){let n=pV(t),r=dV(uV(t));return mV(e,`avatars/${encodeURIComponent(n)}.svg?bg=${r}`)}function gV(e,t){return e.picture?e:{...e,picture:hV(t,e)}}function _V(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&apos;`)}function vV(e,t){let n=/^[0-9a-fA-F]{6}$/.test(t)?`#${t}`:`#7F7F7F`,r=_V([...fV(e)].slice(0,2).join(``).toUpperCase())||`?`;return[`<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120" role="img">`,`<rect width="120" height="120" fill="${n}"/>`,`<text x="50%" y="50%" dy=".05em" fill="#ffffff" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif" font-size="52" font-weight="600" text-anchor="middle" dominant-baseline="central">${r}</text>`,`</svg>`].join(``)}var yV=3600*1e3;function bV(e,t=Date.now()){let n=e.used_at??e.created_at,r=n?new Date(n).getTime():NaN;return Number.isFinite(r)?t-r>=yV:!0}function xV(e,t,n,r){let i=Date.now(),a=()=>e.env.data.sessions.update(t,n,{used_at:new Date(i).toISOString()});if(r){if(!bV(r,i))return;Uc(e,a().catch(()=>{}));return}Uc(e,(async()=>{let r=await e.env.data.sessions.get(t,n);!r||r.revoked_at||bV(r,i)&&await a()})().catch(()=>{}))}function SV(e,t){Object.keys(t).forEach(n=>{let r=t[n];r!=null&&r.length&&e.searchParams.set(n,r)})}function CV(e){try{let t=typeof e==`string`?new URL(e):e,n=`${t.protocol}//${t.host}${t.pathname}`;if(t.search){let e=Array.from(t.searchParams.keys()).map(e=>`${e}=[REDACTED]`).join(`&`);n+=`?${e}`}return t.hash&&(n+=`#[REDACTED]`),n}catch{let t=(typeof e==`string`?e:e.toString()).match(/^([^?#]*)(\?[^#]*)?(#.*)?$/);if(!t)return`[invalid-url]`;let[,n=``,r,i]=t,a=n;if(r){let e=r.substring(1).split(`&`).map(e=>{let[t]=e.split(`=`);return`${t}=[REDACTED]`}).join(`&`);a+=`?${e}`}return i&&(a+=`#[REDACTED]`),a}}var wV=3600;function TV(e){return!e||e<=0?{kind:`unset`}:{kind:`seconds`,seconds:e*wV}}function EV(e){if(!(e===void 0||e<=0))return{kind:`seconds`,seconds:e}}function DV(e){let t=e.refresh_token;return t?.expiration_type===`non-expiring`||t?.infinite_token_lifetime?{kind:`infinite`}:EV(t?.token_lifetime)??TV(e.tenant.session_lifetime)}function OV(e){let t=e.refresh_token;return t?.expiration_type===`non-expiring`||t?.infinite_idle_token_lifetime?{kind:`infinite`}:EV(t?.idle_token_lifetime)??TV(e.tenant.idle_session_lifetime)}function kV(e,t=Date.now()){if(e.kind===`seconds`)return new Date(t+e.seconds*1e3).toISOString()}function AV(e,t=Date.now()){return{expires_at:kV(DV(e),t),idle_expires_at:kV(OV(e),t)}}function jV(e,t,n=Date.now()){let r=OV(e);if(r.kind!==`infinite`)return r.kind===`unset`||!t?t:kV(r,n)}function MV(e,t,n=Date.now()){let r={};if(t.expires_at&&DV(e).kind===`infinite`&&(r.expires_at=null),t.idle_expires_at){let t=OV(e);t.kind===`infinite`?r.idle_expires_at=null:t.kind===`seconds`&&(r.idle_expires_at=kV(t,n))}return r}function NV(e){switch(e){case Wi.DeviceCode:return E.FAILED_EXCHANGE_DEVICE_CODE_FOR_ACCESS_TOKEN;case Wi.AuthorizationCode:return E.FAILED_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN;case Wi.ClientCredential:return E.FAILED_EXCHANGE_ACCESS_TOKEN_FOR_CLIENT_CREDENTIALS;case Wi.RefreshToken:return E.FAILED_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN;case Wi.OTP:return E.FAILED_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN;case Wi.Password:return E.FAILED_EXCHANGE_PASSWORD_FOR_ACCESS_TOKEN;case Wi.Passwordless:return E.FAILED_EXCHANGE_PASSWORDLESS_OTP_FOR_ACCESS_TOKEN;case Wi.TokenExchange:return E.FAILED_EXCHANGE_SUBJECT_TOKEN_FOR_ACCESS_TOKEN;default:return E.FAILED_EXCHANGE_CUSTOM_TOKEN}}function PV(e,t,n,r,i=`onExecuteCredentialsExchange`){return{accessToken:{setCustomClaim:(n,r)=>{lO(t,n,r,{kind:`access_token`,source:i,ctx:e})}},idToken:{setCustomClaim:(t,r)=>{n&&lO(n,t,r,{kind:`id_token`,source:i,ctx:e})}},access:{deny:(t,n)=>{let i=n?`${t} - ${n}`:t;throw O(e,e.var.tenant_id||``,{type:NV(r),description:`Access denied by credentials-exchange hook: ${i}`}),new k(400,{message:`Access denied: ${i}`})}},token:{createServiceToken:async t=>(await hO(e,e.var.tenant_id,t.scope,t.expiresInSeconds,t.customClaims)).access_token}}}function FV(e){if(!e?.state_data)return;let t=Pm(e.state_data);return t.mfa_verified&&t.mfa_method?[`mfa`]:void 0}async function IV(e,t){let{authParams:n,user:r,client:i,session_id:a,organization:o,permissions:s,impersonatingUser:c,actClient:l,grantType:u}=t;if(r?.blocked)throw new k(403,{error:`access_denied`,error_description:`User is blocked`});let d=(()=>{if(c&&l)return{sub:c.user_id,client_id:l.client_id};if(c)return{sub:c.user_id};if(l)return{sub:l.client_id,client_id:l.client_id}})(),f=t.amr??(r&&t.loginSession?.user_id===r.user_id?FV(t.loginSession):void 0),m=t.auth_time,h=n.prompt?.split(` `)??[],g=n.max_age!==void 0||h.includes(`login`)||n.claims?.id_token?.auth_time?.essential===!0;if(m===void 0&&g){if(t.loginSession?.authenticated_at)m=Math.floor(new Date(t.loginSession.authenticated_at).getTime()/1e3);else if(a&&e.var.tenant_id){let t=await e.env.data.sessions.get(e.var.tenant_id,a);t?.authenticated_at&&(m=Math.floor(new Date(t.authenticated_at).getTime()/1e3))}}let _=e.var.tenant_id,v=(await BD(e.env.data.keys,_??``,_?e.env.signingKeyMode:`control-plane`,{purpose:`sign`}))[0];if(!v?.pkcs7||!v.cert)throw new k(500,{message:`No signing key configured for ${_?`tenant "${_}"`:`the control-plane scope`}: found ${(await BD(e.env.data.keys,_??``,_?e.env.signingKeyMode:`control-plane`,{purpose:`publish`})).length} verify key(s) but none with private material to sign tokens.`});let y=iD(v.pkcs7),b=await rD(v.cert),x=Cc(e.env,e.var.custom_domain),S=n.audience??i.tenant.default_audience??`${x}userinfo`,ee=n.claims?.userinfo?Object.keys(n.claims.userinfo):void 0,te=uO(t.customClaims,{kind:`access_token`,source:`createAuthTokens(customClaims)`,ctx:e}),ne={aud:S,scope:n.scope||``,sub:r?.user_id||n.client_id,iss:x,tenant_id:i.tenant.id,sid:a,act:d,org_id:o?o.id:void 0,requested_userinfo_claims:ee,org_name:o&&i.tenant.allow_organization_name_in_authentication_api?o.name.toLowerCase():void 0,permissions:s,...te},re=n.scope?.split(` `)||[],ie=re.includes(`openid`);if(!f&&r&&ie&&a&&e.var.tenant_id){let t=await e.env.data.sessions.get(e.var.tenant_id,a);t&&lB(t,r.user_id)&&(f=[`mfa`])}let ae=(n.response_type??``).trim()===kt.ID_TOKEN,oe=i.auth0_conformant!==!1||ae,se={aud:n.client_id,sub:r?.user_id,iss:x,sid:a,nonce:n.nonce,...m===void 0?{}:{auth_time:m},...f?{amr:f}:{},...n.acr_values?{acr:n.acr_values.split(` `)[0]}:{}},ce={act:d,org_id:o?.id,org_name:o?.name.toLowerCase()},le=r&&ie?{...se,...oe?oV(gV(r,x),re):{},...n.claims?.id_token?sV(gV(r,x),Object.keys(n.claims.id_token)):{},...ae&&n.claims?.userinfo?sV(gV(r,x),Object.keys(n.claims.userinfo)):{},...ce}:void 0,ue=Kc({loginSession:t.loginSession,authConnection:t.authConnection,ctxConnection:e.var.connection,user:r}),de=await qc(e,e.var.tenant_id,ue,r);if(r&&u!==Wi.RefreshToken){let n=e.var.post_login_action_claims??Pm(t.loginSession?.state_data).action_claims;if(n?.user_id===r.user_id){for(let[t,r]of Object.entries(n.access_token??{}))lO(ne,t,r,{kind:`access_token`,source:`post-login-code-hook`,ctx:e});if(le)for(let[t,r]of Object.entries(n.id_token??{}))lO(le,t,r,{kind:`id_token`,source:`post-login-code-hook`,ctx:e})}}e.env.hooks?.onExecuteCredentialsExchange&&await e.env.hooks.onExecuteCredentialsExchange({ctx:e,client:i,user:r,request:{ip:e.var.ip||``,user_agent:e.var.useragent||``,method:e.req.method,url:ll(e.req.url)},scope:n.scope||``,grant_type:u??``,organization:o,connection:de||(ue?{id:ue,name:ue,strategy:r?.provider||`auth0`}:void 0)},PV(e,ne,le,u));{let{hooks:t}=await e.env.data.hooks.list(e.var.tenant_id),a=t.filter(e=>e.trigger_id===`credentials-exchange`&&e.enabled&&fz(e));if(r){for(let t of a)if(fz(t))try{await gz(e,t.template_id,r,PV(e,ne,le,u,`template-hook:${t.template_id}`))}catch(e){if(e instanceof p.HTTPException)throw e;console.warn(`[credentials-exchange] Failed to execute template hook: ${t.template_id}`,e)}}let s=PV(e,ne,le,u,`credentials-exchange-code-hook`),c=await RR(e,t,{ctx:e,client:i,user:r,request:{ip:e.var.ip||``,user_agent:e.var.useragent||``,method:e.req?.method||``,url:ll(e.req?.url||``)},scope:n.scope||``,grant_type:u??``,organization:o,connection:de||(ue?{id:ue,name:ue,strategy:r?.provider||`auth0`}:void 0)},s);c&&e.set(`action_execution_id`,c)}let fe=c?3600:t.token_lifetime??86400,pe={includeIssuedTimestamp:!0,expiresInSeconds:fe,headers:{kid:v.kid}},C=await QD(b,y,ne,pe);if(le){let e=(n.response_type??``).split(` `);t.code&&e.includes(`code`)&&(le.c_hash=await nk(t.code,b)),e.includes(`id_token`)&&e.includes(`token`)&&(le.at_hash=await nk(C,b))}let me=le?await QD(b,y,le,pe):void 0;return{access_token:C,refresh_token:t.refresh_token,id_token:me,token_type:`Bearer`,expires_in:fe}}async function LV(e,t){return{code:(await e.env.data.codes.create(t.client.tenant.id,{code_id:Yl(32),user_id:t.user.user_id,code_type:`authorization_code`,login_id:t.login_id,expires_at:new Date(Date.now()+300*1e3).toISOString(),code_challenge:t.authParams.code_challenge,code_challenge_method:t.authParams.code_challenge_method,redirect_uri:t.authParams.redirect_uri,state:t.authParams.state,nonce:t.authParams.nonce})).code_id,state:t.authParams.state}}function RV(e){if(e)return new Date(Date.now()+e*60*60*1e3).toISOString()}function zV(e,t){return t?e&&Date.parse(e)<=Date.parse(t)?e:t:e}async function BV(e,t){let{client:n,scope:r,login_id:i}=t,a=Cc(e.env,e.var.custom_domain),o=t.audience??n.tenant.default_audience??`${a}userinfo`,{expires_at:s,idle_expires_at:c}=AV(n),l=NO(),{lookup:u,secret:d}=XO(),f=await ZO(d),p=n.refresh_token?.rotation_type===`rotating`;return{row:await e.env.data.refreshTokens.create(n.tenant.id,{id:l,login_id:i,session_id:t.session_id,organization:t.organization,auth_connection:t.auth_connection,auth_strategy:t.auth_strategy,client_id:n.client_id,idle_expires_at:c?zV(c,t.max_expires_at):void 0,expires_at:zV(s,t.max_expires_at),session_transfer:t.session_transfer,user_id:t.user.user_id,device:{last_ip:e.var.ip,initial_ip:e.var.ip,last_user_agent:e.var.useragent||``,initial_user_agent:e.var.useragent||``,initial_asn:``,last_asn:``},resource_servers:[{audience:o,scopes:r}],rotating:p,token_lookup:u,token_hash:f,family_id:l}),wireToken:QO(u,d)}}async function VV(e,{user:t,client:n,loginSession:r}){let i=RV(n.tenant.idle_session_lifetime),a=RV(n.tenant.session_lifetime);return await e.env.data.sessions.create(n.tenant.id,{id:NO(),user_id:t.user_id,login_session_id:r.id,idle_expires_at:i,expires_at:a,device:{last_ip:e.var.ip||``,initial_ip:e.var.ip||``,last_user_agent:e.var.useragent||``,initial_user_agent:e.var.useragent||``,initial_asn:``,last_asn:``},clients:[n.client_id]})}async function HV(e,{user:t,client:n,loginSession:r,existingSessionId:i,authConnection:a,authStrategy:o}){let s=await e.env.data.loginSessions.get(n.tenant.id,r.id);if(!s)throw new p.HTTPException(400,{message:`Login session ${r.id} not found`});let c=s.state||T.PENDING;if(c===T.FAILED)throw new k(400,{error:`access_denied`,error_description:s.failure_reason||`Cannot authenticate login session in failed state`});if(c===T.COMPLETED)throw new k(400,{error:`access_denied`,error_description:`Login session has already been completed`});if(c===T.AUTHENTICATED){if(s.session_id)return s.session_id;throw new p.HTTPException(500,{message:`Login session is authenticated but has no session_id`})}let l,u;if(i){let a=await e.env.data.sessions.get(n.tenant.id,i);if(!a||a.revoked_at){let i=await VV(e,{user:t,client:n,loginSession:r});l=i.id,u=i.authenticated_at}else l=i,u=a.authenticated_at,a.clients.includes(n.client_id)?xV(e,n.tenant.id,i,a):await e.env.data.sessions.update(n.tenant.id,i,{clients:[...a.clients,n.client_id],...bV(a)&&{used_at:new Date().toISOString()}})}else{let i=await VV(e,{user:t,client:n,loginSession:r});l=i.id,u=i.authenticated_at}let{state:d}=Lm(c===T.EXPIRED?T.PENDING:c,{type:j.AUTHENTICATE,userId:t.user_id}),f=Kc({authConnection:a,ctxConnection:e.var.connection});return await e.env.data.loginSessions.update(n.tenant.id,r.id,{session_id:l,state:d,user_id:t.user_id,authenticated_at:u,...f?{auth_connection:f}:{},...o?{auth_strategy:o}:{},...c===T.EXPIRED?{expires_at:new Date(Date.now()+ld*1e3).toISOString()}:{}}),l}async function UV(e,t){let{user:n,client:r,loginSession:i,authStrategy:a,authConnection:o}=t;await HV(e,{user:n,client:r,loginSession:i,existingSessionId:t.existingSessionId,authConnection:o,authStrategy:a});let s=`/authorize/resume?state=${encodeURIComponent(i.id)}`,c=s,l=!1;if(i.authorization_url)try{let t=new URL(i.authorization_url),n=e.var.host||``;t.host&&t.host!==n&&(c=`${t.origin}${s}`,l=!0)}catch{}let u=new Headers({location:c});return l&&u.set(xs,`1`),new Response(null,{status:302,headers:u})}async function WV(e,t,n,r){let i=await e.env.data.loginSessions.get(t,n.id);if(!i){console.warn(`Login session ${n.id} not found when trying to mark as failed`);return}let a=i.state||T.PENDING,{state:o,context:s}=Lm(a,{type:j.FAIL,reason:r});o!==a&&await e.env.data.loginSessions.update(t,n.id,{state:o,failure_reason:s.failureReason})}async function GV(e,t,n,r){let i=await e.env.data.loginSessions.get(t,n.id);if(!i){console.warn(`Login session ${n.id} not found when trying to start hook`);return}let a=i.state||T.PENDING,{state:o,context:s}=Lm(a,{type:j.START_HOOK,hookId:r});o!==a&&await wO(e.env.data.loginSessions,t,n.id,{type:j.UPDATE_CONTEXT,data:{hookId:s.hookId}},{state:o})}async function KV(e,t,n){let r=await e.env.data.loginSessions.get(t,n.id);if(!r){console.warn(`Login session ${n.id} not found when trying to complete hook`);return}let i=r.state||T.PENDING,{state:a}=Lm(i,{type:j.COMPLETE_HOOK});a!==i&&await wO(e.env.data.loginSessions,t,n.id,{type:j.UPDATE_CONTEXT,data:{hookId:void 0,form_values:void 0}},{state:a})}async function qV(e,t,n,r,i){let a=i??await e.env.data.loginSessions.get(t,n.id);if(!a){console.warn(`Login session ${n.id} not found when trying to mark as completed`);return}let o=a.state||T.PENDING,{state:s}=Lm(o,{type:j.COMPLETE});s!==o&&await e.env.data.loginSessions.update(t,n.id,{state:s,...r?{auth_connection:r}:{}})}async function JV(e,t,n,r,i){let a=await e.env.data.loginSessions.get(t,n.id);if(!a){console.warn(`Login session ${n.id} not found when trying to start continuation`);return}let o=a.state||T.PENDING,{state:s}=Lm(o,{type:j.START_CONTINUATION,scope:r});s===o?console.warn(`Failed to start continuation for login session ${n.id}: cannot transition from ${o} to AWAITING_CONTINUATION. Scope: ${JSON.stringify(r)}, Return URL: ${CV(i)}`):await wO(e.env.data.loginSessions,t,n.id,{type:j.UPDATE_CONTEXT,data:{continuationScope:r,continuationReturnUrl:i}},{state:s})}async function YV(e,t,n){let r=await e.env.data.loginSessions.get(t,n.id);if(!r){console.warn(`Login session ${n.id} not found when trying to complete continuation`);return}let i=Pm(r.state_data).continuationReturnUrl,a=r.state||T.PENDING,{state:o}=Lm(a,{type:j.COMPLETE_CONTINUATION});return o===a?console.warn(`completeLoginSessionContinuation: State transition from ${a} with COMPLETE_CONTINUATION was invalid or no-op`):await wO(e.env.data.loginSessions,t,n.id,{type:j.UPDATE_CONTEXT,data:{continuationScope:void 0,continuationReturnUrl:void 0}},{state:o}),i}function XV(e){if(!e.state_data)return null;try{return JSON.parse(e.state_data).continuationScope||null}catch{return null}}function ZV(e,t){if(e.state!==T.AWAITING_CONTINUATION||!(Date.parse(e.expires_at)>Date.now()))return!1;let n=XV(e);return n?n.includes(t):!1}async function QV(e,t){let{authParams:n,client:r,ticketAuth:i}=t,{user:a}=t,o=n.response_type||kt.CODE,s=n.response_mode||At.QUERY;if(i){if(!t.loginSession)throw new k(500,{message:`Login session not found for ticket auth.`});a&&!t.skipHooks&&(t.authStrategy&&a.app_metadata?.strategy!==t.authStrategy.strategy&&(a.app_metadata={...a.app_metadata,strategy:t.authStrategy.strategy},await e.env.data.users.update(r.tenant.id,a.user_id,{app_metadata:{...a.app_metadata||{},strategy:t.authStrategy.strategy}})),await _B(e,e.env.data,r.tenant.id,a,t.loginSession,{client:r,authParams:n,authStrategy:t.authStrategy,authConnection:t.authConnection}));let i=aD(),o=Yl(12),s=await e.env.data.codes.create(r.tenant.id,{code_id:Yl(32),code_type:`ticket`,login_id:t.loginSession.id,user_id:a?.user_id,expires_at:new Date(Date.now()+gd).toISOString(),code_verifier:[o,i].join(`|`),redirect_uri:n.redirect_uri,state:n.state,nonce:n.nonce});return e.json({login_ticket:s.code_id,co_verifier:i,co_id:o})}let c=t.refreshToken,l;if(!t.loginSession)throw new k(500,{message:`loginSession must be provided for front-channel auth responses.`});let u=await e.env.data.loginSessions.get(r.tenant.id,t.loginSession.id);if(!u)throw new k(500,{message:`Login session not found.`});let d=u.state||T.PENDING;if(d===T.COMPLETED)throw new k(400,{error:`invalid_request`,error_description:`Login session has already been completed`});if(d===T.FAILED)throw new k(400,{error:`access_denied`,error_description:`Login session failed: ${u.failure_reason||`unknown reason`}`});if(d===T.PENDING||d===T.EXPIRED){l=await HV(e,{user:a,client:r,loginSession:t.loginSession,existingSessionId:t.existingSessionIdToLink,authConnection:t.authConnection,authStrategy:t.authStrategy});let n=await e.env.data.loginSessions.get(r.tenant.id,t.loginSession.id);n&&(u=n)}else if(l=u.session_id,!l)throw new k(500,{message:`Login session in ${d} state but has no session_id`});let f=!!Pm(u.state_data).mfa_required_by_action,m=t.skipHooks||f;if(f&&a&&(a=await Hu(e.env.data.users,r.tenant.id,a),u.user_id!==a.user_id&&(await e.env.data.loginSessions.update(r.tenant.id,u.id,{user_id:a.user_id}),u={...u,user_id:a.user_id})),t.loginSession&&a){let i=u.state||T.PENDING,o={};if(u.state_data)try{o=JSON.parse(u.state_data)}catch{console.error(`Failed to parse state_data for login session`,u.id)}if(i===T.AWAITING_MFA){let n=`/u2/mfa/login-options`;if(o.authenticationMethodId){let t=(await e.env.data.authenticationMethods.list(r.tenant.id,a.user_id)).find(e=>e.id===o.authenticationMethodId);t?.confirmed&&t.type===`phone`?n=`/u2/mfa/phone-challenge`:t?.confirmed&&t.type===`totp`?n=`/u2/mfa/totp-challenge`:t?.confirmed&&(t.type===`passkey`||t.type===`webauthn-roaming`||t.type===`webauthn-platform`)?n=`/u2/passkey/challenge`:t?.type===`totp`?n=`/u2/mfa/totp-enrollment`:t?.type===`phone`&&(n=`/u2/mfa/phone-enrollment`)}return new Response(null,{status:302,headers:{location:`${n}?state=${encodeURIComponent(t.loginSession.id)}`}})}if(i===T.AUTHENTICATED&&o.mfa_verified===!0&&l)try{let t=await e.env.data.sessions.get(r.tenant.id,l),n=typeof o.mfa_verified_at==`string`?o.mfa_verified_at:void 0;t&&!t.revoked_at&&t.user_id===a.user_id&&(n||!cB(t))&&await uB(e.env.data.sessions,r.tenant.id,t,{type:typeof o.mfa_method==`string`?o.mfa_method:void 0,timestamp:n??new Date().toISOString()})}catch(e){console.error(`Failed to record MFA completion on session`,e)}if(i===T.AUTHENTICATED&&!o.mfa_verified){let{checkMfaRequired:n,sendMfaOtp:i}=await Promise.resolve().then(()=>require("./mfa-B0J_xOxl.js")).then(e=>e.i),{isBrowserRememberedForMfa:s}=await Promise.resolve().then(()=>require("./authhero.cjs")).then(e=>e.t),c=await n(e,r.tenant.id,a.user_id,{force:!!o.mfa_required_by_action}),d=c.required&&l?await e.env.data.sessions.get(r.tenant.id,l).then(e=>e?lB(e,a.user_id):!1):!1,f=c.required&&c.enrolled&&!d?await s(e,{tenant:r.tenant,userId:a.user_id,actionRequest:Pm(u.state_data).mfa_required_by_action}):!1;if(c.required&&!d&&!f){let{state:n}=Lm(T.AUTHENTICATED,{type:j.REQUIRE_MFA});if(c.enrolled){if(c.allEnrollments.length>1)return await e.env.data.loginSessions.update(r.tenant.id,t.loginSession.id,{state:n}),new Response(null,{status:302,headers:{location:`/u2/mfa/login-options?state=${encodeURIComponent(t.loginSession.id)}`}});if(await wO(e.env.data.loginSessions,r.tenant.id,t.loginSession.id,{type:j.UPDATE_CONTEXT,data:{authenticationMethodId:c.enrollment.id}},{state:n}),c.enrollment.type===`totp`)return new Response(null,{status:302,headers:{location:`/u2/mfa/totp-challenge?state=${encodeURIComponent(t.loginSession.id)}`}});if(c.enrollment.type===`passkey`||c.enrollment.type===`webauthn-roaming`||c.enrollment.type===`webauthn-platform`)return new Response(null,{status:302,headers:{location:`/u2/passkey/challenge?state=${encodeURIComponent(t.loginSession.id)}`}});if(!c.enrollment.phone_number)throw Error(`MFA enrollment is missing phone_number`);let{MfaSmsRateLimitError:a}=await Promise.resolve().then(()=>eH);try{await i(e,r,t.loginSession,c.enrollment.phone_number)}catch(e){if(!(e instanceof a))throw e}return new Response(null,{status:302,headers:{location:`/u2/mfa/phone-challenge?state=${encodeURIComponent(t.loginSession.id)}`}})}else{let i=r.tenant,a=i.mfa?.factors?.otp===!0,o=i.mfa?.factors?.sms===!0,s=i.mfa?.factors?.webauthn_roaming===!0||i.mfa?.factors?.webauthn_platform===!0;return await e.env.data.loginSessions.update(r.tenant.id,t.loginSession.id,{state:n}),+!!a+ +!!o+ +!!s>1?new Response(null,{status:302,headers:{location:`/u2/mfa/login-options?state=${encodeURIComponent(t.loginSession.id)}`}}):a?new Response(null,{status:302,headers:{location:`/u2/mfa/totp-enrollment?state=${encodeURIComponent(t.loginSession.id)}`}}):s?new Response(null,{status:302,headers:{location:`/u2/passkey/enrollment?state=${encodeURIComponent(t.loginSession.id)}`}}):new Response(null,{status:302,headers:{location:`/u2/mfa/phone-enrollment?state=${encodeURIComponent(t.loginSession.id)}`}})}}}if(o.mfa_required_by_action&&!o.mfa_verified&&!(l&&await e.env.data.sessions.get(r.tenant.id,l).then(e=>e?lB(e,a.user_id):!1))&&!await Promise.resolve().then(()=>require("./authhero.cjs")).then(e=>e.t).then(({isBrowserRememberedForMfa:t})=>t(e,{tenant:r.tenant,userId:a.user_id,actionRequest:Pm(u.state_data).mfa_required_by_action})))throw new k(403,{error:`access_denied`,error_description:`Multi-factor authentication is required to complete this login`});if(l&&$B(u.state_data)){if(!QB(u)?.ready&&!m){let i=await _B(e,e.env.data,r.tenant.id,a,u,{client:r,authParams:{...n,grant_type:Wi.DeviceCode},authStrategy:t.authStrategy,authConnection:t.authConnection});if(i instanceof Response)return i}await wO(e.env.data.loginSessions,r.tenant.id,u.id,{type:j.UPDATE_CONTEXT,data:{deviceFlow:{...QB(u),ready:!0}}});let i=new Headers({location:`/u2/device/confirmation?state=${encodeURIComponent(u.id)}`});return Ld(r.tenant.id,l,e.var.host||``).forEach(e=>i.append(`set-cookie`,e)),new Response(null,{status:302,headers:i})}if(l&&rV(u.state_data)){let n=new Headers;return Ld(r.tenant.id,l,e.var.host||``).forEach(e=>n.append(`set-cookie`,e)),n.set(`location`,`/u2/connect/start?state=${encodeURIComponent(t.loginSession.id)}`),new Response(null,{status:302,headers:n})}}if(t.loginSession&&a&&!r.is_first_party&&s!==At.WEB_MESSAGE){let n=u.state||T.PENDING;if(n===T.AWAITING_CONSENT)return new Response(null,{status:302,headers:{location:`/u2/consent?state=${encodeURIComponent(t.loginSession.id)}`}});if(n===T.AUTHENTICATED){let n=u.authParams.scope?.split(` `).filter(Boolean)??[];if((await WB(e,{tenantId:r.tenant.id,userId:a.user_id,clientId:r.client_id,requestedScopes:n})).length>0){let{state:n}=Lm(T.AUTHENTICATED,{type:j.REQUIRE_CONSENT});return await e.env.data.loginSessions.update(r.tenant.id,t.loginSession.id,{state:n}),new Response(null,{status:302,headers:{location:`/u2/consent?state=${encodeURIComponent(t.loginSession.id)}`}})}}}if(t.loginSession&&a&&s!==At.WEB_MESSAGE){let n=u.state||T.PENDING,i={};if(u.state_data)try{i=JSON.parse(u.state_data)}catch{}if(n===T.AUTHENTICATED&&!i.passkey_nudge_completed){let{checkPasskeyNudgeRequired:n}=await Promise.resolve().then(()=>require("./passkey-enrollment-D180Gog3.js"));if((await n(e,r.tenant.id,a.user_id,u.auth_connection)).show)return await JV(e,r.tenant.id,u,[`passkey-enrollment`],`/u2/continue?state=${encodeURIComponent(t.loginSession.id)}`),new Response(null,{status:302,headers:{location:`/u2/passkey/enrollment-nudge?state=${encodeURIComponent(t.loginSession.id)}`}})}}let h=o.split(` `).includes(`code`);if(!c&&n.scope?.split(` `).includes(`offline_access`)&&o!==kt.TOKEN&&!h&&!t.impersonatingUser){let i=qO(r,l?await e.env.data.sessions.get(r.tenant.id,l):null);i.allowed&&(c=(await BV(e,{user:a,client:r,login_id:t.loginSession?.id||``,session_id:l,organization:n.organization,auth_connection:u.auth_connection,auth_strategy:u.auth_strategy,scope:n.scope,audience:n.audience,session_transfer:i.session_transfer,max_expires_at:i.max_expires_at})).wireToken)}if(s===At.SAML_POST){if(!l)throw new p.HTTPException(500,{message:`Session ID not available for SAML response`});let i=a;if(t.loginSession&&!m){let o=await _B(e,e.env.data,r.tenant.id,a,t.loginSession,{client:r,authParams:n,authStrategy:t.authStrategy,authConnection:t.authConnection,sessionReused:!!t.existingSessionIdToLink});if(o instanceof Response)return o;i=o}return ML(e,t.client,t.authParams,i,l,t.loginSession?.id)}let g=await $V(e,{authParams:n,user:a,client:r,session_id:l,refresh_token:c,authStrategy:t.authStrategy,authConnection:t.authConnection,loginSession:u,loginSessionIsCurrent:!0,responseType:o,skipHooks:m,organization:t.organization,impersonatingUser:t.impersonatingUser,sessionReused:!!t.existingSessionIdToLink});if(g instanceof Response)return g;if(!n.redirect_uri)throw new k(400,{message:s===At.WEB_MESSAGE?`Redirect URI not allowed for WEB_MESSAGE response mode.`:`Redirect uri not found for this response mode.`});let _=new Headers;l?(Ld(r.tenant.id,l,e.var.host||``).forEach(e=>{_.append(`set-cookie`,e)}),u.auth_connection&&(await e.env.data.promptSettings.get(r.tenant.id))?.show_last_used_connection===!0&&_.append(`set-cookie`,Hd(r.tenant.id,u.auth_connection,e.var.host||``))):s===At.WEB_MESSAGE&&console.warn(`Session ID not available for WEB_MESSAGE, cookie will not be set.`);let v=o.split(` `),y=v.includes(`code`),b=v.includes(`id_token`),x=v.includes(`token`),S={},ee=`code`in g&&typeof g.code==`string`,te=`access_token`in g&&typeof g.access_token==`string`;if(ee&&y&&(S.code=g.code),te&&(x&&(S.access_token=g.access_token,S.token_type=g.token_type,S.expires_in=g.expires_in.toString()),b&&g.id_token&&(S.id_token=g.id_token)),!ee&&!te)throw new k(500,{message:`Invalid token response for front-channel flow.`});let ne=(`state`in g&&typeof g.state==`string`?g.state:void 0)??n.state;if(ne&&(S.state=ne),(x||b)&&n.scope&&(S.scope=n.scope),s===At.WEB_MESSAGE){let t=new URL(n.redirect_uri);return vB(e,`${t.protocol}//${t.host}`,JSON.stringify(S),_)}if(s===At.FORM_POST)return xB(n.redirect_uri,S,_);let re=b||x,ie=new URL(n.redirect_uri);if(re)ie.hash=new URLSearchParams(S).toString();else for(let[e,t]of Object.entries(S))ie.searchParams.set(e,t);return _.set(`location`,ie.toString()),new Response(`Redirecting`,{status:302,headers:_})}async function $V(e,t){let{user:n}=t,r=t.responseType||kt.TOKEN;if(n&&t.organization&&!await LB(e,t.client.tenant.id,n.user_id,t.organization.id))throw new k(403,{error:`access_denied`,error_description:`User is not a member of the specified organization`});let i=t.authParams.scope||``,a=[],o,s=Cc(e.env,e.var.custom_domain),c=t.authParams.audience??t.client.tenant.default_audience??`${s}userinfo`;if(c)try{let r;if(t.grantType===Wi.ClientCredential||!n&&!t.user)r=await VB(e,{grantType:Wi.ClientCredential,tenantId:t.client.tenant.id,clientId:t.client.client_id,audience:c,requestedScopes:t.authParams.scope?.split(` `)||[],organizationId:t.organization?.id});else{let i=n?.user_id||t.user?.user_id;if(!i)throw new k(400,{error:`invalid_request`,error_description:`User ID is required for user-based grants`});r=await VB(e,{grantType:t.grantType,tenantId:t.client.tenant.id,userId:i,clientId:t.client.client_id,audience:c,requestedScopes:t.authParams.scope?.split(` `)||[],organizationId:t.organization?.id})}i=r.scopes.join(` `),a=r.permissions,o=t.client.app_type===`spa`&&r.token_lifetime_for_web?r.token_lifetime_for_web:r.token_lifetime}catch(e){if(e instanceof p.HTTPException)throw e}let l={...t.authParams,scope:i};if(t.loginSession&&n&&!t.skipHooks){t.authStrategy&&n.app_metadata?.strategy!==t.authStrategy.strategy&&(n.app_metadata={...n.app_metadata,strategy:t.authStrategy.strategy},await e.env.data.users.update(t.client.tenant.id,n.user_id,{app_metadata:{...n.app_metadata||{},strategy:t.authStrategy.strategy}}));let r=await _B(e,e.env.data,t.client.tenant.id,n,t.loginSession,{client:t.client,authParams:l,authStrategy:t.authStrategy,authConnection:t.authConnection,sessionReused:t.sessionReused});if(r instanceof Response)return r;n=r}let u=Kc({loginSession:t.loginSession,authConnection:t.authConnection,ctxConnection:e.var.connection}),d=r.split(` `),f=d.includes(`code`),m=d.includes(`id_token`)||d.includes(`token`),h=f&&m;if(r===kt.CODE){if(!n||!t.loginSession)throw new k(500,{message:`User and loginSession is required for code flow`});let r=await LV(e,{user:n,client:t.client,authParams:l,login_id:t.loginSession.id});return await qV(e,t.client.tenant.id,t.loginSession,u,t.loginSessionIsCurrent?t.loginSession:void 0),r}else if(h){if(!n||!t.loginSession)throw new k(500,{message:`User and loginSession is required for hybrid flow`});let r=await LV(e,{user:n,client:t.client,authParams:l,login_id:t.loginSession.id}),i=await IV(e,{...t,user:n,authParams:l,permissions:a,token_lifetime:o,code:r.code});return await qV(e,t.client.tenant.id,t.loginSession,u,t.loginSessionIsCurrent?t.loginSession:void 0),{...i,code:r.code,state:r.state}}else{let r=await IV(e,{...t,user:n,authParams:l,permissions:a,token_lifetime:o});return t.loginSession&&await qV(e,t.client.tenant.id,t.loginSession,u,t.loginSessionIsCurrent?t.loginSession:void 0),r}}var eH=c({MFA_LOCKOUT_REASON:()=>tH,MFA_MAX_FAILED_ATTEMPTS:()=>5,MFA_MAX_SMS_SENDS:()=>5,MfaSmsRateLimitError:()=>nH,checkMfaAttemptAllowed:()=>sH,enforceMfaSmsSendLimit:()=>uH,isMfaLockedOut:()=>aH,recordMfaFailure:()=>cH,resetMfaFailures:()=>lH}),tH=`too_many_mfa_failures`,nH=class extends Error{constructor(){super(`Too many MFA SMS messages sent`),this.name=`MfaSmsRateLimitError`}};function rH(e){return typeof e==`object`&&!!e&&`allowed`in e&&typeof e.allowed==`boolean`}async function iH(e,t){let n=e.env.data.rateLimit;if(!n)return!0;try{let e=await n.consume(`brute-force`,t);return rH(e)?e.allowed:!0}catch(e){return console.error(`MFA rate limit consume failed:`,e),!0}}function aH(e){return e.state===T.FAILED&&e.failure_reason===`too_many_mfa_failures`?!0:(Pm(e.state_data).mfa_failed_attempts??0)>=5}async function oH(e,t,n,r,i){O(e,t,{type:E.TOO_MANY_MFA_FAILURES,description:i,userId:r}),await WV(e,t,n,tH)}async function sH(e,t,n,r){return aH(n)?!1:await iH(e,`mfa:${t}:${r}`)?!0:(await oH(e,t,n,r,`MFA verification rate limit exceeded`),!1)}async function cH(e,t,n,r){let i=await e.env.data.loginSessions.get(t,n);if(!i||aH(i))return{lockedOut:!0};let a=(Pm(i.state_data).mfa_failed_attempts??0)+1;try{await wO(e.env.data.loginSessions,t,n,{type:j.UPDATE_CONTEXT,data:{mfa_failed_attempts:a}})}catch(e){if(e instanceof yO)return{lockedOut:!0};throw e}return a<5?{lockedOut:!1}:(await oH(e,t,i,r,`Too many failed MFA attempts (${a})`),{lockedOut:!0})}async function lH(e,t,n){await wO(e.env.data.loginSessions,t,n,{type:j.UPDATE_CONTEXT,data:{mfa_failed_attempts:void 0}})}async function uH(e,t,n,r,i){let a=await e.env.data.loginSessions.get(t,n);if(a&&(bO(a)||new Date(a.expires_at).getTime()<Date.now()))throw new yO(n);let o=Pm(a?.state_data).mfa_sms_sent??0,s=i??a?.user_id??r,c=()=>(O(e,t,{type:E.ERROR_SENDING_MFA_SMS,description:`MFA SMS send limit reached`,userId:i??a?.user_id}),new nH);if(o>=5||!await iH(e,`mfa-sms:${t}:${s}`))throw c();if(!a)return;let{status:l}=await TO(e.env.data.loginSessions,t,n,`mfa_sms_sent`,5);if(l===`finalized`)throw new yO(n);if(l===`limit_reached`||l===`contended`)throw c()}Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return CB}}),Object.defineProperty(exports,"$a",{enumerable:!0,get:function(){return pa}}),Object.defineProperty(exports,"$c",{enumerable:!0,get:function(){return ac}}),Object.defineProperty(exports,"$d",{enumerable:!0,get:function(){return Ur}}),Object.defineProperty(exports,"$i",{enumerable:!0,get:function(){return kc}}),Object.defineProperty(exports,"$l",{enumerable:!0,get:function(){return go}}),Object.defineProperty(exports,"$n",{enumerable:!0,get:function(){return FT}}),Object.defineProperty(exports,"$o",{enumerable:!0,get:function(){return vo}}),Object.defineProperty(exports,"$r",{enumerable:!0,get:function(){return ju}}),Object.defineProperty(exports,"$s",{enumerable:!0,get:function(){return He}}),Object.defineProperty(exports,"$t",{enumerable:!0,get:function(){return oL}}),Object.defineProperty(exports,"$u",{enumerable:!0,get:function(){return Da}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return nV}}),Object.defineProperty(exports,"Aa",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"Ac",{enumerable:!0,get:function(){return Fa}}),Object.defineProperty(exports,"Ad",{enumerable:!0,get:function(){return Mr}}),Object.defineProperty(exports,"Ai",{enumerable:!0,get:function(){return Vl}}),Object.defineProperty(exports,"Al",{enumerable:!0,get:function(){return eo}}),Object.defineProperty(exports,"An",{enumerable:!0,get:function(){return QD}}),Object.defineProperty(exports,"Ao",{enumerable:!0,get:function(){return jo}}),Object.defineProperty(exports,"Ar",{enumerable:!0,get:function(){return Nm}}),Object.defineProperty(exports,"As",{enumerable:!0,get:function(){return ki}}),Object.defineProperty(exports,"At",{enumerable:!0,get:function(){return oR}}),Object.defineProperty(exports,"Au",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return GB}}),Object.defineProperty(exports,"Ba",{enumerable:!0,get:function(){return Xr}}),Object.defineProperty(exports,"Bc",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"Bd",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(exports,"Bi",{enumerable:!0,get:function(){return Yc}}),Object.defineProperty(exports,"Bl",{enumerable:!0,get:function(){return Ui}}),Object.defineProperty(exports,"Bn",{enumerable:!0,get:function(){return CD}}),Object.defineProperty(exports,"Bo",{enumerable:!0,get:function(){return Cs}}),Object.defineProperty(exports,"Br",{enumerable:!0,get:function(){return Pd}}),Object.defineProperty(exports,"Bs",{enumerable:!0,get:function(){return Fn}}),Object.defineProperty(exports,"Bt",{enumerable:!0,get:function(){return VL}}),Object.defineProperty(exports,"Bu",{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return xV}}),Object.defineProperty(exports,"Ca",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"Cc",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(exports,"Cd",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"Ci",{enumerable:!0,get:function(){return $l}}),Object.defineProperty(exports,"Cl",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"Cn",{enumerable:!0,get:function(){return vO}}),Object.defineProperty(exports,"Co",{enumerable:!0,get:function(){return ka}}),Object.defineProperty(exports,"Cr",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"Cs",{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(exports,"Ct",{enumerable:!0,get:function(){return _R}}),Object.defineProperty(exports,"Cu",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return sV}}),Object.defineProperty(exports,"Da",{enumerable:!0,get:function(){return li}}),Object.defineProperty(exports,"Dc",{enumerable:!0,get:function(){return ps}}),Object.defineProperty(exports,"Dd",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"Di",{enumerable:!0,get:function(){return Yl}}),Object.defineProperty(exports,"Dl",{enumerable:!0,get:function(){return Zs}}),Object.defineProperty(exports,"Dn",{enumerable:!0,get:function(){return lO}}),Object.defineProperty(exports,"Do",{enumerable:!0,get:function(){return Ps}}),Object.defineProperty(exports,"Dr",{enumerable:!0,get:function(){return Rm}}),Object.defineProperty(exports,"Ds",{enumerable:!0,get:function(){return br}}),Object.defineProperty(exports,"Dt",{enumerable:!0,get:function(){return mR}}),Object.defineProperty(exports,"Du",{enumerable:!0,get:function(){return Qo}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return gV}}),Object.defineProperty(exports,"Ea",{enumerable:!0,get:function(){return Es}}),Object.defineProperty(exports,"Ec",{enumerable:!0,get:function(){return xi}}),Object.defineProperty(exports,"Ed",{enumerable:!0,get:function(){return Ja}}),Object.defineProperty(exports,"Ei",{enumerable:!0,get:function(){return Jl}}),Object.defineProperty(exports,"El",{enumerable:!0,get:function(){return zi}}),Object.defineProperty(exports,"En",{enumerable:!0,get:function(){return gO}}),Object.defineProperty(exports,"Eo",{enumerable:!0,get:function(){return Ma}}),Object.defineProperty(exports,"Er",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"Es",{enumerable:!0,get:function(){return Ia}}),Object.defineProperty(exports,"Et",{enumerable:!0,get:function(){return pR}}),Object.defineProperty(exports,"Eu",{enumerable:!0,get:function(){return Hi}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return KB}}),Object.defineProperty(exports,"Fa",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(exports,"Fc",{enumerable:!0,get:function(){return Gi}}),Object.defineProperty(exports,"Fd",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"Fi",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"Fl",{enumerable:!0,get:function(){return tc}}),Object.defineProperty(exports,"Fn",{enumerable:!0,get:function(){return HD}}),Object.defineProperty(exports,"Fo",{enumerable:!0,get:function(){return mi}}),Object.defineProperty(exports,"Fr",{enumerable:!0,get:function(){return Vd}}),Object.defineProperty(exports,"Fs",{enumerable:!0,get:function(){return si}}),Object.defineProperty(exports,"Ft",{enumerable:!0,get:function(){return KL}}),Object.defineProperty(exports,"Fu",{enumerable:!0,get:function(){return wr}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return zB}}),Object.defineProperty(exports,"Ga",{enumerable:!0,get:function(){return ta}}),Object.defineProperty(exports,"Gc",{enumerable:!0,get:function(){return Dr}}),Object.defineProperty(exports,"Gd",{enumerable:!0,get:function(){return ls}}),Object.defineProperty(exports,"Gi",{enumerable:!0,get:function(){return Ic}}),Object.defineProperty(exports,"Gl",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"Gn",{enumerable:!0,get:function(){return pD}}),Object.defineProperty(exports,"Go",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"Gr",{enumerable:!0,get:function(){return sd}}),Object.defineProperty(exports,"Gs",{enumerable:!0,get:function(){return lo}}),Object.defineProperty(exports,"Gt",{enumerable:!0,get:function(){return zI}}),Object.defineProperty(exports,"Gu",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return WB}}),Object.defineProperty(exports,"Ha",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(exports,"Hc",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"Hd",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"Hi",{enumerable:!0,get:function(){return Kc}}),Object.defineProperty(exports,"Hl",{enumerable:!0,get:function(){return Lr}}),Object.defineProperty(exports,"Hn",{enumerable:!0,get:function(){return DD}}),Object.defineProperty(exports,"Ho",{enumerable:!0,get:function(){return Gt}}),Object.defineProperty(exports,"Hr",{enumerable:!0,get:function(){return vd}}),Object.defineProperty(exports,"Hs",{enumerable:!0,get:function(){return Gr}}),Object.defineProperty(exports,"Ht",{enumerable:!0,get:function(){return kL}}),Object.defineProperty(exports,"Hu",{enumerable:!0,get:function(){return Go}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return $B}}),Object.defineProperty(exports,"Ia",{enumerable:!0,get:function(){return fo}}),Object.defineProperty(exports,"Ic",{enumerable:!0,get:function(){return ts}}),Object.defineProperty(exports,"Id",{enumerable:!0,get:function(){return Ki}}),Object.defineProperty(exports,"Ii",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"Il",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(exports,"In",{enumerable:!0,get:function(){return LD}}),Object.defineProperty(exports,"Io",{enumerable:!0,get:function(){return So}}),Object.defineProperty(exports,"Ir",{enumerable:!0,get:function(){return Nd}}),Object.defineProperty(exports,"Is",{enumerable:!0,get:function(){return qt}}),Object.defineProperty(exports,"It",{enumerable:!0,get:function(){return GL}}),Object.defineProperty(exports,"Iu",{enumerable:!0,get:function(){return Vs}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return kB}}),Object.defineProperty(exports,"Ja",{enumerable:!0,get:function(){return dc}}),Object.defineProperty(exports,"Jc",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"Jd",{enumerable:!0,get:function(){return ao}}),Object.defineProperty(exports,"Ji",{enumerable:!0,get:function(){return Rc}}),Object.defineProperty(exports,"Jl",{enumerable:!0,get:function(){return ji}}),Object.defineProperty(exports,"Jn",{enumerable:!0,get:function(){return aD}}),Object.defineProperty(exports,"Jo",{enumerable:!0,get:function(){return vs}}),Object.defineProperty(exports,"Jr",{enumerable:!0,get:function(){return bd}}),Object.defineProperty(exports,"Js",{enumerable:!0,get:function(){return us}}),Object.defineProperty(exports,"Jt",{enumerable:!0,get:function(){return RI}}),Object.defineProperty(exports,"Ju",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return LB}}),Object.defineProperty(exports,"Ka",{enumerable:!0,get:function(){return ds}}),Object.defineProperty(exports,"Kc",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(exports,"Kd",{enumerable:!0,get:function(){return qr}}),Object.defineProperty(exports,"Ki",{enumerable:!0,get:function(){return Lc}}),Object.defineProperty(exports,"Kl",{enumerable:!0,get:function(){return Ha}}),Object.defineProperty(exports,"Kn",{enumerable:!0,get:function(){return _D}}),Object.defineProperty(exports,"Ko",{enumerable:!0,get:function(){return ca}}),Object.defineProperty(exports,"Kr",{enumerable:!0,get:function(){return ld}}),Object.defineProperty(exports,"Ks",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"Kt",{enumerable:!0,get:function(){return LI}}),Object.defineProperty(exports,"Ku",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return ZB}}),Object.defineProperty(exports,"La",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"Lc",{enumerable:!0,get:function(){return zr}}),Object.defineProperty(exports,"Ld",{enumerable:!0,get:function(){return ns}}),Object.defineProperty(exports,"Li",{enumerable:!0,get:function(){return Zc}}),Object.defineProperty(exports,"Ll",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(exports,"Ln",{enumerable:!0,get:function(){return RD}}),Object.defineProperty(exports,"Lo",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"Lr",{enumerable:!0,get:function(){return Rd}}),Object.defineProperty(exports,"Ls",{enumerable:!0,get:function(){return oo}}),Object.defineProperty(exports,"Lt",{enumerable:!0,get:function(){return zL}}),Object.defineProperty(exports,"Lu",{enumerable:!0,get:function(){return at}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return XB}}),Object.defineProperty(exports,"Ma",{enumerable:!0,get:function(){return In}}),Object.defineProperty(exports,"Mc",{enumerable:!0,get:function(){return Ci}}),Object.defineProperty(exports,"Md",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(exports,"Mi",{enumerable:!0,get:function(){return jl}}),Object.defineProperty(exports,"Ml",{enumerable:!0,get:function(){return Wi}}),Object.defineProperty(exports,"Mn",{enumerable:!0,get:function(){return KD}}),Object.defineProperty(exports,"Mo",{enumerable:!0,get:function(){return mr}}),Object.defineProperty(exports,"Mr",{enumerable:!0,get:function(){return Wd}}),Object.defineProperty(exports,"Ms",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"Mt",{enumerable:!0,get:function(){return aR}}),Object.defineProperty(exports,"Mu",{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return tV}}),Object.defineProperty(exports,"Na",{enumerable:!0,get:function(){return cs}}),Object.defineProperty(exports,"Nc",{enumerable:!0,get:function(){return to}}),Object.defineProperty(exports,"Nd",{enumerable:!0,get:function(){return Kt}}),Object.defineProperty(exports,"Ni",{enumerable:!0,get:function(){return Wl}}),Object.defineProperty(exports,"Nl",{enumerable:!0,get:function(){return es}}),Object.defineProperty(exports,"Nn",{enumerable:!0,get:function(){return WD}}),Object.defineProperty(exports,"No",{enumerable:!0,get:function(){return Ms}}),Object.defineProperty(exports,"Nr",{enumerable:!0,get:function(){return Dd}}),Object.defineProperty(exports,"Ns",{enumerable:!0,get:function(){return ga}}),Object.defineProperty(exports,"Nt",{enumerable:!0,get:function(){return rR}}),Object.defineProperty(exports,"Nu",{enumerable:!0,get:function(){return Oi}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return oV}}),Object.defineProperty(exports,"Oa",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(exports,"Oc",{enumerable:!0,get:function(){return Io}}),Object.defineProperty(exports,"Od",{enumerable:!0,get:function(){return Li}}),Object.defineProperty(exports,"Oi",{enumerable:!0,get:function(){return Al}}),Object.defineProperty(exports,"Ol",{enumerable:!0,get:function(){return _t}}),Object.defineProperty(exports,"On",{enumerable:!0,get:function(){return tO}}),Object.defineProperty(exports,"Oo",{enumerable:!0,get:function(){return bi}}),Object.defineProperty(exports,"Or",{enumerable:!0,get:function(){return Pm}}),Object.defineProperty(exports,"Os",{enumerable:!0,get:function(){return Rs}}),Object.defineProperty(exports,"Ot",{enumerable:!0,get:function(){return dR}}),Object.defineProperty(exports,"Ou",{enumerable:!0,get:function(){return Ir}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return QB}}),Object.defineProperty(exports,"Pa",{enumerable:!0,get:function(){return Kr}}),Object.defineProperty(exports,"Pc",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"Pd",{enumerable:!0,get:function(){return no}}),Object.defineProperty(exports,"Pi",{enumerable:!0,get:function(){return Nl}}),Object.defineProperty(exports,"Pl",{enumerable:!0,get:function(){return Rr}}),Object.defineProperty(exports,"Pn",{enumerable:!0,get:function(){return VD}}),Object.defineProperty(exports,"Po",{enumerable:!0,get:function(){return vi}}),Object.defineProperty(exports,"Pr",{enumerable:!0,get:function(){return Fd}}),Object.defineProperty(exports,"Ps",{enumerable:!0,get:function(){return ws}}),Object.defineProperty(exports,"Pt",{enumerable:!0,get:function(){return nR}}),Object.defineProperty(exports,"Pu",{enumerable:!0,get:function(){return Vo}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return SB}}),Object.defineProperty(exports,"Qa",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,"Qc",{enumerable:!0,get:function(){return Hr}}),Object.defineProperty(exports,"Qd",{enumerable:!0,get:function(){return os}}),Object.defineProperty(exports,"Qi",{enumerable:!0,get:function(){return jc}}),Object.defineProperty(exports,"Ql",{enumerable:!0,get:function(){return st}}),Object.defineProperty(exports,"Qn",{enumerable:!0,get:function(){return tD}}),Object.defineProperty(exports,"Qo",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"Qr",{enumerable:!0,get:function(){return Ku}}),Object.defineProperty(exports,"Qs",{enumerable:!0,get:function(){return Oo}}),Object.defineProperty(exports,"Qt",{enumerable:!0,get:function(){return VI}}),Object.defineProperty(exports,"Qu",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return qB}}),Object.defineProperty(exports,"Ra",{enumerable:!0,get:function(){return na}}),Object.defineProperty(exports,"Rc",{enumerable:!0,get:function(){return nc}}),Object.defineProperty(exports,"Rd",{enumerable:!0,get:function(){return Br}}),Object.defineProperty(exports,"Ri",{enumerable:!0,get:function(){return rl}}),Object.defineProperty(exports,"Rl",{enumerable:!0,get:function(){return $a}}),Object.defineProperty(exports,"Rn",{enumerable:!0,get:function(){return BD}}),Object.defineProperty(exports,"Ro",{enumerable:!0,get:function(){return ha}}),Object.defineProperty(exports,"Rr",{enumerable:!0,get:function(){return Ud}}),Object.defineProperty(exports,"Rs",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"Rt",{enumerable:!0,get:function(){return BL}}),Object.defineProperty(exports,"Ru",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return SV}}),Object.defineProperty(exports,"Sa",{enumerable:!0,get:function(){return To}}),Object.defineProperty(exports,"Sc",{enumerable:!0,get:function(){return Po}}),Object.defineProperty(exports,"Sd",{enumerable:!0,get:function(){return Cr}}),Object.defineProperty(exports,"Sf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"Si",{enumerable:!0,get:function(){return eu}}),Object.defineProperty(exports,"Sl",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(exports,"Sn",{enumerable:!0,get:function(){return wO}}),Object.defineProperty(exports,"So",{enumerable:!0,get:function(){return Wt}}),Object.defineProperty(exports,"Sr",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"Ss",{enumerable:!0,get:function(){return xc}}),Object.defineProperty(exports,"St",{enumerable:!0,get:function(){return vR}}),Object.defineProperty(exports,"Su",{enumerable:!0,get:function(){return Js}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return vV}}),Object.defineProperty(exports,"Ta",{enumerable:!0,get:function(){return sr}}),Object.defineProperty(exports,"Tc",{enumerable:!0,get:function(){return Fs}}),Object.defineProperty(exports,"Td",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(exports,"Ti",{enumerable:!0,get:function(){return Ql}}),Object.defineProperty(exports,"Tl",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,"Tn",{enumerable:!0,get:function(){return mO}}),Object.defineProperty(exports,"To",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(exports,"Tr",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"Ts",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(exports,"Tt",{enumerable:!0,get:function(){return hR}}),Object.defineProperty(exports,"Tu",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return NB}}),Object.defineProperty(exports,"Ua",{enumerable:!0,get:function(){return uo}}),Object.defineProperty(exports,"Uc",{enumerable:!0,get:function(){return Mi}}),Object.defineProperty(exports,"Ud",{enumerable:!0,get:function(){return $i}}),Object.defineProperty(exports,"Ui",{enumerable:!0,get:function(){return Wc}}),Object.defineProperty(exports,"Ul",{enumerable:!0,get:function(){return ec}}),Object.defineProperty(exports,"Un",{enumerable:!0,get:function(){return OD}}),Object.defineProperty(exports,"Uo",{enumerable:!0,get:function(){return jr}}),Object.defineProperty(exports,"Ur",{enumerable:!0,get:function(){return md}}),Object.defineProperty(exports,"Us",{enumerable:!0,get:function(){return sc}}),Object.defineProperty(exports,"Ut",{enumerable:!0,get:function(){return II}}),Object.defineProperty(exports,"Uu",{enumerable:!0,get:function(){return Or}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return UB}}),Object.defineProperty(exports,"Va",{enumerable:!0,get:function(){return mc}}),Object.defineProperty(exports,"Vc",{enumerable:!0,get:function(){return Ua}}),Object.defineProperty(exports,"Vd",{enumerable:!0,get:function(){return co}}),Object.defineProperty(exports,"Vi",{enumerable:!0,get:function(){return Xc}}),Object.defineProperty(exports,"Vl",{enumerable:!0,get:function(){return $o}}),Object.defineProperty(exports,"Vn",{enumerable:!0,get:function(){return wD}}),Object.defineProperty(exports,"Vo",{enumerable:!0,get:function(){return oi}}),Object.defineProperty(exports,"Vr",{enumerable:!0,get:function(){return hd}}),Object.defineProperty(exports,"Vs",{enumerable:!0,get:function(){return ss}}),Object.defineProperty(exports,"Vt",{enumerable:!0,get:function(){return wL}}),Object.defineProperty(exports,"Vu",{enumerable:!0,get:function(){return Ni}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return VB}}),Object.defineProperty(exports,"Wa",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"Wc",{enumerable:!0,get:function(){return Wo}}),Object.defineProperty(exports,"Wd",{enumerable:!0,get:function(){return Ln}}),Object.defineProperty(exports,"Wi",{enumerable:!0,get:function(){return Uc}}),Object.defineProperty(exports,"Wl",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(exports,"Wn",{enumerable:!0,get:function(){return AD}}),Object.defineProperty(exports,"Wo",{enumerable:!0,get:function(){return _o}}),Object.defineProperty(exports,"Wr",{enumerable:!0,get:function(){return _d}}),Object.defineProperty(exports,"Ws",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(exports,"Wt",{enumerable:!0,get:function(){return OL}}),Object.defineProperty(exports,"Wu",{enumerable:!0,get:function(){return Gs}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return OB}}),Object.defineProperty(exports,"Xa",{enumerable:!0,get:function(){return ui}}),Object.defineProperty(exports,"Xc",{enumerable:!0,get:function(){return Nn}}),Object.defineProperty(exports,"Xd",{enumerable:!0,get:function(){return Xi}}),Object.defineProperty(exports,"Xi",{enumerable:!0,get:function(){return Hc}}),Object.defineProperty(exports,"Xl",{enumerable:!0,get:function(){return Er}}),Object.defineProperty(exports,"Xn",{enumerable:!0,get:function(){return nD}}),Object.defineProperty(exports,"Xo",{enumerable:!0,get:function(){return yc}}),Object.defineProperty(exports,"Xr",{enumerable:!0,get:function(){return id}}),Object.defineProperty(exports,"Xs",{enumerable:!0,get:function(){return uc}}),Object.defineProperty(exports,"Xt",{enumerable:!0,get:function(){return qI}}),Object.defineProperty(exports,"Xu",{enumerable:!0,get:function(){return Fr}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return wB}}),Object.defineProperty(exports,"Ya",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(exports,"Yc",{enumerable:!0,get:function(){return Ji}}),Object.defineProperty(exports,"Yd",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"Yi",{enumerable:!0,get:function(){return zc}}),Object.defineProperty(exports,"Yl",{enumerable:!0,get:function(){return Uo}}),Object.defineProperty(exports,"Yn",{enumerable:!0,get:function(){return iD}}),Object.defineProperty(exports,"Yo",{enumerable:!0,get:function(){return ti}}),Object.defineProperty(exports,"Yr",{enumerable:!0,get:function(){return xd}}),Object.defineProperty(exports,"Ys",{enumerable:!0,get:function(){return Jr}}),Object.defineProperty(exports,"Yt",{enumerable:!0,get:function(){return sL}}),Object.defineProperty(exports,"Yu",{enumerable:!0,get:function(){return Vi}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return DB}}),Object.defineProperty(exports,"Za",{enumerable:!0,get:function(){return bo}}),Object.defineProperty(exports,"Zc",{enumerable:!0,get:function(){return as}}),Object.defineProperty(exports,"Zd",{enumerable:!0,get:function(){return Pn}}),Object.defineProperty(exports,"Zi",{enumerable:!0,get:function(){return Ac}}),Object.defineProperty(exports,"Zl",{enumerable:!0,get:function(){return Us}}),Object.defineProperty(exports,"Zn",{enumerable:!0,get:function(){return rD}}),Object.defineProperty(exports,"Zo",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(exports,"Zr",{enumerable:!0,get:function(){return qu}}),Object.defineProperty(exports,"Zs",{enumerable:!0,get:function(){return fa}}),Object.defineProperty(exports,"Zt",{enumerable:!0,get:function(){return XI}}),Object.defineProperty(exports,"Zu",{enumerable:!0,get:function(){return Qs}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return ZV}}),Object.defineProperty(exports,"_a",{enumerable:!0,get:function(){return Wn}}),Object.defineProperty(exports,"_c",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,"_d",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(exports,"_f",{enumerable:!0,get:function(){return Jt}}),Object.defineProperty(exports,"_i",{enumerable:!0,get:function(){return ou}}),Object.defineProperty(exports,"_l",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"_n",{enumerable:!0,get:function(){return NO}}),Object.defineProperty(exports,"_o",{enumerable:!0,get:function(){return xo}}),Object.defineProperty(exports,"_r",{enumerable:!0,get:function(){return yv}}),Object.defineProperty(exports,"_s",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,"_t",{enumerable:!0,get:function(){return JR}}),Object.defineProperty(exports,"_u",{enumerable:!0,get:function(){return qa}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return eH}}),Object.defineProperty(exports,"aa",{enumerable:!0,get:function(){return Tc}}),Object.defineProperty(exports,"ac",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"ad",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"af",{enumerable:!0,get:function(){return Mn}}),Object.defineProperty(exports,"ai",{enumerable:!0,get:function(){return Pu}}),Object.defineProperty(exports,"al",{enumerable:!0,get:function(){return qo}}),Object.defineProperty(exports,"an",{enumerable:!0,get:function(){return cL}}),Object.defineProperty(exports,"ao",{enumerable:!0,get:function(){return Ao}}),Object.defineProperty(exports,"ar",{enumerable:!0,get:function(){return qx}}),Object.defineProperty(exports,"as",{enumerable:!0,get:function(){return bc}}),Object.defineProperty(exports,"at",{enumerable:!0,get:function(){return nB}}),Object.defineProperty(exports,"au",{enumerable:!0,get:function(){return vc}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return MV}}),Object.defineProperty(exports,"ba",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(exports,"bc",{enumerable:!0,get:function(){return Si}}),Object.defineProperty(exports,"bd",{enumerable:!0,get:function(){return Di}}),Object.defineProperty(exports,"bf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"bi",{enumerable:!0,get:function(){return pu}}),Object.defineProperty(exports,"bl",{enumerable:!0,get:function(){return Sr}}),Object.defineProperty(exports,"bn",{enumerable:!0,get:function(){return bO}}),Object.defineProperty(exports,"bo",{enumerable:!0,get:function(){return Xn}}),Object.defineProperty(exports,"br",{enumerable:!0,get:function(){return U_}}),Object.defineProperty(exports,"bs",{enumerable:!0,get:function(){return bs}}),Object.defineProperty(exports,"bt",{enumerable:!0,get:function(){return wR}}),Object.defineProperty(exports,"bu",{enumerable:!0,get:function(){return Jo}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return HV}}),Object.defineProperty(exports,"ca",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(exports,"cc",{enumerable:!0,get:function(){return di}}),Object.defineProperty(exports,"cd",{enumerable:!0,get:function(){return Hs}}),Object.defineProperty(exports,"cf",{enumerable:!0,get:function(){return ic}}),Object.defineProperty(exports,"ci",{enumerable:!0,get:function(){return Lu}}),Object.defineProperty(exports,"cl",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(exports,"cn",{enumerable:!0,get:function(){return ZO}}),Object.defineProperty(exports,"co",{enumerable:!0,get:function(){return js}}),Object.defineProperty(exports,"cr",{enumerable:!0,get:function(){return wx}}),Object.defineProperty(exports,"cs",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"ct",{enumerable:!0,get:function(){return Yz}}),Object.defineProperty(exports,"cu",{enumerable:!0,get:function(){return mo}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return IV}}),Object.defineProperty(exports,"da",{enumerable:!0,get:function(){return zs}}),Object.defineProperty(exports,"dc",{enumerable:!0,get:function(){return ko}}),Object.defineProperty(exports,"dd",{enumerable:!0,get:function(){return Ga}}),Object.defineProperty(exports,"df",{enumerable:!0,get:function(){return wo}}),Object.defineProperty(exports,"di",{enumerable:!0,get:function(){return ku}}),Object.defineProperty(exports,"dl",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"dn",{enumerable:!0,get:function(){return WO}}),Object.defineProperty(exports,"do",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(exports,"dr",{enumerable:!0,get:function(){return Uy}}),Object.defineProperty(exports,"ds",{enumerable:!0,get:function(){return ms}}),Object.defineProperty(exports,"dt",{enumerable:!0,get:function(){return Bz}}),Object.defineProperty(exports,"du",{enumerable:!0,get:function(){return Un}}),Object.defineProperty(exports,"ea",{enumerable:!0,get:function(){return Nc}}),Object.defineProperty(exports,"ec",{enumerable:!0,get:function(){return wa}}),Object.defineProperty(exports,"ed",{enumerable:!0,get:function(){return Mo}}),Object.defineProperty(exports,"ef",{enumerable:!0,get:function(){return oc}}),Object.defineProperty(exports,"ei",{enumerable:!0,get:function(){return Mu}}),Object.defineProperty(exports,"el",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(exports,"en",{enumerable:!0,get:function(){return TL}}),Object.defineProperty(exports,"eo",{enumerable:!0,get:function(){return Yn}}),Object.defineProperty(exports,"er",{enumerable:!0,get:function(){return GT}}),Object.defineProperty(exports,"es",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return xB}}),Object.defineProperty(exports,"eu",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return LV}}),Object.defineProperty(exports,"fa",{enumerable:!0,get:function(){return Ti}}),Object.defineProperty(exports,"fc",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(exports,"fd",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,"ff",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"fi",{enumerable:!0,get:function(){return Tu}}),Object.defineProperty(exports,"fl",{enumerable:!0,get:function(){return Ri}}),Object.defineProperty(exports,"fn",{enumerable:!0,get:function(){return UO}}),Object.defineProperty(exports,"fo",{enumerable:!0,get:function(){return Ca}}),Object.defineProperty(exports,"fr",{enumerable:!0,get:function(){return Cy}}),Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return Zr}}),Object.defineProperty(exports,"ft",{enumerable:!0,get:function(){return Fz}}),Object.defineProperty(exports,"fu",{enumerable:!0,get:function(){return hs}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return UV}}),Object.defineProperty(exports,"ga",{enumerable:!0,get:function(){return oa}}),Object.defineProperty(exports,"gc",{enumerable:!0,get:function(){return Fo}}),Object.defineProperty(exports,"gd",{enumerable:!0,get:function(){return Ks}}),Object.defineProperty(exports,"gf",{enumerable:!0,get:function(){return ci}}),Object.defineProperty(exports,"gi",{enumerable:!0,get:function(){return xu}}),Object.defineProperty(exports,"gl",{enumerable:!0,get:function(){return Ra}}),Object.defineProperty(exports,"gn",{enumerable:!0,get:function(){return qO}}),Object.defineProperty(exports,"go",{enumerable:!0,get:function(){return fi}}),Object.defineProperty(exports,"gr",{enumerable:!0,get:function(){return bv}}),Object.defineProperty(exports,"gs",{enumerable:!0,get:function(){return yo}}),Object.defineProperty(exports,"gt",{enumerable:!0,get:function(){return dz}}),Object.defineProperty(exports,"gu",{enumerable:!0,get:function(){return We}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return WV}}),Object.defineProperty(exports,"ha",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"hc",{enumerable:!0,get:function(){return rs}}),Object.defineProperty(exports,"hd",{enumerable:!0,get:function(){return kr}}),Object.defineProperty(exports,"hf",{enumerable:!0,get:function(){return Ts}}),Object.defineProperty(exports,"hi",{enumerable:!0,get:function(){return Su}}),Object.defineProperty(exports,"hl",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(exports,"hn",{enumerable:!0,get:function(){return HO}}),Object.defineProperty(exports,"ho",{enumerable:!0,get:function(){return Zt}}),Object.defineProperty(exports,"hr",{enumerable:!0,get:function(){return Xv}}),Object.defineProperty(exports,"hs",{enumerable:!0,get:function(){return Wr}}),Object.defineProperty(exports,"ht",{enumerable:!0,get:function(){return _z}}),Object.defineProperty(exports,"hu",{enumerable:!0,get:function(){return It}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return aH}}),Object.defineProperty(exports,"ia",{enumerable:!0,get:function(){return Cc}}),Object.defineProperty(exports,"ic",{enumerable:!0,get:function(){return Eo}}),Object.defineProperty(exports,"id",{enumerable:!0,get:function(){return Va}}),Object.defineProperty(exports,"if",{enumerable:!0,get:function(){return qi}}),Object.defineProperty(exports,"ii",{enumerable:!0,get:function(){return Ju}}),Object.defineProperty(exports,"il",{enumerable:!0,get:function(){return Fi}}),Object.defineProperty(exports,"in",{enumerable:!0,get:function(){return HI}}),Object.defineProperty(exports,"io",{enumerable:!0,get:function(){return ya}}),Object.defineProperty(exports,"ir",{enumerable:!0,get:function(){return DS}}),Object.defineProperty(exports,"is",{enumerable:!0,get:function(){return ni}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return eB}}),Object.defineProperty(exports,"iu",{enumerable:!0,get:function(){return ei}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return YB}}),Object.defineProperty(exports,"ja",{enumerable:!0,get:function(){return Qi}}),Object.defineProperty(exports,"jc",{enumerable:!0,get:function(){return Ls}}),Object.defineProperty(exports,"jd",{enumerable:!0,get:function(){return Ys}}),Object.defineProperty(exports,"ji",{enumerable:!0,get:function(){return Ml}}),Object.defineProperty(exports,"jl",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"jn",{enumerable:!0,get:function(){return nO}}),Object.defineProperty(exports,"jo",{enumerable:!0,get:function(){return Oa}}),Object.defineProperty(exports,"jr",{enumerable:!0,get:function(){return Id}}),Object.defineProperty(exports,"js",{enumerable:!0,get:function(){return Co}}),Object.defineProperty(exports,"jt",{enumerable:!0,get:function(){return sR}}),Object.defineProperty(exports,"ju",{enumerable:!0,get:function(){return Ba}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return rV}}),Object.defineProperty(exports,"ka",{enumerable:!0,get:function(){return so}}),Object.defineProperty(exports,"kc",{enumerable:!0,get:function(){return et}}),Object.defineProperty(exports,"kd",{enumerable:!0,get:function(){return Yo}}),Object.defineProperty(exports,"ki",{enumerable:!0,get:function(){return Pl}}),Object.defineProperty(exports,"kl",{enumerable:!0,get:function(){return At}}),Object.defineProperty(exports,"kn",{enumerable:!0,get:function(){return $D}}),Object.defineProperty(exports,"ko",{enumerable:!0,get:function(){return ba}}),Object.defineProperty(exports,"kr",{enumerable:!0,get:function(){return Lm}}),Object.defineProperty(exports,"ks",{enumerable:!0,get:function(){return wi}}),Object.defineProperty(exports,"kt",{enumerable:!0,get:function(){return cR}}),Object.defineProperty(exports,"ku",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return YV}}),Object.defineProperty(exports,"la",{enumerable:!0,get:function(){return La}}),Object.defineProperty(exports,"lc",{enumerable:!0,get:function(){return Xt}}),Object.defineProperty(exports,"ld",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(exports,"lf",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(exports,"li",{enumerable:!0,get:function(){return Du}}),Object.defineProperty(exports,"ll",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(exports,"ln",{enumerable:!0,get:function(){return ek}}),Object.defineProperty(exports,"lo",{enumerable:!0,get:function(){return la}}),Object.defineProperty(exports,"lr",{enumerable:!0,get:function(){return Ax}}),Object.defineProperty(exports,"ls",{enumerable:!0,get:function(){return ra}}),Object.defineProperty(exports,"lt",{enumerable:!0,get:function(){return Hz}}),Object.defineProperty(exports,"lu",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return BV}}),Object.defineProperty(exports,"ma",{enumerable:!0,get:function(){return ho}}),Object.defineProperty(exports,"mc",{enumerable:!0,get:function(){return As}}),Object.defineProperty(exports,"md",{enumerable:!0,get:function(){return Ko}}),Object.defineProperty(exports,"mf",{enumerable:!0,get:function(){return ir}}),Object.defineProperty(exports,"mi",{enumerable:!0,get:function(){return Cu}}),Object.defineProperty(exports,"ml",{enumerable:!0,get:function(){return Xs}}),Object.defineProperty(exports,"mn",{enumerable:!0,get:function(){return KO}}),Object.defineProperty(exports,"mo",{enumerable:!0,get:function(){return pi}}),Object.defineProperty(exports,"mr",{enumerable:!0,get:function(){return Zv}}),Object.defineProperty(exports,"ms",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(exports,"mt",{enumerable:!0,get:function(){return Dz}}),Object.defineProperty(exports,"mu",{enumerable:!0,get:function(){return gc}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return sH}}),Object.defineProperty(exports,"na",{enumerable:!0,get:function(){return Oc}}),Object.defineProperty(exports,"nc",{enumerable:!0,get:function(){return hi}}),Object.defineProperty(exports,"nd",{enumerable:!0,get:function(){return yi}}),Object.defineProperty(exports,"nf",{enumerable:!0,get:function(){return ro}}),Object.defineProperty(exports,"ni",{enumerable:!0,get:function(){return rd}}),Object.defineProperty(exports,"nl",{enumerable:!0,get:function(){return Ka}}),Object.defineProperty(exports,"nn",{enumerable:!0,get:function(){return ZI}}),Object.defineProperty(exports,"no",{enumerable:!0,get:function(){return Sc}}),Object.defineProperty(exports,"nr",{enumerable:!0,get:function(){return ME}}),Object.defineProperty(exports,"ns",{enumerable:!0,get:function(){return qn}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return lB}}),Object.defineProperty(exports,"nu",{enumerable:!0,get:function(){return Gn}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return cH}}),Object.defineProperty(exports,"oa",{enumerable:!0,get:function(){return wc}}),Object.defineProperty(exports,"oc",{enumerable:!0,get:function(){return Sa}}),Object.defineProperty(exports,"od",{enumerable:!0,get:function(){return Ai}}),Object.defineProperty(exports,"of",{enumerable:!0,get:function(){return is}}),Object.defineProperty(exports,"oi",{enumerable:!0,get:function(){return Au}}),Object.defineProperty(exports,"ol",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"on",{enumerable:!0,get:function(){return QO}}),Object.defineProperty(exports,"oo",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(exports,"or",{enumerable:!0,get:function(){return Gx}}),Object.defineProperty(exports,"os",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(exports,"ot",{enumerable:!0,get:function(){return tB}}),Object.defineProperty(exports,"ou",{enumerable:!0,get:function(){return Rt}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return QV}}),Object.defineProperty(exports,"pa",{enumerable:!0,get:function(){return or}}),Object.defineProperty(exports,"pc",{enumerable:!0,get:function(){return Ta}}),Object.defineProperty(exports,"pd",{enumerable:!0,get:function(){return Pi}}),Object.defineProperty(exports,"pf",{enumerable:!0,get:function(){return _a}}),Object.defineProperty(exports,"pi",{enumerable:!0,get:function(){return wu}}),Object.defineProperty(exports,"pl",{enumerable:!0,get:function(){return Nr}}),Object.defineProperty(exports,"pn",{enumerable:!0,get:function(){return VO}}),Object.defineProperty(exports,"po",{enumerable:!0,get:function(){return Os}}),Object.defineProperty(exports,"pr",{enumerable:!0,get:function(){return Sy}}),Object.defineProperty(exports,"ps",{enumerable:!0,get:function(){return hc}}),Object.defineProperty(exports,"pt",{enumerable:!0,get:function(){return jz}}),Object.defineProperty(exports,"pu",{enumerable:!0,get:function(){return Qr}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return FB}}),Object.defineProperty(exports,"qa",{enumerable:!0,get:function(){return Yr}}),Object.defineProperty(exports,"qc",{enumerable:!0,get:function(){return io}}),Object.defineProperty(exports,"qd",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(exports,"qi",{enumerable:!0,get:function(){return Bc}}),Object.defineProperty(exports,"ql",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,"qn",{enumerable:!0,get:function(){return oD}}),Object.defineProperty(exports,"qo",{enumerable:!0,get:function(){return Kn}}),Object.defineProperty(exports,"qr",{enumerable:!0,get:function(){return od}}),Object.defineProperty(exports,"qs",{enumerable:!0,get:function(){return ea}}),Object.defineProperty(exports,"qt",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"qu",{enumerable:!0,get:function(){return Za}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return uH}}),Object.defineProperty(exports,"ra",{enumerable:!0,get:function(){return Ec}}),Object.defineProperty(exports,"rc",{enumerable:!0,get:function(){return ia}}),Object.defineProperty(exports,"rd",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"rf",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"ri",{enumerable:!0,get:function(){return Ru}}),Object.defineProperty(exports,"rl",{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,"rn",{enumerable:!0,get:function(){return YI}}),Object.defineProperty(exports,"ro",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(exports,"rr",{enumerable:!0,get:function(){return YE}}),Object.defineProperty(exports,"rs",{enumerable:!0,get:function(){return ys}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return qz}}),Object.defineProperty(exports,"ru",{enumerable:!0,get:function(){return _s}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return lH}}),Object.defineProperty(exports,"sa",{enumerable:!0,get:function(){return Ro}}),Object.defineProperty(exports,"sc",{enumerable:!0,get:function(){return Ds}}),Object.defineProperty(exports,"sd",{enumerable:!0,get:function(){return Tr}}),Object.defineProperty(exports,"sf",{enumerable:!0,get:function(){return Vr}}),Object.defineProperty(exports,"si",{enumerable:!0,get:function(){return Hu}}),Object.defineProperty(exports,"sl",{enumerable:!0,get:function(){return qs}}),Object.defineProperty(exports,"sn",{enumerable:!0,get:function(){return XO}}),Object.defineProperty(exports,"so",{enumerable:!0,get:function(){return Ea}}),Object.defineProperty(exports,"sr",{enumerable:!0,get:function(){return Ux}}),Object.defineProperty(exports,"ss",{enumerable:!0,get:function(){return po}}),Object.defineProperty(exports,"st",{enumerable:!0,get:function(){return rB}}),Object.defineProperty(exports,"su",{enumerable:!0,get:function(){return ar}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return nH}}),Object.defineProperty(exports,"ta",{enumerable:!0,get:function(){return Dc}}),Object.defineProperty(exports,"tc",{enumerable:!0,get:function(){return ks}}),Object.defineProperty(exports,"td",{enumerable:!0,get:function(){return ja}}),Object.defineProperty(exports,"tf",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(exports,"ti",{enumerable:!0,get:function(){return zu}}),Object.defineProperty(exports,"tl",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"tn",{enumerable:!0,get:function(){return SL}}),Object.defineProperty(exports,"to",{enumerable:!0,get:function(){return xs}}),Object.defineProperty(exports,"tr",{enumerable:!0,get:function(){return VT}}),Object.defineProperty(exports,"ts",{enumerable:!0,get:function(){return ua}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return vB}}),Object.defineProperty(exports,"tu",{enumerable:!0,get:function(){return sa}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return KV}}),Object.defineProperty(exports,"ua",{enumerable:!0,get:function(){return xr}}),Object.defineProperty(exports,"uc",{enumerable:!0,get:function(){return va}}),Object.defineProperty(exports,"ud",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"uf",{enumerable:!0,get:function(){return Bi}}),Object.defineProperty(exports,"ui",{enumerable:!0,get:function(){return Ou}}),Object.defineProperty(exports,"ul",{enumerable:!0,get:function(){return Ya}}),Object.defineProperty(exports,"un",{enumerable:!0,get:function(){return $O}}),Object.defineProperty(exports,"uo",{enumerable:!0,get:function(){return Do}}),Object.defineProperty(exports,"ur",{enumerable:!0,get:function(){return jx}}),Object.defineProperty(exports,"us",{enumerable:!0,get:function(){return Hn}}),Object.defineProperty(exports,"ut",{enumerable:!0,get:function(){return Vz}}),Object.defineProperty(exports,"uu",{enumerable:!0,get:function(){return aa}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return JV}}),Object.defineProperty(exports,"va",{enumerable:!0,get:function(){return gs}}),Object.defineProperty(exports,"vc",{enumerable:!0,get:function(){return Pa}}),Object.defineProperty(exports,"vd",{enumerable:!0,get:function(){return za}}),Object.defineProperty(exports,"vf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"vi",{enumerable:!0,get:function(){return hu}}),Object.defineProperty(exports,"vl",{enumerable:!0,get:function(){return Ei}}),Object.defineProperty(exports,"vn",{enumerable:!0,get:function(){return yO}}),Object.defineProperty(exports,"vo",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"vr",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"vs",{enumerable:!0,get:function(){return da}}),Object.defineProperty(exports,"vt",{enumerable:!0,get:function(){return VR}}),Object.defineProperty(exports,"vu",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return hV}}),Object.defineProperty(exports,"wa",{enumerable:!0,get:function(){return xa}}),Object.defineProperty(exports,"wc",{enumerable:!0,get:function(){return Na}}),Object.defineProperty(exports,"wd",{enumerable:!0,get:function(){return it}}),Object.defineProperty(exports,"wi",{enumerable:!0,get:function(){return Zl}}),Object.defineProperty(exports,"wl",{enumerable:!0,get:function(){return Xa}}),Object.defineProperty(exports,"wn",{enumerable:!0,get:function(){return hO}}),Object.defineProperty(exports,"wo",{enumerable:!0,get:function(){return No}}),Object.defineProperty(exports,"wr",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"ws",{enumerable:!0,get:function(){return Lo}}),Object.defineProperty(exports,"wt",{enumerable:!0,get:function(){return gR}}),Object.defineProperty(exports,"wu",{enumerable:!0,get:function(){return Qa}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return jV}}),Object.defineProperty(exports,"xa",{enumerable:!0,get:function(){return Yi}}),Object.defineProperty(exports,"xc",{enumerable:!0,get:function(){return Aa}}),Object.defineProperty(exports,"xd",{enumerable:!0,get:function(){return Bo}}),Object.defineProperty(exports,"xf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"xi",{enumerable:!0,get:function(){return cu}}),Object.defineProperty(exports,"xl",{enumerable:!0,get:function(){return Bs}}),Object.defineProperty(exports,"xn",{enumerable:!0,get:function(){return TO}}),Object.defineProperty(exports,"xo",{enumerable:!0,get:function(){return ai}}),Object.defineProperty(exports,"xr",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"xs",{enumerable:!0,get:function(){return ri}}),Object.defineProperty(exports,"xt",{enumerable:!0,get:function(){return LR}}),Object.defineProperty(exports,"xu",{enumerable:!0,get:function(){return Ar}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return DV}}),Object.defineProperty(exports,"ya",{enumerable:!0,get:function(){return $r}}),Object.defineProperty(exports,"yc",{enumerable:!0,get:function(){return Is}}),Object.defineProperty(exports,"yd",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,"yf",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"yi",{enumerable:!0,get:function(){return fu}}),Object.defineProperty(exports,"yl",{enumerable:!0,get:function(){return zo}}),Object.defineProperty(exports,"yn",{enumerable:!0,get:function(){return EO}}),Object.defineProperty(exports,"yo",{enumerable:!0,get:function(){return ma}}),Object.defineProperty(exports,"yr",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"ys",{enumerable:!0,get:function(){return Jn}}),Object.defineProperty(exports,"yt",{enumerable:!0,get:function(){return NR}}),Object.defineProperty(exports,"yu",{enumerable:!0,get:function(){return Ii}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return JB}}),Object.defineProperty(exports,"za",{enumerable:!0,get:function(){return fs}}),Object.defineProperty(exports,"zc",{enumerable:!0,get:function(){return St}}),Object.defineProperty(exports,"zd",{enumerable:!0,get:function(){return rc}}),Object.defineProperty(exports,"zi",{enumerable:!0,get:function(){return ll}}),Object.defineProperty(exports,"zl",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"zn",{enumerable:!0,get:function(){return TD}}),Object.defineProperty(exports,"zo",{enumerable:!0,get:function(){return Zn}}),Object.defineProperty(exports,"zr",{enumerable:!0,get:function(){return Ld}}),Object.defineProperty(exports,"zs",{enumerable:!0,get:function(){return Zi}}),Object.defineProperty(exports,"zt",{enumerable:!0,get:function(){return RL}}),Object.defineProperty(exports,"zu",{enumerable:!0,get:function(){return Wa}});
395
+ </html>`;return n.set(`content-type`,`text/html; charset=utf-8`),n.set(`cache-control`,`no-store`),n.set(`pragma`,`no-cache`),new Response(i,{status:200,headers:n})}function TB(e){if(!e)return;let[t,n]=e.split(` `);if(!(!t||t.toLowerCase()!==`bearer`))return n?.trim()||void 0}function EB(e){if(!e)return{};let[t,n]=e.split(` `);if(t?.toLowerCase()!==`basic`||!n)return{};try{let[e,t]=atob(n).split(`:`);return!e||!t?{}:{client_id:e,client_secret:t}}catch{return{}}}var DB=`urn:authhero:management`;function OB(e){return e===`/tenants`?!0:!e.startsWith(`/tenants/`)||/^\/tenants\/[^/]+\/(operations|config-sync)(\/|$)/.test(e)?!1:e!==`/tenants/settings`&&!e.startsWith(`/tenants/settings/`)}function kB(e){return e.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,`{$1}`)}function AB(e){let t=e.split(`:`);if(t.length!==2||!t[0]||!t[1])return[e];let n=`${t[1]}:${t[0]}`;return n===e?[e]:[e,n]}function jB(e,t={}){let n=t.requireManagementAudience??!1,r=t.relaxManagementAudience??!1,i=t.additionalManagementAudiences,a=t.additionalIssuers;return async(t,o)=>{let s=t.req.method===`HEAD`?`GET`:t.req.method,c=t.req.matchedRoutes.find(e=>e.method.toUpperCase()===s&&e.path!==`/*`);if(!c)return await o();let l=kB(c.path),u=l.startsWith(`/api/v2`)?l.slice(7)||`/`:l,d=e.openAPIRegistry.definitions.find(e=>`route`in e&&e.route.path===u&&e.route.method.toUpperCase()===s.toUpperCase());if(d&&`route`in d){let e=d.route.security?.[0]?.Bearer;if(e===void 0)return await o();let s=TB(t.req.header(`authorization`));if(!s)throw Fl.missingAuthentication();try{let o;if(a){let{payload:e}=(0,h.decode)(s);o=await a({tenant_id:typeof e?.tenant_id==`string`?e.tenant_id:void 0})}let c=await rO(t,s,{additionalIssuers:o});if(t.set(`user_id`,c.sub),t.set(`user`,c),c.azp&&(t.set(`client_id`,c.azp),t.set(`client_id_from_token`,!0)),c.org_name&&t.set(`org_name`,c.org_name),c.org_id&&t.set(`organization_id`,c.org_id),!t.var.tenant_id&&c.tenant_id&&t.set(`tenant_id`,c.tenant_id),n){let e=c.aud,n=Array.isArray(e)?e:e?[e]:[],a=typeof c.tenant_id==`string`?c.tenant_id:void 0,o=i?await i({tenant_id:a}):[],s=new Set([DB,...o]);if(!n.some(e=>s.has(e)))if(r)console.warn(`[authhero] management API accepted token without management audience (relaxManagementAudience=true): sub=${c.sub??`unknown`} aud=${JSON.stringify(e)}`);else throw new k(403,{message:`Invalid audience`});let l=typeof c.tenant_id==`string`?c.tenant_id:void 0,d=t.var.tenant_id;if(l&&d&&l!==d){let e=t.env.data?.multiTenancyConfig?.controlPlaneTenantId;if(!e||l!==e)throw new k(403,{message:`Cross-tenant management requires a control-plane token`});if(!await t.var.data.tenants.get(d).catch(e=>{throw new p.HTTPException(500,{message:`Failed to look up tenant`,cause:e})}))throw Nl.tenant()}let f=t.env.data?.multiTenancyConfig?.controlPlaneTenantId,m=typeof c.org_name==`string`?c.org_name:void 0,h=typeof c.org_id==`string`?c.org_id:void 0;if(f&&l===f&&d&&(m||h)){let e=m??(await t.env.data.organizations.get(f,h).catch(e=>{throw new p.HTTPException(500,{message:`Failed to look up organization`,cause:e})}))?.name,n=!!e&&e.toLowerCase()===d.toLowerCase(),r=d===f&&OB(u);if(r&&e&&!t.var.org_name&&t.set(`org_name`,e),!n&&(!r||!e))throw new k(403,{message:e?`This token is for another tenant's organization ("${e}"), not "${d}"`:`An organization token must belong to a tenant's organization`})}}let l=Array.isArray(c.permissions)?c.permissions:[],d=typeof c.scope==`string`?c.scope.split(` `):Array.isArray(c.scope)?c.scope:[];if(e.length){let t=e.flatMap(AB);if(!(t.some(e=>l.includes(e))||t.some(e=>d.includes(e))))throw Fl.insufficientScope(e)}}catch(e){throw e instanceof p.HTTPException?e:Fl.invalidToken()}}return await o()}}async function MB(e,t,n){if(n===`urn:authhero:management`)return!0;let r=e.env.additionalManagementAudiences;return r?(await r({tenant_id:t})).includes(n):!1}var NB=[`openid`,`profile`,`email`,`address`,`phone`,`offline_access`];async function PB(e,t,n,r){let i=[];if(!(await e.env.data.tenants.get(t))?.flags?.inherit_global_permissions_in_organizations)return[];let a=await e.env.data.userRoles.list(t,n,void 0,``),o=await Promise.all(a.map(n=>e.env.data.rolePermissions.list(t,n.id,{per_page:1e3})));for(let e of o)e.forEach(e=>{e.resource_server_identifier===r&&i.push(e.permission_name)});return[...new Set(i)]}var FB=`admin:organizations`,IB=`access:all_organizations`;async function LB(e,t,n,r){let i=new Set,a=e=>{for(let t of e)t.resource_server_identifier===`urn:authhero:management`&&r.includes(t.permission_name)&&i.add(t.permission_name)};if(a(await e.env.data.userPermissions.list(t,n,void 0,``)),i.size===r.length)return i;let o=await e.env.data.userRoles.list(t,n,void 0,``);for(let n of o)if(a(await e.env.data.rolePermissions.list(t,n.id,{per_page:1e3})),i.size===r.length)break;return i}async function RB(e,t,n,r){return(await LB(e,t,n,[r])).has(r)}async function zB(e,t,n,r){let i=(r===void 0?await e.env.data.tenants.get(t):r)?.flags?.inherit_global_permissions_in_organizations===!0,a=await LB(e,t,n,i?[IB,FB]:[IB]);return a.has(`access:all_organizations`)||i&&a.has(`admin:organizations`)}async function BB(e,t,n,r,i){return await zB(e,t,n,i)?!0:(await e.env.data.userOrganizations.list(t,{q:`user_id:${D(n)}`,per_page:1e3})).userOrganizations.some(e=>e.organization_id===r)}function VB(e){let t=e.granted.filter(t=>!e.definedScopes.includes(t));if(t.length===0)return;let n=e.userId?`, user_id=${e.userId}`:``;console.warn(`[scopes-permissions] Dropped scope(s) not defined on the resource server: ${t.join(`, `)} (source=${e.source}, tenant_id=${e.tenantId}, client_id=${e.clientId}, audience=${e.audience}${n})`)}async function HB(e,t){let{tenantId:n,audience:r,scopes:i}=t;if(i.length===0)return[];let{resource_servers:a}=await e.env.data.resourceServers.list(n),o=a.find(e=>e.identifier===r);if(!o)return[];let s=(o.scopes||[]).map(e=>e.value);return i.filter(e=>!s.includes(e))}async function UB(e,t){let{tenantId:n,clientId:r,audience:i,requestedScopes:a}=t,o=a.filter(e=>NB.includes(e)),s=a.filter(e=>!NB.includes(e)),c=(await e.env.data.resourceServers.list(n)).resource_servers.filter(e=>e.identifier===i);if(c.length===0)return{scopes:o,permissions:[],token_lifetime:86400,token_lifetime_for_web:7200};let l=c[0];if(!l)return{scopes:o,permissions:[],token_lifetime:86400,token_lifetime_for_web:7200};let u=l.options?.enforce_policies===!0,d=l.options?.token_dialect||`access_token`,f=(await e.env.data.clientGrants.list(n,{q:`client_id:${D(r)}`})).client_grants.find(e=>e.audience===i);if(!f)return{scopes:o,permissions:[],token_lifetime:l.token_lifetime,token_lifetime_for_web:l.token_lifetime_for_web};let p=f.scope||[],m=(l.scopes||[]).map(e=>e.value);if(s.length>0){let e=s.filter(e=>!p.includes(e));if(e.length>0)throw new k(403,{error:`access_denied`,error_description:`Client is not authorized for scope(s): ${e.join(`, `)}`})}let h=p.filter(e=>m.includes(e));VB({source:`client_grant`,tenantId:n,clientId:r,audience:i,granted:p,definedScopes:m});let g=a.length===0?h:s.filter(e=>h.includes(e)),_={token_lifetime:l.token_lifetime,token_lifetime_for_web:l.token_lifetime_for_web};if(!u)return{scopes:[...new Set([...o,...g])],permissions:[],..._};let v=g;return d===`access_token_authz`?{scopes:[...new Set([...o,...g])],permissions:v,..._}:{scopes:[...new Set([...o,...g])],permissions:[],..._}}async function WB(e,t){if(t.grantType===Wi.ClientCredential)return await UB(e,{tenantId:t.tenantId,clientId:t.clientId,audience:t.audience,requestedScopes:t.requestedScopes});let{tenantId:n,clientId:r,userId:i,audience:a,requestedScopes:o,organizationId:s}=t,c=await e.env.data.tenants.get(n),l=c?.flags?.restrict_undefined_scopes===!0;if(s&&!await BB(e,n,i,s,c))throw new k(403,{error:`access_denied`,error_description:`User is not a member of the specified organization`});let u=o.filter(e=>NB.includes(e)),d=(await e.env.data.resourceServers.list(n)).resource_servers.filter(e=>e.identifier===a)[0];if(!d){if(o.filter(e=>e&&!NB.includes(e)).length>0)throw new k(403,{error:`access_denied`,error_description:`Service not found: ${a}`});return{scopes:u,permissions:[],token_lifetime:86400,token_lifetime_for_web:7200}}let f=(d.scopes||[]).map(e=>e.value),p=await MB(e,n,a),m=d.options?.enforce_policies===!0||p,h=d.options?.token_dialect||`access_token`,g={token_lifetime:d.token_lifetime,token_lifetime_for_web:d.token_lifetime_for_web};if(!m){let e=l?o.filter(e=>f.includes(e)||NB.includes(e)):o;return{scopes:[...new Set(e)],permissions:[],...g}}let[_,v,y]=await Promise.all([e.env.data.userPermissions.list(n,i,void 0,s),e.env.data.userRoles.list(n,i,void 0,``),s?e.env.data.userRoles.list(n,i,void 0,s):Promise.resolve([])]),b=[...v,...y],x=s?await PB(e,n,i,a):[],S=await Promise.all(b.map(t=>e.env.data.rolePermissions.list(n,t.id,{per_page:1e3}))),ee=[];for(let e of S)e.forEach(e=>{e.resource_server_identifier===a&&ee.push(e.permission_name)});let te=new Set;_.forEach(e=>{e.resource_server_identifier===a&&te.add(e.permission_name)}),ee.forEach(e=>{te.add(e)}),x.forEach(e=>{te.add(e)});let ne=Array.from(te),re=ne.filter(e=>f.includes(e));VB({source:`user_permissions`,tenantId:n,clientId:r,audience:a,granted:ne,definedScopes:f,userId:i});let ie=l?[]:o.filter(e=>!f.includes(e)&&!NB.includes(e)&&(!p||te.has(e)));if(h===`access_token_authz`)return{scopes:[...new Set([...u,...ie])],permissions:re,...g};let ae=o.filter(e=>f.includes(e)&&ne.includes(e));return{scopes:[...new Set([...u,...ae,...ie])],permissions:[],...g}}var GB=new Set([`openid`,`profile`,`email`]);function KB(e,t){let n=new Set(t),r=[];for(let t of e)t&&(GB.has(t)||n.has(t)||r.push(t));return Array.from(new Set(r))}async function qB(e,t){if(!e.env.data.grants)return KB(t.requestedScopes,[]);let n=await e.env.data.grants.get(t.tenantId,t.userId,t.clientId);return KB(t.requestedScopes,n?.scope??[])}function JB(e,t){if(!e||!t||e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e.charCodeAt(r)^t.charCodeAt(r);return n===0}async function YB(e){return Is(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))}function XB(e){return e.replace(/[\s-]/g,``).toUpperCase()}function ZB(e){if(!e.deviceCodes)throw new k(503,{error:`temporarily_unavailable`,error_description:`Device authorization storage is not configured`});return e.deviceCodes}function QB(e){if(!e.grant_types?.some(e=>e===Wi.DeviceCode||e===`device_code`))throw new k(400,{error:`unauthorized_client`,error_description:`Device authorization is not enabled for this client`})}function $B(e,t,n,r=!1){let i=t.token_endpoint_auth_method??(t.app_type===`native`||t.app_type===`spa`?`none`:`client_secret_post`);if(!e.var.client_authenticated_via_assertion&&!(i===`none`&&n===void 0)&&!((i===`client_secret_basic`&&r||i===`client_secret_post`&&!r)&&n&&JB(t.client_secret,n)))throw new k(401,{error:`invalid_client`,error_description:`Client authentication failed`})}async function eV(e,t,n,r,i=e.var.ip||`unknown`){let a=300*1e3,o=Math.floor(Date.now()/a),s=`${n}:${await YB(i)}:${o}`;if(await ZB(e.env.data).incrementAttempts(t,s,new Date((o+1)*a).toISOString())>r)throw new k(429,{error:`slow_down`,error_description:`Too many device authorization attempts. Try again later.`})}function tV(e){return Pm(e.state_data).deviceFlow}function nV(e){return!!Pm(e).deviceFlow?.deviceCodeHash}function rV(e){return`__Host-authhero_device_${e}`}function iV(e){return(0,Sd.serialize)(rV(e.id),e.csrf_token,{httpOnly:!0,secure:!0,sameSite:`lax`,path:`/`,maxAge:600})}function aV(e,t){let n=(0,Sd.parse)(e.req.header(`cookie`)||``)[rV(t.id)];if(!n||!JB(t.csrf_token,n))throw new k(403,{error:`access_denied`,error_description:`Start device activation again in this browser`})}function oV(e){if(!e)return!1;try{return!!JSON.parse(e)?.connect}catch{return!1}}function sV(e,t){switch(t){case`email`:return e.email||void 0;case`email_verified`:return e.email_verified===void 0?void 0:e.email_verified;case`name`:return e.name||void 0;case`family_name`:return e.family_name||void 0;case`given_name`:return e.given_name||void 0;case`middle_name`:return e.middle_name||void 0;case`nickname`:return e.nickname||void 0;case`preferred_username`:return e.preferred_username||e.username||void 0;case`profile`:return e.profile||void 0;case`picture`:return e.picture||void 0;case`website`:return e.website||void 0;case`gender`:return e.gender||void 0;case`birthdate`:return e.birthdate||void 0;case`zoneinfo`:return e.zoneinfo||void 0;case`locale`:return e.locale||void 0;case`updated_at`:{if(!e.updated_at)return;let t=new Date(e.updated_at).getTime();return Number.isFinite(t)?Math.floor(t/1e3):void 0}case`address`:return e.address||void 0;case`phone_number`:return e.phone_number||void 0;case`phone_number_verified`:return e.phone_verified===void 0?void 0:e.phone_verified;default:return}}var cV={email:[`email`,`email_verified`],profile:[`name`,`family_name`,`given_name`,`middle_name`,`nickname`,`preferred_username`,`profile`,`picture`,`website`,`gender`,`birthdate`,`zoneinfo`,`locale`,`updated_at`],address:[`address`],phone:[`phone_number`,`phone_number_verified`]};function lV(e,t){let n={};for(let r of t){let t=cV[r];if(t)for(let r of t){let t=sV(e,r);t!==void 0&&(n[r]=t)}}return n}function uV(e,t){let n={};for(let r of t){let t=sV(e,r);t!==void 0&&(n[r]=t)}return n}var dV=[`1F77B4`,`FF7F0E`,`2CA02C`,`D62728`,`9467BD`,`8C564B`,`E377C2`,`17BECF`,`BCBD22`,`7F7F7F`];function fV(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)}function pV(e){return e.email||e.name||e.user_id||`?`}function mV(e){return dV[fV(e.length>0?e:`?`)%dV.length]??`7F7F7F`}function hV(e){return e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])/g,``).replace(/(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,``)}function gV(e){let t=hV(e.name?.trim()||`${e.given_name??``} ${e.family_name??``}`.trim()||e.nickname?.trim()||e.email?.trim()||e.username?.trim()||``).split(/\s+/).filter(Boolean),n=t[0];if(!n)return`?`;if(t.length===1)return[...n].slice(0,2).join(``).toUpperCase()||`?`;let r=t[t.length-1]??n;return`${[...n][0]??``}${[...r][0]??``}`.toUpperCase()||`?`}function _V(e,t){return`${e.endsWith(`/`)?e:`${e}/`}${t}`}function vV(e,t){let n=gV(t),r=mV(pV(t));return _V(e,`avatars/${encodeURIComponent(n)}.svg?bg=${r}`)}function yV(e,t){return e.picture?e:{...e,picture:vV(t,e)}}function bV(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&apos;`)}function xV(e,t){let n=/^[0-9a-fA-F]{6}$/.test(t)?`#${t}`:`#7F7F7F`,r=bV([...hV(e)].slice(0,2).join(``).toUpperCase())||`?`;return[`<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120" role="img">`,`<rect width="120" height="120" fill="${n}"/>`,`<text x="50%" y="50%" dy=".05em" fill="#ffffff" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif" font-size="52" font-weight="600" text-anchor="middle" dominant-baseline="central">${r}</text>`,`</svg>`].join(``)}var SV=3600*1e3;function CV(e,t=Date.now()){let n=e.used_at??e.created_at,r=n?new Date(n).getTime():NaN;return Number.isFinite(r)?t-r>=SV:!0}function wV(e,t,n,r){let i=Date.now(),a=()=>e.env.data.sessions.update(t,n,{used_at:new Date(i).toISOString()});if(r){if(!CV(r,i))return;Uc(e,a().catch(()=>{}));return}Uc(e,(async()=>{let r=await e.env.data.sessions.get(t,n);!r||r.revoked_at||CV(r,i)&&await a()})().catch(()=>{}))}function TV(e,t){Object.keys(t).forEach(n=>{let r=t[n];r!=null&&r.length&&e.searchParams.set(n,r)})}function EV(e){try{let t=typeof e==`string`?new URL(e):e,n=`${t.protocol}//${t.host}${t.pathname}`;if(t.search){let e=Array.from(t.searchParams.keys()).map(e=>`${e}=[REDACTED]`).join(`&`);n+=`?${e}`}return t.hash&&(n+=`#[REDACTED]`),n}catch{let t=(typeof e==`string`?e:e.toString()).match(/^([^?#]*)(\?[^#]*)?(#.*)?$/);if(!t)return`[invalid-url]`;let[,n=``,r,i]=t,a=n;if(r){let e=r.substring(1).split(`&`).map(e=>{let[t]=e.split(`=`);return`${t}=[REDACTED]`}).join(`&`);a+=`?${e}`}return i&&(a+=`#[REDACTED]`),a}}var DV=3600;function OV(e){return!e||e<=0?{kind:`unset`}:{kind:`seconds`,seconds:e*DV}}function kV(e){if(!(e===void 0||e<=0))return{kind:`seconds`,seconds:e}}function AV(e){let t=e.refresh_token;return t?.expiration_type===`non-expiring`||t?.infinite_token_lifetime?{kind:`infinite`}:kV(t?.token_lifetime)??OV(e.tenant.session_lifetime)}function jV(e){let t=e.refresh_token;return t?.expiration_type===`non-expiring`||t?.infinite_idle_token_lifetime?{kind:`infinite`}:kV(t?.idle_token_lifetime)??OV(e.tenant.idle_session_lifetime)}function MV(e,t=Date.now()){if(e.kind===`seconds`)return new Date(t+e.seconds*1e3).toISOString()}function NV(e,t=Date.now()){return{expires_at:MV(AV(e),t),idle_expires_at:MV(jV(e),t)}}function PV(e,t,n=Date.now()){let r=jV(e);if(r.kind!==`infinite`)return r.kind===`unset`||!t?t:MV(r,n)}function FV(e,t,n=Date.now()){let r={};if(t.expires_at&&AV(e).kind===`infinite`&&(r.expires_at=null),t.idle_expires_at){let t=jV(e);t.kind===`infinite`?r.idle_expires_at=null:t.kind===`seconds`&&(r.idle_expires_at=MV(t,n))}return r}function IV(e){switch(e){case Wi.DeviceCode:return E.FAILED_EXCHANGE_DEVICE_CODE_FOR_ACCESS_TOKEN;case Wi.AuthorizationCode:return E.FAILED_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN;case Wi.ClientCredential:return E.FAILED_EXCHANGE_ACCESS_TOKEN_FOR_CLIENT_CREDENTIALS;case Wi.RefreshToken:return E.FAILED_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN;case Wi.OTP:return E.FAILED_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN;case Wi.Password:return E.FAILED_EXCHANGE_PASSWORD_FOR_ACCESS_TOKEN;case Wi.Passwordless:return E.FAILED_EXCHANGE_PASSWORDLESS_OTP_FOR_ACCESS_TOKEN;case Wi.TokenExchange:return E.FAILED_EXCHANGE_SUBJECT_TOKEN_FOR_ACCESS_TOKEN;default:return E.FAILED_EXCHANGE_CUSTOM_TOKEN}}function LV(e,t,n,r,i=`onExecuteCredentialsExchange`){return{accessToken:{setCustomClaim:(n,r)=>{uO(t,n,r,{kind:`access_token`,source:i,ctx:e})}},idToken:{setCustomClaim:(t,r)=>{n&&uO(n,t,r,{kind:`id_token`,source:i,ctx:e})}},access:{deny:(t,n)=>{let i=n?`${t} - ${n}`:t;throw O(e,e.var.tenant_id||``,{type:IV(r),description:`Access denied by credentials-exchange hook: ${i}`}),new k(400,{message:`Access denied: ${i}`})}},token:{createServiceToken:async t=>(await gO(e,e.var.tenant_id,t.scope,t.expiresInSeconds,t.customClaims)).access_token}}}function RV(e){if(!e?.state_data)return;let t=Pm(e.state_data);return t.mfa_verified&&t.mfa_method?[`mfa`]:void 0}async function zV(e,t){let{authParams:n,user:r,client:i,session_id:a,organization:o,permissions:s,impersonatingUser:c,actClient:l,grantType:u}=t;if(r?.blocked)throw new k(403,{error:`access_denied`,error_description:`User is blocked`});let d=(()=>{if(c&&l)return{sub:c.user_id,client_id:l.client_id};if(c)return{sub:c.user_id};if(l)return{sub:l.client_id,client_id:l.client_id}})(),f=t.amr??(r&&t.loginSession?.user_id===r.user_id?RV(t.loginSession):void 0),m=t.auth_time,h=n.prompt?.split(` `)??[],g=n.max_age!==void 0||h.includes(`login`)||n.claims?.id_token?.auth_time?.essential===!0;if(m===void 0&&g){if(t.loginSession?.authenticated_at)m=Math.floor(new Date(t.loginSession.authenticated_at).getTime()/1e3);else if(a&&e.var.tenant_id){let t=await e.env.data.sessions.get(e.var.tenant_id,a);t?.authenticated_at&&(m=Math.floor(new Date(t.authenticated_at).getTime()/1e3))}}let _=e.var.tenant_id,v=(await VD(e.env.data.keys,_??``,_?e.env.signingKeyMode:`control-plane`,{purpose:`sign`}))[0];if(!v?.pkcs7||!v.cert)throw new k(500,{message:`No signing key configured for ${_?`tenant "${_}"`:`the control-plane scope`}: found ${(await VD(e.env.data.keys,_??``,_?e.env.signingKeyMode:`control-plane`,{purpose:`publish`})).length} verify key(s) but none with private material to sign tokens.`});let y=aD(v.pkcs7),b=await iD(v.cert),x=Cc(e.env,e.var.custom_domain),S=n.audience??i.tenant.default_audience??`${x}userinfo`,ee=n.claims?.userinfo?Object.keys(n.claims.userinfo):void 0,te=dO(t.customClaims,{kind:`access_token`,source:`createAuthTokens(customClaims)`,ctx:e}),ne={aud:S,scope:n.scope||``,sub:r?.user_id||n.client_id,iss:x,tenant_id:i.tenant.id,sid:a,act:d,org_id:o?o.id:void 0,requested_userinfo_claims:ee,org_name:o&&i.tenant.allow_organization_name_in_authentication_api?o.name.toLowerCase():void 0,permissions:s,...te},re=n.scope?.split(` `)||[],ie=re.includes(`openid`);if(!f&&r&&ie&&a&&e.var.tenant_id){let t=await e.env.data.sessions.get(e.var.tenant_id,a);t&&lB(t,r.user_id)&&(f=[`mfa`])}let ae=(n.response_type??``).trim()===kt.ID_TOKEN,oe=i.auth0_conformant!==!1||ae,se={aud:n.client_id,sub:r?.user_id,iss:x,sid:a,nonce:n.nonce,...m===void 0?{}:{auth_time:m},...f?{amr:f}:{},...n.acr_values?{acr:n.acr_values.split(` `)[0]}:{}},ce={act:d,org_id:o?.id,org_name:o?.name.toLowerCase()},le=r&&ie?{...se,...oe?lV(yV(r,x),re):{},...n.claims?.id_token?uV(yV(r,x),Object.keys(n.claims.id_token)):{},...ae&&n.claims?.userinfo?uV(yV(r,x),Object.keys(n.claims.userinfo)):{},...ce}:void 0,ue=Kc({loginSession:t.loginSession,authConnection:t.authConnection,ctxConnection:e.var.connection,user:r}),de=await qc(e,e.var.tenant_id,ue,r);if(r&&u!==Wi.RefreshToken){let n=e.var.post_login_action_claims??Pm(t.loginSession?.state_data).action_claims;if(n?.user_id===r.user_id){for(let[t,r]of Object.entries(n.access_token??{}))uO(ne,t,r,{kind:`access_token`,source:`post-login-code-hook`,ctx:e});if(le)for(let[t,r]of Object.entries(n.id_token??{}))uO(le,t,r,{kind:`id_token`,source:`post-login-code-hook`,ctx:e})}}e.env.hooks?.onExecuteCredentialsExchange&&await e.env.hooks.onExecuteCredentialsExchange({ctx:e,client:i,user:r,request:{ip:e.var.ip||``,user_agent:e.var.useragent||``,method:e.req.method,url:ll(e.req.url)},scope:n.scope||``,grant_type:u??``,organization:o,connection:de||(ue?{id:ue,name:ue,strategy:r?.provider||`auth0`}:void 0)},LV(e,ne,le,u));{let{hooks:t}=await e.env.data.hooks.list(e.var.tenant_id),a=t.filter(e=>e.trigger_id===`credentials-exchange`&&e.enabled&&fz(e));if(r){for(let t of a)if(fz(t))try{await gz(e,t.template_id,r,LV(e,ne,le,u,`template-hook:${t.template_id}`))}catch(e){if(e instanceof p.HTTPException)throw e;console.warn(`[credentials-exchange] Failed to execute template hook: ${t.template_id}`,e)}}let s=LV(e,ne,le,u,`credentials-exchange-code-hook`),c=await RR(e,t,{ctx:e,client:i,user:r,request:{ip:e.var.ip||``,user_agent:e.var.useragent||``,method:e.req?.method||``,url:ll(e.req?.url||``)},scope:n.scope||``,grant_type:u??``,organization:o,connection:de||(ue?{id:ue,name:ue,strategy:r?.provider||`auth0`}:void 0)},s);c&&e.set(`action_execution_id`,c)}let fe=c?3600:t.token_lifetime??86400,pe={includeIssuedTimestamp:!0,expiresInSeconds:fe,headers:{kid:v.kid}},C=await $D(b,y,ne,pe);if(le){let e=(n.response_type??``).split(` `);t.code&&e.includes(`code`)&&(le.c_hash=await rk(t.code,b)),e.includes(`id_token`)&&e.includes(`token`)&&(le.at_hash=await rk(C,b))}let me=le?await $D(b,y,le,pe):void 0;return{access_token:C,refresh_token:t.refresh_token,id_token:me,token_type:`Bearer`,expires_in:fe}}async function BV(e,t){return{code:(await e.env.data.codes.create(t.client.tenant.id,{code_id:Yl(32),user_id:t.user.user_id,code_type:`authorization_code`,login_id:t.login_id,expires_at:new Date(Date.now()+300*1e3).toISOString(),code_challenge:t.authParams.code_challenge,code_challenge_method:t.authParams.code_challenge_method,redirect_uri:t.authParams.redirect_uri,state:t.authParams.state,nonce:t.authParams.nonce})).code_id,state:t.authParams.state}}function VV(e){if(e)return new Date(Date.now()+e*60*60*1e3).toISOString()}function HV(e,t){return t?e&&Date.parse(e)<=Date.parse(t)?e:t:e}async function UV(e,t){let{client:n,scope:r,login_id:i}=t,a=Cc(e.env,e.var.custom_domain),o=t.audience??n.tenant.default_audience??`${a}userinfo`,{expires_at:s,idle_expires_at:c}=NV(n),l=PO(),{lookup:u,secret:d}=ZO(),f=await QO(d),p=n.refresh_token?.rotation_type===`rotating`;return{row:await e.env.data.refreshTokens.create(n.tenant.id,{id:l,login_id:i,session_id:t.session_id,organization:t.organization,auth_connection:t.auth_connection,auth_strategy:t.auth_strategy,client_id:n.client_id,idle_expires_at:c?HV(c,t.max_expires_at):void 0,expires_at:HV(s,t.max_expires_at),session_transfer:t.session_transfer,user_id:t.user.user_id,device:{last_ip:e.var.ip,initial_ip:e.var.ip,last_user_agent:e.var.useragent||``,initial_user_agent:e.var.useragent||``,initial_asn:``,last_asn:``},resource_servers:[{audience:o,scopes:r}],rotating:p,token_lookup:u,token_hash:f,family_id:l}),wireToken:$O(u,d)}}async function WV(e,{user:t,client:n,loginSession:r}){let i=VV(n.tenant.idle_session_lifetime),a=VV(n.tenant.session_lifetime);return await e.env.data.sessions.create(n.tenant.id,{id:PO(),user_id:t.user_id,login_session_id:r.id,idle_expires_at:i,expires_at:a,device:{last_ip:e.var.ip||``,initial_ip:e.var.ip||``,last_user_agent:e.var.useragent||``,initial_user_agent:e.var.useragent||``,initial_asn:``,last_asn:``},clients:[n.client_id]})}async function GV(e,{user:t,client:n,loginSession:r,existingSessionId:i,authConnection:a,authStrategy:o}){let s=await e.env.data.loginSessions.get(n.tenant.id,r.id);if(!s)throw new p.HTTPException(400,{message:`Login session ${r.id} not found`});let c=s.state||T.PENDING;if(c===T.FAILED)throw new k(400,{error:`access_denied`,error_description:s.failure_reason||`Cannot authenticate login session in failed state`});if(c===T.COMPLETED)throw new k(400,{error:`access_denied`,error_description:`Login session has already been completed`});if(c===T.AUTHENTICATED){if(s.session_id)return s.session_id;throw new p.HTTPException(500,{message:`Login session is authenticated but has no session_id`})}let l,u;if(i){let a=await e.env.data.sessions.get(n.tenant.id,i);if(!a||a.revoked_at){let i=await WV(e,{user:t,client:n,loginSession:r});l=i.id,u=i.authenticated_at}else l=i,u=a.authenticated_at,a.clients.includes(n.client_id)?wV(e,n.tenant.id,i,a):await e.env.data.sessions.update(n.tenant.id,i,{clients:[...a.clients,n.client_id],...CV(a)&&{used_at:new Date().toISOString()}})}else{let i=await WV(e,{user:t,client:n,loginSession:r});l=i.id,u=i.authenticated_at}let{state:d}=Lm(c===T.EXPIRED?T.PENDING:c,{type:j.AUTHENTICATE,userId:t.user_id}),f=Kc({authConnection:a,ctxConnection:e.var.connection});return await e.env.data.loginSessions.update(n.tenant.id,r.id,{session_id:l,state:d,user_id:t.user_id,authenticated_at:u,...f?{auth_connection:f}:{},...o?{auth_strategy:o}:{},...c===T.EXPIRED?{expires_at:new Date(Date.now()+ld*1e3).toISOString()}:{}}),l}async function KV(e,t){let{user:n,client:r,loginSession:i,authStrategy:a,authConnection:o}=t;await GV(e,{user:n,client:r,loginSession:i,existingSessionId:t.existingSessionId,authConnection:o,authStrategy:a});let s=`/authorize/resume?state=${encodeURIComponent(i.id)}`,c=s,l=!1;if(i.authorization_url)try{let t=new URL(i.authorization_url),n=e.var.host||``;t.host&&t.host!==n&&(c=`${t.origin}${s}`,l=!0)}catch{}let u=new Headers({location:c});return l&&u.set(xs,`1`),new Response(null,{status:302,headers:u})}async function qV(e,t,n,r){let i=await e.env.data.loginSessions.get(t,n.id);if(!i){console.warn(`Login session ${n.id} not found when trying to mark as failed`);return}let a=i.state||T.PENDING,{state:o,context:s}=Lm(a,{type:j.FAIL,reason:r});o!==a&&await e.env.data.loginSessions.update(t,n.id,{state:o,failure_reason:s.failureReason})}async function JV(e,t,n,r){let i=await e.env.data.loginSessions.get(t,n.id);if(!i){console.warn(`Login session ${n.id} not found when trying to start hook`);return}let a=i.state||T.PENDING,{state:o,context:s}=Lm(a,{type:j.START_HOOK,hookId:r});o!==a&&await TO(e.env.data.loginSessions,t,n.id,{type:j.UPDATE_CONTEXT,data:{hookId:s.hookId}},{state:o})}async function YV(e,t,n){let r=await e.env.data.loginSessions.get(t,n.id);if(!r){console.warn(`Login session ${n.id} not found when trying to complete hook`);return}let i=r.state||T.PENDING,{state:a}=Lm(i,{type:j.COMPLETE_HOOK});a!==i&&await TO(e.env.data.loginSessions,t,n.id,{type:j.UPDATE_CONTEXT,data:{hookId:void 0,form_values:void 0}},{state:a})}async function XV(e,t,n,r,i){let a=i??await e.env.data.loginSessions.get(t,n.id);if(!a){console.warn(`Login session ${n.id} not found when trying to mark as completed`);return}let o=a.state||T.PENDING,{state:s}=Lm(o,{type:j.COMPLETE});s!==o&&await e.env.data.loginSessions.update(t,n.id,{state:s,...r?{auth_connection:r}:{}})}async function ZV(e,t,n,r,i){let a=await e.env.data.loginSessions.get(t,n.id);if(!a){console.warn(`Login session ${n.id} not found when trying to start continuation`);return}let o=a.state||T.PENDING,{state:s}=Lm(o,{type:j.START_CONTINUATION,scope:r});s===o?console.warn(`Failed to start continuation for login session ${n.id}: cannot transition from ${o} to AWAITING_CONTINUATION. Scope: ${JSON.stringify(r)}, Return URL: ${EV(i)}`):await TO(e.env.data.loginSessions,t,n.id,{type:j.UPDATE_CONTEXT,data:{continuationScope:r,continuationReturnUrl:i}},{state:s})}async function QV(e,t,n){let r=await e.env.data.loginSessions.get(t,n.id);if(!r){console.warn(`Login session ${n.id} not found when trying to complete continuation`);return}let i=Pm(r.state_data).continuationReturnUrl,a=r.state||T.PENDING,{state:o}=Lm(a,{type:j.COMPLETE_CONTINUATION});return o===a?console.warn(`completeLoginSessionContinuation: State transition from ${a} with COMPLETE_CONTINUATION was invalid or no-op`):await TO(e.env.data.loginSessions,t,n.id,{type:j.UPDATE_CONTEXT,data:{continuationScope:void 0,continuationReturnUrl:void 0}},{state:o}),i}function $V(e){if(!e.state_data)return null;try{return JSON.parse(e.state_data).continuationScope||null}catch{return null}}function eH(e,t){if(e.state!==T.AWAITING_CONTINUATION||!(Date.parse(e.expires_at)>Date.now()))return!1;let n=$V(e);return n?n.includes(t):!1}async function tH(e,t){let{authParams:n,client:r,ticketAuth:i}=t,{user:a}=t,o=n.response_type||kt.CODE,s=n.response_mode||At.QUERY;if(i){if(!t.loginSession)throw new k(500,{message:`Login session not found for ticket auth.`});a&&!t.skipHooks&&(t.authStrategy&&a.app_metadata?.strategy!==t.authStrategy.strategy&&(a.app_metadata={...a.app_metadata,strategy:t.authStrategy.strategy},await e.env.data.users.update(r.tenant.id,a.user_id,{app_metadata:{...a.app_metadata||{},strategy:t.authStrategy.strategy}})),await vB(e,e.env.data,r.tenant.id,a,t.loginSession,{client:r,authParams:n,authStrategy:t.authStrategy,authConnection:t.authConnection}));let i=oD(),o=Yl(12),s=await e.env.data.codes.create(r.tenant.id,{code_id:Yl(32),code_type:`ticket`,login_id:t.loginSession.id,user_id:a?.user_id,expires_at:new Date(Date.now()+gd).toISOString(),code_verifier:[o,i].join(`|`),redirect_uri:n.redirect_uri,state:n.state,nonce:n.nonce});return e.json({login_ticket:s.code_id,co_verifier:i,co_id:o})}let c=t.refreshToken,l;if(!t.loginSession)throw new k(500,{message:`loginSession must be provided for front-channel auth responses.`});let u=await e.env.data.loginSessions.get(r.tenant.id,t.loginSession.id);if(!u)throw new k(500,{message:`Login session not found.`});let d=u.state||T.PENDING;if(d===T.COMPLETED)throw new k(400,{error:`invalid_request`,error_description:`Login session has already been completed`});if(d===T.FAILED)throw new k(400,{error:`access_denied`,error_description:`Login session failed: ${u.failure_reason||`unknown reason`}`});if(d===T.PENDING||d===T.EXPIRED){l=await GV(e,{user:a,client:r,loginSession:t.loginSession,existingSessionId:t.existingSessionIdToLink,authConnection:t.authConnection,authStrategy:t.authStrategy});let n=await e.env.data.loginSessions.get(r.tenant.id,t.loginSession.id);n&&(u=n)}else if(l=u.session_id,!l)throw new k(500,{message:`Login session in ${d} state but has no session_id`});let f=!!Pm(u.state_data).mfa_required_by_action,m=t.skipHooks||f;if(f&&a&&(a=await Hu(e.env.data.users,r.tenant.id,a),u.user_id!==a.user_id&&(await e.env.data.loginSessions.update(r.tenant.id,u.id,{user_id:a.user_id}),u={...u,user_id:a.user_id})),t.loginSession&&a){let i=u.state||T.PENDING,o={};if(u.state_data)try{o=JSON.parse(u.state_data)}catch{console.error(`Failed to parse state_data for login session`,u.id)}if(i===T.AWAITING_MFA){let n=`/u2/mfa/login-options`;if(o.authenticationMethodId){let t=(await e.env.data.authenticationMethods.list(r.tenant.id,a.user_id)).find(e=>e.id===o.authenticationMethodId);t?.confirmed&&t.type===`phone`?n=`/u2/mfa/phone-challenge`:t?.confirmed&&t.type===`totp`?n=`/u2/mfa/totp-challenge`:t?.confirmed&&(t.type===`passkey`||t.type===`webauthn-roaming`||t.type===`webauthn-platform`)?n=`/u2/passkey/challenge`:t?.type===`totp`?n=`/u2/mfa/totp-enrollment`:t?.type===`phone`&&(n=`/u2/mfa/phone-enrollment`)}return new Response(null,{status:302,headers:{location:`${n}?state=${encodeURIComponent(t.loginSession.id)}`}})}if(i===T.AUTHENTICATED&&o.mfa_verified===!0&&l)try{let t=await e.env.data.sessions.get(r.tenant.id,l),n=typeof o.mfa_verified_at==`string`?o.mfa_verified_at:void 0;t&&!t.revoked_at&&t.user_id===a.user_id&&(n||!cB(t))&&await uB(e.env.data.sessions,r.tenant.id,t,{type:typeof o.mfa_method==`string`?o.mfa_method:void 0,timestamp:n??new Date().toISOString()})}catch(e){console.error(`Failed to record MFA completion on session`,e)}if(i===T.AUTHENTICATED&&!o.mfa_verified){let{checkMfaRequired:n,sendMfaOtp:i}=await Promise.resolve().then(()=>require("./mfa-Bo75sbdf.js")).then(e=>e.i),{isBrowserRememberedForMfa:s}=await Promise.resolve().then(()=>require("./authhero.cjs")).then(e=>e.t),c=await n(e,r.tenant.id,a.user_id,{force:!!o.mfa_required_by_action}),d=c.required&&l?await e.env.data.sessions.get(r.tenant.id,l).then(e=>e?lB(e,a.user_id):!1):!1,f=c.required&&c.enrolled&&!d?await s(e,{tenant:r.tenant,userId:a.user_id,actionRequest:Pm(u.state_data).mfa_required_by_action}):!1;if(c.required&&!d&&!f){let{state:n}=Lm(T.AUTHENTICATED,{type:j.REQUIRE_MFA});if(c.enrolled){if(c.allEnrollments.length>1)return await e.env.data.loginSessions.update(r.tenant.id,t.loginSession.id,{state:n}),new Response(null,{status:302,headers:{location:`/u2/mfa/login-options?state=${encodeURIComponent(t.loginSession.id)}`}});if(await TO(e.env.data.loginSessions,r.tenant.id,t.loginSession.id,{type:j.UPDATE_CONTEXT,data:{authenticationMethodId:c.enrollment.id}},{state:n}),c.enrollment.type===`totp`)return new Response(null,{status:302,headers:{location:`/u2/mfa/totp-challenge?state=${encodeURIComponent(t.loginSession.id)}`}});if(c.enrollment.type===`passkey`||c.enrollment.type===`webauthn-roaming`||c.enrollment.type===`webauthn-platform`)return new Response(null,{status:302,headers:{location:`/u2/passkey/challenge?state=${encodeURIComponent(t.loginSession.id)}`}});if(!c.enrollment.phone_number)throw Error(`MFA enrollment is missing phone_number`);let{MfaSmsRateLimitError:a}=await Promise.resolve().then(()=>rH);try{await i(e,r,t.loginSession,c.enrollment.phone_number)}catch(e){if(!(e instanceof a))throw e}return new Response(null,{status:302,headers:{location:`/u2/mfa/phone-challenge?state=${encodeURIComponent(t.loginSession.id)}`}})}else{let i=r.tenant,a=i.mfa?.factors?.otp===!0,o=i.mfa?.factors?.sms===!0,s=i.mfa?.factors?.webauthn_roaming===!0||i.mfa?.factors?.webauthn_platform===!0;return await e.env.data.loginSessions.update(r.tenant.id,t.loginSession.id,{state:n}),+!!a+ +!!o+ +!!s>1?new Response(null,{status:302,headers:{location:`/u2/mfa/login-options?state=${encodeURIComponent(t.loginSession.id)}`}}):a?new Response(null,{status:302,headers:{location:`/u2/mfa/totp-enrollment?state=${encodeURIComponent(t.loginSession.id)}`}}):s?new Response(null,{status:302,headers:{location:`/u2/passkey/enrollment?state=${encodeURIComponent(t.loginSession.id)}`}}):new Response(null,{status:302,headers:{location:`/u2/mfa/phone-enrollment?state=${encodeURIComponent(t.loginSession.id)}`}})}}}if(o.mfa_required_by_action&&!o.mfa_verified&&!(l&&await e.env.data.sessions.get(r.tenant.id,l).then(e=>e?lB(e,a.user_id):!1))&&!await Promise.resolve().then(()=>require("./authhero.cjs")).then(e=>e.t).then(({isBrowserRememberedForMfa:t})=>t(e,{tenant:r.tenant,userId:a.user_id,actionRequest:Pm(u.state_data).mfa_required_by_action})))throw new k(403,{error:`access_denied`,error_description:`Multi-factor authentication is required to complete this login`});if(l&&nV(u.state_data)){if(!tV(u)?.ready&&!m){let i=await vB(e,e.env.data,r.tenant.id,a,u,{client:r,authParams:{...n,grant_type:Wi.DeviceCode},authStrategy:t.authStrategy,authConnection:t.authConnection});if(i instanceof Response)return i}await TO(e.env.data.loginSessions,r.tenant.id,u.id,{type:j.UPDATE_CONTEXT,data:{deviceFlow:{...tV(u),ready:!0}}});let i=new Headers({location:`/u2/device/confirmation?state=${encodeURIComponent(u.id)}`});return Ld(r.tenant.id,l,e.var.host||``).forEach(e=>i.append(`set-cookie`,e)),new Response(null,{status:302,headers:i})}if(l&&oV(u.state_data)){let n=new Headers;return Ld(r.tenant.id,l,e.var.host||``).forEach(e=>n.append(`set-cookie`,e)),n.set(`location`,`/u2/connect/start?state=${encodeURIComponent(t.loginSession.id)}`),new Response(null,{status:302,headers:n})}}if(t.loginSession&&a&&!r.is_first_party&&s!==At.WEB_MESSAGE){let n=u.state||T.PENDING;if(n===T.AWAITING_CONSENT)return new Response(null,{status:302,headers:{location:`/u2/consent?state=${encodeURIComponent(t.loginSession.id)}`}});if(n===T.AUTHENTICATED){let n=u.authParams.scope?.split(` `).filter(Boolean)??[];if((await qB(e,{tenantId:r.tenant.id,userId:a.user_id,clientId:r.client_id,requestedScopes:n})).length>0){let{state:n}=Lm(T.AUTHENTICATED,{type:j.REQUIRE_CONSENT});return await e.env.data.loginSessions.update(r.tenant.id,t.loginSession.id,{state:n}),new Response(null,{status:302,headers:{location:`/u2/consent?state=${encodeURIComponent(t.loginSession.id)}`}})}}}if(t.loginSession&&a&&s!==At.WEB_MESSAGE){let n=u.state||T.PENDING,i={};if(u.state_data)try{i=JSON.parse(u.state_data)}catch{}if(n===T.AUTHENTICATED&&!i.passkey_nudge_completed){let{checkPasskeyNudgeRequired:n}=await Promise.resolve().then(()=>require("./passkey-enrollment-B0D65nrS.js"));if((await n(e,r.tenant.id,a.user_id,u.auth_connection)).show)return await ZV(e,r.tenant.id,u,[`passkey-enrollment`],`/u2/continue?state=${encodeURIComponent(t.loginSession.id)}`),new Response(null,{status:302,headers:{location:`/u2/passkey/enrollment-nudge?state=${encodeURIComponent(t.loginSession.id)}`}})}}let h=o.split(` `).includes(`code`);if(!c&&n.scope?.split(` `).includes(`offline_access`)&&o!==kt.TOKEN&&!h&&!t.impersonatingUser){let i=JO(r,l?await e.env.data.sessions.get(r.tenant.id,l):null);i.allowed&&(c=(await UV(e,{user:a,client:r,login_id:t.loginSession?.id||``,session_id:l,organization:n.organization,auth_connection:u.auth_connection,auth_strategy:u.auth_strategy,scope:n.scope,audience:n.audience,session_transfer:i.session_transfer,max_expires_at:i.max_expires_at})).wireToken)}if(s===At.SAML_POST){if(!l)throw new p.HTTPException(500,{message:`Session ID not available for SAML response`});let i=a;if(t.loginSession&&!m){let o=await vB(e,e.env.data,r.tenant.id,a,t.loginSession,{client:r,authParams:n,authStrategy:t.authStrategy,authConnection:t.authConnection,sessionReused:!!t.existingSessionIdToLink});if(o instanceof Response)return o;i=o}return ML(e,t.client,t.authParams,i,l,t.loginSession?.id)}let g=await nH(e,{authParams:n,user:a,client:r,session_id:l,refresh_token:c,authStrategy:t.authStrategy,authConnection:t.authConnection,loginSession:u,loginSessionIsCurrent:!0,responseType:o,skipHooks:m,organization:t.organization,impersonatingUser:t.impersonatingUser,sessionReused:!!t.existingSessionIdToLink});if(g instanceof Response)return g;if(!n.redirect_uri)throw new k(400,{message:s===At.WEB_MESSAGE?`Redirect URI not allowed for WEB_MESSAGE response mode.`:`Redirect uri not found for this response mode.`});let _=new Headers;l?(Ld(r.tenant.id,l,e.var.host||``).forEach(e=>{_.append(`set-cookie`,e)}),u.auth_connection&&(await e.env.data.promptSettings.get(r.tenant.id))?.show_last_used_connection===!0&&_.append(`set-cookie`,Hd(r.tenant.id,u.auth_connection,e.var.host||``))):s===At.WEB_MESSAGE&&console.warn(`Session ID not available for WEB_MESSAGE, cookie will not be set.`);let v=o.split(` `),y=v.includes(`code`),b=v.includes(`id_token`),x=v.includes(`token`),S={},ee=`code`in g&&typeof g.code==`string`,te=`access_token`in g&&typeof g.access_token==`string`;if(ee&&y&&(S.code=g.code),te&&(x&&(S.access_token=g.access_token,S.token_type=g.token_type,S.expires_in=g.expires_in.toString()),b&&g.id_token&&(S.id_token=g.id_token)),!ee&&!te)throw new k(500,{message:`Invalid token response for front-channel flow.`});let ne=(`state`in g&&typeof g.state==`string`?g.state:void 0)??n.state;if(ne&&(S.state=ne),(x||b)&&n.scope&&(S.scope=n.scope),s===At.WEB_MESSAGE){let t=new URL(n.redirect_uri);return xB(e,`${t.protocol}//${t.host}`,JSON.stringify(S),_)}if(s===At.FORM_POST)return wB(n.redirect_uri,S,_);let re=b||x,ie=new URL(n.redirect_uri);if(re)ie.hash=new URLSearchParams(S).toString();else for(let[e,t]of Object.entries(S))ie.searchParams.set(e,t);return _.set(`location`,ie.toString()),new Response(`Redirecting`,{status:302,headers:_})}async function nH(e,t){let{user:n}=t,r=t.responseType||kt.TOKEN;if(n&&t.organization&&!await BB(e,t.client.tenant.id,n.user_id,t.organization.id))throw new k(403,{error:`access_denied`,error_description:`User is not a member of the specified organization`});let i=t.authParams.scope||``,a=[],o,s=Cc(e.env,e.var.custom_domain),c=t.authParams.audience??t.client.tenant.default_audience??`${s}userinfo`;if(c)try{let r;if(t.grantType===Wi.ClientCredential||!n&&!t.user)r=await WB(e,{grantType:Wi.ClientCredential,tenantId:t.client.tenant.id,clientId:t.client.client_id,audience:c,requestedScopes:t.authParams.scope?.split(` `)||[],organizationId:t.organization?.id});else{let i=n?.user_id||t.user?.user_id;if(!i)throw new k(400,{error:`invalid_request`,error_description:`User ID is required for user-based grants`});r=await WB(e,{grantType:t.grantType,tenantId:t.client.tenant.id,userId:i,clientId:t.client.client_id,audience:c,requestedScopes:t.authParams.scope?.split(` `)||[],organizationId:t.organization?.id})}i=r.scopes.join(` `),a=r.permissions,o=t.client.app_type===`spa`&&r.token_lifetime_for_web?r.token_lifetime_for_web:r.token_lifetime}catch(e){if(e instanceof p.HTTPException)throw e}let l={...t.authParams,scope:i};if(t.loginSession&&n&&!t.skipHooks){t.authStrategy&&n.app_metadata?.strategy!==t.authStrategy.strategy&&(n.app_metadata={...n.app_metadata,strategy:t.authStrategy.strategy},await e.env.data.users.update(t.client.tenant.id,n.user_id,{app_metadata:{...n.app_metadata||{},strategy:t.authStrategy.strategy}}));let r=await vB(e,e.env.data,t.client.tenant.id,n,t.loginSession,{client:t.client,authParams:l,authStrategy:t.authStrategy,authConnection:t.authConnection,sessionReused:t.sessionReused});if(r instanceof Response)return r;n=r}let u=Kc({loginSession:t.loginSession,authConnection:t.authConnection,ctxConnection:e.var.connection}),d=r.split(` `),f=d.includes(`code`),m=d.includes(`id_token`)||d.includes(`token`),h=f&&m;if(r===kt.CODE){if(!n||!t.loginSession)throw new k(500,{message:`User and loginSession is required for code flow`});let r=await BV(e,{user:n,client:t.client,authParams:l,login_id:t.loginSession.id});return await XV(e,t.client.tenant.id,t.loginSession,u,t.loginSessionIsCurrent?t.loginSession:void 0),r}else if(h){if(!n||!t.loginSession)throw new k(500,{message:`User and loginSession is required for hybrid flow`});let r=await BV(e,{user:n,client:t.client,authParams:l,login_id:t.loginSession.id}),i=await zV(e,{...t,user:n,authParams:l,permissions:a,token_lifetime:o,code:r.code});return await XV(e,t.client.tenant.id,t.loginSession,u,t.loginSessionIsCurrent?t.loginSession:void 0),{...i,code:r.code,state:r.state}}else{let r=await zV(e,{...t,user:n,authParams:l,permissions:a,token_lifetime:o});return t.loginSession&&await XV(e,t.client.tenant.id,t.loginSession,u,t.loginSessionIsCurrent?t.loginSession:void 0),r}}var rH=c({MFA_LOCKOUT_REASON:()=>iH,MFA_MAX_FAILED_ATTEMPTS:()=>5,MFA_MAX_SMS_SENDS:()=>5,MfaSmsRateLimitError:()=>aH,checkMfaAttemptAllowed:()=>uH,enforceMfaSmsSendLimit:()=>pH,isMfaLockedOut:()=>cH,recordMfaFailure:()=>dH,resetMfaFailures:()=>fH}),iH=`too_many_mfa_failures`,aH=class extends Error{constructor(){super(`Too many MFA SMS messages sent`),this.name=`MfaSmsRateLimitError`}};function oH(e){return typeof e==`object`&&!!e&&`allowed`in e&&typeof e.allowed==`boolean`}async function sH(e,t){let n=e.env.data.rateLimit;if(!n)return!0;try{let e=await n.consume(`brute-force`,t);return oH(e)?e.allowed:!0}catch(e){return console.error(`MFA rate limit consume failed:`,e),!0}}function cH(e){return e.state===T.FAILED&&e.failure_reason===`too_many_mfa_failures`?!0:(Pm(e.state_data).mfa_failed_attempts??0)>=5}async function lH(e,t,n,r,i){O(e,t,{type:E.TOO_MANY_MFA_FAILURES,description:i,userId:r}),await qV(e,t,n,iH)}async function uH(e,t,n,r){return cH(n)?!1:await sH(e,`mfa:${t}:${r}`)?!0:(await lH(e,t,n,r,`MFA verification rate limit exceeded`),!1)}async function dH(e,t,n,r){let i=await e.env.data.loginSessions.get(t,n);if(!i||cH(i))return{lockedOut:!0};let a=(Pm(i.state_data).mfa_failed_attempts??0)+1;try{await TO(e.env.data.loginSessions,t,n,{type:j.UPDATE_CONTEXT,data:{mfa_failed_attempts:a}})}catch(e){if(e instanceof bO)return{lockedOut:!0};throw e}return a<5?{lockedOut:!1}:(await lH(e,t,i,r,`Too many failed MFA attempts (${a})`),{lockedOut:!0})}async function fH(e,t,n){await TO(e.env.data.loginSessions,t,n,{type:j.UPDATE_CONTEXT,data:{mfa_failed_attempts:void 0}})}async function pH(e,t,n,r,i){let a=await e.env.data.loginSessions.get(t,n);if(a&&(xO(a)||new Date(a.expires_at).getTime()<Date.now()))throw new bO(n);let o=Pm(a?.state_data).mfa_sms_sent??0,s=i??a?.user_id??r,c=()=>(O(e,t,{type:E.ERROR_SENDING_MFA_SMS,description:`MFA SMS send limit reached`,userId:i??a?.user_id}),new aH);if(o>=5||!await sH(e,`mfa-sms:${t}:${s}`))throw c();if(!a)return;let{status:l}=await EO(e.env.data.loginSessions,t,n,`mfa_sms_sent`,5);if(l===`finalized`)throw new bO(n);if(l===`limit_reached`||l===`contended`)throw c()}Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return EB}}),Object.defineProperty(exports,"$a",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,"$c",{enumerable:!0,get:function(){return Hr}}),Object.defineProperty(exports,"$d",{enumerable:!0,get:function(){return os}}),Object.defineProperty(exports,"$i",{enumerable:!0,get:function(){return jc}}),Object.defineProperty(exports,"$l",{enumerable:!0,get:function(){return st}}),Object.defineProperty(exports,"$n",{enumerable:!0,get:function(){return nD}}),Object.defineProperty(exports,"$o",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"$r",{enumerable:!0,get:function(){return Ku}}),Object.defineProperty(exports,"$s",{enumerable:!0,get:function(){return Oo}}),Object.defineProperty(exports,"$t",{enumerable:!0,get:function(){return VI}}),Object.defineProperty(exports,"$u",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return aV}}),Object.defineProperty(exports,"Aa",{enumerable:!0,get:function(){return so}}),Object.defineProperty(exports,"Ac",{enumerable:!0,get:function(){return et}}),Object.defineProperty(exports,"Ad",{enumerable:!0,get:function(){return Yo}}),Object.defineProperty(exports,"Ai",{enumerable:!0,get:function(){return Pl}}),Object.defineProperty(exports,"Al",{enumerable:!0,get:function(){return At}}),Object.defineProperty(exports,"An",{enumerable:!0,get:function(){return eO}}),Object.defineProperty(exports,"Ao",{enumerable:!0,get:function(){return ba}}),Object.defineProperty(exports,"Ar",{enumerable:!0,get:function(){return Lm}}),Object.defineProperty(exports,"As",{enumerable:!0,get:function(){return wi}}),Object.defineProperty(exports,"At",{enumerable:!0,get:function(){return cR}}),Object.defineProperty(exports,"Au",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return JB}}),Object.defineProperty(exports,"Ba",{enumerable:!0,get:function(){return fs}}),Object.defineProperty(exports,"Bc",{enumerable:!0,get:function(){return St}}),Object.defineProperty(exports,"Bd",{enumerable:!0,get:function(){return rc}}),Object.defineProperty(exports,"Bi",{enumerable:!0,get:function(){return ll}}),Object.defineProperty(exports,"Bl",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"Bn",{enumerable:!0,get:function(){return ED}}),Object.defineProperty(exports,"Bo",{enumerable:!0,get:function(){return Zn}}),Object.defineProperty(exports,"Br",{enumerable:!0,get:function(){return Ld}}),Object.defineProperty(exports,"Bs",{enumerable:!0,get:function(){return Zi}}),Object.defineProperty(exports,"Bt",{enumerable:!0,get:function(){return RL}}),Object.defineProperty(exports,"Bu",{enumerable:!0,get:function(){return Wa}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return wV}}),Object.defineProperty(exports,"Ca",{enumerable:!0,get:function(){return To}}),Object.defineProperty(exports,"Cc",{enumerable:!0,get:function(){return Po}}),Object.defineProperty(exports,"Cd",{enumerable:!0,get:function(){return Cr}}),Object.defineProperty(exports,"Cf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"Ci",{enumerable:!0,get:function(){return eu}}),Object.defineProperty(exports,"Cl",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(exports,"Cn",{enumerable:!0,get:function(){return TO}}),Object.defineProperty(exports,"Co",{enumerable:!0,get:function(){return Wt}}),Object.defineProperty(exports,"Cr",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"Cs",{enumerable:!0,get:function(){return xc}}),Object.defineProperty(exports,"Ct",{enumerable:!0,get:function(){return vR}}),Object.defineProperty(exports,"Cu",{enumerable:!0,get:function(){return Js}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return uV}}),Object.defineProperty(exports,"Da",{enumerable:!0,get:function(){return Es}}),Object.defineProperty(exports,"Dc",{enumerable:!0,get:function(){return xi}}),Object.defineProperty(exports,"Dd",{enumerable:!0,get:function(){return Ja}}),Object.defineProperty(exports,"Di",{enumerable:!0,get:function(){return Jl}}),Object.defineProperty(exports,"Dl",{enumerable:!0,get:function(){return zi}}),Object.defineProperty(exports,"Dn",{enumerable:!0,get:function(){return _O}}),Object.defineProperty(exports,"Do",{enumerable:!0,get:function(){return Ma}}),Object.defineProperty(exports,"Dr",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"Ds",{enumerable:!0,get:function(){return Ia}}),Object.defineProperty(exports,"Dt",{enumerable:!0,get:function(){return pR}}),Object.defineProperty(exports,"Du",{enumerable:!0,get:function(){return Hi}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return yV}}),Object.defineProperty(exports,"Ea",{enumerable:!0,get:function(){return sr}}),Object.defineProperty(exports,"Ec",{enumerable:!0,get:function(){return Fs}}),Object.defineProperty(exports,"Ed",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(exports,"Ei",{enumerable:!0,get:function(){return Ql}}),Object.defineProperty(exports,"El",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,"En",{enumerable:!0,get:function(){return hO}}),Object.defineProperty(exports,"Eo",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(exports,"Er",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"Es",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(exports,"Et",{enumerable:!0,get:function(){return hR}}),Object.defineProperty(exports,"Eu",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return YB}}),Object.defineProperty(exports,"Fa",{enumerable:!0,get:function(){return Kr}}),Object.defineProperty(exports,"Fc",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"Fd",{enumerable:!0,get:function(){return no}}),Object.defineProperty(exports,"Fi",{enumerable:!0,get:function(){return Nl}}),Object.defineProperty(exports,"Fl",{enumerable:!0,get:function(){return Rr}}),Object.defineProperty(exports,"Fn",{enumerable:!0,get:function(){return HD}}),Object.defineProperty(exports,"Fo",{enumerable:!0,get:function(){return vi}}),Object.defineProperty(exports,"Fr",{enumerable:!0,get:function(){return Fd}}),Object.defineProperty(exports,"Fs",{enumerable:!0,get:function(){return ws}}),Object.defineProperty(exports,"Ft",{enumerable:!0,get:function(){return nR}}),Object.defineProperty(exports,"Fu",{enumerable:!0,get:function(){return Vo}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return HB}}),Object.defineProperty(exports,"Ga",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"Gc",{enumerable:!0,get:function(){return Wo}}),Object.defineProperty(exports,"Gd",{enumerable:!0,get:function(){return Ln}}),Object.defineProperty(exports,"Gi",{enumerable:!0,get:function(){return Uc}}),Object.defineProperty(exports,"Gl",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(exports,"Gn",{enumerable:!0,get:function(){return jD}}),Object.defineProperty(exports,"Go",{enumerable:!0,get:function(){return _o}}),Object.defineProperty(exports,"Gr",{enumerable:!0,get:function(){return _d}}),Object.defineProperty(exports,"Gs",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(exports,"Gt",{enumerable:!0,get:function(){return OL}}),Object.defineProperty(exports,"Gu",{enumerable:!0,get:function(){return Gs}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return qB}}),Object.defineProperty(exports,"Ha",{enumerable:!0,get:function(){return mc}}),Object.defineProperty(exports,"Hc",{enumerable:!0,get:function(){return Ua}}),Object.defineProperty(exports,"Hd",{enumerable:!0,get:function(){return co}}),Object.defineProperty(exports,"Hi",{enumerable:!0,get:function(){return Xc}}),Object.defineProperty(exports,"Hl",{enumerable:!0,get:function(){return $o}}),Object.defineProperty(exports,"Hn",{enumerable:!0,get:function(){return TD}}),Object.defineProperty(exports,"Ho",{enumerable:!0,get:function(){return oi}}),Object.defineProperty(exports,"Hr",{enumerable:!0,get:function(){return hd}}),Object.defineProperty(exports,"Hs",{enumerable:!0,get:function(){return ss}}),Object.defineProperty(exports,"Ht",{enumerable:!0,get:function(){return wL}}),Object.defineProperty(exports,"Hu",{enumerable:!0,get:function(){return Ni}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return nV}}),Object.defineProperty(exports,"Ia",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(exports,"Ic",{enumerable:!0,get:function(){return Gi}}),Object.defineProperty(exports,"Id",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"Ii",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"Il",{enumerable:!0,get:function(){return tc}}),Object.defineProperty(exports,"In",{enumerable:!0,get:function(){return UD}}),Object.defineProperty(exports,"Io",{enumerable:!0,get:function(){return mi}}),Object.defineProperty(exports,"Ir",{enumerable:!0,get:function(){return Vd}}),Object.defineProperty(exports,"Is",{enumerable:!0,get:function(){return si}}),Object.defineProperty(exports,"It",{enumerable:!0,get:function(){return KL}}),Object.defineProperty(exports,"Iu",{enumerable:!0,get:function(){return wr}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return MB}}),Object.defineProperty(exports,"Ja",{enumerable:!0,get:function(){return Yr}}),Object.defineProperty(exports,"Jc",{enumerable:!0,get:function(){return io}}),Object.defineProperty(exports,"Jd",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(exports,"Ji",{enumerable:!0,get:function(){return Bc}}),Object.defineProperty(exports,"Jl",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,"Jn",{enumerable:!0,get:function(){return sD}}),Object.defineProperty(exports,"Jo",{enumerable:!0,get:function(){return Kn}}),Object.defineProperty(exports,"Jr",{enumerable:!0,get:function(){return od}}),Object.defineProperty(exports,"Js",{enumerable:!0,get:function(){return ea}}),Object.defineProperty(exports,"Jt",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"Ju",{enumerable:!0,get:function(){return Za}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return BB}}),Object.defineProperty(exports,"Ka",{enumerable:!0,get:function(){return ta}}),Object.defineProperty(exports,"Kc",{enumerable:!0,get:function(){return Dr}}),Object.defineProperty(exports,"Kd",{enumerable:!0,get:function(){return ls}}),Object.defineProperty(exports,"Ki",{enumerable:!0,get:function(){return Ic}}),Object.defineProperty(exports,"Kl",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"Kn",{enumerable:!0,get:function(){return mD}}),Object.defineProperty(exports,"Ko",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"Kr",{enumerable:!0,get:function(){return sd}}),Object.defineProperty(exports,"Ks",{enumerable:!0,get:function(){return lo}}),Object.defineProperty(exports,"Kt",{enumerable:!0,get:function(){return zI}}),Object.defineProperty(exports,"Ku",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return eV}}),Object.defineProperty(exports,"La",{enumerable:!0,get:function(){return fo}}),Object.defineProperty(exports,"Lc",{enumerable:!0,get:function(){return ts}}),Object.defineProperty(exports,"Ld",{enumerable:!0,get:function(){return Ki}}),Object.defineProperty(exports,"Li",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"Ll",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(exports,"Ln",{enumerable:!0,get:function(){return RD}}),Object.defineProperty(exports,"Lo",{enumerable:!0,get:function(){return So}}),Object.defineProperty(exports,"Lr",{enumerable:!0,get:function(){return Nd}}),Object.defineProperty(exports,"Ls",{enumerable:!0,get:function(){return qt}}),Object.defineProperty(exports,"Lt",{enumerable:!0,get:function(){return GL}}),Object.defineProperty(exports,"Lu",{enumerable:!0,get:function(){return Vs}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return $B}}),Object.defineProperty(exports,"Ma",{enumerable:!0,get:function(){return Qi}}),Object.defineProperty(exports,"Mc",{enumerable:!0,get:function(){return Ls}}),Object.defineProperty(exports,"Md",{enumerable:!0,get:function(){return Ys}}),Object.defineProperty(exports,"Mi",{enumerable:!0,get:function(){return Ml}}),Object.defineProperty(exports,"Ml",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"Mn",{enumerable:!0,get:function(){return rO}}),Object.defineProperty(exports,"Mo",{enumerable:!0,get:function(){return Oa}}),Object.defineProperty(exports,"Mr",{enumerable:!0,get:function(){return Id}}),Object.defineProperty(exports,"Ms",{enumerable:!0,get:function(){return Co}}),Object.defineProperty(exports,"Mt",{enumerable:!0,get:function(){return sR}}),Object.defineProperty(exports,"Mu",{enumerable:!0,get:function(){return Ba}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return iV}}),Object.defineProperty(exports,"Na",{enumerable:!0,get:function(){return In}}),Object.defineProperty(exports,"Nc",{enumerable:!0,get:function(){return Ci}}),Object.defineProperty(exports,"Nd",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(exports,"Ni",{enumerable:!0,get:function(){return jl}}),Object.defineProperty(exports,"Nl",{enumerable:!0,get:function(){return Wi}}),Object.defineProperty(exports,"Nn",{enumerable:!0,get:function(){return qD}}),Object.defineProperty(exports,"No",{enumerable:!0,get:function(){return mr}}),Object.defineProperty(exports,"Nr",{enumerable:!0,get:function(){return Wd}}),Object.defineProperty(exports,"Ns",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"Nt",{enumerable:!0,get:function(){return aR}}),Object.defineProperty(exports,"Nu",{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return lV}}),Object.defineProperty(exports,"Oa",{enumerable:!0,get:function(){return li}}),Object.defineProperty(exports,"Oc",{enumerable:!0,get:function(){return ps}}),Object.defineProperty(exports,"Od",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"Oi",{enumerable:!0,get:function(){return Yl}}),Object.defineProperty(exports,"Ol",{enumerable:!0,get:function(){return Zs}}),Object.defineProperty(exports,"On",{enumerable:!0,get:function(){return uO}}),Object.defineProperty(exports,"Oo",{enumerable:!0,get:function(){return Ps}}),Object.defineProperty(exports,"Or",{enumerable:!0,get:function(){return Rm}}),Object.defineProperty(exports,"Os",{enumerable:!0,get:function(){return br}}),Object.defineProperty(exports,"Ot",{enumerable:!0,get:function(){return mR}}),Object.defineProperty(exports,"Ou",{enumerable:!0,get:function(){return Qo}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return tV}}),Object.defineProperty(exports,"Pa",{enumerable:!0,get:function(){return cs}}),Object.defineProperty(exports,"Pc",{enumerable:!0,get:function(){return to}}),Object.defineProperty(exports,"Pd",{enumerable:!0,get:function(){return Kt}}),Object.defineProperty(exports,"Pi",{enumerable:!0,get:function(){return Wl}}),Object.defineProperty(exports,"Pl",{enumerable:!0,get:function(){return es}}),Object.defineProperty(exports,"Pn",{enumerable:!0,get:function(){return GD}}),Object.defineProperty(exports,"Po",{enumerable:!0,get:function(){return Ms}}),Object.defineProperty(exports,"Pr",{enumerable:!0,get:function(){return Dd}}),Object.defineProperty(exports,"Ps",{enumerable:!0,get:function(){return ga}}),Object.defineProperty(exports,"Pt",{enumerable:!0,get:function(){return rR}}),Object.defineProperty(exports,"Pu",{enumerable:!0,get:function(){return Oi}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return TB}}),Object.defineProperty(exports,"Qa",{enumerable:!0,get:function(){return bo}}),Object.defineProperty(exports,"Qc",{enumerable:!0,get:function(){return as}}),Object.defineProperty(exports,"Qd",{enumerable:!0,get:function(){return Pn}}),Object.defineProperty(exports,"Qi",{enumerable:!0,get:function(){return Ac}}),Object.defineProperty(exports,"Ql",{enumerable:!0,get:function(){return Us}}),Object.defineProperty(exports,"Qn",{enumerable:!0,get:function(){return iD}}),Object.defineProperty(exports,"Qo",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(exports,"Qr",{enumerable:!0,get:function(){return qu}}),Object.defineProperty(exports,"Qs",{enumerable:!0,get:function(){return fa}}),Object.defineProperty(exports,"Qt",{enumerable:!0,get:function(){return XI}}),Object.defineProperty(exports,"Qu",{enumerable:!0,get:function(){return Qs}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return XB}}),Object.defineProperty(exports,"Ra",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"Rc",{enumerable:!0,get:function(){return zr}}),Object.defineProperty(exports,"Rd",{enumerable:!0,get:function(){return ns}}),Object.defineProperty(exports,"Ri",{enumerable:!0,get:function(){return Zc}}),Object.defineProperty(exports,"Rl",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(exports,"Rn",{enumerable:!0,get:function(){return zD}}),Object.defineProperty(exports,"Ro",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"Rr",{enumerable:!0,get:function(){return Rd}}),Object.defineProperty(exports,"Rs",{enumerable:!0,get:function(){return oo}}),Object.defineProperty(exports,"Rt",{enumerable:!0,get:function(){return zL}}),Object.defineProperty(exports,"Ru",{enumerable:!0,get:function(){return at}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return TV}}),Object.defineProperty(exports,"Sa",{enumerable:!0,get:function(){return Yi}}),Object.defineProperty(exports,"Sc",{enumerable:!0,get:function(){return Aa}}),Object.defineProperty(exports,"Sd",{enumerable:!0,get:function(){return Bo}}),Object.defineProperty(exports,"Sf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"Si",{enumerable:!0,get:function(){return cu}}),Object.defineProperty(exports,"Sl",{enumerable:!0,get:function(){return Bs}}),Object.defineProperty(exports,"Sn",{enumerable:!0,get:function(){return EO}}),Object.defineProperty(exports,"So",{enumerable:!0,get:function(){return ai}}),Object.defineProperty(exports,"Sr",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"Ss",{enumerable:!0,get:function(){return ri}}),Object.defineProperty(exports,"St",{enumerable:!0,get:function(){return LR}}),Object.defineProperty(exports,"Su",{enumerable:!0,get:function(){return Ar}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return xV}}),Object.defineProperty(exports,"Ta",{enumerable:!0,get:function(){return xa}}),Object.defineProperty(exports,"Tc",{enumerable:!0,get:function(){return Na}}),Object.defineProperty(exports,"Td",{enumerable:!0,get:function(){return it}}),Object.defineProperty(exports,"Ti",{enumerable:!0,get:function(){return Zl}}),Object.defineProperty(exports,"Tl",{enumerable:!0,get:function(){return Xa}}),Object.defineProperty(exports,"Tn",{enumerable:!0,get:function(){return gO}}),Object.defineProperty(exports,"To",{enumerable:!0,get:function(){return No}}),Object.defineProperty(exports,"Tr",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"Ts",{enumerable:!0,get:function(){return Lo}}),Object.defineProperty(exports,"Tt",{enumerable:!0,get:function(){return gR}}),Object.defineProperty(exports,"Tu",{enumerable:!0,get:function(){return Qa}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return IB}}),Object.defineProperty(exports,"Ua",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(exports,"Uc",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"Ud",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"Ui",{enumerable:!0,get:function(){return Kc}}),Object.defineProperty(exports,"Ul",{enumerable:!0,get:function(){return Lr}}),Object.defineProperty(exports,"Un",{enumerable:!0,get:function(){return OD}}),Object.defineProperty(exports,"Uo",{enumerable:!0,get:function(){return Gt}}),Object.defineProperty(exports,"Ur",{enumerable:!0,get:function(){return vd}}),Object.defineProperty(exports,"Us",{enumerable:!0,get:function(){return Gr}}),Object.defineProperty(exports,"Ut",{enumerable:!0,get:function(){return kL}}),Object.defineProperty(exports,"Uu",{enumerable:!0,get:function(){return Go}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return KB}}),Object.defineProperty(exports,"Va",{enumerable:!0,get:function(){return Xr}}),Object.defineProperty(exports,"Vc",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"Vd",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(exports,"Vi",{enumerable:!0,get:function(){return Yc}}),Object.defineProperty(exports,"Vl",{enumerable:!0,get:function(){return Ui}}),Object.defineProperty(exports,"Vn",{enumerable:!0,get:function(){return wD}}),Object.defineProperty(exports,"Vo",{enumerable:!0,get:function(){return Cs}}),Object.defineProperty(exports,"Vr",{enumerable:!0,get:function(){return Pd}}),Object.defineProperty(exports,"Vs",{enumerable:!0,get:function(){return Fn}}),Object.defineProperty(exports,"Vt",{enumerable:!0,get:function(){return VL}}),Object.defineProperty(exports,"Vu",{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return WB}}),Object.defineProperty(exports,"Wa",{enumerable:!0,get:function(){return uo}}),Object.defineProperty(exports,"Wc",{enumerable:!0,get:function(){return Mi}}),Object.defineProperty(exports,"Wd",{enumerable:!0,get:function(){return $i}}),Object.defineProperty(exports,"Wi",{enumerable:!0,get:function(){return Wc}}),Object.defineProperty(exports,"Wl",{enumerable:!0,get:function(){return ec}}),Object.defineProperty(exports,"Wn",{enumerable:!0,get:function(){return kD}}),Object.defineProperty(exports,"Wo",{enumerable:!0,get:function(){return jr}}),Object.defineProperty(exports,"Wr",{enumerable:!0,get:function(){return md}}),Object.defineProperty(exports,"Ws",{enumerable:!0,get:function(){return sc}}),Object.defineProperty(exports,"Wt",{enumerable:!0,get:function(){return II}}),Object.defineProperty(exports,"Wu",{enumerable:!0,get:function(){return Or}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return jB}}),Object.defineProperty(exports,"Xa",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(exports,"Xc",{enumerable:!0,get:function(){return Ji}}),Object.defineProperty(exports,"Xd",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"Xi",{enumerable:!0,get:function(){return zc}}),Object.defineProperty(exports,"Xl",{enumerable:!0,get:function(){return Uo}}),Object.defineProperty(exports,"Xn",{enumerable:!0,get:function(){return aD}}),Object.defineProperty(exports,"Xo",{enumerable:!0,get:function(){return ti}}),Object.defineProperty(exports,"Xr",{enumerable:!0,get:function(){return xd}}),Object.defineProperty(exports,"Xs",{enumerable:!0,get:function(){return Jr}}),Object.defineProperty(exports,"Xt",{enumerable:!0,get:function(){return sL}}),Object.defineProperty(exports,"Xu",{enumerable:!0,get:function(){return Vi}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return DB}}),Object.defineProperty(exports,"Ya",{enumerable:!0,get:function(){return dc}}),Object.defineProperty(exports,"Yc",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"Yd",{enumerable:!0,get:function(){return ao}}),Object.defineProperty(exports,"Yi",{enumerable:!0,get:function(){return Rc}}),Object.defineProperty(exports,"Yl",{enumerable:!0,get:function(){return ji}}),Object.defineProperty(exports,"Yn",{enumerable:!0,get:function(){return oD}}),Object.defineProperty(exports,"Yo",{enumerable:!0,get:function(){return vs}}),Object.defineProperty(exports,"Yr",{enumerable:!0,get:function(){return bd}}),Object.defineProperty(exports,"Ys",{enumerable:!0,get:function(){return us}}),Object.defineProperty(exports,"Yt",{enumerable:!0,get:function(){return RI}}),Object.defineProperty(exports,"Yu",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return AB}}),Object.defineProperty(exports,"Za",{enumerable:!0,get:function(){return ui}}),Object.defineProperty(exports,"Zc",{enumerable:!0,get:function(){return Nn}}),Object.defineProperty(exports,"Zd",{enumerable:!0,get:function(){return Xi}}),Object.defineProperty(exports,"Zi",{enumerable:!0,get:function(){return Hc}}),Object.defineProperty(exports,"Zl",{enumerable:!0,get:function(){return Er}}),Object.defineProperty(exports,"Zn",{enumerable:!0,get:function(){return rD}}),Object.defineProperty(exports,"Zo",{enumerable:!0,get:function(){return yc}}),Object.defineProperty(exports,"Zr",{enumerable:!0,get:function(){return id}}),Object.defineProperty(exports,"Zs",{enumerable:!0,get:function(){return uc}}),Object.defineProperty(exports,"Zt",{enumerable:!0,get:function(){return qI}}),Object.defineProperty(exports,"Zu",{enumerable:!0,get:function(){return Fr}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return eH}}),Object.defineProperty(exports,"_a",{enumerable:!0,get:function(){return oa}}),Object.defineProperty(exports,"_c",{enumerable:!0,get:function(){return Fo}}),Object.defineProperty(exports,"_d",{enumerable:!0,get:function(){return Ks}}),Object.defineProperty(exports,"_f",{enumerable:!0,get:function(){return ci}}),Object.defineProperty(exports,"_i",{enumerable:!0,get:function(){return xu}}),Object.defineProperty(exports,"_l",{enumerable:!0,get:function(){return Ra}}),Object.defineProperty(exports,"_n",{enumerable:!0,get:function(){return JO}}),Object.defineProperty(exports,"_o",{enumerable:!0,get:function(){return fi}}),Object.defineProperty(exports,"_r",{enumerable:!0,get:function(){return xv}}),Object.defineProperty(exports,"_s",{enumerable:!0,get:function(){return yo}}),Object.defineProperty(exports,"_t",{enumerable:!0,get:function(){return dz}}),Object.defineProperty(exports,"_u",{enumerable:!0,get:function(){return We}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return rH}}),Object.defineProperty(exports,"aa",{enumerable:!0,get:function(){return Cc}}),Object.defineProperty(exports,"ac",{enumerable:!0,get:function(){return Eo}}),Object.defineProperty(exports,"ad",{enumerable:!0,get:function(){return Va}}),Object.defineProperty(exports,"af",{enumerable:!0,get:function(){return qi}}),Object.defineProperty(exports,"ai",{enumerable:!0,get:function(){return Ju}}),Object.defineProperty(exports,"al",{enumerable:!0,get:function(){return Fi}}),Object.defineProperty(exports,"an",{enumerable:!0,get:function(){return HI}}),Object.defineProperty(exports,"ao",{enumerable:!0,get:function(){return ya}}),Object.defineProperty(exports,"ar",{enumerable:!0,get:function(){return OS}}),Object.defineProperty(exports,"as",{enumerable:!0,get:function(){return ni}}),Object.defineProperty(exports,"at",{enumerable:!0,get:function(){return eB}}),Object.defineProperty(exports,"au",{enumerable:!0,get:function(){return ei}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return FV}}),Object.defineProperty(exports,"ba",{enumerable:!0,get:function(){return $r}}),Object.defineProperty(exports,"bc",{enumerable:!0,get:function(){return Is}}),Object.defineProperty(exports,"bd",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,"bf",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"bi",{enumerable:!0,get:function(){return fu}}),Object.defineProperty(exports,"bl",{enumerable:!0,get:function(){return zo}}),Object.defineProperty(exports,"bn",{enumerable:!0,get:function(){return DO}}),Object.defineProperty(exports,"bo",{enumerable:!0,get:function(){return ma}}),Object.defineProperty(exports,"br",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"bs",{enumerable:!0,get:function(){return Jn}}),Object.defineProperty(exports,"bt",{enumerable:!0,get:function(){return NR}}),Object.defineProperty(exports,"bu",{enumerable:!0,get:function(){return Ii}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return GV}}),Object.defineProperty(exports,"ca",{enumerable:!0,get:function(){return Ro}}),Object.defineProperty(exports,"cc",{enumerable:!0,get:function(){return Ds}}),Object.defineProperty(exports,"cd",{enumerable:!0,get:function(){return Tr}}),Object.defineProperty(exports,"cf",{enumerable:!0,get:function(){return Vr}}),Object.defineProperty(exports,"ci",{enumerable:!0,get:function(){return Hu}}),Object.defineProperty(exports,"cl",{enumerable:!0,get:function(){return qs}}),Object.defineProperty(exports,"cn",{enumerable:!0,get:function(){return ZO}}),Object.defineProperty(exports,"co",{enumerable:!0,get:function(){return Ea}}),Object.defineProperty(exports,"cr",{enumerable:!0,get:function(){return Wx}}),Object.defineProperty(exports,"cs",{enumerable:!0,get:function(){return po}}),Object.defineProperty(exports,"ct",{enumerable:!0,get:function(){return rB}}),Object.defineProperty(exports,"cu",{enumerable:!0,get:function(){return ar}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return zV}}),Object.defineProperty(exports,"da",{enumerable:!0,get:function(){return xr}}),Object.defineProperty(exports,"dc",{enumerable:!0,get:function(){return va}}),Object.defineProperty(exports,"dd",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"df",{enumerable:!0,get:function(){return Bi}}),Object.defineProperty(exports,"di",{enumerable:!0,get:function(){return Ou}}),Object.defineProperty(exports,"dl",{enumerable:!0,get:function(){return Ya}}),Object.defineProperty(exports,"dn",{enumerable:!0,get:function(){return ek}}),Object.defineProperty(exports,"do",{enumerable:!0,get:function(){return Do}}),Object.defineProperty(exports,"dr",{enumerable:!0,get:function(){return Mx}}),Object.defineProperty(exports,"ds",{enumerable:!0,get:function(){return Hn}}),Object.defineProperty(exports,"dt",{enumerable:!0,get:function(){return Vz}}),Object.defineProperty(exports,"du",{enumerable:!0,get:function(){return aa}}),Object.defineProperty(exports,"ea",{enumerable:!0,get:function(){return kc}}),Object.defineProperty(exports,"ec",{enumerable:!0,get:function(){return He}}),Object.defineProperty(exports,"ed",{enumerable:!0,get:function(){return Da}}),Object.defineProperty(exports,"ef",{enumerable:!0,get:function(){return Ur}}),Object.defineProperty(exports,"ei",{enumerable:!0,get:function(){return ju}}),Object.defineProperty(exports,"el",{enumerable:!0,get:function(){return ac}}),Object.defineProperty(exports,"en",{enumerable:!0,get:function(){return oL}}),Object.defineProperty(exports,"eo",{enumerable:!0,get:function(){return pa}}),Object.defineProperty(exports,"er",{enumerable:!0,get:function(){return IT}}),Object.defineProperty(exports,"es",{enumerable:!0,get:function(){return vo}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return wB}}),Object.defineProperty(exports,"eu",{enumerable:!0,get:function(){return go}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return BV}}),Object.defineProperty(exports,"fa",{enumerable:!0,get:function(){return zs}}),Object.defineProperty(exports,"fc",{enumerable:!0,get:function(){return ko}}),Object.defineProperty(exports,"fd",{enumerable:!0,get:function(){return Ga}}),Object.defineProperty(exports,"ff",{enumerable:!0,get:function(){return wo}}),Object.defineProperty(exports,"fi",{enumerable:!0,get:function(){return ku}}),Object.defineProperty(exports,"fl",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"fn",{enumerable:!0,get:function(){return GO}}),Object.defineProperty(exports,"fo",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(exports,"fr",{enumerable:!0,get:function(){return Wy}}),Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return ms}}),Object.defineProperty(exports,"ft",{enumerable:!0,get:function(){return Bz}}),Object.defineProperty(exports,"fu",{enumerable:!0,get:function(){return Un}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return KV}}),Object.defineProperty(exports,"ga",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"gc",{enumerable:!0,get:function(){return rs}}),Object.defineProperty(exports,"gd",{enumerable:!0,get:function(){return kr}}),Object.defineProperty(exports,"gf",{enumerable:!0,get:function(){return Ts}}),Object.defineProperty(exports,"gi",{enumerable:!0,get:function(){return Su}}),Object.defineProperty(exports,"gl",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(exports,"gn",{enumerable:!0,get:function(){return UO}}),Object.defineProperty(exports,"go",{enumerable:!0,get:function(){return Zt}}),Object.defineProperty(exports,"gr",{enumerable:!0,get:function(){return Zv}}),Object.defineProperty(exports,"gs",{enumerable:!0,get:function(){return Wr}}),Object.defineProperty(exports,"gt",{enumerable:!0,get:function(){return _z}}),Object.defineProperty(exports,"gu",{enumerable:!0,get:function(){return It}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return qV}}),Object.defineProperty(exports,"ha",{enumerable:!0,get:function(){return ho}}),Object.defineProperty(exports,"hc",{enumerable:!0,get:function(){return As}}),Object.defineProperty(exports,"hd",{enumerable:!0,get:function(){return Ko}}),Object.defineProperty(exports,"hf",{enumerable:!0,get:function(){return ir}}),Object.defineProperty(exports,"hi",{enumerable:!0,get:function(){return Cu}}),Object.defineProperty(exports,"hl",{enumerable:!0,get:function(){return Xs}}),Object.defineProperty(exports,"hn",{enumerable:!0,get:function(){return qO}}),Object.defineProperty(exports,"ho",{enumerable:!0,get:function(){return pi}}),Object.defineProperty(exports,"hr",{enumerable:!0,get:function(){return Qv}}),Object.defineProperty(exports,"hs",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(exports,"ht",{enumerable:!0,get:function(){return Dz}}),Object.defineProperty(exports,"hu",{enumerable:!0,get:function(){return gc}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return cH}}),Object.defineProperty(exports,"ia",{enumerable:!0,get:function(){return Ec}}),Object.defineProperty(exports,"ic",{enumerable:!0,get:function(){return ia}}),Object.defineProperty(exports,"id",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"if",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"ii",{enumerable:!0,get:function(){return Ru}}),Object.defineProperty(exports,"il",{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,"in",{enumerable:!0,get:function(){return YI}}),Object.defineProperty(exports,"io",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(exports,"ir",{enumerable:!0,get:function(){return XE}}),Object.defineProperty(exports,"is",{enumerable:!0,get:function(){return ys}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return qz}}),Object.defineProperty(exports,"iu",{enumerable:!0,get:function(){return _s}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return QB}}),Object.defineProperty(exports,"ja",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"jc",{enumerable:!0,get:function(){return Fa}}),Object.defineProperty(exports,"jd",{enumerable:!0,get:function(){return Mr}}),Object.defineProperty(exports,"ji",{enumerable:!0,get:function(){return Vl}}),Object.defineProperty(exports,"jl",{enumerable:!0,get:function(){return eo}}),Object.defineProperty(exports,"jn",{enumerable:!0,get:function(){return $D}}),Object.defineProperty(exports,"jo",{enumerable:!0,get:function(){return jo}}),Object.defineProperty(exports,"jr",{enumerable:!0,get:function(){return Nm}}),Object.defineProperty(exports,"js",{enumerable:!0,get:function(){return ki}}),Object.defineProperty(exports,"jt",{enumerable:!0,get:function(){return oR}}),Object.defineProperty(exports,"ju",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return oV}}),Object.defineProperty(exports,"ka",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(exports,"kc",{enumerable:!0,get:function(){return Io}}),Object.defineProperty(exports,"kd",{enumerable:!0,get:function(){return Li}}),Object.defineProperty(exports,"ki",{enumerable:!0,get:function(){return Al}}),Object.defineProperty(exports,"kl",{enumerable:!0,get:function(){return _t}}),Object.defineProperty(exports,"kn",{enumerable:!0,get:function(){return nO}}),Object.defineProperty(exports,"ko",{enumerable:!0,get:function(){return bi}}),Object.defineProperty(exports,"kr",{enumerable:!0,get:function(){return Pm}}),Object.defineProperty(exports,"ks",{enumerable:!0,get:function(){return Rs}}),Object.defineProperty(exports,"kt",{enumerable:!0,get:function(){return dR}}),Object.defineProperty(exports,"ku",{enumerable:!0,get:function(){return Ir}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return QV}}),Object.defineProperty(exports,"la",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(exports,"lc",{enumerable:!0,get:function(){return di}}),Object.defineProperty(exports,"ld",{enumerable:!0,get:function(){return Hs}}),Object.defineProperty(exports,"lf",{enumerable:!0,get:function(){return ic}}),Object.defineProperty(exports,"li",{enumerable:!0,get:function(){return Lu}}),Object.defineProperty(exports,"ll",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(exports,"ln",{enumerable:!0,get:function(){return QO}}),Object.defineProperty(exports,"lo",{enumerable:!0,get:function(){return js}}),Object.defineProperty(exports,"lr",{enumerable:!0,get:function(){return Tx}}),Object.defineProperty(exports,"ls",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"lt",{enumerable:!0,get:function(){return Yz}}),Object.defineProperty(exports,"lu",{enumerable:!0,get:function(){return mo}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return UV}}),Object.defineProperty(exports,"ma",{enumerable:!0,get:function(){return or}}),Object.defineProperty(exports,"mc",{enumerable:!0,get:function(){return Ta}}),Object.defineProperty(exports,"md",{enumerable:!0,get:function(){return Pi}}),Object.defineProperty(exports,"mf",{enumerable:!0,get:function(){return _a}}),Object.defineProperty(exports,"mi",{enumerable:!0,get:function(){return wu}}),Object.defineProperty(exports,"ml",{enumerable:!0,get:function(){return Nr}}),Object.defineProperty(exports,"mn",{enumerable:!0,get:function(){return HO}}),Object.defineProperty(exports,"mo",{enumerable:!0,get:function(){return Os}}),Object.defineProperty(exports,"mr",{enumerable:!0,get:function(){return Cy}}),Object.defineProperty(exports,"ms",{enumerable:!0,get:function(){return hc}}),Object.defineProperty(exports,"mt",{enumerable:!0,get:function(){return jz}}),Object.defineProperty(exports,"mu",{enumerable:!0,get:function(){return Qr}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return uH}}),Object.defineProperty(exports,"na",{enumerable:!0,get:function(){return Dc}}),Object.defineProperty(exports,"nc",{enumerable:!0,get:function(){return ks}}),Object.defineProperty(exports,"nd",{enumerable:!0,get:function(){return ja}}),Object.defineProperty(exports,"nf",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(exports,"ni",{enumerable:!0,get:function(){return zu}}),Object.defineProperty(exports,"nl",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"nn",{enumerable:!0,get:function(){return SL}}),Object.defineProperty(exports,"no",{enumerable:!0,get:function(){return xs}}),Object.defineProperty(exports,"nr",{enumerable:!0,get:function(){return HT}}),Object.defineProperty(exports,"ns",{enumerable:!0,get:function(){return ua}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return yB}}),Object.defineProperty(exports,"nu",{enumerable:!0,get:function(){return sa}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return dH}}),Object.defineProperty(exports,"oa",{enumerable:!0,get:function(){return Tc}}),Object.defineProperty(exports,"oc",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"od",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"of",{enumerable:!0,get:function(){return Mn}}),Object.defineProperty(exports,"oi",{enumerable:!0,get:function(){return Pu}}),Object.defineProperty(exports,"ol",{enumerable:!0,get:function(){return qo}}),Object.defineProperty(exports,"on",{enumerable:!0,get:function(){return cL}}),Object.defineProperty(exports,"oo",{enumerable:!0,get:function(){return Ao}}),Object.defineProperty(exports,"or",{enumerable:!0,get:function(){return Jx}}),Object.defineProperty(exports,"os",{enumerable:!0,get:function(){return bc}}),Object.defineProperty(exports,"ot",{enumerable:!0,get:function(){return nB}}),Object.defineProperty(exports,"ou",{enumerable:!0,get:function(){return vc}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return tH}}),Object.defineProperty(exports,"pa",{enumerable:!0,get:function(){return Ti}}),Object.defineProperty(exports,"pc",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(exports,"pd",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,"pf",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"pi",{enumerable:!0,get:function(){return Tu}}),Object.defineProperty(exports,"pl",{enumerable:!0,get:function(){return Ri}}),Object.defineProperty(exports,"pn",{enumerable:!0,get:function(){return WO}}),Object.defineProperty(exports,"po",{enumerable:!0,get:function(){return Ca}}),Object.defineProperty(exports,"pr",{enumerable:!0,get:function(){return wy}}),Object.defineProperty(exports,"ps",{enumerable:!0,get:function(){return Zr}}),Object.defineProperty(exports,"pt",{enumerable:!0,get:function(){return Fz}}),Object.defineProperty(exports,"pu",{enumerable:!0,get:function(){return hs}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return RB}}),Object.defineProperty(exports,"qa",{enumerable:!0,get:function(){return ds}}),Object.defineProperty(exports,"qc",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(exports,"qd",{enumerable:!0,get:function(){return qr}}),Object.defineProperty(exports,"qi",{enumerable:!0,get:function(){return Lc}}),Object.defineProperty(exports,"ql",{enumerable:!0,get:function(){return Ha}}),Object.defineProperty(exports,"qn",{enumerable:!0,get:function(){return vD}}),Object.defineProperty(exports,"qo",{enumerable:!0,get:function(){return ca}}),Object.defineProperty(exports,"qr",{enumerable:!0,get:function(){return ld}}),Object.defineProperty(exports,"qs",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"qt",{enumerable:!0,get:function(){return LI}}),Object.defineProperty(exports,"qu",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return pH}}),Object.defineProperty(exports,"ra",{enumerable:!0,get:function(){return Oc}}),Object.defineProperty(exports,"rc",{enumerable:!0,get:function(){return hi}}),Object.defineProperty(exports,"rd",{enumerable:!0,get:function(){return yi}}),Object.defineProperty(exports,"rf",{enumerable:!0,get:function(){return ro}}),Object.defineProperty(exports,"ri",{enumerable:!0,get:function(){return rd}}),Object.defineProperty(exports,"rl",{enumerable:!0,get:function(){return Ka}}),Object.defineProperty(exports,"rn",{enumerable:!0,get:function(){return ZI}}),Object.defineProperty(exports,"ro",{enumerable:!0,get:function(){return Sc}}),Object.defineProperty(exports,"rr",{enumerable:!0,get:function(){return NE}}),Object.defineProperty(exports,"rs",{enumerable:!0,get:function(){return qn}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return lB}}),Object.defineProperty(exports,"ru",{enumerable:!0,get:function(){return Gn}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return fH}}),Object.defineProperty(exports,"sa",{enumerable:!0,get:function(){return wc}}),Object.defineProperty(exports,"sc",{enumerable:!0,get:function(){return Sa}}),Object.defineProperty(exports,"sd",{enumerable:!0,get:function(){return Ai}}),Object.defineProperty(exports,"sf",{enumerable:!0,get:function(){return is}}),Object.defineProperty(exports,"si",{enumerable:!0,get:function(){return Au}}),Object.defineProperty(exports,"sl",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"sn",{enumerable:!0,get:function(){return $O}}),Object.defineProperty(exports,"so",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(exports,"sr",{enumerable:!0,get:function(){return Kx}}),Object.defineProperty(exports,"ss",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(exports,"st",{enumerable:!0,get:function(){return tB}}),Object.defineProperty(exports,"su",{enumerable:!0,get:function(){return Rt}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return aH}}),Object.defineProperty(exports,"ta",{enumerable:!0,get:function(){return Nc}}),Object.defineProperty(exports,"tc",{enumerable:!0,get:function(){return wa}}),Object.defineProperty(exports,"td",{enumerable:!0,get:function(){return Mo}}),Object.defineProperty(exports,"tf",{enumerable:!0,get:function(){return oc}}),Object.defineProperty(exports,"ti",{enumerable:!0,get:function(){return Mu}}),Object.defineProperty(exports,"tl",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(exports,"tn",{enumerable:!0,get:function(){return TL}}),Object.defineProperty(exports,"to",{enumerable:!0,get:function(){return Yn}}),Object.defineProperty(exports,"tr",{enumerable:!0,get:function(){return KT}}),Object.defineProperty(exports,"ts",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return xB}}),Object.defineProperty(exports,"tu",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return YV}}),Object.defineProperty(exports,"ua",{enumerable:!0,get:function(){return La}}),Object.defineProperty(exports,"uc",{enumerable:!0,get:function(){return Xt}}),Object.defineProperty(exports,"ud",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(exports,"uf",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(exports,"ui",{enumerable:!0,get:function(){return Du}}),Object.defineProperty(exports,"ul",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(exports,"un",{enumerable:!0,get:function(){return tk}}),Object.defineProperty(exports,"uo",{enumerable:!0,get:function(){return la}}),Object.defineProperty(exports,"ur",{enumerable:!0,get:function(){return jx}}),Object.defineProperty(exports,"us",{enumerable:!0,get:function(){return ra}}),Object.defineProperty(exports,"ut",{enumerable:!0,get:function(){return Hz}}),Object.defineProperty(exports,"uu",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return ZV}}),Object.defineProperty(exports,"va",{enumerable:!0,get:function(){return Wn}}),Object.defineProperty(exports,"vc",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,"vd",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(exports,"vf",{enumerable:!0,get:function(){return Jt}}),Object.defineProperty(exports,"vi",{enumerable:!0,get:function(){return ou}}),Object.defineProperty(exports,"vl",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"vn",{enumerable:!0,get:function(){return PO}}),Object.defineProperty(exports,"vo",{enumerable:!0,get:function(){return xo}}),Object.defineProperty(exports,"vr",{enumerable:!0,get:function(){return bv}}),Object.defineProperty(exports,"vs",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,"vt",{enumerable:!0,get:function(){return JR}}),Object.defineProperty(exports,"vu",{enumerable:!0,get:function(){return qa}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return vV}}),Object.defineProperty(exports,"wa",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"wc",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(exports,"wd",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"wi",{enumerable:!0,get:function(){return $l}}),Object.defineProperty(exports,"wl",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"wn",{enumerable:!0,get:function(){return yO}}),Object.defineProperty(exports,"wo",{enumerable:!0,get:function(){return ka}}),Object.defineProperty(exports,"wr",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"ws",{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(exports,"wt",{enumerable:!0,get:function(){return _R}}),Object.defineProperty(exports,"wu",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return PV}}),Object.defineProperty(exports,"xa",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(exports,"xc",{enumerable:!0,get:function(){return Si}}),Object.defineProperty(exports,"xd",{enumerable:!0,get:function(){return Di}}),Object.defineProperty(exports,"xf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"xi",{enumerable:!0,get:function(){return pu}}),Object.defineProperty(exports,"xl",{enumerable:!0,get:function(){return Sr}}),Object.defineProperty(exports,"xn",{enumerable:!0,get:function(){return xO}}),Object.defineProperty(exports,"xo",{enumerable:!0,get:function(){return Xn}}),Object.defineProperty(exports,"xr",{enumerable:!0,get:function(){return U_}}),Object.defineProperty(exports,"xs",{enumerable:!0,get:function(){return bs}}),Object.defineProperty(exports,"xt",{enumerable:!0,get:function(){return wR}}),Object.defineProperty(exports,"xu",{enumerable:!0,get:function(){return Jo}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return AV}}),Object.defineProperty(exports,"ya",{enumerable:!0,get:function(){return gs}}),Object.defineProperty(exports,"yc",{enumerable:!0,get:function(){return Pa}}),Object.defineProperty(exports,"yd",{enumerable:!0,get:function(){return za}}),Object.defineProperty(exports,"yf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"yi",{enumerable:!0,get:function(){return hu}}),Object.defineProperty(exports,"yl",{enumerable:!0,get:function(){return Ei}}),Object.defineProperty(exports,"yn",{enumerable:!0,get:function(){return bO}}),Object.defineProperty(exports,"yo",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"yr",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"ys",{enumerable:!0,get:function(){return da}}),Object.defineProperty(exports,"yt",{enumerable:!0,get:function(){return VR}}),Object.defineProperty(exports,"yu",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return ZB}}),Object.defineProperty(exports,"za",{enumerable:!0,get:function(){return na}}),Object.defineProperty(exports,"zc",{enumerable:!0,get:function(){return nc}}),Object.defineProperty(exports,"zd",{enumerable:!0,get:function(){return Br}}),Object.defineProperty(exports,"zi",{enumerable:!0,get:function(){return rl}}),Object.defineProperty(exports,"zl",{enumerable:!0,get:function(){return $a}}),Object.defineProperty(exports,"zn",{enumerable:!0,get:function(){return VD}}),Object.defineProperty(exports,"zo",{enumerable:!0,get:function(){return ha}}),Object.defineProperty(exports,"zr",{enumerable:!0,get:function(){return Ud}}),Object.defineProperty(exports,"zs",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"zt",{enumerable:!0,get:function(){return BL}}),Object.defineProperty(exports,"zu",{enumerable:!0,get:function(){return x}});