What is a realtime database?
diff --git a/docs/assets/js/0e268d20.a51dda1a.js b/docs/assets/js/0e268d20.e23b606a.js
similarity index 99%
rename from docs/assets/js/0e268d20.a51dda1a.js
rename to docs/assets/js/0e268d20.e23b606a.js
index 6ad8dd76940..6bae785eaff 100644
--- a/docs/assets/js/0e268d20.a51dda1a.js
+++ b/docs/assets/js/0e268d20.e23b606a.js
@@ -1 +1 @@
-"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[2160],{5921:(e,t,r)=>{r.d(t,{O9:()=>Hr,N8:()=>Qr,dZ:()=>Fr});var a=r(8061);function n(e,t){var r=e.get(t);if(void 0===r)throw new Error("missing value from map "+t);return r}function i(e,t,r,a){var n=e.get(t);return void 0===n?(n=r(),e.set(t,n)):a&&a(n),n}function s(e){return Object.assign({},e)}function o(e,t){if(void 0===t&&(t=!1),!e)return e;if(!t&&Array.isArray(e))return e.sort(((e,t)=>"string"==typeof e&&"string"==typeof t?e.localeCompare(t):"object"==typeof e?1:-1)).map((e=>o(e,t)));if("object"==typeof e&&!Array.isArray(e)){var r={};return Object.keys(e).sort(((e,t)=>e.localeCompare(t))).forEach((a=>{r[a]=o(e[a],t)})),r}return e}var c=function e(t){if(!t)return t;if(null===t||"object"!=typeof t)return t;if(Array.isArray(t)){for(var r=new Array(t.length),a=r.length;a--;)r[a]=e(t[a]);return r}var n={};for(var i in t)n[i]=e(t[i]);return n};function l(e,t,r){return Object.defineProperty(e,t,{get:function(){return r}}),r}var u=e=>{var t=typeof e;return null!==e&&("object"===t||"function"===t)},h=new Set(["__proto__","prototype","constructor"]),d=new Set("0123456789");function m(e){var t=[],r="",a="start",n=!1;for(var i of e)switch(i){case"\\":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");n&&(r+=i),a="property",n=!n;break;case".":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="property";break}if(n){n=!1,r+=i;break}if(h.has(r))return[];t.push(r),r="",a="property";break;case"[":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="index";break}if(n){n=!1,r+=i;break}if("property"===a){if(h.has(r))return[];t.push(r),r=""}a="index";break;case"]":if("index"===a){t.push(Number.parseInt(r,10)),r="",a="indexEnd";break}if("indexEnd"===a)throw new Error("Invalid character after an index");default:if("index"===a&&!d.has(i))throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");"start"===a&&(a="property"),n&&(n=!1,r+="\\"),r+=i}switch(n&&(r+="\\"),a){case"property":if(h.has(r))return[];t.push(r);break;case"index":throw new Error("Index was not closed");case"start":t.push("")}return t}function p(e,t){if("number"!=typeof t&&Array.isArray(e)){var r=Number.parseInt(t,10);return Number.isInteger(r)&&e[r]===e[t]}return!1}function f(e,t){if(p(e,t))throw new Error("Cannot use string index")}function y(e,t,r){if(Array.isArray(t)&&(t=t.join(".")),!t.includes(".")&&!t.includes("["))return e[t];if(!u(e)||"string"!=typeof t)return void 0===r?e:r;var a=m(t);if(0===a.length)return r;for(var n=0;n
!1,deepFreezeWhenDevMode:e=>e,tunnelErrorMessage:e=>"RxDB Error-Code "+e+".\n Error messages are not included in RxDB core to reduce build size.\n - To find out what this error means, either use the dev-mode-plugin https://rxdb.info/dev-mode.html\n - or search for the error code here: https://github.com/pubkey/rxdb/search?q="+e+"\n "};function k(e,t,r){return"RxError ("+t+"):\n"+e+"\n"+function(e){var t="";return 0===Object.keys(e).length?t:(t+="Given parameters: {\n",t+=Object.keys(e).map((t=>{var r="[object Object]";try{r="errors"===t?e[t].map((e=>JSON.stringify(e,Object.getOwnPropertyNames(e)))):JSON.stringify(e[t],(function(e,t){return void 0===t?null:t}),2)}catch(a){}return t+":"+r})).join("\n"),t+="}")}(r)}var D=function(e){function t(t,r,a){var n;void 0===a&&(a={});var i=k(r,t,a);return(n=e.call(this,i)||this).code=t,n.message=i,n.parameters=a,n.rxdb=!0,n}return(0,x.Z)(t,e),t.prototype.toString=function(){return this.message},(0,b.Z)(t,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),t}((0,w.Z)(Error)),_=function(e){function t(t,r,a){var n;void 0===a&&(a={});var i=k(r,t,a);return(n=e.call(this,i)||this).code=t,n.message=i,n.parameters=a,n.rxdb=!0,n}return(0,x.Z)(t,e),t.prototype.toString=function(){return this.message},(0,b.Z)(t,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),t}((0,w.Z)(TypeError));function I(e,t){return new D(e,j.tunnelErrorMessage(e),t)}function R(e,t){return new _(e,j.tunnelErrorMessage(e),t)}function E(e){return!(!e||409!==e.status)&&e}var P={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var S=/\./g,C="abcdefghijklmnopqrstuvwxyz";function O(e){void 0===e&&(e=10);for(var t="",r=0;r{var r=y(t,e);if(void 0===r)throw I("DOC18",{args:{field:e,documentData:t}});return r})).join(r.separator)}function W(e){var t=T((e=s(e)).primaryKey);e.properties=s(e.properties),e.additionalProperties=!1,Object.prototype.hasOwnProperty.call(e,"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=z,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=F(e);(0,g.gu)(e.required,r),e.required=e.required.filter((e=>!e.includes("."))).filter(((e,t,r)=>r.indexOf(e)===t)),e.version=e.version||0;var a=e.indexes.map((e=>{var r=(0,g.AD)(e)?e.slice(0):[e];return r.includes(t)||r.push(t),"_deleted"!==r[0]&&r.unshift("_deleted"),r}));0===a.length&&a.push(function(e){return["_deleted",e]}(t)),a.push(["_meta.lwt",t]),e.internalIndexes&&e.internalIndexes.map((e=>{a.push(e)}));var n=new Set;return a.filter((e=>{var t=e.join(",");return!n.has(t)&&(n.add(t),!0)})),e.indexes=a,e}var z={type:"object",properties:{lwt:{type:"number",minimum:A,maximum:1e15,multipleOf:.01}},additionalProperties:!0,required:["lwt"]};function F(e){var t=Object.keys(e.properties).filter((t=>e.properties[t].final)),r=T(e.primaryKey);return t.push(r),"string"!=typeof e.primaryKey&&e.primaryKey.fields.forEach((e=>t.push(e))),t}var Q="docs",H="changes",U="attachments",K="dexie",Z=new Map,V=new Map;var J="__";function G(e){var t=e.split(".");if(t.length>1)return t.map((e=>G(e))).join(".");if(e.startsWith("|")){var r=e.substring(1);return J+r}return e}function Y(e){var t=e.split(".");return t.length>1?t.map((e=>Y(e))).join("."):e.startsWith(J)?"|"+e.substring(J.length):e}function X(e,t){return t?(t=te(t=s(t)),e.forEach((e=>{var r=y(t,e);v(t,e,r?"1":"0")})),t):t}function ee(e,t){return t?(t=re(t=s(t)),e.forEach((e=>{var r=y(t,e);v(t,e,"1"===r)})),t):t}function te(e){if(!e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(Array.isArray(e))return e.map((e=>te(e)));if("object"==typeof e){var t={};return Object.entries(e).forEach((e=>{let[r,a]=e;"object"==typeof a&&(a=te(a)),t[G(r)]=a})),t}}function re(e){if(!e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(Array.isArray(e))return e.map((e=>re(e)));if("object"==typeof e){var t={};return Object.entries(e).forEach((r=>{let[a,n]=r;("object"==typeof n||Array.isArray(e))&&(n=re(n)),t[Y(a)]=n})),t}}function ae(e){var t=[],r=T(e.primaryKey);t.push([r]),t.push(["_deleted",r]),e.indexes&&e.indexes.forEach((e=>{var r=(0,g.qo)(e);t.push(r)})),t.push(["_meta.lwt",r]),t.push(["_meta.lwt"]);var a=(t=t.map((e=>e.map((e=>G(e)))))).map((e=>1===e.length?e[0]:"["+e.join("+")+"]"));return(a=a.filter(((e,t,r)=>r.indexOf(e)===t))).join(", ")}async function ne(e,t){var r=await e;return(await r.dexieTable.bulkGet(t)).map((e=>ee(r.booleanIndexes,e)))}function ie(e,t){return e+"||"+t}function se(e){var t=new Set,r=[];return e.indexes?(e.indexes.forEach((a=>{(0,g.qo)(a).forEach((a=>{t.has(a)||(t.add(a),"boolean"===M(e,a).type&&r.push(a))}))})),r.push("_deleted"),(0,g.Nb)(r)):r}var oe=r(6974),ce=r(984),le=r(7400),ue=String.fromCharCode(65535),he=Number.MIN_SAFE_INTEGER;function de(e,t){var r=t.selector,a=e.indexes?e.indexes.slice(0):[];t.index&&(a=[t.index]);var n=!!t.sort.find((e=>"desc"===Object.values(e)[0])),i=new Set;Object.keys(r).forEach((t=>{var a=M(e,t);a&&"boolean"===a.type&&Object.prototype.hasOwnProperty.call(r[t],"$eq")&&i.add(t)}));var s,o=t.sort.map((e=>Object.keys(e)[0])).filter((e=>!i.has(e))).join(","),c=-1;if(a.forEach((e=>{var a=!0,l=!0,u=e.map((e=>{var t=r[e],n=t?Object.keys(t):[],i={};t&&n.length?n.forEach((e=>{if(me.has(e)){var r=function(e,t){switch(e){case"$eq":return{startKey:t,endKey:t,inclusiveEnd:!0,inclusiveStart:!0};case"$lte":return{endKey:t,inclusiveEnd:!0};case"$gte":return{startKey:t,inclusiveStart:!0};case"$lt":return{endKey:t,inclusiveEnd:!1};case"$gt":return{startKey:t,inclusiveStart:!1};default:throw new Error("SNH")}}(e,t[e]);i=Object.assign(i,r)}})):i={startKey:l?he:ue,endKey:a?ue:he,inclusiveStart:!0,inclusiveEnd:!0};return void 0===i.startKey&&(i.startKey=he),void 0===i.endKey&&(i.endKey=ue),void 0===i.inclusiveStart&&(i.inclusiveStart=!0),void 0===i.inclusiveEnd&&(i.inclusiveEnd=!0),l&&!i.inclusiveStart&&(l=!1),a&&!i.inclusiveEnd&&(a=!1),i})),h=u.map((e=>e.startKey)),d=u.map((e=>e.endKey)),m={index:e,startKeys:h,endKeys:d,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!i.has(e))).join(","),selectorSatisfiedByIndex:ye(e,t.selector,h,d)},p=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},i=10,s=(0,g.r0)(r.startKeys,(e=>e!==he&&e!==ue));n(s*i);var o=(0,g.r0)(r.startKeys,(e=>e!==ue&&e!==he));n(o*i);var c=(0,g.r0)(r.startKeys,((e,t)=>e===r.endKeys[t]));n(c*i*1.5);var l=r.sortSatisfiedByIndex?5:0;return n(l),a}(0,0,m);(p>=c||t.index)&&(c=p,s=m)})),!s)throw I("SNH",{query:t});return s}var me=new Set(["$eq","$gt","$gte","$lt","$lte"]),pe=new Set(["$eq","$gt","$gte"]),fe=new Set(["$eq","$lt","$lte"]);function ye(e,t,r,a){var n=Object.entries(t).find((t=>{let[r,a]=t;return!e.includes(r)||Object.entries(a).find((e=>{let[t,r]=e;return!me.has(t)}))}));if(n)return!1;if(t.$and||t.$or)return!1;var i=[],s=new Set;for(var[o,c]of Object.entries(t)){if(!e.includes(o))return!1;var l=Object.keys(c).filter((e=>pe.has(e)));if(l.length>1)return!1;var u=l[0];if(u&&s.add(o),"$eq"!==u){if(i.length>0)return!1;i.push(u)}}var h=[],d=new Set;for(var[m,p]of Object.entries(t)){if(!e.includes(m))return!1;var f=Object.keys(p).filter((e=>fe.has(e)));if(f.length>1)return!1;var y=f[0];if(y&&d.add(m),"$eq"!==y){if(h.length>0)return!1;h.push(y)}}var v=0;for(var g of e){for(var b of[s,d]){if(!b.has(g)&&b.size>0)return!1;b.delete(g)}if(r[v]!==a[v]&&s.size>0&&d.size>0)return!1;v++}return!0}var ve=r(6250),ge=r(7761),be=r(7132),xe=r(6496),we=r(6851),je=r(3516),ke=r(8039),De=r(5308),_e=r(2106),Ie=!1;function Re(e){return Ie||((0,ge.Qs)(ge.$M.PIPELINE,{$sort:xe.E3,$project:xe.FM}),(0,ge.Qs)(ge.$M.QUERY,{$and:we.h$,$eq:je.l3,$elemMatch:De.rr,$exists:_e.G,$gt:je.ok,$gte:je.m9,$in:je.FI,$lt:je.Ty,$lte:je.HG,$ne:je.ny,$nin:je.IS,$mod:ke.JD,$nor:we.ps,$not:we._w,$or:we.Ko,$regex:ke.GO,$size:De.QH,$type:_e.e}),Ie=!0),new be.A(e)}function Ee(e,t){var r=T(e.primaryKey);t=s(t);var a=c(t);if("number"!=typeof a.skip&&(a.skip=0),a.selector?(a.selector=a.selector,Object.entries(a.selector).forEach((e=>{let[t,r]=e;"object"==typeof r&&null!==r||(a.selector[t]={$eq:r})}))):a.selector={},a.index){var n=(0,g.qo)(a.index);n.includes(r)||n.push(r),a.index=n}if(a.sort)a.sort.find((e=>{return t=e,Object.keys(t)[0]===r;var t}))||(a.sort=a.sort.slice(0),a.sort.push({[r]:"asc"}));else if(a.index)a.sort=a.index.map((e=>({[e]:"asc"})));else{if(e.indexes){var i=new Set;Object.entries(a.selector).forEach((e=>{let[t,r]=e;("object"!=typeof r||null===r||!!Object.keys(r).find((e=>me.has(e))))&&i.add(t)}));var o,l=-1;e.indexes.forEach((e=>{var t=(0,g.AD)(e)?e:[e],r=t.findIndex((e=>!i.has(e)));r>0&&r>l&&(l=r,o=t)})),o&&(a.sort=o.map((e=>({[e]:"asc"}))))}a.sort||(a.sort=[{[r]:"asc"}])}return a}function Pe(e,t){if(!t.sort)throw I("SNH",{query:t});var r=[];t.sort.forEach((e=>{var t,a,n,i=Object.keys(e)[0],s=Object.values(e)[0];r.push({key:i,direction:s,getValueFn:(t=i,a=t.split("."),n=a.length,1===n?e=>e[t]:e=>{for(var t=e,r=0;r{for(var a=0;ar.test(e)}function Ce(e){return e===he?-1/0:e}function Oe(e,t,r){return e.includes(t)?r===ue||!0===r?"1":"0":r}function Ne(e,t,r){if(!r){if("undefined"==typeof window)throw new Error("IDBKeyRange missing");r=window.IDBKeyRange}var a=t.startKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Ce),n=t.endKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Ce);return r.bound(a,n,!t.inclusiveStart,!t.inclusiveEnd)}async function Be(e,t){var r=await e.internals,a=t.query,n=a.skip?a.skip:0,i=n+(a.limit?a.limit:1/0),s=t.queryPlan,o=!1;s.selectorSatisfiedByIndex||(o=Se(e.schema,t.query));var c=Ne(r.booleanIndexes,s,r.dexieDb._options.IDBKeyRange),l=s.index,u=[];if(await r.dexieDb.transaction("r",r.dexieTable,(async e=>{var t,a=e.idbtrans.objectStore(Q);t="["+l.map((e=>G(e))).join("+")+"]";var n=a.index(t).openCursor(c);await new Promise((e=>{n.onsuccess=function(t){var a=t.target.result;if(a){var n=ee(r.booleanIndexes,a.value);o&&!o(n)||u.push(n),s.sortSatisfiedByIndex&&u.length===i?e():a.continue()}else e()}}))})),!s.sortSatisfiedByIndex){var h=Pe(e.schema,t.query);u=u.sort(h)}return{documents:u=u.slice(n,i)}}function Ae(e){var t=e.split("-");if(2!==t.length)throw new Error("malformatted revision: "+e);return{height:parseInt(t[0],10),hash:t[1]}}function qe(e){return parseInt(e.split("-")[0],10)}function Me(e,t){var r=t?t._rev:null;return(r?Ae(r).height:0)+1+"-"+e}var $e="_rxdb_internal";async function Te(e,t){var r=(await e.findDocumentsById([t],!1))[0];return r||void 0}async function Le(e,t,r){var a=await e.bulkWrite([t],r);if(a.error.length>0)throw a.error[0];return a.success[0]}function We(e,t,r){var a=t.documentData,n=t.previousDocumentData;return{documentId:t.documentId,collectionName:r?r.name:void 0,isLocal:e,operation:t.operation,documentData:j.deepFreezeWhenDevMode(a),previousDocumentData:j.deepFreezeWhenDevMode(n)}}function ze(e,t,r,a){if(a)throw 409===a.status?I("CONFLICT",{collection:e.name,id:t,writeError:a,data:r}):422===a.status?I("VD2",{collection:e.name,id:t,writeError:a,data:r}):a}function Fe(e){return{previous:e.previous,document:Qe(e.document)}}function Qe(e){if(!e._attachments||0===Object.keys(e._attachments).length)return e;var t=s(e);return t._attachments={},Object.entries(e._attachments).forEach((e=>{let[r,a]=e;var n,i,s;t._attachments[r]=(s=(n=a).data)?{length:(i=s,atob(i).length),digest:n.digest,type:n.type}:n})),t}function He(e){var t=s(e);return t._meta=s(e._meta),t}function Ue(e,t,r){j.deepFreezeWhenDevMode(r);var a=T(r.primaryKey);var n={originalStorageInstance:t,schema:t.schema,internals:t.internals,collectionName:t.collectionName,databaseName:t.databaseName,options:t.options,bulkWrite(n,i){var o=n.map((n=>function(n){var i=s(n.document);if(i._meta=s(i._meta),j.isDevMode()){i=$(a,r,i);try{"function"==typeof structuredClone?structuredClone(n):JSON.parse(JSON.stringify(n))}catch(o){throw I("DOC24",{collection:t.collectionName,document:n.document})}n.previous,n.previous&&Object.keys(n.previous._meta).forEach((e=>{if(!Object.prototype.hasOwnProperty.call(n.document._meta,e))throw I("SNH",{dataBefore:n.previous,dataAfter:n.document})}))}return i._meta.lwt=(0,ce.z)(),i._rev=Me(e.token,n.previous),{document:i,previous:n.previous}}(n)));return e.lockedRun((()=>t.bulkWrite(o,i))).then((r=>{var a={error:[],success:r.success.slice(0)},n=r.error.filter((e=>!(409!==e.status||e.writeRow.previous||e.writeRow.document._deleted||!(0,le.Is)(e.documentInDb)._deleted)||(a.error.push(e),!1)));if(n.length>0){var s=n.map((t=>({previous:t.documentInDb,document:Object.assign({},t.writeRow.document,{_rev:Me(e.token,t.documentInDb)})})));return e.lockedRun((()=>t.bulkWrite(s,i))).then((e=>((0,g.gu)(a.error,e.error),(0,g.gu)(a.success,e.success),a)))}return r}))},query:r=>e.lockedRun((()=>t.query(r))),count:r=>e.lockedRun((()=>t.count(r))),findDocumentsById:(r,a)=>e.lockedRun((()=>t.findDocumentsById(r,a))),getAttachmentData:(r,a,n)=>e.lockedRun((()=>t.getAttachmentData(r,a,n))),getChangedDocumentsSince:t.getChangedDocumentsSince?(r,a)=>e.lockedRun((()=>t.getChangedDocumentsSince((0,le.Is)(r),a))):void 0,cleanup:r=>e.lockedRun((()=>t.cleanup(r))),remove:()=>(e.storageInstances.delete(n),e.lockedRun((()=>t.remove()))),close:()=>(e.storageInstances.delete(n),e.lockedRun((()=>t.close()))),changeStream:()=>t.changeStream(),conflictResultionTasks:()=>t.conflictResultionTasks(),resolveConflictResultionTask(e){if(e.output.isEqual)return t.resolveConflictResultionTask(e);var r=s(Object.assign({},e.output.documentData,{_meta:q(),_rev:"",_attachments:{}}));return delete r._meta,delete r._rev,delete r._attachments,t.resolveConflictResultionTask({id:e.id,output:{isEqual:!1,documentData:r}})}};return e.storageInstances.add(n),n}var Ke=r(5677),Ze=r(3981),Ve=new Map;function Je(e,t){var r=Ve.get(e);if(r)return r.refs.delete(t),0===r.refs.size?(Ve.delete(e),r.bc.close()):void 0}function Ge(e,t,r,a){if(t.multiInstance){var n=a||function(e,t,r,a){var n=Ve.get(t);return n||(n={bc:new Ze.g0(["RxDB:",e,r].join("|")),refs:new Set},Ve.set(t,n)),n.refs.add(a),n.bc}(e,t.databaseInstanceToken,r.databaseName,r),i=new oe.x,s=r=>{r.storageName===e&&r.databaseName===t.databaseName&&r.collectionName===t.collectionName&&r.version===t.schema.version&&i.next(r.eventBulk)};n.addEventListener("message",s);var o=r.changeStream(),c=!1,l=o.subscribe((r=>{c||n.postMessage({storageName:e,databaseName:t.databaseName,collectionName:t.collectionName,version:t.schema.version,eventBulk:r})}));r.changeStream=function(){return i.asObservable().pipe((0,Ke.b)(o))};var u=r.close.bind(r);r.close=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),u()};var h=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),h()}}}var Ye=(0,ce.z)(),Xe=function(){function e(e,t,r,a,n,i,s){this.changes$=new oe.x,this.instanceId=Ye++,this.storage=e,this.databaseName=t,this.collectionName=r,this.schema=a,this.internals=n,this.options=i,this.settings=s,this.primaryPath=T(this.schema.primaryKey)}var t=e.prototype;return t.bulkWrite=async function(e,t){tt(this),e.forEach((e=>{if(!e.document._rev||e.previous&&!e.previous._rev)throw I("SNH",{args:{row:e}})}));var r,a=await this.internals,n={success:[],error:[]},i=e.map((e=>e.document[this.primaryPath]));if(await a.dexieDb.transaction("rw",a.dexieTable,a.dexieAttachmentsTable,(async()=>{var s=new Map;(await ne(this.internals,i)).forEach((e=>{var t=e;return t&&s.set(t[this.primaryPath],t),t})),r=function(e,t,r,a,n,i,s){for(var o,c=!!e.schema.attachments,l=[],u=[],h=[],d={id:O(10),events:[],checkpoint:null,context:n,startTime:(0,ce.z)(),endTime:0},m=d.events,p=[],f=[],y=[],v=r.size>0,g=a.length,b=function(){var e,n=a[x],d=n.document,g=n.previous,b=d[t],w=d._deleted,j=g&&g._deleted,k=void 0;if(v&&(k=r.get(b)),k){var D=k._rev;if(!g||g&&D!==g._rev){var _={isError:!0,status:409,documentId:b,writeRow:n,documentInDb:k};return h.push(_),1}var R=c?Fe(n):n;c&&(w?g&&Object.keys(g._attachments).forEach((e=>{f.push({documentId:b,attachmentId:e,digest:(0,le.Is)(g)._attachments[e].digest})})):(Object.entries(d._attachments).find((t=>{let[r,a]=t;return(g?g._attachments[r]:void 0)||a.data||(e={documentId:b,documentInDb:k,isError:!0,status:510,writeRow:n,attachmentId:r}),!0})),e||Object.entries(d._attachments).forEach((e=>{let[t,r]=e;var a=g?g._attachments[t]:void 0;if(a){var n=R.document._attachments[t].digest;r.data&&a.digest!==n&&y.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})}else p.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})})))),e?h.push(e):(c?(u.push(Fe(R)),s&&s(d)):(u.push(R),s&&s(d)),o=R);var E=null,P=null,S=null;if(j&&!w)S="INSERT",E=c?Qe(d):d;else if(!g||j||w){if(!w)throw I("SNH",{args:{writeRow:n}});S="DELETE",E=(0,le.Is)(d),P=g}else S="UPDATE",E=c?Qe(d):d,P=g;var C={documentId:b,documentData:E,previousDocumentData:P,operation:S};m.push(C)}else{var O=!!w;if(c&&Object.entries(d._attachments).forEach((t=>{let[r,a]=t;a.data?p.push({documentId:b,attachmentId:r,attachmentData:a,digest:a.digest}):(e={documentId:b,isError:!0,status:510,writeRow:n,attachmentId:r},h.push(e))})),e||(c?(l.push(Fe(n)),i&&i(d)):(l.push(n),i&&i(d)),o=n),!O){var N={documentId:b,operation:"INSERT",documentData:c?Qe(d):d,previousDocumentData:c&&g?Qe(g):g};m.push(N)}}},x=0;x{n.success.push(e.document),o.push(e.document)})),r.bulkUpdateDocs.forEach((e=>{n.success.push(e.document),o.push(e.document)})),(o=o.map((e=>X(a.booleanIndexes,e)))).length>0&&await a.dexieTable.bulkPut(o);var c=[];r.attachmentsAdd.forEach((e=>{c.push({id:ie(e.documentId,e.attachmentId),data:e.attachmentData.data})})),r.attachmentsUpdate.forEach((e=>{c.push({id:ie(e.documentId,e.attachmentId),data:e.attachmentData.data})})),await a.dexieAttachmentsTable.bulkPut(c),await a.dexieAttachmentsTable.bulkDelete(r.attachmentsRemove.map((e=>ie(e.documentId,e.attachmentId))))})),(r=(0,le.Is)(r)).eventBulk.events.length>0){var s=(0,le.Is)(r.newestRow).document;r.eventBulk.checkpoint={id:s[this.primaryPath],lwt:s._meta.lwt},r.eventBulk.endTime=(0,ce.z)(),this.changes$.next(r.eventBulk)}return n},t.findDocumentsById=async function(e,t){tt(this);var r=await this.internals,a=[];return await r.dexieDb.transaction("r",r.dexieTable,(async()=>{(await ne(this.internals,e)).forEach((e=>{!e||e._deleted&&!t||a.push(e)}))})),a},t.query=function(e){return tt(this),Be(this,e)},t.count=async function(e){if(e.queryPlan.selectorSatisfiedByIndex){var t=await async function(e,t){var r=await e.internals,a=t.queryPlan,n=a.index,i=Ne(r.booleanIndexes,a,r.dexieDb._options.IDBKeyRange),s=-1;return await r.dexieDb.transaction("r",r.dexieTable,(async e=>{var t,r=e.idbtrans.objectStore(Q);t="["+n.map((e=>G(e))).join("+")+"]";var a=r.index(t).count(i);s=await new Promise(((e,t)=>{a.onsuccess=function(){e(a.result)},a.onerror=e=>t(e)}))})),s}(this,e);return{count:t,mode:"fast"}}return{count:(await Be(this,e)).documents.length,mode:"slow"}},t.changeStream=function(){return tt(this),this.changes$.asObservable()},t.cleanup=async function(e){tt(this);var t=await this.internals;return await t.dexieDb.transaction("rw",t.dexieTable,(async()=>{var r=(0,ce.z)()-e,a=await t.dexieTable.where("_meta.lwt").below(r).toArray(),n=[];a.forEach((e=>{"1"===e._deleted&&n.push(e[this.primaryPath])})),await t.dexieTable.bulkDelete(n)})),!0},t.getAttachmentData=async function(e,t,r){tt(this);var a=await this.internals,n=ie(e,t);return await a.dexieDb.transaction("r",a.dexieAttachmentsTable,(async()=>{var r=await a.dexieAttachmentsTable.get(n);if(r)return r.data;throw new Error("attachment missing documentId: "+e+" attachmentId: "+t)}))},t.remove=async function(){tt(this);var e=await this.internals;return await e.dexieTable.clear(),this.close()},t.close=function(){return this.closed||(this.closed=(async()=>{this.changes$.complete(),await async function(e){var t=await e,r=V.get(e)-1;0===r?(t.dexieDb.close(),V.delete(e)):V.set(e,r)}(this.internals)})()),this.closed},t.conflictResultionTasks=function(){return new oe.x},t.resolveConflictResultionTask=async function(e){},e}();async function et(e,t,r){var n=function(e,t,r,n){var o="rxdb-dexie-"+e+"--"+n.version+"--"+t,c=i(Z,o,(()=>{var e=(async()=>{var e=s(r);e.autoOpen=!1;var t=new a.U(o,e),i={[Q]:ae(n),[H]:"++sequence, id",[U]:"id"};return t.version(1).stores(i),await t.open(),{dexieDb:t,dexieTable:t[Q],dexieAttachmentsTable:t[U],booleanIndexes:se(n)}})();return Z.set(o,c),V.set(c,0),e}));return c}(t.databaseName,t.collectionName,r,t.schema),o=new Xe(e,t.databaseName,t.collectionName,t.schema,n,t.options,r);return await Ge(K,t,o),Promise.resolve(o)}function tt(e){if(e.closed)throw new Error("RxStorageInstanceDexie is closed "+e.databaseName+"-"+e.collectionName)}var rt="15.4.1",at=function(){function e(e){this.name=K,this.rxdbVersion=rt,this.settings=e}return e.prototype.createStorageInstance=function(e){return function(e){if(e.schema.keyCompression)throw I("UT5",{args:{params:e}});if((t=e.schema).encrypted&&t.encrypted.length>0||t.attachments&&t.attachments.encrypted)throw I("UT6",{args:{params:e}});var t;if(e.schema.attachments&&e.schema.attachments.compression)throw I("UT7",{args:{params:e}})}(e),et(this,e,this.settings)},e}();function nt(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var r,a;if(Array.isArray(e)){if((r=e.length)!==t.length)return!1;for(a=r;0!=a--;)if(!nt(e[a],t[a]))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 n=Object.keys(e);if((r=n.length)!==Object.keys(t).length)return!1;for(a=r;0!=a--;)if(!Object.prototype.hasOwnProperty.call(t,n[a]))return!1;for(a=r;0!=a--;){var i=n[a];if(!nt(e[i],t[i]))return!1}return!0}return e!=e&&t!=t}var it={preAddRxPlugin:[],preCreateRxDatabase:[],createRxDatabase:[],preCreateRxCollection:[],createRxCollection:[],postDestroyRxCollection:[],postRemoveRxCollection:[],preCreateRxSchema:[],createRxSchema:[],preCreateRxQuery:[],prePrepareQuery:[],createRxDocument:[],postCreateRxDocument:[],preCreateRxStorageInstance:[],preMigrateDocument:[],postMigrateDocument:[],preDestroyRxDatabase:[],postRemoveRxDatabase:[],preReplicationMasterWrite:[],preReplicationMasterWriteDocumentsHandle:[]};function st(e,t){it[e]&&it[e].forEach((e=>e(t)))}function ot(e,t){return Promise.all(it[e].map((e=>e(t))))}var ct=function(){function e(e,t){this.jsonSchema=e,this.hashFunction=t,this.indexes=function(e){return(e.indexes||[]).map((e=>(0,g.AD)(e)?e:[e]))}(this.jsonSchema),this.primaryPath=T(this.jsonSchema.primaryKey),this.finalFields=F(this.jsonSchema)}var t=e.prototype;return t.validateChange=function(e,t){this.finalFields.forEach((r=>{if(!nt(e[r],t[r]))throw I("DOC9",{dataBefore:e,dataAfter:t,fieldName:r,schema:this.jsonSchema})}))},t.getDocumentPrototype=function(){var e={},t=M(this.jsonSchema,"");return Object.keys(t).forEach((t=>{var r=t;e.__defineGetter__(t,(function(){if(this.get&&"function"==typeof this.get)return this.get(r)})),Object.defineProperty(e,t+"$",{get:function(){return this.get$(r)},enumerable:!1,configurable:!1}),Object.defineProperty(e,t+"_",{get:function(){return this.populate(r)},enumerable:!1,configurable:!1})})),l(this,"getDocumentPrototype",(()=>e)),e},t.getPrimaryOfDocumentData=function(e){return L(this.jsonSchema,e)},(0,b.Z)(e,[{key:"version",get:function(){return this.jsonSchema.version}},{key:"defaultValues",get:function(){var e={};return Object.entries(this.jsonSchema.properties).filter((e=>{let[,t]=e;return Object.prototype.hasOwnProperty.call(t,"default")})).forEach((t=>{let[r,a]=t;return e[r]=a.default})),l(this,"defaultValues",e)}},{key:"hash",get:function(){return l(this,"hash",this.hashFunction(JSON.stringify(this.jsonSchema)))}}]),e}();function lt(e,t,r){void 0===r&&(r=!0),r&&st("preCreateRxSchema",e);var a=W(e);a=function(e){return o(e,!0)}(a),j.deepFreezeWhenDevMode(a);var n=new ct(a,t);return st("createRxSchema",n),n}var ut=r(598),ht=r(6621),dt=r(6728),mt=r(6005),pt=r(7570),ft=r(4419);function yt(e){var t=e.split("-"),r="RxDB";return t.forEach((e=>{r+=N(e)})),r+="Plugin",new Error("You are using a function which must be overwritten by a plugin.\n You should either prevent the usage of this function or add the plugin via:\n import { "+r+" } from 'rxdb/plugins/"+e+"';\n addRxPlugin("+r+");\n ")}function vt(e){return e.documentData?e.documentData:e.previousDocumentData}var gt=function(){function e(e,t,r,a){this.queueByDocId=new Map,this.isRunning=!1,this.storageInstance=e,this.primaryPath=t,this.preWrite=r,this.postWrite=a}var t=e.prototype;return t.addWrite=function(e,t){var r=e[this.primaryPath],a=i(this.queueByDocId,r,(()=>[]));return new Promise(((r,n)=>{var i={lastKnownDocumentState:e,modifier:t,resolve:r,reject:n};(0,le.Is)(a).push(i),this.triggerRun()}))},t.triggerRun=async function(){if(!0!==this.isRunning&&0!==this.queueByDocId.size){this.isRunning=!0;var e=[],t=this.queueByDocId;this.queueByDocId=new Map,await Promise.all(Array.from(t.entries()).map((async t=>{let[r,a]=t;var n,i,s,o=(n=a.map((e=>e.lastKnownDocumentState)),i=n[0],s=Ae(i._rev).height,n.forEach((e=>{var t=Ae(e._rev).height;t>s&&(i=e,s=t)})),i),l=o;for(var u of a)try{l=await u.modifier(c(l))}catch(h){u.reject(h),u.reject=()=>{},u.resolve=()=>{}}try{await this.preWrite(l,o)}catch(h){return void a.forEach((e=>e.reject(h)))}e.push({previous:o,document:l})})));var r=e.length>0?await this.storageInstance.bulkWrite(e,"incremental-write"):{error:[],success:[]};return await Promise.all(r.success.map((e=>{var r=e[this.primaryPath];this.postWrite(e),n(t,r).forEach((t=>t.resolve(e)))}))),r.error.forEach((e=>{var r,a=e.documentId,s=n(t,a),o=E(e);if(o){var c=i(this.queueByDocId,a,(()=>[]));s.reverse().forEach((e=>{e.lastKnownDocumentState=(0,le.Is)(o.documentInDb),(0,le.Is)(c).unshift(e)}))}else{var l=I("COL20",{name:P[(r=e).status],document:r.documentId,writeError:r});s.forEach((e=>e.reject(l)))}})),this.isRunning=!1,this.triggerRun()}},e}();function bt(e){return async t=>{var r=function(e){return Object.assign({},e,{_meta:void 0,_deleted:void 0,_rev:void 0})}(t);r._deleted=t._deleted;var a=await e(r),n=Object.assign({},a,{_meta:t._meta,_attachments:t._attachments,_rev:t._rev,_deleted:void 0!==a._deleted?a._deleted:t._deleted});return void 0===n._deleted&&(n._deleted=!1),n}}var xt={get primaryPath(){if(this.isInstanceOfRxDocument)return this.collection.schema.primaryPath},get primary(){var e=this;if(e.isInstanceOfRxDocument)return e._data[e.primaryPath]},get revision(){if(this.isInstanceOfRxDocument)return this._data._rev},get deleted$(){if(this.isInstanceOfRxDocument)return this.$.pipe((0,ut.U)((e=>e._data._deleted)))},get deleted(){if(this.isInstanceOfRxDocument)return this._data._deleted},getLatest(){var e=this.collection._docCache.getLatestDocumentData(this.primary);return this.collection._docCache.getCachedRxDocument(e)},get $(){return this.collection.$.pipe((0,ht.h)((e=>!e.isLocal)),(0,ht.h)((e=>e.documentId===this.primary)),(0,ut.U)((e=>vt(e))),(0,dt.O)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.x)(((e,t)=>e._rev===t._rev)),(0,ut.U)((e=>this.collection._docCache.getCachedRxDocument(e))),(0,pt.d)(le.kv))},get$(e){if(j.isDevMode()){if(e.includes(".item."))throw I("DOC1",{path:e});if(e===this.primaryPath)throw I("DOC2");if(this.collection.schema.finalFields.includes(e))throw I("DOC3",{path:e});if(!M(this.collection.schema.jsonSchema,e))throw I("DOC4",{path:e})}return this.$.pipe((0,ut.U)((t=>y(t,e))),(0,mt.x)())},populate(e){var t=M(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.m5;if(!t)throw I("DOC5",{path:e});if(!t.ref)throw I("DOC6",{path:e,schemaObj:t});var a=this.collection.database.collections[t.ref];if(!a)throw I("DOC7",{ref:t.ref,path:e,schemaObj:t});return"array"===t.type?a.findByIds(r).exec().then((e=>{var t=e.values();return Array.from(t)})):a.findOne(r).exec()},get(e){return i(this._propertyCache,e,(()=>{var t=y(this._data,e);if("object"!=typeof t||null===t||Array.isArray(t))return j.deepFreezeWhenDevMode(t);var r=this;return new Proxy(s(t),{get(t,a){if("string"!=typeof a)return t[a];var n=a.charAt(a.length-1);if("$"===n){var i=a.slice(0,-1);return r.get$(B(e+"."+i))}if("_"===n){var s=a.slice(0,-1);return r.populate(B(e+"."+s))}return r.get(B(e+"."+a))}})}))},toJSON(e){if(void 0===e&&(e=!1),e)return j.deepFreezeWhenDevMode(this._data);var t=s(this._data);return delete t._rev,delete t._attachments,delete t._deleted,delete t._meta,j.deepFreezeWhenDevMode(t)},toMutableJSON(e){return void 0===e&&(e=!1),c(this.toJSON(e))},update(e){throw yt("update")},incrementalUpdate(e){throw yt("update")},updateCRDT(e){throw yt("crdt")},putAttachment(){throw yt("attachments")},getAttachment(){throw yt("attachments")},allAttachments(){throw yt("attachments")},get allAttachments$(){throw yt("attachments")},async modify(e,t){var r=this._data,a=await bt(e)(r);return this._saveData(a,r)},incrementalModify(e,t){return this.collection.incrementalWriteQueue.addWrite(this._data,bt(e)).then((e=>this.collection._docCache.getCachedRxDocument(e)))},patch(e){var t=this._data,r=c(t);return Object.entries(e).forEach((e=>{let[t,a]=e;r[t]=a})),this._saveData(r,t)},incrementalPatch(e){return this.incrementalModify((t=>(Object.entries(e).forEach((e=>{let[r,a]=e;t[r]=a})),t)))},async _saveData(e,t){if(e=s(e),this._data._deleted)throw I("DOC11",{id:this.primary,document:this});await jt(this.collection,e,t);var r=await this.collection.storageInstance.bulkWrite([{previous:t,document:e}],"rx-document-save-data"),a=r.error[0];return ze(this.collection,this.primary,e,a),await this.collection._runHooks("post","save",e,this),this.collection._docCache.getCachedRxDocument(r.success[0])},remove(){var e=this.collection;if(this.deleted)return Promise.reject(I("DOC13",{document:this,id:this.primary}));var t,r=s(this._data);return e._runHooks("pre","remove",r,this).then((async()=>{r._deleted=!0;var t=await e.storageInstance.bulkWrite([{previous:this._data,document:r}],"rx-document-remove"),a=t.error[0];return ze(e,this.primary,r,a),t.success[0]})).then((e=>(t=e,this.collection._runHooks("post","remove",r,this)))).then((()=>this.collection._docCache.getCachedRxDocument(t)))},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 I("DOC14")}};function wt(e){void 0===e&&(e=xt);var t=function(e,t){this.collection=e,this._data=t,this._propertyCache=new Map,this.isInstanceOfRxDocument=!0};return t.prototype=e,t}function jt(e,t,r){return t._meta=Object.assign({},r._meta,t._meta),j.isDevMode()&&e.schema.validateChange(r,t),e._runHooks("pre","save",t,r)}var kt=r(10),Dt=r(6871),_t=r(3028),It=r(1556),Rt=r(8456);function Et(e,t){return t.sort&&0!==t.sort.length?t.sort.map((e=>Object.keys(e)[0])):[e]}var Pt=new WeakMap;function St(e,t){if(!e.collection.database.eventReduce)return{runFullQueryAgain:!0};var r=function(e){return i(Pt,e,(()=>{var t=e.collection,r=Ee(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=Pe(t.schema.jsonSchema,r),i=Se(t.schema.jsonSchema,r);return{primaryKey:e.collection.schema.primaryPath,skip:r.skip,limit:r.limit,sortFields:Et(a,r),sortComparator:(t,r)=>{var a={docA:t,docB:r,rxQuery:e};return n(a.docA,a.docB)},queryMatcher:t=>i({doc:t,rxQuery:e}.doc)}}))}(e),a=(0,le.Is)(e._result).docsData.slice(0),n=(0,le.Is)(e._result).docsDataMap,s=!1;return t.map((e=>function(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:j.deepFreezeWhenDevMode(e.documentData),previous:e.previousDocumentData?e.previousDocumentData:"UNKNOWN"};case"DELETE":return{operation:e.operation,id:e.documentId,doc:null,previous:e.previousDocumentData}}}(e))).filter(g.S7).find((e=>{var t={queryParams:r,changeEvent:e,previousResults:a,keyDocumentMap:n},i=(0,Rt.Rf)(t);return"runFullQueryAgain"===i||("doNothing"!==i?(s=!0,(0,Rt.wu)(i,r,e,a,n),!1):void 0)}))?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:s,newResults:a}}var Ct=function(){function e(){this._map=new Map}return e.prototype.getByQuery=function(e){var t=e.toString();return i(this._map,t,(()=>e))},e}();function Ot(e,t){t.uncached=!0;var r=t.toString();e._map.delete(r)}function Nt(e){return e.refCount$.observers.length}var Bt,At,qt=(Bt=100,At=3e4,(e,t)=>{if(!(t._map.size0||(0===i._lastEnsureEqual&&i._creationTimee._lastEnsureEqual-t._lastEnsureEqual)).slice(0,s).forEach((e=>Ot(t,e)))}}),Mt=new WeakSet;var $t=function(){function e(e,t,r){this.cacheItemByDocId=new Map,this.registry="function"==typeof FinalizationRegistry?new FinalizationRegistry((e=>{var t=e.docId,r=this.cacheItemByDocId.get(t);r&&(r.byRev.delete(e.revisionHeight),0===r.byRev.size&&this.cacheItemByDocId.delete(t))})):void 0,this.registerIdleTasks=[],this.primaryPath=e,this.changes$=t,this.documentCreator=r,t.subscribe((e=>{var t=e.documentId,r=this.cacheItemByDocId.get(t);if(r){var a=vt(e);r.last=a}}))}var t=e.prototype;return t.getLatestDocumentData=function(e){return n(this.cacheItemByDocId,e).last},t.getLatestDocumentDataIfExists=function(e){var t=this.cacheItemByDocId.get(e);if(t)return t.last},(0,b.Z)(e,[{key:"getCachedRxDocument",get:function(){return l(this,"getCachedRxDocument",function(e){var t=e.primaryPath,r=e.cacheItemByDocId,a=e.registry,n=j.deepFreezeWhenDevMode,s=e.documentCreator,o=o=>{var c=o[t],l=qe(o._rev),u=i(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),h=u.byRev,d=h.get(l),m=d?d.deref():void 0;return m||(o=n(o),m=s(o),h.set(l,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,ft.y$)().then((()=>{e.registerIdlePromise=void 0;var t=e.registerIdleTasks;0!==t.length&&(e.registerIdleTasks=[],t.forEach((e=>{a.register(e,{docId:e.primary,revisionHeight:qe(e.revision)})})))}))))),m};return o}(this))}}]),e}();function Tt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Wt=function(){function e(e,t,r){this.time=(0,ce.z)(),this.collection=e,this.count=r,this.documents=Tt(this.collection._docCache,t)}return(0,b.Z)(e,[{key:"docsData",get:function(){return l(this,"docsData",this.documents.map((e=>e._data)))}},{key:"docsDataMap",get:function(){var e=new Map;return this.documents.forEach((t=>{e.set(t.primary,t._data)})),l(this,"docsDataMap",e)}},{key:"docsMap",get:function(){for(var e=new Map,t=this.documents,r=0;r"string"!=typeof e)))return r.$eq}return!1}(this.collection.schema.primaryPath,t)}var t=e.prototype;return t._setResultData=function(e){if("number"!=typeof e){e instanceof Map&&(e=Array.from(e.values()));var t=new Wt(this.collection,e,e.length);this._result=t}else this._result=new Wt(this.collection,[],e)},t._execOverDatabase=async function(){if(this._execOverDatabaseCount=this._execOverDatabaseCount+1,this._lastExecStart=(0,ce.z)(),"count"===this.op){var e=this.getPreparedQuery(),t=await this.collection.storageInstance.count(e);if("slow"!==t.mode||this.collection.database.allowSlowCount)return t.count;throw I("QU14",{collection:this.collection,queryObj:this.mangoQuery})}if("findByIds"===this.op){var r=(0,le.Is)(this.mangoQuery.selector)[this.collection.schema.primaryPath].$in,a=new Map,n=[];if(r.forEach((e=>{var t=this.collection._docCache.getLatestDocumentDataIfExists(e);if(t){if(!t._deleted){var r=this.collection._docCache.getCachedRxDocument(t);a.set(e,r)}}else n.push(e)})),n.length>0)(await this.collection.storageInstance.findDocumentsById(n,!1)).forEach((e=>{var t=this.collection._docCache.getCachedRxDocument(e);a.set(t.primary,t)}));return a}var i=async function(e){var t=[],r=e.collection;if(e.isFindOneByIdQuery)if(Array.isArray(e.isFindOneByIdQuery)){var a=e.isFindOneByIdQuery;if(a=a.filter((r=>{var a=e.collection._docCache.getLatestDocumentDataIfExists(r);return!a||(a._deleted||t.push(a),!1)})),a.length>0){var n=await r.storageInstance.findDocumentsById(a,!1);(0,g.gu)(t,n)}}else{var i=e.isFindOneByIdQuery,s=e.collection._docCache.getLatestDocumentDataIfExists(i);if(!s){var o=await r.storageInstance.findDocumentsById([i],!1);o[0]&&(s=o[0])}s&&!s._deleted&&t.push(s)}else{var c=e.getPreparedQuery(),l=await r.storageInstance.query(c);t=l.documents}return t}(this);return i.then((e=>(this._lastExecEnd=(0,ce.z)(),e)))},t.exec=function(e){if(e&&"findOne"!==this.op)throw I("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Ut(this).then((()=>(0,Dt.z)(this.$))).then((t=>{if(!t&&e)throw I("QU10",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return t}))},t.toString=function(){var e=o({op:this.op,query:this.mangoQuery,other:this.other},!0),t=JSON.stringify(e);return this.toString=()=>t,t},t.getPreparedQuery=function(){var e={rxQuery:this,mangoQuery:Ee(this.collection.schema.jsonSchema,this.mangoQuery)};e.mangoQuery.selector._deleted={$eq:!1},e.mangoQuery.index&&e.mangoQuery.index.unshift("_deleted"),st("prePrepareQuery",e);var t=Kt(this.collection.schema.jsonSchema,e.mangoQuery);return this.getPreparedQuery=()=>t,t},t.doesDocumentDataMatch=function(e){return!e._deleted&&this.queryMatcher(e)},t.remove=function(){return this.exec().then((e=>Array.isArray(e)?Promise.all(e.map((e=>e.remove()))):e.remove()))},t.update=function(e){throw yt("update")},t.where=function(e){throw yt("query-builder")},t.sort=function(e){throw yt("query-builder")},t.skip=function(e){throw yt("query-builder")},t.limit=function(e){throw yt("query-builder")},(0,b.Z)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,ht.h)((e=>!e.isLocal)),(0,dt.O)(null),(0,It.z)((()=>Ut(this))),(0,ut.U)((()=>this._result)),(0,pt.d)(le.kv),(0,mt.x)(((e,t)=>!(!e||e.time!==(0,le.Is)(t).time))),(0,ht.h)((e=>!!e)),(0,ut.U)((e=>{var t=(0,le.Is)(e);return"count"===this.op?t.count:"findOne"===this.op?0===t.documents.length?null:t.documents[0]:"findByIds"===this.op?t.docsMap:t.documents.slice(0)})));this._$=(0,_t.T)(e,this.refCount$.pipe((0,ht.h)((()=>!1))))}return this._$}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return l(this,"queryMatcher",Se(0,Ee(this.collection.schema.jsonSchema,this.mangoQuery)))}},{key:"asRxQuery",get:function(){return this}}]),e}();function Qt(e,t,r,a){st("preCreateRxQuery",{op:e,queryObj:t,collection:r,other:a});var n,i,s=new Ft(e,t,r,a);return s=(n=s).collection._queryCache.getByQuery(n),i=r,Mt.has(i)||(Mt.add(i),(0,ft.Y3)().then((()=>(0,ft.C2)(200))).then((()=>{i.destroyed||i.cacheReplacementPolicy(i,i._queryCache),Mt.delete(i)}))),s}function Ht(e){var t=e.asRxQuery.collection._changeEventBuffer.counter;return e._latestChangeEvent>=t}function Ut(e){return e.collection.database.destroyed||Ht(e)?ft.kZ:(e._ensureEqualQueue=e._ensureEqualQueue.then((()=>function(e){if(e._lastEnsureEqual=(0,ce.z)(),e.collection.database.destroyed||Ht(e))return ft.kZ;var t=!1,r=!1;-1===e._latestChangeEvent&&(r=!0);if(!r){var a=e.asRxQuery.collection._changeEventBuffer.getFrom(e._latestChangeEvent+1);if(null===a)r=!0;else{e._latestChangeEvent=e.asRxQuery.collection._changeEventBuffer.counter;var n=e.asRxQuery.collection._changeEventBuffer.reduceByLastOfDoc(a);if("count"===e.op){var i=(0,le.Is)(e._result).count,s=i;n.forEach((t=>{var r=t.previousDocumentData&&e.doesDocumentDataMatch(t.previousDocumentData),a=e.doesDocumentDataMatch(t.documentData);!r&&a&&s++,r&&!a&&s--})),s!==i&&(t=!0,e._setResultData(s))}else{var o=St(e,n);o.runFullQueryAgain?r=!0:o.changed&&(t=!0,e._setResultData(o.newResults))}}}if(r)return e._execOverDatabase().then((r=>(e._latestChangeEvent=e.collection._changeEventBuffer.counter,"number"==typeof r?(e._result&&r===e._result.count||(t=!0,e._setResultData(r)),t):(e._result&&function(e,t,r){if(t.length!==r.length)return!1;for(var a=0,n=t.length;ae.data.name===n)),c=[];o.forEach((e=>{c.push({collectionName:e.data.name,schema:e.data.schema,isCollection:!0}),e.data.connectedStorages.forEach((e=>c.push({collectionName:e.collectionName,isCollection:!1,schema:e.schema})))}));var l=new Set;if(c=c.filter((e=>{var t=e.collectionName+"||"+e.schema.version;return!l.has(t)&&(l.add(t),!0)})),await Promise.all(c.map((async t=>{var s=await e.createStorageInstance({collectionName:t.collectionName,databaseInstanceToken:r,databaseName:a,multiInstance:!1,options:{},schema:t.schema,password:i,devMode:j.isDevMode()});await s.remove(),t.isCollection&&await ot("postRemoveRxCollection",{storage:e,databaseName:a,collectionName:n})}))),s){var u=o.map((e=>{var t=He(e);return t._deleted=!0,t._meta.lwt=(0,ce.z)(),t._rev=Me(r,e),{previous:e,document:t}}));await t.bulkWrite(u,"rx-database-remove-collection-all")}}var nr=function(){function e(e){this.subs=[],this.limit=100,this.counter=0,this.eventCounterMap=new WeakMap,this.buffer=[],this.collection=e,this.subs.push(this.collection.$.pipe((0,ht.h)((e=>!e.isLocal))).subscribe((e=>this._handleChangeEvent(e))))}var t=e.prototype;return t._handleChangeEvent=function(e){for(this.counter++,this.buffer.push(e),this.eventCounterMap.set(e,this.counter);this.buffer.length>this.limit;)this.buffer.shift()},t.getArrayIndexByPointer=function(e){var t=this.buffer[0],r=this.eventCounterMap.get(t);return et(e)))},t.reduceByLastOfDoc=function(e){return e.slice(0)},t.destroy=function(){this.subs.forEach((e=>e.unsubscribe()))},e}();var ir=new WeakMap;function sr(e){var t=e.schema.getDocumentPrototype(),r=function(e){var t={};return Object.entries(e.methods).forEach((e=>{let[r,a]=e;t[r]=a})),t}(e),a={};return[t,r,xt].forEach((e=>{Object.getOwnPropertyNames(e).forEach((t=>{var r=Object.getOwnPropertyDescriptor(e,t),n=!0;(t.startsWith("_")||t.endsWith("_")||t.startsWith("$")||t.endsWith("$"))&&(n=!1),"function"==typeof r.value?Object.defineProperty(a,t,{get(){return r.value.bind(this)},enumerable:n,configurable:!1}):(r.enumerable=n,r.configurable=!1,r.writable&&(r.writable=!1),Object.defineProperty(a,t,r))}))})),a}function or(e,t){var r=function(e,t,r){var a=new e(t,r);return st("createRxDocument",a),a}(function(e){return i(ir,e,(()=>wt(sr(e))))}(e),e,j.deepFreezeWhenDevMode(t));return e._runHooksSync("post","create",t,r),st("postCreateRxDocument",r),r}var cr=function(e,t){return nt(Qe(e.newDocumentState),Qe(e.realMasterState))?Promise.resolve({isEqual:!0}):Promise.resolve({isEqual:!1,documentData:e.realMasterState})};var lr=["pre","post"],ur=["insert","save","remove","create"],hr=!1,dr=function(){function e(e,t,r,a,n,i,s,o,c,l,u,h){void 0===n&&(n={}),void 0===i&&(i={}),void 0===s&&(s={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===l&&(l=qt),void 0===u&&(u={}),void 0===h&&(h=cr),this.storageInstance={},this.timeouts=new Set,this.incrementalWriteQueue={},this._incrementalUpsertQueues=new Map,this.synced=!1,this.hooks={},this._subs=[],this._docCache={},this._queryCache=new Ct,this.$={},this.checkpoint$={},this._changeEventBuffer={},this.onDestroy=[],this.destroyed=!1,this.database=e,this.name=t,this.schema=r,this.internalStorageInstance=a,this.instanceCreationOptions=n,this.migrationStrategies=i,this.methods=s,this.attachments=o,this.options=c,this.cacheReplacementPolicy=l,this.statics=u,this.conflictHandler=h,function(e){if(hr)return;hr=!0;var t=Object.getPrototypeOf(e);ur.forEach((e=>{lr.map((r=>{var a=r+N(e);t[a]=function(t,a){return this.addHook(r,e,t,a)}}))}))}(this.asRxCollection)}var t=e.prototype;return t.prepare=async function(){this.storageInstance=Ue(this.database,this.internalStorageInstance,this.schema.jsonSchema),this.incrementalWriteQueue=new gt(this.storageInstance,this.schema.primaryPath,((e,t)=>jt(this,e,t)),(e=>this._runHooks("post","save",e)));var e,t=this.database.eventBulks$.pipe((0,ht.h)((e=>e.collectionName===this.name)));this.$=t.pipe((0,It.z)((e=>e.events))),this.checkpoint$=t.pipe((0,ut.U)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new $t(this.schema.primaryPath,this.$.pipe((0,ht.h)((e=>!e.isLocal))),(e=>or(this.asRxCollection,e)));var r=await this.database.storageToken,a=this.storageInstance.changeStream().subscribe((e=>{var t={id:e.id,internal:!1,collectionName:this.name,storageToken:r,events:e.events.map((e=>We(!1,e,this))),databaseToken:this.database.token,checkpoint:e.checkpoint,context:e.context,endTime:e.endTime,startTime:e.startTime};this.database.$emit(t)}));return this._subs.push(a),this._subs.push(this.storageInstance.conflictResultionTasks().subscribe((e=>{this.conflictHandler(e.input,e.context).then((t=>{this.storageInstance.resolveConflictResultionTask({id:e.id,output:t})}))}))),ft.$Y},t.cleanup=function(e){throw yt("cleanup")},t.migrationNeeded=function(){throw yt("migration-schema")},t.getMigrationState=function(){throw yt("migration-schema")},t.startMigration=function(e){return void 0===e&&(e=10),this.getMigrationState().startMigration(e)},t.migratePromise=function(e){return void 0===e&&(e=10),this.getMigrationState().migratePromise(e)},t.insert=async function(e){var t=await this.bulkInsert([e]),r=t.error[0];return ze(this,e[this.schema.primaryPath],e,r),(0,le.Is)(t.success[0])},t.bulkInsert=async function(e){if(0===e.length)return{success:[],error:[]};var t=this.schema.primaryPath,r=e.map((e=>rr(this.schema,e))),a=this.hasHooks("pre","insert")?await Promise.all(r.map((e=>this._runHooks("pre","insert",e).then((()=>e))))):r,n=a.map((e=>({document:e}))),i=await this.storageInstance.bulkWrite(n,"rx-collection-bulk-insert"),s=Tt(this._docCache,i.success);if(this.hasHooks("post","insert")){var o=new Map;a.forEach((e=>{o.set(e[t],e)})),await Promise.all(s.map((e=>this._runHooks("post","insert",o.get(e.primary),e))))}return{success:s,error:i.error}},t.bulkRemove=async function(e){var t=this.schema.primaryPath;if(0===e.length)return{success:[],error:[]};var r=await this.findByIds(e).exec(),a=[],i=new Map;Array.from(r.values()).forEach((e=>{var t=e.toMutableJSON(!0);a.push(t),i.set(e.primary,t)})),await Promise.all(a.map((e=>{var t=e[this.schema.primaryPath];return this._runHooks("pre","remove",e,r.get(t))})));var o=a.map((e=>{var t=s(e);return t._deleted=!0,{previous:e,document:t}})),c=await this.storageInstance.bulkWrite(o,"rx-collection-bulk-remove"),l=c.success.map((e=>e[t]));return await Promise.all(l.map((e=>this._runHooks("post","remove",i.get(e),r.get(e))))),{success:l.map((e=>n(r,e))),error:c.error}},t.bulkUpsert=async function(e){var t=[],r=new Map;e.forEach((e=>{var a=rr(this.schema,e),n=a[this.schema.primaryPath];if(!n)throw I("COL3",{primaryPath:this.schema.primaryPath,data:a,schema:this.schema.jsonSchema});r.set(n,a),t.push(a)}));var a=await this.bulkInsert(t),i=a.success.slice(0),s=[];return await Promise.all(a.error.map((async e=>{if(409!==e.status)s.push(e);else{var t=e.documentId,a=n(r,t),o=(0,le.Is)(e.documentInDb),c=this._docCache.getCachedRxDocument(o),l=await c.incrementalModify((()=>a));i.push(l)}}))),{error:s,success:i}},t.upsert=async function(e){var t=await this.bulkUpsert([e]);return ze(this.asRxCollection,e[this.schema.primaryPath],e,t.error[0]),t.success[0]},t.incrementalUpsert=function(e){var t=rr(this.schema,e),r=t[this.schema.primaryPath];if(!r)throw I("COL4",{data:e});var a=this._incrementalUpsertQueues.get(r);return a||(a=ft.$Y),a=a.then((()=>function(e,t,r){var a=e._docCache.getLatestDocumentDataIfExists(t);if(a)return Promise.resolve({doc:e._docCache.getCachedRxDocument(a),inserted:!1});return e.findOne(t).exec().then((t=>t?{doc:t,inserted:!1}:e.insert(r).then((e=>({doc:e,inserted:!0})))))}(this,r,t))).then((e=>e.inserted?e.doc:function(e,t){return e.incrementalModify((e=>t))}(e.doc,t))),this._incrementalUpsertQueues.set(r,a),a},t.find=function(e){if("string"==typeof e)throw I("COL5",{queryObj:e});return e||(e={selector:{}}),Qt("find",e,this)},t.findOne=function(e){if("number"==typeof e||Array.isArray(e))throw R("COL6",{queryObj:e});var t;if("string"==typeof e)t=Qt("findOne",{selector:{[this.schema.primaryPath]:e},limit:1},this);else{if(e||(e={selector:{}}),e.limit)throw I("QU6");(e=s(e)).limit=1,t=Qt("findOne",e,this)}return t},t.count=function(e){return e||(e={selector:{}}),Qt("count",e,this)},t.findByIds=function(e){return Qt("findByIds",{selector:{[this.schema.primaryPath]:{$in:e.slice(0)}}},this)},t.exportJSON=function(){throw yt("json-dump")},t.importJSON=function(e){throw yt("json-dump")},t.insertCRDT=function(e){throw yt("crdt")},t.addHook=function(e,t,r,a){if(void 0===a&&(a=!1),"function"!=typeof r)throw R("COL7",{key:t,when:e});if(!lr.includes(e))throw R("COL8",{key:t,when:e});if(!ur.includes(t))throw I("COL9",{key:t});if("post"===e&&"create"===t&&!0===a)throw I("COL10",{when:e,key:t,parallel:a});var n=r.bind(this),i=a?"parallel":"series";this.hooks[t]=this.hooks[t]||{},this.hooks[t][e]=this.hooks[t][e]||{series:[],parallel:[]},this.hooks[t][e][i].push(n)},t.getHooks=function(e,t){return this.hooks[t]&&this.hooks[t][e]?this.hooks[t][e]:{series:[],parallel:[]}},t.hasHooks=function(e,t){var r=this.getHooks(e,t);return!!r&&(r.series.length>0||r.parallel.length>0)},t._runHooks=function(e,t,r,a){var n=this.getHooks(e,t);if(!n)return ft.$Y;var i=n.series.map((e=>()=>e(r,a)));return(0,ft.Ze)(i).then((()=>Promise.all(n.parallel.map((e=>e(r,a))))))},t._runHooksSync=function(e,t,r,a){var n=this.getHooks(e,t);n&&n.series.forEach((e=>e(r,a)))},t.promiseWait=function(e){return new Promise((t=>{var r=setTimeout((()=>{this.timeouts.delete(r),t()}),e);this.timeouts.add(r)}))},t.destroy=function(){return this.destroyed?ft.kZ:(this.destroyed=!0,Array.from(this.timeouts).forEach((e=>clearTimeout(e))),this._changeEventBuffer&&this._changeEventBuffer.destroy(),this.database.requestIdlePromise().then((()=>Promise.all(this.onDestroy.map((e=>e()))))).then((()=>this.storageInstance.close())).then((()=>(this._subs.forEach((e=>e.unsubscribe())),delete this.database.collections[this.name],ot("postDestroyRxCollection",this).then((()=>!0))))))},t.remove=async function(){await this.destroy(),await ar(this.database.storage,this.database.internalStore,this.database.token,this.database.name,this.name,this.database.password,this.database.hashFunction)},(0,b.Z)(e,[{key:"insert$",get:function(){return this.$.pipe((0,ht.h)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,ht.h)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,ht.h)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}]),e}();var mr=r(7782),pr=r(6753);var fr="undefined"!=typeof crypto&&void 0!==crypto.subtle&&"function"==typeof crypto.subtle.digest?async function(e){var t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.prototype.map.call(new Uint8Array(r),(e=>("00"+e.toString(16)).slice(-2))).join("")}:function(e){return Promise.resolve((0,pr.JQ)(e))},yr=r(5898),vr=new Set,gr=function(){function e(e,t,r,a,n,i,s,o,c,l,u,h){void 0===s&&(s=!1),void 0===o&&(o={}),this.idleQueue=new mr.F,this.rxdbVersion=rt,this.storageInstances=new Set,this._subs=[],this.startupErrors=[],this.onDestroy=[],this.destroyed=!1,this.collections={},this.eventBulks$=new oe.x,this.observable$=this.eventBulks$.pipe((0,It.z)((e=>e.events))),this.storageToken=ft.kZ,this.storageTokenDocument=ft.kZ,this.emittedEventBulkIds=new yr.i(6e4),this.name=e,this.token=t,this.storage=r,this.instanceCreationOptions=a,this.password=n,this.multiInstance=i,this.eventReduce=s,this.options=o,this.internalStore=c,this.hashFunction=l,this.cleanupPolicy=u,this.allowSlowCount=h,"pseudoInstance"!==this.name&&(this.internalStore=Ue(this.asRxDatabase,c,Jt),this.storageTokenDocument=async function(e){var t=O(10),r=e.password?await e.hashFunction(JSON.stringify(e.password)):void 0,a={id:er,context:Vt,key:Xt,data:{rxdbVersion:e.rxdbVersion,token:t,instanceToken:e.token,passwordHash:r},_deleted:!1,_meta:q(),_rev:"",_attachments:{}},n=await e.internalStore.bulkWrite([{document:a}],"internal-add-storage-token");if(n.success[0])return n.success[0];var i=(0,le.Is)(n.error[0]);if(i.isError&&E(i)){var s=i;if(c=s.documentInDb.data.rxdbVersion,l=e.rxdbVersion,!c||l.includes("beta")&&l!==c||c.split(".")[0]!==l.split(".")[0])throw I("DM5",{args:{database:e.name,databaseStateVersion:s.documentInDb.data.rxdbVersion,codeVersion:e.rxdbVersion}});if(r&&r!==s.documentInDb.data.passwordHash)throw I("DB1",{passwordHash:r,existingPasswordHash:s.documentInDb.data.passwordHash});var o=s.documentInDb;return(0,le.Is)(o)}var c,l;throw i}(this.asRxDatabase).catch((e=>this.startupErrors.push(e))),this.storageToken=this.storageTokenDocument.then((e=>e.data.token)).catch((e=>this.startupErrors.push(e))))}var t=e.prototype;return t.$emit=function(e){this.emittedEventBulkIds.has(e.id)||(this.emittedEventBulkIds.add(e.id),this.eventBulks$.next(e))},t.removeCollectionDoc=async function(e,t){var r=await Te(this.internalStore,Gt(tr(e,t),Zt));if(!r)throw I("SNH",{name:e,schema:t});var a=He(r);a._deleted=!0,await this.internalStore.bulkWrite([{document:a,previous:r}],"rx-database-remove-collection")},t.addCollections=async function(e){var t={},r={},a=[],n={};await Promise.all(Object.entries(e).map((async e=>{let[i,o]=e;var c=i,l=o.schema;t[c]=l;var u=lt(l,this.hashFunction);if(r[c]=u,this.collections[i])throw I("DB3",{name:i});var h=tr(i,l),d={id:Gt(h,Zt),key:h,context:Zt,data:{name:c,schemaHash:await u.hash,schema:u.jsonSchema,version:u.version,connectedStorages:[]},_deleted:!1,_meta:q(),_rev:"",_attachments:{}};a.push({document:d});var m=Object.assign({},o,{name:c,schema:u,database:this}),p=s(o);p.database=this,p.name=i,st("preCreateRxCollection",p),m.conflictHandler=p.conflictHandler,n[c]=m})));var i=await this.internalStore.bulkWrite(a,"rx-database-add-collection");await async function(e){if(await e.storageToken,e.startupErrors[0])throw e.startupErrors[0]}(this),await Promise.all(i.error.map((async e=>{if(409!==e.status)throw I("DB12",{database:this.name,writeError:e});var a=(0,le.Is)(e.documentInDb),n=a.data.name,i=r[n];if(a.data.schemaHash!==await i.hash)throw I("DB6",{database:this.name,collection:n,previousSchemaHash:a.data.schemaHash,schemaHash:await i.hash,previousSchema:a.data.schema,schema:(0,le.Is)(t[n])})})));var o={};return await Promise.all(Object.keys(e).map((async e=>{var t=n[e],r=await function(e){let{database:t,name:r,schema:a,instanceCreationOptions:n={},migrationStrategies:i={},autoMigrate:s=!0,statics:o={},methods:c={},attachments:l={},options:u={},localDocuments:h=!1,cacheReplacementPolicy:d=qt,conflictHandler:m=cr}=e;var p={databaseInstanceToken:t.token,databaseName:t.name,collectionName:r,schema:a.jsonSchema,options:n,multiInstance:t.multiInstance,password:t.password,devMode:j.isDevMode()};return st("preCreateRxStorageInstance",p),async function(e,t){return t.multiInstance=e.multiInstance,await e.storage.createStorageInstance(t)}(t,p).then((e=>{var p=new dr(t,r,a,e,n,i,c,l,u,d,o,m);return p.prepare().then((()=>{Object.entries(o).forEach((e=>{let[t,r]=e;Object.defineProperty(p,t,{get:()=>r.bind(p)})}));var e=ft.$Y;return s&&0!==p.schema.version&&(e=p.migratePromise()),e})).then((()=>(st("createRxCollection",{collection:p,creator:{name:r,schema:a,storageInstance:e,instanceCreationOptions:n,migrationStrategies:i,methods:c,attachments:l,options:u,cacheReplacementPolicy:d,localDocuments:h,statics:o}}),p))).catch((t=>e.close().then((()=>Promise.reject(t)))))}))}(t);o[e]=r,this.collections[e]=r,this[e]||Object.defineProperty(this,e,{get:()=>this.collections[e]})}))),o},t.lockedRun=function(e){return this.idleQueue.wrapCall(e)},t.requestIdlePromise=function(){return this.idleQueue.requestIdlePromise()},t.exportJSON=function(e){throw yt("json-dump")},t.importJSON=function(e){throw yt("json-dump")},t.backup=function(e){throw yt("backup")},t.leaderElector=function(){throw yt("leader-election")},t.isLeader=function(){throw yt("leader-election")},t.waitForLeadership=function(){throw yt("leader-election")},t.migrationStates=function(){throw yt("migration-schema")},t.destroy=async function(){return this.destroyed?ft.kZ:(this.destroyed=!0,await ot("preDestroyRxDatabase",this),this.eventBulks$.complete(),this._subs.map((e=>e.unsubscribe())),"pseudoInstance"===this.name?ft.kZ:this.requestIdlePromise().then((()=>Promise.all(this.onDestroy.map((e=>e()))))).then((()=>Promise.all(Object.keys(this.collections).map((e=>this.collections[e])).map((e=>e.destroy()))))).then((()=>this.internalStore.close())).then((()=>vr.delete(this.name))).then((()=>!0)))},t.remove=function(){return this.destroy().then((()=>async function(e,t,r){var a=O(10),n=await br(a,t,e,{},!1,r),i=await Yt(n),s=new Set;i.forEach((e=>s.add(e.data.name)));var o=Array.from(s);return await Promise.all(o.map((i=>ar(t,n,a,e,i,r)))),await ot("postRemoveRxDatabase",{databaseName:e,storage:t}),await n.remove(),o}(this.name,this.storage,this.password)))},(0,b.Z)(e,[{key:"$",get:function(){return this.observable$}},{key:"asRxDatabase",get:function(){return this}}]),e}();async function br(e,t,r,a,n,i){return await t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:$e,schema:Jt,options:a,multiInstance:n,password:i,devMode:j.isDevMode()})}function xr(e){let{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i=!0,eventReduce:s=!0,ignoreDuplicate:o=!1,options:c={},cleanupPolicy:l,allowSlowCount:u=!1,localDocuments:h=!1,hashFunction:d=fr}=e;st("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:h}),o||function(e){if(vr.has(e))throw I("DB8",{name:e,link:"https://pubkey.github.io/rxdb/rx-database.html#ignoreduplicate"})}(a),vr.add(a);var m=O(10);return br(m,t,a,r,i,n).catch((e=>{throw vr.delete(a),e})).then((e=>{var p=new gr(a,m,t,r,n,i,s,c,e,d,l,u);return ot("createRxDatabase",{database:p,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:h}}).then((()=>p))}))}var wr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Ft.prototype,RxCollection:dr.prototype,RxDatabase:gr.prototype},jr=new Set,kr=new Set;var Dr=function(e){function t(t,r,a){var n;return(n=e.call(this,null,r)||this).id=t,n.parent=a,n}return(0,x.Z)(t,e),t}(wt()),_r={get isLocal(){return!0},get allAttachments$(){throw I("LD1",{document:this})},get primaryPath(){return"id"},get primary(){return this.id},get $(){var e=n(Pr,this.parent);return this.parent.$.pipe((0,ht.h)((e=>e.documentId===this.primary)),(0,ht.h)((e=>e.isLocal)),(0,ut.U)((e=>vt(e))),(0,dt.O)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.x)(((e,t)=>e._rev===t._rev)),(0,ut.U)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.d)(le.kv))},getLatest(){var e=n(Pr,this.parent),t=e.docCache.getLatestDocumentData(this.primary);return e.docCache.getCachedRxDocument(t)},get(e){if(e="data."+e,this._data){if("string"!=typeof e)throw R("LD2",{objPath:e});var t=y(this._data,e);return t=j.deepFreezeWhenDevMode(t)}},get$(e){if(e="data."+e,j.isDevMode()){if(e.includes(".item."))throw I("LD3",{objPath:e});if(e===this.primaryPath)throw I("LD4")}return this.$.pipe((0,ut.U)((e=>e._data)),(0,ut.U)((t=>y(t,e))),(0,mt.x)())},async incrementalModify(e){var t=await Cr(this.parent);return t.incrementalWriteQueue.addWrite(this._data,(async t=>(t.data=await e(t.data,this),t))).then((e=>t.docCache.getCachedRxDocument(e)))},incrementalPatch(e){return this.incrementalModify((t=>(Object.entries(e).forEach((e=>{let[r,a]=e;t[r]=a})),t)))},async _saveData(e){var t=await Cr(this.parent),r=this._data;return e.id=this.id,t.storageInstance.bulkWrite([{previous:r,document:e}],"local-document-save-data").then((t=>{var r=t.success[0];if(!r)throw t.error[0];(e=s(e))._rev=r._rev}))},async remove(){var e=await Cr(this.parent),t={id:this._data.id,data:{},_deleted:!0,_meta:q(),_rev:"",_attachments:{}};return Le(e.storageInstance,{previous:this._data,document:t},"local-document-remove").then((t=>e.docCache.getCachedRxDocument(t)))}},Ir=!1,Rr=()=>{if(!Ir){Ir=!0;var e=xt;Object.getOwnPropertyNames(e).forEach((t=>{if(!Object.getOwnPropertyDescriptor(_r,t)){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(_r,t,r)}}));["populate","update","putAttachment","getAttachment","allAttachments"].forEach((e=>_r[e]=(e=>()=>{throw I("LD6",{functionName:e})})(e)))}};var Er=new WeakMap,Pr=new WeakMap;function Sr(e){var t=e.database?e.database:e,r=e.database?e.name:"",a=(async()=>{var a=await Or(t.token,t.storage,t.name,r,t.instanceCreationOptions,t.multiInstance);a=Ue(t,a,qr);var n=new $t("id",e.$.pipe((0,ht.h)((e=>e.isLocal))),(t=>function(e,t){Rr();var r=new Dr(e.id,e,t);return Object.setPrototypeOf(r,_r),r.prototype=_r,r}(t,e))),i=new gt(a,"id",(()=>{}),(()=>{})),s=await t.storageToken,o=a.changeStream().subscribe((r=>{var a={id:r.id,internal:!1,collectionName:e.database?e.name:void 0,storageToken:s,events:r.events.map((t=>We(!0,t,e.database?e:void 0))),databaseToken:t.token,checkpoint:r.checkpoint,context:r.context,endTime:r.endTime,startTime:r.startTime};t.$emit(a)}));e._subs.push(o);var c={database:t,parent:e,storageInstance:a,docCache:n,incrementalWriteQueue:i};return Pr.set(e,c),c})();Er.set(e,a)}function Cr(e){var t=Er.get(e);if(!t){var r=e.database?e.database:e,a=e.database?e.name:"";throw I("LD8",{database:r.name,collection:a})}return t}function Or(e,t,r,a,n,i){return t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:Ar(a),schema:qr,options:n,multiInstance:i,devMode:j.isDevMode()})}function Nr(e){var t=Er.get(e);if(t)return Er.delete(e),t.then((e=>e.storageInstance.close()))}async function Br(e,t,r){var a=O(10),n=await Or(a,e,t,r,{},!1);await n.remove()}function Ar(e){return"plugin-local-documents-"+e}var qr=W({title:"RxLocalDocument",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:128},data:{type:"object",additionalProperties:!0}},required:["id","data"]});async function Mr(e,t){var r=await Cr(this),a={id:e,data:t,_deleted:!1,_meta:q(),_rev:"",_attachments:{}};return Le(r.storageInstance,{document:a},"local-document-insert").then((e=>r.docCache.getCachedRxDocument(e)))}function $r(e,t){return this.getLocal(e).then((r=>r?r.incrementalModify((()=>t)):this.insertLocal(e,t)))}async function Tr(e){var t=await Cr(this),r=t.docCache,a=r.getLatestDocumentDataIfExists(e);return a?Promise.resolve(r.getCachedRxDocument(a)):Te(t.storageInstance,e).then((e=>e?t.docCache.getCachedRxDocument(e):null))}function Lr(e){return this.$.pipe((0,dt.O)(null),(0,It.z)((async t=>t?{changeEvent:t}:{doc:await this.getLocal(e)})),(0,It.z)((async t=>{if(t.changeEvent){var r=t.changeEvent;return r.isLocal&&r.documentId===e?{use:!0,doc:await this.getLocal(e)}:{use:!1}}return{use:!0,doc:t.doc}})),(0,ht.h)((e=>e.use)),(0,ut.U)((e=>e.doc)))}var Wr={name:"local-documents",rxdb:!0,prototypes:{RxCollection:e=>{e.insertLocal=Mr,e.upsertLocal=$r,e.getLocal=Tr,e.getLocal$=Lr},RxDatabase:e=>{e.insertLocal=Mr,e.upsertLocal=$r,e.getLocal=Tr,e.getLocal$=Lr}},hooks:{createRxDatabase:{before:e=>{e.creator.localDocuments&&Sr(e.database)}},createRxCollection:{before:e=>{e.creator.localDocuments&&Sr(e.collection)}},preDestroyRxDatabase:{after:e=>Nr(e)},postDestroyRxCollection:{after:e=>Nr(e)},postRemoveRxDatabase:{after:e=>Br(e.storage,e.databaseName,"")},postRemoveRxCollection:{after:e=>Br(e.storage,e.databaseName,e.collectionName)}},overwritable:{}};let zr;function Fr(){return"undefined"!=typeof window&&window.indexedDB}function Qr(){return zr||(zr=(async()=>{!function(e){if(st("preAddRxPlugin",{plugin:e,plugins:jr}),!jr.has(e)){if(kr.has(e.name))throw I("PL3",{name:e.name,plugin:e});if(jr.add(e),kr.add(e.name),!e.rxdb)throw R("PL1",{plugin:e});e.init&&e.init(),e.prototypes&&Object.entries(e.prototypes).forEach((e=>{let[t,r]=e;return r(wr[t])})),e.overwritable&&Object.assign(j,e.overwritable),e.hooks&&Object.entries(e.hooks).forEach((e=>{let[t,r]=e;r.after&&it[t].push(r.after),r.before&&it[t].unshift(r.before)}))}}(Wr);var e;return await xr({name:"rxdb-landing-v3",localDocuments:!0,storage:(void 0===e&&(e={}),new at(e))})})()),zr}const Hr=["#e6008d","#8d2089","#5f2688"]},341:(e,t,r)=>{function a(e,t){if(!window.trigger)throw new Error("window.trigger not defined");return window.trigger(e,t)}r.d(t,{X:()=>a})},6451:(e,t,r)=>{r.r(t),r.d(t,{default:()=>g});var a=r(2263),n=r(3799),i=r(5742),s=r(7294),o=r(7400),c=r(6087);const l=[{name:"Antigua and Barbuda",code:"AG",salary:49527},{name:"Argentina",code:"AR",salary:17158},{name:"Australia",code:"AU",salary:76036},{name:"Austria",code:"AT",salary:59383},{name:"Bahamas",code:"BS",salary:62024},{name:"Belarus",code:"BY",salary:5749},{name:"Belgium",code:"BE",salary:63749},{name:"Bermuda",code:"BM",salary:86590},{name:"Bosnia and Herzegovina",code:"BA",salary:11992},{name:"Brazil",code:"BR",salary:26464},{name:"Bulgaria",code:"BG",salary:23384},{name:"Cambodia",code:"KH",salary:18e3},{name:"Canada",code:"CA",salary:71554},{name:"Chile",code:"CL",salary:31073},{name:"China",code:"CN",salary:40611},{name:"Colombia",code:"CO",salary:12894},{name:"Costa Rica",code:"CR",salary:40256},{name:"Croatia",code:"HR",salary:22566},{name:"Czech Republic",code:"CZ",salary:33760},{name:"Denmark",code:"DK",salary:68778},{name:"Ecuador",code:"EC",salary:35016},{name:"Egypt",code:"EG",salary:7758},{name:"Estonia",code:"EE",salary:26728},{name:"Finland",code:"FI",salary:64198},{name:"France",code:"FR",salary:58137},{name:"Georgia",code:"GE",salary:40315},{name:"Germany",code:"DE",salary:72138},{name:"Greece",code:"GR",salary:36824},{name:"Guatemala",code:"GT",salary:49612},{name:"Holy See (Vatican City State)",code:"VA",salary:51474},{name:"Hong Kong",code:"HK",salary:71970},{name:"Hungary",code:"HU",salary:22341},{name:"Iceland",code:"IS",salary:66512},{name:"India",code:"IN",salary:17710},{name:"Indonesia",code:"ID",salary:20978},{name:"Iraq",code:"IQ",salary:21029},{name:"Ireland",code:"IE",salary:66281},{name:"Israel",code:"IL",salary:57466},{name:"Italy",code:"IT",salary:50900},{name:"Jamaica",code:"JM",salary:21048},{name:"Japan",code:"JP",salary:57793},{name:"Kazakhstan",code:"KZ",salary:12243},{name:"Korea, Republic of",code:"KR",salary:45957},{name:"Latvia",code:"LV",salary:26728},{name:"Luxembourg",code:"LU",salary:84663},{name:"Malaysia",code:"MY",salary:26117},{name:"Malta",code:"MT",salary:41971},{name:"Mexico",code:"MX",salary:24050},{name:"Morocco",code:"MA",salary:17903},{name:"Netherlands",code:"NL",salary:62661},{name:"New Zealand",code:"NZ",salary:63948},{name:"Norway",code:"NO",salary:69498},{name:"Pakistan",code:"PK",salary:9066},{name:"Panama",code:"PA",salary:39143},{name:"Peru",code:"PE",salary:17469},{name:"Philippines",code:"PH",salary:11088},{name:"Poland",code:"PL",salary:30236},{name:"Portugal",code:"PT",salary:37959},{name:"Romania",code:"RO",salary:22319},{name:"Russian Federation",code:"RU",salary:20492},{name:"Saudi Arabia",code:"SA",salary:47336},{name:"Singapore",code:"SG",salary:66023},{name:"Slovakia",code:"SK",salary:29650},{name:"South Africa",code:"ZA",salary:40336},{name:"Spain",code:"ES",salary:47819},{name:"Sweden",code:"SE",salary:49361},{name:"Switzerland",code:"CH",salary:92820},{name:"Taiwan",code:"TW",salary:47737},{name:"Thailand",code:"TH",salary:21772},{name:"Turkey",code:"TR",salary:8788},{name:"Ukraine",code:"UA",salary:14139},{name:"United Arab Emirates",code:"AE",salary:66381},{name:"United Kingdom",code:"GB",salary:61188},{name:"United States",code:"US",salary:91935},{name:"Uruguay",code:"UY",salary:23754},{name:"Vietnam",code:"VN",salary:19058}],u={browser:.4,native:.4,performance:.35,sourcecode:0,perpetual:0},h=.05;var d=r(341),m=r(5921),p=r(2389),f=r(5893);function y(e){let{children:t,fallback:r}=e;return(0,p.Z)()?(0,f.jsx)(f.Fragment,{children:t?.()}):r??null}const v="premium-price-form-value";function g(){const{siteConfig:e}=(0,a.Z)(),t=(0,p.Z)();return(0,s.useEffect)((()=>{(async()=>{if(!t||!(0,m.dZ)())return;const e=await(0,m.N8)(),r=await e.getLocal(v);r&&(console.log("formValueDoc:"),console.dir(r),b("home-country",r._data.data.homeCountry),b("company-size",r._data.data.companySize),b("project-amount",r._data.data.projectAmount),b("license-period",r._data.data.licensePeriod),Object.keys(u).forEach((e=>{b("package-"+e,!1)})),r._data.data.packages.forEach((e=>{b("package-"+e,!0)})))})()})),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(i.Z,{children:(0,f.jsx)("body",{className:"homepage"})}),(0,f.jsx)(n.Z,{title:`Premium Plugins - ${e.title}`,description:"RxDB plugins for professionals. FAQ, pricing and license",children:(0,f.jsxs)("main",{children:[(0,f.jsx)("div",{className:"block first",children:(0,f.jsxs)("div",{className:"content centered",children:[(0,f.jsxs)("h2",{children:["\ud83d\udc51 ",(0,f.jsx)("b",{className:"underline",children:"RxDB"})," Premium Plugins"]}),(0,f.jsxs)("p",{style:{width:"80%"},children:["To make RxDB a sustainable project, some plugins are not part of the RxDB open source project. Instead they are part of the"," ",(0,f.jsx)("b",{children:"rxdb-premium"})," package which must be purchased.",(0,f.jsx)("br",{}),"Professional developers use these to get the best ",(0,f.jsx)("b",{children:"performance"})," and the most out of RxDB."]}),(0,f.jsxs)("div",{className:"premium-blocks",children:[(0,f.jsx)("a",{href:"/rx-storage-opfs.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-right-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage OPFS"}),(0,f.jsxs)("p",{children:["Currently the fastest RxStorage that can be used in the browser. Based on the ",(0,f.jsx)("b",{children:"File System Access API"}),"."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-indexeddb.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage IndexedDB"}),(0,f.jsxs)("p",{children:["A really fast storage based on ",(0,f.jsx)("b",{children:"IndexedDB"}),". Made to be used in browsers."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-sqlite.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-right-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage SQLite"}),(0,f.jsxs)("p",{children:["A really fast storage based on ",(0,f.jsx)("b",{children:"SQLite"}),". Used with"," ",(0,f.jsx)("b",{children:"Node.js"}),", ",(0,f.jsx)("b",{children:"Electron"}),", ",(0,f.jsx)("b",{children:"React Native"}),", ",(0,f.jsx)("b",{children:"Capacitor"}),"."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-sharding.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage Sharding"}),(0,f.jsx)("p",{children:"A wrapper around any other storage that improves performance by applying the sharding technique."})]})})}),(0,f.jsx)("a",{href:"/rx-storage-memory-synced.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage Memory Synced"}),(0,f.jsx)("p",{children:"A wrapper around any other storage that creates a synced in-memory copy which improves performance for the initial page load time and write & read operations."})]})})}),(0,f.jsx)("a",{href:"/query-optimizer.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-right-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"Query Optimizer"}),(0,f.jsx)("p",{children:"A tool to find the best index for a given query. You can use this during build time to find the best index and then use that index during runtime."})]})})}),(0,f.jsx)("a",{href:"/rx-storage-localstorage-meta-optimizer.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage Localstorage Meta Optimizer"}),(0,f.jsxs)("p",{children:["A wrapper around any other storage which optimizes the initial page load one by using localstorage for meta key-value document. Only works in ",(0,f.jsx)("b",{children:"browsers"}),"."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-shared-worker.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-right-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage SharedWorker"}),(0,f.jsxs)("p",{children:["A RxStorage wrapper to run the storage inside of a SharedWorker which improves the performance by taking CPU load away from the main process. Used in ",(0,f.jsx)("b",{children:"browsers"}),"."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-worker.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage Worker"}),(0,f.jsx)("p",{children:"A RxStorage wrapper to run the storage inside of a Worker which improves the performance by taking CPU load away from the main process."})]})})}),(0,f.jsx)("a",{href:"/encryption.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-right-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"WebCrypto Encryption"}),(0,f.jsx)("p",{children:"A faster and more secure encryption plugin based on the Web Crypto API."})]})})}),(0,f.jsx)("a",{href:"/rx-storage-filesystem-node.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage Filesystem Node"}),(0,f.jsxs)("p",{children:["A fast RxStorage based on the ",(0,f.jsx)("b",{children:"Node.js"})," Filesystem."]})]})})}),(0,f.jsx)("a",{href:"/logger.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-right-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"Logger"}),(0,f.jsx)("p",{children:"A logging plugin useful to debug performance problems and for monitoring with Application Performance Monitoring (APM) tools like Bugsnag, Datadog, Elastic, Sentry and others"})]})})})]})]})}),(0,f.jsx)("div",{className:"block dark",id:"faq",children:(0,f.jsxs)("div",{className:"content centered premium-faq",children:[(0,f.jsxs)("h2",{children:["F.A.Q. ",(0,f.jsx)("b",{children:"(click to toggle)"})]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Do I need the Premium Plugins?"}),"When you start using RxDB, you do not need access to the premium plugins. Most use cases can be implemented with the Open Core part of RxDB. There are many"," ",(0,f.jsx)("a",{href:"/rx-storage.html",target:"_blank",children:"RxStorage"}),"options and all core plugins that are required for replication, schema validation, encryption and so on, are totally free. As soon as your application is more then a side project, it is pretty easy to switch to RxDB Premium Plugins by just changing a few lines of configuration.",(0,f.jsx)("br",{}),"The main benefit of the Premium Plugins is ",(0,f.jsx)("b",{children:"performance"}),". The Premium RxStorage implementations have a better performance so reading and writing data is much faster especially on low-end devices. You can find a performance comparison"," ",(0,f.jsx)("a",{href:"/rx-storage-performance.html",target:"_blank",children:"here"}),". Also there are additional Premium Plugins that can be used to further optimize the performance of your application like the"," ",(0,f.jsx)("a",{href:"/query-optimizer.html",target:"_blank",children:"Query Optimizer"})," ","or the"," ",(0,f.jsx)("a",{href:"/rx-storage-sharding.html",target:"_blank",children:"Sharding"})," ","plugin."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Why is it not for free?"}),"The development of RxDB started in 2016 and after all these years it became clear that big implementation and improvement steps will not be done by the RxDB community. While the community submits valuable pull requests, they are mostly small improvements or bugfixes for specific edge case. Big rewrites and optimizations that require a big effort have only be done by the RxDB maintainer.",(0,f.jsx)("br",{}),"Selling RxDB Premium ensures that there will be always an incentive for someone to add features, keep everything up to date and to further improve and optimize the codebase. This gives the user the confidence that RxDB is a ",(0,f.jsx)("b",{children:"future proof"})," tech stack to build on which lets RxDB stand out compared to similar technologies."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Why is there no free trial period?"}),(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:"RxDB is written in JavaScript and the code of the Premium Plugins does not contain any tracking or measurement code that would send information from your application to our servers in production mode. As soon as someone has the code on his computer, the maintainer has no chance to really ensure that after a free trial period the code is no longer used and deleted."}),(0,f.jsxs)("li",{children:["Before you can use the Premium Plugins you have to debate and sign a license agreement with the maintainer. This is a sophisticated process that creates overhead which distracts the maintainer from writing RxDB code. So handling trial period users is just not manageable. For this reason there is also no monthly subscriptions. Premium access must be paid ",(0,f.jsx)("b",{children:"per year"}),"."]})]})]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Why is it not cheaper?"}),"The price of the Premium Plugins is chosen in way that ensures that there can be always one person that develops RxDB ",(0,f.jsx)("b",{children:"full time"}),". Compared to other JavaScript frameworks and developer tools, RxDB satisfies an edge use case for people that want to store data inside of their application on the users device. Most web developers do not need to do that and rely on the traditional client-server stack. So RxDB cannot be sold to that many people which increases the price."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Can I install/build the premium plugins in my CI?"}),(0,f.jsx)("b",{children:"Yes"})," you can safely install and use the Premium Plugins in your CI without additional payment."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Can I get a discount?"}),"Discounts are provided for people that have made a significant contribution to RxDB or one of RxDB's dependencies or to the Open Source Community overall. Also for private personal projects there is the option to solve one of the",(0,f.jsx)("a",{href:"https://github.com/pubkey/rxdb/blob/master/orga/premium-tasks.md",target:"_blank",children:"Premium Tasks"}),"to get 3 years access to the Premium Plugins."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Which payment methods are accepted?"}),(0,f.jsx)("b",{children:"Stripe.com"})," is used as payment processor so most known payment options like credit card, PayPal, SEPA transfer and others are available. A list of all options can be found"," ",(0,f.jsx)("a",{href:"https://stripe.com/docs/payments/payment-methods/overview",title:"stripe payment options",target:"_blank",children:"here"}),"."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Can I still use the premium plugins when the license has expired?"}),"By default you are not allowed to use the premium plugins after the license has expired and you will no longer be able to install them. But you can choose the ",(0,f.jsx)("b",{children:"Perpetual license"})," option. With the perpetual license option, you can still use the plugins even after the license is expired. But you will no longer get any updates from newer RxDB versions."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Is there any tracking code inside of the premium plugins?"}),'No, the premium plugins themself do not contain any tracking code. When you build your application with RxDB and deploy it to production, it will not make requests to any RxDB server. But when you run "npm install" with the premium package there will be some metadata send from your developers machine to RxDB.']})]})}),(0,f.jsxs)("div",{className:"block",children:[(0,f.jsxs)("div",{className:"content centered",children:[(0,f.jsxs)("h2",{children:["RxDB Premium ",(0,f.jsx)("b",{className:"underline",children:"Price Calculator"})]}),(0,f.jsx)("div",{className:"price-calculator",children:(0,f.jsxs)("div",{className:"price-calculator-inner",children:[(0,f.jsxs)("form",{id:"price-calculator-form",children:[(0,f.jsxs)("div",{className:"field",children:[(0,f.jsx)("label",{htmlFor:"home-country",children:"Company Home Country:"}),(0,f.jsxs)("div",{className:"input",children:[(0,f.jsx)("input",{list:"home-country",name:"home-country",pattern:"[A-Za-z \\-]{2,}",required:!0,style:{width:"100%",maxWidth:240},autoComplete:"off"}),(0,f.jsx)("datalist",{id:"home-country",children:l.sort(((e,t)=>e.code>=t.code?1:-1)).map(((e,t)=>(0,f.jsx)("option",{value:e.name,children:e.name},t)))})]})]}),(0,f.jsxs)("div",{className:"field",children:[(0,f.jsx)("label",{htmlFor:"company-size",children:"Company Size:"}),(0,f.jsxs)("div",{className:"input",children:[(0,f.jsx)("input",{type:"number",name:"company-size",min:1,max:1e6,required:!0,onKeyDown:()=>{const e=(0,o.Is)(event);return 69!==e.keyCode&&189!==e.keyCode&&190!==e.keyCode}}),(0,f.jsx)("div",{className:"suffix",children:"employee(s)"})]})]}),(0,f.jsxs)("div",{className:"field",children:[(0,f.jsx)("label",{htmlFor:"project-amount",children:"Project Amount:"}),(0,f.jsxs)("div",{className:"input",children:[(0,f.jsxs)("select",{name:"project-amount",id:"project-amount",required:!0,defaultValue:1,children:[(0,f.jsx)("option",{value:1,children:"1"}),(0,f.jsx)("option",{value:2,children:"2"}),(0,f.jsx)("option",{value:"infinity",children:"Infinity"})]}),(0,f.jsx)("div",{className:"suffix",children:"project(s)"})]})]}),(0,f.jsxs)("div",{className:"packages",children:[(0,f.jsx)("h3",{children:"Packages:"}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("input",{name:"package-browser",type:"checkbox",className:"package-checkbox",defaultChecked:!0}),(0,f.jsx)("h4",{children:"Browser Package"}),(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-opfs.html",target:"_blank",children:"RxStorage OPFS"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-indexeddb.html",target:"_blank",children:"RxStorage IndexedDB"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-worker.html",target:"_blank",children:"RxStorage Worker"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/encryption.html",target:"_blank",children:"WebCrypto Encryption"})})]})]})}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("input",{name:"package-native",type:"checkbox",className:"package-checkbox",defaultChecked:!0}),(0,f.jsx)("h4",{children:"Native Package"}),(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-sqlite.html",target:"_blank",children:"RxStorage SQLite"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-filesystem-node.html",target:"_blank",children:"RxStorage Filesystem Node"})})]})]})}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("input",{name:"package-performance",type:"checkbox",className:"package-checkbox",defaultChecked:!0}),(0,f.jsx)("h4",{children:"Performance Package"}),(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-sharding.html",target:"_blank",children:"RxStorage Sharding"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-memory-synced.html",target:"_blank",children:"RxStorage Memory Synced"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/query-optimizer.html",target:"_blank",children:"Query Optimizer"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-localstorage-meta-optimizer.html",target:"_blank",children:"RxStorage Localstorage Meta Optimizer"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-shared-worker.html",target:"_blank",children:"RxStorage Shared Worker"})})]})]})}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("input",{name:"package-utilities",type:"checkbox",className:"package-checkbox",defaultChecked:!0,disabled:!0}),(0,f.jsxs)("h4",{children:["Utilities Package ",(0,f.jsx)("b",{children:"always included"})]}),(0,f.jsx)("ul",{children:(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/logger.html",target:"_blank",children:"Logger"})})})]})}),(0,f.jsx)("div",{className:"clear"}),(0,f.jsx)("h3",{children:"Other Options:"}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("input",{name:"package-sourcecode",type:"checkbox",className:"package-checkbox"}),(0,f.jsx)("h4",{children:"Source Code access"}),(0,f.jsxs)("p",{children:["Get read access to the unminified plain source code of all purchased packages.",(0,f.jsx)("br",{})]})]})}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("input",{name:"package-perpetual",type:"checkbox",className:"package-checkbox"}),(0,f.jsx)("h4",{children:"Perpetual license"}),(0,f.jsxs)("p",{children:["With the perpetual license option, you can still use the plugins even after the license is expired. But you will no longer get any updates from newer RxDB versions.",(0,f.jsx)("br",{})]})]})}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("h4",{children:"Increase license period"}),(0,f.jsxs)("p",{children:["The default license period is one year. We can do a longer license period to safe time on both sides by not having to go through the licensing process each single year. By choosing a license period of 2 years, you get a 10% discount. With a 3 year license the discount is 20%.",(0,f.jsx)("br",{})]}),(0,f.jsxs)("div",{className:"field",children:[(0,f.jsxs)("div",{className:"input",style:{float:"left",width:"100%"},children:[(0,f.jsx)("div",{className:"prefix",children:"License period "}),(0,f.jsxs)("select",{name:"license-period",id:"license-period",required:!0,defaultValue:1,children:[(0,f.jsx)("option",{value:1,children:"1"}),(0,f.jsx)("option",{value:2,children:"2 (10% discount)"}),(0,f.jsx)("option",{value:3,children:"3 (20% discount)"})]}),(0,f.jsx)("div",{className:"suffix",children:"year(s)"})]}),(0,f.jsx)("div",{className:"clear"})]}),(0,f.jsx)("p",{})]})}),(0,f.jsx)("div",{className:"clear"})]}),(0,f.jsx)("div",{className:"button",id:"price-calculator-submit",onClick:async()=>{(0,d.X)("calculate_premium_price",3);const e=(0,o.Is)(document.getElementById("price-calculator-form"));if(!e.reportValidity())return void console.log("form not valid");const t=new FormData(e),r=Object.fromEntries(t.entries());console.log("formData:"),console.dir(r);const a=l.find((e=>e.name.toLowerCase()===r["home-country"].toLowerCase()));if(!a)return;const n=Object.entries(r).filter((e=>{let[t,r]=e;return t.startsWith("package-")})).map((e=>{let[t]=e;return(0,c.SI)(t.split("-"))})),i=await(0,m.N8)();await i.upsertLocal(v,{companySize:r["company-size"],projectAmount:r["project-amount"],licensePeriod:r["license-period"],homeCountry:a.name,packages:n});const s={companySize:r["company-size"],teamSize:r["developer-count"],projectAmount:r["project-amount"],licensePeriod:parseInt(r["license-period"],10),homeCountryCode:a.code,packages:n},p=function(e){if(console.log("calculatePrice:"),console.dir(e),"number"!=typeof e.licensePeriod)throw new Error("not a number "+typeof e.licensePeriod);const t=(0,o.Is)(l.find((t=>t.code===e.homeCountryCode))).salary;let r=0;e.packages.forEach((e=>{const t=u[e];r+=t})),console.log("aimInPercent: "+r);let a=350+1.4*t*(r/100);if(2===e.packages.length&&(a*=.9),e.packages.length>2&&(a*=.85),e.companySize>1){let t=1+Math.pow(1*e.companySize-1,.95)/100*4.5;const r=6;t>r&&(t=r),console.log("input.companySize "+e.companySize+" - "+t),a*=t}if(e.packages.includes("sourcecode")){a*=1.75;const e=1520;a{console.log("setPrice:"),console.dir(t),e.innerHTML=Math.ceil(t).toString()+" € (EUR)",e.href=function(e){return"https://www.xe.com/en/currencyconverter/convert/?Amount="+e+"&From=EUR&To=USD"}(Math.ceil(t))},w=p.totalPrice/s.licensePeriod;x(y,"infinity"!==s.projectAmount?w/parseInt(s.projectAmount,10)/12:0),x(g,w),x(b,p.totalPrice),f.style.display="block"},children:"Estimate Price"})]}),(0,f.jsxs)("div",{id:"price-calculator-result",style:{display:"none"},children:[(0,f.jsx)("hr",{}),(0,f.jsx)("h4",{children:"Estimated Price:"}),(0,f.jsx)("table",{children:(0,f.jsxs)("tbody",{children:[(0,f.jsxs)("tr",{children:[(0,f.jsx)("th",{children:"Price Per Project per Month"}),(0,f.jsx)("td",{children:(0,f.jsx)("a",{id:"total-per-project-per-month",target:"_blank",rel:"nofollow noopener noreferrer",title:"Click to convert to other currency",href:"#",children:"XX \u20ac"})})]}),(0,f.jsxs)("tr",{children:[(0,f.jsx)("th",{children:"Total Price per Year"}),(0,f.jsx)("td",{children:(0,f.jsx)("a",{id:"total-per-year",target:"_blank",rel:"nofollow noopener noreferrer",title:"Click to convert to other currency",href:"#",children:"XX \u20ac"})})]}),(0,f.jsxs)("tr",{children:[(0,f.jsx)("th",{children:"Total Price"}),(0,f.jsx)("td",{children:(0,f.jsx)("a",{id:"total-price",target:"_blank",rel:"nofollow noopener noreferrer",title:"Click to convert to other currency",href:"#",children:"XX \u20ac"})})]})]})}),(0,f.jsxs)("div",{className:"proceed-hint",children:["Fill out",(0,f.jsxs)("a",{href:"#premium-request-form-block",children:[" ",(0,f.jsx)("b",{children:"this form"})," "]}),"to proceed."]})]})]})})]}),(0,f.jsx)("div",{className:"block dark",id:"premium-request-form-block",children:(0,f.jsxs)("div",{className:"content centered premium-request",children:[(0,f.jsxs)("h2",{children:["Request Premium ",(0,f.jsx)("b",{className:"underline",children:"Form"})]}),(0,f.jsx)("p",{}),(0,f.jsx)(y,{fallback:(0,f.jsx)("span",{children:"Loading form iframe..."}),children:()=>(0,f.jsxs)("iframe",{id:"request-premium-form",src:"https://webforms.pipedrive.com/f/6qflURDWONiPpj67lpG6r45n8feakrtS2AqMRcBf1EuCPRvNcXWdvNH2unFm5EpjW3",children:["Your browser doesn't support iframes, ",(0,f.jsx)("a",{href:"https://webforms.pipedrive.com/f/6qflURDWONiPpj67lpG6r45n8feakrtS2AqMRcBf1EuCPRvNcXWdvNH2unFm5EpjW3",target:"_blank",rel:"nofollow",children:"go here"})]})})]})})]})]})})]})}function b(e,t){if(void 0===t)return;const r=document.querySelector("[name="+e+"]");r&&(r.type&&"checkbox"===r.type?r.checked=t:r.value=t)}},6087:(e,t,r)=>{function a(e){return e[e.length-1]}function n(e){return Array.isArray(e)?e.slice(0):[e]}function i(e){return Array.isArray(e)}function s(e){return null!=e}function o(e,t){var r=0,a=-1;for(var n of e){if(!t(n,a+=1))break;r+=1}return r}function c(e,t){for(var r=t.length,a=0;ai,Nb:()=>l,S7:()=>s,SI:()=>a,gu:()=>c,qo:()=>n,r0:()=>o})},7400:(e,t,r)=>{function a(e,t){if(!e)throw t||(t=""),new Error("ensureNotFalsy() is falsy: "+t);return e}r.d(t,{Is:()=>a,kv:()=>n});var n={bufferSize:1,refCount:!0}},4419:(e,t,r)=>{function a(){return new Promise((e=>setTimeout(e,0)))}function n(e){return void 0===e&&(e=0),new Promise((t=>setTimeout(t,e)))}r.d(t,{$Y:()=>o,C2:()=>u,Y3:()=>a,YB:()=>n,Ze:()=>h,kZ:()=>i,m5:()=>s,y$:()=>c});Promise.resolve(!0);var i=Promise.resolve(!1),s=Promise.resolve(null),o=Promise.resolve();function c(e){return void 0===e&&(e=1e4),"function"==typeof requestIdleCallback?new Promise((t=>{requestIdleCallback((()=>t()),{timeout:e})})):n(0)}var l=o;function u(e){return void 0===e&&(e=void 0),l=l.then((()=>c(e)))}function h(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},984:(e,t,r)=>{r.d(t,{z:()=>n});var a=0;function n(){var e=Date.now();(e+=.01)<=a&&(e=a+.01);var t=parseFloat(e.toFixed(2));return a=t,t}}}]);
\ No newline at end of file
+"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[2160],{5921:(e,t,r)=>{r.d(t,{O9:()=>Hr,N8:()=>Qr,dZ:()=>Fr});var a=r(8061);function n(e,t){var r=e.get(t);if(void 0===r)throw new Error("missing value from map "+t);return r}function i(e,t,r,a){var n=e.get(t);return void 0===n?(n=r(),e.set(t,n)):a&&a(n),n}function s(e){return Object.assign({},e)}function o(e,t){if(void 0===t&&(t=!1),!e)return e;if(!t&&Array.isArray(e))return e.sort(((e,t)=>"string"==typeof e&&"string"==typeof t?e.localeCompare(t):"object"==typeof e?1:-1)).map((e=>o(e,t)));if("object"==typeof e&&!Array.isArray(e)){var r={};return Object.keys(e).sort(((e,t)=>e.localeCompare(t))).forEach((a=>{r[a]=o(e[a],t)})),r}return e}var c=function e(t){if(!t)return t;if(null===t||"object"!=typeof t)return t;if(Array.isArray(t)){for(var r=new Array(t.length),a=r.length;a--;)r[a]=e(t[a]);return r}var n={};for(var i in t)n[i]=e(t[i]);return n};function l(e,t,r){return Object.defineProperty(e,t,{get:function(){return r}}),r}var u=e=>{var t=typeof e;return null!==e&&("object"===t||"function"===t)},h=new Set(["__proto__","prototype","constructor"]),d=new Set("0123456789");function m(e){var t=[],r="",a="start",n=!1;for(var i of e)switch(i){case"\\":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");n&&(r+=i),a="property",n=!n;break;case".":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="property";break}if(n){n=!1,r+=i;break}if(h.has(r))return[];t.push(r),r="",a="property";break;case"[":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="index";break}if(n){n=!1,r+=i;break}if("property"===a){if(h.has(r))return[];t.push(r),r=""}a="index";break;case"]":if("index"===a){t.push(Number.parseInt(r,10)),r="",a="indexEnd";break}if("indexEnd"===a)throw new Error("Invalid character after an index");default:if("index"===a&&!d.has(i))throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");"start"===a&&(a="property"),n&&(n=!1,r+="\\"),r+=i}switch(n&&(r+="\\"),a){case"property":if(h.has(r))return[];t.push(r);break;case"index":throw new Error("Index was not closed");case"start":t.push("")}return t}function p(e,t){if("number"!=typeof t&&Array.isArray(e)){var r=Number.parseInt(t,10);return Number.isInteger(r)&&e[r]===e[t]}return!1}function f(e,t){if(p(e,t))throw new Error("Cannot use string index")}function y(e,t,r){if(Array.isArray(t)&&(t=t.join(".")),!t.includes(".")&&!t.includes("["))return e[t];if(!u(e)||"string"!=typeof t)return void 0===r?e:r;var a=m(t);if(0===a.length)return r;for(var n=0;n!1,deepFreezeWhenDevMode:e=>e,tunnelErrorMessage:e=>"RxDB Error-Code "+e+".\n Error messages are not included in RxDB core to reduce build size.\n - To find out what this error means, either use the dev-mode-plugin https://rxdb.info/dev-mode.html\n - or search for the error code here: https://github.com/pubkey/rxdb/search?q="+e+"\n "};function k(e,t,r){return"RxError ("+t+"):\n"+e+"\n"+function(e){var t="";return 0===Object.keys(e).length?t:(t+="Given parameters: {\n",t+=Object.keys(e).map((t=>{var r="[object Object]";try{r="errors"===t?e[t].map((e=>JSON.stringify(e,Object.getOwnPropertyNames(e)))):JSON.stringify(e[t],(function(e,t){return void 0===t?null:t}),2)}catch(a){}return t+":"+r})).join("\n"),t+="}")}(r)}var D=function(e){function t(t,r,a){var n;void 0===a&&(a={});var i=k(r,t,a);return(n=e.call(this,i)||this).code=t,n.message=i,n.parameters=a,n.rxdb=!0,n}return(0,x.Z)(t,e),t.prototype.toString=function(){return this.message},(0,b.Z)(t,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),t}((0,w.Z)(Error)),_=function(e){function t(t,r,a){var n;void 0===a&&(a={});var i=k(r,t,a);return(n=e.call(this,i)||this).code=t,n.message=i,n.parameters=a,n.rxdb=!0,n}return(0,x.Z)(t,e),t.prototype.toString=function(){return this.message},(0,b.Z)(t,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),t}((0,w.Z)(TypeError));function I(e,t){return new D(e,j.tunnelErrorMessage(e),t)}function R(e,t){return new _(e,j.tunnelErrorMessage(e),t)}function E(e){return!(!e||409!==e.status)&&e}var P={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var S=/\./g,C="abcdefghijklmnopqrstuvwxyz";function O(e){void 0===e&&(e=10);for(var t="",r=0;r{var r=y(t,e);if(void 0===r)throw I("DOC18",{args:{field:e,documentData:t}});return r})).join(r.separator)}function W(e){var t=T((e=s(e)).primaryKey);e.properties=s(e.properties),e.additionalProperties=!1,Object.prototype.hasOwnProperty.call(e,"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=z,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=F(e);(0,g.gu)(e.required,r),e.required=e.required.filter((e=>!e.includes("."))).filter(((e,t,r)=>r.indexOf(e)===t)),e.version=e.version||0;var a=e.indexes.map((e=>{var r=(0,g.AD)(e)?e.slice(0):[e];return r.includes(t)||r.push(t),"_deleted"!==r[0]&&r.unshift("_deleted"),r}));0===a.length&&a.push(function(e){return["_deleted",e]}(t)),a.push(["_meta.lwt",t]),e.internalIndexes&&e.internalIndexes.map((e=>{a.push(e)}));var n=new Set;return a.filter((e=>{var t=e.join(",");return!n.has(t)&&(n.add(t),!0)})),e.indexes=a,e}var z={type:"object",properties:{lwt:{type:"number",minimum:A,maximum:1e15,multipleOf:.01}},additionalProperties:!0,required:["lwt"]};function F(e){var t=Object.keys(e.properties).filter((t=>e.properties[t].final)),r=T(e.primaryKey);return t.push(r),"string"!=typeof e.primaryKey&&e.primaryKey.fields.forEach((e=>t.push(e))),t}var Q="docs",H="changes",U="attachments",K="dexie",Z=new Map,V=new Map;var J="__";function G(e){var t=e.split(".");if(t.length>1)return t.map((e=>G(e))).join(".");if(e.startsWith("|")){var r=e.substring(1);return J+r}return e}function Y(e){var t=e.split(".");return t.length>1?t.map((e=>Y(e))).join("."):e.startsWith(J)?"|"+e.substring(J.length):e}function X(e,t){return t?(t=te(t=s(t)),e.forEach((e=>{var r=y(t,e);v(t,e,r?"1":"0")})),t):t}function ee(e,t){return t?(t=re(t=s(t)),e.forEach((e=>{var r=y(t,e);v(t,e,"1"===r)})),t):t}function te(e){if(!e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(Array.isArray(e))return e.map((e=>te(e)));if("object"==typeof e){var t={};return Object.entries(e).forEach((e=>{let[r,a]=e;"object"==typeof a&&(a=te(a)),t[G(r)]=a})),t}}function re(e){if(!e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(Array.isArray(e))return e.map((e=>re(e)));if("object"==typeof e){var t={};return Object.entries(e).forEach((r=>{let[a,n]=r;("object"==typeof n||Array.isArray(e))&&(n=re(n)),t[Y(a)]=n})),t}}function ae(e){var t=[],r=T(e.primaryKey);t.push([r]),t.push(["_deleted",r]),e.indexes&&e.indexes.forEach((e=>{var r=(0,g.qo)(e);t.push(r)})),t.push(["_meta.lwt",r]),t.push(["_meta.lwt"]);var a=(t=t.map((e=>e.map((e=>G(e)))))).map((e=>1===e.length?e[0]:"["+e.join("+")+"]"));return(a=a.filter(((e,t,r)=>r.indexOf(e)===t))).join(", ")}async function ne(e,t){var r=await e;return(await r.dexieTable.bulkGet(t)).map((e=>ee(r.booleanIndexes,e)))}function ie(e,t){return e+"||"+t}function se(e){var t=new Set,r=[];return e.indexes?(e.indexes.forEach((a=>{(0,g.qo)(a).forEach((a=>{t.has(a)||(t.add(a),"boolean"===M(e,a).type&&r.push(a))}))})),r.push("_deleted"),(0,g.Nb)(r)):r}var oe=r(6974),ce=r(984),le=r(7400),ue=String.fromCharCode(65535),he=Number.MIN_SAFE_INTEGER;function de(e,t){var r=t.selector,a=e.indexes?e.indexes.slice(0):[];t.index&&(a=[t.index]);var n=!!t.sort.find((e=>"desc"===Object.values(e)[0])),i=new Set;Object.keys(r).forEach((t=>{var a=M(e,t);a&&"boolean"===a.type&&Object.prototype.hasOwnProperty.call(r[t],"$eq")&&i.add(t)}));var s,o=t.sort.map((e=>Object.keys(e)[0])).filter((e=>!i.has(e))).join(","),c=-1;if(a.forEach((e=>{var a=!0,l=!0,u=e.map((e=>{var t=r[e],n=t?Object.keys(t):[],i={};t&&n.length?n.forEach((e=>{if(me.has(e)){var r=function(e,t){switch(e){case"$eq":return{startKey:t,endKey:t,inclusiveEnd:!0,inclusiveStart:!0};case"$lte":return{endKey:t,inclusiveEnd:!0};case"$gte":return{startKey:t,inclusiveStart:!0};case"$lt":return{endKey:t,inclusiveEnd:!1};case"$gt":return{startKey:t,inclusiveStart:!1};default:throw new Error("SNH")}}(e,t[e]);i=Object.assign(i,r)}})):i={startKey:l?he:ue,endKey:a?ue:he,inclusiveStart:!0,inclusiveEnd:!0};return void 0===i.startKey&&(i.startKey=he),void 0===i.endKey&&(i.endKey=ue),void 0===i.inclusiveStart&&(i.inclusiveStart=!0),void 0===i.inclusiveEnd&&(i.inclusiveEnd=!0),l&&!i.inclusiveStart&&(l=!1),a&&!i.inclusiveEnd&&(a=!1),i})),h=u.map((e=>e.startKey)),d=u.map((e=>e.endKey)),m={index:e,startKeys:h,endKeys:d,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!i.has(e))).join(","),selectorSatisfiedByIndex:ye(e,t.selector,h,d)},p=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},i=10,s=(0,g.r0)(r.startKeys,(e=>e!==he&&e!==ue));n(s*i);var o=(0,g.r0)(r.startKeys,(e=>e!==ue&&e!==he));n(o*i);var c=(0,g.r0)(r.startKeys,((e,t)=>e===r.endKeys[t]));n(c*i*1.5);var l=r.sortSatisfiedByIndex?5:0;return n(l),a}(0,0,m);(p>=c||t.index)&&(c=p,s=m)})),!s)throw I("SNH",{query:t});return s}var me=new Set(["$eq","$gt","$gte","$lt","$lte"]),pe=new Set(["$eq","$gt","$gte"]),fe=new Set(["$eq","$lt","$lte"]);function ye(e,t,r,a){var n=Object.entries(t).find((t=>{let[r,a]=t;return!e.includes(r)||Object.entries(a).find((e=>{let[t,r]=e;return!me.has(t)}))}));if(n)return!1;if(t.$and||t.$or)return!1;var i=[],s=new Set;for(var[o,c]of Object.entries(t)){if(!e.includes(o))return!1;var l=Object.keys(c).filter((e=>pe.has(e)));if(l.length>1)return!1;var u=l[0];if(u&&s.add(o),"$eq"!==u){if(i.length>0)return!1;i.push(u)}}var h=[],d=new Set;for(var[m,p]of Object.entries(t)){if(!e.includes(m))return!1;var f=Object.keys(p).filter((e=>fe.has(e)));if(f.length>1)return!1;var y=f[0];if(y&&d.add(m),"$eq"!==y){if(h.length>0)return!1;h.push(y)}}var v=0;for(var g of e){for(var b of[s,d]){if(!b.has(g)&&b.size>0)return!1;b.delete(g)}if(r[v]!==a[v]&&s.size>0&&d.size>0)return!1;v++}return!0}var ve=r(6250),ge=r(7761),be=r(7132),xe=r(6496),we=r(6851),je=r(3516),ke=r(8039),De=r(5308),_e=r(2106),Ie=!1;function Re(e){return Ie||((0,ge.Qs)(ge.$M.PIPELINE,{$sort:xe.E3,$project:xe.FM}),(0,ge.Qs)(ge.$M.QUERY,{$and:we.h$,$eq:je.l3,$elemMatch:De.rr,$exists:_e.G,$gt:je.ok,$gte:je.m9,$in:je.FI,$lt:je.Ty,$lte:je.HG,$ne:je.ny,$nin:je.IS,$mod:ke.JD,$nor:we.ps,$not:we._w,$or:we.Ko,$regex:ke.GO,$size:De.QH,$type:_e.e}),Ie=!0),new be.A(e)}function Ee(e,t){var r=T(e.primaryKey);t=s(t);var a=c(t);if("number"!=typeof a.skip&&(a.skip=0),a.selector?(a.selector=a.selector,Object.entries(a.selector).forEach((e=>{let[t,r]=e;"object"==typeof r&&null!==r||(a.selector[t]={$eq:r})}))):a.selector={},a.index){var n=(0,g.qo)(a.index);n.includes(r)||n.push(r),a.index=n}if(a.sort)a.sort.find((e=>{return t=e,Object.keys(t)[0]===r;var t}))||(a.sort=a.sort.slice(0),a.sort.push({[r]:"asc"}));else if(a.index)a.sort=a.index.map((e=>({[e]:"asc"})));else{if(e.indexes){var i=new Set;Object.entries(a.selector).forEach((e=>{let[t,r]=e;("object"!=typeof r||null===r||!!Object.keys(r).find((e=>me.has(e))))&&i.add(t)}));var o,l=-1;e.indexes.forEach((e=>{var t=(0,g.AD)(e)?e:[e],r=t.findIndex((e=>!i.has(e)));r>0&&r>l&&(l=r,o=t)})),o&&(a.sort=o.map((e=>({[e]:"asc"}))))}a.sort||(a.sort=[{[r]:"asc"}])}return a}function Pe(e,t){if(!t.sort)throw I("SNH",{query:t});var r=[];t.sort.forEach((e=>{var t,a,n,i=Object.keys(e)[0],s=Object.values(e)[0];r.push({key:i,direction:s,getValueFn:(t=i,a=t.split("."),n=a.length,1===n?e=>e[t]:e=>{for(var t=e,r=0;r{for(var a=0;ar.test(e)}function Ce(e){return e===he?-1/0:e}function Oe(e,t,r){return e.includes(t)?r===ue||!0===r?"1":"0":r}function Ne(e,t,r){if(!r){if("undefined"==typeof window)throw new Error("IDBKeyRange missing");r=window.IDBKeyRange}var a=t.startKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Ce),n=t.endKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Ce);return r.bound(a,n,!t.inclusiveStart,!t.inclusiveEnd)}async function Be(e,t){var r=await e.internals,a=t.query,n=a.skip?a.skip:0,i=n+(a.limit?a.limit:1/0),s=t.queryPlan,o=!1;s.selectorSatisfiedByIndex||(o=Se(e.schema,t.query));var c=Ne(r.booleanIndexes,s,r.dexieDb._options.IDBKeyRange),l=s.index,u=[];if(await r.dexieDb.transaction("r",r.dexieTable,(async e=>{var t,a=e.idbtrans.objectStore(Q);t="["+l.map((e=>G(e))).join("+")+"]";var n=a.index(t).openCursor(c);await new Promise((e=>{n.onsuccess=function(t){var a=t.target.result;if(a){var n=ee(r.booleanIndexes,a.value);o&&!o(n)||u.push(n),s.sortSatisfiedByIndex&&u.length===i?e():a.continue()}else e()}}))})),!s.sortSatisfiedByIndex){var h=Pe(e.schema,t.query);u=u.sort(h)}return{documents:u=u.slice(n,i)}}function Ae(e){var t=e.split("-");if(2!==t.length)throw new Error("malformatted revision: "+e);return{height:parseInt(t[0],10),hash:t[1]}}function qe(e){return parseInt(e.split("-")[0],10)}function Me(e,t){var r=t?t._rev:null;return(r?Ae(r).height:0)+1+"-"+e}var $e="_rxdb_internal";async function Te(e,t){var r=(await e.findDocumentsById([t],!1))[0];return r||void 0}async function Le(e,t,r){var a=await e.bulkWrite([t],r);if(a.error.length>0)throw a.error[0];return a.success[0]}function We(e,t,r){var a=t.documentData,n=t.previousDocumentData;return{documentId:t.documentId,collectionName:r?r.name:void 0,isLocal:e,operation:t.operation,documentData:j.deepFreezeWhenDevMode(a),previousDocumentData:j.deepFreezeWhenDevMode(n)}}function ze(e,t,r,a){if(a)throw 409===a.status?I("CONFLICT",{collection:e.name,id:t,writeError:a,data:r}):422===a.status?I("VD2",{collection:e.name,id:t,writeError:a,data:r}):a}function Fe(e){return{previous:e.previous,document:Qe(e.document)}}function Qe(e){if(!e._attachments||0===Object.keys(e._attachments).length)return e;var t=s(e);return t._attachments={},Object.entries(e._attachments).forEach((e=>{let[r,a]=e;var n,i,s;t._attachments[r]=(s=(n=a).data)?{length:(i=s,atob(i).length),digest:n.digest,type:n.type}:n})),t}function He(e){var t=s(e);return t._meta=s(e._meta),t}function Ue(e,t,r){j.deepFreezeWhenDevMode(r);var a=T(r.primaryKey);var n={originalStorageInstance:t,schema:t.schema,internals:t.internals,collectionName:t.collectionName,databaseName:t.databaseName,options:t.options,bulkWrite(n,i){var o=n.map((n=>function(n){var i=s(n.document);if(i._meta=s(i._meta),j.isDevMode()){i=$(a,r,i);try{"function"==typeof structuredClone?structuredClone(n):JSON.parse(JSON.stringify(n))}catch(o){throw I("DOC24",{collection:t.collectionName,document:n.document})}n.previous,n.previous&&Object.keys(n.previous._meta).forEach((e=>{if(!Object.prototype.hasOwnProperty.call(n.document._meta,e))throw I("SNH",{dataBefore:n.previous,dataAfter:n.document})}))}return i._meta.lwt=(0,ce.z)(),i._rev=Me(e.token,n.previous),{document:i,previous:n.previous}}(n)));return e.lockedRun((()=>t.bulkWrite(o,i))).then((r=>{var a={error:[],success:r.success.slice(0)},n=r.error.filter((e=>!(409!==e.status||e.writeRow.previous||e.writeRow.document._deleted||!(0,le.Is)(e.documentInDb)._deleted)||(a.error.push(e),!1)));if(n.length>0){var s=n.map((t=>({previous:t.documentInDb,document:Object.assign({},t.writeRow.document,{_rev:Me(e.token,t.documentInDb)})})));return e.lockedRun((()=>t.bulkWrite(s,i))).then((e=>((0,g.gu)(a.error,e.error),(0,g.gu)(a.success,e.success),a)))}return r}))},query:r=>e.lockedRun((()=>t.query(r))),count:r=>e.lockedRun((()=>t.count(r))),findDocumentsById:(r,a)=>e.lockedRun((()=>t.findDocumentsById(r,a))),getAttachmentData:(r,a,n)=>e.lockedRun((()=>t.getAttachmentData(r,a,n))),getChangedDocumentsSince:t.getChangedDocumentsSince?(r,a)=>e.lockedRun((()=>t.getChangedDocumentsSince((0,le.Is)(r),a))):void 0,cleanup:r=>e.lockedRun((()=>t.cleanup(r))),remove:()=>(e.storageInstances.delete(n),e.lockedRun((()=>t.remove()))),close:()=>(e.storageInstances.delete(n),e.lockedRun((()=>t.close()))),changeStream:()=>t.changeStream(),conflictResultionTasks:()=>t.conflictResultionTasks(),resolveConflictResultionTask(e){if(e.output.isEqual)return t.resolveConflictResultionTask(e);var r=s(Object.assign({},e.output.documentData,{_meta:q(),_rev:"",_attachments:{}}));return delete r._meta,delete r._rev,delete r._attachments,t.resolveConflictResultionTask({id:e.id,output:{isEqual:!1,documentData:r}})}};return e.storageInstances.add(n),n}var Ke=r(5677),Ze=r(3981),Ve=new Map;function Je(e,t){var r=Ve.get(e);if(r)return r.refs.delete(t),0===r.refs.size?(Ve.delete(e),r.bc.close()):void 0}function Ge(e,t,r,a){if(t.multiInstance){var n=a||function(e,t,r,a){var n=Ve.get(t);return n||(n={bc:new Ze.g0(["RxDB:",e,r].join("|")),refs:new Set},Ve.set(t,n)),n.refs.add(a),n.bc}(e,t.databaseInstanceToken,r.databaseName,r),i=new oe.x,s=r=>{r.storageName===e&&r.databaseName===t.databaseName&&r.collectionName===t.collectionName&&r.version===t.schema.version&&i.next(r.eventBulk)};n.addEventListener("message",s);var o=r.changeStream(),c=!1,l=o.subscribe((r=>{c||n.postMessage({storageName:e,databaseName:t.databaseName,collectionName:t.collectionName,version:t.schema.version,eventBulk:r})}));r.changeStream=function(){return i.asObservable().pipe((0,Ke.b)(o))};var u=r.close.bind(r);r.close=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),u()};var h=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),h()}}}var Ye=(0,ce.z)(),Xe=function(){function e(e,t,r,a,n,i,s){this.changes$=new oe.x,this.instanceId=Ye++,this.storage=e,this.databaseName=t,this.collectionName=r,this.schema=a,this.internals=n,this.options=i,this.settings=s,this.primaryPath=T(this.schema.primaryKey)}var t=e.prototype;return t.bulkWrite=async function(e,t){tt(this),e.forEach((e=>{if(!e.document._rev||e.previous&&!e.previous._rev)throw I("SNH",{args:{row:e}})}));var r,a=await this.internals,n={success:[],error:[]},i=e.map((e=>e.document[this.primaryPath]));if(await a.dexieDb.transaction("rw",a.dexieTable,a.dexieAttachmentsTable,(async()=>{var s=new Map;(await ne(this.internals,i)).forEach((e=>{var t=e;return t&&s.set(t[this.primaryPath],t),t})),r=function(e,t,r,a,n,i,s){for(var o,c=!!e.schema.attachments,l=[],u=[],h=[],d={id:O(10),events:[],checkpoint:null,context:n,startTime:(0,ce.z)(),endTime:0},m=d.events,p=[],f=[],y=[],v=r.size>0,g=a.length,b=function(){var e,n=a[x],d=n.document,g=n.previous,b=d[t],w=d._deleted,j=g&&g._deleted,k=void 0;if(v&&(k=r.get(b)),k){var D=k._rev;if(!g||g&&D!==g._rev){var _={isError:!0,status:409,documentId:b,writeRow:n,documentInDb:k};return h.push(_),1}var R=c?Fe(n):n;c&&(w?g&&Object.keys(g._attachments).forEach((e=>{f.push({documentId:b,attachmentId:e,digest:(0,le.Is)(g)._attachments[e].digest})})):(Object.entries(d._attachments).find((t=>{let[r,a]=t;return(g?g._attachments[r]:void 0)||a.data||(e={documentId:b,documentInDb:k,isError:!0,status:510,writeRow:n,attachmentId:r}),!0})),e||Object.entries(d._attachments).forEach((e=>{let[t,r]=e;var a=g?g._attachments[t]:void 0;if(a){var n=R.document._attachments[t].digest;r.data&&a.digest!==n&&y.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})}else p.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})})))),e?h.push(e):(c?(u.push(Fe(R)),s&&s(d)):(u.push(R),s&&s(d)),o=R);var E=null,P=null,S=null;if(j&&!w)S="INSERT",E=c?Qe(d):d;else if(!g||j||w){if(!w)throw I("SNH",{args:{writeRow:n}});S="DELETE",E=(0,le.Is)(d),P=g}else S="UPDATE",E=c?Qe(d):d,P=g;var C={documentId:b,documentData:E,previousDocumentData:P,operation:S};m.push(C)}else{var O=!!w;if(c&&Object.entries(d._attachments).forEach((t=>{let[r,a]=t;a.data?p.push({documentId:b,attachmentId:r,attachmentData:a,digest:a.digest}):(e={documentId:b,isError:!0,status:510,writeRow:n,attachmentId:r},h.push(e))})),e||(c?(l.push(Fe(n)),i&&i(d)):(l.push(n),i&&i(d)),o=n),!O){var N={documentId:b,operation:"INSERT",documentData:c?Qe(d):d,previousDocumentData:c&&g?Qe(g):g};m.push(N)}}},x=0;x{n.success.push(e.document),o.push(e.document)})),r.bulkUpdateDocs.forEach((e=>{n.success.push(e.document),o.push(e.document)})),(o=o.map((e=>X(a.booleanIndexes,e)))).length>0&&await a.dexieTable.bulkPut(o);var c=[];r.attachmentsAdd.forEach((e=>{c.push({id:ie(e.documentId,e.attachmentId),data:e.attachmentData.data})})),r.attachmentsUpdate.forEach((e=>{c.push({id:ie(e.documentId,e.attachmentId),data:e.attachmentData.data})})),await a.dexieAttachmentsTable.bulkPut(c),await a.dexieAttachmentsTable.bulkDelete(r.attachmentsRemove.map((e=>ie(e.documentId,e.attachmentId))))})),(r=(0,le.Is)(r)).eventBulk.events.length>0){var s=(0,le.Is)(r.newestRow).document;r.eventBulk.checkpoint={id:s[this.primaryPath],lwt:s._meta.lwt},r.eventBulk.endTime=(0,ce.z)(),this.changes$.next(r.eventBulk)}return n},t.findDocumentsById=async function(e,t){tt(this);var r=await this.internals,a=[];return await r.dexieDb.transaction("r",r.dexieTable,(async()=>{(await ne(this.internals,e)).forEach((e=>{!e||e._deleted&&!t||a.push(e)}))})),a},t.query=function(e){return tt(this),Be(this,e)},t.count=async function(e){if(e.queryPlan.selectorSatisfiedByIndex){var t=await async function(e,t){var r=await e.internals,a=t.queryPlan,n=a.index,i=Ne(r.booleanIndexes,a,r.dexieDb._options.IDBKeyRange),s=-1;return await r.dexieDb.transaction("r",r.dexieTable,(async e=>{var t,r=e.idbtrans.objectStore(Q);t="["+n.map((e=>G(e))).join("+")+"]";var a=r.index(t).count(i);s=await new Promise(((e,t)=>{a.onsuccess=function(){e(a.result)},a.onerror=e=>t(e)}))})),s}(this,e);return{count:t,mode:"fast"}}return{count:(await Be(this,e)).documents.length,mode:"slow"}},t.changeStream=function(){return tt(this),this.changes$.asObservable()},t.cleanup=async function(e){tt(this);var t=await this.internals;return await t.dexieDb.transaction("rw",t.dexieTable,(async()=>{var r=(0,ce.z)()-e,a=await t.dexieTable.where("_meta.lwt").below(r).toArray(),n=[];a.forEach((e=>{"1"===e._deleted&&n.push(e[this.primaryPath])})),await t.dexieTable.bulkDelete(n)})),!0},t.getAttachmentData=async function(e,t,r){tt(this);var a=await this.internals,n=ie(e,t);return await a.dexieDb.transaction("r",a.dexieAttachmentsTable,(async()=>{var r=await a.dexieAttachmentsTable.get(n);if(r)return r.data;throw new Error("attachment missing documentId: "+e+" attachmentId: "+t)}))},t.remove=async function(){tt(this);var e=await this.internals;return await e.dexieTable.clear(),this.close()},t.close=function(){return this.closed||(this.closed=(async()=>{this.changes$.complete(),await async function(e){var t=await e,r=V.get(e)-1;0===r?(t.dexieDb.close(),V.delete(e)):V.set(e,r)}(this.internals)})()),this.closed},t.conflictResultionTasks=function(){return new oe.x},t.resolveConflictResultionTask=async function(e){},e}();async function et(e,t,r){var n=function(e,t,r,n){var o="rxdb-dexie-"+e+"--"+n.version+"--"+t,c=i(Z,o,(()=>{var e=(async()=>{var e=s(r);e.autoOpen=!1;var t=new a.U(o,e),i={[Q]:ae(n),[H]:"++sequence, id",[U]:"id"};return t.version(1).stores(i),await t.open(),{dexieDb:t,dexieTable:t[Q],dexieAttachmentsTable:t[U],booleanIndexes:se(n)}})();return Z.set(o,c),V.set(c,0),e}));return c}(t.databaseName,t.collectionName,r,t.schema),o=new Xe(e,t.databaseName,t.collectionName,t.schema,n,t.options,r);return await Ge(K,t,o),Promise.resolve(o)}function tt(e){if(e.closed)throw new Error("RxStorageInstanceDexie is closed "+e.databaseName+"-"+e.collectionName)}var rt="15.4.2",at=function(){function e(e){this.name=K,this.rxdbVersion=rt,this.settings=e}return e.prototype.createStorageInstance=function(e){return function(e){if(e.schema.keyCompression)throw I("UT5",{args:{params:e}});if((t=e.schema).encrypted&&t.encrypted.length>0||t.attachments&&t.attachments.encrypted)throw I("UT6",{args:{params:e}});var t;if(e.schema.attachments&&e.schema.attachments.compression)throw I("UT7",{args:{params:e}})}(e),et(this,e,this.settings)},e}();function nt(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var r,a;if(Array.isArray(e)){if((r=e.length)!==t.length)return!1;for(a=r;0!=a--;)if(!nt(e[a],t[a]))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 n=Object.keys(e);if((r=n.length)!==Object.keys(t).length)return!1;for(a=r;0!=a--;)if(!Object.prototype.hasOwnProperty.call(t,n[a]))return!1;for(a=r;0!=a--;){var i=n[a];if(!nt(e[i],t[i]))return!1}return!0}return e!=e&&t!=t}var it={preAddRxPlugin:[],preCreateRxDatabase:[],createRxDatabase:[],preCreateRxCollection:[],createRxCollection:[],postDestroyRxCollection:[],postRemoveRxCollection:[],preCreateRxSchema:[],createRxSchema:[],preCreateRxQuery:[],prePrepareQuery:[],createRxDocument:[],postCreateRxDocument:[],preCreateRxStorageInstance:[],preMigrateDocument:[],postMigrateDocument:[],preDestroyRxDatabase:[],postRemoveRxDatabase:[],preReplicationMasterWrite:[],preReplicationMasterWriteDocumentsHandle:[]};function st(e,t){it[e]&&it[e].forEach((e=>e(t)))}function ot(e,t){return Promise.all(it[e].map((e=>e(t))))}var ct=function(){function e(e,t){this.jsonSchema=e,this.hashFunction=t,this.indexes=function(e){return(e.indexes||[]).map((e=>(0,g.AD)(e)?e:[e]))}(this.jsonSchema),this.primaryPath=T(this.jsonSchema.primaryKey),this.finalFields=F(this.jsonSchema)}var t=e.prototype;return t.validateChange=function(e,t){this.finalFields.forEach((r=>{if(!nt(e[r],t[r]))throw I("DOC9",{dataBefore:e,dataAfter:t,fieldName:r,schema:this.jsonSchema})}))},t.getDocumentPrototype=function(){var e={},t=M(this.jsonSchema,"");return Object.keys(t).forEach((t=>{var r=t;e.__defineGetter__(t,(function(){if(this.get&&"function"==typeof this.get)return this.get(r)})),Object.defineProperty(e,t+"$",{get:function(){return this.get$(r)},enumerable:!1,configurable:!1}),Object.defineProperty(e,t+"_",{get:function(){return this.populate(r)},enumerable:!1,configurable:!1})})),l(this,"getDocumentPrototype",(()=>e)),e},t.getPrimaryOfDocumentData=function(e){return L(this.jsonSchema,e)},(0,b.Z)(e,[{key:"version",get:function(){return this.jsonSchema.version}},{key:"defaultValues",get:function(){var e={};return Object.entries(this.jsonSchema.properties).filter((e=>{let[,t]=e;return Object.prototype.hasOwnProperty.call(t,"default")})).forEach((t=>{let[r,a]=t;return e[r]=a.default})),l(this,"defaultValues",e)}},{key:"hash",get:function(){return l(this,"hash",this.hashFunction(JSON.stringify(this.jsonSchema)))}}]),e}();function lt(e,t,r){void 0===r&&(r=!0),r&&st("preCreateRxSchema",e);var a=W(e);a=function(e){return o(e,!0)}(a),j.deepFreezeWhenDevMode(a);var n=new ct(a,t);return st("createRxSchema",n),n}var ut=r(598),ht=r(6621),dt=r(6728),mt=r(6005),pt=r(7570),ft=r(4419);function yt(e){var t=e.split("-"),r="RxDB";return t.forEach((e=>{r+=N(e)})),r+="Plugin",new Error("You are using a function which must be overwritten by a plugin.\n You should either prevent the usage of this function or add the plugin via:\n import { "+r+" } from 'rxdb/plugins/"+e+"';\n addRxPlugin("+r+");\n ")}function vt(e){return e.documentData?e.documentData:e.previousDocumentData}var gt=function(){function e(e,t,r,a){this.queueByDocId=new Map,this.isRunning=!1,this.storageInstance=e,this.primaryPath=t,this.preWrite=r,this.postWrite=a}var t=e.prototype;return t.addWrite=function(e,t){var r=e[this.primaryPath],a=i(this.queueByDocId,r,(()=>[]));return new Promise(((r,n)=>{var i={lastKnownDocumentState:e,modifier:t,resolve:r,reject:n};(0,le.Is)(a).push(i),this.triggerRun()}))},t.triggerRun=async function(){if(!0!==this.isRunning&&0!==this.queueByDocId.size){this.isRunning=!0;var e=[],t=this.queueByDocId;this.queueByDocId=new Map,await Promise.all(Array.from(t.entries()).map((async t=>{let[r,a]=t;var n,i,s,o=(n=a.map((e=>e.lastKnownDocumentState)),i=n[0],s=Ae(i._rev).height,n.forEach((e=>{var t=Ae(e._rev).height;t>s&&(i=e,s=t)})),i),l=o;for(var u of a)try{l=await u.modifier(c(l))}catch(h){u.reject(h),u.reject=()=>{},u.resolve=()=>{}}try{await this.preWrite(l,o)}catch(h){return void a.forEach((e=>e.reject(h)))}e.push({previous:o,document:l})})));var r=e.length>0?await this.storageInstance.bulkWrite(e,"incremental-write"):{error:[],success:[]};return await Promise.all(r.success.map((e=>{var r=e[this.primaryPath];this.postWrite(e),n(t,r).forEach((t=>t.resolve(e)))}))),r.error.forEach((e=>{var r,a=e.documentId,s=n(t,a),o=E(e);if(o){var c=i(this.queueByDocId,a,(()=>[]));s.reverse().forEach((e=>{e.lastKnownDocumentState=(0,le.Is)(o.documentInDb),(0,le.Is)(c).unshift(e)}))}else{var l=I("COL20",{name:P[(r=e).status],document:r.documentId,writeError:r});s.forEach((e=>e.reject(l)))}})),this.isRunning=!1,this.triggerRun()}},e}();function bt(e){return async t=>{var r=function(e){return Object.assign({},e,{_meta:void 0,_deleted:void 0,_rev:void 0})}(t);r._deleted=t._deleted;var a=await e(r),n=Object.assign({},a,{_meta:t._meta,_attachments:t._attachments,_rev:t._rev,_deleted:void 0!==a._deleted?a._deleted:t._deleted});return void 0===n._deleted&&(n._deleted=!1),n}}var xt={get primaryPath(){if(this.isInstanceOfRxDocument)return this.collection.schema.primaryPath},get primary(){var e=this;if(e.isInstanceOfRxDocument)return e._data[e.primaryPath]},get revision(){if(this.isInstanceOfRxDocument)return this._data._rev},get deleted$(){if(this.isInstanceOfRxDocument)return this.$.pipe((0,ut.U)((e=>e._data._deleted)))},get deleted(){if(this.isInstanceOfRxDocument)return this._data._deleted},getLatest(){var e=this.collection._docCache.getLatestDocumentData(this.primary);return this.collection._docCache.getCachedRxDocument(e)},get $(){return this.collection.$.pipe((0,ht.h)((e=>!e.isLocal)),(0,ht.h)((e=>e.documentId===this.primary)),(0,ut.U)((e=>vt(e))),(0,dt.O)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.x)(((e,t)=>e._rev===t._rev)),(0,ut.U)((e=>this.collection._docCache.getCachedRxDocument(e))),(0,pt.d)(le.kv))},get$(e){if(j.isDevMode()){if(e.includes(".item."))throw I("DOC1",{path:e});if(e===this.primaryPath)throw I("DOC2");if(this.collection.schema.finalFields.includes(e))throw I("DOC3",{path:e});if(!M(this.collection.schema.jsonSchema,e))throw I("DOC4",{path:e})}return this.$.pipe((0,ut.U)((t=>y(t,e))),(0,mt.x)())},populate(e){var t=M(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.m5;if(!t)throw I("DOC5",{path:e});if(!t.ref)throw I("DOC6",{path:e,schemaObj:t});var a=this.collection.database.collections[t.ref];if(!a)throw I("DOC7",{ref:t.ref,path:e,schemaObj:t});return"array"===t.type?a.findByIds(r).exec().then((e=>{var t=e.values();return Array.from(t)})):a.findOne(r).exec()},get(e){return i(this._propertyCache,e,(()=>{var t=y(this._data,e);if("object"!=typeof t||null===t||Array.isArray(t))return j.deepFreezeWhenDevMode(t);var r=this;return new Proxy(s(t),{get(t,a){if("string"!=typeof a)return t[a];var n=a.charAt(a.length-1);if("$"===n){var i=a.slice(0,-1);return r.get$(B(e+"."+i))}if("_"===n){var s=a.slice(0,-1);return r.populate(B(e+"."+s))}return r.get(B(e+"."+a))}})}))},toJSON(e){if(void 0===e&&(e=!1),e)return j.deepFreezeWhenDevMode(this._data);var t=s(this._data);return delete t._rev,delete t._attachments,delete t._deleted,delete t._meta,j.deepFreezeWhenDevMode(t)},toMutableJSON(e){return void 0===e&&(e=!1),c(this.toJSON(e))},update(e){throw yt("update")},incrementalUpdate(e){throw yt("update")},updateCRDT(e){throw yt("crdt")},putAttachment(){throw yt("attachments")},getAttachment(){throw yt("attachments")},allAttachments(){throw yt("attachments")},get allAttachments$(){throw yt("attachments")},async modify(e,t){var r=this._data,a=await bt(e)(r);return this._saveData(a,r)},incrementalModify(e,t){return this.collection.incrementalWriteQueue.addWrite(this._data,bt(e)).then((e=>this.collection._docCache.getCachedRxDocument(e)))},patch(e){var t=this._data,r=c(t);return Object.entries(e).forEach((e=>{let[t,a]=e;r[t]=a})),this._saveData(r,t)},incrementalPatch(e){return this.incrementalModify((t=>(Object.entries(e).forEach((e=>{let[r,a]=e;t[r]=a})),t)))},async _saveData(e,t){if(e=s(e),this._data._deleted)throw I("DOC11",{id:this.primary,document:this});await jt(this.collection,e,t);var r=await this.collection.storageInstance.bulkWrite([{previous:t,document:e}],"rx-document-save-data"),a=r.error[0];return ze(this.collection,this.primary,e,a),await this.collection._runHooks("post","save",e,this),this.collection._docCache.getCachedRxDocument(r.success[0])},remove(){var e=this.collection;if(this.deleted)return Promise.reject(I("DOC13",{document:this,id:this.primary}));var t,r=s(this._data);return e._runHooks("pre","remove",r,this).then((async()=>{r._deleted=!0;var t=await e.storageInstance.bulkWrite([{previous:this._data,document:r}],"rx-document-remove"),a=t.error[0];return ze(e,this.primary,r,a),t.success[0]})).then((e=>(t=e,this.collection._runHooks("post","remove",r,this)))).then((()=>this.collection._docCache.getCachedRxDocument(t)))},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 I("DOC14")}};function wt(e){void 0===e&&(e=xt);var t=function(e,t){this.collection=e,this._data=t,this._propertyCache=new Map,this.isInstanceOfRxDocument=!0};return t.prototype=e,t}function jt(e,t,r){return t._meta=Object.assign({},r._meta,t._meta),j.isDevMode()&&e.schema.validateChange(r,t),e._runHooks("pre","save",t,r)}var kt=r(10),Dt=r(6871),_t=r(3028),It=r(1556),Rt=r(8456);function Et(e,t){return t.sort&&0!==t.sort.length?t.sort.map((e=>Object.keys(e)[0])):[e]}var Pt=new WeakMap;function St(e,t){if(!e.collection.database.eventReduce)return{runFullQueryAgain:!0};var r=function(e){return i(Pt,e,(()=>{var t=e.collection,r=Ee(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=Pe(t.schema.jsonSchema,r),i=Se(t.schema.jsonSchema,r);return{primaryKey:e.collection.schema.primaryPath,skip:r.skip,limit:r.limit,sortFields:Et(a,r),sortComparator:(t,r)=>{var a={docA:t,docB:r,rxQuery:e};return n(a.docA,a.docB)},queryMatcher:t=>i({doc:t,rxQuery:e}.doc)}}))}(e),a=(0,le.Is)(e._result).docsData.slice(0),n=(0,le.Is)(e._result).docsDataMap,s=!1;return t.map((e=>function(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:j.deepFreezeWhenDevMode(e.documentData),previous:e.previousDocumentData?e.previousDocumentData:"UNKNOWN"};case"DELETE":return{operation:e.operation,id:e.documentId,doc:null,previous:e.previousDocumentData}}}(e))).filter(g.S7).find((e=>{var t={queryParams:r,changeEvent:e,previousResults:a,keyDocumentMap:n},i=(0,Rt.Rf)(t);return"runFullQueryAgain"===i||("doNothing"!==i?(s=!0,(0,Rt.wu)(i,r,e,a,n),!1):void 0)}))?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:s,newResults:a}}var Ct=function(){function e(){this._map=new Map}return e.prototype.getByQuery=function(e){var t=e.toString();return i(this._map,t,(()=>e))},e}();function Ot(e,t){t.uncached=!0;var r=t.toString();e._map.delete(r)}function Nt(e){return e.refCount$.observers.length}var Bt,At,qt=(Bt=100,At=3e4,(e,t)=>{if(!(t._map.size0||(0===i._lastEnsureEqual&&i._creationTimee._lastEnsureEqual-t._lastEnsureEqual)).slice(0,s).forEach((e=>Ot(t,e)))}}),Mt=new WeakSet;var $t=function(){function e(e,t,r){this.cacheItemByDocId=new Map,this.registry="function"==typeof FinalizationRegistry?new FinalizationRegistry((e=>{var t=e.docId,r=this.cacheItemByDocId.get(t);r&&(r.byRev.delete(e.revisionHeight),0===r.byRev.size&&this.cacheItemByDocId.delete(t))})):void 0,this.registerIdleTasks=[],this.primaryPath=e,this.changes$=t,this.documentCreator=r,t.subscribe((e=>{var t=e.documentId,r=this.cacheItemByDocId.get(t);if(r){var a=vt(e);r.last=a}}))}var t=e.prototype;return t.getLatestDocumentData=function(e){return n(this.cacheItemByDocId,e).last},t.getLatestDocumentDataIfExists=function(e){var t=this.cacheItemByDocId.get(e);if(t)return t.last},(0,b.Z)(e,[{key:"getCachedRxDocument",get:function(){return l(this,"getCachedRxDocument",function(e){var t=e.primaryPath,r=e.cacheItemByDocId,a=e.registry,n=j.deepFreezeWhenDevMode,s=e.documentCreator,o=o=>{var c=o[t],l=qe(o._rev),u=i(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),h=u.byRev,d=h.get(l),m=d?d.deref():void 0;return m||(o=n(o),m=s(o),h.set(l,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,ft.y$)().then((()=>{e.registerIdlePromise=void 0;var t=e.registerIdleTasks;0!==t.length&&(e.registerIdleTasks=[],t.forEach((e=>{a.register(e,{docId:e.primary,revisionHeight:qe(e.revision)})})))}))))),m};return o}(this))}}]),e}();function Tt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Wt=function(){function e(e,t,r){this.time=(0,ce.z)(),this.collection=e,this.count=r,this.documents=Tt(this.collection._docCache,t)}return(0,b.Z)(e,[{key:"docsData",get:function(){return l(this,"docsData",this.documents.map((e=>e._data)))}},{key:"docsDataMap",get:function(){var e=new Map;return this.documents.forEach((t=>{e.set(t.primary,t._data)})),l(this,"docsDataMap",e)}},{key:"docsMap",get:function(){for(var e=new Map,t=this.documents,r=0;r"string"!=typeof e)))return r.$eq}return!1}(this.collection.schema.primaryPath,t)}var t=e.prototype;return t._setResultData=function(e){if("number"!=typeof e){e instanceof Map&&(e=Array.from(e.values()));var t=new Wt(this.collection,e,e.length);this._result=t}else this._result=new Wt(this.collection,[],e)},t._execOverDatabase=async function(){if(this._execOverDatabaseCount=this._execOverDatabaseCount+1,this._lastExecStart=(0,ce.z)(),"count"===this.op){var e=this.getPreparedQuery(),t=await this.collection.storageInstance.count(e);if("slow"!==t.mode||this.collection.database.allowSlowCount)return t.count;throw I("QU14",{collection:this.collection,queryObj:this.mangoQuery})}if("findByIds"===this.op){var r=(0,le.Is)(this.mangoQuery.selector)[this.collection.schema.primaryPath].$in,a=new Map,n=[];if(r.forEach((e=>{var t=this.collection._docCache.getLatestDocumentDataIfExists(e);if(t){if(!t._deleted){var r=this.collection._docCache.getCachedRxDocument(t);a.set(e,r)}}else n.push(e)})),n.length>0)(await this.collection.storageInstance.findDocumentsById(n,!1)).forEach((e=>{var t=this.collection._docCache.getCachedRxDocument(e);a.set(t.primary,t)}));return a}var i=async function(e){var t=[],r=e.collection;if(e.isFindOneByIdQuery)if(Array.isArray(e.isFindOneByIdQuery)){var a=e.isFindOneByIdQuery;if(a=a.filter((r=>{var a=e.collection._docCache.getLatestDocumentDataIfExists(r);return!a||(a._deleted||t.push(a),!1)})),a.length>0){var n=await r.storageInstance.findDocumentsById(a,!1);(0,g.gu)(t,n)}}else{var i=e.isFindOneByIdQuery,s=e.collection._docCache.getLatestDocumentDataIfExists(i);if(!s){var o=await r.storageInstance.findDocumentsById([i],!1);o[0]&&(s=o[0])}s&&!s._deleted&&t.push(s)}else{var c=e.getPreparedQuery(),l=await r.storageInstance.query(c);t=l.documents}return t}(this);return i.then((e=>(this._lastExecEnd=(0,ce.z)(),e)))},t.exec=function(e){if(e&&"findOne"!==this.op)throw I("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Ut(this).then((()=>(0,Dt.z)(this.$))).then((t=>{if(!t&&e)throw I("QU10",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return t}))},t.toString=function(){var e=o({op:this.op,query:this.mangoQuery,other:this.other},!0),t=JSON.stringify(e);return this.toString=()=>t,t},t.getPreparedQuery=function(){var e={rxQuery:this,mangoQuery:Ee(this.collection.schema.jsonSchema,this.mangoQuery)};e.mangoQuery.selector._deleted={$eq:!1},e.mangoQuery.index&&e.mangoQuery.index.unshift("_deleted"),st("prePrepareQuery",e);var t=Kt(this.collection.schema.jsonSchema,e.mangoQuery);return this.getPreparedQuery=()=>t,t},t.doesDocumentDataMatch=function(e){return!e._deleted&&this.queryMatcher(e)},t.remove=function(){return this.exec().then((e=>Array.isArray(e)?Promise.all(e.map((e=>e.remove()))):e.remove()))},t.update=function(e){throw yt("update")},t.where=function(e){throw yt("query-builder")},t.sort=function(e){throw yt("query-builder")},t.skip=function(e){throw yt("query-builder")},t.limit=function(e){throw yt("query-builder")},(0,b.Z)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,ht.h)((e=>!e.isLocal)),(0,dt.O)(null),(0,It.z)((()=>Ut(this))),(0,ut.U)((()=>this._result)),(0,pt.d)(le.kv),(0,mt.x)(((e,t)=>!(!e||e.time!==(0,le.Is)(t).time))),(0,ht.h)((e=>!!e)),(0,ut.U)((e=>{var t=(0,le.Is)(e);return"count"===this.op?t.count:"findOne"===this.op?0===t.documents.length?null:t.documents[0]:"findByIds"===this.op?t.docsMap:t.documents.slice(0)})));this._$=(0,_t.T)(e,this.refCount$.pipe((0,ht.h)((()=>!1))))}return this._$}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return l(this,"queryMatcher",Se(0,Ee(this.collection.schema.jsonSchema,this.mangoQuery)))}},{key:"asRxQuery",get:function(){return this}}]),e}();function Qt(e,t,r,a){st("preCreateRxQuery",{op:e,queryObj:t,collection:r,other:a});var n,i,s=new Ft(e,t,r,a);return s=(n=s).collection._queryCache.getByQuery(n),i=r,Mt.has(i)||(Mt.add(i),(0,ft.Y3)().then((()=>(0,ft.C2)(200))).then((()=>{i.destroyed||i.cacheReplacementPolicy(i,i._queryCache),Mt.delete(i)}))),s}function Ht(e){var t=e.asRxQuery.collection._changeEventBuffer.counter;return e._latestChangeEvent>=t}function Ut(e){return e.collection.database.destroyed||Ht(e)?ft.kZ:(e._ensureEqualQueue=e._ensureEqualQueue.then((()=>function(e){if(e._lastEnsureEqual=(0,ce.z)(),e.collection.database.destroyed||Ht(e))return ft.kZ;var t=!1,r=!1;-1===e._latestChangeEvent&&(r=!0);if(!r){var a=e.asRxQuery.collection._changeEventBuffer.getFrom(e._latestChangeEvent+1);if(null===a)r=!0;else{e._latestChangeEvent=e.asRxQuery.collection._changeEventBuffer.counter;var n=e.asRxQuery.collection._changeEventBuffer.reduceByLastOfDoc(a);if("count"===e.op){var i=(0,le.Is)(e._result).count,s=i;n.forEach((t=>{var r=t.previousDocumentData&&e.doesDocumentDataMatch(t.previousDocumentData),a=e.doesDocumentDataMatch(t.documentData);!r&&a&&s++,r&&!a&&s--})),s!==i&&(t=!0,e._setResultData(s))}else{var o=St(e,n);o.runFullQueryAgain?r=!0:o.changed&&(t=!0,e._setResultData(o.newResults))}}}if(r)return e._execOverDatabase().then((r=>(e._latestChangeEvent=e.collection._changeEventBuffer.counter,"number"==typeof r?(e._result&&r===e._result.count||(t=!0,e._setResultData(r)),t):(e._result&&function(e,t,r){if(t.length!==r.length)return!1;for(var a=0,n=t.length;ae.data.name===n)),c=[];o.forEach((e=>{c.push({collectionName:e.data.name,schema:e.data.schema,isCollection:!0}),e.data.connectedStorages.forEach((e=>c.push({collectionName:e.collectionName,isCollection:!1,schema:e.schema})))}));var l=new Set;if(c=c.filter((e=>{var t=e.collectionName+"||"+e.schema.version;return!l.has(t)&&(l.add(t),!0)})),await Promise.all(c.map((async t=>{var s=await e.createStorageInstance({collectionName:t.collectionName,databaseInstanceToken:r,databaseName:a,multiInstance:!1,options:{},schema:t.schema,password:i,devMode:j.isDevMode()});await s.remove(),t.isCollection&&await ot("postRemoveRxCollection",{storage:e,databaseName:a,collectionName:n})}))),s){var u=o.map((e=>{var t=He(e);return t._deleted=!0,t._meta.lwt=(0,ce.z)(),t._rev=Me(r,e),{previous:e,document:t}}));await t.bulkWrite(u,"rx-database-remove-collection-all")}}var nr=function(){function e(e){this.subs=[],this.limit=100,this.counter=0,this.eventCounterMap=new WeakMap,this.buffer=[],this.collection=e,this.subs.push(this.collection.$.pipe((0,ht.h)((e=>!e.isLocal))).subscribe((e=>this._handleChangeEvent(e))))}var t=e.prototype;return t._handleChangeEvent=function(e){for(this.counter++,this.buffer.push(e),this.eventCounterMap.set(e,this.counter);this.buffer.length>this.limit;)this.buffer.shift()},t.getArrayIndexByPointer=function(e){var t=this.buffer[0],r=this.eventCounterMap.get(t);return et(e)))},t.reduceByLastOfDoc=function(e){return e.slice(0)},t.destroy=function(){this.subs.forEach((e=>e.unsubscribe()))},e}();var ir=new WeakMap;function sr(e){var t=e.schema.getDocumentPrototype(),r=function(e){var t={};return Object.entries(e.methods).forEach((e=>{let[r,a]=e;t[r]=a})),t}(e),a={};return[t,r,xt].forEach((e=>{Object.getOwnPropertyNames(e).forEach((t=>{var r=Object.getOwnPropertyDescriptor(e,t),n=!0;(t.startsWith("_")||t.endsWith("_")||t.startsWith("$")||t.endsWith("$"))&&(n=!1),"function"==typeof r.value?Object.defineProperty(a,t,{get(){return r.value.bind(this)},enumerable:n,configurable:!1}):(r.enumerable=n,r.configurable=!1,r.writable&&(r.writable=!1),Object.defineProperty(a,t,r))}))})),a}function or(e,t){var r=function(e,t,r){var a=new e(t,r);return st("createRxDocument",a),a}(function(e){return i(ir,e,(()=>wt(sr(e))))}(e),e,j.deepFreezeWhenDevMode(t));return e._runHooksSync("post","create",t,r),st("postCreateRxDocument",r),r}var cr=function(e,t){return nt(Qe(e.newDocumentState),Qe(e.realMasterState))?Promise.resolve({isEqual:!0}):Promise.resolve({isEqual:!1,documentData:e.realMasterState})};var lr=["pre","post"],ur=["insert","save","remove","create"],hr=!1,dr=function(){function e(e,t,r,a,n,i,s,o,c,l,u,h){void 0===n&&(n={}),void 0===i&&(i={}),void 0===s&&(s={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===l&&(l=qt),void 0===u&&(u={}),void 0===h&&(h=cr),this.storageInstance={},this.timeouts=new Set,this.incrementalWriteQueue={},this._incrementalUpsertQueues=new Map,this.synced=!1,this.hooks={},this._subs=[],this._docCache={},this._queryCache=new Ct,this.$={},this.checkpoint$={},this._changeEventBuffer={},this.onDestroy=[],this.destroyed=!1,this.database=e,this.name=t,this.schema=r,this.internalStorageInstance=a,this.instanceCreationOptions=n,this.migrationStrategies=i,this.methods=s,this.attachments=o,this.options=c,this.cacheReplacementPolicy=l,this.statics=u,this.conflictHandler=h,function(e){if(hr)return;hr=!0;var t=Object.getPrototypeOf(e);ur.forEach((e=>{lr.map((r=>{var a=r+N(e);t[a]=function(t,a){return this.addHook(r,e,t,a)}}))}))}(this.asRxCollection)}var t=e.prototype;return t.prepare=async function(){this.storageInstance=Ue(this.database,this.internalStorageInstance,this.schema.jsonSchema),this.incrementalWriteQueue=new gt(this.storageInstance,this.schema.primaryPath,((e,t)=>jt(this,e,t)),(e=>this._runHooks("post","save",e)));var e,t=this.database.eventBulks$.pipe((0,ht.h)((e=>e.collectionName===this.name)));this.$=t.pipe((0,It.z)((e=>e.events))),this.checkpoint$=t.pipe((0,ut.U)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new $t(this.schema.primaryPath,this.$.pipe((0,ht.h)((e=>!e.isLocal))),(e=>or(this.asRxCollection,e)));var r=await this.database.storageToken,a=this.storageInstance.changeStream().subscribe((e=>{var t={id:e.id,internal:!1,collectionName:this.name,storageToken:r,events:e.events.map((e=>We(!1,e,this))),databaseToken:this.database.token,checkpoint:e.checkpoint,context:e.context,endTime:e.endTime,startTime:e.startTime};this.database.$emit(t)}));return this._subs.push(a),this._subs.push(this.storageInstance.conflictResultionTasks().subscribe((e=>{this.conflictHandler(e.input,e.context).then((t=>{this.storageInstance.resolveConflictResultionTask({id:e.id,output:t})}))}))),ft.$Y},t.cleanup=function(e){throw yt("cleanup")},t.migrationNeeded=function(){throw yt("migration-schema")},t.getMigrationState=function(){throw yt("migration-schema")},t.startMigration=function(e){return void 0===e&&(e=10),this.getMigrationState().startMigration(e)},t.migratePromise=function(e){return void 0===e&&(e=10),this.getMigrationState().migratePromise(e)},t.insert=async function(e){var t=await this.bulkInsert([e]),r=t.error[0];return ze(this,e[this.schema.primaryPath],e,r),(0,le.Is)(t.success[0])},t.bulkInsert=async function(e){if(0===e.length)return{success:[],error:[]};var t=this.schema.primaryPath,r=e.map((e=>rr(this.schema,e))),a=this.hasHooks("pre","insert")?await Promise.all(r.map((e=>this._runHooks("pre","insert",e).then((()=>e))))):r,n=a.map((e=>({document:e}))),i=await this.storageInstance.bulkWrite(n,"rx-collection-bulk-insert"),s=Tt(this._docCache,i.success);if(this.hasHooks("post","insert")){var o=new Map;a.forEach((e=>{o.set(e[t],e)})),await Promise.all(s.map((e=>this._runHooks("post","insert",o.get(e.primary),e))))}return{success:s,error:i.error}},t.bulkRemove=async function(e){var t=this.schema.primaryPath;if(0===e.length)return{success:[],error:[]};var r=await this.findByIds(e).exec(),a=[],i=new Map;Array.from(r.values()).forEach((e=>{var t=e.toMutableJSON(!0);a.push(t),i.set(e.primary,t)})),await Promise.all(a.map((e=>{var t=e[this.schema.primaryPath];return this._runHooks("pre","remove",e,r.get(t))})));var o=a.map((e=>{var t=s(e);return t._deleted=!0,{previous:e,document:t}})),c=await this.storageInstance.bulkWrite(o,"rx-collection-bulk-remove"),l=c.success.map((e=>e[t]));return await Promise.all(l.map((e=>this._runHooks("post","remove",i.get(e),r.get(e))))),{success:l.map((e=>n(r,e))),error:c.error}},t.bulkUpsert=async function(e){var t=[],r=new Map;e.forEach((e=>{var a=rr(this.schema,e),n=a[this.schema.primaryPath];if(!n)throw I("COL3",{primaryPath:this.schema.primaryPath,data:a,schema:this.schema.jsonSchema});r.set(n,a),t.push(a)}));var a=await this.bulkInsert(t),i=a.success.slice(0),s=[];return await Promise.all(a.error.map((async e=>{if(409!==e.status)s.push(e);else{var t=e.documentId,a=n(r,t),o=(0,le.Is)(e.documentInDb),c=this._docCache.getCachedRxDocument(o),l=await c.incrementalModify((()=>a));i.push(l)}}))),{error:s,success:i}},t.upsert=async function(e){var t=await this.bulkUpsert([e]);return ze(this.asRxCollection,e[this.schema.primaryPath],e,t.error[0]),t.success[0]},t.incrementalUpsert=function(e){var t=rr(this.schema,e),r=t[this.schema.primaryPath];if(!r)throw I("COL4",{data:e});var a=this._incrementalUpsertQueues.get(r);return a||(a=ft.$Y),a=a.then((()=>function(e,t,r){var a=e._docCache.getLatestDocumentDataIfExists(t);if(a)return Promise.resolve({doc:e._docCache.getCachedRxDocument(a),inserted:!1});return e.findOne(t).exec().then((t=>t?{doc:t,inserted:!1}:e.insert(r).then((e=>({doc:e,inserted:!0})))))}(this,r,t))).then((e=>e.inserted?e.doc:function(e,t){return e.incrementalModify((e=>t))}(e.doc,t))),this._incrementalUpsertQueues.set(r,a),a},t.find=function(e){if("string"==typeof e)throw I("COL5",{queryObj:e});return e||(e={selector:{}}),Qt("find",e,this)},t.findOne=function(e){if("number"==typeof e||Array.isArray(e))throw R("COL6",{queryObj:e});var t;if("string"==typeof e)t=Qt("findOne",{selector:{[this.schema.primaryPath]:e},limit:1},this);else{if(e||(e={selector:{}}),e.limit)throw I("QU6");(e=s(e)).limit=1,t=Qt("findOne",e,this)}return t},t.count=function(e){return e||(e={selector:{}}),Qt("count",e,this)},t.findByIds=function(e){return Qt("findByIds",{selector:{[this.schema.primaryPath]:{$in:e.slice(0)}}},this)},t.exportJSON=function(){throw yt("json-dump")},t.importJSON=function(e){throw yt("json-dump")},t.insertCRDT=function(e){throw yt("crdt")},t.addHook=function(e,t,r,a){if(void 0===a&&(a=!1),"function"!=typeof r)throw R("COL7",{key:t,when:e});if(!lr.includes(e))throw R("COL8",{key:t,when:e});if(!ur.includes(t))throw I("COL9",{key:t});if("post"===e&&"create"===t&&!0===a)throw I("COL10",{when:e,key:t,parallel:a});var n=r.bind(this),i=a?"parallel":"series";this.hooks[t]=this.hooks[t]||{},this.hooks[t][e]=this.hooks[t][e]||{series:[],parallel:[]},this.hooks[t][e][i].push(n)},t.getHooks=function(e,t){return this.hooks[t]&&this.hooks[t][e]?this.hooks[t][e]:{series:[],parallel:[]}},t.hasHooks=function(e,t){var r=this.getHooks(e,t);return!!r&&(r.series.length>0||r.parallel.length>0)},t._runHooks=function(e,t,r,a){var n=this.getHooks(e,t);if(!n)return ft.$Y;var i=n.series.map((e=>()=>e(r,a)));return(0,ft.Ze)(i).then((()=>Promise.all(n.parallel.map((e=>e(r,a))))))},t._runHooksSync=function(e,t,r,a){var n=this.getHooks(e,t);n&&n.series.forEach((e=>e(r,a)))},t.promiseWait=function(e){return new Promise((t=>{var r=setTimeout((()=>{this.timeouts.delete(r),t()}),e);this.timeouts.add(r)}))},t.destroy=function(){return this.destroyed?ft.kZ:(this.destroyed=!0,Array.from(this.timeouts).forEach((e=>clearTimeout(e))),this._changeEventBuffer&&this._changeEventBuffer.destroy(),this.database.requestIdlePromise().then((()=>Promise.all(this.onDestroy.map((e=>e()))))).then((()=>this.storageInstance.close())).then((()=>(this._subs.forEach((e=>e.unsubscribe())),delete this.database.collections[this.name],ot("postDestroyRxCollection",this).then((()=>!0))))))},t.remove=async function(){await this.destroy(),await ar(this.database.storage,this.database.internalStore,this.database.token,this.database.name,this.name,this.database.password,this.database.hashFunction)},(0,b.Z)(e,[{key:"insert$",get:function(){return this.$.pipe((0,ht.h)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,ht.h)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,ht.h)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}]),e}();var mr=r(7782),pr=r(6753);var fr="undefined"!=typeof crypto&&void 0!==crypto.subtle&&"function"==typeof crypto.subtle.digest?async function(e){var t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.prototype.map.call(new Uint8Array(r),(e=>("00"+e.toString(16)).slice(-2))).join("")}:function(e){return Promise.resolve((0,pr.JQ)(e))},yr=r(5898),vr=new Set,gr=function(){function e(e,t,r,a,n,i,s,o,c,l,u,h){void 0===s&&(s=!1),void 0===o&&(o={}),this.idleQueue=new mr.F,this.rxdbVersion=rt,this.storageInstances=new Set,this._subs=[],this.startupErrors=[],this.onDestroy=[],this.destroyed=!1,this.collections={},this.eventBulks$=new oe.x,this.observable$=this.eventBulks$.pipe((0,It.z)((e=>e.events))),this.storageToken=ft.kZ,this.storageTokenDocument=ft.kZ,this.emittedEventBulkIds=new yr.i(6e4),this.name=e,this.token=t,this.storage=r,this.instanceCreationOptions=a,this.password=n,this.multiInstance=i,this.eventReduce=s,this.options=o,this.internalStore=c,this.hashFunction=l,this.cleanupPolicy=u,this.allowSlowCount=h,"pseudoInstance"!==this.name&&(this.internalStore=Ue(this.asRxDatabase,c,Jt),this.storageTokenDocument=async function(e){var t=O(10),r=e.password?await e.hashFunction(JSON.stringify(e.password)):void 0,a={id:er,context:Vt,key:Xt,data:{rxdbVersion:e.rxdbVersion,token:t,instanceToken:e.token,passwordHash:r},_deleted:!1,_meta:q(),_rev:"",_attachments:{}},n=await e.internalStore.bulkWrite([{document:a}],"internal-add-storage-token");if(n.success[0])return n.success[0];var i=(0,le.Is)(n.error[0]);if(i.isError&&E(i)){var s=i;if(c=s.documentInDb.data.rxdbVersion,l=e.rxdbVersion,!c||l.includes("beta")&&l!==c||c.split(".")[0]!==l.split(".")[0])throw I("DM5",{args:{database:e.name,databaseStateVersion:s.documentInDb.data.rxdbVersion,codeVersion:e.rxdbVersion}});if(r&&r!==s.documentInDb.data.passwordHash)throw I("DB1",{passwordHash:r,existingPasswordHash:s.documentInDb.data.passwordHash});var o=s.documentInDb;return(0,le.Is)(o)}var c,l;throw i}(this.asRxDatabase).catch((e=>this.startupErrors.push(e))),this.storageToken=this.storageTokenDocument.then((e=>e.data.token)).catch((e=>this.startupErrors.push(e))))}var t=e.prototype;return t.$emit=function(e){this.emittedEventBulkIds.has(e.id)||(this.emittedEventBulkIds.add(e.id),this.eventBulks$.next(e))},t.removeCollectionDoc=async function(e,t){var r=await Te(this.internalStore,Gt(tr(e,t),Zt));if(!r)throw I("SNH",{name:e,schema:t});var a=He(r);a._deleted=!0,await this.internalStore.bulkWrite([{document:a,previous:r}],"rx-database-remove-collection")},t.addCollections=async function(e){var t={},r={},a=[],n={};await Promise.all(Object.entries(e).map((async e=>{let[i,o]=e;var c=i,l=o.schema;t[c]=l;var u=lt(l,this.hashFunction);if(r[c]=u,this.collections[i])throw I("DB3",{name:i});var h=tr(i,l),d={id:Gt(h,Zt),key:h,context:Zt,data:{name:c,schemaHash:await u.hash,schema:u.jsonSchema,version:u.version,connectedStorages:[]},_deleted:!1,_meta:q(),_rev:"",_attachments:{}};a.push({document:d});var m=Object.assign({},o,{name:c,schema:u,database:this}),p=s(o);p.database=this,p.name=i,st("preCreateRxCollection",p),m.conflictHandler=p.conflictHandler,n[c]=m})));var i=await this.internalStore.bulkWrite(a,"rx-database-add-collection");await async function(e){if(await e.storageToken,e.startupErrors[0])throw e.startupErrors[0]}(this),await Promise.all(i.error.map((async e=>{if(409!==e.status)throw I("DB12",{database:this.name,writeError:e});var a=(0,le.Is)(e.documentInDb),n=a.data.name,i=r[n];if(a.data.schemaHash!==await i.hash)throw I("DB6",{database:this.name,collection:n,previousSchemaHash:a.data.schemaHash,schemaHash:await i.hash,previousSchema:a.data.schema,schema:(0,le.Is)(t[n])})})));var o={};return await Promise.all(Object.keys(e).map((async e=>{var t=n[e],r=await function(e){let{database:t,name:r,schema:a,instanceCreationOptions:n={},migrationStrategies:i={},autoMigrate:s=!0,statics:o={},methods:c={},attachments:l={},options:u={},localDocuments:h=!1,cacheReplacementPolicy:d=qt,conflictHandler:m=cr}=e;var p={databaseInstanceToken:t.token,databaseName:t.name,collectionName:r,schema:a.jsonSchema,options:n,multiInstance:t.multiInstance,password:t.password,devMode:j.isDevMode()};return st("preCreateRxStorageInstance",p),async function(e,t){return t.multiInstance=e.multiInstance,await e.storage.createStorageInstance(t)}(t,p).then((e=>{var p=new dr(t,r,a,e,n,i,c,l,u,d,o,m);return p.prepare().then((()=>{Object.entries(o).forEach((e=>{let[t,r]=e;Object.defineProperty(p,t,{get:()=>r.bind(p)})}));var e=ft.$Y;return s&&0!==p.schema.version&&(e=p.migratePromise()),e})).then((()=>(st("createRxCollection",{collection:p,creator:{name:r,schema:a,storageInstance:e,instanceCreationOptions:n,migrationStrategies:i,methods:c,attachments:l,options:u,cacheReplacementPolicy:d,localDocuments:h,statics:o}}),p))).catch((t=>e.close().then((()=>Promise.reject(t)))))}))}(t);o[e]=r,this.collections[e]=r,this[e]||Object.defineProperty(this,e,{get:()=>this.collections[e]})}))),o},t.lockedRun=function(e){return this.idleQueue.wrapCall(e)},t.requestIdlePromise=function(){return this.idleQueue.requestIdlePromise()},t.exportJSON=function(e){throw yt("json-dump")},t.importJSON=function(e){throw yt("json-dump")},t.backup=function(e){throw yt("backup")},t.leaderElector=function(){throw yt("leader-election")},t.isLeader=function(){throw yt("leader-election")},t.waitForLeadership=function(){throw yt("leader-election")},t.migrationStates=function(){throw yt("migration-schema")},t.destroy=async function(){return this.destroyed?ft.kZ:(this.destroyed=!0,await ot("preDestroyRxDatabase",this),this.eventBulks$.complete(),this._subs.map((e=>e.unsubscribe())),"pseudoInstance"===this.name?ft.kZ:this.requestIdlePromise().then((()=>Promise.all(this.onDestroy.map((e=>e()))))).then((()=>Promise.all(Object.keys(this.collections).map((e=>this.collections[e])).map((e=>e.destroy()))))).then((()=>this.internalStore.close())).then((()=>vr.delete(this.name))).then((()=>!0)))},t.remove=function(){return this.destroy().then((()=>async function(e,t,r){var a=O(10),n=await br(a,t,e,{},!1,r),i=await Yt(n),s=new Set;i.forEach((e=>s.add(e.data.name)));var o=Array.from(s);return await Promise.all(o.map((i=>ar(t,n,a,e,i,r)))),await ot("postRemoveRxDatabase",{databaseName:e,storage:t}),await n.remove(),o}(this.name,this.storage,this.password)))},(0,b.Z)(e,[{key:"$",get:function(){return this.observable$}},{key:"asRxDatabase",get:function(){return this}}]),e}();async function br(e,t,r,a,n,i){return await t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:$e,schema:Jt,options:a,multiInstance:n,password:i,devMode:j.isDevMode()})}function xr(e){let{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i=!0,eventReduce:s=!0,ignoreDuplicate:o=!1,options:c={},cleanupPolicy:l,allowSlowCount:u=!1,localDocuments:h=!1,hashFunction:d=fr}=e;st("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:h}),o||function(e){if(vr.has(e))throw I("DB8",{name:e,link:"https://pubkey.github.io/rxdb/rx-database.html#ignoreduplicate"})}(a),vr.add(a);var m=O(10);return br(m,t,a,r,i,n).catch((e=>{throw vr.delete(a),e})).then((e=>{var p=new gr(a,m,t,r,n,i,s,c,e,d,l,u);return ot("createRxDatabase",{database:p,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:h}}).then((()=>p))}))}var wr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Ft.prototype,RxCollection:dr.prototype,RxDatabase:gr.prototype},jr=new Set,kr=new Set;var Dr=function(e){function t(t,r,a){var n;return(n=e.call(this,null,r)||this).id=t,n.parent=a,n}return(0,x.Z)(t,e),t}(wt()),_r={get isLocal(){return!0},get allAttachments$(){throw I("LD1",{document:this})},get primaryPath(){return"id"},get primary(){return this.id},get $(){var e=n(Pr,this.parent);return this.parent.$.pipe((0,ht.h)((e=>e.documentId===this.primary)),(0,ht.h)((e=>e.isLocal)),(0,ut.U)((e=>vt(e))),(0,dt.O)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.x)(((e,t)=>e._rev===t._rev)),(0,ut.U)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.d)(le.kv))},getLatest(){var e=n(Pr,this.parent),t=e.docCache.getLatestDocumentData(this.primary);return e.docCache.getCachedRxDocument(t)},get(e){if(e="data."+e,this._data){if("string"!=typeof e)throw R("LD2",{objPath:e});var t=y(this._data,e);return t=j.deepFreezeWhenDevMode(t)}},get$(e){if(e="data."+e,j.isDevMode()){if(e.includes(".item."))throw I("LD3",{objPath:e});if(e===this.primaryPath)throw I("LD4")}return this.$.pipe((0,ut.U)((e=>e._data)),(0,ut.U)((t=>y(t,e))),(0,mt.x)())},async incrementalModify(e){var t=await Cr(this.parent);return t.incrementalWriteQueue.addWrite(this._data,(async t=>(t.data=await e(t.data,this),t))).then((e=>t.docCache.getCachedRxDocument(e)))},incrementalPatch(e){return this.incrementalModify((t=>(Object.entries(e).forEach((e=>{let[r,a]=e;t[r]=a})),t)))},async _saveData(e){var t=await Cr(this.parent),r=this._data;return e.id=this.id,t.storageInstance.bulkWrite([{previous:r,document:e}],"local-document-save-data").then((t=>{var r=t.success[0];if(!r)throw t.error[0];(e=s(e))._rev=r._rev}))},async remove(){var e=await Cr(this.parent),t={id:this._data.id,data:{},_deleted:!0,_meta:q(),_rev:"",_attachments:{}};return Le(e.storageInstance,{previous:this._data,document:t},"local-document-remove").then((t=>e.docCache.getCachedRxDocument(t)))}},Ir=!1,Rr=()=>{if(!Ir){Ir=!0;var e=xt;Object.getOwnPropertyNames(e).forEach((t=>{if(!Object.getOwnPropertyDescriptor(_r,t)){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(_r,t,r)}}));["populate","update","putAttachment","getAttachment","allAttachments"].forEach((e=>_r[e]=(e=>()=>{throw I("LD6",{functionName:e})})(e)))}};var Er=new WeakMap,Pr=new WeakMap;function Sr(e){var t=e.database?e.database:e,r=e.database?e.name:"",a=(async()=>{var a=await Or(t.token,t.storage,t.name,r,t.instanceCreationOptions,t.multiInstance);a=Ue(t,a,qr);var n=new $t("id",e.$.pipe((0,ht.h)((e=>e.isLocal))),(t=>function(e,t){Rr();var r=new Dr(e.id,e,t);return Object.setPrototypeOf(r,_r),r.prototype=_r,r}(t,e))),i=new gt(a,"id",(()=>{}),(()=>{})),s=await t.storageToken,o=a.changeStream().subscribe((r=>{var a={id:r.id,internal:!1,collectionName:e.database?e.name:void 0,storageToken:s,events:r.events.map((t=>We(!0,t,e.database?e:void 0))),databaseToken:t.token,checkpoint:r.checkpoint,context:r.context,endTime:r.endTime,startTime:r.startTime};t.$emit(a)}));e._subs.push(o);var c={database:t,parent:e,storageInstance:a,docCache:n,incrementalWriteQueue:i};return Pr.set(e,c),c})();Er.set(e,a)}function Cr(e){var t=Er.get(e);if(!t){var r=e.database?e.database:e,a=e.database?e.name:"";throw I("LD8",{database:r.name,collection:a})}return t}function Or(e,t,r,a,n,i){return t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:Ar(a),schema:qr,options:n,multiInstance:i,devMode:j.isDevMode()})}function Nr(e){var t=Er.get(e);if(t)return Er.delete(e),t.then((e=>e.storageInstance.close()))}async function Br(e,t,r){var a=O(10),n=await Or(a,e,t,r,{},!1);await n.remove()}function Ar(e){return"plugin-local-documents-"+e}var qr=W({title:"RxLocalDocument",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:128},data:{type:"object",additionalProperties:!0}},required:["id","data"]});async function Mr(e,t){var r=await Cr(this),a={id:e,data:t,_deleted:!1,_meta:q(),_rev:"",_attachments:{}};return Le(r.storageInstance,{document:a},"local-document-insert").then((e=>r.docCache.getCachedRxDocument(e)))}function $r(e,t){return this.getLocal(e).then((r=>r?r.incrementalModify((()=>t)):this.insertLocal(e,t)))}async function Tr(e){var t=await Cr(this),r=t.docCache,a=r.getLatestDocumentDataIfExists(e);return a?Promise.resolve(r.getCachedRxDocument(a)):Te(t.storageInstance,e).then((e=>e?t.docCache.getCachedRxDocument(e):null))}function Lr(e){return this.$.pipe((0,dt.O)(null),(0,It.z)((async t=>t?{changeEvent:t}:{doc:await this.getLocal(e)})),(0,It.z)((async t=>{if(t.changeEvent){var r=t.changeEvent;return r.isLocal&&r.documentId===e?{use:!0,doc:await this.getLocal(e)}:{use:!1}}return{use:!0,doc:t.doc}})),(0,ht.h)((e=>e.use)),(0,ut.U)((e=>e.doc)))}var Wr={name:"local-documents",rxdb:!0,prototypes:{RxCollection:e=>{e.insertLocal=Mr,e.upsertLocal=$r,e.getLocal=Tr,e.getLocal$=Lr},RxDatabase:e=>{e.insertLocal=Mr,e.upsertLocal=$r,e.getLocal=Tr,e.getLocal$=Lr}},hooks:{createRxDatabase:{before:e=>{e.creator.localDocuments&&Sr(e.database)}},createRxCollection:{before:e=>{e.creator.localDocuments&&Sr(e.collection)}},preDestroyRxDatabase:{after:e=>Nr(e)},postDestroyRxCollection:{after:e=>Nr(e)},postRemoveRxDatabase:{after:e=>Br(e.storage,e.databaseName,"")},postRemoveRxCollection:{after:e=>Br(e.storage,e.databaseName,e.collectionName)}},overwritable:{}};let zr;function Fr(){return"undefined"!=typeof window&&window.indexedDB}function Qr(){return zr||(zr=(async()=>{!function(e){if(st("preAddRxPlugin",{plugin:e,plugins:jr}),!jr.has(e)){if(kr.has(e.name))throw I("PL3",{name:e.name,plugin:e});if(jr.add(e),kr.add(e.name),!e.rxdb)throw R("PL1",{plugin:e});e.init&&e.init(),e.prototypes&&Object.entries(e.prototypes).forEach((e=>{let[t,r]=e;return r(wr[t])})),e.overwritable&&Object.assign(j,e.overwritable),e.hooks&&Object.entries(e.hooks).forEach((e=>{let[t,r]=e;r.after&&it[t].push(r.after),r.before&&it[t].unshift(r.before)}))}}(Wr);var e;return await xr({name:"rxdb-landing-v3",localDocuments:!0,storage:(void 0===e&&(e={}),new at(e))})})()),zr}const Hr=["#e6008d","#8d2089","#5f2688"]},341:(e,t,r)=>{function a(e,t){if(!window.trigger)throw new Error("window.trigger not defined");return window.trigger(e,t)}r.d(t,{X:()=>a})},6451:(e,t,r)=>{r.r(t),r.d(t,{default:()=>g});var a=r(2263),n=r(3799),i=r(5742),s=r(7294),o=r(7400),c=r(6087);const l=[{name:"Antigua and Barbuda",code:"AG",salary:49527},{name:"Argentina",code:"AR",salary:17158},{name:"Australia",code:"AU",salary:76036},{name:"Austria",code:"AT",salary:59383},{name:"Bahamas",code:"BS",salary:62024},{name:"Belarus",code:"BY",salary:5749},{name:"Belgium",code:"BE",salary:63749},{name:"Bermuda",code:"BM",salary:86590},{name:"Bosnia and Herzegovina",code:"BA",salary:11992},{name:"Brazil",code:"BR",salary:26464},{name:"Bulgaria",code:"BG",salary:23384},{name:"Cambodia",code:"KH",salary:18e3},{name:"Canada",code:"CA",salary:71554},{name:"Chile",code:"CL",salary:31073},{name:"China",code:"CN",salary:40611},{name:"Colombia",code:"CO",salary:12894},{name:"Costa Rica",code:"CR",salary:40256},{name:"Croatia",code:"HR",salary:22566},{name:"Czech Republic",code:"CZ",salary:33760},{name:"Denmark",code:"DK",salary:68778},{name:"Ecuador",code:"EC",salary:35016},{name:"Egypt",code:"EG",salary:7758},{name:"Estonia",code:"EE",salary:26728},{name:"Finland",code:"FI",salary:64198},{name:"France",code:"FR",salary:58137},{name:"Georgia",code:"GE",salary:40315},{name:"Germany",code:"DE",salary:72138},{name:"Greece",code:"GR",salary:36824},{name:"Guatemala",code:"GT",salary:49612},{name:"Holy See (Vatican City State)",code:"VA",salary:51474},{name:"Hong Kong",code:"HK",salary:71970},{name:"Hungary",code:"HU",salary:22341},{name:"Iceland",code:"IS",salary:66512},{name:"India",code:"IN",salary:17710},{name:"Indonesia",code:"ID",salary:20978},{name:"Iraq",code:"IQ",salary:21029},{name:"Ireland",code:"IE",salary:66281},{name:"Israel",code:"IL",salary:57466},{name:"Italy",code:"IT",salary:50900},{name:"Jamaica",code:"JM",salary:21048},{name:"Japan",code:"JP",salary:57793},{name:"Kazakhstan",code:"KZ",salary:12243},{name:"Korea, Republic of",code:"KR",salary:45957},{name:"Latvia",code:"LV",salary:26728},{name:"Luxembourg",code:"LU",salary:84663},{name:"Malaysia",code:"MY",salary:26117},{name:"Malta",code:"MT",salary:41971},{name:"Mexico",code:"MX",salary:24050},{name:"Morocco",code:"MA",salary:17903},{name:"Netherlands",code:"NL",salary:62661},{name:"New Zealand",code:"NZ",salary:63948},{name:"Norway",code:"NO",salary:69498},{name:"Pakistan",code:"PK",salary:9066},{name:"Panama",code:"PA",salary:39143},{name:"Peru",code:"PE",salary:17469},{name:"Philippines",code:"PH",salary:11088},{name:"Poland",code:"PL",salary:30236},{name:"Portugal",code:"PT",salary:37959},{name:"Romania",code:"RO",salary:22319},{name:"Russian Federation",code:"RU",salary:20492},{name:"Saudi Arabia",code:"SA",salary:47336},{name:"Singapore",code:"SG",salary:66023},{name:"Slovakia",code:"SK",salary:29650},{name:"South Africa",code:"ZA",salary:40336},{name:"Spain",code:"ES",salary:47819},{name:"Sweden",code:"SE",salary:49361},{name:"Switzerland",code:"CH",salary:92820},{name:"Taiwan",code:"TW",salary:47737},{name:"Thailand",code:"TH",salary:21772},{name:"Turkey",code:"TR",salary:8788},{name:"Ukraine",code:"UA",salary:14139},{name:"United Arab Emirates",code:"AE",salary:66381},{name:"United Kingdom",code:"GB",salary:61188},{name:"United States",code:"US",salary:91935},{name:"Uruguay",code:"UY",salary:23754},{name:"Vietnam",code:"VN",salary:19058}],u={browser:.4,native:.4,performance:.35,sourcecode:0,perpetual:0},h=.05;var d=r(341),m=r(5921),p=r(2389),f=r(5893);function y(e){let{children:t,fallback:r}=e;return(0,p.Z)()?(0,f.jsx)(f.Fragment,{children:t?.()}):r??null}const v="premium-price-form-value";function g(){const{siteConfig:e}=(0,a.Z)(),t=(0,p.Z)();return(0,s.useEffect)((()=>{(async()=>{if(!t||!(0,m.dZ)())return;const e=await(0,m.N8)(),r=await e.getLocal(v);r&&(console.log("formValueDoc:"),console.dir(r),b("home-country",r._data.data.homeCountry),b("company-size",r._data.data.companySize),b("project-amount",r._data.data.projectAmount),b("license-period",r._data.data.licensePeriod),Object.keys(u).forEach((e=>{b("package-"+e,!1)})),r._data.data.packages.forEach((e=>{b("package-"+e,!0)})))})()})),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(i.Z,{children:(0,f.jsx)("body",{className:"homepage"})}),(0,f.jsx)(n.Z,{title:`Premium Plugins - ${e.title}`,description:"RxDB plugins for professionals. FAQ, pricing and license",children:(0,f.jsxs)("main",{children:[(0,f.jsx)("div",{className:"block first",children:(0,f.jsxs)("div",{className:"content centered",children:[(0,f.jsxs)("h2",{children:["\ud83d\udc51 ",(0,f.jsx)("b",{className:"underline",children:"RxDB"})," Premium Plugins"]}),(0,f.jsxs)("p",{style:{width:"80%"},children:["To make RxDB a sustainable project, some plugins are not part of the RxDB open source project. Instead they are part of the"," ",(0,f.jsx)("b",{children:"rxdb-premium"})," package which must be purchased.",(0,f.jsx)("br",{}),"Professional developers use these to get the best ",(0,f.jsx)("b",{children:"performance"})," and the most out of RxDB."]}),(0,f.jsxs)("div",{className:"premium-blocks",children:[(0,f.jsx)("a",{href:"/rx-storage-opfs.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-right-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage OPFS"}),(0,f.jsxs)("p",{children:["Currently the fastest RxStorage that can be used in the browser. Based on the ",(0,f.jsx)("b",{children:"File System Access API"}),"."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-indexeddb.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage IndexedDB"}),(0,f.jsxs)("p",{children:["A really fast storage based on ",(0,f.jsx)("b",{children:"IndexedDB"}),". Made to be used in browsers."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-sqlite.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-right-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage SQLite"}),(0,f.jsxs)("p",{children:["A really fast storage based on ",(0,f.jsx)("b",{children:"SQLite"}),". Used with"," ",(0,f.jsx)("b",{children:"Node.js"}),", ",(0,f.jsx)("b",{children:"Electron"}),", ",(0,f.jsx)("b",{children:"React Native"}),", ",(0,f.jsx)("b",{children:"Capacitor"}),"."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-sharding.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage Sharding"}),(0,f.jsx)("p",{children:"A wrapper around any other storage that improves performance by applying the sharding technique."})]})})}),(0,f.jsx)("a",{href:"/rx-storage-memory-synced.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage Memory Synced"}),(0,f.jsx)("p",{children:"A wrapper around any other storage that creates a synced in-memory copy which improves performance for the initial page load time and write & read operations."})]})})}),(0,f.jsx)("a",{href:"/query-optimizer.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-right-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"Query Optimizer"}),(0,f.jsx)("p",{children:"A tool to find the best index for a given query. You can use this during build time to find the best index and then use that index during runtime."})]})})}),(0,f.jsx)("a",{href:"/rx-storage-localstorage-meta-optimizer.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage Localstorage Meta Optimizer"}),(0,f.jsxs)("p",{children:["A wrapper around any other storage which optimizes the initial page load one by using localstorage for meta key-value document. Only works in ",(0,f.jsx)("b",{children:"browsers"}),"."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-shared-worker.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-right-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage SharedWorker"}),(0,f.jsxs)("p",{children:["A RxStorage wrapper to run the storage inside of a SharedWorker which improves the performance by taking CPU load away from the main process. Used in ",(0,f.jsx)("b",{children:"browsers"}),"."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-worker.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage Worker"}),(0,f.jsx)("p",{children:"A RxStorage wrapper to run the storage inside of a Worker which improves the performance by taking CPU load away from the main process."})]})})}),(0,f.jsx)("a",{href:"/encryption.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-right-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"WebCrypto Encryption"}),(0,f.jsx)("p",{children:"A faster and more secure encryption plugin based on the Web Crypto API."})]})})}),(0,f.jsx)("a",{href:"/rx-storage-filesystem-node.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"RxStorage Filesystem Node"}),(0,f.jsxs)("p",{children:["A fast RxStorage based on the ",(0,f.jsx)("b",{children:"Node.js"})," Filesystem."]})]})})}),(0,f.jsx)("a",{href:"/logger.html",target:"_blank",children:(0,f.jsx)("div",{className:"premium-block hover-shadow-middle bg-gradient-right-top",children:(0,f.jsxs)("div",{className:"premium-block-inner",children:[(0,f.jsx)("h4",{children:"Logger"}),(0,f.jsx)("p",{children:"A logging plugin useful to debug performance problems and for monitoring with Application Performance Monitoring (APM) tools like Bugsnag, Datadog, Elastic, Sentry and others"})]})})})]})]})}),(0,f.jsx)("div",{className:"block dark",id:"faq",children:(0,f.jsxs)("div",{className:"content centered premium-faq",children:[(0,f.jsxs)("h2",{children:["F.A.Q. ",(0,f.jsx)("b",{children:"(click to toggle)"})]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Do I need the Premium Plugins?"}),"When you start using RxDB, you do not need access to the premium plugins. Most use cases can be implemented with the Open Core part of RxDB. There are many"," ",(0,f.jsx)("a",{href:"/rx-storage.html",target:"_blank",children:"RxStorage"}),"options and all core plugins that are required for replication, schema validation, encryption and so on, are totally free. As soon as your application is more then a side project, it is pretty easy to switch to RxDB Premium Plugins by just changing a few lines of configuration.",(0,f.jsx)("br",{}),"The main benefit of the Premium Plugins is ",(0,f.jsx)("b",{children:"performance"}),". The Premium RxStorage implementations have a better performance so reading and writing data is much faster especially on low-end devices. You can find a performance comparison"," ",(0,f.jsx)("a",{href:"/rx-storage-performance.html",target:"_blank",children:"here"}),". Also there are additional Premium Plugins that can be used to further optimize the performance of your application like the"," ",(0,f.jsx)("a",{href:"/query-optimizer.html",target:"_blank",children:"Query Optimizer"})," ","or the"," ",(0,f.jsx)("a",{href:"/rx-storage-sharding.html",target:"_blank",children:"Sharding"})," ","plugin."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Why is it not for free?"}),"The development of RxDB started in 2016 and after all these years it became clear that big implementation and improvement steps will not be done by the RxDB community. While the community submits valuable pull requests, they are mostly small improvements or bugfixes for specific edge case. Big rewrites and optimizations that require a big effort have only be done by the RxDB maintainer.",(0,f.jsx)("br",{}),"Selling RxDB Premium ensures that there will be always an incentive for someone to add features, keep everything up to date and to further improve and optimize the codebase. This gives the user the confidence that RxDB is a ",(0,f.jsx)("b",{children:"future proof"})," tech stack to build on which lets RxDB stand out compared to similar technologies."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Why is there no free trial period?"}),(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:"RxDB is written in JavaScript and the code of the Premium Plugins does not contain any tracking or measurement code that would send information from your application to our servers in production mode. As soon as someone has the code on his computer, the maintainer has no chance to really ensure that after a free trial period the code is no longer used and deleted."}),(0,f.jsxs)("li",{children:["Before you can use the Premium Plugins you have to debate and sign a license agreement with the maintainer. This is a sophisticated process that creates overhead which distracts the maintainer from writing RxDB code. So handling trial period users is just not manageable. For this reason there is also no monthly subscriptions. Premium access must be paid ",(0,f.jsx)("b",{children:"per year"}),"."]})]})]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Why is it not cheaper?"}),"The price of the Premium Plugins is chosen in way that ensures that there can be always one person that develops RxDB ",(0,f.jsx)("b",{children:"full time"}),". Compared to other JavaScript frameworks and developer tools, RxDB satisfies an edge use case for people that want to store data inside of their application on the users device. Most web developers do not need to do that and rely on the traditional client-server stack. So RxDB cannot be sold to that many people which increases the price."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Can I install/build the premium plugins in my CI?"}),(0,f.jsx)("b",{children:"Yes"})," you can safely install and use the Premium Plugins in your CI without additional payment."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Can I get a discount?"}),"Discounts are provided for people that have made a significant contribution to RxDB or one of RxDB's dependencies or to the Open Source Community overall. Also for private personal projects there is the option to solve one of the",(0,f.jsx)("a",{href:"https://github.com/pubkey/rxdb/blob/master/orga/premium-tasks.md",target:"_blank",children:"Premium Tasks"}),"to get 3 years access to the Premium Plugins."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Which payment methods are accepted?"}),(0,f.jsx)("b",{children:"Stripe.com"})," is used as payment processor so most known payment options like credit card, PayPal, SEPA transfer and others are available. A list of all options can be found"," ",(0,f.jsx)("a",{href:"https://stripe.com/docs/payments/payment-methods/overview",title:"stripe payment options",target:"_blank",children:"here"}),"."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Can I still use the premium plugins when the license has expired?"}),"By default you are not allowed to use the premium plugins after the license has expired and you will no longer be able to install them. But you can choose the ",(0,f.jsx)("b",{children:"Perpetual license"})," option. With the perpetual license option, you can still use the plugins even after the license is expired. But you will no longer get any updates from newer RxDB versions."]}),(0,f.jsxs)("details",{children:[(0,f.jsx)("summary",{children:"Is there any tracking code inside of the premium plugins?"}),'No, the premium plugins themself do not contain any tracking code. When you build your application with RxDB and deploy it to production, it will not make requests to any RxDB server. But when you run "npm install" with the premium package there will be some metadata send from your developers machine to RxDB.']})]})}),(0,f.jsxs)("div",{className:"block",children:[(0,f.jsxs)("div",{className:"content centered",children:[(0,f.jsxs)("h2",{children:["RxDB Premium ",(0,f.jsx)("b",{className:"underline",children:"Price Calculator"})]}),(0,f.jsx)("div",{className:"price-calculator",children:(0,f.jsxs)("div",{className:"price-calculator-inner",children:[(0,f.jsxs)("form",{id:"price-calculator-form",children:[(0,f.jsxs)("div",{className:"field",children:[(0,f.jsx)("label",{htmlFor:"home-country",children:"Company Home Country:"}),(0,f.jsxs)("div",{className:"input",children:[(0,f.jsx)("input",{list:"home-country",name:"home-country",pattern:"[A-Za-z \\-]{2,}",required:!0,style:{width:"100%",maxWidth:240},autoComplete:"off"}),(0,f.jsx)("datalist",{id:"home-country",children:l.sort(((e,t)=>e.code>=t.code?1:-1)).map(((e,t)=>(0,f.jsx)("option",{value:e.name,children:e.name},t)))})]})]}),(0,f.jsxs)("div",{className:"field",children:[(0,f.jsx)("label",{htmlFor:"company-size",children:"Company Size:"}),(0,f.jsxs)("div",{className:"input",children:[(0,f.jsx)("input",{type:"number",name:"company-size",min:1,max:1e6,required:!0,onKeyDown:()=>{const e=(0,o.Is)(event);return 69!==e.keyCode&&189!==e.keyCode&&190!==e.keyCode}}),(0,f.jsx)("div",{className:"suffix",children:"employee(s)"})]})]}),(0,f.jsxs)("div",{className:"field",children:[(0,f.jsx)("label",{htmlFor:"project-amount",children:"Project Amount:"}),(0,f.jsxs)("div",{className:"input",children:[(0,f.jsxs)("select",{name:"project-amount",id:"project-amount",required:!0,defaultValue:1,children:[(0,f.jsx)("option",{value:1,children:"1"}),(0,f.jsx)("option",{value:2,children:"2"}),(0,f.jsx)("option",{value:"infinity",children:"Infinity"})]}),(0,f.jsx)("div",{className:"suffix",children:"project(s)"})]})]}),(0,f.jsxs)("div",{className:"packages",children:[(0,f.jsx)("h3",{children:"Packages:"}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("input",{name:"package-browser",type:"checkbox",className:"package-checkbox",defaultChecked:!0}),(0,f.jsx)("h4",{children:"Browser Package"}),(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-opfs.html",target:"_blank",children:"RxStorage OPFS"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-indexeddb.html",target:"_blank",children:"RxStorage IndexedDB"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-worker.html",target:"_blank",children:"RxStorage Worker"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/encryption.html",target:"_blank",children:"WebCrypto Encryption"})})]})]})}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("input",{name:"package-native",type:"checkbox",className:"package-checkbox",defaultChecked:!0}),(0,f.jsx)("h4",{children:"Native Package"}),(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-sqlite.html",target:"_blank",children:"RxStorage SQLite"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-filesystem-node.html",target:"_blank",children:"RxStorage Filesystem Node"})})]})]})}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("input",{name:"package-performance",type:"checkbox",className:"package-checkbox",defaultChecked:!0}),(0,f.jsx)("h4",{children:"Performance Package"}),(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-sharding.html",target:"_blank",children:"RxStorage Sharding"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-memory-synced.html",target:"_blank",children:"RxStorage Memory Synced"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/query-optimizer.html",target:"_blank",children:"Query Optimizer"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-localstorage-meta-optimizer.html",target:"_blank",children:"RxStorage Localstorage Meta Optimizer"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-storage-shared-worker.html",target:"_blank",children:"RxStorage Shared Worker"})})]})]})}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("input",{name:"package-utilities",type:"checkbox",className:"package-checkbox",defaultChecked:!0,disabled:!0}),(0,f.jsxs)("h4",{children:["Utilities Package ",(0,f.jsx)("b",{children:"always included"})]}),(0,f.jsx)("ul",{children:(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/logger.html",target:"_blank",children:"Logger"})})})]})}),(0,f.jsx)("div",{className:"clear"}),(0,f.jsx)("h3",{children:"Other Options:"}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("input",{name:"package-sourcecode",type:"checkbox",className:"package-checkbox"}),(0,f.jsx)("h4",{children:"Source Code access"}),(0,f.jsxs)("p",{children:["Get read access to the unminified plain source code of all purchased packages.",(0,f.jsx)("br",{})]})]})}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("input",{name:"package-perpetual",type:"checkbox",className:"package-checkbox"}),(0,f.jsx)("h4",{children:"Perpetual license"}),(0,f.jsxs)("p",{children:["With the perpetual license option, you can still use the plugins even after the license is expired. But you will no longer get any updates from newer RxDB versions.",(0,f.jsx)("br",{})]})]})}),(0,f.jsx)("div",{className:"package bg-gradient-left-top",children:(0,f.jsxs)("div",{className:"package-inner",children:[(0,f.jsx)("h4",{children:"Increase license period"}),(0,f.jsxs)("p",{children:["The default license period is one year. We can do a longer license period to safe time on both sides by not having to go through the licensing process each single year. By choosing a license period of 2 years, you get a 10% discount. With a 3 year license the discount is 20%.",(0,f.jsx)("br",{})]}),(0,f.jsxs)("div",{className:"field",children:[(0,f.jsxs)("div",{className:"input",style:{float:"left",width:"100%"},children:[(0,f.jsx)("div",{className:"prefix",children:"License period "}),(0,f.jsxs)("select",{name:"license-period",id:"license-period",required:!0,defaultValue:1,children:[(0,f.jsx)("option",{value:1,children:"1"}),(0,f.jsx)("option",{value:2,children:"2 (10% discount)"}),(0,f.jsx)("option",{value:3,children:"3 (20% discount)"})]}),(0,f.jsx)("div",{className:"suffix",children:"year(s)"})]}),(0,f.jsx)("div",{className:"clear"})]}),(0,f.jsx)("p",{})]})}),(0,f.jsx)("div",{className:"clear"})]}),(0,f.jsx)("div",{className:"button",id:"price-calculator-submit",onClick:async()=>{(0,d.X)("calculate_premium_price",3);const e=(0,o.Is)(document.getElementById("price-calculator-form"));if(!e.reportValidity())return void console.log("form not valid");const t=new FormData(e),r=Object.fromEntries(t.entries());console.log("formData:"),console.dir(r);const a=l.find((e=>e.name.toLowerCase()===r["home-country"].toLowerCase()));if(!a)return;const n=Object.entries(r).filter((e=>{let[t,r]=e;return t.startsWith("package-")})).map((e=>{let[t]=e;return(0,c.SI)(t.split("-"))})),i=await(0,m.N8)();await i.upsertLocal(v,{companySize:r["company-size"],projectAmount:r["project-amount"],licensePeriod:r["license-period"],homeCountry:a.name,packages:n});const s={companySize:r["company-size"],teamSize:r["developer-count"],projectAmount:r["project-amount"],licensePeriod:parseInt(r["license-period"],10),homeCountryCode:a.code,packages:n},p=function(e){if(console.log("calculatePrice:"),console.dir(e),"number"!=typeof e.licensePeriod)throw new Error("not a number "+typeof e.licensePeriod);const t=(0,o.Is)(l.find((t=>t.code===e.homeCountryCode))).salary;let r=0;e.packages.forEach((e=>{const t=u[e];r+=t})),console.log("aimInPercent: "+r);let a=350+1.4*t*(r/100);if(2===e.packages.length&&(a*=.9),e.packages.length>2&&(a*=.85),e.companySize>1){let t=1+Math.pow(1*e.companySize-1,.95)/100*4.5;const r=6;t>r&&(t=r),console.log("input.companySize "+e.companySize+" - "+t),a*=t}if(e.packages.includes("sourcecode")){a*=1.75;const e=1520;a{console.log("setPrice:"),console.dir(t),e.innerHTML=Math.ceil(t).toString()+" € (EUR)",e.href=function(e){return"https://www.xe.com/en/currencyconverter/convert/?Amount="+e+"&From=EUR&To=USD"}(Math.ceil(t))},w=p.totalPrice/s.licensePeriod;x(y,"infinity"!==s.projectAmount?w/parseInt(s.projectAmount,10)/12:0),x(g,w),x(b,p.totalPrice),f.style.display="block"},children:"Estimate Price"})]}),(0,f.jsxs)("div",{id:"price-calculator-result",style:{display:"none"},children:[(0,f.jsx)("hr",{}),(0,f.jsx)("h4",{children:"Estimated Price:"}),(0,f.jsx)("table",{children:(0,f.jsxs)("tbody",{children:[(0,f.jsxs)("tr",{children:[(0,f.jsx)("th",{children:"Price Per Project per Month"}),(0,f.jsx)("td",{children:(0,f.jsx)("a",{id:"total-per-project-per-month",target:"_blank",rel:"nofollow noopener noreferrer",title:"Click to convert to other currency",href:"#",children:"XX \u20ac"})})]}),(0,f.jsxs)("tr",{children:[(0,f.jsx)("th",{children:"Total Price per Year"}),(0,f.jsx)("td",{children:(0,f.jsx)("a",{id:"total-per-year",target:"_blank",rel:"nofollow noopener noreferrer",title:"Click to convert to other currency",href:"#",children:"XX \u20ac"})})]}),(0,f.jsxs)("tr",{children:[(0,f.jsx)("th",{children:"Total Price"}),(0,f.jsx)("td",{children:(0,f.jsx)("a",{id:"total-price",target:"_blank",rel:"nofollow noopener noreferrer",title:"Click to convert to other currency",href:"#",children:"XX \u20ac"})})]})]})}),(0,f.jsxs)("div",{className:"proceed-hint",children:["Fill out",(0,f.jsxs)("a",{href:"#premium-request-form-block",children:[" ",(0,f.jsx)("b",{children:"this form"})," "]}),"to proceed."]})]})]})})]}),(0,f.jsx)("div",{className:"block dark",id:"premium-request-form-block",children:(0,f.jsxs)("div",{className:"content centered premium-request",children:[(0,f.jsxs)("h2",{children:["Request Premium ",(0,f.jsx)("b",{className:"underline",children:"Form"})]}),(0,f.jsx)("p",{}),(0,f.jsx)(y,{fallback:(0,f.jsx)("span",{children:"Loading form iframe..."}),children:()=>(0,f.jsxs)("iframe",{id:"request-premium-form",src:"https://webforms.pipedrive.com/f/6qflURDWONiPpj67lpG6r45n8feakrtS2AqMRcBf1EuCPRvNcXWdvNH2unFm5EpjW3",children:["Your browser doesn't support iframes, ",(0,f.jsx)("a",{href:"https://webforms.pipedrive.com/f/6qflURDWONiPpj67lpG6r45n8feakrtS2AqMRcBf1EuCPRvNcXWdvNH2unFm5EpjW3",target:"_blank",rel:"nofollow",children:"go here"})]})})]})})]})]})})]})}function b(e,t){if(void 0===t)return;const r=document.querySelector("[name="+e+"]");r&&(r.type&&"checkbox"===r.type?r.checked=t:r.value=t)}},6087:(e,t,r)=>{function a(e){return e[e.length-1]}function n(e){return Array.isArray(e)?e.slice(0):[e]}function i(e){return Array.isArray(e)}function s(e){return null!=e}function o(e,t){var r=0,a=-1;for(var n of e){if(!t(n,a+=1))break;r+=1}return r}function c(e,t){for(var r=t.length,a=0;ai,Nb:()=>l,S7:()=>s,SI:()=>a,gu:()=>c,qo:()=>n,r0:()=>o})},7400:(e,t,r)=>{function a(e,t){if(!e)throw t||(t=""),new Error("ensureNotFalsy() is falsy: "+t);return e}r.d(t,{Is:()=>a,kv:()=>n});var n={bufferSize:1,refCount:!0}},4419:(e,t,r)=>{function a(){return new Promise((e=>setTimeout(e,0)))}function n(e){return void 0===e&&(e=0),new Promise((t=>setTimeout(t,e)))}r.d(t,{$Y:()=>o,C2:()=>u,Y3:()=>a,YB:()=>n,Ze:()=>h,kZ:()=>i,m5:()=>s,y$:()=>c});Promise.resolve(!0);var i=Promise.resolve(!1),s=Promise.resolve(null),o=Promise.resolve();function c(e){return void 0===e&&(e=1e4),"function"==typeof requestIdleCallback?new Promise((t=>{requestIdleCallback((()=>t()),{timeout:e})})):n(0)}var l=o;function u(e){return void 0===e&&(e=void 0),l=l.then((()=>c(e)))}function h(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},984:(e,t,r)=>{r.d(t,{z:()=>n});var a=0;function n(){var e=Date.now();(e+=.01)<=a&&(e=a+.01);var t=parseFloat(e.toFixed(2));return a=t,t}}}]);
\ No newline at end of file
diff --git a/docs/assets/js/1df93b7f.5d342824.js b/docs/assets/js/1df93b7f.937c5c7c.js
similarity index 99%
rename from docs/assets/js/1df93b7f.5d342824.js
rename to docs/assets/js/1df93b7f.937c5c7c.js
index e6597e3f063..1581f812d83 100644
--- a/docs/assets/js/1df93b7f.5d342824.js
+++ b/docs/assets/js/1df93b7f.937c5c7c.js
@@ -1 +1 @@
-"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[3237],{5921:(e,t,r)=>{r.d(t,{O9:()=>zr,N8:()=>Hr,dZ:()=>Fr});var a=r(8061);function n(e,t){var r=e.get(t);if(void 0===r)throw new Error("missing value from map "+t);return r}function s(e,t,r,a){var n=e.get(t);return void 0===n?(n=r(),e.set(t,n)):a&&a(n),n}function i(e){return Object.assign({},e)}function o(e,t){if(void 0===t&&(t=!1),!e)return e;if(!t&&Array.isArray(e))return e.sort(((e,t)=>"string"==typeof e&&"string"==typeof t?e.localeCompare(t):"object"==typeof e?1:-1)).map((e=>o(e,t)));if("object"==typeof e&&!Array.isArray(e)){var r={};return Object.keys(e).sort(((e,t)=>e.localeCompare(t))).forEach((a=>{r[a]=o(e[a],t)})),r}return e}var c=function e(t){if(!t)return t;if(null===t||"object"!=typeof t)return t;if(Array.isArray(t)){for(var r=new Array(t.length),a=r.length;a--;)r[a]=e(t[a]);return r}var n={};for(var s in t)n[s]=e(t[s]);return n};function l(e,t,r){return Object.defineProperty(e,t,{get:function(){return r}}),r}var u=e=>{var t=typeof e;return null!==e&&("object"===t||"function"===t)},h=new Set(["__proto__","prototype","constructor"]),d=new Set("0123456789");function m(e){var t=[],r="",a="start",n=!1;for(var s of e)switch(s){case"\\":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");n&&(r+=s),a="property",n=!n;break;case".":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="property";break}if(n){n=!1,r+=s;break}if(h.has(r))return[];t.push(r),r="",a="property";break;case"[":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="index";break}if(n){n=!1,r+=s;break}if("property"===a){if(h.has(r))return[];t.push(r),r=""}a="index";break;case"]":if("index"===a){t.push(Number.parseInt(r,10)),r="",a="indexEnd";break}if("indexEnd"===a)throw new Error("Invalid character after an index");default:if("index"===a&&!d.has(s))throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");"start"===a&&(a="property"),n&&(n=!1,r+="\\"),r+=s}switch(n&&(r+="\\"),a){case"property":if(h.has(r))return[];t.push(r);break;case"index":throw new Error("Index was not closed");case"start":t.push("")}return t}function p(e,t){if("number"!=typeof t&&Array.isArray(e)){var r=Number.parseInt(t,10);return Number.isInteger(r)&&e[r]===e[t]}return!1}function f(e,t){if(p(e,t))throw new Error("Cannot use string index")}function v(e,t,r){if(Array.isArray(t)&&(t=t.join(".")),!t.includes(".")&&!t.includes("["))return e[t];if(!u(e)||"string"!=typeof t)return void 0===r?e:r;var a=m(t);if(0===a.length)return r;for(var n=0;n!1,deepFreezeWhenDevMode:e=>e,tunnelErrorMessage:e=>"RxDB Error-Code "+e+".\n Error messages are not included in RxDB core to reduce build size.\n - To find out what this error means, either use the dev-mode-plugin https://rxdb.info/dev-mode.html\n - or search for the error code here: https://github.com/pubkey/rxdb/search?q="+e+"\n "};function k(e,t,r){return"RxError ("+t+"):\n"+e+"\n"+function(e){var t="";return 0===Object.keys(e).length?t:(t+="Given parameters: {\n",t+=Object.keys(e).map((t=>{var r="[object Object]";try{r="errors"===t?e[t].map((e=>JSON.stringify(e,Object.getOwnPropertyNames(e)))):JSON.stringify(e[t],(function(e,t){return void 0===t?null:t}),2)}catch(a){}return t+":"+r})).join("\n"),t+="}")}(r)}var _=function(e){function t(t,r,a){var n;void 0===a&&(a={});var s=k(r,t,a);return(n=e.call(this,s)||this).code=t,n.message=s,n.parameters=a,n.rxdb=!0,n}return(0,x.Z)(t,e),t.prototype.toString=function(){return this.message},(0,b.Z)(t,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),t}((0,w.Z)(Error)),D=function(e){function t(t,r,a){var n;void 0===a&&(a={});var s=k(r,t,a);return(n=e.call(this,s)||this).code=t,n.message=s,n.parameters=a,n.rxdb=!0,n}return(0,x.Z)(t,e),t.prototype.toString=function(){return this.message},(0,b.Z)(t,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),t}((0,w.Z)(TypeError));function N(e,t){return new _(e,j.tunnelErrorMessage(e),t)}function I(e,t){return new D(e,j.tunnelErrorMessage(e),t)}function E(e){return!(!e||409!==e.status)&&e}var C={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var R=/\./g,O="abcdefghijklmnopqrstuvwxyz";function S(e){void 0===e&&(e=10);for(var t="",r=0;r{var r=v(t,e);if(void 0===r)throw N("DOC18",{args:{field:e,documentData:t}});return r})).join(r.separator)}function Q(e){var t=A((e=i(e)).primaryKey);e.properties=i(e.properties),e.additionalProperties=!1,Object.prototype.hasOwnProperty.call(e,"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=W,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=F(e);(0,y.gu)(e.required,r),e.required=e.required.filter((e=>!e.includes("."))).filter(((e,t,r)=>r.indexOf(e)===t)),e.version=e.version||0;var a=e.indexes.map((e=>{var r=(0,y.AD)(e)?e.slice(0):[e];return r.includes(t)||r.push(t),"_deleted"!==r[0]&&r.unshift("_deleted"),r}));0===a.length&&a.push(function(e){return["_deleted",e]}(t)),a.push(["_meta.lwt",t]),e.internalIndexes&&e.internalIndexes.map((e=>{a.push(e)}));var n=new Set;return a.filter((e=>{var t=e.join(",");return!n.has(t)&&(n.add(t),!0)})),e.indexes=a,e}var W={type:"object",properties:{lwt:{type:"number",minimum:$,maximum:1e15,multipleOf:.01}},additionalProperties:!0,required:["lwt"]};function F(e){var t=Object.keys(e.properties).filter((t=>e.properties[t].final)),r=A(e.primaryKey);return t.push(r),"string"!=typeof e.primaryKey&&e.primaryKey.fields.forEach((e=>t.push(e))),t}var H="docs",z="changes",K="attachments",U="dexie",Z=new Map,J=new Map;var V="__";function X(e){var t=e.split(".");if(t.length>1)return t.map((e=>X(e))).join(".");if(e.startsWith("|")){var r=e.substring(1);return V+r}return e}function Y(e){var t=e.split(".");return t.length>1?t.map((e=>Y(e))).join("."):e.startsWith(V)?"|"+e.substring(V.length):e}function G(e,t){return t?(t=te(t=i(t)),e.forEach((e=>{var r=v(t,e);g(t,e,r?"1":"0")})),t):t}function ee(e,t){return t?(t=re(t=i(t)),e.forEach((e=>{var r=v(t,e);g(t,e,"1"===r)})),t):t}function te(e){if(!e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(Array.isArray(e))return e.map((e=>te(e)));if("object"==typeof e){var t={};return Object.entries(e).forEach((e=>{let[r,a]=e;"object"==typeof a&&(a=te(a)),t[X(r)]=a})),t}}function re(e){if(!e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(Array.isArray(e))return e.map((e=>re(e)));if("object"==typeof e){var t={};return Object.entries(e).forEach((r=>{let[a,n]=r;("object"==typeof n||Array.isArray(e))&&(n=re(n)),t[Y(a)]=n})),t}}function ae(e){var t=[],r=A(e.primaryKey);t.push([r]),t.push(["_deleted",r]),e.indexes&&e.indexes.forEach((e=>{var r=(0,y.qo)(e);t.push(r)})),t.push(["_meta.lwt",r]),t.push(["_meta.lwt"]);var a=(t=t.map((e=>e.map((e=>X(e)))))).map((e=>1===e.length?e[0]:"["+e.join("+")+"]"));return(a=a.filter(((e,t,r)=>r.indexOf(e)===t))).join(", ")}async function ne(e,t){var r=await e;return(await r.dexieTable.bulkGet(t)).map((e=>ee(r.booleanIndexes,e)))}function se(e,t){return e+"||"+t}function ie(e){var t=new Set,r=[];return e.indexes?(e.indexes.forEach((a=>{(0,y.qo)(a).forEach((a=>{t.has(a)||(t.add(a),"boolean"===q(e,a).type&&r.push(a))}))})),r.push("_deleted"),(0,y.Nb)(r)):r}var oe=r(6974),ce=r(984),le=r(7400),ue=String.fromCharCode(65535),he=Number.MIN_SAFE_INTEGER;function de(e,t){var r=t.selector,a=e.indexes?e.indexes.slice(0):[];t.index&&(a=[t.index]);var n=!!t.sort.find((e=>"desc"===Object.values(e)[0])),s=new Set;Object.keys(r).forEach((t=>{var a=q(e,t);a&&"boolean"===a.type&&Object.prototype.hasOwnProperty.call(r[t],"$eq")&&s.add(t)}));var i,o=t.sort.map((e=>Object.keys(e)[0])).filter((e=>!s.has(e))).join(","),c=-1;if(a.forEach((e=>{var a=!0,l=!0,u=e.map((e=>{var t=r[e],n=t?Object.keys(t):[],s={};t&&n.length?n.forEach((e=>{if(me.has(e)){var r=function(e,t){switch(e){case"$eq":return{startKey:t,endKey:t,inclusiveEnd:!0,inclusiveStart:!0};case"$lte":return{endKey:t,inclusiveEnd:!0};case"$gte":return{startKey:t,inclusiveStart:!0};case"$lt":return{endKey:t,inclusiveEnd:!1};case"$gt":return{startKey:t,inclusiveStart:!1};default:throw new Error("SNH")}}(e,t[e]);s=Object.assign(s,r)}})):s={startKey:l?he:ue,endKey:a?ue:he,inclusiveStart:!0,inclusiveEnd:!0};return void 0===s.startKey&&(s.startKey=he),void 0===s.endKey&&(s.endKey=ue),void 0===s.inclusiveStart&&(s.inclusiveStart=!0),void 0===s.inclusiveEnd&&(s.inclusiveEnd=!0),l&&!s.inclusiveStart&&(l=!1),a&&!s.inclusiveEnd&&(a=!1),s})),h=u.map((e=>e.startKey)),d=u.map((e=>e.endKey)),m={index:e,startKeys:h,endKeys:d,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!s.has(e))).join(","),selectorSatisfiedByIndex:ve(e,t.selector,h,d)},p=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},s=10,i=(0,y.r0)(r.startKeys,(e=>e!==he&&e!==ue));n(i*s);var o=(0,y.r0)(r.startKeys,(e=>e!==ue&&e!==he));n(o*s);var c=(0,y.r0)(r.startKeys,((e,t)=>e===r.endKeys[t]));n(c*s*1.5);var l=r.sortSatisfiedByIndex?5:0;return n(l),a}(0,0,m);(p>=c||t.index)&&(c=p,i=m)})),!i)throw N("SNH",{query:t});return i}var me=new Set(["$eq","$gt","$gte","$lt","$lte"]),pe=new Set(["$eq","$gt","$gte"]),fe=new Set(["$eq","$lt","$lte"]);function ve(e,t,r,a){var n=Object.entries(t).find((t=>{let[r,a]=t;return!e.includes(r)||Object.entries(a).find((e=>{let[t,r]=e;return!me.has(t)}))}));if(n)return!1;if(t.$and||t.$or)return!1;var s=[],i=new Set;for(var[o,c]of Object.entries(t)){if(!e.includes(o))return!1;var l=Object.keys(c).filter((e=>pe.has(e)));if(l.length>1)return!1;var u=l[0];if(u&&i.add(o),"$eq"!==u){if(s.length>0)return!1;s.push(u)}}var h=[],d=new Set;for(var[m,p]of Object.entries(t)){if(!e.includes(m))return!1;var f=Object.keys(p).filter((e=>fe.has(e)));if(f.length>1)return!1;var v=f[0];if(v&&d.add(m),"$eq"!==v){if(h.length>0)return!1;h.push(v)}}var g=0;for(var y of e){for(var b of[i,d]){if(!b.has(y)&&b.size>0)return!1;b.delete(y)}if(r[g]!==a[g]&&i.size>0&&d.size>0)return!1;g++}return!0}var ge=r(6250),ye=r(7761),be=r(7132),xe=r(6496),we=r(6851),je=r(3516),ke=r(8039),_e=r(5308),De=r(2106),Ne=!1;function Ie(e){return Ne||((0,ye.Qs)(ye.$M.PIPELINE,{$sort:xe.E3,$project:xe.FM}),(0,ye.Qs)(ye.$M.QUERY,{$and:we.h$,$eq:je.l3,$elemMatch:_e.rr,$exists:De.G,$gt:je.ok,$gte:je.m9,$in:je.FI,$lt:je.Ty,$lte:je.HG,$ne:je.ny,$nin:je.IS,$mod:ke.JD,$nor:we.ps,$not:we._w,$or:we.Ko,$regex:ke.GO,$size:_e.QH,$type:De.e}),Ne=!0),new be.A(e)}function Ee(e,t){var r=A(e.primaryKey);t=i(t);var a=c(t);if("number"!=typeof a.skip&&(a.skip=0),a.selector?(a.selector=a.selector,Object.entries(a.selector).forEach((e=>{let[t,r]=e;"object"==typeof r&&null!==r||(a.selector[t]={$eq:r})}))):a.selector={},a.index){var n=(0,y.qo)(a.index);n.includes(r)||n.push(r),a.index=n}if(a.sort)a.sort.find((e=>{return t=e,Object.keys(t)[0]===r;var t}))||(a.sort=a.sort.slice(0),a.sort.push({[r]:"asc"}));else if(a.index)a.sort=a.index.map((e=>({[e]:"asc"})));else{if(e.indexes){var s=new Set;Object.entries(a.selector).forEach((e=>{let[t,r]=e;("object"!=typeof r||null===r||!!Object.keys(r).find((e=>me.has(e))))&&s.add(t)}));var o,l=-1;e.indexes.forEach((e=>{var t=(0,y.AD)(e)?e:[e],r=t.findIndex((e=>!s.has(e)));r>0&&r>l&&(l=r,o=t)})),o&&(a.sort=o.map((e=>({[e]:"asc"}))))}a.sort||(a.sort=[{[r]:"asc"}])}return a}function Ce(e,t){if(!t.sort)throw N("SNH",{query:t});var r=[];t.sort.forEach((e=>{var t,a,n,s=Object.keys(e)[0],i=Object.values(e)[0];r.push({key:s,direction:i,getValueFn:(t=s,a=t.split("."),n=a.length,1===n?e=>e[t]:e=>{for(var t=e,r=0;r{for(var a=0;ar.test(e)}function Oe(e){return e===he?-1/0:e}function Se(e,t,r){return e.includes(t)?r===ue||!0===r?"1":"0":r}function Pe(e,t,r){if(!r){if("undefined"==typeof window)throw new Error("IDBKeyRange missing");r=window.IDBKeyRange}var a=t.startKeys.map(((r,a)=>{var n=t.index[a];return Se(e,n,r)})).map(Oe),n=t.endKeys.map(((r,a)=>{var n=t.index[a];return Se(e,n,r)})).map(Oe);return r.bound(a,n,!t.inclusiveStart,!t.inclusiveEnd)}async function Be(e,t){var r=await e.internals,a=t.query,n=a.skip?a.skip:0,s=n+(a.limit?a.limit:1/0),i=t.queryPlan,o=!1;i.selectorSatisfiedByIndex||(o=Re(e.schema,t.query));var c=Pe(r.booleanIndexes,i,r.dexieDb._options.IDBKeyRange),l=i.index,u=[];if(await r.dexieDb.transaction("r",r.dexieTable,(async e=>{var t,a=e.idbtrans.objectStore(H);t="["+l.map((e=>X(e))).join("+")+"]";var n=a.index(t).openCursor(c);await new Promise((e=>{n.onsuccess=function(t){var a=t.target.result;if(a){var n=ee(r.booleanIndexes,a.value);o&&!o(n)||u.push(n),i.sortSatisfiedByIndex&&u.length===s?e():a.continue()}else e()}}))})),!i.sortSatisfiedByIndex){var h=Ce(e.schema,t.query);u=u.sort(h)}return{documents:u=u.slice(n,s)}}function $e(e){var t=e.split("-");if(2!==t.length)throw new Error("malformatted revision: "+e);return{height:parseInt(t[0],10),hash:t[1]}}function Te(e){return parseInt(e.split("-")[0],10)}function qe(e,t){var r=t?t._rev:null;return(r?$e(r).height:0)+1+"-"+e}var Me="_rxdb_internal";async function Ae(e,t){var r=(await e.findDocumentsById([t],!1))[0];return r||void 0}async function Le(e,t,r){var a=await e.bulkWrite([t],r);if(a.error.length>0)throw a.error[0];return a.success[0]}function Qe(e,t,r){var a=t.documentData,n=t.previousDocumentData;return{documentId:t.documentId,collectionName:r?r.name:void 0,isLocal:e,operation:t.operation,documentData:j.deepFreezeWhenDevMode(a),previousDocumentData:j.deepFreezeWhenDevMode(n)}}function We(e,t,r,a){if(a)throw 409===a.status?N("CONFLICT",{collection:e.name,id:t,writeError:a,data:r}):422===a.status?N("VD2",{collection:e.name,id:t,writeError:a,data:r}):a}function Fe(e){return{previous:e.previous,document:He(e.document)}}function He(e){if(!e._attachments||0===Object.keys(e._attachments).length)return e;var t=i(e);return t._attachments={},Object.entries(e._attachments).forEach((e=>{let[r,a]=e;var n,s,i;t._attachments[r]=(i=(n=a).data)?{length:(s=i,atob(s).length),digest:n.digest,type:n.type}:n})),t}function ze(e){var t=i(e);return t._meta=i(e._meta),t}function Ke(e,t,r){j.deepFreezeWhenDevMode(r);var a=A(r.primaryKey);var n={originalStorageInstance:t,schema:t.schema,internals:t.internals,collectionName:t.collectionName,databaseName:t.databaseName,options:t.options,bulkWrite(n,s){var o=n.map((n=>function(n){var s=i(n.document);if(s._meta=i(s._meta),j.isDevMode()){s=M(a,r,s);try{"function"==typeof structuredClone?structuredClone(n):JSON.parse(JSON.stringify(n))}catch(o){throw N("DOC24",{collection:t.collectionName,document:n.document})}n.previous,n.previous&&Object.keys(n.previous._meta).forEach((e=>{if(!Object.prototype.hasOwnProperty.call(n.document._meta,e))throw N("SNH",{dataBefore:n.previous,dataAfter:n.document})}))}return s._meta.lwt=(0,ce.z)(),s._rev=qe(e.token,n.previous),{document:s,previous:n.previous}}(n)));return e.lockedRun((()=>t.bulkWrite(o,s))).then((r=>{var a={error:[],success:r.success.slice(0)},n=r.error.filter((e=>!(409!==e.status||e.writeRow.previous||e.writeRow.document._deleted||!(0,le.Is)(e.documentInDb)._deleted)||(a.error.push(e),!1)));if(n.length>0){var i=n.map((t=>({previous:t.documentInDb,document:Object.assign({},t.writeRow.document,{_rev:qe(e.token,t.documentInDb)})})));return e.lockedRun((()=>t.bulkWrite(i,s))).then((e=>((0,y.gu)(a.error,e.error),(0,y.gu)(a.success,e.success),a)))}return r}))},query:r=>e.lockedRun((()=>t.query(r))),count:r=>e.lockedRun((()=>t.count(r))),findDocumentsById:(r,a)=>e.lockedRun((()=>t.findDocumentsById(r,a))),getAttachmentData:(r,a,n)=>e.lockedRun((()=>t.getAttachmentData(r,a,n))),getChangedDocumentsSince:t.getChangedDocumentsSince?(r,a)=>e.lockedRun((()=>t.getChangedDocumentsSince((0,le.Is)(r),a))):void 0,cleanup:r=>e.lockedRun((()=>t.cleanup(r))),remove:()=>(e.storageInstances.delete(n),e.lockedRun((()=>t.remove()))),close:()=>(e.storageInstances.delete(n),e.lockedRun((()=>t.close()))),changeStream:()=>t.changeStream(),conflictResultionTasks:()=>t.conflictResultionTasks(),resolveConflictResultionTask(e){if(e.output.isEqual)return t.resolveConflictResultionTask(e);var r=i(Object.assign({},e.output.documentData,{_meta:T(),_rev:"",_attachments:{}}));return delete r._meta,delete r._rev,delete r._attachments,t.resolveConflictResultionTask({id:e.id,output:{isEqual:!1,documentData:r}})}};return e.storageInstances.add(n),n}var Ue=r(5677),Ze=r(3981),Je=new Map;function Ve(e,t){var r=Je.get(e);if(r)return r.refs.delete(t),0===r.refs.size?(Je.delete(e),r.bc.close()):void 0}function Xe(e,t,r,a){if(t.multiInstance){var n=a||function(e,t,r,a){var n=Je.get(t);return n||(n={bc:new Ze.g0(["RxDB:",e,r].join("|")),refs:new Set},Je.set(t,n)),n.refs.add(a),n.bc}(e,t.databaseInstanceToken,r.databaseName,r),s=new oe.x,i=r=>{r.storageName===e&&r.databaseName===t.databaseName&&r.collectionName===t.collectionName&&r.version===t.schema.version&&s.next(r.eventBulk)};n.addEventListener("message",i);var o=r.changeStream(),c=!1,l=o.subscribe((r=>{c||n.postMessage({storageName:e,databaseName:t.databaseName,collectionName:t.collectionName,version:t.schema.version,eventBulk:r})}));r.changeStream=function(){return s.asObservable().pipe((0,Ue.b)(o))};var u=r.close.bind(r);r.close=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",i),a||await Ve(t.databaseInstanceToken,r),u()};var h=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",i),a||await Ve(t.databaseInstanceToken,r),h()}}}var Ye=(0,ce.z)(),Ge=function(){function e(e,t,r,a,n,s,i){this.changes$=new oe.x,this.instanceId=Ye++,this.storage=e,this.databaseName=t,this.collectionName=r,this.schema=a,this.internals=n,this.options=s,this.settings=i,this.primaryPath=A(this.schema.primaryKey)}var t=e.prototype;return t.bulkWrite=async function(e,t){tt(this),e.forEach((e=>{if(!e.document._rev||e.previous&&!e.previous._rev)throw N("SNH",{args:{row:e}})}));var r,a=await this.internals,n={success:[],error:[]},s=e.map((e=>e.document[this.primaryPath]));if(await a.dexieDb.transaction("rw",a.dexieTable,a.dexieAttachmentsTable,(async()=>{var i=new Map;(await ne(this.internals,s)).forEach((e=>{var t=e;return t&&i.set(t[this.primaryPath],t),t})),r=function(e,t,r,a,n,s,i){for(var o,c=!!e.schema.attachments,l=[],u=[],h=[],d={id:S(10),events:[],checkpoint:null,context:n,startTime:(0,ce.z)(),endTime:0},m=d.events,p=[],f=[],v=[],g=r.size>0,y=a.length,b=function(){var e,n=a[x],d=n.document,y=n.previous,b=d[t],w=d._deleted,j=y&&y._deleted,k=void 0;if(g&&(k=r.get(b)),k){var _=k._rev;if(!y||y&&_!==y._rev){var D={isError:!0,status:409,documentId:b,writeRow:n,documentInDb:k};return h.push(D),1}var I=c?Fe(n):n;c&&(w?y&&Object.keys(y._attachments).forEach((e=>{f.push({documentId:b,attachmentId:e,digest:(0,le.Is)(y)._attachments[e].digest})})):(Object.entries(d._attachments).find((t=>{let[r,a]=t;return(y?y._attachments[r]:void 0)||a.data||(e={documentId:b,documentInDb:k,isError:!0,status:510,writeRow:n,attachmentId:r}),!0})),e||Object.entries(d._attachments).forEach((e=>{let[t,r]=e;var a=y?y._attachments[t]:void 0;if(a){var n=I.document._attachments[t].digest;r.data&&a.digest!==n&&v.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})}else p.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})})))),e?h.push(e):(c?(u.push(Fe(I)),i&&i(d)):(u.push(I),i&&i(d)),o=I);var E=null,C=null,R=null;if(j&&!w)R="INSERT",E=c?He(d):d;else if(!y||j||w){if(!w)throw N("SNH",{args:{writeRow:n}});R="DELETE",E=(0,le.Is)(d),C=y}else R="UPDATE",E=c?He(d):d,C=y;var O={documentId:b,documentData:E,previousDocumentData:C,operation:R};m.push(O)}else{var S=!!w;if(c&&Object.entries(d._attachments).forEach((t=>{let[r,a]=t;a.data?p.push({documentId:b,attachmentId:r,attachmentData:a,digest:a.digest}):(e={documentId:b,isError:!0,status:510,writeRow:n,attachmentId:r},h.push(e))})),e||(c?(l.push(Fe(n)),s&&s(d)):(l.push(n),s&&s(d)),o=n),!S){var P={documentId:b,operation:"INSERT",documentData:c?He(d):d,previousDocumentData:c&&y?He(y):y};m.push(P)}}},x=0;x{n.success.push(e.document),o.push(e.document)})),r.bulkUpdateDocs.forEach((e=>{n.success.push(e.document),o.push(e.document)})),(o=o.map((e=>G(a.booleanIndexes,e)))).length>0&&await a.dexieTable.bulkPut(o);var c=[];r.attachmentsAdd.forEach((e=>{c.push({id:se(e.documentId,e.attachmentId),data:e.attachmentData.data})})),r.attachmentsUpdate.forEach((e=>{c.push({id:se(e.documentId,e.attachmentId),data:e.attachmentData.data})})),await a.dexieAttachmentsTable.bulkPut(c),await a.dexieAttachmentsTable.bulkDelete(r.attachmentsRemove.map((e=>se(e.documentId,e.attachmentId))))})),(r=(0,le.Is)(r)).eventBulk.events.length>0){var i=(0,le.Is)(r.newestRow).document;r.eventBulk.checkpoint={id:i[this.primaryPath],lwt:i._meta.lwt},r.eventBulk.endTime=(0,ce.z)(),this.changes$.next(r.eventBulk)}return n},t.findDocumentsById=async function(e,t){tt(this);var r=await this.internals,a=[];return await r.dexieDb.transaction("r",r.dexieTable,(async()=>{(await ne(this.internals,e)).forEach((e=>{!e||e._deleted&&!t||a.push(e)}))})),a},t.query=function(e){return tt(this),Be(this,e)},t.count=async function(e){if(e.queryPlan.selectorSatisfiedByIndex){var t=await async function(e,t){var r=await e.internals,a=t.queryPlan,n=a.index,s=Pe(r.booleanIndexes,a,r.dexieDb._options.IDBKeyRange),i=-1;return await r.dexieDb.transaction("r",r.dexieTable,(async e=>{var t,r=e.idbtrans.objectStore(H);t="["+n.map((e=>X(e))).join("+")+"]";var a=r.index(t).count(s);i=await new Promise(((e,t)=>{a.onsuccess=function(){e(a.result)},a.onerror=e=>t(e)}))})),i}(this,e);return{count:t,mode:"fast"}}return{count:(await Be(this,e)).documents.length,mode:"slow"}},t.changeStream=function(){return tt(this),this.changes$.asObservable()},t.cleanup=async function(e){tt(this);var t=await this.internals;return await t.dexieDb.transaction("rw",t.dexieTable,(async()=>{var r=(0,ce.z)()-e,a=await t.dexieTable.where("_meta.lwt").below(r).toArray(),n=[];a.forEach((e=>{"1"===e._deleted&&n.push(e[this.primaryPath])})),await t.dexieTable.bulkDelete(n)})),!0},t.getAttachmentData=async function(e,t,r){tt(this);var a=await this.internals,n=se(e,t);return await a.dexieDb.transaction("r",a.dexieAttachmentsTable,(async()=>{var r=await a.dexieAttachmentsTable.get(n);if(r)return r.data;throw new Error("attachment missing documentId: "+e+" attachmentId: "+t)}))},t.remove=async function(){tt(this);var e=await this.internals;return await e.dexieTable.clear(),this.close()},t.close=function(){return this.closed||(this.closed=(async()=>{this.changes$.complete(),await async function(e){var t=await e,r=J.get(e)-1;0===r?(t.dexieDb.close(),J.delete(e)):J.set(e,r)}(this.internals)})()),this.closed},t.conflictResultionTasks=function(){return new oe.x},t.resolveConflictResultionTask=async function(e){},e}();async function et(e,t,r){var n=function(e,t,r,n){var o="rxdb-dexie-"+e+"--"+n.version+"--"+t,c=s(Z,o,(()=>{var e=(async()=>{var e=i(r);e.autoOpen=!1;var t=new a.U(o,e),s={[H]:ae(n),[z]:"++sequence, id",[K]:"id"};return t.version(1).stores(s),await t.open(),{dexieDb:t,dexieTable:t[H],dexieAttachmentsTable:t[K],booleanIndexes:ie(n)}})();return Z.set(o,c),J.set(c,0),e}));return c}(t.databaseName,t.collectionName,r,t.schema),o=new Ge(e,t.databaseName,t.collectionName,t.schema,n,t.options,r);return await Xe(U,t,o),Promise.resolve(o)}function tt(e){if(e.closed)throw new Error("RxStorageInstanceDexie is closed "+e.databaseName+"-"+e.collectionName)}var rt="15.4.1",at=function(){function e(e){this.name=U,this.rxdbVersion=rt,this.settings=e}return e.prototype.createStorageInstance=function(e){return function(e){if(e.schema.keyCompression)throw N("UT5",{args:{params:e}});if((t=e.schema).encrypted&&t.encrypted.length>0||t.attachments&&t.attachments.encrypted)throw N("UT6",{args:{params:e}});var t;if(e.schema.attachments&&e.schema.attachments.compression)throw N("UT7",{args:{params:e}})}(e),et(this,e,this.settings)},e}();function nt(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var r,a;if(Array.isArray(e)){if((r=e.length)!==t.length)return!1;for(a=r;0!=a--;)if(!nt(e[a],t[a]))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 n=Object.keys(e);if((r=n.length)!==Object.keys(t).length)return!1;for(a=r;0!=a--;)if(!Object.prototype.hasOwnProperty.call(t,n[a]))return!1;for(a=r;0!=a--;){var s=n[a];if(!nt(e[s],t[s]))return!1}return!0}return e!=e&&t!=t}var st={preAddRxPlugin:[],preCreateRxDatabase:[],createRxDatabase:[],preCreateRxCollection:[],createRxCollection:[],postDestroyRxCollection:[],postRemoveRxCollection:[],preCreateRxSchema:[],createRxSchema:[],preCreateRxQuery:[],prePrepareQuery:[],createRxDocument:[],postCreateRxDocument:[],preCreateRxStorageInstance:[],preMigrateDocument:[],postMigrateDocument:[],preDestroyRxDatabase:[],postRemoveRxDatabase:[],preReplicationMasterWrite:[],preReplicationMasterWriteDocumentsHandle:[]};function it(e,t){st[e]&&st[e].forEach((e=>e(t)))}function ot(e,t){return Promise.all(st[e].map((e=>e(t))))}var ct=function(){function e(e,t){this.jsonSchema=e,this.hashFunction=t,this.indexes=function(e){return(e.indexes||[]).map((e=>(0,y.AD)(e)?e:[e]))}(this.jsonSchema),this.primaryPath=A(this.jsonSchema.primaryKey),this.finalFields=F(this.jsonSchema)}var t=e.prototype;return t.validateChange=function(e,t){this.finalFields.forEach((r=>{if(!nt(e[r],t[r]))throw N("DOC9",{dataBefore:e,dataAfter:t,fieldName:r,schema:this.jsonSchema})}))},t.getDocumentPrototype=function(){var e={},t=q(this.jsonSchema,"");return Object.keys(t).forEach((t=>{var r=t;e.__defineGetter__(t,(function(){if(this.get&&"function"==typeof this.get)return this.get(r)})),Object.defineProperty(e,t+"$",{get:function(){return this.get$(r)},enumerable:!1,configurable:!1}),Object.defineProperty(e,t+"_",{get:function(){return this.populate(r)},enumerable:!1,configurable:!1})})),l(this,"getDocumentPrototype",(()=>e)),e},t.getPrimaryOfDocumentData=function(e){return L(this.jsonSchema,e)},(0,b.Z)(e,[{key:"version",get:function(){return this.jsonSchema.version}},{key:"defaultValues",get:function(){var e={};return Object.entries(this.jsonSchema.properties).filter((e=>{let[,t]=e;return Object.prototype.hasOwnProperty.call(t,"default")})).forEach((t=>{let[r,a]=t;return e[r]=a.default})),l(this,"defaultValues",e)}},{key:"hash",get:function(){return l(this,"hash",this.hashFunction(JSON.stringify(this.jsonSchema)))}}]),e}();function lt(e,t,r){void 0===r&&(r=!0),r&&it("preCreateRxSchema",e);var a=Q(e);a=function(e){return o(e,!0)}(a),j.deepFreezeWhenDevMode(a);var n=new ct(a,t);return it("createRxSchema",n),n}var ut=r(598),ht=r(6621),dt=r(6728),mt=r(6005),pt=r(7570),ft=r(4419);function vt(e){var t=e.split("-"),r="RxDB";return t.forEach((e=>{r+=P(e)})),r+="Plugin",new Error("You are using a function which must be overwritten by a plugin.\n You should either prevent the usage of this function or add the plugin via:\n import { "+r+" } from 'rxdb/plugins/"+e+"';\n addRxPlugin("+r+");\n ")}function gt(e){return e.documentData?e.documentData:e.previousDocumentData}var yt=function(){function e(e,t,r,a){this.queueByDocId=new Map,this.isRunning=!1,this.storageInstance=e,this.primaryPath=t,this.preWrite=r,this.postWrite=a}var t=e.prototype;return t.addWrite=function(e,t){var r=e[this.primaryPath],a=s(this.queueByDocId,r,(()=>[]));return new Promise(((r,n)=>{var s={lastKnownDocumentState:e,modifier:t,resolve:r,reject:n};(0,le.Is)(a).push(s),this.triggerRun()}))},t.triggerRun=async function(){if(!0!==this.isRunning&&0!==this.queueByDocId.size){this.isRunning=!0;var e=[],t=this.queueByDocId;this.queueByDocId=new Map,await Promise.all(Array.from(t.entries()).map((async t=>{let[r,a]=t;var n,s,i,o=(n=a.map((e=>e.lastKnownDocumentState)),s=n[0],i=$e(s._rev).height,n.forEach((e=>{var t=$e(e._rev).height;t>i&&(s=e,i=t)})),s),l=o;for(var u of a)try{l=await u.modifier(c(l))}catch(h){u.reject(h),u.reject=()=>{},u.resolve=()=>{}}try{await this.preWrite(l,o)}catch(h){return void a.forEach((e=>e.reject(h)))}e.push({previous:o,document:l})})));var r=e.length>0?await this.storageInstance.bulkWrite(e,"incremental-write"):{error:[],success:[]};return await Promise.all(r.success.map((e=>{var r=e[this.primaryPath];this.postWrite(e),n(t,r).forEach((t=>t.resolve(e)))}))),r.error.forEach((e=>{var r,a=e.documentId,i=n(t,a),o=E(e);if(o){var c=s(this.queueByDocId,a,(()=>[]));i.reverse().forEach((e=>{e.lastKnownDocumentState=(0,le.Is)(o.documentInDb),(0,le.Is)(c).unshift(e)}))}else{var l=N("COL20",{name:C[(r=e).status],document:r.documentId,writeError:r});i.forEach((e=>e.reject(l)))}})),this.isRunning=!1,this.triggerRun()}},e}();function bt(e){return async t=>{var r=function(e){return Object.assign({},e,{_meta:void 0,_deleted:void 0,_rev:void 0})}(t);r._deleted=t._deleted;var a=await e(r),n=Object.assign({},a,{_meta:t._meta,_attachments:t._attachments,_rev:t._rev,_deleted:void 0!==a._deleted?a._deleted:t._deleted});return void 0===n._deleted&&(n._deleted=!1),n}}var xt={get primaryPath(){if(this.isInstanceOfRxDocument)return this.collection.schema.primaryPath},get primary(){var e=this;if(e.isInstanceOfRxDocument)return e._data[e.primaryPath]},get revision(){if(this.isInstanceOfRxDocument)return this._data._rev},get deleted$(){if(this.isInstanceOfRxDocument)return this.$.pipe((0,ut.U)((e=>e._data._deleted)))},get deleted(){if(this.isInstanceOfRxDocument)return this._data._deleted},getLatest(){var e=this.collection._docCache.getLatestDocumentData(this.primary);return this.collection._docCache.getCachedRxDocument(e)},get $(){return this.collection.$.pipe((0,ht.h)((e=>!e.isLocal)),(0,ht.h)((e=>e.documentId===this.primary)),(0,ut.U)((e=>gt(e))),(0,dt.O)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.x)(((e,t)=>e._rev===t._rev)),(0,ut.U)((e=>this.collection._docCache.getCachedRxDocument(e))),(0,pt.d)(le.kv))},get$(e){if(j.isDevMode()){if(e.includes(".item."))throw N("DOC1",{path:e});if(e===this.primaryPath)throw N("DOC2");if(this.collection.schema.finalFields.includes(e))throw N("DOC3",{path:e});if(!q(this.collection.schema.jsonSchema,e))throw N("DOC4",{path:e})}return this.$.pipe((0,ut.U)((t=>v(t,e))),(0,mt.x)())},populate(e){var t=q(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.m5;if(!t)throw N("DOC5",{path:e});if(!t.ref)throw N("DOC6",{path:e,schemaObj:t});var a=this.collection.database.collections[t.ref];if(!a)throw N("DOC7",{ref:t.ref,path:e,schemaObj:t});return"array"===t.type?a.findByIds(r).exec().then((e=>{var t=e.values();return Array.from(t)})):a.findOne(r).exec()},get(e){return s(this._propertyCache,e,(()=>{var t=v(this._data,e);if("object"!=typeof t||null===t||Array.isArray(t))return j.deepFreezeWhenDevMode(t);var r=this;return new Proxy(i(t),{get(t,a){if("string"!=typeof a)return t[a];var n=a.charAt(a.length-1);if("$"===n){var s=a.slice(0,-1);return r.get$(B(e+"."+s))}if("_"===n){var i=a.slice(0,-1);return r.populate(B(e+"."+i))}return r.get(B(e+"."+a))}})}))},toJSON(e){if(void 0===e&&(e=!1),e)return j.deepFreezeWhenDevMode(this._data);var t=i(this._data);return delete t._rev,delete t._attachments,delete t._deleted,delete t._meta,j.deepFreezeWhenDevMode(t)},toMutableJSON(e){return void 0===e&&(e=!1),c(this.toJSON(e))},update(e){throw vt("update")},incrementalUpdate(e){throw vt("update")},updateCRDT(e){throw vt("crdt")},putAttachment(){throw vt("attachments")},getAttachment(){throw vt("attachments")},allAttachments(){throw vt("attachments")},get allAttachments$(){throw vt("attachments")},async modify(e,t){var r=this._data,a=await bt(e)(r);return this._saveData(a,r)},incrementalModify(e,t){return this.collection.incrementalWriteQueue.addWrite(this._data,bt(e)).then((e=>this.collection._docCache.getCachedRxDocument(e)))},patch(e){var t=this._data,r=c(t);return Object.entries(e).forEach((e=>{let[t,a]=e;r[t]=a})),this._saveData(r,t)},incrementalPatch(e){return this.incrementalModify((t=>(Object.entries(e).forEach((e=>{let[r,a]=e;t[r]=a})),t)))},async _saveData(e,t){if(e=i(e),this._data._deleted)throw N("DOC11",{id:this.primary,document:this});await jt(this.collection,e,t);var r=await this.collection.storageInstance.bulkWrite([{previous:t,document:e}],"rx-document-save-data"),a=r.error[0];return We(this.collection,this.primary,e,a),await this.collection._runHooks("post","save",e,this),this.collection._docCache.getCachedRxDocument(r.success[0])},remove(){var e=this.collection;if(this.deleted)return Promise.reject(N("DOC13",{document:this,id:this.primary}));var t,r=i(this._data);return e._runHooks("pre","remove",r,this).then((async()=>{r._deleted=!0;var t=await e.storageInstance.bulkWrite([{previous:this._data,document:r}],"rx-document-remove"),a=t.error[0];return We(e,this.primary,r,a),t.success[0]})).then((e=>(t=e,this.collection._runHooks("post","remove",r,this)))).then((()=>this.collection._docCache.getCachedRxDocument(t)))},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 N("DOC14")}};function wt(e){void 0===e&&(e=xt);var t=function(e,t){this.collection=e,this._data=t,this._propertyCache=new Map,this.isInstanceOfRxDocument=!0};return t.prototype=e,t}function jt(e,t,r){return t._meta=Object.assign({},r._meta,t._meta),j.isDevMode()&&e.schema.validateChange(r,t),e._runHooks("pre","save",t,r)}var kt=r(10),_t=r(6871),Dt=r(3028),Nt=r(1556),It=r(8456);function Et(e,t){return t.sort&&0!==t.sort.length?t.sort.map((e=>Object.keys(e)[0])):[e]}var Ct=new WeakMap;function Rt(e,t){if(!e.collection.database.eventReduce)return{runFullQueryAgain:!0};var r=function(e){return s(Ct,e,(()=>{var t=e.collection,r=Ee(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=Ce(t.schema.jsonSchema,r),s=Re(t.schema.jsonSchema,r);return{primaryKey:e.collection.schema.primaryPath,skip:r.skip,limit:r.limit,sortFields:Et(a,r),sortComparator:(t,r)=>{var a={docA:t,docB:r,rxQuery:e};return n(a.docA,a.docB)},queryMatcher:t=>s({doc:t,rxQuery:e}.doc)}}))}(e),a=(0,le.Is)(e._result).docsData.slice(0),n=(0,le.Is)(e._result).docsDataMap,i=!1;return t.map((e=>function(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:j.deepFreezeWhenDevMode(e.documentData),previous:e.previousDocumentData?e.previousDocumentData:"UNKNOWN"};case"DELETE":return{operation:e.operation,id:e.documentId,doc:null,previous:e.previousDocumentData}}}(e))).filter(y.S7).find((e=>{var t={queryParams:r,changeEvent:e,previousResults:a,keyDocumentMap:n},s=(0,It.Rf)(t);return"runFullQueryAgain"===s||("doNothing"!==s?(i=!0,(0,It.wu)(s,r,e,a,n),!1):void 0)}))?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:i,newResults:a}}var Ot=function(){function e(){this._map=new Map}return e.prototype.getByQuery=function(e){var t=e.toString();return s(this._map,t,(()=>e))},e}();function St(e,t){t.uncached=!0;var r=t.toString();e._map.delete(r)}function Pt(e){return e.refCount$.observers.length}var Bt,$t,Tt=(Bt=100,$t=3e4,(e,t)=>{if(!(t._map.size0||(0===s._lastEnsureEqual&&s._creationTimee._lastEnsureEqual-t._lastEnsureEqual)).slice(0,i).forEach((e=>St(t,e)))}}),qt=new WeakSet;var Mt=function(){function e(e,t,r){this.cacheItemByDocId=new Map,this.registry="function"==typeof FinalizationRegistry?new FinalizationRegistry((e=>{var t=e.docId,r=this.cacheItemByDocId.get(t);r&&(r.byRev.delete(e.revisionHeight),0===r.byRev.size&&this.cacheItemByDocId.delete(t))})):void 0,this.registerIdleTasks=[],this.primaryPath=e,this.changes$=t,this.documentCreator=r,t.subscribe((e=>{var t=e.documentId,r=this.cacheItemByDocId.get(t);if(r){var a=gt(e);r.last=a}}))}var t=e.prototype;return t.getLatestDocumentData=function(e){return n(this.cacheItemByDocId,e).last},t.getLatestDocumentDataIfExists=function(e){var t=this.cacheItemByDocId.get(e);if(t)return t.last},(0,b.Z)(e,[{key:"getCachedRxDocument",get:function(){return l(this,"getCachedRxDocument",function(e){var t=e.primaryPath,r=e.cacheItemByDocId,a=e.registry,n=j.deepFreezeWhenDevMode,i=e.documentCreator,o=o=>{var c=o[t],l=Te(o._rev),u=s(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),h=u.byRev,d=h.get(l),m=d?d.deref():void 0;return m||(o=n(o),m=i(o),h.set(l,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,ft.y$)().then((()=>{e.registerIdlePromise=void 0;var t=e.registerIdleTasks;0!==t.length&&(e.registerIdleTasks=[],t.forEach((e=>{a.register(e,{docId:e.primary,revisionHeight:Te(e.revision)})})))}))))),m};return o}(this))}}]),e}();function At(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Qt=function(){function e(e,t,r){this.time=(0,ce.z)(),this.collection=e,this.count=r,this.documents=At(this.collection._docCache,t)}return(0,b.Z)(e,[{key:"docsData",get:function(){return l(this,"docsData",this.documents.map((e=>e._data)))}},{key:"docsDataMap",get:function(){var e=new Map;return this.documents.forEach((t=>{e.set(t.primary,t._data)})),l(this,"docsDataMap",e)}},{key:"docsMap",get:function(){for(var e=new Map,t=this.documents,r=0;r"string"!=typeof e)))return r.$eq}return!1}(this.collection.schema.primaryPath,t)}var t=e.prototype;return t._setResultData=function(e){if("number"!=typeof e){e instanceof Map&&(e=Array.from(e.values()));var t=new Qt(this.collection,e,e.length);this._result=t}else this._result=new Qt(this.collection,[],e)},t._execOverDatabase=async function(){if(this._execOverDatabaseCount=this._execOverDatabaseCount+1,this._lastExecStart=(0,ce.z)(),"count"===this.op){var e=this.getPreparedQuery(),t=await this.collection.storageInstance.count(e);if("slow"!==t.mode||this.collection.database.allowSlowCount)return t.count;throw N("QU14",{collection:this.collection,queryObj:this.mangoQuery})}if("findByIds"===this.op){var r=(0,le.Is)(this.mangoQuery.selector)[this.collection.schema.primaryPath].$in,a=new Map,n=[];if(r.forEach((e=>{var t=this.collection._docCache.getLatestDocumentDataIfExists(e);if(t){if(!t._deleted){var r=this.collection._docCache.getCachedRxDocument(t);a.set(e,r)}}else n.push(e)})),n.length>0)(await this.collection.storageInstance.findDocumentsById(n,!1)).forEach((e=>{var t=this.collection._docCache.getCachedRxDocument(e);a.set(t.primary,t)}));return a}var s=async function(e){var t=[],r=e.collection;if(e.isFindOneByIdQuery)if(Array.isArray(e.isFindOneByIdQuery)){var a=e.isFindOneByIdQuery;if(a=a.filter((r=>{var a=e.collection._docCache.getLatestDocumentDataIfExists(r);return!a||(a._deleted||t.push(a),!1)})),a.length>0){var n=await r.storageInstance.findDocumentsById(a,!1);(0,y.gu)(t,n)}}else{var s=e.isFindOneByIdQuery,i=e.collection._docCache.getLatestDocumentDataIfExists(s);if(!i){var o=await r.storageInstance.findDocumentsById([s],!1);o[0]&&(i=o[0])}i&&!i._deleted&&t.push(i)}else{var c=e.getPreparedQuery(),l=await r.storageInstance.query(c);t=l.documents}return t}(this);return s.then((e=>(this._lastExecEnd=(0,ce.z)(),e)))},t.exec=function(e){if(e&&"findOne"!==this.op)throw N("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Kt(this).then((()=>(0,_t.z)(this.$))).then((t=>{if(!t&&e)throw N("QU10",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return t}))},t.toString=function(){var e=o({op:this.op,query:this.mangoQuery,other:this.other},!0),t=JSON.stringify(e);return this.toString=()=>t,t},t.getPreparedQuery=function(){var e={rxQuery:this,mangoQuery:Ee(this.collection.schema.jsonSchema,this.mangoQuery)};e.mangoQuery.selector._deleted={$eq:!1},e.mangoQuery.index&&e.mangoQuery.index.unshift("_deleted"),it("prePrepareQuery",e);var t=Ut(this.collection.schema.jsonSchema,e.mangoQuery);return this.getPreparedQuery=()=>t,t},t.doesDocumentDataMatch=function(e){return!e._deleted&&this.queryMatcher(e)},t.remove=function(){return this.exec().then((e=>Array.isArray(e)?Promise.all(e.map((e=>e.remove()))):e.remove()))},t.update=function(e){throw vt("update")},t.where=function(e){throw vt("query-builder")},t.sort=function(e){throw vt("query-builder")},t.skip=function(e){throw vt("query-builder")},t.limit=function(e){throw vt("query-builder")},(0,b.Z)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,ht.h)((e=>!e.isLocal)),(0,dt.O)(null),(0,Nt.z)((()=>Kt(this))),(0,ut.U)((()=>this._result)),(0,pt.d)(le.kv),(0,mt.x)(((e,t)=>!(!e||e.time!==(0,le.Is)(t).time))),(0,ht.h)((e=>!!e)),(0,ut.U)((e=>{var t=(0,le.Is)(e);return"count"===this.op?t.count:"findOne"===this.op?0===t.documents.length?null:t.documents[0]:"findByIds"===this.op?t.docsMap:t.documents.slice(0)})));this._$=(0,Dt.T)(e,this.refCount$.pipe((0,ht.h)((()=>!1))))}return this._$}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return l(this,"queryMatcher",Re(0,Ee(this.collection.schema.jsonSchema,this.mangoQuery)))}},{key:"asRxQuery",get:function(){return this}}]),e}();function Ht(e,t,r,a){it("preCreateRxQuery",{op:e,queryObj:t,collection:r,other:a});var n,s,i=new Ft(e,t,r,a);return i=(n=i).collection._queryCache.getByQuery(n),s=r,qt.has(s)||(qt.add(s),(0,ft.Y3)().then((()=>(0,ft.C2)(200))).then((()=>{s.destroyed||s.cacheReplacementPolicy(s,s._queryCache),qt.delete(s)}))),i}function zt(e){var t=e.asRxQuery.collection._changeEventBuffer.counter;return e._latestChangeEvent>=t}function Kt(e){return e.collection.database.destroyed||zt(e)?ft.kZ:(e._ensureEqualQueue=e._ensureEqualQueue.then((()=>function(e){if(e._lastEnsureEqual=(0,ce.z)(),e.collection.database.destroyed||zt(e))return ft.kZ;var t=!1,r=!1;-1===e._latestChangeEvent&&(r=!0);if(!r){var a=e.asRxQuery.collection._changeEventBuffer.getFrom(e._latestChangeEvent+1);if(null===a)r=!0;else{e._latestChangeEvent=e.asRxQuery.collection._changeEventBuffer.counter;var n=e.asRxQuery.collection._changeEventBuffer.reduceByLastOfDoc(a);if("count"===e.op){var s=(0,le.Is)(e._result).count,i=s;n.forEach((t=>{var r=t.previousDocumentData&&e.doesDocumentDataMatch(t.previousDocumentData),a=e.doesDocumentDataMatch(t.documentData);!r&&a&&i++,r&&!a&&i--})),i!==s&&(t=!0,e._setResultData(i))}else{var o=Rt(e,n);o.runFullQueryAgain?r=!0:o.changed&&(t=!0,e._setResultData(o.newResults))}}}if(r)return e._execOverDatabase().then((r=>(e._latestChangeEvent=e.collection._changeEventBuffer.counter,"number"==typeof r?(e._result&&r===e._result.count||(t=!0,e._setResultData(r)),t):(e._result&&function(e,t,r){if(t.length!==r.length)return!1;for(var a=0,n=t.length;ae.data.name===n)),c=[];o.forEach((e=>{c.push({collectionName:e.data.name,schema:e.data.schema,isCollection:!0}),e.data.connectedStorages.forEach((e=>c.push({collectionName:e.collectionName,isCollection:!1,schema:e.schema})))}));var l=new Set;if(c=c.filter((e=>{var t=e.collectionName+"||"+e.schema.version;return!l.has(t)&&(l.add(t),!0)})),await Promise.all(c.map((async t=>{var i=await e.createStorageInstance({collectionName:t.collectionName,databaseInstanceToken:r,databaseName:a,multiInstance:!1,options:{},schema:t.schema,password:s,devMode:j.isDevMode()});await i.remove(),t.isCollection&&await ot("postRemoveRxCollection",{storage:e,databaseName:a,collectionName:n})}))),i){var u=o.map((e=>{var t=ze(e);return t._deleted=!0,t._meta.lwt=(0,ce.z)(),t._rev=qe(r,e),{previous:e,document:t}}));await t.bulkWrite(u,"rx-database-remove-collection-all")}}var nr=function(){function e(e){this.subs=[],this.limit=100,this.counter=0,this.eventCounterMap=new WeakMap,this.buffer=[],this.collection=e,this.subs.push(this.collection.$.pipe((0,ht.h)((e=>!e.isLocal))).subscribe((e=>this._handleChangeEvent(e))))}var t=e.prototype;return t._handleChangeEvent=function(e){for(this.counter++,this.buffer.push(e),this.eventCounterMap.set(e,this.counter);this.buffer.length>this.limit;)this.buffer.shift()},t.getArrayIndexByPointer=function(e){var t=this.buffer[0],r=this.eventCounterMap.get(t);return et(e)))},t.reduceByLastOfDoc=function(e){return e.slice(0)},t.destroy=function(){this.subs.forEach((e=>e.unsubscribe()))},e}();var sr=new WeakMap;function ir(e){var t=e.schema.getDocumentPrototype(),r=function(e){var t={};return Object.entries(e.methods).forEach((e=>{let[r,a]=e;t[r]=a})),t}(e),a={};return[t,r,xt].forEach((e=>{Object.getOwnPropertyNames(e).forEach((t=>{var r=Object.getOwnPropertyDescriptor(e,t),n=!0;(t.startsWith("_")||t.endsWith("_")||t.startsWith("$")||t.endsWith("$"))&&(n=!1),"function"==typeof r.value?Object.defineProperty(a,t,{get(){return r.value.bind(this)},enumerable:n,configurable:!1}):(r.enumerable=n,r.configurable=!1,r.writable&&(r.writable=!1),Object.defineProperty(a,t,r))}))})),a}function or(e,t){var r=function(e,t,r){var a=new e(t,r);return it("createRxDocument",a),a}(function(e){return s(sr,e,(()=>wt(ir(e))))}(e),e,j.deepFreezeWhenDevMode(t));return e._runHooksSync("post","create",t,r),it("postCreateRxDocument",r),r}var cr=function(e,t){return nt(He(e.newDocumentState),He(e.realMasterState))?Promise.resolve({isEqual:!0}):Promise.resolve({isEqual:!1,documentData:e.realMasterState})};var lr=["pre","post"],ur=["insert","save","remove","create"],hr=!1,dr=function(){function e(e,t,r,a,n,s,i,o,c,l,u,h){void 0===n&&(n={}),void 0===s&&(s={}),void 0===i&&(i={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===l&&(l=Tt),void 0===u&&(u={}),void 0===h&&(h=cr),this.storageInstance={},this.timeouts=new Set,this.incrementalWriteQueue={},this._incrementalUpsertQueues=new Map,this.synced=!1,this.hooks={},this._subs=[],this._docCache={},this._queryCache=new Ot,this.$={},this.checkpoint$={},this._changeEventBuffer={},this.onDestroy=[],this.destroyed=!1,this.database=e,this.name=t,this.schema=r,this.internalStorageInstance=a,this.instanceCreationOptions=n,this.migrationStrategies=s,this.methods=i,this.attachments=o,this.options=c,this.cacheReplacementPolicy=l,this.statics=u,this.conflictHandler=h,function(e){if(hr)return;hr=!0;var t=Object.getPrototypeOf(e);ur.forEach((e=>{lr.map((r=>{var a=r+P(e);t[a]=function(t,a){return this.addHook(r,e,t,a)}}))}))}(this.asRxCollection)}var t=e.prototype;return t.prepare=async function(){this.storageInstance=Ke(this.database,this.internalStorageInstance,this.schema.jsonSchema),this.incrementalWriteQueue=new yt(this.storageInstance,this.schema.primaryPath,((e,t)=>jt(this,e,t)),(e=>this._runHooks("post","save",e)));var e,t=this.database.eventBulks$.pipe((0,ht.h)((e=>e.collectionName===this.name)));this.$=t.pipe((0,Nt.z)((e=>e.events))),this.checkpoint$=t.pipe((0,ut.U)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Mt(this.schema.primaryPath,this.$.pipe((0,ht.h)((e=>!e.isLocal))),(e=>or(this.asRxCollection,e)));var r=await this.database.storageToken,a=this.storageInstance.changeStream().subscribe((e=>{var t={id:e.id,internal:!1,collectionName:this.name,storageToken:r,events:e.events.map((e=>Qe(!1,e,this))),databaseToken:this.database.token,checkpoint:e.checkpoint,context:e.context,endTime:e.endTime,startTime:e.startTime};this.database.$emit(t)}));return this._subs.push(a),this._subs.push(this.storageInstance.conflictResultionTasks().subscribe((e=>{this.conflictHandler(e.input,e.context).then((t=>{this.storageInstance.resolveConflictResultionTask({id:e.id,output:t})}))}))),ft.$Y},t.cleanup=function(e){throw vt("cleanup")},t.migrationNeeded=function(){throw vt("migration-schema")},t.getMigrationState=function(){throw vt("migration-schema")},t.startMigration=function(e){return void 0===e&&(e=10),this.getMigrationState().startMigration(e)},t.migratePromise=function(e){return void 0===e&&(e=10),this.getMigrationState().migratePromise(e)},t.insert=async function(e){var t=await this.bulkInsert([e]),r=t.error[0];return We(this,e[this.schema.primaryPath],e,r),(0,le.Is)(t.success[0])},t.bulkInsert=async function(e){if(0===e.length)return{success:[],error:[]};var t=this.schema.primaryPath,r=e.map((e=>rr(this.schema,e))),a=this.hasHooks("pre","insert")?await Promise.all(r.map((e=>this._runHooks("pre","insert",e).then((()=>e))))):r,n=a.map((e=>({document:e}))),s=await this.storageInstance.bulkWrite(n,"rx-collection-bulk-insert"),i=At(this._docCache,s.success);if(this.hasHooks("post","insert")){var o=new Map;a.forEach((e=>{o.set(e[t],e)})),await Promise.all(i.map((e=>this._runHooks("post","insert",o.get(e.primary),e))))}return{success:i,error:s.error}},t.bulkRemove=async function(e){var t=this.schema.primaryPath;if(0===e.length)return{success:[],error:[]};var r=await this.findByIds(e).exec(),a=[],s=new Map;Array.from(r.values()).forEach((e=>{var t=e.toMutableJSON(!0);a.push(t),s.set(e.primary,t)})),await Promise.all(a.map((e=>{var t=e[this.schema.primaryPath];return this._runHooks("pre","remove",e,r.get(t))})));var o=a.map((e=>{var t=i(e);return t._deleted=!0,{previous:e,document:t}})),c=await this.storageInstance.bulkWrite(o,"rx-collection-bulk-remove"),l=c.success.map((e=>e[t]));return await Promise.all(l.map((e=>this._runHooks("post","remove",s.get(e),r.get(e))))),{success:l.map((e=>n(r,e))),error:c.error}},t.bulkUpsert=async function(e){var t=[],r=new Map;e.forEach((e=>{var a=rr(this.schema,e),n=a[this.schema.primaryPath];if(!n)throw N("COL3",{primaryPath:this.schema.primaryPath,data:a,schema:this.schema.jsonSchema});r.set(n,a),t.push(a)}));var a=await this.bulkInsert(t),s=a.success.slice(0),i=[];return await Promise.all(a.error.map((async e=>{if(409!==e.status)i.push(e);else{var t=e.documentId,a=n(r,t),o=(0,le.Is)(e.documentInDb),c=this._docCache.getCachedRxDocument(o),l=await c.incrementalModify((()=>a));s.push(l)}}))),{error:i,success:s}},t.upsert=async function(e){var t=await this.bulkUpsert([e]);return We(this.asRxCollection,e[this.schema.primaryPath],e,t.error[0]),t.success[0]},t.incrementalUpsert=function(e){var t=rr(this.schema,e),r=t[this.schema.primaryPath];if(!r)throw N("COL4",{data:e});var a=this._incrementalUpsertQueues.get(r);return a||(a=ft.$Y),a=a.then((()=>function(e,t,r){var a=e._docCache.getLatestDocumentDataIfExists(t);if(a)return Promise.resolve({doc:e._docCache.getCachedRxDocument(a),inserted:!1});return e.findOne(t).exec().then((t=>t?{doc:t,inserted:!1}:e.insert(r).then((e=>({doc:e,inserted:!0})))))}(this,r,t))).then((e=>e.inserted?e.doc:function(e,t){return e.incrementalModify((e=>t))}(e.doc,t))),this._incrementalUpsertQueues.set(r,a),a},t.find=function(e){if("string"==typeof e)throw N("COL5",{queryObj:e});return e||(e={selector:{}}),Ht("find",e,this)},t.findOne=function(e){if("number"==typeof e||Array.isArray(e))throw I("COL6",{queryObj:e});var t;if("string"==typeof e)t=Ht("findOne",{selector:{[this.schema.primaryPath]:e},limit:1},this);else{if(e||(e={selector:{}}),e.limit)throw N("QU6");(e=i(e)).limit=1,t=Ht("findOne",e,this)}return t},t.count=function(e){return e||(e={selector:{}}),Ht("count",e,this)},t.findByIds=function(e){return Ht("findByIds",{selector:{[this.schema.primaryPath]:{$in:e.slice(0)}}},this)},t.exportJSON=function(){throw vt("json-dump")},t.importJSON=function(e){throw vt("json-dump")},t.insertCRDT=function(e){throw vt("crdt")},t.addHook=function(e,t,r,a){if(void 0===a&&(a=!1),"function"!=typeof r)throw I("COL7",{key:t,when:e});if(!lr.includes(e))throw I("COL8",{key:t,when:e});if(!ur.includes(t))throw N("COL9",{key:t});if("post"===e&&"create"===t&&!0===a)throw N("COL10",{when:e,key:t,parallel:a});var n=r.bind(this),s=a?"parallel":"series";this.hooks[t]=this.hooks[t]||{},this.hooks[t][e]=this.hooks[t][e]||{series:[],parallel:[]},this.hooks[t][e][s].push(n)},t.getHooks=function(e,t){return this.hooks[t]&&this.hooks[t][e]?this.hooks[t][e]:{series:[],parallel:[]}},t.hasHooks=function(e,t){var r=this.getHooks(e,t);return!!r&&(r.series.length>0||r.parallel.length>0)},t._runHooks=function(e,t,r,a){var n=this.getHooks(e,t);if(!n)return ft.$Y;var s=n.series.map((e=>()=>e(r,a)));return(0,ft.Ze)(s).then((()=>Promise.all(n.parallel.map((e=>e(r,a))))))},t._runHooksSync=function(e,t,r,a){var n=this.getHooks(e,t);n&&n.series.forEach((e=>e(r,a)))},t.promiseWait=function(e){return new Promise((t=>{var r=setTimeout((()=>{this.timeouts.delete(r),t()}),e);this.timeouts.add(r)}))},t.destroy=function(){return this.destroyed?ft.kZ:(this.destroyed=!0,Array.from(this.timeouts).forEach((e=>clearTimeout(e))),this._changeEventBuffer&&this._changeEventBuffer.destroy(),this.database.requestIdlePromise().then((()=>Promise.all(this.onDestroy.map((e=>e()))))).then((()=>this.storageInstance.close())).then((()=>(this._subs.forEach((e=>e.unsubscribe())),delete this.database.collections[this.name],ot("postDestroyRxCollection",this).then((()=>!0))))))},t.remove=async function(){await this.destroy(),await ar(this.database.storage,this.database.internalStore,this.database.token,this.database.name,this.name,this.database.password,this.database.hashFunction)},(0,b.Z)(e,[{key:"insert$",get:function(){return this.$.pipe((0,ht.h)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,ht.h)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,ht.h)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}]),e}();var mr=r(7782),pr=r(6753);var fr="undefined"!=typeof crypto&&void 0!==crypto.subtle&&"function"==typeof crypto.subtle.digest?async function(e){var t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.prototype.map.call(new Uint8Array(r),(e=>("00"+e.toString(16)).slice(-2))).join("")}:function(e){return Promise.resolve((0,pr.JQ)(e))},vr=r(5898),gr=new Set,yr=function(){function e(e,t,r,a,n,s,i,o,c,l,u,h){void 0===i&&(i=!1),void 0===o&&(o={}),this.idleQueue=new mr.F,this.rxdbVersion=rt,this.storageInstances=new Set,this._subs=[],this.startupErrors=[],this.onDestroy=[],this.destroyed=!1,this.collections={},this.eventBulks$=new oe.x,this.observable$=this.eventBulks$.pipe((0,Nt.z)((e=>e.events))),this.storageToken=ft.kZ,this.storageTokenDocument=ft.kZ,this.emittedEventBulkIds=new vr.i(6e4),this.name=e,this.token=t,this.storage=r,this.instanceCreationOptions=a,this.password=n,this.multiInstance=s,this.eventReduce=i,this.options=o,this.internalStore=c,this.hashFunction=l,this.cleanupPolicy=u,this.allowSlowCount=h,"pseudoInstance"!==this.name&&(this.internalStore=Ke(this.asRxDatabase,c,Vt),this.storageTokenDocument=async function(e){var t=S(10),r=e.password?await e.hashFunction(JSON.stringify(e.password)):void 0,a={id:er,context:Jt,key:Gt,data:{rxdbVersion:e.rxdbVersion,token:t,instanceToken:e.token,passwordHash:r},_deleted:!1,_meta:T(),_rev:"",_attachments:{}},n=await e.internalStore.bulkWrite([{document:a}],"internal-add-storage-token");if(n.success[0])return n.success[0];var s=(0,le.Is)(n.error[0]);if(s.isError&&E(s)){var i=s;if(c=i.documentInDb.data.rxdbVersion,l=e.rxdbVersion,!c||l.includes("beta")&&l!==c||c.split(".")[0]!==l.split(".")[0])throw N("DM5",{args:{database:e.name,databaseStateVersion:i.documentInDb.data.rxdbVersion,codeVersion:e.rxdbVersion}});if(r&&r!==i.documentInDb.data.passwordHash)throw N("DB1",{passwordHash:r,existingPasswordHash:i.documentInDb.data.passwordHash});var o=i.documentInDb;return(0,le.Is)(o)}var c,l;throw s}(this.asRxDatabase).catch((e=>this.startupErrors.push(e))),this.storageToken=this.storageTokenDocument.then((e=>e.data.token)).catch((e=>this.startupErrors.push(e))))}var t=e.prototype;return t.$emit=function(e){this.emittedEventBulkIds.has(e.id)||(this.emittedEventBulkIds.add(e.id),this.eventBulks$.next(e))},t.removeCollectionDoc=async function(e,t){var r=await Ae(this.internalStore,Xt(tr(e,t),Zt));if(!r)throw N("SNH",{name:e,schema:t});var a=ze(r);a._deleted=!0,await this.internalStore.bulkWrite([{document:a,previous:r}],"rx-database-remove-collection")},t.addCollections=async function(e){var t={},r={},a=[],n={};await Promise.all(Object.entries(e).map((async e=>{let[s,o]=e;var c=s,l=o.schema;t[c]=l;var u=lt(l,this.hashFunction);if(r[c]=u,this.collections[s])throw N("DB3",{name:s});var h=tr(s,l),d={id:Xt(h,Zt),key:h,context:Zt,data:{name:c,schemaHash:await u.hash,schema:u.jsonSchema,version:u.version,connectedStorages:[]},_deleted:!1,_meta:T(),_rev:"",_attachments:{}};a.push({document:d});var m=Object.assign({},o,{name:c,schema:u,database:this}),p=i(o);p.database=this,p.name=s,it("preCreateRxCollection",p),m.conflictHandler=p.conflictHandler,n[c]=m})));var s=await this.internalStore.bulkWrite(a,"rx-database-add-collection");await async function(e){if(await e.storageToken,e.startupErrors[0])throw e.startupErrors[0]}(this),await Promise.all(s.error.map((async e=>{if(409!==e.status)throw N("DB12",{database:this.name,writeError:e});var a=(0,le.Is)(e.documentInDb),n=a.data.name,s=r[n];if(a.data.schemaHash!==await s.hash)throw N("DB6",{database:this.name,collection:n,previousSchemaHash:a.data.schemaHash,schemaHash:await s.hash,previousSchema:a.data.schema,schema:(0,le.Is)(t[n])})})));var o={};return await Promise.all(Object.keys(e).map((async e=>{var t=n[e],r=await function(e){let{database:t,name:r,schema:a,instanceCreationOptions:n={},migrationStrategies:s={},autoMigrate:i=!0,statics:o={},methods:c={},attachments:l={},options:u={},localDocuments:h=!1,cacheReplacementPolicy:d=Tt,conflictHandler:m=cr}=e;var p={databaseInstanceToken:t.token,databaseName:t.name,collectionName:r,schema:a.jsonSchema,options:n,multiInstance:t.multiInstance,password:t.password,devMode:j.isDevMode()};return it("preCreateRxStorageInstance",p),async function(e,t){return t.multiInstance=e.multiInstance,await e.storage.createStorageInstance(t)}(t,p).then((e=>{var p=new dr(t,r,a,e,n,s,c,l,u,d,o,m);return p.prepare().then((()=>{Object.entries(o).forEach((e=>{let[t,r]=e;Object.defineProperty(p,t,{get:()=>r.bind(p)})}));var e=ft.$Y;return i&&0!==p.schema.version&&(e=p.migratePromise()),e})).then((()=>(it("createRxCollection",{collection:p,creator:{name:r,schema:a,storageInstance:e,instanceCreationOptions:n,migrationStrategies:s,methods:c,attachments:l,options:u,cacheReplacementPolicy:d,localDocuments:h,statics:o}}),p))).catch((t=>e.close().then((()=>Promise.reject(t)))))}))}(t);o[e]=r,this.collections[e]=r,this[e]||Object.defineProperty(this,e,{get:()=>this.collections[e]})}))),o},t.lockedRun=function(e){return this.idleQueue.wrapCall(e)},t.requestIdlePromise=function(){return this.idleQueue.requestIdlePromise()},t.exportJSON=function(e){throw vt("json-dump")},t.importJSON=function(e){throw vt("json-dump")},t.backup=function(e){throw vt("backup")},t.leaderElector=function(){throw vt("leader-election")},t.isLeader=function(){throw vt("leader-election")},t.waitForLeadership=function(){throw vt("leader-election")},t.migrationStates=function(){throw vt("migration-schema")},t.destroy=async function(){return this.destroyed?ft.kZ:(this.destroyed=!0,await ot("preDestroyRxDatabase",this),this.eventBulks$.complete(),this._subs.map((e=>e.unsubscribe())),"pseudoInstance"===this.name?ft.kZ:this.requestIdlePromise().then((()=>Promise.all(this.onDestroy.map((e=>e()))))).then((()=>Promise.all(Object.keys(this.collections).map((e=>this.collections[e])).map((e=>e.destroy()))))).then((()=>this.internalStore.close())).then((()=>gr.delete(this.name))).then((()=>!0)))},t.remove=function(){return this.destroy().then((()=>async function(e,t,r){var a=S(10),n=await br(a,t,e,{},!1,r),s=await Yt(n),i=new Set;s.forEach((e=>i.add(e.data.name)));var o=Array.from(i);return await Promise.all(o.map((s=>ar(t,n,a,e,s,r)))),await ot("postRemoveRxDatabase",{databaseName:e,storage:t}),await n.remove(),o}(this.name,this.storage,this.password)))},(0,b.Z)(e,[{key:"$",get:function(){return this.observable$}},{key:"asRxDatabase",get:function(){return this}}]),e}();async function br(e,t,r,a,n,s){return await t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:Me,schema:Vt,options:a,multiInstance:n,password:s,devMode:j.isDevMode()})}function xr(e){let{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:s=!0,eventReduce:i=!0,ignoreDuplicate:o=!1,options:c={},cleanupPolicy:l,allowSlowCount:u=!1,localDocuments:h=!1,hashFunction:d=fr}=e;it("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:s,eventReduce:i,ignoreDuplicate:o,options:c,localDocuments:h}),o||function(e){if(gr.has(e))throw N("DB8",{name:e,link:"https://pubkey.github.io/rxdb/rx-database.html#ignoreduplicate"})}(a),gr.add(a);var m=S(10);return br(m,t,a,r,s,n).catch((e=>{throw gr.delete(a),e})).then((e=>{var p=new yr(a,m,t,r,n,s,i,c,e,d,l,u);return ot("createRxDatabase",{database:p,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:s,eventReduce:i,ignoreDuplicate:o,options:c,localDocuments:h}}).then((()=>p))}))}var wr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Ft.prototype,RxCollection:dr.prototype,RxDatabase:yr.prototype},jr=new Set,kr=new Set;var _r=function(e){function t(t,r,a){var n;return(n=e.call(this,null,r)||this).id=t,n.parent=a,n}return(0,x.Z)(t,e),t}(wt()),Dr={get isLocal(){return!0},get allAttachments$(){throw N("LD1",{document:this})},get primaryPath(){return"id"},get primary(){return this.id},get $(){var e=n(Cr,this.parent);return this.parent.$.pipe((0,ht.h)((e=>e.documentId===this.primary)),(0,ht.h)((e=>e.isLocal)),(0,ut.U)((e=>gt(e))),(0,dt.O)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.x)(((e,t)=>e._rev===t._rev)),(0,ut.U)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.d)(le.kv))},getLatest(){var e=n(Cr,this.parent),t=e.docCache.getLatestDocumentData(this.primary);return e.docCache.getCachedRxDocument(t)},get(e){if(e="data."+e,this._data){if("string"!=typeof e)throw I("LD2",{objPath:e});var t=v(this._data,e);return t=j.deepFreezeWhenDevMode(t)}},get$(e){if(e="data."+e,j.isDevMode()){if(e.includes(".item."))throw N("LD3",{objPath:e});if(e===this.primaryPath)throw N("LD4")}return this.$.pipe((0,ut.U)((e=>e._data)),(0,ut.U)((t=>v(t,e))),(0,mt.x)())},async incrementalModify(e){var t=await Or(this.parent);return t.incrementalWriteQueue.addWrite(this._data,(async t=>(t.data=await e(t.data,this),t))).then((e=>t.docCache.getCachedRxDocument(e)))},incrementalPatch(e){return this.incrementalModify((t=>(Object.entries(e).forEach((e=>{let[r,a]=e;t[r]=a})),t)))},async _saveData(e){var t=await Or(this.parent),r=this._data;return e.id=this.id,t.storageInstance.bulkWrite([{previous:r,document:e}],"local-document-save-data").then((t=>{var r=t.success[0];if(!r)throw t.error[0];(e=i(e))._rev=r._rev}))},async remove(){var e=await Or(this.parent),t={id:this._data.id,data:{},_deleted:!0,_meta:T(),_rev:"",_attachments:{}};return Le(e.storageInstance,{previous:this._data,document:t},"local-document-remove").then((t=>e.docCache.getCachedRxDocument(t)))}},Nr=!1,Ir=()=>{if(!Nr){Nr=!0;var e=xt;Object.getOwnPropertyNames(e).forEach((t=>{if(!Object.getOwnPropertyDescriptor(Dr,t)){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(Dr,t,r)}}));["populate","update","putAttachment","getAttachment","allAttachments"].forEach((e=>Dr[e]=(e=>()=>{throw N("LD6",{functionName:e})})(e)))}};var Er=new WeakMap,Cr=new WeakMap;function Rr(e){var t=e.database?e.database:e,r=e.database?e.name:"",a=(async()=>{var a=await Sr(t.token,t.storage,t.name,r,t.instanceCreationOptions,t.multiInstance);a=Ke(t,a,Tr);var n=new Mt("id",e.$.pipe((0,ht.h)((e=>e.isLocal))),(t=>function(e,t){Ir();var r=new _r(e.id,e,t);return Object.setPrototypeOf(r,Dr),r.prototype=Dr,r}(t,e))),s=new yt(a,"id",(()=>{}),(()=>{})),i=await t.storageToken,o=a.changeStream().subscribe((r=>{var a={id:r.id,internal:!1,collectionName:e.database?e.name:void 0,storageToken:i,events:r.events.map((t=>Qe(!0,t,e.database?e:void 0))),databaseToken:t.token,checkpoint:r.checkpoint,context:r.context,endTime:r.endTime,startTime:r.startTime};t.$emit(a)}));e._subs.push(o);var c={database:t,parent:e,storageInstance:a,docCache:n,incrementalWriteQueue:s};return Cr.set(e,c),c})();Er.set(e,a)}function Or(e){var t=Er.get(e);if(!t){var r=e.database?e.database:e,a=e.database?e.name:"";throw N("LD8",{database:r.name,collection:a})}return t}function Sr(e,t,r,a,n,s){return t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:$r(a),schema:Tr,options:n,multiInstance:s,devMode:j.isDevMode()})}function Pr(e){var t=Er.get(e);if(t)return Er.delete(e),t.then((e=>e.storageInstance.close()))}async function Br(e,t,r){var a=S(10),n=await Sr(a,e,t,r,{},!1);await n.remove()}function $r(e){return"plugin-local-documents-"+e}var Tr=Q({title:"RxLocalDocument",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:128},data:{type:"object",additionalProperties:!0}},required:["id","data"]});async function qr(e,t){var r=await Or(this),a={id:e,data:t,_deleted:!1,_meta:T(),_rev:"",_attachments:{}};return Le(r.storageInstance,{document:a},"local-document-insert").then((e=>r.docCache.getCachedRxDocument(e)))}function Mr(e,t){return this.getLocal(e).then((r=>r?r.incrementalModify((()=>t)):this.insertLocal(e,t)))}async function Ar(e){var t=await Or(this),r=t.docCache,a=r.getLatestDocumentDataIfExists(e);return a?Promise.resolve(r.getCachedRxDocument(a)):Ae(t.storageInstance,e).then((e=>e?t.docCache.getCachedRxDocument(e):null))}function Lr(e){return this.$.pipe((0,dt.O)(null),(0,Nt.z)((async t=>t?{changeEvent:t}:{doc:await this.getLocal(e)})),(0,Nt.z)((async t=>{if(t.changeEvent){var r=t.changeEvent;return r.isLocal&&r.documentId===e?{use:!0,doc:await this.getLocal(e)}:{use:!1}}return{use:!0,doc:t.doc}})),(0,ht.h)((e=>e.use)),(0,ut.U)((e=>e.doc)))}var Qr={name:"local-documents",rxdb:!0,prototypes:{RxCollection:e=>{e.insertLocal=qr,e.upsertLocal=Mr,e.getLocal=Ar,e.getLocal$=Lr},RxDatabase:e=>{e.insertLocal=qr,e.upsertLocal=Mr,e.getLocal=Ar,e.getLocal$=Lr}},hooks:{createRxDatabase:{before:e=>{e.creator.localDocuments&&Rr(e.database)}},createRxCollection:{before:e=>{e.creator.localDocuments&&Rr(e.collection)}},preDestroyRxDatabase:{after:e=>Pr(e)},postDestroyRxCollection:{after:e=>Pr(e)},postRemoveRxDatabase:{after:e=>Br(e.storage,e.databaseName,"")},postRemoveRxCollection:{after:e=>Br(e.storage,e.databaseName,e.collectionName)}},overwritable:{}};let Wr;function Fr(){return"undefined"!=typeof window&&window.indexedDB}function Hr(){return Wr||(Wr=(async()=>{!function(e){if(it("preAddRxPlugin",{plugin:e,plugins:jr}),!jr.has(e)){if(kr.has(e.name))throw N("PL3",{name:e.name,plugin:e});if(jr.add(e),kr.add(e.name),!e.rxdb)throw I("PL1",{plugin:e});e.init&&e.init(),e.prototypes&&Object.entries(e.prototypes).forEach((e=>{let[t,r]=e;return r(wr[t])})),e.overwritable&&Object.assign(j,e.overwritable),e.hooks&&Object.entries(e.hooks).forEach((e=>{let[t,r]=e;r.after&&st[t].push(r.after),r.before&&st[t].unshift(r.before)}))}}(Qr);var e;return await xr({name:"rxdb-landing-v3",localDocuments:!0,storage:(void 0===e&&(e={}),new at(e))})})()),Wr}const zr=["#e6008d","#8d2089","#5f2688"]},341:(e,t,r)=>{function a(e,t){if(!window.trigger)throw new Error("window.trigger not defined");return window.trigger(e,t)}r.d(t,{X:()=>a})},1960:(e,t,r)=>{r.r(t),r.d(t,{default:()=>O});var a=r(2263),n=r(3799),s=r(5742),i=r(3028),o=r(5556),c=r(9655),l=r(3784),u=r(1556),h=r(7236),d=r(8804),m=r(598),p=Array.isArray;function f(e){return(0,m.U)((function(t){return function(e,t){return p(t)?e.apply(void 0,(0,o.ev)([],(0,o.CR)(t))):e(t)}(e,t)}))}var v=["addListener","removeListener"],g=["addEventListener","removeEventListener"],y=["on","off"];function b(e,t,r,a){if((0,d.m)(r)&&(a=r,r=void 0),a)return b(e,t,r).pipe(f(a));var n=(0,o.CR)(function(e){return(0,d.m)(e.addEventListener)&&(0,d.m)(e.removeEventListener)}(e)?g.map((function(a){return function(n){return e[a](t,n,r)}})):function(e){return(0,d.m)(e.addListener)&&(0,d.m)(e.removeListener)}(e)?v.map(x(e,t)):function(e){return(0,d.m)(e.on)&&(0,d.m)(e.off)}(e)?y.map(x(e,t)):[],2),s=n[0],i=n[1];if(!s&&(0,h.z)(e))return(0,u.z)((function(e){return b(e,t,r)}))((0,c.Xf)(e));if(!s)throw new TypeError("Invalid event target");return new l.y((function(e){var t=function(){for(var t=[],r=0;r{for(await(0,k.YB)(B);C;){const e=$(),r=(0,k.YB)(e.timeToNextPeriod);if(e.period%2==0)try{await t.incrementalModify((t=>(t.beatPeriod>=e.period||(t.beatPeriod=e.period,t.color=D.O9[e.period%3],e.period%4==0?t.text1=L(S,e.period)[0]:t.text2=L(P,e.period)[0]),t)))}catch(p){}await r}})();const r=await e.upsertLocal("mousepos",{x:0,y:0,time:0});let a=[];window.addEventListener("mousemove",(e=>{a=[e.clientX,e.clientY]})),(0,i.T)(b(window,"mousemove"),b(window,"scroll"),b(window,"resize")).subscribe((()=>{r.incrementalPatch({x:a[0],y:a[1],time:(0,_.z)()})})),function(e){const t=document.getElementsByClassName("tilt-to-mouse"),r=100;function a(e,t,a){const n=a.getBoundingClientRect(),s=-(t-n.y-n.height/2)/r,i=(e-n.x-n.width/2)/r;return`perspective(150px) rotateX(${M(s)}deg) rotateY(${M(i)}deg) `}function n(e,t){e.style.transform=a.apply(null,t)}e.$.subscribe((e=>{e._data.data.time&&Array.from(t).forEach((t=>{if(!W(t))return;n(t,(0,j.Is)([e._data.data.x,e._data.data.y]).concat([t]))}))}))}(r),function(e){const t=document.getElementsByClassName("enlarge-on-mouse");function r(e){const t=e.getBoundingClientRect();return{centerX:t.left+t.width/2,centerY:t.top+t.height/2,width:t.width,height:t.height}}function a(e,t){const r=`scale(${t})`;e.style.transform=r}e.$.pipe((0,m.U)((e=>e._data))).subscribe((e=>{e.data.time&&e.data.x&&e.data.y&&Array.from(t).forEach((t=>{if(!W(t))return;const n=r(t),s=e.data.x-n.centerX,i=e.data.y-n.centerY,o=Math.sqrt(s*s+i*i);function c(e){return 1.9^e}let l=1+n.width/2/c(o+300);l>1.5&&(l=1.5),l<1.01&&(l=1),a(t,l)}))}))}(r);const n=document.getElementsByClassName("beating"),s=document.getElementsByClassName("beating-first"),o=document.getElementsByClassName("beating-second"),c=document.getElementsByClassName("beating-number"),l=document.getElementsByClassName("beating-color"),u=document.getElementsByClassName("beating-color-string"),h=[];let d=0;$(),t.$.pipe((0,m.U)((e=>e._data.data)),(0,w.x)(((e,t)=>JSON.stringify(e)===JSON.stringify(t)))).subscribe((e=>{h.forEach((function(e){e(d)})),d+=1;const t=e.color;Array.from(l).forEach((function(e){e.style.backgroundColor=t})),Array.from(u).forEach((function(e){e.innerHTML=t}))})),h.push((function(){Array.from(n).forEach((function(e){e.style.animationDuration=B+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")})),Array.from(s).forEach((function(e){e.style.animationDuration=B+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")})),Array.from(o).forEach((function(e){e.style.animationDuration=B+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")}))})),h.push((function(){Array.from(c).forEach((function(e){A()&&A()&&setTimeout((function(){const t=parseFloat(e.innerHTML)+1;e.innerHTML=t+""}),105)}))}))}function O(){const{siteConfig:e}=(0,a.Z)();return(0,N.useEffect)((()=>(R(),()=>{console.log("stop animation"),C=!1}))),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(s.Z,{children:(0,E.jsx)("body",{className:"homepage"})}),(0,E.jsx)(n.Z,{title:`${e.title}`,description:"RxDB is a fast, local-first NoSQL-database for JavaScript Applications like Websites, hybrid Apps, Electron-Apps, Progressive Web Apps and Node.js",children:(0,E.jsxs)("main",{children:[(0,E.jsx)("div",{className:"block first centered",children:(0,E.jsx)("div",{className:"content",children:(0,E.jsxs)("div",{className:"inner",children:[(0,E.jsxs)("div",{className:"half",children:[(0,E.jsx)("br",{}),(0,E.jsxs)("h1",{children:["The local ",(0,E.jsx)("b",{className:"underline",children:"Database"})," for"," ",(0,E.jsx)("b",{className:"underline",children:"JavaScript"})," Applications"]}),(0,E.jsx)("br",{}),(0,E.jsxs)("ul",{className:"checked",children:[(0,E.jsx)("li",{children:"Realtime Queries"}),(0,E.jsx)("li",{children:"Realtime Replication"}),(0,E.jsx)("li",{children:"Works Offline"}),(0,E.jsx)("li",{children:"Supports all JavaScript runtimes"}),(0,E.jsx)("li",{children:"Great Performance"})]}),(0,E.jsx)("a",{className:"button",href:"/quickstart.html",target:"_blank",children:"Get Started"}),(0,E.jsx)("div",{className:"clear"})]}),(0,E.jsx)("div",{className:"half",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,E.jsxs)("div",{className:"content-canvas",style:{marginTop:30,marginBottom:30},children:[(0,E.jsx)("div",{className:"device tablet",style:{marginLeft:481,marginTop:117},children:(0,E.jsx)("div",{className:"beating-color",style:{backgroundColor:"rgb(141, 32, 137)"},children:(0,E.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo animation",alt:"RxDB",style:{animationDuration:"851ms"}})})}),(0,E.jsx)("div",{className:"device desktop",style:{marginTop:"0%"},children:(0,E.jsx)("div",{className:"beating-color",style:{backgroundColor:"rgb(141, 32, 137)"},children:(0,E.jsx)("img",{src:"/files/logo/logo_text.svg",className:"beating logo animation",alt:"RxDB",style:{animationDuration:"851ms",width:"52%"}})})}),(0,E.jsxs)("div",{className:"device server",style:{marginLeft:0,marginTop:168},children:[(0,E.jsx)("div",{className:"beating-color one",style:{backgroundColor:"rgb(141, 32, 137)"}}),(0,E.jsx)("div",{className:"beating-color two",style:{backgroundColor:"rgb(141, 32, 137)"}}),(0,E.jsx)("div",{className:"beating-color three",style:{backgroundColor:"rgb(141, 32, 137)"}})]})]})})]})})}),(0,E.jsx)("a",{href:"https://github.com/pubkey/rxdb",onClick:()=>(0,I.X)("github_trophy_click",.2),target:"_blank",children:(0,E.jsxs)("div",{className:"trophy",children:[(0,E.jsx)("img",{src:"./files/icons/github-star-with-logo.svg",alt:"RxDB github star"}),(0,E.jsxs)("div",{style:{flex:1},children:[(0,E.jsx)("div",{className:"subtitle",children:"Open Source on"}),(0,E.jsx)("div",{className:"title",children:"GitHub"})]}),(0,E.jsxs)("div",{children:[(0,E.jsx)("div",{className:"valuetitle",children:"stars"}),(0,E.jsxs)("div",{className:"value",children:["19247",(0,E.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,E.jsx)("div",{className:"block second dark",children:(0,E.jsxs)("div",{className:"content",children:[(0,E.jsxs)("h2",{children:["Realtime applications ",(0,E.jsx)("b",{className:"underline",children:"made easy"})]}),(0,E.jsxs)("p",{children:["From the results of a query, to a single field of a document, with RxDB you can ",(0,E.jsx)("b",{children:"observe everything"}),". This enables you to build realtime applications ",(0,E.jsx)("b",{children:"fast"})," and ",(0,E.jsx)("b",{children:"reliable"}),". It does not matter if the data was changed by"," ",(0,E.jsx)("b",{children:"a user event"}),", ",(0,E.jsx)("b",{children:"another browser tab"})," or by the",(0,E.jsx)("b",{children:" replication"}),"."," ","Whenever your data changes, your UI reflects the new state."]}),(0,E.jsxs)("div",{className:"inner",children:[(0,E.jsxs)("div",{className:"code half",children:[(0,E.jsxs)("fieldset",{className:"samp-wrapper",style:{backgroundColor:"var(--bg-color)"},children:[(0,E.jsx)("legend",{children:"Write"}),(0,E.jsxs)("samp",{children:[(0,E.jsx)("span",{className:"cm-keyword",children:"await "}),(0,E.jsx)("span",{className:"cm-variable",children:"collection"}),".",(0,E.jsx)("span",{className:"cm-method",children:"upsert"}),"(","{",(0,E.jsx)("br",{}),(0,E.jsx)("span",{className:"cm-property",children:"\xa0 id"}),": ",(0,E.jsx)("span",{className:"cm-string",children:"'foobar'"}),",",(0,E.jsx)("br",{}),(0,E.jsx)("span",{className:"cm-property",children:"\xa0 color"}),": ",(0,E.jsxs)("span",{className:"cm-string",children:["'",(0,E.jsx)("span",{className:"beating-color-string beating-color",children:"#e6008d"}),"'"]}),(0,E.jsx)("br",{}),"}",");"]})]}),(0,E.jsx)("br",{}),(0,E.jsx)("br",{}),(0,E.jsxs)("fieldset",{className:"samp-wrapper",style:{backgroundColor:"var(--bg-color)"},children:[(0,E.jsx)("legend",{children:"Observe"}),(0,E.jsxs)("samp",{style:{backgroundColor:"var(--bg-color)"},children:[(0,E.jsx)("span",{className:"cm-keyword",children:"await "}),(0,E.jsx)("span",{className:"cm-variable",children:"collection"}),".",(0,E.jsxs)("span",{className:"cm-method",children:["findOne(",(0,E.jsx)("span",{className:"cm-string",children:"'foobar'"}),")"]}),(0,E.jsx)("br",{}),"\xa0.",(0,E.jsx)("span",{className:"cm-property",children:"$"}),(0,E.jsx)("span",{className:"cm-comment",children:" // get observable"}),(0,E.jsx)("br",{}),"\xa0.",(0,E.jsx)("span",{className:"cm-method",children:"subscribe"}),"(",(0,E.jsx)("span",{className:"cm-def",children:"d"}),(0,E.jsx)("span",{className:"cm-operator",children:" =>"})," ","{",(0,E.jsx)("br",{}),(0,E.jsx)("span",{className:"cm-variable",children:"\xa0\xa0 screen"}),".",(0,E.jsx)("span",{className:"cm-property",children:"backgroundColor"}),(0,E.jsx)("span",{className:"cm-operator",children:" = "}),(0,E.jsx)("span",{className:"cm-variable",children:"d"}),".",(0,E.jsx)("span",{className:"cm-property beating-color",children:"color"}),";",(0,E.jsx)("br",{}),"\xa0","}",");"]})]})]}),(0,E.jsx)("div",{className:"canvas half",children:(0,E.jsxs)("div",{className:"content-canvas",children:[(0,E.jsx)("div",{className:"device tablet",style:{marginLeft:481,marginTop:117},children:(0,E.jsx)("div",{className:"beating-color",children:(0,E.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo",alt:"RxDB"})})}),(0,E.jsx)("div",{className:"device desktop",style:{marginTop:"0%"},children:(0,E.jsx)("div",{className:"beating-color",children:(0,E.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo",alt:"RxDB"})})}),(0,E.jsxs)("div",{className:"device server",style:{marginLeft:0,marginTop:168},children:[(0,E.jsx)("div",{className:"beating-color one"}),(0,E.jsx)("div",{className:"beating-color two"}),(0,E.jsx)("div",{className:"beating-color three"})]})]})})]})]})}),(0,E.jsx)("a",{href:"https://twitter.com/intent/user?screen_name=rxdbjs",onClick:()=>(0,I.X)("twitter_trophy_click",.2),target:"_blank",children:(0,E.jsxs)("div",{className:"trophy twitter",children:[(0,E.jsx)("img",{src:"./files/icons/twitter-blue.svg",alt:"RxDB Twitter"}),(0,E.jsxs)("div",{style:{flex:1},children:[(0,E.jsx)("div",{className:"subtitle",children:"Follow on"}),(0,E.jsx)("div",{className:"title",children:"Twitter"})]}),(0,E.jsxs)("div",{children:[(0,E.jsx)("div",{className:"valuetitle",children:"followers"}),(0,E.jsxs)("div",{className:"value",children:["2843",(0,E.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,E.jsx)("div",{className:"block replication",children:(0,E.jsxs)("div",{className:"content",children:[(0,E.jsxs)("div",{className:"half left",children:[(0,E.jsx)("br",{}),(0,E.jsx)("br",{}),(0,E.jsx)("br",{}),(0,E.jsx)("br",{}),(0,E.jsx)("br",{}),(0,E.jsxs)("h2",{children:["Replicate ",(0,E.jsx)("b",{children:"with your existing infrastructure"})]}),(0,E.jsxs)("p",{children:["RxDB supports replication with a"," ",(0,E.jsx)("a",{href:"/replication-couchdb.html",target:"_blank",children:"CouchDB"})," ","server or any custom"," ",(0,E.jsx)("a",{href:"/replication-graphql.html",target:"_blank",children:"GraphQL"})," ","endpoint which smoothly integrates with your existing infrastructure. Also you can use the replication primitives plugin to create custom replications over any protocol like"," ",(0,E.jsx)("a",{href:"/replication-http.html",target:"_blank",children:"HTTP"}),","," ",(0,E.jsx)("a",{href:"/replication-websocket.html",target:"_blank",children:"Websocket"}),","," ",(0,E.jsx)("a",{href:"/replication-webrtc.html",target:"_blank",children:"WebRTC"})," ","or"," ",(0,E.jsx)("a",{href:"/replication-firestore.html",target:"_blank",children:"Firestore"}),"."]})]}),(0,E.jsx)("div",{className:"half right",children:(0,E.jsxs)("div",{className:"replication-icons",children:[(0,E.jsx)("img",{src:"./files/logo/logo.svg",alt:"RxDB",className:"replicate-logo tilt-to-mouse"}),(0,E.jsx)("a",{href:"/replication-graphql.html",target:"_blank",children:(0,E.jsx)("div",{className:"neumorphism-circle-xl centered replicate-graphql enlarge-on-mouse",children:(0,E.jsx)("img",{src:"./files/icons/graphql-text.svg",alt:"GraphQL",className:"protocol"})})}),(0,E.jsx)("a",{href:"/replication-couchdb.html",target:"_blank",children:(0,E.jsx)("div",{className:"neumorphism-circle-xl centered replicate-couchdb enlarge-on-mouse",children:(0,E.jsx)("img",{src:"./files/icons/couchdb-text.svg",alt:"CouchDB",className:"protocol"})})}),(0,E.jsxs)("div",{className:"neumorphism-circle-xs centered replicate-rest enlarge-on-mouse",children:["{"," REST ","}"]}),(0,E.jsx)("a",{href:"/replication-websocket.html",target:"_blank",children:(0,E.jsx)("div",{className:"neumorphism-circle-xs centered replicate-websocket enlarge-on-mouse",children:"websocket"})}),(0,E.jsx)("a",{href:"/replication-webrtc.html",target:"_blank",children:(0,E.jsx)("div",{className:"neumorphism-circle-xs centered replicate-webrtc enlarge-on-mouse",children:"WebRTC"})})]})}),(0,E.jsx)("div",{className:"clear"})]})}),(0,E.jsx)("a",{href:"https://rxdb.info/chat.html",onClick:()=>(0,I.X)("discord_trophy_click",.2),target:"_blank",children:(0,E.jsxs)("div",{className:"trophy discord",children:[(0,E.jsx)("img",{src:"./files/icons/discord.svg",alt:"RxDB Discord chat"}),(0,E.jsxs)("div",{style:{flex:1},children:[(0,E.jsx)("div",{className:"subtitle",children:"Chat on"}),(0,E.jsx)("div",{className:"title",children:"Discord"})]}),(0,E.jsxs)("div",{children:[(0,E.jsx)("div",{className:"valuetitle",children:"members"}),(0,E.jsxs)("div",{className:"value",children:["414",(0,E.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,E.jsxs)("div",{className:"block offline-first dark",children:[(0,E.jsx)("div",{className:"offline-image-wrapper",children:(0,E.jsx)("img",{src:"files/icons/wifi/wifi_1a202c.svg",className:"offline-image beating-second",alt:"offline"})}),(0,E.jsxs)("div",{className:"content",children:[(0,E.jsxs)("h2",{children:["Online ",(0,E.jsx)("b",{className:"underline",children:"is optional"})]}),(0,E.jsxs)("div",{className:"full-width",children:[(0,E.jsx)("div",{className:"half left",children:(0,E.jsxs)("p",{children:["RxDB follows the"," ",(0,E.jsx)("a",{href:"/offline-first.html",target:"_blank",children:"Offline First"})," ","paradigm where an application must work as well offline as it does online. This is done by persisting data locally on the client side and replicating it in the background. RxDB can even be used solely on the client side, with no backend at all."]})}),(0,E.jsx)("div",{className:"half right",children:(0,E.jsxs)("ul",{className:"checked",children:[(0,E.jsxs)("li",{children:["Your application still ",(0,E.jsx)("b",{children:"works offline"})]}),(0,E.jsxs)("li",{children:["Increases ",(0,E.jsx)("b",{children:"perceived performance"})]}),(0,E.jsxs)("li",{children:["Easier and ",(0,E.jsx)("b",{children:"faster implementation"})]}),(0,E.jsxs)("li",{children:["Needs less backend resources and ",(0,E.jsx)("b",{children:"scales better"})]})]})})]})]})]}),(0,E.jsx)("div",{className:"block frameworks",children:(0,E.jsxs)("div",{className:"content",children:[(0,E.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/angular",target:"_blank",children:(0,E.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"-10%",left:"10%"},children:[(0,E.jsx)("img",{src:"./files/icons/angular.svg",alt:"angular"}),"Angular"]})}),(0,E.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"10%",left:"58%"},children:[(0,E.jsx)("img",{src:"./files/icons/capacitor.svg",alt:"capacitor"}),"Capacitor"]}),(0,E.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"-4%",left:"44%"},children:[(0,E.jsx)("img",{src:"./files/icons/deno.svg",alt:"deno"}),"Deno"]}),(0,E.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/node",target:"_blank",children:(0,E.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"-5%",left:"85%"},children:[(0,E.jsx)("img",{src:"./files/icons/nodejs.svg",alt:"Node.js"}),"Node.js"]})}),(0,E.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/react",target:"_blank",children:(0,E.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"4%",left:"26%"},children:[(0,E.jsx)("img",{src:"./files/icons/react.svg",alt:"React"}),"React"]})}),(0,E.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"15%",left:"90%",marginLeft:"-35px"},children:[(0,E.jsx)("img",{src:"./files/icons/svelte.svg",alt:"Svelte"}),"Svelte"]}),(0,E.jsx)("br",{}),(0,E.jsx)("br",{}),(0,E.jsx)("br",{}),(0,E.jsx)("br",{}),(0,E.jsx)("br",{}),(0,E.jsxs)("h2",{children:["Flexible ",(0,E.jsx)("b",{className:"underline",children:"storage layer"})]}),(0,E.jsxs)("p",{children:["RxDB is based on a storage interface that enables you to swap out the underlying storage engine. This increases code reuse because the same database code can be used in ",(0,E.jsx)("b",{children:"any JavaScript runtime"})," ","by just switching out the storage settings.",(0,E.jsx)("br",{})]}),(0,E.jsxs)("div",{className:"below-text",children:[(0,E.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/electron",target:"_blank",children:(0,E.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"2%",left:"18%"},children:[(0,E.jsx)("img",{src:"./files/icons/electron.svg",alt:"electron"}),"Electron"]})}),(0,E.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/vue",target:"_blank",children:(0,E.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"3%",left:"45%"},children:[(0,E.jsx)("img",{src:"./files/icons/vuejs.svg",alt:"Vue.js"}),"Vue.js"]})}),(0,E.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/ionic2",target:"_blank",children:(0,E.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"2%",left:"71%"},children:[(0,E.jsx)("img",{src:"./files/icons/ionic.svg",alt:"ionic"}),"Ionic"]})}),(0,E.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"46%",left:"11%"},children:[(0,E.jsx)("img",{src:"./files/icons/nativescript.svg",alt:"NativeScript"}),"NativeScript"]}),(0,E.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/react-native",target:"_blank",children:(0,E.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"45%",left:"35%"},children:[(0,E.jsx)("img",{src:"./files/icons/react.svg",alt:"React Native"}),"React Native"]})}),(0,E.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"45%",left:"62%"},children:[(0,E.jsx)("img",{src:"./files/icons/nextjs.svg",alt:"Next.js"}),"Next.js"]}),(0,E.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/flutter",target:"_blank",children:(0,E.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"40%",left:"86%"},children:[(0,E.jsx)("img",{src:"./files/icons/flutter.svg",alt:"Flutter"}),"Flutter"]})})]})]})}),(0,E.jsx)("div",{className:"block fifth dark",children:(0,E.jsx)("div",{className:"content centered",children:(0,E.jsxs)("div",{className:"inner",children:[(0,E.jsxs)("h2",{children:["Trusted and ",(0,E.jsx)("b",{className:"underline",children:"open source"})]}),(0,E.jsxs)("div",{className:"box dark",children:[(0,E.jsx)("img",{src:"files/icons/github-star.svg",alt:"github star"}),(0,E.jsx)("div",{className:"label",children:"Github Stars"}),(0,E.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb",rel:"noopener",target:"_blank",children:"19247"}),(0,E.jsx)("div",{className:"clear"})]}),(0,E.jsxs)("div",{className:"box dark",children:[(0,E.jsx)("img",{src:"files/icons/download.svg",alt:"npm downloads"}),(0,E.jsx)("div",{className:"label",children:"npm downloads"}),(0,E.jsx)("a",{className:"value beating-number",href:"https://www.npmjs.com/package/rxdb",rel:"noopener",target:"_blank",children:"238572"}),(0,E.jsx)("div",{className:"clear"})]}),(0,E.jsx)("div",{className:"clear"}),(0,E.jsxs)("div",{className:"box dark",children:[(0,E.jsx)("img",{src:"files/icons/person.svg",alt:"contributor"}),(0,E.jsx)("div",{className:"label",children:"Contributors"}),(0,E.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/graphs/contributors",rel:"noopener",target:"_blank",children:"133"}),(0,E.jsx)("div",{className:"clear"})]}),(0,E.jsxs)("div",{className:"box dark",children:[(0,E.jsx)("img",{src:"files/icons/commit.svg",alt:"commit"}),(0,E.jsx)("div",{className:"label",children:"Commits"}),(0,E.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/commits/master",rel:"noopener",target:"_blank",children:"6891"}),(0,E.jsx)("div",{className:"clear"})]}),(0,E.jsx)("div",{className:"clear"}),(0,E.jsxs)("div",{className:"box dark",children:[(0,E.jsx)("img",{src:"files/icons/gear.svg",alt:"gear"}),(0,E.jsx)("div",{className:"label",children:"Projects build with RxDB"}),(0,E.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/network/dependents?package_id=UGFja2FnZS0xODM0NzAyMw%3D%3D",rel:"noopener",target:"_blank",children:"825"}),(0,E.jsx)("div",{className:"clear"})]}),(0,E.jsxs)("div",{className:"box dark",children:[(0,E.jsx)("img",{src:"files/icons/twitter.svg",alt:"twitter"}),(0,E.jsx)("div",{className:"label",children:"Twitter followers"}),(0,E.jsx)("a",{className:"value",href:"https://twitter.com/intent/user?screen_name=rxdbjs",rel:"noopener",target:"_blank",children:"2843"}),(0,E.jsx)("div",{className:"clear"})]}),(0,E.jsx)("div",{className:"clear"})]})})}),(0,E.jsx)("div",{className:"block sixth",children:(0,E.jsxs)("div",{className:"content",children:[(0,E.jsx)("h2",{children:"Pricing Models"}),(0,E.jsx)("div",{className:"inner",children:(0,E.jsxs)("div",{className:"buy-options",children:[(0,E.jsx)("div",{className:"buy-option bg-gradient-left-top",children:(0,E.jsxs)("div",{className:"buy-option-inner",children:[(0,E.jsxs)("div",{className:"buy-option-title",children:[(0,E.jsx)("h2",{children:"RxDB Basics"}),(0,E.jsx)("div",{className:"price",children:"Free & Open Source"})]}),(0,E.jsx)("div",{className:"buy-option-features",children:(0,E.jsxs)("ul",{children:[(0,E.jsx)("li",{children:"Basic RxStorages"}),(0,E.jsx)("li",{children:"Realtime Replication"}),(0,E.jsx)("li",{children:"Live Queries"}),(0,E.jsx)("li",{children:"Schema Validation"}),(0,E.jsx)("li",{children:"Multi-Tab Support"}),(0,E.jsx)("li",{children:"Encryption"}),(0,E.jsx)("li",{children:"Compression"})]})}),(0,E.jsx)("a",{href:"https://github.com/pubkey/rxdb",target:"_blank",rel:"noopener",onClick:()=>(0,I.X)("goto_code",.2),children:(0,E.jsx)("div",{className:"buy-option-action bg-top hover-shadow-top",children:"Get the Code"})})]})}),(0,E.jsx)("div",{className:"buy-option bg-gradient-right-top",children:(0,E.jsxs)("div",{className:"buy-option-inner",children:[(0,E.jsxs)("div",{className:"buy-option-title",children:[(0,E.jsx)("h2",{children:"Premium Plugins"}),(0,E.jsx)("div",{className:"price",children:"for professionals to get the most out of RxDB"})]}),(0,E.jsx)("div",{className:"buy-option-features",children:(0,E.jsxs)("ul",{children:[(0,E.jsx)("li",{children:(0,E.jsx)("a",{href:"https://rxdb.info/rx-storage-sqlite.html",target:"_blank",children:"SQLite RxStorage"})}),(0,E.jsx)("li",{children:(0,E.jsx)("a",{href:"https://rxdb.info/rx-storage-opfs.html",target:"_blank",children:"OPFS RxStorage"})}),(0,E.jsx)("li",{children:(0,E.jsx)("a",{href:"https://rxdb.info/rx-storage-indexeddb.html",target:"_blank",children:"IndexedDB RxStorage"})}),(0,E.jsx)("li",{children:(0,E.jsx)("a",{href:"https://rxdb.info/rx-storage-memory-synced.html",target:"_blank",children:"Memory-Synced RxStorage"})}),(0,E.jsx)("li",{children:(0,E.jsx)("a",{href:"https://rxdb.info/rx-storage-sharding.html",target:"_blank",children:"Sharding Plugin"})}),(0,E.jsx)("li",{children:(0,E.jsx)("a",{href:"https://rxdb.info/query-optimizer.html",target:"_blank",children:"Query Optimizer"})}),(0,E.jsx)("li",{children:(0,E.jsx)("a",{href:"https://rxdb.info/migration-storage.html",target:"_blank",children:"Storage Migrator"})}),(0,E.jsx)("li",{children:(0,E.jsx)("a",{href:"https://rxdb.info/rx-storage-localstorage-meta-optimizer.html",target:"_blank",children:"RxStorage Localstorage Meta Optimizer"})}),(0,E.jsx)("li",{children:(0,E.jsx)("a",{href:"https://rxdb.info/rx-storage-shared-worker.html",target:"_blank",children:"Shared Worker"})}),(0,E.jsx)("li",{children:(0,E.jsx)("a",{href:"https://rxdb.info/rx-storage-worker.html",target:"_blank",children:"Worker"})})]})}),(0,E.jsx)("a",{href:"/premium",onClick:()=>(0,I.X)("premium_request",1),children:(0,E.jsx)("div",{className:"buy-option-action bg-middle hover-shadow-middle",children:"Request Premium"})})]})}),(0,E.jsx)("div",{className:"buy-option bg-gradient-left-top",children:(0,E.jsxs)("div",{className:"buy-option-inner",children:[(0,E.jsxs)("div",{className:"buy-option-title",children:[(0,E.jsx)("h2",{children:"Consulting Session"}),(0,E.jsx)("div",{className:"price",children:"fast in person consulting"})]}),(0,E.jsx)("div",{className:"buy-option-features",children:(0,E.jsxs)("p",{children:["Book a one hour consulting session with the RxDB maintainer. I will answer all your questions, give proposals for your use case and we can even do a pair programming session if you have a specific problem in your source code.",(0,E.jsx)("br",{}),"You can book this by doing a one-time donation via github sponsors."]})}),(0,E.jsx)("a",{href:"https://github.com/sponsors/pubkey?frequency=one-time&sponsor=pubkey",target:"_blank",onClick:()=>(0,I.X)("consulting_session_request",1.5),children:(0,E.jsx)("div",{className:"buy-option-action bg-bottom hover-shadow-bottom",children:"Book Now"})})]})})]})})]})}),(0,E.jsx)("div",{className:"block last dark",children:(0,E.jsxs)("div",{className:"content",children:[(0,E.jsxs)("h2",{children:["Start using ",(0,E.jsx)("b",{className:"underline",children:"RxDB"})," today"]}),(0,E.jsxs)("div",{className:"buttons full-width",children:[(0,E.jsx)("a",{href:"/quickstart.html",rel:"noopener",target:"_blank",onClick:()=>(0,I.X)("start_now",.4),children:(0,E.jsx)("div",{className:"button get-premium",style:{left:"50%",top:"20%",marginLeft:"-122px"},children:"Start now"})}),(0,E.jsx)("a",{href:"https://rxdb.info/newsletter.html",rel:"noopener",target:"_blank",onClick:()=>(0,I.X)("get_newsletter",.4),children:(0,E.jsx)("div",{className:"button",style:{left:"25%",marginLeft:"-90px"},children:"Get the Newsletter"})}),(0,E.jsx)("a",{href:"https://rxdb.info/chat.html",rel:"noopener",target:"_blank",onClick:()=>(0,I.X)("join_chat",.4),children:(0,E.jsx)("div",{className:"button",style:{left:"77%",top:"6%",marginLeft:"-70.5px"},children:"Join the Chat"})}),(0,E.jsx)("a",{href:"/premium",onClick:()=>(0,I.X)("premium_request",1),children:(0,E.jsx)("div",{className:"button",style:{top:"40%",left:"20%",marginLeft:"-70.5px"},children:"Get Premium"})}),(0,E.jsx)("a",{href:"https://twitter.com/intent/user?screen_name=rxdbjs",rel:"noopener",target:"_blank",onClick:()=>(0,I.X)("follow_twitter",.4),children:(0,E.jsx)("div",{className:"button",style:{top:"44%",left:"73%",marginLeft:"-85px"},children:"Follow on Twitter"})}),(0,E.jsx)("a",{href:"https://github.com/pubkey/rxdb",rel:"noopener",target:"_blank",onClick:()=>(0,I.X)("goto_code",.4),children:(0,E.jsx)("div",{className:"button",style:{top:"54%",left:"32%",marginLeft:"-70px"},children:"Get the Code"})})]})]})})]})})]})}const S=["NoSQL","OfflineFirst","JavaScript","observable","reactive","realtime","client side","fast"],P=["for the Web","for Node.js","for Browsers","for Capacitor","for Electron","for hybrid apps","for PWAs","for React Native","for NativeScript","for UI apps","you deserve","that syncs"],B=851;function $(){const e=((new Date).getTime()-196e7)/B,t=Math.floor(e);return{ratio:e,period:t,timeToNextPeriod:(e-t)*B}}const T=22,q=-1*T;function M(e){return eT?T:e}function A(){return Math.random()<.5}function L(e,t){let r,a,n=(e=e.slice(0)).length;for(;n;)a=Math.floor(Q(t)*n--),r=e[n],e[n]=e[a],e[a]=r,++t;return e}function Q(e){const t=1e4*Math.sin(e++);return t-Math.floor(t)}function W(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}},6087:(e,t,r)=>{function a(e){return e[e.length-1]}function n(e){return Array.isArray(e)?e.slice(0):[e]}function s(e){return Array.isArray(e)}function i(e){return null!=e}function o(e,t){var r=0,a=-1;for(var n of e){if(!t(n,a+=1))break;r+=1}return r}function c(e,t){for(var r=t.length,a=0;as,Nb:()=>l,S7:()=>i,SI:()=>a,gu:()=>c,qo:()=>n,r0:()=>o})},7400:(e,t,r)=>{function a(e,t){if(!e)throw t||(t=""),new Error("ensureNotFalsy() is falsy: "+t);return e}r.d(t,{Is:()=>a,kv:()=>n});var n={bufferSize:1,refCount:!0}},4419:(e,t,r)=>{function a(){return new Promise((e=>setTimeout(e,0)))}function n(e){return void 0===e&&(e=0),new Promise((t=>setTimeout(t,e)))}r.d(t,{$Y:()=>o,C2:()=>u,Y3:()=>a,YB:()=>n,Ze:()=>h,kZ:()=>s,m5:()=>i,y$:()=>c});Promise.resolve(!0);var s=Promise.resolve(!1),i=Promise.resolve(null),o=Promise.resolve();function c(e){return void 0===e&&(e=1e4),"function"==typeof requestIdleCallback?new Promise((t=>{requestIdleCallback((()=>t()),{timeout:e})})):n(0)}var l=o;function u(e){return void 0===e&&(e=void 0),l=l.then((()=>c(e)))}function h(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},984:(e,t,r)=>{r.d(t,{z:()=>n});var a=0;function n(){var e=Date.now();(e+=.01)<=a&&(e=a+.01);var t=parseFloat(e.toFixed(2));return a=t,t}}}]);
\ No newline at end of file
+"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[3237],{5921:(e,t,r)=>{r.d(t,{O9:()=>zr,N8:()=>Hr,dZ:()=>Fr});var a=r(8061);function n(e,t){var r=e.get(t);if(void 0===r)throw new Error("missing value from map "+t);return r}function s(e,t,r,a){var n=e.get(t);return void 0===n?(n=r(),e.set(t,n)):a&&a(n),n}function i(e){return Object.assign({},e)}function o(e,t){if(void 0===t&&(t=!1),!e)return e;if(!t&&Array.isArray(e))return e.sort(((e,t)=>"string"==typeof e&&"string"==typeof t?e.localeCompare(t):"object"==typeof e?1:-1)).map((e=>o(e,t)));if("object"==typeof e&&!Array.isArray(e)){var r={};return Object.keys(e).sort(((e,t)=>e.localeCompare(t))).forEach((a=>{r[a]=o(e[a],t)})),r}return e}var c=function e(t){if(!t)return t;if(null===t||"object"!=typeof t)return t;if(Array.isArray(t)){for(var r=new Array(t.length),a=r.length;a--;)r[a]=e(t[a]);return r}var n={};for(var s in t)n[s]=e(t[s]);return n};function l(e,t,r){return Object.defineProperty(e,t,{get:function(){return r}}),r}var u=e=>{var t=typeof e;return null!==e&&("object"===t||"function"===t)},h=new Set(["__proto__","prototype","constructor"]),d=new Set("0123456789");function m(e){var t=[],r="",a="start",n=!1;for(var s of e)switch(s){case"\\":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");n&&(r+=s),a="property",n=!n;break;case".":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="property";break}if(n){n=!1,r+=s;break}if(h.has(r))return[];t.push(r),r="",a="property";break;case"[":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="index";break}if(n){n=!1,r+=s;break}if("property"===a){if(h.has(r))return[];t.push(r),r=""}a="index";break;case"]":if("index"===a){t.push(Number.parseInt(r,10)),r="",a="indexEnd";break}if("indexEnd"===a)throw new Error("Invalid character after an index");default:if("index"===a&&!d.has(s))throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");"start"===a&&(a="property"),n&&(n=!1,r+="\\"),r+=s}switch(n&&(r+="\\"),a){case"property":if(h.has(r))return[];t.push(r);break;case"index":throw new Error("Index was not closed");case"start":t.push("")}return t}function p(e,t){if("number"!=typeof t&&Array.isArray(e)){var r=Number.parseInt(t,10);return Number.isInteger(r)&&e[r]===e[t]}return!1}function f(e,t){if(p(e,t))throw new Error("Cannot use string index")}function v(e,t,r){if(Array.isArray(t)&&(t=t.join(".")),!t.includes(".")&&!t.includes("["))return e[t];if(!u(e)||"string"!=typeof t)return void 0===r?e:r;var a=m(t);if(0===a.length)return r;for(var n=0;n!1,deepFreezeWhenDevMode:e=>e,tunnelErrorMessage:e=>"RxDB Error-Code "+e+".\n Error messages are not included in RxDB core to reduce build size.\n - To find out what this error means, either use the dev-mode-plugin https://rxdb.info/dev-mode.html\n - or search for the error code here: https://github.com/pubkey/rxdb/search?q="+e+"\n "};function k(e,t,r){return"RxError ("+t+"):\n"+e+"\n"+function(e){var t="";return 0===Object.keys(e).length?t:(t+="Given parameters: {\n",t+=Object.keys(e).map((t=>{var r="[object Object]";try{r="errors"===t?e[t].map((e=>JSON.stringify(e,Object.getOwnPropertyNames(e)))):JSON.stringify(e[t],(function(e,t){return void 0===t?null:t}),2)}catch(a){}return t+":"+r})).join("\n"),t+="}")}(r)}var _=function(e){function t(t,r,a){var n;void 0===a&&(a={});var s=k(r,t,a);return(n=e.call(this,s)||this).code=t,n.message=s,n.parameters=a,n.rxdb=!0,n}return(0,x.Z)(t,e),t.prototype.toString=function(){return this.message},(0,b.Z)(t,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),t}((0,w.Z)(Error)),D=function(e){function t(t,r,a){var n;void 0===a&&(a={});var s=k(r,t,a);return(n=e.call(this,s)||this).code=t,n.message=s,n.parameters=a,n.rxdb=!0,n}return(0,x.Z)(t,e),t.prototype.toString=function(){return this.message},(0,b.Z)(t,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),t}((0,w.Z)(TypeError));function N(e,t){return new _(e,j.tunnelErrorMessage(e),t)}function I(e,t){return new D(e,j.tunnelErrorMessage(e),t)}function E(e){return!(!e||409!==e.status)&&e}var C={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var R=/\./g,O="abcdefghijklmnopqrstuvwxyz";function S(e){void 0===e&&(e=10);for(var t="",r=0;r