@banou/ripple 0.0.3 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,26 +0,0 @@
1
- import{R as Ds}from"./index-9a320571.js";let vn,Hp,Pe,fx,tp,ad,ot,yx,Ih,mx,vx,Ps,Uc,Dt,Ct,pt,hx,Qp,Le,Xe,nx,pn,ui,R1,Fh,gx,dx,kh,px,mn,cx;let __tla=(async()=>{function Hh(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(n,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var Wh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};Ps=function Ps(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e};var Dc={exports:{}},U={};var hn=Symbol.for("react.element"),Qh=Symbol.for("react.portal"),zh=Symbol.for("react.fragment"),Gh=Symbol.for("react.strict_mode"),Vh=Symbol.for("react.profiler"),Jh=Symbol.for("react.provider"),Yh=Symbol.for("react.context"),Xh=Symbol.for("react.forward_ref"),Zh=Symbol.for("react.suspense"),ed=Symbol.for("react.memo"),td=Symbol.for("react.lazy"),$a=Symbol.iterator;function rd(e){return e===null||typeof e!="object"?null:(e=$a&&e[$a]||e["@@iterator"],typeof e=="function"?e:null)}var Pc={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ic=Object.assign,Rc={};function Tr(e,t,r){this.props=e,this.context=t,this.refs=Rc,this.updater=r||Pc}Tr.prototype.isReactComponent={};Tr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Tr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function kc(){}kc.prototype=Tr.prototype;function Is(e,t,r){this.props=e,this.context=t,this.refs=Rc,this.updater=r||Pc}var Rs=Is.prototype=new kc;Rs.constructor=Is;Ic(Rs,Tr.prototype);Rs.isPureReactComponent=!0;var Ba=Array.isArray,Tc=Object.prototype.hasOwnProperty,ks={current:null},$c={key:!0,ref:!0,__self:!0,__source:!0};function Bc(e,t,r){var n,i={},o=null,s=null;if(t!=null)for(n in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(o=""+t.key),t)Tc.call(t,n)&&!$c.hasOwnProperty(n)&&(i[n]=t[n]);var a=arguments.length-2;if(a===1)i.children=r;else if(1<a){for(var u=Array(a),c=0;c<a;c++)u[c]=arguments[c+2];i.children=u}if(e&&e.defaultProps)for(n in a=e.defaultProps,a)i[n]===void 0&&(i[n]=a[n]);return{$$typeof:hn,type:e,key:o,ref:s,props:i,_owner:ks.current}}function nd(e,t){return{$$typeof:hn,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Ts(e){return typeof e=="object"&&e!==null&&e.$$typeof===hn}function id(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(r){return t[r]})}var Ma=/\/+/g;function Vi(e,t){return typeof e=="object"&&e!==null&&e.key!=null?id(""+e.key):t.toString(36)}function Wn(e,t,r,n,i){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var s=!1;if(e===null)s=!0;else switch(o){case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case hn:case Qh:s=!0}}if(s)return s=e,i=i(s),e=n===""?"."+Vi(s,0):n,Ba(i)?(r="",e!=null&&(r=e.replace(Ma,"$&/")+"/"),Wn(i,t,r,"",function(c){return c})):i!=null&&(Ts(i)&&(i=nd(i,r+(!i.key||s&&s.key===i.key?"":(""+i.key).replace(Ma,"$&/")+"/")+e)),t.push(i)),1;if(s=0,n=n===""?".":n+":",Ba(e))for(var a=0;a<e.length;a++){o=e[a];var u=n+Vi(o,a);s+=Wn(o,t,r,u,i)}else if(u=rd(e),typeof u=="function")for(e=u.call(e),a=0;!(o=e.next()).done;)o=o.value,u=n+Vi(o,a++),s+=Wn(o,t,r,u,i);else if(o==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return s}function $n(e,t,r){if(e==null)return e;var n=[],i=0;return Wn(e,n,"","",function(o){return t.call(r,o,i++)}),n}function od(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(r){(e._status===0||e._status===-1)&&(e._status=1,e._result=r)},function(r){(e._status===0||e._status===-1)&&(e._status=2,e._result=r)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Ae={current:null},Qn={transition:null},sd={ReactCurrentDispatcher:Ae,ReactCurrentBatchConfig:Qn,ReactCurrentOwner:ks};U.Children={map:$n,forEach:function(e,t,r){$n(e,function(){t.apply(this,arguments)},r)},count:function(e){var t=0;return $n(e,function(){t++}),t},toArray:function(e){return $n(e,function(t){return t})||[]},only:function(e){if(!Ts(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};U.Component=Tr;U.Fragment=zh;U.Profiler=Vh;U.PureComponent=Is;U.StrictMode=Gh;U.Suspense=Zh;U.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=sd;U.cloneElement=function(e,t,r){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var n=Ic({},e.props),i=e.key,o=e.ref,s=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,s=ks.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(u in t)Tc.call(t,u)&&!$c.hasOwnProperty(u)&&(n[u]=t[u]===void 0&&a!==void 0?a[u]:t[u])}var u=arguments.length-2;if(u===1)n.children=r;else if(1<u){a=Array(u);for(var c=0;c<u;c++)a[c]=arguments[c+2];n.children=a}return{$$typeof:hn,type:e.type,key:i,ref:o,props:n,_owner:s}};U.createContext=function(e){return e={$$typeof:Yh,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Jh,_context:e},e.Consumer=e};U.createElement=Bc;U.createFactory=function(e){var t=Bc.bind(null,e);return t.type=e,t};U.createRef=function(){return{current:null}};U.forwardRef=function(e){return{$$typeof:Xh,render:e}};U.isValidElement=Ts;U.lazy=function(e){return{$$typeof:td,_payload:{_status:-1,_result:e},_init:od}};U.memo=function(e,t){return{$$typeof:ed,type:e,compare:t===void 0?null:t}};U.startTransition=function(e){var t=Qn.transition;Qn.transition={};try{e()}finally{Qn.transition=t}};U.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")};U.useCallback=function(e,t){return Ae.current.useCallback(e,t)};U.useContext=function(e){return Ae.current.useContext(e)};U.useDebugValue=function(){};U.useDeferredValue=function(e){return Ae.current.useDeferredValue(e)};U.useEffect=function(e,t){return Ae.current.useEffect(e,t)};U.useId=function(){return Ae.current.useId()};U.useImperativeHandle=function(e,t,r){return Ae.current.useImperativeHandle(e,t,r)};U.useInsertionEffect=function(e,t){return Ae.current.useInsertionEffect(e,t)};U.useLayoutEffect=function(e,t){return Ae.current.useLayoutEffect(e,t)};U.useMemo=function(e,t){return Ae.current.useMemo(e,t)};U.useReducer=function(e,t,r){return Ae.current.useReducer(e,t,r)};U.useRef=function(e){return Ae.current.useRef(e)};U.useState=function(e){return Ae.current.useState(e)};U.useSyncExternalStore=function(e,t,r){return Ae.current.useSyncExternalStore(e,t,r)};U.useTransition=function(){return Ae.current.useTransition()};U.version="18.2.0";Dc.exports=U;ui=Dc.exports;ad=Ps(ui);fx=Hh({__proto__:null,default:ad},[ui]);function en(e){"@babel/helpers - typeof";return en=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},en(e)}function ud(e,t){if(en(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(en(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function cd(e){var t=ud(e,"string");return en(t)==="symbol"?t:String(t)}function La(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,cd(n.key),n)}}function $r(e,t,r){return t&&La(e.prototype,t),r&&La(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function ld(e){return e[e.length-1]}function $s(e){return Array.isArray(e)?e.slice(0):[e]}function yr(e){return Array.isArray(e)}function fd(e){return e!=null}function Ji(e,t){var r=0,n=-1;for(var i of e){n=n+1;var o=t(i,n);if(o)r=r+1;else break}return r}function Ri(e,t){for(var r=t.length,n=0;n<r;++n){var i=t[n];e.push(i)}}function hd(e){for(var t="",r=new Uint8Array(e),n=r.byteLength,i=0;i<n;i++)t+=String.fromCharCode(r[i]);return btoa(t)}async function dd(e,t){var r=await fetch("data:"+t+";base64,"+e),n=await r.blob();return n}function pd(e){var t=Object.prototype.toString.call(e);return t==="[object Uint8Array]"&&(e=new Blob([e])),typeof e=="string"?Promise.resolve(e):e.text()}async function yd(e){if(typeof e=="string")return e;var t=Object.prototype.toString.call(e);t==="[object Uint8Array]"&&(e=new Blob([e]));var r=URL.createObjectURL(e),n=await fetch(r).then(i=>i.arrayBuffer());return hd(n)}function md(e){return e.size}function ko(e){var t=e.split("-");if(t.length!==2)throw new Error("malformatted revision: "+e);return{height:parseInt(t[0],10),hash:t[1]}}function vd(e){var t=parseInt(e.split("-")[0],10);return t}function ci(e,t){var r=t?t._rev:null,n=r?ko(r).height:0,i=n+1;return i+"-"+e}var Bs=1;function dn(){return{lwt:Bs}}function ki(){return""}function gd(e){return Object.assign({},e,{_meta:void 0,_deleted:void 0,_rev:void 0})}function bd(e,t,r){if(t.length!==r.length)return!1;for(var n=0,i=t.length;n<i;){var o=t[n],s=r[n];if(n++,o._rev!==s._rev||o[e]!==s[e])return!1}return!0}function wd(e){return(t,r)=>t._meta.lwt===r._meta.lwt?r[e]<t[e]?1:-1:t._meta.lwt-r._meta.lwt}function _d(e,t){return t.sort(wd(e))}class At{constructor(t,r){t=this.words=t||[],this.sigBytes=r===void 0?t.length*4:r}toString(t){return(t||xd).stringify(this)}concat(t){if(this.clamp(),this.sigBytes%4)for(let r=0;r<t.sigBytes;r++){const n=t.words[r>>>2]>>>24-r%4*8&255;this.words[this.sigBytes+r>>>2]|=n<<24-(this.sigBytes+r)%4*8}else for(let r=0;r<t.sigBytes;r+=4)this.words[this.sigBytes+r>>>2]=t.words[r>>>2];return this.sigBytes+=t.sigBytes,this}clamp(){this.words[this.sigBytes>>>2]&=4294967295<<32-this.sigBytes%4*8,this.words.length=Math.ceil(this.sigBytes/4)}clone(){return new At([...this.words])}}const xd={stringify(e){const t=[];for(let r=0;r<e.sigBytes;r++){const n=e.words[r>>>2]>>>24-r%4*8&255;t.push((n>>>4).toString(16),(n&15).toString(16))}return t.join("")}},Ed={parse(e){const t=e.length,r=[];for(let n=0;n<t;n++)r[n>>>2]|=(e.charCodeAt(n)&255)<<24-n%4*8;return new At(r,t)}},Sd={parse(e){return Ed.parse(unescape(encodeURIComponent(e)))}};class Od{constructor(){this._data=new At,this._nDataBytes=0,this._minBufferSize=0,this.blockSize=512/32}reset(){this._data=new At,this._nDataBytes=0}_append(t){typeof t=="string"&&(t=Sd.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes}_doProcessBlock(t,r){}_process(t){let r,n=this._data.sigBytes/(this.blockSize*4);t?n=Math.ceil(n):n=Math.max((n|0)-this._minBufferSize,0);const i=n*this.blockSize,o=Math.min(i*4,this._data.sigBytes);if(i){for(let s=0;s<i;s+=this.blockSize)this._doProcessBlock(this._data.words,s);r=this._data.words.splice(0,i),this._data.sigBytes-=o}return new At(r,o)}}class Ad extends Od{update(t){return this._append(t),this._process(),this}finalize(t){t&&this._append(t)}}const Fa=[1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225],Cd=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],$t=[];class Dd extends Ad{constructor(){super(...arguments),this._hash=new At([...Fa])}reset(){super.reset(),this._hash=new At([...Fa])}_doProcessBlock(t,r){const n=this._hash.words;let i=n[0],o=n[1],s=n[2],a=n[3],u=n[4],c=n[5],l=n[6],h=n[7];for(let p=0;p<64;p++){if(p<16)$t[p]=t[r+p]|0;else{const A=$t[p-15],R=(A<<25|A>>>7)^(A<<14|A>>>18)^A>>>3,O=$t[p-2],C=(O<<15|O>>>17)^(O<<13|O>>>19)^O>>>10;$t[p]=R+$t[p-7]+C+$t[p-16]}const y=u&c^~u&l,b=i&o^i&s^o&s,g=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),E=(u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25),w=h+E+y+Cd[p]+$t[p],_=g+b;h=l,l=c,c=u,u=a+w|0,a=s,s=o,o=i,i=w+_|0}n[0]=n[0]+i|0,n[1]=n[1]+o|0,n[2]=n[2]+s|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+h|0}finalize(t){super.finalize(t);const r=this._nDataBytes*8,n=this._data.sigBytes*8;return this._data.words[n>>>5]|=128<<24-n%32,this._data.words[(n+64>>>9<<4)+14]=Math.floor(r/4294967296),this._data.words[(n+64>>>9<<4)+15]=r,this._data.sigBytes=this._data.words.length*4,this._process(),this._hash}}function Pd(e){return new Dd().finalize(e).toString()}function Wr(e){return Pd(e)}function Id(){return new Promise(e=>setTimeout(e,0))}function Rd(e=0){return new Promise(t=>setTimeout(t,e))}function kd(e){return e&&typeof e.then=="function"?e:Promise.resolve(e)}var Td=Promise.resolve(!0),Fe=Promise.resolve(!1),Ms=Promise.resolve(null),ke=Promise.resolve(),Yi=ke;function $d(e=void 0){return Yi=Yi.then(()=>typeof requestIdleCallback=="function"?new Promise(t=>{requestIdleCallback(()=>t(),{timeout:e})}):Rd(0)),Yi}function Bd(e,t){return e.reduce((r,n)=>r.then(n),Promise.resolve(t))}function Ti(e=10){for(var t="",r="abcdefghijklmnopqrstuvwxyz",n=0;n<e;n++)t+=r.charAt(Math.floor(Math.random()*r.length));return t}function Mc(e){e+="";var t=e.charAt(0).toUpperCase();return t+e.substr(1)}function tn(e){for(;e.charAt(0)===".";)e=e.substr(1);for(;e.slice(-1)===".";)e=e.slice(0,-1);return e}function Lc(e){return!!(e.includes("/")||e.includes("\\"))}function Or(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var r,n;if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;n--!==0;)if(!Or(e[n],t[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();var i=Object.keys(e);if(r=i.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[n]))return!1;for(n=r;n--!==0;){var o=i[n];if(!Or(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}var Md=e=>{var t=typeof e;return e!==null&&(t==="object"||t==="function")},Xi=new Set(["__proto__","prototype","constructor"]),Ld=new Set("0123456789");function Fd(e){var t=[],r="",n="start",i=!1;for(var o of e)switch(o){case"\\":{if(n==="index")throw new Error("Invalid character in an index");if(n==="indexEnd")throw new Error("Invalid character after an index");i&&(r+=o),n="property",i=!i;break}case".":{if(n==="index")throw new Error("Invalid character in an index");if(n==="indexEnd"){n="property";break}if(i){i=!1,r+=o;break}if(Xi.has(r))return[];t.push(r),r="",n="property";break}case"[":{if(n==="index")throw new Error("Invalid character in an index");if(n==="indexEnd"){n="index";break}if(i){i=!1,r+=o;break}if(n==="property"){if(Xi.has(r))return[];t.push(r),r=""}n="index";break}case"]":{if(n==="index"){t.push(Number.parseInt(r,10)),r="",n="indexEnd";break}if(n==="indexEnd")throw new Error("Invalid character after an index")}default:{if(n==="index"&&!Ld.has(o))throw new Error("Invalid character in an index");if(n==="indexEnd")throw new Error("Invalid character after an index");n==="start"&&(n="property"),i&&(i=!1,r+="\\"),r+=o}}switch(i&&(r+="\\"),n){case"property":{if(Xi.has(r))return[];t.push(r);break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}function Nd(e,t){if(typeof t!="number"&&Array.isArray(e)){var r=Number.parseInt(t,10);return Number.isInteger(r)&&e[r]===e[t]}return!1}function St(e,t,r){if(Array.isArray(t)&&(t=t.join(".")),!Md(e)||typeof t!="string")return r===void 0?e:r;var n=Fd(t);if(n.length===0)return r;for(var i=0;i<n.length;i++){var o=n[i];if(Nd(e,o)?e=i===n.length-1?void 0:null:e=e[o],e==null){if(i!==n.length-1)return r;break}}return e===void 0?r:e}function Fc(e){return Object.freeze(e),Object.getOwnPropertyNames(e).forEach(function(t){e.hasOwnProperty(t)&&e[t]!==null&&(typeof e[t]=="object"||typeof e[t]=="function")&&!Object.isFrozen(e[t])&&Fc(e[t])}),e}function jd(e){var t=e.split("."),r=t.length;return r===1?n=>n[e]:n=>{for(var i=n,o=0;o<r;++o){var s=t[o];if(i=i[s],typeof i>"u")return i}return i}}function Na(e,t){var r=e[t];if(!r)throw new Error("missing value from object "+t);return r}function To(e){var t={};for(var r in e)if(e.hasOwnProperty(r))if(typeof e[r]=="object"){var n=To(e[r]);for(var i in n)n.hasOwnProperty(i)&&(t[r+"."+i]=n[i])}else t[r]=e[r];return t}function Z(e){return Object.assign({},e)}function Ud(e){return Object.keys(e)[0]}function li(e,t=!1){if(!e)return e;if(!t&&Array.isArray(e))return e.sort((n,i)=>typeof n=="string"&&typeof i=="string"?n.localeCompare(i):typeof n=="object"?1:-1).map(n=>li(n,t));if(typeof e=="object"&&!Array.isArray(e)){if(e instanceof RegExp)return e;var r={};return Object.keys(e).sort((n,i)=>n.localeCompare(i)).forEach(n=>{r[n]=li(e[n],t)}),r}return e}function $o(e){if(!e||e===null||typeof e!="object")return e;if(Array.isArray(e)){for(var t=new Array(e.length),r=t.length;r--;)t[r]=$o(e[r]);return t}var n={};for(var i in e)n[i]=$o(e[i]);return n}var at=$o;function zn(e,t,r){return Object.defineProperty(e,t,{get:function(){return r}}),r}function Kd(e,t){return t instanceof RegExp?t.toString():t}function rn(e,t){var r=e.get(t);if(typeof r>"u")throw new Error("missing value from map "+t);return r}function Je(e,t,r,n){var i=e.get(t);return typeof i>"u"?(i=r(),e.set(t,i)):n&&n(i),i}function re(e){var t=e.split("-"),r="RxDB";return t.forEach(n=>{r+=Mc(n)}),r+="Plugin",new Error(`You are using a function which must be overwritten by a plugin.
2
- You should either prevent the usage of this function or add the plugin via:
3
- import { `+r+" } from 'rxdb/plugins/"+e+`';
4
- addRxPlugin(`+r+`);
5
- `)}var Zi=0;function be(){var e=(new Date).getTime();e=e+.01,e<=Zi&&(e=Zi+.01);var t=parseFloat(e.toFixed(2));return Zi=t,t}function se(e){if(!e)throw new Error("ensureNotFalsy() is falsy");return e}var Ls={bufferSize:1,refCount:!0},qd=/\./g,Hd=/(\/?)(.+)\1([a-z]*)/i;function Wd(e){var t=se(e.toString().match(Hd));return{pattern:t[2],flags:t[3]}}function nn(e,t){return nn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},nn(e,t)}function Nc(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,nn(e,t)}function Bo(e){return Bo=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Bo(e)}function Qd(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function zd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Gn(e,t,r){return zd()?Gn=Reflect.construct.bind():Gn=function(i,o,s){var a=[null];a.push.apply(a,o);var u=Function.bind.apply(i,a),c=new u;return s&&nn(c,s.prototype),c},Gn.apply(null,arguments)}function fi(e){var t=typeof Map=="function"?new Map:void 0;return fi=function(n){if(n===null||!Qd(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return Gn(n,arguments,Bo(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),nn(i,n)},fi(e)}var ce={isDevMode(){return!1},deepFreezeWhenDevMode(e){return e},tunnelErrorMessage(e){return"RxDB Error-Code "+e+`.
6
- Error messages are not included in RxDB core to reduce build size.
7
- - To find out what this error means, either use the dev-mode-plugin https://rxdb.info/dev-mode.html
8
- - or search for the error code here: https://github.com/pubkey/rxdb/search?q=`+e+`
9
- `}};function Gd(e){var t="";return Object.keys(e).length===0||(t+=`Given parameters: {
10
- `,t+=Object.keys(e).map(r=>{var n="[object Object]";try{r==="errors"?n=e[r].map(i=>JSON.stringify(i,Object.getOwnPropertyNames(i))):n=JSON.stringify(e[r],function(i,o){return o===void 0?null:o},2)}catch{}return r+":"+n}).join(`
11
- `),t+="}"),t}function jc(e,t,r){return"RxError ("+t+`):
12
- `+e+`
13
- `+Gd(r)}var Vd=function(e){Nc(t,e);function t(n,i,o={}){var s,a=jc(i,n,o);return s=e.call(this,a)||this,s.code=n,s.message=a,s.parameters=o,s.rxdb=!0,s}var r=t.prototype;return r.toString=function(){return this.message},$r(t,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),t}(fi(Error)),Jd=function(e){Nc(t,e);function t(n,i,o={}){var s,a=jc(i,n,o);return s=e.call(this,a)||this,s.code=n,s.message=a,s.parameters=o,s.rxdb=!0,s}var r=t.prototype;return r.toString=function(){return this.message},$r(t,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),t}(fi(TypeError));function D(e,t){return new Vd(e,ce.tunnelErrorMessage(e),t)}function ue(e,t){return new Jd(e,ce.tunnelErrorMessage(e),t)}function Yd(e){return e&&e.status===409?e:!1}var Xd={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};function Zd(e){return D("COL20",{name:Xd[e.status],document:e.documentId,writeError:e})}var on={preAddRxPlugin:[],preCreateRxDatabase:[],createRxDatabase:[],preCreateRxCollection:[],createRxCollection:[],postDestroyRxCollection:[],postRemoveRxCollection:[],preCreateRxSchema:[],createRxSchema:[],preCreateRxQuery:[],prePrepareQuery:[],createRxDocument:[],postCreateRxDocument:[],preCreateRxStorageInstance:[],preMigrateDocument:[],postMigrateDocument:[],preDestroyRxDatabase:[],postRemoveRxDatabase:[],preReplicationMasterWrite:[],preReplicationMasterWriteDocumentsHandle:[]};function Be(e,t){on[e]&&on[e].forEach(r=>r(t))}function Gt(e,t){return Promise.all(on[e].map(r=>r(t)))}function le(e){return typeof e=="function"}function ep(e){return le(e?.lift)}Xe=function Xe(e){return function(t){if(ep(t))return t.lift(function(r){try{return e(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}};var Mo=function(e,t){return Mo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},Mo(e,t)};function rr(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Mo(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}tp=function tp(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(h){s(h)}}function u(l){try{c(n.throw(l))}catch(h){s(h)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(e,t||[])).next())})};Uc=function Uc(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(l){return u([c,l])}}function u(c){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(r=0)),r;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,i=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){r.label=c[1];break}if(c[0]===6&&r.label<o[1]){r.label=o[1],o=c;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(c);break}o[2]&&r.ops.pop(),r.trys.pop();continue}c=t.call(e,r)}catch(l){c=[6,l],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}};function Ar(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}Ct=function Ct(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o};Dt=function Dt(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))};function mr(e){return this instanceof mr?(this.v=e,this):new mr(e)}function rp(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(p){n[p]&&(i[p]=function(y){return new Promise(function(b,g){o.push([p,y,b,g])>1||a(p,y)})})}function a(p,y){try{u(n[p](y))}catch(b){h(o[0][3],b)}}function u(p){p.value instanceof mr?Promise.resolve(p.value.v).then(c,l):h(o[0][2],p)}function c(p){a("next",p)}function l(p){a("throw",p)}function h(p,y){p(y),o.shift(),o.length&&a(o[0][0],o[0][1])}}function np(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof Ar=="function"?Ar(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=e[o]&&function(s){return new Promise(function(a,u){s=e[o](s),i(a,u,s.done,s.value)})}}function i(o,s,a,u){Promise.resolve(u).then(function(c){o({value:c,done:a})},s)}}var Kc=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function qc(e){return le(e?.then)}function Fs(e){var t=function(n){Error.call(n),n.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var eo=Fs(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
14
- `+r.map(function(n,i){return i+1+") "+n.toString()}).join(`
15
- `):"",this.name="UnsubscriptionError",this.errors=r}});function Lo(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var $i=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,i,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=Ar(s),u=a.next();!u.done;u=a.next()){var c=u.value;c.remove(this)}}catch(g){t={error:g}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}else s.remove(this);var l=this.initialTeardown;if(le(l))try{l()}catch(g){o=g instanceof eo?g.errors:[g]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var p=Ar(h),y=p.next();!y.done;y=p.next()){var b=y.value;try{ja(b)}catch(g){o=o??[],g instanceof eo?o=Dt(Dt([],Ct(o)),Ct(g.errors)):o.push(g)}}}catch(g){n={error:g}}finally{try{y&&!y.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}}if(o)throw new eo(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)ja(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&Lo(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&Lo(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Hc=$i.EMPTY;function Wc(e){return e instanceof $i||e&&"closed"in e&&le(e.remove)&&le(e.add)&&le(e.unsubscribe)}function ja(e){le(e)?e():e.unsubscribe()}var Qc={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Fo={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=Fo.delegate;return i?.setTimeout?i.setTimeout.apply(i,Dt([e,t],Ct(r))):setTimeout.apply(void 0,Dt([e,t],Ct(r)))},clearTimeout:function(e){var t=Fo.delegate;return(t?.clearTimeout||clearTimeout)(e)},delegate:void 0};function zc(e){Fo.setTimeout(function(){throw e})}function Ua(){}function Vn(e){e()}var Ns=function(e){rr(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,Wc(r)&&r.add(n)):n.destination=ap,n}return t.create=function(r,n,i){return new Cr(r,n,i)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}($i),ip=Function.prototype.bind;function to(e,t){return ip.call(e,t)}var op=function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){Bn(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){Bn(n)}else Bn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){Bn(r)}},e}(),Cr=function(e){rr(t,e);function t(r,n,i){var o=e.call(this)||this,s;if(le(r)||!r)s={next:r??void 0,error:n??void 0,complete:i??void 0};else{var a;o&&Qc.useDeprecatedNextContext?(a=Object.create(r),a.unsubscribe=function(){return o.unsubscribe()},s={next:r.next&&to(r.next,a),error:r.error&&to(r.error,a),complete:r.complete&&to(r.complete,a)}):s=r}return o.destination=new op(s),o}return t}(Ns);function Bn(e){zc(e)}function sp(e){throw e}var ap={closed:!0,next:Ua,error:sp,complete:Ua},js=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();pn=function pn(e){return e};function up(e){return e.length===0?pn:e.length===1?e[0]:function(r){return e.reduce(function(n,i){return i(n)},r)}}Pe=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var i=this,o=lp(t)?t:new Cr(t,r,n);return Vn(function(){var s=i,a=s.operator,u=s.source;o.add(a?a.call(o,u):u?i._subscribe(o):i._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=Ka(r),new r(function(i,o){var s=new Cr({next:function(a){try{t(a)}catch(u){o(u),s.unsubscribe()}},error:o,complete:i});n.subscribe(s)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[js]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return up(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=Ka(t),new t(function(n,i){var o;r.subscribe(function(s){return o=s},function(s){return i(s)},function(){return n(o)})})},e.create=function(t){return new e(t)},e}();function Ka(e){var t;return(t=e??Qc.Promise)!==null&&t!==void 0?t:Promise}function cp(e){return e&&le(e.next)&&le(e.error)&&le(e.complete)}function lp(e){return e&&e instanceof Ns||cp(e)&&Wc(e)}function Gc(e){return le(e[js])}function Vc(e){return Symbol.asyncIterator&&le(e?.[Symbol.asyncIterator])}function Jc(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function fp(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Yc=fp();function Xc(e){return le(e?.[Yc])}function Zc(e){return rp(this,arguments,function(){var r,n,i,o;return Uc(this,function(s){switch(s.label){case 0:r=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,mr(r.read())];case 3:return n=s.sent(),i=n.value,o=n.done,o?[4,mr(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,mr(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function el(e){return le(e?.getReader)}function bt(e){if(e instanceof Pe)return e;if(e!=null){if(Gc(e))return hp(e);if(Kc(e))return dp(e);if(qc(e))return pp(e);if(Vc(e))return tl(e);if(Xc(e))return yp(e);if(el(e))return mp(e)}throw Jc(e)}function hp(e){return new Pe(function(t){var r=e[js]();if(le(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function dp(e){return new Pe(function(t){for(var r=0;r<e.length&&!t.closed;r++)t.next(e[r]);t.complete()})}function pp(e){return new Pe(function(t){e.then(function(r){t.closed||(t.next(r),t.complete())},function(r){return t.error(r)}).then(null,zc)})}function yp(e){return new Pe(function(t){var r,n;try{for(var i=Ar(e),o=i.next();!o.done;o=i.next()){var s=o.value;if(t.next(s),t.closed)return}}catch(a){r={error:a}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}t.complete()})}function tl(e){return new Pe(function(t){vp(e,t).catch(function(r){return t.error(r)})})}function mp(e){return tl(Zc(e))}function vp(e,t){var r,n,i,o;return tp(this,void 0,void 0,function(){var s,a;return Uc(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),r=np(e),u.label=1;case 1:return[4,r.next()];case 2:if(n=u.sent(),!!n.done)return[3,4];if(s=n.value,t.next(s),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=u.sent(),i={error:a},[3,11];case 6:return u.trys.push([6,,9,10]),n&&!n.done&&(o=r.return)?[4,o.call(r)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}pt=function pt(e,t,r,n,i){return new gp(e,t,r,n,i)};var gp=function(e){rr(t,e);function t(r,n,i,o,s,a){var u=e.call(this,r)||this;return u.onFinalize=s,u.shouldUnsubscribe=a,u._next=n?function(c){try{n(c)}catch(l){r.error(l)}}:e.prototype._next,u._error=o?function(c){try{o(c)}catch(l){r.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=i?function(){try{i()}catch(c){r.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},t}(Ns),rl={now:function(){return(rl.delegate||Date).now()},delegate:void 0};function bp(e){return e&&le(e.schedule)}function Us(e){return e[e.length-1]}function wp(e){return le(Us(e))?e.pop():void 0}function yn(e){return bp(Us(e))?e.pop():void 0}function nl(e,t){return typeof Us(e)=="number"?e.pop():t}function ut(e,t,r,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var o=t.schedule(function(){r(),i?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(o),!i)return o}var _p=Array.isArray,xp=Object.getPrototypeOf,Ep=Object.prototype,Sp=Object.keys;function Op(e){if(e.length===1){var t=e[0];if(_p(t))return{args:t,keys:null};if(Ap(t)){var r=Sp(t);return{args:r.map(function(n){return t[n]}),keys:r}}}return{args:e,keys:null}}function Ap(e){return e&&typeof e=="object"&&xp(e)===Ep}function il(e,t){return t===void 0&&(t=0),Xe(function(r,n){r.subscribe(pt(n,function(i){return ut(n,e,function(){return n.next(i)},t)},function(){return ut(n,e,function(){return n.complete()},t)},function(i){return ut(n,e,function(){return n.error(i)},t)}))})}function ol(e,t){return t===void 0&&(t=0),Xe(function(r,n){n.add(e.schedule(function(){return r.subscribe(n)},t))})}function Cp(e,t){return bt(e).pipe(ol(t),il(t))}function Dp(e,t){return bt(e).pipe(ol(t),il(t))}function Pp(e,t){return new Pe(function(r){var n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())})})}function Ip(e,t){return new Pe(function(r){var n;return ut(r,t,function(){n=e[Yc](),ut(r,t,function(){var i,o,s;try{i=n.next(),o=i.value,s=i.done}catch(a){r.error(a);return}s?r.complete():r.next(o)},0,!0)}),function(){return le(n?.return)&&n.return()}})}function sl(e,t){if(!e)throw new Error("Iterable cannot be null");return new Pe(function(r){ut(r,t,function(){var n=e[Symbol.asyncIterator]();ut(r,t,function(){n.next().then(function(i){i.done?r.complete():r.next(i.value)})},0,!0)})})}function Rp(e,t){return sl(Zc(e),t)}function kp(e,t){if(e!=null){if(Gc(e))return Cp(e,t);if(Kc(e))return Pp(e,t);if(qc(e))return Dp(e,t);if(Vc(e))return sl(e,t);if(Xc(e))return Ip(e,t);if(el(e))return Rp(e,t)}throw Jc(e)}mn=function mn(e,t){return t?kp(e,t):bt(e)};function Te(e,t){return Xe(function(r,n){var i=0;r.subscribe(pt(n,function(o){n.next(e.call(t,o,i++))}))})}var Tp=Array.isArray;function $p(e,t){return Tp(t)?e.apply(void 0,Dt([],Ct(t))):e(t)}function Bp(e){return Te(function(t){return $p(e,t)})}function Mp(e,t){return e.reduce(function(r,n,i){return r[n]=t[i],r},{})}function Lp(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=yn(e),n=wp(e),i=Op(e),o=i.args,s=i.keys;if(o.length===0)return mn([],r);var a=new Pe(Fp(o,r,s?function(u){return Mp(s,u)}:pn));return n?a.pipe(Bp(n)):a}function Fp(e,t,r){return r===void 0&&(r=pn),function(n){qa(t,function(){for(var i=e.length,o=new Array(i),s=i,a=i,u=function(l){qa(t,function(){var h=mn(e[l],t),p=!1;h.subscribe(pt(n,function(y){o[l]=y,p||(p=!0,a--),a||n.next(r(o.slice()))},function(){--s||n.complete()}))},n)},c=0;c<i;c++)u(c)},n)}}function qa(e,t,r){e?ut(r,e,t):t()}function Np(e,t,r,n,i,o,s,a){var u=[],c=0,l=0,h=!1,p=function(){h&&!u.length&&!c&&t.complete()},y=function(g){return c<n?b(g):u.push(g)},b=function(g){o&&t.next(g),c++;var E=!1;bt(r(g,l++)).subscribe(pt(t,function(w){i?.(w),o?y(w):t.next(w)},function(){E=!0},void 0,function(){if(E)try{c--;for(var w=function(){var _=u.shift();s?ut(t,s,function(){return b(_)}):b(_)};u.length&&c<n;)w();p()}catch(_){t.error(_)}}))};return e.subscribe(pt(t,y,function(){h=!0,p()})),function(){a?.()}}vn=function vn(e,t,r){return r===void 0&&(r=1/0),le(t)?vn(function(n,i){return Te(function(o,s){return t(n,o,i,s)})(bt(e(n,i)))},r):(typeof t=="number"&&(r=t),Xe(function(n,i){return Np(n,i,e,r)}))};var jp=Array.isArray;function Up(e){return e.length===1&&jp(e[0])?e[0]:e}function Ks(e){return e===void 0&&(e=1/0),vn(pn,e)}function Kp(){return Ks(1)}var qp=Fs(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Ye=function(e){rr(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new Ha(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new qp},t.prototype.next=function(r){var n=this;Vn(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var s=Ar(n.currentObservers),a=s.next();!a.done;a=s.next()){var u=a.value;u.next(r)}}catch(c){i={error:c}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},t.prototype.error=function(r){var n=this;Vn(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var i=n.observers;i.length;)i.shift().error(r)}})},t.prototype.complete=function(){var r=this;Vn(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,i=this,o=i.hasError,s=i.isStopped,a=i.observers;return o||s?Hc:(this.currentObservers=null,a.push(r),new $i(function(){n.currentObservers=null,Lo(a,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,i=n.hasError,o=n.thrownError,s=n.isStopped;i?r.error(o):s&&r.complete()},t.prototype.asObservable=function(){var r=new Pe;return r.source=this,r},t.create=function(r,n){return new Ha(r,n)},t}(Pe),Ha=function(e){rr(t,e);function t(r,n){var i=e.call(this)||this;return i.destination=r,i.source=n,i}return t.prototype.next=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,r)},t.prototype.error=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&i!==void 0?i:Hc},t}(Ye);function Wa(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Kp()(mn(e,yn(e)))}Hp=new Pe(function(e){return e.complete()});function No(e,t){return t===void 0&&(t=pn),e=e??Wp,Xe(function(r,n){var i,o=!0;r.subscribe(pt(n,function(s){var a=t(s);(o||!e(i,a))&&(o=!1,i=a,n.next(s))}))})}function Wp(e,t){return e===t}Le=function Le(e,t){return Xe(function(r,n){var i=0;r.subscribe(pt(n,function(o){return e.call(t,o,i++)&&n.next(o)}))})};Qp=Fs(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function zp(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=yn(e),n=nl(e,1/0);return e=Up(e),Xe(function(i,o){Ks(n)(mn(Dt([i],Ct(e)),r)).subscribe(o)})}function Gp(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return zp.apply(void 0,Dt([],Ct(e)))}var al=function(e){rr(t,e);function t(r){var n=e.call(this)||this;return n._value=r,n}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(r){var n=e.prototype._subscribe.call(this,r);return!n.closed&&r.next(this._value),n},t.prototype.getValue=function(){var r=this,n=r.hasError,i=r.thrownError,o=r._value;if(n)throw i;return this._throwIfClosed(),o},t.prototype.next=function(r){e.prototype.next.call(this,this._value=r)},t}(Ye),Vp=function(e){rr(t,e);function t(r,n,i){r===void 0&&(r=1/0),n===void 0&&(n=1/0),i===void 0&&(i=rl);var o=e.call(this)||this;return o._bufferSize=r,o._windowTime=n,o._timestampProvider=i,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=n===1/0,o._bufferSize=Math.max(1,r),o._windowTime=Math.max(1,n),o}return t.prototype.next=function(r){var n=this,i=n.isStopped,o=n._buffer,s=n._infiniteTimeWindow,a=n._timestampProvider,u=n._windowTime;i||(o.push(r),!s&&o.push(a.now()+u)),this._trimBuffer(),e.prototype.next.call(this,r)},t.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),i=this,o=i._infiniteTimeWindow,s=i._buffer,a=s.slice(),u=0;u<a.length&&!r.closed;u+=o?1:2)r.next(a[u]);return this._checkFinalizedStatuses(r),n},t.prototype._trimBuffer=function(){var r=this,n=r._bufferSize,i=r._timestampProvider,o=r._buffer,s=r._infiniteTimeWindow,a=(s?1:2)*n;if(n<1/0&&a<o.length&&o.splice(0,o.length-a),!s){for(var u=i.now(),c=0,l=1;l<o.length&&o[l]<=u;l+=2)c=l;c&&o.splice(0,c+1)}},t}(Ye);function Jp(e){e===void 0&&(e={});var t=e.connector,r=t===void 0?function(){return new Ye}:t,n=e.resetOnError,i=n===void 0?!0:n,o=e.resetOnComplete,s=o===void 0?!0:o,a=e.resetOnRefCountZero,u=a===void 0?!0:a;return function(c){var l,h,p,y=0,b=!1,g=!1,E=function(){h?.unsubscribe(),h=void 0},w=function(){E(),l=p=void 0,b=g=!1},_=function(){var A=l;w(),A?.unsubscribe()};return Xe(function(A,R){y++,!g&&!b&&E();var O=p=p??r();R.add(function(){y--,y===0&&!g&&!b&&(h=ro(_,u))}),O.subscribe(R),!l&&y>0&&(l=new Cr({next:function(C){return O.next(C)},error:function(C){g=!0,E(),h=ro(w,i,C),O.error(C)},complete:function(){b=!0,E(),h=ro(w,s),O.complete()}}),bt(A).subscribe(l))})(c)}}function ro(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(t===!0){e();return}if(t!==!1){var i=new Cr({next:function(){i.unsubscribe(),e()}});return bt(t.apply(void 0,Dt([],Ct(r)))).subscribe(i)}}function qs(e,t,r){var n,i,o,s,a=!1;return e&&typeof e=="object"?(n=e.bufferSize,s=n===void 0?1/0:n,i=e.windowTime,t=i===void 0?1/0:i,o=e.refCount,a=o===void 0?!1:o,r=e.scheduler):s=e??1/0,Jp({connector:function(){return new Vp(s,t,r)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}function ul(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=yn(e);return Xe(function(n,i){(r?Wa(e,n,r):Wa(e,n)).subscribe(i)})}function Yp(e,t){return Xe(function(r,n){var i=null,o=0,s=!1,a=function(){return s&&!i&&n.complete()};r.subscribe(pt(n,function(u){i?.unsubscribe();var c=0,l=o++;bt(e(u,l)).subscribe(i=pt(n,function(h){return n.next(t?t(u,h,l,c++):h)},function(){i=null,a()}))},function(){s=!0,a()}))})}function cl(e){return e.documentData?e.documentData:e.previousDocumentData}function Xp(e){switch(e.operation){case"INSERT":return{operation:e.operation,id:e.documentId,doc:e.documentData,previous:null};case"UPDATE":return{operation:e.operation,id:e.documentId,doc:ce.deepFreezeWhenDevMode(e.documentData),previous:e.previousDocumentData?e.previousDocumentData:"UNKNOWN"};case"DELETE":return{operation:e.operation,id:e.documentId,doc:null,previous:e.previousDocumentData}}}function Pt(e,t){var r=t;r=r.replace(qd,".properties."),r="properties."+r,r=tn(r);var n=St(e,r);return n}function ll(e,t,r){if(typeof t.primaryKey=="string")return r;var n=Hs(t,r),i=r[e];if(i&&i!==n)throw D("DOC19",{args:{documentData:r,existingPrimary:i,newPrimary:n},schema:t});return r[e]=n,r}function Ke(e){return typeof e=="string"?e:e.key}function Hs(e,t){if(typeof e.primaryKey=="string")return t[e.primaryKey];var r=e.primaryKey;return r.fields.map(n=>{var i=St(t,n);if(typeof i>"u")throw D("DOC18",{args:{field:n,documentData:t}});return i}).join(r.separator)}function Zp(e){var t=li(e,!0);return t}function fl(e){e=Z(e);var t=Ke(e.primaryKey);e.properties=Z(e.properties),e.additionalProperties=!1,e.hasOwnProperty("keyCompression")||(e.keyCompression=!1),e.indexes=e.indexes?e.indexes.slice(0):[],e.required=e.required?e.required.slice(0):[],e.encrypted=e.encrypted?e.encrypted.slice(0):[],e.properties._rev={type:"string",minLength:1},e.properties._attachments={type:"object"},e.properties._deleted={type:"boolean"},e.properties._meta=ey,e.required=e.required?e.required.slice(0):[],e.required.push("_deleted"),e.required.push("_rev"),e.required.push("_meta"),e.required.push("_attachments");var r=hl(e);return Ri(e.required,r),e.required=e.required.filter(n=>!n.includes(".")).filter((n,i,o)=>o.indexOf(n)===i),e.version=e.version||0,e.indexes&&(e.indexes=e.indexes.map(n=>{var i=yr(n)?n.slice(0):[n];if(!i.includes(t)){var o=i.slice(0);return o.push(t),o}return i})),e}var ey={type:"object",properties:{lwt:{type:"number",minimum:Bs,maximum:1e15,multipleOf:.01}},additionalProperties:!0,required:["lwt"]};function hl(e){var t=Object.keys(e.properties).filter(n=>e.properties[n].final),r=Ke(e.primaryKey);return t.push(r),typeof e.primaryKey!="string"&&e.primaryKey.fields.forEach(n=>t.push(n)),t}function ty(e,t){for(var r=Object.keys(e.defaultValues),n=0;n<r.length;++n){var i=r[n];(!t.hasOwnProperty(i)||typeof t[i]>"u")&&(t[i]=e.defaultValues[i])}return t}var ry={type:"object",properties:{id:{type:"string"},lwt:{type:"number"}},required:["id","lwt"],additionalProperties:!1},ny="_rxdb_internal";async function iy(e,t){var r=await e.findDocumentsById([t],!1),n=r[t];return n||null}function oy(e,t,r){var n=t.documentData,i=t.previousDocumentData,o={eventId:t.eventId,documentId:t.documentId,collectionName:r?r.name:void 0,startTime:t.startTime,endTime:t.endTime,isLocal:e,operation:t.operation,documentData:ce.deepFreezeWhenDevMode(n),previousDocumentData:ce.deepFreezeWhenDevMode(i)};return o}function jo(e,t,r,n){if(n)throw n.status===409?D("CONFLICT",{collection:e.name,id:t,writeError:n,data:r}):n.status===422?D("VD2",{collection:e.name,id:t,writeError:n,data:r}):n}function sy(e,t,r,n,i){for(var o=!!e.schema.attachments,s=[],a=[],u={},c=new Map,l=Ti(10),h={id:l,events:[],checkpoint:null,context:i},p=h.events,y=[],b=[],g=[],E=be(),w=typeof r.get=="function",_=w?r.size>0:Object.keys(r).length>0,A,R=n.length,O=function(){var S=n[C],k=S.document[t],T=!1;_&&(T=w?r.get(k):r[k]);var F;if(T){var Y=T._rev;if(!S.previous||S.previous&&Y!==S.previous._rev){var K={isError:!0,status:409,documentId:k,writeRow:S,documentInDb:T};return u[k]=K,1}var ve=o?Qa(S):S;o&&(S.document._deleted?S.previous&&Object.keys(S.previous._attachments).forEach(H=>{b.push({documentId:k,attachmentId:H,digest:se(S.previous)._attachments[H].digest})}):(Object.entries(S.document._attachments).find(([H,J])=>{var Tt=S.previous?S.previous._attachments[H]:void 0;return!Tt&&!J.data&&(F={documentId:k,documentInDb:T,isError:!0,status:510,writeRow:S,attachmentId:H}),!0}),F||Object.entries(S.document._attachments).forEach(([H,J])=>{var Tt=S.previous?S.previous._attachments[H]:void 0;if(!Tt)y.push({documentId:k,attachmentId:H,attachmentData:J,digest:Wr(J.data)});else{var Rn=ve.document._attachments[H].digest;J.data&&Tt.digest!==Rn&&g.push({documentId:k,attachmentId:H,attachmentData:J,digest:Wr(J.data)})}}))),F?u[k]=F:(a.push(ve),(!A||A.document._meta.lwt<ve.document._meta.lwt)&&(A=ve));var ae=S.document,z=null,he=null,ye=null;if(S.previous&&S.previous._deleted&&!ae._deleted)ye="INSERT",z=o?Ur(ae):ae;else if(S.previous&&!S.previous._deleted&&!ae._deleted)ye="UPDATE",z=o?Ur(ae):ae,he=S.previous;else if(ae._deleted)ye="DELETE",z=se(S.document),he=S.previous;else throw D("SNH",{args:{writeRow:S}});var qe={eventId:za(l,C,k,S),documentId:k,documentData:z,previousDocumentData:he,operation:ye,startTime:E,endTime:be()};c.set(k,qe),p.push(qe)}else{var W=!!S.document._deleted;if(o&&Object.entries(S.document._attachments).forEach(([H,J])=>{J.data?y.push({documentId:k,attachmentId:H,attachmentData:J,digest:Wr(J.data)}):(F={documentId:k,isError:!0,status:510,writeRow:S,attachmentId:H},u[k]=F)}),F||(o?s.push(Qa(S)):s.push(S),(!A||A.document._meta.lwt<S.document._meta.lwt)&&(A=S)),!W){var ne={eventId:za(l,C,k,S),documentId:k,operation:"INSERT",documentData:o?Ur(S.document):S.document,previousDocumentData:o&&S.previous?Ur(S.previous):S.previous,startTime:E,endTime:be()};c.set(k,ne),p.push(ne)}}},C=0;C<R;C++)O();return{bulkInsertDocs:s,bulkUpdateDocs:a,newestRow:A,errors:u,changeByDocId:c,eventBulk:h,attachmentsAdd:y,attachmentsRemove:b,attachmentsUpdate:g}}function Qa(e){return{previous:e.previous,document:Ur(e.document)}}function ay(e){return atob(e).length}function uy(e){var t=e.data;if(!t)return e;var r={digest:Wr(t),length:ay(t),type:e.type};return r}function Ur(e){var t=Z(e);return t._attachments={},Object.entries(e._attachments).forEach(([r,n])=>{t._attachments[r]=uy(n)}),t}function dl(e){var t=Z(e);return t._meta=Z(e._meta),t}function za(e,t,r,n){return e+"|"+t+"|"+r+"|"+n.document._rev}function Ws(e,t,r){ce.deepFreezeWhenDevMode(r);var n=Ke(r.primaryKey);function i(s){var a=Z(s.document);return a._meta=Z(a._meta),ce.isDevMode()&&(a=ll(n,r,a),s.previous,s.previous&&Object.keys(s.previous._meta).forEach(u=>{if(!s.document._meta.hasOwnProperty(u))throw D("SNH",{dataBefore:s.previous,dataAfter:s.document})})),a._meta.lwt=be(),a._rev=ci(e.token,s.previous),{document:a,previous:s.previous}}var o={originalStorageInstance:t,schema:t.schema,internals:t.internals,collectionName:t.collectionName,databaseName:t.databaseName,options:t.options,bulkWrite(s,a){var u=s.map(c=>i(c));return e.lockedRun(()=>t.bulkWrite(u,a)).then(c=>{var l=Object.values(c.error).filter(y=>!!(y.status===409&&!y.writeRow.previous&&!y.writeRow.document._deleted&&se(y.documentInDb)._deleted));if(l.length>0){var h={error:Z(c.error),success:Z(c.success)},p=l.map(y=>(delete h.error[y.documentId],{previous:y.documentInDb,document:Object.assign({},y.writeRow.document,{_rev:ci(e.token,y.documentInDb)})}));return e.lockedRun(()=>t.bulkWrite(p,a)).then(y=>(h.error=Object.assign(h.error,y.error),h.success=Object.assign(h.success,y.success),h))}return c})},query(s){return e.lockedRun(()=>t.query(s))},count(s){return e.lockedRun(()=>t.count(s))},findDocumentsById(s,a){return e.lockedRun(()=>t.findDocumentsById(s,a))},getAttachmentData(s,a,u){return e.lockedRun(()=>t.getAttachmentData(s,a,u))},getChangedDocumentsSince(s,a){return e.lockedRun(()=>t.getChangedDocumentsSince(se(s),a))},cleanup(s){return e.lockedRun(()=>t.cleanup(s))},remove(){return e.storageInstances.delete(o),e.lockedRun(()=>t.remove())},close(){return e.storageInstances.delete(o),e.lockedRun(()=>t.close())},changeStream(){return t.changeStream()},conflictResultionTasks(){return t.conflictResultionTasks()},resolveConflictResultionTask(s){if(s.output.isEqual)return t.resolveConflictResultionTask(s);var a=Object.assign({},s.output.documentData,{_meta:dn(),_rev:ki(),_attachments:{}}),u=Z(a);return delete u._meta,delete u._rev,delete u._attachments,t.resolveConflictResultionTask({id:s.id,output:{isEqual:!1,documentData:u}})}};return e.storageInstances.add(o),o}function cy(e){if(e.schema.keyCompression)throw D("UT5",{args:{params:e}});if(ly(e.schema))throw D("UT6",{args:{params:e}});if(e.schema.attachments&&e.schema.attachments.compression)throw D("UT7",{args:{params:e}})}function ly(e){return!!(e.encrypted&&e.encrypted.length>0||e.attachments&&e.attachments.encrypted)}var fy=function(){function e(r,n,i,o){this.queueByDocId=new Map,this.isRunning=!1,this.storageInstance=r,this.primaryPath=n,this.preWrite=i,this.postWrite=o}var t=e.prototype;return t.addWrite=function(n,i){var o=n[this.primaryPath],s=Je(this.queueByDocId,o,()=>[]),a=new Promise((u,c)=>{var l={lastKnownDocumentState:n,modifier:i,resolve:u,reject:c};se(s).push(l),this.triggerRun()});return a},t.triggerRun=async function(){if(!(this.isRunning===!0||this.queueByDocId.size===0)){this.isRunning=!0;var n=[],i=this.queueByDocId;this.queueByDocId=new Map,await Promise.all(Array.from(i.entries()).map(async([s,a])=>{var u=hy(a.map(h=>h.lastKnownDocumentState)),c=u;for(var l of a)try{c=await l.modifier(at(c))}catch(h){l.reject(h),l.reject=()=>{},l.resolve=()=>{}}try{await this.preWrite(c,u)}catch(h){a.forEach(p=>p.reject(h));return}n.push({previous:u,document:c})}));var o=n.length>0?await this.storageInstance.bulkWrite(n,"incremental-write"):{error:{},success:{}};return await Promise.all(Array.from(Object.entries(o.success)).map(([s,a])=>{this.postWrite(a);var u=rn(i,s);u.forEach(c=>c.resolve(a))})),Array.from(Object.entries(o.error)).forEach(([s,a])=>{var u=rn(i,s),c=Yd(a);if(c){var l=Je(this.queueByDocId,s,()=>[]);u.reverse().forEach(p=>{p.lastKnownDocumentState=se(c.documentInDb),se(l).unshift(p)})}else{var h=Zd(a);u.forEach(p=>p.reject(h))}}),this.isRunning=!1,this.triggerRun()}},e}();function Ga(e){var t=async r=>{var n=gd(r);n._deleted=r._deleted;var i=await e(n),o=Object.assign({},i,{_meta:r._meta,_attachments:r._attachments,_rev:r._rev,_deleted:typeof i._deleted<"u"?i._deleted:r._deleted});return typeof o._deleted>"u"&&(o._deleted=!1),o};return t}function hy(e){var t=e[0],r=ko(t._rev).height;return e.forEach(n=>{var i=ko(n._rev).height;i>r&&(t=n,r=i)}),t}var gn={get primaryPath(){var e=this;if(e.isInstanceOfRxDocument)return e.collection.schema.primaryPath},get primary(){var e=this;if(e.isInstanceOfRxDocument)return e._data[e.primaryPath]},get revision(){var e=this;if(e.isInstanceOfRxDocument)return e._data._rev},get deleted$(){var e=this;if(e.isInstanceOfRxDocument)return e.$.pipe(Te(t=>t._deleted))},get deleted(){var e=this;if(e.isInstanceOfRxDocument)return e._data._deleted},getLatest(){var e=this.collection._docCache.getLatestDocumentData(this.primary);return this.collection._docCache.getCachedRxDocument(e)},get $(){var e=this;return e.collection.$.pipe(Le(t=>!t.isLocal),Le(t=>t.documentId===this.primary),Te(t=>cl(t)),ul(e.collection._docCache.getLatestDocumentData(this.primary)),No((t,r)=>t._rev===r._rev),Te(t=>this.collection._docCache.getCachedRxDocument(t)),qs(Ls))},get$(e){if(ce.isDevMode()){if(e.includes(".item."))throw D("DOC1",{path:e});if(e===this.primaryPath)throw D("DOC2");if(this.collection.schema.finalFields.includes(e))throw D("DOC3",{path:e});var t=Pt(this.collection.schema.jsonSchema,e);if(!t)throw D("DOC4",{path:e})}return this.$.pipe(Te(r=>St(r,e)),No())},populate(e){var t=Pt(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return Ms;if(!t)throw D("DOC5",{path:e});if(!t.ref)throw D("DOC6",{path:e,schemaObj:t});var n=this.collection.database.collections[t.ref];if(!n)throw D("DOC7",{ref:t.ref,path:e,schemaObj:t});return t.type==="array"?n.findByIds(r).exec().then(i=>{var o=i.values();return Array.from(o)}):n.findOne(r).exec()},get(e){if(this._data){var t=this._propertyCache.get(e);if(t)return t;var r=St(this._data,e);return typeof r!="object"||Array.isArray(r)?ce.deepFreezeWhenDevMode(r):(r=at(r),yl(this.collection.schema,r,e,this),this._propertyCache.set(e,r),r)}},toJSON(e=!1){if(e)return ce.deepFreezeWhenDevMode(this._data);var t=Z(this._data);return delete t._rev,delete t._attachments,delete t._deleted,delete t._meta,ce.deepFreezeWhenDevMode(t)},toMutableJSON(e=!1){return at(this.toJSON(e))},update(e){throw re("update")},incrementalUpdate(e){throw re("update")},updateCRDT(e){throw re("crdt")},putAttachment(){throw re("attachments")},getAttachment(){throw re("attachments")},allAttachments(){throw re("attachments")},get allAttachments$(){throw re("attachments")},async modify(e,t){var r=this._data,n=await Ga(e)(r);return this._saveData(n,r)},incrementalModify(e,t){return this.collection.incrementalWriteQueue.addWrite(this._data,Ga(e)).then(r=>this.collection._docCache.getCachedRxDocument(r))},patch(e){var t=this._data,r=at(t);return Object.entries(e).forEach(([n,i])=>{r[n]=i}),this._saveData(r,t)},incrementalPatch(e){return this.incrementalModify(t=>(Object.entries(e).forEach(([r,n])=>{t[r]=n}),t))},async _saveData(e,t){if(e=Z(e),this._data._deleted)throw D("DOC11",{id:this.primary,document:this});await ml(this.collection,e,t);var r=await this.collection.storageInstance.bulkWrite([{previous:t,document:e}],"rx-document-save-data"),n=r.error[this.primary];return jo(this.collection,this.primary,e,n),await this.collection._runHooks("post","save",e,this),this.collection._docCache.getCachedRxDocument(Na(r.success,this.primary))},remove(){var e=this.collection;if(this.deleted)return Promise.reject(D("DOC13",{document:this,id:this.primary}));var t=Z(this._data),r;return e._runHooks("pre","remove",t,this).then(async()=>{t._deleted=!0;var n=await e.storageInstance.bulkWrite([{previous:this._data,document:t}],"rx-document-remove"),i=n.error[this.primary];return jo(e,this.primary,t,i),Na(n.success,this.primary)}).then(n=>(r=n,this.collection._runHooks("post","remove",t,this))).then(()=>this.collection._docCache.getCachedRxDocument(r))},incrementalRemove(){return this.incrementalModify(async e=>(await this.collection._runHooks("pre","remove",e,this),e._deleted=!0,e)).then(async e=>(await this.collection._runHooks("post","remove",e._data,e),e))},destroy(){throw D("DOC14")}};function pl(e=gn){var t=function(n,i){this.collection=n,this._data=i,this._propertyCache=new Map,this.isInstanceOfRxDocument=!0};return t.prototype=e,t}function yl(e,t,r="",n=!1){if(t!==null){var i=Pt(e.jsonSchema,r);typeof i>"u"||(i.properties&&(i=i.properties),Object.keys(i).forEach(o=>{var s=tn(r+"."+o);t.__defineGetter__(o,function(){var a=n||this;if(!(!a.get||typeof a.get!="function")){var u=a.get(s);return u}}),Object.defineProperty(t,o+"$",{get:function(){var a=n||this;return a.get$(s)},enumerable:!1,configurable:!1}),Object.defineProperty(t,o+"_",{get:function(){var a=n||this;return a.populate(s)},enumerable:!1,configurable:!1}),t.__defineSetter__(o,function(a){var u=n||this;return u.set(s,a)})}))}}function dy(e,t,r){var n=new e(t,r);return Be("createRxDocument",n),n}function ml(e,t,r){return t._meta=Object.assign({},r._meta,t._meta),ce.isDevMode()&&e.schema.validateChange(r,t),e._runHooks("pre","save",t,r)}var vl=function(){function e(r,n){this.jsonSchema=r,this.hashFunction=n,this.indexes=py(this.jsonSchema),this.primaryPath=Ke(this.jsonSchema.primaryKey),this.finalFields=hl(this.jsonSchema)}var t=e.prototype;return t.validateChange=function(n,i){this.finalFields.forEach(o=>{if(!Or(n[o],i[o]))throw D("DOC9",{dataBefore:n,dataAfter:i,fieldName:o,schema:this.jsonSchema})})},t.getDocumentPrototype=function(){var n={};return yl(this,n,""),zn(this,"getDocumentPrototype",()=>n),n},t.getPrimaryOfDocumentData=function(n){return Hs(this.jsonSchema,n)},$r(e,[{key:"version",get:function(){return this.jsonSchema.version}},{key:"defaultValues",get:function(){var r={};return Object.entries(this.jsonSchema.properties).filter(([,n])=>n.hasOwnProperty("default")).forEach(([n,i])=>r[n]=i.default),zn(this,"defaultValues",r)}},{key:"hash",get:function(){return zn(this,"hash",this.hashFunction(JSON.stringify(this.jsonSchema)))}}]),e}();function py(e){return(e.indexes||[]).map(t=>yr(t)?t:[t])}function gl(e){var t=e.version?e.version:0,r=0;return new Array(t).fill(0).map(()=>r++)}function bl(e,t,r=!0){r&&Be("preCreateRxSchema",e);var n=fl(e);n=Zp(n),ce.deepFreezeWhenDevMode(n);var i=new vl(n,t);return Be("createRxSchema",i),i}function yy(e,t){var r=typeof t=="object";return new Promise(function(n,i){var o=new Cr({next:function(s){n(s),o.unsubscribe()},error:i,complete:function(){r?n(t.defaultValue):i(new Qp)}});e.subscribe(o)})}function my(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=yn(e),n=nl(e,1/0),i=e;return i.length?i.length===1?bt(i[0]):Ks(n)(mn(i,r)):Hp}const bn="UNKNOWN";function Qs(e){return e[e.length-1]}function vy(e){const t=typeof e;return e!==null&&(t==="object"||t==="function")}function Va(e,t,r){if(Array.isArray(t)&&(t=t.join(".")),!vy(e)||typeof t!="string")return r===void 0?e:r;const n=t.split(".");if(n.length===0)return r;for(let i=0;i<n.length;i++){const o=n[i];if(gy(e,o)?e=i===n.length-1?void 0:null:e=e[o],e==null){if(i!==n.length-1)return r;break}}return e===void 0?r:e}function gy(e,t){if(typeof t!="number"&&Array.isArray(e)){const r=Number.parseInt(t,10);return Number.isInteger(r)&&e[r]===e[t]}return!1}const wl=e=>!!e.queryParams.limit,by=e=>e.queryParams.limit===1,wy=e=>!!(e.queryParams.skip&&e.queryParams.skip>0),_y=e=>e.changeEvent.operation==="DELETE",xy=e=>e.changeEvent.operation==="INSERT",Ey=e=>e.changeEvent.operation==="UPDATE",Sy=e=>e.changeEvent.previous===bn,Oy=e=>wl(e)&&e.previousResults.length>=e.queryParams.limit,Ay=e=>{const t=e.queryParams.sortFields,r=e.changeEvent.previous,n=e.changeEvent.doc;if(!n)return!1;if(!r||r===bn)return!0;for(let i=0;i<t.length;i++){const o=t[i],s=Va(r,o),a=Va(n,o);if(s!==a)return!0}return!1},Cy=e=>{const t=e.changeEvent.id;if(e.keyDocumentMap)return e.keyDocumentMap.has(t);{const r=e.queryParams.primaryKey,n=e.previousResults;for(let i=0;i<n.length;i++)if(n[i][r]===t)return!0;return!1}},Dy=e=>{const t=e.previousResults[0];return!!(t&&t[e.queryParams.primaryKey]===e.changeEvent.id)},Py=e=>{const t=Qs(e.previousResults);return!!(t&&t[e.queryParams.primaryKey]===e.changeEvent.id)},Iy=e=>{const t=e.changeEvent.previous;if(!t||t===bn)return!1;const r=e.previousResults[0];return r?r[e.queryParams.primaryKey]===e.changeEvent.id?!0:e.queryParams.sortComparator(t,r)<0:!1},Ry=e=>{const t=e.changeEvent.previous;if(!t||t===bn)return!1;const r=Qs(e.previousResults);return r?r[e.queryParams.primaryKey]===e.changeEvent.id?!0:e.queryParams.sortComparator(t,r)>0:!1},ky=e=>{const t=e.changeEvent.doc;if(!t)return!1;const r=e.previousResults[0];return r?r[e.queryParams.primaryKey]===e.changeEvent.id?!0:e.queryParams.sortComparator(t,r)<0:!1},Ty=e=>{const t=e.changeEvent.doc;if(!t)return!1;const r=Qs(e.previousResults);return r?r[e.queryParams.primaryKey]===e.changeEvent.id?!0:e.queryParams.sortComparator(t,r)>0:!1},$y=e=>{const t=e.changeEvent.previous;return!t||t===bn?!1:e.queryParams.queryMatcher(t)},By=e=>{const t=e.changeEvent.doc;return t?e.queryParams.queryMatcher(t):!1},My=e=>e.previousResults.length===0,Ly={0:xy,1:Ey,2:_y,3:wl,4:by,5:wy,6:My,7:Sy,8:Oy,9:Dy,10:Py,11:Ay,12:Cy,13:Iy,14:Ry,15:ky,16:Ty,17:$y,18:By};function Fy(e,t,r,n){var i=e.length,o=i-1,s=0;if(i===0)return e.push(t),0;for(var a;n<=o;)s=n+(o-n>>1),a=e[s],r(a,t)<=0?n=s+1:o=s-1;return r(a,t)<=0&&s++,e.splice(s,0,t),s}const Ny=e=>{},zs=e=>{e.previousResults.unshift(e.changeEvent.doc),e.keyDocumentMap&&e.keyDocumentMap.set(e.changeEvent.id,e.changeEvent.doc)},Gs=e=>{e.previousResults.push(e.changeEvent.doc),e.keyDocumentMap&&e.keyDocumentMap.set(e.changeEvent.id,e.changeEvent.doc)},Vs=e=>{const t=e.previousResults.shift();e.keyDocumentMap&&t&&e.keyDocumentMap.delete(t[e.queryParams.primaryKey])},Js=e=>{const t=e.previousResults.pop();e.keyDocumentMap&&t&&e.keyDocumentMap.delete(t[e.queryParams.primaryKey])},jy=e=>{Vs(e),Gs(e)},Uy=e=>{Js(e),zs(e)},Ky=e=>{Vs(e),zs(e)},qy=e=>{Js(e),Gs(e)},_l=e=>{e.keyDocumentMap&&e.keyDocumentMap.delete(e.changeEvent.id);const t=e.queryParams.primaryKey,r=e.previousResults;for(let n=0;n<r.length;n++)if(r[n][t]===e.changeEvent.id){r.splice(n,1);break}},Hy=e=>{const t=e.changeEvent.doc,r=e.queryParams.primaryKey,n=e.previousResults;for(let i=0;i<n.length;i++)if(n[i][r]===e.changeEvent.id){n[i]=t,e.keyDocumentMap&&e.keyDocumentMap.set(e.changeEvent.id,t);break}},Wy=e=>{const t={_id:"wrongHuman"+(new Date).getTime()};e.previousResults.length=0,e.previousResults.push(t),e.keyDocumentMap&&(e.keyDocumentMap.clear(),e.keyDocumentMap.set(t._id,t))},xl=e=>{const t=e.changeEvent.id,r=e.changeEvent.doc;if(e.keyDocumentMap){if(e.keyDocumentMap.has(t))return;e.keyDocumentMap.set(t,r)}else if(e.previousResults.find(i=>i[e.queryParams.primaryKey]===t))return;Fy(e.previousResults,r,e.queryParams.sortComparator,0)},Qy=e=>{_l(e),xl(e)},zy=e=>{throw new Error("Action runFullQueryAgain must be implemented by yourself")},Gy=e=>{throw new Error("Action unknownAction should never be called")},Vy=["doNothing","insertFirst","insertLast","removeFirstItem","removeLastItem","removeFirstInsertLast","removeLastInsertFirst","removeFirstInsertFirst","removeLastInsertLast","removeExisting","replaceExisting","alwaysWrong","insertAtSortPosition","removeExistingAndInsertAtSortPosition","runFullQueryAgain","unknownAction"],Jy={doNothing:Ny,insertFirst:zs,insertLast:Gs,removeFirstItem:Vs,removeLastItem:Js,removeFirstInsertLast:jy,removeLastInsertFirst:Uy,removeFirstInsertFirst:Ky,removeLastInsertLast:qy,removeExisting:_l,replaceExisting:Hy,alwaysWrong:Wy,insertAtSortPosition:xl,removeExistingAndInsertAtSortPosition:Qy,runFullQueryAgain:zy,unknownAction:Gy},Yy=40;function no(e){return e.charCodeAt(0)-Yy}function Xy(e){return e?"1":"0"}function Ja(e,t){const r=[];for(let n=0,i=e.length;n<i;n+=t)r.push(e.substring(n,n+t));return r}function Zy(e){const t=new Map,n=2+parseInt(e.charAt(0)+e.charAt(1),10)*2,i=e.substring(2,n),o=Ja(i,2);for(let g=0;g<o.length;g++){const E=o[g],w=E.charAt(0),_=no(E.charAt(1));t.set(w,_)}const s=e.substring(n,e.length-3),a=Ja(s,4);for(let g=0;g<a.length;g++){const E=a[g],w=E.charAt(0),_=E.charAt(1),A=E.charAt(2),R=no(E.charAt(3));if(!t.has(_))throw new Error("missing node with id "+_);if(!t.has(A))throw new Error("missing node with id "+A);const O=t.get(_),C=t.get(A),S={l:R,0:O,1:C};t.set(w,S)}const u=e.slice(-3),c=u.charAt(0),l=u.charAt(1),h=no(u.charAt(2)),p=t.get(c),y=t.get(l);return{l:h,0:p,1:y}}function em(e,t,r){let n=e,i=e.l;for(;;){const o=t[i](r),s=Xy(o);if(n=n[s],typeof n=="number"||typeof n=="string")return n;i=n.l}}const tm="14a2b0c/d1e,f+g5h.i4j*k-l)m(n6ohk1pdf1qef1rin-sjn-ton-ugn-vmn-whn-xkn-yln-zdf5{ef5|wx5}df7~dz7\x7fef7\xa1bk7\xa2e{7\xa3g|7\xa4ry7\xa5dp7\xa6gk7\xa7eq7\xa8gt7\xa9ac7\xaamv7\xabgu7\xacnm7\xadiy7\xaenw7\xaf\xa4s8\xb0\xab\xa68\xb1\xack8\xb2\xaam8\xb3\xaev8\xb4\xabn8\xb5\xacn8\xb6vm8\xb7xv8\xb8mn8\xb9\xadj8\xba\xaem8\xbbxm8\xbc\xad\xb93\xbd}~3\xbe\xa9\xb03\xbf\x7f\xa23\xc0\xa1\xa33\xc1m\xb13\xc2\xae\xba3\xc3m\xba3\xc4\xa9\xb43\xc5b\xae3\xc6m\xb53\xc7m\xbb3\xc8x\xbb3\xc9kn3\xcam\xb83\xcb\xbcj6\xcc\xc2m6\xcd\xc6\xc36\xce\xc8m6\xcfnm6\xd0\xca\xc76\xd1\xcc\xce,\xd2\xcd\xd0,\xd3\xc5\xc9,\xd4\xb2\xb6,\xd5\xb3\xb7,\xd6\xaen,\xd7\xba\xbb,\xd8mf9\xd9\xcb\xc19\xdaym9\xdbm\xcf9\xdc\xd1\xd29\xddz{2\xdepq2\xdf\xbd\xbf2\xe0\xbe\xc02\xe1\xa5\xa72\xe2\xb0\xa82\xe3\xc4\xd32\xe4\xb4\xd62\xe5\xddn0\xe6\xden0\xe7\xd8\xdb0\xe8\xd9\xdc0\xe9\xdfn0\xea\xe0\xe30\xeb\xb2\xd40\xec\xaf\xd50\xed\xe1n0\xee\xe2\xe40\xef\xb9\xd70\xf0\xe7v/\xf1\xe5\xe6/\xf2\xe7\xeb/\xf3\xe8\xec/\xf4\xe9\xed/\xf5\xea\xee/\xf6\xday/\xf7\xf2m(\xf8\xf3\xef(\xf9\xf6y(\xfa\xf7\xf8:\xfb\xf4\xf5:\xfcm\xf9:\xfd\xf0\xf14\xfe\xfa\xfb4\xff\xfe\xfd*Ā\xfcm*\xffĀ.";let io;function rm(){return io||(io=Zy(tm)),io}const nm=e=>em(rm(),Ly,e);function im(e){const t=nm(e);return Vy[t]}function om(e,t,r,n,i){const o=Jy[e];return o({queryParams:t,changeEvent:r,previousResults:n,keyDocumentMap:i}),n}var hr=String.fromCharCode(65535),Lt=Number.MIN_VALUE;function sm(e,t){var r=Ke(e.primaryKey),n=t.selector,i=e.indexes?e.indexes.slice(0):[];t.index?i=[t.index]:i.push([r]);var o=t.sort.map(l=>Object.keys(l)[0]),s=o.join(","),a=!!t.sort.find(l=>Object.values(l)[0]==="desc"),u=-1,c;return i.forEach(l=>{var h=!0,p=!0,y=l.map(E=>{var w=n[E],_=w?Object.keys(w):[],A={};if(!w||!_.length){var R=p?Lt:hr;A={startKey:R,endKey:h?hr:Lt,inclusiveStart:!0,inclusiveEnd:!0}}else _.forEach(O=>{if(Ys.has(O)){var C=w[O],S=cm(O,C);A=Object.assign(A,S)}});return typeof A.startKey>"u"&&(A.startKey=Lt),typeof A.endKey>"u"&&(A.endKey=hr),typeof A.inclusiveStart>"u"&&(A.inclusiveStart=!0),typeof A.inclusiveEnd>"u"&&(A.inclusiveEnd=!0),p&&!A.inclusiveStart&&(p=!1),h&&!A.inclusiveEnd&&(h=!1),A}),b={index:l,startKeys:y.map(E=>E.startKey),endKeys:y.map(E=>E.endKey),inclusiveEnd:h,inclusiveStart:p,sortFieldsSameAsIndexFields:!a&&s===l.join(","),selectorSatisfiedByIndex:Ya(l,t.selector)},g=lm(e,t,b);(g>0&&g>u||t.index)&&(u=g,c=b)}),c||(c={index:[r],startKeys:[Lt],endKeys:[hr],inclusiveEnd:!0,inclusiveStart:!0,sortFieldsSameAsIndexFields:!a&&s===r,selectorSatisfiedByIndex:Ya([r],t.selector)}),c}var Ys=new Set(["$eq","$gt","$gte","$lt","$lte"]),am=new Set(["$eq","$gt","$gte"]),um=new Set(["$eq","$lt","$lte"]);function Ya(e,t){var r=Object.entries(t),n=r.find(([u,c])=>{if(!e.includes(u))return!0;var l=Object.entries(c).find(([h,p])=>!Ys.has(h));return l});if(n)return!1;var i,o=e.find(u=>{var c=t[u];if(!c)return!1;var l=Object.keys(c).find(h=>am.has(h));return i&&l?!0:(l!=="$eq"&&(i=l),!1)});if(o)return!1;var s,a=e.find(u=>{var c=t[u];if(!c)return!1;var l=Object.keys(c).find(h=>um.has(h));return s&&l?!0:(l!=="$eq"&&(s=l),!1)});return!a}function cm(e,t){switch(e){case"$eq":return{startKey:t,endKey:t};case"$lte":return{endKey:t};case"$gte":return{startKey:t};case"$lt":return{endKey:t,inclusiveEnd:!1};case"$gt":return{startKey:t,inclusiveStart:!1};default:throw new Error("SNH")}}function lm(e,t,r){var n=0,i=l=>{l>0&&(n=n+l)},o=10,s=Ji(r.startKeys,l=>l!==Lt&&l!==hr);i(s*o);var a=Ji(r.startKeys,l=>l!==hr&&l!==Lt);i(a*o);var u=Ji(r.startKeys,(l,h)=>l===r.endKeys[h]);i(u*o*1.5);var c=r.sortFieldsSameAsIndexFields?5:0;return i(c),n}const fm=2147483647,hm=-2147483648,dm=Number.MAX_SAFE_INTEGER,pm=Number.MIN_SAFE_INTEGER,Vt=Symbol("missing"),ym=Object.getPrototypeOf({}),mm="[object Object]",vm=/^\[object ([a-zA-Z0-9]+)\]$/,Bi=e=>{const t=vr(e);let r=0,n=t.length;for(;n;)r=(r<<5)-r^t.charCodeAt(--n);return r>>>0},El=new Set(["null","undefined","boolean","number","string","date","regexp"]),gm={null:0,undefined:0,number:1,string:2,object:3,array:4,boolean:5,date:6,regexp:7,function:8},je=(e,t)=>{e===Vt&&(e=void 0),t===Vt&&(t=void 0);const[r,n]=[e,t].map(i=>gm[yt(i).toLowerCase()]);return r!==n?r-n:r===1||r===2||r===6?e<t?-1:e>t?1:0:Jt(e,t)?0:e<t?-1:e>t?1:0};function $e(e,t){if(!e)throw new Error(t)}const Uo=e=>{const t=new Map,r=i=>{if(t.has(i))throw new Error("cycle detected during clone operation.");t.set(i,!0)},n=i=>{if(i instanceof Date)return new Date(i);if(Se(i)){r(i);const o=new Array(i.length),s=i.length;for(let a=0;a<s;a++)o[a]=n(i[a]);return o}if(pe(i)){r(i);const o={};for(const s in i)o[s]=n(i[s]);return o}return i};return n(e)},yt=e=>vm.exec(Object.prototype.toString.call(e))[1],oo=e=>typeof e=="boolean",mt=e=>typeof e=="string",Et=e=>!isNaN(e)&&typeof e=="number",Se=Array.isArray,pe=e=>{if(!e)return!1;const t=Object.getPrototypeOf(e);return(t===ym||t===null)&&mm===Object.prototype.toString.call(e)},Mi=e=>e===Object(e),Xa=e=>e instanceof Date,Jn=e=>e instanceof RegExp,bm=e=>typeof e=="function",xe=e=>e==null,Dr=(e,t)=>e.includes(t),Sl=(e,t)=>!Dr(e,t),wm=(e,t=!0)=>!!e||t&&e==="",Br=e=>xe(e)||mt(e)&&!e||e instanceof Array&&e.length===0||pe(e)&&Object.keys(e).length===0,Za=e=>e===Vt,wn=e=>e instanceof Array?e:[e],ct=(e,t)=>!!e&&Object.prototype.hasOwnProperty.call(e,t),_m=(e,t)=>pe(e)&&pe(t)||Se(e)&&Se(t);function hi(e,t,r){if(r=r||{flatten:!1},Za(e)||xe(e))return t;if(Za(t)||xe(t))return e;if(!_m(e,t)){if(r.skipValidation)return t||e;throw Error("mismatched types. must both be array or object")}if(r.skipValidation=!0,Se(e)){const n=e,i=t;if(r.flatten){let o=0,s=0;for(;o<n.length&&s<i.length;)n[o]=hi(n[o++],i[s++],r);for(;s<i.length;)n.push(t[s++])}else Yt(n,i)}else for(const n in t)e[n]=hi(e[n],t[n],r);return e}function eu(e,t=Bi){const r=new Map;return e.forEach((n,i)=>{const o=Cl(n,t);r.has(o)?r.get(o).some(s=>Jt(e[s],n))||r.get(o).push(i):r.set(o,[i])}),r}function Ol(e,t=Bi){if(e.some(a=>a.length==0))return[];if(e.length===1)return Array.from(e);const r=xm(e.map((a,u)=>[u,a.length]),a=>a[1]),n=e[r[0][0]],i=eu(n,t),o=new Map,s=new Array;return i.forEach((a,u)=>{const c=a.map(y=>n[y]),l=c.map(y=>0),h=c.map(y=>[r[0][0],0]);let p=!1;for(let y=1;y<e.length;y++){const[b,g]=r[y],E=e[b];if(o.has(y)||o.set(y,eu(E)),o.get(y).has(u)){const w=o.get(y).get(u).map(_=>E[_]);p=c.map((_,A)=>w.some((R,O)=>{const C=l[A];return Jt(_,R)&&(l[A]++,b<h[A][0]&&(h[A]=[b,o.get(y).get(u)[O]])),C<l[A]})).some(Boolean)}if(!p)return}p&&Yt(s,l.map((y,b)=>y===e.length-1?[c[b],h[b]]:Vt).filter(y=>y!==Vt))}),s.sort((a,u)=>{const[c,[l,h]]=a,[p,[y,b]]=u,g=je(l,y);return g!==0?g:je(h,b)}).map(a=>a[0])}function Al(e,t=0){const r=new Array;function n(i,o){for(let s=0,a=i.length;s<a;s++)Se(i[s])&&(o>0||o<0)?n(i[s],Math.max(-1,o-1)):r.push(i[s])}return n(e,t),r}function Jt(e,t){const r=[e],n=[t];for(;r.length>0;){if(e=r.pop(),t=n.pop(),e===t)continue;const i=yt(e).toLowerCase();if(i!==yt(t).toLowerCase()||i==="function")return!1;if(i==="array"){const o=e,s=t;if(o.length!==s.length)return!1;if(o.length===s.length&&o.length===0)continue;Yt(r,o),Yt(n,s)}else if(i==="object"){const o=Object.keys(e),s=Object.keys(t);if(o.length!==s.length)return!1;for(let a=0,u=o.length;a<u;a++){const c=o[a];if(!ct(t,c))return!1;r.push(e[c]),n.push(t[c])}}else if(vr(e)!==vr(t))return!1}return r.length===0}function vr(e){const t=yt(e).toLowerCase();switch(t){case"boolean":case"number":case"regexp":return e.toString();case"string":return JSON.stringify(e);case"date":return e.toISOString();case"null":case"undefined":return t;case"array":return"["+e.map(vr).join(",")+"]"}const r=t==="object"?"":`${yt(e)}`,n=Object.keys(e);return n.sort(),`${r}{`+n.map(i=>`${vr(i)}:${vr(e[i])}`).join(",")+"}"}function Cl(e,t){return t=t||Bi,xe(e)?null:t(e).toString()}function xm(e,t,r=je){if(Br(e))return e;const n=new Array,i=new Array;for(let o=0;o<e.length;o++){const s=e[o],a=t(s,o);xe(a)?i.push(s):n.push([a,s])}return n.sort((o,s)=>r(o[0],s[0])),Yt(i,n.map(o=>o[1]))}function Em(e,t,r=Bi){if(e.length<1)return new Map;const n=new Map,i=new Map;for(let o=0;o<e.length;o++){const s=e[o],a=t(s,o),u=Cl(a,r);if(u===null)i.has(null)?i.get(null).push(s):i.set(null,[s]);else{const c=n.has(u)?n.get(u).find(l=>Jt(l,a)):null;xe(c)?(i.set(a,[s]),n.has(u)?n.get(u).push(a):n.set(u,[a])):i.get(c).push(s)}}return i}const so=5e4;function Yt(e,...t){return e instanceof Array?t.reduce((r,n)=>{let i=Math.ceil(n.length/so),o=0;for(;i-- >0;)Array.prototype.push.apply(r,n.slice(o,o+so)),o+=so;return r},e):t.filter(Mi).reduce((r,n)=>(Object.assign(r,n),r),e)}function Ko(e,t){return Mi(e)?e[t]:void 0}function Sm(e,t){if(t<1)return e;for(;t--&&e.length===1;)e=e[0];return e}function Xs(e,t,r){let n=0;function i(s,a){let u=s;for(let c=0;c<a.length;c++){const l=a[c];if(/^\d+$/.exec(l)===null&&u instanceof Array){if(c===0&&n>0)break;n+=1;const p=a.slice(c);u=u.reduce((y,b)=>{const g=i(b,p);return g!==void 0&&y.push(g),y},[]);break}else u=Ko(u,l);if(u===void 0)break}return u}const o=El.has(yt(e).toLowerCase())?e:i(e,t.split("."));return o instanceof Array&&r?.unwrapArray?Sm(o,n):o}function Yn(e,t,r){const n=t.split("."),i=n[0],o=n.slice(1).join("."),s=/^\d+$/.exec(i)!==null,a=n.length>1;let u,c;if(e instanceof Array)if(s)u=Ko(e,Number(i)),a&&(u=Yn(u,o,r)),u=[u];else{u=[];for(const l of e)c=Yn(l,t,r),r?.preserveMissing?(c===void 0&&(c=Vt),u.push(c)):c!==void 0&&u.push(c)}else{if(c=Ko(e,i),a&&(c=Yn(c,o,r)),c===void 0)return;u=r?.preserveKeys?Object.assign({},e):{},u[i]=c}return u}function qo(e){if(e instanceof Array)for(let t=e.length-1;t>=0;t--)e[t]===Vt?e.splice(t,1):qo(e[t]);else if(pe(e))for(const t in e)ct(e,t)&&qo(e[t])}const tu=/^\d+$/;function di(e,t,r,n){const i=t.split("."),o=i[0],s=i.slice(1).join(".");if(i.length===1)(pe(e)||Se(e)&&tu.test(o))&&r(e,o);else{n?.buildGraph&&xe(e[o])&&(e[o]={});const a=e[o];if(!a)return;const u=!!(i.length>1&&tu.test(i[1]));a instanceof Array&&n?.descendArray&&!u?a.forEach(c=>di(c,s,r,n)):di(a,s,r,n)}}function Om(e,t,r){di(e,t,(n,i)=>{n[i]=r},{buildGraph:!0})}function ru(e,t,r){di(e,t,(n,i)=>{if(n instanceof Array){if(/^\d+$/.test(i))n.splice(parseInt(i),1);else if(r&&r.descendArray)for(const o of n)pe(o)&&delete o[i]}else pe(n)&&delete n[i]},r)}const Am=/^\$[a-zA-Z0-9_]+$/;function Mr(e){return Am.test(e)}function Dl(e){if(El.has(yt(e).toLowerCase()))return Jn(e)?{$regex:e}:{$eq:e};if(Mi(e)){if(!Object.keys(e).some(Mr))return{$eq:e};if(ct(e,"$regex")){const r=Object.assign({},e);return r.$regex=new RegExp(e.$regex,e.$options),delete r.$options,r}}return e}var Ot;(function(e){e.CLONE_ALL="CLONE_ALL",e.CLONE_INPUT="CLONE_INPUT",e.CLONE_OUTPUT="CLONE_OUTPUT",e.CLONE_OFF="CLONE_OFF"})(Ot||(Ot={}));class jt{constructor(t,r,n,i=Date.now()){this._opts=t,this._root=r,this._local=n,this.timestamp=i,this.update(r,n)}static init(t,r,n){return t instanceof jt?new jt(t._opts,xe(t.root)?r:t.root,Object.assign({},t.local,n)):new jt(t,r,n)}update(t,r){var n;return this._root=t,this._local=r&&Object.assign({},r,{variables:Object.assign({},(n=this._local)===null||n===void 0?void 0:n.variables,r?.variables)}),this}getOptions(){return Object.freeze(Object.assign(Object.assign({},this._opts),{context:Xt.from(this._opts.context)}))}get root(){return this._root}get local(){return this._local}get idKey(){return this._opts.idKey}get collation(){var t;return(t=this._opts)===null||t===void 0?void 0:t.collation}get processingMode(){var t;return((t=this._opts)===null||t===void 0?void 0:t.processingMode)||Ot.CLONE_OFF}get useStrictMode(){var t;return(t=this._opts)===null||t===void 0?void 0:t.useStrictMode}get scriptEnabled(){var t;return(t=this._opts)===null||t===void 0?void 0:t.scriptEnabled}get useGlobalContext(){var t;return(t=this._opts)===null||t===void 0?void 0:t.useGlobalContext}get hashFunction(){var t;return(t=this._opts)===null||t===void 0?void 0:t.hashFunction}get collectionResolver(){var t;return(t=this._opts)===null||t===void 0?void 0:t.collectionResolver}get jsonSchemaValidator(){var t;return(t=this._opts)===null||t===void 0?void 0:t.jsonSchemaValidator}get variables(){var t;return(t=this._opts)===null||t===void 0?void 0:t.variables}get context(){var t;return(t=this._opts)===null||t===void 0?void 0:t.context}}function Pl(e){return e instanceof jt?e.getOptions():Object.freeze(Object.assign(Object.assign({idKey:"_id",scriptEnabled:!0,useStrictMode:!0,useGlobalContext:!0,processingMode:Ot.CLONE_OFF},e),{context:e?.context?Xt.from(e?.context):Xt.init({})}))}var ie;(function(e){e.ACCUMULATOR="accumulator",e.EXPRESSION="expression",e.PIPELINE="pipeline",e.PROJECTION="projection",e.QUERY="query",e.WINDOW="window"})(ie||(ie={}));class Xt{constructor(t){this.operators=Uo(t)}static init(t){return new Xt(hi({[ie.ACCUMULATOR]:{},[ie.EXPRESSION]:{},[ie.PIPELINE]:{},[ie.PROJECTION]:{},[ie.QUERY]:{},[ie.WINDOW]:{}},t,{skipValidation:!0}))}static from(t){return new Xt(t.operators)}addOperators(t,r){for(const[n,i]of Object.entries(r))this.getOperator(t,n)||(this.operators[t][n]=i);return this}addAccumulatorOps(t){return this.addOperators(ie.ACCUMULATOR,t)}addExpressionOps(t){return this.addOperators(ie.EXPRESSION,t)}addQueryOps(t){return this.addOperators(ie.QUERY,t)}addPipelineOps(t){return this.addOperators(ie.PIPELINE,t)}addProjectionOps(t){return this.addOperators(ie.PROJECTION,t)}addWindowOps(t){return this.addOperators(ie.WINDOW,t)}getOperator(t,r){return t in this.operators&&this.operators[t][r]||null}}const Il=Xt.init({});function nu(e,t){for(const[r,n]of Object.entries(t)){$e(bm(n)&&Mr(r),`'${r}' is not a valid operator`);const i=Ut(e,r,null);$e(!i||n===i,`${r} already exists for '${e}' operators. Cannot change operator function once registered.`)}Il.addOperators(e,t)}function Ut(e,t,r){const{context:n,useGlobalContext:i}=r||{},o=n?n.getOperator(e,t):null;return!o&&i?Il.getOperator(e,t):o}const iu={$$ROOT(e,t,r){return r.root},$$CURRENT(e,t,r){return e},$$REMOVE(e,t,r){},$$NOW(e,t,r){return new Date(r.timestamp)}},Ho={$$KEEP(e,t,r){return e},$$PRUNE(e,t,r){},$$DESCEND(e,t,r){if(!ct(t,"$cond"))return e;let n;for(const[i,o]of Object.entries(e))if(Mi(o)){if(o instanceof Array){const s=[];for(let a of o)pe(a)&&(a=ou(a,t,r.update(a))),xe(a)||s.push(a);n=s}else n=ou(o,t,r.update(o));xe(n)?delete e[i]:e[i]=n}return e}};function ze(e,t,r,n){var i;const o=jt.init(n,e);if(r=r||"",Mr(r)){const s=Ut(ie.EXPRESSION,r,n);if(s)return s(e,t,o);const a=Ut(ie.ACCUMULATOR,r,n);if(a)return e instanceof Array||(e=ze(e,t,null,o),t=null),$e(e instanceof Array,`'${r}' target must be an array.`),a(e,t,o.update(null,o.local));throw new Error(`operator '${r}' is not registered`)}if(mt(t)&&t.length>0&&t[0]==="$"){if(ct(Ho,t))return t;let s=o.root;const a=t.split(".");if(ct(iu,a[0]))s=iu[a[0]](e,null,o),t=t.slice(a[0].length+1);else if(a[0].slice(0,2)==="$$"){s=Object.assign({},o.variables,{this:e},(i=o.local)===null||i===void 0?void 0:i.variables);const u=a[0].slice(2);$e(ct(s,u),`Use of undefined variable: ${u}`),t=t.slice(2)}else t=t.slice(1);return t===""?s:Xs(s,t)}if(Se(t))return t.map(s=>ze(e,s,null,o));if(pe(t)){const s={};for(const[a,u]of Object.entries(t))if(s[a]=ze(e,u,a,o),[ie.EXPRESSION,ie.ACCUMULATOR].some(c=>!!Ut(c,a,n)))return $e(Object.keys(t).length===1,"Invalid aggregation expression '"+JSON.stringify(t)+"'"),s[a];return s}return t}function ou(e,t,r){const n=ze(e,t,null,r);return ct(Ho,n)?Ho[n](e,t,r):n}function Pr(e){return e instanceof su?e:new su(e)}function Cm(...e){let t=0;return Pr(()=>{for(;t<e.length;){const r=e[t].next();if(!r.done)return r;t++}return{done:!0}})}function Dm(e){return!!e&&typeof e=="object"&&e?.next instanceof Function}function Pm(e,t){const r=e.slice(t+1);e.splice(t),Array.prototype.push.apply(e,r)}const Wo=new Error;var Ve;(function(e){e[e.MAP=0]="MAP",e[e.FILTER=1]="FILTER",e[e.TAKE=2]="TAKE",e[e.DROP=3]="DROP"})(Ve||(Ve={}));function Im(e,t,r){let n=!1,i=-1,o=0;return function(s){try{e:for(;!n;){let a=e();i++;let u=-1;const c=t.length;let l=!1;for(;++u<c;){const h=t[u];switch(h.action){case Ve.MAP:a=h.func(a,i);break;case Ve.FILTER:if(!h.func(a,i))continue e;break;case Ve.TAKE:--h.count,h.count||(l=!0);break;case Ve.DROP:--h.count,h.count||Pm(t,u);continue e;default:break e}}if(n=l,s)r[o++]=a;else return{value:a,done:!1}}}catch(a){if(a!==Wo)throw a}return n=!0,{done:n}}}class su{constructor(t){this.iteratees=[],this.yieldedValues=[],this.isDone=!1;let r;if(t instanceof Function&&(t={next:t}),Dm(t)){const n=t;r=()=>{const i=n.next();if(i.done)throw Wo;return i.value}}else if(t instanceof Array){const n=t,i=n.length;let o=0;r=()=>{if(o<i)return n[o++];throw Wo}}else if(!(t instanceof Function))throw new Error(`Source is of type '${typeof t}'. Must be Array, Function, or Generator`);this.getNext=Im(r,this.iteratees,this.yieldedValues)}push(t,r){return typeof r=="function"?this.iteratees.push({action:t,func:r}):typeof r=="number"&&this.iteratees.push({action:t,count:r}),this}next(){return this.getNext()}map(t){return this.push(Ve.MAP,t)}filter(t){return this.push(Ve.FILTER,t)}take(t){return t>0?this.push(Ve.TAKE,t):this}drop(t){return t>0?this.push(Ve.DROP,t):this}transform(t){const r=this;let n;return Pr(()=>(n||(n=Pr(t(r.value()))),n.next()))}value(){return this.isDone||(this.isDone=this.getNext(!0).done),this.yieldedValues}each(t){for(;;){const r=this.next();if(r.done)break;if(t(r.value)===!1)return!1}return!0}reduce(t,r){let n=this.next();for(r===void 0&&!n.done&&(r=n.value,n=this.next());!n.done;)r=t(r,n.value),n=this.next();return r}size(){return this.reduce((t,r)=>++t,0)}[Symbol.iterator](){return this}}class Rm{constructor(t,r){this.pipeline=t,this.options=Pl(r)}stream(t){let r=Pr(t);const n=this.options.processingMode;(n==Ot.CLONE_ALL||n==Ot.CLONE_INPUT)&&r.map(Uo);const i=new Array;if(!Br(this.pipeline))for(const o of this.pipeline){const s=Object.keys(o),a=s[0],u=Ut(ie.PIPELINE,a,this.options);$e(s.length===1&&!!u,`invalid pipeline operator ${a}`),i.push(a),r=u(r,o[a],this.options)}return(n==Ot.CLONE_OUTPUT||n==Ot.CLONE_ALL&&Ol([["$group","$unwind"],i]).length)&&r.map(Uo),r}run(t){return this.stream(t).value()}}class km{constructor(t,r,n,i){this.source=t,this.predicate=r,this.projection=n,this.options=i,this.operators=[],this.result=null,this.buffer=[]}fetch(){return this.result?this.result:(pe(this.projection)&&this.operators.push({$project:this.projection}),this.result=Pr(this.source).filter(this.predicate),this.operators.length>0&&(this.result=new Rm(this.operators,this.options).stream(this.result)),this.result)}fetchAll(){const t=Pr([...this.buffer]);return this.buffer=[],Cm(t,this.fetch())}all(){return this.fetchAll().value()}count(){return this.all().length}skip(t){return this.operators.push({$skip:t}),this}limit(t){return this.operators.push({$limit:t}),this}sort(t){return this.operators.push({$sort:t}),this}collation(t){return this.options=Object.assign(Object.assign({},this.options),{collation:t}),this}next(){if(this.buffer.length>0)return this.buffer.pop();const t=this.fetch().next();if(!t.done)return t.value}hasNext(){if(this.buffer.length>0)return!0;const t=this.fetch().next();return t.done?!1:(this.buffer.push(t.value),!0)}map(t){return this.all().map(t)}forEach(t){this.all().forEach(t)}[Symbol.iterator](){return this.fetchAll()}}class _n{constructor(t,r){this.condition=t,this.options=Pl(r),this.compiled=[],this.compile()}compile(){$e(pe(this.condition),"query criteria must be an object");const t={};for(const[r,n]of Object.entries(this.condition)){if(r==="$where")Object.assign(t,{field:r,expr:n});else if(Dr(["$and","$or","$nor","$expr","$jsonSchema"],r))this.processOperator(r,r,n);else{$e(!Mr(r),`unknown top level operator: ${r}`);for(const[i,o]of Object.entries(Dl(n)))this.processOperator(r,i,o)}t.field&&this.processOperator(t.field,t.field,t.expr)}}processOperator(t,r,n){const i=Ut(ie.QUERY,r,this.options);if(!i)throw new Error(`unknown operator ${r}`);const o=i(t,n,this.options);this.compiled.push(o)}test(t){for(let r=0,n=this.compiled.length;r<n;r++)if(!this.compiled[r](t))return!1;return!0}find(t,r){return new km(t,n=>this.test(n),r||{},this.options)}remove(t){return t.reduce((r,n)=>(this.test(n)||r.push(n),r),[])}}function Ce(e){const t=(r,n,i)=>{const o={unwrapArray:!0},s=Math.max(1,r.split(".").length-1);return a=>{const u=Xs(a,r,o);return e(u,n,Object.assign(Object.assign({},i),{depth:s}))}};return t.op="query",t}function Rl(e,t,r){if(Jt(e,t)||xe(e)&&xe(t))return!0;if(e instanceof Array){const n=Jt.bind(null,t);return e.some(n)||Al(e,r?.depth).some(n)}return!1}function Tm(e,t,r){return!Rl(e,t,r)}function kl(e,t,r){return xe(e)?t.some(n=>n===null):Ol([wn(e),t],r?.hashFunction).length>0}function $m(e,t,r){return!kl(e,t,r)}function Bm(e,t,r){return Li(e,t,(n,i)=>je(n,i)<0)}function Mm(e,t,r){return Li(e,t,(n,i)=>je(n,i)<=0)}function Lm(e,t,r){return Li(e,t,(n,i)=>je(n,i)>0)}function Fm(e,t,r){return Li(e,t,(n,i)=>je(n,i)>=0)}function Nm(e,t,r){return wn(e).some(n=>t.length===2&&n%t[0]===t[1])}function jm(e,t,r){const n=wn(e),i=o=>mt(o)&&wm(t.exec(o),r?.useStrictMode);return n.some(i)||Al(n,1).some(i)}function Um(e,t,r){return(t===!1||t===0)&&e===void 0||(t===!0||t===1)&&e!==void 0}function Km(e,t,r){if(!Se(e)||!Se(t)||!e.length||!t.length)return!1;let n=!0;for(const i of t){if(!n)break;pe(i)&&Dr(Object.keys(i),"$elemMatch")?n=Tl(e,i.$elemMatch,r):i instanceof RegExp?n=e.some(o=>typeof o=="string"&&i.test(o)):n=e.some(o=>Jt(i,o))}return n}function qm(e,t,r){return Array.isArray(e)&&e.length===t}function Hm(e){return Mr(e)&&["$and","$or","$nor"].indexOf(e)===-1}function Tl(e,t,r){if(Se(e)&&!Br(e)){let n=s=>s,i=t;Object.keys(t).every(Hm)&&(i={temp:t},n=s=>({temp:s}));const o=new _n(i,r);for(let s=0,a=e.length;s<a;s++)if(o.test(n(e[s])))return!0}return!1}const au=e=>e===null,uu=e=>Et(e)&&e>=hm&&e<=fm&&e.toString().indexOf(".")===-1,cu=e=>Et(e)&&e>=pm&&e<=dm&&e.toString().indexOf(".")===-1,Wm={array:Se,bool:oo,boolean:oo,date:Xa,decimal:Et,double:Et,int:uu,long:cu,number:Et,null:au,object:pe,regex:Jn,regexp:Jn,string:mt,undefined:xe,function:e=>{throw new Error("unsupported type key `function`.")},1:Et,2:mt,3:pe,4:Se,6:xe,8:oo,9:Xa,10:au,11:Jn,16:uu,18:cu,19:Et};function lu(e,t,r){const n=Wm[t];return n?n(e):!1}function Qm(e,t,r){return Array.isArray(t)?t.findIndex(n=>lu(e,n))>=0:lu(e,t)}function Li(e,t,r){return wn(e).some(n=>yt(n)===yt(t)&&r(n,t))}const fu=(e,t)=>{const r={};return e.split("").forEach((n,i)=>r[n]=t*(i+1)),r};Object.assign(Object.assign(Object.assign({},fu("ABCDEFGHIKLM",1)),fu("NOPQRSTUVWXY",-1)),{Z:0});const hu={undefined:null,null:null,NaN:NaN,Infinity:new Error,"-Infinity":new Error};function Ie(e,t=hu){const r=Object.assign({},hu,t),n=new Set(Object.keys(r));return(i,o,s)=>{const a=ze(i,o,null,s);if(n.has(`${a}`)){const u=r[`${a}`];if(u instanceof Error)throw new Error(`cannot apply $${e.name} to -inf, value must in (-inf,inf)`);return u}return e(a)}}Ie(Math.acos,{Infinity:1/0,0:new Error});Ie(Math.acosh,{Infinity:1/0,0:new Error});Ie(Math.asin);Ie(Math.asinh,{Infinity:1/0,"-Infinity":-1/0});Ie(Math.atan);Ie(Math.atanh,{1:1/0,"-1":-1/0});Ie(Math.cos);Ie(Math.cosh,{"-Infinity":1/0,Infinity:1/0});const zm=Math.PI/180;Ie(e=>e*zm,{Infinity:1/0,"-Infinity":1/0});const Gm=180/Math.PI;Ie(e=>e*Gm,{Infinity:1/0,"-Infinity":-1/0});Ie(Math.sin);Ie(Math.sinh,{"-Infinity":-1/0,Infinity:1/0});Ie(Math.tan);const Vm=(e,t,r)=>{if(Br(t)||!pe(t))return e;let n=je;const i=r.collation;return pe(i)&&mt(i.locale)&&(n=Ym(i)),e.transform(o=>{const s=Object.keys(t);for(const a of s.reverse()){const u=Em(o,l=>Xs(l,a),r.hashFunction),c=Array.from(u.keys()).sort(n);t[a]===-1&&c.reverse(),o=[],c.reduce((l,h)=>Yt(l,u.get(h)),o)}return o})},Jm={1:"base",2:"accent",3:"variant"};function Ym(e){const t={sensitivity:Jm[e.strength||3],caseFirst:e.caseFirst==="off"?"false":e.caseFirst||"false",numeric:e.numericOrdering||!1,ignorePunctuation:e.alternate==="shifted"};(e.caseLevel||!1)===!0&&(t.sensitivity==="base"&&(t.sensitivity="case"),t.sensitivity==="accent"&&(t.sensitivity="variant"));const r=new Intl.Collator(e.locale,t);return(n,i)=>{if(!mt(n)||!mt(i))return je(n,i);const o=r.compare(n,i);return o<0?-1:o>0?1:0}}const Xm=(e,t,r)=>{if(Br(t))return e;let n=Object.keys(t),i=!1;$l(t,r);const o=r.idKey;if(Dr(n,o)){const a=t[o];(a===0||a===!1)&&(n=n.filter(Sl.bind(null,[o])),i=n.length==0)}else n.push(o);const s=jt.init(r);return e.map(a=>Qo(a,t,s.update(a),n,i))};function Qo(e,t,r,n,i){let o={},s=!1,a=!1;const u=[];i&&u.push(r.idKey);for(const c of n){let l;const h=t[c];if(c!==r.idKey&&Dr([0,!1],h)&&(a=!0),c===r.idKey&&Br(h))l=e[c];else if(mt(h))l=ze(e,h,c,r);else if(!Dr([1,!0],h))if(h instanceof Array)l=h.map(y=>{const b=ze(e,y,null,r);return xe(b)?null:b});else if(pe(h)){const y=h,b=Object.keys(h),g=b.length==1?b[0]:"",E=Ut(ie.PROJECTION,g,r);if(E)g==="$slice"?wn(y[g]).every(Et)?(l=E(e,y[g],c,r),s=!0):l=ze(e,y,c,r):l=E(e,y[g],c,r);else if(Mr(g))l=ze(e,y[g],g,r);else if(ct(e,c)){$l(y,r);let w=e[c];w instanceof Array?l=w.map(_=>Qo(_,y,r,b,!1)):(w=pe(w)?w:e,l=Qo(w,y,r,b,!1))}else l=ze(e,h,null,r)}else{u.push(c);continue}const p=Yn(e,c,{preserveMissing:!0});p!==void 0&&hi(o,p,{flatten:!0}),Sl([0,1,!1,!0],h)&&(l===void 0?ru(o,c,{descendArray:!0}):Om(o,c,l))}if(qo(o),(s||a||i)&&(o=Yt({},e,o),u.length>0))for(const c of u)ru(o,c,{descendArray:!0});return o}function $l(e,t){const r=[!1,!1];for(const[n,i]of Object.entries(e)){if(n===t?.idKey)return;i===0||i===!1?r[0]=!0:(i===1||i===!0)&&(r[1]=!0),$e(!(r[0]&&r[1]),"Projection cannot have a mix of inclusion and exclusion.")}}const Zm=(e,t,r)=>{$e(Se(t),"Invalid expression: $and expects value to be an Array.");const n=t.map(i=>new _n(i,r));return i=>n.every(o=>o.test(i))},Bl=(e,t,r)=>{$e(Se(t),"Invalid expression. $or expects value to be an Array");const n=t.map(i=>new _n(i,r));return i=>n.some(o=>o.test(i))},ev=(e,t,r)=>{$e(Se(t),"Invalid expression. $nor expects value to be an array.");const n=Bl("$or",t,r);return i=>!n(i)},tv=(e,t,r)=>{const n={};n[e]=Dl(t);const i=new _n(n,r);return o=>!i.test(o)},rv=Ce(Rl),nv=Ce(Lm),iv=Ce(Fm),ov=Ce(kl),sv=Ce(Bm),av=Ce(Mm),uv=Ce(Tm),cv=Ce($m),lv=Ce(Nm),fv=Ce(jm);Ce(Km);const hv=Ce(Tl),dv=Ce(qm),pv=Ce(Um),yv=Ce(Qm);var du=!1;function mv(e){return du||(nu(ie.PIPELINE,{$sort:Vm,$project:Xm}),nu(ie.QUERY,{$and:Zm,$eq:rv,$elemMatch:hv,$exists:pv,$gt:nv,$gte:iv,$in:ov,$lt:sv,$lte:av,$ne:uv,$nin:cv,$mod:lv,$nor:ev,$not:tv,$or:Bl,$regex:fv,$size:dv,$type:yv}),du=!0),new _n(e)}function pi(e,t){var r=Ke(e.primaryKey);t=Z(t),t.selector&&(t.selector=zo(t.selector));var n=at(t);if(typeof n.skip!="number"&&(n.skip=0),n.selector?(n.selector=n.selector,Object.entries(n.selector).forEach(([c,l])=>{(typeof l!="object"||l===null)&&(n.selector[c]={$eq:l})})):n.selector={},n.index){var i=$s(n.index);i.includes(r)||i.push(r),n.index=i}if(n.sort){var u=n.sort.find(c=>Ud(c)===r);u||(n.sort=n.sort.slice(0),n.sort.push({[r]:"asc"}))}else if(n.index)n.sort=n.index.map(c=>({[c]:"asc"}));else{if(e.indexes){var o=new Set;Object.entries(n.selector).forEach(([c,l])=>{var h=!1;typeof l=="object"&&l!==null?h=!!Object.keys(l).find(p=>Ys.has(p)):h=!0,h&&o.add(c)});var s=-1,a;e.indexes.forEach(c=>{var l=yr(c)?c:[c],h=l.findIndex(p=>!o.has(p));h>0&&h>s&&(s=h,a=l)}),a&&(n.sort=a.map(c=>({[c]:"asc"})))}n.sort||(n.sort=[{[r]:"asc"}])}return n}function zo(e){if(typeof e!="object"||e===null)return e;var t=Object.keys(e),r={};return t.forEach(n=>{var i=e[n];if(n==="$regex"&&i instanceof RegExp){var o=Wd(i);r.$regex=o.pattern,r.$options=o.flags}else Array.isArray(i)?r[n]=i.map(s=>zo(s)):r[n]=zo(i)}),r}function Ml(e,t){if(!t.sort)throw D("SNH",{query:t});var r=[];t.sort.forEach(i=>{var o=Object.keys(i)[0],s=Object.values(i)[0];r.push({key:o,direction:s,getValueFn:jd(o)})});var n=(i,o)=>{for(var s=0;s<r.length;++s){var a=r[s],u=a.getValueFn(i),c=a.getValueFn(o);if(u!==c){var l=a.direction==="asc"?je(u,c):je(c,u);return l}}};return n}function Zs(e,t){if(!t.sort)throw D("SNH",{query:t});var r=mv(t.selector),n=i=>{if(i._deleted)return!1;var o=r.find([i]),s=o.next();return!!s};return n}function vv(e,t){return!t.sort||t.sort.length===0?[e]:t.sort.map(r=>Object.keys(r)[0])}var gv=new WeakMap;function bv(e){return Je(gv,e,()=>{var t=e.collection,r=pi(t.storageInstance.schema,at(e.mangoQuery)),n=t.schema.primaryPath,i=Ml(t.schema.jsonSchema,r),o=(c,l)=>{var h={docA:c,docB:l,rxQuery:e};return i(h.docA,h.docB)},s=Zs(t.schema.jsonSchema,r),a=c=>{var l={doc:c,rxQuery:e};return s(l.doc)},u={primaryKey:e.collection.schema.primaryPath,skip:r.skip,limit:r.limit,sortFields:vv(n,r),sortComparator:o,queryMatcher:a};return u})}function wv(e,t){if(!e.collection.database.eventReduce)return{runFullQueryAgain:!0};var r=bv(e),n=se(e._result).docsData.slice(0),i=se(e._result).docsDataMap,o=!1,s=t.map(u=>Xp(u)).filter(fd),a=s.find(u=>{var c={queryParams:r,changeEvent:u,previousResults:n,keyDocumentMap:i},l=im(c);if(l==="runFullQueryAgain")return!0;if(l!=="doNothing")return o=!0,om(l,r,u,n,i),!1});return a?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:o,newResults:n}}var _v=function(){function e(){this._map=new Map}var t=e.prototype;return t.getByQuery=function(n){var i=n.toString();return Je(this._map,i,()=>n)},e}();function xv(){return new _v}function pu(e,t){t.uncached=!0;var r=t.toString();e._map.delete(r)}function Ev(e){return e.refCount$.observers.length}var Sv=100,Ov=30*1e3,Av=(e,t)=>(r,n)=>{if(!(n._map.size<e)){var i=be()-t,o=[],s=Array.from(n._map.values());for(var a of s)if(!(Ev(a)>0)){if(a._lastEnsureEqual===0&&a._creationTime<i){pu(n,a);continue}o.push(a)}var u=o.length-e;if(!(u<=0)){var c=o.sort((h,p)=>h._lastEnsureEqual-p._lastEnsureEqual),l=c.slice(0,u);l.forEach(h=>pu(n,h))}}},Ll=Av(Sv,Ov),ao=new WeakSet;function Cv(e){ao.has(e)||(ao.add(e),Id().then(()=>$d(200)).then(()=>{e.destroyed||e.cacheReplacementPolicy(e,e._queryCache),ao.delete(e)}))}var Dv=0,Pv=function(){return++Dv},Fl=function(){function e(r,n,i,o={}){this.id=Pv(),this._execOverDatabaseCount=0,this._creationTime=be(),this._lastEnsureEqual=0,this.uncached=!1,this.refCount$=new al(null),this._result=null,this._latestChangeEvent=-1,this._lastExecStart=0,this._lastExecEnd=0,this._ensureEqualQueue=Fe,this.op=r,this.mangoQuery=n,this.collection=i,this.other=o,n||(this.mangoQuery=Xn()),this.isFindOneByIdQuery=Tv(this.collection.schema.primaryPath,n)}var t=e.prototype;return t._setResultData=function(n){if(typeof n=="number"){this._result={docsData:[],docsMap:new Map,docsDataMap:new Map,count:n,docs:[],time:be()};return}else n instanceof Map&&(n=Array.from(n.values()));var i=new Map,o=new Map,s=n.map(u=>this.collection._docCache.getCachedRxDocument(u)),a=s.map(u=>(i.set(u.primary,u._data),o.set(u.primary,u),u._data));this._result={docsData:a,docsMap:o,docsDataMap:i,count:a.length,docs:s,time:be()}},t._execOverDatabase=async function(){if(this._execOverDatabaseCount=this._execOverDatabaseCount+1,this._lastExecStart=be(),this.op==="count"){var n=this.getPreparedQuery(),i=await this.collection.storageInstance.count(n);if(i.mode==="slow"&&!this.collection.database.allowSlowCount)throw D("QU14",{collection:this.collection,queryObj:this.mangoQuery});return i.count}if(this.op==="findByIds"){var o=se(this.mangoQuery.selector)[this.collection.schema.primaryPath].$in,s=new Map,a=[];if(o.forEach(l=>{var h=this.collection._docCache.getLatestDocumentDataIfExists(l);if(h){if(!h._deleted){var p=this.collection._docCache.getCachedRxDocument(h);s.set(l,p)}}else a.push(l)}),a.length>0){var u=await this.collection.storageInstance.findDocumentsById(a,!1);Object.values(u).forEach(l=>{var h=this.collection._docCache.getCachedRxDocument(l);s.set(h.primary,h)})}return s}var c=kv(this);return c.then(l=>(this._lastExecEnd=be(),l))},t.exec=function(n){if(n&&this.op!=="findOne")throw D("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return yu(this).then(()=>yy(this.$)).then(i=>{if(!i&&n)throw D("QU10",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return i})},t.toString=function(){var n=li({op:this.op,query:this.mangoQuery,other:this.other},!0),i=JSON.stringify(n,Kd);return this.toString=()=>i,i},t.getPreparedQuery=function(){var n={rxQuery:this,mangoQuery:pi(this.collection.schema.jsonSchema,this.mangoQuery)};Be("prePrepareQuery",n);var i=this.collection.database.storage.statics.prepareQuery(this.collection.schema.jsonSchema,n.mangoQuery);return this.getPreparedQuery=()=>i,i},t.doesDocumentDataMatch=function(n){return n._deleted?!1:this.queryMatcher(n)},t.remove=function(){return this.exec().then(n=>Array.isArray(n)?Promise.all(n.map(i=>i.remove())):n.remove())},t.update=function(n){throw re("update")},t.where=function(n){throw re("query-builder")},t.sort=function(n){throw re("query-builder")},t.skip=function(n){throw re("query-builder")},t.limit=function(n){throw re("query-builder")},$r(e,[{key:"$",get:function(){if(!this._$){var r=this.collection.$.pipe(Le(n=>!n.isLocal),ul(null),vn(()=>yu(this)),Te(()=>this._result),qs(Ls),No((n,i)=>!!(n&&n.time===se(i).time)),Le(n=>!!n),Te(n=>{var i=se(n);return this.op==="count"?i.count:this.op==="findOne"?i.docs.length===0?null:i.docs[0]:this.op==="findByIds"?i.docsMap:i.docs.slice(0)}));this._$=my(r,this.refCount$.pipe(Le(()=>!1)))}return this._$}},{key:"queryMatcher",get:function(){var r=this.collection.schema.jsonSchema,n=pi(this.collection.schema.jsonSchema,this.mangoQuery);return zn(this,"queryMatcher",Zs(r,n))}},{key:"asRxQuery",get:function(){return this}}]),e}();function Xn(){return{selector:{}}}function Iv(e){return e.collection._queryCache.getByQuery(e)}function cr(e,t,r,n){Be("preCreateRxQuery",{op:e,queryObj:t,collection:r,other:n});var i=new Fl(e,t,r,n);return i=Iv(i),Cv(r),i}function Nl(e){var t=e.asRxQuery.collection._changeEventBuffer.counter;return e._latestChangeEvent>=t}function yu(e){return e.collection.database.destroyed||Nl(e)?Fe:(e._ensureEqualQueue=e._ensureEqualQueue.then(()=>Rv(e)),e._ensureEqualQueue)}function Rv(e){if(e._lastEnsureEqual=be(),e.collection.database.destroyed||Nl(e))return Fe;var t=!1,r=!1;if(e._latestChangeEvent===-1&&(r=!0),!r){var n=e.asRxQuery.collection._changeEventBuffer.getFrom(e._latestChangeEvent+1);if(n===null)r=!0;else{e._latestChangeEvent=e.asRxQuery.collection._changeEventBuffer.counter;var i=e.asRxQuery.collection._changeEventBuffer.reduceByLastOfDoc(n);if(e.op==="count"){var o=se(e._result).count,s=o;i.forEach(c=>{var l=c.previousDocumentData&&e.doesDocumentDataMatch(c.previousDocumentData),h=e.doesDocumentDataMatch(c.documentData);!l&&h&&s++,l&&!h&&s--}),s!==o&&(t=!0,e._setResultData(s))}else{var a=wv(e,i);a.runFullQueryAgain?r=!0:a.changed&&(t=!0,e._setResultData(a.newResults))}}}if(r){var u=e.collection._changeEventBuffer.counter;return e._execOverDatabase().then(c=>(e._latestChangeEvent=u,typeof c=="number"?((!e._result||c!==e._result.count)&&(t=!0,e._setResultData(c)),t):((!e._result||!bd(e.collection.schema.primaryPath,c,e._result.docsData))&&(t=!0,e._setResultData(c)),t)))}return Promise.resolve(t)}async function kv(e){var t=[],r=e.collection;if(e.isFindOneByIdQuery)if(Array.isArray(e.isFindOneByIdQuery)){var n=e.isFindOneByIdQuery;if(n=n.filter(l=>{var h=e.collection._docCache.getLatestDocumentDataIfExists(l);return h?(h._deleted||t.push(h),!1):!0}),n.length>0){var i=await r.storageInstance.findDocumentsById(n,!1);Object.values(i).forEach(l=>{t.push(l)})}}else{var o=e.isFindOneByIdQuery,s=e.collection._docCache.getLatestDocumentDataIfExists(o);if(!s){var a=await r.storageInstance.findDocumentsById([o],!1);a.hasOwnProperty(o)&&(s=a[o])}s&&!s._deleted&&t.push(s)}else{var u=e.getPreparedQuery(),c=await r.storageInstance.query(u);t=c.documents}return t}function Tv(e,t){if(!t.skip&&t.selector&&Object.keys(t.selector).length===1&&t.selector[e]){var r=t.selector[e];if(typeof r=="string")return r;if(Object.keys(r).length===1&&typeof r.$eq=="string"||Object.keys(r).length===1&&Array.isArray(r.$eq)&&!r.$eq.find(n=>typeof n!="string"))return r.$eq}return!1}var gr="collection",ea="storage-token",$v="RxInternalDocument",ta=fl({version:0,title:$v,primaryKey:{key:"id",fields:["context","key"],separator:"|"},type:"object",properties:{id:{type:"string",maxLength:200},key:{type:"string"},context:{type:"string",enum:[gr,ea,"OTHER"]},data:{type:"object",additionalProperties:!0}},indexes:[],required:["key","context","data"],additionalProperties:!1,sharding:{shards:1,mode:"collection"}});function yi(e,t){return Hs(ta,{key:e,context:t})}async function jl(e,t){var r=e.prepareQuery(t.schema,{selector:{context:gr},sort:[{id:"asc"}],skip:0}),n=await t.query(r),i=n.documents;return i}var Ul="storageToken",Mn=yi(Ul,ea);async function Bv(e){var t=Ti(10),r=e.password?e.hashFunction(JSON.stringify(e.password)):void 0,n={id:Mn,context:ea,key:Ul,data:{token:t,instanceToken:e.token,passwordHash:r},_deleted:!1,_meta:dn(),_rev:ki(),_attachments:{}},i=await e.internalStore.bulkWrite([{document:n}],"internal-add-storage-token");if(i.success[Mn])return i.success[Mn];var o=se(i.error[Mn]);if(o.isError&&o.status===409){var s=o;if(r&&r!==s.documentInDb.data.passwordHash)throw D("DB1",{passwordHash:r,existingPasswordHash:s.documentInDb.data.passwordHash});var a=s.documentInDb;return se(a)}throw o}function mu(e,t){return e+"-"+t.version}function uo(e,t){return t=Z(t),t=ty(e,t),t=ll(e.primaryPath,e.jsonSchema,t),t._meta=dn(),t.hasOwnProperty("_deleted")||(t._deleted=!1),t.hasOwnProperty("_attachments")||(t._attachments={}),t.hasOwnProperty("_rev")||(t._rev=ki()),t}async function Mv(e,t){t.multiInstance=e.multiInstance;var r=await e.storage.createStorageInstance(t);return r}async function Kl(e,t,r,n,i,o){var s=await jl(e.statics,t),a=s.filter(h=>h.data.name===i),u=[];a.forEach(h=>{u.push({collectionName:h.data.name,schema:h.data.schema,isCollection:!0}),h.data.connectedStorages.forEach(p=>u.push({collectionName:p.collectionName,isCollection:!1,schema:p.schema}))});var c=new Set;if(u=u.filter(h=>{var p=h.collectionName+"||"+h.schema.version;return c.has(p)?!1:(c.add(p),!0)}),await Promise.all(u.map(async h=>{var p=await e.createStorageInstance({collectionName:h.collectionName,databaseInstanceToken:r,databaseName:n,multiInstance:!1,options:{},schema:h.schema,devMode:ce.isDevMode()});await p.remove(),h.isCollection&&await Gt("postRemoveRxCollection",{storage:e,databaseName:n,collectionName:i})})),o){var l=a.map(h=>{var p=dl(h);return p._deleted=!0,p._meta.lwt=be(),p._rev=ci(r,h),{previous:h,document:p}});await t.bulkWrite(l,"rx-database-remove-collection-all")}}var Lv=function(){function e(r,n,i){this.cacheItemByDocId=new Map,this.registry=typeof FinalizationRegistry=="function"?new FinalizationRegistry(o=>{var s=o.docId,a=this.cacheItemByDocId.get(s);a&&(a.documentByRevisionHeight.delete(o.revisionHeight),a.documentByRevisionHeight.size===0&&this.cacheItemByDocId.delete(s))}):void 0,this.primaryPath=r,this.changes$=n,this.documentCreator=i,n.subscribe(o=>{var s=o.documentId,a=this.cacheItemByDocId.get(s);if(a){var u=cl(o);a.latestDoc=u}})}var t=e.prototype;return t.getCachedRxDocument=function(n){var i=n[this.primaryPath],o=vd(n._rev),s=Je(this.cacheItemByDocId,i,()=>Fv(n)),a=s.documentByRevisionHeight.get(o),u=a?a.deref():void 0;return u||(n=ce.deepFreezeWhenDevMode(n),u=this.documentCreator(n),s.documentByRevisionHeight.set(o,jv(u)),this.registry&&this.registry.register(u,{docId:i,revisionHeight:o})),u},t.getLatestDocumentData=function(n){var i=rn(this.cacheItemByDocId,n);return i.latestDoc},t.getLatestDocumentDataIfExists=function(n){var i=this.cacheItemByDocId.get(n);if(i)return i.latestDoc},e}();function Fv(e){return{documentByRevisionHeight:new Map,latestDoc:e}}var Nv=typeof WeakRef=="function";function jv(e){return Nv?new WeakRef(e):{deref(){return e}}}var Uv=function(){function e(r){this.subs=[],this.limit=100,this.counter=0,this.eventCounterMap=new WeakMap,this.buffer=[],this.collection=r,this.subs.push(this.collection.$.pipe(Le(n=>!n.isLocal)).subscribe(n=>this._handleChangeEvent(n)))}var t=e.prototype;return t._handleChangeEvent=function(n){for(this.counter++,this.buffer.push(n),this.eventCounterMap.set(n,this.counter);this.buffer.length>this.limit;)this.buffer.shift()},t.getArrayIndexByPointer=function(n){var i=this.buffer[0],o=this.eventCounterMap.get(i);if(n<o)return null;var s=n-o;return s},t.getFrom=function(n){var i=[],o=this.getArrayIndexByPointer(n);if(o===null)return null;for(;;){var s=this.buffer[o];if(o++,s)i.push(s);else return i}},t.runFrom=function(n,i){var o=this.getFrom(n);if(o===null)throw new Error("out of bounds");o.forEach(s=>i(s))},t.reduceByLastOfDoc=function(n){return n.slice(0)},t.destroy=function(){this.subs.forEach(n=>n.unsubscribe())},e}();function Kv(e){return new Uv(e)}var qv=new WeakMap;function Hv(e){var t=e.schema.getDocumentPrototype(),r=zv(e),n=gn,i={};return[t,r,n].forEach(o=>{var s=Object.getOwnPropertyNames(o);s.forEach(a=>{var u=Object.getOwnPropertyDescriptor(o,a),c=!0;(a.startsWith("_")||a.endsWith("_")||a.startsWith("$")||a.endsWith("$"))&&(c=!1),typeof u.value=="function"?Object.defineProperty(i,a,{get(){return u.value.bind(this)},enumerable:c,configurable:!1}):(u.enumerable=c,u.configurable=!1,u.writable&&(u.writable=!1),Object.defineProperty(i,a,u))})}),i}function Wv(e){return Je(qv,e,()=>pl(Hv(e)))}function Qv(e,t){var r=dy(Wv(e),e,ce.deepFreezeWhenDevMode(t));return e._runHooksSync("post","create",t,r),Be("postCreateRxDocument",r),r}function zv(e){var t={};return Object.entries(e.methods).forEach(([r,n])=>{t[r]=n}),t}var ql=function(e,t){return Or(e.newDocumentState,e.realMasterState)?Promise.resolve({isEqual:!0}):Promise.resolve({isEqual:!1,documentData:e.realMasterState})},Hl=["pre","post"],Wl=["insert","save","remove","create"],vu=!1,ra=function(){function e(r,n,i,o,s={},a={},u={},c={},l={},h=Ll,p={},y=ql){this.storageInstance={},this.timeouts=new Set,this.incrementalWriteQueue={},this._incrementalUpsertQueues=new Map,this.synced=!1,this.hooks={},this._subs=[],this._docCache={},this._queryCache=xv(),this.$={},this.checkpoint$={},this._changeEventBuffer={},this.onDestroy=[],this.destroyed=!1,this.database=r,this.name=n,this.schema=i,this.internalStorageInstance=o,this.instanceCreationOptions=s,this.migrationStrategies=a,this.methods=u,this.attachments=c,this.options=l,this.cacheReplacementPolicy=h,this.statics=p,this.conflictHandler=y,Gv(this.asRxCollection)}var t=e.prototype;return t.prepare=async function(){this.storageInstance=Ws(this.database,this.internalStorageInstance,this.schema.jsonSchema),this.incrementalWriteQueue=new fy(this.storageInstance,this.schema.primaryPath,(s,a)=>ml(this,s,a),s=>this._runHooks("post","save",s));var n=this.database.eventBulks$.pipe(Le(s=>s.collectionName===this.name));this.$=n.pipe(vn(s=>s.events)),this.checkpoint$=n.pipe(Te(s=>s.checkpoint)),this._changeEventBuffer=Kv(this.asRxCollection),this._docCache=new Lv(this.schema.primaryPath,this.$.pipe(Le(s=>!s.isLocal)),s=>Qv(this.asRxCollection,s));var i=await this.database.storageToken,o=this.storageInstance.changeStream().subscribe(s=>{var a={id:s.id,internal:!1,collectionName:this.name,storageToken:i,events:s.events.map(u=>oy(!1,u,this)),databaseToken:this.database.token,checkpoint:s.checkpoint,context:s.context};this.database.$emit(a)});return this._subs.push(o),this._subs.push(this.storageInstance.conflictResultionTasks().subscribe(s=>{this.conflictHandler(s.input,s.context).then(a=>{this.storageInstance.resolveConflictResultionTask({id:s.id,output:a})})})),ke},t.migrationNeeded=function(){throw re("migration")},t.getDataMigrator=function(){throw re("migration")},t.migrate=function(n=10){return this.getDataMigrator().migrate(n)},t.migratePromise=function(n=10){return this.getDataMigrator().migratePromise(n)},t.insert=async function(n){var i=await this.bulkInsert([n]),o=i.error[0];jo(this,n[this.schema.primaryPath],n,o);var s=se(i.success[0]);return s},t.bulkInsert=async function(n){if(n.length===0)return{success:[],error:[]};var i=this.schema.primaryPath,o=n.map(h=>{var p=uo(this.schema,h);return p}),s=this.hasHooks("pre","insert")?await Promise.all(o.map(h=>this._runHooks("pre","insert",h).then(()=>h))):o,a=new Map,u=s.map(h=>{a.set(h[i],h);var p={document:h};return p}),c=await this.storageInstance.bulkWrite(u,"rx-collection-bulk-insert"),l=Object.values(c.success).map(h=>this._docCache.getCachedRxDocument(h));return this.hasHooks("post","insert")&&await Promise.all(l.map(h=>this._runHooks("post","insert",a.get(h.primary),h))),{success:l,error:Object.values(c.error)}},t.bulkRemove=async function(n){if(n.length===0)return{success:[],error:[]};var i=await this.findByIds(n).exec(),o=[],s=new Map;Array.from(i.values()).forEach(h=>{var p=h.toMutableJSON(!0);o.push(p),s.set(h.primary,p)}),await Promise.all(o.map(h=>{var p=h[this.schema.primaryPath];return this._runHooks("pre","remove",h,i.get(p))}));var a=o.map(h=>{var p=Z(h);return p._deleted=!0,{previous:h,document:p}}),u=await this.storageInstance.bulkWrite(a,"rx-collection-bulk-remove"),c=Object.keys(u.success);await Promise.all(c.map(h=>this._runHooks("post","remove",s.get(h),i.get(h))));var l=c.map(h=>rn(i,h));return{success:l,error:Object.values(u.error)}},t.bulkUpsert=async function(n){var i=[],o=new Map;n.forEach(c=>{var l=uo(this.schema,c),h=l[this.schema.primaryPath];if(!h)throw D("COL3",{primaryPath:this.schema.primaryPath,data:l,schema:this.schema.jsonSchema});o.set(h,l),i.push(l)});var s=await this.bulkInsert(i),a=s.success.slice(0),u=await Promise.all(s.error.map(async c=>{if(c.status!==409)throw D("VD2",{collection:this.name,writeError:c});var l=c.documentId,h=rn(o,l),p=se(c.documentInDb),y=this._docCache.getCachedRxDocument(p),b=await y.incrementalModify(()=>h);return b}));return Ri(a,u),a},t.upsert=function(n){return this.bulkUpsert([n]).then(i=>i[0])},t.incrementalUpsert=function(n){var i=uo(this.schema,n),o=i[this.schema.primaryPath];if(!o)throw D("COL4",{data:n});var s=this._incrementalUpsertQueues.get(o);return s||(s=ke),s=s.then(()=>Jv(this,o,i)).then(a=>a.inserted?a.doc:Vv(a.doc,i)),this._incrementalUpsertQueues.set(o,s),s},t.find=function(n){if(typeof n=="string")throw D("COL5",{queryObj:n});n||(n=Xn());var i=cr("find",n,this);return i},t.findOne=function(n){var i;if(typeof n=="string")i=cr("findOne",{selector:{[this.schema.primaryPath]:n},limit:1},this);else{if(n||(n=Xn()),n.limit)throw D("QU6");n.limit=1,i=cr("findOne",n,this)}if(typeof n=="number"||Array.isArray(n))throw ue("COL6",{queryObj:n});return i},t.count=function(n){n||(n=Xn());var i=cr("count",n,this);return i},t.findByIds=function(n){var i={selector:{[this.schema.primaryPath]:{$in:n.slice(0)}}},o=cr("findByIds",i,this);return o},t.exportJSON=function(){throw re("json-dump")},t.importJSON=function(n){throw re("json-dump")},t.insertCRDT=function(n){throw re("crdt")},t.addHook=function(n,i,o,s=!1){if(typeof o!="function")throw ue("COL7",{key:i,when:n});if(!Hl.includes(n))throw ue("COL8",{key:i,when:n});if(!Wl.includes(i))throw D("COL9",{key:i});if(n==="post"&&i==="create"&&s===!0)throw D("COL10",{when:n,key:i,parallel:s});var a=o.bind(this),u=s?"parallel":"series";this.hooks[i]=this.hooks[i]||{},this.hooks[i][n]=this.hooks[i][n]||{series:[],parallel:[]},this.hooks[i][n][u].push(a)},t.getHooks=function(n,i){return!this.hooks[i]||!this.hooks[i][n]?{series:[],parallel:[]}:this.hooks[i][n]},t.hasHooks=function(n,i){var o=this.getHooks(n,i);return o?o.series.length>0||o.parallel.length>0:!1},t._runHooks=function(n,i,o,s){var a=this.getHooks(n,i);if(!a)return ke;var u=a.series.map(c=>()=>c(o,s));return Bd(u).then(()=>Promise.all(a.parallel.map(c=>c(o,s))))},t._runHooksSync=function(n,i,o,s){var a=this.getHooks(n,i);a&&a.series.forEach(u=>u(o,s))},t.promiseWait=function(n){var i=new Promise(o=>{var s=setTimeout(()=>{this.timeouts.delete(s),o()},n);this.timeouts.add(s)});return i},t.destroy=function(){return this.destroyed?Fe:(this.destroyed=!0,Array.from(this.timeouts).forEach(n=>clearTimeout(n)),this._changeEventBuffer&&this._changeEventBuffer.destroy(),this.database.requestIdlePromise().then(()=>Promise.all(this.onDestroy.map(n=>n()))).then(()=>this.storageInstance.close()).then(()=>(this._subs.forEach(n=>n.unsubscribe()),delete this.database.collections[this.name],Gt("postDestroyRxCollection",this).then(()=>!0))))},t.remove=async function(){await this.destroy(),await Kl(this.database.storage,this.database.internalStore,this.database.token,this.database.name,this.name,this.database.hashFunction)},$r(e,[{key:"insert$",get:function(){return this.$.pipe(Le(r=>r.operation==="INSERT"))}},{key:"update$",get:function(){return this.$.pipe(Le(r=>r.operation==="UPDATE"))}},{key:"remove$",get:function(){return this.$.pipe(Le(r=>r.operation==="DELETE"))}},{key:"asRxCollection",get:function(){return this}}]),e}();function Gv(e){if(!vu){vu=!0;var t=Object.getPrototypeOf(e);Wl.forEach(r=>{Hl.map(n=>{var i=n+Mc(r);t[i]=function(o,s){return this.addHook(n,r,o,s)}})})}}function Vv(e,t){return e.incrementalModify(r=>t)}function Jv(e,t,r){var n=e._docCache.getLatestDocumentDataIfExists(t);return n?Promise.resolve({doc:e._docCache.getCachedRxDocument(n),inserted:!1}):e.findOne(t).exec().then(i=>i?{doc:i,inserted:!1}:e.insert(r).then(o=>({doc:o,inserted:!0})))}function Yv({database:e,name:t,schema:r,instanceCreationOptions:n={},migrationStrategies:i={},autoMigrate:o=!0,statics:s={},methods:a={},attachments:u={},options:c={},localDocuments:l=!1,cacheReplacementPolicy:h=Ll,conflictHandler:p=ql}){var y={databaseInstanceToken:e.token,databaseName:e.name,collectionName:t,schema:r.jsonSchema,options:n,multiInstance:e.multiInstance,password:e.password,devMode:ce.isDevMode()};return Be("preCreateRxStorageInstance",y),Mv(e,y).then(b=>{var g=new ra(e,t,r,b,n,i,a,u,c,h,s,p);return g.prepare().then(()=>{Object.entries(s).forEach(([w,_])=>{Object.defineProperty(g,w,{get:()=>_.bind(g)})});var E=ke;return o&&g.schema.version!==0&&(E=g.migratePromise()),E}).then(()=>(Be("createRxCollection",{collection:g,creator:{name:t,schema:r,storageInstance:b,instanceCreationOptions:n,migrationStrategies:i,methods:a,attachments:u,options:c,cacheReplacementPolicy:h,localDocuments:l,statics:s}}),g)).catch(E=>b.close().then(()=>Promise.reject(E)))})}var Ql=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;this._parallels=t||1,this._qC=0,this._iC=new Set,this._lHN=0,this._hPM=new Map,this._pHM=new Map};Ql.prototype={isIdle:function(){return this._qC<this._parallels},lock:function(){this._qC++},unlock:function(){this._qC--,Go(this)},wrapCall:function(t){var r=this;this.lock();var n;try{n=t()}catch(i){throw this.unlock(),i}return!n.then||typeof n.then!="function"?(this.unlock(),n):n.then(function(i){return r.unlock(),i}).catch(function(i){throw r.unlock(),i})},requestIdlePromise:function(t){var r=this;t=t||{};var n,i=new Promise(function(a){return n=a}),o=function(){co(r,i),n()};if(i._manRes=o,t.timeout){var s=setTimeout(function(){i._manRes()},t.timeout);i._timeoutObj=s}return this._iC.add(i),Go(this),i},cancelIdlePromise:function(t){co(this,t)},requestIdleCallback:function(t,r){var n=this._lHN++,i=this.requestIdlePromise(r);return this._hPM.set(n,i),this._pHM.set(i,n),i.then(function(){return t()}),n},cancelIdleCallback:function(t){var r=this._hPM.get(t);this.cancelIdlePromise(r)},clear:function(){var t=this;this._iC.forEach(function(r){return co(t,r)}),this._qC=0,this._iC.clear(),this._hPM=new Map,this._pHM=new Map}};function Xv(e){if(e._iC.size!==0){var t=e._iC.values(),r=t.next().value;r._manRes(),setTimeout(function(){return Go(e)},0)}}function co(e,t){if(t){if(t._timeoutObj&&clearTimeout(t._timeoutObj),e._pHM.has(t)){var r=e._pHM.get(t);e._hPM.delete(r),e._pHM.delete(t)}e._iC.delete(t)}}function Go(e){e._tryIR||e._iC.size===0||(e._tryIR=!0,setTimeout(function(){if(!e.isIdle()){e._tryIR=!1;return}setTimeout(function(){if(!e.isIdle()){e._tryIR=!1;return}Xv(e),e._tryIR=!1},0)},0))}var na=(function(){function e(t){this.ttl=t,this.map=new Map,this._to=!1}return e.prototype.has=function(t){return this.map.has(t)},e.prototype.add=function(t){var r=this;this.map.set(t,zl()),this._to||(this._to=!0,setTimeout(function(){r._to=!1,Zv(r)},0))},e.prototype.clear=function(){this.map.clear()},e}());function Zv(e){for(var t=zl()-e.ttl,r=e.map[Symbol.iterator]();;){var n=r.next().value;if(!n)return;var i=n[0],o=n[1];if(o<t)e.map.delete(i);else return}}function zl(){return(new Date).getTime()}var mi=new Set,ia=function(){function e(r,n,i,o,s,a,u=!1,c={},l,h,p,y){this.idleQueue=new Ql,this.storageInstances=new Set,this._subs=[],this.startupErrors=[],this.onDestroy=[],this.destroyed=!1,this.collections={},this.eventBulks$=new Ye,this.observable$=this.eventBulks$.pipe(vn(b=>b.events)),this.storageToken=Fe,this.storageTokenDocument=Fe,this.emittedEventBulkIds=new na(60*1e3),this.name=r,this.token=n,this.storage=i,this.instanceCreationOptions=o,this.password=s,this.multiInstance=a,this.eventReduce=u,this.options=c,this.internalStore=l,this.hashFunction=h,this.cleanupPolicy=p,this.allowSlowCount=y,this.name!=="pseudoInstance"&&(this.internalStore=Ws(this.asRxDatabase,l,ta),this.storageTokenDocument=Bv(this.asRxDatabase).catch(b=>this.startupErrors.push(b)),this.storageToken=this.storageTokenDocument.then(b=>b.data.token).catch(b=>this.startupErrors.push(b)))}var t=e.prototype;return t.$emit=function(n){this.emittedEventBulkIds.has(n.id)||(this.emittedEventBulkIds.add(n.id),this.eventBulks$.next(n))},t.removeCollectionDoc=async function(n,i){var o=await iy(this.internalStore,yi(mu(n,i),gr));if(!o)throw D("SNH",{name:n,schema:i});var s=dl(o);s._deleted=!0,await this.internalStore.bulkWrite([{document:s,previous:o}],"rx-database-remove-collection")},t.addCollections=async function(n){var i={},o={},s=[],a={};Object.entries(n).forEach(([l,h])=>{var p=l,y=h.schema;i[p]=y;var b=bl(y,this.hashFunction);if(o[p]=b,this.collections[l])throw D("DB3",{name:l});var g=mu(l,y),E={id:yi(g,gr),key:g,context:gr,data:{name:p,schemaHash:b.hash,schema:b.jsonSchema,version:b.version,connectedStorages:[]},_deleted:!1,_meta:dn(),_rev:ki(),_attachments:{}};s.push({document:E});var w=Object.assign({},h,{name:p,schema:b,database:this}),_=Z(h);_.database=this,_.name=l,Be("preCreateRxCollection",_),w.conflictHandler=_.conflictHandler,a[p]=w});var u=await this.internalStore.bulkWrite(s,"rx-database-add-collection");await ng(this),Object.entries(u.error).forEach(([l,h])=>{if(h.status!==409)throw D("DB12",{database:this.name,writeError:h});var p=se(h.documentInDb),y=p.data.name,b=o[y];if(p.data.schemaHash!==b.hash)throw D("DB6",{database:this.name,collection:y,previousSchemaHash:p.data.schemaHash,schemaHash:b.hash,previousSchema:p.data.schema,schema:se(i[y])})});var c={};return await Promise.all(Object.keys(n).map(async l=>{var h=a[l],p=await Yv(h);c[l]=p,this.collections[l]=p,this[l]||Object.defineProperty(this,l,{get:()=>this.collections[l]})})),c},t.lockedRun=function(n){return this.idleQueue.wrapCall(n)},t.requestIdlePromise=function(){return this.idleQueue.requestIdlePromise()},t.exportJSON=function(n){throw re("json-dump")},t.importJSON=function(n){throw re("json-dump")},t.backup=function(n){throw re("backup")},t.leaderElector=function(){throw re("leader-election")},t.isLeader=function(){throw re("leader-election")},t.waitForLeadership=function(){throw re("leader-election")},t.migrationStates=function(){throw re("migration")},t.destroy=async function(){return this.destroyed||(this.destroyed=!0,await Gt("preDestroyRxDatabase",this),this.eventBulks$.complete(),this._subs.map(n=>n.unsubscribe()),this.name==="pseudoInstance")?Fe:this.requestIdlePromise().then(()=>Promise.all(this.onDestroy.map(n=>n()))).then(()=>Promise.all(Object.keys(this.collections).map(n=>this.collections[n]).map(n=>n.destroy()))).then(()=>this.internalStore.close()).then(()=>mi.delete(this.name)).then(()=>!0)},t.remove=function(){return this.destroy().then(()=>rg(this.name,this.storage))},$r(e,[{key:"$",get:function(){return this.observable$}},{key:"asRxDatabase",get:function(){return this}}]),e}();function eg(e){if(mi.has(e))throw D("DB8",{name:e,link:"https://pubkey.github.io/rxdb/rx-database.html#ignoreduplicate"})}async function Gl(e,t,r,n,i,o){var s=await t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:ny,schema:ta,options:n,multiInstance:i,password:o,devMode:ce.isDevMode()});return s}function tg({storage:e,instanceCreationOptions:t,name:r,password:n,multiInstance:i=!0,eventReduce:o=!1,ignoreDuplicate:s=!1,options:a={},cleanupPolicy:u,allowSlowCount:c=!1,localDocuments:l=!1,hashFunction:h=Wr}){Be("preCreateRxDatabase",{storage:e,instanceCreationOptions:t,name:r,password:n,multiInstance:i,eventReduce:o,ignoreDuplicate:s,options:a,localDocuments:l}),s||eg(r),mi.add(r);var p=Ti(10);return Gl(p,e,r,t,i,n).catch(y=>{throw mi.delete(r),y}).then(y=>{var b=new ia(r,p,e,t,n,i,o,a,y,h,u,c);return Gt("createRxDatabase",{database:b,creator:{storage:e,instanceCreationOptions:t,name:r,password:n,multiInstance:i,eventReduce:o,ignoreDuplicate:s,options:a,localDocuments:l}}).then(()=>b)})}async function rg(e,t){var r=Ti(10),n=await Gl(r,t,e,{},!1),i=await jl(t.statics,n),o=new Set;i.forEach(a=>o.add(a.data.name));var s=Array.from(o);return await Promise.all(s.map(a=>Kl(t,n,r,e,a))),await Gt("postRemoveRxDatabase",{databaseName:e,storage:t}),await n.remove(),s}async function ng(e){if(await e.storageToken,e.startupErrors[0])throw e.startupErrors[0]}var ig={RxSchema:vl.prototype,RxDocument:gn,RxQuery:Fl.prototype,RxCollection:ra.prototype,RxDatabase:ia.prototype},lo=new Set,gu=new Set;function Lr(e){if(Be("preAddRxPlugin",{plugin:e,plugins:lo}),!lo.has(e)){{if(gu.has(e.name))throw D("PL3",{name:e.name,plugin:e});lo.add(e),gu.add(e.name)}if(!e.rxdb)throw ue("PL1",{plugin:e});e.init&&e.init(),e.prototypes&&Object.entries(e.prototypes).forEach(([t,r])=>r(ig[t])),e.overwritable&&Object.assign(ce,e.overwritable),e.hooks&&Object.entries(e.hooks).forEach(([t,r])=>{r.after&&on[t].push(r.after),r.before&&on[t].unshift(r.before)})}}var og={prepareQuery(e,t){if(!t.sort)throw D("SNH",{query:t});var r=sm(e,t);return{query:t,queryPlan:r}},checkpointSchema:ry};function sg(e){return e&&typeof e.then=="function"}Promise.resolve(!1);var ag=Promise.resolve(!0),lt=Promise.resolve();function Ft(e,t){return e||(e=0),new Promise(function(r){return setTimeout(function(){return r(t)},e)})}function ug(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function xn(){return Math.random().toString(36).substring(2)}var bu=0,fo=0;function Fi(){var e=(new Date).getTime();return e===bu?(fo++,e*1e3+fo):(bu=e,fo=0,e*1e3)}function cg(){return typeof navigator<"u"&&typeof navigator.locks<"u"&&typeof navigator.locks.request=="function"}var lg=Fi,fg="native";function hg(e){var t={messagesCallback:null,bc:new BroadcastChannel(e),subFns:[]};return t.bc.onmessage=function(r){t.messagesCallback&&t.messagesCallback(r.data)},t}function dg(e){e.bc.close(),e.subFns=[]}function pg(e,t){try{return e.bc.postMessage(t,!1),lt}catch(r){return Promise.reject(r)}}function yg(e,t){e.messagesCallback=t}function mg(){if((typeof window<"u"||typeof self<"u")&&typeof BroadcastChannel=="function"){if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0}else return!1}function vg(){return 150}var gg={create:hg,close:dg,onMessage:yg,postMessage:pg,canBeUsed:mg,type:fg,averageResponseTime:vg,microSeconds:lg};function oa(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=JSON.parse(JSON.stringify(e));return typeof t.webWorkerSupport>"u"&&(t.webWorkerSupport=!0),t.idb||(t.idb={}),t.idb.ttl||(t.idb.ttl=1e3*45),t.idb.fallbackInterval||(t.idb.fallbackInterval=150),e.idb&&typeof e.idb.onclose=="function"&&(t.idb.onclose=e.idb.onclose),t.localstorage||(t.localstorage={}),t.localstorage.removeTimeout||(t.localstorage.removeTimeout=1e3*60),e.methods&&(t.methods=e.methods),t.node||(t.node={}),t.node.ttl||(t.node.ttl=1e3*60*2),t.node.maxParallelWrites||(t.node.maxParallelWrites=2048),typeof t.node.useFastPath>"u"&&(t.node.useFastPath=!0),t}var bg=Fi,wg="pubkey.broadcast-channel-0-",vt="messages",Ni={durability:"relaxed"},_g="idb";function Vl(){if(typeof indexedDB<"u")return indexedDB;if(typeof window<"u"){if(typeof window.mozIndexedDB<"u")return window.mozIndexedDB;if(typeof window.webkitIndexedDB<"u")return window.webkitIndexedDB;if(typeof window.msIndexedDB<"u")return window.msIndexedDB}return!1}function sa(e){e.commit&&e.commit()}function xg(e){var t=Vl(),r=wg+e,n=t.open(r);return n.onupgradeneeded=function(i){var o=i.target.result;o.createObjectStore(vt,{keyPath:"id",autoIncrement:!0})},new Promise(function(i,o){n.onerror=function(s){return o(s)},n.onsuccess=function(){i(n.result)}})}function Eg(e,t,r){var n=(new Date).getTime(),i={uuid:t,time:n,data:r},o=e.transaction([vt],"readwrite",Ni);return new Promise(function(s,a){o.oncomplete=function(){return s()},o.onerror=function(c){return a(c)};var u=o.objectStore(vt);u.add(i),sa(o)})}function Sg(e,t){var r=e.transaction(vt,"readonly",Ni),n=r.objectStore(vt),i=[],o=IDBKeyRange.bound(t+1,1/0);if(n.getAll){var s=n.getAll(o);return new Promise(function(u,c){s.onerror=function(l){return c(l)},s.onsuccess=function(l){u(l.target.result)}})}function a(){try{return o=IDBKeyRange.bound(t+1,1/0),n.openCursor(o)}catch{return n.openCursor()}}return new Promise(function(u,c){var l=a();l.onerror=function(h){return c(h)},l.onsuccess=function(h){var p=h.target.result;p?p.value.id<t+1?p.continue(t+1):(i.push(p.value),p.continue()):(sa(r),u(i))}})}function Og(e,t){if(e.closed)return Promise.resolve([]);var r=e.db.transaction(vt,"readwrite",Ni),n=r.objectStore(vt);return Promise.all(t.map(function(i){var o=n.delete(i);return new Promise(function(s){o.onsuccess=function(){return s()}})}))}function Ag(e,t){var r=(new Date).getTime()-t,n=e.transaction(vt,"readonly",Ni),i=n.objectStore(vt),o=[];return new Promise(function(s){i.openCursor().onsuccess=function(a){var u=a.target.result;if(u){var c=u.value;c.time<r?(o.push(c),u.continue()):(sa(n),s(o))}else s(o)}})}function Cg(e){return Ag(e.db,e.options.idb.ttl).then(function(t){return Og(e,t.map(function(r){return r.id}))})}function Dg(e,t){return t=oa(t),xg(e).then(function(r){var n={closed:!1,lastCursorId:0,channelName:e,options:t,uuid:xn(),eMIs:new na(t.idb.ttl*2),writeBlockPromise:lt,messagesCallback:null,readQueuePromises:[],db:r};return r.onclose=function(){n.closed=!0,t.idb.onclose&&t.idb.onclose()},Jl(n),n})}function Jl(e){e.closed||Yl(e).then(function(){return Ft(e.options.idb.fallbackInterval)}).then(function(){return Jl(e)})}function Pg(e,t){return!(e.uuid===t.uuid||t.eMIs.has(e.id)||e.data.time<t.messagesCallbackTime)}function Yl(e){return e.closed||!e.messagesCallback?lt:Sg(e.db,e.lastCursorId).then(function(t){var r=t.filter(function(n){return!!n}).map(function(n){return n.id>e.lastCursorId&&(e.lastCursorId=n.id),n}).filter(function(n){return Pg(n,e)}).sort(function(n,i){return n.time-i.time});return r.forEach(function(n){e.messagesCallback&&(e.eMIs.add(n.id),e.messagesCallback(n.data))}),lt})}function Ig(e){e.closed=!0,e.db.close()}function Rg(e,t){return e.writeBlockPromise=e.writeBlockPromise.then(function(){return Eg(e.db,e.uuid,t)}).then(function(){ug(0,10)===0&&Cg(e)}),e.writeBlockPromise}function kg(e,t,r){e.messagesCallbackTime=r,e.messagesCallback=t,Yl(e)}function Tg(){return!!Vl()}function $g(e){return e.idb.fallbackInterval*2}var Bg={create:Dg,close:Ig,onMessage:kg,postMessage:Rg,canBeUsed:Tg,type:_g,averageResponseTime:$g,microSeconds:bg},Mg=Fi,Lg="pubkey.broadcastChannel-",Fg="localstorage";function Xl(){var e;if(typeof window>"u")return null;try{e=window.localStorage,e=window["ie8-eventlistener/storage"]||window.localStorage}catch{}return e}function Zl(e){return Lg+e}function Ng(e,t){return new Promise(function(r){Ft().then(function(){var n=Zl(e.channelName),i={token:xn(),time:(new Date).getTime(),data:t,uuid:e.uuid},o=JSON.stringify(i);Xl().setItem(n,o);var s=document.createEvent("Event");s.initEvent("storage",!0,!0),s.key=n,s.newValue=o,window.dispatchEvent(s),r()})})}function jg(e,t){var r=Zl(e),n=function(o){o.key===r&&t(JSON.parse(o.newValue))};return window.addEventListener("storage",n),n}function Ug(e){window.removeEventListener("storage",e)}function Kg(e,t){if(t=oa(t),!ef())throw new Error("BroadcastChannel: localstorage cannot be used");var r=xn(),n=new na(t.localstorage.removeTimeout),i={channelName:e,uuid:r,eMIs:n};return i.listener=jg(e,function(o){i.messagesCallback&&o.uuid!==r&&(!o.token||n.has(o.token)||o.data.time&&o.data.time<i.messagesCallbackTime||(n.add(o.token),i.messagesCallback(o.data)))}),i}function qg(e){Ug(e.listener)}function Hg(e,t,r){e.messagesCallbackTime=r,e.messagesCallback=t}function ef(){var e=Xl();if(!e)return!1;try{var t="__broadcastchannel_check";e.setItem(t,"works"),e.removeItem(t)}catch{return!1}return!0}function Wg(){var e=120,t=navigator.userAgent.toLowerCase();return t.includes("safari")&&!t.includes("chrome")?e*2:e}var Qg={create:Kg,close:qg,onMessage:Hg,postMessage:Ng,canBeUsed:ef,type:Fg,averageResponseTime:Wg,microSeconds:Mg},zg=Fi,Gg="simulate",aa=new Set;function Vg(e){var t={name:e,messagesCallback:null};return aa.add(t),t}function Jg(e){aa.delete(e)}function Yg(e,t){return new Promise(function(r){return setTimeout(function(){var n=Array.from(aa);n.filter(function(i){return i.name===e.name}).filter(function(i){return i!==e}).filter(function(i){return!!i.messagesCallback}).forEach(function(i){return i.messagesCallback(t)}),r()},5)})}function Xg(e,t){e.messagesCallback=t}function Zg(){return!0}function e0(){return 5}var t0={create:Vg,close:Jg,onMessage:Xg,postMessage:Yg,canBeUsed:Zg,type:Gg,averageResponseTime:e0,microSeconds:zg},wu=[gg,Bg,Qg];function r0(e){var t=[].concat(e.methods,wu).filter(Boolean);if(e.type){if(e.type==="simulate")return t0;var r=t.find(function(i){return i.type===e.type});if(r)return r;throw new Error("method-type "+e.type+" not found")}e.webWorkerSupport||(t=t.filter(function(i){return i.type!=="idb"}));var n=t.find(function(i){return i.canBeUsed()});if(n)return n;throw new Error("No usable method found in "+JSON.stringify(wu.map(function(i){return i.type})))}var tf=new Set,n0=0,ji=function(t,r){this.id=n0++,tf.add(this),this.name=t,_u&&(r=_u),this.options=oa(r),this.method=r0(this.options),this._iL=!1,this._onML=null,this._addEL={message:[],internal:[]},this._uMP=new Set,this._befC=[],this._prepP=null,i0(this)};ji._pubkey=!0;var _u;ji.prototype={postMessage:function(t){if(this.closed)throw new Error("BroadcastChannel.postMessage(): Cannot post message after channel has closed "+JSON.stringify(t));return xu(this,"message",t)},postInternal:function(t){return xu(this,"internal",t)},set onmessage(e){var t=this.method.microSeconds(),r={time:t,fn:e};Su(this,"message",this._onML),e&&typeof e=="function"?(this._onML=r,Eu(this,"message",r)):this._onML=null},addEventListener:function(t,r){var n=this.method.microSeconds(),i={time:n,fn:r};Eu(this,t,i)},removeEventListener:function(t,r){var n=this._addEL[t].find(function(i){return i.fn===r});Su(this,t,n)},close:function(){var t=this;if(!this.closed){tf.delete(this),this.closed=!0;var r=this._prepP?this._prepP:lt;return this._onML=null,this._addEL.message=[],r.then(function(){return Promise.all(Array.from(t._uMP))}).then(function(){return Promise.all(t._befC.map(function(n){return n()}))}).then(function(){return t.method.close(t._state)})}},get type(){return this.method.type},get isClosed(){return this.closed}};function xu(e,t,r){var n=e.method.microSeconds(),i={time:n,type:t,data:r},o=e._prepP?e._prepP:lt;return o.then(function(){var s=e.method.postMessage(e._state,i);return e._uMP.add(s),s.catch().then(function(){return e._uMP.delete(s)}),s})}function i0(e){var t=e.method.create(e.name,e.options);sg(t)?(e._prepP=t,t.then(function(r){e._state=r})):e._state=t}function rf(e){return e._addEL.message.length>0||e._addEL.internal.length>0}function Eu(e,t,r){e._addEL[t].push(r),o0(e)}function Su(e,t,r){e._addEL[t]=e._addEL[t].filter(function(n){return n!==r}),s0(e)}function o0(e){if(!e._iL&&rf(e)){var t=function(i){e._addEL[i.type].forEach(function(o){var s=1e5,a=o.time-s;i.time>=a&&o.fn(i.data)})},r=e.method.microSeconds();e._prepP?e._prepP.then(function(){e._iL=!0,e.method.onMessage(e._state,t,r)}):(e._iL=!0,e.method.onMessage(e._state,t,r))}}function s0(e){if(e._iL&&!rf(e)){e._iL=!1;var t=e.method.microSeconds();e.method.onMessage(e._state,null,t)}}function a0(e){if(typeof WorkerGlobalScope=="function"&&self instanceof WorkerGlobalScope){var t=self.close.bind(self);self.close=function(){return e(),t()}}else{if(typeof window.addEventListener!="function")return;window.addEventListener("beforeunload",function(){e()},!0),window.addEventListener("unload",function(){e()},!0)}}function u0(e){process.on("exit",function(){return e()}),process.on("beforeExit",function(){return e().then(function(){return process.exit()})}),process.on("SIGINT",function(){return e().then(function(){return process.exit()})}),process.on("uncaughtException",function(t){return e().then(function(){console.trace(t),process.exit(101)})})}var c0=Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",l0=c0?u0:a0,Qr=new Set,Ou=!1;function f0(){Ou||(Ou=!0,l0(d0))}function h0(e){if(f0(),typeof e!="function")throw new Error("Listener is no function");Qr.add(e);var t={remove:function(){return Qr.delete(e)},run:function(){return Qr.delete(e),e()}};return t}function d0(){var e=[];return Qr.forEach(function(t){e.push(t()),Qr.delete(t)}),Promise.all(e)}function Kt(e,t){var r={context:"leader",action:t,token:e.token};return e.broadcastChannel.postInternal(r)}function nf(e){e.isLeader=!0,e._hasLeader=!0;var t=h0(function(){return e.die()});e._unl.push(t);var r=function(i){i.context==="leader"&&i.action==="apply"&&Kt(e,"tell"),i.context==="leader"&&i.action==="tell"&&!e._dpLC&&(e._dpLC=!0,e._dpL(),Kt(e,"tell"))};return e.broadcastChannel.addEventListener("internal",r),e._lstns.push(r),Kt(e,"tell")}var of=function(t,r){var n=this;this.broadcastChannel=t,t._befC.push(function(){return n.die()}),this._options=r,this.isLeader=!1,this.isDead=!1,this.token=xn(),this._lstns=[],this._unl=[],this._dpL=function(){},this._dpLC=!1,this._wKMC={},this.lN="pubkey-bc||"+t.method.type+"||"+t.name};of.prototype={hasLeader:function(){var t=this;return navigator.locks.query().then(function(r){var n=r.held?r.held.filter(function(i){return i.name===t.lN}):[];return!!(n&&n.length>0)})},awaitLeadership:function(){var t=this;if(!this._wLMP){this._wKMC.c=new AbortController;var r=new Promise(function(n,i){t._wKMC.res=n,t._wKMC.rej=i});this._wLMP=new Promise(function(n){navigator.locks.request(t.lN,{signal:t._wKMC.c.signal},function(){return t._wKMC.c=void 0,nf(t),n(),r}).catch(function(){})})}return this._wLMP},set onduplicate(e){},die:function(){var t=this;return this._lstns.forEach(function(r){return t.broadcastChannel.removeEventListener("internal",r)}),this._lstns=[],this._unl.forEach(function(r){return r.remove()}),this._unl=[],this.isLeader&&(this.isLeader=!1),this.isDead=!0,this._wKMC.res&&this._wKMC.res(),this._wKMC.c&&this._wKMC.c.abort("LeaderElectionWebLock.die() called"),Kt(this,"death")}};var sf=function(t,r){var n=this;this.broadcastChannel=t,this._options=r,this.isLeader=!1,this._hasLeader=!1,this.isDead=!1,this.token=xn(),this._aplQ=lt,this._aplQC=0,this._unl=[],this._lstns=[],this._dpL=function(){},this._dpLC=!1;var i=function(s){s.context==="leader"&&(s.action==="death"&&(n._hasLeader=!1),s.action==="tell"&&(n._hasLeader=!0))};this.broadcastChannel.addEventListener("internal",i),this._lstns.push(i)};sf.prototype={hasLeader:function(){return Promise.resolve(this._hasLeader)},applyOnce:function(t){var r=this;if(this.isLeader)return Ft(0,!0);if(this.isDead)return Ft(0,!1);if(this._aplQC>1)return this._aplQ;var n=function(){if(r.isLeader)return ag;var o=!1,s,a=new Promise(function(l){s=function(){o=!0,l()}}),u=function(h){h.context==="leader"&&h.token!=r.token&&(h.action==="apply"&&h.token>r.token&&s(),h.action==="tell"&&(s(),r._hasLeader=!0))};r.broadcastChannel.addEventListener("internal",u);var c=t?r._options.responseTime*4:r._options.responseTime;return Kt(r,"apply").then(function(){return Promise.race([Ft(c),a.then(function(){return Promise.reject(new Error)})])}).then(function(){return Kt(r,"apply")}).then(function(){return Promise.race([Ft(c),a.then(function(){return Promise.reject(new Error)})])}).catch(function(){}).then(function(){return r.broadcastChannel.removeEventListener("internal",u),o?!1:nf(r).then(function(){return!0})})};return this._aplQC=this._aplQC+1,this._aplQ=this._aplQ.then(function(){return n()}).then(function(){r._aplQC=r._aplQC-1}),this._aplQ.then(function(){return r.isLeader})},awaitLeadership:function(){return this._aLP||(this._aLP=p0(this)),this._aLP},set onduplicate(e){this._dpL=e},die:function(){var t=this;return this._lstns.forEach(function(r){return t.broadcastChannel.removeEventListener("internal",r)}),this._lstns=[],this._unl.forEach(function(r){return r.remove()}),this._unl=[],this.isLeader&&(this._hasLeader=!1,this.isLeader=!1),this.isDead=!0,Kt(this,"death")}};function p0(e){return e.isLeader?lt:new Promise(function(t){var r=!1;function n(){r||(r=!0,e.broadcastChannel.removeEventListener("internal",o),t(!0))}e.applyOnce().then(function(){e.isLeader&&n()});var i=function s(){return Ft(e._options.fallbackInterval).then(function(){if(!(e.isDead||r))if(e.isLeader)n();else return e.applyOnce(!0).then(function(){e.isLeader?n():s()})})};i();var o=function(a){a.context==="leader"&&a.action==="death"&&(e._hasLeader=!1,e.applyOnce().then(function(){e.isLeader&&n()}))};e.broadcastChannel.addEventListener("internal",o),e._lstns.push(o)})}function y0(e,t){return e||(e={}),e=JSON.parse(JSON.stringify(e)),e.fallbackInterval||(e.fallbackInterval=3e3),e.responseTime||(e.responseTime=t.method.averageResponseTime(t.options)),e}function m0(e,t){if(e._leaderElector)throw new Error("BroadcastChannel already has a leader-elector");t=y0(t,e);var r=cg()?new of(e,t):new sf(e,t);return e._befC.push(function(){return r.die()}),e._leaderElector=r,r}var vi=new Map;function af(e,t,r){var n=vi.get(e);return n||(n={bc:new ji("RxDB:"+t),refs:new Set},vi.set(e,n)),n.refs.add(r),n.bc}function Vo(e,t){var r=vi.get(e);if(r&&(r.refs.delete(t),r.refs.size===0))return vi.delete(e),r.bc.close()}function v0(e,t,r,n){if(t.multiInstance){var i=n||af(t.databaseInstanceToken,r.databaseName,r),o=new Ye,s=p=>{p.storageName===e&&p.databaseName===t.databaseName&&p.collectionName===t.collectionName&&p.version===t.schema.version&&o.next(p.eventBulk)};i.addEventListener("message",s);var a=r.changeStream(),u=!1,c=a.subscribe(p=>{u||i.postMessage({storageName:e,databaseName:t.databaseName,collectionName:t.collectionName,version:t.schema.version,eventBulk:p})});r.changeStream=function(){return o.asObservable().pipe(Gp(a))};var l=r.close.bind(r);r.close=async function(){return u=!0,c.unsubscribe(),i.removeEventListener("message",s),n||await Vo(t.databaseInstanceToken,r),l()};var h=r.remove.bind(r);r.remove=async function(){return u=!0,c.unsubscribe(),i.removeEventListener("message",s),n||await Vo(t.databaseInstanceToken,r),h()}}}var uf=new WeakMap,g0=new WeakMap;function Jo(e){return Je(g0,e,()=>m0(e))}function b0(){var e=af(this.token,this.name,this),t=this.destroy.bind(this);this.destroy=function(){return Vo(this.token,this),t()};var r=Jo(e);return r||(r=Jo(e),uf.set(this,r)),this.leaderElector=()=>r,r}function w0(){return this.multiInstance?this.leaderElector().isLeader:!0}function _0(){return this.multiInstance?this.leaderElector().awaitLeadership().then(()=>!0):Td}function x0(e){var t=uf.get(e);t&&t.die()}var E0=!0,S0={RxDatabase:e=>{e.leaderElector=b0,e.isLeader=w0,e.waitForLeadership=_0}},O0={name:"leader-election",rxdb:E0,prototypes:S0,hooks:{preDestroyRxDatabase:{after:x0}}},A0=["__proto__","constructor","prototype"];function Kr(e,t){Object.keys(t).forEach(r=>{A0.includes(r)||(typeof e[r]>"u"?e[r]=t[r]:zr(t[r])?Kr(e[r],t[r]):e[r]=t[r])})}function zr(e){return e.toString()==="[object Object]"}var Ui=function(){function e(r,n){if(this.options={},this._conditions={},this._fields={},this._path=n,r){var i=this;r.selector&&i.find(r.selector),r.limit&&i.limit(r.limit),r.skip&&i.skip(r.skip),r.sort&&r.sort.forEach(o=>i.sort(o))}}var t=e.prototype;return t.where=function(n,i){if(!arguments.length)return this;var o=typeof arguments[0];if(o==="string")return this._path=arguments[0],arguments.length===2&&(this._conditions[this._path]=arguments[1]),this;if(o==="object"&&!Array.isArray(arguments[0]))return this.merge(arguments[0]);throw ue("MQ1",{path:arguments[0]})},t.equals=function(n){this._ensurePath("equals");var i=this._path;return this._conditions[i]=n,this},t.eq=function(n){this._ensurePath("eq");var i=this._path;return this._conditions[i]=n,this},t.or=function(n){var i=this._conditions.$or||(this._conditions.$or=[]);return Array.isArray(n)||(n=[n]),i.push.apply(i,n),this},t.nor=function(n){var i=this._conditions.$nor||(this._conditions.$nor=[]);return Array.isArray(n)||(n=[n]),i.push.apply(i,n),this},t.and=function(n){var i=this._conditions.$and||(this._conditions.$and=[]);return Array.isArray(n)||(n=[n]),i.push.apply(i,n),this},t.mod=function(n,i){var o,s;arguments.length===1?(this._ensurePath("mod"),o=arguments[0],s=this._path):arguments.length===2&&!Array.isArray(arguments[1])?(this._ensurePath("mod"),o=arguments.slice(),s=this._path):arguments.length===3?(o=arguments.slice(1),s=arguments[0]):(o=arguments[1],s=arguments[0]);var a=this._conditions[s]||(this._conditions[s]={});return a.$mod=o,this},t.exists=function(n,i){var o,s;arguments.length===0?(this._ensurePath("exists"),o=this._path,s=!0):arguments.length===1?typeof arguments[0]=="boolean"?(this._ensurePath("exists"),o=this._path,s=arguments[0]):(o=arguments[0],s=!0):arguments.length===2&&(o=arguments[0],s=arguments[1]);var a=this._conditions[o]||(this._conditions[o]={});return a.$exists=s,this},t.elemMatch=function(n,i){if(arguments[0]===null)throw ue("MQ2");var o,s,a;if(typeof arguments[0]=="function")this._ensurePath("elemMatch"),s=this._path,o=arguments[0];else if(zr(arguments[0]))this._ensurePath("elemMatch"),s=this._path,a=arguments[0];else if(typeof arguments[1]=="function")s=arguments[0],o=arguments[1];else if(arguments[1]&&zr(arguments[1]))s=arguments[0],a=arguments[1];else throw ue("MQ2");o&&(a=new e,o(a),a=a._conditions);var u=this._conditions[s]||(this._conditions[s]={});return u.$elemMatch=a,this},t.sort=function(n){if(!n)return this;var i,o=typeof n;if(Array.isArray(n)){i=n.length;for(var s=0;s<n.length;++s)D0(this.options,n[s][0],n[s][1]);return this}if(arguments.length===1&&o==="string"){n=n.split(/\s+/),i=n.length;for(var a=0;a<i;++a){var u=n[a];if(u){var c=u[0]==="-"?-1:1;c===-1&&(u=u.substring(1)),Au(this.options,u,c)}}return this}if(zr(n)){var l=Object.keys(n);return l.forEach(h=>Au(this.options,h,n[h])),this}throw ue("MQ3",{args:arguments})},t.merge=function(n){if(!n)return this;if(!Cu(n))throw ue("MQ4",{source:n});return n instanceof e?(n._conditions&&Kr(this._conditions,n._conditions),n._fields&&(this._fields||(this._fields={}),Kr(this._fields,n._fields)),n.options&&(this.options||(this.options={}),Kr(this.options,n.options)),n._distinct&&(this._distinct=n._distinct),this):(Kr(this._conditions,n),this)},t.find=function(n){return Cu(n)&&this.merge(n),this},t._ensurePath=function(n){if(!this._path)throw D("MQ5",{method:n})},t.toJSON=function(){var n={selector:this._conditions};return this.options.skip&&(n.skip=this.options.skip),this.options.limit&&(n.limit=this.options.limit),this.options.sort&&(n.sort=C0(this.options.sort)),{query:n,path:this._path}},e}();function C0(e){return Object.entries(e).map(([t,r])=>{var n=r===1?"asc":"desc",i={[t]:n};return i})}var cf=["limit","skip","maxScan","batchSize","comment"];cf.forEach(function(e){Ui.prototype[e]=function(t){return this.options[e]=t,this}});var lf=["gt","gte","lt","lte","ne","in","nin","all","regex","size"];lf.forEach(function(e){Ui.prototype[e]=function(){var t,r;arguments.length===1?(this._ensurePath(e),r=arguments[0],t=this._path):(r=arguments[1],t=arguments[0]);var n=this._conditions[t]===null||typeof this._conditions[t]=="object"?this._conditions[t]:this._conditions[t]={};return n["$"+e]=r,this}});function Au(e,t,r){if(Array.isArray(e.sort))throw ue("MQ6",{opts:e,field:t,value:r});if(r&&r.$meta){var n=e.sort||(e.sort={});n[t]={$meta:r.$meta};return}var i=String(r||1).toLowerCase();if(!/^(?:ascending|asc|descending|desc|1|-1)$/.test(i))throw Array.isArray(r)&&(r="["+r+"]"),ue("MQ7",{field:t,value:r});var o=e.sort||(e.sort={}),s=r.toString().replace("asc","1").replace("ascending","1").replace("desc","-1").replace("descending","-1");o[t]=parseInt(s,10)}function D0(e,t,r){if(e.sort=e.sort||[],!Array.isArray(e.sort))throw ue("MQ8",{opts:e,field:t,value:r});e.sort.push([t,r])}function Cu(e){return e instanceof Ui||zr(e)}function P0(e,t){return new Ui(e,t)}var Du="queryBuilderPath";function I0(e,t,r){var n=P0(at(e.mangoQuery),e.other[Du]);n[t](r);var i=n.toJSON();return cr(e.op,i.query,e.collection,{...e.other,[Du]:i.path})}function ho(e,t){e[t]=function(r){return I0(this,t,r)}}var R0={name:"query-builder",rxdb:!0,prototypes:{RxQuery(e){["where","equals","eq","or","nor","and","mod","exists","elemMatch","sort"].forEach(t=>{ho(e,t)}),cf.forEach(t=>{ho(e,t)}),lf.forEach(t=>{ho(e,t)})}}},ff={exports:{}};(function(e){var t=function(){function r(p,y){return y!=null&&p instanceof y}var n;try{n=Map}catch{n=function(){}}var i;try{i=Set}catch{i=function(){}}var o;try{o=Promise}catch{o=function(){}}function s(p,y,b,g,E){typeof y=="object"&&(b=y.depth,g=y.prototype,E=y.includeNonEnumerable,y=y.circular);var w=[],_=[],A=typeof Buffer<"u";typeof y>"u"&&(y=!0),typeof b>"u"&&(b=1/0);function R(O,C){if(O===null)return null;if(C===0)return O;var S,k;if(typeof O!="object")return O;if(r(O,n))S=new n;else if(r(O,i))S=new i;else if(r(O,o))S=new o(function(z,he){O.then(function(ye){z(R(ye,C-1))},function(ye){he(R(ye,C-1))})});else if(s.__isArray(O))S=[];else if(s.__isRegExp(O))S=new RegExp(O.source,h(O)),O.lastIndex&&(S.lastIndex=O.lastIndex);else if(s.__isDate(O))S=new Date(O.getTime());else{if(A&&Buffer.isBuffer(O))return Buffer.allocUnsafe?S=Buffer.allocUnsafe(O.length):S=new Buffer(O.length),O.copy(S),S;r(O,Error)?S=Object.create(O):typeof g>"u"?(k=Object.getPrototypeOf(O),S=Object.create(k)):(S=Object.create(g),k=g)}if(y){var T=w.indexOf(O);if(T!=-1)return _[T];w.push(O),_.push(S)}r(O,n)&&O.forEach(function(z,he){var ye=R(he,C-1),qe=R(z,C-1);S.set(ye,qe)}),r(O,i)&&O.forEach(function(z){var he=R(z,C-1);S.add(he)});for(var F in O){var W;k&&(W=Object.getOwnPropertyDescriptor(k,F)),!(W&&W.set==null)&&(S[F]=R(O[F],C-1))}if(Object.getOwnPropertySymbols)for(var ne=Object.getOwnPropertySymbols(O),F=0;F<ne.length;F++){var Y=ne[F],K=Object.getOwnPropertyDescriptor(O,Y);K&&!K.enumerable&&!E||(S[Y]=R(O[Y],C-1),K.enumerable||Object.defineProperty(S,Y,{enumerable:!1}))}if(E)for(var ve=Object.getOwnPropertyNames(O),F=0;F<ve.length;F++){var ae=ve[F],K=Object.getOwnPropertyDescriptor(O,ae);K&&K.enumerable||(S[ae]=R(O[ae],C-1),Object.defineProperty(S,ae,{enumerable:!1}))}return S}return R(p,b)}s.clonePrototype=function(y){if(y===null)return null;var b=function(){};return b.prototype=y,new b};function a(p){return Object.prototype.toString.call(p)}s.__objToStr=a;function u(p){return typeof p=="object"&&a(p)==="[object Date]"}s.__isDate=u;function c(p){return typeof p=="object"&&a(p)==="[object Array]"}s.__isArray=c;function l(p){return typeof p=="object"&&a(p)==="[object RegExp]"}s.__isRegExp=l;function h(p){var y="";return p.global&&(y+="g"),p.ignoreCase&&(y+="i"),p.multiline&&(y+="m"),y}return s.__getRegExpFlags=h,s}();e.exports&&(e.exports=t)})(ff);var k0=ff.exports,Pu=Object.prototype.toString,hf=function(t){var r=Pu.call(t),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&Pu.call(t.callee)==="[object Function]"),n},po,Iu;function T0(){if(Iu)return po;Iu=1;var e;if(!Object.keys){var t=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=hf,i=Object.prototype.propertyIsEnumerable,o=!i.call({toString:null},"toString"),s=i.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],u=function(p){var y=p.constructor;return y&&y.prototype===p},c={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},l=function(){if(typeof window>"u")return!1;for(var p in window)try{if(!c["$"+p]&&t.call(window,p)&&window[p]!==null&&typeof window[p]=="object")try{u(window[p])}catch{return!0}}catch{return!0}return!1}(),h=function(p){if(typeof window>"u"||!l)return u(p);try{return u(p)}catch{return!1}};e=function(y){var b=y!==null&&typeof y=="object",g=r.call(y)==="[object Function]",E=n(y),w=b&&r.call(y)==="[object String]",_=[];if(!b&&!g&&!E)throw new TypeError("Object.keys called on a non-object");var A=s&&g;if(w&&y.length>0&&!t.call(y,0))for(var R=0;R<y.length;++R)_.push(String(R));if(E&&y.length>0)for(var O=0;O<y.length;++O)_.push(String(O));else for(var C in y)!(A&&C==="prototype")&&t.call(y,C)&&_.push(String(C));if(o)for(var S=h(y),k=0;k<a.length;++k)!(S&&a[k]==="constructor")&&t.call(y,a[k])&&_.push(a[k]);return _}}return po=e,po}var $0=Array.prototype.slice,B0=hf,Ru=Object.keys,Zn=Ru?function(t){return Ru(t)}:T0(),ku=Object.keys;Zn.shim=function(){if(Object.keys){var t=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);t||(Object.keys=function(n){return B0(n)?ku($0.call(n)):ku(n)})}else Object.keys=Zn;return Object.keys||Zn};var df=Zn,pf=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[r]=i;for(r in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(t,r);if(s.value!==i||s.enumerable!==!0)return!1}return!0},M0=pf,ua=function(){return M0()&&!!Symbol.toStringTag},Tu=typeof Symbol<"u"&&Symbol,L0=pf,F0=function(){return typeof Tu!="function"||typeof Symbol!="function"||typeof Tu("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:L0()},$u={foo:{}},N0=Object,j0=function(){return{__proto__:$u}.foo===$u.foo&&!({__proto__:null}instanceof N0)},U0="Function.prototype.bind called on incompatible ",yo=Array.prototype.slice,K0=Object.prototype.toString,q0="[object Function]",H0=function(t){var r=this;if(typeof r!="function"||K0.call(r)!==q0)throw new TypeError(U0+r);for(var n=yo.call(arguments,1),i,o=function(){if(this instanceof i){var l=r.apply(this,n.concat(yo.call(arguments)));return Object(l)===l?l:this}else return r.apply(t,n.concat(yo.call(arguments)))},s=Math.max(0,r.length-n.length),a=[],u=0;u<s;u++)a.push("$"+u);if(i=Function("binder","return function ("+a.join(",")+"){ return binder.apply(this,arguments); }")(o),r.prototype){var c=function(){};c.prototype=r.prototype,i.prototype=new c,c.prototype=null}return i},W0=H0,ca=Function.prototype.bind||W0,Q0=ca,z0=Q0.call(Function.call,Object.prototype.hasOwnProperty),j,Ir=SyntaxError,yf=Function,br=TypeError,mo=function(e){try{return yf('"use strict"; return ('+e+").constructor;")()}catch{}},qt=Object.getOwnPropertyDescriptor;if(qt)try{qt({},"")}catch{qt=null}var vo=function(){throw new br},G0=qt?function(){try{return arguments.callee,vo}catch{try{return qt(arguments,"callee").get}catch{return vo}}}():vo,ir=F0(),V0=j0(),me=Object.getPrototypeOf||(V0?function(e){return e.__proto__}:null),lr={},J0=typeof Uint8Array>"u"||!me?j:me(Uint8Array),Ht={"%AggregateError%":typeof AggregateError>"u"?j:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?j:ArrayBuffer,"%ArrayIteratorPrototype%":ir&&me?me([][Symbol.iterator]()):j,"%AsyncFromSyncIteratorPrototype%":j,"%AsyncFunction%":lr,"%AsyncGenerator%":lr,"%AsyncGeneratorFunction%":lr,"%AsyncIteratorPrototype%":lr,"%Atomics%":typeof Atomics>"u"?j:Atomics,"%BigInt%":typeof BigInt>"u"?j:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?j:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?j:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?j:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?j:Float32Array,"%Float64Array%":typeof Float64Array>"u"?j:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?j:FinalizationRegistry,"%Function%":yf,"%GeneratorFunction%":lr,"%Int8Array%":typeof Int8Array>"u"?j:Int8Array,"%Int16Array%":typeof Int16Array>"u"?j:Int16Array,"%Int32Array%":typeof Int32Array>"u"?j:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":ir&&me?me(me([][Symbol.iterator]())):j,"%JSON%":typeof JSON=="object"?JSON:j,"%Map%":typeof Map>"u"?j:Map,"%MapIteratorPrototype%":typeof Map>"u"||!ir||!me?j:me((new Map)[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?j:Promise,"%Proxy%":typeof Proxy>"u"?j:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?j:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?j:Set,"%SetIteratorPrototype%":typeof Set>"u"||!ir||!me?j:me((new Set)[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?j:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":ir&&me?me(""[Symbol.iterator]()):j,"%Symbol%":ir?Symbol:j,"%SyntaxError%":Ir,"%ThrowTypeError%":G0,"%TypedArray%":J0,"%TypeError%":br,"%Uint8Array%":typeof Uint8Array>"u"?j:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?j:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?j:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?j:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?j:WeakMap,"%WeakRef%":typeof WeakRef>"u"?j:WeakRef,"%WeakSet%":typeof WeakSet>"u"?j:WeakSet};if(me)try{null.error}catch(e){var Y0=me(me(e));Ht["%Error.prototype%"]=Y0}var X0=function e(t){var r;if(t==="%AsyncFunction%")r=mo("async function () {}");else if(t==="%GeneratorFunction%")r=mo("function* () {}");else if(t==="%AsyncGeneratorFunction%")r=mo("async function* () {}");else if(t==="%AsyncGenerator%"){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=e("%AsyncGenerator%");i&&me&&(r=me(i.prototype))}return Ht[t]=r,r},Bu={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},En=ca,gi=z0,Z0=En.call(Function.call,Array.prototype.concat),eb=En.call(Function.apply,Array.prototype.splice),Mu=En.call(Function.call,String.prototype.replace),bi=En.call(Function.call,String.prototype.slice),tb=En.call(Function.call,RegExp.prototype.exec),rb=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,nb=/\\(\\)?/g,ib=function(t){var r=bi(t,0,1),n=bi(t,-1);if(r==="%"&&n!=="%")throw new Ir("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new Ir("invalid intrinsic syntax, expected opening `%`");var i=[];return Mu(t,rb,function(o,s,a,u){i[i.length]=a?Mu(u,nb,"$1"):s||o}),i},ob=function(t,r){var n=t,i;if(gi(Bu,n)&&(i=Bu[n],n="%"+i[0]+"%"),gi(Ht,n)){var o=Ht[n];if(o===lr&&(o=X0(n)),typeof o>"u"&&!r)throw new br("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:o}}throw new Ir("intrinsic "+t+" does not exist!")},Sn=function(t,r){if(typeof t!="string"||t.length===0)throw new br("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new br('"allowMissing" argument must be a boolean');if(tb(/^%?[^%]*%?$/,t)===null)throw new Ir("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=ib(t),i=n.length>0?n[0]:"",o=ob("%"+i+"%",r),s=o.name,a=o.value,u=!1,c=o.alias;c&&(i=c[0],eb(n,Z0([0,1],c)));for(var l=1,h=!0;l<n.length;l+=1){var p=n[l],y=bi(p,0,1),b=bi(p,-1);if((y==='"'||y==="'"||y==="`"||b==='"'||b==="'"||b==="`")&&y!==b)throw new Ir("property names with quotes must have matching quotes");if((p==="constructor"||!h)&&(u=!0),i+="."+p,s="%"+i+"%",gi(Ht,s))a=Ht[s];else if(a!=null){if(!(p in a)){if(!r)throw new br("base intrinsic for "+t+" exists, but the property is not available.");return}if(qt&&l+1>=n.length){var g=qt(a,p);h=!!g,h&&"get"in g&&!("originalValue"in g.get)?a=g.get:a=a[p]}else h=gi(a,p),a=a[p];h&&!u&&(Ht[s]=a)}}return a},mf={exports:{}};(function(e){var t=ca,r=Sn,n=r("%Function.prototype.apply%"),i=r("%Function.prototype.call%"),o=r("%Reflect.apply%",!0)||t.call(i,n),s=r("%Object.getOwnPropertyDescriptor%",!0),a=r("%Object.defineProperty%",!0),u=r("%Math.max%");if(a)try{a({},"a",{value:1})}catch{a=null}e.exports=function(h){var p=o(t,i,arguments);if(s&&a){var y=s(p,"length");y.configurable&&a(p,"length",{value:1+u(0,h.length-(arguments.length-1))})}return p};var c=function(){return o(t,n,arguments)};a?a(e.exports,"apply",{value:c}):e.exports.apply=c})(mf);var la=mf.exports,vf=Sn,gf=la,sb=gf(vf("String.prototype.indexOf")),bf=function(t,r){var n=vf(t,!!r);return typeof n=="function"&&sb(t,".prototype.")>-1?gf(n):n},ab=ua(),ub=bf,Yo=ub("Object.prototype.toString"),Ki=function(t){return ab&&t&&typeof t=="object"&&Symbol.toStringTag in t?!1:Yo(t)==="[object Arguments]"},wf=function(t){return Ki(t)?!0:t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&Yo(t)!=="[object Array]"&&Yo(t.callee)==="[object Function]"},cb=function(){return Ki(arguments)}();Ki.isLegacyArguments=wf;var lb=cb?Ki:wf,fb=Sn,Xo=fb("%Object.defineProperty%",!0),Zo=function(){if(Xo)try{return Xo({},"a",{value:1}),!0}catch{return!1}return!1};Zo.hasArrayLengthDefineBug=function(){if(!Zo())return null;try{return Xo([],"length",{value:1}).length!==1}catch{return!0}};var fa=Zo,go,Lu;function hb(){if(Lu)return go;Lu=1;var e=Sn,t=e("%Object.getOwnPropertyDescriptor%",!0);if(t)try{t([],"length")}catch{t=null}return go=t,go}var db=fa(),ha=Sn,Fu=db&&ha("%Object.defineProperty%",!0),pb=ha("%SyntaxError%"),or=ha("%TypeError%"),Nu=hb(),_f=function(t,r,n){if(!t||typeof t!="object"&&typeof t!="function")throw new or("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new or("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new or("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new or("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new or("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new or("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,s=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,u=!!Nu&&Nu(t,r);if(Fu)Fu(t,r,{configurable:s===null&&u?u.configurable:!s,enumerable:i===null&&u?u.enumerable:!i,value:n,writable:o===null&&u?u.writable:!o});else if(a||!i&&!o&&!s)t[r]=n;else throw new pb("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},yb=df,mb=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",vb=Object.prototype.toString,gb=Array.prototype.concat,ju=_f,bb=function(e){return typeof e=="function"&&vb.call(e)==="[object Function]"},xf=fa(),wb=function(e,t,r,n){if(t in e){if(n===!0){if(e[t]===r)return}else if(!bb(n)||!n())return}xf?ju(e,t,r,!0):ju(e,t,r)},Ef=function(e,t){var r=arguments.length>2?arguments[2]:{},n=yb(t);mb&&(n=gb.call(n,Object.getOwnPropertySymbols(t)));for(var i=0;i<n.length;i+=1)wb(e,n[i],t[n[i]],r[n[i]])};Ef.supportsDescriptors=!!xf;var On=Ef,Uu=function(e){return e!==e},Sf=function(t,r){return t===0&&r===0?1/t===1/r:!!(t===r||Uu(t)&&Uu(r))},_b=Sf,Of=function(){return typeof Object.is=="function"?Object.is:_b},xb=Of,Eb=On,Sb=function(){var t=xb();return Eb(Object,{is:t},{is:function(){return Object.is!==t}}),t},Ob=On,Ab=la,Cb=Sf,Af=Of,Db=Sb,Cf=Ab(Af(),Object);Ob(Cf,{getPolyfill:Af,implementation:Cb,shim:Db});var Pb=Cf,es=bf,Df=ua(),Pf,If,ts,rs;if(Df){Pf=es("Object.prototype.hasOwnProperty"),If=es("RegExp.prototype.exec"),ts={};var bo=function(){throw ts};rs={toString:bo,valueOf:bo},typeof Symbol.toPrimitive=="symbol"&&(rs[Symbol.toPrimitive]=bo)}var Ib=es("Object.prototype.toString"),Rb=Object.getOwnPropertyDescriptor,kb="[object RegExp]",Tb=Df?function(t){if(!t||typeof t!="object")return!1;var r=Rb(t,"lastIndex"),n=r&&Pf(r,"value");if(!n)return!1;try{If(t,rs)}catch(i){return i===ts}}:function(t){return!t||typeof t!="object"&&typeof t!="function"?!1:Ib(t)===kb},sn=function(){return typeof function(){}.name=="string"},Gr=Object.getOwnPropertyDescriptor;if(Gr)try{Gr([],"length")}catch{Gr=null}sn.functionsHaveConfigurableNames=function(){if(!sn()||!Gr)return!1;var t=Gr(function(){},"name");return!!t&&!!t.configurable};var $b=Function.prototype.bind;sn.boundFunctionsHaveNames=function(){return sn()&&typeof $b=="function"&&function(){}.bind().name!==""};var Bb=sn,Ku=_f,Mb=fa(),Lb=Bb.functionsHaveConfigurableNames(),Fb=TypeError,Nb=function(t,r){if(typeof t!="function")throw new Fb("`fn` is not a function");var n=arguments.length>2&&!!arguments[2];return(!n||Lb)&&(Mb?Ku(t,"name",r,!0,!0):Ku(t,"name",r)),t},jb=Nb,Ub=Object,Kb=TypeError,Rf=jb(function(){if(this!=null&&this!==Ub(this))throw new Kb("RegExp.prototype.flags getter called on non-object");var t="";return this.hasIndices&&(t+="d"),this.global&&(t+="g"),this.ignoreCase&&(t+="i"),this.multiline&&(t+="m"),this.dotAll&&(t+="s"),this.unicode&&(t+="u"),this.unicodeSets&&(t+="v"),this.sticky&&(t+="y"),t},"get flags",!0),qb=Rf,Hb=On.supportsDescriptors,Wb=Object.getOwnPropertyDescriptor,kf=function(){if(Hb&&/a/mig.flags==="gim"){var t=Wb(RegExp.prototype,"flags");if(t&&typeof t.get=="function"&&typeof RegExp.prototype.dotAll=="boolean"&&typeof RegExp.prototype.hasIndices=="boolean"){var r="",n={};if(Object.defineProperty(n,"hasIndices",{get:function(){r+="d"}}),Object.defineProperty(n,"sticky",{get:function(){r+="y"}}),r==="dy")return t.get}}return qb},Qb=On.supportsDescriptors,zb=kf,Gb=Object.getOwnPropertyDescriptor,Vb=Object.defineProperty,Jb=TypeError,qu=Object.getPrototypeOf,Yb=/a/,Xb=function(){if(!Qb||!qu)throw new Jb("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var t=zb(),r=qu(Yb),n=Gb(r,"flags");return(!n||n.get!==t)&&Vb(r,"flags",{configurable:!0,enumerable:!1,get:t}),t},Zb=On,ew=la,tw=Rf,Tf=kf,rw=Xb,$f=ew(Tf());Zb($f,{getPolyfill:Tf,implementation:tw,shim:rw});var nw=$f,iw=Date.prototype.getDay,ow=function(t){try{return iw.call(t),!0}catch{return!1}},sw=Object.prototype.toString,aw="[object Date]",uw=ua(),cw=function(t){return typeof t!="object"||t===null?!1:uw?ow(t):sw.call(t)===aw},Hu=df,Wu=lb,Qu=Pb,zu=Tb,Gu=nw,Vu=cw,Ju=Date.prototype.getTime;function Bf(e,t,r){var n=r||{};return(n.strict?Qu(e,t):e===t)?!0:!e||!t||typeof e!="object"&&typeof t!="object"?n.strict?Qu(e,t):e==t:lw(e,t,n)}function Yu(e){return e==null}function Xu(e){return!(!e||typeof e!="object"||typeof e.length!="number"||typeof e.copy!="function"||typeof e.slice!="function"||e.length>0&&typeof e[0]!="number")}function lw(e,t,r){var n,i;if(typeof e!=typeof t||Yu(e)||Yu(t)||e.prototype!==t.prototype||Wu(e)!==Wu(t))return!1;var o=zu(e),s=zu(t);if(o!==s)return!1;if(o||s)return e.source===t.source&&Gu(e)===Gu(t);if(Vu(e)&&Vu(t))return Ju.call(e)===Ju.call(t);var a=Xu(e),u=Xu(t);if(a!==u)return!1;if(a||u){if(e.length!==t.length)return!1;for(n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}if(typeof e!=typeof t)return!1;try{var c=Hu(e),l=Hu(t)}catch{return!1}if(c.length!==l.length)return!1;for(c.sort(),l.sort(),n=c.length-1;n>=0;n--)if(c[n]!=l[n])return!1;for(n=c.length-1;n>=0;n--)if(i=c[n],!Bf(e[i],t[i],r))return!1;return!0}var fw=Bf;function Mf(e){return e&&typeof e=="object"&&"default"in e?e.default:e}var Zu=Mf(k0),ec=Mf(fw),dr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},hw=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},dw=function(e){return(typeof e>"u"?"undefined":dr(e))==="object"&&e!==null},pw=function(e,t){return e.every(function(r){return t&&t(r)||r})},yw=function(e,t){return e.hasOwnProperty(t)},mw=function(e){return Object.keys(e)},Lf=function(e,t){Object.keys(e).forEach(function(r){t(e[r],r)})},vw=function(e){return Array.isArray(e)},Ff=function(e){return!!(typeof Uint8Array<"u"&&e instanceof Uint8Array||e&&e.$Uint8ArrayPolyfill)},Nf={isArray:vw,each:Lf},jf=function(t){return Nf.isArray(t)&&!Ff(t)},gw=function(t){return jf(t)||da(t)},bw=function(t,r){if(!da(t))return!1;var n=void 0;return Nf.each(t,function(i,o){var s=o.substr(0,1)==="$";if(n===void 0)n=s;else if(n!==s){if(!r)throw new Error("Inconsistent operator: "+JSON.stringify(t));n=!1}}),!!n},ww=function(t){return/^[0-9]+$/.test(t)},da=function(e){return!(!e||typeof e=="number"||typeof e=="string"||typeof e=="boolean"||jf(e)||e===null||e instanceof RegExp||typeof e=="function"||e instanceof Date||Ff(e))},N=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof e=="string"&&t.field&&(e+=" for field '"+t.field+"'");var r=new Error(e);return r.name="ModifyJsError",r},_t={all:pw,each:Lf,keys:mw,has:yw,isObject:dw},_w=function(e,t,r){if(!(r&&r.each))return xw(e,t,hw({},r,{returnInsteadOfReplacing:!0}))},xw=function(t,r,n){if(n=n||{},!da(r))throw N("Modifier must be an object");r=Zu(r);var i=bw(r),o;if(i?(o=Zu(t),_t.each(r,function(s,a){var u=Sw[a];if(!u)throw N("Invalid modifier specified "+a);_t.each(s,function(c,l){if(l==="")throw N("An empty update path is not valid.");var h=l.split(".");if(!_t.all(h))throw N("The update path '"+l+"' contains an empty field name, which is not allowed.");var p=Uf(o,h,{noCreate:Ew[a],forbidArray:a==="$rename",arrayIndices:n.arrayIndices}),y=h.pop();u(p,y,c,l,o)})})):o=r,n.returnInsteadOfReplacing)return o;_t.each(_t.keys(t),function(s){s!=="_id"&&delete t[s]}),_t.each(o,function(s,a){t[a]=s})},Uf=function(t,r,n){n=n||{};for(var i=!1,o=0;o<r.length;o++){var s=o===r.length-1,a=r[o],u=gw(t);if(!u){if(n.noCreate)return;var c=N("cannot use the part '"+a+"' to traverse "+t);throw c.setPropertyError=!0,c}if(t instanceof Array){if(n.forbidArray)return null;if(a==="$"){if(i)throw N("Too many positional (i.e. '$') elements");if(!n.arrayIndices||!n.arrayIndices.length)throw N("The positional operator did not find the match needed from the query");a=n.arrayIndices[0],i=!0}else if(ww(a))a=parseInt(a);else{if(n.noCreate)return;throw N("can't append to array using string field name ["+a+"]")}if(s&&(r[o]=a),n.noCreate&&a>=t.length)return;for(;t.length<a;)t.push(null);if(!s){if(t.length===a)t.push({});else if(dr(t[a])!=="object")throw N("can't modify field '"+r[o+1]+"' of list value "+JSON.stringify(t[a]))}}else if(!(a in t)){if(n.noCreate)return;s||(t[a]={})}if(s)return t;t=t[a]}},Ew={$unset:!0,$pop:!0,$rename:!0,$pull:!0,$pullAll:!0},Sw={$currentDate:function(t,r,n){if((typeof n>"u"?"undefined":dr(n))==="object"&&n.hasOwnProperty("$type")){if(n.$type!=="date")throw N("Minimongo does currently only support the date type in $currentDate modifiers",{field:r})}else if(n!==!0)throw N("Invalid $currentDate modifier",{field:r});t[r]=new Date},$min:function(t,r,n){if(typeof n!="number")throw N("Modifier $min allowed for numbers only",{field:r});if(r in t){if(typeof t[r]!="number")throw N("Cannot apply $min modifier to non-number",{field:r});t[r]>n&&(t[r]=n)}else t[r]=n},$max:function(t,r,n){if(typeof n!="number")throw N("Modifier $max allowed for numbers only",{field:r});if(r in t){if(typeof t[r]!="number")throw N("Cannot apply $max modifier to non-number",{field:r});t[r]<n&&(t[r]=n)}else t[r]=n},$inc:function(t,r,n){if(typeof n!="number")throw N("Modifier $inc allowed for numbers only",{field:r});if(r in t){if(typeof t[r]!="number")throw N("Cannot apply $inc modifier to non-number",{field:r});t[r]+=n}else t[r]=n},$set:function(t,r,n){if(!_t.isObject(t)){var i=N("Cannot set property on non-object field",{field:r});throw i.setPropertyError=!0,i}if(t===null){var i=N("Cannot set property on null",{field:r});throw i.setPropertyError=!0,i}t[r]=n},$setOnInsert:function(t,r,n){},$unset:function(t,r,n){t!==void 0&&(t instanceof Array?r in t&&(t[r]=null):delete t[r])},$push:function(t,r,n){if(t[r]===void 0&&(t[r]=[]),!(t[r]instanceof Array))throw N("Cannot apply $push modifier to non-array",{field:r});if(!(n&&n.$each)){t[r].push(n);return}var i=n.$each;if(!(i instanceof Array))throw N("$each must be an array",{field:r});var o=void 0;if("$position"in n){if(typeof n.$position!="number")throw N("$position must be a numeric value",{field:r});if(n.$position<0)throw N("$position in $push must be zero or positive",{field:r});o=n.$position}var s=void 0;if("$slice"in n){if(typeof n.$slice!="number")throw N("$slice must be a numeric value",{field:r});if(n.$slice>0)throw N("$slice in $push must be zero or negative",{field:r});s=n.$slice}if(n.$sort)throw N("$sort in $push not implemented yet");if(o===void 0)for(var a=0;a<i.length;a++)t[r].push(i[a]);else{for(var u=[o,0],a=0;a<i.length;a++)u.push(i[a]);Array.prototype.splice.apply(t[r],u)}s!==void 0&&(s===0?t[r]=[]:t[r]=t[r].slice(s))},$pushAll:function(t,r,n){if(!((typeof n>"u"?"undefined":dr(n))==="object"&&n instanceof Array))throw N("Modifier $pushAll/pullAll allowed for arrays only");var i=t[r];if(i===void 0)t[r]=n;else if(i instanceof Array)for(var o=0;o<n.length;o++)i.push(n[o]);else throw N("Cannot apply $pushAll modifier to non-array",{field:r})},$addToSet:function(t,r,n){var i=!1;if((typeof n>"u"?"undefined":dr(n))==="object"){var o=Object.keys(n);o[0]==="$each"&&(i=!0)}var s=i?n.$each:[n],a=t[r];if(a===void 0)t[r]=s;else if(a instanceof Array)_t.each(s,function(u){for(var c=0;c<a.length;c++)if(ec(u,a[c]))return;a.push(u)});else throw N("Cannot apply $addToSet modifier to non-array",{field:r})},$pop:function(t,r,n){if(t!==void 0){var i=t[r];if(i!==void 0)if(i instanceof Array)typeof n=="number"&&n<0?i.splice(0,1):i.pop();else throw N("Cannot apply $pop modifier to non-array",{field:r})}},$pull:function(t,r,n){if(t!==void 0){var i=t[r];if(i!==void 0)throw i instanceof Array?N("$pull not implemented yet"):N("Cannot apply $pull/pullAll modifier to non-array",{field:r})}},$pullAll:function(t,r,n){if(!((typeof n>"u"?"undefined":dr(n))==="object"&&n instanceof Array))throw N("Modifier $pushAll/pullAll allowed for arrays only",{field:r});if(t!==void 0){var i=t[r];if(i!==void 0)if(i instanceof Array){for(var o=[],s=0;s<i.length;s++){for(var a=!1,u=0;u<n.length;u++)if(ec(i[s],n[u])){a=!0;break}a||o.push(i[s])}t[r]=o}else throw N("Cannot apply $pull/pullAll modifier to non-array",{field:r})}},$rename:function(t,r,n,i,o){if(i===n)throw N("$rename source must differ from target",{field:r});if(t===null)throw N("$rename source field invalid",{field:r});if(typeof n!="string")throw N("$rename target must be a string",{field:r});if(n.indexOf("\x00")>-1)throw N("The 'to' field for $rename cannot contain an embedded null byte",{field:r});if(t!==void 0){var s=t[r];delete t[r];var a=n.split("."),u=Uf(o,a,{forbidArray:!0});if(u===null)throw N("$rename target field invalid",{field:r});var c=a.pop();u[c]=s}},$bit:function(t,r,n){throw N("$bit is not supported",{field:r})}},Ow=_w;const Kf=Ps(Ow);function Aw(e){return this.incrementalModify(t=>{var r=Kf(t,e);return r})}function Cw(e){var t=this._data,r=Kf(t,e);return this._saveData(r,t)}function Dw(e){return this.exec().then(t=>t?Array.isArray(t)?Promise.all(t.map(r=>r.update(e))).then(()=>t):t.update(e).then(()=>t):null)}var Pw={name:"update",rxdb:!0,prototypes:{RxDocument:e=>{e.update=Cw,e.incrementalUpdate=Aw},RxQuery:e=>{e.update=Dw}}},tc={UT1:"given name is no string or empty",UT2:`collection- and database-names must match the regex to be compatible with couchdb databases.
16
- See https://neighbourhood.ie/blog/2020/10/13/everything-you-need-to-know-about-couchdb-database-names/
17
- info: if your database-name specifies a folder, the name must contain the slash-char '/' or '\\'`,UT3:"replication-direction must either be push or pull or both. But not none",UT4:"given leveldown is no valid adapter",UT5:"keyCompression is set to true in the schema but no key-compression handler is used in the storage",UT6:"schema contains encrypted fields but no encryption handler is used in the storage",UT7:"attachments.compression is enabled but no attachment-compression plugin is used",PL1:"Given plugin is not RxDB plugin.",PL3:"A plugin with the same name was already added but it was not the exact same JavaScript object",P2:"bulkWrite() cannot be called with an empty array",QU1:"RxQuery._execOverDatabase(): op not known",QU4:"RxQuery.regex(): You cannot use .regex() on the primary field",QU5:"RxQuery.sort(): does not work because key is not defined in the schema",QU6:"RxQuery.limit(): cannot be called on .findOne()",QU9:"throwIfMissing can only be used in findOne queries",QU10:"result empty and throwIfMissing: true",QU11:"RxQuery: no valid query params given",QU12:"Given index is not in schema",QU13:"A top level field of the query is not included in the schema",QU14:"Running a count() query in slow mode is now allowed. Either run a count() query with a selector that fully matches an index or set allowSlowCount=true when calling the createRxDatabase",QU15:"For count queries it is not allowed to use skip or limit",MQ1:"path must be a string or object",MQ2:"Invalid argument",MQ3:"Invalid sort() argument. Must be a string, object, or array",MQ4:"Invalid argument. Expected instanceof mquery or plain object",MQ5:"method must be used after where() when called with these arguments",MQ6:"Can't mix sort syntaxes. Use either array or object | .sort([['field', 1], ['test', -1]]) | .sort({ field: 1, test: -1 })",MQ7:"Invalid sort value",MQ8:"Can't mix sort syntaxes. Use either array or object",DB1:"RxDocument.prepare(): another instance on this adapter has a different password",DB2:"RxDatabase.addCollections(): collection-names cannot start with underscore _",DB3:"RxDatabase.addCollections(): collection already exists. use myDatabase.[collectionName] to get it",DB4:"RxDatabase.addCollections(): schema is missing",DB5:"RxDatabase.addCollections(): collection-name not allowed",DB6:"RxDatabase.addCollections(): another instance created this collection with a different schema. Read this https://pubkey.github.io/rxdb/questions-answers.html#cant-change-the-schema",DB8:`RxDatabase.create(): A RxDatabase with the same name and adapter already exists.
18
- Make sure to use this combination only once or set ignoreDuplicate to true if you do this intentional`,DB11:"createRxDatabase(): Invalid db-name, folder-paths must not have an ending slash",DB12:"RxDatabase.addCollections(): could not write to internal store",DB13:"createRxDatabase(): Invalid db-name or collection name, name contains the dollar sign",COL1:"RxDocument.insert() You cannot insert an existing document",COL2:"RxCollection.insert() fieldName ._id can only be used as primaryKey",COL3:"RxCollection.upsert() does not work without primary",COL4:"RxCollection.incrementalUpsert() does not work without primary",COL5:"RxCollection.find() if you want to search by _id, use .findOne(_id)",COL6:"RxCollection.findOne() needs a queryObject or string",COL7:"hook must be a function",COL8:"hooks-when not known",COL9:"RxCollection.addHook() hook-name not known",COL10:"RxCollection .postCreate-hooks cannot be async",COL11:"migrationStrategies must be an object",COL12:"A migrationStrategy is missing or too much",COL13:"migrationStrategy must be a function",COL14:"given static method-name is not a string",COL15:"static method-names cannot start with underscore _",COL16:"given static method is not a function",COL17:"RxCollection.ORM: statics-name not allowed",COL18:"collection-method not allowed because fieldname is in the schema",COL20:"Storage write error",CONFLICT:"Document update conflict. When changing a document you must work on the previous revision",DOC1:"RxDocument.get$ cannot get observable of in-array fields because order cannot be guessed",DOC2:"cannot observe primary path",DOC3:"final fields cannot be observed",DOC4:"RxDocument.get$ cannot observe a non-existed field",DOC5:"RxDocument.populate() cannot populate a non-existed field",DOC6:"RxDocument.populate() cannot populate because path has no ref",DOC7:"RxDocument.populate() ref-collection not in database",DOC8:"RxDocument.set(): primary-key cannot be modified",DOC9:"final fields cannot be modified",DOC10:"RxDocument.set(): cannot set childpath when rootPath not selected",DOC11:"RxDocument.save(): can't save deleted document",DOC13:"RxDocument.remove(): Document is already deleted",DOC14:"RxDocument.destroy() does not exist",DOC15:"query cannot be an array",DOC16:"Since version 8.0.0 RxDocument.set() can only be called on temporary RxDocuments",DOC17:"Since version 8.0.0 RxDocument.save() can only be called on non-temporary documents",DOC18:"Document property for composed primary key is missing",DOC19:"Value of primary key(s) cannot be changed",DOC20:"PrimaryKey missing",DOC21:"PrimaryKey must be equal to PrimaryKey.trim(). It cannot start or end with a whitespace",DOC22:"PrimaryKey must not contain a linebreak",DOC23:'PrimaryKey must not contain a double-quote ["]',DM1:"migrate() Migration has already run",DM2:"migration of document failed final document does not match final schema",DM3:"migration already running",AT1:"to use attachments, please define this in your schema",EN1:"password is not valid",EN2:"validatePassword: min-length of password not complied",EN3:"Schema contains encrypted properties but no password is given",EN4:"Password not valid",JD1:"You must create the collections before you can import their data",JD2:"RxCollection.importJSON(): the imported json relies on a different schema",JD3:"RxCollection.importJSON(): json.passwordHash does not match the own",LD1:"RxDocument.allAttachments$ can't use attachments on local documents",LD2:"RxDocument.get(): objPath must be a string",LD3:"RxDocument.get$ cannot get observable of in-array fields because order cannot be guessed",LD4:"cannot observe primary path",LD5:"RxDocument.set() id cannot be modified",LD6:"LocalDocument: Function is not usable on local documents",LD7:"Local document already exists",LD8:"localDocuments not activated. Set localDocuments=true on creation, when you want to store local documents on the RxDatabase or RxCollection.",RC1:"Replication: already added",RC2:"replicateCouchDB() query must be from the same RxCollection",RC4:"RxCouchDBReplicationState.awaitInitialReplication() cannot await initial replication when live: true",RC5:"RxCouchDBReplicationState.awaitInitialReplication() cannot await initial replication if multiInstance because the replication might run on another instance",RC6:"syncFirestore() serverTimestampField MUST NOT be part of the collections schema and MUST NOT be nested.",RC_PULL:"RxReplication pull handler threw an error - see .errors for more details",RC_STREAM:"RxReplication pull stream$ threw an error - see .errors for more details",RC_PUSH:"RxReplication push handler threw an error - see .errors for more details",RC_PUSH_NO_AR:"RxReplication push handler did not return an array with the conflicts",RC_P2P_PEER:"RxReplication P2P Peer has error",RC_COUCHDB_1:"replicateCouchDB() url must end with a slash like 'https://example.com/mydatabase/'",RC_COUCHDB_2:"replicateCouchDB() did not get valid result with rows.",SC1:"fieldnames do not match the regex",SC2:"SchemaCheck: name 'item' reserved for array-fields",SC3:"SchemaCheck: fieldname has a ref-array but items-type is not string",SC4:"SchemaCheck: fieldname has a ref but is not type string, [string,null] or array<string>",SC6:"SchemaCheck: primary can only be defined at top-level",SC7:"SchemaCheck: default-values can only be defined at top-level",SC8:"SchemaCheck: first level-fields cannot start with underscore _",SC10:"SchemaCheck: schema defines ._rev, this will be done automatically",SC11:"SchemaCheck: schema needs a number >=0 as version",SC13:"SchemaCheck: primary is always index, do not declare it as index",SC14:"SchemaCheck: primary is always unique, do not declare it as index",SC15:"SchemaCheck: primary cannot be encrypted",SC16:"SchemaCheck: primary must have type: string",SC17:"SchemaCheck: top-level fieldname is not allowed",SC18:"SchemaCheck: indexes must be an array",SC19:"SchemaCheck: indexes must contain strings or arrays of strings",SC20:"SchemaCheck: indexes.array must contain strings",SC21:"SchemaCheck: given index is not defined in schema",SC22:"SchemaCheck: given indexKey is not type:string",SC23:"SchemaCheck: fieldname is not allowed",SC24:"SchemaCheck: required fields must be set via array. See https://spacetelescope.github.io/understanding-json-schema/reference/object.html#required",SC25:"SchemaCheck: compoundIndexes needs to be specified in the indexes field",SC26:"SchemaCheck: indexes needs to be specified at collection schema level",SC27:"SchemaCheck: encrypted fields need to be specified at collection schema level",SC28:"SchemaCheck: encrypted fields is not defined in the schema",SC29:"SchemaCheck: missing object key 'properties'",SC30:"SchemaCheck: primaryKey is required",SC32:"SchemaCheck: primary field must have the type string/number/integer",SC33:"SchemaCheck: used primary key is not a property in the schema",SC34:"Fields of type string that are used in an index, must have set the maxLength attribute in the schema",SC35:"Fields of type number/integer that are used in an index, must have set the multipleOf attribute in the schema",SC36:"A field of this type cannot be used as index",SC37:"Fields of type number that are used in an index, must have set the minimum and maximum attribute in the schema",SC38:"Fields of type boolean that are used in an index, must be required in the schema",SC39:"The primary key must have the maxLength attribute set",VD1:"Sub-schema not found, does the schemaPath exists in your schema?",VD2:"object does not match schema",S1:"You cannot create collections after calling RxDatabase.server()",GQL1:"GraphQL replication: cannot find sub schema by key",GQL3:"GraphQL replication: pull returns more documents then batchSize",CRDT1:"CRDT operations cannot be used because the crdt options are not set in the schema.",CRDT2:"RxDocument.incrementalModify() cannot be used when CRDTs are activated.",CRDT3:"To use CRDTs you MUST NOT set a conflictHandler because the default CRDT conflict handler must be used",DXE1:"The dexie.js RxStorage does not support boolean indexes, see https://rxdb.info/rx-storage-dexie.html#boolean-index",SNH:"This should never happen"},wo;function Iw(){if(!wo){var e=new ra,t=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(Object.getPrototypeOf(e));wo=[...t,...r]}return wo}var _o;function Rw(){if(!_o){var e=new ia("pseudoInstance","memory"),t=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(Object.getPrototypeOf(e));_o=[...t,...r],e.destroy()}return _o}var kw=pl(gn),Tw=new kw,xo;function qf(){if(!xo){var e=["deleted","synced"],t=Object.getOwnPropertyNames(Tw),r=Object.getOwnPropertyNames(gn);xo=[...t,...r,...e]}return xo}function $w(e){if(e!=="_deleted"){if(["properties"].includes(e))throw D("SC23",{fieldName:e});var t="^[a-zA-Z](?:[[a-zA-Z0-9_]*]?[a-zA-Z0-9])?$",r=new RegExp(t);if(e!=="_id"&&!e.match(r))throw D("SC1",{regex:t,fieldName:e})}}function Bw(e){var t=Ke(e.primaryKey);function r(i,o,s){if(typeof i=="string"&&typeof o=="object"&&!Array.isArray(o)&&$w(i),o.hasOwnProperty("item")&&o.type!=="array")throw D("SC2",{fieldName:i});if(o.hasOwnProperty("required")&&typeof o.required=="boolean")throw D("SC24",{fieldName:i});if(o.hasOwnProperty("ref"))if(Array.isArray(o.type)){if(o.type.length>2||!o.type.includes("string")||!o.type.includes("null"))throw D("SC4",{fieldName:i})}else switch(o.type){case"string":break;case"array":if(!o.items||!o.items.type||o.items.type!=="string")throw D("SC3",{fieldName:i});break;default:throw D("SC4",{fieldName:i})}var a=s.split(".").length>=2;if(a){if(o.primary)throw D("SC6",{path:s,primary:o.primary});if(o.default)throw D("SC7",{path:s})}if(!a){if(i==="_id"&&t!=="_id")throw D("COL2",{fieldName:i});if(i.charAt(0)==="_"){if(i==="_id"||i==="_deleted")return;throw D("SC8",{fieldName:i})}}}function n(i,o){!i||typeof i!="object"||Object.keys(i).forEach(s=>{var a=i[s];!i.properties&&a&&typeof a=="object"&&!Array.isArray(i)&&r(s,a,o);var u=o;s!=="properties"&&(u=u+"."+s),n(a,u)})}return n(e,""),!0}function Mw(e){if(!e.primaryKey)throw D("SC30",{schema:e});function t(u){if(!u)throw D("SC33",{schema:e});var c=u.type;if(!c||!["string","number","integer"].includes(c))throw D("SC32",{schema:e,args:{schemaPart:u}})}if(typeof e.primaryKey=="string"){var r=e.primaryKey,n=e.properties[r];t(n)}else{var i=e.primaryKey,o=Pt(e,i.key);t(o),i.fields.forEach(u=>{var c=Pt(e,u);t(c)})}var s=Ke(e.primaryKey),a=e.properties[s];if(!a.maxLength)throw D("SC39",{schema:e,args:{primaryPathSchemaPart:a}})}function rc(e){for(var t=e.split("."),r="",n=0;n<t.length;n+=1)t[n]!=="[]"?r=r.concat(".properties.".concat(t[n])):r=r.concat(".items");return tn(r)}function Lw(e){if(!e.primaryKey)throw D("SC30",{schema:e});if(!e.hasOwnProperty("properties"))throw D("SC29",{schema:e});if(e.properties._rev)throw D("SC10",{schema:e});if(!e.hasOwnProperty("version")||typeof e.version!="number"||e.version<0)throw D("SC11",{version:e.version});if(Bw(e),Mw(e),Object.keys(e.properties).forEach(t=>{var r=e.properties[t];if(t===e.primaryKey){if(e.indexes&&e.indexes.includes(t))throw D("SC13",{value:r,schema:e});if(r.unique)throw D("SC14",{value:r,schema:e});if(e.encrypted&&e.encrypted.includes(t))throw D("SC15",{value:r,schema:e});if(r.type!=="string")throw D("SC16",{value:r,schema:e})}if(qf().includes(t))throw D("SC17",{key:t,schema:e})}),e.indexes){if(!yr(e.indexes))throw D("SC18",{indexes:e.indexes,schema:e});e.indexes.forEach(t=>{if(!(typeof t=="string"||Array.isArray(t)))throw D("SC19",{index:t,schema:e});if(Array.isArray(t)){for(var r=0;r<t.length;r+=1)if(typeof t[r]!="string")throw D("SC20",{index:t,schema:e})}var n=yr(t)?t:[t];n.forEach(i=>{var o=Pt(e,i),s=o.type;switch(s){case"string":var a=o.maxLength;if(!a)throw D("SC34",{index:t,field:i,schema:e});break;case"number":case"integer":var u=o.multipleOf;if(!u)throw D("SC35",{index:t,field:i,schema:e});var c=o.maximum,l=o.minimum;if(typeof c>"u"||typeof l>"u")throw D("SC37",{index:t,field:i,schema:e});break;case"boolean":var h="",p=i;if(i.includes(".")){var y=i.split(".");p=y.pop(),h=y.join(".")}var b=h===""?e:Pt(e,h);if(!b.required||!b.required.includes(p))throw D("SC38",{index:t,field:i,schema:e});break;default:throw D("SC36",{fieldName:i,type:o.type,schema:e})}})})}Object.keys(To(e)).map(t=>{var r=t.split(".");return r.pop(),r.join(".")}).filter(t=>t!=="").filter((t,r,n)=>n.indexOf(t)===r).filter(t=>{var r=St(e,t);return r&&!!r.index}).forEach(t=>{throw t=t.replace("properties.",""),t=t.replace(/\.properties\./g,"."),D("SC26",{index:tn(t),schema:e})}),(e.indexes||[]).reduce((t,r)=>(yr(r)?Ri(t,r):t.push(r),t),[]).filter((t,r,n)=>n.indexOf(t)===r).map(t=>{var r=rc(t),n=St(e,r);if(!n||typeof n!="object")throw D("SC21",{index:t,schema:e});return{indexPath:t,schemaObj:n}}).filter(t=>t.schemaObj.type!=="string"&&t.schemaObj.type!=="integer"&&t.schemaObj.type!=="number"&&t.schemaObj.type!=="boolean").forEach(t=>{throw D("SC22",{key:t.indexPath,type:t.schemaObj.type,schema:e})}),Object.keys(To(e)).map(t=>{var r=t.split(".");return r.pop(),r.join(".")}).filter(t=>t!==""&&t!=="attachments").filter((t,r,n)=>n.indexOf(t)===r).filter(t=>{var r=St(e,t);return r&&!!r.encrypted}).forEach(t=>{throw t=t.replace("properties.",""),t=t.replace(/\.properties\./g,"."),D("SC27",{index:tn(t),schema:e})}),e.encrypted&&e.encrypted.forEach(t=>{var r=rc(t),n=St(e,r);if(!n||typeof n!="object")throw D("SC28",{field:t,schema:e})})}function Eo(e){e&&Object.entries(e).forEach(([t,r])=>{if(typeof t!="string")throw ue("COL14",{name:t});if(t.startsWith("_"))throw ue("COL15",{name:t});if(typeof r!="function")throw ue("COL16",{name:t,type:typeof t});if(Iw().includes(t)||qf().includes(t))throw D("COL17",{name:t})})}function Fw(e,t){var r=Object.keys(e.properties);t&&Object.keys(t).filter(n=>r.includes(n)).forEach(n=>{throw D("COL18",{funName:n})})}function Nw(e,t){if(typeof t!="object"||Array.isArray(t))throw ue("COL11",{schema:e});var r=gl(e);if(r.length!==Object.keys(t).length)throw D("COL12",{have:Object.keys(t),should:r});return r.map(n=>({v:n,s:t[n+1]})).filter(n=>typeof n.s!="function").forEach(n=>{throw ue("COL13",{version:n.v,type:typeof n,schema:e})}),!0}function jw(e){if(Rw().includes(e.name))throw D("DB5",{name:e.name});Wf(e.name)}function Uw(e){if(Wf(e.name),e.name.includes("$"))throw D("DB13",{name:e.name});if(Lc(e.name)&&(e.name.endsWith("/")||e.name.endsWith("\\")))throw D("DB11",{name:e.name})}var Hf="^[a-z][_$a-z0-9\\-]*$",Kw=new RegExp(Hf);function Wf(e){if(typeof e!="string"||e.length===0)throw ue("UT1",{name:e});if(Lc(e))return!0;if(!e.match(Kw)&&e!==":memory:")throw D("UT2",{regex:Hf,givenName:e});return!0}const X=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,fe=Object.keys,_e=Array.isArray;function Oe(e,t){return typeof t!="object"||fe(t).forEach(function(r){e[r]=t[r]}),e}typeof Promise>"u"||X.Promise||(X.Promise=Promise);const Rr=Object.getPrototypeOf,qw={}.hasOwnProperty;function Me(e,t){return qw.call(e,t)}function kr(e,t){typeof t=="function"&&(t=t(Rr(e))),(typeof Reflect>"u"?fe:Reflect.ownKeys)(t).forEach(r=>{ft(e,r,t[r])})}const Qf=Object.defineProperty;function ft(e,t,r,n){Qf(e,t,Oe(r&&Me(r,"get")&&typeof r.get=="function"?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function wr(e){return{from:function(t){return e.prototype=Object.create(t.prototype),ft(e.prototype,"constructor",e),{extend:kr.bind(null,e.prototype)}}}}const Hw=Object.getOwnPropertyDescriptor;function pa(e,t){let r;return Hw(e,t)||(r=Rr(e))&&pa(r,t)}const Ww=[].slice;function wi(e,t,r){return Ww.call(e,t,r)}function zf(e,t){return t(e)}function qr(e){if(!e)throw new Error("Assertion Failed")}function Gf(e){X.setImmediate?setImmediate(e):setTimeout(e,0)}function Vf(e,t){return e.reduce((r,n,i)=>{var o=t(n,i);return o&&(r[o[0]]=o[1]),r},{})}function ht(e,t){if(Me(e,t))return e[t];if(!t)return e;if(typeof t!="string"){for(var r=[],n=0,i=t.length;n<i;++n){var o=ht(e,t[n]);r.push(o)}return r}var s=t.indexOf(".");if(s!==-1){var a=e[t.substr(0,s)];return a===void 0?void 0:ht(a,t.substr(s+1))}}function Ne(e,t,r){if(e&&t!==void 0&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if(typeof t!="string"&&"length"in t){qr(typeof r!="string"&&"length"in r);for(var n=0,i=t.length;n<i;++n)Ne(e,t[n],r[n])}else{var o=t.indexOf(".");if(o!==-1){var s=t.substr(0,o),a=t.substr(o+1);if(a==="")r===void 0?_e(e)&&!isNaN(parseInt(s))?e.splice(s,1):delete e[s]:e[s]=r;else{var u=e[s];u&&Me(e,s)||(u=e[s]={}),Ne(u,a,r)}}else r===void 0?_e(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=r}}function Jf(e){var t={};for(var r in e)Me(e,r)&&(t[r]=e[r]);return t}const Qw=[].concat;function Yf(e){return Qw.apply([],e)}const Xf="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(Yf([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>X[e]),zw=Xf.map(e=>X[e]);Vf(Xf,e=>[e,!0]);let xt=null;function An(e){xt=typeof WeakMap<"u"&&new WeakMap;const t=ns(e);return xt=null,t}function ns(e){if(!e||typeof e!="object")return e;let t=xt&&xt.get(e);if(t)return t;if(_e(e)){t=[],xt&&xt.set(e,t);for(var r=0,n=e.length;r<n;++r)t.push(ns(e[r]))}else if(zw.indexOf(e.constructor)>=0)t=e;else{const o=Rr(e);for(var i in t=o===Object.prototype?{}:Object.create(o),xt&&xt.set(e,t),e)Me(e,i)&&(t[i]=ns(e[i]))}return t}const{toString:Gw}={};function is(e){return Gw.call(e).slice(8,-1)}const os=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Vw=typeof os=="symbol"?function(e){var t;return e!=null&&(t=e[os])&&t.apply(e)}:function(){return null},fr={};function it(e){var t,r,n,i;if(arguments.length===1){if(_e(e))return e.slice();if(this===fr&&typeof e=="string")return[e];if(i=Vw(e)){for(r=[];!(n=i.next()).done;)r.push(n.value);return r}if(e==null)return[e];if(typeof(t=e.length)=="number"){for(r=new Array(t);t--;)r[t]=e[t];return r}return[e]}for(t=arguments.length,r=new Array(t);t--;)r[t]=arguments[t];return r}const ya=typeof Symbol<"u"?e=>e[Symbol.toStringTag]==="AsyncFunction":()=>!1;var Ze=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Zf(e,t){Ze=e,eh=t}var eh=()=>!0;const Jw=!new Error("").stack;function nr(){if(Jw)try{throw nr.arguments,new Error}catch(e){return e}return new Error}function ss(e,t){var r=e.stack;return r?(t=t||0,r.indexOf(e.name)===0&&(t+=(e.name+e.message).split(`
19
- `).length),r.split(`
20
- `).slice(t).filter(eh).map(n=>`
21
- `+n).join("")):""}var th=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],ma=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(th),Yw={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function _r(e,t){this._e=nr(),this.name=e,this.message=t}function rh(e,t){return e+". Errors: "+Object.keys(t).map(r=>t[r].toString()).filter((r,n,i)=>i.indexOf(r)===n).join(`
22
- `)}function _i(e,t,r,n){this._e=nr(),this.failures=t,this.failedKeys=n,this.successCount=r,this.message=rh(e,t)}function Vr(e,t){this._e=nr(),this.name="BulkError",this.failures=Object.keys(t).map(r=>t[r]),this.failuresByPos=t,this.message=rh(e,t)}wr(_r).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+ss(this._e,2))}},toString:function(){return this.name+": "+this.message}}),wr(_i).from(_r),wr(Vr).from(_r);var va=ma.reduce((e,t)=>(e[t]=t+"Error",e),{});const Xw=_r;var M=ma.reduce((e,t)=>{var r=t+"Error";function n(i,o){this._e=nr(),this.name=r,i?typeof i=="string"?(this.message=`${i}${o?`
23
- `+o:""}`,this.inner=o||null):typeof i=="object"&&(this.message=`${i.name} ${i.message}`,this.inner=i):(this.message=Yw[t]||r,this.inner=null)}return wr(n).from(Xw),e[t]=n,e},{});M.Syntax=SyntaxError,M.Type=TypeError,M.Range=RangeError;var nc=th.reduce((e,t)=>(e[t+"Error"]=M[t],e),{}),ei=ma.reduce((e,t)=>(["Syntax","Type","Range"].indexOf(t)===-1&&(e[t+"Error"]=M[t]),e),{});function V(){}function an(e){return e}function Zw(e,t){return e==null||e===an?t:function(r){return t(e(r))}}function Zt(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function e_(e,t){return e===V?t:function(){var r=e.apply(this,arguments);r!==void 0&&(arguments[0]=r);var n=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?Zt(n,this.onsuccess):n),i&&(this.onerror=this.onerror?Zt(i,this.onerror):i),o!==void 0?o:r}}function t_(e,t){return e===V?t:function(){e.apply(this,arguments);var r=this.onsuccess,n=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),r&&(this.onsuccess=this.onsuccess?Zt(r,this.onsuccess):r),n&&(this.onerror=this.onerror?Zt(n,this.onerror):n)}}function r_(e,t){return e===V?t:function(r){var n=e.apply(this,arguments);Oe(r,n);var i=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var s=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?Zt(i,this.onsuccess):i),o&&(this.onerror=this.onerror?Zt(o,this.onerror):o),n===void 0?s===void 0?void 0:s:Oe(n,s)}}function n_(e,t){return e===V?t:function(){return t.apply(this,arguments)!==!1&&e.apply(this,arguments)}}function ga(e,t){return e===V?t:function(){var r=e.apply(this,arguments);if(r&&typeof r.then=="function"){for(var n=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return r.then(function(){return t.apply(n,o)})}return t.apply(this,arguments)}}ei.ModifyError=_i,ei.DexieError=_r,ei.BulkError=Vr;var un={};const[as,xi,us]=typeof Promise>"u"?[]:(()=>{let e=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[e,Rr(e),e];const t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,Rr(t),e]})(),nh=xi&&xi.then,ti=as&&as.constructor,ba=!!us;var cs=!1,i_=us?()=>{us.then(Ln)}:X.setImmediate?setImmediate.bind(null,Ln):X.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{Ln(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(Ln,0)},Jr=function(e,t){Hr.push([e,t]),Ei&&(i_(),Ei=!1)},ls=!0,Ei=!0,Wt=[],ri=[],fs=null,hs=an,xr={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:oc,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{oc(e[0],e[1])}catch{}})}},B=xr,Hr=[],Qt=0,ni=[];function $(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=V,this._lib=!1;var t=this._PSD=B;if(Ze&&(this._stackHolder=nr(),this._prev=null,this._numPrev=0),typeof e!="function"){if(e!==un)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&ps(this,this._value))}this._state=null,this._value=null,++t.ref,oh(this,e)}const ds={get:function(){var e=B,t=Si;function r(n,i){var o=!e.global&&(e!==B||t!==Si);const s=o&&!gt();var a=new $((u,c)=>{wa(this,new ih(Oi(n,e,o,s),Oi(i,e,o,s),u,c,e))});return Ze&&uh(a,this),a}return r.prototype=un,r},set:function(e){ft(this,"then",e&&e.prototype===un?ds:{get:function(){return e},set:ds.set})}};function ih(e,t,r,n,i){this.onFulfilled=typeof e=="function"?e:null,this.onRejected=typeof t=="function"?t:null,this.resolve=r,this.reject=n,this.psd=i}function oh(e,t){try{t(r=>{if(e._state===null){if(r===e)throw new TypeError("A promise cannot be resolved with itself.");var n=e._lib&&Cn();r&&typeof r.then=="function"?oh(e,(i,o)=>{r instanceof $?r._then(i,o):r.then(i,o)}):(e._state=!0,e._value=r,sh(e)),n&&Dn()}},ps.bind(null,e))}catch(r){ps(e,r)}}function ps(e,t){if(ri.push(t),e._state===null){var r=e._lib&&Cn();t=hs(t),e._state=!1,e._value=t,Ze&&t!==null&&typeof t=="object"&&!t._promise&&function(n,i,o){try{n.apply(null,o)}catch(s){i&&i(s)}}(()=>{var n=pa(t,"stack");t._promise=e,ft(t,"stack",{get:()=>cs?n&&(n.get?n.get.apply(t):n.value):e.stack})}),function(n){Wt.some(i=>i._value===n._value)||Wt.push(n)}(e),sh(e),r&&Dn()}}function sh(e){var t=e._listeners;e._listeners=[];for(var r=0,n=t.length;r<n;++r)wa(e,t[r]);var i=e._PSD;--i.ref||i.finalize(),Qt===0&&(++Qt,Jr(()=>{--Qt==0&&_a()},[]))}function wa(e,t){if(e._state!==null){var r=e._state?t.onFulfilled:t.onRejected;if(r===null)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++Qt,Jr(o_,[r,e,t])}else e._listeners.push(t)}function o_(e,t,r){try{fs=t;var n,i=t._value;t._state?n=e(i):(ri.length&&(ri=[]),n=e(i),ri.indexOf(i)===-1&&function(o){for(var s=Wt.length;s;)if(Wt[--s]._value===o._value)return void Wt.splice(s,1)}(t)),r.resolve(n)}catch(o){r.reject(o)}finally{fs=null,--Qt==0&&_a(),--r.psd.ref||r.psd.finalize()}}function ah(e,t,r){if(t.length===r)return t;var n="";if(e._state===!1){var i,o,s=e._value;s!=null?(i=s.name||"Error",o=s.message||s,n=ss(s,0)):(i=s,o=""),t.push(i+(o?": "+o:"")+n)}return Ze&&((n=ss(e._stackHolder,2))&&t.indexOf(n)===-1&&t.push(n),e._prev&&ah(e._prev,t,r)),t}function uh(e,t){var r=t?t._numPrev+1:0;r<100&&(e._prev=t,e._numPrev=r)}function Ln(){Cn()&&Dn()}function Cn(){var e=ls;return ls=!1,Ei=!1,e}function Dn(){var e,t,r;do for(;Hr.length>0;)for(e=Hr,Hr=[],r=e.length,t=0;t<r;++t){var n=e[t];n[0].apply(null,n[1])}while(Hr.length>0);ls=!0,Ei=!0}function _a(){var e=Wt;Wt=[],e.forEach(n=>{n._PSD.onunhandled.call(null,n._value,n)});for(var t=ni.slice(0),r=t.length;r;)t[--r]()}function Fn(e){return new $(un,!1,e)}function te(e,t){var r=B;return function(){var n=Cn(),i=B;try{return Rt(r,!0),e.apply(this,arguments)}catch(o){t&&t(o)}finally{Rt(i,!1),n&&Dn()}}}kr($.prototype,{then:ds,_then:function(e,t){wa(this,new ih(null,null,e,t,B))},catch:function(e){if(arguments.length===1)return this.then(null,e);var t=arguments[0],r=arguments[1];return typeof t=="function"?this.then(null,n=>n instanceof t?r(n):Fn(n)):this.then(null,n=>n&&n.name===t?r(n):Fn(n))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),Fn(t)))},stack:{get:function(){if(this._stack)return this._stack;try{cs=!0;var e=ah(this,[],20).join(`
24
- From previous: `);return this._state!==null&&(this._stack=e),e}finally{cs=!1}}},timeout:function(e,t){return e<1/0?new $((r,n)=>{var i=setTimeout(()=>n(new M.Timeout(t)),e);this.then(r,n).finally(clearTimeout.bind(null,i))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&ft($.prototype,Symbol.toStringTag,"Dexie.Promise"),xr.env=ch(),kr($,{all:function(){var e=it.apply(null,arguments).map(Nn);return new $(function(t,r){e.length===0&&t([]);var n=e.length;e.forEach((i,o)=>$.resolve(i).then(s=>{e[o]=s,--n||t(e)},r))})},resolve:e=>{if(e instanceof $)return e;if(e&&typeof e.then=="function")return new $((r,n)=>{e.then(r,n)});var t=new $(un,!0,e);return uh(t,fs),t},reject:Fn,race:function(){var e=it.apply(null,arguments).map(Nn);return new $((t,r)=>{e.map(n=>$.resolve(n).then(t,r))})},PSD:{get:()=>B,set:e=>B=e},totalEchoes:{get:()=>Si},newPSD:It,usePSD:Nr,scheduler:{get:()=>Jr,set:e=>{Jr=e}},rejectionMapper:{get:()=>hs,set:e=>{hs=e}},follow:(e,t)=>new $((r,n)=>It((i,o)=>{var s=B;s.unhandleds=[],s.onunhandled=o,s.finalize=Zt(function(){(function(a){function u(){a(),ni.splice(ni.indexOf(u),1)}ni.push(u),++Qt,Jr(()=>{--Qt==0&&_a()},[])})(()=>{this.unhandleds.length===0?i():o(this.unhandleds[0])})},s.finalize),e()},t,r,n))}),ti&&(ti.allSettled&&ft($,"allSettled",function(){const e=it.apply(null,arguments).map(Nn);return new $(t=>{e.length===0&&t([]);let r=e.length;const n=new Array(r);e.forEach((i,o)=>$.resolve(i).then(s=>n[o]={status:"fulfilled",value:s},s=>n[o]={status:"rejected",reason:s}).then(()=>--r||t(n)))})}),ti.any&&typeof AggregateError<"u"&&ft($,"any",function(){const e=it.apply(null,arguments).map(Nn);return new $((t,r)=>{e.length===0&&r(new AggregateError([]));let n=e.length;const i=new Array(n);e.forEach((o,s)=>$.resolve(o).then(a=>t(a),a=>{i[s]=a,--n||r(new AggregateError(i))}))})}));const we={awaits:0,echoes:0,id:0};var s_=0,ii=[],So=0,Si=0,a_=0;function It(e,t,r,n){var i=B,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++a_;var s=xr.env;o.env=ba?{Promise:$,PromiseProp:{value:$,configurable:!0,writable:!0},all:$.all,race:$.race,allSettled:$.allSettled,any:$.any,resolve:$.resolve,reject:$.reject,nthen:ic(s.nthen,o),gthen:ic(s.gthen,o)}:{},t&&Oe(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=Nr(o,e,r,n);return o.ref===0&&o.finalize(),a}function Fr(){return we.id||(we.id=++s_),++we.awaits,we.echoes+=100,we.id}function gt(){return!!we.awaits&&(--we.awaits==0&&(we.id=0),we.echoes=100*we.awaits,!0)}function Nn(e){return we.echoes&&e&&e.constructor===ti?(Fr(),e.then(t=>(gt(),t),t=>(gt(),de(t)))):e}function u_(e){++Si,we.echoes&&--we.echoes!=0||(we.echoes=we.id=0),ii.push(B),Rt(e,!0)}function c_(){var e=ii[ii.length-1];ii.pop(),Rt(e,!1)}function Rt(e,t){var r=B;if((t?!we.echoes||So++&&e===B:!So||--So&&e===B)||lh(t?u_.bind(null,e):c_),e!==B&&(B=e,r===xr&&(xr.env=ch()),ba)){var n=xr.env.Promise,i=e.env;xi.then=i.nthen,n.prototype.then=i.gthen,(r.global||e.global)&&(Object.defineProperty(X,"Promise",i.PromiseProp),n.all=i.all,n.race=i.race,n.resolve=i.resolve,n.reject=i.reject,i.allSettled&&(n.allSettled=i.allSettled),i.any&&(n.any=i.any))}}function ch(){var e=X.Promise;return ba?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(X,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:xi.then,gthen:e.prototype.then}:{}}function Nr(e,t,r,n,i){var o=B;try{return Rt(e,!0),t(r,n,i)}finally{Rt(o,!1)}}function lh(e){nh.call(as,e)}function Oi(e,t,r,n){return typeof e!="function"?e:function(){var i=B;r&&Fr(),Rt(t,!0);try{return e.apply(this,arguments)}finally{Rt(i,!1),n&&lh(gt)}}}function ic(e,t){return function(r,n){return e.call(this,Oi(r,t),Oi(n,t))}}(""+nh).indexOf("[native code]")===-1&&(Fr=gt=V);function oc(e,t){var r;try{r=t.onuncatched(e)}catch{}if(r!==!1)try{var n,i={promise:t,reason:e};if(X.document&&document.createEvent?((n=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),Oe(n,i)):X.CustomEvent&&Oe(n=new CustomEvent("unhandledrejection",{detail:i}),i),n&&X.dispatchEvent&&(dispatchEvent(n),!X.PromiseRejectionEvent&&X.onunhandledrejection))try{X.onunhandledrejection(n)}catch{}Ze&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch{}}var de=$.reject;function ys(e,t,r,n){if(e.idbdb&&(e._state.openComplete||B.letThrough||e._vip)){var i=e._createTransaction(t,r,e._dbSchema);try{i.create(),e._state.PR1398_maxLoop=3}catch(o){return o.name===va.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>ys(e,t,r,n))):de(o)}return i._promise(t,(o,s)=>It(()=>(B.trans=i,n(o,s,i)))).then(o=>i._completion.then(()=>o))}if(e._state.openComplete)return de(new M.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._options.autoOpen)return de(new M.DatabaseClosed);e.open().catch(V)}return e._state.dbReadyPromise.then(()=>ys(e,t,r,n))}const Nt=String.fromCharCode(65535),et="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Yr=[],qi=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),l_=qi,f_=qi,fh=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function er(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}const hh={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function jn(e){return typeof e!="string"||/\./.test(e)?t=>t:t=>(t[e]===void 0&&e in t&&delete(t=An(t))[e],t)}function h_(){throw M.Type()}class d_{_trans(t,r,n){const i=this._tx||B.trans,o=this.name;function s(u,c,l){if(!l.schema[o])throw new M.NotFound("Table "+o+" not part of transaction");return r(l.idbtrans,l)}const a=Cn();try{return i&&i.db===this.db?i===B.trans?i._promise(t,s,n):It(()=>i._promise(t,s,n),{trans:i,transless:B.transless||B}):ys(this.db,t,[this.name],s)}finally{a&&Dn()}}get(t,r){return t&&t.constructor===Object?this.where(t).first(r):this._trans("readonly",n=>this.core.get({trans:n,key:t}).then(i=>this.hook.reading.fire(i))).then(r)}where(t){if(typeof t=="string")return new this.db.WhereClause(this,t);if(_e(t))return new this.db.WhereClause(this,`[${t.join("+")}]`);const r=fe(t);if(r.length===1)return this.where(r[0]).equals(t[r[0]]);const n=this.schema.indexes.concat(this.schema.primKey).filter(c=>c.compound&&r.every(l=>c.keyPath.indexOf(l)>=0)&&c.keyPath.every(l=>r.indexOf(l)>=0))[0];if(n&&this.db._maxKey!==Nt)return this.where(n.name).equals(n.keyPath.map(c=>t[c]));!n&&Ze&&console.warn(`The query ${JSON.stringify(t)} on ${this.name} would benefit of a compound index [${r.join("+")}]`);const{idxByName:i}=this.schema,o=this.db._deps.indexedDB;function s(c,l){try{return o.cmp(c,l)===0}catch{return!1}}const[a,u]=r.reduce(([c,l],h)=>{const p=i[h],y=t[h];return[c||p,c||!p?er(l,p&&p.multi?b=>{const g=ht(b,h);return _e(g)&&g.some(E=>s(y,E))}:b=>s(y,ht(b,h))):l]},[null,null]);return a?this.where(a.name).equals(t[a.keyPath]).filter(u):n?this.filter(u):this.where(r).equals("")}filter(t){return this.toCollection().and(t)}count(t){return this.toCollection().count(t)}offset(t){return this.toCollection().offset(t)}limit(t){return this.toCollection().limit(t)}each(t){return this.toCollection().each(t)}toArray(t){return this.toCollection().toArray(t)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(t){return new this.db.Collection(new this.db.WhereClause(this,_e(t)?`[${t.join("+")}]`:t))}reverse(){return this.toCollection().reverse()}mapToClass(t){const{db:r,name:n}=this;this.schema.mappedClass=t,t.prototype instanceof h_&&(t=class extends t{get db(){return r}table(){return n}});const i=new Set;for(let s=t.prototype;s;s=Rr(s))Object.getOwnPropertyNames(s).forEach(a=>i.add(a));const o=s=>{if(!s)return s;const a=Object.create(t.prototype);for(let u in s)if(!i.has(u))try{a[u]=s[u]}catch{}return a};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=o,this.hook("reading",o),t}defineClass(){return this.mapToClass(function(t){Oe(this,t)})}add(t,r){const{auto:n,keyPath:i}=this.schema.primKey;let o=t;return i&&n&&(o=jn(i)(t)),this._trans("readwrite",s=>this.core.mutate({trans:s,type:"add",keys:r!=null?[r]:null,values:[o]})).then(s=>s.numFailures?$.reject(s.failures[0]):s.lastResult).then(s=>{if(i)try{Ne(t,i,s)}catch{}return s})}update(t,r){if(typeof t!="object"||_e(t))return this.where(":id").equals(t).modify(r);{const n=ht(t,this.schema.primKey.keyPath);if(n===void 0)return de(new M.InvalidArgument("Given object does not contain its primary key"));try{typeof r!="function"?fe(r).forEach(i=>{Ne(t,i,r[i])}):r(t,{value:t,primKey:n})}catch{}return this.where(":id").equals(n).modify(r)}}put(t,r){const{auto:n,keyPath:i}=this.schema.primKey;let o=t;return i&&n&&(o=jn(i)(t)),this._trans("readwrite",s=>this.core.mutate({trans:s,type:"put",values:[o],keys:r!=null?[r]:null})).then(s=>s.numFailures?$.reject(s.failures[0]):s.lastResult).then(s=>{if(i)try{Ne(t,i,s)}catch{}return s})}delete(t){return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:[t]})).then(r=>r.numFailures?$.reject(r.failures[0]):void 0)}clear(){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"deleteRange",range:hh})).then(t=>t.numFailures?$.reject(t.failures[0]):void 0)}bulkGet(t){return this._trans("readonly",r=>this.core.getMany({keys:t,trans:r}).then(n=>n.map(i=>this.hook.reading.fire(i))))}bulkAdd(t,r,n){const i=Array.isArray(r)?r:void 0,o=(n=n||(i?void 0:r))?n.allKeys:void 0;return this._trans("readwrite",s=>{const{auto:a,keyPath:u}=this.schema.primKey;if(u&&i)throw new M.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==t.length)throw new M.InvalidArgument("Arguments objects and keys must have the same length");const c=t.length;let l=u&&a?t.map(jn(u)):t;return this.core.mutate({trans:s,type:"add",keys:i,values:l,wantResults:o}).then(({numFailures:h,results:p,lastResult:y,failures:b})=>{if(h===0)return o?p:y;throw new Vr(`${this.name}.bulkAdd(): ${h} of ${c} operations failed`,b)})})}bulkPut(t,r,n){const i=Array.isArray(r)?r:void 0,o=(n=n||(i?void 0:r))?n.allKeys:void 0;return this._trans("readwrite",s=>{const{auto:a,keyPath:u}=this.schema.primKey;if(u&&i)throw new M.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==t.length)throw new M.InvalidArgument("Arguments objects and keys must have the same length");const c=t.length;let l=u&&a?t.map(jn(u)):t;return this.core.mutate({trans:s,type:"put",keys:i,values:l,wantResults:o}).then(({numFailures:h,results:p,lastResult:y,failures:b})=>{if(h===0)return o?p:y;throw new Vr(`${this.name}.bulkPut(): ${h} of ${c} operations failed`,b)})})}bulkDelete(t){const r=t.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:t})).then(({numFailures:n,lastResult:i,failures:o})=>{if(n===0)return i;throw new Vr(`${this.name}.bulkDelete(): ${n} of ${r} operations failed`,o)})}}function Xr(e){var t={},r=function(a,u){if(u){for(var c=arguments.length,l=new Array(c-1);--c;)l[c-1]=arguments[c];return t[a].subscribe.apply(null,l),e}if(typeof a=="string")return t[a]};r.addEventType=o;for(var n=1,i=arguments.length;n<i;++n)o(arguments[n]);return r;function o(a,u,c){if(typeof a=="object")return s(a);u||(u=n_),c||(c=V);var l={subscribers:[],fire:c,subscribe:function(h){l.subscribers.indexOf(h)===-1&&(l.subscribers.push(h),l.fire=u(l.fire,h))},unsubscribe:function(h){l.subscribers=l.subscribers.filter(function(p){return p!==h}),l.fire=l.subscribers.reduce(u,c)}};return t[a]=r[a]=l,l}function s(a){fe(a).forEach(function(u){var c=a[u];if(_e(c))o(u,a[u][0],a[u][1]);else{if(c!=="asap")throw new M.InvalidArgument("Invalid event config");var l=o(u,an,function(){for(var h=arguments.length,p=new Array(h);h--;)p[h]=arguments[h];l.subscribers.forEach(function(y){Gf(function(){y.apply(null,p)})})})}})}}function jr(e,t){return wr(t).from({prototype:e}),t}function sr(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Oo(e,t){e.filter=er(e.filter,t)}function Ao(e,t,r){var n=e.replayFilter;e.replayFilter=n?()=>er(n(),t()):t,e.justLimit=r&&!n}function oi(e,t){if(e.isPrimKey)return t.primaryKey;const r=t.getIndexByKeyPath(e.index);if(!r)throw new M.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return r}function sc(e,t,r){const n=oi(e,t.schema);return t.openCursor({trans:r,values:!e.keysOnly,reverse:e.dir==="prev",unique:!!e.unique,query:{index:n,range:e.range}})}function Un(e,t,r,n){const i=e.replayFilter?er(e.filter,e.replayFilter()):e.filter;if(e.or){const o={},s=(a,u,c)=>{if(!i||i(u,c,p=>u.stop(p),p=>u.fail(p))){var l=u.primaryKey,h=""+l;h==="[object ArrayBuffer]"&&(h=""+new Uint8Array(l)),Me(o,h)||(o[h]=!0,t(a,u,c))}};return Promise.all([e.or._iterate(s,r),ac(sc(e,n,r),e.algorithm,s,!e.keysOnly&&e.valueMapper)])}return ac(sc(e,n,r),er(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function ac(e,t,r,n){var i=te(n?(o,s,a)=>r(n(o),s,a):r);return e.then(o=>{if(o)return o.start(()=>{var s=()=>o.continue();t&&!t(o,a=>s=a,a=>{o.stop(a),s=V},a=>{o.fail(a),s=V})||i(o.value,o,a=>s=a),s()})})}function Ee(e,t){try{const r=uc(e),n=uc(t);if(r!==n)return r==="Array"?1:n==="Array"?-1:r==="binary"?1:n==="binary"?-1:r==="string"?1:n==="string"?-1:r==="Date"?1:n!=="Date"?NaN:-1;switch(r){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(i,o){const s=i.length,a=o.length,u=s<a?s:a;for(let c=0;c<u;++c)if(i[c]!==o[c])return i[c]<o[c]?-1:1;return s===a?0:s<a?-1:1}(cc(e),cc(t));case"Array":return function(i,o){const s=i.length,a=o.length,u=s<a?s:a;for(let c=0;c<u;++c){const l=Ee(i[c],o[c]);if(l!==0)return l}return s===a?0:s<a?-1:1}(e,t)}}catch{}return NaN}function uc(e){const t=typeof e;if(t!=="object")return t;if(ArrayBuffer.isView(e))return"binary";const r=is(e);return r==="ArrayBuffer"?"binary":r}function cc(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class p_{_read(t,r){var n=this._ctx;return n.error?n.table._trans(null,de.bind(null,n.error)):n.table._trans("readonly",t).then(r)}_write(t){var r=this._ctx;return r.error?r.table._trans(null,de.bind(null,r.error)):r.table._trans("readwrite",t,"locked")}_addAlgorithm(t){var r=this._ctx;r.algorithm=er(r.algorithm,t)}_iterate(t,r){return Un(this._ctx,t,r,this._ctx.table.core)}clone(t){var r=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return t&&Oe(n,t),r._ctx=n,r}raw(){return this._ctx.valueMapper=null,this}each(t){var r=this._ctx;return this._read(n=>Un(r,t,n,r.table.core))}count(t){return this._read(r=>{const n=this._ctx,i=n.table.core;if(sr(n,!0))return i.count({trans:r,query:{index:oi(n,i.schema),range:n.range}}).then(s=>Math.min(s,n.limit));var o=0;return Un(n,()=>(++o,!1),r,i).then(()=>o)}).then(t)}sortBy(t,r){const n=t.split(".").reverse(),i=n[0],o=n.length-1;function s(c,l){return l?s(c[n[l]],l-1):c[i]}var a=this._ctx.dir==="next"?1:-1;function u(c,l){var h=s(c,o),p=s(l,o);return h<p?-a:h>p?a:0}return this.toArray(function(c){return c.sort(u)}).then(r)}toArray(t){return this._read(r=>{var n=this._ctx;if(n.dir==="next"&&sr(n,!0)&&n.limit>0){const{valueMapper:i}=n,o=oi(n,n.table.core.schema);return n.table.core.query({trans:r,limit:n.limit,values:!0,query:{index:o,range:n.range}}).then(({result:s})=>i?s.map(i):s)}{const i=[];return Un(n,o=>i.push(o),r,n.table.core).then(()=>i)}},t)}offset(t){var r=this._ctx;return t<=0||(r.offset+=t,sr(r)?Ao(r,()=>{var n=t;return(i,o)=>n===0||(n===1?(--n,!1):(o(()=>{i.advance(n),n=0}),!1))}):Ao(r,()=>{var n=t;return()=>--n<0})),this}limit(t){return this._ctx.limit=Math.min(this._ctx.limit,t),Ao(this._ctx,()=>{var r=t;return function(n,i,o){return--r<=0&&i(o),r>=0}},!0),this}until(t,r){return Oo(this._ctx,function(n,i,o){return!t(n.value)||(i(o),r)}),this}first(t){return this.limit(1).toArray(function(r){return r[0]}).then(t)}last(t){return this.reverse().first(t)}filter(t){var r,n;return Oo(this._ctx,function(i){return t(i.value)}),r=this._ctx,n=t,r.isMatch=er(r.isMatch,n),this}and(t){return this.filter(t)}or(t){return new this.db.WhereClause(this._ctx.table,t,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(t){var r=this._ctx;return r.keysOnly=!r.isMatch,this.each(function(n,i){t(i.key,i)})}eachUniqueKey(t){return this._ctx.unique="unique",this.eachKey(t)}eachPrimaryKey(t){var r=this._ctx;return r.keysOnly=!r.isMatch,this.each(function(n,i){t(i.primaryKey,i)})}keys(t){var r=this._ctx;r.keysOnly=!r.isMatch;var n=[];return this.each(function(i,o){n.push(o.key)}).then(function(){return n}).then(t)}primaryKeys(t){var r=this._ctx;if(r.dir==="next"&&sr(r,!0)&&r.limit>0)return this._read(i=>{var o=oi(r,r.table.core.schema);return r.table.core.query({trans:i,values:!1,limit:r.limit,query:{index:o,range:r.range}})}).then(({result:i})=>i).then(t);r.keysOnly=!r.isMatch;var n=[];return this.each(function(i,o){n.push(o.primaryKey)}).then(function(){return n}).then(t)}uniqueKeys(t){return this._ctx.unique="unique",this.keys(t)}firstKey(t){return this.limit(1).keys(function(r){return r[0]}).then(t)}lastKey(t){return this.reverse().firstKey(t)}distinct(){var t=this._ctx,r=t.index&&t.table.schema.idxByName[t.index];if(!r||!r.multi)return this;var n={};return Oo(this._ctx,function(i){var o=i.primaryKey.toString(),s=Me(n,o);return n[o]=!0,!s}),this}modify(t){var r=this._ctx;return this._write(n=>{var i;if(typeof t=="function")i=t;else{var o=fe(t),s=o.length;i=function(g){for(var E=!1,w=0;w<s;++w){var _=o[w],A=t[_];ht(g,_)!==A&&(Ne(g,_,A),E=!0)}return E}}const a=r.table.core,{outbound:u,extractKey:c}=a.schema.primaryKey,l=this.db._options.modifyChunkSize||200,h=[];let p=0;const y=[],b=(g,E)=>{const{failures:w,numFailures:_}=E;p+=g-_;for(let A of fe(w))h.push(w[A])};return this.clone().primaryKeys().then(g=>{const E=w=>{const _=Math.min(l,g.length-w);return a.getMany({trans:n,keys:g.slice(w,w+_),cache:"immutable"}).then(A=>{const R=[],O=[],C=u?[]:null,S=[];for(let T=0;T<_;++T){const F=A[T],W={value:An(F),primKey:g[w+T]};i.call(W,W.value,W)!==!1&&(W.value==null?S.push(g[w+T]):u||Ee(c(F),c(W.value))===0?(O.push(W.value),u&&C.push(g[w+T])):(S.push(g[w+T]),R.push(W.value)))}const k=sr(r)&&r.limit===1/0&&(typeof t!="function"||t===Co)&&{index:r.index,range:r.range};return Promise.resolve(R.length>0&&a.mutate({trans:n,type:"add",values:R}).then(T=>{for(let F in T.failures)S.splice(parseInt(F),1);b(R.length,T)})).then(()=>(O.length>0||k&&typeof t=="object")&&a.mutate({trans:n,type:"put",keys:C,values:O,criteria:k,changeSpec:typeof t!="function"&&t}).then(T=>b(O.length,T))).then(()=>(S.length>0||k&&t===Co)&&a.mutate({trans:n,type:"delete",keys:S,criteria:k}).then(T=>b(S.length,T))).then(()=>g.length>w+_&&E(w+l))})};return E(0).then(()=>{if(h.length>0)throw new _i("Error modifying one or more objects",h,p,y);return g.length})})})}delete(){var t=this._ctx,r=t.range;return sr(t)&&(t.isPrimKey&&!f_||r.type===3)?this._write(n=>{const{primaryKey:i}=t.table.core.schema,o=r;return t.table.core.count({trans:n,query:{index:i,range:o}}).then(s=>t.table.core.mutate({trans:n,type:"deleteRange",range:o}).then(({failures:a,lastResult:u,results:c,numFailures:l})=>{if(l)throw new _i("Could not delete some values",Object.keys(a).map(h=>a[h]),s-l);return s-l}))}):this.modify(Co)}}const Co=(e,t)=>t.value=null;function y_(e,t){return e<t?-1:e===t?0:1}function m_(e,t){return e>t?-1:e===t?0:1}function De(e,t,r){var n=e instanceof ph?new e.Collection(e):e;return n._ctx.error=r?new r(t):new TypeError(t),n}function ar(e){return new e.Collection(e,()=>dh("")).limit(0)}function v_(e,t,r,n,i,o){for(var s=Math.min(e.length,n.length),a=-1,u=0;u<s;++u){var c=t[u];if(c!==n[u])return i(e[u],r[u])<0?e.substr(0,u)+r[u]+r.substr(u+1):i(e[u],n[u])<0?e.substr(0,u)+n[u]+r.substr(u+1):a>=0?e.substr(0,a)+t[a]+r.substr(a+1):null;i(e[u],c)<0&&(a=u)}return s<n.length&&o==="next"?e+r.substr(e.length):s<e.length&&o==="prev"?e.substr(0,r.length):a<0?null:e.substr(0,a)+n[a]+r.substr(a+1)}function Kn(e,t,r,n){var i,o,s,a,u,c,l,h=r.length;if(!r.every(g=>typeof g=="string"))return De(e,"String expected.");function p(g){i=function(w){return w==="next"?_=>_.toUpperCase():_=>_.toLowerCase()}(g),o=function(w){return w==="next"?_=>_.toLowerCase():_=>_.toUpperCase()}(g),s=g==="next"?y_:m_;var E=r.map(function(w){return{lower:o(w),upper:i(w)}}).sort(function(w,_){return s(w.lower,_.lower)});a=E.map(function(w){return w.upper}),u=E.map(function(w){return w.lower}),c=g,l=g==="next"?"":n}p("next");var y=new e.Collection(e,()=>wt(a[0],u[h-1]+n));y._ondirectionchange=function(g){p(g)};var b=0;return y._addAlgorithm(function(g,E,w){var _=g.key;if(typeof _!="string")return!1;var A=o(_);if(t(A,u,b))return!0;for(var R=null,O=b;O<h;++O){var C=v_(_,A,a[O],u[O],s,c);C===null&&R===null?b=O+1:(R===null||s(R,C)>0)&&(R=C)}return E(R!==null?function(){g.continue(R+l)}:w),!1}),y}function wt(e,t,r,n){return{type:2,lower:e,upper:t,lowerOpen:r,upperOpen:n}}function dh(e){return{type:1,lower:e,upper:e}}class ph{get Collection(){return this._ctx.table.db.Collection}between(t,r,n,i){n=n!==!1,i=i===!0;try{return this._cmp(t,r)>0||this._cmp(t,r)===0&&(n||i)&&(!n||!i)?ar(this):new this.Collection(this,()=>wt(t,r,!n,!i))}catch{return De(this,et)}}equals(t){return t==null?De(this,et):new this.Collection(this,()=>dh(t))}above(t){return t==null?De(this,et):new this.Collection(this,()=>wt(t,void 0,!0))}aboveOrEqual(t){return t==null?De(this,et):new this.Collection(this,()=>wt(t,void 0,!1))}below(t){return t==null?De(this,et):new this.Collection(this,()=>wt(void 0,t,!1,!0))}belowOrEqual(t){return t==null?De(this,et):new this.Collection(this,()=>wt(void 0,t))}startsWith(t){return typeof t!="string"?De(this,"String expected."):this.between(t,t+Nt,!0,!0)}startsWithIgnoreCase(t){return t===""?this.startsWith(t):Kn(this,(r,n)=>r.indexOf(n[0])===0,[t],Nt)}equalsIgnoreCase(t){return Kn(this,(r,n)=>r===n[0],[t],"")}anyOfIgnoreCase(){var t=it.apply(fr,arguments);return t.length===0?ar(this):Kn(this,(r,n)=>n.indexOf(r)!==-1,t,"")}startsWithAnyOfIgnoreCase(){var t=it.apply(fr,arguments);return t.length===0?ar(this):Kn(this,(r,n)=>n.some(i=>r.indexOf(i)===0),t,Nt)}anyOf(){const t=it.apply(fr,arguments);let r=this._cmp;try{t.sort(r)}catch{return De(this,et)}if(t.length===0)return ar(this);const n=new this.Collection(this,()=>wt(t[0],t[t.length-1]));n._ondirectionchange=o=>{r=o==="next"?this._ascending:this._descending,t.sort(r)};let i=0;return n._addAlgorithm((o,s,a)=>{const u=o.key;for(;r(u,t[i])>0;)if(++i,i===t.length)return s(a),!1;return r(u,t[i])===0||(s(()=>{o.continue(t[i])}),!1)}),n}notEqual(t){return this.inAnyRange([[-(1/0),t],[t,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const t=it.apply(fr,arguments);if(t.length===0)return new this.Collection(this);try{t.sort(this._ascending)}catch{return De(this,et)}const r=t.reduce((n,i)=>n?n.concat([[n[n.length-1][1],i]]):[[-(1/0),i]],null);return r.push([t[t.length-1],this.db._maxKey]),this.inAnyRange(r,{includeLowers:!1,includeUppers:!1})}inAnyRange(t,r){const n=this._cmp,i=this._ascending,o=this._descending,s=this._min,a=this._max;if(t.length===0)return ar(this);if(!t.every(_=>_[0]!==void 0&&_[1]!==void 0&&i(_[0],_[1])<=0))return De(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",M.InvalidArgument);const u=!r||r.includeLowers!==!1,c=r&&r.includeUppers===!0;let l,h=i;function p(_,A){return h(_[0],A[0])}try{l=t.reduce(function(_,A){let R=0,O=_.length;for(;R<O;++R){const C=_[R];if(n(A[0],C[1])<0&&n(A[1],C[0])>0){C[0]=s(C[0],A[0]),C[1]=a(C[1],A[1]);break}}return R===O&&_.push(A),_},[]),l.sort(p)}catch{return De(this,et)}let y=0;const b=c?_=>i(_,l[y][1])>0:_=>i(_,l[y][1])>=0,g=u?_=>o(_,l[y][0])>0:_=>o(_,l[y][0])>=0;let E=b;const w=new this.Collection(this,()=>wt(l[0][0],l[l.length-1][1],!u,!c));return w._ondirectionchange=_=>{_==="next"?(E=b,h=i):(E=g,h=o),l.sort(p)},w._addAlgorithm((_,A,R)=>{for(var O=_.key;E(O);)if(++y,y===l.length)return A(R),!1;return!!function(C){return!b(C)&&!g(C)}(O)||(this._cmp(O,l[y][1])===0||this._cmp(O,l[y][0])===0||A(()=>{h===i?_.continue(l[y][0]):_.continue(l[y][1])}),!1)}),w}startsWithAnyOf(){const t=it.apply(fr,arguments);return t.every(r=>typeof r=="string")?t.length===0?ar(this):this.inAnyRange(t.map(r=>[r,r+Nt])):De(this,"startsWithAnyOf() only works with strings")}}function Qe(e){return te(function(t){return cn(t),e(t.target.error),!1})}function cn(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}const kt=Xr(null,"storagemutated");class g_{_lock(){return qr(!B.global),++this._reculock,this._reculock!==1||B.global||(B.lockOwnerFor=this),this}_unlock(){if(qr(!B.global),--this._reculock==0)for(B.global||(B.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var t=this._blockedFuncs.shift();try{Nr(t[1],t[0])}catch{}}return this}_locked(){return this._reculock&&B.lockOwnerFor!==this}create(t){if(!this.mode)return this;const r=this.db.idbdb,n=this.db._state.dbOpenError;if(qr(!this.idbtrans),!t&&!r)switch(n&&n.name){case"DatabaseClosedError":throw new M.DatabaseClosed(n);case"MissingAPIError":throw new M.MissingAPI(n.message,n);default:throw new M.OpenFailed(n)}if(!this.active)throw new M.TransactionInactive;return qr(this._completion._state===null),(t=this.idbtrans=t||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):r.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=te(i=>{cn(i),this._reject(t.error)}),t.onabort=te(i=>{cn(i),this.active&&this._reject(new M.Abort(t.error)),this.active=!1,this.on("abort").fire(i)}),t.oncomplete=te(()=>{this.active=!1,this._resolve(),"mutatedParts"in t&&kt.storagemutated.fire(t.mutatedParts)}),this}_promise(t,r,n){if(t==="readwrite"&&this.mode!=="readwrite")return de(new M.ReadOnly("Transaction is readonly"));if(!this.active)return de(new M.TransactionInactive);if(this._locked())return new $((o,s)=>{this._blockedFuncs.push([()=>{this._promise(t,r,n).then(o,s)},B])});if(n)return It(()=>{var o=new $((s,a)=>{this._lock();const u=r(s,a,this);u&&u.then&&u.then(s,a)});return o.finally(()=>this._unlock()),o._lib=!0,o});var i=new $((o,s)=>{var a=r(o,s,this);a&&a.then&&a.then(o,s)});return i._lib=!0,i}_root(){return this.parent?this.parent._root():this}waitFor(t){var r=this._root();const n=$.resolve(t);if(r._waitingFor)r._waitingFor=r._waitingFor.then(()=>n);else{r._waitingFor=n,r._waitingQueue=[];var i=r.idbtrans.objectStore(r.storeNames[0]);(function s(){for(++r._spinCount;r._waitingQueue.length;)r._waitingQueue.shift()();r._waitingFor&&(i.get(-1/0).onsuccess=s)})()}var o=r._waitingFor;return new $((s,a)=>{n.then(u=>r._waitingQueue.push(te(s.bind(null,u))),u=>r._waitingQueue.push(te(a.bind(null,u)))).finally(()=>{r._waitingFor===o&&(r._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new M.Abort))}table(t){const r=this._memoizedTables||(this._memoizedTables={});if(Me(r,t))return r[t];const n=this.schema[t];if(!n)throw new M.NotFound("Table "+t+" not part of transaction");const i=new this.db.Table(t,n,this);return i.core=this.db.core.table(t),r[t]=i,i}}function ms(e,t,r,n,i,o,s){return{name:e,keyPath:t,unique:r,multi:n,auto:i,compound:o,src:(r&&!s?"&":"")+(n?"*":"")+(i?"++":"")+yh(t)}}function yh(e){return typeof e=="string"?e:e?"["+[].join.call(e,"+")+"]":""}function mh(e,t,r){return{name:e,primKey:t,indexes:r,mappedClass:null,idxByName:Vf(r,n=>[n.name,n])}}let ln=e=>{try{return e.only([[]]),ln=()=>[[]],[[]]}catch{return ln=()=>Nt,Nt}};function vs(e){return e==null?()=>{}:typeof e=="string"?function(t){return t.split(".").length===1?r=>r[t]:r=>ht(r,t)}(e):t=>ht(t,e)}function lc(e){return[].slice.call(e)}let b_=0;function Zr(e){return e==null?":id":typeof e=="string"?e:`[${e.join("+")}]`}function w_(e,t,r){function n(u){if(u.type===3)return null;if(u.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:c,upper:l,lowerOpen:h,upperOpen:p}=u;return c===void 0?l===void 0?null:t.upperBound(l,!!p):l===void 0?t.lowerBound(c,!!h):t.bound(c,l,!!h,!!p)}const{schema:i,hasGetAll:o}=function(u,c){const l=lc(u.objectStoreNames);return{schema:{name:u.name,tables:l.map(h=>c.objectStore(h)).map(h=>{const{keyPath:p,autoIncrement:y}=h,b=_e(p),g=p==null,E={},w={name:h.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:g,compound:b,keyPath:p,autoIncrement:y,unique:!0,extractKey:vs(p)},indexes:lc(h.indexNames).map(_=>h.index(_)).map(_=>{const{name:A,unique:R,multiEntry:O,keyPath:C}=_,S={name:A,compound:_e(C),keyPath:C,unique:R,multiEntry:O,extractKey:vs(C)};return E[Zr(C)]=S,S}),getIndexByKeyPath:_=>E[Zr(_)]};return E[":id"]=w.primaryKey,p!=null&&(E[Zr(p)]=w.primaryKey),w})},hasGetAll:l.length>0&&"getAll"in c.objectStore(l[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(e,r),s=i.tables.map(u=>function(c){const l=c.name;return{name:l,schema:c,mutate:function({trans:h,type:p,keys:y,values:b,range:g}){return new Promise((E,w)=>{E=te(E);const _=h.objectStore(l),A=_.keyPath==null,R=p==="put"||p==="add";if(!R&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);const{length:O}=y||b||{length:1};if(y&&b&&y.length!==b.length)throw new Error("Given keys array must have same length as given values array.");if(O===0)return E({numFailures:0,failures:{},results:[],lastResult:void 0});let C;const S=[],k=[];let T=0;const F=ne=>{++T,cn(ne)};if(p==="deleteRange"){if(g.type===4)return E({numFailures:T,failures:k,results:[],lastResult:void 0});g.type===3?S.push(C=_.clear()):S.push(C=_.delete(n(g)))}else{const[ne,Y]=R?A?[b,y]:[b,null]:[y,null];if(R)for(let K=0;K<O;++K)S.push(C=Y&&Y[K]!==void 0?_[p](ne[K],Y[K]):_[p](ne[K])),C.onerror=F;else for(let K=0;K<O;++K)S.push(C=_[p](ne[K])),C.onerror=F}const W=ne=>{const Y=ne.target.result;S.forEach((K,ve)=>K.error!=null&&(k[ve]=K.error)),E({numFailures:T,failures:k,results:p==="delete"?y:S.map(K=>K.result),lastResult:Y})};C.onerror=ne=>{F(ne),W(ne)},C.onsuccess=W})},getMany:({trans:h,keys:p})=>new Promise((y,b)=>{y=te(y);const g=h.objectStore(l),E=p.length,w=new Array(E);let _,A=0,R=0;const O=S=>{const k=S.target;w[k._pos]=k.result,++R===A&&y(w)},C=Qe(b);for(let S=0;S<E;++S)p[S]!=null&&(_=g.get(p[S]),_._pos=S,_.onsuccess=O,_.onerror=C,++A);A===0&&y(w)}),get:({trans:h,key:p})=>new Promise((y,b)=>{y=te(y);const g=h.objectStore(l).get(p);g.onsuccess=E=>y(E.target.result),g.onerror=Qe(b)}),query:function(h){return p=>new Promise((y,b)=>{y=te(y);const{trans:g,values:E,limit:w,query:_}=p,A=w===1/0?void 0:w,{index:R,range:O}=_,C=g.objectStore(l),S=R.isPrimaryKey?C:C.index(R.name),k=n(O);if(w===0)return y({result:[]});if(h){const T=E?S.getAll(k,A):S.getAllKeys(k,A);T.onsuccess=F=>y({result:F.target.result}),T.onerror=Qe(b)}else{let T=0;const F=E||!("openKeyCursor"in S)?S.openCursor(k):S.openKeyCursor(k),W=[];F.onsuccess=ne=>{const Y=F.result;return Y?(W.push(E?Y.value:Y.primaryKey),++T===w?y({result:W}):void Y.continue()):y({result:W})},F.onerror=Qe(b)}})}(o),openCursor:function({trans:h,values:p,query:y,reverse:b,unique:g}){return new Promise((E,w)=>{E=te(E);const{index:_,range:A}=y,R=h.objectStore(l),O=_.isPrimaryKey?R:R.index(_.name),C=b?g?"prevunique":"prev":g?"nextunique":"next",S=p||!("openKeyCursor"in O)?O.openCursor(n(A),C):O.openKeyCursor(n(A),C);S.onerror=Qe(w),S.onsuccess=te(k=>{const T=S.result;if(!T)return void E(null);T.___id=++b_,T.done=!1;const F=T.continue.bind(T);let W=T.continuePrimaryKey;W&&(W=W.bind(T));const ne=T.advance.bind(T),Y=()=>{throw new Error("Cursor not stopped")};T.trans=h,T.stop=T.continue=T.continuePrimaryKey=T.advance=()=>{throw new Error("Cursor not started")},T.fail=te(w),T.next=function(){let K=1;return this.start(()=>K--?this.continue():this.stop()).then(()=>this)},T.start=K=>{const ve=new Promise((z,he)=>{z=te(z),S.onerror=Qe(he),T.fail=he,T.stop=ye=>{T.stop=T.continue=T.continuePrimaryKey=T.advance=Y,z(ye)}}),ae=()=>{if(S.result)try{K()}catch(z){T.fail(z)}else T.done=!0,T.start=()=>{throw new Error("Cursor behind last entry")},T.stop()};return S.onsuccess=te(z=>{S.onsuccess=ae,ae()}),T.continue=F,T.continuePrimaryKey=W,T.advance=ne,ae(),ve},E(T)},w)})},count({query:h,trans:p}){const{index:y,range:b}=h;return new Promise((g,E)=>{const w=p.objectStore(l),_=y.isPrimaryKey?w:w.index(y.name),A=n(b),R=A?_.count(A):_.count();R.onsuccess=te(O=>g(O.target.result)),R.onerror=Qe(E)})}}}(u)),a={};return s.forEach(u=>a[u.name]=u),{stack:"dbcore",transaction:e.transaction.bind(e),table(u){if(!a[u])throw new Error(`Table '${u}' not found`);return a[u]},MIN_KEY:-1/0,MAX_KEY:ln(t),schema:i}}function gs({_novip:e},t){const r=t.db,n=function(i,o,{IDBKeyRange:s,indexedDB:a},u){return{dbcore:function(l,h){return h.reduce((p,{create:y})=>({...p,...y(p)}),l)}(w_(o,s,u),i.dbcore)}}(e._middlewares,r,e._deps,t);e.core=n.dbcore,e.tables.forEach(i=>{const o=i.name;e.core.schema.tables.some(s=>s.name===o)&&(i.core=e.core.table(o),e[o]instanceof e.Table&&(e[o].core=i.core))})}function Ai({_novip:e},t,r,n){r.forEach(i=>{const o=n[i];t.forEach(s=>{const a=pa(s,i);(!a||"value"in a&&a.value===void 0)&&(s===e.Transaction.prototype||s instanceof e.Transaction?ft(s,i,{get(){return this.table(i)},set(u){Qf(this,i,{value:u,writable:!0,configurable:!0,enumerable:!0})}}):s[i]=new e.Table(i,o))})})}function bs({_novip:e},t){t.forEach(r=>{for(let n in r)r[n]instanceof e.Table&&delete r[n]})}function __(e,t){return e._cfg.version-t._cfg.version}function x_(e,t,r,n){const i=e._dbSchema,o=e._createTransaction("readwrite",e._storeNames,i);o.create(r),o._completion.catch(n);const s=o._reject.bind(o),a=B.transless||B;It(()=>{B.trans=o,B.transless=a,t===0?(fe(i).forEach(u=>{Do(r,u,i[u].primKey,i[u].indexes)}),gs(e,r),$.follow(()=>e.on.populate.fire(o)).catch(s)):function({_novip:u},c,l,h){const p=[],y=u._versions;let b=u._dbSchema=_s(u,u.idbdb,h),g=!1;function E(){return p.length?$.resolve(p.shift()(l.idbtrans)).then(E):$.resolve()}return y.filter(w=>w._cfg.version>=c).forEach(w=>{p.push(()=>{const _=b,A=w._cfg.dbschema;xs(u,_,h),xs(u,A,h),b=u._dbSchema=A;const R=vh(_,A);R.add.forEach(C=>{Do(h,C[0],C[1].primKey,C[1].indexes)}),R.change.forEach(C=>{if(C.recreate)throw new M.Upgrade("Not yet support for changing primary key");{const S=h.objectStore(C.name);C.add.forEach(k=>ws(S,k)),C.change.forEach(k=>{S.deleteIndex(k.name),ws(S,k)}),C.del.forEach(k=>S.deleteIndex(k))}});const O=w._cfg.contentUpgrade;if(O&&w._cfg.version>c){gs(u,h),l._memoizedTables={},g=!0;let C=Jf(A);R.del.forEach(F=>{C[F]=_[F]}),bs(u,[u.Transaction.prototype]),Ai(u,[u.Transaction.prototype],fe(C),C),l.schema=C;const S=ya(O);let k;S&&Fr();const T=$.follow(()=>{if(k=O(l),k&&S){var F=gt.bind(null,null);k.then(F,F)}});return k&&typeof k.then=="function"?$.resolve(k):T.then(()=>k)}}),p.push(_=>{(!g||!l_)&&function(A,R){[].slice.call(R.db.objectStoreNames).forEach(O=>A[O]==null&&R.db.deleteObjectStore(O))}(w._cfg.dbschema,_),bs(u,[u.Transaction.prototype]),Ai(u,[u.Transaction.prototype],u._storeNames,u._dbSchema),l.schema=u._dbSchema})}),E().then(()=>{var w,_;_=h,fe(w=b).forEach(A=>{_.db.objectStoreNames.contains(A)||Do(_,A,w[A].primKey,w[A].indexes)})})}(e,t,o,r).catch(s)})}function vh(e,t){const r={del:[],add:[],change:[]};let n;for(n in e)t[n]||r.del.push(n);for(n in t){const i=e[n],o=t[n];if(i){const s={name:n,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(o.primKey.keyPath||"")||i.primKey.auto!==o.primKey.auto&&!qi)s.recreate=!0,r.change.push(s);else{const a=i.idxByName,u=o.idxByName;let c;for(c in a)u[c]||s.del.push(c);for(c in u){const l=a[c],h=u[c];l?l.src!==h.src&&s.change.push(h):s.add.push(h)}(s.del.length>0||s.add.length>0||s.change.length>0)&&r.change.push(s)}}else r.add.push([n,o])}return r}function Do(e,t,r,n){const i=e.db.createObjectStore(t,r.keyPath?{keyPath:r.keyPath,autoIncrement:r.auto}:{autoIncrement:r.auto});return n.forEach(o=>ws(i,o)),i}function ws(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function _s(e,t,r){const n={};return wi(t.objectStoreNames,0).forEach(i=>{const o=r.objectStore(i);let s=o.keyPath;const a=ms(yh(s),s||"",!1,!1,!!o.autoIncrement,s&&typeof s!="string",!0),u=[];for(let l=0;l<o.indexNames.length;++l){const h=o.index(o.indexNames[l]);s=h.keyPath;var c=ms(h.name,s,!!h.unique,!!h.multiEntry,!1,s&&typeof s!="string",!1);u.push(c)}n[i]=mh(i,a,u)}),n}function xs({_novip:e},t,r){const n=r.db.objectStoreNames;for(let i=0;i<n.length;++i){const o=n[i],s=r.objectStore(o);e._hasGetAll="getAll"in s;for(let a=0;a<s.indexNames.length;++a){const u=s.indexNames[a],c=s.index(u).keyPath,l=typeof c=="string"?c:"["+wi(c).join("+")+"]";if(t[o]){const h=t[o].idxByName[l];h&&(h.name=u,delete t[o].idxByName[l],t[o].idxByName[u]=h)}}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&X.WorkerGlobalScope&&X instanceof X.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class E_{_parseStoresSpec(t,r){fe(t).forEach(n=>{if(t[n]!==null){var i=t[n].split(",").map((s,a)=>{const u=(s=s.trim()).replace(/([&*]|\+\+)/g,""),c=/^\[/.test(u)?u.match(/^\[(.*)\]$/)[1].split("+"):u;return ms(u,c||null,/\&/.test(s),/\*/.test(s),/\+\+/.test(s),_e(c),a===0)}),o=i.shift();if(o.multi)throw new M.Schema("Primary key cannot be multi-valued");i.forEach(s=>{if(s.auto)throw new M.Schema("Only primary key can be marked as autoIncrement (++)");if(!s.keyPath)throw new M.Schema("Index must have a name and cannot be an empty string")}),r[n]=mh(n,o,i)}})}stores(t){const r=this.db;this._cfg.storesSource=this._cfg.storesSource?Oe(this._cfg.storesSource,t):t;const n=r._versions,i={};let o={};return n.forEach(s=>{Oe(i,s._cfg.storesSource),o=s._cfg.dbschema={},s._parseStoresSpec(i,o)}),r._dbSchema=o,bs(r,[r._allTables,r,r.Transaction.prototype]),Ai(r,[r._allTables,r,r.Transaction.prototype,this._cfg.tables],fe(o),o),r._storeNames=fe(o),this}upgrade(t){return this._cfg.contentUpgrade=ga(this._cfg.contentUpgrade||V,t),this}}function xa(e,t){let r=e._dbNamesDB;return r||(r=e._dbNamesDB=new zt("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t}),r.version(1).stores({dbnames:"name"})),r.table("dbnames")}function Ea(e){return e&&typeof e.databases=="function"}function Es(e){return It(function(){return B.letThrough=!0,e()})}function S_(){var e;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(t){var r=function(){return indexedDB.databases().finally(t)};e=setInterval(r,100),r()}).finally(function(){return clearInterval(e)}):Promise.resolve()}function O_(e){const t=e._state,{indexedDB:r}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?de(t.dbOpenError):e);Ze&&(t.openCanceller._stackHolder=nr()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;const n=t.openCanceller;function i(){if(t.openCanceller!==n)throw new M.DatabaseClosed("db.open() was cancelled")}let o=t.dbReadyResolve,s=null,a=!1;return $.race([n,(typeof navigator>"u"?$.resolve():S_()).then(()=>new $((u,c)=>{if(i(),!r)throw new M.MissingAPI;const l=e.name,h=t.autoSchema?r.open(l):r.open(l,Math.round(10*e.verno));if(!h)throw new M.MissingAPI;h.onerror=Qe(c),h.onblocked=te(e._fireOnBlocked),h.onupgradeneeded=te(p=>{if(s=h.transaction,t.autoSchema&&!e._options.allowEmptyDB){h.onerror=cn,s.abort(),h.result.close();const b=r.deleteDatabase(l);b.onsuccess=b.onerror=te(()=>{c(new M.NoSuchDatabase(`Database ${l} doesnt exist`))})}else{s.onerror=Qe(c);var y=p.oldVersion>Math.pow(2,62)?0:p.oldVersion;a=y<1,e._novip.idbdb=h.result,x_(e,y/10,s,c)}},c),h.onsuccess=te(()=>{s=null;const p=e._novip.idbdb=h.result,y=wi(p.objectStoreNames);if(y.length>0)try{const g=p.transaction((b=y).length===1?b[0]:b,"readonly");t.autoSchema?function({_novip:E},w,_){E.verno=w.version/10;const A=E._dbSchema=_s(0,w,_);E._storeNames=wi(w.objectStoreNames,0),Ai(E,[E._allTables],fe(A),A)}(e,p,g):(xs(e,e._dbSchema,g),function(E,w){const _=vh(_s(0,E.idbdb,w),E._dbSchema);return!(_.add.length||_.change.some(A=>A.add.length||A.change.length))}(e,g)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),gs(e,g)}catch{}var b;Yr.push(e),p.onversionchange=te(g=>{t.vcFired=!0,e.on("versionchange").fire(g)}),p.onclose=te(g=>{e.on("close").fire(g)}),a&&function({indexedDB:g,IDBKeyRange:E},w){!Ea(g)&&w!=="__dbnames"&&xa(g,E).put({name:w}).catch(V)}(e._deps,l),u()},c)}))]).then(()=>(i(),t.onReadyBeingFired=[],$.resolve(Es(()=>e.on.ready.fire(e.vip))).then(function u(){if(t.onReadyBeingFired.length>0){let c=t.onReadyBeingFired.reduce(ga,V);return t.onReadyBeingFired=[],$.resolve(Es(()=>c(e.vip))).then(u)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(u=>{t.dbOpenError=u;try{s&&s.abort()}catch{}return n===t.openCanceller&&e._close(),de(u)}).finally(()=>{t.openComplete=!0,o()})}function Ss(e){var t=o=>e.next(o),r=i(t),n=i(o=>e.throw(o));function i(o){return s=>{var a=o(s),u=a.value;return a.done?u:u&&typeof u.then=="function"?u.then(r,n):_e(u)?Promise.all(u).then(r,n):r(u)}}return i(t)()}function A_(e,t,r){var n=arguments.length;if(n<2)throw new M.InvalidArgument("Too few arguments");for(var i=new Array(n-1);--n;)i[n-1]=arguments[n];r=i.pop();var o=Yf(i);return[e,o,r]}function gh(e,t,r,n,i){return $.resolve().then(()=>{const o=B.transless||B,s=e._createTransaction(t,r,e._dbSchema,n),a={trans:s,transless:o};if(n)s.idbtrans=n.idbtrans;else try{s.create(),e._state.PR1398_maxLoop=3}catch(h){return h.name===va.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>gh(e,t,r,null,i))):de(h)}const u=ya(i);let c;u&&Fr();const l=$.follow(()=>{if(c=i.call(s,s),c)if(u){var h=gt.bind(null,null);c.then(h,h)}else typeof c.next=="function"&&typeof c.throw=="function"&&(c=Ss(c))},a);return(c&&typeof c.then=="function"?$.resolve(c).then(h=>s.active?h:de(new M.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):l.then(()=>c)).then(h=>(n&&s._resolve(),s._completion.then(()=>h))).catch(h=>(s._reject(h),de(h)))})}function qn(e,t,r){const n=_e(e)?e.slice():[e];for(let i=0;i<r;++i)n.push(t);return n}const C_={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){const r=e.table(t),{schema:n}=r,i={},o=[];function s(l,h,p){const y=Zr(l),b=i[y]=i[y]||[],g=l==null?0:typeof l=="string"?1:l.length,E=h>0,w={...p,isVirtual:E,keyTail:h,keyLength:g,extractKey:vs(l),unique:!E&&p.unique};return b.push(w),w.isPrimaryKey||o.push(w),g>1&&s(g===2?l[0]:l.slice(0,g-1),h+1,p),b.sort((_,A)=>_.keyTail-A.keyTail),w}const a=s(n.primaryKey.keyPath,0,n.primaryKey);i[":id"]=[a];for(const l of n.indexes)s(l.keyPath,0,l);function u(l){const h=l.query.index;return h.isVirtual?{...l,query:{index:h,range:(p=l.query.range,y=h.keyTail,{type:p.type===1?2:p.type,lower:qn(p.lower,p.lowerOpen?e.MAX_KEY:e.MIN_KEY,y),lowerOpen:!0,upper:qn(p.upper,p.upperOpen?e.MIN_KEY:e.MAX_KEY,y),upperOpen:!0})}}:l;var p,y}return{...r,schema:{...n,primaryKey:a,indexes:o,getIndexByKeyPath:function(l){const h=i[Zr(l)];return h&&h[0]}},count:l=>r.count(u(l)),query:l=>r.query(u(l)),openCursor(l){const{keyTail:h,isVirtual:p,keyLength:y}=l.query.index;return p?r.openCursor(u(l)).then(b=>b&&function(g){return Object.create(g,{continue:{value:function(w){w!=null?g.continue(qn(w,l.reverse?e.MAX_KEY:e.MIN_KEY,h)):l.unique?g.continue(g.key.slice(0,y).concat(l.reverse?e.MIN_KEY:e.MAX_KEY,h)):g.continue()}},continuePrimaryKey:{value(w,_){g.continuePrimaryKey(qn(w,e.MAX_KEY,h),_)}},primaryKey:{get:()=>g.primaryKey},key:{get(){const w=g.key;return y===1?w[0]:w.slice(0,y)}},value:{get:()=>g.value}})}(b)):r.openCursor(l)}}}}}};function Sa(e,t,r,n){return r=r||{},n=n||"",fe(e).forEach(i=>{if(Me(t,i)){var o=e[i],s=t[i];if(typeof o=="object"&&typeof s=="object"&&o&&s){const a=is(o);a!==is(s)?r[n+i]=t[i]:a==="Object"?Sa(o,s,r,n+i+"."):o!==s&&(r[n+i]=t[i])}else o!==s&&(r[n+i]=t[i])}else r[n+i]=void 0}),fe(t).forEach(i=>{Me(e,i)||(r[n+i]=t[i])}),r}const D_={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){const r=e.table(t),{primaryKey:n}=r.schema;return{...r,mutate(o){const s=B.trans,{deleting:a,creating:u,updating:c}=s.table(t).hook;switch(o.type){case"add":if(u.fire===V)break;return s._promise("readwrite",()=>l(o),!0);case"put":if(u.fire===V&&c.fire===V)break;return s._promise("readwrite",()=>l(o),!0);case"delete":if(a.fire===V)break;return s._promise("readwrite",()=>l(o),!0);case"deleteRange":if(a.fire===V)break;return s._promise("readwrite",()=>function(p){return h(p.trans,p.range,1e4)}(o),!0)}return r.mutate(o);function l(p){const y=B.trans,b=p.keys||function(g,E){return E.type==="delete"?E.keys:E.keys||E.values.map(g.extractKey)}(n,p);if(!b)throw new Error("Keys missing");return(p=p.type==="add"||p.type==="put"?{...p,keys:b}:{...p}).type!=="delete"&&(p.values=[...p.values]),p.keys&&(p.keys=[...p.keys]),function(g,E,w){return E.type==="add"?Promise.resolve([]):g.getMany({trans:E.trans,keys:w,cache:"immutable"})}(r,p,b).then(g=>{const E=b.map((w,_)=>{const A=g[_],R={onerror:null,onsuccess:null};if(p.type==="delete")a.fire.call(R,w,A,y);else if(p.type==="add"||A===void 0){const O=u.fire.call(R,w,p.values[_],y);w==null&&O!=null&&(w=O,p.keys[_]=w,n.outbound||Ne(p.values[_],n.keyPath,w))}else{const O=Sa(A,p.values[_]),C=c.fire.call(R,O,w,A,y);if(C){const S=p.values[_];Object.keys(C).forEach(k=>{Me(S,k)?S[k]=C[k]:Ne(S,k,C[k])})}}return R});return r.mutate(p).then(({failures:w,results:_,numFailures:A,lastResult:R})=>{for(let O=0;O<b.length;++O){const C=_?_[O]:b[O],S=E[O];C==null?S.onerror&&S.onerror(w[O]):S.onsuccess&&S.onsuccess(p.type==="put"&&g[O]?p.values[O]:C)}return{failures:w,results:_,numFailures:A,lastResult:R}}).catch(w=>(E.forEach(_=>_.onerror&&_.onerror(w)),Promise.reject(w)))})}function h(p,y,b){return r.query({trans:p,values:!1,query:{index:n,range:y},limit:b}).then(({result:g})=>l({type:"delete",keys:g,trans:p}).then(E=>E.numFailures>0?Promise.reject(E.failures[0]):g.length<b?{failures:[],numFailures:0,lastResult:void 0}:h(p,{...y,lower:g[g.length-1],lowerOpen:!0},b)))}}}}})};function bh(e,t,r){try{if(!t||t.keys.length<e.length)return null;const n=[];for(let i=0,o=0;i<t.keys.length&&o<e.length;++i)Ee(t.keys[i],e[o])===0&&(n.push(r?An(t.values[i]):t.values[i]),++o);return n.length===e.length?n:null}catch{return null}}const P_={stack:"dbcore",level:-1,create:e=>({table:t=>{const r=e.table(t);return{...r,getMany:n=>{if(!n.cache)return r.getMany(n);const i=bh(n.keys,n.trans._cache,n.cache==="clone");return i?$.resolve(i):r.getMany(n).then(o=>(n.trans._cache={keys:n.keys,values:n.cache==="clone"?An(o):o},o))},mutate:n=>(n.type!=="add"&&(n.trans._cache=null),r.mutate(n))}}})};function Oa(e){return!("from"in e)}const nt=function(e,t){if(!this){const r=new nt;return e&&"d"in e&&Oe(r,e),r}Oe(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function fn(e,t,r){const n=Ee(t,r);if(isNaN(n))return;if(n>0)throw RangeError();if(Oa(e))return Oe(e,{from:t,to:r,d:1});const i=e.l,o=e.r;if(Ee(r,e.from)<0)return i?fn(i,t,r):e.l={from:t,to:r,d:1,l:null,r:null},fc(e);if(Ee(t,e.to)>0)return o?fn(o,t,r):e.r={from:t,to:r,d:1,l:null,r:null},fc(e);Ee(t,e.from)<0&&(e.from=t,e.l=null,e.d=o?o.d+1:1),Ee(r,e.to)>0&&(e.to=r,e.r=null,e.d=e.l?e.l.d+1:1);const s=!e.r;i&&!e.l&&Ci(e,i),o&&s&&Ci(e,o)}function Ci(e,t){Oa(t)||function r(n,{from:i,to:o,l:s,r:a}){fn(n,i,o),s&&r(n,s),a&&r(n,a)}(e,t)}function I_(e,t){const r=Os(t);let n=r.next();if(n.done)return!1;let i=n.value;const o=Os(e);let s=o.next(i.from),a=s.value;for(;!n.done&&!s.done;){if(Ee(a.from,i.to)<=0&&Ee(a.to,i.from)>=0)return!0;Ee(i.from,a.from)<0?i=(n=r.next(a.from)).value:a=(s=o.next(i.from)).value}return!1}function Os(e){let t=Oa(e)?null:{s:0,n:e};return{next(r){const n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&Ee(r,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||Ee(r,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function fc(e){var t,r;const n=(((t=e.r)===null||t===void 0?void 0:t.d)||0)-(((r=e.l)===null||r===void 0?void 0:r.d)||0),i=n>1?"r":n<-1?"l":"";if(i){const o=i==="r"?"l":"r",s={...e},a=e[i];e.from=a.from,e.to=a.to,e[i]=a[i],s[i]=a[o],e[o]=s,s.d=hc(s)}e.d=hc(e)}function hc({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}kr(nt.prototype,{add(e){return Ci(this,e),this},addKey(e){return fn(this,e,e),this},addKeys(e){return e.forEach(t=>fn(this,t,t)),this},[os](){return Os(this)}});const R_={stack:"dbcore",level:0,create:e=>{const t=e.schema.name,r=new nt(e.MIN_KEY,e.MAX_KEY);return{...e,table:n=>{const i=e.table(n),{schema:o}=i,{primaryKey:s}=o,{extractKey:a,outbound:u}=s,c={...i,mutate:p=>{const y=p.trans,b=y.mutatedParts||(y.mutatedParts={}),g=C=>{const S=`idb://${t}/${n}/${C}`;return b[S]||(b[S]=new nt)},E=g(""),w=g(":dels"),{type:_}=p;let[A,R]=p.type==="deleteRange"?[p.range]:p.type==="delete"?[p.keys]:p.values.length<50?[[],p.values]:[];const O=p.trans._cache;return i.mutate(p).then(C=>{if(_e(A)){_!=="delete"&&(A=C.results),E.addKeys(A);const S=bh(A,O);S||_==="add"||w.addKeys(A),(S||R)&&function(k,T,F,W){function ne(Y){const K=k(Y.name||"");function ve(z){return z!=null?Y.extractKey(z):null}const ae=z=>Y.multiEntry&&_e(z)?z.forEach(he=>K.addKey(he)):K.addKey(z);(F||W).forEach((z,he)=>{const ye=F&&ve(F[he]),qe=W&&ve(W[he]);Ee(ye,qe)!==0&&(ye!=null&&ae(ye),qe!=null&&ae(qe))})}T.indexes.forEach(ne)}(g,o,S,R)}else if(A){const S={from:A.lower,to:A.upper};w.add(S),E.add(S)}else E.add(r),w.add(r),o.indexes.forEach(S=>g(S.name).add(r));return C})}},l=({query:{index:p,range:y}})=>{var b,g;return[p,new nt((b=y.lower)!==null&&b!==void 0?b:e.MIN_KEY,(g=y.upper)!==null&&g!==void 0?g:e.MAX_KEY)]},h={get:p=>[s,new nt(p.key)],getMany:p=>[s,new nt().addKeys(p.keys)],count:l,query:l,openCursor:l};return fe(h).forEach(p=>{c[p]=function(y){const{subscr:b}=B;if(b){const g=R=>{const O=`idb://${t}/${n}/${R}`;return b[O]||(b[O]=new nt)},E=g(""),w=g(":dels"),[_,A]=h[p](y);if(g(_.name||"").add(A),!_.isPrimaryKey){if(p!=="count"){const R=p==="query"&&u&&y.values&&i.query({...y,values:!1});return i[p].apply(this,arguments).then(O=>{if(p==="query"){if(u&&y.values)return R.then(({result:S})=>(E.addKeys(S),O));const C=y.values?O.result.map(a):O.result;y.values?E.addKeys(C):w.addKeys(C)}else if(p==="openCursor"){const C=O,S=y.values;return C&&Object.create(C,{key:{get:()=>(w.addKey(C.primaryKey),C.key)},primaryKey:{get(){const k=C.primaryKey;return w.addKey(k),k}},value:{get:()=>(S&&E.addKey(C.primaryKey),C.value)}})}return O})}w.add(r)}}return i[p].apply(this,arguments)}}),c}}}};class zt{constructor(t,r){this._middlewares={},this.verno=0;const n=zt.dependencies;this._options=r={addons:zt.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...r},this._deps={indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange};const{addons:i}=r;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const o={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:V,dbReadyPromise:null,cancelOpen:V,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var s;o.dbReadyPromise=new $(a=>{o.dbReadyResolve=a}),o.openCanceller=new $((a,u)=>{o.cancelOpen=u}),this._state=o,this.name=t,this.on=Xr(this,"populate","blocked","versionchange","close",{ready:[ga,V]}),this.on.ready.subscribe=zf(this.on.ready.subscribe,a=>(u,c)=>{zt.vip(()=>{const l=this._state;if(l.openComplete)l.dbOpenError||$.resolve().then(u),c&&a(u);else if(l.onReadyBeingFired)l.onReadyBeingFired.push(u),c&&a(u);else{a(u);const h=this;c||a(function p(){h.on.ready.unsubscribe(u),h.on.ready.unsubscribe(p)})}})}),this.Collection=(s=this,jr(p_.prototype,function(a,u){this.db=s;let c=hh,l=null;if(u)try{c=u()}catch(b){l=b}const h=a._ctx,p=h.table,y=p.hook.reading.fire;this._ctx={table:p,index:h.index,isPrimKey:!h.index||p.schema.primKey.keyPath&&h.index===p.schema.primKey.name,range:c,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:l,or:h.or,valueMapper:y!==an?y:null}})),this.Table=function(a){return jr(d_.prototype,function(u,c,l){this.db=a,this._tx=l,this.name=u,this.schema=c,this.hook=a._allTables[u]?a._allTables[u].hook:Xr(null,{creating:[e_,V],reading:[Zw,an],updating:[r_,V],deleting:[t_,V]})})}(this),this.Transaction=function(a){return jr(g_.prototype,function(u,c,l,h,p){this.db=a,this.mode=u,this.storeNames=c,this.schema=l,this.chromeTransactionDurability=h,this.idbtrans=null,this.on=Xr(this,"complete","error","abort"),this.parent=p||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new $((y,b)=>{this._resolve=y,this._reject=b}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},y=>{var b=this.active;return this.active=!1,this.on.error.fire(y),this.parent?this.parent._reject(y):b&&this.idbtrans&&this.idbtrans.abort(),de(y)})})}(this),this.Version=function(a){return jr(E_.prototype,function(u){this.db=a,this._cfg={version:u,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(a){return jr(ph.prototype,function(u,c,l){this.db=a,this._ctx={table:u,index:c===":id"?null:c,or:l};const h=a._deps.indexedDB;if(!h)throw new M.MissingAPI;this._cmp=this._ascending=h.cmp.bind(h),this._descending=(p,y)=>h.cmp(y,p),this._max=(p,y)=>h.cmp(p,y)>0?p:y,this._min=(p,y)=>h.cmp(p,y)<0?p:y,this._IDBKeyRange=a._deps.IDBKeyRange})}(this),this.on("versionchange",a=>{a.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",a=>{!a.newVersion||a.newVersion<a.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${a.oldVersion/10}`)}),this._maxKey=ln(r.IDBKeyRange),this._createTransaction=(a,u,c,l)=>new this.Transaction(a,u,c,this._options.chromeTransactionDurability,l),this._fireOnBlocked=a=>{this.on("blocked").fire(a),Yr.filter(u=>u.name===this.name&&u!==this&&!u._state.vcFired).map(u=>u.on("versionchange").fire(a))},this.use(C_),this.use(D_),this.use(R_),this.use(P_),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(a=>a(this))}version(t){if(isNaN(t)||t<.1)throw new M.Type("Given version is not a positive number");if(t=Math.round(10*t)/10,this.idbdb||this._state.isBeingOpened)throw new M.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,t);const r=this._versions;var n=r.filter(i=>i._cfg.version===t)[0];return n||(n=new this.Version(t),r.push(n),r.sort(__),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(t){return this.idbdb&&(this._state.openComplete||B.letThrough||this._vip)?t():new $((r,n)=>{if(this._state.openComplete)return n(new M.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new M.DatabaseClosed);this.open().catch(V)}this._state.dbReadyPromise.then(r,n)}).then(t)}use({stack:t,create:r,level:n,name:i}){i&&this.unuse({stack:t,name:i});const o=this._middlewares[t]||(this._middlewares[t]=[]);return o.push({stack:t,create:r,level:n??10,name:i}),o.sort((s,a)=>s.level-a.level),this}unuse({stack:t,name:r,create:n}){return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(i=>n?i.create!==n:!!r&&i.name!==r)),this}open(){return O_(this)}_close(){const t=this._state,r=Yr.indexOf(this);if(r>=0&&Yr.splice(r,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}t.dbReadyPromise=new $(n=>{t.dbReadyResolve=n}),t.openCanceller=new $((n,i)=>{t.cancelOpen=i})}close(){this._close();const t=this._state;this._options.autoOpen=!1,t.dbOpenError=new M.DatabaseClosed,t.isBeingOpened&&t.cancelOpen(t.dbOpenError)}delete(){const t=arguments.length>0,r=this._state;return new $((n,i)=>{const o=()=>{this.close();var s=this._deps.indexedDB.deleteDatabase(this.name);s.onsuccess=te(()=>{(function({indexedDB:a,IDBKeyRange:u},c){!Ea(a)&&c!=="__dbnames"&&xa(a,u).delete(c).catch(V)})(this._deps,this.name),n()}),s.onerror=Qe(i),s.onblocked=this._fireOnBlocked};if(t)throw new M.InvalidArgument("Arguments not allowed in db.delete()");r.isBeingOpened?r.dbReadyPromise.then(o):o()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const t=this._state.dbOpenError;return t&&t.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return fe(this._allTables).map(t=>this._allTables[t])}transaction(){const t=A_.apply(this,arguments);return this._transaction.apply(this,t)}_transaction(t,r,n){let i=B.trans;i&&i.db===this&&t.indexOf("!")===-1||(i=null);const o=t.indexOf("?")!==-1;let s,a;t=t.replace("!","").replace("?","");try{if(a=r.map(c=>{var l=c instanceof this.Table?c.name:c;if(typeof l!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return l}),t=="r"||t==="readonly")s="readonly";else{if(t!="rw"&&t!="readwrite")throw new M.InvalidArgument("Invalid transaction mode: "+t);s="readwrite"}if(i){if(i.mode==="readonly"&&s==="readwrite"){if(!o)throw new M.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&a.forEach(c=>{if(i&&i.storeNames.indexOf(c)===-1){if(!o)throw new M.SubTransaction("Table "+c+" not included in parent transaction.");i=null}}),o&&i&&!i.active&&(i=null)}}catch(c){return i?i._promise(null,(l,h)=>{h(c)}):de(c)}const u=gh.bind(null,this,s,a,i,n);return i?i._promise(s,u,"lock"):B.trans?Nr(B.transless,()=>this._whenReady(u)):this._whenReady(u)}table(t){if(!Me(this._allTables,t))throw new M.InvalidTable(`Table ${t} does not exist`);return this._allTables[t]}}const k_=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class T_{constructor(t){this._subscribe=t}subscribe(t,r,n){return this._subscribe(t&&typeof t!="function"?t:{next:t,error:r,complete:n})}[k_](){return this}}function wh(e,t){return fe(t).forEach(r=>{Ci(e[r]||(e[r]=new nt),t[r])}),e}function $_(e){return new T_(t=>{const r=ya(e);let n=!1,i={},o={};const s={get closed(){return n},unsubscribe:()=>{n=!0,kt.storagemutated.unsubscribe(l)}};t.start&&t.start(s);let a=!1,u=!1;function c(){return fe(o).some(p=>i[p]&&I_(i[p],o[p]))}const l=p=>{wh(i,p),c()&&h()},h=()=>{if(a||n)return;i={};const p={},y=function(b){r&&Fr();const g=()=>It(e,{subscr:b,trans:null}),E=B.trans?Nr(B.transless,g):g();return r&&E.then(gt,gt),E}(p);u||(kt("storagemutated",l),u=!0),a=!0,Promise.resolve(y).then(b=>{a=!1,n||(c()?h():(i={},o=p,t.next&&t.next(b)))},b=>{["DatabaseClosedError","AbortError"].includes(b?.name)||(a=!1,t.error&&t.error(b),s.unsubscribe())})};return h(),s})}let As;try{As={indexedDB:X.indexedDB||X.mozIndexedDB||X.webkitIndexedDB||X.msIndexedDB,IDBKeyRange:X.IDBKeyRange||X.webkitIDBKeyRange}}catch{As={indexedDB:null,IDBKeyRange:null}}const Bt=zt;function si(e){let t=st;try{st=!0,kt.storagemutated.fire(e)}finally{st=t}}kr(Bt,{...ei,delete:e=>new Bt(e,{addons:[]}).delete(),exists:e=>new Bt(e,{addons:[]}).open().then(t=>(t.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return function({indexedDB:t,IDBKeyRange:r}){return Ea(t)?Promise.resolve(t.databases()).then(n=>n.map(i=>i.name).filter(i=>i!=="__dbnames")):xa(t,r).toCollection().primaryKeys()}(Bt.dependencies).then(e)}catch{return de(new M.MissingAPI)}},defineClass:()=>function(e){Oe(this,e)},ignoreTransaction:e=>B.trans?Nr(B.transless,e):e(),vip:Es,async:function(e){return function(){try{var t=Ss(e.apply(this,arguments));return t&&typeof t.then=="function"?t:$.resolve(t)}catch(r){return de(r)}}},spawn:function(e,t,r){try{var n=Ss(e.apply(r,t||[]));return n&&typeof n.then=="function"?n:$.resolve(n)}catch(i){return de(i)}},currentTransaction:{get:()=>B.trans||null},waitFor:function(e,t){const r=$.resolve(typeof e=="function"?Bt.ignoreTransaction(e):e).timeout(t||6e4);return B.trans?B.trans.waitFor(r):r},Promise:$,debug:{get:()=>Ze,set:e=>{Zf(e,e==="dexie"?()=>!0:fh)}},derive:wr,extend:Oe,props:kr,override:zf,Events:Xr,on:kt,liveQuery:$_,extendObservabilitySet:wh,getByKeyPath:ht,setByKeyPath:Ne,delByKeyPath:function(e,t){typeof t=="string"?Ne(e,t,void 0):"length"in t&&[].map.call(t,function(r){Ne(e,r,void 0)})},shallowClone:Jf,deepClone:An,getObjectDiff:Sa,cmp:Ee,asap:Gf,minKey:-(1/0),addons:[],connections:Yr,errnames:va,dependencies:As,semVer:"4.0.0-alpha.4",version:"4.0.0-alpha.4".split(".").map(e=>parseInt(e)).reduce((e,t,r)=>e+t/Math.pow(10,2*r))}),Bt.maxKey=ln(Bt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(kt("storagemutated",e=>{if(!st){let t;qi?(t=document.createEvent("CustomEvent"),t.initCustomEvent("x-storagemutated-1",!0,!0,e)):t=new CustomEvent("x-storagemutated-1",{detail:e}),st=!0,dispatchEvent(t),st=!1}}),addEventListener("x-storagemutated-1",({detail:e})=>{st||si(e)}));let st=!1;if(typeof BroadcastChannel<"u"){const e=new BroadcastChannel("x-storagemutated-1");typeof e.unref=="function"&&e.unref(),kt("storagemutated",t=>{st||e.postMessage(t)}),e.onmessage=t=>{t.data&&si(t.data)}}else if(typeof self<"u"&&typeof navigator<"u"){kt("storagemutated",t=>{try{st||(typeof localStorage<"u"&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:t})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(r=>r.postMessage({type:"x-storagemutated-1",changedParts:t})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",t=>{if(t.key==="x-storagemutated-1"){const r=JSON.parse(t.newValue);r&&si(r.changedParts)}});const e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:t}){t&&t.type==="x-storagemutated-1"&&si(t.changedParts)})}$.rejectionMapper=function(e,t){if(!e||e instanceof _r||e instanceof TypeError||e instanceof SyntaxError||!e.name||!nc[e.name])return e;var r=new nc[e.name](t||e.message,e);return"stack"in e&&ft(r,"stack",{get:function(){return this.inner.stack}}),r},Zf(Ze,fh);var Di="docs",dc="deleted-docs",B_="changes",_h="dexie",xh=og,pc=new Map,ai=new Map;function M_(e,t,r,n){var i=Ke(n.primaryKey),o="rxdb-dexie-"+e+"--"+n.version+"--"+t,s=Je(pc,o,()=>{var a=(async()=>{var u=Z(r);u.autoOpen=!1;var c=new zt(o,u),l={[Di]:N_(n),[B_]:"++sequence, id",[dc]:i+",_meta.lwt,[_meta.lwt+"+i+"]"};return c.version(1).stores(l),await c.open(),{dexieDb:c,dexieTable:c[Di],dexieDeletedTable:c[dc]}})();return pc.set(o,s),ai.set(s,0),a});return s}async function L_(e){var t=await e,r=ai.get(e),n=r-1;n===0?(t.dexieDb.close(),ai.delete(e)):ai.set(e,n)}function F_(e){if(e.indexes){var t=new Set;e.indexes.forEach(r=>{var n=$s(r);n.forEach(i=>{if(!t.has(i)){t.add(i);var o=Pt(e,i);if(o.type==="boolean")throw D("DXE1",{schema:e,index:r,field:i})}})})}}var Cs="__";function tr(e){var t=e.split(".");if(t.length>1)return t.map(n=>tr(n)).join(".");if(e.startsWith("|")){var r=e.substring(1);return Cs+r}else return e}function Eh(e){var t=e.split(".");if(t.length>1)return t.map(n=>Eh(n)).join(".");if(e.startsWith(Cs)){var r=e.substring(Cs.length);return"|"+r}else return e}function Pi(e){if(!e||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(r=>Pi(r));if(typeof e=="object"){var t={};return Object.entries(e).forEach(([r,n])=>{typeof n=="object"&&(n=Pi(n)),t[tr(r)]=n}),t}}function Er(e){if(!e||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(r=>Er(r));if(typeof e=="object"){var t={};return Object.entries(e).forEach(([r,n])=>{(typeof n=="object"||Array.isArray(e))&&(n=Er(n)),t[Eh(r)]=n}),t}}function N_(e){var t=[],r=Ke(e.primaryKey);return t.push([r]),e.indexes&&e.indexes.forEach(n=>{var i=$s(n);t.push(i)}),t.push(["_meta.lwt",r]),t=t.map(n=>n.map(i=>tr(i))),t.map(n=>n.length===1?n[0]:"["+n.join("+")+"]").join(", ")}async function yc(e,t){var r=await e,[n,i]=await Promise.all([r.dexieTable.bulkGet(t),r.dexieDeletedTable.bulkGet(t)]),o=i.slice(0);return n.forEach((s,a)=>{s&&(o[a]=s)}),o}function mc(e){return e===Lt?-1/0:e}function Sh(e,t){if(!t){if(typeof window>"u")throw new Error("IDBKeyRange missing");t=window.IDBKeyRange}var r=e.startKeys.map(mc),n=e.endKeys.map(mc),i;if(e.index.length===1){var o=r[0]===n[0];i=t.bound(r[0],n[0],o?!1:!e.inclusiveStart,o?!1:!e.inclusiveEnd)}else i=t.bound(r,n,!e.inclusiveStart,!e.inclusiveEnd);return i}async function vc(e,t){var r=await e.internals,n=t.query,i=n.skip?n.skip:0,o=n.limit?n.limit:1/0,s=i+o,a=t.queryPlan,u=!1;a.selectorSatisfiedByIndex||(u=Zs(e.schema,t.query));var c=Sh(a,r.dexieDb._options.IDBKeyRange),l=a.index,h=[];if(await r.dexieDb.transaction("r",r.dexieTable,async y=>{var b=y.idbtrans,g=b.objectStore(Di),E;if(l.length===1&&l[0]===e.primaryPath)E=g;else{var w;l.length===1?w=tr(l[0]):w="["+l.map(A=>tr(A)).join("+")+"]",E=g.index(w)}var _=E.openCursor(c);await new Promise(A=>{_.onsuccess=function(R){var O=R.target.result;if(O){var C=Er(O.value);!C._deleted&&(!u||u(C))&&h.push(C),a.sortFieldsSameAsIndexFields&&h.length===s?A():O.continue()}else A()}})}),!a.sortFieldsSameAsIndexFields){var p=Ml(e.schema,t.query);h=h.sort(p)}return h=h.slice(i,s),{documents:h}}async function j_(e,t){var r=await e.internals,n=t.queryPlan,i=n.index,o=Sh(n,r.dexieDb._options.IDBKeyRange),s=-1;return await r.dexieDb.transaction("r",r.dexieTable,async a=>{var u=a.idbtrans,c=u.objectStore(Di),l;if(i.length===1&&i[0]===e.primaryPath)l=c;else{var h;i.length===1?h=tr(i[0]):h="["+i.map(y=>tr(y)).join("+")+"]",l=c.index(h)}var p=l.count(o);s=await new Promise((y,b)=>{p.onsuccess=function(){y(p.result)},p.onerror=g=>b(g)})}),s}var U_=be(),K_=function(){function e(r,n,i,o,s,a,u){this.changes$=new Ye,this.instanceId=U_++,this.closed=!1,this.storage=r,this.databaseName=n,this.collectionName=i,this.schema=o,this.internals=s,this.options=a,this.settings=u,this.primaryPath=Ke(this.schema.primaryKey)}var t=e.prototype;return t.bulkWrite=async function(n,i){tt(this),n.forEach(h=>{if(!h.document._rev||h.previous&&!h.previous._rev)throw D("SNH",{args:{row:h}})});var o=await this.internals,s={success:{},error:{}},a=n.map(h=>h.document[this.primaryPath]),u;if(await o.dexieDb.transaction("rw",o.dexieTable,o.dexieDeletedTable,async()=>{var h=new Map,p=await yc(this.internals,a);p.forEach(w=>{var _=w&&Er(w);return _&&h.set(_[this.primaryPath],_),_}),u=sy(this,this.primaryPath,h,n,i),s.error=u.errors;var y=[],b=[],g=[],E=[];u.bulkInsertDocs.forEach(w=>{var _=w.document[this.primaryPath];s.success[_]=w.document,y.push(w.document)}),u.bulkUpdateDocs.forEach(w=>{var _=w.document[this.primaryPath];if(s.success[_]=w.document,w.document._deleted&&w.previous&&!w.previous._deleted)b.push(_),g.push(w.document);else if(w.document._deleted&&w.previous&&w.previous._deleted)g.push(w.document);else if(!w.document._deleted)y.push(w.document);else throw D("SNH",{args:{row:w}})}),await Promise.all([y.length>0?o.dexieTable.bulkPut(y.map(w=>Pi(w))):ke,b.length>0?o.dexieTable.bulkDelete(b):ke,g.length>0?o.dexieDeletedTable.bulkPut(g.map(w=>Pi(w))):ke,E.length>0?o.dexieDeletedTable.bulkDelete(E):ke])}),u=se(u),u.eventBulk.events.length>0){var c=se(u.newestRow).document;u.eventBulk.checkpoint={id:c[this.primaryPath],lwt:c._meta.lwt};var l=be();u.eventBulk.events.forEach(h=>h.endTime=l),this.changes$.next(u.eventBulk)}return s},t.findDocumentsById=async function(n,i){tt(this);var o=await this.internals,s={};return await o.dexieDb.transaction("r",o.dexieTable,o.dexieDeletedTable,async()=>{var a;i?a=await yc(this.internals,n):a=await o.dexieTable.bulkGet(n),n.forEach((u,c)=>{var l=a[c];l&&(!l._deleted||i)&&(s[u]=Er(l))})}),s},t.query=function(n){return tt(this),vc(this,n)},t.count=async function(n){if(n.queryPlan.selectorSatisfiedByIndex){var i=await j_(this,n);return{count:i,mode:"fast"}}else{var o=await vc(this,n);return{count:o.documents.length,mode:"slow"}}},t.getChangedDocumentsSince=async function(n,i){tt(this);var o=i?i.lwt:Bs,s=i?i.id:"",a=await this.internals,[u,c]=await Promise.all([a.dexieTable,a.dexieDeletedTable].map(async p=>{var y=p.where("[_meta.lwt+"+this.primaryPath+"]").above([o,s]).limit(n),b=await y.toArray();return b.map(g=>Er(g))})),l=u.slice(0);Ri(l,c),l=_d(this.primaryPath,l),l=l.slice(0,n);var h=ld(l);return{documents:l,checkpoint:h?{id:h[this.primaryPath],lwt:h._meta.lwt}:i||{id:"",lwt:0}}},t.remove=async function(){tt(this);var n=await this.internals;return await Promise.all([n.dexieDeletedTable.clear(),n.dexieTable.clear()]),this.close()},t.changeStream=function(){return tt(this),this.changes$.asObservable()},t.cleanup=async function(n){tt(this);var i=await this.internals;return await i.dexieDb.transaction("rw",i.dexieDeletedTable,async()=>{var o=be()-n,s=await i.dexieDeletedTable.where("_meta.lwt").below(o).toArray(),a=s.map(u=>u[this.primaryPath]);await i.dexieDeletedTable.bulkDelete(a)}),!0},t.getAttachmentData=function(n,i,o){throw tt(this),new Error("Attachments are not implemented in the dexie RxStorage. Make a pull request.")},t.close=function(){return tt(this),this.closed=!0,this.changes$.complete(),L_(this.internals),ke},t.conflictResultionTasks=function(){return new Ye},t.resolveConflictResultionTask=async function(n){},e}();function q_(e,t,r){var n=M_(t.databaseName,t.collectionName,r,t.schema),i=new K_(e,t.databaseName,t.collectionName,t.schema,n,t.options,r);return v0(_h,t,i),Promise.resolve(i)}function tt(e){if(e.closed)throw new Error("RxStorageInstanceDexie is closed "+e.databaseName+"-"+e.collectionName)}var H_=function(){function e(r){this.name=_h,this.statics=xh,this.settings=r}var t=e.prototype;return t.createStorageInstance=function(n){return cy(n),F_(n.schema),q_(this,n,this.settings)},e}();function W_(e={}){var t=new H_(e);return t}function Q_(e){var t=Object.prototype.toString.call(e.queryObj)==="[object Object]";if(!t)throw ue("QU11",{op:e.op,collection:e.collection.name,queryObj:e.queryObj});var r=["selector","limit","skip","sort","index"];if(Object.keys(e.queryObj).forEach(n=>{if(!r.includes(n))throw ue("QU11",{op:e.op,collection:e.collection.name,queryObj:e.queryObj,key:n,args:{validKeys:r}})}),e.op==="count"&&(e.queryObj.limit||e.queryObj.skip))throw D("QU15",{collection:e.collection.name,query:e.queryObj})}function z_(e){var t=e.rxQuery.collection.schema.jsonSchema,r=e.mangoQuery.selector,n=Object.keys(t.properties);Object.keys(r).filter(a=>!a.startsWith("$")).filter(a=>!a.includes(".")).forEach(a=>{if(!n.includes(a))throw D("QU13",{schema:t,field:a,query:e.mangoQuery})});var i=t.indexes?t.indexes:[],o=e.mangoQuery.index;if(o){var s=i.find(a=>Or(a,o));if(!s)throw D("QU12",{collection:e.rxQuery.collection.name,query:e.mangoQuery,schema:t})}if(e.rxQuery.op==="count"&&!G_(e.rxQuery.collection.schema.jsonSchema,e.mangoQuery)&&!e.rxQuery.collection.database.allowSlowCount)throw D("QU14",{collection:e.rxQuery.collection,query:e.mangoQuery});e.mangoQuery.sort&&e.mangoQuery.sort.map(a=>Object.keys(a)[0]).filter(a=>!a.includes(".")).forEach(a=>{if(!n.includes(a))throw D("QU13",{schema:t,field:a,query:e.mangoQuery})})}function G_(e,t){var r=xh.prepareQuery(e,t);return r.queryPlan.selectorSatisfiedByIndex}function V_(e,t){if(!e)throw D("DOC20",{primaryKey:e,document:t});if(e!==e.trim())throw D("DOC21",{primaryKey:e,document:t});if(e.includes("\r")||e.includes(`
25
- `))throw D("DOC22",{primaryKey:e,document:t});if(e.includes('"'))throw D("DOC23",{primaryKey:e,document:t})}function J_(e){return!e||typeof e=="string"||typeof e=="number"?e:Fc(e)}var Y_="dev-mode",X_={name:Y_,rxdb:!0,init:()=>{console.warn(["-------------- RxDB dev-mode warning -------------------------------","you are seeing this because you use the RxDB dev-mode plugin https://rxdb.info/dev-mode.html","This is great in development mode, because it will run many checks to ensure","that you use RxDB correct. If you see this in production mode,","you did something wrong because the dev-mode plugin will decrease the performance.","","\uD83E\uDD17 Hint: To get the most out of RxDB, check out the Premium Plugins","to get access to faster storages and more professional features: https://rxdb.info/premium.html","","Also take part in the RxDB User Survey: https://rxdb.info/survey.html","---------------------------------------------------------------------"].join(`
26
- `))},overwritable:{isDevMode(){return!0},deepFreezeWhenDevMode:J_,tunnelErrorMessage(e){if(!tc[e])throw console.error("RxDB: Error-Code not known: "+e),new Error("Error-Code "+e+" not known, contact the maintainer");return tc[e]}},hooks:{preCreateRxSchema:{after:Lw},preCreateRxDatabase:{after:function(e){Uw(e)}},preCreateRxCollection:{after:function(e){if(jw(e),Fw(e.schema,e.methods),e.name.charAt(0)==="_")throw D("DB2",{name:e.name});if(!e.schema)throw D("DB4",{name:e.name,args:e})}},createRxDocument:{before:function(e){V_(e.primary,e.toJSON(!0))}},preCreateRxQuery:{after:function(e){Q_(e)}},prePrepareQuery:{after:e=>{z_(e)}},createRxCollection:{after:e=>{Eo(e.creator.statics),Eo(e.creator.methods),Eo(e.creator.attachments),e.creator.schema&&e.creator.migrationStrategies&&Nw(e.creator.schema,e.creator.migrationStrategies)}}}},Oh=new WeakMap;function Ah(e){return Je(Oh,e,()=>new al([]))}function Z_(e){var t=Oh.get(e);t&&t.complete()}var Ch=200,e1=function(){function e(r,n){this._migrated=!1,this.nonMigratedOldCollections=[],this.allOldCollections=[],this.newestCollection=r,this.migrationStrategies=n,this.currentSchema=r.schema,this.database=r.database,this.name=r.name}var t=e.prototype;return t.migrate=function(n=Ch){var i=this;if(this._migrated)throw D("DM1");this._migrated=!0;var o={done:!1,total:0,handled:0,success:0,deleted:0,percent:0},s=new Ye,a=Ah(this.newestCollection.database),u=a.getValue().slice(0);return u.push(s.asObservable()),a.next(u),r1(this).then(c=>{this.nonMigratedOldCollections=c,this.allOldCollections=this.nonMigratedOldCollections.slice(0);var l=this.database.storage;async function h(y,b){var g=l.statics.prepareQuery(y.schema,pi(b,{})),E=await y.count(g);return E.count}var p=Promise.all(this.nonMigratedOldCollections.map(y=>h(y.storageInstance,y.schema.jsonSchema)));return p}).then(c=>{var l=c.reduce((b,g)=>g=b+g,0);o.total=l,s.next({collection:this.newestCollection,state:Z(o)});for(var h=this.nonMigratedOldCollections.shift(),p=ke,y=function(){var b=c1(h,n);p=p.then(()=>new Promise(g=>{var E=b.subscribe({next:w=>{o.handled++,o[w.type]=o[w.type]+1,o.percent=Math.round(o.handled/o.total*100),s.next({collection:i.newestCollection,state:Z(o)})},error:w=>{E.unsubscribe(),i.allOldCollections.forEach(_=>_.storageInstance.close().catch(()=>{})),s.error(w)},complete:()=>{h&&h.storageInstance.close().catch(()=>{}),E.unsubscribe(),g()}})})),h=i.nonMigratedOldCollections.shift()};h;)y();return p}).then(()=>{o.done=!0,o.percent=100,s.next({collection:this.newestCollection,state:Z(o)}),s.complete()}),s.pipe(Te(c=>c.state))},t.migratePromise=function(n){return this._migratePromise||(this._migratePromise=Ph(this).then(i=>i?new Promise((o,s)=>{var a=this.migrate(n);a.subscribe(null,s,o),this.allOldCollections.forEach(u=>u.storageInstance.close().catch(()=>{}))}).catch(o=>{throw this.allOldCollections.forEach(s=>s.storageInstance.close().catch(()=>{})),o}):Fe)),this._migratePromise},e}();async function t1(e,t,r){var n=r.newestCollection.database,i={databaseInstanceToken:n.token,databaseName:n.name,collectionName:r.newestCollection.name,schema:t,options:r.newestCollection.instanceCreationOptions,multiInstance:n.multiInstance,devMode:ce.isDevMode()};Be("preCreateRxStorageInstance",i);var o=await n.storage.createStorageInstance(i),s={version:e,dataMigrator:r,newestCollection:r.newestCollection,database:n,schema:bl(t,n.hashFunction,!1),storageInstance:o};return s.storageInstance=Ws(s.database,o,t),s}function Dh(e){var t=gl(e.currentSchema.jsonSchema).map(r=>e.name+"-"+r);return e.database.internalStore.findDocumentsById(t.map(r=>yi(r,gr)),!1).then(r=>Object.values(r))}async function r1(e){var t=await Dh(e);return Promise.all(t.map(r=>r?t1(r.data.schema.version,r.data.schema,e):null).filter(r=>r!==null))}function Ph(e){return e.currentSchema.version===0?Fe:Dh(e).then(t=>t.length!==0)}function n1(e,t,r){if(r===null)return Ms;var n=e.dataMigrator.migrationStrategies[t](r,e),i=kd(n);return i}function i1(e,t){var r=e.database.storage,n=e.storageInstance,i=r.statics.prepareQuery(n.schema,{selector:{},sort:[{[e.schema.primaryPath]:"asc"}],limit:t,skip:0});return n.query(i).then(o=>o.documents.map(s=>(s=Z(s),s)))}function o1(e,t){var r=Z(t._attachments),n=at(t);n._attachments=r;for(var i=e.version+1,o=Promise.resolve(n),s=function(){var a=i;o=o.then(u=>n1(e,a,u)),i++};i<=e.newestCollection.schema.version;)s();return o.then(a=>a===null?Ms:(a._meta||(a._meta=dn()),a))}function s1(e,t){var r=Object.assign({},e,{_attachments:void 0,_rev:void 0}),n=Object.assign({},t,{_attachments:void 0,_rev:void 0});return Or(r,n)}async function a1(e,t){var r=at(t);await Promise.all(t.map(u=>Gt("preMigrateDocument",{docData:u,oldCollection:e})));var n=await Promise.all(t.map(u=>o1(e,u))),i=[],o=[];if(t.forEach((u,c)=>{var l=n[c],h={res:null,type:"",migrated:l,doc:u,oldCollection:e,newestCollection:e.newestCollection};if(o.push(h),s1(u,l)?l._rev=u._rev:l!==null&&(l._rev=ci(e.newestCollection.database.token,u)),l){var p=l._attachments,y=l;y._attachments=p,y._meta.lwt=be(),i.push(y),h.res=y,h.type="success"}else h.type="deleted"}),i.length){var s=e.newestCollection.storageInstance.originalStorageInstance;await s.bulkWrite(i.map(u=>({document:u})),"data-migrator-import")}await Promise.all(o.map(u=>Gt("postMigrateDocument",u)));var a=t.map((u,c)=>{var l=Z(u);return l._deleted=!0,l._attachments={},{previous:r[c],document:l}});return a.length&&await e.storageInstance.bulkWrite(a,"data-migrator-delete"),o}function u1(e){return e.storageInstance.remove().then(()=>e.database.removeCollectionDoc(e.dataMigrator.name,e.schema))}function c1(e,t=Ch){if(e._migrate)throw D("DM3");e._migrate=!0;var r=new Ye;return(()=>{var n,i=()=>u1(e).then(()=>r.complete()),o=()=>i1(e,t).then(s=>s.length===0?(i(),!1):a1(e,s).then(a=>a.forEach(u=>r.next(u))).catch(a=>n=a).then(()=>!0)).then(s=>{s&&(n?r.error(n):o())});o()})(),r.asObservable()}var l1=new WeakMap,f1={name:"migration",rxdb:!0,hooks:{preDestroyRxDatabase:{after:Z_}},prototypes:{RxDatabase:e=>{e.migrationStates=function(){return Ah(this).pipe(Yp(t=>Lp(t)),qs(Ls))}},RxCollection:e=>{e.getDataMigrator=function(){return Je(l1,this,()=>new e1(this.asRxCollection,this.migrationStrategies))},e.migrationNeeded=function(){return this.schema.version===0?Fe:Ph(this.getDataMigrator())}}}};function Aa(e){var t=e.collection.schema.jsonSchema;if(!t.attachments)throw D("AT1",{link:"https://pubkey.github.io/rxdb/rx-attachment.html"})}var h1=function(e){Object.entries(e.doc.collection.attachments).forEach(([t,r])=>{Object.defineProperty(e,t,{get:()=>r.bind(e)})})},d1=function(){function e({doc:r,id:n,type:i,length:o,digest:s}){this.doc=r,this.id=n,this.type=i,this.length=o,this.digest=s,h1(this)}var t=e.prototype;return t.remove=function(){return this.doc.collection.incrementalWriteQueue.addWrite(this.doc._data,n=>(delete n._attachments[this.id],n)).then(()=>{})},t.getData=async function(){var n=await this.doc.collection.storageInstance.getAttachmentData(this.doc.primary,this.id,this.digest),i=await dd(n,this.type);return i},t.getStringData=async function(){var n=await this.getData(),i=await pd(n);return i},e}();function Hi(e,t,r){return new d1({doc:r,id:e,type:t.type,length:t.length,digest:t.digest})}async function p1(e){Aa(this);var t=md(e.data),r=await yd(e.data),n=e.id,i=e.type,o=r;return this.collection.incrementalWriteQueue.addWrite(this._data,s=>(s._attachments=Z(s._attachments),s._attachments[n]={length:t,type:i,data:o},s)).then(s=>{var a=this.collection._docCache.getCachedRxDocument(s),u=s._attachments[n],c=Hi(n,u,a);return c})}function y1(e){Aa(this);var t=this._data;if(!t._attachments||!t._attachments[e])return null;var r=t._attachments[e],n=Hi(e,r,this);return n}function m1(){Aa(this);var e=this._data;return e._attachments?Object.keys(e._attachments).map(t=>Hi(t,e._attachments[t],this)):[]}async function v1(e){var t=e.docData._attachments;if(t){var r={};await Promise.all(Object.keys(t).map(async n=>{var i=t[n],o=e.docData[e.oldCollection.schema.primaryPath],s=await e.oldCollection.storageInstance.getAttachmentData(o,n,i.digest);r[n]={length:i.length,type:i.type,data:s}})),e.docData._attachments=r}}function g1(e){return ke}var b1={name:"attachments",rxdb:!0,prototypes:{RxDocument:e=>{e.putAttachment=p1,e.getAttachment=y1,e.allAttachments=m1,Object.defineProperty(e,"allAttachments$",{get:function(){return this.$.pipe(Te(r=>Object.entries(r.toJSON(!0)._attachments)),Te(r=>r.map(([n,i])=>Hi(n,i,this))))}})}},overwritable:{},hooks:{preMigrateDocument:{after:v1},postMigrateDocument:{after:g1}}};Lr(b1);Lr(X_);Lr(Pw);Lr(R0);Lr(O0);Lr(f1);let w1,_1,x1;w1=new ji("ripple");Ih=await tg({name:"ripple",storage:W_(),multiInstance:!0,eventReduce:!0});hx=Jo(w1);_1={title:"Torrent schema",description:"Describes a torrent",version:0,primaryKey:"infoHash",type:"object",properties:{infoHash:{type:"string",maxLength:255},options:{type:"object",properties:{paused:{type:"boolean"}}},state:{type:"object",properties:{magnet:{type:"string",maxLength:2**15},torrentFile:{type:"object"},name:{type:"string",maxLength:2**11},status:{type:"string",enum:["paused","checkingFiles","downloadingMetadata","downloading","finished","seeding","error"]},progress:{type:"number"},size:{type:"number"},peers:{type:"array",items:{type:"object",properties:{ip:{type:"string",maxLength:255},port:{type:"number"}}}},pieces:{type:"array",items:{type:"number"}},addedAt:{type:"number"},remainingTime:{type:"number"},peersCount:{type:"number"},seedersCount:{type:"number"},leechersCount:{type:"number"},downloaded:{type:"number"},uploaded:{type:"number"},downloadSpeed:{type:"number"},uploadSpeed:{type:"number"},ratio:{type:"number"},path:{type:"string",maxLength:255},files:{type:"array",items:{type:"object",properties:{status:{type:"string",enum:["paused","checking","downloading","finished","seeding","error"]},index:{type:"number"},name:{type:"string",maxLength:255},path:{type:"string",maxLength:255},pathArray:{type:"array",items:{type:"string",maxLength:255}},offset:{type:"number"},length:{type:"number"},downloaded:{type:"number"},progress:{type:"number"},selected:{type:"boolean"},priority:{type:"number"},downloadedRanges:{type:"array",items:{type:"object",properties:{start:{type:"number"},end:{type:"number"}}}},downloadSpeed:{type:"number"},streamBandwithLogs:{type:"array",items:{type:"object",properties:{timestamp:{type:"number"},byteLength:{type:"number"}}}}}}},streamBandwithLogs:{type:"array",items:{type:"object",properties:{timestamp:{type:"number"},byteLength:{type:"number"}}}}}}},required:["infoHash"]};x1={title:"Settings schema",description:"Describes the settings of the app",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:255},paused:{type:"boolean"},throttle:{type:"number"},maxConnections:{type:"number"},downloadSpeedLimit:{type:"number"},downloadSpeedLimitEnabled:{type:"boolean"},saveFolderEnabled:{type:"boolean"}}};let Wi;ot={};Wi={};Wi.byteLength=O1;Wi.toByteArray=C1;Wi.fromByteArray=I1;var Ge=[],Re=[],E1=typeof Uint8Array<"u"?Uint8Array:Array,Po="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var ur=0,S1=Po.length;ur<S1;++ur)Ge[ur]=Po[ur],Re[Po.charCodeAt(ur)]=ur;Re["-".charCodeAt(0)]=62;Re["_".charCodeAt(0)]=63;function Rh(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function O1(e){var t=Rh(e),r=t[0],n=t[1];return(r+n)*3/4-n}function A1(e,t,r){return(t+r)*3/4-r}function C1(e){var t,r=Rh(e),n=r[0],i=r[1],o=new E1(A1(e,n,i)),s=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)t=Re[e.charCodeAt(u)]<<18|Re[e.charCodeAt(u+1)]<<12|Re[e.charCodeAt(u+2)]<<6|Re[e.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=Re[e.charCodeAt(u)]<<2|Re[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=Re[e.charCodeAt(u)]<<10|Re[e.charCodeAt(u+1)]<<4|Re[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function D1(e){return Ge[e>>18&63]+Ge[e>>12&63]+Ge[e>>6&63]+Ge[e&63]}function P1(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(D1(n));return i.join("")}function I1(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(P1(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Ge[t>>2]+Ge[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Ge[t>>10]+Ge[t>>4&63]+Ge[t<<2&63]+"=")),i.join("")}var Ca={};Ca.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<<a)-1,c=u>>1,l=-7,h=r?i-1:0,p=r?-1:1,y=e[t+h];for(h+=p,o=y&(1<<-l)-1,y>>=-l,l+=a;l>0;o=o*256+e[t+h],h+=p,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=s*256+e[t+h],h+=p,l-=8);if(o===0)o=1-c;else{if(o===u)return s?NaN:(y?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-c}return(y?-1:1)*s*Math.pow(2,o-n)};Ca.write=function(e,t,r,n,i,o){var s,a,u,c=o*8-i-1,l=(1<<c)-1,h=l>>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=n?0:o-1,b=n?1:-1,g=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+h>=1?t+=p/u:t+=p*Math.pow(2,1-h),t*u>=2&&(s++,u/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*u-1)*Math.pow(2,i),s=s+h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+y]=a&255,y+=b,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[r+y]=s&255,y+=b,s/=256,c-=8);e[r+y-b]|=g*128};(function(e){var t=Wi,r=Ca,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=_,e.INSPECT_MAX_BYTES=50;var i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{var m=new Uint8Array(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,Uint8Array.prototype),Object.setPrototypeOf(m,f),m.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(m){if(m>i)throw new RangeError('The value "'+m+'" is invalid for option "size"');var f=new Uint8Array(m);return Object.setPrototypeOf(f,a.prototype),f}function a(m,f,d){if(typeof m=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return h(m)}return u(m,f,d)}a.poolSize=8192;function u(m,f,d){if(typeof m=="string")return p(m,f);if(ArrayBuffer.isView(m))return b(m);if(m==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m);if(He(m,ArrayBuffer)||m&&He(m.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(He(m,SharedArrayBuffer)||m&&He(m.buffer,SharedArrayBuffer)))return g(m,f,d);if(typeof m=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var v=m.valueOf&&m.valueOf();if(v!=null&&v!==m)return a.from(v,f,d);var x=E(m);if(x)return x;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof m[Symbol.toPrimitive]=="function")return a.from(m[Symbol.toPrimitive]("string"),f,d);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m)}a.from=function(m,f,d){return u(m,f,d)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function c(m){if(typeof m!="number")throw new TypeError('"size" argument must be of type number');if(m<0)throw new RangeError('The value "'+m+'" is invalid for option "size"')}function l(m,f,d){return c(m),m<=0?s(m):f!==void 0?typeof d=="string"?s(m).fill(f,d):s(m).fill(f):s(m)}a.alloc=function(m,f,d){return l(m,f,d)};function h(m){return c(m),s(m<0?0:w(m)|0)}a.allocUnsafe=function(m){return h(m)},a.allocUnsafeSlow=function(m){return h(m)};function p(m,f){if((typeof f!="string"||f==="")&&(f="utf8"),!a.isEncoding(f))throw new TypeError("Unknown encoding: "+f);var d=A(m,f)|0,v=s(d),x=v.write(m,f);return x!==d&&(v=v.slice(0,x)),v}function y(m){for(var f=m.length<0?0:w(m.length)|0,d=s(f),v=0;v<f;v+=1)d[v]=m[v]&255;return d}function b(m){if(He(m,Uint8Array)){var f=new Uint8Array(m);return g(f.buffer,f.byteOffset,f.byteLength)}return y(m)}function g(m,f,d){if(f<0||m.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(m.byteLength<f+(d||0))throw new RangeError('"length" is outside of buffer bounds');var v;return f===void 0&&d===void 0?v=new Uint8Array(m):d===void 0?v=new Uint8Array(m,f):v=new Uint8Array(m,f,d),Object.setPrototypeOf(v,a.prototype),v}function E(m){if(a.isBuffer(m)){var f=w(m.length)|0,d=s(f);return d.length===0||m.copy(d,0,0,f),d}if(m.length!==void 0)return typeof m.length!="number"||Gi(m.length)?s(0):y(m);if(m.type==="Buffer"&&Array.isArray(m.data))return y(m.data)}function w(m){if(m>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return m|0}function _(m){return+m!=m&&(m=0),a.alloc(+m)}a.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==a.prototype},a.compare=function(f,d){if(He(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),He(d,Uint8Array)&&(d=a.from(d,d.offset,d.byteLength)),!a.isBuffer(f)||!a.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===d)return 0;for(var v=f.length,x=d.length,P=0,I=Math.min(v,x);P<I;++P)if(f[P]!==d[P]){v=f[P],x=d[P];break}return v<x?-1:x<v?1:0},a.isEncoding=function(f){switch(String(f).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(f,d){if(!Array.isArray(f))throw new TypeError('"list" argument must be an Array of Buffers');if(f.length===0)return a.alloc(0);var v;if(d===void 0)for(d=0,v=0;v<f.length;++v)d+=f[v].length;var x=a.allocUnsafe(d),P=0;for(v=0;v<f.length;++v){var I=f[v];if(He(I,Uint8Array))P+I.length>x.length?a.from(I).copy(x,P):Uint8Array.prototype.set.call(x,I,P);else if(a.isBuffer(I))I.copy(x,P);else throw new TypeError('"list" argument must be an Array of Buffers');P+=I.length}return x};function A(m,f){if(a.isBuffer(m))return m.length;if(ArrayBuffer.isView(m)||He(m,ArrayBuffer))return m.byteLength;if(typeof m!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof m);var d=m.length,v=arguments.length>2&&arguments[2]===!0;if(!v&&d===0)return 0;for(var x=!1;;)switch(f){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return zi(m).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return Ra(m).length;default:if(x)return v?-1:zi(m).length;f=(""+f).toLowerCase(),x=!0}}a.byteLength=A;function R(m,f,d){var v=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((d===void 0||d>this.length)&&(d=this.length),d<=0)||(d>>>=0,f>>>=0,d<=f))return"";for(m||(m="utf8");;)switch(m){case"hex":return ye(this,f,d);case"utf8":case"utf-8":return K(this,f,d);case"ascii":return z(this,f,d);case"latin1":case"binary":return he(this,f,d);case"base64":return Y(this,f,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qe(this,f,d);default:if(v)throw new TypeError("Unknown encoding: "+m);m=(m+"").toLowerCase(),v=!0}}a.prototype._isBuffer=!0;function O(m,f,d){var v=m[f];m[f]=m[d],m[d]=v}a.prototype.swap16=function(){var f=this.length;if(f%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var d=0;d<f;d+=2)O(this,d,d+1);return this},a.prototype.swap32=function(){var f=this.length;if(f%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var d=0;d<f;d+=4)O(this,d,d+3),O(this,d+1,d+2);return this},a.prototype.swap64=function(){var f=this.length;if(f%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var d=0;d<f;d+=8)O(this,d,d+7),O(this,d+1,d+6),O(this,d+2,d+5),O(this,d+3,d+4);return this},a.prototype.toString=function(){var f=this.length;return f===0?"":arguments.length===0?K(this,0,f):R.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(f){if(!a.isBuffer(f))throw new TypeError("Argument must be a Buffer");return this===f?!0:a.compare(this,f)===0},a.prototype.inspect=function(){var f="",d=e.INSPECT_MAX_BYTES;return f=this.toString("hex",0,d).replace(/(.{2})/g,"$1 ").trim(),this.length>d&&(f+=" ... "),"<Buffer "+f+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(f,d,v,x,P){if(He(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),!a.isBuffer(f))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof f);if(d===void 0&&(d=0),v===void 0&&(v=f?f.length:0),x===void 0&&(x=0),P===void 0&&(P=this.length),d<0||v>f.length||x<0||P>this.length)throw new RangeError("out of range index");if(x>=P&&d>=v)return 0;if(x>=P)return-1;if(d>=v)return 1;if(d>>>=0,v>>>=0,x>>>=0,P>>>=0,this===f)return 0;for(var I=P-x,q=v-d,G=Math.min(I,q),ee=this.slice(x,P),ge=f.slice(d,v),oe=0;oe<G;++oe)if(ee[oe]!==ge[oe]){I=ee[oe],q=ge[oe];break}return I<q?-1:q<I?1:0};function C(m,f,d,v,x){if(m.length===0)return-1;if(typeof d=="string"?(v=d,d=0):d>2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,Gi(d)&&(d=x?0:m.length-1),d<0&&(d=m.length+d),d>=m.length){if(x)return-1;d=m.length-1}else if(d<0)if(x)d=0;else return-1;if(typeof f=="string"&&(f=a.from(f,v)),a.isBuffer(f))return f.length===0?-1:S(m,f,d,v,x);if(typeof f=="number")return f=f&255,typeof Uint8Array.prototype.indexOf=="function"?x?Uint8Array.prototype.indexOf.call(m,f,d):Uint8Array.prototype.lastIndexOf.call(m,f,d):S(m,[f],d,v,x);throw new TypeError("val must be string, number or Buffer")}function S(m,f,d,v,x){var P=1,I=m.length,q=f.length;if(v!==void 0&&(v=String(v).toLowerCase(),v==="ucs2"||v==="ucs-2"||v==="utf16le"||v==="utf-16le")){if(m.length<2||f.length<2)return-1;P=2,I/=2,q/=2,d/=2}function G(ka,Ta){return P===1?ka[Ta]:ka.readUInt16BE(Ta*P)}var ee;if(x){var ge=-1;for(ee=d;ee<I;ee++)if(G(m,ee)===G(f,ge===-1?0:ee-ge)){if(ge===-1&&(ge=ee),ee-ge+1===q)return ge*P}else ge!==-1&&(ee-=ee-ge),ge=-1}else for(d+q>I&&(d=I-q),ee=d;ee>=0;ee--){for(var oe=!0,Tn=0;Tn<q;Tn++)if(G(m,ee+Tn)!==G(f,Tn)){oe=!1;break}if(oe)return ee}return-1}a.prototype.includes=function(f,d,v){return this.indexOf(f,d,v)!==-1},a.prototype.indexOf=function(f,d,v){return C(this,f,d,v,!0)},a.prototype.lastIndexOf=function(f,d,v){return C(this,f,d,v,!1)};function k(m,f,d,v){d=Number(d)||0;var x=m.length-d;v?(v=Number(v),v>x&&(v=x)):v=x;var P=f.length;v>P/2&&(v=P/2);for(var I=0;I<v;++I){var q=parseInt(f.substr(I*2,2),16);if(Gi(q))return I;m[d+I]=q}return I}function T(m,f,d,v){return kn(zi(f,m.length-d),m,d,v)}function F(m,f,d,v){return kn(Uh(f),m,d,v)}function W(m,f,d,v){return kn(Ra(f),m,d,v)}function ne(m,f,d,v){return kn(Kh(f,m.length-d),m,d,v)}a.prototype.write=function(f,d,v,x){if(d===void 0)x="utf8",v=this.length,d=0;else if(v===void 0&&typeof d=="string")x=d,v=this.length,d=0;else if(isFinite(d))d=d>>>0,isFinite(v)?(v=v>>>0,x===void 0&&(x="utf8")):(x=v,v=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var P=this.length-d;if((v===void 0||v>P)&&(v=P),f.length>0&&(v<0||d<0)||d>this.length)throw new RangeError("Attempt to write outside buffer bounds");x||(x="utf8");for(var I=!1;;)switch(x){case"hex":return k(this,f,d,v);case"utf8":case"utf-8":return T(this,f,d,v);case"ascii":case"latin1":case"binary":return F(this,f,d,v);case"base64":return W(this,f,d,v);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,f,d,v);default:if(I)throw new TypeError("Unknown encoding: "+x);x=(""+x).toLowerCase(),I=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Y(m,f,d){return f===0&&d===m.length?t.fromByteArray(m):t.fromByteArray(m.slice(f,d))}function K(m,f,d){d=Math.min(m.length,d);for(var v=[],x=f;x<d;){var P=m[x],I=null,q=P>239?4:P>223?3:P>191?2:1;if(x+q<=d){var G,ee,ge,oe;switch(q){case 1:P<128&&(I=P);break;case 2:G=m[x+1],(G&192)===128&&(oe=(P&31)<<6|G&63,oe>127&&(I=oe));break;case 3:G=m[x+1],ee=m[x+2],(G&192)===128&&(ee&192)===128&&(oe=(P&15)<<12|(G&63)<<6|ee&63,oe>2047&&(oe<55296||oe>57343)&&(I=oe));break;case 4:G=m[x+1],ee=m[x+2],ge=m[x+3],(G&192)===128&&(ee&192)===128&&(ge&192)===128&&(oe=(P&15)<<18|(G&63)<<12|(ee&63)<<6|ge&63,oe>65535&&oe<1114112&&(I=oe))}}I===null?(I=65533,q=1):I>65535&&(I-=65536,v.push(I>>>10&1023|55296),I=56320|I&1023),v.push(I),x+=q}return ae(v)}var ve=4096;function ae(m){var f=m.length;if(f<=ve)return String.fromCharCode.apply(String,m);for(var d="",v=0;v<f;)d+=String.fromCharCode.apply(String,m.slice(v,v+=ve));return d}function z(m,f,d){var v="";d=Math.min(m.length,d);for(var x=f;x<d;++x)v+=String.fromCharCode(m[x]&127);return v}function he(m,f,d){var v="";d=Math.min(m.length,d);for(var x=f;x<d;++x)v+=String.fromCharCode(m[x]);return v}function ye(m,f,d){var v=m.length;(!f||f<0)&&(f=0),(!d||d<0||d>v)&&(d=v);for(var x="",P=f;P<d;++P)x+=qh[m[P]];return x}function qe(m,f,d){for(var v=m.slice(f,d),x="",P=0;P<v.length-1;P+=2)x+=String.fromCharCode(v[P]+v[P+1]*256);return x}a.prototype.slice=function(f,d){var v=this.length;f=~~f,d=d===void 0?v:~~d,f<0?(f+=v,f<0&&(f=0)):f>v&&(f=v),d<0?(d+=v,d<0&&(d=0)):d>v&&(d=v),d<f&&(d=f);var x=this.subarray(f,d);return Object.setPrototypeOf(x,a.prototype),x};function H(m,f,d){if(m%1!==0||m<0)throw new RangeError("offset is not uint");if(m+f>d)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(f,d,v){f=f>>>0,d=d>>>0,v||H(f,d,this.length);for(var x=this[f],P=1,I=0;++I<d&&(P*=256);)x+=this[f+I]*P;return x},a.prototype.readUintBE=a.prototype.readUIntBE=function(f,d,v){f=f>>>0,d=d>>>0,v||H(f,d,this.length);for(var x=this[f+--d],P=1;d>0&&(P*=256);)x+=this[f+--d]*P;return x},a.prototype.readUint8=a.prototype.readUInt8=function(f,d){return f=f>>>0,d||H(f,1,this.length),this[f]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(f,d){return f=f>>>0,d||H(f,2,this.length),this[f]|this[f+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(f,d){return f=f>>>0,d||H(f,2,this.length),this[f]<<8|this[f+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(f,d){return f=f>>>0,d||H(f,4,this.length),(this[f]|this[f+1]<<8|this[f+2]<<16)+this[f+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(f,d){return f=f>>>0,d||H(f,4,this.length),this[f]*16777216+(this[f+1]<<16|this[f+2]<<8|this[f+3])},a.prototype.readIntLE=function(f,d,v){f=f>>>0,d=d>>>0,v||H(f,d,this.length);for(var x=this[f],P=1,I=0;++I<d&&(P*=256);)x+=this[f+I]*P;return P*=128,x>=P&&(x-=Math.pow(2,8*d)),x},a.prototype.readIntBE=function(f,d,v){f=f>>>0,d=d>>>0,v||H(f,d,this.length);for(var x=d,P=1,I=this[f+--x];x>0&&(P*=256);)I+=this[f+--x]*P;return P*=128,I>=P&&(I-=Math.pow(2,8*d)),I},a.prototype.readInt8=function(f,d){return f=f>>>0,d||H(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},a.prototype.readInt16LE=function(f,d){f=f>>>0,d||H(f,2,this.length);var v=this[f]|this[f+1]<<8;return v&32768?v|4294901760:v},a.prototype.readInt16BE=function(f,d){f=f>>>0,d||H(f,2,this.length);var v=this[f+1]|this[f]<<8;return v&32768?v|4294901760:v},a.prototype.readInt32LE=function(f,d){return f=f>>>0,d||H(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},a.prototype.readInt32BE=function(f,d){return f=f>>>0,d||H(f,4,this.length),this[f]<<24|this[f+1]<<16|this[f+2]<<8|this[f+3]},a.prototype.readFloatLE=function(f,d){return f=f>>>0,d||H(f,4,this.length),r.read(this,f,!0,23,4)},a.prototype.readFloatBE=function(f,d){return f=f>>>0,d||H(f,4,this.length),r.read(this,f,!1,23,4)},a.prototype.readDoubleLE=function(f,d){return f=f>>>0,d||H(f,8,this.length),r.read(this,f,!0,52,8)},a.prototype.readDoubleBE=function(f,d){return f=f>>>0,d||H(f,8,this.length),r.read(this,f,!1,52,8)};function J(m,f,d,v,x,P){if(!a.isBuffer(m))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>x||f<P)throw new RangeError('"value" argument is out of bounds');if(d+v>m.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(f,d,v,x){if(f=+f,d=d>>>0,v=v>>>0,!x){var P=Math.pow(2,8*v)-1;J(this,f,d,v,P,0)}var I=1,q=0;for(this[d]=f&255;++q<v&&(I*=256);)this[d+q]=f/I&255;return d+v},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(f,d,v,x){if(f=+f,d=d>>>0,v=v>>>0,!x){var P=Math.pow(2,8*v)-1;J(this,f,d,v,P,0)}var I=v-1,q=1;for(this[d+I]=f&255;--I>=0&&(q*=256);)this[d+I]=f/q&255;return d+v},a.prototype.writeUint8=a.prototype.writeUInt8=function(f,d,v){return f=+f,d=d>>>0,v||J(this,f,d,1,255,0),this[d]=f&255,d+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(f,d,v){return f=+f,d=d>>>0,v||J(this,f,d,2,65535,0),this[d]=f&255,this[d+1]=f>>>8,d+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(f,d,v){return f=+f,d=d>>>0,v||J(this,f,d,2,65535,0),this[d]=f>>>8,this[d+1]=f&255,d+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(f,d,v){return f=+f,d=d>>>0,v||J(this,f,d,4,4294967295,0),this[d+3]=f>>>24,this[d+2]=f>>>16,this[d+1]=f>>>8,this[d]=f&255,d+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(f,d,v){return f=+f,d=d>>>0,v||J(this,f,d,4,4294967295,0),this[d]=f>>>24,this[d+1]=f>>>16,this[d+2]=f>>>8,this[d+3]=f&255,d+4},a.prototype.writeIntLE=function(f,d,v,x){if(f=+f,d=d>>>0,!x){var P=Math.pow(2,8*v-1);J(this,f,d,v,P-1,-P)}var I=0,q=1,G=0;for(this[d]=f&255;++I<v&&(q*=256);)f<0&&G===0&&this[d+I-1]!==0&&(G=1),this[d+I]=(f/q>>0)-G&255;return d+v},a.prototype.writeIntBE=function(f,d,v,x){if(f=+f,d=d>>>0,!x){var P=Math.pow(2,8*v-1);J(this,f,d,v,P-1,-P)}var I=v-1,q=1,G=0;for(this[d+I]=f&255;--I>=0&&(q*=256);)f<0&&G===0&&this[d+I+1]!==0&&(G=1),this[d+I]=(f/q>>0)-G&255;return d+v},a.prototype.writeInt8=function(f,d,v){return f=+f,d=d>>>0,v||J(this,f,d,1,127,-128),f<0&&(f=255+f+1),this[d]=f&255,d+1},a.prototype.writeInt16LE=function(f,d,v){return f=+f,d=d>>>0,v||J(this,f,d,2,32767,-32768),this[d]=f&255,this[d+1]=f>>>8,d+2},a.prototype.writeInt16BE=function(f,d,v){return f=+f,d=d>>>0,v||J(this,f,d,2,32767,-32768),this[d]=f>>>8,this[d+1]=f&255,d+2},a.prototype.writeInt32LE=function(f,d,v){return f=+f,d=d>>>0,v||J(this,f,d,4,2147483647,-2147483648),this[d]=f&255,this[d+1]=f>>>8,this[d+2]=f>>>16,this[d+3]=f>>>24,d+4},a.prototype.writeInt32BE=function(f,d,v){return f=+f,d=d>>>0,v||J(this,f,d,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[d]=f>>>24,this[d+1]=f>>>16,this[d+2]=f>>>8,this[d+3]=f&255,d+4};function Tt(m,f,d,v,x,P){if(d+v>m.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function Rn(m,f,d,v,x){return f=+f,d=d>>>0,x||Tt(m,f,d,4),r.write(m,f,d,v,23,4),d+4}a.prototype.writeFloatLE=function(f,d,v){return Rn(this,f,d,!0,v)},a.prototype.writeFloatBE=function(f,d,v){return Rn(this,f,d,!1,v)};function Ia(m,f,d,v,x){return f=+f,d=d>>>0,x||Tt(m,f,d,8),r.write(m,f,d,v,52,8),d+8}a.prototype.writeDoubleLE=function(f,d,v){return Ia(this,f,d,!0,v)},a.prototype.writeDoubleBE=function(f,d,v){return Ia(this,f,d,!1,v)},a.prototype.copy=function(f,d,v,x){if(!a.isBuffer(f))throw new TypeError("argument should be a Buffer");if(v||(v=0),!x&&x!==0&&(x=this.length),d>=f.length&&(d=f.length),d||(d=0),x>0&&x<v&&(x=v),x===v||f.length===0||this.length===0)return 0;if(d<0)throw new RangeError("targetStart out of bounds");if(v<0||v>=this.length)throw new RangeError("Index out of range");if(x<0)throw new RangeError("sourceEnd out of bounds");x>this.length&&(x=this.length),f.length-d<x-v&&(x=f.length-d+v);var P=x-v;return this===f&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(d,v,x):Uint8Array.prototype.set.call(f,this.subarray(v,x),d),P},a.prototype.fill=function(f,d,v,x){if(typeof f=="string"){if(typeof d=="string"?(x=d,d=0,v=this.length):typeof v=="string"&&(x=v,v=this.length),x!==void 0&&typeof x!="string")throw new TypeError("encoding must be a string");if(typeof x=="string"&&!a.isEncoding(x))throw new TypeError("Unknown encoding: "+x);if(f.length===1){var P=f.charCodeAt(0);(x==="utf8"&&P<128||x==="latin1")&&(f=P)}}else typeof f=="number"?f=f&255:typeof f=="boolean"&&(f=Number(f));if(d<0||this.length<d||this.length<v)throw new RangeError("Out of range index");if(v<=d)return this;d=d>>>0,v=v===void 0?this.length:v>>>0,f||(f=0);var I;if(typeof f=="number")for(I=d;I<v;++I)this[I]=f;else{var q=a.isBuffer(f)?f:a.from(f,x),G=q.length;if(G===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for(I=0;I<v-d;++I)this[I+d]=q[I%G]}return this};var Nh=/[^+/0-9A-Za-z-_]/g;function jh(m){if(m=m.split("=")[0],m=m.trim().replace(Nh,""),m.length<2)return"";for(;m.length%4!==0;)m=m+"=";return m}function zi(m,f){f=f||1/0;for(var d,v=m.length,x=null,P=[],I=0;I<v;++I){if(d=m.charCodeAt(I),d>55295&&d<57344){if(!x){if(d>56319){(f-=3)>-1&&P.push(239,191,189);continue}else if(I+1===v){(f-=3)>-1&&P.push(239,191,189);continue}x=d;continue}if(d<56320){(f-=3)>-1&&P.push(239,191,189),x=d;continue}d=(x-55296<<10|d-56320)+65536}else x&&(f-=3)>-1&&P.push(239,191,189);if(x=null,d<128){if((f-=1)<0)break;P.push(d)}else if(d<2048){if((f-=2)<0)break;P.push(d>>6|192,d&63|128)}else if(d<65536){if((f-=3)<0)break;P.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((f-=4)<0)break;P.push(d>>18|240,d>>12&63|128,d>>6&63|128,d&63|128)}else throw new Error("Invalid code point")}return P}function Uh(m){for(var f=[],d=0;d<m.length;++d)f.push(m.charCodeAt(d)&255);return f}function Kh(m,f){for(var d,v,x,P=[],I=0;I<m.length&&!((f-=2)<0);++I)d=m.charCodeAt(I),v=d>>8,x=d%256,P.push(x),P.push(v);return P}function Ra(m){return t.toByteArray(jh(m))}function kn(m,f,d,v){for(var x=0;x<v&&!(x+d>=f.length||x>=m.length);++x)f[x+d]=m[x];return x}function He(m,f){return m instanceof f||m!=null&&m.constructor!=null&&m.constructor.name!=null&&m.constructor.name===f.name}function Gi(m){return m!==m}var qh=function(){for(var m="0123456789abcdef",f=new Array(256),d=0;d<16;++d)for(var v=d*16,x=0;x<16;++x)f[v+x]=m[d]+m[x];return f}()})(ot);let k1;kh=e=>({...e,created:e.created?.getTime(),info:e.info&&{...e.info,files:e.info.files&&e.info.files.map(t=>({...t,path:t.path.map(r=>ot.Buffer.from(r).toString("utf-8"))})),name:ot.Buffer.from(e.name).toString("utf-8"),pieces:ot.Buffer.from(e.info.pieces).toString("base64")},infoBuffer:e.infoBuffer&&ot.Buffer.from(e.infoBuffer).toString("base64"),infoHashBuffer:ot.Buffer.from(e.infoHashBuffer).toString("base64")});R1=e=>({...e,created:e.created?new Date(e.created):void 0,info:e.info&&{...e.info,files:e.info.files&&e.info.files.map(t=>({...t,path:t.path})),name:e.info.name,pieces:new Uint8Array(ot.Buffer.from(e.info.pieces,"base64"))},infoBuffer:e.infoBuffer&&new Uint8Array(ot.Buffer.from(e.infoBuffer,"base64")),infoHashBuffer:new Uint8Array(ot.Buffer.from(e.infoHashBuffer,"base64"))});k1=e=>({magnet:e.magnet,path:e.path,pieces:e.pieces,name:e.torrentFile?.name||"",status:e.status??"checkingFiles",progress:e.progress??0,size:e.torrentFile?.length||0,peers:[],addedAt:e.addedAt??Date.now(),remainingTime:e.remainingTime??0,peersCount:e.peersCount??0,seedersCount:e.seedersCount??0,leechersCount:e.leechersCount??0,downloaded:e.downloaded??0,uploaded:e.uploaded??0,downloadSpeed:e.downloadSpeed??0,uploadSpeed:e.uploadSpeed??0,ratio:e.ratio??0,files:e.files??e.torrentFile?.files?.map((t,r)=>({index:r,status:"checking",name:t.name,path:t.path,pathArray:e.torrentFile?.info?.files?.[r]?.path??t.path.split("/"),offset:t.offset,length:t.length,downloaded:0,progress:0,selected:!0,priority:1,downloadedRanges:[],downloadSpeed:0,streamBandwithLogs:[]})),streamBandwithLogs:e.streamBandwithLogs??[],torrentFile:e.torrentFile});dx=e=>({infoHash:e.infoHash,options:{paused:e.options?.paused??!1},state:k1(e.state??{})});const gc="0123456789abcdef",Th=[],Ii=[];for(let e=0;e<256;e++)Th[e]=gc[e>>4&15]+gc[e&15],e<16&&(e<10?Ii[48+e]=e:Ii[97-10+e]=e);const dt=e=>{const t=e.length;let r="",n=0;for(;n<t;)r+=Th[e[n++]];return r},Io=e=>{const t=e.length>>1,r=t<<1,n=new Uint8Array(t);let i=0,o=0;for(;o<r;)n[i++]=Ii[e.charCodeAt(o++)]<<4|Ii[e.charCodeAt(o++)];return n},T1=(e,t=0)=>{const r=e.length||0;if(!t){let s=r;for(;s--;)t+=e[s].length}const n=new Uint8Array(t);let i=t,o=r;for(;o--;)i-=e[o].length,n.set(e[o],i);return n};var pr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",$1=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Hn=0;Hn<pr.length;Hn++)$1[pr.charCodeAt(Hn)]=Hn;var B1=function(e){var t=new Uint8Array(e),r,n=t.length,i="";for(r=0;r<n;r+=3)i+=pr[t[r]>>2],i+=pr[(t[r]&3)<<4|t[r+1]>>4],i+=pr[(t[r+1]&15)<<2|t[r+2]>>6],i+=pr[t[r+2]&63];return n%3===2?i=i.substring(0,i.length-1)+"=":n%3===1&&(i=i.substring(0,i.length-2)+"=="),i};const M1=new TextDecoder,rt=(e,t)=>t?new TextDecoder(t).decode(e):M1.decode(e),L1=new TextEncoder,Ue=e=>L1.encode(e),F1=e=>B1(e),bc=typeof window<"u"?window:self,wc=bc.crypto||bc.msCrypto||{},_c=wc.subtle||wc.webkitSubtle,N1={hex:dt,base64:F1},j1=async(e,t,r="sha-1")=>{if(!_c)throw new Error("no web crypto support");typeof e=="string"&&(e=Ue(e));const n=new Uint8Array(await _c.digest(r,e));return t?N1[t](n):n};function Pn(e){const t=e<0?1:0;return e=Math.abs(Number(e||1)),Math.floor(Math.log10(e))+1+t}function $h(e){return ArrayBuffer.isView(e)?"arraybufferview":Array.isArray(e)?"array":e instanceof Number?"number":e instanceof Boolean?"boolean":e instanceof Set?"set":e instanceof Map?"map":e instanceof String?"string":e instanceof ArrayBuffer?"arraybuffer":typeof e}function Q(e,t,r){const n=[];let i=null;return Q._encode(n,e),i=T1(n),Q.bytes=i.length,ArrayBuffer.isView(t)?(t.set(i,r),t):i}Q.bytes=-1;Q._floatConversionDetected=!1;Q._encode=function(e,t){if(t!=null)switch($h(t)){case"object":Q.dict(e,t);break;case"map":Q.dictMap(e,t);break;case"array":Q.list(e,t);break;case"set":Q.listSet(e,t);break;case"string":Q.string(e,t);break;case"number":Q.number(e,t);break;case"boolean":Q.number(e,t);break;case"arraybufferview":Q.buffer(e,new Uint8Array(t.buffer,t.byteOffset,t.byteLength));break;case"arraybuffer":Q.buffer(e,new Uint8Array(t));break}};const Qi=new Uint8Array([101]),Bh=new Uint8Array([100]),Mh=new Uint8Array([108]);Q.buffer=function(e,t){e.push(Ue(t.length+":"),t)};Q.string=function(e,t){e.push(Ue(Ue(t).byteLength+":"+t))};Q.number=function(e,t){if(Number.isInteger(t))return e.push(Ue("i"+BigInt(t)+"e"));const r=2147483648,n=t/r<<0,i=t%r<<0,o=n*r+i;e.push(Ue("i"+o+"e")),o!==t&&!Q._floatConversionDetected&&(Q._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+t+'":','Bencoding only defines support for integers, value was converted to "'+o+'"'),console.trace())};Q.dict=function(e,t){e.push(Bh);let r=0,n;const i=Object.keys(t).sort(),o=i.length;for(;r<o;r++)n=i[r],t[n]!=null&&(Q.string(e,n),Q._encode(e,t[n]));e.push(Qi)};Q.dictMap=function(e,t){e.push(Bh);const r=Array.from(t.keys()).sort();for(const n of r)t.get(n)!=null&&(ArrayBuffer.isView(n)?Q._encode(e,n):Q.string(e,String(n)),Q._encode(e,t.get(n)));e.push(Qi)};Q.list=function(e,t){let r=0;const n=t.length;for(e.push(Mh);r<n;r++)t[r]!=null&&Q._encode(e,t[r]);e.push(Qi)};Q.listSet=function(e,t){e.push(Mh);for(const r of t)r!=null&&Q._encode(e,r);e.push(Qi)};const U1=105,K1=58,q1=100,H1=108,Da=101;function Lh(e,t,r){let n=0,i=1;for(let o=t;o<r;o++){const s=e[o];if(s<58&&s>=48){n=n*10+(s-48);continue}if(!(o===t&&s===43)){if(o===t&&s===45){i=-1;continue}if(s===46)break;throw new Error("not a number: buffer["+o+"] = "+s)}}return n*i}function L(e,t,r,n){return e==null||e.length===0?null:(typeof t!="number"&&n==null&&(n=t,t=void 0),typeof r!="number"&&n==null&&(n=r,r=void 0),L.position=0,L.encoding=n||null,L.data=ArrayBuffer.isView(e)?new Uint8Array(e.slice(t,r)):Ue(e),L.bytes=L.data.length,L.next())}L.bytes=0;L.position=0;L.data=null;L.encoding=null;L.next=function(){switch(L.data[L.position]){case q1:return L.dictionary();case H1:return L.list();case U1:return L.integer();default:return L.buffer()}};L.find=function(e){let t=L.position;const r=L.data.length,n=L.data;for(;t<r;){if(n[t]===e)return t;t++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(e)+'" [0x'+e.toString(16)+"]")};L.dictionary=function(){L.position++;const e={};for(;L.data[L.position]!==Da;){const t=L.buffer();let r=rt(t);r.includes("�")&&(r=dt(t)),e[r]=L.next()}return L.position++,e};L.list=function(){L.position++;const e=[];for(;L.data[L.position]!==Da;)e.push(L.next());return L.position++,e};L.integer=function(){const e=L.find(Da),t=Lh(L.data,L.position+1,e);return L.position+=e+1-L.position,t};L.buffer=function(){let e=L.find(K1);const t=Lh(L.data,L.position,e),r=++e+t;return L.position=r,L.encoding?rt(L.data.slice(e,r)):L.data.slice(e,r)};function W1(e){let t=2;for(const r of e)t+=In(r);return t}function Q1(e){let t=2;for(const[r,n]of e){const i=Ue(r).byteLength;t+=Pn(i)+1+i,t+=In(n)}return t}function z1(e){let t=2;const r=Object.keys(e);for(let n=0;n<r.length;n++){const i=Ue(r[n]).byteLength;t+=Pn(i)+1+i,t+=In(e[r[n]])}return t}function G1(e){const t=Ue(e).byteLength;return Pn(t)+1+t}function V1(e){const t=e.byteLength-e.byteOffset;return Pn(t)+1+t}function In(e){if(e==null)return 0;const r=$h(e);switch(r){case"arraybufferview":return V1(e);case"string":return G1(e);case"array":case"set":return W1(e);case"number":return 1+Pn(Math.floor(e))+1;case"bigint":return 1+e.toString().length+1;case"object":return z1(e);case"map":return Q1(e);default:throw new TypeError(`Unsupported value of type "${r}"`)}}const J1=In,xc={encode:Q,decode:L,byteLength:In,encodingLength:J1},Ec=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255],Y1=function(e){if(!ArrayBuffer.isView(e)&&typeof e!="string")throw new TypeError("base32.decode only takes Buffer or string as parameter");let t=0,r=0,n,i=0;ArrayBuffer.isView(e)||(e=Ue(e));const o=new Uint8Array(Math.ceil(e.length*5/8));for(let s=0;s<e.length&&e[s]!==61;s++){const a=e[s]-48;if(a<Ec.length)r=Ec[a],t<=3?(t=(t+5)%8,t===0?(n|=r,o[i]=n,i++,n=0):n|=255&r<<8-t):(t=(t+5)%8,n|=255&r>>>t,o[i]=n,i++,n=255&r<<8-t);else throw new Error("Invalid input - it is not base32 encoded string")}return o.subarray(0,i)};function X1(e){return e.reduce((t,r,n,i)=>((n===0||r!==i[n-1]+1)&&t.push([]),t[t.length-1].push(r),t),[]).map(t=>t.length>1?`${t[0]}-${t[t.length-1]}`:`${t[0]}`)}function Z1(e){const t=(r,n=r)=>Array.from({length:n-r+1},(i,o)=>o+r);return e.reduce((r,n,i,o)=>{const s=n.split("-").map(a=>parseInt(a));return r.concat(t(...s))},[])}function Ro(e){const t={},r=e.split("magnet:?")[1];(r&&r.length>=0?r.split("&"):[]).forEach(o=>{const s=o.split("=");if(s.length!==2)return;const a=s[0];let u=s[1];a==="dn"&&(u=decodeURIComponent(u).replace(/\+/g," ")),(a==="tr"||a==="xs"||a==="as"||a==="ws")&&(u=decodeURIComponent(u)),a==="kt"&&(u=decodeURIComponent(u).split("+")),a==="ix"&&(u=Number(u)),a==="so"&&(u=Z1(decodeURIComponent(u).split(","))),t[a]?(Array.isArray(t[a])||(t[a]=[t[a]]),t[a].push(u)):t[a]=u});let i;return t.xt&&(Array.isArray(t.xt)?t.xt:[t.xt]).forEach(s=>{(i=s.match(/^urn:btih:(.{40})/))?t.infoHash=i[1].toLowerCase():(i=s.match(/^urn:btih:(.{32})/))?t.infoHash=dt(Y1(i[1])):(i=s.match(/^urn:btmh:1220(.{64})/))&&(t.infoHashV2=i[1].toLowerCase())}),t.xs&&(Array.isArray(t.xs)?t.xs:[t.xs]).forEach(s=>{(i=s.match(/^urn:btpk:(.{64})/))&&(t.publicKey=i[1].toLowerCase())}),t.infoHash&&(t.infoHashBuffer=Io(t.infoHash)),t.infoHashV2&&(t.infoHashV2Buffer=Io(t.infoHashV2)),t.publicKey&&(t.publicKeyBuffer=Io(t.publicKey)),t.dn&&(t.name=t.dn),t.kt&&(t.keywords=t.kt),t.announce=[],(typeof t.tr=="string"||Array.isArray(t.tr))&&(t.announce=t.announce.concat(t.tr)),t.urlList=[],(typeof t.as=="string"||Array.isArray(t.as))&&(t.urlList=t.urlList.concat(t.as)),(typeof t.ws=="string"||Array.isArray(t.ws))&&(t.urlList=t.urlList.concat(t.ws)),t.peerAddresses=[],(typeof t["x.pe"]=="string"||Array.isArray(t["x.pe"]))&&(t.peerAddresses=t.peerAddresses.concat(t["x.pe"])),t.announce=Array.from(new Set(t.announce)),t.urlList=Array.from(new Set(t.urlList)),t.peerAddresses=Array.from(new Set(t.peerAddresses)),t}function ex(e){e=Object.assign({},e);let t=new Set;e.xt&&typeof e.xt=="string"&&t.add(e.xt),e.xt&&Array.isArray(e.xt)&&(t=new Set(e.xt)),e.infoHashBuffer&&t.add(`urn:btih:${dt(e.infoHashBuffer)}`),e.infoHash&&t.add(`urn:btih:${e.infoHash}`),e.infoHashV2Buffer&&t.add(e.xt=`urn:btmh:1220${dt(e.infoHashV2Buffer)}`),e.infoHashV2&&t.add(`urn:btmh:1220${e.infoHashV2}`);const r=Array.from(t);r.length===1&&(e.xt=r[0]),r.length>1&&(e.xt=r),e.publicKeyBuffer&&(e.xs=`urn:btpk:${dt(e.publicKeyBuffer)}`),e.publicKey&&(e.xs=`urn:btpk:${e.publicKey}`),e.name&&(e.dn=e.name),e.keywords&&(e.kt=e.keywords),e.announce&&(e.tr=e.announce),e.urlList&&(e.ws=e.urlList,delete e.as),e.peerAddresses&&(e["x.pe"]=e.peerAddresses);let n="magnet:?";return Object.keys(e).filter(i=>i.length===2||i==="x.pe").forEach((i,o)=>{const s=Array.isArray(e[i])?e[i]:[e[i]];s.forEach((a,u)=>{(o>0||u>0)&&(i!=="kt"&&i!=="so"||u===0)&&(n+="&"),i==="dn"&&(a=encodeURIComponent(a).replace(/%20/g,"+")),(i==="tr"||i==="as"||i==="ws")&&(a=encodeURIComponent(a)),i==="xs"&&!a.startsWith("urn:btpk:")&&(a=encodeURIComponent(a)),i==="kt"&&(a=encodeURIComponent(a)),i!=="so"&&(i==="kt"&&u>0?n+=`+${a}`:n+=`${i}=${a}`)}),i==="so"&&(n+=`${i}=${X1(s)}`)}),n}function We(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function Sc(e,t){for(var r="",n=0,i=-1,o=0,s,a=0;a<=e.length;++a){if(a<e.length)s=e.charCodeAt(a);else{if(s===47)break;s=47}if(s===47){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(r.length<2||n!==2||r.charCodeAt(r.length-1)!==46||r.charCodeAt(r.length-2)!==46){if(r.length>2){var u=r.lastIndexOf("/");if(u!==r.length-1){u===-1?(r="",n=0):(r=r.slice(0,u),n=r.length-1-r.lastIndexOf("/")),i=a,o=0;continue}}else if(r.length===2||r.length===1){r="",n=0,i=a,o=0;continue}}t&&(r.length>0?r+="/..":r="..",n=2)}else r.length>0?r+="/"+e.slice(i+1,a):r=e.slice(i+1,a),n=a-i-1;i=a,o=0}else s===46&&o!==-1?++o:o=-1}return r}function tx(e,t){var r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+n:r+e+n:n}var Sr={resolve:function(){for(var t="",r=!1,n,i=arguments.length-1;i>=-1&&!r;i--){var o;i>=0?o=arguments[i]:(n===void 0&&(n=process.cwd()),o=n),We(o),o.length!==0&&(t=o+"/"+t,r=o.charCodeAt(0)===47)}return t=Sc(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(We(t),t.length===0)return".";var r=t.charCodeAt(0)===47,n=t.charCodeAt(t.length-1)===47;return t=Sc(t,!r),t.length===0&&!r&&(t="."),t.length>0&&n&&(t+="/"),r?"/"+t:t},isAbsolute:function(t){return We(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,r=0;r<arguments.length;++r){var n=arguments[r];We(n),n.length>0&&(t===void 0?t=n:t+="/"+n)}return t===void 0?".":Sr.normalize(t)},relative:function(t,r){if(We(t),We(r),t===r||(t=Sr.resolve(t),r=Sr.resolve(r),t===r))return"";for(var n=1;n<t.length&&t.charCodeAt(n)===47;++n);for(var i=t.length,o=i-n,s=1;s<r.length&&r.charCodeAt(s)===47;++s);for(var a=r.length,u=a-s,c=o<u?o:u,l=-1,h=0;h<=c;++h){if(h===c){if(u>c){if(r.charCodeAt(s+h)===47)return r.slice(s+h+1);if(h===0)return r.slice(s+h)}else o>c&&(t.charCodeAt(n+h)===47?l=h:h===0&&(l=0));break}var p=t.charCodeAt(n+h),y=r.charCodeAt(s+h);if(p!==y)break;p===47&&(l=h)}var b="";for(h=n+l+1;h<=i;++h)(h===i||t.charCodeAt(h)===47)&&(b.length===0?b+="..":b+="/..");return b.length>0?b+r.slice(s+l):(s+=l,r.charCodeAt(s)===47&&++s,r.slice(s))},_makeLong:function(t){return t},dirname:function(t){if(We(t),t.length===0)return".";for(var r=t.charCodeAt(0),n=r===47,i=-1,o=!0,s=t.length-1;s>=1;--s)if(r=t.charCodeAt(s),r===47){if(!o){i=s;break}}else o=!1;return i===-1?n?"/":".":n&&i===1?"//":t.slice(0,i)},basename:function(t,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');We(t);var n=0,i=-1,o=!0,s;if(r!==void 0&&r.length>0&&r.length<=t.length){if(r.length===t.length&&r===t)return"";var a=r.length-1,u=-1;for(s=t.length-1;s>=0;--s){var c=t.charCodeAt(s);if(c===47){if(!o){n=s+1;break}}else u===-1&&(o=!1,u=s+1),a>=0&&(c===r.charCodeAt(a)?--a===-1&&(i=s):(a=-1,i=u))}return n===i?i=u:i===-1&&(i=t.length),t.slice(n,i)}else{for(s=t.length-1;s>=0;--s)if(t.charCodeAt(s)===47){if(!o){n=s+1;break}}else i===-1&&(o=!1,i=s+1);return i===-1?"":t.slice(n,i)}},extname:function(t){We(t);for(var r=-1,n=0,i=-1,o=!0,s=0,a=t.length-1;a>=0;--a){var u=t.charCodeAt(a);if(u===47){if(!o){n=a+1;break}continue}i===-1&&(o=!1,i=a+1),u===46?r===-1?r=a:s!==1&&(s=1):r!==-1&&(s=-1)}return r===-1||i===-1||s===0||s===1&&r===i-1&&r===n+1?"":t.slice(r,i)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return tx("/",t)},parse:function(t){We(t);var r={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return r;var n=t.charCodeAt(0),i=n===47,o;i?(r.root="/",o=1):o=0;for(var s=-1,a=0,u=-1,c=!0,l=t.length-1,h=0;l>=o;--l){if(n=t.charCodeAt(l),n===47){if(!c){a=l+1;break}continue}u===-1&&(c=!1,u=l+1),n===46?s===-1?s=l:h!==1&&(h=1):s!==-1&&(h=-1)}return s===-1||u===-1||h===0||h===1&&s===u-1&&s===a+1?u!==-1&&(a===0&&i?r.base=r.name=t.slice(1,u):r.base=r.name=t.slice(a,u)):(a===0&&i?(r.name=t.slice(1,s),r.base=t.slice(1,u)):(r.name=t.slice(a,s),r.base=t.slice(a,u)),r.ext=t.slice(s,u)),a>0?r.dir=t.slice(0,a-1):i&&(r.dir="/"),r},sep:"/",delimiter:":",win32:null,posix:null};Sr.posix=Sr;var rx=Sr;const Oc=Ps(rx);let Ac;typeof queueMicrotask=="function"&&queueMicrotask.bind(typeof window<"u"?window:Wh);nx=async function nx(e){if(typeof e=="string"&&/^(stream-)?magnet:/.test(e)){const t=Ro(e);if(!t.infoHash)throw new Error("Invalid torrent identifier");return t}else{if(typeof e=="string"&&(/^[a-f0-9]{40}$/i.test(e)||/^[a-z2-7]{32}$/i.test(e)))return Ro(`magnet:?xt=urn:btih:${e}`);if(ArrayBuffer.isView(e)&&e.length===20)return Ro(`magnet:?xt=urn:btih:${dt(e)}`);if(ArrayBuffer.isView(e))return await ix(e);if(e&&e.infoHash)return e.infoHash=e.infoHash.toLowerCase(),e.announce||(e.announce=[]),typeof e.announce=="string"&&(e.announce=[e.announce]),e.urlList||(e.urlList=[]),e;throw new Error("Invalid torrent identifier")}};async function ix(e){ArrayBuffer.isView(e)&&(e=xc.decode(e)),Mt(e.info,"info"),Mt(e.info["name.utf-8"]||e.info.name,"info.name"),Mt(e.info["piece length"],"info['piece length']"),Mt(e.info.pieces,"info.pieces"),e.info.files?e.info.files.forEach(i=>{Mt(typeof i.length=="number","info.files[0].length"),Mt(i["path.utf-8"]||i.path,"info.files[0].path")}):Mt(typeof e.info.length=="number","info.length");const t={info:e.info,infoBuffer:xc.encode(e.info),name:rt(e.info["name.utf-8"]||e.info.name),announce:[]};t.infoHashBuffer=await j1(t.infoBuffer),t.infoHash=dt(t.infoHashBuffer),e.info.private!==void 0&&(t.private=!!e.info.private),e["creation date"]&&(t.created=new Date(e["creation date"]*1e3)),e["created by"]&&(t.createdBy=rt(e["created by"])),ArrayBuffer.isView(e.comment)&&(t.comment=rt(e.comment)),Array.isArray(e["announce-list"])&&e["announce-list"].length>0?e["announce-list"].forEach(i=>{i.forEach(o=>{t.announce.push(rt(o))})}):e.announce&&t.announce.push(rt(e.announce)),ArrayBuffer.isView(e["url-list"])&&(e["url-list"]=e["url-list"].length>0?[e["url-list"]]:[]),t.urlList=(e["url-list"]||[]).map(i=>rt(i)),t.announce=Array.from(new Set(t.announce)),t.urlList=Array.from(new Set(t.urlList));const r=e.info.files||[e.info];t.files=r.map((i,o)=>{const s=[].concat(t.name,i["path.utf-8"]||i.path||[]).map(a=>ArrayBuffer.isView(a)?rt(a):a);return{path:Oc.join.apply(null,[Oc.sep].concat(s)).slice(1),name:s[s.length-1],length:i.length,offset:r.slice(0,o).reduce(Cc,0)}}),t.length=r.reduce(Cc,0);const n=t.files[t.files.length-1];return t.pieceLength=e.info["piece length"],t.lastPieceLength=(n.offset+n.length)%t.pieceLength||t.pieceLength,t.pieces=ox(e.info.pieces),t}function Cc(e,t){return e+t.length}function ox(e){const t=[];for(let r=0;r<e.length;r+=20)t.push(dt(e.slice(r,r+20)));return t}function Mt(e,t){if(!e)throw new Error(`Torrent is missing required field: ${t}`)}let sx;px=ex;({torrents:sx}=await Ih.addCollections({torrents:{schema:_1}}).catch(e=>{throw e}));Fh=sx;Fh.preInsert(e=>{e.state.torrentFile=kh(e.state.torrentFile),e.state.addedAt=Date.now()},!0);Fh.postCreate((e,t)=>{const r=R1(e.state.torrentFile);Object.defineProperty(t.state,"torrentFile",{get:()=>r})});let ax,Pa,ux;yx=async e=>{const{default:t}=await import("./shared-worker-c85a5375.js").then(async m=>{await m.__tla;return m}),{magnet:r,torrentFile:n}={magnet:"magnet"in e?e.magnet:void 0,torrentFile:"torrentFile"in e?e.torrentFile:void 0},i=n?.infoHash??nx(r).infoHash;await Ds(t.port,{key:"shared-worker-fkn-api"})("addTorrent",{infoHash:i,magnet:r,torrentFile:n&&kh(n)})};mx=async e=>{const{default:t}=await import("./shared-worker-c85a5375.js").then(async m=>{await m.__tla;return m});await Ds(t.port,{key:"shared-worker-fkn-api"})("removeTorrent",{infoHash:e.infoHash,removeFiles:e.removeFiles})};vx=async e=>{const{default:t}=await import("./shared-worker-c85a5375.js").then(async m=>{await m.__tla;return m});return Ds(t.port,{key:"shared-worker-fkn-api"})("readTorrentFile",{infoHash:e.infoHash,filePath:e.filePath,offset:e.offset,size:e.size})};({settings:ax}=await Ih.addCollections({settings:{schema:x1}}).catch(e=>{throw e}));Pa=ax;ux={id:"settings",paused:!1,throttle:0,maxConnections:0,downloadSpeedLimit:1e7,downloadSpeedLimitEnabled:!0,saveFolderEnabled:!1};gx=()=>{const[e,t]=ui.useState();return ui.useEffect(()=>{const r=Pa.findOne({}).$.subscribe(n=>t(n??void 0));return()=>r.unsubscribe()},[]),e};cx=async()=>await Pa.findOne({}).exec();cx().then(e=>{e||Pa.insert(ux)})})();export{vn as A,Hp as E,Pe as O,fx as R,tp as _,ad as a,ot as b,yx as c,Ih as d,mx as e,vx as f,Ps as g,Uc as h,Dt as i,Ct as j,pt as k,hx as l,Qp as m,Le as n,Xe as o,nx as p,pn as q,ui as r,R1 as s,Fh as t,gx as u,dx as v,kh as w,px as x,mn as y,cx as z,__tla};