From 846f57f3303bf431c47c93ee38c5dd0c8e6b7539 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:29:54 +0000 Subject: [PATCH] 15.12.0 --- CHANGELOG.md | 9 ++++++--- .../rx-storage-instance-loki.js | 18 ++++-------------- .../rx-storage-instance-loki.js.map | 2 +- dist/cjs/plugins/utils/utils-rxdb-version.js | 2 +- .../plugins/utils/utils-rxdb-version.js.map | 2 +- .../rx-storage-instance-loki.js | 18 ++++-------------- .../rx-storage-instance-loki.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 +- .../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 ++-- ...68d20.68cfa9fc.js => 0e268d20.aead1a7b.js} | 2 +- ...93b7f.34032eb5.js => 1df93b7f.8468c8f6.js} | 2 +- ...a2389.62acb9e6.js => 280a2389.2a5b1215.js} | 2 +- docs/assets/js/4ed9495b.12f9cf04.js | 1 + docs/assets/js/4ed9495b.f857df51.js | 1 - ...f2afb.dfc6d928.js => 935f2afb.4cf455a3.js} | 2 +- ...77f4f.b17a3699.js => cde77f4f.ebf53539.js} | 2 +- ...4d6b0.2150b686.js => db34d6b0.aa85a0ae.js} | 2 +- .../js/{main.0d1a1a20.js => main.0c0128ea.js} | 4 ++-- ...CENSE.txt => main.0c0128ea.js.LICENSE.txt} | 0 ...n.aa3d2845.js => runtime~main.af063a36.js} | 2 +- 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 44495 -> 45284 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 | 4 ++-- docs/logger.html | 4 ++-- docs/lunr-index-1710240912552.json | 1 - docs/lunr-index-1710588555715.json | 1 + docs/lunr-index.json | 2 +- docs/markdown-page/index.html | 4 ++-- docs/meeting/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 | 4 ++-- 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 | 4 ++-- 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-state.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 | 4 ++-- docs/rx-storage-performance.html | 4 ++-- 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 | 15 +++++++++------ docs/rx-storage-worker.html | 4 ++-- docs/rx-storage.html | 4 ++-- docs/rxdb-tradeoffs.html | 4 ++-- docs/schema-validation.html | 4 ++-- docs/search-doc-1710240912552.json | 1 - docs/search-doc-1710588555715.json | 1 + docs/search-doc.json | 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 +- 149 files changed, 276 insertions(+), 290 deletions(-) rename docs/assets/js/{0e268d20.68cfa9fc.js => 0e268d20.aead1a7b.js} (99%) rename docs/assets/js/{1df93b7f.34032eb5.js => 1df93b7f.8468c8f6.js} (99%) rename docs/assets/js/{280a2389.62acb9e6.js => 280a2389.2a5b1215.js} (99%) create mode 100644 docs/assets/js/4ed9495b.12f9cf04.js delete mode 100644 docs/assets/js/4ed9495b.f857df51.js rename docs/assets/js/{935f2afb.dfc6d928.js => 935f2afb.4cf455a3.js} (94%) rename docs/assets/js/{cde77f4f.b17a3699.js => cde77f4f.ebf53539.js} (99%) rename docs/assets/js/{db34d6b0.2150b686.js => db34d6b0.aa85a0ae.js} (99%) rename docs/assets/js/{main.0d1a1a20.js => main.0c0128ea.js} (99%) rename docs/assets/js/{main.0d1a1a20.js.LICENSE.txt => main.0c0128ea.js.LICENSE.txt} (100%) rename docs/assets/js/{runtime~main.aa3d2845.js => runtime~main.af063a36.js} (70%) delete mode 100644 docs/lunr-index-1710240912552.json create mode 100644 docs/lunr-index-1710588555715.json delete mode 100644 docs/search-doc-1710240912552.json create mode 100644 docs/search-doc-1710588555715.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 4677554e332..4db54eedeee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,6 @@ # RxDB Changelog -- [SQLite RxStorage](https://rxdb.info/rx-storage-sqlite.html) add support to use Webassembly SQLite in the browser -- FIX(Lokisjs RxStorage) always use slice() for applying offset and limit [#5757](https://github.com/pubkey/rxdb/pull/5757) -- FIX randomly failing lokijs and denokv test [#5765](https://github.com/pubkey/rxdb/pull/5765) @@ -12,6 +9,12 @@ +### 15.12.0 (16 March 2024) + +- [SQLite RxStorage](https://rxdb.info/rx-storage-sqlite.html) add support to use Webassembly SQLite in the browser +- FIX(Lokisjs RxStorage) always use slice() for applying offset and limit [#5757](https://github.com/pubkey/rxdb/pull/5757) +- FIX randomly failing lokijs and denokv test [#5765](https://github.com/pubkey/rxdb/pull/5765) + ### 15.11.1 (10 March 2024) ### 15.11.0 (10 March 2024) diff --git a/dist/cjs/plugins/storage-lokijs/rx-storage-instance-loki.js b/dist/cjs/plugins/storage-lokijs/rx-storage-instance-loki.js index 90dfe7cf600..5f490719d0d 100644 --- a/dist/cjs/plugins/storage-lokijs/rx-storage-instance-loki.js +++ b/dist/cjs/plugins/storage-lokijs/rx-storage-instance-loki.js @@ -157,17 +157,6 @@ var RxStorageInstanceLoki = exports.RxStorageInstanceLoki = /*#__PURE__*/functio if (preparedQuery.sort) { lokiQuery = lokiQuery.sort((0, _lokijsHelper.getLokiSortComparator)(this.schema, preparedQuery)); } - - /** - * Offset must be used before limit in LokiJS - * @link https://github.com/techfort/LokiJS/issues/570 - */ - if (!mustRunMatcher && preparedQuery.skip) { - lokiQuery = lokiQuery.offset(preparedQuery.skip); - } - if (!mustRunMatcher && preparedQuery.limit) { - lokiQuery = lokiQuery.limit(preparedQuery.limit); - } var foundDocuments = lokiQuery.data().map(lokiDoc => (0, _lokijsHelper.stripLokiKey)(lokiDoc)); /** @@ -178,9 +167,10 @@ var RxStorageInstanceLoki = exports.RxStorageInstanceLoki = /*#__PURE__*/functio */ var queryMatcher = (0, _rxQueryHelper.getQueryMatcher)(this.schema, preparedQuery); foundDocuments = foundDocuments.filter(d => queryMatcher(d)); - if (mustRunMatcher) { - foundDocuments = foundDocuments.slice(skip, skipPlusLimit); - } + + // always apply offset and limit like this, because + // sylvieQuery.offset() and sylvieQuery.limit() results were inconsistent + foundDocuments = foundDocuments.slice(skip, skipPlusLimit); return { documents: foundDocuments }; diff --git a/dist/cjs/plugins/storage-lokijs/rx-storage-instance-loki.js.map b/dist/cjs/plugins/storage-lokijs/rx-storage-instance-loki.js.map index c72de889f9a..d57f7314f10 100644 --- a/dist/cjs/plugins/storage-lokijs/rx-storage-instance-loki.js.map +++ b/dist/cjs/plugins/storage-lokijs/rx-storage-instance-loki.js.map @@ -1 +1 @@ -{"version":3,"file":"rx-storage-instance-loki.js","names":["_rxjs","require","_index","_rxError","_lokijsHelper","_rxSchemaHelper","_rxStorageHelper","_rxStorageMultiinstance","_rxQueryHelper","instanceId","now","RxStorageInstanceLoki","exports","databaseInstanceToken","storage","databaseName","collectionName","schema","internals","options","databaseSettings","changes$","Subject","primaryPath","getPrimaryFieldOfPrimaryKey","primaryKey","OPEN_LOKIJS_STORAGE_INSTANCES","add","leaderElector","copiedSelf","bulkWrite","bind","changeStream","cleanup","close","query","count","findDocumentsById","conflictResultionTasks","getAttachmentData","remove","resolveConflictResultionTask","awaitLeadership","then","ensureNotFalsy","broadcastChannel","addEventListener","msg","handleRemoteRequest","catch","_proto","prototype","documentWrites","context","length","newRxError","args","localState","mustUseLocalState","requestRemoteInstance","ret","success","error","docsInDb","Map","docsInDbWithLokiKey","forEach","writeRow","id","document","documentInDb","collection","by","set","stripLokiKey","categorized","categorizeBulkWriteRows","errors","bulkInsertDocs","insert","flatClone","push","bulkUpdateDocs","docId","documentInDbWithLokiKey","getFromMapOrThrow","writeDoc","Object","assign","$loki","update","databaseState","saveQueue","addWrite","eventBulk","events","lastState","newestRow","checkpoint","lwt","_meta","endTime","next","ids","deleted","_deleted","preparedQueryOriginal","preparedQuery","selector","transformRegexToRegExp","skip","limit","Infinity","skipPlusLimit","mustRunMatcher","hasDeepProperty","lokiQuery","chain","find","sort","getLokiSortComparator","offset","foundDocuments","data","map","lokiDoc","queryMatcher","getQueryMatcher","filter","d","slice","documents","result","mode","_documentId","_attachmentId","_digest","Error","asObservable","minimumDeletedTime","deleteAmountPerRun","maxDeletionTime","$lt","closed","complete","delete","dbState","getLokiDatabase","run","closeLokiCollections","database","removeCollection","name","_taskSolution","createLokiLocalState","params","indices","indexes","idx","isMaybeReadonlyArray","lokiCollectionName","version","collectionOptions","unique","LOKIJS_COLLECTION_DEFAULT_OPTIONS","addCollection","collections","createLokiStorageInstance","broadcastChannelRefObject","multiInstance","getLokiLeaderElector","instance","addRxStorageMultiInstanceSupport","RX_STORAGE_NAME_LOKIJS","undefined","closeBefore","removeBroadcastChannelReference","removeBefore"],"sources":["../../../../src/plugins/storage-lokijs/rx-storage-instance-loki.ts"],"sourcesContent":["import {\n Subject,\n Observable\n} from 'rxjs';\nimport {\n flatClone,\n now,\n ensureNotFalsy,\n isMaybeReadonlyArray,\n getFromMapOrThrow,\n hasDeepProperty\n} from '../utils/index.ts';\nimport { newRxError } from '../../rx-error.ts';\nimport type {\n RxStorageInstance,\n LokiSettings,\n RxStorageChangeEvent,\n RxDocumentData,\n BulkWriteRow,\n RxStorageBulkWriteResponse,\n RxStorageQueryResult,\n RxJsonSchema,\n MangoQuery,\n LokiStorageInternals,\n RxStorageInstanceCreationParams,\n LokiDatabaseSettings,\n LokiLocalDatabaseState,\n EventBulk,\n StringKeys,\n DeepReadonly,\n RxConflictResultionTask,\n RxConflictResultionTaskSolution,\n RxStorageDefaultCheckpoint,\n RxStorageCountResult,\n PreparedQuery\n} from '../../types/index.d.ts';\nimport {\n closeLokiCollections,\n getLokiDatabase,\n OPEN_LOKIJS_STORAGE_INSTANCES,\n LOKIJS_COLLECTION_DEFAULT_OPTIONS,\n stripLokiKey,\n getLokiSortComparator,\n getLokiLeaderElector,\n requestRemoteInstance,\n mustUseLocalState,\n handleRemoteRequest,\n RX_STORAGE_NAME_LOKIJS,\n transformRegexToRegExp\n} from './lokijs-helper.ts';\nimport type { RxStorageLoki } from './rx-storage-lokijs.ts';\nimport { getPrimaryFieldOfPrimaryKey } from '../../rx-schema-helper.ts';\nimport { categorizeBulkWriteRows } from '../../rx-storage-helper.ts';\nimport {\n addRxStorageMultiInstanceSupport,\n removeBroadcastChannelReference\n} from '../../rx-storage-multiinstance.ts';\nimport { getQueryMatcher } from '../../rx-query-helper.ts';\n\nlet instanceId = now();\n\nexport class RxStorageInstanceLoki implements RxStorageInstance<\n RxDocType,\n LokiStorageInternals,\n LokiSettings,\n RxStorageDefaultCheckpoint\n> {\n\n public readonly primaryPath: StringKeys>;\n private changes$: Subject>, RxStorageDefaultCheckpoint>> = new Subject();\n public readonly instanceId = instanceId++;\n\n public closed?: Promise;\n\n constructor(\n public readonly databaseInstanceToken: string,\n public readonly storage: RxStorageLoki,\n public readonly databaseName: string,\n public readonly collectionName: string,\n public readonly schema: Readonly>>,\n public readonly internals: LokiStorageInternals,\n public readonly options: Readonly,\n public readonly databaseSettings: LokiDatabaseSettings\n ) {\n this.primaryPath = getPrimaryFieldOfPrimaryKey(this.schema.primaryKey);\n OPEN_LOKIJS_STORAGE_INSTANCES.add(this);\n if (this.internals.leaderElector) {\n\n\n /**\n * To run handleRemoteRequest(),\n * the instance will call its own methods.\n * But these methods could have already been swapped out by a RxStorageWrapper\n * so we must store the original methods here and use them instead.\n */\n const copiedSelf: RxStorageInstance = {\n bulkWrite: this.bulkWrite.bind(this),\n changeStream: this.changeStream.bind(this),\n cleanup: this.cleanup.bind(this),\n close: this.close.bind(this),\n query: this.query.bind(this),\n count: this.count.bind(this),\n findDocumentsById: this.findDocumentsById.bind(this),\n collectionName: this.collectionName,\n databaseName: this.databaseName,\n conflictResultionTasks: this.conflictResultionTasks.bind(this),\n getAttachmentData: this.getAttachmentData.bind(this),\n internals: this.internals,\n options: this.options,\n remove: this.remove.bind(this),\n resolveConflictResultionTask: this.resolveConflictResultionTask.bind(this),\n schema: this.schema\n };\n\n this.internals.leaderElector.awaitLeadership().then(() => {\n // this instance is leader now, so it has to reply to queries from other instances\n ensureNotFalsy(this.internals.leaderElector).broadcastChannel\n .addEventListener('message', (msg) => handleRemoteRequest(copiedSelf as any, msg));\n }).catch(() => { });\n }\n }\n\n async bulkWrite(\n documentWrites: BulkWriteRow[],\n context: string\n ): Promise> {\n if (documentWrites.length === 0) {\n throw newRxError('P2', {\n args: {\n documentWrites\n }\n });\n }\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'bulkWrite', [documentWrites]);\n }\n\n const ret: RxStorageBulkWriteResponse = {\n success: [],\n error: []\n };\n\n const docsInDb: Map[StringKeys], RxDocumentData> = new Map();\n const docsInDbWithLokiKey: Map<\n RxDocumentData[StringKeys],\n RxDocumentData & { $loki: number; }\n > = new Map();\n documentWrites.forEach(writeRow => {\n const id = writeRow.document[this.primaryPath];\n const documentInDb = localState.collection.by(this.primaryPath, id);\n if (documentInDb) {\n docsInDbWithLokiKey.set(id as any, documentInDb);\n docsInDb.set(id as any, stripLokiKey(documentInDb));\n }\n });\n\n const categorized = categorizeBulkWriteRows(\n this,\n this.primaryPath as any,\n docsInDb,\n documentWrites,\n context\n );\n ret.error = categorized.errors;\n\n categorized.bulkInsertDocs.forEach(writeRow => {\n localState.collection.insert(flatClone(writeRow.document));\n ret.success.push(writeRow.document);\n });\n categorized.bulkUpdateDocs.forEach(writeRow => {\n const docId = writeRow.document[this.primaryPath];\n const documentInDbWithLokiKey = getFromMapOrThrow(docsInDbWithLokiKey, docId as any);\n const writeDoc: any = Object.assign(\n {},\n writeRow.document,\n {\n $loki: documentInDbWithLokiKey.$loki\n }\n );\n localState.collection.update(writeDoc);\n ret.success.push(writeRow.document);\n });\n localState.databaseState.saveQueue.addWrite();\n\n if (categorized.eventBulk.events.length > 0) {\n const lastState = ensureNotFalsy(categorized.newestRow).document;\n categorized.eventBulk.checkpoint = {\n id: lastState[this.primaryPath],\n lwt: lastState._meta.lwt\n };\n categorized.eventBulk.endTime = now();\n this.changes$.next(categorized.eventBulk);\n }\n\n return ret;\n }\n async findDocumentsById(ids: string[], deleted: boolean): Promise[]> {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'findDocumentsById', [ids, deleted]);\n }\n\n const ret: RxDocumentData[] = [];\n ids.forEach(id => {\n const documentInDb = localState.collection.by(this.primaryPath, id);\n if (\n documentInDb &&\n (!documentInDb._deleted || deleted)\n ) {\n ret.push(stripLokiKey(documentInDb));\n }\n });\n return ret;\n }\n async query(preparedQueryOriginal: PreparedQuery): Promise> {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'query', [preparedQueryOriginal]);\n }\n\n let preparedQuery = ensureNotFalsy(preparedQueryOriginal.query);\n if (preparedQuery.selector) {\n preparedQuery = flatClone(preparedQuery);\n preparedQuery.selector = transformRegexToRegExp(preparedQuery.selector);\n }\n\n const query = preparedQueryOriginal.query;\n const skip = query.skip ? query.skip : 0;\n const limit = query.limit ? query.limit : Infinity;\n const skipPlusLimit = skip + limit;\n\n /**\n * LokiJS is not able to give correct results for some\n * operators, so we have to check all documents in that case\n * and laster apply skip and limit manually.\n * @link https://github.com/pubkey/rxdb/issues/5320\n */\n let mustRunMatcher = false;\n if (hasDeepProperty(preparedQuery.selector, '$in')) {\n mustRunMatcher = true;\n }\n\n\n let lokiQuery = localState.collection\n .chain()\n .find(mustRunMatcher ? {} : preparedQuery.selector);\n\n if (preparedQuery.sort) {\n lokiQuery = lokiQuery.sort(getLokiSortComparator(this.schema, preparedQuery));\n }\n\n\n\n\n /**\n * Offset must be used before limit in LokiJS\n * @link https://github.com/techfort/LokiJS/issues/570\n */\n if (!mustRunMatcher && preparedQuery.skip) {\n lokiQuery = lokiQuery.offset(preparedQuery.skip);\n }\n\n if (!mustRunMatcher && preparedQuery.limit) {\n lokiQuery = lokiQuery.limit(preparedQuery.limit);\n }\n\n let foundDocuments = lokiQuery.data().map((lokiDoc: any) => stripLokiKey(lokiDoc));\n\n\n /**\n * LokiJS returned wrong results on some queries\n * with complex indexes. Therefore we run the query-match\n * over all result docs to patch this bug.\n * TODO create an issue at the LokiJS repository.\n */\n const queryMatcher = getQueryMatcher(\n this.schema,\n preparedQuery as any\n );\n foundDocuments = foundDocuments.filter((d: any) => queryMatcher(d));\n\n\n if (mustRunMatcher) {\n foundDocuments = foundDocuments.slice(skip, skipPlusLimit);\n }\n\n return {\n documents: foundDocuments\n };\n }\n async count(\n preparedQuery: PreparedQuery\n ): Promise {\n const result = await this.query(preparedQuery);\n return {\n count: result.documents.length,\n mode: 'fast'\n };\n }\n getAttachmentData(_documentId: string, _attachmentId: string, _digest: string): Promise {\n throw new Error('Attachments are not implemented in the lokijs RxStorage. Make a pull request.');\n }\n\n changeStream(): Observable>, RxStorageDefaultCheckpoint>> {\n return this.changes$.asObservable();\n }\n\n async cleanup(minimumDeletedTime: number): Promise {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'cleanup', [minimumDeletedTime]);\n }\n\n const deleteAmountPerRun = 10;\n const maxDeletionTime = now() - minimumDeletedTime;\n const query = localState.collection\n .chain()\n .find({\n _deleted: true,\n '_meta.lwt': {\n $lt: maxDeletionTime\n }\n }).limit(deleteAmountPerRun);\n const foundDocuments = query.data();\n if (foundDocuments.length > 0) {\n localState.collection.remove(foundDocuments);\n localState.databaseState.saveQueue.addWrite();\n }\n\n return foundDocuments.length !== deleteAmountPerRun;\n }\n\n async close(): Promise {\n if (this.closed) {\n return this.closed;\n }\n this.closed = (async () => {\n this.changes$.complete();\n OPEN_LOKIJS_STORAGE_INSTANCES.delete(this);\n if (this.internals.localState) {\n const localState = await this.internals.localState;\n const dbState = await getLokiDatabase(\n this.databaseName,\n this.databaseSettings\n );\n await dbState.saveQueue.run();\n await closeLokiCollections(\n this.databaseName,\n [\n localState.collection\n ]\n );\n }\n })();\n return this.closed;\n }\n async remove(): Promise {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'remove', []);\n }\n localState.databaseState.database.removeCollection(localState.collection.name);\n await localState.databaseState.saveQueue.run();\n return this.close();\n }\n\n conflictResultionTasks(): Observable> {\n return new Subject();\n }\n async resolveConflictResultionTask(_taskSolution: RxConflictResultionTaskSolution): Promise { }\n\n}\n\nexport async function createLokiLocalState(\n params: RxStorageInstanceCreationParams,\n databaseSettings: LokiDatabaseSettings\n): Promise {\n if (!params.options) {\n params.options = {};\n }\n\n const databaseState = await getLokiDatabase(\n params.databaseName,\n databaseSettings\n );\n\n /**\n * Construct loki indexes from RxJsonSchema indexes.\n * TODO what about compound indexes? Are they possible in lokijs?\n */\n const indices: string[] = [];\n if (params.schema.indexes) {\n params.schema.indexes.forEach(idx => {\n if (!isMaybeReadonlyArray(idx)) {\n indices.push(idx);\n }\n });\n }\n /**\n * LokiJS has no concept of custom primary key, they use a number-id that is generated.\n * To be able to query fast by primary key, we always add an index to the primary.\n */\n const primaryKey = getPrimaryFieldOfPrimaryKey(params.schema.primaryKey);\n indices.push(primaryKey as string);\n\n const lokiCollectionName = params.collectionName + '-' + params.schema.version;\n const collectionOptions: Partial = Object.assign(\n {},\n lokiCollectionName,\n {\n indices: indices as string[],\n unique: [primaryKey]\n } as any,\n LOKIJS_COLLECTION_DEFAULT_OPTIONS\n );\n\n const collection: any = databaseState.database.addCollection(\n lokiCollectionName,\n collectionOptions as any\n );\n databaseState.collections[params.collectionName] = collection;\n const ret: LokiLocalDatabaseState = {\n databaseState,\n collection\n };\n\n return ret;\n}\n\n\nexport async function createLokiStorageInstance(\n storage: RxStorageLoki,\n params: RxStorageInstanceCreationParams,\n databaseSettings: LokiDatabaseSettings\n): Promise> {\n const internals: LokiStorageInternals = {};\n\n const broadcastChannelRefObject: DeepReadonly = {};\n\n\n if (params.multiInstance) {\n const leaderElector = getLokiLeaderElector(\n params.databaseInstanceToken,\n broadcastChannelRefObject,\n params.databaseName\n );\n internals.leaderElector = leaderElector;\n } else {\n // optimisation shortcut, directly create db is non multi instance.\n internals.localState = createLokiLocalState(params, databaseSettings);\n await internals.localState;\n }\n\n const instance = new RxStorageInstanceLoki(\n params.databaseInstanceToken,\n storage,\n params.databaseName,\n params.collectionName,\n params.schema,\n internals,\n params.options,\n databaseSettings\n );\n\n await addRxStorageMultiInstanceSupport(\n RX_STORAGE_NAME_LOKIJS,\n params,\n instance,\n internals.leaderElector ? internals.leaderElector.broadcastChannel : undefined\n );\n\n if (params.multiInstance) {\n /**\n * Clean up the broadcast-channel reference on close()\n */\n const closeBefore = instance.close.bind(instance);\n instance.close = function () {\n removeBroadcastChannelReference(\n params.databaseInstanceToken,\n broadcastChannelRefObject\n );\n return closeBefore();\n };\n const removeBefore = instance.remove.bind(instance);\n instance.remove = function () {\n removeBroadcastChannelReference(\n params.databaseInstanceToken,\n broadcastChannelRefObject\n );\n return removeBefore();\n };\n\n /**\n * Directly create the localState when/if the db becomes leader.\n */\n ensureNotFalsy(internals.leaderElector)\n .awaitLeadership()\n .then(() => {\n if (!instance.closed) {\n mustUseLocalState(instance);\n }\n });\n }\n\n\n return instance;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAQA,IAAAE,QAAA,GAAAF,OAAA;AAwBA,IAAAG,aAAA,GAAAH,OAAA;AAeA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,uBAAA,GAAAN,OAAA;AAIA,IAAAO,cAAA,GAAAP,OAAA;AAEA,IAAIQ,UAAU,GAAG,IAAAC,UAAG,EAAC,CAAC;AAAC,IAEVC,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA;EAa9B,SAAAA,sBACoBE,qBAA6B,EAC7BC,OAAsB,EACtBC,YAAoB,EACpBC,cAAsB,EACtBC,MAAyD,EACzDC,SAA+B,EAC/BC,OAA+B,EAC/BC,gBAAsC,EACxD;IAAA,KAdMC,QAAQ,GAAoG,IAAIC,aAAO,CAAC,CAAC;IAAA,KACjHb,UAAU,GAAGA,UAAU,EAAE;IAAA,KAKrBI,qBAA6B,GAA7BA,qBAA6B;IAAA,KAC7BC,OAAsB,GAAtBA,OAAsB;IAAA,KACtBC,YAAoB,GAApBA,YAAoB;IAAA,KACpBC,cAAsB,GAAtBA,cAAsB;IAAA,KACtBC,MAAyD,GAAzDA,MAAyD;IAAA,KACzDC,SAA+B,GAA/BA,SAA+B;IAAA,KAC/BC,OAA+B,GAA/BA,OAA+B;IAAA,KAC/BC,gBAAsC,GAAtCA,gBAAsC;IAEtD,IAAI,CAACG,WAAW,GAAG,IAAAC,2CAA2B,EAAC,IAAI,CAACP,MAAM,CAACQ,UAAU,CAAC;IACtEC,2CAA6B,CAACC,GAAG,CAAC,IAAI,CAAC;IACvC,IAAI,IAAI,CAACT,SAAS,CAACU,aAAa,EAAE;MAG9B;AACZ;AACA;AACA;AACA;AACA;MACY,IAAMC,UAAkD,GAAG;QACvDC,SAAS,EAAE,IAAI,CAACA,SAAS,CAACC,IAAI,CAAC,IAAI,CAAC;QACpCC,YAAY,EAAE,IAAI,CAACA,YAAY,CAACD,IAAI,CAAC,IAAI,CAAC;QAC1CE,OAAO,EAAE,IAAI,CAACA,OAAO,CAACF,IAAI,CAAC,IAAI,CAAC;QAChCG,KAAK,EAAE,IAAI,CAACA,KAAK,CAACH,IAAI,CAAC,IAAI,CAAC;QAC5BI,KAAK,EAAE,IAAI,CAACA,KAAK,CAACJ,IAAI,CAAC,IAAI,CAAC;QAC5BK,KAAK,EAAE,IAAI,CAACA,KAAK,CAACL,IAAI,CAAC,IAAI,CAAC;QAC5BM,iBAAiB,EAAE,IAAI,CAACA,iBAAiB,CAACN,IAAI,CAAC,IAAI,CAAC;QACpDf,cAAc,EAAE,IAAI,CAACA,cAAc;QACnCD,YAAY,EAAE,IAAI,CAACA,YAAY;QAC/BuB,sBAAsB,EAAE,IAAI,CAACA,sBAAsB,CAACP,IAAI,CAAC,IAAI,CAAC;QAC9DQ,iBAAiB,EAAE,IAAI,CAACA,iBAAiB,CAACR,IAAI,CAAC,IAAI,CAAC;QACpDb,SAAS,EAAE,IAAI,CAACA,SAAS;QACzBC,OAAO,EAAE,IAAI,CAACA,OAAO;QACrBqB,MAAM,EAAE,IAAI,CAACA,MAAM,CAACT,IAAI,CAAC,IAAI,CAAC;QAC9BU,4BAA4B,EAAE,IAAI,CAACA,4BAA4B,CAACV,IAAI,CAAC,IAAI,CAAC;QAC1Ed,MAAM,EAAE,IAAI,CAACA;MACjB,CAAC;MAED,IAAI,CAACC,SAAS,CAACU,aAAa,CAACc,eAAe,CAAC,CAAC,CAACC,IAAI,CAAC,MAAM;QACtD;QACA,IAAAC,qBAAc,EAAC,IAAI,CAAC1B,SAAS,CAACU,aAAa,CAAC,CAACiB,gBAAgB,CACxDC,gBAAgB,CAAC,SAAS,EAAGC,GAAG,IAAK,IAAAC,iCAAmB,EAACnB,UAAU,EAASkB,GAAG,CAAC,CAAC;MAC1F,CAAC,CAAC,CAACE,KAAK,CAAC,MAAM,CAAE,CAAC,CAAC;IACvB;EACJ;EAAC,IAAAC,MAAA,GAAAvC,qBAAA,CAAAwC,SAAA;EAAAD,MAAA,CAEKpB,SAAS,GAAf,eAAAA,UACIsB,cAAyC,EACzCC,OAAe,EAC+B;IAC9C,IAAID,cAAc,CAACE,MAAM,KAAK,CAAC,EAAE;MAC7B,MAAM,IAAAC,mBAAU,EAAC,IAAI,EAAE;QACnBC,IAAI,EAAE;UACFJ;QACJ;MACJ,CAAC,CAAC;IACN;IACA,IAAMK,UAAU,GAAG,MAAM,IAAAC,+BAAiB,EAAC,IAAI,CAAC;IAChD,IAAI,CAACD,UAAU,EAAE;MACb,OAAO,IAAAE,mCAAqB,EAAC,IAAI,EAAE,WAAW,EAAE,CAACP,cAAc,CAAC,CAAC;IACrE;IAEA,IAAMQ,GAA0C,GAAG;MAC/CC,OAAO,EAAE,EAAE;MACXC,KAAK,EAAE;IACX,CAAC;IAED,IAAMC,QAA0F,GAAG,IAAIC,GAAG,CAAC,CAAC;IAC5G,IAAMC,mBAGL,GAAG,IAAID,GAAG,CAAC,CAAC;IACbZ,cAAc,CAACc,OAAO,CAACC,QAAQ,IAAI;MAC/B,IAAMC,EAAE,GAAGD,QAAQ,CAACE,QAAQ,CAAC,IAAI,CAAC9C,WAAW,CAAC;MAC9C,IAAM+C,YAAY,GAAGb,UAAU,CAACc,UAAU,CAACC,EAAE,CAAC,IAAI,CAACjD,WAAW,EAAE6C,EAAE,CAAC;MACnE,IAAIE,YAAY,EAAE;QACdL,mBAAmB,CAACQ,GAAG,CAACL,EAAE,EAASE,YAAY,CAAC;QAChDP,QAAQ,CAACU,GAAG,CAACL,EAAE,EAAS,IAAAM,0BAAY,EAACJ,YAAY,CAAC,CAAC;MACvD;IACJ,CAAC,CAAC;IAEF,IAAMK,WAAW,GAAG,IAAAC,wCAAuB,EACvC,IAAI,EACJ,IAAI,CAACrD,WAAW,EAChBwC,QAAQ,EACRX,cAAc,EACdC,OACJ,CAAC;IACDO,GAAG,CAACE,KAAK,GAAGa,WAAW,CAACE,MAAM;IAE9BF,WAAW,CAACG,cAAc,CAACZ,OAAO,CAACC,QAAQ,IAAI;MAC3CV,UAAU,CAACc,UAAU,CAACQ,MAAM,CAAC,IAAAC,gBAAS,EAACb,QAAQ,CAACE,QAAQ,CAAC,CAAC;MAC1DT,GAAG,CAACC,OAAO,CAACoB,IAAI,CAACd,QAAQ,CAACE,QAAQ,CAAC;IACvC,CAAC,CAAC;IACFM,WAAW,CAACO,cAAc,CAAChB,OAAO,CAACC,QAAQ,IAAI;MAC3C,IAAMgB,KAAK,GAAGhB,QAAQ,CAACE,QAAQ,CAAC,IAAI,CAAC9C,WAAW,CAAC;MACjD,IAAM6D,uBAAuB,GAAG,IAAAC,wBAAiB,EAACpB,mBAAmB,EAAEkB,KAAY,CAAC;MACpF,IAAMG,QAAa,GAAGC,MAAM,CAACC,MAAM,CAC/B,CAAC,CAAC,EACFrB,QAAQ,CAACE,QAAQ,EACjB;QACIoB,KAAK,EAAEL,uBAAuB,CAACK;MACnC,CACJ,CAAC;MACDhC,UAAU,CAACc,UAAU,CAACmB,MAAM,CAACJ,QAAQ,CAAC;MACtC1B,GAAG,CAACC,OAAO,CAACoB,IAAI,CAACd,QAAQ,CAACE,QAAQ,CAAC;IACvC,CAAC,CAAC;IACFZ,UAAU,CAACkC,aAAa,CAACC,SAAS,CAACC,QAAQ,CAAC,CAAC;IAE7C,IAAIlB,WAAW,CAACmB,SAAS,CAACC,MAAM,CAACzC,MAAM,GAAG,CAAC,EAAE;MACzC,IAAM0C,SAAS,GAAG,IAAApD,qBAAc,EAAC+B,WAAW,CAACsB,SAAS,CAAC,CAAC5B,QAAQ;MAChEM,WAAW,CAACmB,SAAS,CAACI,UAAU,GAAG;QAC/B9B,EAAE,EAAE4B,SAAS,CAAC,IAAI,CAACzE,WAAW,CAAC;QAC/B4E,GAAG,EAAEH,SAAS,CAACI,KAAK,CAACD;MACzB,CAAC;MACDxB,WAAW,CAACmB,SAAS,CAACO,OAAO,GAAG,IAAA3F,UAAG,EAAC,CAAC;MACrC,IAAI,CAACW,QAAQ,CAACiF,IAAI,CAAC3B,WAAW,CAACmB,SAAS,CAAC;IAC7C;IAEA,OAAOlC,GAAG;EACd,CAAC;EAAAV,MAAA,CACKb,iBAAiB,GAAvB,eAAAA,kBAAwBkE,GAAa,EAAEC,OAAgB,EAAwC;IAC3F,IAAM/C,UAAU,GAAG,MAAM,IAAAC,+BAAiB,EAAC,IAAI,CAAC;IAChD,IAAI,CAACD,UAAU,EAAE;MACb,OAAO,IAAAE,mCAAqB,EAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC4C,GAAG,EAAEC,OAAO,CAAC,CAAC;IAC3E;IAEA,IAAM5C,GAAgC,GAAG,EAAE;IAC3C2C,GAAG,CAACrC,OAAO,CAACE,EAAE,IAAI;MACd,IAAME,YAAY,GAAGb,UAAU,CAACc,UAAU,CAACC,EAAE,CAAC,IAAI,CAACjD,WAAW,EAAE6C,EAAE,CAAC;MACnE,IACIE,YAAY,KACX,CAACA,YAAY,CAACmC,QAAQ,IAAID,OAAO,CAAC,EACrC;QACE5C,GAAG,CAACqB,IAAI,CAAC,IAAAP,0BAAY,EAACJ,YAAY,CAAC,CAAC;MACxC;IACJ,CAAC,CAAC;IACF,OAAOV,GAAG;EACd,CAAC;EAAAV,MAAA,CACKf,KAAK,GAAX,eAAAA,MAAYuE,qBAA+C,EAA4C;IACnG,IAAMjD,UAAU,GAAG,MAAM,IAAAC,+BAAiB,EAAC,IAAI,CAAC;IAChD,IAAI,CAACD,UAAU,EAAE;MACb,OAAO,IAAAE,mCAAqB,EAAC,IAAI,EAAE,OAAO,EAAE,CAAC+C,qBAAqB,CAAC,CAAC;IACxE;IAEA,IAAIC,aAAa,GAAG,IAAA/D,qBAAc,EAAC8D,qBAAqB,CAACvE,KAAK,CAAC;IAC/D,IAAIwE,aAAa,CAACC,QAAQ,EAAE;MACxBD,aAAa,GAAG,IAAA3B,gBAAS,EAAC2B,aAAa,CAAC;MACxCA,aAAa,CAACC,QAAQ,GAAG,IAAAC,oCAAsB,EAACF,aAAa,CAACC,QAAQ,CAAC;IAC3E;IAEA,IAAMzE,KAAK,GAAGuE,qBAAqB,CAACvE,KAAK;IACzC,IAAM2E,IAAI,GAAG3E,KAAK,CAAC2E,IAAI,GAAG3E,KAAK,CAAC2E,IAAI,GAAG,CAAC;IACxC,IAAMC,KAAK,GAAG5E,KAAK,CAAC4E,KAAK,GAAG5E,KAAK,CAAC4E,KAAK,GAAGC,QAAQ;IAClD,IAAMC,aAAa,GAAGH,IAAI,GAAGC,KAAK;;IAElC;AACR;AACA;AACA;AACA;AACA;IACQ,IAAIG,cAAc,GAAG,KAAK;IAC1B,IAAI,IAAAC,sBAAe,EAACR,aAAa,CAACC,QAAQ,EAAE,KAAK,CAAC,EAAE;MAChDM,cAAc,GAAG,IAAI;IACzB;IAGA,IAAIE,SAAS,GAAG3D,UAAU,CAACc,UAAU,CAChC8C,KAAK,CAAC,CAAC,CACPC,IAAI,CAACJ,cAAc,GAAG,CAAC,CAAC,GAAGP,aAAa,CAACC,QAAQ,CAAC;IAEvD,IAAID,aAAa,CAACY,IAAI,EAAE;MACpBH,SAAS,GAAGA,SAAS,CAACG,IAAI,CAAC,IAAAC,mCAAqB,EAAC,IAAI,CAACvG,MAAM,EAAE0F,aAAa,CAAC,CAAC;IACjF;;IAKA;AACR;AACA;AACA;IACQ,IAAI,CAACO,cAAc,IAAIP,aAAa,CAACG,IAAI,EAAE;MACvCM,SAAS,GAAGA,SAAS,CAACK,MAAM,CAACd,aAAa,CAACG,IAAI,CAAC;IACpD;IAEA,IAAI,CAACI,cAAc,IAAIP,aAAa,CAACI,KAAK,EAAE;MACxCK,SAAS,GAAGA,SAAS,CAACL,KAAK,CAACJ,aAAa,CAACI,KAAK,CAAC;IACpD;IAEA,IAAIW,cAAc,GAAGN,SAAS,CAACO,IAAI,CAAC,CAAC,CAACC,GAAG,CAAEC,OAAY,IAAK,IAAAnD,0BAAY,EAACmD,OAAO,CAAC,CAAC;;IAGlF;AACR;AACA;AACA;AACA;AACA;IACQ,IAAMC,YAAY,GAAG,IAAAC,8BAAe,EAChC,IAAI,CAAC9G,MAAM,EACX0F,aACJ,CAAC;IACDe,cAAc,GAAGA,cAAc,CAACM,MAAM,CAAEC,CAAM,IAAKH,YAAY,CAACG,CAAC,CAAC,CAAC;IAGnE,IAAIf,cAAc,EAAE;MAChBQ,cAAc,GAAGA,cAAc,CAACQ,KAAK,CAACpB,IAAI,EAAEG,aAAa,CAAC;IAC9D;IAEA,OAAO;MACHkB,SAAS,EAAET;IACf,CAAC;EACL,CAAC;EAAAxE,MAAA,CACKd,KAAK,GAAX,eAAAA,MACIuE,aAAuC,EACV;IAC7B,IAAMyB,MAAM,GAAG,MAAM,IAAI,CAACjG,KAAK,CAACwE,aAAa,CAAC;IAC9C,OAAO;MACHvE,KAAK,EAAEgG,MAAM,CAACD,SAAS,CAAC7E,MAAM;MAC9B+E,IAAI,EAAE;IACV,CAAC;EACL,CAAC;EAAAnF,MAAA,CACDX,iBAAiB,GAAjB,SAAAA,kBAAkB+F,WAAmB,EAAEC,aAAqB,EAAEC,OAAe,EAAmB;IAC5F,MAAM,IAAIC,KAAK,CAAC,+EAA+E,CAAC;EACpG,CAAC;EAAAvF,MAAA,CAEDlB,YAAY,GAAZ,SAAAA,aAAA,EAAmH;IAC/G,OAAO,IAAI,CAACX,QAAQ,CAACqH,YAAY,CAAC,CAAC;EACvC,CAAC;EAAAxF,MAAA,CAEKjB,OAAO,GAAb,eAAAA,QAAc0G,kBAA0B,EAAoB;IACxD,IAAMlF,UAAU,GAAG,MAAM,IAAAC,+BAAiB,EAAC,IAAI,CAAC;IAChD,IAAI,CAACD,UAAU,EAAE;MACb,OAAO,IAAAE,mCAAqB,EAAC,IAAI,EAAE,SAAS,EAAE,CAACgF,kBAAkB,CAAC,CAAC;IACvE;IAEA,IAAMC,kBAAkB,GAAG,EAAE;IAC7B,IAAMC,eAAe,GAAG,IAAAnI,UAAG,EAAC,CAAC,GAAGiI,kBAAkB;IAClD,IAAMxG,KAAK,GAAGsB,UAAU,CAACc,UAAU,CAC9B8C,KAAK,CAAC,CAAC,CACPC,IAAI,CAAC;MACFb,QAAQ,EAAE,IAAI;MACd,WAAW,EAAE;QACTqC,GAAG,EAAED;MACT;IACJ,CAAC,CAAC,CAAC9B,KAAK,CAAC6B,kBAAkB,CAAC;IAChC,IAAMlB,cAAc,GAAGvF,KAAK,CAACwF,IAAI,CAAC,CAAC;IACnC,IAAID,cAAc,CAACpE,MAAM,GAAG,CAAC,EAAE;MAC3BG,UAAU,CAACc,UAAU,CAAC/B,MAAM,CAACkF,cAAc,CAAC;MAC5CjE,UAAU,CAACkC,aAAa,CAACC,SAAS,CAACC,QAAQ,CAAC,CAAC;IACjD;IAEA,OAAO6B,cAAc,CAACpE,MAAM,KAAKsF,kBAAkB;EACvD,CAAC;EAAA1F,MAAA,CAEKhB,KAAK,GAAX,eAAAA,MAAA,EAA6B;IACzB,IAAI,IAAI,CAAC6G,MAAM,EAAE;MACb,OAAO,IAAI,CAACA,MAAM;IACtB;IACA,IAAI,CAACA,MAAM,GAAG,CAAC,YAAY;MACvB,IAAI,CAAC1H,QAAQ,CAAC2H,QAAQ,CAAC,CAAC;MACxBtH,2CAA6B,CAACuH,MAAM,CAAC,IAAI,CAAC;MAC1C,IAAI,IAAI,CAAC/H,SAAS,CAACuC,UAAU,EAAE;QAC3B,IAAMA,UAAU,GAAG,MAAM,IAAI,CAACvC,SAAS,CAACuC,UAAU;QAClD,IAAMyF,OAAO,GAAG,MAAM,IAAAC,6BAAe,EACjC,IAAI,CAACpI,YAAY,EACjB,IAAI,CAACK,gBACT,CAAC;QACD,MAAM8H,OAAO,CAACtD,SAAS,CAACwD,GAAG,CAAC,CAAC;QAC7B,MAAM,IAAAC,kCAAoB,EACtB,IAAI,CAACtI,YAAY,EACjB,CACI0C,UAAU,CAACc,UAAU,CAE7B,CAAC;MACL;IACJ,CAAC,EAAE,CAAC;IACJ,OAAO,IAAI,CAACwE,MAAM;EACtB,CAAC;EAAA7F,MAAA,CACKV,MAAM,GAAZ,eAAAA,OAAA,EAA8B;IAC1B,IAAMiB,UAAU,GAAG,MAAM,IAAAC,+BAAiB,EAAC,IAAI,CAAC;IAChD,IAAI,CAACD,UAAU,EAAE;MACb,OAAO,IAAAE,mCAAqB,EAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC;IACpD;IACAF,UAAU,CAACkC,aAAa,CAAC2D,QAAQ,CAACC,gBAAgB,CAAC9F,UAAU,CAACc,UAAU,CAACiF,IAAI,CAAC;IAC9E,MAAM/F,UAAU,CAACkC,aAAa,CAACC,SAAS,CAACwD,GAAG,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAClH,KAAK,CAAC,CAAC;EACvB,CAAC;EAAAgB,MAAA,CAEDZ,sBAAsB,GAAtB,SAAAA,uBAAA,EAAyE;IACrE,OAAO,IAAIhB,aAAO,CAAC,CAAC;EACxB,CAAC;EAAA4B,MAAA,CACKT,4BAA4B,GAAlC,eAAAA,6BAAmCgH,aAAyD,EAAiB,CAAE,CAAC;EAAA,OAAA9I,qBAAA;AAAA;AAI7G,eAAe+I,oBAAoBA,CACtCC,MAAgE,EAChEvI,gBAAsC,EACP;EAC/B,IAAI,CAACuI,MAAM,CAACxI,OAAO,EAAE;IACjBwI,MAAM,CAACxI,OAAO,GAAG,CAAC,CAAC;EACvB;EAEA,IAAMwE,aAAa,GAAG,MAAM,IAAAwD,6BAAe,EACvCQ,MAAM,CAAC5I,YAAY,EACnBK,gBACJ,CAAC;;EAED;AACJ;AACA;AACA;EACI,IAAMwI,OAAiB,GAAG,EAAE;EAC5B,IAAID,MAAM,CAAC1I,MAAM,CAAC4I,OAAO,EAAE;IACvBF,MAAM,CAAC1I,MAAM,CAAC4I,OAAO,CAAC3F,OAAO,CAAC4F,GAAG,IAAI;MACjC,IAAI,CAAC,IAAAC,2BAAoB,EAACD,GAAG,CAAC,EAAE;QAC5BF,OAAO,CAAC3E,IAAI,CAAC6E,GAAG,CAAC;MACrB;IACJ,CAAC,CAAC;EACN;EACA;AACJ;AACA;AACA;EACI,IAAMrI,UAAU,GAAG,IAAAD,2CAA2B,EAACmI,MAAM,CAAC1I,MAAM,CAACQ,UAAU,CAAC;EACxEmI,OAAO,CAAC3E,IAAI,CAACxD,UAAoB,CAAC;EAElC,IAAMuI,kBAAkB,GAAGL,MAAM,CAAC3I,cAAc,GAAG,GAAG,GAAG2I,MAAM,CAAC1I,MAAM,CAACgJ,OAAO;EAC9E,IAAMC,iBAA+B,GAAG3E,MAAM,CAACC,MAAM,CACjD,CAAC,CAAC,EACFwE,kBAAkB,EAClB;IACIJ,OAAO,EAAEA,OAAmB;IAC5BO,MAAM,EAAE,CAAC1I,UAAU;EACvB,CAAC,EACD2I,+CACJ,CAAC;EAED,IAAM7F,UAAe,GAAGoB,aAAa,CAAC2D,QAAQ,CAACe,aAAa,CACxDL,kBAAkB,EAClBE,iBACJ,CAAC;EACDvE,aAAa,CAAC2E,WAAW,CAACX,MAAM,CAAC3I,cAAc,CAAC,GAAGuD,UAAU;EAC7D,IAAMX,GAA2B,GAAG;IAChC+B,aAAa;IACbpB;EACJ,CAAC;EAED,OAAOX,GAAG;AACd;AAGO,eAAe2G,yBAAyBA,CAC3CzJ,OAAsB,EACtB6I,MAAgE,EAChEvI,gBAAsC,EACG;EACzC,IAAMF,SAA+B,GAAG,CAAC,CAAC;EAE1C,IAAMsJ,yBAA4C,GAAG,CAAC,CAAC;EAGvD,IAAIb,MAAM,CAACc,aAAa,EAAE;IACtB,IAAM7I,aAAa,GAAG,IAAA8I,kCAAoB,EACtCf,MAAM,CAAC9I,qBAAqB,EAC5B2J,yBAAyB,EACzBb,MAAM,CAAC5I,YACX,CAAC;IACDG,SAAS,CAACU,aAAa,GAAGA,aAAa;EAC3C,CAAC,MAAM;IACH;IACAV,SAAS,CAACuC,UAAU,GAAGiG,oBAAoB,CAACC,MAAM,EAAEvI,gBAAgB,CAAC;IACrE,MAAMF,SAAS,CAACuC,UAAU;EAC9B;EAEA,IAAMkH,QAAQ,GAAG,IAAIhK,qBAAqB,CACtCgJ,MAAM,CAAC9I,qBAAqB,EAC5BC,OAAO,EACP6I,MAAM,CAAC5I,YAAY,EACnB4I,MAAM,CAAC3I,cAAc,EACrB2I,MAAM,CAAC1I,MAAM,EACbC,SAAS,EACTyI,MAAM,CAACxI,OAAO,EACdC,gBACJ,CAAC;EAED,MAAM,IAAAwJ,wDAAgC,EAClCC,oCAAsB,EACtBlB,MAAM,EACNgB,QAAQ,EACRzJ,SAAS,CAACU,aAAa,GAAGV,SAAS,CAACU,aAAa,CAACiB,gBAAgB,GAAGiI,SACzE,CAAC;EAED,IAAInB,MAAM,CAACc,aAAa,EAAE;IACtB;AACR;AACA;IACQ,IAAMM,WAAW,GAAGJ,QAAQ,CAACzI,KAAK,CAACH,IAAI,CAAC4I,QAAQ,CAAC;IACjDA,QAAQ,CAACzI,KAAK,GAAG,YAAY;MACzB,IAAA8I,uDAA+B,EAC3BrB,MAAM,CAAC9I,qBAAqB,EAC5B2J,yBACJ,CAAC;MACD,OAAOO,WAAW,CAAC,CAAC;IACxB,CAAC;IACD,IAAME,YAAY,GAAGN,QAAQ,CAACnI,MAAM,CAACT,IAAI,CAAC4I,QAAQ,CAAC;IACnDA,QAAQ,CAACnI,MAAM,GAAG,YAAY;MAC1B,IAAAwI,uDAA+B,EAC3BrB,MAAM,CAAC9I,qBAAqB,EAC5B2J,yBACJ,CAAC;MACD,OAAOS,YAAY,CAAC,CAAC;IACzB,CAAC;;IAED;AACR;AACA;IACQ,IAAArI,qBAAc,EAAC1B,SAAS,CAACU,aAAa,CAAC,CAClCc,eAAe,CAAC,CAAC,CACjBC,IAAI,CAAC,MAAM;MACR,IAAI,CAACgI,QAAQ,CAAC5B,MAAM,EAAE;QAClB,IAAArF,+BAAiB,EAACiH,QAAQ,CAAC;MAC/B;IACJ,CAAC,CAAC;EACV;EAGA,OAAOA,QAAQ;AACnB","ignoreList":[]} \ No newline at end of file +{"version":3,"file":"rx-storage-instance-loki.js","names":["_rxjs","require","_index","_rxError","_lokijsHelper","_rxSchemaHelper","_rxStorageHelper","_rxStorageMultiinstance","_rxQueryHelper","instanceId","now","RxStorageInstanceLoki","exports","databaseInstanceToken","storage","databaseName","collectionName","schema","internals","options","databaseSettings","changes$","Subject","primaryPath","getPrimaryFieldOfPrimaryKey","primaryKey","OPEN_LOKIJS_STORAGE_INSTANCES","add","leaderElector","copiedSelf","bulkWrite","bind","changeStream","cleanup","close","query","count","findDocumentsById","conflictResultionTasks","getAttachmentData","remove","resolveConflictResultionTask","awaitLeadership","then","ensureNotFalsy","broadcastChannel","addEventListener","msg","handleRemoteRequest","catch","_proto","prototype","documentWrites","context","length","newRxError","args","localState","mustUseLocalState","requestRemoteInstance","ret","success","error","docsInDb","Map","docsInDbWithLokiKey","forEach","writeRow","id","document","documentInDb","collection","by","set","stripLokiKey","categorized","categorizeBulkWriteRows","errors","bulkInsertDocs","insert","flatClone","push","bulkUpdateDocs","docId","documentInDbWithLokiKey","getFromMapOrThrow","writeDoc","Object","assign","$loki","update","databaseState","saveQueue","addWrite","eventBulk","events","lastState","newestRow","checkpoint","lwt","_meta","endTime","next","ids","deleted","_deleted","preparedQueryOriginal","preparedQuery","selector","transformRegexToRegExp","skip","limit","Infinity","skipPlusLimit","mustRunMatcher","hasDeepProperty","lokiQuery","chain","find","sort","getLokiSortComparator","foundDocuments","data","map","lokiDoc","queryMatcher","getQueryMatcher","filter","d","slice","documents","result","mode","_documentId","_attachmentId","_digest","Error","asObservable","minimumDeletedTime","deleteAmountPerRun","maxDeletionTime","$lt","closed","complete","delete","dbState","getLokiDatabase","run","closeLokiCollections","database","removeCollection","name","_taskSolution","createLokiLocalState","params","indices","indexes","idx","isMaybeReadonlyArray","lokiCollectionName","version","collectionOptions","unique","LOKIJS_COLLECTION_DEFAULT_OPTIONS","addCollection","collections","createLokiStorageInstance","broadcastChannelRefObject","multiInstance","getLokiLeaderElector","instance","addRxStorageMultiInstanceSupport","RX_STORAGE_NAME_LOKIJS","undefined","closeBefore","removeBroadcastChannelReference","removeBefore"],"sources":["../../../../src/plugins/storage-lokijs/rx-storage-instance-loki.ts"],"sourcesContent":["import {\n Subject,\n Observable\n} from 'rxjs';\nimport {\n flatClone,\n now,\n ensureNotFalsy,\n isMaybeReadonlyArray,\n getFromMapOrThrow,\n hasDeepProperty\n} from '../utils/index.ts';\nimport { newRxError } from '../../rx-error.ts';\nimport type {\n RxStorageInstance,\n LokiSettings,\n RxStorageChangeEvent,\n RxDocumentData,\n BulkWriteRow,\n RxStorageBulkWriteResponse,\n RxStorageQueryResult,\n RxJsonSchema,\n MangoQuery,\n LokiStorageInternals,\n RxStorageInstanceCreationParams,\n LokiDatabaseSettings,\n LokiLocalDatabaseState,\n EventBulk,\n StringKeys,\n DeepReadonly,\n RxConflictResultionTask,\n RxConflictResultionTaskSolution,\n RxStorageDefaultCheckpoint,\n RxStorageCountResult,\n PreparedQuery\n} from '../../types/index.d.ts';\nimport {\n closeLokiCollections,\n getLokiDatabase,\n OPEN_LOKIJS_STORAGE_INSTANCES,\n LOKIJS_COLLECTION_DEFAULT_OPTIONS,\n stripLokiKey,\n getLokiSortComparator,\n getLokiLeaderElector,\n requestRemoteInstance,\n mustUseLocalState,\n handleRemoteRequest,\n RX_STORAGE_NAME_LOKIJS,\n transformRegexToRegExp\n} from './lokijs-helper.ts';\nimport type { RxStorageLoki } from './rx-storage-lokijs.ts';\nimport { getPrimaryFieldOfPrimaryKey } from '../../rx-schema-helper.ts';\nimport { categorizeBulkWriteRows } from '../../rx-storage-helper.ts';\nimport {\n addRxStorageMultiInstanceSupport,\n removeBroadcastChannelReference\n} from '../../rx-storage-multiinstance.ts';\nimport { getQueryMatcher } from '../../rx-query-helper.ts';\n\nlet instanceId = now();\n\nexport class RxStorageInstanceLoki implements RxStorageInstance<\n RxDocType,\n LokiStorageInternals,\n LokiSettings,\n RxStorageDefaultCheckpoint\n> {\n\n public readonly primaryPath: StringKeys>;\n private changes$: Subject>, RxStorageDefaultCheckpoint>> = new Subject();\n public readonly instanceId = instanceId++;\n\n public closed?: Promise;\n\n constructor(\n public readonly databaseInstanceToken: string,\n public readonly storage: RxStorageLoki,\n public readonly databaseName: string,\n public readonly collectionName: string,\n public readonly schema: Readonly>>,\n public readonly internals: LokiStorageInternals,\n public readonly options: Readonly,\n public readonly databaseSettings: LokiDatabaseSettings\n ) {\n this.primaryPath = getPrimaryFieldOfPrimaryKey(this.schema.primaryKey);\n OPEN_LOKIJS_STORAGE_INSTANCES.add(this);\n if (this.internals.leaderElector) {\n\n\n /**\n * To run handleRemoteRequest(),\n * the instance will call its own methods.\n * But these methods could have already been swapped out by a RxStorageWrapper\n * so we must store the original methods here and use them instead.\n */\n const copiedSelf: RxStorageInstance = {\n bulkWrite: this.bulkWrite.bind(this),\n changeStream: this.changeStream.bind(this),\n cleanup: this.cleanup.bind(this),\n close: this.close.bind(this),\n query: this.query.bind(this),\n count: this.count.bind(this),\n findDocumentsById: this.findDocumentsById.bind(this),\n collectionName: this.collectionName,\n databaseName: this.databaseName,\n conflictResultionTasks: this.conflictResultionTasks.bind(this),\n getAttachmentData: this.getAttachmentData.bind(this),\n internals: this.internals,\n options: this.options,\n remove: this.remove.bind(this),\n resolveConflictResultionTask: this.resolveConflictResultionTask.bind(this),\n schema: this.schema\n };\n\n this.internals.leaderElector.awaitLeadership().then(() => {\n // this instance is leader now, so it has to reply to queries from other instances\n ensureNotFalsy(this.internals.leaderElector).broadcastChannel\n .addEventListener('message', (msg) => handleRemoteRequest(copiedSelf as any, msg));\n }).catch(() => { });\n }\n }\n\n async bulkWrite(\n documentWrites: BulkWriteRow[],\n context: string\n ): Promise> {\n if (documentWrites.length === 0) {\n throw newRxError('P2', {\n args: {\n documentWrites\n }\n });\n }\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'bulkWrite', [documentWrites]);\n }\n\n const ret: RxStorageBulkWriteResponse = {\n success: [],\n error: []\n };\n\n const docsInDb: Map[StringKeys], RxDocumentData> = new Map();\n const docsInDbWithLokiKey: Map<\n RxDocumentData[StringKeys],\n RxDocumentData & { $loki: number; }\n > = new Map();\n documentWrites.forEach(writeRow => {\n const id = writeRow.document[this.primaryPath];\n const documentInDb = localState.collection.by(this.primaryPath, id);\n if (documentInDb) {\n docsInDbWithLokiKey.set(id as any, documentInDb);\n docsInDb.set(id as any, stripLokiKey(documentInDb));\n }\n });\n\n const categorized = categorizeBulkWriteRows(\n this,\n this.primaryPath as any,\n docsInDb,\n documentWrites,\n context\n );\n ret.error = categorized.errors;\n\n categorized.bulkInsertDocs.forEach(writeRow => {\n localState.collection.insert(flatClone(writeRow.document));\n ret.success.push(writeRow.document);\n });\n categorized.bulkUpdateDocs.forEach(writeRow => {\n const docId = writeRow.document[this.primaryPath];\n const documentInDbWithLokiKey = getFromMapOrThrow(docsInDbWithLokiKey, docId as any);\n const writeDoc: any = Object.assign(\n {},\n writeRow.document,\n {\n $loki: documentInDbWithLokiKey.$loki\n }\n );\n localState.collection.update(writeDoc);\n ret.success.push(writeRow.document);\n });\n localState.databaseState.saveQueue.addWrite();\n\n if (categorized.eventBulk.events.length > 0) {\n const lastState = ensureNotFalsy(categorized.newestRow).document;\n categorized.eventBulk.checkpoint = {\n id: lastState[this.primaryPath],\n lwt: lastState._meta.lwt\n };\n categorized.eventBulk.endTime = now();\n this.changes$.next(categorized.eventBulk);\n }\n\n return ret;\n }\n async findDocumentsById(ids: string[], deleted: boolean): Promise[]> {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'findDocumentsById', [ids, deleted]);\n }\n\n const ret: RxDocumentData[] = [];\n ids.forEach(id => {\n const documentInDb = localState.collection.by(this.primaryPath, id);\n if (\n documentInDb &&\n (!documentInDb._deleted || deleted)\n ) {\n ret.push(stripLokiKey(documentInDb));\n }\n });\n return ret;\n }\n async query(preparedQueryOriginal: PreparedQuery): Promise> {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'query', [preparedQueryOriginal]);\n }\n\n let preparedQuery = ensureNotFalsy(preparedQueryOriginal.query);\n if (preparedQuery.selector) {\n preparedQuery = flatClone(preparedQuery);\n preparedQuery.selector = transformRegexToRegExp(preparedQuery.selector);\n }\n\n const query = preparedQueryOriginal.query;\n const skip = query.skip ? query.skip : 0;\n const limit = query.limit ? query.limit : Infinity;\n const skipPlusLimit = skip + limit;\n\n /**\n * LokiJS is not able to give correct results for some\n * operators, so we have to check all documents in that case\n * and laster apply skip and limit manually.\n * @link https://github.com/pubkey/rxdb/issues/5320\n */\n let mustRunMatcher = false;\n if (hasDeepProperty(preparedQuery.selector, '$in')) {\n mustRunMatcher = true;\n }\n\n\n let lokiQuery = localState.collection\n .chain()\n .find(mustRunMatcher ? {} : preparedQuery.selector);\n\n if (preparedQuery.sort) {\n lokiQuery = lokiQuery.sort(getLokiSortComparator(this.schema, preparedQuery));\n }\n\n\n let foundDocuments = lokiQuery.data().map((lokiDoc: any) => stripLokiKey(lokiDoc));\n\n\n /**\n * LokiJS returned wrong results on some queries\n * with complex indexes. Therefore we run the query-match\n * over all result docs to patch this bug.\n * TODO create an issue at the LokiJS repository.\n */\n const queryMatcher = getQueryMatcher(\n this.schema,\n preparedQuery as any\n );\n foundDocuments = foundDocuments.filter((d: any) => queryMatcher(d));\n\n // always apply offset and limit like this, because\n // sylvieQuery.offset() and sylvieQuery.limit() results were inconsistent\n foundDocuments = foundDocuments.slice(skip, skipPlusLimit);\n\n return {\n documents: foundDocuments\n };\n }\n async count(\n preparedQuery: PreparedQuery\n ): Promise {\n const result = await this.query(preparedQuery);\n return {\n count: result.documents.length,\n mode: 'fast'\n };\n }\n getAttachmentData(_documentId: string, _attachmentId: string, _digest: string): Promise {\n throw new Error('Attachments are not implemented in the lokijs RxStorage. Make a pull request.');\n }\n\n changeStream(): Observable>, RxStorageDefaultCheckpoint>> {\n return this.changes$.asObservable();\n }\n\n async cleanup(minimumDeletedTime: number): Promise {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'cleanup', [minimumDeletedTime]);\n }\n\n const deleteAmountPerRun = 10;\n const maxDeletionTime = now() - minimumDeletedTime;\n const query = localState.collection\n .chain()\n .find({\n _deleted: true,\n '_meta.lwt': {\n $lt: maxDeletionTime\n }\n }).limit(deleteAmountPerRun);\n const foundDocuments = query.data();\n if (foundDocuments.length > 0) {\n localState.collection.remove(foundDocuments);\n localState.databaseState.saveQueue.addWrite();\n }\n\n return foundDocuments.length !== deleteAmountPerRun;\n }\n\n async close(): Promise {\n if (this.closed) {\n return this.closed;\n }\n this.closed = (async () => {\n this.changes$.complete();\n OPEN_LOKIJS_STORAGE_INSTANCES.delete(this);\n if (this.internals.localState) {\n const localState = await this.internals.localState;\n const dbState = await getLokiDatabase(\n this.databaseName,\n this.databaseSettings\n );\n await dbState.saveQueue.run();\n await closeLokiCollections(\n this.databaseName,\n [\n localState.collection\n ]\n );\n }\n })();\n return this.closed;\n }\n async remove(): Promise {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'remove', []);\n }\n localState.databaseState.database.removeCollection(localState.collection.name);\n await localState.databaseState.saveQueue.run();\n return this.close();\n }\n\n conflictResultionTasks(): Observable> {\n return new Subject();\n }\n async resolveConflictResultionTask(_taskSolution: RxConflictResultionTaskSolution): Promise { }\n\n}\n\nexport async function createLokiLocalState(\n params: RxStorageInstanceCreationParams,\n databaseSettings: LokiDatabaseSettings\n): Promise {\n if (!params.options) {\n params.options = {};\n }\n\n const databaseState = await getLokiDatabase(\n params.databaseName,\n databaseSettings\n );\n\n /**\n * Construct loki indexes from RxJsonSchema indexes.\n * TODO what about compound indexes? Are they possible in lokijs?\n */\n const indices: string[] = [];\n if (params.schema.indexes) {\n params.schema.indexes.forEach(idx => {\n if (!isMaybeReadonlyArray(idx)) {\n indices.push(idx);\n }\n });\n }\n /**\n * LokiJS has no concept of custom primary key, they use a number-id that is generated.\n * To be able to query fast by primary key, we always add an index to the primary.\n */\n const primaryKey = getPrimaryFieldOfPrimaryKey(params.schema.primaryKey);\n indices.push(primaryKey as string);\n\n const lokiCollectionName = params.collectionName + '-' + params.schema.version;\n const collectionOptions: Partial = Object.assign(\n {},\n lokiCollectionName,\n {\n indices: indices as string[],\n unique: [primaryKey]\n } as any,\n LOKIJS_COLLECTION_DEFAULT_OPTIONS\n );\n\n const collection: any = databaseState.database.addCollection(\n lokiCollectionName,\n collectionOptions as any\n );\n databaseState.collections[params.collectionName] = collection;\n const ret: LokiLocalDatabaseState = {\n databaseState,\n collection\n };\n\n return ret;\n}\n\n\nexport async function createLokiStorageInstance(\n storage: RxStorageLoki,\n params: RxStorageInstanceCreationParams,\n databaseSettings: LokiDatabaseSettings\n): Promise> {\n const internals: LokiStorageInternals = {};\n\n const broadcastChannelRefObject: DeepReadonly = {};\n\n\n if (params.multiInstance) {\n const leaderElector = getLokiLeaderElector(\n params.databaseInstanceToken,\n broadcastChannelRefObject,\n params.databaseName\n );\n internals.leaderElector = leaderElector;\n } else {\n // optimisation shortcut, directly create db is non multi instance.\n internals.localState = createLokiLocalState(params, databaseSettings);\n await internals.localState;\n }\n\n const instance = new RxStorageInstanceLoki(\n params.databaseInstanceToken,\n storage,\n params.databaseName,\n params.collectionName,\n params.schema,\n internals,\n params.options,\n databaseSettings\n );\n\n await addRxStorageMultiInstanceSupport(\n RX_STORAGE_NAME_LOKIJS,\n params,\n instance,\n internals.leaderElector ? internals.leaderElector.broadcastChannel : undefined\n );\n\n if (params.multiInstance) {\n /**\n * Clean up the broadcast-channel reference on close()\n */\n const closeBefore = instance.close.bind(instance);\n instance.close = function () {\n removeBroadcastChannelReference(\n params.databaseInstanceToken,\n broadcastChannelRefObject\n );\n return closeBefore();\n };\n const removeBefore = instance.remove.bind(instance);\n instance.remove = function () {\n removeBroadcastChannelReference(\n params.databaseInstanceToken,\n broadcastChannelRefObject\n );\n return removeBefore();\n };\n\n /**\n * Directly create the localState when/if the db becomes leader.\n */\n ensureNotFalsy(internals.leaderElector)\n .awaitLeadership()\n .then(() => {\n if (!instance.closed) {\n mustUseLocalState(instance);\n }\n });\n }\n\n\n return instance;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAQA,IAAAE,QAAA,GAAAF,OAAA;AAwBA,IAAAG,aAAA,GAAAH,OAAA;AAeA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,uBAAA,GAAAN,OAAA;AAIA,IAAAO,cAAA,GAAAP,OAAA;AAEA,IAAIQ,UAAU,GAAG,IAAAC,UAAG,EAAC,CAAC;AAAC,IAEVC,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA;EAa9B,SAAAA,sBACoBE,qBAA6B,EAC7BC,OAAsB,EACtBC,YAAoB,EACpBC,cAAsB,EACtBC,MAAyD,EACzDC,SAA+B,EAC/BC,OAA+B,EAC/BC,gBAAsC,EACxD;IAAA,KAdMC,QAAQ,GAAoG,IAAIC,aAAO,CAAC,CAAC;IAAA,KACjHb,UAAU,GAAGA,UAAU,EAAE;IAAA,KAKrBI,qBAA6B,GAA7BA,qBAA6B;IAAA,KAC7BC,OAAsB,GAAtBA,OAAsB;IAAA,KACtBC,YAAoB,GAApBA,YAAoB;IAAA,KACpBC,cAAsB,GAAtBA,cAAsB;IAAA,KACtBC,MAAyD,GAAzDA,MAAyD;IAAA,KACzDC,SAA+B,GAA/BA,SAA+B;IAAA,KAC/BC,OAA+B,GAA/BA,OAA+B;IAAA,KAC/BC,gBAAsC,GAAtCA,gBAAsC;IAEtD,IAAI,CAACG,WAAW,GAAG,IAAAC,2CAA2B,EAAC,IAAI,CAACP,MAAM,CAACQ,UAAU,CAAC;IACtEC,2CAA6B,CAACC,GAAG,CAAC,IAAI,CAAC;IACvC,IAAI,IAAI,CAACT,SAAS,CAACU,aAAa,EAAE;MAG9B;AACZ;AACA;AACA;AACA;AACA;MACY,IAAMC,UAAkD,GAAG;QACvDC,SAAS,EAAE,IAAI,CAACA,SAAS,CAACC,IAAI,CAAC,IAAI,CAAC;QACpCC,YAAY,EAAE,IAAI,CAACA,YAAY,CAACD,IAAI,CAAC,IAAI,CAAC;QAC1CE,OAAO,EAAE,IAAI,CAACA,OAAO,CAACF,IAAI,CAAC,IAAI,CAAC;QAChCG,KAAK,EAAE,IAAI,CAACA,KAAK,CAACH,IAAI,CAAC,IAAI,CAAC;QAC5BI,KAAK,EAAE,IAAI,CAACA,KAAK,CAACJ,IAAI,CAAC,IAAI,CAAC;QAC5BK,KAAK,EAAE,IAAI,CAACA,KAAK,CAACL,IAAI,CAAC,IAAI,CAAC;QAC5BM,iBAAiB,EAAE,IAAI,CAACA,iBAAiB,CAACN,IAAI,CAAC,IAAI,CAAC;QACpDf,cAAc,EAAE,IAAI,CAACA,cAAc;QACnCD,YAAY,EAAE,IAAI,CAACA,YAAY;QAC/BuB,sBAAsB,EAAE,IAAI,CAACA,sBAAsB,CAACP,IAAI,CAAC,IAAI,CAAC;QAC9DQ,iBAAiB,EAAE,IAAI,CAACA,iBAAiB,CAACR,IAAI,CAAC,IAAI,CAAC;QACpDb,SAAS,EAAE,IAAI,CAACA,SAAS;QACzBC,OAAO,EAAE,IAAI,CAACA,OAAO;QACrBqB,MAAM,EAAE,IAAI,CAACA,MAAM,CAACT,IAAI,CAAC,IAAI,CAAC;QAC9BU,4BAA4B,EAAE,IAAI,CAACA,4BAA4B,CAACV,IAAI,CAAC,IAAI,CAAC;QAC1Ed,MAAM,EAAE,IAAI,CAACA;MACjB,CAAC;MAED,IAAI,CAACC,SAAS,CAACU,aAAa,CAACc,eAAe,CAAC,CAAC,CAACC,IAAI,CAAC,MAAM;QACtD;QACA,IAAAC,qBAAc,EAAC,IAAI,CAAC1B,SAAS,CAACU,aAAa,CAAC,CAACiB,gBAAgB,CACxDC,gBAAgB,CAAC,SAAS,EAAGC,GAAG,IAAK,IAAAC,iCAAmB,EAACnB,UAAU,EAASkB,GAAG,CAAC,CAAC;MAC1F,CAAC,CAAC,CAACE,KAAK,CAAC,MAAM,CAAE,CAAC,CAAC;IACvB;EACJ;EAAC,IAAAC,MAAA,GAAAvC,qBAAA,CAAAwC,SAAA;EAAAD,MAAA,CAEKpB,SAAS,GAAf,eAAAA,UACIsB,cAAyC,EACzCC,OAAe,EAC+B;IAC9C,IAAID,cAAc,CAACE,MAAM,KAAK,CAAC,EAAE;MAC7B,MAAM,IAAAC,mBAAU,EAAC,IAAI,EAAE;QACnBC,IAAI,EAAE;UACFJ;QACJ;MACJ,CAAC,CAAC;IACN;IACA,IAAMK,UAAU,GAAG,MAAM,IAAAC,+BAAiB,EAAC,IAAI,CAAC;IAChD,IAAI,CAACD,UAAU,EAAE;MACb,OAAO,IAAAE,mCAAqB,EAAC,IAAI,EAAE,WAAW,EAAE,CAACP,cAAc,CAAC,CAAC;IACrE;IAEA,IAAMQ,GAA0C,GAAG;MAC/CC,OAAO,EAAE,EAAE;MACXC,KAAK,EAAE;IACX,CAAC;IAED,IAAMC,QAA0F,GAAG,IAAIC,GAAG,CAAC,CAAC;IAC5G,IAAMC,mBAGL,GAAG,IAAID,GAAG,CAAC,CAAC;IACbZ,cAAc,CAACc,OAAO,CAACC,QAAQ,IAAI;MAC/B,IAAMC,EAAE,GAAGD,QAAQ,CAACE,QAAQ,CAAC,IAAI,CAAC9C,WAAW,CAAC;MAC9C,IAAM+C,YAAY,GAAGb,UAAU,CAACc,UAAU,CAACC,EAAE,CAAC,IAAI,CAACjD,WAAW,EAAE6C,EAAE,CAAC;MACnE,IAAIE,YAAY,EAAE;QACdL,mBAAmB,CAACQ,GAAG,CAACL,EAAE,EAASE,YAAY,CAAC;QAChDP,QAAQ,CAACU,GAAG,CAACL,EAAE,EAAS,IAAAM,0BAAY,EAACJ,YAAY,CAAC,CAAC;MACvD;IACJ,CAAC,CAAC;IAEF,IAAMK,WAAW,GAAG,IAAAC,wCAAuB,EACvC,IAAI,EACJ,IAAI,CAACrD,WAAW,EAChBwC,QAAQ,EACRX,cAAc,EACdC,OACJ,CAAC;IACDO,GAAG,CAACE,KAAK,GAAGa,WAAW,CAACE,MAAM;IAE9BF,WAAW,CAACG,cAAc,CAACZ,OAAO,CAACC,QAAQ,IAAI;MAC3CV,UAAU,CAACc,UAAU,CAACQ,MAAM,CAAC,IAAAC,gBAAS,EAACb,QAAQ,CAACE,QAAQ,CAAC,CAAC;MAC1DT,GAAG,CAACC,OAAO,CAACoB,IAAI,CAACd,QAAQ,CAACE,QAAQ,CAAC;IACvC,CAAC,CAAC;IACFM,WAAW,CAACO,cAAc,CAAChB,OAAO,CAACC,QAAQ,IAAI;MAC3C,IAAMgB,KAAK,GAAGhB,QAAQ,CAACE,QAAQ,CAAC,IAAI,CAAC9C,WAAW,CAAC;MACjD,IAAM6D,uBAAuB,GAAG,IAAAC,wBAAiB,EAACpB,mBAAmB,EAAEkB,KAAY,CAAC;MACpF,IAAMG,QAAa,GAAGC,MAAM,CAACC,MAAM,CAC/B,CAAC,CAAC,EACFrB,QAAQ,CAACE,QAAQ,EACjB;QACIoB,KAAK,EAAEL,uBAAuB,CAACK;MACnC,CACJ,CAAC;MACDhC,UAAU,CAACc,UAAU,CAACmB,MAAM,CAACJ,QAAQ,CAAC;MACtC1B,GAAG,CAACC,OAAO,CAACoB,IAAI,CAACd,QAAQ,CAACE,QAAQ,CAAC;IACvC,CAAC,CAAC;IACFZ,UAAU,CAACkC,aAAa,CAACC,SAAS,CAACC,QAAQ,CAAC,CAAC;IAE7C,IAAIlB,WAAW,CAACmB,SAAS,CAACC,MAAM,CAACzC,MAAM,GAAG,CAAC,EAAE;MACzC,IAAM0C,SAAS,GAAG,IAAApD,qBAAc,EAAC+B,WAAW,CAACsB,SAAS,CAAC,CAAC5B,QAAQ;MAChEM,WAAW,CAACmB,SAAS,CAACI,UAAU,GAAG;QAC/B9B,EAAE,EAAE4B,SAAS,CAAC,IAAI,CAACzE,WAAW,CAAC;QAC/B4E,GAAG,EAAEH,SAAS,CAACI,KAAK,CAACD;MACzB,CAAC;MACDxB,WAAW,CAACmB,SAAS,CAACO,OAAO,GAAG,IAAA3F,UAAG,EAAC,CAAC;MACrC,IAAI,CAACW,QAAQ,CAACiF,IAAI,CAAC3B,WAAW,CAACmB,SAAS,CAAC;IAC7C;IAEA,OAAOlC,GAAG;EACd,CAAC;EAAAV,MAAA,CACKb,iBAAiB,GAAvB,eAAAA,kBAAwBkE,GAAa,EAAEC,OAAgB,EAAwC;IAC3F,IAAM/C,UAAU,GAAG,MAAM,IAAAC,+BAAiB,EAAC,IAAI,CAAC;IAChD,IAAI,CAACD,UAAU,EAAE;MACb,OAAO,IAAAE,mCAAqB,EAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC4C,GAAG,EAAEC,OAAO,CAAC,CAAC;IAC3E;IAEA,IAAM5C,GAAgC,GAAG,EAAE;IAC3C2C,GAAG,CAACrC,OAAO,CAACE,EAAE,IAAI;MACd,IAAME,YAAY,GAAGb,UAAU,CAACc,UAAU,CAACC,EAAE,CAAC,IAAI,CAACjD,WAAW,EAAE6C,EAAE,CAAC;MACnE,IACIE,YAAY,KACX,CAACA,YAAY,CAACmC,QAAQ,IAAID,OAAO,CAAC,EACrC;QACE5C,GAAG,CAACqB,IAAI,CAAC,IAAAP,0BAAY,EAACJ,YAAY,CAAC,CAAC;MACxC;IACJ,CAAC,CAAC;IACF,OAAOV,GAAG;EACd,CAAC;EAAAV,MAAA,CACKf,KAAK,GAAX,eAAAA,MAAYuE,qBAA+C,EAA4C;IACnG,IAAMjD,UAAU,GAAG,MAAM,IAAAC,+BAAiB,EAAC,IAAI,CAAC;IAChD,IAAI,CAACD,UAAU,EAAE;MACb,OAAO,IAAAE,mCAAqB,EAAC,IAAI,EAAE,OAAO,EAAE,CAAC+C,qBAAqB,CAAC,CAAC;IACxE;IAEA,IAAIC,aAAa,GAAG,IAAA/D,qBAAc,EAAC8D,qBAAqB,CAACvE,KAAK,CAAC;IAC/D,IAAIwE,aAAa,CAACC,QAAQ,EAAE;MACxBD,aAAa,GAAG,IAAA3B,gBAAS,EAAC2B,aAAa,CAAC;MACxCA,aAAa,CAACC,QAAQ,GAAG,IAAAC,oCAAsB,EAACF,aAAa,CAACC,QAAQ,CAAC;IAC3E;IAEA,IAAMzE,KAAK,GAAGuE,qBAAqB,CAACvE,KAAK;IACzC,IAAM2E,IAAI,GAAG3E,KAAK,CAAC2E,IAAI,GAAG3E,KAAK,CAAC2E,IAAI,GAAG,CAAC;IACxC,IAAMC,KAAK,GAAG5E,KAAK,CAAC4E,KAAK,GAAG5E,KAAK,CAAC4E,KAAK,GAAGC,QAAQ;IAClD,IAAMC,aAAa,GAAGH,IAAI,GAAGC,KAAK;;IAElC;AACR;AACA;AACA;AACA;AACA;IACQ,IAAIG,cAAc,GAAG,KAAK;IAC1B,IAAI,IAAAC,sBAAe,EAACR,aAAa,CAACC,QAAQ,EAAE,KAAK,CAAC,EAAE;MAChDM,cAAc,GAAG,IAAI;IACzB;IAGA,IAAIE,SAAS,GAAG3D,UAAU,CAACc,UAAU,CAChC8C,KAAK,CAAC,CAAC,CACPC,IAAI,CAACJ,cAAc,GAAG,CAAC,CAAC,GAAGP,aAAa,CAACC,QAAQ,CAAC;IAEvD,IAAID,aAAa,CAACY,IAAI,EAAE;MACpBH,SAAS,GAAGA,SAAS,CAACG,IAAI,CAAC,IAAAC,mCAAqB,EAAC,IAAI,CAACvG,MAAM,EAAE0F,aAAa,CAAC,CAAC;IACjF;IAGA,IAAIc,cAAc,GAAGL,SAAS,CAACM,IAAI,CAAC,CAAC,CAACC,GAAG,CAAEC,OAAY,IAAK,IAAAlD,0BAAY,EAACkD,OAAO,CAAC,CAAC;;IAGlF;AACR;AACA;AACA;AACA;AACA;IACQ,IAAMC,YAAY,GAAG,IAAAC,8BAAe,EAChC,IAAI,CAAC7G,MAAM,EACX0F,aACJ,CAAC;IACDc,cAAc,GAAGA,cAAc,CAACM,MAAM,CAAEC,CAAM,IAAKH,YAAY,CAACG,CAAC,CAAC,CAAC;;IAEnE;IACA;IACAP,cAAc,GAAGA,cAAc,CAACQ,KAAK,CAACnB,IAAI,EAAEG,aAAa,CAAC;IAE1D,OAAO;MACHiB,SAAS,EAAET;IACf,CAAC;EACL,CAAC;EAAAvE,MAAA,CACKd,KAAK,GAAX,eAAAA,MACIuE,aAAuC,EACV;IAC7B,IAAMwB,MAAM,GAAG,MAAM,IAAI,CAAChG,KAAK,CAACwE,aAAa,CAAC;IAC9C,OAAO;MACHvE,KAAK,EAAE+F,MAAM,CAACD,SAAS,CAAC5E,MAAM;MAC9B8E,IAAI,EAAE;IACV,CAAC;EACL,CAAC;EAAAlF,MAAA,CACDX,iBAAiB,GAAjB,SAAAA,kBAAkB8F,WAAmB,EAAEC,aAAqB,EAAEC,OAAe,EAAmB;IAC5F,MAAM,IAAIC,KAAK,CAAC,+EAA+E,CAAC;EACpG,CAAC;EAAAtF,MAAA,CAEDlB,YAAY,GAAZ,SAAAA,aAAA,EAAmH;IAC/G,OAAO,IAAI,CAACX,QAAQ,CAACoH,YAAY,CAAC,CAAC;EACvC,CAAC;EAAAvF,MAAA,CAEKjB,OAAO,GAAb,eAAAA,QAAcyG,kBAA0B,EAAoB;IACxD,IAAMjF,UAAU,GAAG,MAAM,IAAAC,+BAAiB,EAAC,IAAI,CAAC;IAChD,IAAI,CAACD,UAAU,EAAE;MACb,OAAO,IAAAE,mCAAqB,EAAC,IAAI,EAAE,SAAS,EAAE,CAAC+E,kBAAkB,CAAC,CAAC;IACvE;IAEA,IAAMC,kBAAkB,GAAG,EAAE;IAC7B,IAAMC,eAAe,GAAG,IAAAlI,UAAG,EAAC,CAAC,GAAGgI,kBAAkB;IAClD,IAAMvG,KAAK,GAAGsB,UAAU,CAACc,UAAU,CAC9B8C,KAAK,CAAC,CAAC,CACPC,IAAI,CAAC;MACFb,QAAQ,EAAE,IAAI;MACd,WAAW,EAAE;QACToC,GAAG,EAAED;MACT;IACJ,CAAC,CAAC,CAAC7B,KAAK,CAAC4B,kBAAkB,CAAC;IAChC,IAAMlB,cAAc,GAAGtF,KAAK,CAACuF,IAAI,CAAC,CAAC;IACnC,IAAID,cAAc,CAACnE,MAAM,GAAG,CAAC,EAAE;MAC3BG,UAAU,CAACc,UAAU,CAAC/B,MAAM,CAACiF,cAAc,CAAC;MAC5ChE,UAAU,CAACkC,aAAa,CAACC,SAAS,CAACC,QAAQ,CAAC,CAAC;IACjD;IAEA,OAAO4B,cAAc,CAACnE,MAAM,KAAKqF,kBAAkB;EACvD,CAAC;EAAAzF,MAAA,CAEKhB,KAAK,GAAX,eAAAA,MAAA,EAA6B;IACzB,IAAI,IAAI,CAAC4G,MAAM,EAAE;MACb,OAAO,IAAI,CAACA,MAAM;IACtB;IACA,IAAI,CAACA,MAAM,GAAG,CAAC,YAAY;MACvB,IAAI,CAACzH,QAAQ,CAAC0H,QAAQ,CAAC,CAAC;MACxBrH,2CAA6B,CAACsH,MAAM,CAAC,IAAI,CAAC;MAC1C,IAAI,IAAI,CAAC9H,SAAS,CAACuC,UAAU,EAAE;QAC3B,IAAMA,UAAU,GAAG,MAAM,IAAI,CAACvC,SAAS,CAACuC,UAAU;QAClD,IAAMwF,OAAO,GAAG,MAAM,IAAAC,6BAAe,EACjC,IAAI,CAACnI,YAAY,EACjB,IAAI,CAACK,gBACT,CAAC;QACD,MAAM6H,OAAO,CAACrD,SAAS,CAACuD,GAAG,CAAC,CAAC;QAC7B,MAAM,IAAAC,kCAAoB,EACtB,IAAI,CAACrI,YAAY,EACjB,CACI0C,UAAU,CAACc,UAAU,CAE7B,CAAC;MACL;IACJ,CAAC,EAAE,CAAC;IACJ,OAAO,IAAI,CAACuE,MAAM;EACtB,CAAC;EAAA5F,MAAA,CACKV,MAAM,GAAZ,eAAAA,OAAA,EAA8B;IAC1B,IAAMiB,UAAU,GAAG,MAAM,IAAAC,+BAAiB,EAAC,IAAI,CAAC;IAChD,IAAI,CAACD,UAAU,EAAE;MACb,OAAO,IAAAE,mCAAqB,EAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC;IACpD;IACAF,UAAU,CAACkC,aAAa,CAAC0D,QAAQ,CAACC,gBAAgB,CAAC7F,UAAU,CAACc,UAAU,CAACgF,IAAI,CAAC;IAC9E,MAAM9F,UAAU,CAACkC,aAAa,CAACC,SAAS,CAACuD,GAAG,CAAC,CAAC;IAC9C,OAAO,IAAI,CAACjH,KAAK,CAAC,CAAC;EACvB,CAAC;EAAAgB,MAAA,CAEDZ,sBAAsB,GAAtB,SAAAA,uBAAA,EAAyE;IACrE,OAAO,IAAIhB,aAAO,CAAC,CAAC;EACxB,CAAC;EAAA4B,MAAA,CACKT,4BAA4B,GAAlC,eAAAA,6BAAmC+G,aAAyD,EAAiB,CAAE,CAAC;EAAA,OAAA7I,qBAAA;AAAA;AAI7G,eAAe8I,oBAAoBA,CACtCC,MAAgE,EAChEtI,gBAAsC,EACP;EAC/B,IAAI,CAACsI,MAAM,CAACvI,OAAO,EAAE;IACjBuI,MAAM,CAACvI,OAAO,GAAG,CAAC,CAAC;EACvB;EAEA,IAAMwE,aAAa,GAAG,MAAM,IAAAuD,6BAAe,EACvCQ,MAAM,CAAC3I,YAAY,EACnBK,gBACJ,CAAC;;EAED;AACJ;AACA;AACA;EACI,IAAMuI,OAAiB,GAAG,EAAE;EAC5B,IAAID,MAAM,CAACzI,MAAM,CAAC2I,OAAO,EAAE;IACvBF,MAAM,CAACzI,MAAM,CAAC2I,OAAO,CAAC1F,OAAO,CAAC2F,GAAG,IAAI;MACjC,IAAI,CAAC,IAAAC,2BAAoB,EAACD,GAAG,CAAC,EAAE;QAC5BF,OAAO,CAAC1E,IAAI,CAAC4E,GAAG,CAAC;MACrB;IACJ,CAAC,CAAC;EACN;EACA;AACJ;AACA;AACA;EACI,IAAMpI,UAAU,GAAG,IAAAD,2CAA2B,EAACkI,MAAM,CAACzI,MAAM,CAACQ,UAAU,CAAC;EACxEkI,OAAO,CAAC1E,IAAI,CAACxD,UAAoB,CAAC;EAElC,IAAMsI,kBAAkB,GAAGL,MAAM,CAAC1I,cAAc,GAAG,GAAG,GAAG0I,MAAM,CAACzI,MAAM,CAAC+I,OAAO;EAC9E,IAAMC,iBAA+B,GAAG1E,MAAM,CAACC,MAAM,CACjD,CAAC,CAAC,EACFuE,kBAAkB,EAClB;IACIJ,OAAO,EAAEA,OAAmB;IAC5BO,MAAM,EAAE,CAACzI,UAAU;EACvB,CAAC,EACD0I,+CACJ,CAAC;EAED,IAAM5F,UAAe,GAAGoB,aAAa,CAAC0D,QAAQ,CAACe,aAAa,CACxDL,kBAAkB,EAClBE,iBACJ,CAAC;EACDtE,aAAa,CAAC0E,WAAW,CAACX,MAAM,CAAC1I,cAAc,CAAC,GAAGuD,UAAU;EAC7D,IAAMX,GAA2B,GAAG;IAChC+B,aAAa;IACbpB;EACJ,CAAC;EAED,OAAOX,GAAG;AACd;AAGO,eAAe0G,yBAAyBA,CAC3CxJ,OAAsB,EACtB4I,MAAgE,EAChEtI,gBAAsC,EACG;EACzC,IAAMF,SAA+B,GAAG,CAAC,CAAC;EAE1C,IAAMqJ,yBAA4C,GAAG,CAAC,CAAC;EAGvD,IAAIb,MAAM,CAACc,aAAa,EAAE;IACtB,IAAM5I,aAAa,GAAG,IAAA6I,kCAAoB,EACtCf,MAAM,CAAC7I,qBAAqB,EAC5B0J,yBAAyB,EACzBb,MAAM,CAAC3I,YACX,CAAC;IACDG,SAAS,CAACU,aAAa,GAAGA,aAAa;EAC3C,CAAC,MAAM;IACH;IACAV,SAAS,CAACuC,UAAU,GAAGgG,oBAAoB,CAACC,MAAM,EAAEtI,gBAAgB,CAAC;IACrE,MAAMF,SAAS,CAACuC,UAAU;EAC9B;EAEA,IAAMiH,QAAQ,GAAG,IAAI/J,qBAAqB,CACtC+I,MAAM,CAAC7I,qBAAqB,EAC5BC,OAAO,EACP4I,MAAM,CAAC3I,YAAY,EACnB2I,MAAM,CAAC1I,cAAc,EACrB0I,MAAM,CAACzI,MAAM,EACbC,SAAS,EACTwI,MAAM,CAACvI,OAAO,EACdC,gBACJ,CAAC;EAED,MAAM,IAAAuJ,wDAAgC,EAClCC,oCAAsB,EACtBlB,MAAM,EACNgB,QAAQ,EACRxJ,SAAS,CAACU,aAAa,GAAGV,SAAS,CAACU,aAAa,CAACiB,gBAAgB,GAAGgI,SACzE,CAAC;EAED,IAAInB,MAAM,CAACc,aAAa,EAAE;IACtB;AACR;AACA;IACQ,IAAMM,WAAW,GAAGJ,QAAQ,CAACxI,KAAK,CAACH,IAAI,CAAC2I,QAAQ,CAAC;IACjDA,QAAQ,CAACxI,KAAK,GAAG,YAAY;MACzB,IAAA6I,uDAA+B,EAC3BrB,MAAM,CAAC7I,qBAAqB,EAC5B0J,yBACJ,CAAC;MACD,OAAOO,WAAW,CAAC,CAAC;IACxB,CAAC;IACD,IAAME,YAAY,GAAGN,QAAQ,CAAClI,MAAM,CAACT,IAAI,CAAC2I,QAAQ,CAAC;IACnDA,QAAQ,CAAClI,MAAM,GAAG,YAAY;MAC1B,IAAAuI,uDAA+B,EAC3BrB,MAAM,CAAC7I,qBAAqB,EAC5B0J,yBACJ,CAAC;MACD,OAAOS,YAAY,CAAC,CAAC;IACzB,CAAC;;IAED;AACR;AACA;IACQ,IAAApI,qBAAc,EAAC1B,SAAS,CAACU,aAAa,CAAC,CAClCc,eAAe,CAAC,CAAC,CACjBC,IAAI,CAAC,MAAM;MACR,IAAI,CAAC+H,QAAQ,CAAC5B,MAAM,EAAE;QAClB,IAAApF,+BAAiB,EAACgH,QAAQ,CAAC;MAC/B;IACJ,CAAC,CAAC;EACV;EAGA,OAAOA,QAAQ;AACnB","ignoreList":[]} \ 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 950d6004a1d..f1b01976caf 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.11.1'; +var RXDB_VERSION = exports.RXDB_VERSION = '15.12.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 ccb09c72a0e..85c263a6887 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.11.1';\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACO,IAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,SAAS","ignoreList":[]} \ 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.12.0';\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACO,IAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,SAAS","ignoreList":[]} \ No newline at end of file diff --git a/dist/esm/plugins/storage-lokijs/rx-storage-instance-loki.js b/dist/esm/plugins/storage-lokijs/rx-storage-instance-loki.js index e11fdc39b93..7a33cf095e1 100644 --- a/dist/esm/plugins/storage-lokijs/rx-storage-instance-loki.js +++ b/dist/esm/plugins/storage-lokijs/rx-storage-instance-loki.js @@ -149,17 +149,6 @@ export var RxStorageInstanceLoki = /*#__PURE__*/function () { if (preparedQuery.sort) { lokiQuery = lokiQuery.sort(getLokiSortComparator(this.schema, preparedQuery)); } - - /** - * Offset must be used before limit in LokiJS - * @link https://github.com/techfort/LokiJS/issues/570 - */ - if (!mustRunMatcher && preparedQuery.skip) { - lokiQuery = lokiQuery.offset(preparedQuery.skip); - } - if (!mustRunMatcher && preparedQuery.limit) { - lokiQuery = lokiQuery.limit(preparedQuery.limit); - } var foundDocuments = lokiQuery.data().map(lokiDoc => stripLokiKey(lokiDoc)); /** @@ -170,9 +159,10 @@ export var RxStorageInstanceLoki = /*#__PURE__*/function () { */ var queryMatcher = getQueryMatcher(this.schema, preparedQuery); foundDocuments = foundDocuments.filter(d => queryMatcher(d)); - if (mustRunMatcher) { - foundDocuments = foundDocuments.slice(skip, skipPlusLimit); - } + + // always apply offset and limit like this, because + // sylvieQuery.offset() and sylvieQuery.limit() results were inconsistent + foundDocuments = foundDocuments.slice(skip, skipPlusLimit); return { documents: foundDocuments }; diff --git a/dist/esm/plugins/storage-lokijs/rx-storage-instance-loki.js.map b/dist/esm/plugins/storage-lokijs/rx-storage-instance-loki.js.map index 8961c2be795..cf5a3ea95bf 100644 --- a/dist/esm/plugins/storage-lokijs/rx-storage-instance-loki.js.map +++ b/dist/esm/plugins/storage-lokijs/rx-storage-instance-loki.js.map @@ -1 +1 @@ -{"version":3,"file":"rx-storage-instance-loki.js","names":["Subject","flatClone","now","ensureNotFalsy","isMaybeReadonlyArray","getFromMapOrThrow","hasDeepProperty","newRxError","closeLokiCollections","getLokiDatabase","OPEN_LOKIJS_STORAGE_INSTANCES","LOKIJS_COLLECTION_DEFAULT_OPTIONS","stripLokiKey","getLokiSortComparator","getLokiLeaderElector","requestRemoteInstance","mustUseLocalState","handleRemoteRequest","RX_STORAGE_NAME_LOKIJS","transformRegexToRegExp","getPrimaryFieldOfPrimaryKey","categorizeBulkWriteRows","addRxStorageMultiInstanceSupport","removeBroadcastChannelReference","getQueryMatcher","instanceId","RxStorageInstanceLoki","databaseInstanceToken","storage","databaseName","collectionName","schema","internals","options","databaseSettings","changes$","primaryPath","primaryKey","add","leaderElector","copiedSelf","bulkWrite","bind","changeStream","cleanup","close","query","count","findDocumentsById","conflictResultionTasks","getAttachmentData","remove","resolveConflictResultionTask","awaitLeadership","then","broadcastChannel","addEventListener","msg","catch","_proto","prototype","documentWrites","context","length","args","localState","ret","success","error","docsInDb","Map","docsInDbWithLokiKey","forEach","writeRow","id","document","documentInDb","collection","by","set","categorized","errors","bulkInsertDocs","insert","push","bulkUpdateDocs","docId","documentInDbWithLokiKey","writeDoc","Object","assign","$loki","update","databaseState","saveQueue","addWrite","eventBulk","events","lastState","newestRow","checkpoint","lwt","_meta","endTime","next","ids","deleted","_deleted","preparedQueryOriginal","preparedQuery","selector","skip","limit","Infinity","skipPlusLimit","mustRunMatcher","lokiQuery","chain","find","sort","offset","foundDocuments","data","map","lokiDoc","queryMatcher","filter","d","slice","documents","result","mode","_documentId","_attachmentId","_digest","Error","asObservable","minimumDeletedTime","deleteAmountPerRun","maxDeletionTime","$lt","closed","complete","delete","dbState","run","database","removeCollection","name","_taskSolution","createLokiLocalState","params","indices","indexes","idx","lokiCollectionName","version","collectionOptions","unique","addCollection","collections","createLokiStorageInstance","broadcastChannelRefObject","multiInstance","instance","undefined","closeBefore","removeBefore"],"sources":["../../../../src/plugins/storage-lokijs/rx-storage-instance-loki.ts"],"sourcesContent":["import {\n Subject,\n Observable\n} from 'rxjs';\nimport {\n flatClone,\n now,\n ensureNotFalsy,\n isMaybeReadonlyArray,\n getFromMapOrThrow,\n hasDeepProperty\n} from '../utils/index.ts';\nimport { newRxError } from '../../rx-error.ts';\nimport type {\n RxStorageInstance,\n LokiSettings,\n RxStorageChangeEvent,\n RxDocumentData,\n BulkWriteRow,\n RxStorageBulkWriteResponse,\n RxStorageQueryResult,\n RxJsonSchema,\n MangoQuery,\n LokiStorageInternals,\n RxStorageInstanceCreationParams,\n LokiDatabaseSettings,\n LokiLocalDatabaseState,\n EventBulk,\n StringKeys,\n DeepReadonly,\n RxConflictResultionTask,\n RxConflictResultionTaskSolution,\n RxStorageDefaultCheckpoint,\n RxStorageCountResult,\n PreparedQuery\n} from '../../types/index.d.ts';\nimport {\n closeLokiCollections,\n getLokiDatabase,\n OPEN_LOKIJS_STORAGE_INSTANCES,\n LOKIJS_COLLECTION_DEFAULT_OPTIONS,\n stripLokiKey,\n getLokiSortComparator,\n getLokiLeaderElector,\n requestRemoteInstance,\n mustUseLocalState,\n handleRemoteRequest,\n RX_STORAGE_NAME_LOKIJS,\n transformRegexToRegExp\n} from './lokijs-helper.ts';\nimport type { RxStorageLoki } from './rx-storage-lokijs.ts';\nimport { getPrimaryFieldOfPrimaryKey } from '../../rx-schema-helper.ts';\nimport { categorizeBulkWriteRows } from '../../rx-storage-helper.ts';\nimport {\n addRxStorageMultiInstanceSupport,\n removeBroadcastChannelReference\n} from '../../rx-storage-multiinstance.ts';\nimport { getQueryMatcher } from '../../rx-query-helper.ts';\n\nlet instanceId = now();\n\nexport class RxStorageInstanceLoki implements RxStorageInstance<\n RxDocType,\n LokiStorageInternals,\n LokiSettings,\n RxStorageDefaultCheckpoint\n> {\n\n public readonly primaryPath: StringKeys>;\n private changes$: Subject>, RxStorageDefaultCheckpoint>> = new Subject();\n public readonly instanceId = instanceId++;\n\n public closed?: Promise;\n\n constructor(\n public readonly databaseInstanceToken: string,\n public readonly storage: RxStorageLoki,\n public readonly databaseName: string,\n public readonly collectionName: string,\n public readonly schema: Readonly>>,\n public readonly internals: LokiStorageInternals,\n public readonly options: Readonly,\n public readonly databaseSettings: LokiDatabaseSettings\n ) {\n this.primaryPath = getPrimaryFieldOfPrimaryKey(this.schema.primaryKey);\n OPEN_LOKIJS_STORAGE_INSTANCES.add(this);\n if (this.internals.leaderElector) {\n\n\n /**\n * To run handleRemoteRequest(),\n * the instance will call its own methods.\n * But these methods could have already been swapped out by a RxStorageWrapper\n * so we must store the original methods here and use them instead.\n */\n const copiedSelf: RxStorageInstance = {\n bulkWrite: this.bulkWrite.bind(this),\n changeStream: this.changeStream.bind(this),\n cleanup: this.cleanup.bind(this),\n close: this.close.bind(this),\n query: this.query.bind(this),\n count: this.count.bind(this),\n findDocumentsById: this.findDocumentsById.bind(this),\n collectionName: this.collectionName,\n databaseName: this.databaseName,\n conflictResultionTasks: this.conflictResultionTasks.bind(this),\n getAttachmentData: this.getAttachmentData.bind(this),\n internals: this.internals,\n options: this.options,\n remove: this.remove.bind(this),\n resolveConflictResultionTask: this.resolveConflictResultionTask.bind(this),\n schema: this.schema\n };\n\n this.internals.leaderElector.awaitLeadership().then(() => {\n // this instance is leader now, so it has to reply to queries from other instances\n ensureNotFalsy(this.internals.leaderElector).broadcastChannel\n .addEventListener('message', (msg) => handleRemoteRequest(copiedSelf as any, msg));\n }).catch(() => { });\n }\n }\n\n async bulkWrite(\n documentWrites: BulkWriteRow[],\n context: string\n ): Promise> {\n if (documentWrites.length === 0) {\n throw newRxError('P2', {\n args: {\n documentWrites\n }\n });\n }\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'bulkWrite', [documentWrites]);\n }\n\n const ret: RxStorageBulkWriteResponse = {\n success: [],\n error: []\n };\n\n const docsInDb: Map[StringKeys], RxDocumentData> = new Map();\n const docsInDbWithLokiKey: Map<\n RxDocumentData[StringKeys],\n RxDocumentData & { $loki: number; }\n > = new Map();\n documentWrites.forEach(writeRow => {\n const id = writeRow.document[this.primaryPath];\n const documentInDb = localState.collection.by(this.primaryPath, id);\n if (documentInDb) {\n docsInDbWithLokiKey.set(id as any, documentInDb);\n docsInDb.set(id as any, stripLokiKey(documentInDb));\n }\n });\n\n const categorized = categorizeBulkWriteRows(\n this,\n this.primaryPath as any,\n docsInDb,\n documentWrites,\n context\n );\n ret.error = categorized.errors;\n\n categorized.bulkInsertDocs.forEach(writeRow => {\n localState.collection.insert(flatClone(writeRow.document));\n ret.success.push(writeRow.document);\n });\n categorized.bulkUpdateDocs.forEach(writeRow => {\n const docId = writeRow.document[this.primaryPath];\n const documentInDbWithLokiKey = getFromMapOrThrow(docsInDbWithLokiKey, docId as any);\n const writeDoc: any = Object.assign(\n {},\n writeRow.document,\n {\n $loki: documentInDbWithLokiKey.$loki\n }\n );\n localState.collection.update(writeDoc);\n ret.success.push(writeRow.document);\n });\n localState.databaseState.saveQueue.addWrite();\n\n if (categorized.eventBulk.events.length > 0) {\n const lastState = ensureNotFalsy(categorized.newestRow).document;\n categorized.eventBulk.checkpoint = {\n id: lastState[this.primaryPath],\n lwt: lastState._meta.lwt\n };\n categorized.eventBulk.endTime = now();\n this.changes$.next(categorized.eventBulk);\n }\n\n return ret;\n }\n async findDocumentsById(ids: string[], deleted: boolean): Promise[]> {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'findDocumentsById', [ids, deleted]);\n }\n\n const ret: RxDocumentData[] = [];\n ids.forEach(id => {\n const documentInDb = localState.collection.by(this.primaryPath, id);\n if (\n documentInDb &&\n (!documentInDb._deleted || deleted)\n ) {\n ret.push(stripLokiKey(documentInDb));\n }\n });\n return ret;\n }\n async query(preparedQueryOriginal: PreparedQuery): Promise> {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'query', [preparedQueryOriginal]);\n }\n\n let preparedQuery = ensureNotFalsy(preparedQueryOriginal.query);\n if (preparedQuery.selector) {\n preparedQuery = flatClone(preparedQuery);\n preparedQuery.selector = transformRegexToRegExp(preparedQuery.selector);\n }\n\n const query = preparedQueryOriginal.query;\n const skip = query.skip ? query.skip : 0;\n const limit = query.limit ? query.limit : Infinity;\n const skipPlusLimit = skip + limit;\n\n /**\n * LokiJS is not able to give correct results for some\n * operators, so we have to check all documents in that case\n * and laster apply skip and limit manually.\n * @link https://github.com/pubkey/rxdb/issues/5320\n */\n let mustRunMatcher = false;\n if (hasDeepProperty(preparedQuery.selector, '$in')) {\n mustRunMatcher = true;\n }\n\n\n let lokiQuery = localState.collection\n .chain()\n .find(mustRunMatcher ? {} : preparedQuery.selector);\n\n if (preparedQuery.sort) {\n lokiQuery = lokiQuery.sort(getLokiSortComparator(this.schema, preparedQuery));\n }\n\n\n\n\n /**\n * Offset must be used before limit in LokiJS\n * @link https://github.com/techfort/LokiJS/issues/570\n */\n if (!mustRunMatcher && preparedQuery.skip) {\n lokiQuery = lokiQuery.offset(preparedQuery.skip);\n }\n\n if (!mustRunMatcher && preparedQuery.limit) {\n lokiQuery = lokiQuery.limit(preparedQuery.limit);\n }\n\n let foundDocuments = lokiQuery.data().map((lokiDoc: any) => stripLokiKey(lokiDoc));\n\n\n /**\n * LokiJS returned wrong results on some queries\n * with complex indexes. Therefore we run the query-match\n * over all result docs to patch this bug.\n * TODO create an issue at the LokiJS repository.\n */\n const queryMatcher = getQueryMatcher(\n this.schema,\n preparedQuery as any\n );\n foundDocuments = foundDocuments.filter((d: any) => queryMatcher(d));\n\n\n if (mustRunMatcher) {\n foundDocuments = foundDocuments.slice(skip, skipPlusLimit);\n }\n\n return {\n documents: foundDocuments\n };\n }\n async count(\n preparedQuery: PreparedQuery\n ): Promise {\n const result = await this.query(preparedQuery);\n return {\n count: result.documents.length,\n mode: 'fast'\n };\n }\n getAttachmentData(_documentId: string, _attachmentId: string, _digest: string): Promise {\n throw new Error('Attachments are not implemented in the lokijs RxStorage. Make a pull request.');\n }\n\n changeStream(): Observable>, RxStorageDefaultCheckpoint>> {\n return this.changes$.asObservable();\n }\n\n async cleanup(minimumDeletedTime: number): Promise {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'cleanup', [minimumDeletedTime]);\n }\n\n const deleteAmountPerRun = 10;\n const maxDeletionTime = now() - minimumDeletedTime;\n const query = localState.collection\n .chain()\n .find({\n _deleted: true,\n '_meta.lwt': {\n $lt: maxDeletionTime\n }\n }).limit(deleteAmountPerRun);\n const foundDocuments = query.data();\n if (foundDocuments.length > 0) {\n localState.collection.remove(foundDocuments);\n localState.databaseState.saveQueue.addWrite();\n }\n\n return foundDocuments.length !== deleteAmountPerRun;\n }\n\n async close(): Promise {\n if (this.closed) {\n return this.closed;\n }\n this.closed = (async () => {\n this.changes$.complete();\n OPEN_LOKIJS_STORAGE_INSTANCES.delete(this);\n if (this.internals.localState) {\n const localState = await this.internals.localState;\n const dbState = await getLokiDatabase(\n this.databaseName,\n this.databaseSettings\n );\n await dbState.saveQueue.run();\n await closeLokiCollections(\n this.databaseName,\n [\n localState.collection\n ]\n );\n }\n })();\n return this.closed;\n }\n async remove(): Promise {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'remove', []);\n }\n localState.databaseState.database.removeCollection(localState.collection.name);\n await localState.databaseState.saveQueue.run();\n return this.close();\n }\n\n conflictResultionTasks(): Observable> {\n return new Subject();\n }\n async resolveConflictResultionTask(_taskSolution: RxConflictResultionTaskSolution): Promise { }\n\n}\n\nexport async function createLokiLocalState(\n params: RxStorageInstanceCreationParams,\n databaseSettings: LokiDatabaseSettings\n): Promise {\n if (!params.options) {\n params.options = {};\n }\n\n const databaseState = await getLokiDatabase(\n params.databaseName,\n databaseSettings\n );\n\n /**\n * Construct loki indexes from RxJsonSchema indexes.\n * TODO what about compound indexes? Are they possible in lokijs?\n */\n const indices: string[] = [];\n if (params.schema.indexes) {\n params.schema.indexes.forEach(idx => {\n if (!isMaybeReadonlyArray(idx)) {\n indices.push(idx);\n }\n });\n }\n /**\n * LokiJS has no concept of custom primary key, they use a number-id that is generated.\n * To be able to query fast by primary key, we always add an index to the primary.\n */\n const primaryKey = getPrimaryFieldOfPrimaryKey(params.schema.primaryKey);\n indices.push(primaryKey as string);\n\n const lokiCollectionName = params.collectionName + '-' + params.schema.version;\n const collectionOptions: Partial = Object.assign(\n {},\n lokiCollectionName,\n {\n indices: indices as string[],\n unique: [primaryKey]\n } as any,\n LOKIJS_COLLECTION_DEFAULT_OPTIONS\n );\n\n const collection: any = databaseState.database.addCollection(\n lokiCollectionName,\n collectionOptions as any\n );\n databaseState.collections[params.collectionName] = collection;\n const ret: LokiLocalDatabaseState = {\n databaseState,\n collection\n };\n\n return ret;\n}\n\n\nexport async function createLokiStorageInstance(\n storage: RxStorageLoki,\n params: RxStorageInstanceCreationParams,\n databaseSettings: LokiDatabaseSettings\n): Promise> {\n const internals: LokiStorageInternals = {};\n\n const broadcastChannelRefObject: DeepReadonly = {};\n\n\n if (params.multiInstance) {\n const leaderElector = getLokiLeaderElector(\n params.databaseInstanceToken,\n broadcastChannelRefObject,\n params.databaseName\n );\n internals.leaderElector = leaderElector;\n } else {\n // optimisation shortcut, directly create db is non multi instance.\n internals.localState = createLokiLocalState(params, databaseSettings);\n await internals.localState;\n }\n\n const instance = new RxStorageInstanceLoki(\n params.databaseInstanceToken,\n storage,\n params.databaseName,\n params.collectionName,\n params.schema,\n internals,\n params.options,\n databaseSettings\n );\n\n await addRxStorageMultiInstanceSupport(\n RX_STORAGE_NAME_LOKIJS,\n params,\n instance,\n internals.leaderElector ? internals.leaderElector.broadcastChannel : undefined\n );\n\n if (params.multiInstance) {\n /**\n * Clean up the broadcast-channel reference on close()\n */\n const closeBefore = instance.close.bind(instance);\n instance.close = function () {\n removeBroadcastChannelReference(\n params.databaseInstanceToken,\n broadcastChannelRefObject\n );\n return closeBefore();\n };\n const removeBefore = instance.remove.bind(instance);\n instance.remove = function () {\n removeBroadcastChannelReference(\n params.databaseInstanceToken,\n broadcastChannelRefObject\n );\n return removeBefore();\n };\n\n /**\n * Directly create the localState when/if the db becomes leader.\n */\n ensureNotFalsy(internals.leaderElector)\n .awaitLeadership()\n .then(() => {\n if (!instance.closed) {\n mustUseLocalState(instance);\n }\n });\n }\n\n\n return instance;\n}\n"],"mappings":"AAAA,SACIA,OAAO,QAEJ,MAAM;AACb,SACIC,SAAS,EACTC,GAAG,EACHC,cAAc,EACdC,oBAAoB,EACpBC,iBAAiB,EACjBC,eAAe,QACZ,mBAAmB;AAC1B,SAASC,UAAU,QAAQ,mBAAmB;AAwB9C,SACIC,oBAAoB,EACpBC,eAAe,EACfC,6BAA6B,EAC7BC,iCAAiC,EACjCC,YAAY,EACZC,qBAAqB,EACrBC,oBAAoB,EACpBC,qBAAqB,EACrBC,iBAAiB,EACjBC,mBAAmB,EACnBC,sBAAsB,EACtBC,sBAAsB,QACnB,oBAAoB;AAE3B,SAASC,2BAA2B,QAAQ,2BAA2B;AACvE,SAASC,uBAAuB,QAAQ,4BAA4B;AACpE,SACIC,gCAAgC,EAChCC,+BAA+B,QAC5B,mCAAmC;AAC1C,SAASC,eAAe,QAAQ,0BAA0B;AAE1D,IAAIC,UAAU,GAAGvB,GAAG,CAAC,CAAC;AAEtB,WAAawB,qBAAqB;EAa9B,SAAAA,sBACoBC,qBAA6B,EAC7BC,OAAsB,EACtBC,YAAoB,EACpBC,cAAsB,EACtBC,MAAyD,EACzDC,SAA+B,EAC/BC,OAA+B,EAC/BC,gBAAsC,EACxD;IAAA,KAdMC,QAAQ,GAAoG,IAAInC,OAAO,CAAC,CAAC;IAAA,KACjHyB,UAAU,GAAGA,UAAU,EAAE;IAAA,KAKrBE,qBAA6B,GAA7BA,qBAA6B;IAAA,KAC7BC,OAAsB,GAAtBA,OAAsB;IAAA,KACtBC,YAAoB,GAApBA,YAAoB;IAAA,KACpBC,cAAsB,GAAtBA,cAAsB;IAAA,KACtBC,MAAyD,GAAzDA,MAAyD;IAAA,KACzDC,SAA+B,GAA/BA,SAA+B;IAAA,KAC/BC,OAA+B,GAA/BA,OAA+B;IAAA,KAC/BC,gBAAsC,GAAtCA,gBAAsC;IAEtD,IAAI,CAACE,WAAW,GAAGhB,2BAA2B,CAAC,IAAI,CAACW,MAAM,CAACM,UAAU,CAAC;IACtE3B,6BAA6B,CAAC4B,GAAG,CAAC,IAAI,CAAC;IACvC,IAAI,IAAI,CAACN,SAAS,CAACO,aAAa,EAAE;MAG9B;AACZ;AACA;AACA;AACA;AACA;MACY,IAAMC,UAAkD,GAAG;QACvDC,SAAS,EAAE,IAAI,CAACA,SAAS,CAACC,IAAI,CAAC,IAAI,CAAC;QACpCC,YAAY,EAAE,IAAI,CAACA,YAAY,CAACD,IAAI,CAAC,IAAI,CAAC;QAC1CE,OAAO,EAAE,IAAI,CAACA,OAAO,CAACF,IAAI,CAAC,IAAI,CAAC;QAChCG,KAAK,EAAE,IAAI,CAACA,KAAK,CAACH,IAAI,CAAC,IAAI,CAAC;QAC5BI,KAAK,EAAE,IAAI,CAACA,KAAK,CAACJ,IAAI,CAAC,IAAI,CAAC;QAC5BK,KAAK,EAAE,IAAI,CAACA,KAAK,CAACL,IAAI,CAAC,IAAI,CAAC;QAC5BM,iBAAiB,EAAE,IAAI,CAACA,iBAAiB,CAACN,IAAI,CAAC,IAAI,CAAC;QACpDZ,cAAc,EAAE,IAAI,CAACA,cAAc;QACnCD,YAAY,EAAE,IAAI,CAACA,YAAY;QAC/BoB,sBAAsB,EAAE,IAAI,CAACA,sBAAsB,CAACP,IAAI,CAAC,IAAI,CAAC;QAC9DQ,iBAAiB,EAAE,IAAI,CAACA,iBAAiB,CAACR,IAAI,CAAC,IAAI,CAAC;QACpDV,SAAS,EAAE,IAAI,CAACA,SAAS;QACzBC,OAAO,EAAE,IAAI,CAACA,OAAO;QACrBkB,MAAM,EAAE,IAAI,CAACA,MAAM,CAACT,IAAI,CAAC,IAAI,CAAC;QAC9BU,4BAA4B,EAAE,IAAI,CAACA,4BAA4B,CAACV,IAAI,CAAC,IAAI,CAAC;QAC1EX,MAAM,EAAE,IAAI,CAACA;MACjB,CAAC;MAED,IAAI,CAACC,SAAS,CAACO,aAAa,CAACc,eAAe,CAAC,CAAC,CAACC,IAAI,CAAC,MAAM;QACtD;QACAnD,cAAc,CAAC,IAAI,CAAC6B,SAAS,CAACO,aAAa,CAAC,CAACgB,gBAAgB,CACxDC,gBAAgB,CAAC,SAAS,EAAGC,GAAG,IAAKxC,mBAAmB,CAACuB,UAAU,EAASiB,GAAG,CAAC,CAAC;MAC1F,CAAC,CAAC,CAACC,KAAK,CAAC,MAAM,CAAE,CAAC,CAAC;IACvB;EACJ;EAAC,IAAAC,MAAA,GAAAjC,qBAAA,CAAAkC,SAAA;EAAAD,MAAA,CAEKlB,SAAS,GAAf,eAAAA,UACIoB,cAAyC,EACzCC,OAAe,EAC+B;IAC9C,IAAID,cAAc,CAACE,MAAM,KAAK,CAAC,EAAE;MAC7B,MAAMxD,UAAU,CAAC,IAAI,EAAE;QACnByD,IAAI,EAAE;UACFH;QACJ;MACJ,CAAC,CAAC;IACN;IACA,IAAMI,UAAU,GAAG,MAAMjD,iBAAiB,CAAC,IAAI,CAAC;IAChD,IAAI,CAACiD,UAAU,EAAE;MACb,OAAOlD,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC8C,cAAc,CAAC,CAAC;IACrE;IAEA,IAAMK,GAA0C,GAAG;MAC/CC,OAAO,EAAE,EAAE;MACXC,KAAK,EAAE;IACX,CAAC;IAED,IAAMC,QAA0F,GAAG,IAAIC,GAAG,CAAC,CAAC;IAC5G,IAAMC,mBAGL,GAAG,IAAID,GAAG,CAAC,CAAC;IACbT,cAAc,CAACW,OAAO,CAACC,QAAQ,IAAI;MAC/B,IAAMC,EAAE,GAAGD,QAAQ,CAACE,QAAQ,CAAC,IAAI,CAACvC,WAAW,CAAC;MAC9C,IAAMwC,YAAY,GAAGX,UAAU,CAACY,UAAU,CAACC,EAAE,CAAC,IAAI,CAAC1C,WAAW,EAAEsC,EAAE,CAAC;MACnE,IAAIE,YAAY,EAAE;QACdL,mBAAmB,CAACQ,GAAG,CAACL,EAAE,EAASE,YAAY,CAAC;QAChDP,QAAQ,CAACU,GAAG,CAACL,EAAE,EAAS9D,YAAY,CAACgE,YAAY,CAAC,CAAC;MACvD;IACJ,CAAC,CAAC;IAEF,IAAMI,WAAW,GAAG3D,uBAAuB,CACvC,IAAI,EACJ,IAAI,CAACe,WAAW,EAChBiC,QAAQ,EACRR,cAAc,EACdC,OACJ,CAAC;IACDI,GAAG,CAACE,KAAK,GAAGY,WAAW,CAACC,MAAM;IAE9BD,WAAW,CAACE,cAAc,CAACV,OAAO,CAACC,QAAQ,IAAI;MAC3CR,UAAU,CAACY,UAAU,CAACM,MAAM,CAAClF,SAAS,CAACwE,QAAQ,CAACE,QAAQ,CAAC,CAAC;MAC1DT,GAAG,CAACC,OAAO,CAACiB,IAAI,CAACX,QAAQ,CAACE,QAAQ,CAAC;IACvC,CAAC,CAAC;IACFK,WAAW,CAACK,cAAc,CAACb,OAAO,CAACC,QAAQ,IAAI;MAC3C,IAAMa,KAAK,GAAGb,QAAQ,CAACE,QAAQ,CAAC,IAAI,CAACvC,WAAW,CAAC;MACjD,IAAMmD,uBAAuB,GAAGlF,iBAAiB,CAACkE,mBAAmB,EAAEe,KAAY,CAAC;MACpF,IAAME,QAAa,GAAGC,MAAM,CAACC,MAAM,CAC/B,CAAC,CAAC,EACFjB,QAAQ,CAACE,QAAQ,EACjB;QACIgB,KAAK,EAAEJ,uBAAuB,CAACI;MACnC,CACJ,CAAC;MACD1B,UAAU,CAACY,UAAU,CAACe,MAAM,CAACJ,QAAQ,CAAC;MACtCtB,GAAG,CAACC,OAAO,CAACiB,IAAI,CAACX,QAAQ,CAACE,QAAQ,CAAC;IACvC,CAAC,CAAC;IACFV,UAAU,CAAC4B,aAAa,CAACC,SAAS,CAACC,QAAQ,CAAC,CAAC;IAE7C,IAAIf,WAAW,CAACgB,SAAS,CAACC,MAAM,CAAClC,MAAM,GAAG,CAAC,EAAE;MACzC,IAAMmC,SAAS,GAAG/F,cAAc,CAAC6E,WAAW,CAACmB,SAAS,CAAC,CAACxB,QAAQ;MAChEK,WAAW,CAACgB,SAAS,CAACI,UAAU,GAAG;QAC/B1B,EAAE,EAAEwB,SAAS,CAAC,IAAI,CAAC9D,WAAW,CAAC;QAC/BiE,GAAG,EAAEH,SAAS,CAACI,KAAK,CAACD;MACzB,CAAC;MACDrB,WAAW,CAACgB,SAAS,CAACO,OAAO,GAAGrG,GAAG,CAAC,CAAC;MACrC,IAAI,CAACiC,QAAQ,CAACqE,IAAI,CAACxB,WAAW,CAACgB,SAAS,CAAC;IAC7C;IAEA,OAAO9B,GAAG;EACd,CAAC;EAAAP,MAAA,CACKX,iBAAiB,GAAvB,eAAAA,kBAAwByD,GAAa,EAAEC,OAAgB,EAAwC;IAC3F,IAAMzC,UAAU,GAAG,MAAMjD,iBAAiB,CAAC,IAAI,CAAC;IAChD,IAAI,CAACiD,UAAU,EAAE;MACb,OAAOlD,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC0F,GAAG,EAAEC,OAAO,CAAC,CAAC;IAC3E;IAEA,IAAMxC,GAAgC,GAAG,EAAE;IAC3CuC,GAAG,CAACjC,OAAO,CAACE,EAAE,IAAI;MACd,IAAME,YAAY,GAAGX,UAAU,CAACY,UAAU,CAACC,EAAE,CAAC,IAAI,CAAC1C,WAAW,EAAEsC,EAAE,CAAC;MACnE,IACIE,YAAY,KACX,CAACA,YAAY,CAAC+B,QAAQ,IAAID,OAAO,CAAC,EACrC;QACExC,GAAG,CAACkB,IAAI,CAACxE,YAAY,CAACgE,YAAY,CAAC,CAAC;MACxC;IACJ,CAAC,CAAC;IACF,OAAOV,GAAG;EACd,CAAC;EAAAP,MAAA,CACKb,KAAK,GAAX,eAAAA,MAAY8D,qBAA+C,EAA4C;IACnG,IAAM3C,UAAU,GAAG,MAAMjD,iBAAiB,CAAC,IAAI,CAAC;IAChD,IAAI,CAACiD,UAAU,EAAE;MACb,OAAOlD,qBAAqB,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC6F,qBAAqB,CAAC,CAAC;IACxE;IAEA,IAAIC,aAAa,GAAG1G,cAAc,CAACyG,qBAAqB,CAAC9D,KAAK,CAAC;IAC/D,IAAI+D,aAAa,CAACC,QAAQ,EAAE;MACxBD,aAAa,GAAG5G,SAAS,CAAC4G,aAAa,CAAC;MACxCA,aAAa,CAACC,QAAQ,GAAG3F,sBAAsB,CAAC0F,aAAa,CAACC,QAAQ,CAAC;IAC3E;IAEA,IAAMhE,KAAK,GAAG8D,qBAAqB,CAAC9D,KAAK;IACzC,IAAMiE,IAAI,GAAGjE,KAAK,CAACiE,IAAI,GAAGjE,KAAK,CAACiE,IAAI,GAAG,CAAC;IACxC,IAAMC,KAAK,GAAGlE,KAAK,CAACkE,KAAK,GAAGlE,KAAK,CAACkE,KAAK,GAAGC,QAAQ;IAClD,IAAMC,aAAa,GAAGH,IAAI,GAAGC,KAAK;;IAElC;AACR;AACA;AACA;AACA;AACA;IACQ,IAAIG,cAAc,GAAG,KAAK;IAC1B,IAAI7G,eAAe,CAACuG,aAAa,CAACC,QAAQ,EAAE,KAAK,CAAC,EAAE;MAChDK,cAAc,GAAG,IAAI;IACzB;IAGA,IAAIC,SAAS,GAAGnD,UAAU,CAACY,UAAU,CAChCwC,KAAK,CAAC,CAAC,CACPC,IAAI,CAACH,cAAc,GAAG,CAAC,CAAC,GAAGN,aAAa,CAACC,QAAQ,CAAC;IAEvD,IAAID,aAAa,CAACU,IAAI,EAAE;MACpBH,SAAS,GAAGA,SAAS,CAACG,IAAI,CAAC1G,qBAAqB,CAAC,IAAI,CAACkB,MAAM,EAAE8E,aAAa,CAAC,CAAC;IACjF;;IAKA;AACR;AACA;AACA;IACQ,IAAI,CAACM,cAAc,IAAIN,aAAa,CAACE,IAAI,EAAE;MACvCK,SAAS,GAAGA,SAAS,CAACI,MAAM,CAACX,aAAa,CAACE,IAAI,CAAC;IACpD;IAEA,IAAI,CAACI,cAAc,IAAIN,aAAa,CAACG,KAAK,EAAE;MACxCI,SAAS,GAAGA,SAAS,CAACJ,KAAK,CAACH,aAAa,CAACG,KAAK,CAAC;IACpD;IAEA,IAAIS,cAAc,GAAGL,SAAS,CAACM,IAAI,CAAC,CAAC,CAACC,GAAG,CAAEC,OAAY,IAAKhH,YAAY,CAACgH,OAAO,CAAC,CAAC;;IAGlF;AACR;AACA;AACA;AACA;AACA;IACQ,IAAMC,YAAY,GAAGrG,eAAe,CAChC,IAAI,CAACO,MAAM,EACX8E,aACJ,CAAC;IACDY,cAAc,GAAGA,cAAc,CAACK,MAAM,CAAEC,CAAM,IAAKF,YAAY,CAACE,CAAC,CAAC,CAAC;IAGnE,IAAIZ,cAAc,EAAE;MAChBM,cAAc,GAAGA,cAAc,CAACO,KAAK,CAACjB,IAAI,EAAEG,aAAa,CAAC;IAC9D;IAEA,OAAO;MACHe,SAAS,EAAER;IACf,CAAC;EACL,CAAC;EAAA9D,MAAA,CACKZ,KAAK,GAAX,eAAAA,MACI8D,aAAuC,EACV;IAC7B,IAAMqB,MAAM,GAAG,MAAM,IAAI,CAACpF,KAAK,CAAC+D,aAAa,CAAC;IAC9C,OAAO;MACH9D,KAAK,EAAEmF,MAAM,CAACD,SAAS,CAAClE,MAAM;MAC9BoE,IAAI,EAAE;IACV,CAAC;EACL,CAAC;EAAAxE,MAAA,CACDT,iBAAiB,GAAjB,SAAAA,kBAAkBkF,WAAmB,EAAEC,aAAqB,EAAEC,OAAe,EAAmB;IAC5F,MAAM,IAAIC,KAAK,CAAC,+EAA+E,CAAC;EACpG,CAAC;EAAA5E,MAAA,CAEDhB,YAAY,GAAZ,SAAAA,aAAA,EAAmH;IAC/G,OAAO,IAAI,CAACR,QAAQ,CAACqG,YAAY,CAAC,CAAC;EACvC,CAAC;EAAA7E,MAAA,CAEKf,OAAO,GAAb,eAAAA,QAAc6F,kBAA0B,EAAoB;IACxD,IAAMxE,UAAU,GAAG,MAAMjD,iBAAiB,CAAC,IAAI,CAAC;IAChD,IAAI,CAACiD,UAAU,EAAE;MACb,OAAOlD,qBAAqB,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC0H,kBAAkB,CAAC,CAAC;IACvE;IAEA,IAAMC,kBAAkB,GAAG,EAAE;IAC7B,IAAMC,eAAe,GAAGzI,GAAG,CAAC,CAAC,GAAGuI,kBAAkB;IAClD,IAAM3F,KAAK,GAAGmB,UAAU,CAACY,UAAU,CAC9BwC,KAAK,CAAC,CAAC,CACPC,IAAI,CAAC;MACFX,QAAQ,EAAE,IAAI;MACd,WAAW,EAAE;QACTiC,GAAG,EAAED;MACT;IACJ,CAAC,CAAC,CAAC3B,KAAK,CAAC0B,kBAAkB,CAAC;IAChC,IAAMjB,cAAc,GAAG3E,KAAK,CAAC4E,IAAI,CAAC,CAAC;IACnC,IAAID,cAAc,CAAC1D,MAAM,GAAG,CAAC,EAAE;MAC3BE,UAAU,CAACY,UAAU,CAAC1B,MAAM,CAACsE,cAAc,CAAC;MAC5CxD,UAAU,CAAC4B,aAAa,CAACC,SAAS,CAACC,QAAQ,CAAC,CAAC;IACjD;IAEA,OAAO0B,cAAc,CAAC1D,MAAM,KAAK2E,kBAAkB;EACvD,CAAC;EAAA/E,MAAA,CAEKd,KAAK,GAAX,eAAAA,MAAA,EAA6B;IACzB,IAAI,IAAI,CAACgG,MAAM,EAAE;MACb,OAAO,IAAI,CAACA,MAAM;IACtB;IACA,IAAI,CAACA,MAAM,GAAG,CAAC,YAAY;MACvB,IAAI,CAAC1G,QAAQ,CAAC2G,QAAQ,CAAC,CAAC;MACxBpI,6BAA6B,CAACqI,MAAM,CAAC,IAAI,CAAC;MAC1C,IAAI,IAAI,CAAC/G,SAAS,CAACiC,UAAU,EAAE;QAC3B,IAAMA,UAAU,GAAG,MAAM,IAAI,CAACjC,SAAS,CAACiC,UAAU;QAClD,IAAM+E,OAAO,GAAG,MAAMvI,eAAe,CACjC,IAAI,CAACoB,YAAY,EACjB,IAAI,CAACK,gBACT,CAAC;QACD,MAAM8G,OAAO,CAAClD,SAAS,CAACmD,GAAG,CAAC,CAAC;QAC7B,MAAMzI,oBAAoB,CACtB,IAAI,CAACqB,YAAY,EACjB,CACIoC,UAAU,CAACY,UAAU,CAE7B,CAAC;MACL;IACJ,CAAC,EAAE,CAAC;IACJ,OAAO,IAAI,CAACgE,MAAM;EACtB,CAAC;EAAAlF,MAAA,CACKR,MAAM,GAAZ,eAAAA,OAAA,EAA8B;IAC1B,IAAMc,UAAU,GAAG,MAAMjD,iBAAiB,CAAC,IAAI,CAAC;IAChD,IAAI,CAACiD,UAAU,EAAE;MACb,OAAOlD,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC;IACpD;IACAkD,UAAU,CAAC4B,aAAa,CAACqD,QAAQ,CAACC,gBAAgB,CAAClF,UAAU,CAACY,UAAU,CAACuE,IAAI,CAAC;IAC9E,MAAMnF,UAAU,CAAC4B,aAAa,CAACC,SAAS,CAACmD,GAAG,CAAC,CAAC;IAC9C,OAAO,IAAI,CAACpG,KAAK,CAAC,CAAC;EACvB,CAAC;EAAAc,MAAA,CAEDV,sBAAsB,GAAtB,SAAAA,uBAAA,EAAyE;IACrE,OAAO,IAAIjD,OAAO,CAAC,CAAC;EACxB,CAAC;EAAA2D,MAAA,CACKP,4BAA4B,GAAlC,eAAAA,6BAAmCiG,aAAyD,EAAiB,CAAE,CAAC;EAAA,OAAA3H,qBAAA;AAAA;AAIpH,OAAO,eAAe4H,oBAAoBA,CACtCC,MAAgE,EAChErH,gBAAsC,EACP;EAC/B,IAAI,CAACqH,MAAM,CAACtH,OAAO,EAAE;IACjBsH,MAAM,CAACtH,OAAO,GAAG,CAAC,CAAC;EACvB;EAEA,IAAM4D,aAAa,GAAG,MAAMpF,eAAe,CACvC8I,MAAM,CAAC1H,YAAY,EACnBK,gBACJ,CAAC;;EAED;AACJ;AACA;AACA;EACI,IAAMsH,OAAiB,GAAG,EAAE;EAC5B,IAAID,MAAM,CAACxH,MAAM,CAAC0H,OAAO,EAAE;IACvBF,MAAM,CAACxH,MAAM,CAAC0H,OAAO,CAACjF,OAAO,CAACkF,GAAG,IAAI;MACjC,IAAI,CAACtJ,oBAAoB,CAACsJ,GAAG,CAAC,EAAE;QAC5BF,OAAO,CAACpE,IAAI,CAACsE,GAAG,CAAC;MACrB;IACJ,CAAC,CAAC;EACN;EACA;AACJ;AACA;AACA;EACI,IAAMrH,UAAU,GAAGjB,2BAA2B,CAACmI,MAAM,CAACxH,MAAM,CAACM,UAAU,CAAC;EACxEmH,OAAO,CAACpE,IAAI,CAAC/C,UAAoB,CAAC;EAElC,IAAMsH,kBAAkB,GAAGJ,MAAM,CAACzH,cAAc,GAAG,GAAG,GAAGyH,MAAM,CAACxH,MAAM,CAAC6H,OAAO;EAC9E,IAAMC,iBAA+B,GAAGpE,MAAM,CAACC,MAAM,CACjD,CAAC,CAAC,EACFiE,kBAAkB,EAClB;IACIH,OAAO,EAAEA,OAAmB;IAC5BM,MAAM,EAAE,CAACzH,UAAU;EACvB,CAAC,EACD1B,iCACJ,CAAC;EAED,IAAMkE,UAAe,GAAGgB,aAAa,CAACqD,QAAQ,CAACa,aAAa,CACxDJ,kBAAkB,EAClBE,iBACJ,CAAC;EACDhE,aAAa,CAACmE,WAAW,CAACT,MAAM,CAACzH,cAAc,CAAC,GAAG+C,UAAU;EAC7D,IAAMX,GAA2B,GAAG;IAChC2B,aAAa;IACbhB;EACJ,CAAC;EAED,OAAOX,GAAG;AACd;AAGA,OAAO,eAAe+F,yBAAyBA,CAC3CrI,OAAsB,EACtB2H,MAAgE,EAChErH,gBAAsC,EACG;EACzC,IAAMF,SAA+B,GAAG,CAAC,CAAC;EAE1C,IAAMkI,yBAA4C,GAAG,CAAC,CAAC;EAGvD,IAAIX,MAAM,CAACY,aAAa,EAAE;IACtB,IAAM5H,aAAa,GAAGzB,oBAAoB,CACtCyI,MAAM,CAAC5H,qBAAqB,EAC5BuI,yBAAyB,EACzBX,MAAM,CAAC1H,YACX,CAAC;IACDG,SAAS,CAACO,aAAa,GAAGA,aAAa;EAC3C,CAAC,MAAM;IACH;IACAP,SAAS,CAACiC,UAAU,GAAGqF,oBAAoB,CAACC,MAAM,EAAErH,gBAAgB,CAAC;IACrE,MAAMF,SAAS,CAACiC,UAAU;EAC9B;EAEA,IAAMmG,QAAQ,GAAG,IAAI1I,qBAAqB,CACtC6H,MAAM,CAAC5H,qBAAqB,EAC5BC,OAAO,EACP2H,MAAM,CAAC1H,YAAY,EACnB0H,MAAM,CAACzH,cAAc,EACrByH,MAAM,CAACxH,MAAM,EACbC,SAAS,EACTuH,MAAM,CAACtH,OAAO,EACdC,gBACJ,CAAC;EAED,MAAMZ,gCAAgC,CAClCJ,sBAAsB,EACtBqI,MAAM,EACNa,QAAQ,EACRpI,SAAS,CAACO,aAAa,GAAGP,SAAS,CAACO,aAAa,CAACgB,gBAAgB,GAAG8G,SACzE,CAAC;EAED,IAAId,MAAM,CAACY,aAAa,EAAE;IACtB;AACR;AACA;IACQ,IAAMG,WAAW,GAAGF,QAAQ,CAACvH,KAAK,CAACH,IAAI,CAAC0H,QAAQ,CAAC;IACjDA,QAAQ,CAACvH,KAAK,GAAG,YAAY;MACzBtB,+BAA+B,CAC3BgI,MAAM,CAAC5H,qBAAqB,EAC5BuI,yBACJ,CAAC;MACD,OAAOI,WAAW,CAAC,CAAC;IACxB,CAAC;IACD,IAAMC,YAAY,GAAGH,QAAQ,CAACjH,MAAM,CAACT,IAAI,CAAC0H,QAAQ,CAAC;IACnDA,QAAQ,CAACjH,MAAM,GAAG,YAAY;MAC1B5B,+BAA+B,CAC3BgI,MAAM,CAAC5H,qBAAqB,EAC5BuI,yBACJ,CAAC;MACD,OAAOK,YAAY,CAAC,CAAC;IACzB,CAAC;;IAED;AACR;AACA;IACQpK,cAAc,CAAC6B,SAAS,CAACO,aAAa,CAAC,CAClCc,eAAe,CAAC,CAAC,CACjBC,IAAI,CAAC,MAAM;MACR,IAAI,CAAC8G,QAAQ,CAACvB,MAAM,EAAE;QAClB7H,iBAAiB,CAACoJ,QAAQ,CAAC;MAC/B;IACJ,CAAC,CAAC;EACV;EAGA,OAAOA,QAAQ;AACnB","ignoreList":[]} \ No newline at end of file +{"version":3,"file":"rx-storage-instance-loki.js","names":["Subject","flatClone","now","ensureNotFalsy","isMaybeReadonlyArray","getFromMapOrThrow","hasDeepProperty","newRxError","closeLokiCollections","getLokiDatabase","OPEN_LOKIJS_STORAGE_INSTANCES","LOKIJS_COLLECTION_DEFAULT_OPTIONS","stripLokiKey","getLokiSortComparator","getLokiLeaderElector","requestRemoteInstance","mustUseLocalState","handleRemoteRequest","RX_STORAGE_NAME_LOKIJS","transformRegexToRegExp","getPrimaryFieldOfPrimaryKey","categorizeBulkWriteRows","addRxStorageMultiInstanceSupport","removeBroadcastChannelReference","getQueryMatcher","instanceId","RxStorageInstanceLoki","databaseInstanceToken","storage","databaseName","collectionName","schema","internals","options","databaseSettings","changes$","primaryPath","primaryKey","add","leaderElector","copiedSelf","bulkWrite","bind","changeStream","cleanup","close","query","count","findDocumentsById","conflictResultionTasks","getAttachmentData","remove","resolveConflictResultionTask","awaitLeadership","then","broadcastChannel","addEventListener","msg","catch","_proto","prototype","documentWrites","context","length","args","localState","ret","success","error","docsInDb","Map","docsInDbWithLokiKey","forEach","writeRow","id","document","documentInDb","collection","by","set","categorized","errors","bulkInsertDocs","insert","push","bulkUpdateDocs","docId","documentInDbWithLokiKey","writeDoc","Object","assign","$loki","update","databaseState","saveQueue","addWrite","eventBulk","events","lastState","newestRow","checkpoint","lwt","_meta","endTime","next","ids","deleted","_deleted","preparedQueryOriginal","preparedQuery","selector","skip","limit","Infinity","skipPlusLimit","mustRunMatcher","lokiQuery","chain","find","sort","foundDocuments","data","map","lokiDoc","queryMatcher","filter","d","slice","documents","result","mode","_documentId","_attachmentId","_digest","Error","asObservable","minimumDeletedTime","deleteAmountPerRun","maxDeletionTime","$lt","closed","complete","delete","dbState","run","database","removeCollection","name","_taskSolution","createLokiLocalState","params","indices","indexes","idx","lokiCollectionName","version","collectionOptions","unique","addCollection","collections","createLokiStorageInstance","broadcastChannelRefObject","multiInstance","instance","undefined","closeBefore","removeBefore"],"sources":["../../../../src/plugins/storage-lokijs/rx-storage-instance-loki.ts"],"sourcesContent":["import {\n Subject,\n Observable\n} from 'rxjs';\nimport {\n flatClone,\n now,\n ensureNotFalsy,\n isMaybeReadonlyArray,\n getFromMapOrThrow,\n hasDeepProperty\n} from '../utils/index.ts';\nimport { newRxError } from '../../rx-error.ts';\nimport type {\n RxStorageInstance,\n LokiSettings,\n RxStorageChangeEvent,\n RxDocumentData,\n BulkWriteRow,\n RxStorageBulkWriteResponse,\n RxStorageQueryResult,\n RxJsonSchema,\n MangoQuery,\n LokiStorageInternals,\n RxStorageInstanceCreationParams,\n LokiDatabaseSettings,\n LokiLocalDatabaseState,\n EventBulk,\n StringKeys,\n DeepReadonly,\n RxConflictResultionTask,\n RxConflictResultionTaskSolution,\n RxStorageDefaultCheckpoint,\n RxStorageCountResult,\n PreparedQuery\n} from '../../types/index.d.ts';\nimport {\n closeLokiCollections,\n getLokiDatabase,\n OPEN_LOKIJS_STORAGE_INSTANCES,\n LOKIJS_COLLECTION_DEFAULT_OPTIONS,\n stripLokiKey,\n getLokiSortComparator,\n getLokiLeaderElector,\n requestRemoteInstance,\n mustUseLocalState,\n handleRemoteRequest,\n RX_STORAGE_NAME_LOKIJS,\n transformRegexToRegExp\n} from './lokijs-helper.ts';\nimport type { RxStorageLoki } from './rx-storage-lokijs.ts';\nimport { getPrimaryFieldOfPrimaryKey } from '../../rx-schema-helper.ts';\nimport { categorizeBulkWriteRows } from '../../rx-storage-helper.ts';\nimport {\n addRxStorageMultiInstanceSupport,\n removeBroadcastChannelReference\n} from '../../rx-storage-multiinstance.ts';\nimport { getQueryMatcher } from '../../rx-query-helper.ts';\n\nlet instanceId = now();\n\nexport class RxStorageInstanceLoki implements RxStorageInstance<\n RxDocType,\n LokiStorageInternals,\n LokiSettings,\n RxStorageDefaultCheckpoint\n> {\n\n public readonly primaryPath: StringKeys>;\n private changes$: Subject>, RxStorageDefaultCheckpoint>> = new Subject();\n public readonly instanceId = instanceId++;\n\n public closed?: Promise;\n\n constructor(\n public readonly databaseInstanceToken: string,\n public readonly storage: RxStorageLoki,\n public readonly databaseName: string,\n public readonly collectionName: string,\n public readonly schema: Readonly>>,\n public readonly internals: LokiStorageInternals,\n public readonly options: Readonly,\n public readonly databaseSettings: LokiDatabaseSettings\n ) {\n this.primaryPath = getPrimaryFieldOfPrimaryKey(this.schema.primaryKey);\n OPEN_LOKIJS_STORAGE_INSTANCES.add(this);\n if (this.internals.leaderElector) {\n\n\n /**\n * To run handleRemoteRequest(),\n * the instance will call its own methods.\n * But these methods could have already been swapped out by a RxStorageWrapper\n * so we must store the original methods here and use them instead.\n */\n const copiedSelf: RxStorageInstance = {\n bulkWrite: this.bulkWrite.bind(this),\n changeStream: this.changeStream.bind(this),\n cleanup: this.cleanup.bind(this),\n close: this.close.bind(this),\n query: this.query.bind(this),\n count: this.count.bind(this),\n findDocumentsById: this.findDocumentsById.bind(this),\n collectionName: this.collectionName,\n databaseName: this.databaseName,\n conflictResultionTasks: this.conflictResultionTasks.bind(this),\n getAttachmentData: this.getAttachmentData.bind(this),\n internals: this.internals,\n options: this.options,\n remove: this.remove.bind(this),\n resolveConflictResultionTask: this.resolveConflictResultionTask.bind(this),\n schema: this.schema\n };\n\n this.internals.leaderElector.awaitLeadership().then(() => {\n // this instance is leader now, so it has to reply to queries from other instances\n ensureNotFalsy(this.internals.leaderElector).broadcastChannel\n .addEventListener('message', (msg) => handleRemoteRequest(copiedSelf as any, msg));\n }).catch(() => { });\n }\n }\n\n async bulkWrite(\n documentWrites: BulkWriteRow[],\n context: string\n ): Promise> {\n if (documentWrites.length === 0) {\n throw newRxError('P2', {\n args: {\n documentWrites\n }\n });\n }\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'bulkWrite', [documentWrites]);\n }\n\n const ret: RxStorageBulkWriteResponse = {\n success: [],\n error: []\n };\n\n const docsInDb: Map[StringKeys], RxDocumentData> = new Map();\n const docsInDbWithLokiKey: Map<\n RxDocumentData[StringKeys],\n RxDocumentData & { $loki: number; }\n > = new Map();\n documentWrites.forEach(writeRow => {\n const id = writeRow.document[this.primaryPath];\n const documentInDb = localState.collection.by(this.primaryPath, id);\n if (documentInDb) {\n docsInDbWithLokiKey.set(id as any, documentInDb);\n docsInDb.set(id as any, stripLokiKey(documentInDb));\n }\n });\n\n const categorized = categorizeBulkWriteRows(\n this,\n this.primaryPath as any,\n docsInDb,\n documentWrites,\n context\n );\n ret.error = categorized.errors;\n\n categorized.bulkInsertDocs.forEach(writeRow => {\n localState.collection.insert(flatClone(writeRow.document));\n ret.success.push(writeRow.document);\n });\n categorized.bulkUpdateDocs.forEach(writeRow => {\n const docId = writeRow.document[this.primaryPath];\n const documentInDbWithLokiKey = getFromMapOrThrow(docsInDbWithLokiKey, docId as any);\n const writeDoc: any = Object.assign(\n {},\n writeRow.document,\n {\n $loki: documentInDbWithLokiKey.$loki\n }\n );\n localState.collection.update(writeDoc);\n ret.success.push(writeRow.document);\n });\n localState.databaseState.saveQueue.addWrite();\n\n if (categorized.eventBulk.events.length > 0) {\n const lastState = ensureNotFalsy(categorized.newestRow).document;\n categorized.eventBulk.checkpoint = {\n id: lastState[this.primaryPath],\n lwt: lastState._meta.lwt\n };\n categorized.eventBulk.endTime = now();\n this.changes$.next(categorized.eventBulk);\n }\n\n return ret;\n }\n async findDocumentsById(ids: string[], deleted: boolean): Promise[]> {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'findDocumentsById', [ids, deleted]);\n }\n\n const ret: RxDocumentData[] = [];\n ids.forEach(id => {\n const documentInDb = localState.collection.by(this.primaryPath, id);\n if (\n documentInDb &&\n (!documentInDb._deleted || deleted)\n ) {\n ret.push(stripLokiKey(documentInDb));\n }\n });\n return ret;\n }\n async query(preparedQueryOriginal: PreparedQuery): Promise> {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'query', [preparedQueryOriginal]);\n }\n\n let preparedQuery = ensureNotFalsy(preparedQueryOriginal.query);\n if (preparedQuery.selector) {\n preparedQuery = flatClone(preparedQuery);\n preparedQuery.selector = transformRegexToRegExp(preparedQuery.selector);\n }\n\n const query = preparedQueryOriginal.query;\n const skip = query.skip ? query.skip : 0;\n const limit = query.limit ? query.limit : Infinity;\n const skipPlusLimit = skip + limit;\n\n /**\n * LokiJS is not able to give correct results for some\n * operators, so we have to check all documents in that case\n * and laster apply skip and limit manually.\n * @link https://github.com/pubkey/rxdb/issues/5320\n */\n let mustRunMatcher = false;\n if (hasDeepProperty(preparedQuery.selector, '$in')) {\n mustRunMatcher = true;\n }\n\n\n let lokiQuery = localState.collection\n .chain()\n .find(mustRunMatcher ? {} : preparedQuery.selector);\n\n if (preparedQuery.sort) {\n lokiQuery = lokiQuery.sort(getLokiSortComparator(this.schema, preparedQuery));\n }\n\n\n let foundDocuments = lokiQuery.data().map((lokiDoc: any) => stripLokiKey(lokiDoc));\n\n\n /**\n * LokiJS returned wrong results on some queries\n * with complex indexes. Therefore we run the query-match\n * over all result docs to patch this bug.\n * TODO create an issue at the LokiJS repository.\n */\n const queryMatcher = getQueryMatcher(\n this.schema,\n preparedQuery as any\n );\n foundDocuments = foundDocuments.filter((d: any) => queryMatcher(d));\n\n // always apply offset and limit like this, because\n // sylvieQuery.offset() and sylvieQuery.limit() results were inconsistent\n foundDocuments = foundDocuments.slice(skip, skipPlusLimit);\n\n return {\n documents: foundDocuments\n };\n }\n async count(\n preparedQuery: PreparedQuery\n ): Promise {\n const result = await this.query(preparedQuery);\n return {\n count: result.documents.length,\n mode: 'fast'\n };\n }\n getAttachmentData(_documentId: string, _attachmentId: string, _digest: string): Promise {\n throw new Error('Attachments are not implemented in the lokijs RxStorage. Make a pull request.');\n }\n\n changeStream(): Observable>, RxStorageDefaultCheckpoint>> {\n return this.changes$.asObservable();\n }\n\n async cleanup(minimumDeletedTime: number): Promise {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'cleanup', [minimumDeletedTime]);\n }\n\n const deleteAmountPerRun = 10;\n const maxDeletionTime = now() - minimumDeletedTime;\n const query = localState.collection\n .chain()\n .find({\n _deleted: true,\n '_meta.lwt': {\n $lt: maxDeletionTime\n }\n }).limit(deleteAmountPerRun);\n const foundDocuments = query.data();\n if (foundDocuments.length > 0) {\n localState.collection.remove(foundDocuments);\n localState.databaseState.saveQueue.addWrite();\n }\n\n return foundDocuments.length !== deleteAmountPerRun;\n }\n\n async close(): Promise {\n if (this.closed) {\n return this.closed;\n }\n this.closed = (async () => {\n this.changes$.complete();\n OPEN_LOKIJS_STORAGE_INSTANCES.delete(this);\n if (this.internals.localState) {\n const localState = await this.internals.localState;\n const dbState = await getLokiDatabase(\n this.databaseName,\n this.databaseSettings\n );\n await dbState.saveQueue.run();\n await closeLokiCollections(\n this.databaseName,\n [\n localState.collection\n ]\n );\n }\n })();\n return this.closed;\n }\n async remove(): Promise {\n const localState = await mustUseLocalState(this);\n if (!localState) {\n return requestRemoteInstance(this, 'remove', []);\n }\n localState.databaseState.database.removeCollection(localState.collection.name);\n await localState.databaseState.saveQueue.run();\n return this.close();\n }\n\n conflictResultionTasks(): Observable> {\n return new Subject();\n }\n async resolveConflictResultionTask(_taskSolution: RxConflictResultionTaskSolution): Promise { }\n\n}\n\nexport async function createLokiLocalState(\n params: RxStorageInstanceCreationParams,\n databaseSettings: LokiDatabaseSettings\n): Promise {\n if (!params.options) {\n params.options = {};\n }\n\n const databaseState = await getLokiDatabase(\n params.databaseName,\n databaseSettings\n );\n\n /**\n * Construct loki indexes from RxJsonSchema indexes.\n * TODO what about compound indexes? Are they possible in lokijs?\n */\n const indices: string[] = [];\n if (params.schema.indexes) {\n params.schema.indexes.forEach(idx => {\n if (!isMaybeReadonlyArray(idx)) {\n indices.push(idx);\n }\n });\n }\n /**\n * LokiJS has no concept of custom primary key, they use a number-id that is generated.\n * To be able to query fast by primary key, we always add an index to the primary.\n */\n const primaryKey = getPrimaryFieldOfPrimaryKey(params.schema.primaryKey);\n indices.push(primaryKey as string);\n\n const lokiCollectionName = params.collectionName + '-' + params.schema.version;\n const collectionOptions: Partial = Object.assign(\n {},\n lokiCollectionName,\n {\n indices: indices as string[],\n unique: [primaryKey]\n } as any,\n LOKIJS_COLLECTION_DEFAULT_OPTIONS\n );\n\n const collection: any = databaseState.database.addCollection(\n lokiCollectionName,\n collectionOptions as any\n );\n databaseState.collections[params.collectionName] = collection;\n const ret: LokiLocalDatabaseState = {\n databaseState,\n collection\n };\n\n return ret;\n}\n\n\nexport async function createLokiStorageInstance(\n storage: RxStorageLoki,\n params: RxStorageInstanceCreationParams,\n databaseSettings: LokiDatabaseSettings\n): Promise> {\n const internals: LokiStorageInternals = {};\n\n const broadcastChannelRefObject: DeepReadonly = {};\n\n\n if (params.multiInstance) {\n const leaderElector = getLokiLeaderElector(\n params.databaseInstanceToken,\n broadcastChannelRefObject,\n params.databaseName\n );\n internals.leaderElector = leaderElector;\n } else {\n // optimisation shortcut, directly create db is non multi instance.\n internals.localState = createLokiLocalState(params, databaseSettings);\n await internals.localState;\n }\n\n const instance = new RxStorageInstanceLoki(\n params.databaseInstanceToken,\n storage,\n params.databaseName,\n params.collectionName,\n params.schema,\n internals,\n params.options,\n databaseSettings\n );\n\n await addRxStorageMultiInstanceSupport(\n RX_STORAGE_NAME_LOKIJS,\n params,\n instance,\n internals.leaderElector ? internals.leaderElector.broadcastChannel : undefined\n );\n\n if (params.multiInstance) {\n /**\n * Clean up the broadcast-channel reference on close()\n */\n const closeBefore = instance.close.bind(instance);\n instance.close = function () {\n removeBroadcastChannelReference(\n params.databaseInstanceToken,\n broadcastChannelRefObject\n );\n return closeBefore();\n };\n const removeBefore = instance.remove.bind(instance);\n instance.remove = function () {\n removeBroadcastChannelReference(\n params.databaseInstanceToken,\n broadcastChannelRefObject\n );\n return removeBefore();\n };\n\n /**\n * Directly create the localState when/if the db becomes leader.\n */\n ensureNotFalsy(internals.leaderElector)\n .awaitLeadership()\n .then(() => {\n if (!instance.closed) {\n mustUseLocalState(instance);\n }\n });\n }\n\n\n return instance;\n}\n"],"mappings":"AAAA,SACIA,OAAO,QAEJ,MAAM;AACb,SACIC,SAAS,EACTC,GAAG,EACHC,cAAc,EACdC,oBAAoB,EACpBC,iBAAiB,EACjBC,eAAe,QACZ,mBAAmB;AAC1B,SAASC,UAAU,QAAQ,mBAAmB;AAwB9C,SACIC,oBAAoB,EACpBC,eAAe,EACfC,6BAA6B,EAC7BC,iCAAiC,EACjCC,YAAY,EACZC,qBAAqB,EACrBC,oBAAoB,EACpBC,qBAAqB,EACrBC,iBAAiB,EACjBC,mBAAmB,EACnBC,sBAAsB,EACtBC,sBAAsB,QACnB,oBAAoB;AAE3B,SAASC,2BAA2B,QAAQ,2BAA2B;AACvE,SAASC,uBAAuB,QAAQ,4BAA4B;AACpE,SACIC,gCAAgC,EAChCC,+BAA+B,QAC5B,mCAAmC;AAC1C,SAASC,eAAe,QAAQ,0BAA0B;AAE1D,IAAIC,UAAU,GAAGvB,GAAG,CAAC,CAAC;AAEtB,WAAawB,qBAAqB;EAa9B,SAAAA,sBACoBC,qBAA6B,EAC7BC,OAAsB,EACtBC,YAAoB,EACpBC,cAAsB,EACtBC,MAAyD,EACzDC,SAA+B,EAC/BC,OAA+B,EAC/BC,gBAAsC,EACxD;IAAA,KAdMC,QAAQ,GAAoG,IAAInC,OAAO,CAAC,CAAC;IAAA,KACjHyB,UAAU,GAAGA,UAAU,EAAE;IAAA,KAKrBE,qBAA6B,GAA7BA,qBAA6B;IAAA,KAC7BC,OAAsB,GAAtBA,OAAsB;IAAA,KACtBC,YAAoB,GAApBA,YAAoB;IAAA,KACpBC,cAAsB,GAAtBA,cAAsB;IAAA,KACtBC,MAAyD,GAAzDA,MAAyD;IAAA,KACzDC,SAA+B,GAA/BA,SAA+B;IAAA,KAC/BC,OAA+B,GAA/BA,OAA+B;IAAA,KAC/BC,gBAAsC,GAAtCA,gBAAsC;IAEtD,IAAI,CAACE,WAAW,GAAGhB,2BAA2B,CAAC,IAAI,CAACW,MAAM,CAACM,UAAU,CAAC;IACtE3B,6BAA6B,CAAC4B,GAAG,CAAC,IAAI,CAAC;IACvC,IAAI,IAAI,CAACN,SAAS,CAACO,aAAa,EAAE;MAG9B;AACZ;AACA;AACA;AACA;AACA;MACY,IAAMC,UAAkD,GAAG;QACvDC,SAAS,EAAE,IAAI,CAACA,SAAS,CAACC,IAAI,CAAC,IAAI,CAAC;QACpCC,YAAY,EAAE,IAAI,CAACA,YAAY,CAACD,IAAI,CAAC,IAAI,CAAC;QAC1CE,OAAO,EAAE,IAAI,CAACA,OAAO,CAACF,IAAI,CAAC,IAAI,CAAC;QAChCG,KAAK,EAAE,IAAI,CAACA,KAAK,CAACH,IAAI,CAAC,IAAI,CAAC;QAC5BI,KAAK,EAAE,IAAI,CAACA,KAAK,CAACJ,IAAI,CAAC,IAAI,CAAC;QAC5BK,KAAK,EAAE,IAAI,CAACA,KAAK,CAACL,IAAI,CAAC,IAAI,CAAC;QAC5BM,iBAAiB,EAAE,IAAI,CAACA,iBAAiB,CAACN,IAAI,CAAC,IAAI,CAAC;QACpDZ,cAAc,EAAE,IAAI,CAACA,cAAc;QACnCD,YAAY,EAAE,IAAI,CAACA,YAAY;QAC/BoB,sBAAsB,EAAE,IAAI,CAACA,sBAAsB,CAACP,IAAI,CAAC,IAAI,CAAC;QAC9DQ,iBAAiB,EAAE,IAAI,CAACA,iBAAiB,CAACR,IAAI,CAAC,IAAI,CAAC;QACpDV,SAAS,EAAE,IAAI,CAACA,SAAS;QACzBC,OAAO,EAAE,IAAI,CAACA,OAAO;QACrBkB,MAAM,EAAE,IAAI,CAACA,MAAM,CAACT,IAAI,CAAC,IAAI,CAAC;QAC9BU,4BAA4B,EAAE,IAAI,CAACA,4BAA4B,CAACV,IAAI,CAAC,IAAI,CAAC;QAC1EX,MAAM,EAAE,IAAI,CAACA;MACjB,CAAC;MAED,IAAI,CAACC,SAAS,CAACO,aAAa,CAACc,eAAe,CAAC,CAAC,CAACC,IAAI,CAAC,MAAM;QACtD;QACAnD,cAAc,CAAC,IAAI,CAAC6B,SAAS,CAACO,aAAa,CAAC,CAACgB,gBAAgB,CACxDC,gBAAgB,CAAC,SAAS,EAAGC,GAAG,IAAKxC,mBAAmB,CAACuB,UAAU,EAASiB,GAAG,CAAC,CAAC;MAC1F,CAAC,CAAC,CAACC,KAAK,CAAC,MAAM,CAAE,CAAC,CAAC;IACvB;EACJ;EAAC,IAAAC,MAAA,GAAAjC,qBAAA,CAAAkC,SAAA;EAAAD,MAAA,CAEKlB,SAAS,GAAf,eAAAA,UACIoB,cAAyC,EACzCC,OAAe,EAC+B;IAC9C,IAAID,cAAc,CAACE,MAAM,KAAK,CAAC,EAAE;MAC7B,MAAMxD,UAAU,CAAC,IAAI,EAAE;QACnByD,IAAI,EAAE;UACFH;QACJ;MACJ,CAAC,CAAC;IACN;IACA,IAAMI,UAAU,GAAG,MAAMjD,iBAAiB,CAAC,IAAI,CAAC;IAChD,IAAI,CAACiD,UAAU,EAAE;MACb,OAAOlD,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC8C,cAAc,CAAC,CAAC;IACrE;IAEA,IAAMK,GAA0C,GAAG;MAC/CC,OAAO,EAAE,EAAE;MACXC,KAAK,EAAE;IACX,CAAC;IAED,IAAMC,QAA0F,GAAG,IAAIC,GAAG,CAAC,CAAC;IAC5G,IAAMC,mBAGL,GAAG,IAAID,GAAG,CAAC,CAAC;IACbT,cAAc,CAACW,OAAO,CAACC,QAAQ,IAAI;MAC/B,IAAMC,EAAE,GAAGD,QAAQ,CAACE,QAAQ,CAAC,IAAI,CAACvC,WAAW,CAAC;MAC9C,IAAMwC,YAAY,GAAGX,UAAU,CAACY,UAAU,CAACC,EAAE,CAAC,IAAI,CAAC1C,WAAW,EAAEsC,EAAE,CAAC;MACnE,IAAIE,YAAY,EAAE;QACdL,mBAAmB,CAACQ,GAAG,CAACL,EAAE,EAASE,YAAY,CAAC;QAChDP,QAAQ,CAACU,GAAG,CAACL,EAAE,EAAS9D,YAAY,CAACgE,YAAY,CAAC,CAAC;MACvD;IACJ,CAAC,CAAC;IAEF,IAAMI,WAAW,GAAG3D,uBAAuB,CACvC,IAAI,EACJ,IAAI,CAACe,WAAW,EAChBiC,QAAQ,EACRR,cAAc,EACdC,OACJ,CAAC;IACDI,GAAG,CAACE,KAAK,GAAGY,WAAW,CAACC,MAAM;IAE9BD,WAAW,CAACE,cAAc,CAACV,OAAO,CAACC,QAAQ,IAAI;MAC3CR,UAAU,CAACY,UAAU,CAACM,MAAM,CAAClF,SAAS,CAACwE,QAAQ,CAACE,QAAQ,CAAC,CAAC;MAC1DT,GAAG,CAACC,OAAO,CAACiB,IAAI,CAACX,QAAQ,CAACE,QAAQ,CAAC;IACvC,CAAC,CAAC;IACFK,WAAW,CAACK,cAAc,CAACb,OAAO,CAACC,QAAQ,IAAI;MAC3C,IAAMa,KAAK,GAAGb,QAAQ,CAACE,QAAQ,CAAC,IAAI,CAACvC,WAAW,CAAC;MACjD,IAAMmD,uBAAuB,GAAGlF,iBAAiB,CAACkE,mBAAmB,EAAEe,KAAY,CAAC;MACpF,IAAME,QAAa,GAAGC,MAAM,CAACC,MAAM,CAC/B,CAAC,CAAC,EACFjB,QAAQ,CAACE,QAAQ,EACjB;QACIgB,KAAK,EAAEJ,uBAAuB,CAACI;MACnC,CACJ,CAAC;MACD1B,UAAU,CAACY,UAAU,CAACe,MAAM,CAACJ,QAAQ,CAAC;MACtCtB,GAAG,CAACC,OAAO,CAACiB,IAAI,CAACX,QAAQ,CAACE,QAAQ,CAAC;IACvC,CAAC,CAAC;IACFV,UAAU,CAAC4B,aAAa,CAACC,SAAS,CAACC,QAAQ,CAAC,CAAC;IAE7C,IAAIf,WAAW,CAACgB,SAAS,CAACC,MAAM,CAAClC,MAAM,GAAG,CAAC,EAAE;MACzC,IAAMmC,SAAS,GAAG/F,cAAc,CAAC6E,WAAW,CAACmB,SAAS,CAAC,CAACxB,QAAQ;MAChEK,WAAW,CAACgB,SAAS,CAACI,UAAU,GAAG;QAC/B1B,EAAE,EAAEwB,SAAS,CAAC,IAAI,CAAC9D,WAAW,CAAC;QAC/BiE,GAAG,EAAEH,SAAS,CAACI,KAAK,CAACD;MACzB,CAAC;MACDrB,WAAW,CAACgB,SAAS,CAACO,OAAO,GAAGrG,GAAG,CAAC,CAAC;MACrC,IAAI,CAACiC,QAAQ,CAACqE,IAAI,CAACxB,WAAW,CAACgB,SAAS,CAAC;IAC7C;IAEA,OAAO9B,GAAG;EACd,CAAC;EAAAP,MAAA,CACKX,iBAAiB,GAAvB,eAAAA,kBAAwByD,GAAa,EAAEC,OAAgB,EAAwC;IAC3F,IAAMzC,UAAU,GAAG,MAAMjD,iBAAiB,CAAC,IAAI,CAAC;IAChD,IAAI,CAACiD,UAAU,EAAE;MACb,OAAOlD,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC0F,GAAG,EAAEC,OAAO,CAAC,CAAC;IAC3E;IAEA,IAAMxC,GAAgC,GAAG,EAAE;IAC3CuC,GAAG,CAACjC,OAAO,CAACE,EAAE,IAAI;MACd,IAAME,YAAY,GAAGX,UAAU,CAACY,UAAU,CAACC,EAAE,CAAC,IAAI,CAAC1C,WAAW,EAAEsC,EAAE,CAAC;MACnE,IACIE,YAAY,KACX,CAACA,YAAY,CAAC+B,QAAQ,IAAID,OAAO,CAAC,EACrC;QACExC,GAAG,CAACkB,IAAI,CAACxE,YAAY,CAACgE,YAAY,CAAC,CAAC;MACxC;IACJ,CAAC,CAAC;IACF,OAAOV,GAAG;EACd,CAAC;EAAAP,MAAA,CACKb,KAAK,GAAX,eAAAA,MAAY8D,qBAA+C,EAA4C;IACnG,IAAM3C,UAAU,GAAG,MAAMjD,iBAAiB,CAAC,IAAI,CAAC;IAChD,IAAI,CAACiD,UAAU,EAAE;MACb,OAAOlD,qBAAqB,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC6F,qBAAqB,CAAC,CAAC;IACxE;IAEA,IAAIC,aAAa,GAAG1G,cAAc,CAACyG,qBAAqB,CAAC9D,KAAK,CAAC;IAC/D,IAAI+D,aAAa,CAACC,QAAQ,EAAE;MACxBD,aAAa,GAAG5G,SAAS,CAAC4G,aAAa,CAAC;MACxCA,aAAa,CAACC,QAAQ,GAAG3F,sBAAsB,CAAC0F,aAAa,CAACC,QAAQ,CAAC;IAC3E;IAEA,IAAMhE,KAAK,GAAG8D,qBAAqB,CAAC9D,KAAK;IACzC,IAAMiE,IAAI,GAAGjE,KAAK,CAACiE,IAAI,GAAGjE,KAAK,CAACiE,IAAI,GAAG,CAAC;IACxC,IAAMC,KAAK,GAAGlE,KAAK,CAACkE,KAAK,GAAGlE,KAAK,CAACkE,KAAK,GAAGC,QAAQ;IAClD,IAAMC,aAAa,GAAGH,IAAI,GAAGC,KAAK;;IAElC;AACR;AACA;AACA;AACA;AACA;IACQ,IAAIG,cAAc,GAAG,KAAK;IAC1B,IAAI7G,eAAe,CAACuG,aAAa,CAACC,QAAQ,EAAE,KAAK,CAAC,EAAE;MAChDK,cAAc,GAAG,IAAI;IACzB;IAGA,IAAIC,SAAS,GAAGnD,UAAU,CAACY,UAAU,CAChCwC,KAAK,CAAC,CAAC,CACPC,IAAI,CAACH,cAAc,GAAG,CAAC,CAAC,GAAGN,aAAa,CAACC,QAAQ,CAAC;IAEvD,IAAID,aAAa,CAACU,IAAI,EAAE;MACpBH,SAAS,GAAGA,SAAS,CAACG,IAAI,CAAC1G,qBAAqB,CAAC,IAAI,CAACkB,MAAM,EAAE8E,aAAa,CAAC,CAAC;IACjF;IAGA,IAAIW,cAAc,GAAGJ,SAAS,CAACK,IAAI,CAAC,CAAC,CAACC,GAAG,CAAEC,OAAY,IAAK/G,YAAY,CAAC+G,OAAO,CAAC,CAAC;;IAGlF;AACR;AACA;AACA;AACA;AACA;IACQ,IAAMC,YAAY,GAAGpG,eAAe,CAChC,IAAI,CAACO,MAAM,EACX8E,aACJ,CAAC;IACDW,cAAc,GAAGA,cAAc,CAACK,MAAM,CAAEC,CAAM,IAAKF,YAAY,CAACE,CAAC,CAAC,CAAC;;IAEnE;IACA;IACAN,cAAc,GAAGA,cAAc,CAACO,KAAK,CAAChB,IAAI,EAAEG,aAAa,CAAC;IAE1D,OAAO;MACHc,SAAS,EAAER;IACf,CAAC;EACL,CAAC;EAAA7D,MAAA,CACKZ,KAAK,GAAX,eAAAA,MACI8D,aAAuC,EACV;IAC7B,IAAMoB,MAAM,GAAG,MAAM,IAAI,CAACnF,KAAK,CAAC+D,aAAa,CAAC;IAC9C,OAAO;MACH9D,KAAK,EAAEkF,MAAM,CAACD,SAAS,CAACjE,MAAM;MAC9BmE,IAAI,EAAE;IACV,CAAC;EACL,CAAC;EAAAvE,MAAA,CACDT,iBAAiB,GAAjB,SAAAA,kBAAkBiF,WAAmB,EAAEC,aAAqB,EAAEC,OAAe,EAAmB;IAC5F,MAAM,IAAIC,KAAK,CAAC,+EAA+E,CAAC;EACpG,CAAC;EAAA3E,MAAA,CAEDhB,YAAY,GAAZ,SAAAA,aAAA,EAAmH;IAC/G,OAAO,IAAI,CAACR,QAAQ,CAACoG,YAAY,CAAC,CAAC;EACvC,CAAC;EAAA5E,MAAA,CAEKf,OAAO,GAAb,eAAAA,QAAc4F,kBAA0B,EAAoB;IACxD,IAAMvE,UAAU,GAAG,MAAMjD,iBAAiB,CAAC,IAAI,CAAC;IAChD,IAAI,CAACiD,UAAU,EAAE;MACb,OAAOlD,qBAAqB,CAAC,IAAI,EAAE,SAAS,EAAE,CAACyH,kBAAkB,CAAC,CAAC;IACvE;IAEA,IAAMC,kBAAkB,GAAG,EAAE;IAC7B,IAAMC,eAAe,GAAGxI,GAAG,CAAC,CAAC,GAAGsI,kBAAkB;IAClD,IAAM1F,KAAK,GAAGmB,UAAU,CAACY,UAAU,CAC9BwC,KAAK,CAAC,CAAC,CACPC,IAAI,CAAC;MACFX,QAAQ,EAAE,IAAI;MACd,WAAW,EAAE;QACTgC,GAAG,EAAED;MACT;IACJ,CAAC,CAAC,CAAC1B,KAAK,CAACyB,kBAAkB,CAAC;IAChC,IAAMjB,cAAc,GAAG1E,KAAK,CAAC2E,IAAI,CAAC,CAAC;IACnC,IAAID,cAAc,CAACzD,MAAM,GAAG,CAAC,EAAE;MAC3BE,UAAU,CAACY,UAAU,CAAC1B,MAAM,CAACqE,cAAc,CAAC;MAC5CvD,UAAU,CAAC4B,aAAa,CAACC,SAAS,CAACC,QAAQ,CAAC,CAAC;IACjD;IAEA,OAAOyB,cAAc,CAACzD,MAAM,KAAK0E,kBAAkB;EACvD,CAAC;EAAA9E,MAAA,CAEKd,KAAK,GAAX,eAAAA,MAAA,EAA6B;IACzB,IAAI,IAAI,CAAC+F,MAAM,EAAE;MACb,OAAO,IAAI,CAACA,MAAM;IACtB;IACA,IAAI,CAACA,MAAM,GAAG,CAAC,YAAY;MACvB,IAAI,CAACzG,QAAQ,CAAC0G,QAAQ,CAAC,CAAC;MACxBnI,6BAA6B,CAACoI,MAAM,CAAC,IAAI,CAAC;MAC1C,IAAI,IAAI,CAAC9G,SAAS,CAACiC,UAAU,EAAE;QAC3B,IAAMA,UAAU,GAAG,MAAM,IAAI,CAACjC,SAAS,CAACiC,UAAU;QAClD,IAAM8E,OAAO,GAAG,MAAMtI,eAAe,CACjC,IAAI,CAACoB,YAAY,EACjB,IAAI,CAACK,gBACT,CAAC;QACD,MAAM6G,OAAO,CAACjD,SAAS,CAACkD,GAAG,CAAC,CAAC;QAC7B,MAAMxI,oBAAoB,CACtB,IAAI,CAACqB,YAAY,EACjB,CACIoC,UAAU,CAACY,UAAU,CAE7B,CAAC;MACL;IACJ,CAAC,EAAE,CAAC;IACJ,OAAO,IAAI,CAAC+D,MAAM;EACtB,CAAC;EAAAjF,MAAA,CACKR,MAAM,GAAZ,eAAAA,OAAA,EAA8B;IAC1B,IAAMc,UAAU,GAAG,MAAMjD,iBAAiB,CAAC,IAAI,CAAC;IAChD,IAAI,CAACiD,UAAU,EAAE;MACb,OAAOlD,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC;IACpD;IACAkD,UAAU,CAAC4B,aAAa,CAACoD,QAAQ,CAACC,gBAAgB,CAACjF,UAAU,CAACY,UAAU,CAACsE,IAAI,CAAC;IAC9E,MAAMlF,UAAU,CAAC4B,aAAa,CAACC,SAAS,CAACkD,GAAG,CAAC,CAAC;IAC9C,OAAO,IAAI,CAACnG,KAAK,CAAC,CAAC;EACvB,CAAC;EAAAc,MAAA,CAEDV,sBAAsB,GAAtB,SAAAA,uBAAA,EAAyE;IACrE,OAAO,IAAIjD,OAAO,CAAC,CAAC;EACxB,CAAC;EAAA2D,MAAA,CACKP,4BAA4B,GAAlC,eAAAA,6BAAmCgG,aAAyD,EAAiB,CAAE,CAAC;EAAA,OAAA1H,qBAAA;AAAA;AAIpH,OAAO,eAAe2H,oBAAoBA,CACtCC,MAAgE,EAChEpH,gBAAsC,EACP;EAC/B,IAAI,CAACoH,MAAM,CAACrH,OAAO,EAAE;IACjBqH,MAAM,CAACrH,OAAO,GAAG,CAAC,CAAC;EACvB;EAEA,IAAM4D,aAAa,GAAG,MAAMpF,eAAe,CACvC6I,MAAM,CAACzH,YAAY,EACnBK,gBACJ,CAAC;;EAED;AACJ;AACA;AACA;EACI,IAAMqH,OAAiB,GAAG,EAAE;EAC5B,IAAID,MAAM,CAACvH,MAAM,CAACyH,OAAO,EAAE;IACvBF,MAAM,CAACvH,MAAM,CAACyH,OAAO,CAAChF,OAAO,CAACiF,GAAG,IAAI;MACjC,IAAI,CAACrJ,oBAAoB,CAACqJ,GAAG,CAAC,EAAE;QAC5BF,OAAO,CAACnE,IAAI,CAACqE,GAAG,CAAC;MACrB;IACJ,CAAC,CAAC;EACN;EACA;AACJ;AACA;AACA;EACI,IAAMpH,UAAU,GAAGjB,2BAA2B,CAACkI,MAAM,CAACvH,MAAM,CAACM,UAAU,CAAC;EACxEkH,OAAO,CAACnE,IAAI,CAAC/C,UAAoB,CAAC;EAElC,IAAMqH,kBAAkB,GAAGJ,MAAM,CAACxH,cAAc,GAAG,GAAG,GAAGwH,MAAM,CAACvH,MAAM,CAAC4H,OAAO;EAC9E,IAAMC,iBAA+B,GAAGnE,MAAM,CAACC,MAAM,CACjD,CAAC,CAAC,EACFgE,kBAAkB,EAClB;IACIH,OAAO,EAAEA,OAAmB;IAC5BM,MAAM,EAAE,CAACxH,UAAU;EACvB,CAAC,EACD1B,iCACJ,CAAC;EAED,IAAMkE,UAAe,GAAGgB,aAAa,CAACoD,QAAQ,CAACa,aAAa,CACxDJ,kBAAkB,EAClBE,iBACJ,CAAC;EACD/D,aAAa,CAACkE,WAAW,CAACT,MAAM,CAACxH,cAAc,CAAC,GAAG+C,UAAU;EAC7D,IAAMX,GAA2B,GAAG;IAChC2B,aAAa;IACbhB;EACJ,CAAC;EAED,OAAOX,GAAG;AACd;AAGA,OAAO,eAAe8F,yBAAyBA,CAC3CpI,OAAsB,EACtB0H,MAAgE,EAChEpH,gBAAsC,EACG;EACzC,IAAMF,SAA+B,GAAG,CAAC,CAAC;EAE1C,IAAMiI,yBAA4C,GAAG,CAAC,CAAC;EAGvD,IAAIX,MAAM,CAACY,aAAa,EAAE;IACtB,IAAM3H,aAAa,GAAGzB,oBAAoB,CACtCwI,MAAM,CAAC3H,qBAAqB,EAC5BsI,yBAAyB,EACzBX,MAAM,CAACzH,YACX,CAAC;IACDG,SAAS,CAACO,aAAa,GAAGA,aAAa;EAC3C,CAAC,MAAM;IACH;IACAP,SAAS,CAACiC,UAAU,GAAGoF,oBAAoB,CAACC,MAAM,EAAEpH,gBAAgB,CAAC;IACrE,MAAMF,SAAS,CAACiC,UAAU;EAC9B;EAEA,IAAMkG,QAAQ,GAAG,IAAIzI,qBAAqB,CACtC4H,MAAM,CAAC3H,qBAAqB,EAC5BC,OAAO,EACP0H,MAAM,CAACzH,YAAY,EACnByH,MAAM,CAACxH,cAAc,EACrBwH,MAAM,CAACvH,MAAM,EACbC,SAAS,EACTsH,MAAM,CAACrH,OAAO,EACdC,gBACJ,CAAC;EAED,MAAMZ,gCAAgC,CAClCJ,sBAAsB,EACtBoI,MAAM,EACNa,QAAQ,EACRnI,SAAS,CAACO,aAAa,GAAGP,SAAS,CAACO,aAAa,CAACgB,gBAAgB,GAAG6G,SACzE,CAAC;EAED,IAAId,MAAM,CAACY,aAAa,EAAE;IACtB;AACR;AACA;IACQ,IAAMG,WAAW,GAAGF,QAAQ,CAACtH,KAAK,CAACH,IAAI,CAACyH,QAAQ,CAAC;IACjDA,QAAQ,CAACtH,KAAK,GAAG,YAAY;MACzBtB,+BAA+B,CAC3B+H,MAAM,CAAC3H,qBAAqB,EAC5BsI,yBACJ,CAAC;MACD,OAAOI,WAAW,CAAC,CAAC;IACxB,CAAC;IACD,IAAMC,YAAY,GAAGH,QAAQ,CAAChH,MAAM,CAACT,IAAI,CAACyH,QAAQ,CAAC;IACnDA,QAAQ,CAAChH,MAAM,GAAG,YAAY;MAC1B5B,+BAA+B,CAC3B+H,MAAM,CAAC3H,qBAAqB,EAC5BsI,yBACJ,CAAC;MACD,OAAOK,YAAY,CAAC,CAAC;IACzB,CAAC;;IAED;AACR;AACA;IACQnK,cAAc,CAAC6B,SAAS,CAACO,aAAa,CAAC,CAClCc,eAAe,CAAC,CAAC,CACjBC,IAAI,CAAC,MAAM;MACR,IAAI,CAAC6G,QAAQ,CAACvB,MAAM,EAAE;QAClB5H,iBAAiB,CAACmJ,QAAQ,CAAC;MAC/B;IACJ,CAAC,CAAC;EACV;EAGA,OAAOA,QAAQ;AACnB","ignoreList":[]} \ 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 6c03150de2a..35700017b64 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.11.1'; +export var RXDB_VERSION = '15.12.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 0b1e82139b2..d82c8c70a40 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.11.1';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,IAAMA,YAAY,GAAG,SAAS","ignoreList":[]} \ 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.12.0';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,IAAMA,YAAY,GAAG,SAAS","ignoreList":[]} \ 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 d217294742b..bcfad38da08 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.11.1"; + readonly rxdbVersion = "15.12.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 6983dcd3890..5fd2354c023 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.11.1"; + readonly rxdbVersion = "15.12.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 ea50d28469d..8cd21e84b5a 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.11.1"; + readonly rxdbVersion = "15.12.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 8cb2130a626..1693b26da61 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.11.1"; + readonly rxdbVersion = "15.12.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 ef650f27b1c..f8362d7fd1c 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.11.1"; + readonly rxdbVersion = "15.12.0"; private seed; private lastRequestId; messageChannelIfOneMode?: Promise; diff --git a/dist/types/plugins/utils/utils-rxdb-version.d.ts b/dist/types/plugins/utils/utils-rxdb-version.d.ts index cb715f0a12f..4ff5eea0c72 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.11.1"; +export declare const RXDB_VERSION = "15.12.0"; diff --git a/dist/types/rx-database.d.ts b/dist/types/rx-database.d.ts index 1200c989686..1531519c46a 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.11.1"; + readonly rxdbVersion = "15.12.0"; /** * Contains all known non-closed storage instances * that belong to this database. diff --git a/docs/404.html b/docs/404.html index c5373fd64c2..1fdbdabe19e 100644 --- a/docs/404.html +++ b/docs/404.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/adapters.html b/docs/adapters.html index 179f901aa54..08290bb9017 100644 --- a/docs/adapters.html +++ b/docs/adapters.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/alternatives.html b/docs/alternatives.html index 653ee37b6f8..31166c80d3f 100644 --- a/docs/alternatives.html +++ b/docs/alternatives.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/angular-database.html b/docs/articles/angular-database.html index 92055b30594..c7e4c7123f1 100644 --- a/docs/articles/angular-database.html +++ b/docs/articles/angular-database.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/browser-database.html b/docs/articles/browser-database.html index 0e804b54176..4032af821ff 100644 --- a/docs/articles/browser-database.html +++ b/docs/articles/browser-database.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/browser-storage.html b/docs/articles/browser-storage.html index 5763425b444..16e79068d88 100644 --- a/docs/articles/browser-storage.html +++ b/docs/articles/browser-storage.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/data-base.html b/docs/articles/data-base.html index 0d264fd1bd5..3e38d47435e 100644 --- a/docs/articles/data-base.html +++ b/docs/articles/data-base.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/embedded-database.html b/docs/articles/embedded-database.html index 5595e451cfa..a1e39763855 100644 --- a/docs/articles/embedded-database.html +++ b/docs/articles/embedded-database.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/flutter-database.html b/docs/articles/flutter-database.html index 9694d82295a..3968cad8fc8 100644 --- a/docs/articles/flutter-database.html +++ b/docs/articles/flutter-database.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/frontend-database.html b/docs/articles/frontend-database.html index cb0adc230ac..1f37bb3c639 100644 --- a/docs/articles/frontend-database.html +++ b/docs/articles/frontend-database.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/in-memory-nosql-database.html b/docs/articles/in-memory-nosql-database.html index 8e81d45202b..cd0b8d3e37d 100644 --- a/docs/articles/in-memory-nosql-database.html +++ b/docs/articles/in-memory-nosql-database.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/ionic-database.html b/docs/articles/ionic-database.html index 0ef55a303fd..5fe01eb31d7 100644 --- a/docs/articles/ionic-database.html +++ b/docs/articles/ionic-database.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/json-database.html b/docs/articles/json-database.html index 8eff02d8055..33b9bd68000 100644 --- a/docs/articles/json-database.html +++ b/docs/articles/json-database.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/localstorage.html b/docs/articles/localstorage.html index b295f0ae515..b402fea9a49 100644 --- a/docs/articles/localstorage.html +++ b/docs/articles/localstorage.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/mobile-database.html b/docs/articles/mobile-database.html index 2e141b03ffd..4fbbb9bea68 100644 --- a/docs/articles/mobile-database.html +++ b/docs/articles/mobile-database.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/progressive-web-app-database.html b/docs/articles/progressive-web-app-database.html index 2044e97a917..8730bde06e0 100644 --- a/docs/articles/progressive-web-app-database.html +++ b/docs/articles/progressive-web-app-database.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/react-database.html b/docs/articles/react-database.html index 91122861c15..e3ce0b971bd 100644 --- a/docs/articles/react-database.html +++ b/docs/articles/react-database.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/realtime-database.html b/docs/articles/realtime-database.html index 3d867da7e56..295db592b9f 100644 --- a/docs/articles/realtime-database.html +++ b/docs/articles/realtime-database.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/assets/js/0e268d20.68cfa9fc.js b/docs/assets/js/0e268d20.aead1a7b.js similarity index 99% rename from docs/assets/js/0e268d20.68cfa9fc.js rename to docs/assets/js/0e268d20.aead1a7b.js index 675cac7c461..83eef96eab1 100644 --- a/docs/assets/js/0e268d20.68cfa9fc.js +++ b/docs/assets/js/0e268d20.aead1a7b.js @@ -1 +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.11.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:[],createRxState:[],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.states={},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.addState=function(e){throw yt("state")},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:"Republic of Korea",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.name>=t.name?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 +"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.12.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:[],createRxState:[],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.states={},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.addState=function(e){throw yt("state")},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:"Republic of Korea",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.name>=t.name?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/1df93b7f.34032eb5.js b/docs/assets/js/1df93b7f.8468c8f6.js similarity index 99% rename from docs/assets/js/1df93b7f.34032eb5.js rename to docs/assets/js/1df93b7f.8468c8f6.js index b48627b131e..c00d17b53f5 100644 --- a/docs/assets/js/1df93b7f.34032eb5.js +++ b/docs/assets/js/1df93b7f.8468c8f6.js @@ -1 +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 h=e=>{var t=typeof e;return null!==e&&("object"===t||"function"===t)},d=new Set(["__proto__","prototype","constructor"]),u=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(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+=s;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&&!u.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(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 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 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,j.A)(Error)),N=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,j.A)(TypeError));function D(e,t){return new _(e,w.tunnelErrorMessage(e),t)}function R(e,t){return new N(e,w.tunnelErrorMessage(e),t)}function I(e){return!(!e||409!==e.status)&&e}var E={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var C=/\./g,S="abcdefghijklmnopqrstuvwxyz";function O(e){void 0===e&&(e=10);for(var t="",r=0;r{var r=v(t,e);if(void 0===r)throw D("DOC18",{args:{field:e,documentData:t}});return r})).join(r.separator)}function W(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=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=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 F={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),he=String.fromCharCode(65535),de=Number.MIN_SAFE_INTEGER;function ue(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,h=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?de:he,endKey:a?he:de,inclusiveStart:!0,inclusiveEnd:!0};return void 0===s.startKey&&(s.startKey=de),void 0===s.endKey&&(s.endKey=he),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})),d=h.map((e=>e.startKey)),u=h.map((e=>e.endKey)),m={index:e,startKeys:d,endKeys:u,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!s.has(e))).join(","),selectorSatisfiedByIndex:ve(e,t.selector,d,u)},p=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},s=10,i=(0,y.Sd)(r.startKeys,(e=>e!==de&&e!==he));n(i*s);var o=(0,y.Sd)(r.startKeys,(e=>e!==he&&e!==de));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 D("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 h=l[0];if(h&&i.add(o),"$eq"!==h){if(s.length>0)return!1;s.push(h)}}var d=[],u=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&&u.add(m),"$eq"!==v){if(d.length>0)return!1;d.push(v)}}var g=0;for(var y of e){for(var b of[i,u]){if(!b.has(y)&&b.size>0)return!1;b.delete(y)}if(r[g]!==a[g]&&i.size>0&&u.size>0)return!1;g++}return!0}var ge=r(744),ye=r(2779),be=r(1692),xe=r(4903),je=r(7705),we=r(2403),ke=r(6776),_e=r(6950),Ne=r(6823),De=!1;function Re(e){return De||((0,ye.DZ)(ye.hu.PIPELINE,{$sort:xe.xF,$project:xe.C2}),(0,ye.DZ)(ye.hu.QUERY,{$and:je.a6,$eq:we.XV,$elemMatch:_e.Jy,$exists:Ne.P,$gt:we.MR,$gte:we.fy,$in:we.oZ,$lt:we.NV,$lte:we.Q_,$ne:we.C5,$nin:we.GU,$mod:ke.Pp,$nor:je.q3,$not:je.En,$or:je.sU,$regex:ke.WP,$size:_e.Ig,$type:Ne.T}),De=!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 Ee(e,t){if(!t.sort)throw D("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 Se(e){return e===de?-1/0:e}function Oe(e,t,r){return e.includes(t)?r===he||!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 Oe(e,n,r)})).map(Se),n=t.endKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Se);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,h=[];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)||h.push(n),i.sortSatisfiedByIndex&&h.length===s?e():a.continue()}else e()}}))})),!i.sortSatisfiedByIndex){var d=Ee(e.schema,t.query);h=h.sort(d)}return{documents:h=h.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 We(e,t,r){var a=t.documentData,n=t.previousDocumentData;return{documentId:t.documentId,collectionName:r?r.name:void 0,isLocal:e,operation:t.operation,documentData:w.deepFreezeWhenDevMode(a),previousDocumentData:w.deepFreezeWhenDevMode(n)}}function Fe(e,t,r,a){if(a)throw 409===a.status?D("CONFLICT",{collection:e.name,id:t,writeError:a,data:r}):422===a.status?D("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){w.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),w.isDevMode()){s=M(a,r,s);try{"function"==typeof structuredClone?structuredClone(n):JSON.parse(JSON.stringify(n))}catch(o){throw D("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 D("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 h=r.close.bind(r);r.close=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",i),a||await Ve(t.databaseInstanceToken,r),h()};var d=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",i),a||await Ve(t.databaseInstanceToken,r),d()}}}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 D("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=[],h=[],d=[],u={id:O(10),events:[],checkpoint:null,context:n,startTime:(0,ce.t)(),endTime:0},m=u.events,p=[],f=[],v=[],g=r.size>0,y=a.length,b=function(){var e,n=a[x],u=n.document,y=n.previous,b=u[t],j=u._deleted,w=y&&y._deleted,k=void 0;if(g&&(k=r.get(b)),k){var _=k._rev;if(!y||y&&_!==y._rev){var N={isError:!0,status:409,documentId:b,writeRow:n,documentInDb:k};return d.push(N),1}var R=c?Qe(n):n;c&&(j?y&&Object.keys(y._attachments).forEach((e=>{f.push({documentId:b,attachmentId:e,digest:(0,le.ZN)(y)._attachments[e].digest})})):(Object.entries(u._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(u._attachments).forEach((e=>{let[t,r]=e;var a=y?y._attachments[t]:void 0;if(a){var n=R.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?d.push(e):(c?(h.push(Qe(R)),i&&i(u)):(h.push(R),i&&i(u)),o=R);var I=null,E=null,C=null;if(w&&!j)C="INSERT",I=c?He(u):u;else if(!y||w||j){if(!j)throw D("SNH",{args:{writeRow:n}});C="DELETE",I=(0,le.ZN)(u),E=y}else C="UPDATE",I=c?He(u):u,E=y;var S={documentId:b,documentData:I,previousDocumentData:E,operation:C};m.push(S)}else{var O=!!j;if(c&&Object.entries(u._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(Qe(n)),s&&s(u)):(l.push(n),s&&s(u)),o=n),!O){var P={documentId:b,operation:"INSERT",documentData:c?He(u):u,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.11.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 D("UT5",{args:{params:e}});if((t=e.schema).encrypted&&t.encrypted.length>0||t.attachments&&t.attachments.encrypted)throw D("UT6",{args:{params:e}});var t;if(e.schema.attachments&&e.schema.attachments.compression)throw D("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:[],createRxState:[],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 D("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=W(e);a=function(e){return o(e,!0)}(a),w.deepFreezeWhenDevMode(a);var n=new ct(a,t);return it("createRxSchema",n),n}var ht=r(7708),dt=r(8146),ut=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 h of a)try{l=await h.modifier(c(l))}catch(d){h.reject(d),h.reject=()=>{},h.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,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=D("COL20",{name:E[(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,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,dt.p)((e=>!e.isLocal)),(0,dt.p)((e=>e.documentId===this.primary)),(0,ht.T)((e=>gt(e))),(0,ut.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,pt.t)(le.bz))},get $$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},get$(e){if(w.isDevMode()){if(e.includes(".item."))throw D("DOC1",{path:e});if(e===this.primaryPath)throw D("DOC2");if(this.collection.schema.finalFields.includes(e))throw D("DOC3",{path:e});if(!A(this.collection.schema.jsonSchema,e))throw D("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=A(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.$A;if(!t)throw D("DOC5",{path:e});if(!t.ref)throw D("DOC6",{path:e,schemaObj:t});var a=this.collection.database.collections[t.ref];if(!a)throw D("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 w.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 w.deepFreezeWhenDevMode(this._data);var t=i(this._data);return delete t._rev,delete t._attachments,delete t._deleted,delete t._meta,w.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 D("DOC11",{id:this.primary,document:this});await wt(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(D("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 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 D("DOC14")}};function jt(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 wt(e,t,r){return t._meta=Object.assign({},r._meta,t._meta),w.isDevMode()&&e.schema.validateChange(r,t),e._runHooks("pre","save",t,r)}var kt=r(2198),_t=r(511),Nt=r(4157),Dt=r(2442),Rt=r(6114);function It(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 s(Et,e,(()=>{var t=e.collection,r=Ie(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=Ee(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:w.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,Rt.kC)(t);return"runFullQueryAgain"===s||("doNothing"!==s?(i=!0,(0,Rt.Cs)(s,r,e,a,n),!1):void 0)}))?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:i,newResults:a}}var St=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 Ot(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=>Ot(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=w.deepFreezeWhenDevMode,i=e.documentCreator,o=o=>{var c=o[t],l=Be(o._rev),h=s(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),d=h.byRev,u=d.get(l),m=u?u.deref():void 0;return m||(o=n(o),m=i(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 Wt=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 Wt(this.collection,e,e.length);this._result=t}else this._result=new Wt(this.collection,[],e)},t._execOverDatabase=async function(){if(this._execOverDatabaseCount=this._execOverDatabaseCount+1,this._lastExecStart=(0,ce.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 D("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 D("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Zt(this).then((()=>(0,_t._)(this.$))).then((t=>{if(!t&&e)throw D("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,dt.p)((e=>!e.isLocal)),(0,ut.Z)(null),(0,Dt.Z)((()=>Zt(this))),(0,ht.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,ht.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,Nt.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,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:w.isDevMode()});await i.remove(),t.isCollection&&await ot("postRemoveRxCollection",{storage:e,databaseName:a,collectionName:n})}))),i){var h=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(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,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 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,(()=>jt(ir(e))))}(e),e,w.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"],hr=["insert","save","remove","create"],dr=!1,ur=function(){function e(e,t,r,a,n,s,i,o,c,l,h,d){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===h&&(h={}),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 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=s,this.methods=i,this.attachments=o,this.options=c,this.cacheReplacementPolicy=l,this.statics=h,this.conflictHandler=d,function(e){if(dr)return;dr=!0;var t=Object.getPrototypeOf(e);hr.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)=>wt(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,Dt.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,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=>We(!1,e,this))),databaseToken:this.database.token,checkpoint:e.checkpoint,context:e.context,endTime:e.endTime,startTime:e.startTime};this.database.$emit(t)}));return this._subs.push(a),this._subs.push(this.storageInstance.conflictResultionTasks().subscribe((e=>{this.conflictHandler(e.input,e.context).then((t=>{this.storageInstance.resolveConflictResultionTask({id:e.id,output:t})}))}))),ft.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,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 D("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 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 D("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 D("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 D("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 R("COL7",{key:t,when:e});if(!lr.includes(e))throw R("COL8",{key:t,when:e});if(!hr.includes(t))throw D("COL9",{key:t});if("post"===e&&"create"===t&&!0===a)throw D("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,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))},vr=r(5525),gr=new Set,yr=function(){function e(e,t,r,a,n,s,i,o,c,l,h,d,u){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.states={},this.eventBulks$=new oe.B,this.observable$=this.eventBulks$.pipe((0,Dt.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=h,this.allowSlowCount=d,this.reactivity=u,"pseudoInstance"!==this.name&&(this.internalStore=Ze(this.asRxDatabase,c,Vt),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: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 D("DM5",{args:{database:e.name,databaseStateVersion:i.documentInDb.data.rxdbVersion,codeVersion:e.rxdbVersion}});if(r&&r!==i.documentInDb.data.passwordHash)throw D("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 D("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 D("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 h=lt(l,this.hashFunction);if(r[c]=h,this.collections[s])throw D("DB3",{name:s});var d=tr(s,l),u={id:Gt(d,Ut),key:d,context:Ut,data:{name:c,schemaHash:await h.hash,schema:h.jsonSchema,version:h.version,connectedStorages:[]},_deleted:!1,_meta:B(),_rev:"",_attachments:{}};a.push({document:u});var m=Object.assign({},o,{name:c,schema:h,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 D("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 D("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:h={},localDocuments:d=!1,cacheReplacementPolicy:u=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:w.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 ur(t,r,a,e,n,s,c,l,h,u,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:h,cacheReplacementPolicy:u,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 vt("json-dump")},t.addState=function(e){throw vt("state")},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=O(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:w.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:h=!1,localDocuments:d=!1,hashFunction:u=fr,reactivity:m}=e;it("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:s,eventReduce:i,ignoreDuplicate:o,options:c,localDocuments:d}),o||function(e,t){var r=t.name+"|"+e;if(gr.has(r))throw D("DB8",{name:e,storage:t.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}(a,t),gr.add(t.name+"|"+a);var p=O(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,u,l,h,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:s,eventReduce:i,ignoreDuplicate:o,options:c,localDocuments:d}}).then((()=>f))}))}var jr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Qt.prototype,RxCollection:ur.prototype,RxDatabase:yr.prototype},wr=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}(jt()),Nr={get isLocal(){return!0},get allAttachments$(){throw D("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,ht.T)((e=>gt(e))),(0,ut.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ht.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 R("LD2",{objPath:e});var t=v(this._data,e);return t=w.deepFreezeWhenDevMode(t)}},get$(e){if(e="data."+e,w.isDevMode()){if(e.includes(".item."))throw D("LD3",{objPath:e});if(e===this.primaryPath)throw D("LD4")}return this.$.pipe((0,ht.T)((e=>e._data)),(0,ht.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 Or(this.parent);return t.incrementalWriteQueue.addWrite(this._data,(async t=>(t.data=await e(t.data,this),t))).then((e=>t.docCache.getCachedRxDocument(e)))},incrementalPatch(e){return this.incrementalModify((t=>(Object.entries(e).forEach((e=>{let[r,a]=e;t[r]=a})),t)))},async _saveData(e){var t=await Or(this.parent),r=this._data;return e.id=this.id,t.storageInstance.bulkWrite([{previous:r,document:e}],"local-document-save-data").then((t=>{var r=t.success[0];if(!r)throw t.error[0];(e=i(e))._rev=r._rev}))},async remove(){var e=await Or(this.parent),t={id:this._data.id,data:{},_deleted:!0,_meta:B(),_rev:"",_attachments:{}};return Le(e.storageInstance,{previous:this._data,document:t},"local-document-remove").then((t=>e.docCache.getCachedRxDocument(t)))}},Dr=!1,Rr=()=>{if(!Dr){Dr=!0;var e=xt;Object.getOwnPropertyNames(e).forEach((t=>{if(!Object.getOwnPropertyDescriptor(Nr,t)){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(Nr,t,r)}}));["populate","update","putAttachment","getAttachment","allAttachments"].forEach((e=>Nr[e]=(e=>()=>{throw D("LD6",{functionName:e})})(e)))}};function Ir(e){var t=e.parent;return t instanceof yr?t:t.database}var Er=new WeakMap,Cr=new WeakMap;function Sr(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,dt.p)((e=>e.isLocal))),(t=>function(e,t){Rr();var r=new _r(e.id,e,t);return Object.setPrototypeOf(r,Nr),r.prototype=Nr,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=>We(!0,t,e.database?e:void 0))),databaseToken:t.token,checkpoint:r.checkpoint,context:r.context,endTime:r.endTime,startTime:r.startTime};t.$emit(a)}));e._subs.push(o);var c={database:t,parent:e,storageInstance:a,docCache:n,incrementalWriteQueue:s};return Cr.set(e,c),c})();Er.set(e,a)}function Or(e){var t=Er.get(e);if(!t){var r=e.database?e.database:e,a=e.database?e.name:"";throw D("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:w.isDevMode()})}function $r(e){var t=Er.get(e);if(t)return Er.delete(e),t.then((e=>e.storageInstance.close()))}async function Tr(e,t,r){var a=O(10),n=await Pr(a,e,t,r,{},!1);await n.remove()}function Br(e){return"plugin-local-documents-"+e}var Ar=W({title:"RxLocalDocument",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:128},data:{type:"object",additionalProperties:!0}},required:["id","data"]});async function Mr(e,t){var r=await 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 Wr(e){return this.$.pipe((0,ut.Z)(null),(0,Dt.Z)((async t=>t?{changeEvent:t}:{doc:await this.getLocal(e)})),(0,Dt.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,ht.T)((e=>e.doc)))}var Fr={name:"local-documents",rxdb:!0,prototypes:{RxCollection:e=>{e.insertLocal=Mr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Wr},RxDatabase:e=>{e.insertLocal=Mr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Wr}},hooks:{createRxDatabase:{before:e=>{e.creator.localDocuments&&Sr(e.database)}},createRxCollection:{before:e=>{e.creator.localDocuments&&Sr(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:wr}),!wr.has(e)){if(kr.has(e.name))throw D("PL3",{name:e.name,plugin:e});if(wr.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(jr[t])})),e.overwritable&&Object.assign(w,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)}))}}(Fr);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})},6866:(e,t,r)=>{r.r(t),r.d(t,{default:()=>x});var a=r(4586),n=r(1595),s=r(5260),i=r(4157),o=r(943),c=r(7708),l=r(5520),h=r(3337),d=r(1753),u=r(5734),m=r(2658),p=r(6540),f=r(1527),v=r(4589),g=r(4848);let y=!1;async function b(){if(y)return;y=!0,console.log("start animation");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return void console.log("reducedMotion is set to true");if(!(0,m.IA)())return;const e=await(0,m.C3)();try{await e.insertLocal("beatingvalues",{beatPeriod:0,text1:"JavaScript",text2:"you deserve",color:m.Tj[0]})}catch(N){}const t=(0,h.ZN)(await e.getLocal("beatingvalues"));(async()=>{for(await(0,d.ND)(k);y;){const e=_(),r=(0,d.ND)(e.timeToNextPeriod);if(e.period%2==0)try{await t.incrementalModify((t=>(t.beatPeriod>=e.period||(t.beatPeriod=e.period,t.color=m.Tj[e.period%3],e.period%4==0?t.text1=E(j,e.period)[0]:t.text2=E(w,e.period)[0]),t)))}catch(N){}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)((0,o.R)(window,"mousemove"),(0,o.R)(window,"scroll"),(0,o.R)(window,"resize")).subscribe((()=>{r.incrementalPatch({x:a[0],y:a[1],time:(0,u.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(${R(s)}deg) rotateY(${R(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(!S(t))return;n(t,(0,h.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,c.T)((e=>e._data))).subscribe((e=>{e.data.time&&e.data.x&&e.data.y&&Array.from(t).forEach((t=>{if(!S(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"),p=document.getElementsByClassName("beating-second"),f=document.getElementsByClassName("beating-number"),v=document.getElementsByClassName("beating-color"),g=document.getElementsByClassName("beating-color-string"),b=[];let x=0;_(),t.$.pipe((0,c.T)((e=>e._data.data)),(0,l.F)(((e,t)=>JSON.stringify(e)===JSON.stringify(t)))).subscribe((e=>{b.forEach((function(e){e(x)})),x+=1;const t=e.color;Array.from(v).forEach((function(e){e.style.backgroundColor=t})),Array.from(g).forEach((function(e){e.innerHTML=t}))})),b.push((function(){Array.from(n).forEach((function(e){e.style.animationDuration=k+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")})),Array.from(s).forEach((function(e){e.style.animationDuration=k+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")})),Array.from(p).forEach((function(e){e.style.animationDuration=k+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")}))})),b.push((function(){Array.from(f).forEach((function(e){I()&&I()&&setTimeout((function(){const t=parseFloat(e.innerHTML)+1;e.innerHTML=t+""}),105)}))}))}function x(){const{siteConfig:e}=(0,a.A)();(0,p.useEffect)((()=>(b(),()=>{console.log("stop animation"),y=!1})));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(s.A,{children:(0,g.jsx)("body",{className:"homepage"})}),(0,g.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,g.jsxs)("main",{children:[(0,g.jsx)("div",{className:"block first centered dark",children:(0,g.jsxs)("div",{className:"content",children:[(0,g.jsxs)("h1",{children:["The local ",(0,g.jsx)("b",{className:"underline",children:"Database"})," for"," ",(0,g.jsx)("b",{className:"underline",children:"JavaScript"})," Applications"]}),(0,g.jsxs)("div",{className:"inner",children:[(0,g.jsxs)("div",{className:"half left",children:[(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsxs)("ul",{className:"checked",children:[(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"Realtime Queries"}),": From results of queries to single document fields, with RxDB you can observe everything which makes building ",(0,g.jsx)("u",{children:"realtime applications"})," effortless."]}),(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"Realtime Replication"}),": Run a two-way realtime replication with one of the many replication plugins. Also making your ",(0,g.jsx)("u",{children:"custom backend compatible"})," is pretty simple."]}),(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"Offline Support"}),": Store data locally on your clients device to build applications that still work when there is ",(0,g.jsx)("u",{children:"no internet access"}),". Running queries locally also improves your user experience."]}),(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"Supports all JavaScript runtimes"}),": With the flexible RxDB storage layer you can run the same code in ",(0,g.jsx)("u",{children:"Browsers"}),", ",(0,g.jsx)("u",{children:"Node.js"}),", ",(0,g.jsx)("u",{children:"Electron"}),","," ",(0,g.jsx)("u",{children:"React-Native"}),", ",(0,g.jsx)("u",{children:"Capacitor"}),", ",(0,g.jsx)("u",{children:"Bun"})," and ",(0,g.jsx)("u",{children:"Deno"}),"."]}),(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"Great Performance"}),": Years of performance optimization made RxDB one of the ",(0,g.jsx)("u",{children:"fastest"})," ways to store and query data inside of JavaScript."]})]}),(0,g.jsx)("a",{className:"button",href:"/quickstart.html",target:"_blank",onClick:()=>(0,f.h)("start_now",.4),children:"Quickstart \xbb"}),(0,g.jsxs)("a",{className:"button light",href:"/code",target:"_blank",children:[(0,g.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,g.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,g.jsx)("div",{className:"clear"})]}),(0,g.jsx)("div",{className:"half right",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,g.jsxs)("div",{className:"content-canvas",style:{marginTop:0,marginBottom:30,marginLeft:20},children:[(0,g.jsx)("div",{className:"device tablet",style:{marginLeft:481,marginTop:117},children:(0,g.jsx)("div",{className:"beating-color",style:{backgroundColor:"rgb(141, 32, 137)"},children:(0,g.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo animation",alt:"RxDB",style:{animationDuration:"851ms"}})})}),(0,g.jsx)("div",{className:"device desktop",style:{marginTop:"0%"},children:(0,g.jsx)("div",{className:"beating-color",style:{backgroundColor:"rgb(141, 32, 137)"},children:(0,g.jsx)("img",{src:"/files/logo/logo_text.svg",className:"beating logo animation",alt:"RxDB",style:{animationDuration:"851ms",width:"52%"}})})}),(0,g.jsxs)("div",{className:"device server",style:{marginLeft:0,marginTop:168},children:[(0,g.jsx)("div",{className:"beating-color one",style:{backgroundColor:"rgb(141, 32, 137)"}}),(0,g.jsx)("div",{className:"beating-color two",style:{backgroundColor:"rgb(141, 32, 137)"}}),(0,g.jsx)("div",{className:"beating-color three",style:{backgroundColor:"rgb(141, 32, 137)"}})]})]})})]})]})}),(0,g.jsx)("a",{href:"/chat",target:"_blank",children:(0,g.jsxs)("div",{className:"trophy discord",children:[(0,g.jsx)("img",{src:"./files/icons/discord.svg",alt:"RxDB Discord chat"}),(0,g.jsxs)("div",{style:{flex:1},children:[(0,g.jsx)("div",{className:"subtitle",children:"Chat on"}),(0,g.jsx)("div",{className:"title",children:"Discord"})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"valuetitle",children:"members"}),(0,g.jsxs)("div",{className:"value",children:["747",(0,g.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,g.jsxs)("div",{className:"block reviews",children:[(0,g.jsx)("div",{className:"content centered",children:(0,g.jsxs)("div",{className:"inner",children:[(0,g.jsxs)("h2",{children:["Our ",(0,g.jsx)("b",{className:"underline",children:"Success Stories"})]}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{})]})}),(0,g.jsxs)(v.A,{dots:!0,centerMode:!0,centerPadding:"10px",infinite:!0,arrows:!1,adaptiveHeight:!0,speed:500,slidesToShow:4,slidesToScroll:1,initialSlide:0,responsive:[{breakpoint:1250,settings:{slidesToShow:3,slidesToScroll:1,infinite:!0,dots:!0}},{breakpoint:1024,settings:{slidesToShow:3,slidesToScroll:1,infinite:!0,dots:!0}},{breakpoint:900,settings:{slidesToShow:2,slidesToScroll:1,infinite:!0,dots:!0}},{breakpoint:600,settings:{slidesToShow:2,slidesToScroll:1,infinite:!0,dots:!0}},{breakpoint:480,settings:{slidesToShow:1.1,centerPadding:"15px",slidesToScroll:1,infinite:!1,dots:!1}}],children:[(0,g.jsxs)("div",{className:"slider-content",children:[(0,g.jsx)("h3",{children:'"We use RxDB to create applications capable of being used in the most remote areas where Internet access is really a challenge."'}),(0,g.jsxs)("div",{className:"slider-profile",children:[(0,g.jsx)("img",{className:"slider-logo-white",src:"https://altgras.com/assets/img/logo.png"}),(0,g.jsxs)("div",{className:"slider-info",children:[(0,g.jsx)("p",{className:"developer",children:"ALTGRAS"}),(0,g.jsx)("a",{href:"https://altgras.com/",target:"_blank",className:"company-link",children:"https://altgras.com/"})]})]})]}),(0,g.jsxs)("div",{className:"slider-content",children:[(0,g.jsx)("h3",{children:'"We provide a mobile app that is used by people in the field to fill in valuable information like inspections, surveys and audits"'}),(0,g.jsxs)("div",{className:"slider-profile",children:[(0,g.jsx)("img",{className:"slider-logo-black",src:"https://moreapp.com/assets/img/logo.png"}),(0,g.jsxs)("div",{className:"slider-info",children:[(0,g.jsx)("p",{className:"developer",children:"MoreApp"}),(0,g.jsx)("a",{href:"https://moreapp.com/",target:"_blank",className:"company-link",children:"https://moreapp.com/"})]})]})]}),(0,g.jsxs)("div",{className:"slider-content",children:[(0,g.jsx)("h3",{children:'"We use RxDB to provide an offline first, cross platform point of sale system"'}),(0,g.jsxs)("div",{className:"slider-profile",children:[(0,g.jsx)("img",{className:"slider-logo-black",src:"https://wcpos.com/wp-content/uploads/2014/06/woopos-logo.png"}),(0,g.jsxs)("div",{className:"slider-info",children:[(0,g.jsx)("p",{className:"developer",children:"WooCommerce POS"}),(0,g.jsx)("a",{href:"https://wcpos.com/",target:"_blank",className:"company-link",children:"https://wcpos.com/"})]})]})]}),(0,g.jsxs)("div",{className:"slider-content",children:[(0,g.jsx)("h3",{children:'"RxDB is a main component in building offline-ready multichannel apps. It has become our default stack for this kind of apps."'}),(0,g.jsxs)("div",{className:"slider-profile",children:[(0,g.jsx)("img",{className:"slider-logo-black",src:"https://atroo.de/wp-content/uploads/2018/10/atroo-small-300x117.png"}),(0,g.jsxs)("div",{className:"slider-info",children:[(0,g.jsx)("p",{className:"developer",children:"atroo GmbH"}),(0,g.jsx)("a",{href:"https://atroo.de/",target:"_blank",className:"company-link",children:"https://atroo.de/"})]})]})]})]})]}),(0,g.jsx)("div",{className:"block second dark",children:(0,g.jsxs)("div",{className:"content",children:[(0,g.jsxs)("h2",{children:["Realtime applications ",(0,g.jsx)("b",{className:"underline",children:"made easy"})]}),(0,g.jsxs)("p",{children:["From the results of a query, to a single field of a document, with RxDB you can ",(0,g.jsx)("b",{children:"observe everything"}),". This enables you to build realtime applications ",(0,g.jsx)("b",{children:"fast"})," and ",(0,g.jsx)("b",{children:"reliable"}),". It does not matter if the data was changed by"," ",(0,g.jsx)("b",{children:"a user event"}),", ",(0,g.jsx)("b",{children:"another browser tab"})," or by the",(0,g.jsx)("b",{children:" replication"}),"."," ","Whenever your data changes, your UI reflects the new state. You can either use ",(0,g.jsx)("b",{children:"RxJS"})," or add ",(0,g.jsx)("a",{href:"/reactivity.html",target:"_blank",children:"custom reactiveness libraries"})," like signals or other state management."]}),(0,g.jsxs)("div",{className:"inner",children:[(0,g.jsxs)("div",{className:"code half",children:[(0,g.jsxs)("fieldset",{className:"samp-wrapper",style:{backgroundColor:"var(--bg-color)"},children:[(0,g.jsx)("legend",{children:"Write"}),(0,g.jsxs)("samp",{children:[(0,g.jsx)("span",{className:"cm-keyword",children:"await "}),(0,g.jsx)("span",{className:"cm-variable",children:"collection"}),".",(0,g.jsx)("span",{className:"cm-method",children:"upsert"}),"(","{",(0,g.jsx)("br",{}),(0,g.jsx)("span",{className:"cm-property",children:"\xa0 id"}),": ",(0,g.jsx)("span",{className:"cm-string",children:"'foobar'"}),",",(0,g.jsx)("br",{}),(0,g.jsx)("span",{className:"cm-property",children:"\xa0 color"}),": ",(0,g.jsxs)("span",{className:"cm-string",children:["'",(0,g.jsx)("span",{className:"beating-color-string beating-color",children:"#e6008d"}),"'"]}),(0,g.jsx)("br",{}),"}",");"]})]}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsxs)("fieldset",{className:"samp-wrapper",style:{backgroundColor:"var(--bg-color)"},children:[(0,g.jsx)("legend",{children:"Observe"}),(0,g.jsxs)("samp",{style:{backgroundColor:"var(--bg-color)"},children:[(0,g.jsx)("span",{className:"cm-keyword",children:"await "}),(0,g.jsx)("span",{className:"cm-variable",children:"collection"}),".",(0,g.jsxs)("span",{className:"cm-method",children:["findOne(",(0,g.jsx)("span",{className:"cm-string",children:"'foobar'"}),")"]}),(0,g.jsx)("br",{}),"\xa0.",(0,g.jsx)("span",{className:"cm-property",children:"$"}),(0,g.jsx)("span",{className:"cm-comment",children:" // get observable"}),(0,g.jsx)("br",{}),"\xa0.",(0,g.jsx)("span",{className:"cm-method",children:"subscribe"}),"(",(0,g.jsx)("span",{className:"cm-def",children:"d"}),(0,g.jsx)("span",{className:"cm-operator",children:" =>"})," ","{",(0,g.jsx)("br",{}),(0,g.jsx)("span",{className:"cm-variable",children:"\xa0\xa0 screen"}),".",(0,g.jsx)("span",{className:"cm-property",children:"backgroundColor"}),(0,g.jsx)("span",{className:"cm-operator",children:" = "}),(0,g.jsx)("span",{className:"cm-variable",children:"d"}),".",(0,g.jsx)("span",{className:"cm-property beating-color",children:"color"}),";",(0,g.jsx)("br",{}),"\xa0","}",");"]})]})]}),(0,g.jsx)("div",{className:"canvas half",children:(0,g.jsxs)("div",{className:"content-canvas",children:[(0,g.jsx)("div",{className:"device tablet",style:{marginLeft:481,marginTop:117},children:(0,g.jsx)("div",{className:"beating-color",children:(0,g.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo",alt:"RxDB"})})}),(0,g.jsx)("div",{className:"device desktop",style:{marginTop:"0%"},children:(0,g.jsx)("div",{className:"beating-color",children:(0,g.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo",alt:"RxDB"})})}),(0,g.jsxs)("div",{className:"device server",style:{marginLeft:0,marginTop:168},children:[(0,g.jsx)("div",{className:"beating-color one"}),(0,g.jsx)("div",{className:"beating-color two"}),(0,g.jsx)("div",{className:"beating-color three"})]})]})})]})]})}),(0,g.jsx)("a",{href:"https://twitter.com/intent/user?screen_name=rxdbjs",onClick:()=>(0,f.h)("twitter_trophy_click",.2),target:"_blank",children:(0,g.jsxs)("div",{className:"trophy twitter",children:[(0,g.jsx)("img",{src:"./files/icons/twitter-blue.svg",alt:"RxDB Twitter"}),(0,g.jsxs)("div",{style:{flex:1},children:[(0,g.jsx)("div",{className:"subtitle",children:"Follow on"}),(0,g.jsx)("div",{className:"title",children:"Twitter"})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"valuetitle",children:"followers"}),(0,g.jsxs)("div",{className:"value",children:["2843",(0,g.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,g.jsx)("div",{className:"block replication",children:(0,g.jsxs)("div",{className:"content",children:[(0,g.jsxs)("div",{className:"half left",children:[(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsxs)("h2",{children:["Replicate ",(0,g.jsx)("b",{children:"with your existing infrastructure"})]}),(0,g.jsxs)("p",{children:["RxDB supports replication with a"," ",(0,g.jsx)("a",{href:"/replication-couchdb.html",target:"_blank",children:"CouchDB"})," ","server or any custom"," ",(0,g.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,g.jsx)("a",{href:"/replication-http.html",target:"_blank",children:"HTTP"}),","," ",(0,g.jsx)("a",{href:"/replication-websocket.html",target:"_blank",children:"Websocket"}),","," ",(0,g.jsx)("a",{href:"/replication-webrtc.html",target:"_blank",children:"WebRTC"})," ","or"," ",(0,g.jsx)("a",{href:"/replication-firestore.html",target:"_blank",children:"Firestore"}),"."]})]}),(0,g.jsx)("div",{className:"half right",children:(0,g.jsxs)("div",{className:"replication-icons",children:[(0,g.jsx)("img",{src:"./files/logo/logo.svg",alt:"RxDB",className:"replicate-logo tilt-to-mouse"}),(0,g.jsx)("a",{href:"/replication-graphql.html",target:"_blank",children:(0,g.jsx)("div",{className:"neumorphism-circle-xl centered replicate-graphql enlarge-on-mouse",children:(0,g.jsx)("img",{src:"./files/icons/graphql-text.svg",alt:"GraphQL",className:"protocol"})})}),(0,g.jsx)("a",{href:"/replication-couchdb.html",target:"_blank",children:(0,g.jsx)("div",{className:"neumorphism-circle-xl centered replicate-couchdb enlarge-on-mouse",children:(0,g.jsx)("img",{src:"./files/icons/couchdb-text.svg",alt:"CouchDB",className:"protocol"})})}),(0,g.jsx)("a",{href:"/replication-http.html",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-xs centered replicate-rest enlarge-on-mouse",children:["{"," HTTP ","}"]})}),(0,g.jsx)("a",{href:"/replication-websocket.html",target:"_blank",children:(0,g.jsx)("div",{className:"neumorphism-circle-xs centered replicate-websocket enlarge-on-mouse",children:"websocket"})}),(0,g.jsx)("a",{href:"/replication-webrtc.html",target:"_blank",children:(0,g.jsx)("div",{className:"neumorphism-circle-xs centered replicate-webrtc enlarge-on-mouse",children:"WebRTC"})})]})}),(0,g.jsx)("div",{className:"clear"})]})}),(0,g.jsx)("a",{href:"/code",target:"_blank",children:(0,g.jsxs)("div",{className:"trophy",children:[(0,g.jsx)("img",{src:"./files/icons/github-star-with-logo.svg",alt:"RxDB github star"}),(0,g.jsxs)("div",{style:{flex:1},children:[(0,g.jsx)("div",{className:"subtitle",children:"Open Source on"}),(0,g.jsx)("div",{className:"title",children:"GitHub"})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"valuetitle",children:"stars"}),(0,g.jsxs)("div",{className:"value",children:["20172",(0,g.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,g.jsxs)("div",{className:"block offline-first dark",children:[(0,g.jsx)("div",{className:"offline-image-wrapper",children:(0,g.jsx)("img",{src:"files/icons/wifi/wifi_1a202c.svg",className:"offline-image beating-second",alt:"offline"})}),(0,g.jsxs)("div",{className:"content",children:[(0,g.jsxs)("h2",{children:["Online ",(0,g.jsx)("b",{className:"underline",children:"is optional"})]}),(0,g.jsxs)("div",{className:"full-width",children:[(0,g.jsx)("div",{className:"half left",children:(0,g.jsxs)("p",{children:["RxDB follows the"," ",(0,g.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,g.jsx)("div",{className:"half right",children:(0,g.jsxs)("ul",{className:"checked",children:[(0,g.jsxs)("li",{children:["Your application still ",(0,g.jsx)("b",{children:"works offline"})]}),(0,g.jsxs)("li",{children:["Increases ",(0,g.jsx)("b",{children:"perceived performance"})]}),(0,g.jsxs)("li",{children:["Easier and ",(0,g.jsx)("b",{children:"faster implementation"})]}),(0,g.jsxs)("li",{children:["Needs less backend resources and ",(0,g.jsx)("b",{children:"scales better"})]})]})})]})]})]}),(0,g.jsx)("div",{className:"block frameworks",children:(0,g.jsxs)("div",{className:"content",children:[(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/angular",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"-10%",left:"10%"},children:[(0,g.jsx)("img",{src:"./files/icons/angular.svg",alt:"angular"}),"Angular"]})}),(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"10%",left:"58%"},children:[(0,g.jsx)("img",{src:"./files/icons/capacitor.svg",alt:"capacitor"}),"Capacitor"]}),(0,g.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"-4%",left:"44%"},children:[(0,g.jsx)("img",{src:"./files/icons/deno.svg",alt:"deno"}),"Deno"]}),(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/node",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"-5%",left:"85%"},children:[(0,g.jsx)("img",{src:"./files/icons/nodejs.svg",alt:"Node.js"}),"Node.js"]})}),(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/react",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"4%",left:"26%"},children:[(0,g.jsx)("img",{src:"./files/icons/react.svg",alt:"React"}),"React"]})}),(0,g.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"15%",left:"90%",marginLeft:"-35px"},children:[(0,g.jsx)("img",{src:"./files/icons/svelte.svg",alt:"Svelte"}),"Svelte"]}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsxs)("h2",{children:["Flexible ",(0,g.jsx)("b",{className:"underline",children:"storage layer"})]}),(0,g.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,g.jsx)("b",{children:"any JavaScript runtime"})," ","by just switching out the storage settings.",(0,g.jsx)("br",{})]}),(0,g.jsxs)("div",{className:"below-text",children:[(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/electron",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"2%",left:"18%"},children:[(0,g.jsx)("img",{src:"./files/icons/electron.svg",alt:"electron"}),"Electron"]})}),(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/vue",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"3%",left:"45%"},children:[(0,g.jsx)("img",{src:"./files/icons/vuejs.svg",alt:"Vue.js"}),"Vue.js"]})}),(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/ionic2",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"2%",left:"71%"},children:[(0,g.jsx)("img",{src:"./files/icons/ionic.svg",alt:"ionic"}),"Ionic"]})}),(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"46%",left:"11%"},children:[(0,g.jsx)("img",{src:"./files/icons/nativescript.svg",alt:"NativeScript"}),"NativeScript"]}),(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/react-native",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"45%",left:"35%"},children:[(0,g.jsx)("img",{src:"./files/icons/react.svg",alt:"React Native"}),"React Native"]})}),(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"45%",left:"62%"},children:[(0,g.jsx)("img",{src:"./files/icons/nextjs.svg",alt:"Next.js"}),"Next.js"]}),(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/flutter",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"40%",left:"86%"},children:[(0,g.jsx)("img",{src:"./files/icons/flutter.svg",alt:"Flutter"}),"Flutter"]})})]})]})}),(0,g.jsx)("div",{className:"block fifth dark",children:(0,g.jsx)("div",{className:"content centered",children:(0,g.jsxs)("div",{className:"inner",children:[(0,g.jsxs)("h2",{children:["Trusted and ",(0,g.jsx)("b",{className:"underline",children:"open source"})]}),(0,g.jsxs)("div",{className:"box dark",children:[(0,g.jsx)("img",{src:"files/icons/github-star.svg",alt:"github star"}),(0,g.jsx)("div",{className:"label",children:"Github Stars"}),(0,g.jsx)("a",{className:"value",href:"/code",rel:"noopener",target:"_blank",children:"20172"}),(0,g.jsx)("div",{className:"clear"})]}),(0,g.jsxs)("div",{className:"box dark",children:[(0,g.jsx)("img",{src:"files/icons/download.svg",alt:"npm downloads"}),(0,g.jsx)("div",{className:"label",children:"npm downloads"}),(0,g.jsx)("a",{className:"value beating-number",href:"https://www.npmjs.com/package/rxdb",rel:"noopener",target:"_blank",children:"238572"}),(0,g.jsx)("div",{className:"clear"})]}),(0,g.jsx)("div",{className:"clear"}),(0,g.jsxs)("div",{className:"box dark",children:[(0,g.jsx)("img",{src:"files/icons/person.svg",alt:"contributor"}),(0,g.jsx)("div",{className:"label",children:"Contributors"}),(0,g.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/graphs/contributors",rel:"noopener",target:"_blank",children:"211"}),(0,g.jsx)("div",{className:"clear"})]}),(0,g.jsxs)("div",{className:"box dark",children:[(0,g.jsx)("img",{src:"files/icons/commit.svg",alt:"commit"}),(0,g.jsx)("div",{className:"label",children:"Commits"}),(0,g.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/commits/master",rel:"noopener",target:"_blank",children:"10409"}),(0,g.jsx)("div",{className:"clear"})]}),(0,g.jsx)("div",{className:"clear"}),(0,g.jsxs)("div",{className:"box dark",children:[(0,g.jsx)("img",{src:"files/icons/gear.svg",alt:"gear"}),(0,g.jsx)("div",{className:"label",children:"RxDB made Projects"}),(0,g.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/network/dependents?package_id=UGFja2FnZS0xODM0NzAyMw%3D%3D",rel:"noopener",target:"_blank",children:"1402"}),(0,g.jsx)("div",{className:"clear"})]}),(0,g.jsxs)("div",{className:"box dark",children:[(0,g.jsx)("img",{src:"files/icons/twitter.svg",alt:"twitter"}),(0,g.jsx)("div",{className:"label",children:"Twitter followers"}),(0,g.jsx)("a",{className:"value",href:"https://twitter.com/intent/user?screen_name=rxdbjs",rel:"noopener",target:"_blank",children:"2925"}),(0,g.jsx)("div",{className:"clear"})]}),(0,g.jsx)("div",{className:"clear"})]})})}),(0,g.jsx)("div",{className:"block sixth",children:(0,g.jsxs)("div",{className:"content",children:[(0,g.jsx)("h2",{children:"Pricing Models"}),(0,g.jsx)("div",{className:"inner",children:(0,g.jsxs)("div",{className:"buy-options",children:[(0,g.jsx)("div",{className:"buy-option bg-gradient-left-top",children:(0,g.jsxs)("div",{className:"buy-option-inner",children:[(0,g.jsxs)("div",{className:"buy-option-title",children:[(0,g.jsx)("h2",{children:"RxDB Basics"}),(0,g.jsx)("div",{className:"price",children:"Free & Open Source"})]}),(0,g.jsx)("div",{className:"buy-option-features",children:(0,g.jsxs)("ul",{children:[(0,g.jsx)("li",{children:"Basic RxStorages"}),(0,g.jsx)("li",{children:"Realtime Replication"}),(0,g.jsx)("li",{children:"Live Queries"}),(0,g.jsx)("li",{children:"Schema Validation"}),(0,g.jsx)("li",{children:"Multi-Tab Support"}),(0,g.jsx)("li",{children:"Encryption"}),(0,g.jsx)("li",{children:"Compression"})]})}),(0,g.jsx)("a",{href:"/code",target:"_blank",rel:"noopener",onClick:()=>(0,f.h)("get_the_code_main_page",.8),children:(0,g.jsx)("div",{className:"buy-option-action bg-top hover-shadow-top",children:"Get the Code"})})]})}),(0,g.jsx)("div",{className:"buy-option bg-gradient-right-top",children:(0,g.jsxs)("div",{className:"buy-option-inner",children:[(0,g.jsxs)("div",{className:"buy-option-title",children:[(0,g.jsx)("h2",{children:"Premium Plugins"}),(0,g.jsx)("div",{className:"price",children:"for professionals to get the most out of RxDB"})]}),(0,g.jsx)("div",{className:"buy-option-features",children:(0,g.jsxs)("ul",{children:[(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-sqlite.html",target:"_blank",children:"SQLite RxStorage"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-opfs.html",target:"_blank",children:"OPFS RxStorage"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-indexeddb.html",target:"_blank",children:"IndexedDB RxStorage"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-memory-synced.html",target:"_blank",children:"Memory-Synced RxStorage"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-sharding.html",target:"_blank",children:"Sharding Plugin"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/query-optimizer.html",target:"_blank",children:"Query Optimizer"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/migration-storage.html",target:"_blank",children:"Storage Migrator"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-localstorage-meta-optimizer.html",target:"_blank",children:"RxStorage Localstorage Meta Optimizer"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-shared-worker.html",target:"_blank",children:"Shared Worker"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-worker.html",target:"_blank",children:"Worker"})})]})}),(0,g.jsx)("a",{href:"/premium",onClick:()=>(0,f.h)("request_premium_main_page",3),children:(0,g.jsx)("div",{className:"buy-option-action bg-middle hover-shadow-middle",children:"Request Premium"})})]})}),(0,g.jsx)("div",{className:"buy-option bg-gradient-left-top",children:(0,g.jsxs)("div",{className:"buy-option-inner",children:[(0,g.jsxs)("div",{className:"buy-option-title",children:[(0,g.jsx)("h2",{children:"Consulting Session"}),(0,g.jsx)("div",{className:"price",children:"fast in person consulting"})]}),(0,g.jsx)("div",{className:"buy-option-features",children:(0,g.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,g.jsx)("br",{}),"You can book this by doing a one-time donation via github sponsors."]})}),(0,g.jsx)("a",{href:"https://github.com/sponsors/pubkey?frequency=one-time&sponsor=pubkey",target:"_blank",onClick:()=>(0,f.h)("consulting_session_request_main_page",4),children:(0,g.jsx)("div",{className:"buy-option-action bg-bottom hover-shadow-bottom",children:"Book Now"})})]})})]})})]})}),(0,g.jsx)("div",{className:"block last dark",children:(0,g.jsxs)("div",{className:"content",children:[(0,g.jsxs)("h2",{children:["Start using ",(0,g.jsx)("b",{className:"underline",children:"RxDB"})," today"]}),(0,g.jsxs)("div",{className:"buttons full-width",children:[(0,g.jsx)("a",{href:"/quickstart.html",rel:"noopener",target:"_blank",onClick:()=>(0,f.h)("start_now_main_bottom",.4),children:(0,g.jsx)("div",{className:"button get-premium",style:{left:"50%",top:"20%",marginLeft:"-122px"},children:"Start now"})}),(0,g.jsx)("a",{href:"/newsletter",rel:"noopener",target:"_blank",onClick:()=>(0,f.h)("newsletter_main_bottom",.4),children:(0,g.jsx)("div",{className:"button",style:{left:"25%",marginLeft:"-90px"},children:"Get the Newsletter"})}),(0,g.jsx)("a",{href:"/chat",rel:"noopener",target:"_blank",onClick:()=>(0,f.h)("join_chat_main_bottom",.4),children:(0,g.jsx)("div",{className:"button",style:{left:"77%",top:"6%",marginLeft:"-70.5px"},children:"Join the Chat"})}),(0,g.jsx)("a",{href:"/premium",onClick:()=>(0,f.h)("get_premium_main_bottom",.4),children:(0,g.jsx)("div",{className:"button",style:{top:"40%",left:"20%",marginLeft:"-70.5px"},children:"Get Premium"})}),(0,g.jsx)("a",{href:"https://twitter.com/intent/user?screen_name=rxdbjs",rel:"noopener",target:"_blank",onClick:()=>(0,f.h)("follow_twitter_main_bottom",.4),children:(0,g.jsx)("div",{className:"button",style:{top:"44%",left:"73%",marginLeft:"-85px"},children:"Follow on Twitter"})}),(0,g.jsx)("a",{href:"/code",rel:"noopener",target:"_blank",onClick:()=>(0,f.h)("get_code_main_bottom",.4),children:(0,g.jsx)("div",{className:"button",style:{top:"54%",left:"32%",marginLeft:"-70px"},children:"Get the Code"})})]})]})})]})})]})}const j=["NoSQL","OfflineFirst","JavaScript","observable","reactive","realtime","client side","fast"],w=["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"],k=851;function _(){const e=((new Date).getTime()-196e7)/k,t=Math.floor(e);return{ratio:e,period:t,timeToNextPeriod:(e-t)*k}}const N=22,D=-1*N;function R(e){return eN?N:e}function I(){return Math.random()<.5}function E(e,t){let r,a,n=(e=e.slice(0)).length;for(;n;)a=Math.floor(C(t)*n--),r=e[n],e[n]=e[a],e[a]=r,++t;return e}function C(e){const t=1e4*Math.sin(e++);return t-Math.floor(t)}function S(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:()=>h,dY:()=>a,em:()=>o,h$:()=>d,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 h(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 +"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 h=e=>{var t=typeof e;return null!==e&&("object"===t||"function"===t)},d=new Set(["__proto__","prototype","constructor"]),u=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(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+=s;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&&!u.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(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 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 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,j.A)(Error)),N=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,j.A)(TypeError));function D(e,t){return new _(e,w.tunnelErrorMessage(e),t)}function R(e,t){return new N(e,w.tunnelErrorMessage(e),t)}function I(e){return!(!e||409!==e.status)&&e}var E={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var C=/\./g,S="abcdefghijklmnopqrstuvwxyz";function O(e){void 0===e&&(e=10);for(var t="",r=0;r{var r=v(t,e);if(void 0===r)throw D("DOC18",{args:{field:e,documentData:t}});return r})).join(r.separator)}function W(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=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=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 F={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),he=String.fromCharCode(65535),de=Number.MIN_SAFE_INTEGER;function ue(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,h=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?de:he,endKey:a?he:de,inclusiveStart:!0,inclusiveEnd:!0};return void 0===s.startKey&&(s.startKey=de),void 0===s.endKey&&(s.endKey=he),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})),d=h.map((e=>e.startKey)),u=h.map((e=>e.endKey)),m={index:e,startKeys:d,endKeys:u,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!s.has(e))).join(","),selectorSatisfiedByIndex:ve(e,t.selector,d,u)},p=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},s=10,i=(0,y.Sd)(r.startKeys,(e=>e!==de&&e!==he));n(i*s);var o=(0,y.Sd)(r.startKeys,(e=>e!==he&&e!==de));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 D("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 h=l[0];if(h&&i.add(o),"$eq"!==h){if(s.length>0)return!1;s.push(h)}}var d=[],u=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&&u.add(m),"$eq"!==v){if(d.length>0)return!1;d.push(v)}}var g=0;for(var y of e){for(var b of[i,u]){if(!b.has(y)&&b.size>0)return!1;b.delete(y)}if(r[g]!==a[g]&&i.size>0&&u.size>0)return!1;g++}return!0}var ge=r(744),ye=r(2779),be=r(1692),xe=r(4903),je=r(7705),we=r(2403),ke=r(6776),_e=r(6950),Ne=r(6823),De=!1;function Re(e){return De||((0,ye.DZ)(ye.hu.PIPELINE,{$sort:xe.xF,$project:xe.C2}),(0,ye.DZ)(ye.hu.QUERY,{$and:je.a6,$eq:we.XV,$elemMatch:_e.Jy,$exists:Ne.P,$gt:we.MR,$gte:we.fy,$in:we.oZ,$lt:we.NV,$lte:we.Q_,$ne:we.C5,$nin:we.GU,$mod:ke.Pp,$nor:je.q3,$not:je.En,$or:je.sU,$regex:ke.WP,$size:_e.Ig,$type:Ne.T}),De=!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 Ee(e,t){if(!t.sort)throw D("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 Se(e){return e===de?-1/0:e}function Oe(e,t,r){return e.includes(t)?r===he||!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 Oe(e,n,r)})).map(Se),n=t.endKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Se);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,h=[];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)||h.push(n),i.sortSatisfiedByIndex&&h.length===s?e():a.continue()}else e()}}))})),!i.sortSatisfiedByIndex){var d=Ee(e.schema,t.query);h=h.sort(d)}return{documents:h=h.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 We(e,t,r){var a=t.documentData,n=t.previousDocumentData;return{documentId:t.documentId,collectionName:r?r.name:void 0,isLocal:e,operation:t.operation,documentData:w.deepFreezeWhenDevMode(a),previousDocumentData:w.deepFreezeWhenDevMode(n)}}function Fe(e,t,r,a){if(a)throw 409===a.status?D("CONFLICT",{collection:e.name,id:t,writeError:a,data:r}):422===a.status?D("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){w.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),w.isDevMode()){s=M(a,r,s);try{"function"==typeof structuredClone?structuredClone(n):JSON.parse(JSON.stringify(n))}catch(o){throw D("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 D("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 h=r.close.bind(r);r.close=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",i),a||await Ve(t.databaseInstanceToken,r),h()};var d=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",i),a||await Ve(t.databaseInstanceToken,r),d()}}}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 D("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=[],h=[],d=[],u={id:O(10),events:[],checkpoint:null,context:n,startTime:(0,ce.t)(),endTime:0},m=u.events,p=[],f=[],v=[],g=r.size>0,y=a.length,b=function(){var e,n=a[x],u=n.document,y=n.previous,b=u[t],j=u._deleted,w=y&&y._deleted,k=void 0;if(g&&(k=r.get(b)),k){var _=k._rev;if(!y||y&&_!==y._rev){var N={isError:!0,status:409,documentId:b,writeRow:n,documentInDb:k};return d.push(N),1}var R=c?Qe(n):n;c&&(j?y&&Object.keys(y._attachments).forEach((e=>{f.push({documentId:b,attachmentId:e,digest:(0,le.ZN)(y)._attachments[e].digest})})):(Object.entries(u._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(u._attachments).forEach((e=>{let[t,r]=e;var a=y?y._attachments[t]:void 0;if(a){var n=R.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?d.push(e):(c?(h.push(Qe(R)),i&&i(u)):(h.push(R),i&&i(u)),o=R);var I=null,E=null,C=null;if(w&&!j)C="INSERT",I=c?He(u):u;else if(!y||w||j){if(!j)throw D("SNH",{args:{writeRow:n}});C="DELETE",I=(0,le.ZN)(u),E=y}else C="UPDATE",I=c?He(u):u,E=y;var S={documentId:b,documentData:I,previousDocumentData:E,operation:C};m.push(S)}else{var O=!!j;if(c&&Object.entries(u._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(Qe(n)),s&&s(u)):(l.push(n),s&&s(u)),o=n),!O){var P={documentId:b,operation:"INSERT",documentData:c?He(u):u,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.12.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 D("UT5",{args:{params:e}});if((t=e.schema).encrypted&&t.encrypted.length>0||t.attachments&&t.attachments.encrypted)throw D("UT6",{args:{params:e}});var t;if(e.schema.attachments&&e.schema.attachments.compression)throw D("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:[],createRxState:[],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 D("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=W(e);a=function(e){return o(e,!0)}(a),w.deepFreezeWhenDevMode(a);var n=new ct(a,t);return it("createRxSchema",n),n}var ht=r(7708),dt=r(8146),ut=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 h of a)try{l=await h.modifier(c(l))}catch(d){h.reject(d),h.reject=()=>{},h.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,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=D("COL20",{name:E[(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,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,dt.p)((e=>!e.isLocal)),(0,dt.p)((e=>e.documentId===this.primary)),(0,ht.T)((e=>gt(e))),(0,ut.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,pt.t)(le.bz))},get $$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.$,e.getLatest()._data)},get$(e){if(w.isDevMode()){if(e.includes(".item."))throw D("DOC1",{path:e});if(e===this.primaryPath)throw D("DOC2");if(this.collection.schema.finalFields.includes(e))throw D("DOC3",{path:e});if(!A(this.collection.schema.jsonSchema,e))throw D("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=A(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.$A;if(!t)throw D("DOC5",{path:e});if(!t.ref)throw D("DOC6",{path:e,schemaObj:t});var a=this.collection.database.collections[t.ref];if(!a)throw D("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 w.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 w.deepFreezeWhenDevMode(this._data);var t=i(this._data);return delete t._rev,delete t._attachments,delete t._deleted,delete t._meta,w.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 D("DOC11",{id:this.primary,document:this});await wt(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(D("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 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 D("DOC14")}};function jt(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 wt(e,t,r){return t._meta=Object.assign({},r._meta,t._meta),w.isDevMode()&&e.schema.validateChange(r,t),e._runHooks("pre","save",t,r)}var kt=r(2198),_t=r(511),Nt=r(4157),Dt=r(2442),Rt=r(6114);function It(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 s(Et,e,(()=>{var t=e.collection,r=Ie(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=Ee(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:w.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,Rt.kC)(t);return"runFullQueryAgain"===s||("doNothing"!==s?(i=!0,(0,Rt.Cs)(s,r,e,a,n),!1):void 0)}))?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:i,newResults:a}}var St=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 Ot(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=>Ot(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=w.deepFreezeWhenDevMode,i=e.documentCreator,o=o=>{var c=o[t],l=Be(o._rev),h=s(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),d=h.byRev,u=d.get(l),m=u?u.deref():void 0;return m||(o=n(o),m=i(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 Wt=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 Wt(this.collection,e,e.length);this._result=t}else this._result=new Wt(this.collection,[],e)},t._execOverDatabase=async function(){if(this._execOverDatabaseCount=this._execOverDatabaseCount+1,this._lastExecStart=(0,ce.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 D("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 D("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Zt(this).then((()=>(0,_t._)(this.$))).then((t=>{if(!t&&e)throw D("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,dt.p)((e=>!e.isLocal)),(0,ut.Z)(null),(0,Dt.Z)((()=>Zt(this))),(0,ht.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,ht.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,Nt.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,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:w.isDevMode()});await i.remove(),t.isCollection&&await ot("postRemoveRxCollection",{storage:e,databaseName:a,collectionName:n})}))),i){var h=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(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,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 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,(()=>jt(ir(e))))}(e),e,w.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"],hr=["insert","save","remove","create"],dr=!1,ur=function(){function e(e,t,r,a,n,s,i,o,c,l,h,d){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===h&&(h={}),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 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=s,this.methods=i,this.attachments=o,this.options=c,this.cacheReplacementPolicy=l,this.statics=h,this.conflictHandler=d,function(e){if(dr)return;dr=!0;var t=Object.getPrototypeOf(e);hr.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)=>wt(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,Dt.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,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=>We(!1,e,this))),databaseToken:this.database.token,checkpoint:e.checkpoint,context:e.context,endTime:e.endTime,startTime:e.startTime};this.database.$emit(t)}));return this._subs.push(a),this._subs.push(this.storageInstance.conflictResultionTasks().subscribe((e=>{this.conflictHandler(e.input,e.context).then((t=>{this.storageInstance.resolveConflictResultionTask({id:e.id,output:t})}))}))),ft.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,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 D("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 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 D("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 D("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 D("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 R("COL7",{key:t,when:e});if(!lr.includes(e))throw R("COL8",{key:t,when:e});if(!hr.includes(t))throw D("COL9",{key:t});if("post"===e&&"create"===t&&!0===a)throw D("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,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))},vr=r(5525),gr=new Set,yr=function(){function e(e,t,r,a,n,s,i,o,c,l,h,d,u){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.states={},this.eventBulks$=new oe.B,this.observable$=this.eventBulks$.pipe((0,Dt.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=h,this.allowSlowCount=d,this.reactivity=u,"pseudoInstance"!==this.name&&(this.internalStore=Ze(this.asRxDatabase,c,Vt),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: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 D("DM5",{args:{database:e.name,databaseStateVersion:i.documentInDb.data.rxdbVersion,codeVersion:e.rxdbVersion}});if(r&&r!==i.documentInDb.data.passwordHash)throw D("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 D("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 D("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 h=lt(l,this.hashFunction);if(r[c]=h,this.collections[s])throw D("DB3",{name:s});var d=tr(s,l),u={id:Gt(d,Ut),key:d,context:Ut,data:{name:c,schemaHash:await h.hash,schema:h.jsonSchema,version:h.version,connectedStorages:[]},_deleted:!1,_meta:B(),_rev:"",_attachments:{}};a.push({document:u});var m=Object.assign({},o,{name:c,schema:h,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 D("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 D("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:h={},localDocuments:d=!1,cacheReplacementPolicy:u=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:w.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 ur(t,r,a,e,n,s,c,l,h,u,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:h,cacheReplacementPolicy:u,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 vt("json-dump")},t.addState=function(e){throw vt("state")},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=O(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:w.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:h=!1,localDocuments:d=!1,hashFunction:u=fr,reactivity:m}=e;it("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:s,eventReduce:i,ignoreDuplicate:o,options:c,localDocuments:d}),o||function(e,t){var r=t.name+"|"+e;if(gr.has(r))throw D("DB8",{name:e,storage:t.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}(a,t),gr.add(t.name+"|"+a);var p=O(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,u,l,h,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:s,eventReduce:i,ignoreDuplicate:o,options:c,localDocuments:d}}).then((()=>f))}))}var jr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Qt.prototype,RxCollection:ur.prototype,RxDatabase:yr.prototype},wr=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}(jt()),Nr={get isLocal(){return!0},get allAttachments$(){throw D("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,ht.T)((e=>gt(e))),(0,ut.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,ht.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 R("LD2",{objPath:e});var t=v(this._data,e);return t=w.deepFreezeWhenDevMode(t)}},get$(e){if(e="data."+e,w.isDevMode()){if(e.includes(".item."))throw D("LD3",{objPath:e});if(e===this.primaryPath)throw D("LD4")}return this.$.pipe((0,ht.T)((e=>e._data)),(0,ht.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 Or(this.parent);return t.incrementalWriteQueue.addWrite(this._data,(async t=>(t.data=await e(t.data,this),t))).then((e=>t.docCache.getCachedRxDocument(e)))},incrementalPatch(e){return this.incrementalModify((t=>(Object.entries(e).forEach((e=>{let[r,a]=e;t[r]=a})),t)))},async _saveData(e){var t=await Or(this.parent),r=this._data;return e.id=this.id,t.storageInstance.bulkWrite([{previous:r,document:e}],"local-document-save-data").then((t=>{var r=t.success[0];if(!r)throw t.error[0];(e=i(e))._rev=r._rev}))},async remove(){var e=await Or(this.parent),t={id:this._data.id,data:{},_deleted:!0,_meta:B(),_rev:"",_attachments:{}};return Le(e.storageInstance,{previous:this._data,document:t},"local-document-remove").then((t=>e.docCache.getCachedRxDocument(t)))}},Dr=!1,Rr=()=>{if(!Dr){Dr=!0;var e=xt;Object.getOwnPropertyNames(e).forEach((t=>{if(!Object.getOwnPropertyDescriptor(Nr,t)){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(Nr,t,r)}}));["populate","update","putAttachment","getAttachment","allAttachments"].forEach((e=>Nr[e]=(e=>()=>{throw D("LD6",{functionName:e})})(e)))}};function Ir(e){var t=e.parent;return t instanceof yr?t:t.database}var Er=new WeakMap,Cr=new WeakMap;function Sr(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,dt.p)((e=>e.isLocal))),(t=>function(e,t){Rr();var r=new _r(e.id,e,t);return Object.setPrototypeOf(r,Nr),r.prototype=Nr,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=>We(!0,t,e.database?e:void 0))),databaseToken:t.token,checkpoint:r.checkpoint,context:r.context,endTime:r.endTime,startTime:r.startTime};t.$emit(a)}));e._subs.push(o);var c={database:t,parent:e,storageInstance:a,docCache:n,incrementalWriteQueue:s};return Cr.set(e,c),c})();Er.set(e,a)}function Or(e){var t=Er.get(e);if(!t){var r=e.database?e.database:e,a=e.database?e.name:"";throw D("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:w.isDevMode()})}function $r(e){var t=Er.get(e);if(t)return Er.delete(e),t.then((e=>e.storageInstance.close()))}async function Tr(e,t,r){var a=O(10),n=await Pr(a,e,t,r,{},!1);await n.remove()}function Br(e){return"plugin-local-documents-"+e}var Ar=W({title:"RxLocalDocument",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:128},data:{type:"object",additionalProperties:!0}},required:["id","data"]});async function Mr(e,t){var r=await 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 Wr(e){return this.$.pipe((0,ut.Z)(null),(0,Dt.Z)((async t=>t?{changeEvent:t}:{doc:await this.getLocal(e)})),(0,Dt.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,ht.T)((e=>e.doc)))}var Fr={name:"local-documents",rxdb:!0,prototypes:{RxCollection:e=>{e.insertLocal=Mr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Wr},RxDatabase:e=>{e.insertLocal=Mr,e.upsertLocal=qr,e.getLocal=Lr,e.getLocal$=Wr}},hooks:{createRxDatabase:{before:e=>{e.creator.localDocuments&&Sr(e.database)}},createRxCollection:{before:e=>{e.creator.localDocuments&&Sr(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:wr}),!wr.has(e)){if(kr.has(e.name))throw D("PL3",{name:e.name,plugin:e});if(wr.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(jr[t])})),e.overwritable&&Object.assign(w,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)}))}}(Fr);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})},6866:(e,t,r)=>{r.r(t),r.d(t,{default:()=>x});var a=r(4586),n=r(1595),s=r(5260),i=r(4157),o=r(943),c=r(7708),l=r(5520),h=r(3337),d=r(1753),u=r(5734),m=r(2658),p=r(6540),f=r(1527),v=r(4589),g=r(4848);let y=!1;async function b(){if(y)return;y=!0,console.log("start animation");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return void console.log("reducedMotion is set to true");if(!(0,m.IA)())return;const e=await(0,m.C3)();try{await e.insertLocal("beatingvalues",{beatPeriod:0,text1:"JavaScript",text2:"you deserve",color:m.Tj[0]})}catch(N){}const t=(0,h.ZN)(await e.getLocal("beatingvalues"));(async()=>{for(await(0,d.ND)(k);y;){const e=_(),r=(0,d.ND)(e.timeToNextPeriod);if(e.period%2==0)try{await t.incrementalModify((t=>(t.beatPeriod>=e.period||(t.beatPeriod=e.period,t.color=m.Tj[e.period%3],e.period%4==0?t.text1=E(j,e.period)[0]:t.text2=E(w,e.period)[0]),t)))}catch(N){}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)((0,o.R)(window,"mousemove"),(0,o.R)(window,"scroll"),(0,o.R)(window,"resize")).subscribe((()=>{r.incrementalPatch({x:a[0],y:a[1],time:(0,u.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(${R(s)}deg) rotateY(${R(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(!S(t))return;n(t,(0,h.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,c.T)((e=>e._data))).subscribe((e=>{e.data.time&&e.data.x&&e.data.y&&Array.from(t).forEach((t=>{if(!S(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"),p=document.getElementsByClassName("beating-second"),f=document.getElementsByClassName("beating-number"),v=document.getElementsByClassName("beating-color"),g=document.getElementsByClassName("beating-color-string"),b=[];let x=0;_(),t.$.pipe((0,c.T)((e=>e._data.data)),(0,l.F)(((e,t)=>JSON.stringify(e)===JSON.stringify(t)))).subscribe((e=>{b.forEach((function(e){e(x)})),x+=1;const t=e.color;Array.from(v).forEach((function(e){e.style.backgroundColor=t})),Array.from(g).forEach((function(e){e.innerHTML=t}))})),b.push((function(){Array.from(n).forEach((function(e){e.style.animationDuration=k+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")})),Array.from(s).forEach((function(e){e.style.animationDuration=k+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")})),Array.from(p).forEach((function(e){e.style.animationDuration=k+"ms",e.classList.remove("animation"),e.offsetWidth,e.classList.add("animation")}))})),b.push((function(){Array.from(f).forEach((function(e){I()&&I()&&setTimeout((function(){const t=parseFloat(e.innerHTML)+1;e.innerHTML=t+""}),105)}))}))}function x(){const{siteConfig:e}=(0,a.A)();(0,p.useEffect)((()=>(b(),()=>{console.log("stop animation"),y=!1})));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(s.A,{children:(0,g.jsx)("body",{className:"homepage"})}),(0,g.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,g.jsxs)("main",{children:[(0,g.jsx)("div",{className:"block first centered dark",children:(0,g.jsxs)("div",{className:"content",children:[(0,g.jsxs)("h1",{children:["The local ",(0,g.jsx)("b",{className:"underline",children:"Database"})," for"," ",(0,g.jsx)("b",{className:"underline",children:"JavaScript"})," Applications"]}),(0,g.jsxs)("div",{className:"inner",children:[(0,g.jsxs)("div",{className:"half left",children:[(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsxs)("ul",{className:"checked",children:[(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"Realtime Queries"}),": From results of queries to single document fields, with RxDB you can observe everything which makes building ",(0,g.jsx)("u",{children:"realtime applications"})," effortless."]}),(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"Realtime Replication"}),": Run a two-way realtime replication with one of the many replication plugins. Also making your ",(0,g.jsx)("u",{children:"custom backend compatible"})," is pretty simple."]}),(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"Offline Support"}),": Store data locally on your clients device to build applications that still work when there is ",(0,g.jsx)("u",{children:"no internet access"}),". Running queries locally also improves your user experience."]}),(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"Supports all JavaScript runtimes"}),": With the flexible RxDB storage layer you can run the same code in ",(0,g.jsx)("u",{children:"Browsers"}),", ",(0,g.jsx)("u",{children:"Node.js"}),", ",(0,g.jsx)("u",{children:"Electron"}),","," ",(0,g.jsx)("u",{children:"React-Native"}),", ",(0,g.jsx)("u",{children:"Capacitor"}),", ",(0,g.jsx)("u",{children:"Bun"})," and ",(0,g.jsx)("u",{children:"Deno"}),"."]}),(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"Great Performance"}),": Years of performance optimization made RxDB one of the ",(0,g.jsx)("u",{children:"fastest"})," ways to store and query data inside of JavaScript."]})]}),(0,g.jsx)("a",{className:"button",href:"/quickstart.html",target:"_blank",onClick:()=>(0,f.h)("start_now",.4),children:"Quickstart \xbb"}),(0,g.jsxs)("a",{className:"button light",href:"/code",target:"_blank",children:[(0,g.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,g.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,g.jsx)("div",{className:"clear"})]}),(0,g.jsx)("div",{className:"half right",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,g.jsxs)("div",{className:"content-canvas",style:{marginTop:0,marginBottom:30,marginLeft:20},children:[(0,g.jsx)("div",{className:"device tablet",style:{marginLeft:481,marginTop:117},children:(0,g.jsx)("div",{className:"beating-color",style:{backgroundColor:"rgb(141, 32, 137)"},children:(0,g.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo animation",alt:"RxDB",style:{animationDuration:"851ms"}})})}),(0,g.jsx)("div",{className:"device desktop",style:{marginTop:"0%"},children:(0,g.jsx)("div",{className:"beating-color",style:{backgroundColor:"rgb(141, 32, 137)"},children:(0,g.jsx)("img",{src:"/files/logo/logo_text.svg",className:"beating logo animation",alt:"RxDB",style:{animationDuration:"851ms",width:"52%"}})})}),(0,g.jsxs)("div",{className:"device server",style:{marginLeft:0,marginTop:168},children:[(0,g.jsx)("div",{className:"beating-color one",style:{backgroundColor:"rgb(141, 32, 137)"}}),(0,g.jsx)("div",{className:"beating-color two",style:{backgroundColor:"rgb(141, 32, 137)"}}),(0,g.jsx)("div",{className:"beating-color three",style:{backgroundColor:"rgb(141, 32, 137)"}})]})]})})]})]})}),(0,g.jsx)("a",{href:"/chat",target:"_blank",children:(0,g.jsxs)("div",{className:"trophy discord",children:[(0,g.jsx)("img",{src:"./files/icons/discord.svg",alt:"RxDB Discord chat"}),(0,g.jsxs)("div",{style:{flex:1},children:[(0,g.jsx)("div",{className:"subtitle",children:"Chat on"}),(0,g.jsx)("div",{className:"title",children:"Discord"})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"valuetitle",children:"members"}),(0,g.jsxs)("div",{className:"value",children:["747",(0,g.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,g.jsxs)("div",{className:"block reviews",children:[(0,g.jsx)("div",{className:"content centered",children:(0,g.jsxs)("div",{className:"inner",children:[(0,g.jsxs)("h2",{children:["Our ",(0,g.jsx)("b",{className:"underline",children:"Success Stories"})]}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{})]})}),(0,g.jsxs)(v.A,{dots:!0,centerMode:!0,centerPadding:"10px",infinite:!0,arrows:!1,adaptiveHeight:!0,speed:500,slidesToShow:4,slidesToScroll:1,initialSlide:0,responsive:[{breakpoint:1250,settings:{slidesToShow:3,slidesToScroll:1,infinite:!0,dots:!0}},{breakpoint:1024,settings:{slidesToShow:3,slidesToScroll:1,infinite:!0,dots:!0}},{breakpoint:900,settings:{slidesToShow:2,slidesToScroll:1,infinite:!0,dots:!0}},{breakpoint:600,settings:{slidesToShow:2,slidesToScroll:1,infinite:!0,dots:!0}},{breakpoint:480,settings:{slidesToShow:1.1,centerPadding:"15px",slidesToScroll:1,infinite:!1,dots:!1}}],children:[(0,g.jsxs)("div",{className:"slider-content",children:[(0,g.jsx)("h3",{children:'"We use RxDB to create applications capable of being used in the most remote areas where Internet access is really a challenge."'}),(0,g.jsxs)("div",{className:"slider-profile",children:[(0,g.jsx)("img",{className:"slider-logo-white",src:"https://altgras.com/assets/img/logo.png"}),(0,g.jsxs)("div",{className:"slider-info",children:[(0,g.jsx)("p",{className:"developer",children:"ALTGRAS"}),(0,g.jsx)("a",{href:"https://altgras.com/",target:"_blank",className:"company-link",children:"https://altgras.com/"})]})]})]}),(0,g.jsxs)("div",{className:"slider-content",children:[(0,g.jsx)("h3",{children:'"We provide a mobile app that is used by people in the field to fill in valuable information like inspections, surveys and audits"'}),(0,g.jsxs)("div",{className:"slider-profile",children:[(0,g.jsx)("img",{className:"slider-logo-black",src:"https://moreapp.com/assets/img/logo.png"}),(0,g.jsxs)("div",{className:"slider-info",children:[(0,g.jsx)("p",{className:"developer",children:"MoreApp"}),(0,g.jsx)("a",{href:"https://moreapp.com/",target:"_blank",className:"company-link",children:"https://moreapp.com/"})]})]})]}),(0,g.jsxs)("div",{className:"slider-content",children:[(0,g.jsx)("h3",{children:'"We use RxDB to provide an offline first, cross platform point of sale system"'}),(0,g.jsxs)("div",{className:"slider-profile",children:[(0,g.jsx)("img",{className:"slider-logo-black",src:"https://wcpos.com/wp-content/uploads/2014/06/woopos-logo.png"}),(0,g.jsxs)("div",{className:"slider-info",children:[(0,g.jsx)("p",{className:"developer",children:"WooCommerce POS"}),(0,g.jsx)("a",{href:"https://wcpos.com/",target:"_blank",className:"company-link",children:"https://wcpos.com/"})]})]})]}),(0,g.jsxs)("div",{className:"slider-content",children:[(0,g.jsx)("h3",{children:'"RxDB is a main component in building offline-ready multichannel apps. It has become our default stack for this kind of apps."'}),(0,g.jsxs)("div",{className:"slider-profile",children:[(0,g.jsx)("img",{className:"slider-logo-black",src:"https://atroo.de/wp-content/uploads/2018/10/atroo-small-300x117.png"}),(0,g.jsxs)("div",{className:"slider-info",children:[(0,g.jsx)("p",{className:"developer",children:"atroo GmbH"}),(0,g.jsx)("a",{href:"https://atroo.de/",target:"_blank",className:"company-link",children:"https://atroo.de/"})]})]})]})]})]}),(0,g.jsx)("div",{className:"block second dark",children:(0,g.jsxs)("div",{className:"content",children:[(0,g.jsxs)("h2",{children:["Realtime applications ",(0,g.jsx)("b",{className:"underline",children:"made easy"})]}),(0,g.jsxs)("p",{children:["From the results of a query, to a single field of a document, with RxDB you can ",(0,g.jsx)("b",{children:"observe everything"}),". This enables you to build realtime applications ",(0,g.jsx)("b",{children:"fast"})," and ",(0,g.jsx)("b",{children:"reliable"}),". It does not matter if the data was changed by"," ",(0,g.jsx)("b",{children:"a user event"}),", ",(0,g.jsx)("b",{children:"another browser tab"})," or by the",(0,g.jsx)("b",{children:" replication"}),"."," ","Whenever your data changes, your UI reflects the new state. You can either use ",(0,g.jsx)("b",{children:"RxJS"})," or add ",(0,g.jsx)("a",{href:"/reactivity.html",target:"_blank",children:"custom reactiveness libraries"})," like signals or other state management."]}),(0,g.jsxs)("div",{className:"inner",children:[(0,g.jsxs)("div",{className:"code half",children:[(0,g.jsxs)("fieldset",{className:"samp-wrapper",style:{backgroundColor:"var(--bg-color)"},children:[(0,g.jsx)("legend",{children:"Write"}),(0,g.jsxs)("samp",{children:[(0,g.jsx)("span",{className:"cm-keyword",children:"await "}),(0,g.jsx)("span",{className:"cm-variable",children:"collection"}),".",(0,g.jsx)("span",{className:"cm-method",children:"upsert"}),"(","{",(0,g.jsx)("br",{}),(0,g.jsx)("span",{className:"cm-property",children:"\xa0 id"}),": ",(0,g.jsx)("span",{className:"cm-string",children:"'foobar'"}),",",(0,g.jsx)("br",{}),(0,g.jsx)("span",{className:"cm-property",children:"\xa0 color"}),": ",(0,g.jsxs)("span",{className:"cm-string",children:["'",(0,g.jsx)("span",{className:"beating-color-string beating-color",children:"#e6008d"}),"'"]}),(0,g.jsx)("br",{}),"}",");"]})]}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsxs)("fieldset",{className:"samp-wrapper",style:{backgroundColor:"var(--bg-color)"},children:[(0,g.jsx)("legend",{children:"Observe"}),(0,g.jsxs)("samp",{style:{backgroundColor:"var(--bg-color)"},children:[(0,g.jsx)("span",{className:"cm-keyword",children:"await "}),(0,g.jsx)("span",{className:"cm-variable",children:"collection"}),".",(0,g.jsxs)("span",{className:"cm-method",children:["findOne(",(0,g.jsx)("span",{className:"cm-string",children:"'foobar'"}),")"]}),(0,g.jsx)("br",{}),"\xa0.",(0,g.jsx)("span",{className:"cm-property",children:"$"}),(0,g.jsx)("span",{className:"cm-comment",children:" // get observable"}),(0,g.jsx)("br",{}),"\xa0.",(0,g.jsx)("span",{className:"cm-method",children:"subscribe"}),"(",(0,g.jsx)("span",{className:"cm-def",children:"d"}),(0,g.jsx)("span",{className:"cm-operator",children:" =>"})," ","{",(0,g.jsx)("br",{}),(0,g.jsx)("span",{className:"cm-variable",children:"\xa0\xa0 screen"}),".",(0,g.jsx)("span",{className:"cm-property",children:"backgroundColor"}),(0,g.jsx)("span",{className:"cm-operator",children:" = "}),(0,g.jsx)("span",{className:"cm-variable",children:"d"}),".",(0,g.jsx)("span",{className:"cm-property beating-color",children:"color"}),";",(0,g.jsx)("br",{}),"\xa0","}",");"]})]})]}),(0,g.jsx)("div",{className:"canvas half",children:(0,g.jsxs)("div",{className:"content-canvas",children:[(0,g.jsx)("div",{className:"device tablet",style:{marginLeft:481,marginTop:117},children:(0,g.jsx)("div",{className:"beating-color",children:(0,g.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo",alt:"RxDB"})})}),(0,g.jsx)("div",{className:"device desktop",style:{marginTop:"0%"},children:(0,g.jsx)("div",{className:"beating-color",children:(0,g.jsx)("img",{src:"./files/logo/logo.svg",className:"beating logo",alt:"RxDB"})})}),(0,g.jsxs)("div",{className:"device server",style:{marginLeft:0,marginTop:168},children:[(0,g.jsx)("div",{className:"beating-color one"}),(0,g.jsx)("div",{className:"beating-color two"}),(0,g.jsx)("div",{className:"beating-color three"})]})]})})]})]})}),(0,g.jsx)("a",{href:"https://twitter.com/intent/user?screen_name=rxdbjs",onClick:()=>(0,f.h)("twitter_trophy_click",.2),target:"_blank",children:(0,g.jsxs)("div",{className:"trophy twitter",children:[(0,g.jsx)("img",{src:"./files/icons/twitter-blue.svg",alt:"RxDB Twitter"}),(0,g.jsxs)("div",{style:{flex:1},children:[(0,g.jsx)("div",{className:"subtitle",children:"Follow on"}),(0,g.jsx)("div",{className:"title",children:"Twitter"})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"valuetitle",children:"followers"}),(0,g.jsxs)("div",{className:"value",children:["2843",(0,g.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,g.jsx)("div",{className:"block replication",children:(0,g.jsxs)("div",{className:"content",children:[(0,g.jsxs)("div",{className:"half left",children:[(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsxs)("h2",{children:["Replicate ",(0,g.jsx)("b",{children:"with your existing infrastructure"})]}),(0,g.jsxs)("p",{children:["RxDB supports replication with a"," ",(0,g.jsx)("a",{href:"/replication-couchdb.html",target:"_blank",children:"CouchDB"})," ","server or any custom"," ",(0,g.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,g.jsx)("a",{href:"/replication-http.html",target:"_blank",children:"HTTP"}),","," ",(0,g.jsx)("a",{href:"/replication-websocket.html",target:"_blank",children:"Websocket"}),","," ",(0,g.jsx)("a",{href:"/replication-webrtc.html",target:"_blank",children:"WebRTC"})," ","or"," ",(0,g.jsx)("a",{href:"/replication-firestore.html",target:"_blank",children:"Firestore"}),"."]})]}),(0,g.jsx)("div",{className:"half right",children:(0,g.jsxs)("div",{className:"replication-icons",children:[(0,g.jsx)("img",{src:"./files/logo/logo.svg",alt:"RxDB",className:"replicate-logo tilt-to-mouse"}),(0,g.jsx)("a",{href:"/replication-graphql.html",target:"_blank",children:(0,g.jsx)("div",{className:"neumorphism-circle-xl centered replicate-graphql enlarge-on-mouse",children:(0,g.jsx)("img",{src:"./files/icons/graphql-text.svg",alt:"GraphQL",className:"protocol"})})}),(0,g.jsx)("a",{href:"/replication-couchdb.html",target:"_blank",children:(0,g.jsx)("div",{className:"neumorphism-circle-xl centered replicate-couchdb enlarge-on-mouse",children:(0,g.jsx)("img",{src:"./files/icons/couchdb-text.svg",alt:"CouchDB",className:"protocol"})})}),(0,g.jsx)("a",{href:"/replication-http.html",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-xs centered replicate-rest enlarge-on-mouse",children:["{"," HTTP ","}"]})}),(0,g.jsx)("a",{href:"/replication-websocket.html",target:"_blank",children:(0,g.jsx)("div",{className:"neumorphism-circle-xs centered replicate-websocket enlarge-on-mouse",children:"websocket"})}),(0,g.jsx)("a",{href:"/replication-webrtc.html",target:"_blank",children:(0,g.jsx)("div",{className:"neumorphism-circle-xs centered replicate-webrtc enlarge-on-mouse",children:"WebRTC"})})]})}),(0,g.jsx)("div",{className:"clear"})]})}),(0,g.jsx)("a",{href:"/code",target:"_blank",children:(0,g.jsxs)("div",{className:"trophy",children:[(0,g.jsx)("img",{src:"./files/icons/github-star-with-logo.svg",alt:"RxDB github star"}),(0,g.jsxs)("div",{style:{flex:1},children:[(0,g.jsx)("div",{className:"subtitle",children:"Open Source on"}),(0,g.jsx)("div",{className:"title",children:"GitHub"})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"valuetitle",children:"stars"}),(0,g.jsxs)("div",{className:"value",children:["20172",(0,g.jsx)("div",{className:"arrow-up",children:" "})]})]})]})}),(0,g.jsxs)("div",{className:"block offline-first dark",children:[(0,g.jsx)("div",{className:"offline-image-wrapper",children:(0,g.jsx)("img",{src:"files/icons/wifi/wifi_1a202c.svg",className:"offline-image beating-second",alt:"offline"})}),(0,g.jsxs)("div",{className:"content",children:[(0,g.jsxs)("h2",{children:["Online ",(0,g.jsx)("b",{className:"underline",children:"is optional"})]}),(0,g.jsxs)("div",{className:"full-width",children:[(0,g.jsx)("div",{className:"half left",children:(0,g.jsxs)("p",{children:["RxDB follows the"," ",(0,g.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,g.jsx)("div",{className:"half right",children:(0,g.jsxs)("ul",{className:"checked",children:[(0,g.jsxs)("li",{children:["Your application still ",(0,g.jsx)("b",{children:"works offline"})]}),(0,g.jsxs)("li",{children:["Increases ",(0,g.jsx)("b",{children:"perceived performance"})]}),(0,g.jsxs)("li",{children:["Easier and ",(0,g.jsx)("b",{children:"faster implementation"})]}),(0,g.jsxs)("li",{children:["Needs less backend resources and ",(0,g.jsx)("b",{children:"scales better"})]})]})})]})]})]}),(0,g.jsx)("div",{className:"block frameworks",children:(0,g.jsxs)("div",{className:"content",children:[(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/angular",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"-10%",left:"10%"},children:[(0,g.jsx)("img",{src:"./files/icons/angular.svg",alt:"angular"}),"Angular"]})}),(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"10%",left:"58%"},children:[(0,g.jsx)("img",{src:"./files/icons/capacitor.svg",alt:"capacitor"}),"Capacitor"]}),(0,g.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"-4%",left:"44%"},children:[(0,g.jsx)("img",{src:"./files/icons/deno.svg",alt:"deno"}),"Deno"]}),(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/node",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"-5%",left:"85%"},children:[(0,g.jsx)("img",{src:"./files/icons/nodejs.svg",alt:"Node.js"}),"Node.js"]})}),(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/react",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"4%",left:"26%"},children:[(0,g.jsx)("img",{src:"./files/icons/react.svg",alt:"React"}),"React"]})}),(0,g.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"15%",left:"90%",marginLeft:"-35px"},children:[(0,g.jsx)("img",{src:"./files/icons/svelte.svg",alt:"Svelte"}),"Svelte"]}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsxs)("h2",{children:["Flexible ",(0,g.jsx)("b",{className:"underline",children:"storage layer"})]}),(0,g.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,g.jsx)("b",{children:"any JavaScript runtime"})," ","by just switching out the storage settings.",(0,g.jsx)("br",{})]}),(0,g.jsxs)("div",{className:"below-text",children:[(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/electron",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"2%",left:"18%"},children:[(0,g.jsx)("img",{src:"./files/icons/electron.svg",alt:"electron"}),"Electron"]})}),(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/vue",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"3%",left:"45%"},children:[(0,g.jsx)("img",{src:"./files/icons/vuejs.svg",alt:"Vue.js"}),"Vue.js"]})}),(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/ionic2",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"2%",left:"71%"},children:[(0,g.jsx)("img",{src:"./files/icons/ionic.svg",alt:"ionic"}),"Ionic"]})}),(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"46%",left:"11%"},children:[(0,g.jsx)("img",{src:"./files/icons/nativescript.svg",alt:"NativeScript"}),"NativeScript"]}),(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/react-native",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"45%",left:"35%"},children:[(0,g.jsx)("img",{src:"./files/icons/react.svg",alt:"React Native"}),"React Native"]})}),(0,g.jsxs)("div",{className:"neumorphism-circle-m circle centered enlarge-on-mouse",style:{top:"45%",left:"62%"},children:[(0,g.jsx)("img",{src:"./files/icons/nextjs.svg",alt:"Next.js"}),"Next.js"]}),(0,g.jsx)("a",{href:"https://github.com/pubkey/rxdb/tree/master/examples/flutter",target:"_blank",children:(0,g.jsxs)("div",{className:"neumorphism-circle-s circle centered enlarge-on-mouse",style:{top:"40%",left:"86%"},children:[(0,g.jsx)("img",{src:"./files/icons/flutter.svg",alt:"Flutter"}),"Flutter"]})})]})]})}),(0,g.jsx)("div",{className:"block fifth dark",children:(0,g.jsx)("div",{className:"content centered",children:(0,g.jsxs)("div",{className:"inner",children:[(0,g.jsxs)("h2",{children:["Trusted and ",(0,g.jsx)("b",{className:"underline",children:"open source"})]}),(0,g.jsxs)("div",{className:"box dark",children:[(0,g.jsx)("img",{src:"files/icons/github-star.svg",alt:"github star"}),(0,g.jsx)("div",{className:"label",children:"Github Stars"}),(0,g.jsx)("a",{className:"value",href:"/code",rel:"noopener",target:"_blank",children:"20172"}),(0,g.jsx)("div",{className:"clear"})]}),(0,g.jsxs)("div",{className:"box dark",children:[(0,g.jsx)("img",{src:"files/icons/download.svg",alt:"npm downloads"}),(0,g.jsx)("div",{className:"label",children:"npm downloads"}),(0,g.jsx)("a",{className:"value beating-number",href:"https://www.npmjs.com/package/rxdb",rel:"noopener",target:"_blank",children:"238572"}),(0,g.jsx)("div",{className:"clear"})]}),(0,g.jsx)("div",{className:"clear"}),(0,g.jsxs)("div",{className:"box dark",children:[(0,g.jsx)("img",{src:"files/icons/person.svg",alt:"contributor"}),(0,g.jsx)("div",{className:"label",children:"Contributors"}),(0,g.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/graphs/contributors",rel:"noopener",target:"_blank",children:"211"}),(0,g.jsx)("div",{className:"clear"})]}),(0,g.jsxs)("div",{className:"box dark",children:[(0,g.jsx)("img",{src:"files/icons/commit.svg",alt:"commit"}),(0,g.jsx)("div",{className:"label",children:"Commits"}),(0,g.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/commits/master",rel:"noopener",target:"_blank",children:"10409"}),(0,g.jsx)("div",{className:"clear"})]}),(0,g.jsx)("div",{className:"clear"}),(0,g.jsxs)("div",{className:"box dark",children:[(0,g.jsx)("img",{src:"files/icons/gear.svg",alt:"gear"}),(0,g.jsx)("div",{className:"label",children:"RxDB made Projects"}),(0,g.jsx)("a",{className:"value",href:"https://github.com/pubkey/rxdb/network/dependents?package_id=UGFja2FnZS0xODM0NzAyMw%3D%3D",rel:"noopener",target:"_blank",children:"1402"}),(0,g.jsx)("div",{className:"clear"})]}),(0,g.jsxs)("div",{className:"box dark",children:[(0,g.jsx)("img",{src:"files/icons/twitter.svg",alt:"twitter"}),(0,g.jsx)("div",{className:"label",children:"Twitter followers"}),(0,g.jsx)("a",{className:"value",href:"https://twitter.com/intent/user?screen_name=rxdbjs",rel:"noopener",target:"_blank",children:"2925"}),(0,g.jsx)("div",{className:"clear"})]}),(0,g.jsx)("div",{className:"clear"})]})})}),(0,g.jsx)("div",{className:"block sixth",children:(0,g.jsxs)("div",{className:"content",children:[(0,g.jsx)("h2",{children:"Pricing Models"}),(0,g.jsx)("div",{className:"inner",children:(0,g.jsxs)("div",{className:"buy-options",children:[(0,g.jsx)("div",{className:"buy-option bg-gradient-left-top",children:(0,g.jsxs)("div",{className:"buy-option-inner",children:[(0,g.jsxs)("div",{className:"buy-option-title",children:[(0,g.jsx)("h2",{children:"RxDB Basics"}),(0,g.jsx)("div",{className:"price",children:"Free & Open Source"})]}),(0,g.jsx)("div",{className:"buy-option-features",children:(0,g.jsxs)("ul",{children:[(0,g.jsx)("li",{children:"Basic RxStorages"}),(0,g.jsx)("li",{children:"Realtime Replication"}),(0,g.jsx)("li",{children:"Live Queries"}),(0,g.jsx)("li",{children:"Schema Validation"}),(0,g.jsx)("li",{children:"Multi-Tab Support"}),(0,g.jsx)("li",{children:"Encryption"}),(0,g.jsx)("li",{children:"Compression"})]})}),(0,g.jsx)("a",{href:"/code",target:"_blank",rel:"noopener",onClick:()=>(0,f.h)("get_the_code_main_page",.8),children:(0,g.jsx)("div",{className:"buy-option-action bg-top hover-shadow-top",children:"Get the Code"})})]})}),(0,g.jsx)("div",{className:"buy-option bg-gradient-right-top",children:(0,g.jsxs)("div",{className:"buy-option-inner",children:[(0,g.jsxs)("div",{className:"buy-option-title",children:[(0,g.jsx)("h2",{children:"Premium Plugins"}),(0,g.jsx)("div",{className:"price",children:"for professionals to get the most out of RxDB"})]}),(0,g.jsx)("div",{className:"buy-option-features",children:(0,g.jsxs)("ul",{children:[(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-sqlite.html",target:"_blank",children:"SQLite RxStorage"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-opfs.html",target:"_blank",children:"OPFS RxStorage"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-indexeddb.html",target:"_blank",children:"IndexedDB RxStorage"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-memory-synced.html",target:"_blank",children:"Memory-Synced RxStorage"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-sharding.html",target:"_blank",children:"Sharding Plugin"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/query-optimizer.html",target:"_blank",children:"Query Optimizer"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/migration-storage.html",target:"_blank",children:"Storage Migrator"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-localstorage-meta-optimizer.html",target:"_blank",children:"RxStorage Localstorage Meta Optimizer"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-shared-worker.html",target:"_blank",children:"Shared Worker"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{href:"https://rxdb.info/rx-storage-worker.html",target:"_blank",children:"Worker"})})]})}),(0,g.jsx)("a",{href:"/premium",onClick:()=>(0,f.h)("request_premium_main_page",3),children:(0,g.jsx)("div",{className:"buy-option-action bg-middle hover-shadow-middle",children:"Request Premium"})})]})}),(0,g.jsx)("div",{className:"buy-option bg-gradient-left-top",children:(0,g.jsxs)("div",{className:"buy-option-inner",children:[(0,g.jsxs)("div",{className:"buy-option-title",children:[(0,g.jsx)("h2",{children:"Consulting Session"}),(0,g.jsx)("div",{className:"price",children:"fast in person consulting"})]}),(0,g.jsx)("div",{className:"buy-option-features",children:(0,g.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,g.jsx)("br",{}),"You can book this by doing a one-time donation via github sponsors."]})}),(0,g.jsx)("a",{href:"https://github.com/sponsors/pubkey?frequency=one-time&sponsor=pubkey",target:"_blank",onClick:()=>(0,f.h)("consulting_session_request_main_page",4),children:(0,g.jsx)("div",{className:"buy-option-action bg-bottom hover-shadow-bottom",children:"Book Now"})})]})})]})})]})}),(0,g.jsx)("div",{className:"block last dark",children:(0,g.jsxs)("div",{className:"content",children:[(0,g.jsxs)("h2",{children:["Start using ",(0,g.jsx)("b",{className:"underline",children:"RxDB"})," today"]}),(0,g.jsxs)("div",{className:"buttons full-width",children:[(0,g.jsx)("a",{href:"/quickstart.html",rel:"noopener",target:"_blank",onClick:()=>(0,f.h)("start_now_main_bottom",.4),children:(0,g.jsx)("div",{className:"button get-premium",style:{left:"50%",top:"20%",marginLeft:"-122px"},children:"Start now"})}),(0,g.jsx)("a",{href:"/newsletter",rel:"noopener",target:"_blank",onClick:()=>(0,f.h)("newsletter_main_bottom",.4),children:(0,g.jsx)("div",{className:"button",style:{left:"25%",marginLeft:"-90px"},children:"Get the Newsletter"})}),(0,g.jsx)("a",{href:"/chat",rel:"noopener",target:"_blank",onClick:()=>(0,f.h)("join_chat_main_bottom",.4),children:(0,g.jsx)("div",{className:"button",style:{left:"77%",top:"6%",marginLeft:"-70.5px"},children:"Join the Chat"})}),(0,g.jsx)("a",{href:"/premium",onClick:()=>(0,f.h)("get_premium_main_bottom",.4),children:(0,g.jsx)("div",{className:"button",style:{top:"40%",left:"20%",marginLeft:"-70.5px"},children:"Get Premium"})}),(0,g.jsx)("a",{href:"https://twitter.com/intent/user?screen_name=rxdbjs",rel:"noopener",target:"_blank",onClick:()=>(0,f.h)("follow_twitter_main_bottom",.4),children:(0,g.jsx)("div",{className:"button",style:{top:"44%",left:"73%",marginLeft:"-85px"},children:"Follow on Twitter"})}),(0,g.jsx)("a",{href:"/code",rel:"noopener",target:"_blank",onClick:()=>(0,f.h)("get_code_main_bottom",.4),children:(0,g.jsx)("div",{className:"button",style:{top:"54%",left:"32%",marginLeft:"-70px"},children:"Get the Code"})})]})]})})]})})]})}const j=["NoSQL","OfflineFirst","JavaScript","observable","reactive","realtime","client side","fast"],w=["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"],k=851;function _(){const e=((new Date).getTime()-196e7)/k,t=Math.floor(e);return{ratio:e,period:t,timeToNextPeriod:(e-t)*k}}const N=22,D=-1*N;function R(e){return eN?N:e}function I(){return Math.random()<.5}function E(e,t){let r,a,n=(e=e.slice(0)).length;for(;n;)a=Math.floor(C(t)*n--),r=e[n],e[n]=e[a],e[a]=r,++t;return e}function C(e){const t=1e4*Math.sin(e++);return t-Math.floor(t)}function S(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:()=>h,dY:()=>a,em:()=>o,h$:()=>d,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 h(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/280a2389.62acb9e6.js b/docs/assets/js/280a2389.2a5b1215.js similarity index 99% rename from docs/assets/js/280a2389.62acb9e6.js rename to docs/assets/js/280a2389.2a5b1215.js index 371a41b8cf8..b6dbccdea0e 100644 --- a/docs/assets/js/280a2389.62acb9e6.js +++ b/docs/assets/js/280a2389.2a5b1215.js @@ -1 +1 @@ -"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[176],{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",z="dexie",U=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"===M(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=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,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 Me(e,t){var r=t?t._rev:null;return(r?Ae(r).height:0)+1+"-"+e}var qe="_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=q(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=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,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: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,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 ze=r(3561),Ue=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 Ue.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,ze.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(U,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 U.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(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.11.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 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:[],createRxState:[],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=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})})),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(!M(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=M(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)))}}),Mt=new WeakSet;var qt=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=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,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,Mt.has(i)||(Mt.add(i),(0,pt.dY)().then((()=>(0,pt.Ve)(200))).then((()=>{i.destroyed||i.cacheReplacementPolicy(i,i._queryCache),Mt.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=Me(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 qt(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.states={},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),Ut));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,Ut),key:l,context:Ut,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.addState=function(e){throw vt("state")},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:qe,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,Mr);var n=new qt("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:Mr,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 Mr=Q({title:"RxLocalDocument",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:128},data:{type:"object",additionalProperties:!0}},required:["id","data"]});async function qr(e,t){var r=await 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=qr,e.upsertLocal=Br,e.getLocal=Lr,e.getLocal$=Qr},RxDatabase:e=>{e.insertLocal=qr,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"]},8141:(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="meeting-link-clicked";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)();await e.getLocal(u)?console.log("# already tracked "+u):(window.trigger(u,10),await e.upsertLocal(u,{}))})()}));let r="https://rxdb.pipedrive.com/scheduler/";if(t){r+=new URLSearchParams(window.location.search).get("f")+"/schedulr"}return(0,c.jsx)(n.A,{title:`Chat - ${e.title}`,description:"Meeting Scheduler",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 Meeting Scheduler"}),(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 meeting scheduler directly."})}),(0,c.jsx)("meta",{httpEquiv:"Refresh",content:"0; 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 +"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[176],{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",z="dexie",U=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"===M(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=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,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 Me(e,t){var r=t?t._rev:null;return(r?Ae(r).height:0)+1+"-"+e}var qe="_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=q(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=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,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: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,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 ze=r(3561),Ue=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 Ue.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,ze.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(U,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 U.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(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.12.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 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:[],createRxState:[],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=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})})),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(!M(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=M(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)))}}),Mt=new WeakSet;var qt=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=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,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,Mt.has(i)||(Mt.add(i),(0,pt.dY)().then((()=>(0,pt.Ve)(200))).then((()=>{i.destroyed||i.cacheReplacementPolicy(i,i._queryCache),Mt.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=Me(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 qt(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.states={},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),Ut));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,Ut),key:l,context:Ut,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.addState=function(e){throw vt("state")},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:qe,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,Mr);var n=new qt("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:Mr,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 Mr=Q({title:"RxLocalDocument",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:128},data:{type:"object",additionalProperties:!0}},required:["id","data"]});async function qr(e,t){var r=await 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=qr,e.upsertLocal=Br,e.getLocal=Lr,e.getLocal$=Qr},RxDatabase:e=>{e.insertLocal=qr,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"]},8141:(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="meeting-link-clicked";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)();await e.getLocal(u)?console.log("# already tracked "+u):(window.trigger(u,10),await e.upsertLocal(u,{}))})()}));let r="https://rxdb.pipedrive.com/scheduler/";if(t){r+=new URLSearchParams(window.location.search).get("f")+"/schedulr"}return(0,c.jsx)(n.A,{title:`Chat - ${e.title}`,description:"Meeting Scheduler",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 Meeting Scheduler"}),(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 meeting scheduler directly."})}),(0,c.jsx)("meta",{httpEquiv:"Refresh",content:"0; 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/4ed9495b.12f9cf04.js b/docs/assets/js/4ed9495b.12f9cf04.js new file mode 100644 index 00000000000..72ad83c63f4 --- /dev/null +++ b/docs/assets/js/4ed9495b.12f9cf04.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[1199],{1787:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>c,contentTitle:()=>r,default:()=>h,frontMatter:()=>n,metadata:()=>o,toc:()=>l});var a=s(4848),i=s(8453);const n={title:"SQLite RxStorage \ud83d\udc51",slug:"rx-storage-sqlite.html"},r="SQLite RxStorage",o={id:"rx-storage-sqlite",title:"SQLite RxStorage \ud83d\udc51",description:"This RxStorage is based on SQLite and is made to work with Node.js, Electron, React Native and Capacitor or SQLite via webassembly in the browser. It can be used with different so called sqliteBasics adapters to account for the differences in the various SQLite bundles and libraries that exist.",source:"@site/docs/rx-storage-sqlite.md",sourceDirName:".",slug:"/rx-storage-sqlite.html",permalink:"/rx-storage-sqlite.html",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"SQLite RxStorage \ud83d\udc51",slug:"rx-storage-sqlite.html"},sidebar:"tutorialSidebar",previous:{title:"IndexedDB RxStorage \ud83d\udc51",permalink:"/rx-storage-indexeddb.html"},next:{title:"Memory RxStorage",permalink:"/rx-storage-memory.html"}},c={},l=[{value:"Performance comparison with other storages",id:"performance-comparison-with-other-storages",level:2},{value:"Using the SQLite RxStorage",id:"using-the-sqlite-rxstorage",level:2},{value:"Usage with Node.js SQLite",id:"usage-with-nodejs-sqlite",level:2},{value:"Usage with Webassembly in the Browser",id:"usage-with-webassembly-in-the-browser",level:2},{value:"Usage with React Native",id:"usage-with-react-native",level:2},{value:"Usage with SQLite Capacitor",id:"usage-with-sqlite-capacitor",level:2},{value:"Database Connection",id:"database-connection",level:2},{value:"Known Problems of SQLite in JavaScript apps",id:"known-problems-of-sqlite-in-javascript-apps",level:2},{value:"Related",id:"related",level:2}];function d(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.h1,{id:"sqlite-rxstorage",children:"SQLite RxStorage"}),"\n",(0,a.jsxs)(t.p,{children:["This ",(0,a.jsx)(t.a,{href:"/rx-storage.html",children:"RxStorage"})," is based on ",(0,a.jsx)(t.a,{href:"https://www.sqlite.org/index.html",children:"SQLite"})," and is made to work with ",(0,a.jsx)(t.strong,{children:"Node.js"}),", ",(0,a.jsx)(t.a,{href:"/electron-database.html",children:"Electron"}),", ",(0,a.jsx)(t.a,{href:"/react-native-database.html",children:"React Native"})," and ",(0,a.jsx)(t.a,{href:"/capacitor-database.html",children:"Capacitor"})," or SQLite via webassembly in the browser. It can be used with different so called ",(0,a.jsx)(t.code,{children:"sqliteBasics"})," adapters to account for the differences in the various SQLite bundles and libraries that exist."]}),"\n",(0,a.jsx)(t.h2,{id:"performance-comparison-with-other-storages",children:"Performance comparison with other storages"}),"\n",(0,a.jsxs)(t.p,{children:["The SQLite storage is a bit slower compared to other Node.js based storages like the ",(0,a.jsx)(t.a,{href:"/rx-storage-filesystem-node.html",children:"Filesystem Storage"})," because wrapping SQLite has a bit of overhead and sending data from the JavaScript process to SQLite and backwards increases the latency. However for most hybrid apps the SQLite storage is the best option because it can leverage the SQLite version that comes already installed on the smartphones OS (iOS and android). Also for desktop electron apps it can be a viable solution because it is easy to ship SQLite together inside of the electron bundle."]}),"\n",(0,a.jsx)("p",{align:"center",children:(0,a.jsx)("img",{src:"./files/rx-storage-performance-node.png",alt:"SQLite performance - Node.js",width:"700"})}),"\n",(0,a.jsx)(t.h2,{id:"using-the-sqlite-rxstorage",children:"Using the SQLite RxStorage"}),"\n",(0,a.jsxs)(t.p,{children:["To use the SQLite storage you have to import ",(0,a.jsx)(t.code,{children:"getRxStorageSQLite"})," from the ",(0,a.jsx)(t.a,{href:"/premium",children:"RxDB Premium \ud83d\udc51"})," package and then add the correct ",(0,a.jsx)(t.code,{children:"sqliteBasics"})," adapter depending on which sqlite module you want to use. This can then be used as storage when creating the ",(0,a.jsx)(t.a,{href:"/rx-database.html",children:"RxDatabase"}),". In the following you can see some examples for some of the most common SQLite packages."]}),"\n",(0,a.jsxs)(t.h2,{id:"usage-with-nodejs-sqlite",children:["Usage with ",(0,a.jsx)(t.strong,{children:"Node.js SQLite"})]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-ts",children:"import {\n createRxDatabase\n} from 'rxdb';\nimport {\n getRxStorageSQLite,\n getSQLiteBasicsNode\n} from 'rxdb-premium/plugins/storage-sqlite';\n\n/**\n * In Node.js, we use the SQLite database\n * from the 'sqlite' npm module.\n * @link https://www.npmjs.com/package/sqlite3\n */\nimport sqlite3 from 'sqlite3';\n\nconst myRxDatabase = await createRxDatabase({\n name: 'exampledb',\n storage: getRxStorageSQLite({\n /**\n * Different runtimes have different interfaces to SQLite.\n * For example in node.js we have a callback API,\n * while in capacitor sqlite we have Promises.\n * So we need a helper object that is capable of doing the basic\n * sqlite operations.\n */\n sqliteBasics: getSQLiteBasicsNode(sqlite3)\n })\n});\n"})}),"\n",(0,a.jsx)(t.h2,{id:"usage-with-webassembly-in-the-browser",children:"Usage with Webassembly in the Browser"}),"\n",(0,a.jsxs)(t.p,{children:["In the browser you can use the ",(0,a.jsx)(t.a,{href:"https://github.com/rhashimoto/wa-sqlite",children:"wa-sqlite"})," package to run sQLite in Webassembly. The wa-sqlite module also allows to use persistence with IndexedDB or OPFS."]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-ts",children:"import {\n createRxDatabase\n} from 'rxdb';\nimport {\n getRxStorageSQLite,\n getSQLiteBasicsWasm\n} from 'rxdb-premium/plugins/storage-sqlite';\n\n/**\n * In the Browser, we use the SQLite database\n * from the 'wa-sqlite' npm module. This contains the SQLite library\n * compiled to Webassembly\n * @link https://www.npmjs.com/package/wa-sqlite\n */\nimport SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite-async.mjs';\nimport SQLite from 'wa-sqlite';\nconst sqliteModule = await SQLiteESMFactory();\nconst sqlite3 = SQLite.Factory(module);\n\nconst myRxDatabase = await createRxDatabase({\n name: 'exampledb',\n storage: getRxStorageSQLite({\n sqliteBasics: getSQLiteBasicsWasm(sqlite3)\n })\n});\n"})}),"\n",(0,a.jsxs)(t.h2,{id:"usage-with-react-native",children:["Usage with ",(0,a.jsx)(t.strong,{children:"React Native"})]}),"\n",(0,a.jsxs)(t.ol,{children:["\n",(0,a.jsxs)(t.li,{children:["Install the ",(0,a.jsx)(t.a,{href:"https://www.npmjs.com/package/react-native-quick-sqlite",children:"react-native-quick-sqlite npm module"})]}),"\n",(0,a.jsxs)(t.li,{children:["Import ",(0,a.jsx)(t.code,{children:"getSQLiteBasicsQuickSQLite"})," from the SQLite plugin and use it to create a ",(0,a.jsx)(t.a,{href:"/rx-database.html",children:"RxDatabase"}),":"]}),"\n"]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-ts",children:"import {\n createRxDatabase\n} from 'rxdb';\nimport {\n getRxStorageSQLite,\n getSQLiteBasicsQuickSQLite\n} from 'rxdb-premium/plugins/storage-sqlite';\nimport { open } from 'react-native-quick-sqlite';\n\n// create database\nconst myRxDatabase = await createRxDatabase({\n name: 'exampledb',\n multiInstance: false, // <- Set multiInstance to false when using RxDB in React Native\n storage: getRxStorageSQLite({\n sqliteBasics: getSQLiteBasicsQuickSQLite(open)\n })\n});\n"})}),"\n",(0,a.jsxs)(t.p,{children:["If ",(0,a.jsx)(t.code,{children:"react-native-quick-sqlite"})," does not work for you, as alternative you can use the ",(0,a.jsx)(t.a,{href:"https://www.npmjs.com/package/react-native-sqlite-2",children:"react-native-sqlite-2"})," library instead:"]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-ts",children:"import {\n getRxStorageSQLite,\n getSQLiteBasicsWebSQL\n} from 'rxdb-premium/plugins/storage-sqlite';\nimport SQLite from 'react-native-sqlite-2';\nconst storage = getRxStorageSQLite({\n sqliteBasics: getSQLiteBasicsWebSQL(SQLite.openDatabase)\n});\n"})}),"\n",(0,a.jsxs)(t.h2,{id:"usage-with-sqlite-capacitor",children:["Usage with ",(0,a.jsx)(t.strong,{children:"SQLite Capacitor"})]}),"\n",(0,a.jsxs)(t.ol,{children:["\n",(0,a.jsxs)(t.li,{children:["Install the ",(0,a.jsx)(t.a,{href:"https://github.com/capacitor-community/sqlite",children:"sqlite capacitor npm module"})]}),"\n",(0,a.jsx)(t.li,{children:"Add the iOS database location to your capacitor config"}),"\n"]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-json",children:'{\n "plugins": {\n "CapacitorSQLite": {\n "iosDatabaseLocation": "Library/CapacitorDatabase"\n }\n }\n}\n'})}),"\n",(0,a.jsxs)(t.ol,{start:"3",children:["\n",(0,a.jsxs)(t.li,{children:["Use the function ",(0,a.jsx)(t.code,{children:"getSQLiteBasicsCapacitor"})," to get the capacitor sqlite wrapper."]}),"\n"]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-ts",children:"import {\n createRxDatabase\n} from 'rxdb';\nimport {\n getRxStorageSQLite,\n getSQLiteBasicsCapacitor\n} from 'rxdb-premium/plugins/storage-sqlite';\n\n/**\n * Import SQLite from the capacitor plugin.\n */\nimport {\n CapacitorSQLite,\n SQLiteConnection\n} from '@capacitor-community/sqlite';\nimport { Capacitor } from '@capacitor/core';\n\nconst sqlite = new SQLiteConnection(CapacitorSQLite);\n\nconst myRxDatabase = await createRxDatabase({\n name: 'exampledb',\n storage: getRxStorageSQLite({\n /**\n * Different runtimes have different interfaces to SQLite.\n * For example in node.js we have a callback API,\n * while in capacitor sqlite we have Promises.\n * So we need a helper object that is capable of doing the basic\n * sqlite operations.\n */\n sqliteBasics: getSQLiteBasicsCapacitor(sqlite, Capacitor)\n })\n});\n"})}),"\n",(0,a.jsx)(t.h2,{id:"database-connection",children:"Database Connection"}),"\n",(0,a.jsxs)(t.p,{children:["If you need to access the database connection for any reason you can use ",(0,a.jsx)(t.code,{children:"getDatabaseConnection"})," to do so:"]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-ts",children:"import { getDatabaseConnection } from 'rxdb-premium/plugins/storage-sqlite'\n"})}),"\n",(0,a.jsx)(t.p,{children:"It has the following signature:"}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-ts",children:"getDatabaseConnection(\n sqliteBasics: SQLiteBasics,\n databaseName: string\n): Promise;\n"})}),"\n",(0,a.jsx)(t.h2,{id:"known-problems-of-sqlite-in-javascript-apps",children:"Known Problems of SQLite in JavaScript apps"}),"\n",(0,a.jsxs)(t.ul,{children:["\n",(0,a.jsxs)(t.li,{children:["\n",(0,a.jsxs)(t.p,{children:["Some JavaScript runtimes do not contain a ",(0,a.jsx)(t.code,{children:"Buffer"})," API which is used by SQLite to store binary attachments data as ",(0,a.jsx)(t.code,{children:"BLOB"}),". You can set ",(0,a.jsx)(t.code,{children:"storeAttachmentsAsBase64String: true"})," if you want to store the attachments data as base64 string instead. This increases the database size but makes it work even without having a ",(0,a.jsx)(t.code,{children:"Buffer"}),"."]}),"\n"]}),"\n",(0,a.jsxs)(t.li,{children:["\n",(0,a.jsxs)(t.p,{children:["The SQlite RxStorage works on SQLite libraries that use SQLite in version ",(0,a.jsx)(t.code,{children:"3.38.0 (2022-02-22)"})," or newer, because it uses the ",(0,a.jsx)(t.a,{href:"https://www.sqlite.org/json1.html",children:"SQLite JSON"})," methods like ",(0,a.jsx)(t.code,{children:"JSON_EXTRACT"}),". If you get an error like ",(0,a.jsx)(t.code,{children:"[Error: no such function: JSON_EXTRACT (code 1 SQLITE_ERROR[1])"}),", you might have a too old version of SQLite."]}),"\n"]}),"\n",(0,a.jsxs)(t.li,{children:["\n",(0,a.jsxs)(t.p,{children:[(0,a.jsx)(t.a,{href:"https://www.npmjs.com/package/expo-sqlite",children:"expo-sqlite"})," cannot be used on android (but it works on iOS) because it uses an ",(0,a.jsx)(t.a,{href:"https://expo.canny.io/feature-requests/p/expo-sqlite-ship-newer-sqlite3-version-on-android",children:"outdated SQLite version"}),". This is fixed if you use Expo SDK version 50 or never."]}),"\n"]}),"\n",(0,a.jsxs)(t.li,{children:["\n",(0,a.jsxs)(t.p,{children:["To debug all SQL operations, you can pass a log function to ",(0,a.jsx)(t.code,{children:"getRxStorageSQLite()"})," like this:"]}),"\n"]}),"\n"]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-ts",children:"const storage = getRxStorageSQLite({\n sqliteBasics: getSQLiteBasicsCapacitor(sqlite, Capacitor),\n // pass log function\n log: console.log.bind(console)\n});\n"})}),"\n",(0,a.jsx)(t.h2,{id:"related",children:"Related"}),"\n",(0,a.jsxs)(t.ul,{children:["\n",(0,a.jsx)(t.li,{children:(0,a.jsx)(t.a,{href:"/react-native-database.html",children:"React Native Databases"})}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,a.jsx)(t,{...e,children:(0,a.jsx)(d,{...e})}):d(e)}},8453:(e,t,s)=>{s.d(t,{R:()=>r,x:()=>o});var a=s(6540);const i={},n=a.createContext(i);function r(e){const t=a.useContext(n);return a.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:r(e.components),a.createElement(n.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/docs/assets/js/4ed9495b.f857df51.js b/docs/assets/js/4ed9495b.f857df51.js deleted file mode 100644 index 5b44e11a863..00000000000 --- a/docs/assets/js/4ed9495b.f857df51.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[1199],{1787:(e,t,a)=>{a.r(t),a.d(t,{assets:()=>c,contentTitle:()=>r,default:()=>h,frontMatter:()=>n,metadata:()=>o,toc:()=>l});var s=a(4848),i=a(8453);const n={title:"SQLite RxStorage \ud83d\udc51",slug:"rx-storage-sqlite.html"},r="SQLite RxStorage",o={id:"rx-storage-sqlite",title:"SQLite RxStorage \ud83d\udc51",description:"This RxStorage is based on SQLite and is made to work with Node.js, Electron, React Native and Capacitor or SQLite via wasm in the browser. It can be used with different so called sqliteBasics adapters to account for the differences in the various SQLite bundles and libraries that exist.",source:"@site/docs/rx-storage-sqlite.md",sourceDirName:".",slug:"/rx-storage-sqlite.html",permalink:"/rx-storage-sqlite.html",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"SQLite RxStorage \ud83d\udc51",slug:"rx-storage-sqlite.html"},sidebar:"tutorialSidebar",previous:{title:"IndexedDB RxStorage \ud83d\udc51",permalink:"/rx-storage-indexeddb.html"},next:{title:"Memory RxStorage",permalink:"/rx-storage-memory.html"}},c={},l=[{value:"Performance comparison with other storages",id:"performance-comparison-with-other-storages",level:2},{value:"Using the SQLite RxStorage",id:"using-the-sqlite-rxstorage",level:2},{value:"Usage with Node.js SQLite",id:"usage-with-nodejs-sqlite",level:2},{value:"Usage with React Native",id:"usage-with-react-native",level:2},{value:"Usage with SQLite Capacitor",id:"usage-with-sqlite-capacitor",level:2},{value:"Database Connection",id:"database-connection",level:2},{value:"Known Problems of SQLite in JavaScript apps",id:"known-problems-of-sqlite-in-javascript-apps",level:2},{value:"Related",id:"related",level:2}];function d(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h1,{id:"sqlite-rxstorage",children:"SQLite RxStorage"}),"\n",(0,s.jsxs)(t.p,{children:["This ",(0,s.jsx)(t.a,{href:"/rx-storage.html",children:"RxStorage"})," is based on ",(0,s.jsx)(t.a,{href:"https://www.sqlite.org/index.html",children:"SQLite"})," and is made to work with ",(0,s.jsx)(t.strong,{children:"Node.js"}),", ",(0,s.jsx)(t.a,{href:"/electron-database.html",children:"Electron"}),", ",(0,s.jsx)(t.a,{href:"/react-native-database.html",children:"React Native"})," and ",(0,s.jsx)(t.a,{href:"/capacitor-database.html",children:"Capacitor"})," or SQLite via wasm in the browser. It can be used with different so called ",(0,s.jsx)(t.code,{children:"sqliteBasics"})," adapters to account for the differences in the various SQLite bundles and libraries that exist."]}),"\n",(0,s.jsx)(t.h2,{id:"performance-comparison-with-other-storages",children:"Performance comparison with other storages"}),"\n",(0,s.jsxs)(t.p,{children:["The SQLite storage is a bit slower compared to other Node.js based storages like the ",(0,s.jsx)(t.a,{href:"/rx-storage-filesystem-node.html",children:"Filesystem Storage"})," because wrapping SQLite has a bit of overhead and sending data from the JavaScript process to SQLite and backwards increases the latency. However for most hybrid apps the SQLite storage is the best option because it can leverage the SQLite version that comes already installed on the smartphones OS (iOS and android). Also for desktop electron apps it can be a viable solution because it is easy to ship SQLite together inside of the electron bundle."]}),"\n",(0,s.jsx)("p",{align:"center",children:(0,s.jsx)("img",{src:"./files/rx-storage-performance-node.png",alt:"SQLite performance - Node.js",width:"700"})}),"\n",(0,s.jsx)(t.h2,{id:"using-the-sqlite-rxstorage",children:"Using the SQLite RxStorage"}),"\n",(0,s.jsxs)(t.p,{children:["To use the SQLite storage you have to import ",(0,s.jsx)(t.code,{children:"getRxStorageSQLite"})," from the ",(0,s.jsx)(t.a,{href:"/premium",children:"RxDB Premium \ud83d\udc51"})," package and then add the correct ",(0,s.jsx)(t.code,{children:"sqliteBasics"})," adapter depending on which sqlite module you want to use. This can then be used as storage when creating the ",(0,s.jsx)(t.a,{href:"/rx-database.html",children:"RxDatabase"}),". In the following you can see some examples for some of the most common SQLite packages."]}),"\n",(0,s.jsxs)(t.h2,{id:"usage-with-nodejs-sqlite",children:["Usage with ",(0,s.jsx)(t.strong,{children:"Node.js SQLite"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"import {\n createRxDatabase\n} from 'rxdb';\nimport {\n getRxStorageSQLite,\n getSQLiteBasicsNode\n} from 'rxdb-premium/plugins/storage-sqlite';\n\n/**\n * In Node.js, we get use the SQLite database\n * from the 'sqlite' npm module.\n * @link https://www.npmjs.com/package/sqlite3\n */\nimport sqlite3 from 'sqlite3';\n\nconst myRxDatabase = await createRxDatabase({\n name: 'exampledb',\n storage: getRxStorageSQLite({\n /**\n * Different runtimes have different interfaces to SQLite.\n * For example in node.js we have a callback API,\n * while in capacitor sqlite we have Promises.\n * So we need a helper object that is capable of doing the basic\n * sqlite operations.\n */\n sqliteBasics: getSQLiteBasicsNode(sqlite3)\n })\n});\n"})}),"\n",(0,s.jsxs)(t.h2,{id:"usage-with-react-native",children:["Usage with ",(0,s.jsx)(t.strong,{children:"React Native"})]}),"\n",(0,s.jsxs)(t.ol,{children:["\n",(0,s.jsxs)(t.li,{children:["Install the ",(0,s.jsx)(t.a,{href:"https://www.npmjs.com/package/react-native-quick-sqlite",children:"react-native-quick-sqlite npm module"})]}),"\n",(0,s.jsxs)(t.li,{children:["Import ",(0,s.jsx)(t.code,{children:"getSQLiteBasicsQuickSQLite"})," from the SQLite plugin and use it to create a ",(0,s.jsx)(t.a,{href:"/rx-database.html",children:"RxDatabase"}),":"]}),"\n"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"import {\n createRxDatabase\n} from 'rxdb';\nimport {\n getRxStorageSQLite,\n getSQLiteBasicsQuickSQLite\n} from 'rxdb-premium/plugins/storage-sqlite';\nimport { open } from 'react-native-quick-sqlite';\n\n// create database\nconst myRxDatabase = await createRxDatabase({\n name: 'exampledb',\n multiInstance: false, // <- Set multiInstance to false when using RxDB in React Native\n storage: getRxStorageSQLite({\n sqliteBasics: getSQLiteBasicsQuickSQLite(open)\n })\n});\n"})}),"\n",(0,s.jsxs)(t.p,{children:["If ",(0,s.jsx)(t.code,{children:"react-native-quick-sqlite"})," does not work for you, as alternative you can use the ",(0,s.jsx)(t.a,{href:"https://www.npmjs.com/package/react-native-sqlite-2",children:"react-native-sqlite-2"})," library instead:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"import {\n getRxStorageSQLite,\n getSQLiteBasicsWebSQL\n} from 'rxdb-premium/plugins/storage-sqlite';\nimport SQLite from 'react-native-sqlite-2';\nconst storage = getRxStorageSQLite({\n sqliteBasics: getSQLiteBasicsWebSQL(SQLite.openDatabase)\n});\n"})}),"\n",(0,s.jsxs)(t.h2,{id:"usage-with-sqlite-capacitor",children:["Usage with ",(0,s.jsx)(t.strong,{children:"SQLite Capacitor"})]}),"\n",(0,s.jsxs)(t.ol,{children:["\n",(0,s.jsxs)(t.li,{children:["Install the ",(0,s.jsx)(t.a,{href:"https://github.com/capacitor-community/sqlite",children:"sqlite capacitor npm module"})]}),"\n",(0,s.jsx)(t.li,{children:"Add the iOS database location to your capacitor config"}),"\n"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-json",children:'{\n "plugins": {\n "CapacitorSQLite": {\n "iosDatabaseLocation": "Library/CapacitorDatabase"\n }\n }\n}\n'})}),"\n",(0,s.jsxs)(t.ol,{start:"3",children:["\n",(0,s.jsxs)(t.li,{children:["Use the function ",(0,s.jsx)(t.code,{children:"getSQLiteBasicsCapacitor"})," to get the capacitor sqlite wrapper."]}),"\n"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"import {\n createRxDatabase\n} from 'rxdb';\nimport {\n getRxStorageSQLite,\n getSQLiteBasicsCapacitor\n} from 'rxdb-premium/plugins/storage-sqlite';\n\n/**\n * Import SQLite from the capacitor plugin.\n */\nimport {\n CapacitorSQLite,\n SQLiteConnection\n} from '@capacitor-community/sqlite';\nimport { Capacitor } from '@capacitor/core';\n\nconst sqlite = new SQLiteConnection(CapacitorSQLite);\n\nconst myRxDatabase = await createRxDatabase({\n name: 'exampledb',\n storage: getRxStorageSQLite({\n /**\n * Different runtimes have different interfaces to SQLite.\n * For example in node.js we have a callback API,\n * while in capacitor sqlite we have Promises.\n * So we need a helper object that is capable of doing the basic\n * sqlite operations.\n */\n sqliteBasics: getSQLiteBasicsCapacitor(sqlite, Capacitor)\n })\n});\n"})}),"\n",(0,s.jsx)(t.h2,{id:"database-connection",children:"Database Connection"}),"\n",(0,s.jsxs)(t.p,{children:["If you need to access the database connection for any reason you can use ",(0,s.jsx)(t.code,{children:"getDatabaseConnection"})," to do so:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"import { getDatabaseConnection } from 'rxdb-premium/plugins/storage-sqlite'\n"})}),"\n",(0,s.jsx)(t.p,{children:"It has the following signature:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"getDatabaseConnection(\n sqliteBasics: SQLiteBasics,\n databaseName: string\n): Promise;\n"})}),"\n",(0,s.jsx)(t.h2,{id:"known-problems-of-sqlite-in-javascript-apps",children:"Known Problems of SQLite in JavaScript apps"}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:["\n",(0,s.jsxs)(t.p,{children:["Some JavaScript runtimes do not contain a ",(0,s.jsx)(t.code,{children:"Buffer"})," API which is used by SQLite to store binary attachments data as ",(0,s.jsx)(t.code,{children:"BLOB"}),". You can set ",(0,s.jsx)(t.code,{children:"storeAttachmentsAsBase64String: true"})," if you want to store the attachments data as base64 string instead. This increases the database size but makes it work even without having a ",(0,s.jsx)(t.code,{children:"Buffer"}),"."]}),"\n"]}),"\n",(0,s.jsxs)(t.li,{children:["\n",(0,s.jsxs)(t.p,{children:["The SQlite RxStorage works on SQLite libraries that use SQLite in version ",(0,s.jsx)(t.code,{children:"3.38.0 (2022-02-22)"})," or newer, because it uses the ",(0,s.jsx)(t.a,{href:"https://www.sqlite.org/json1.html",children:"SQLite JSON"})," methods like ",(0,s.jsx)(t.code,{children:"JSON_EXTRACT"}),". If you get an error like ",(0,s.jsx)(t.code,{children:"[Error: no such function: JSON_EXTRACT (code 1 SQLITE_ERROR[1])"}),", you might have a too old version of SQLite."]}),"\n"]}),"\n",(0,s.jsxs)(t.li,{children:["\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.a,{href:"https://www.npmjs.com/package/expo-sqlite",children:"expo-sqlite"})," cannot be used on android (but it works on iOS) because it uses an ",(0,s.jsx)(t.a,{href:"https://expo.canny.io/feature-requests/p/expo-sqlite-ship-newer-sqlite3-version-on-android",children:"outdated SQLite version"}),". This is fixed if you use Expo SDK version 50 or never."]}),"\n"]}),"\n",(0,s.jsxs)(t.li,{children:["\n",(0,s.jsxs)(t.p,{children:["To debug all SQL operations, you can pass a log function to ",(0,s.jsx)(t.code,{children:"getRxStorageSQLite()"})," like this:"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const storage = getRxStorageSQLite({\n sqliteBasics: getSQLiteBasicsCapacitor(sqlite, Capacitor),\n // pass log function\n log: console.log.bind(console)\n});\n"})}),"\n",(0,s.jsx)(t.h2,{id:"related",children:"Related"}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsx)(t.li,{children:(0,s.jsx)(t.a,{href:"/react-native-database.html",children:"React Native Databases"})}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},8453:(e,t,a)=>{a.d(t,{R:()=>r,x:()=>o});var s=a(6540);const i={},n=s.createContext(i);function r(e){const t=s.useContext(n);return s.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:r(e.components),s.createElement(n.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/docs/assets/js/935f2afb.dfc6d928.js b/docs/assets/js/935f2afb.4cf455a3.js similarity index 94% rename from docs/assets/js/935f2afb.dfc6d928.js rename to docs/assets/js/935f2afb.4cf455a3.js index 027223a1771..2aec14c8322 100644 --- a/docs/assets/js/935f2afb.dfc6d928.js +++ b/docs/assets/js/935f2afb.4cf455a3.js @@ -1 +1 @@ -"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[8581],{5610:e=>{e.exports=JSON.parse('{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"tutorialSidebar":[{"type":"link","label":"\ud83d\ude80 Quickstart","href":"/quickstart.html","docId":"quickstart","unlisted":false},{"type":"link","label":"Installation","href":"/install.html","docId":"install","unlisted":false},{"type":"link","label":"Dev-Mode Plugin","href":"/dev-mode.html","docId":"dev-mode","unlisted":false},{"type":"link","label":"RxDatabase","href":"/rx-database.html","docId":"rx-database","unlisted":false},{"type":"link","label":"RxSchema","href":"/rx-schema.html","docId":"rx-schema","unlisted":false},{"type":"link","label":"RxCollection","href":"/rx-collection.html","docId":"rx-collection","unlisted":false},{"type":"link","label":"RxDocument","href":"/rx-document.html","docId":"rx-document","unlisted":false},{"type":"link","label":"RxQuery","href":"/rx-query.html","docId":"rx-query","unlisted":false},{"type":"link","label":"Attachments","href":"/rx-attachment.html","docId":"rx-attachment","unlisted":false},{"type":"category","label":"\ud83d\udcbe RxStorage","items":[{"type":"link","label":"\u2699\ufe0f Rxstorage Layer","href":"/rx-storage.html","docId":"rx-storage","unlisted":false},{"type":"link","label":"\ud83d\udcc8 RxStorage Performance","href":"/rx-storage-performance.html","docId":"rx-storage-performance","unlisted":false},{"type":"link","label":"IndexedDB RxStorage \ud83d\udc51","href":"/rx-storage-indexeddb.html","docId":"rx-storage-indexeddb","unlisted":false},{"type":"link","label":"SQLite RxStorage \ud83d\udc51","href":"/rx-storage-sqlite.html","docId":"rx-storage-sqlite","unlisted":false},{"type":"link","label":"Memory RxStorage","href":"/rx-storage-memory.html","docId":"rx-storage-memory","unlisted":false},{"type":"link","label":"Dexie.js RxStorage","href":"/rx-storage-dexie.html","docId":"rx-storage-dexie","unlisted":false},{"type":"link","label":"OPFS RxStorage \ud83d\udc51","href":"/rx-storage-opfs.html","docId":"rx-storage-opfs","unlisted":false},{"type":"link","label":"Node.js Filesystem RxStorage \ud83d\udc51","href":"/rx-storage-filesystem-node.html","docId":"rx-storage-filesystem-node","unlisted":false},{"type":"link","label":"MongoDB RxStorage","href":"/rx-storage-mongodb.html","docId":"rx-storage-mongodb","unlisted":false},{"type":"link","label":"DenoKV RxStorage","href":"/rx-storage-denokv.html","docId":"rx-storage-denokv","unlisted":false},{"type":"link","label":"FoundationDB RxStorage","href":"/rx-storage-foundationdb.html","docId":"rx-storage-foundationdb","unlisted":false},{"type":"link","label":"LokiJS RxStorage","href":"/rx-storage-lokijs.html","docId":"rx-storage-lokijs","unlisted":false},{"type":"link","label":"Remote RxStorage","href":"/rx-storage-remote.html","docId":"rx-storage-remote","unlisted":false},{"type":"link","label":"Worker RxStorage \ud83d\udc51","href":"/rx-storage-worker.html","docId":"rx-storage-worker","unlisted":false},{"type":"link","label":"SharedWorker RxStorage \ud83d\udc51","href":"/rx-storage-shared-worker.html","docId":"rx-storage-shared-worker","unlisted":false},{"type":"link","label":"Memory Synced RxStorage \ud83d\udc51","href":"/rx-storage-memory-synced.html","docId":"rx-storage-memory-synced","unlisted":false},{"type":"link","label":"Sharding RxStorage \ud83d\udc51","href":"/rx-storage-sharding.html","docId":"rx-storage-sharding","unlisted":false},{"type":"link","label":"RxStorage Localstorage Meta Optimizer \ud83d\udc51","href":"/rx-storage-localstorage-meta-optimizer.html","docId":"rx-storage-localstorage-meta-optimizer","unlisted":false},{"type":"link","label":"Electron Plugin","href":"/electron.html","docId":"electron","unlisted":false}],"collapsed":true,"collapsible":true},{"type":"category","label":"\ud83d\udd04 Replication","items":[{"type":"link","label":"\u2699\ufe0f Replication Protocol","href":"/replication.html","docId":"replication","unlisted":false},{"type":"link","label":"HTTP Replication","href":"/replication-http.html","docId":"replication-http","unlisted":false},{"type":"link","label":"RxDB Server Replication","href":"/replication-server","docId":"replication-server","unlisted":false},{"type":"link","label":"GraphQL Replication","href":"/replication-graphql.html","docId":"replication-graphql","unlisted":false},{"type":"link","label":"Websocket Replication","href":"/replication-websocket.html","docId":"replication-websocket","unlisted":false},{"type":"link","label":"CouchDB Replication","href":"/replication-couchdb.html","docId":"replication-couchdb","unlisted":false},{"type":"link","label":"WebRTC Replication","href":"/replication-webrtc.html","docId":"replication-webrtc","unlisted":false},{"type":"link","label":"Firestore Replication","href":"/replication-firestore.html","docId":"replication-firestore","unlisted":false},{"type":"link","label":"NATS Replication","href":"/replication-nats.html","docId":"replication-nats","unlisted":false}],"collapsed":true,"collapsible":true},{"type":"category","label":"Server","items":[{"type":"link","label":"RxServer","href":"/rx-server.html","docId":"rx-server","unlisted":false},{"type":"link","label":"RxServer Scaling","href":"/rx-server-scaling.html","docId":"rx-server-scaling","unlisted":false}],"collapsed":true,"collapsible":true},{"type":"category","label":"Migration","items":[{"type":"link","label":"Migration Schema","href":"/migration-schema.html","docId":"migration-schema","unlisted":false},{"type":"link","label":"Migration Storage","href":"/migration-storage.html","docId":"migration-storage","unlisted":false}],"collapsed":true,"collapsible":true},{"type":"link","label":"Signals & Custom Reactivity","href":"/reactivity.html","docId":"reactivity","unlisted":false},{"type":"link","label":"RxState","href":"/rx-state.html","docId":"rx-state","unlisted":false},{"type":"link","label":"Local Documents","href":"/rx-local-document.html","docId":"rx-local-document","unlisted":false},{"type":"link","label":"Encryption","href":"/encryption.html","docId":"encryption","unlisted":false},{"type":"link","label":"Key Compression","href":"/key-compression.html","docId":"key-compression","unlisted":false},{"type":"link","label":"Leader Election","href":"/leader-election.html","docId":"leader-election","unlisted":false},{"type":"link","label":"Cleanup","href":"/cleanup.html","docId":"cleanup","unlisted":false},{"type":"link","label":"Backup","href":"/backup.html","docId":"backup","unlisted":false},{"type":"link","label":"Transactions, Conflicts and Revisions","href":"/transactions-conflicts-revisions.html","docId":"transactions-conflicts-revisions","unlisted":false},{"type":"link","label":"Middleware","href":"/middleware.html","docId":"middleware","unlisted":false},{"type":"link","label":"Query Cache","href":"/query-cache.html","docId":"query-cache","unlisted":false},{"type":"link","label":"CRDT - Conflict-free replicated data type Database","href":"/crdt.html","docId":"crdt","unlisted":false},{"type":"link","label":"Population","href":"/population.html","docId":"population","unlisted":false},{"type":"link","label":"ORM","href":"/orm.html","docId":"orm","unlisted":false},{"type":"link","label":"Query Optimizer \ud83d\udc51","href":"/query-optimizer.html","docId":"query-optimizer","unlisted":false},{"type":"link","label":"Logger \ud83d\udc51","href":"/logger.html","docId":"logger","unlisted":false},{"type":"link","label":"Plugins","href":"/plugins.html","docId":"plugins","unlisted":false},{"type":"link","label":"RxDB NoSQL Performance Tips","href":"/nosql-performance-tips.html","docId":"nosql-performance-tips","unlisted":false},{"type":"link","label":"Third Party Plugins","href":"/third-party-plugins.html","docId":"third-party-plugins","unlisted":false},{"type":"category","label":"Tutorials","items":[{"type":"link","label":"RxDB TypeScript Tutorial","href":"/tutorials/typescript.html","docId":"tutorials/typescript","unlisted":false},{"type":"link","label":"Node.js Database","href":"/nodejs-database.html","docId":"nodejs-database","unlisted":false}],"collapsed":true,"collapsible":true},{"type":"link","label":"Questions and Answers","href":"/questions-answers.html","docId":"questions-answers","unlisted":false},{"type":"link","label":"Contribute to RxDB","href":"/contribution.html","docId":"contribute","unlisted":false},{"type":"category","label":"\ud83c\udd95 Releases","items":[{"type":"link","label":"\ud83c\udd95 RxDB 15.0.0","href":"/releases/15.0.0.html","docId":"releases/15.0.0","unlisted":false},{"type":"link","label":"RxDB 14.0.0","href":"/releases/14.0.0.html","docId":"releases/14.0.0","unlisted":false},{"type":"link","label":"RxDB 13.0.0","href":"/releases/13.0.0.html","docId":"releases/13.0.0","unlisted":false},{"type":"link","label":"RxDB 12.0.0","href":"/releases/12.0.0.html","docId":"releases/12.0.0","unlisted":false},{"type":"link","label":"RxDB 11.0.0","href":"/releases/11.0.0.html","docId":"releases/11.0.0","unlisted":false},{"type":"link","label":"RxDB 10.0.0","href":"/releases/10.0.0.html","docId":"releases/10.0.0","unlisted":false},{"type":"link","label":"RxDB 9.0.0","href":"/releases/9.0.0.html","docId":"releases/9.0.0","unlisted":false},{"type":"link","label":"RxDB 8.0.0","href":"/releases/8.0.0.html","docId":"releases/8.0.0","unlisted":false}],"collapsed":true,"collapsible":true},{"type":"category","label":"Articles","items":[{"type":"link","label":"Local First / Offline First","href":"/offline-first.html","docId":"offline-first","unlisted":false},{"type":"link","label":"Downsides of Local First / Offline First","href":"/downsides-of-offline-first.html","docId":"downsides-of-offline-first","unlisted":false},{"type":"link","label":"Slow IndexedDB","href":"/slow-indexeddb.html","docId":"slow-indexeddb","unlisted":false},{"type":"link","label":"Why NOSQL","href":"/why-nosql.html","docId":"why-nosql","unlisted":false},{"type":"link","label":"React Native Database","href":"/react-native-database.html","docId":"react-native-database","unlisted":false},{"type":"link","label":"Alternatives for realtime offline-first JavaScript applications and local databases","href":"/alternatives.html","docId":"alternatives","unlisted":false},{"type":"link","label":"RxDB as a Database in an Angular Application","href":"/articles/angular-database.html","docId":"articles/angular-database","unlisted":false},{"type":"link","label":"The benefits of Browser Databases and RxDB","href":"/articles/browser-database.html","docId":"articles/browser-database","unlisted":false},{"type":"link","label":"Browser Storage - RxDB as a Database for Browsers","href":"/articles/browser-storage.html","docId":"articles/browser-storage","unlisted":false},{"type":"link","label":"RxDB as a data base - Empowering Web Applications with Reactive Data Handling","href":"/articles/data-base.html","docId":"articles/data-base","unlisted":false},{"type":"link","label":"Using RxDB as an Embedded Database","href":"/articles/embedded-database.html","docId":"articles/embedded-database","unlisted":false},{"type":"link","label":"RxDB as a Database in a Flutter Application","href":"/articles/flutter-database.html","docId":"articles/flutter-database","unlisted":false},{"type":"link","label":"RxDB JavaScript Frontend Database - Efficient Data Storage in Frontend Applications","href":"/articles/frontend-database.html","docId":"articles/frontend-database","unlisted":false},{"type":"link","label":"RxDB as In-memory NoSQL Database - Empowering Real-Time Applications","href":"/articles/in-memory-nosql-database.html","docId":"articles/in-memory-nosql-database","unlisted":false},{"type":"link","label":"Ionic Storage - RxDB as database for hybrid apps","href":"/articles/ionic-database.html","docId":"articles/ionic-database","unlisted":false},{"type":"link","label":"RxDB - JSON Database for JavaScript","href":"/articles/json-database.html","docId":"articles/json-database","unlisted":false},{"type":"link","label":"Using localStorage in Modern Applications - A Comprehensive Guide","href":"/articles/localstorage.html","docId":"articles/localstorage","unlisted":false},{"type":"link","label":"Mobile Database - RxDB as Database for Mobile Applications","href":"/articles/mobile-database.html","docId":"articles/mobile-database","unlisted":false},{"type":"link","label":"RxDB as a Database for Progressive Web Apps (PWA)","href":"/articles/progressive-web-app-database.html","docId":"articles/progressive-web-app-database","unlisted":false},{"type":"link","label":"RxDB as a Database for React Applications","href":"/articles/react-database.html","docId":"articles/react-database","unlisted":false},{"type":"link","label":"What is a realtime database?","href":"/articles/realtime-database.html","docId":"articles/realtime-database","unlisted":false},{"type":"link","label":"Capacitor Database - SQLite, RxDB and others","href":"/capacitor-database.html","docId":"capacitor-database","unlisted":false},{"type":"link","label":"Electron Database - Storage adapters for SQLite, Filesystem and In-Memory","href":"/electron-database.html","docId":"electron-database","unlisted":false}],"collapsed":true,"collapsible":true}]},"docs":{"adapters":{"id":"adapters","title":"PouchDB Adapters","description":"When you use PouchDB RxStorage, there are many adapters that define where the data has to be stored."},"alternatives":{"id":"alternatives","title":"Alternatives for realtime offline-first JavaScript applications and local databases","description":"Explore real-time, offline-first JS alternatives to RxDB. Compare Firebase, Meteor, AWS, CouchDB, and more for robust, seamless web/mobile app development.","sidebar":"tutorialSidebar"},"articles/angular-database":{"id":"articles/angular-database","title":"RxDB as a Database in an Angular Application","description":"Discover the RxDB Revolution for Angular Apps! \ud83d\ude80 Learn how to supercharge your web applications with RxDB\'s reactive, offline-first database capabilities. Master real-time data synchronization and build ultra-responsive Angular applications. Click now for expert tips and techniques that will elevate your development game!","sidebar":"tutorialSidebar"},"articles/browser-database":{"id":"articles/browser-database","title":"The benefits of Browser Databases and RxDB","description":"In the world of web development, efficient data management is a cornerstone of building successful and performant applications. The ability to store data directly in the browser brings numerous advantages, such as caching, offline accessibility, simplified replication of database state, and real-time application development. In this article, we will explore RxDB, a powerful browser JavaScript database, and understand why it is an excellent choice for implementing a browser database solution.","sidebar":"tutorialSidebar"},"articles/browser-storage":{"id":"articles/browser-storage","title":"Browser Storage - RxDB as a Database for Browsers","description":"Explore RxDB for browser storage its advantages, limitations, and why it outperforms SQL databases in web applications for enhanced efficiency","sidebar":"tutorialSidebar"},"articles/data-base":{"id":"articles/data-base","title":"RxDB as a data base - Empowering Web Applications with Reactive Data Handling","description":"In the world of web applications, efficient data management plays a crucial role in delivering a seamless user experience. As mobile applications continue to dominate the digital landscape, the importance of robust data bases becomes evident. In this article, we will explore RxDB as a powerful data base solution for web applications. We will delve into its features, advantages, and advanced techniques, highlighting its ability to handle reactive data and enable an offline-first approach.","sidebar":"tutorialSidebar"},"articles/embedded-database":{"id":"articles/embedded-database","title":"Using RxDB as an Embedded Database","description":"In modern UI applications, efficient data storage is a crucial aspect for seamless user experiences. One powerful solution for achieving this is by utilizing an embedded database. In this article, we will explore the concept of an embedded database and delve into the benefits of using RxDB as an embedded database in UI applications. We will also discuss why RxDB stands out as a robust choice for real-time applications with embedded database functionality.","sidebar":"tutorialSidebar"},"articles/flutter-database":{"id":"articles/flutter-database","title":"RxDB as a Database in a Flutter Application","description":"In the world of mobile application development, Flutter has gained significant popularity due to its cross-platform capabilities and rich UI framework. When it comes to building feature-rich Flutter applications, the choice of a robust and efficient database is crucial. In this article, we will explore RxDB as a database solution for Flutter applications. We\'ll delve into the core features of RxDB, its benefits over other database options, and how to integrate it into a Flutter app.","sidebar":"tutorialSidebar"},"articles/frontend-database":{"id":"articles/frontend-database","title":"RxDB JavaScript Frontend Database - Efficient Data Storage in Frontend Applications","description":"Explore RxDB as simple frontend database - Learn the benefits of offline access, caching, and improved performance in modern web apps, making RxDB a superior choice over traditional SQL databases.","sidebar":"tutorialSidebar"},"articles/in-memory-nosql-database":{"id":"articles/in-memory-nosql-database","title":"RxDB as In-memory NoSQL Database - Empowering Real-Time Applications","description":"Real-time applications have become increasingly popular in today\'s digital landscape. From instant messaging to collaborative editing tools, the demand for responsive and interactive software is on the rise. To meet these requirements, developers need powerful and efficient database solutions that can handle large amounts of data in real-time. RxDB, an javascript NoSQL database, is revolutionizing the way developers build and scale their applications by offering exceptional speed, flexibility, and scalability.","sidebar":"tutorialSidebar"},"articles/ionic-database":{"id":"articles/ionic-database","title":"Ionic Storage - RxDB as database for hybrid apps","description":"In the fast-paced world of mobile app development, hybrid applications have emerged as a versatile solution, offering the best of both worlds - the web and native app experiences. One key challenge these apps face is efficiently storing and querying data on the client\'s device. Enter RxDB, a powerful client-side database tailored for ionic hybrid applications. In this article, we\'ll explore how RxDB addresses the requirements of storing and querying data in ionic apps, and why it stands out as a preferred choice.","sidebar":"tutorialSidebar"},"articles/json-database":{"id":"articles/json-database","title":"RxDB - JSON Database for JavaScript","description":"Storing data as JSON documents in a NoSQL database is not just a trend; it\'s a practical choice. JSON data is highly compatible with various tools and is human-readable, making it an excellent fit for modern applications. JSON documents offer more flexibility compared to traditional SQL table rows, as they can contain nested data structures. This article introduces RxDB, an open-source, flexible, performant, and battle-tested NoSQL JSON database specifically designed for JavaScript applications.","sidebar":"tutorialSidebar"},"articles/localstorage":{"id":"articles/localstorage","title":"Using localStorage in Modern Applications - A Comprehensive Guide","description":"This guide explores localStorage in JavaScript web apps, detailing its usage, limitations, and alternatives like IndexedDB and AsyncStorage.","sidebar":"tutorialSidebar"},"articles/mobile-database":{"id":"articles/mobile-database","title":"Mobile Database - RxDB as Database for Mobile Applications","description":"In today\'s digital landscape, mobile applications have become an integral part of our lives. From social media platforms to e-commerce solutions, mobile apps have transformed the way we interact with digital services. At the heart of any mobile app lies the database, a critical component responsible for storing, retrieving, and managing data efficiently. In this article, we will delve into the world of mobile databases, exploring their significance, challenges, and the emergence of RxDB as a powerful database solution for hybrid app development in frameworks like React Native and Capacitor.","sidebar":"tutorialSidebar"},"articles/progressive-web-app-database":{"id":"articles/progressive-web-app-database","title":"RxDB as a Database for Progressive Web Apps (PWA)","description":"Progressive Web Apps (PWAs) have revolutionized the digital landscape, offering users an immersive blend of web and native app experiences. At the heart of every successful PWA lies effective data management, and this is where RxDB comes into play. In this article, we\'ll explore the dynamic synergy between RxDB, a robust client-side database, and Progressive Web Apps, uncovering how RxDB enhances data handling, synchronization, and overall performance, propelling PWAs into a new era of excellence.","sidebar":"tutorialSidebar"},"articles/react-database":{"id":"articles/react-database","title":"RxDB as a Database for React Applications","description":"Discover how RxDB enhances React applications by offering efficient data management, real-time updates, and offline capabilities. This article explores RxDB\'s integration with React for dynamic, responsive UIs.","sidebar":"tutorialSidebar"},"articles/realtime-database":{"id":"articles/realtime-database","title":"What is a realtime database?","description":"I have been building RxDB, a NoSQL realtime JavaScript database for many years.","sidebar":"tutorialSidebar"},"backup":{"id":"backup","title":"Backup","description":"With the backup plugin you can write the current database state and ongoing changes into folders on the filesystem.","sidebar":"tutorialSidebar"},"capacitor-database":{"id":"capacitor-database","title":"Capacitor Database - SQLite, RxDB and others","description":"Explore Capacitor\'s database options including SQLite, RxDB, and Preferences API for web-native apps. Learn about their uses, limitations, and integration in this comprehensive guide.","sidebar":"tutorialSidebar"},"cleanup":{"id":"cleanup","title":"Cleanup","description":"To make the replication work, and for other reasons, RxDB has to keep deleted documents in the storage.","sidebar":"tutorialSidebar"},"contribute":{"id":"contribute","title":"Contribute to RxDB","description":"We are open to, and grateful for, any contributions made by the community.","sidebar":"tutorialSidebar"},"crdt":{"id":"crdt","title":"CRDT - Conflict-free replicated data type Database","description":"Explore the beta RxDB CRDT Plugin - A guide to conflict-free data handling in distributed systems with RxDB\'s novel CRDT approach to store and handle CRDTs in a database.","sidebar":"tutorialSidebar"},"data-migration":{"id":"data-migration","title":"data-migration","description":"This documentation page has been moved to here"},"dev-mode":{"id":"dev-mode","title":"Dev-Mode Plugin","description":"The dev-mode plugin adds many checks and validations to RxDB.","sidebar":"tutorialSidebar"},"downsides-of-offline-first":{"id":"downsides-of-offline-first","title":"Downsides of Local First / Offline First","description":"So you have read all these things about how the local-first (aka offline-first) paradigm makes it easy to create realtime web applications that even work when the user has no internet connection.","sidebar":"tutorialSidebar"},"electron":{"id":"electron","title":"Electron Plugin","description":"RxStorage Electron IpcRenderer & IpcMain","sidebar":"tutorialSidebar"},"electron-database":{"id":"electron-database","title":"Electron Database - Storage adapters for SQLite, Filesystem and In-Memory","description":"SQLite, Filesystem, and In-Memory storage with RxDB for creating robust local-first Electron apps. Perfect for complex, real-time client-side applications","sidebar":"tutorialSidebar"},"encryption":{"id":"encryption","title":"Encryption","description":"Explore RxDB\'s \ud83d\udd12 encryption plugin for enhanced data security in web and native apps, featuring password-based encryption and secure storage.","sidebar":"tutorialSidebar"},"install":{"id":"install","title":"Installation","description":"npm","sidebar":"tutorialSidebar"},"key-compression":{"id":"key-compression","title":"Key Compression","description":"With the key compression plugin, documents will be stored in a compressed format which saves up to 40% disc space.","sidebar":"tutorialSidebar"},"leader-election":{"id":"leader-election","title":"Leader Election","description":"RxDB comes with a leader-election which elects a leading instance between different instances in the same javascript runtime.","sidebar":"tutorialSidebar"},"logger":{"id":"logger","title":"Logger \ud83d\udc51","description":"With the logger plugin you can log all operations to the storage layer of your RxDatabase.","sidebar":"tutorialSidebar"},"middleware":{"id":"middleware","title":"Middleware","description":"RxDB supports middleware-hooks like mongoose.","sidebar":"tutorialSidebar"},"migration-schema":{"id":"migration-schema","title":"Migration Schema","description":"The RxDB Data Migration Plugin helps developers easily update stored data in their apps when they make changes to the data structure by changing the schema of a RxCollection. This is useful when developers release a new version of the app with a different schema.","sidebar":"tutorialSidebar"},"migration-storage":{"id":"migration-storage","title":"Migration Storage","description":"The storage migration plugin can be used to migrate all data from one existing RxStorage into another. This is useful when:","sidebar":"tutorialSidebar"},"nodejs-database":{"id":"nodejs-database","title":"Node.js Database","description":"RxDB is a fast, reactive realtime NoSQL database made for JavaScript applications like Websites, hybrid Apps, Electron-Apps, Progressive Web Apps and Node.js. While RxDB was initially created to be used with UI applications, it has been matured and optimized to make it useful for pure server-side use cases. It can be used as embedded, local database inside of the Node.js JavaScript process, or it can be used similar to a database server that Node.js can connect to. The RxStorage layer makes it possible to switch out the underlying storage engine which makes RxDB a very flexible database that can be optimized for many scenarios.","sidebar":"tutorialSidebar"},"nosql-performance-tips":{"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","sidebar":"tutorialSidebar"},"offline-first":{"id":"offline-first","title":"Local First / Offline First","description":"Local-First software stores data on client devices for seamless offline and online functionality, enhancing user experience and efficiency.","sidebar":"tutorialSidebar"},"orm":{"id":"orm","title":"ORM","description":"Like mongoose, RxDB has ORM-capabilities which can be used to add specific behavior to documents and collections.","sidebar":"tutorialSidebar"},"plugins":{"id":"plugins","title":"Plugins","description":"Creating your own plugin is very simple. A plugin is basically a javascript-object which overwrites or extends RxDB\'s internal classes, prototypes, and hooks.","sidebar":"tutorialSidebar"},"population":{"id":"population","title":"Population","description":"There are no joins in RxDB but sometimes we still want references to documents in other collections. This is where population comes in. You can specify a relation from one RxDocument to another RxDocument in the same or another RxCollection of the same database.","sidebar":"tutorialSidebar"},"query-cache":{"id":"query-cache","title":"Query Cache","description":"RxDB uses a QueryCache which optimizes the reuse of queries at runtime. This makes sense especially when RxDB is used in UI-applications where people move for- and backwards on different routes or pages and the same queries are used many times. Because of the event-reduce algorithm cached queries are even valuable for optimization, when changes to the database occur between now and the last execution.","sidebar":"tutorialSidebar"},"query-optimizer":{"id":"query-optimizer","title":"Query Optimizer \ud83d\udc51","description":"The query optimizer can be used to determine which index is the best to use for a given query.","sidebar":"tutorialSidebar"},"questions-answers":{"id":"questions-answers","title":"Questions and Answers","description":"Can\'t change the schema of a collection","sidebar":"tutorialSidebar"},"quickstart":{"id":"quickstart","title":"\ud83d\ude80 Quickstart","description":"Welcome to the RxDB Quickstart. Here we\'ll create a simple realtime TODO-app with RxDB to demonstrate the basic concepts.","sidebar":"tutorialSidebar"},"react-native-database":{"id":"react-native-database","title":"React Native Database","description":"Explore React Native database solutions for cross-platform apps - AsyncStorage, SQLite, RxDB, and more. Tailored for iOS, Android, and Windows, ensuring seamless data storage and sync.","sidebar":"tutorialSidebar"},"reactivity":{"id":"reactivity","title":"Signals & Custom Reactivity","description":"RxDB internally uses the rxjs library for observables and streams. All functionalities of RxDB like query results or document fields that expose values that change over time return a rxjs Observable that allows you to observe the values and update your UI accordingly depending on the changes to the database state.","sidebar":"tutorialSidebar"},"releases/10.0.0":{"id":"releases/10.0.0","title":"RxDB 10.0.0","description":"RxDB Major Release 10.0.0","sidebar":"tutorialSidebar"},"releases/11.0.0":{"id":"releases/11.0.0","title":"RxDB 11.0.0","description":"RxDB Major Release 11.0.0","sidebar":"tutorialSidebar"},"releases/12.0.0":{"id":"releases/12.0.0","title":"RxDB 12.0.0","description":"RxDB Major Release 12.0.0","sidebar":"tutorialSidebar"},"releases/13.0.0":{"id":"releases/13.0.0","title":"RxDB 13.0.0","description":"RxDB Major Release 13.0.0","sidebar":"tutorialSidebar"},"releases/14.0.0":{"id":"releases/14.0.0","title":"RxDB 14.0.0","description":"RxDB Major Release 14.0.0","sidebar":"tutorialSidebar"},"releases/15.0.0":{"id":"releases/15.0.0","title":"\ud83c\udd95 RxDB 15.0.0","description":"RxDB Major Release 15.0.0","sidebar":"tutorialSidebar"},"releases/8.0.0":{"id":"releases/8.0.0","title":"RxDB 8.0.0","description":"RxDB Major Release 8.0.0","sidebar":"tutorialSidebar"},"releases/9.0.0":{"id":"releases/9.0.0","title":"RxDB 9.0.0","description":"RxDB Major Release 9.0.0","sidebar":"tutorialSidebar"},"replication":{"id":"replication","title":"\u2699\ufe0f Replication Protocol","description":"The RxDB replication protocol provides the ability to replicate the database state in realtime between the clients and the server.","sidebar":"tutorialSidebar"},"replication-couchdb":{"id":"replication-couchdb","title":"CouchDB Replication","description":"A plugin to replicate between a RxCollection and a CouchDB server.","sidebar":"tutorialSidebar"},"replication-firestore":{"id":"replication-firestore","title":"Firestore Replication","description":"With the replication-firestore plugin you can do a two-way realtime replication","sidebar":"tutorialSidebar"},"replication-graphql":{"id":"replication-graphql","title":"GraphQL Replication","description":"The GraphQL replication provides handlers for GraphQL to run replication with GraphQL as the transportation layer.","sidebar":"tutorialSidebar"},"replication-http":{"id":"replication-http","title":"HTTP Replication","description":"Learn how to establish HTTP replication between RxDB clients and a Node.js Express server for data synchronization.","sidebar":"tutorialSidebar"},"replication-nats":{"id":"replication-nats","title":"NATS Replication","description":"With this RxDB plugin you can run a two-way realtime replication with a NATS server.","sidebar":"tutorialSidebar"},"replication-p2p":{"id":"replication-p2p","title":"P2P Replication","description":"The new documentation page has been moved to here"},"replication-server":{"id":"replication-server","title":"RxDB Server Replication","description":"The Server Replication Plugin connects to the replication endpoint of an RxDB Server Replication Endpoint and replicates data between the client and the server.","sidebar":"tutorialSidebar"},"replication-webrtc":{"id":"replication-webrtc","title":"WebRTC Replication","description":"In the world of web and mobile development, data synchronization between clients and servers has always been a critical aspect of building real-time JavaScript applications.","sidebar":"tutorialSidebar"},"replication-websocket":{"id":"replication-websocket","title":"Websocket Replication","description":"With the websocket replication plugin, you can spawn a websocket server from a RxDB database in Node.js and replicate with it.","sidebar":"tutorialSidebar"},"rx-attachment":{"id":"rx-attachment","title":"Attachments","description":"Attachments are binary data files that can be attachment to an RxDocument, like a file that is attached to an email.","sidebar":"tutorialSidebar"},"rx-collection":{"id":"rx-collection","title":"RxCollection","description":"A collection stores documents of the same type.","sidebar":"tutorialSidebar"},"rx-database":{"id":"rx-database","title":"RxDatabase","description":"A RxDatabase-Object contains your collections and handles the synchronization of change-events.","sidebar":"tutorialSidebar"},"rx-document":{"id":"rx-document","title":"RxDocument","description":"A document is a single object which is stored in a collection. It can be compared to a single record in a relational database table. You get an RxDocument either as return on inserts, or as result-set of queries.","sidebar":"tutorialSidebar"},"rx-local-document":{"id":"rx-local-document","title":"Local Documents","description":"Local documents are a special class of documents which are used to store local metadata.","sidebar":"tutorialSidebar"},"rx-query":{"id":"rx-query","title":"RxQuery","description":"A query allows to find documents in your collection.","sidebar":"tutorialSidebar"},"rx-schema":{"id":"rx-schema","title":"RxSchema","description":"Schemas define the structure of the documents of a collection. Which field should be used as primary, which fields should be used as indexes and what should be encrypted. Every collection has its own schema. With RxDB, schemas are defined with the jsonschema-standard which you might know from other projects.","sidebar":"tutorialSidebar"},"rx-server":{"id":"rx-server","title":"RxServer","description":"The RxDB Server Plugin makes it possible to spawn a server on top of a RxDB database that offers multiple types of endpoints for various usages. It can spawn basic CRUD REST endpoints or even realtime replication endpoints that can be used by the client devices to replicate data. The RxServer plugin is designed to be used in Node.js but you can also use it in Deno, Bun or the Electron \\"main\\" process. You can use it either as a standalone server or add it on top of an existing http server (like express) in nodejs.","sidebar":"tutorialSidebar"},"rx-server-scaling":{"id":"rx-server-scaling","title":"RxServer Scaling","description":"Explore how to scale the RxServer with vertical and horizontal methods, including multiple processes, worker threads, in-memory storage, and replication strategies for enhanced performance.","sidebar":"tutorialSidebar"},"rx-state":{"id":"rx-state","title":"RxState","description":"RxState is a flexible state library build on top of the RxDB Database. While RxDB stores similar documents inside of collections, RxState can store any complex JSON data without having a predefined schema.","sidebar":"tutorialSidebar"},"rx-storage":{"id":"rx-storage","title":"\u2699\ufe0f Rxstorage Layer","description":"RxDB is not a self contained database. Instead the data is stored in an implementation of the RxStorage interface. This allows you to switch out the underlying data layer, depending on the JavaScript environment and performance requirements. For example you can use the SQLite storage for a capacitor app or you can use the Dexie.js RxStorage to store data in IndexedDB in a browser based application. There are also storages for other JavaScript runtimes like Node.js, React-Native, NativeScript and more.","sidebar":"tutorialSidebar"},"rx-storage-denokv":{"id":"rx-storage-denokv","title":"DenoKV RxStorage","description":"With the DenoKV RxStorage layer for RxDB, you can run a fully featured NoSQL database on top of the DenoKV API.","sidebar":"tutorialSidebar"},"rx-storage-dexie":{"id":"rx-storage-dexie","title":"Dexie.js RxStorage","description":"To store the data inside of IndexedDB in the browser, you can also use the Dexie.js RxStorage.","sidebar":"tutorialSidebar"},"rx-storage-filesystem-node":{"id":"rx-storage-filesystem-node","title":"Node.js Filesystem RxStorage \ud83d\udc51","description":"The Filesystem Node RxStorage for RxDB is built on top of the Node.js Filesystem API.","sidebar":"tutorialSidebar"},"rx-storage-foundationdb":{"id":"rx-storage-foundationdb","title":"FoundationDB RxStorage","description":"Explore the advanced features of RxDB with FoundationDB RxStorage - Efficient indexing, complex NoSQL queries, real-time updates, data compression, and attachment management for optimized database performance and scalability","sidebar":"tutorialSidebar"},"rx-storage-indexeddb":{"id":"rx-storage-indexeddb","title":"IndexedDB RxStorage \ud83d\udc51","description":"Optimize browser, Electron, and hybrid app performance with IndexedDB RxStorage with the fastest, smallest build size storage solution for small to medium datasets.","sidebar":"tutorialSidebar"},"rx-storage-localstorage-meta-optimizer":{"id":"rx-storage-localstorage-meta-optimizer","title":"RxStorage Localstorage Meta Optimizer \ud83d\udc51","description":"The RxStorage Localstorage Meta Optimizer is a wrapper around any other RxStorage. The wrapper uses the original RxStorage for normal collection documents. But to optimize the initial page load time, it uses localstorage to store the plain key-value metadata that RxDB needs to create databases and collections. This plugin can only be used in browsers.","sidebar":"tutorialSidebar"},"rx-storage-lokijs":{"id":"rx-storage-lokijs","title":"LokiJS RxStorage","description":"The LokiJS RxStorage is based on LokiJS which is an in-memory database that processes all data in memory and only saves to disc when the app is closed or an interval is reached. This makes it very fast but you have the possibility to lose semingly persisted writes when the JavaScript process ends before the persistence loop has been done.","sidebar":"tutorialSidebar"},"rx-storage-memory":{"id":"rx-storage-memory","title":"Memory RxStorage","description":"\x3c!-- keywords:","sidebar":"tutorialSidebar"},"rx-storage-memory-synced":{"id":"rx-storage-memory-synced","title":"Memory Synced RxStorage \ud83d\udc51","description":"The memory synced RxStorage is a wrapper around any other RxStorage. The wrapper creates an in-memory storage that is used for query and write operations. This memory instance is replicated with the underlying storage for persistence.","sidebar":"tutorialSidebar"},"rx-storage-mongodb":{"id":"rx-storage-mongodb","title":"MongoDB RxStorage","description":"RxDB MongoDB RxStorage is an RxDB RxStorage that allows you to use MongoDB as the underlying storage engine for your RxDB database. With this you can take advantage of MongoDB\'s features and scalability while benefiting from RxDB\'s real-time data synchronization capabilities.","sidebar":"tutorialSidebar"},"rx-storage-opfs":{"id":"rx-storage-opfs","title":"OPFS RxStorage \ud83d\udc51","description":"Origin Private File System (OPFS) Database with the RxDB OPFS-RxStorage","sidebar":"tutorialSidebar"},"rx-storage-performance":{"id":"rx-storage-performance","title":"\ud83d\udcc8 RxStorage Performance","description":"RxStorage Performance comparison","sidebar":"tutorialSidebar"},"rx-storage-pouchdb":{"id":"rx-storage-pouchdb","title":"PouchDB RxStorage","description":"The PouchDB RxStorage is based on the PouchDB database. It is the most battle proven RxStorage and has a big ecosystem of adapters. PouchDB does a lot of overhead to enable CouchDB replication which makes the PouchDB RxStorage one of the slowest."},"rx-storage-remote":{"id":"rx-storage-remote","title":"Remote RxStorage","description":"The Remote RxStorage is made to use a remote storage and communicate with it over an asynchronous message channel.","sidebar":"tutorialSidebar"},"rx-storage-sharding":{"id":"rx-storage-sharding","title":"Sharding RxStorage \ud83d\udc51","description":"With the sharding plugin, you can improve the write and query times of some RxStorage implementations.","sidebar":"tutorialSidebar"},"rx-storage-shared-worker":{"id":"rx-storage-shared-worker","title":"SharedWorker RxStorage \ud83d\udc51","description":"The SharedWorker RxStorage uses the SharedWorker API to run the storage inside of a separate JavaScript process in browsers. Compared to a normal WebWorker, the SharedWorker is created exactly once, even when there are multiple browser tabs opened. Because of having exactly one worker, multiple performance optimizations can be done because the storage itself does not have to handle multiple opened database connections.","sidebar":"tutorialSidebar"},"rx-storage-sqlite":{"id":"rx-storage-sqlite","title":"SQLite RxStorage \ud83d\udc51","description":"This RxStorage is based on SQLite and is made to work with Node.js, Electron, React Native and Capacitor or SQLite via wasm in the browser. It can be used with different so called sqliteBasics adapters to account for the differences in the various SQLite bundles and libraries that exist.","sidebar":"tutorialSidebar"},"rx-storage-worker":{"id":"rx-storage-worker","title":"Worker RxStorage \ud83d\udc51","description":"With the worker plugin, you can put the RxStorage of your database inside of a WebWorker (in browsers) or a Worker Thread (in node.js). By doing so, you can take CPU load from the main process and move it into the worker\'s process which can improve the perceived performance of your application. Notice that for browsers, it is recommend to use the SharedWorker instead to get a better performance.","sidebar":"tutorialSidebar"},"rxdb-tradeoffs":{"id":"rxdb-tradeoffs","title":"RxDB Tradeoffs","description":"RxDB is client-side, offline first Database for JavaScript applications."},"schema-validation":{"id":"schema-validation","title":"Schema Validation","description":"RxDB has multiple validation implementations that can be used to ensure that your document data is always matching the provided JSON"},"slow-indexeddb":{"id":"slow-indexeddb","title":"Slow IndexedDB","description":"So you have a JavaScript web application that needs to store data at the client side, either to make it offline usable, just for caching purposes or for other reasons.","sidebar":"tutorialSidebar"},"third-party-plugins":{"id":"third-party-plugins","title":"Third Party Plugins","description":"* rxdb-hooks A set of hooks to integrate RxDB into react applications.","sidebar":"tutorialSidebar"},"transactions-conflicts-revisions":{"id":"transactions-conflicts-revisions","title":"Transactions, Conflicts and Revisions","description":"In contrast to most SQL databases, RxDB does not have the concept of relational, ACID transactions. Instead, RxDB has to apply different techniques that better suit the offline-first, client side world where it is not possible to create a transaction between multiple maybe-offline client devices.","sidebar":"tutorialSidebar"},"tutorials/typescript":{"id":"tutorials/typescript","title":"RxDB TypeScript Tutorial","description":"In this tutorial you will learn how to use RxDB with TypeScript.","sidebar":"tutorialSidebar"},"why-nosql":{"id":"why-nosql","title":"Why NOSQL","description":"RxDB, a client side, offline first, JavaScript database, is now several years old.","sidebar":"tutorialSidebar"}}}')}}]); \ No newline at end of file +"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[8581],{5610:e=>{e.exports=JSON.parse('{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"tutorialSidebar":[{"type":"link","label":"\ud83d\ude80 Quickstart","href":"/quickstart.html","docId":"quickstart","unlisted":false},{"type":"link","label":"Installation","href":"/install.html","docId":"install","unlisted":false},{"type":"link","label":"Dev-Mode Plugin","href":"/dev-mode.html","docId":"dev-mode","unlisted":false},{"type":"link","label":"RxDatabase","href":"/rx-database.html","docId":"rx-database","unlisted":false},{"type":"link","label":"RxSchema","href":"/rx-schema.html","docId":"rx-schema","unlisted":false},{"type":"link","label":"RxCollection","href":"/rx-collection.html","docId":"rx-collection","unlisted":false},{"type":"link","label":"RxDocument","href":"/rx-document.html","docId":"rx-document","unlisted":false},{"type":"link","label":"RxQuery","href":"/rx-query.html","docId":"rx-query","unlisted":false},{"type":"link","label":"Attachments","href":"/rx-attachment.html","docId":"rx-attachment","unlisted":false},{"type":"category","label":"\ud83d\udcbe RxStorage","items":[{"type":"link","label":"\u2699\ufe0f Rxstorage Layer","href":"/rx-storage.html","docId":"rx-storage","unlisted":false},{"type":"link","label":"\ud83d\udcc8 RxStorage Performance","href":"/rx-storage-performance.html","docId":"rx-storage-performance","unlisted":false},{"type":"link","label":"IndexedDB RxStorage \ud83d\udc51","href":"/rx-storage-indexeddb.html","docId":"rx-storage-indexeddb","unlisted":false},{"type":"link","label":"SQLite RxStorage \ud83d\udc51","href":"/rx-storage-sqlite.html","docId":"rx-storage-sqlite","unlisted":false},{"type":"link","label":"Memory RxStorage","href":"/rx-storage-memory.html","docId":"rx-storage-memory","unlisted":false},{"type":"link","label":"Dexie.js RxStorage","href":"/rx-storage-dexie.html","docId":"rx-storage-dexie","unlisted":false},{"type":"link","label":"OPFS RxStorage \ud83d\udc51","href":"/rx-storage-opfs.html","docId":"rx-storage-opfs","unlisted":false},{"type":"link","label":"Node.js Filesystem RxStorage \ud83d\udc51","href":"/rx-storage-filesystem-node.html","docId":"rx-storage-filesystem-node","unlisted":false},{"type":"link","label":"MongoDB RxStorage","href":"/rx-storage-mongodb.html","docId":"rx-storage-mongodb","unlisted":false},{"type":"link","label":"DenoKV RxStorage","href":"/rx-storage-denokv.html","docId":"rx-storage-denokv","unlisted":false},{"type":"link","label":"FoundationDB RxStorage","href":"/rx-storage-foundationdb.html","docId":"rx-storage-foundationdb","unlisted":false},{"type":"link","label":"LokiJS RxStorage","href":"/rx-storage-lokijs.html","docId":"rx-storage-lokijs","unlisted":false},{"type":"link","label":"Remote RxStorage","href":"/rx-storage-remote.html","docId":"rx-storage-remote","unlisted":false},{"type":"link","label":"Worker RxStorage \ud83d\udc51","href":"/rx-storage-worker.html","docId":"rx-storage-worker","unlisted":false},{"type":"link","label":"SharedWorker RxStorage \ud83d\udc51","href":"/rx-storage-shared-worker.html","docId":"rx-storage-shared-worker","unlisted":false},{"type":"link","label":"Memory Synced RxStorage \ud83d\udc51","href":"/rx-storage-memory-synced.html","docId":"rx-storage-memory-synced","unlisted":false},{"type":"link","label":"Sharding RxStorage \ud83d\udc51","href":"/rx-storage-sharding.html","docId":"rx-storage-sharding","unlisted":false},{"type":"link","label":"RxStorage Localstorage Meta Optimizer \ud83d\udc51","href":"/rx-storage-localstorage-meta-optimizer.html","docId":"rx-storage-localstorage-meta-optimizer","unlisted":false},{"type":"link","label":"Electron Plugin","href":"/electron.html","docId":"electron","unlisted":false}],"collapsed":true,"collapsible":true},{"type":"category","label":"\ud83d\udd04 Replication","items":[{"type":"link","label":"\u2699\ufe0f Replication Protocol","href":"/replication.html","docId":"replication","unlisted":false},{"type":"link","label":"HTTP Replication","href":"/replication-http.html","docId":"replication-http","unlisted":false},{"type":"link","label":"RxDB Server Replication","href":"/replication-server","docId":"replication-server","unlisted":false},{"type":"link","label":"GraphQL Replication","href":"/replication-graphql.html","docId":"replication-graphql","unlisted":false},{"type":"link","label":"Websocket Replication","href":"/replication-websocket.html","docId":"replication-websocket","unlisted":false},{"type":"link","label":"CouchDB Replication","href":"/replication-couchdb.html","docId":"replication-couchdb","unlisted":false},{"type":"link","label":"WebRTC Replication","href":"/replication-webrtc.html","docId":"replication-webrtc","unlisted":false},{"type":"link","label":"Firestore Replication","href":"/replication-firestore.html","docId":"replication-firestore","unlisted":false},{"type":"link","label":"NATS Replication","href":"/replication-nats.html","docId":"replication-nats","unlisted":false}],"collapsed":true,"collapsible":true},{"type":"category","label":"Server","items":[{"type":"link","label":"RxServer","href":"/rx-server.html","docId":"rx-server","unlisted":false},{"type":"link","label":"RxServer Scaling","href":"/rx-server-scaling.html","docId":"rx-server-scaling","unlisted":false}],"collapsed":true,"collapsible":true},{"type":"category","label":"Migration","items":[{"type":"link","label":"Migration Schema","href":"/migration-schema.html","docId":"migration-schema","unlisted":false},{"type":"link","label":"Migration Storage","href":"/migration-storage.html","docId":"migration-storage","unlisted":false}],"collapsed":true,"collapsible":true},{"type":"link","label":"Signals & Custom Reactivity","href":"/reactivity.html","docId":"reactivity","unlisted":false},{"type":"link","label":"RxState","href":"/rx-state.html","docId":"rx-state","unlisted":false},{"type":"link","label":"Local Documents","href":"/rx-local-document.html","docId":"rx-local-document","unlisted":false},{"type":"link","label":"Encryption","href":"/encryption.html","docId":"encryption","unlisted":false},{"type":"link","label":"Key Compression","href":"/key-compression.html","docId":"key-compression","unlisted":false},{"type":"link","label":"Leader Election","href":"/leader-election.html","docId":"leader-election","unlisted":false},{"type":"link","label":"Cleanup","href":"/cleanup.html","docId":"cleanup","unlisted":false},{"type":"link","label":"Backup","href":"/backup.html","docId":"backup","unlisted":false},{"type":"link","label":"Transactions, Conflicts and Revisions","href":"/transactions-conflicts-revisions.html","docId":"transactions-conflicts-revisions","unlisted":false},{"type":"link","label":"Middleware","href":"/middleware.html","docId":"middleware","unlisted":false},{"type":"link","label":"Query Cache","href":"/query-cache.html","docId":"query-cache","unlisted":false},{"type":"link","label":"CRDT - Conflict-free replicated data type Database","href":"/crdt.html","docId":"crdt","unlisted":false},{"type":"link","label":"Population","href":"/population.html","docId":"population","unlisted":false},{"type":"link","label":"ORM","href":"/orm.html","docId":"orm","unlisted":false},{"type":"link","label":"Query Optimizer \ud83d\udc51","href":"/query-optimizer.html","docId":"query-optimizer","unlisted":false},{"type":"link","label":"Logger \ud83d\udc51","href":"/logger.html","docId":"logger","unlisted":false},{"type":"link","label":"Plugins","href":"/plugins.html","docId":"plugins","unlisted":false},{"type":"link","label":"RxDB NoSQL Performance Tips","href":"/nosql-performance-tips.html","docId":"nosql-performance-tips","unlisted":false},{"type":"link","label":"Third Party Plugins","href":"/third-party-plugins.html","docId":"third-party-plugins","unlisted":false},{"type":"category","label":"Tutorials","items":[{"type":"link","label":"RxDB TypeScript Tutorial","href":"/tutorials/typescript.html","docId":"tutorials/typescript","unlisted":false},{"type":"link","label":"Node.js Database","href":"/nodejs-database.html","docId":"nodejs-database","unlisted":false}],"collapsed":true,"collapsible":true},{"type":"link","label":"Questions and Answers","href":"/questions-answers.html","docId":"questions-answers","unlisted":false},{"type":"link","label":"Contribute to RxDB","href":"/contribution.html","docId":"contribute","unlisted":false},{"type":"category","label":"\ud83c\udd95 Releases","items":[{"type":"link","label":"\ud83c\udd95 RxDB 15.0.0","href":"/releases/15.0.0.html","docId":"releases/15.0.0","unlisted":false},{"type":"link","label":"RxDB 14.0.0","href":"/releases/14.0.0.html","docId":"releases/14.0.0","unlisted":false},{"type":"link","label":"RxDB 13.0.0","href":"/releases/13.0.0.html","docId":"releases/13.0.0","unlisted":false},{"type":"link","label":"RxDB 12.0.0","href":"/releases/12.0.0.html","docId":"releases/12.0.0","unlisted":false},{"type":"link","label":"RxDB 11.0.0","href":"/releases/11.0.0.html","docId":"releases/11.0.0","unlisted":false},{"type":"link","label":"RxDB 10.0.0","href":"/releases/10.0.0.html","docId":"releases/10.0.0","unlisted":false},{"type":"link","label":"RxDB 9.0.0","href":"/releases/9.0.0.html","docId":"releases/9.0.0","unlisted":false},{"type":"link","label":"RxDB 8.0.0","href":"/releases/8.0.0.html","docId":"releases/8.0.0","unlisted":false}],"collapsed":true,"collapsible":true},{"type":"category","label":"Articles","items":[{"type":"link","label":"Local First / Offline First","href":"/offline-first.html","docId":"offline-first","unlisted":false},{"type":"link","label":"Downsides of Local First / Offline First","href":"/downsides-of-offline-first.html","docId":"downsides-of-offline-first","unlisted":false},{"type":"link","label":"Slow IndexedDB","href":"/slow-indexeddb.html","docId":"slow-indexeddb","unlisted":false},{"type":"link","label":"Why NOSQL","href":"/why-nosql.html","docId":"why-nosql","unlisted":false},{"type":"link","label":"React Native Database","href":"/react-native-database.html","docId":"react-native-database","unlisted":false},{"type":"link","label":"Alternatives for realtime offline-first JavaScript applications and local databases","href":"/alternatives.html","docId":"alternatives","unlisted":false},{"type":"link","label":"RxDB as a Database in an Angular Application","href":"/articles/angular-database.html","docId":"articles/angular-database","unlisted":false},{"type":"link","label":"The benefits of Browser Databases and RxDB","href":"/articles/browser-database.html","docId":"articles/browser-database","unlisted":false},{"type":"link","label":"Browser Storage - RxDB as a Database for Browsers","href":"/articles/browser-storage.html","docId":"articles/browser-storage","unlisted":false},{"type":"link","label":"RxDB as a data base - Empowering Web Applications with Reactive Data Handling","href":"/articles/data-base.html","docId":"articles/data-base","unlisted":false},{"type":"link","label":"Using RxDB as an Embedded Database","href":"/articles/embedded-database.html","docId":"articles/embedded-database","unlisted":false},{"type":"link","label":"RxDB as a Database in a Flutter Application","href":"/articles/flutter-database.html","docId":"articles/flutter-database","unlisted":false},{"type":"link","label":"RxDB JavaScript Frontend Database - Efficient Data Storage in Frontend Applications","href":"/articles/frontend-database.html","docId":"articles/frontend-database","unlisted":false},{"type":"link","label":"RxDB as In-memory NoSQL Database - Empowering Real-Time Applications","href":"/articles/in-memory-nosql-database.html","docId":"articles/in-memory-nosql-database","unlisted":false},{"type":"link","label":"Ionic Storage - RxDB as database for hybrid apps","href":"/articles/ionic-database.html","docId":"articles/ionic-database","unlisted":false},{"type":"link","label":"RxDB - JSON Database for JavaScript","href":"/articles/json-database.html","docId":"articles/json-database","unlisted":false},{"type":"link","label":"Using localStorage in Modern Applications - A Comprehensive Guide","href":"/articles/localstorage.html","docId":"articles/localstorage","unlisted":false},{"type":"link","label":"Mobile Database - RxDB as Database for Mobile Applications","href":"/articles/mobile-database.html","docId":"articles/mobile-database","unlisted":false},{"type":"link","label":"RxDB as a Database for Progressive Web Apps (PWA)","href":"/articles/progressive-web-app-database.html","docId":"articles/progressive-web-app-database","unlisted":false},{"type":"link","label":"RxDB as a Database for React Applications","href":"/articles/react-database.html","docId":"articles/react-database","unlisted":false},{"type":"link","label":"What is a realtime database?","href":"/articles/realtime-database.html","docId":"articles/realtime-database","unlisted":false},{"type":"link","label":"Capacitor Database - SQLite, RxDB and others","href":"/capacitor-database.html","docId":"capacitor-database","unlisted":false},{"type":"link","label":"Electron Database - Storage adapters for SQLite, Filesystem and In-Memory","href":"/electron-database.html","docId":"electron-database","unlisted":false}],"collapsed":true,"collapsible":true}]},"docs":{"adapters":{"id":"adapters","title":"PouchDB Adapters","description":"When you use PouchDB RxStorage, there are many adapters that define where the data has to be stored."},"alternatives":{"id":"alternatives","title":"Alternatives for realtime offline-first JavaScript applications and local databases","description":"Explore real-time, offline-first JS alternatives to RxDB. Compare Firebase, Meteor, AWS, CouchDB, and more for robust, seamless web/mobile app development.","sidebar":"tutorialSidebar"},"articles/angular-database":{"id":"articles/angular-database","title":"RxDB as a Database in an Angular Application","description":"Discover the RxDB Revolution for Angular Apps! \ud83d\ude80 Learn how to supercharge your web applications with RxDB\'s reactive, offline-first database capabilities. Master real-time data synchronization and build ultra-responsive Angular applications. Click now for expert tips and techniques that will elevate your development game!","sidebar":"tutorialSidebar"},"articles/browser-database":{"id":"articles/browser-database","title":"The benefits of Browser Databases and RxDB","description":"In the world of web development, efficient data management is a cornerstone of building successful and performant applications. The ability to store data directly in the browser brings numerous advantages, such as caching, offline accessibility, simplified replication of database state, and real-time application development. In this article, we will explore RxDB, a powerful browser JavaScript database, and understand why it is an excellent choice for implementing a browser database solution.","sidebar":"tutorialSidebar"},"articles/browser-storage":{"id":"articles/browser-storage","title":"Browser Storage - RxDB as a Database for Browsers","description":"Explore RxDB for browser storage its advantages, limitations, and why it outperforms SQL databases in web applications for enhanced efficiency","sidebar":"tutorialSidebar"},"articles/data-base":{"id":"articles/data-base","title":"RxDB as a data base - Empowering Web Applications with Reactive Data Handling","description":"In the world of web applications, efficient data management plays a crucial role in delivering a seamless user experience. As mobile applications continue to dominate the digital landscape, the importance of robust data bases becomes evident. In this article, we will explore RxDB as a powerful data base solution for web applications. We will delve into its features, advantages, and advanced techniques, highlighting its ability to handle reactive data and enable an offline-first approach.","sidebar":"tutorialSidebar"},"articles/embedded-database":{"id":"articles/embedded-database","title":"Using RxDB as an Embedded Database","description":"In modern UI applications, efficient data storage is a crucial aspect for seamless user experiences. One powerful solution for achieving this is by utilizing an embedded database. In this article, we will explore the concept of an embedded database and delve into the benefits of using RxDB as an embedded database in UI applications. We will also discuss why RxDB stands out as a robust choice for real-time applications with embedded database functionality.","sidebar":"tutorialSidebar"},"articles/flutter-database":{"id":"articles/flutter-database","title":"RxDB as a Database in a Flutter Application","description":"In the world of mobile application development, Flutter has gained significant popularity due to its cross-platform capabilities and rich UI framework. When it comes to building feature-rich Flutter applications, the choice of a robust and efficient database is crucial. In this article, we will explore RxDB as a database solution for Flutter applications. We\'ll delve into the core features of RxDB, its benefits over other database options, and how to integrate it into a Flutter app.","sidebar":"tutorialSidebar"},"articles/frontend-database":{"id":"articles/frontend-database","title":"RxDB JavaScript Frontend Database - Efficient Data Storage in Frontend Applications","description":"Explore RxDB as simple frontend database - Learn the benefits of offline access, caching, and improved performance in modern web apps, making RxDB a superior choice over traditional SQL databases.","sidebar":"tutorialSidebar"},"articles/in-memory-nosql-database":{"id":"articles/in-memory-nosql-database","title":"RxDB as In-memory NoSQL Database - Empowering Real-Time Applications","description":"Real-time applications have become increasingly popular in today\'s digital landscape. From instant messaging to collaborative editing tools, the demand for responsive and interactive software is on the rise. To meet these requirements, developers need powerful and efficient database solutions that can handle large amounts of data in real-time. RxDB, an javascript NoSQL database, is revolutionizing the way developers build and scale their applications by offering exceptional speed, flexibility, and scalability.","sidebar":"tutorialSidebar"},"articles/ionic-database":{"id":"articles/ionic-database","title":"Ionic Storage - RxDB as database for hybrid apps","description":"In the fast-paced world of mobile app development, hybrid applications have emerged as a versatile solution, offering the best of both worlds - the web and native app experiences. One key challenge these apps face is efficiently storing and querying data on the client\'s device. Enter RxDB, a powerful client-side database tailored for ionic hybrid applications. In this article, we\'ll explore how RxDB addresses the requirements of storing and querying data in ionic apps, and why it stands out as a preferred choice.","sidebar":"tutorialSidebar"},"articles/json-database":{"id":"articles/json-database","title":"RxDB - JSON Database for JavaScript","description":"Storing data as JSON documents in a NoSQL database is not just a trend; it\'s a practical choice. JSON data is highly compatible with various tools and is human-readable, making it an excellent fit for modern applications. JSON documents offer more flexibility compared to traditional SQL table rows, as they can contain nested data structures. This article introduces RxDB, an open-source, flexible, performant, and battle-tested NoSQL JSON database specifically designed for JavaScript applications.","sidebar":"tutorialSidebar"},"articles/localstorage":{"id":"articles/localstorage","title":"Using localStorage in Modern Applications - A Comprehensive Guide","description":"This guide explores localStorage in JavaScript web apps, detailing its usage, limitations, and alternatives like IndexedDB and AsyncStorage.","sidebar":"tutorialSidebar"},"articles/mobile-database":{"id":"articles/mobile-database","title":"Mobile Database - RxDB as Database for Mobile Applications","description":"In today\'s digital landscape, mobile applications have become an integral part of our lives. From social media platforms to e-commerce solutions, mobile apps have transformed the way we interact with digital services. At the heart of any mobile app lies the database, a critical component responsible for storing, retrieving, and managing data efficiently. In this article, we will delve into the world of mobile databases, exploring their significance, challenges, and the emergence of RxDB as a powerful database solution for hybrid app development in frameworks like React Native and Capacitor.","sidebar":"tutorialSidebar"},"articles/progressive-web-app-database":{"id":"articles/progressive-web-app-database","title":"RxDB as a Database for Progressive Web Apps (PWA)","description":"Progressive Web Apps (PWAs) have revolutionized the digital landscape, offering users an immersive blend of web and native app experiences. At the heart of every successful PWA lies effective data management, and this is where RxDB comes into play. In this article, we\'ll explore the dynamic synergy between RxDB, a robust client-side database, and Progressive Web Apps, uncovering how RxDB enhances data handling, synchronization, and overall performance, propelling PWAs into a new era of excellence.","sidebar":"tutorialSidebar"},"articles/react-database":{"id":"articles/react-database","title":"RxDB as a Database for React Applications","description":"Discover how RxDB enhances React applications by offering efficient data management, real-time updates, and offline capabilities. This article explores RxDB\'s integration with React for dynamic, responsive UIs.","sidebar":"tutorialSidebar"},"articles/realtime-database":{"id":"articles/realtime-database","title":"What is a realtime database?","description":"I have been building RxDB, a NoSQL realtime JavaScript database for many years.","sidebar":"tutorialSidebar"},"backup":{"id":"backup","title":"Backup","description":"With the backup plugin you can write the current database state and ongoing changes into folders on the filesystem.","sidebar":"tutorialSidebar"},"capacitor-database":{"id":"capacitor-database","title":"Capacitor Database - SQLite, RxDB and others","description":"Explore Capacitor\'s database options including SQLite, RxDB, and Preferences API for web-native apps. Learn about their uses, limitations, and integration in this comprehensive guide.","sidebar":"tutorialSidebar"},"cleanup":{"id":"cleanup","title":"Cleanup","description":"To make the replication work, and for other reasons, RxDB has to keep deleted documents in the storage.","sidebar":"tutorialSidebar"},"contribute":{"id":"contribute","title":"Contribute to RxDB","description":"We are open to, and grateful for, any contributions made by the community.","sidebar":"tutorialSidebar"},"crdt":{"id":"crdt","title":"CRDT - Conflict-free replicated data type Database","description":"Explore the beta RxDB CRDT Plugin - A guide to conflict-free data handling in distributed systems with RxDB\'s novel CRDT approach to store and handle CRDTs in a database.","sidebar":"tutorialSidebar"},"data-migration":{"id":"data-migration","title":"data-migration","description":"This documentation page has been moved to here"},"dev-mode":{"id":"dev-mode","title":"Dev-Mode Plugin","description":"The dev-mode plugin adds many checks and validations to RxDB.","sidebar":"tutorialSidebar"},"downsides-of-offline-first":{"id":"downsides-of-offline-first","title":"Downsides of Local First / Offline First","description":"So you have read all these things about how the local-first (aka offline-first) paradigm makes it easy to create realtime web applications that even work when the user has no internet connection.","sidebar":"tutorialSidebar"},"electron":{"id":"electron","title":"Electron Plugin","description":"RxStorage Electron IpcRenderer & IpcMain","sidebar":"tutorialSidebar"},"electron-database":{"id":"electron-database","title":"Electron Database - Storage adapters for SQLite, Filesystem and In-Memory","description":"SQLite, Filesystem, and In-Memory storage with RxDB for creating robust local-first Electron apps. Perfect for complex, real-time client-side applications","sidebar":"tutorialSidebar"},"encryption":{"id":"encryption","title":"Encryption","description":"Explore RxDB\'s \ud83d\udd12 encryption plugin for enhanced data security in web and native apps, featuring password-based encryption and secure storage.","sidebar":"tutorialSidebar"},"install":{"id":"install","title":"Installation","description":"npm","sidebar":"tutorialSidebar"},"key-compression":{"id":"key-compression","title":"Key Compression","description":"With the key compression plugin, documents will be stored in a compressed format which saves up to 40% disc space.","sidebar":"tutorialSidebar"},"leader-election":{"id":"leader-election","title":"Leader Election","description":"RxDB comes with a leader-election which elects a leading instance between different instances in the same javascript runtime.","sidebar":"tutorialSidebar"},"logger":{"id":"logger","title":"Logger \ud83d\udc51","description":"With the logger plugin you can log all operations to the storage layer of your RxDatabase.","sidebar":"tutorialSidebar"},"middleware":{"id":"middleware","title":"Middleware","description":"RxDB supports middleware-hooks like mongoose.","sidebar":"tutorialSidebar"},"migration-schema":{"id":"migration-schema","title":"Migration Schema","description":"The RxDB Data Migration Plugin helps developers easily update stored data in their apps when they make changes to the data structure by changing the schema of a RxCollection. This is useful when developers release a new version of the app with a different schema.","sidebar":"tutorialSidebar"},"migration-storage":{"id":"migration-storage","title":"Migration Storage","description":"The storage migration plugin can be used to migrate all data from one existing RxStorage into another. This is useful when:","sidebar":"tutorialSidebar"},"nodejs-database":{"id":"nodejs-database","title":"Node.js Database","description":"RxDB is a fast, reactive realtime NoSQL database made for JavaScript applications like Websites, hybrid Apps, Electron-Apps, Progressive Web Apps and Node.js. While RxDB was initially created to be used with UI applications, it has been matured and optimized to make it useful for pure server-side use cases. It can be used as embedded, local database inside of the Node.js JavaScript process, or it can be used similar to a database server that Node.js can connect to. The RxStorage layer makes it possible to switch out the underlying storage engine which makes RxDB a very flexible database that can be optimized for many scenarios.","sidebar":"tutorialSidebar"},"nosql-performance-tips":{"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","sidebar":"tutorialSidebar"},"offline-first":{"id":"offline-first","title":"Local First / Offline First","description":"Local-First software stores data on client devices for seamless offline and online functionality, enhancing user experience and efficiency.","sidebar":"tutorialSidebar"},"orm":{"id":"orm","title":"ORM","description":"Like mongoose, RxDB has ORM-capabilities which can be used to add specific behavior to documents and collections.","sidebar":"tutorialSidebar"},"plugins":{"id":"plugins","title":"Plugins","description":"Creating your own plugin is very simple. A plugin is basically a javascript-object which overwrites or extends RxDB\'s internal classes, prototypes, and hooks.","sidebar":"tutorialSidebar"},"population":{"id":"population","title":"Population","description":"There are no joins in RxDB but sometimes we still want references to documents in other collections. This is where population comes in. You can specify a relation from one RxDocument to another RxDocument in the same or another RxCollection of the same database.","sidebar":"tutorialSidebar"},"query-cache":{"id":"query-cache","title":"Query Cache","description":"RxDB uses a QueryCache which optimizes the reuse of queries at runtime. This makes sense especially when RxDB is used in UI-applications where people move for- and backwards on different routes or pages and the same queries are used many times. Because of the event-reduce algorithm cached queries are even valuable for optimization, when changes to the database occur between now and the last execution.","sidebar":"tutorialSidebar"},"query-optimizer":{"id":"query-optimizer","title":"Query Optimizer \ud83d\udc51","description":"The query optimizer can be used to determine which index is the best to use for a given query.","sidebar":"tutorialSidebar"},"questions-answers":{"id":"questions-answers","title":"Questions and Answers","description":"Can\'t change the schema of a collection","sidebar":"tutorialSidebar"},"quickstart":{"id":"quickstart","title":"\ud83d\ude80 Quickstart","description":"Welcome to the RxDB Quickstart. Here we\'ll create a simple realtime TODO-app with RxDB to demonstrate the basic concepts.","sidebar":"tutorialSidebar"},"react-native-database":{"id":"react-native-database","title":"React Native Database","description":"Explore React Native database solutions for cross-platform apps - AsyncStorage, SQLite, RxDB, and more. Tailored for iOS, Android, and Windows, ensuring seamless data storage and sync.","sidebar":"tutorialSidebar"},"reactivity":{"id":"reactivity","title":"Signals & Custom Reactivity","description":"RxDB internally uses the rxjs library for observables and streams. All functionalities of RxDB like query results or document fields that expose values that change over time return a rxjs Observable that allows you to observe the values and update your UI accordingly depending on the changes to the database state.","sidebar":"tutorialSidebar"},"releases/10.0.0":{"id":"releases/10.0.0","title":"RxDB 10.0.0","description":"RxDB Major Release 10.0.0","sidebar":"tutorialSidebar"},"releases/11.0.0":{"id":"releases/11.0.0","title":"RxDB 11.0.0","description":"RxDB Major Release 11.0.0","sidebar":"tutorialSidebar"},"releases/12.0.0":{"id":"releases/12.0.0","title":"RxDB 12.0.0","description":"RxDB Major Release 12.0.0","sidebar":"tutorialSidebar"},"releases/13.0.0":{"id":"releases/13.0.0","title":"RxDB 13.0.0","description":"RxDB Major Release 13.0.0","sidebar":"tutorialSidebar"},"releases/14.0.0":{"id":"releases/14.0.0","title":"RxDB 14.0.0","description":"RxDB Major Release 14.0.0","sidebar":"tutorialSidebar"},"releases/15.0.0":{"id":"releases/15.0.0","title":"\ud83c\udd95 RxDB 15.0.0","description":"RxDB Major Release 15.0.0","sidebar":"tutorialSidebar"},"releases/8.0.0":{"id":"releases/8.0.0","title":"RxDB 8.0.0","description":"RxDB Major Release 8.0.0","sidebar":"tutorialSidebar"},"releases/9.0.0":{"id":"releases/9.0.0","title":"RxDB 9.0.0","description":"RxDB Major Release 9.0.0","sidebar":"tutorialSidebar"},"replication":{"id":"replication","title":"\u2699\ufe0f Replication Protocol","description":"The RxDB replication protocol provides the ability to replicate the database state in realtime between the clients and the server.","sidebar":"tutorialSidebar"},"replication-couchdb":{"id":"replication-couchdb","title":"CouchDB Replication","description":"A plugin to replicate between a RxCollection and a CouchDB server.","sidebar":"tutorialSidebar"},"replication-firestore":{"id":"replication-firestore","title":"Firestore Replication","description":"With the replication-firestore plugin you can do a two-way realtime replication","sidebar":"tutorialSidebar"},"replication-graphql":{"id":"replication-graphql","title":"GraphQL Replication","description":"The GraphQL replication provides handlers for GraphQL to run replication with GraphQL as the transportation layer.","sidebar":"tutorialSidebar"},"replication-http":{"id":"replication-http","title":"HTTP Replication","description":"Learn how to establish HTTP replication between RxDB clients and a Node.js Express server for data synchronization.","sidebar":"tutorialSidebar"},"replication-nats":{"id":"replication-nats","title":"NATS Replication","description":"With this RxDB plugin you can run a two-way realtime replication with a NATS server.","sidebar":"tutorialSidebar"},"replication-p2p":{"id":"replication-p2p","title":"P2P Replication","description":"The new documentation page has been moved to here"},"replication-server":{"id":"replication-server","title":"RxDB Server Replication","description":"The Server Replication Plugin connects to the replication endpoint of an RxDB Server Replication Endpoint and replicates data between the client and the server.","sidebar":"tutorialSidebar"},"replication-webrtc":{"id":"replication-webrtc","title":"WebRTC Replication","description":"In the world of web and mobile development, data synchronization between clients and servers has always been a critical aspect of building real-time JavaScript applications.","sidebar":"tutorialSidebar"},"replication-websocket":{"id":"replication-websocket","title":"Websocket Replication","description":"With the websocket replication plugin, you can spawn a websocket server from a RxDB database in Node.js and replicate with it.","sidebar":"tutorialSidebar"},"rx-attachment":{"id":"rx-attachment","title":"Attachments","description":"Attachments are binary data files that can be attachment to an RxDocument, like a file that is attached to an email.","sidebar":"tutorialSidebar"},"rx-collection":{"id":"rx-collection","title":"RxCollection","description":"A collection stores documents of the same type.","sidebar":"tutorialSidebar"},"rx-database":{"id":"rx-database","title":"RxDatabase","description":"A RxDatabase-Object contains your collections and handles the synchronization of change-events.","sidebar":"tutorialSidebar"},"rx-document":{"id":"rx-document","title":"RxDocument","description":"A document is a single object which is stored in a collection. It can be compared to a single record in a relational database table. You get an RxDocument either as return on inserts, or as result-set of queries.","sidebar":"tutorialSidebar"},"rx-local-document":{"id":"rx-local-document","title":"Local Documents","description":"Local documents are a special class of documents which are used to store local metadata.","sidebar":"tutorialSidebar"},"rx-query":{"id":"rx-query","title":"RxQuery","description":"A query allows to find documents in your collection.","sidebar":"tutorialSidebar"},"rx-schema":{"id":"rx-schema","title":"RxSchema","description":"Schemas define the structure of the documents of a collection. Which field should be used as primary, which fields should be used as indexes and what should be encrypted. Every collection has its own schema. With RxDB, schemas are defined with the jsonschema-standard which you might know from other projects.","sidebar":"tutorialSidebar"},"rx-server":{"id":"rx-server","title":"RxServer","description":"The RxDB Server Plugin makes it possible to spawn a server on top of a RxDB database that offers multiple types of endpoints for various usages. It can spawn basic CRUD REST endpoints or even realtime replication endpoints that can be used by the client devices to replicate data. The RxServer plugin is designed to be used in Node.js but you can also use it in Deno, Bun or the Electron \\"main\\" process. You can use it either as a standalone server or add it on top of an existing http server (like express) in nodejs.","sidebar":"tutorialSidebar"},"rx-server-scaling":{"id":"rx-server-scaling","title":"RxServer Scaling","description":"Explore how to scale the RxServer with vertical and horizontal methods, including multiple processes, worker threads, in-memory storage, and replication strategies for enhanced performance.","sidebar":"tutorialSidebar"},"rx-state":{"id":"rx-state","title":"RxState","description":"RxState is a flexible state library build on top of the RxDB Database. While RxDB stores similar documents inside of collections, RxState can store any complex JSON data without having a predefined schema.","sidebar":"tutorialSidebar"},"rx-storage":{"id":"rx-storage","title":"\u2699\ufe0f Rxstorage Layer","description":"RxDB is not a self contained database. Instead the data is stored in an implementation of the RxStorage interface. This allows you to switch out the underlying data layer, depending on the JavaScript environment and performance requirements. For example you can use the SQLite storage for a capacitor app or you can use the Dexie.js RxStorage to store data in IndexedDB in a browser based application. There are also storages for other JavaScript runtimes like Node.js, React-Native, NativeScript and more.","sidebar":"tutorialSidebar"},"rx-storage-denokv":{"id":"rx-storage-denokv","title":"DenoKV RxStorage","description":"With the DenoKV RxStorage layer for RxDB, you can run a fully featured NoSQL database on top of the DenoKV API.","sidebar":"tutorialSidebar"},"rx-storage-dexie":{"id":"rx-storage-dexie","title":"Dexie.js RxStorage","description":"To store the data inside of IndexedDB in the browser, you can also use the Dexie.js RxStorage.","sidebar":"tutorialSidebar"},"rx-storage-filesystem-node":{"id":"rx-storage-filesystem-node","title":"Node.js Filesystem RxStorage \ud83d\udc51","description":"The Filesystem Node RxStorage for RxDB is built on top of the Node.js Filesystem API.","sidebar":"tutorialSidebar"},"rx-storage-foundationdb":{"id":"rx-storage-foundationdb","title":"FoundationDB RxStorage","description":"Explore the advanced features of RxDB with FoundationDB RxStorage - Efficient indexing, complex NoSQL queries, real-time updates, data compression, and attachment management for optimized database performance and scalability","sidebar":"tutorialSidebar"},"rx-storage-indexeddb":{"id":"rx-storage-indexeddb","title":"IndexedDB RxStorage \ud83d\udc51","description":"Optimize browser, Electron, and hybrid app performance with IndexedDB RxStorage with the fastest, smallest build size storage solution for small to medium datasets.","sidebar":"tutorialSidebar"},"rx-storage-localstorage-meta-optimizer":{"id":"rx-storage-localstorage-meta-optimizer","title":"RxStorage Localstorage Meta Optimizer \ud83d\udc51","description":"The RxStorage Localstorage Meta Optimizer is a wrapper around any other RxStorage. The wrapper uses the original RxStorage for normal collection documents. But to optimize the initial page load time, it uses localstorage to store the plain key-value metadata that RxDB needs to create databases and collections. This plugin can only be used in browsers.","sidebar":"tutorialSidebar"},"rx-storage-lokijs":{"id":"rx-storage-lokijs","title":"LokiJS RxStorage","description":"The LokiJS RxStorage is based on LokiJS which is an in-memory database that processes all data in memory and only saves to disc when the app is closed or an interval is reached. This makes it very fast but you have the possibility to lose semingly persisted writes when the JavaScript process ends before the persistence loop has been done.","sidebar":"tutorialSidebar"},"rx-storage-memory":{"id":"rx-storage-memory","title":"Memory RxStorage","description":"\x3c!-- keywords:","sidebar":"tutorialSidebar"},"rx-storage-memory-synced":{"id":"rx-storage-memory-synced","title":"Memory Synced RxStorage \ud83d\udc51","description":"The memory synced RxStorage is a wrapper around any other RxStorage. The wrapper creates an in-memory storage that is used for query and write operations. This memory instance is replicated with the underlying storage for persistence.","sidebar":"tutorialSidebar"},"rx-storage-mongodb":{"id":"rx-storage-mongodb","title":"MongoDB RxStorage","description":"RxDB MongoDB RxStorage is an RxDB RxStorage that allows you to use MongoDB as the underlying storage engine for your RxDB database. With this you can take advantage of MongoDB\'s features and scalability while benefiting from RxDB\'s real-time data synchronization capabilities.","sidebar":"tutorialSidebar"},"rx-storage-opfs":{"id":"rx-storage-opfs","title":"OPFS RxStorage \ud83d\udc51","description":"Origin Private File System (OPFS) Database with the RxDB OPFS-RxStorage","sidebar":"tutorialSidebar"},"rx-storage-performance":{"id":"rx-storage-performance","title":"\ud83d\udcc8 RxStorage Performance","description":"RxStorage Performance comparison","sidebar":"tutorialSidebar"},"rx-storage-pouchdb":{"id":"rx-storage-pouchdb","title":"PouchDB RxStorage","description":"The PouchDB RxStorage is based on the PouchDB database. It is the most battle proven RxStorage and has a big ecosystem of adapters. PouchDB does a lot of overhead to enable CouchDB replication which makes the PouchDB RxStorage one of the slowest."},"rx-storage-remote":{"id":"rx-storage-remote","title":"Remote RxStorage","description":"The Remote RxStorage is made to use a remote storage and communicate with it over an asynchronous message channel.","sidebar":"tutorialSidebar"},"rx-storage-sharding":{"id":"rx-storage-sharding","title":"Sharding RxStorage \ud83d\udc51","description":"With the sharding plugin, you can improve the write and query times of some RxStorage implementations.","sidebar":"tutorialSidebar"},"rx-storage-shared-worker":{"id":"rx-storage-shared-worker","title":"SharedWorker RxStorage \ud83d\udc51","description":"The SharedWorker RxStorage uses the SharedWorker API to run the storage inside of a separate JavaScript process in browsers. Compared to a normal WebWorker, the SharedWorker is created exactly once, even when there are multiple browser tabs opened. Because of having exactly one worker, multiple performance optimizations can be done because the storage itself does not have to handle multiple opened database connections.","sidebar":"tutorialSidebar"},"rx-storage-sqlite":{"id":"rx-storage-sqlite","title":"SQLite RxStorage \ud83d\udc51","description":"This RxStorage is based on SQLite and is made to work with Node.js, Electron, React Native and Capacitor or SQLite via webassembly in the browser. It can be used with different so called sqliteBasics adapters to account for the differences in the various SQLite bundles and libraries that exist.","sidebar":"tutorialSidebar"},"rx-storage-worker":{"id":"rx-storage-worker","title":"Worker RxStorage \ud83d\udc51","description":"With the worker plugin, you can put the RxStorage of your database inside of a WebWorker (in browsers) or a Worker Thread (in node.js). By doing so, you can take CPU load from the main process and move it into the worker\'s process which can improve the perceived performance of your application. Notice that for browsers, it is recommend to use the SharedWorker instead to get a better performance.","sidebar":"tutorialSidebar"},"rxdb-tradeoffs":{"id":"rxdb-tradeoffs","title":"RxDB Tradeoffs","description":"RxDB is client-side, offline first Database for JavaScript applications."},"schema-validation":{"id":"schema-validation","title":"Schema Validation","description":"RxDB has multiple validation implementations that can be used to ensure that your document data is always matching the provided JSON"},"slow-indexeddb":{"id":"slow-indexeddb","title":"Slow IndexedDB","description":"So you have a JavaScript web application that needs to store data at the client side, either to make it offline usable, just for caching purposes or for other reasons.","sidebar":"tutorialSidebar"},"third-party-plugins":{"id":"third-party-plugins","title":"Third Party Plugins","description":"* rxdb-hooks A set of hooks to integrate RxDB into react applications.","sidebar":"tutorialSidebar"},"transactions-conflicts-revisions":{"id":"transactions-conflicts-revisions","title":"Transactions, Conflicts and Revisions","description":"In contrast to most SQL databases, RxDB does not have the concept of relational, ACID transactions. Instead, RxDB has to apply different techniques that better suit the offline-first, client side world where it is not possible to create a transaction between multiple maybe-offline client devices.","sidebar":"tutorialSidebar"},"tutorials/typescript":{"id":"tutorials/typescript","title":"RxDB TypeScript Tutorial","description":"In this tutorial you will learn how to use RxDB with TypeScript.","sidebar":"tutorialSidebar"},"why-nosql":{"id":"why-nosql","title":"Why NOSQL","description":"RxDB, a client side, offline first, JavaScript database, is now several years old.","sidebar":"tutorialSidebar"}}}')}}]); \ No newline at end of file diff --git a/docs/assets/js/cde77f4f.b17a3699.js b/docs/assets/js/cde77f4f.ebf53539.js similarity index 99% rename from docs/assets/js/cde77f4f.b17a3699.js rename to docs/assets/js/cde77f4f.ebf53539.js index 5fe8442897f..5ea6067bb98 100644 --- a/docs/assets/js/cde77f4f.b17a3699.js +++ b/docs/assets/js/cde77f4f.ebf53539.js @@ -1 +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.11.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:[],createRxState:[],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.states={},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.addState=function(e){throw yt("state")},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:"Republic of Korea",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.name>=t.name?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 +"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.12.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:[],createRxState:[],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.states={},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.addState=function(e){throw yt("state")},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:"Republic of Korea",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.name>=t.name?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.2150b686.js b/docs/assets/js/db34d6b0.aa85a0ae.js similarity index 99% rename from docs/assets/js/db34d6b0.2150b686.js rename to docs/assets/js/db34d6b0.aa85a0ae.js index 2f01e69da94..5538bcdb12f 100644 --- a/docs/assets/js/db34d6b0.2150b686.js +++ b/docs/assets/js/db34d6b0.aa85a0ae.js @@ -1 +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.11.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 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:[],createRxState:[],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.states={},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.addState=function(e){throw vt("state")},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="premium_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(u,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 +"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.12.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:[],createRxState:[],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.states={},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.addState=function(e){throw vt("state")},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="premium_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(u,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.0d1a1a20.js b/docs/assets/js/main.0c0128ea.js similarity index 99% rename from docs/assets/js/main.0d1a1a20.js rename to docs/assets/js/main.0c0128ea.js index dbc95e43774..9520f7ccf72 100644 --- a/docs/assets/js/main.0d1a1a20.js +++ b/docs/assets/js/main.0c0128ea.js @@ -1,2 +1,2 @@ -/*! For license information please see main.0d1a1a20.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(1869),n.e(5106),n.e(4579),n.e(4583)]).then(n.bind(n,6866)),"@site/src/pages/index.tsx",6866],"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],"280a2389":[()=>Promise.all([n.e(5106),n.e(176)]).then(n.bind(n,8141)),"@site/src/pages/meeting.tsx",8141],"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],c44853e1:[()=>n.e(6584).then(n.bind(n,7390)),"@site/docs/rx-state.md",7390],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:"/meeting",component:d("/meeting","6b0"),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("/","f6a"),routes:[{path:"/",component:d("/","854"),routes:[{path:"/",component:d("/","1b8"),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-state.html",component:d("/rx-state.html","198"),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-lunr-search":{"default":{"fileNames":{"searchDoc":"search-doc-1710240912552.json","lunrIndex":"lunr-index-1710240912552.json"}}},"docusaurus-plugin-google-gtag":{"default":{"trackingID":["G-62D63SY3S0"],"anonymizeIP":false,"id":"default"}},"docusaurus-plugin-google-tag-manager":{"default":{"containerId":"GTM-PL63TR5","id":"default"}},"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-state","path":"/rx-state.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-google-tag-manager":{"type":"package","name":"@docusaurus/plugin-google-tag-manager","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