From 4d50e17a9567cee87217e87340ac3dfe6e1cc756 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 23:08:12 +0000 Subject: [PATCH] 15.10.0 --- CHANGELOG.md | 10 ++++-- dist/cjs/plugins/storage-remote/remote.js | 8 +++++ dist/cjs/plugins/storage-remote/remote.js.map | 2 +- dist/cjs/plugins/utils/utils-array.js | 5 +++ dist/cjs/plugins/utils/utils-array.js.map | 2 +- dist/cjs/plugins/utils/utils-rxdb-version.js | 2 +- .../plugins/utils/utils-rxdb-version.js.map | 2 +- dist/esm/plugins/storage-remote/remote.js | 8 +++++ dist/esm/plugins/storage-remote/remote.js.map | 2 +- dist/esm/plugins/utils/utils-array.js | 4 +++ dist/esm/plugins/utils/utils-array.js.map | 2 +- dist/esm/plugins/utils/utils-rxdb-version.js | 2 +- .../plugins/utils/utils-rxdb-version.js.map | 2 +- dist/types/plugins/storage-denokv/index.d.ts | 2 +- .../storage-dexie/rx-storage-dexie.d.ts | 2 +- .../storage-lokijs/rx-storage-lokijs.d.ts | 2 +- .../storage-mongodb/rx-storage-mongodb.d.ts | 2 +- .../storage-remote/rx-storage-remote.d.ts | 2 +- dist/types/plugins/utils/utils-array.d.ts | 1 + .../plugins/utils/utils-rxdb-version.d.ts | 2 +- dist/types/rx-database.d.ts | 2 +- docs/404.html | 4 +-- docs/adapters.html | 4 +-- docs/alternatives.html | 4 +-- docs/articles/angular-database.html | 4 +-- docs/articles/browser-database.html | 4 +-- docs/articles/browser-storage.html | 4 +-- docs/articles/data-base.html | 4 +-- docs/articles/embedded-database.html | 4 +-- docs/articles/flutter-database.html | 4 +-- docs/articles/frontend-database.html | 4 +-- docs/articles/in-memory-nosql-database.html | 4 +-- docs/articles/ionic-database.html | 4 +-- docs/articles/json-database.html | 4 +-- docs/articles/localstorage.html | 4 +-- docs/articles/mobile-database.html | 4 +-- .../progressive-web-app-database.html | 4 +-- docs/articles/react-database.html | 4 +-- docs/articles/realtime-database.html | 4 +-- docs/assets/js/0e268d20.2d62c3fd.js | 1 + docs/assets/js/0e268d20.f1ff5a10.js | 1 - docs/assets/js/1b238727.8126c191.js | 1 - docs/assets/js/1b238727.dfc4a389.js | 1 + docs/assets/js/1df93b7f.35927cbb.js | 1 + docs/assets/js/1df93b7f.e4d1174b.js | 1 - docs/assets/js/32667c41.12eda0f5.js | 1 + docs/assets/js/32667c41.15f9ac4c.js | 1 - .../js/{5106.4acc95d1.js => 5106.839e1170.js} | 2 +- docs/assets/js/6cbff7c2.2c0fdd4e.js | 1 - docs/assets/js/6cbff7c2.648148ea.js | 1 + docs/assets/js/cbbe8f0a.9592af82.js | 1 - docs/assets/js/cbbe8f0a.eb6667a5.js | 1 + docs/assets/js/cde77f4f.61f8bda2.js | 1 + docs/assets/js/cde77f4f.a6f9099e.js | 1 - docs/assets/js/db34d6b0.648ab0fc.js | 1 + docs/assets/js/main.5517924f.js | 2 ++ ...CENSE.txt => main.5517924f.js.LICENSE.txt} | 0 docs/assets/js/main.ba92057b.js | 2 -- docs/assets/js/runtime~main.03298db3.js | 1 - docs/assets/js/runtime~main.ddc381ef.js | 1 + docs/backup.html | 4 +-- docs/capacitor-database.html | 4 +-- docs/chat/index.html | 4 +-- docs/cleanup.html | 4 +-- docs/code/index.html | 4 +-- docs/contribution.html | 4 +-- docs/crdt.html | 4 +-- docs/data-migration/index.html | 4 +-- docs/dev-mode.html | 4 +-- docs/downsides-of-offline-first.html | 4 +-- docs/electron-database.html | 4 +-- docs/electron.html | 4 +-- docs/encryption.html | 4 +-- docs/files/rx-storage-performance-browser.png | Bin 56043 -> 44495 bytes docs/index.html | 4 +-- docs/install.html | 4 +-- docs/key-compression.html | 4 +-- docs/leader-election.html | 4 +-- docs/legal-notice/index.html | 4 +-- docs/license/index.html | 21 ++++++++++++ docs/logger.html | 4 +-- docs/lunr-index-1708823008214.json | 1 - docs/lunr-index-1709075253588.json | 1 + docs/lunr-index.json | 2 +- docs/markdown-page/index.html | 4 +-- docs/middleware.html | 4 +-- docs/migration-schema.html | 4 +-- docs/migration-storage.html | 4 +-- docs/newsletter/index.html | 4 +-- docs/nodejs-database.html | 4 +-- docs/nosql-performance-tips.html | 6 ++-- docs/offline-first.html | 4 +-- docs/orm.html | 4 +-- docs/plugins.html | 4 +-- docs/population.html | 4 +-- docs/premium-submitted/index.html | 4 +-- docs/premium/index.html | 4 +-- docs/query-cache.html | 4 +-- docs/query-optimizer.html | 4 +-- docs/questions-answers.html | 4 +-- docs/quickstart.html | 4 +-- docs/react-native-database.html | 4 +-- docs/reactivity.html | 4 +-- docs/releases/10.0.0.html | 4 +-- docs/releases/11.0.0.html | 4 +-- docs/releases/12.0.0.html | 4 +-- docs/releases/13.0.0.html | 4 +-- docs/releases/14.0.0.html | 4 +-- docs/releases/15.0.0.html | 4 +-- docs/releases/8.0.0.html | 4 +-- docs/releases/9.0.0.html | 4 +-- docs/replication-couchdb.html | 4 +-- docs/replication-firestore.html | 4 +-- docs/replication-graphql.html | 4 +-- docs/replication-http.html | 4 +-- docs/replication-nats.html | 4 +-- docs/replication-p2p.html | 4 +-- docs/replication-server/index.html | 4 +-- docs/replication-webrtc.html | 4 +-- docs/replication-websocket.html | 4 +-- docs/replication.html | 4 +-- docs/rx-attachment.html | 4 +-- docs/rx-collection.html | 9 +++-- docs/rx-database.html | 4 +-- docs/rx-document.html | 4 +-- docs/rx-local-document.html | 4 +-- docs/rx-query.html | 4 +-- docs/rx-schema.html | 4 +-- docs/rx-server-scaling.html | 4 +-- docs/rx-server.html | 4 +-- docs/rx-storage-denokv.html | 4 +-- docs/rx-storage-dexie.html | 4 +-- docs/rx-storage-filesystem-node.html | 4 +-- docs/rx-storage-foundationdb.html | 4 +-- docs/rx-storage-indexeddb.html | 4 +-- ...x-storage-localstorage-meta-optimizer.html | 4 +-- docs/rx-storage-lokijs.html | 4 +-- docs/rx-storage-memory-synced.html | 4 +-- docs/rx-storage-memory.html | 4 +-- docs/rx-storage-mongodb.html | 4 +-- docs/rx-storage-opfs.html | 14 ++++++-- docs/rx-storage-performance.html | 31 ++++++++++++++---- docs/rx-storage-pouchdb.html | 4 +-- docs/rx-storage-remote.html | 4 +-- docs/rx-storage-sharding.html | 4 +-- docs/rx-storage-shared-worker.html | 4 +-- docs/rx-storage-sqlite.html | 4 +-- docs/rx-storage-worker.html | 4 +-- docs/rx-storage.html | 4 +-- docs/rxdb-tradeoffs.html | 4 +-- docs/schema-validation.html | 4 +-- docs/search-doc-1708823008214.json | 1 - docs/search-doc-1709075253588.json | 1 + docs/search-doc.json | 2 +- docs/sitemap.xml | 2 +- docs/slow-indexeddb.html | 4 +-- docs/survey/index.html | 4 +-- docs/third-party-plugins.html | 4 +-- docs/transactions-conflicts-revisions.html | 4 +-- docs/tutorials/typescript.html | 4 +-- docs/why-nosql.html | 4 +-- package.json | 2 +- src/plugins/utils/utils-rxdb-version.ts | 2 +- 163 files changed, 344 insertions(+), 264 deletions(-) create mode 100644 docs/assets/js/0e268d20.2d62c3fd.js delete mode 100644 docs/assets/js/0e268d20.f1ff5a10.js delete mode 100644 docs/assets/js/1b238727.8126c191.js create mode 100644 docs/assets/js/1b238727.dfc4a389.js create mode 100644 docs/assets/js/1df93b7f.35927cbb.js delete mode 100644 docs/assets/js/1df93b7f.e4d1174b.js create mode 100644 docs/assets/js/32667c41.12eda0f5.js delete mode 100644 docs/assets/js/32667c41.15f9ac4c.js rename docs/assets/js/{5106.4acc95d1.js => 5106.839e1170.js} (55%) delete mode 100644 docs/assets/js/6cbff7c2.2c0fdd4e.js create mode 100644 docs/assets/js/6cbff7c2.648148ea.js delete mode 100644 docs/assets/js/cbbe8f0a.9592af82.js create mode 100644 docs/assets/js/cbbe8f0a.eb6667a5.js create mode 100644 docs/assets/js/cde77f4f.61f8bda2.js delete mode 100644 docs/assets/js/cde77f4f.a6f9099e.js create mode 100644 docs/assets/js/db34d6b0.648ab0fc.js create mode 100644 docs/assets/js/main.5517924f.js rename docs/assets/js/{main.ba92057b.js.LICENSE.txt => main.5517924f.js.LICENSE.txt} (100%) delete mode 100644 docs/assets/js/main.ba92057b.js delete mode 100644 docs/assets/js/runtime~main.03298db3.js create mode 100644 docs/assets/js/runtime~main.ddc381ef.js create mode 100644 docs/license/index.html delete mode 100644 docs/lunr-index-1708823008214.json create mode 100644 docs/lunr-index-1709075253588.json delete mode 100644 docs/search-doc-1708823008214.json create mode 100644 docs/search-doc-1709075253588.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a8b737d947..be7bf1d7b8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,15 +2,19 @@ # RxDB Changelog -- IMPROVE [OPFS RxStorage](https://rxdb.info/rx-storage-opfs.html) performance. -- ADD `usesRxDatabaseInWorker` option to the [OPFS RxStorage](https://rxdb.info/rx-storage-opfs.html). -- ADD `getRxStorageOPFSMainThread()` to run OPFS from the main thread instead of a worker for less latency. + +### 15.10.0 (27 February 2024) + +- IMPROVE [OPFS RxStorage](https://rxdb.info/rx-storage-opfs.html) performance. +- ADD `usesRxDatabaseInWorker` option to the [OPFS RxStorage](https://rxdb.info/rx-storage-opfs.html). +- ADD `getRxStorageOPFSMainThread()` to run OPFS from the main thread instead of a worker for less latency. + ### 15.9.1 (21 February 2024) - FIX creating two databases with the same name but different storage must work. diff --git a/dist/cjs/plugins/storage-remote/remote.js b/dist/cjs/plugins/storage-remote/remote.js index 96f96a2ab47..c48a3708aa8 100644 --- a/dist/cjs/plugins/storage-remote/remote.js +++ b/dist/cjs/plugins/storage-remote/remote.js @@ -86,6 +86,14 @@ function exposeRxStorageRemote(settings) { params }; instanceByFullName.set(fullName, state); + + /** + * Must await the creation here + * so that in case of an error, + * it knows about the error message and can send + * that back to the main process. + */ + await state.storageInstancePromise; } catch (err) { settings.send((0, _storageRemoteHelpers.createErrorAnswer)(msg, err)); return; diff --git a/dist/cjs/plugins/storage-remote/remote.js.map b/dist/cjs/plugins/storage-remote/remote.js.map index af807f0d9bb..0ca1632b210 100644 --- a/dist/cjs/plugins/storage-remote/remote.js.map +++ b/dist/cjs/plugins/storage-remote/remote.js.map @@ -1 +1 @@ -{"version":3,"file":"remote.js","names":["_rxjs","require","_index","_storageRemoteHelpers","_rxStorageHelper","exposeRxStorageRemote","settings","instanceByFullName","Map","messages$","pipe","filter","msg","method","subscribe","customRequestHandler","send","createErrorAnswer","Error","result","params","createAnswer","err","getRxStorageInstance","storage","createStorageInstance","database","storageInstances","Array","from","collectionName","storageInstance","find","instance","console","dir","JSON","stringify","schema","deepEqual","existingSchema","Promise","resolve","connectionId","isArray","fullName","databaseName","version","join","state","get","storageInstancePromise","connectionIds","Set","set","add","subs","push","changeStream","changes","message","answerTo","return","conflictResultionTasks","conflicts","connectionClosed","closeThisConnection","forEach","sub","unsubscribe","ensureNotFalsy","delete","collection","collections","onDestroy","subMsg","plainMessage","size","getChangedDocumentsSince"],"sources":["../../../../src/plugins/storage-remote/remote.ts"],"sourcesContent":["import { filter, Subscription } from 'rxjs';\nimport type {\n RxStorageInstance,\n RxStorageInstanceCreationParams\n} from '../../types/index.d.ts';\nimport {\n deepEqual,\n ensureNotFalsy\n} from '../../plugins/utils/index.ts';\nimport { createAnswer, createErrorAnswer } from './storage-remote-helpers.ts';\nimport type {\n MessageFromRemote,\n MessageToRemote,\n RxStorageRemoteExposeSettings,\n RxStorageRemoteExposeSettingsRxDatabase,\n RxStorageRemoteExposeSettingsRxStorage,\n RxStorageRemoteExposeType\n} from './storage-remote-types.ts';\nimport { getChangedDocumentsSince } from '../../rx-storage-helper.ts';\n\n/**\n * Run this on the 'remote' part,\n * so that RxStorageMessageChannel can connect to it.\n */\nexport function exposeRxStorageRemote(settings: RxStorageRemoteExposeSettings): RxStorageRemoteExposeType {\n type InstanceState = {\n storageInstancePromise: Promise>;\n connectionIds: Set;\n params: RxStorageInstanceCreationParams;\n };\n const instanceByFullName: Map = new Map();\n\n\n settings.messages$.pipe(\n filter(msg => msg.method === 'custom')\n ).subscribe(async (msg) => {\n if (!settings.customRequestHandler) {\n settings.send(createErrorAnswer(\n msg,\n new Error('Remote storage: cannot resolve custom request because settings.customRequestHandler is not set')\n ));\n } else {\n try {\n const result = await settings.customRequestHandler(msg.params);\n settings.send(createAnswer(msg, result));\n } catch (err: any) {\n settings.send(createErrorAnswer(\n msg,\n err\n ));\n }\n }\n });\n\n\n function getRxStorageInstance(params: any): Promise> {\n if ((settings as RxStorageRemoteExposeSettingsRxStorage).storage) {\n return (settings as RxStorageRemoteExposeSettingsRxStorage).storage.createStorageInstance(params);\n } else if ((settings as RxStorageRemoteExposeSettingsRxDatabase).database) {\n const storageInstances = Array.from((settings as RxStorageRemoteExposeSettingsRxDatabase).database.storageInstances);\n const collectionName = params.collectionName;\n const storageInstance = storageInstances.find(instance => instance.collectionName === collectionName);\n if (!storageInstance) {\n console.dir(storageInstances);\n throw new Error('storageInstance does not exist ' + JSON.stringify({\n collectionName\n }));\n }\n const schema = params.schema;\n if (!deepEqual(schema, storageInstance.schema)) {\n throw new Error('Wrong schema ' + JSON.stringify({\n schema,\n existingSchema: storageInstance.schema\n }));\n }\n return Promise.resolve(storageInstance);\n } else {\n throw new Error('no base given');\n }\n }\n\n settings.messages$.pipe(\n filter(msg => msg.method === 'create')\n ).subscribe(async (msg) => {\n const connectionId = msg.connectionId;\n\n /**\n * Do an isArray check here\n * for runtime check types to ensure we have\n * instance creation params and not method input params.\n */\n if (Array.isArray(msg.params)) {\n return;\n }\n const params = msg.params;\n const collectionName = params.collectionName;\n\n /**\n * We de-duplicate the storage instances.\n * This makes sense in many environments like\n * electron where on main process contains the storage\n * for multiple renderer processes. Same goes for SharedWorkers etc.\n */\n const fullName = [\n params.databaseName,\n params.collectionName,\n params.schema.version\n ].join('|');\n let state = instanceByFullName.get(fullName);\n if (!state) {\n try {\n state = {\n /**\n * We work with a promise here to ensure\n * that parallel create-calls will still end up\n * with exactly one instance and not more.\n */\n storageInstancePromise: getRxStorageInstance(params),\n connectionIds: new Set(),\n params\n };\n instanceByFullName.set(fullName, state);\n } catch (err: any) {\n settings.send(createErrorAnswer(msg, err));\n return;\n }\n } else {\n // if instance already existed, ensure that the schema is equal\n if (!deepEqual(params.schema, state.params.schema)) {\n settings.send(createErrorAnswer(msg, new Error('Remote storage: schema not equal to existing storage')));\n return;\n }\n }\n state.connectionIds.add(msg.connectionId);\n const subs: Subscription[] = [];\n\n const storageInstance = await state.storageInstancePromise;\n /**\n * Automatically subscribe to the changeStream()\n * because we always need them.\n */\n subs.push(\n storageInstance.changeStream().subscribe(changes => {\n const message: MessageFromRemote = {\n connectionId,\n answerTo: 'changestream',\n method: 'changeStream',\n return: changes\n };\n settings.send(message);\n })\n );\n subs.push(\n storageInstance.conflictResultionTasks().subscribe(conflicts => {\n const message: MessageFromRemote = {\n connectionId,\n answerTo: 'conflictResultionTasks',\n method: 'conflictResultionTasks',\n return: conflicts\n };\n settings.send(message);\n })\n );\n\n\n let connectionClosed = false;\n function closeThisConnection() {\n if (connectionClosed) {\n return;\n }\n connectionClosed = true;\n subs.forEach(sub => sub.unsubscribe());\n ensureNotFalsy(state).connectionIds.delete(connectionId);\n instanceByFullName.delete(fullName);\n /**\n * TODO how to notify the other ports on remove() ?\n */\n }\n\n // also close the connection when the collection gets destroyed\n if ((settings as RxStorageRemoteExposeSettingsRxDatabase).database) {\n const database = (settings as RxStorageRemoteExposeSettingsRxDatabase).database;\n const collection = database.collections[collectionName];\n if (collection) {\n collection.onDestroy.push(() => closeThisConnection());\n } else {\n database.onDestroy.push(() => closeThisConnection());\n }\n }\n\n subs.push(\n settings.messages$.pipe(\n filter(subMsg => (subMsg as MessageToRemote).connectionId === connectionId)\n ).subscribe(async (plainMessage) => {\n const message: MessageToRemote = plainMessage as any;\n if (\n message.method === 'create' ||\n message.method === 'custom'\n ) {\n return;\n }\n if (!Array.isArray(message.params)) {\n return;\n }\n let result;\n try {\n if (\n message.method === 'close' &&\n (settings as RxStorageRemoteExposeSettingsRxDatabase).database\n ) {\n /**\n * Do not close the storageInstance if it was taken from\n * a running RxDatabase.\n * In that case we only close the instance\n * when the RxDatabase gets destroyed.\n */\n settings.send(createAnswer(message, null));\n return;\n }\n /**\n * On calls to 'close()',\n * we only close the main instance if there are no other\n * ports connected.\n */\n if (\n message.method === 'close' &&\n ensureNotFalsy(state).connectionIds.size > 1\n ) {\n settings.send(createAnswer(message, null));\n ensureNotFalsy(state).connectionIds.delete(connectionId);\n subs.forEach(sub => sub.unsubscribe());\n return;\n }\n\n if (message.method === 'getChangedDocumentsSince' && !storageInstance.getChangedDocumentsSince) {\n result = await getChangedDocumentsSince(\n storageInstance,\n message.params[0],\n message.params[1]\n );\n } else {\n result = await (storageInstance as any)[message.method](\n message.params[0],\n message.params[1],\n message.params[2],\n message.params[3]\n );\n }\n if (\n message.method === 'close' ||\n message.method === 'remove'\n ) {\n closeThisConnection();\n }\n settings.send(createAnswer(message, result));\n } catch (err: any) {\n settings.send(createErrorAnswer(message, err));\n }\n })\n );\n\n settings.send(createAnswer(msg, 'ok'));\n });\n\n return {\n instanceByFullName\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AAIA,IAAAE,qBAAA,GAAAF,OAAA;AASA,IAAAG,gBAAA,GAAAH,OAAA;AAEA;AACA;AACA;AACA;AACO,SAASI,qBAAqBA,CAACC,QAAuC,EAA6B;EAMtG,IAAMC,kBAA8C,GAAG,IAAIC,GAAG,CAAC,CAAC;EAGhEF,QAAQ,CAACG,SAAS,CAACC,IAAI,CACnB,IAAAC,YAAM,EAACC,GAAG,IAAIA,GAAG,CAACC,MAAM,KAAK,QAAQ,CACzC,CAAC,CAACC,SAAS,CAAC,MAAOF,GAAG,IAAK;IACvB,IAAI,CAACN,QAAQ,CAACS,oBAAoB,EAAE;MAChCT,QAAQ,CAACU,IAAI,CAAC,IAAAC,uCAAiB,EAC3BL,GAAG,EACH,IAAIM,KAAK,CAAC,gGAAgG,CAC9G,CAAC,CAAC;IACN,CAAC,MAAM;MACH,IAAI;QACA,IAAMC,MAAM,GAAG,MAAMb,QAAQ,CAACS,oBAAoB,CAACH,GAAG,CAACQ,MAAM,CAAC;QAC9Dd,QAAQ,CAACU,IAAI,CAAC,IAAAK,kCAAY,EAACT,GAAG,EAAEO,MAAM,CAAC,CAAC;MAC5C,CAAC,CAAC,OAAOG,GAAQ,EAAE;QACfhB,QAAQ,CAACU,IAAI,CAAC,IAAAC,uCAAiB,EAC3BL,GAAG,EACHU,GACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;EAGF,SAASC,oBAAoBA,CAAYH,MAAW,EAAwD;IACxG,IAAKd,QAAQ,CAA4CkB,OAAO,EAAE;MAC9D,OAAQlB,QAAQ,CAA4CkB,OAAO,CAACC,qBAAqB,CAACL,MAAM,CAAC;IACrG,CAAC,MAAM,IAAKd,QAAQ,CAA6CoB,QAAQ,EAAE;MACvE,IAAMC,gBAAgB,GAAGC,KAAK,CAACC,IAAI,CAAEvB,QAAQ,CAA6CoB,QAAQ,CAACC,gBAAgB,CAAC;MACpH,IAAMG,cAAc,GAAGV,MAAM,CAACU,cAAc;MAC5C,IAAMC,eAAe,GAAGJ,gBAAgB,CAACK,IAAI,CAACC,QAAQ,IAAIA,QAAQ,CAACH,cAAc,KAAKA,cAAc,CAAC;MACrG,IAAI,CAACC,eAAe,EAAE;QAClBG,OAAO,CAACC,GAAG,CAACR,gBAAgB,CAAC;QAC7B,MAAM,IAAIT,KAAK,CAAC,iCAAiC,GAAGkB,IAAI,CAACC,SAAS,CAAC;UAC/DP;QACJ,CAAC,CAAC,CAAC;MACP;MACA,IAAMQ,MAAM,GAAGlB,MAAM,CAACkB,MAAM;MAC5B,IAAI,CAAC,IAAAC,gBAAS,EAACD,MAAM,EAAEP,eAAe,CAACO,MAAM,CAAC,EAAE;QAC5C,MAAM,IAAIpB,KAAK,CAAC,eAAe,GAAGkB,IAAI,CAACC,SAAS,CAAC;UAC7CC,MAAM;UACNE,cAAc,EAAET,eAAe,CAACO;QACpC,CAAC,CAAC,CAAC;MACP;MACA,OAAOG,OAAO,CAACC,OAAO,CAACX,eAAe,CAAC;IAC3C,CAAC,MAAM;MACH,MAAM,IAAIb,KAAK,CAAC,eAAe,CAAC;IACpC;EACJ;EAEAZ,QAAQ,CAACG,SAAS,CAACC,IAAI,CACnB,IAAAC,YAAM,EAACC,GAAG,IAAIA,GAAG,CAACC,MAAM,KAAK,QAAQ,CACzC,CAAC,CAACC,SAAS,CAAC,MAAOF,GAAG,IAAK;IACvB,IAAM+B,YAAY,GAAG/B,GAAG,CAAC+B,YAAY;;IAErC;AACR;AACA;AACA;AACA;IACQ,IAAIf,KAAK,CAACgB,OAAO,CAAChC,GAAG,CAACQ,MAAM,CAAC,EAAE;MAC3B;IACJ;IACA,IAAMA,MAAM,GAAGR,GAAG,CAACQ,MAAM;IACzB,IAAMU,cAAc,GAAGV,MAAM,CAACU,cAAc;;IAE5C;AACR;AACA;AACA;AACA;AACA;IACQ,IAAMe,QAAQ,GAAG,CACbzB,MAAM,CAAC0B,YAAY,EACnB1B,MAAM,CAACU,cAAc,EACrBV,MAAM,CAACkB,MAAM,CAACS,OAAO,CACxB,CAACC,IAAI,CAAC,GAAG,CAAC;IACX,IAAIC,KAAK,GAAG1C,kBAAkB,CAAC2C,GAAG,CAACL,QAAQ,CAAC;IAC5C,IAAI,CAACI,KAAK,EAAE;MACR,IAAI;QACAA,KAAK,GAAG;UACJ;AACpB;AACA;AACA;AACA;UACoBE,sBAAsB,EAAE5B,oBAAoB,CAACH,MAAM,CAAC;UACpDgC,aAAa,EAAE,IAAIC,GAAG,CAAC,CAAC;UACxBjC;QACJ,CAAC;QACDb,kBAAkB,CAAC+C,GAAG,CAACT,QAAQ,EAAEI,KAAK,CAAC;MAC3C,CAAC,CAAC,OAAO3B,GAAQ,EAAE;QACfhB,QAAQ,CAACU,IAAI,CAAC,IAAAC,uCAAiB,EAACL,GAAG,EAAEU,GAAG,CAAC,CAAC;QAC1C;MACJ;IACJ,CAAC,MAAM;MACH;MACA,IAAI,CAAC,IAAAiB,gBAAS,EAACnB,MAAM,CAACkB,MAAM,EAAEW,KAAK,CAAC7B,MAAM,CAACkB,MAAM,CAAC,EAAE;QAChDhC,QAAQ,CAACU,IAAI,CAAC,IAAAC,uCAAiB,EAACL,GAAG,EAAE,IAAIM,KAAK,CAAC,sDAAsD,CAAC,CAAC,CAAC;QACxG;MACJ;IACJ;IACA+B,KAAK,CAACG,aAAa,CAACG,GAAG,CAAC3C,GAAG,CAAC+B,YAAY,CAAC;IACzC,IAAMa,IAAoB,GAAG,EAAE;IAE/B,IAAMzB,eAAe,GAAG,MAAMkB,KAAK,CAACE,sBAAsB;IAC1D;AACR;AACA;AACA;IACQK,IAAI,CAACC,IAAI,CACL1B,eAAe,CAAC2B,YAAY,CAAC,CAAC,CAAC5C,SAAS,CAAC6C,OAAO,IAAI;MAChD,IAAMC,OAA0B,GAAG;QAC/BjB,YAAY;QACZkB,QAAQ,EAAE,cAAc;QACxBhD,MAAM,EAAE,cAAc;QACtBiD,MAAM,EAAEH;MACZ,CAAC;MACDrD,QAAQ,CAACU,IAAI,CAAC4C,OAAO,CAAC;IAC1B,CAAC,CACL,CAAC;IACDJ,IAAI,CAACC,IAAI,CACL1B,eAAe,CAACgC,sBAAsB,CAAC,CAAC,CAACjD,SAAS,CAACkD,SAAS,IAAI;MAC5D,IAAMJ,OAA0B,GAAG;QAC/BjB,YAAY;QACZkB,QAAQ,EAAE,wBAAwB;QAClChD,MAAM,EAAE,wBAAwB;QAChCiD,MAAM,EAAEE;MACZ,CAAC;MACD1D,QAAQ,CAACU,IAAI,CAAC4C,OAAO,CAAC;IAC1B,CAAC,CACL,CAAC;IAGD,IAAIK,gBAAgB,GAAG,KAAK;IAC5B,SAASC,mBAAmBA,CAAA,EAAG;MAC3B,IAAID,gBAAgB,EAAE;QAClB;MACJ;MACAA,gBAAgB,GAAG,IAAI;MACvBT,IAAI,CAACW,OAAO,CAACC,GAAG,IAAIA,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC;MACtC,IAAAC,qBAAc,EAACrB,KAAK,CAAC,CAACG,aAAa,CAACmB,MAAM,CAAC5B,YAAY,CAAC;MACxDpC,kBAAkB,CAACgE,MAAM,CAAC1B,QAAQ,CAAC;MACnC;AACZ;AACA;IACQ;;IAEA;IACA,IAAKvC,QAAQ,CAA6CoB,QAAQ,EAAE;MAChE,IAAMA,QAAQ,GAAIpB,QAAQ,CAA6CoB,QAAQ;MAC/E,IAAM8C,UAAU,GAAG9C,QAAQ,CAAC+C,WAAW,CAAC3C,cAAc,CAAC;MACvD,IAAI0C,UAAU,EAAE;QACZA,UAAU,CAACE,SAAS,CAACjB,IAAI,CAAC,MAAMS,mBAAmB,CAAC,CAAC,CAAC;MAC1D,CAAC,MAAM;QACHxC,QAAQ,CAACgD,SAAS,CAACjB,IAAI,CAAC,MAAMS,mBAAmB,CAAC,CAAC,CAAC;MACxD;IACJ;IAEAV,IAAI,CAACC,IAAI,CACLnD,QAAQ,CAACG,SAAS,CAACC,IAAI,CACnB,IAAAC,YAAM,EAACgE,MAAM,IAAKA,MAAM,CAAqBhC,YAAY,KAAKA,YAAY,CAC9E,CAAC,CAAC7B,SAAS,CAAC,MAAO8D,YAAY,IAAK;MAChC,IAAMhB,OAAwB,GAAGgB,YAAmB;MACpD,IACIhB,OAAO,CAAC/C,MAAM,KAAK,QAAQ,IAC3B+C,OAAO,CAAC/C,MAAM,KAAK,QAAQ,EAC7B;QACE;MACJ;MACA,IAAI,CAACe,KAAK,CAACgB,OAAO,CAACgB,OAAO,CAACxC,MAAM,CAAC,EAAE;QAChC;MACJ;MACA,IAAID,MAAM;MACV,IAAI;QACA,IACIyC,OAAO,CAAC/C,MAAM,KAAK,OAAO,IACzBP,QAAQ,CAA6CoB,QAAQ,EAChE;UACE;AACxB;AACA;AACA;AACA;AACA;UACwBpB,QAAQ,CAACU,IAAI,CAAC,IAAAK,kCAAY,EAACuC,OAAO,EAAE,IAAI,CAAC,CAAC;UAC1C;QACJ;QACA;AACpB;AACA;AACA;AACA;QACoB,IACIA,OAAO,CAAC/C,MAAM,KAAK,OAAO,IAC1B,IAAAyD,qBAAc,EAACrB,KAAK,CAAC,CAACG,aAAa,CAACyB,IAAI,GAAG,CAAC,EAC9C;UACEvE,QAAQ,CAACU,IAAI,CAAC,IAAAK,kCAAY,EAACuC,OAAO,EAAE,IAAI,CAAC,CAAC;UAC1C,IAAAU,qBAAc,EAACrB,KAAK,CAAC,CAACG,aAAa,CAACmB,MAAM,CAAC5B,YAAY,CAAC;UACxDa,IAAI,CAACW,OAAO,CAACC,GAAG,IAAIA,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC;UACtC;QACJ;QAEA,IAAIT,OAAO,CAAC/C,MAAM,KAAK,0BAA0B,IAAI,CAACkB,eAAe,CAAC+C,wBAAwB,EAAE;UAC5F3D,MAAM,GAAG,MAAM,IAAA2D,yCAAwB,EACnC/C,eAAe,EACf6B,OAAO,CAACxC,MAAM,CAAC,CAAC,CAAC,EACjBwC,OAAO,CAACxC,MAAM,CAAC,CAAC,CACpB,CAAC;QACL,CAAC,MAAM;UACHD,MAAM,GAAG,MAAOY,eAAe,CAAS6B,OAAO,CAAC/C,MAAM,CAAC,CACnD+C,OAAO,CAACxC,MAAM,CAAC,CAAC,CAAC,EACjBwC,OAAO,CAACxC,MAAM,CAAC,CAAC,CAAC,EACjBwC,OAAO,CAACxC,MAAM,CAAC,CAAC,CAAC,EACjBwC,OAAO,CAACxC,MAAM,CAAC,CAAC,CACpB,CAAC;QACL;QACA,IACIwC,OAAO,CAAC/C,MAAM,KAAK,OAAO,IAC1B+C,OAAO,CAAC/C,MAAM,KAAK,QAAQ,EAC7B;UACEqD,mBAAmB,CAAC,CAAC;QACzB;QACA5D,QAAQ,CAACU,IAAI,CAAC,IAAAK,kCAAY,EAACuC,OAAO,EAAEzC,MAAM,CAAC,CAAC;MAChD,CAAC,CAAC,OAAOG,GAAQ,EAAE;QACfhB,QAAQ,CAACU,IAAI,CAAC,IAAAC,uCAAiB,EAAC2C,OAAO,EAAEtC,GAAG,CAAC,CAAC;MAClD;IACJ,CAAC,CACL,CAAC;IAEDhB,QAAQ,CAACU,IAAI,CAAC,IAAAK,kCAAY,EAACT,GAAG,EAAE,IAAI,CAAC,CAAC;EAC1C,CAAC,CAAC;EAEF,OAAO;IACHL;EACJ,CAAC;AACL"} \ No newline at end of file +{"version":3,"file":"remote.js","names":["_rxjs","require","_index","_storageRemoteHelpers","_rxStorageHelper","exposeRxStorageRemote","settings","instanceByFullName","Map","messages$","pipe","filter","msg","method","subscribe","customRequestHandler","send","createErrorAnswer","Error","result","params","createAnswer","err","getRxStorageInstance","storage","createStorageInstance","database","storageInstances","Array","from","collectionName","storageInstance","find","instance","console","dir","JSON","stringify","schema","deepEqual","existingSchema","Promise","resolve","connectionId","isArray","fullName","databaseName","version","join","state","get","storageInstancePromise","connectionIds","Set","set","add","subs","push","changeStream","changes","message","answerTo","return","conflictResultionTasks","conflicts","connectionClosed","closeThisConnection","forEach","sub","unsubscribe","ensureNotFalsy","delete","collection","collections","onDestroy","subMsg","plainMessage","size","getChangedDocumentsSince"],"sources":["../../../../src/plugins/storage-remote/remote.ts"],"sourcesContent":["import { filter, Subscription } from 'rxjs';\nimport type {\n RxStorageInstance,\n RxStorageInstanceCreationParams\n} from '../../types/index.d.ts';\nimport {\n deepEqual,\n ensureNotFalsy\n} from '../../plugins/utils/index.ts';\nimport { createAnswer, createErrorAnswer } from './storage-remote-helpers.ts';\nimport type {\n MessageFromRemote,\n MessageToRemote,\n RxStorageRemoteExposeSettings,\n RxStorageRemoteExposeSettingsRxDatabase,\n RxStorageRemoteExposeSettingsRxStorage,\n RxStorageRemoteExposeType\n} from './storage-remote-types.ts';\nimport { getChangedDocumentsSince } from '../../rx-storage-helper.ts';\n\n/**\n * Run this on the 'remote' part,\n * so that RxStorageMessageChannel can connect to it.\n */\nexport function exposeRxStorageRemote(settings: RxStorageRemoteExposeSettings): RxStorageRemoteExposeType {\n type InstanceState = {\n storageInstancePromise: Promise>;\n connectionIds: Set;\n params: RxStorageInstanceCreationParams;\n };\n const instanceByFullName: Map = new Map();\n\n\n settings.messages$.pipe(\n filter(msg => msg.method === 'custom')\n ).subscribe(async (msg) => {\n if (!settings.customRequestHandler) {\n settings.send(createErrorAnswer(\n msg,\n new Error('Remote storage: cannot resolve custom request because settings.customRequestHandler is not set')\n ));\n } else {\n try {\n const result = await settings.customRequestHandler(msg.params);\n settings.send(createAnswer(msg, result));\n } catch (err: any) {\n settings.send(createErrorAnswer(\n msg,\n err\n ));\n }\n }\n });\n\n\n function getRxStorageInstance(params: any): Promise> {\n if ((settings as RxStorageRemoteExposeSettingsRxStorage).storage) {\n return (settings as RxStorageRemoteExposeSettingsRxStorage).storage.createStorageInstance(params);\n } else if ((settings as RxStorageRemoteExposeSettingsRxDatabase).database) {\n const storageInstances = Array.from((settings as RxStorageRemoteExposeSettingsRxDatabase).database.storageInstances);\n const collectionName = params.collectionName;\n const storageInstance = storageInstances.find(instance => instance.collectionName === collectionName);\n if (!storageInstance) {\n console.dir(storageInstances);\n throw new Error('storageInstance does not exist ' + JSON.stringify({\n collectionName\n }));\n }\n const schema = params.schema;\n if (!deepEqual(schema, storageInstance.schema)) {\n throw new Error('Wrong schema ' + JSON.stringify({\n schema,\n existingSchema: storageInstance.schema\n }));\n }\n return Promise.resolve(storageInstance);\n } else {\n throw new Error('no base given');\n }\n }\n\n settings.messages$.pipe(\n filter(msg => msg.method === 'create')\n ).subscribe(async (msg) => {\n const connectionId = msg.connectionId;\n\n /**\n * Do an isArray check here\n * for runtime check types to ensure we have\n * instance creation params and not method input params.\n */\n if (Array.isArray(msg.params)) {\n return;\n }\n const params = msg.params;\n const collectionName = params.collectionName;\n\n /**\n * We de-duplicate the storage instances.\n * This makes sense in many environments like\n * electron where on main process contains the storage\n * for multiple renderer processes. Same goes for SharedWorkers etc.\n */\n const fullName = [\n params.databaseName,\n params.collectionName,\n params.schema.version\n ].join('|');\n let state = instanceByFullName.get(fullName);\n if (!state) {\n try {\n state = {\n /**\n * We work with a promise here to ensure\n * that parallel create-calls will still end up\n * with exactly one instance and not more.\n */\n storageInstancePromise: getRxStorageInstance(params),\n connectionIds: new Set(),\n params\n };\n instanceByFullName.set(fullName, state);\n\n /**\n * Must await the creation here\n * so that in case of an error,\n * it knows about the error message and can send\n * that back to the main process. \n */\n await state.storageInstancePromise;\n } catch (err: any) {\n settings.send(createErrorAnswer(msg, err));\n return;\n }\n } else {\n // if instance already existed, ensure that the schema is equal\n if (!deepEqual(params.schema, state.params.schema)) {\n settings.send(createErrorAnswer(msg, new Error('Remote storage: schema not equal to existing storage')));\n return;\n }\n }\n state.connectionIds.add(msg.connectionId);\n const subs: Subscription[] = [];\n\n const storageInstance = await state.storageInstancePromise;\n /**\n * Automatically subscribe to the changeStream()\n * because we always need them.\n */\n subs.push(\n storageInstance.changeStream().subscribe(changes => {\n const message: MessageFromRemote = {\n connectionId,\n answerTo: 'changestream',\n method: 'changeStream',\n return: changes\n };\n settings.send(message);\n })\n );\n subs.push(\n storageInstance.conflictResultionTasks().subscribe(conflicts => {\n const message: MessageFromRemote = {\n connectionId,\n answerTo: 'conflictResultionTasks',\n method: 'conflictResultionTasks',\n return: conflicts\n };\n settings.send(message);\n })\n );\n\n\n let connectionClosed = false;\n function closeThisConnection() {\n if (connectionClosed) {\n return;\n }\n connectionClosed = true;\n subs.forEach(sub => sub.unsubscribe());\n ensureNotFalsy(state).connectionIds.delete(connectionId);\n instanceByFullName.delete(fullName);\n /**\n * TODO how to notify the other ports on remove() ?\n */\n }\n\n // also close the connection when the collection gets destroyed\n if ((settings as RxStorageRemoteExposeSettingsRxDatabase).database) {\n const database = (settings as RxStorageRemoteExposeSettingsRxDatabase).database;\n const collection = database.collections[collectionName];\n if (collection) {\n collection.onDestroy.push(() => closeThisConnection());\n } else {\n database.onDestroy.push(() => closeThisConnection());\n }\n }\n\n subs.push(\n settings.messages$.pipe(\n filter(subMsg => (subMsg as MessageToRemote).connectionId === connectionId)\n ).subscribe(async (plainMessage) => {\n const message: MessageToRemote = plainMessage as any;\n if (\n message.method === 'create' ||\n message.method === 'custom'\n ) {\n return;\n }\n if (!Array.isArray(message.params)) {\n return;\n }\n let result;\n try {\n if (\n message.method === 'close' &&\n (settings as RxStorageRemoteExposeSettingsRxDatabase).database\n ) {\n /**\n * Do not close the storageInstance if it was taken from\n * a running RxDatabase.\n * In that case we only close the instance\n * when the RxDatabase gets destroyed.\n */\n settings.send(createAnswer(message, null));\n return;\n }\n /**\n * On calls to 'close()',\n * we only close the main instance if there are no other\n * ports connected.\n */\n if (\n message.method === 'close' &&\n ensureNotFalsy(state).connectionIds.size > 1\n ) {\n settings.send(createAnswer(message, null));\n ensureNotFalsy(state).connectionIds.delete(connectionId);\n subs.forEach(sub => sub.unsubscribe());\n return;\n }\n\n if (message.method === 'getChangedDocumentsSince' && !storageInstance.getChangedDocumentsSince) {\n result = await getChangedDocumentsSince(\n storageInstance,\n message.params[0],\n message.params[1]\n );\n } else {\n result = await (storageInstance as any)[message.method](\n message.params[0],\n message.params[1],\n message.params[2],\n message.params[3]\n );\n }\n if (\n message.method === 'close' ||\n message.method === 'remove'\n ) {\n closeThisConnection();\n }\n settings.send(createAnswer(message, result));\n } catch (err: any) {\n settings.send(createErrorAnswer(message, err));\n }\n })\n );\n\n settings.send(createAnswer(msg, 'ok'));\n });\n\n return {\n instanceByFullName\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AAIA,IAAAE,qBAAA,GAAAF,OAAA;AASA,IAAAG,gBAAA,GAAAH,OAAA;AAEA;AACA;AACA;AACA;AACO,SAASI,qBAAqBA,CAACC,QAAuC,EAA6B;EAMtG,IAAMC,kBAA8C,GAAG,IAAIC,GAAG,CAAC,CAAC;EAGhEF,QAAQ,CAACG,SAAS,CAACC,IAAI,CACnB,IAAAC,YAAM,EAACC,GAAG,IAAIA,GAAG,CAACC,MAAM,KAAK,QAAQ,CACzC,CAAC,CAACC,SAAS,CAAC,MAAOF,GAAG,IAAK;IACvB,IAAI,CAACN,QAAQ,CAACS,oBAAoB,EAAE;MAChCT,QAAQ,CAACU,IAAI,CAAC,IAAAC,uCAAiB,EAC3BL,GAAG,EACH,IAAIM,KAAK,CAAC,gGAAgG,CAC9G,CAAC,CAAC;IACN,CAAC,MAAM;MACH,IAAI;QACA,IAAMC,MAAM,GAAG,MAAMb,QAAQ,CAACS,oBAAoB,CAACH,GAAG,CAACQ,MAAM,CAAC;QAC9Dd,QAAQ,CAACU,IAAI,CAAC,IAAAK,kCAAY,EAACT,GAAG,EAAEO,MAAM,CAAC,CAAC;MAC5C,CAAC,CAAC,OAAOG,GAAQ,EAAE;QACfhB,QAAQ,CAACU,IAAI,CAAC,IAAAC,uCAAiB,EAC3BL,GAAG,EACHU,GACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;EAGF,SAASC,oBAAoBA,CAAYH,MAAW,EAAwD;IACxG,IAAKd,QAAQ,CAA4CkB,OAAO,EAAE;MAC9D,OAAQlB,QAAQ,CAA4CkB,OAAO,CAACC,qBAAqB,CAACL,MAAM,CAAC;IACrG,CAAC,MAAM,IAAKd,QAAQ,CAA6CoB,QAAQ,EAAE;MACvE,IAAMC,gBAAgB,GAAGC,KAAK,CAACC,IAAI,CAAEvB,QAAQ,CAA6CoB,QAAQ,CAACC,gBAAgB,CAAC;MACpH,IAAMG,cAAc,GAAGV,MAAM,CAACU,cAAc;MAC5C,IAAMC,eAAe,GAAGJ,gBAAgB,CAACK,IAAI,CAACC,QAAQ,IAAIA,QAAQ,CAACH,cAAc,KAAKA,cAAc,CAAC;MACrG,IAAI,CAACC,eAAe,EAAE;QAClBG,OAAO,CAACC,GAAG,CAACR,gBAAgB,CAAC;QAC7B,MAAM,IAAIT,KAAK,CAAC,iCAAiC,GAAGkB,IAAI,CAACC,SAAS,CAAC;UAC/DP;QACJ,CAAC,CAAC,CAAC;MACP;MACA,IAAMQ,MAAM,GAAGlB,MAAM,CAACkB,MAAM;MAC5B,IAAI,CAAC,IAAAC,gBAAS,EAACD,MAAM,EAAEP,eAAe,CAACO,MAAM,CAAC,EAAE;QAC5C,MAAM,IAAIpB,KAAK,CAAC,eAAe,GAAGkB,IAAI,CAACC,SAAS,CAAC;UAC7CC,MAAM;UACNE,cAAc,EAAET,eAAe,CAACO;QACpC,CAAC,CAAC,CAAC;MACP;MACA,OAAOG,OAAO,CAACC,OAAO,CAACX,eAAe,CAAC;IAC3C,CAAC,MAAM;MACH,MAAM,IAAIb,KAAK,CAAC,eAAe,CAAC;IACpC;EACJ;EAEAZ,QAAQ,CAACG,SAAS,CAACC,IAAI,CACnB,IAAAC,YAAM,EAACC,GAAG,IAAIA,GAAG,CAACC,MAAM,KAAK,QAAQ,CACzC,CAAC,CAACC,SAAS,CAAC,MAAOF,GAAG,IAAK;IACvB,IAAM+B,YAAY,GAAG/B,GAAG,CAAC+B,YAAY;;IAErC;AACR;AACA;AACA;AACA;IACQ,IAAIf,KAAK,CAACgB,OAAO,CAAChC,GAAG,CAACQ,MAAM,CAAC,EAAE;MAC3B;IACJ;IACA,IAAMA,MAAM,GAAGR,GAAG,CAACQ,MAAM;IACzB,IAAMU,cAAc,GAAGV,MAAM,CAACU,cAAc;;IAE5C;AACR;AACA;AACA;AACA;AACA;IACQ,IAAMe,QAAQ,GAAG,CACbzB,MAAM,CAAC0B,YAAY,EACnB1B,MAAM,CAACU,cAAc,EACrBV,MAAM,CAACkB,MAAM,CAACS,OAAO,CACxB,CAACC,IAAI,CAAC,GAAG,CAAC;IACX,IAAIC,KAAK,GAAG1C,kBAAkB,CAAC2C,GAAG,CAACL,QAAQ,CAAC;IAC5C,IAAI,CAACI,KAAK,EAAE;MACR,IAAI;QACAA,KAAK,GAAG;UACJ;AACpB;AACA;AACA;AACA;UACoBE,sBAAsB,EAAE5B,oBAAoB,CAACH,MAAM,CAAC;UACpDgC,aAAa,EAAE,IAAIC,GAAG,CAAC,CAAC;UACxBjC;QACJ,CAAC;QACDb,kBAAkB,CAAC+C,GAAG,CAACT,QAAQ,EAAEI,KAAK,CAAC;;QAEvC;AAChB;AACA;AACA;AACA;AACA;QACgB,MAAMA,KAAK,CAACE,sBAAsB;MACtC,CAAC,CAAC,OAAO7B,GAAQ,EAAE;QACfhB,QAAQ,CAACU,IAAI,CAAC,IAAAC,uCAAiB,EAACL,GAAG,EAAEU,GAAG,CAAC,CAAC;QAC1C;MACJ;IACJ,CAAC,MAAM;MACH;MACA,IAAI,CAAC,IAAAiB,gBAAS,EAACnB,MAAM,CAACkB,MAAM,EAAEW,KAAK,CAAC7B,MAAM,CAACkB,MAAM,CAAC,EAAE;QAChDhC,QAAQ,CAACU,IAAI,CAAC,IAAAC,uCAAiB,EAACL,GAAG,EAAE,IAAIM,KAAK,CAAC,sDAAsD,CAAC,CAAC,CAAC;QACxG;MACJ;IACJ;IACA+B,KAAK,CAACG,aAAa,CAACG,GAAG,CAAC3C,GAAG,CAAC+B,YAAY,CAAC;IACzC,IAAMa,IAAoB,GAAG,EAAE;IAE/B,IAAMzB,eAAe,GAAG,MAAMkB,KAAK,CAACE,sBAAsB;IAC1D;AACR;AACA;AACA;IACQK,IAAI,CAACC,IAAI,CACL1B,eAAe,CAAC2B,YAAY,CAAC,CAAC,CAAC5C,SAAS,CAAC6C,OAAO,IAAI;MAChD,IAAMC,OAA0B,GAAG;QAC/BjB,YAAY;QACZkB,QAAQ,EAAE,cAAc;QACxBhD,MAAM,EAAE,cAAc;QACtBiD,MAAM,EAAEH;MACZ,CAAC;MACDrD,QAAQ,CAACU,IAAI,CAAC4C,OAAO,CAAC;IAC1B,CAAC,CACL,CAAC;IACDJ,IAAI,CAACC,IAAI,CACL1B,eAAe,CAACgC,sBAAsB,CAAC,CAAC,CAACjD,SAAS,CAACkD,SAAS,IAAI;MAC5D,IAAMJ,OAA0B,GAAG;QAC/BjB,YAAY;QACZkB,QAAQ,EAAE,wBAAwB;QAClChD,MAAM,EAAE,wBAAwB;QAChCiD,MAAM,EAAEE;MACZ,CAAC;MACD1D,QAAQ,CAACU,IAAI,CAAC4C,OAAO,CAAC;IAC1B,CAAC,CACL,CAAC;IAGD,IAAIK,gBAAgB,GAAG,KAAK;IAC5B,SAASC,mBAAmBA,CAAA,EAAG;MAC3B,IAAID,gBAAgB,EAAE;QAClB;MACJ;MACAA,gBAAgB,GAAG,IAAI;MACvBT,IAAI,CAACW,OAAO,CAACC,GAAG,IAAIA,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC;MACtC,IAAAC,qBAAc,EAACrB,KAAK,CAAC,CAACG,aAAa,CAACmB,MAAM,CAAC5B,YAAY,CAAC;MACxDpC,kBAAkB,CAACgE,MAAM,CAAC1B,QAAQ,CAAC;MACnC;AACZ;AACA;IACQ;;IAEA;IACA,IAAKvC,QAAQ,CAA6CoB,QAAQ,EAAE;MAChE,IAAMA,QAAQ,GAAIpB,QAAQ,CAA6CoB,QAAQ;MAC/E,IAAM8C,UAAU,GAAG9C,QAAQ,CAAC+C,WAAW,CAAC3C,cAAc,CAAC;MACvD,IAAI0C,UAAU,EAAE;QACZA,UAAU,CAACE,SAAS,CAACjB,IAAI,CAAC,MAAMS,mBAAmB,CAAC,CAAC,CAAC;MAC1D,CAAC,MAAM;QACHxC,QAAQ,CAACgD,SAAS,CAACjB,IAAI,CAAC,MAAMS,mBAAmB,CAAC,CAAC,CAAC;MACxD;IACJ;IAEAV,IAAI,CAACC,IAAI,CACLnD,QAAQ,CAACG,SAAS,CAACC,IAAI,CACnB,IAAAC,YAAM,EAACgE,MAAM,IAAKA,MAAM,CAAqBhC,YAAY,KAAKA,YAAY,CAC9E,CAAC,CAAC7B,SAAS,CAAC,MAAO8D,YAAY,IAAK;MAChC,IAAMhB,OAAwB,GAAGgB,YAAmB;MACpD,IACIhB,OAAO,CAAC/C,MAAM,KAAK,QAAQ,IAC3B+C,OAAO,CAAC/C,MAAM,KAAK,QAAQ,EAC7B;QACE;MACJ;MACA,IAAI,CAACe,KAAK,CAACgB,OAAO,CAACgB,OAAO,CAACxC,MAAM,CAAC,EAAE;QAChC;MACJ;MACA,IAAID,MAAM;MACV,IAAI;QACA,IACIyC,OAAO,CAAC/C,MAAM,KAAK,OAAO,IACzBP,QAAQ,CAA6CoB,QAAQ,EAChE;UACE;AACxB;AACA;AACA;AACA;AACA;UACwBpB,QAAQ,CAACU,IAAI,CAAC,IAAAK,kCAAY,EAACuC,OAAO,EAAE,IAAI,CAAC,CAAC;UAC1C;QACJ;QACA;AACpB;AACA;AACA;AACA;QACoB,IACIA,OAAO,CAAC/C,MAAM,KAAK,OAAO,IAC1B,IAAAyD,qBAAc,EAACrB,KAAK,CAAC,CAACG,aAAa,CAACyB,IAAI,GAAG,CAAC,EAC9C;UACEvE,QAAQ,CAACU,IAAI,CAAC,IAAAK,kCAAY,EAACuC,OAAO,EAAE,IAAI,CAAC,CAAC;UAC1C,IAAAU,qBAAc,EAACrB,KAAK,CAAC,CAACG,aAAa,CAACmB,MAAM,CAAC5B,YAAY,CAAC;UACxDa,IAAI,CAACW,OAAO,CAACC,GAAG,IAAIA,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC;UACtC;QACJ;QAEA,IAAIT,OAAO,CAAC/C,MAAM,KAAK,0BAA0B,IAAI,CAACkB,eAAe,CAAC+C,wBAAwB,EAAE;UAC5F3D,MAAM,GAAG,MAAM,IAAA2D,yCAAwB,EACnC/C,eAAe,EACf6B,OAAO,CAACxC,MAAM,CAAC,CAAC,CAAC,EACjBwC,OAAO,CAACxC,MAAM,CAAC,CAAC,CACpB,CAAC;QACL,CAAC,MAAM;UACHD,MAAM,GAAG,MAAOY,eAAe,CAAS6B,OAAO,CAAC/C,MAAM,CAAC,CACnD+C,OAAO,CAACxC,MAAM,CAAC,CAAC,CAAC,EACjBwC,OAAO,CAACxC,MAAM,CAAC,CAAC,CAAC,EACjBwC,OAAO,CAACxC,MAAM,CAAC,CAAC,CAAC,EACjBwC,OAAO,CAACxC,MAAM,CAAC,CAAC,CACpB,CAAC;QACL;QACA,IACIwC,OAAO,CAAC/C,MAAM,KAAK,OAAO,IAC1B+C,OAAO,CAAC/C,MAAM,KAAK,QAAQ,EAC7B;UACEqD,mBAAmB,CAAC,CAAC;QACzB;QACA5D,QAAQ,CAACU,IAAI,CAAC,IAAAK,kCAAY,EAACuC,OAAO,EAAEzC,MAAM,CAAC,CAAC;MAChD,CAAC,CAAC,OAAOG,GAAQ,EAAE;QACfhB,QAAQ,CAACU,IAAI,CAAC,IAAAC,uCAAiB,EAAC2C,OAAO,EAAEtC,GAAG,CAAC,CAAC;MAClD;IACJ,CAAC,CACL,CAAC;IAEDhB,QAAQ,CAACU,IAAI,CAAC,IAAAK,kCAAY,EAACT,GAAG,EAAE,IAAI,CAAC,CAAC;EAC1C,CAAC,CAAC;EAEF,OAAO;IACHL;EACJ,CAAC;AACL"} \ No newline at end of file diff --git a/dist/cjs/plugins/utils/utils-array.js b/dist/cjs/plugins/utils/utils-array.js index bffe485b0d9..cefdcfe43fd 100644 --- a/dist/cjs/plugins/utils/utils-array.js +++ b/dist/cjs/plugins/utils/utils-array.js @@ -12,6 +12,7 @@ exports.isMaybeReadonlyArray = isMaybeReadonlyArray; exports.isOneItemOfArrayInOtherArray = isOneItemOfArrayInOtherArray; exports.lastOfArray = lastOfArray; exports.maxOfNumbers = maxOfNumbers; +exports.randomOfArray = randomOfArray; exports.removeOneFromArrayIfMatches = removeOneFromArrayIfMatches; exports.shuffleArray = shuffleArray; exports.sumNumberArray = sumNumberArray; @@ -27,6 +28,10 @@ function lastOfArray(ar) { function shuffleArray(arr) { return arr.slice(0).sort(() => Math.random() - 0.5); } +function randomOfArray(arr) { + var randomElement = arr[Math.floor(Math.random() * arr.length)]; + return randomElement; +} function toArray(input) { return Array.isArray(input) ? input.slice(0) : [input]; } diff --git a/dist/cjs/plugins/utils/utils-array.js.map b/dist/cjs/plugins/utils/utils-array.js.map index 62a8bf69997..b8ef1bc5316 100644 --- a/dist/cjs/plugins/utils/utils-array.js.map +++ b/dist/cjs/plugins/utils/utils-array.js.map @@ -1 +1 @@ -{"version":3,"file":"utils-array.js","names":["lastOfArray","ar","length","shuffleArray","arr","slice","sort","Math","random","toArray","input","Array","isArray","batchArray","array","batchSize","ret","batch","splice","push","removeOneFromArrayIfMatches","condition","i","done","isMaybeReadonlyArray","x","isOneItemOfArrayInOtherArray","ar1","ar2","el","has","includes","arrayFilterNotEmpty","value","undefined","countUntilNotMatching","matchingFn","count","idx","item","matching","asyncFilter","predicate","filters","Promise","all","map","filter","index","sumNumberArray","maxOfNumbers","max","appendToArray","add","amount","element","uniqueArray","arrArg","elem","pos","indexOf"],"sources":["../../../../src/plugins/utils/utils-array.ts"],"sourcesContent":["import type {\n MaybePromise,\n MaybeReadonly\n} from '../../types/index.d.ts';\n\nexport function lastOfArray(ar: T[]): T | undefined {\n return ar[ar.length - 1];\n}\n\n/**\n * shuffle the given array\n */\nexport function shuffleArray(arr: T[]): T[] {\n return arr.slice(0).sort(() => (Math.random() - 0.5));\n}\n\nexport function toArray(input: T | T[] | Readonly | Readonly): T[] {\n return Array.isArray(input) ? (input as any[]).slice(0) : [input];\n}\n\n/**\n * Split array with items into smaller arrays with items\n * @link https://stackoverflow.com/a/7273794/3443137\n */\nexport function batchArray(array: T[], batchSize: number): T[][] {\n array = array.slice(0);\n const ret: T[][] = [];\n while (array.length) {\n const batch = array.splice(0, batchSize);\n ret.push(batch);\n }\n return ret;\n}\n\n/**\n * @link https://stackoverflow.com/a/15996017\n */\nexport function removeOneFromArrayIfMatches(ar: T[], condition: (x: T) => boolean): T[] {\n ar = ar.slice();\n let i = ar.length;\n let done = false;\n while (i-- && !done) {\n if (condition(ar[i])) {\n done = true;\n ar.splice(i, 1);\n }\n }\n return ar;\n}\n\n/**\n * returns true if the supplied argument is either an Array or a Readonly>\n */\nexport function isMaybeReadonlyArray(x: any): x is MaybeReadonly {\n // While this looks strange, it's a workaround for an issue in TypeScript:\n // https://github.com/microsoft/TypeScript/issues/17002\n //\n // The problem is that `Array.isArray` as a type guard returns `false` for a readonly array,\n // but at runtime the object is an array and the runtime call to `Array.isArray` would return `true`.\n // The type predicate here allows for both `Array` and `Readonly>` to pass a type check while\n // still performing runtime type inspection.\n return Array.isArray(x);\n}\n\n\n\nexport function isOneItemOfArrayInOtherArray(ar1: T[], ar2: T[]): boolean {\n for (let i = 0; i < ar1.length; i++) {\n const el = ar1[i];\n const has = ar2.includes(el);\n if (has) {\n return true;\n }\n }\n return false;\n}\n\n\n/**\n * Use this in array.filter() to remove all empty slots\n * and have the correct typings afterwards.\n * @link https://stackoverflow.com/a/46700791/3443137\n */\nexport function arrayFilterNotEmpty(value: TValue | null | undefined): value is TValue {\n if (value === null || value === undefined) {\n return false;\n }\n return true;\n}\n\nexport function countUntilNotMatching(\n ar: T[],\n matchingFn: (v: T, idx: number) => boolean\n): number {\n let count = 0;\n let idx = -1;\n for (const item of ar) {\n idx = idx + 1;\n const matching = matchingFn(item, idx);\n if (matching) {\n count = count + 1;\n } else {\n break;\n }\n }\n return count;\n}\n\nexport async function asyncFilter(array: T[], predicate: (item: T, index: number, a: T[]) => MaybePromise): Promise {\n const filters = await Promise.all(\n array.map(predicate)\n );\n\n return array.filter((...[, index]) => filters[index]);\n}\n\n/**\n * @link https://stackoverflow.com/a/3762735\n */\nexport function sumNumberArray(array: number[]): number {\n let count = 0;\n for (let i = array.length; i--;) {\n count += array[i];\n }\n return count;\n}\n\nexport function maxOfNumbers(arr: number[]): number {\n return Math.max(...arr);\n}\n\n\n/**\n * Appends the given documents to the given array.\n * This will mutate the first given array.\n * Mostly used as faster alternative to Array.concat()\n * because .concat() is so slow.\n * @link https://www.measurethat.net/Benchmarks/Show/4223/0/array-concat-vs-spread-operator-vs-push#latest_results_block\n */\nexport function appendToArray(ar: T[], add: T[] | readonly T[]): void {\n const amount = add.length;\n for (let i = 0; i < amount; ++i) {\n const element = add[i];\n ar.push(element);\n }\n}\n\n/**\n * @link https://gist.github.com/telekosmos/3b62a31a5c43f40849bb\n */\nexport function uniqueArray(arrArg: string[]): string[] {\n return arrArg.filter(function (elem, pos, arr) {\n return arr.indexOf(elem) === pos;\n });\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAKO,SAASA,WAAWA,CAAIC,EAAO,EAAiB;EACnD,OAAOA,EAAE,CAACA,EAAE,CAACC,MAAM,GAAG,CAAC,CAAC;AAC5B;;AAEA;AACA;AACA;AACO,SAASC,YAAYA,CAAIC,GAAQ,EAAO;EAC3C,OAAOA,GAAG,CAACC,KAAK,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,MAAOC,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,GAAI,CAAC;AACzD;AAEO,SAASC,OAAOA,CAAIC,KAA4C,EAAO;EAC1E,OAAOC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,GAAIA,KAAK,CAAWL,KAAK,CAAC,CAAC,CAAC,GAAG,CAACK,KAAK,CAAC;AACrE;;AAEA;AACA;AACA;AACA;AACO,SAASG,UAAUA,CAAIC,KAAU,EAAEC,SAAiB,EAAS;EAChED,KAAK,GAAGA,KAAK,CAACT,KAAK,CAAC,CAAC,CAAC;EACtB,IAAMW,GAAU,GAAG,EAAE;EACrB,OAAOF,KAAK,CAACZ,MAAM,EAAE;IACjB,IAAMe,KAAK,GAAGH,KAAK,CAACI,MAAM,CAAC,CAAC,EAAEH,SAAS,CAAC;IACxCC,GAAG,CAACG,IAAI,CAACF,KAAK,CAAC;EACnB;EACA,OAAOD,GAAG;AACd;;AAEA;AACA;AACA;AACO,SAASI,2BAA2BA,CAAInB,EAAO,EAAEoB,SAA4B,EAAO;EACvFpB,EAAE,GAAGA,EAAE,CAACI,KAAK,CAAC,CAAC;EACf,IAAIiB,CAAC,GAAGrB,EAAE,CAACC,MAAM;EACjB,IAAIqB,IAAI,GAAG,KAAK;EAChB,OAAOD,CAAC,EAAE,IAAI,CAACC,IAAI,EAAE;IACjB,IAAIF,SAAS,CAACpB,EAAE,CAACqB,CAAC,CAAC,CAAC,EAAE;MAClBC,IAAI,GAAG,IAAI;MACXtB,EAAE,CAACiB,MAAM,CAACI,CAAC,EAAE,CAAC,CAAC;IACnB;EACJ;EACA,OAAOrB,EAAE;AACb;;AAEA;AACA;AACA;AACO,SAASuB,oBAAoBA,CAACC,CAAM,EAA6B;EACpE;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAOd,KAAK,CAACC,OAAO,CAACa,CAAC,CAAC;AAC3B;AAIO,SAASC,4BAA4BA,CAAIC,GAAQ,EAAEC,GAAQ,EAAW;EACzE,KAAK,IAAIN,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGK,GAAG,CAACzB,MAAM,EAAEoB,CAAC,EAAE,EAAE;IACjC,IAAMO,EAAE,GAAGF,GAAG,CAACL,CAAC,CAAC;IACjB,IAAMQ,GAAG,GAAGF,GAAG,CAACG,QAAQ,CAACF,EAAE,CAAC;IAC5B,IAAIC,GAAG,EAAE;MACL,OAAO,IAAI;IACf;EACJ;EACA,OAAO,KAAK;AAChB;;AAGA;AACA;AACA;AACA;AACA;AACO,SAASE,mBAAmBA,CAASC,KAAgC,EAAmB;EAC3F,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKC,SAAS,EAAE;IACvC,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf;AAEO,SAASC,qBAAqBA,CACjClC,EAAO,EACPmC,UAA0C,EACpC;EACN,IAAIC,KAAK,GAAG,CAAC;EACb,IAAIC,GAAG,GAAG,CAAC,CAAC;EACZ,KAAK,IAAMC,KAAI,IAAItC,EAAE,EAAE;IACnBqC,GAAG,GAAGA,GAAG,GAAG,CAAC;IACb,IAAME,QAAQ,GAAGJ,UAAU,CAACG,KAAI,EAAED,GAAG,CAAC;IACtC,IAAIE,QAAQ,EAAE;MACVH,KAAK,GAAGA,KAAK,GAAG,CAAC;IACrB,CAAC,MAAM;MACH;IACJ;EACJ;EACA,OAAOA,KAAK;AAChB;AAEO,eAAeI,WAAWA,CAAI3B,KAAU,EAAE4B,SAAoE,EAAgB;EACjI,IAAMC,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC7B/B,KAAK,CAACgC,GAAG,CAACJ,SAAS,CACvB,CAAC;EAED,OAAO5B,KAAK,CAACiC,MAAM,CAAC,CAAC,GAAG,GAAGC,KAAK,CAAC,KAAKL,OAAO,CAACK,KAAK,CAAC,CAAC;AACzD;;AAEA;AACA;AACA;AACO,SAASC,cAAcA,CAACnC,KAAe,EAAU;EACpD,IAAIuB,KAAK,GAAG,CAAC;EACb,KAAK,IAAIf,CAAC,GAAGR,KAAK,CAACZ,MAAM,EAAEoB,CAAC,EAAE,GAAG;IAC7Be,KAAK,IAAIvB,KAAK,CAACQ,CAAC,CAAC;EACrB;EACA,OAAOe,KAAK;AAChB;AAEO,SAASa,YAAYA,CAAC9C,GAAa,EAAU;EAChD,OAAOG,IAAI,CAAC4C,GAAG,CAAC,GAAG/C,GAAG,CAAC;AAC3B;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASgD,aAAaA,CAAInD,EAAO,EAAEoD,GAAuB,EAAQ;EACrE,IAAMC,MAAM,GAAGD,GAAG,CAACnD,MAAM;EACzB,KAAK,IAAIoB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGgC,MAAM,EAAE,EAAEhC,CAAC,EAAE;IAC7B,IAAMiC,OAAO,GAAGF,GAAG,CAAC/B,CAAC,CAAC;IACtBrB,EAAE,CAACkB,IAAI,CAACoC,OAAO,CAAC;EACpB;AACJ;;AAEA;AACA;AACA;AACO,SAASC,WAAWA,CAACC,MAAgB,EAAY;EACpD,OAAOA,MAAM,CAACV,MAAM,CAAC,UAAUW,IAAI,EAAEC,GAAG,EAAEvD,GAAG,EAAE;IAC3C,OAAOA,GAAG,CAACwD,OAAO,CAACF,IAAI,CAAC,KAAKC,GAAG;EACpC,CAAC,CAAC;AACN"} \ No newline at end of file +{"version":3,"file":"utils-array.js","names":["lastOfArray","ar","length","shuffleArray","arr","slice","sort","Math","random","randomOfArray","randomElement","floor","toArray","input","Array","isArray","batchArray","array","batchSize","ret","batch","splice","push","removeOneFromArrayIfMatches","condition","i","done","isMaybeReadonlyArray","x","isOneItemOfArrayInOtherArray","ar1","ar2","el","has","includes","arrayFilterNotEmpty","value","undefined","countUntilNotMatching","matchingFn","count","idx","item","matching","asyncFilter","predicate","filters","Promise","all","map","filter","index","sumNumberArray","maxOfNumbers","max","appendToArray","add","amount","element","uniqueArray","arrArg","elem","pos","indexOf"],"sources":["../../../../src/plugins/utils/utils-array.ts"],"sourcesContent":["import type {\n MaybePromise,\n MaybeReadonly\n} from '../../types/index.d.ts';\n\nexport function lastOfArray(ar: T[]): T | undefined {\n return ar[ar.length - 1];\n}\n\n/**\n * shuffle the given array\n */\nexport function shuffleArray(arr: T[]): T[] {\n return arr.slice(0).sort(() => (Math.random() - 0.5));\n}\n\nexport function randomOfArray(arr: T[]): T {\n const randomElement = arr[Math.floor(Math.random() * arr.length)];\n return randomElement;\n}\n\n\nexport function toArray(input: T | T[] | Readonly | Readonly): T[] {\n return Array.isArray(input) ? (input as any[]).slice(0) : [input];\n}\n\n/**\n * Split array with items into smaller arrays with items\n * @link https://stackoverflow.com/a/7273794/3443137\n */\nexport function batchArray(array: T[], batchSize: number): T[][] {\n array = array.slice(0);\n const ret: T[][] = [];\n while (array.length) {\n const batch = array.splice(0, batchSize);\n ret.push(batch);\n }\n return ret;\n}\n\n/**\n * @link https://stackoverflow.com/a/15996017\n */\nexport function removeOneFromArrayIfMatches(ar: T[], condition: (x: T) => boolean): T[] {\n ar = ar.slice();\n let i = ar.length;\n let done = false;\n while (i-- && !done) {\n if (condition(ar[i])) {\n done = true;\n ar.splice(i, 1);\n }\n }\n return ar;\n}\n\n/**\n * returns true if the supplied argument is either an Array or a Readonly>\n */\nexport function isMaybeReadonlyArray(x: any): x is MaybeReadonly {\n // While this looks strange, it's a workaround for an issue in TypeScript:\n // https://github.com/microsoft/TypeScript/issues/17002\n //\n // The problem is that `Array.isArray` as a type guard returns `false` for a readonly array,\n // but at runtime the object is an array and the runtime call to `Array.isArray` would return `true`.\n // The type predicate here allows for both `Array` and `Readonly>` to pass a type check while\n // still performing runtime type inspection.\n return Array.isArray(x);\n}\n\n\n\nexport function isOneItemOfArrayInOtherArray(ar1: T[], ar2: T[]): boolean {\n for (let i = 0; i < ar1.length; i++) {\n const el = ar1[i];\n const has = ar2.includes(el);\n if (has) {\n return true;\n }\n }\n return false;\n}\n\n\n/**\n * Use this in array.filter() to remove all empty slots\n * and have the correct typings afterwards.\n * @link https://stackoverflow.com/a/46700791/3443137\n */\nexport function arrayFilterNotEmpty(value: TValue | null | undefined): value is TValue {\n if (value === null || value === undefined) {\n return false;\n }\n return true;\n}\n\nexport function countUntilNotMatching(\n ar: T[],\n matchingFn: (v: T, idx: number) => boolean\n): number {\n let count = 0;\n let idx = -1;\n for (const item of ar) {\n idx = idx + 1;\n const matching = matchingFn(item, idx);\n if (matching) {\n count = count + 1;\n } else {\n break;\n }\n }\n return count;\n}\n\nexport async function asyncFilter(array: T[], predicate: (item: T, index: number, a: T[]) => MaybePromise): Promise {\n const filters = await Promise.all(\n array.map(predicate)\n );\n\n return array.filter((...[, index]) => filters[index]);\n}\n\n/**\n * @link https://stackoverflow.com/a/3762735\n */\nexport function sumNumberArray(array: number[]): number {\n let count = 0;\n for (let i = array.length; i--;) {\n count += array[i];\n }\n return count;\n}\n\nexport function maxOfNumbers(arr: number[]): number {\n return Math.max(...arr);\n}\n\n\n/**\n * Appends the given documents to the given array.\n * This will mutate the first given array.\n * Mostly used as faster alternative to Array.concat()\n * because .concat() is so slow.\n * @link https://www.measurethat.net/Benchmarks/Show/4223/0/array-concat-vs-spread-operator-vs-push#latest_results_block\n */\nexport function appendToArray(ar: T[], add: T[] | readonly T[]): void {\n const amount = add.length;\n for (let i = 0; i < amount; ++i) {\n const element = add[i];\n ar.push(element);\n }\n}\n\n/**\n * @link https://gist.github.com/telekosmos/3b62a31a5c43f40849bb\n */\nexport function uniqueArray(arrArg: string[]): string[] {\n return arrArg.filter(function (elem, pos, arr) {\n return arr.indexOf(elem) === pos;\n });\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAKO,SAASA,WAAWA,CAAIC,EAAO,EAAiB;EACnD,OAAOA,EAAE,CAACA,EAAE,CAACC,MAAM,GAAG,CAAC,CAAC;AAC5B;;AAEA;AACA;AACA;AACO,SAASC,YAAYA,CAAIC,GAAQ,EAAO;EAC3C,OAAOA,GAAG,CAACC,KAAK,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,MAAOC,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,GAAI,CAAC;AACzD;AAEO,SAASC,aAAaA,CAAIL,GAAQ,EAAK;EAC1C,IAAMM,aAAa,GAAGN,GAAG,CAACG,IAAI,CAACI,KAAK,CAACJ,IAAI,CAACC,MAAM,CAAC,CAAC,GAAGJ,GAAG,CAACF,MAAM,CAAC,CAAC;EACjE,OAAOQ,aAAa;AACxB;AAGO,SAASE,OAAOA,CAAIC,KAA4C,EAAO;EAC1E,OAAOC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,GAAIA,KAAK,CAAWR,KAAK,CAAC,CAAC,CAAC,GAAG,CAACQ,KAAK,CAAC;AACrE;;AAEA;AACA;AACA;AACA;AACO,SAASG,UAAUA,CAAIC,KAAU,EAAEC,SAAiB,EAAS;EAChED,KAAK,GAAGA,KAAK,CAACZ,KAAK,CAAC,CAAC,CAAC;EACtB,IAAMc,GAAU,GAAG,EAAE;EACrB,OAAOF,KAAK,CAACf,MAAM,EAAE;IACjB,IAAMkB,KAAK,GAAGH,KAAK,CAACI,MAAM,CAAC,CAAC,EAAEH,SAAS,CAAC;IACxCC,GAAG,CAACG,IAAI,CAACF,KAAK,CAAC;EACnB;EACA,OAAOD,GAAG;AACd;;AAEA;AACA;AACA;AACO,SAASI,2BAA2BA,CAAItB,EAAO,EAAEuB,SAA4B,EAAO;EACvFvB,EAAE,GAAGA,EAAE,CAACI,KAAK,CAAC,CAAC;EACf,IAAIoB,CAAC,GAAGxB,EAAE,CAACC,MAAM;EACjB,IAAIwB,IAAI,GAAG,KAAK;EAChB,OAAOD,CAAC,EAAE,IAAI,CAACC,IAAI,EAAE;IACjB,IAAIF,SAAS,CAACvB,EAAE,CAACwB,CAAC,CAAC,CAAC,EAAE;MAClBC,IAAI,GAAG,IAAI;MACXzB,EAAE,CAACoB,MAAM,CAACI,CAAC,EAAE,CAAC,CAAC;IACnB;EACJ;EACA,OAAOxB,EAAE;AACb;;AAEA;AACA;AACA;AACO,SAAS0B,oBAAoBA,CAACC,CAAM,EAA6B;EACpE;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAOd,KAAK,CAACC,OAAO,CAACa,CAAC,CAAC;AAC3B;AAIO,SAASC,4BAA4BA,CAAIC,GAAQ,EAAEC,GAAQ,EAAW;EACzE,KAAK,IAAIN,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGK,GAAG,CAAC5B,MAAM,EAAEuB,CAAC,EAAE,EAAE;IACjC,IAAMO,EAAE,GAAGF,GAAG,CAACL,CAAC,CAAC;IACjB,IAAMQ,GAAG,GAAGF,GAAG,CAACG,QAAQ,CAACF,EAAE,CAAC;IAC5B,IAAIC,GAAG,EAAE;MACL,OAAO,IAAI;IACf;EACJ;EACA,OAAO,KAAK;AAChB;;AAGA;AACA;AACA;AACA;AACA;AACO,SAASE,mBAAmBA,CAASC,KAAgC,EAAmB;EAC3F,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKC,SAAS,EAAE;IACvC,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf;AAEO,SAASC,qBAAqBA,CACjCrC,EAAO,EACPsC,UAA0C,EACpC;EACN,IAAIC,KAAK,GAAG,CAAC;EACb,IAAIC,GAAG,GAAG,CAAC,CAAC;EACZ,KAAK,IAAMC,KAAI,IAAIzC,EAAE,EAAE;IACnBwC,GAAG,GAAGA,GAAG,GAAG,CAAC;IACb,IAAME,QAAQ,GAAGJ,UAAU,CAACG,KAAI,EAAED,GAAG,CAAC;IACtC,IAAIE,QAAQ,EAAE;MACVH,KAAK,GAAGA,KAAK,GAAG,CAAC;IACrB,CAAC,MAAM;MACH;IACJ;EACJ;EACA,OAAOA,KAAK;AAChB;AAEO,eAAeI,WAAWA,CAAI3B,KAAU,EAAE4B,SAAoE,EAAgB;EACjI,IAAMC,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC7B/B,KAAK,CAACgC,GAAG,CAACJ,SAAS,CACvB,CAAC;EAED,OAAO5B,KAAK,CAACiC,MAAM,CAAC,CAAC,GAAG,GAAGC,KAAK,CAAC,KAAKL,OAAO,CAACK,KAAK,CAAC,CAAC;AACzD;;AAEA;AACA;AACA;AACO,SAASC,cAAcA,CAACnC,KAAe,EAAU;EACpD,IAAIuB,KAAK,GAAG,CAAC;EACb,KAAK,IAAIf,CAAC,GAAGR,KAAK,CAACf,MAAM,EAAEuB,CAAC,EAAE,GAAG;IAC7Be,KAAK,IAAIvB,KAAK,CAACQ,CAAC,CAAC;EACrB;EACA,OAAOe,KAAK;AAChB;AAEO,SAASa,YAAYA,CAACjD,GAAa,EAAU;EAChD,OAAOG,IAAI,CAAC+C,GAAG,CAAC,GAAGlD,GAAG,CAAC;AAC3B;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASmD,aAAaA,CAAItD,EAAO,EAAEuD,GAAuB,EAAQ;EACrE,IAAMC,MAAM,GAAGD,GAAG,CAACtD,MAAM;EACzB,KAAK,IAAIuB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGgC,MAAM,EAAE,EAAEhC,CAAC,EAAE;IAC7B,IAAMiC,OAAO,GAAGF,GAAG,CAAC/B,CAAC,CAAC;IACtBxB,EAAE,CAACqB,IAAI,CAACoC,OAAO,CAAC;EACpB;AACJ;;AAEA;AACA;AACA;AACO,SAASC,WAAWA,CAACC,MAAgB,EAAY;EACpD,OAAOA,MAAM,CAACV,MAAM,CAAC,UAAUW,IAAI,EAAEC,GAAG,EAAE1D,GAAG,EAAE;IAC3C,OAAOA,GAAG,CAAC2D,OAAO,CAACF,IAAI,CAAC,KAAKC,GAAG;EACpC,CAAC,CAAC;AACN"} \ No newline at end of file diff --git a/dist/cjs/plugins/utils/utils-rxdb-version.js b/dist/cjs/plugins/utils/utils-rxdb-version.js index 0383209889b..2de57fb6e47 100644 --- a/dist/cjs/plugins/utils/utils-rxdb-version.js +++ b/dist/cjs/plugins/utils/utils-rxdb-version.js @@ -7,5 +7,5 @@ exports.RXDB_VERSION = void 0; /** * This file is replaced in the 'npm run build:version' script. */ -var RXDB_VERSION = exports.RXDB_VERSION = '15.9.1'; +var RXDB_VERSION = exports.RXDB_VERSION = '15.10.0'; //# sourceMappingURL=utils-rxdb-version.js.map \ No newline at end of file diff --git a/dist/cjs/plugins/utils/utils-rxdb-version.js.map b/dist/cjs/plugins/utils/utils-rxdb-version.js.map index e1ac4d430a7..aa28bead46f 100644 --- a/dist/cjs/plugins/utils/utils-rxdb-version.js.map +++ b/dist/cjs/plugins/utils/utils-rxdb-version.js.map @@ -1 +1 @@ -{"version":3,"file":"utils-rxdb-version.js","names":["RXDB_VERSION","exports"],"sources":["../../../../src/plugins/utils/utils-rxdb-version.ts"],"sourcesContent":["/**\n * This file is replaced in the 'npm run build:version' script.\n */\nexport const RXDB_VERSION = '15.9.1';\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACO,IAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,QAAQ"} \ No newline at end of file +{"version":3,"file":"utils-rxdb-version.js","names":["RXDB_VERSION","exports"],"sources":["../../../../src/plugins/utils/utils-rxdb-version.ts"],"sourcesContent":["/**\n * This file is replaced in the 'npm run build:version' script.\n */\nexport const RXDB_VERSION = '15.10.0';\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACO,IAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,SAAS"} \ No newline at end of file diff --git a/dist/esm/plugins/storage-remote/remote.js b/dist/esm/plugins/storage-remote/remote.js index bd96ff00d97..a0d921119f9 100644 --- a/dist/esm/plugins/storage-remote/remote.js +++ b/dist/esm/plugins/storage-remote/remote.js @@ -81,6 +81,14 @@ export function exposeRxStorageRemote(settings) { params }; instanceByFullName.set(fullName, state); + + /** + * Must await the creation here + * so that in case of an error, + * it knows about the error message and can send + * that back to the main process. + */ + await state.storageInstancePromise; } catch (err) { settings.send(createErrorAnswer(msg, err)); return; diff --git a/dist/esm/plugins/storage-remote/remote.js.map b/dist/esm/plugins/storage-remote/remote.js.map index 22ebab9ad5a..31b0fd314bf 100644 --- a/dist/esm/plugins/storage-remote/remote.js.map +++ b/dist/esm/plugins/storage-remote/remote.js.map @@ -1 +1 @@ -{"version":3,"file":"remote.js","names":["filter","deepEqual","ensureNotFalsy","createAnswer","createErrorAnswer","getChangedDocumentsSince","exposeRxStorageRemote","settings","instanceByFullName","Map","messages$","pipe","msg","method","subscribe","customRequestHandler","send","Error","result","params","err","getRxStorageInstance","storage","createStorageInstance","database","storageInstances","Array","from","collectionName","storageInstance","find","instance","console","dir","JSON","stringify","schema","existingSchema","Promise","resolve","connectionId","isArray","fullName","databaseName","version","join","state","get","storageInstancePromise","connectionIds","Set","set","add","subs","push","changeStream","changes","message","answerTo","return","conflictResultionTasks","conflicts","connectionClosed","closeThisConnection","forEach","sub","unsubscribe","delete","collection","collections","onDestroy","subMsg","plainMessage","size"],"sources":["../../../../src/plugins/storage-remote/remote.ts"],"sourcesContent":["import { filter, Subscription } from 'rxjs';\nimport type {\n RxStorageInstance,\n RxStorageInstanceCreationParams\n} from '../../types/index.d.ts';\nimport {\n deepEqual,\n ensureNotFalsy\n} from '../../plugins/utils/index.ts';\nimport { createAnswer, createErrorAnswer } from './storage-remote-helpers.ts';\nimport type {\n MessageFromRemote,\n MessageToRemote,\n RxStorageRemoteExposeSettings,\n RxStorageRemoteExposeSettingsRxDatabase,\n RxStorageRemoteExposeSettingsRxStorage,\n RxStorageRemoteExposeType\n} from './storage-remote-types.ts';\nimport { getChangedDocumentsSince } from '../../rx-storage-helper.ts';\n\n/**\n * Run this on the 'remote' part,\n * so that RxStorageMessageChannel can connect to it.\n */\nexport function exposeRxStorageRemote(settings: RxStorageRemoteExposeSettings): RxStorageRemoteExposeType {\n type InstanceState = {\n storageInstancePromise: Promise>;\n connectionIds: Set;\n params: RxStorageInstanceCreationParams;\n };\n const instanceByFullName: Map = new Map();\n\n\n settings.messages$.pipe(\n filter(msg => msg.method === 'custom')\n ).subscribe(async (msg) => {\n if (!settings.customRequestHandler) {\n settings.send(createErrorAnswer(\n msg,\n new Error('Remote storage: cannot resolve custom request because settings.customRequestHandler is not set')\n ));\n } else {\n try {\n const result = await settings.customRequestHandler(msg.params);\n settings.send(createAnswer(msg, result));\n } catch (err: any) {\n settings.send(createErrorAnswer(\n msg,\n err\n ));\n }\n }\n });\n\n\n function getRxStorageInstance(params: any): Promise> {\n if ((settings as RxStorageRemoteExposeSettingsRxStorage).storage) {\n return (settings as RxStorageRemoteExposeSettingsRxStorage).storage.createStorageInstance(params);\n } else if ((settings as RxStorageRemoteExposeSettingsRxDatabase).database) {\n const storageInstances = Array.from((settings as RxStorageRemoteExposeSettingsRxDatabase).database.storageInstances);\n const collectionName = params.collectionName;\n const storageInstance = storageInstances.find(instance => instance.collectionName === collectionName);\n if (!storageInstance) {\n console.dir(storageInstances);\n throw new Error('storageInstance does not exist ' + JSON.stringify({\n collectionName\n }));\n }\n const schema = params.schema;\n if (!deepEqual(schema, storageInstance.schema)) {\n throw new Error('Wrong schema ' + JSON.stringify({\n schema,\n existingSchema: storageInstance.schema\n }));\n }\n return Promise.resolve(storageInstance);\n } else {\n throw new Error('no base given');\n }\n }\n\n settings.messages$.pipe(\n filter(msg => msg.method === 'create')\n ).subscribe(async (msg) => {\n const connectionId = msg.connectionId;\n\n /**\n * Do an isArray check here\n * for runtime check types to ensure we have\n * instance creation params and not method input params.\n */\n if (Array.isArray(msg.params)) {\n return;\n }\n const params = msg.params;\n const collectionName = params.collectionName;\n\n /**\n * We de-duplicate the storage instances.\n * This makes sense in many environments like\n * electron where on main process contains the storage\n * for multiple renderer processes. Same goes for SharedWorkers etc.\n */\n const fullName = [\n params.databaseName,\n params.collectionName,\n params.schema.version\n ].join('|');\n let state = instanceByFullName.get(fullName);\n if (!state) {\n try {\n state = {\n /**\n * We work with a promise here to ensure\n * that parallel create-calls will still end up\n * with exactly one instance and not more.\n */\n storageInstancePromise: getRxStorageInstance(params),\n connectionIds: new Set(),\n params\n };\n instanceByFullName.set(fullName, state);\n } catch (err: any) {\n settings.send(createErrorAnswer(msg, err));\n return;\n }\n } else {\n // if instance already existed, ensure that the schema is equal\n if (!deepEqual(params.schema, state.params.schema)) {\n settings.send(createErrorAnswer(msg, new Error('Remote storage: schema not equal to existing storage')));\n return;\n }\n }\n state.connectionIds.add(msg.connectionId);\n const subs: Subscription[] = [];\n\n const storageInstance = await state.storageInstancePromise;\n /**\n * Automatically subscribe to the changeStream()\n * because we always need them.\n */\n subs.push(\n storageInstance.changeStream().subscribe(changes => {\n const message: MessageFromRemote = {\n connectionId,\n answerTo: 'changestream',\n method: 'changeStream',\n return: changes\n };\n settings.send(message);\n })\n );\n subs.push(\n storageInstance.conflictResultionTasks().subscribe(conflicts => {\n const message: MessageFromRemote = {\n connectionId,\n answerTo: 'conflictResultionTasks',\n method: 'conflictResultionTasks',\n return: conflicts\n };\n settings.send(message);\n })\n );\n\n\n let connectionClosed = false;\n function closeThisConnection() {\n if (connectionClosed) {\n return;\n }\n connectionClosed = true;\n subs.forEach(sub => sub.unsubscribe());\n ensureNotFalsy(state).connectionIds.delete(connectionId);\n instanceByFullName.delete(fullName);\n /**\n * TODO how to notify the other ports on remove() ?\n */\n }\n\n // also close the connection when the collection gets destroyed\n if ((settings as RxStorageRemoteExposeSettingsRxDatabase).database) {\n const database = (settings as RxStorageRemoteExposeSettingsRxDatabase).database;\n const collection = database.collections[collectionName];\n if (collection) {\n collection.onDestroy.push(() => closeThisConnection());\n } else {\n database.onDestroy.push(() => closeThisConnection());\n }\n }\n\n subs.push(\n settings.messages$.pipe(\n filter(subMsg => (subMsg as MessageToRemote).connectionId === connectionId)\n ).subscribe(async (plainMessage) => {\n const message: MessageToRemote = plainMessage as any;\n if (\n message.method === 'create' ||\n message.method === 'custom'\n ) {\n return;\n }\n if (!Array.isArray(message.params)) {\n return;\n }\n let result;\n try {\n if (\n message.method === 'close' &&\n (settings as RxStorageRemoteExposeSettingsRxDatabase).database\n ) {\n /**\n * Do not close the storageInstance if it was taken from\n * a running RxDatabase.\n * In that case we only close the instance\n * when the RxDatabase gets destroyed.\n */\n settings.send(createAnswer(message, null));\n return;\n }\n /**\n * On calls to 'close()',\n * we only close the main instance if there are no other\n * ports connected.\n */\n if (\n message.method === 'close' &&\n ensureNotFalsy(state).connectionIds.size > 1\n ) {\n settings.send(createAnswer(message, null));\n ensureNotFalsy(state).connectionIds.delete(connectionId);\n subs.forEach(sub => sub.unsubscribe());\n return;\n }\n\n if (message.method === 'getChangedDocumentsSince' && !storageInstance.getChangedDocumentsSince) {\n result = await getChangedDocumentsSince(\n storageInstance,\n message.params[0],\n message.params[1]\n );\n } else {\n result = await (storageInstance as any)[message.method](\n message.params[0],\n message.params[1],\n message.params[2],\n message.params[3]\n );\n }\n if (\n message.method === 'close' ||\n message.method === 'remove'\n ) {\n closeThisConnection();\n }\n settings.send(createAnswer(message, result));\n } catch (err: any) {\n settings.send(createErrorAnswer(message, err));\n }\n })\n );\n\n settings.send(createAnswer(msg, 'ok'));\n });\n\n return {\n instanceByFullName\n };\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAsB,MAAM;AAK3C,SACIC,SAAS,EACTC,cAAc,QACX,8BAA8B;AACrC,SAASC,YAAY,EAAEC,iBAAiB,QAAQ,6BAA6B;AAS7E,SAASC,wBAAwB,QAAQ,4BAA4B;;AAErE;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAACC,QAAuC,EAA6B;EAMtG,IAAMC,kBAA8C,GAAG,IAAIC,GAAG,CAAC,CAAC;EAGhEF,QAAQ,CAACG,SAAS,CAACC,IAAI,CACnBX,MAAM,CAACY,GAAG,IAAIA,GAAG,CAACC,MAAM,KAAK,QAAQ,CACzC,CAAC,CAACC,SAAS,CAAC,MAAOF,GAAG,IAAK;IACvB,IAAI,CAACL,QAAQ,CAACQ,oBAAoB,EAAE;MAChCR,QAAQ,CAACS,IAAI,CAACZ,iBAAiB,CAC3BQ,GAAG,EACH,IAAIK,KAAK,CAAC,gGAAgG,CAC9G,CAAC,CAAC;IACN,CAAC,MAAM;MACH,IAAI;QACA,IAAMC,MAAM,GAAG,MAAMX,QAAQ,CAACQ,oBAAoB,CAACH,GAAG,CAACO,MAAM,CAAC;QAC9DZ,QAAQ,CAACS,IAAI,CAACb,YAAY,CAACS,GAAG,EAAEM,MAAM,CAAC,CAAC;MAC5C,CAAC,CAAC,OAAOE,GAAQ,EAAE;QACfb,QAAQ,CAACS,IAAI,CAACZ,iBAAiB,CAC3BQ,GAAG,EACHQ,GACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;EAGF,SAASC,oBAAoBA,CAAYF,MAAW,EAAwD;IACxG,IAAKZ,QAAQ,CAA4Ce,OAAO,EAAE;MAC9D,OAAQf,QAAQ,CAA4Ce,OAAO,CAACC,qBAAqB,CAACJ,MAAM,CAAC;IACrG,CAAC,MAAM,IAAKZ,QAAQ,CAA6CiB,QAAQ,EAAE;MACvE,IAAMC,gBAAgB,GAAGC,KAAK,CAACC,IAAI,CAAEpB,QAAQ,CAA6CiB,QAAQ,CAACC,gBAAgB,CAAC;MACpH,IAAMG,cAAc,GAAGT,MAAM,CAACS,cAAc;MAC5C,IAAMC,eAAe,GAAGJ,gBAAgB,CAACK,IAAI,CAACC,QAAQ,IAAIA,QAAQ,CAACH,cAAc,KAAKA,cAAc,CAAC;MACrG,IAAI,CAACC,eAAe,EAAE;QAClBG,OAAO,CAACC,GAAG,CAACR,gBAAgB,CAAC;QAC7B,MAAM,IAAIR,KAAK,CAAC,iCAAiC,GAAGiB,IAAI,CAACC,SAAS,CAAC;UAC/DP;QACJ,CAAC,CAAC,CAAC;MACP;MACA,IAAMQ,MAAM,GAAGjB,MAAM,CAACiB,MAAM;MAC5B,IAAI,CAACnC,SAAS,CAACmC,MAAM,EAAEP,eAAe,CAACO,MAAM,CAAC,EAAE;QAC5C,MAAM,IAAInB,KAAK,CAAC,eAAe,GAAGiB,IAAI,CAACC,SAAS,CAAC;UAC7CC,MAAM;UACNC,cAAc,EAAER,eAAe,CAACO;QACpC,CAAC,CAAC,CAAC;MACP;MACA,OAAOE,OAAO,CAACC,OAAO,CAACV,eAAe,CAAC;IAC3C,CAAC,MAAM;MACH,MAAM,IAAIZ,KAAK,CAAC,eAAe,CAAC;IACpC;EACJ;EAEAV,QAAQ,CAACG,SAAS,CAACC,IAAI,CACnBX,MAAM,CAACY,GAAG,IAAIA,GAAG,CAACC,MAAM,KAAK,QAAQ,CACzC,CAAC,CAACC,SAAS,CAAC,MAAOF,GAAG,IAAK;IACvB,IAAM4B,YAAY,GAAG5B,GAAG,CAAC4B,YAAY;;IAErC;AACR;AACA;AACA;AACA;IACQ,IAAId,KAAK,CAACe,OAAO,CAAC7B,GAAG,CAACO,MAAM,CAAC,EAAE;MAC3B;IACJ;IACA,IAAMA,MAAM,GAAGP,GAAG,CAACO,MAAM;IACzB,IAAMS,cAAc,GAAGT,MAAM,CAACS,cAAc;;IAE5C;AACR;AACA;AACA;AACA;AACA;IACQ,IAAMc,QAAQ,GAAG,CACbvB,MAAM,CAACwB,YAAY,EACnBxB,MAAM,CAACS,cAAc,EACrBT,MAAM,CAACiB,MAAM,CAACQ,OAAO,CACxB,CAACC,IAAI,CAAC,GAAG,CAAC;IACX,IAAIC,KAAK,GAAGtC,kBAAkB,CAACuC,GAAG,CAACL,QAAQ,CAAC;IAC5C,IAAI,CAACI,KAAK,EAAE;MACR,IAAI;QACAA,KAAK,GAAG;UACJ;AACpB;AACA;AACA;AACA;UACoBE,sBAAsB,EAAE3B,oBAAoB,CAACF,MAAM,CAAC;UACpD8B,aAAa,EAAE,IAAIC,GAAG,CAAC,CAAC;UACxB/B;QACJ,CAAC;QACDX,kBAAkB,CAAC2C,GAAG,CAACT,QAAQ,EAAEI,KAAK,CAAC;MAC3C,CAAC,CAAC,OAAO1B,GAAQ,EAAE;QACfb,QAAQ,CAACS,IAAI,CAACZ,iBAAiB,CAACQ,GAAG,EAAEQ,GAAG,CAAC,CAAC;QAC1C;MACJ;IACJ,CAAC,MAAM;MACH;MACA,IAAI,CAACnB,SAAS,CAACkB,MAAM,CAACiB,MAAM,EAAEU,KAAK,CAAC3B,MAAM,CAACiB,MAAM,CAAC,EAAE;QAChD7B,QAAQ,CAACS,IAAI,CAACZ,iBAAiB,CAACQ,GAAG,EAAE,IAAIK,KAAK,CAAC,sDAAsD,CAAC,CAAC,CAAC;QACxG;MACJ;IACJ;IACA6B,KAAK,CAACG,aAAa,CAACG,GAAG,CAACxC,GAAG,CAAC4B,YAAY,CAAC;IACzC,IAAMa,IAAoB,GAAG,EAAE;IAE/B,IAAMxB,eAAe,GAAG,MAAMiB,KAAK,CAACE,sBAAsB;IAC1D;AACR;AACA;AACA;IACQK,IAAI,CAACC,IAAI,CACLzB,eAAe,CAAC0B,YAAY,CAAC,CAAC,CAACzC,SAAS,CAAC0C,OAAO,IAAI;MAChD,IAAMC,OAA0B,GAAG;QAC/BjB,YAAY;QACZkB,QAAQ,EAAE,cAAc;QACxB7C,MAAM,EAAE,cAAc;QACtB8C,MAAM,EAAEH;MACZ,CAAC;MACDjD,QAAQ,CAACS,IAAI,CAACyC,OAAO,CAAC;IAC1B,CAAC,CACL,CAAC;IACDJ,IAAI,CAACC,IAAI,CACLzB,eAAe,CAAC+B,sBAAsB,CAAC,CAAC,CAAC9C,SAAS,CAAC+C,SAAS,IAAI;MAC5D,IAAMJ,OAA0B,GAAG;QAC/BjB,YAAY;QACZkB,QAAQ,EAAE,wBAAwB;QAClC7C,MAAM,EAAE,wBAAwB;QAChC8C,MAAM,EAAEE;MACZ,CAAC;MACDtD,QAAQ,CAACS,IAAI,CAACyC,OAAO,CAAC;IAC1B,CAAC,CACL,CAAC;IAGD,IAAIK,gBAAgB,GAAG,KAAK;IAC5B,SAASC,mBAAmBA,CAAA,EAAG;MAC3B,IAAID,gBAAgB,EAAE;QAClB;MACJ;MACAA,gBAAgB,GAAG,IAAI;MACvBT,IAAI,CAACW,OAAO,CAACC,GAAG,IAAIA,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC;MACtChE,cAAc,CAAC4C,KAAK,CAAC,CAACG,aAAa,CAACkB,MAAM,CAAC3B,YAAY,CAAC;MACxDhC,kBAAkB,CAAC2D,MAAM,CAACzB,QAAQ,CAAC;MACnC;AACZ;AACA;IACQ;;IAEA;IACA,IAAKnC,QAAQ,CAA6CiB,QAAQ,EAAE;MAChE,IAAMA,QAAQ,GAAIjB,QAAQ,CAA6CiB,QAAQ;MAC/E,IAAM4C,UAAU,GAAG5C,QAAQ,CAAC6C,WAAW,CAACzC,cAAc,CAAC;MACvD,IAAIwC,UAAU,EAAE;QACZA,UAAU,CAACE,SAAS,CAAChB,IAAI,CAAC,MAAMS,mBAAmB,CAAC,CAAC,CAAC;MAC1D,CAAC,MAAM;QACHvC,QAAQ,CAAC8C,SAAS,CAAChB,IAAI,CAAC,MAAMS,mBAAmB,CAAC,CAAC,CAAC;MACxD;IACJ;IAEAV,IAAI,CAACC,IAAI,CACL/C,QAAQ,CAACG,SAAS,CAACC,IAAI,CACnBX,MAAM,CAACuE,MAAM,IAAKA,MAAM,CAAqB/B,YAAY,KAAKA,YAAY,CAC9E,CAAC,CAAC1B,SAAS,CAAC,MAAO0D,YAAY,IAAK;MAChC,IAAMf,OAAwB,GAAGe,YAAmB;MACpD,IACIf,OAAO,CAAC5C,MAAM,KAAK,QAAQ,IAC3B4C,OAAO,CAAC5C,MAAM,KAAK,QAAQ,EAC7B;QACE;MACJ;MACA,IAAI,CAACa,KAAK,CAACe,OAAO,CAACgB,OAAO,CAACtC,MAAM,CAAC,EAAE;QAChC;MACJ;MACA,IAAID,MAAM;MACV,IAAI;QACA,IACIuC,OAAO,CAAC5C,MAAM,KAAK,OAAO,IACzBN,QAAQ,CAA6CiB,QAAQ,EAChE;UACE;AACxB;AACA;AACA;AACA;AACA;UACwBjB,QAAQ,CAACS,IAAI,CAACb,YAAY,CAACsD,OAAO,EAAE,IAAI,CAAC,CAAC;UAC1C;QACJ;QACA;AACpB;AACA;AACA;AACA;QACoB,IACIA,OAAO,CAAC5C,MAAM,KAAK,OAAO,IAC1BX,cAAc,CAAC4C,KAAK,CAAC,CAACG,aAAa,CAACwB,IAAI,GAAG,CAAC,EAC9C;UACElE,QAAQ,CAACS,IAAI,CAACb,YAAY,CAACsD,OAAO,EAAE,IAAI,CAAC,CAAC;UAC1CvD,cAAc,CAAC4C,KAAK,CAAC,CAACG,aAAa,CAACkB,MAAM,CAAC3B,YAAY,CAAC;UACxDa,IAAI,CAACW,OAAO,CAACC,GAAG,IAAIA,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC;UACtC;QACJ;QAEA,IAAIT,OAAO,CAAC5C,MAAM,KAAK,0BAA0B,IAAI,CAACgB,eAAe,CAACxB,wBAAwB,EAAE;UAC5Fa,MAAM,GAAG,MAAMb,wBAAwB,CACnCwB,eAAe,EACf4B,OAAO,CAACtC,MAAM,CAAC,CAAC,CAAC,EACjBsC,OAAO,CAACtC,MAAM,CAAC,CAAC,CACpB,CAAC;QACL,CAAC,MAAM;UACHD,MAAM,GAAG,MAAOW,eAAe,CAAS4B,OAAO,CAAC5C,MAAM,CAAC,CACnD4C,OAAO,CAACtC,MAAM,CAAC,CAAC,CAAC,EACjBsC,OAAO,CAACtC,MAAM,CAAC,CAAC,CAAC,EACjBsC,OAAO,CAACtC,MAAM,CAAC,CAAC,CAAC,EACjBsC,OAAO,CAACtC,MAAM,CAAC,CAAC,CACpB,CAAC;QACL;QACA,IACIsC,OAAO,CAAC5C,MAAM,KAAK,OAAO,IAC1B4C,OAAO,CAAC5C,MAAM,KAAK,QAAQ,EAC7B;UACEkD,mBAAmB,CAAC,CAAC;QACzB;QACAxD,QAAQ,CAACS,IAAI,CAACb,YAAY,CAACsD,OAAO,EAAEvC,MAAM,CAAC,CAAC;MAChD,CAAC,CAAC,OAAOE,GAAQ,EAAE;QACfb,QAAQ,CAACS,IAAI,CAACZ,iBAAiB,CAACqD,OAAO,EAAErC,GAAG,CAAC,CAAC;MAClD;IACJ,CAAC,CACL,CAAC;IAEDb,QAAQ,CAACS,IAAI,CAACb,YAAY,CAACS,GAAG,EAAE,IAAI,CAAC,CAAC;EAC1C,CAAC,CAAC;EAEF,OAAO;IACHJ;EACJ,CAAC;AACL"} \ No newline at end of file +{"version":3,"file":"remote.js","names":["filter","deepEqual","ensureNotFalsy","createAnswer","createErrorAnswer","getChangedDocumentsSince","exposeRxStorageRemote","settings","instanceByFullName","Map","messages$","pipe","msg","method","subscribe","customRequestHandler","send","Error","result","params","err","getRxStorageInstance","storage","createStorageInstance","database","storageInstances","Array","from","collectionName","storageInstance","find","instance","console","dir","JSON","stringify","schema","existingSchema","Promise","resolve","connectionId","isArray","fullName","databaseName","version","join","state","get","storageInstancePromise","connectionIds","Set","set","add","subs","push","changeStream","changes","message","answerTo","return","conflictResultionTasks","conflicts","connectionClosed","closeThisConnection","forEach","sub","unsubscribe","delete","collection","collections","onDestroy","subMsg","plainMessage","size"],"sources":["../../../../src/plugins/storage-remote/remote.ts"],"sourcesContent":["import { filter, Subscription } from 'rxjs';\nimport type {\n RxStorageInstance,\n RxStorageInstanceCreationParams\n} from '../../types/index.d.ts';\nimport {\n deepEqual,\n ensureNotFalsy\n} from '../../plugins/utils/index.ts';\nimport { createAnswer, createErrorAnswer } from './storage-remote-helpers.ts';\nimport type {\n MessageFromRemote,\n MessageToRemote,\n RxStorageRemoteExposeSettings,\n RxStorageRemoteExposeSettingsRxDatabase,\n RxStorageRemoteExposeSettingsRxStorage,\n RxStorageRemoteExposeType\n} from './storage-remote-types.ts';\nimport { getChangedDocumentsSince } from '../../rx-storage-helper.ts';\n\n/**\n * Run this on the 'remote' part,\n * so that RxStorageMessageChannel can connect to it.\n */\nexport function exposeRxStorageRemote(settings: RxStorageRemoteExposeSettings): RxStorageRemoteExposeType {\n type InstanceState = {\n storageInstancePromise: Promise>;\n connectionIds: Set;\n params: RxStorageInstanceCreationParams;\n };\n const instanceByFullName: Map = new Map();\n\n\n settings.messages$.pipe(\n filter(msg => msg.method === 'custom')\n ).subscribe(async (msg) => {\n if (!settings.customRequestHandler) {\n settings.send(createErrorAnswer(\n msg,\n new Error('Remote storage: cannot resolve custom request because settings.customRequestHandler is not set')\n ));\n } else {\n try {\n const result = await settings.customRequestHandler(msg.params);\n settings.send(createAnswer(msg, result));\n } catch (err: any) {\n settings.send(createErrorAnswer(\n msg,\n err\n ));\n }\n }\n });\n\n\n function getRxStorageInstance(params: any): Promise> {\n if ((settings as RxStorageRemoteExposeSettingsRxStorage).storage) {\n return (settings as RxStorageRemoteExposeSettingsRxStorage).storage.createStorageInstance(params);\n } else if ((settings as RxStorageRemoteExposeSettingsRxDatabase).database) {\n const storageInstances = Array.from((settings as RxStorageRemoteExposeSettingsRxDatabase).database.storageInstances);\n const collectionName = params.collectionName;\n const storageInstance = storageInstances.find(instance => instance.collectionName === collectionName);\n if (!storageInstance) {\n console.dir(storageInstances);\n throw new Error('storageInstance does not exist ' + JSON.stringify({\n collectionName\n }));\n }\n const schema = params.schema;\n if (!deepEqual(schema, storageInstance.schema)) {\n throw new Error('Wrong schema ' + JSON.stringify({\n schema,\n existingSchema: storageInstance.schema\n }));\n }\n return Promise.resolve(storageInstance);\n } else {\n throw new Error('no base given');\n }\n }\n\n settings.messages$.pipe(\n filter(msg => msg.method === 'create')\n ).subscribe(async (msg) => {\n const connectionId = msg.connectionId;\n\n /**\n * Do an isArray check here\n * for runtime check types to ensure we have\n * instance creation params and not method input params.\n */\n if (Array.isArray(msg.params)) {\n return;\n }\n const params = msg.params;\n const collectionName = params.collectionName;\n\n /**\n * We de-duplicate the storage instances.\n * This makes sense in many environments like\n * electron where on main process contains the storage\n * for multiple renderer processes. Same goes for SharedWorkers etc.\n */\n const fullName = [\n params.databaseName,\n params.collectionName,\n params.schema.version\n ].join('|');\n let state = instanceByFullName.get(fullName);\n if (!state) {\n try {\n state = {\n /**\n * We work with a promise here to ensure\n * that parallel create-calls will still end up\n * with exactly one instance and not more.\n */\n storageInstancePromise: getRxStorageInstance(params),\n connectionIds: new Set(),\n params\n };\n instanceByFullName.set(fullName, state);\n\n /**\n * Must await the creation here\n * so that in case of an error,\n * it knows about the error message and can send\n * that back to the main process. \n */\n await state.storageInstancePromise;\n } catch (err: any) {\n settings.send(createErrorAnswer(msg, err));\n return;\n }\n } else {\n // if instance already existed, ensure that the schema is equal\n if (!deepEqual(params.schema, state.params.schema)) {\n settings.send(createErrorAnswer(msg, new Error('Remote storage: schema not equal to existing storage')));\n return;\n }\n }\n state.connectionIds.add(msg.connectionId);\n const subs: Subscription[] = [];\n\n const storageInstance = await state.storageInstancePromise;\n /**\n * Automatically subscribe to the changeStream()\n * because we always need them.\n */\n subs.push(\n storageInstance.changeStream().subscribe(changes => {\n const message: MessageFromRemote = {\n connectionId,\n answerTo: 'changestream',\n method: 'changeStream',\n return: changes\n };\n settings.send(message);\n })\n );\n subs.push(\n storageInstance.conflictResultionTasks().subscribe(conflicts => {\n const message: MessageFromRemote = {\n connectionId,\n answerTo: 'conflictResultionTasks',\n method: 'conflictResultionTasks',\n return: conflicts\n };\n settings.send(message);\n })\n );\n\n\n let connectionClosed = false;\n function closeThisConnection() {\n if (connectionClosed) {\n return;\n }\n connectionClosed = true;\n subs.forEach(sub => sub.unsubscribe());\n ensureNotFalsy(state).connectionIds.delete(connectionId);\n instanceByFullName.delete(fullName);\n /**\n * TODO how to notify the other ports on remove() ?\n */\n }\n\n // also close the connection when the collection gets destroyed\n if ((settings as RxStorageRemoteExposeSettingsRxDatabase).database) {\n const database = (settings as RxStorageRemoteExposeSettingsRxDatabase).database;\n const collection = database.collections[collectionName];\n if (collection) {\n collection.onDestroy.push(() => closeThisConnection());\n } else {\n database.onDestroy.push(() => closeThisConnection());\n }\n }\n\n subs.push(\n settings.messages$.pipe(\n filter(subMsg => (subMsg as MessageToRemote).connectionId === connectionId)\n ).subscribe(async (plainMessage) => {\n const message: MessageToRemote = plainMessage as any;\n if (\n message.method === 'create' ||\n message.method === 'custom'\n ) {\n return;\n }\n if (!Array.isArray(message.params)) {\n return;\n }\n let result;\n try {\n if (\n message.method === 'close' &&\n (settings as RxStorageRemoteExposeSettingsRxDatabase).database\n ) {\n /**\n * Do not close the storageInstance if it was taken from\n * a running RxDatabase.\n * In that case we only close the instance\n * when the RxDatabase gets destroyed.\n */\n settings.send(createAnswer(message, null));\n return;\n }\n /**\n * On calls to 'close()',\n * we only close the main instance if there are no other\n * ports connected.\n */\n if (\n message.method === 'close' &&\n ensureNotFalsy(state).connectionIds.size > 1\n ) {\n settings.send(createAnswer(message, null));\n ensureNotFalsy(state).connectionIds.delete(connectionId);\n subs.forEach(sub => sub.unsubscribe());\n return;\n }\n\n if (message.method === 'getChangedDocumentsSince' && !storageInstance.getChangedDocumentsSince) {\n result = await getChangedDocumentsSince(\n storageInstance,\n message.params[0],\n message.params[1]\n );\n } else {\n result = await (storageInstance as any)[message.method](\n message.params[0],\n message.params[1],\n message.params[2],\n message.params[3]\n );\n }\n if (\n message.method === 'close' ||\n message.method === 'remove'\n ) {\n closeThisConnection();\n }\n settings.send(createAnswer(message, result));\n } catch (err: any) {\n settings.send(createErrorAnswer(message, err));\n }\n })\n );\n\n settings.send(createAnswer(msg, 'ok'));\n });\n\n return {\n instanceByFullName\n };\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAsB,MAAM;AAK3C,SACIC,SAAS,EACTC,cAAc,QACX,8BAA8B;AACrC,SAASC,YAAY,EAAEC,iBAAiB,QAAQ,6BAA6B;AAS7E,SAASC,wBAAwB,QAAQ,4BAA4B;;AAErE;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAACC,QAAuC,EAA6B;EAMtG,IAAMC,kBAA8C,GAAG,IAAIC,GAAG,CAAC,CAAC;EAGhEF,QAAQ,CAACG,SAAS,CAACC,IAAI,CACnBX,MAAM,CAACY,GAAG,IAAIA,GAAG,CAACC,MAAM,KAAK,QAAQ,CACzC,CAAC,CAACC,SAAS,CAAC,MAAOF,GAAG,IAAK;IACvB,IAAI,CAACL,QAAQ,CAACQ,oBAAoB,EAAE;MAChCR,QAAQ,CAACS,IAAI,CAACZ,iBAAiB,CAC3BQ,GAAG,EACH,IAAIK,KAAK,CAAC,gGAAgG,CAC9G,CAAC,CAAC;IACN,CAAC,MAAM;MACH,IAAI;QACA,IAAMC,MAAM,GAAG,MAAMX,QAAQ,CAACQ,oBAAoB,CAACH,GAAG,CAACO,MAAM,CAAC;QAC9DZ,QAAQ,CAACS,IAAI,CAACb,YAAY,CAACS,GAAG,EAAEM,MAAM,CAAC,CAAC;MAC5C,CAAC,CAAC,OAAOE,GAAQ,EAAE;QACfb,QAAQ,CAACS,IAAI,CAACZ,iBAAiB,CAC3BQ,GAAG,EACHQ,GACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;EAGF,SAASC,oBAAoBA,CAAYF,MAAW,EAAwD;IACxG,IAAKZ,QAAQ,CAA4Ce,OAAO,EAAE;MAC9D,OAAQf,QAAQ,CAA4Ce,OAAO,CAACC,qBAAqB,CAACJ,MAAM,CAAC;IACrG,CAAC,MAAM,IAAKZ,QAAQ,CAA6CiB,QAAQ,EAAE;MACvE,IAAMC,gBAAgB,GAAGC,KAAK,CAACC,IAAI,CAAEpB,QAAQ,CAA6CiB,QAAQ,CAACC,gBAAgB,CAAC;MACpH,IAAMG,cAAc,GAAGT,MAAM,CAACS,cAAc;MAC5C,IAAMC,eAAe,GAAGJ,gBAAgB,CAACK,IAAI,CAACC,QAAQ,IAAIA,QAAQ,CAACH,cAAc,KAAKA,cAAc,CAAC;MACrG,IAAI,CAACC,eAAe,EAAE;QAClBG,OAAO,CAACC,GAAG,CAACR,gBAAgB,CAAC;QAC7B,MAAM,IAAIR,KAAK,CAAC,iCAAiC,GAAGiB,IAAI,CAACC,SAAS,CAAC;UAC/DP;QACJ,CAAC,CAAC,CAAC;MACP;MACA,IAAMQ,MAAM,GAAGjB,MAAM,CAACiB,MAAM;MAC5B,IAAI,CAACnC,SAAS,CAACmC,MAAM,EAAEP,eAAe,CAACO,MAAM,CAAC,EAAE;QAC5C,MAAM,IAAInB,KAAK,CAAC,eAAe,GAAGiB,IAAI,CAACC,SAAS,CAAC;UAC7CC,MAAM;UACNC,cAAc,EAAER,eAAe,CAACO;QACpC,CAAC,CAAC,CAAC;MACP;MACA,OAAOE,OAAO,CAACC,OAAO,CAACV,eAAe,CAAC;IAC3C,CAAC,MAAM;MACH,MAAM,IAAIZ,KAAK,CAAC,eAAe,CAAC;IACpC;EACJ;EAEAV,QAAQ,CAACG,SAAS,CAACC,IAAI,CACnBX,MAAM,CAACY,GAAG,IAAIA,GAAG,CAACC,MAAM,KAAK,QAAQ,CACzC,CAAC,CAACC,SAAS,CAAC,MAAOF,GAAG,IAAK;IACvB,IAAM4B,YAAY,GAAG5B,GAAG,CAAC4B,YAAY;;IAErC;AACR;AACA;AACA;AACA;IACQ,IAAId,KAAK,CAACe,OAAO,CAAC7B,GAAG,CAACO,MAAM,CAAC,EAAE;MAC3B;IACJ;IACA,IAAMA,MAAM,GAAGP,GAAG,CAACO,MAAM;IACzB,IAAMS,cAAc,GAAGT,MAAM,CAACS,cAAc;;IAE5C;AACR;AACA;AACA;AACA;AACA;IACQ,IAAMc,QAAQ,GAAG,CACbvB,MAAM,CAACwB,YAAY,EACnBxB,MAAM,CAACS,cAAc,EACrBT,MAAM,CAACiB,MAAM,CAACQ,OAAO,CACxB,CAACC,IAAI,CAAC,GAAG,CAAC;IACX,IAAIC,KAAK,GAAGtC,kBAAkB,CAACuC,GAAG,CAACL,QAAQ,CAAC;IAC5C,IAAI,CAACI,KAAK,EAAE;MACR,IAAI;QACAA,KAAK,GAAG;UACJ;AACpB;AACA;AACA;AACA;UACoBE,sBAAsB,EAAE3B,oBAAoB,CAACF,MAAM,CAAC;UACpD8B,aAAa,EAAE,IAAIC,GAAG,CAAC,CAAC;UACxB/B;QACJ,CAAC;QACDX,kBAAkB,CAAC2C,GAAG,CAACT,QAAQ,EAAEI,KAAK,CAAC;;QAEvC;AAChB;AACA;AACA;AACA;AACA;QACgB,MAAMA,KAAK,CAACE,sBAAsB;MACtC,CAAC,CAAC,OAAO5B,GAAQ,EAAE;QACfb,QAAQ,CAACS,IAAI,CAACZ,iBAAiB,CAACQ,GAAG,EAAEQ,GAAG,CAAC,CAAC;QAC1C;MACJ;IACJ,CAAC,MAAM;MACH;MACA,IAAI,CAACnB,SAAS,CAACkB,MAAM,CAACiB,MAAM,EAAEU,KAAK,CAAC3B,MAAM,CAACiB,MAAM,CAAC,EAAE;QAChD7B,QAAQ,CAACS,IAAI,CAACZ,iBAAiB,CAACQ,GAAG,EAAE,IAAIK,KAAK,CAAC,sDAAsD,CAAC,CAAC,CAAC;QACxG;MACJ;IACJ;IACA6B,KAAK,CAACG,aAAa,CAACG,GAAG,CAACxC,GAAG,CAAC4B,YAAY,CAAC;IACzC,IAAMa,IAAoB,GAAG,EAAE;IAE/B,IAAMxB,eAAe,GAAG,MAAMiB,KAAK,CAACE,sBAAsB;IAC1D;AACR;AACA;AACA;IACQK,IAAI,CAACC,IAAI,CACLzB,eAAe,CAAC0B,YAAY,CAAC,CAAC,CAACzC,SAAS,CAAC0C,OAAO,IAAI;MAChD,IAAMC,OAA0B,GAAG;QAC/BjB,YAAY;QACZkB,QAAQ,EAAE,cAAc;QACxB7C,MAAM,EAAE,cAAc;QACtB8C,MAAM,EAAEH;MACZ,CAAC;MACDjD,QAAQ,CAACS,IAAI,CAACyC,OAAO,CAAC;IAC1B,CAAC,CACL,CAAC;IACDJ,IAAI,CAACC,IAAI,CACLzB,eAAe,CAAC+B,sBAAsB,CAAC,CAAC,CAAC9C,SAAS,CAAC+C,SAAS,IAAI;MAC5D,IAAMJ,OAA0B,GAAG;QAC/BjB,YAAY;QACZkB,QAAQ,EAAE,wBAAwB;QAClC7C,MAAM,EAAE,wBAAwB;QAChC8C,MAAM,EAAEE;MACZ,CAAC;MACDtD,QAAQ,CAACS,IAAI,CAACyC,OAAO,CAAC;IAC1B,CAAC,CACL,CAAC;IAGD,IAAIK,gBAAgB,GAAG,KAAK;IAC5B,SAASC,mBAAmBA,CAAA,EAAG;MAC3B,IAAID,gBAAgB,EAAE;QAClB;MACJ;MACAA,gBAAgB,GAAG,IAAI;MACvBT,IAAI,CAACW,OAAO,CAACC,GAAG,IAAIA,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC;MACtChE,cAAc,CAAC4C,KAAK,CAAC,CAACG,aAAa,CAACkB,MAAM,CAAC3B,YAAY,CAAC;MACxDhC,kBAAkB,CAAC2D,MAAM,CAACzB,QAAQ,CAAC;MACnC;AACZ;AACA;IACQ;;IAEA;IACA,IAAKnC,QAAQ,CAA6CiB,QAAQ,EAAE;MAChE,IAAMA,QAAQ,GAAIjB,QAAQ,CAA6CiB,QAAQ;MAC/E,IAAM4C,UAAU,GAAG5C,QAAQ,CAAC6C,WAAW,CAACzC,cAAc,CAAC;MACvD,IAAIwC,UAAU,EAAE;QACZA,UAAU,CAACE,SAAS,CAAChB,IAAI,CAAC,MAAMS,mBAAmB,CAAC,CAAC,CAAC;MAC1D,CAAC,MAAM;QACHvC,QAAQ,CAAC8C,SAAS,CAAChB,IAAI,CAAC,MAAMS,mBAAmB,CAAC,CAAC,CAAC;MACxD;IACJ;IAEAV,IAAI,CAACC,IAAI,CACL/C,QAAQ,CAACG,SAAS,CAACC,IAAI,CACnBX,MAAM,CAACuE,MAAM,IAAKA,MAAM,CAAqB/B,YAAY,KAAKA,YAAY,CAC9E,CAAC,CAAC1B,SAAS,CAAC,MAAO0D,YAAY,IAAK;MAChC,IAAMf,OAAwB,GAAGe,YAAmB;MACpD,IACIf,OAAO,CAAC5C,MAAM,KAAK,QAAQ,IAC3B4C,OAAO,CAAC5C,MAAM,KAAK,QAAQ,EAC7B;QACE;MACJ;MACA,IAAI,CAACa,KAAK,CAACe,OAAO,CAACgB,OAAO,CAACtC,MAAM,CAAC,EAAE;QAChC;MACJ;MACA,IAAID,MAAM;MACV,IAAI;QACA,IACIuC,OAAO,CAAC5C,MAAM,KAAK,OAAO,IACzBN,QAAQ,CAA6CiB,QAAQ,EAChE;UACE;AACxB;AACA;AACA;AACA;AACA;UACwBjB,QAAQ,CAACS,IAAI,CAACb,YAAY,CAACsD,OAAO,EAAE,IAAI,CAAC,CAAC;UAC1C;QACJ;QACA;AACpB;AACA;AACA;AACA;QACoB,IACIA,OAAO,CAAC5C,MAAM,KAAK,OAAO,IAC1BX,cAAc,CAAC4C,KAAK,CAAC,CAACG,aAAa,CAACwB,IAAI,GAAG,CAAC,EAC9C;UACElE,QAAQ,CAACS,IAAI,CAACb,YAAY,CAACsD,OAAO,EAAE,IAAI,CAAC,CAAC;UAC1CvD,cAAc,CAAC4C,KAAK,CAAC,CAACG,aAAa,CAACkB,MAAM,CAAC3B,YAAY,CAAC;UACxDa,IAAI,CAACW,OAAO,CAACC,GAAG,IAAIA,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC;UACtC;QACJ;QAEA,IAAIT,OAAO,CAAC5C,MAAM,KAAK,0BAA0B,IAAI,CAACgB,eAAe,CAACxB,wBAAwB,EAAE;UAC5Fa,MAAM,GAAG,MAAMb,wBAAwB,CACnCwB,eAAe,EACf4B,OAAO,CAACtC,MAAM,CAAC,CAAC,CAAC,EACjBsC,OAAO,CAACtC,MAAM,CAAC,CAAC,CACpB,CAAC;QACL,CAAC,MAAM;UACHD,MAAM,GAAG,MAAOW,eAAe,CAAS4B,OAAO,CAAC5C,MAAM,CAAC,CACnD4C,OAAO,CAACtC,MAAM,CAAC,CAAC,CAAC,EACjBsC,OAAO,CAACtC,MAAM,CAAC,CAAC,CAAC,EACjBsC,OAAO,CAACtC,MAAM,CAAC,CAAC,CAAC,EACjBsC,OAAO,CAACtC,MAAM,CAAC,CAAC,CACpB,CAAC;QACL;QACA,IACIsC,OAAO,CAAC5C,MAAM,KAAK,OAAO,IAC1B4C,OAAO,CAAC5C,MAAM,KAAK,QAAQ,EAC7B;UACEkD,mBAAmB,CAAC,CAAC;QACzB;QACAxD,QAAQ,CAACS,IAAI,CAACb,YAAY,CAACsD,OAAO,EAAEvC,MAAM,CAAC,CAAC;MAChD,CAAC,CAAC,OAAOE,GAAQ,EAAE;QACfb,QAAQ,CAACS,IAAI,CAACZ,iBAAiB,CAACqD,OAAO,EAAErC,GAAG,CAAC,CAAC;MAClD;IACJ,CAAC,CACL,CAAC;IAEDb,QAAQ,CAACS,IAAI,CAACb,YAAY,CAACS,GAAG,EAAE,IAAI,CAAC,CAAC;EAC1C,CAAC,CAAC;EAEF,OAAO;IACHJ;EACJ,CAAC;AACL"} \ No newline at end of file diff --git a/dist/esm/plugins/utils/utils-array.js b/dist/esm/plugins/utils/utils-array.js index 22b81ec5053..f0f2855bfda 100644 --- a/dist/esm/plugins/utils/utils-array.js +++ b/dist/esm/plugins/utils/utils-array.js @@ -8,6 +8,10 @@ export function lastOfArray(ar) { export function shuffleArray(arr) { return arr.slice(0).sort(() => Math.random() - 0.5); } +export function randomOfArray(arr) { + var randomElement = arr[Math.floor(Math.random() * arr.length)]; + return randomElement; +} export function toArray(input) { return Array.isArray(input) ? input.slice(0) : [input]; } diff --git a/dist/esm/plugins/utils/utils-array.js.map b/dist/esm/plugins/utils/utils-array.js.map index 439a72b8dec..e012b737222 100644 --- a/dist/esm/plugins/utils/utils-array.js.map +++ b/dist/esm/plugins/utils/utils-array.js.map @@ -1 +1 @@ -{"version":3,"file":"utils-array.js","names":["lastOfArray","ar","length","shuffleArray","arr","slice","sort","Math","random","toArray","input","Array","isArray","batchArray","array","batchSize","ret","batch","splice","push","removeOneFromArrayIfMatches","condition","i","done","isMaybeReadonlyArray","x","isOneItemOfArrayInOtherArray","ar1","ar2","el","has","includes","arrayFilterNotEmpty","value","undefined","countUntilNotMatching","matchingFn","count","idx","item","matching","asyncFilter","predicate","filters","Promise","all","map","filter","index","sumNumberArray","maxOfNumbers","max","appendToArray","add","amount","element","uniqueArray","arrArg","elem","pos","indexOf"],"sources":["../../../../src/plugins/utils/utils-array.ts"],"sourcesContent":["import type {\n MaybePromise,\n MaybeReadonly\n} from '../../types/index.d.ts';\n\nexport function lastOfArray(ar: T[]): T | undefined {\n return ar[ar.length - 1];\n}\n\n/**\n * shuffle the given array\n */\nexport function shuffleArray(arr: T[]): T[] {\n return arr.slice(0).sort(() => (Math.random() - 0.5));\n}\n\nexport function toArray(input: T | T[] | Readonly | Readonly): T[] {\n return Array.isArray(input) ? (input as any[]).slice(0) : [input];\n}\n\n/**\n * Split array with items into smaller arrays with items\n * @link https://stackoverflow.com/a/7273794/3443137\n */\nexport function batchArray(array: T[], batchSize: number): T[][] {\n array = array.slice(0);\n const ret: T[][] = [];\n while (array.length) {\n const batch = array.splice(0, batchSize);\n ret.push(batch);\n }\n return ret;\n}\n\n/**\n * @link https://stackoverflow.com/a/15996017\n */\nexport function removeOneFromArrayIfMatches(ar: T[], condition: (x: T) => boolean): T[] {\n ar = ar.slice();\n let i = ar.length;\n let done = false;\n while (i-- && !done) {\n if (condition(ar[i])) {\n done = true;\n ar.splice(i, 1);\n }\n }\n return ar;\n}\n\n/**\n * returns true if the supplied argument is either an Array or a Readonly>\n */\nexport function isMaybeReadonlyArray(x: any): x is MaybeReadonly {\n // While this looks strange, it's a workaround for an issue in TypeScript:\n // https://github.com/microsoft/TypeScript/issues/17002\n //\n // The problem is that `Array.isArray` as a type guard returns `false` for a readonly array,\n // but at runtime the object is an array and the runtime call to `Array.isArray` would return `true`.\n // The type predicate here allows for both `Array` and `Readonly>` to pass a type check while\n // still performing runtime type inspection.\n return Array.isArray(x);\n}\n\n\n\nexport function isOneItemOfArrayInOtherArray(ar1: T[], ar2: T[]): boolean {\n for (let i = 0; i < ar1.length; i++) {\n const el = ar1[i];\n const has = ar2.includes(el);\n if (has) {\n return true;\n }\n }\n return false;\n}\n\n\n/**\n * Use this in array.filter() to remove all empty slots\n * and have the correct typings afterwards.\n * @link https://stackoverflow.com/a/46700791/3443137\n */\nexport function arrayFilterNotEmpty(value: TValue | null | undefined): value is TValue {\n if (value === null || value === undefined) {\n return false;\n }\n return true;\n}\n\nexport function countUntilNotMatching(\n ar: T[],\n matchingFn: (v: T, idx: number) => boolean\n): number {\n let count = 0;\n let idx = -1;\n for (const item of ar) {\n idx = idx + 1;\n const matching = matchingFn(item, idx);\n if (matching) {\n count = count + 1;\n } else {\n break;\n }\n }\n return count;\n}\n\nexport async function asyncFilter(array: T[], predicate: (item: T, index: number, a: T[]) => MaybePromise): Promise {\n const filters = await Promise.all(\n array.map(predicate)\n );\n\n return array.filter((...[, index]) => filters[index]);\n}\n\n/**\n * @link https://stackoverflow.com/a/3762735\n */\nexport function sumNumberArray(array: number[]): number {\n let count = 0;\n for (let i = array.length; i--;) {\n count += array[i];\n }\n return count;\n}\n\nexport function maxOfNumbers(arr: number[]): number {\n return Math.max(...arr);\n}\n\n\n/**\n * Appends the given documents to the given array.\n * This will mutate the first given array.\n * Mostly used as faster alternative to Array.concat()\n * because .concat() is so slow.\n * @link https://www.measurethat.net/Benchmarks/Show/4223/0/array-concat-vs-spread-operator-vs-push#latest_results_block\n */\nexport function appendToArray(ar: T[], add: T[] | readonly T[]): void {\n const amount = add.length;\n for (let i = 0; i < amount; ++i) {\n const element = add[i];\n ar.push(element);\n }\n}\n\n/**\n * @link https://gist.github.com/telekosmos/3b62a31a5c43f40849bb\n */\nexport function uniqueArray(arrArg: string[]): string[] {\n return arrArg.filter(function (elem, pos, arr) {\n return arr.indexOf(elem) === pos;\n });\n}\n\n"],"mappings":"AAKA,OAAO,SAASA,WAAWA,CAAIC,EAAO,EAAiB;EACnD,OAAOA,EAAE,CAACA,EAAE,CAACC,MAAM,GAAG,CAAC,CAAC;AAC5B;;AAEA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAIC,GAAQ,EAAO;EAC3C,OAAOA,GAAG,CAACC,KAAK,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,MAAOC,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,GAAI,CAAC;AACzD;AAEA,OAAO,SAASC,OAAOA,CAAIC,KAA4C,EAAO;EAC1E,OAAOC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,GAAIA,KAAK,CAAWL,KAAK,CAAC,CAAC,CAAC,GAAG,CAACK,KAAK,CAAC;AACrE;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,UAAUA,CAAIC,KAAU,EAAEC,SAAiB,EAAS;EAChED,KAAK,GAAGA,KAAK,CAACT,KAAK,CAAC,CAAC,CAAC;EACtB,IAAMW,GAAU,GAAG,EAAE;EACrB,OAAOF,KAAK,CAACZ,MAAM,EAAE;IACjB,IAAMe,KAAK,GAAGH,KAAK,CAACI,MAAM,CAAC,CAAC,EAAEH,SAAS,CAAC;IACxCC,GAAG,CAACG,IAAI,CAACF,KAAK,CAAC;EACnB;EACA,OAAOD,GAAG;AACd;;AAEA;AACA;AACA;AACA,OAAO,SAASI,2BAA2BA,CAAInB,EAAO,EAAEoB,SAA4B,EAAO;EACvFpB,EAAE,GAAGA,EAAE,CAACI,KAAK,CAAC,CAAC;EACf,IAAIiB,CAAC,GAAGrB,EAAE,CAACC,MAAM;EACjB,IAAIqB,IAAI,GAAG,KAAK;EAChB,OAAOD,CAAC,EAAE,IAAI,CAACC,IAAI,EAAE;IACjB,IAAIF,SAAS,CAACpB,EAAE,CAACqB,CAAC,CAAC,CAAC,EAAE;MAClBC,IAAI,GAAG,IAAI;MACXtB,EAAE,CAACiB,MAAM,CAACI,CAAC,EAAE,CAAC,CAAC;IACnB;EACJ;EACA,OAAOrB,EAAE;AACb;;AAEA;AACA;AACA;AACA,OAAO,SAASuB,oBAAoBA,CAACC,CAAM,EAA6B;EACpE;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAOd,KAAK,CAACC,OAAO,CAACa,CAAC,CAAC;AAC3B;AAIA,OAAO,SAASC,4BAA4BA,CAAIC,GAAQ,EAAEC,GAAQ,EAAW;EACzE,KAAK,IAAIN,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGK,GAAG,CAACzB,MAAM,EAAEoB,CAAC,EAAE,EAAE;IACjC,IAAMO,EAAE,GAAGF,GAAG,CAACL,CAAC,CAAC;IACjB,IAAMQ,GAAG,GAAGF,GAAG,CAACG,QAAQ,CAACF,EAAE,CAAC;IAC5B,IAAIC,GAAG,EAAE;MACL,OAAO,IAAI;IACf;EACJ;EACA,OAAO,KAAK;AAChB;;AAGA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,mBAAmBA,CAASC,KAAgC,EAAmB;EAC3F,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKC,SAAS,EAAE;IACvC,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf;AAEA,OAAO,SAASC,qBAAqBA,CACjClC,EAAO,EACPmC,UAA0C,EACpC;EACN,IAAIC,KAAK,GAAG,CAAC;EACb,IAAIC,GAAG,GAAG,CAAC,CAAC;EACZ,KAAK,IAAMC,KAAI,IAAItC,EAAE,EAAE;IACnBqC,GAAG,GAAGA,GAAG,GAAG,CAAC;IACb,IAAME,QAAQ,GAAGJ,UAAU,CAACG,KAAI,EAAED,GAAG,CAAC;IACtC,IAAIE,QAAQ,EAAE;MACVH,KAAK,GAAGA,KAAK,GAAG,CAAC;IACrB,CAAC,MAAM;MACH;IACJ;EACJ;EACA,OAAOA,KAAK;AAChB;AAEA,OAAO,eAAeI,WAAWA,CAAI3B,KAAU,EAAE4B,SAAoE,EAAgB;EACjI,IAAMC,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC7B/B,KAAK,CAACgC,GAAG,CAACJ,SAAS,CACvB,CAAC;EAED,OAAO5B,KAAK,CAACiC,MAAM,CAAC,CAAC,GAAG,GAAGC,KAAK,CAAC,KAAKL,OAAO,CAACK,KAAK,CAAC,CAAC;AACzD;;AAEA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACnC,KAAe,EAAU;EACpD,IAAIuB,KAAK,GAAG,CAAC;EACb,KAAK,IAAIf,CAAC,GAAGR,KAAK,CAACZ,MAAM,EAAEoB,CAAC,EAAE,GAAG;IAC7Be,KAAK,IAAIvB,KAAK,CAACQ,CAAC,CAAC;EACrB;EACA,OAAOe,KAAK;AAChB;AAEA,OAAO,SAASa,YAAYA,CAAC9C,GAAa,EAAU;EAChD,OAAOG,IAAI,CAAC4C,GAAG,CAAC,GAAG/C,GAAG,CAAC;AAC3B;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASgD,aAAaA,CAAInD,EAAO,EAAEoD,GAAuB,EAAQ;EACrE,IAAMC,MAAM,GAAGD,GAAG,CAACnD,MAAM;EACzB,KAAK,IAAIoB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGgC,MAAM,EAAE,EAAEhC,CAAC,EAAE;IAC7B,IAAMiC,OAAO,GAAGF,GAAG,CAAC/B,CAAC,CAAC;IACtBrB,EAAE,CAACkB,IAAI,CAACoC,OAAO,CAAC;EACpB;AACJ;;AAEA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAACC,MAAgB,EAAY;EACpD,OAAOA,MAAM,CAACV,MAAM,CAAC,UAAUW,IAAI,EAAEC,GAAG,EAAEvD,GAAG,EAAE;IAC3C,OAAOA,GAAG,CAACwD,OAAO,CAACF,IAAI,CAAC,KAAKC,GAAG;EACpC,CAAC,CAAC;AACN"} \ No newline at end of file +{"version":3,"file":"utils-array.js","names":["lastOfArray","ar","length","shuffleArray","arr","slice","sort","Math","random","randomOfArray","randomElement","floor","toArray","input","Array","isArray","batchArray","array","batchSize","ret","batch","splice","push","removeOneFromArrayIfMatches","condition","i","done","isMaybeReadonlyArray","x","isOneItemOfArrayInOtherArray","ar1","ar2","el","has","includes","arrayFilterNotEmpty","value","undefined","countUntilNotMatching","matchingFn","count","idx","item","matching","asyncFilter","predicate","filters","Promise","all","map","filter","index","sumNumberArray","maxOfNumbers","max","appendToArray","add","amount","element","uniqueArray","arrArg","elem","pos","indexOf"],"sources":["../../../../src/plugins/utils/utils-array.ts"],"sourcesContent":["import type {\n MaybePromise,\n MaybeReadonly\n} from '../../types/index.d.ts';\n\nexport function lastOfArray(ar: T[]): T | undefined {\n return ar[ar.length - 1];\n}\n\n/**\n * shuffle the given array\n */\nexport function shuffleArray(arr: T[]): T[] {\n return arr.slice(0).sort(() => (Math.random() - 0.5));\n}\n\nexport function randomOfArray(arr: T[]): T {\n const randomElement = arr[Math.floor(Math.random() * arr.length)];\n return randomElement;\n}\n\n\nexport function toArray(input: T | T[] | Readonly | Readonly): T[] {\n return Array.isArray(input) ? (input as any[]).slice(0) : [input];\n}\n\n/**\n * Split array with items into smaller arrays with items\n * @link https://stackoverflow.com/a/7273794/3443137\n */\nexport function batchArray(array: T[], batchSize: number): T[][] {\n array = array.slice(0);\n const ret: T[][] = [];\n while (array.length) {\n const batch = array.splice(0, batchSize);\n ret.push(batch);\n }\n return ret;\n}\n\n/**\n * @link https://stackoverflow.com/a/15996017\n */\nexport function removeOneFromArrayIfMatches(ar: T[], condition: (x: T) => boolean): T[] {\n ar = ar.slice();\n let i = ar.length;\n let done = false;\n while (i-- && !done) {\n if (condition(ar[i])) {\n done = true;\n ar.splice(i, 1);\n }\n }\n return ar;\n}\n\n/**\n * returns true if the supplied argument is either an Array or a Readonly>\n */\nexport function isMaybeReadonlyArray(x: any): x is MaybeReadonly {\n // While this looks strange, it's a workaround for an issue in TypeScript:\n // https://github.com/microsoft/TypeScript/issues/17002\n //\n // The problem is that `Array.isArray` as a type guard returns `false` for a readonly array,\n // but at runtime the object is an array and the runtime call to `Array.isArray` would return `true`.\n // The type predicate here allows for both `Array` and `Readonly>` to pass a type check while\n // still performing runtime type inspection.\n return Array.isArray(x);\n}\n\n\n\nexport function isOneItemOfArrayInOtherArray(ar1: T[], ar2: T[]): boolean {\n for (let i = 0; i < ar1.length; i++) {\n const el = ar1[i];\n const has = ar2.includes(el);\n if (has) {\n return true;\n }\n }\n return false;\n}\n\n\n/**\n * Use this in array.filter() to remove all empty slots\n * and have the correct typings afterwards.\n * @link https://stackoverflow.com/a/46700791/3443137\n */\nexport function arrayFilterNotEmpty(value: TValue | null | undefined): value is TValue {\n if (value === null || value === undefined) {\n return false;\n }\n return true;\n}\n\nexport function countUntilNotMatching(\n ar: T[],\n matchingFn: (v: T, idx: number) => boolean\n): number {\n let count = 0;\n let idx = -1;\n for (const item of ar) {\n idx = idx + 1;\n const matching = matchingFn(item, idx);\n if (matching) {\n count = count + 1;\n } else {\n break;\n }\n }\n return count;\n}\n\nexport async function asyncFilter(array: T[], predicate: (item: T, index: number, a: T[]) => MaybePromise): Promise {\n const filters = await Promise.all(\n array.map(predicate)\n );\n\n return array.filter((...[, index]) => filters[index]);\n}\n\n/**\n * @link https://stackoverflow.com/a/3762735\n */\nexport function sumNumberArray(array: number[]): number {\n let count = 0;\n for (let i = array.length; i--;) {\n count += array[i];\n }\n return count;\n}\n\nexport function maxOfNumbers(arr: number[]): number {\n return Math.max(...arr);\n}\n\n\n/**\n * Appends the given documents to the given array.\n * This will mutate the first given array.\n * Mostly used as faster alternative to Array.concat()\n * because .concat() is so slow.\n * @link https://www.measurethat.net/Benchmarks/Show/4223/0/array-concat-vs-spread-operator-vs-push#latest_results_block\n */\nexport function appendToArray(ar: T[], add: T[] | readonly T[]): void {\n const amount = add.length;\n for (let i = 0; i < amount; ++i) {\n const element = add[i];\n ar.push(element);\n }\n}\n\n/**\n * @link https://gist.github.com/telekosmos/3b62a31a5c43f40849bb\n */\nexport function uniqueArray(arrArg: string[]): string[] {\n return arrArg.filter(function (elem, pos, arr) {\n return arr.indexOf(elem) === pos;\n });\n}\n\n"],"mappings":"AAKA,OAAO,SAASA,WAAWA,CAAIC,EAAO,EAAiB;EACnD,OAAOA,EAAE,CAACA,EAAE,CAACC,MAAM,GAAG,CAAC,CAAC;AAC5B;;AAEA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAIC,GAAQ,EAAO;EAC3C,OAAOA,GAAG,CAACC,KAAK,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,MAAOC,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,GAAI,CAAC;AACzD;AAEA,OAAO,SAASC,aAAaA,CAAIL,GAAQ,EAAK;EAC1C,IAAMM,aAAa,GAAGN,GAAG,CAACG,IAAI,CAACI,KAAK,CAACJ,IAAI,CAACC,MAAM,CAAC,CAAC,GAAGJ,GAAG,CAACF,MAAM,CAAC,CAAC;EACjE,OAAOQ,aAAa;AACxB;AAGA,OAAO,SAASE,OAAOA,CAAIC,KAA4C,EAAO;EAC1E,OAAOC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,GAAIA,KAAK,CAAWR,KAAK,CAAC,CAAC,CAAC,GAAG,CAACQ,KAAK,CAAC;AACrE;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,UAAUA,CAAIC,KAAU,EAAEC,SAAiB,EAAS;EAChED,KAAK,GAAGA,KAAK,CAACZ,KAAK,CAAC,CAAC,CAAC;EACtB,IAAMc,GAAU,GAAG,EAAE;EACrB,OAAOF,KAAK,CAACf,MAAM,EAAE;IACjB,IAAMkB,KAAK,GAAGH,KAAK,CAACI,MAAM,CAAC,CAAC,EAAEH,SAAS,CAAC;IACxCC,GAAG,CAACG,IAAI,CAACF,KAAK,CAAC;EACnB;EACA,OAAOD,GAAG;AACd;;AAEA;AACA;AACA;AACA,OAAO,SAASI,2BAA2BA,CAAItB,EAAO,EAAEuB,SAA4B,EAAO;EACvFvB,EAAE,GAAGA,EAAE,CAACI,KAAK,CAAC,CAAC;EACf,IAAIoB,CAAC,GAAGxB,EAAE,CAACC,MAAM;EACjB,IAAIwB,IAAI,GAAG,KAAK;EAChB,OAAOD,CAAC,EAAE,IAAI,CAACC,IAAI,EAAE;IACjB,IAAIF,SAAS,CAACvB,EAAE,CAACwB,CAAC,CAAC,CAAC,EAAE;MAClBC,IAAI,GAAG,IAAI;MACXzB,EAAE,CAACoB,MAAM,CAACI,CAAC,EAAE,CAAC,CAAC;IACnB;EACJ;EACA,OAAOxB,EAAE;AACb;;AAEA;AACA;AACA;AACA,OAAO,SAAS0B,oBAAoBA,CAACC,CAAM,EAA6B;EACpE;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAOd,KAAK,CAACC,OAAO,CAACa,CAAC,CAAC;AAC3B;AAIA,OAAO,SAASC,4BAA4BA,CAAIC,GAAQ,EAAEC,GAAQ,EAAW;EACzE,KAAK,IAAIN,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGK,GAAG,CAAC5B,MAAM,EAAEuB,CAAC,EAAE,EAAE;IACjC,IAAMO,EAAE,GAAGF,GAAG,CAACL,CAAC,CAAC;IACjB,IAAMQ,GAAG,GAAGF,GAAG,CAACG,QAAQ,CAACF,EAAE,CAAC;IAC5B,IAAIC,GAAG,EAAE;MACL,OAAO,IAAI;IACf;EACJ;EACA,OAAO,KAAK;AAChB;;AAGA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,mBAAmBA,CAASC,KAAgC,EAAmB;EAC3F,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKC,SAAS,EAAE;IACvC,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf;AAEA,OAAO,SAASC,qBAAqBA,CACjCrC,EAAO,EACPsC,UAA0C,EACpC;EACN,IAAIC,KAAK,GAAG,CAAC;EACb,IAAIC,GAAG,GAAG,CAAC,CAAC;EACZ,KAAK,IAAMC,KAAI,IAAIzC,EAAE,EAAE;IACnBwC,GAAG,GAAGA,GAAG,GAAG,CAAC;IACb,IAAME,QAAQ,GAAGJ,UAAU,CAACG,KAAI,EAAED,GAAG,CAAC;IACtC,IAAIE,QAAQ,EAAE;MACVH,KAAK,GAAGA,KAAK,GAAG,CAAC;IACrB,CAAC,MAAM;MACH;IACJ;EACJ;EACA,OAAOA,KAAK;AAChB;AAEA,OAAO,eAAeI,WAAWA,CAAI3B,KAAU,EAAE4B,SAAoE,EAAgB;EACjI,IAAMC,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC7B/B,KAAK,CAACgC,GAAG,CAACJ,SAAS,CACvB,CAAC;EAED,OAAO5B,KAAK,CAACiC,MAAM,CAAC,CAAC,GAAG,GAAGC,KAAK,CAAC,KAAKL,OAAO,CAACK,KAAK,CAAC,CAAC;AACzD;;AAEA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACnC,KAAe,EAAU;EACpD,IAAIuB,KAAK,GAAG,CAAC;EACb,KAAK,IAAIf,CAAC,GAAGR,KAAK,CAACf,MAAM,EAAEuB,CAAC,EAAE,GAAG;IAC7Be,KAAK,IAAIvB,KAAK,CAACQ,CAAC,CAAC;EACrB;EACA,OAAOe,KAAK;AAChB;AAEA,OAAO,SAASa,YAAYA,CAACjD,GAAa,EAAU;EAChD,OAAOG,IAAI,CAAC+C,GAAG,CAAC,GAAGlD,GAAG,CAAC;AAC3B;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASmD,aAAaA,CAAItD,EAAO,EAAEuD,GAAuB,EAAQ;EACrE,IAAMC,MAAM,GAAGD,GAAG,CAACtD,MAAM;EACzB,KAAK,IAAIuB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGgC,MAAM,EAAE,EAAEhC,CAAC,EAAE;IAC7B,IAAMiC,OAAO,GAAGF,GAAG,CAAC/B,CAAC,CAAC;IACtBxB,EAAE,CAACqB,IAAI,CAACoC,OAAO,CAAC;EACpB;AACJ;;AAEA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAACC,MAAgB,EAAY;EACpD,OAAOA,MAAM,CAACV,MAAM,CAAC,UAAUW,IAAI,EAAEC,GAAG,EAAE1D,GAAG,EAAE;IAC3C,OAAOA,GAAG,CAAC2D,OAAO,CAACF,IAAI,CAAC,KAAKC,GAAG;EACpC,CAAC,CAAC;AACN"} \ No newline at end of file diff --git a/dist/esm/plugins/utils/utils-rxdb-version.js b/dist/esm/plugins/utils/utils-rxdb-version.js index e6c584a5f74..c420332f785 100644 --- a/dist/esm/plugins/utils/utils-rxdb-version.js +++ b/dist/esm/plugins/utils/utils-rxdb-version.js @@ -1,5 +1,5 @@ /** * This file is replaced in the 'npm run build:version' script. */ -export var RXDB_VERSION = '15.9.1'; +export var RXDB_VERSION = '15.10.0'; //# sourceMappingURL=utils-rxdb-version.js.map \ No newline at end of file diff --git a/dist/esm/plugins/utils/utils-rxdb-version.js.map b/dist/esm/plugins/utils/utils-rxdb-version.js.map index 32ec291170f..d899e219126 100644 --- a/dist/esm/plugins/utils/utils-rxdb-version.js.map +++ b/dist/esm/plugins/utils/utils-rxdb-version.js.map @@ -1 +1 @@ -{"version":3,"file":"utils-rxdb-version.js","names":["RXDB_VERSION"],"sources":["../../../../src/plugins/utils/utils-rxdb-version.ts"],"sourcesContent":["/**\n * This file is replaced in the 'npm run build:version' script.\n */\nexport const RXDB_VERSION = '15.9.1';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,IAAMA,YAAY,GAAG,QAAQ"} \ No newline at end of file +{"version":3,"file":"utils-rxdb-version.js","names":["RXDB_VERSION"],"sources":["../../../../src/plugins/utils/utils-rxdb-version.ts"],"sourcesContent":["/**\n * This file is replaced in the 'npm run build:version' script.\n */\nexport const RXDB_VERSION = '15.10.0';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,IAAMA,YAAY,GAAG,SAAS"} \ No newline at end of file diff --git a/dist/types/plugins/storage-denokv/index.d.ts b/dist/types/plugins/storage-denokv/index.d.ts index 7fcd8530934..651bed1936a 100644 --- a/dist/types/plugins/storage-denokv/index.d.ts +++ b/dist/types/plugins/storage-denokv/index.d.ts @@ -4,7 +4,7 @@ import { RxStorageInstanceDenoKV } from "./rx-storage-instance-denokv.ts"; export declare class RxStorageDenoKV implements RxStorage, DenoKVSettings> { settings: DenoKVSettings; name: string; - readonly rxdbVersion = "15.9.1"; + readonly rxdbVersion = "15.10.0"; constructor(settings: DenoKVSettings); createStorageInstance(params: RxStorageInstanceCreationParams): Promise>; } diff --git a/dist/types/plugins/storage-dexie/rx-storage-dexie.d.ts b/dist/types/plugins/storage-dexie/rx-storage-dexie.d.ts index b0f9adbd921..1039fded9aa 100644 --- a/dist/types/plugins/storage-dexie/rx-storage-dexie.d.ts +++ b/dist/types/plugins/storage-dexie/rx-storage-dexie.d.ts @@ -4,7 +4,7 @@ import { RxStorageInstanceDexie } from './rx-storage-instance-dexie.ts'; export declare class RxStorageDexie implements RxStorage { settings: DexieSettings; name: string; - readonly rxdbVersion = "15.9.1"; + readonly rxdbVersion = "15.10.0"; constructor(settings: DexieSettings); createStorageInstance(params: RxStorageInstanceCreationParams): Promise>; } diff --git a/dist/types/plugins/storage-lokijs/rx-storage-lokijs.d.ts b/dist/types/plugins/storage-lokijs/rx-storage-lokijs.d.ts index 5bc925f6e4b..babf5f95597 100644 --- a/dist/types/plugins/storage-lokijs/rx-storage-lokijs.d.ts +++ b/dist/types/plugins/storage-lokijs/rx-storage-lokijs.d.ts @@ -4,7 +4,7 @@ import type { LeaderElector } from 'broadcast-channel'; export declare class RxStorageLoki implements RxStorage { databaseSettings: LokiDatabaseSettings; name: string; - readonly rxdbVersion = "15.9.1"; + readonly rxdbVersion = "15.10.0"; /** * Create one leader elector by db name. * This is done inside of the storage, not globally diff --git a/dist/types/plugins/storage-mongodb/rx-storage-mongodb.d.ts b/dist/types/plugins/storage-mongodb/rx-storage-mongodb.d.ts index 389e50d6745..8ca98de4423 100644 --- a/dist/types/plugins/storage-mongodb/rx-storage-mongodb.d.ts +++ b/dist/types/plugins/storage-mongodb/rx-storage-mongodb.d.ts @@ -4,7 +4,7 @@ import { RxStorageInstanceMongoDB } from './rx-storage-instance-mongodb.ts'; export declare class RxStorageMongoDB implements RxStorage { databaseSettings: MongoDBDatabaseSettings; name: string; - readonly rxdbVersion = "15.9.1"; + readonly rxdbVersion = "15.10.0"; constructor(databaseSettings: MongoDBDatabaseSettings); createStorageInstance(params: RxStorageInstanceCreationParams): Promise>; } diff --git a/dist/types/plugins/storage-remote/rx-storage-remote.d.ts b/dist/types/plugins/storage-remote/rx-storage-remote.d.ts index 9caef93470d..2ca063bd8ca 100644 --- a/dist/types/plugins/storage-remote/rx-storage-remote.d.ts +++ b/dist/types/plugins/storage-remote/rx-storage-remote.d.ts @@ -4,7 +4,7 @@ import type { MessageFromRemote, RemoteMessageChannel, RxStorageRemoteInternals, export declare class RxStorageRemote implements RxStorage { readonly settings: RxStorageRemoteSettings; readonly name: string; - readonly rxdbVersion = "15.9.1"; + readonly rxdbVersion = "15.10.0"; private seed; private lastRequestId; messageChannelIfOneMode?: Promise; diff --git a/dist/types/plugins/utils/utils-array.d.ts b/dist/types/plugins/utils/utils-array.d.ts index b500996fd6e..03b7c448148 100644 --- a/dist/types/plugins/utils/utils-array.d.ts +++ b/dist/types/plugins/utils/utils-array.d.ts @@ -4,6 +4,7 @@ export declare function lastOfArray(ar: T[]): T | undefined; * shuffle the given array */ export declare function shuffleArray(arr: T[]): T[]; +export declare function randomOfArray(arr: T[]): T; export declare function toArray(input: T | T[] | Readonly | Readonly): T[]; /** * Split array with items into smaller arrays with items diff --git a/dist/types/plugins/utils/utils-rxdb-version.d.ts b/dist/types/plugins/utils/utils-rxdb-version.d.ts index 76e5ce2294b..f1cd39233c6 100644 --- a/dist/types/plugins/utils/utils-rxdb-version.d.ts +++ b/dist/types/plugins/utils/utils-rxdb-version.d.ts @@ -1,4 +1,4 @@ /** * This file is replaced in the 'npm run build:version' script. */ -export declare const RXDB_VERSION = "15.9.1"; +export declare const RXDB_VERSION = "15.10.0"; diff --git a/dist/types/rx-database.d.ts b/dist/types/rx-database.d.ts index dc7c0aa7c02..687aa5035c8 100644 --- a/dist/types/rx-database.d.ts +++ b/dist/types/rx-database.d.ts @@ -29,7 +29,7 @@ export declare class RxDatabaseBase | undefined; readonly idleQueue: IdleQueue; - readonly rxdbVersion = "15.9.1"; + readonly rxdbVersion = "15.10.0"; /** * Contains all known non-closed storage instances * that belong to this database. diff --git a/docs/404.html b/docs/404.html index 2154a1b479f..5f674209fe9 100644 --- a/docs/404.html +++ b/docs/404.html @@ -12,8 +12,8 @@ - - + +

RxDB
404 Page Not Found

The page you are looking for does not exist anymore or never has existed. If you have found this page through a link, you should tell the link author to update it.

Maybe one of these can help you to find the desired content:

diff --git a/docs/adapters.html b/docs/adapters.html index fb54069a578..02a2e64a4aa 100644 --- a/docs/adapters.html +++ b/docs/adapters.html @@ -12,8 +12,8 @@ - - + +

PouchDB Adapters

diff --git a/docs/alternatives.html b/docs/alternatives.html index 3201af33650..1154ccb09c6 100644 --- a/docs/alternatives.html +++ b/docs/alternatives.html @@ -12,8 +12,8 @@ - - + +

Alternatives for realtime offline-first JavaScript applications

diff --git a/docs/articles/angular-database.html b/docs/articles/angular-database.html index 22d8987a30b..e681cdffeab 100644 --- a/docs/articles/angular-database.html +++ b/docs/articles/angular-database.html @@ -12,8 +12,8 @@ - - + +

RxDB as a Database in an Angular Application

diff --git a/docs/articles/browser-database.html b/docs/articles/browser-database.html index 8bd6a078125..85ec5861543 100644 --- a/docs/articles/browser-database.html +++ b/docs/articles/browser-database.html @@ -12,8 +12,8 @@ - - + +

RxDB: The benefits of Browser Databases

diff --git a/docs/articles/browser-storage.html b/docs/articles/browser-storage.html index 4fb6071980e..f33983a53a3 100644 --- a/docs/articles/browser-storage.html +++ b/docs/articles/browser-storage.html @@ -12,8 +12,8 @@ - - + +

Browser Storage - RxDB as a Database for Browsers

diff --git a/docs/articles/data-base.html b/docs/articles/data-base.html index 7143ecb93a4..8bb6c8a7ed7 100644 --- a/docs/articles/data-base.html +++ b/docs/articles/data-base.html @@ -12,8 +12,8 @@ - - + +

RxDB as a data base: Empowering Web Applications with Reactive Data Handling

diff --git a/docs/articles/embedded-database.html b/docs/articles/embedded-database.html index b04ff6b1728..cc552b206e6 100644 --- a/docs/articles/embedded-database.html +++ b/docs/articles/embedded-database.html @@ -12,8 +12,8 @@ - - + +

Using RxDB as an Embedded Database

diff --git a/docs/articles/flutter-database.html b/docs/articles/flutter-database.html index 564d028c973..df8aeb15cd0 100644 --- a/docs/articles/flutter-database.html +++ b/docs/articles/flutter-database.html @@ -12,8 +12,8 @@ - - + +

RxDB as a Database in a Flutter Application

diff --git a/docs/articles/frontend-database.html b/docs/articles/frontend-database.html index 18c79087a9f..11ee83b6e92 100644 --- a/docs/articles/frontend-database.html +++ b/docs/articles/frontend-database.html @@ -12,8 +12,8 @@ - - + +

RxDB JavaScript Frontend Database: Efficient Data Storage in Frontend Applications

diff --git a/docs/articles/in-memory-nosql-database.html b/docs/articles/in-memory-nosql-database.html index 89bed5bf43f..ec8380421a7 100644 --- a/docs/articles/in-memory-nosql-database.html +++ b/docs/articles/in-memory-nosql-database.html @@ -12,8 +12,8 @@ - - + +

RxDB as In-memory NoSQL Database: Empowering Real-Time Applications

diff --git a/docs/articles/ionic-database.html b/docs/articles/ionic-database.html index 8460996c261..8e692576624 100644 --- a/docs/articles/ionic-database.html +++ b/docs/articles/ionic-database.html @@ -12,8 +12,8 @@ - - + +

Ionic Storage - RxDB as database for hybrid apps

diff --git a/docs/articles/json-database.html b/docs/articles/json-database.html index 629f06a050a..aa5cc69b5d6 100644 --- a/docs/articles/json-database.html +++ b/docs/articles/json-database.html @@ -12,8 +12,8 @@ - - + +

RxDB - JSON Database for JavaScript

diff --git a/docs/articles/localstorage.html b/docs/articles/localstorage.html index 1bfa80f483e..04c26ea254a 100644 --- a/docs/articles/localstorage.html +++ b/docs/articles/localstorage.html @@ -12,8 +12,8 @@ - - + +

Using localStorage in Modern Applications: A Comprehensive Guide

diff --git a/docs/articles/mobile-database.html b/docs/articles/mobile-database.html index 4c9800e943f..fccc2eaa4d6 100644 --- a/docs/articles/mobile-database.html +++ b/docs/articles/mobile-database.html @@ -12,8 +12,8 @@ - - + +

Mobile Database - RxDB as Database for Mobile Applications

diff --git a/docs/articles/progressive-web-app-database.html b/docs/articles/progressive-web-app-database.html index 7be84cfa8fe..1f85c3d0cac 100644 --- a/docs/articles/progressive-web-app-database.html +++ b/docs/articles/progressive-web-app-database.html @@ -12,8 +12,8 @@ - - + +

RxDB as a Database for Progressive Web Apps (PWA)

diff --git a/docs/articles/react-database.html b/docs/articles/react-database.html index abe99d98274..224d159a448 100644 --- a/docs/articles/react-database.html +++ b/docs/articles/react-database.html @@ -12,8 +12,8 @@ - - + +

RxDB as a Database for React Applications

diff --git a/docs/articles/realtime-database.html b/docs/articles/realtime-database.html index c8816f91cdb..17b4bd6619c 100644 --- a/docs/articles/realtime-database.html +++ b/docs/articles/realtime-database.html @@ -12,8 +12,8 @@ - - + +

What is a realtime database?

diff --git a/docs/assets/js/0e268d20.2d62c3fd.js b/docs/assets/js/0e268d20.2d62c3fd.js new file mode 100644 index 00000000000..04bca9d1936 --- /dev/null +++ b/docs/assets/js/0e268d20.2d62c3fd.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[2584],{2658:(e,t,r)=>{r.d(t,{Tj:()=>Kr,C3:()=>zr,IA:()=>Hr});var a=r(7329);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)},d=new Set(["__proto__","prototype","constructor"]),h=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(d.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(d.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&&!h.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(d.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 j(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=j(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.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),t}((0,w.A)(Error)),_=function(e){function t(t,r,a){var n;void 0===a&&(a={});var i=j(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.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),t}((0,w.A)(TypeError));function I(e,t){return new D(e,k.tunnelErrorMessage(e),t)}function R(e,t){return new _(e,k.tunnelErrorMessage(e),t)}function S(e){return!(!e||409!==e.status)&&e}var E={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var C=/\./g,P="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 F(e){var t=q((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=Q,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=W(e);(0,g.Hb)(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.k_)(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 Q={type:"object",properties:{lwt:{type:"number",minimum:$,maximum:1e15,multipleOf:.01}},additionalProperties:!0,required:["lwt"]};function W(e){var t=Object.keys(e.properties).filter((t=>e.properties[t].final)),r=q(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,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=q(e.primaryKey);t.push([r]),t.push(["_deleted",r]),e.indexes&&e.indexes.forEach((e=>{var r=(0,g.$r)(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.$r)(a).forEach((a=>{t.has(a)||(t.add(a),"boolean"===M(e,a).type&&r.push(a))}))})),r.push("_deleted"),(0,g.jw)(r)):r}var oe=r(9092),ce=r(5734),le=r(3337),ue=String.fromCharCode(65535),de=Number.MIN_SAFE_INTEGER;function he(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?de:ue,endKey:a?ue:de,inclusiveStart:!0,inclusiveEnd:!0};return void 0===i.startKey&&(i.startKey=de),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})),d=u.map((e=>e.startKey)),h=u.map((e=>e.endKey)),m={index:e,startKeys:d,endKeys:h,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!i.has(e))).join(","),selectorSatisfiedByIndex:ye(e,t.selector,d,h)},p=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},i=10,s=(0,g.Sd)(r.startKeys,(e=>e!==de&&e!==ue));n(s*i);var o=(0,g.Sd)(r.startKeys,(e=>e!==ue&&e!==de));n(o*i);var c=(0,g.Sd)(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 d=[],h=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&&h.add(m),"$eq"!==y){if(d.length>0)return!1;d.push(y)}}var v=0;for(var g of e){for(var b of[s,h]){if(!b.has(g)&&b.size>0)return!1;b.delete(g)}if(r[v]!==a[v]&&s.size>0&&h.size>0)return!1;v++}return!0}var ve=r(744),ge=r(2779),be=r(1692),xe=r(4903),we=r(7705),ke=r(2403),je=r(6776),De=r(6950),_e=r(6823),Ie=!1;function Re(e){return Ie||((0,ge.DZ)(ge.hu.PIPELINE,{$sort:xe.xF,$project:xe.C2}),(0,ge.DZ)(ge.hu.QUERY,{$and:we.a6,$eq:ke.XV,$elemMatch:De.Jy,$exists:_e.P,$gt:ke.MR,$gte:ke.fy,$in:ke.oZ,$lt:ke.NV,$lte:ke.Q_,$ne:ke.C5,$nin:ke.GU,$mod:je.Pp,$nor:we.q3,$not:we.En,$or:we.sU,$regex:je.WP,$size:De.Ig,$type:_e.T}),Ie=!0),new be.X(e)}function Se(e,t){var r=q(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.$r)(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.k_)(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 Ee(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 Pe(e){return e===de?-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(Pe),n=t.endKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Pe);return r.bound(a,n,!t.inclusiveStart,!t.inclusiveEnd)}async function Ae(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=Ce(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(H);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 d=Ee(e.schema,t.query);u=u.sort(d)}return{documents:u=u.slice(n,i)}}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 Be(e){return parseInt(e.split("-")[0],10)}function Me(e,t){var r=t?t._rev:null;return(r?$e(r).height:0)+1+"-"+e}var Te="_rxdb_internal";async function qe(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 Fe(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:k.deepFreezeWhenDevMode(a),previousDocumentData:k.deepFreezeWhenDevMode(n)}}function Qe(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 We(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=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 ze(e){var t=s(e);return t._meta=s(e._meta),t}function Ke(e,t,r){k.deepFreezeWhenDevMode(r);var a=q(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),k.isDevMode()){i=T(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.t)(),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.ZN)(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.Hb)(a.error,e.error),(0,g.Hb)(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.ZN)(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:B(),_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(3561),Ze=r(703),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.X2(["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.B,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,Ue.X)(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 d=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),d()}}}var Ye=(0,ce.t)(),Xe=function(){function e(e,t,r,a,n,i,s){this.changes$=new oe.B,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=q(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=[],d=[],h={id:O(10),events:[],checkpoint:null,context:n,startTime:(0,ce.t)(),endTime:0},m=h.events,p=[],f=[],y=[],v=r.size>0,g=a.length,b=function(){var e,n=a[x],h=n.document,g=n.previous,b=h[t],w=h._deleted,k=g&&g._deleted,j=void 0;if(v&&(j=r.get(b)),j){var D=j._rev;if(!g||g&&D!==g._rev){var _={isError:!0,status:409,documentId:b,writeRow:n,documentInDb:j};return d.push(_),1}var R=c?We(n):n;c&&(w?g&&Object.keys(g._attachments).forEach((e=>{f.push({documentId:b,attachmentId:e,digest:(0,le.ZN)(g)._attachments[e].digest})})):(Object.entries(h._attachments).find((t=>{let[r,a]=t;return(g?g._attachments[r]:void 0)||a.data||(e={documentId:b,documentInDb:j,isError:!0,status:510,writeRow:n,attachmentId:r}),!0})),e||Object.entries(h._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?d.push(e):(c?(u.push(We(R)),s&&s(h)):(u.push(R),s&&s(h)),o=R);var S=null,E=null,C=null;if(k&&!w)C="INSERT",S=c?He(h):h;else if(!g||k||w){if(!w)throw I("SNH",{args:{writeRow:n}});C="DELETE",S=(0,le.ZN)(h),E=g}else C="UPDATE",S=c?He(h):h,E=g;var P={documentId:b,documentData:S,previousDocumentData:E,operation:C};m.push(P)}else{var O=!!w;if(c&&Object.entries(h._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},d.push(e))})),e||(c?(l.push(We(n)),i&&i(h)):(l.push(n),i&&i(h)),o=n),!O){var N={documentId:b,operation:"INSERT",documentData:c?He(h):h,previousDocumentData:c&&g?He(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.ZN)(r)).eventBulk.events.length>0){var s=(0,le.ZN)(r.newestRow).document;r.eventBulk.checkpoint={id:s[this.primaryPath],lwt:s._meta.lwt},r.eventBulk.endTime=(0,ce.t)(),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),Ae(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(H);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 Ae(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.t)()-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.B},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.cf(o,e),i={[H]:ae(n),[z]:"++sequence, id",[K]:"id"};return t.version(1).stores(i),await t.open(),{dexieDb:t,dexieTable:t[H],dexieAttachmentsTable:t[K],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(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.10.0",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 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.k_)(e)?e:[e]))}(this.jsonSchema),this.primaryPath=q(this.jsonSchema.primaryKey),this.finalFields=W(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.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.A)(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=F(e);a=function(e){return o(e,!0)}(a),k.deepFreezeWhenDevMode(a);var n=new ct(a,t);return st("createRxSchema",n),n}var ut=r(7708),dt=r(8146),ht=r(3356),mt=r(5520),pt=r(8609),ft=r(1753);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.ZN)(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=$e(i._rev).height,n.forEach((e=>{var t=$e(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(d){u.reject(d),u.reject=()=>{},u.resolve=()=>{}}try{await this.preWrite(l,o)}catch(d){return void a.forEach((e=>e.reject(d)))}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=S(e);if(o){var c=i(this.queueByDocId,a,(()=>[]));s.reverse().forEach((e=>{e.lastKnownDocumentState=(0,le.ZN)(o.documentInDb),(0,le.ZN)(c).unshift(e)}))}else{var l=I("COL20",{name:E[(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.T)((e=>e._data._deleted)))},get deleted$$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().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,dt.p)((e=>!e.isLocal)),(0,dt.p)((e=>e.documentId===this.primary)),(0,ut.T)((e=>vt(e))),(0,ht.Z)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ut.T)((e=>this.collection._docCache.getCachedRxDocument(e))),(0,pt.t)(le.bz))},get $$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},get$(e){if(k.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.T)((t=>y(t,e))),(0,mt.F)())},get$$(e){var t=this.get$(e);return this.collection.database.getReactivityFactory().fromObservable(t,this.getLatest().get(e))},populate(e){var t=M(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.$A;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 k.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(a.endsWith("$$")){var i=a.slice(0,-2);return r.get$$(A(e+"."+i))}if("$"===n){var s=a.slice(0,-1);return r.get$(A(e+"."+s))}if("_"===n){var o=a.slice(0,-1);return r.populate(A(e+"."+o))}return r.get(A(e+"."+a))}})}))},toJSON(e){if(void 0===e&&(e=!1),e)return k.deepFreezeWhenDevMode(this._data);var t=s(this._data);return delete t._rev,delete t._attachments,delete t._deleted,delete t._meta,k.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 kt(this.collection,e,t);var r=await this.collection.storageInstance.bulkWrite([{previous:t,document:e}],"rx-document-save-data"),a=r.error[0];return Qe(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 Qe(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 kt(e,t,r){return t._meta=Object.assign({},r._meta,t._meta),k.isDevMode()&&e.schema.validateChange(r,t),e._runHooks("pre","save",t,r)}var jt=r(2198),Dt=r(511),_t=r(4157),It=r(2442),Rt=r(6114);function St(e,t){return t.sort&&0!==t.sort.length?t.sort.map((e=>Object.keys(e)[0])):[e]}var Et=new WeakMap;function Ct(e,t){if(!e.collection.database.eventReduce)return{runFullQueryAgain:!0};var r=function(e){return i(Et,e,(()=>{var t=e.collection,r=Se(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=Ee(t.schema.jsonSchema,r),i=Ce(t.schema.jsonSchema,r);return{primaryKey:e.collection.schema.primaryPath,skip:r.skip,limit:r.limit,sortFields:St(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.ZN)(e._result).docsData.slice(0),n=(0,le.ZN)(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:k.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.kC)(t);return"runFullQueryAgain"===i||("doNothing"!==i?(s=!0,(0,Rt.Cs)(i,r,e,a,n),!1):void 0)}))?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:s,newResults:a}}var Pt=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 At,$t,Bt=(At=100,$t=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 Tt=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.A)(e,[{key:"getCachedRxDocument",get:function(){return l(this,"getCachedRxDocument",function(e){var t=e.primaryPath,r=e.cacheItemByDocId,a=e.registry,n=k.deepFreezeWhenDevMode,s=e.documentCreator,o=o=>{var c=o[t],l=Be(o._rev),u=i(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),d=u.byRev,h=d.get(l),m=h?h.deref():void 0;return m||(o=n(o),m=s(o),d.set(l,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,ft.vN)().then((()=>{e.registerIdlePromise=void 0;var t=e.registerIdleTasks;0!==t.length&&(e.registerIdleTasks=[],t.forEach((e=>{a.register(e,{docId:e.primary,revisionHeight:Be(e.revision)})})))}))))),m};return o}(this))}}]),e}();function qt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Ft=function(){function e(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=qt(this.collection._docCache,t)}return(0,b.A)(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 Ft(this.collection,e,e.length);this._result=t}else this._result=new Ft(this.collection,[],e)},t._execOverDatabase=async function(){if(this._execOverDatabaseCount=this._execOverDatabaseCount+1,this._lastExecStart=(0,ce.t)(),"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.ZN)(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.Hb)(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.t)(),e)))},t.exec=function(e){if(e&&"findOne"!==this.op)throw I("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Kt(this).then((()=>(0,Dt._)(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:Se(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=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 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.A)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,dt.p)((e=>!e.isLocal)),(0,ht.Z)(null),(0,It.Z)((()=>Kt(this))),(0,ut.T)((()=>this._result)),(0,pt.t)(le.bz),(0,mt.F)(((e,t)=>!(!e||e.time!==(0,le.ZN)(t).time))),(0,dt.p)((e=>!!e)),(0,ut.T)((e=>{var t=(0,le.ZN)(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.h)(e,this.refCount$.pipe((0,dt.p)((()=>!1))))}return this._$}},{key:"$$",get:function(){return this.collection.database.getReactivityFactory().fromObservable(this.$,void 0)}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return l(this,"queryMatcher",Ce(0,Se(this.collection.schema.jsonSchema,this.mangoQuery)))}},{key:"asRxQuery",get:function(){return this}}]),e}();function Ht(e,t,r,a){st("preCreateRxQuery",{op:e,queryObj:t,collection:r,other:a});var n,i,s=new Wt(e,t,r,a);return s=(n=s).collection._queryCache.getByQuery(n),i=r,Mt.has(i)||(Mt.add(i),(0,ft.dY)().then((()=>(0,ft.Ve)(200))).then((()=>{i.destroyed||i.cacheReplacementPolicy(i,i._queryCache),Mt.delete(i)}))),s}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.Dr:(e._ensureEqualQueue=e._ensureEqualQueue.then((()=>function(e){if(e._lastEnsureEqual=(0,ce.t)(),e.collection.database.destroyed||zt(e))return ft.Dr;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.ZN)(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=Ct(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:k.isDevMode()});await s.remove(),t.isCollection&&await ot("postRemoveRxCollection",{storage:e,databaseName:a,collectionName:n})}))),s){var u=o.map((e=>{var t=ze(e);return t._deleted=!0,t._meta.lwt=(0,ce.t)(),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,dt.p)((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,k.deepFreezeWhenDevMode(t));return e._runHooksSync("post","create",t,r),st("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"],dr=!1,hr=function(){function e(e,t,r,a,n,i,s,o,c,l,u,d){void 0===n&&(n={}),void 0===i&&(i={}),void 0===s&&(s={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===l&&(l=Bt),void 0===u&&(u={}),void 0===d&&(d=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 Pt,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=d,function(e){if(dr)return;dr=!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=Ke(this.database,this.internalStorageInstance,this.schema.jsonSchema),this.incrementalWriteQueue=new gt(this.storageInstance,this.schema.primaryPath,((e,t)=>kt(this,e,t)),(e=>this._runHooks("post","save",e)));var e,t=this.database.eventBulks$.pipe((0,dt.p)((e=>e.collectionName===this.name)));this.$=t.pipe((0,It.Z)((e=>e.events))),this.checkpoint$=t.pipe((0,ut.T)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Tt(this.schema.primaryPath,this.$.pipe((0,dt.p)((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=>Fe(!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.em},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 Qe(this,e[this.schema.primaryPath],e,r),(0,le.ZN)(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=qt(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.ZN)(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 Qe(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.em),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:{}}),Ht("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=Ht("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=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 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.em;var i=n.series.map((e=>()=>e(r,a)));return(0,ft.h$)(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.Dr:(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.A)(e,[{key:"insert$",get:function(){return this.$.pipe((0,dt.p)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,dt.p)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,dt.p)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}]),e}();var mr=r(7635),pr=r(1007);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.sc)(e))},yr=r(5525),vr=new Set,gr=function(){function e(e,t,r,a,n,i,s,o,c,l,u,d,h){void 0===s&&(s=!1),void 0===o&&(o={}),this.idleQueue=new mr.G,this.rxdbVersion=rt,this.storageInstances=new Set,this._subs=[],this.startupErrors=[],this.onDestroy=[],this.destroyed=!1,this.collections={},this.eventBulks$=new oe.B,this.observable$=this.eventBulks$.pipe((0,It.Z)((e=>e.events))),this.storageToken=ft.Dr,this.storageTokenDocument=ft.Dr,this.emittedEventBulkIds=new yr.p4(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=d,this.reactivity=h,"pseudoInstance"!==this.name&&(this.internalStore=Ke(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:B(),_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.ZN)(n.error[0]);if(i.isError&&S(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.ZN)(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.getReactivityFactory=function(){if(!this.reactivity)throw I("DB14",{database:this.name});return this.reactivity},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 qe(this.internalStore,Gt(tr(e,t),Zt));if(!r)throw I("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[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 d=tr(i,l),h={id:Gt(d,Zt),key:d,context:Zt,data:{name:c,schemaHash:await u.hash,schema:u.jsonSchema,version:u.version,connectedStorages:[]},_deleted:!1,_meta:B(),_rev:"",_attachments:{}};a.push({document:h});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.ZN)(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.ZN)(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:d=!1,cacheReplacementPolicy:h=Bt,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:k.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 hr(t,r,a,e,n,i,c,l,u,h,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.em;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:h,localDocuments:d,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.Dr:(this.destroyed=!0,await ot("preDestroyRxDatabase",this),this.eventBulks$.complete(),this._subs.map((e=>e.unsubscribe())),"pseudoInstance"===this.name?ft.Dr: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.storage.name+"|"+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.A)(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:Te,schema:Jt,options:a,multiInstance:n,password:i,devMode:k.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:d=!1,hashFunction:h=fr,reactivity:m}=e;st("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:d}),o||function(e,t){var r=t.name+"|"+e;if(vr.has(r))throw I("DB8",{name:e,storage:t.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}(a,t),vr.add(t.name+"|"+a);var p=O(10);return br(p,t,a,r,i,n).catch((e=>{throw vr.delete(t.name+"|"+a),e})).then((e=>{var f=new gr(a,p,t,r,n,i,s,c,e,h,l,u,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:d}}).then((()=>f))}))}var wr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Wt.prototype,RxCollection:hr.prototype,RxDatabase:gr.prototype},kr=new Set,jr=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.A)(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(Cr,this.parent);return this.parent.$.pipe((0,dt.p)((e=>e.documentId===this.primary)),(0,dt.p)((e=>e.isLocal)),(0,ut.T)((e=>vt(e))),(0,ht.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ut.T)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.t)(le.bz))},get $$(){var e=this;return Sr(e).getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},get deleted$$(){var e=this;return Sr(e).getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted)},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 R("LD2",{objPath:e});var t=y(this._data,e);return t=k.deepFreezeWhenDevMode(t)}},get$(e){if(e="data."+e,k.isDevMode()){if(e.includes(".item."))throw I("LD3",{objPath:e});if(e===this.primaryPath)throw I("LD4")}return this.$.pipe((0,ut.T)((e=>e._data)),(0,ut.T)((t=>y(t,e))),(0,mt.F)())},get$$(e){return Sr(this).getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e))},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=s(e))._rev=r._rev}))},async remove(){var e=await Or(this.parent),t={id:this._data.id,data:{},_deleted:!0,_meta:B(),_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)))}};function Sr(e){var t=e.parent;return t instanceof gr?t:t.database}var Er=new WeakMap,Cr=new WeakMap;function Pr(e){var t=e.database?e.database:e,r=e.database?e.name:"",a=(async()=>{var a=await Nr(t.token,t.storage,t.name,r,t.instanceCreationOptions,t.multiInstance);a=Ke(t,a,Mr);var n=new Tt("id",e.$.pipe((0,dt.p)((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=>Fe(!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 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 I("LD8",{database:r.name,collection:a})}return t}function Nr(e,t,r,a,n,i){return t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:Br(a),schema:Mr,options:n,multiInstance:i,devMode:k.isDevMode()})}function Ar(e){var t=Er.get(e);if(t)return Er.delete(e),t.then((e=>e.storageInstance.close()))}async function $r(e,t,r){var a=O(10),n=await Nr(a,e,t,r,{},!1);await n.remove()}function Br(e){return"plugin-local-documents-"+e}var Mr=F({title:"RxLocalDocument",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:128},data:{type:"object",additionalProperties:!0}},required:["id","data"]});async function Tr(e,t){var r=await Or(this),a={id:e,data:t,_deleted:!1,_meta:B(),_rev:"",_attachments:{}};return Le(r.storageInstance,{document:a},"local-document-insert").then((e=>r.docCache.getCachedRxDocument(e)))}function qr(e,t){return this.getLocal(e).then((r=>r?r.incrementalModify((()=>t)):this.insertLocal(e,t)))}async function Lr(e){var t=await Or(this),r=t.docCache,a=r.getLatestDocumentDataIfExists(e);return a?Promise.resolve(r.getCachedRxDocument(a)):qe(t.storageInstance,e).then((e=>e?t.docCache.getCachedRxDocument(e):null))}function Fr(e){return this.$.pipe((0,ht.Z)(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,dt.p)((e=>e.use)),(0,ut.T)((e=>e.doc)))}var Qr={name:"local-documents",rxdb:!0,prototypes:{RxCollection:e=>{e.insertLocal=Tr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Fr},RxDatabase:e=>{e.insertLocal=Tr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Fr}},hooks:{createRxDatabase:{before:e=>{e.creator.localDocuments&&Pr(e.database)}},createRxCollection:{before:e=>{e.creator.localDocuments&&Pr(e.collection)}},preDestroyRxDatabase:{after:e=>Ar(e)},postDestroyRxCollection:{after:e=>Ar(e)},postRemoveRxDatabase:{after:e=>$r(e.storage,e.databaseName,"")},postRemoveRxCollection:{after:e=>$r(e.storage,e.databaseName,e.collectionName)}},overwritable:{}};let Wr;function Hr(){return"undefined"!=typeof window&&window.indexedDB}function zr(){return Wr||(Wr=(async()=>{!function(e){if(st("preAddRxPlugin",{plugin:e,plugins:kr}),!kr.has(e)){if(jr.has(e.name))throw I("PL3",{name:e.name,plugin:e});if(kr.add(e),jr.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(k,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)}))}}(Qr);var e;return await xr({name:"rxdb-landing-v3",localDocuments:!0,storage:(void 0===e&&(e={}),new at(e))})})()),Wr}const Kr=["#e6008d","#8d2089","#5f2688"]},1527:(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,{h:()=>a})},5607:(e,t,r)=>{r.r(t),r.d(t,{FORM_VALUE_DOCUMENT_ID:()=>v,default:()=>g});var a=r(4586),n=r(1595),i=r(5260),s=r(6540),o=r(3337),c=r(7810);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:35420},{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},d=.05;var h=r(1527),m=r(2658),p=r(2303),f=r(4848);function y(e){let{children:t,fallback:r}=e;return(0,p.A)()?(0,f.jsx)(f.Fragment,{children:t?.()}):r??null}const v="premium-price-form-value";function g(){const{siteConfig:e}=(0,a.A)(),t=(0,p.A)();return(0,s.useEffect)((()=>{t&&window.trigger("open_pricing_page",1),(async()=>{if(!t||!(0,m.IA)())return;const e=await(0,m.C3)(),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)})),document.getElementById("price-calculator-submit").click())})()})),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(i.A,{children:(0,f.jsx)("body",{className:"homepage"})}),(0,f.jsx)(n.A,{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:[(0,f.jsx)("b",{className:"underline",children:"RxDB"})," Premium Plugins"]}),(0,f.jsxs)("p",{style:{width:"80%"},children:["RxDB's premium plugins offer advanced features and optimizations that enhance application ",(0,f.jsx)("b",{children:"performance"})," ","and are backed by dedicated support and regular updates. Using the premium plugins is recommended for users that use RxDB in a professional context."]}),(0,f.jsxs)("div",{className:"premium-blocks",children:[(0,f.jsx)("a",{href:"/rx-storage-indexeddb.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 IndexedDB"}),(0,f.jsxs)("p",{children:["A storage for browsers based on ",(0,f.jsx)("b",{children:"IndexedDB"}),". Has the best latency on writes and smallest build size."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-opfs.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 OPFS"}),(0,f.jsxs)("p",{children:["Currently the RxStorage with best data throughput that can be used in the browser. Based on the ",(0,f.jsx)("b",{children:"OPFS File System Access API"}),"."]})]})})}),(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 fast storage based on ",(0,f.jsx)("b",{children:"SQLite"})," for Servers and Hybrid Apps. Can be 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-shared-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 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:"/rx-storage-sharding.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 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:"/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?"}),"RxDB Core is open source and many 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 you can consider using the premium plugins as an easy way to improve your applications performance and reduce the build size.",(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:"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 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 2 years access to the Premium Plugins."]}),(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 from your users to any RxDB server."]})]})}),(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.jsx)("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",placeholder:"Company Home Country"}),(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.jsx)("br",{}),(0,f.jsx)("div",{className:"clear"}),(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.ZN)(event);return 69!==e.keyCode&&189!==e.keyCode&&190!==e.keyCode},placeholder:"Company Size"}),(0,f.jsx)("div",{className:"suffix",children:"employee(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)("div",{className:"clear"})]}),(0,f.jsx)("div",{className:"button",id:"price-calculator-submit",onClick:async()=>{(0,h.h)("calculate_premium_price",3);const e=(0,o.ZN)(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.dG)(t.split("-"))})),i={companySize:parseInt(r["company-size"],10),teamSize:r["developer-count"],projectAmount:"1",licensePeriod:1,homeCountryCode:a.code,packages:n},s=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.ZN)(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*=.8),e.packages.length>2&&(a*=.7),e.companySize>1){let t=1+Math.pow(1*e.companySize-1,.85)/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;a1200?100*Math.floor(a/100):50*Math.floor(a/50),{totalPrice:a}}(i);console.log("priceResult:"),console.log(JSON.stringify(s,null,4));const p=(0,o.ZN)(document.getElementById("price-calculator-result")),f=(0,o.ZN)(document.getElementById("total-per-project-per-month")),y=(e,t)=>{console.log("setPrice:"),console.dir(t),e.innerHTML=Math.ceil(t).toString()},g=s.totalPrice/i.licensePeriod;y(f,"infinity"!==i.projectAmount?g/parseInt(i.projectAmount,10)/12:0);const b=await(0,m.C3)();await b.upsertLocal(v,{companySize:r["company-size"],projectAmount:r["project-amount"],licensePeriod:r["license-period"],homeCountry:a.name,packages:n,price:s.totalPrice,formSubmitted:!1}),p.style.display="block"},children:"Estimate Price"})]})})}),(0,f.jsx)("div",{className:"price-calculator",style:{marginBottom:90},children:(0,f.jsxs)("div",{className:"price-calculator-inner",id:"price-calculator-result",style:{display:"none"},children:[(0,f.jsx)("h4",{children:"Estimated Price:"}),(0,f.jsx)("br",{}),(0,f.jsxs)("div",{className:"inner",children:[(0,f.jsx)("span",{className:"price-label",children:"\u20ac"}),(0,f.jsx)("span",{id:"total-per-project-per-month",children:"84"}),(0,f.jsx)("span",{className:"per-month",children:"/month"}),(0,f.jsx)("span",{className:"clear"})]}),(0,f.jsx)("br",{}),(0,f.jsx)("br",{}),(0,f.jsxs)("div",{className:"proceed-hint",children:["Fill out the ",(0,f.jsx)("b",{children:"form below \u2193"})," 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/c5cAfYVe373ccihUfJkyxdU2zg5Iz2liQB09nU6jOQCyRXOJy6W7qPdQdmomvugRj5",children:["Your browser doesn't support iframes, ",(0,f.jsx)("a",{href:"https://webforms.pipedrive.com/f/c5cAfYVe373ccihUfJkyxdU2zg5Iz2liQB09nU6jOQCyRXOJy6W7qPdQdmomvugRj5",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)}},7810:(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;an,Hb:()=>c,S7:()=>s,Sd:()=>o,dG:()=>a,jw:()=>l,k_:()=>i})},3337:(e,t,r)=>{function a(e,t){if(!e)throw t||(t=""),new Error("ensureNotFalsy() is falsy: "+t);return e}r.d(t,{ZN:()=>a,bz:()=>n});var n={bufferSize:1,refCount:!0}},1753:(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,{$A:()=>s,Dr:()=>i,ND:()=>n,Ve:()=>u,dY:()=>a,em:()=>o,h$:()=>d,vN:()=>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 d(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},5734:(e,t,r)=>{r.d(t,{t:()=>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/0e268d20.f1ff5a10.js b/docs/assets/js/0e268d20.f1ff5a10.js deleted file mode 100644 index 3953943e20c..00000000000 --- a/docs/assets/js/0e268d20.f1ff5a10.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[2584],{2658:(e,t,r)=>{r.d(t,{Tj:()=>Kr,C3:()=>zr,IA:()=>Hr});var a=r(7329);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)},d=new Set(["__proto__","prototype","constructor"]),h=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(d.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(d.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&&!h.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(d.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 j(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=j(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.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),t}((0,w.A)(Error)),_=function(e){function t(t,r,a){var n;void 0===a&&(a={});var i=j(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.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),t}((0,w.A)(TypeError));function I(e,t){return new D(e,k.tunnelErrorMessage(e),t)}function R(e,t){return new _(e,k.tunnelErrorMessage(e),t)}function S(e){return!(!e||409!==e.status)&&e}var E={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var C=/\./g,P="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 F(e){var t=q((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=Q,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=W(e);(0,g.Hb)(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.k_)(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 Q={type:"object",properties:{lwt:{type:"number",minimum:$,maximum:1e15,multipleOf:.01}},additionalProperties:!0,required:["lwt"]};function W(e){var t=Object.keys(e.properties).filter((t=>e.properties[t].final)),r=q(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,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=q(e.primaryKey);t.push([r]),t.push(["_deleted",r]),e.indexes&&e.indexes.forEach((e=>{var r=(0,g.$r)(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.$r)(a).forEach((a=>{t.has(a)||(t.add(a),"boolean"===M(e,a).type&&r.push(a))}))})),r.push("_deleted"),(0,g.jw)(r)):r}var oe=r(9092),ce=r(5734),le=r(3337),ue=String.fromCharCode(65535),de=Number.MIN_SAFE_INTEGER;function he(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?de:ue,endKey:a?ue:de,inclusiveStart:!0,inclusiveEnd:!0};return void 0===i.startKey&&(i.startKey=de),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})),d=u.map((e=>e.startKey)),h=u.map((e=>e.endKey)),m={index:e,startKeys:d,endKeys:h,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!i.has(e))).join(","),selectorSatisfiedByIndex:ye(e,t.selector,d,h)},p=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},i=10,s=(0,g.Sd)(r.startKeys,(e=>e!==de&&e!==ue));n(s*i);var o=(0,g.Sd)(r.startKeys,(e=>e!==ue&&e!==de));n(o*i);var c=(0,g.Sd)(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 d=[],h=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&&h.add(m),"$eq"!==y){if(d.length>0)return!1;d.push(y)}}var v=0;for(var g of e){for(var b of[s,h]){if(!b.has(g)&&b.size>0)return!1;b.delete(g)}if(r[v]!==a[v]&&s.size>0&&h.size>0)return!1;v++}return!0}var ve=r(744),ge=r(2779),be=r(1692),xe=r(4903),we=r(7705),ke=r(2403),je=r(6776),De=r(6950),_e=r(6823),Ie=!1;function Re(e){return Ie||((0,ge.DZ)(ge.hu.PIPELINE,{$sort:xe.xF,$project:xe.C2}),(0,ge.DZ)(ge.hu.QUERY,{$and:we.a6,$eq:ke.XV,$elemMatch:De.Jy,$exists:_e.P,$gt:ke.MR,$gte:ke.fy,$in:ke.oZ,$lt:ke.NV,$lte:ke.Q_,$ne:ke.C5,$nin:ke.GU,$mod:je.Pp,$nor:we.q3,$not:we.En,$or:we.sU,$regex:je.WP,$size:De.Ig,$type:_e.T}),Ie=!0),new be.X(e)}function Se(e,t){var r=q(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.$r)(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.k_)(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 Ee(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 Pe(e){return e===de?-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(Pe),n=t.endKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Pe);return r.bound(a,n,!t.inclusiveStart,!t.inclusiveEnd)}async function Ae(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=Ce(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(H);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 d=Ee(e.schema,t.query);u=u.sort(d)}return{documents:u=u.slice(n,i)}}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 Be(e){return parseInt(e.split("-")[0],10)}function Me(e,t){var r=t?t._rev:null;return(r?$e(r).height:0)+1+"-"+e}var Te="_rxdb_internal";async function qe(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 Fe(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:k.deepFreezeWhenDevMode(a),previousDocumentData:k.deepFreezeWhenDevMode(n)}}function Qe(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 We(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=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 ze(e){var t=s(e);return t._meta=s(e._meta),t}function Ke(e,t,r){k.deepFreezeWhenDevMode(r);var a=q(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),k.isDevMode()){i=T(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.t)(),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.ZN)(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.Hb)(a.error,e.error),(0,g.Hb)(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.ZN)(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:B(),_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(3561),Ze=r(703),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.X2(["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.B,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,Ue.X)(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 d=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),d()}}}var Ye=(0,ce.t)(),Xe=function(){function e(e,t,r,a,n,i,s){this.changes$=new oe.B,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=q(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=[],d=[],h={id:O(10),events:[],checkpoint:null,context:n,startTime:(0,ce.t)(),endTime:0},m=h.events,p=[],f=[],y=[],v=r.size>0,g=a.length,b=function(){var e,n=a[x],h=n.document,g=n.previous,b=h[t],w=h._deleted,k=g&&g._deleted,j=void 0;if(v&&(j=r.get(b)),j){var D=j._rev;if(!g||g&&D!==g._rev){var _={isError:!0,status:409,documentId:b,writeRow:n,documentInDb:j};return d.push(_),1}var R=c?We(n):n;c&&(w?g&&Object.keys(g._attachments).forEach((e=>{f.push({documentId:b,attachmentId:e,digest:(0,le.ZN)(g)._attachments[e].digest})})):(Object.entries(h._attachments).find((t=>{let[r,a]=t;return(g?g._attachments[r]:void 0)||a.data||(e={documentId:b,documentInDb:j,isError:!0,status:510,writeRow:n,attachmentId:r}),!0})),e||Object.entries(h._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?d.push(e):(c?(u.push(We(R)),s&&s(h)):(u.push(R),s&&s(h)),o=R);var S=null,E=null,C=null;if(k&&!w)C="INSERT",S=c?He(h):h;else if(!g||k||w){if(!w)throw I("SNH",{args:{writeRow:n}});C="DELETE",S=(0,le.ZN)(h),E=g}else C="UPDATE",S=c?He(h):h,E=g;var P={documentId:b,documentData:S,previousDocumentData:E,operation:C};m.push(P)}else{var O=!!w;if(c&&Object.entries(h._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},d.push(e))})),e||(c?(l.push(We(n)),i&&i(h)):(l.push(n),i&&i(h)),o=n),!O){var N={documentId:b,operation:"INSERT",documentData:c?He(h):h,previousDocumentData:c&&g?He(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.ZN)(r)).eventBulk.events.length>0){var s=(0,le.ZN)(r.newestRow).document;r.eventBulk.checkpoint={id:s[this.primaryPath],lwt:s._meta.lwt},r.eventBulk.endTime=(0,ce.t)(),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),Ae(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(H);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 Ae(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.t)()-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.B},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.cf(o,e),i={[H]:ae(n),[z]:"++sequence, id",[K]:"id"};return t.version(1).stores(i),await t.open(),{dexieDb:t,dexieTable:t[H],dexieAttachmentsTable:t[K],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(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.9.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 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.k_)(e)?e:[e]))}(this.jsonSchema),this.primaryPath=q(this.jsonSchema.primaryKey),this.finalFields=W(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.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.A)(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=F(e);a=function(e){return o(e,!0)}(a),k.deepFreezeWhenDevMode(a);var n=new ct(a,t);return st("createRxSchema",n),n}var ut=r(7708),dt=r(8146),ht=r(3356),mt=r(5520),pt=r(8609),ft=r(1753);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.ZN)(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=$e(i._rev).height,n.forEach((e=>{var t=$e(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(d){u.reject(d),u.reject=()=>{},u.resolve=()=>{}}try{await this.preWrite(l,o)}catch(d){return void a.forEach((e=>e.reject(d)))}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=S(e);if(o){var c=i(this.queueByDocId,a,(()=>[]));s.reverse().forEach((e=>{e.lastKnownDocumentState=(0,le.ZN)(o.documentInDb),(0,le.ZN)(c).unshift(e)}))}else{var l=I("COL20",{name:E[(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.T)((e=>e._data._deleted)))},get deleted$$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().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,dt.p)((e=>!e.isLocal)),(0,dt.p)((e=>e.documentId===this.primary)),(0,ut.T)((e=>vt(e))),(0,ht.Z)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ut.T)((e=>this.collection._docCache.getCachedRxDocument(e))),(0,pt.t)(le.bz))},get $$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},get$(e){if(k.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.T)((t=>y(t,e))),(0,mt.F)())},get$$(e){var t=this.get$(e);return this.collection.database.getReactivityFactory().fromObservable(t,this.getLatest().get(e))},populate(e){var t=M(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.$A;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 k.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(a.endsWith("$$")){var i=a.slice(0,-2);return r.get$$(A(e+"."+i))}if("$"===n){var s=a.slice(0,-1);return r.get$(A(e+"."+s))}if("_"===n){var o=a.slice(0,-1);return r.populate(A(e+"."+o))}return r.get(A(e+"."+a))}})}))},toJSON(e){if(void 0===e&&(e=!1),e)return k.deepFreezeWhenDevMode(this._data);var t=s(this._data);return delete t._rev,delete t._attachments,delete t._deleted,delete t._meta,k.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 kt(this.collection,e,t);var r=await this.collection.storageInstance.bulkWrite([{previous:t,document:e}],"rx-document-save-data"),a=r.error[0];return Qe(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 Qe(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 kt(e,t,r){return t._meta=Object.assign({},r._meta,t._meta),k.isDevMode()&&e.schema.validateChange(r,t),e._runHooks("pre","save",t,r)}var jt=r(2198),Dt=r(511),_t=r(4157),It=r(2442),Rt=r(6114);function St(e,t){return t.sort&&0!==t.sort.length?t.sort.map((e=>Object.keys(e)[0])):[e]}var Et=new WeakMap;function Ct(e,t){if(!e.collection.database.eventReduce)return{runFullQueryAgain:!0};var r=function(e){return i(Et,e,(()=>{var t=e.collection,r=Se(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=Ee(t.schema.jsonSchema,r),i=Ce(t.schema.jsonSchema,r);return{primaryKey:e.collection.schema.primaryPath,skip:r.skip,limit:r.limit,sortFields:St(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.ZN)(e._result).docsData.slice(0),n=(0,le.ZN)(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:k.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.kC)(t);return"runFullQueryAgain"===i||("doNothing"!==i?(s=!0,(0,Rt.Cs)(i,r,e,a,n),!1):void 0)}))?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:s,newResults:a}}var Pt=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 At,$t,Bt=(At=100,$t=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 Tt=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.A)(e,[{key:"getCachedRxDocument",get:function(){return l(this,"getCachedRxDocument",function(e){var t=e.primaryPath,r=e.cacheItemByDocId,a=e.registry,n=k.deepFreezeWhenDevMode,s=e.documentCreator,o=o=>{var c=o[t],l=Be(o._rev),u=i(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),d=u.byRev,h=d.get(l),m=h?h.deref():void 0;return m||(o=n(o),m=s(o),d.set(l,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,ft.vN)().then((()=>{e.registerIdlePromise=void 0;var t=e.registerIdleTasks;0!==t.length&&(e.registerIdleTasks=[],t.forEach((e=>{a.register(e,{docId:e.primary,revisionHeight:Be(e.revision)})})))}))))),m};return o}(this))}}]),e}();function qt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Ft=function(){function e(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=qt(this.collection._docCache,t)}return(0,b.A)(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 Ft(this.collection,e,e.length);this._result=t}else this._result=new Ft(this.collection,[],e)},t._execOverDatabase=async function(){if(this._execOverDatabaseCount=this._execOverDatabaseCount+1,this._lastExecStart=(0,ce.t)(),"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.ZN)(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.Hb)(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.t)(),e)))},t.exec=function(e){if(e&&"findOne"!==this.op)throw I("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Kt(this).then((()=>(0,Dt._)(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:Se(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=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 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.A)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,dt.p)((e=>!e.isLocal)),(0,ht.Z)(null),(0,It.Z)((()=>Kt(this))),(0,ut.T)((()=>this._result)),(0,pt.t)(le.bz),(0,mt.F)(((e,t)=>!(!e||e.time!==(0,le.ZN)(t).time))),(0,dt.p)((e=>!!e)),(0,ut.T)((e=>{var t=(0,le.ZN)(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.h)(e,this.refCount$.pipe((0,dt.p)((()=>!1))))}return this._$}},{key:"$$",get:function(){return this.collection.database.getReactivityFactory().fromObservable(this.$,void 0)}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return l(this,"queryMatcher",Ce(0,Se(this.collection.schema.jsonSchema,this.mangoQuery)))}},{key:"asRxQuery",get:function(){return this}}]),e}();function Ht(e,t,r,a){st("preCreateRxQuery",{op:e,queryObj:t,collection:r,other:a});var n,i,s=new Wt(e,t,r,a);return s=(n=s).collection._queryCache.getByQuery(n),i=r,Mt.has(i)||(Mt.add(i),(0,ft.dY)().then((()=>(0,ft.Ve)(200))).then((()=>{i.destroyed||i.cacheReplacementPolicy(i,i._queryCache),Mt.delete(i)}))),s}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.Dr:(e._ensureEqualQueue=e._ensureEqualQueue.then((()=>function(e){if(e._lastEnsureEqual=(0,ce.t)(),e.collection.database.destroyed||zt(e))return ft.Dr;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.ZN)(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=Ct(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:k.isDevMode()});await s.remove(),t.isCollection&&await ot("postRemoveRxCollection",{storage:e,databaseName:a,collectionName:n})}))),s){var u=o.map((e=>{var t=ze(e);return t._deleted=!0,t._meta.lwt=(0,ce.t)(),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,dt.p)((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,k.deepFreezeWhenDevMode(t));return e._runHooksSync("post","create",t,r),st("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"],dr=!1,hr=function(){function e(e,t,r,a,n,i,s,o,c,l,u,d){void 0===n&&(n={}),void 0===i&&(i={}),void 0===s&&(s={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===l&&(l=Bt),void 0===u&&(u={}),void 0===d&&(d=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 Pt,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=d,function(e){if(dr)return;dr=!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=Ke(this.database,this.internalStorageInstance,this.schema.jsonSchema),this.incrementalWriteQueue=new gt(this.storageInstance,this.schema.primaryPath,((e,t)=>kt(this,e,t)),(e=>this._runHooks("post","save",e)));var e,t=this.database.eventBulks$.pipe((0,dt.p)((e=>e.collectionName===this.name)));this.$=t.pipe((0,It.Z)((e=>e.events))),this.checkpoint$=t.pipe((0,ut.T)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Tt(this.schema.primaryPath,this.$.pipe((0,dt.p)((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=>Fe(!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.em},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 Qe(this,e[this.schema.primaryPath],e,r),(0,le.ZN)(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=qt(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.ZN)(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 Qe(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.em),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:{}}),Ht("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=Ht("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=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 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.em;var i=n.series.map((e=>()=>e(r,a)));return(0,ft.h$)(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.Dr:(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.A)(e,[{key:"insert$",get:function(){return this.$.pipe((0,dt.p)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,dt.p)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,dt.p)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}]),e}();var mr=r(7635),pr=r(1007);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.sc)(e))},yr=r(5525),vr=new Set,gr=function(){function e(e,t,r,a,n,i,s,o,c,l,u,d,h){void 0===s&&(s=!1),void 0===o&&(o={}),this.idleQueue=new mr.G,this.rxdbVersion=rt,this.storageInstances=new Set,this._subs=[],this.startupErrors=[],this.onDestroy=[],this.destroyed=!1,this.collections={},this.eventBulks$=new oe.B,this.observable$=this.eventBulks$.pipe((0,It.Z)((e=>e.events))),this.storageToken=ft.Dr,this.storageTokenDocument=ft.Dr,this.emittedEventBulkIds=new yr.p4(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=d,this.reactivity=h,"pseudoInstance"!==this.name&&(this.internalStore=Ke(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:B(),_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.ZN)(n.error[0]);if(i.isError&&S(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.ZN)(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.getReactivityFactory=function(){if(!this.reactivity)throw I("DB14",{database:this.name});return this.reactivity},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 qe(this.internalStore,Gt(tr(e,t),Zt));if(!r)throw I("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[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 d=tr(i,l),h={id:Gt(d,Zt),key:d,context:Zt,data:{name:c,schemaHash:await u.hash,schema:u.jsonSchema,version:u.version,connectedStorages:[]},_deleted:!1,_meta:B(),_rev:"",_attachments:{}};a.push({document:h});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.ZN)(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.ZN)(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:d=!1,cacheReplacementPolicy:h=Bt,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:k.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 hr(t,r,a,e,n,i,c,l,u,h,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.em;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:h,localDocuments:d,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.Dr:(this.destroyed=!0,await ot("preDestroyRxDatabase",this),this.eventBulks$.complete(),this._subs.map((e=>e.unsubscribe())),"pseudoInstance"===this.name?ft.Dr: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.storage.name+"|"+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.A)(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:Te,schema:Jt,options:a,multiInstance:n,password:i,devMode:k.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:d=!1,hashFunction:h=fr,reactivity:m}=e;st("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:d}),o||function(e,t){var r=t.name+"|"+e;if(vr.has(r))throw I("DB8",{name:e,storage:t.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}(a,t),vr.add(t.name+"|"+a);var p=O(10);return br(p,t,a,r,i,n).catch((e=>{throw vr.delete(t.name+"|"+a),e})).then((e=>{var f=new gr(a,p,t,r,n,i,s,c,e,h,l,u,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:d}}).then((()=>f))}))}var wr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Wt.prototype,RxCollection:hr.prototype,RxDatabase:gr.prototype},kr=new Set,jr=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.A)(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(Cr,this.parent);return this.parent.$.pipe((0,dt.p)((e=>e.documentId===this.primary)),(0,dt.p)((e=>e.isLocal)),(0,ut.T)((e=>vt(e))),(0,ht.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ut.T)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.t)(le.bz))},get $$(){var e=this;return Sr(e).getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},get deleted$$(){var e=this;return Sr(e).getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted)},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 R("LD2",{objPath:e});var t=y(this._data,e);return t=k.deepFreezeWhenDevMode(t)}},get$(e){if(e="data."+e,k.isDevMode()){if(e.includes(".item."))throw I("LD3",{objPath:e});if(e===this.primaryPath)throw I("LD4")}return this.$.pipe((0,ut.T)((e=>e._data)),(0,ut.T)((t=>y(t,e))),(0,mt.F)())},get$$(e){return Sr(this).getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e))},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=s(e))._rev=r._rev}))},async remove(){var e=await Or(this.parent),t={id:this._data.id,data:{},_deleted:!0,_meta:B(),_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)))}};function Sr(e){var t=e.parent;return t instanceof gr?t:t.database}var Er=new WeakMap,Cr=new WeakMap;function Pr(e){var t=e.database?e.database:e,r=e.database?e.name:"",a=(async()=>{var a=await Nr(t.token,t.storage,t.name,r,t.instanceCreationOptions,t.multiInstance);a=Ke(t,a,Mr);var n=new Tt("id",e.$.pipe((0,dt.p)((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=>Fe(!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 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 I("LD8",{database:r.name,collection:a})}return t}function Nr(e,t,r,a,n,i){return t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:Br(a),schema:Mr,options:n,multiInstance:i,devMode:k.isDevMode()})}function Ar(e){var t=Er.get(e);if(t)return Er.delete(e),t.then((e=>e.storageInstance.close()))}async function $r(e,t,r){var a=O(10),n=await Nr(a,e,t,r,{},!1);await n.remove()}function Br(e){return"plugin-local-documents-"+e}var Mr=F({title:"RxLocalDocument",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:128},data:{type:"object",additionalProperties:!0}},required:["id","data"]});async function Tr(e,t){var r=await Or(this),a={id:e,data:t,_deleted:!1,_meta:B(),_rev:"",_attachments:{}};return Le(r.storageInstance,{document:a},"local-document-insert").then((e=>r.docCache.getCachedRxDocument(e)))}function qr(e,t){return this.getLocal(e).then((r=>r?r.incrementalModify((()=>t)):this.insertLocal(e,t)))}async function Lr(e){var t=await Or(this),r=t.docCache,a=r.getLatestDocumentDataIfExists(e);return a?Promise.resolve(r.getCachedRxDocument(a)):qe(t.storageInstance,e).then((e=>e?t.docCache.getCachedRxDocument(e):null))}function Fr(e){return this.$.pipe((0,ht.Z)(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,dt.p)((e=>e.use)),(0,ut.T)((e=>e.doc)))}var Qr={name:"local-documents",rxdb:!0,prototypes:{RxCollection:e=>{e.insertLocal=Tr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Fr},RxDatabase:e=>{e.insertLocal=Tr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Fr}},hooks:{createRxDatabase:{before:e=>{e.creator.localDocuments&&Pr(e.database)}},createRxCollection:{before:e=>{e.creator.localDocuments&&Pr(e.collection)}},preDestroyRxDatabase:{after:e=>Ar(e)},postDestroyRxCollection:{after:e=>Ar(e)},postRemoveRxDatabase:{after:e=>$r(e.storage,e.databaseName,"")},postRemoveRxCollection:{after:e=>$r(e.storage,e.databaseName,e.collectionName)}},overwritable:{}};let Wr;function Hr(){return"undefined"!=typeof window&&window.indexedDB}function zr(){return Wr||(Wr=(async()=>{!function(e){if(st("preAddRxPlugin",{plugin:e,plugins:kr}),!kr.has(e)){if(jr.has(e.name))throw I("PL3",{name:e.name,plugin:e});if(kr.add(e),jr.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(k,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)}))}}(Qr);var e;return await xr({name:"rxdb-landing-v3",localDocuments:!0,storage:(void 0===e&&(e={}),new at(e))})})()),Wr}const Kr=["#e6008d","#8d2089","#5f2688"]},1527:(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,{h:()=>a})},5607:(e,t,r)=>{r.r(t),r.d(t,{FORM_VALUE_DOCUMENT_ID:()=>v,default:()=>g});var a=r(4586),n=r(1595),i=r(5260),s=r(6540),o=r(3337),c=r(7810);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:35420},{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},d=.05;var h=r(1527),m=r(2658),p=r(2303),f=r(4848);function y(e){let{children:t,fallback:r}=e;return(0,p.A)()?(0,f.jsx)(f.Fragment,{children:t?.()}):r??null}const v="premium-price-form-value";function g(){const{siteConfig:e}=(0,a.A)(),t=(0,p.A)();return(0,s.useEffect)((()=>{t&&window.trigger("open_pricing_page",1),(async()=>{if(!t||!(0,m.IA)())return;const e=await(0,m.C3)(),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)})),document.getElementById("price-calculator-submit").click())})()})),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(i.A,{children:(0,f.jsx)("body",{className:"homepage"})}),(0,f.jsx)(n.A,{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:[(0,f.jsx)("b",{className:"underline",children:"RxDB"})," Premium Plugins"]}),(0,f.jsxs)("p",{style:{width:"80%"},children:["RxDB's premium plugins offer advanced features and optimizations that enhance application ",(0,f.jsx)("b",{children:"performance"})," ","and are backed by dedicated support and regular updates. Using the premium plugins is recommended for users that use RxDB in a professional context."]}),(0,f.jsxs)("div",{className:"premium-blocks",children:[(0,f.jsx)("a",{href:"/rx-storage-indexeddb.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 IndexedDB"}),(0,f.jsxs)("p",{children:["A storage for browsers based on ",(0,f.jsx)("b",{children:"IndexedDB"}),". Has the best latency on writes and smallest build size."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-opfs.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 OPFS"}),(0,f.jsxs)("p",{children:["Currently the RxStorage with best data throughput that can be used in the browser. Based on the ",(0,f.jsx)("b",{children:"OPFS File System Access API"}),"."]})]})})}),(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 fast storage based on ",(0,f.jsx)("b",{children:"SQLite"})," for Servers and Hybrid Apps. Can be 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-shared-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 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:"/rx-storage-sharding.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 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:"/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?"}),"RxDB Core is open source and many 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 you can consider using the premium plugins as an easy way to improve your applications performance and reduce the build size.",(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:"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 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 2 years access to the Premium Plugins."]}),(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 from your users to any RxDB server."]})]})}),(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.jsx)("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",placeholder:"Company Home Country"}),(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.jsx)("br",{}),(0,f.jsx)("div",{className:"clear"}),(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.ZN)(event);return 69!==e.keyCode&&189!==e.keyCode&&190!==e.keyCode},placeholder:"Company Size"}),(0,f.jsx)("div",{className:"suffix",children:"employee(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)("div",{className:"clear"})]}),(0,f.jsx)("div",{className:"button",id:"price-calculator-submit",onClick:async()=>{(0,h.h)("calculate_premium_price",3);const e=(0,o.ZN)(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.dG)(t.split("-"))})),i={companySize:parseInt(r["company-size"],10),teamSize:r["developer-count"],projectAmount:"1",licensePeriod:1,homeCountryCode:a.code,packages:n},s=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.ZN)(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*=.8),e.packages.length>2&&(a*=.7),e.companySize>1){let t=1+Math.pow(1*e.companySize-1,.85)/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;a1200?100*Math.floor(a/100):50*Math.floor(a/50),{totalPrice:a}}(i);console.log("priceResult:"),console.log(JSON.stringify(s,null,4));const p=(0,o.ZN)(document.getElementById("price-calculator-result")),f=(0,o.ZN)(document.getElementById("total-per-project-per-month")),y=(e,t)=>{console.log("setPrice:"),console.dir(t),e.innerHTML=Math.ceil(t).toString()},g=s.totalPrice/i.licensePeriod;y(f,"infinity"!==i.projectAmount?g/parseInt(i.projectAmount,10)/12:0);const b=await(0,m.C3)();await b.upsertLocal(v,{companySize:r["company-size"],projectAmount:r["project-amount"],licensePeriod:r["license-period"],homeCountry:a.name,packages:n,price:s.totalPrice,formSubmitted:!1}),p.style.display="block"},children:"Estimate Price"})]})})}),(0,f.jsx)("div",{className:"price-calculator",style:{marginBottom:90},children:(0,f.jsxs)("div",{className:"price-calculator-inner",id:"price-calculator-result",style:{display:"none"},children:[(0,f.jsx)("h4",{children:"Estimated Price:"}),(0,f.jsx)("br",{}),(0,f.jsxs)("div",{className:"inner",children:[(0,f.jsx)("span",{className:"price-label",children:"\u20ac"}),(0,f.jsx)("span",{id:"total-per-project-per-month",children:"84"}),(0,f.jsx)("span",{className:"per-month",children:"/month"}),(0,f.jsx)("span",{className:"clear"})]}),(0,f.jsx)("br",{}),(0,f.jsx)("br",{}),(0,f.jsxs)("div",{className:"proceed-hint",children:["Fill out the ",(0,f.jsx)("b",{children:"form below \u2193"})," 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/c5cAfYVe373ccihUfJkyxdU2zg5Iz2liQB09nU6jOQCyRXOJy6W7qPdQdmomvugRj5",children:["Your browser doesn't support iframes, ",(0,f.jsx)("a",{href:"https://webforms.pipedrive.com/f/c5cAfYVe373ccihUfJkyxdU2zg5Iz2liQB09nU6jOQCyRXOJy6W7qPdQdmomvugRj5",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)}},7810:(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;an,Hb:()=>c,S7:()=>s,Sd:()=>o,dG:()=>a,jw:()=>l,k_:()=>i})},3337:(e,t,r)=>{function a(e,t){if(!e)throw t||(t=""),new Error("ensureNotFalsy() is falsy: "+t);return e}r.d(t,{ZN:()=>a,bz:()=>n});var n={bufferSize:1,refCount:!0}},1753:(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,{$A:()=>s,Dr:()=>i,ND:()=>n,Ve:()=>u,dY:()=>a,em:()=>o,h$:()=>d,vN:()=>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 d(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},5734:(e,t,r)=>{r.d(t,{t:()=>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/1b238727.8126c191.js b/docs/assets/js/1b238727.8126c191.js deleted file mode 100644 index 65f17315b80..00000000000 --- a/docs/assets/js/1b238727.8126c191.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[4013],{3721:(e,r,t)=>{t.r(r),t.d(r,{assets:()=>c,contentTitle:()=>a,default:()=>d,frontMatter:()=>s,metadata:()=>i,toc:()=>l});var n=t(4848),o=t(8453);const s={title:"\ud83d\udcc8 RxStorage Performance",slug:"rx-storage-performance.html"},a=void 0,i={id:"rx-storage-performance",title:"\ud83d\udcc8 RxStorage Performance",description:"RxStorage Performance comparison",source:"@site/docs/rx-storage-performance.md",sourceDirName:".",slug:"/rx-storage-performance.html",permalink:"/rx-storage-performance.html",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"\ud83d\udcc8 RxStorage Performance",slug:"rx-storage-performance.html"},sidebar:"tutorialSidebar",previous:{title:"\u2699\ufe0f Rxstorage Layer",permalink:"/rx-storage.html"},next:{title:"IndexedDB RxStorage \ud83d\udc51",permalink:"/rx-storage-indexeddb.html"}},c={},l=[{value:"RxStorage Performance comparison",id:"rxstorage-performance-comparison",level:2}];function m(e){const r={a:"a",h2:"h2",p:"p",strong:"strong",...(0,o.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.h2,{id:"rxstorage-performance-comparison",children:"RxStorage Performance comparison"}),"\n",(0,n.jsxs)(r.p,{children:["A big difference in the RxStorage implementations is the performance. In difference to a server side database, RxDB is bound to the limits of the JavaScript runtime. For example in the browser it is only possible to store data in a ",(0,n.jsx)(r.a,{href:"/slow-indexeddb.html",children:"slow IndexedDB"})," instead of a filesystem."]}),"\n",(0,n.jsxs)(r.p,{children:["Semi-persistend storages like ",(0,n.jsx)(r.a,{href:"/rx-storage-memory-synced.html",children:"Memory-Synced"})," and ",(0,n.jsx)(r.a,{href:"/rx-storage-lokijs.html",children:"LokiJS"})," store all data in memory and only saves to disc occasionally (or on exit). Therefore it has a very fast read/write performance, but loading all data into memory on the first page load can take longer for big amounts of documents. Also these storages can only be used when all data fits into the memory at least once."]}),"\n",(0,n.jsxs)(r.p,{children:["The \ud83d\udc51 Premium ",(0,n.jsx)(r.a,{href:"/rx-storage-sharding.html",children:"sharding RxStorage"})," is only useful when big amounts of documents have to be stored or queries. Small single-document reads and writes are likely slower with the sharding plugin in use."]}),"\n",(0,n.jsxs)(r.p,{children:["Many storages run lazy, so it makes no sense to compare the time which is required to create a database with collections. Instead we measure the ",(0,n.jsx)(r.strong,{children:"time-to-first-insert"})," which is the whole timespan from database creation until the first single document write is done."]}),"\n",(0,n.jsx)("p",{align:"center",children:(0,n.jsx)("img",{src:"./files/rx-storage-performance-browser.png",alt:"RxStorage performance - browser",width:"700"})}),"\n",(0,n.jsx)("p",{align:"center",children:(0,n.jsx)("img",{src:"./files/rx-storage-performance-node.png",alt:"RxStorage performance - Node.js",width:"700"})})]})}function d(e={}){const{wrapper:r}={...(0,o.R)(),...e.components};return r?(0,n.jsx)(r,{...e,children:(0,n.jsx)(m,{...e})}):m(e)}},8453:(e,r,t)=>{t.d(r,{R:()=>a,x:()=>i});var n=t(6540);const o={},s=n.createContext(o);function a(e){const r=n.useContext(s);return n.useMemo((function(){return"function"==typeof e?e(r):{...r,...e}}),[r,e])}function i(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:a(e.components),n.createElement(s.Provider,{value:r},e.children)}}}]); \ No newline at end of file diff --git a/docs/assets/js/1b238727.dfc4a389.js b/docs/assets/js/1b238727.dfc4a389.js new file mode 100644 index 00000000000..8648c927d29 --- /dev/null +++ b/docs/assets/js/1b238727.dfc4a389.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[4013],{3721:(e,r,s)=>{s.r(r),s.d(r,{assets:()=>d,contentTitle:()=>a,default:()=>m,frontMatter:()=>o,metadata:()=>i,toc:()=>c});var t=s(4848),n=s(8453);const o={title:"\ud83d\udcc8 RxStorage Performance",slug:"rx-storage-performance.html"},a=void 0,i={id:"rx-storage-performance",title:"\ud83d\udcc8 RxStorage Performance",description:"RxStorage Performance comparison",source:"@site/docs/rx-storage-performance.md",sourceDirName:".",slug:"/rx-storage-performance.html",permalink:"/rx-storage-performance.html",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"\ud83d\udcc8 RxStorage Performance",slug:"rx-storage-performance.html"},sidebar:"tutorialSidebar",previous:{title:"\u2699\ufe0f Rxstorage Layer",permalink:"/rx-storage.html"},next:{title:"IndexedDB RxStorage \ud83d\udc51",permalink:"/rx-storage-indexeddb.html"}},d={},c=[{value:"RxStorage Performance comparison",id:"rxstorage-performance-comparison",level:2},{value:"Persistend vs Semi-Persistend storages",id:"persistend-vs-semi-persistend-storages",level:2},{value:"Performance comparison",id:"performance-comparison",level:2},{value:"Measurements",id:"measurements",level:3},{value:"Browser based Storages Performance Comparison",id:"browser-based-storages-performance-comparison",level:2},{value:"Node/Native based Storages Performance Comparison",id:"nodenative-based-storages-performance-comparison",level:2}];function l(e){const r={a:"a",code:"code",h2:"h2",h3:"h3",li:"li",p:"p",strong:"strong",ul:"ul",...(0,n.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.h2,{id:"rxstorage-performance-comparison",children:"RxStorage Performance comparison"}),"\n",(0,t.jsxs)(r.p,{children:["A big difference in the RxStorage implementations is the ",(0,t.jsx)(r.strong,{children:"performance"}),". In difference to a server side database, RxDB is bound to the limits of the JavaScript runtime and depending on the runtime, there are different possibilities to store and fetch data. For example in the browser it is only possible to store data in a ",(0,t.jsx)(r.a,{href:"/slow-indexeddb.html",children:"slow IndexedDB"})," or OPFS instead of a filesystem while on React-Native you can use the ",(0,t.jsx)(r.a,{href:"/rx-storage-sqlite.html",children:"SQLite storage"}),"."]}),"\n",(0,t.jsxs)(r.p,{children:["Therefore the performance can be completely different depending on where you use RxDB and what you do with it. Here you can see some performance measurements and descriptions on how the different ",(0,t.jsx)(r.a,{href:"/rx-storage.html",children:"storages"})," work and how their performance is different."]}),"\n",(0,t.jsx)(r.h2,{id:"persistend-vs-semi-persistend-storages",children:"Persistend vs Semi-Persistend storages"}),"\n",(0,t.jsx)(r.p,{children:'The "normal" storages are always persistend. This means each RxDB write is directly written to disc and all queries run on the disc state. This means a good startup performance because nothing has to be done on startup.'}),"\n",(0,t.jsxs)(r.p,{children:["In contrast, semi-persistend storages like ",(0,t.jsx)(r.a,{href:"/rx-storage-memory-synced.html",children:"Memory-Synced"})," and ",(0,t.jsx)(r.a,{href:"/rx-storage-lokijs.html",children:"LokiJS"})," store all data in memory on startup and only save to disc occasionally (or on exit). Therefore it has a very fast read/write performance, but loading all data into memory on the first page load can take longer for big amounts of documents. Also these storages can only be used when all data fits into the memory at least once. In general it is recommended to stay on the persistend storages and only use semi-persitend ones, when you know for sure that the dataset will stay small (less then 2k documents)."]}),"\n",(0,t.jsx)(r.h2,{id:"performance-comparison",children:"Performance comparison"}),"\n",(0,t.jsx)(r.p,{children:"In the following you can find some performance measurements and comparisons. Notice that these are only a small set of possible RxDB operations. If performance is really relevant for your use case, you should do your own measurements with usage-patterns that are equal to how you use RxDB in production."}),"\n",(0,t.jsx)(r.h3,{id:"measurements",children:"Measurements"}),"\n",(0,t.jsx)(r.p,{children:"Here the following metrics are measured:"}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsxs)(r.li,{children:["time-to-first-insert: Many storages run lazy, so it makes no sense to compare the time which is required to create a database with collections. Instead we measure the ",(0,t.jsx)(r.strong,{children:"time-to-first-insert"})," which is the whole timespan from database creation until the first single document write is done."]}),"\n",(0,t.jsx)(r.li,{children:"insert 200 documents: Insert 200 documents with a single bulk-insert operation."}),"\n",(0,t.jsxs)(r.li,{children:["find 1200 documents by id: Here we fetch 100% of the stored documents with a single ",(0,t.jsx)(r.code,{children:"findByIds()"})," call."]}),"\n",(0,t.jsxs)(r.li,{children:["find 12000 documents by query: Here we fetch 100% of the stored documents with a single ",(0,t.jsx)(r.code,{children:"find()"})," call."]}),"\n",(0,t.jsxs)(r.li,{children:["find 300x4 documents by query: Here we fetch 100% of the stored documents with a 4 ",(0,t.jsx)(r.code,{children:"find()"})," calls that run in parallel."]}),"\n",(0,t.jsxs)(r.li,{children:["count 1200 documents: Counts 100% of the stored documents with a single ",(0,t.jsx)(r.code,{children:"count()"})," call."]}),"\n"]}),"\n",(0,t.jsx)(r.h2,{id:"browser-based-storages-performance-comparison",children:"Browser based Storages Performance Comparison"}),"\n",(0,t.jsxs)(r.p,{children:["The performance patterns of the browser based storages are very diverse. The ",(0,t.jsx)(r.a,{href:"/rx-storage-indexeddb.html",children:"IndexedDB storage"})," is recommended for mostly all use cases so you should start with that one. Later you can do performance testings and switch to another storage like ",(0,t.jsx)(r.a,{href:"/rx-storage-opfs.html",children:"OPFS"})," or ",(0,t.jsx)(r.a,{href:"/rx-storage-memory-synced.html",children:"memory-synced"}),". If you do not want to purchase ",(0,t.jsx)(r.a,{href:"/premium",children:"RxDB Premium"}),", you could use the slower ",(0,t.jsx)(r.a,{href:"/rx-storage-dexie.html",children:"Dexie.js based RxStorage"})," instead."]}),"\n",(0,t.jsx)("p",{align:"center",children:(0,t.jsx)("img",{src:"./files/rx-storage-performance-browser.png",alt:"RxStorage performance - browser",width:"700"})}),"\n",(0,t.jsx)(r.h2,{id:"nodenative-based-storages-performance-comparison",children:"Node/Native based Storages Performance Comparison"}),"\n",(0,t.jsxs)(r.p,{children:["For most client-side native applications (react-native, electron, capacitor), using the ",(0,t.jsx)(r.a,{href:"/rx-storage-sqlite.html",children:"SQLite RxStorage"})," is recommended. For non-client side applications like a server, use the ",(0,t.jsx)(r.a,{href:"/rx-storage-mongodb.html",children:"MongoDB storage"})," instead."]}),"\n",(0,t.jsx)("p",{align:"center",children:(0,t.jsx)("img",{src:"./files/rx-storage-performance-node.png",alt:"RxStorage performance - Node.js",width:"700"})})]})}function m(e={}){const{wrapper:r}={...(0,n.R)(),...e.components};return r?(0,t.jsx)(r,{...e,children:(0,t.jsx)(l,{...e})}):l(e)}},8453:(e,r,s)=>{s.d(r,{R:()=>a,x:()=>i});var t=s(6540);const n={},o=t.createContext(n);function a(e){const r=t.useContext(o);return t.useMemo((function(){return"function"==typeof e?e(r):{...r,...e}}),[r,e])}function i(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:a(e.components),t.createElement(o.Provider,{value:r},e.children)}}}]); \ No newline at end of file diff --git a/docs/assets/js/1df93b7f.35927cbb.js b/docs/assets/js/1df93b7f.35927cbb.js new file mode 100644 index 00000000000..678c57a5dbc --- /dev/null +++ b/docs/assets/js/1df93b7f.35927cbb.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[4583],{2658:(e,t,r)=>{r.d(t,{Tj:()=>zr,C3:()=>Kr,IA:()=>Hr});var a=r(7329);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.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),t}((0,w.A)(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.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),t}((0,w.A)(TypeError));function N(e,t){return new _(e,j.tunnelErrorMessage(e),t)}function E(e,t){return new D(e,j.tunnelErrorMessage(e),t)}function I(e){return!(!e||409!==e.status)&&e}var R={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var C=/\./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 F(e){var t=q((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=Q(e);(0,y.Hb)(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.k_)(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:T,maximum:1e15,multipleOf:.01}},additionalProperties:!0,required:["lwt"]};function Q(e){var t=Object.keys(e.properties).filter((t=>e.properties[t].final)),r=q(e.primaryKey);return t.push(r),"string"!=typeof e.primaryKey&&e.primaryKey.fields.forEach((e=>t.push(e))),t}var H="docs",K="changes",z="attachments",Z="dexie",U=new Map,J=new Map;var V="__";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 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 X(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[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=q(e.primaryKey);t.push([r]),t.push(["_deleted",r]),e.indexes&&e.indexes.forEach((e=>{var r=(0,y.$r)(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 se(e,t){return e+"||"+t}function ie(e){var t=new Set,r=[];return e.indexes?(e.indexes.forEach((a=>{(0,y.$r)(a).forEach((a=>{t.has(a)||(t.add(a),"boolean"===A(e,a).type&&r.push(a))}))})),r.push("_deleted"),(0,y.jw)(r)):r}var oe=r(9092),ce=r(5734),le=r(3337),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=A(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.Sd)(r.startKeys,(e=>e!==he&&e!==ue));n(i*s);var o=(0,y.Sd)(r.startKeys,(e=>e!==ue&&e!==he));n(o*s);var c=(0,y.Sd)(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(744),ye=r(2779),be=r(1692),xe=r(4903),we=r(7705),je=r(2403),ke=r(6776),_e=r(6950),De=r(6823),Ne=!1;function Ee(e){return Ne||((0,ye.DZ)(ye.hu.PIPELINE,{$sort:xe.xF,$project:xe.C2}),(0,ye.DZ)(ye.hu.QUERY,{$and:we.a6,$eq:je.XV,$elemMatch:_e.Jy,$exists:De.P,$gt:je.MR,$gte:je.fy,$in:je.oZ,$lt:je.NV,$lte:je.Q_,$ne:je.C5,$nin:je.GU,$mod:ke.Pp,$nor:we.q3,$not:we.En,$or:we.sU,$regex:ke.WP,$size:_e.Ig,$type:De.T}),Ne=!0),new be.X(e)}function Ie(e,t){var r=q(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.$r)(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.k_)(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 Re(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 $e(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=Ce(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=>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),i.sortSatisfiedByIndex&&u.length===s?e():a.continue()}else e()}}))})),!i.sortSatisfiedByIndex){var h=Re(e.schema,t.query);u=u.sort(h)}return{documents:u=u.slice(n,s)}}function Te(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 Be(e){return parseInt(e.split("-")[0],10)}function Ae(e,t){var r=t?t._rev:null;return(r?Te(r).height:0)+1+"-"+e}var Me="_rxdb_internal";async function qe(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 Fe(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 Qe(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 Ke(e){var t=i(e);return t._meta=i(e._meta),t}function ze(e,t,r){j.deepFreezeWhenDevMode(r);var a=q(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.t)(),s._rev=Ae(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.ZN)(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:Ae(e.token,t.documentInDb)})})));return e.lockedRun((()=>t.bulkWrite(i,s))).then((e=>((0,y.Hb)(a.error,e.error),(0,y.Hb)(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.ZN)(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:B(),_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 Ze=r(3561),Ue=r(703),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 Ge(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 Ue.X2(["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.B,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,Ze.X)(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.t)(),Xe=function(){function e(e,t,r,a,n,s,i){this.changes$=new oe.B,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=q(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.t)(),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 E=c?Qe(n):n;c&&(w?y&&Object.keys(y._attachments).forEach((e=>{f.push({documentId:b,attachmentId:e,digest:(0,le.ZN)(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=E.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(Qe(E)),i&&i(d)):(u.push(E),i&&i(d)),o=E);var I=null,R=null,C=null;if(j&&!w)C="INSERT",I=c?He(d):d;else if(!y||j||w){if(!w)throw N("SNH",{args:{writeRow:n}});C="DELETE",I=(0,le.ZN)(d),R=y}else C="UPDATE",I=c?He(d):d,R=y;var O={documentId:b,documentData:I,previousDocumentData:R,operation:C};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(Qe(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=>X(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.ZN)(r)).eventBulk.events.length>0){var i=(0,le.ZN)(r.newestRow).document;r.eventBulk.checkpoint={id:i[this.primaryPath],lwt:i._meta.lwt},r.eventBulk.endTime=(0,ce.t)(),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),$e(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=>G(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 $e(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.t)()-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.B},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(U,o,(()=>{var e=(async()=>{var e=i(r);e.autoOpen=!1;var t=new a.cf(o,e),s={[H]:ae(n),[K]:"++sequence, id",[z]:"id"};return t.version(1).stores(s),await t.open(),{dexieDb:t,dexieTable:t[H],dexieAttachmentsTable:t[z],booleanIndexes:ie(n)}})();return U.set(o,c),J.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(Z,t,o),Promise.resolve(o)}function tt(e){if(e.closed)throw new Error("RxStorageInstanceDexie is closed "+e.databaseName+"-"+e.collectionName)}var rt="15.10.0",at=function(){function e(e){this.name=Z,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.k_)(e)?e:[e]))}(this.jsonSchema),this.primaryPath=q(this.jsonSchema.primaryKey),this.finalFields=Q(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=A(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.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.A)(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=F(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(7708),ht=r(8146),dt=r(3356),mt=r(5520),pt=r(8609),ft=r(1753);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.ZN)(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=Te(s._rev).height,n.forEach((e=>{var t=Te(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=I(e);if(o){var c=s(this.queueByDocId,a,(()=>[]));i.reverse().forEach((e=>{e.lastKnownDocumentState=(0,le.ZN)(o.documentInDb),(0,le.ZN)(c).unshift(e)}))}else{var l=N("COL20",{name:R[(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.T)((e=>e._data._deleted)))},get deleted$$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().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.p)((e=>!e.isLocal)),(0,ht.p)((e=>e.documentId===this.primary)),(0,ut.T)((e=>gt(e))),(0,dt.Z)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ut.T)((e=>this.collection._docCache.getCachedRxDocument(e))),(0,pt.t)(le.bz))},get $$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},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(!A(this.collection.schema.jsonSchema,e))throw N("DOC4",{path:e})}return this.$.pipe((0,ut.T)((t=>v(t,e))),(0,mt.F)())},get$$(e){var t=this.get$(e);return this.collection.database.getReactivityFactory().fromObservable(t,this.getLatest().get(e))},populate(e){var t=A(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.$A;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(a.endsWith("$$")){var s=a.slice(0,-2);return r.get$$($(e+"."+s))}if("$"===n){var i=a.slice(0,-1);return r.get$($(e+"."+i))}if("_"===n){var o=a.slice(0,-1);return r.populate($(e+"."+o))}return r.get($(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(2198),_t=r(511),Dt=r(4157),Nt=r(2442),Et=r(6114);function It(e,t){return t.sort&&0!==t.sort.length?t.sort.map((e=>Object.keys(e)[0])):[e]}var Rt=new WeakMap;function Ct(e,t){if(!e.collection.database.eventReduce)return{runFullQueryAgain:!0};var r=function(e){return s(Rt,e,(()=>{var t=e.collection,r=Ie(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=Re(t.schema.jsonSchema,r),s=Ce(t.schema.jsonSchema,r);return{primaryKey:e.collection.schema.primaryPath,skip:r.skip,limit:r.limit,sortFields:It(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.ZN)(e._result).docsData.slice(0),n=(0,le.ZN)(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,Et.kC)(t);return"runFullQueryAgain"===s||("doNothing"!==s?(i=!0,(0,Et.Cs)(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 $t,Tt,Bt=($t=100,Tt=3e4,(e,t)=>{if(!(t._map.size<$t)){var r=(0,ce.t)()-Tt,a=[],n=Array.from(t._map.values());for(var s of n)Pt(s)>0||(0===s._lastEnsureEqual&&s._creationTimee._lastEnsureEqual-t._lastEnsureEqual)).slice(0,i).forEach((e=>St(t,e)))}}),At=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.A)(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=Be(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.vN)().then((()=>{e.registerIdlePromise=void 0;var t=e.registerIdleTasks;0!==t.length&&(e.registerIdleTasks=[],t.forEach((e=>{a.register(e,{docId:e.primary,revisionHeight:Be(e.revision)})})))}))))),m};return o}(this))}}]),e}();function qt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Ft=function(){function e(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=qt(this.collection._docCache,t)}return(0,b.A)(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 Ft(this.collection,e,e.length);this._result=t}else this._result=new Ft(this.collection,[],e)},t._execOverDatabase=async function(){if(this._execOverDatabaseCount=this._execOverDatabaseCount+1,this._lastExecStart=(0,ce.t)(),"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.ZN)(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.Hb)(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.t)(),e)))},t.exec=function(e){if(e&&"findOne"!==this.op)throw N("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return zt(this).then((()=>(0,_t._)(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:Ie(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=Zt(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.A)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,ht.p)((e=>!e.isLocal)),(0,dt.Z)(null),(0,Nt.Z)((()=>zt(this))),(0,ut.T)((()=>this._result)),(0,pt.t)(le.bz),(0,mt.F)(((e,t)=>!(!e||e.time!==(0,le.ZN)(t).time))),(0,ht.p)((e=>!!e)),(0,ut.T)((e=>{var t=(0,le.ZN)(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.h)(e,this.refCount$.pipe((0,ht.p)((()=>!1))))}return this._$}},{key:"$$",get:function(){return this.collection.database.getReactivityFactory().fromObservable(this.$,void 0)}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return l(this,"queryMatcher",Ce(0,Ie(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 Qt(e,t,r,a);return i=(n=i).collection._queryCache.getByQuery(n),s=r,At.has(s)||(At.add(s),(0,ft.dY)().then((()=>(0,ft.Ve)(200))).then((()=>{s.destroyed||s.cacheReplacementPolicy(s,s._queryCache),At.delete(s)}))),i}function Kt(e){var t=e.asRxQuery.collection._changeEventBuffer.counter;return e._latestChangeEvent>=t}function zt(e){return e.collection.database.destroyed||Kt(e)?ft.Dr:(e._ensureEqualQueue=e._ensureEqualQueue.then((()=>function(e){if(e._lastEnsureEqual=(0,ce.t)(),e.collection.database.destroyed||Kt(e))return ft.Dr;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.ZN)(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=Ct(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=Ke(e);return t._deleted=!0,t._meta.lwt=(0,ce.t)(),t._rev=Ae(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.p)((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=Bt),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=ze(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.p)((e=>e.collectionName===this.name)));this.$=t.pipe((0,Nt.Z)((e=>e.events))),this.checkpoint$=t.pipe((0,ut.T)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Mt(this.schema.primaryPath,this.$.pipe((0,ht.p)((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=>Fe(!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.em},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.ZN)(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=qt(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.ZN)(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.em),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 E("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 E("COL7",{key:t,when:e});if(!lr.includes(e))throw E("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.em;var s=n.series.map((e=>()=>e(r,a)));return(0,ft.h$)(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.Dr:(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.A)(e,[{key:"insert$",get:function(){return this.$.pipe((0,ht.p)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,ht.p)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,ht.p)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}]),e}();var mr=r(7635),pr=r(1007);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.sc)(e))},vr=r(5525),gr=new Set,yr=function(){function e(e,t,r,a,n,s,i,o,c,l,u,h,d){void 0===i&&(i=!1),void 0===o&&(o={}),this.idleQueue=new mr.G,this.rxdbVersion=rt,this.storageInstances=new Set,this._subs=[],this.startupErrors=[],this.onDestroy=[],this.destroyed=!1,this.collections={},this.eventBulks$=new oe.B,this.observable$=this.eventBulks$.pipe((0,Nt.Z)((e=>e.events))),this.storageToken=ft.Dr,this.storageTokenDocument=ft.Dr,this.emittedEventBulkIds=new vr.p4(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,this.reactivity=d,"pseudoInstance"!==this.name&&(this.internalStore=ze(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:Xt,data:{rxdbVersion:e.rxdbVersion,token:t,instanceToken:e.token,passwordHash:r},_deleted:!1,_meta:B(),_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.ZN)(n.error[0]);if(s.isError&&I(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.ZN)(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.getReactivityFactory=function(){if(!this.reactivity)throw N("DB14",{database:this.name});return this.reactivity},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 qe(this.internalStore,Gt(tr(e,t),Ut));if(!r)throw N("SNH",{name:e,schema:t});var a=Ke(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:Gt(h,Ut),key:h,context:Ut,data:{name:c,schemaHash:await u.hash,schema:u.jsonSchema,version:u.version,connectedStorages:[]},_deleted:!1,_meta:B(),_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.ZN)(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.ZN)(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=Bt,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.em;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.Dr:(this.destroyed=!0,await ot("preDestroyRxDatabase",this),this.eventBulks$.complete(),this._subs.map((e=>e.unsubscribe())),"pseudoInstance"===this.name?ft.Dr: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.storage.name+"|"+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.A)(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,reactivity:m}=e;it("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:s,eventReduce:i,ignoreDuplicate:o,options:c,localDocuments:h}),o||function(e,t){var r=t.name+"|"+e;if(gr.has(r))throw N("DB8",{name:e,storage:t.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}(a,t),gr.add(t.name+"|"+a);var p=S(10);return br(p,t,a,r,s,n).catch((e=>{throw gr.delete(t.name+"|"+a),e})).then((e=>{var f=new yr(a,p,t,r,n,s,i,c,e,d,l,u,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:s,eventReduce:i,ignoreDuplicate:o,options:c,localDocuments:h}}).then((()=>f))}))}var wr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Qt.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.A)(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.p)((e=>e.documentId===this.primary)),(0,ht.p)((e=>e.isLocal)),(0,ut.T)((e=>gt(e))),(0,dt.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ut.T)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.t)(le.bz))},get $$(){var e=this;return Ir(e).getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},get deleted$$(){var e=this;return Ir(e).getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted)},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 E("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.T)((e=>e._data)),(0,ut.T)((t=>v(t,e))),(0,mt.F)())},get$$(e){return Ir(this).getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e))},async incrementalModify(e){var t=await Sr(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 Sr(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 Sr(this.parent),t={id:this._data.id,data:{},_deleted:!0,_meta:B(),_rev:"",_attachments:{}};return Le(e.storageInstance,{previous:this._data,document:t},"local-document-remove").then((t=>e.docCache.getCachedRxDocument(t)))}},Nr=!1,Er=()=>{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)))}};function Ir(e){var t=e.parent;return t instanceof yr?t:t.database}var Rr=new WeakMap,Cr=new WeakMap;function Or(e){var t=e.database?e.database:e,r=e.database?e.name:"",a=(async()=>{var a=await Pr(t.token,t.storage,t.name,r,t.instanceCreationOptions,t.multiInstance);a=ze(t,a,Ar);var n=new Mt("id",e.$.pipe((0,ht.p)((e=>e.isLocal))),(t=>function(e,t){Er();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=>Fe(!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})();Rr.set(e,a)}function Sr(e){var t=Rr.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 Pr(e,t,r,a,n,s){return t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:Br(a),schema:Ar,options:n,multiInstance:s,devMode:j.isDevMode()})}function $r(e){var t=Rr.get(e);if(t)return Rr.delete(e),t.then((e=>e.storageInstance.close()))}async function Tr(e,t,r){var a=S(10),n=await Pr(a,e,t,r,{},!1);await n.remove()}function Br(e){return"plugin-local-documents-"+e}var Ar=F({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 Sr(this),a={id:e,data:t,_deleted:!1,_meta:B(),_rev:"",_attachments:{}};return Le(r.storageInstance,{document:a},"local-document-insert").then((e=>r.docCache.getCachedRxDocument(e)))}function qr(e,t){return this.getLocal(e).then((r=>r?r.incrementalModify((()=>t)):this.insertLocal(e,t)))}async function Lr(e){var t=await Sr(this),r=t.docCache,a=r.getLatestDocumentDataIfExists(e);return a?Promise.resolve(r.getCachedRxDocument(a)):qe(t.storageInstance,e).then((e=>e?t.docCache.getCachedRxDocument(e):null))}function Fr(e){return this.$.pipe((0,dt.Z)(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.p)((e=>e.use)),(0,ut.T)((e=>e.doc)))}var Wr={name:"local-documents",rxdb:!0,prototypes:{RxCollection:e=>{e.insertLocal=Mr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Fr},RxDatabase:e=>{e.insertLocal=Mr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Fr}},hooks:{createRxDatabase:{before:e=>{e.creator.localDocuments&&Or(e.database)}},createRxCollection:{before:e=>{e.creator.localDocuments&&Or(e.collection)}},preDestroyRxDatabase:{after:e=>$r(e)},postDestroyRxCollection:{after:e=>$r(e)},postRemoveRxDatabase:{after:e=>Tr(e.storage,e.databaseName,"")},postRemoveRxCollection:{after:e=>Tr(e.storage,e.databaseName,e.collectionName)}},overwritable:{}};let Qr;function Hr(){return"undefined"!=typeof window&&window.indexedDB}function Kr(){return Qr||(Qr=(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 E("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)}))}}(Wr);var e;return await xr({name:"rxdb-landing-v3",localDocuments:!0,storage:(void 0===e&&(e={}),new at(e))})})()),Qr}const zr=["#e6008d","#8d2089","#5f2688"]},1527:(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,{h:()=>a})},9612:(e,t,r)=>{r.r(t),r.d(t,{default:()=>O});var a=r(4586),n=r(1595),s=r(5260),i=r(4157),o=r(4629),c=r(7688),l=r(4134),u=r(2442),h=r(9739),d=r(1693),m=r(7708),p=Array.isArray;function f(e){return(0,m.T)((function(t){return function(e,t){return p(t)?e.apply(void 0,(0,o.fX)([],(0,o.zs)(t))):e(t)}(e,t)}))}var v=["addListener","removeListener"],g=["addEventListener","removeEventListener"],y=["on","off"];function b(e,t,r,a){if((0,d.T)(r)&&(a=r,r=void 0),a)return b(e,t,r).pipe(f(a));var n=(0,o.zs)(function(e){return(0,d.T)(e.addEventListener)&&(0,d.T)(e.removeEventListener)}(e)?g.map((function(a){return function(n){return e[a](t,n,r)}})):function(e){return(0,d.T)(e.addListener)&&(0,d.T)(e.removeListener)}(e)?v.map(x(e,t)):function(e){return(0,d.T)(e.on)&&(0,d.T)(e.off)}(e)?y.map(x(e,t)):[],2),s=n[0],i=n[1];if(!s&&(0,h.X)(e))return(0,u.Z)((function(e){return b(e,t,r)}))((0,c.Tg)(e));if(!s)throw new TypeError("Invalid event target");return new l.c((function(e){var t=function(){for(var t=[],r=0;r{for(await(0,k.ND)($);R;){const e=T(),r=(0,k.ND)(e.timeToNextPeriod);if(e.period%2==0)try{await t.incrementalModify((t=>(t.beatPeriod>=e.period||(t.beatPeriod=e.period,t.color=D.Tj[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.h)(b(window,"mousemove"),b(window,"scroll"),b(window,"resize")).subscribe((()=>{r.incrementalPatch({x:a[0],y:a[1],time:(0,_.t)()})})),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.ZN)([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.T)((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(),t.$.pipe((0,m.T)((e=>e._data.data)),(0,w.F)(((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=$+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")})),Array.from(s).forEach((function(e){e.style.animationDuration=$+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")})),Array.from(o).forEach((function(e){e.style.animationDuration=$+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")}))})),h.push((function(){Array.from(c).forEach((function(e){q()&&q()&&setTimeout((function(){const t=parseFloat(e.innerHTML)+1;e.innerHTML=t+""}),105)}))}))}function O(){const{siteConfig:e}=(0,a.A)();return(0,N.useEffect)((()=>(C(),()=>{console.log("stop animation"),R=!1}))),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(s.A,{children:(0,I.jsx)("body",{className:"homepage"})}),(0,I.jsx)(n.A,{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,I.jsxs)("main",{children:[(0,I.jsx)("div",{className:"block first centered",children:(0,I.jsxs)("div",{className:"content",children:[(0,I.jsxs)("h1",{children:["The local ",(0,I.jsx)("b",{className:"underline",children:"Database"})," for"," ",(0,I.jsx)("b",{className:"underline",children:"JavaScript"})," Applications"]}),(0,I.jsxs)("div",{className:"inner",children:[(0,I.jsxs)("div",{className:"half left",children:[(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsxs)("ul",{className:"checked",children:[(0,I.jsxs)("li",{children:[(0,I.jsx)("b",{children:"Realtime Queries"}),": From results of queries to single document fields, with RxDB you can observe everything which makes building ",(0,I.jsx)("u",{children:"realtime applications"})," effortless."]}),(0,I.jsxs)("li",{children:[(0,I.jsx)("b",{children:"Realtime Replication"}),": Run a two-way realtime replication with one of the many replication plugins. Also making your ",(0,I.jsx)("u",{children:"custom backend compatible"})," is pretty simple."]}),(0,I.jsxs)("li",{children:[(0,I.jsx)("b",{children:"Offline Support"}),": Store data locally on your clients device to build applications that still work when there is ",(0,I.jsx)("u",{children:"no internet access"}),". Running queries locally also improves your user experience."]}),(0,I.jsxs)("li",{children:[(0,I.jsx)("b",{children:"Supports all JavaScript runtimes"}),": With the flexible RxDB storage layer you can run the same code in ",(0,I.jsx)("u",{children:"Browsers"}),", ",(0,I.jsx)("u",{children:"Node.js"}),", ",(0,I.jsx)("u",{children:"Electron"}),","," ",(0,I.jsx)("u",{children:"React-Native"}),", ",(0,I.jsx)("u",{children:"Capacitor"}),", ",(0,I.jsx)("u",{children:"Bun"})," and ",(0,I.jsx)("u",{children:"Deno"}),"."]}),(0,I.jsxs)("li",{children:[(0,I.jsx)("b",{children:"Great Performance"}),": Years of performance optimization made RxDB one of the ",(0,I.jsx)("u",{children:"fastest"})," ways to store and query data inside of JavaScript."]})]}),(0,I.jsx)("a",{className:"button",href:"/quickstart.html",target:"_blank",onClick:()=>(0,E.h)("start_now",.4),children:"Quickstart \xbb"}),(0,I.jsxs)("a",{className:"button light",href:"/code",target:"_blank",children:[(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",className:"star-icon","aria-hidden":"true",fill:"currentColor",style:{width:14,marginRight:8,marginLeft:-6,float:"left",marginTop:2},children:(0,I.jsx)("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),"Star (20,172)"]}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsx)("div",{className:"half right",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,I.jsxs)("div",{className:"content-canvas",style:{marginTop:0,marginBottom:30,marginLeft:20},children:[(0,I.jsx)("div",{className:"device tablet",style:{marginLeft:481,marginTop:117},children:(0,I.jsx)("div",{className:"beating-color",style:{backgroundColor:"rgb(141, 32, 137)"},children:(0,I.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo animation",alt:"RxDB",style:{animationDuration:"851ms"}})})}),(0,I.jsx)("div",{className:"device desktop",style:{marginTop:"0%"},children:(0,I.jsx)("div",{className:"beating-color",style:{backgroundColor:"rgb(141, 32, 137)"},children:(0,I.jsx)("img",{src:"/files/logo/logo_text.svg",className:"beating logo animation",alt:"RxDB",style:{animationDuration:"851ms",width:"52%"}})})}),(0,I.jsxs)("div",{className:"device server",style:{marginLeft:0,marginTop:168},children:[(0,I.jsx)("div",{className:"beating-color one",style:{backgroundColor:"rgb(141, 32, 137)"}}),(0,I.jsx)("div",{className:"beating-color two",style:{backgroundColor:"rgb(141, 32, 137)"}}),(0,I.jsx)("div",{className:"beating-color three",style:{backgroundColor:"rgb(141, 32, 137)"}})]})]})})]})]})}),(0,I.jsx)("a",{href:"/chat",target:"_blank",children:(0,I.jsxs)("div",{className:"trophy discord",children:[(0,I.jsx)("img",{src:"./files/icons/discord.svg",alt:"RxDB Discord chat"}),(0,I.jsxs)("div",{style:{flex:1},children:[(0,I.jsx)("div",{className:"subtitle",children:"Chat on"}),(0,I.jsx)("div",{className:"title",children:"Discord"})]}),(0,I.jsxs)("div",{children:[(0,I.jsx)("div",{className:"valuetitle",children:"members"}),(0,I.jsxs)("div",{className:"value",children:["747",(0,I.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,I.jsx)("div",{className:"block second dark",children:(0,I.jsxs)("div",{className:"content",children:[(0,I.jsxs)("h2",{children:["Realtime applications ",(0,I.jsx)("b",{className:"underline",children:"made easy"})]}),(0,I.jsxs)("p",{children:["From the results of a query, to a single field of a document, with RxDB you can ",(0,I.jsx)("b",{children:"observe everything"}),". This enables you to build realtime applications ",(0,I.jsx)("b",{children:"fast"})," and ",(0,I.jsx)("b",{children:"reliable"}),". It does not matter if the data was changed by"," ",(0,I.jsx)("b",{children:"a user event"}),", ",(0,I.jsx)("b",{children:"another browser tab"})," or by the",(0,I.jsx)("b",{children:" replication"}),"."," ","Whenever your data changes, your UI reflects the new state. You can either use ",(0,I.jsx)("b",{children:"RxJS"})," or add ",(0,I.jsx)("a",{href:"/reactivity.html",target:"_blank",children:"custom reactiveness libraries"})," like signals or other state management."]}),(0,I.jsxs)("div",{className:"inner",children:[(0,I.jsxs)("div",{className:"code half",children:[(0,I.jsxs)("fieldset",{className:"samp-wrapper",style:{backgroundColor:"var(--bg-color)"},children:[(0,I.jsx)("legend",{children:"Write"}),(0,I.jsxs)("samp",{children:[(0,I.jsx)("span",{className:"cm-keyword",children:"await "}),(0,I.jsx)("span",{className:"cm-variable",children:"collection"}),".",(0,I.jsx)("span",{className:"cm-method",children:"upsert"}),"(","{",(0,I.jsx)("br",{}),(0,I.jsx)("span",{className:"cm-property",children:"\xa0 id"}),": ",(0,I.jsx)("span",{className:"cm-string",children:"'foobar'"}),",",(0,I.jsx)("br",{}),(0,I.jsx)("span",{className:"cm-property",children:"\xa0 color"}),": ",(0,I.jsxs)("span",{className:"cm-string",children:["'",(0,I.jsx)("span",{className:"beating-color-string beating-color",children:"#e6008d"}),"'"]}),(0,I.jsx)("br",{}),"}",");"]})]}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsxs)("fieldset",{className:"samp-wrapper",style:{backgroundColor:"var(--bg-color)"},children:[(0,I.jsx)("legend",{children:"Observe"}),(0,I.jsxs)("samp",{style:{backgroundColor:"var(--bg-color)"},children:[(0,I.jsx)("span",{className:"cm-keyword",children:"await "}),(0,I.jsx)("span",{className:"cm-variable",children:"collection"}),".",(0,I.jsxs)("span",{className:"cm-method",children:["findOne(",(0,I.jsx)("span",{className:"cm-string",children:"'foobar'"}),")"]}),(0,I.jsx)("br",{}),"\xa0.",(0,I.jsx)("span",{className:"cm-property",children:"$"}),(0,I.jsx)("span",{className:"cm-comment",children:" // get observable"}),(0,I.jsx)("br",{}),"\xa0.",(0,I.jsx)("span",{className:"cm-method",children:"subscribe"}),"(",(0,I.jsx)("span",{className:"cm-def",children:"d"}),(0,I.jsx)("span",{className:"cm-operator",children:" =>"})," ","{",(0,I.jsx)("br",{}),(0,I.jsx)("span",{className:"cm-variable",children:"\xa0\xa0 screen"}),".",(0,I.jsx)("span",{className:"cm-property",children:"backgroundColor"}),(0,I.jsx)("span",{className:"cm-operator",children:" = "}),(0,I.jsx)("span",{className:"cm-variable",children:"d"}),".",(0,I.jsx)("span",{className:"cm-property beating-color",children:"color"}),";",(0,I.jsx)("br",{}),"\xa0","}",");"]})]})]}),(0,I.jsx)("div",{className:"canvas half",children:(0,I.jsxs)("div",{className:"content-canvas",children:[(0,I.jsx)("div",{className:"device tablet",style:{marginLeft:481,marginTop:117},children:(0,I.jsx)("div",{className:"beating-color",children:(0,I.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo",alt:"RxDB"})})}),(0,I.jsx)("div",{className:"device desktop",style:{marginTop:"0%"},children:(0,I.jsx)("div",{className:"beating-color",children:(0,I.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo",alt:"RxDB"})})}),(0,I.jsxs)("div",{className:"device server",style:{marginLeft:0,marginTop:168},children:[(0,I.jsx)("div",{className:"beating-color one"}),(0,I.jsx)("div",{className:"beating-color two"}),(0,I.jsx)("div",{className:"beating-color three"})]})]})})]})]})}),(0,I.jsx)("a",{href:"https://twitter.com/intent/user?screen_name=rxdbjs",onClick:()=>(0,E.h)("twitter_trophy_click",.2),target:"_blank",children:(0,I.jsxs)("div",{className:"trophy twitter",children:[(0,I.jsx)("img",{src:"./files/icons/twitter-blue.svg",alt:"RxDB Twitter"}),(0,I.jsxs)("div",{style:{flex:1},children:[(0,I.jsx)("div",{className:"subtitle",children:"Follow on"}),(0,I.jsx)("div",{className:"title",children:"Twitter"})]}),(0,I.jsxs)("div",{children:[(0,I.jsx)("div",{className:"valuetitle",children:"followers"}),(0,I.jsxs)("div",{className:"value",children:["2843",(0,I.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,I.jsx)("div",{className:"block replication",children:(0,I.jsxs)("div",{className:"content",children:[(0,I.jsxs)("div",{className:"half left",children:[(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsxs)("h2",{children:["Replicate ",(0,I.jsx)("b",{children:"with your existing infrastructure"})]}),(0,I.jsxs)("p",{children:["RxDB supports replication with a"," ",(0,I.jsx)("a",{href:"/replication-couchdb.html",target:"_blank",children:"CouchDB"})," ","server or any custom"," ",(0,I.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,I.jsx)("a",{href:"/replication-http.html",target:"_blank",children:"HTTP"}),","," ",(0,I.jsx)("a",{href:"/replication-websocket.html",target:"_blank",children:"Websocket"}),","," ",(0,I.jsx)("a",{href:"/replication-webrtc.html",target:"_blank",children:"WebRTC"})," ","or"," ",(0,I.jsx)("a",{href:"/replication-firestore.html",target:"_blank",children:"Firestore"}),"."]})]}),(0,I.jsx)("div",{className:"half right",children:(0,I.jsxs)("div",{className:"replication-icons",children:[(0,I.jsx)("img",{src:"./files/logo/logo.svg",alt:"RxDB",className:"replicate-logo tilt-to-mouse"}),(0,I.jsx)("a",{href:"/replication-graphql.html",target:"_blank",children:(0,I.jsx)("div",{className:"neumorphism-circle-xl centered replicate-graphql enlarge-on-mouse",children:(0,I.jsx)("img",{src:"./files/icons/graphql-text.svg",alt:"GraphQL",className:"protocol"})})}),(0,I.jsx)("a",{href:"/replication-couchdb.html",target:"_blank",children:(0,I.jsx)("div",{className:"neumorphism-circle-xl centered replicate-couchdb enlarge-on-mouse",children:(0,I.jsx)("img",{src:"./files/icons/couchdb-text.svg",alt:"CouchDB",className:"protocol"})})}),(0,I.jsx)("a",{href:"/replication-http.html",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-xs centered replicate-rest enlarge-on-mouse",children:["{"," HTTP ","}"]})}),(0,I.jsx)("a",{href:"/replication-websocket.html",target:"_blank",children:(0,I.jsx)("div",{className:"neumorphism-circle-xs centered replicate-websocket enlarge-on-mouse",children:"websocket"})}),(0,I.jsx)("a",{href:"/replication-webrtc.html",target:"_blank",children:(0,I.jsx)("div",{className:"neumorphism-circle-xs centered replicate-webrtc enlarge-on-mouse",children:"WebRTC"})})]})}),(0,I.jsx)("div",{className:"clear"})]})}),(0,I.jsx)("a",{href:"/code",target:"_blank",children:(0,I.jsxs)("div",{className:"trophy",children:[(0,I.jsx)("img",{src:"./files/icons/github-star-with-logo.svg",alt:"RxDB github star"}),(0,I.jsxs)("div",{style:{flex:1},children:[(0,I.jsx)("div",{className:"subtitle",children:"Open Source on"}),(0,I.jsx)("div",{className:"title",children:"GitHub"})]}),(0,I.jsxs)("div",{children:[(0,I.jsx)("div",{className:"valuetitle",children:"stars"}),(0,I.jsxs)("div",{className:"value",children:["20172",(0,I.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,I.jsxs)("div",{className:"block offline-first dark",children:[(0,I.jsx)("div",{className:"offline-image-wrapper",children:(0,I.jsx)("img",{src:"files/icons/wifi/wifi_1a202c.svg",className:"offline-image beating-second",alt:"offline"})}),(0,I.jsxs)("div",{className:"content",children:[(0,I.jsxs)("h2",{children:["Online ",(0,I.jsx)("b",{className:"underline",children:"is optional"})]}),(0,I.jsxs)("div",{className:"full-width",children:[(0,I.jsx)("div",{className:"half left",children:(0,I.jsxs)("p",{children:["RxDB follows the"," ",(0,I.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,I.jsx)("div",{className:"half right",children:(0,I.jsxs)("ul",{className:"checked",children:[(0,I.jsxs)("li",{children:["Your application still ",(0,I.jsx)("b",{children:"works offline"})]}),(0,I.jsxs)("li",{children:["Increases ",(0,I.jsx)("b",{children:"perceived performance"})]}),(0,I.jsxs)("li",{children:["Easier and ",(0,I.jsx)("b",{children:"faster implementation"})]}),(0,I.jsxs)("li",{children:["Needs less backend resources and ",(0,I.jsx)("b",{children:"scales better"})]})]})})]})]})]}),(0,I.jsx)("div",{className:"block frameworks",children:(0,I.jsxs)("div",{className:"content",children:[(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/angular",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"-10%",left:"10%"},children:[(0,I.jsx)("img",{src:"./files/icons/angular.svg",alt:"angular"}),"Angular"]})}),(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"10%",left:"58%"},children:[(0,I.jsx)("img",{src:"./files/icons/capacitor.svg",alt:"capacitor"}),"Capacitor"]}),(0,I.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"-4%",left:"44%"},children:[(0,I.jsx)("img",{src:"./files/icons/deno.svg",alt:"deno"}),"Deno"]}),(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/node",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"-5%",left:"85%"},children:[(0,I.jsx)("img",{src:"./files/icons/nodejs.svg",alt:"Node.js"}),"Node.js"]})}),(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/react",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"4%",left:"26%"},children:[(0,I.jsx)("img",{src:"./files/icons/react.svg",alt:"React"}),"React"]})}),(0,I.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"15%",left:"90%",marginLeft:"-35px"},children:[(0,I.jsx)("img",{src:"./files/icons/svelte.svg",alt:"Svelte"}),"Svelte"]}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsxs)("h2",{children:["Flexible ",(0,I.jsx)("b",{className:"underline",children:"storage layer"})]}),(0,I.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,I.jsx)("b",{children:"any JavaScript runtime"})," ","by just switching out the storage settings.",(0,I.jsx)("br",{})]}),(0,I.jsxs)("div",{className:"below-text",children:[(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/electron",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"2%",left:"18%"},children:[(0,I.jsx)("img",{src:"./files/icons/electron.svg",alt:"electron"}),"Electron"]})}),(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/vue",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"3%",left:"45%"},children:[(0,I.jsx)("img",{src:"./files/icons/vuejs.svg",alt:"Vue.js"}),"Vue.js"]})}),(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/ionic2",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"2%",left:"71%"},children:[(0,I.jsx)("img",{src:"./files/icons/ionic.svg",alt:"ionic"}),"Ionic"]})}),(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"46%",left:"11%"},children:[(0,I.jsx)("img",{src:"./files/icons/nativescript.svg",alt:"NativeScript"}),"NativeScript"]}),(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/react-native",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"45%",left:"35%"},children:[(0,I.jsx)("img",{src:"./files/icons/react.svg",alt:"React Native"}),"React Native"]})}),(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"45%",left:"62%"},children:[(0,I.jsx)("img",{src:"./files/icons/nextjs.svg",alt:"Next.js"}),"Next.js"]}),(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/flutter",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"40%",left:"86%"},children:[(0,I.jsx)("img",{src:"./files/icons/flutter.svg",alt:"Flutter"}),"Flutter"]})})]})]})}),(0,I.jsx)("div",{className:"block fifth dark",children:(0,I.jsx)("div",{className:"content centered",children:(0,I.jsxs)("div",{className:"inner",children:[(0,I.jsxs)("h2",{children:["Trusted and ",(0,I.jsx)("b",{className:"underline",children:"open source"})]}),(0,I.jsxs)("div",{className:"box dark",children:[(0,I.jsx)("img",{src:"files/icons/github-star.svg",alt:"github star"}),(0,I.jsx)("div",{className:"label",children:"Github Stars"}),(0,I.jsx)("a",{className:"value",href:"/code",rel:"noopener",target:"_blank",children:"20172"}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsxs)("div",{className:"box dark",children:[(0,I.jsx)("img",{src:"files/icons/download.svg",alt:"npm downloads"}),(0,I.jsx)("div",{className:"label",children:"npm downloads"}),(0,I.jsx)("a",{className:"value beating-number",href:"https://www.npmjs.com/package/rxdb",rel:"noopener",target:"_blank",children:"238572"}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsx)("div",{className:"clear"}),(0,I.jsxs)("div",{className:"box dark",children:[(0,I.jsx)("img",{src:"files/icons/person.svg",alt:"contributor"}),(0,I.jsx)("div",{className:"label",children:"Contributors"}),(0,I.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/graphs/contributors",rel:"noopener",target:"_blank",children:"211"}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsxs)("div",{className:"box dark",children:[(0,I.jsx)("img",{src:"files/icons/commit.svg",alt:"commit"}),(0,I.jsx)("div",{className:"label",children:"Commits"}),(0,I.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/commits/master",rel:"noopener",target:"_blank",children:"10409"}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsx)("div",{className:"clear"}),(0,I.jsxs)("div",{className:"box dark",children:[(0,I.jsx)("img",{src:"files/icons/gear.svg",alt:"gear"}),(0,I.jsx)("div",{className:"label",children:"RxDB made Projects"}),(0,I.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/network/dependents?package_id=UGFja2FnZS0xODM0NzAyMw%3D%3D",rel:"noopener",target:"_blank",children:"1402"}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsxs)("div",{className:"box dark",children:[(0,I.jsx)("img",{src:"files/icons/twitter.svg",alt:"twitter"}),(0,I.jsx)("div",{className:"label",children:"Twitter followers"}),(0,I.jsx)("a",{className:"value",href:"https://twitter.com/intent/user?screen_name=rxdbjs",rel:"noopener",target:"_blank",children:"2925"}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsx)("div",{className:"clear"})]})})}),(0,I.jsx)("div",{className:"block sixth",children:(0,I.jsxs)("div",{className:"content",children:[(0,I.jsx)("h2",{children:"Pricing Models"}),(0,I.jsx)("div",{className:"inner",children:(0,I.jsxs)("div",{className:"buy-options",children:[(0,I.jsx)("div",{className:"buy-option bg-gradient-left-top",children:(0,I.jsxs)("div",{className:"buy-option-inner",children:[(0,I.jsxs)("div",{className:"buy-option-title",children:[(0,I.jsx)("h2",{children:"RxDB Basics"}),(0,I.jsx)("div",{className:"price",children:"Free & Open Source"})]}),(0,I.jsx)("div",{className:"buy-option-features",children:(0,I.jsxs)("ul",{children:[(0,I.jsx)("li",{children:"Basic RxStorages"}),(0,I.jsx)("li",{children:"Realtime Replication"}),(0,I.jsx)("li",{children:"Live Queries"}),(0,I.jsx)("li",{children:"Schema Validation"}),(0,I.jsx)("li",{children:"Multi-Tab Support"}),(0,I.jsx)("li",{children:"Encryption"}),(0,I.jsx)("li",{children:"Compression"})]})}),(0,I.jsx)("a",{href:"/code",target:"_blank",rel:"noopener",children:(0,I.jsx)("div",{className:"buy-option-action bg-top hover-shadow-top",children:"Get the Code"})})]})}),(0,I.jsx)("div",{className:"buy-option bg-gradient-right-top",children:(0,I.jsxs)("div",{className:"buy-option-inner",children:[(0,I.jsxs)("div",{className:"buy-option-title",children:[(0,I.jsx)("h2",{children:"Premium Plugins"}),(0,I.jsx)("div",{className:"price",children:"for professionals to get the most out of RxDB"})]}),(0,I.jsx)("div",{className:"buy-option-features",children:(0,I.jsxs)("ul",{children:[(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-sqlite.html",target:"_blank",children:"SQLite RxStorage"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-opfs.html",target:"_blank",children:"OPFS RxStorage"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-indexeddb.html",target:"_blank",children:"IndexedDB RxStorage"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-memory-synced.html",target:"_blank",children:"Memory-Synced RxStorage"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-sharding.html",target:"_blank",children:"Sharding Plugin"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/query-optimizer.html",target:"_blank",children:"Query Optimizer"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/migration-storage.html",target:"_blank",children:"Storage Migrator"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-localstorage-meta-optimizer.html",target:"_blank",children:"RxStorage Localstorage Meta Optimizer"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-shared-worker.html",target:"_blank",children:"Shared Worker"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-worker.html",target:"_blank",children:"Worker"})})]})}),(0,I.jsx)("a",{href:"/premium",children:(0,I.jsx)("div",{className:"buy-option-action bg-middle hover-shadow-middle",children:"Request Premium"})})]})}),(0,I.jsx)("div",{className:"buy-option bg-gradient-left-top",children:(0,I.jsxs)("div",{className:"buy-option-inner",children:[(0,I.jsxs)("div",{className:"buy-option-title",children:[(0,I.jsx)("h2",{children:"Consulting Session"}),(0,I.jsx)("div",{className:"price",children:"fast in person consulting"})]}),(0,I.jsx)("div",{className:"buy-option-features",children:(0,I.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,I.jsx)("br",{}),"You can book this by doing a one-time donation via github sponsors."]})}),(0,I.jsx)("a",{href:"https://github.com/sponsors/pubkey?frequency=one-time&sponsor=pubkey",target:"_blank",onClick:()=>(0,E.h)("consulting_session_request",1.5),children:(0,I.jsx)("div",{className:"buy-option-action bg-bottom hover-shadow-bottom",children:"Book Now"})})]})})]})})]})}),(0,I.jsx)("div",{className:"block last dark",children:(0,I.jsxs)("div",{className:"content",children:[(0,I.jsxs)("h2",{children:["Start using ",(0,I.jsx)("b",{className:"underline",children:"RxDB"})," today"]}),(0,I.jsxs)("div",{className:"buttons full-width",children:[(0,I.jsx)("a",{href:"/quickstart.html",rel:"noopener",target:"_blank",onClick:()=>(0,E.h)("start_now",.4),children:(0,I.jsx)("div",{className:"button get-premium",style:{left:"50%",top:"20%",marginLeft:"-122px"},children:"Start now"})}),(0,I.jsx)("a",{href:"/newsletter",rel:"noopener",target:"_blank",children:(0,I.jsx)("div",{className:"button",style:{left:"25%",marginLeft:"-90px"},children:"Get the Newsletter"})}),(0,I.jsx)("a",{href:"/chat",rel:"noopener",target:"_blank",children:(0,I.jsx)("div",{className:"button",style:{left:"77%",top:"6%",marginLeft:"-70.5px"},children:"Join the Chat"})}),(0,I.jsx)("a",{href:"/premium",children:(0,I.jsx)("div",{className:"button",style:{top:"40%",left:"20%",marginLeft:"-70.5px"},children:"Get Premium"})}),(0,I.jsx)("a",{href:"https://twitter.com/intent/user?screen_name=rxdbjs",rel:"noopener",target:"_blank",onClick:()=>(0,E.h)("follow_twitter",.4),children:(0,I.jsx)("div",{className:"button",style:{top:"44%",left:"73%",marginLeft:"-85px"},children:"Follow on Twitter"})}),(0,I.jsx)("a",{href:"/code",rel:"noopener",target:"_blank",children:(0,I.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"],$=851;function T(){const e=((new Date).getTime()-196e7)/$,t=Math.floor(e);return{ratio:e,period:t,timeToNextPeriod:(e-t)*$}}const B=22,A=-1*B;function M(e){return eB?B:e}function q(){return Math.random()<.5}function L(e,t){let r,a,n=(e=e.slice(0)).length;for(;n;)a=Math.floor(F(t)*n--),r=e[n],e[n]=e[a],e[a]=r,++t;return e}function F(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)}},7810:(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;an,Hb:()=>c,S7:()=>i,Sd:()=>o,dG:()=>a,jw:()=>l,k_:()=>s})},3337:(e,t,r)=>{function a(e,t){if(!e)throw t||(t=""),new Error("ensureNotFalsy() is falsy: "+t);return e}r.d(t,{ZN:()=>a,bz:()=>n});var n={bufferSize:1,refCount:!0}},1753:(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,{$A:()=>i,Dr:()=>s,ND:()=>n,Ve:()=>u,dY:()=>a,em:()=>o,h$:()=>h,vN:()=>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))}},5734:(e,t,r)=>{r.d(t,{t:()=>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.e4d1174b.js b/docs/assets/js/1df93b7f.e4d1174b.js deleted file mode 100644 index 719e0c6adf5..00000000000 --- a/docs/assets/js/1df93b7f.e4d1174b.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[4583],{2658:(e,t,r)=>{r.d(t,{Tj:()=>zr,C3:()=>Kr,IA:()=>Hr});var a=r(7329);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.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),t}((0,w.A)(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.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),t}((0,w.A)(TypeError));function N(e,t){return new _(e,j.tunnelErrorMessage(e),t)}function E(e,t){return new D(e,j.tunnelErrorMessage(e),t)}function I(e){return!(!e||409!==e.status)&&e}var R={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var C=/\./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 F(e){var t=q((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=Q(e);(0,y.Hb)(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.k_)(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:T,maximum:1e15,multipleOf:.01}},additionalProperties:!0,required:["lwt"]};function Q(e){var t=Object.keys(e.properties).filter((t=>e.properties[t].final)),r=q(e.primaryKey);return t.push(r),"string"!=typeof e.primaryKey&&e.primaryKey.fields.forEach((e=>t.push(e))),t}var H="docs",K="changes",z="attachments",Z="dexie",U=new Map,J=new Map;var V="__";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 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 X(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[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=q(e.primaryKey);t.push([r]),t.push(["_deleted",r]),e.indexes&&e.indexes.forEach((e=>{var r=(0,y.$r)(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 se(e,t){return e+"||"+t}function ie(e){var t=new Set,r=[];return e.indexes?(e.indexes.forEach((a=>{(0,y.$r)(a).forEach((a=>{t.has(a)||(t.add(a),"boolean"===A(e,a).type&&r.push(a))}))})),r.push("_deleted"),(0,y.jw)(r)):r}var oe=r(9092),ce=r(5734),le=r(3337),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=A(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.Sd)(r.startKeys,(e=>e!==he&&e!==ue));n(i*s);var o=(0,y.Sd)(r.startKeys,(e=>e!==ue&&e!==he));n(o*s);var c=(0,y.Sd)(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(744),ye=r(2779),be=r(1692),xe=r(4903),we=r(7705),je=r(2403),ke=r(6776),_e=r(6950),De=r(6823),Ne=!1;function Ee(e){return Ne||((0,ye.DZ)(ye.hu.PIPELINE,{$sort:xe.xF,$project:xe.C2}),(0,ye.DZ)(ye.hu.QUERY,{$and:we.a6,$eq:je.XV,$elemMatch:_e.Jy,$exists:De.P,$gt:je.MR,$gte:je.fy,$in:je.oZ,$lt:je.NV,$lte:je.Q_,$ne:je.C5,$nin:je.GU,$mod:ke.Pp,$nor:we.q3,$not:we.En,$or:we.sU,$regex:ke.WP,$size:_e.Ig,$type:De.T}),Ne=!0),new be.X(e)}function Ie(e,t){var r=q(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.$r)(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.k_)(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 Re(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 $e(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=Ce(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=>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),i.sortSatisfiedByIndex&&u.length===s?e():a.continue()}else e()}}))})),!i.sortSatisfiedByIndex){var h=Re(e.schema,t.query);u=u.sort(h)}return{documents:u=u.slice(n,s)}}function Te(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 Be(e){return parseInt(e.split("-")[0],10)}function Ae(e,t){var r=t?t._rev:null;return(r?Te(r).height:0)+1+"-"+e}var Me="_rxdb_internal";async function qe(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 Fe(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 Qe(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 Ke(e){var t=i(e);return t._meta=i(e._meta),t}function ze(e,t,r){j.deepFreezeWhenDevMode(r);var a=q(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.t)(),s._rev=Ae(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.ZN)(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:Ae(e.token,t.documentInDb)})})));return e.lockedRun((()=>t.bulkWrite(i,s))).then((e=>((0,y.Hb)(a.error,e.error),(0,y.Hb)(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.ZN)(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:B(),_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 Ze=r(3561),Ue=r(703),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 Ge(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 Ue.X2(["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.B,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,Ze.X)(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.t)(),Xe=function(){function e(e,t,r,a,n,s,i){this.changes$=new oe.B,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=q(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.t)(),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 E=c?Qe(n):n;c&&(w?y&&Object.keys(y._attachments).forEach((e=>{f.push({documentId:b,attachmentId:e,digest:(0,le.ZN)(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=E.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(Qe(E)),i&&i(d)):(u.push(E),i&&i(d)),o=E);var I=null,R=null,C=null;if(j&&!w)C="INSERT",I=c?He(d):d;else if(!y||j||w){if(!w)throw N("SNH",{args:{writeRow:n}});C="DELETE",I=(0,le.ZN)(d),R=y}else C="UPDATE",I=c?He(d):d,R=y;var O={documentId:b,documentData:I,previousDocumentData:R,operation:C};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(Qe(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=>X(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.ZN)(r)).eventBulk.events.length>0){var i=(0,le.ZN)(r.newestRow).document;r.eventBulk.checkpoint={id:i[this.primaryPath],lwt:i._meta.lwt},r.eventBulk.endTime=(0,ce.t)(),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),$e(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=>G(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 $e(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.t)()-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.B},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(U,o,(()=>{var e=(async()=>{var e=i(r);e.autoOpen=!1;var t=new a.cf(o,e),s={[H]:ae(n),[K]:"++sequence, id",[z]:"id"};return t.version(1).stores(s),await t.open(),{dexieDb:t,dexieTable:t[H],dexieAttachmentsTable:t[z],booleanIndexes:ie(n)}})();return U.set(o,c),J.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(Z,t,o),Promise.resolve(o)}function tt(e){if(e.closed)throw new Error("RxStorageInstanceDexie is closed "+e.databaseName+"-"+e.collectionName)}var rt="15.9.1",at=function(){function e(e){this.name=Z,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.k_)(e)?e:[e]))}(this.jsonSchema),this.primaryPath=q(this.jsonSchema.primaryKey),this.finalFields=Q(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=A(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.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.A)(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=F(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(7708),ht=r(8146),dt=r(3356),mt=r(5520),pt=r(8609),ft=r(1753);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.ZN)(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=Te(s._rev).height,n.forEach((e=>{var t=Te(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=I(e);if(o){var c=s(this.queueByDocId,a,(()=>[]));i.reverse().forEach((e=>{e.lastKnownDocumentState=(0,le.ZN)(o.documentInDb),(0,le.ZN)(c).unshift(e)}))}else{var l=N("COL20",{name:R[(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.T)((e=>e._data._deleted)))},get deleted$$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().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.p)((e=>!e.isLocal)),(0,ht.p)((e=>e.documentId===this.primary)),(0,ut.T)((e=>gt(e))),(0,dt.Z)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ut.T)((e=>this.collection._docCache.getCachedRxDocument(e))),(0,pt.t)(le.bz))},get $$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},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(!A(this.collection.schema.jsonSchema,e))throw N("DOC4",{path:e})}return this.$.pipe((0,ut.T)((t=>v(t,e))),(0,mt.F)())},get$$(e){var t=this.get$(e);return this.collection.database.getReactivityFactory().fromObservable(t,this.getLatest().get(e))},populate(e){var t=A(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.$A;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(a.endsWith("$$")){var s=a.slice(0,-2);return r.get$$($(e+"."+s))}if("$"===n){var i=a.slice(0,-1);return r.get$($(e+"."+i))}if("_"===n){var o=a.slice(0,-1);return r.populate($(e+"."+o))}return r.get($(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(2198),_t=r(511),Dt=r(4157),Nt=r(2442),Et=r(6114);function It(e,t){return t.sort&&0!==t.sort.length?t.sort.map((e=>Object.keys(e)[0])):[e]}var Rt=new WeakMap;function Ct(e,t){if(!e.collection.database.eventReduce)return{runFullQueryAgain:!0};var r=function(e){return s(Rt,e,(()=>{var t=e.collection,r=Ie(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=Re(t.schema.jsonSchema,r),s=Ce(t.schema.jsonSchema,r);return{primaryKey:e.collection.schema.primaryPath,skip:r.skip,limit:r.limit,sortFields:It(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.ZN)(e._result).docsData.slice(0),n=(0,le.ZN)(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,Et.kC)(t);return"runFullQueryAgain"===s||("doNothing"!==s?(i=!0,(0,Et.Cs)(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 $t,Tt,Bt=($t=100,Tt=3e4,(e,t)=>{if(!(t._map.size<$t)){var r=(0,ce.t)()-Tt,a=[],n=Array.from(t._map.values());for(var s of n)Pt(s)>0||(0===s._lastEnsureEqual&&s._creationTimee._lastEnsureEqual-t._lastEnsureEqual)).slice(0,i).forEach((e=>St(t,e)))}}),At=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.A)(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=Be(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.vN)().then((()=>{e.registerIdlePromise=void 0;var t=e.registerIdleTasks;0!==t.length&&(e.registerIdleTasks=[],t.forEach((e=>{a.register(e,{docId:e.primary,revisionHeight:Be(e.revision)})})))}))))),m};return o}(this))}}]),e}();function qt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Ft=function(){function e(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=qt(this.collection._docCache,t)}return(0,b.A)(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 Ft(this.collection,e,e.length);this._result=t}else this._result=new Ft(this.collection,[],e)},t._execOverDatabase=async function(){if(this._execOverDatabaseCount=this._execOverDatabaseCount+1,this._lastExecStart=(0,ce.t)(),"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.ZN)(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.Hb)(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.t)(),e)))},t.exec=function(e){if(e&&"findOne"!==this.op)throw N("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return zt(this).then((()=>(0,_t._)(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:Ie(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=Zt(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.A)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,ht.p)((e=>!e.isLocal)),(0,dt.Z)(null),(0,Nt.Z)((()=>zt(this))),(0,ut.T)((()=>this._result)),(0,pt.t)(le.bz),(0,mt.F)(((e,t)=>!(!e||e.time!==(0,le.ZN)(t).time))),(0,ht.p)((e=>!!e)),(0,ut.T)((e=>{var t=(0,le.ZN)(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.h)(e,this.refCount$.pipe((0,ht.p)((()=>!1))))}return this._$}},{key:"$$",get:function(){return this.collection.database.getReactivityFactory().fromObservable(this.$,void 0)}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return l(this,"queryMatcher",Ce(0,Ie(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 Qt(e,t,r,a);return i=(n=i).collection._queryCache.getByQuery(n),s=r,At.has(s)||(At.add(s),(0,ft.dY)().then((()=>(0,ft.Ve)(200))).then((()=>{s.destroyed||s.cacheReplacementPolicy(s,s._queryCache),At.delete(s)}))),i}function Kt(e){var t=e.asRxQuery.collection._changeEventBuffer.counter;return e._latestChangeEvent>=t}function zt(e){return e.collection.database.destroyed||Kt(e)?ft.Dr:(e._ensureEqualQueue=e._ensureEqualQueue.then((()=>function(e){if(e._lastEnsureEqual=(0,ce.t)(),e.collection.database.destroyed||Kt(e))return ft.Dr;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.ZN)(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=Ct(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=Ke(e);return t._deleted=!0,t._meta.lwt=(0,ce.t)(),t._rev=Ae(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.p)((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=Bt),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=ze(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.p)((e=>e.collectionName===this.name)));this.$=t.pipe((0,Nt.Z)((e=>e.events))),this.checkpoint$=t.pipe((0,ut.T)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Mt(this.schema.primaryPath,this.$.pipe((0,ht.p)((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=>Fe(!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.em},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.ZN)(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=qt(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.ZN)(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.em),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 E("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 E("COL7",{key:t,when:e});if(!lr.includes(e))throw E("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.em;var s=n.series.map((e=>()=>e(r,a)));return(0,ft.h$)(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.Dr:(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.A)(e,[{key:"insert$",get:function(){return this.$.pipe((0,ht.p)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,ht.p)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,ht.p)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}]),e}();var mr=r(7635),pr=r(1007);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.sc)(e))},vr=r(5525),gr=new Set,yr=function(){function e(e,t,r,a,n,s,i,o,c,l,u,h,d){void 0===i&&(i=!1),void 0===o&&(o={}),this.idleQueue=new mr.G,this.rxdbVersion=rt,this.storageInstances=new Set,this._subs=[],this.startupErrors=[],this.onDestroy=[],this.destroyed=!1,this.collections={},this.eventBulks$=new oe.B,this.observable$=this.eventBulks$.pipe((0,Nt.Z)((e=>e.events))),this.storageToken=ft.Dr,this.storageTokenDocument=ft.Dr,this.emittedEventBulkIds=new vr.p4(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,this.reactivity=d,"pseudoInstance"!==this.name&&(this.internalStore=ze(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:Xt,data:{rxdbVersion:e.rxdbVersion,token:t,instanceToken:e.token,passwordHash:r},_deleted:!1,_meta:B(),_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.ZN)(n.error[0]);if(s.isError&&I(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.ZN)(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.getReactivityFactory=function(){if(!this.reactivity)throw N("DB14",{database:this.name});return this.reactivity},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 qe(this.internalStore,Gt(tr(e,t),Ut));if(!r)throw N("SNH",{name:e,schema:t});var a=Ke(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:Gt(h,Ut),key:h,context:Ut,data:{name:c,schemaHash:await u.hash,schema:u.jsonSchema,version:u.version,connectedStorages:[]},_deleted:!1,_meta:B(),_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.ZN)(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.ZN)(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=Bt,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.em;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.Dr:(this.destroyed=!0,await ot("preDestroyRxDatabase",this),this.eventBulks$.complete(),this._subs.map((e=>e.unsubscribe())),"pseudoInstance"===this.name?ft.Dr: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.storage.name+"|"+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.A)(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,reactivity:m}=e;it("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:s,eventReduce:i,ignoreDuplicate:o,options:c,localDocuments:h}),o||function(e,t){var r=t.name+"|"+e;if(gr.has(r))throw N("DB8",{name:e,storage:t.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}(a,t),gr.add(t.name+"|"+a);var p=S(10);return br(p,t,a,r,s,n).catch((e=>{throw gr.delete(t.name+"|"+a),e})).then((e=>{var f=new yr(a,p,t,r,n,s,i,c,e,d,l,u,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:s,eventReduce:i,ignoreDuplicate:o,options:c,localDocuments:h}}).then((()=>f))}))}var wr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Qt.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.A)(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.p)((e=>e.documentId===this.primary)),(0,ht.p)((e=>e.isLocal)),(0,ut.T)((e=>gt(e))),(0,dt.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ut.T)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.t)(le.bz))},get $$(){var e=this;return Ir(e).getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},get deleted$$(){var e=this;return Ir(e).getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted)},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 E("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.T)((e=>e._data)),(0,ut.T)((t=>v(t,e))),(0,mt.F)())},get$$(e){return Ir(this).getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e))},async incrementalModify(e){var t=await Sr(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 Sr(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 Sr(this.parent),t={id:this._data.id,data:{},_deleted:!0,_meta:B(),_rev:"",_attachments:{}};return Le(e.storageInstance,{previous:this._data,document:t},"local-document-remove").then((t=>e.docCache.getCachedRxDocument(t)))}},Nr=!1,Er=()=>{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)))}};function Ir(e){var t=e.parent;return t instanceof yr?t:t.database}var Rr=new WeakMap,Cr=new WeakMap;function Or(e){var t=e.database?e.database:e,r=e.database?e.name:"",a=(async()=>{var a=await Pr(t.token,t.storage,t.name,r,t.instanceCreationOptions,t.multiInstance);a=ze(t,a,Ar);var n=new Mt("id",e.$.pipe((0,ht.p)((e=>e.isLocal))),(t=>function(e,t){Er();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=>Fe(!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})();Rr.set(e,a)}function Sr(e){var t=Rr.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 Pr(e,t,r,a,n,s){return t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:Br(a),schema:Ar,options:n,multiInstance:s,devMode:j.isDevMode()})}function $r(e){var t=Rr.get(e);if(t)return Rr.delete(e),t.then((e=>e.storageInstance.close()))}async function Tr(e,t,r){var a=S(10),n=await Pr(a,e,t,r,{},!1);await n.remove()}function Br(e){return"plugin-local-documents-"+e}var Ar=F({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 Sr(this),a={id:e,data:t,_deleted:!1,_meta:B(),_rev:"",_attachments:{}};return Le(r.storageInstance,{document:a},"local-document-insert").then((e=>r.docCache.getCachedRxDocument(e)))}function qr(e,t){return this.getLocal(e).then((r=>r?r.incrementalModify((()=>t)):this.insertLocal(e,t)))}async function Lr(e){var t=await Sr(this),r=t.docCache,a=r.getLatestDocumentDataIfExists(e);return a?Promise.resolve(r.getCachedRxDocument(a)):qe(t.storageInstance,e).then((e=>e?t.docCache.getCachedRxDocument(e):null))}function Fr(e){return this.$.pipe((0,dt.Z)(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.p)((e=>e.use)),(0,ut.T)((e=>e.doc)))}var Wr={name:"local-documents",rxdb:!0,prototypes:{RxCollection:e=>{e.insertLocal=Mr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Fr},RxDatabase:e=>{e.insertLocal=Mr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Fr}},hooks:{createRxDatabase:{before:e=>{e.creator.localDocuments&&Or(e.database)}},createRxCollection:{before:e=>{e.creator.localDocuments&&Or(e.collection)}},preDestroyRxDatabase:{after:e=>$r(e)},postDestroyRxCollection:{after:e=>$r(e)},postRemoveRxDatabase:{after:e=>Tr(e.storage,e.databaseName,"")},postRemoveRxCollection:{after:e=>Tr(e.storage,e.databaseName,e.collectionName)}},overwritable:{}};let Qr;function Hr(){return"undefined"!=typeof window&&window.indexedDB}function Kr(){return Qr||(Qr=(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 E("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)}))}}(Wr);var e;return await xr({name:"rxdb-landing-v3",localDocuments:!0,storage:(void 0===e&&(e={}),new at(e))})})()),Qr}const zr=["#e6008d","#8d2089","#5f2688"]},1527:(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,{h:()=>a})},9612:(e,t,r)=>{r.r(t),r.d(t,{default:()=>O});var a=r(4586),n=r(1595),s=r(5260),i=r(4157),o=r(4629),c=r(7688),l=r(4134),u=r(2442),h=r(9739),d=r(1693),m=r(7708),p=Array.isArray;function f(e){return(0,m.T)((function(t){return function(e,t){return p(t)?e.apply(void 0,(0,o.fX)([],(0,o.zs)(t))):e(t)}(e,t)}))}var v=["addListener","removeListener"],g=["addEventListener","removeEventListener"],y=["on","off"];function b(e,t,r,a){if((0,d.T)(r)&&(a=r,r=void 0),a)return b(e,t,r).pipe(f(a));var n=(0,o.zs)(function(e){return(0,d.T)(e.addEventListener)&&(0,d.T)(e.removeEventListener)}(e)?g.map((function(a){return function(n){return e[a](t,n,r)}})):function(e){return(0,d.T)(e.addListener)&&(0,d.T)(e.removeListener)}(e)?v.map(x(e,t)):function(e){return(0,d.T)(e.on)&&(0,d.T)(e.off)}(e)?y.map(x(e,t)):[],2),s=n[0],i=n[1];if(!s&&(0,h.X)(e))return(0,u.Z)((function(e){return b(e,t,r)}))((0,c.Tg)(e));if(!s)throw new TypeError("Invalid event target");return new l.c((function(e){var t=function(){for(var t=[],r=0;r{for(await(0,k.ND)($);R;){const e=T(),r=(0,k.ND)(e.timeToNextPeriod);if(e.period%2==0)try{await t.incrementalModify((t=>(t.beatPeriod>=e.period||(t.beatPeriod=e.period,t.color=D.Tj[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.h)(b(window,"mousemove"),b(window,"scroll"),b(window,"resize")).subscribe((()=>{r.incrementalPatch({x:a[0],y:a[1],time:(0,_.t)()})})),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.ZN)([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.T)((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(),t.$.pipe((0,m.T)((e=>e._data.data)),(0,w.F)(((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=$+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")})),Array.from(s).forEach((function(e){e.style.animationDuration=$+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")})),Array.from(o).forEach((function(e){e.style.animationDuration=$+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")}))})),h.push((function(){Array.from(c).forEach((function(e){q()&&q()&&setTimeout((function(){const t=parseFloat(e.innerHTML)+1;e.innerHTML=t+""}),105)}))}))}function O(){const{siteConfig:e}=(0,a.A)();return(0,N.useEffect)((()=>(C(),()=>{console.log("stop animation"),R=!1}))),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(s.A,{children:(0,I.jsx)("body",{className:"homepage"})}),(0,I.jsx)(n.A,{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,I.jsxs)("main",{children:[(0,I.jsx)("div",{className:"block first centered",children:(0,I.jsxs)("div",{className:"content",children:[(0,I.jsxs)("h1",{children:["The local ",(0,I.jsx)("b",{className:"underline",children:"Database"})," for"," ",(0,I.jsx)("b",{className:"underline",children:"JavaScript"})," Applications"]}),(0,I.jsxs)("div",{className:"inner",children:[(0,I.jsxs)("div",{className:"half left",children:[(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsxs)("ul",{className:"checked",children:[(0,I.jsxs)("li",{children:[(0,I.jsx)("b",{children:"Realtime Queries"}),": From results of queries to single document fields, with RxDB you can observe everything which makes building ",(0,I.jsx)("u",{children:"realtime applications"})," effortless."]}),(0,I.jsxs)("li",{children:[(0,I.jsx)("b",{children:"Realtime Replication"}),": Run a two-way realtime replication with one of the many replication plugins. Also making your ",(0,I.jsx)("u",{children:"custom backend compatible"})," is pretty simple."]}),(0,I.jsxs)("li",{children:[(0,I.jsx)("b",{children:"Offline Support"}),": Store data locally on your clients device to build applications that still work when there is ",(0,I.jsx)("u",{children:"no internet access"}),". Running queries locally also improves your user experience."]}),(0,I.jsxs)("li",{children:[(0,I.jsx)("b",{children:"Supports all JavaScript runtimes"}),": With the flexible RxDB storage layer you can run the same code in ",(0,I.jsx)("u",{children:"Browsers"}),", ",(0,I.jsx)("u",{children:"Node.js"}),", ",(0,I.jsx)("u",{children:"Electron"}),","," ",(0,I.jsx)("u",{children:"React-Native"}),", ",(0,I.jsx)("u",{children:"Capacitor"}),", ",(0,I.jsx)("u",{children:"Bun"})," and ",(0,I.jsx)("u",{children:"Deno"}),"."]}),(0,I.jsxs)("li",{children:[(0,I.jsx)("b",{children:"Great Performance"}),": Years of performance optimization made RxDB one of the ",(0,I.jsx)("u",{children:"fastest"})," ways to store and query data inside of JavaScript."]})]}),(0,I.jsx)("a",{className:"button",href:"/quickstart.html",target:"_blank",onClick:()=>(0,E.h)("start_now",.4),children:"Quickstart \xbb"}),(0,I.jsxs)("a",{className:"button light",href:"/code",target:"_blank",children:[(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",className:"star-icon","aria-hidden":"true",fill:"currentColor",style:{width:14,marginRight:8,marginLeft:-6,float:"left",marginTop:2},children:(0,I.jsx)("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),"Star (20,172)"]}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsx)("div",{className:"half right",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,I.jsxs)("div",{className:"content-canvas",style:{marginTop:0,marginBottom:30,marginLeft:20},children:[(0,I.jsx)("div",{className:"device tablet",style:{marginLeft:481,marginTop:117},children:(0,I.jsx)("div",{className:"beating-color",style:{backgroundColor:"rgb(141, 32, 137)"},children:(0,I.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo animation",alt:"RxDB",style:{animationDuration:"851ms"}})})}),(0,I.jsx)("div",{className:"device desktop",style:{marginTop:"0%"},children:(0,I.jsx)("div",{className:"beating-color",style:{backgroundColor:"rgb(141, 32, 137)"},children:(0,I.jsx)("img",{src:"/files/logo/logo_text.svg",className:"beating logo animation",alt:"RxDB",style:{animationDuration:"851ms",width:"52%"}})})}),(0,I.jsxs)("div",{className:"device server",style:{marginLeft:0,marginTop:168},children:[(0,I.jsx)("div",{className:"beating-color one",style:{backgroundColor:"rgb(141, 32, 137)"}}),(0,I.jsx)("div",{className:"beating-color two",style:{backgroundColor:"rgb(141, 32, 137)"}}),(0,I.jsx)("div",{className:"beating-color three",style:{backgroundColor:"rgb(141, 32, 137)"}})]})]})})]})]})}),(0,I.jsx)("a",{href:"/chat",target:"_blank",children:(0,I.jsxs)("div",{className:"trophy discord",children:[(0,I.jsx)("img",{src:"./files/icons/discord.svg",alt:"RxDB Discord chat"}),(0,I.jsxs)("div",{style:{flex:1},children:[(0,I.jsx)("div",{className:"subtitle",children:"Chat on"}),(0,I.jsx)("div",{className:"title",children:"Discord"})]}),(0,I.jsxs)("div",{children:[(0,I.jsx)("div",{className:"valuetitle",children:"members"}),(0,I.jsxs)("div",{className:"value",children:["747",(0,I.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,I.jsx)("div",{className:"block second dark",children:(0,I.jsxs)("div",{className:"content",children:[(0,I.jsxs)("h2",{children:["Realtime applications ",(0,I.jsx)("b",{className:"underline",children:"made easy"})]}),(0,I.jsxs)("p",{children:["From the results of a query, to a single field of a document, with RxDB you can ",(0,I.jsx)("b",{children:"observe everything"}),". This enables you to build realtime applications ",(0,I.jsx)("b",{children:"fast"})," and ",(0,I.jsx)("b",{children:"reliable"}),". It does not matter if the data was changed by"," ",(0,I.jsx)("b",{children:"a user event"}),", ",(0,I.jsx)("b",{children:"another browser tab"})," or by the",(0,I.jsx)("b",{children:" replication"}),"."," ","Whenever your data changes, your UI reflects the new state. You can either use ",(0,I.jsx)("b",{children:"RxJS"})," or add ",(0,I.jsx)("a",{href:"/reactivity.html",target:"_blank",children:"custom reactiveness libraries"})," like signals or other state management."]}),(0,I.jsxs)("div",{className:"inner",children:[(0,I.jsxs)("div",{className:"code half",children:[(0,I.jsxs)("fieldset",{className:"samp-wrapper",style:{backgroundColor:"var(--bg-color)"},children:[(0,I.jsx)("legend",{children:"Write"}),(0,I.jsxs)("samp",{children:[(0,I.jsx)("span",{className:"cm-keyword",children:"await "}),(0,I.jsx)("span",{className:"cm-variable",children:"collection"}),".",(0,I.jsx)("span",{className:"cm-method",children:"upsert"}),"(","{",(0,I.jsx)("br",{}),(0,I.jsx)("span",{className:"cm-property",children:"\xa0 id"}),": ",(0,I.jsx)("span",{className:"cm-string",children:"'foobar'"}),",",(0,I.jsx)("br",{}),(0,I.jsx)("span",{className:"cm-property",children:"\xa0 color"}),": ",(0,I.jsxs)("span",{className:"cm-string",children:["'",(0,I.jsx)("span",{className:"beating-color-string beating-color",children:"#e6008d"}),"'"]}),(0,I.jsx)("br",{}),"}",");"]})]}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsxs)("fieldset",{className:"samp-wrapper",style:{backgroundColor:"var(--bg-color)"},children:[(0,I.jsx)("legend",{children:"Observe"}),(0,I.jsxs)("samp",{style:{backgroundColor:"var(--bg-color)"},children:[(0,I.jsx)("span",{className:"cm-keyword",children:"await "}),(0,I.jsx)("span",{className:"cm-variable",children:"collection"}),".",(0,I.jsxs)("span",{className:"cm-method",children:["findOne(",(0,I.jsx)("span",{className:"cm-string",children:"'foobar'"}),")"]}),(0,I.jsx)("br",{}),"\xa0.",(0,I.jsx)("span",{className:"cm-property",children:"$"}),(0,I.jsx)("span",{className:"cm-comment",children:" // get observable"}),(0,I.jsx)("br",{}),"\xa0.",(0,I.jsx)("span",{className:"cm-method",children:"subscribe"}),"(",(0,I.jsx)("span",{className:"cm-def",children:"d"}),(0,I.jsx)("span",{className:"cm-operator",children:" =>"})," ","{",(0,I.jsx)("br",{}),(0,I.jsx)("span",{className:"cm-variable",children:"\xa0\xa0 screen"}),".",(0,I.jsx)("span",{className:"cm-property",children:"backgroundColor"}),(0,I.jsx)("span",{className:"cm-operator",children:" = "}),(0,I.jsx)("span",{className:"cm-variable",children:"d"}),".",(0,I.jsx)("span",{className:"cm-property beating-color",children:"color"}),";",(0,I.jsx)("br",{}),"\xa0","}",");"]})]})]}),(0,I.jsx)("div",{className:"canvas half",children:(0,I.jsxs)("div",{className:"content-canvas",children:[(0,I.jsx)("div",{className:"device tablet",style:{marginLeft:481,marginTop:117},children:(0,I.jsx)("div",{className:"beating-color",children:(0,I.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo",alt:"RxDB"})})}),(0,I.jsx)("div",{className:"device desktop",style:{marginTop:"0%"},children:(0,I.jsx)("div",{className:"beating-color",children:(0,I.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo",alt:"RxDB"})})}),(0,I.jsxs)("div",{className:"device server",style:{marginLeft:0,marginTop:168},children:[(0,I.jsx)("div",{className:"beating-color one"}),(0,I.jsx)("div",{className:"beating-color two"}),(0,I.jsx)("div",{className:"beating-color three"})]})]})})]})]})}),(0,I.jsx)("a",{href:"https://twitter.com/intent/user?screen_name=rxdbjs",onClick:()=>(0,E.h)("twitter_trophy_click",.2),target:"_blank",children:(0,I.jsxs)("div",{className:"trophy twitter",children:[(0,I.jsx)("img",{src:"./files/icons/twitter-blue.svg",alt:"RxDB Twitter"}),(0,I.jsxs)("div",{style:{flex:1},children:[(0,I.jsx)("div",{className:"subtitle",children:"Follow on"}),(0,I.jsx)("div",{className:"title",children:"Twitter"})]}),(0,I.jsxs)("div",{children:[(0,I.jsx)("div",{className:"valuetitle",children:"followers"}),(0,I.jsxs)("div",{className:"value",children:["2843",(0,I.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,I.jsx)("div",{className:"block replication",children:(0,I.jsxs)("div",{className:"content",children:[(0,I.jsxs)("div",{className:"half left",children:[(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsxs)("h2",{children:["Replicate ",(0,I.jsx)("b",{children:"with your existing infrastructure"})]}),(0,I.jsxs)("p",{children:["RxDB supports replication with a"," ",(0,I.jsx)("a",{href:"/replication-couchdb.html",target:"_blank",children:"CouchDB"})," ","server or any custom"," ",(0,I.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,I.jsx)("a",{href:"/replication-http.html",target:"_blank",children:"HTTP"}),","," ",(0,I.jsx)("a",{href:"/replication-websocket.html",target:"_blank",children:"Websocket"}),","," ",(0,I.jsx)("a",{href:"/replication-webrtc.html",target:"_blank",children:"WebRTC"})," ","or"," ",(0,I.jsx)("a",{href:"/replication-firestore.html",target:"_blank",children:"Firestore"}),"."]})]}),(0,I.jsx)("div",{className:"half right",children:(0,I.jsxs)("div",{className:"replication-icons",children:[(0,I.jsx)("img",{src:"./files/logo/logo.svg",alt:"RxDB",className:"replicate-logo tilt-to-mouse"}),(0,I.jsx)("a",{href:"/replication-graphql.html",target:"_blank",children:(0,I.jsx)("div",{className:"neumorphism-circle-xl centered replicate-graphql enlarge-on-mouse",children:(0,I.jsx)("img",{src:"./files/icons/graphql-text.svg",alt:"GraphQL",className:"protocol"})})}),(0,I.jsx)("a",{href:"/replication-couchdb.html",target:"_blank",children:(0,I.jsx)("div",{className:"neumorphism-circle-xl centered replicate-couchdb enlarge-on-mouse",children:(0,I.jsx)("img",{src:"./files/icons/couchdb-text.svg",alt:"CouchDB",className:"protocol"})})}),(0,I.jsx)("a",{href:"/replication-http.html",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-xs centered replicate-rest enlarge-on-mouse",children:["{"," HTTP ","}"]})}),(0,I.jsx)("a",{href:"/replication-websocket.html",target:"_blank",children:(0,I.jsx)("div",{className:"neumorphism-circle-xs centered replicate-websocket enlarge-on-mouse",children:"websocket"})}),(0,I.jsx)("a",{href:"/replication-webrtc.html",target:"_blank",children:(0,I.jsx)("div",{className:"neumorphism-circle-xs centered replicate-webrtc enlarge-on-mouse",children:"WebRTC"})})]})}),(0,I.jsx)("div",{className:"clear"})]})}),(0,I.jsx)("a",{href:"/code",target:"_blank",children:(0,I.jsxs)("div",{className:"trophy",children:[(0,I.jsx)("img",{src:"./files/icons/github-star-with-logo.svg",alt:"RxDB github star"}),(0,I.jsxs)("div",{style:{flex:1},children:[(0,I.jsx)("div",{className:"subtitle",children:"Open Source on"}),(0,I.jsx)("div",{className:"title",children:"GitHub"})]}),(0,I.jsxs)("div",{children:[(0,I.jsx)("div",{className:"valuetitle",children:"stars"}),(0,I.jsxs)("div",{className:"value",children:["20172",(0,I.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,I.jsxs)("div",{className:"block offline-first dark",children:[(0,I.jsx)("div",{className:"offline-image-wrapper",children:(0,I.jsx)("img",{src:"files/icons/wifi/wifi_1a202c.svg",className:"offline-image beating-second",alt:"offline"})}),(0,I.jsxs)("div",{className:"content",children:[(0,I.jsxs)("h2",{children:["Online ",(0,I.jsx)("b",{className:"underline",children:"is optional"})]}),(0,I.jsxs)("div",{className:"full-width",children:[(0,I.jsx)("div",{className:"half left",children:(0,I.jsxs)("p",{children:["RxDB follows the"," ",(0,I.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,I.jsx)("div",{className:"half right",children:(0,I.jsxs)("ul",{className:"checked",children:[(0,I.jsxs)("li",{children:["Your application still ",(0,I.jsx)("b",{children:"works offline"})]}),(0,I.jsxs)("li",{children:["Increases ",(0,I.jsx)("b",{children:"perceived performance"})]}),(0,I.jsxs)("li",{children:["Easier and ",(0,I.jsx)("b",{children:"faster implementation"})]}),(0,I.jsxs)("li",{children:["Needs less backend resources and ",(0,I.jsx)("b",{children:"scales better"})]})]})})]})]})]}),(0,I.jsx)("div",{className:"block frameworks",children:(0,I.jsxs)("div",{className:"content",children:[(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/angular",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"-10%",left:"10%"},children:[(0,I.jsx)("img",{src:"./files/icons/angular.svg",alt:"angular"}),"Angular"]})}),(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"10%",left:"58%"},children:[(0,I.jsx)("img",{src:"./files/icons/capacitor.svg",alt:"capacitor"}),"Capacitor"]}),(0,I.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"-4%",left:"44%"},children:[(0,I.jsx)("img",{src:"./files/icons/deno.svg",alt:"deno"}),"Deno"]}),(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/node",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"-5%",left:"85%"},children:[(0,I.jsx)("img",{src:"./files/icons/nodejs.svg",alt:"Node.js"}),"Node.js"]})}),(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/react",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"4%",left:"26%"},children:[(0,I.jsx)("img",{src:"./files/icons/react.svg",alt:"React"}),"React"]})}),(0,I.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"15%",left:"90%",marginLeft:"-35px"},children:[(0,I.jsx)("img",{src:"./files/icons/svelte.svg",alt:"Svelte"}),"Svelte"]}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsx)("br",{}),(0,I.jsxs)("h2",{children:["Flexible ",(0,I.jsx)("b",{className:"underline",children:"storage layer"})]}),(0,I.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,I.jsx)("b",{children:"any JavaScript runtime"})," ","by just switching out the storage settings.",(0,I.jsx)("br",{})]}),(0,I.jsxs)("div",{className:"below-text",children:[(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/electron",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"2%",left:"18%"},children:[(0,I.jsx)("img",{src:"./files/icons/electron.svg",alt:"electron"}),"Electron"]})}),(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/vue",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"3%",left:"45%"},children:[(0,I.jsx)("img",{src:"./files/icons/vuejs.svg",alt:"Vue.js"}),"Vue.js"]})}),(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/ionic2",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"2%",left:"71%"},children:[(0,I.jsx)("img",{src:"./files/icons/ionic.svg",alt:"ionic"}),"Ionic"]})}),(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"46%",left:"11%"},children:[(0,I.jsx)("img",{src:"./files/icons/nativescript.svg",alt:"NativeScript"}),"NativeScript"]}),(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/react-native",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"45%",left:"35%"},children:[(0,I.jsx)("img",{src:"./files/icons/react.svg",alt:"React Native"}),"React Native"]})}),(0,I.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"45%",left:"62%"},children:[(0,I.jsx)("img",{src:"./files/icons/nextjs.svg",alt:"Next.js"}),"Next.js"]}),(0,I.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/flutter",target:"_blank",children:(0,I.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"40%",left:"86%"},children:[(0,I.jsx)("img",{src:"./files/icons/flutter.svg",alt:"Flutter"}),"Flutter"]})})]})]})}),(0,I.jsx)("div",{className:"block fifth dark",children:(0,I.jsx)("div",{className:"content centered",children:(0,I.jsxs)("div",{className:"inner",children:[(0,I.jsxs)("h2",{children:["Trusted and ",(0,I.jsx)("b",{className:"underline",children:"open source"})]}),(0,I.jsxs)("div",{className:"box dark",children:[(0,I.jsx)("img",{src:"files/icons/github-star.svg",alt:"github star"}),(0,I.jsx)("div",{className:"label",children:"Github Stars"}),(0,I.jsx)("a",{className:"value",href:"/code",rel:"noopener",target:"_blank",children:"20172"}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsxs)("div",{className:"box dark",children:[(0,I.jsx)("img",{src:"files/icons/download.svg",alt:"npm downloads"}),(0,I.jsx)("div",{className:"label",children:"npm downloads"}),(0,I.jsx)("a",{className:"value beating-number",href:"https://www.npmjs.com/package/rxdb",rel:"noopener",target:"_blank",children:"238572"}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsx)("div",{className:"clear"}),(0,I.jsxs)("div",{className:"box dark",children:[(0,I.jsx)("img",{src:"files/icons/person.svg",alt:"contributor"}),(0,I.jsx)("div",{className:"label",children:"Contributors"}),(0,I.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/graphs/contributors",rel:"noopener",target:"_blank",children:"211"}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsxs)("div",{className:"box dark",children:[(0,I.jsx)("img",{src:"files/icons/commit.svg",alt:"commit"}),(0,I.jsx)("div",{className:"label",children:"Commits"}),(0,I.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/commits/master",rel:"noopener",target:"_blank",children:"10409"}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsx)("div",{className:"clear"}),(0,I.jsxs)("div",{className:"box dark",children:[(0,I.jsx)("img",{src:"files/icons/gear.svg",alt:"gear"}),(0,I.jsx)("div",{className:"label",children:"RxDB made Projects"}),(0,I.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/network/dependents?package_id=UGFja2FnZS0xODM0NzAyMw%3D%3D",rel:"noopener",target:"_blank",children:"1402"}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsxs)("div",{className:"box dark",children:[(0,I.jsx)("img",{src:"files/icons/twitter.svg",alt:"twitter"}),(0,I.jsx)("div",{className:"label",children:"Twitter followers"}),(0,I.jsx)("a",{className:"value",href:"https://twitter.com/intent/user?screen_name=rxdbjs",rel:"noopener",target:"_blank",children:"2925"}),(0,I.jsx)("div",{className:"clear"})]}),(0,I.jsx)("div",{className:"clear"})]})})}),(0,I.jsx)("div",{className:"block sixth",children:(0,I.jsxs)("div",{className:"content",children:[(0,I.jsx)("h2",{children:"Pricing Models"}),(0,I.jsx)("div",{className:"inner",children:(0,I.jsxs)("div",{className:"buy-options",children:[(0,I.jsx)("div",{className:"buy-option bg-gradient-left-top",children:(0,I.jsxs)("div",{className:"buy-option-inner",children:[(0,I.jsxs)("div",{className:"buy-option-title",children:[(0,I.jsx)("h2",{children:"RxDB Basics"}),(0,I.jsx)("div",{className:"price",children:"Free & Open Source"})]}),(0,I.jsx)("div",{className:"buy-option-features",children:(0,I.jsxs)("ul",{children:[(0,I.jsx)("li",{children:"Basic RxStorages"}),(0,I.jsx)("li",{children:"Realtime Replication"}),(0,I.jsx)("li",{children:"Live Queries"}),(0,I.jsx)("li",{children:"Schema Validation"}),(0,I.jsx)("li",{children:"Multi-Tab Support"}),(0,I.jsx)("li",{children:"Encryption"}),(0,I.jsx)("li",{children:"Compression"})]})}),(0,I.jsx)("a",{href:"/code",target:"_blank",rel:"noopener",children:(0,I.jsx)("div",{className:"buy-option-action bg-top hover-shadow-top",children:"Get the Code"})})]})}),(0,I.jsx)("div",{className:"buy-option bg-gradient-right-top",children:(0,I.jsxs)("div",{className:"buy-option-inner",children:[(0,I.jsxs)("div",{className:"buy-option-title",children:[(0,I.jsx)("h2",{children:"Premium Plugins"}),(0,I.jsx)("div",{className:"price",children:"for professionals to get the most out of RxDB"})]}),(0,I.jsx)("div",{className:"buy-option-features",children:(0,I.jsxs)("ul",{children:[(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-sqlite.html",target:"_blank",children:"SQLite RxStorage"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-opfs.html",target:"_blank",children:"OPFS RxStorage"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-indexeddb.html",target:"_blank",children:"IndexedDB RxStorage"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-memory-synced.html",target:"_blank",children:"Memory-Synced RxStorage"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-sharding.html",target:"_blank",children:"Sharding Plugin"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/query-optimizer.html",target:"_blank",children:"Query Optimizer"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/migration-storage.html",target:"_blank",children:"Storage Migrator"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-localstorage-meta-optimizer.html",target:"_blank",children:"RxStorage Localstorage Meta Optimizer"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-shared-worker.html",target:"_blank",children:"Shared Worker"})}),(0,I.jsx)("li",{children:(0,I.jsx)("a",{href:"https://rxdb.info/rx-storage-worker.html",target:"_blank",children:"Worker"})})]})}),(0,I.jsx)("a",{href:"/premium",children:(0,I.jsx)("div",{className:"buy-option-action bg-middle hover-shadow-middle",children:"Request Premium"})})]})}),(0,I.jsx)("div",{className:"buy-option bg-gradient-left-top",children:(0,I.jsxs)("div",{className:"buy-option-inner",children:[(0,I.jsxs)("div",{className:"buy-option-title",children:[(0,I.jsx)("h2",{children:"Consulting Session"}),(0,I.jsx)("div",{className:"price",children:"fast in person consulting"})]}),(0,I.jsx)("div",{className:"buy-option-features",children:(0,I.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,I.jsx)("br",{}),"You can book this by doing a one-time donation via github sponsors."]})}),(0,I.jsx)("a",{href:"https://github.com/sponsors/pubkey?frequency=one-time&sponsor=pubkey",target:"_blank",onClick:()=>(0,E.h)("consulting_session_request",1.5),children:(0,I.jsx)("div",{className:"buy-option-action bg-bottom hover-shadow-bottom",children:"Book Now"})})]})})]})})]})}),(0,I.jsx)("div",{className:"block last dark",children:(0,I.jsxs)("div",{className:"content",children:[(0,I.jsxs)("h2",{children:["Start using ",(0,I.jsx)("b",{className:"underline",children:"RxDB"})," today"]}),(0,I.jsxs)("div",{className:"buttons full-width",children:[(0,I.jsx)("a",{href:"/quickstart.html",rel:"noopener",target:"_blank",onClick:()=>(0,E.h)("start_now",.4),children:(0,I.jsx)("div",{className:"button get-premium",style:{left:"50%",top:"20%",marginLeft:"-122px"},children:"Start now"})}),(0,I.jsx)("a",{href:"/newsletter",rel:"noopener",target:"_blank",children:(0,I.jsx)("div",{className:"button",style:{left:"25%",marginLeft:"-90px"},children:"Get the Newsletter"})}),(0,I.jsx)("a",{href:"/chat",rel:"noopener",target:"_blank",children:(0,I.jsx)("div",{className:"button",style:{left:"77%",top:"6%",marginLeft:"-70.5px"},children:"Join the Chat"})}),(0,I.jsx)("a",{href:"/premium",children:(0,I.jsx)("div",{className:"button",style:{top:"40%",left:"20%",marginLeft:"-70.5px"},children:"Get Premium"})}),(0,I.jsx)("a",{href:"https://twitter.com/intent/user?screen_name=rxdbjs",rel:"noopener",target:"_blank",onClick:()=>(0,E.h)("follow_twitter",.4),children:(0,I.jsx)("div",{className:"button",style:{top:"44%",left:"73%",marginLeft:"-85px"},children:"Follow on Twitter"})}),(0,I.jsx)("a",{href:"/code",rel:"noopener",target:"_blank",children:(0,I.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"],$=851;function T(){const e=((new Date).getTime()-196e7)/$,t=Math.floor(e);return{ratio:e,period:t,timeToNextPeriod:(e-t)*$}}const B=22,A=-1*B;function M(e){return eB?B:e}function q(){return Math.random()<.5}function L(e,t){let r,a,n=(e=e.slice(0)).length;for(;n;)a=Math.floor(F(t)*n--),r=e[n],e[n]=e[a],e[a]=r,++t;return e}function F(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)}},7810:(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;an,Hb:()=>c,S7:()=>i,Sd:()=>o,dG:()=>a,jw:()=>l,k_:()=>s})},3337:(e,t,r)=>{function a(e,t){if(!e)throw t||(t=""),new Error("ensureNotFalsy() is falsy: "+t);return e}r.d(t,{ZN:()=>a,bz:()=>n});var n={bufferSize:1,refCount:!0}},1753:(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,{$A:()=>i,Dr:()=>s,ND:()=>n,Ve:()=>u,dY:()=>a,em:()=>o,h$:()=>h,vN:()=>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))}},5734:(e,t,r)=>{r.d(t,{t:()=>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/32667c41.12eda0f5.js b/docs/assets/js/32667c41.12eda0f5.js new file mode 100644 index 00000000000..77b440f5c89 --- /dev/null +++ b/docs/assets/js/32667c41.12eda0f5.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[8191],{6895:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>d,contentTitle:()=>i,default:()=>h,frontMatter:()=>o,metadata:()=>s,toc:()=>l});var r=t(4848),a=t(8453);const o={title:"RxDB NoSQL Performance Tips",slug:"nosql-performance-tips.html",description:"Enhance your NoSQL database performance with RxDB creator's tips on bulk operations, query optimization, and efficient use of hooks and plugins, perfect for developers looking to improve speed and efficiency"},i="Performance tips for RxDB and other NoSQL databases",s={id:"nosql-performance-tips",title:"RxDB NoSQL Performance Tips",description:"Enhance your NoSQL database performance with RxDB creator's tips on bulk operations, query optimization, and efficient use of hooks and plugins, perfect for developers looking to improve speed and efficiency",source:"@site/docs/nosql-performance-tips.md",sourceDirName:".",slug:"/nosql-performance-tips.html",permalink:"/nosql-performance-tips.html",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"RxDB NoSQL Performance Tips",slug:"nosql-performance-tips.html",description:"Enhance your NoSQL database performance with RxDB creator's tips on bulk operations, query optimization, and efficient use of hooks and plugins, perfect for developers looking to improve speed and efficiency"},sidebar:"tutorialSidebar",previous:{title:"Plugins",permalink:"/plugins.html"},next:{title:"Third Party Plugins",permalink:"/third-party-plugins.html"}},d={},l=[{value:"Use bulk operations",id:"use-bulk-operations",level:2},{value:"Help the query planner by adding operators that better restrict the index range",id:"help-the-query-planner-by-adding-operators-that-better-restrict-the-index-range",level:2},{value:"Set a specific index",id:"set-a-specific-index",level:2},{value:"Try different ordering of index fields",id:"try-different-ordering-of-index-fields",level:2},{value:"Make a Query "hot" to reduce load",id:"make-a-query-hot-to-reduce-load",level:2},{value:"Store parts of your document data as attachment",id:"store-parts-of-your-document-data-as-attachment",level:2},{value:"Process queries in a worker process",id:"process-queries-in-a-worker-process",level:2},{value:"Use less plugins and hooks",id:"use-less-plugins-and-hooks",level:2}];function c(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",p:"p",pre:"pre",...(0,a.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h1,{id:"performance-tips-for-rxdb-and-other-nosql-databases",children:"Performance tips for RxDB and other NoSQL databases"}),"\n",(0,r.jsx)(n.p,{children:"In this guide, you'll find techniques to improve the performance of RxDB operations and queries. Notice that all your performance optimizations should be done with a correct tracking of the metrics, otherwise you might change stuff into the wrong direction."}),"\n",(0,r.jsx)(n.h2,{id:"use-bulk-operations",children:"Use bulk operations"}),"\n",(0,r.jsx)(n.p,{children:"When you run write operations on multiple documents, make sure you use bulk operations instead of single document operations."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"// wrong \u274c\nfor(const docData of dataAr){\n await myCollection.insert(docData);\n}\n\n// right \u2714\ufe0f\nawait myCollection.bulkInsert(dataAr);\n"})}),"\n",(0,r.jsx)(n.h2,{id:"help-the-query-planner-by-adding-operators-that-better-restrict-the-index-range",children:"Help the query planner by adding operators that better restrict the index range"}),"\n",(0,r.jsx)(n.p,{children:"Often on complex queries, RxDB (and other databases) do not pick the optimal index range when querying a result set.\nYou can add additional restrictive operators to ensure the query runs over a smaller index space and has a better performance."}),"\n",(0,r.jsx)(n.p,{children:"Lets see some examples for different query types."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"/**\n * Adding a restrictive operator for an $or query\n * so that it better limits the index space for the time-field.\n */\nconst orQuery = {\n selector: {\n $or: [\n {\n time: { $gt: 1234 },\n },\n {\n time: { $eg: 1234 },\n user: { $gt: 'foobar' }\n },\n ]\n time: { $gte: 1234 } // <- add restrictive operator\n }\n}\n\n/**\n * Adding a restrictive operator for an $regex query\n * so that it better limits the index space for the user-field.\n * We know that all matching fields start with 'foo' so we can\n * tell the query to use that as lower constraint for the index.\n */\nconst regexQuery = {\n selector: {\n user: {\n $regex: '^foo(.*)0-9$', // a complex regex with a ^ in the beginning\n $gte: 'foo' // <- add restrictive operator\n }\n }\n}\n\n/**\n * Adding a restrictive operator for a query on an enum field.\n * so that it better limits the index space for the time-field.\n */\n\nconst enumQuery = {\n selector: {\n /**\n * Here lets assume our status field has the enum type ['idle', 'in-progress', 'done']\n * so our restrictive operator can exclude all documents with 'done' as status.\n */\n status: {\n $in: {\n 'idle',\n 'in-progress',\n },\n $gt: 'done' // <- add restrictive operator on status\n }\n }\n}\n"})}),"\n",(0,r.jsx)(n.h2,{id:"set-a-specific-index",children:"Set a specific index"}),"\n",(0,r.jsx)(n.p,{children:"Sometime the query planner of the database itself has no chance in picking the best index of the possible given indexes.\nFor queries where performance is very important, you might want to explicitly specify which index must be used."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"const myQuery = myCollection.find({\n selector: {\n /* ... */\n },\n // explicitly specify index\n index: [\n 'fieldA',\n 'fieldB'\n ]\n\n});\n"})}),"\n",(0,r.jsx)(n.h2,{id:"try-different-ordering-of-index-fields",children:"Try different ordering of index fields"}),"\n",(0,r.jsxs)(n.p,{children:["The order of the fields in a compound index is very important for performance. When optimizing index usage, you should try out different orders on the index fields and measure which runs faster. For that it is very important to run tests on real-world data where the distribution of the data is the same as in production.\nFor example when there is a query on a user collection with an ",(0,r.jsx)(n.code,{children:"age"})," and a ",(0,r.jsx)(n.code,{children:"gender"})," field, it depends if the index ",(0,r.jsx)(n.code,{children:"['gender', 'age']"})," performance better as ",(0,r.jsx)(n.code,{children:"['age', 'gender']"})," based on the distribution of data:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"const query = myCollection\n .findOne({\n selector: {\n age: {\n $gt: 18\n },\n gender: {\n $eq: 'm'\n }\n },\n /**\n * Because the developer knows that 50% of the documents are 'male',\n * but only 20% are below age 18,\n * it makes sense to enforce using the ['gender', 'age'] index to improve performance.\n * This could not be known by the query planer which might have chosen ['age', 'gender'] instead.\n */\n index: ['gender', 'age']\n });\n"})}),"\n",(0,r.jsxs)(n.p,{children:["Notice that RxDB has the ",(0,r.jsx)(n.a,{href:"/query-optimizer.html",children:"Query Optimizer Plugin"})," that can be used to automatically find the best indexes."]}),"\n",(0,r.jsx)(n.h2,{id:"make-a-query-hot-to-reduce-load",children:'Make a Query "hot" to reduce load'}),"\n",(0,r.jsxs)(n.p,{children:['Having a query where the up-to-date result set is needed more then once, you might want to make the query "hot" by permanently subscribing to it. This ensures that the query result is kept up to date by RxDB ant the ',(0,r.jsx)(n.a,{href:"https://github.com/pubkey/event-reduce",children:"EventReduce algorithm"})," at any time so that at the moment you need the current results, it has them already."]}),"\n",(0,r.jsx)(n.p,{children:'For example when you use RxDB at Node.js for a webserver, you should use an outer "hot" query instead of running the same query again on every request to a route.'}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"// wrong \u274c\napp.get('/list', (req, res) => {\n const result = await myCollection.find({/* ... */}).exec();\n res.send(JSON.stringify(result));\n});\n\n// right \u2714\ufe0f\nconst query = myCollection.find({/* ... */});\nquery.subscribe(); // <- make it hot\n\napp.get('/list', (req, res) => {\n const result = await query.exec();\n res.send(JSON.stringify(result));\n});\n"})}),"\n",(0,r.jsx)(n.h2,{id:"store-parts-of-your-document-data-as-attachment",children:"Store parts of your document data as attachment"}),"\n",(0,r.jsxs)(n.p,{children:["For in-app databases like RxDB, it does not make sense to partially parse the ",(0,r.jsx)(n.code,{children:"JSON"})," of a document. Instead, always the whole document json is parsed and handled. This has a better performance because ",(0,r.jsx)(n.code,{children:"JSON.parse()"})," in JavaScript directly calls a C++ binding which can parse really fast compared to a partial parsing in JavaScript itself. Also by always having the full document, RxDB can de-duplicate memory caches of document across multiple queries."]}),"\n",(0,r.jsxs)(n.p,{children:["The downside is that very very big documents with a complex structure can increase query time significantly. Documents fields with complex that are mostly not in use, can be move into an ",(0,r.jsx)(n.a,{href:"/rx-attachment.html",children:"attachment"}),". This would lead RxDB to not fetch the attachment data each time the document is loaded from disc. Instead only when explicitly asked for."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"const myDocument = await myCollection.insert({/* ... */});\nconst attachment = await myDocument.putAttachment(\n {\n id: 'otherStuff.json',\n data: createBlob(JSON.stringify({/* ... */}), 'application/json'),\n type: 'application/json'\n }\n);\n"})}),"\n",(0,r.jsx)(n.h2,{id:"process-queries-in-a-worker-process",children:"Process queries in a worker process"}),"\n",(0,r.jsxs)(n.p,{children:["Moving database storage into a WebWorker can significantly improve performance in web applications that use RxDB or similar NoSQL databases. When database operations are executed in the main JavaScript thread, they can block or slow down the User Interface, especially during heavy or complex data operations. By offloading these operations to a WebWorker, you effectively separate the data processing workload from the UI thread. This means the main thread remains free to handle user interactions and render updates without delay, leading to a smoother and more responsive user experience. Additionally, WebWorkers allow for parallel data processing, which can expedite tasks like querying and indexing. This approach not only enhances UI responsiveness but also optimizes overall application performance by leveraging the multi-threading capabilities of modern browsers.\nWith RxDB you can use the ",(0,r.jsx)(n.a,{href:"/rx-storage-worker.html",children:"Worker"})," and ",(0,r.jsx)(n.a,{href:"/rx-storage-shared-worker.html",children:"SharedWorker"})," plugin to to move the query processing away from the main thread."]}),"\n",(0,r.jsx)(n.h2,{id:"use-less-plugins-and-hooks",children:"Use less plugins and hooks"}),"\n",(0,r.jsxs)(n.p,{children:["Utilizing fewer ",(0,r.jsx)(n.a,{href:"/middleware.html",children:"hooks"})," and plugins in RxDB or similar NoSQL database systems can lead to markedly better performance. Each additional hook or plugin introduces extra layers of processing and potential overhead, which can cumulatively slow down database operations. These extensions often execute additional code or enforce extra checks with each operation, such as insertions, updates, or deletions. While they can provide valuable functionalities or custom behaviors, their overuse can inadvertently increase the complexity and execution time of basic database operations. By minimizing their use and only employing essential hooks and plugins, the system can operate more efficiently. This streamlined approach reduces the computational burden on each transaction, leading to faster response times and a more efficient overall data handling process, especially critical in high-load or real-time applications where performance is paramount."]})]})}function h(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(c,{...e})}):c(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>s});var r=t(6540);const a={},o=r.createContext(a);function i(e){const n=r.useContext(o);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:i(e.components),r.createElement(o.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/docs/assets/js/32667c41.15f9ac4c.js b/docs/assets/js/32667c41.15f9ac4c.js deleted file mode 100644 index b08dc5cbbe2..00000000000 --- a/docs/assets/js/32667c41.15f9ac4c.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[8191],{6895:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>d,contentTitle:()=>i,default:()=>h,frontMatter:()=>o,metadata:()=>s,toc:()=>l});var r=t(4848),a=t(8453);const o={title:"RxDB NoSQL Performance Tips",slug:"nosql-performance-tips.html",description:"Enhance your NoSQL database performance with RxDB creator's tips on bulk operations, query optimization, and efficient use of hooks and plugins, perfect for developers looking to improve speed and efficiency"},i="Performance tips for RxDB and other NoSQL databases",s={id:"nosql-performance-tips",title:"RxDB NoSQL Performance Tips",description:"Enhance your NoSQL database performance with RxDB creator's tips on bulk operations, query optimization, and efficient use of hooks and plugins, perfect for developers looking to improve speed and efficiency",source:"@site/docs/nosql-performance-tips.md",sourceDirName:".",slug:"/nosql-performance-tips.html",permalink:"/nosql-performance-tips.html",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"RxDB NoSQL Performance Tips",slug:"nosql-performance-tips.html",description:"Enhance your NoSQL database performance with RxDB creator's tips on bulk operations, query optimization, and efficient use of hooks and plugins, perfect for developers looking to improve speed and efficiency"},sidebar:"tutorialSidebar",previous:{title:"Plugins",permalink:"/plugins.html"},next:{title:"Third Party Plugins",permalink:"/third-party-plugins.html"}},d={},l=[{value:"Use bulk operations",id:"use-bulk-operations",level:2},{value:"Help the query planner by adding operators that better restrict the index range",id:"help-the-query-planner-by-adding-operators-that-better-restrict-the-index-range",level:2},{value:"Set a specific index",id:"set-a-specific-index",level:2},{value:"Try different ordering of index fields",id:"try-different-ordering-of-index-fields",level:2},{value:"Make a Query "hot" to reduce load",id:"make-a-query-hot-to-reduce-load",level:2},{value:"Store parts of your document data as attachment",id:"store-parts-of-your-document-data-as-attachment",level:2},{value:"Process queries in a worker process",id:"process-queries-in-a-worker-process",level:2},{value:"Use less plugins and hooks",id:"use-less-plugins-and-hooks",level:2}];function c(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",p:"p",pre:"pre",...(0,a.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h1,{id:"performance-tips-for-rxdb-and-other-nosql-databases",children:"Performance tips for RxDB and other NoSQL databases"}),"\n",(0,r.jsx)(n.p,{children:"In this guide, you'll find techniques to improve the performance of RxDB operations and queries. Notice that all your performance optimizations should be done with a correct tracking of the metrics, otherwise you might change stuff into the wrong direction."}),"\n",(0,r.jsx)(n.h2,{id:"use-bulk-operations",children:"Use bulk operations"}),"\n",(0,r.jsx)(n.p,{children:"When you run write operations on multiple documents, make sure you use bulk operations instead of single document operations."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"// wrong \u274c\nfor(const docData of dataAr){\n await myCollection.insert(docData);\n}\n\n// right \u2714\ufe0f\nawait myCollection.bulkInsert(dataAr);\n"})}),"\n",(0,r.jsx)(n.h2,{id:"help-the-query-planner-by-adding-operators-that-better-restrict-the-index-range",children:"Help the query planner by adding operators that better restrict the index range"}),"\n",(0,r.jsx)(n.p,{children:"Often on complex queries, RxDB (and other databases) do not pick the optimal index range when querying a result set.\nYou can add additional restrictive operators to ensure the query runs over a smaller index space and has a better performance."}),"\n",(0,r.jsx)(n.p,{children:"Lets see some examples for different query types."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"/**\n * Adding a restrictive operator for an $or query\n * so that it better limits the index space for the time-field.\n */\nconst orQuery = {\n selector: {\n $or: [\n {\n time: { $gt: 1234 },\n },\n {\n time: { $eg: 1234 },\n user: { $gt: 'foobar' }\n },\n ]\n time: { $gt: 1234 } // <- add restrictive operator\n }\n}\n\n/**\n * Adding a restrictive operator for an $regex query\n * so that it better limits the index space for the user-field.\n * We know that all matching fields start with 'foo' so we can\n * tell the query to use that as lower constraint for the index.\n */\nconst regexQuery = {\n selector: {\n user: {\n $regex: '^foo(.*)0-9$', // a complex regex with a ^ in the beginning\n $gt: 'foo' // <- add restrictive operator\n }\n }\n}\n\n/**\n * Adding a restrictive operator for a query on an enum field.\n * so that it better limits the index space for the time-field.\n */\n\nconst enumQuery = {\n selector: {\n /**\n * Here lets assume our status field has the enum type ['idle', 'in-progress', 'done']\n * so our restrictive operator can exclude all documents with 'done' as status.\n */\n status: {\n $in: {\n 'idle',\n 'in-progress',\n },\n $gt: 'done' // <- add restrictive operator on status\n }\n }\n}\n"})}),"\n",(0,r.jsx)(n.h2,{id:"set-a-specific-index",children:"Set a specific index"}),"\n",(0,r.jsx)(n.p,{children:"Sometime the query planner of the database itself has no chance in picking the best index of the possible given indexes.\nFor queries where performance is very important, you might want to explicitly specify which index must be used."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"const myQuery = myCollection.find({\n selector: {\n /* ... */\n },\n // explicitly specify index\n index: [\n 'fieldA',\n 'fieldB'\n ]\n\n});\n"})}),"\n",(0,r.jsx)(n.h2,{id:"try-different-ordering-of-index-fields",children:"Try different ordering of index fields"}),"\n",(0,r.jsxs)(n.p,{children:["The order of the fields in a compound index is very important for performance. When optimizing index usage, you should try out different orders on the index fields and measure which runs faster. For that it is very important to run tests on real-world data where the distribution of the data is the same as in production.\nFor example when there is a query on a user collection with an ",(0,r.jsx)(n.code,{children:"age"})," and a ",(0,r.jsx)(n.code,{children:"gender"})," field, it depends if the index ",(0,r.jsx)(n.code,{children:"['gender', 'age']"})," performance better as ",(0,r.jsx)(n.code,{children:"['age', 'gender']"})," based on the distribution of data:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"const query = myCollection\n .findOne({\n selector: {\n age: {\n $gt: 18\n },\n gender: {\n $eq: 'm'\n }\n },\n /**\n * Because the developer knows that 50% of the documents are 'male',\n * but only 20% are below age 18,\n * it makes sense to enforce using the ['gender', 'age'] index to improve performance.\n * This could not be known by the query planer which might have chosen ['age', 'gender'] instead.\n */\n index: ['gender', 'age']\n });\n"})}),"\n",(0,r.jsxs)(n.p,{children:["Notice that RxDB has the ",(0,r.jsx)(n.a,{href:"/query-optimizer.html",children:"Query Optimizer Plugin"})," that can be used to automatically find the best indexes."]}),"\n",(0,r.jsx)(n.h2,{id:"make-a-query-hot-to-reduce-load",children:'Make a Query "hot" to reduce load'}),"\n",(0,r.jsxs)(n.p,{children:['Having a query where the up-to-date result set is needed more then once, you might want to make the query "hot" by permanently subscribing to it. This ensures that the query result is kept up to date by RxDB ant the ',(0,r.jsx)(n.a,{href:"https://github.com/pubkey/event-reduce",children:"EventReduce algorithm"})," at any time so that at the moment you need the current results, it has them already."]}),"\n",(0,r.jsx)(n.p,{children:'For example when you use RxDB at Node.js for a webserver, you should use an outer "hot" query instead of running the same query again on every request to a route.'}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"// wrong \u274c\napp.get('/list', (req, res) => {\n const result = await myCollection.find({/* ... */}).exec();\n res.send(JSON.stringify(result));\n});\n\n// right \u2714\ufe0f\nconst query = myCollection.find({/* ... */});\nquery.subscribe(); // <- make it hot\n\napp.get('/list', (req, res) => {\n const result = await query.exec();\n res.send(JSON.stringify(result));\n});\n"})}),"\n",(0,r.jsx)(n.h2,{id:"store-parts-of-your-document-data-as-attachment",children:"Store parts of your document data as attachment"}),"\n",(0,r.jsxs)(n.p,{children:["For in-app databases like RxDB, it does not make sense to partially parse the ",(0,r.jsx)(n.code,{children:"JSON"})," of a document. Instead, always the whole document json is parsed and handled. This has a better performance because ",(0,r.jsx)(n.code,{children:"JSON.parse()"})," in JavaScript directly calls a C++ binding which can parse really fast compared to a partial parsing in JavaScript itself. Also by always having the full document, RxDB can de-duplicate memory caches of document across multiple queries."]}),"\n",(0,r.jsxs)(n.p,{children:["The downside is that very very big documents with a complex structure can increase query time significantly. Documents fields with complex that are mostly not in use, can be move into an ",(0,r.jsx)(n.a,{href:"/rx-attachment.html",children:"attachment"}),". This would lead RxDB to not fetch the attachment data each time the document is loaded from disc. Instead only when explicitly asked for."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"const myDocument = await myCollection.insert({/* ... */});\nconst attachment = await myDocument.putAttachment(\n {\n id: 'otherStuff.json',\n data: createBlob(JSON.stringify({/* ... */}), 'application/json'),\n type: 'application/json'\n }\n);\n"})}),"\n",(0,r.jsx)(n.h2,{id:"process-queries-in-a-worker-process",children:"Process queries in a worker process"}),"\n",(0,r.jsxs)(n.p,{children:["Moving database storage into a WebWorker can significantly improve performance in web applications that use RxDB or similar NoSQL databases. When database operations are executed in the main JavaScript thread, they can block or slow down the User Interface, especially during heavy or complex data operations. By offloading these operations to a WebWorker, you effectively separate the data processing workload from the UI thread. This means the main thread remains free to handle user interactions and render updates without delay, leading to a smoother and more responsive user experience. Additionally, WebWorkers allow for parallel data processing, which can expedite tasks like querying and indexing. This approach not only enhances UI responsiveness but also optimizes overall application performance by leveraging the multi-threading capabilities of modern browsers.\nWith RxDB you can use the ",(0,r.jsx)(n.a,{href:"/rx-storage-worker.html",children:"Worker"})," and ",(0,r.jsx)(n.a,{href:"/rx-storage-shared-worker.html",children:"SharedWorker"})," plugin to to move the query processing away from the main thread."]}),"\n",(0,r.jsx)(n.h2,{id:"use-less-plugins-and-hooks",children:"Use less plugins and hooks"}),"\n",(0,r.jsxs)(n.p,{children:["Utilizing fewer ",(0,r.jsx)(n.a,{href:"/middleware.html",children:"hooks"})," and plugins in RxDB or similar NoSQL database systems can lead to markedly better performance. Each additional hook or plugin introduces extra layers of processing and potential overhead, which can cumulatively slow down database operations. These extensions often execute additional code or enforce extra checks with each operation, such as insertions, updates, or deletions. While they can provide valuable functionalities or custom behaviors, their overuse can inadvertently increase the complexity and execution time of basic database operations. By minimizing their use and only employing essential hooks and plugins, the system can operate more efficiently. This streamlined approach reduces the computational burden on each transaction, leading to faster response times and a more efficient overall data handling process, especially critical in high-load or real-time applications where performance is paramount."]})]})}function h(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(c,{...e})}):c(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>s});var r=t(6540);const a={},o=r.createContext(a);function i(e){const n=r.useContext(o);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:i(e.components),r.createElement(o.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/docs/assets/js/5106.4acc95d1.js b/docs/assets/js/5106.839e1170.js similarity index 55% rename from docs/assets/js/5106.4acc95d1.js rename to docs/assets/js/5106.839e1170.js index b78cb9bae7b..7fc385fc006 100644 --- a/docs/assets/js/5106.4acc95d1.js +++ b/docs/assets/js/5106.839e1170.js @@ -1 +1 @@ -(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[5106],{7635:(e,t,n)=>{"use strict";n.d(t,{G:()=>r});var r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this._parallels=e||1,this._qC=0,this._iC=new Set,this._lHN=0,this._hPM=new Map,this._pHM=new Map};function o(e,t){if(t){if(t._timeoutObj&&clearTimeout(t._timeoutObj),e._pHM.has(t)){var n=e._pHM.get(t);e._hPM.delete(n),e._pHM.delete(t)}e._iC.delete(t)}}function i(e){e._tryIR||0===e._iC.size||(e._tryIR=!0,setTimeout((function(){e.isIdle()?setTimeout((function(){e.isIdle()?(!function(e){0!==e._iC.size&&(e._iC.values().next().value._manRes(),setTimeout((function(){return i(e)}),0))}(e),e._tryIR=!1):e._tryIR=!1}),0):e._tryIR=!1}),0))}r.prototype={isIdle:function(){return this._qC.",et="String expected.",tt=[],nt="__dbnames",rt="readonly",ot="readwrite";function it(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var st={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function ut(e){return"string"!=typeof e||/\./.test(e)?function(e){return e}:function(t){return void 0===t[e]&&e in t&&delete(t=j(t))[e],t}}function at(){throw W.Type()}function ct(e,t){try{var n=lt(e),r=lt(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return ti+s&&o(i+d)}))}))}return o(0).then((function(){if(0=o}))).length?(t.forEach((function(e){c.push((function(){var t=l,n=e._cfg.dbschema;ln(r,t,a),ln(r,n,a),l=r._dbSchema=n;var s=on(t,n);s.add.forEach((function(e){sn(a,e[0],e[1].primKey,e[1].indexes)})),s.change.forEach((function(e){if(e.recreate)throw new W.Upgrade("Not yet support for changing primary key");var t=a.objectStore(e.name);e.add.forEach((function(e){return an(t,e)})),e.change.forEach((function(e){t.deleteIndex(e.name),an(t,e)})),e.del.forEach((function(e){return t.deleteIndex(e)}))}));var c=e._cfg.contentUpgrade;if(c&&e._cfg.version>o){Jt(r,a),u._memoizedTables={};var f=O(n);s.del.forEach((function(e){f[e]=t[e]})),en(r,[r.Transaction.prototype]),Zt(r,[r.Transaction.prototype],i(f),f),u.schema=f;var h,d=N(c);return d&&$e(),s=xe.follow((function(){var e;(h=c(u))&&d&&(e=Ue.bind(null,null),h.then(e,e))})),h&&"function"==typeof h.then?xe.resolve(h):s.then((function(){return h}))}})),c.push((function(t){var n,o,i=e._cfg.dbschema;n=i,o=t,[].slice.call(o.db.objectStoreNames).forEach((function(e){return null==n[e]&&o.db.deleteObjectStore(e)})),en(r,[r.Transaction.prototype]),Zt(r,[r.Transaction.prototype],r._storeNames,r._dbSchema),u.schema=r._dbSchema})),c.push((function(t){r.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(r.idbdb.version/10)===e._cfg.version?(r.idbdb.deleteObjectStore("$meta"),delete r._dbSchema.$meta,r._storeNames=r._storeNames.filter((function(e){return"$meta"!==e}))):t.objectStore("$meta").put(e._cfg.version,"version"))}))})),function e(){return c.length?xe.resolve(c.shift()(u.idbtrans)).then(e):xe.resolve()}().then((function(){un(l,a)}))):xe.resolve();var r,o,u,a,c,l})).catch(u)):(i(o).forEach((function(e){sn(n,e,o[e].primKey,o[e].indexes)})),Jt(e,n),void xe.follow((function(){return e.on.populate.fire(s)})).catch(u));var r,c}))}function rn(e,t){un(e._dbSchema,t),t.db.version%10!=0||t.objectStoreNames.contains("$meta")||t.db.createObjectStore("$meta").add(Math.ceil(t.db.version/10-1),"version");var n=cn(0,e.idbdb,t);ln(e,e._dbSchema,t);for(var r=0,o=on(n,e._dbSchema).change;rMath.pow(2,62)?0:r.oldVersion,h=r<1,e.idbdb=d.result,s&&rn(e,f),nn(e,r/10,f,c))}),c),d.onsuccess=De((function(){f=null;var n,u,c,p,y,v=e.idbdb=d.result,b=m(v.objectStoreNames);if(0t.limit?n.length=t.limit:e.length===t.limit&&n.length=r.limit&&(!r.values||e.req.values)&&Yn(e.req.query.range,r.query.range)})),!1,o,i];case"count":return s=i.find((function(e){return Xn(e.req.query.range,r.query.range)})),[s,!!s,o,i]}}(n,r,"query",e),a=u[0],c=u[1],l=u[2],f=u[3];return a&&c?a.obsSet=e.obsSet:(c=o.query(e).then((function(e){var n=e.result;if(a&&(a.res=n),t){for(var r=0,o=n.length;r{"use strict";n.d(t,{u:()=>s});var r=n(2779),o=n(374),i=n(744);class s{constructor(e,t){this.pipeline=e,this.options=(0,r.B3)(t)}stream(e){let t=(0,o.dF)(e);const n=this.options.processingMode;n!=r.to.CLONE_ALL&&n!=r.to.CLONE_INPUT||t.map(i.mg);const s=new Array;if(!(0,i.Im)(this.pipeline))for(const o of this.pipeline){const e=Object.keys(o),n=e[0],u=(0,r.F5)(r.hu.PIPELINE,n,this.options);(0,i.vA)(1===e.length&&!!u,`invalid pipeline operator ${n}`),s.push(n),t=u(t,o[n],this.options)}return(n==r.to.CLONE_OUTPUT||n==r.to.CLONE_ALL&&(0,i.E$)([["$group","$unwind"],s]).length)&&t.map(i.mg),t}run(e){return this.stream(e).value()}}},2779:(e,t,n)=>{"use strict";n.d(t,{B3:()=>u,DZ:()=>l,F5:()=>f,hu:()=>o,px:()=>p,qk:()=>s,to:()=>r});var r,o,i=n(744);!function(e){e.CLONE_ALL="CLONE_ALL",e.CLONE_INPUT="CLONE_INPUT",e.CLONE_OUTPUT="CLONE_OUTPUT",e.CLONE_OFF="CLONE_OFF"}(r||(r={}));class s{constructor(e,t,n,r=Date.now()){this._opts=e,this._root=t,this._local=n,this.timestamp=r,this.update(t,n)}static init(e,t,n){return e instanceof s?new s(e._opts,(0,i.gD)(e.root)?t:e.root,Object.assign({},e.local,n)):new s(e,t,n)}update(e,t){var n;return this._root=e,this._local=t?Object.assign({},t,{variables:Object.assign({},null===(n=this._local)||void 0===n?void 0:n.variables,null==t?void 0:t.variables)}):t,this}getOptions(){return Object.freeze(Object.assign(Object.assign({},this._opts),{context:a.from(this._opts.context)}))}get root(){return this._root}get local(){return this._local}get idKey(){return this._opts.idKey}get collation(){var e;return null===(e=this._opts)||void 0===e?void 0:e.collation}get processingMode(){var e;return(null===(e=this._opts)||void 0===e?void 0:e.processingMode)||r.CLONE_OFF}get useStrictMode(){var e;return null===(e=this._opts)||void 0===e?void 0:e.useStrictMode}get scriptEnabled(){var e;return null===(e=this._opts)||void 0===e?void 0:e.scriptEnabled}get useGlobalContext(){var e;return null===(e=this._opts)||void 0===e?void 0:e.useGlobalContext}get hashFunction(){var e;return null===(e=this._opts)||void 0===e?void 0:e.hashFunction}get collectionResolver(){var e;return null===(e=this._opts)||void 0===e?void 0:e.collectionResolver}get jsonSchemaValidator(){var e;return null===(e=this._opts)||void 0===e?void 0:e.jsonSchemaValidator}get variables(){var e;return null===(e=this._opts)||void 0===e?void 0:e.variables}get context(){var e;return null===(e=this._opts)||void 0===e?void 0:e.context}}function u(e){return e instanceof s?e.getOptions():Object.freeze(Object.assign(Object.assign({idKey:"_id",scriptEnabled:!0,useStrictMode:!0,useGlobalContext:!0,processingMode:r.CLONE_OFF},e),{context:(null==e?void 0:e.context)?a.from(null==e?void 0:e.context):a.init({})}))}!function(e){e.ACCUMULATOR="accumulator",e.EXPRESSION="expression",e.PIPELINE="pipeline",e.PROJECTION="projection",e.QUERY="query",e.WINDOW="window"}(o||(o={}));class a{constructor(e){this.operators={[o.ACCUMULATOR]:{},[o.EXPRESSION]:{},[o.PIPELINE]:{},[o.PROJECTION]:{},[o.QUERY]:{},[o.WINDOW]:{}};for(const[t,n]of Object.entries(e))this.addOperators(t,n)}static init(e={}){return new a(e)}static from(e){return new a(e.operators)}addOperators(e,t){for(const[n,r]of Object.entries(t))this.getOperator(e,n)||(this.operators[e][n]=r);return this}addAccumulatorOps(e){return this.addOperators(o.ACCUMULATOR,e)}addExpressionOps(e){return this.addOperators(o.EXPRESSION,e)}addQueryOps(e){return this.addOperators(o.QUERY,e)}addPipelineOps(e){return this.addOperators(o.PIPELINE,e)}addProjectionOps(e){return this.addOperators(o.PROJECTION,e)}addWindowOps(e){return this.addOperators(o.WINDOW,e)}getOperator(e,t){return e in this.operators&&this.operators[e][t]||null}}const c=a.init();function l(e,t){for(const[n,r]of Object.entries(t)){(0,i.vA)((0,i.Tn)(r)&&(0,i.Zo)(n),`'${n}' is not a valid operator`);const t=f(e,n,null);(0,i.vA)(!t||r===t,`${n} already exists for '${e}' operators. Cannot change operator function once registered.`)}switch(e){case o.ACCUMULATOR:c.addAccumulatorOps(t);break;case o.EXPRESSION:c.addExpressionOps(t);break;case o.PIPELINE:c.addPipelineOps(t);break;case o.PROJECTION:c.addProjectionOps(t);break;case o.QUERY:c.addQueryOps(t);break;case o.WINDOW:c.addWindowOps(t)}}function f(e,t,n){const{context:r,useGlobalContext:o}=n||{},i=r?r.getOperator(e,t):null;return!i&&o?c.getOperator(e,t):i}const h={$$ROOT:(e,t,n)=>n.root,$$CURRENT:(e,t,n)=>e,$$REMOVE(e,t,n){},$$NOW:(e,t,n)=>new Date(n.timestamp)},d={$$KEEP:(e,t,n)=>e,$$PRUNE(e,t,n){},$$DESCEND(e,t,n){if(!(0,i.zy)(t,"$cond"))return e;let r;for(const[o,s]of Object.entries(e))if((0,i.Z4)(s)){if(s instanceof Array){const e=[];for(let r of s)(0,i.Gv)(r)&&(r=y(r,t,n.update(r))),(0,i.gD)(r)||e.push(r);r=e}else r=y(s,t,n.update(s));(0,i.gD)(r)?delete e[o]:e[o]=r}return e}};function p(e,t,n,r){var u;const a=s.init(r,e);if(n=n||"",(0,i.Zo)(n)){const s=f(o.EXPRESSION,n,r);if(s)return s(e,t,a);const u=f(o.ACCUMULATOR,n,r);if(u)return e instanceof Array||(e=p(e,t,null,a),t=null),(0,i.vA)(e instanceof Array,`'${n}' target must be an array.`),u(e,t,a.update(null,a.local));throw new Error(`operator '${n}' is not registered`)}if((0,i.Kg)(t)&&t.length>0&&"$"===t[0]){if((0,i.zy)(d,t))return t;let n=a.root;const r=t.split(".");if((0,i.zy)(h,r[0]))n=h[r[0]](e,null,a),t=t.slice(r[0].length+1);else if("$$"===r[0].slice(0,2)){n=Object.assign({},a.variables,{this:e},null===(u=a.local)||void 0===u?void 0:u.variables);const o=r[0].slice(2);(0,i.vA)((0,i.zy)(n,o),`Use of undefined variable: ${o}`),t=t.slice(2)}else t=t.slice(1);return""===t?n:(0,i.hd)(n,t)}if((0,i.cy)(t))return t.map((t=>p(e,t,null,a)));if((0,i.Gv)(t)){const n={};for(const[s,u]of Object.entries(t))if(n[s]=p(e,u,s,a),[o.EXPRESSION,o.ACCUMULATOR].some((e=>!!f(e,s,r))))return(0,i.vA)(1===Object.keys(t).length,"Invalid aggregation expression '"+JSON.stringify(t)+"'"),n[s];return n}return t}function y(e,t,n){const r=p(e,t,null,n);return(0,i.zy)(d,r)?d[r](e,t,n):r}},374:(e,t,n)=>{"use strict";function r(e){return e instanceof a?e:new a(e)}function o(...e){let t=0;return r((()=>{for(;to,dF:()=>r});const s=new Error;var u;!function(e){e[e.MAP=0]="MAP",e[e.FILTER=1]="FILTER",e[e.TAKE=2]="TAKE",e[e.DROP=3]="DROP"}(u||(u={}));class a{constructor(e){let t;if(this.iteratees=[],this.yieldedValues=[],this.isDone=!1,e instanceof Function&&(e={next:e}),(n=e)&&"object"==typeof n&&(null==n?void 0:n.next)instanceof Function){const n=e;t=()=>{const e=n.next();if(e.done)throw s;return e.value}}else if(e instanceof Array){const n=e,r=n.length;let o=0;t=()=>{if(o0?this.push(u.TAKE,e):this}drop(e){return e>0?this.push(u.DROP,e):this}transform(e){const t=this;let n;return r((()=>(n||(n=r(e(t.value()))),n.next())))}value(){return this.isDone||(this.isDone=this.getNext(!0).done),this.yieldedValues}each(e){for(;;){const t=this.next();if(t.done)break;if(!1===e(t.value))return!1}return!0}reduce(e,t){let n=this.next();for(void 0!==t||n.done||(t=n.value,n=this.next());!n.done;)t=e(t,n.value),n=this.next();return t}size(){return this.reduce(((e,t)=>++e),0)}[Symbol.iterator](){return this}}},6827:(e,t,n)=>{"use strict";n.d(t,{C5:()=>c,GU:()=>f,Gd:()=>g,Ig:()=>w,Jy:()=>x,MR:()=>p,NV:()=>h,P:()=>b,Pp:()=>v,Q_:()=>d,TU:()=>A,WP:()=>m,XV:()=>a,fw:()=>u,fy:()=>y,jm:()=>s,oZ:()=>l});var r=n(2779),o=n(1692),i=n(744);function s(e){const t=(t,n,r)=>{const o={unwrapArray:!0},s=Math.max(1,t.split(".").length-1);return u=>{const a=(0,i.hd)(u,t,o);return e(a,n,Object.assign(Object.assign({},r),{depth:s}))}};return t.op="query",t}function u(e){return(t,n,o)=>{const i=(0,r.px)(t,n,null,o);return e(...i)}}function a(e,t,n){if((0,i.n4)(e,t))return!0;if((0,i.gD)(e)&&(0,i.gD)(t))return!0;if(e instanceof Array){const r=i.n4.bind(null,t);return e.some(r)||(0,i.Bq)(e,null==n?void 0:n.depth).some(r)}return!1}function c(e,t,n){return!a(e,t,n)}function l(e,t,n){return(0,i.gD)(e)?t.some((e=>null===e)):(0,i.E$)([(0,i.eC)(e),t],null==n?void 0:n.hashFunction).length>0}function f(e,t,n){return!l(e,t,n)}function h(e,t,n){return j(e,t,((e,t)=>(0,i.UD)(e,t)<0))}function d(e,t,n){return j(e,t,((e,t)=>(0,i.UD)(e,t)<=0))}function p(e,t,n){return j(e,t,((e,t)=>(0,i.UD)(e,t)>0))}function y(e,t,n){return j(e,t,((e,t)=>(0,i.UD)(e,t)>=0))}function v(e,t,n){return(0,i.eC)(e).some((e=>2===t.length&&e%t[0]===t[1]))}function m(e,t,n){const r=(0,i.eC)(e),o=e=>(0,i.Kg)(e)&&(0,i.vN)(t.exec(e),null==n?void 0:n.useStrictMode);return r.some(o)||(0,i.Bq)(r,1).some(o)}function b(e,t,n){return(!1===t||0===t)&&void 0===e||(!0===t||1===t)&&void 0!==e}function g(e,t,n){if(!((0,i.cy)(e)&&(0,i.cy)(t)&&e.length&&t.length))return!1;let r=!0;for(const o of t){if(!r)break;r=(0,i.Gv)(o)&&(0,i.RV)(Object.keys(o),"$elemMatch")?x(e,o.$elemMatch,n):o instanceof RegExp?e.some((e=>"string"==typeof e&&o.test(e))):e.some((e=>(0,i.n4)(o,e)))}return r}function w(e,t,n){return Array.isArray(e)&&e.length===t}function _(e){return(0,i.Zo)(e)&&-1===["$and","$or","$nor"].indexOf(e)}function x(e,t,n){if((0,i.cy)(e)&&!(0,i.Im)(e)){let r=e=>e,i=t;Object.keys(t).every(_)&&(i={temp:t},r=e=>({temp:e}));const s=new o.X(i,n);for(let t=0,n=e.length;tnull===e,k=e=>(0,i.Et)(e)&&e>=i.R&&e<=i.Hq&&-1===e.toString().indexOf("."),E=e=>(0,i.Et)(e)&&e>=i.oU&&e<=i.W_&&-1===e.toString().indexOf("."),P={array:i.cy,bool:i.Lm,boolean:i.Lm,date:i.$P,decimal:i.Et,double:i.Et,int:k,long:E,number:i.Et,null:O,object:i.Gv,regex:i.gd,regexp:i.gd,string:i.Kg,undefined:i.gD,function:e=>{throw new Error("unsupported type key `function`.")},1:i.Et,2:i.Kg,3:i.Gv,4:i.cy,6:i.gD,8:i.Lm,9:i.$P,10:O,11:i.gd,16:k,18:E,19:i.Et};function S(e,t,n){const r=P[t];return!!r&&r(e)}function A(e,t,n){return Array.isArray(t)?t.findIndex((t=>S(e,t)))>=0:S(e,t)}function j(e,t,n){return(0,i.eC)(e).some((e=>(0,i.Pw)(e)===(0,i.Pw)(t)&&n(e,t)))}},4903:(e,t,n)=>{"use strict";n.d(t,{C2:()=>p,xF:()=>i});var r=n(2779),o=n(744);n(374);n(7681);new WeakMap;const i=(e,t,n)=>{if((0,o.Im)(t)||!(0,o.Gv)(t))return e;let r=o.UD;const i=n.collation;return(0,o.Gv)(i)&&(0,o.Kg)(i.locale)&&(r=function(e){const t={sensitivity:s[e.strength||3],caseFirst:"off"===e.caseFirst?"false":e.caseFirst||"false",numeric:e.numericOrdering||!1,ignorePunctuation:"shifted"===e.alternate};!0===(e.caseLevel||!1)&&("base"===t.sensitivity&&(t.sensitivity="case"),"accent"===t.sensitivity&&(t.sensitivity="variant"));const n=new Intl.Collator(e.locale,t);return(e,t)=>{if(!(0,o.Kg)(e)||!(0,o.Kg)(t))return(0,o.UD)(e,t);const r=n.compare(e,t);return r<0?-1:r>0?1:0}}(i)),e.transform((e=>{const i=Object.keys(t);for(const s of i.reverse()){const i=(0,o.$z)(e,(e=>(0,o.hd)(e,s)),n.hashFunction),u=Array.from(i.keys()).sort(r);-1===t[s]&&u.reverse(),e=[],u.reduce(((e,t)=>(0,o.dj)(e,i.get(t))),e)}return e}))},s={1:"base",2:"accent",3:"variant"};new Set(["$denseRank","$documentNumber","$first","$last","$linearFill","$rank","$shift"]),new Set(["$denseRank","$expMovingAvg","$linearFill","$locf","$rank","$shift"]);n(1692);var u=n(6827);(0,u.fw)(u.GU);const a=(e,t)=>(n,i,s)=>{(0,o.vA)((0,o.cy)(i),`${e}: expression must be an array.`);const u=(0,r.px)(n,i,null,s);return u.some(o.gD)?null:((0,o.vA)(u.every(o.Et),`${e}: expression must evalue to array of numbers.`),t(u))};a("$bitAnd",(e=>e.reduce(((e,t)=>e&t),-1))),a("$bitOr",(e=>e.reduce(((e,t)=>e|t),0))),a("$bitXor",(e=>e.reduce(((e,t)=>e^t),0))),(0,u.fw)(u.XV),(0,u.fw)(u.MR),(0,u.fw)(u.fy),(0,u.fw)(u.NV),(0,u.fw)(u.Q_),(0,u.fw)(u.C5);const c=(e,t)=>{const n={};return e.split("").forEach(((e,r)=>n[e]=t*(r+1))),n};Object.assign(Object.assign(Object.assign({},c("ABCDEFGHIKLM",1)),c("NOPQRSTUVWXY",-1)),{Z:0});const l={undefined:null,null:null,NaN:NaN,Infinity:new Error,"-Infinity":new Error};function f(e,t=l){const n=Object.assign({},l,t),o=new Set(Object.keys(n));return(t,i,s)=>{const u=(0,r.px)(t,i,null,s);if(o.has(`${u}`)){const t=n[`${u}`];if(t instanceof Error)throw new Error(`cannot apply $${e.name} to -inf, value must in (-inf,inf)`);return t}return e(u)}}f(Math.acos,{Infinity:1/0,0:new Error}),f(Math.acosh,{Infinity:1/0,0:new Error}),f(Math.asin),f(Math.asinh,{Infinity:1/0,"-Infinity":-1/0}),f(Math.atan),f(Math.atanh,{1:1/0,"-1":-1/0}),f(Math.cos),f(Math.cosh,{"-Infinity":1/0,Infinity:1/0});const h=Math.PI/180,d=(f((e=>e*h),{Infinity:1/0,"-Infinity":1/0}),180/Math.PI);f((e=>e*d),{Infinity:1/0,"-Infinity":-1/0}),f(Math.sin),f(Math.sinh,{"-Infinity":-1/0,Infinity:1/0}),f(Math.tan);Error;const p=(e,t,n)=>{if((0,o.Im)(t))return e;let i=Object.keys(t),s=!1;v(t,n);const u=n.idKey;if((0,o.RV)(i,u)){const e=t[u];0!==e&&!1!==e||(i=i.filter(o.KL.bind(null,[u])),s=0==i.length)}else i.push(u);const a=r.qk.init(n);return e.map((e=>y(e,t,a.update(e),i,s)))};function y(e,t,n,i,s){let u={},a=!1,c=!1;const l=[];s&&l.push(n.idKey);for(const f of i){let i;const s=t[f];if(f!==n.idKey&&(0,o.RV)([0,!1],s)&&(c=!0),f===n.idKey&&(0,o.Im)(s))i=e[f];else if((0,o.Kg)(s))i=(0,r.px)(e,s,f,n);else if((0,o.RV)([1,!0],s));else if(s instanceof Array)i=s.map((t=>{const i=(0,r.px)(e,t,null,n);return(0,o.gD)(i)?null:i}));else{if(!(0,o.Gv)(s)){l.push(f);continue}{const t=s,u=Object.keys(s),c=1==u.length?u[0]:"",l=(0,r.F5)(r.hu.PROJECTION,c,n);if(l)"$slice"===c?(0,o.eC)(t[c]).every(o.Et)?(i=l(e,t[c],f,n),a=!0):i=(0,r.px)(e,t,f,n):i=l(e,t[c],f,n);else if((0,o.Zo)(c))i=(0,r.px)(e,t[c],c,n);else if((0,o.zy)(e,f)){v(t,n);let r=e[f];r instanceof Array?i=r.map((e=>y(e,t,n,u,!1))):(r=(0,o.Gv)(r)?r:e,i=y(r,t,n,u,!1))}else i=(0,r.px)(e,s,null,n)}}const h=(0,o.Rm)(e,f,{preserveMissing:!0});void 0!==h&&(0,o.h1)(u,h,{flatten:!0}),(0,o.KL)([0,1,!1,!0],s)&&(void 0===i?(0,o.yT)(u,f,{descendArray:!0}):(0,o.KY)(u,f,i))}if((0,o.B2)(u),(a||c||s)&&(u=(0,o.dj)({},e,u),l.length>0))for(const r of l)(0,o.yT)(u,r,{descendArray:!0});return u}function v(e,t){const n=[!1,!1];for(const[r,i]of Object.entries(e)){if(r===(null==t?void 0:t.idKey))return;0===i||!1===i?n[0]=!0:1!==i&&!0!==i||(n[1]=!0),(0,o.vA)(!(n[0]&&n[1]),"Projection cannot have a mix of inclusion and exclusion.")}}},6950:(e,t,n)=>{"use strict";n.d(t,{Jy:()=>o,Ig:()=>i});var r=n(6827);(0,r.jm)(r.Gd);const o=(0,r.jm)(r.Jy),i=(0,r.jm)(r.Ig)},2403:(e,t,n)=>{"use strict";n.d(t,{XV:()=>o,MR:()=>i,fy:()=>s,oZ:()=>u,NV:()=>a,Q_:()=>c,C5:()=>l,GU:()=>f});var r=n(6827);const o=(0,r.jm)(r.XV),i=(0,r.jm)(r.MR),s=(0,r.jm)(r.fy),u=(0,r.jm)(r.oZ),a=(0,r.jm)(r.NV),c=(0,r.jm)(r.Q_),l=(0,r.jm)(r.C5),f=(0,r.jm)(r.GU)},6823:(e,t,n)=>{"use strict";n.d(t,{P:()=>o,T:()=>i});var r=n(6827);const o=(0,r.jm)(r.P),i=(0,r.jm)(r.TU)},6776:(e,t,n)=>{"use strict";n.d(t,{Pp:()=>o,WP:()=>i});n(2779);var r=n(6827);const o=(0,r.jm)(r.Pp),i=(0,r.jm)(r.WP);n(744)},7705:(e,t,n)=>{"use strict";n.d(t,{a6:()=>i,q3:()=>u,En:()=>a,sU:()=>s});var r=n(1692),o=n(744);const i=(e,t,n)=>{(0,o.vA)((0,o.cy)(t),"Invalid expression: $and expects value to be an Array.");const i=t.map((e=>new r.X(e,n)));return e=>i.every((t=>t.test(e)))},s=(e,t,n)=>{(0,o.vA)((0,o.cy)(t),"Invalid expression. $or expects value to be an Array");const i=t.map((e=>new r.X(e,n)));return e=>i.some((t=>t.test(e)))},u=(e,t,n)=>{(0,o.vA)((0,o.cy)(t),"Invalid expression. $nor expects value to be an array.");const r=s("$or",t,n);return e=>!r(e)},a=(e,t,n)=>{const i={};i[e]=(0,o.S8)(t);const s=new r.X(i,n);return e=>!s.test(e)}},1692:(e,t,n)=>{"use strict";n.d(t,{X:()=>a});var r=n(2779),o=n(7681),i=n(374),s=n(744);class u{constructor(e,t,n,r){this.source=e,this.predicate=t,this.projection=n,this.options=r,this.operators=[],this.result=null,this.buffer=[]}fetch(){return this.result||((0,s.Gv)(this.projection)&&this.operators.push({$project:this.projection}),this.result=(0,i.dF)(this.source).filter(this.predicate),this.operators.length>0&&(this.result=new o.u(this.operators,this.options).stream(this.result))),this.result}fetchAll(){const e=(0,i.dF)([...this.buffer]);return this.buffer=[],(0,i.Zz)(e,this.fetch())}all(){return this.fetchAll().value()}count(){return this.all().length}skip(e){return this.operators.push({$skip:e}),this}limit(e){return this.operators.push({$limit:e}),this}sort(e){return this.operators.push({$sort:e}),this}collation(e){return this.options=Object.assign(Object.assign({},this.options),{collation:e}),this}next(){if(this.buffer.length>0)return this.buffer.pop();const e=this.fetch().next();return e.done?void 0:e.value}hasNext(){if(this.buffer.length>0)return!0;const e=this.fetch().next();return!e.done&&(this.buffer.push(e.value),!0)}map(e){return this.all().map(e)}forEach(e){this.all().forEach(e)}[Symbol.iterator](){return this.fetchAll()}}class a{constructor(e,t){this.condition=e,this.options=(0,r.B3)(t),this.compiled=[],this.compile()}compile(){(0,s.vA)((0,s.Gv)(this.condition),`query criteria must be an object: ${JSON.stringify(this.condition)}`);const e={};for(const[t,n]of Object.entries(this.condition)){if("$where"===t)Object.assign(e,{field:t,expr:n});else if((0,s.RV)(["$and","$or","$nor","$expr","$jsonSchema"],t))this.processOperator(t,t,n);else{(0,s.vA)(!(0,s.Zo)(t),`unknown top level operator: ${t}`);for(const[e,r]of Object.entries((0,s.S8)(n)))this.processOperator(t,e,r)}e.field&&this.processOperator(e.field,e.field,e.expr)}}processOperator(e,t,n){const o=(0,r.F5)(r.hu.QUERY,t,this.options);if(!o)throw new Error(`unknown operator ${t}`);const i=o(e,n,this.options);this.compiled.push(i)}test(e){for(let t=0,n=this.compiled.length;tthis.test(e)),t||{},this.options)}remove(e){return e.reduce(((e,t)=>(this.test(t)||e.push(t),e)),[])}}},744:(e,t,n)=>{"use strict";n.d(t,{$P:()=>T,$z:()=>Q,B2:()=>re,Bq:()=>G,E$:()=>W,Et:()=>A,Gv:()=>C,Hq:()=>r,Im:()=>q,KL:()=>N,KY:()=>se,Kg:()=>S,Lm:()=>P,Pw:()=>E,R:()=>o,RV:()=>K,Rm:()=>ne,S8:()=>le,Tn:()=>D,UD:()=>x,W_:()=>i,Z4:()=>I,Zo:()=>ce,cy:()=>j,dj:()=>Z,eC:()=>L,gD:()=>R,gd:()=>M,h1:()=>z,hd:()=>te,mg:()=>k,n4:()=>Y,oU:()=>s,vA:()=>O,vN:()=>B,yT:()=>ue,zy:()=>$});const r=2147483647,o=-2147483648,i=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,u=Symbol("missing"),a=Object.freeze(new Error("mingo: cycle detected while processing object/array")),c=Object.getPrototypeOf([]),l=Object.getPrototypeOf({}),f=/^\[object ([a-zA-Z0-9]+)\]$/;class h{}class d{}const p=e=>null===e?h:void 0===e?d:e.constructor,y=e=>{const t=function(e){const t=new Set,n=e=>{const r=p(e);if(w.has(r))return w.get(r)(e);const o=r===Object?"":r.name;if(D(e.toJSON))return`${o}(${JSON.stringify(e)})`;if(t.has(e))throw a;t.add(e);try{if(r===Array)return"["+e.map(n).join(",")+"]";if(r!==Object){const[t,r]=X(e);if(j(e))return`${o}${n([...e,t])}`;e=t}const t=Object.keys(e);return t.sort(),`${o}{`+t.map((t=>`${t}:${n(e[t])}`)).join(",")+"}"}finally{t.delete(e)}};return n(e)}(e);let n=0,r=t.length;for(;r;)n=(n<<5)-n^t.charCodeAt(--r);return n>>>0},v=new Set(["null","undefined","boolean","number","string","date","regexp"]),m=new Set([d,h,Boolean,String,Number]),b=e=>e.toString(),g=e=>`${p(e).name}[${e.toString()}]`,w=new Map([[Number,b],[Boolean,b],[RegExp,b],[Function,b],[Symbol,b],[Date,e=>e.toISOString()],[String,JSON.stringify],[h,e=>"null"],[d,e=>"undefined"],[Int8Array,g],[Uint8Array,g],[Uint8ClampedArray,g],[Int16Array,g],[Uint16Array,g],[Int32Array,g],[Uint32Array,g],[Float32Array,g],[Float64Array,g]]);"undefined"!=typeof BigInt&&w.set(BigInt,(e=>"0x"+e.toString(16))),"undefined"!=typeof BigInt64Array&&w.set(BigInt64Array,g),"undefined"!=typeof BigUint64Array&&w.set(BigUint64Array,g);const _={null:0,undefined:0,number:1,string:2,object:3,array:4,boolean:5,date:6,regexp:7,function:8},x=(e,t)=>{e===u&&(e=void 0),t===u&&(t=void 0);const[n,r]=[e,t].map((e=>_[E(e).toLowerCase()]));return n!==r?n-r:1===n||2===n||6===n?et?1:0:Y(e,t)?0:et?1:0};function O(e,t){if(!e)throw new Error(t)}const k=e=>{if(m.has(p(e)))return e;const t=new Set,n=e=>{if(t.has(e))throw a;const r=p(e);if(m.has(r))return e;try{if(j(e))return t.add(e),e.map(n);if(C(e)){t.add(e);const r={};for(const t in e)r[t]=n(e[t]);return r}}finally{t.delete(e)}return r===Date||r===RegExp||(e=>{const t=Object.getPrototypeOf(p(e));return t&&"TypedArray"===t.name})(e)?new r(e):e};return n(e)},E=e=>f.exec(Object.prototype.toString.call(e))[1],P=e=>"boolean"==typeof e,S=e=>"string"==typeof e,A=e=>!isNaN(e)&&"number"==typeof e,j=Array.isArray,C=e=>{if(!e)return!1;const t=Object.getPrototypeOf(e);return(t===l||null===t)&&"[object Object]"===Object.prototype.toString.call(e)},I=e=>e===Object(e),T=e=>e instanceof Date,M=e=>e instanceof RegExp,D=e=>"function"==typeof e,R=e=>null==e,K=(e,t)=>e.includes(t),N=(e,t)=>!K(e,t),B=(e,t=!0)=>!!e||t&&""===e,q=e=>R(e)||S(e)&&!e||e instanceof Array&&0===e.length||C(e)&&0===Object.keys(e).length,F=e=>e===u,L=e=>e instanceof Array?e:[e],$=(e,t)=>!!e&&Object.prototype.hasOwnProperty.call(e,t),U=(e,t)=>C(e)&&C(t)||j(e)&&j(t);function z(e,t,n){if(n=n||{flatten:!1},F(e)||R(e))return t;if(F(t)||R(t))return e;if(!U(e,t)){if(n.skipValidation)return t||e;throw Error("mismatched types. must both be array or object")}if(n.skipValidation=!0,j(e)){const r=e,o=t;if(n.flatten){let e=0,i=0;for(;e{const i=H(r,t);n.has(i)?n.get(i).some((t=>Y(e[t],r)))||n.get(i).push(o):n.set(i,[o])})),n}function W(e,t=y){if(e.some((e=>0==e.length)))return[];if(1===e.length)return Array.from(e);const n=function(e,t,n=x){if(q(e))return e;const r=new Array,o=new Array;for(let i=0;in(e[0],t[0]))),Z(o,r.map((e=>e[1])))}(e.map(((e,t)=>[t,e.length])),(e=>e[1])),r=e[n[0][0]],o=V(r,t),i=new Map,s=new Array;return o.forEach(((t,o)=>{const a=t.map((e=>r[e])),c=a.map((e=>0)),l=a.map((e=>[n[0][0],0]));let f=!1;for(let r=1;ru[e]));f=a.map(((n,s)=>e.some(((e,u)=>{const a=c[s];return Y(n,e)&&(c[s]++,tt===e.length-1?[a[n],l[n]]:u)).filter((e=>e!==u)))})),s.sort(((e,t)=>{const[n,[r,o]]=e,[i,[s,u]]=t,a=x(r,s);return 0!==a?a:x(o,u)})).map((e=>e[0]))}function G(e,t=0){const n=new Array;return function e(t,r){for(let o=0,i=t.length;o0||r<0)?e(t[o],Math.max(-1,r-1)):n.push(t[o])}(e,t),n}const X=e=>{let[t,n]=[Object.getPrototypeOf(e),Object.getOwnPropertyNames(e)],r=t;for(;!n.length&&t!==l&&t!==c;)r=t,n=Object.getOwnPropertyNames(t),t=Object.getPrototypeOf(t);const o={};return n.forEach((t=>o[t]=e[t])),[o,r]};function Y(e,t){const n=[[e,t]];for(;n.length>0;){if([e,t]=n.pop(),e===t)continue;const r=p(e);if(r!==p(t)||D(e))return!1;if(w.has(r)){const n=w.get(r);if(n(e)!==n(t))return!1}else{if(r!==Array&&r!==Object)return!1;{const r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;if(new Set(r.concat(o)).size!=r.length)return!1;for(const i of r)n.push([e[i],t[i]])}}}return!n.length}function H(e,t){return t=t||y,R(e)?null:t(e).toString()}function Q(e,t,n=y){if(e.length<1)return new Map;const r=new Map,o=new Map;for(let i=0;iY(e,u))):null;R(e)?(o.set(u,[s]),r.has(a)?r.get(a).push(u):r.set(a,[u])):o.get(e).push(s)}}return o}const J=5e4;function Z(e,...t){return e instanceof Array?t.reduce(((e,t)=>{let n=Math.ceil(t.length/J),r=0;for(;n-- >0;)Array.prototype.push.apply(e,t.slice(r,r+J)),r+=J;return e}),e):t.filter(I).reduce(((e,t)=>(Object.assign(e,t),e)),e)}function ee(e,t){return I(e)?e[t]:void 0}function te(e,t,n){let r=0;const o=v.has(E(e).toLowerCase())?e:function e(t,n){let o=t;for(let i=0;i0)break;r+=1;const t=n.slice(i);o=o.reduce(((n,r)=>{const o=e(r,t);return void 0!==o&&n.push(o),n}),[]);break}if(o=ee(o,t),void 0===o)break}return o}(e,t.split("."));return o instanceof Array&&(null==n?void 0:n.unwrapArray)?function(e,t){if(t<1)return e;for(;t--&&1===e.length;)e=e[0];return e}(o,r):o}function ne(e,t,n){const r=t.split("."),o=r[0],i=r.slice(1).join("."),s=null!==/^\d+$/.exec(o),a=r.length>1;let c,l;if(e instanceof Array)if(s)c=ee(e,Number(o)),a&&(c=ne(c,i,n)),c=[c];else{c=[];for(const r of e)l=ne(r,t,n),(null==n?void 0:n.preserveMissing)?(void 0===l&&(l=u),c.push(l)):void 0!==l&&c.push(l)}else{if(l=ee(e,o),a&&(l=ne(l,i,n)),void 0===l)return;c=(null==n?void 0:n.preserveKeys)?Object.assign({},e):{},c[o]=l}return c}function re(e){if(e instanceof Array)for(let t=e.length-1;t>=0;t--)e[t]===u?e.splice(t,1):re(e[t]);else if(C(e))for(const t in e)$(e,t)&&re(e[t])}const oe=/^\d+$/;function ie(e,t,n,r){const o=t.split("."),i=o[0],s=o.slice(1).join(".");if(1===o.length)(C(e)||j(e)&&oe.test(i))&&n(e,i);else{(null==r?void 0:r.buildGraph)&&R(e[i])&&(e[i]={});const t=e[i];if(!t)return;const u=!!(o.length>1&&oe.test(o[1]));t instanceof Array&&(null==r?void 0:r.descendArray)&&!u?t.forEach((e=>ie(e,s,n,r))):ie(t,s,n,r)}}function se(e,t,n){ie(e,t,((e,t)=>{e[t]=D(n)?n(e[t]):n}),{buildGraph:!0})}function ue(e,t,n){ie(e,t,((e,t)=>{if(e instanceof Array){if(/^\d+$/.test(t))e.splice(parseInt(t),1);else if(n&&n.descendArray)for(const n of e)C(n)&&delete n[t]}else C(e)&&delete e[t]}),n)}const ae=/^\$[a-zA-Z0-9_]+$/;function ce(e){return ae.test(e)}function le(e){if(v.has(E(e).toLowerCase()))return M(e)?{$regex:e}:{$eq:e};if(I(e)){const t=e;if(!Object.keys(t).some(ce))return{$eq:e};if($(e,"$regex")){const t=Object.assign({},e);return t.$regex=new RegExp(e.$regex,e.$options),delete t.$options,t}}return e}},2198:(e,t,n)=>{"use strict";n.d(t,{t:()=>o});var r=n(4629),o=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return(0,r.C6)(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){var e=this,t=e.hasError,n=e.thrownError,r=e._value;if(t)throw n;return this._throwIfClosed(),r},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(n(9092).B)},4134:(e,t,n)=>{"use strict";n.d(t,{c:()=>f});var r=n(8857),o=n(2258),i=n(8896),s=n(3887);function u(e){return 0===e.length?s.D:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var a=n(2236),c=n(1693),l=n(3004),f=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var i,s=this,u=(i=e)&&i instanceof r.vU||function(e){return e&&(0,c.T)(e.next)&&(0,c.T)(e.error)&&(0,c.T)(e.complete)}(i)&&(0,o.Uv)(i)?e:new r.Ms(e,t,n);return(0,l.Y)((function(){var e=s,t=e.operator,n=e.source;u.add(t?t.call(u,n):n?s._subscribe(u):s._trySubscribe(u))})),u},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=h(t))((function(t,o){var i=new r.Ms({next:function(t){try{e(t)}catch(n){o(n),i.unsubscribe()}},error:o,complete:t});n.subscribe(i)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[i.s]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t{"use strict";n.d(t,{B:()=>c});var r=n(4629),o=n(4134),i=n(2258),s=(0,n(5383).L)((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),u=n(34),a=n(3004),c=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return(0,r.C6)(t,e),t.prototype.lift=function(e){var t=new l(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new s},t.prototype.next=function(e){var t=this;(0,a.Y)((function(){var n,o;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=(0,r.Ju)(t.currentObservers),s=i.next();!s.done;s=i.next()){s.value.next(e)}}catch(u){n={error:u}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}}}))},t.prototype.error=function(e){var t=this;(0,a.Y)((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}}))},t.prototype.complete=function(){var e=this;(0,a.Y)((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,o=n.isStopped,s=n.observers;return r||o?i.Kn:(this.currentObservers=null,s.push(e),new i.yU((function(){t.currentObservers=null,(0,u.o)(s,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,o=t.isStopped;n?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new o.c;return e.source=this,e},t.create=function(e,t){return new l(e,t)},t}(o.c),l=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return(0,r.C6)(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:i.Kn},t}(c)},8857:(e,t,n)=>{"use strict";n.d(t,{Ms:()=>m,vU:()=>d});var r=n(4629),o=n(1693),i=n(2258),s=n(2236),u=n(6712);function a(){}var c=l("C",void 0,void 0);function l(e,t,n){return{kind:e,value:t,error:n}}var f=n(2332),h=n(3004),d=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,(0,i.Uv)(t)&&t.add(n)):n.destination=w,n}return(0,r.C6)(t,e),t.create=function(e,t,n){return new m(e,t,n)},t.prototype.next=function(e){this.isStopped?g(function(e){return l("N",e,void 0)}(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?g(l("E",void 0,e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?g(c,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(i.yU),p=Function.prototype.bind;function y(e,t){return p.call(e,t)}var v=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){b(n)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){b(n)}else b(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){b(t)}},e}(),m=function(e){function t(t,n,r){var i,u,a=e.call(this)||this;(0,o.T)(t)||!t?i={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:a&&s.$.useDeprecatedNextContext?((u=Object.create(t)).unsubscribe=function(){return a.unsubscribe()},i={next:t.next&&y(t.next,u),error:t.error&&y(t.error,u),complete:t.complete&&y(t.complete,u)}):i=t;return a.destination=new v(i),a}return(0,r.C6)(t,e),t}(d);function b(e){s.$.useDeprecatedSynchronousErrorHandling?(0,h.l)(e):(0,u.m)(e)}function g(e,t){var n=s.$.onStoppedNotification;n&&f.f.setTimeout((function(){return n(e,t)}))}var w={closed:!0,next:a,error:function(e){throw e},complete:a}},2258:(e,t,n)=>{"use strict";n.d(t,{Kn:()=>a,yU:()=>u,Uv:()=>c});var r=n(4629),o=n(1693),i=(0,n(5383).L)((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}})),s=n(34),u=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,n,s,u;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var c=(0,r.Ju)(a),f=c.next();!f.done;f=c.next()){f.value.remove(this)}}catch(m){e={error:m}}finally{try{f&&!f.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else a.remove(this);var h=this.initialTeardown;if((0,o.T)(h))try{h()}catch(b){u=b instanceof i?b.errors:[b]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var p=(0,r.Ju)(d),y=p.next();!y.done;y=p.next()){var v=y.value;try{l(v)}catch(g){u=null!=u?u:[],g instanceof i?u=(0,r.fX)((0,r.fX)([],(0,r.zs)(u)),(0,r.zs)(g.errors)):u.push(g)}}}catch(w){n={error:w}}finally{try{y&&!y.done&&(s=p.return)&&s.call(p)}finally{if(n)throw n.error}}}if(u)throw new i(u)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)l(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&(0,s.o)(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&(0,s.o)(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),a=u.EMPTY;function c(e){return e instanceof u||e&&"closed"in e&&(0,o.T)(e.remove)&&(0,o.T)(e.add)&&(0,o.T)(e.unsubscribe)}function l(e){(0,o.T)(e)?e():e.unsubscribe()}},2236:(e,t,n)=>{"use strict";n.d(t,{$:()=>r});var r={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1}},511:(e,t,n)=>{"use strict";n.d(t,{_:()=>i});var r=(0,n(5383).L)((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}})),o=n(8857);function i(e,t){var n="object"==typeof t;return new Promise((function(i,s){var u=new o.Ms({next:function(e){i(e),u.unsubscribe()},error:s,complete:function(){n?i(t.defaultValue):s(new r)}});e.subscribe(u)}))}},9852:(e,t,n)=>{"use strict";n.d(t,{H:()=>_});var r=n(7688),o=n(8071),i=n(5096),s=n(4370);function u(e,t){return void 0===t&&(t=0),(0,i.N)((function(n,r){n.subscribe((0,s._)(r,(function(n){return(0,o.N)(r,e,(function(){return r.next(n)}),t)}),(function(){return(0,o.N)(r,e,(function(){return r.complete()}),t)}),(function(n){return(0,o.N)(r,e,(function(){return r.error(n)}),t)})))}))}function a(e,t){return void 0===t&&(t=0),(0,i.N)((function(n,r){r.add(e.schedule((function(){return n.subscribe(r)}),t))}))}var c=n(4134);var l=n(9445),f=n(1693);function h(e,t){if(!e)throw new Error("Iterable cannot be null");return new c.c((function(n){(0,o.N)(n,t,(function(){var r=e[Symbol.asyncIterator]();(0,o.N)(n,t,(function(){r.next().then((function(e){e.done?n.complete():n.next(e.value)}))}),0,!0)}))}))}var d=n(9065),p=n(5796),y=n(9739),v=n(4799),m=n(3819),b=n(4429),g=n(3026);function w(e,t){if(null!=e){if((0,d.l)(e))return function(e,t){return(0,r.Tg)(e).pipe(a(t),u(t))}(e,t);if((0,y.X)(e))return function(e,t){return new c.c((function(n){var r=0;return t.schedule((function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())}))}))}(e,t);if((0,p.y)(e))return function(e,t){return(0,r.Tg)(e).pipe(a(t),u(t))}(e,t);if((0,m.T)(e))return h(e,t);if((0,v.x)(e))return function(e,t){return new c.c((function(n){var r;return(0,o.N)(n,t,(function(){r=e[l.l](),(0,o.N)(n,t,(function(){var e,t,o;try{t=(e=r.next()).value,o=e.done}catch(i){return void n.error(i)}o?n.complete():n.next(t)}),0,!0)})),function(){return(0,f.T)(null==r?void 0:r.return)&&r.return()}}))}(e,t);if((0,g.U)(e))return function(e,t){return h((0,g.C)(e),t)}(e,t)}throw(0,b.L)(e)}function _(e,t){return t?w(e,t):(0,r.Tg)(e)}},7688:(e,t,n)=>{"use strict";n.d(t,{Tg:()=>y});var r=n(4629),o=n(9739),i=n(5796),s=n(4134),u=n(9065),a=n(3819),c=n(4429),l=n(4799),f=n(3026),h=n(1693),d=n(6712),p=n(8896);function y(e){if(e instanceof s.c)return e;if(null!=e){if((0,u.l)(e))return b=e,new s.c((function(e){var t=b[p.s]();if((0,h.T)(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if((0,o.X)(e))return m=e,new s.c((function(e){for(var t=0;t{"use strict";n.d(t,{h:()=>a});var r=n(5499),o=n(7688),i=new(n(4134).c)((function(e){return e.complete()}));var s=n(235),u=n(9852);function a(){for(var e=[],t=0;t{"use strict";n.d(t,{_:()=>o});var r=n(4629);function o(e,t,n,r,o){return new i(e,t,n,r,o)}var i=function(e){function t(t,n,r,o,i,s){var u=e.call(this,t)||this;return u.onFinalize=i,u.shouldUnsubscribe=s,u._next=n?function(e){try{n(e)}catch(r){t.error(r)}}:e.prototype._next,u._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,u}return(0,r.C6)(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(n(8857).vU)},5520:(e,t,n)=>{"use strict";n.d(t,{F:()=>s});var r=n(3887),o=n(5096),i=n(4370);function s(e,t){return void 0===t&&(t=r.D),e=null!=e?e:u,(0,o.N)((function(n,r){var o,s=!0;n.subscribe((0,i._)(r,(function(n){var i=t(n);!s&&e(o,i)||(s=!1,o=i,r.next(n))})))}))}function u(e,t){return e===t}},8146:(e,t,n)=>{"use strict";n.d(t,{p:()=>i});var r=n(5096),o=n(4370);function i(e,t){return(0,r.N)((function(n,r){var i=0;n.subscribe((0,o._)(r,(function(n){return e.call(t,n,i++)&&r.next(n)})))}))}},7708:(e,t,n)=>{"use strict";n.d(t,{T:()=>i});var r=n(5096),o=n(4370);function i(e,t){return(0,r.N)((function(n,r){var i=0;n.subscribe((0,o._)(r,(function(n){r.next(e.call(t,n,i++))})))}))}},5499:(e,t,n)=>{"use strict";n.d(t,{U:()=>i});var r=n(2442),o=n(3887);function i(e){return void 0===e&&(e=1/0),(0,r.Z)(o.D,e)}},2442:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(7708),o=n(7688),i=n(5096),s=n(8071),u=n(4370);var a=n(1693);function c(e,t,n){return void 0===n&&(n=1/0),(0,a.T)(t)?c((function(n,i){return(0,r.T)((function(e,r){return t(n,e,i,r)}))((0,o.Tg)(e(n,i)))}),n):("number"==typeof t&&(n=t),(0,i.N)((function(t,r){return function(e,t,n,r,i,a,c,l){var f=[],h=0,d=0,p=!1,y=function(){!p||f.length||h||t.complete()},v=function(e){return h{"use strict";n.d(t,{X:()=>l});var r=n(4629),o=n(5096),i=Array.isArray;var s=n(5499),u=n(235),a=n(9852);function c(){for(var e=[],t=0;t{"use strict";n.d(t,{t:()=>f});var r=n(4629),o=n(9092),i={now:function(){return(i.delegate||Date).now()},delegate:void 0},s=function(e){function t(t,n,r){void 0===t&&(t=1/0),void 0===n&&(n=1/0),void 0===r&&(r=i);var o=e.call(this)||this;return o._bufferSize=t,o._windowTime=n,o._timestampProvider=r,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=n===1/0,o._bufferSize=Math.max(1,t),o._windowTime=Math.max(1,n),o}return(0,r.C6)(t,e),t.prototype.next=function(t){var n=this,r=n.isStopped,o=n._buffer,i=n._infiniteTimeWindow,s=n._timestampProvider,u=n._windowTime;r||(o.push(t),!i&&o.push(s.now()+u)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this._infiniteTimeWindow,r=this._buffer.slice(),o=0;o0&&(t=new a.Ms({next:function(e){return b.next(e)},error:function(e){p=!0,y(),r=l(v,i,e),b.error(e)},complete:function(){h=!0,y(),r=l(v,f),b.complete()}}),(0,u.Tg)(e).subscribe(t))}))(e)}}({connector:function(){return new s(h,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:d})}},3356:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var r=n(5499);var o=n(235),i=n(9852);function s(){for(var e=[],t=0;t{"use strict";n.d(t,{f:()=>o});var r=n(4629),o={setTimeout:function(e,t){for(var n=[],i=2;i{"use strict";n.d(t,{l:()=>r});var r="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"},8896:(e,t,n)=>{"use strict";n.d(t,{s:()=>r});var r="function"==typeof Symbol&&Symbol.observable||"@@observable"},235:(e,t,n)=>{"use strict";n.d(t,{R0:()=>s,lI:()=>i});var r=n(1693);function o(e){return e[e.length-1]}function i(e){return(t=o(e))&&(0,r.T)(t.schedule)?e.pop():void 0;var t}function s(e,t){return"number"==typeof o(e)?e.pop():t}},34:(e,t,n)=>{"use strict";function r(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}n.d(t,{o:()=>r})},5383:(e,t,n)=>{"use strict";function r(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}n.d(t,{L:()=>r})},3004:(e,t,n)=>{"use strict";n.d(t,{Y:()=>i,l:()=>s});var r=n(2236),o=null;function i(e){if(r.$.useDeprecatedSynchronousErrorHandling){var t=!o;if(t&&(o={errorThrown:!1,error:null}),e(),t){var n=o,i=n.errorThrown,s=n.error;if(o=null,i)throw s}}else e()}function s(e){r.$.useDeprecatedSynchronousErrorHandling&&o&&(o.errorThrown=!0,o.error=e)}},8071:(e,t,n)=>{"use strict";function r(e,t,n,r,o){void 0===r&&(r=0),void 0===o&&(o=!1);var i=t.schedule((function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()}),r);if(e.add(i),!o)return i}n.d(t,{N:()=>r})},3887:(e,t,n)=>{"use strict";function r(e){return e}n.d(t,{D:()=>r})},9739:(e,t,n)=>{"use strict";n.d(t,{X:()=>r});var r=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e}},3819:(e,t,n)=>{"use strict";n.d(t,{T:()=>o});var r=n(1693);function o(e){return Symbol.asyncIterator&&(0,r.T)(null==e?void 0:e[Symbol.asyncIterator])}},1693:(e,t,n)=>{"use strict";function r(e){return"function"==typeof e}n.d(t,{T:()=>r})},9065:(e,t,n)=>{"use strict";n.d(t,{l:()=>i});var r=n(8896),o=n(1693);function i(e){return(0,o.T)(e[r.s])}},4799:(e,t,n)=>{"use strict";n.d(t,{x:()=>i});var r=n(9445),o=n(1693);function i(e){return(0,o.T)(null==e?void 0:e[r.l])}},5796:(e,t,n)=>{"use strict";n.d(t,{y:()=>o});var r=n(1693);function o(e){return(0,r.T)(null==e?void 0:e.then)}},3026:(e,t,n)=>{"use strict";n.d(t,{C:()=>i,U:()=>s});var r=n(4629),o=n(1693);function i(e){return(0,r.AQ)(this,arguments,(function(){var t,n,o;return(0,r.YH)(this,(function(i){switch(i.label){case 0:t=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,(0,r.N3)(t.read())];case 3:return n=i.sent(),o=n.value,n.done?[4,(0,r.N3)(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,(0,r.N3)(o)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}function s(e){return(0,o.T)(null==e?void 0:e.getReader)}},5096:(e,t,n)=>{"use strict";n.d(t,{N:()=>o});var r=n(1693);function o(e){return function(t){if(function(e){return(0,r.T)(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(n){this.error(n)}}));throw new TypeError("Unable to lift unknown Observable type")}}},6712:(e,t,n)=>{"use strict";n.d(t,{m:()=>i});var r=n(2236),o=n(2332);function i(e){o.f.setTimeout((function(){var t=r.$.onUnhandledError;if(!t)throw e;t(e)}))}},4429:(e,t,n)=>{"use strict";function r(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}n.d(t,{L:()=>r})},3836:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:String(t)}function i(e,t){for(var n=0;ns})},1449:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(1576);function o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,(0,r.A)(e,t)}},1576:(e,t,n)=>{"use strict";function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}n.d(t,{A:()=>r})},6343:(e,t,n)=>{"use strict";function r(e){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},r(e)}n.d(t,{A:()=>s});var o=n(1576);function i(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(i=function(){return!!e})()}function s(e){var t="function"==typeof Map?new Map:void 0;return s=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(i())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var s=new(e.bind.apply(e,r));return n&&(0,o.A)(s,n.prototype),s}(e,arguments,r(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),(0,o.A)(n,e)},s(e)}},703:(e,t,n)=>{"use strict";n.d(t,{X2:()=>M});Promise.resolve(!1),Promise.resolve(!0);var r=Promise.resolve();function o(e,t){return e||(e=0),new Promise((function(n){return setTimeout((function(){return n(t)}),e)}))}function i(){return Math.random().toString(36).substring(2)}var s=0;function u(){var e=1e3*Date.now();return e<=s&&(e=s+1),s=e,e}var a={create:function(e){var t={time:u(),messagesCallback:null,bc:new BroadcastChannel(e),subFns:[]};return t.bc.onmessage=function(e){t.messagesCallback&&t.messagesCallback(e.data)},t},close:function(e){e.bc.close(),e.subFns=[]},onMessage:function(e,t){e.messagesCallback=t},postMessage:function(e,t){try{return e.bc.postMessage(t,!1),r}catch(n){return Promise.reject(n)}},canBeUsed:function(){if("undefined"!=typeof globalThis&&globalThis.Deno&&globalThis.Deno.args)return!0;if("undefined"==typeof window&&"undefined"==typeof self||"function"!=typeof BroadcastChannel)return!1;if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0},type:"native",averageResponseTime:function(){return 150},microSeconds:u},c=n(5525);function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=JSON.parse(JSON.stringify(e));return void 0===t.webWorkerSupport&&(t.webWorkerSupport=!0),t.idb||(t.idb={}),t.idb.ttl||(t.idb.ttl=45e3),t.idb.fallbackInterval||(t.idb.fallbackInterval=150),e.idb&&"function"==typeof e.idb.onclose&&(t.idb.onclose=e.idb.onclose),t.localstorage||(t.localstorage={}),t.localstorage.removeTimeout||(t.localstorage.removeTimeout=6e4),e.methods&&(t.methods=e.methods),t.node||(t.node={}),t.node.ttl||(t.node.ttl=12e4),t.node.maxParallelWrites||(t.node.maxParallelWrites=2048),void 0===t.node.useFastPath&&(t.node.useFastPath=!0),t}var f="pubkey.broadcast-channel-0-",h="messages",d={durability:"relaxed"};function p(){if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof window){if(void 0!==window.mozIndexedDB)return window.mozIndexedDB;if(void 0!==window.webkitIndexedDB)return window.webkitIndexedDB;if(void 0!==window.msIndexedDB)return window.msIndexedDB}return!1}function y(e){e.commit&&e.commit()}function v(e,t){var n=e.transaction(h,"readonly",d),r=n.objectStore(h),o=[],i=IDBKeyRange.bound(t+1,1/0);if(r.getAll){var s=r.getAll(i);return new Promise((function(e,t){s.onerror=function(e){return t(e)},s.onsuccess=function(t){e(t.target.result)}}))}return new Promise((function(e,s){var u=function(){try{return i=IDBKeyRange.bound(t+1,1/0),r.openCursor(i)}catch(e){return r.openCursor()}}();u.onerror=function(e){return s(e)},u.onsuccess=function(r){var i=r.target.result;i?i.value.ide.lastCursorId&&(e.lastCursorId=t.id),t})).filter((function(t){return function(e,t){return!(e.uuid===t.uuid||t.eMIs.has(e.id)||e.data.time0||e._addEL.internal.length>0}function K(e,t,n){e._addEL[t].push(n),function(e){if(!e._iL&&R(e)){var t=function(t){e._addEL[t.type].forEach((function(e){t.time>=e.time&&e.fn(t.data)}))},n=e.method.microSeconds();e._prepP?e._prepP.then((function(){e._iL=!0,e.method.onMessage(e._state,t,n)})):(e._iL=!0,e.method.onMessage(e._state,t,n))}}(e)}function N(e,t,n){e._addEL[t]=e._addEL[t].filter((function(e){return e!==n})),function(e){if(e._iL&&!R(e)){e._iL=!1;var t=e.method.microSeconds();e.method.onMessage(e._state,null,t)}}(e)}M._pubkey=!0,M.prototype={postMessage:function(e){if(this.closed)throw new Error("BroadcastChannel.postMessage(): Cannot post message after channel has closed "+JSON.stringify(e));return D(this,"message",e)},postInternal:function(e){return D(this,"internal",e)},set onmessage(e){var t={time:this.method.microSeconds(),fn:e};N(this,"message",this._onML),e&&"function"==typeof e?(this._onML=t,K(this,"message",t)):this._onML=null},addEventListener:function(e,t){K(this,e,{time:this.method.microSeconds(),fn:t})},removeEventListener:function(e,t){N(this,e,this._addEL[e].find((function(e){return e.fn===t})))},close:function(){var e=this;if(!this.closed){I.delete(this),this.closed=!0;var t=this._prepP?this._prepP:r;return this._onML=null,this._addEL.message=[],t.then((function(){return Promise.all(Array.from(e._uMP))})).then((function(){return Promise.all(e._befC.map((function(e){return e()})))})).then((function(){return e.method.close(e._state)}))}},get type(){return this.method.type},get isClosed(){return this.closed}}},7329:(e,t,n)=>{"use strict";n.d(t,{cf:()=>i});var r=n(8900);const o=Symbol.for("Dexie"),i=globalThis[o]||(globalThis[o]=r);if(r.semVer!==i.semVer)throw new Error(`Two different versions of Dexie loaded in the same app: ${r.semVer} and ${i.semVer}`);const{liveQuery:s,mergeRanges:u,rangesOverlap:a,RangeSet:c,cmp:l,Entity:f}=i},6114:(e,t,n)=>{"use strict";n.d(t,{kC:()=>q,Cs:()=>F});const r=e=>{e.previousResults.unshift(e.changeEvent.doc),e.keyDocumentMap&&e.keyDocumentMap.set(e.changeEvent.id,e.changeEvent.doc)},o=e=>{e.previousResults.push(e.changeEvent.doc),e.keyDocumentMap&&e.keyDocumentMap.set(e.changeEvent.id,e.changeEvent.doc)},i=e=>{const t=e.previousResults.shift();e.keyDocumentMap&&t&&e.keyDocumentMap.delete(t[e.queryParams.primaryKey])},s=e=>{const t=e.previousResults.pop();e.keyDocumentMap&&t&&e.keyDocumentMap.delete(t[e.queryParams.primaryKey])},u=e=>{e.keyDocumentMap&&e.keyDocumentMap.delete(e.changeEvent.id);const t=e.queryParams.primaryKey,n=e.previousResults;for(let r=0;r{const t=e.changeEvent.id,n=e.changeEvent.doc;if(e.keyDocumentMap){if(e.keyDocumentMap.has(t))return;e.keyDocumentMap.set(t,n)}else{if(e.previousResults.find((n=>n[e.queryParams.primaryKey]===t)))return}!function(e,t,n,r){var o,i=e.length,s=i-1,u=0;if(0===i)return e.push(t),0;for(;r<=s;)n(o=e[u=r+(s-r>>1)],t)<=0?r=u+1:s=u-1;n(o,t)<=0&&u++,e.splice(u,0,t)}(e.previousResults,n,e.queryParams.sortComparator,0)},c=["doNothing","insertFirst","insertLast","removeFirstItem","removeLastItem","removeFirstInsertLast","removeLastInsertFirst","removeFirstInsertFirst","removeLastInsertLast","removeExisting","replaceExisting","alwaysWrong","insertAtSortPosition","removeExistingAndInsertAtSortPosition","runFullQueryAgain","unknownAction"],l={doNothing:e=>{},insertFirst:r,insertLast:o,removeFirstItem:i,removeLastItem:s,removeFirstInsertLast:e=>{i(e),o(e)},removeLastInsertFirst:e=>{s(e),r(e)},removeFirstInsertFirst:e=>{i(e),r(e)},removeLastInsertLast:e=>{s(e),o(e)},removeExisting:u,replaceExisting:e=>{const t=e.changeEvent.doc,n=e.queryParams.primaryKey,r=e.previousResults;for(let o=0;o{const t={_id:"wrongHuman"+(new Date).getTime()};e.previousResults.length=0,e.previousResults.push(t),e.keyDocumentMap&&(e.keyDocumentMap.clear(),e.keyDocumentMap.set(t._id,t))},insertAtSortPosition:a,removeExistingAndInsertAtSortPosition:e=>{u(e),a(e)},runFullQueryAgain:e=>{throw new Error("Action runFullQueryAgain must be implemented by yourself")},unknownAction:e=>{throw new Error("Action unknownAction should never be called")}};!function(e=6){let t="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let r=0;r!!e.queryParams.limit,b=e=>1===e.queryParams.limit,g=e=>!!(e.queryParams.skip&&e.queryParams.skip>0),w=e=>"DELETE"===e.changeEvent.operation,_=e=>"INSERT"===e.changeEvent.operation,x=e=>"UPDATE"===e.changeEvent.operation,O=e=>m(e)&&e.previousResults.length>=e.queryParams.limit,k=e=>{const t=e.queryParams.sortFields,n=e.changeEvent.previous,r=e.changeEvent.doc;if(!r)return!1;if(!n)return!0;for(let o=0;o{const t=e.changeEvent.id;if(e.keyDocumentMap){return e.keyDocumentMap.has(t)}{const n=e.queryParams.primaryKey,r=e.previousResults;for(let e=0;e{const t=e.previousResults[0];return!(!t||t[e.queryParams.primaryKey]!==e.changeEvent.id)},S=e=>{const t=p(e.previousResults);return!(!t||t[e.queryParams.primaryKey]!==e.changeEvent.id)},A=e=>{const t=e.changeEvent.previous;if(!t)return!1;const n=e.previousResults[0];if(!n)return!1;if(n[e.queryParams.primaryKey]===e.changeEvent.id)return!0;return e.queryParams.sortComparator(t,n)<0},j=e=>{const t=e.changeEvent.previous;if(!t)return!1;const n=p(e.previousResults);if(!n)return!1;if(n[e.queryParams.primaryKey]===e.changeEvent.id)return!0;return e.queryParams.sortComparator(t,n)>0},C=e=>{const t=e.changeEvent.doc;if(!t)return!1;const n=e.previousResults[0];if(!n)return!1;if(n[e.queryParams.primaryKey]===e.changeEvent.id)return!0;return e.queryParams.sortComparator(t,n)<0},I=e=>{const t=e.changeEvent.doc;if(!t)return!1;const n=p(e.previousResults);if(!n)return!1;if(n[e.queryParams.primaryKey]===e.changeEvent.id)return!0;return e.queryParams.sortComparator(t,n)>0},T=e=>{const t=e.changeEvent.previous;return!!t&&e.queryParams.queryMatcher(t)},M=e=>{const t=e.changeEvent.doc;if(!t)return!1;return e.queryParams.queryMatcher(t)},D=e=>0===e.previousResults.length,R={0:_,1:x,2:w,3:m,4:b,5:g,6:D,7:O,8:P,9:S,10:k,11:E,12:A,13:j,14:C,15:I,16:T,17:M};let K;function N(){return K||(K=function(e){const t=new Map,n=2+2*parseInt(e.charAt(0)+e.charAt(1),10),r=f(e.substring(2,n),2);for(let a=0;afunction(e,t,n){let r=e,o=e.l;for(;;){if(r=r[t[o](n)?"1":"0"],"number"==typeof r||"string"==typeof r)return r;o=r.l}}(N(),R,e);function q(e){const t=B(e);return c[t]}function F(e,t,n,r,o){return(0,l[e])({queryParams:t,changeEvent:n,previousResults:r,keyDocumentMap:o}),r}},5525:(e,t,n)=>{"use strict";n.d(t,{p4:()=>r});class r{ttl;map=new Map;_to=!1;constructor(e){this.ttl=e}has(e){return this.map.has(e)}add(e){this.map.set(e,o()),this._to||(this._to=!0,setTimeout((()=>{this._to=!1,function(e){const t=o()-e.ttl,n=e.map[Symbol.iterator]();for(;;){const r=n.next().value;if(!r)return;const o=r[0];if(!(r[1]{"use strict";n.d(t,{sc:()=>p});Object.freeze({ignoreUnknown:!1,respectType:!1,respectFunctionNames:!1,respectFunctionProperties:!1,unorderedObjects:!0,unorderedArrays:!1,unorderedSets:!1,excludeKeys:void 0,excludeValues:void 0,replacer:void 0});Object.freeze(["prototype","__proto__","constructor"]);const r="[native code] }";r.length;class o{constructor(e,t){e=this.words=e||[],this.sigBytes=void 0===t?4*e.length:t}toString(e){return(e||i).stringify(this)}concat(e){if(this.clamp(),this.sigBytes%4)for(let t=0;t>>2]>>>24-t%4*8&255;this.words[this.sigBytes+t>>>2]|=n<<24-(this.sigBytes+t)%4*8}else for(let t=0;t>>2]=e.words[t>>>2];return this.sigBytes+=e.sigBytes,this}clamp(){this.words[this.sigBytes>>>2]&=4294967295<<32-this.sigBytes%4*8,this.words.length=Math.ceil(this.sigBytes/4)}clone(){return new o([...this.words])}}const i={stringify(e){const t=[];for(let n=0;n>>2]>>>24-n%4*8&255;t.push((r>>>4).toString(16),(15&r).toString(16))}return t.join("")}},s={parse(e){const t=e.length,n=[];for(let r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o(n,t)}},u={parse:e=>s.parse(unescape(encodeURIComponent(e)))};class a{constructor(){this._data=new o,this._nDataBytes=0,this._minBufferSize=0,this.blockSize=16}reset(){this._data=new o,this._nDataBytes=0}_append(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes}_doProcessBlock(e,t){}_process(e){let t,n=this._data.sigBytes/(4*this.blockSize);n=e?Math.ceil(n):Math.max((0|n)-this._minBufferSize,0);const r=n*this.blockSize,i=Math.min(4*r,this._data.sigBytes);if(r){for(let e=0;e>>7)^(e<<14|e>>>18)^e>>>3,n=h[d-2],r=(n<<15|n>>>17)^(n<<13|n>>>19)^n>>>10;h[d]=t+h[d-7]+r+h[d-16]}const n=r&o^r&i^o&i,p=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),y=l+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&a^~u&c)+f[d]+h[d];l=c,c=a,a=u,u=s+y|0,s=i,i=o,o=r,r=y+(p+n)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+a|0,n[6]=n[6]+c|0,n[7]=n[7]+l|0}finalize(e){super.finalize(e);const t=8*this._nDataBytes,n=8*this._data.sigBytes;return this._data.words[n>>>5]|=128<<24-n%32,this._data.words[14+(n+64>>>9<<4)]=Math.floor(t/4294967296),this._data.words[15+(n+64>>>9<<4)]=t,this._data.sigBytes=4*this._data.words.length,this._process(),this._hash}}function p(e){return(new d).finalize(e).toString()}},4629:(e,t,n)=>{"use strict";n.d(t,{AQ:()=>f,C6:()=>o,Ju:()=>u,N3:()=>l,YH:()=>s,fX:()=>c,sH:()=>i,xN:()=>h,zs:()=>a});var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function i(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(t){i(t)}}function u(e){try{a(r.throw(e))}catch(t){i(t)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))}function s(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,r=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(u){o={error:u}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function c(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o1||u(e,t)}))})}function u(e,t){try{(n=o[e](t)).value instanceof l?Promise.resolve(n.value.v).then(a,c):f(i[0][2],n)}catch(r){f(i[0][3],r)}var n}function a(e){u("next",e)}function c(e){u("throw",e)}function f(e,t){e(t),i.shift(),i.length&&u(i[0][0],i[0][1])}}function h(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=u(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}}Object.create;"function"==typeof SuppressedError&&SuppressedError}}]); \ No newline at end of file +(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[5106],{7635:(e,t,n)=>{"use strict";n.d(t,{G:()=>r});var r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this._parallels=e||1,this._qC=0,this._iC=new Set,this._lHN=0,this._hPM=new Map,this._pHM=new Map};function o(e,t){if(t){if(t._timeoutObj&&clearTimeout(t._timeoutObj),e._pHM.has(t)){var n=e._pHM.get(t);e._hPM.delete(n),e._pHM.delete(t)}e._iC.delete(t)}}function i(e){e._tryIR||0===e._iC.size||(e._tryIR=!0,setTimeout((function(){e.isIdle()?setTimeout((function(){e.isIdle()?(!function(e){0!==e._iC.size&&(e._iC.values().next().value._manRes(),setTimeout((function(){return i(e)}),0))}(e),e._tryIR=!1):e._tryIR=!1}),0):e._tryIR=!1}),0))}r.prototype={isIdle:function(){return this._qC.",et="String expected.",tt=[],nt="__dbnames",rt="readonly",ot="readwrite";function it(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var st={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function ut(e){return"string"!=typeof e||/\./.test(e)?function(e){return e}:function(t){return void 0===t[e]&&e in t&&delete(t=j(t))[e],t}}function at(){throw W.Type()}function ct(e,t){try{var n=lt(e),r=lt(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return ti+s&&o(i+d)}))}))}return o(0).then((function(){if(0=o}))).length?(t.forEach((function(e){c.push((function(){var t=l,n=e._cfg.dbschema;ln(r,t,a),ln(r,n,a),l=r._dbSchema=n;var s=on(t,n);s.add.forEach((function(e){sn(a,e[0],e[1].primKey,e[1].indexes)})),s.change.forEach((function(e){if(e.recreate)throw new W.Upgrade("Not yet support for changing primary key");var t=a.objectStore(e.name);e.add.forEach((function(e){return an(t,e)})),e.change.forEach((function(e){t.deleteIndex(e.name),an(t,e)})),e.del.forEach((function(e){return t.deleteIndex(e)}))}));var c=e._cfg.contentUpgrade;if(c&&e._cfg.version>o){Jt(r,a),u._memoizedTables={};var f=O(n);s.del.forEach((function(e){f[e]=t[e]})),en(r,[r.Transaction.prototype]),Zt(r,[r.Transaction.prototype],i(f),f),u.schema=f;var h,d=N(c);return d&&$e(),s=xe.follow((function(){var e;(h=c(u))&&d&&(e=Ue.bind(null,null),h.then(e,e))})),h&&"function"==typeof h.then?xe.resolve(h):s.then((function(){return h}))}})),c.push((function(t){var n,o,i=e._cfg.dbschema;n=i,o=t,[].slice.call(o.db.objectStoreNames).forEach((function(e){return null==n[e]&&o.db.deleteObjectStore(e)})),en(r,[r.Transaction.prototype]),Zt(r,[r.Transaction.prototype],r._storeNames,r._dbSchema),u.schema=r._dbSchema})),c.push((function(t){r.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(r.idbdb.version/10)===e._cfg.version?(r.idbdb.deleteObjectStore("$meta"),delete r._dbSchema.$meta,r._storeNames=r._storeNames.filter((function(e){return"$meta"!==e}))):t.objectStore("$meta").put(e._cfg.version,"version"))}))})),function e(){return c.length?xe.resolve(c.shift()(u.idbtrans)).then(e):xe.resolve()}().then((function(){un(l,a)}))):xe.resolve();var r,o,u,a,c,l})).catch(u)):(i(o).forEach((function(e){sn(n,e,o[e].primKey,o[e].indexes)})),Jt(e,n),void xe.follow((function(){return e.on.populate.fire(s)})).catch(u));var r,c}))}function rn(e,t){un(e._dbSchema,t),t.db.version%10!=0||t.objectStoreNames.contains("$meta")||t.db.createObjectStore("$meta").add(Math.ceil(t.db.version/10-1),"version");var n=cn(0,e.idbdb,t);ln(e,e._dbSchema,t);for(var r=0,o=on(n,e._dbSchema).change;rMath.pow(2,62)?0:r.oldVersion,h=r<1,e.idbdb=d.result,s&&rn(e,f),nn(e,r/10,f,c))}),c),d.onsuccess=De((function(){f=null;var n,u,c,p,y,v=e.idbdb=d.result,b=m(v.objectStoreNames);if(0t.limit?n.length=t.limit:e.length===t.limit&&n.length=r.limit&&(!r.values||e.req.values)&&Yn(e.req.query.range,r.query.range)})),!1,o,i];case"count":return s=i.find((function(e){return Xn(e.req.query.range,r.query.range)})),[s,!!s,o,i]}}(n,r,"query",e),a=u[0],c=u[1],l=u[2],f=u[3];return a&&c?a.obsSet=e.obsSet:(c=o.query(e).then((function(e){var n=e.result;if(a&&(a.res=n),t){for(var r=0,o=n.length;r{"use strict";n.d(t,{u:()=>s});var r=n(2779),o=n(374),i=n(744);class s{constructor(e,t){this.pipeline=e,this.options=(0,r.B3)(t)}stream(e){let t=(0,o.dF)(e);const n=this.options.processingMode;n!=r.to.CLONE_ALL&&n!=r.to.CLONE_INPUT||t.map(i.mg);const s=new Array;if(!(0,i.Im)(this.pipeline))for(const o of this.pipeline){const e=Object.keys(o),n=e[0],u=(0,r.F5)(r.hu.PIPELINE,n,this.options);(0,i.vA)(1===e.length&&!!u,`invalid pipeline operator ${n}`),s.push(n),t=u(t,o[n],this.options)}return(n==r.to.CLONE_OUTPUT||n==r.to.CLONE_ALL&&(0,i.E$)([["$group","$unwind"],s]).length)&&t.map(i.mg),t}run(e){return this.stream(e).value()}}},2779:(e,t,n)=>{"use strict";n.d(t,{B3:()=>a,DZ:()=>f,F5:()=>h,hu:()=>o,px:()=>y,qk:()=>u,to:()=>r});var r,o,i=n(3787),s=n(744);!function(e){e.CLONE_ALL="CLONE_ALL",e.CLONE_INPUT="CLONE_INPUT",e.CLONE_OUTPUT="CLONE_OUTPUT",e.CLONE_OFF="CLONE_OFF"}(r||(r={}));class u{constructor(e,t,n,r=Date.now()){this._opts=e,this._root=t,this._local=n,this.timestamp=r,this.update(t,n)}static init(e,t,n){return e instanceof u?new u(e._opts,(0,s.gD)(e.root)?t:e.root,Object.assign({},e.local,n)):new u(e,t,n)}update(e,t){var n;return this._root=e,this._local=t?Object.assign({},t,{variables:Object.assign({},null===(n=this._local)||void 0===n?void 0:n.variables,null==t?void 0:t.variables)}):t,this}getOptions(){return Object.freeze(Object.assign(Object.assign({},this._opts),{context:c.from(this._opts.context)}))}get root(){return this._root}get local(){return this._local}get idKey(){return this._opts.idKey}get collation(){var e;return null===(e=this._opts)||void 0===e?void 0:e.collation}get processingMode(){var e;return(null===(e=this._opts)||void 0===e?void 0:e.processingMode)||r.CLONE_OFF}get useStrictMode(){var e;return null===(e=this._opts)||void 0===e?void 0:e.useStrictMode}get scriptEnabled(){var e;return null===(e=this._opts)||void 0===e?void 0:e.scriptEnabled}get useGlobalContext(){var e;return null===(e=this._opts)||void 0===e?void 0:e.useGlobalContext}get hashFunction(){var e;return null===(e=this._opts)||void 0===e?void 0:e.hashFunction}get collectionResolver(){var e;return null===(e=this._opts)||void 0===e?void 0:e.collectionResolver}get jsonSchemaValidator(){var e;return null===(e=this._opts)||void 0===e?void 0:e.jsonSchemaValidator}get variables(){var e;return null===(e=this._opts)||void 0===e?void 0:e.variables}get context(){var e;return null===(e=this._opts)||void 0===e?void 0:e.context}}function a(e){return e instanceof u?e.getOptions():Object.freeze(Object.assign(Object.assign({idKey:"_id",scriptEnabled:!0,useStrictMode:!0,useGlobalContext:!0,processingMode:r.CLONE_OFF},e),{context:(null==e?void 0:e.context)?c.from(null==e?void 0:e.context):c.init({})}))}!function(e){e.ACCUMULATOR="accumulator",e.EXPRESSION="expression",e.PIPELINE="pipeline",e.PROJECTION="projection",e.QUERY="query",e.WINDOW="window"}(o||(o={}));class c{constructor(e){this.operators={[o.ACCUMULATOR]:{},[o.EXPRESSION]:{},[o.PIPELINE]:{},[o.PROJECTION]:{},[o.QUERY]:{},[o.WINDOW]:{}};for(const[t,n]of Object.entries(e))this.addOperators(t,n)}static init(e={}){return new c(e)}static from(e){return new c(e.operators)}addOperators(e,t){for(const[n,r]of Object.entries(t))this.getOperator(e,n)||(this.operators[e][n]=r);return this}addAccumulatorOps(e){return this.addOperators(o.ACCUMULATOR,e)}addExpressionOps(e){return this.addOperators(o.EXPRESSION,e)}addQueryOps(e){return this.addOperators(o.QUERY,e)}addPipelineOps(e){return this.addOperators(o.PIPELINE,e)}addProjectionOps(e){return this.addOperators(o.PROJECTION,e)}addWindowOps(e){return this.addOperators(o.WINDOW,e)}getOperator(e,t){return e in this.operators&&this.operators[e][t]||null}}const l=c.init();function f(e,t){for(const[n,r]of Object.entries(t)){(0,s.vA)((0,s.Tn)(r)&&(0,s.Zo)(n),`'${n}' is not a valid operator`);const t=h(e,n,null);(0,s.vA)(!t||r===t,`${n} already exists for '${e}' operators. Cannot change operator function once registered.`)}switch(e){case o.ACCUMULATOR:l.addAccumulatorOps(t);break;case o.EXPRESSION:l.addExpressionOps(t);break;case o.PIPELINE:l.addPipelineOps(t);break;case o.PROJECTION:l.addProjectionOps(t);break;case o.QUERY:l.addQueryOps(t);break;case o.WINDOW:l.addWindowOps(t)}}function h(e,t,n){const{context:r,useGlobalContext:o}=n||{},i=r?r.getOperator(e,t):null;return!i&&o?l.getOperator(e,t):i}const d={$$ROOT:(e,t,n)=>n.root,$$CURRENT:(e,t,n)=>e,$$REMOVE(e,t,n){},$$NOW:(e,t,n)=>new Date(n.timestamp)},p={$$KEEP:(e,t,n)=>e,$$PRUNE(e,t,n){},$$DESCEND(e,t,n){if(!(0,s.zy)(t,"$cond"))return e;let r;for(const[o,i]of Object.entries(e))if((0,s.Z4)(i)){if(i instanceof Array){const e=[];for(let r of i)(0,s.Gv)(r)&&(r=v(r,t,n.update(r))),(0,s.gD)(r)||e.push(r);r=e}else r=v(i,t,n.update(i));(0,s.gD)(r)?delete e[o]:e[o]=r}return e}};function y(e,t,n,r){var a;const c=u.init(r,e);if(n=n||"",(0,s.Zo)(n)){const u=h(o.EXPRESSION,n,r);if(u)return u(e,t,c);const a=h(o.ACCUMULATOR,n,r);if(a)return e instanceof Array||(e=y(e,t,null,c),t=null),(0,s.vA)(e instanceof Array,`'${n}' target must be an array.`),a(e,t,c.update(null,c.local));throw new i.d(`operator '${n}' is not registered`)}if((0,s.Kg)(t)&&t.length>0&&"$"===t[0]){if((0,s.zy)(p,t))return t;let n=c.root;const r=t.split(".");if((0,s.zy)(d,r[0]))n=d[r[0]](e,null,c),t=t.slice(r[0].length+1);else if("$$"===r[0].slice(0,2)){n=Object.assign({},c.variables,{this:e},null===(a=c.local)||void 0===a?void 0:a.variables);const o=r[0].slice(2);(0,s.vA)((0,s.zy)(n,o),`Use of undefined variable: ${o}`),t=t.slice(2)}else t=t.slice(1);return""===t?n:(0,s.hd)(n,t)}if((0,s.cy)(t))return t.map((t=>y(e,t,null,c)));if((0,s.Gv)(t)){const n={};for(const[i,u]of Object.entries(t))if(n[i]=y(e,u,i,c),[o.EXPRESSION,o.ACCUMULATOR].some((e=>!!h(e,i,r))))return(0,s.vA)(1===Object.keys(t).length,"Invalid aggregation expression '"+JSON.stringify(t)+"'"),n[i];return n}return t}function v(e,t,n){const r=y(e,t,null,n);return(0,s.zy)(p,r)?p[r](e,t,n):r}},374:(e,t,n)=>{"use strict";n.d(t,{Zz:()=>i,dF:()=>o});var r=n(3787);function o(e){return e instanceof c?e:new c(e)}function i(...e){let t=0;return o((()=>{for(;t{const e=n.next();if(e.done)throw u;return e.value}}else if(e instanceof Array){const n=e,r=n.length;let o=0;t=()=>{if(o0?this.push(a.TAKE,e):this}drop(e){return e>0?this.push(a.DROP,e):this}transform(e){const t=this;let n;return o((()=>(n||(n=o(e(t.value()))),n.next())))}value(){return this.isDone||(this.isDone=this.getNext(!0).done),this.yieldedValues}each(e){for(;;){const t=this.next();if(t.done)break;if(!1===e(t.value))return!1}return!0}reduce(e,t){let n=this.next();for(void 0!==t||n.done||(t=n.value,n=this.next());!n.done;)t=e(t,n.value),n=this.next();return t}size(){return this.reduce(((e,t)=>++e),0)}[Symbol.iterator](){return this}}},6827:(e,t,n)=>{"use strict";n.d(t,{C5:()=>l,GU:()=>h,Gd:()=>w,Ig:()=>_,Jy:()=>O,MR:()=>y,NV:()=>d,P:()=>g,Pp:()=>m,Q_:()=>p,TU:()=>j,WP:()=>b,XV:()=>c,fw:()=>a,fy:()=>v,jm:()=>u,oZ:()=>f});var r=n(2779),o=n(1692),i=n(3787),s=n(744);function u(e){const t=(t,n,r)=>{const o={unwrapArray:!0},i=Math.max(1,t.split(".").length-1);return u=>{const a=(0,s.hd)(u,t,o);return e(a,n,Object.assign(Object.assign({},r),{depth:i}))}};return t.op="query",t}function a(e){return(t,n,o)=>{const i=(0,r.px)(t,n,null,o);return e(...i)}}function c(e,t,n){if((0,s.n4)(e,t))return!0;if((0,s.gD)(e)&&(0,s.gD)(t))return!0;if(e instanceof Array){const r=s.n4.bind(null,t);return e.some(r)||(0,s.Bq)(e,null==n?void 0:n.depth).some(r)}return!1}function l(e,t,n){return!c(e,t,n)}function f(e,t,n){return(0,s.gD)(e)?t.some((e=>null===e)):(0,s.E$)([(0,s.eC)(e),t],null==n?void 0:n.hashFunction).length>0}function h(e,t,n){return!f(e,t,n)}function d(e,t,n){return C(e,t,((e,t)=>(0,s.UD)(e,t)<0))}function p(e,t,n){return C(e,t,((e,t)=>(0,s.UD)(e,t)<=0))}function y(e,t,n){return C(e,t,((e,t)=>(0,s.UD)(e,t)>0))}function v(e,t,n){return C(e,t,((e,t)=>(0,s.UD)(e,t)>=0))}function m(e,t,n){return(0,s.eC)(e).some((e=>2===t.length&&e%t[0]===t[1]))}function b(e,t,n){const r=(0,s.eC)(e),o=e=>(0,s.Kg)(e)&&(0,s.vN)(t.exec(e),null==n?void 0:n.useStrictMode);return r.some(o)||(0,s.Bq)(r,1).some(o)}function g(e,t,n){return(!1===t||0===t)&&void 0===e||(!0===t||1===t)&&void 0!==e}function w(e,t,n){if(!((0,s.cy)(e)&&(0,s.cy)(t)&&e.length&&t.length))return!1;let r=!0;for(const o of t){if(!r)break;r=(0,s.Gv)(o)&&(0,s.RV)(Object.keys(o),"$elemMatch")?O(e,o.$elemMatch,n):o instanceof RegExp?e.some((e=>"string"==typeof e&&o.test(e))):e.some((e=>(0,s.n4)(o,e)))}return r}function _(e,t,n){return Array.isArray(e)&&e.length===t}function x(e){return(0,s.Zo)(e)&&-1===["$and","$or","$nor"].indexOf(e)}function O(e,t,n){if((0,s.cy)(e)&&!(0,s.Im)(e)){let r=e=>e,i=t;Object.keys(t).every(x)&&(i={temp:t},r=e=>({temp:e}));const s=new o.X(i,n);for(let t=0,n=e.length;tnull===e,E=e=>(0,s.Et)(e)&&e>=s.R&&e<=s.Hq&&-1===e.toString().indexOf("."),P=e=>(0,s.Et)(e)&&e>=s.oU&&e<=s.W_&&-1===e.toString().indexOf("."),S={array:s.cy,bool:s.Lm,boolean:s.Lm,date:s.$P,decimal:s.Et,double:s.Et,int:E,long:P,number:s.Et,null:k,object:s.Gv,regex:s.gd,regexp:s.gd,string:s.Kg,undefined:s.gD,function:e=>{throw new i.d("unsupported type key `function`.")},1:s.Et,2:s.Kg,3:s.Gv,4:s.cy,6:s.gD,8:s.Lm,9:s.$P,10:k,11:s.gd,16:E,18:P,19:s.Et};function A(e,t,n){const r=S[t];return!!r&&r(e)}function j(e,t,n){return Array.isArray(t)?t.findIndex((t=>A(e,t)))>=0:A(e,t)}function C(e,t,n){return(0,s.eC)(e).some((e=>(0,s.Pw)(e)===(0,s.Pw)(t)&&n(e,t)))}},4903:(e,t,n)=>{"use strict";n.d(t,{C2:()=>y,xF:()=>i});var r=n(2779),o=n(744);n(374);n(7681);new WeakMap;const i=(e,t,n)=>{if((0,o.Im)(t)||!(0,o.Gv)(t))return e;let r=o.UD;const i=n.collation;return(0,o.Gv)(i)&&(0,o.Kg)(i.locale)&&(r=function(e){const t={sensitivity:s[e.strength||3],caseFirst:"off"===e.caseFirst?"false":e.caseFirst||"false",numeric:e.numericOrdering||!1,ignorePunctuation:"shifted"===e.alternate};!0===(e.caseLevel||!1)&&("base"===t.sensitivity&&(t.sensitivity="case"),"accent"===t.sensitivity&&(t.sensitivity="variant"));const n=new Intl.Collator(e.locale,t);return(e,t)=>{if(!(0,o.Kg)(e)||!(0,o.Kg)(t))return(0,o.UD)(e,t);const r=n.compare(e,t);return r<0?-1:r>0?1:0}}(i)),e.transform((e=>{const i=Object.keys(t);for(const s of i.reverse()){const i=(0,o.$z)(e,(e=>(0,o.hd)(e,s)),n.hashFunction),u=Array.from(i.keys()).sort(r);-1===t[s]&&u.reverse(),e=[],u.reduce(((e,t)=>(0,o.dj)(e,i.get(t))),e)}return e}))},s={1:"base",2:"accent",3:"variant"};new Set(["$denseRank","$documentNumber","$first","$last","$linearFill","$rank","$shift"]),new Set(["$denseRank","$expMovingAvg","$linearFill","$locf","$rank","$shift"]);n(1692);var u=n(6827);(0,u.fw)(u.GU);const a=(e,t)=>(n,i,s)=>{(0,o.vA)((0,o.cy)(i),`${e}: expression must be an array.`);const u=(0,r.px)(n,i,null,s);return u.some(o.gD)?null:((0,o.vA)(u.every(o.Et),`${e}: expression must evalue to array of numbers.`),t(u))};a("$bitAnd",(e=>e.reduce(((e,t)=>e&t),-1))),a("$bitOr",(e=>e.reduce(((e,t)=>e|t),0))),a("$bitXor",(e=>e.reduce(((e,t)=>e^t),0))),(0,u.fw)(u.XV),(0,u.fw)(u.MR),(0,u.fw)(u.fy),(0,u.fw)(u.NV),(0,u.fw)(u.Q_),(0,u.fw)(u.C5);const c=(e,t)=>{const n={};return e.split("").forEach(((e,r)=>n[e]=t*(r+1))),n};Object.assign(Object.assign(Object.assign({},c("ABCDEFGHIKLM",1)),c("NOPQRSTUVWXY",-1)),{Z:0});var l=n(3787);const f={undefined:null,null:null,NaN:NaN,Infinity:new Error,"-Infinity":new Error};function h(e,t=f){const n=Object.assign({},f,t),o=new Set(Object.keys(n));return(t,i,s)=>{const u=(0,r.px)(t,i,null,s);if(o.has(`${u}`)){const t=n[`${u}`];if(t instanceof Error)throw new l.d(`cannot apply $${e.name} to -inf, value must in (-inf,inf)`);return t}return e(u)}}h(Math.acos,{Infinity:1/0,0:new Error}),h(Math.acosh,{Infinity:1/0,0:new Error}),h(Math.asin),h(Math.asinh,{Infinity:1/0,"-Infinity":-1/0}),h(Math.atan),h(Math.atanh,{1:1/0,"-1":-1/0}),h(Math.cos),h(Math.cosh,{"-Infinity":1/0,Infinity:1/0});const d=Math.PI/180,p=(h((e=>e*d),{Infinity:1/0,"-Infinity":1/0}),180/Math.PI);h((e=>e*p),{Infinity:1/0,"-Infinity":-1/0}),h(Math.sin),h(Math.sinh,{"-Infinity":-1/0,Infinity:1/0}),h(Math.tan);Error;const y=(e,t,n)=>{if((0,o.Im)(t))return e;let i=Object.keys(t),s=!1;m(t,n);const u=n.idKey;if((0,o.RV)(i,u)){const e=t[u];0!==e&&!1!==e||(i=i.filter(o.KL.bind(null,[u])),s=0==i.length)}else i.push(u);const a=r.qk.init(n);return e.map((e=>v(e,t,a.update(e),i,s)))};function v(e,t,n,i,s){let u={},a=!1,c=!1;const l=[];s&&l.push(n.idKey);for(const f of i){let i;const s=t[f];if(f!==n.idKey&&(0,o.RV)([0,!1],s)&&(c=!0),f===n.idKey&&(0,o.Im)(s))i=e[f];else if((0,o.Kg)(s))i=(0,r.px)(e,s,f,n);else if((0,o.RV)([1,!0],s));else if(s instanceof Array)i=s.map((t=>{const i=(0,r.px)(e,t,null,n);return(0,o.gD)(i)?null:i}));else{if(!(0,o.Gv)(s)){l.push(f);continue}{const t=s,u=Object.keys(s),c=1==u.length?u[0]:"",l=(0,r.F5)(r.hu.PROJECTION,c,n);if(l)"$slice"===c?(0,o.eC)(t[c]).every(o.Et)?(i=l(e,t[c],f,n),a=!0):i=(0,r.px)(e,t,f,n):i=l(e,t[c],f,n);else if((0,o.Zo)(c))i=(0,r.px)(e,t[c],c,n);else if((0,o.zy)(e,f)){m(t,n);let r=e[f];r instanceof Array?i=r.map((e=>v(e,t,n,u,!1))):(r=(0,o.Gv)(r)?r:e,i=v(r,t,n,u,!1))}else i=(0,r.px)(e,s,null,n)}}const h=(0,o.Rm)(e,f,{preserveMissing:!0});void 0!==h&&(0,o.h1)(u,h,{flatten:!0}),(0,o.KL)([0,1,!1,!0],s)&&(void 0===i?(0,o.yT)(u,f,{descendArray:!0}):(0,o.KY)(u,f,i))}if((0,o.B2)(u),(a||c||s)&&(u=(0,o.dj)({},e,u),l.length>0))for(const r of l)(0,o.yT)(u,r,{descendArray:!0});return u}function m(e,t){const n=[!1,!1];for(const[r,i]of Object.entries(e)){if(r===(null==t?void 0:t.idKey))return;0===i||!1===i?n[0]=!0:1!==i&&!0!==i||(n[1]=!0),(0,o.vA)(!(n[0]&&n[1]),"Projection cannot have a mix of inclusion and exclusion.")}}},6950:(e,t,n)=>{"use strict";n.d(t,{Jy:()=>o,Ig:()=>i});var r=n(6827);(0,r.jm)(r.Gd);const o=(0,r.jm)(r.Jy),i=(0,r.jm)(r.Ig)},2403:(e,t,n)=>{"use strict";n.d(t,{XV:()=>o,MR:()=>i,fy:()=>s,oZ:()=>u,NV:()=>a,Q_:()=>c,C5:()=>l,GU:()=>f});var r=n(6827);const o=(0,r.jm)(r.XV),i=(0,r.jm)(r.MR),s=(0,r.jm)(r.fy),u=(0,r.jm)(r.oZ),a=(0,r.jm)(r.NV),c=(0,r.jm)(r.Q_),l=(0,r.jm)(r.C5),f=(0,r.jm)(r.GU)},6823:(e,t,n)=>{"use strict";n.d(t,{P:()=>o,T:()=>i});var r=n(6827);const o=(0,r.jm)(r.P),i=(0,r.jm)(r.TU)},6776:(e,t,n)=>{"use strict";n.d(t,{Pp:()=>o,WP:()=>i});n(2779);var r=n(6827);const o=(0,r.jm)(r.Pp),i=(0,r.jm)(r.WP);n(744)},7705:(e,t,n)=>{"use strict";n.d(t,{a6:()=>i,q3:()=>u,En:()=>a,sU:()=>s});var r=n(1692),o=n(744);const i=(e,t,n)=>{(0,o.vA)((0,o.cy)(t),"Invalid expression: $and expects value to be an Array.");const i=t.map((e=>new r.X(e,n)));return e=>i.every((t=>t.test(e)))},s=(e,t,n)=>{(0,o.vA)((0,o.cy)(t),"Invalid expression. $or expects value to be an Array");const i=t.map((e=>new r.X(e,n)));return e=>i.some((t=>t.test(e)))},u=(e,t,n)=>{(0,o.vA)((0,o.cy)(t),"Invalid expression. $nor expects value to be an array.");const r=s("$or",t,n);return e=>!r(e)},a=(e,t,n)=>{const i={};i[e]=(0,o.S8)(t);const s=new r.X(i,n);return e=>!s.test(e)}},1692:(e,t,n)=>{"use strict";n.d(t,{X:()=>c});var r=n(2779),o=n(7681),i=n(374),s=n(744);class u{constructor(e,t,n,r){this.source=e,this.predicate=t,this.projection=n,this.options=r,this.operators=[],this.result=null,this.buffer=[]}fetch(){return this.result||((0,s.Gv)(this.projection)&&this.operators.push({$project:this.projection}),this.result=(0,i.dF)(this.source).filter(this.predicate),this.operators.length>0&&(this.result=new o.u(this.operators,this.options).stream(this.result))),this.result}fetchAll(){const e=(0,i.dF)([...this.buffer]);return this.buffer=[],(0,i.Zz)(e,this.fetch())}all(){return this.fetchAll().value()}count(){return this.all().length}skip(e){return this.operators.push({$skip:e}),this}limit(e){return this.operators.push({$limit:e}),this}sort(e){return this.operators.push({$sort:e}),this}collation(e){return this.options=Object.assign(Object.assign({},this.options),{collation:e}),this}next(){if(this.buffer.length>0)return this.buffer.pop();const e=this.fetch().next();return e.done?void 0:e.value}hasNext(){if(this.buffer.length>0)return!0;const e=this.fetch().next();return!e.done&&(this.buffer.push(e.value),!0)}map(e){return this.all().map(e)}forEach(e){this.all().forEach(e)}[Symbol.iterator](){return this.fetchAll()}}var a=n(3787);class c{constructor(e,t){this.condition=e,this.options=(0,r.B3)(t),this.compiled=[],this.compile()}compile(){(0,s.vA)((0,s.Gv)(this.condition),`query criteria must be an object: ${JSON.stringify(this.condition)}`);const e={};for(const[t,n]of Object.entries(this.condition)){if("$where"===t)Object.assign(e,{field:t,expr:n});else if((0,s.RV)(["$and","$or","$nor","$expr","$jsonSchema"],t))this.processOperator(t,t,n);else{(0,s.vA)(!(0,s.Zo)(t),`unknown top level operator: ${t}`);for(const[e,r]of Object.entries((0,s.S8)(n)))this.processOperator(t,e,r)}e.field&&this.processOperator(e.field,e.field,e.expr)}}processOperator(e,t,n){const o=(0,r.F5)(r.hu.QUERY,t,this.options);if(!o)throw new a.d(`unknown query operator ${t}`);const i=o(e,n,this.options);this.compiled.push(i)}test(e){for(let t=0,n=this.compiled.length;tthis.test(e)),t||{},this.options)}remove(e){return e.reduce(((e,t)=>(this.test(t)||e.push(t),e)),[])}}},3787:(e,t,n)=>{"use strict";n.d(t,{d:()=>r});class r extends Error{}},744:(e,t,n)=>{"use strict";n.d(t,{$P:()=>M,$z:()=>J,B2:()=>oe,Bq:()=>X,E$:()=>G,Et:()=>j,Gv:()=>I,Hq:()=>o,Im:()=>F,KL:()=>B,KY:()=>ue,Kg:()=>A,Lm:()=>S,Pw:()=>P,R:()=>i,RV:()=>N,Rm:()=>re,S8:()=>fe,Tn:()=>R,UD:()=>O,W_:()=>s,Z4:()=>T,Zo:()=>le,cy:()=>C,dj:()=>ee,eC:()=>$,gD:()=>K,gd:()=>D,h1:()=>V,hd:()=>ne,mg:()=>E,n4:()=>H,oU:()=>u,vA:()=>k,vN:()=>q,yT:()=>ae,zy:()=>U});var r=n(3787);const o=2147483647,i=-2147483648,s=Number.MAX_SAFE_INTEGER,u=Number.MIN_SAFE_INTEGER,a=Symbol("missing"),c=Object.freeze(new Error("mingo: cycle detected while processing object/array")),l=Object.getPrototypeOf([]),f=Object.getPrototypeOf({}),h=/^\[object ([a-zA-Z0-9]+)\]$/;class d{}class p{}const y=e=>null===e?d:void 0===e?p:e.constructor,v=e=>{const t=function(e){const t=new Set,n=e=>{const r=y(e);if(_.has(r))return _.get(r)(e);const o=r===Object?"":r.name;if(R(e.toJSON))return`${o}(${JSON.stringify(e)})`;if(t.has(e))throw c;t.add(e);try{if(r===Array)return"["+e.map(n).join(",")+"]";if(r!==Object){const[t,r]=Y(e);if(C(e))return`${o}${n([...e,t])}`;e=t}const t=Object.keys(e);return t.sort(),`${o}{`+t.map((t=>`${t}:${n(e[t])}`)).join(",")+"}"}finally{t.delete(e)}};return n(e)}(e);let n=0,r=t.length;for(;r;)n=(n<<5)-n^t.charCodeAt(--r);return n>>>0},m=new Set(["null","undefined","boolean","number","string","date","regexp"]),b=new Set([p,d,Boolean,String,Number]),g=e=>e.toString(),w=e=>`${y(e).name}[${e.toString()}]`,_=new Map([[Number,g],[Boolean,g],[RegExp,g],[Function,g],[Symbol,g],[Date,e=>e.toISOString()],[String,JSON.stringify],[d,e=>"null"],[p,e=>"undefined"],[Int8Array,w],[Uint8Array,w],[Uint8ClampedArray,w],[Int16Array,w],[Uint16Array,w],[Int32Array,w],[Uint32Array,w],[Float32Array,w],[Float64Array,w]]);"undefined"!=typeof BigInt&&_.set(BigInt,(e=>"0x"+e.toString(16))),"undefined"!=typeof BigInt64Array&&_.set(BigInt64Array,w),"undefined"!=typeof BigUint64Array&&_.set(BigUint64Array,w);const x={null:0,undefined:0,number:1,string:2,object:3,array:4,boolean:5,date:6,regexp:7,function:8},O=(e,t)=>{e===a&&(e=void 0),t===a&&(t=void 0);const[n,r]=[e,t].map((e=>x[P(e).toLowerCase()]));return n!==r?n-r:1===n||2===n||6===n?et?1:0:H(e,t)?0:et?1:0};function k(e,t){if(!e)throw new r.d(t)}const E=e=>{if(b.has(y(e)))return e;const t=new Set,n=e=>{if(t.has(e))throw c;const r=y(e);if(b.has(r))return e;try{if(C(e))return t.add(e),e.map(n);if(I(e)){t.add(e);const r={};for(const t in e)r[t]=n(e[t]);return r}}finally{t.delete(e)}return r===Date||r===RegExp||(e=>{const t=Object.getPrototypeOf(y(e));return t&&"TypedArray"===t.name})(e)?new r(e):e};return n(e)},P=e=>h.exec(Object.prototype.toString.call(e))[1],S=e=>"boolean"==typeof e,A=e=>"string"==typeof e,j=e=>!isNaN(e)&&"number"==typeof e,C=Array.isArray,I=e=>{if(!e)return!1;const t=Object.getPrototypeOf(e);return(t===f||null===t)&&"[object Object]"===Object.prototype.toString.call(e)},T=e=>e===Object(e),M=e=>e instanceof Date,D=e=>e instanceof RegExp,R=e=>"function"==typeof e,K=e=>null==e,N=(e,t)=>e.includes(t),B=(e,t)=>!N(e,t),q=(e,t=!0)=>!!e||t&&""===e,F=e=>K(e)||A(e)&&!e||e instanceof Array&&0===e.length||I(e)&&0===Object.keys(e).length,L=e=>e===a,$=e=>e instanceof Array?e:[e],U=(e,t)=>!!e&&Object.prototype.hasOwnProperty.call(e,t),z=(e,t)=>I(e)&&I(t)||C(e)&&C(t);function V(e,t,n){if(n=n||{flatten:!1},L(e)||K(e))return t;if(L(t)||K(t))return e;if(!z(e,t)){if(n.skipValidation)return t||e;throw Error("mismatched types. must both be array or object")}if(n.skipValidation=!0,C(e)){const r=e,o=t;if(n.flatten){let e=0,i=0;for(;e{const i=Q(r,t);n.has(i)?n.get(i).some((t=>H(e[t],r)))||n.get(i).push(o):n.set(i,[o])})),n}function G(e,t=v){if(e.some((e=>0==e.length)))return[];if(1===e.length)return Array.from(e);const n=function(e,t,n=O){if(F(e))return e;const r=new Array,o=new Array;for(let i=0;in(e[0],t[0]))),ee(o,r.map((e=>e[1])))}(e.map(((e,t)=>[t,e.length])),(e=>e[1])),r=e[n[0][0]],o=W(r,t),i=new Map,s=new Array;return o.forEach(((t,o)=>{const u=t.map((e=>r[e])),c=u.map((e=>0)),l=u.map((e=>[n[0][0],0]));let f=!1;for(let r=1;ra[e]));f=u.map(((n,s)=>e.some(((e,u)=>{const a=c[s];return H(n,e)&&(c[s]++,tt===e.length-1?[u[n],l[n]]:a)).filter((e=>e!==a)))})),s.sort(((e,t)=>{const[n,[r,o]]=e,[i,[s,u]]=t,a=O(r,s);return 0!==a?a:O(o,u)})).map((e=>e[0]))}function X(e,t=0){const n=new Array;return function e(t,r){for(let o=0,i=t.length;o0||r<0)?e(t[o],Math.max(-1,r-1)):n.push(t[o])}(e,t),n}const Y=e=>{let[t,n]=[Object.getPrototypeOf(e),Object.getOwnPropertyNames(e)],r=t;for(;!n.length&&t!==f&&t!==l;)r=t,n=Object.getOwnPropertyNames(t),t=Object.getPrototypeOf(t);const o={};return n.forEach((t=>o[t]=e[t])),[o,r]};function H(e,t){const n=[[e,t]];for(;n.length>0;){if([e,t]=n.pop(),e===t)continue;const r=y(e);if(r!==y(t)||R(e))return!1;if(_.has(r)){const n=_.get(r);if(n(e)!==n(t))return!1}else{if(r!==Array&&r!==Object)return!1;{const r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;if(new Set(r.concat(o)).size!=r.length)return!1;for(const i of r)n.push([e[i],t[i]])}}}return!n.length}function Q(e,t){return t=t||v,K(e)?null:t(e).toString()}function J(e,t,n=v){if(e.length<1)return new Map;const r=new Map,o=new Map;for(let i=0;iH(e,u))):null;K(e)?(o.set(u,[s]),r.has(a)?r.get(a).push(u):r.set(a,[u])):o.get(e).push(s)}}return o}const Z=5e4;function ee(e,...t){return e instanceof Array?t.reduce(((e,t)=>{let n=Math.ceil(t.length/Z),r=0;for(;n-- >0;)Array.prototype.push.apply(e,t.slice(r,r+Z)),r+=Z;return e}),e):t.filter(T).reduce(((e,t)=>(Object.assign(e,t),e)),e)}function te(e,t){return T(e)?e[t]:void 0}function ne(e,t,n){let r=0;const o=m.has(P(e).toLowerCase())?e:function e(t,n){let o=t;for(let i=0;i0)break;r+=1;const t=n.slice(i);o=o.reduce(((n,r)=>{const o=e(r,t);return void 0!==o&&n.push(o),n}),[]);break}if(o=te(o,t),void 0===o)break}return o}(e,t.split("."));return o instanceof Array&&(null==n?void 0:n.unwrapArray)?function(e,t){if(t<1)return e;for(;t--&&1===e.length;)e=e[0];return e}(o,r):o}function re(e,t,n){const r=t.split("."),o=r[0],i=r.slice(1).join("."),s=null!==/^\d+$/.exec(o),u=r.length>1;let c,l;if(e instanceof Array)if(s)c=te(e,Number(o)),u&&(c=re(c,i,n)),c=[c];else{c=[];for(const r of e)l=re(r,t,n),(null==n?void 0:n.preserveMissing)?(void 0===l&&(l=a),c.push(l)):void 0!==l&&c.push(l)}else{if(l=te(e,o),u&&(l=re(l,i,n)),void 0===l)return;c=(null==n?void 0:n.preserveKeys)?Object.assign({},e):{},c[o]=l}return c}function oe(e){if(e instanceof Array)for(let t=e.length-1;t>=0;t--)e[t]===a?e.splice(t,1):oe(e[t]);else if(I(e))for(const t in e)U(e,t)&&oe(e[t])}const ie=/^\d+$/;function se(e,t,n,r){const o=t.split("."),i=o[0],s=o.slice(1).join(".");if(1===o.length)(I(e)||C(e)&&ie.test(i))&&n(e,i);else{(null==r?void 0:r.buildGraph)&&K(e[i])&&(e[i]={});const t=e[i];if(!t)return;const u=!!(o.length>1&&ie.test(o[1]));t instanceof Array&&(null==r?void 0:r.descendArray)&&!u?t.forEach((e=>se(e,s,n,r))):se(t,s,n,r)}}function ue(e,t,n){se(e,t,((e,t)=>{e[t]=R(n)?n(e[t]):n}),{buildGraph:!0})}function ae(e,t,n){se(e,t,((e,t)=>{if(e instanceof Array){if(/^\d+$/.test(t))e.splice(parseInt(t),1);else if(n&&n.descendArray)for(const n of e)I(n)&&delete n[t]}else I(e)&&delete e[t]}),n)}const ce=/^\$[a-zA-Z0-9_]+$/;function le(e){return ce.test(e)}function fe(e){if(m.has(P(e).toLowerCase()))return D(e)?{$regex:e}:{$eq:e};if(T(e)){const t=e;if(!Object.keys(t).some(le))return{$eq:e};if(U(e,"$regex")){const t=Object.assign({},e);return t.$regex=new RegExp(e.$regex,e.$options),delete t.$options,t}}return e}},2198:(e,t,n)=>{"use strict";n.d(t,{t:()=>o});var r=n(4629),o=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return(0,r.C6)(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){var e=this,t=e.hasError,n=e.thrownError,r=e._value;if(t)throw n;return this._throwIfClosed(),r},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(n(9092).B)},4134:(e,t,n)=>{"use strict";n.d(t,{c:()=>f});var r=n(8857),o=n(2258),i=n(8896),s=n(3887);function u(e){return 0===e.length?s.D:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var a=n(2236),c=n(1693),l=n(3004),f=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var i,s=this,u=(i=e)&&i instanceof r.vU||function(e){return e&&(0,c.T)(e.next)&&(0,c.T)(e.error)&&(0,c.T)(e.complete)}(i)&&(0,o.Uv)(i)?e:new r.Ms(e,t,n);return(0,l.Y)((function(){var e=s,t=e.operator,n=e.source;u.add(t?t.call(u,n):n?s._subscribe(u):s._trySubscribe(u))})),u},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=h(t))((function(t,o){var i=new r.Ms({next:function(t){try{e(t)}catch(n){o(n),i.unsubscribe()}},error:o,complete:t});n.subscribe(i)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[i.s]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t{"use strict";n.d(t,{B:()=>c});var r=n(4629),o=n(4134),i=n(2258),s=(0,n(5383).L)((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),u=n(34),a=n(3004),c=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return(0,r.C6)(t,e),t.prototype.lift=function(e){var t=new l(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new s},t.prototype.next=function(e){var t=this;(0,a.Y)((function(){var n,o;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=(0,r.Ju)(t.currentObservers),s=i.next();!s.done;s=i.next()){s.value.next(e)}}catch(u){n={error:u}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}}}))},t.prototype.error=function(e){var t=this;(0,a.Y)((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}}))},t.prototype.complete=function(){var e=this;(0,a.Y)((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,o=n.isStopped,s=n.observers;return r||o?i.Kn:(this.currentObservers=null,s.push(e),new i.yU((function(){t.currentObservers=null,(0,u.o)(s,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,o=t.isStopped;n?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new o.c;return e.source=this,e},t.create=function(e,t){return new l(e,t)},t}(o.c),l=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return(0,r.C6)(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:i.Kn},t}(c)},8857:(e,t,n)=>{"use strict";n.d(t,{Ms:()=>m,vU:()=>d});var r=n(4629),o=n(1693),i=n(2258),s=n(2236),u=n(6712);function a(){}var c=l("C",void 0,void 0);function l(e,t,n){return{kind:e,value:t,error:n}}var f=n(2332),h=n(3004),d=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,(0,i.Uv)(t)&&t.add(n)):n.destination=w,n}return(0,r.C6)(t,e),t.create=function(e,t,n){return new m(e,t,n)},t.prototype.next=function(e){this.isStopped?g(function(e){return l("N",e,void 0)}(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?g(l("E",void 0,e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?g(c,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(i.yU),p=Function.prototype.bind;function y(e,t){return p.call(e,t)}var v=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){b(n)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){b(n)}else b(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){b(t)}},e}(),m=function(e){function t(t,n,r){var i,u,a=e.call(this)||this;(0,o.T)(t)||!t?i={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:a&&s.$.useDeprecatedNextContext?((u=Object.create(t)).unsubscribe=function(){return a.unsubscribe()},i={next:t.next&&y(t.next,u),error:t.error&&y(t.error,u),complete:t.complete&&y(t.complete,u)}):i=t;return a.destination=new v(i),a}return(0,r.C6)(t,e),t}(d);function b(e){s.$.useDeprecatedSynchronousErrorHandling?(0,h.l)(e):(0,u.m)(e)}function g(e,t){var n=s.$.onStoppedNotification;n&&f.f.setTimeout((function(){return n(e,t)}))}var w={closed:!0,next:a,error:function(e){throw e},complete:a}},2258:(e,t,n)=>{"use strict";n.d(t,{Kn:()=>a,yU:()=>u,Uv:()=>c});var r=n(4629),o=n(1693),i=(0,n(5383).L)((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}})),s=n(34),u=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,n,s,u;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var c=(0,r.Ju)(a),f=c.next();!f.done;f=c.next()){f.value.remove(this)}}catch(m){e={error:m}}finally{try{f&&!f.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else a.remove(this);var h=this.initialTeardown;if((0,o.T)(h))try{h()}catch(b){u=b instanceof i?b.errors:[b]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var p=(0,r.Ju)(d),y=p.next();!y.done;y=p.next()){var v=y.value;try{l(v)}catch(g){u=null!=u?u:[],g instanceof i?u=(0,r.fX)((0,r.fX)([],(0,r.zs)(u)),(0,r.zs)(g.errors)):u.push(g)}}}catch(w){n={error:w}}finally{try{y&&!y.done&&(s=p.return)&&s.call(p)}finally{if(n)throw n.error}}}if(u)throw new i(u)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)l(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&(0,s.o)(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&(0,s.o)(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),a=u.EMPTY;function c(e){return e instanceof u||e&&"closed"in e&&(0,o.T)(e.remove)&&(0,o.T)(e.add)&&(0,o.T)(e.unsubscribe)}function l(e){(0,o.T)(e)?e():e.unsubscribe()}},2236:(e,t,n)=>{"use strict";n.d(t,{$:()=>r});var r={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1}},511:(e,t,n)=>{"use strict";n.d(t,{_:()=>i});var r=(0,n(5383).L)((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}})),o=n(8857);function i(e,t){var n="object"==typeof t;return new Promise((function(i,s){var u=new o.Ms({next:function(e){i(e),u.unsubscribe()},error:s,complete:function(){n?i(t.defaultValue):s(new r)}});e.subscribe(u)}))}},9852:(e,t,n)=>{"use strict";n.d(t,{H:()=>_});var r=n(7688),o=n(8071),i=n(5096),s=n(4370);function u(e,t){return void 0===t&&(t=0),(0,i.N)((function(n,r){n.subscribe((0,s._)(r,(function(n){return(0,o.N)(r,e,(function(){return r.next(n)}),t)}),(function(){return(0,o.N)(r,e,(function(){return r.complete()}),t)}),(function(n){return(0,o.N)(r,e,(function(){return r.error(n)}),t)})))}))}function a(e,t){return void 0===t&&(t=0),(0,i.N)((function(n,r){r.add(e.schedule((function(){return n.subscribe(r)}),t))}))}var c=n(4134);var l=n(9445),f=n(1693);function h(e,t){if(!e)throw new Error("Iterable cannot be null");return new c.c((function(n){(0,o.N)(n,t,(function(){var r=e[Symbol.asyncIterator]();(0,o.N)(n,t,(function(){r.next().then((function(e){e.done?n.complete():n.next(e.value)}))}),0,!0)}))}))}var d=n(9065),p=n(5796),y=n(9739),v=n(4799),m=n(3819),b=n(4429),g=n(3026);function w(e,t){if(null!=e){if((0,d.l)(e))return function(e,t){return(0,r.Tg)(e).pipe(a(t),u(t))}(e,t);if((0,y.X)(e))return function(e,t){return new c.c((function(n){var r=0;return t.schedule((function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())}))}))}(e,t);if((0,p.y)(e))return function(e,t){return(0,r.Tg)(e).pipe(a(t),u(t))}(e,t);if((0,m.T)(e))return h(e,t);if((0,v.x)(e))return function(e,t){return new c.c((function(n){var r;return(0,o.N)(n,t,(function(){r=e[l.l](),(0,o.N)(n,t,(function(){var e,t,o;try{t=(e=r.next()).value,o=e.done}catch(i){return void n.error(i)}o?n.complete():n.next(t)}),0,!0)})),function(){return(0,f.T)(null==r?void 0:r.return)&&r.return()}}))}(e,t);if((0,g.U)(e))return function(e,t){return h((0,g.C)(e),t)}(e,t)}throw(0,b.L)(e)}function _(e,t){return t?w(e,t):(0,r.Tg)(e)}},7688:(e,t,n)=>{"use strict";n.d(t,{Tg:()=>y});var r=n(4629),o=n(9739),i=n(5796),s=n(4134),u=n(9065),a=n(3819),c=n(4429),l=n(4799),f=n(3026),h=n(1693),d=n(6712),p=n(8896);function y(e){if(e instanceof s.c)return e;if(null!=e){if((0,u.l)(e))return b=e,new s.c((function(e){var t=b[p.s]();if((0,h.T)(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if((0,o.X)(e))return m=e,new s.c((function(e){for(var t=0;t{"use strict";n.d(t,{h:()=>a});var r=n(5499),o=n(7688),i=new(n(4134).c)((function(e){return e.complete()}));var s=n(235),u=n(9852);function a(){for(var e=[],t=0;t{"use strict";n.d(t,{_:()=>o});var r=n(4629);function o(e,t,n,r,o){return new i(e,t,n,r,o)}var i=function(e){function t(t,n,r,o,i,s){var u=e.call(this,t)||this;return u.onFinalize=i,u.shouldUnsubscribe=s,u._next=n?function(e){try{n(e)}catch(r){t.error(r)}}:e.prototype._next,u._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,u}return(0,r.C6)(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(n(8857).vU)},5520:(e,t,n)=>{"use strict";n.d(t,{F:()=>s});var r=n(3887),o=n(5096),i=n(4370);function s(e,t){return void 0===t&&(t=r.D),e=null!=e?e:u,(0,o.N)((function(n,r){var o,s=!0;n.subscribe((0,i._)(r,(function(n){var i=t(n);!s&&e(o,i)||(s=!1,o=i,r.next(n))})))}))}function u(e,t){return e===t}},8146:(e,t,n)=>{"use strict";n.d(t,{p:()=>i});var r=n(5096),o=n(4370);function i(e,t){return(0,r.N)((function(n,r){var i=0;n.subscribe((0,o._)(r,(function(n){return e.call(t,n,i++)&&r.next(n)})))}))}},7708:(e,t,n)=>{"use strict";n.d(t,{T:()=>i});var r=n(5096),o=n(4370);function i(e,t){return(0,r.N)((function(n,r){var i=0;n.subscribe((0,o._)(r,(function(n){r.next(e.call(t,n,i++))})))}))}},5499:(e,t,n)=>{"use strict";n.d(t,{U:()=>i});var r=n(2442),o=n(3887);function i(e){return void 0===e&&(e=1/0),(0,r.Z)(o.D,e)}},2442:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(7708),o=n(7688),i=n(5096),s=n(8071),u=n(4370);var a=n(1693);function c(e,t,n){return void 0===n&&(n=1/0),(0,a.T)(t)?c((function(n,i){return(0,r.T)((function(e,r){return t(n,e,i,r)}))((0,o.Tg)(e(n,i)))}),n):("number"==typeof t&&(n=t),(0,i.N)((function(t,r){return function(e,t,n,r,i,a,c,l){var f=[],h=0,d=0,p=!1,y=function(){!p||f.length||h||t.complete()},v=function(e){return h{"use strict";n.d(t,{X:()=>l});var r=n(4629),o=n(5096),i=Array.isArray;var s=n(5499),u=n(235),a=n(9852);function c(){for(var e=[],t=0;t{"use strict";n.d(t,{t:()=>f});var r=n(4629),o=n(9092),i={now:function(){return(i.delegate||Date).now()},delegate:void 0},s=function(e){function t(t,n,r){void 0===t&&(t=1/0),void 0===n&&(n=1/0),void 0===r&&(r=i);var o=e.call(this)||this;return o._bufferSize=t,o._windowTime=n,o._timestampProvider=r,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=n===1/0,o._bufferSize=Math.max(1,t),o._windowTime=Math.max(1,n),o}return(0,r.C6)(t,e),t.prototype.next=function(t){var n=this,r=n.isStopped,o=n._buffer,i=n._infiniteTimeWindow,s=n._timestampProvider,u=n._windowTime;r||(o.push(t),!i&&o.push(s.now()+u)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this._infiniteTimeWindow,r=this._buffer.slice(),o=0;o0&&(t=new a.Ms({next:function(e){return b.next(e)},error:function(e){p=!0,y(),r=l(v,i,e),b.error(e)},complete:function(){h=!0,y(),r=l(v,f),b.complete()}}),(0,u.Tg)(e).subscribe(t))}))(e)}}({connector:function(){return new s(h,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:d})}},3356:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var r=n(5499);var o=n(235),i=n(9852);function s(){for(var e=[],t=0;t{"use strict";n.d(t,{f:()=>o});var r=n(4629),o={setTimeout:function(e,t){for(var n=[],i=2;i{"use strict";n.d(t,{l:()=>r});var r="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"},8896:(e,t,n)=>{"use strict";n.d(t,{s:()=>r});var r="function"==typeof Symbol&&Symbol.observable||"@@observable"},235:(e,t,n)=>{"use strict";n.d(t,{R0:()=>s,lI:()=>i});var r=n(1693);function o(e){return e[e.length-1]}function i(e){return(t=o(e))&&(0,r.T)(t.schedule)?e.pop():void 0;var t}function s(e,t){return"number"==typeof o(e)?e.pop():t}},34:(e,t,n)=>{"use strict";function r(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}n.d(t,{o:()=>r})},5383:(e,t,n)=>{"use strict";function r(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}n.d(t,{L:()=>r})},3004:(e,t,n)=>{"use strict";n.d(t,{Y:()=>i,l:()=>s});var r=n(2236),o=null;function i(e){if(r.$.useDeprecatedSynchronousErrorHandling){var t=!o;if(t&&(o={errorThrown:!1,error:null}),e(),t){var n=o,i=n.errorThrown,s=n.error;if(o=null,i)throw s}}else e()}function s(e){r.$.useDeprecatedSynchronousErrorHandling&&o&&(o.errorThrown=!0,o.error=e)}},8071:(e,t,n)=>{"use strict";function r(e,t,n,r,o){void 0===r&&(r=0),void 0===o&&(o=!1);var i=t.schedule((function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()}),r);if(e.add(i),!o)return i}n.d(t,{N:()=>r})},3887:(e,t,n)=>{"use strict";function r(e){return e}n.d(t,{D:()=>r})},9739:(e,t,n)=>{"use strict";n.d(t,{X:()=>r});var r=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e}},3819:(e,t,n)=>{"use strict";n.d(t,{T:()=>o});var r=n(1693);function o(e){return Symbol.asyncIterator&&(0,r.T)(null==e?void 0:e[Symbol.asyncIterator])}},1693:(e,t,n)=>{"use strict";function r(e){return"function"==typeof e}n.d(t,{T:()=>r})},9065:(e,t,n)=>{"use strict";n.d(t,{l:()=>i});var r=n(8896),o=n(1693);function i(e){return(0,o.T)(e[r.s])}},4799:(e,t,n)=>{"use strict";n.d(t,{x:()=>i});var r=n(9445),o=n(1693);function i(e){return(0,o.T)(null==e?void 0:e[r.l])}},5796:(e,t,n)=>{"use strict";n.d(t,{y:()=>o});var r=n(1693);function o(e){return(0,r.T)(null==e?void 0:e.then)}},3026:(e,t,n)=>{"use strict";n.d(t,{C:()=>i,U:()=>s});var r=n(4629),o=n(1693);function i(e){return(0,r.AQ)(this,arguments,(function(){var t,n,o;return(0,r.YH)(this,(function(i){switch(i.label){case 0:t=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,(0,r.N3)(t.read())];case 3:return n=i.sent(),o=n.value,n.done?[4,(0,r.N3)(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,(0,r.N3)(o)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}function s(e){return(0,o.T)(null==e?void 0:e.getReader)}},5096:(e,t,n)=>{"use strict";n.d(t,{N:()=>o});var r=n(1693);function o(e){return function(t){if(function(e){return(0,r.T)(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(n){this.error(n)}}));throw new TypeError("Unable to lift unknown Observable type")}}},6712:(e,t,n)=>{"use strict";n.d(t,{m:()=>i});var r=n(2236),o=n(2332);function i(e){o.f.setTimeout((function(){var t=r.$.onUnhandledError;if(!t)throw e;t(e)}))}},4429:(e,t,n)=>{"use strict";function r(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}n.d(t,{L:()=>r})},3836:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:String(t)}function i(e,t){for(var n=0;ns})},1449:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(1576);function o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,(0,r.A)(e,t)}},1576:(e,t,n)=>{"use strict";function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}n.d(t,{A:()=>r})},6343:(e,t,n)=>{"use strict";function r(e){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},r(e)}n.d(t,{A:()=>s});var o=n(1576);function i(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(i=function(){return!!e})()}function s(e){var t="function"==typeof Map?new Map:void 0;return s=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(i())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var s=new(e.bind.apply(e,r));return n&&(0,o.A)(s,n.prototype),s}(e,arguments,r(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),(0,o.A)(n,e)},s(e)}},703:(e,t,n)=>{"use strict";n.d(t,{X2:()=>M});Promise.resolve(!1),Promise.resolve(!0);var r=Promise.resolve();function o(e,t){return e||(e=0),new Promise((function(n){return setTimeout((function(){return n(t)}),e)}))}function i(){return Math.random().toString(36).substring(2)}var s=0;function u(){var e=1e3*Date.now();return e<=s&&(e=s+1),s=e,e}var a={create:function(e){var t={time:u(),messagesCallback:null,bc:new BroadcastChannel(e),subFns:[]};return t.bc.onmessage=function(e){t.messagesCallback&&t.messagesCallback(e.data)},t},close:function(e){e.bc.close(),e.subFns=[]},onMessage:function(e,t){e.messagesCallback=t},postMessage:function(e,t){try{return e.bc.postMessage(t,!1),r}catch(n){return Promise.reject(n)}},canBeUsed:function(){if("undefined"!=typeof globalThis&&globalThis.Deno&&globalThis.Deno.args)return!0;if("undefined"==typeof window&&"undefined"==typeof self||"function"!=typeof BroadcastChannel)return!1;if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0},type:"native",averageResponseTime:function(){return 150},microSeconds:u},c=n(5525);function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=JSON.parse(JSON.stringify(e));return void 0===t.webWorkerSupport&&(t.webWorkerSupport=!0),t.idb||(t.idb={}),t.idb.ttl||(t.idb.ttl=45e3),t.idb.fallbackInterval||(t.idb.fallbackInterval=150),e.idb&&"function"==typeof e.idb.onclose&&(t.idb.onclose=e.idb.onclose),t.localstorage||(t.localstorage={}),t.localstorage.removeTimeout||(t.localstorage.removeTimeout=6e4),e.methods&&(t.methods=e.methods),t.node||(t.node={}),t.node.ttl||(t.node.ttl=12e4),t.node.maxParallelWrites||(t.node.maxParallelWrites=2048),void 0===t.node.useFastPath&&(t.node.useFastPath=!0),t}var f="pubkey.broadcast-channel-0-",h="messages",d={durability:"relaxed"};function p(){if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof window){if(void 0!==window.mozIndexedDB)return window.mozIndexedDB;if(void 0!==window.webkitIndexedDB)return window.webkitIndexedDB;if(void 0!==window.msIndexedDB)return window.msIndexedDB}return!1}function y(e){e.commit&&e.commit()}function v(e,t){var n=e.transaction(h,"readonly",d),r=n.objectStore(h),o=[],i=IDBKeyRange.bound(t+1,1/0);if(r.getAll){var s=r.getAll(i);return new Promise((function(e,t){s.onerror=function(e){return t(e)},s.onsuccess=function(t){e(t.target.result)}}))}return new Promise((function(e,s){var u=function(){try{return i=IDBKeyRange.bound(t+1,1/0),r.openCursor(i)}catch(e){return r.openCursor()}}();u.onerror=function(e){return s(e)},u.onsuccess=function(r){var i=r.target.result;i?i.value.ide.lastCursorId&&(e.lastCursorId=t.id),t})).filter((function(t){return function(e,t){return!(e.uuid===t.uuid||t.eMIs.has(e.id)||e.data.time0||e._addEL.internal.length>0}function K(e,t,n){e._addEL[t].push(n),function(e){if(!e._iL&&R(e)){var t=function(t){e._addEL[t.type].forEach((function(e){t.time>=e.time&&e.fn(t.data)}))},n=e.method.microSeconds();e._prepP?e._prepP.then((function(){e._iL=!0,e.method.onMessage(e._state,t,n)})):(e._iL=!0,e.method.onMessage(e._state,t,n))}}(e)}function N(e,t,n){e._addEL[t]=e._addEL[t].filter((function(e){return e!==n})),function(e){if(e._iL&&!R(e)){e._iL=!1;var t=e.method.microSeconds();e.method.onMessage(e._state,null,t)}}(e)}M._pubkey=!0,M.prototype={postMessage:function(e){if(this.closed)throw new Error("BroadcastChannel.postMessage(): Cannot post message after channel has closed "+JSON.stringify(e));return D(this,"message",e)},postInternal:function(e){return D(this,"internal",e)},set onmessage(e){var t={time:this.method.microSeconds(),fn:e};N(this,"message",this._onML),e&&"function"==typeof e?(this._onML=t,K(this,"message",t)):this._onML=null},addEventListener:function(e,t){K(this,e,{time:this.method.microSeconds(),fn:t})},removeEventListener:function(e,t){N(this,e,this._addEL[e].find((function(e){return e.fn===t})))},close:function(){var e=this;if(!this.closed){I.delete(this),this.closed=!0;var t=this._prepP?this._prepP:r;return this._onML=null,this._addEL.message=[],t.then((function(){return Promise.all(Array.from(e._uMP))})).then((function(){return Promise.all(e._befC.map((function(e){return e()})))})).then((function(){return e.method.close(e._state)}))}},get type(){return this.method.type},get isClosed(){return this.closed}}},7329:(e,t,n)=>{"use strict";n.d(t,{cf:()=>i});var r=n(8900);const o=Symbol.for("Dexie"),i=globalThis[o]||(globalThis[o]=r);if(r.semVer!==i.semVer)throw new Error(`Two different versions of Dexie loaded in the same app: ${r.semVer} and ${i.semVer}`);const{liveQuery:s,mergeRanges:u,rangesOverlap:a,RangeSet:c,cmp:l,Entity:f}=i},6114:(e,t,n)=>{"use strict";n.d(t,{kC:()=>q,Cs:()=>F});const r=e=>{e.previousResults.unshift(e.changeEvent.doc),e.keyDocumentMap&&e.keyDocumentMap.set(e.changeEvent.id,e.changeEvent.doc)},o=e=>{e.previousResults.push(e.changeEvent.doc),e.keyDocumentMap&&e.keyDocumentMap.set(e.changeEvent.id,e.changeEvent.doc)},i=e=>{const t=e.previousResults.shift();e.keyDocumentMap&&t&&e.keyDocumentMap.delete(t[e.queryParams.primaryKey])},s=e=>{const t=e.previousResults.pop();e.keyDocumentMap&&t&&e.keyDocumentMap.delete(t[e.queryParams.primaryKey])},u=e=>{e.keyDocumentMap&&e.keyDocumentMap.delete(e.changeEvent.id);const t=e.queryParams.primaryKey,n=e.previousResults;for(let r=0;r{const t=e.changeEvent.id,n=e.changeEvent.doc;if(e.keyDocumentMap){if(e.keyDocumentMap.has(t))return;e.keyDocumentMap.set(t,n)}else{if(e.previousResults.find((n=>n[e.queryParams.primaryKey]===t)))return}!function(e,t,n,r){var o,i=e.length,s=i-1,u=0;if(0===i)return e.push(t),0;for(;r<=s;)n(o=e[u=r+(s-r>>1)],t)<=0?r=u+1:s=u-1;n(o,t)<=0&&u++,e.splice(u,0,t)}(e.previousResults,n,e.queryParams.sortComparator,0)},c=["doNothing","insertFirst","insertLast","removeFirstItem","removeLastItem","removeFirstInsertLast","removeLastInsertFirst","removeFirstInsertFirst","removeLastInsertLast","removeExisting","replaceExisting","alwaysWrong","insertAtSortPosition","removeExistingAndInsertAtSortPosition","runFullQueryAgain","unknownAction"],l={doNothing:e=>{},insertFirst:r,insertLast:o,removeFirstItem:i,removeLastItem:s,removeFirstInsertLast:e=>{i(e),o(e)},removeLastInsertFirst:e=>{s(e),r(e)},removeFirstInsertFirst:e=>{i(e),r(e)},removeLastInsertLast:e=>{s(e),o(e)},removeExisting:u,replaceExisting:e=>{const t=e.changeEvent.doc,n=e.queryParams.primaryKey,r=e.previousResults;for(let o=0;o{const t={_id:"wrongHuman"+(new Date).getTime()};e.previousResults.length=0,e.previousResults.push(t),e.keyDocumentMap&&(e.keyDocumentMap.clear(),e.keyDocumentMap.set(t._id,t))},insertAtSortPosition:a,removeExistingAndInsertAtSortPosition:e=>{u(e),a(e)},runFullQueryAgain:e=>{throw new Error("Action runFullQueryAgain must be implemented by yourself")},unknownAction:e=>{throw new Error("Action unknownAction should never be called")}};!function(e=6){let t="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let r=0;r!!e.queryParams.limit,b=e=>1===e.queryParams.limit,g=e=>!!(e.queryParams.skip&&e.queryParams.skip>0),w=e=>"DELETE"===e.changeEvent.operation,_=e=>"INSERT"===e.changeEvent.operation,x=e=>"UPDATE"===e.changeEvent.operation,O=e=>m(e)&&e.previousResults.length>=e.queryParams.limit,k=e=>{const t=e.queryParams.sortFields,n=e.changeEvent.previous,r=e.changeEvent.doc;if(!r)return!1;if(!n)return!0;for(let o=0;o{const t=e.changeEvent.id;if(e.keyDocumentMap){return e.keyDocumentMap.has(t)}{const n=e.queryParams.primaryKey,r=e.previousResults;for(let e=0;e{const t=e.previousResults[0];return!(!t||t[e.queryParams.primaryKey]!==e.changeEvent.id)},S=e=>{const t=p(e.previousResults);return!(!t||t[e.queryParams.primaryKey]!==e.changeEvent.id)},A=e=>{const t=e.changeEvent.previous;if(!t)return!1;const n=e.previousResults[0];if(!n)return!1;if(n[e.queryParams.primaryKey]===e.changeEvent.id)return!0;return e.queryParams.sortComparator(t,n)<0},j=e=>{const t=e.changeEvent.previous;if(!t)return!1;const n=p(e.previousResults);if(!n)return!1;if(n[e.queryParams.primaryKey]===e.changeEvent.id)return!0;return e.queryParams.sortComparator(t,n)>0},C=e=>{const t=e.changeEvent.doc;if(!t)return!1;const n=e.previousResults[0];if(!n)return!1;if(n[e.queryParams.primaryKey]===e.changeEvent.id)return!0;return e.queryParams.sortComparator(t,n)<0},I=e=>{const t=e.changeEvent.doc;if(!t)return!1;const n=p(e.previousResults);if(!n)return!1;if(n[e.queryParams.primaryKey]===e.changeEvent.id)return!0;return e.queryParams.sortComparator(t,n)>0},T=e=>{const t=e.changeEvent.previous;return!!t&&e.queryParams.queryMatcher(t)},M=e=>{const t=e.changeEvent.doc;if(!t)return!1;return e.queryParams.queryMatcher(t)},D=e=>0===e.previousResults.length,R={0:_,1:x,2:w,3:m,4:b,5:g,6:D,7:O,8:P,9:S,10:k,11:E,12:A,13:j,14:C,15:I,16:T,17:M};let K;function N(){return K||(K=function(e){const t=new Map,n=2+2*parseInt(e.charAt(0)+e.charAt(1),10),r=f(e.substring(2,n),2);for(let a=0;afunction(e,t,n){let r=e,o=e.l;for(;;){if(r=r[t[o](n)?"1":"0"],"number"==typeof r||"string"==typeof r)return r;o=r.l}}(N(),R,e);function q(e){const t=B(e);return c[t]}function F(e,t,n,r,o){return(0,l[e])({queryParams:t,changeEvent:n,previousResults:r,keyDocumentMap:o}),r}},5525:(e,t,n)=>{"use strict";n.d(t,{p4:()=>r});class r{ttl;map=new Map;_to=!1;constructor(e){this.ttl=e}has(e){return this.map.has(e)}add(e){this.map.set(e,o()),this._to||(this._to=!0,setTimeout((()=>{this._to=!1,function(e){const t=o()-e.ttl,n=e.map[Symbol.iterator]();for(;;){const r=n.next().value;if(!r)return;const o=r[0];if(!(r[1]{"use strict";n.d(t,{sc:()=>p});Object.freeze({ignoreUnknown:!1,respectType:!1,respectFunctionNames:!1,respectFunctionProperties:!1,unorderedObjects:!0,unorderedArrays:!1,unorderedSets:!1,excludeKeys:void 0,excludeValues:void 0,replacer:void 0});Object.freeze(["prototype","__proto__","constructor"]);const r="[native code] }";r.length;class o{constructor(e,t){e=this.words=e||[],this.sigBytes=void 0===t?4*e.length:t}toString(e){return(e||i).stringify(this)}concat(e){if(this.clamp(),this.sigBytes%4)for(let t=0;t>>2]>>>24-t%4*8&255;this.words[this.sigBytes+t>>>2]|=n<<24-(this.sigBytes+t)%4*8}else for(let t=0;t>>2]=e.words[t>>>2];return this.sigBytes+=e.sigBytes,this}clamp(){this.words[this.sigBytes>>>2]&=4294967295<<32-this.sigBytes%4*8,this.words.length=Math.ceil(this.sigBytes/4)}clone(){return new o([...this.words])}}const i={stringify(e){const t=[];for(let n=0;n>>2]>>>24-n%4*8&255;t.push((r>>>4).toString(16),(15&r).toString(16))}return t.join("")}},s={parse(e){const t=e.length,n=[];for(let r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o(n,t)}},u={parse:e=>s.parse(unescape(encodeURIComponent(e)))};class a{constructor(){this._data=new o,this._nDataBytes=0,this._minBufferSize=0,this.blockSize=16}reset(){this._data=new o,this._nDataBytes=0}_append(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes}_doProcessBlock(e,t){}_process(e){let t,n=this._data.sigBytes/(4*this.blockSize);n=e?Math.ceil(n):Math.max((0|n)-this._minBufferSize,0);const r=n*this.blockSize,i=Math.min(4*r,this._data.sigBytes);if(r){for(let e=0;e>>7)^(e<<14|e>>>18)^e>>>3,n=h[d-2],r=(n<<15|n>>>17)^(n<<13|n>>>19)^n>>>10;h[d]=t+h[d-7]+r+h[d-16]}const n=r&o^r&i^o&i,p=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),y=l+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&a^~u&c)+f[d]+h[d];l=c,c=a,a=u,u=s+y|0,s=i,i=o,o=r,r=y+(p+n)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+a|0,n[6]=n[6]+c|0,n[7]=n[7]+l|0}finalize(e){super.finalize(e);const t=8*this._nDataBytes,n=8*this._data.sigBytes;return this._data.words[n>>>5]|=128<<24-n%32,this._data.words[14+(n+64>>>9<<4)]=Math.floor(t/4294967296),this._data.words[15+(n+64>>>9<<4)]=t,this._data.sigBytes=4*this._data.words.length,this._process(),this._hash}}function p(e){return(new d).finalize(e).toString()}},4629:(e,t,n)=>{"use strict";n.d(t,{AQ:()=>f,C6:()=>o,Ju:()=>u,N3:()=>l,YH:()=>s,fX:()=>c,sH:()=>i,xN:()=>h,zs:()=>a});var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function i(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(t){i(t)}}function u(e){try{a(r.throw(e))}catch(t){i(t)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))}function s(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,r=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(u){o={error:u}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function c(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o1||u(e,t)}))})}function u(e,t){try{(n=o[e](t)).value instanceof l?Promise.resolve(n.value.v).then(a,c):f(i[0][2],n)}catch(r){f(i[0][3],r)}var n}function a(e){u("next",e)}function c(e){u("throw",e)}function f(e,t){e(t),i.shift(),i.length&&u(i[0][0],i[0][1])}}function h(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=u(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}}Object.create;"function"==typeof SuppressedError&&SuppressedError}}]); \ No newline at end of file diff --git a/docs/assets/js/6cbff7c2.2c0fdd4e.js b/docs/assets/js/6cbff7c2.2c0fdd4e.js deleted file mode 100644 index f0456840ba2..00000000000 --- a/docs/assets/js/6cbff7c2.2c0fdd4e.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[7408],{5943:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>l,contentTitle:()=>o,default:()=>h,frontMatter:()=>n,metadata:()=>a,toc:()=>c});var r=s(4848),i=s(8453);const n={title:"OPFS RxStorage \ud83d\udc51",slug:"rx-storage-opfs.html",description:"Origin Private File System (OPFS) Database with the RxDB OPFS-RxStorage"},o="Origin Private File System (OPFS) Database with the RxDB OPFS-RxStorage",a={id:"rx-storage-opfs",title:"OPFS RxStorage \ud83d\udc51",description:"Origin Private File System (OPFS) Database with the RxDB OPFS-RxStorage",source:"@site/docs/rx-storage-opfs.md",sourceDirName:".",slug:"/rx-storage-opfs.html",permalink:"/rx-storage-opfs.html",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"OPFS RxStorage \ud83d\udc51",slug:"rx-storage-opfs.html",description:"Origin Private File System (OPFS) Database with the RxDB OPFS-RxStorage"},sidebar:"tutorialSidebar",previous:{title:"Dexie.js RxStorage",permalink:"/rx-storage-dexie.html"},next:{title:"Node.js Filesystem RxStorage \ud83d\udc51",permalink:"/rx-storage-filesystem-node.html"}},l={},c=[{value:"What is OPFS",id:"what-is-opfs",level:2},{value:"OPFS limitations",id:"opfs-limitations",level:3},{value:"How the OPFS API works",id:"how-the-opfs-api-works",level:2},{value:"OPFS performance",id:"opfs-performance",level:2},{value:"Using OPFS as RxStorage in RxDB",id:"using-opfs-as-rxstorage-in-rxdb",level:2},{value:"Building a custom worker.js",id:"building-a-custom-workerjs",level:2},{value:"Setting jsonPositionSize to increase the maximum database size.",id:"setting-jsonpositionsize-to-increase-the-maximum-database-size",level:2},{value:"OPFS in Electron, React-Native or Capacitor.js",id:"opfs-in-electron-react-native-or-capacitorjs",level:2},{value:"Difference between File System Access API and Origin Private File System (OPFS)",id:"difference-between-file-system-access-api-and-origin-private-file-system-opfs",level:2},{value:"Learn more about OPFS:",id:"learn-more-about-opfs",level:2}];function d(e){const t={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.h1,{id:"origin-private-file-system-opfs-database-with-the-rxdb-opfs-rxstorage",children:"Origin Private File System (OPFS) Database with the RxDB OPFS-RxStorage"}),"\n",(0,r.jsxs)(t.p,{children:["With the ",(0,r.jsx)(t.a,{href:"https://rxdb.info/",children:"RxDB"})," OPFS storage you can build a fully featured database on top of the ",(0,r.jsx)(t.a,{href:"https://web.dev/opfs",children:"Origin Private File System"})," (OPFS) browser API. Compared to other storage solutions, it has a way better performance."]}),"\n",(0,r.jsx)(t.h2,{id:"what-is-opfs",children:"What is OPFS"}),"\n",(0,r.jsxs)(t.p,{children:["The ",(0,r.jsx)(t.strong,{children:"Origin Private File System (OPFS)"})," is a native browser storage API that allows web applications to manage files in a private, sandboxed, ",(0,r.jsx)(t.strong,{children:"origin-specific virtual filesystem"}),". Unlike ",(0,r.jsx)(t.a,{href:"/rx-storage-indexeddb.html",children:"IndexedDB"})," and ",(0,r.jsx)(t.a,{href:"/articles/localstorage.html",children:"LocalStorage"}),", which are optimized as object/key-value storage, OPFS provides more granular control for file operations, enabling byte-by-byte access, file streaming, and even low-level manipulations.\nOPFS is ideal for applications requiring ",(0,r.jsx)(t.strong,{children:"high-performance"})," file operations (",(0,r.jsx)(t.strong,{children:"3x-4x faster compared to IndexedDB"}),") inside of a client-side application, offering advantages like improved speed, more efficient use of resources, and enhanced security and privacy features."]}),"\n",(0,r.jsx)(t.h3,{id:"opfs-limitations",children:"OPFS limitations"}),"\n",(0,r.jsxs)(t.p,{children:["From the beginning of 2023, the Origin Private File System API is supported by ",(0,r.jsx)(t.a,{href:"https://caniuse.com/native-filesystem-api",children:"all modern browsers"})," like Safari, Chrome, Edge and Firefox. Only Internet Explorer is not supported and likely will never get support."]}),"\n",(0,r.jsxs)(t.p,{children:["It is important to know that the most performant synchronous methods like ",(0,r.jsx)(t.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/read",children:(0,r.jsx)(t.code,{children:"read()"})})," and ",(0,r.jsx)(t.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/write",children:(0,r.jsx)(t.code,{children:"write()"})})," of the OPFS API are ",(0,r.jsxs)(t.strong,{children:["only available inside of a ",(0,r.jsx)(t.a,{href:"/rx-storage-worker.html",children:"WebWorker"})]}),".\nThey cannot be used in the main thread, an iFrame or even a ",(0,r.jsx)(t.a,{href:"/rx-storage-shared-worker.html",children:"SharedWorker"}),".\nThe OPFS ",(0,r.jsx)(t.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createSyncAccessHandle",children:(0,r.jsx)(t.code,{children:"createSyncAccessHandle()"})})," method that gives you access to the synchronous methods is not exposed in the main thread, only in a Worker."]}),"\n",(0,r.jsxs)(t.p,{children:["While there is no concrete ",(0,r.jsx)(t.strong,{children:"data size limit"})," defined by the API, browsers will refuse to store more data at some point.\nIf no more data can be written, a ",(0,r.jsx)(t.code,{children:"QuotaExceededError"})," is thrown which should be handled by the application, like showing an error message to the user."]}),"\n",(0,r.jsx)(t.h2,{id:"how-the-opfs-api-works",children:"How the OPFS API works"}),"\n",(0,r.jsxs)(t.p,{children:["The OPFS API is pretty straightforward to use. First you get the root filesystem. Then you can create files and directories on that. Notice that whenever you ",(0,r.jsx)(t.em,{children:"synchronously"})," write to, or read from a file, an ",(0,r.jsx)(t.code,{children:"ArrayBuffer"})," must be used that contains the data. It is not possible to synchronously write plain strings or objects into the file. Therefore the ",(0,r.jsx)(t.code,{children:"TextEncoder"})," and ",(0,r.jsx)(t.code,{children:"TextDecoder"})," API must be used."]}),"\n",(0,r.jsxs)(t.p,{children:["Also notice that some of the methods of ",(0,r.jsx)(t.code,{children:"FileSystemSyncAccessHandle"})," ",(0,r.jsx)(t.a,{href:"https://developer.chrome.com/blog/sync-methods-for-accesshandles",children:"have been asynchronous"})," in the past, but are synchronous since Chromium 108. To make it less confusing, we just use ",(0,r.jsx)(t.code,{children:"await"})," in front of them, so it will work in both cases."]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",children:"// Access the root directory of the origin's private file system.\nconst root = await navigator.storage.getDirectory();\n\n// Create a subdirectory.\nconst diaryDirectory = await root.getDirectoryHandle('subfolder', {\n create: true,\n}); \n\n// Create a new file named 'example.txt'.\nconst fileHandle = await diaryDirectory.getFileHandle('example.txt', {\n create: true,\n});\n\n// Create a FileSystemSyncAccessHandle on the file.\nconst accessHandle = await fileHandle.createSyncAccessHandle();\n\n// Write a sentence to the file.\nlet writeBuffer = new TextEncoder().encode('Hello from RxDB');\nconst writeSize = accessHandle.write(writeBuffer);\n\n// Read file and transform data to string.\nconst readBuffer = new Uint8Array(writeSize);\nconst readSize = accessHandle.read(readBuffer, { at: 0 }); \nconst contentAsString = new TextDecoder().decode(readBuffer);\n\n// Write an exclamation mark to the end of the file.\nwriteBuffer = new TextEncoder().encode('!');\naccessHandle.write(writeBuffer, { at: readSize });\n\n// Truncate file to 10 bytes.\nawait accessHandle.truncate(10);\n\n// Get the new size of the file.\nconst fileSize = await accessHandle.getSize();\n\n// Persist changes to disk.\nawait accessHandle.flush();\n\n// Always close FileSystemSyncAccessHandle if done, so others can open the file again.\nawait accessHandle.close();\n"})}),"\n",(0,r.jsxs)(t.p,{children:["A more detailed description of the OPFS API can be found ",(0,r.jsx)(t.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system",children:"on MDN"}),"."]}),"\n",(0,r.jsx)(t.h2,{id:"opfs-performance",children:"OPFS performance"}),"\n",(0,r.jsxs)(t.p,{children:["Because the Origin Private File System API provides low-level access to binary files, it is much faster compared to ",(0,r.jsx)(t.a,{href:"/slow-indexeddb.html",children:"IndexedDB"})," or ",(0,r.jsx)(t.a,{href:"/articles/localstorage.html",children:"localStorage"}),". According to the ",(0,r.jsx)(t.a,{href:"https://pubkey.github.io/client-side-databases/database-comparison/index.html",children:"storage performance test"}),", OPFS is up to 2x times faster on plain inserts when a new file is created on each write. Reads are even faster."]}),"\n",(0,r.jsxs)(t.p,{children:["A good comparison about real world scenarios, are the ",(0,r.jsx)(t.a,{href:"/rx-storage-performance.html",children:"performance results"})," of the various RxDB storages. Here it shows that reads are up to 4x faster compared to IndexedDB, even with complex queries:"]}),"\n",(0,r.jsx)("p",{align:"center",children:(0,r.jsx)("img",{src:"./files/rx-storage-performance-browser.png",alt:"RxStorage performance - browser",width:"700"})}),"\n",(0,r.jsx)(t.h2,{id:"using-opfs-as-rxstorage-in-rxdb",children:"Using OPFS as RxStorage in RxDB"}),"\n",(0,r.jsxs)(t.p,{children:["The OPFS ",(0,r.jsx)(t.a,{href:"/rx-storage.html",children:"RxStorage"})," itself must run inside a WebWorker. Therefore we use the ",(0,r.jsx)(t.a,{href:"/rx-storage-worker.html",children:"Worker RxStorage"})," and let it point to the prebuild ",(0,r.jsx)(t.code,{children:"opfs.worker.js"})," file that comes shipped with RxDB Premium \ud83d\udc51."]}),"\n",(0,r.jsxs)(t.p,{children:["Notice that the OPFS RxStorage is part of the ",(0,r.jsx)(t.a,{href:"/premium",children:"RxDB Premium \ud83d\udc51"})," plugin that must be purchased."]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",children:"import {\n createRxDatabase\n} from 'rxdb';\nimport { getRxStorageWorker } from 'rxdb-premium/plugins/storage-worker';\n\nconst database = await createRxDatabase({\n name: 'mydatabase',\n storage: getRxStorageWorker(\n {\n /**\n * This file must be statically served from a webserver.\n * You might want to first copy it somewhere outside of\n * your node_modules folder.\n */\n workerInput: 'node_modules/rxdb-premium/dist/workers/opfs.worker.js'\n }\n )\n});\n"})}),"\n",(0,r.jsxs)(t.h2,{id:"building-a-custom-workerjs",children:["Building a custom ",(0,r.jsx)(t.code,{children:"worker.js"})]}),"\n",(0,r.jsxs)(t.p,{children:["When you want to run additional plugins like storage wrappers or replication ",(0,r.jsx)(t.strong,{children:"inside"})," of the worker, you have to build your own ",(0,r.jsx)(t.code,{children:"worker.js"})," file. You can do that similar to other workers by calling ",(0,r.jsx)(t.code,{children:"exposeWorkerRxStorage"})," like described in the ",(0,r.jsx)(t.a,{href:"/rx-storage-worker.html",children:"worker storage plugin"}),"."]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",children:"// inside of the worker.js file\nimport { getRxStorageOPFS } from 'rxdb-premium/plugins/storage-opfs';\nimport { exposeWorkerRxStorage } from 'rxdb-premium/plugins/storage-worker';\n\nconst storage = getRxStorageOPFS();\nexposeWorkerRxStorage({\n storage\n});\n"})}),"\n",(0,r.jsxs)(t.h2,{id:"setting-jsonpositionsize-to-increase-the-maximum-database-size",children:["Setting ",(0,r.jsx)(t.code,{children:"jsonPositionSize"})," to increase the maximum database size."]}),"\n",(0,r.jsxs)(t.p,{children:["By default the ",(0,r.jsx)(t.code,{children:"jsonPositionSize"})," value is set to ",(0,r.jsx)(t.code,{children:"8"})," which allows the database to get up to 100 megabytes in size (per collection).\nThis is ok for most use cases but you might want to just increase ",(0,r.jsx)(t.code,{children:"jsonPositionSize"})," to ",(0,r.jsx)(t.code,{children:"14"}),".\nIn the next major RxDB version the default will be set to ",(0,r.jsx)(t.code,{children:"14"}),", but this was not possible without introducing a breaking change."]}),"\n",(0,r.jsxs)(t.p,{children:["NOTICE: If you have already stored data, you cannot just change the ",(0,r.jsx)(t.code,{children:"jsonPositionSize"})," value because your stored binary data will not be compatible anymore."]}),"\n",(0,r.jsxs)(t.p,{children:["Also there is a ",(0,r.jsx)(t.code,{children:"opfs-big.worker.js"})," file that has ",(0,r.jsx)(t.code,{children:"jsonPositionSize"})," set to ",(0,r.jsx)(t.code,{children:"14"})," already."]}),"\n",(0,r.jsx)(t.h2,{id:"opfs-in-electron-react-native-or-capacitorjs",children:"OPFS in Electron, React-Native or Capacitor.js"}),"\n",(0,r.jsx)(t.p,{children:"Origin Private File System is a browser API that is only accessible in browsers. Other JavaScript like React-Native or Node.js, do not support it."}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.strong,{children:"Electron"})," has two JavaScript contexts: the browser (chromium) context and the Node.js context. While you could use the OPFS API in the browser context, it is not recommended. Instead you should use the Filesystem API of Node.js and then only transfer the relevant data with the ",(0,r.jsx)(t.a,{href:"https://www.electronjs.org/de/docs/latest/api/ipc-renderer",children:"ipcRenderer"}),". With RxDB that is pretty easy to configure:"]}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsxs)(t.li,{children:["In the ",(0,r.jsx)(t.code,{children:"main.js"}),", expose the ",(0,r.jsx)(t.a,{href:"/rx-storage-filesystem-node.html",children:"Node Filesystem"})," storage with the ",(0,r.jsx)(t.code,{children:"exposeIpcMainRxStorage()"})," that comes with the ",(0,r.jsx)(t.a,{href:"/electron.html",children:"electron plugin"})]}),"\n",(0,r.jsxs)(t.li,{children:["In the browser context, access the main storage with the ",(0,r.jsx)(t.code,{children:"getRxStorageIpcRenderer()"})," method."]}),"\n"]}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.strong,{children:"React Native"})," (and Expo) does not have an OPFS API. You could use the ReactNative Filesystem to directly write data. But to get a fully featured database like RxDB it is easier to use the ",(0,r.jsx)(t.a,{href:"/rx-storage-sqlite.html",children:"SQLite RxStorage"})," which starts an SQLite database inside of the ReactNative app and uses that to do the database operations."]}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.strong,{children:"Capacitor.js"})," is able to access the OPFS API."]}),"\n",(0,r.jsxs)(t.h2,{id:"difference-between-file-system-access-api-and-origin-private-file-system-opfs",children:["Difference between ",(0,r.jsx)(t.code,{children:"File System Access API"})," and ",(0,r.jsx)(t.code,{children:"Origin Private File System (OPFS)"})]}),"\n",(0,r.jsxs)(t.p,{children:["Often developers are confused with the differences between the ",(0,r.jsx)(t.code,{children:"File System Access API"})," and the ",(0,r.jsx)(t.code,{children:"Origin Private File System (OPFS)"}),"."]}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsxs)(t.li,{children:["The ",(0,r.jsx)(t.code,{children:"File System Access API"})," provides access to the files on the device file system, like the ones shown in the file explorer of the operating system. To use the File System API, the user has to actively select the files from a filepicker."]}),"\n",(0,r.jsxs)(t.li,{children:[(0,r.jsx)(t.code,{children:"Origin Private File System (OPFS)"})," is a sub-part of the ",(0,r.jsx)(t.code,{children:"File System Standard"})," and it only describes the things you can do with the filesystem root from ",(0,r.jsx)(t.code,{children:"navigator.storage.getDirectory()"}),". OPFS writes to a ",(0,r.jsx)(t.strong,{children:"sandboxed"})," filesystem, not visible to the user. Therefore the user does not have to actively select or allow the data access."]}),"\n"]}),"\n",(0,r.jsx)(t.h2,{id:"learn-more-about-opfs",children:"Learn more about OPFS:"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://webkit.org/blog/12257/the-file-system-access-api-with-origin-private-file-system/",children:"WebKit: The File System API with Origin Private File System"})}),"\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://caniuse.com/native-filesystem-api",children:"Browser Support"})}),"\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://pubkey.github.io/client-side-databases/database-comparison/index.html",children:"Performance Test Tool"})}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}},8453:(e,t,s)=>{s.d(t,{R:()=>o,x:()=>a});var r=s(6540);const i={},n=r.createContext(i);function o(e){const t=r.useContext(n);return r.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:o(e.components),r.createElement(n.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/docs/assets/js/6cbff7c2.648148ea.js b/docs/assets/js/6cbff7c2.648148ea.js new file mode 100644 index 00000000000..c5c9135aa9f --- /dev/null +++ b/docs/assets/js/6cbff7c2.648148ea.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[7408],{5943:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>l,contentTitle:()=>a,default:()=>h,frontMatter:()=>n,metadata:()=>o,toc:()=>c});var r=s(4848),i=s(8453);const n={title:"OPFS RxStorage \ud83d\udc51",slug:"rx-storage-opfs.html",description:"Origin Private File System (OPFS) Database with the RxDB OPFS-RxStorage"},a="Origin Private File System (OPFS) Database with the RxDB OPFS-RxStorage",o={id:"rx-storage-opfs",title:"OPFS RxStorage \ud83d\udc51",description:"Origin Private File System (OPFS) Database with the RxDB OPFS-RxStorage",source:"@site/docs/rx-storage-opfs.md",sourceDirName:".",slug:"/rx-storage-opfs.html",permalink:"/rx-storage-opfs.html",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"OPFS RxStorage \ud83d\udc51",slug:"rx-storage-opfs.html",description:"Origin Private File System (OPFS) Database with the RxDB OPFS-RxStorage"},sidebar:"tutorialSidebar",previous:{title:"Dexie.js RxStorage",permalink:"/rx-storage-dexie.html"},next:{title:"Node.js Filesystem RxStorage \ud83d\udc51",permalink:"/rx-storage-filesystem-node.html"}},l={},c=[{value:"What is OPFS",id:"what-is-opfs",level:2},{value:"OPFS limitations",id:"opfs-limitations",level:3},{value:"How the OPFS API works",id:"how-the-opfs-api-works",level:2},{value:"OPFS performance",id:"opfs-performance",level:2},{value:"Using OPFS as RxStorage in RxDB",id:"using-opfs-as-rxstorage-in-rxdb",level:2},{value:"Using OPFS in the main thread instead of a worker",id:"using-opfs-in-the-main-thread-instead-of-a-worker",level:2},{value:"Building a custom worker.js",id:"building-a-custom-workerjs",level:2},{value:"Setting usesRxDatabaseInWorker when a RxDatabase is also used inside of the worker",id:"setting-usesrxdatabaseinworker-when-a-rxdatabase-is-also-used-inside-of-the-worker",level:2},{value:"Setting jsonPositionSize to increase the maximum database size.",id:"setting-jsonpositionsize-to-increase-the-maximum-database-size",level:2},{value:"OPFS in Electron, React-Native or Capacitor.js",id:"opfs-in-electron-react-native-or-capacitorjs",level:2},{value:"Difference between File System Access API and Origin Private File System (OPFS)",id:"difference-between-file-system-access-api-and-origin-private-file-system-opfs",level:2},{value:"Learn more about OPFS:",id:"learn-more-about-opfs",level:2}];function d(e){const t={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.h1,{id:"origin-private-file-system-opfs-database-with-the-rxdb-opfs-rxstorage",children:"Origin Private File System (OPFS) Database with the RxDB OPFS-RxStorage"}),"\n",(0,r.jsxs)(t.p,{children:["With the ",(0,r.jsx)(t.a,{href:"https://rxdb.info/",children:"RxDB"})," OPFS storage you can build a fully featured database on top of the ",(0,r.jsx)(t.a,{href:"https://web.dev/opfs",children:"Origin Private File System"})," (OPFS) browser API. Compared to other storage solutions, it has a way better performance."]}),"\n",(0,r.jsx)(t.h2,{id:"what-is-opfs",children:"What is OPFS"}),"\n",(0,r.jsxs)(t.p,{children:["The ",(0,r.jsx)(t.strong,{children:"Origin Private File System (OPFS)"})," is a native browser storage API that allows web applications to manage files in a private, sandboxed, ",(0,r.jsx)(t.strong,{children:"origin-specific virtual filesystem"}),". Unlike ",(0,r.jsx)(t.a,{href:"/rx-storage-indexeddb.html",children:"IndexedDB"})," and ",(0,r.jsx)(t.a,{href:"/articles/localstorage.html",children:"LocalStorage"}),", which are optimized as object/key-value storage, OPFS provides more granular control for file operations, enabling byte-by-byte access, file streaming, and even low-level manipulations.\nOPFS is ideal for applications requiring ",(0,r.jsx)(t.strong,{children:"high-performance"})," file operations (",(0,r.jsx)(t.strong,{children:"3x-4x faster compared to IndexedDB"}),") inside of a client-side application, offering advantages like improved speed, more efficient use of resources, and enhanced security and privacy features."]}),"\n",(0,r.jsx)(t.h3,{id:"opfs-limitations",children:"OPFS limitations"}),"\n",(0,r.jsxs)(t.p,{children:["From the beginning of 2023, the Origin Private File System API is supported by ",(0,r.jsx)(t.a,{href:"https://caniuse.com/native-filesystem-api",children:"all modern browsers"})," like Safari, Chrome, Edge and Firefox. Only Internet Explorer is not supported and likely will never get support."]}),"\n",(0,r.jsxs)(t.p,{children:["It is important to know that the most performant synchronous methods like ",(0,r.jsx)(t.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/read",children:(0,r.jsx)(t.code,{children:"read()"})})," and ",(0,r.jsx)(t.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/write",children:(0,r.jsx)(t.code,{children:"write()"})})," of the OPFS API are ",(0,r.jsxs)(t.strong,{children:["only available inside of a ",(0,r.jsx)(t.a,{href:"/rx-storage-worker.html",children:"WebWorker"})]}),".\nThey cannot be used in the main thread, an iFrame or even a ",(0,r.jsx)(t.a,{href:"/rx-storage-shared-worker.html",children:"SharedWorker"}),".\nThe OPFS ",(0,r.jsx)(t.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createSyncAccessHandle",children:(0,r.jsx)(t.code,{children:"createSyncAccessHandle()"})})," method that gives you access to the synchronous methods is not exposed in the main thread, only in a Worker."]}),"\n",(0,r.jsxs)(t.p,{children:["While there is no concrete ",(0,r.jsx)(t.strong,{children:"data size limit"})," defined by the API, browsers will refuse to store more data at some point.\nIf no more data can be written, a ",(0,r.jsx)(t.code,{children:"QuotaExceededError"})," is thrown which should be handled by the application, like showing an error message to the user."]}),"\n",(0,r.jsx)(t.h2,{id:"how-the-opfs-api-works",children:"How the OPFS API works"}),"\n",(0,r.jsxs)(t.p,{children:["The OPFS API is pretty straightforward to use. First you get the root filesystem. Then you can create files and directories on that. Notice that whenever you ",(0,r.jsx)(t.em,{children:"synchronously"})," write to, or read from a file, an ",(0,r.jsx)(t.code,{children:"ArrayBuffer"})," must be used that contains the data. It is not possible to synchronously write plain strings or objects into the file. Therefore the ",(0,r.jsx)(t.code,{children:"TextEncoder"})," and ",(0,r.jsx)(t.code,{children:"TextDecoder"})," API must be used."]}),"\n",(0,r.jsxs)(t.p,{children:["Also notice that some of the methods of ",(0,r.jsx)(t.code,{children:"FileSystemSyncAccessHandle"})," ",(0,r.jsx)(t.a,{href:"https://developer.chrome.com/blog/sync-methods-for-accesshandles",children:"have been asynchronous"})," in the past, but are synchronous since Chromium 108. To make it less confusing, we just use ",(0,r.jsx)(t.code,{children:"await"})," in front of them, so it will work in both cases."]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",children:"// Access the root directory of the origin's private file system.\nconst root = await navigator.storage.getDirectory();\n\n// Create a subdirectory.\nconst diaryDirectory = await root.getDirectoryHandle('subfolder', {\n create: true,\n}); \n\n// Create a new file named 'example.txt'.\nconst fileHandle = await diaryDirectory.getFileHandle('example.txt', {\n create: true,\n});\n\n// Create a FileSystemSyncAccessHandle on the file.\nconst accessHandle = await fileHandle.createSyncAccessHandle();\n\n// Write a sentence to the file.\nlet writeBuffer = new TextEncoder().encode('Hello from RxDB');\nconst writeSize = accessHandle.write(writeBuffer);\n\n// Read file and transform data to string.\nconst readBuffer = new Uint8Array(writeSize);\nconst readSize = accessHandle.read(readBuffer, { at: 0 }); \nconst contentAsString = new TextDecoder().decode(readBuffer);\n\n// Write an exclamation mark to the end of the file.\nwriteBuffer = new TextEncoder().encode('!');\naccessHandle.write(writeBuffer, { at: readSize });\n\n// Truncate file to 10 bytes.\nawait accessHandle.truncate(10);\n\n// Get the new size of the file.\nconst fileSize = await accessHandle.getSize();\n\n// Persist changes to disk.\nawait accessHandle.flush();\n\n// Always close FileSystemSyncAccessHandle if done, so others can open the file again.\nawait accessHandle.close();\n"})}),"\n",(0,r.jsxs)(t.p,{children:["A more detailed description of the OPFS API can be found ",(0,r.jsx)(t.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system",children:"on MDN"}),"."]}),"\n",(0,r.jsx)(t.h2,{id:"opfs-performance",children:"OPFS performance"}),"\n",(0,r.jsxs)(t.p,{children:["Because the Origin Private File System API provides low-level access to binary files, it is much faster compared to ",(0,r.jsx)(t.a,{href:"/slow-indexeddb.html",children:"IndexedDB"})," or ",(0,r.jsx)(t.a,{href:"/articles/localstorage.html",children:"localStorage"}),". According to the ",(0,r.jsx)(t.a,{href:"https://pubkey.github.io/client-side-databases/database-comparison/index.html",children:"storage performance test"}),", OPFS is up to 2x times faster on plain inserts when a new file is created on each write. Reads are even faster."]}),"\n",(0,r.jsxs)(t.p,{children:["A good comparison about real world scenarios, are the ",(0,r.jsx)(t.a,{href:"/rx-storage-performance.html",children:"performance results"})," of the various RxDB storages. Here it shows that reads are up to 4x faster compared to IndexedDB, even with complex queries:"]}),"\n",(0,r.jsx)("p",{align:"center",children:(0,r.jsx)("img",{src:"./files/rx-storage-performance-browser.png",alt:"RxStorage performance - browser",width:"700"})}),"\n",(0,r.jsx)(t.h2,{id:"using-opfs-as-rxstorage-in-rxdb",children:"Using OPFS as RxStorage in RxDB"}),"\n",(0,r.jsxs)(t.p,{children:["The OPFS ",(0,r.jsx)(t.a,{href:"/rx-storage.html",children:"RxStorage"})," itself must run inside a WebWorker. Therefore we use the ",(0,r.jsx)(t.a,{href:"/rx-storage-worker.html",children:"Worker RxStorage"})," and let it point to the prebuild ",(0,r.jsx)(t.code,{children:"opfs.worker.js"})," file that comes shipped with RxDB Premium \ud83d\udc51."]}),"\n",(0,r.jsxs)(t.p,{children:["Notice that the OPFS RxStorage is part of the ",(0,r.jsx)(t.a,{href:"/premium",children:"RxDB Premium \ud83d\udc51"})," plugin that must be purchased."]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",children:"import {\n createRxDatabase\n} from 'rxdb';\nimport { getRxStorageWorker } from 'rxdb-premium/plugins/storage-worker';\n\nconst database = await createRxDatabase({\n name: 'mydatabase',\n storage: getRxStorageWorker(\n {\n /**\n * This file must be statically served from a webserver.\n * You might want to first copy it somewhere outside of\n * your node_modules folder.\n */\n workerInput: 'node_modules/rxdb-premium/dist/workers/opfs.worker.js'\n }\n )\n});\n"})}),"\n",(0,r.jsx)(t.h2,{id:"using-opfs-in-the-main-thread-instead-of-a-worker",children:"Using OPFS in the main thread instead of a worker"}),"\n",(0,r.jsxs)(t.p,{children:["The ",(0,r.jsx)(t.code,{children:"createSyncAccessHandle"})," method from the Filesystem API is only available inside of a Webworker. Therefore you cannot use ",(0,r.jsx)(t.code,{children:"getRxStorageOPFS()"})," in the main thread. But there is a slightly slower way to access the virtual filesystem from the main thread. RxDB support the ",(0,r.jsx)(t.code,{children:"getRxStorageOPFSMainThread()"})," for that. Notice that this uses the ",(0,r.jsx)(t.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createWritable",children:"createWritable"})," function which is not supported in safari."]}),"\n",(0,r.jsx)(t.p,{children:"Using OPFS from the main thread can have benefits because not having to cross the worker bridge can reduce latence in reads and writes."}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",children:"import { createRxDatabase } from 'rxdb';\nimport { getRxStorageOPFSMainThread } from 'rxdb-premium/plugins/storage-worker';\n\nconst database = await createRxDatabase({\n name: 'mydatabase',\n storage: getRxStorageOPFSMainThread()\n});\n"})}),"\n",(0,r.jsxs)(t.h2,{id:"building-a-custom-workerjs",children:["Building a custom ",(0,r.jsx)(t.code,{children:"worker.js"})]}),"\n",(0,r.jsxs)(t.p,{children:["When you want to run additional plugins like storage wrappers or replication ",(0,r.jsx)(t.strong,{children:"inside"})," of the worker, you have to build your own ",(0,r.jsx)(t.code,{children:"worker.js"})," file. You can do that similar to other workers by calling ",(0,r.jsx)(t.code,{children:"exposeWorkerRxStorage"})," like described in the ",(0,r.jsx)(t.a,{href:"/rx-storage-worker.html",children:"worker storage plugin"}),"."]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",children:"// inside of the worker.js file\nimport { getRxStorageOPFS } from 'rxdb-premium/plugins/storage-opfs';\nimport { exposeWorkerRxStorage } from 'rxdb-premium/plugins/storage-worker';\n\nconst storage = getRxStorageOPFS();\nexposeWorkerRxStorage({\n storage\n});\n"})}),"\n",(0,r.jsxs)(t.h2,{id:"setting-usesrxdatabaseinworker-when-a-rxdatabase-is-also-used-inside-of-the-worker",children:["Setting ",(0,r.jsx)(t.code,{children:"usesRxDatabaseInWorker"})," when a RxDatabase is also used inside of the worker"]}),"\n",(0,r.jsxs)(t.p,{children:["When you use the OPFS inside of a worker, it will internally use strings to represent operation results. This has the benefit that transferring strings from the worker to the main thread, is way faster compared to complex json objects. The ",(0,r.jsx)(t.code,{children:"getRxStorageWorker()"})," will automatically decode these strings on the main thread so that the data can be used by the RxDatabase."]}),"\n",(0,r.jsxs)(t.p,{children:["But using a RxDatabase ",(0,r.jsx)(t.strong,{children:"inside"})," of your worker can make sense for example when you want to move the ",(0,r.jsx)(t.a,{href:"/replication.html",children:"replication"})," with a server. To enable this, you have to set ",(0,r.jsx)(t.code,{children:"usesRxDatabaseInWorker"})," to ",(0,r.jsx)(t.code,{children:"true"}),":"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",children:"// inside of the worker.js file\nimport { getRxStorageOPFS } from 'rxdb-premium/plugins/storage-opfs';\nconst storage = getRxStorageOPFS({\n usesRxDatabaseInWorker: true\n});\n"})}),"\n",(0,r.jsxs)(t.h2,{id:"setting-jsonpositionsize-to-increase-the-maximum-database-size",children:["Setting ",(0,r.jsx)(t.code,{children:"jsonPositionSize"})," to increase the maximum database size."]}),"\n",(0,r.jsxs)(t.p,{children:["By default the ",(0,r.jsx)(t.code,{children:"jsonPositionSize"})," value is set to ",(0,r.jsx)(t.code,{children:"8"})," which allows the database to get up to 100 megabytes in size (per collection).\nThis is ok for most use cases but you might want to just increase ",(0,r.jsx)(t.code,{children:"jsonPositionSize"})," to ",(0,r.jsx)(t.code,{children:"14"}),".\nIn the next major RxDB version the default will be set to ",(0,r.jsx)(t.code,{children:"14"}),", but this was not possible without introducing a breaking change."]}),"\n",(0,r.jsxs)(t.p,{children:["NOTICE: If you have already stored data, you cannot just change the ",(0,r.jsx)(t.code,{children:"jsonPositionSize"})," value because your stored binary data will not be compatible anymore."]}),"\n",(0,r.jsxs)(t.p,{children:["Also there is a ",(0,r.jsx)(t.code,{children:"opfs-big.worker.js"})," file that has ",(0,r.jsx)(t.code,{children:"jsonPositionSize"})," set to ",(0,r.jsx)(t.code,{children:"14"})," already."]}),"\n",(0,r.jsx)(t.h2,{id:"opfs-in-electron-react-native-or-capacitorjs",children:"OPFS in Electron, React-Native or Capacitor.js"}),"\n",(0,r.jsx)(t.p,{children:"Origin Private File System is a browser API that is only accessible in browsers. Other JavaScript like React-Native or Node.js, do not support it."}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.strong,{children:"Electron"})," has two JavaScript contexts: the browser (chromium) context and the Node.js context. While you could use the OPFS API in the browser context, it is not recommended. Instead you should use the Filesystem API of Node.js and then only transfer the relevant data with the ",(0,r.jsx)(t.a,{href:"https://www.electronjs.org/de/docs/latest/api/ipc-renderer",children:"ipcRenderer"}),". With RxDB that is pretty easy to configure:"]}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsxs)(t.li,{children:["In the ",(0,r.jsx)(t.code,{children:"main.js"}),", expose the ",(0,r.jsx)(t.a,{href:"/rx-storage-filesystem-node.html",children:"Node Filesystem"})," storage with the ",(0,r.jsx)(t.code,{children:"exposeIpcMainRxStorage()"})," that comes with the ",(0,r.jsx)(t.a,{href:"/electron.html",children:"electron plugin"})]}),"\n",(0,r.jsxs)(t.li,{children:["In the browser context, access the main storage with the ",(0,r.jsx)(t.code,{children:"getRxStorageIpcRenderer()"})," method."]}),"\n"]}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.strong,{children:"React Native"})," (and Expo) does not have an OPFS API. You could use the ReactNative Filesystem to directly write data. But to get a fully featured database like RxDB it is easier to use the ",(0,r.jsx)(t.a,{href:"/rx-storage-sqlite.html",children:"SQLite RxStorage"})," which starts an SQLite database inside of the ReactNative app and uses that to do the database operations."]}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.strong,{children:"Capacitor.js"})," is able to access the OPFS API."]}),"\n",(0,r.jsxs)(t.h2,{id:"difference-between-file-system-access-api-and-origin-private-file-system-opfs",children:["Difference between ",(0,r.jsx)(t.code,{children:"File System Access API"})," and ",(0,r.jsx)(t.code,{children:"Origin Private File System (OPFS)"})]}),"\n",(0,r.jsxs)(t.p,{children:["Often developers are confused with the differences between the ",(0,r.jsx)(t.code,{children:"File System Access API"})," and the ",(0,r.jsx)(t.code,{children:"Origin Private File System (OPFS)"}),"."]}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsxs)(t.li,{children:["The ",(0,r.jsx)(t.code,{children:"File System Access API"})," provides access to the files on the device file system, like the ones shown in the file explorer of the operating system. To use the File System API, the user has to actively select the files from a filepicker."]}),"\n",(0,r.jsxs)(t.li,{children:[(0,r.jsx)(t.code,{children:"Origin Private File System (OPFS)"})," is a sub-part of the ",(0,r.jsx)(t.code,{children:"File System Standard"})," and it only describes the things you can do with the filesystem root from ",(0,r.jsx)(t.code,{children:"navigator.storage.getDirectory()"}),". OPFS writes to a ",(0,r.jsx)(t.strong,{children:"sandboxed"})," filesystem, not visible to the user. Therefore the user does not have to actively select or allow the data access."]}),"\n"]}),"\n",(0,r.jsx)(t.h2,{id:"learn-more-about-opfs",children:"Learn more about OPFS:"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://webkit.org/blog/12257/the-file-system-access-api-with-origin-private-file-system/",children:"WebKit: The File System API with Origin Private File System"})}),"\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://caniuse.com/native-filesystem-api",children:"Browser Support"})}),"\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://pubkey.github.io/client-side-databases/database-comparison/index.html",children:"Performance Test Tool"})}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}},8453:(e,t,s)=>{s.d(t,{R:()=>a,x:()=>o});var r=s(6540);const i={},n=r.createContext(i);function a(e){const t=r.useContext(n);return r.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),r.createElement(n.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/docs/assets/js/cbbe8f0a.9592af82.js b/docs/assets/js/cbbe8f0a.9592af82.js deleted file mode 100644 index cba68ce9c9a..00000000000 --- a/docs/assets/js/cbbe8f0a.9592af82.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[3852],{8783:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>r,contentTitle:()=>l,default:()=>h,frontMatter:()=>i,metadata:()=>c,toc:()=>a});var o=t(4848),s=t(8453);const i={title:"RxCollection",slug:"rx-collection.html"},l="RxCollection",c={id:"rx-collection",title:"RxCollection",description:"A collection stores documents of the same type.",source:"@site/docs/rx-collection.md",sourceDirName:".",slug:"/rx-collection.html",permalink:"/rx-collection.html",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"RxCollection",slug:"rx-collection.html"},sidebar:"tutorialSidebar",previous:{title:"RxSchema",permalink:"/rx-schema.html"},next:{title:"RxDocument",permalink:"/rx-document.html"}},r={},a=[{value:"Creating a Collection",id:"creating-a-collection",level:2},{value:"name",id:"name",level:3},{value:"schema",id:"schema",level:3},{value:"ORM-functions",id:"orm-functions",level:3},{value:"Migration",id:"migration",level:3},{value:"Get a collection from the database",id:"get-a-collection-from-the-database",level:2},{value:"Functions",id:"functions",level:2},{value:"Observe $",id:"observe-",level:3},{value:"insert()",id:"insert",level:3},{value:"bulkInsert()",id:"bulkinsert",level:3},{value:"bulkRemove()",id:"bulkremove",level:3},{value:"upsert()",id:"upsert",level:3},{value:"bulkUpsert()",id:"bulkupsert",level:3},{value:"incrementalUpsert()",id:"incrementalupsert",level:3},{value:"find()",id:"find",level:3},{value:"findOne()",id:"findone",level:3},{value:"findByIds()",id:"findbyids",level:3},{value:"exportJSON()",id:"exportjson",level:3},{value:"importJSON()",id:"importjson",level:3},{value:"remove()",id:"remove",level:3},{value:"destroy()",id:"destroy",level:3},{value:"isRxCollection",id:"isrxcollection",level:3}];function d(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",...(0,s.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.h1,{id:"rxcollection",children:"RxCollection"}),"\n",(0,o.jsx)(n.p,{children:"A collection stores documents of the same type."}),"\n",(0,o.jsx)(n.h2,{id:"creating-a-collection",children:"Creating a Collection"}),"\n",(0,o.jsxs)(n.p,{children:["To create one or more collections you need a RxDatabase object which has the ",(0,o.jsx)(n.code,{children:".addCollections()"}),"-method. Every collection needs a collection name and a valid ",(0,o.jsx)(n.code,{children:"RxJsonSchema"}),". Other attributes are optional."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const myCollections = await myDatabase.addCollections({\n // key = collectionName\n humans: {\n schema: mySchema,\n statics: {}, // (optional) ORM-functions for this collection\n methods: {}, // (optional) ORM-functions for documents\n attachments: {}, // (optional) ORM-functions for attachments\n options: {}, // (optional) Custom parameters that might be used in plugins\n migrationStrategies: {}, // (optional)\n autoMigrate: true, // (optional) [default=true]\n cacheReplacementPolicy: function(){}, // (optional) custom cache replacement policy\n conflictHandler: function(){} // (optional) a custom conflict handler can be used\n },\n // you can create multiple collections at once\n animals: {\n // ...\n }\n});\n"})}),"\n",(0,o.jsx)(n.h3,{id:"name",children:"name"}),"\n",(0,o.jsxs)(n.p,{children:["The name uniquely identifies the collection and should be used to refine the collection in the database. Two different collections in the same database can never have the same name. Collection names must match the following regex: ",(0,o.jsx)(n.code,{children:"^[a-z][a-z0-9]*$"}),"."]}),"\n",(0,o.jsx)(n.h3,{id:"schema",children:"schema"}),"\n",(0,o.jsxs)(n.p,{children:["The schema defines how the documents of the collection are structured. RxDB uses a schema format, similar to ",(0,o.jsx)(n.a,{href:"https://json-schema.org/",children:"JSON schema"}),". Read more about the RxDB schema format ",(0,o.jsx)(n.a,{href:"/rx-schema.html",children:"here"}),"."]}),"\n",(0,o.jsx)(n.h3,{id:"orm-functions",children:"ORM-functions"}),"\n",(0,o.jsxs)(n.p,{children:["With the parameters ",(0,o.jsx)(n.code,{children:"statics"}),", ",(0,o.jsx)(n.code,{children:"methods"})," and ",(0,o.jsx)(n.code,{children:"attachments"}),", you can define ORM-functions that are applied to each of these objects that belong to this collection. See ",(0,o.jsx)(n.a,{href:"/orm.html",children:"ORM/DRM"}),"."]}),"\n",(0,o.jsx)(n.h3,{id:"migration",children:"Migration"}),"\n",(0,o.jsxs)(n.p,{children:["With the parameters ",(0,o.jsx)(n.code,{children:"migrationStrategies"})," and ",(0,o.jsx)(n.code,{children:"autoMigrate"})," you can specify how migration between different schema-versions should be done. ",(0,o.jsx)(n.a,{href:"/migration-schema.html",children:"See Migration"}),"."]}),"\n",(0,o.jsx)(n.h2,{id:"get-a-collection-from-the-database",children:"Get a collection from the database"}),"\n",(0,o.jsx)(n.p,{children:"To get an existing collection from the database, call the collection name directly on the database:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-javascript",children:"// newly created collection\nconst collections = await db.addCollections({\n heroes: {\n schema: mySchema\n }\n});\nconst collection2 = db.heroes;\nconsole.log(collections.heroes === collection2); //> true\n"})}),"\n",(0,o.jsx)(n.h2,{id:"functions",children:"Functions"}),"\n",(0,o.jsx)(n.h3,{id:"observe-",children:"Observe $"}),"\n",(0,o.jsxs)(n.p,{children:["Calling this will return an ",(0,o.jsx)(n.a,{href:"http://reactivex.io/rxjs/manual/overview.html#observable",children:"rxjs-Observable"})," which streams every change to data of this collection."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"myCollection.$.subscribe(changeEvent => console.dir(changeEvent));\n\n// you can also observe single event-types with insert$ update$ remove$\nmyCollection.insert$.subscribe(changeEvent => console.dir(changeEvent));\nmyCollection.update$.subscribe(changeEvent => console.dir(changeEvent));\nmyCollection.remove$.subscribe(changeEvent => console.dir(changeEvent));\n\n"})}),"\n",(0,o.jsx)(n.h3,{id:"insert",children:"insert()"}),"\n",(0,o.jsx)(n.p,{children:"Use this to insert new documents into the database. The collection will validate the schema and automatically encrypt any encrypted fields. Returns the new RxDocument."}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const doc = await myCollection.insert({\n name: 'foo',\n lastname: 'bar'\n});\n"})}),"\n",(0,o.jsx)(n.h3,{id:"bulkinsert",children:"bulkInsert()"}),"\n",(0,o.jsxs)(n.p,{children:["When you have to insert many documents at once, use bulk insert. This is much faster than calling ",(0,o.jsx)(n.code,{children:".insert()"})," multiple times.\nReturns an object with a ",(0,o.jsx)(n.code,{children:"success"}),"- and ",(0,o.jsx)(n.code,{children:"error"}),"-array."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const result = await myCollection.bulkInsert([{\n name: 'foo1',\n lastname: 'bar1'\n},\n{\n name: 'foo2',\n lastname: 'bar2'\n}]);\n\n// > {\n// success: [RxDocument, RxDocument],\n// error: []\n// }\n"})}),"\n",(0,o.jsxs)(n.p,{children:["NOTICE: ",(0,o.jsx)(n.code,{children:"bulkInsert"})," will not fail on update conflicts and you cannot expect that on failure the other documents are not inserted. Also the call to ",(0,o.jsx)(n.code,{children:"bulkInsert()"})," it will not throw if a single document errors because of validation errors. Instead it will return the error in the ",(0,o.jsx)(n.code,{children:".error"})," property of the returned object."]}),"\n",(0,o.jsx)(n.h3,{id:"bulkremove",children:"bulkRemove()"}),"\n",(0,o.jsxs)(n.p,{children:["When you want to remove many documents at once, use bulk remove. Returns an object with a ",(0,o.jsx)(n.code,{children:"success"}),"- and ",(0,o.jsx)(n.code,{children:"error"}),"-array."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const result = await myCollection.bulkRemove([\n 'primary1',\n 'primary2'\n]);\n\n// > {\n// success: [RxDocument, RxDocument],\n// error: []\n// }\n"})}),"\n",(0,o.jsx)(n.h3,{id:"upsert",children:"upsert()"}),"\n",(0,o.jsx)(n.p,{children:"Inserts the document if it does not exist within the collection, otherwise it will overwrite it. Returns the new or overwritten RxDocument."}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const doc = await myCollection.upsert({\n name: 'foo',\n lastname: 'bar2'\n});\n"})}),"\n",(0,o.jsx)(n.h3,{id:"bulkupsert",children:"bulkUpsert()"}),"\n",(0,o.jsxs)(n.p,{children:["Same as ",(0,o.jsx)(n.code,{children:"upsert()"})," but runs over multiple documents. Improves performance compared to running many ",(0,o.jsx)(n.code,{children:"upsert()"})," calls.\nReturns an ",(0,o.jsx)(n.code,{children:"error"})," and a ",(0,o.jsx)(n.code,{children:"success"})," array."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const docs = await myCollection.bulkUpsert([\n {\n name: 'foo',\n lastname: 'bar2'\n },\n {\n name: 'bar',\n lastname: 'foo2'\n }\n]);\n/**\n * {\n * success: [RxDocument, RxDocument]\n * error: [],\n * }\n */\n"})}),"\n",(0,o.jsx)(n.h3,{id:"incrementalupsert",children:"incrementalUpsert()"}),"\n",(0,o.jsxs)(n.p,{children:["When you run many upsert operations on the same RxDocument in a very short timespan, you might get a ",(0,o.jsx)(n.code,{children:"409 Conflict"})," error.\nThis means that you tried to run a ",(0,o.jsx)(n.code,{children:".upsert()"})," on the document, while the previous upsert operation was still running.\nTo prevent these types of errors, you can run incremental upsert operations.\nThe behavior is similar to ",(0,o.jsx)(n.a,{href:"/rx-document.html#incrementalModify",children:"RxDocument.incrementalModify"}),"."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const docData = {\n name: 'Bob', // primary\n lastName: 'Kelso'\n};\n\nmyCollection.upsert(docData);\nmyCollection.upsert(docData);\n// -> throws because of parallel update to the same document\n\nmyCollection.incrementalUpsert(docData);\nmyCollection.incrementalUpsert(docData);\nmyCollection.incrementalUpsert(docData);\n\n// wait until last upsert finished\nawait myCollection.incrementalUpsert(docData);\n// -> works\n"})}),"\n",(0,o.jsx)(n.h3,{id:"find",children:"find()"}),"\n",(0,o.jsxs)(n.p,{children:["To find documents in your collection, use this method. ",(0,o.jsx)(n.a,{href:"/rx-query.html#find",children:"See RxQuery.find()"}),"."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"// find all that are older than 18\nconst olderDocuments = await myCollection\n .find()\n .where('age')\n .gt(18)\n .exec(); // execute\n"})}),"\n",(0,o.jsx)(n.h3,{id:"findone",children:"findOne()"}),"\n",(0,o.jsx)(n.p,{children:"This does basically what find() does, but it returns only a single document. You can pass a primary value to find a single document more easily."}),"\n",(0,o.jsxs)(n.p,{children:["To find documents in your collection, use this method. ",(0,o.jsx)(n.a,{href:"/rx-query.html#findOne",children:"See RxQuery.find()"}),"."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"// get document with name:foobar\nmyCollection.findOne({\n selector: {\n name: 'foo'\n }\n}).exec().then(doc => console.dir(doc));\n\n// get document by primary, functionally identical to above query\nmyCollection.findOne('foo')\n .exec().then(doc => console.dir(doc));\n"})}),"\n",(0,o.jsx)(n.h3,{id:"findbyids",children:"findByIds()"}),"\n",(0,o.jsxs)(n.p,{children:["Find many documents by their id (primary value). This has a way better performance than running multiple ",(0,o.jsx)(n.code,{children:"findOne()"})," or a ",(0,o.jsx)(n.code,{children:"find()"})," with a big ",(0,o.jsx)(n.code,{children:"$or"})," selector."]}),"\n",(0,o.jsxs)(n.p,{children:["Returns a ",(0,o.jsx)(n.code,{children:"Map"})," where the primary key of the document is mapped to the document. Documents that do not exist or are deleted, will not be inside of the returned Map."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const ids = [\n 'alice',\n 'bob',\n /* ... */\n];\nconst docsMap = await myCollection.findByIds(ids);\n\nconsole.dir(docsMap); // Map(2)\n"})}),"\n",(0,o.jsxs)(n.p,{children:["NOTICE: The ",(0,o.jsx)(n.code,{children:"Map"})," returned by ",(0,o.jsx)(n.code,{children:"findByIds"})," is not guaranteed to return elements in the same order as the list of ids passed to it."]}),"\n",(0,o.jsx)(n.h3,{id:"exportjson",children:"exportJSON()"}),"\n",(0,o.jsx)(n.p,{children:"Use this function to create a json export from every document in the collection."}),"\n",(0,o.jsxs)(n.p,{children:["Before ",(0,o.jsx)(n.code,{children:"exportJSON()"})," and ",(0,o.jsx)(n.code,{children:"importJSON()"})," can be used, you have to add the ",(0,o.jsx)(n.code,{children:"json-dump"})," plugin."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-javascript",children:"import { addRxPlugin } from 'rxdb';\nimport { RxDBJsonDumpPlugin } from 'rxdb/plugins/json-dump';\naddRxPlugin(RxDBJsonDumpPlugin);\n"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"myCollection.exportJSON()\n .then(json => console.dir(json));\n"})}),"\n",(0,o.jsx)(n.h3,{id:"importjson",children:"importJSON()"}),"\n",(0,o.jsx)(n.p,{children:"To import the json dump into your collection, use this function."}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"// import the dump to the database\nmyCollection.importJSON(json)\n .then(() => console.log('done'));\n"})}),"\n",(0,o.jsx)(n.p,{children:"Note that importing will fire events for each inserted document."}),"\n",(0,o.jsx)(n.h3,{id:"remove",children:"remove()"}),"\n",(0,o.jsx)(n.p,{children:"Removes all known data of the collection and its previous versions.\nThis removes the documents, the schemas, and older schemaVersions."}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"await myCollection.remove();\n// collection is now removed and can be re-created\n"})}),"\n",(0,o.jsx)(n.h3,{id:"destroy",children:"destroy()"}),"\n",(0,o.jsx)(n.p,{children:"Destroys the collection's object instance. This is to free up memory and stop all observers and replications."}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"await myCollection.destroy();\n"})}),"\n",(0,o.jsx)(n.h3,{id:"isrxcollection",children:"isRxCollection"}),"\n",(0,o.jsx)(n.p,{children:"Returns true if the given object is an instance of RxCollection. Returns false if not."}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const is = isRxCollection(myObj);\n"})})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(d,{...e})}):d(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>c});var o=t(6540);const s={},i=o.createContext(s);function l(e){const n=o.useContext(i);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),o.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/docs/assets/js/cbbe8f0a.eb6667a5.js b/docs/assets/js/cbbe8f0a.eb6667a5.js new file mode 100644 index 00000000000..037cb8cf55b --- /dev/null +++ b/docs/assets/js/cbbe8f0a.eb6667a5.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[3852],{8783:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>r,contentTitle:()=>l,default:()=>h,frontMatter:()=>s,metadata:()=>c,toc:()=>a});var o=t(4848),i=t(8453);const s={title:"RxCollection",slug:"rx-collection.html"},l="RxCollection",c={id:"rx-collection",title:"RxCollection",description:"A collection stores documents of the same type.",source:"@site/docs/rx-collection.md",sourceDirName:".",slug:"/rx-collection.html",permalink:"/rx-collection.html",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"RxCollection",slug:"rx-collection.html"},sidebar:"tutorialSidebar",previous:{title:"RxSchema",permalink:"/rx-schema.html"},next:{title:"RxDocument",permalink:"/rx-document.html"}},r={},a=[{value:"Creating a Collection",id:"creating-a-collection",level:2},{value:"name",id:"name",level:3},{value:"schema",id:"schema",level:3},{value:"ORM-functions",id:"orm-functions",level:3},{value:"Migration",id:"migration",level:3},{value:"Get a collection from the database",id:"get-a-collection-from-the-database",level:2},{value:"Functions",id:"functions",level:2},{value:"Observe $",id:"observe-",level:3},{value:"insert()",id:"insert",level:3},{value:"bulkInsert()",id:"bulkinsert",level:3},{value:"bulkRemove()",id:"bulkremove",level:3},{value:"upsert()",id:"upsert",level:3},{value:"bulkUpsert()",id:"bulkupsert",level:3},{value:"incrementalUpsert()",id:"incrementalupsert",level:3},{value:"find()",id:"find",level:3},{value:"findOne()",id:"findone",level:3},{value:"findByIds()",id:"findbyids",level:3},{value:"exportJSON()",id:"exportjson",level:3},{value:"importJSON()",id:"importjson",level:3},{value:"remove()",id:"remove",level:3},{value:"destroy()",id:"destroy",level:3},{value:"isRxCollection",id:"isrxcollection",level:3},{value:"FAQ",id:"faq",level:2}];function d(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",...(0,i.R)(),...e.components},{Details:t}=n;return t||function(e,n){throw new Error("Expected "+(n?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Details",!0),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.h1,{id:"rxcollection",children:"RxCollection"}),"\n",(0,o.jsx)(n.p,{children:"A collection stores documents of the same type."}),"\n",(0,o.jsx)(n.h2,{id:"creating-a-collection",children:"Creating a Collection"}),"\n",(0,o.jsxs)(n.p,{children:["To create one or more collections you need a RxDatabase object which has the ",(0,o.jsx)(n.code,{children:".addCollections()"}),"-method. Every collection needs a collection name and a valid ",(0,o.jsx)(n.code,{children:"RxJsonSchema"}),". Other attributes are optional."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const myCollections = await myDatabase.addCollections({\n // key = collectionName\n humans: {\n schema: mySchema,\n statics: {}, // (optional) ORM-functions for this collection\n methods: {}, // (optional) ORM-functions for documents\n attachments: {}, // (optional) ORM-functions for attachments\n options: {}, // (optional) Custom parameters that might be used in plugins\n migrationStrategies: {}, // (optional)\n autoMigrate: true, // (optional) [default=true]\n cacheReplacementPolicy: function(){}, // (optional) custom cache replacement policy\n conflictHandler: function(){} // (optional) a custom conflict handler can be used\n },\n // you can create multiple collections at once\n animals: {\n // ...\n }\n});\n"})}),"\n",(0,o.jsx)(n.h3,{id:"name",children:"name"}),"\n",(0,o.jsxs)(n.p,{children:["The name uniquely identifies the collection and should be used to refine the collection in the database. Two different collections in the same database can never have the same name. Collection names must match the following regex: ",(0,o.jsx)(n.code,{children:"^[a-z][a-z0-9]*$"}),"."]}),"\n",(0,o.jsx)(n.h3,{id:"schema",children:"schema"}),"\n",(0,o.jsxs)(n.p,{children:["The schema defines how the documents of the collection are structured. RxDB uses a schema format, similar to ",(0,o.jsx)(n.a,{href:"https://json-schema.org/",children:"JSON schema"}),". Read more about the RxDB schema format ",(0,o.jsx)(n.a,{href:"/rx-schema.html",children:"here"}),"."]}),"\n",(0,o.jsx)(n.h3,{id:"orm-functions",children:"ORM-functions"}),"\n",(0,o.jsxs)(n.p,{children:["With the parameters ",(0,o.jsx)(n.code,{children:"statics"}),", ",(0,o.jsx)(n.code,{children:"methods"})," and ",(0,o.jsx)(n.code,{children:"attachments"}),", you can define ORM-functions that are applied to each of these objects that belong to this collection. See ",(0,o.jsx)(n.a,{href:"/orm.html",children:"ORM/DRM"}),"."]}),"\n",(0,o.jsx)(n.h3,{id:"migration",children:"Migration"}),"\n",(0,o.jsxs)(n.p,{children:["With the parameters ",(0,o.jsx)(n.code,{children:"migrationStrategies"})," and ",(0,o.jsx)(n.code,{children:"autoMigrate"})," you can specify how migration between different schema-versions should be done. ",(0,o.jsx)(n.a,{href:"/migration-schema.html",children:"See Migration"}),"."]}),"\n",(0,o.jsx)(n.h2,{id:"get-a-collection-from-the-database",children:"Get a collection from the database"}),"\n",(0,o.jsx)(n.p,{children:"To get an existing collection from the database, call the collection name directly on the database:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-javascript",children:"// newly created collection\nconst collections = await db.addCollections({\n heroes: {\n schema: mySchema\n }\n});\nconst collection2 = db.heroes;\nconsole.log(collections.heroes === collection2); //> true\n"})}),"\n",(0,o.jsx)(n.h2,{id:"functions",children:"Functions"}),"\n",(0,o.jsx)(n.h3,{id:"observe-",children:"Observe $"}),"\n",(0,o.jsxs)(n.p,{children:["Calling this will return an ",(0,o.jsx)(n.a,{href:"http://reactivex.io/rxjs/manual/overview.html#observable",children:"rxjs-Observable"})," which streams every change to data of this collection."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"myCollection.$.subscribe(changeEvent => console.dir(changeEvent));\n\n// you can also observe single event-types with insert$ update$ remove$\nmyCollection.insert$.subscribe(changeEvent => console.dir(changeEvent));\nmyCollection.update$.subscribe(changeEvent => console.dir(changeEvent));\nmyCollection.remove$.subscribe(changeEvent => console.dir(changeEvent));\n\n"})}),"\n",(0,o.jsx)(n.h3,{id:"insert",children:"insert()"}),"\n",(0,o.jsx)(n.p,{children:"Use this to insert new documents into the database. The collection will validate the schema and automatically encrypt any encrypted fields. Returns the new RxDocument."}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const doc = await myCollection.insert({\n name: 'foo',\n lastname: 'bar'\n});\n"})}),"\n",(0,o.jsx)(n.h3,{id:"bulkinsert",children:"bulkInsert()"}),"\n",(0,o.jsxs)(n.p,{children:["When you have to insert many documents at once, use bulk insert. This is much faster than calling ",(0,o.jsx)(n.code,{children:".insert()"})," multiple times.\nReturns an object with a ",(0,o.jsx)(n.code,{children:"success"}),"- and ",(0,o.jsx)(n.code,{children:"error"}),"-array."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const result = await myCollection.bulkInsert([{\n name: 'foo1',\n lastname: 'bar1'\n},\n{\n name: 'foo2',\n lastname: 'bar2'\n}]);\n\n// > {\n// success: [RxDocument, RxDocument],\n// error: []\n// }\n"})}),"\n",(0,o.jsxs)(n.p,{children:["NOTICE: ",(0,o.jsx)(n.code,{children:"bulkInsert"})," will not fail on update conflicts and you cannot expect that on failure the other documents are not inserted. Also the call to ",(0,o.jsx)(n.code,{children:"bulkInsert()"})," it will not throw if a single document errors because of validation errors. Instead it will return the error in the ",(0,o.jsx)(n.code,{children:".error"})," property of the returned object."]}),"\n",(0,o.jsx)(n.h3,{id:"bulkremove",children:"bulkRemove()"}),"\n",(0,o.jsxs)(n.p,{children:["When you want to remove many documents at once, use bulk remove. Returns an object with a ",(0,o.jsx)(n.code,{children:"success"}),"- and ",(0,o.jsx)(n.code,{children:"error"}),"-array."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const result = await myCollection.bulkRemove([\n 'primary1',\n 'primary2'\n]);\n\n// > {\n// success: [RxDocument, RxDocument],\n// error: []\n// }\n"})}),"\n",(0,o.jsx)(n.h3,{id:"upsert",children:"upsert()"}),"\n",(0,o.jsx)(n.p,{children:"Inserts the document if it does not exist within the collection, otherwise it will overwrite it. Returns the new or overwritten RxDocument."}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const doc = await myCollection.upsert({\n name: 'foo',\n lastname: 'bar2'\n});\n"})}),"\n",(0,o.jsx)(n.h3,{id:"bulkupsert",children:"bulkUpsert()"}),"\n",(0,o.jsxs)(n.p,{children:["Same as ",(0,o.jsx)(n.code,{children:"upsert()"})," but runs over multiple documents. Improves performance compared to running many ",(0,o.jsx)(n.code,{children:"upsert()"})," calls.\nReturns an ",(0,o.jsx)(n.code,{children:"error"})," and a ",(0,o.jsx)(n.code,{children:"success"})," array."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const docs = await myCollection.bulkUpsert([\n {\n name: 'foo',\n lastname: 'bar2'\n },\n {\n name: 'bar',\n lastname: 'foo2'\n }\n]);\n/**\n * {\n * success: [RxDocument, RxDocument]\n * error: [],\n * }\n */\n"})}),"\n",(0,o.jsx)(n.h3,{id:"incrementalupsert",children:"incrementalUpsert()"}),"\n",(0,o.jsxs)(n.p,{children:["When you run many upsert operations on the same RxDocument in a very short timespan, you might get a ",(0,o.jsx)(n.code,{children:"409 Conflict"})," error.\nThis means that you tried to run a ",(0,o.jsx)(n.code,{children:".upsert()"})," on the document, while the previous upsert operation was still running.\nTo prevent these types of errors, you can run incremental upsert operations.\nThe behavior is similar to ",(0,o.jsx)(n.a,{href:"/rx-document.html#incrementalModify",children:"RxDocument.incrementalModify"}),"."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const docData = {\n name: 'Bob', // primary\n lastName: 'Kelso'\n};\n\nmyCollection.upsert(docData);\nmyCollection.upsert(docData);\n// -> throws because of parallel update to the same document\n\nmyCollection.incrementalUpsert(docData);\nmyCollection.incrementalUpsert(docData);\nmyCollection.incrementalUpsert(docData);\n\n// wait until last upsert finished\nawait myCollection.incrementalUpsert(docData);\n// -> works\n"})}),"\n",(0,o.jsx)(n.h3,{id:"find",children:"find()"}),"\n",(0,o.jsxs)(n.p,{children:["To find documents in your collection, use this method. ",(0,o.jsx)(n.a,{href:"/rx-query.html#find",children:"See RxQuery.find()"}),"."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"// find all that are older than 18\nconst olderDocuments = await myCollection\n .find()\n .where('age')\n .gt(18)\n .exec(); // execute\n"})}),"\n",(0,o.jsx)(n.h3,{id:"findone",children:"findOne()"}),"\n",(0,o.jsx)(n.p,{children:"This does basically what find() does, but it returns only a single document. You can pass a primary value to find a single document more easily."}),"\n",(0,o.jsxs)(n.p,{children:["To find documents in your collection, use this method. ",(0,o.jsx)(n.a,{href:"/rx-query.html#findOne",children:"See RxQuery.find()"}),"."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"// get document with name:foobar\nmyCollection.findOne({\n selector: {\n name: 'foo'\n }\n}).exec().then(doc => console.dir(doc));\n\n// get document by primary, functionally identical to above query\nmyCollection.findOne('foo')\n .exec().then(doc => console.dir(doc));\n"})}),"\n",(0,o.jsx)(n.h3,{id:"findbyids",children:"findByIds()"}),"\n",(0,o.jsxs)(n.p,{children:["Find many documents by their id (primary value). This has a way better performance than running multiple ",(0,o.jsx)(n.code,{children:"findOne()"})," or a ",(0,o.jsx)(n.code,{children:"find()"})," with a big ",(0,o.jsx)(n.code,{children:"$or"})," selector."]}),"\n",(0,o.jsxs)(n.p,{children:["Returns a ",(0,o.jsx)(n.code,{children:"Map"})," where the primary key of the document is mapped to the document. Documents that do not exist or are deleted, will not be inside of the returned Map."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const ids = [\n 'alice',\n 'bob',\n /* ... */\n];\nconst docsMap = await myCollection.findByIds(ids);\n\nconsole.dir(docsMap); // Map(2)\n"})}),"\n",(0,o.jsxs)(n.p,{children:["NOTICE: The ",(0,o.jsx)(n.code,{children:"Map"})," returned by ",(0,o.jsx)(n.code,{children:"findByIds"})," is not guaranteed to return elements in the same order as the list of ids passed to it."]}),"\n",(0,o.jsx)(n.h3,{id:"exportjson",children:"exportJSON()"}),"\n",(0,o.jsx)(n.p,{children:"Use this function to create a json export from every document in the collection."}),"\n",(0,o.jsxs)(n.p,{children:["Before ",(0,o.jsx)(n.code,{children:"exportJSON()"})," and ",(0,o.jsx)(n.code,{children:"importJSON()"})," can be used, you have to add the ",(0,o.jsx)(n.code,{children:"json-dump"})," plugin."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-javascript",children:"import { addRxPlugin } from 'rxdb';\nimport { RxDBJsonDumpPlugin } from 'rxdb/plugins/json-dump';\naddRxPlugin(RxDBJsonDumpPlugin);\n"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"myCollection.exportJSON()\n .then(json => console.dir(json));\n"})}),"\n",(0,o.jsx)(n.h3,{id:"importjson",children:"importJSON()"}),"\n",(0,o.jsx)(n.p,{children:"To import the json dump into your collection, use this function."}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"// import the dump to the database\nmyCollection.importJSON(json)\n .then(() => console.log('done'));\n"})}),"\n",(0,o.jsx)(n.p,{children:"Note that importing will fire events for each inserted document."}),"\n",(0,o.jsx)(n.h3,{id:"remove",children:"remove()"}),"\n",(0,o.jsx)(n.p,{children:"Removes all known data of the collection and its previous versions.\nThis removes the documents, the schemas, and older schemaVersions."}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"await myCollection.remove();\n// collection is now removed and can be re-created\n"})}),"\n",(0,o.jsx)(n.h3,{id:"destroy",children:"destroy()"}),"\n",(0,o.jsx)(n.p,{children:"Destroys the collection's object instance. This is to free up memory and stop all observers and replications."}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"await myCollection.destroy();\n"})}),"\n",(0,o.jsx)(n.h3,{id:"isrxcollection",children:"isRxCollection"}),"\n",(0,o.jsx)(n.p,{children:"Returns true if the given object is an instance of RxCollection. Returns false if not."}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",children:"const is = isRxCollection(myObj);\n"})}),"\n",(0,o.jsx)(n.h2,{id:"faq",children:"FAQ"}),"\n",(0,o.jsxs)(t,{children:[(0,o.jsx)("summary",{children:"When I reload the browser window, will my collections still be in the database?"}),(0,o.jsx)("div",{children:(0,o.jsxs)(n.p,{children:["No, the javascript instance of the collections will not automatically load into the database on page reloads.\nYou have to call the ",(0,o.jsx)(n.code,{children:"addCollections()"})," method each time you create your database. This will create the JavaScript object instance of the RxCollection so that you can use it in the RxDatabase. The persisted data will be automatically in your RxCollection each time you create it."]})})]})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(d,{...e})}):d(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>c});var o=t(6540);const i={},s=o.createContext(i);function l(e){const n=o.useContext(s);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:l(e.components),o.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/docs/assets/js/cde77f4f.61f8bda2.js b/docs/assets/js/cde77f4f.61f8bda2.js new file mode 100644 index 00000000000..23f0e54b145 --- /dev/null +++ b/docs/assets/js/cde77f4f.61f8bda2.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[6287,2584],{2658:(e,t,r)=>{r.d(t,{Tj:()=>Kr,C3:()=>zr,IA:()=>Hr});var a=r(7329);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)},d=new Set(["__proto__","prototype","constructor"]),h=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(d.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(d.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&&!h.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(d.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.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),t}((0,w.A)(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.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),t}((0,w.A)(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 S(e){return!(!e||409!==e.status)&&e}var E={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var C=/\./g,P="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 F(e){var t=q((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=Q,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=W(e);(0,g.Hb)(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.k_)(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 Q={type:"object",properties:{lwt:{type:"number",minimum:$,maximum:1e15,multipleOf:.01}},additionalProperties:!0,required:["lwt"]};function W(e){var t=Object.keys(e.properties).filter((t=>e.properties[t].final)),r=q(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,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=q(e.primaryKey);t.push([r]),t.push(["_deleted",r]),e.indexes&&e.indexes.forEach((e=>{var r=(0,g.$r)(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.$r)(a).forEach((a=>{t.has(a)||(t.add(a),"boolean"===M(e,a).type&&r.push(a))}))})),r.push("_deleted"),(0,g.jw)(r)):r}var oe=r(9092),ce=r(5734),le=r(3337),ue=String.fromCharCode(65535),de=Number.MIN_SAFE_INTEGER;function he(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?de:ue,endKey:a?ue:de,inclusiveStart:!0,inclusiveEnd:!0};return void 0===i.startKey&&(i.startKey=de),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})),d=u.map((e=>e.startKey)),h=u.map((e=>e.endKey)),m={index:e,startKeys:d,endKeys:h,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!i.has(e))).join(","),selectorSatisfiedByIndex:ye(e,t.selector,d,h)},p=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},i=10,s=(0,g.Sd)(r.startKeys,(e=>e!==de&&e!==ue));n(s*i);var o=(0,g.Sd)(r.startKeys,(e=>e!==ue&&e!==de));n(o*i);var c=(0,g.Sd)(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 d=[],h=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&&h.add(m),"$eq"!==y){if(d.length>0)return!1;d.push(y)}}var v=0;for(var g of e){for(var b of[s,h]){if(!b.has(g)&&b.size>0)return!1;b.delete(g)}if(r[v]!==a[v]&&s.size>0&&h.size>0)return!1;v++}return!0}var ve=r(744),ge=r(2779),be=r(1692),xe=r(4903),we=r(7705),je=r(2403),ke=r(6776),De=r(6950),_e=r(6823),Ie=!1;function Re(e){return Ie||((0,ge.DZ)(ge.hu.PIPELINE,{$sort:xe.xF,$project:xe.C2}),(0,ge.DZ)(ge.hu.QUERY,{$and:we.a6,$eq:je.XV,$elemMatch:De.Jy,$exists:_e.P,$gt:je.MR,$gte:je.fy,$in:je.oZ,$lt:je.NV,$lte:je.Q_,$ne:je.C5,$nin:je.GU,$mod:ke.Pp,$nor:we.q3,$not:we.En,$or:we.sU,$regex:ke.WP,$size:De.Ig,$type:_e.T}),Ie=!0),new be.X(e)}function Se(e,t){var r=q(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.$r)(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.k_)(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 Ee(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 Pe(e){return e===de?-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(Pe),n=t.endKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Pe);return r.bound(a,n,!t.inclusiveStart,!t.inclusiveEnd)}async function Ae(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=Ce(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(H);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 d=Ee(e.schema,t.query);u=u.sort(d)}return{documents:u=u.slice(n,i)}}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 Be(e){return parseInt(e.split("-")[0],10)}function Me(e,t){var r=t?t._rev:null;return(r?$e(r).height:0)+1+"-"+e}var Te="_rxdb_internal";async function qe(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 Fe(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 Qe(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 We(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=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 ze(e){var t=s(e);return t._meta=s(e._meta),t}function Ke(e,t,r){j.deepFreezeWhenDevMode(r);var a=q(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=T(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.t)(),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.ZN)(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.Hb)(a.error,e.error),(0,g.Hb)(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.ZN)(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:B(),_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(3561),Ze=r(703),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.X2(["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.B,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,Ue.X)(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 d=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),d()}}}var Ye=(0,ce.t)(),Xe=function(){function e(e,t,r,a,n,i,s){this.changes$=new oe.B,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=q(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=[],d=[],h={id:O(10),events:[],checkpoint:null,context:n,startTime:(0,ce.t)(),endTime:0},m=h.events,p=[],f=[],y=[],v=r.size>0,g=a.length,b=function(){var e,n=a[x],h=n.document,g=n.previous,b=h[t],w=h._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 d.push(_),1}var R=c?We(n):n;c&&(w?g&&Object.keys(g._attachments).forEach((e=>{f.push({documentId:b,attachmentId:e,digest:(0,le.ZN)(g)._attachments[e].digest})})):(Object.entries(h._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(h._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?d.push(e):(c?(u.push(We(R)),s&&s(h)):(u.push(R),s&&s(h)),o=R);var S=null,E=null,C=null;if(j&&!w)C="INSERT",S=c?He(h):h;else if(!g||j||w){if(!w)throw I("SNH",{args:{writeRow:n}});C="DELETE",S=(0,le.ZN)(h),E=g}else C="UPDATE",S=c?He(h):h,E=g;var P={documentId:b,documentData:S,previousDocumentData:E,operation:C};m.push(P)}else{var O=!!w;if(c&&Object.entries(h._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},d.push(e))})),e||(c?(l.push(We(n)),i&&i(h)):(l.push(n),i&&i(h)),o=n),!O){var N={documentId:b,operation:"INSERT",documentData:c?He(h):h,previousDocumentData:c&&g?He(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.ZN)(r)).eventBulk.events.length>0){var s=(0,le.ZN)(r.newestRow).document;r.eventBulk.checkpoint={id:s[this.primaryPath],lwt:s._meta.lwt},r.eventBulk.endTime=(0,ce.t)(),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),Ae(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(H);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 Ae(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.t)()-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.B},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.cf(o,e),i={[H]:ae(n),[z]:"++sequence, id",[K]:"id"};return t.version(1).stores(i),await t.open(),{dexieDb:t,dexieTable:t[H],dexieAttachmentsTable:t[K],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(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.10.0",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 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.k_)(e)?e:[e]))}(this.jsonSchema),this.primaryPath=q(this.jsonSchema.primaryKey),this.finalFields=W(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.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.A)(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=F(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(7708),dt=r(8146),ht=r(3356),mt=r(5520),pt=r(8609),ft=r(1753);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.ZN)(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=$e(i._rev).height,n.forEach((e=>{var t=$e(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(d){u.reject(d),u.reject=()=>{},u.resolve=()=>{}}try{await this.preWrite(l,o)}catch(d){return void a.forEach((e=>e.reject(d)))}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=S(e);if(o){var c=i(this.queueByDocId,a,(()=>[]));s.reverse().forEach((e=>{e.lastKnownDocumentState=(0,le.ZN)(o.documentInDb),(0,le.ZN)(c).unshift(e)}))}else{var l=I("COL20",{name:E[(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.T)((e=>e._data._deleted)))},get deleted$$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().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,dt.p)((e=>!e.isLocal)),(0,dt.p)((e=>e.documentId===this.primary)),(0,ut.T)((e=>vt(e))),(0,ht.Z)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ut.T)((e=>this.collection._docCache.getCachedRxDocument(e))),(0,pt.t)(le.bz))},get $$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},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.T)((t=>y(t,e))),(0,mt.F)())},get$$(e){var t=this.get$(e);return this.collection.database.getReactivityFactory().fromObservable(t,this.getLatest().get(e))},populate(e){var t=M(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.$A;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(a.endsWith("$$")){var i=a.slice(0,-2);return r.get$$(A(e+"."+i))}if("$"===n){var s=a.slice(0,-1);return r.get$(A(e+"."+s))}if("_"===n){var o=a.slice(0,-1);return r.populate(A(e+"."+o))}return r.get(A(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 Qe(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 Qe(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(2198),Dt=r(511),_t=r(4157),It=r(2442),Rt=r(6114);function St(e,t){return t.sort&&0!==t.sort.length?t.sort.map((e=>Object.keys(e)[0])):[e]}var Et=new WeakMap;function Ct(e,t){if(!e.collection.database.eventReduce)return{runFullQueryAgain:!0};var r=function(e){return i(Et,e,(()=>{var t=e.collection,r=Se(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=Ee(t.schema.jsonSchema,r),i=Ce(t.schema.jsonSchema,r);return{primaryKey:e.collection.schema.primaryPath,skip:r.skip,limit:r.limit,sortFields:St(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.ZN)(e._result).docsData.slice(0),n=(0,le.ZN)(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.kC)(t);return"runFullQueryAgain"===i||("doNothing"!==i?(s=!0,(0,Rt.Cs)(i,r,e,a,n),!1):void 0)}))?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:s,newResults:a}}var Pt=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 At,$t,Bt=(At=100,$t=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 Tt=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.A)(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=Be(o._rev),u=i(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),d=u.byRev,h=d.get(l),m=h?h.deref():void 0;return m||(o=n(o),m=s(o),d.set(l,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,ft.vN)().then((()=>{e.registerIdlePromise=void 0;var t=e.registerIdleTasks;0!==t.length&&(e.registerIdleTasks=[],t.forEach((e=>{a.register(e,{docId:e.primary,revisionHeight:Be(e.revision)})})))}))))),m};return o}(this))}}]),e}();function qt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Ft=function(){function e(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=qt(this.collection._docCache,t)}return(0,b.A)(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 Ft(this.collection,e,e.length);this._result=t}else this._result=new Ft(this.collection,[],e)},t._execOverDatabase=async function(){if(this._execOverDatabaseCount=this._execOverDatabaseCount+1,this._lastExecStart=(0,ce.t)(),"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.ZN)(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.Hb)(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.t)(),e)))},t.exec=function(e){if(e&&"findOne"!==this.op)throw I("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Kt(this).then((()=>(0,Dt._)(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:Se(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=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 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.A)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,dt.p)((e=>!e.isLocal)),(0,ht.Z)(null),(0,It.Z)((()=>Kt(this))),(0,ut.T)((()=>this._result)),(0,pt.t)(le.bz),(0,mt.F)(((e,t)=>!(!e||e.time!==(0,le.ZN)(t).time))),(0,dt.p)((e=>!!e)),(0,ut.T)((e=>{var t=(0,le.ZN)(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.h)(e,this.refCount$.pipe((0,dt.p)((()=>!1))))}return this._$}},{key:"$$",get:function(){return this.collection.database.getReactivityFactory().fromObservable(this.$,void 0)}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return l(this,"queryMatcher",Ce(0,Se(this.collection.schema.jsonSchema,this.mangoQuery)))}},{key:"asRxQuery",get:function(){return this}}]),e}();function Ht(e,t,r,a){st("preCreateRxQuery",{op:e,queryObj:t,collection:r,other:a});var n,i,s=new Wt(e,t,r,a);return s=(n=s).collection._queryCache.getByQuery(n),i=r,Mt.has(i)||(Mt.add(i),(0,ft.dY)().then((()=>(0,ft.Ve)(200))).then((()=>{i.destroyed||i.cacheReplacementPolicy(i,i._queryCache),Mt.delete(i)}))),s}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.Dr:(e._ensureEqualQueue=e._ensureEqualQueue.then((()=>function(e){if(e._lastEnsureEqual=(0,ce.t)(),e.collection.database.destroyed||zt(e))return ft.Dr;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.ZN)(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=Ct(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=ze(e);return t._deleted=!0,t._meta.lwt=(0,ce.t)(),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,dt.p)((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(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"],dr=!1,hr=function(){function e(e,t,r,a,n,i,s,o,c,l,u,d){void 0===n&&(n={}),void 0===i&&(i={}),void 0===s&&(s={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===l&&(l=Bt),void 0===u&&(u={}),void 0===d&&(d=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 Pt,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=d,function(e){if(dr)return;dr=!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=Ke(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,dt.p)((e=>e.collectionName===this.name)));this.$=t.pipe((0,It.Z)((e=>e.events))),this.checkpoint$=t.pipe((0,ut.T)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Tt(this.schema.primaryPath,this.$.pipe((0,dt.p)((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=>Fe(!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.em},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 Qe(this,e[this.schema.primaryPath],e,r),(0,le.ZN)(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=qt(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.ZN)(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 Qe(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.em),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:{}}),Ht("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=Ht("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=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 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.em;var i=n.series.map((e=>()=>e(r,a)));return(0,ft.h$)(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.Dr:(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.A)(e,[{key:"insert$",get:function(){return this.$.pipe((0,dt.p)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,dt.p)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,dt.p)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}]),e}();var mr=r(7635),pr=r(1007);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.sc)(e))},yr=r(5525),vr=new Set,gr=function(){function e(e,t,r,a,n,i,s,o,c,l,u,d,h){void 0===s&&(s=!1),void 0===o&&(o={}),this.idleQueue=new mr.G,this.rxdbVersion=rt,this.storageInstances=new Set,this._subs=[],this.startupErrors=[],this.onDestroy=[],this.destroyed=!1,this.collections={},this.eventBulks$=new oe.B,this.observable$=this.eventBulks$.pipe((0,It.Z)((e=>e.events))),this.storageToken=ft.Dr,this.storageTokenDocument=ft.Dr,this.emittedEventBulkIds=new yr.p4(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=d,this.reactivity=h,"pseudoInstance"!==this.name&&(this.internalStore=Ke(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:B(),_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.ZN)(n.error[0]);if(i.isError&&S(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.ZN)(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.getReactivityFactory=function(){if(!this.reactivity)throw I("DB14",{database:this.name});return this.reactivity},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 qe(this.internalStore,Gt(tr(e,t),Zt));if(!r)throw I("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[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 d=tr(i,l),h={id:Gt(d,Zt),key:d,context:Zt,data:{name:c,schemaHash:await u.hash,schema:u.jsonSchema,version:u.version,connectedStorages:[]},_deleted:!1,_meta:B(),_rev:"",_attachments:{}};a.push({document:h});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.ZN)(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.ZN)(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:d=!1,cacheReplacementPolicy:h=Bt,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 hr(t,r,a,e,n,i,c,l,u,h,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.em;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:h,localDocuments:d,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.Dr:(this.destroyed=!0,await ot("preDestroyRxDatabase",this),this.eventBulks$.complete(),this._subs.map((e=>e.unsubscribe())),"pseudoInstance"===this.name?ft.Dr: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.storage.name+"|"+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.A)(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:Te,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:d=!1,hashFunction:h=fr,reactivity:m}=e;st("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:d}),o||function(e,t){var r=t.name+"|"+e;if(vr.has(r))throw I("DB8",{name:e,storage:t.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}(a,t),vr.add(t.name+"|"+a);var p=O(10);return br(p,t,a,r,i,n).catch((e=>{throw vr.delete(t.name+"|"+a),e})).then((e=>{var f=new gr(a,p,t,r,n,i,s,c,e,h,l,u,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:d}}).then((()=>f))}))}var wr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Wt.prototype,RxCollection:hr.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.A)(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(Cr,this.parent);return this.parent.$.pipe((0,dt.p)((e=>e.documentId===this.primary)),(0,dt.p)((e=>e.isLocal)),(0,ut.T)((e=>vt(e))),(0,ht.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ut.T)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.t)(le.bz))},get $$(){var e=this;return Sr(e).getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},get deleted$$(){var e=this;return Sr(e).getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted)},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 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.T)((e=>e._data)),(0,ut.T)((t=>y(t,e))),(0,mt.F)())},get$$(e){return Sr(this).getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e))},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=s(e))._rev=r._rev}))},async remove(){var e=await Or(this.parent),t={id:this._data.id,data:{},_deleted:!0,_meta:B(),_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)))}};function Sr(e){var t=e.parent;return t instanceof gr?t:t.database}var Er=new WeakMap,Cr=new WeakMap;function Pr(e){var t=e.database?e.database:e,r=e.database?e.name:"",a=(async()=>{var a=await Nr(t.token,t.storage,t.name,r,t.instanceCreationOptions,t.multiInstance);a=Ke(t,a,Mr);var n=new Tt("id",e.$.pipe((0,dt.p)((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=>Fe(!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 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 I("LD8",{database:r.name,collection:a})}return t}function Nr(e,t,r,a,n,i){return t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:Br(a),schema:Mr,options:n,multiInstance:i,devMode:j.isDevMode()})}function Ar(e){var t=Er.get(e);if(t)return Er.delete(e),t.then((e=>e.storageInstance.close()))}async function $r(e,t,r){var a=O(10),n=await Nr(a,e,t,r,{},!1);await n.remove()}function Br(e){return"plugin-local-documents-"+e}var Mr=F({title:"RxLocalDocument",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:128},data:{type:"object",additionalProperties:!0}},required:["id","data"]});async function Tr(e,t){var r=await Or(this),a={id:e,data:t,_deleted:!1,_meta:B(),_rev:"",_attachments:{}};return Le(r.storageInstance,{document:a},"local-document-insert").then((e=>r.docCache.getCachedRxDocument(e)))}function qr(e,t){return this.getLocal(e).then((r=>r?r.incrementalModify((()=>t)):this.insertLocal(e,t)))}async function Lr(e){var t=await Or(this),r=t.docCache,a=r.getLatestDocumentDataIfExists(e);return a?Promise.resolve(r.getCachedRxDocument(a)):qe(t.storageInstance,e).then((e=>e?t.docCache.getCachedRxDocument(e):null))}function Fr(e){return this.$.pipe((0,ht.Z)(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,dt.p)((e=>e.use)),(0,ut.T)((e=>e.doc)))}var Qr={name:"local-documents",rxdb:!0,prototypes:{RxCollection:e=>{e.insertLocal=Tr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Fr},RxDatabase:e=>{e.insertLocal=Tr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Fr}},hooks:{createRxDatabase:{before:e=>{e.creator.localDocuments&&Pr(e.database)}},createRxCollection:{before:e=>{e.creator.localDocuments&&Pr(e.collection)}},preDestroyRxDatabase:{after:e=>Ar(e)},postDestroyRxCollection:{after:e=>Ar(e)},postRemoveRxDatabase:{after:e=>$r(e.storage,e.databaseName,"")},postRemoveRxCollection:{after:e=>$r(e.storage,e.databaseName,e.collectionName)}},overwritable:{}};let Wr;function Hr(){return"undefined"!=typeof window&&window.indexedDB}function zr(){return Wr||(Wr=(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)}))}}(Qr);var e;return await xr({name:"rxdb-landing-v3",localDocuments:!0,storage:(void 0===e&&(e={}),new at(e))})})()),Wr}const Kr=["#e6008d","#8d2089","#5f2688"]},1527:(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,{h:()=>a})},6465:(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var a=r(2303),n=r(6540),i=r(2658),s=r(5607),o=r(4848);function c(){const e=(0,a.A)();return(0,n.useEffect)((()=>{e&&(0,i.IA)()&&(async()=>{const e=await(0,i.C3)(),t=await e.getLocal(s.FORM_VALUE_DOCUMENT_ID);if(console.dir(t),t){if(t._data.data.formSubmitted)return void console.log("# lead already tracked");window.trigger("premium_lead_"+t._data.data.homeCountry.toLowerCase(),Math.floor(t._data.data.price/3)),await t.incrementalPatch({formSubmitted:!0})}else window.trigger("premium_lead_unknown",300),await e.upsertLocal(s.FORM_VALUE_DOCUMENT_ID,{formSubmitted:!0})})()})),(0,o.jsxs)("main",{children:[(0,o.jsx)("br",{}),(0,o.jsx)("br",{}),(0,o.jsx)("br",{}),(0,o.jsx)("br",{}),(0,o.jsxs)("div",{className:"redirectBox",style:{textAlign:"center"},children:[(0,o.jsx)("a",{href:"/",target:"_blank",children:(0,o.jsx)("div",{className:"logo",children:(0,o.jsx)("img",{src:"/files/logo/logo_text.svg",alt:"RxDB",width:120})})}),(0,o.jsx)("br",{}),(0,o.jsx)("br",{}),(0,o.jsx)("h1",{children:"RxDB Premium Form Submitted"}),(0,o.jsx)("br",{}),(0,o.jsxs)("p",{style:{padding:50},children:["Thank you for submitting the form. You will directly get a confirmation email.",(0,o.jsx)("br",{}),(0,o.jsx)("b",{children:"Please check your spam folder!"}),".",(0,o.jsx)("br",{}),"In the next 24 hours you will get an email with a preview of the license agreement."]}),(0,o.jsx)("br",{}),(0,o.jsx)("br",{})]})]})}},5607:(e,t,r)=>{r.r(t),r.d(t,{FORM_VALUE_DOCUMENT_ID:()=>v,default:()=>g});var a=r(4586),n=r(1595),i=r(5260),s=r(6540),o=r(3337),c=r(7810);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:35420},{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},d=.05;var h=r(1527),m=r(2658),p=r(2303),f=r(4848);function y(e){let{children:t,fallback:r}=e;return(0,p.A)()?(0,f.jsx)(f.Fragment,{children:t?.()}):r??null}const v="premium-price-form-value";function g(){const{siteConfig:e}=(0,a.A)(),t=(0,p.A)();return(0,s.useEffect)((()=>{t&&window.trigger("open_pricing_page",1),(async()=>{if(!t||!(0,m.IA)())return;const e=await(0,m.C3)(),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)})),document.getElementById("price-calculator-submit").click())})()})),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(i.A,{children:(0,f.jsx)("body",{className:"homepage"})}),(0,f.jsx)(n.A,{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:[(0,f.jsx)("b",{className:"underline",children:"RxDB"})," Premium Plugins"]}),(0,f.jsxs)("p",{style:{width:"80%"},children:["RxDB's premium plugins offer advanced features and optimizations that enhance application ",(0,f.jsx)("b",{children:"performance"})," ","and are backed by dedicated support and regular updates. Using the premium plugins is recommended for users that use RxDB in a professional context."]}),(0,f.jsxs)("div",{className:"premium-blocks",children:[(0,f.jsx)("a",{href:"/rx-storage-indexeddb.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 IndexedDB"}),(0,f.jsxs)("p",{children:["A storage for browsers based on ",(0,f.jsx)("b",{children:"IndexedDB"}),". Has the best latency on writes and smallest build size."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-opfs.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 OPFS"}),(0,f.jsxs)("p",{children:["Currently the RxStorage with best data throughput that can be used in the browser. Based on the ",(0,f.jsx)("b",{children:"OPFS File System Access API"}),"."]})]})})}),(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 fast storage based on ",(0,f.jsx)("b",{children:"SQLite"})," for Servers and Hybrid Apps. Can be 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-shared-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 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:"/rx-storage-sharding.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 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:"/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?"}),"RxDB Core is open source and many 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 you can consider using the premium plugins as an easy way to improve your applications performance and reduce the build size.",(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:"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 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 2 years access to the Premium Plugins."]}),(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 from your users to any RxDB server."]})]})}),(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.jsx)("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",placeholder:"Company Home Country"}),(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.jsx)("br",{}),(0,f.jsx)("div",{className:"clear"}),(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.ZN)(event);return 69!==e.keyCode&&189!==e.keyCode&&190!==e.keyCode},placeholder:"Company Size"}),(0,f.jsx)("div",{className:"suffix",children:"employee(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)("div",{className:"clear"})]}),(0,f.jsx)("div",{className:"button",id:"price-calculator-submit",onClick:async()=>{(0,h.h)("calculate_premium_price",3);const e=(0,o.ZN)(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.dG)(t.split("-"))})),i={companySize:parseInt(r["company-size"],10),teamSize:r["developer-count"],projectAmount:"1",licensePeriod:1,homeCountryCode:a.code,packages:n},s=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.ZN)(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*=.8),e.packages.length>2&&(a*=.7),e.companySize>1){let t=1+Math.pow(1*e.companySize-1,.85)/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;a1200?100*Math.floor(a/100):50*Math.floor(a/50),{totalPrice:a}}(i);console.log("priceResult:"),console.log(JSON.stringify(s,null,4));const p=(0,o.ZN)(document.getElementById("price-calculator-result")),f=(0,o.ZN)(document.getElementById("total-per-project-per-month")),y=(e,t)=>{console.log("setPrice:"),console.dir(t),e.innerHTML=Math.ceil(t).toString()},g=s.totalPrice/i.licensePeriod;y(f,"infinity"!==i.projectAmount?g/parseInt(i.projectAmount,10)/12:0);const b=await(0,m.C3)();await b.upsertLocal(v,{companySize:r["company-size"],projectAmount:r["project-amount"],licensePeriod:r["license-period"],homeCountry:a.name,packages:n,price:s.totalPrice,formSubmitted:!1}),p.style.display="block"},children:"Estimate Price"})]})})}),(0,f.jsx)("div",{className:"price-calculator",style:{marginBottom:90},children:(0,f.jsxs)("div",{className:"price-calculator-inner",id:"price-calculator-result",style:{display:"none"},children:[(0,f.jsx)("h4",{children:"Estimated Price:"}),(0,f.jsx)("br",{}),(0,f.jsxs)("div",{className:"inner",children:[(0,f.jsx)("span",{className:"price-label",children:"\u20ac"}),(0,f.jsx)("span",{id:"total-per-project-per-month",children:"84"}),(0,f.jsx)("span",{className:"per-month",children:"/month"}),(0,f.jsx)("span",{className:"clear"})]}),(0,f.jsx)("br",{}),(0,f.jsx)("br",{}),(0,f.jsxs)("div",{className:"proceed-hint",children:["Fill out the ",(0,f.jsx)("b",{children:"form below \u2193"})," 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/c5cAfYVe373ccihUfJkyxdU2zg5Iz2liQB09nU6jOQCyRXOJy6W7qPdQdmomvugRj5",children:["Your browser doesn't support iframes, ",(0,f.jsx)("a",{href:"https://webforms.pipedrive.com/f/c5cAfYVe373ccihUfJkyxdU2zg5Iz2liQB09nU6jOQCyRXOJy6W7qPdQdmomvugRj5",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)}},7810:(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;an,Hb:()=>c,S7:()=>s,Sd:()=>o,dG:()=>a,jw:()=>l,k_:()=>i})},3337:(e,t,r)=>{function a(e,t){if(!e)throw t||(t=""),new Error("ensureNotFalsy() is falsy: "+t);return e}r.d(t,{ZN:()=>a,bz:()=>n});var n={bufferSize:1,refCount:!0}},1753:(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,{$A:()=>s,Dr:()=>i,ND:()=>n,Ve:()=>u,dY:()=>a,em:()=>o,h$:()=>d,vN:()=>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 d(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},5734:(e,t,r)=>{r.d(t,{t:()=>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/cde77f4f.a6f9099e.js b/docs/assets/js/cde77f4f.a6f9099e.js deleted file mode 100644 index bf0d1160c3f..00000000000 --- a/docs/assets/js/cde77f4f.a6f9099e.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[6287,2584],{2658:(e,t,r)=>{r.d(t,{Tj:()=>Kr,C3:()=>zr,IA:()=>Hr});var a=r(7329);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)},d=new Set(["__proto__","prototype","constructor"]),h=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(d.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(d.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&&!h.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(d.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.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),t}((0,w.A)(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.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),t}((0,w.A)(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 S(e){return!(!e||409!==e.status)&&e}var E={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var C=/\./g,P="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 F(e){var t=q((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=Q,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=W(e);(0,g.Hb)(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.k_)(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 Q={type:"object",properties:{lwt:{type:"number",minimum:$,maximum:1e15,multipleOf:.01}},additionalProperties:!0,required:["lwt"]};function W(e){var t=Object.keys(e.properties).filter((t=>e.properties[t].final)),r=q(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,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=q(e.primaryKey);t.push([r]),t.push(["_deleted",r]),e.indexes&&e.indexes.forEach((e=>{var r=(0,g.$r)(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.$r)(a).forEach((a=>{t.has(a)||(t.add(a),"boolean"===M(e,a).type&&r.push(a))}))})),r.push("_deleted"),(0,g.jw)(r)):r}var oe=r(9092),ce=r(5734),le=r(3337),ue=String.fromCharCode(65535),de=Number.MIN_SAFE_INTEGER;function he(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?de:ue,endKey:a?ue:de,inclusiveStart:!0,inclusiveEnd:!0};return void 0===i.startKey&&(i.startKey=de),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})),d=u.map((e=>e.startKey)),h=u.map((e=>e.endKey)),m={index:e,startKeys:d,endKeys:h,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!i.has(e))).join(","),selectorSatisfiedByIndex:ye(e,t.selector,d,h)},p=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},i=10,s=(0,g.Sd)(r.startKeys,(e=>e!==de&&e!==ue));n(s*i);var o=(0,g.Sd)(r.startKeys,(e=>e!==ue&&e!==de));n(o*i);var c=(0,g.Sd)(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 d=[],h=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&&h.add(m),"$eq"!==y){if(d.length>0)return!1;d.push(y)}}var v=0;for(var g of e){for(var b of[s,h]){if(!b.has(g)&&b.size>0)return!1;b.delete(g)}if(r[v]!==a[v]&&s.size>0&&h.size>0)return!1;v++}return!0}var ve=r(744),ge=r(2779),be=r(1692),xe=r(4903),we=r(7705),je=r(2403),ke=r(6776),De=r(6950),_e=r(6823),Ie=!1;function Re(e){return Ie||((0,ge.DZ)(ge.hu.PIPELINE,{$sort:xe.xF,$project:xe.C2}),(0,ge.DZ)(ge.hu.QUERY,{$and:we.a6,$eq:je.XV,$elemMatch:De.Jy,$exists:_e.P,$gt:je.MR,$gte:je.fy,$in:je.oZ,$lt:je.NV,$lte:je.Q_,$ne:je.C5,$nin:je.GU,$mod:ke.Pp,$nor:we.q3,$not:we.En,$or:we.sU,$regex:ke.WP,$size:De.Ig,$type:_e.T}),Ie=!0),new be.X(e)}function Se(e,t){var r=q(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.$r)(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.k_)(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 Ee(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 Pe(e){return e===de?-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(Pe),n=t.endKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Pe);return r.bound(a,n,!t.inclusiveStart,!t.inclusiveEnd)}async function Ae(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=Ce(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(H);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 d=Ee(e.schema,t.query);u=u.sort(d)}return{documents:u=u.slice(n,i)}}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 Be(e){return parseInt(e.split("-")[0],10)}function Me(e,t){var r=t?t._rev:null;return(r?$e(r).height:0)+1+"-"+e}var Te="_rxdb_internal";async function qe(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 Fe(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 Qe(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 We(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=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 ze(e){var t=s(e);return t._meta=s(e._meta),t}function Ke(e,t,r){j.deepFreezeWhenDevMode(r);var a=q(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=T(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.t)(),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.ZN)(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.Hb)(a.error,e.error),(0,g.Hb)(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.ZN)(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:B(),_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(3561),Ze=r(703),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.X2(["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.B,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,Ue.X)(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 d=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),d()}}}var Ye=(0,ce.t)(),Xe=function(){function e(e,t,r,a,n,i,s){this.changes$=new oe.B,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=q(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=[],d=[],h={id:O(10),events:[],checkpoint:null,context:n,startTime:(0,ce.t)(),endTime:0},m=h.events,p=[],f=[],y=[],v=r.size>0,g=a.length,b=function(){var e,n=a[x],h=n.document,g=n.previous,b=h[t],w=h._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 d.push(_),1}var R=c?We(n):n;c&&(w?g&&Object.keys(g._attachments).forEach((e=>{f.push({documentId:b,attachmentId:e,digest:(0,le.ZN)(g)._attachments[e].digest})})):(Object.entries(h._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(h._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?d.push(e):(c?(u.push(We(R)),s&&s(h)):(u.push(R),s&&s(h)),o=R);var S=null,E=null,C=null;if(j&&!w)C="INSERT",S=c?He(h):h;else if(!g||j||w){if(!w)throw I("SNH",{args:{writeRow:n}});C="DELETE",S=(0,le.ZN)(h),E=g}else C="UPDATE",S=c?He(h):h,E=g;var P={documentId:b,documentData:S,previousDocumentData:E,operation:C};m.push(P)}else{var O=!!w;if(c&&Object.entries(h._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},d.push(e))})),e||(c?(l.push(We(n)),i&&i(h)):(l.push(n),i&&i(h)),o=n),!O){var N={documentId:b,operation:"INSERT",documentData:c?He(h):h,previousDocumentData:c&&g?He(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.ZN)(r)).eventBulk.events.length>0){var s=(0,le.ZN)(r.newestRow).document;r.eventBulk.checkpoint={id:s[this.primaryPath],lwt:s._meta.lwt},r.eventBulk.endTime=(0,ce.t)(),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),Ae(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(H);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 Ae(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.t)()-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.B},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.cf(o,e),i={[H]:ae(n),[z]:"++sequence, id",[K]:"id"};return t.version(1).stores(i),await t.open(),{dexieDb:t,dexieTable:t[H],dexieAttachmentsTable:t[K],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(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.9.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 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.k_)(e)?e:[e]))}(this.jsonSchema),this.primaryPath=q(this.jsonSchema.primaryKey),this.finalFields=W(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.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.A)(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=F(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(7708),dt=r(8146),ht=r(3356),mt=r(5520),pt=r(8609),ft=r(1753);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.ZN)(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=$e(i._rev).height,n.forEach((e=>{var t=$e(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(d){u.reject(d),u.reject=()=>{},u.resolve=()=>{}}try{await this.preWrite(l,o)}catch(d){return void a.forEach((e=>e.reject(d)))}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=S(e);if(o){var c=i(this.queueByDocId,a,(()=>[]));s.reverse().forEach((e=>{e.lastKnownDocumentState=(0,le.ZN)(o.documentInDb),(0,le.ZN)(c).unshift(e)}))}else{var l=I("COL20",{name:E[(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.T)((e=>e._data._deleted)))},get deleted$$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().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,dt.p)((e=>!e.isLocal)),(0,dt.p)((e=>e.documentId===this.primary)),(0,ut.T)((e=>vt(e))),(0,ht.Z)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ut.T)((e=>this.collection._docCache.getCachedRxDocument(e))),(0,pt.t)(le.bz))},get $$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},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.T)((t=>y(t,e))),(0,mt.F)())},get$$(e){var t=this.get$(e);return this.collection.database.getReactivityFactory().fromObservable(t,this.getLatest().get(e))},populate(e){var t=M(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.$A;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(a.endsWith("$$")){var i=a.slice(0,-2);return r.get$$(A(e+"."+i))}if("$"===n){var s=a.slice(0,-1);return r.get$(A(e+"."+s))}if("_"===n){var o=a.slice(0,-1);return r.populate(A(e+"."+o))}return r.get(A(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 Qe(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 Qe(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(2198),Dt=r(511),_t=r(4157),It=r(2442),Rt=r(6114);function St(e,t){return t.sort&&0!==t.sort.length?t.sort.map((e=>Object.keys(e)[0])):[e]}var Et=new WeakMap;function Ct(e,t){if(!e.collection.database.eventReduce)return{runFullQueryAgain:!0};var r=function(e){return i(Et,e,(()=>{var t=e.collection,r=Se(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=Ee(t.schema.jsonSchema,r),i=Ce(t.schema.jsonSchema,r);return{primaryKey:e.collection.schema.primaryPath,skip:r.skip,limit:r.limit,sortFields:St(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.ZN)(e._result).docsData.slice(0),n=(0,le.ZN)(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.kC)(t);return"runFullQueryAgain"===i||("doNothing"!==i?(s=!0,(0,Rt.Cs)(i,r,e,a,n),!1):void 0)}))?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:s,newResults:a}}var Pt=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 At,$t,Bt=(At=100,$t=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 Tt=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.A)(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=Be(o._rev),u=i(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),d=u.byRev,h=d.get(l),m=h?h.deref():void 0;return m||(o=n(o),m=s(o),d.set(l,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,ft.vN)().then((()=>{e.registerIdlePromise=void 0;var t=e.registerIdleTasks;0!==t.length&&(e.registerIdleTasks=[],t.forEach((e=>{a.register(e,{docId:e.primary,revisionHeight:Be(e.revision)})})))}))))),m};return o}(this))}}]),e}();function qt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Ft=function(){function e(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=qt(this.collection._docCache,t)}return(0,b.A)(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 Ft(this.collection,e,e.length);this._result=t}else this._result=new Ft(this.collection,[],e)},t._execOverDatabase=async function(){if(this._execOverDatabaseCount=this._execOverDatabaseCount+1,this._lastExecStart=(0,ce.t)(),"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.ZN)(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.Hb)(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.t)(),e)))},t.exec=function(e){if(e&&"findOne"!==this.op)throw I("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Kt(this).then((()=>(0,Dt._)(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:Se(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=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 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.A)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,dt.p)((e=>!e.isLocal)),(0,ht.Z)(null),(0,It.Z)((()=>Kt(this))),(0,ut.T)((()=>this._result)),(0,pt.t)(le.bz),(0,mt.F)(((e,t)=>!(!e||e.time!==(0,le.ZN)(t).time))),(0,dt.p)((e=>!!e)),(0,ut.T)((e=>{var t=(0,le.ZN)(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.h)(e,this.refCount$.pipe((0,dt.p)((()=>!1))))}return this._$}},{key:"$$",get:function(){return this.collection.database.getReactivityFactory().fromObservable(this.$,void 0)}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return l(this,"queryMatcher",Ce(0,Se(this.collection.schema.jsonSchema,this.mangoQuery)))}},{key:"asRxQuery",get:function(){return this}}]),e}();function Ht(e,t,r,a){st("preCreateRxQuery",{op:e,queryObj:t,collection:r,other:a});var n,i,s=new Wt(e,t,r,a);return s=(n=s).collection._queryCache.getByQuery(n),i=r,Mt.has(i)||(Mt.add(i),(0,ft.dY)().then((()=>(0,ft.Ve)(200))).then((()=>{i.destroyed||i.cacheReplacementPolicy(i,i._queryCache),Mt.delete(i)}))),s}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.Dr:(e._ensureEqualQueue=e._ensureEqualQueue.then((()=>function(e){if(e._lastEnsureEqual=(0,ce.t)(),e.collection.database.destroyed||zt(e))return ft.Dr;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.ZN)(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=Ct(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=ze(e);return t._deleted=!0,t._meta.lwt=(0,ce.t)(),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,dt.p)((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(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"],dr=!1,hr=function(){function e(e,t,r,a,n,i,s,o,c,l,u,d){void 0===n&&(n={}),void 0===i&&(i={}),void 0===s&&(s={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===l&&(l=Bt),void 0===u&&(u={}),void 0===d&&(d=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 Pt,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=d,function(e){if(dr)return;dr=!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=Ke(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,dt.p)((e=>e.collectionName===this.name)));this.$=t.pipe((0,It.Z)((e=>e.events))),this.checkpoint$=t.pipe((0,ut.T)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Tt(this.schema.primaryPath,this.$.pipe((0,dt.p)((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=>Fe(!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.em},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 Qe(this,e[this.schema.primaryPath],e,r),(0,le.ZN)(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=qt(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.ZN)(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 Qe(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.em),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:{}}),Ht("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=Ht("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=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 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.em;var i=n.series.map((e=>()=>e(r,a)));return(0,ft.h$)(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.Dr:(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.A)(e,[{key:"insert$",get:function(){return this.$.pipe((0,dt.p)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,dt.p)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,dt.p)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}]),e}();var mr=r(7635),pr=r(1007);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.sc)(e))},yr=r(5525),vr=new Set,gr=function(){function e(e,t,r,a,n,i,s,o,c,l,u,d,h){void 0===s&&(s=!1),void 0===o&&(o={}),this.idleQueue=new mr.G,this.rxdbVersion=rt,this.storageInstances=new Set,this._subs=[],this.startupErrors=[],this.onDestroy=[],this.destroyed=!1,this.collections={},this.eventBulks$=new oe.B,this.observable$=this.eventBulks$.pipe((0,It.Z)((e=>e.events))),this.storageToken=ft.Dr,this.storageTokenDocument=ft.Dr,this.emittedEventBulkIds=new yr.p4(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=d,this.reactivity=h,"pseudoInstance"!==this.name&&(this.internalStore=Ke(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:B(),_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.ZN)(n.error[0]);if(i.isError&&S(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.ZN)(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.getReactivityFactory=function(){if(!this.reactivity)throw I("DB14",{database:this.name});return this.reactivity},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 qe(this.internalStore,Gt(tr(e,t),Zt));if(!r)throw I("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[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 d=tr(i,l),h={id:Gt(d,Zt),key:d,context:Zt,data:{name:c,schemaHash:await u.hash,schema:u.jsonSchema,version:u.version,connectedStorages:[]},_deleted:!1,_meta:B(),_rev:"",_attachments:{}};a.push({document:h});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.ZN)(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.ZN)(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:d=!1,cacheReplacementPolicy:h=Bt,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 hr(t,r,a,e,n,i,c,l,u,h,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.em;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:h,localDocuments:d,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.Dr:(this.destroyed=!0,await ot("preDestroyRxDatabase",this),this.eventBulks$.complete(),this._subs.map((e=>e.unsubscribe())),"pseudoInstance"===this.name?ft.Dr: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.storage.name+"|"+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.A)(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:Te,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:d=!1,hashFunction:h=fr,reactivity:m}=e;st("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:d}),o||function(e,t){var r=t.name+"|"+e;if(vr.has(r))throw I("DB8",{name:e,storage:t.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}(a,t),vr.add(t.name+"|"+a);var p=O(10);return br(p,t,a,r,i,n).catch((e=>{throw vr.delete(t.name+"|"+a),e})).then((e=>{var f=new gr(a,p,t,r,n,i,s,c,e,h,l,u,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:d}}).then((()=>f))}))}var wr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Wt.prototype,RxCollection:hr.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.A)(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(Cr,this.parent);return this.parent.$.pipe((0,dt.p)((e=>e.documentId===this.primary)),(0,dt.p)((e=>e.isLocal)),(0,ut.T)((e=>vt(e))),(0,ht.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ut.T)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.t)(le.bz))},get $$(){var e=this;return Sr(e).getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},get deleted$$(){var e=this;return Sr(e).getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted)},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 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.T)((e=>e._data)),(0,ut.T)((t=>y(t,e))),(0,mt.F)())},get$$(e){return Sr(this).getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e))},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=s(e))._rev=r._rev}))},async remove(){var e=await Or(this.parent),t={id:this._data.id,data:{},_deleted:!0,_meta:B(),_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)))}};function Sr(e){var t=e.parent;return t instanceof gr?t:t.database}var Er=new WeakMap,Cr=new WeakMap;function Pr(e){var t=e.database?e.database:e,r=e.database?e.name:"",a=(async()=>{var a=await Nr(t.token,t.storage,t.name,r,t.instanceCreationOptions,t.multiInstance);a=Ke(t,a,Mr);var n=new Tt("id",e.$.pipe((0,dt.p)((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=>Fe(!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 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 I("LD8",{database:r.name,collection:a})}return t}function Nr(e,t,r,a,n,i){return t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:Br(a),schema:Mr,options:n,multiInstance:i,devMode:j.isDevMode()})}function Ar(e){var t=Er.get(e);if(t)return Er.delete(e),t.then((e=>e.storageInstance.close()))}async function $r(e,t,r){var a=O(10),n=await Nr(a,e,t,r,{},!1);await n.remove()}function Br(e){return"plugin-local-documents-"+e}var Mr=F({title:"RxLocalDocument",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:128},data:{type:"object",additionalProperties:!0}},required:["id","data"]});async function Tr(e,t){var r=await Or(this),a={id:e,data:t,_deleted:!1,_meta:B(),_rev:"",_attachments:{}};return Le(r.storageInstance,{document:a},"local-document-insert").then((e=>r.docCache.getCachedRxDocument(e)))}function qr(e,t){return this.getLocal(e).then((r=>r?r.incrementalModify((()=>t)):this.insertLocal(e,t)))}async function Lr(e){var t=await Or(this),r=t.docCache,a=r.getLatestDocumentDataIfExists(e);return a?Promise.resolve(r.getCachedRxDocument(a)):qe(t.storageInstance,e).then((e=>e?t.docCache.getCachedRxDocument(e):null))}function Fr(e){return this.$.pipe((0,ht.Z)(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,dt.p)((e=>e.use)),(0,ut.T)((e=>e.doc)))}var Qr={name:"local-documents",rxdb:!0,prototypes:{RxCollection:e=>{e.insertLocal=Tr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Fr},RxDatabase:e=>{e.insertLocal=Tr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Fr}},hooks:{createRxDatabase:{before:e=>{e.creator.localDocuments&&Pr(e.database)}},createRxCollection:{before:e=>{e.creator.localDocuments&&Pr(e.collection)}},preDestroyRxDatabase:{after:e=>Ar(e)},postDestroyRxCollection:{after:e=>Ar(e)},postRemoveRxDatabase:{after:e=>$r(e.storage,e.databaseName,"")},postRemoveRxCollection:{after:e=>$r(e.storage,e.databaseName,e.collectionName)}},overwritable:{}};let Wr;function Hr(){return"undefined"!=typeof window&&window.indexedDB}function zr(){return Wr||(Wr=(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)}))}}(Qr);var e;return await xr({name:"rxdb-landing-v3",localDocuments:!0,storage:(void 0===e&&(e={}),new at(e))})})()),Wr}const Kr=["#e6008d","#8d2089","#5f2688"]},1527:(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,{h:()=>a})},6465:(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var a=r(2303),n=r(6540),i=r(2658),s=r(5607),o=r(4848);function c(){const e=(0,a.A)();return(0,n.useEffect)((()=>{e&&(0,i.IA)()&&(async()=>{const e=await(0,i.C3)(),t=await e.getLocal(s.FORM_VALUE_DOCUMENT_ID);if(console.dir(t),t){if(t._data.data.formSubmitted)return void console.log("# lead already tracked");window.trigger("premium_lead_"+t._data.data.homeCountry.toLowerCase(),Math.floor(t._data.data.price/3)),await t.incrementalPatch({formSubmitted:!0})}else window.trigger("premium_lead_unknown",300),await e.upsertLocal(s.FORM_VALUE_DOCUMENT_ID,{formSubmitted:!0})})()})),(0,o.jsxs)("main",{children:[(0,o.jsx)("br",{}),(0,o.jsx)("br",{}),(0,o.jsx)("br",{}),(0,o.jsx)("br",{}),(0,o.jsxs)("div",{className:"redirectBox",style:{textAlign:"center"},children:[(0,o.jsx)("a",{href:"/",target:"_blank",children:(0,o.jsx)("div",{className:"logo",children:(0,o.jsx)("img",{src:"/files/logo/logo_text.svg",alt:"RxDB",width:120})})}),(0,o.jsx)("br",{}),(0,o.jsx)("br",{}),(0,o.jsx)("h1",{children:"RxDB Premium Form Submitted"}),(0,o.jsx)("br",{}),(0,o.jsxs)("p",{style:{padding:50},children:["Thank you for submitting the form. You will directly get a confirmation email.",(0,o.jsx)("br",{}),(0,o.jsx)("b",{children:"Please check your spam folder!"}),".",(0,o.jsx)("br",{}),"In the next 24 hours you will get an email with a preview of the license agreement."]}),(0,o.jsx)("br",{}),(0,o.jsx)("br",{})]})]})}},5607:(e,t,r)=>{r.r(t),r.d(t,{FORM_VALUE_DOCUMENT_ID:()=>v,default:()=>g});var a=r(4586),n=r(1595),i=r(5260),s=r(6540),o=r(3337),c=r(7810);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:35420},{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},d=.05;var h=r(1527),m=r(2658),p=r(2303),f=r(4848);function y(e){let{children:t,fallback:r}=e;return(0,p.A)()?(0,f.jsx)(f.Fragment,{children:t?.()}):r??null}const v="premium-price-form-value";function g(){const{siteConfig:e}=(0,a.A)(),t=(0,p.A)();return(0,s.useEffect)((()=>{t&&window.trigger("open_pricing_page",1),(async()=>{if(!t||!(0,m.IA)())return;const e=await(0,m.C3)(),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)})),document.getElementById("price-calculator-submit").click())})()})),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(i.A,{children:(0,f.jsx)("body",{className:"homepage"})}),(0,f.jsx)(n.A,{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:[(0,f.jsx)("b",{className:"underline",children:"RxDB"})," Premium Plugins"]}),(0,f.jsxs)("p",{style:{width:"80%"},children:["RxDB's premium plugins offer advanced features and optimizations that enhance application ",(0,f.jsx)("b",{children:"performance"})," ","and are backed by dedicated support and regular updates. Using the premium plugins is recommended for users that use RxDB in a professional context."]}),(0,f.jsxs)("div",{className:"premium-blocks",children:[(0,f.jsx)("a",{href:"/rx-storage-indexeddb.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 IndexedDB"}),(0,f.jsxs)("p",{children:["A storage for browsers based on ",(0,f.jsx)("b",{children:"IndexedDB"}),". Has the best latency on writes and smallest build size."]})]})})}),(0,f.jsx)("a",{href:"/rx-storage-opfs.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 OPFS"}),(0,f.jsxs)("p",{children:["Currently the RxStorage with best data throughput that can be used in the browser. Based on the ",(0,f.jsx)("b",{children:"OPFS File System Access API"}),"."]})]})})}),(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 fast storage based on ",(0,f.jsx)("b",{children:"SQLite"})," for Servers and Hybrid Apps. Can be 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-shared-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 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:"/rx-storage-sharding.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 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:"/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?"}),"RxDB Core is open source and many 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 you can consider using the premium plugins as an easy way to improve your applications performance and reduce the build size.",(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:"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 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 2 years access to the Premium Plugins."]}),(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 from your users to any RxDB server."]})]})}),(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.jsx)("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",placeholder:"Company Home Country"}),(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.jsx)("br",{}),(0,f.jsx)("div",{className:"clear"}),(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.ZN)(event);return 69!==e.keyCode&&189!==e.keyCode&&190!==e.keyCode},placeholder:"Company Size"}),(0,f.jsx)("div",{className:"suffix",children:"employee(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)("div",{className:"clear"})]}),(0,f.jsx)("div",{className:"button",id:"price-calculator-submit",onClick:async()=>{(0,h.h)("calculate_premium_price",3);const e=(0,o.ZN)(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.dG)(t.split("-"))})),i={companySize:parseInt(r["company-size"],10),teamSize:r["developer-count"],projectAmount:"1",licensePeriod:1,homeCountryCode:a.code,packages:n},s=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.ZN)(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*=.8),e.packages.length>2&&(a*=.7),e.companySize>1){let t=1+Math.pow(1*e.companySize-1,.85)/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;a1200?100*Math.floor(a/100):50*Math.floor(a/50),{totalPrice:a}}(i);console.log("priceResult:"),console.log(JSON.stringify(s,null,4));const p=(0,o.ZN)(document.getElementById("price-calculator-result")),f=(0,o.ZN)(document.getElementById("total-per-project-per-month")),y=(e,t)=>{console.log("setPrice:"),console.dir(t),e.innerHTML=Math.ceil(t).toString()},g=s.totalPrice/i.licensePeriod;y(f,"infinity"!==i.projectAmount?g/parseInt(i.projectAmount,10)/12:0);const b=await(0,m.C3)();await b.upsertLocal(v,{companySize:r["company-size"],projectAmount:r["project-amount"],licensePeriod:r["license-period"],homeCountry:a.name,packages:n,price:s.totalPrice,formSubmitted:!1}),p.style.display="block"},children:"Estimate Price"})]})})}),(0,f.jsx)("div",{className:"price-calculator",style:{marginBottom:90},children:(0,f.jsxs)("div",{className:"price-calculator-inner",id:"price-calculator-result",style:{display:"none"},children:[(0,f.jsx)("h4",{children:"Estimated Price:"}),(0,f.jsx)("br",{}),(0,f.jsxs)("div",{className:"inner",children:[(0,f.jsx)("span",{className:"price-label",children:"\u20ac"}),(0,f.jsx)("span",{id:"total-per-project-per-month",children:"84"}),(0,f.jsx)("span",{className:"per-month",children:"/month"}),(0,f.jsx)("span",{className:"clear"})]}),(0,f.jsx)("br",{}),(0,f.jsx)("br",{}),(0,f.jsxs)("div",{className:"proceed-hint",children:["Fill out the ",(0,f.jsx)("b",{children:"form below \u2193"})," 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/c5cAfYVe373ccihUfJkyxdU2zg5Iz2liQB09nU6jOQCyRXOJy6W7qPdQdmomvugRj5",children:["Your browser doesn't support iframes, ",(0,f.jsx)("a",{href:"https://webforms.pipedrive.com/f/c5cAfYVe373ccihUfJkyxdU2zg5Iz2liQB09nU6jOQCyRXOJy6W7qPdQdmomvugRj5",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)}},7810:(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;an,Hb:()=>c,S7:()=>s,Sd:()=>o,dG:()=>a,jw:()=>l,k_:()=>i})},3337:(e,t,r)=>{function a(e,t){if(!e)throw t||(t=""),new Error("ensureNotFalsy() is falsy: "+t);return e}r.d(t,{ZN:()=>a,bz:()=>n});var n={bufferSize:1,refCount:!0}},1753:(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,{$A:()=>s,Dr:()=>i,ND:()=>n,Ve:()=>u,dY:()=>a,em:()=>o,h$:()=>d,vN:()=>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 d(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},5734:(e,t,r)=>{r.d(t,{t:()=>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/db34d6b0.648ab0fc.js b/docs/assets/js/db34d6b0.648ab0fc.js new file mode 100644 index 00000000000..9de1284afc9 --- /dev/null +++ b/docs/assets/js/db34d6b0.648ab0fc.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[7320],{2658:(e,t,r)=>{r.d(t,{Tj:()=>Zr,C3:()=>Kr,IA:()=>Hr});var a=r(7329);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 u(e,t,r){return Object.defineProperty(e,t,{get:function(){return r}}),r}var h=e=>{var t=typeof e;return null!==e&&("object"===t||"function"===t)},l=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(l.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(l.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(l.has(r))return[];t.push(r);break;case"index":throw new Error("Index was not closed");case"start":t.push("")}return t}function f(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 p(e,t){if(f(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(!h(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 _(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 k=function(e){function t(t,r,a){var n;void 0===a&&(a={});var i=_(r,t,a);return(n=e.call(this,i)||this).code=t,n.message=i,n.parameters=a,n.rxdb=!0,n}return(0,w.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),t}((0,D.A)(Error)),I=function(e){function t(t,r,a){var n;void 0===a&&(a={});var i=_(r,t,a);return(n=e.call(this,i)||this).code=t,n.message=i,n.parameters=a,n.rxdb=!0,n}return(0,w.A)(t,e),t.prototype.toString=function(){return this.message},(0,b.A)(t,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),t}((0,D.A)(TypeError));function E(e,t){return new k(e,x.tunnelErrorMessage(e),t)}function O(e,t){return new I(e,x.tunnelErrorMessage(e),t)}function R(e){return!(!e||409!==e.status)&&e}var C={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var j=/\./g,S="abcdefghijklmnopqrstuvwxyz";function P(e){void 0===e&&(e=10);for(var t="",r=0;r{var r=v(t,e);if(void 0===r)throw E("DOC18",{args:{field:e,documentData:t}});return r})).join(r.separator)}function Q(e){var t=B((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=F,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=W(e);(0,g.Hb)(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.k_)(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 F={type:"object",properties:{lwt:{type:"number",minimum:A,maximum:1e15,multipleOf:.01}},additionalProperties:!0,required:["lwt"]};function W(e){var t=Object.keys(e.properties).filter((t=>e.properties[t].final)),r=B(e.primaryKey);return t.push(r),"string"!=typeof e.primaryKey&&e.primaryKey.fields.forEach((e=>t.push(e))),t}var H="docs",K="changes",Z="attachments",U="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=v(t,e);y(t,e,r?"1":"0")})),t):t}function ee(e,t){return t?(t=re(t=s(t)),e.forEach((e=>{var r=v(t,e);y(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=B(e.primaryKey);t.push([r]),t.push(["_deleted",r]),e.indexes&&e.indexes.forEach((e=>{var r=(0,g.$r)(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.$r)(a).forEach((a=>{t.has(a)||(t.add(a),"boolean"===q(e,a).type&&r.push(a))}))})),r.push("_deleted"),(0,g.jw)(r)):r}var oe=r(9092),ce=r(5734),ue=r(3337),he=String.fromCharCode(65535),le=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=q(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,u=!0,h=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:u?le:he,endKey:a?he:le,inclusiveStart:!0,inclusiveEnd:!0};return void 0===i.startKey&&(i.startKey=le),void 0===i.endKey&&(i.endKey=he),void 0===i.inclusiveStart&&(i.inclusiveStart=!0),void 0===i.inclusiveEnd&&(i.inclusiveEnd=!0),u&&!i.inclusiveStart&&(u=!1),a&&!i.inclusiveEnd&&(a=!1),i})),l=h.map((e=>e.startKey)),d=h.map((e=>e.endKey)),m={index:e,startKeys:l,endKeys:d,inclusiveEnd:a,inclusiveStart:u,sortSatisfiedByIndex:!n&&o===e.filter((e=>!i.has(e))).join(","),selectorSatisfiedByIndex:ve(e,t.selector,l,d)},f=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},i=10,s=(0,g.Sd)(r.startKeys,(e=>e!==le&&e!==he));n(s*i);var o=(0,g.Sd)(r.startKeys,(e=>e!==he&&e!==le));n(o*i);var c=(0,g.Sd)(r.startKeys,((e,t)=>e===r.endKeys[t]));n(c*i*1.5);var u=r.sortSatisfiedByIndex?5:0;return n(u),a}(0,0,m);(f>=c||t.index)&&(c=f,s=m)})),!s)throw E("SNH",{query:t});return s}var me=new Set(["$eq","$gt","$gte","$lt","$lte"]),fe=new Set(["$eq","$gt","$gte"]),pe=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 i=[],s=new Set;for(var[o,c]of Object.entries(t)){if(!e.includes(o))return!1;var u=Object.keys(c).filter((e=>fe.has(e)));if(u.length>1)return!1;var h=u[0];if(h&&s.add(o),"$eq"!==h){if(i.length>0)return!1;i.push(h)}}var l=[],d=new Set;for(var[m,f]of Object.entries(t)){if(!e.includes(m))return!1;var p=Object.keys(f).filter((e=>pe.has(e)));if(p.length>1)return!1;var v=p[0];if(v&&d.add(m),"$eq"!==v){if(l.length>0)return!1;l.push(v)}}var y=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[y]!==a[y]&&s.size>0&&d.size>0)return!1;y++}return!0}var ye=r(744),ge=r(2779),be=r(1692),we=r(4903),De=r(7705),xe=r(2403),_e=r(6776),ke=r(6950),Ie=r(6823),Ee=!1;function Oe(e){return Ee||((0,ge.DZ)(ge.hu.PIPELINE,{$sort:we.xF,$project:we.C2}),(0,ge.DZ)(ge.hu.QUERY,{$and:De.a6,$eq:xe.XV,$elemMatch:ke.Jy,$exists:Ie.P,$gt:xe.MR,$gte:xe.fy,$in:xe.oZ,$lt:xe.NV,$lte:xe.Q_,$ne:xe.C5,$nin:xe.GU,$mod:_e.Pp,$nor:De.q3,$not:De.En,$or:De.sU,$regex:_e.WP,$size:ke.Ig,$type:Ie.T}),Ee=!0),new be.X(e)}function Re(e,t){var r=B(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.$r)(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,u=-1;e.indexes.forEach((e=>{var t=(0,g.k_)(e)?e:[e],r=t.findIndex((e=>!i.has(e)));r>0&&r>u&&(u=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 E("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 Se(e){return e===le?-1/0:e}function Pe(e,t,r){return e.includes(t)?r===he||!0===r?"1":"0":r}function $e(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 Pe(e,n,r)})).map(Se),n=t.endKeys.map(((r,a)=>{var n=t.index[a];return Pe(e,n,r)})).map(Se);return r.bound(a,n,!t.inclusiveStart,!t.inclusiveEnd)}async function Ne(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=je(e.schema,t.query));var c=$e(r.booleanIndexes,s,r.dexieDb._options.IDBKeyRange),u=s.index,h=[];if(await r.dexieDb.transaction("r",r.dexieTable,(async e=>{var t,a=e.idbtrans.objectStore(H);t="["+u.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)||h.push(n),s.sortSatisfiedByIndex&&h.length===i?e():a.continue()}else e()}}))})),!s.sortSatisfiedByIndex){var l=Ce(e.schema,t.query);h=h.sort(l)}return{documents:h=h.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 Te(e){return parseInt(e.split("-")[0],10)}function qe(e,t){var r=t?t._rev:null;return(r?Ae(r).height:0)+1+"-"+e}var Me="_rxdb_internal";async function Be(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:x.deepFreezeWhenDevMode(a),previousDocumentData:x.deepFreezeWhenDevMode(n)}}function Fe(e,t,r,a){if(a)throw 409===a.status?E("CONFLICT",{collection:e.name,id:t,writeError:a,data:r}):422===a.status?E("VD2",{collection:e.name,id:t,writeError:a,data:r}):a}function We(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=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 Ke(e){var t=s(e);return t._meta=s(e._meta),t}function Ze(e,t,r){x.deepFreezeWhenDevMode(r);var a=B(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),x.isDevMode()){i=M(a,r,i);try{"function"==typeof structuredClone?structuredClone(n):JSON.parse(JSON.stringify(n))}catch(o){throw E("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 E("SNH",{dataBefore:n.previous,dataAfter:n.document})}))}return i._meta.lwt=(0,ce.t)(),i._rev=qe(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,ue.ZN)(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:qe(e.token,t.documentInDb)})})));return e.lockedRun((()=>t.bulkWrite(s,i))).then((e=>((0,g.Hb)(a.error,e.error),(0,g.Hb)(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,ue.ZN)(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: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(3561),ze=r(703),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.X2(["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.B,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,u=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,Ue.X)(o))};var h=r.close.bind(r);r.close=async function(){return c=!0,u.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),h()};var l=r.remove.bind(r);r.remove=async function(){return c=!0,u.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),l()}}}var Ye=(0,ce.t)(),Xe=function(){function e(e,t,r,a,n,i,s){this.changes$=new oe.B,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=B(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 E("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,u=[],h=[],l=[],d={id:P(10),events:[],checkpoint:null,context:n,startTime:(0,ce.t)(),endTime:0},m=d.events,f=[],p=[],v=[],y=r.size>0,g=a.length,b=function(){var e,n=a[w],d=n.document,g=n.previous,b=d[t],D=d._deleted,x=g&&g._deleted,_=void 0;if(y&&(_=r.get(b)),_){var k=_._rev;if(!g||g&&k!==g._rev){var I={isError:!0,status:409,documentId:b,writeRow:n,documentInDb:_};return l.push(I),1}var O=c?We(n):n;c&&(D?g&&Object.keys(g._attachments).forEach((e=>{p.push({documentId:b,attachmentId:e,digest:(0,ue.ZN)(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:_,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=O.document._attachments[t].digest;r.data&&a.digest!==n&&v.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})}else f.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})})))),e?l.push(e):(c?(h.push(We(O)),s&&s(d)):(h.push(O),s&&s(d)),o=O);var R=null,C=null,j=null;if(x&&!D)j="INSERT",R=c?He(d):d;else if(!g||x||D){if(!D)throw E("SNH",{args:{writeRow:n}});j="DELETE",R=(0,ue.ZN)(d),C=g}else j="UPDATE",R=c?He(d):d,C=g;var S={documentId:b,documentData:R,previousDocumentData:C,operation:j};m.push(S)}else{var P=!!D;if(c&&Object.entries(d._attachments).forEach((t=>{let[r,a]=t;a.data?f.push({documentId:b,attachmentId:r,attachmentData:a,digest:a.digest}):(e={documentId:b,isError:!0,status:510,writeRow:n,attachmentId:r},l.push(e))})),e||(c?(u.push(We(n)),i&&i(d)):(u.push(n),i&&i(d)),o=n),!P){var $={documentId:b,operation:"INSERT",documentData:c?He(d):d,previousDocumentData:c&&g?He(g):g};m.push($)}}},w=0;w{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,ue.ZN)(r)).eventBulk.events.length>0){var s=(0,ue.ZN)(r.newestRow).document;r.eventBulk.checkpoint={id:s[this.primaryPath],lwt:s._meta.lwt},r.eventBulk.endTime=(0,ce.t)(),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),Ne(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=$e(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(H);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 Ne(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.t)()-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.B},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.cf(o,e),i={[H]:ae(n),[K]:"++sequence, id",[Z]:"id"};return t.version(1).stores(i),await t.open(),{dexieDb:t,dexieTable:t[H],dexieAttachmentsTable:t[Z],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(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.10.0",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 E("UT5",{args:{params:e}});if((t=e.schema).encrypted&&t.encrypted.length>0||t.attachments&&t.attachments.encrypted)throw E("UT6",{args:{params:e}});var t;if(e.schema.attachments&&e.schema.attachments.compression)throw E("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.k_)(e)?e:[e]))}(this.jsonSchema),this.primaryPath=B(this.jsonSchema.primaryKey),this.finalFields=W(this.jsonSchema)}var t=e.prototype;return t.validateChange=function(e,t){this.finalFields.forEach((r=>{if(!nt(e[r],t[r]))throw E("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.get$$(r)},enumerable:!1,configurable:!1}),Object.defineProperty(e,t+"_",{get:function(){return this.populate(r)},enumerable:!1,configurable:!1})})),u(this,"getDocumentPrototype",(()=>e)),e},t.getPrimaryOfDocumentData=function(e){return L(this.jsonSchema,e)},(0,b.A)(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})),u(this,"defaultValues",e)}},{key:"hash",get:function(){return u(this,"hash",this.hashFunction(JSON.stringify(this.jsonSchema)))}}]),e}();function ut(e,t,r){void 0===r&&(r=!0),r&&st("preCreateRxSchema",e);var a=Q(e);a=function(e){return o(e,!0)}(a),x.deepFreezeWhenDevMode(a);var n=new ct(a,t);return st("createRxSchema",n),n}var ht=r(7708),lt=r(8146),dt=r(3356),mt=r(5520),ft=r(8609),pt=r(1753);function vt(e){var t=e.split("-"),r="RxDB";return t.forEach((e=>{r+=$(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 yt(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,ue.ZN)(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),u=o;for(var h of a)try{u=await h.modifier(c(u))}catch(l){h.reject(l),h.reject=()=>{},h.resolve=()=>{}}try{await this.preWrite(u,o)}catch(l){return void a.forEach((e=>e.reject(l)))}e.push({previous:o,document:u})})));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=R(e);if(o){var c=i(this.queueByDocId,a,(()=>[]));s.reverse().forEach((e=>{e.lastKnownDocumentState=(0,ue.ZN)(o.documentInDb),(0,ue.ZN)(c).unshift(e)}))}else{var u=E("COL20",{name:C[(r=e).status],document:r.documentId,writeError:r});s.forEach((e=>e.reject(u)))}})),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 wt={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,ht.T)((e=>e._data._deleted)))},get deleted$$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().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,lt.p)((e=>!e.isLocal)),(0,lt.p)((e=>e.documentId===this.primary)),(0,ht.T)((e=>yt(e))),(0,dt.Z)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ht.T)((e=>this.collection._docCache.getCachedRxDocument(e))),(0,ft.t)(ue.bz))},get $$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},get$(e){if(x.isDevMode()){if(e.includes(".item."))throw E("DOC1",{path:e});if(e===this.primaryPath)throw E("DOC2");if(this.collection.schema.finalFields.includes(e))throw E("DOC3",{path:e});if(!q(this.collection.schema.jsonSchema,e))throw E("DOC4",{path:e})}return this.$.pipe((0,ht.T)((t=>v(t,e))),(0,mt.F)())},get$$(e){var t=this.get$(e);return this.collection.database.getReactivityFactory().fromObservable(t,this.getLatest().get(e))},populate(e){var t=q(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return pt.$A;if(!t)throw E("DOC5",{path:e});if(!t.ref)throw E("DOC6",{path:e,schemaObj:t});var a=this.collection.database.collections[t.ref];if(!a)throw E("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=v(this._data,e);if("object"!=typeof t||null===t||Array.isArray(t))return x.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(a.endsWith("$$")){var i=a.slice(0,-2);return r.get$$(N(e+"."+i))}if("$"===n){var s=a.slice(0,-1);return r.get$(N(e+"."+s))}if("_"===n){var o=a.slice(0,-1);return r.populate(N(e+"."+o))}return r.get(N(e+"."+a))}})}))},toJSON(e){if(void 0===e&&(e=!1),e)return x.deepFreezeWhenDevMode(this._data);var t=s(this._data);return delete t._rev,delete t._attachments,delete t._deleted,delete t._meta,x.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=s(e),this._data._deleted)throw E("DOC11",{id:this.primary,document:this});await xt(this.collection,e,t);var r=await this.collection.storageInstance.bulkWrite([{previous:t,document:e}],"rx-document-save-data"),a=r.error[0];return Fe(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(E("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 Fe(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 E("DOC14")}};function Dt(e){void 0===e&&(e=wt);var t=function(e,t){this.collection=e,this._data=t,this._propertyCache=new Map,this.isInstanceOfRxDocument=!0};return t.prototype=e,t}function xt(e,t,r){return t._meta=Object.assign({},r._meta,t._meta),x.isDevMode()&&e.schema.validateChange(r,t),e._runHooks("pre","save",t,r)}var _t=r(2198),kt=r(511),It=r(4157),Et=r(2442),Ot=r(6114);function Rt(e,t){return t.sort&&0!==t.sort.length?t.sort.map((e=>Object.keys(e)[0])):[e]}var Ct=new WeakMap;function jt(e,t){if(!e.collection.database.eventReduce)return{runFullQueryAgain:!0};var r=function(e){return i(Ct,e,(()=>{var t=e.collection,r=Re(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=Ce(t.schema.jsonSchema,r),i=je(t.schema.jsonSchema,r);return{primaryKey:e.collection.schema.primaryPath,skip:r.skip,limit:r.limit,sortFields:Rt(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,ue.ZN)(e._result).docsData.slice(0),n=(0,ue.ZN)(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:x.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,Ot.kC)(t);return"runFullQueryAgain"===i||("doNothing"!==i?(s=!0,(0,Ot.Cs)(i,r,e,a,n),!1):void 0)}))?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:s,newResults:a}}var St=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 Pt(e,t){t.uncached=!0;var r=t.toString();e._map.delete(r)}function $t(e){return e.refCount$.observers.length}var Nt,At,Tt=(Nt=100,At=3e4,(e,t)=>{if(!(t._map.size0||(0===i._lastEnsureEqual&&i._creationTimee._lastEnsureEqual-t._lastEnsureEqual)).slice(0,s).forEach((e=>Pt(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=yt(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.A)(e,[{key:"getCachedRxDocument",get:function(){return u(this,"getCachedRxDocument",function(e){var t=e.primaryPath,r=e.cacheItemByDocId,a=e.registry,n=x.deepFreezeWhenDevMode,s=e.documentCreator,o=o=>{var c=o[t],u=Te(o._rev),h=i(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),l=h.byRev,d=l.get(u),m=d?d.deref():void 0;return m||(o=n(o),m=s(o),l.set(u,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,pt.vN)().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 Bt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Qt=function(){function e(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=Bt(this.collection._docCache,t)}return(0,b.A)(e,[{key:"docsData",get:function(){return u(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)})),u(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.t)(),"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 E("QU14",{collection:this.collection,queryObj:this.mangoQuery})}if("findByIds"===this.op){var r=(0,ue.ZN)(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.Hb)(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(),u=await r.storageInstance.query(c);t=u.documents}return t}(this);return i.then((e=>(this._lastExecEnd=(0,ce.t)(),e)))},t.exec=function(e){if(e&&"findOne"!==this.op)throw E("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Zt(this).then((()=>(0,kt._)(this.$))).then((t=>{if(!t&&e)throw E("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:Re(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=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.A)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,lt.p)((e=>!e.isLocal)),(0,dt.Z)(null),(0,Et.Z)((()=>Zt(this))),(0,ht.T)((()=>this._result)),(0,ft.t)(ue.bz),(0,mt.F)(((e,t)=>!(!e||e.time!==(0,ue.ZN)(t).time))),(0,lt.p)((e=>!!e)),(0,ht.T)((e=>{var t=(0,ue.ZN)(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,It.h)(e,this.refCount$.pipe((0,lt.p)((()=>!1))))}return this._$}},{key:"$$",get:function(){return this.collection.database.getReactivityFactory().fromObservable(this.$,void 0)}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return u(this,"queryMatcher",je(0,Re(this.collection.schema.jsonSchema,this.mangoQuery)))}},{key:"asRxQuery",get:function(){return this}}]),e}();function Ht(e,t,r,a){st("preCreateRxQuery",{op:e,queryObj:t,collection:r,other:a});var n,i,s=new Wt(e,t,r,a);return s=(n=s).collection._queryCache.getByQuery(n),i=r,qt.has(i)||(qt.add(i),(0,pt.dY)().then((()=>(0,pt.Ve)(200))).then((()=>{i.destroyed||i.cacheReplacementPolicy(i,i._queryCache),qt.delete(i)}))),s}function Kt(e){var t=e.asRxQuery.collection._changeEventBuffer.counter;return e._latestChangeEvent>=t}function Zt(e){return e.collection.database.destroyed||Kt(e)?pt.Dr:(e._ensureEqualQueue=e._ensureEqualQueue.then((()=>function(e){if(e._lastEnsureEqual=(0,ce.t)(),e.collection.database.destroyed||Kt(e))return pt.Dr;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,ue.ZN)(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=jt(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 u=new Set;if(c=c.filter((e=>{var t=e.collectionName+"||"+e.schema.version;return!u.has(t)&&(u.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:x.isDevMode()});await s.remove(),t.isCollection&&await ot("postRemoveRxCollection",{storage:e,databaseName:a,collectionName:n})}))),s){var h=o.map((e=>{var t=Ke(e);return t._deleted=!0,t._meta.lwt=(0,ce.t)(),t._rev=qe(r,e),{previous:e,document:t}}));await t.bulkWrite(h,"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,lt.p)((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,wt].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,(()=>Dt(sr(e))))}(e),e,x.deepFreezeWhenDevMode(t));return e._runHooksSync("post","create",t,r),st("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 ur=["pre","post"],hr=["insert","save","remove","create"],lr=!1,dr=function(){function e(e,t,r,a,n,i,s,o,c,u,h,l){void 0===n&&(n={}),void 0===i&&(i={}),void 0===s&&(s={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===u&&(u=Tt),void 0===h&&(h={}),void 0===l&&(l=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 St,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=u,this.statics=h,this.conflictHandler=l,function(e){if(lr)return;lr=!0;var t=Object.getPrototypeOf(e);hr.forEach((e=>{ur.map((r=>{var a=r+$(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=Ze(this.database,this.internalStorageInstance,this.schema.jsonSchema),this.incrementalWriteQueue=new gt(this.storageInstance,this.schema.primaryPath,((e,t)=>xt(this,e,t)),(e=>this._runHooks("post","save",e)));var e,t=this.database.eventBulks$.pipe((0,lt.p)((e=>e.collectionName===this.name)));this.$=t.pipe((0,Et.Z)((e=>e.events))),this.checkpoint$=t.pipe((0,ht.T)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Mt(this.schema.primaryPath,this.$.pipe((0,lt.p)((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})}))}))),pt.em},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 Fe(this,e[this.schema.primaryPath],e,r),(0,ue.ZN)(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=Bt(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"),u=c.success.map((e=>e[t]));return await Promise.all(u.map((e=>this._runHooks("post","remove",i.get(e),r.get(e))))),{success:u.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 E("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,ue.ZN)(e.documentInDb),c=this._docCache.getCachedRxDocument(o),u=await c.incrementalModify((()=>a));i.push(u)}}))),{error:s,success:i}},t.upsert=async function(e){var t=await this.bulkUpsert([e]);return Fe(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 E("COL4",{data:e});var a=this._incrementalUpsertQueues.get(r);return a||(a=pt.em),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 E("COL5",{queryObj:e});return e||(e={selector:{}}),Ht("find",e,this)},t.findOne=function(e){if("number"==typeof e||Array.isArray(e))throw O("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 E("QU6");(e=s(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 O("COL7",{key:t,when:e});if(!ur.includes(e))throw O("COL8",{key:t,when:e});if(!hr.includes(t))throw E("COL9",{key:t});if("post"===e&&"create"===t&&!0===a)throw E("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 pt.em;var i=n.series.map((e=>()=>e(r,a)));return(0,pt.h$)(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?pt.Dr:(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.A)(e,[{key:"insert$",get:function(){return this.$.pipe((0,lt.p)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,lt.p)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,lt.p)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}]),e}();var mr=r(7635),fr=r(1007);var pr="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,fr.sc)(e))},vr=r(5525),yr=new Set,gr=function(){function e(e,t,r,a,n,i,s,o,c,u,h,l,d){void 0===s&&(s=!1),void 0===o&&(o={}),this.idleQueue=new mr.G,this.rxdbVersion=rt,this.storageInstances=new Set,this._subs=[],this.startupErrors=[],this.onDestroy=[],this.destroyed=!1,this.collections={},this.eventBulks$=new oe.B,this.observable$=this.eventBulks$.pipe((0,Et.Z)((e=>e.events))),this.storageToken=pt.Dr,this.storageTokenDocument=pt.Dr,this.emittedEventBulkIds=new vr.p4(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=u,this.cleanupPolicy=h,this.allowSlowCount=l,this.reactivity=d,"pseudoInstance"!==this.name&&(this.internalStore=Ze(this.asRxDatabase,c,Jt),this.storageTokenDocument=async function(e){var t=P(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:T(),_rev:"",_attachments:{}},n=await e.internalStore.bulkWrite([{document:a}],"internal-add-storage-token");if(n.success[0])return n.success[0];var i=(0,ue.ZN)(n.error[0]);if(i.isError&&R(i)){var s=i;if(c=s.documentInDb.data.rxdbVersion,u=e.rxdbVersion,!c||u.includes("beta")&&u!==c||c.split(".")[0]!==u.split(".")[0])throw E("DM5",{args:{database:e.name,databaseStateVersion:s.documentInDb.data.rxdbVersion,codeVersion:e.rxdbVersion}});if(r&&r!==s.documentInDb.data.passwordHash)throw E("DB1",{passwordHash:r,existingPasswordHash:s.documentInDb.data.passwordHash});var o=s.documentInDb;return(0,ue.ZN)(o)}var c,u;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.getReactivityFactory=function(){if(!this.reactivity)throw E("DB14",{database:this.name});return this.reactivity},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 Be(this.internalStore,Gt(tr(e,t),zt));if(!r)throw E("SNH",{name:e,schema:t});var a=Ke(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,u=o.schema;t[c]=u;var h=ut(u,this.hashFunction);if(r[c]=h,this.collections[i])throw E("DB3",{name:i});var l=tr(i,u),d={id:Gt(l,zt),key:l,context:zt,data:{name:c,schemaHash:await h.hash,schema:h.jsonSchema,version:h.version,connectedStorages:[]},_deleted:!1,_meta:T(),_rev:"",_attachments:{}};a.push({document:d});var m=Object.assign({},o,{name:c,schema:h,database:this}),f=s(o);f.database=this,f.name=i,st("preCreateRxCollection",f),m.conflictHandler=f.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 E("DB12",{database:this.name,writeError:e});var a=(0,ue.ZN)(e.documentInDb),n=a.data.name,i=r[n];if(a.data.schemaHash!==await i.hash)throw E("DB6",{database:this.name,collection:n,previousSchemaHash:a.data.schemaHash,schemaHash:await i.hash,previousSchema:a.data.schema,schema:(0,ue.ZN)(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:u={},options:h={},localDocuments:l=!1,cacheReplacementPolicy:d=Tt,conflictHandler:m=cr}=e;var f={databaseInstanceToken:t.token,databaseName:t.name,collectionName:r,schema:a.jsonSchema,options:n,multiInstance:t.multiInstance,password:t.password,devMode:x.isDevMode()};return st("preCreateRxStorageInstance",f),async function(e,t){return t.multiInstance=e.multiInstance,await e.storage.createStorageInstance(t)}(t,f).then((e=>{var f=new dr(t,r,a,e,n,i,c,u,h,d,o,m);return f.prepare().then((()=>{Object.entries(o).forEach((e=>{let[t,r]=e;Object.defineProperty(f,t,{get:()=>r.bind(f)})}));var e=pt.em;return s&&0!==f.schema.version&&(e=f.migratePromise()),e})).then((()=>(st("createRxCollection",{collection:f,creator:{name:r,schema:a,storageInstance:e,instanceCreationOptions:n,migrationStrategies:i,methods:c,attachments:u,options:h,cacheReplacementPolicy:d,localDocuments:l,statics:o}}),f))).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?pt.Dr:(this.destroyed=!0,await ot("preDestroyRxDatabase",this),this.eventBulks$.complete(),this._subs.map((e=>e.unsubscribe())),"pseudoInstance"===this.name?pt.Dr: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((()=>yr.delete(this.storage.name+"|"+this.name))).then((()=>!0)))},t.remove=function(){return this.destroy().then((()=>async function(e,t,r){var a=P(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.A)(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:Me,schema:Jt,options:a,multiInstance:n,password:i,devMode:x.isDevMode()})}function wr(e){let{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i=!0,eventReduce:s=!0,ignoreDuplicate:o=!1,options:c={},cleanupPolicy:u,allowSlowCount:h=!1,localDocuments:l=!1,hashFunction:d=pr,reactivity:m}=e;st("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:l}),o||function(e,t){var r=t.name+"|"+e;if(yr.has(r))throw E("DB8",{name:e,storage:t.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}(a,t),yr.add(t.name+"|"+a);var f=P(10);return br(f,t,a,r,i,n).catch((e=>{throw yr.delete(t.name+"|"+a),e})).then((e=>{var p=new gr(a,f,t,r,n,i,s,c,e,d,u,h,m);return ot("createRxDatabase",{database:p,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:l}}).then((()=>p))}))}var Dr={RxSchema:ct.prototype,RxDocument:wt,RxQuery:Wt.prototype,RxCollection:dr.prototype,RxDatabase:gr.prototype},xr=new Set,_r=new Set;var kr=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,w.A)(t,e),t}(Dt()),Ir={get isLocal(){return!0},get allAttachments$(){throw E("LD1",{document:this})},get primaryPath(){return"id"},get primary(){return this.id},get $(){var e=n(jr,this.parent);return this.parent.$.pipe((0,lt.p)((e=>e.documentId===this.primary)),(0,lt.p)((e=>e.isLocal)),(0,ht.T)((e=>yt(e))),(0,dt.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ht.T)((t=>e.docCache.getCachedRxDocument(t))),(0,ft.t)(ue.bz))},get $$(){var e=this;return Rr(e).getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},get deleted$$(){var e=this;return Rr(e).getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted)},getLatest(){var e=n(jr,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 O("LD2",{objPath:e});var t=v(this._data,e);return t=x.deepFreezeWhenDevMode(t)}},get$(e){if(e="data."+e,x.isDevMode()){if(e.includes(".item."))throw E("LD3",{objPath:e});if(e===this.primaryPath)throw E("LD4")}return this.$.pipe((0,ht.T)((e=>e._data)),(0,ht.T)((t=>v(t,e))),(0,mt.F)())},get$$(e){return Rr(this).getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e))},async incrementalModify(e){var t=await Pr(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 Pr(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 Pr(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)))}},Er=!1,Or=()=>{if(!Er){Er=!0;var e=wt;Object.getOwnPropertyNames(e).forEach((t=>{if(!Object.getOwnPropertyDescriptor(Ir,t)){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(Ir,t,r)}}));["populate","update","putAttachment","getAttachment","allAttachments"].forEach((e=>Ir[e]=(e=>()=>{throw E("LD6",{functionName:e})})(e)))}};function Rr(e){var t=e.parent;return t instanceof gr?t:t.database}var Cr=new WeakMap,jr=new WeakMap;function Sr(e){var t=e.database?e.database:e,r=e.database?e.name:"",a=(async()=>{var a=await $r(t.token,t.storage,t.name,r,t.instanceCreationOptions,t.multiInstance);a=Ze(t,a,qr);var n=new Mt("id",e.$.pipe((0,lt.p)((e=>e.isLocal))),(t=>function(e,t){Or();var r=new kr(e.id,e,t);return Object.setPrototypeOf(r,Ir),r.prototype=Ir,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=>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:i};return jr.set(e,c),c})();Cr.set(e,a)}function Pr(e){var t=Cr.get(e);if(!t){var r=e.database?e.database:e,a=e.database?e.name:"";throw E("LD8",{database:r.name,collection:a})}return t}function $r(e,t,r,a,n,i){return t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:Tr(a),schema:qr,options:n,multiInstance:i,devMode:x.isDevMode()})}function Nr(e){var t=Cr.get(e);if(t)return Cr.delete(e),t.then((e=>e.storageInstance.close()))}async function Ar(e,t,r){var a=P(10),n=await $r(a,e,t,r,{},!1);await n.remove()}function Tr(e){return"plugin-local-documents-"+e}var qr=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 Mr(e,t){var r=await Pr(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 Br(e,t){return this.getLocal(e).then((r=>r?r.incrementalModify((()=>t)):this.insertLocal(e,t)))}async function Lr(e){var t=await Pr(this),r=t.docCache,a=r.getLatestDocumentDataIfExists(e);return a?Promise.resolve(r.getCachedRxDocument(a)):Be(t.storageInstance,e).then((e=>e?t.docCache.getCachedRxDocument(e):null))}function Qr(e){return this.$.pipe((0,dt.Z)(null),(0,Et.Z)((async t=>t?{changeEvent:t}:{doc:await this.getLocal(e)})),(0,Et.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,lt.p)((e=>e.use)),(0,ht.T)((e=>e.doc)))}var Fr={name:"local-documents",rxdb:!0,prototypes:{RxCollection:e=>{e.insertLocal=Mr,e.upsertLocal=Br,e.getLocal=Lr,e.getLocal$=Qr},RxDatabase:e=>{e.insertLocal=Mr,e.upsertLocal=Br,e.getLocal=Lr,e.getLocal$=Qr}},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=>Ar(e.storage,e.databaseName,"")},postRemoveRxCollection:{after:e=>Ar(e.storage,e.databaseName,e.collectionName)}},overwritable:{}};let Wr;function Hr(){return"undefined"!=typeof window&&window.indexedDB}function Kr(){return Wr||(Wr=(async()=>{!function(e){if(st("preAddRxPlugin",{plugin:e,plugins:xr}),!xr.has(e)){if(_r.has(e.name))throw E("PL3",{name:e.name,plugin:e});if(xr.add(e),_r.add(e.name),!e.rxdb)throw O("PL1",{plugin:e});e.init&&e.init(),e.prototypes&&Object.entries(e.prototypes).forEach((e=>{let[t,r]=e;return r(Dr[t])})),e.overwritable&&Object.assign(x,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)}))}}(Fr);var e;return await wr({name:"rxdb-landing-v3",localDocuments:!0,storage:(void 0===e&&(e={}),new at(e))})})()),Wr}const Zr=["#e6008d","#8d2089","#5f2688"]},9891:(e,t,r)=>{r.r(t),r.d(t,{default:()=>h});var a=r(4586),n=r(1595),i=r(6540),s=r(2303),o=r(2658),c=r(4848);const u="license-opened";function h(){const{siteConfig:e}=(0,a.A)(),t=(0,s.A)();(0,i.useEffect)((()=>{t&&(0,o.IA)()&&(async()=>{const e=await(0,o.C3)();if(await e.getLocal(u))console.log("# file opening already tracked");else{const t=new URLSearchParams(window.location.search).get("v"),r=t?parseInt(t,10):300;window.trigger("premium_license_opened",Math.floor(r/3)),await e.upsertLocal(u,{})}})()}));let r="https://rxdb.pipedrive.com/documents/p/";if(t){r+=new URLSearchParams(window.location.search).get("f")}return(0,c.jsx)(n.A,{title:`Chat - ${e.title}`,description:"License Preview",children:(0,c.jsx)("main",{children:(0,c.jsxs)("div",{className:"redirectBox",style:{textAlign:"center"},children:[(0,c.jsx)("a",{href:"/",children:(0,c.jsx)("div",{className:"logo",children:(0,c.jsx)("img",{src:"/files/logo/logo_text.svg",alt:"RxDB",width:160})})}),(0,c.jsx)("h1",{children:"RxDB License Preview"}),(0,c.jsx)("p",{children:(0,c.jsx)("b",{children:"You will be redirected in a few seconds."})}),(0,c.jsx)("p",{children:(0,c.jsx)("a",{href:r,children:"Click here to open the license agreement directly."})}),(0,c.jsx)("meta",{httpEquiv:"Refresh",content:"1; url="+r})]})})})}},7810:(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;an,Hb:()=>c,S7:()=>s,Sd:()=>o,dG:()=>a,jw:()=>u,k_:()=>i})},3337:(e,t,r)=>{function a(e,t){if(!e)throw t||(t=""),new Error("ensureNotFalsy() is falsy: "+t);return e}r.d(t,{ZN:()=>a,bz:()=>n});var n={bufferSize:1,refCount:!0}},1753:(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,{$A:()=>s,Dr:()=>i,ND:()=>n,Ve:()=>h,dY:()=>a,em:()=>o,h$:()=>l,vN:()=>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 u=o;function h(e){return void 0===e&&(e=void 0),u=u.then((()=>c(e)))}function l(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},5734:(e,t,r)=>{r.d(t,{t:()=>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/main.5517924f.js b/docs/assets/js/main.5517924f.js new file mode 100644 index 00000000000..e6975b49981 --- /dev/null +++ b/docs/assets/js/main.5517924f.js @@ -0,0 +1,2 @@ +/*! For license information please see main.5517924f.js.LICENSE.txt */ +(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[8792],{8328:(e,t,n)=>{"use strict";n.d(t,{A:()=>p});n(6540);var r=n(3259),a=n.n(r),o=n(4054);const i={"0027230a":[()=>n.e(8382).then(n.bind(n,2081)),"@site/docs/rx-storage-lokijs.md",2081],"01684a0a":[()=>n.e(6616).then(n.bind(n,3395)),"@site/docs/rx-storage-memory-synced.md",3395],"03e37916":[()=>n.e(6465).then(n.bind(n,3184)),"@site/docs/transactions-conflicts-revisions.md",3184],"045bd6f5":[()=>n.e(4475).then(n.bind(n,8201)),"@site/docs/encryption.md",8201],"04b0214f":[()=>n.e(6264).then(n.t.bind(n,4061,19)),"/home/runner/work/rxdb/rxdb/docs-src/.docusaurus/docusaurus-plugin-content-pages/default/plugin-route-context-module-100.json",4061],"0e268d20":[()=>Promise.all([n.e(5106),n.e(2584)]).then(n.bind(n,5607)),"@site/src/pages/premium.tsx",5607],"0e945c41":[()=>n.e(9796).then(n.bind(n,9722)),"@site/docs/replication-server.md",9722],"0f6e10f0":[()=>n.e(1475).then(n.bind(n,654)),"@site/docs/articles/progressive-web-app-database.md",654],"118cde4c":[()=>n.e(5272).then(n.bind(n,7245)),"@site/docs/replication-couchdb.md",7245],"14d72841":[()=>n.e(9772).then(n.bind(n,5221)),"@site/src/pages/newsletter.tsx",5221],17896441:[()=>Promise.all([n.e(1869),n.e(1968),n.e(8401)]).then(n.bind(n,242)),"@theme/DocItem",242],"187b985e":[()=>n.e(6866).then(n.bind(n,844)),"@site/docs/replication-webrtc.md",844],"1b0f8c91":[()=>n.e(3129).then(n.bind(n,9642)),"@site/docs/backup.md",9642],"1b238727":[()=>n.e(4013).then(n.bind(n,3721)),"@site/docs/rx-storage-performance.md",3721],"1c0701dd":[()=>n.e(6953).then(n.bind(n,668)),"@site/docs/middleware.md",668],"1da545ff":[()=>n.e(9743).then(n.bind(n,2678)),"@site/docs/releases/9.0.0.md",2678],"1df93b7f":[()=>Promise.all([n.e(5106),n.e(4583)]).then(n.bind(n,9612)),"@site/src/pages/index.tsx",9612],"1e0353aa":[()=>n.e(8588).then(n.bind(n,142)),"@site/docs/rx-storage.md",142],"1f391b9e":[()=>Promise.all([n.e(1869),n.e(1968),n.e(6061)]).then(n.bind(n,7973)),"@theme/MDXPage",7973],"21fa2740":[()=>n.e(5694).then(n.bind(n,763)),"@site/docs/releases/15.0.0.md",763],"2456d5e0":[()=>n.e(2966).then(n.bind(n,5654)),"@site/docs/rx-database.md",5654],"25626d15":[()=>n.e(268).then(n.bind(n,7258)),"@site/src/pages/chat.tsx",7258],"2564bf4f":[()=>n.e(6724).then(n.bind(n,5705)),"@site/docs/rxdb-tradeoffs.md",5705],"25a43fd4":[()=>n.e(4812).then(n.bind(n,3917)),"@site/docs/rx-storage-shared-worker.md",3917],"26b8a621":[()=>n.e(2055).then(n.bind(n,3439)),"@site/docs/replication-p2p.md",3439],"294ac9d5":[()=>n.e(8744).then(n.bind(n,958)),"@site/docs/plugins.md",958],"2efd0200":[()=>n.e(4132).then(n.bind(n,9839)),"@site/docs/tutorials/typescript.md",9839],"32667c41":[()=>n.e(8191).then(n.bind(n,6895)),"@site/docs/nosql-performance-tips.md",6895],"326aca46":[()=>n.e(4853).then(n.bind(n,3142)),"@site/docs/offline-first.md",3142],"34f94d1b":[()=>n.e(5832).then(n.bind(n,7746)),"@site/docs/electron-database.md",7746],36715375:[()=>n.e(2076).then(n.bind(n,2323)),"@site/src/pages/code.tsx",2323],"380cc66a":[()=>n.e(2061).then(n.bind(n,5668)),"@site/docs/rx-storage-dexie.md",5668],"38bbf12a":[()=>n.e(2078).then(n.bind(n,3762)),"@site/docs/articles/data-base.md",3762],"393be207":[()=>n.e(4134).then(n.bind(n,6602)),"@site/src/pages/markdown-page.md",6602],"39600c95":[()=>n.e(3148).then(n.bind(n,755)),"@site/docs/rx-query.md",755],"401008a8":[()=>n.e(5219).then(n.bind(n,6805)),"@site/docs/nodejs-database.md",6805],"41f941a1":[()=>n.e(5966).then(n.bind(n,3057)),"@site/docs/leader-election.md",3057],"432b83f9":[()=>n.e(4424).then(n.bind(n,9429)),"@site/docs/releases/8.0.0.md",9429],"4616b86a":[()=>n.e(465).then(n.bind(n,81)),"@site/docs/rx-storage-mongodb.md",81],"4777fd9a":[()=>n.e(6386).then(n.bind(n,1600)),"@site/docs/alternatives.md",1600],"4adf80bb":[()=>n.e(9548).then(n.bind(n,4442)),"@site/docs/rx-storage-pouchdb.md",4442],"4af60d2e":[()=>n.e(8545).then(n.bind(n,9249)),"@site/docs/articles/realtime-database.md",9249],"4ba7e5a3":[()=>n.e(9591).then(n.bind(n,6467)),"@site/docs/contribute.md",6467],"4ed9495b":[()=>n.e(1199).then(n.bind(n,1787)),"@site/docs/rx-storage-sqlite.md",1787],"502d8946":[()=>n.e(7817).then(n.bind(n,732)),"@site/src/pages/legal-notice.tsx",732],51334108:[()=>n.e(8926).then(n.bind(n,2644)),"@site/docs/articles/mobile-database.md",2644],"55a5b596":[()=>n.e(6717).then(n.bind(n,5536)),"@site/docs/rx-schema.md",5536],"5a273530":[()=>n.e(3881).then(n.bind(n,7589)),"@site/docs/rx-storage-remote.md",7589],"5e95c892":[()=>n.e(9647).then(n.bind(n,7121)),"@theme/DocsRoot",7121],"5e9f5e1a":[()=>Promise.resolve().then(n.bind(n,4784)),"@generated/docusaurus.config",4784],"60c23941":[()=>n.e(2915).then(n.t.bind(n,1966,19)),"/home/runner/work/rxdb/rxdb/docs-src/.docusaurus/docusaurus-plugin-content-docs/default/plugin-route-context-module-100.json",1966],"6187b59a":[()=>n.e(5866).then(n.bind(n,7409)),"@site/docs/rx-storage-worker.md",7409],"68a466be":[()=>n.e(3997).then(n.bind(n,3923)),"@site/docs/downsides-of-offline-first.md",3923],"6ae3580c":[()=>n.e(5320).then(n.bind(n,5376)),"@site/docs/replication.md",5376],"6bfb0089":[()=>n.e(6422).then(n.bind(n,300)),"@site/docs/adapters.md",300],"6cbff7c2":[()=>n.e(7408).then(n.bind(n,5943)),"@site/docs/rx-storage-opfs.md",5943],"6fd28feb":[()=>n.e(4618).then(n.bind(n,9408)),"@site/docs/rx-storage-foundationdb.md",9408],"714575d7":[()=>n.e(3185).then(n.bind(n,4880)),"@site/docs/rx-local-document.md",4880],"77d975e6":[()=>n.e(3949).then(n.bind(n,5707)),"@site/docs/articles/in-memory-nosql-database.md",5707],"7815dd0c":[()=>n.e(5335).then(n.bind(n,5515)),"@site/docs/population.md",5515],"7f02c700":[()=>n.e(9592).then(n.bind(n,9640)),"@site/docs/replication-firestore.md",9640],"8070e160":[()=>n.e(3822).then(n.bind(n,1685)),"@site/docs/quickstart.md",1685],"8288c265":[()=>n.e(9881).then(n.bind(n,1839)),"@site/docs/releases/11.0.0.md",1839],"84a3af36":[()=>n.e(6861).then(n.bind(n,8160)),"@site/docs/articles/json-database.md",8160],"84ae55a4":[()=>n.e(588).then(n.bind(n,2045)),"@site/docs/replication-nats.md",2045],"86b4e356":[()=>n.e(2786).then(n.bind(n,9278)),"@site/docs/orm.md",9278],"8aa53ed7":[()=>n.e(6723).then(n.bind(n,5870)),"@site/docs/articles/angular-database.md",5870],"8b0a0922":[()=>n.e(4557).then(n.bind(n,767)),"@site/docs/slow-indexeddb.md",767],"8bc07e20":[()=>n.e(1850).then(n.bind(n,5054)),"@site/docs/capacitor-database.md",5054],"91b454ee":[()=>n.e(4202).then(n.bind(n,9107)),"@site/docs/rx-storage-sharding.md",9107],"924d6dd6":[()=>n.e(5122).then(n.bind(n,2414)),"@site/docs/electron.md",2414],"92698a99":[()=>n.e(4166).then(n.bind(n,8568)),"@site/docs/rx-storage-indexeddb.md",8568],"931f4566":[()=>n.e(3595).then(n.bind(n,2439)),"@site/docs/schema-validation.md",2439],"935f2afb":[()=>n.e(8581).then(n.t.bind(n,5610,19)),"~docs/default/version-current-metadata-prop-751.json",5610],98405524:[()=>n.e(5504).then(n.bind(n,1934)),"@site/src/pages/survey.tsx",1934],"9dd8ea89":[()=>n.e(1715).then(n.bind(n,7919)),"@site/docs/logger.md",7919],"9e91b6f0":[()=>n.e(3021).then(n.bind(n,1844)),"@site/docs/why-nosql.md",1844],a406dc27:[()=>n.e(1500).then(n.bind(n,8306)),"@site/docs/migration-storage.md",8306],a442adcd:[()=>n.e(8760).then(n.bind(n,188)),"@site/docs/reactivity.md",188],a574e172:[()=>n.e(7149).then(n.bind(n,9329)),"@site/docs/replication-http.md",9329],a69eebfc:[()=>n.e(9408).then(n.bind(n,4120)),"@site/docs/query-optimizer.md",4120],a7bd4aaa:[()=>n.e(7098).then(n.bind(n,4532)),"@theme/DocVersionRoot",4532],a7f10198:[()=>n.e(1098).then(n.bind(n,769)),"@site/docs/data-migration.md",769],a94703ab:[()=>Promise.all([n.e(1869),n.e(9048)]).then(n.bind(n,2559)),"@theme/DocRoot",2559],aa14e6b1:[()=>n.e(9824).then(n.bind(n,3268)),"@site/docs/replication-graphql.md",3268],ab919a1f:[()=>n.e(6491).then(n.bind(n,4760)),"@site/docs/articles/embedded-database.md",4760],ac62b32d:[()=>n.e(9192).then(n.bind(n,9585)),"@site/docs/replication-websocket.md",9585],ad16b3ea:[()=>n.e(8674).then(n.bind(n,2462)),"@site/docs/dev-mode.md",2462],b0889a22:[()=>n.e(1107).then(n.bind(n,1798)),"@site/docs/cleanup.md",1798],b30f4f1f:[()=>n.e(3779).then(n.bind(n,5830)),"@site/docs/rx-attachment.md",5830],b8c49ce4:[()=>n.e(6355).then(n.bind(n,1605)),"@site/docs/releases/13.0.0.md",1605],badcd764:[()=>n.e(8318).then(n.bind(n,6042)),"@site/docs/articles/flutter-database.md",6042],c3bc9c50:[()=>n.e(9167).then(n.bind(n,4337)),"@site/docs/articles/react-database.md",4337],c4de80f8:[()=>n.e(2777).then(n.bind(n,1173)),"@site/docs/install.md",1173],c6349bb6:[()=>n.e(5740).then(n.bind(n,2964)),"@site/docs/releases/14.0.0.md",2964],c6fdd490:[()=>n.e(4141).then(n.bind(n,5008)),"@site/docs/rx-server-scaling.md",5008],c843a053:[()=>n.e(9146).then(n.bind(n,8723)),"@site/docs/third-party-plugins.md",8723],c9c8e0b6:[()=>n.e(7249).then(n.bind(n,7674)),"@site/docs/articles/ionic-database.md",7674],cbbe8f0a:[()=>n.e(3852).then(n.bind(n,8783)),"@site/docs/rx-collection.md",8783],cde77f4f:[()=>Promise.all([n.e(5106),n.e(6287)]).then(n.bind(n,6465)),"@site/src/pages/premium-submitted.tsx",6465],d20e74b4:[()=>n.e(5123).then(n.bind(n,2853)),"@site/docs/crdt.md",2853],d2758528:[()=>n.e(2586).then(n.bind(n,7108)),"@site/docs/articles/browser-storage.md",7108],d4da9db3:[()=>n.e(1400).then(n.bind(n,4228)),"@site/docs/rx-storage-memory.md",4228],d622bd51:[()=>n.e(2845).then(n.bind(n,9804)),"@site/docs/migration-schema.md",9804],db34d6b0:[()=>Promise.all([n.e(5106),n.e(7320)]).then(n.bind(n,9891)),"@site/src/pages/license.tsx",9891],dbde2ffe:[()=>n.e(6543).then(n.bind(n,118)),"@site/docs/rx-document.md",118],dc42ba65:[()=>n.e(4962).then(n.bind(n,4494)),"@site/docs/key-compression.md",4494],e24529eb:[()=>n.e(6797).then(n.bind(n,9263)),"@site/docs/rx-storage-localstorage-meta-optimizer.md",9263],e6b4453d:[()=>n.e(2360).then(n.bind(n,9133)),"@site/docs/query-cache.md",9133],e7478ff0:[()=>n.e(5416).then(n.bind(n,1873)),"@site/docs/questions-answers.md",1873],eadd9b3c:[()=>n.e(4886).then(n.bind(n,8041)),"@site/docs/rx-storage-filesystem-node.md",8041],ebace26e:[()=>n.e(4028).then(n.bind(n,7016)),"@site/docs/releases/10.0.0.md",7016],ec526260:[()=>n.e(7396).then(n.bind(n,9592)),"@site/docs/articles/browser-database.md",9592],ed2d6610:[()=>n.e(3469).then(n.bind(n,9222)),"@site/docs/releases/12.0.0.md",9222],ee1b9f21:[()=>n.e(6998).then(n.bind(n,3179)),"@site/docs/react-native-database.md",3179],f15938da:[()=>n.e(4630).then(n.bind(n,5674)),"@site/docs/articles/localstorage.md",5674],f43e80a8:[()=>n.e(1558).then(n.bind(n,9544)),"@site/docs/rx-server.md",9544],f44bb875:[()=>n.e(561).then(n.bind(n,46)),"@site/docs/articles/frontend-database.md",46],fe7a07ee:[()=>n.e(2085).then(n.bind(n,9378)),"@site/docs/rx-storage-denokv.md",9378]};var l=n(4848);function s(e){let{error:t,retry:n,pastDelay:r}=e;return t?(0,l.jsxs)("div",{style:{textAlign:"center",color:"#fff",backgroundColor:"#fa383e",borderColor:"#fa383e",borderStyle:"solid",borderRadius:"0.25rem",borderWidth:"1px",boxSizing:"border-box",display:"block",padding:"1rem",flex:"0 0 50%",marginLeft:"25%",marginRight:"25%",marginTop:"5rem",maxWidth:"50%",width:"100%"},children:[(0,l.jsx)("p",{children:String(t)}),(0,l.jsx)("div",{children:(0,l.jsx)("button",{type:"button",onClick:n,children:"Retry"})})]}):r?(0,l.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"},children:(0,l.jsx)("svg",{id:"loader",style:{width:128,height:110,position:"absolute",top:"calc(100vh - 64%)"},viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",stroke:"#61dafb",children:(0,l.jsxs)("g",{fill:"none",fillRule:"evenodd",transform:"translate(1 1)",strokeWidth:"2",children:[(0,l.jsxs)("circle",{cx:"22",cy:"22",r:"6",strokeOpacity:"0",children:[(0,l.jsx)("animate",{attributeName:"r",begin:"1.5s",dur:"3s",values:"6;22",calcMode:"linear",repeatCount:"indefinite"}),(0,l.jsx)("animate",{attributeName:"stroke-opacity",begin:"1.5s",dur:"3s",values:"1;0",calcMode:"linear",repeatCount:"indefinite"}),(0,l.jsx)("animate",{attributeName:"stroke-width",begin:"1.5s",dur:"3s",values:"2;0",calcMode:"linear",repeatCount:"indefinite"})]}),(0,l.jsxs)("circle",{cx:"22",cy:"22",r:"6",strokeOpacity:"0",children:[(0,l.jsx)("animate",{attributeName:"r",begin:"3s",dur:"3s",values:"6;22",calcMode:"linear",repeatCount:"indefinite"}),(0,l.jsx)("animate",{attributeName:"stroke-opacity",begin:"3s",dur:"3s",values:"1;0",calcMode:"linear",repeatCount:"indefinite"}),(0,l.jsx)("animate",{attributeName:"stroke-width",begin:"3s",dur:"3s",values:"2;0",calcMode:"linear",repeatCount:"indefinite"})]}),(0,l.jsx)("circle",{cx:"22",cy:"22",r:"8",children:(0,l.jsx)("animate",{attributeName:"r",begin:"0s",dur:"1.5s",values:"6;1;2;3;4;5;6",calcMode:"linear",repeatCount:"indefinite"})})]})})}):null}var c=n(6921),u=n(3102);function d(e,t){if("*"===e)return a()({loading:s,loader:()=>n.e(9293).then(n.bind(n,9293)),modules:["@theme/NotFound"],webpack:()=>[9293],render(e,t){const n=e.default;return(0,l.jsx)(u.W,{value:{plugin:{name:"native",id:"default"}},children:(0,l.jsx)(n,{...t})})}});const r=o[`${e}-${t}`],d={},p=[],f=[],m=(0,c.A)(r);return Object.entries(m).forEach((e=>{let[t,n]=e;const r=i[n];r&&(d[t]=r[0],p.push(r[1]),f.push(r[2]))})),a().Map({loading:s,loader:d,modules:p,webpack:()=>f,render(t,n){const a=JSON.parse(JSON.stringify(r));Object.entries(t).forEach((t=>{let[n,r]=t;const o=r.default;if(!o)throw new Error(`The page component at ${e} doesn't have a default export. This makes it impossible to render anything. Consider default-exporting a React component.`);"object"!=typeof o&&"function"!=typeof o||Object.keys(r).filter((e=>"default"!==e)).forEach((e=>{o[e]=r[e]}));let i=a;const l=n.split(".");l.slice(0,-1).forEach((e=>{i=i[e]})),i[l[l.length-1]]=o}));const o=a.__comp;delete a.__comp;const i=a.__context;return delete a.__context,(0,l.jsx)(u.W,{value:i,children:(0,l.jsx)(o,{...a,...n})})}})}const p=[{path:"/chat",component:d("/chat","fd7"),exact:!0},{path:"/code",component:d("/code","8ef"),exact:!0},{path:"/legal-notice",component:d("/legal-notice","cfc"),exact:!0},{path:"/license",component:d("/license","d06"),exact:!0},{path:"/markdown-page",component:d("/markdown-page","784"),exact:!0},{path:"/newsletter",component:d("/newsletter","d15"),exact:!0},{path:"/premium",component:d("/premium","d94"),exact:!0},{path:"/premium-submitted",component:d("/premium-submitted","714"),exact:!0},{path:"/survey",component:d("/survey","9e0"),exact:!0},{path:"/",component:d("/","d82"),exact:!0},{path:"/",component:d("/","734"),routes:[{path:"/",component:d("/","494"),routes:[{path:"/",component:d("/","780"),routes:[{path:"/adapters.html",component:d("/adapters.html","fb4"),exact:!0},{path:"/alternatives.html",component:d("/alternatives.html","d53"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/angular-database.html",component:d("/articles/angular-database.html","e30"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/browser-database.html",component:d("/articles/browser-database.html","b0a"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/browser-storage.html",component:d("/articles/browser-storage.html","286"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/data-base.html",component:d("/articles/data-base.html","797"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/embedded-database.html",component:d("/articles/embedded-database.html","596"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/flutter-database.html",component:d("/articles/flutter-database.html","f8a"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/frontend-database.html",component:d("/articles/frontend-database.html","a83"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/in-memory-nosql-database.html",component:d("/articles/in-memory-nosql-database.html","ead"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/ionic-database.html",component:d("/articles/ionic-database.html","df6"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/json-database.html",component:d("/articles/json-database.html","bff"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/localstorage.html",component:d("/articles/localstorage.html","b1b"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/mobile-database.html",component:d("/articles/mobile-database.html","1d7"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/progressive-web-app-database.html",component:d("/articles/progressive-web-app-database.html","862"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/react-database.html",component:d("/articles/react-database.html","179"),exact:!0,sidebar:"tutorialSidebar"},{path:"/articles/realtime-database.html",component:d("/articles/realtime-database.html","bc3"),exact:!0,sidebar:"tutorialSidebar"},{path:"/backup.html",component:d("/backup.html","123"),exact:!0,sidebar:"tutorialSidebar"},{path:"/capacitor-database.html",component:d("/capacitor-database.html","71f"),exact:!0,sidebar:"tutorialSidebar"},{path:"/cleanup.html",component:d("/cleanup.html","d7f"),exact:!0,sidebar:"tutorialSidebar"},{path:"/contribution.html",component:d("/contribution.html","129"),exact:!0,sidebar:"tutorialSidebar"},{path:"/crdt.html",component:d("/crdt.html","c69"),exact:!0,sidebar:"tutorialSidebar"},{path:"/data-migration",component:d("/data-migration","7c7"),exact:!0},{path:"/dev-mode.html",component:d("/dev-mode.html","11d"),exact:!0,sidebar:"tutorialSidebar"},{path:"/downsides-of-offline-first.html",component:d("/downsides-of-offline-first.html","ba4"),exact:!0,sidebar:"tutorialSidebar"},{path:"/electron-database.html",component:d("/electron-database.html","44e"),exact:!0,sidebar:"tutorialSidebar"},{path:"/electron.html",component:d("/electron.html","693"),exact:!0,sidebar:"tutorialSidebar"},{path:"/encryption.html",component:d("/encryption.html","265"),exact:!0,sidebar:"tutorialSidebar"},{path:"/install.html",component:d("/install.html","9ec"),exact:!0,sidebar:"tutorialSidebar"},{path:"/key-compression.html",component:d("/key-compression.html","171"),exact:!0,sidebar:"tutorialSidebar"},{path:"/leader-election.html",component:d("/leader-election.html","9aa"),exact:!0,sidebar:"tutorialSidebar"},{path:"/logger.html",component:d("/logger.html","949"),exact:!0,sidebar:"tutorialSidebar"},{path:"/middleware.html",component:d("/middleware.html","34f"),exact:!0,sidebar:"tutorialSidebar"},{path:"/migration-schema.html",component:d("/migration-schema.html","618"),exact:!0,sidebar:"tutorialSidebar"},{path:"/migration-storage.html",component:d("/migration-storage.html","34a"),exact:!0,sidebar:"tutorialSidebar"},{path:"/nodejs-database.html",component:d("/nodejs-database.html","6a2"),exact:!0,sidebar:"tutorialSidebar"},{path:"/nosql-performance-tips.html",component:d("/nosql-performance-tips.html","fd8"),exact:!0,sidebar:"tutorialSidebar"},{path:"/offline-first.html",component:d("/offline-first.html","e1b"),exact:!0,sidebar:"tutorialSidebar"},{path:"/orm.html",component:d("/orm.html","798"),exact:!0,sidebar:"tutorialSidebar"},{path:"/plugins.html",component:d("/plugins.html","f25"),exact:!0,sidebar:"tutorialSidebar"},{path:"/population.html",component:d("/population.html","b89"),exact:!0,sidebar:"tutorialSidebar"},{path:"/query-cache.html",component:d("/query-cache.html","45f"),exact:!0,sidebar:"tutorialSidebar"},{path:"/query-optimizer.html",component:d("/query-optimizer.html","bd3"),exact:!0,sidebar:"tutorialSidebar"},{path:"/questions-answers.html",component:d("/questions-answers.html","840"),exact:!0,sidebar:"tutorialSidebar"},{path:"/quickstart.html",component:d("/quickstart.html","417"),exact:!0,sidebar:"tutorialSidebar"},{path:"/react-native-database.html",component:d("/react-native-database.html","7b4"),exact:!0,sidebar:"tutorialSidebar"},{path:"/reactivity.html",component:d("/reactivity.html","4d4"),exact:!0,sidebar:"tutorialSidebar"},{path:"/releases/10.0.0.html",component:d("/releases/10.0.0.html","8ce"),exact:!0,sidebar:"tutorialSidebar"},{path:"/releases/11.0.0.html",component:d("/releases/11.0.0.html","712"),exact:!0,sidebar:"tutorialSidebar"},{path:"/releases/12.0.0.html",component:d("/releases/12.0.0.html","a36"),exact:!0,sidebar:"tutorialSidebar"},{path:"/releases/13.0.0.html",component:d("/releases/13.0.0.html","605"),exact:!0,sidebar:"tutorialSidebar"},{path:"/releases/14.0.0.html",component:d("/releases/14.0.0.html","14c"),exact:!0,sidebar:"tutorialSidebar"},{path:"/releases/15.0.0.html",component:d("/releases/15.0.0.html","4dd"),exact:!0,sidebar:"tutorialSidebar"},{path:"/releases/8.0.0.html",component:d("/releases/8.0.0.html","fdc"),exact:!0,sidebar:"tutorialSidebar"},{path:"/releases/9.0.0.html",component:d("/releases/9.0.0.html","f4b"),exact:!0,sidebar:"tutorialSidebar"},{path:"/replication-couchdb.html",component:d("/replication-couchdb.html","6d5"),exact:!0,sidebar:"tutorialSidebar"},{path:"/replication-firestore.html",component:d("/replication-firestore.html","bcb"),exact:!0,sidebar:"tutorialSidebar"},{path:"/replication-graphql.html",component:d("/replication-graphql.html","a6c"),exact:!0,sidebar:"tutorialSidebar"},{path:"/replication-http.html",component:d("/replication-http.html","16a"),exact:!0,sidebar:"tutorialSidebar"},{path:"/replication-nats.html",component:d("/replication-nats.html","ac4"),exact:!0,sidebar:"tutorialSidebar"},{path:"/replication-p2p.html",component:d("/replication-p2p.html","ec6"),exact:!0},{path:"/replication-server",component:d("/replication-server","aa6"),exact:!0,sidebar:"tutorialSidebar"},{path:"/replication-webrtc.html",component:d("/replication-webrtc.html","ff6"),exact:!0,sidebar:"tutorialSidebar"},{path:"/replication-websocket.html",component:d("/replication-websocket.html","4f9"),exact:!0,sidebar:"tutorialSidebar"},{path:"/replication.html",component:d("/replication.html","62b"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-attachment.html",component:d("/rx-attachment.html","7d7"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-collection.html",component:d("/rx-collection.html","7dc"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-database.html",component:d("/rx-database.html","e4e"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-document.html",component:d("/rx-document.html","e09"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-local-document.html",component:d("/rx-local-document.html","0db"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-query.html",component:d("/rx-query.html","2cf"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-schema.html",component:d("/rx-schema.html","671"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-server-scaling.html",component:d("/rx-server-scaling.html","da1"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-server.html",component:d("/rx-server.html","ed5"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-denokv.html",component:d("/rx-storage-denokv.html","b6e"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-dexie.html",component:d("/rx-storage-dexie.html","bb3"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-filesystem-node.html",component:d("/rx-storage-filesystem-node.html","a57"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-foundationdb.html",component:d("/rx-storage-foundationdb.html","3c8"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-indexeddb.html",component:d("/rx-storage-indexeddb.html","631"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-localstorage-meta-optimizer.html",component:d("/rx-storage-localstorage-meta-optimizer.html","064"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-lokijs.html",component:d("/rx-storage-lokijs.html","1be"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-memory-synced.html",component:d("/rx-storage-memory-synced.html","65f"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-memory.html",component:d("/rx-storage-memory.html","c21"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-mongodb.html",component:d("/rx-storage-mongodb.html","5ad"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-opfs.html",component:d("/rx-storage-opfs.html","6f7"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-performance.html",component:d("/rx-storage-performance.html","b12"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-pouchdb.html",component:d("/rx-storage-pouchdb.html","d82"),exact:!0},{path:"/rx-storage-remote.html",component:d("/rx-storage-remote.html","5df"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-sharding.html",component:d("/rx-storage-sharding.html","b30"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-shared-worker.html",component:d("/rx-storage-shared-worker.html","0f4"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-sqlite.html",component:d("/rx-storage-sqlite.html","ad7"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage-worker.html",component:d("/rx-storage-worker.html","a4e"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rx-storage.html",component:d("/rx-storage.html","144"),exact:!0,sidebar:"tutorialSidebar"},{path:"/rxdb-tradeoffs.html",component:d("/rxdb-tradeoffs.html","5cb"),exact:!0},{path:"/schema-validation.html",component:d("/schema-validation.html","3f1"),exact:!0},{path:"/slow-indexeddb.html",component:d("/slow-indexeddb.html","a40"),exact:!0,sidebar:"tutorialSidebar"},{path:"/third-party-plugins.html",component:d("/third-party-plugins.html","549"),exact:!0,sidebar:"tutorialSidebar"},{path:"/transactions-conflicts-revisions.html",component:d("/transactions-conflicts-revisions.html","53a"),exact:!0,sidebar:"tutorialSidebar"},{path:"/tutorials/typescript.html",component:d("/tutorials/typescript.html","a33"),exact:!0,sidebar:"tutorialSidebar"},{path:"/why-nosql.html",component:d("/why-nosql.html","ad0"),exact:!0,sidebar:"tutorialSidebar"}]}]}]},{path:"*",component:d("*")}]},6125:(e,t,n)=>{"use strict";n.d(t,{o:()=>o,x:()=>i});var r=n(6540),a=n(4848);const o=r.createContext(!1);function i(e){let{children:t}=e;const[n,i]=(0,r.useState)(!1);return(0,r.useEffect)((()=>{i(!0)}),[]),(0,a.jsx)(o.Provider,{value:n,children:t})}},8522:(e,t,n)=>{"use strict";var r=n(6540),a=n(5338),o=n(4625),i=n(545),l=n(8193);const s=[n(1911),n(119),n(6134),n(6294),n(1043)];var c=n(8328),u=n(6347),d=n(2831),p=n(2303),f=n(4848);function m(e){let{children:t}=e;const n=(0,p.A)();return(0,r.useEffect)((()=>{n&&(function(){const e="fixed-chat-button";if(document.getElementById(e))return;const t=document.createElement("a");t.id=e,t.href="/chat",t.target="_blank",t.innerHTML="\ud83d\udcac Community Chat";const n=document.createElement("style");n.type="text/css",n.innerText="#"+e+" {color: white;position: fixed;right: 0;bottom: 0;background-color: var(--color-top);padding-left: 17px;padding-right: 17px;padding-top: 10px;padding-bottom: 5px;text-align: center;margin-right: 50px;font-weight: bold;border-top-left-radius: 9px;border-top-right-radius: 9px;z-index: 11;}#fixed-chat-button:hover {box-shadow: 2px 2px 13px #ca007c, -2px -1px 14px #ff009e;text-decoration: underline;}",document.head.appendChild(n),document.body.appendChild(t)}(),function(){if("/"===location.pathname)return;const e=[{text:"Follow",keyword:"@twitter",url:"https://twitter.com/intent/user?screen_name=rxdbjs",icon:"\ud83d\udc26"},{text:"Follow",keyword:"@LinkedIn",url:"https://www.linkedin.com/company/rxdb",icon:"[in]"},{text:"Chat",keyword:"@discord",url:"https://rxdb.info/chat",icon:"\ud83d\udcac"},{text:"Star",keyword:"@github",url:"https://rxdb.info/code",icon:"\ud83d\udc19\ud83d\udcbb"},{text:"Subscribe",keyword:"@newsletter",url:"https://rxdb.info/newsletter",icon:"\ud83d\udcf0"}];function t(e,t){e.parentNode.insertBefore(t,e.nextSibling)}const n="rxdb-call-to-action-button";function r(){console.log("set call to action button");const r=6e5,a=Date.now(),o=(a-a%r)/r;console.log("timeslot "+o);const i=o%e.length;console.log("randid: "+i);const l=e[i],s=document.querySelector(".call-to-action");s&&s.parentNode.removeChild(s);const c=document.querySelector(".navbar__items");if(!c)return;const u=document.createElement("div");u.classList.add("call-to-action");const d=document.createElement("a");d.onclick=()=>{window.trigger("call-to-action",.35)},d.classList.add("hover-shadow-top"),d.id=n,d.innerHTML=l.text+' '+l.keyword+''+l.icon+"",d.href=l.url,d.target="_blank",u.append(d),t(c,u)}r()}())})),(0,f.jsx)(f.Fragment,{children:t})}var h=n(5260),g=n(4586),b=n(6025),y=n(6342),v=n(1003),w=n(2131),x=n(4090),k=n(2967),S=n(440),E=n(1463);function _(){const{i18n:{currentLocale:e,defaultLocale:t,localeConfigs:n}}=(0,g.A)(),r=(0,w.o)(),a=n[e].htmlLang,o=e=>e.replace("-","_");return(0,f.jsxs)(h.A,{children:[Object.entries(n).map((e=>{let[t,{htmlLang:n}]=e;return(0,f.jsx)("link",{rel:"alternate",href:r.createUrl({locale:t,fullyQualified:!0}),hrefLang:n},t)})),(0,f.jsx)("link",{rel:"alternate",href:r.createUrl({locale:t,fullyQualified:!0}),hrefLang:"x-default"}),(0,f.jsx)("meta",{property:"og:locale",content:o(a)}),Object.values(n).filter((e=>a!==e.htmlLang)).map((e=>(0,f.jsx)("meta",{property:"og:locale:alternate",content:o(e.htmlLang)},`meta-og-${e.htmlLang}`)))]})}function C(e){let{permalink:t}=e;const{siteConfig:{url:n}}=(0,g.A)(),r=function(){const{siteConfig:{url:e,baseUrl:t,trailingSlash:n}}=(0,g.A)(),{pathname:r}=(0,u.zy)();return e+(0,S.applyTrailingSlash)((0,b.A)(r),{trailingSlash:n,baseUrl:t})}(),a=t?`${n}${t}`:r;return(0,f.jsxs)(h.A,{children:[(0,f.jsx)("meta",{property:"og:url",content:a}),(0,f.jsx)("link",{rel:"canonical",href:a})]})}function T(){const{i18n:{currentLocale:e}}=(0,g.A)(),{metadata:t,image:n}=(0,y.p)();return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(h.A,{children:[(0,f.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),(0,f.jsx)("body",{className:x.w})]}),n&&(0,f.jsx)(v.be,{image:n}),(0,f.jsx)(C,{}),(0,f.jsx)(_,{}),(0,f.jsx)(E.A,{tag:k.Cy,locale:e}),(0,f.jsx)(h.A,{children:t.map(((e,t)=>(0,f.jsx)("meta",{...e},t)))})]})}const A=new Map;function j(e){if(A.has(e.pathname))return{...e,pathname:A.get(e.pathname)};if((0,d.u)(c.A,e.pathname).some((e=>{let{route:t}=e;return!0===t.exact})))return A.set(e.pathname,e.pathname),e;const t=e.pathname.trim().replace(/(?:\/index)?\.html$/,"")||"/";return A.set(e.pathname,t),{...e,pathname:t}}var N=n(6125),R=n(6988),L=n(205);function P(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{const r=t.default?.[e]??t[e];return r?.(...n)}));return()=>a.forEach((e=>e?.()))}const O=function(e){let{children:t,location:n,previousLocation:r}=e;return(0,L.A)((()=>{r!==n&&(!function(e){let{location:t,previousLocation:n}=e;if(!n)return;const r=t.pathname===n.pathname,a=t.hash===n.hash,o=t.search===n.search;if(r&&a&&!o)return;const{hash:i}=t;if(i){const e=decodeURIComponent(i.substring(1)),t=document.getElementById(e);t?.scrollIntoView()}else window.scrollTo(0,0)}({location:n,previousLocation:r}),P("onRouteDidUpdate",{previousLocation:r,location:n}))}),[r,n]),t};function I(e){const t=Array.from(new Set([e,decodeURI(e)])).map((e=>(0,d.u)(c.A,e))).flat();return Promise.all(t.map((e=>e.route.component.preload?.())))}class D extends r.Component{previousLocation;routeUpdateCleanupCb;constructor(e){super(e),this.previousLocation=null,this.routeUpdateCleanupCb=l.A.canUseDOM?P("onRouteUpdate",{previousLocation:null,location:this.props.location}):()=>{},this.state={nextRouteHasLoaded:!0}}shouldComponentUpdate(e,t){if(e.location===this.props.location)return t.nextRouteHasLoaded;const n=e.location;return this.previousLocation=this.props.location,this.setState({nextRouteHasLoaded:!1}),this.routeUpdateCleanupCb=P("onRouteUpdate",{previousLocation:this.previousLocation,location:n}),I(n.pathname).then((()=>{this.routeUpdateCleanupCb(),this.setState({nextRouteHasLoaded:!0})})).catch((e=>{console.warn(e),window.location.reload()})),!1}render(){const{children:e,location:t}=this.props;return(0,f.jsx)(O,{previousLocation:this.previousLocation,location:t,children:(0,f.jsx)(u.qh,{location:t,render:()=>e})})}}const M=D,F="__docusaurus-base-url-issue-banner-container",z="__docusaurus-base-url-issue-banner",B="__docusaurus-base-url-issue-banner-suggestion-container";function $(e){return`\ndocument.addEventListener('DOMContentLoaded', function maybeInsertBanner() {\n var shouldInsert = typeof window['docusaurus'] === 'undefined';\n shouldInsert && insertBanner();\n});\n\nfunction insertBanner() {\n var bannerContainer = document.createElement('div');\n bannerContainer.id = '${F}';\n var bannerHtml = ${JSON.stringify(function(e){return`\n
\n

Your Docusaurus site did not load properly.

\n

A very common reason is a wrong site baseUrl configuration.

\n

Current configured baseUrl = ${e} ${"/"===e?" (default value)":""}

\n

We suggest trying baseUrl =

\n
\n`}(e)).replace(/{if("undefined"==typeof document)return void n();const r=document.createElement("link");r.setAttribute("rel","prefetch"),r.setAttribute("href",e),r.onload=()=>t(),r.onerror=()=>n();const a=document.getElementsByTagName("head")[0]??document.getElementsByName("script")[0]?.parentNode;a?.appendChild(r)}))}:function(e){return new Promise(((t,n)=>{const r=new XMLHttpRequest;r.open("GET",e,!0),r.withCredentials=!0,r.onload=()=>{200===r.status?t():n()},r.send(null)}))};var Y=n(6921);const J=new Set,Z=new Set,X=()=>navigator.connection?.effectiveType.includes("2g")||navigator.connection?.saveData,ee={prefetch(e){if(!(e=>!X()&&!Z.has(e)&&!J.has(e))(e))return!1;J.add(e);const t=(0,d.u)(c.A,e).flatMap((e=>{return t=e.route.path,Object.entries(Q).filter((e=>{let[n]=e;return n.replace(/-[^-]+$/,"")===t})).flatMap((e=>{let[,t]=e;return Object.values((0,Y.A)(t))}));var t}));return Promise.all(t.map((e=>{const t=n.gca(e);return t&&!t.includes("undefined")?K(t).catch((()=>{})):Promise.resolve()})))},preload:e=>!!(e=>!X()&&!Z.has(e))(e)&&(Z.add(e),I(e))},te=Object.freeze(ee),ne=Boolean(!0);if(l.A.canUseDOM){window.docusaurus=te;const e=document.getElementById("__docusaurus"),t=(0,f.jsx)(i.vd,{children:(0,f.jsx)(o.Kd,{children:(0,f.jsx)(V,{})})}),n=(e,t)=>{console.error("Docusaurus React Root onRecoverableError:",e,t)},l=()=>{if(ne)r.startTransition((()=>{a.hydrateRoot(e,t,{onRecoverableError:n})}));else{const o=a.createRoot(e,{onRecoverableError:n});r.startTransition((()=>{o.render(t)}))}};I(window.location.pathname).then(l)}},6988:(e,t,n)=>{"use strict";n.d(t,{o:()=>d,l:()=>p});var r=n(6540),a=n(4784);const o=JSON.parse('{"docusaurus-plugin-google-gtag":{"default":{"trackingID":["G-62D63SY3S0"],"anonymizeIP":false,"id":"default"}},"docusaurus-lunr-search":{"default":{"fileNames":{"searchDoc":"search-doc-1709075253588.json","lunrIndex":"lunr-index-1709075253588.json"}}},"docusaurus-plugin-content-docs":{"default":{"path":"/","versions":[{"name":"current","label":"Next","isLast":true,"path":"/","mainDocId":"quickstart","docs":[{"id":"adapters","path":"/adapters.html"},{"id":"alternatives","path":"/alternatives.html","sidebar":"tutorialSidebar"},{"id":"articles/angular-database","path":"/articles/angular-database.html","sidebar":"tutorialSidebar"},{"id":"articles/browser-database","path":"/articles/browser-database.html","sidebar":"tutorialSidebar"},{"id":"articles/browser-storage","path":"/articles/browser-storage.html","sidebar":"tutorialSidebar"},{"id":"articles/data-base","path":"/articles/data-base.html","sidebar":"tutorialSidebar"},{"id":"articles/embedded-database","path":"/articles/embedded-database.html","sidebar":"tutorialSidebar"},{"id":"articles/flutter-database","path":"/articles/flutter-database.html","sidebar":"tutorialSidebar"},{"id":"articles/frontend-database","path":"/articles/frontend-database.html","sidebar":"tutorialSidebar"},{"id":"articles/in-memory-nosql-database","path":"/articles/in-memory-nosql-database.html","sidebar":"tutorialSidebar"},{"id":"articles/ionic-database","path":"/articles/ionic-database.html","sidebar":"tutorialSidebar"},{"id":"articles/json-database","path":"/articles/json-database.html","sidebar":"tutorialSidebar"},{"id":"articles/localstorage","path":"/articles/localstorage.html","sidebar":"tutorialSidebar"},{"id":"articles/mobile-database","path":"/articles/mobile-database.html","sidebar":"tutorialSidebar"},{"id":"articles/progressive-web-app-database","path":"/articles/progressive-web-app-database.html","sidebar":"tutorialSidebar"},{"id":"articles/react-database","path":"/articles/react-database.html","sidebar":"tutorialSidebar"},{"id":"articles/realtime-database","path":"/articles/realtime-database.html","sidebar":"tutorialSidebar"},{"id":"backup","path":"/backup.html","sidebar":"tutorialSidebar"},{"id":"capacitor-database","path":"/capacitor-database.html","sidebar":"tutorialSidebar"},{"id":"cleanup","path":"/cleanup.html","sidebar":"tutorialSidebar"},{"id":"contribute","path":"/contribution.html","sidebar":"tutorialSidebar"},{"id":"crdt","path":"/crdt.html","sidebar":"tutorialSidebar"},{"id":"data-migration","path":"/data-migration"},{"id":"dev-mode","path":"/dev-mode.html","sidebar":"tutorialSidebar"},{"id":"downsides-of-offline-first","path":"/downsides-of-offline-first.html","sidebar":"tutorialSidebar"},{"id":"electron","path":"/electron.html","sidebar":"tutorialSidebar"},{"id":"electron-database","path":"/electron-database.html","sidebar":"tutorialSidebar"},{"id":"encryption","path":"/encryption.html","sidebar":"tutorialSidebar"},{"id":"install","path":"/install.html","sidebar":"tutorialSidebar"},{"id":"key-compression","path":"/key-compression.html","sidebar":"tutorialSidebar"},{"id":"leader-election","path":"/leader-election.html","sidebar":"tutorialSidebar"},{"id":"logger","path":"/logger.html","sidebar":"tutorialSidebar"},{"id":"middleware","path":"/middleware.html","sidebar":"tutorialSidebar"},{"id":"migration-schema","path":"/migration-schema.html","sidebar":"tutorialSidebar"},{"id":"migration-storage","path":"/migration-storage.html","sidebar":"tutorialSidebar"},{"id":"nodejs-database","path":"/nodejs-database.html","sidebar":"tutorialSidebar"},{"id":"nosql-performance-tips","path":"/nosql-performance-tips.html","sidebar":"tutorialSidebar"},{"id":"offline-first","path":"/offline-first.html","sidebar":"tutorialSidebar"},{"id":"orm","path":"/orm.html","sidebar":"tutorialSidebar"},{"id":"plugins","path":"/plugins.html","sidebar":"tutorialSidebar"},{"id":"population","path":"/population.html","sidebar":"tutorialSidebar"},{"id":"query-cache","path":"/query-cache.html","sidebar":"tutorialSidebar"},{"id":"query-optimizer","path":"/query-optimizer.html","sidebar":"tutorialSidebar"},{"id":"questions-answers","path":"/questions-answers.html","sidebar":"tutorialSidebar"},{"id":"quickstart","path":"/quickstart.html","sidebar":"tutorialSidebar"},{"id":"react-native-database","path":"/react-native-database.html","sidebar":"tutorialSidebar"},{"id":"reactivity","path":"/reactivity.html","sidebar":"tutorialSidebar"},{"id":"releases/10.0.0","path":"/releases/10.0.0.html","sidebar":"tutorialSidebar"},{"id":"releases/11.0.0","path":"/releases/11.0.0.html","sidebar":"tutorialSidebar"},{"id":"releases/12.0.0","path":"/releases/12.0.0.html","sidebar":"tutorialSidebar"},{"id":"releases/13.0.0","path":"/releases/13.0.0.html","sidebar":"tutorialSidebar"},{"id":"releases/14.0.0","path":"/releases/14.0.0.html","sidebar":"tutorialSidebar"},{"id":"releases/15.0.0","path":"/releases/15.0.0.html","sidebar":"tutorialSidebar"},{"id":"releases/8.0.0","path":"/releases/8.0.0.html","sidebar":"tutorialSidebar"},{"id":"releases/9.0.0","path":"/releases/9.0.0.html","sidebar":"tutorialSidebar"},{"id":"replication","path":"/replication.html","sidebar":"tutorialSidebar"},{"id":"replication-couchdb","path":"/replication-couchdb.html","sidebar":"tutorialSidebar"},{"id":"replication-firestore","path":"/replication-firestore.html","sidebar":"tutorialSidebar"},{"id":"replication-graphql","path":"/replication-graphql.html","sidebar":"tutorialSidebar"},{"id":"replication-http","path":"/replication-http.html","sidebar":"tutorialSidebar"},{"id":"replication-nats","path":"/replication-nats.html","sidebar":"tutorialSidebar"},{"id":"replication-p2p","path":"/replication-p2p.html"},{"id":"replication-server","path":"/replication-server","sidebar":"tutorialSidebar"},{"id":"replication-webrtc","path":"/replication-webrtc.html","sidebar":"tutorialSidebar"},{"id":"replication-websocket","path":"/replication-websocket.html","sidebar":"tutorialSidebar"},{"id":"rx-attachment","path":"/rx-attachment.html","sidebar":"tutorialSidebar"},{"id":"rx-collection","path":"/rx-collection.html","sidebar":"tutorialSidebar"},{"id":"rx-database","path":"/rx-database.html","sidebar":"tutorialSidebar"},{"id":"rx-document","path":"/rx-document.html","sidebar":"tutorialSidebar"},{"id":"rx-local-document","path":"/rx-local-document.html","sidebar":"tutorialSidebar"},{"id":"rx-query","path":"/rx-query.html","sidebar":"tutorialSidebar"},{"id":"rx-schema","path":"/rx-schema.html","sidebar":"tutorialSidebar"},{"id":"rx-server","path":"/rx-server.html","sidebar":"tutorialSidebar"},{"id":"rx-server-scaling","path":"/rx-server-scaling.html","sidebar":"tutorialSidebar"},{"id":"rx-storage","path":"/rx-storage.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-denokv","path":"/rx-storage-denokv.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-dexie","path":"/rx-storage-dexie.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-filesystem-node","path":"/rx-storage-filesystem-node.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-foundationdb","path":"/rx-storage-foundationdb.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-indexeddb","path":"/rx-storage-indexeddb.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-localstorage-meta-optimizer","path":"/rx-storage-localstorage-meta-optimizer.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-lokijs","path":"/rx-storage-lokijs.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-memory","path":"/rx-storage-memory.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-memory-synced","path":"/rx-storage-memory-synced.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-mongodb","path":"/rx-storage-mongodb.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-opfs","path":"/rx-storage-opfs.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-performance","path":"/rx-storage-performance.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-pouchdb","path":"/rx-storage-pouchdb.html"},{"id":"rx-storage-remote","path":"/rx-storage-remote.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-sharding","path":"/rx-storage-sharding.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-shared-worker","path":"/rx-storage-shared-worker.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-sqlite","path":"/rx-storage-sqlite.html","sidebar":"tutorialSidebar"},{"id":"rx-storage-worker","path":"/rx-storage-worker.html","sidebar":"tutorialSidebar"},{"id":"rxdb-tradeoffs","path":"/rxdb-tradeoffs.html"},{"id":"schema-validation","path":"/schema-validation.html"},{"id":"slow-indexeddb","path":"/slow-indexeddb.html","sidebar":"tutorialSidebar"},{"id":"third-party-plugins","path":"/third-party-plugins.html","sidebar":"tutorialSidebar"},{"id":"transactions-conflicts-revisions","path":"/transactions-conflicts-revisions.html","sidebar":"tutorialSidebar"},{"id":"tutorials/typescript","path":"/tutorials/typescript.html","sidebar":"tutorialSidebar"},{"id":"why-nosql","path":"/why-nosql.html","sidebar":"tutorialSidebar"}],"draftIds":[],"sidebars":{"tutorialSidebar":{"link":{"path":"/quickstart.html","label":"quickstart"}}}}],"breadcrumbs":true}}}'),i=JSON.parse('{"defaultLocale":"en","locales":["en"],"path":"i18n","currentLocale":"en","localeConfigs":{"en":{"label":"English","direction":"ltr","htmlLang":"en","calendar":"gregory","path":"en"}}}');var l=n(2654);const s=JSON.parse('{"docusaurusVersion":"3.0.1","siteVersion":"0.0.0","pluginVersions":{"docusaurus-plugin-content-docs":{"type":"package","name":"@docusaurus/plugin-content-docs","version":"3.0.1"},"docusaurus-plugin-content-blog":{"type":"package","name":"@docusaurus/plugin-content-blog","version":"3.0.1"},"docusaurus-plugin-content-pages":{"type":"package","name":"@docusaurus/plugin-content-pages","version":"3.0.1"},"docusaurus-plugin-google-gtag":{"type":"package","name":"@docusaurus/plugin-google-gtag","version":"3.0.1"},"docusaurus-plugin-sitemap":{"type":"package","name":"@docusaurus/plugin-sitemap","version":"3.0.1"},"docusaurus-theme-classic":{"type":"package","name":"@docusaurus/theme-classic","version":"3.0.1"},"docusaurus-lunr-search":{"type":"package","name":"docusaurus-lunr-search","version":"3.3.1"}}}');var c=n(4848);const u={siteConfig:a.default,siteMetadata:s,globalData:o,i18n:i,codeTranslations:l},d=r.createContext(u);function p(e){let{children:t}=e;return(0,c.jsx)(d.Provider,{value:u,children:t})}},7489:(e,t,n)=>{"use strict";n.d(t,{A:()=>f});var r=n(6540),a=n(8193),o=n(5260),i=n(440),l=n(1595),s=n(4848);function c(e){let{error:t,tryAgain:n}=e;return(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"flex-start",minHeight:"100vh",width:"100%",maxWidth:"80ch",fontSize:"20px",margin:"0 auto",padding:"1rem"},children:[(0,s.jsx)("h1",{style:{fontSize:"3rem"},children:"This page crashed"}),(0,s.jsx)("button",{type:"button",onClick:n,style:{margin:"1rem 0",fontSize:"2rem",cursor:"pointer",borderRadius:20,padding:"1rem"},children:"Try again"}),(0,s.jsx)(u,{error:t})]})}function u(e){let{error:t}=e;const n=(0,i.getErrorCausalChain)(t).map((e=>e.message)).join("\n\nCause:\n");return(0,s.jsx)("p",{style:{whiteSpace:"pre-wrap"},children:n})}function d(e){let{error:t,tryAgain:n}=e;return(0,s.jsxs)(f,{fallback:()=>(0,s.jsx)(c,{error:t,tryAgain:n}),children:[(0,s.jsx)(o.A,{children:(0,s.jsx)("title",{children:"Page Error"})}),(0,s.jsx)(l.A,{children:(0,s.jsx)(c,{error:t,tryAgain:n})})]})}const p=e=>(0,s.jsx)(d,{...e});class f extends r.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){a.A.canUseDOM&&this.setState({error:e})}render(){const{children:e}=this.props,{error:t}=this.state;if(t){const e={error:t,tryAgain:()=>this.setState({error:null})};return(this.props.fallback??p)(e)}return e??null}}},8193:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});const r="undefined"!=typeof window&&"document"in window&&"createElement"in window.document,a={canUseDOM:r,canUseEventListeners:r&&("addEventListener"in window||"attachEvent"in window),canUseIntersectionObserver:r&&"IntersectionObserver"in window,canUseViewport:r&&"screen"in window}},5260:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});n(6540);var r=n(545),a=n(4848);function o(e){return(0,a.jsx)(r.mg,{...e})}},5489:(e,t,n)=>{"use strict";n.d(t,{A:()=>f});var r=n(6540),a=n(4625),o=n(440),i=n(4586),l=n(6654),s=n(8193),c=n(4848);const u=r.createContext({collectLink:()=>{}});var d=n(6025);function p(e,t){let{isNavLink:n,to:p,href:f,activeClassName:m,isActive:h,"data-noBrokenLinkCheck":g,autoAddBaseUrl:b=!0,...y}=e;const{siteConfig:{trailingSlash:v,baseUrl:w}}=(0,i.A)(),{withBaseUrl:x}=(0,d.h)(),k=(0,r.useContext)(u),S=(0,r.useRef)(null);(0,r.useImperativeHandle)(t,(()=>S.current));const E=p||f;const _=(0,l.A)(E),C=E?.replace("pathname://","");let T=void 0!==C?(A=C,b&&(e=>e.startsWith("/"))(A)?x(A):A):void 0;var A;T&&_&&(T=(0,o.applyTrailingSlash)(T,{trailingSlash:v,baseUrl:w}));const j=(0,r.useRef)(!1),N=n?a.k2:a.N_,R=s.A.canUseIntersectionObserver,L=(0,r.useRef)(),P=()=>{j.current||null==T||(window.docusaurus.preload(T),j.current=!0)};(0,r.useEffect)((()=>(!R&&_&&null!=T&&window.docusaurus.prefetch(T),()=>{R&&L.current&&L.current.disconnect()})),[L,T,R,_]);const O=T?.startsWith("#")??!1,I=!T||!_||O;return I||g||k.collectLink(T),I?(0,c.jsx)("a",{ref:S,href:T,...E&&!_&&{target:"_blank",rel:"noopener noreferrer"},...y}):(0,c.jsx)(N,{...y,onMouseEnter:P,onTouchStart:P,innerRef:e=>{S.current=e,R&&e&&_&&(L.current=new window.IntersectionObserver((t=>{t.forEach((t=>{e===t.target&&(t.isIntersecting||t.intersectionRatio>0)&&(L.current.unobserve(e),L.current.disconnect(),null!=T&&window.docusaurus.prefetch(T))}))})),L.current.observe(e))},to:T,...n&&{isActive:h,activeClassName:m}})}const f=r.forwardRef(p)},1312:(e,t,n)=>{"use strict";n.d(t,{A:()=>c,T:()=>s});var r=n(6540),a=n(4848);function o(e,t){const n=e.split(/(\{\w+\})/).map(((e,n)=>{if(n%2==1){const n=t?.[e.slice(1,-1)];if(void 0!==n)return n}return e}));return n.some((e=>(0,r.isValidElement)(e)))?n.map(((e,t)=>(0,r.isValidElement)(e)?r.cloneElement(e,{key:t}):e)).filter((e=>""!==e)):n.join("")}var i=n(2654);function l(e){let{id:t,message:n}=e;if(void 0===t&&void 0===n)throw new Error("Docusaurus translation declarations must have at least a translation id or a default translation message");return i[t??n]??n??t}function s(e,t){let{message:n,id:r}=e;return o(l({message:n,id:r}),t)}function c(e){let{children:t,id:n,values:r}=e;if(t&&"string"!=typeof t)throw console.warn("Illegal children",t),new Error("The Docusaurus component only accept simple string values");const i=l({message:t,id:n});return(0,a.jsx)(a.Fragment,{children:o(i,r)})}},7065:(e,t,n)=>{"use strict";n.d(t,{W:()=>r});const r="default"},6654:(e,t,n)=>{"use strict";function r(e){return/^(?:\w*:|\/\/)/.test(e)}function a(e){return void 0!==e&&!r(e)}n.d(t,{A:()=>a,z:()=>r})},6025:(e,t,n)=>{"use strict";n.d(t,{A:()=>l,h:()=>i});var r=n(6540),a=n(4586),o=n(6654);function i(){const{siteConfig:{baseUrl:e,url:t}}=(0,a.A)(),n=(0,r.useCallback)(((n,r)=>function(e,t,n,r){let{forcePrependBaseUrl:a=!1,absolute:i=!1}=void 0===r?{}:r;if(!n||n.startsWith("#")||(0,o.z)(n))return n;if(a)return t+n.replace(/^\//,"");if(n===t.replace(/\/$/,""))return t;const l=n.startsWith(t)?n:t+n.replace(/^\//,"");return i?e+l:l}(t,e,n,r)),[t,e]);return{withBaseUrl:n}}function l(e,t){void 0===t&&(t={});const{withBaseUrl:n}=i();return n(e,t)}},4586:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(6540),a=n(6988);function o(){return(0,r.useContext)(a.o)}},6588:(e,t,n)=>{"use strict";n.d(t,{P_:()=>i,kh:()=>o});var r=n(4586),a=n(7065);function o(e,t){void 0===t&&(t={});const n=function(){const{globalData:e}=(0,r.A)();return e}()[e];if(!n&&t.failfast)throw new Error(`Docusaurus plugin global data not found for "${e}" plugin.`);return n}function i(e,t,n){void 0===t&&(t=a.W),void 0===n&&(n={});const r=o(e),i=r?.[t];if(!i&&n.failfast)throw new Error(`Docusaurus plugin global data not found for "${e}" plugin with id "${t}".`);return i}},2303:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(6540),a=n(6125);function o(){return(0,r.useContext)(a.o)}},205:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(6540);const a=n(8193).A.canUseDOM?r.useLayoutEffect:r.useEffect},6921:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});const r=e=>"object"==typeof e&&!!e&&Object.keys(e).length>0;function a(e){const t={};return function e(n,a){Object.entries(n).forEach((n=>{let[o,i]=n;const l=a?`${a}.${o}`:o;r(i)?e(i,l):t[l]=i}))}(e),t}},3102:(e,t,n)=>{"use strict";n.d(t,{W:()=>i,o:()=>o});var r=n(6540),a=n(4848);const o=r.createContext(null);function i(e){let{children:t,value:n}=e;const i=r.useContext(o),l=(0,r.useMemo)((()=>function(e){let{parent:t,value:n}=e;if(!t){if(!n)throw new Error("Unexpected: no Docusaurus route context found");if(!("plugin"in n))throw new Error("Unexpected: Docusaurus topmost route context has no `plugin` attribute");return n}const r={...t.data,...n?.data};return{plugin:t.plugin,data:r}}({parent:i,value:n})),[i,n]);return(0,a.jsx)(o.Provider,{value:l,children:t})}},8295:(e,t,n)=>{"use strict";n.d(t,{zK:()=>f,vT:()=>u,Gy:()=>s,HW:()=>m,ht:()=>c,r7:()=>p,jh:()=>d});var r=n(6347),a=n(6588);const o=e=>e.versions.find((e=>e.isLast));function i(e,t){const n=function(e,t){const n=o(e);return[...e.versions.filter((e=>e!==n)),n].find((e=>!!(0,r.B6)(t,{path:e.path,exact:!1,strict:!1})))}(e,t),a=n?.docs.find((e=>!!(0,r.B6)(t,{path:e.path,exact:!0,strict:!1})));return{activeVersion:n,activeDoc:a,alternateDocVersions:a?function(t){const n={};return e.versions.forEach((e=>{e.docs.forEach((r=>{r.id===t&&(n[e.name]=r)}))})),n}(a.id):{}}}const l={},s=()=>(0,a.kh)("docusaurus-plugin-content-docs")??l,c=e=>(0,a.P_)("docusaurus-plugin-content-docs",e,{failfast:!0});function u(e){void 0===e&&(e={});const t=s(),{pathname:n}=(0,r.zy)();return function(e,t,n){void 0===n&&(n={});const a=Object.entries(e).sort(((e,t)=>t[1].path.localeCompare(e[1].path))).find((e=>{let[,n]=e;return!!(0,r.B6)(t,{path:n.path,exact:!1,strict:!1})})),o=a?{pluginId:a[0],pluginData:a[1]}:void 0;if(!o&&n.failfast)throw new Error(`Can't find active docs plugin for "${t}" pathname, while it was expected to be found. Maybe you tried to use a docs feature that can only be used on a docs-related page? Existing docs plugin paths are: ${Object.values(e).map((e=>e.path)).join(", ")}`);return o}(t,n,e)}function d(e){return c(e).versions}function p(e){const t=c(e);return o(t)}function f(e){const t=c(e),{pathname:n}=(0,r.zy)();return i(t,n)}function m(e){const t=c(e),{pathname:n}=(0,r.zy)();return function(e,t){const n=o(e);return{latestDocSuggestion:i(e,t).alternateDocVersions[n.name],latestVersionSuggestion:n}}(t,n)}},1911:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r});const r={onRouteDidUpdate(e){let{location:t,previousLocation:n}=e;!n||t.pathname===n.pathname&&t.search===n.search&&t.hash===n.hash||setTimeout((()=>{window.gtag("set","page_path",t.pathname+t.search+t.hash),window.gtag("event","page_view")}))}}},6294:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(5947),a=n.n(r);a().configure({showSpinner:!1});const o={onRouteUpdate(e){let{location:t,previousLocation:n}=e;if(n&&t.pathname!==n.pathname){const e=window.setTimeout((()=>{a().start()}),200);return()=>window.clearTimeout(e)}},onRouteDidUpdate(){a().done()}}},6134:(e,t,n)=>{"use strict";n.r(t);var r=n(1765),a=n(4784);!function(e){const{themeConfig:{prism:t}}=a.default,{additionalLanguages:r}=t;globalThis.Prism=e,r.forEach((e=>{"php"===e&&n(9700),n(8692)(`./prism-${e}`)})),delete globalThis.Prism}(r.My)},1107:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});n(6540);var r=n(4164),a=n(1312),o=n(6342),i=n(5489);const l={anchorWithStickyNavbar:"anchorWithStickyNavbar_LWe7",anchorWithHideOnScrollNavbar:"anchorWithHideOnScrollNavbar_WYt5"};var s=n(4848);function c(e){let{as:t,id:n,...c}=e;const{navbar:{hideOnScroll:u}}=(0,o.p)();if("h1"===t||!n)return(0,s.jsx)(t,{...c,id:void 0});const d=(0,a.T)({id:"theme.common.headingLinkTitle",message:"Direct link to {heading}",description:"Title for link to heading"},{heading:"string"==typeof c.children?c.children:n});return(0,s.jsxs)(t,{...c,className:(0,r.A)("anchor",u?l.anchorWithHideOnScrollNavbar:l.anchorWithStickyNavbar,c.className),id:n,children:[c.children,(0,s.jsx)(i.A,{className:"hash-link",to:`#${n}`,"aria-label":d,title:d,children:"\u200b"})]})}},3186:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});n(6540);const r={iconExternalLink:"iconExternalLink_nPIU"};var a=n(4848);function o(e){let{width:t=13.5,height:n=13.5}=e;return(0,a.jsx)("svg",{width:t,height:n,"aria-hidden":"true",viewBox:"0 0 24 24",className:r.iconExternalLink,children:(0,a.jsx)("path",{fill:"currentColor",d:"M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"})})}},1595:(e,t,n)=>{"use strict";n.d(t,{A:()=>bt});var r=n(6540),a=n(4164),o=n(7489),i=n(1003),l=n(6347),s=n(1312),c=n(5062),u=n(4848);const d="__docusaurus_skipToContent_fallback";function p(e){e.setAttribute("tabindex","-1"),e.focus(),e.removeAttribute("tabindex")}function f(){const e=(0,r.useRef)(null),{action:t}=(0,l.W6)(),n=(0,r.useCallback)((e=>{e.preventDefault();const t=document.querySelector("main:first-of-type")??document.getElementById(d);t&&p(t)}),[]);return(0,c.$)((n=>{let{location:r}=n;e.current&&!r.hash&&"PUSH"===t&&p(e.current)})),{containerRef:e,onClick:n}}const m=(0,s.T)({id:"theme.common.skipToMainContent",description:"The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation",message:"Skip to main content"});function h(e){const t=e.children??m,{containerRef:n,onClick:r}=f();return(0,u.jsx)("div",{ref:n,role:"region","aria-label":m,children:(0,u.jsx)("a",{...e,href:`#${d}`,onClick:r,children:t})})}var g=n(7559),b=n(4090);const y={skipToContent:"skipToContent_fXgn"};function v(){return(0,u.jsx)(h,{className:y.skipToContent})}var w=n(6342),x=n(5041);function k(e){let{width:t=21,height:n=21,color:r="currentColor",strokeWidth:a=1.2,className:o,...i}=e;return(0,u.jsx)("svg",{viewBox:"0 0 15 15",width:t,height:n,...i,children:(0,u.jsx)("g",{stroke:r,strokeWidth:a,children:(0,u.jsx)("path",{d:"M.75.75l13.5 13.5M14.25.75L.75 14.25"})})})}const S={closeButton:"closeButton_CVFx"};function E(e){return(0,u.jsx)("button",{type:"button","aria-label":(0,s.T)({id:"theme.AnnouncementBar.closeButtonAriaLabel",message:"Close",description:"The ARIA label for close button of announcement bar"}),...e,className:(0,a.A)("clean-btn close",S.closeButton,e.className),children:(0,u.jsx)(k,{width:14,height:14,strokeWidth:3.1})})}const _={content:"content_knG7"};function C(e){const{announcementBar:t}=(0,w.p)(),{content:n}=t;return(0,u.jsx)("div",{...e,className:(0,a.A)(_.content,e.className),dangerouslySetInnerHTML:{__html:n}})}const T={announcementBar:"announcementBar_mb4j",announcementBarPlaceholder:"announcementBarPlaceholder_vyr4",announcementBarClose:"announcementBarClose_gvF7",announcementBarContent:"announcementBarContent_xLdY"};function A(){const{announcementBar:e}=(0,w.p)(),{isActive:t,close:n}=(0,x.Mj)();if(!t)return null;const{backgroundColor:r,textColor:a,isCloseable:o}=e;return(0,u.jsxs)("div",{className:T.announcementBar,style:{backgroundColor:r,color:a},role:"banner",children:[o&&(0,u.jsx)("div",{className:T.announcementBarPlaceholder}),(0,u.jsx)(C,{className:T.announcementBarContent}),o&&(0,u.jsx)(E,{onClick:n,className:T.announcementBarClose})]})}var j=n(9876),N=n(3104);var R=n(9532),L=n(5600);const P=r.createContext(null);function O(e){let{children:t}=e;const n=function(){const e=(0,j.M)(),t=(0,L.YL)(),[n,a]=(0,r.useState)(!1),o=null!==t.component,i=(0,R.ZC)(o);return(0,r.useEffect)((()=>{o&&!i&&a(!0)}),[o,i]),(0,r.useEffect)((()=>{o?e.shown||a(!0):a(!1)}),[e.shown,o]),(0,r.useMemo)((()=>[n,a]),[n])}();return(0,u.jsx)(P.Provider,{value:n,children:t})}function I(e){if(e.component){const t=e.component;return(0,u.jsx)(t,{...e.props})}}function D(){const e=(0,r.useContext)(P);if(!e)throw new R.dV("NavbarSecondaryMenuDisplayProvider");const[t,n]=e,a=(0,r.useCallback)((()=>n(!1)),[n]),o=(0,L.YL)();return(0,r.useMemo)((()=>({shown:t,hide:a,content:I(o)})),[a,o,t])}function M(e){let{header:t,primaryMenu:n,secondaryMenu:r}=e;const{shown:o}=D();return(0,u.jsxs)("div",{className:"navbar-sidebar",children:[t,(0,u.jsxs)("div",{className:(0,a.A)("navbar-sidebar__items",{"navbar-sidebar__items--show-secondary":o}),children:[(0,u.jsx)("div",{className:"navbar-sidebar__item menu",children:n}),(0,u.jsx)("div",{className:"navbar-sidebar__item menu",children:r})]})]})}var F=n(5293),z=n(2303);function B(e){return(0,u.jsx)("svg",{viewBox:"0 0 24 24",width:24,height:24,...e,children:(0,u.jsx)("path",{fill:"currentColor",d:"M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"})})}function $(e){return(0,u.jsx)("svg",{viewBox:"0 0 24 24",width:24,height:24,...e,children:(0,u.jsx)("path",{fill:"currentColor",d:"M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"})})}const U={toggle:"toggle_vylO",toggleButton:"toggleButton_gllP",darkToggleIcon:"darkToggleIcon_wfgR",lightToggleIcon:"lightToggleIcon_pyhR",toggleButtonDisabled:"toggleButtonDisabled_aARS"};function q(e){let{className:t,buttonClassName:n,value:r,onChange:o}=e;const i=(0,z.A)(),l=(0,s.T)({message:"Switch between dark and light mode (currently {mode})",id:"theme.colorToggle.ariaLabel",description:"The ARIA label for the navbar color mode toggle"},{mode:"dark"===r?(0,s.T)({message:"dark mode",id:"theme.colorToggle.ariaLabel.mode.dark",description:"The name for the dark color mode"}):(0,s.T)({message:"light mode",id:"theme.colorToggle.ariaLabel.mode.light",description:"The name for the light color mode"})});return(0,u.jsx)("div",{className:(0,a.A)(U.toggle,t),children:(0,u.jsxs)("button",{className:(0,a.A)("clean-btn",U.toggleButton,!i&&U.toggleButtonDisabled,n),type:"button",onClick:()=>o("dark"===r?"light":"dark"),disabled:!i,title:l,"aria-label":l,"aria-live":"polite",children:[(0,u.jsx)(B,{className:(0,a.A)(U.toggleIcon,U.lightToggleIcon)}),(0,u.jsx)($,{className:(0,a.A)(U.toggleIcon,U.darkToggleIcon)})]})})}const H=r.memo(q),G={darkNavbarColorModeToggle:"darkNavbarColorModeToggle_X3D1"};function W(e){let{className:t}=e;const n=(0,w.p)().navbar.style,r=(0,w.p)().colorMode.disableSwitch,{colorMode:a,setColorMode:o}=(0,F.G)();return r?null:(0,u.jsx)(H,{className:t,buttonClassName:"dark"===n?G.darkNavbarColorModeToggle:void 0,value:a,onChange:o})}var V=n(3465);function Q(){return(0,u.jsx)(V.A,{className:"navbar__brand",imageClassName:"navbar__logo",titleClassName:"navbar__title text--truncate"})}function K(){const e=(0,j.M)();return(0,u.jsx)("button",{type:"button","aria-label":(0,s.T)({id:"theme.docs.sidebar.closeSidebarButtonAriaLabel",message:"Close navigation bar",description:"The ARIA label for close button of mobile sidebar"}),className:"clean-btn navbar-sidebar__close",onClick:()=>e.toggle(),children:(0,u.jsx)(k,{color:"var(--ifm-color-emphasis-600)"})})}function Y(){return(0,u.jsxs)("div",{className:"navbar-sidebar__brand",children:[(0,u.jsx)(Q,{}),(0,u.jsx)(W,{className:"margin-right--md"}),(0,u.jsx)(K,{})]})}var J=n(5489),Z=n(6025),X=n(6654);function ee(e,t){return void 0!==e&&void 0!==t&&new RegExp(e,"gi").test(t)}var te=n(3186);function ne(e){let{activeBasePath:t,activeBaseRegex:n,to:r,href:a,label:o,html:i,isDropdownLink:l,prependBaseUrlToHref:s,...c}=e;const d=(0,Z.A)(r),p=(0,Z.A)(t),f=(0,Z.A)(a,{forcePrependBaseUrl:!0}),m=o&&a&&!(0,X.A)(a),h=i?{dangerouslySetInnerHTML:{__html:i}}:{children:(0,u.jsxs)(u.Fragment,{children:[o,m&&(0,u.jsx)(te.A,{...l&&{width:12,height:12}})]})};return a?(0,u.jsx)(J.A,{href:s?f:a,...c,...h}):(0,u.jsx)(J.A,{to:d,isNavLink:!0,...(t||n)&&{isActive:(e,t)=>n?ee(n,t.pathname):t.pathname.startsWith(p)},...c,...h})}function re(e){let{className:t,isDropdownItem:n=!1,...r}=e;const o=(0,u.jsx)(ne,{className:(0,a.A)(n?"dropdown__link":"navbar__item navbar__link",t),isDropdownLink:n,...r});return n?(0,u.jsx)("li",{children:o}):o}function ae(e){let{className:t,isDropdownItem:n,...r}=e;return(0,u.jsx)("li",{className:"menu__list-item",children:(0,u.jsx)(ne,{className:(0,a.A)("menu__link",t),...r})})}function oe(e){let{mobile:t=!1,position:n,...r}=e;const a=t?ae:re;return(0,u.jsx)(a,{...r,activeClassName:r.activeClassName??(t?"menu__link--active":"navbar__link--active")})}var ie=n(1422),le=n(9169),se=n(4586);const ce={dropdownNavbarItemMobile:"dropdownNavbarItemMobile_S0Fm"};function ue(e,t){return e.some((e=>function(e,t){return!!(0,le.ys)(e.to,t)||!!ee(e.activeBaseRegex,t)||!(!e.activeBasePath||!t.startsWith(e.activeBasePath))}(e,t)))}function de(e){let{items:t,position:n,className:o,onClick:i,...l}=e;const s=(0,r.useRef)(null),[c,d]=(0,r.useState)(!1);return(0,r.useEffect)((()=>{const e=e=>{s.current&&!s.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),document.addEventListener("focusin",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e),document.removeEventListener("focusin",e)}}),[s]),(0,u.jsxs)("div",{ref:s,className:(0,a.A)("navbar__item","dropdown","dropdown--hoverable",{"dropdown--right":"right"===n,"dropdown--show":c}),children:[(0,u.jsx)(ne,{"aria-haspopup":"true","aria-expanded":c,role:"button",href:l.to?void 0:"#",className:(0,a.A)("navbar__link",o),...l,onClick:l.to?void 0:e=>e.preventDefault(),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),d(!c))},children:l.children??l.label}),(0,u.jsx)("ul",{className:"dropdown__menu",children:t.map(((e,t)=>(0,r.createElement)(je,{isDropdownItem:!0,activeClassName:"dropdown__link--active",...e,key:t})))})]})}function pe(e){let{items:t,className:n,position:o,onClick:i,...s}=e;const c=function(){const{siteConfig:{baseUrl:e}}=(0,se.A)(),{pathname:t}=(0,l.zy)();return t.replace(e,"/")}(),d=ue(t,c),{collapsed:p,toggleCollapsed:f,setCollapsed:m}=(0,ie.u)({initialState:()=>!d});return(0,r.useEffect)((()=>{d&&m(!d)}),[c,d,m]),(0,u.jsxs)("li",{className:(0,a.A)("menu__list-item",{"menu__list-item--collapsed":p}),children:[(0,u.jsx)(ne,{role:"button",className:(0,a.A)(ce.dropdownNavbarItemMobile,"menu__link menu__link--sublist menu__link--sublist-caret",n),...s,onClick:e=>{e.preventDefault(),f()},children:s.children??s.label}),(0,u.jsx)(ie.N,{lazy:!0,as:"ul",className:"menu__list",collapsed:p,children:t.map(((e,t)=>(0,r.createElement)(je,{mobile:!0,isDropdownItem:!0,onClick:i,activeClassName:"menu__link--active",...e,key:t})))})]})}function fe(e){let{mobile:t=!1,...n}=e;const r=t?pe:de;return(0,u.jsx)(r,{...n})}var me=n(2131);function he(e){let{width:t=20,height:n=20,...r}=e;return(0,u.jsx)("svg",{viewBox:"0 0 24 24",width:t,height:n,"aria-hidden":!0,...r,children:(0,u.jsx)("path",{fill:"currentColor",d:"M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"})})}const ge="iconLanguage_nlXk";var be=n(6588),ye=n(689),ve=n.n(ye);function we(){const e=(0,l.zy)(),t=(0,l.W6)(),{siteConfig:{baseUrl:n}}=(0,se.A)(),[a,o]=(0,r.useState)({wordToHighlight:"",isTitleSuggestion:!1,titleText:""});return(0,r.useEffect)((()=>{if(!e.state?.highlightState||0===e.state.highlightState.wordToHighlight.length)return;o(e.state.highlightState);const{highlightState:n,...r}=e.state;t.replace({...e,state:r})}),[e.state?.highlightState,t,e]),(0,r.useEffect)((()=>{if(0===a.wordToHighlight.length)return;const e=document.getElementsByTagName("article")[0]??document.getElementsByTagName("main")[0];if(!e)return;const t=new(ve())(e),n={ignoreJoiners:!0};return t.mark(a.wordToHighlight,n),()=>t.unmark(n)}),[a,n]),null}const xe=e=>{const t=(0,r.useRef)(!1),o=(0,r.useRef)(null),[i,s]=(0,r.useState)(!1),c=(0,l.W6)(),{siteConfig:d={}}=(0,se.A)(),p=(d.plugins||[]).find((e=>Array.isArray(e)&&"string"==typeof e[0]&&e[0].includes("docusaurus-lunr-search"))),f=(0,z.A)(),{baseUrl:m}=d,h=p&&p[1]?.assetUrl||m,g=(0,be.P_)("docusaurus-lunr-search"),b=()=>{t.current||(Promise.all([fetch(`${h}${g.fileNames.searchDoc}`).then((e=>e.json())),fetch(`${h}${g.fileNames.lunrIndex}`).then((e=>e.json())),Promise.all([n.e(4250),n.e(7443)]).then(n.bind(n,4004)),Promise.all([n.e(1869),n.e(9187)]).then(n.bind(n,9187))]).then((e=>{let[t,n,{default:r}]=e;const{searchDocs:a,options:o}=t;a&&0!==a.length&&(((e,t,n,r)=>{new n({searchDocs:e,searchIndex:t,baseUrl:m,inputSelector:"#search_input_react",handleSelected:(e,t,n)=>{const a=n.url||"/";document.createElement("a").href=a,e.setVal(""),t.target.blur();let o="";if(r.highlightResult)try{const e=(n.text||n.subcategory||n.title).match(new RegExp("\\w*","g"));if(e&&e.length>0){const t=document.createElement("div");t.innerHTML=e[0],o=t.textContent}}catch(i){console.log(i)}c.push(a,{highlightState:{wordToHighlight:o}})},maxHits:r.maxHits})})(a,n,r,o),s(!0))})),t.current=!0)},y=(0,r.useCallback)((t=>{o.current.contains(t.target)||o.current.focus(),e.handleSearchBarToggle&&e.handleSearchBarToggle(!e.isSearchBarExpanded)}),[e.isSearchBarExpanded]);let v;return f&&(b(),v=window.navigator.platform.startsWith("Mac")?"Search \u2318+K":"Search Ctrl+K"),(0,u.jsxs)("div",{className:"navbar__search",children:[(0,u.jsx)("span",{"aria-label":"expand searchbar",role:"button",className:(0,a.A)("search-icon",{"search-icon-hidden":e.isSearchBarExpanded}),onClick:y,onKeyDown:y,tabIndex:0}),(0,u.jsx)("input",{id:"search_input_react",type:"search",placeholder:i?v:"Loading...","aria-label":"Search",className:(0,a.A)("navbar__search-input",{"search-bar-expanded":e.isSearchBarExpanded},{"search-bar":!e.isSearchBarExpanded}),onClick:b,onMouseOver:b,onFocus:y,onBlur:y,ref:o,disabled:!i}),(0,u.jsx)(we,{})]},"search-box")},ke={navbarSearchContainer:"navbarSearchContainer_Bca1"};function Se(e){let{children:t,className:n}=e;return(0,u.jsx)("div",{className:(0,a.A)(n,ke.navbarSearchContainer),children:t})}var Ee=n(8295),_e=n(1754);var Ce=n(5597);const Te=e=>e.docs.find((t=>t.id===e.mainDocId));const Ae={default:oe,localeDropdown:function(e){let{mobile:t,dropdownItemsBefore:n,dropdownItemsAfter:r,queryString:a="",...o}=e;const{i18n:{currentLocale:i,locales:c,localeConfigs:d}}=(0,se.A)(),p=(0,me.o)(),{search:f,hash:m}=(0,l.zy)(),h=[...n,...c.map((e=>{const n=`${`pathname://${p.createUrl({locale:e,fullyQualified:!1})}`}${f}${m}${a}`;return{label:d[e].label,lang:d[e].htmlLang,to:n,target:"_self",autoAddBaseUrl:!1,className:e===i?t?"menu__link--active":"dropdown__link--active":""}})),...r],g=t?(0,s.T)({message:"Languages",id:"theme.navbar.mobileLanguageDropdown.label",description:"The label for the mobile language switcher dropdown"}):d[i].label;return(0,u.jsx)(fe,{...o,mobile:t,label:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(he,{className:ge}),g]}),items:h})},search:function(e){let{mobile:t,className:n}=e;return t?null:(0,u.jsx)(Se,{className:n,children:(0,u.jsx)(xe,{})})},dropdown:fe,html:function(e){let{value:t,className:n,mobile:r=!1,isDropdownItem:o=!1}=e;const i=o?"li":"div";return(0,u.jsx)(i,{className:(0,a.A)({navbar__item:!r&&!o,"menu__list-item":r},n),dangerouslySetInnerHTML:{__html:t}})},doc:function(e){let{docId:t,label:n,docsPluginId:r,...a}=e;const{activeDoc:o}=(0,Ee.zK)(r),i=(0,_e.QB)(t,r),l=o?.path===i?.path;return null===i||i.unlisted&&!l?null:(0,u.jsx)(oe,{exact:!0,...a,isActive:()=>l||!!o?.sidebar&&o.sidebar===i.sidebar,label:n??i.id,to:i.path})},docSidebar:function(e){let{sidebarId:t,label:n,docsPluginId:r,...a}=e;const{activeDoc:o}=(0,Ee.zK)(r),i=(0,_e.fW)(t,r).link;if(!i)throw new Error(`DocSidebarNavbarItem: Sidebar with ID "${t}" doesn't have anything to be linked to.`);return(0,u.jsx)(oe,{exact:!0,...a,isActive:()=>o?.sidebar===t,label:n??i.label,to:i.path})},docsVersion:function(e){let{label:t,to:n,docsPluginId:r,...a}=e;const o=(0,_e.Vd)(r)[0],i=t??o.label,l=n??(e=>e.docs.find((t=>t.id===e.mainDocId)))(o).path;return(0,u.jsx)(oe,{...a,label:i,to:l})},docsVersionDropdown:function(e){let{mobile:t,docsPluginId:n,dropdownActiveClassDisabled:r,dropdownItemsBefore:a,dropdownItemsAfter:o,...i}=e;const{search:c,hash:d}=(0,l.zy)(),p=(0,Ee.zK)(n),f=(0,Ee.jh)(n),{savePreferredVersionName:m}=(0,Ce.g1)(n),h=[...a,...f.map((e=>{const t=p.alternateDocVersions[e.name]??Te(e);return{label:e.label,to:`${t.path}${c}${d}`,isActive:()=>e===p.activeVersion,onClick:()=>m(e.name)}})),...o],g=(0,_e.Vd)(n)[0],b=t&&h.length>1?(0,s.T)({id:"theme.navbar.mobileVersionsDropdown.label",message:"Versions",description:"The label for the navbar versions dropdown on mobile view"}):g.label,y=t&&h.length>1?void 0:Te(g).path;return h.length<=1?(0,u.jsx)(oe,{...i,mobile:t,label:b,to:y,isActive:r?()=>!1:void 0}):(0,u.jsx)(fe,{...i,mobile:t,label:b,to:y,items:h,isActive:r?()=>!1:void 0})}};function je(e){let{type:t,...n}=e;const r=function(e,t){return e&&"default"!==e?e:"items"in t?"dropdown":"default"}(t,n),a=Ae[r];if(!a)throw new Error(`No NavbarItem component found for type "${t}".`);return(0,u.jsx)(a,{...n})}function Ne(){const e=(0,j.M)(),t=(0,w.p)().navbar.items;return(0,u.jsx)("ul",{className:"menu__list",children:t.map(((t,n)=>(0,r.createElement)(je,{mobile:!0,...t,onClick:()=>e.toggle(),key:n})))})}function Re(e){return(0,u.jsx)("button",{...e,type:"button",className:"clean-btn navbar-sidebar__back",children:(0,u.jsx)(s.A,{id:"theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel",description:"The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)",children:"\u2190 Back to main menu"})})}function Le(){const e=0===(0,w.p)().navbar.items.length,t=D();return(0,u.jsxs)(u.Fragment,{children:[!e&&(0,u.jsx)(Re,{onClick:()=>t.hide()}),t.content]})}function Pe(){const e=(0,j.M)();var t;return void 0===(t=e.shown)&&(t=!0),(0,r.useEffect)((()=>(document.body.style.overflow=t?"hidden":"visible",()=>{document.body.style.overflow="visible"})),[t]),e.shouldRender?(0,u.jsx)(M,{header:(0,u.jsx)(Y,{}),primaryMenu:(0,u.jsx)(Ne,{}),secondaryMenu:(0,u.jsx)(Le,{})}):null}const Oe={navbarHideable:"navbarHideable_m1mJ",navbarHidden:"navbarHidden_jGov"};function Ie(e){return(0,u.jsx)("div",{role:"presentation",...e,className:(0,a.A)("navbar-sidebar__backdrop",e.className)})}function De(e){let{children:t}=e;const{navbar:{hideOnScroll:n,style:o}}=(0,w.p)(),i=(0,j.M)(),{navbarRef:l,isNavbarVisible:d}=function(e){const[t,n]=(0,r.useState)(e),a=(0,r.useRef)(!1),o=(0,r.useRef)(0),i=(0,r.useCallback)((e=>{null!==e&&(o.current=e.getBoundingClientRect().height)}),[]);return(0,N.Mq)(((t,r)=>{let{scrollY:i}=t;if(!e)return;if(i=l?n(!1):i+c{if(!e)return;const r=t.location.hash;if(r?document.getElementById(r.substring(1)):void 0)return a.current=!0,void n(!1);n(!0)})),{navbarRef:i,isNavbarVisible:t}}(n);return(0,u.jsxs)("nav",{ref:l,"aria-label":(0,s.T)({id:"theme.NavBar.navAriaLabel",message:"Main",description:"The ARIA label for the main navigation"}),className:(0,a.A)("navbar","navbar--fixed-top",n&&[Oe.navbarHideable,!d&&Oe.navbarHidden],{"navbar--dark":"dark"===o,"navbar--primary":"primary"===o,"navbar-sidebar--show":i.shown}),children:[t,(0,u.jsx)(Ie,{onClick:i.toggle}),(0,u.jsx)(Pe,{})]})}var Me=n(440);const Fe={errorBoundaryError:"errorBoundaryError_a6uf",errorBoundaryFallback:"errorBoundaryFallback_VBag"};function ze(e){return(0,u.jsx)("button",{type:"button",...e,children:(0,u.jsx)(s.A,{id:"theme.ErrorPageContent.tryAgain",description:"The label of the button to try again rendering when the React error boundary captures an error",children:"Try again"})})}function Be(e){let{error:t}=e;const n=(0,Me.getErrorCausalChain)(t).map((e=>e.message)).join("\n\nCause:\n");return(0,u.jsx)("p",{className:Fe.errorBoundaryError,children:n})}class $e extends r.Component{componentDidCatch(e,t){throw this.props.onError(e,t)}render(){return this.props.children}}const Ue="right";function qe(e){let{width:t=30,height:n=30,className:r,...a}=e;return(0,u.jsx)("svg",{className:r,width:t,height:n,viewBox:"0 0 30 30","aria-hidden":"true",...a,children:(0,u.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M4 7h22M4 15h22M4 23h22"})})}function He(){const{toggle:e,shown:t}=(0,j.M)();return(0,u.jsx)("button",{onClick:e,"aria-label":(0,s.T)({id:"theme.docs.sidebar.toggleSidebarButtonAriaLabel",message:"Toggle navigation bar",description:"The ARIA label for hamburger menu button of mobile navigation"}),"aria-expanded":t,className:"navbar__toggle clean-btn",type:"button",children:(0,u.jsx)(qe,{})})}const Ge={colorModeToggle:"colorModeToggle_DEke"};function We(e){let{items:t}=e;return(0,u.jsx)(u.Fragment,{children:t.map(((e,t)=>(0,u.jsx)($e,{onError:t=>new Error(`A theme navbar item failed to render.\nPlease double-check the following navbar item (themeConfig.navbar.items) of your Docusaurus config:\n${JSON.stringify(e,null,2)}`,{cause:t}),children:(0,u.jsx)(je,{...e})},t)))})}function Ve(e){let{left:t,right:n}=e;return(0,u.jsxs)("div",{className:"navbar__inner",children:[(0,u.jsx)("div",{className:"navbar__items",children:t}),(0,u.jsx)("div",{className:"navbar__items navbar__items--right",children:n})]})}function Qe(){const e=(0,j.M)(),t=(0,w.p)().navbar.items,[n,r]=function(e){function t(e){return"left"===(e.position??Ue)}return[e.filter(t),e.filter((e=>!t(e)))]}(t),a=t.find((e=>"search"===e.type));return(0,u.jsx)(Ve,{left:(0,u.jsxs)(u.Fragment,{children:[!e.disabled&&(0,u.jsx)(He,{}),(0,u.jsx)(Q,{}),(0,u.jsx)(We,{items:n})]}),right:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(We,{items:r}),(0,u.jsx)(W,{className:Ge.colorModeToggle}),!a&&(0,u.jsx)(Se,{children:(0,u.jsx)(xe,{})})]})})}function Ke(){return(0,u.jsx)(De,{children:(0,u.jsx)(Qe,{})})}function Ye(e){let{item:t}=e;const{to:n,href:r,label:a,prependBaseUrlToHref:o,...i}=t,l=(0,Z.A)(n),s=(0,Z.A)(r,{forcePrependBaseUrl:!0});return(0,u.jsxs)(J.A,{className:"footer__link-item",...r?{href:o?s:r}:{to:l},...i,children:[a,r&&!(0,X.A)(r)&&(0,u.jsx)(te.A,{})]})}function Je(e){let{item:t}=e;return t.html?(0,u.jsx)("li",{className:"footer__item",dangerouslySetInnerHTML:{__html:t.html}}):(0,u.jsx)("li",{className:"footer__item",children:(0,u.jsx)(Ye,{item:t})},t.href??t.to)}function Ze(e){let{column:t}=e;return(0,u.jsxs)("div",{className:"col footer__col",children:[(0,u.jsx)("div",{className:"footer__title",children:t.title}),(0,u.jsx)("ul",{className:"footer__items clean-list",children:t.items.map(((e,t)=>(0,u.jsx)(Je,{item:e},t)))})]})}function Xe(e){let{columns:t}=e;return(0,u.jsx)("div",{className:"row footer__links",children:t.map(((e,t)=>(0,u.jsx)(Ze,{column:e},t)))})}function et(){return(0,u.jsx)("span",{className:"footer__link-separator",children:"\xb7"})}function tt(e){let{item:t}=e;return t.html?(0,u.jsx)("span",{className:"footer__link-item",dangerouslySetInnerHTML:{__html:t.html}}):(0,u.jsx)(Ye,{item:t})}function nt(e){let{links:t}=e;return(0,u.jsx)("div",{className:"footer__links text--center",children:(0,u.jsx)("div",{className:"footer__links",children:t.map(((e,n)=>(0,u.jsxs)(r.Fragment,{children:[(0,u.jsx)(tt,{item:e}),t.length!==n+1&&(0,u.jsx)(et,{})]},n)))})})}function rt(e){let{links:t}=e;return function(e){return"title"in e[0]}(t)?(0,u.jsx)(Xe,{columns:t}):(0,u.jsx)(nt,{links:t})}var at=n(1122);const ot={footerLogoLink:"footerLogoLink_BH7S"};function it(e){let{logo:t}=e;const{withBaseUrl:n}=(0,Z.h)(),r={light:n(t.src),dark:n(t.srcDark??t.src)};return(0,u.jsx)(at.A,{className:(0,a.A)("footer__logo",t.className),alt:t.alt,sources:r,width:t.width,height:t.height,style:t.style})}function lt(e){let{logo:t}=e;return t.href?(0,u.jsx)(J.A,{href:t.href,className:ot.footerLogoLink,target:t.target,children:(0,u.jsx)(it,{logo:t})}):(0,u.jsx)(it,{logo:t})}function st(e){let{copyright:t}=e;return(0,u.jsx)("div",{className:"footer__copyright",dangerouslySetInnerHTML:{__html:t}})}function ct(e){let{style:t,links:n,logo:r,copyright:o}=e;return(0,u.jsx)("footer",{className:(0,a.A)("footer",{"footer--dark":"dark"===t}),children:(0,u.jsxs)("div",{className:"container container-fluid",children:[n,(r||o)&&(0,u.jsxs)("div",{className:"footer__bottom text--center",children:[r&&(0,u.jsx)("div",{className:"margin-bottom--sm",children:r}),o]})]})})}function ut(){const{footer:e}=(0,w.p)();if(!e)return null;const{copyright:t,links:n,logo:r,style:a}=e;return(0,u.jsx)(ct,{style:a,links:n&&n.length>0&&(0,u.jsx)(rt,{links:n}),logo:r&&(0,u.jsx)(lt,{logo:r}),copyright:t&&(0,u.jsx)(st,{copyright:t})})}const dt=r.memo(ut),pt=(0,R.fM)([F.a,x.oq,N.Tv,Ce.VQ,i.Jx,function(e){let{children:t}=e;return(0,u.jsx)(L.y_,{children:(0,u.jsx)(j.e,{children:(0,u.jsx)(O,{children:t})})})}]);function ft(e){let{children:t}=e;return(0,u.jsx)(pt,{children:t})}var mt=n(1107);function ht(e){let{error:t,tryAgain:n}=e;return(0,u.jsx)("main",{className:"container margin-vert--xl",children:(0,u.jsx)("div",{className:"row",children:(0,u.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,u.jsx)(mt.A,{as:"h1",className:"hero__title",children:(0,u.jsx)(s.A,{id:"theme.ErrorPageContent.title",description:"The title of the fallback page when the page crashed",children:"This page crashed."})}),(0,u.jsx)("div",{className:"margin-vert--lg",children:(0,u.jsx)(ze,{onClick:n,className:"button button--primary shadow--lw"})}),(0,u.jsx)("hr",{}),(0,u.jsx)("div",{className:"margin-vert--md",children:(0,u.jsx)(Be,{error:t})})]})})})}const gt={mainWrapper:"mainWrapper_z2l0"};function bt(e){const{children:t,noFooter:n,wrapperClassName:r,title:l,description:s}=e;return(0,b.J)(),(0,u.jsxs)(ft,{children:[(0,u.jsx)(i.be,{title:l,description:s}),(0,u.jsx)(v,{}),(0,u.jsx)(A,{}),(0,u.jsx)(Ke,{}),(0,u.jsx)("div",{id:d,className:(0,a.A)(g.G.wrapper.main,gt.mainWrapper,r),children:(0,u.jsx)(o.A,{fallback:e=>(0,u.jsx)(ht,{...e}),children:t})}),!n&&(0,u.jsx)(dt,{})]})}},3465:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});n(6540);var r=n(5489),a=n(6025),o=n(4586),i=n(6342),l=n(1122),s=n(4848);function c(e){let{logo:t,alt:n,imageClassName:r}=e;const o={light:(0,a.A)(t.src),dark:(0,a.A)(t.srcDark||t.src)},i=(0,s.jsx)(l.A,{className:t.className,sources:o,height:t.height,width:t.width,alt:n,style:t.style});return r?(0,s.jsx)("div",{className:r,children:i}):i}function u(e){const{siteConfig:{title:t}}=(0,o.A)(),{navbar:{title:n,logo:l}}=(0,i.p)(),{imageClassName:u,titleClassName:d,...p}=e,f=(0,a.A)(l?.href||"/"),m=n?"":t,h=l?.alt??m;return(0,s.jsxs)(r.A,{to:f,...p,...l?.target&&{target:l.target},children:[l&&(0,s.jsx)(c,{logo:l,alt:h,imageClassName:u}),null!=n&&(0,s.jsx)("b",{className:d,children:n})]})}},1463:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});n(6540);var r=n(5260),a=n(4848);function o(e){let{locale:t,version:n,tag:o}=e;const i=t;return(0,a.jsxs)(r.A,{children:[t&&(0,a.jsx)("meta",{name:"docusaurus_locale",content:t}),n&&(0,a.jsx)("meta",{name:"docusaurus_version",content:n}),o&&(0,a.jsx)("meta",{name:"docusaurus_tag",content:o}),i&&(0,a.jsx)("meta",{name:"docsearch:language",content:i}),n&&(0,a.jsx)("meta",{name:"docsearch:version",content:n}),o&&(0,a.jsx)("meta",{name:"docsearch:docusaurus_tag",content:o})]})}},1122:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});var r=n(6540),a=n(4164),o=n(2303),i=n(5293);const l={themedComponent:"themedComponent_mlkZ","themedComponent--light":"themedComponent--light_NVdE","themedComponent--dark":"themedComponent--dark_xIcU"};var s=n(4848);function c(e){let{className:t,children:n}=e;const c=(0,o.A)(),{colorMode:u}=(0,i.G)();return(0,s.jsx)(s.Fragment,{children:(c?"dark"===u?["dark"]:["light"]:["light","dark"]).map((e=>{const o=n({theme:e,className:(0,a.A)(t,l.themedComponent,l[`themedComponent--${e}`])});return(0,s.jsx)(r.Fragment,{children:o},e)}))})}function u(e){const{sources:t,className:n,alt:r,...a}=e;return(0,s.jsx)(c,{className:n,children:e=>{let{theme:n,className:o}=e;return(0,s.jsx)("img",{src:t[n],alt:r,className:o,...a})}})}},1422:(e,t,n)=>{"use strict";n.d(t,{N:()=>b,u:()=>c});var r=n(6540),a=n(8193),o=n(205),i=n(3109),l=n(4848);const s="ease-in-out";function c(e){let{initialState:t}=e;const[n,a]=(0,r.useState)(t??!1),o=(0,r.useCallback)((()=>{a((e=>!e))}),[]);return{collapsed:n,setCollapsed:a,toggleCollapsed:o}}const u={display:"none",overflow:"hidden",height:"0px"},d={display:"block",overflow:"visible",height:"auto"};function p(e,t){const n=t?u:d;e.style.display=n.display,e.style.overflow=n.overflow,e.style.height=n.height}function f(e){let{collapsibleRef:t,collapsed:n,animation:a}=e;const o=(0,r.useRef)(!1);(0,r.useEffect)((()=>{const e=t.current;function r(){const t=e.scrollHeight,n=a?.duration??function(e){if((0,i.O)())return 1;const t=e/36;return Math.round(10*(4+15*t**.25+t/5))}(t);return{transition:`height ${n}ms ${a?.easing??s}`,height:`${t}px`}}function l(){const t=r();e.style.transition=t.transition,e.style.height=t.height}if(!o.current)return p(e,n),void(o.current=!0);return e.style.willChange="height",function(){const t=requestAnimationFrame((()=>{n?(l(),requestAnimationFrame((()=>{e.style.height=u.height,e.style.overflow=u.overflow}))):(e.style.display="block",requestAnimationFrame((()=>{l()})))}));return()=>cancelAnimationFrame(t)}()}),[t,n,a])}function m(e){if(!a.A.canUseDOM)return e?u:d}function h(e){let{as:t="div",collapsed:n,children:a,animation:o,onCollapseTransitionEnd:i,className:s,disableSSRStyle:c}=e;const u=(0,r.useRef)(null);return f({collapsibleRef:u,collapsed:n,animation:o}),(0,l.jsx)(t,{ref:u,style:c?void 0:m(n),onTransitionEnd:e=>{"height"===e.propertyName&&(p(u.current,n),i?.(n))},className:s,children:a})}function g(e){let{collapsed:t,...n}=e;const[a,i]=(0,r.useState)(!t),[s,c]=(0,r.useState)(t);return(0,o.A)((()=>{t||i(!0)}),[t]),(0,o.A)((()=>{a&&c(t)}),[a,t]),a?(0,l.jsx)(h,{...n,collapsed:s}):null}function b(e){let{lazy:t,...n}=e;const r=t?g:h;return(0,l.jsx)(r,{...n})}},5041:(e,t,n)=>{"use strict";n.d(t,{Mj:()=>h,oq:()=>m});var r=n(6540),a=n(2303),o=n(9466),i=n(9532),l=n(6342),s=n(4848);const c=(0,o.Wf)("docusaurus.announcement.dismiss"),u=(0,o.Wf)("docusaurus.announcement.id"),d=()=>"true"===c.get(),p=e=>c.set(String(e)),f=r.createContext(null);function m(e){let{children:t}=e;const n=function(){const{announcementBar:e}=(0,l.p)(),t=(0,a.A)(),[n,o]=(0,r.useState)((()=>!!t&&d()));(0,r.useEffect)((()=>{o(d())}),[]);const i=(0,r.useCallback)((()=>{p(!0),o(!0)}),[]);return(0,r.useEffect)((()=>{if(!e)return;const{id:t}=e;let n=u.get();"annoucement-bar"===n&&(n="announcement-bar");const r=t!==n;u.set(t),r&&p(!1),!r&&d()||o(!1)}),[e]),(0,r.useMemo)((()=>({isActive:!!e&&!n,close:i})),[e,n,i])}();return(0,s.jsx)(f.Provider,{value:n,children:t})}function h(){const e=(0,r.useContext)(f);if(!e)throw new i.dV("AnnouncementBarProvider");return e}},5293:(e,t,n)=>{"use strict";n.d(t,{G:()=>b,a:()=>g});var r=n(6540),a=n(8193),o=n(9532),i=n(9466),l=n(6342),s=n(4848);const c=r.createContext(void 0),u="theme",d=(0,i.Wf)(u),p={light:"light",dark:"dark"},f=e=>e===p.dark?p.dark:p.light,m=e=>a.A.canUseDOM?f(document.documentElement.getAttribute("data-theme")):f(e),h=e=>{d.set(f(e))};function g(e){let{children:t}=e;const n=function(){const{colorMode:{defaultMode:e,disableSwitch:t,respectPrefersColorScheme:n}}=(0,l.p)(),[a,o]=(0,r.useState)(m(e));(0,r.useEffect)((()=>{t&&d.del()}),[t]);const i=(0,r.useCallback)((function(t,r){void 0===r&&(r={});const{persist:a=!0}=r;t?(o(t),a&&h(t)):(o(n?window.matchMedia("(prefers-color-scheme: dark)").matches?p.dark:p.light:e),d.del())}),[n,e]);(0,r.useEffect)((()=>{document.documentElement.setAttribute("data-theme",f(a))}),[a]),(0,r.useEffect)((()=>{if(t)return;const e=e=>{if(e.key!==u)return;const t=d.get();null!==t&&i(f(t))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)}),[t,i]);const s=(0,r.useRef)(!1);return(0,r.useEffect)((()=>{if(t&&!n)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{window.matchMedia("print").matches||s.current?s.current=window.matchMedia("print").matches:i(null)};return e.addListener(r),()=>e.removeListener(r)}),[i,t,n]),(0,r.useMemo)((()=>({colorMode:a,setColorMode:i,get isDarkTheme(){return a===p.dark},setLightTheme(){i(p.light)},setDarkTheme(){i(p.dark)}})),[a,i])}();return(0,s.jsx)(c.Provider,{value:n,children:t})}function b(){const e=(0,r.useContext)(c);if(null==e)throw new o.dV("ColorModeProvider","Please see https://docusaurus.io/docs/api/themes/configuration#use-color-mode.");return e}},5597:(e,t,n)=>{"use strict";n.d(t,{VQ:()=>b,g1:()=>v});var r=n(6540),a=n(8295),o=n(7065),i=n(6342),l=n(1754),s=n(9532),c=n(9466),u=n(4848);const d=e=>`docs-preferred-version-${e}`,p={save:(e,t,n)=>{(0,c.Wf)(d(e),{persistence:t}).set(n)},read:(e,t)=>(0,c.Wf)(d(e),{persistence:t}).get(),clear:(e,t)=>{(0,c.Wf)(d(e),{persistence:t}).del()}},f=e=>Object.fromEntries(e.map((e=>[e,{preferredVersionName:null}])));const m=r.createContext(null);function h(){const e=(0,a.Gy)(),t=(0,i.p)().docs.versionPersistence,n=(0,r.useMemo)((()=>Object.keys(e)),[e]),[o,l]=(0,r.useState)((()=>f(n)));(0,r.useEffect)((()=>{l(function(e){let{pluginIds:t,versionPersistence:n,allDocsData:r}=e;function a(e){const t=p.read(e,n);return r[e].versions.some((e=>e.name===t))?{preferredVersionName:t}:(p.clear(e,n),{preferredVersionName:null})}return Object.fromEntries(t.map((e=>[e,a(e)])))}({allDocsData:e,versionPersistence:t,pluginIds:n}))}),[e,t,n]);return[o,(0,r.useMemo)((()=>({savePreferredVersion:function(e,n){p.save(e,t,n),l((t=>({...t,[e]:{preferredVersionName:n}})))}})),[t])]}function g(e){let{children:t}=e;const n=h();return(0,u.jsx)(m.Provider,{value:n,children:t})}function b(e){let{children:t}=e;return l.C5?(0,u.jsx)(g,{children:t}):(0,u.jsx)(u.Fragment,{children:t})}function y(){const e=(0,r.useContext)(m);if(!e)throw new s.dV("DocsPreferredVersionContextProvider");return e}function v(e){void 0===e&&(e=o.W);const t=(0,a.ht)(e),[n,i]=y(),{preferredVersionName:l}=n[e];return{preferredVersion:t.versions.find((e=>e.name===l))??null,savePreferredVersionName:(0,r.useCallback)((t=>{i.savePreferredVersion(e,t)}),[i,e])}}},4207:(e,t,n)=>{"use strict";n.d(t,{V:()=>s,t:()=>c});var r=n(6540),a=n(9532),o=n(4848);const i=Symbol("EmptyContext"),l=r.createContext(i);function s(e){let{children:t,name:n,items:a}=e;const i=(0,r.useMemo)((()=>n&&a?{name:n,items:a}:null),[n,a]);return(0,o.jsx)(l.Provider,{value:i,children:t})}function c(){const e=(0,r.useContext)(l);if(e===i)throw new a.dV("DocsSidebarProvider");return e}},2252:(e,t,n)=>{"use strict";n.d(t,{n:()=>l,r:()=>s});var r=n(6540),a=n(9532),o=n(4848);const i=r.createContext(null);function l(e){let{children:t,version:n}=e;return(0,o.jsx)(i.Provider,{value:n,children:t})}function s(){const e=(0,r.useContext)(i);if(null===e)throw new a.dV("DocsVersionProvider");return e}},9876:(e,t,n)=>{"use strict";n.d(t,{e:()=>f,M:()=>m});var r=n(6540),a=n(5600),o=n(4581),i=n(6347),l=n(9532);function s(e){!function(e){const t=(0,i.W6)(),n=(0,l._q)(e);(0,r.useEffect)((()=>t.block(((e,t)=>n(e,t)))),[t,n])}(((t,n)=>{if("POP"===n)return e(t,n)}))}var c=n(6342),u=n(4848);const d=r.createContext(void 0);function p(){const e=function(){const e=(0,a.YL)(),{items:t}=(0,c.p)().navbar;return 0===t.length&&!e.component}(),t=(0,o.l)(),n=!e&&"mobile"===t,[i,l]=(0,r.useState)(!1);s((()=>{if(i)return l(!1),!1}));const u=(0,r.useCallback)((()=>{l((e=>!e))}),[]);return(0,r.useEffect)((()=>{"desktop"===t&&l(!1)}),[t]),(0,r.useMemo)((()=>({disabled:e,shouldRender:n,toggle:u,shown:i})),[e,n,u,i])}function f(e){let{children:t}=e;const n=p();return(0,u.jsx)(d.Provider,{value:n,children:t})}function m(){const e=r.useContext(d);if(void 0===e)throw new l.dV("NavbarMobileSidebarProvider");return e}},5600:(e,t,n)=>{"use strict";n.d(t,{GX:()=>c,YL:()=>s,y_:()=>l});var r=n(6540),a=n(9532),o=n(4848);const i=r.createContext(null);function l(e){let{children:t}=e;const n=(0,r.useState)({component:null,props:null});return(0,o.jsx)(i.Provider,{value:n,children:t})}function s(){const e=(0,r.useContext)(i);if(!e)throw new a.dV("NavbarSecondaryMenuContentProvider");return e[0]}function c(e){let{component:t,props:n}=e;const o=(0,r.useContext)(i);if(!o)throw new a.dV("NavbarSecondaryMenuContentProvider");const[,l]=o,s=(0,a.Be)(n);return(0,r.useEffect)((()=>{l({component:t,props:s})}),[l,t,s]),(0,r.useEffect)((()=>()=>l({component:null,props:null})),[l]),null}},4090:(e,t,n)=>{"use strict";n.d(t,{w:()=>a,J:()=>o});var r=n(6540);const a="navigation-with-keyboard";function o(){(0,r.useEffect)((()=>{function e(e){"keydown"===e.type&&"Tab"===e.key&&document.body.classList.add(a),"mousedown"===e.type&&document.body.classList.remove(a)}return document.addEventListener("keydown",e),document.addEventListener("mousedown",e),()=>{document.body.classList.remove(a),document.removeEventListener("keydown",e),document.removeEventListener("mousedown",e)}}),[])}},4581:(e,t,n)=>{"use strict";n.d(t,{l:()=>l});var r=n(6540),a=n(8193);const o={desktop:"desktop",mobile:"mobile",ssr:"ssr"},i=996;function l(){const[e,t]=(0,r.useState)((()=>"ssr"));return(0,r.useEffect)((()=>{function e(){t(function(){if(!a.A.canUseDOM)throw new Error("getWindowSize() should only be called after React hydration");return window.innerWidth>i?o.desktop:o.mobile}())}return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),e}},7559:(e,t,n)=>{"use strict";n.d(t,{G:()=>r});const r={page:{blogListPage:"blog-list-page",blogPostPage:"blog-post-page",blogTagsListPage:"blog-tags-list-page",blogTagPostListPage:"blog-tags-post-list-page",docsDocPage:"docs-doc-page",docsTagsListPage:"docs-tags-list-page",docsTagDocListPage:"docs-tags-doc-list-page",mdxPage:"mdx-page"},wrapper:{main:"main-wrapper",blogPages:"blog-wrapper",docsPages:"docs-wrapper",mdxPages:"mdx-wrapper"},common:{editThisPage:"theme-edit-this-page",lastUpdated:"theme-last-updated",backToTopButton:"theme-back-to-top-button",codeBlock:"theme-code-block",admonition:"theme-admonition",unlistedBanner:"theme-unlisted-banner",admonitionType:e=>`theme-admonition-${e}`},layout:{},docs:{docVersionBanner:"theme-doc-version-banner",docVersionBadge:"theme-doc-version-badge",docBreadcrumbs:"theme-doc-breadcrumbs",docMarkdown:"theme-doc-markdown",docTocMobile:"theme-doc-toc-mobile",docTocDesktop:"theme-doc-toc-desktop",docFooter:"theme-doc-footer",docFooterTagsRow:"theme-doc-footer-tags-row",docFooterEditMetaRow:"theme-doc-footer-edit-meta-row",docSidebarContainer:"theme-doc-sidebar-container",docSidebarMenu:"theme-doc-sidebar-menu",docSidebarItemCategory:"theme-doc-sidebar-item-category",docSidebarItemLink:"theme-doc-sidebar-item-link",docSidebarItemCategoryLevel:e=>`theme-doc-sidebar-item-category-level-${e}`,docSidebarItemLinkLevel:e=>`theme-doc-sidebar-item-link-level-${e}`},blog:{}}},3109:(e,t,n)=>{"use strict";function r(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}n.d(t,{O:()=>r})},1754:(e,t,n)=>{"use strict";n.d(t,{Nr:()=>f,w8:()=>g,C5:()=>p,B5:()=>E,Vd:()=>x,QB:()=>S,fW:()=>k,OF:()=>w,Y:()=>y});var r=n(6540),a=n(6347),o=n(2831),i=n(8295),l=n(5597),s=n(2252),c=n(4207);function u(e){return Array.from(new Set(e))}var d=n(9169);const p=!!i.Gy;function f(e){return"link"!==e.type||e.unlisted?"category"===e.type?function(e){if(e.href&&!e.linkUnlisted)return e.href;for(const t of e.items){const e=f(t);if(e)return e}}(e):void 0:e.href}const m=(e,t)=>void 0!==e&&(0,d.ys)(e,t),h=(e,t)=>e.some((e=>g(e,t)));function g(e,t){return"link"===e.type?m(e.href,t):"category"===e.type&&(m(e.href,t)||h(e.items,t))}function b(e,t){switch(e.type){case"category":return g(e,t)||e.items.some((e=>b(e,t)));case"link":return!e.unlisted||g(e,t);default:return!0}}function y(e,t){return(0,r.useMemo)((()=>e.filter((e=>b(e,t)))),[e,t])}function v(e){let{sidebarItems:t,pathname:n,onlyCategories:r=!1}=e;const a=[];return function e(t){for(const o of t)if("category"===o.type&&((0,d.ys)(o.href,n)||e(o.items))||"link"===o.type&&(0,d.ys)(o.href,n)){return r&&"category"!==o.type||a.unshift(o),!0}return!1}(t),a}function w(){const e=(0,c.t)(),{pathname:t}=(0,a.zy)(),n=(0,i.vT)()?.pluginData.breadcrumbs;return!1!==n&&e?v({sidebarItems:e.items,pathname:t}):null}function x(e){const{activeVersion:t}=(0,i.zK)(e),{preferredVersion:n}=(0,l.g1)(e),a=(0,i.r7)(e);return(0,r.useMemo)((()=>u([t,n,a].filter(Boolean))),[t,n,a])}function k(e,t){const n=x(t);return(0,r.useMemo)((()=>{const t=n.flatMap((e=>e.sidebars?Object.entries(e.sidebars):[])),r=t.find((t=>t[0]===e));if(!r)throw new Error(`Can't find any sidebar with id "${e}" in version${n.length>1?"s":""} ${n.map((e=>e.name)).join(", ")}".\nAvailable sidebar ids are:\n- ${t.map((e=>e[0])).join("\n- ")}`);return r[1]}),[e,n])}function S(e,t){const n=x(t);return(0,r.useMemo)((()=>{const t=n.flatMap((e=>e.docs)),r=t.find((t=>t.id===e));if(!r){if(n.flatMap((e=>e.draftIds)).includes(e))return null;throw new Error(`Couldn't find any doc with id "${e}" in version${n.length>1?"s":""} "${n.map((e=>e.name)).join(", ")}".\nAvailable doc ids are:\n- ${u(t.map((e=>e.id))).join("\n- ")}`)}return r}),[e,n])}function E(e){let{route:t}=e;const n=(0,a.zy)(),r=(0,s.r)(),i=t.routes,l=i.find((e=>(0,a.B6)(n.pathname,e)));if(!l)return null;const c=l.sidebar,u=c?r.docsSidebars[c]:void 0;return{docElement:(0,o.v)(i),sidebarName:c,sidebarItems:u}}},1003:(e,t,n)=>{"use strict";n.d(t,{e3:()=>f,be:()=>d,Jx:()=>m});var r=n(6540),a=n(4164),o=n(5260),i=n(3102);function l(){const e=r.useContext(i.o);if(!e)throw new Error("Unexpected: no Docusaurus route context found");return e}var s=n(6025),c=n(4586);var u=n(4848);function d(e){let{title:t,description:n,keywords:r,image:a,children:i}=e;const l=function(e){const{siteConfig:t}=(0,c.A)(),{title:n,titleDelimiter:r}=t;return e?.trim().length?`${e.trim()} ${r} ${n}`:n}(t),{withBaseUrl:d}=(0,s.h)(),p=a?d(a,{absolute:!0}):void 0;return(0,u.jsxs)(o.A,{children:[t&&(0,u.jsx)("title",{children:l}),t&&(0,u.jsx)("meta",{property:"og:title",content:l}),n&&(0,u.jsx)("meta",{name:"description",content:n}),n&&(0,u.jsx)("meta",{property:"og:description",content:n}),r&&(0,u.jsx)("meta",{name:"keywords",content:Array.isArray(r)?r.join(","):r}),p&&(0,u.jsx)("meta",{property:"og:image",content:p}),p&&(0,u.jsx)("meta",{name:"twitter:image",content:p}),i]})}const p=r.createContext(void 0);function f(e){let{className:t,children:n}=e;const i=r.useContext(p),l=(0,a.A)(i,t);return(0,u.jsxs)(p.Provider,{value:l,children:[(0,u.jsx)(o.A,{children:(0,u.jsx)("html",{className:l})}),n]})}function m(e){let{children:t}=e;const n=l(),r=`plugin-${n.plugin.name.replace(/docusaurus-(?:plugin|theme)-(?:content-)?/gi,"")}`;const o=`plugin-id-${n.plugin.id}`;return(0,u.jsx)(f,{className:(0,a.A)(r,o),children:t})}},9532:(e,t,n)=>{"use strict";n.d(t,{Be:()=>c,ZC:()=>l,_q:()=>i,dV:()=>s,fM:()=>u});var r=n(6540),a=n(205),o=n(4848);function i(e){const t=(0,r.useRef)(e);return(0,a.A)((()=>{t.current=e}),[e]),(0,r.useCallback)((function(){return t.current(...arguments)}),[])}function l(e){const t=(0,r.useRef)();return(0,a.A)((()=>{t.current=e})),t.current}class s extends Error{constructor(e,t){super(),this.name="ReactContextError",this.message=`Hook ${this.stack?.split("\n")[1]?.match(/at (?:\w+\.)?(?\w+)/)?.groups.name??""} is called outside the <${e}>. ${t??""}`}}function c(e){const t=Object.entries(e);return t.sort(((e,t)=>e[0].localeCompare(t[0]))),(0,r.useMemo)((()=>e),t.flat())}function u(e){return t=>{let{children:n}=t;return(0,o.jsx)(o.Fragment,{children:e.reduceRight(((e,t)=>(0,o.jsx)(t,{children:e})),n)})}}},9169:(e,t,n)=>{"use strict";n.d(t,{Dt:()=>l,ys:()=>i});var r=n(6540),a=n(8328),o=n(4586);function i(e,t){const n=e=>(!e||e.endsWith("/")?e:`${e}/`)?.toLowerCase();return n(e)===n(t)}function l(){const{baseUrl:e}=(0,o.A)().siteConfig;return(0,r.useMemo)((()=>function(e){let{baseUrl:t,routes:n}=e;function r(e){return e.path===t&&!0===e.exact}function a(e){return e.path===t&&!e.exact}return function e(t){if(0===t.length)return;return t.find(r)||e(t.filter(a).flatMap((e=>e.routes??[])))}(n)}({routes:a.A,baseUrl:e})),[e])}},3104:(e,t,n)=>{"use strict";n.d(t,{Mq:()=>p,Tv:()=>c,gk:()=>f});var r=n(6540),a=n(8193),o=n(2303),i=(n(205),n(9532)),l=n(4848);const s=r.createContext(void 0);function c(e){let{children:t}=e;const n=function(){const e=(0,r.useRef)(!0);return(0,r.useMemo)((()=>({scrollEventsEnabledRef:e,enableScrollEvents:()=>{e.current=!0},disableScrollEvents:()=>{e.current=!1}})),[])}();return(0,l.jsx)(s.Provider,{value:n,children:t})}function u(){const e=(0,r.useContext)(s);if(null==e)throw new i.dV("ScrollControllerProvider");return e}const d=()=>a.A.canUseDOM?{scrollX:window.pageXOffset,scrollY:window.pageYOffset}:null;function p(e,t){void 0===t&&(t=[]);const{scrollEventsEnabledRef:n}=u(),a=(0,r.useRef)(d()),o=(0,i._q)(e);(0,r.useEffect)((()=>{const e=()=>{if(!n.current)return;const e=d();o(e,a.current),a.current=e},t={passive:!0};return e(),window.addEventListener("scroll",e,t),()=>window.removeEventListener("scroll",e,t)}),[o,n,...t])}function f(){const e=(0,r.useRef)(null),t=(0,o.A)()&&"smooth"===getComputedStyle(document.documentElement).scrollBehavior;return{startScroll:n=>{e.current=t?function(e){return window.scrollTo({top:e,behavior:"smooth"}),()=>{}}(n):function(e){let t=null;const n=document.documentElement.scrollTop>e;return function r(){const a=document.documentElement.scrollTop;(n&&a>e||!n&&at&&cancelAnimationFrame(t)}(n)},cancelScroll:()=>e.current?.()}}},2967:(e,t,n)=>{"use strict";n.d(t,{Cy:()=>r,tU:()=>a});n(4586);const r="default";function a(e,t){return`docs-${e}-${t}`}},9466:(e,t,n)=>{"use strict";n.d(t,{Wf:()=>s});n(6540);const r="localStorage";function a(e){let{key:t,oldValue:n,newValue:r,storage:a}=e;if(n===r)return;const o=document.createEvent("StorageEvent");o.initStorageEvent("storage",!1,!1,t,n,r,window.location.href,a),window.dispatchEvent(o)}function o(e){if(void 0===e&&(e=r),"undefined"==typeof window)throw new Error("Browser storage is not available on Node.js/Docusaurus SSR process.");if("none"===e)return null;try{return window[e]}catch(n){return t=n,i||(console.warn("Docusaurus browser storage is not available.\nPossible reasons: running Docusaurus in an iframe, in an incognito browser session, or using too strict browser privacy settings.",t),i=!0),null}var t}let i=!1;const l={get:()=>null,set:()=>{},del:()=>{},listen:()=>()=>{}};function s(e,t){if("undefined"==typeof window)return function(e){function t(){throw new Error(`Illegal storage API usage for storage key "${e}".\nDocusaurus storage APIs are not supposed to be called on the server-rendering process.\nPlease only call storage APIs in effects and event handlers.`)}return{get:t,set:t,del:t,listen:t}}(e);const n=o(t?.persistence);return null===n?l:{get:()=>{try{return n.getItem(e)}catch(t){return console.error(`Docusaurus storage error, can't get key=${e}`,t),null}},set:t=>{try{const r=n.getItem(e);n.setItem(e,t),a({key:e,oldValue:r,newValue:t,storage:n})}catch(r){console.error(`Docusaurus storage error, can't set ${e}=${t}`,r)}},del:()=>{try{const t=n.getItem(e);n.removeItem(e),a({key:e,oldValue:t,newValue:null,storage:n})}catch(t){console.error(`Docusaurus storage error, can't delete key=${e}`,t)}},listen:t=>{try{const r=r=>{r.storageArea===n&&r.key===e&&t(r)};return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)}catch(r){return console.error(`Docusaurus storage error, can't listen for changes of key=${e}`,r),()=>{}}}}}},2131:(e,t,n)=>{"use strict";n.d(t,{o:()=>i});var r=n(4586),a=n(6347),o=n(440);function i(){const{siteConfig:{baseUrl:e,url:t,trailingSlash:n},i18n:{defaultLocale:i,currentLocale:l}}=(0,r.A)(),{pathname:s}=(0,a.zy)(),c=(0,o.applyTrailingSlash)(s,{trailingSlash:n,baseUrl:e}),u=l===i?e:e.replace(`/${l}/`,"/"),d=c.replace(e,"");return{createUrl:function(e){let{locale:n,fullyQualified:r}=e;return`${r?t:""}${function(e){return e===i?`${u}`:`${u}${e}/`}(n)}${d}`}}}},5062:(e,t,n)=>{"use strict";n.d(t,{$:()=>i});var r=n(6540),a=n(6347),o=n(9532);function i(e){const t=(0,a.zy)(),n=(0,o.ZC)(t),i=(0,o._q)(e);(0,r.useEffect)((()=>{n&&t!==n&&i({location:t,previousLocation:n})}),[i,t,n])}},6342:(e,t,n)=>{"use strict";n.d(t,{p:()=>a});var r=n(4586);function a(){return(0,r.A)().siteConfig.themeConfig}},2983:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){const{trailingSlash:n,baseUrl:r}=t;if(e.startsWith("#"))return e;if(void 0===n)return e;const[a]=e.split(/[#?]/),o="/"===a||a===r?a:(i=a,n?function(e){return e.endsWith("/")?e:`${e}/`}(i):function(e){return e.endsWith("/")?e.slice(0,-1):e}(i));var i;return e.replace(a,o)}},253:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorCausalChain=void 0,t.getErrorCausalChain=function e(t){return t.cause?[t,...e(t.cause)]:[t]}},440:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorCausalChain=t.applyTrailingSlash=t.blogPostContainerID=void 0,t.blogPostContainerID="__blog-post-container";var a=n(2983);Object.defineProperty(t,"applyTrailingSlash",{enumerable:!0,get:function(){return r(a).default}});var o=n(253);Object.defineProperty(t,"getErrorCausalChain",{enumerable:!0,get:function(){return o.getErrorCausalChain}})},1513:(e,t,n)=>{"use strict";n.d(t,{zR:()=>w,TM:()=>C,yJ:()=>f,sC:()=>A,AO:()=>p});var r=n(8168);function a(e){return"/"===e.charAt(0)}function o(e,t){for(var n=t,r=n+1,a=e.length;r=0;p--){var f=i[p];"."===f?o(i,p):".."===f?(o(i,p),d++):d&&(o(i,p),d--)}if(!c)for(;d--;d)i.unshift("..");!c||""===i[0]||i[0]&&a(i[0])||i.unshift("");var m=i.join("/");return n&&"/"!==m.substr(-1)&&(m+="/"),m};var l=n(1561);function s(e){return"/"===e.charAt(0)?e:"/"+e}function c(e){return"/"===e.charAt(0)?e.substr(1):e}function u(e,t){return function(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}(e,t)?e.substr(t.length):e}function d(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function p(e){var t=e.pathname,n=e.search,r=e.hash,a=t||"/";return n&&"?"!==n&&(a+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(a+="#"===r.charAt(0)?r:"#"+r),a}function f(e,t,n,a){var o;"string"==typeof e?(o=function(e){var t=e||"/",n="",r="",a=t.indexOf("#");-1!==a&&(r=t.substr(a),t=t.substr(0,a));var o=t.indexOf("?");return-1!==o&&(n=t.substr(o),t=t.substr(0,o)),{pathname:t,search:"?"===n?"":n,hash:"#"===r?"":r}}(e),o.state=t):(void 0===(o=(0,r.A)({},e)).pathname&&(o.pathname=""),o.search?"?"!==o.search.charAt(0)&&(o.search="?"+o.search):o.search="",o.hash?"#"!==o.hash.charAt(0)&&(o.hash="#"+o.hash):o.hash="",void 0!==t&&void 0===o.state&&(o.state=t));try{o.pathname=decodeURI(o.pathname)}catch(l){throw l instanceof URIError?new URIError('Pathname "'+o.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):l}return n&&(o.key=n),a?o.pathname?"/"!==o.pathname.charAt(0)&&(o.pathname=i(o.pathname,a.pathname)):o.pathname=a.pathname:o.pathname||(o.pathname="/"),o}function m(){var e=null;var t=[];return{setPrompt:function(t){return e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,r,a){if(null!=e){var o="function"==typeof e?e(t,n):e;"string"==typeof o?"function"==typeof r?r(o,a):a(!0):a(!1!==o)}else a(!0)},appendListener:function(e){var n=!0;function r(){n&&e.apply(void 0,arguments)}return t.push(r),function(){n=!1,t=t.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),r=0;rt?n.splice(t,n.length-t,a):n.push(a),d({action:r,location:a,index:t,entries:n})}}))},replace:function(e,t){var r="REPLACE",a=f(e,t,h(),w.location);u.confirmTransitionTo(a,r,n,(function(e){e&&(w.entries[w.index]=a,d({action:r,location:a}))}))},go:v,goBack:function(){v(-1)},goForward:function(){v(1)},canGo:function(e){var t=w.index+e;return t>=0&&t{"use strict";var r=n(4363),a={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},i={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},l={};function s(e){return r.isMemo(e)?i:l[e.$$typeof]||a}l[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},l[r.Memo]=i;var c=Object.defineProperty,u=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,p=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,m=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(m){var a=f(n);a&&a!==m&&e(t,a,r)}var i=u(n);d&&(i=i.concat(d(n)));for(var l=s(t),h=s(n),g=0;g{"use strict";e.exports=function(e,t,n,r,a,o,i,l){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,a,o,i,l],u=0;(s=new Error(t.replace(/%s/g,(function(){return c[u++]})))).name="Invariant Violation"}throw s.framesToPop=1,s}}},4634:e=>{e.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},689:function(e){e.exports=function(){"use strict";var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},n=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1])||arguments[1],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5e3;t(this,e),this.ctx=n,this.iframes=r,this.exclude=a,this.iframesTimeout=o}return n(e,[{key:"getContexts",value:function(){var e=[];return(void 0!==this.ctx&&this.ctx?NodeList.prototype.isPrototypeOf(this.ctx)?Array.prototype.slice.call(this.ctx):Array.isArray(this.ctx)?this.ctx:"string"==typeof this.ctx?Array.prototype.slice.call(document.querySelectorAll(this.ctx)):[this.ctx]:[]).forEach((function(t){var n=e.filter((function(e){return e.contains(t)})).length>0;-1!==e.indexOf(t)||n||e.push(t)})),e}},{key:"getIframeContents",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},r=void 0;try{var a=e.contentWindow;if(r=a.document,!a||!r)throw new Error("iframe inaccessible")}catch(o){n()}r&&t(r)}},{key:"isIframeBlank",value:function(e){var t="about:blank",n=e.getAttribute("src").trim();return e.contentWindow.location.href===t&&n!==t&&n}},{key:"observeIframeLoad",value:function(e,t,n){var r=this,a=!1,o=null,i=function i(){if(!a){a=!0,clearTimeout(o);try{r.isIframeBlank(e)||(e.removeEventListener("load",i),r.getIframeContents(e,t,n))}catch(l){n()}}};e.addEventListener("load",i),o=setTimeout(i,this.iframesTimeout)}},{key:"onIframeReady",value:function(e,t,n){try{"complete"===e.contentWindow.document.readyState?this.isIframeBlank(e)?this.observeIframeLoad(e,t,n):this.getIframeContents(e,t,n):this.observeIframeLoad(e,t,n)}catch(r){n()}}},{key:"waitForIframes",value:function(e,t){var n=this,r=0;this.forEachIframe(e,(function(){return!0}),(function(e){r++,n.waitForIframes(e.querySelector("html"),(function(){--r||t()}))}),(function(e){e||t()}))}},{key:"forEachIframe",value:function(t,n,r){var a=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},i=t.querySelectorAll("iframe"),l=i.length,s=0;i=Array.prototype.slice.call(i);var c=function(){--l<=0&&o(s)};l||c(),i.forEach((function(t){e.matches(t,a.exclude)?c():a.onIframeReady(t,(function(e){n(t)&&(s++,r(e)),c()}),c)}))}},{key:"createIterator",value:function(e,t,n){return document.createNodeIterator(e,t,n,!1)}},{key:"createInstanceOnIframe",value:function(t){return new e(t.querySelector("html"),this.iframes)}},{key:"compareNodeIframe",value:function(e,t,n){if(e.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_PRECEDING){if(null===t)return!0;if(t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING)return!0}return!1}},{key:"getIteratorNode",value:function(e){var t=e.previousNode();return{prevNode:t,node:(null===t||e.nextNode())&&e.nextNode()}}},{key:"checkIframeFilter",value:function(e,t,n,r){var a=!1,o=!1;return r.forEach((function(e,t){e.val===n&&(a=t,o=e.handled)})),this.compareNodeIframe(e,t,n)?(!1!==a||o?!1===a||o||(r[a].handled=!0):r.push({val:n,handled:!0}),!0):(!1===a&&r.push({val:n,handled:!1}),!1)}},{key:"handleOpenIframes",value:function(e,t,n,r){var a=this;e.forEach((function(e){e.handled||a.getIframeContents(e.val,(function(e){a.createInstanceOnIframe(e).forEachNode(t,n,r)}))}))}},{key:"iterateThroughNodes",value:function(e,t,n,r,a){for(var o=this,i=this.createIterator(t,e,r),l=[],s=[],c=void 0,u=void 0,d=function(){var e=o.getIteratorNode(i);return u=e.prevNode,c=e.node};d();)this.iframes&&this.forEachIframe(t,(function(e){return o.checkIframeFilter(c,u,e,l)}),(function(t){o.createInstanceOnIframe(t).forEachNode(e,(function(e){return s.push(e)}),r)})),s.push(c);s.forEach((function(e){n(e)})),this.iframes&&this.handleOpenIframes(l,e,n,r),a()}},{key:"forEachNode",value:function(e,t,n){var r=this,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},o=this.getContexts(),i=o.length;i||a(),o.forEach((function(o){var l=function(){r.iterateThroughNodes(e,o,t,n,(function(){--i<=0&&a()}))};r.iframes?r.waitForIframes(o,l):l()}))}}],[{key:"matches",value:function(e,t){var n="string"==typeof t?[t]:t,r=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector;if(r){var a=!1;return n.every((function(t){return!r.call(e,t)||(a=!0,!1)})),a}return!1}}]),e}(),o=function(){function o(e){t(this,o),this.ctx=e,this.ie=!1;var n=window.navigator.userAgent;(n.indexOf("MSIE")>-1||n.indexOf("Trident")>-1)&&(this.ie=!0)}return n(o,[{key:"log",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"debug",r=this.opt.log;this.opt.debug&&"object"===(void 0===r?"undefined":e(r))&&"function"==typeof r[n]&&r[n]("mark.js: "+t)}},{key:"escapeStr",value:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}},{key:"createRegExp",value:function(e){return"disabled"!==this.opt.wildcards&&(e=this.setupWildcardsRegExp(e)),e=this.escapeStr(e),Object.keys(this.opt.synonyms).length&&(e=this.createSynonymsRegExp(e)),(this.opt.ignoreJoiners||this.opt.ignorePunctuation.length)&&(e=this.setupIgnoreJoinersRegExp(e)),this.opt.diacritics&&(e=this.createDiacriticsRegExp(e)),e=this.createMergedBlanksRegExp(e),(this.opt.ignoreJoiners||this.opt.ignorePunctuation.length)&&(e=this.createJoinersRegExp(e)),"disabled"!==this.opt.wildcards&&(e=this.createWildcardsRegExp(e)),e=this.createAccuracyRegExp(e)}},{key:"createSynonymsRegExp",value:function(e){var t=this.opt.synonyms,n=this.opt.caseSensitive?"":"i",r=this.opt.ignoreJoiners||this.opt.ignorePunctuation.length?"\0":"";for(var a in t)if(t.hasOwnProperty(a)){var o=t[a],i="disabled"!==this.opt.wildcards?this.setupWildcardsRegExp(a):this.escapeStr(a),l="disabled"!==this.opt.wildcards?this.setupWildcardsRegExp(o):this.escapeStr(o);""!==i&&""!==l&&(e=e.replace(new RegExp("("+this.escapeStr(i)+"|"+this.escapeStr(l)+")","gm"+n),r+"("+this.processSynomyms(i)+"|"+this.processSynomyms(l)+")"+r))}return e}},{key:"processSynomyms",value:function(e){return(this.opt.ignoreJoiners||this.opt.ignorePunctuation.length)&&(e=this.setupIgnoreJoinersRegExp(e)),e}},{key:"setupWildcardsRegExp",value:function(e){return(e=e.replace(/(?:\\)*\?/g,(function(e){return"\\"===e.charAt(0)?"?":"\x01"}))).replace(/(?:\\)*\*/g,(function(e){return"\\"===e.charAt(0)?"*":"\x02"}))}},{key:"createWildcardsRegExp",value:function(e){var t="withSpaces"===this.opt.wildcards;return e.replace(/\u0001/g,t?"[\\S\\s]?":"\\S?").replace(/\u0002/g,t?"[\\S\\s]*?":"\\S*")}},{key:"setupIgnoreJoinersRegExp",value:function(e){return e.replace(/[^(|)\\]/g,(function(e,t,n){var r=n.charAt(t+1);return/[(|)\\]/.test(r)||""===r?e:e+"\0"}))}},{key:"createJoinersRegExp",value:function(e){var t=[],n=this.opt.ignorePunctuation;return Array.isArray(n)&&n.length&&t.push(this.escapeStr(n.join(""))),this.opt.ignoreJoiners&&t.push("\\u00ad\\u200b\\u200c\\u200d"),t.length?e.split(/\u0000+/).join("["+t.join("")+"]*"):e}},{key:"createDiacriticsRegExp",value:function(e){var t=this.opt.caseSensitive?"":"i",n=this.opt.caseSensitive?["a\xe0\xe1\u1ea3\xe3\u1ea1\u0103\u1eb1\u1eaf\u1eb3\u1eb5\u1eb7\xe2\u1ea7\u1ea5\u1ea9\u1eab\u1ead\xe4\xe5\u0101\u0105","A\xc0\xc1\u1ea2\xc3\u1ea0\u0102\u1eb0\u1eae\u1eb2\u1eb4\u1eb6\xc2\u1ea6\u1ea4\u1ea8\u1eaa\u1eac\xc4\xc5\u0100\u0104","c\xe7\u0107\u010d","C\xc7\u0106\u010c","d\u0111\u010f","D\u0110\u010e","e\xe8\xe9\u1ebb\u1ebd\u1eb9\xea\u1ec1\u1ebf\u1ec3\u1ec5\u1ec7\xeb\u011b\u0113\u0119","E\xc8\xc9\u1eba\u1ebc\u1eb8\xca\u1ec0\u1ebe\u1ec2\u1ec4\u1ec6\xcb\u011a\u0112\u0118","i\xec\xed\u1ec9\u0129\u1ecb\xee\xef\u012b","I\xcc\xcd\u1ec8\u0128\u1eca\xce\xcf\u012a","l\u0142","L\u0141","n\xf1\u0148\u0144","N\xd1\u0147\u0143","o\xf2\xf3\u1ecf\xf5\u1ecd\xf4\u1ed3\u1ed1\u1ed5\u1ed7\u1ed9\u01a1\u1edf\u1ee1\u1edb\u1edd\u1ee3\xf6\xf8\u014d","O\xd2\xd3\u1ece\xd5\u1ecc\xd4\u1ed2\u1ed0\u1ed4\u1ed6\u1ed8\u01a0\u1ede\u1ee0\u1eda\u1edc\u1ee2\xd6\xd8\u014c","r\u0159","R\u0158","s\u0161\u015b\u0219\u015f","S\u0160\u015a\u0218\u015e","t\u0165\u021b\u0163","T\u0164\u021a\u0162","u\xf9\xfa\u1ee7\u0169\u1ee5\u01b0\u1eeb\u1ee9\u1eed\u1eef\u1ef1\xfb\xfc\u016f\u016b","U\xd9\xda\u1ee6\u0168\u1ee4\u01af\u1eea\u1ee8\u1eec\u1eee\u1ef0\xdb\xdc\u016e\u016a","y\xfd\u1ef3\u1ef7\u1ef9\u1ef5\xff","Y\xdd\u1ef2\u1ef6\u1ef8\u1ef4\u0178","z\u017e\u017c\u017a","Z\u017d\u017b\u0179"]:["a\xe0\xe1\u1ea3\xe3\u1ea1\u0103\u1eb1\u1eaf\u1eb3\u1eb5\u1eb7\xe2\u1ea7\u1ea5\u1ea9\u1eab\u1ead\xe4\xe5\u0101\u0105A\xc0\xc1\u1ea2\xc3\u1ea0\u0102\u1eb0\u1eae\u1eb2\u1eb4\u1eb6\xc2\u1ea6\u1ea4\u1ea8\u1eaa\u1eac\xc4\xc5\u0100\u0104","c\xe7\u0107\u010dC\xc7\u0106\u010c","d\u0111\u010fD\u0110\u010e","e\xe8\xe9\u1ebb\u1ebd\u1eb9\xea\u1ec1\u1ebf\u1ec3\u1ec5\u1ec7\xeb\u011b\u0113\u0119E\xc8\xc9\u1eba\u1ebc\u1eb8\xca\u1ec0\u1ebe\u1ec2\u1ec4\u1ec6\xcb\u011a\u0112\u0118","i\xec\xed\u1ec9\u0129\u1ecb\xee\xef\u012bI\xcc\xcd\u1ec8\u0128\u1eca\xce\xcf\u012a","l\u0142L\u0141","n\xf1\u0148\u0144N\xd1\u0147\u0143","o\xf2\xf3\u1ecf\xf5\u1ecd\xf4\u1ed3\u1ed1\u1ed5\u1ed7\u1ed9\u01a1\u1edf\u1ee1\u1edb\u1edd\u1ee3\xf6\xf8\u014dO\xd2\xd3\u1ece\xd5\u1ecc\xd4\u1ed2\u1ed0\u1ed4\u1ed6\u1ed8\u01a0\u1ede\u1ee0\u1eda\u1edc\u1ee2\xd6\xd8\u014c","r\u0159R\u0158","s\u0161\u015b\u0219\u015fS\u0160\u015a\u0218\u015e","t\u0165\u021b\u0163T\u0164\u021a\u0162","u\xf9\xfa\u1ee7\u0169\u1ee5\u01b0\u1eeb\u1ee9\u1eed\u1eef\u1ef1\xfb\xfc\u016f\u016bU\xd9\xda\u1ee6\u0168\u1ee4\u01af\u1eea\u1ee8\u1eec\u1eee\u1ef0\xdb\xdc\u016e\u016a","y\xfd\u1ef3\u1ef7\u1ef9\u1ef5\xffY\xdd\u1ef2\u1ef6\u1ef8\u1ef4\u0178","z\u017e\u017c\u017aZ\u017d\u017b\u0179"],r=[];return e.split("").forEach((function(a){n.every((function(n){if(-1!==n.indexOf(a)){if(r.indexOf(n)>-1)return!1;e=e.replace(new RegExp("["+n+"]","gm"+t),"["+n+"]"),r.push(n)}return!0}))})),e}},{key:"createMergedBlanksRegExp",value:function(e){return e.replace(/[\s]+/gim,"[\\s]+")}},{key:"createAccuracyRegExp",value:function(e){var t=this,n="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\xa1\xbf",r=this.opt.accuracy,a="string"==typeof r?r:r.value,o="string"==typeof r?[]:r.limiters,i="";switch(o.forEach((function(e){i+="|"+t.escapeStr(e)})),a){case"partially":default:return"()("+e+")";case"complementary":return"()([^"+(i="\\s"+(i||this.escapeStr(n)))+"]*"+e+"[^"+i+"]*)";case"exactly":return"(^|\\s"+i+")("+e+")(?=$|\\s"+i+")"}}},{key:"getSeparatedKeywords",value:function(e){var t=this,n=[];return e.forEach((function(e){t.opt.separateWordSearch?e.split(" ").forEach((function(e){e.trim()&&-1===n.indexOf(e)&&n.push(e)})):e.trim()&&-1===n.indexOf(e)&&n.push(e)})),{keywords:n.sort((function(e,t){return t.length-e.length})),length:n.length}}},{key:"isNumeric",value:function(e){return Number(parseFloat(e))==e}},{key:"checkRanges",value:function(e){var t=this;if(!Array.isArray(e)||"[object Object]"!==Object.prototype.toString.call(e[0]))return this.log("markRanges() will only accept an array of objects"),this.opt.noMatch(e),[];var n=[],r=0;return e.sort((function(e,t){return e.start-t.start})).forEach((function(e){var a=t.callNoMatchOnInvalidRanges(e,r),o=a.start,i=a.end;a.valid&&(e.start=o,e.length=i-o,n.push(e),r=i)})),n}},{key:"callNoMatchOnInvalidRanges",value:function(e,t){var n=void 0,r=void 0,a=!1;return e&&void 0!==e.start?(r=(n=parseInt(e.start,10))+parseInt(e.length,10),this.isNumeric(e.start)&&this.isNumeric(e.length)&&r-t>0&&r-n>0?a=!0:(this.log("Ignoring invalid or overlapping range: "+JSON.stringify(e)),this.opt.noMatch(e))):(this.log("Ignoring invalid range: "+JSON.stringify(e)),this.opt.noMatch(e)),{start:n,end:r,valid:a}}},{key:"checkWhitespaceRanges",value:function(e,t,n){var r=void 0,a=!0,o=n.length,i=t-o,l=parseInt(e.start,10)-i;return(r=(l=l>o?o:l)+parseInt(e.length,10))>o&&(r=o,this.log("End range automatically set to the max value of "+o)),l<0||r-l<0||l>o||r>o?(a=!1,this.log("Invalid range: "+JSON.stringify(e)),this.opt.noMatch(e)):""===n.substring(l,r).replace(/\s+/g,"")&&(a=!1,this.log("Skipping whitespace only range: "+JSON.stringify(e)),this.opt.noMatch(e)),{start:l,end:r,valid:a}}},{key:"getTextNodes",value:function(e){var t=this,n="",r=[];this.iterator.forEachNode(NodeFilter.SHOW_TEXT,(function(e){r.push({start:n.length,end:(n+=e.textContent).length,node:e})}),(function(e){return t.matchesExclude(e.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),(function(){e({value:n,nodes:r})}))}},{key:"matchesExclude",value:function(e){return a.matches(e,this.opt.exclude.concat(["script","style","title","head","html"]))}},{key:"wrapRangeInTextNode",value:function(e,t,n){var r=this.opt.element?this.opt.element:"mark",a=e.splitText(t),o=a.splitText(n-t),i=document.createElement(r);return i.setAttribute("data-markjs","true"),this.opt.className&&i.setAttribute("class",this.opt.className),i.textContent=a.textContent,a.parentNode.replaceChild(i,a),o}},{key:"wrapRangeInMappedTextNode",value:function(e,t,n,r,a){var o=this;e.nodes.every((function(i,l){var s=e.nodes[l+1];if(void 0===s||s.start>t){if(!r(i.node))return!1;var c=t-i.start,u=(n>i.end?i.end:n)-i.start,d=e.value.substr(0,i.start),p=e.value.substr(u+i.start);if(i.node=o.wrapRangeInTextNode(i.node,c,u),e.value=d+p,e.nodes.forEach((function(t,n){n>=l&&(e.nodes[n].start>0&&n!==l&&(e.nodes[n].start-=u),e.nodes[n].end-=u)})),n-=u,a(i.node.previousSibling,i.start),!(n>i.end))return!1;t=i.end}return!0}))}},{key:"wrapMatches",value:function(e,t,n,r,a){var o=this,i=0===t?0:t+1;this.getTextNodes((function(t){t.nodes.forEach((function(t){t=t.node;for(var a=void 0;null!==(a=e.exec(t.textContent))&&""!==a[i];)if(n(a[i],t)){var l=a.index;if(0!==i)for(var s=1;s{"use strict";n.r(t)},1043:(e,t,n)=>{"use strict";n.r(t)},5947:function(e,t,n){var r,a;r=function(){var e,t,n={version:"0.2.0"},r=n.settings={minimum:.08,easing:"ease",positionUsing:"",speed:200,trickle:!0,trickleRate:.02,trickleSpeed:800,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:'
'};function a(e,t,n){return en?n:e}function o(e){return 100*(-1+e)}function i(e,t,n){var a;return(a="translate3d"===r.positionUsing?{transform:"translate3d("+o(e)+"%,0,0)"}:"translate"===r.positionUsing?{transform:"translate("+o(e)+"%,0)"}:{"margin-left":o(e)+"%"}).transition="all "+t+"ms "+n,a}n.configure=function(e){var t,n;for(t in e)void 0!==(n=e[t])&&e.hasOwnProperty(t)&&(r[t]=n);return this},n.status=null,n.set=function(e){var t=n.isStarted();e=a(e,r.minimum,1),n.status=1===e?null:e;var o=n.render(!t),c=o.querySelector(r.barSelector),u=r.speed,d=r.easing;return o.offsetWidth,l((function(t){""===r.positionUsing&&(r.positionUsing=n.getPositioningCSS()),s(c,i(e,u,d)),1===e?(s(o,{transition:"none",opacity:1}),o.offsetWidth,setTimeout((function(){s(o,{transition:"all "+u+"ms linear",opacity:0}),setTimeout((function(){n.remove(),t()}),u)}),u)):setTimeout(t,u)})),this},n.isStarted=function(){return"number"==typeof n.status},n.start=function(){n.status||n.set(0);var e=function(){setTimeout((function(){n.status&&(n.trickle(),e())}),r.trickleSpeed)};return r.trickle&&e(),this},n.done=function(e){return e||n.status?n.inc(.3+.5*Math.random()).set(1):this},n.inc=function(e){var t=n.status;return t?("number"!=typeof e&&(e=(1-t)*a(Math.random()*t,.1,.95)),t=a(t+e,0,.994),n.set(t)):n.start()},n.trickle=function(){return n.inc(Math.random()*r.trickleRate)},e=0,t=0,n.promise=function(r){return r&&"resolved"!==r.state()?(0===t&&n.start(),e++,t++,r.always((function(){0==--t?(e=0,n.done()):n.set((e-t)/e)})),this):this},n.render=function(e){if(n.isRendered())return document.getElementById("nprogress");u(document.documentElement,"nprogress-busy");var t=document.createElement("div");t.id="nprogress",t.innerHTML=r.template;var a,i=t.querySelector(r.barSelector),l=e?"-100":o(n.status||0),c=document.querySelector(r.parent);return s(i,{transition:"all 0 linear",transform:"translate3d("+l+"%,0,0)"}),r.showSpinner||(a=t.querySelector(r.spinnerSelector))&&f(a),c!=document.body&&u(c,"nprogress-custom-parent"),c.appendChild(t),t},n.remove=function(){d(document.documentElement,"nprogress-busy"),d(document.querySelector(r.parent),"nprogress-custom-parent");var e=document.getElementById("nprogress");e&&f(e)},n.isRendered=function(){return!!document.getElementById("nprogress")},n.getPositioningCSS=function(){var e=document.body.style,t="WebkitTransform"in e?"Webkit":"MozTransform"in e?"Moz":"msTransform"in e?"ms":"OTransform"in e?"O":"";return t+"Perspective"in e?"translate3d":t+"Transform"in e?"translate":"margin"};var l=function(){var e=[];function t(){var n=e.shift();n&&n(t)}return function(n){e.push(n),1==e.length&&t()}}(),s=function(){var e=["Webkit","O","Moz","ms"],t={};function n(e){return e.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,(function(e,t){return t.toUpperCase()}))}function r(t){var n=document.body.style;if(t in n)return t;for(var r,a=e.length,o=t.charAt(0).toUpperCase()+t.slice(1);a--;)if((r=e[a]+o)in n)return r;return t}function a(e){return e=n(e),t[e]||(t[e]=r(e))}function o(e,t,n){t=a(t),e.style[t]=n}return function(e,t){var n,r,a=arguments;if(2==a.length)for(n in t)void 0!==(r=t[n])&&t.hasOwnProperty(n)&&o(e,n,r);else o(e,a[1],a[2])}}();function c(e,t){return("string"==typeof e?e:p(e)).indexOf(" "+t+" ")>=0}function u(e,t){var n=p(e),r=n+t;c(n,t)||(e.className=r.substring(1))}function d(e,t){var n,r=p(e);c(e,t)&&(n=r.replace(" "+t+" "," "),e.className=n.substring(1,n.length-1))}function p(e){return(" "+(e.className||"")+" ").replace(/\s+/gi," ")}function f(e){e&&e.parentNode&&e.parentNode.removeChild(e)}return n},void 0===(a="function"==typeof r?r.call(t,n,t,e):r)||(e.exports=a)},5302:(e,t,n)=>{var r=n(4634);e.exports=f,e.exports.parse=o,e.exports.compile=function(e,t){return l(o(e,t),t)},e.exports.tokensToFunction=l,e.exports.tokensToRegExp=p;var a=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function o(e,t){for(var n,r=[],o=0,i=0,l="",u=t&&t.delimiter||"/";null!=(n=a.exec(e));){var d=n[0],p=n[1],f=n.index;if(l+=e.slice(i,f),i=f+d.length,p)l+=p[1];else{var m=e[i],h=n[2],g=n[3],b=n[4],y=n[5],v=n[6],w=n[7];l&&(r.push(l),l="");var x=null!=h&&null!=m&&m!==h,k="+"===v||"*"===v,S="?"===v||"*"===v,E=n[2]||u,_=b||y;r.push({name:g||o++,prefix:h||"",delimiter:E,optional:S,repeat:k,partial:x,asterisk:!!w,pattern:_?c(_):w?".*":"[^"+s(E)+"]+?"})}}return i{e.exports&&(e.exports={core:{meta:{path:"components/prism-core.js",option:"mandatory"},core:"Core"},themes:{meta:{path:"themes/{id}.css",link:"index.html?theme={id}",exclusive:!0},prism:{title:"Default",option:"default"},"prism-dark":"Dark","prism-funky":"Funky","prism-okaidia":{title:"Okaidia",owner:"ocodia"},"prism-twilight":{title:"Twilight",owner:"remybach"},"prism-coy":{title:"Coy",owner:"tshedor"},"prism-solarizedlight":{title:"Solarized Light",owner:"hectormatos2011 "},"prism-tomorrow":{title:"Tomorrow Night",owner:"Rosey"}},languages:{meta:{path:"components/prism-{id}",noCSS:!0,examplesPath:"examples/prism-{id}",addCheckAll:!0},markup:{title:"Markup",alias:["html","xml","svg","mathml","ssml","atom","rss"],aliasTitles:{html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",ssml:"SSML",atom:"Atom",rss:"RSS"},option:"default"},css:{title:"CSS",option:"default",modify:"markup"},clike:{title:"C-like",option:"default"},javascript:{title:"JavaScript",require:"clike",modify:"markup",optional:"regex",alias:"js",option:"default"},abap:{title:"ABAP",owner:"dellagustin"},abnf:{title:"ABNF",owner:"RunDevelopment"},actionscript:{title:"ActionScript",require:"javascript",modify:"markup",owner:"Golmote"},ada:{title:"Ada",owner:"Lucretia"},agda:{title:"Agda",owner:"xy-ren"},al:{title:"AL",owner:"RunDevelopment"},antlr4:{title:"ANTLR4",alias:"g4",owner:"RunDevelopment"},apacheconf:{title:"Apache Configuration",owner:"GuiTeK"},apex:{title:"Apex",require:["clike","sql"],owner:"RunDevelopment"},apl:{title:"APL",owner:"ngn"},applescript:{title:"AppleScript",owner:"Golmote"},aql:{title:"AQL",owner:"RunDevelopment"},arduino:{title:"Arduino",require:"cpp",alias:"ino",owner:"dkern"},arff:{title:"ARFF",owner:"Golmote"},armasm:{title:"ARM Assembly",alias:"arm-asm",owner:"RunDevelopment"},arturo:{title:"Arturo",alias:"art",optional:["bash","css","javascript","markup","markdown","sql"],owner:"drkameleon"},asciidoc:{alias:"adoc",title:"AsciiDoc",owner:"Golmote"},aspnet:{title:"ASP.NET (C#)",require:["markup","csharp"],owner:"nauzilus"},asm6502:{title:"6502 Assembly",owner:"kzurawel"},asmatmel:{title:"Atmel AVR Assembly",owner:"cerkit"},autohotkey:{title:"AutoHotkey",owner:"aviaryan"},autoit:{title:"AutoIt",owner:"Golmote"},avisynth:{title:"AviSynth",alias:"avs",owner:"Zinfidel"},"avro-idl":{title:"Avro IDL",alias:"avdl",owner:"RunDevelopment"},awk:{title:"AWK",alias:"gawk",aliasTitles:{gawk:"GAWK"},owner:"RunDevelopment"},bash:{title:"Bash",alias:["sh","shell"],aliasTitles:{sh:"Shell",shell:"Shell"},owner:"zeitgeist87"},basic:{title:"BASIC",owner:"Golmote"},batch:{title:"Batch",owner:"Golmote"},bbcode:{title:"BBcode",alias:"shortcode",aliasTitles:{shortcode:"Shortcode"},owner:"RunDevelopment"},bbj:{title:"BBj",owner:"hyyan"},bicep:{title:"Bicep",owner:"johnnyreilly"},birb:{title:"Birb",require:"clike",owner:"Calamity210"},bison:{title:"Bison",require:"c",owner:"Golmote"},bnf:{title:"BNF",alias:"rbnf",aliasTitles:{rbnf:"RBNF"},owner:"RunDevelopment"},bqn:{title:"BQN",owner:"yewscion"},brainfuck:{title:"Brainfuck",owner:"Golmote"},brightscript:{title:"BrightScript",owner:"RunDevelopment"},bro:{title:"Bro",owner:"wayward710"},bsl:{title:"BSL (1C:Enterprise)",alias:"oscript",aliasTitles:{oscript:"OneScript"},owner:"Diversus23"},c:{title:"C",require:"clike",owner:"zeitgeist87"},csharp:{title:"C#",require:"clike",alias:["cs","dotnet"],owner:"mvalipour"},cpp:{title:"C++",require:"c",owner:"zeitgeist87"},cfscript:{title:"CFScript",require:"clike",alias:"cfc",owner:"mjclemente"},chaiscript:{title:"ChaiScript",require:["clike","cpp"],owner:"RunDevelopment"},cil:{title:"CIL",owner:"sbrl"},cilkc:{title:"Cilk/C",require:"c",alias:"cilk-c",owner:"OpenCilk"},cilkcpp:{title:"Cilk/C++",require:"cpp",alias:["cilk-cpp","cilk"],owner:"OpenCilk"},clojure:{title:"Clojure",owner:"troglotit"},cmake:{title:"CMake",owner:"mjrogozinski"},cobol:{title:"COBOL",owner:"RunDevelopment"},coffeescript:{title:"CoffeeScript",require:"javascript",alias:"coffee",owner:"R-osey"},concurnas:{title:"Concurnas",alias:"conc",owner:"jasontatton"},csp:{title:"Content-Security-Policy",owner:"ScottHelme"},cooklang:{title:"Cooklang",owner:"ahue"},coq:{title:"Coq",owner:"RunDevelopment"},crystal:{title:"Crystal",require:"ruby",owner:"MakeNowJust"},"css-extras":{title:"CSS Extras",require:"css",modify:"css",owner:"milesj"},csv:{title:"CSV",owner:"RunDevelopment"},cue:{title:"CUE",owner:"RunDevelopment"},cypher:{title:"Cypher",owner:"RunDevelopment"},d:{title:"D",require:"clike",owner:"Golmote"},dart:{title:"Dart",require:"clike",owner:"Golmote"},dataweave:{title:"DataWeave",owner:"machaval"},dax:{title:"DAX",owner:"peterbud"},dhall:{title:"Dhall",owner:"RunDevelopment"},diff:{title:"Diff",owner:"uranusjr"},django:{title:"Django/Jinja2",require:"markup-templating",alias:"jinja2",owner:"romanvm"},"dns-zone-file":{title:"DNS zone file",owner:"RunDevelopment",alias:"dns-zone"},docker:{title:"Docker",alias:"dockerfile",owner:"JustinBeckwith"},dot:{title:"DOT (Graphviz)",alias:"gv",optional:"markup",owner:"RunDevelopment"},ebnf:{title:"EBNF",owner:"RunDevelopment"},editorconfig:{title:"EditorConfig",owner:"osipxd"},eiffel:{title:"Eiffel",owner:"Conaclos"},ejs:{title:"EJS",require:["javascript","markup-templating"],owner:"RunDevelopment",alias:"eta",aliasTitles:{eta:"Eta"}},elixir:{title:"Elixir",owner:"Golmote"},elm:{title:"Elm",owner:"zwilias"},etlua:{title:"Embedded Lua templating",require:["lua","markup-templating"],owner:"RunDevelopment"},erb:{title:"ERB",require:["ruby","markup-templating"],owner:"Golmote"},erlang:{title:"Erlang",owner:"Golmote"},"excel-formula":{title:"Excel Formula",alias:["xlsx","xls"],owner:"RunDevelopment"},fsharp:{title:"F#",require:"clike",owner:"simonreynolds7"},factor:{title:"Factor",owner:"catb0t"},false:{title:"False",owner:"edukisto"},"firestore-security-rules":{title:"Firestore security rules",require:"clike",owner:"RunDevelopment"},flow:{title:"Flow",require:"javascript",owner:"Golmote"},fortran:{title:"Fortran",owner:"Golmote"},ftl:{title:"FreeMarker Template Language",require:"markup-templating",owner:"RunDevelopment"},gml:{title:"GameMaker Language",alias:"gamemakerlanguage",require:"clike",owner:"LiarOnce"},gap:{title:"GAP (CAS)",owner:"RunDevelopment"},gcode:{title:"G-code",owner:"RunDevelopment"},gdscript:{title:"GDScript",owner:"RunDevelopment"},gedcom:{title:"GEDCOM",owner:"Golmote"},gettext:{title:"gettext",alias:"po",owner:"RunDevelopment"},gherkin:{title:"Gherkin",owner:"hason"},git:{title:"Git",owner:"lgiraudel"},glsl:{title:"GLSL",require:"c",owner:"Golmote"},gn:{title:"GN",alias:"gni",owner:"RunDevelopment"},"linker-script":{title:"GNU Linker Script",alias:"ld",owner:"RunDevelopment"},go:{title:"Go",require:"clike",owner:"arnehormann"},"go-module":{title:"Go module",alias:"go-mod",owner:"RunDevelopment"},gradle:{title:"Gradle",require:"clike",owner:"zeabdelkhalek-badido18"},graphql:{title:"GraphQL",optional:"markdown",owner:"Golmote"},groovy:{title:"Groovy",require:"clike",owner:"robfletcher"},haml:{title:"Haml",require:"ruby",optional:["css","css-extras","coffeescript","erb","javascript","less","markdown","scss","textile"],owner:"Golmote"},handlebars:{title:"Handlebars",require:"markup-templating",alias:["hbs","mustache"],aliasTitles:{mustache:"Mustache"},owner:"Golmote"},haskell:{title:"Haskell",alias:"hs",owner:"bholst"},haxe:{title:"Haxe",require:"clike",optional:"regex",owner:"Golmote"},hcl:{title:"HCL",owner:"outsideris"},hlsl:{title:"HLSL",require:"c",owner:"RunDevelopment"},hoon:{title:"Hoon",owner:"matildepark"},http:{title:"HTTP",optional:["csp","css","hpkp","hsts","javascript","json","markup","uri"],owner:"danielgtaylor"},hpkp:{title:"HTTP Public-Key-Pins",owner:"ScottHelme"},hsts:{title:"HTTP Strict-Transport-Security",owner:"ScottHelme"},ichigojam:{title:"IchigoJam",owner:"BlueCocoa"},icon:{title:"Icon",owner:"Golmote"},"icu-message-format":{title:"ICU Message Format",owner:"RunDevelopment"},idris:{title:"Idris",alias:"idr",owner:"KeenS",require:"haskell"},ignore:{title:".ignore",owner:"osipxd",alias:["gitignore","hgignore","npmignore"],aliasTitles:{gitignore:".gitignore",hgignore:".hgignore",npmignore:".npmignore"}},inform7:{title:"Inform 7",owner:"Golmote"},ini:{title:"Ini",owner:"aviaryan"},io:{title:"Io",owner:"AlesTsurko"},j:{title:"J",owner:"Golmote"},java:{title:"Java",require:"clike",owner:"sherblot"},javadoc:{title:"JavaDoc",require:["markup","java","javadoclike"],modify:"java",optional:"scala",owner:"RunDevelopment"},javadoclike:{title:"JavaDoc-like",modify:["java","javascript","php"],owner:"RunDevelopment"},javastacktrace:{title:"Java stack trace",owner:"RunDevelopment"},jexl:{title:"Jexl",owner:"czosel"},jolie:{title:"Jolie",require:"clike",owner:"thesave"},jq:{title:"JQ",owner:"RunDevelopment"},jsdoc:{title:"JSDoc",require:["javascript","javadoclike","typescript"],modify:"javascript",optional:["actionscript","coffeescript"],owner:"RunDevelopment"},"js-extras":{title:"JS Extras",require:"javascript",modify:"javascript",optional:["actionscript","coffeescript","flow","n4js","typescript"],owner:"RunDevelopment"},json:{title:"JSON",alias:"webmanifest",aliasTitles:{webmanifest:"Web App Manifest"},owner:"CupOfTea696"},json5:{title:"JSON5",require:"json",owner:"RunDevelopment"},jsonp:{title:"JSONP",require:"json",owner:"RunDevelopment"},jsstacktrace:{title:"JS stack trace",owner:"sbrl"},"js-templates":{title:"JS Templates",require:"javascript",modify:"javascript",optional:["css","css-extras","graphql","markdown","markup","sql"],owner:"RunDevelopment"},julia:{title:"Julia",owner:"cdagnino"},keepalived:{title:"Keepalived Configure",owner:"dev-itsheng"},keyman:{title:"Keyman",owner:"mcdurdin"},kotlin:{title:"Kotlin",alias:["kt","kts"],aliasTitles:{kts:"Kotlin Script"},require:"clike",owner:"Golmote"},kumir:{title:"KuMir (\u041a\u0443\u041c\u0438\u0440)",alias:"kum",owner:"edukisto"},kusto:{title:"Kusto",owner:"RunDevelopment"},latex:{title:"LaTeX",alias:["tex","context"],aliasTitles:{tex:"TeX",context:"ConTeXt"},owner:"japborst"},latte:{title:"Latte",require:["clike","markup-templating","php"],owner:"nette"},less:{title:"Less",require:"css",optional:"css-extras",owner:"Golmote"},lilypond:{title:"LilyPond",require:"scheme",alias:"ly",owner:"RunDevelopment"},liquid:{title:"Liquid",require:"markup-templating",owner:"cinhtau"},lisp:{title:"Lisp",alias:["emacs","elisp","emacs-lisp"],owner:"JuanCaicedo"},livescript:{title:"LiveScript",owner:"Golmote"},llvm:{title:"LLVM IR",owner:"porglezomp"},log:{title:"Log file",optional:"javastacktrace",owner:"RunDevelopment"},lolcode:{title:"LOLCODE",owner:"Golmote"},lua:{title:"Lua",owner:"Golmote"},magma:{title:"Magma (CAS)",owner:"RunDevelopment"},makefile:{title:"Makefile",owner:"Golmote"},markdown:{title:"Markdown",require:"markup",optional:"yaml",alias:"md",owner:"Golmote"},"markup-templating":{title:"Markup templating",require:"markup",owner:"Golmote"},mata:{title:"Mata",owner:"RunDevelopment"},matlab:{title:"MATLAB",owner:"Golmote"},maxscript:{title:"MAXScript",owner:"RunDevelopment"},mel:{title:"MEL",owner:"Golmote"},mermaid:{title:"Mermaid",owner:"RunDevelopment"},metafont:{title:"METAFONT",owner:"LaeriExNihilo"},mizar:{title:"Mizar",owner:"Golmote"},mongodb:{title:"MongoDB",owner:"airs0urce",require:"javascript"},monkey:{title:"Monkey",owner:"Golmote"},moonscript:{title:"MoonScript",alias:"moon",owner:"RunDevelopment"},n1ql:{title:"N1QL",owner:"TMWilds"},n4js:{title:"N4JS",require:"javascript",optional:"jsdoc",alias:"n4jsd",owner:"bsmith-n4"},"nand2tetris-hdl":{title:"Nand To Tetris HDL",owner:"stephanmax"},naniscript:{title:"Naninovel Script",owner:"Elringus",alias:"nani"},nasm:{title:"NASM",owner:"rbmj"},neon:{title:"NEON",owner:"nette"},nevod:{title:"Nevod",owner:"nezaboodka"},nginx:{title:"nginx",owner:"volado"},nim:{title:"Nim",owner:"Golmote"},nix:{title:"Nix",owner:"Golmote"},nsis:{title:"NSIS",owner:"idleberg"},objectivec:{title:"Objective-C",require:"c",alias:"objc",owner:"uranusjr"},ocaml:{title:"OCaml",owner:"Golmote"},odin:{title:"Odin",owner:"edukisto"},opencl:{title:"OpenCL",require:"c",modify:["c","cpp"],owner:"Milania1"},openqasm:{title:"OpenQasm",alias:"qasm",owner:"RunDevelopment"},oz:{title:"Oz",owner:"Golmote"},parigp:{title:"PARI/GP",owner:"Golmote"},parser:{title:"Parser",require:"markup",owner:"Golmote"},pascal:{title:"Pascal",alias:"objectpascal",aliasTitles:{objectpascal:"Object Pascal"},owner:"Golmote"},pascaligo:{title:"Pascaligo",owner:"DefinitelyNotAGoat"},psl:{title:"PATROL Scripting Language",owner:"bertysentry"},pcaxis:{title:"PC-Axis",alias:"px",owner:"RunDevelopment"},peoplecode:{title:"PeopleCode",alias:"pcode",owner:"RunDevelopment"},perl:{title:"Perl",owner:"Golmote"},php:{title:"PHP",require:"markup-templating",owner:"milesj"},phpdoc:{title:"PHPDoc",require:["php","javadoclike"],modify:"php",owner:"RunDevelopment"},"php-extras":{title:"PHP Extras",require:"php",modify:"php",owner:"milesj"},"plant-uml":{title:"PlantUML",alias:"plantuml",owner:"RunDevelopment"},plsql:{title:"PL/SQL",require:"sql",owner:"Golmote"},powerquery:{title:"PowerQuery",alias:["pq","mscript"],owner:"peterbud"},powershell:{title:"PowerShell",owner:"nauzilus"},processing:{title:"Processing",require:"clike",owner:"Golmote"},prolog:{title:"Prolog",owner:"Golmote"},promql:{title:"PromQL",owner:"arendjr"},properties:{title:".properties",owner:"Golmote"},protobuf:{title:"Protocol Buffers",require:"clike",owner:"just-boris"},pug:{title:"Pug",require:["markup","javascript"],optional:["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],owner:"Golmote"},puppet:{title:"Puppet",owner:"Golmote"},pure:{title:"Pure",optional:["c","cpp","fortran"],owner:"Golmote"},purebasic:{title:"PureBasic",require:"clike",alias:"pbfasm",owner:"HeX0R101"},purescript:{title:"PureScript",require:"haskell",alias:"purs",owner:"sriharshachilakapati"},python:{title:"Python",alias:"py",owner:"multipetros"},qsharp:{title:"Q#",require:"clike",alias:"qs",owner:"fedonman"},q:{title:"Q (kdb+ database)",owner:"Golmote"},qml:{title:"QML",require:"javascript",owner:"RunDevelopment"},qore:{title:"Qore",require:"clike",owner:"temnroegg"},r:{title:"R",owner:"Golmote"},racket:{title:"Racket",require:"scheme",alias:"rkt",owner:"RunDevelopment"},cshtml:{title:"Razor C#",alias:"razor",require:["markup","csharp"],optional:["css","css-extras","javascript","js-extras"],owner:"RunDevelopment"},jsx:{title:"React JSX",require:["markup","javascript"],optional:["jsdoc","js-extras","js-templates"],owner:"vkbansal"},tsx:{title:"React TSX",require:["jsx","typescript"]},reason:{title:"Reason",require:"clike",owner:"Golmote"},regex:{title:"Regex",owner:"RunDevelopment"},rego:{title:"Rego",owner:"JordanSh"},renpy:{title:"Ren'py",alias:"rpy",owner:"HyuchiaDiego"},rescript:{title:"ReScript",alias:"res",owner:"vmarcosp"},rest:{title:"reST (reStructuredText)",owner:"Golmote"},rip:{title:"Rip",owner:"ravinggenius"},roboconf:{title:"Roboconf",owner:"Golmote"},robotframework:{title:"Robot Framework",alias:"robot",owner:"RunDevelopment"},ruby:{title:"Ruby",require:"clike",alias:"rb",owner:"samflores"},rust:{title:"Rust",owner:"Golmote"},sas:{title:"SAS",optional:["groovy","lua","sql"],owner:"Golmote"},sass:{title:"Sass (Sass)",require:"css",optional:"css-extras",owner:"Golmote"},scss:{title:"Sass (SCSS)",require:"css",optional:"css-extras",owner:"MoOx"},scala:{title:"Scala",require:"java",owner:"jozic"},scheme:{title:"Scheme",owner:"bacchus123"},"shell-session":{title:"Shell session",require:"bash",alias:["sh-session","shellsession"],owner:"RunDevelopment"},smali:{title:"Smali",owner:"RunDevelopment"},smalltalk:{title:"Smalltalk",owner:"Golmote"},smarty:{title:"Smarty",require:"markup-templating",optional:"php",owner:"Golmote"},sml:{title:"SML",alias:"smlnj",aliasTitles:{smlnj:"SML/NJ"},owner:"RunDevelopment"},solidity:{title:"Solidity (Ethereum)",alias:"sol",require:"clike",owner:"glachaud"},"solution-file":{title:"Solution file",alias:"sln",owner:"RunDevelopment"},soy:{title:"Soy (Closure Template)",require:"markup-templating",owner:"Golmote"},sparql:{title:"SPARQL",require:"turtle",owner:"Triply-Dev",alias:"rq"},"splunk-spl":{title:"Splunk SPL",owner:"RunDevelopment"},sqf:{title:"SQF: Status Quo Function (Arma 3)",require:"clike",owner:"RunDevelopment"},sql:{title:"SQL",owner:"multipetros"},squirrel:{title:"Squirrel",require:"clike",owner:"RunDevelopment"},stan:{title:"Stan",owner:"RunDevelopment"},stata:{title:"Stata Ado",require:["mata","java","python"],owner:"RunDevelopment"},iecst:{title:"Structured Text (IEC 61131-3)",owner:"serhioromano"},stylus:{title:"Stylus",owner:"vkbansal"},supercollider:{title:"SuperCollider",alias:"sclang",owner:"RunDevelopment"},swift:{title:"Swift",owner:"chrischares"},systemd:{title:"Systemd configuration file",owner:"RunDevelopment"},"t4-templating":{title:"T4 templating",owner:"RunDevelopment"},"t4-cs":{title:"T4 Text Templates (C#)",require:["t4-templating","csharp"],alias:"t4",owner:"RunDevelopment"},"t4-vb":{title:"T4 Text Templates (VB)",require:["t4-templating","vbnet"],owner:"RunDevelopment"},tap:{title:"TAP",owner:"isaacs",require:"yaml"},tcl:{title:"Tcl",owner:"PeterChaplin"},tt2:{title:"Template Toolkit 2",require:["clike","markup-templating"],owner:"gflohr"},textile:{title:"Textile",require:"markup",optional:"css",owner:"Golmote"},toml:{title:"TOML",owner:"RunDevelopment"},tremor:{title:"Tremor",alias:["trickle","troy"],owner:"darach",aliasTitles:{trickle:"trickle",troy:"troy"}},turtle:{title:"Turtle",alias:"trig",aliasTitles:{trig:"TriG"},owner:"jakubklimek"},twig:{title:"Twig",require:"markup-templating",owner:"brandonkelly"},typescript:{title:"TypeScript",require:"javascript",optional:"js-templates",alias:"ts",owner:"vkbansal"},typoscript:{title:"TypoScript",alias:"tsconfig",aliasTitles:{tsconfig:"TSConfig"},owner:"dkern"},unrealscript:{title:"UnrealScript",alias:["uscript","uc"],owner:"RunDevelopment"},uorazor:{title:"UO Razor Script",owner:"jaseowns"},uri:{title:"URI",alias:"url",aliasTitles:{url:"URL"},owner:"RunDevelopment"},v:{title:"V",require:"clike",owner:"taggon"},vala:{title:"Vala",require:"clike",optional:"regex",owner:"TemplarVolk"},vbnet:{title:"VB.Net",require:"basic",owner:"Bigsby"},velocity:{title:"Velocity",require:"markup",owner:"Golmote"},verilog:{title:"Verilog",owner:"a-rey"},vhdl:{title:"VHDL",owner:"a-rey"},vim:{title:"vim",owner:"westonganger"},"visual-basic":{title:"Visual Basic",alias:["vb","vba"],aliasTitles:{vba:"VBA"},owner:"Golmote"},warpscript:{title:"WarpScript",owner:"RunDevelopment"},wasm:{title:"WebAssembly",owner:"Golmote"},"web-idl":{title:"Web IDL",alias:"webidl",owner:"RunDevelopment"},wgsl:{title:"WGSL",owner:"Dr4gonthree"},wiki:{title:"Wiki markup",require:"markup",owner:"Golmote"},wolfram:{title:"Wolfram language",alias:["mathematica","nb","wl"],aliasTitles:{mathematica:"Mathematica",nb:"Mathematica Notebook"},owner:"msollami"},wren:{title:"Wren",owner:"clsource"},xeora:{title:"Xeora",require:"markup",alias:"xeoracube",aliasTitles:{xeoracube:"XeoraCube"},owner:"freakmaxi"},"xml-doc":{title:"XML doc (.net)",require:"markup",modify:["csharp","fsharp","vbnet"],owner:"RunDevelopment"},xojo:{title:"Xojo (REALbasic)",owner:"Golmote"},xquery:{title:"XQuery",require:"markup",owner:"Golmote"},yaml:{title:"YAML",alias:"yml",owner:"hason"},yang:{title:"YANG",owner:"RunDevelopment"},zig:{title:"Zig",owner:"RunDevelopment"}},plugins:{meta:{path:"plugins/{id}/prism-{id}",link:"plugins/{id}/"},"line-highlight":{title:"Line Highlight",description:"Highlights specific lines and/or line ranges."},"line-numbers":{title:"Line Numbers",description:"Line number at the beginning of code lines.",owner:"kuba-kubula"},"show-invisibles":{title:"Show Invisibles",description:"Show hidden characters such as tabs and line breaks.",optional:["autolinker","data-uri-highlight"]},autolinker:{title:"Autolinker",description:"Converts URLs and emails in code to clickable links. Parses Markdown links in comments."},wpd:{title:"WebPlatform Docs",description:'Makes tokens link to WebPlatform.org documentation. The links open in a new tab.'},"custom-class":{title:"Custom Class",description:"This plugin allows you to prefix Prism's default classes (.comment can become .namespace--comment) or replace them with your defined ones (like .editor__comment). You can even add new classes.",owner:"dvkndn",noCSS:!0},"file-highlight":{title:"File Highlight",description:"Fetch external files and highlight them with Prism. Used on the Prism website itself.",noCSS:!0},"show-language":{title:"Show Language",description:"Display the highlighted language in code blocks (inline code does not show the label).",owner:"nauzilus",noCSS:!0,require:"toolbar"},"jsonp-highlight":{title:"JSONP Highlight",description:"Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).",noCSS:!0,owner:"nauzilus"},"highlight-keywords":{title:"Highlight Keywords",description:"Adds special CSS classes for each keyword for fine-grained highlighting.",owner:"vkbansal",noCSS:!0},"remove-initial-line-feed":{title:"Remove initial line feed",description:"Removes the initial line feed in code blocks.",owner:"Golmote",noCSS:!0},"inline-color":{title:"Inline color",description:"Adds a small inline preview for colors in style sheets.",require:"css-extras",owner:"RunDevelopment"},previewers:{title:"Previewers",description:"Previewers for angles, colors, gradients, easing and time.",require:"css-extras",owner:"Golmote"},autoloader:{title:"Autoloader",description:"Automatically loads the needed languages to highlight the code blocks.",owner:"Golmote",noCSS:!0},"keep-markup":{title:"Keep Markup",description:"Prevents custom markup from being dropped out during highlighting.",owner:"Golmote",optional:"normalize-whitespace",noCSS:!0},"command-line":{title:"Command Line",description:"Display a command line with a prompt and, optionally, the output/response from the commands.",owner:"chriswells0"},"unescaped-markup":{title:"Unescaped Markup",description:"Write markup without having to escape anything."},"normalize-whitespace":{title:"Normalize Whitespace",description:"Supports multiple operations to normalize whitespace in code blocks.",owner:"zeitgeist87",optional:"unescaped-markup",noCSS:!0},"data-uri-highlight":{title:"Data-URI Highlight",description:"Highlights data-URI contents.",owner:"Golmote",noCSS:!0},toolbar:{title:"Toolbar",description:"Attach a toolbar for plugins to easily register buttons on the top of a code block.",owner:"mAAdhaTTah"},"copy-to-clipboard":{title:"Copy to Clipboard Button",description:"Add a button that copies the code block to the clipboard when clicked.",owner:"mAAdhaTTah",require:"toolbar",noCSS:!0},"download-button":{title:"Download Button",description:"A button in the toolbar of a code block adding a convenient way to download a code file.",owner:"Golmote",require:"toolbar",noCSS:!0},"match-braces":{title:"Match braces",description:"Highlights matching braces.",owner:"RunDevelopment"},"diff-highlight":{title:"Diff Highlight",description:"Highlights the code inside diff blocks.",owner:"RunDevelopment",require:"diff"},"filter-highlight-all":{title:"Filter highlightAll",description:"Filters the elements the highlightAll and highlightAllUnder methods actually highlight.",owner:"RunDevelopment",noCSS:!0},treeview:{title:"Treeview",description:"A language with special styles to highlight file system tree structures.",owner:"Golmote"}}})},8722:(e,t,n)=>{const r=n(6969),a=n(8380),o=new Set;function i(e){void 0===e?e=Object.keys(r.languages).filter((e=>"meta"!=e)):Array.isArray(e)||(e=[e]);const t=[...o,...Object.keys(Prism.languages)];a(r,e,t).load((e=>{if(!(e in r.languages))return void(i.silent||console.warn("Language does not exist: "+e));const t="./prism-"+e;delete n.c[n(3157).resolve(t)],delete Prism.languages[e],n(3157)(t),o.add(e)}))}i.silent=!1,e.exports=i},9700:()=>{!function(e){function t(e,t){return"___"+e.toUpperCase()+t+"___"}Object.defineProperties(e.languages["markup-templating"]={},{buildPlaceholders:{value:function(n,r,a,o){if(n.language===r){var i=n.tokenStack=[];n.code=n.code.replace(a,(function(e){if("function"==typeof o&&!o(e))return e;for(var a,l=i.length;-1!==n.code.indexOf(a=t(r,l));)++l;return i[l]=e,a})),n.grammar=e.languages.markup}}},tokenizePlaceholders:{value:function(n,r){if(n.language===r&&n.tokenStack){n.grammar=e.languages[r];var a=0,o=Object.keys(n.tokenStack);!function i(l){for(var s=0;s=o.length);s++){var c=l[s];if("string"==typeof c||c.content&&"string"==typeof c.content){var u=o[a],d=n.tokenStack[u],p="string"==typeof c?c:c.content,f=t(r,u),m=p.indexOf(f);if(m>-1){++a;var h=p.substring(0,m),g=new e.Token(r,e.tokenize(d,n.grammar),"language-"+r,d),b=p.substring(m+f.length),y=[];h&&y.push.apply(y,i([h])),y.push(g),b&&y.push.apply(y,i([b])),"string"==typeof c?l.splice.apply(l,[s,1].concat(y)):c.content=y}}else c.content&&i(c.content)}return l}(n.tokens)}}}})}(Prism)},8692:(e,t,n)=>{var r={"./":8722};function a(e){var t=o(e);return n(t)}function o(e){if(!n.o(r,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return r[e]}a.keys=function(){return Object.keys(r)},a.resolve=o,e.exports=a,a.id=8692},3157:(e,t,n)=>{var r={"./":8722};function a(e){var t=o(e);return n(t)}function o(e){if(!n.o(r,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return r[e]}a.keys=function(){return Object.keys(r)},a.resolve=o,e.exports=a,a.id=3157},8380:e=>{"use strict";var t=function(){var e=function(){};function t(e,t){Array.isArray(e)?e.forEach(t):null!=e&&t(e,0)}function n(e){for(var t={},n=0,r=e.length;n "));var l={},s=e[r];if(s){function c(t){if(!(t in e))throw new Error(r+" depends on an unknown component "+t);if(!(t in l))for(var i in a(t,o),l[t]=!0,n[t])l[i]=!0}t(s.require,c),t(s.optional,c),t(s.modify,c)}n[r]=l,o.pop()}}return function(e){var t=n[e];return t||(a(e,r),t=n[e]),t}}function a(e){for(var t in e)return!0;return!1}return function(o,i,l){var s=function(e){var t={};for(var n in e){var r=e[n];for(var a in r)if("meta"!=a){var o=r[a];t[a]="string"==typeof o?{title:o}:o}}return t}(o),c=function(e){var n;return function(r){if(r in e)return r;if(!n)for(var a in n={},e){var o=e[a];t(o&&o.alias,(function(t){if(t in n)throw new Error(t+" cannot be alias for both "+a+" and "+n[t]);if(t in e)throw new Error(t+" cannot be alias of "+a+" because it is a component.");n[t]=a}))}return n[r]||r}}(s);i=i.map(c),l=(l||[]).map(c);var u=n(i),d=n(l);i.forEach((function e(n){var r=s[n];t(r&&r.require,(function(t){t in d||(u[t]=!0,e(t))}))}));for(var p,f=r(s),m=u;a(m);){for(var h in p={},m){var g=s[h];t(g&&g.modify,(function(e){e in d&&(p[e]=!0)}))}for(var b in d)if(!(b in u))for(var y in f(b))if(y in u){p[b]=!0;break}for(var v in m=p)u[v]=!0}var w={getIds:function(){var e=[];return w.load((function(t){e.push(t)})),e},load:function(t,n){return function(t,n,r,a){var o=a?a.series:void 0,i=a?a.parallel:e,l={},s={};function c(e){if(e in l)return l[e];s[e]=!0;var a,u=[];for(var d in t(e))d in n&&u.push(d);if(0===u.length)a=r(e);else{var p=i(u.map((function(e){var t=c(e);return delete s[e],t})));o?a=o(p,(function(){return r(e)})):r(e)}return l[e]=a}for(var u in n)c(u);var d=[];for(var p in s)d.push(l[p]);return i(d)}(f,u,t,n)}};return w}}();e.exports=t},2694:(e,t,n)=>{"use strict";var r=n(6925);function a(){}function o(){}o.resetWarningCache=a,e.exports=function(){function e(e,t,n,a,o,i){if(i!==r){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:a};return n.PropTypes=n,n}},5556:(e,t,n)=>{e.exports=n(2694)()},6925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},2551:(e,t,n)=>{"use strict";var r=n(6540),a=n(9982);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n