@clerk/clerk-js
Version:
Clerk JS library
1 lines • 1.51 MB
JavaScript
var e,t,a={9296(e,t,a){a.d(t,{getDebugLogger:()=>l}),a(6100);class r{logLevel;transport;constructor(e,t){this.transport=e,this.logLevel=t??"debug"}debug(e,t,a){this.log("debug",e,t,a)}error(e,t,a){this.log("error",e,t,a)}info(e,t,a){this.log("info",e,t,a)}warn(e,t,a){this.log("warn",e,t,a)}log(e,t,a,r){if(!this.shouldLogLevel(e))return;let n={timestamp:Date.now(),level:e,message:t,context:a,source:r};this.transport.send(n).catch(e=>{console.error("Failed to send log entry:",e)})}shouldLogLevel(e){let t=["error","warn","info","debug"],a=t.indexOf(this.logLevel);return t.indexOf(e)<=a}}class n{transports;constructor(e){this.transports=e}async send(e){let t=this.transports.map(t=>t.send(e).catch(e=>{console.error("Failed to send to transport:",e)}));await Promise.allSettled(t)}}class i{send(e){let t=new Date(e.timestamp).toISOString(),a=e.level.toUpperCase(),r=e.source?`[${e.source}]`:"",n=e.context?` ${JSON.stringify(e.context)}`:"",i=`[Clerk Debug] ${t} ${a}${r}: ${e.message}${n}`;switch(e.level){case"error":console.error(i);break;case"warn":console.warn(i);break;case"info":console.info(i);break;case"debug":console.debug(i);break;default:console.log(i)}return Promise.resolve()}}class s{collector;constructor(e){this.collector=e}async send(e){this.collector&&await Promise.resolve(this.collector.recordLog({context:e.context,level:e.level,message:e.message,organizationId:e.organizationId,sessionId:e.sessionId,source:e.source,timestamp:e.timestamp,userId:e.userId}))}}class o{static instance;initialized=!1;logger=null;initializationPromise=null;static getInstance(){return o.instance||(o.instance=new o),o.instance}async initialize(e={}){return this.initialized?this.logger:(this.initializationPromise||(this.initializationPromise=this.performInitialization(e)),this.initializationPromise)}async performInitialization(e){try{if(e.logLevel&&"string"!=typeof e.logLevel)throw Error("logLevel must be a string");let{logLevel:t,telemetryCollector:a}=e,o=[{transport:new i},...a?[{transport:new s(a)}]:[]].map(e=>e.transport),l=new n(o),c=new r(l,t??"info");return this.logger=c,this.initialized=!0,this.logger}catch(e){return console.error("Failed to initialize debug module:",e),this.initializationPromise=null,null}}getLogger(){return this.logger}isInitialized(){return this.initialized}reset(){this.initialized=!1,this.logger=null,this.initializationPromise=null}}async function l(e={}){return o.getInstance().initialize(e)}},6125(e,t,a){let r,n,i,s,o,l,c;a.d(t,{QueryClient:()=>V});var u={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},d=new class{#e=u;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},h="u"<typeof window||"Deno"in globalThis;function m(){}function p(e,t){return"function"==typeof e?e(t):e}function f(e,t){let{type:a="all",exact:r,fetchStatus:n,predicate:i,queryKey:s,stale:o}=e;if(s){if(r){if(t.queryHash!==b(s,t.options))return!1}else if(!w(t.queryKey,s))return!1}if("all"!==a){let e=t.isActive();if("active"===a&&!e||"inactive"===a&&e)return!1}return("boolean"!=typeof o||t.isStale()===o)&&(!n||n===t.state.fetchStatus)&&(!i||!!i(t))}function g(e,t){let{exact:a,status:r,predicate:n,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(a){if(y(t.options.mutationKey)!==y(i))return!1}else if(!w(t.options.mutationKey,i))return!1}return(!r||t.state.status===r)&&(!n||!!n(t))}function b(e,t){return(t?.queryKeyHashFn||y)(e)}function y(e){return JSON.stringify(e,(e,t)=>_(t)?Object.keys(t).sort().reduce((e,a)=>(e[a]=t[a],e),{}):t)}function w(e,t){return e===t||typeof e==typeof t&&!!e&&!!t&&"object"==typeof e&&"object"==typeof t&&Object.keys(t).every(a=>w(e[a],t[a]))}var k=Object.prototype.hasOwnProperty;function v(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function _(e){if(!x(e))return!1;let t=e.constructor;if(void 0===t)return!0;let a=t.prototype;return!!x(a)&&!!a.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function x(e){return"[object Object]"===Object.prototype.toString.call(e)}function j(e,t,a=0){let r=[...e,t];return a&&r.length>a?r.slice(1):r}function z(e,t,a=0){let r=[t,...e];return a&&r.length>a?r.slice(0,-1):r}var S=Symbol();function I(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==S?e.queryFn:()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`))}var A=(r=[],n=0,i=e=>{e()},s=e=>{e()},o=function(e){setTimeout(e,0)},{batch:e=>{let t;n++;try{t=e()}finally{let e;--n||(e=r,r=[],e.length&&o(()=>{s(()=>{e.forEach(e=>{i(e)})})}))}return t},batchCalls:e=>(...t)=>{l(()=>{e(...t)})},schedule:l=e=>{n?r.push(e):o(()=>{i(e)})},setNotifyFunction:e=>{i=e},setBatchNotifyFunction:e=>{s=e},setScheduler:e=>{o=e}}),C=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},E=new class extends C{#a;#r;#n;constructor(){super(),this.#n=e=>{if("u">typeof window&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#r||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#r?.(),this.#r=void 0)}setEventListener(e){this.#n=e,this.#r?.(),this.#r=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#a!==e&&(this.#a=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#a?this.#a:globalThis.document?.visibilityState!=="hidden"}},P=new class extends C{#i=!0;#r;#n;constructor(){super(),this.#n=e=>{if("u">typeof window&&window.addEventListener){let t=()=>e(!0),a=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",a,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",a)}}}}onSubscribe(){this.#r||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#r?.(),this.#r=void 0)}setEventListener(e){this.#n=e,this.#r?.(),this.#r=e(this.setOnline.bind(this))}setOnline(e){this.#i!==e&&(this.#i=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#i}},q=(c=()=>h,{isServer:()=>c(),setIsServer(e){c=e}});function O(e){return Math.min(1e3*2**e,3e4)}function T(e){return(e??"online")!=="online"||P.isOnline()}var U=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function M(e){let t,a=!1,r=0,n=function(){let e,t,a=new Promise((a,r)=>{e=a,t=r});function r(e){Object.assign(a,e),delete a.resolve,delete a.reject}return a.status="pending",a.catch(()=>{}),a.resolve=t=>{r({status:"fulfilled",value:t}),e(t)},a.reject=e=>{r({status:"rejected",reason:e}),t(e)},a}(),i=()=>E.isFocused()&&("always"===e.networkMode||P.isOnline())&&e.canRun(),s=()=>T(e.networkMode)&&e.canRun(),o=e=>{"pending"===n.status&&(t?.(),n.resolve(e))},l=e=>{"pending"===n.status&&(t?.(),n.reject(e))},c=()=>new Promise(a=>{t=e=>{("pending"!==n.status||i())&&a(e)},e.onPause?.()}).then(()=>{t=void 0,"pending"===n.status&&e.onContinue?.()}),u=()=>{let t;if("pending"!==n.status)return;let s=0===r?e.initialPromise:void 0;try{t=s??e.fn()}catch(e){t=Promise.reject(e)}Promise.resolve(t).then(o).catch(t=>{if("pending"!==n.status)return;let s=e.retry??3*!q.isServer(),o=e.retryDelay??O,h="function"==typeof o?o(r,t):o,m=!0===s||"number"==typeof s&&r<s||"function"==typeof s&&s(r,t);a||!m?l(t):(r++,e.onFail?.(r,t),new Promise(e=>{d.setTimeout(e,h)}).then(()=>i()?void 0:c()).then(()=>{a?l(t):u()}))})};return{promise:n,status:()=>n.status,cancel:t=>{if("pending"===n.status){let a=new U(t);l(a),e.onCancel?.(a)}},continue:()=>(t?.(),n),cancelRetry:()=>{a=!0},continueRetry:()=>{a=!1},canStart:s,start:()=>(s()?u():c().then(u),n)}}var R=class{#s;destroy(){this.clearGcTimeout()}scheduleGc(){var e;this.clearGcTimeout(),"number"==typeof(e=this.gcTime)&&e>=0&&e!==1/0&&(this.#s=d.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(q.isServer()?1/0:3e5))}clearGcTimeout(){void 0!==this.#s&&(d.clearTimeout(this.#s),this.#s=void 0)}};function N(e,{pages:t,pageParams:a}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,a[r],a):void 0}var B=class extends R{#o;#l;#c;#u;#d;#h;#m;#p;constructor(e){super(),this.#p=!1,this.#m=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#d=e.client,this.#u=this.#d.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#l=F(this.options),this.state=e.state??this.#l,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#o}get promise(){return this.#h?.promise}setOptions(e){if(this.options={...this.#m,...e},e?._type&&(this.#o=e._type),this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){let e=F(this.options);void 0!==e.data&&(this.setState(D(e.data,e.dataUpdatedAt)),this.#l=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#u.remove(this)}setData(e,t){var a,r;let n=(a=this.state.data,"function"==typeof(r=this.options).structuralSharing?r.structuralSharing(a,e):!1!==r.structuralSharing?function e(t,a,r=0){if(t===a)return t;if(r>500)return a;let n=v(t)&&v(a);if(!n&&!(_(t)&&_(a)))return a;let i=(n?t:Object.keys(t)).length,s=n?a:Object.keys(a),o=s.length,l=n?Array(o):{},c=0;for(let u=0;u<o;u++){let o=n?u:s[u],d=t[o],h=a[o];if(d===h){l[o]=d,(n?u<i:k.call(t,o))&&c++;continue}if(null===d||null===h||"object"!=typeof d||"object"!=typeof h){l[o]=h;continue}let m=e(d,h,r+1);l[o]=m,m===d&&c++}return i===o&&c===i?t:l}(a,e):e);return this.#f({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#f({type:"setState",state:e})}cancel(e){let t=this.#h?.promise;return this.#h?.cancel(e),t?t.then(m).catch(m):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#l}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>{var t;return!1!==(t=e.options.enabled,"function"==typeof t?t(this):t)})}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===S||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===p(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!Math.max(this.state.dataUpdatedAt+(e||0)-Date.now(),0))}onFocus(){let e=this.observers.find(e=>e.shouldFetchOnWindowFocus());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}onOnline(){let e=this.observers.find(e=>e.shouldFetchOnReconnect());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#u.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#h&&(this.#p||this.#g()?this.#h.cancel({revert:!0}):this.#h.cancelRetry()),this.scheduleGc()),this.#u.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#g(){return"paused"===this.state.fetchStatus&&"pending"===this.state.status}invalidate(){this.state.isInvalidated||this.#f({type:"invalidate"})}async fetch(e,t){var a;let r;if("idle"!==this.state.fetchStatus&&this.#h?.status()!=="rejected"){if(void 0!==this.state.data&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#h)return this.#h.continueRetry(),this.#h.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,i=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#p=!0,n.signal)})},s=()=>{let e,a=I(this.options,t),r=(i(e={client:this.#d,queryKey:this.queryKey,meta:this.meta}),e);return(this.#p=!1,this.options.persister)?this.options.persister(a,r,this):a(r)},o=(i(r={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#d,state:this.state,fetchFn:s}),r),l="infinite"===this.#o?(a=this.options.pages,{onFetch:(e,t)=>{let r=e.options,n=e.fetchOptions?.meta?.fetchMore?.direction,i=e.state.data?.pages||[],s=e.state.data?.pageParams||[],o={pages:[],pageParams:[]},l=0,c=async()=>{let t=!1,c=I(e.options,e.fetchOptions),u=async(a,r,n)=>{if(t)return Promise.reject(e.signal.reason);if(null==r&&a.pages.length)return Promise.resolve(a);let i=(()=>{var a,i;let s,o,l={client:e.client,queryKey:e.queryKey,pageParam:r,direction:n?"backward":"forward",meta:e.options.meta};return a=()=>e.signal,i=()=>t=!0,o=!1,Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(s??=a(),o||(o=!0,s.aborted?i():s.addEventListener("abort",i,{once:!0})),s)}),l})(),s=await c(i),{maxPages:o}=e.options,l=n?z:j;return{pages:l(a.pages,s,o),pageParams:l(a.pageParams,r,o)}};if(n&&i.length){let e="backward"===n,t={pages:i,pageParams:s},a=(e?function(e,{pages:t,pageParams:a}){return t.length>0?e.getPreviousPageParam?.(t[0],t,a[0],a):void 0}:N)(r,t);o=await u(t,a,e)}else{let e=a??i.length;do{let e=0===l?s[0]??r.initialPageParam:N(r,o);if(l>0&&null==e)break;o=await u(o,e),l++}while(l<e)}return o};e.options.persister?e.fetchFn=()=>e.options.persister?.(c,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},t):e.fetchFn=c}}):this.options.behavior;l?.onFetch(o,this),this.#c=this.state,("idle"===this.state.fetchStatus||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#f({type:"fetch",meta:o.fetchOptions?.meta}),this.#h=M({initialPromise:t?.initialPromise,fn:o.fetchFn,onCancel:e=>{e instanceof U&&e.revert&&this.setState({...this.#c,fetchStatus:"idle"}),n.abort()},onFail:(e,t)=>{this.#f({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#f({type:"pause"})},onContinue:()=>{this.#f({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{let e=await this.#h.start();if(void 0===e)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#u.config.onSuccess?.(e,this),this.#u.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof U){if(e.silent)return this.#h.promise;else if(e.revert){if(void 0===this.state.data)throw e;return this.state.data}}throw this.#f({type:"error",error:e}),this.#u.config.onError?.(e,this),this.#u.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#f(e){let t=t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":var a;return{...t,...(a=t.data,{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:T(this.options.networkMode)?"fetching":"paused",...void 0===a&&{error:null,status:"pending"}}),fetchMeta:e.meta??null};case"success":let r={...t,...D(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#c=e.manual?r:void 0,r;case"error":let n=e.error;return{...t,error:n,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}};this.state=t(this.state),A.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#u.notify({query:this,type:"updated",action:e})})}};function D(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function F(e){let t="function"==typeof e.initialData?e.initialData():e.initialData,a=void 0!==t,r=a?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:a?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:a?"success":"pending",fetchStatus:"idle"}}var L=class extends C{constructor(e={}){super(),this.config=e,this.#b=new Map}#b;build(e,t,a){let r=t.queryKey,n=t.queryHash??b(r,t),i=this.get(n);return i||(i=new B({client:e,queryKey:r,queryHash:n,options:e.defaultQueryOptions(t),state:a,defaultOptions:e.getQueryDefaults(r)}),this.add(i)),i}add(e){this.#b.has(e.queryHash)||(this.#b.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#b.get(e.queryHash);t&&(e.destroy(),t===e&&this.#b.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){A.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#b.get(e)}getAll(){return[...this.#b.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>f(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>f(e,t)):t}notify(e){A.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){A.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){A.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},W=class extends R{#d;#y;#w;#h;constructor(e){super(),this.#d=e.client,this.mutationId=e.mutationId,this.#w=e.mutationCache,this.#y=[],this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#y.includes(e)||(this.#y.push(e),this.clearGcTimeout(),this.#w.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#y=this.#y.filter(t=>t!==e),this.scheduleGc(),this.#w.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#y.length||("pending"===this.state.status?this.scheduleGc():this.#w.remove(this))}continue(){return this.#h?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#f({type:"continue"})},a={client:this.#d,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#h=M({fn:()=>this.options.mutationFn?this.options.mutationFn(e,a):Promise.reject(Error("No mutationFn found")),onFail:(e,t)=>{this.#f({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#f({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#w.canRun(this)});let r="pending"===this.state.status,n=!this.#h.canStart();try{if(r)t();else{this.#f({type:"pending",variables:e,isPaused:n}),this.#w.config.onMutate&&await this.#w.config.onMutate(e,this,a);let t=await this.options.onMutate?.(e,a);t!==this.state.context&&this.#f({type:"pending",context:t,variables:e,isPaused:n})}let i=await this.#h.start();return await this.#w.config.onSuccess?.(i,e,this.state.context,this,a),await this.options.onSuccess?.(i,e,this.state.context,a),await this.#w.config.onSettled?.(i,null,this.state.variables,this.state.context,this,a),await this.options.onSettled?.(i,null,e,this.state.context,a),this.#f({type:"success",data:i}),i}catch(t){try{await this.#w.config.onError?.(t,e,this.state.context,this,a)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,a)}catch(e){Promise.reject(e)}try{await this.#w.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,a)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,a)}catch(e){Promise.reject(e)}throw this.#f({type:"error",error:t}),t}finally{this.#w.runNext(this)}}#f(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),A.batch(()=>{this.#y.forEach(t=>{t.onMutationUpdate(e)}),this.#w.notify({mutation:this,type:"updated",action:e})})}},K=class extends C{constructor(e={}){super(),this.config=e,this.#k=new Set,this.#v=new Map,this.#_=0}#k;#v;#_;build(e,t,a){let r=new W({client:e,mutationCache:this,mutationId:++this.#_,options:e.defaultMutationOptions(t),state:a});return this.add(r),r}add(e){this.#k.add(e);let t=H(e);if("string"==typeof t){let a=this.#v.get(t);a?a.push(e):this.#v.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#k.delete(e)){let t=H(e);if("string"==typeof t){let a=this.#v.get(t);if(a)if(a.length>1){let t=a.indexOf(e);-1!==t&&a.splice(t,1)}else a[0]===e&&this.#v.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=H(e);if("string"!=typeof t)return!0;{let a=this.#v.get(t),r=a?.find(e=>"pending"===e.state.status);return!r||r===e}}runNext(e){let t=H(e);if("string"!=typeof t)return Promise.resolve();{let a=this.#v.get(t)?.find(t=>t!==e&&t.state.isPaused);return a?.continue()??Promise.resolve()}}clear(){A.batch(()=>{this.#k.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#k.clear(),this.#v.clear()})}getAll(){return Array.from(this.#k)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>g(t,e))}findAll(e={}){return this.getAll().filter(t=>g(e,t))}notify(e){A.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return A.batch(()=>Promise.all(e.map(e=>e.continue().catch(m))))}};function H(e){return e.options.scope?.id}var V=class{#x;#w;#m;#j;#z;#S;#I;#A;constructor(e={}){this.#x=e.queryCache||new L,this.#w=e.mutationCache||new K,this.#m=e.defaultOptions||{},this.#j=new Map,this.#z=new Map,this.#S=0}mount(){this.#S++,1===this.#S&&(this.#I=E.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#x.onFocus())}),this.#A=P.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#x.onOnline())}))}unmount(){this.#S--,0===this.#S&&(this.#I?.(),this.#I=void 0,this.#A?.(),this.#A=void 0)}isFetching(e){return this.#x.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#w.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#x.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),a=this.#x.build(this,t),r=a.state.data;return void 0===r?this.fetchQuery(e):(e.revalidateIfStale&&a.isStaleByTime(p(t.staleTime,a))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#x.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,a){let r=this.defaultQueryOptions({queryKey:e}),n=this.#x.get(r.queryHash),i=n?.state.data,s="function"==typeof t?t(i):t;if(void 0!==s)return this.#x.build(this,r).setData(s,{...a,manual:!0})}setQueriesData(e,t,a){return A.batch(()=>this.#x.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,a)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#x.get(t.queryHash)?.state}removeQueries(e){let t=this.#x;A.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let a=this.#x;return A.batch(()=>(a.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let a={revert:!0,...t};return Promise.all(A.batch(()=>this.#x.findAll(e).map(e=>e.cancel(a)))).then(m).catch(m)}invalidateQueries(e,t={}){return A.batch(()=>(this.#x.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType==="none")?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t))}refetchQueries(e,t={}){let a={...t,cancelRefetch:t.cancelRefetch??!0};return Promise.all(A.batch(()=>this.#x.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,a);return a.throwOnError||(t=t.catch(m)),"paused"===e.state.fetchStatus?Promise.resolve():t}))).then(m)}fetchQuery(e){let t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);let a=this.#x.build(this,t);return a.isStaleByTime(p(t.staleTime,a))?a.fetch(t):Promise.resolve(a.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(m).catch(m)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(m).catch(m)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return P.isOnline()?this.#w.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#x}getMutationCache(){return this.#w}getDefaultOptions(){return this.#m}setDefaultOptions(e){this.#m=e}setQueryDefaults(e,t){this.#j.set(y(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#j.values()],a={};return t.forEach(t=>{w(e,t.queryKey)&&Object.assign(a,t.defaultOptions)}),a}setMutationDefaults(e,t){this.#z.set(y(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#z.values()],a={};return t.forEach(t=>{w(e,t.mutationKey)&&Object.assign(a,t.defaultOptions)}),a}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#m.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=b(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===S&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#m.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#x.clear(),this.#w.clear()}}},3009(e,t){t.rotlSL=t.rotlSH=t.rotlBL=t.rotlBH=void 0,t.split=function(e,t=!1){let n=e.length,i=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;o<n;o++){let{h:n,l}=function(e,t=!1){return t?{h:Number(e&a),l:Number(e>>r&a)}:{h:0|Number(e>>r&a),l:0|Number(e&a)}}(e[o],t);[i[o],s[o]]=[n,l]}return[i,s]};let a=BigInt(0x100000000-1),r=BigInt(32);t.rotlSH=(e,t,a)=>e<<a|t>>>32-a;t.rotlSL=(e,t,a)=>t<<a|e>>>32-a;t.rotlBH=(e,t,a)=>t<<a-32|e>>>64-a;t.rotlBL=(e,t,a)=>e<<a-32|t>>>64-a},8510(e,t){t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},5376(e,t,a){t.keccak_256=void 0;let r=a(3009),n=a(6770),i=BigInt(0),s=BigInt(1),o=BigInt(2),l=BigInt(7),c=BigInt(256),u=BigInt(113),d=[],h=[],m=[];for(let e=0,t=s,a=1,r=0;e<24;e++){[a,r]=[r,(2*a+3*r)%5],d.push(2*(5*r+a)),h.push((e+1)*(e+2)/2%64);let n=i;for(let e=0;e<7;e++)(t=(t<<s^(t>>l)*u)%c)&o&&(n^=s<<(s<<BigInt(e))-s);m.push(n)}let p=(0,r.split)(m,!0),f=p[0],g=p[1],b=(e,t,a)=>a>32?(0,r.rotlBH)(e,t,a):(0,r.rotlSH)(e,t,a),y=(e,t,a)=>a>32?(0,r.rotlBL)(e,t,a):(0,r.rotlSL)(e,t,a);class w extends n.Hash{constructor(e,t,a,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=a,this.enableXOF=r,this.rounds=i,(0,n.anumber)(a),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,n.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,n.swap32IfBE)(this.state32),function(e,t=24){let a=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)a[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,n=(t+2)%10,i=a[n],s=a[n+1],o=b(i,s,1)^a[r],l=y(i,s,1)^a[r+1];for(let a=0;a<50;a+=10)e[t+a]^=o,e[t+a+1]^=l}let t=e[2],n=e[3];for(let a=0;a<24;a++){let r=h[a],i=b(t,n,r),s=y(t,n,r),o=d[a];t=e[o],n=e[o+1],e[o]=i,e[o+1]=s}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)a[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~a[(r+2)%10]&a[(r+4)%10]}e[0]^=f[r],e[1]^=g[r]}(0,n.clean)(a)}(this.state32,this.rounds),(0,n.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(e){(0,n.aexists)(this),e=(0,n.toBytes)(e),(0,n.abytes)(e);let{blockLen:t,state:a}=this,r=e.length;for(let n=0;n<r;){let i=Math.min(t-this.pos,r-n);for(let t=0;t<i;t++)a[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:a,blockLen:r}=this;e[a]^=t,(128&t)!=0&&a===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){(0,n.aexists)(this,!1),(0,n.abytes)(e),this.finish();let t=this.state,{blockLen:a}=this;for(let r=0,n=e.length;r<n;){this.posOut>=a&&this.keccak();let i=Math.min(a-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,n.anumber)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,n.aoutput)(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,(0,n.clean)(this.state)}_cloneInto(e){let{blockLen:t,suffix:a,outputLen:r,rounds:n,enableXOF:i}=this;return e||(e=new w(t,a,r,i,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=a,e.outputLen=r,e.enableXOF=i,e.destroyed=this.destroyed,e}}let k=(e,t,a)=>(0,n.createHasher)(()=>new w(t,e,a));k(6,144,28),k(6,136,32),k(6,104,48),k(6,72,64),k(1,144,28),t.keccak_256=k(1,136,32),k(1,104,48),k(1,72,64);let v=(e,t,a)=>(0,n.createXOFer)((r={})=>new w(t,e,void 0===r.dkLen?a:r.dkLen,!0));v(31,168,16),v(31,136,32)},6770(e,t,a){t.Hash=t.dY=t.swap32IfBE=t.Y1=t.qv=void 0,t.anumber=function(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)},t.abytes=r,t.aexists=function(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")},t.aoutput=function(e,t){r(e);let a=t.outputLen;if(e.length<a)throw Error("digestInto() expects output buffer of length at least "+a)},t.u32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))},t.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)},t.toBytes=i,t.createHasher=function(e){let t=t=>e().update(i(t)).digest(),a=e();return t.outputLen=a.outputLen,t.blockLen=a.blockLen,t.create=()=>e(),t},t.createXOFer=function(e){let t=(t,a)=>e(a).update(i(t)).digest(),a=e({});return t.outputLen=a.outputLen,t.blockLen=a.blockLen,t.create=t=>e(t),t},a(8510);function r(e,...t){if(!(e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function n(e){return e<<24&0xff000000|e<<8&0xff0000|e>>>8&65280|e>>>24&255}t.qv=68===new Uint8Array(new Uint32Array([0x11223344]).buffer)[0],t.Y1=t.qv?e=>e:e=>n(e),t.Y1,t.swap32IfBE=t.qv?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=n(e[t]);return e},"function"==typeof Uint8Array.from([]).toHex&&Uint8Array.fromHex,(e,t)=>t.toString(16).padStart(2,"0");t.dY=async()=>{};function i(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}(e)),r(e),e}t.Hash=class{}},3239(e,t,a){a.r(t),a.d(t,{Options:()=>A,debounce:()=>en,zxcvbn:()=>el,zxcvbnAsync:()=>ec,zxcvbnOptions:()=>C});let r=(e,t)=>e.push.apply(e,t),n=e=>e.sort((e,t)=>e.i-t.i||e.j-t.j),i=e=>{let t={},a=1;return e.forEach(e=>{t[e]=a,a+=1}),t},s={4:[[1,2],[2,3]],5:[[1,3],[2,3],[2,4]],6:[[1,2],[2,4],[4,5]],7:[[1,3],[2,3],[4,5],[4,6]],8:[[2,4],[4,6]]},o=/^[A-Z\xbf-\xdf][^A-Z\xbf-\xdf]+$/,l=/^[^A-Z\xbf-\xdf]+[A-Z\xbf-\xdf]$/,c=/^[A-Z\xbf-\xdf]+$/,u=/^[^a-z\xdf-\xff]+$/,d=/^[a-z\xdf-\xff]+$/,h=/^[^A-Z\xbf-\xdf]+$/,m=/[a-z\xdf-\xff]/,p=/[A-Z\xbf-\xdf]/,f=/[^A-Za-z\xbf-\xdf]/gi,g=/^\d+$/,b=new Date().getFullYear(),y={recentYear:/19\d\d|200\d|201\d|202\d/g},w=[" ",",",";",":","|","/","\\","_",".","-"],k=w.length;class v{match({password:e}){let t=[...this.getMatchesWithoutSeparator(e),...this.getMatchesWithSeparator(e)];return n(this.filterNoise(t))}getMatchesWithSeparator(e){let t=[],a=/^(\d{1,4})([\s/\\_.-])(\d{1,2})\2(\d{1,4})$/;for(let r=0;r<=Math.abs(e.length-6);r+=1)for(let n=r+5;n<=r+9&&!(n>=e.length);n+=1){let i=e.slice(r,+n+1||9e9),s=a.exec(i);if(null!=s){let e=this.mapIntegersToDayMonthYear([parseInt(s[1],10),parseInt(s[3],10),parseInt(s[4],10)]);null!=e&&t.push({pattern:"date",token:i,i:r,j:n,separator:s[2],year:e.year,month:e.month,day:e.day})}}return t}getMatchesWithoutSeparator(e){let t=[],a=/^\d{4,8}$/,r=e=>Math.abs(e.year-b);for(let n=0;n<=Math.abs(e.length-4);n+=1)for(let i=n+3;i<=n+7&&!(i>=e.length);i+=1){let o=e.slice(n,+i+1||9e9);if(a.exec(o)){let e=[];if(s[o.length].forEach(([t,a])=>{let r=this.mapIntegersToDayMonthYear([parseInt(o.slice(0,t),10),parseInt(o.slice(t,a),10),parseInt(o.slice(a),10)]);null!=r&&e.push(r)}),e.length>0){let a=e[0],s=r(e[0]);e.slice(1).forEach(e=>{let t=r(e);t<s&&(a=e,s=t)}),t.push({pattern:"date",token:o,i:n,j:i,separator:"",year:a.year,month:a.month,day:a.day})}}}return t}filterNoise(e){return e.filter(t=>{let a=!1,r=e.length;for(let n=0;n<r;n+=1){let r=e[n];if(t!==r&&r.i<=t.i&&r.j>=t.j){a=!0;break}}return!a})}mapIntegersToDayMonthYear(e){if(e[1]>31||e[1]<=0)return null;let t=0,a=0,r=0;for(let n=0,i=e.length;n<i;n+=1){let i=e[n];if(i>99&&i<1e3||i>2050)return null;i>31&&(a+=1),i>12&&(t+=1),i<=0&&(r+=1)}return a>=2||3===t||r>=2?null:this.getDayMonth(e)}getDayMonth(e){let t=[[e[2],e.slice(0,2)],[e[0],e.slice(1,3)]],a=t.length;for(let e=0;e<a;e+=1){let[a,r]=t[e];if(1e3<=a&&a<=2050){let e=this.mapIntegersToDayMonth(r);if(null!=e)return{year:a,month:e.month,day:e.day};return null}}for(let e=0;e<a;e+=1){let[a,r]=t[e],n=this.mapIntegersToDayMonth(r);if(null!=n)return{year:this.twoToFourDigitYear(a),month:n.month,day:n.day}}return null}mapIntegersToDayMonth(e){let t=[e,e.slice().reverse()];for(let e=0;e<t.length;e+=1){let a=t[e],r=a[0],n=a[1];if(r>=1&&r<=31&&n>=1&&n<=12)return{day:r,month:n}}return null}twoToFourDigitYear(e){return e>99?e:e>50?e+1900:e+2e3}}let _=new Uint32Array(65536),x=(e,t,a)=>{let r=0,n=Object.keys(t).find(t=>{let n,i,s=(n=e.length<=t.length,i=e.length<=a,n||i?Math.ceil(e.length/4):a);if(Math.abs(e.length-t.length)>s)return!1;let o=((e,t)=>{if(e.length<t.length){let a=t;t=e,e=a}return 0===t.length?e.length:e.length<=32?((e,t)=>{let a=e.length,r=t.length,n=1<<a-1,i=-1,s=0,o=a,l=a;for(;l--;)_[e.charCodeAt(l)]|=1<<l;for(l=0;l<r;l++){let e=_[t.charCodeAt(l)],a=e|s;e|=(e&i)+i^i,s|=~(e|i),i&=e,s&n&&o++,i&n&&o--,i=i<<1|~(a|(s=s<<1|1)),s&=a}for(l=a;l--;)_[e.charCodeAt(l)]=0;return o})(e,t):((e,t)=>{let a=t.length,r=e.length,n=[],i=[],s=Math.ceil(a/32),o=Math.ceil(r/32);for(let e=0;e<s;e++)i[e]=-1,n[e]=0;let l=0;for(;l<o-1;l++){let s=0,o=-1,c=32*l,u=Math.min(32,r)+c;for(let t=c;t<u;t++)_[e.charCodeAt(t)]|=1<<t;for(let e=0;e<a;e++){let a=_[t.charCodeAt(e)],r=i[e/32|0]>>>e&1,l=n[e/32|0]>>>e&1,c=a|s,u=((a|l)&o)+o^o|a|l,d=s|~(u|o),h=o&u;d>>>31^r&&(i[e/32|0]^=1<<e),h>>>31^l&&(n[e/32|0]^=1<<e),d=d<<1|r,o=(h=h<<1|l)|~(c|d),s=d&c}for(let t=c;t<u;t++)_[e.charCodeAt(t)]=0}let c=0,u=-1,d=32*l,h=Math.min(32,r-d)+d;for(let t=d;t<h;t++)_[e.charCodeAt(t)]|=1<<t;let m=r;for(let e=0;e<a;e++){let a=_[t.charCodeAt(e)],s=i[e/32|0]>>>e&1,o=n[e/32|0]>>>e&1,l=a|c,d=((a|o)&u)+u^u|a|o,h=c|~(d|u),p=u&d;m+=h>>>r-1&1,m-=p>>>r-1&1,h>>>31^s&&(i[e/32|0]^=1<<e),p>>>31^o&&(n[e/32|0]^=1<<e),h=h<<1|s,u=(p=p<<1|o)|~(l|h),c=h&l}for(let t=d;t<h;t++)_[e.charCodeAt(t)]=0;return m})(e,t)})(e,t),l=o<=s;return l&&(r=o),l});return n?{levenshteinDistance:r,levenshteinDistanceEntry:n}:{}};var j={a:["4","@"],b:["8"],c:["(","{","[","<"],d:["6","|)"],e:["3"],f:["#"],g:["6","9","&"],h:["#","|-|"],i:["1","!","|"],k:["<","|<"],l:["!","1","|","7"],m:["^^","nn","2n","/\\\\/\\\\"],n:["//"],o:["0","()"],q:["9"],u:["|_|"],s:["$","5"],t:["+","7"],v:["<",">","/"],w:["^/","uu","vv","2u","2v","\\\\/\\\\/"],x:["%","><"],z:["2"]},z={warnings:{straightRow:"straightRow",keyPattern:"keyPattern",simpleRepeat:"simpleRepeat",extendedRepeat:"extendedRepeat",sequences:"sequences",recentYears:"recentYears",dates:"dates",topTen:"topTen",topHundred:"topHundred",common:"common",similarToCommon:"similarToCommon",wordByItself:"wordByItself",namesByThemselves:"namesByThemselves",commonNames:"commonNames",userInputs:"userInputs",pwned:"pwned"},suggestions:{l33t:"l33t",reverseWords:"reverseWords",allUppercase:"allUppercase",capitalization:"capitalization",dates:"dates",recentYears:"recentYears",associatedYears:"associatedYears",sequences:"sequences",repeated:"repeated",longerKeyboardPattern:"longerKeyboardPattern",anotherWord:"anotherWord",useWords:"useWords",noNeed:"noNeed",pwned:"pwned"},timeEstimation:{ltSecond:"ltSecond",second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",month:"month",months:"months",year:"year",years:"years",centuries:"centuries"}};class S{constructor(e=[]){this.parents=e,this.children=new Map}addSub(e,...t){let a=e.charAt(0);this.children.has(a)||this.children.set(a,new S([...this.parents,a]));let r=this.children.get(a);for(let t=1;t<e.length;t+=1){let a=e.charAt(t);r.hasChild(a)||r.addChild(a),r=r.getChild(a)}return r.subs=(r.subs||[]).concat(t),this}getChild(e){return this.children.get(e)}isTerminal(){return!!this.subs}addChild(e){this.hasChild(e)||this.children.set(e,new S([...this.parents,e]))}hasChild(e){return this.children.has(e)}}var I=(e,t)=>(Object.entries(e).forEach(([e,a])=>{a.forEach(a=>{t.addSub(a,e)})}),t);class A{constructor(){this.matchers={},this.l33tTable=j,this.trieNodeRoot=I(j,new S),this.dictionary={userInputs:[]},this.rankedDictionaries={},this.rankedDictionariesMaxWordSize={},this.translations=z,this.graphs={},this.useLevenshteinDistance=!1,this.levenshteinThreshold=2,this.l33tMaxSubstitutions=100,this.maxLength=256,this.setRankedDictionaries()}setOptions(e={}){e.l33tTable&&(this.l33tTable=e.l33tTable,this.trieNodeRoot=I(e.l33tTable,new S)),e.dictionary&&(this.dictionary=e.dictionary,this.setRankedDictionaries()),e.translations&&this.setTranslations(e.translations),e.graphs&&(this.graphs=e.graphs),void 0!==e.useLevenshteinDistance&&(this.useLevenshteinDistance=e.useLevenshteinDistance),void 0!==e.levenshteinThreshold&&(this.levenshteinThreshold=e.levenshteinThreshold),void 0!==e.l33tMaxSubstitutions&&(this.l33tMaxSubstitutions=e.l33tMaxSubstitutions),void 0!==e.maxLength&&(this.maxLength=e.maxLength)}setTranslations(e){if(this.checkCustomTranslations(e))this.translations=e;else throw Error("Invalid translations object fallback to keys")}checkCustomTranslations(e){let t=!0;return Object.keys(z).forEach(a=>{a in e?Object.keys(z[a]).forEach(r=>{r in e[a]||(t=!1)}):t=!1}),t}setRankedDictionaries(){let e={},t={};Object.keys(this.dictionary).forEach(a=>{e[a]=i(this.dictionary[a]),t[a]=this.getRankedDictionariesMaxWordSize(this.dictionary[a])}),this.rankedDictionaries=e,this.rankedDictionariesMaxWordSize=t}getRankedDictionariesMaxWordSize(e){let t=e.map(e=>"string"!=typeof e?e.toString().length:e.length);return 0===t.length?0:t.reduce((e,t)=>Math.max(e,t),-1/0)}buildSanitizedRankedDictionary(e){let t=[];return e.forEach(e=>{let a=typeof e;("string"===a||"number"===a||"boolean"===a)&&t.push(e.toString().toLowerCase())}),i(t)}extendUserInputsDictionary(e){this.dictionary.userInputs||(this.dictionary.userInputs=[]);let t=[...this.dictionary.userInputs,...e];this.rankedDictionaries.userInputs=this.buildSanitizedRankedDictionary(t),this.rankedDictionariesMaxWordSize.userInputs=this.getRankedDictionariesMaxWordSize(t)}addMatcher(e,t){this.matchers[e]?console.info(`Matcher ${e} already exists`):this.matchers[e]=t}}let C=new A;class E{constructor(e){this.defaultMatch=e}match({password:e}){let t=e.split("").reverse().join("");return this.defaultMatch({password:t}).map(t=>({...t,token:t.token.split("").reverse().join(""),reversed:!0,i:e.length-1-t.j,j:e.length-1-t.i}))}}class P{constructor({substr:e,limit:t,trieRoot:a}){this.buffer=[],this.finalPasswords=[],this.substr=e,this.limit=t,this.trieRoot=a}getAllPossibleSubsAtIndex(e){let t=[],a=this.trieRoot;for(let r=e;r<this.substr.length;r+=1){let e=this.substr.charAt(r);if(!(a=a.getChild(e)))break;t.push(a)}return t}helper({onlyFullSub:e,isFullSub:t,index:a,subIndex:r,changes:n,lastSubLetter:i,consecutiveSubCount:s}){if(this.finalPasswords.length>=this.limit)return;if(a===this.substr.length){e===t&&this.finalPasswords.push({password:this.buffer.join(""),changes:n});return}let o=[...this.getAllPossibleSubsAtIndex(a)],l=!1;for(let c=a+o.length-1;c>=a;c-=1){let u=o[c-a];if(u.isTerminal()){if(i===u.parents.join("")&&s>=3)continue;for(let a of(l=!0,u.subs)){this.buffer.push(a);let o=n.concat({i:r,letter:a,substitution:u.parents.join("")});if(this.helper({onlyFullSub:e,isFullSub:t,index:c+1,subIndex:r+a.length,changes:o,lastSubLetter:u.parents.join(""),consecutiveSubCount:i===u.parents.join("")?s+1:1}),this.buffer.pop(),this.finalPasswords.length>=this.limit)return}}}if(!e||!l){let o=this.substr.charAt(a);this.buffer.push(o),this.helper({onlyFullSub:e,isFullSub:t&&!l,index:a+1,subIndex:r+1,changes:n,lastSubLetter:i,consecutiveSubCount:s}),this.buffer.pop()}}getAll(){return this.helper({onlyFullSub:!0,isFullSub:!0,index:0,subIndex:0,changes:[],lastSubLetter:void 0,consecutiveSubCount:0}),this.helper({onlyFullSub:!1,isFullSub:!0,index:0,subIndex:0,changes:[],lastSubLetter:void 0,consecutiveSubCount:0}),this.finalPasswords}}class q{constructor(e){this.defaultMatch=e}isAlreadyIncluded(e,t){return e.some(e=>Object.entries(e).every(([e,a])=>"subs"===e||a===t[e]))}match({password:e}){let t=[],a=new P({substr:e,limit:C.l33tMaxSubstitutions,trieRoot:C.trieNodeRoot}).getAll(),r=!1,n=!0;return a.forEach(a=>{if(r)return;let i=this.defaultMatch({password:a.password,useLevenshtein:n});n=!1,i.forEach(n=>{var i,s;let o,l,c,u,d;r||(r=0===n.i&&n.j===e.length-1);let h=(i=n.i,s=n.j,o=a.changes.filter(e=>e.i<i).reduce((e,t)=>e-t.letter.length+t.substitution.length,i),c=(l=a.changes.filter(e=>e.i>=i&&e.i<=s)).reduce((e,t)=>e-t.letter.length+t.substitution.length,s-i+o),u=[],d=[],l.forEach(e=>{0>u.findIndex(t=>t.letter===e.letter&&t.substitution===e.substitution)&&(u.push({letter:e.letter,substitution:e.substitution}),d.push(`${e.substitution} -> ${e.letter}`))}),{i:o,j:c,subs:u,subDisplay:d.join(", ")}),m=e.slice(h.i,+h.j+1||9e9),p={...n,l33t:!0,token:m,...h},f=this.isAlreadyIncluded(t,p);m.toLowerCase()===n.matchedWord||f||t.push(p)})}),t.filter(e=>e.token.length>1)}}class O{constructor(){this.l33t=new q(this.defaultMatch),this.reverse=new E(this.defaultMatch)}match({password:e}){return n([...this.defaultMatch({password:e}),...this.reverse.match({password:e}),...this.l33t.match({password:e})])}defaultMatch({password:e,useLevenshtein:t=!0}){let a=[],r=e.length,n=e.toLowerCase();return Object.keys(C.rankedDictionaries).forEach(i=>{let s=C.rankedDictionaries[i],o=Math.min(C.rankedDictionariesMaxWordSize[i],r);for(let l=0;l<r;l+=1){let c=Math.min(l+o,r);for(let o=l;o<c;o+=1){let c=n.slice(l,+o+1||9e9),u=c in s,d={},h=0===l&&o===r-1;C.useLevenshteinDistance&&h&&!u&&t&&(d=x(c,s,C.levenshteinThreshold));let m=0!==Object.keys(d).length;if(u||m){let t=s[m?d.levenshteinDistanceEntry:c];a.push({pattern:"dictionary",i:l,j:o,token:e.slice(l,+o+1||9e9),matchedWord:c,rank:t,dictionaryName:i,reversed:!1,l33t:!1,...d})}}}}),a}}class T{match({password:e,regexes:t=y}){let a=[];return Object.keys(t).forEach(r=>{let n,i=t[r];for(i.lastIndex=0;n=i.exec(e);)if(n){let e=n[0];a.push({pattern:"regex",token:e,i:n.index,j:n.index+n[0].length-1,regexName:r,regexMatch:n})}}),n(a)}}var U={nCk(e,t){let a=e;if(t>a)return 0;if(0===t)return 1;let r=1;for(let e=1;e<=t;e+=1)r*=a,r/=e,a-=1;return r},log10:e=>0===e?0:Math.log(e)/Math.log(10),log2:e=>Math.log(e)/Math.log(2),factorial(e){let t=1;for(let a=2;a<=e;a+=1)t*=a;return t}};let M=(e,t)=>{let a=0,r=e.indexOf(t);for(;r>=0;)a+=1,r=e.indexOf(t,r+t.length);return a},R={bruteforce:({token:e})=>{let t=10**e.length;return t===1/0&&(t=Number.MAX_VALUE),Math.max(t,1===e.length?11:51)},date:({year:e,separator:t})=>{let a=365*Math.max(Math.abs(e-b),20);return t&&(a*=4),a},dictionary:({rank:e,reversed:t,l33t:a,subs:r,token:n,dictionaryName:i})=>{let s,c=(e=>{let t=e.replace(f,"");if(t.match(h)||t.toLowerCase()===t)return 1;let a=[o,l,u],r=a.length;for(let e=0;e<r;e+=1){let r=a[e];if(t.match(r))return 2}return(e=>{let t=e.split(""),a=t.filter(e=>e.match(p)).length,r=t.filter(e=>e.match(m)).length,n=0,i=Math.min(a,r);for(let e=1;e<=i;e+=1)n+=U.nCk(a+r,e);return n})(t)})(n),d=(({l33t:e,subs:t,token:a})=>{if(!e)return 1;let r=1;return t.forEach(e=>{let{subbedCount:t,unsubbedCount:n}=(({sub:e,token:t})=>{let a=t.toLowerCase();return{subbedCount:M(a,e.substitution),unsubbedCount:M(a,e.letter)}})({sub:e,token:a});if(0===t||0===n)r*=2;else{let e=Math.min(n,t),a=0;for(let r=1;r<=e;r+=1)a+=U.nCk(n+t,r);r*=a}}),r})({l33t:a,subs:r,token:n});return s="diceware"===i?3888:e*c*d*(t&&2||1),{baseGuesses:e,uppercaseVariations:c,l33tVariations:d,calculation:s}},regex:({regexName:e,regexMatch:t,token:a})=>{let r={alphaLower:26,alphaUpper:26,alpha:52,alphanumeric:62,digits:10,symbols:33};return e in r?r[e]**a.length:"recentYear"===e?Math.max(Math.abs(parseInt(t[0],10)-b),20):0},repeat:({baseGuesses:e,repeatCount:t})=>e*t,sequence:({token:e,ascending:t})=>{let a=e.charAt(0),r=0;return r=["a","A","z","Z","0","1","9"].includes(a)?4:a.match(/\d/)?10:26,t||(r*=2),r*e.length},spatial:({graph:e,token:t,shiftedCount:a,turns:r})=>{let n=(({token:e,graph:t,turns:a})=>{var r;let n,i=Object.keys(C.graphs[t]).length,s=(r=C.graphs[t],n=0,Object.keys(r).forEach(e=>{let t=r[e];n+=t.filter(e=>!!e).length}),n/=Object.entries(r).length),o=0,l=e.length;for(let e=2;e<=l;e+=1){let t=Math.min(a,e-1);for(let a=1;a<=t;a+=1)o+=U.nCk(e-1,a-1)*i*s**a}return o})({token:t,graph:e,turns:r});if(a){let e=t.length-a;if(0===a||0===e)n*=2;else{let t=0;for(let r=1;r<=Math.min(a,e);r+=1)t+=U.nCk(a+e,r);n*=t}}return Math.round(n)},separator:()=>k},N={password:"",optimal:{},excludeAdditive:!1,separatorRegex:void 0,fillArray(e,t){let a=[];for(let r=0;r<e;r+=1){let e=[];"object"===t&&(e={}),a.push(e)}return a},makeBruteforceMatch(e,t){return{pattern:"bruteforce",token:this.password.slice(e,+t+1||9e9),i:e,j:t}},update(e,t){let a=e.j,r=((e,t)=>{var a;let r,n={};if("guesses"in e&&null!=e.guesses)return e;let i=(r=1,e.token.length<t.length&&(r=1===e.token.length?10:50),r),s=(a=e.pattern,R[a]?R[a](e):C.matchers[a]&&"scoring"in C.matchers[a]?C.matchers[a].scoring(e):0),o=0;"number"==typeof s?o=s:"dictionary"===e.pattern&&(o=s.calculation,n.baseGuesses=s.baseGuesses,n.uppercaseVariations=s.uppercaseVariations,n.l33tVariations=s.l33tVariations);let l=Math.max(o,i);return{...e,...n,guesses:l,guessesLog10:U.log10(l)}})(e,this.password),n=r.guesses;t>1&&(n*=this.optimal.pi[r.i-1][t-1]);let i=U.factorial(t)*n;this.excludeAdditive||(i+=1e4**(t-1));let s=!1;Object.keys(this.optimal.g[a]).forEach(e=>{let r=this.optimal.g[a][e];parseInt(e,10)<=t&&r<=i&&(s=!0)}),s||(this.optimal.g[a][t]=i,this.optimal.m[a][t]=r,this.optimal.pi[a][t]=n)},bruteforceUpdate(e){let t=this.makeBruteforceMatch(0,e);this.update(t,1);for(let a=1;a<=e;a+=1){t=this.makeBruteforceMatch(a,e);let r=this.optimal.m[a-1];Object.keys(r).forEach(e=>{"bruteforce"!==r[e].pattern&&this.update(t,parseInt(e,10)+1)})}},unwind(e){let t=[],a=e-1,r=0,n=2e308,i=this.optimal.g[a];for(i&&Object.keys(i).forEach(e=>{let t=i[e];t<n&&(r=parseInt(e,10),n=t)});a>=0;){let e=this.optimal.m[a][r];t.unshift(e),a=e.i-1,r-=1}return t}};var B={mostGuessableMatchSequence(e,t,a=!1){N.password=e,N.excludeAdditive=a;let r=e.length,n=N.fillArray(r,"array");t.forEach(e=>{n[e.j].push(e)}),n=n.map(e=>e.sort((e,t)=>e.i-t.i)),N.optimal={m:N.fillArray(r,"object"),pi:N.fillArray(r,"object"),g:N.fillArray(r,"object")};for(let e=0;e<r;e+=1)n[e].forEach(e=>{e.i>0?Object.keys(N.optimal.m[e.i-1]).forEach(t=>{N.update(e,parseInt(t,10)+1)}):N.update(e,1)}),N.bruteforceUpdate(e);let i=N.unwind(r),s=i.length,o=this.getGuesses(e,s);return{password:e,guesses:o,guessesLog10:U.log10(o),sequence:i}},getGuesses(e,t){let a=e.length;return 0===e.length?1:N.optimal.g[a-1][t]}};class D{match({password:e,omniMatch:t}){let a=[],r=0;for(;r<e.length;){let n=this.getGreedyMatch(e,r),i=this.getLazyMatch(e,r);if(null==n)break;let{match:s,baseToken:o}=this.setMatchToken(n,i);if(s){let e=s.index+s[0].length-1,n=this.getBaseGuesses(o,t);a.push(this.normalizeMatch(o,e,s,n)),r=e+1}}return a.some(e=>e instanceof Promise)?Promise.all(a):a}normalizeMatch(e,t,a,r){let n={pattern:"repeat",i:a.index,j:t,token:a[0],baseToken:e,baseGuesses:0,repeatCount:a[0].length/e.length};return r instanceof Promise?r.then(e=>({...n,baseGuesses:e})):{...n,baseGuesses:r}}getGreedyMatch(e,t){let a=/(.+)\1+/g;return a.lastIndex=t,a.exec(e)}getLazyMatch(e,t){let a=/(.+?)\1+/g;return a.lastIndex=t,a.exec(e)}setMatchToken(e,t){let a,r="";if(t&&e[0].length>t[0].length){a=e;let t=/^(.+?)\1+$/.exec(a[0]);t&&(r=t[1])}else(a=t)&&(r=a[1]);return{match:a,baseToken:r}}getBaseGuesses(e,t){let a=t.match(e);return a instanceof Promise?a.then(t=>B.mostGuessableMatchSequence(e,t).guesses):B.mostGuessableMatchSequence(e,a).guesses}}class F{constructor(){this.MAX_DELTA=5}match({password:e}){let t=[];if(1===e.length)return[];let a=0,r=null,n=e.length;for(let i=1;i<n;i+=1){let n=e.charCodeAt(i)-e.charCodeAt(i-1);if(null==r&&(r=n),n