var qi=Object.defineProperty;var Gi=(e,t,n)=>t in e?qi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Nn=(e,t,n)=>Gi(e,typeof t!="symbol"?t+"":t,n);import{b as re,a as S,D as Ne,l as Pe,e as Ji,n as ht,s as Kr,u as Hi,f as Yi,h as Qi,i as Xi}from"./chunk-DbSUcVMv.js";import{r as We,R as zt}from"./chunk-DpBkJLqh.js";var qr={exports:{}},Gr={};/**
 * @license React
 * use-sync-external-store-with-selector.development.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */(function(){function e(u,l){return u===l&&(u!==0||1/u===1/l)||u!==u&&l!==l}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=We,n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,s=t.useEffect,o=t.useMemo,c=t.useDebugValue;Gr.useSyncExternalStoreWithSelector=function(u,l,h,m,b){var A=i(null);if(A.current===null){var _={hasValue:!1,value:null};A.current=_}else _=A.current;A=o(function(){function x(B){if(!L){if(L=!0,F=B,B=m(B),b!==void 0&&_.hasValue){var z=_.value;if(b(z,B))return O=z}return O=B}if(z=O,n(F,B))return z;var J=m(B);return b!==void 0&&b(z,J)?(F=B,z):(F=B,O=J)}var L=!1,F,O,P=h===void 0?null:h;return[function(){return x(l())},P===null?void 0:function(){return x(P())}]},[l,h,m,b]);var k=r(u,A[0],A[1]);return s(function(){_.hasValue=!0,_.value=k},[k]),c(k),k},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})();qr.exports=Gr;var Zi=qr.exports;function es(e){e()}function ts(){let e=null,t=null;return{clear(){e=null,t=null},notify(){es(()=>{let n=e;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=e;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=t={callback:n,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!r||e===null||(r=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var wr={notify(){},get:()=>[]};function ns(e,t){let n,r=wr,i=0,s=!1;function o(k){h();const x=r.subscribe(k);let L=!1;return()=>{L||(L=!0,x(),m())}}function c(){r.notify()}function u(){_.onStateChange&&_.onStateChange()}function l(){return s}function h(){i++,n||(n=e.subscribe(u),r=ts())}function m(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=wr)}function b(){s||(s=!0,h())}function A(){s&&(s=!1,m())}const _={addNestedSub:o,notifyNestedSubs:c,handleChangeWrapper:u,isSubscribed:l,trySubscribe:b,tryUnsubscribe:A,getListeners:()=>r};return _}var rs=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",is=rs(),ss=()=>typeof navigator<"u"&&navigator.product==="ReactNative",os=ss(),as=()=>is||os?We.useLayoutEffect:We.useEffect,cs=as(),Pn=Symbol.for("react-redux-context"),Rn=typeof globalThis<"u"?globalThis:{};function us(){if(!We.createContext)return{};const e=Rn[Pn]??(Rn[Pn]=new Map);let t=e.get(We.createContext);return t||(t=We.createContext(null),t.displayName="ReactRedux",e.set(We.createContext,t)),t}var vt=us();function ls(e){const{children:t,context:n,serverState:r,store:i}=e,s=We.useMemo(()=>{const u=ns(i),l={store:i,subscription:u,getServerState:r?()=>r:void 0};{const{identityFunctionCheck:h="once",stabilityCheck:m="once"}=e;return Object.assign(l,{stabilityCheck:m,identityFunctionCheck:h})}},[i,r]),o=We.useMemo(()=>i.getState(),[i]);cs(()=>{const{subscription:u}=s;return u.onStateChange=u.notifyNestedSubs,u.trySubscribe(),o!==i.getState()&&u.notifyNestedSubs(),()=>{u.tryUnsubscribe(),u.onStateChange=void 0}},[s,o]);const c=n||vt;return We.createElement(c.Provider,{value:s},t)}var Ec=ls;function ar(e=vt){return function(){const n=We.useContext(e);if(!n)throw new Error("could not find react-redux context value; please ensure the component is wrapped in a <Provider>");return n}}var Jr=ar();function Hr(e=vt){const t=e===vt?Jr:ar(e),n=()=>{const{store:r}=t();return r};return Object.assign(n,{withTypes:()=>n}),n}var fs=Hr();function ds(e=vt){const t=e===vt?fs:Hr(e),n=()=>t().dispatch;return Object.assign(n,{withTypes:()=>n}),n}var hs=ds(),ps=(e,t)=>e===t;function ys(e=vt){const t=e===vt?Jr:ar(e),n=(r,i={})=>{const{equalityFn:s=ps}=typeof i=="function"?{equalityFn:i}:i;{if(!r)throw new Error("You must pass a selector to useSelector");if(typeof r!="function")throw new Error("You must pass a function as a selector to useSelector");if(typeof s!="function")throw new Error("You must pass a function as an equality function to useSelector")}const o=t(),{store:c,subscription:u,getServerState:l}=o,h=We.useRef(!0),m=We.useCallback({[r.name](A){const _=r(A);{const{devModeChecks:k={}}=typeof i=="function"?{}:i,{identityFunctionCheck:x,stabilityCheck:L}=o,{identityFunctionCheck:F,stabilityCheck:O}={stabilityCheck:L,identityFunctionCheck:x,...k};if(O==="always"||O==="once"&&h.current){const P=r(A);if(!s(_,P)){let B;try{throw new Error}catch(z){({stack:B}=z)}console.warn("Selector "+(r.name||"unknown")+` returned a different result when called with the same parameters. This can lead to unnecessary rerenders.
Selectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization`,{state:A,selected:_,selected2:P,stack:B})}}if((F==="always"||F==="once"&&h.current)&&_===A){let P;try{throw new Error}catch(B){({stack:P}=B)}console.warn("Selector "+(r.name||"unknown")+` returned the root state when called. This can lead to unnecessary rerenders.
Selectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.`,{stack:P})}h.current&&(h.current=!1)}return _}}[r.name],[r]),b=Zi.useSyncExternalStoreWithSelector(u.addNestedSub,c.getState,l||c.getState,m,s);return We.useDebugValue(b),b};return Object.assign(n,{withTypes:()=>n}),n}var ms=ys(),gs=typeof Symbol=="function"&&Symbol.observable||"@@observable",br=gs,jn=()=>Math.random().toString(36).substring(7).split("").join("."),ws={INIT:`@@redux/INIT${jn()}`,REPLACE:`@@redux/REPLACE${jn()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${jn()}`},At=ws;function Gt(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function bs(e){if(e===void 0)return"undefined";if(e===null)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(_s(e))return"date";if(Ss(e))return"error";const n=vs(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function vs(e){return typeof e.constructor=="function"?e.constructor.name:null}function Ss(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function _s(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function mt(e){let t=typeof e;return t=bs(e),t}function Yr(e,t,n){if(typeof e!="function")throw new Error(`Expected the root reducer to be a function. Instead, received: '${mt(e)}'`);if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(`Expected the enhancer to be a function. Instead, received: '${mt(n)}'`);return n(Yr)(e,t)}let r=e,i=t,s=new Map,o=s,c=0,u=!1;function l(){o===s&&(o=new Map,s.forEach((x,L)=>{o.set(L,x)}))}function h(){if(u)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function m(x){if(typeof x!="function")throw new Error(`Expected the listener to be a function. Instead, received: '${mt(x)}'`);if(u)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let L=!0;l();const F=c++;return o.set(F,x),function(){if(L){if(u)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");L=!1,l(),o.delete(F),s=null}}}function b(x){if(!Gt(x))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${mt(x)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(typeof x.type>"u")throw new Error('Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if(typeof x.type!="string")throw new Error(`Action "type" property must be a string. Instead, the actual type was: '${mt(x.type)}'. Value was: '${x.type}' (stringified)`);if(u)throw new Error("Reducers may not dispatch actions.");try{u=!0,i=r(i,x)}finally{u=!1}return(s=o).forEach(F=>{F()}),x}function A(x){if(typeof x!="function")throw new Error(`Expected the nextReducer to be a function. Instead, received: '${mt(x)}`);r=x,b({type:At.REPLACE})}function _(){const x=m;return{subscribe(L){if(typeof L!="object"||L===null)throw new Error(`Expected the observer to be an object. Instead, received: '${mt(L)}'`);function F(){const P=L;P.next&&P.next(h())}return F(),{unsubscribe:x(F)}},[br](){return this}}}return b({type:At.INIT}),{dispatch:b,subscribe:m,getState:h,replaceReducer:A,[br]:_}}function vr(e){typeof console<"u"&&typeof console.error=="function"&&console.error(e);try{throw new Error(e)}catch{}}function Ts(e,t,n,r){const i=Object.keys(t),s=n&&n.type===At.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(i.length===0)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!Gt(e))return`The ${s} has unexpected type of "${mt(e)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const o=Object.keys(e).filter(c=>!t.hasOwnProperty(c)&&!r[c]);if(o.forEach(c=>{r[c]=!0}),!(n&&n.type===At.REPLACE)&&o.length>0)return`Unexpected ${o.length>1?"keys":"key"} "${o.join('", "')}" found in ${s}. Expected to find one of the known reducer keys instead: "${i.join('", "')}". Unexpected keys will be ignored.`}function Es(e){Object.keys(e).forEach(t=>{const n=e[t];if(typeof n(void 0,{type:At.INIT})>"u")throw new Error(`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof n(void 0,{type:At.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${At.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)})}function Qr(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const c=t[o];typeof e[c]>"u"&&vr(`No reducer provided for key "${c}"`),typeof e[c]=="function"&&(n[c]=e[c])}const r=Object.keys(n);let i;i={};let s;try{Es(n)}catch(o){s=o}return function(c={},u){if(s)throw s;{const m=Ts(c,n,u,i);m&&vr(m)}let l=!1;const h={};for(let m=0;m<r.length;m++){const b=r[m],A=n[b],_=c[b],k=A(_,u);if(typeof k>"u"){const x=u&&u.type;throw new Error(`When called with an action of type ${x?`"${String(x)}"`:"(unknown type)"}, the slice reducer for key "${b}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}h[b]=k,l=l||k!==_}return l=l||r.length!==Object.keys(c).length,l?h:c}}function pn(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function As(...e){return t=>(n,r)=>{const i=t(n,r);let s=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const o={getState:i.getState,dispatch:(u,...l)=>s(u,...l)},c=e.map(u=>u(o));return s=pn(...c)(i.dispatch),{...i,dispatch:s}}}function Xr(e){return Gt(e)&&"type"in e&&typeof e.type=="string"}var Zr=Symbol.for("immer-nothing"),Sr=Symbol.for("immer-draftable"),He=Symbol.for("immer-state"),Os=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function Ve(e,...t){{const n=Os[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}}var Vt=Object.getPrototypeOf;function It(e){return!!e&&!!e[He]}function pt(e){var t;return e?ei(e)||Array.isArray(e)||!!e[Sr]||!!((t=e.constructor)!=null&&t[Sr])||Jt(e)||Tn(e):!1}var Is=Object.prototype.constructor.toString(),_r=new WeakMap;function ei(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=_r.get(n);return r===void 0&&(r=Function.toString.call(n),_r.set(n,r)),r===Is}function yn(e,t,n=!0){_n(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function _n(e){const t=e[He];return t?t.type_:Array.isArray(e)?1:Jt(e)?2:Tn(e)?3:0}function Hn(e,t){return _n(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ti(e,t,n){const r=_n(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function ks(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Jt(e){return e instanceof Map}function Tn(e){return e instanceof Set}function Et(e){return e.copy_||e.base_}function Yn(e,t){if(Jt(e))return new Map(e);if(Tn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=ei(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[He];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const o=i[s],c=r[o];c.writable===!1&&(c.writable=!0,c.configurable=!0),(c.get||c.set)&&(r[o]={configurable:!0,writable:!0,enumerable:c.enumerable,value:e[o]})}return Object.create(Vt(e),r)}else{const r=Vt(e);if(r!==null&&n)return{...e};const i=Object.create(r);return Object.assign(i,e)}}function cr(e,t=!1){return En(e)||It(e)||!pt(e)||(_n(e)>1&&Object.defineProperties(e,{set:Xt,add:Xt,clear:Xt,delete:Xt}),Object.freeze(e),t&&Object.values(e).forEach(n=>cr(n,!0))),e}function Cs(){Ve(2)}var Xt={value:Cs};function En(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var xs={};function kt(e){const t=xs[e];return t||Ve(0,e),t}var Wt;function ni(){return Wt}function Ns(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Tr(e,t){t&&(kt("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Qn(e){Xn(e),e.drafts_.forEach(Ps),e.drafts_=null}function Xn(e){e===Wt&&(Wt=e.parent_)}function Er(e){return Wt=Ns(Wt,e)}function Ps(e){const t=e[He];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Ar(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[He].modified_&&(Qn(t),Ve(4)),pt(e)&&(e=mn(t,e),t.parent_||gn(t,e)),t.patches_&&kt("Patches").generateReplacementPatches_(n[He].base_,e,t.patches_,t.inversePatches_)):e=mn(t,n,[]),Qn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Zr?e:void 0}function mn(e,t,n){if(En(t))return t;const r=e.immer_.shouldUseStrictIteration(),i=t[He];if(!i)return yn(t,(s,o)=>Or(e,i,t,s,o,n),r),t;if(i.scope_!==e)return t;if(!i.modified_)return gn(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const s=i.copy_;let o=s,c=!1;i.type_===3&&(o=new Set(s),s.clear(),c=!0),yn(o,(u,l)=>Or(e,i,s,u,l,n,c),r),gn(e,s,!1),n&&e.patches_&&kt("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function Or(e,t,n,r,i,s,o){if(i==null||typeof i!="object"&&!o)return;const c=En(i);if(!(c&&!o)){if(i===n&&Ve(5),It(i)){const u=s&&t&&t.type_!==3&&!Hn(t.assigned_,r)?s.concat(r):void 0,l=mn(e,i,u);if(ti(n,r,l),It(l))e.canAutoFreeze_=!1;else return}else o&&n.add(i);if(pt(i)&&!c){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&c)return;mn(e,i),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(Jt(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&gn(e,i)}}}function gn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&cr(t,n)}function Rs(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:ni(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=ur;n&&(i=[r],s=Kt);const{revoke:o,proxy:c}=Proxy.revocable(i,s);return r.draft_=c,r.revoke_=o,c}var ur={get(e,t){if(t===He)return e;const n=Et(e);if(!Hn(n,t))return js(e,n,t);const r=n[t];return e.finalized_||!pt(r)?r:r===Un(e.base_,t)?(Dn(e),e.copy_[t]=er(r,e)):r},has(e,t){return t in Et(e)},ownKeys(e){return Reflect.ownKeys(Et(e))},set(e,t,n){const r=ri(Et(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Un(Et(e),t),s=i==null?void 0:i[He];if(s&&s.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(ks(n,i)&&(n!==void 0||Hn(e.base_,t)))return!0;Dn(e),Zn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Un(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Dn(e),Zn(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Et(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){Ve(11)},getPrototypeOf(e){return Vt(e.base_)},setPrototypeOf(){Ve(12)}},Kt={};yn(ur,(e,t)=>{Kt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Kt.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Ve(13),Kt.set.call(this,e,t,void 0)};Kt.set=function(e,t,n){return t!=="length"&&isNaN(parseInt(t))&&Ve(14),ur.set.call(this,e[0],t,n,e[0])};function Un(e,t){const n=e[He];return(n?Et(n):e)[t]}function js(e,t,n){var i;const r=ri(t,n);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function ri(e,t){if(!(t in e))return;let n=Vt(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Vt(n)}}function Zn(e){e.modified_||(e.modified_=!0,e.parent_&&Zn(e.parent_))}function Dn(e){e.copy_||(e.copy_=Yn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Us=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const s=n;n=t;const o=this;return function(u=s,...l){return o.produce(u,h=>n.call(this,h,...l))}}typeof n!="function"&&Ve(6),r!==void 0&&typeof r!="function"&&Ve(7);let i;if(pt(t)){const s=Er(this),o=er(t,void 0);let c=!0;try{i=n(o),c=!1}finally{c?Qn(s):Xn(s)}return Tr(s,r),Ar(i,s)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===Zr&&(i=void 0),this.autoFreeze_&&cr(i,!0),r){const s=[],o=[];kt("Patches").generateReplacementPatches_(t,i,s,o),r(s,o)}return i}else Ve(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(o,...c)=>this.produceWithPatches(o,u=>t(u,...c));let r,i;return[this.produce(t,n,(o,c)=>{r=o,i=c}),r,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){pt(e)||Ve(8),It(e)&&(e=Ds(e));const t=Er(this),n=er(e,void 0);return n[He].isManual_=!0,Xn(t),n}finishDraft(e,t){const n=e&&e[He];(!n||!n.isManual_)&&Ve(9);const{scope_:r}=n;return Tr(r,t),Ar(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=kt("Patches").applyPatches_;return It(e)?r(e,t):this.produce(e,i=>r(i,t))}};function er(e,t){const n=Jt(e)?kt("MapSet").proxyMap_(e,t):Tn(e)?kt("MapSet").proxySet_(e,t):Rs(e,t);return(t?t.scope_:ni()).drafts_.push(n),n}function Ds(e){return It(e)||Ve(10,e),ii(e)}function ii(e){if(!pt(e)||En(e))return e;const t=e[He];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Yn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Yn(e,!0);return yn(n,(i,s)=>{ti(n,i,ii(s))},r),t&&(t.finalized_=!1),n}var zs=new Us,si=zs.produce,Ms=(e,t,n)=>{if(t.length===1&&t[0]===n){let r=!1;try{const i={};e(i)===i&&(r=!0)}catch{}if(r){let i;try{throw new Error}catch(s){({stack:i}=s)}console.warn(`The result function returned its own inputs without modification. e.g
\`createSelector([state => state.todos], todos => todos)\`
This could lead to inefficient memoization and unnecessary re-renders.
Ensure transformation logic is in the result function, and extraction logic is in the input selectors.`,{stack:i})}}},Ls=(e,t,n)=>{const{memoize:r,memoizeOptions:i}=t,{inputSelectorResults:s,inputSelectorResultsCopy:o}=e,c=r(()=>({}),...i);if(!(c.apply(null,s)===c.apply(null,o))){let l;try{throw new Error}catch(h){({stack:l}=h)}console.warn(`An input selector returned a different result when passed same arguments.
This means your output selector will likely run more frequently than intended.
Avoid returning a new reference inside your input selector, e.g.
\`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)\``,{arguments:n,firstInputs:s,secondInputs:o,stack:l})}},Bs={inputStabilityCheck:"once",identityFunctionCheck:"once"};function Fs(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function $s(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function Vs(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var Ir=e=>Array.isArray(e)?e:[e];function Ws(e){const t=Array.isArray(e[0])?e[0]:e;return Vs(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function kr(e,t){const n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}var Ks=(e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:r}={...Bs,...t};return{identityFunctionCheck:{shouldRun:n==="always"||n==="once"&&e,run:Ms},inputStabilityCheck:{shouldRun:r==="always"||r==="once"&&e,run:Ls}}},qs=class{constructor(e){this.value=e}deref(){return this.value}},Gs=typeof WeakRef<"u"?WeakRef:qs,Js=0,Cr=1;function Zt(){return{s:Js,v:void 0,o:null,p:null}}function oi(e,t={}){let n=Zt();const{resultEqualityCheck:r}=t;let i,s=0;function o(){var m;let c=n;const{length:u}=arguments;for(let b=0,A=u;b<A;b++){const _=arguments[b];if(typeof _=="function"||typeof _=="object"&&_!==null){let k=c.o;k===null&&(c.o=k=new WeakMap);const x=k.get(_);x===void 0?(c=Zt(),k.set(_,c)):c=x}else{let k=c.p;k===null&&(c.p=k=new Map);const x=k.get(_);x===void 0?(c=Zt(),k.set(_,c)):c=x}}const l=c;let h;if(c.s===Cr)h=c.v;else if(h=e.apply(null,arguments),s++,r){const b=((m=i==null?void 0:i.deref)==null?void 0:m.call(i))??i;b!=null&&r(b,h)&&(h=b,s!==0&&s--),i=typeof h=="object"&&h!==null||typeof h=="function"?new Gs(h):h}return l.s=Cr,l.v=h,h}return o.clearCache=()=>{n=Zt(),o.resetResultsCount()},o.resultsCount=()=>s,o.resetResultsCount=()=>{s=0},o}function Hs(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...i)=>{let s=0,o=0,c,u={},l=i.pop();typeof l=="object"&&(u=l,l=i.pop()),Fs(l,`createSelector expects an output function after the inputs, but received: [${typeof l}]`);const h={...n,...u},{memoize:m,memoizeOptions:b=[],argsMemoize:A=oi,argsMemoizeOptions:_=[],devModeChecks:k={}}=h,x=Ir(b),L=Ir(_),F=Ws(i),O=m(function(){return s++,l.apply(null,arguments)},...x);let P=!0;const B=A(function(){o++;const J=kr(F,arguments);c=O.apply(null,J);{const{identityFunctionCheck:w,inputStabilityCheck:p}=Ks(P,k);if(w.shouldRun&&w.run(l,J,c),p.shouldRun){const N=kr(F,arguments);p.run({inputSelectorResults:J,inputSelectorResultsCopy:N},{memoize:m,memoizeOptions:x},arguments)}P&&(P=!1)}return c},...L);return Object.assign(B,{resultFunc:l,memoizedResultFunc:O,dependencies:F,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>c,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:m,argsMemoize:A})};return Object.assign(r,{withTypes:()=>r}),r}var ct=Hs(oi),Ys=Object.assign((e,t=ct)=>{$s(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const n=Object.keys(e),r=n.map(s=>e[s]);return t(r,(...s)=>s.reduce((o,c,u)=>(o[n[u]]=c,o),{}))},{withTypes:()=>Ys});function ai(e){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,e):i(s)}var Qs=ai(),Xs=ai,Zs=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?pn:pn.apply(null,arguments)},ci=e=>e&&typeof e.match=="function";function $t(e,t){function n(...r){if(t){let i=t(...r);if(!i)throw new Error("prepareAction did not return an object");return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>Xr(r)&&r.type===e,n}function eo(e){return typeof e=="function"&&"type"in e&&ci(e)}function to(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. 
Make sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}function no(e={}){const{isActionCreator:t=eo}=e;return()=>n=>r=>(t(r)&&console.warn(to(r.type)),n(r))}function ui(e,t){let n=0;return{measureTime(r){const i=Date.now();try{return r()}finally{const s=Date.now();n+=s-i}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. 
If your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.
It is disabled in production builds, so you don't need to worry about that.`)}}}var li=class Lt extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,Lt.prototype)}static get[Symbol.species](){return Lt}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new Lt(...t[0].concat(this)):new Lt(...t.concat(this))}};function xr(e){return pt(e)?si(e,()=>{}):e}function tr(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function ro(e){return typeof e!="object"||e==null||Object.isFrozen(e)}function io(e,t,n){const r=fi(e,t,n);return{detectMutations(){return di(e,t,r,n)}}}function fi(e,t=[],n,r="",i=new Set){const s={value:n};if(!e(n)&&!i.has(n)){i.add(n),s.children={};for(const o in n){const c=r?r+"."+o:o;t.length&&t.indexOf(c)!==-1||(s.children[o]=fi(e,t,n[o],c))}}return s}function di(e,t=[],n,r,i=!1,s=""){const o=n?n.value:void 0,c=o===r;if(i&&!c&&!Number.isNaN(r))return{wasMutated:!0,path:s};if(e(o)||e(r))return{wasMutated:!1};const u={};for(let h in n.children)u[h]=!0;for(let h in r)u[h]=!0;const l=t.length>0;for(let h in u){const m=s?s+"."+h:h;if(l&&t.some(_=>_ instanceof RegExp?_.test(m):m===_))continue;const b=di(e,t,n.children[h],r[h],c,m);if(b.wasMutated)return b}return{wasMutated:!1}}function so(e={}){{let t=function(c,u,l,h){return JSON.stringify(c,n(u,h),l)},n=function(c,u){let l=[],h=[];return u||(u=function(m,b){return l[0]===b?"[Circular ~]":"[Circular ~."+h.slice(0,l.indexOf(b)).join(".")+"]"}),function(m,b){if(l.length>0){var A=l.indexOf(this);~A?l.splice(A+1):l.push(this),~A?h.splice(A,1/0,m):h.push(m),~l.indexOf(b)&&(b=u.call(this,m,b))}else l.push(b);return c==null?b:c.call(this,m,b)}},{isImmutable:r=ro,ignoredPaths:i,warnAfter:s=32}=e;const o=io.bind(null,r,i);return({getState:c})=>{let u=c(),l=o(u),h;return m=>b=>{const A=ui(s,"ImmutableStateInvariantMiddleware");A.measureTime(()=>{if(u=c(),h=l.detectMutations(),l=o(u),h.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${h.path||""}'.  This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)});const _=m(b);return A.measureTime(()=>{if(u=c(),h=l.detectMutations(),l=o(u),h.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${h.path||""}. Take a look at the reducer(s) handling the action ${t(b)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}),A.warnIfExceeded(),_}}}}function hi(e){const t=typeof e;return e==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(e)||Gt(e)}function nr(e,t="",n=hi,r,i=[],s){let o;if(!n(e))return{keyPath:t||"<root>",value:e};if(typeof e!="object"||e===null||s!=null&&s.has(e))return!1;const c=r!=null?r(e):Object.entries(e),u=i.length>0;for(const[l,h]of c){const m=t?t+"."+l:l;if(!(u&&i.some(A=>A instanceof RegExp?A.test(m):m===A))){if(!n(h))return{keyPath:m,value:h};if(typeof h=="object"&&(o=nr(h,m,n,r,i,s),o))return o}}return s&&pi(e)&&s.add(e),!1}function pi(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if(!(typeof t!="object"||t===null)&&!pi(t))return!1;return!0}function oo(e={}){{const{isSerializable:t=hi,getEntries:n,ignoredActions:r=[],ignoredActionPaths:i=["meta.arg","meta.baseQueryMeta"],ignoredPaths:s=[],warnAfter:o=32,ignoreState:c=!1,ignoreActions:u=!1,disableCache:l=!1}=e,h=!l&&WeakSet?new WeakSet:void 0;return m=>b=>A=>{if(!Xr(A))return b(A);const _=b(A),k=ui(o,"SerializableStateInvariantMiddleware");return!u&&!(r.length&&r.indexOf(A.type)!==-1)&&k.measureTime(()=>{const x=nr(A,"",t,n,i,h);if(x){const{keyPath:L,value:F}=x;console.error(`A non-serializable value was detected in an action, in the path: \`${L}\`. Value:`,F,`
Take a look at the logic that dispatched this action: `,A,`
(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)`,`
(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)`)}}),c||(k.measureTime(()=>{const x=m.getState(),L=nr(x,"",t,n,s,h);if(L){const{keyPath:F,value:O}=L;console.error(`A non-serializable value was detected in the state, in the path: \`${F}\`. Value:`,O,`
Take a look at the reducer(s) handling this action type: ${A.type}.
(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}}),k.warnIfExceeded()),_}}}function en(e){return typeof e=="boolean"}var ao=()=>function(t){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=t??{};let o=new li;n&&(en(n)?o.push(Qs):o.push(Xs(n.extraArgument)));{if(r){let c={};en(r)||(c=r),o.unshift(so(c))}if(i){let c={};en(i)||(c=i),o.push(oo(c))}if(s){let c={};en(s)||(c=s),o.unshift(no(c))}}return o},co="RTK_autoBatch",Nr=e=>t=>{setTimeout(t,e)},uo=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let i=!0,s=!1,o=!1;const c=new Set,u=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Nr(10):e.type==="callback"?e.queueNotification:Nr(e.timeout),l=()=>{o=!1,s&&(s=!1,c.forEach(h=>h()))};return Object.assign({},r,{subscribe(h){const m=()=>i&&h(),b=r.subscribe(m);return c.add(h),()=>{b(),c.delete(h)}},dispatch(h){var m;try{return i=!((m=h==null?void 0:h.meta)!=null&&m[co]),s=!i,s&&(o||(o=!0,u(l))),r.dispatch(h)}finally{i=!0}}})},lo=e=>function(n){const{autoBatch:r=!0}=n??{};let i=new li(e);return r&&i.push(uo(typeof r=="object"?r:void 0)),i};function Ac(e){const t=ao(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:s=void 0,enhancers:o=void 0}=e||{};let c;if(typeof n=="function")c=n;else if(Gt(n))c=Qr(n);else throw new Error("`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");if(r&&typeof r!="function")throw new Error("`middleware` field must be a callback");let u;if(typeof r=="function"){if(u=r(t),!Array.isArray(u))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else u=t();if(u.some(_=>typeof _!="function"))throw new Error("each middleware provided to configureStore must be a function");let l=pn;i&&(l=Zs({trace:!0,...typeof i=="object"&&i}));const h=As(...u),m=lo(h);if(o&&typeof o!="function")throw new Error("`enhancers` field must be a callback");let b=typeof o=="function"?o(m):m();if(!Array.isArray(b))throw new Error("`enhancers` callback must return an array");if(b.some(_=>typeof _!="function"))throw new Error("each enhancer provided to configureStore must be a function");u.length&&!b.includes(h)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");const A=l(...b);return Yr(c,s,A)}function yi(e){const t={},n=[];let r;const i={addCase(s,o){{if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(r)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const c=typeof s=="string"?s:s.type;if(!c)throw new Error("`builder.addCase` cannot be called with an empty action type");if(c in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${c}'`);return t[c]=o,i},addMatcher(s,o){if(r)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:s,reducer:o}),i},addDefaultCase(s){if(r)throw new Error("`builder.addDefaultCase` can only be called once");return r=s,i}};return e(i),[t,n,r]}function fo(e){return typeof e=="function"}function ho(e,t){if(typeof t=="object")throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let[n,r,i]=yi(t),s;if(fo(e))s=()=>xr(e());else{const c=xr(e);s=()=>c}function o(c=s(),u){let l=[n[u.type],...r.filter(({matcher:h})=>h(u)).map(({reducer:h})=>h)];return l.filter(h=>!!h).length===0&&(l=[i]),l.reduce((h,m)=>{if(m)if(It(h)){const A=m(h,u);return A===void 0?h:A}else{if(pt(h))return si(h,b=>m(b,u));{const b=m(h,u);if(b===void 0){if(h===null)return h;throw Error("A case reducer on a non-draftable value must not return undefined")}return b}}return h},c)}return o.getInitialState=s,o}var po=(e,t)=>ci(e)?e.match(t):e(t);function yo(...e){return t=>e.some(n=>po(n,t))}var mo="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",mi=(e=21)=>{let t="",n=e;for(;n--;)t+=mo[Math.random()*64|0];return t},go=["name","message","stack","code"],zn=class{constructor(e,t){Nn(this,"_type");this.payload=e,this.meta=t}},Pr=class{constructor(e,t){Nn(this,"_type");this.payload=e,this.meta=t}},wo=e=>{if(typeof e=="object"&&e!==null){const t={};for(const n of go)typeof e[n]=="string"&&(t[n]=e[n]);return t}return{message:String(e)}},Ht=(()=>{function e(t,n,r){const i=$t(t+"/fulfilled",(u,l,h,m)=>({payload:u,meta:{...m||{},arg:h,requestId:l,requestStatus:"fulfilled"}})),s=$t(t+"/pending",(u,l,h)=>({payload:void 0,meta:{...h||{},arg:l,requestId:u,requestStatus:"pending"}})),o=$t(t+"/rejected",(u,l,h,m,b)=>({payload:m,error:(r&&r.serializeError||wo)(u||"Rejected"),meta:{...b||{},arg:h,requestId:l,rejectedWithValue:!!m,requestStatus:"rejected",aborted:(u==null?void 0:u.name)==="AbortError",condition:(u==null?void 0:u.name)==="ConditionError"}}));function c(u){return(l,h,m)=>{const b=r!=null&&r.idGenerator?r.idGenerator(u):mi(),A=new AbortController;let _,k;function x(F){k=F,A.abort()}const L=async function(){var P,B;let F;try{let z=(P=r==null?void 0:r.condition)==null?void 0:P.call(r,u,{getState:h,extra:m});if(vo(z)&&(z=await z),z===!1||A.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const J=new Promise((w,p)=>{_=()=>{p({name:"AbortError",message:k||"Aborted"})},A.signal.addEventListener("abort",_)});l(s(b,u,(B=r==null?void 0:r.getPendingMeta)==null?void 0:B.call(r,{requestId:b,arg:u},{getState:h,extra:m}))),F=await Promise.race([J,Promise.resolve(n(u,{dispatch:l,getState:h,extra:m,requestId:b,signal:A.signal,abort:x,rejectWithValue:(w,p)=>new zn(w,p),fulfillWithValue:(w,p)=>new Pr(w,p)})).then(w=>{if(w instanceof zn)throw w;return w instanceof Pr?i(w.payload,b,u,w.meta):i(w,b,u)})])}catch(z){F=z instanceof zn?o(null,b,u,z.payload,z.meta):o(z,b,u)}finally{_&&A.signal.removeEventListener("abort",_)}return r&&!r.dispatchConditionRejection&&o.match(F)&&F.meta.condition||l(F),F}();return Object.assign(L,{abort:x,requestId:b,arg:u,unwrap(){return L.then(bo)}})}}return Object.assign(c,{pending:s,rejected:o,fulfilled:i,settled:yo(o,i),typePrefix:t})}return e.withTypes=()=>e,e})();function bo(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function vo(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var So=Symbol.for("rtk-slice-createasyncthunk");function _o(e,t){return`${e}/${t}`}function To({creators:e}={}){var n;const t=(n=e==null?void 0:e.asyncThunk)==null?void 0:n[So];return function(i){const{name:s,reducerPath:o=s}=i;if(!s)throw new Error("`name` is a required option for createSlice");typeof process<"u"&&i.initialState===void 0&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const c=(typeof i.reducers=="function"?i.reducers(Ao()):i.reducers)||{},u=Object.keys(c),l={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},h={addCase(O,P){const B=typeof O=="string"?O:O.type;if(!B)throw new Error("`context.addCase` cannot be called with an empty action type");if(B in l.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+B);return l.sliceCaseReducersByType[B]=P,h},addMatcher(O,P){return l.sliceMatchers.push({matcher:O,reducer:P}),h},exposeAction(O,P){return l.actionCreators[O]=P,h},exposeCaseReducer(O,P){return l.sliceCaseReducersByName[O]=P,h}};u.forEach(O=>{const P=c[O],B={reducerName:O,type:_o(s,O),createNotation:typeof i.reducers=="function"};Io(P)?Co(B,P,h,t):Oo(B,P,h)});function m(){if(typeof i.extraReducers=="object")throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[O={},P=[],B=void 0]=typeof i.extraReducers=="function"?yi(i.extraReducers):[i.extraReducers],z={...O,...l.sliceCaseReducersByType};return ho(i.initialState,J=>{for(let w in z)J.addCase(w,z[w]);for(let w of l.sliceMatchers)J.addMatcher(w.matcher,w.reducer);for(let w of P)J.addMatcher(w.matcher,w.reducer);B&&J.addDefaultCase(B)})}const b=O=>O,A=new Map;let _;function k(O,P){return _||(_=m()),_(O,P)}function x(){return _||(_=m()),_.getInitialState()}function L(O,P=!1){function B(J){let w=J[O];if(typeof w>"u")if(P)w=x();else throw new Error("selectSlice returned undefined for an uninjected slice reducer");return w}function z(J=b){const w=tr(A,P,()=>new WeakMap);return tr(w,J,()=>{const p={};for(const[N,v]of Object.entries(i.selectors??{}))p[N]=Eo(v,J,x,P);return p})}return{reducerPath:O,getSelectors:z,get selectors(){return z(B)},selectSlice:B}}const F={name:s,reducer:k,actions:l.actionCreators,caseReducers:l.sliceCaseReducersByName,getInitialState:x,...L(o),injectInto(O,{reducerPath:P,...B}={}){const z=P??o;return O.inject({reducerPath:z,reducer:k},B),{...F,...L(z,!0)}}};return F}}function Eo(e,t,n,r){function i(s,...o){let c=t(s);if(typeof c>"u")if(r)c=n();else throw new Error("selectState returned undefined for an uninjected slice reducer");return e(c,...o)}return i.unwrapped=e,i}var gi=To();function Ao(){function e(t,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...n}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function Oo({type:e,reducerName:t,createNotation:n},r,i){let s,o;if("reducer"in r){if(n&&!ko(r))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");s=r.reducer,o=r.prepare}else s=r;i.addCase(e,s).exposeCaseReducer(t,s).exposeAction(t,o?$t(e,o):$t(e))}function Io(e){return e._reducerDefinitionType==="asyncThunk"}function ko(e){return e._reducerDefinitionType==="reducerWithPrepare"}function Co({type:e,reducerName:t},n,r,i){if(!i)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:s,fulfilled:o,pending:c,rejected:u,settled:l,options:h}=n,m=i(e,s,h);r.exposeAction(t,m),o&&r.addCase(m.fulfilled,o),c&&r.addCase(m.pending,c),u&&r.addCase(m.rejected,u),l&&r.addMatcher(m.settled,l),r.exposeCaseReducer(t,{fulfilled:o||tn,pending:c||tn,rejected:u||tn,settled:l||tn})}function tn(){}var xo=e=>"reducerPath"in e&&typeof e.reducerPath=="string",No=e=>e.flatMap(t=>xo(t)?[[t.reducerPath,t.reducer]]:Object.entries(t)),lr=Symbol.for("rtk-state-proxy-original"),Po=e=>!!e&&!!e[lr],Ro=new WeakMap,jo=(e,t)=>tr(Ro,e,()=>new Proxy(e,{get:(n,r,i)=>{if(r===lr)return n;const s=Reflect.get(n,r,i);if(typeof s>"u"){const o=t[r.toString()];if(o){const c=o(void 0,{type:mi()});if(typeof c>"u")throw new Error(`The slice reducer for key "${r.toString()}" returned undefined when called for selector(). If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);return c}}return s}})),Uo=e=>{if(!Po(e))throw new Error("original must be used on state Proxy");return e[lr]},Do=(e={})=>e;function Oc(...e){const t=Object.fromEntries(No(e)),n=()=>Object.keys(t).length?Qr(t):Do;let r=n();function i(c,u){return r(c,u)}i.withLazyLoadedSlices=()=>i;const s=(c,u={})=>{const{reducerPath:l,reducer:h}=c,m=t[l];return!u.overrideExisting&&m&&m!==h?(typeof process<"u"&&console.error(`called \`inject\` to override already-existing reducer ${l} without specifying \`overrideExisting: true\``),i):(t[l]=h,r=n(),i)},o=Object.assign(function(u,l){return function(m,...b){return u(jo(l?l(m,...b):m,t),...b)}},{original:Uo});return Object.assign(i,{inject:s,selector:o})}function wi(e,t,n,r){if(r.state=="beforeStart"&&(e.id===t||e.id===n)){r.state="recording",r.ids.push(e.id);return}if(r.state!=="afterEnd"){if(r.state=="recording"&&((e.id===t||e.id===n)&&(r.state="afterEnd"),e.id)){r.ids.push(e.id);return}for(const i of e.childNodes)i.nodeType===Node.ELEMENT_NODE&&wi(i,t,n,r)}}function zo(e,t){const n=[];return wi(document.body,e,t,{ids:n,state:"beforeStart"}),n}const Mo=7,Lo={expandedTags:[],selectedUrls:[],similarUrls:{},similarTags:{},latestSelectionId:void 0,tabIndex:2,searchInput:"",queryTokens:[],autoComputeSimilarity:!0};function Ic(e,t,n){return`pagerow ${e} ${t} ${n}`}function Bo(e){return e.split(" ")[1]}const Fo=gi({name:"ui",initialState:Lo,reducers:{toggleSelected:(e,t)=>{const{url:n,id:r}=t.payload;e.selectedUrls.includes(n.normalized)?e.selectedUrls=e.selectedUrls.filter(i=>i!=n.normalized):(e.selectedUrls.push(n.normalized),e.latestSelectionId=r)},rangeSelected:(e,t)=>{if(!e.latestSelectionId)return;const r=zo(e.latestSelectionId,t.payload.id).filter(i=>i.startsWith("pagerow"));re.debug("[UI] selectedIds",r),e.selectedUrls=r.map(Bo)},clearSelection:e=>{e.selectedUrls=[],e.latestSelectionId=void 0,e.autoComputeSimilarity&&(e.similarUrls={},e.similarTags={})},clearSelectionAndSelect:(e,t)=>{const{url:n,id:r}=t.payload;e.latestSelectionId=r,e.selectedUrls=[n.normalized],e.autoComputeSimilarity&&(e.similarUrls={},e.similarTags={})},clearSelectionAndSelectMulti:(e,t)=>{const{urls:n}=t.payload;re.debug("clearSelectionAndSelectMulti"),e.latestSelectionId=void 0,e.selectedUrls=n.map(r=>r.normalized),e.autoComputeSimilarity&&(e.similarUrls={},e.similarTags={})},addMultiToSelection:(e,t)=>{const r=t.payload.filter(i=>!e.selectedUrls.includes(i));e.selectedUrls.push(...r),r.length>0&&(e.latestSelectionId=void 0)},removeMultiFromSelection:(e,t)=>{const n=t.payload;e.selectedUrls=e.selectedUrls.filter(r=>!n.includes(r)),e.latestSelectionId=void 0},setTagExpanded:(e,t)=>{const{tag:n,expanded:r}=t.payload;r?e.expandedTags.push(n):e.expandedTags=e.expandedTags.filter(i=>i!=n)},renameTagInExpanded:(e,t)=>{const{oldTag:n,newTag:r}=t.payload;e.expandedTags=e.expandedTags.map(i=>i===n?r:i)},focusTag:(e,t)=>{const{tag:n}=t.payload;re.debug("[UI] focusTag",n),e.expandedTags=[n]},expandAllTags:(e,t)=>{e.expandedTags=[...t.payload.tags]},collapseAllTags:e=>{e.expandedTags=[]},setTabIndex:(e,t)=>{re.debug("[UI] setTabIndex",t.payload),e.tabIndex=t.payload},setSearchInput:(e,t)=>{e.searchInput=t.payload,e.queryTokens=e.searchInput.split(" ").filter(n=>n.length>0).map(n=>n.toLowerCase())},newSearch:e=>{e.tabIndex=Mo,e.searchInput="",e.queryTokens=[]},setSimilarUrls:(e,t)=>{e.similarUrls=t.payload},setSimilarTags:(e,t)=>{e.similarTags=t.payload},setAutoComputeSimilarity:(e,t)=>{e.autoComputeSimilarity=t.payload}},extraReducers:e=>{}}),$o=e=>e.ui.selectedUrls,kc=e=>e.ui.similarUrls,Cc=(e,t)=>e.ui.expandedTags.includes(t),xc=e=>e.ui.tabIndex,Nc=e=>e.ui.searchInput,Pc=e=>e.ui.queryTokens,Rc=e=>e.ui.similarTags,jc=e=>e.ui.autoComputeSimilarity,{toggleSelected:Uc,rangeSelected:Dc,clearSelection:zc,clearSelectionAndSelect:Mc,clearSelectionAndSelectMulti:Lc,addMultiToSelection:Bc,removeMultiFromSelection:Fc,renameTagInExpanded:$c,focusTag:Vc,setTagExpanded:Wc,expandAllTags:Kc,collapseAllTags:qc,setTabIndex:Vo,setSearchInput:Wo,newSearch:Gc,setSimilarUrls:bi,setSimilarTags:Ko,setAutoComputeSimilarity:Jc}=Fo.actions;function Hc(e,t){e&&t&&(chrome.windows.update(e,{focused:!0}),chrome.tabs.update(t,{active:!0}))}function qo(e){e&&chrome.tabs.remove(e)}async function Yc(){const e=chrome.runtime.getURL("src/options/options.html"),t=await chrome.tabs.query({url:e});t.length>0&&t[0].id&&t[0].windowId?(await chrome.windows.update(t[0].windowId,{focused:!0}),await chrome.tabs.update(t[0].id,{active:!0})):await chrome.windows.create({url:e,type:"popup",focused:!0,width:1024,height:800})}const Go="ENTRIES",vi="KEYS",Si="VALUES",xe="";class Mn{constructor(t,n){const r=t._tree,i=Array.from(r.keys());this.set=t,this._type=n,this._path=i.length>0?[{node:r,keys:i}]:[]}next(){const t=this.dive();return this.backtrack(),t}dive(){if(this._path.length===0)return{done:!0,value:void 0};const{node:t,keys:n}=Rt(this._path);if(Rt(n)===xe)return{done:!1,value:this.result()};const r=t.get(Rt(n));return this._path.push({node:r,keys:Array.from(r.keys())}),this.dive()}backtrack(){if(this._path.length===0)return;const t=Rt(this._path).keys;t.pop(),!(t.length>0)&&(this._path.pop(),this.backtrack())}key(){return this.set._prefix+this._path.map(({keys:t})=>Rt(t)).filter(t=>t!==xe).join("")}value(){return Rt(this._path).node.get(xe)}result(){switch(this._type){case Si:return this.value();case vi:return this.key();default:return[this.key(),this.value()]}}[Symbol.iterator](){return this}}const Rt=e=>e[e.length-1],Jo=(e,t,n)=>{const r=new Map;if(t===void 0)return r;const i=t.length+1,s=i+n,o=new Uint8Array(s*i).fill(n+1);for(let c=0;c<i;++c)o[c]=c;for(let c=1;c<s;++c)o[c*i]=c;return _i(e,t,n,r,o,1,i,""),r},_i=(e,t,n,r,i,s,o,c)=>{const u=s*o;e:for(const l of e.keys())if(l===xe){const h=i[u-1];h<=n&&r.set(c,[e.get(l),h])}else{let h=s;for(let m=0;m<l.length;++m,++h){const b=l[m],A=o*h,_=A-o;let k=i[A];const x=Math.max(0,h-n-1),L=Math.min(o-1,h+n);for(let F=x;F<L;++F){const O=b!==t[F],P=i[_+F]+ +O,B=i[_+F+1]+1,z=i[A+F]+1,J=i[A+F+1]=Math.min(P,B,z);J<k&&(k=J)}if(k>n)continue e}_i(e.get(l),t,n,r,i,h,o,c+l)}};class wt{constructor(t=new Map,n=""){this._size=void 0,this._tree=t,this._prefix=n}atPrefix(t){if(!t.startsWith(this._prefix))throw new Error("Mismatched prefix");const[n,r]=wn(this._tree,t.slice(this._prefix.length));if(n===void 0){const[i,s]=fr(r);for(const o of i.keys())if(o!==xe&&o.startsWith(s)){const c=new Map;return c.set(o.slice(s.length),i.get(o)),new wt(c,t)}}return new wt(n,t)}clear(){this._size=void 0,this._tree.clear()}delete(t){return this._size=void 0,Ho(this._tree,t)}entries(){return new Mn(this,Go)}forEach(t){for(const[n,r]of this)t(n,r,this)}fuzzyGet(t,n){return Jo(this._tree,t,n)}get(t){const n=rr(this._tree,t);return n!==void 0?n.get(xe):void 0}has(t){const n=rr(this._tree,t);return n!==void 0&&n.has(xe)}keys(){return new Mn(this,vi)}set(t,n){if(typeof t!="string")throw new Error("key must be a string");return this._size=void 0,Ln(this._tree,t).set(xe,n),this}get size(){if(this._size)return this._size;this._size=0;const t=this.entries();for(;!t.next().done;)this._size+=1;return this._size}update(t,n){if(typeof t!="string")throw new Error("key must be a string");this._size=void 0;const r=Ln(this._tree,t);return r.set(xe,n(r.get(xe))),this}fetch(t,n){if(typeof t!="string")throw new Error("key must be a string");this._size=void 0;const r=Ln(this._tree,t);let i=r.get(xe);return i===void 0&&r.set(xe,i=n()),i}values(){return new Mn(this,Si)}[Symbol.iterator](){return this.entries()}static from(t){const n=new wt;for(const[r,i]of t)n.set(r,i);return n}static fromObject(t){return wt.from(Object.entries(t))}}const wn=(e,t,n=[])=>{if(t.length===0||e==null)return[e,n];for(const r of e.keys())if(r!==xe&&t.startsWith(r))return n.push([e,r]),wn(e.get(r),t.slice(r.length),n);return n.push([e,t]),wn(void 0,"",n)},rr=(e,t)=>{if(t.length===0||e==null)return e;for(const n of e.keys())if(n!==xe&&t.startsWith(n))return rr(e.get(n),t.slice(n.length))},Ln=(e,t)=>{const n=t.length;e:for(let r=0;e&&r<n;){for(const s of e.keys())if(s!==xe&&t[r]===s[0]){const o=Math.min(n-r,s.length);let c=1;for(;c<o&&t[r+c]===s[c];)++c;const u=e.get(s);if(c===s.length)e=u;else{const l=new Map;l.set(s.slice(c),u),e.set(t.slice(r,r+c),l),e.delete(s),e=l}r+=c;continue e}const i=new Map;return e.set(t.slice(r),i),i}return e},Ho=(e,t)=>{const[n,r]=wn(e,t);if(n!==void 0){if(n.delete(xe),n.size===0)Ti(r);else if(n.size===1){const[i,s]=n.entries().next().value;Ei(r,i,s)}}},Ti=e=>{if(e.length===0)return;const[t,n]=fr(e);if(t.delete(n),t.size===0)Ti(e.slice(0,-1));else if(t.size===1){const[r,i]=t.entries().next().value;r!==xe&&Ei(e.slice(0,-1),r,i)}},Ei=(e,t,n)=>{if(e.length===0)return;const[r,i]=fr(e);r.set(i+t,n),r.delete(i)},fr=e=>e[e.length-1],dr="or",Ai="and",Yo="and_not";class Dt{constructor(t){if((t==null?void 0:t.fields)==null)throw new Error('MiniSearch: option "fields" must be provided');const n=t.autoVacuum==null||t.autoVacuum===!0?$n:t.autoVacuum;this._options={...Fn,...t,autoVacuum:n,searchOptions:{...Rr,...t.searchOptions||{}},autoSuggestOptions:{...ta,...t.autoSuggestOptions||{}}},this._index=new wt,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=sr,this.addFields(this._options.fields)}add(t){const{extractField:n,stringifyField:r,tokenize:i,processTerm:s,fields:o,idField:c}=this._options,u=n(t,c);if(u==null)throw new Error(`MiniSearch: document does not have ID field "${c}"`);if(this._idToShortId.has(u))throw new Error(`MiniSearch: duplicate ID ${u}`);const l=this.addDocumentId(u);this.saveStoredFields(l,t);for(const h of o){const m=n(t,h);if(m==null)continue;const b=i(r(m,h),h),A=this._fieldIds[h],_=new Set(b).size;this.addFieldLength(l,A,this._documentCount-1,_);for(const k of b){const x=s(k,h);if(Array.isArray(x))for(const L of x)this.addTerm(A,l,L);else x&&this.addTerm(A,l,x)}}}addAll(t){for(const n of t)this.add(n)}addAllAsync(t,n={}){const{chunkSize:r=10}=n,i={chunk:[],promise:Promise.resolve()},{chunk:s,promise:o}=t.reduce(({chunk:c,promise:u},l,h)=>(c.push(l),(h+1)%r===0?{chunk:[],promise:u.then(()=>new Promise(m=>setTimeout(m,0))).then(()=>this.addAll(c))}:{chunk:c,promise:u}),i);return o.then(()=>this.addAll(s))}remove(t){const{tokenize:n,processTerm:r,extractField:i,stringifyField:s,fields:o,idField:c}=this._options,u=i(t,c);if(u==null)throw new Error(`MiniSearch: document does not have ID field "${c}"`);const l=this._idToShortId.get(u);if(l==null)throw new Error(`MiniSearch: cannot remove document with ID ${u}: it is not in the index`);for(const h of o){const m=i(t,h);if(m==null)continue;const b=n(s(m,h),h),A=this._fieldIds[h],_=new Set(b).size;this.removeFieldLength(l,A,this._documentCount,_);for(const k of b){const x=r(k,h);if(Array.isArray(x))for(const L of x)this.removeTerm(A,l,L);else x&&this.removeTerm(A,l,x)}}this._storedFields.delete(l),this._documentIds.delete(l),this._idToShortId.delete(u),this._fieldLength.delete(l),this._documentCount-=1}removeAll(t){if(t)for(const n of t)this.remove(n);else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new wt,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}}discard(t){const n=this._idToShortId.get(t);if(n==null)throw new Error(`MiniSearch: cannot discard document with ID ${t}: it is not in the index`);this._idToShortId.delete(t),this._documentIds.delete(n),this._storedFields.delete(n),(this._fieldLength.get(n)||[]).forEach((r,i)=>{this.removeFieldLength(n,i,this._documentCount,r)}),this._fieldLength.delete(n),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()}maybeAutoVacuum(){if(this._options.autoVacuum===!1)return;const{minDirtFactor:t,minDirtCount:n,batchSize:r,batchWait:i}=this._options.autoVacuum;this.conditionalVacuum({batchSize:r,batchWait:i},{minDirtCount:n,minDirtFactor:t})}discardAll(t){const n=this._options.autoVacuum;try{this._options.autoVacuum=!1;for(const r of t)this.discard(r)}finally{this._options.autoVacuum=n}this.maybeAutoVacuum()}replace(t){const{idField:n,extractField:r}=this._options,i=r(t,n);this.discard(i),this.add(t)}vacuum(t={}){return this.conditionalVacuum(t)}conditionalVacuum(t,n){return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&n,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(()=>{const r=this._enqueuedVacuumConditions;return this._enqueuedVacuumConditions=sr,this.performVacuuming(t,r)}),this._enqueuedVacuum)):this.vacuumConditionsMet(n)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(t),this._currentVacuum)}async performVacuuming(t,n){const r=this._dirtCount;if(this.vacuumConditionsMet(n)){const i=t.batchSize||ir.batchSize,s=t.batchWait||ir.batchWait;let o=1;for(const[c,u]of this._index){for(const[l,h]of u)for(const[m]of h)this._documentIds.has(m)||(h.size<=1?u.delete(l):h.delete(m));this._index.get(c).size===0&&this._index.delete(c),o%i===0&&await new Promise(l=>setTimeout(l,s)),o+=1}this._dirtCount-=r}await null,this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null}vacuumConditionsMet(t){if(t==null)return!0;let{minDirtCount:n,minDirtFactor:r}=t;return n=n||$n.minDirtCount,r=r||$n.minDirtFactor,this.dirtCount>=n&&this.dirtFactor>=r}get isVacuuming(){return this._currentVacuum!=null}get dirtCount(){return this._dirtCount}get dirtFactor(){return this._dirtCount/(1+this._documentCount+this._dirtCount)}has(t){return this._idToShortId.has(t)}getStoredFields(t){const n=this._idToShortId.get(t);if(n!=null)return this._storedFields.get(n)}search(t,n={}){const{searchOptions:r}=this._options,i={...r,...n},s=this.executeQuery(t,n),o=[];for(const[c,{score:u,terms:l,match:h}]of s){const m=l.length||1,b={id:this._documentIds.get(c),score:u*m,terms:Object.keys(h),queryTerms:l,match:h};Object.assign(b,this._storedFields.get(c)),(i.filter==null||i.filter(b))&&o.push(b)}return t===Dt.wildcard&&i.boostDocument==null||o.sort(Ur),o}autoSuggest(t,n={}){n={...this._options.autoSuggestOptions,...n};const r=new Map;for(const{score:s,terms:o}of this.search(t,n)){const c=o.join(" "),u=r.get(c);u!=null?(u.score+=s,u.count+=1):r.set(c,{score:s,terms:o,count:1})}const i=[];for(const[s,{score:o,terms:c,count:u}]of r)i.push({suggestion:s,terms:c,score:o/u});return i.sort(Ur),i}get documentCount(){return this._documentCount}get termCount(){return this._index.size}static loadJSON(t,n){if(n==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(t),n)}static async loadJSONAsync(t,n){if(n==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJSAsync(JSON.parse(t),n)}static getDefault(t){if(Fn.hasOwnProperty(t))return Bn(Fn,t);throw new Error(`MiniSearch: unknown option "${t}"`)}static loadJS(t,n){const{index:r,documentIds:i,fieldLength:s,storedFields:o,serializationVersion:c}=t,u=this.instantiateMiniSearch(t,n);u._documentIds=nn(i),u._fieldLength=nn(s),u._storedFields=nn(o);for(const[l,h]of u._documentIds)u._idToShortId.set(h,l);for(const[l,h]of r){const m=new Map;for(const b of Object.keys(h)){let A=h[b];c===1&&(A=A.ds),m.set(parseInt(b,10),nn(A))}u._index.set(l,m)}return u}static async loadJSAsync(t,n){const{index:r,documentIds:i,fieldLength:s,storedFields:o,serializationVersion:c}=t,u=this.instantiateMiniSearch(t,n);u._documentIds=await rn(i),u._fieldLength=await rn(s),u._storedFields=await rn(o);for(const[h,m]of u._documentIds)u._idToShortId.set(m,h);let l=0;for(const[h,m]of r){const b=new Map;for(const A of Object.keys(m)){let _=m[A];c===1&&(_=_.ds),b.set(parseInt(A,10),await rn(_))}++l%1e3===0&&await Oi(0),u._index.set(h,b)}return u}static instantiateMiniSearch(t,n){const{documentCount:r,nextId:i,fieldIds:s,averageFieldLength:o,dirtCount:c,serializationVersion:u}=t;if(u!==1&&u!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");const l=new Dt(n);return l._documentCount=r,l._nextId=i,l._idToShortId=new Map,l._fieldIds=s,l._avgFieldLength=o,l._dirtCount=c||0,l._index=new wt,l}executeQuery(t,n={}){if(t===Dt.wildcard)return this.executeWildcardQuery(n);if(typeof t!="string"){const b={...n,...t,queries:void 0},A=t.queries.map(_=>this.executeQuery(_,b));return this.combineResults(A,b.combineWith)}const{tokenize:r,processTerm:i,searchOptions:s}=this._options,o={tokenize:r,processTerm:i,...s,...n},{tokenize:c,processTerm:u}=o,m=c(t).flatMap(b=>u(b)).filter(b=>!!b).map(ea(o)).map(b=>this.executeQuerySpec(b,o));return this.combineResults(m,o.combineWith)}executeQuerySpec(t,n){const r={...this._options.searchOptions,...n},i=(r.fields||this._options.fields).reduce((k,x)=>({...k,[x]:Bn(r.boost,x)||1}),{}),{boostDocument:s,weights:o,maxFuzzy:c,bm25:u}=r,{fuzzy:l,prefix:h}={...Rr.weights,...o},m=this._index.get(t.term),b=this.termResults(t.term,t.term,1,t.termBoost,m,i,s,u);let A,_;if(t.prefix&&(A=this._index.atPrefix(t.term)),t.fuzzy){const k=t.fuzzy===!0?.2:t.fuzzy,x=k<1?Math.min(c,Math.round(t.term.length*k)):k;x&&(_=this._index.fuzzyGet(t.term,x))}if(A)for(const[k,x]of A){const L=k.length-t.term.length;if(!L)continue;_==null||_.delete(k);const F=h*k.length/(k.length+.3*L);this.termResults(t.term,k,F,t.termBoost,x,i,s,u,b)}if(_)for(const k of _.keys()){const[x,L]=_.get(k);if(!L)continue;const F=l*k.length/(k.length+L);this.termResults(t.term,k,F,t.termBoost,x,i,s,u,b)}return b}executeWildcardQuery(t){const n=new Map,r={...this._options.searchOptions,...t};for(const[i,s]of this._documentIds){const o=r.boostDocument?r.boostDocument(s,"",this._storedFields.get(i)):1;n.set(i,{score:o,terms:[],match:{}})}return n}combineResults(t,n=dr){if(t.length===0)return new Map;const r=n.toLowerCase(),i=Qo[r];if(!i)throw new Error(`Invalid combination operator: ${n}`);return t.reduce(i)||new Map}toJSON(){const t=[];for(const[n,r]of this._index){const i={};for(const[s,o]of r)i[s]=Object.fromEntries(o);t.push([n,i])}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:t,serializationVersion:2}}termResults(t,n,r,i,s,o,c,u,l=new Map){if(s==null)return l;for(const h of Object.keys(o)){const m=o[h],b=this._fieldIds[h],A=s.get(b);if(A==null)continue;let _=A.size;const k=this._avgFieldLength[b];for(const x of A.keys()){if(!this._documentIds.has(x)){this.removeTerm(b,x,n),_-=1;continue}const L=c?c(this._documentIds.get(x),n,this._storedFields.get(x)):1;if(!L)continue;const F=A.get(x),O=this._fieldLength.get(x)[b],P=Zo(F,_,this._documentCount,O,k,u),B=r*i*m*L*P,z=l.get(x);if(z){z.score+=B,na(z.terms,t);const J=Bn(z.match,n);J?J.push(h):z.match[n]=[h]}else l.set(x,{score:B,terms:[t],match:{[n]:[h]}})}}return l}addTerm(t,n,r){const i=this._index.fetch(r,Dr);let s=i.get(t);if(s==null)s=new Map,s.set(n,1),i.set(t,s);else{const o=s.get(n);s.set(n,(o||0)+1)}}removeTerm(t,n,r){if(!this._index.has(r)){this.warnDocumentChanged(n,t,r);return}const i=this._index.fetch(r,Dr),s=i.get(t);s==null||s.get(n)==null?this.warnDocumentChanged(n,t,r):s.get(n)<=1?s.size<=1?i.delete(t):s.delete(n):s.set(n,s.get(n)-1),this._index.get(r).size===0&&this._index.delete(r)}warnDocumentChanged(t,n,r){for(const i of Object.keys(this._fieldIds))if(this._fieldIds[i]===n){this._options.logger("warn",`MiniSearch: document with ID ${this._documentIds.get(t)} has changed before removal: term "${r}" was not present in field "${i}". Removing a document after it has changed can corrupt the index!`,"version_conflict");return}}addDocumentId(t){const n=this._nextId;return this._idToShortId.set(t,n),this._documentIds.set(n,t),this._documentCount+=1,this._nextId+=1,n}addFields(t){for(let n=0;n<t.length;n++)this._fieldIds[t[n]]=n}addFieldLength(t,n,r,i){let s=this._fieldLength.get(t);s==null&&this._fieldLength.set(t,s=[]),s[n]=i;const c=(this._avgFieldLength[n]||0)*r+i;this._avgFieldLength[n]=c/(r+1)}removeFieldLength(t,n,r,i){if(r===1){this._avgFieldLength[n]=0;return}const s=this._avgFieldLength[n]*r-i;this._avgFieldLength[n]=s/(r-1)}saveStoredFields(t,n){const{storeFields:r,extractField:i}=this._options;if(r==null||r.length===0)return;let s=this._storedFields.get(t);s==null&&this._storedFields.set(t,s={});for(const o of r){const c=i(n,o);c!==void 0&&(s[o]=c)}}}Dt.wildcard=Symbol("*");const Bn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0,Qo={[dr]:(e,t)=>{for(const n of t.keys()){const r=e.get(n);if(r==null)e.set(n,t.get(n));else{const{score:i,terms:s,match:o}=t.get(n);r.score=r.score+i,r.match=Object.assign(r.match,o),jr(r.terms,s)}}return e},[Ai]:(e,t)=>{const n=new Map;for(const r of t.keys()){const i=e.get(r);if(i==null)continue;const{score:s,terms:o,match:c}=t.get(r);jr(i.terms,o),n.set(r,{score:i.score+s,terms:i.terms,match:Object.assign(i.match,c)})}return n},[Yo]:(e,t)=>{for(const n of t.keys())e.delete(n);return e}},Xo={k:1.2,b:.7,d:.5},Zo=(e,t,n,r,i,s)=>{const{k:o,b:c,d:u}=s;return Math.log(1+(n-t+.5)/(t+.5))*(u+e*(o+1)/(e+o*(1-c+c*r/i)))},ea=e=>(t,n,r)=>{const i=typeof e.fuzzy=="function"?e.fuzzy(t,n,r):e.fuzzy||!1,s=typeof e.prefix=="function"?e.prefix(t,n,r):e.prefix===!0,o=typeof e.boostTerm=="function"?e.boostTerm(t,n,r):1;return{term:t,fuzzy:i,prefix:s,termBoost:o}},Fn={idField:"id",extractField:(e,t)=>e[t],stringifyField:(e,t)=>e.toString(),tokenize:e=>e.split(ra),processTerm:e=>e.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(e,t)=>{typeof(console==null?void 0:console[e])=="function"&&console[e](t)},autoVacuum:!0},Rr={combineWith:dr,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:Xo},ta={combineWith:Ai,prefix:(e,t,n)=>t===n.length-1},ir={batchSize:1e3,batchWait:10},sr={minDirtFactor:.1,minDirtCount:20},$n={...ir,...sr},na=(e,t)=>{e.includes(t)||e.push(t)},jr=(e,t)=>{for(const n of t)e.includes(n)||e.push(n)},Ur=({score:e},{score:t})=>t-e,Dr=()=>new Map,nn=e=>{const t=new Map;for(const n of Object.keys(e))t.set(parseInt(n,10),e[n]);return t},rn=async e=>{const t=new Map;let n=0;for(const r of Object.keys(e))t.set(parseInt(r,10),e[r]),++n%1e3===0&&await Oi(0);return t},Oi=e=>new Promise(t=>setTimeout(t,e)),ra=/[\n\r\p{Z}\p{P}]+/u;function sn(e){return{url:e.url,title:e.title||"",urlText:[e.url,e.originalUrl].filter(Boolean).join(" "),tags:(e.humanTags||[]).join(" ")}}function ia(e){return e.toLowerCase().split(/[\s\-_./:?&#=+]+/).filter(t=>t.length>0)}const gt=new Dt({fields:["title","urlText","tags"],idField:"url",tokenize:ia,searchOptions:{prefix:!0,combineWith:"AND",boost:{title:2}}});let Vn=null,hr=!1;async function sa(){try{re.info("[Search] Building full-text search index...");const e=await S.pages.toArray();await gt.addAllAsync(e.map(sn),{chunkSize:500}),S.pages.hook("creating",(t,n)=>{gt.has(n.url)?gt.replace(sn(n)):gt.add(sn(n))}),S.pages.hook("updating",function(t,n,r){this.onsuccess=i=>{i&&(gt.discard(i.url),gt.add(sn(i)))}}),S.pages.hook("deleting",t=>{gt.discard(t)}),hr=!0,re.info(`[Search] Index ready with ${e.length} documents.`)}catch(e){re.error("[Search] Failed to initialize search index:",e)}}function Qc(){return Vn||(Vn=sa()),Vn}function oa(){return hr}function aa(e){return!hr||e.length===0?[]:gt.search(e.join(" ")).map(t=>t.id)}function zr(e,t){var n=null,r=!1;return[S.transaction("r",e,()=>{if(r)throw new Ne.AbortError("Query was cancelled");return n=Ne.currentTransaction,t()}),()=>{r=!0,n&&n.abort(),n=null}]}const Xc=()=>S.tags.toCollection().uniqueKeys();function Zc(e=[]){return S.tags.toArray().then(t=>t.filter(n=>!e.includes(n.name)))}const eu=()=>S.tags.count(),ca=e=>e.length==0?[S.tags.toArray(),()=>{}]:S.tags.filter(t=>{const n=t.name.toLowerCase();return e.every(r=>n.includes(r))}).toArray();async function tu(e){const t=await S.tags.get(e);return t==null?void 0:t.last_active}async function nu(e,t){t!=e&&await S.transaction("rw",[S.pages,S.tags,S.progress,S.logs],async()=>{await S.tags.put({name:t,last_active:Pe.now()}),await S.pages.toCollection().modify(n=>{n.humanTags.includes(e)&&(n.humanTags.push(t),n.humanTags=n.humanTags.filter(r=>r!=e)),n.humanRejectedTags.includes(e)&&(n.humanRejectedTags.push(t),n.humanRejectedTags=n.humanRejectedTags.filter(r=>r!=e));for(const r of n.autoTags)r.name==e&&(r.name=t)}),await S.tags.delete(e)})}const ft="#stash",Ii="#flag",ua="#archive",ru=[ft,Ii,ua];function la(e,t,n){var r,i;typeof e=="function"?(r=t||[],i=n):(r=[],i=t);var s=zt.useRef({hasResult:!1,result:i,error:null}),o=zt.useReducer(function(l){return l+1},0);o[0];var c=o[1],u=zt.useMemo(function(){var l=typeof e=="function"?e():e;if(!l||typeof l.subscribe!="function")throw e===l?new TypeError("Given argument to useObservable() was neither a valid observable nor a function."):new TypeError("Observable factory given to useObservable() did not return a valid observable.");if(!s.current.hasResult&&typeof window<"u"&&(typeof l.hasValue!="function"||l.hasValue()))if(typeof l.getValue=="function")s.current.result=l.getValue(),s.current.hasResult=!0;else{var h=l.subscribe(function(m){s.current.result=m,s.current.hasResult=!0});typeof h=="function"?h():h.unsubscribe()}return l},r);if(zt.useDebugValue(s.current.result),zt.useEffect(function(){var l=u.subscribe(function(h){var m=s.current;(m.error!==null||m.result!==h)&&(m.error=null,m.result=h,m.hasResult=!0,c())},function(h){var m=s.current;m.error!==h&&(m.error=h,c())});return typeof l=="function"?l:l.unsubscribe.bind(l)},r),s.current.error)throw s.current.error;return s.current.result}function ki(e,t,n){return la(function(){return Ji(e)},t||[],n)}const iu=hs,fa=ms,Ot=new Map;async function Ue(e,t,n,r,i){const o=Date.now();let c=Ot.get(e);if(c||(c={source:t,type:n,current:r,total:i,lastUpdate:0,timeout:null},Ot.set(e,c)),c.source=t,c.type=n,c.current=r,c.total=i,o-c.lastUpdate>=100||r===i){c.timeout&&(clearTimeout(c.timeout),c.timeout=null),c.lastUpdate=o,await S.progress.put({id:e,source:c.source,type:c.type,current:c.current,total:c.total,updatedAt:o});return}return c.timeout||(c.timeout=setTimeout(()=>{const u=Ot.get(e);u&&(u.lastUpdate=Date.now(),u.timeout=null,S.progress.put({id:e,source:u.source,type:u.type,current:u.current,total:u.total,updatedAt:u.lastUpdate}).catch(l=>re.error("Delayed progress put failed",l)))},100-(o-c.lastUpdate))),Promise.resolve()}async function Ct(e,t=!1){const n=Ot.get(e);if(n&&n.timeout&&clearTimeout(n.timeout),t&&n)try{if(await S.completedProgress.add({originalId:e,source:n.source,type:n.type,total:n.total,completedAt:Date.now()}),await S.completedProgress.count()>10){const i=await S.completedProgress.orderBy("completedAt").first();i&&i.id&&await S.completedProgress.delete(i.id)}}catch(r){re.error("Failed to log completed progress",r)}Ot.delete(e),await S.progress.delete(e)}async function su(){for(const e of Ot.values())e.timeout&&clearTimeout(e.timeout);Ot.clear(),await S.progress.clear()}function ou(){const e=fa(Nt);return(ki(()=>S.progress.toArray())||[]).filter(i=>{if(i.source==="background")return!0;if(i.source.startsWith("window-")){const s=i.source.replace("window-",""),o=parseInt(s);return e[o]!==void 0}return!1}).reduce((i,s)=>({totalWork:i.totalWork+s.total,completedWork:i.completedWork+s.current,activeTasks:i.activeTasks+1,operations:[...i.operations,s]}),{totalWork:0,completedWork:0,activeTasks:0,operations:[]})}function au(){return ki(()=>S.completedProgress.orderBy("completedAt").reverse().limit(10).toArray())||[]}const Ce=[];for(let e=0;e<256;++e)Ce.push((e+256).toString(16).slice(1));function da(e,t=0){return(Ce[e[t+0]]+Ce[e[t+1]]+Ce[e[t+2]]+Ce[e[t+3]]+"-"+Ce[e[t+4]]+Ce[e[t+5]]+"-"+Ce[e[t+6]]+Ce[e[t+7]]+"-"+Ce[e[t+8]]+Ce[e[t+9]]+"-"+Ce[e[t+10]]+Ce[e[t+11]]+Ce[e[t+12]]+Ce[e[t+13]]+Ce[e[t+14]]+Ce[e[t+15]]).toLowerCase()}let Wn;const ha=new Uint8Array(16);function pa(){if(!Wn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Wn=crypto.getRandomValues.bind(crypto)}return Wn(ha)}const ya=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Mr={randomUUID:ya};function xt(e,t,n){var i;if(Mr.randomUUID&&!e)return Mr.randomUUID();e=e||{};const r=e.random??((i=e.rng)==null?void 0:i.call(e))??pa();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,da(r)}const ma="processQueue";async function Ze(e,t,n=100){var s;const r=JSON.stringify(t);if(await S.operations.where({type:e,payloadHash:r}).filter(o=>o.status==="pending"||o.status==="processing").count()>0){re.info(`[Queue] Skipping duplicate operation: ${e}`,t);return}re.info(`[Queue] Enqueuing operation: ${e}`,t),await S.operations.add({type:e,payload:t,payloadHash:r,status:"pending",createdAt:Date.now(),priority:n});try{typeof chrome<"u"&&((s=chrome.runtime)!=null&&s.sendMessage)&&await chrome.runtime.sendMessage(ma)}catch(o){re.debug("Failed to notify background worker:",o)}}async function cu(){re.info("[Queue] Clearing queue of all operations");const e=await S.operations.filter(t=>t.status==="pending"||t.status==="processing").toArray();if(e.length>0){const t=e.map(r=>r.id).filter(r=>r!==void 0),n=100;for(let r=0;r<t.length;r+=n)await S.operations.bulkDelete(t.slice(r,r+n))}}const ga={name:"gemini",matches:e=>/^https:\/\/gemini\.google\.com\//.test(e),transform:(e,t)=>t.replace(/\s*[-\u2013]\s*Gemini\s*$/i,"").trim()||t,isGeneric:e=>/^gemini$/i.test(e.trim())},Ci=[ga];function wa(e,t){for(const n of Ci)if(n.matches(e))return n.transform(e,t);return t}function uu(e,t){var n;for(const r of Ci)if(r.matches(e)&&((n=r.isGeneric)!=null&&n.call(r,t)))return!0;return!1}function dt(e){return{nurl:{normalized:e.url,original:e.originalUrl,domainSortKey:e.domainSortKey},title:e.title,favIconUrl:e.favIconUrl,visible:e.visible,accessTimes:e.accessTimes,lastActiveDesc:e.lastActiveDesc,hotnessDesc:e.hotnessDesc,humanTags:e.humanTags||[],humanRejectedTags:e.humanRejectedTags||[],autoTags:e.autoTags||[],openerUrls:e.openerUrls||[],openedUrls:e.openedUrls||[],timeAdjacentUrls:e.timeAdjacentUrls||[],disableTagPropagation:e.disableTagPropagation,lastWindowId:e.lastWindowId,dueDate:e.dueDate,completionStatus:e.completionStatus,priority:e.priority,creationDate:e.creationDate,embedding:e.embedding}}const xi=(e,t,n,r)=>((!t||t=="")&&(re.info("newDBPage: Empty Title",e.normalized),setTimeout(()=>{Ze("fetchMissingTitle",{url:e.normalized},10).catch(i=>{re.warn("Failed to enqueue fetchMissingTitle for",e.normalized,i)})},0)),{url:e.normalized,originalUrl:e.original,domainSortKey:e.domainSortKey,title:t,favIconUrl:n,visible:"active",accessTimes:r?[r]:[],lastActiveDesc:r?-r:0,hotnessDesc:r?-1:0,humanTags:[],humanRejectedTags:[],autoTags:[],openerUrls:[],openedUrls:[],timeAdjacentUrls:[]});function Ni(e){const t=Date.now(),n=1e3,r=60*n,i=60*r,s=24*i,o=30*s,c=new Set;for(const l of e)t-l<i?c.add(l-l%n):t-l<s?c.add(l-l%r):t-l<o?c.add(l-l%i):c.add(l-l%s);const u=Array.from(c).toSorted();return u.length>1e3?u.slice(-1e3):u}async function ba(e,t,n,r,i,s){if(!e)return;if((!n||n==="")&&!e.normalized.startsWith("todo://")){re.info("ensurePageTracked: Empty Title",e.normalized);return}let o=!1;const c=await S.transaction("rw",[S.pages,S.tags],async()=>{let u=!1,l=await S.pages.get(e.normalized);if(l||(l=xi(e,n,r,t?Date.now():void 0),u=!0),l.embedding?n&&l.title!==n&&(o=!0,l.embedding=void 0,l.embeddingErrored=!1):o=!0,pr(l),n&&(l.title=n,l.titleFetchFailed=void 0),l.favIconUrl=r,l.visible="active",t&&!u){const h=Date.now();l.accessTimes.push(h),l.accessTimes=Ni(l.accessTimes),l.lastActiveDesc=-l.accessTimes.slice(-1)[0],l.hotnessDesc=-l.accessTimes.length,await S.tags.bulkPut(l.humanTags.map(m=>({name:m,last_active:h})))}return l.lastWindowId=i,re.info("ensurePageTracked",l.url),await S.pages.put(l),l});return o&&!(s!=null&&s.skipEmbeddingEnqueue)&&await Ze("generateEmbedding",{url:e.normalized},10),c}const bt=500;async function lu(e,t){const n=ht(e).normalized,r=ht(t).normalized;await S.transaction("rw",[S.pages,S.logs],async()=>{await S.pages.where("url").equals(n).modify(i=>{i.openedUrls.includes(r)||(i.openedUrls.push(r),i.openedUrls.length>bt&&(i.openedUrls=i.openedUrls.slice(-bt)))}),await S.pages.where("url").equals(r).modify(i=>{i.openerUrls.includes(n)||(i.openerUrls.push(n),i.openerUrls.length>bt&&(i.openerUrls=i.openerUrls.slice(-bt)))})})}async function fu(e,t){const n=ht(e).normalized,r=ht(t).normalized;n!=r&&await S.transaction("rw",[S.pages,S.logs],async()=>{await S.pages.where("url").equals(n).modify(i=>{i.timeAdjacentUrls||(i.timeAdjacentUrls=[]),i.timeAdjacentUrls.includes(r)||(i.timeAdjacentUrls.push(r),i.timeAdjacentUrls.length>bt&&(i.timeAdjacentUrls=i.timeAdjacentUrls.slice(-bt)))}),await S.pages.where("url").equals(r).modify(i=>{i.timeAdjacentUrls||(i.timeAdjacentUrls=[]),i.timeAdjacentUrls.includes(n)||(i.timeAdjacentUrls.push(n),i.timeAdjacentUrls.length>bt&&(i.timeAdjacentUrls=i.timeAdjacentUrls.slice(-bt)))})})}async function du(e){const t=e.map(i=>i.normalized),n=500,r=[];for(let i=0;i<t.length;i+=n){const s=t.slice(i,i+n),o=await S.pages.bulkGet(s);r.push(...o.filter(c=>c!=null&&(!c.humanTags||c.humanTags.length==0)))}return r.map(i=>dt(i))}async function An(e){const n=[];for(let o=0;o<e.length;o+=500){const c=e.slice(o,o+500),u=await S.pages.bulkGet(c);n.push(...u.filter(l=>l!=null))}const r=new Set(n.map(o=>o==null?void 0:o.url).filter(Boolean));e.filter(o=>!r.has(o)).forEach(o=>{re.warn("preparePagesAndTagsToPut: Creating new page for",o);const c=ht(o);return n.push(xi(c))}),n.forEach(o=>{o.visible="active",o.accessTimes.push(Date.now()),o.accessTimes=Ni(o.accessTimes),o.lastActiveDesc=-o.accessTimes.slice(-1)[0],o.hotnessDesc=-o.accessTimes.length});const s=new Set(n.flatMap(o=>o.humanTags));return[n,Array.from(s)]}async function hu(e){const t=xt(),n=e.reduce((r,i)=>{var s;return r+(((s=i.tabs)==null?void 0:s.length)||0)},0);await Ue(t,"background","Syncing from browser",0,n);try{await S.pages.where("visible").equals("active").modify(o=>{o.visible="closed"});const r=[];let i=0;e.forEach(o=>{var c;(c=o.tabs)==null||c.forEach(u=>{if(u.url){const l=ht(u.url),h=u.title?wa(l.normalized,u.title):u.title;r.push(()=>ba(l,!1,h,u.favIconUrl,u.windowId,{skipEmbeddingEnqueue:!0}).then(m=>(i++,i%10===0&&Ue(t,"background","Syncing from browser",i,n),m)))}})});const s=50;for(let o=0;o<r.length;o+=s){const c=r.slice(o,o+s);await Promise.all(c.map(u=>u()))}r.length>0&&await Ze("generateEmbedding",{},10)}finally{Ct(t)}}async function pu(e,t){const n=xt();await Ue(n,"background","Adding tag",0,e.length);try{await S.transaction("rw",[S.pages,S.tags,S.progress,S.logs],async()=>{const[r,i]=await An(e);let s=0;for(const o of r)o.humanTags.includes(t)||o.humanTags.push(t),t!=ft&&pr(o),o.autoTags=o.autoTags.filter(c=>c.name!=t),o.humanRejectedTags=o.humanRejectedTags.filter(c=>c!=t),o.embedding=void 0,o.embeddingErrored=!1,s++,s%10===0&&Ue(n,"background","Adding tag",s,e.length);i.push(t),await S.tags.bulkPut(i.map(o=>({name:o,last_active:Pe.now()}))),await S.pages.bulkPut(r)}),await Ze("generateEmbedding",{urls:e},10)}finally{Ct(n)}}async function yu(e,t){const n=xt();await Ue(n,"background","Removing tag",0,e.length);try{await S.transaction("rw",[S.pages,S.tags,S.progress,S.logs],async()=>{const[r,i]=await An(e);let s=0;for(const o of r)o.humanTags=o.humanTags.filter(c=>c!=t),o.humanRejectedTags.includes(t)||o.humanRejectedTags.push(t),o.embedding=void 0,o.embeddingErrored=!1,s++,s%10===0&&Ue(n,"background","Removing tag",s,e.length);await S.pages.bulkPut(r)}),await Ze("generateEmbedding",{urls:e},10)}finally{Ct(n)}}function va(e){let t=!1;e.humanTags.includes(ft)||(e.humanTags.push(ft),t=!0),e.humanRejectedTags.includes(ft)&&(e.humanRejectedTags=e.humanRejectedTags.filter(n=>n!=ft),t=!0),t&&(e.embedding=void 0,e.embeddingErrored=!1)}async function mu(e){const t=xt();await Ue(t,"background","Stashing pages",0,e.length);try{await S.transaction("rw",[S.pages,S.tags,S.progress,S.logs],async()=>{const[n,r]=await An(e);let i=0;for(const s of n)va(s),i++,i%5===0&&Ue(t,"background","Stashing pages",i,e.length);await S.pages.bulkPut(n),re.info("Stashed: ",n)}),await Ze("generateEmbedding",{urls:e},10)}finally{Ct(t)}}function pr(e){const t=e.humanTags.includes(ft);e.humanTags=e.humanTags.filter(n=>n!=ft),t&&(e.embedding=void 0,e.embeddingErrored=!1)}async function gu(e){const t=xt();await Ue(t,"background","Unstashing pages",0,e.length);try{await S.transaction("rw",[S.pages,S.tags,S.progress,S.logs],async()=>{const[n,r]=await An(e);let i=0;for(const s of n)pr(s),i++,i%5===0&&Ue(t,"background","Unstashing pages",i,e.length);await S.pages.bulkPut(n)}),await Ze("generateEmbedding",{urls:e},10)}finally{Ct(t)}}async function wu(e){await S.pages.delete(e),Ze("cleanupGraphRefs",{url:e},80).catch(t=>re.warn("[deletePage] Failed to enqueue cleanupGraphRefs for",e,t))}const Pi=async e=>(await S.pages.bulkGet(e)).filter(n=>n!=null),Ri=async e=>(await Pi(e)).map(dt),bu=async()=>(await S.pages.toArray()).map(dt),vu=e=>{const t=e.filter(Boolean).map(n=>n==null?void 0:n.normalized).filter(Boolean);return Ri(t)};async function Sa(e){if(oa()){const n=aa(e);if(n.length===0)return[];const r=await S.pages.bulkGet(n),i=new Map(r.filter(s=>s!=null).map(s=>[s.url,s]));return n.map(s=>i.get(s)).filter(s=>s!=null).map(dt)}return(await S.pages.toArray()).filter(n=>Ea(n,e)).sort((n,r)=>n.lastActiveDesc-r.lastActiveDesc).map(dt)}var on=[];async function Su(e){try{if(on.forEach(o=>o()),on=[],e.length==0||e.length===1&&e[0].length<=1)return{tags:[],pages:[]};const[t,n]=zr(["tags"],()=>ca(e));on.push(n);const[r,i]=zr(["pages"],()=>Sa(e));return on.push(i),{tags:await t,pages:await r}}catch(t){return(t==null?void 0:t.name)!=="AbortError"&&re.error("fetchTagsAndPagesForQuery error:",t),{tags:[],pages:[]}}}async function _u(){return await S.pages.where("humanTags").equals(ft).count()}async function Tu(){return await S.pages.where("humanTags").equals(Ii).count()}async function Eu(){return await S.pages.filter(e=>!e.humanTags||e.humanTags.length==0).count()}async function _a(){return await S.pages.count()}var Ta=(e=>(e.title="title",e.domain="domainSortKey",e.recent="lastActiveDesc",e.hot="hotnessDesc",e.similarity="similarity",e))(Ta||{});async function Au(e){return e=="#ALL"?(await S.pages.toArray()).map(dt):e=="#UNTAGGED"?(await S.pages.filter(n=>!n.humanTags||n.humanTags.length==0).toArray()).map(dt):(await S.pages.where("humanTags").equals(e).toArray()).map(dt)}function Ea(e,t){const n=[e.title,e.url,e.originalUrl,...e.humanTags].join(" ").toLowerCase();return t.every(r=>n.includes(r))}async function Ou(e,t,n){const r=`todo://${xt()}`,i=ht(r),s=Date.now(),o={url:i.normalized,originalUrl:i.original,domainSortKey:i.domainSortKey,title:e,visible:"closed",accessTimes:[s],lastActiveDesc:-s,hotnessDesc:-1,humanTags:[],humanRejectedTags:[],autoTags:[],openerUrls:[],openedUrls:[],timeAdjacentUrls:[],completionStatus:"pending",priority:t,dueDate:n,creationDate:s};return await S.pages.put(o),await Ze("generateEmbedding",{url:i.normalized},10),dt(o)}async function Iu(e,t){await S.pages.where("url").equals(e).modify(n=>{n.title=t,n.embedding=void 0,n.embeddingErrored=!1}),await Ze("generateEmbedding",{url:e},10)}async function ku(e,t){await S.pages.where("url").equals(e).modify(n=>{n.completionStatus=t})}async function Cu(e,t){await S.pages.where("url").equals(e).modify(n=>{n.priority=t})}async function xu(e,t){await S.pages.where("url").equals(e).modify(n=>{n.dueDate=t})}async function Nu(e){await S.pages.where("url").equals(e).modify(t=>{t.completionStatus="pending",t.creationDate=Date.now()})}async function Pu(e){await S.pages.where("url").equals(e).modify(t=>{delete t.completionStatus,delete t.priority,delete t.dueDate,delete t.creationDate})}async function Ru(){return S.pages.where("completionStatus").equals("pending").count()}async function ju(){const e=xt();var t=0;const n=performance.now(),r=await _a();Ue(e,"background","Calculating hotness",0,r);try{await S.transaction("rw",[S.pages,S.progress,S.logs],async()=>{const s=await S.pages.toCollection().primaryKeys();for(let o=0;o<s.length;o+=500){const c=s.slice(o,o+500),u=await S.pages.bulkGet(c),l=[];for(const h of u){if(!h)continue;t+=1;let m=0,b=0;h.accessTimes&&h.accessTimes.length>0&&(m=-h.accessTimes[h.accessTimes.length-1],b=-h.accessTimes.length),l.push({...h,lastActiveDesc:m,hotnessDesc:b})}await S.pages.bulkPut(l),t%500===0&&(re.info("renormalized count:",t),Ue(e,"background","Calculating hotness",t,r)),await new Promise(h=>setTimeout(h,0))}}),re.info(`refreshHotness: ${(performance.now()-n).toFixed(0)} ms, processed ${t}`)}finally{Ct(e)}}const Aa={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},Oa={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},Ia="[^aeiou]",bn="[aeiouy]",at=Ia+"[^aeiouy]*",qt=bn+"[aeiou]*",Kn="^("+at+")?"+qt+at,ka="^("+at+")?"+qt+at+"("+qt+")?$",an="^("+at+")?"+qt+at+qt+at,Lr="^("+at+")?"+bn;function Ca(e){let t,n,r,i,s,o,c;if(e.length<3)return e;if(r=e.substr(0,1),r=="y"&&(e=r.toUpperCase()+e.substr(1)),i=/^(.+?)(ss|i)es$/,s=/^(.+?)([^s])s$/,i.test(e)?e=e.replace(i,"$1$2"):s.test(e)&&(e=e.replace(s,"$1$2")),i=/^(.+?)eed$/,s=/^(.+?)(ed|ing)$/,i.test(e)){const u=i.exec(e);i=new RegExp(Kn),i.test(u[1])&&(i=/.$/,e=e.replace(i,""))}else s.test(e)&&(t=s.exec(e)[1],s=new RegExp(Lr),s.test(t)&&(e=t,s=/(at|bl|iz)$/,o=new RegExp("([^aeiouylsz])\\1$"),c=new RegExp("^"+at+bn+"[^aeiouwxy]$"),s.test(e)?e=e+"e":o.test(e)?(i=/.$/,e=e.replace(i,"")):c.test(e)&&(e=e+"e")));if(i=/^(.+?)y$/,i.test(e)&&(t=i.exec(e)[1],i=new RegExp(Lr),i.test(t)&&(e=t+"i")),i=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,i.test(e)){const u=i.exec(e);t=u[1],n=u[2],i=new RegExp(Kn),i.test(t)&&(e=t+Aa[n])}if(i=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,i.test(e)){const u=i.exec(e);t=u[1],n=u[2],i=new RegExp(Kn),i.test(t)&&(e=t+Oa[n])}if(i=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,s=/^(.+?)(s|t)(ion)$/,i.test(e))t=i.exec(e)[1],i=new RegExp(an),i.test(t)&&(e=t);else if(s.test(e)){const u=s.exec(e);t=u[1]+u[2],s=new RegExp(an),s.test(t)&&(e=t)}return i=/^(.+?)e$/,i.test(e)&&(t=i.exec(e)[1],i=new RegExp(an),s=new RegExp(ka),o=new RegExp("^"+at+bn+"[^aeiouwxy]$"),(i.test(t)||s.test(t)&&!o.test(t))&&(e=t)),i=/ll$/,s=new RegExp(an),i.test(e)&&s.test(e)&&(i=/.$/,e=e.replace(i,"")),r=="y"&&(e=r.toLowerCase()+e.substr(1)),e}function ji(e){return e!=null&&e.length>0}function yr(){return{tabIds:[],accessTime:Date.now()}}const Ui={windows:{},tabs:{},focusedWindowId:void 0,desynced:!1,recentTabs:{}};function ln(e,t,n=!0){const r=t.id;if(!r||!t.url)return;xa(e);const i=ht(t.url),s=Pe.now();n&&ji(i.normalized)&&(e.recentTabs[i.normalized]=s),e.tabs[r]={id:t.id,windowId:t.windowId,title:t.title,url:i,accessTime:s}}function xa(e){const n=Pe.now()-6e4;for(const r in e.recentTabs)e.recentTabs[r]<n&&delete e.recentTabs[r]}function Na(e,t,n={}){const r=performance.now(),i={...Ui};return i.windows={},i.tabs={},i.recentTabs={},t.forEach(s=>{var u,l;if(s.id==null||s.incognito)return;const o=s.id;i.windows[o]=yr();const c=Math.max(n[o]??0,((u=e.windows[o])==null?void 0:u.accessTime)??0);c>0&&(i.windows[o].accessTime=c),(l=s.tabs)==null||l.forEach(h=>{!h.id||h.url&&Kr(h.url)||(i.windows[o].tabIds.includes(h.id)||i.windows[o].tabIds.push(h.id),h.active&&(i.windows[o].activeTabId=h.id),ln(i,h,!1))})}),i.focusedWindowId=void 0,i.desynced=!1,re.debug(`overwriteActiveTabs: ${(performance.now()-r).toFixed(0)} ms`),i}function Tt(e,t){(e.windows==null||e.windows[t]==null)&&(e.windows[t]=yr(),e.desynced=!0,re.warn(`[WindowsSlice] Desynced: window ${t} not found`))}const Pa=Ht("windows/update",async()=>{re.debug("[WindowsSlice] updateWindowsAsync");const[e,t]=await Promise.all([chrome.windows.getAll({populate:!0}),chrome.storage.session.get(null)]),n={};for(const[s,o]of Object.entries(t))s.startsWith("wt_")&&typeof o=="number"&&(n[Number(s.slice(3))]=o);const r={};for(const s of e)if(!(s.id==null||s.incognito))for(const o of s.tabs??[]){if(!o.url||Kr(o.url))continue;const c=ht(o.url);c.normalized&&(r[c.normalized]=s.id)}const i=Object.keys(r);if(i.length>0){const s=await Pi(i);for(const o of s){const c=r[o.url];if(c==null)continue;const u=-o.lastActiveDesc;u>0&&(n[c]=Math.max(n[c]??0,u))}}return re.debug("[WindowsSlice] updateWindowsAsync done"),{windows:e,storedAccessTimes:n}});Ht("windows/stashWindows",async(e,t)=>{await Ze("stash",{retainWindowId:e})});const Uu=Ht("windows/cleanup",async(e,t)=>{await Ze("cleanup",{retainWindowId:e})});let Mt=null;function Ra(e){return Mt||(Mt=new Worker(new URL("/assets/similarityWorker-xY322UuG.js",import.meta.url),{type:"module"}),Mt.addEventListener("message",t=>{t.data.type==="result"&&(e(bi(t.data.similarUrls)),e(Ko(t.data.similarTags)))}),Mt.addEventListener("error",t=>{re.error("[SimilarityWorker] Uncaught worker error:",t.message)})),Mt}const Du=Ht("windows/similarUrls",async(e,t)=>{const n=t.getState();if(!n.ui.autoComputeSimilarity)return;t.dispatch(bi({}));const r=n.ui.selectedUrls,i=Ra(t.dispatch);if(i.postMessage({type:"abort"}),r.length===0)return;const s=n.windows.focusedWindowId?`window-${n.windows.focusedWindowId}-similarity`:`background-similarity-${Date.now()}`,o=n.windows.focusedWindowId?`window-${n.windows.focusedWindowId}`:"background";i.postMessage({type:"compute",selectedUrls:r,taskId:s,source:o})});let cn=null;const zu=Ht("ui/searchSimilar",async(e,t)=>{cn&&cn.abort(),cn=new AbortController;const n=cn.signal,r=t.getState();let i=[];const s=$o(r);if(e&&s.includes(e.normalized)?i=s:e?i=[e.normalized]:i=s,i.length!==0)try{const o=await Ri(i);if(n.aborted)return;const c=o.map(h=>{var b;const m=((b=h.title)==null?void 0:b.toLowerCase())||"";return Pe.uniq(m.split(/\W+/).filter(A=>A.length>2).map(A=>Ca(A.toLowerCase())))});if(c.length===0)return;const u=Pe.intersection(...c);if(u.length===0)return;const l=u.join(" ");n.aborted||(t.dispatch(Wo(l)),t.dispatch(Vo(5)))}catch(o){re.error("[SearchSimilar] Error during searchSimilarAsync:",o)}}),ja=gi({name:"windows",initialState:Ui,reducers:{activated:(e,t)=>{const n=t.payload.windowId;Tt(e,n);const r=t.payload.tabId;e.focusedWindowId=n,e.windows[n].activeTabId=r,e.windows[n].accessTime=Pe.now(),ln(e,t.payload.chromeTab)},attached:(e,t)=>{const{tabId:n,newWindowId:r,newPosition:i}=t.payload;Tt(e,r);const s=e.windows[r].tabIds.indexOf(n);s!==-1&&e.windows[r].tabIds.splice(s,1),e.windows[r].tabIds.splice(i,0,n),e.tabs[n].windowId=r,e.focusedWindowId=r,e.windows[r].activeTabId=n,e.windows[r].accessTime=Pe.now()},created:(e,t)=>{const n=t.payload.chromeTab;if(n.id){Tt(e,n.windowId),ln(e,n);const r=e.windows[n.windowId].tabIds.indexOf(n.id);r!==-1&&e.windows[n.windowId].tabIds.splice(r,1),e.windows[n.windowId].tabIds.splice(n.index,0,n.id)}},detached:(e,t)=>{const{tabId:n,oldWindowId:r,oldPosition:i}=t.payload;Tt(e,r),e.windows[r].tabIds.splice(i,1),e.windows[r].tabIds.length==0&&delete e.windows[r],e.tabs[n].windowId=void 0},moved:(e,t)=>{const{tabId:n,windowId:r,fromIndex:i,toIndex:s}=t.payload;Tt(e,r);const o=e.windows[r].tabIds.indexOf(n);o!==-1&&e.windows[r].tabIds.splice(o,1),e.windows[r].tabIds.splice(s,0,n),e.focusedWindowId=r,e.windows[r].activeTabId=n,e.windows[r].accessTime=Pe.now()},removed:(e,t)=>{const{tabId:n,windowId:r,isWindowClosing:i}=t.payload;Tt(e,r),e.windows[r].tabIds=e.windows[r].tabIds.filter(s=>s!=n),delete e.tabs[n]},replaced:(e,t)=>{const{addedTabId:n,removedTabId:r}=t.payload;for(const i in e.windows)e.windows[i].tabIds=e.windows[i].tabIds.map(s=>s==r?n:s);e.tabs[n]=e.tabs[r],delete e.tabs[r]},updated:(e,t)=>{ln(e,t.payload.chromeTab)},zoomChanged:(e,t)=>{},windowBoundsChanged:(e,t)=>{},windowCreated:(e,t)=>{const n=t.payload.window;n.id&&!e.windows[n.id]&&(e.windows[n.id]=yr())},windowRemoved:(e,t)=>{const n=t.payload.windowId;n&&e.windows[n]&&delete e.windows[n]},windowFocused:(e,t)=>{const n=t.payload.windowId;e.focusedWindowId=n,n&&(Tt(e,n),e.windows[n].accessTime=Pe.now())},dedupAll:e=>{const t=Di(e.tabs);for(const[n,r]of t){const i=[...r],s=Pe.sortBy(i,([o,c])=>c.accessTime);s.shift();for(const[o,c]of s)qo(o)}}},extraReducers:e=>{e.addCase(Pa.fulfilled,(t,n)=>Na(t,n.payload.windows,n.payload.storedAccessTimes))}}),Nt=e=>e.windows.windows,Mu=(e,t)=>e.windows.windows[t],Lu=ct([Nt,(e,t)=>t],(e,t)=>Object.keys(e).filter(n=>Number(n)!==t).length),On=e=>e.windows.tabs,Bu=ct([Nt,(e,t)=>t],(e,t)=>Object.entries(e).filter(([n])=>Number(n)!==t).reduce((n,[,r])=>n+r.tabIds.length,0)),Fu=()=>ct([Nt,On,(e,t)=>t],(e,t,n)=>[...new Set(e[n].tabIds)].map(i=>i?t[i]:null).filter(Boolean)),Ua=e=>e.windows.focusedWindowId,$u=ct([Nt,(e,t,n)=>t,(e,t,n)=>n],(e,t,n)=>{if(!n||!t)return!1;const r=e[t];return r==null?!1:r.activeTabId==n});ct([Nt,On,(e,t)=>t],(e,t,n)=>{if(!n)return!1;for(const r in e){const i=e[r].activeTabId;if(i&&t[i].url==n)return!0}return!1});ct([Nt,Ua,On,(e,t)=>t],(e,t,n,r)=>{var s,o,c;if(!r||!t)return!1;const i=(s=e[t])==null?void 0:s.activeTabId;return i&&((c=(o=n[i])==null?void 0:o.url)==null?void 0:c.normalized)==r});const Vu=ct(On,(e,t)=>t,(e,t)=>Pe.entries(e).filter(([r,i])=>{var s;return i!=null&&((s=i.url)==null?void 0:s.normalized)==t.normalized}).map(([r,i])=>i));function Di(e){const t=Pe.entries(e).filter(([r,i])=>i!=null&&i.id!=null&&i.url!=null).map(([r,i])=>[Number(r),i]),n=Pe.groupBy(t,([r,i])=>{var s;return(s=i.url)==null?void 0:s.normalized});return Object.entries(n).filter(([r,i])=>i.length>1)}const Da=ct(e=>e.windows.tabs,e=>Di(e).map(([t,n])=>t)),Wu=ct(e=>Da(e),(e,t)=>t,(e,t)=>ji(t==null?void 0:t.normalized)&&e.includes(t.normalized)),Ku=e=>e.windows.desynced,{activated:qu,attached:Gu,created:Ju,detached:Hu,moved:Yu,removed:Qu,replaced:Xu,updated:Zu,zoomChanged:el,windowBoundsChanged:tl,windowCreated:nl,windowFocused:rl,windowRemoved:il,dedupAll:sl}=ja.actions,za=Date.now(),Ma=30*1e3;S.on("populate",e=>{e.table("prefs").add({name:"backupEveryNSeconds",numVal:60})});async function zi(){const e=await S.prefs.get("backupEveryNSeconds");return e==null||e.numVal==null?0:e.numVal}async function ol(){if(Date.now()-za<Ma)return!1;const e=await Mi(),t=await zi();return t===0||t==null?!1:!e||Date.now()-e>t*1e3}function al(e){return S.prefs.put({name:"backupEveryNSeconds",numVal:e})}async function cl(){var e;return(e=await S.prefs.get("backupPath"))==null?void 0:e.strVal}async function In(){var e;return(e=await S.prefs.get("backupDirectoryHandle"))==null?void 0:e.dirHandle}async function La(e){return await S.prefs.put({name:"backupStatus",numVal:2}),await S.prefs.put({name:"backupDirectoryHandle",dirHandle:e})}async function ul(){const e=await S.prefs.get("backupStatus");return e==null||e.numVal==null?1:e.numVal}function Bt(e){return S.prefs.put({name:"backupStatus",numVal:e})}var jt=(e=>(e[e.Unknown=0]="Unknown",e[e.DirectoryNotAccessible=1]="DirectoryNotAccessible",e[e.DirectoryAccessible=2]="DirectoryAccessible",e[e.BackupInProgress=3]="BackupInProgress",e))(jt||{});async function Mi(){const e=await S.prefs.get("latestBackup");return e==null||e.numVal==null?0:e.numVal}function Ba(e){return S.prefs.put({name:"latestBackup",numVal:e})}async function ll(){const e=await S.prefs.get("latestBackupSize");return e==null||e.numVal==null?0:e.numVal}function Fa(e){return S.prefs.put({name:"latestBackupSize",numVal:e})}async function fl(){const e=await S.prefs.get("tabvanaWindowId");return e==null?void 0:e.numVal}function dl(e){return S.prefs.put({name:"tabvanaWindowId",numVal:e})}function hl(){return["Main"]}async function pl(){const e=await S.prefs.get("similarityScaler");return e==null||e.numVal==null?5:e.numVal}function yl(e){return S.prefs.put({name:"similarityScaler",numVal:e})}async function ml(){const e=await S.prefs.get("tagSimilarityScaler");return e==null||e.numVal==null?20:e.numVal}function gl(e){return S.prefs.put({name:"tagSimilarityScaler",numVal:e})}async function $a(){const e=await S.prefs.get("ignoredUrls");let t;const n=e==null?void 0:e.strVal;if(n)try{t=JSON.parse(n)}catch(r){re.error("Failed to parse ignoredUrls",r)}return t}function Va(e){return S.prefs.put({name:"ignoredUrls",strVal:JSON.stringify(e)})}async function Wa(){const e=await S.prefs.get("normalizeRules");let t;const n=e==null?void 0:e.strVal;if(n)try{t=JSON.parse(n)}catch(r){re.error("Failed to parse normalizeRules",r)}return t}function Ka(e){return S.prefs.put({name:"normalizeRules",strVal:JSON.stringify(e)})}async function wl(){const e=await $a();let t=e;e||(t=Yi,await Va(t));const n=await Wa();let r=n;n||(r=Qi,await Ka(r)),t&&r&&Hi(t,r),re.info("Prefs loaded",{finalIgnored:t,finalRules:r})}var Br={},vn=function(){return vn=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},vn.apply(this,arguments)};function St(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function c(h){try{l(r.next(h))}catch(m){o(m)}}function u(h){try{l(r.throw(h))}catch(m){o(m)}}function l(h){h.done?s(h.value):i(h.value).then(c,u)}l((r=r.apply(e,[])).next())})}function ot(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=c(0),o.throw=c(1),o.return=c(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(l){return function(h){return u([l,h])}}function u(l){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(n=0)),n;)try{if(r=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return n.label++,{value:l[1],done:!1};case 5:n.label++,i=l[1],l=[0];continue;case 7:l=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){n=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){n.label=l[1];break}if(l[0]===6&&n.label<s[1]){n.label=s[1],s=l;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(l);break}s[2]&&n.ops.pop(),n.trys.pop();continue}l=t.call(e,n)}catch(h){l=[6,h],i=0}finally{r=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function qa(e){var t=[e.schema.primKey].concat(e.schema.indexes);return t.map(function(n){return n.src}).join(",")}function Ga(e){for(var t={},n=0,r=e.tables;n<r.length;n++){var i=r[n];t[i.name]=i.schema}return t}function Li(e,t){return new Promise(function(n,r){var i=new FileReader;i.onabort=function(s){return r(new Error("file read aborted"))},i.onerror=function(s){return r(s.target.error)},i.onload=function(s){return n(s.target.result)},i.readAsArrayBuffer(e)})}function Bi(e,t){if(typeof FileReaderSync>"u")throw new Error("FileReaderSync missing. Reading blobs synchronously requires code to run from within a web worker. Use TSON.encapsulateAsync() to do it from the main thread.");var n=new FileReaderSync,r=n.readAsArrayBuffer(e);return r}var Ja=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function mr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fn={exports:{}},Ha=fn.exports,Fr;function Ya(){return Fr||(Fr=1,function(e,t){(function(n,r){e.exports=r()})(Ha,function(){function n(T){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?n=function(E){return typeof E}:n=function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},n(T)}function r(T,E,C,I,U,Z,se){try{var oe=T[Z](se),K=oe.value}catch(Ie){C(Ie);return}oe.done?E(K):Promise.resolve(K).then(I,U)}function i(T){return function(){var E=this,C=arguments;return new Promise(function(I,U){var Z=T.apply(E,C);function se(K){r(Z,I,U,se,oe,"next",K)}function oe(K){r(Z,I,U,se,oe,"throw",K)}se(void 0)})}}function s(T,E){if(!(T instanceof E))throw new TypeError("Cannot call a class as a function")}function o(T,E){for(var C=0;C<E.length;C++){var I=E[C];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(T,I.key,I)}}function c(T,E,C){return E&&o(T.prototype,E),T}function u(T,E,C){return E in T?Object.defineProperty(T,E,{value:C,enumerable:!0,configurable:!0,writable:!0}):T[E]=C,T}function l(T,E){var C=Object.keys(T);if(Object.getOwnPropertySymbols){var I=Object.getOwnPropertySymbols(T);E&&(I=I.filter(function(U){return Object.getOwnPropertyDescriptor(T,U).enumerable})),C.push.apply(C,I)}return C}function h(T){for(var E=1;E<arguments.length;E++){var C=arguments[E]!=null?arguments[E]:{};E%2?l(Object(C),!0).forEach(function(I){u(T,I,C[I])}):Object.getOwnPropertyDescriptors?Object.defineProperties(T,Object.getOwnPropertyDescriptors(C)):l(Object(C)).forEach(function(I){Object.defineProperty(T,I,Object.getOwnPropertyDescriptor(C,I))})}return T}function m(T,E){return _(T)||x(T,E)||F()}function b(T){return A(T)||k(T)||L()}function A(T){if(Array.isArray(T)){for(var E=0,C=new Array(T.length);E<T.length;E++)C[E]=T[E];return C}}function _(T){if(Array.isArray(T))return T}function k(T){if(Symbol.iterator in Object(T)||Object.prototype.toString.call(T)==="[object Arguments]")return Array.from(T)}function x(T,E){if(Symbol.iterator in Object(T)||Object.prototype.toString.call(T)==="[object Arguments]"){var C=[],I=!0,U=!1,Z=void 0;try{for(var se=T[Symbol.iterator](),oe;!(I=(oe=se.next()).done)&&(C.push(oe.value),!(E&&C.length===E));I=!0);}catch(K){U=!0,Z=K}finally{try{!I&&se.return!=null&&se.return()}finally{if(U)throw Z}}return C}}function L(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function F(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var O=function T(E){s(this,T),this.p=new Promise(E)};O.__typeson__type__="TypesonPromise",typeof Symbol<"u"&&(O.prototype[Symbol.toStringTag]="TypesonPromise"),O.prototype.then=function(T,E){var C=this;return new O(function(I,U){C.p.then(function(Z){I(T?T(Z):Z)}).catch(function(Z){return E?E(Z):Promise.reject(Z)}).then(I,U)})},O.prototype.catch=function(T){return this.then(null,T)},O.resolve=function(T){return new O(function(E){E(T)})},O.reject=function(T){return new O(function(E,C){C(T)})},["all","race"].forEach(function(T){O[T]=function(E){return new O(function(C,I){Promise[T](E.map(function(U){return U&&U.constructor&&U.constructor.__typeson__type__==="TypesonPromise"?U.p:U})).then(C,I)})}});var P={},B=P.toString,z={}.hasOwnProperty,J=Object.getPrototypeOf,w=z.toString;function p(T,E){return fe(T)&&typeof T.then=="function"&&(!E||typeof T.catch=="function")}function N(T){return B.call(T).slice(8,-1)}function v(T,E){if(!T||n(T)!=="object")return!1;var C=J(T);if(!C)return E===null;var I=z.call(C,"constructor")&&C.constructor;return typeof I!="function"?E===null:E===I||E!==null&&w.call(I)===w.call(E)||typeof E=="function"&&typeof I.__typeson__type__=="string"&&I.__typeson__type__===E.__typeson__type__}function ie(T){if(!T||N(T)!=="Object")return!1;var E=J(T);return E?v(T,Object):!0}function ae(T){if(!T||N(T)!=="Object")return!1;var E=J(T);return E?v(T,Object)||ae(E):!0}function fe(T){return T&&n(T)==="object"}function he(T){return T.replace(/~/g,"~0").replace(/\./g,"~1")}function Te(T){return T.replace(/~1/g,".").replace(/~0/g,"~")}function Re(T,E){if(E==="")return T;var C=E.indexOf(".");if(C>-1){var I=T[Te(E.slice(0,C))];return I===void 0?void 0:Re(I,E.slice(C+1))}return T[Te(E)]}function Me(T,E,C){if(E==="")return C;var I=E.indexOf(".");if(I>-1){var U=T[Te(E.slice(0,I))];return Me(U,E.slice(I+1),C)}return T[Te(E)]=C,T}function je(T){return T===null?"null":Array.isArray(T)?"array":n(T)}var ge=Object.keys,_e=Array.isArray,Le={}.hasOwnProperty,et=["type","replaced","iterateIn","iterateUnsetNumeric"];function Q(T,E){if(T.keypath==="")return-1;var C=T.keypath.match(/\./g)||0,I=E.keypath.match(/\./g)||0;return C&&(C=C.length),I&&(I=I.length),C>I?-1:C<I?1:T.keypath<E.keypath?-1:T.keypath>E.keypath}var ve=function(){function T(E){s(this,T),this.options=E,this.plainObjectReplacers=[],this.nonplainObjectReplacers=[],this.revivers={},this.types={}}return c(T,[{key:"stringify",value:function(C,I,U,Z){Z=h({},this.options,{},Z,{stringification:!0});var se=this.encapsulate(C,null,Z);return _e(se)?JSON.stringify(se[0],I,U):se.then(function(oe){return JSON.stringify(oe,I,U)})}},{key:"stringifySync",value:function(C,I,U,Z){return this.stringify(C,I,U,h({throwOnBadSyncType:!0},Z,{sync:!0}))}},{key:"stringifyAsync",value:function(C,I,U,Z){return this.stringify(C,I,U,h({throwOnBadSyncType:!0},Z,{sync:!1}))}},{key:"parse",value:function(C,I,U){return U=h({},this.options,{},U,{parse:!0}),this.revive(JSON.parse(C,I),U)}},{key:"parseSync",value:function(C,I,U){return this.parse(C,I,h({throwOnBadSyncType:!0},U,{sync:!0}))}},{key:"parseAsync",value:function(C,I,U){return this.parse(C,I,h({throwOnBadSyncType:!0},U,{sync:!1}))}},{key:"specialTypeNames",value:function(C,I){var U=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return U.returnTypeNames=!0,this.encapsulate(C,I,U)}},{key:"rootTypeName",value:function(C,I){var U=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return U.iterateNone=!0,this.encapsulate(C,I,U)}},{key:"encapsulate",value:function(C,I,U){U=h({sync:!0},this.options,{},U);var Z=U,se=Z.sync,oe=this,K={},Ie=[],Fe=[],Ke=[],tt="cyclic"in U?U.cyclic:!0,nt=U,ut=nt.encapsulateObserver,qe=ye("",C,tt,I||{},Ke);function rt(V){var f=Object.values(K);if(U.iterateNone)return f.length?f[0]:T.getJSONType(V);if(f.length){if(U.returnTypeNames)return b(new Set(f));!V||!ie(V)||Le.call(V,"$types")?V={$:V,$types:{$:K}}:V.$types=K}else fe(V)&&Le.call(V,"$types")&&(V={$:V,$types:!0});return U.returnTypeNames?!1:V}function Ee(V,f){return pe.apply(this,arguments)}function pe(){return pe=i(regeneratorRuntime.mark(function V(f,a){var d;return regeneratorRuntime.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,Promise.all(a.map(function(R){return R[1].p}));case 2:return d=g.sent,g.next=5,Promise.all(d.map(function(){var R=i(regeneratorRuntime.mark(function D(W){var M,H,ee,te,de,ue,ce,we,be,X,ke,$,j,G;return regeneratorRuntime.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:if(M=[],H=a.splice(0,1),ee=m(H,1),te=ee[0],de=m(te,7),ue=de[0],ce=de[2],we=de[3],be=de[4],X=de[5],ke=de[6],$=ye(ue,W,ce,we,M,!0,ke),j=v($,O),!(ue&&j)){Y.next=11;break}return Y.next=8,$.p;case 8:return G=Y.sent,be[X]=G,Y.abrupt("return",Ee(f,M));case 11:return ue?be[X]=$:j?f=$.p:f=$,Y.abrupt("return",Ee(f,M));case 13:case"end":return Y.stop()}},D)}));return function(D){return R.apply(this,arguments)}}()));case 5:return g.abrupt("return",f);case 6:case"end":return g.stop()}},V)})),pe.apply(this,arguments)}function le(V,f,a){Object.assign(V,f);var d=et.map(function(y){var g=V[y];return delete V[y],g});a(),et.forEach(function(y,g){V[y]=d[g]})}function ye(V,f,a,d,y,g,R){var D,W={},M=n(f),H=ut?function(j){var G=R||d.type||T.getJSONType(f);ut(Object.assign(j||W,{keypath:V,value:f,cyclic:a,stateObj:d,promisesData:y,resolvingTypesonPromise:g,awaitingTypesonPromise:v(f,O)},{type:G}))}:null;if(["string","boolean","number","undefined"].includes(M))return f===void 0||M==="number"&&(isNaN(f)||f===-1/0||f===1/0)?(d.replaced?D=f:D=Ae(V,f,d,y,!1,g,H),D!==f&&(W={replaced:D})):D=f,H&&H(),D;if(f===null)return H&&H(),f;if(a&&!d.iterateIn&&!d.iterateUnsetNumeric&&f&&n(f)==="object"){var ee=Ie.indexOf(f);if(ee<0)a===!0&&(Ie.push(f),Fe.push(V));else return K[V]="#",H&&H({cyclicKeypath:Fe[ee]}),"#"+Fe[ee]}var te=ie(f),de=_e(f),ue=(te||de)&&(!oe.plainObjectReplacers.length||d.replaced)||d.iterateIn?f:Ae(V,f,d,y,te||de,null,H),ce;if(ue!==f?(D=ue,W={replaced:ue}):V===""&&v(f,O)?(y.push([V,f,a,d,void 0,void 0,d.type]),D=f):de&&d.iterateIn!=="object"||d.iterateIn==="array"?(ce=new Array(f.length),W={clone:ce}):!["function","symbol"].includes(n(f))&&!("toJSON"in f)&&!v(f,O)&&!v(f,Promise)&&!v(f,ArrayBuffer)||te||d.iterateIn==="object"?(ce={},d.addLength&&(ce.length=f.length),W={clone:ce}):D=f,H&&H(),U.iterateNone)return ce||D;if(!ce)return D;if(d.iterateIn){var we=function(G){var q={ownKeys:Le.call(f,G)};le(d,q,function(){var Y=V+(V?".":"")+he(G),ne=ye(Y,f[G],!!a,d,y,g);v(ne,O)?y.push([Y,ne,!!a,d,ce,G,d.type]):ne!==void 0&&(ce[G]=ne)})};for(var be in f)we(be);H&&H({endIterateIn:!0,end:!0})}else ge(f).forEach(function(j){var G=V+(V?".":"")+he(j),q={ownKeys:!0};le(d,q,function(){var Y=ye(G,f[j],!!a,d,y,g);v(Y,O)?y.push([G,Y,!!a,d,ce,j,d.type]):Y!==void 0&&(ce[j]=Y)})}),H&&H({endIterateOwn:!0,end:!0});if(d.iterateUnsetNumeric){for(var X=f.length,ke=function(G){if(!(G in f)){var q=V+(V?".":"")+G,Y={ownKeys:!1};le(d,Y,function(){var ne=ye(q,void 0,!!a,d,y,g);v(ne,O)?y.push([q,ne,!!a,d,ce,G,d.type]):ne!==void 0&&(ce[G]=ne)})}},$=0;$<X;$++)ke($);H&&H({endIterateUnsetNumeric:!0,end:!0})}return ce}function Ae(V,f,a,d,y,g,R){for(var D=y?oe.plainObjectReplacers:oe.nonplainObjectReplacers,W=D.length;W--;){var M=D[W];if(M.test(f,a)){var H=M.type;if(oe.revivers[H]){var ee=K[V];K[V]=ee?[H].concat(ee):H}if(Object.assign(a,{type:H,replaced:!0}),(se||!M.replaceAsync)&&!M.replace)return R&&R({typeDetected:!0}),ye(V,f,tt&&"readonly",a,d,g,H);R&&R({replacing:!0});var te=se||!M.replaceAsync?"replace":"replaceAsync";return ye(V,M[te](f,a),tt&&"readonly",a,d,g,H)}}return f}return Ke.length?se&&U.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(Ee(qe,Ke)).then(rt):!se&&U.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():U.stringification&&se?[rt(qe)]:se?rt(qe):Promise.resolve(rt(qe))}},{key:"encapsulateSync",value:function(C,I,U){return this.encapsulate(C,I,h({throwOnBadSyncType:!0},U,{sync:!0}))}},{key:"encapsulateAsync",value:function(C,I,U){return this.encapsulate(C,I,h({throwOnBadSyncType:!0},U,{sync:!1}))}},{key:"revive",value:function(C,I){var U=C&&C.$types;if(!U)return C;if(U===!0)return C.$;I=h({sync:!0},this.options,{},I);var Z=I,se=Z.sync,oe=[],K={},Ie=!0;U.$&&ie(U.$)&&(C=C.$,U=U.$,Ie=!1);var Fe=this;function Ke(pe,le){var ye=Fe.revivers[pe]||[],Ae=m(ye,1),V=Ae[0];if(!V)throw new Error("Unregistered type: "+pe);return se&&!("revive"in V)?le:V[se&&V.revive?"revive":!se&&V.reviveAsync?"reviveAsync":"revive"](le,K)}function tt(){var pe=[];if(Object.entries(U).forEach(function(le){var ye=m(le,2),Ae=ye[0],V=ye[1];V!=="#"&&[].concat(V).forEach(function(f){var a=Fe.revivers[f]||[null,{}],d=m(a,2),y=d[1].plain;y&&(pe.push({keypath:Ae,type:f}),delete U[Ae])})}),!!pe.length)return pe.sort(Q).reduce(function le(ye,Ae){var V=Ae.keypath,f=Ae.type;if(p(ye))return ye.then(function(y){return le(y,{keypath:V,type:f})});var a=Re(C,V);if(a=Ke(f,a),v(a,O))return a.then(function(y){var g=Me(C,V,y);g===y&&(C=g)});var d=Me(C,V,a);d===a&&(C=d)},void 0)}var nt=[];function ut(pe,le,ye,Ae,V){if(!(Ie&&pe==="$types")){var f=U[pe],a=_e(le);if(a||ie(le)){var d=a?new Array(le.length):{};for(ge(le).forEach(function(ee){var te=ut(pe+(pe?".":"")+he(ee),le[ee],ye||d,d,ee),de=function(ce){return v(ce,Be)?d[ee]=void 0:ce!==void 0&&(d[ee]=ce),ce};v(te,O)?nt.push(te.then(function(ue){return de(ue)})):de(te)}),le=d;oe.length;){var y=m(oe[0],4),g=y[0],R=y[1],D=y[2],W=y[3],M=Re(g,R);if(M!==void 0)D[W]=M;else break;oe.splice(0,1)}}if(!f)return le;if(f==="#"){var H=Re(ye,le.slice(1));return H===void 0&&oe.push([ye,le.slice(1),Ae,V]),H}return[].concat(f).reduce(function ee(te,de){return v(te,O)?te.then(function(ue){return ee(ue,de)}):Ke(de,te)},le)}}function qe(pe){return v(pe,Be)?void 0:pe}var rt=tt(),Ee;return v(rt,O)?Ee=rt.then(function(){return C}):(Ee=ut("",C,null),nt.length&&(Ee=O.resolve(Ee).then(function(pe){return O.all([pe].concat(nt))}).then(function(pe){var le=m(pe,1),ye=le[0];return ye}))),p(Ee)?se&&I.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():v(Ee,O)?Ee.p.then(qe):Ee:!se&&I.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():se?qe(Ee):Promise.resolve(qe(Ee))}},{key:"reviveSync",value:function(C,I){return this.revive(C,h({throwOnBadSyncType:!0},I,{sync:!0}))}},{key:"reviveAsync",value:function(C,I){return this.revive(C,h({throwOnBadSyncType:!0},I,{sync:!1}))}},{key:"register",value:function(C,I){return I=I||{},[].concat(C).forEach(function U(Z){var se=this;if(_e(Z))return Z.map(function(oe){return U.call(se,oe)});Z&&ge(Z).forEach(function(oe){if(oe==="#")throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(T.JSON_TYPES.includes(oe))throw new TypeError("Plain JSON object types are reserved as type names");var K=Z[oe],Ie=K&&K.testPlainObjects?this.plainObjectReplacers:this.nonplainObjectReplacers,Fe=Ie.filter(function(ye){return ye.type===oe});if(Fe.length&&(Ie.splice(Ie.indexOf(Fe[0]),1),delete this.revivers[oe],delete this.types[oe]),typeof K=="function"){var Ke=K;K={test:function(Ae){return Ae&&Ae.constructor===Ke},replace:function(Ae){return h({},Ae)},revive:function(Ae){return Object.assign(Object.create(Ke.prototype),Ae)}}}else if(_e(K)){var tt=K,nt=m(tt,3),ut=nt[0],qe=nt[1],rt=nt[2];K={test:ut,replace:qe,revive:rt}}if(!(!K||!K.test)){var Ee={type:oe,test:K.test.bind(K)};K.replace&&(Ee.replace=K.replace.bind(K)),K.replaceAsync&&(Ee.replaceAsync=K.replaceAsync.bind(K));var pe=typeof I.fallback=="number"?I.fallback:I.fallback?0:1/0;if(K.testPlainObjects?this.plainObjectReplacers.splice(pe,0,Ee):this.nonplainObjectReplacers.splice(pe,0,Ee),K.revive||K.reviveAsync){var le={};K.revive&&(le.revive=K.revive.bind(K)),K.reviveAsync&&(le.reviveAsync=K.reviveAsync.bind(K)),this.revivers[oe]=[le,{plain:K.testPlainObjects}]}this.types[oe]=K}},this)},this),this}}]),T}(),Be=function T(){s(this,T)};return Be.__typeson__type__="TypesonUndefined",ve.Undefined=Be,ve.Promise=O,ve.isThenable=p,ve.toStringTag=N,ve.hasConstructorOf=v,ve.isObject=fe,ve.isPlainObject=ie,ve.isUserObject=ae,ve.escapeKeyPathComponent=he,ve.unescapeKeyPathComponent=Te,ve.getByKeyPath=Re,ve.getJSONType=je,ve.JSON_TYPES=["null","boolean","number","string","array","object"],ve})}(fn)),fn.exports}var Qa=Ya(),kn=mr(Qa),dn={exports:{}},Xa=dn.exports,$r;function Za(){return $r||($r=1,function(e,t){(function(n,r){e.exports=r()})(Xa,function(){function n(f){return(n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(f)}function r(f,a){if(!(f instanceof a))throw new TypeError("Cannot call a class as a function")}function i(f,a){for(var d=0;d<a.length;d++){var y=a[d];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(f,y.key,y)}}function s(f,a,d){return a in f?Object.defineProperty(f,a,{value:d,enumerable:!0,configurable:!0,writable:!0}):f[a]=d,f}function o(f,a){var d=Object.keys(f);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(f);a&&(y=y.filter(function(g){return Object.getOwnPropertyDescriptor(f,g).enumerable})),d.push.apply(d,y)}return d}function c(f){return function(d){if(Array.isArray(d))return u(d)}(f)||function(d){if(typeof Symbol<"u"&&Symbol.iterator in Object(d))return Array.from(d)}(f)||function(d,y){if(d){if(typeof d=="string")return u(d,y);var g=Object.prototype.toString.call(d).slice(8,-1);if(g==="Object"&&d.constructor&&(g=d.constructor.name),g==="Map"||g==="Set")return Array.from(d);if(g==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(g))return u(d,y)}}(f)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function u(f,a){(a==null||a>f.length)&&(a=f.length);for(var d=0,y=new Array(a);d<a;d++)y[d]=f[d];return y}function l(f){return(l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d})(f)}function h(f,a){if(!(f instanceof a))throw new TypeError("Cannot call a class as a function")}function m(f,a){for(var d=0;d<a.length;d++){var y=a[d];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(f,y.key,y)}}function b(f,a,d){return a in f?Object.defineProperty(f,a,{value:d,enumerable:!0,configurable:!0,writable:!0}):f[a]=d,f}function A(f,a){var d=Object.keys(f);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(f);a&&(y=y.filter(function(g){return Object.getOwnPropertyDescriptor(f,g).enumerable})),d.push.apply(d,y)}return d}function _(f){for(var a=1;a<arguments.length;a++){var d=arguments[a]!=null?arguments[a]:{};a%2?A(Object(d),!0).forEach(function(y){b(f,y,d[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(f,Object.getOwnPropertyDescriptors(d)):A(Object(d)).forEach(function(y){Object.defineProperty(f,y,Object.getOwnPropertyDescriptor(d,y))})}return f}function k(f,a){return function(y){if(Array.isArray(y))return y}(f)||function(y,g){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(y)))){var R=[],D=!0,W=!1,M=void 0;try{for(var H,ee=y[Symbol.iterator]();!(D=(H=ee.next()).done)&&(R.push(H.value),!g||R.length!==g);D=!0);}catch(te){W=!0,M=te}finally{try{D||ee.return==null||ee.return()}finally{if(W)throw M}}return R}}(f,a)||L(f,a)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function x(f){return function(d){if(Array.isArray(d))return F(d)}(f)||function(d){if(typeof Symbol<"u"&&Symbol.iterator in Object(d))return Array.from(d)}(f)||L(f)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function L(f,a){if(f){if(typeof f=="string")return F(f,a);var d=Object.prototype.toString.call(f).slice(8,-1);return d==="Object"&&f.constructor&&(d=f.constructor.name),d==="Map"||d==="Set"?Array.from(f):d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d)?F(f,a):void 0}}function F(f,a){(a==null||a>f.length)&&(a=f.length);for(var d=0,y=new Array(a);d<a;d++)y[d]=f[d];return y}var O=function f(a){h(this,f),this.p=new Promise(a)};O.__typeson__type__="TypesonPromise",typeof Symbol<"u"&&(O.prototype[Symbol.toStringTag]="TypesonPromise"),O.prototype.then=function(f,a){var d=this;return new O(function(y,g){d.p.then(function(R){y(f?f(R):R)}).catch(function(R){return a?a(R):Promise.reject(R)}).then(y,g)})},O.prototype.catch=function(f){return this.then(null,f)},O.resolve=function(f){return new O(function(a){a(f)})},O.reject=function(f){return new O(function(a,d){d(f)})},["all","race"].forEach(function(f){O[f]=function(a){return new O(function(d,y){Promise[f](a.map(function(g){return g&&g.constructor&&g.constructor.__typeson__type__==="TypesonPromise"?g.p:g})).then(d,y)})}});var P={}.toString,B={}.hasOwnProperty,z=Object.getPrototypeOf,J=B.toString;function w(f,a){return ie(f)&&typeof f.then=="function"&&(!a||typeof f.catch=="function")}function p(f){return P.call(f).slice(8,-1)}function N(f,a){if(!f||l(f)!=="object")return!1;var d=z(f);if(!d)return a===null;var y=B.call(d,"constructor")&&d.constructor;return typeof y!="function"?a===null:a===y||a!==null&&J.call(y)===J.call(a)||typeof a=="function"&&typeof y.__typeson__type__=="string"&&y.__typeson__type__===a.__typeson__type__}function v(f){return!(!f||p(f)!=="Object")&&(!z(f)||N(f,Object))}function ie(f){return f&&l(f)==="object"}function ae(f){return f.replace(/~/g,"~0").replace(/\./g,"~1")}function fe(f){return f.replace(/~1/g,".").replace(/~0/g,"~")}function he(f,a){if(a==="")return f;var d=a.indexOf(".");if(d>-1){var y=f[fe(a.slice(0,d))];return y===void 0?void 0:he(y,a.slice(d+1))}return f[fe(a)]}function Te(f,a,d){if(a==="")return d;var y=a.indexOf(".");return y>-1?Te(f[fe(a.slice(0,y))],a.slice(y+1),d):(f[fe(a)]=d,f)}function Re(f,a,d){return d?a?a(f):f:(f&&f.then||(f=Promise.resolve(f)),a?f.then(a):f)}var Me=Object.keys,je=Array.isArray,ge={}.hasOwnProperty,_e=["type","replaced","iterateIn","iterateUnsetNumeric"];function Le(f){return function(){for(var a=[],d=0;d<arguments.length;d++)a[d]=arguments[d];try{return Promise.resolve(f.apply(this,a))}catch(y){return Promise.reject(y)}}}function et(f,a){if(f.keypath==="")return-1;var d=f.keypath.match(/\./g)||0,y=a.keypath.match(/\./g)||0;return d&&(d=d.length),y&&(y=y.length),d>y?-1:d<y?1:f.keypath<a.keypath?-1:f.keypath>a.keypath}var Q=function(){function f(a){h(this,f),this.options=a,this.plainObjectReplacers=[],this.nonplainObjectReplacers=[],this.revivers={},this.types={}}return function(d,y,g){return y&&m(d.prototype,y),d}(f,[{key:"stringify",value:function(d,y,g,R){R=_(_(_({},this.options),R),{},{stringification:!0});var D=this.encapsulate(d,null,R);return je(D)?JSON.stringify(D[0],y,g):D.then(function(W){return JSON.stringify(W,y,g)})}},{key:"stringifySync",value:function(d,y,g,R){return this.stringify(d,y,g,_(_({throwOnBadSyncType:!0},R),{},{sync:!0}))}},{key:"stringifyAsync",value:function(d,y,g,R){return this.stringify(d,y,g,_(_({throwOnBadSyncType:!0},R),{},{sync:!1}))}},{key:"parse",value:function(d,y,g){return g=_(_(_({},this.options),g),{},{parse:!0}),this.revive(JSON.parse(d,y),g)}},{key:"parseSync",value:function(d,y,g){return this.parse(d,y,_(_({throwOnBadSyncType:!0},g),{},{sync:!0}))}},{key:"parseAsync",value:function(d,y,g){return this.parse(d,y,_(_({throwOnBadSyncType:!0},g),{},{sync:!1}))}},{key:"specialTypeNames",value:function(d,y){var g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return g.returnTypeNames=!0,this.encapsulate(d,y,g)}},{key:"rootTypeName",value:function(d,y){var g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return g.iterateNone=!0,this.encapsulate(d,y,g)}},{key:"encapsulate",value:function(d,y,g){var R=Le(function($,j){return Re(Promise.all(j.map(function(G){return G[1].p})),function(G){return Re(Promise.all(G.map(Le(function(q){var Y=!1,ne=[],Ge=k(j.splice(0,1),1),Oe=k(Ge[0],7),$e=Oe[0],Ye=Oe[2],me=Oe[3],Qe=Oe[4],Se=Oe[5],Je=Oe[6],De=X($e,q,Ye,me,ne,!0,Je),it=N(De,O);return function(Cn,Yt){var Pt=Cn();return Pt&&Pt.then?Pt.then(Yt):Yt(Pt)}(function(){if($e&&it)return Re(De.p,function(st){return Qe[Se]=st,Y=!0,R($,ne)})},function(st){return Y?st:($e?Qe[Se]=De:$=it?De.p:De,R($,ne))})}))),function(){return $})})}),D=(g=_(_({sync:!0},this.options),g)).sync,W=this,M={},H=[],ee=[],te=[],de=!("cyclic"in g)||g.cyclic,ue=g.encapsulateObserver,ce=X("",d,de,y||{},te);function we($){var j=Object.values(M);if(g.iterateNone)return j.length?j[0]:f.getJSONType($);if(j.length){if(g.returnTypeNames)return x(new Set(j));$&&v($)&&!ge.call($,"$types")?$.$types=M:$={$,$types:{$:M}}}else ie($)&&ge.call($,"$types")&&($={$,$types:!0});return!g.returnTypeNames&&$}function be($,j,G){Object.assign($,j);var q=_e.map(function(Y){var ne=$[Y];return delete $[Y],ne});G(),_e.forEach(function(Y,ne){$[Y]=q[ne]})}function X($,j,G,q,Y,ne,Ge){var Oe,$e={},Ye=l(j),me=ue?function(yt){var ze=Ge||q.type||f.getJSONType(j);ue(Object.assign(yt||$e,{keypath:$,value:j,cyclic:G,stateObj:q,promisesData:Y,resolvingTypesonPromise:ne,awaitingTypesonPromise:N(j,O)},{type:ze}))}:null;if(["string","boolean","number","undefined"].includes(Ye))return j===void 0||Number.isNaN(j)||j===Number.NEGATIVE_INFINITY||j===Number.POSITIVE_INFINITY?(Oe=q.replaced?j:ke($,j,q,Y,!1,ne,me))!==j&&($e={replaced:Oe}):Oe=j,me&&me(),Oe;if(j===null)return me&&me(),j;if(G&&!q.iterateIn&&!q.iterateUnsetNumeric&&j&&l(j)==="object"){var Qe=H.indexOf(j);if(!(Qe<0))return M[$]="#",me&&me({cyclicKeypath:ee[Qe]}),"#"+ee[Qe];G===!0&&(H.push(j),ee.push($))}var Se,Je=v(j),De=je(j),it=(Je||De)&&(!W.plainObjectReplacers.length||q.replaced)||q.iterateIn?j:ke($,j,q,Y,Je||De,null,me);if(it!==j?(Oe=it,$e={replaced:it}):$===""&&N(j,O)?(Y.push([$,j,G,q,void 0,void 0,q.type]),Oe=j):De&&q.iterateIn!=="object"||q.iterateIn==="array"?(Se=new Array(j.length),$e={clone:Se}):(["function","symbol"].includes(l(j))||"toJSON"in j||N(j,O)||N(j,Promise)||N(j,ArrayBuffer))&&!Je&&q.iterateIn!=="object"?Oe=j:(Se={},q.addLength&&(Se.length=j.length),$e={clone:Se}),me&&me(),g.iterateNone)return Se||Oe;if(!Se)return Oe;if(q.iterateIn){var st=function(ze){var lt={ownKeys:ge.call(j,ze)};be(q,lt,function(){var _t=$+($?".":"")+ae(ze),Qt=X(_t,j[ze],!!G,q,Y,ne);N(Qt,O)?Y.push([_t,Qt,!!G,q,Se,ze,q.type]):Qt!==void 0&&(Se[ze]=Qt)})};for(var Cn in j)st(Cn);me&&me({endIterateIn:!0,end:!0})}else Me(j).forEach(function(yt){var ze=$+($?".":"")+ae(yt);be(q,{ownKeys:!0},function(){var lt=X(ze,j[yt],!!G,q,Y,ne);N(lt,O)?Y.push([ze,lt,!!G,q,Se,yt,q.type]):lt!==void 0&&(Se[yt]=lt)})}),me&&me({endIterateOwn:!0,end:!0});if(q.iterateUnsetNumeric){for(var Yt=j.length,Pt=function(ze){if(!(ze in j)){var lt=$+($?".":"")+ze;be(q,{ownKeys:!1},function(){var _t=X(lt,void 0,!!G,q,Y,ne);N(_t,O)?Y.push([lt,_t,!!G,q,Se,ze,q.type]):_t!==void 0&&(Se[ze]=_t)})}},xn=0;xn<Yt;xn++)Pt(xn);me&&me({endIterateUnsetNumeric:!0,end:!0})}return Se}function ke($,j,G,q,Y,ne,Ge){for(var Oe=Y?W.plainObjectReplacers:W.nonplainObjectReplacers,$e=Oe.length;$e--;){var Ye=Oe[$e];if(Ye.test(j,G)){var me=Ye.type;if(W.revivers[me]){var Qe=M[$];M[$]=Qe?[me].concat(Qe):me}return Object.assign(G,{type:me,replaced:!0}),!D&&Ye.replaceAsync||Ye.replace?(Ge&&Ge({replacing:!0}),X($,Ye[D||!Ye.replaceAsync?"replace":"replaceAsync"](j,G),de&&"readonly",G,q,ne,me)):(Ge&&Ge({typeDetected:!0}),X($,j,de&&"readonly",G,q,ne,me))}}return j}return te.length?D&&g.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(R(ce,te)).then(we):!D&&g.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():g.stringification&&D?[we(ce)]:D?we(ce):Promise.resolve(we(ce))}},{key:"encapsulateSync",value:function(d,y,g){return this.encapsulate(d,y,_(_({throwOnBadSyncType:!0},g),{},{sync:!0}))}},{key:"encapsulateAsync",value:function(d,y,g){return this.encapsulate(d,y,_(_({throwOnBadSyncType:!0},g),{},{sync:!1}))}},{key:"revive",value:function(d,y){var g=d&&d.$types;if(!g)return d;if(g===!0)return d.$;var R=(y=_(_({sync:!0},this.options),y)).sync,D=[],W={},M=!0;g.$&&v(g.$)&&(d=d.$,g=g.$,M=!1);var H=this;function ee(we,be){var X=k(H.revivers[we]||[],1)[0];if(!X)throw new Error("Unregistered type: "+we);return R&&!("revive"in X)?be:X[R&&X.revive?"revive":!R&&X.reviveAsync?"reviveAsync":"revive"](be,W)}var te=[];function de(we){return N(we,ve)?void 0:we}var ue,ce=function(){var be=[];if(Object.entries(g).forEach(function(X){var ke=k(X,2),$=ke[0],j=ke[1];j!=="#"&&[].concat(j).forEach(function(G){k(H.revivers[G]||[null,{}],2)[1].plain&&(be.push({keypath:$,type:G}),delete g[$])})}),be.length)return be.sort(et).reduce(function X(ke,$){var j=$.keypath,G=$.type;if(w(ke))return ke.then(function(ne){return X(ne,{keypath:j,type:G})});var q=he(d,j);if(N(q=ee(G,q),O))return q.then(function(ne){var Ge=Te(d,j,ne);Ge===ne&&(d=Ge)});var Y=Te(d,j,q);Y===q&&(d=Y)},void 0)}();return N(ce,O)?ue=ce.then(function(){return d}):(ue=function we(be,X,ke,$,j){if(!M||be!=="$types"){var G=g[be],q=je(X);if(q||v(X)){var Y=q?new Array(X.length):{};for(Me(X).forEach(function(Se){var Je=we(be+(be?".":"")+ae(Se),X[Se],ke||Y,Y,Se),De=function(st){return N(st,ve)?Y[Se]=void 0:st!==void 0&&(Y[Se]=st),st};N(Je,O)?te.push(Je.then(function(it){return De(it)})):De(Je)}),X=Y;D.length;){var ne=k(D[0],4),Ge=ne[0],Oe=ne[1],$e=ne[2],Ye=ne[3],me=he(Ge,Oe);if(me===void 0)break;$e[Ye]=me,D.splice(0,1)}}if(!G)return X;if(G==="#"){var Qe=he(ke,X.slice(1));return Qe===void 0&&D.push([ke,X.slice(1),$,j]),Qe}return[].concat(G).reduce(function Se(Je,De){return N(Je,O)?Je.then(function(it){return Se(it,De)}):ee(De,Je)},X)}}("",d,null),te.length&&(ue=O.resolve(ue).then(function(we){return O.all([we].concat(te))}).then(function(we){return k(we,1)[0]}))),w(ue)?R&&y.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():N(ue,O)?ue.p.then(de):ue:!R&&y.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():R?de(ue):Promise.resolve(de(ue))}},{key:"reviveSync",value:function(d,y){return this.revive(d,_(_({throwOnBadSyncType:!0},y),{},{sync:!0}))}},{key:"reviveAsync",value:function(d,y){return this.revive(d,_(_({throwOnBadSyncType:!0},y),{},{sync:!1}))}},{key:"register",value:function(d,y){return y=y||{},[].concat(d).forEach(function g(R){var D=this;if(je(R))return R.map(function(W){return g.call(D,W)});R&&Me(R).forEach(function(W){if(W==="#")throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(f.JSON_TYPES.includes(W))throw new TypeError("Plain JSON object types are reserved as type names");var M=R[W],H=M&&M.testPlainObjects?this.plainObjectReplacers:this.nonplainObjectReplacers,ee=H.filter(function(be){return be.type===W});if(ee.length&&(H.splice(H.indexOf(ee[0]),1),delete this.revivers[W],delete this.types[W]),typeof M=="function"){var te=M;M={test:function(X){return X&&X.constructor===te},replace:function(X){return _({},X)},revive:function(X){return Object.assign(Object.create(te.prototype),X)}}}else if(je(M)){var de=k(M,3);M={test:de[0],replace:de[1],revive:de[2]}}if(M&&M.test){var ue={type:W,test:M.test.bind(M)};M.replace&&(ue.replace=M.replace.bind(M)),M.replaceAsync&&(ue.replaceAsync=M.replaceAsync.bind(M));var ce=typeof y.fallback=="number"?y.fallback:y.fallback?0:Number.POSITIVE_INFINITY;if(M.testPlainObjects?this.plainObjectReplacers.splice(ce,0,ue):this.nonplainObjectReplacers.splice(ce,0,ue),M.revive||M.reviveAsync){var we={};M.revive&&(we.revive=M.revive.bind(M)),M.reviveAsync&&(we.reviveAsync=M.reviveAsync.bind(M)),this.revivers[W]=[we,{plain:M.testPlainObjects}]}this.types[W]=M}},this)},this),this}}]),f}(),ve=function f(){h(this,f)};ve.__typeson__type__="TypesonUndefined",Q.Undefined=ve,Q.Promise=O,Q.isThenable=w,Q.toStringTag=p,Q.hasConstructorOf=N,Q.isObject=ie,Q.isPlainObject=v,Q.isUserObject=function f(a){if(!a||p(a)!=="Object")return!1;var d=z(a);return!d||N(a,Object)||f(d)},Q.escapeKeyPathComponent=ae,Q.unescapeKeyPathComponent=fe,Q.getByKeyPath=he,Q.getJSONType=function(a){return a===null?"null":Array.isArray(a)?"array":l(a)},Q.JSON_TYPES=["null","boolean","number","string","array","object"];for(var Be={userObject:{test:function(a,d){return Q.isUserObject(a)},replace:function(a){return function(y){for(var g=1;g<arguments.length;g++){var R=arguments[g]!=null?arguments[g]:{};g%2?o(Object(R),!0).forEach(function(D){s(y,D,R[D])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(R)):o(Object(R)).forEach(function(D){Object.defineProperty(y,D,Object.getOwnPropertyDescriptor(R,D))})}return y}({},a)},revive:function(a){return a}}},T=[{arrayNonindexKeys:{testPlainObjects:!0,test:function(a,d){return!!Array.isArray(a)&&(Object.keys(a).some(function(y){return String(Number.parseInt(y))!==y})&&(d.iterateIn="object",d.addLength=!0),!0)},replace:function(a,d){return d.iterateUnsetNumeric=!0,a},revive:function(a){if(Array.isArray(a))return a;var d=[];return Object.keys(a).forEach(function(y){var g=a[y];d[y]=g}),d}}},{sparseUndefined:{test:function(a,d){return a===void 0&&d.ownKeys===!1},replace:function(a){return 0},revive:function(a){}}}],E={undef:{test:function(a,d){return a===void 0&&(d.ownKeys||!("ownKeys"in d))},replace:function(a){return 0},revive:function(a){return new Q.Undefined}}},C={StringObject:{test:function(a){return Q.toStringTag(a)==="String"&&n(a)==="object"},replace:function(a){return String(a)},revive:function(a){return new String(a)}},BooleanObject:{test:function(a){return Q.toStringTag(a)==="Boolean"&&n(a)==="object"},replace:function(a){return!!a},revive:function(a){return new Boolean(a)}},NumberObject:{test:function(a){return Q.toStringTag(a)==="Number"&&n(a)==="object"},replace:function(a){return Number(a)},revive:function(a){return new Number(a)}}},I=[{nan:{test:function(a){return Number.isNaN(a)},replace:function(a){return"NaN"},revive:function(a){return Number.NaN}}},{infinity:{test:function(a){return a===Number.POSITIVE_INFINITY},replace:function(a){return"Infinity"},revive:function(a){return Number.POSITIVE_INFINITY}}},{negativeInfinity:{test:function(a){return a===Number.NEGATIVE_INFINITY},replace:function(a){return"-Infinity"},revive:function(a){return Number.NEGATIVE_INFINITY}}}],U={date:{test:function(a){return Q.toStringTag(a)==="Date"},replace:function(a){var d=a.getTime();return Number.isNaN(d)?"NaN":d},revive:function(a){return a==="NaN"?new Date(Number.NaN):new Date(a)}}},Z={regexp:{test:function(a){return Q.toStringTag(a)==="RegExp"},replace:function(a){return{source:a.source,flags:(a.global?"g":"")+(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.sticky?"y":"")+(a.unicode?"u":"")}},revive:function(a){var d=a.source,y=a.flags;return new RegExp(d,y)}}},se={map:{test:function(a){return Q.toStringTag(a)==="Map"},replace:function(a){return c(a.entries())},revive:function(a){return new Map(a)}}},oe={set:{test:function(a){return Q.toStringTag(a)==="Set"},replace:function(a){return c(a.values())},revive:function(a){return new Set(a)}}},K="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ie=new Uint8Array(256),Fe=0;Fe<K.length;Fe++)Ie[K.charCodeAt(Fe)]=Fe;var Ke=function(a,d,y){y==null&&(y=a.byteLength);for(var g=new Uint8Array(a,0,y),R=g.length,D="",W=0;W<R;W+=3)D+=K[g[W]>>2],D+=K[(3&g[W])<<4|g[W+1]>>4],D+=K[(15&g[W+1])<<2|g[W+2]>>6],D+=K[63&g[W+2]];return R%3==2?D=D.slice(0,-1)+"=":R%3==1&&(D=D.slice(0,-2)+"=="),D},tt=function(a){var d,y,g,R,D=a.length,W=.75*a.length,M=0;a[a.length-1]==="="&&(W--,a[a.length-2]==="="&&W--);for(var H=new ArrayBuffer(W),ee=new Uint8Array(H),te=0;te<D;te+=4)d=Ie[a.charCodeAt(te)],y=Ie[a.charCodeAt(te+1)],g=Ie[a.charCodeAt(te+2)],R=Ie[a.charCodeAt(te+3)],ee[M++]=d<<2|y>>4,ee[M++]=(15&y)<<4|g>>2,ee[M++]=(3&g)<<6|63&R;return H},nt={arraybuffer:{test:function(a){return Q.toStringTag(a)==="ArrayBuffer"},replace:function(a,d){d.buffers||(d.buffers=[]);var y=d.buffers.indexOf(a);return y>-1?{index:y}:(d.buffers.push(a),Ke(a))},revive:function(a,d){if(d.buffers||(d.buffers=[]),n(a)==="object")return d.buffers[a.index];var y=tt(a);return d.buffers.push(y),y}}},ut=typeof self>"u"?Ja:self,qe={};["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"].forEach(function(f){var a=f,d=ut[a];d&&(qe[f.toLowerCase()]={test:function(g){return Q.toStringTag(g)===a},replace:function(g,R){var D=g.buffer,W=g.byteOffset,M=g.length;R.buffers||(R.buffers=[]);var H=R.buffers.indexOf(D);return H>-1?{index:H,byteOffset:W,length:M}:(R.buffers.push(D),{encoded:Ke(D),byteOffset:W,length:M})},revive:function(g,R){R.buffers||(R.buffers=[]);var D,W=g.byteOffset,M=g.length,H=g.encoded,ee=g.index;return"index"in g?D=R.buffers[ee]:(D=tt(H),R.buffers.push(D)),new d(D,W,M)}})});var rt={dataview:{test:function(a){return Q.toStringTag(a)==="DataView"},replace:function(a,d){var y=a.buffer,g=a.byteOffset,R=a.byteLength;d.buffers||(d.buffers=[]);var D=d.buffers.indexOf(y);return D>-1?{index:D,byteOffset:g,byteLength:R}:(d.buffers.push(y),{encoded:Ke(y),byteOffset:g,byteLength:R})},revive:function(a,d){d.buffers||(d.buffers=[]);var y,g=a.byteOffset,R=a.byteLength,D=a.encoded,W=a.index;return"index"in a?y=d.buffers[W]:(y=tt(D),d.buffers.push(y)),new DataView(y,g,R)}}},Ee={IntlCollator:{test:function(a){return Q.hasConstructorOf(a,Intl.Collator)},replace:function(a){return a.resolvedOptions()},revive:function(a){return new Intl.Collator(a.locale,a)}},IntlDateTimeFormat:{test:function(a){return Q.hasConstructorOf(a,Intl.DateTimeFormat)},replace:function(a){return a.resolvedOptions()},revive:function(a){return new Intl.DateTimeFormat(a.locale,a)}},IntlNumberFormat:{test:function(a){return Q.hasConstructorOf(a,Intl.NumberFormat)},replace:function(a){return a.resolvedOptions()},revive:function(a){return new Intl.NumberFormat(a.locale,a)}}};function pe(f){for(var a=new Uint8Array(f.length),d=0;d<f.length;d++)a[d]=f.charCodeAt(d);return a.buffer}var le={file:{test:function(a){return Q.toStringTag(a)==="File"},replace:function(a){var d=new XMLHttpRequest;if(d.overrideMimeType("text/plain; charset=x-user-defined"),d.open("GET",URL.createObjectURL(a),!1),d.send(),d.status!==200&&d.status!==0)throw new Error("Bad File access: "+d.status);return{type:a.type,stringContents:d.responseText,name:a.name,lastModified:a.lastModified}},revive:function(a){var d=a.name,y=a.type,g=a.stringContents,R=a.lastModified;return new File([pe(g)],d,{type:y,lastModified:R})},replaceAsync:function(a){return new Q.Promise(function(d,y){var g=new FileReader;g.addEventListener("load",function(){d({type:a.type,stringContents:g.result,name:a.name,lastModified:a.lastModified})}),g.addEventListener("error",function(){y(g.error)}),g.readAsBinaryString(a)})}}},ye={bigint:{test:function(a){return typeof a=="bigint"},replace:function(a){return String(a)},revive:function(a){return BigInt(a)}}},Ae={bigintObject:{test:function(a){return n(a)==="object"&&Q.hasConstructorOf(a,BigInt)},replace:function(a){return String(a)},revive:function(a){return new Object(BigInt(a))}}},V={cryptokey:{test:function(a){return Q.toStringTag(a)==="CryptoKey"&&a.extractable},replaceAsync:function(a){return new Q.Promise(function(d,y){crypto.subtle.exportKey("jwk",a).catch(function(g){y(g)}).then(function(g){d({jwk:g,algorithm:a.algorithm,usages:a.usages})})})},revive:function(a){var d=a.jwk,y=a.algorithm,g=a.usages;return crypto.subtle.importKey("jwk",d,y,!0,g)}}};return[Be,E,T,C,I,U,Z,{imagedata:{test:function(a){return Q.toStringTag(a)==="ImageData"},replace:function(a){return{array:c(a.data),width:a.width,height:a.height}},revive:function(a){return new ImageData(new Uint8ClampedArray(a.array),a.width,a.height)}}},{imagebitmap:{test:function(a){return Q.toStringTag(a)==="ImageBitmap"||a&&a.dataset&&a.dataset.toStringTag==="ImageBitmap"},replace:function(a){var d=document.createElement("canvas");return d.getContext("2d").drawImage(a,0,0),d.toDataURL()},revive:function(a){var d=document.createElement("canvas"),y=d.getContext("2d"),g=document.createElement("img");return g.addEventListener("load",function(){y.drawImage(g,0,0)}),g.src=a,d},reviveAsync:function(a){var d=document.createElement("canvas"),y=d.getContext("2d"),g=document.createElement("img");return g.addEventListener("load",function(){y.drawImage(g,0,0)}),g.src=a,createImageBitmap(d)}}},le,{file:le.file,filelist:{test:function(a){return Q.toStringTag(a)==="FileList"},replace:function(a){for(var d=[],y=0;y<a.length;y++)d[y]=a.item(y);return d},revive:function(a){return new(function(){function d(){r(this,d),this._files=arguments[0],this.length=this._files.length}return function(g,R,D){return R&&i(g.prototype,R),g}(d,[{key:"item",value:function(g){return this._files[g]}},{key:Symbol.toStringTag,get:function(){return"FileList"}}]),d}())(a)}}},{blob:{test:function(a){return Q.toStringTag(a)==="Blob"},replace:function(a){var d=new XMLHttpRequest;if(d.overrideMimeType("text/plain; charset=x-user-defined"),d.open("GET",URL.createObjectURL(a),!1),d.send(),d.status!==200&&d.status!==0)throw new Error("Bad Blob access: "+d.status);return{type:a.type,stringContents:d.responseText}},revive:function(a){var d=a.type,y=a.stringContents;return new Blob([pe(y)],{type:d})},replaceAsync:function(a){return new Q.Promise(function(d,y){var g=new FileReader;g.addEventListener("load",function(){d({type:a.type,stringContents:g.result})}),g.addEventListener("error",function(){y(g.error)}),g.readAsBinaryString(a)})}}}].concat(typeof Map=="function"?se:[],typeof Set=="function"?oe:[],typeof ArrayBuffer=="function"?nt:[],typeof Uint8Array=="function"?qe:[],typeof DataView=="function"?rt:[],typeof Intl<"u"?Ee:[],typeof crypto<"u"?V:[],typeof BigInt<"u"?[ye,Ae]:[])})}(dn)),dn.exports}var ec=Za(),tc=mr(ec),Ut="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ft=new Uint8Array(256);for(var un=0;un<Ut.length;un++)Ft[Ut.codePointAt(un)]=un;var or=function(t,n,r){r==null&&(r=t.byteLength);for(var i=new Uint8Array(t,0,r),s=i.length,o="",c=0;c<s;c+=3)o+=Ut[i[c]>>2],o+=Ut[(i[c]&3)<<4|i[c+1]>>4],o+=Ut[(i[c+1]&15)<<2|i[c+2]>>6],o+=Ut[i[c+2]&63];return s%3===2?o=o.slice(0,-1)+"=":s%3===1&&(o=o.slice(0,-2)+"=="),o},Fi=function(t,n){var r=t.length;if(r%4)throw new Error("Bad base64 length: not divisible by four");var i=t.length*.75,s=0,o,c,u,l;t[t.length-1]==="="&&(i--,t[t.length-2]==="="&&i--);for(var h=new ArrayBuffer(i,n),m=new Uint8Array(h),b=0;b<r;b+=4)o=Ft[t.codePointAt(b)],c=Ft[t.codePointAt(b+1)],u=Ft[t.codePointAt(b+2)],l=Ft[t.codePointAt(b+3)],m[s++]=o<<2|c>>4,m[s++]=(c&15)<<4|u>>2,m[s++]=(u&3)<<6|l&63;return h},nc=typeof self>"u"?global:self,$i={};["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"].forEach(function(e){var t=e,n=nc[t];n&&($i[e.toLowerCase()+"2"]={test:function(r){return kn.toStringTag(r)===t},replace:function(r){var i=r.buffer,s=r.byteOffset,o=r.length;return{buffer:i,byteOffset:s,length:o}},revive:function(r){var i=r.buffer,s=r.byteOffset,o=r.length;return new n(i,s,o)}})});var rc={arraybuffer:{test:function(e){return kn.toStringTag(e)==="ArrayBuffer"},replace:function(e){return or(e,0,e.byteLength)},revive:function(e){var t=Fi(e);return t}}},Xe=new kn().register(tc),ic="FileReaderSync"in self,Sn=[],hn=0;Xe.register([rc,$i,{blob2:{test:function(e){return kn.toStringTag(e)==="Blob"},replace:function(e){if(e.isClosed)throw new Error("The Blob is closed");if(ic){var t=Bi(e),n=or(t,0,t.byteLength);return{type:e.type,data:n}}else{Sn.push(e);var r={type:e.type,data:{start:hn,end:hn+e.size}};return hn+=e.size,r}},finalize:function(e,t){e.data=or(t,0,t.byteLength)},revive:function(e){var t=e.type,n=e.data;return new Blob([Fi(n)],{type:t})}}}]);Xe.mustFinalize=function(){return Sn.length>0};Xe.finalize=function(e){return St(void 0,void 0,void 0,function(){var t,n,r,i,s,o,c,u,l,h,m,b;return ot(this,function(A){switch(A.label){case 0:return[4,Li(new Blob(Sn))];case 1:if(t=A.sent(),e){for(n=0,r=e;n<r.length;n++)if(i=r[n],i.$types){s=i.$types,o=s.$,o&&(s=s.$);for(c in s)u=s[c],l=Xe.types[u],l&&l.finalize&&(h=Ne.getByKeyPath(i,o?"$."+c:c),l.finalize(h,t.slice((m=h.data)===null||m===void 0?void 0:m.start,(b=h.data)===null||b===void 0?void 0:b.end)))}}return Sn=[],hn=0,[2]}})})};var sc=2e3;function Vi(e,t){return St(this,void 0,void 0,function(){function n(){return St(this,void 0,void 0,function(){var m,b,A,_,k,x,L,F,O,P;return ot(this,function(B){switch(B.label){case 0:return[4,Promise.all(i.map(function(z){return z.count()}))];case 1:m=B.sent(),m.forEach(function(z,J){return o[J].rowCount=z}),h.totalRows=m.reduce(function(z,J){return z+J}),b=JSON.stringify(u,void 0,c?2:void 0),A=b.lastIndexOf("]"),_=b.substring(0,A),s.push(_),k=t.filter,x=t.transform,L=function(z){var J,w,p,N,v,ie,ae,fe,he,Te,Re,Me;return ot(this,function(je){switch(je.label){case 0:J=e.table(z),w=J.schema.primKey,p=!!w.keyPath,N=t.numRowsPerChunk||sc,v=p?{tableName:J.name,inbound:!0,rows:[]}:{tableName:J.name,inbound:!1,rows:[]},ie=JSON.stringify(v,void 0,c?2:void 0),c&&(ie=ie.split(`
`).join(`
    `)),ae=ie.lastIndexOf("]"),s.push(ie.substring(0,ae)),fe=null,he=0,Te=!0,Re=function(){var ge,_e,Le,et,Q,E,ve,Be,T,E;return ot(this,function(C){switch(C.label){case 0:return l&&Ne.ignoreTransaction(function(){return l(h)}),ge=fe==null?J.limit(N):J.where(":id").above(fe).limit(N),[4,ge.toArray()];case 1:return _e=C.sent(),_e.length===0?[2,"break"]:(fe!=null&&he>0&&(s.push(","),c&&s.push(`
      `)),Te=_e.length===N,p?(Le=k?_e.filter(function(I){return k(z,I)}):_e,et=x?Le.map(function(I){return x(z,I).value}):Le,Q=et.map(function(I){return Xe.encapsulate(I)}),Xe.mustFinalize()?[4,Ne.waitFor(Xe.finalize(Q))]:[3,3]):[3,4]);case 2:C.sent(),C.label=3;case 3:return E=JSON.stringify(Q,void 0,c?2:void 0),c&&(E=E.split(`
`).join(`
      `)),s.push(new Blob([E.substring(1,E.length-1)])),he=et.length,fe=_e.length>0?Ne.getByKeyPath(_e[_e.length-1],w.keyPath):null,[3,8];case 4:return[4,ge.primaryKeys()];case 5:return ve=C.sent(),Be=ve.map(function(I,U){return[I,_e[U]]}),k&&(Be=Be.filter(function(I){var U=I[0],Z=I[1];return k(z,Z,U)})),x&&(Be=Be.map(function(I){var U=I[0],Z=I[1],se=x(z,Z,U);return[se.key,se.value]})),T=Be.map(function(I){return Xe.encapsulate(I)}),Xe.mustFinalize()?[4,Ne.waitFor(Xe.finalize(T))]:[3,7];case 6:C.sent(),C.label=7;case 7:E=JSON.stringify(T,void 0,c?2:void 0),c&&(E=E.split(`
`).join(`
      `)),s.push(new Blob([E.substring(1,E.length-1)])),he=Be.length,fe=ve.length>0?ve[ve.length-1]:null,C.label=8;case 8:return h.completedRows+=_e.length,[2]}})},je.label=1;case 1:return Te?[5,Re()]:[3,3];case 2:return Me=je.sent(),Me==="break"?[3,3]:[3,1];case 3:return s.push(ie.substr(ae)),h.completedTables+=1,h.completedTables<h.totalTables&&s.push(","),[2]}})},F=0,O=o,B.label=2;case 2:return F<O.length?(P=O[F].name,[5,L(P)]):[3,5];case 3:B.sent(),B.label=4;case 4:return F++,[3,2];case 5:return s.push(b.substr(A)),h.done=!0,l&&Ne.ignoreTransaction(function(){return l(h)}),[2]}})})}var r,i,s,o,c,u,l,h;return ot(this,function(m){switch(m.label){case 0:t=t||{},r=t.skipTables?t.skipTables:[],i=e.tables.filter(function(b){return!r.includes(b.name)}),s=[],o=i.map(function(b){return{name:b.name,schema:qa(b),rowCount:0}}),c=t.prettyJson,u={formatName:"dexie",formatVersion:1,data:{databaseName:e.name,databaseVersion:e.verno,tables:o,data:[]}},l=t.progressCallback,h={done:!1,completedRows:0,completedTables:0,totalRows:NaN,totalTables:o.length},m.label=1;case 1:return m.trys.push([1,,6,7]),t.noTransaction?[4,n()]:[3,3];case 2:return m.sent(),[3,5];case 3:return[4,e.transaction("r",e.tables,n)];case 4:m.sent(),m.label=5;case 5:return[3,7];case 6:return Xe.finalize(),[7];case 7:return[2,new Blob(s,{type:"text/json"})]}})})}var oc=1,qn={},Gn,Vr;function ac(){return Vr||(Vr=1,Gn={Stream:function(){}}),Gn}var Wr;function cc(){return Wr||(Wr=1,function(e){(function(t){var n=typeof process=="object"&&Br?Br:self;t.parser=function(w){return new b(w)},t.CParser=b,t.CStream=_,t.createStream=A,t.MAX_BUFFER_LENGTH=10*1024*1024,t.DEBUG=n.CDEBUG==="debug",t.INFO=n.CDEBUG==="debug"||n.CDEBUG==="info",t.EVENTS=["value","string","key","openobject","closeobject","openarray","closearray","error","end","ready"];var r={textNode:void 0,numberNode:""},i=t.EVENTS.filter(function(w){return w!=="error"&&w!=="end"}),s=0,o;t.STATE={BEGIN:s++,VALUE:s++,OPEN_OBJECT:s++,CLOSE_OBJECT:s++,OPEN_ARRAY:s++,CLOSE_ARRAY:s++,TEXT_ESCAPE:s++,STRING:s++,BACKSLASH:s++,END:s++,OPEN_KEY:s++,CLOSE_KEY:s++,TRUE:s++,TRUE2:s++,TRUE3:s++,FALSE:s++,FALSE2:s++,FALSE3:s++,FALSE4:s++,NULL:s++,NULL2:s++,NULL3:s++,NUMBER_DECIMAL_POINT:s++,NUMBER_DIGIT:s++};for(var c in t.STATE)t.STATE[t.STATE[c]]=c;s=t.STATE;const u={tab:9,lineFeed:10,carriageReturn:13,space:32,doubleQuote:34,plus:43,comma:44,minus:45,period:46,_0:48,_9:57,colon:58,E:69,openBracket:91,backslash:92,closeBracket:93,a:97,b:98,e:101,f:102,l:108,n:110,r:114,s:115,t:116,u:117,openBrace:123,closeBrace:125};Object.create||(Object.create=function(w){function p(){this.__proto__=w}return p.prototype=w,new p}),Object.getPrototypeOf||(Object.getPrototypeOf=function(w){return w.__proto__}),Object.keys||(Object.keys=function(w){var p=[];for(var N in w)w.hasOwnProperty(N)&&p.push(N);return p});function l(w){var p=Math.max(t.MAX_BUFFER_LENGTH,10),N=0;for(var v in r){var ie=w[v]===void 0?0:w[v].length;if(ie>p)switch(v){case"text":closeText(w);break;default:P(w,"Max buffer length exceeded: "+v)}N=Math.max(N,ie)}w.bufferCheckPosition=t.MAX_BUFFER_LENGTH-N+w.position}function h(w){for(var p in r)w[p]=r[p]}var m=/[\\"\n]/g;function b(w){if(!(this instanceof b))return new b(w);var p=this;h(p),p.bufferCheckPosition=t.MAX_BUFFER_LENGTH,p.q=p.c=p.p="",p.opt=w||{},p.closed=p.closedRoot=p.sawRoot=!1,p.tag=p.error=null,p.state=s.BEGIN,p.stack=new Array,p.position=p.column=0,p.line=1,p.slashed=!1,p.unicodeI=0,p.unicodeS=null,p.depth=0,k(p,"onready")}b.prototype={end:function(){B(this)},write:J,resume:function(){return this.error=null,this},close:function(){return this.write(null)}};try{o=ac().Stream}catch{o=function(){}}function A(w){return new _(w)}function _(w){if(!(this instanceof _))return new _(w);this._parser=new b(w),this.writable=!0,this.readable=!0,this.bytes_remaining=0,this.bytes_in_sequence=0,this.temp_buffs={2:new Buffer(2),3:new Buffer(3),4:new Buffer(4)},this.string="";var p=this;o.apply(p),this._parser.onend=function(){p.emit("end")},this._parser.onerror=function(N){p.emit("error",N),p._parser.error=null},i.forEach(function(N){Object.defineProperty(p,"on"+N,{get:function(){return p._parser["on"+N]},set:function(v){if(!v)return p.removeAllListeners(N),p._parser["on"+N]=v,v;p.on(N,v)},enumerable:!0,configurable:!1})})}_.prototype=Object.create(o.prototype,{constructor:{value:_}}),_.prototype.write=function(w){w=new Buffer(w);for(var p=0;p<w.length;p++){var N=w[p];if(this.bytes_remaining>0){for(var v=0;v<this.bytes_remaining;v++)this.temp_buffs[this.bytes_in_sequence][this.bytes_in_sequence-this.bytes_remaining+v]=w[v];this.string=this.temp_buffs[this.bytes_in_sequence].toString(),this.bytes_in_sequence=this.bytes_remaining=0,p=p+v-1,this._parser.write(this.string),this.emit("data",this.string);continue}if(this.bytes_remaining===0&&N>=128)if(N>=194&&N<=223&&(this.bytes_in_sequence=2),N>=224&&N<=239&&(this.bytes_in_sequence=3),N>=240&&N<=244&&(this.bytes_in_sequence=4),this.bytes_in_sequence+p>w.length){for(var ie=0;ie<=w.length-1-p;ie++)this.temp_buffs[this.bytes_in_sequence][ie]=w[p+ie];return this.bytes_remaining=p+this.bytes_in_sequence-w.length,!0}else{this.string=w.slice(p,p+this.bytes_in_sequence).toString(),p=p+this.bytes_in_sequence-1,this._parser.write(this.string),this.emit("data",this.string);continue}for(var ae=p;ae<w.length&&!(w[ae]>=128);ae++);this.string=w.slice(p,ae).toString(),this._parser.write(this.string),this.emit("data",this.string),p=ae-1}},_.prototype.end=function(w){return w&&w.length&&this._parser.write(w.toString()),this._parser.end(),!0},_.prototype.on=function(w,p){var N=this;return!N._parser["on"+w]&&i.indexOf(w)!==-1&&(N._parser["on"+w]=function(){var v=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);v.splice(0,0,w),N.emit.apply(N,v)}),o.prototype.on.call(N,w,p)},_.prototype.destroy=function(){h(this._parser),this.emit("close")};function k(w,p,N){t.INFO&&console.log("-- emit",p,N),w[p]&&w[p](N)}function x(w,p,N){L(w),k(w,p,N)}function L(w,p){w.textNode=O(w.opt,w.textNode),w.textNode!==void 0&&k(w,p||"onvalue",w.textNode),w.textNode=void 0}function F(w){w.numberNode&&k(w,"onvalue",parseFloat(w.numberNode)),w.numberNode=""}function O(w,p){return p===void 0||(w.trim&&(p=p.trim()),w.normalize&&(p=p.replace(/\s+/g," "))),p}function P(w,p){return L(w),p+=`
Line: `+w.line+`
Column: `+w.column+`
Char: `+w.c,p=new Error(p),w.error=p,k(w,"onerror",p),w}function B(w){return(w.state!==s.VALUE||w.depth!==0)&&P(w,"Unexpected end"),L(w),w.c="",w.closed=!0,k(w,"onend"),b.call(w,w.opt),w}function z(w){return w===u.carriageReturn||w===u.lineFeed||w===u.space||w===u.tab}function J(w){var p=this;if(this.error)throw this.error;if(p.closed)return P(p,"Cannot write after close. Assign an onready handler.");if(w===null)return B(p);var N=0,v=w.charCodeAt(0),ie=p.p;for(t.DEBUG&&console.log("write -> ["+w+"]");v&&(ie=v,p.c=v=w.charCodeAt(N++),ie!==v?p.p=ie:ie=p.p,!!v);)switch(t.DEBUG&&console.log(N,v,t.STATE[p.state]),p.position++,v===u.lineFeed?(p.line++,p.column=0):p.column++,p.state){case s.BEGIN:v===u.openBrace?p.state=s.OPEN_OBJECT:v===u.openBracket?p.state=s.OPEN_ARRAY:z(v)||P(p,"Non-whitespace before {[.");continue;case s.OPEN_KEY:case s.OPEN_OBJECT:if(z(v))continue;if(p.state===s.OPEN_KEY)p.stack.push(s.CLOSE_KEY);else if(v===u.closeBrace){k(p,"onopenobject"),this.depth++,k(p,"oncloseobject"),this.depth--,p.state=p.stack.pop()||s.VALUE;continue}else p.stack.push(s.CLOSE_OBJECT);v===u.doubleQuote?p.state=s.STRING:P(p,'Malformed object key should start with "');continue;case s.CLOSE_KEY:case s.CLOSE_OBJECT:if(z(v))continue;p.state,s.CLOSE_KEY,v===u.colon?(p.state===s.CLOSE_OBJECT?(p.stack.push(s.CLOSE_OBJECT),L(p,"onopenobject"),this.depth++):L(p,"onkey"),p.state=s.VALUE):v===u.closeBrace?(x(p,"oncloseobject"),this.depth--,p.state=p.stack.pop()||s.VALUE):v===u.comma?(p.state===s.CLOSE_OBJECT&&p.stack.push(s.CLOSE_OBJECT),L(p),p.state=s.OPEN_KEY):P(p,"Bad object");continue;case s.OPEN_ARRAY:case s.VALUE:if(z(v))continue;if(p.state===s.OPEN_ARRAY)if(k(p,"onopenarray"),this.depth++,p.state=s.VALUE,v===u.closeBracket){k(p,"onclosearray"),this.depth--,p.state=p.stack.pop()||s.VALUE;continue}else p.stack.push(s.CLOSE_ARRAY);v===u.doubleQuote?p.state=s.STRING:v===u.openBrace?p.state=s.OPEN_OBJECT:v===u.openBracket?p.state=s.OPEN_ARRAY:v===u.t?p.state=s.TRUE:v===u.f?p.state=s.FALSE:v===u.n?p.state=s.NULL:v===u.minus?p.numberNode+="-":u._0<=v&&v<=u._9?(p.numberNode+=String.fromCharCode(v),p.state=s.NUMBER_DIGIT):P(p,"Bad value");continue;case s.CLOSE_ARRAY:if(v===u.comma)p.stack.push(s.CLOSE_ARRAY),L(p,"onvalue"),p.state=s.VALUE;else if(v===u.closeBracket)x(p,"onclosearray"),this.depth--,p.state=p.stack.pop()||s.VALUE;else{if(z(v))continue;P(p,"Bad array")}continue;case s.STRING:p.textNode===void 0&&(p.textNode="");var ae=N-1,fe=p.slashed,he=p.unicodeI;e:for(;;){for(t.DEBUG&&console.log(N,v,t.STATE[p.state],fe);he>0;)if(p.unicodeS+=String.fromCharCode(v),v=w.charCodeAt(N++),p.position++,he===4?(p.textNode+=String.fromCharCode(parseInt(p.unicodeS,16)),he=0,ae=N-1):he++,!v)break e;if(v===u.doubleQuote&&!fe){p.state=p.stack.pop()||s.VALUE,p.textNode+=w.substring(ae,N-1),p.position+=N-1-ae;break}if(v===u.backslash&&!fe&&(fe=!0,p.textNode+=w.substring(ae,N-1),p.position+=N-1-ae,v=w.charCodeAt(N++),p.position++,!v))break;if(fe){if(fe=!1,v===u.n?p.textNode+=`
`:v===u.r?p.textNode+="\r":v===u.t?p.textNode+="	":v===u.f?p.textNode+="\f":v===u.b?p.textNode+="\b":v===u.u?(he=1,p.unicodeS=""):p.textNode+=String.fromCharCode(v),v=w.charCodeAt(N++),p.position++,ae=N-1,v)continue;break}m.lastIndex=N;var Te=m.exec(w);if(Te===null){N=w.length+1,p.textNode+=w.substring(ae,N-1),p.position+=N-1-ae;break}if(N=Te.index+1,v=w.charCodeAt(Te.index),!v){p.textNode+=w.substring(ae,N-1),p.position+=N-1-ae;break}}p.slashed=fe,p.unicodeI=he;continue;case s.TRUE:v===u.r?p.state=s.TRUE2:P(p,"Invalid true started with t"+v);continue;case s.TRUE2:v===u.u?p.state=s.TRUE3:P(p,"Invalid true started with tr"+v);continue;case s.TRUE3:v===u.e?(k(p,"onvalue",!0),p.state=p.stack.pop()||s.VALUE):P(p,"Invalid true started with tru"+v);continue;case s.FALSE:v===u.a?p.state=s.FALSE2:P(p,"Invalid false started with f"+v);continue;case s.FALSE2:v===u.l?p.state=s.FALSE3:P(p,"Invalid false started with fa"+v);continue;case s.FALSE3:v===u.s?p.state=s.FALSE4:P(p,"Invalid false started with fal"+v);continue;case s.FALSE4:v===u.e?(k(p,"onvalue",!1),p.state=p.stack.pop()||s.VALUE):P(p,"Invalid false started with fals"+v);continue;case s.NULL:v===u.u?p.state=s.NULL2:P(p,"Invalid null started with n"+v);continue;case s.NULL2:v===u.l?p.state=s.NULL3:P(p,"Invalid null started with nu"+v);continue;case s.NULL3:v===u.l?(k(p,"onvalue",null),p.state=p.stack.pop()||s.VALUE):P(p,"Invalid null started with nul"+v);continue;case s.NUMBER_DECIMAL_POINT:v===u.period?(p.numberNode+=".",p.state=s.NUMBER_DIGIT):P(p,"Leading zero not followed by .");continue;case s.NUMBER_DIGIT:u._0<=v&&v<=u._9?p.numberNode+=String.fromCharCode(v):v===u.period?(p.numberNode.indexOf(".")!==-1&&P(p,"Invalid number has two dots"),p.numberNode+="."):v===u.e||v===u.E?((p.numberNode.indexOf("e")!==-1||p.numberNode.indexOf("E")!==-1)&&P(p,"Invalid number has two exponential"),p.numberNode+="e"):v===u.plus||v===u.minus?(ie===u.e||ie===u.E||P(p,"Invalid symbol in number"),p.numberNode+=String.fromCharCode(v)):(F(p),N--,p.state=p.stack.pop()||s.VALUE);continue;default:P(p,"Unknown state: "+p.state)}return p.position>=p.bufferCheckPosition&&l(p),p}})(e)}(qn)),qn}var uc=cc(),lc=mr(uc);function fc(e){var t=0,n=dc(),r=new TextDecoder("utf-8",{fatal:!0}),i={pullAsync:function(s){return St(this,void 0,void 0,function(){var o,c,u,l;return ot(this,function(h){switch(h.label){case 0:return o=e.slice(t,t+s),t+=s,[4,Li(o)];case 1:return c=h.sent(),u=r.decode(c,{stream:t<e.size}),l=n.write(u),i.result=l||{},[2,l]}})})},pullSync:function(s){var o=e.slice(t,t+s);t+=s;var c=Bi(o),u=r.decode(c,{stream:t<e.size}),l=n.write(u);return i.result=l||{},l},done:function(){return n.done()},eof:function(){return t>=e.size},result:{}};return i}function dc(e){var t=lc.parser(),n=0,r,i=[],s,o,c=!1,u=!1;return t.onopenobject=function(l){var h={};h.incomplete=!0,r||(r=h),s&&(i.push([o,s,u]),u?s.push(h):s[o]=h),s=h,o=l,u=!1,++n},t.onkey=function(l){return o=l},t.onvalue=function(l){return u?s.push(l):s[o]=l},t.oncloseobject=function(){var l;delete s.incomplete,o=null,--n===0?c=!0:(l=i.pop(),o=l[0],s=l[1],u=l[2])},t.onopenarray=function(){var l=[];l.incomplete=!0,r||(r=l),s&&(i.push([o,s,u]),u?s.push(l):s[o]=l),s=l,u=!0,o=null,++n},t.onclosearray=function(){var l;delete s.incomplete,o=null,--n===0?c=!0:(l=i.pop(),o=l[0],s=l[1],u=l[2])},{write:function(l){return t.write(l),r},done:function(){return c}}}var Wi=1024;function hc(e,t){return St(this,void 0,void 0,function(){var n,r,i,s;return ot(this,function(o){switch(o.label){case 0:return t=t||{},n=t.chunkSizeBytes||Wi*1024,[4,Ki(e,n)];case 1:return r=o.sent(),i=r.result.data,s=new Ne(t.name!==void 0?t.name:i.databaseName),s.version(i.databaseVersion).stores(Ga(i)),[4,gr(s,r,t.name!==void 0?vn(vn({},t),{acceptNameDiff:!0}):t)];case 2:return o.sent(),[2,s]}})})}function gr(e,t,n){return St(this,void 0,void 0,function(){function r(){return St(this,void 0,void 0,function(){var k,x,L,F,O;return ot(this,function(P){switch(P.label){case 0:k=function(B){var z,J,w,p,N,v,ie,ae,fe,he,Te,Re,Me;return ot(this,function(je){switch(je.label){case 0:if(l.includes(B.tableName))return[2,"continue"];if(!B.rows)return[2,"break"];if(!B.rows.incomplete&&B.rows.length===0)return[2,"continue"];if(h&&Ne.ignoreTransaction(function(){return h(m)}),z=B.tableName,J=e.table(z),w=u.tables.filter(function(ge){return ge.name===z})[0].schema,!J){if(n.acceptMissingTables)return[2,"continue"];throw new Error("Exported table ".concat(B.tableName," is missing in installed database"))}if(!n.acceptChangedPrimaryKey&&w.split(",")[0]!=J.schema.primKey.src)throw new Error("Primary key differs for table ".concat(B.tableName,". "));for(p=B.rows,N=[],v=0;v<p.length&&(ie=p[v],!ie.incomplete);v++)N.push(Xe.revive(ie));return ae=n.filter,fe=n.transform,he=ae?B.inbound?N.filter(function(ge){return ae(z,ge)}):N.filter(function(ge){var _e=ge[0],Le=ge[1];return ae(z,Le,_e)}):N,fe&&(he=he.map(B.inbound?function(ge){return fe(z,ge).value}:function(ge){var _e=ge[0],Le=ge[1],et=fe(z,Le,_e);return[et.key,et.value]})),Te=B.inbound?[void 0,he]:[he.map(function(ge){return ge[0]}),N.map(function(ge){return ge[1]})],Re=Te[0],Me=Te[1],n.overwriteValues?[4,J.bulkPut(Me,Re)]:[3,2];case 1:return je.sent(),[3,4];case 2:return[4,J.bulkAdd(Me,Re)];case 3:je.sent(),je.label=4;case 4:return m.completedRows+=N.length,N.incomplete||(m.completedTables+=1),p.splice(0,N.length),[2]}})},x=0,L=u.data,P.label=1;case 1:return x<L.length?(F=L[x],[5,k(F)]):[3,4];case 2:if(O=P.sent(),O==="break")return[3,4];P.label=3;case 3:return x++,[3,1];case 4:for(;u.data.length>0&&u.data[0].rows&&!u.data[0].rows.incomplete;)u.data.splice(0,1);return!s.done()&&!s.eof()?c?(s.pullSync(i),[3,7]):[3,5]:[3,8];case 5:return[4,Ne.waitFor(s.pullAsync(i))];case 6:P.sent(),P.label=7;case 7:return[3,9];case 8:return[3,10];case 9:return[3,0];case 10:return[2]}})})}var i,s,o,c,u,l,h,m,b,A,_;return ot(this,function(k){switch(k.label){case 0:return n=n||{},i=n.chunkSizeBytes||Wi*1024,[4,Ki(t,i)];case 1:if(s=k.sent(),o=s.result,c="FileReaderSync"in self,u=o.data,l=n.skipTables?n.skipTables:[],!n.acceptNameDiff&&e.name!==u.databaseName)throw new Error("Name differs. Current database name is ".concat(e.name," but export is ").concat(u.databaseName));if(!n.acceptVersionDiff&&e.verno!==u.databaseVersion)throw new Error("Database version differs. Current database is in version ".concat(e.verno," but export is ").concat(u.databaseVersion));if(h=n.progressCallback,m={done:!1,completedRows:0,completedTables:0,totalRows:u.tables.reduce(function(x,L){return x+L.rowCount},0),totalTables:u.tables.length},h&&Ne.ignoreTransaction(function(){return h(m)}),!n.clearTablesBeforeImport)return[3,5];b=0,A=e.tables,k.label=2;case 2:return b<A.length?(_=A[b],l.includes(_.name)?[3,4]:[4,_.clear()]):[3,5];case 3:k.sent(),k.label=4;case 4:return b++,[3,2];case 5:return n.noTransaction?[4,r()]:[3,7];case 6:return k.sent(),[3,9];case 7:return[4,e.transaction("rw",e.tables,r)];case 8:k.sent(),k.label=9;case 9:return m.done=!0,h&&Ne.ignoreTransaction(function(){return h(m)}),[2]}})})}function Ki(e,t){return St(this,void 0,void 0,function(){var n,r;return ot(this,function(i){switch(i.label){case 0:n="slice"in e?fc(e):e,i.label=1;case 1:return n.eof()?[3,3]:[4,n.pullAsync(t)];case 2:return i.sent(),n.result.data&&n.result.data.data?[3,3]:[3,1];case 3:if(r=n.result,!r||r.formatName!="dexie")throw new Error("Given file is not a dexie export");if(r.formatVersion>oc)throw new Error("Format version ".concat(r.formatVersion," not supported"));if(!r.data)throw new Error("No data in export file");if(!r.data.databaseName)throw new Error("Missing databaseName in export file");if(!r.data.databaseVersion)throw new Error("Missing databaseVersion in export file");if(!r.data.tables)throw new Error("Missing tables in export file");return[2,n]}})})}Ne.prototype.export=function(e){return Vi(this,e)};Ne.prototype.import=function(e,t){return gr(this,e,t)};Ne.import=function(e,t){return hc(e,t)};const pc=Date.now(),yc=30*1e3;async function mc(e){return e||(e=await In()),e?await e.queryPermission({mode:"readwrite"})==="granted":!1}async function bl(){const e=await In();return e&&await e.requestPermission({mode:"readwrite"})==="granted"?(await Bt(jt.DirectoryAccessible),!0):!1}async function vl(){let e;try{e=await window.showDirectoryPicker({mode:"readwrite"})}catch(t){if(t instanceof DOMException&&t.name==="AbortError")return;throw t}re.info("Set Backup Directory: ",e),await La(e)}async function gc(){const e=Pe.now(),t=await In();try{if(t==null)throw new Error("No backup directory selected");const n=await t.getFileHandle(`tabvana-${e}.json`,{create:!0}),r=await Vi(S,{prettyJson:!0}),i=await n.createWritable();await i.write(r),await i.close(),await Ba(e),await Fa(r.size)}catch(n){re.error("Backup failed:",n)}}let Jn=!1;async function wc(){if(Jn){re.info("Backup already in progress, skipping...");return}Jn=!0;const e="backup-task";let t=!1;try{if(await Ue(e,"background","backup",0,3),await Bt(jt.BackupInProgress),!await mc()){await Bt(jt.DirectoryNotAccessible);return}await Ue(e,"background","backup",1,3),await gc(),await Ue(e,"background","backup",2,3);const n=await In();if(n==null)throw new Error("No backup directory selected");const r=[];for await(const c of n.values())r.push(c);const i=[];for await(const c of n.values())c.kind=="file"&&i.push(c.getFile().then(u=>[u.lastModified,u]));const s=await Promise.all(i);s.sort((c,u)=>c[0]-u[0]);const o=s.slice(0,s.length-50);for(const c of o)n.removeEntry&&await n.removeEntry(c[1].name);await Bt(jt.DirectoryAccessible),await Ue(e,"background","backup",3,3),t=!0}catch(n){re.error("[Backup] backupAndThin failed:",n),await Bt(jt.DirectoryNotAccessible)}finally{Jn=!1,await Ct(e,t)}}async function bc(e=!1){if(!e&&Date.now()-pc<yc)return;const t=await Mi(),n=await zi();!e&&n==null||(e||t==null||Pe.now()-t>n*1e3)&&await wc()}const vc=Pe.debounce(()=>bc(!1),5e3);async function Sl(){let e;try{e=await window.showOpenFilePicker()}catch(r){if(r instanceof DOMException&&r.name==="AbortError")return;throw r}const n=await e[0].getFile();await gr(S,n,{clearTablesBeforeImport:!0})}Xi()==="[SW]"&&Ne.on("storagemutated",vc);export{Cu as $,iu as A,fa as B,Lc as C,Fc as D,Bc as E,gu as F,mu as G,qo as H,zc as I,ki as J,Ii as K,Vo as L,Du as M,pu as N,ru as O,Xc as P,Vu as Q,$u as R,ft as S,Wu as T,kc as U,Ic as V,Uc as W,ku as X,Dc as Y,Mc as Z,Nu as _,Ht as a,yl as a$,xu as a0,zu as a1,Pu as a2,Va as a3,Ka as a4,Ze as a5,Pa as a6,Iu as a7,pl as a8,Ta as a9,au as aA,Ku as aB,bl as aC,bc as aD,vl as aE,Uu as aF,Yc as aG,cu as aH,su as aI,ol as aJ,wl as aK,Qc as aL,xc as aM,Mo as aN,Lu as aO,Bu as aP,Nc as aQ,Wo as aR,Ru as aS,eu as aT,_u as aU,Tu as aV,Eu as aW,_a as aX,Zc as aY,ml as aZ,Ec as a_,Fu as aa,Mu as ab,vu as ac,Kc as ad,qc as ae,ju as af,Rc as ag,wu as ah,Ri as ai,jc as aj,Jc as ak,Da as al,sl as am,fl as an,dt as ao,Ou as ap,Au as aq,Cc as ar,nu as as,$c as at,Wc as au,tu as av,bu as aw,Pc as ax,Su as ay,ou as az,Oc as b,gl as b0,al as b1,jt as b2,Sl as b3,zi as b4,ul as b5,Mi as b6,ll as b7,In as b8,cl as b9,$a as ba,Wa as bb,hu as bc,ji as bd,ba as be,uu as bf,wa as bg,fu as bh,lu as bi,Ct as bj,Ue as bk,du as bl,hl as bm,dl as bn,ho as c,Ac as d,qu as e,Vc as f,Gu as g,Ju as h,Hu as i,Xu as j,Zu as k,nl as l,Yu as m,Gc as n,rl as o,il as p,ct as q,Qu as r,Nt as s,$o as t,Fo as u,On as v,ja as w,Hc as x,yu as y,el as z};
//# sourceMappingURL=chunk-gAtUpT02.js.map
