@clerk/clerk-js
Version:
Clerk JS library
2 lines • 809 kB
JavaScript
var e,a,t={296(e,a,t){t.d(a,{getDebugLogger:()=>l}),t(100);class r{logLevel;transport;constructor(e,a){this.transport=e,this.logLevel=a??"debug"}debug(e,a,t){this.log("debug",e,a,t)}error(e,a,t){this.log("error",e,a,t)}info(e,a,t){this.log("info",e,a,t)}warn(e,a,t){this.log("warn",e,a,t)}log(e,a,t,r){if(!this.shouldLogLevel(e))return;let i={timestamp:Date.now(),level:e,message:a,context:t,source:r};this.transport.send(i).catch(e=>{console.error("Failed to send log entry:",e)})}shouldLogLevel(e){let a=["error","warn","info","debug"],t=a.indexOf(this.logLevel);return a.indexOf(e)<=t}}class i{transports;constructor(e){this.transports=e}async send(e){let a=this.transports.map(a=>a.send(e).catch(e=>{console.error("Failed to send to transport:",e)}));await Promise.allSettled(a)}}class n{send(e){let a=new Date(e.timestamp).toISOString(),t=e.level.toUpperCase(),r=e.source?`[${e.source}]`:"",i=e.context?` ${JSON.stringify(e.context)}`:"",n=`[Clerk Debug] ${a} ${t}${r}: ${e.message}${i}`;switch(e.level){case"error":console.error(n);break;case"warn":console.warn(n);break;case"info":console.info(n);break;case"debug":console.debug(n);break;default:console.log(n)}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:a,telemetryCollector:t}=e,o=[{transport:new n},...t?[{transport:new s(t)}]:[]].map(e=>e.transport),l=new i(o),c=new r(l,a??"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)}},125(e,a,t){let r,i,n,s,o,l,c;t.d(a,{QueryClient:()=>J});var d={setTimeout:(e,a)=>setTimeout(e,a),clearTimeout:e=>clearTimeout(e),setInterval:(e,a)=>setInterval(e,a),clearInterval:e=>clearInterval(e)},u=new class{#e=d;#a=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,a){return this.#e.setTimeout(e,a)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,a){return this.#e.setInterval(e,a)}clearInterval(e){this.#e.clearInterval(e)}},h="u"<typeof window||"Deno"in globalThis;function m(){}function p(e,a){return"function"==typeof e?e(a):e}function g(e,a){let{type:t="all",exact:r,fetchStatus:i,predicate:n,queryKey:s,stale:o}=e;if(s){if(r){if(a.queryHash!==f(s,a.options))return!1}else if(!k(a.queryKey,s))return!1}if("all"!==t){let e=a.isActive();if("active"===t&&!e||"inactive"===t&&e)return!1}return("boolean"!=typeof o||a.isStale()===o)&&(!i||i===a.state.fetchStatus)&&(!n||!!n(a))}function b(e,a){let{exact:t,status:r,predicate:i,mutationKey:n}=e;if(n){if(!a.options.mutationKey)return!1;if(t){if(y(a.options.mutationKey)!==y(n))return!1}else if(!k(a.options.mutationKey,n))return!1}return(!r||a.state.status===r)&&(!i||!!i(a))}function f(e,a){return(a?.queryKeyHashFn||y)(e)}function y(e){return JSON.stringify(e,(e,a)=>_(a)?Object.keys(a).sort().reduce((e,t)=>(e[t]=a[t],e),{}):a)}function k(e,a){return e===a||typeof e==typeof a&&!!e&&!!a&&"object"==typeof e&&"object"==typeof a&&Object.keys(a).every(t=>k(e[t],a[t]))}var w=Object.prototype.hasOwnProperty;function v(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function _(e){if(!j(e))return!1;let a=e.constructor;if(void 0===a)return!0;let t=a.prototype;return!!j(t)&&!!t.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function j(e){return"[object Object]"===Object.prototype.toString.call(e)}function z(e,a,t=0){let r=[...e,a];return t&&r.length>t?r.slice(1):r}function x(e,a,t=0){let r=[a,...e];return t&&r.length>t?r.slice(0,-1):r}var q=Symbol();function S(e,a){return!e.queryFn&&a?.initialPromise?()=>a.initialPromise:e.queryFn&&e.queryFn!==q?e.queryFn:()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`))}var C=(r=[],i=0,n=e=>{e()},s=e=>{e()},o=function(e){setTimeout(e,0)},{batch:e=>{let a;i++;try{a=e()}finally{let e;--i||(e=r,r=[],e.length&&o(()=>{s(()=>{e.forEach(e=>{n(e)})})}))}return a},batchCalls:e=>(...a)=>{l(()=>{e(...a)})},schedule:l=e=>{i?r.push(e):o(()=>{n(e)})},setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{s=e},setScheduler:e=>{o=e}}),I=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(){}},U=new class extends I{#t;#r;#i;constructor(){super(),this.#i=e=>{if("u">typeof window&&window.addEventListener){let a=()=>e();return window.addEventListener("visibilitychange",a,!1),()=>{window.removeEventListener("visibilitychange",a)}}}}onSubscribe(){this.#r||this.setEventListener(this.#i)}onUnsubscribe(){this.hasListeners()||(this.#r?.(),this.#r=void 0)}setEventListener(e){this.#i=e,this.#r?.(),this.#r=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#t!==e&&(this.#t=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(a=>{a(e)})}isFocused(){return"boolean"==typeof this.#t?this.#t:globalThis.document?.visibilityState!=="hidden"}},A=new class extends I{#n=!0;#r;#i;constructor(){super(),this.#i=e=>{if("u">typeof window&&window.addEventListener){let a=()=>e(!0),t=()=>e(!1);return window.addEventListener("online",a,!1),window.addEventListener("offline",t,!1),()=>{window.removeEventListener("online",a),window.removeEventListener("offline",t)}}}}onSubscribe(){this.#r||this.setEventListener(this.#i)}onUnsubscribe(){this.hasListeners()||(this.#r?.(),this.#r=void 0)}setEventListener(e){this.#i=e,this.#r?.(),this.#r=e(this.setOnline.bind(this))}setOnline(e){this.#n!==e&&(this.#n=e,this.listeners.forEach(a=>{a(e)}))}isOnline(){return this.#n}},P=(c=()=>h,{isServer:()=>c(),setIsServer(e){c=e}});function T(e){return Math.min(1e3*2**e,3e4)}function O(e){return(e??"online")!=="online"||A.isOnline()}var E=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function R(e){let a,t=!1,r=0,i=function(){let e,a,t=new Promise((t,r)=>{e=t,a=r});function r(e){Object.assign(t,e),delete t.resolve,delete t.reject}return t.status="pending",t.catch(()=>{}),t.resolve=a=>{r({status:"fulfilled",value:a}),e(a)},t.reject=e=>{r({status:"rejected",reason:e}),a(e)},t}(),n=()=>U.isFocused()&&("always"===e.networkMode||A.isOnline())&&e.canRun(),s=()=>O(e.networkMode)&&e.canRun(),o=e=>{"pending"===i.status&&(a?.(),i.resolve(e))},l=e=>{"pending"===i.status&&(a?.(),i.reject(e))},c=()=>new Promise(t=>{a=e=>{("pending"!==i.status||n())&&t(e)},e.onPause?.()}).then(()=>{a=void 0,"pending"===i.status&&e.onContinue?.()}),d=()=>{let a;if("pending"!==i.status)return;let s=0===r?e.initialPromise:void 0;try{a=s??e.fn()}catch(e){a=Promise.reject(e)}Promise.resolve(a).then(o).catch(a=>{if("pending"!==i.status)return;let s=e.retry??3*!P.isServer(),o=e.retryDelay??T,h="function"==typeof o?o(r,a):o,m=!0===s||"number"==typeof s&&r<s||"function"==typeof s&&s(r,a);t||!m?l(a):(r++,e.onFail?.(r,a),new Promise(e=>{u.setTimeout(e,h)}).then(()=>n()?void 0:c()).then(()=>{t?l(a):d()}))})};return{promise:i,status:()=>i.status,cancel:a=>{if("pending"===i.status){let t=new E(a);l(t),e.onCancel?.(t)}},continue:()=>(a?.(),i),cancelRetry:()=>{t=!0},continueRetry:()=>{t=!1},canStart:s,start:()=>(s()?d():c().then(d),i)}}var M=class{#s;destroy(){this.clearGcTimeout()}scheduleGc(){var e;this.clearGcTimeout(),"number"==typeof(e=this.gcTime)&&e>=0&&e!==1/0&&(this.#s=u.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(P.isServer()?1/0:3e5))}clearGcTimeout(){void 0!==this.#s&&(u.clearTimeout(this.#s),this.#s=void 0)}};function F(e,{pages:a,pageParams:t}){let r=a.length-1;return a.length>0?e.getNextPageParam(a[r],a,t[r],t):void 0}var D=class extends M{#o;#l;#c;#d;#u;#h;#m;#p;constructor(e){super(),this.#p=!1,this.#m=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#u=e.client,this.#d=this.#u.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#l=W(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=W(this.options);void 0!==e.data&&(this.setState(N(e.data,e.dataUpdatedAt)),this.#l=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#d.remove(this)}setData(e,a){var t,r;let i=(t=this.state.data,"function"==typeof(r=this.options).structuralSharing?r.structuralSharing(t,e):!1!==r.structuralSharing?function e(a,t,r=0){if(a===t)return a;if(r>500)return t;let i=v(a)&&v(t);if(!i&&!(_(a)&&_(t)))return t;let n=(i?a:Object.keys(a)).length,s=i?t:Object.keys(t),o=s.length,l=i?Array(o):{},c=0;for(let d=0;d<o;d++){let o=i?d:s[d],u=a[o],h=t[o];if(u===h){l[o]=u,(i?d<n:w.call(a,o))&&c++;continue}if(null===u||null===h||"object"!=typeof u||"object"!=typeof h){l[o]=h;continue}let m=e(u,h,r+1);l[o]=m,m===u&&c++}return n===o&&c===n?a:l}(t,e):e);return this.#g({data:i,type:"success",dataUpdatedAt:a?.updatedAt,manual:a?.manual}),i}setState(e){this.#g({type:"setState",state:e})}cancel(e){let a=this.#h?.promise;return this.#h?.cancel(e),a?a.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 a;return!1!==(a=e.options.enabled,"function"==typeof a?a(this):a)})}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===q||!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.#d.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(a=>a!==e),this.observers.length||(this.#h&&(this.#p||this.#b()?this.#h.cancel({revert:!0}):this.#h.cancelRetry()),this.scheduleGc()),this.#d.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#b(){return"paused"===this.state.fetchStatus&&"pending"===this.state.status}invalidate(){this.state.isInvalidated||this.#g({type:"invalidate"})}async fetch(e,a){var t;let r;if("idle"!==this.state.fetchStatus&&this.#h?.status()!=="rejected"){if(void 0!==this.state.data&&a?.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 i=new AbortController,n=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#p=!0,i.signal)})},s=()=>{let e,t=S(this.options,a),r=(n(e={client:this.#u,queryKey:this.queryKey,meta:this.meta}),e);return(this.#p=!1,this.options.persister)?this.options.persister(t,r,this):t(r)},o=(n(r={fetchOptions:a,options:this.options,queryKey:this.queryKey,client:this.#u,state:this.state,fetchFn:s}),r),l="infinite"===this.#o?(t=this.options.pages,{onFetch:(e,a)=>{let r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,n=e.state.data?.pages||[],s=e.state.data?.pageParams||[],o={pages:[],pageParams:[]},l=0,c=async()=>{let a=!1,c=S(e.options,e.fetchOptions),d=async(t,r,i)=>{if(a)return Promise.reject(e.signal.reason);if(null==r&&t.pages.length)return Promise.resolve(t);let n=(()=>{var t,n;let s,o,l={client:e.client,queryKey:e.queryKey,pageParam:r,direction:i?"backward":"forward",meta:e.options.meta};return t=()=>e.signal,n=()=>a=!0,o=!1,Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(s??=t(),o||(o=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),l})(),s=await c(n),{maxPages:o}=e.options,l=i?x:z;return{pages:l(t.pages,s,o),pageParams:l(t.pageParams,r,o)}};if(i&&n.length){let e="backward"===i,a={pages:n,pageParams:s},t=(e?function(e,{pages:a,pageParams:t}){return a.length>0?e.getPreviousPageParam?.(a[0],a,t[0],t):void 0}:F)(r,a);o=await d(a,t,e)}else{let e=t??n.length;do{let e=0===l?s[0]??r.initialPageParam:F(r,o);if(l>0&&null==e)break;o=await d(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},a):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.#g({type:"fetch",meta:o.fetchOptions?.meta}),this.#h=R({initialPromise:a?.initialPromise,fn:o.fetchFn,onCancel:e=>{e instanceof E&&e.revert&&this.setState({...this.#c,fetchStatus:"idle"}),i.abort()},onFail:(e,a)=>{this.#g({type:"failed",failureCount:e,error:a})},onPause:()=>{this.#g({type:"pause"})},onContinue:()=>{this.#g({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.#d.config.onSuccess?.(e,this),this.#d.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof E){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.#g({type:"error",error:e}),this.#d.config.onError?.(e,this),this.#d.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#g(e){let a=a=>{switch(e.type){case"failed":return{...a,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...a,fetchStatus:"paused"};case"continue":return{...a,fetchStatus:"fetching"};case"fetch":var t;return{...a,...(t=a.data,{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:O(this.options.networkMode)?"fetching":"paused",...void 0===t&&{error:null,status:"pending"}}),fetchMeta:e.meta??null};case"success":let r={...a,...N(e.data,e.dataUpdatedAt),dataUpdateCount:a.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#c=e.manual?r:void 0,r;case"error":let i=e.error;return{...a,error:i,errorUpdateCount:a.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:a.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...a,isInvalidated:!0};case"setState":return{...a,...e.state}}};this.state=a(this.state),C.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#d.notify({query:this,type:"updated",action:e})})}};function N(e,a){return{data:e,dataUpdatedAt:a??Date.now(),error:null,isInvalidated:!1,status:"success"}}function W(e){let a="function"==typeof e.initialData?e.initialData():e.initialData,t=void 0!==a,r=t?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:a,dataUpdateCount:0,dataUpdatedAt:t?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"pending",fetchStatus:"idle"}}var L=class extends I{constructor(e={}){super(),this.config=e,this.#f=new Map}#f;build(e,a,t){let r=a.queryKey,i=a.queryHash??f(r,a),n=this.get(i);return n||(n=new D({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(a),state:t,defaultOptions:e.getQueryDefaults(r)}),this.add(n)),n}add(e){this.#f.has(e.queryHash)||(this.#f.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let a=this.#f.get(e.queryHash);a&&(e.destroy(),a===e&&this.#f.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){C.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#f.get(e)}getAll(){return[...this.#f.values()]}find(e){let a={exact:!0,...e};return this.getAll().find(e=>g(a,e))}findAll(e={}){let a=this.getAll();return Object.keys(e).length>0?a.filter(a=>g(e,a)):a}notify(e){C.batch(()=>{this.listeners.forEach(a=>{a(e)})})}onFocus(){C.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){C.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},$=class extends M{#u;#y;#k;#h;constructor(e){super(),this.#u=e.client,this.mutationId=e.mutationId,this.#k=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.#k.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#y=this.#y.filter(a=>a!==e),this.scheduleGc(),this.#k.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#y.length||("pending"===this.state.status?this.scheduleGc():this.#k.remove(this))}continue(){return this.#h?.continue()??this.execute(this.state.variables)}async execute(e){let a=()=>{this.#g({type:"continue"})},t={client:this.#u,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#h=R({fn:()=>this.options.mutationFn?this.options.mutationFn(e,t):Promise.reject(Error("No mutationFn found")),onFail:(e,a)=>{this.#g({type:"failed",failureCount:e,error:a})},onPause:()=>{this.#g({type:"pause"})},onContinue:a,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#k.canRun(this)});let r="pending"===this.state.status,i=!this.#h.canStart();try{if(r)a();else{this.#g({type:"pending",variables:e,isPaused:i}),this.#k.config.onMutate&&await this.#k.config.onMutate(e,this,t);let a=await this.options.onMutate?.(e,t);a!==this.state.context&&this.#g({type:"pending",context:a,variables:e,isPaused:i})}let n=await this.#h.start();return await this.#k.config.onSuccess?.(n,e,this.state.context,this,t),await this.options.onSuccess?.(n,e,this.state.context,t),await this.#k.config.onSettled?.(n,null,this.state.variables,this.state.context,this,t),await this.options.onSettled?.(n,null,e,this.state.context,t),this.#g({type:"success",data:n}),n}catch(a){try{await this.#k.config.onError?.(a,e,this.state.context,this,t)}catch(e){Promise.reject(e)}try{await this.options.onError?.(a,e,this.state.context,t)}catch(e){Promise.reject(e)}try{await this.#k.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,t)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,a,e,this.state.context,t)}catch(e){Promise.reject(e)}throw this.#g({type:"error",error:a}),a}finally{this.#k.runNext(this)}}#g(e){this.state=(a=>{switch(e.type){case"failed":return{...a,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...a,isPaused:!0};case"continue":return{...a,isPaused:!1};case"pending":return{...a,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{...a,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...a,data:void 0,error:e.error,failureCount:a.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),C.batch(()=>{this.#y.forEach(a=>{a.onMutationUpdate(e)}),this.#k.notify({mutation:this,type:"updated",action:e})})}},B=class extends I{constructor(e={}){super(),this.config=e,this.#w=new Set,this.#v=new Map,this.#_=0}#w;#v;#_;build(e,a,t){let r=new $({client:e,mutationCache:this,mutationId:++this.#_,options:e.defaultMutationOptions(a),state:t});return this.add(r),r}add(e){this.#w.add(e);let a=K(e);if("string"==typeof a){let t=this.#v.get(a);t?t.push(e):this.#v.set(a,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#w.delete(e)){let a=K(e);if("string"==typeof a){let t=this.#v.get(a);if(t)if(t.length>1){let a=t.indexOf(e);-1!==a&&t.splice(a,1)}else t[0]===e&&this.#v.delete(a)}}this.notify({type:"removed",mutation:e})}canRun(e){let a=K(e);if("string"!=typeof a)return!0;{let t=this.#v.get(a),r=t?.find(e=>"pending"===e.state.status);return!r||r===e}}runNext(e){let a=K(e);if("string"!=typeof a)return Promise.resolve();{let t=this.#v.get(a)?.find(a=>a!==e&&a.state.isPaused);return t?.continue()??Promise.resolve()}}clear(){C.batch(()=>{this.#w.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#w.clear(),this.#v.clear()})}getAll(){return Array.from(this.#w)}find(e){let a={exact:!0,...e};return this.getAll().find(e=>b(a,e))}findAll(e={}){return this.getAll().filter(a=>b(e,a))}notify(e){C.batch(()=>{this.listeners.forEach(a=>{a(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return C.batch(()=>Promise.all(e.map(e=>e.continue().catch(m))))}};function K(e){return e.options.scope?.id}var J=class{#j;#k;#m;#z;#x;#q;#S;#C;constructor(e={}){this.#j=e.queryCache||new L,this.#k=e.mutationCache||new B,this.#m=e.defaultOptions||{},this.#z=new Map,this.#x=new Map,this.#q=0}mount(){this.#q++,1===this.#q&&(this.#S=U.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#j.onFocus())}),this.#C=A.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#j.onOnline())}))}unmount(){this.#q--,0===this.#q&&(this.#S?.(),this.#S=void 0,this.#C?.(),this.#C=void 0)}isFetching(e){return this.#j.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#k.findAll({...e,status:"pending"}).length}getQueryData(e){let a=this.defaultQueryOptions({queryKey:e});return this.#j.get(a.queryHash)?.state.data}ensureQueryData(e){let a=this.defaultQueryOptions(e),t=this.#j.build(this,a),r=t.state.data;return void 0===r?this.fetchQuery(e):(e.revalidateIfStale&&t.isStaleByTime(p(a.staleTime,t))&&this.prefetchQuery(a),Promise.resolve(r))}getQueriesData(e){return this.#j.findAll(e).map(({queryKey:e,state:a})=>[e,a.data])}setQueryData(e,a,t){let r=this.defaultQueryOptions({queryKey:e}),i=this.#j.get(r.queryHash),n=i?.state.data,s="function"==typeof a?a(n):a;if(void 0!==s)return this.#j.build(this,r).setData(s,{...t,manual:!0})}setQueriesData(e,a,t){return C.batch(()=>this.#j.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,a,t)]))}getQueryState(e){let a=this.defaultQueryOptions({queryKey:e});return this.#j.get(a.queryHash)?.state}removeQueries(e){let a=this.#j;C.batch(()=>{a.findAll(e).forEach(e=>{a.remove(e)})})}resetQueries(e,a){let t=this.#j;return C.batch(()=>(t.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},a)))}cancelQueries(e,a={}){let t={revert:!0,...a};return Promise.all(C.batch(()=>this.#j.findAll(e).map(e=>e.cancel(t)))).then(m).catch(m)}invalidateQueries(e,a={}){return C.batch(()=>(this.#j.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType==="none")?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},a))}refetchQueries(e,a={}){let t={...a,cancelRefetch:a.cancelRefetch??!0};return Promise.all(C.batch(()=>this.#j.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let a=e.fetch(void 0,t);return t.throwOnError||(a=a.catch(m)),"paused"===e.state.fetchStatus?Promise.resolve():a}))).then(m)}fetchQuery(e){let a=this.defaultQueryOptions(e);void 0===a.retry&&(a.retry=!1);let t=this.#j.build(this,a);return t.isStaleByTime(p(a.staleTime,t))?t.fetch(a):Promise.resolve(t.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 A.isOnline()?this.#k.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#j}getMutationCache(){return this.#k}getDefaultOptions(){return this.#m}setDefaultOptions(e){this.#m=e}setQueryDefaults(e,a){this.#z.set(y(e),{queryKey:e,defaultOptions:a})}getQueryDefaults(e){let a=[...this.#z.values()],t={};return a.forEach(a=>{k(e,a.queryKey)&&Object.assign(t,a.defaultOptions)}),t}setMutationDefaults(e,a){this.#x.set(y(e),{mutationKey:e,defaultOptions:a})}getMutationDefaults(e){let a=[...this.#x.values()],t={};return a.forEach(a=>{k(e,a.mutationKey)&&Object.assign(t,a.defaultOptions)}),t}defaultQueryOptions(e){if(e._defaulted)return e;let a={...this.#m.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return a.queryHash||(a.queryHash=f(a.queryKey,a)),void 0===a.refetchOnReconnect&&(a.refetchOnReconnect="always"!==a.networkMode),void 0===a.throwOnError&&(a.throwOnError=!!a.suspense),!a.networkMode&&a.persister&&(a.networkMode="offlineFirst"),a.queryFn===q&&(a.enabled=!1),a}defaultMutationOptions(e){return e?._defaulted?e:{...this.#m.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#j.clear(),this.#k.clear()}}},239(e,a,t){t.r(a),t.d(a,{Options:()=>C,debounce:()=>ei,zxcvbn:()=>el,zxcvbnAsync:()=>ec,zxcvbnOptions:()=>I});let r=(e,a)=>e.push.apply(e,a),i=e=>e.sort((e,a)=>e.i-a.i||e.j-a.j),n=e=>{let a={},t=1;return e.forEach(e=>{a[e]=t,t+=1}),a},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]+$/,d=/^[^a-z\xdf-\xff]+$/,u=/^[a-z\xdf-\xff]+$/,h=/^[^A-Z\xbf-\xdf]+$/,m=/[a-z\xdf-\xff]/,p=/[A-Z\xbf-\xdf]/,g=/[^A-Za-z\xbf-\xdf]/gi,b=/^\d+$/,f=new Date().getFullYear(),y={recentYear:/19\d\d|200\d|201\d|202\d/g},k=[" ",",",";",":","|","/","\\","_",".","-"],w=k.length;class v{match({password:e}){let a=[...this.getMatchesWithoutSeparator(e),...this.getMatchesWithSeparator(e)];return i(this.filterNoise(a))}getMatchesWithSeparator(e){let a=[],t=/^(\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 i=r+5;i<=r+9&&!(i>=e.length);i+=1){let n=e.slice(r,+i+1||9e9),s=t.exec(n);if(null!=s){let e=this.mapIntegersToDayMonthYear([parseInt(s[1],10),parseInt(s[3],10),parseInt(s[4],10)]);null!=e&&a.push({pattern:"date",token:n,i:r,j:i,separator:s[2],year:e.year,month:e.month,day:e.day})}}return a}getMatchesWithoutSeparator(e){let a=[],t=/^\d{4,8}$/,r=e=>Math.abs(e.year-f);for(let i=0;i<=Math.abs(e.length-4);i+=1)for(let n=i+3;n<=i+7&&!(n>=e.length);n+=1){let o=e.slice(i,+n+1||9e9);if(t.exec(o)){let e=[];if(s[o.length].forEach(([a,t])=>{let r=this.mapIntegersToDayMonthYear([parseInt(o.slice(0,a),10),parseInt(o.slice(a,t),10),parseInt(o.slice(t),10)]);null!=r&&e.push(r)}),e.length>0){let t=e[0],s=r(e[0]);e.slice(1).forEach(e=>{let a=r(e);a<s&&(t=e,s=a)}),a.push({pattern:"date",token:o,i,j:n,separator:"",year:t.year,month:t.month,day:t.day})}}}return a}filterNoise(e){return e.filter(a=>{let t=!1,r=e.length;for(let i=0;i<r;i+=1){let r=e[i];if(a!==r&&r.i<=a.i&&r.j>=a.j){t=!0;break}}return!t})}mapIntegersToDayMonthYear(e){if(e[1]>31||e[1]<=0)return null;let a=0,t=0,r=0;for(let i=0,n=e.length;i<n;i+=1){let n=e[i];if(n>99&&n<1e3||n>2050)return null;n>31&&(t+=1),n>12&&(a+=1),n<=0&&(r+=1)}return t>=2||3===a||r>=2?null:this.getDayMonth(e)}getDayMonth(e){let a=[[e[2],e.slice(0,2)],[e[0],e.slice(1,3)]],t=a.length;for(let e=0;e<t;e+=1){let[t,r]=a[e];if(1e3<=t&&t<=2050){let e=this.mapIntegersToDayMonth(r);if(null!=e)return{year:t,month:e.month,day:e.day};return null}}for(let e=0;e<t;e+=1){let[t,r]=a[e],i=this.mapIntegersToDayMonth(r);if(null!=i)return{year:this.twoToFourDigitYear(t),month:i.month,day:i.day}}return null}mapIntegersToDayMonth(e){let a=[e,e.slice().reverse()];for(let e=0;e<a.length;e+=1){let t=a[e],r=t[0],i=t[1];if(r>=1&&r<=31&&i>=1&&i<=12)return{day:r,month:i}}return null}twoToFourDigitYear(e){return e>99?e:e>50?e+1900:e+2e3}}let _=new Uint32Array(65536),j=(e,a,t)=>{let r=0,i=Object.keys(a).find(a=>{let i,n,s=(i=e.length<=a.length,n=e.length<=t,i||n?Math.ceil(e.length/4):t);if(Math.abs(e.length-a.length)>s)return!1;let o=((e,a)=>{if(e.length<a.length){let t=a;a=e,e=t}return 0===a.length?e.length:e.length<=32?((e,a)=>{let t=e.length,r=a.length,i=1<<t-1,n=-1,s=0,o=t,l=t;for(;l--;)_[e.charCodeAt(l)]|=1<<l;for(l=0;l<r;l++){let e=_[a.charCodeAt(l)],t=e|s;e|=(e&n)+n^n,s|=~(e|n),n&=e,s&i&&o++,n&i&&o--,n=n<<1|~(t|(s=s<<1|1)),s&=t}for(l=t;l--;)_[e.charCodeAt(l)]=0;return o})(e,a):((e,a)=>{let t=a.length,r=e.length,i=[],n=[],s=Math.ceil(t/32),o=Math.ceil(r/32);for(let e=0;e<s;e++)n[e]=-1,i[e]=0;let l=0;for(;l<o-1;l++){let s=0,o=-1,c=32*l,d=Math.min(32,r)+c;for(let a=c;a<d;a++)_[e.charCodeAt(a)]|=1<<a;for(let e=0;e<t;e++){let t=_[a.charCodeAt(e)],r=n[e/32|0]>>>e&1,l=i[e/32|0]>>>e&1,c=t|s,d=((t|l)&o)+o^o|t|l,u=s|~(d|o),h=o&d;u>>>31^r&&(n[e/32|0]^=1<<e),h>>>31^l&&(i[e/32|0]^=1<<e),u=u<<1|r,o=(h=h<<1|l)|~(c|u),s=u&c}for(let a=c;a<d;a++)_[e.charCodeAt(a)]=0}let c=0,d=-1,u=32*l,h=Math.min(32,r-u)+u;for(let a=u;a<h;a++)_[e.charCodeAt(a)]|=1<<a;let m=r;for(let e=0;e<t;e++){let t=_[a.charCodeAt(e)],s=n[e/32|0]>>>e&1,o=i[e/32|0]>>>e&1,l=t|c,u=((t|o)&d)+d^d|t|o,h=c|~(u|d),p=d&u;m+=h>>>r-1&1,m-=p>>>r-1&1,h>>>31^s&&(n[e/32|0]^=1<<e),p>>>31^o&&(i[e/32|0]^=1<<e),h=h<<1|s,d=(p=p<<1|o)|~(l|h),c=h&l}for(let a=u;a<h;a++)_[e.charCodeAt(a)]=0;return m})(e,a)})(e,a),l=o<=s;return l&&(r=o),l});return i?{levenshteinDistance:r,levenshteinDistanceEntry:i}:{}};var z={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"]},x={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 q{constructor(e=[]){this.parents=e,this.children=new Map}addSub(e,...a){let t=e.charAt(0);this.children.has(t)||this.children.set(t,new q([...this.parents,t]));let r=this.children.get(t);for(let a=1;a<e.length;a+=1){let t=e.charAt(a);r.hasChild(t)||r.addChild(t),r=r.getChild(t)}return r.subs=(r.subs||[]).concat(a),this}getChild(e){return this.children.get(e)}isTerminal(){return!!this.subs}addChild(e){this.hasChild(e)||this.children.set(e,new q([...this.parents,e]))}hasChild(e){return this.children.has(e)}}var S=(e,a)=>(Object.entries(e).forEach(([e,t])=>{t.forEach(t=>{a.addSub(t,e)})}),a);class C{constructor(){this.matchers={},this.l33tTable=z,this.trieNodeRoot=S(z,new q),this.dictionary={userInputs:[]},this.rankedDictionaries={},this.rankedDictionariesMaxWordSize={},this.translations=x,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=S(e.l33tTable,new q)),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 a=!0;return Object.keys(x).forEach(t=>{t in e?Object.keys(x[t]).forEach(r=>{r in e[t]||(a=!1)}):a=!1}),a}setRankedDictionaries(){let e={},a={};Object.keys(this.dictionary).forEach(t=>{e[t]=n(this.dictionary[t]),a[t]=this.getRankedDictionariesMaxWordSize(this.dictionary[t])}),this.rankedDictionaries=e,this.rankedDictionariesMaxWordSize=a}getRankedDictionariesMaxWordSize(e){let a=e.map(e=>"string"!=typeof e?e.toString().length:e.length);return 0===a.length?0:a.reduce((e,a)=>Math.max(e,a),-1/0)}buildSanitizedRankedDictionary(e){let a=[];return e.forEach(e=>{let t=typeof e;("string"===t||"number"===t||"boolean"===t)&&a.push(e.toString().toLowerCase())}),n(a)}extendUserInputsDictionary(e){this.dictionary.userInputs||(this.dictionary.userInputs=[]);let a=[...this.dictionary.userInputs,...e];this.rankedDictionaries.userInputs=this.buildSanitizedRankedDictionary(a),this.rankedDictionariesMaxWordSize.userInputs=this.getRankedDictionariesMaxWordSize(a)}addMatcher(e,a){this.matchers[e]?console.info(`Matcher ${e} already exists`):this.matchers[e]=a}}let I=new C;class U{constructor(e){this.defaultMatch=e}match({password:e}){let a=e.split("").reverse().join("");return this.defaultMatch({password:a}).map(a=>({...a,token:a.token.split("").reverse().join(""),reversed:!0,i:e.length-1-a.j,j:e.length-1-a.i}))}}class A{constructor({substr:e,limit:a,trieRoot:t}){this.buffer=[],this.finalPasswords=[],this.substr=e,this.limit=a,this.trieRoot=t}getAllPossibleSubsAtIndex(e){let a=[],t=this.trieRoot;for(let r=e;r<this.substr.length;r+=1){let e=this.substr.charAt(r);if(!(t=t.getChild(e)))break;a.push(t)}return a}helper({onlyFullSub:e,isFullSub:a,index:t,subIndex:r,changes:i,lastSubLetter:n,consecutiveSubCount:s}){if(this.finalPasswords.length>=this.limit)return;if(t===this.substr.length){e===a&&this.finalPasswords.push({password:this.buffer.join(""),changes:i});return}let o=[...this.getAllPossibleSubsAtIndex(t)],l=!1;for(let c=t+o.length-1;c>=t;c-=1){let d=o[c-t];if(d.isTerminal()){if(n===d.parents.join("")&&s>=3)continue;for(let t of(l=!0,d.subs)){this.buffer.push(t);let o=i.concat({i:r,letter:t,substitution:d.parents.join("")});if(this.helper({onlyFullSub:e,isFullSub:a,index:c+1,subIndex:r+t.length,changes:o,lastSubLetter:d.parents.join(""),consecutiveSubCount:n===d.parents.join("")?s+1:1}),this.buffer.pop(),this.finalPasswords.length>=this.limit)return}}}if(!e||!l){let o=this.substr.charAt(t);this.buffer.push(o),this.helper({onlyFullSub:e,isFullSub:a&&!l,index:t+1,subIndex:r+1,changes:i,lastSubLetter:n,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 P{constructor(e){this.defaultMatch=e}isAlreadyIncluded(e,a){return e.some(e=>Object.entries(e).every(([e,t])=>"subs"===e||t===a[e]))}match({password:e}){let a=[],t=new A({substr:e,limit:I.l33tMaxSubstitutions,trieRoot:I.trieNodeRoot}).getAll(),r=!1,i=!0;return t.forEach(t=>{if(r)return;let n=this.defaultMatch({password:t.password,useLevenshtein:i});i=!1,n.forEach(i=>{var n,s;let o,l,c,d,u;r||(r=0===i.i&&i.j===e.length-1);let h=(n=i.i,s=i.j,o=t.changes.filter(e=>e.i<n).reduce((e,a)=>e-a.letter.length+a.substitution.length,n),c=(l=t.changes.filter(e=>e.i>=n&&e.i<=s)).reduce((e,a)=>e-a.letter.length+a.substitution.length,s-n+o),d=[],u=[],l.forEach(e=>{0>d.findIndex(a=>a.letter===e.letter&&a.substitution===e.substitution)&&(d.push({letter:e.letter,substitution:e.substitution}),u.push(`${e.substitution} -> ${e.letter}`))}),{i:o,j:c,subs:d,subDisplay:u.join(", ")}),m=e.slice(h.i,+h.j+1||9e9),p={...i,l33t:!0,token:m,...h},g=this.isAlreadyIncluded(a,p);m.toLowerCase()===i.matchedWord||g||a.push(p)})}),a.filter(e=>e.token.length>1)}}class T{constructor(){this.l33t=new P(this.defaultMatch),this.reverse=new U(this.defaultMatch)}match({password:e}){return i([...this.defaultMatch({password:e}),...this.reverse.match({password:e}),...this.l33t.match({password:e})])}defaultMatch({password:e,useLevenshtein:a=!0}){let t=[],r=e.length,i=e.toLowerCase();return Object.keys(I.rankedDictionaries).forEach(n=>{let s=I.rankedDictionaries[n],o=Math.min(I.rankedDictionariesMaxWordSize[n],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=i.slice(l,+o+1||9e9),d=c in s,u={},h=0===l&&o===r-1;I.useLevenshteinDistance&&h&&!d&&a&&(u=j(c,s,I.levenshteinThreshold));let m=0!==Object.keys(u).length;if(d||m){let a=s[m?u.levenshteinDistanceEntry:c];t.push({pattern:"dictionary",i:l,j:o,token:e.slice(l,+o+1||9e9),matchedWord:c,rank:a,dictionaryName:n,reversed:!1,l33t:!1,...u})}}}}),t}}class O{match({password:e,regexes:a=y}){let t=[];return Object.keys(a).forEach(r=>{let i,n=a[r];for(n.lastIndex=0;i=n.exec(e);)if(i){let e=i[0];t.push({pattern:"regex",token:e,i:i.index,j:i.index+i[0].length-1,regexName:r,regexMatch:i})}}),i(t)}}var E={nCk(e,a){let t=e;if(a>t)return 0;if(0===a)return 1;let r=1;for(let e=1;e<=a;e+=1)r*=t,r/=e,t-=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 a=1;for(let t=2;t<=e;t+=1)a*=t;return a}};let R=(e,a)=>{let t=0,r=e.indexOf(a);for(;r>=0;)t+=1,r=e.indexOf(a,r+a.length);return t},M={bruteforce:({token:e})=>{let a=10**e.length;return a===1/0&&(a=Number.MAX_VALUE),Math.max(a,1===e.length?11:51)},date:({year:e,separator:a})=>{let t=365*Math.max(Math.abs(e-f),20);return a&&(t*=4),t},dictionary:({rank:e,reversed:a,l33t:t,subs:r,token:i,dictionaryName:n})=>{let s,c=(e=>{let a=e.replace(g,"");if(a.match(h)||a.toLowerCase()===a)return 1;let t=[o,l,d],r=t.length;for(let e=0;e<r;e+=1){let r=t[e];if(a.match(r))return 2}return(e=>{let a=e.split(""),t=a.filter(e=>e.match(p)).length,r=a.filter(e=>e.match(m)).length,i=0,n=Math.min(t,r);for(let e=1;e<=n;e+=1)i+=E.nCk(t+r,e);return i})(a)})(i),u=(({l33t:e,subs:a,token:t})=>{if(!e)return 1;let r=1;return a.forEach(e=>{let{subbedCount:a,unsubbedCount:i}=(({sub:e,token:a})=>{let t=a.toLowerCase();return{subbedCount:R(t,e.substitution),unsubbedCount:R(t,e.letter)}})({sub:e,token:t});if(0===a||0===i)r*=2;else{let e=Math.min(i,a),t=0;for(let r=1;r<=e;r+=1)t+=E.nCk(i+a,r);r*=t}}),r})({l33t:t,subs:r,token:i});return s="diceware"===n?3888:e*c*u*(a&&2||1),{baseGuesses:e,uppercaseVariations:c,l33tVariations:u,calculation:s}},regex:({regexName:e,regexMatch:a,token:t})=>{let r={alphaLower:26,alphaUpper:26,alpha:52,alphanumeric:62,digits:10,symbols:33};return e in r?r[e]**t.length:"recentYear"===e?Math.max(Math.abs(parseInt(a[0],10)-f),20):0},repeat:({baseGuesses:e,repeatCount:a})=>e*a,sequence:({token:e,ascending:a})=>{let t=e.charAt(0),r=0;return r=["a","A","z","Z","0","1","9"].includes(t)?4:t.match(/\d/)?10:26,a||(r*=2),r*e.length},spatial:({graph:e,token:a,shiftedCount:t,turns:r})=>{let i=(({token:e,graph:a,turns:t})=>{var r;let i,n=Object.keys(I.graphs[a]).length,s=(r=I.graphs[a],i=0,Object.keys(r).forEach(e=>{let a=r[e];i+=a.filter(e=>!!e).length}),i/=Object.entries(r).length),o=0,l=e.length;for(let e=2;e<=l;e+=1){let a=Math.min(t,e-1);for(let t=1;t<=a;t+=1)o+=E.nCk(e-1,t-1)*n*s**t}return o})({token:a,graph:e,turns:r});if(t){let e=a.length-t;if(0===t||0===e)i*=2;else{let a=0;for(let r=1;r<=Math.min(t,e);r+=1)a+=E.nCk(t+e,r);i*=a}}return Math.round(i)},separator:()=>w},F={password:"",optimal:{},excludeAdditive:!1,separatorRegex:void 0,fillArray(e,a){let t=[];for(let r=0;r<e;r+=1){let e=[];"object"===a&&(e={}),t.push(e)}return t},makeBruteforceMatch(e,a){return{pattern:"bruteforce",token:this.password.slice(e,+a+1||9e9),i:e,j:a}},update(e,a){let t=e.j,r=((e,a)=>{var t;let r,i={};if("guesses"in e&&null!=e.guesses)return e;let n=(r=1,e.token.length<a.length&&(r=1===e.token.length?10:50),r),s=(t=e.pattern,M[t]?M[t](e):I.matchers[t]&&"scoring"in I.matchers[t]?I.matchers[t].scoring(e):0),o=0;"number"==typeof s?o=s:"dictionary"===e.pattern&&(o=s.calculation,i.baseGuesses=s.baseGuesses,i.uppercaseVariations=s.uppercaseVariations,i.l33tVariations=s.l33tVariations);let l=Math.max(o,n);return{...e,...i,guesses:l,guessesLog10:E.log10(l)}})(e,this.password),i=r.guesses;a>1&&(i*=this.optimal.pi[r.i-1][a-1]);let n=E.factorial(a)*i;this.excludeAdditive||(n+=1e4**(a-1));let s=!1;Object.keys(this.optimal.g[t]).forEach(e=>{let r=this.optimal.g[t][e];parseInt(e,10)<=a&&r<=n&&(s=!0)}),s||(this.optimal.g[t][a]=n,this.optimal.m[t][a]=r,this.optimal.pi[t][a]=i)},bruteforceUpdate(e){let a=this.makeBruteforceMatch(0,e);this.update(a,1);for(let t=1;t<=e;t+=1){a=this.makeBruteforceMatch(t,e);let r=this.optimal.m[t-1];Object.keys(r).forEach(e=>{"bruteforce"!==r[e].pattern&&this.update(a,parseInt(e,10)+1)})}},unwind(e){let a=[],t=e-1,r=0,i=2e308,n=this.optimal.g[t];for(n&&Object.keys(n).forEach(e=>{let a=n[e];a<i&&(r=parseInt(e,10),i=a)});t>=0;){let e=this.optimal.m[t][r];a.unshift(e),t=e.i-1,r-=1}return a}};var D={mostGuessableMatchSequence(e,a,t=!1){F.password=e,F.excludeAdditive=t;let r=e.length,i=F.fillArray(r,"array");a.forEach(e=>{i[e.j].push(e)}),i=i.map(e=>e.sort((e,a)=>e.i-a.i)),F.optimal={m:F.fillArray(r,"object"),pi:F.fillArray(r,"object"),g:F.fillArray(r,"object")};for(let e=0;e<r;e+=1)i[e].forEach(e=>{e.i>0?Object.keys(F.optimal.m[e.i-1]).forEach(a=>{F.update(e,parseInt(a,10)+1)}):F.update(e,1)}),F.bruteforceUpdate(e);let n=F.unwind(r),s=n.length,o=this.getGuesses(e,s);return{password:e,guesses:o,guessesLog10:E.log10(o),sequence:n}},getGuesses(e,a){let t=e.length;return 0===e.length?1:F.optimal.g[t-1][a]}};class N{match({password:e,omniMatch:a}){let t=[],r=0;for(;r<e.length;){let i=this.getGreedyMatch(e,r),n=this.getLazyMatch(e,r);if(null==i)break;let{match:s,baseToken:o}=this.setMatchToken(i,n);if(s){let e=s.index+s[0].length-1,i=this.getBaseGuesses(o,a);t.push(this.normalizeMatch(o,e,s,i)),r=e+1}}return t.some(e=>e instanceof Promise)?Promise.all(t):t}normalizeMatch(e,a,t,r){let i={pattern:"repeat",i:t.index,j:a,token:t[0],baseToken:e,baseGuesses:0,repeatCount:t[0].length/e.length};return r instanceof Promise?r.then(e=>({...i,baseGuesses:e})):{...i,baseGuesses:r}}getGreedyMatch(e,a){let t=/(.+)\1+/g;return t.lastIndex=a,t.exec(e)}getLazyMatch(e,a){let t=/(.+?)\1+/g;return t.lastIndex=a,t.exec(e)}setMatchToken(e,a){let t,r="";if(a&&e[0].length>a[0].length){t=e;let a=/^(.+?)\1+$/.exec(t[0]);a&&(r=a[1])}else(t=a)&&(r=t[1]);return{match:t,baseToken:r}}getBaseGuesses(e,a){let t=a.match(e);return t instanceof Promise?t.then(a=>D.mostGuessableMatchSequence(e,a).guesses):D.mostGuessableMatchSequence(e,t).guesses}}class W{constructor(){this.MAX_DELTA=5}match({password:e}){let a=[];if(1===e.length)return[];let t=0,r=null,i=e.length;for(let n=1;n<i;n+=1){let i=e.charCodeAt(n)-e.charCodeAt(n-1);if(null==r&&(r=i),i!==r){let s=n-1;this.update({i:t,j:s,delta:r,password:e,result:a}),t=s,r=i}}return this.update({i:t,j:i-1,delta:r,password:e,result:a}),a}update({i:e,j:a,delta:t,password:r,result:i}){if(a-e>1||1===Math.abs(t)){let n=Math.abs(t);if(n>0&&n<=this.MAX_DELTA){let n=r.slice(e,+a+1||9e9),{sequenceName:s,sequenceSpace:o}=this.getSequence(n);return i.push({pattern:"sequence",i:e,j:a,token:r.slice(e,+a+1||9e9),sequenceName:s,sequenceSpace:o,ascending:t>0})}}return null}getSequence(e){let a="unicode",t=26;return u.test(e)?(a="lower",t=26):c.test(e)?(a="upper",t=26):b.test(e)&&(a="digits",t=10),{sequenceName:a,sequenceSpace:t}}}class L{constructor(){this.SHIFTED_RX=/[~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?]/}match({password:e}){let a=[];return Object.keys(I.graphs).forEach(t=>{let i=I.graphs[t];r(a,this.helper(e,i,t))}),i(a)}checkIfShifted(e,a,t){return!e.includes("keypad")&&this.SHIFTED_RX.test(a.charAt(t))?1:0}helper(e,a,t){let r,i=[],n=0,s=e.length;for(;n<s-1;){let o=n+1,l=null,c=0;for(r=this.checkIfShifted(t,e,n);;){let d=a[e.charAt(o-1)]||[],u=!1,h=-1,m=-1;if(o<s){let a=e.charAt(o),t=d.length;for(let e=0;e<t;e+=1){let t=d[e];if(m+=1,t){let e=t.indexOf(a);if(-1!==e){u=!0,1===e&&(r+=1),l!==(h=m)&&(c+=1,l=h);break}}}}if(u)o+=1;else{o-n>2&&i.push({pattern:"spatial",i:n,j:o-1,token:e.slice(n,o),graph:t,turns:c,shiftedCount:r}),n=o;break}}}return i}}let $=RegExp(`[${k.join("")}]`);class B{static getMostUsedSeparatorChar(e){let a=[...e.split("").filter(e=>$.test(e)).reduce((e,a)=>{let t=e.get(a);return t?e.set(a,t+1):e.set(a,1),e},new Map).entries()].sort(([e,a],[t,r])=>r-a);if(!a.length)return;let t=a[0];if(!(t[1]<2))return t[0]}static getSeparatorRegex(e){return RegExp(`([^${e}
])(${e})(?!${e})`,"g")}match({password:e}){let a=[];if(0===e.length)return a;let t=B.getMostUsedSeparatorChar(e);if(void 0===t)return a;let r=B.getSeparatorRegex(t);for(let i of e.matchAll(r)){if(void 0===i.index)continue;let e=i.index+1;a.push({pattern:"separator",token:t,i:e,j:e})}return a}}class K{constructor(){this.matchers={date:v,dictionary:T,regex:O,repeat:N,sequence:W,spatial:L,separator:B}}match(e){let a=[],t=[];return([...Object.keys(this.matchers),...Object.keys(I.matchers)].forEach(i=>{if(!this.matchers[i]&&!I.matchers[i])return;let n=new(this.matchers[i]?this.matchers[i]:I.matchers[i].Matching)().match({password:e,omniMatch:this});n instanceof Promise?(n.then(e=>{r(a,e)}),t.push(n)):r(a,n)}),t.length>0)?new Promise((e,r)=>{Promise.all(t).then(()=>{e(i(a))}).catch(e=>{r(e)})}):i(a)}}let J={second:1,minute:60,hour:3600,day:86400,month:2678400,year:0x1ea6e00,century:321408e4};class V{translate(e,a){let t=e;void 0!==a&&1!==a&&(t+="s");let{timeEstimation:r}=I.translations;return r[t].replace("{base}",`${a}`)}estimateAttackTimes(e){let a={onlineThrottling100PerHour:e/(100/3600),onlineNoThrottling10PerSecond:e/10,offlineSlowHashing1e4PerSecond:e/1e4,offlineFastHashing1e10PerSecond:e/1e10},t={onlineThrottling100PerHour:"",onlineNoThrottling10PerSecond:"",offlineSlowHashing1e4PerSecond:"",offlineFastHashing1e10PerSecond:""};return Object.keys(a).forEach(e=>{let r=a[e];t[e]=this.displayTime(r)}),{crackTimesSeconds:a,crackTimesDisplay:t,score:this.guessesToScore(e)}}guessesToScore(e){return e<1005?0:e<1000005?1:e<0x5f5e105?2:e<0x2540be405?3:4}displayTime(e){let a,t="centuries",r=Object.keys(J),i=r.findIndex(a=>e<J[a]);return i>-1&&(t=r[i-1],0!==i?a=Math.round(e/J[t]):t="ltSecond"),this.translate(t,a)}}var H=()=>null,G=()=>({warning:I.translations.warnings.dates,suggestions:[I.translations.suggestions.dates]}),Q=(e,a)=>{let t=((e,a)=>{let t=null,r=e.dictionaryName,i="lastnames"===r||r.toLowerCase().includes("firstnames");if("passwords"===r){let r;r=null,!a||e.l33t||e.reversed?e.guessesLog10<=4&&(r=I.translations.warnings.similarToCommon):r=e.rank<=10?I.translations.warnings.topTen:e.rank<=100?I.translations.warnings.topHundred:I.translations.warnings.common,t=r}else if(r.includes("wikipedia")){let e;e=null,a&&(e=I.translations.warnings.wordByItself),t=e}else i?t=a?I.translations.warnings.namesByThemselves:I.translations.warnings.commonNames:"userInputs"===r&&(t=I.translations.warnings.userInputs);return t})(e,a),r=[],i=e.token;return i.match(o)?r.push(I.translations.suggestions.capitalization):i.match(d)&&i.toLowerCase()!==i&&r.push(I.translations.suggestions.allUppercase),e.reversed&&e.token.length>=4&&r.push(I.translations.suggestions.reverseWords),e.l33t&&r.push(I.translations.suggestions.l33t),{warning:t,suggestions:r}},Y=e=>"recentYear"===e.regexName?{warning:I.translations.warnings.recentYears,suggestions:[I.translations.suggestions.recentYears,I.translations.suggestions.associatedYears]}:{warning:null,suggestions:[]},Z=e=>{let a=I.translations.warnings.extendedRepeat;return 1===e.baseToken.length&&(a=I.translations.warnings.simpleRepeat),{warning:a,suggestions:[I.translations.suggestions.repeated]}},X=()=>({warning:I.translations.warnings.sequences,suggestions:[I.translations.suggestions.sequences]}),ee=e=>{let a=I.translations.warnings.keyPattern;return 1===e.turns&&(a=I.translations.warnings.straightRow),{warning:a,suggestions:[I.translations.suggestions.longerKeyboardPattern]}},ea=()=>null;let et={warning:null,suggestions:[]};class er{constructor(){this.matchers={bruteforce:H,date:G,dictionary:Q,regex:Y,repeat:Z,sequence:X,spatial:ee,separator:ea},this.defaultFeedback={warning:null,suggestions:[]},this.setDefaultSuggestions()}setDefaultSuggestions(){this.defaultFeedback.suggestions.push(I.translations.suggestions.useWords,I.translations.su