From aae676b3bed4c9aedef8b13d1baae0b6ce2d2e60 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:01:55 +0000 Subject: [PATCH] 15.18.2 --- CHANGELOG.md | 6 +++++- .../plugins/storage-memory/rx-storage-instance-memory.js | 9 +++++++++ .../storage-memory/rx-storage-instance-memory.js.map | 2 +- dist/cjs/plugins/utils/utils-rxdb-version.js | 2 +- dist/cjs/plugins/utils/utils-rxdb-version.js.map | 2 +- dist/cjs/rx-storage-helper.js.map | 2 +- .../plugins/storage-memory/rx-storage-instance-memory.js | 9 +++++++++ .../storage-memory/rx-storage-instance-memory.js.map | 2 +- dist/esm/plugins/utils/utils-rxdb-version.js | 2 +- dist/esm/plugins/utils/utils-rxdb-version.js.map | 2 +- dist/esm/rx-storage-helper.js.map | 2 +- dist/types/plugins/storage-denokv/index.d.ts | 2 +- dist/types/plugins/storage-dexie/rx-storage-dexie.d.ts | 2 +- dist/types/plugins/storage-lokijs/rx-storage-lokijs.d.ts | 2 +- .../storage-memory/rx-storage-instance-memory.d.ts | 9 ++++++++- .../plugins/storage-mongodb/rx-storage-mongodb.d.ts | 2 +- dist/types/plugins/storage-remote/rx-storage-remote.d.ts | 2 +- dist/types/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 ++-- docs/articles/progressive-web-app-database.html | 4 ++-- docs/articles/react-database.html | 4 ++-- docs/articles/realtime-database.html | 4 ++-- .../websockets-sse-polling-webrtc-webtransport.html | 4 ++-- .../js/{0e268d20.60e1364a.js => 0e268d20.61206afa.js} | 2 +- .../js/{1df93b7f.0b4dbce7.js => 1df93b7f.38923739.js} | 2 +- .../js/{280a2389.95c2e659.js => 280a2389.5b3df3d5.js} | 2 +- .../js/{4f17bbdd.dffc1562.js => 4f17bbdd.ff63f20a.js} | 2 +- .../js/{7bbb96fd.b645735e.js => 7bbb96fd.b49e06ee.js} | 2 +- .../js/{cde77f4f.e330432a.js => cde77f4f.82016b37.js} | 2 +- .../js/{db34d6b0.18d7964e.js => db34d6b0.8ce45070.js} | 2 +- docs/assets/js/{main.e87ecdb8.js => main.f7f42393.js} | 4 ++-- ...ecdb8.js.LICENSE.txt => main.f7f42393.js.LICENSE.txt} | 0 ...runtime~main.2e62ef44.js => runtime~main.551749d7.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/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-1713968233231.json | 1 - docs/lunr-index-1714046474059.json | 1 + docs/lunr-index.json | 2 +- docs/markdown-page/index.html | 4 ++-- docs/meeting-paid/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 ++-- docs/rx-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 | 4 ++-- docs/rx-storage-worker.html | 4 ++-- docs/rx-storage.html | 4 ++-- docs/rxdb-tradeoffs.html | 4 ++-- docs/schema-validation.html | 4 ++-- docs/search-doc-1713968233231.json | 1 - docs/search-doc-1714046474059.json | 1 + docs/search-doc.json | 2 +- docs/service-submitted/index.html | 4 ++-- 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 +- 153 files changed, 294 insertions(+), 265 deletions(-) rename docs/assets/js/{0e268d20.60e1364a.js => 0e268d20.61206afa.js} (99%) rename docs/assets/js/{1df93b7f.0b4dbce7.js => 1df93b7f.38923739.js} (99%) rename docs/assets/js/{280a2389.95c2e659.js => 280a2389.5b3df3d5.js} (99%) rename docs/assets/js/{4f17bbdd.dffc1562.js => 4f17bbdd.ff63f20a.js} (99%) rename docs/assets/js/{7bbb96fd.b645735e.js => 7bbb96fd.b49e06ee.js} (99%) rename docs/assets/js/{cde77f4f.e330432a.js => cde77f4f.82016b37.js} (99%) rename docs/assets/js/{db34d6b0.18d7964e.js => db34d6b0.8ce45070.js} (99%) rename docs/assets/js/{main.e87ecdb8.js => main.f7f42393.js} (99%) rename docs/assets/js/{main.e87ecdb8.js.LICENSE.txt => main.f7f42393.js.LICENSE.txt} (100%) rename docs/assets/js/{runtime~main.2e62ef44.js => runtime~main.551749d7.js} (71%) delete mode 100644 docs/lunr-index-1713968233231.json create mode 100644 docs/lunr-index-1714046474059.json delete mode 100644 docs/search-doc-1713968233231.json create mode 100644 docs/search-doc-1714046474059.json diff --git a/CHANGELOG.md b/CHANGELOG.md index f0f4f7455ef..279cd25c3df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,17 @@ # RxDB Changelog -- Memory RxStorage: Add `categorizedByWriteInput` property that can be used by other plugins. + +### 15.18.2 (25 April 2024) + +- Memory RxStorage: Add `categorizedByWriteInput` property that can be used by other plugins. + ### 15.18.1 (18 April 2024) - FIX CouchDB replication error `Cannot read properties of undefined (reading '_attachments')` diff --git a/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js b/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js index 956707f3f29..035b4fc58b9 100644 --- a/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js +++ b/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js @@ -20,8 +20,16 @@ var _rxQueryHelper = require("../../rx-query-helper.js"); */ var OPEN_MEMORY_INSTANCES = exports.OPEN_MEMORY_INSTANCES = new Set(); var RxStorageInstanceMemory = exports.RxStorageInstanceMemory = /*#__PURE__*/function () { + /** + * Used by some plugins and storage wrappers + * to find out details about the internals of a write operation. + * For example if you want to know which documents really have been replaced + * or newly inserted. + */ + function RxStorageInstanceMemory(storage, databaseName, collectionName, schema, internals, options, settings) { this.closed = false; + this.categorizedByWriteInput = new WeakMap(); this.storage = storage; this.databaseName = databaseName; this.collectionName = collectionName; @@ -54,6 +62,7 @@ var RxStorageInstanceMemory = exports.RxStorageInstanceMemory = /*#__PURE__*/fun var _doc = _writeRow.document; success.push(_doc); } + this.categorizedByWriteInput.set(documentWrites, categorized); this.internals.ensurePersistenceTask = categorized; if (!this.internals.ensurePersistenceIdlePromise) { this.internals.ensurePersistenceIdlePromise = (0, _index.requestIdlePromiseNoQueue)().then(() => { diff --git a/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js.map b/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js.map index bf2013d6e1b..1a0d47c211f 100644 --- a/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js.map +++ b/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js.map @@ -1 +1 @@ -{"version":3,"file":"rx-storage-instance-memory.js","names":["_rxjs","require","_customIndex","_rxSchemaHelper","_rxStorageHelper","_index","_binarySearchBounds","_memoryHelper","_memoryIndexes","_rxQueryHelper","OPEN_MEMORY_INSTANCES","exports","Set","RxStorageInstanceMemory","storage","databaseName","collectionName","schema","internals","options","settings","closed","add","primaryPath","getPrimaryFieldOfPrimaryKey","primaryKey","_proto","prototype","bulkWrite","documentWrites","context","ensurePersistence","ensureNotRemoved","documentsById","documents","categorized","categorizeBulkWriteRows","error","errors","success","Array","bulkInsertDocs","length","i","writeRow","doc","document","bulkUpdateDocs","push","ensurePersistenceTask","ensurePersistenceIdlePromise","requestIdlePromiseNoQueue","then","undefined","eventBulk","events","lastState","ensureNotFalsy","newestRow","checkpoint","id","lwt","_meta","endTime","now","PROMISE_RESOLVE_TRUE","changes$","next","ret","Promise","resolve","stateByIndex","Object","values","byIndex","docId","putWriteRowToState","get","attachments","attachmentsMap","attachmentsAdd","forEach","attachment","set","attachmentMapKey","documentId","attachmentId","writeData","attachmentData","digest","attachmentsUpdate","attachmentsRemove","delete","findDocumentsById","docIds","withDeleted","size","docInDb","_deleted","query","preparedQuery","queryPlan","skip","limit","Infinity","skipPlusLimit","queryMatcher","selectorSatisfiedByIndex","getQueryMatcher","queryPlanFields","index","mustManuallyResort","sortSatisfiedByIndex","lowerBound","startKeys","lowerBoundString","getStartIndexStringFromLowerBound","upperBound","endKeys","upperBoundString","getStartIndexStringFromUpperBound","indexName","getMemoryIndexName","Error","docsWithIndex","indexOfLower","inclusiveStart","boundGE","boundGT","indexString","compareDocsWithIndex","indexOfUpper","inclusiveEnd","boundLE","boundLT","rows","done","currentRow","currentDoc","sortComparator","getSortComparator","sort","slice","count","result","mode","cleanup","minimumDeletedTime","maxDeletionTime","removeDocFromState","getAttachmentData","key","data","changeStream","asObservable","remove","removed","collectionStates","getMemoryCollectionKey","version","close","PROMISE_RESOLVE_VOID","refCount","conflictResultionTasks","conflictResultionTasks$","resolveConflictResultionTask","_taskSolution","createMemoryStorageInstance","params","collectionKey","randomCouchString","Map","Subject","addIndexesToInternalsState","devMode","deepEqual","instance"],"sources":["../../../../src/plugins/storage-memory/rx-storage-instance-memory.ts"],"sourcesContent":["import {\n Observable,\n Subject\n} from 'rxjs';\nimport {\n getStartIndexStringFromLowerBound,\n getStartIndexStringFromUpperBound\n} from '../../custom-index.ts';\nimport { getPrimaryFieldOfPrimaryKey } from '../../rx-schema-helper.ts';\nimport {\n categorizeBulkWriteRows\n} from '../../rx-storage-helper.ts';\nimport type {\n BulkWriteRow,\n EventBulk,\n PreparedQuery,\n QueryMatcher,\n RxConflictResultionTask,\n RxConflictResultionTaskSolution,\n RxDocumentData,\n RxJsonSchema,\n RxStorageBulkWriteResponse,\n RxStorageChangeEvent,\n RxStorageCountResult,\n RxStorageDefaultCheckpoint,\n RxStorageInstance,\n RxStorageInstanceCreationParams,\n RxStorageQueryResult,\n StringKeys\n} from '../../types/index.d.ts';\nimport {\n deepEqual,\n ensureNotFalsy,\n now,\n PROMISE_RESOLVE_TRUE,\n PROMISE_RESOLVE_VOID,\n randomCouchString,\n requestIdlePromiseNoQueue\n} from '../../plugins/utils/index.ts';\nimport {\n boundGE,\n boundGT,\n boundLE,\n boundLT\n} from './binary-search-bounds.ts';\nimport {\n attachmentMapKey,\n compareDocsWithIndex,\n ensureNotRemoved,\n getMemoryCollectionKey,\n putWriteRowToState,\n removeDocFromState\n} from './memory-helper.ts';\nimport {\n addIndexesToInternalsState,\n getMemoryIndexName\n} from './memory-indexes.ts';\nimport type {\n MemoryStorageInternals,\n RxStorageMemory,\n RxStorageMemoryInstanceCreationOptions,\n RxStorageMemorySettings\n} from './memory-types.ts';\nimport { getQueryMatcher, getSortComparator } from '../../rx-query-helper.ts';\n\n/**\n * Used in tests to ensure everything\n * is closed correctly\n */\nexport const OPEN_MEMORY_INSTANCES = new Set>();\n\nexport class RxStorageInstanceMemory implements RxStorageInstance<\n RxDocType,\n MemoryStorageInternals,\n RxStorageMemoryInstanceCreationOptions,\n RxStorageDefaultCheckpoint\n> {\n\n public readonly primaryPath: StringKeys>;\n public closed = false;\n\n constructor(\n public readonly storage: RxStorageMemory,\n public readonly databaseName: string,\n public readonly collectionName: string,\n public readonly schema: Readonly>>,\n public readonly internals: MemoryStorageInternals,\n public readonly options: Readonly,\n public readonly settings: RxStorageMemorySettings\n ) {\n OPEN_MEMORY_INSTANCES.add(this);\n this.primaryPath = getPrimaryFieldOfPrimaryKey(this.schema.primaryKey);\n }\n\n bulkWrite(\n documentWrites: BulkWriteRow[],\n context: string\n ): Promise> {\n this.ensurePersistence();\n ensureNotRemoved(this);\n const internals = this.internals;\n const documentsById = this.internals.documents;\n const primaryPath = this.primaryPath;\n\n const categorized = categorizeBulkWriteRows(\n this,\n primaryPath as any,\n documentsById,\n documentWrites,\n context\n );\n const error = categorized.errors;\n const success: RxDocumentData[] = new Array(categorized.bulkInsertDocs.length);\n const bulkInsertDocs = categorized.bulkInsertDocs;\n for (let i = 0; i < bulkInsertDocs.length; ++i) {\n const writeRow = bulkInsertDocs[i];\n const doc = writeRow.document;\n success[i] = doc;\n }\n const bulkUpdateDocs = categorized.bulkUpdateDocs;\n for (let i = 0; i < bulkUpdateDocs.length; ++i) {\n const writeRow = bulkUpdateDocs[i];\n const doc = writeRow.document;\n success.push(doc);\n }\n\n this.internals.ensurePersistenceTask = categorized;\n if (!this.internals.ensurePersistenceIdlePromise) {\n this.internals.ensurePersistenceIdlePromise = requestIdlePromiseNoQueue().then(() => {\n this.internals.ensurePersistenceIdlePromise = undefined;\n this.ensurePersistence();\n });\n }\n\n /**\n * Important: The events must be emitted AFTER the persistence\n * task has been added.\n */\n if (categorized.eventBulk.events.length > 0) {\n const lastState = ensureNotFalsy(categorized.newestRow).document;\n categorized.eventBulk.checkpoint = {\n id: lastState[primaryPath],\n lwt: lastState._meta.lwt\n };\n categorized.eventBulk.endTime = now();\n PROMISE_RESOLVE_TRUE.then(() => {\n internals.changes$.next(categorized.eventBulk);\n });\n }\n\n const ret = Promise.resolve({ success, error });\n return ret;\n }\n\n /**\n * Instead of directly inserting the documents into all indexes,\n * we do it lazy in the background. This gives the application time\n * to directly work with the write-result and to do stuff like rendering DOM\n * notes and processing RxDB queries.\n * Then in some later time, or just before the next read/write,\n * it is ensured that the indexes have been written.\n */\n public ensurePersistence() {\n if (\n !this.internals.ensurePersistenceTask\n ) {\n return;\n }\n const internals = this.internals;\n const documentsById = this.internals.documents;\n const primaryPath = this.primaryPath;\n\n const categorized = this.internals.ensurePersistenceTask;\n this.internals.ensurePersistenceTask = undefined;\n\n /**\n * Do inserts/updates\n */\n const stateByIndex = Object.values(this.internals.byIndex);\n\n const bulkInsertDocs = categorized.bulkInsertDocs;\n for (let i = 0; i < bulkInsertDocs.length; ++i) {\n const writeRow = bulkInsertDocs[i];\n const doc = writeRow.document;\n const docId = doc[primaryPath];\n putWriteRowToState(\n docId as any,\n internals,\n stateByIndex,\n writeRow,\n undefined\n );\n }\n\n const bulkUpdateDocs = categorized.bulkUpdateDocs;\n for (let i = 0; i < bulkUpdateDocs.length; ++i) {\n const writeRow = bulkUpdateDocs[i];\n const doc = writeRow.document;\n const docId = doc[primaryPath];\n putWriteRowToState(\n docId as any,\n internals,\n stateByIndex,\n writeRow,\n documentsById.get(docId as any)\n );\n }\n\n /**\n * Handle attachments\n */\n if (this.schema.attachments) {\n const attachmentsMap = internals.attachments;\n categorized.attachmentsAdd.forEach(attachment => {\n attachmentsMap.set(\n attachmentMapKey(attachment.documentId, attachment.attachmentId),\n {\n writeData: attachment.attachmentData,\n digest: attachment.digest\n }\n );\n });\n if (this.schema.attachments) {\n categorized.attachmentsUpdate.forEach(attachment => {\n attachmentsMap.set(\n attachmentMapKey(attachment.documentId, attachment.attachmentId),\n {\n writeData: attachment.attachmentData,\n digest: attachment.digest\n }\n );\n });\n categorized.attachmentsRemove.forEach(attachment => {\n attachmentsMap.delete(\n attachmentMapKey(attachment.documentId, attachment.attachmentId)\n );\n });\n }\n }\n }\n\n findDocumentsById(\n docIds: string[],\n withDeleted: boolean\n ): Promise[]> {\n this.ensurePersistence();\n const documentsById = this.internals.documents;\n const ret: RxDocumentData[] = [];\n if (documentsById.size === 0) {\n return Promise.resolve(ret);\n }\n for (let i = 0; i < docIds.length; ++i) {\n const docId = docIds[i];\n const docInDb = documentsById.get(docId);\n if (\n docInDb &&\n (\n !docInDb._deleted ||\n withDeleted\n )\n ) {\n ret.push(docInDb);\n }\n }\n return Promise.resolve(ret);\n }\n\n query(\n preparedQuery: PreparedQuery\n ): Promise> {\n this.ensurePersistence();\n\n const queryPlan = preparedQuery.queryPlan;\n const query = preparedQuery.query;\n\n const skip = query.skip ? query.skip : 0;\n const limit = query.limit ? query.limit : Infinity;\n const skipPlusLimit = skip + limit;\n\n let queryMatcher: QueryMatcher> | false = false;\n if (!queryPlan.selectorSatisfiedByIndex) {\n queryMatcher = getQueryMatcher(\n this.schema,\n preparedQuery.query\n );\n }\n\n const queryPlanFields: string[] = queryPlan.index;\n const mustManuallyResort = !queryPlan.sortSatisfiedByIndex;\n const index: string[] | undefined = queryPlanFields;\n const lowerBound: any[] = queryPlan.startKeys;\n const lowerBoundString = getStartIndexStringFromLowerBound(\n this.schema,\n index,\n lowerBound\n );\n\n let upperBound: any[] = queryPlan.endKeys;\n upperBound = upperBound;\n const upperBoundString = getStartIndexStringFromUpperBound(\n this.schema,\n index,\n upperBound\n );\n const indexName = getMemoryIndexName(index);\n\n if (!this.internals.byIndex[indexName]) {\n throw new Error('index does not exist ' + indexName);\n }\n const docsWithIndex = this.internals.byIndex[indexName].docsWithIndex;\n\n\n\n let indexOfLower = (queryPlan.inclusiveStart ? boundGE : boundGT)(\n docsWithIndex,\n {\n indexString: lowerBoundString\n } as any,\n compareDocsWithIndex\n );\n\n const indexOfUpper = (queryPlan.inclusiveEnd ? boundLE : boundLT)(\n docsWithIndex,\n {\n indexString: upperBoundString\n } as any,\n compareDocsWithIndex\n );\n\n let rows: RxDocumentData[] = [];\n let done = false;\n while (!done) {\n const currentRow = docsWithIndex[indexOfLower];\n if (\n !currentRow ||\n indexOfLower > indexOfUpper\n ) {\n break;\n }\n const currentDoc = currentRow.doc;\n\n if (!queryMatcher || queryMatcher(currentDoc)) {\n rows.push(currentDoc);\n }\n\n if (\n (rows.length >= skipPlusLimit && !mustManuallyResort)\n ) {\n done = true;\n }\n\n indexOfLower++;\n }\n\n if (mustManuallyResort) {\n const sortComparator = getSortComparator(this.schema, preparedQuery.query);\n rows = rows.sort(sortComparator);\n }\n\n // apply skip and limit boundaries.\n rows = rows.slice(skip, skipPlusLimit);\n return Promise.resolve({\n documents: rows\n });\n }\n\n async count(\n preparedQuery: PreparedQuery\n ): Promise {\n this.ensurePersistence();\n const result = await this.query(preparedQuery);\n return {\n count: result.documents.length,\n mode: 'fast'\n };\n }\n\n cleanup(minimumDeletedTime: number): Promise {\n this.ensurePersistence();\n const maxDeletionTime = now() - minimumDeletedTime;\n const index = ['_deleted', '_meta.lwt', this.primaryPath as any];\n const indexName = getMemoryIndexName(index);\n const docsWithIndex = this.internals.byIndex[indexName].docsWithIndex;\n\n const lowerBoundString = getStartIndexStringFromLowerBound(\n this.schema,\n index,\n [\n true,\n 0,\n ''\n ]\n );\n\n let indexOfLower = boundGT(\n docsWithIndex,\n {\n indexString: lowerBoundString\n } as any,\n compareDocsWithIndex\n );\n\n let done = false;\n while (!done) {\n const currentDoc = docsWithIndex[indexOfLower];\n if (!currentDoc || currentDoc.doc._meta.lwt > maxDeletionTime) {\n done = true;\n } else {\n removeDocFromState(\n this.primaryPath as any,\n this.schema,\n this.internals,\n currentDoc.doc\n );\n indexOfLower++;\n }\n }\n return PROMISE_RESOLVE_TRUE;\n }\n\n getAttachmentData(\n documentId: string,\n attachmentId: string,\n digest: string\n ): Promise {\n this.ensurePersistence();\n ensureNotRemoved(this);\n const key = attachmentMapKey(documentId, attachmentId);\n const data = this.internals.attachments.get(key);\n\n if (\n !digest ||\n !data ||\n data.digest !== digest\n ) {\n throw new Error('attachment does not exist: ' + key);\n }\n return Promise.resolve(data.writeData.data);\n }\n\n changeStream(): Observable>, RxStorageDefaultCheckpoint>> {\n ensureNotRemoved(this);\n return this.internals.changes$.asObservable();\n }\n\n async remove(): Promise {\n if (this.closed) {\n throw new Error('closed');\n }\n this.ensurePersistence();\n ensureNotRemoved(this);\n\n this.internals.removed = true;\n this.storage.collectionStates.delete(\n getMemoryCollectionKey(\n this.databaseName,\n this.collectionName,\n this.schema.version\n )\n );\n await this.close();\n }\n\n close(): Promise {\n OPEN_MEMORY_INSTANCES.delete(this);\n\n this.ensurePersistence();\n if (this.closed) {\n return PROMISE_RESOLVE_VOID;\n }\n this.closed = true;\n\n this.internals.refCount = this.internals.refCount - 1;\n return PROMISE_RESOLVE_VOID;\n }\n\n conflictResultionTasks(): Observable> {\n return this.internals.conflictResultionTasks$.asObservable();\n }\n resolveConflictResultionTask(_taskSolution: RxConflictResultionTaskSolution): Promise {\n return PROMISE_RESOLVE_VOID;\n }\n}\n\nexport function createMemoryStorageInstance(\n storage: RxStorageMemory,\n params: RxStorageInstanceCreationParams,\n settings: RxStorageMemorySettings\n): Promise> {\n const collectionKey = getMemoryCollectionKey(\n params.databaseName,\n params.collectionName,\n params.schema.version\n );\n\n let internals = storage.collectionStates.get(collectionKey);\n if (!internals) {\n internals = {\n id: randomCouchString(5),\n schema: params.schema,\n removed: false,\n refCount: 1,\n documents: new Map(),\n attachments: params.schema.attachments ? new Map() : undefined as any,\n byIndex: {},\n conflictResultionTasks$: new Subject(),\n changes$: new Subject()\n };\n addIndexesToInternalsState(internals, params.schema);\n storage.collectionStates.set(collectionKey, internals);\n } else {\n /**\n * Ensure that the storage was not already\n * created with a different schema.\n * This is very important because if this check\n * does not exist here, we have hard-to-debug problems\n * downstream.\n */\n if (\n params.devMode &&\n !deepEqual(internals.schema, params.schema)\n ) {\n throw new Error('storage was already created with a different schema');\n }\n internals.refCount = internals.refCount + 1;\n }\n\n const instance = new RxStorageInstanceMemory(\n storage,\n params.databaseName,\n params.collectionName,\n params.schema,\n internals,\n params.options,\n settings\n );\n return Promise.resolve(instance);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAIA,IAAAC,YAAA,GAAAD,OAAA;AAIA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAqBA,IAAAI,MAAA,GAAAJ,OAAA;AASA,IAAAK,mBAAA,GAAAL,OAAA;AAMA,IAAAM,aAAA,GAAAN,OAAA;AAQA,IAAAO,cAAA,GAAAP,OAAA;AAUA,IAAAQ,cAAA,GAAAR,OAAA;AAEA;AACA;AACA;AACA;AACO,IAAMS,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,IAAIE,GAAG,CAA+B,CAAC;AAAC,IAEhEC,uBAAuB,GAAAF,OAAA,CAAAE,uBAAA;EAUhC,SAAAA,wBACoBC,OAAwB,EACxBC,YAAoB,EACpBC,cAAsB,EACtBC,MAAyD,EACzDC,SAA4C,EAC5CC,OAAyD,EACzDC,QAAiC,EACnD;IAAA,KAVKC,MAAM,GAAG,KAAK;IAAA,KAGDP,OAAwB,GAAxBA,OAAwB;IAAA,KACxBC,YAAoB,GAApBA,YAAoB;IAAA,KACpBC,cAAsB,GAAtBA,cAAsB;IAAA,KACtBC,MAAyD,GAAzDA,MAAyD;IAAA,KACzDC,SAA4C,GAA5CA,SAA4C;IAAA,KAC5CC,OAAyD,GAAzDA,OAAyD;IAAA,KACzDC,QAAiC,GAAjCA,QAAiC;IAEjDV,qBAAqB,CAACY,GAAG,CAAC,IAAI,CAAC;IAC/B,IAAI,CAACC,WAAW,GAAG,IAAAC,2CAA2B,EAAC,IAAI,CAACP,MAAM,CAACQ,UAAU,CAAC;EAC1E;EAAC,IAAAC,MAAA,GAAAb,uBAAA,CAAAc,SAAA;EAAAD,MAAA,CAEDE,SAAS,GAAT,SAAAA,UACIC,cAAyC,EACz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AAM,EACbC,SAAS,EACTsJ,MAAM,CAACrJ,OAAO,EACdC,QACJ,CAAC;EACD,OAAOiD,OAAO,CAACC,OAAO,CAAC0G,QAAQ,CAAC;AACpC","ignoreList":[]} \ No newline at end of file +{"version":3,"file":"rx-storage-instance-memory.js","names":["_rxjs","require","_customIndex","_rxSchemaHelper","_rxStorageHelper","_index","_binarySearchBounds","_memoryHelper","_memoryIndexes","_rxQueryHelper","OPEN_MEMORY_INSTANCES","exports","Set","RxStorageInstanceMemory","storage","databaseName","collectionName","schema","internals","options","settings","closed","categorizedByWriteInput","WeakMap","add","primaryPath","getPrimaryFieldOfPrimaryKey","primaryKey","_proto","prototype","bulkWrite","documentWrites","context","ensurePersistence","ensureNotRemoved","documentsById","documents","categorized","categorizeBulkWriteRows","error","errors","success","Array","bulkInsertDocs","length","i","writeRow","doc","document","bulkUpdateDocs","push","set","ensurePersistenceTask","ensurePersistenceIdlePromise","requestIdlePromiseNoQueue","then","undefined","eventBulk","events","lastState","ensureNotFalsy","newestRow","checkpoint","id","lwt","_meta","endTime","now","PROMISE_RESOLVE_TRUE","changes$","next","ret","Promise","resolve","stateByIndex","Object","values","byIndex","docId","putWriteRowToState","get","attachments","attachmentsMap","attachmentsAdd","forEach","attachment","attachmentMapKey","documentId","attachmentId","writeData","attachmentData","digest","attachmentsUpdate","attachmentsRemove","delete","findDocumentsById","docIds","withDeleted","size","docInDb","_deleted","query","preparedQuery","queryPlan","skip","limit","Infinity","skipPlusLimit","queryMatcher","selectorSatisfiedByIndex","getQueryMatcher","queryPlanFields","index","mustManuallyResort","sortSatisfiedByIndex","lowerBound","startKeys","lowerBoundString","getStartIndexStringFromLowerBound","upperBound","endKeys","upperBoundString","getStartIndexStringFromUpperBound","indexName","getMemoryIndexName","Error","docsWithIndex","indexOfLower","inclusiveStart","boundGE","boundGT","indexString","compareDocsWithIndex","indexOfUpper","inclusiveEnd","boundLE","boundLT","rows","done","currentRow","currentDoc","sortComparator","getSortComparator","sort","slice","count","result","mode","cleanup","minimumDeletedTime","maxDeletionTime","removeDocFromState","getAttachmentData","key","data","changeStream","asObservable","remove","removed","collectionStates","getMemoryCollectionKey","version","close","PROMISE_RESOLVE_VOID","refCount","conflictResultionTasks","conflictResultionTasks$","resolveConflictResultionTask","_taskSolution","createMemoryStorageInstance","params","collectionKey","randomCouchString","Map","Subject","addIndexesToInternalsState","devMode","deepEqual","instance"],"sources":["../../../../src/plugins/storage-memory/rx-storage-instance-memory.ts"],"sourcesContent":["import {\n Observable,\n Subject\n} from 'rxjs';\nimport {\n getStartIndexStringFromLowerBound,\n getStartIndexStringFromUpperBound\n} from '../../custom-index.ts';\nimport { getPrimaryFieldOfPrimaryKey } from '../../rx-schema-helper.ts';\nimport {\n categorizeBulkWriteRows\n} from '../../rx-storage-helper.ts';\nimport type {\n BulkWriteRow,\n CategorizeBulkWriteRowsOutput,\n EventBulk,\n PreparedQuery,\n QueryMatcher,\n RxConflictResultionTask,\n RxConflictResultionTaskSolution,\n RxDocumentData,\n RxJsonSchema,\n RxStorageBulkWriteResponse,\n RxStorageChangeEvent,\n RxStorageCountResult,\n RxStorageDefaultCheckpoint,\n RxStorageInstance,\n RxStorageInstanceCreationParams,\n RxStorageQueryResult,\n StringKeys\n} from '../../types/index.d.ts';\nimport {\n deepEqual,\n ensureNotFalsy,\n now,\n PROMISE_RESOLVE_TRUE,\n PROMISE_RESOLVE_VOID,\n randomCouchString,\n requestIdlePromiseNoQueue\n} from '../../plugins/utils/index.ts';\nimport {\n boundGE,\n boundGT,\n boundLE,\n boundLT\n} from './binary-search-bounds.ts';\nimport {\n attachmentMapKey,\n compareDocsWithIndex,\n ensureNotRemoved,\n getMemoryCollectionKey,\n putWriteRowToState,\n removeDocFromState\n} from './memory-helper.ts';\nimport {\n addIndexesToInternalsState,\n getMemoryIndexName\n} from './memory-indexes.ts';\nimport type {\n MemoryStorageInternals,\n RxStorageMemory,\n RxStorageMemoryInstanceCreationOptions,\n RxStorageMemorySettings\n} from './memory-types.ts';\nimport { getQueryMatcher, getSortComparator } from '../../rx-query-helper.ts';\n\n/**\n * Used in tests to ensure everything\n * is closed correctly\n */\nexport const OPEN_MEMORY_INSTANCES = new Set>();\n\nexport class RxStorageInstanceMemory implements RxStorageInstance<\n RxDocType,\n MemoryStorageInternals,\n RxStorageMemoryInstanceCreationOptions,\n RxStorageDefaultCheckpoint\n> {\n\n public readonly primaryPath: StringKeys>;\n public closed = false;\n\n /**\n * Used by some plugins and storage wrappers\n * to find out details about the internals of a write operation.\n * For example if you want to know which documents really have been replaced\n * or newly inserted.\n */\n public categorizedByWriteInput = new WeakMap[], CategorizeBulkWriteRowsOutput>();\n\n constructor(\n public readonly storage: RxStorageMemory,\n public readonly databaseName: string,\n public readonly collectionName: string,\n public readonly schema: Readonly>>,\n public readonly internals: MemoryStorageInternals,\n public readonly options: Readonly,\n public readonly settings: RxStorageMemorySettings\n ) {\n OPEN_MEMORY_INSTANCES.add(this);\n this.primaryPath = getPrimaryFieldOfPrimaryKey(this.schema.primaryKey);\n }\n\n bulkWrite(\n documentWrites: BulkWriteRow[],\n context: string\n ): Promise> {\n this.ensurePersistence();\n ensureNotRemoved(this);\n const internals = this.internals;\n const documentsById = this.internals.documents;\n const primaryPath = this.primaryPath;\n\n const categorized = categorizeBulkWriteRows(\n this,\n primaryPath as any,\n documentsById,\n documentWrites,\n context\n );\n const error = categorized.errors;\n const success: RxDocumentData[] = new Array(categorized.bulkInsertDocs.length);\n const bulkInsertDocs = categorized.bulkInsertDocs;\n for (let i = 0; i < bulkInsertDocs.length; ++i) {\n const writeRow = bulkInsertDocs[i];\n const doc = writeRow.document;\n success[i] = doc;\n }\n const bulkUpdateDocs = categorized.bulkUpdateDocs;\n for (let i = 0; i < bulkUpdateDocs.length; ++i) {\n const writeRow = bulkUpdateDocs[i];\n const doc = writeRow.document;\n success.push(doc);\n }\n\n this.categorizedByWriteInput.set(documentWrites, categorized);\n this.internals.ensurePersistenceTask = categorized;\n if (!this.internals.ensurePersistenceIdlePromise) {\n this.internals.ensurePersistenceIdlePromise = requestIdlePromiseNoQueue().then(() => {\n this.internals.ensurePersistenceIdlePromise = undefined;\n this.ensurePersistence();\n });\n }\n\n /**\n * Important: The events must be emitted AFTER the persistence\n * task has been added.\n */\n if (categorized.eventBulk.events.length > 0) {\n const lastState = ensureNotFalsy(categorized.newestRow).document;\n categorized.eventBulk.checkpoint = {\n id: lastState[primaryPath],\n lwt: lastState._meta.lwt\n };\n categorized.eventBulk.endTime = now();\n PROMISE_RESOLVE_TRUE.then(() => {\n internals.changes$.next(categorized.eventBulk);\n });\n }\n\n const ret = Promise.resolve({ success, error });\n return ret;\n }\n\n /**\n * Instead of directly inserting the documents into all indexes,\n * we do it lazy in the background. This gives the application time\n * to directly work with the write-result and to do stuff like rendering DOM\n * notes and processing RxDB queries.\n * Then in some later time, or just before the next read/write,\n * it is ensured that the indexes have been written.\n */\n public ensurePersistence() {\n if (\n !this.internals.ensurePersistenceTask\n ) {\n return;\n }\n const internals = this.internals;\n const documentsById = this.internals.documents;\n const primaryPath = this.primaryPath;\n\n const categorized = this.internals.ensurePersistenceTask;\n this.internals.ensurePersistenceTask = undefined;\n\n /**\n * Do inserts/updates\n */\n const stateByIndex = Object.values(this.internals.byIndex);\n\n const bulkInsertDocs = categorized.bulkInsertDocs;\n for (let i = 0; i < bulkInsertDocs.length; ++i) {\n const writeRow = bulkInsertDocs[i];\n const doc = writeRow.document;\n const docId = doc[primaryPath];\n putWriteRowToState(\n docId as any,\n internals,\n stateByIndex,\n writeRow,\n undefined\n );\n }\n\n const bulkUpdateDocs = categorized.bulkUpdateDocs;\n for (let i = 0; i < bulkUpdateDocs.length; ++i) {\n const writeRow = bulkUpdateDocs[i];\n const doc = writeRow.document;\n const docId = doc[primaryPath];\n putWriteRowToState(\n docId as any,\n internals,\n stateByIndex,\n writeRow,\n documentsById.get(docId as any)\n );\n }\n\n /**\n * Handle attachments\n */\n if (this.schema.attachments) {\n const attachmentsMap = internals.attachments;\n categorized.attachmentsAdd.forEach(attachment => {\n attachmentsMap.set(\n attachmentMapKey(attachment.documentId, attachment.attachmentId),\n {\n writeData: attachment.attachmentData,\n digest: attachment.digest\n }\n );\n });\n if (this.schema.attachments) {\n categorized.attachmentsUpdate.forEach(attachment => {\n attachmentsMap.set(\n attachmentMapKey(attachment.documentId, attachment.attachmentId),\n {\n writeData: attachment.attachmentData,\n digest: attachment.digest\n }\n );\n });\n categorized.attachmentsRemove.forEach(attachment => {\n attachmentsMap.delete(\n attachmentMapKey(attachment.documentId, attachment.attachmentId)\n );\n });\n }\n }\n }\n\n findDocumentsById(\n docIds: string[],\n withDeleted: boolean\n ): Promise[]> {\n this.ensurePersistence();\n const documentsById = this.internals.documents;\n const ret: RxDocumentData[] = [];\n if (documentsById.size === 0) {\n return Promise.resolve(ret);\n }\n for (let i = 0; i < docIds.length; ++i) {\n const docId = docIds[i];\n const docInDb = documentsById.get(docId);\n if (\n docInDb &&\n (\n !docInDb._deleted ||\n withDeleted\n )\n ) {\n ret.push(docInDb);\n }\n }\n return Promise.resolve(ret);\n }\n\n query(\n preparedQuery: PreparedQuery\n ): Promise> {\n this.ensurePersistence();\n\n const queryPlan = preparedQuery.queryPlan;\n const query = preparedQuery.query;\n\n const skip = query.skip ? query.skip : 0;\n const limit = query.limit ? query.limit : Infinity;\n const skipPlusLimit = skip + limit;\n\n let queryMatcher: QueryMatcher> | false = false;\n if (!queryPlan.selectorSatisfiedByIndex) {\n queryMatcher = getQueryMatcher(\n this.schema,\n preparedQuery.query\n );\n }\n\n const queryPlanFields: string[] = queryPlan.index;\n const mustManuallyResort = !queryPlan.sortSatisfiedByIndex;\n const index: string[] | undefined = queryPlanFields;\n const lowerBound: any[] = queryPlan.startKeys;\n const lowerBoundString = getStartIndexStringFromLowerBound(\n this.schema,\n index,\n lowerBound\n );\n\n let upperBound: any[] = queryPlan.endKeys;\n upperBound = upperBound;\n const upperBoundString = getStartIndexStringFromUpperBound(\n this.schema,\n index,\n upperBound\n );\n const indexName = getMemoryIndexName(index);\n\n if (!this.internals.byIndex[indexName]) {\n throw new Error('index does not exist ' + indexName);\n }\n const docsWithIndex = this.internals.byIndex[indexName].docsWithIndex;\n\n\n\n let indexOfLower = (queryPlan.inclusiveStart ? boundGE : boundGT)(\n docsWithIndex,\n {\n indexString: lowerBoundString\n } as any,\n compareDocsWithIndex\n );\n\n const indexOfUpper = (queryPlan.inclusiveEnd ? boundLE : boundLT)(\n docsWithIndex,\n {\n indexString: upperBoundString\n } as any,\n compareDocsWithIndex\n );\n\n let rows: RxDocumentData[] = [];\n let done = false;\n while (!done) {\n const currentRow = docsWithIndex[indexOfLower];\n if (\n !currentRow ||\n indexOfLower > indexOfUpper\n ) {\n break;\n }\n const currentDoc = currentRow.doc;\n\n if (!queryMatcher || queryMatcher(currentDoc)) {\n rows.push(currentDoc);\n }\n\n if (\n (rows.length >= skipPlusLimit && !mustManuallyResort)\n ) {\n done = true;\n }\n\n indexOfLower++;\n }\n\n if (mustManuallyResort) {\n const sortComparator = getSortComparator(this.schema, preparedQuery.query);\n rows = rows.sort(sortComparator);\n }\n\n // apply skip and limit boundaries.\n rows = rows.slice(skip, skipPlusLimit);\n return Promise.resolve({\n documents: rows\n });\n }\n\n async count(\n preparedQuery: PreparedQuery\n ): Promise {\n this.ensurePersistence();\n const result = await this.query(preparedQuery);\n return {\n count: result.documents.length,\n mode: 'fast'\n };\n }\n\n cleanup(minimumDeletedTime: number): Promise {\n this.ensurePersistence();\n const maxDeletionTime = now() - minimumDeletedTime;\n const index = ['_deleted', '_meta.lwt', this.primaryPath as any];\n const indexName = getMemoryIndexName(index);\n const docsWithIndex = this.internals.byIndex[indexName].docsWithIndex;\n\n const lowerBoundString = getStartIndexStringFromLowerBound(\n this.schema,\n index,\n [\n true,\n 0,\n ''\n ]\n );\n\n let indexOfLower = boundGT(\n docsWithIndex,\n {\n indexString: lowerBoundString\n } as any,\n compareDocsWithIndex\n );\n\n let done = false;\n while (!done) {\n const currentDoc = docsWithIndex[indexOfLower];\n if (!currentDoc || currentDoc.doc._meta.lwt > maxDeletionTime) {\n done = true;\n } else {\n removeDocFromState(\n this.primaryPath as any,\n this.schema,\n this.internals,\n currentDoc.doc\n );\n indexOfLower++;\n }\n }\n return PROMISE_RESOLVE_TRUE;\n }\n\n getAttachmentData(\n documentId: string,\n attachmentId: string,\n digest: string\n ): Promise {\n this.ensurePersistence();\n ensureNotRemoved(this);\n const key = attachmentMapKey(documentId, attachmentId);\n const data = this.internals.attachments.get(key);\n\n if (\n !digest ||\n !data ||\n data.digest !== digest\n ) {\n throw new Error('attachment does not exist: ' + key);\n }\n return Promise.resolve(data.writeData.data);\n }\n\n changeStream(): Observable>, RxStorageDefaultCheckpoint>> {\n ensureNotRemoved(this);\n return this.internals.changes$.asObservable();\n }\n\n async remove(): Promise {\n if (this.closed) {\n throw new Error('closed');\n }\n this.ensurePersistence();\n ensureNotRemoved(this);\n\n this.internals.removed = true;\n this.storage.collectionStates.delete(\n getMemoryCollectionKey(\n this.databaseName,\n this.collectionName,\n this.schema.version\n )\n );\n await this.close();\n }\n\n close(): Promise {\n OPEN_MEMORY_INSTANCES.delete(this);\n\n this.ensurePersistence();\n if (this.closed) {\n return PROMISE_RESOLVE_VOID;\n }\n this.closed = true;\n\n this.internals.refCount = this.internals.refCount - 1;\n return PROMISE_RESOLVE_VOID;\n }\n\n conflictResultionTasks(): Observable> {\n return this.internals.conflictResultionTasks$.asObservable();\n }\n resolveConflictResultionTask(_taskSolution: RxConflictResultionTaskSolution): Promise {\n return PROMISE_RESOLVE_VOID;\n }\n}\n\nexport function createMemoryStorageInstance(\n storage: RxStorageMemory,\n params: RxStorageInstanceCreationParams,\n settings: RxStorageMemorySettings\n): Promise> {\n const collectionKey = getMemoryCollectionKey(\n params.databaseName,\n params.collectionName,\n params.schema.version\n );\n\n let internals = storage.collectionStates.get(collectionKey);\n if (!internals) {\n internals = {\n id: randomCouchString(5),\n schema: params.schema,\n removed: false,\n refCount: 1,\n documents: new Map(),\n attachments: params.schema.attachments ? new Map() : undefined as any,\n byIndex: {},\n conflictResultionTasks$: new Subject(),\n changes$: new Subject()\n };\n addIndexesToInternalsState(internals, params.schema);\n storage.collectionStates.set(collectionKey, internals);\n } else {\n /**\n * Ensure that the storage was not already\n * created with a different schema.\n * This is very important because if this check\n * does not exist here, we have hard-to-debug problems\n * downstream.\n */\n if (\n params.devMode &&\n !deepEqual(internals.schema, params.schema)\n ) {\n throw new Error('storage was already created with a different schema');\n }\n internals.refCount = internals.refCount + 1;\n }\n\n const instance = new RxStorageInstanceMemory(\n storage,\n params.databaseName,\n params.collectionName,\n params.schema,\n internals,\n params.options,\n settings\n );\n return Promise.resolve(instance);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAIA,IAAAC,YAAA,GAAAD,OAAA;AAIA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAsBA,IAAAI,MAAA,GAAAJ,OAAA;AASA,IAAAK,mBAAA,GAAAL,OAAA;AAMA,IAAAM,aAAA,GAAAN,OAAA;AAQA,IAAAO,cAAA,GAAAP,OAAA;AAUA,IAAAQ,cAAA,GAAAR,OAAA;AAEA;AACA;AACA;AACA;AACO,IAAMS,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,IAAIE,GAAG,CAA+B,CAAC;AAAC,IAEhEC,uBAAuB,GAAAF,OAAA,CAAAE,uBAAA;EAUhC;AACJ;AACA;AACA;AACA;AACA;;EAGI,SAAAA,wBACoBC,OAAwB,EACxBC,YAAoB,EACpBC,cAAsB,EACtBC,MAAyD,EACzDC,SAA4C,EAC5CC,OAAyD,EACzDC,QAAiC,EACnD;IAAA,KAlBKC,MAAM,GAAG,KAAK;IAAA,KAQdC,uBAAuB,GAAG,IAAIC,OAAO,CAAsE,CAAC;IAAA,KAG/FT,OAAwB,GAAxBA,OAAwB;IAAA,KACxBC,YAAoB,GAApBA,YAAoB;IAAA,KACpBC,cAAsB,GAAtBA,cAAsB;IAAA,K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aAAa,EAAEzJ,SAAS,CAAC;EAC1D,CAAC,MAAM;IACH;AACR;AACA;AACA;AACA;AACA;AACA;IACQ,IACIwJ,MAAM,CAACM,OAAO,IACd,CAAC,IAAAC,gBAAS,EAAC/J,SAAS,CAACD,MAAM,EAAEyJ,MAAM,CAACzJ,MAAM,CAAC,EAC7C;MACE,MAAM,IAAI4G,KAAK,CAAC,qDAAqD,CAAC;IAC1E;IACA3G,SAAS,CAACkJ,QAAQ,GAAGlJ,SAAS,CAACkJ,QAAQ,GAAG,CAAC;EAC/C;EAEA,IAAMc,QAAQ,GAAG,IAAIrK,uBAAuB,CACxCC,OAAO,EACP4J,MAAM,CAAC3J,YAAY,EACnB2J,MAAM,CAAC1J,cAAc,EACrB0J,MAAM,CAACzJ,MAAM,EACbC,SAAS,EACTwJ,MAAM,CAACvJ,OAAO,EACdC,QACJ,CAAC;EACD,OAAOoD,OAAO,CAACC,OAAO,CAACyG,QAAQ,CAAC;AACpC","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 8001b758cd1..bc9b352ee4f 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.18.1'; +var RXDB_VERSION = exports.RXDB_VERSION = '15.18.2'; //# 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 0eed3e4153e..0a31585a4c6 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.18.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.18.2';\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/cjs/rx-storage-helper.js.map b/dist/cjs/rx-storage-helper.js.map index 9a081ac708f..eacd66cd4b4 100644 --- a/dist/cjs/rx-storage-helper.js.map +++ b/dist/cjs/rx-storage-helper.js.map @@ -1 +1 @@ -{"version":3,"file":"rx-storage-helper.js","names":["_overwritable","require","_rxError","_rxSchemaHelper","_index","_rxjs","_rxQuery","_rxQueryHelper","INTERNAL_STORAGE_NAME","exports","RX_DATABASE_LOCAL_DOCS_STORAGE_NAME","getSingleDocument","storageInstance","documentId","results","findDocumentsById","doc","undefined","writeSingle","instance","writeRow","context","writeResult","bulkWrite","error","length","ret","success","observeSingle","firstFindPromise","changeStream","pipe","map","evBulk","events","find","ev","filter","Promise","resolve","ensureNotFalsy","documentData","startWith","switchMap","v","stackCheckpoints","checkpoints","Object","assign","storageChangeEventToRxChangeEvent","isLocal","rxStorageChangeEvent","rxCollection","previousDocumentData","collectionName","name","operation","overwritable","deepFreezeWhenDevMode","throwIfIsStorageWriteError","collection","writeData","status","newRxError","id","writeError","data","categorizeBulkWriteRows","primaryPath","docsInDb","bulkWriteRows","onInsert","onUpdate","hasAttachments","schema","attachments","bulkInsertDocs","bulkUpdateDocs","errors","eventBulkId","randomCouchString","eventBulk","checkpoint","startTime","now","endTime","eventBulkEvents","attachmentsAdd","attachmentsRemove","attachmentsUpdate","hasDocsInDb","size","newestRow","rowAmount","_loop","rowId","document","previous","docId","documentDeleted","_deleted","previousDeleted","documentInDb","get","attachmentError","insertedIsDeleted","entries","_attachments","forEach","attachmentId","attachmentData","isError","push","digest","stripAttachmentsDataFromRow","event","stripAttachmentsDataFromDocument","revInDb","_rev","err","updatedRow","keys","previousAttachmentData","newDigest","eventDocumentData","previousEventDocumentData","args","getAttachmentSize","attachmentBase64String","atob","attachmentWriteDataToNormalData","type","useDoc","flatClone","flatCloneDocWithMeta","_meta","getWrappedStorageInstance","database","rxJsonSchema","getPrimaryFieldOfPrimaryKey","primaryKey","transformDocumentDataFromRxDBToRxStorage","isDevMode","fillPrimaryKey","structuredClone","JSON","parse","stringify","metaFieldName","prototype","hasOwnProperty","call","dataBefore","dataAfter","lwt","createRevision","token","originalStorageInstance","internals","databaseName","options","rows","toStorageWriteRows","row","lockedRun","then","useWriteResult","slice","reInsertErrors","reInserts","subResult","appendToArray","query","preparedQuery","count","ids","deleted","getAttachmentData","getChangedDocumentsSince","limit","cleanup","minDeletedTime","remove","storageInstances","delete","close","conflictResultionTasks","resolveConflictResultionTask","taskSolution","output","isEqual","getDefaultRxDocumentMeta","getDefaultRevision","add","ensureRxStorageInstanceParamsAreCorrect","params","keyCompression","hasEncryption","compression","jsonSchema","encrypted","getChangedDocumentsSinceQuery","sinceLwt","RX_META_LWT_MINIMUM","sinceId","normalizeMangoQuery","selector","$or","$gt","$eq","$gte","sort","skip","prepareQuery","result","documents","lastDoc","lastOfArray","randomDelayStorage","input","retStorage","storage","rxdbVersion","RXDB_VERSION","createStorageInstance","promiseWait","delayTimeBefore","delayTimeAfter","writeQueue","PROMISE_RESOLVE_TRUE","a","b","response","c"],"sources":["../../src/rx-storage-helper.ts"],"sourcesContent":["/**\n * Helper functions for accessing the RxStorage instances.\n */\n\nimport { overwritable } from './overwritable.ts';\nimport { newRxError } from './rx-error.ts';\nimport {\n fillPrimaryKey,\n getPrimaryFieldOfPrimaryKey\n} from './rx-schema-helper.ts';\nimport type {\n BulkWriteRow,\n BulkWriteRowProcessed,\n CategorizeBulkWriteRowsOutput,\n EventBulk,\n RxAttachmentData,\n RxAttachmentWriteData,\n RxChangeEvent,\n RxCollection,\n RxDatabase,\n RxDocumentData,\n RxDocumentWriteData,\n RxJsonSchema,\n RxStorageWriteError,\n RxStorageChangeEvent,\n RxStorageInstance,\n RxStorageInstanceCreationParams,\n StringKeys,\n RxStorageWriteErrorConflict,\n RxStorageWriteErrorAttachment,\n RxStorage,\n RxStorageDefaultCheckpoint,\n FilledMangoQuery\n} from './types/index.d.ts';\nimport {\n PROMISE_RESOLVE_TRUE,\n RXDB_VERSION,\n RX_META_LWT_MINIMUM,\n appendToArray,\n createRevision,\n ensureNotFalsy,\n flatClone,\n getDefaultRevision,\n getDefaultRxDocumentMeta,\n lastOfArray,\n now,\n promiseWait,\n randomCouchString\n} from './plugins/utils/index.ts';\nimport { Observable, filter, map, startWith, switchMap } from 'rxjs';\nimport { prepareQuery } from './rx-query.ts';\nimport { normalizeMangoQuery } from './rx-query-helper.ts';\n\nexport const INTERNAL_STORAGE_NAME = '_rxdb_internal';\nexport const RX_DATABASE_LOCAL_DOCS_STORAGE_NAME = 'rxdatabase_storage_local';\n\nexport async function getSingleDocument(\n storageInstance: RxStorageInstance,\n documentId: string\n): Promise | undefined> {\n const results = await storageInstance.findDocumentsById([documentId], false);\n const doc = results[0];\n if (doc) {\n return doc;\n } else {\n return undefined;\n }\n}\n\n/**\n * Writes a single document,\n * throws RxStorageBulkWriteError on failure\n */\nexport async function writeSingle(\n instance: RxStorageInstance,\n writeRow: BulkWriteRow,\n context: string\n): Promise> {\n const writeResult = await instance.bulkWrite(\n [writeRow],\n context\n );\n if (writeResult.error.length > 0) {\n const error = writeResult.error[0];\n throw error;\n } else {\n const ret = writeResult.success[0];\n return ret;\n }\n}\n\n/**\n * Observe the plain document data of a single document.\n * Do not forget to unsubscribe.\n */\nexport function observeSingle(\n storageInstance: RxStorageInstance,\n documentId: string\n): Observable> {\n const firstFindPromise = getSingleDocument(storageInstance, documentId);\n const ret = storageInstance\n .changeStream()\n .pipe(\n map(evBulk => evBulk.events.find(ev => ev.documentId === documentId)),\n filter(ev => !!ev),\n map(ev => Promise.resolve(ensureNotFalsy(ev).documentData)),\n startWith(firstFindPromise),\n switchMap(v => v),\n filter(v => !!v)\n ) as any;\n return ret;\n}\n\n\n/**\n * Checkpoints must be stackable over another.\n * This is required form some RxStorage implementations\n * like the sharding plugin, where a checkpoint only represents\n * the document state from some, but not all shards.\n */\nexport function stackCheckpoints(\n checkpoints: CheckpointType[]\n): CheckpointType {\n return Object.assign(\n {},\n ...checkpoints\n );\n}\n\nexport function storageChangeEventToRxChangeEvent(\n isLocal: boolean,\n rxStorageChangeEvent: RxStorageChangeEvent,\n rxCollection?: RxCollection,\n): RxChangeEvent {\n const documentData = rxStorageChangeEvent.documentData;\n const previousDocumentData = rxStorageChangeEvent.previousDocumentData;\n const ret: RxChangeEvent = {\n documentId: rxStorageChangeEvent.documentId,\n collectionName: rxCollection ? rxCollection.name : undefined,\n isLocal,\n operation: rxStorageChangeEvent.operation,\n documentData: overwritable.deepFreezeWhenDevMode(documentData as any),\n previousDocumentData: overwritable.deepFreezeWhenDevMode(previousDocumentData as any)\n };\n return ret;\n}\n\nexport function throwIfIsStorageWriteError(\n collection: RxCollection,\n documentId: string,\n writeData: RxDocumentWriteData | RxDocType,\n error: RxStorageWriteError | undefined\n) {\n if (error) {\n if (error.status === 409) {\n throw newRxError('CONFLICT', {\n collection: collection.name,\n id: documentId,\n writeError: error,\n data: writeData\n });\n } else if (error.status === 422) {\n throw newRxError('VD2', {\n collection: collection.name,\n id: documentId,\n writeError: error,\n data: writeData\n });\n } else {\n throw error;\n }\n }\n}\n\n\n/**\n * Analyzes a list of BulkWriteRows and determines\n * which documents must be inserted, updated or deleted\n * and which events must be emitted and which documents cause a conflict\n * and must not be written.\n * Used as helper inside of some RxStorage implementations.\n * @hotPath The performance of this function is critical\n */\nexport function categorizeBulkWriteRows(\n storageInstance: RxStorageInstance,\n primaryPath: StringKeys,\n /**\n * Current state of the documents\n * inside of the storage. Used to determine\n * which writes cause conflicts.\n * This must be a Map for better performance.\n */\n docsInDb: Map[StringKeys] | string, RxDocumentData>,\n /**\n * The write rows that are passed to\n * RxStorageInstance().bulkWrite().\n */\n bulkWriteRows: BulkWriteRow[],\n context: string,\n /**\n * Used by some storages for better performance.\n * For example when get-by-id and insert/update can run in parallel.\n */\n onInsert?: (docData: RxDocumentData) => void,\n onUpdate?: (docData: RxDocumentData) => void\n): CategorizeBulkWriteRowsOutput {\n const hasAttachments = !!storageInstance.schema.attachments;\n const bulkInsertDocs: BulkWriteRowProcessed[] = [];\n const bulkUpdateDocs: BulkWriteRowProcessed[] = [];\n const errors: RxStorageWriteError[] = [];\n const eventBulkId = randomCouchString(10);\n const eventBulk: EventBulk>, any> = {\n id: eventBulkId,\n events: [],\n checkpoint: null,\n context,\n startTime: now(),\n endTime: 0\n };\n const eventBulkEvents = eventBulk.events;\n\n const attachmentsAdd: {\n documentId: string;\n attachmentId: string;\n attachmentData: RxAttachmentWriteData;\n digest: string;\n }[] = [];\n const attachmentsRemove: {\n documentId: string;\n attachmentId: string;\n digest: string;\n }[] = [];\n const attachmentsUpdate: {\n documentId: string;\n attachmentId: string;\n attachmentData: RxAttachmentWriteData;\n digest: string;\n }[] = [];\n\n const hasDocsInDb = docsInDb.size > 0;\n let newestRow: BulkWriteRowProcessed | undefined;\n\n /**\n * @performance is really important in this loop!\n */\n const rowAmount = bulkWriteRows.length;\n for (let rowId = 0; rowId < rowAmount; rowId++) {\n const writeRow = bulkWriteRows[rowId];\n\n // use these variables to have less property accesses\n const document = writeRow.document;\n const previous = writeRow.previous;\n const docId = document[primaryPath] as string;\n const documentDeleted = document._deleted;\n const previousDeleted = previous && previous._deleted;\n\n let documentInDb: RxDocumentData | undefined = undefined as any;\n if (hasDocsInDb) {\n documentInDb = docsInDb.get(docId);\n }\n let attachmentError: RxStorageWriteErrorAttachment | undefined;\n\n if (!documentInDb) {\n /**\n * It is possible to insert already deleted documents,\n * this can happen on replication.\n */\n const insertedIsDeleted = documentDeleted ? true : false;\n if (hasAttachments) {\n Object\n .entries(document._attachments)\n .forEach(([attachmentId, attachmentData]) => {\n if (\n !(attachmentData as RxAttachmentWriteData).data\n ) {\n attachmentError = {\n documentId: docId,\n isError: true,\n status: 510,\n writeRow,\n attachmentId\n };\n errors.push(attachmentError);\n } else {\n attachmentsAdd.push({\n documentId: docId,\n attachmentId,\n attachmentData: attachmentData as any,\n digest: attachmentData.digest\n });\n }\n });\n }\n if (!attachmentError) {\n if (hasAttachments) {\n bulkInsertDocs.push(stripAttachmentsDataFromRow(writeRow));\n if (onInsert) {\n onInsert(document);\n }\n } else {\n bulkInsertDocs.push(writeRow as any);\n if (onInsert) {\n onInsert(document);\n }\n }\n\n newestRow = writeRow as any;\n }\n\n if (!insertedIsDeleted) {\n const event = {\n documentId: docId,\n operation: 'INSERT' as const,\n documentData: hasAttachments ? stripAttachmentsDataFromDocument(document) : document as any,\n previousDocumentData: hasAttachments && previous ? stripAttachmentsDataFromDocument(previous) : previous as any\n };\n eventBulkEvents.push(event);\n }\n } else {\n // update existing document\n const revInDb: string = documentInDb._rev;\n\n /**\n * Check for conflict\n */\n if (\n (\n !previous\n ) ||\n (\n !!previous &&\n revInDb !== previous._rev\n )\n ) {\n // is conflict error\n const err: RxStorageWriteError = {\n isError: true,\n status: 409,\n documentId: docId,\n writeRow: writeRow,\n documentInDb\n };\n errors.push(err);\n continue;\n }\n\n // handle attachments data\n\n const updatedRow: BulkWriteRowProcessed = hasAttachments ? stripAttachmentsDataFromRow(writeRow) : writeRow as any;\n if (hasAttachments) {\n if (documentDeleted) {\n /**\n * Deleted documents must have cleared all their attachments.\n */\n if (previous) {\n Object\n .keys(previous._attachments)\n .forEach(attachmentId => {\n attachmentsRemove.push({\n documentId: docId,\n attachmentId,\n digest: ensureNotFalsy(previous)._attachments[attachmentId].digest\n });\n });\n }\n } else {\n // first check for errors\n Object\n .entries(document._attachments)\n .find(([attachmentId, attachmentData]) => {\n const previousAttachmentData = previous ? previous._attachments[attachmentId] : undefined;\n if (\n !previousAttachmentData &&\n !(attachmentData as RxAttachmentWriteData).data\n ) {\n attachmentError = {\n documentId: docId,\n documentInDb: documentInDb as any,\n isError: true,\n status: 510,\n writeRow,\n attachmentId\n };\n }\n return true;\n });\n if (!attachmentError) {\n Object\n .entries(document._attachments)\n .forEach(([attachmentId, attachmentData]) => {\n const previousAttachmentData = previous ? previous._attachments[attachmentId] : undefined;\n if (!previousAttachmentData) {\n attachmentsAdd.push({\n documentId: docId,\n attachmentId,\n attachmentData: attachmentData as any,\n digest: attachmentData.digest\n });\n } else {\n const newDigest = updatedRow.document._attachments[attachmentId].digest;\n if (\n (attachmentData as RxAttachmentWriteData).data &&\n /**\n * Performance shortcut,\n * do not update the attachment data if it did not change.\n */\n previousAttachmentData.digest !== newDigest\n ) {\n attachmentsUpdate.push({\n documentId: docId,\n attachmentId,\n attachmentData: attachmentData as RxAttachmentWriteData,\n digest: attachmentData.digest\n });\n }\n }\n });\n }\n }\n }\n\n if (attachmentError) {\n errors.push(attachmentError);\n } else {\n if (hasAttachments) {\n bulkUpdateDocs.push(stripAttachmentsDataFromRow(updatedRow));\n if (onUpdate) {\n onUpdate(document);\n }\n } else {\n bulkUpdateDocs.push(updatedRow);\n if (onUpdate) {\n onUpdate(document);\n }\n }\n newestRow = updatedRow as any;\n }\n\n let eventDocumentData: RxDocumentData | undefined = null as any;\n let previousEventDocumentData: RxDocumentData | undefined = null as any;\n let operation: 'INSERT' | 'UPDATE' | 'DELETE' = null as any;\n\n if (previousDeleted && !documentDeleted) {\n operation = 'INSERT';\n eventDocumentData = hasAttachments ? stripAttachmentsDataFromDocument(document) : document as any;\n } else if (previous && !previousDeleted && !documentDeleted) {\n operation = 'UPDATE';\n eventDocumentData = hasAttachments ? stripAttachmentsDataFromDocument(document) : document as any;\n previousEventDocumentData = previous;\n } else if (documentDeleted) {\n operation = 'DELETE';\n eventDocumentData = ensureNotFalsy(document) as any;\n previousEventDocumentData = previous;\n } else {\n throw newRxError('SNH', { args: { writeRow } });\n }\n\n const event = {\n documentId: docId,\n documentData: eventDocumentData as RxDocumentData,\n previousDocumentData: previousEventDocumentData,\n operation: operation\n };\n eventBulkEvents.push(event);\n }\n }\n\n return {\n bulkInsertDocs,\n bulkUpdateDocs,\n newestRow,\n errors,\n eventBulk,\n attachmentsAdd,\n attachmentsRemove,\n attachmentsUpdate\n };\n}\n\nexport function stripAttachmentsDataFromRow(writeRow: BulkWriteRow): BulkWriteRowProcessed {\n return {\n previous: writeRow.previous,\n document: stripAttachmentsDataFromDocument(writeRow.document)\n };\n}\n\nexport function getAttachmentSize(\n attachmentBase64String: string\n): number {\n return atob(attachmentBase64String).length;\n}\n\n/**\n * Used in custom RxStorage implementations.\n */\nexport function attachmentWriteDataToNormalData(writeData: RxAttachmentData | RxAttachmentWriteData): RxAttachmentData {\n const data = (writeData as RxAttachmentWriteData).data;\n if (!data) {\n return writeData as any;\n }\n const ret: RxAttachmentData = {\n length: getAttachmentSize(data),\n digest: writeData.digest,\n type: writeData.type\n };\n return ret;\n}\n\nexport function stripAttachmentsDataFromDocument(doc: RxDocumentWriteData): RxDocumentData {\n if (!doc._attachments || Object.keys(doc._attachments).length === 0) {\n return doc;\n }\n\n const useDoc: RxDocumentData = flatClone(doc) as any;\n useDoc._attachments = {};\n Object\n .entries(doc._attachments)\n .forEach(([attachmentId, attachmentData]) => {\n useDoc._attachments[attachmentId] = attachmentWriteDataToNormalData(attachmentData);\n });\n return useDoc;\n}\n\n/**\n * Flat clone the document data\n * and also the _meta field.\n * Used many times when we want to change the meta\n * during replication etc.\n */\nexport function flatCloneDocWithMeta(\n doc: RxDocumentData\n): RxDocumentData {\n const ret = flatClone(doc);\n ret._meta = flatClone(doc._meta);\n return ret;\n}\n\nexport type WrappedRxStorageInstance = RxStorageInstance & {\n originalStorageInstance: RxStorageInstance;\n};\n\n/**\n * Wraps the normal storageInstance of a RxCollection\n * to ensure that all access is properly using the hooks\n * and other data transformations and also ensure that database.lockedRun()\n * is used properly.\n */\nexport function getWrappedStorageInstance<\n RxDocType,\n Internals,\n InstanceCreationOptions,\n CheckpointType\n>(\n database: RxDatabase<{}, Internals, InstanceCreationOptions, any>,\n storageInstance: RxStorageInstance,\n /**\n * The original RxJsonSchema\n * before it was mutated by hooks.\n */\n rxJsonSchema: RxJsonSchema>\n): WrappedRxStorageInstance {\n overwritable.deepFreezeWhenDevMode(rxJsonSchema);\n const primaryPath = getPrimaryFieldOfPrimaryKey(rxJsonSchema.primaryKey);\n\n function transformDocumentDataFromRxDBToRxStorage(\n writeRow: BulkWriteRow\n ) {\n let data = flatClone(writeRow.document);\n data._meta = flatClone(data._meta);\n\n /**\n * Do some checks in dev-mode\n * that would be too performance expensive\n * in production.\n */\n if (overwritable.isDevMode()) {\n // ensure that the primary key has not been changed\n data = fillPrimaryKey(\n primaryPath,\n rxJsonSchema,\n data as any\n );\n\n\n /**\n * Ensure it can be structured cloned\n */\n try {\n /**\n * Notice that structuredClone() is not available\n * in ReactNative, so we test for JSON.stringify() instead\n * @link https://github.com/pubkey/rxdb/issues/5046#issuecomment-1827374498\n */\n if (typeof structuredClone === 'function') {\n structuredClone(writeRow);\n } else {\n JSON.parse(JSON.stringify(writeRow));\n }\n } catch (err) {\n throw newRxError('DOC24', {\n collection: storageInstance.collectionName,\n document: writeRow.document\n });\n }\n\n /**\n * Ensure that the new revision is higher\n * then the previous one\n */\n if (writeRow.previous) {\n // TODO run this in the dev-mode plugin\n // const prev = parseRevision(writeRow.previous._rev);\n // const current = parseRevision(writeRow.document._rev);\n // if (current.height <= prev.height) {\n // throw newRxError('SNH', {\n // dataBefore: writeRow.previous,\n // dataAfter: writeRow.document,\n // args: {\n // prev,\n // current\n // }\n // });\n // }\n }\n\n /**\n * Ensure that _meta fields have been merged\n * and not replaced.\n * This is important so that when one plugin A\n * sets a _meta field and another plugin B does a write\n * to the document, it must be ensured that the\n * field of plugin A was not removed.\n */\n if (writeRow.previous) {\n Object.keys(writeRow.previous._meta)\n .forEach(metaFieldName => {\n if (!Object.prototype.hasOwnProperty.call(writeRow.document._meta, metaFieldName)) {\n throw newRxError('SNH', {\n dataBefore: writeRow.previous,\n dataAfter: writeRow.document\n });\n }\n });\n }\n }\n data._meta.lwt = now();\n\n /**\n * Yes we really want to set the revision here.\n * If you make a plugin that relies on having its own revision\n * stored into the storage, use this.originalStorageInstance.bulkWrite() instead.\n */\n data._rev = createRevision(\n database.token,\n writeRow.previous\n );\n\n return {\n document: data,\n previous: writeRow.previous\n };\n }\n\n const ret: WrappedRxStorageInstance = {\n originalStorageInstance: storageInstance,\n schema: storageInstance.schema,\n internals: storageInstance.internals,\n collectionName: storageInstance.collectionName,\n databaseName: storageInstance.databaseName,\n options: storageInstance.options,\n bulkWrite(\n rows: BulkWriteRow[],\n context: string\n ) {\n const toStorageWriteRows: BulkWriteRow[] = rows\n .map(row => transformDocumentDataFromRxDBToRxStorage(row));\n\n return database.lockedRun(\n () => storageInstance.bulkWrite(\n toStorageWriteRows,\n context\n )\n )\n /**\n * The RxStorageInstance MUST NOT allow to insert already _deleted documents,\n * without sending the previous document version.\n * But for better developer experience, RxDB does allow to re-insert deleted documents.\n * We do this by automatically fixing the conflict errors for that case\n * by running another bulkWrite() and merging the results.\n * @link https://github.com/pubkey/rxdb/pull/3839\n */\n .then(writeResult => {\n const useWriteResult: typeof writeResult = {\n error: [],\n success: writeResult.success.slice(0)\n };\n const reInsertErrors: RxStorageWriteErrorConflict[] =\n writeResult.error\n .filter((error) => {\n if (\n error.status === 409 &&\n !error.writeRow.previous &&\n !error.writeRow.document._deleted &&\n ensureNotFalsy(error.documentInDb)._deleted\n ) {\n return true;\n }\n useWriteResult.error.push(error);\n return false;\n }) as any;\n if (reInsertErrors.length > 0) {\n const reInserts: BulkWriteRow[] = reInsertErrors\n .map((error) => {\n return {\n previous: error.documentInDb,\n document: Object.assign(\n {},\n error.writeRow.document,\n {\n _rev: createRevision(\n database.token,\n error.documentInDb\n )\n }\n )\n };\n });\n\n return database.lockedRun(\n () => storageInstance.bulkWrite(\n reInserts,\n context\n )\n ).then(subResult => {\n appendToArray(useWriteResult.error, subResult.error);\n appendToArray(useWriteResult.success, subResult.success);\n return useWriteResult;\n });\n }\n\n return writeResult;\n });\n },\n query(preparedQuery) {\n return database.lockedRun(\n () => storageInstance.query(preparedQuery)\n );\n },\n count(preparedQuery) {\n return database.lockedRun(\n () => storageInstance.count(preparedQuery)\n );\n },\n findDocumentsById(ids, deleted) {\n return database.lockedRun(\n () => storageInstance.findDocumentsById(ids, deleted)\n );\n },\n getAttachmentData(\n documentId: string,\n attachmentId: string,\n digest: string\n ) {\n return database.lockedRun(\n () => storageInstance.getAttachmentData(documentId, attachmentId, digest)\n );\n },\n getChangedDocumentsSince: !storageInstance.getChangedDocumentsSince ? undefined : (limit: number, checkpoint?: any) => {\n return database.lockedRun(\n () => ((storageInstance as any).getChangedDocumentsSince)(ensureNotFalsy(limit), checkpoint)\n );\n },\n cleanup(minDeletedTime: number) {\n return database.lockedRun(\n () => storageInstance.cleanup(minDeletedTime)\n );\n },\n remove() {\n database.storageInstances.delete(ret);\n return database.lockedRun(\n () => storageInstance.remove()\n );\n },\n close() {\n database.storageInstances.delete(ret);\n return database.lockedRun(\n () => storageInstance.close()\n );\n },\n changeStream() {\n return storageInstance.changeStream();\n },\n conflictResultionTasks() {\n return storageInstance.conflictResultionTasks();\n },\n resolveConflictResultionTask(taskSolution) {\n if (taskSolution.output.isEqual) {\n return storageInstance.resolveConflictResultionTask(taskSolution);\n }\n\n const doc = Object.assign(\n {},\n taskSolution.output.documentData,\n {\n _meta: getDefaultRxDocumentMeta(),\n _rev: getDefaultRevision(),\n _attachments: {}\n }\n );\n\n const documentData = flatClone(doc);\n delete (documentData as any)._meta;\n delete (documentData as any)._rev;\n delete (documentData as any)._attachments;\n\n return storageInstance.resolveConflictResultionTask({\n id: taskSolution.id,\n output: {\n isEqual: false,\n documentData\n }\n });\n }\n };\n\n database.storageInstances.add(ret);\n return ret;\n}\n\n/**\n * Each RxStorage implementation should\n * run this method at the first step of createStorageInstance()\n * to ensure that the configuration is correct.\n */\nexport function ensureRxStorageInstanceParamsAreCorrect(\n params: RxStorageInstanceCreationParams\n) {\n if (params.schema.keyCompression) {\n throw newRxError('UT5', { args: { params } });\n }\n if (hasEncryption(params.schema)) {\n throw newRxError('UT6', { args: { params } });\n }\n if (\n params.schema.attachments &&\n params.schema.attachments.compression\n ) {\n throw newRxError('UT7', { args: { params } });\n }\n}\n\nexport function hasEncryption(jsonSchema: RxJsonSchema): boolean {\n if (\n (!!jsonSchema.encrypted && jsonSchema.encrypted.length > 0) ||\n (jsonSchema.attachments && jsonSchema.attachments.encrypted)\n ) {\n return true;\n } else {\n return false;\n }\n}\n\nexport function getChangedDocumentsSinceQuery(\n storageInstance: RxStorageInstance,\n limit: number,\n checkpoint?: CheckpointType\n): FilledMangoQuery {\n const primaryPath = getPrimaryFieldOfPrimaryKey(storageInstance.schema.primaryKey);\n const sinceLwt = checkpoint ? (checkpoint as unknown as RxStorageDefaultCheckpoint).lwt : RX_META_LWT_MINIMUM;\n const sinceId = checkpoint ? (checkpoint as unknown as RxStorageDefaultCheckpoint).id : '';\n return normalizeMangoQuery(storageInstance.schema, {\n selector: {\n $or: [\n {\n '_meta.lwt': {\n $gt: sinceLwt\n }\n },\n {\n '_meta.lwt': {\n $eq: sinceLwt\n },\n [primaryPath]: {\n $gt: checkpoint ? sinceId : ''\n }\n }\n ],\n // add this hint for better index usage\n '_meta.lwt': {\n $gte: sinceLwt\n }\n } as any,\n sort: [\n { '_meta.lwt': 'asc' },\n { [primaryPath]: 'asc' }\n ] as any,\n skip: 0,\n limit,\n /**\n * DO NOT SET A SPECIFIC INDEX HERE!\n * The query might be modified by some plugin\n * before sending it to the storage.\n * We can be sure that in the end the query planner\n * will find the best index.\n */\n // index: ['_meta.lwt', primaryPath]\n });\n}\n\nexport async function getChangedDocumentsSince(\n storageInstance: RxStorageInstance,\n limit: number,\n checkpoint?: CheckpointType\n): Promise<{\n documents: RxDocumentData[];\n /**\n * The checkpoint contains data so that another\n * call to getChangedDocumentsSince() will continue\n * from exactly the last document that was returned before.\n */\n checkpoint: CheckpointType;\n}> {\n if (storageInstance.getChangedDocumentsSince) {\n return storageInstance.getChangedDocumentsSince(limit, checkpoint);\n }\n\n const primaryPath = getPrimaryFieldOfPrimaryKey(storageInstance.schema.primaryKey);\n const query = prepareQuery>(\n storageInstance.schema,\n getChangedDocumentsSinceQuery(\n storageInstance,\n limit,\n checkpoint\n )\n );\n\n const result = await storageInstance.query(query);\n const documents = result.documents;\n const lastDoc = lastOfArray(documents);\n\n return {\n documents: documents,\n checkpoint: lastDoc ? {\n id: (lastDoc as any)[primaryPath],\n lwt: lastDoc._meta.lwt\n } as any : checkpoint ? checkpoint : {\n id: '',\n lwt: 0\n }\n };\n}\n\n\n/**\n * Wraps the storage and simluates\n * delays. Mostly used in tests.\n */\nexport function randomDelayStorage(\n input: {\n storage: RxStorage;\n delayTimeBefore: () => number;\n delayTimeAfter: () => number;\n }\n): RxStorage {\n\n const retStorage: RxStorage = {\n name: 'random-delay-' + input.storage.name,\n rxdbVersion: RXDB_VERSION,\n async createStorageInstance(params) {\n await promiseWait(input.delayTimeBefore());\n const storageInstance = await input.storage.createStorageInstance(params);\n await promiseWait(input.delayTimeAfter());\n\n // write still must be processed in order\n let writeQueue: Promise = PROMISE_RESOLVE_TRUE;\n\n return {\n databaseName: storageInstance.databaseName,\n internals: storageInstance.internals,\n options: storageInstance.options,\n schema: storageInstance.schema,\n collectionName: storageInstance.collectionName,\n async bulkWrite(a, b) {\n writeQueue = writeQueue.then(async () => {\n await promiseWait(input.delayTimeBefore());\n const response = await storageInstance.bulkWrite(a, b);\n await promiseWait(input.delayTimeAfter());\n return response;\n });\n const ret = await writeQueue;\n return ret;\n },\n async findDocumentsById(a, b) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.findDocumentsById(a, b);\n await promiseWait(input.delayTimeAfter());\n return ret;\n },\n async query(a) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.query(a);\n return ret;\n },\n async count(a) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.count(a);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n async getAttachmentData(a, b, c) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.getAttachmentData(a, b, c);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n getChangedDocumentsSince: !storageInstance.getChangedDocumentsSince ? undefined : async (a, b) => {\n await promiseWait(input.delayTimeBefore());\n const ret = await ensureNotFalsy(storageInstance.getChangedDocumentsSince)(a, b);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n changeStream() {\n return storageInstance.changeStream();\n },\n conflictResultionTasks() {\n return storageInstance.conflictResultionTasks();\n },\n resolveConflictResultionTask(a) {\n return storageInstance.resolveConflictResultionTask(a);\n },\n async cleanup(a) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.cleanup(a);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n async close() {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.close();\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n async remove() {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.remove();\n await promiseWait(input.delayTimeAfter());\n return ret;\n },\n };\n\n\n }\n };\n return retStorage;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AA4BA,IAAAG,MAAA,GAAAH,OAAA;AAeA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAA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,CAACwK,OAAO,CAACkD,CAAC,CAAC;UAC5C,MAAM,IAAAL,kBAAW,EAACN,KAAK,CAACQ,cAAc,CAAC,CAAC,CAAC;UACzC,OAAOzM,GAAG;QAEd,CAAC;QACD,MAAM+J,KAAKA,CAAA,EAAG;UACV,MAAM,IAAAwC,kBAAW,EAACN,KAAK,CAACO,eAAe,CAAC,CAAC,CAAC;UAC1C,IAAMxM,GAAG,GAAG,MAAMd,eAAe,CAAC6K,KAAK,CAAC,CAAC;UACzC,MAAM,IAAAwC,kBAAW,EAACN,KAAK,CAACQ,cAAc,CAAC,CAAC,CAAC;UACzC,OAAOzM,GAAG;QAEd,CAAC;QACD,MAAM4J,MAAMA,CAAA,EAAG;UACX,MAAM,IAAA2C,kBAAW,EAACN,KAAK,CAACO,eAAe,CAAC,CAAC,CAAC;UAC1C,IAAMxM,GAAG,GAAG,MAAMd,eAAe,CAAC0K,MAAM,CAAC,CAAC;UAC1C,MAAM,IAAA2C,kBAAW,EAACN,KAAK,CAACQ,cAAc,CAAC,CAAC,CAAC;UACzC,OAAOzM,GAAG;QACd;MACJ,CAAC;IAGL;EACJ,CAAC;EACD,OAAOkM,UAAU;AACrB","ignoreList":[]} \ No newline at end of file +{"version":3,"file":"rx-storage-helper.js","names":["_overwritable","require","_rxError","_rxSchemaHelper","_index","_rxjs","_rxQuery","_rxQueryHelper","INTERNAL_STORAGE_NAME","exports","RX_DATABASE_LOCAL_DOCS_STORAGE_NAME","getSingleDocument","storageInstance","documentId","results","findDocumentsById","doc","undefined","writeSingle","instance","writeRow","context","writeResult","bulkWrite","error","length","ret","success","observeSingle","firstFindPromise","changeStream","pipe","map","evBulk","events","find","ev","filter","Promise","resolve","ensureNotFalsy","documentData","startWith","switchMap","v","stackCheckpoints","checkpoints","Object","assign","storageChangeEventToRxChangeEvent","isLocal","rxStorageChangeEvent","rxCollection","previousDocumentData","collectionName","name","operation","overwritable","deepFreezeWhenDevMode","throwIfIsStorageWriteError","collection","writeData","status","newRxError","id","writeError","data","categorizeBulkWriteRows","primaryPath","docsInDb","bulkWriteRows","onInsert","onUpdate","hasAttachments","schema","attachments","bulkInsertDocs","bulkUpdateDocs","errors","eventBulkId","randomCouchString","eventBulk","checkpoint","startTime","now","endTime","eventBulkEvents","attachmentsAdd","attachmentsRemove","attachmentsUpdate","hasDocsInDb","size","newestRow","rowAmount","_loop","rowId","document","previous","docId","documentDeleted","_deleted","previousDeleted","documentInDb","get","attachmentError","insertedIsDeleted","entries","_attachments","forEach","attachmentId","attachmentData","isError","push","digest","stripAttachmentsDataFromRow","event","stripAttachmentsDataFromDocument","revInDb","_rev","err","updatedRow","keys","previousAttachmentData","newDigest","eventDocumentData","previousEventDocumentData","args","getAttachmentSize","attachmentBase64String","atob","attachmentWriteDataToNormalData","type","useDoc","flatClone","flatCloneDocWithMeta","_meta","getWrappedStorageInstance","database","rxJsonSchema","getPrimaryFieldOfPrimaryKey","primaryKey","transformDocumentDataFromRxDBToRxStorage","isDevMode","fillPrimaryKey","structuredClone","JSON","parse","stringify","metaFieldName","prototype","hasOwnProperty","call","dataBefore","dataAfter","lwt","createRevision","token","originalStorageInstance","internals","databaseName","options","rows","toStorageWriteRows","row","lockedRun","then","useWriteResult","slice","reInsertErrors","reInserts","subResult","appendToArray","query","preparedQuery","count","ids","deleted","getAttachmentData","getChangedDocumentsSince","limit","cleanup","minDeletedTime","remove","storageInstances","delete","close","conflictResultionTasks","resolveConflictResultionTask","taskSolution","output","isEqual","getDefaultRxDocumentMeta","getDefaultRevision","add","ensureRxStorageInstanceParamsAreCorrect","params","keyCompression","hasEncryption","compression","jsonSchema","encrypted","getChangedDocumentsSinceQuery","sinceLwt","RX_META_LWT_MINIMUM","sinceId","normalizeMangoQuery","selector","$or","$gt","$eq","$gte","sort","skip","prepareQuery","result","documents","lastDoc","lastOfArray","randomDelayStorage","input","retStorage","storage","rxdbVersion","RXDB_VERSION","createStorageInstance","promiseWait","delayTimeBefore","delayTimeAfter","writeQueue","PROMISE_RESOLVE_TRUE","a","b","response","c"],"sources":["../../src/rx-storage-helper.ts"],"sourcesContent":["/**\n * Helper functions for accessing the RxStorage instances.\n */\n\nimport { overwritable } from './overwritable.ts';\nimport { newRxError } from './rx-error.ts';\nimport {\n fillPrimaryKey,\n getPrimaryFieldOfPrimaryKey\n} from './rx-schema-helper.ts';\nimport type {\n BulkWriteRow,\n BulkWriteRowProcessed,\n CategorizeBulkWriteRowsOutput,\n EventBulk,\n RxAttachmentData,\n RxAttachmentWriteData,\n RxChangeEvent,\n RxCollection,\n RxDatabase,\n RxDocumentData,\n RxDocumentWriteData,\n RxJsonSchema,\n RxStorageWriteError,\n RxStorageChangeEvent,\n RxStorageInstance,\n RxStorageInstanceCreationParams,\n StringKeys,\n RxStorageWriteErrorConflict,\n RxStorageWriteErrorAttachment,\n RxStorage,\n RxStorageDefaultCheckpoint,\n FilledMangoQuery\n} from './types/index.d.ts';\nimport {\n PROMISE_RESOLVE_TRUE,\n RXDB_VERSION,\n RX_META_LWT_MINIMUM,\n appendToArray,\n createRevision,\n ensureNotFalsy,\n flatClone,\n getDefaultRevision,\n getDefaultRxDocumentMeta,\n lastOfArray,\n now,\n promiseWait,\n randomCouchString\n} from './plugins/utils/index.ts';\nimport { Observable, filter, map, startWith, switchMap } from 'rxjs';\nimport { prepareQuery } from './rx-query.ts';\nimport { normalizeMangoQuery } from './rx-query-helper.ts';\n\nexport const INTERNAL_STORAGE_NAME = '_rxdb_internal';\nexport const RX_DATABASE_LOCAL_DOCS_STORAGE_NAME = 'rxdatabase_storage_local';\n\nexport async function getSingleDocument(\n storageInstance: RxStorageInstance,\n documentId: string\n): Promise | undefined> {\n const results = await storageInstance.findDocumentsById([documentId], false);\n const doc = results[0];\n if (doc) {\n return doc;\n } else {\n return undefined;\n }\n}\n\n/**\n * Writes a single document,\n * throws RxStorageBulkWriteError on failure\n */\nexport async function writeSingle(\n instance: RxStorageInstance,\n writeRow: BulkWriteRow,\n context: string\n): Promise> {\n const writeResult = await instance.bulkWrite(\n [writeRow],\n context\n );\n if (writeResult.error.length > 0) {\n const error = writeResult.error[0];\n throw error;\n } else {\n const ret = writeResult.success[0];\n return ret;\n }\n}\n\n/**\n * Observe the plain document data of a single document.\n * Do not forget to unsubscribe.\n */\nexport function observeSingle(\n storageInstance: RxStorageInstance,\n documentId: string\n): Observable> {\n const firstFindPromise = getSingleDocument(storageInstance, documentId);\n const ret = storageInstance\n .changeStream()\n .pipe(\n map(evBulk => evBulk.events.find(ev => ev.documentId === documentId)),\n filter(ev => !!ev),\n map(ev => Promise.resolve(ensureNotFalsy(ev).documentData)),\n startWith(firstFindPromise),\n switchMap(v => v),\n filter(v => !!v)\n ) as any;\n return ret;\n}\n\n/**\n * Checkpoints must be stackable over another.\n * This is required form some RxStorage implementations\n * like the sharding plugin, where a checkpoint only represents\n * the document state from some, but not all shards.\n */\nexport function stackCheckpoints(\n checkpoints: CheckpointType[]\n): CheckpointType {\n return Object.assign(\n {},\n ...checkpoints\n );\n}\n\nexport function storageChangeEventToRxChangeEvent(\n isLocal: boolean,\n rxStorageChangeEvent: RxStorageChangeEvent,\n rxCollection?: RxCollection,\n): RxChangeEvent {\n const documentData = rxStorageChangeEvent.documentData;\n const previousDocumentData = rxStorageChangeEvent.previousDocumentData;\n const ret: RxChangeEvent = {\n documentId: rxStorageChangeEvent.documentId,\n collectionName: rxCollection ? rxCollection.name : undefined,\n isLocal,\n operation: rxStorageChangeEvent.operation,\n documentData: overwritable.deepFreezeWhenDevMode(documentData as any),\n previousDocumentData: overwritable.deepFreezeWhenDevMode(previousDocumentData as any)\n };\n return ret;\n}\n\nexport function throwIfIsStorageWriteError(\n collection: RxCollection,\n documentId: string,\n writeData: RxDocumentWriteData | RxDocType,\n error: RxStorageWriteError | undefined\n) {\n if (error) {\n if (error.status === 409) {\n throw newRxError('CONFLICT', {\n collection: collection.name,\n id: documentId,\n writeError: error,\n data: writeData\n });\n } else if (error.status === 422) {\n throw newRxError('VD2', {\n collection: collection.name,\n id: documentId,\n writeError: error,\n data: writeData\n });\n } else {\n throw error;\n }\n }\n}\n\n\n/**\n * Analyzes a list of BulkWriteRows and determines\n * which documents must be inserted, updated or deleted\n * and which events must be emitted and which documents cause a conflict\n * and must not be written.\n * Used as helper inside of some RxStorage implementations.\n * @hotPath The performance of this function is critical\n */\nexport function categorizeBulkWriteRows(\n storageInstance: RxStorageInstance,\n primaryPath: StringKeys,\n /**\n * Current state of the documents\n * inside of the storage. Used to determine\n * which writes cause conflicts.\n * This must be a Map for better performance.\n */\n docsInDb: Map[StringKeys] | string, RxDocumentData>,\n /**\n * The write rows that are passed to\n * RxStorageInstance().bulkWrite().\n */\n bulkWriteRows: BulkWriteRow[],\n context: string,\n /**\n * Used by some storages for better performance.\n * For example when get-by-id and insert/update can run in parallel.\n */\n onInsert?: (docData: RxDocumentData) => void,\n onUpdate?: (docData: RxDocumentData) => void\n): CategorizeBulkWriteRowsOutput {\n const hasAttachments = !!storageInstance.schema.attachments;\n const bulkInsertDocs: BulkWriteRowProcessed[] = [];\n const bulkUpdateDocs: BulkWriteRowProcessed[] = [];\n const errors: RxStorageWriteError[] = [];\n const eventBulkId = randomCouchString(10);\n const eventBulk: EventBulk>, any> = {\n id: eventBulkId,\n events: [],\n checkpoint: null,\n context,\n startTime: now(),\n endTime: 0\n };\n const eventBulkEvents = eventBulk.events;\n\n const attachmentsAdd: {\n documentId: string;\n attachmentId: string;\n attachmentData: RxAttachmentWriteData;\n digest: string;\n }[] = [];\n const attachmentsRemove: {\n documentId: string;\n attachmentId: string;\n digest: string;\n }[] = [];\n const attachmentsUpdate: {\n documentId: string;\n attachmentId: string;\n attachmentData: RxAttachmentWriteData;\n digest: string;\n }[] = [];\n\n const hasDocsInDb = docsInDb.size > 0;\n let newestRow: BulkWriteRowProcessed | undefined;\n\n /**\n * @performance is really important in this loop!\n */\n const rowAmount = bulkWriteRows.length;\n for (let rowId = 0; rowId < rowAmount; rowId++) {\n const writeRow = bulkWriteRows[rowId];\n\n // use these variables to have less property accesses\n const document = writeRow.document;\n const previous = writeRow.previous;\n const docId = document[primaryPath] as string;\n const documentDeleted = document._deleted;\n const previousDeleted = previous && previous._deleted;\n\n let documentInDb: RxDocumentData | undefined = undefined as any;\n if (hasDocsInDb) {\n documentInDb = docsInDb.get(docId);\n }\n let attachmentError: RxStorageWriteErrorAttachment | undefined;\n\n if (!documentInDb) {\n /**\n * It is possible to insert already deleted documents,\n * this can happen on replication.\n */\n const insertedIsDeleted = documentDeleted ? true : false;\n if (hasAttachments) {\n Object\n .entries(document._attachments)\n .forEach(([attachmentId, attachmentData]) => {\n if (\n !(attachmentData as RxAttachmentWriteData).data\n ) {\n attachmentError = {\n documentId: docId,\n isError: true,\n status: 510,\n writeRow,\n attachmentId\n };\n errors.push(attachmentError);\n } else {\n attachmentsAdd.push({\n documentId: docId,\n attachmentId,\n attachmentData: attachmentData as any,\n digest: attachmentData.digest\n });\n }\n });\n }\n if (!attachmentError) {\n if (hasAttachments) {\n bulkInsertDocs.push(stripAttachmentsDataFromRow(writeRow));\n if (onInsert) {\n onInsert(document);\n }\n } else {\n bulkInsertDocs.push(writeRow as any);\n if (onInsert) {\n onInsert(document);\n }\n }\n\n newestRow = writeRow as any;\n }\n\n if (!insertedIsDeleted) {\n const event = {\n documentId: docId,\n operation: 'INSERT' as const,\n documentData: hasAttachments ? stripAttachmentsDataFromDocument(document) : document as any,\n previousDocumentData: hasAttachments && previous ? stripAttachmentsDataFromDocument(previous) : previous as any\n };\n eventBulkEvents.push(event);\n }\n } else {\n // update existing document\n const revInDb: string = documentInDb._rev;\n\n /**\n * Check for conflict\n */\n if (\n (\n !previous\n ) ||\n (\n !!previous &&\n revInDb !== previous._rev\n )\n ) {\n // is conflict error\n const err: RxStorageWriteError = {\n isError: true,\n status: 409,\n documentId: docId,\n writeRow: writeRow,\n documentInDb\n };\n errors.push(err);\n continue;\n }\n\n // handle attachments data\n\n const updatedRow: BulkWriteRowProcessed = hasAttachments ? stripAttachmentsDataFromRow(writeRow) : writeRow as any;\n if (hasAttachments) {\n if (documentDeleted) {\n /**\n * Deleted documents must have cleared all their attachments.\n */\n if (previous) {\n Object\n .keys(previous._attachments)\n .forEach(attachmentId => {\n attachmentsRemove.push({\n documentId: docId,\n attachmentId,\n digest: ensureNotFalsy(previous)._attachments[attachmentId].digest\n });\n });\n }\n } else {\n // first check for errors\n Object\n .entries(document._attachments)\n .find(([attachmentId, attachmentData]) => {\n const previousAttachmentData = previous ? previous._attachments[attachmentId] : undefined;\n if (\n !previousAttachmentData &&\n !(attachmentData as RxAttachmentWriteData).data\n ) {\n attachmentError = {\n documentId: docId,\n documentInDb: documentInDb as any,\n isError: true,\n status: 510,\n writeRow,\n attachmentId\n };\n }\n return true;\n });\n if (!attachmentError) {\n Object\n .entries(document._attachments)\n .forEach(([attachmentId, attachmentData]) => {\n const previousAttachmentData = previous ? previous._attachments[attachmentId] : undefined;\n if (!previousAttachmentData) {\n attachmentsAdd.push({\n documentId: docId,\n attachmentId,\n attachmentData: attachmentData as any,\n digest: attachmentData.digest\n });\n } else {\n const newDigest = updatedRow.document._attachments[attachmentId].digest;\n if (\n (attachmentData as RxAttachmentWriteData).data &&\n /**\n * Performance shortcut,\n * do not update the attachment data if it did not change.\n */\n previousAttachmentData.digest !== newDigest\n ) {\n attachmentsUpdate.push({\n documentId: docId,\n attachmentId,\n attachmentData: attachmentData as RxAttachmentWriteData,\n digest: attachmentData.digest\n });\n }\n }\n });\n }\n }\n }\n\n if (attachmentError) {\n errors.push(attachmentError);\n } else {\n if (hasAttachments) {\n bulkUpdateDocs.push(stripAttachmentsDataFromRow(updatedRow));\n if (onUpdate) {\n onUpdate(document);\n }\n } else {\n bulkUpdateDocs.push(updatedRow);\n if (onUpdate) {\n onUpdate(document);\n }\n }\n newestRow = updatedRow as any;\n }\n\n let eventDocumentData: RxDocumentData | undefined = null as any;\n let previousEventDocumentData: RxDocumentData | undefined = null as any;\n let operation: 'INSERT' | 'UPDATE' | 'DELETE' = null as any;\n\n if (previousDeleted && !documentDeleted) {\n operation = 'INSERT';\n eventDocumentData = hasAttachments ? stripAttachmentsDataFromDocument(document) : document as any;\n } else if (previous && !previousDeleted && !documentDeleted) {\n operation = 'UPDATE';\n eventDocumentData = hasAttachments ? stripAttachmentsDataFromDocument(document) : document as any;\n previousEventDocumentData = previous;\n } else if (documentDeleted) {\n operation = 'DELETE';\n eventDocumentData = ensureNotFalsy(document) as any;\n previousEventDocumentData = previous;\n } else {\n throw newRxError('SNH', { args: { writeRow } });\n }\n\n const event = {\n documentId: docId,\n documentData: eventDocumentData as RxDocumentData,\n previousDocumentData: previousEventDocumentData,\n operation: operation\n };\n eventBulkEvents.push(event);\n }\n }\n\n return {\n bulkInsertDocs,\n bulkUpdateDocs,\n newestRow,\n errors,\n eventBulk,\n attachmentsAdd,\n attachmentsRemove,\n attachmentsUpdate\n };\n}\n\nexport function stripAttachmentsDataFromRow(writeRow: BulkWriteRow): BulkWriteRowProcessed {\n return {\n previous: writeRow.previous,\n document: stripAttachmentsDataFromDocument(writeRow.document)\n };\n}\n\nexport function getAttachmentSize(\n attachmentBase64String: string\n): number {\n return atob(attachmentBase64String).length;\n}\n\n/**\n * Used in custom RxStorage implementations.\n */\nexport function attachmentWriteDataToNormalData(writeData: RxAttachmentData | RxAttachmentWriteData): RxAttachmentData {\n const data = (writeData as RxAttachmentWriteData).data;\n if (!data) {\n return writeData as any;\n }\n const ret: RxAttachmentData = {\n length: getAttachmentSize(data),\n digest: writeData.digest,\n type: writeData.type\n };\n return ret;\n}\n\nexport function stripAttachmentsDataFromDocument(doc: RxDocumentWriteData): RxDocumentData {\n if (!doc._attachments || Object.keys(doc._attachments).length === 0) {\n return doc;\n }\n\n const useDoc: RxDocumentData = flatClone(doc) as any;\n useDoc._attachments = {};\n Object\n .entries(doc._attachments)\n .forEach(([attachmentId, attachmentData]) => {\n useDoc._attachments[attachmentId] = attachmentWriteDataToNormalData(attachmentData);\n });\n return useDoc;\n}\n\n/**\n * Flat clone the document data\n * and also the _meta field.\n * Used many times when we want to change the meta\n * during replication etc.\n */\nexport function flatCloneDocWithMeta(\n doc: RxDocumentData\n): RxDocumentData {\n const ret = flatClone(doc);\n ret._meta = flatClone(doc._meta);\n return ret;\n}\n\nexport type WrappedRxStorageInstance = RxStorageInstance & {\n originalStorageInstance: RxStorageInstance;\n};\n\n/**\n * Wraps the normal storageInstance of a RxCollection\n * to ensure that all access is properly using the hooks\n * and other data transformations and also ensure that database.lockedRun()\n * is used properly.\n */\nexport function getWrappedStorageInstance<\n RxDocType,\n Internals,\n InstanceCreationOptions,\n CheckpointType\n>(\n database: RxDatabase<{}, Internals, InstanceCreationOptions, any>,\n storageInstance: RxStorageInstance,\n /**\n * The original RxJsonSchema\n * before it was mutated by hooks.\n */\n rxJsonSchema: RxJsonSchema>\n): WrappedRxStorageInstance {\n overwritable.deepFreezeWhenDevMode(rxJsonSchema);\n const primaryPath = getPrimaryFieldOfPrimaryKey(rxJsonSchema.primaryKey);\n\n function transformDocumentDataFromRxDBToRxStorage(\n writeRow: BulkWriteRow\n ) {\n let data = flatClone(writeRow.document);\n data._meta = flatClone(data._meta);\n\n /**\n * Do some checks in dev-mode\n * that would be too performance expensive\n * in production.\n */\n if (overwritable.isDevMode()) {\n // ensure that the primary key has not been changed\n data = fillPrimaryKey(\n primaryPath,\n rxJsonSchema,\n data as any\n );\n\n\n /**\n * Ensure it can be structured cloned\n */\n try {\n /**\n * Notice that structuredClone() is not available\n * in ReactNative, so we test for JSON.stringify() instead\n * @link https://github.com/pubkey/rxdb/issues/5046#issuecomment-1827374498\n */\n if (typeof structuredClone === 'function') {\n structuredClone(writeRow);\n } else {\n JSON.parse(JSON.stringify(writeRow));\n }\n } catch (err) {\n throw newRxError('DOC24', {\n collection: storageInstance.collectionName,\n document: writeRow.document\n });\n }\n\n /**\n * Ensure that the new revision is higher\n * then the previous one\n */\n if (writeRow.previous) {\n // TODO run this in the dev-mode plugin\n // const prev = parseRevision(writeRow.previous._rev);\n // const current = parseRevision(writeRow.document._rev);\n // if (current.height <= prev.height) {\n // throw newRxError('SNH', {\n // dataBefore: writeRow.previous,\n // dataAfter: writeRow.document,\n // args: {\n // prev,\n // current\n // }\n // });\n // }\n }\n\n /**\n * Ensure that _meta fields have been merged\n * and not replaced.\n * This is important so that when one plugin A\n * sets a _meta field and another plugin B does a write\n * to the document, it must be ensured that the\n * field of plugin A was not removed.\n */\n if (writeRow.previous) {\n Object.keys(writeRow.previous._meta)\n .forEach(metaFieldName => {\n if (!Object.prototype.hasOwnProperty.call(writeRow.document._meta, metaFieldName)) {\n throw newRxError('SNH', {\n dataBefore: writeRow.previous,\n dataAfter: writeRow.document\n });\n }\n });\n }\n }\n data._meta.lwt = now();\n\n /**\n * Yes we really want to set the revision here.\n * If you make a plugin that relies on having its own revision\n * stored into the storage, use this.originalStorageInstance.bulkWrite() instead.\n */\n data._rev = createRevision(\n database.token,\n writeRow.previous\n );\n\n return {\n document: data,\n previous: writeRow.previous\n };\n }\n\n const ret: WrappedRxStorageInstance = {\n originalStorageInstance: storageInstance,\n schema: storageInstance.schema,\n internals: storageInstance.internals,\n collectionName: storageInstance.collectionName,\n databaseName: storageInstance.databaseName,\n options: storageInstance.options,\n bulkWrite(\n rows: BulkWriteRow[],\n context: string\n ) {\n const toStorageWriteRows: BulkWriteRow[] = rows\n .map(row => transformDocumentDataFromRxDBToRxStorage(row));\n\n return database.lockedRun(\n () => storageInstance.bulkWrite(\n toStorageWriteRows,\n context\n )\n )\n /**\n * The RxStorageInstance MUST NOT allow to insert already _deleted documents,\n * without sending the previous document version.\n * But for better developer experience, RxDB does allow to re-insert deleted documents.\n * We do this by automatically fixing the conflict errors for that case\n * by running another bulkWrite() and merging the results.\n * @link https://github.com/pubkey/rxdb/pull/3839\n */\n .then(writeResult => {\n const useWriteResult: typeof writeResult = {\n error: [],\n success: writeResult.success.slice(0)\n };\n const reInsertErrors: RxStorageWriteErrorConflict[] =\n writeResult.error\n .filter((error) => {\n if (\n error.status === 409 &&\n !error.writeRow.previous &&\n !error.writeRow.document._deleted &&\n ensureNotFalsy(error.documentInDb)._deleted\n ) {\n return true;\n }\n useWriteResult.error.push(error);\n return false;\n }) as any;\n if (reInsertErrors.length > 0) {\n const reInserts: BulkWriteRow[] = reInsertErrors\n .map((error) => {\n return {\n previous: error.documentInDb,\n document: Object.assign(\n {},\n error.writeRow.document,\n {\n _rev: createRevision(\n database.token,\n error.documentInDb\n )\n }\n )\n };\n });\n\n return database.lockedRun(\n () => storageInstance.bulkWrite(\n reInserts,\n context\n )\n ).then(subResult => {\n appendToArray(useWriteResult.error, subResult.error);\n appendToArray(useWriteResult.success, subResult.success);\n return useWriteResult;\n });\n }\n\n return writeResult;\n });\n },\n query(preparedQuery) {\n return database.lockedRun(\n () => storageInstance.query(preparedQuery)\n );\n },\n count(preparedQuery) {\n return database.lockedRun(\n () => storageInstance.count(preparedQuery)\n );\n },\n findDocumentsById(ids, deleted) {\n return database.lockedRun(\n () => storageInstance.findDocumentsById(ids, deleted)\n );\n },\n getAttachmentData(\n documentId: string,\n attachmentId: string,\n digest: string\n ) {\n return database.lockedRun(\n () => storageInstance.getAttachmentData(documentId, attachmentId, digest)\n );\n },\n getChangedDocumentsSince: !storageInstance.getChangedDocumentsSince ? undefined : (limit: number, checkpoint?: any) => {\n return database.lockedRun(\n () => ((storageInstance as any).getChangedDocumentsSince)(ensureNotFalsy(limit), checkpoint)\n );\n },\n cleanup(minDeletedTime: number) {\n return database.lockedRun(\n () => storageInstance.cleanup(minDeletedTime)\n );\n },\n remove() {\n database.storageInstances.delete(ret);\n return database.lockedRun(\n () => storageInstance.remove()\n );\n },\n close() {\n database.storageInstances.delete(ret);\n return database.lockedRun(\n () => storageInstance.close()\n );\n },\n changeStream() {\n return storageInstance.changeStream();\n },\n conflictResultionTasks() {\n return storageInstance.conflictResultionTasks();\n },\n resolveConflictResultionTask(taskSolution) {\n if (taskSolution.output.isEqual) {\n return storageInstance.resolveConflictResultionTask(taskSolution);\n }\n\n const doc = Object.assign(\n {},\n taskSolution.output.documentData,\n {\n _meta: getDefaultRxDocumentMeta(),\n _rev: getDefaultRevision(),\n _attachments: {}\n }\n );\n\n const documentData = flatClone(doc);\n delete (documentData as any)._meta;\n delete (documentData as any)._rev;\n delete (documentData as any)._attachments;\n\n return storageInstance.resolveConflictResultionTask({\n id: taskSolution.id,\n output: {\n isEqual: false,\n documentData\n }\n });\n }\n };\n\n database.storageInstances.add(ret);\n return ret;\n}\n\n/**\n * Each RxStorage implementation should\n * run this method at the first step of createStorageInstance()\n * to ensure that the configuration is correct.\n */\nexport function ensureRxStorageInstanceParamsAreCorrect(\n params: RxStorageInstanceCreationParams\n) {\n if (params.schema.keyCompression) {\n throw newRxError('UT5', { args: { params } });\n }\n if (hasEncryption(params.schema)) {\n throw newRxError('UT6', { args: { params } });\n }\n if (\n params.schema.attachments &&\n params.schema.attachments.compression\n ) {\n throw newRxError('UT7', { args: { params } });\n }\n}\n\nexport function hasEncryption(jsonSchema: RxJsonSchema): boolean {\n if (\n (!!jsonSchema.encrypted && jsonSchema.encrypted.length > 0) ||\n (jsonSchema.attachments && jsonSchema.attachments.encrypted)\n ) {\n return true;\n } else {\n return false;\n }\n}\n\nexport function getChangedDocumentsSinceQuery(\n storageInstance: RxStorageInstance,\n limit: number,\n checkpoint?: CheckpointType\n): FilledMangoQuery {\n const primaryPath = getPrimaryFieldOfPrimaryKey(storageInstance.schema.primaryKey);\n const sinceLwt = checkpoint ? (checkpoint as unknown as RxStorageDefaultCheckpoint).lwt : RX_META_LWT_MINIMUM;\n const sinceId = checkpoint ? (checkpoint as unknown as RxStorageDefaultCheckpoint).id : '';\n return normalizeMangoQuery(storageInstance.schema, {\n selector: {\n $or: [\n {\n '_meta.lwt': {\n $gt: sinceLwt\n }\n },\n {\n '_meta.lwt': {\n $eq: sinceLwt\n },\n [primaryPath]: {\n $gt: checkpoint ? sinceId : ''\n }\n }\n ],\n // add this hint for better index usage\n '_meta.lwt': {\n $gte: sinceLwt\n }\n } as any,\n sort: [\n { '_meta.lwt': 'asc' },\n { [primaryPath]: 'asc' }\n ] as any,\n skip: 0,\n limit,\n /**\n * DO NOT SET A SPECIFIC INDEX HERE!\n * The query might be modified by some plugin\n * before sending it to the storage.\n * We can be sure that in the end the query planner\n * will find the best index.\n */\n // index: ['_meta.lwt', primaryPath]\n });\n}\n\nexport async function getChangedDocumentsSince(\n storageInstance: RxStorageInstance,\n limit: number,\n checkpoint?: CheckpointType\n): Promise<{\n documents: RxDocumentData[];\n /**\n * The checkpoint contains data so that another\n * call to getChangedDocumentsSince() will continue\n * from exactly the last document that was returned before.\n */\n checkpoint: CheckpointType;\n}> {\n if (storageInstance.getChangedDocumentsSince) {\n return storageInstance.getChangedDocumentsSince(limit, checkpoint);\n }\n\n const primaryPath = getPrimaryFieldOfPrimaryKey(storageInstance.schema.primaryKey);\n const query = prepareQuery>(\n storageInstance.schema,\n getChangedDocumentsSinceQuery(\n storageInstance,\n limit,\n checkpoint\n )\n );\n\n const result = await storageInstance.query(query);\n const documents = result.documents;\n const lastDoc = lastOfArray(documents);\n\n return {\n documents: documents,\n checkpoint: lastDoc ? {\n id: (lastDoc as any)[primaryPath],\n lwt: lastDoc._meta.lwt\n } as any : checkpoint ? checkpoint : {\n id: '',\n lwt: 0\n }\n };\n}\n\n\n/**\n * Wraps the storage and simluates\n * delays. Mostly used in tests.\n */\nexport function randomDelayStorage(\n input: {\n storage: RxStorage;\n delayTimeBefore: () => number;\n delayTimeAfter: () => number;\n }\n): RxStorage {\n\n const retStorage: RxStorage = {\n name: 'random-delay-' + input.storage.name,\n rxdbVersion: RXDB_VERSION,\n async createStorageInstance(params) {\n await promiseWait(input.delayTimeBefore());\n const storageInstance = await input.storage.createStorageInstance(params);\n await promiseWait(input.delayTimeAfter());\n\n // write still must be processed in order\n let writeQueue: Promise = PROMISE_RESOLVE_TRUE;\n\n return {\n databaseName: storageInstance.databaseName,\n internals: storageInstance.internals,\n options: storageInstance.options,\n schema: storageInstance.schema,\n collectionName: storageInstance.collectionName,\n async bulkWrite(a, b) {\n writeQueue = writeQueue.then(async () => {\n await promiseWait(input.delayTimeBefore());\n const response = await storageInstance.bulkWrite(a, b);\n await promiseWait(input.delayTimeAfter());\n return response;\n });\n const ret = await writeQueue;\n return ret;\n },\n async findDocumentsById(a, b) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.findDocumentsById(a, b);\n await promiseWait(input.delayTimeAfter());\n return ret;\n },\n async query(a) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.query(a);\n return ret;\n },\n async count(a) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.count(a);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n async getAttachmentData(a, b, c) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.getAttachmentData(a, b, c);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n getChangedDocumentsSince: !storageInstance.getChangedDocumentsSince ? undefined : async (a, b) => {\n await promiseWait(input.delayTimeBefore());\n const ret = await ensureNotFalsy(storageInstance.getChangedDocumentsSince)(a, b);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n changeStream() {\n return storageInstance.changeStream();\n },\n conflictResultionTasks() {\n return storageInstance.conflictResultionTasks();\n },\n resolveConflictResultionTask(a) {\n return storageInstance.resolveConflictResultionTask(a);\n },\n async cleanup(a) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.cleanup(a);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n async close() {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.close();\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n async remove() {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.remove();\n await promiseWait(input.delayTimeAfter());\n return ret;\n },\n };\n\n\n }\n };\n return retStorage;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA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D,CAAC,EAAE;UACb,MAAM,IAAAL,kBAAW,EAACN,KAAK,CAACO,eAAe,CAAC,CAAC,CAAC;UAC1C,IAAMxM,GAAG,GAAG,MAAMd,eAAe,CAACwK,OAAO,CAACkD,CAAC,CAAC;UAC5C,MAAM,IAAAL,kBAAW,EAACN,KAAK,CAACQ,cAAc,CAAC,CAAC,CAAC;UACzC,OAAOzM,GAAG;QAEd,CAAC;QACD,MAAM+J,KAAKA,CAAA,EAAG;UACV,MAAM,IAAAwC,kBAAW,EAACN,KAAK,CAACO,eAAe,CAAC,CAAC,CAAC;UAC1C,IAAMxM,GAAG,GAAG,MAAMd,eAAe,CAAC6K,KAAK,CAAC,CAAC;UACzC,MAAM,IAAAwC,kBAAW,EAACN,KAAK,CAACQ,cAAc,CAAC,CAAC,CAAC;UACzC,OAAOzM,GAAG;QAEd,CAAC;QACD,MAAM4J,MAAMA,CAAA,EAAG;UACX,MAAM,IAAA2C,kBAAW,EAACN,KAAK,CAACO,eAAe,CAAC,CAAC,CAAC;UAC1C,IAAMxM,GAAG,GAAG,MAAMd,eAAe,CAAC0K,MAAM,CAAC,CAAC;UAC1C,MAAM,IAAA2C,kBAAW,EAACN,KAAK,CAACQ,cAAc,CAAC,CAAC,CAAC;UACzC,OAAOzM,GAAG;QACd;MACJ,CAAC;IAGL;EACJ,CAAC;EACD,OAAOkM,UAAU;AACrB","ignoreList":[]} \ No newline at end of file diff --git a/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js b/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js index 2967d12e386..6c8ac6b3587 100644 --- a/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js +++ b/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js @@ -14,8 +14,16 @@ import { getQueryMatcher, getSortComparator } from "../../rx-query-helper.js"; */ export var OPEN_MEMORY_INSTANCES = new Set(); export var RxStorageInstanceMemory = /*#__PURE__*/function () { + /** + * Used by some plugins and storage wrappers + * to find out details about the internals of a write operation. + * For example if you want to know which documents really have been replaced + * or newly inserted. + */ + function RxStorageInstanceMemory(storage, databaseName, collectionName, schema, internals, options, settings) { this.closed = false; + this.categorizedByWriteInput = new WeakMap(); this.storage = storage; this.databaseName = databaseName; this.collectionName = collectionName; @@ -48,6 +56,7 @@ export var RxStorageInstanceMemory = /*#__PURE__*/function () { var _doc = _writeRow.document; success.push(_doc); } + this.categorizedByWriteInput.set(documentWrites, categorized); this.internals.ensurePersistenceTask = categorized; if (!this.internals.ensurePersistenceIdlePromise) { this.internals.ensurePersistenceIdlePromise = requestIdlePromiseNoQueue().then(() => { diff --git a/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js.map b/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js.map index 683f57056f3..cec71a0694a 100644 --- a/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js.map +++ b/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js.map @@ -1 +1 @@ -{"version":3,"file":"rx-storage-instance-memory.js","names":["Subject","getStartIndexStringFromLowerBound","getStartIndexStringFromUpperBound","getPrimaryFieldOfPrimaryKey","categorizeBulkWriteRows","deepEqual","ensureNotFalsy","now","PROMISE_RESOLVE_TRUE","PROMISE_RESOLVE_VOID","randomCouchString","requestIdlePromiseNoQueue","boundGE","boundGT","boundLE","boundLT","attachmentMapKey","compareDocsWithIndex","ensureNotRemoved","getMemoryCollectionKey","putWriteRowToState","removeDocFromState","addIndexesToInternalsState","getMemoryIndexName","getQueryMatcher","getSortComparator","OPEN_MEMORY_INSTANCES","Set","RxStorageInstanceMemory","storage","databaseName","collectionName","schema","internals","options","settings","closed","add","primaryPath","primaryKey","_proto","prototype","bulkWrite","documentWrites","context","ensurePersistence","documentsById","documents","categorized","error","errors","success","Array","bulkInsertDocs","length","i","writeRow","doc","document","bulkUpdateDocs","push","ensurePersistenceTask","ensurePersistenceIdlePromise","then","undefined","eventBulk","events","lastState","newestRow","checkpoint","id","lwt","_meta","endTime","changes$","next","ret","Promise","resolve","stateByIndex","Object","values","byIndex","docId","get","attachments","attachmentsMap","attachmentsAdd","forEach","attachment","set","documentId","attachmentId","writeData","attachmentData","digest","attachmentsUpdate","attachmentsRemove","delete","findDocumentsById","docIds","withDeleted","size","docInDb","_deleted","query","preparedQuery","queryPlan","skip","limit","Infinity","skipPlusLimit","queryMatcher","selectorSatisfiedByIndex","queryPlanFields","index","mustManuallyResort","sortSatisfiedByIndex","lowerBound","startKeys","lowerBoundString","upperBound","endKeys","upperBoundString","indexName","Error","docsWithIndex","indexOfLower","inclusiveStart","indexString","indexOfUpper","inclusiveEnd","rows","done","currentRow","currentDoc","sortComparator","sort","slice","count","result","mode","cleanup","minimumDeletedTime","maxDeletionTime","getAttachmentData","key","data","changeStream","asObservable","remove","removed","collectionStates","version","close","refCount","conflictResultionTasks","conflictResultionTasks$","resolveConflictResultionTask","_taskSolution","createMemoryStorageInstance","params","collectionKey","Map","devMode","instance"],"sources":["../../../../src/plugins/storage-memory/rx-storage-instance-memory.ts"],"sourcesContent":["import {\n Observable,\n Subject\n} from 'rxjs';\nimport {\n getStartIndexStringFromLowerBound,\n getStartIndexStringFromUpperBound\n} from '../../custom-index.ts';\nimport { getPrimaryFieldOfPrimaryKey } from '../../rx-schema-helper.ts';\nimport {\n categorizeBulkWriteRows\n} from '../../rx-storage-helper.ts';\nimport type {\n BulkWriteRow,\n EventBulk,\n PreparedQuery,\n QueryMatcher,\n RxConflictResultionTask,\n RxConflictResultionTaskSolution,\n RxDocumentData,\n RxJsonSchema,\n RxStorageBulkWriteResponse,\n RxStorageChangeEvent,\n RxStorageCountResult,\n RxStorageDefaultCheckpoint,\n RxStorageInstance,\n RxStorageInstanceCreationParams,\n RxStorageQueryResult,\n StringKeys\n} from '../../types/index.d.ts';\nimport {\n deepEqual,\n ensureNotFalsy,\n now,\n PROMISE_RESOLVE_TRUE,\n PROMISE_RESOLVE_VOID,\n randomCouchString,\n requestIdlePromiseNoQueue\n} from '../../plugins/utils/index.ts';\nimport {\n boundGE,\n boundGT,\n boundLE,\n boundLT\n} from './binary-search-bounds.ts';\nimport {\n attachmentMapKey,\n compareDocsWithIndex,\n ensureNotRemoved,\n getMemoryCollectionKey,\n putWriteRowToState,\n removeDocFromState\n} from './memory-helper.ts';\nimport {\n addIndexesToInternalsState,\n getMemoryIndexName\n} from './memory-indexes.ts';\nimport type {\n MemoryStorageInternals,\n RxStorageMemory,\n RxStorageMemoryInstanceCreationOptions,\n RxStorageMemorySettings\n} from './memory-types.ts';\nimport { getQueryMatcher, getSortComparator } from '../../rx-query-helper.ts';\n\n/**\n * Used in tests to ensure everything\n * is closed correctly\n */\nexport const OPEN_MEMORY_INSTANCES = new Set>();\n\nexport class RxStorageInstanceMemory implements RxStorageInstance<\n RxDocType,\n MemoryStorageInternals,\n RxStorageMemoryInstanceCreationOptions,\n RxStorageDefaultCheckpoint\n> {\n\n public readonly primaryPath: StringKeys>;\n public closed = false;\n\n constructor(\n public readonly storage: RxStorageMemory,\n public readonly databaseName: string,\n public readonly collectionName: string,\n public readonly schema: Readonly>>,\n public readonly internals: MemoryStorageInternals,\n public readonly options: Readonly,\n public readonly settings: RxStorageMemorySettings\n ) {\n OPEN_MEMORY_INSTANCES.add(this);\n this.primaryPath = getPrimaryFieldOfPrimaryKey(this.schema.primaryKey);\n }\n\n bulkWrite(\n documentWrites: BulkWriteRow[],\n context: string\n ): Promise> {\n this.ensurePersistence();\n ensureNotRemoved(this);\n const internals = this.internals;\n const documentsById = this.internals.documents;\n const primaryPath = this.primaryPath;\n\n const categorized = categorizeBulkWriteRows(\n this,\n primaryPath as any,\n documentsById,\n documentWrites,\n context\n );\n const error = categorized.errors;\n const success: RxDocumentData[] = new Array(categorized.bulkInsertDocs.length);\n const bulkInsertDocs = categorized.bulkInsertDocs;\n for (let i = 0; i < bulkInsertDocs.length; ++i) {\n const writeRow = bulkInsertDocs[i];\n const doc = writeRow.document;\n success[i] = doc;\n }\n const bulkUpdateDocs = categorized.bulkUpdateDocs;\n for (let i = 0; i < bulkUpdateDocs.length; ++i) {\n const writeRow = bulkUpdateDocs[i];\n const doc = writeRow.document;\n success.push(doc);\n }\n\n this.internals.ensurePersistenceTask = categorized;\n if (!this.internals.ensurePersistenceIdlePromise) {\n this.internals.ensurePersistenceIdlePromise = requestIdlePromiseNoQueue().then(() => {\n this.internals.ensurePersistenceIdlePromise = undefined;\n this.ensurePersistence();\n });\n }\n\n /**\n * Important: The events must be emitted AFTER the persistence\n * task has been added.\n */\n if (categorized.eventBulk.events.length > 0) {\n const lastState = ensureNotFalsy(categorized.newestRow).document;\n categorized.eventBulk.checkpoint = {\n id: lastState[primaryPath],\n lwt: lastState._meta.lwt\n };\n categorized.eventBulk.endTime = now();\n PROMISE_RESOLVE_TRUE.then(() => {\n internals.changes$.next(categorized.eventBulk);\n });\n }\n\n const ret = Promise.resolve({ success, error });\n return ret;\n }\n\n /**\n * Instead of directly inserting the documents into all indexes,\n * we do it lazy in the background. This gives the application time\n * to directly work with the write-result and to do stuff like rendering DOM\n * notes and processing RxDB queries.\n * Then in some later time, or just before the next read/write,\n * it is ensured that the indexes have been written.\n */\n public ensurePersistence() {\n if (\n !this.internals.ensurePersistenceTask\n ) {\n return;\n }\n const internals = this.internals;\n const documentsById = this.internals.documents;\n const primaryPath = this.primaryPath;\n\n const categorized = this.internals.ensurePersistenceTask;\n this.internals.ensurePersistenceTask = undefined;\n\n /**\n * Do inserts/updates\n */\n const stateByIndex = Object.values(this.internals.byIndex);\n\n const bulkInsertDocs = categorized.bulkInsertDocs;\n for (let i = 0; i < bulkInsertDocs.length; ++i) {\n const writeRow = bulkInsertDocs[i];\n const doc = writeRow.document;\n const docId = doc[primaryPath];\n putWriteRowToState(\n docId as any,\n internals,\n stateByIndex,\n writeRow,\n undefined\n );\n }\n\n const bulkUpdateDocs = categorized.bulkUpdateDocs;\n for (let i = 0; i < bulkUpdateDocs.length; ++i) {\n const writeRow = bulkUpdateDocs[i];\n const doc = writeRow.document;\n const docId = doc[primaryPath];\n putWriteRowToState(\n docId as any,\n internals,\n stateByIndex,\n writeRow,\n documentsById.get(docId as any)\n );\n }\n\n /**\n * Handle attachments\n */\n if (this.schema.attachments) {\n const attachmentsMap = internals.attachments;\n categorized.attachmentsAdd.forEach(attachment => {\n attachmentsMap.set(\n attachmentMapKey(attachment.documentId, attachment.attachmentId),\n {\n writeData: attachment.attachmentData,\n digest: attachment.digest\n }\n );\n });\n if (this.schema.attachments) {\n categorized.attachmentsUpdate.forEach(attachment => {\n attachmentsMap.set(\n attachmentMapKey(attachment.documentId, attachment.attachmentId),\n {\n writeData: attachment.attachmentData,\n digest: attachment.digest\n }\n );\n });\n categorized.attachmentsRemove.forEach(attachment => {\n attachmentsMap.delete(\n attachmentMapKey(attachment.documentId, attachment.attachmentId)\n );\n });\n }\n }\n }\n\n findDocumentsById(\n docIds: string[],\n withDeleted: boolean\n ): Promise[]> {\n this.ensurePersistence();\n const documentsById = this.internals.documents;\n const ret: RxDocumentData[] = [];\n if (documentsById.size === 0) {\n return Promise.resolve(ret);\n }\n for (let i = 0; i < docIds.length; ++i) {\n const docId = docIds[i];\n const docInDb = documentsById.get(docId);\n if (\n docInDb &&\n (\n !docInDb._deleted ||\n withDeleted\n )\n ) {\n ret.push(docInDb);\n }\n }\n return Promise.resolve(ret);\n }\n\n query(\n preparedQuery: PreparedQuery\n ): Promise> {\n this.ensurePersistence();\n\n const queryPlan = preparedQuery.queryPlan;\n const query = preparedQuery.query;\n\n const skip = query.skip ? query.skip : 0;\n const limit = query.limit ? query.limit : Infinity;\n const skipPlusLimit = skip + limit;\n\n let queryMatcher: QueryMatcher> | false = false;\n if (!queryPlan.selectorSatisfiedByIndex) {\n queryMatcher = getQueryMatcher(\n this.schema,\n preparedQuery.query\n );\n }\n\n const queryPlanFields: string[] = queryPlan.index;\n const mustManuallyResort = !queryPlan.sortSatisfiedByIndex;\n const index: string[] | undefined = queryPlanFields;\n const lowerBound: any[] = queryPlan.startKeys;\n const lowerBoundString = getStartIndexStringFromLowerBound(\n this.schema,\n index,\n lowerBound\n );\n\n let upperBound: any[] = queryPlan.endKeys;\n upperBound = upperBound;\n const upperBoundString = getStartIndexStringFromUpperBound(\n this.schema,\n index,\n upperBound\n );\n const indexName = getMemoryIndexName(index);\n\n if (!this.internals.byIndex[indexName]) {\n throw new Error('index does not exist ' + indexName);\n }\n const docsWithIndex = this.internals.byIndex[indexName].docsWithIndex;\n\n\n\n let indexOfLower = (queryPlan.inclusiveStart ? boundGE : boundGT)(\n docsWithIndex,\n {\n indexString: lowerBoundString\n } as any,\n compareDocsWithIndex\n );\n\n const indexOfUpper = (queryPlan.inclusiveEnd ? boundLE : boundLT)(\n docsWithIndex,\n {\n indexString: upperBoundString\n } as any,\n compareDocsWithIndex\n );\n\n let rows: RxDocumentData[] = [];\n let done = false;\n while (!done) {\n const currentRow = docsWithIndex[indexOfLower];\n if (\n !currentRow ||\n indexOfLower > indexOfUpper\n ) {\n break;\n }\n const currentDoc = currentRow.doc;\n\n if (!queryMatcher || queryMatcher(currentDoc)) {\n rows.push(currentDoc);\n }\n\n if (\n (rows.length >= skipPlusLimit && !mustManuallyResort)\n ) {\n done = true;\n }\n\n indexOfLower++;\n }\n\n if (mustManuallyResort) {\n const sortComparator = getSortComparator(this.schema, preparedQuery.query);\n rows = rows.sort(sortComparator);\n }\n\n // apply skip and limit boundaries.\n rows = rows.slice(skip, skipPlusLimit);\n return Promise.resolve({\n documents: rows\n });\n }\n\n async count(\n preparedQuery: PreparedQuery\n ): Promise {\n this.ensurePersistence();\n const result = await this.query(preparedQuery);\n return {\n count: result.documents.length,\n mode: 'fast'\n };\n }\n\n cleanup(minimumDeletedTime: number): Promise {\n this.ensurePersistence();\n const maxDeletionTime = now() - minimumDeletedTime;\n const index = ['_deleted', '_meta.lwt', this.primaryPath as any];\n const indexName = getMemoryIndexName(index);\n const docsWithIndex = this.internals.byIndex[indexName].docsWithIndex;\n\n const lowerBoundString = getStartIndexStringFromLowerBound(\n this.schema,\n index,\n [\n true,\n 0,\n ''\n ]\n );\n\n let indexOfLower = boundGT(\n docsWithIndex,\n {\n indexString: lowerBoundString\n } as any,\n compareDocsWithIndex\n );\n\n let done = false;\n while (!done) {\n const currentDoc = docsWithIndex[indexOfLower];\n if (!currentDoc || currentDoc.doc._meta.lwt > maxDeletionTime) {\n done = true;\n } else {\n removeDocFromState(\n this.primaryPath as any,\n this.schema,\n this.internals,\n currentDoc.doc\n );\n indexOfLower++;\n }\n }\n return PROMISE_RESOLVE_TRUE;\n }\n\n getAttachmentData(\n documentId: string,\n attachmentId: string,\n digest: string\n ): Promise {\n this.ensurePersistence();\n ensureNotRemoved(this);\n const key = attachmentMapKey(documentId, attachmentId);\n const data = this.internals.attachments.get(key);\n\n if (\n !digest ||\n !data ||\n data.digest !== digest\n ) {\n throw new Error('attachment does not exist: ' + key);\n }\n return Promise.resolve(data.writeData.data);\n }\n\n changeStream(): Observable>, RxStorageDefaultCheckpoint>> {\n ensureNotRemoved(this);\n return this.internals.changes$.asObservable();\n }\n\n async remove(): Promise {\n if (this.closed) {\n throw new Error('closed');\n }\n this.ensurePersistence();\n ensureNotRemoved(this);\n\n this.internals.removed = true;\n this.storage.collectionStates.delete(\n getMemoryCollectionKey(\n this.databaseName,\n this.collectionName,\n this.schema.version\n )\n );\n await this.close();\n }\n\n close(): Promise {\n OPEN_MEMORY_INSTANCES.delete(this);\n\n this.ensurePersistence();\n if (this.closed) {\n return PROMISE_RESOLVE_VOID;\n }\n this.closed = true;\n\n this.internals.refCount = this.internals.refCount - 1;\n return PROMISE_RESOLVE_VOID;\n }\n\n conflictResultionTasks(): Observable> {\n return this.internals.conflictResultionTasks$.asObservable();\n }\n resolveConflictResultionTask(_taskSolution: RxConflictResultionTaskSolution): Promise {\n return PROMISE_RESOLVE_VOID;\n }\n}\n\nexport function createMemoryStorageInstance(\n storage: RxStorageMemory,\n params: RxStorageInstanceCreationParams,\n settings: RxStorageMemorySettings\n): Promise> {\n const collectionKey = getMemoryCollectionKey(\n params.databaseName,\n params.collectionName,\n params.schema.version\n );\n\n let internals = storage.collectionStates.get(collectionKey);\n if (!internals) {\n internals = {\n id: randomCouchString(5),\n schema: params.schema,\n removed: false,\n refCount: 1,\n documents: new Map(),\n attachments: params.schema.attachments ? new Map() : undefined as any,\n byIndex: {},\n conflictResultionTasks$: new Subject(),\n changes$: new Subject()\n };\n addIndexesToInternalsState(internals, params.schema);\n storage.collectionStates.set(collectionKey, internals);\n } else {\n /**\n * Ensure that the storage was not already\n * created with a different schema.\n * This is very important because if this check\n * does not exist here, we have hard-to-debug problems\n * downstream.\n */\n if (\n params.devMode &&\n !deepEqual(internals.schema, params.schema)\n ) {\n throw new Error('storage was already created with a different schema');\n }\n internals.refCount = internals.refCount + 1;\n }\n\n const instance = new RxStorageInstanceMemory(\n storage,\n params.databaseName,\n params.collectionName,\n params.schema,\n internals,\n params.options,\n settings\n );\n return Promise.resolve(instance);\n}\n"],"mappings":"AAAA,SAEIA,OAAO,QACJ,MAAM;AACb,SACIC,iCAAiC,EACjCC,iCAAiC,QAC9B,uBAAuB;AAC9B,SAASC,2BAA2B,QAAQ,2BAA2B;AACvE,SACIC,uBAAuB,QACpB,4BAA4B;AAmBnC,SACIC,SAAS,EACTC,cAAc,EACdC,GAAG,EACHC,oBAAoB,EACpBC,oBAAoB,EACpBC,iBAAiB,EACjBC,yBAAyB,QACtB,8BAA8B;AACrC,SACIC,OAAO,EACPC,OAAO,EACPC,OAAO,EACPC,OAAO,QACJ,2BAA2B;AAClC,SACIC,gBAAgB,EAChBC,oBAAoB,EACpBC,gBAAgB,EAChBC,sBAAsB,EACtBC,kBAAkB,EAClBC,kBAAkB,QACf,oBAAoB;AAC3B,SACIC,0BAA0B,EAC1BC,kBAAkB,QACf,qBAAqB;AAO5B,SAASC,eAAe,EAAEC,iBAAiB,QAAQ,0BAA0B;;AAE7E;AACA;AACA;AACA;AACA,OAAO,IAAMC,qBAAqB,GAAG,IAAIC,GAAG,CAA+B,CAAC;AAE5E,WAAaC,uBAAuB;EAUhC,SAAAA,wBACoBC,OAAwB,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,CAAC;EAC1D,CAAC,MAAM;IACH;AACR;AACA;AACA;AACA;AACA;AACA;IACQ,IACIgI,MAAM,CAACG,OAAO,IACd,CAAC/J,SAAS,CAAC4B,SAAS,CAACD,MAAM,EAAEiI,MAAM,CAACjI,MAAM,CAAC,EAC7C;MACE,MAAM,IAAI6F,KAAK,CAAC,qDAAqD,CAAC;IAC1E;IACA5F,SAAS,CAAC0H,QAAQ,GAAG1H,SAAS,CAAC0H,QAAQ,GAAG,CAAC;EAC/C;EAEA,IAAMU,QAAQ,GAAG,IAAIzI,uBAAuB,CACxCC,OAAO,EACPoI,MAAM,CAACnI,YAAY,EACnBmI,MAAM,CAAClI,cAAc,EACrBkI,MAAM,CAACjI,MAAM,EACbC,SAAS,EACTgI,MAAM,CAAC/H,OAAO,EACdC,QACJ,CAAC;EACD,OAAO0C,OAAO,CAACC,OAAO,CAACuF,QAAQ,CAAC;AACpC","ignoreList":[]} \ No newline at end of file +{"version":3,"file":"rx-storage-instance-memory.js","names":["Subject","getStartIndexStringFromLowerBound","getStartIndexStringFromUpperBound","getPrimaryFieldOfPrimaryKey","categorizeBulkWriteRows","deepEqual","ensureNotFalsy","now","PROMISE_RESOLVE_TRUE","PROMISE_RESOLVE_VOID","randomCouchString","requestIdlePromiseNoQueue","boundGE","boundGT","boundLE","boundLT","attachmentMapKey","compareDocsWithIndex","ensureNotRemoved","getMemoryCollectionKey","putWriteRowToState","removeDocFromState","addIndexesToInternalsState","getMemoryIndexName","getQueryMatcher","getSortComparator","OPEN_MEMORY_INSTANCES","Set","RxStorageInstanceMemory","storage","databaseName","collectionName","schema","internals","options","settings","closed","categorizedByWriteInput","WeakMap","add","primaryPath","primaryKey","_proto","prototype","bulkWrite","documentWrites","context","ensurePersistence","documentsById","documents","categorized","error","errors","success","Array","bulkInsertDocs","length","i","writeRow","doc","document","bulkUpdateDocs","push","set","ensurePersistenceTask","ensurePersistenceIdlePromise","then","undefined","eventBulk","events","lastState","newestRow","checkpoint","id","lwt","_meta","endTime","changes$","next","ret","Promise","resolve","stateByIndex","Object","values","byIndex","docId","get","attachments","attachmentsMap","attachmentsAdd","forEach","attachment","documentId","attachmentId","writeData","attachmentData","digest","attachmentsUpdate","attachmentsRemove","delete","findDocumentsById","docIds","withDeleted","size","docInDb","_deleted","query","preparedQuery","queryPlan","skip","limit","Infinity","skipPlusLimit","queryMatcher","selectorSatisfiedByIndex","queryPlanFields","index","mustManuallyResort","sortSatisfiedByIndex","lowerBound","startKeys","lowerBoundString","upperBound","endKeys","upperBoundString","indexName","Error","docsWithIndex","indexOfLower","inclusiveStart","indexString","indexOfUpper","inclusiveEnd","rows","done","currentRow","currentDoc","sortComparator","sort","slice","count","result","mode","cleanup","minimumDeletedTime","maxDeletionTime","getAttachmentData","key","data","changeStream","asObservable","remove","removed","collectionStates","version","close","refCount","conflictResultionTasks","conflictResultionTasks$","resolveConflictResultionTask","_taskSolution","createMemoryStorageInstance","params","collectionKey","Map","devMode","instance"],"sources":["../../../../src/plugins/storage-memory/rx-storage-instance-memory.ts"],"sourcesContent":["import {\n Observable,\n Subject\n} from 'rxjs';\nimport {\n getStartIndexStringFromLowerBound,\n getStartIndexStringFromUpperBound\n} from '../../custom-index.ts';\nimport { getPrimaryFieldOfPrimaryKey } from '../../rx-schema-helper.ts';\nimport {\n categorizeBulkWriteRows\n} from '../../rx-storage-helper.ts';\nimport type {\n BulkWriteRow,\n CategorizeBulkWriteRowsOutput,\n EventBulk,\n PreparedQuery,\n QueryMatcher,\n RxConflictResultionTask,\n RxConflictResultionTaskSolution,\n RxDocumentData,\n RxJsonSchema,\n RxStorageBulkWriteResponse,\n RxStorageChangeEvent,\n RxStorageCountResult,\n RxStorageDefaultCheckpoint,\n RxStorageInstance,\n RxStorageInstanceCreationParams,\n RxStorageQueryResult,\n StringKeys\n} from '../../types/index.d.ts';\nimport {\n deepEqual,\n ensureNotFalsy,\n now,\n PROMISE_RESOLVE_TRUE,\n PROMISE_RESOLVE_VOID,\n randomCouchString,\n requestIdlePromiseNoQueue\n} from '../../plugins/utils/index.ts';\nimport {\n boundGE,\n boundGT,\n boundLE,\n boundLT\n} from './binary-search-bounds.ts';\nimport {\n attachmentMapKey,\n compareDocsWithIndex,\n ensureNotRemoved,\n getMemoryCollectionKey,\n putWriteRowToState,\n removeDocFromState\n} from './memory-helper.ts';\nimport {\n addIndexesToInternalsState,\n getMemoryIndexName\n} from './memory-indexes.ts';\nimport type {\n MemoryStorageInternals,\n RxStorageMemory,\n RxStorageMemoryInstanceCreationOptions,\n RxStorageMemorySettings\n} from './memory-types.ts';\nimport { getQueryMatcher, getSortComparator } from '../../rx-query-helper.ts';\n\n/**\n * Used in tests to ensure everything\n * is closed correctly\n */\nexport const OPEN_MEMORY_INSTANCES = new Set>();\n\nexport class RxStorageInstanceMemory implements RxStorageInstance<\n RxDocType,\n MemoryStorageInternals,\n RxStorageMemoryInstanceCreationOptions,\n RxStorageDefaultCheckpoint\n> {\n\n public readonly primaryPath: StringKeys>;\n public closed = false;\n\n /**\n * Used by some plugins and storage wrappers\n * to find out details about the internals of a write operation.\n * For example if you want to know which documents really have been replaced\n * or newly inserted.\n */\n public categorizedByWriteInput = new WeakMap[], CategorizeBulkWriteRowsOutput>();\n\n constructor(\n public readonly storage: RxStorageMemory,\n public readonly databaseName: string,\n public readonly collectionName: string,\n public readonly schema: Readonly>>,\n public readonly internals: MemoryStorageInternals,\n public readonly options: Readonly,\n public readonly settings: RxStorageMemorySettings\n ) {\n OPEN_MEMORY_INSTANCES.add(this);\n this.primaryPath = getPrimaryFieldOfPrimaryKey(this.schema.primaryKey);\n }\n\n bulkWrite(\n documentWrites: BulkWriteRow[],\n context: string\n ): Promise> {\n this.ensurePersistence();\n ensureNotRemoved(this);\n const internals = this.internals;\n const documentsById = this.internals.documents;\n const primaryPath = this.primaryPath;\n\n const categorized = categorizeBulkWriteRows(\n this,\n primaryPath as any,\n documentsById,\n documentWrites,\n context\n );\n const error = categorized.errors;\n const success: RxDocumentData[] = new Array(categorized.bulkInsertDocs.length);\n const bulkInsertDocs = categorized.bulkInsertDocs;\n for (let i = 0; i < bulkInsertDocs.length; ++i) {\n const writeRow = bulkInsertDocs[i];\n const doc = writeRow.document;\n success[i] = doc;\n }\n const bulkUpdateDocs = categorized.bulkUpdateDocs;\n for (let i = 0; i < bulkUpdateDocs.length; ++i) {\n const writeRow = bulkUpdateDocs[i];\n const doc = writeRow.document;\n success.push(doc);\n }\n\n this.categorizedByWriteInput.set(documentWrites, categorized);\n this.internals.ensurePersistenceTask = categorized;\n if (!this.internals.ensurePersistenceIdlePromise) {\n this.internals.ensurePersistenceIdlePromise = requestIdlePromiseNoQueue().then(() => {\n this.internals.ensurePersistenceIdlePromise = undefined;\n this.ensurePersistence();\n });\n }\n\n /**\n * Important: The events must be emitted AFTER the persistence\n * task has been added.\n */\n if (categorized.eventBulk.events.length > 0) {\n const lastState = ensureNotFalsy(categorized.newestRow).document;\n categorized.eventBulk.checkpoint = {\n id: lastState[primaryPath],\n lwt: lastState._meta.lwt\n };\n categorized.eventBulk.endTime = now();\n PROMISE_RESOLVE_TRUE.then(() => {\n internals.changes$.next(categorized.eventBulk);\n });\n }\n\n const ret = Promise.resolve({ success, error });\n return ret;\n }\n\n /**\n * Instead of directly inserting the documents into all indexes,\n * we do it lazy in the background. This gives the application time\n * to directly work with the write-result and to do stuff like rendering DOM\n * notes and processing RxDB queries.\n * Then in some later time, or just before the next read/write,\n * it is ensured that the indexes have been written.\n */\n public ensurePersistence() {\n if (\n !this.internals.ensurePersistenceTask\n ) {\n return;\n }\n const internals = this.internals;\n const documentsById = this.internals.documents;\n const primaryPath = this.primaryPath;\n\n const categorized = this.internals.ensurePersistenceTask;\n this.internals.ensurePersistenceTask = undefined;\n\n /**\n * Do inserts/updates\n */\n const stateByIndex = Object.values(this.internals.byIndex);\n\n const bulkInsertDocs = categorized.bulkInsertDocs;\n for (let i = 0; i < bulkInsertDocs.length; ++i) {\n const writeRow = bulkInsertDocs[i];\n const doc = writeRow.document;\n const docId = doc[primaryPath];\n putWriteRowToState(\n docId as any,\n internals,\n stateByIndex,\n writeRow,\n undefined\n );\n }\n\n const bulkUpdateDocs = categorized.bulkUpdateDocs;\n for (let i = 0; i < bulkUpdateDocs.length; ++i) {\n const writeRow = bulkUpdateDocs[i];\n const doc = writeRow.document;\n const docId = doc[primaryPath];\n putWriteRowToState(\n docId as any,\n internals,\n stateByIndex,\n writeRow,\n documentsById.get(docId as any)\n );\n }\n\n /**\n * Handle attachments\n */\n if (this.schema.attachments) {\n const attachmentsMap = internals.attachments;\n categorized.attachmentsAdd.forEach(attachment => {\n attachmentsMap.set(\n attachmentMapKey(attachment.documentId, attachment.attachmentId),\n {\n writeData: attachment.attachmentData,\n digest: attachment.digest\n }\n );\n });\n if (this.schema.attachments) {\n categorized.attachmentsUpdate.forEach(attachment => {\n attachmentsMap.set(\n attachmentMapKey(attachment.documentId, attachment.attachmentId),\n {\n writeData: attachment.attachmentData,\n digest: attachment.digest\n }\n );\n });\n categorized.attachmentsRemove.forEach(attachment => {\n attachmentsMap.delete(\n attachmentMapKey(attachment.documentId, attachment.attachmentId)\n );\n });\n }\n }\n }\n\n findDocumentsById(\n docIds: string[],\n withDeleted: boolean\n ): Promise[]> {\n this.ensurePersistence();\n const documentsById = this.internals.documents;\n const ret: RxDocumentData[] = [];\n if (documentsById.size === 0) {\n return Promise.resolve(ret);\n }\n for (let i = 0; i < docIds.length; ++i) {\n const docId = docIds[i];\n const docInDb = documentsById.get(docId);\n if (\n docInDb &&\n (\n !docInDb._deleted ||\n withDeleted\n )\n ) {\n ret.push(docInDb);\n }\n }\n return Promise.resolve(ret);\n }\n\n query(\n preparedQuery: PreparedQuery\n ): Promise> {\n this.ensurePersistence();\n\n const queryPlan = preparedQuery.queryPlan;\n const query = preparedQuery.query;\n\n const skip = query.skip ? query.skip : 0;\n const limit = query.limit ? query.limit : Infinity;\n const skipPlusLimit = skip + limit;\n\n let queryMatcher: QueryMatcher> | false = false;\n if (!queryPlan.selectorSatisfiedByIndex) {\n queryMatcher = getQueryMatcher(\n this.schema,\n preparedQuery.query\n );\n }\n\n const queryPlanFields: string[] = queryPlan.index;\n const mustManuallyResort = !queryPlan.sortSatisfiedByIndex;\n const index: string[] | undefined = queryPlanFields;\n const lowerBound: any[] = queryPlan.startKeys;\n const lowerBoundString = getStartIndexStringFromLowerBound(\n this.schema,\n index,\n lowerBound\n );\n\n let upperBound: any[] = queryPlan.endKeys;\n upperBound = upperBound;\n const upperBoundString = getStartIndexStringFromUpperBound(\n this.schema,\n index,\n upperBound\n );\n const indexName = getMemoryIndexName(index);\n\n if (!this.internals.byIndex[indexName]) {\n throw new Error('index does not exist ' + indexName);\n }\n const docsWithIndex = this.internals.byIndex[indexName].docsWithIndex;\n\n\n\n let indexOfLower = (queryPlan.inclusiveStart ? boundGE : boundGT)(\n docsWithIndex,\n {\n indexString: lowerBoundString\n } as any,\n compareDocsWithIndex\n );\n\n const indexOfUpper = (queryPlan.inclusiveEnd ? boundLE : boundLT)(\n docsWithIndex,\n {\n indexString: upperBoundString\n } as any,\n compareDocsWithIndex\n );\n\n let rows: RxDocumentData[] = [];\n let done = false;\n while (!done) {\n const currentRow = docsWithIndex[indexOfLower];\n if (\n !currentRow ||\n indexOfLower > indexOfUpper\n ) {\n break;\n }\n const currentDoc = currentRow.doc;\n\n if (!queryMatcher || queryMatcher(currentDoc)) {\n rows.push(currentDoc);\n }\n\n if (\n (rows.length >= skipPlusLimit && !mustManuallyResort)\n ) {\n done = true;\n }\n\n indexOfLower++;\n }\n\n if (mustManuallyResort) {\n const sortComparator = getSortComparator(this.schema, preparedQuery.query);\n rows = rows.sort(sortComparator);\n }\n\n // apply skip and limit boundaries.\n rows = rows.slice(skip, skipPlusLimit);\n return Promise.resolve({\n documents: rows\n });\n }\n\n async count(\n preparedQuery: PreparedQuery\n ): Promise {\n this.ensurePersistence();\n const result = await this.query(preparedQuery);\n return {\n count: result.documents.length,\n mode: 'fast'\n };\n }\n\n cleanup(minimumDeletedTime: number): Promise {\n this.ensurePersistence();\n const maxDeletionTime = now() - minimumDeletedTime;\n const index = ['_deleted', '_meta.lwt', this.primaryPath as any];\n const indexName = getMemoryIndexName(index);\n const docsWithIndex = this.internals.byIndex[indexName].docsWithIndex;\n\n const lowerBoundString = getStartIndexStringFromLowerBound(\n this.schema,\n index,\n [\n true,\n 0,\n ''\n ]\n );\n\n let indexOfLower = boundGT(\n docsWithIndex,\n {\n indexString: lowerBoundString\n } as any,\n compareDocsWithIndex\n );\n\n let done = false;\n while (!done) {\n const currentDoc = docsWithIndex[indexOfLower];\n if (!currentDoc || currentDoc.doc._meta.lwt > maxDeletionTime) {\n done = true;\n } else {\n removeDocFromState(\n this.primaryPath as any,\n this.schema,\n this.internals,\n currentDoc.doc\n );\n indexOfLower++;\n }\n }\n return PROMISE_RESOLVE_TRUE;\n }\n\n getAttachmentData(\n documentId: string,\n attachmentId: string,\n digest: string\n ): Promise {\n this.ensurePersistence();\n ensureNotRemoved(this);\n const key = attachmentMapKey(documentId, attachmentId);\n const data = this.internals.attachments.get(key);\n\n if (\n !digest ||\n !data ||\n data.digest !== digest\n ) {\n throw new Error('attachment does not exist: ' + key);\n }\n return Promise.resolve(data.writeData.data);\n }\n\n changeStream(): Observable>, RxStorageDefaultCheckpoint>> {\n ensureNotRemoved(this);\n return this.internals.changes$.asObservable();\n }\n\n async remove(): Promise {\n if (this.closed) {\n throw new Error('closed');\n }\n this.ensurePersistence();\n ensureNotRemoved(this);\n\n this.internals.removed = true;\n this.storage.collectionStates.delete(\n getMemoryCollectionKey(\n this.databaseName,\n this.collectionName,\n this.schema.version\n )\n );\n await this.close();\n }\n\n close(): Promise {\n OPEN_MEMORY_INSTANCES.delete(this);\n\n this.ensurePersistence();\n if (this.closed) {\n return PROMISE_RESOLVE_VOID;\n }\n this.closed = true;\n\n this.internals.refCount = this.internals.refCount - 1;\n return PROMISE_RESOLVE_VOID;\n }\n\n conflictResultionTasks(): Observable> {\n return this.internals.conflictResultionTasks$.asObservable();\n }\n resolveConflictResultionTask(_taskSolution: RxConflictResultionTaskSolution): Promise {\n return PROMISE_RESOLVE_VOID;\n }\n}\n\nexport function createMemoryStorageInstance(\n storage: RxStorageMemory,\n params: RxStorageInstanceCreationParams,\n settings: RxStorageMemorySettings\n): Promise> {\n const collectionKey = getMemoryCollectionKey(\n params.databaseName,\n params.collectionName,\n params.schema.version\n );\n\n let internals = storage.collectionStates.get(collectionKey);\n if (!internals) {\n internals = {\n id: randomCouchString(5),\n schema: params.schema,\n removed: false,\n refCount: 1,\n documents: new Map(),\n attachments: params.schema.attachments ? new Map() : undefined as any,\n byIndex: {},\n conflictResultionTasks$: new Subject(),\n changes$: new Subject()\n };\n addIndexesToInternalsState(internals, params.schema);\n storage.collectionStates.set(collectionKey, internals);\n } else {\n /**\n * Ensure that the storage was not already\n * created with a different schema.\n * This is very important because if this check\n * does not exist here, we have hard-to-debug problems\n * downstream.\n */\n if (\n params.devMode &&\n !deepEqual(internals.schema, params.schema)\n ) {\n throw new Error('storage was already created with a different schema');\n }\n internals.refCount = internals.refCount + 1;\n }\n\n const instance = new RxStorageInstanceMemory(\n storage,\n params.databaseName,\n params.collectionName,\n params.schema,\n internals,\n params.options,\n settings\n );\n return Promise.resolve(instance);\n}\n"],"mappings":"AAAA,SAEIA,OAAO,QACJ,MAAM;AACb,SACIC,iCAAiC,EACjCC,iCAAiC,QAC9B,uBAAuB;AAC9B,SAASC,2BAA2B,QAAQ,2BAA2B;AACvE,SACIC,uBAAuB,QACpB,4BAA4B;AAoBnC,SACIC,SAAS,EACTC,cAAc,EACdC,GAAG,EACHC,oBAAoB,EACpBC,oBAAoB,EACpBC,iBAAiB,EACjBC,yBAAyB,QACtB,8BAA8B;AACrC,SACIC,OAAO,EACPC,OAAO,EACPC,OAAO,EACPC,OAAO,QACJ,2BAA2B;AAClC,SACIC,gBAAgB,EAChBC,oBAAoB,EACpBC,gBAAgB,EAChBC,sBAAsB,EACtBC,kBAAkB,EAClBC,kBAAkB,QACf,oBAAoB;AAC3B,SACIC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,GAAG,CAAC,CAAC;MACpB7E,WAAW,EAAE2E,MAAM,CAACnI,MAAM,CAACwD,WAAW,GAAG,IAAI6E,GAAG,CAAC,CAAC,GAAGlG,SAAgB;MACrEkB,OAAO,EAAE,CAAC,CAAC;MACX0E,uBAAuB,EAAE,IAAI/J,OAAO,CAAC,CAAC;MACtC6E,QAAQ,EAAE,IAAI7E,OAAO,CAAC;IAC1B,CAAC;IACDsB,0BAA0B,CAACW,SAAS,EAAEkI,MAAM,CAACnI,MAAM,CAAC;IACpDH,OAAO,CAAC6H,gBAAgB,CAAC3F,GAAG,CAACqG,aAAa,EAAEnI,SAAS,CAAC;EAC1D,CAAC,MAAM;IACH;AACR;AACA;AACA;AACA;AACA;AACA;IACQ,IACIkI,MAAM,CAACG,OAAO,IACd,CAACjK,SAAS,CAAC4B,SAAS,CAACD,MAAM,EAAEmI,MAAM,CAACnI,MAAM,CAAC,EAC7C;MACE,MAAM,IAAI+F,KAAK,CAAC,qDAAqD,CAAC;IAC1E;IACA9F,SAAS,CAAC4H,QAAQ,GAAG5H,SAAS,CAAC4H,QAAQ,GAAG,CAAC;EAC/C;EAEA,IAAMU,QAAQ,GAAG,IAAI3I,uBAAuB,CACxCC,OAAO,EACPsI,MAAM,CAACrI,YAAY,EACnBqI,MAAM,CAACpI,cAAc,EACrBoI,MAAM,CAACnI,MAAM,EACbC,SAAS,EACTkI,MAAM,CAACjI,OAAO,EACdC,QACJ,CAAC;EACD,OAAO6C,OAAO,CAACC,OAAO,CAACsF,QAAQ,CAAC;AACpC","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 e3f720d022e..3c2d951e6aa 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.18.1'; +export var RXDB_VERSION = '15.18.2'; //# 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 bedb123a122..b503e218207 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.18.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.18.2';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,IAAMA,YAAY,GAAG,SAAS","ignoreList":[]} \ No newline at end of file diff --git a/dist/esm/rx-storage-helper.js.map b/dist/esm/rx-storage-helper.js.map index 29e614c770f..da12aea8503 100644 --- a/dist/esm/rx-storage-helper.js.map +++ b/dist/esm/rx-storage-helper.js.map @@ -1 +1 @@ -{"version":3,"file":"rx-storage-helper.js","names":["overwritable","newRxError","fillPrimaryKey","getPrimaryFieldOfPrimaryKey","PROMISE_RESOLVE_TRUE","RXDB_VERSION","RX_META_LWT_MINIMUM","appendToArray","createRevision","ensureNotFalsy","flatClone","getDefaultRevision","getDefaultRxDocumentMeta","lastOfArray","now","promiseWait","randomCouchString","filter","map","startWith","switchMap","prepareQuery","normalizeMangoQuery","INTERNAL_STORAGE_NAME","RX_DATABASE_LOCAL_DOCS_STORAGE_NAME","getSingleDocument","storageInstance","documentId","results","findDocumentsById","doc","undefined","writeSingle","instance","writeRow","context","writeResult","bulkWrite","error","length","ret","success","observeSingle","firstFindPromise","changeStream","pipe","evBulk","events","find","ev","Promise","resolve","documentData","v","stackCheckpoints","checkpoints","Object","assign","storageChangeEventToRxChangeEvent","isLocal","rxStorageChangeEvent","rxCollection","previousDocumentData","collectionName","name","operation","deepFreezeWhenDevMode","throwIfIsStorageWriteError","collection","writeData","status","id","writeError","data","categorizeBulkWriteRows","primaryPath","docsInDb","bulkWriteRows","onInsert","onUpdate","hasAttachments","schema","attachments","bulkInsertDocs","bulkUpdateDocs","errors","eventBulkId","eventBulk","checkpoint","startTime","endTime","eventBulkEvents","attachmentsAdd","attachmentsRemove","attachmentsUpdate","hasDocsInDb","size","newestRow","rowAmount","_loop","rowId","document","previous","docId","documentDeleted","_deleted","previousDeleted","documentInDb","get","attachmentError","insertedIsDeleted","entries","_attachments","forEach","attachmentId","attachmentData","isError","push","digest","stripAttachmentsDataFromRow","event","stripAttachmentsDataFromDocument","revInDb","_rev","err","updatedRow","keys","previousAttachmentData","newDigest","eventDocumentData","previousEventDocumentData","args","getAttachmentSize","attachmentBase64String","atob","attachmentWriteDataToNormalData","type","useDoc","flatCloneDocWithMeta","_meta","getWrappedStorageInstance","database","rxJsonSchema","primaryKey","transformDocumentDataFromRxDBToRxStorage","isDevMode","structuredClone","JSON","parse","stringify","metaFieldName","prototype","hasOwnProperty","call","dataBefore","dataAfter","lwt","token","originalStorageInstance","internals","databaseName","options","rows","toStorageWriteRows","row","lockedRun","then","useWriteResult","slice","reInsertErrors","reInserts","subResult","query","preparedQuery","count","ids","deleted","getAttachmentData","getChangedDocumentsSince","limit","cleanup","minDeletedTime","remove","storageInstances","delete","close","conflictResultionTasks","resolveConflictResultionTask","taskSolution","output","isEqual","add","ensureRxStorageInstanceParamsAreCorrect","params","keyCompression","hasEncryption","compression","jsonSchema","encrypted","getChangedDocumentsSinceQuery","sinceLwt","sinceId","selector","$or","$gt","$eq","$gte","sort","skip","result","documents","lastDoc","randomDelayStorage","input","retStorage","storage","rxdbVersion","createStorageInstance","delayTimeBefore","delayTimeAfter","writeQueue","a","b","response","c"],"sources":["../../src/rx-storage-helper.ts"],"sourcesContent":["/**\n * Helper functions for accessing the RxStorage instances.\n */\n\nimport { overwritable } from './overwritable.ts';\nimport { newRxError } from './rx-error.ts';\nimport {\n fillPrimaryKey,\n getPrimaryFieldOfPrimaryKey\n} from './rx-schema-helper.ts';\nimport type {\n BulkWriteRow,\n BulkWriteRowProcessed,\n CategorizeBulkWriteRowsOutput,\n EventBulk,\n RxAttachmentData,\n RxAttachmentWriteData,\n RxChangeEvent,\n RxCollection,\n RxDatabase,\n RxDocumentData,\n RxDocumentWriteData,\n RxJsonSchema,\n RxStorageWriteError,\n RxStorageChangeEvent,\n RxStorageInstance,\n RxStorageInstanceCreationParams,\n StringKeys,\n RxStorageWriteErrorConflict,\n RxStorageWriteErrorAttachment,\n RxStorage,\n RxStorageDefaultCheckpoint,\n FilledMangoQuery\n} from './types/index.d.ts';\nimport {\n PROMISE_RESOLVE_TRUE,\n RXDB_VERSION,\n RX_META_LWT_MINIMUM,\n appendToArray,\n createRevision,\n ensureNotFalsy,\n flatClone,\n getDefaultRevision,\n getDefaultRxDocumentMeta,\n lastOfArray,\n now,\n promiseWait,\n randomCouchString\n} from './plugins/utils/index.ts';\nimport { Observable, filter, map, startWith, switchMap } from 'rxjs';\nimport { prepareQuery } from './rx-query.ts';\nimport { normalizeMangoQuery } from './rx-query-helper.ts';\n\nexport const INTERNAL_STORAGE_NAME = '_rxdb_internal';\nexport const RX_DATABASE_LOCAL_DOCS_STORAGE_NAME = 'rxdatabase_storage_local';\n\nexport async function getSingleDocument(\n storageInstance: RxStorageInstance,\n documentId: string\n): Promise | undefined> {\n const results = await storageInstance.findDocumentsById([documentId], false);\n const doc = results[0];\n if (doc) {\n return doc;\n } else {\n return undefined;\n }\n}\n\n/**\n * Writes a single document,\n * throws RxStorageBulkWriteError on failure\n */\nexport async function writeSingle(\n instance: RxStorageInstance,\n writeRow: BulkWriteRow,\n context: string\n): Promise> {\n const writeResult = await instance.bulkWrite(\n [writeRow],\n context\n );\n if (writeResult.error.length > 0) {\n const error = writeResult.error[0];\n throw error;\n } else {\n const ret = writeResult.success[0];\n return ret;\n }\n}\n\n/**\n * Observe the plain document data of a single document.\n * Do not forget to unsubscribe.\n */\nexport function observeSingle(\n storageInstance: RxStorageInstance,\n documentId: string\n): Observable> {\n const firstFindPromise = getSingleDocument(storageInstance, documentId);\n const ret = storageInstance\n .changeStream()\n .pipe(\n map(evBulk => evBulk.events.find(ev => ev.documentId === documentId)),\n filter(ev => !!ev),\n map(ev => Promise.resolve(ensureNotFalsy(ev).documentData)),\n startWith(firstFindPromise),\n switchMap(v => v),\n filter(v => !!v)\n ) as any;\n return ret;\n}\n\n\n/**\n * Checkpoints must be stackable over another.\n * This is required form some RxStorage implementations\n * like the sharding plugin, where a checkpoint only represents\n * the document state from some, but not all shards.\n */\nexport function stackCheckpoints(\n checkpoints: CheckpointType[]\n): CheckpointType {\n return Object.assign(\n {},\n ...checkpoints\n );\n}\n\nexport function storageChangeEventToRxChangeEvent(\n isLocal: boolean,\n rxStorageChangeEvent: RxStorageChangeEvent,\n rxCollection?: RxCollection,\n): RxChangeEvent {\n const documentData = rxStorageChangeEvent.documentData;\n const previousDocumentData = rxStorageChangeEvent.previousDocumentData;\n const ret: RxChangeEvent = {\n documentId: rxStorageChangeEvent.documentId,\n collectionName: rxCollection ? rxCollection.name : undefined,\n isLocal,\n operation: rxStorageChangeEvent.operation,\n documentData: overwritable.deepFreezeWhenDevMode(documentData as any),\n previousDocumentData: overwritable.deepFreezeWhenDevMode(previousDocumentData as any)\n };\n return ret;\n}\n\nexport function throwIfIsStorageWriteError(\n collection: RxCollection,\n documentId: string,\n writeData: RxDocumentWriteData | RxDocType,\n error: RxStorageWriteError | undefined\n) {\n if (error) {\n if (error.status === 409) {\n throw newRxError('CONFLICT', {\n collection: collection.name,\n id: documentId,\n writeError: error,\n data: writeData\n });\n } else if (error.status === 422) {\n throw newRxError('VD2', {\n collection: collection.name,\n id: documentId,\n writeError: error,\n data: writeData\n });\n } else {\n throw error;\n }\n }\n}\n\n\n/**\n * Analyzes a list of BulkWriteRows and determines\n * which documents must be inserted, updated or deleted\n * and which events must be emitted and which documents cause a conflict\n * and must not be written.\n * Used as helper inside of some RxStorage implementations.\n * @hotPath The performance of this function is critical\n */\nexport function categorizeBulkWriteRows(\n storageInstance: RxStorageInstance,\n primaryPath: StringKeys,\n /**\n * Current state of the documents\n * inside of the storage. Used to determine\n * which writes cause conflicts.\n * This must be a Map for better performance.\n */\n docsInDb: Map[StringKeys] | string, RxDocumentData>,\n /**\n * The write rows that are passed to\n * RxStorageInstance().bulkWrite().\n */\n bulkWriteRows: BulkWriteRow[],\n context: string,\n /**\n * Used by some storages for better performance.\n * For example when get-by-id and insert/update can run in parallel.\n */\n onInsert?: (docData: RxDocumentData) => void,\n onUpdate?: (docData: RxDocumentData) => void\n): CategorizeBulkWriteRowsOutput {\n const hasAttachments = !!storageInstance.schema.attachments;\n const bulkInsertDocs: BulkWriteRowProcessed[] = [];\n const bulkUpdateDocs: BulkWriteRowProcessed[] = [];\n const errors: RxStorageWriteError[] = [];\n const eventBulkId = randomCouchString(10);\n const eventBulk: EventBulk>, any> = {\n id: eventBulkId,\n events: [],\n checkpoint: null,\n context,\n startTime: now(),\n endTime: 0\n };\n const eventBulkEvents = eventBulk.events;\n\n const attachmentsAdd: {\n documentId: string;\n attachmentId: string;\n attachmentData: RxAttachmentWriteData;\n digest: string;\n }[] = [];\n const attachmentsRemove: {\n documentId: string;\n attachmentId: string;\n digest: string;\n }[] = [];\n const attachmentsUpdate: {\n documentId: string;\n attachmentId: string;\n attachmentData: RxAttachmentWriteData;\n digest: string;\n }[] = [];\n\n const hasDocsInDb = docsInDb.size > 0;\n let newestRow: BulkWriteRowProcessed | undefined;\n\n /**\n * @performance is really important in this loop!\n */\n const rowAmount = bulkWriteRows.length;\n for (let rowId = 0; rowId < rowAmount; rowId++) {\n const writeRow = bulkWriteRows[rowId];\n\n // use these variables to have less property accesses\n const document = writeRow.document;\n const previous = writeRow.previous;\n const docId = document[primaryPath] as string;\n const documentDeleted = document._deleted;\n const previousDeleted = previous && previous._deleted;\n\n let documentInDb: RxDocumentData | undefined = undefined as any;\n if (hasDocsInDb) {\n documentInDb = docsInDb.get(docId);\n }\n let attachmentError: RxStorageWriteErrorAttachment | undefined;\n\n if (!documentInDb) {\n /**\n * It is possible to insert already deleted documents,\n * this can happen on replication.\n */\n const insertedIsDeleted = documentDeleted ? true : false;\n if (hasAttachments) {\n Object\n .entries(document._attachments)\n .forEach(([attachmentId, attachmentData]) => {\n if (\n !(attachmentData as RxAttachmentWriteData).data\n ) {\n attachmentError = {\n documentId: docId,\n isError: true,\n status: 510,\n writeRow,\n attachmentId\n };\n errors.push(attachmentError);\n } else {\n attachmentsAdd.push({\n documentId: docId,\n attachmentId,\n attachmentData: attachmentData as any,\n digest: attachmentData.digest\n });\n }\n });\n }\n if (!attachmentError) {\n if (hasAttachments) {\n bulkInsertDocs.push(stripAttachmentsDataFromRow(writeRow));\n if (onInsert) {\n onInsert(document);\n }\n } else {\n bulkInsertDocs.push(writeRow as any);\n if (onInsert) {\n onInsert(document);\n }\n }\n\n newestRow = writeRow as any;\n }\n\n if (!insertedIsDeleted) {\n const event = {\n documentId: docId,\n operation: 'INSERT' as const,\n documentData: hasAttachments ? stripAttachmentsDataFromDocument(document) : document as any,\n previousDocumentData: hasAttachments && previous ? stripAttachmentsDataFromDocument(previous) : previous as any\n };\n eventBulkEvents.push(event);\n }\n } else {\n // update existing document\n const revInDb: string = documentInDb._rev;\n\n /**\n * Check for conflict\n */\n if (\n (\n !previous\n ) ||\n (\n !!previous &&\n revInDb !== previous._rev\n )\n ) {\n // is conflict error\n const err: RxStorageWriteError = {\n isError: true,\n status: 409,\n documentId: docId,\n writeRow: writeRow,\n documentInDb\n };\n errors.push(err);\n continue;\n }\n\n // handle attachments data\n\n const updatedRow: BulkWriteRowProcessed = hasAttachments ? stripAttachmentsDataFromRow(writeRow) : writeRow as any;\n if (hasAttachments) {\n if (documentDeleted) {\n /**\n * Deleted documents must have cleared all their attachments.\n */\n if (previous) {\n Object\n .keys(previous._attachments)\n .forEach(attachmentId => {\n attachmentsRemove.push({\n documentId: docId,\n attachmentId,\n digest: ensureNotFalsy(previous)._attachments[attachmentId].digest\n });\n });\n }\n } else {\n // first check for errors\n Object\n .entries(document._attachments)\n .find(([attachmentId, attachmentData]) => {\n const previousAttachmentData = previous ? previous._attachments[attachmentId] : undefined;\n if (\n !previousAttachmentData &&\n !(attachmentData as RxAttachmentWriteData).data\n ) {\n attachmentError = {\n documentId: docId,\n documentInDb: documentInDb as any,\n isError: true,\n status: 510,\n writeRow,\n attachmentId\n };\n }\n return true;\n });\n if (!attachmentError) {\n Object\n .entries(document._attachments)\n .forEach(([attachmentId, attachmentData]) => {\n const previousAttachmentData = previous ? previous._attachments[attachmentId] : undefined;\n if (!previousAttachmentData) {\n attachmentsAdd.push({\n documentId: docId,\n attachmentId,\n attachmentData: attachmentData as any,\n digest: attachmentData.digest\n });\n } else {\n const newDigest = updatedRow.document._attachments[attachmentId].digest;\n if (\n (attachmentData as RxAttachmentWriteData).data &&\n /**\n * Performance shortcut,\n * do not update the attachment data if it did not change.\n */\n previousAttachmentData.digest !== newDigest\n ) {\n attachmentsUpdate.push({\n documentId: docId,\n attachmentId,\n attachmentData: attachmentData as RxAttachmentWriteData,\n digest: attachmentData.digest\n });\n }\n }\n });\n }\n }\n }\n\n if (attachmentError) {\n errors.push(attachmentError);\n } else {\n if (hasAttachments) {\n bulkUpdateDocs.push(stripAttachmentsDataFromRow(updatedRow));\n if (onUpdate) {\n onUpdate(document);\n }\n } else {\n bulkUpdateDocs.push(updatedRow);\n if (onUpdate) {\n onUpdate(document);\n }\n }\n newestRow = updatedRow as any;\n }\n\n let eventDocumentData: RxDocumentData | undefined = null as any;\n let previousEventDocumentData: RxDocumentData | undefined = null as any;\n let operation: 'INSERT' | 'UPDATE' | 'DELETE' = null as any;\n\n if (previousDeleted && !documentDeleted) {\n operation = 'INSERT';\n eventDocumentData = hasAttachments ? stripAttachmentsDataFromDocument(document) : document as any;\n } else if (previous && !previousDeleted && !documentDeleted) {\n operation = 'UPDATE';\n eventDocumentData = hasAttachments ? stripAttachmentsDataFromDocument(document) : document as any;\n previousEventDocumentData = previous;\n } else if (documentDeleted) {\n operation = 'DELETE';\n eventDocumentData = ensureNotFalsy(document) as any;\n previousEventDocumentData = previous;\n } else {\n throw newRxError('SNH', { args: { writeRow } });\n }\n\n const event = {\n documentId: docId,\n documentData: eventDocumentData as RxDocumentData,\n previousDocumentData: previousEventDocumentData,\n operation: operation\n };\n eventBulkEvents.push(event);\n }\n }\n\n return {\n bulkInsertDocs,\n bulkUpdateDocs,\n newestRow,\n errors,\n eventBulk,\n attachmentsAdd,\n attachmentsRemove,\n attachmentsUpdate\n };\n}\n\nexport function stripAttachmentsDataFromRow(writeRow: BulkWriteRow): BulkWriteRowProcessed {\n return {\n previous: writeRow.previous,\n document: stripAttachmentsDataFromDocument(writeRow.document)\n };\n}\n\nexport function getAttachmentSize(\n attachmentBase64String: string\n): number {\n return atob(attachmentBase64String).length;\n}\n\n/**\n * Used in custom RxStorage implementations.\n */\nexport function attachmentWriteDataToNormalData(writeData: RxAttachmentData | RxAttachmentWriteData): RxAttachmentData {\n const data = (writeData as RxAttachmentWriteData).data;\n if (!data) {\n return writeData as any;\n }\n const ret: RxAttachmentData = {\n length: getAttachmentSize(data),\n digest: writeData.digest,\n type: writeData.type\n };\n return ret;\n}\n\nexport function stripAttachmentsDataFromDocument(doc: RxDocumentWriteData): RxDocumentData {\n if (!doc._attachments || Object.keys(doc._attachments).length === 0) {\n return doc;\n }\n\n const useDoc: RxDocumentData = flatClone(doc) as any;\n useDoc._attachments = {};\n Object\n .entries(doc._attachments)\n .forEach(([attachmentId, attachmentData]) => {\n useDoc._attachments[attachmentId] = attachmentWriteDataToNormalData(attachmentData);\n });\n return useDoc;\n}\n\n/**\n * Flat clone the document data\n * and also the _meta field.\n * Used many times when we want to change the meta\n * during replication etc.\n */\nexport function flatCloneDocWithMeta(\n doc: RxDocumentData\n): RxDocumentData {\n const ret = flatClone(doc);\n ret._meta = flatClone(doc._meta);\n return ret;\n}\n\nexport type WrappedRxStorageInstance = RxStorageInstance & {\n originalStorageInstance: RxStorageInstance;\n};\n\n/**\n * Wraps the normal storageInstance of a RxCollection\n * to ensure that all access is properly using the hooks\n * and other data transformations and also ensure that database.lockedRun()\n * is used properly.\n */\nexport function getWrappedStorageInstance<\n RxDocType,\n Internals,\n InstanceCreationOptions,\n CheckpointType\n>(\n database: RxDatabase<{}, Internals, InstanceCreationOptions, any>,\n storageInstance: RxStorageInstance,\n /**\n * The original RxJsonSchema\n * before it was mutated by hooks.\n */\n rxJsonSchema: RxJsonSchema>\n): WrappedRxStorageInstance {\n overwritable.deepFreezeWhenDevMode(rxJsonSchema);\n const primaryPath = getPrimaryFieldOfPrimaryKey(rxJsonSchema.primaryKey);\n\n function transformDocumentDataFromRxDBToRxStorage(\n writeRow: BulkWriteRow\n ) {\n let data = flatClone(writeRow.document);\n data._meta = flatClone(data._meta);\n\n /**\n * Do some checks in dev-mode\n * that would be too performance expensive\n * in production.\n */\n if (overwritable.isDevMode()) {\n // ensure that the primary key has not been changed\n data = fillPrimaryKey(\n primaryPath,\n rxJsonSchema,\n data as any\n );\n\n\n /**\n * Ensure it can be structured cloned\n */\n try {\n /**\n * Notice that structuredClone() is not available\n * in ReactNative, so we test for JSON.stringify() instead\n * @link https://github.com/pubkey/rxdb/issues/5046#issuecomment-1827374498\n */\n if (typeof structuredClone === 'function') {\n structuredClone(writeRow);\n } else {\n JSON.parse(JSON.stringify(writeRow));\n }\n } catch (err) {\n throw newRxError('DOC24', {\n collection: storageInstance.collectionName,\n document: writeRow.document\n });\n }\n\n /**\n * Ensure that the new revision is higher\n * then the previous one\n */\n if (writeRow.previous) {\n // TODO run this in the dev-mode plugin\n // const prev = parseRevision(writeRow.previous._rev);\n // const current = parseRevision(writeRow.document._rev);\n // if (current.height <= prev.height) {\n // throw newRxError('SNH', {\n // dataBefore: writeRow.previous,\n // dataAfter: writeRow.document,\n // args: {\n // prev,\n // current\n // }\n // });\n // }\n }\n\n /**\n * Ensure that _meta fields have been merged\n * and not replaced.\n * This is important so that when one plugin A\n * sets a _meta field and another plugin B does a write\n * to the document, it must be ensured that the\n * field of plugin A was not removed.\n */\n if (writeRow.previous) {\n Object.keys(writeRow.previous._meta)\n .forEach(metaFieldName => {\n if (!Object.prototype.hasOwnProperty.call(writeRow.document._meta, metaFieldName)) {\n throw newRxError('SNH', {\n dataBefore: writeRow.previous,\n dataAfter: writeRow.document\n });\n }\n });\n }\n }\n data._meta.lwt = now();\n\n /**\n * Yes we really want to set the revision here.\n * If you make a plugin that relies on having its own revision\n * stored into the storage, use this.originalStorageInstance.bulkWrite() instead.\n */\n data._rev = createRevision(\n database.token,\n writeRow.previous\n );\n\n return {\n document: data,\n previous: writeRow.previous\n };\n }\n\n const ret: WrappedRxStorageInstance = {\n originalStorageInstance: storageInstance,\n schema: storageInstance.schema,\n internals: storageInstance.internals,\n collectionName: storageInstance.collectionName,\n databaseName: storageInstance.databaseName,\n options: storageInstance.options,\n bulkWrite(\n rows: BulkWriteRow[],\n context: string\n ) {\n const toStorageWriteRows: BulkWriteRow[] = rows\n .map(row => transformDocumentDataFromRxDBToRxStorage(row));\n\n return database.lockedRun(\n () => storageInstance.bulkWrite(\n toStorageWriteRows,\n context\n )\n )\n /**\n * The RxStorageInstance MUST NOT allow to insert already _deleted documents,\n * without sending the previous document version.\n * But for better developer experience, RxDB does allow to re-insert deleted documents.\n * We do this by automatically fixing the conflict errors for that case\n * by running another bulkWrite() and merging the results.\n * @link https://github.com/pubkey/rxdb/pull/3839\n */\n .then(writeResult => {\n const useWriteResult: typeof writeResult = {\n error: [],\n success: writeResult.success.slice(0)\n };\n const reInsertErrors: RxStorageWriteErrorConflict[] =\n writeResult.error\n .filter((error) => {\n if (\n error.status === 409 &&\n !error.writeRow.previous &&\n !error.writeRow.document._deleted &&\n ensureNotFalsy(error.documentInDb)._deleted\n ) {\n return true;\n }\n useWriteResult.error.push(error);\n return false;\n }) as any;\n if (reInsertErrors.length > 0) {\n const reInserts: BulkWriteRow[] = reInsertErrors\n .map((error) => {\n return {\n previous: error.documentInDb,\n document: Object.assign(\n {},\n error.writeRow.document,\n {\n _rev: createRevision(\n database.token,\n error.documentInDb\n )\n }\n )\n };\n });\n\n return database.lockedRun(\n () => storageInstance.bulkWrite(\n reInserts,\n context\n )\n ).then(subResult => {\n appendToArray(useWriteResult.error, subResult.error);\n appendToArray(useWriteResult.success, subResult.success);\n return useWriteResult;\n });\n }\n\n return writeResult;\n });\n },\n query(preparedQuery) {\n return database.lockedRun(\n () => storageInstance.query(preparedQuery)\n );\n },\n count(preparedQuery) {\n return database.lockedRun(\n () => storageInstance.count(preparedQuery)\n );\n },\n findDocumentsById(ids, deleted) {\n return database.lockedRun(\n () => storageInstance.findDocumentsById(ids, deleted)\n );\n },\n getAttachmentData(\n documentId: string,\n attachmentId: string,\n digest: string\n ) {\n return database.lockedRun(\n () => storageInstance.getAttachmentData(documentId, attachmentId, digest)\n );\n },\n getChangedDocumentsSince: !storageInstance.getChangedDocumentsSince ? undefined : (limit: number, checkpoint?: any) => {\n return database.lockedRun(\n () => ((storageInstance as any).getChangedDocumentsSince)(ensureNotFalsy(limit), checkpoint)\n );\n },\n cleanup(minDeletedTime: number) {\n return database.lockedRun(\n () => storageInstance.cleanup(minDeletedTime)\n );\n },\n remove() {\n database.storageInstances.delete(ret);\n return database.lockedRun(\n () => storageInstance.remove()\n );\n },\n close() {\n database.storageInstances.delete(ret);\n return database.lockedRun(\n () => storageInstance.close()\n );\n },\n changeStream() {\n return storageInstance.changeStream();\n },\n conflictResultionTasks() {\n return storageInstance.conflictResultionTasks();\n },\n resolveConflictResultionTask(taskSolution) {\n if (taskSolution.output.isEqual) {\n return storageInstance.resolveConflictResultionTask(taskSolution);\n }\n\n const doc = Object.assign(\n {},\n taskSolution.output.documentData,\n {\n _meta: getDefaultRxDocumentMeta(),\n _rev: getDefaultRevision(),\n _attachments: {}\n }\n );\n\n const documentData = flatClone(doc);\n delete (documentData as any)._meta;\n delete (documentData as any)._rev;\n delete (documentData as any)._attachments;\n\n return storageInstance.resolveConflictResultionTask({\n id: taskSolution.id,\n output: {\n isEqual: false,\n documentData\n }\n });\n }\n };\n\n database.storageInstances.add(ret);\n return ret;\n}\n\n/**\n * Each RxStorage implementation should\n * run this method at the first step of createStorageInstance()\n * to ensure that the configuration is correct.\n */\nexport function ensureRxStorageInstanceParamsAreCorrect(\n params: RxStorageInstanceCreationParams\n) {\n if (params.schema.keyCompression) {\n throw newRxError('UT5', { args: { params } });\n }\n if (hasEncryption(params.schema)) {\n throw newRxError('UT6', { args: { params } });\n }\n if (\n params.schema.attachments &&\n params.schema.attachments.compression\n ) {\n throw newRxError('UT7', { args: { params } });\n }\n}\n\nexport function hasEncryption(jsonSchema: RxJsonSchema): boolean {\n if (\n (!!jsonSchema.encrypted && jsonSchema.encrypted.length > 0) ||\n (jsonSchema.attachments && jsonSchema.attachments.encrypted)\n ) {\n return true;\n } else {\n return false;\n }\n}\n\nexport function getChangedDocumentsSinceQuery(\n storageInstance: RxStorageInstance,\n limit: number,\n checkpoint?: CheckpointType\n): FilledMangoQuery {\n const primaryPath = getPrimaryFieldOfPrimaryKey(storageInstance.schema.primaryKey);\n const sinceLwt = checkpoint ? (checkpoint as unknown as RxStorageDefaultCheckpoint).lwt : RX_META_LWT_MINIMUM;\n const sinceId = checkpoint ? (checkpoint as unknown as RxStorageDefaultCheckpoint).id : '';\n return normalizeMangoQuery(storageInstance.schema, {\n selector: {\n $or: [\n {\n '_meta.lwt': {\n $gt: sinceLwt\n }\n },\n {\n '_meta.lwt': {\n $eq: sinceLwt\n },\n [primaryPath]: {\n $gt: checkpoint ? sinceId : ''\n }\n }\n ],\n // add this hint for better index usage\n '_meta.lwt': {\n $gte: sinceLwt\n }\n } as any,\n sort: [\n { '_meta.lwt': 'asc' },\n { [primaryPath]: 'asc' }\n ] as any,\n skip: 0,\n limit,\n /**\n * DO NOT SET A SPECIFIC INDEX HERE!\n * The query might be modified by some plugin\n * before sending it to the storage.\n * We can be sure that in the end the query planner\n * will find the best index.\n */\n // index: ['_meta.lwt', primaryPath]\n });\n}\n\nexport async function getChangedDocumentsSince(\n storageInstance: RxStorageInstance,\n limit: number,\n checkpoint?: CheckpointType\n): Promise<{\n documents: RxDocumentData[];\n /**\n * The checkpoint contains data so that another\n * call to getChangedDocumentsSince() will continue\n * from exactly the last document that was returned before.\n */\n checkpoint: CheckpointType;\n}> {\n if (storageInstance.getChangedDocumentsSince) {\n return storageInstance.getChangedDocumentsSince(limit, checkpoint);\n }\n\n const primaryPath = getPrimaryFieldOfPrimaryKey(storageInstance.schema.primaryKey);\n const query = prepareQuery>(\n storageInstance.schema,\n getChangedDocumentsSinceQuery(\n storageInstance,\n limit,\n checkpoint\n )\n );\n\n const result = await storageInstance.query(query);\n const documents = result.documents;\n const lastDoc = lastOfArray(documents);\n\n return {\n documents: documents,\n checkpoint: lastDoc ? {\n id: (lastDoc as any)[primaryPath],\n lwt: lastDoc._meta.lwt\n } as any : checkpoint ? checkpoint : {\n id: '',\n lwt: 0\n }\n };\n}\n\n\n/**\n * Wraps the storage and simluates\n * delays. Mostly used in tests.\n */\nexport function randomDelayStorage(\n input: {\n storage: RxStorage;\n delayTimeBefore: () => number;\n delayTimeAfter: () => number;\n }\n): RxStorage {\n\n const retStorage: RxStorage = {\n name: 'random-delay-' + input.storage.name,\n rxdbVersion: RXDB_VERSION,\n async createStorageInstance(params) {\n await promiseWait(input.delayTimeBefore());\n const storageInstance = await input.storage.createStorageInstance(params);\n await promiseWait(input.delayTimeAfter());\n\n // write still must be processed in order\n let writeQueue: Promise = PROMISE_RESOLVE_TRUE;\n\n return {\n databaseName: storageInstance.databaseName,\n internals: storageInstance.internals,\n options: storageInstance.options,\n schema: storageInstance.schema,\n collectionName: storageInstance.collectionName,\n async bulkWrite(a, b) {\n writeQueue = writeQueue.then(async () => {\n await promiseWait(input.delayTimeBefore());\n const response = await storageInstance.bulkWrite(a, b);\n await promiseWait(input.delayTimeAfter());\n return response;\n });\n const ret = await writeQueue;\n return ret;\n },\n async findDocumentsById(a, b) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.findDocumentsById(a, b);\n await promiseWait(input.delayTimeAfter());\n return ret;\n },\n async query(a) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.query(a);\n return ret;\n },\n async count(a) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.count(a);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n async getAttachmentData(a, b, c) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.getAttachmentData(a, b, c);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n getChangedDocumentsSince: !storageInstance.getChangedDocumentsSince ? undefined : async (a, b) => {\n await promiseWait(input.delayTimeBefore());\n const ret = await ensureNotFalsy(storageInstance.getChangedDocumentsSince)(a, b);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n changeStream() {\n return storageInstance.changeStream();\n },\n conflictResultionTasks() {\n return storageInstance.conflictResultionTasks();\n },\n resolveConflictResultionTask(a) {\n return storageInstance.resolveConflictResultionTask(a);\n },\n async cleanup(a) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.cleanup(a);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n async close() {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.close();\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n async remove() {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.remove();\n await promiseWait(input.delayTimeAfter());\n return ret;\n },\n };\n\n\n }\n };\n return retStorage;\n}\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,YAAY,QAAQ,mBAAmB;AAChD,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAC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,GAAG,MAAMd,eAAe,CAAC0J,OAAO,CAACyC,CAAC,CAAC;UAC5C,MAAM9M,WAAW,CAACsM,KAAK,CAACM,cAAc,CAAC,CAAC,CAAC;UACzC,OAAOnL,GAAG;QAEd,CAAC;QACD,MAAMiJ,KAAKA,CAAA,EAAG;UACV,MAAM1K,WAAW,CAACsM,KAAK,CAACK,eAAe,CAAC,CAAC,CAAC;UAC1C,IAAMlL,GAAG,GAAG,MAAMd,eAAe,CAAC+J,KAAK,CAAC,CAAC;UACzC,MAAM1K,WAAW,CAACsM,KAAK,CAACM,cAAc,CAAC,CAAC,CAAC;UACzC,OAAOnL,GAAG;QAEd,CAAC;QACD,MAAM8I,MAAMA,CAAA,EAAG;UACX,MAAMvK,WAAW,CAACsM,KAAK,CAACK,eAAe,CAAC,CAAC,CAAC;UAC1C,IAAMlL,GAAG,GAAG,MAAMd,eAAe,CAAC4J,MAAM,CAAC,CAAC;UAC1C,MAAMvK,WAAW,CAACsM,KAAK,CAACM,cAAc,CAAC,CAAC,CAAC;UACzC,OAAOnL,GAAG;QACd;MACJ,CAAC;IAGL;EACJ,CAAC;EACD,OAAO8K,UAAU;AACrB","ignoreList":[]} \ No newline at end of file +{"version":3,"file":"rx-storage-helper.js","names":["overwritable","newRxError","fillPrimaryKey","getPrimaryFieldOfPrimaryKey","PROMISE_RESOLVE_TRUE","RXDB_VERSION","RX_META_LWT_MINIMUM","appendToArray","createRevision","ensureNotFalsy","flatClone","getDefaultRevision","getDefaultRxDocumentMeta","lastOfArray","now","promiseWait","randomCouchString","filter","map","startWith","switchMap","prepareQuery","normalizeMangoQuery","INTERNAL_STORAGE_NAME","RX_DATABASE_LOCAL_DOCS_STORAGE_NAME","getSingleDocument","storageInstance","documentId","results","findDocumentsById","doc","undefined","writeSingle","instance","writeRow","context","writeResult","bulkWrite","error","length","ret","success","observeSingle","firstFindPromise","changeStream","pipe","evBulk","events","find","ev","Promise","resolve","documentData","v","stackCheckpoints","checkpoints","Object","assign","storageChangeEventToRxChangeEvent","isLocal","rxStorageChangeEvent","rxCollection","previousDocumentData","collectionName","name","operation","deepFreezeWhenDevMode","throwIfIsStorageWriteError","collection","writeData","status","id","writeError","data","categorizeBulkWriteRows","primaryPath","docsInDb","bulkWriteRows","onInsert","onUpdate","hasAttachments","schema","attachments","bulkInsertDocs","bulkUpdateDocs","errors","eventBulkId","eventBulk","checkpoint","startTime","endTime","eventBulkEvents","attachmentsAdd","attachmentsRemove","attachmentsUpdate","hasDocsInDb","size","newestRow","rowAmount","_loop","rowId","document","previous","docId","documentDeleted","_deleted","previousDeleted","documentInDb","get","attachmentError","insertedIsDeleted","entries","_attachments","forEach","attachmentId","attachmentData","isError","push","digest","stripAttachmentsDataFromRow","event","stripAttachmentsDataFromDocument","revInDb","_rev","err","updatedRow","keys","previousAttachmentData","newDigest","eventDocumentData","previousEventDocumentData","args","getAttachmentSize","attachmentBase64String","atob","attachmentWriteDataToNormalData","type","useDoc","flatCloneDocWithMeta","_meta","getWrappedStorageInstance","database","rxJsonSchema","primaryKey","transformDocumentDataFromRxDBToRxStorage","isDevMode","structuredClone","JSON","parse","stringify","metaFieldName","prototype","hasOwnProperty","call","dataBefore","dataAfter","lwt","token","originalStorageInstance","internals","databaseName","options","rows","toStorageWriteRows","row","lockedRun","then","useWriteResult","slice","reInsertErrors","reInserts","subResult","query","preparedQuery","count","ids","deleted","getAttachmentData","getChangedDocumentsSince","limit","cleanup","minDeletedTime","remove","storageInstances","delete","close","conflictResultionTasks","resolveConflictResultionTask","taskSolution","output","isEqual","add","ensureRxStorageInstanceParamsAreCorrect","params","keyCompression","hasEncryption","compression","jsonSchema","encrypted","getChangedDocumentsSinceQuery","sinceLwt","sinceId","selector","$or","$gt","$eq","$gte","sort","skip","result","documents","lastDoc","randomDelayStorage","input","retStorage","storage","rxdbVersion","createStorageInstance","delayTimeBefore","delayTimeAfter","writeQueue","a","b","response","c"],"sources":["../../src/rx-storage-helper.ts"],"sourcesContent":["/**\n * Helper functions for accessing the RxStorage instances.\n */\n\nimport { overwritable } from './overwritable.ts';\nimport { newRxError } from './rx-error.ts';\nimport {\n fillPrimaryKey,\n getPrimaryFieldOfPrimaryKey\n} from './rx-schema-helper.ts';\nimport type {\n BulkWriteRow,\n BulkWriteRowProcessed,\n CategorizeBulkWriteRowsOutput,\n EventBulk,\n RxAttachmentData,\n RxAttachmentWriteData,\n RxChangeEvent,\n RxCollection,\n RxDatabase,\n RxDocumentData,\n RxDocumentWriteData,\n RxJsonSchema,\n RxStorageWriteError,\n RxStorageChangeEvent,\n RxStorageInstance,\n RxStorageInstanceCreationParams,\n StringKeys,\n RxStorageWriteErrorConflict,\n RxStorageWriteErrorAttachment,\n RxStorage,\n RxStorageDefaultCheckpoint,\n FilledMangoQuery\n} from './types/index.d.ts';\nimport {\n PROMISE_RESOLVE_TRUE,\n RXDB_VERSION,\n RX_META_LWT_MINIMUM,\n appendToArray,\n createRevision,\n ensureNotFalsy,\n flatClone,\n getDefaultRevision,\n getDefaultRxDocumentMeta,\n lastOfArray,\n now,\n promiseWait,\n randomCouchString\n} from './plugins/utils/index.ts';\nimport { Observable, filter, map, startWith, switchMap } from 'rxjs';\nimport { prepareQuery } from './rx-query.ts';\nimport { normalizeMangoQuery } from './rx-query-helper.ts';\n\nexport const INTERNAL_STORAGE_NAME = '_rxdb_internal';\nexport const RX_DATABASE_LOCAL_DOCS_STORAGE_NAME = 'rxdatabase_storage_local';\n\nexport async function getSingleDocument(\n storageInstance: RxStorageInstance,\n documentId: string\n): Promise | undefined> {\n const results = await storageInstance.findDocumentsById([documentId], false);\n const doc = results[0];\n if (doc) {\n return doc;\n } else {\n return undefined;\n }\n}\n\n/**\n * Writes a single document,\n * throws RxStorageBulkWriteError on failure\n */\nexport async function writeSingle(\n instance: RxStorageInstance,\n writeRow: BulkWriteRow,\n context: string\n): Promise> {\n const writeResult = await instance.bulkWrite(\n [writeRow],\n context\n );\n if (writeResult.error.length > 0) {\n const error = writeResult.error[0];\n throw error;\n } else {\n const ret = writeResult.success[0];\n return ret;\n }\n}\n\n/**\n * Observe the plain document data of a single document.\n * Do not forget to unsubscribe.\n */\nexport function observeSingle(\n storageInstance: RxStorageInstance,\n documentId: string\n): Observable> {\n const firstFindPromise = getSingleDocument(storageInstance, documentId);\n const ret = storageInstance\n .changeStream()\n .pipe(\n map(evBulk => evBulk.events.find(ev => ev.documentId === documentId)),\n filter(ev => !!ev),\n map(ev => Promise.resolve(ensureNotFalsy(ev).documentData)),\n startWith(firstFindPromise),\n switchMap(v => v),\n filter(v => !!v)\n ) as any;\n return ret;\n}\n\n/**\n * Checkpoints must be stackable over another.\n * This is required form some RxStorage implementations\n * like the sharding plugin, where a checkpoint only represents\n * the document state from some, but not all shards.\n */\nexport function stackCheckpoints(\n checkpoints: CheckpointType[]\n): CheckpointType {\n return Object.assign(\n {},\n ...checkpoints\n );\n}\n\nexport function storageChangeEventToRxChangeEvent(\n isLocal: boolean,\n rxStorageChangeEvent: RxStorageChangeEvent,\n rxCollection?: RxCollection,\n): RxChangeEvent {\n const documentData = rxStorageChangeEvent.documentData;\n const previousDocumentData = rxStorageChangeEvent.previousDocumentData;\n const ret: RxChangeEvent = {\n documentId: rxStorageChangeEvent.documentId,\n collectionName: rxCollection ? rxCollection.name : undefined,\n isLocal,\n operation: rxStorageChangeEvent.operation,\n documentData: overwritable.deepFreezeWhenDevMode(documentData as any),\n previousDocumentData: overwritable.deepFreezeWhenDevMode(previousDocumentData as any)\n };\n return ret;\n}\n\nexport function throwIfIsStorageWriteError(\n collection: RxCollection,\n documentId: string,\n writeData: RxDocumentWriteData | RxDocType,\n error: RxStorageWriteError | undefined\n) {\n if (error) {\n if (error.status === 409) {\n throw newRxError('CONFLICT', {\n collection: collection.name,\n id: documentId,\n writeError: error,\n data: writeData\n });\n } else if (error.status === 422) {\n throw newRxError('VD2', {\n collection: collection.name,\n id: documentId,\n writeError: error,\n data: writeData\n });\n } else {\n throw error;\n }\n }\n}\n\n\n/**\n * Analyzes a list of BulkWriteRows and determines\n * which documents must be inserted, updated or deleted\n * and which events must be emitted and which documents cause a conflict\n * and must not be written.\n * Used as helper inside of some RxStorage implementations.\n * @hotPath The performance of this function is critical\n */\nexport function categorizeBulkWriteRows(\n storageInstance: RxStorageInstance,\n primaryPath: StringKeys,\n /**\n * Current state of the documents\n * inside of the storage. Used to determine\n * which writes cause conflicts.\n * This must be a Map for better performance.\n */\n docsInDb: Map[StringKeys] | string, RxDocumentData>,\n /**\n * The write rows that are passed to\n * RxStorageInstance().bulkWrite().\n */\n bulkWriteRows: BulkWriteRow[],\n context: string,\n /**\n * Used by some storages for better performance.\n * For example when get-by-id and insert/update can run in parallel.\n */\n onInsert?: (docData: RxDocumentData) => void,\n onUpdate?: (docData: RxDocumentData) => void\n): CategorizeBulkWriteRowsOutput {\n const hasAttachments = !!storageInstance.schema.attachments;\n const bulkInsertDocs: BulkWriteRowProcessed[] = [];\n const bulkUpdateDocs: BulkWriteRowProcessed[] = [];\n const errors: RxStorageWriteError[] = [];\n const eventBulkId = randomCouchString(10);\n const eventBulk: EventBulk>, any> = {\n id: eventBulkId,\n events: [],\n checkpoint: null,\n context,\n startTime: now(),\n endTime: 0\n };\n const eventBulkEvents = eventBulk.events;\n\n const attachmentsAdd: {\n documentId: string;\n attachmentId: string;\n attachmentData: RxAttachmentWriteData;\n digest: string;\n }[] = [];\n const attachmentsRemove: {\n documentId: string;\n attachmentId: string;\n digest: string;\n }[] = [];\n const attachmentsUpdate: {\n documentId: string;\n attachmentId: string;\n attachmentData: RxAttachmentWriteData;\n digest: string;\n }[] = [];\n\n const hasDocsInDb = docsInDb.size > 0;\n let newestRow: BulkWriteRowProcessed | undefined;\n\n /**\n * @performance is really important in this loop!\n */\n const rowAmount = bulkWriteRows.length;\n for (let rowId = 0; rowId < rowAmount; rowId++) {\n const writeRow = bulkWriteRows[rowId];\n\n // use these variables to have less property accesses\n const document = writeRow.document;\n const previous = writeRow.previous;\n const docId = document[primaryPath] as string;\n const documentDeleted = document._deleted;\n const previousDeleted = previous && previous._deleted;\n\n let documentInDb: RxDocumentData | undefined = undefined as any;\n if (hasDocsInDb) {\n documentInDb = docsInDb.get(docId);\n }\n let attachmentError: RxStorageWriteErrorAttachment | undefined;\n\n if (!documentInDb) {\n /**\n * It is possible to insert already deleted documents,\n * this can happen on replication.\n */\n const insertedIsDeleted = documentDeleted ? true : false;\n if (hasAttachments) {\n Object\n .entries(document._attachments)\n .forEach(([attachmentId, attachmentData]) => {\n if (\n !(attachmentData as RxAttachmentWriteData).data\n ) {\n attachmentError = {\n documentId: docId,\n isError: true,\n status: 510,\n writeRow,\n attachmentId\n };\n errors.push(attachmentError);\n } else {\n attachmentsAdd.push({\n documentId: docId,\n attachmentId,\n attachmentData: attachmentData as any,\n digest: attachmentData.digest\n });\n }\n });\n }\n if (!attachmentError) {\n if (hasAttachments) {\n bulkInsertDocs.push(stripAttachmentsDataFromRow(writeRow));\n if (onInsert) {\n onInsert(document);\n }\n } else {\n bulkInsertDocs.push(writeRow as any);\n if (onInsert) {\n onInsert(document);\n }\n }\n\n newestRow = writeRow as any;\n }\n\n if (!insertedIsDeleted) {\n const event = {\n documentId: docId,\n operation: 'INSERT' as const,\n documentData: hasAttachments ? stripAttachmentsDataFromDocument(document) : document as any,\n previousDocumentData: hasAttachments && previous ? stripAttachmentsDataFromDocument(previous) : previous as any\n };\n eventBulkEvents.push(event);\n }\n } else {\n // update existing document\n const revInDb: string = documentInDb._rev;\n\n /**\n * Check for conflict\n */\n if (\n (\n !previous\n ) ||\n (\n !!previous &&\n revInDb !== previous._rev\n )\n ) {\n // is conflict error\n const err: RxStorageWriteError = {\n isError: true,\n status: 409,\n documentId: docId,\n writeRow: writeRow,\n documentInDb\n };\n errors.push(err);\n continue;\n }\n\n // handle attachments data\n\n const updatedRow: BulkWriteRowProcessed = hasAttachments ? stripAttachmentsDataFromRow(writeRow) : writeRow as any;\n if (hasAttachments) {\n if (documentDeleted) {\n /**\n * Deleted documents must have cleared all their attachments.\n */\n if (previous) {\n Object\n .keys(previous._attachments)\n .forEach(attachmentId => {\n attachmentsRemove.push({\n documentId: docId,\n attachmentId,\n digest: ensureNotFalsy(previous)._attachments[attachmentId].digest\n });\n });\n }\n } else {\n // first check for errors\n Object\n .entries(document._attachments)\n .find(([attachmentId, attachmentData]) => {\n const previousAttachmentData = previous ? previous._attachments[attachmentId] : undefined;\n if (\n !previousAttachmentData &&\n !(attachmentData as RxAttachmentWriteData).data\n ) {\n attachmentError = {\n documentId: docId,\n documentInDb: documentInDb as any,\n isError: true,\n status: 510,\n writeRow,\n attachmentId\n };\n }\n return true;\n });\n if (!attachmentError) {\n Object\n .entries(document._attachments)\n .forEach(([attachmentId, attachmentData]) => {\n const previousAttachmentData = previous ? previous._attachments[attachmentId] : undefined;\n if (!previousAttachmentData) {\n attachmentsAdd.push({\n documentId: docId,\n attachmentId,\n attachmentData: attachmentData as any,\n digest: attachmentData.digest\n });\n } else {\n const newDigest = updatedRow.document._attachments[attachmentId].digest;\n if (\n (attachmentData as RxAttachmentWriteData).data &&\n /**\n * Performance shortcut,\n * do not update the attachment data if it did not change.\n */\n previousAttachmentData.digest !== newDigest\n ) {\n attachmentsUpdate.push({\n documentId: docId,\n attachmentId,\n attachmentData: attachmentData as RxAttachmentWriteData,\n digest: attachmentData.digest\n });\n }\n }\n });\n }\n }\n }\n\n if (attachmentError) {\n errors.push(attachmentError);\n } else {\n if (hasAttachments) {\n bulkUpdateDocs.push(stripAttachmentsDataFromRow(updatedRow));\n if (onUpdate) {\n onUpdate(document);\n }\n } else {\n bulkUpdateDocs.push(updatedRow);\n if (onUpdate) {\n onUpdate(document);\n }\n }\n newestRow = updatedRow as any;\n }\n\n let eventDocumentData: RxDocumentData | undefined = null as any;\n let previousEventDocumentData: RxDocumentData | undefined = null as any;\n let operation: 'INSERT' | 'UPDATE' | 'DELETE' = null as any;\n\n if (previousDeleted && !documentDeleted) {\n operation = 'INSERT';\n eventDocumentData = hasAttachments ? stripAttachmentsDataFromDocument(document) : document as any;\n } else if (previous && !previousDeleted && !documentDeleted) {\n operation = 'UPDATE';\n eventDocumentData = hasAttachments ? stripAttachmentsDataFromDocument(document) : document as any;\n previousEventDocumentData = previous;\n } else if (documentDeleted) {\n operation = 'DELETE';\n eventDocumentData = ensureNotFalsy(document) as any;\n previousEventDocumentData = previous;\n } else {\n throw newRxError('SNH', { args: { writeRow } });\n }\n\n const event = {\n documentId: docId,\n documentData: eventDocumentData as RxDocumentData,\n previousDocumentData: previousEventDocumentData,\n operation: operation\n };\n eventBulkEvents.push(event);\n }\n }\n\n return {\n bulkInsertDocs,\n bulkUpdateDocs,\n newestRow,\n errors,\n eventBulk,\n attachmentsAdd,\n attachmentsRemove,\n attachmentsUpdate\n };\n}\n\nexport function stripAttachmentsDataFromRow(writeRow: BulkWriteRow): BulkWriteRowProcessed {\n return {\n previous: writeRow.previous,\n document: stripAttachmentsDataFromDocument(writeRow.document)\n };\n}\n\nexport function getAttachmentSize(\n attachmentBase64String: string\n): number {\n return atob(attachmentBase64String).length;\n}\n\n/**\n * Used in custom RxStorage implementations.\n */\nexport function attachmentWriteDataToNormalData(writeData: RxAttachmentData | RxAttachmentWriteData): RxAttachmentData {\n const data = (writeData as RxAttachmentWriteData).data;\n if (!data) {\n return writeData as any;\n }\n const ret: RxAttachmentData = {\n length: getAttachmentSize(data),\n digest: writeData.digest,\n type: writeData.type\n };\n return ret;\n}\n\nexport function stripAttachmentsDataFromDocument(doc: RxDocumentWriteData): RxDocumentData {\n if (!doc._attachments || Object.keys(doc._attachments).length === 0) {\n return doc;\n }\n\n const useDoc: RxDocumentData = flatClone(doc) as any;\n useDoc._attachments = {};\n Object\n .entries(doc._attachments)\n .forEach(([attachmentId, attachmentData]) => {\n useDoc._attachments[attachmentId] = attachmentWriteDataToNormalData(attachmentData);\n });\n return useDoc;\n}\n\n/**\n * Flat clone the document data\n * and also the _meta field.\n * Used many times when we want to change the meta\n * during replication etc.\n */\nexport function flatCloneDocWithMeta(\n doc: RxDocumentData\n): RxDocumentData {\n const ret = flatClone(doc);\n ret._meta = flatClone(doc._meta);\n return ret;\n}\n\nexport type WrappedRxStorageInstance = RxStorageInstance & {\n originalStorageInstance: RxStorageInstance;\n};\n\n/**\n * Wraps the normal storageInstance of a RxCollection\n * to ensure that all access is properly using the hooks\n * and other data transformations and also ensure that database.lockedRun()\n * is used properly.\n */\nexport function getWrappedStorageInstance<\n RxDocType,\n Internals,\n InstanceCreationOptions,\n CheckpointType\n>(\n database: RxDatabase<{}, Internals, InstanceCreationOptions, any>,\n storageInstance: RxStorageInstance,\n /**\n * The original RxJsonSchema\n * before it was mutated by hooks.\n */\n rxJsonSchema: RxJsonSchema>\n): WrappedRxStorageInstance {\n overwritable.deepFreezeWhenDevMode(rxJsonSchema);\n const primaryPath = getPrimaryFieldOfPrimaryKey(rxJsonSchema.primaryKey);\n\n function transformDocumentDataFromRxDBToRxStorage(\n writeRow: BulkWriteRow\n ) {\n let data = flatClone(writeRow.document);\n data._meta = flatClone(data._meta);\n\n /**\n * Do some checks in dev-mode\n * that would be too performance expensive\n * in production.\n */\n if (overwritable.isDevMode()) {\n // ensure that the primary key has not been changed\n data = fillPrimaryKey(\n primaryPath,\n rxJsonSchema,\n data as any\n );\n\n\n /**\n * Ensure it can be structured cloned\n */\n try {\n /**\n * Notice that structuredClone() is not available\n * in ReactNative, so we test for JSON.stringify() instead\n * @link https://github.com/pubkey/rxdb/issues/5046#issuecomment-1827374498\n */\n if (typeof structuredClone === 'function') {\n structuredClone(writeRow);\n } else {\n JSON.parse(JSON.stringify(writeRow));\n }\n } catch (err) {\n throw newRxError('DOC24', {\n collection: storageInstance.collectionName,\n document: writeRow.document\n });\n }\n\n /**\n * Ensure that the new revision is higher\n * then the previous one\n */\n if (writeRow.previous) {\n // TODO run this in the dev-mode plugin\n // const prev = parseRevision(writeRow.previous._rev);\n // const current = parseRevision(writeRow.document._rev);\n // if (current.height <= prev.height) {\n // throw newRxError('SNH', {\n // dataBefore: writeRow.previous,\n // dataAfter: writeRow.document,\n // args: {\n // prev,\n // current\n // }\n // });\n // }\n }\n\n /**\n * Ensure that _meta fields have been merged\n * and not replaced.\n * This is important so that when one plugin A\n * sets a _meta field and another plugin B does a write\n * to the document, it must be ensured that the\n * field of plugin A was not removed.\n */\n if (writeRow.previous) {\n Object.keys(writeRow.previous._meta)\n .forEach(metaFieldName => {\n if (!Object.prototype.hasOwnProperty.call(writeRow.document._meta, metaFieldName)) {\n throw newRxError('SNH', {\n dataBefore: writeRow.previous,\n dataAfter: writeRow.document\n });\n }\n });\n }\n }\n data._meta.lwt = now();\n\n /**\n * Yes we really want to set the revision here.\n * If you make a plugin that relies on having its own revision\n * stored into the storage, use this.originalStorageInstance.bulkWrite() instead.\n */\n data._rev = createRevision(\n database.token,\n writeRow.previous\n );\n\n return {\n document: data,\n previous: writeRow.previous\n };\n }\n\n const ret: WrappedRxStorageInstance = {\n originalStorageInstance: storageInstance,\n schema: storageInstance.schema,\n internals: storageInstance.internals,\n collectionName: storageInstance.collectionName,\n databaseName: storageInstance.databaseName,\n options: storageInstance.options,\n bulkWrite(\n rows: BulkWriteRow[],\n context: string\n ) {\n const toStorageWriteRows: BulkWriteRow[] = rows\n .map(row => transformDocumentDataFromRxDBToRxStorage(row));\n\n return database.lockedRun(\n () => storageInstance.bulkWrite(\n toStorageWriteRows,\n context\n )\n )\n /**\n * The RxStorageInstance MUST NOT allow to insert already _deleted documents,\n * without sending the previous document version.\n * But for better developer experience, RxDB does allow to re-insert deleted documents.\n * We do this by automatically fixing the conflict errors for that case\n * by running another bulkWrite() and merging the results.\n * @link https://github.com/pubkey/rxdb/pull/3839\n */\n .then(writeResult => {\n const useWriteResult: typeof writeResult = {\n error: [],\n success: writeResult.success.slice(0)\n };\n const reInsertErrors: RxStorageWriteErrorConflict[] =\n writeResult.error\n .filter((error) => {\n if (\n error.status === 409 &&\n !error.writeRow.previous &&\n !error.writeRow.document._deleted &&\n ensureNotFalsy(error.documentInDb)._deleted\n ) {\n return true;\n }\n useWriteResult.error.push(error);\n return false;\n }) as any;\n if (reInsertErrors.length > 0) {\n const reInserts: BulkWriteRow[] = reInsertErrors\n .map((error) => {\n return {\n previous: error.documentInDb,\n document: Object.assign(\n {},\n error.writeRow.document,\n {\n _rev: createRevision(\n database.token,\n error.documentInDb\n )\n }\n )\n };\n });\n\n return database.lockedRun(\n () => storageInstance.bulkWrite(\n reInserts,\n context\n )\n ).then(subResult => {\n appendToArray(useWriteResult.error, subResult.error);\n appendToArray(useWriteResult.success, subResult.success);\n return useWriteResult;\n });\n }\n\n return writeResult;\n });\n },\n query(preparedQuery) {\n return database.lockedRun(\n () => storageInstance.query(preparedQuery)\n );\n },\n count(preparedQuery) {\n return database.lockedRun(\n () => storageInstance.count(preparedQuery)\n );\n },\n findDocumentsById(ids, deleted) {\n return database.lockedRun(\n () => storageInstance.findDocumentsById(ids, deleted)\n );\n },\n getAttachmentData(\n documentId: string,\n attachmentId: string,\n digest: string\n ) {\n return database.lockedRun(\n () => storageInstance.getAttachmentData(documentId, attachmentId, digest)\n );\n },\n getChangedDocumentsSince: !storageInstance.getChangedDocumentsSince ? undefined : (limit: number, checkpoint?: any) => {\n return database.lockedRun(\n () => ((storageInstance as any).getChangedDocumentsSince)(ensureNotFalsy(limit), checkpoint)\n );\n },\n cleanup(minDeletedTime: number) {\n return database.lockedRun(\n () => storageInstance.cleanup(minDeletedTime)\n );\n },\n remove() {\n database.storageInstances.delete(ret);\n return database.lockedRun(\n () => storageInstance.remove()\n );\n },\n close() {\n database.storageInstances.delete(ret);\n return database.lockedRun(\n () => storageInstance.close()\n );\n },\n changeStream() {\n return storageInstance.changeStream();\n },\n conflictResultionTasks() {\n return storageInstance.conflictResultionTasks();\n },\n resolveConflictResultionTask(taskSolution) {\n if (taskSolution.output.isEqual) {\n return storageInstance.resolveConflictResultionTask(taskSolution);\n }\n\n const doc = Object.assign(\n {},\n taskSolution.output.documentData,\n {\n _meta: getDefaultRxDocumentMeta(),\n _rev: getDefaultRevision(),\n _attachments: {}\n }\n );\n\n const documentData = flatClone(doc);\n delete (documentData as any)._meta;\n delete (documentData as any)._rev;\n delete (documentData as any)._attachments;\n\n return storageInstance.resolveConflictResultionTask({\n id: taskSolution.id,\n output: {\n isEqual: false,\n documentData\n }\n });\n }\n };\n\n database.storageInstances.add(ret);\n return ret;\n}\n\n/**\n * Each RxStorage implementation should\n * run this method at the first step of createStorageInstance()\n * to ensure that the configuration is correct.\n */\nexport function ensureRxStorageInstanceParamsAreCorrect(\n params: RxStorageInstanceCreationParams\n) {\n if (params.schema.keyCompression) {\n throw newRxError('UT5', { args: { params } });\n }\n if (hasEncryption(params.schema)) {\n throw newRxError('UT6', { args: { params } });\n }\n if (\n params.schema.attachments &&\n params.schema.attachments.compression\n ) {\n throw newRxError('UT7', { args: { params } });\n }\n}\n\nexport function hasEncryption(jsonSchema: RxJsonSchema): boolean {\n if (\n (!!jsonSchema.encrypted && jsonSchema.encrypted.length > 0) ||\n (jsonSchema.attachments && jsonSchema.attachments.encrypted)\n ) {\n return true;\n } else {\n return false;\n }\n}\n\nexport function getChangedDocumentsSinceQuery(\n storageInstance: RxStorageInstance,\n limit: number,\n checkpoint?: CheckpointType\n): FilledMangoQuery {\n const primaryPath = getPrimaryFieldOfPrimaryKey(storageInstance.schema.primaryKey);\n const sinceLwt = checkpoint ? (checkpoint as unknown as RxStorageDefaultCheckpoint).lwt : RX_META_LWT_MINIMUM;\n const sinceId = checkpoint ? (checkpoint as unknown as RxStorageDefaultCheckpoint).id : '';\n return normalizeMangoQuery(storageInstance.schema, {\n selector: {\n $or: [\n {\n '_meta.lwt': {\n $gt: sinceLwt\n }\n },\n {\n '_meta.lwt': {\n $eq: sinceLwt\n },\n [primaryPath]: {\n $gt: checkpoint ? sinceId : ''\n }\n }\n ],\n // add this hint for better index usage\n '_meta.lwt': {\n $gte: sinceLwt\n }\n } as any,\n sort: [\n { '_meta.lwt': 'asc' },\n { [primaryPath]: 'asc' }\n ] as any,\n skip: 0,\n limit,\n /**\n * DO NOT SET A SPECIFIC INDEX HERE!\n * The query might be modified by some plugin\n * before sending it to the storage.\n * We can be sure that in the end the query planner\n * will find the best index.\n */\n // index: ['_meta.lwt', primaryPath]\n });\n}\n\nexport async function getChangedDocumentsSince(\n storageInstance: RxStorageInstance,\n limit: number,\n checkpoint?: CheckpointType\n): Promise<{\n documents: RxDocumentData[];\n /**\n * The checkpoint contains data so that another\n * call to getChangedDocumentsSince() will continue\n * from exactly the last document that was returned before.\n */\n checkpoint: CheckpointType;\n}> {\n if (storageInstance.getChangedDocumentsSince) {\n return storageInstance.getChangedDocumentsSince(limit, checkpoint);\n }\n\n const primaryPath = getPrimaryFieldOfPrimaryKey(storageInstance.schema.primaryKey);\n const query = prepareQuery>(\n storageInstance.schema,\n getChangedDocumentsSinceQuery(\n storageInstance,\n limit,\n checkpoint\n )\n );\n\n const result = await storageInstance.query(query);\n const documents = result.documents;\n const lastDoc = lastOfArray(documents);\n\n return {\n documents: documents,\n checkpoint: lastDoc ? {\n id: (lastDoc as any)[primaryPath],\n lwt: lastDoc._meta.lwt\n } as any : checkpoint ? checkpoint : {\n id: '',\n lwt: 0\n }\n };\n}\n\n\n/**\n * Wraps the storage and simluates\n * delays. Mostly used in tests.\n */\nexport function randomDelayStorage(\n input: {\n storage: RxStorage;\n delayTimeBefore: () => number;\n delayTimeAfter: () => number;\n }\n): RxStorage {\n\n const retStorage: RxStorage = {\n name: 'random-delay-' + input.storage.name,\n rxdbVersion: RXDB_VERSION,\n async createStorageInstance(params) {\n await promiseWait(input.delayTimeBefore());\n const storageInstance = await input.storage.createStorageInstance(params);\n await promiseWait(input.delayTimeAfter());\n\n // write still must be processed in order\n let writeQueue: Promise = PROMISE_RESOLVE_TRUE;\n\n return {\n databaseName: storageInstance.databaseName,\n internals: storageInstance.internals,\n options: storageInstance.options,\n schema: storageInstance.schema,\n collectionName: storageInstance.collectionName,\n async bulkWrite(a, b) {\n writeQueue = writeQueue.then(async () => {\n await promiseWait(input.delayTimeBefore());\n const response = await storageInstance.bulkWrite(a, b);\n await promiseWait(input.delayTimeAfter());\n return response;\n });\n const ret = await writeQueue;\n return ret;\n },\n async findDocumentsById(a, b) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.findDocumentsById(a, b);\n await promiseWait(input.delayTimeAfter());\n return ret;\n },\n async query(a) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.query(a);\n return ret;\n },\n async count(a) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.count(a);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n async getAttachmentData(a, b, c) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.getAttachmentData(a, b, c);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n getChangedDocumentsSince: !storageInstance.getChangedDocumentsSince ? undefined : async (a, b) => {\n await promiseWait(input.delayTimeBefore());\n const ret = await ensureNotFalsy(storageInstance.getChangedDocumentsSince)(a, b);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n changeStream() {\n return storageInstance.changeStream();\n },\n conflictResultionTasks() {\n return storageInstance.conflictResultionTasks();\n },\n resolveConflictResultionTask(a) {\n return storageInstance.resolveConflictResultionTask(a);\n },\n async cleanup(a) {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.cleanup(a);\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n async close() {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.close();\n await promiseWait(input.delayTimeAfter());\n return ret;\n\n },\n async remove() {\n await promiseWait(input.delayTimeBefore());\n const ret = await storageInstance.remove();\n await promiseWait(input.delayTimeAfter());\n return ret;\n },\n };\n\n\n }\n };\n return retStorage;\n}\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,YAAY,QAAQ,mBAAmB;AAChD,SAASC,UAAU,QAAQ,eAAe;AAC1C,SACIC,cAAc,EACdC,2BAA2B,QACxB,uBAAuB;AAyB9B,SACIC,oBAAoB,EACpBC,YAAY,EACZC,mBAAmB,EACnBC,aAAa,EAC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C,CAAC,CAAC;UACzC,OAAOnL,GAAG;QAEd,CAAC;QACD,MAAMiJ,KAAKA,CAAA,EAAG;UACV,MAAM1K,WAAW,CAACsM,KAAK,CAACK,eAAe,CAAC,CAAC,CAAC;UAC1C,IAAMlL,GAAG,GAAG,MAAMd,eAAe,CAAC+J,KAAK,CAAC,CAAC;UACzC,MAAM1K,WAAW,CAACsM,KAAK,CAACM,cAAc,CAAC,CAAC,CAAC;UACzC,OAAOnL,GAAG;QAEd,CAAC;QACD,MAAM8I,MAAMA,CAAA,EAAG;UACX,MAAMvK,WAAW,CAACsM,KAAK,CAACK,eAAe,CAAC,CAAC,CAAC;UAC1C,IAAMlL,GAAG,GAAG,MAAMd,eAAe,CAAC4J,MAAM,CAAC,CAAC;UAC1C,MAAMvK,WAAW,CAACsM,KAAK,CAACM,cAAc,CAAC,CAAC,CAAC;UACzC,OAAOnL,GAAG;QACd;MACJ,CAAC;IAGL;EACJ,CAAC;EACD,OAAO8K,UAAU;AACrB","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 7d6f15ea7f1..75268c94fbe 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.18.1"; + readonly rxdbVersion = "15.18.2"; 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 8f03b6625c7..174e43dbbff 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.18.1"; + readonly rxdbVersion = "15.18.2"; 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 f37e9f785ef..11046f8ca6f 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.18.1"; + readonly rxdbVersion = "15.18.2"; /** * Create one leader elector by db name. * This is done inside of the storage, not globally diff --git a/dist/types/plugins/storage-memory/rx-storage-instance-memory.d.ts b/dist/types/plugins/storage-memory/rx-storage-instance-memory.d.ts index 9763801f0d4..a7ac61ee1b6 100644 --- a/dist/types/plugins/storage-memory/rx-storage-instance-memory.d.ts +++ b/dist/types/plugins/storage-memory/rx-storage-instance-memory.d.ts @@ -1,5 +1,5 @@ import { Observable } from 'rxjs'; -import type { BulkWriteRow, EventBulk, PreparedQuery, RxConflictResultionTask, RxConflictResultionTaskSolution, RxDocumentData, RxJsonSchema, RxStorageBulkWriteResponse, RxStorageChangeEvent, RxStorageCountResult, RxStorageDefaultCheckpoint, RxStorageInstance, RxStorageInstanceCreationParams, RxStorageQueryResult, StringKeys } from '../../types/index.d.ts'; +import type { BulkWriteRow, CategorizeBulkWriteRowsOutput, EventBulk, PreparedQuery, RxConflictResultionTask, RxConflictResultionTaskSolution, RxDocumentData, RxJsonSchema, RxStorageBulkWriteResponse, RxStorageChangeEvent, RxStorageCountResult, RxStorageDefaultCheckpoint, RxStorageInstance, RxStorageInstanceCreationParams, RxStorageQueryResult, StringKeys } from '../../types/index.d.ts'; import type { MemoryStorageInternals, RxStorageMemory, RxStorageMemoryInstanceCreationOptions, RxStorageMemorySettings } from './memory-types.ts'; /** * Used in tests to ensure everything @@ -16,6 +16,13 @@ export declare class RxStorageInstanceMemory implements RxStorageInst readonly settings: RxStorageMemorySettings; readonly primaryPath: StringKeys>; closed: boolean; + /** + * Used by some plugins and storage wrappers + * to find out details about the internals of a write operation. + * For example if you want to know which documents really have been replaced + * or newly inserted. + */ + categorizedByWriteInput: WeakMap[], CategorizeBulkWriteRowsOutput>; constructor(storage: RxStorageMemory, databaseName: string, collectionName: string, schema: Readonly>>, internals: MemoryStorageInternals, options: Readonly, settings: RxStorageMemorySettings); bulkWrite(documentWrites: BulkWriteRow[], context: string): Promise>; /** 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 eb39ecf45d8..c260050f08b 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.18.1"; + readonly rxdbVersion = "15.18.2"; 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 d19957e3b7d..d874b6bae21 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.18.1"; + readonly rxdbVersion = "15.18.2"; 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 639632cf618..395c288d7e9 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.18.1"; +export declare const RXDB_VERSION = "15.18.2"; diff --git a/dist/types/rx-database.d.ts b/dist/types/rx-database.d.ts index 5ebd5f0e5ea..252e85b25f2 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.18.1"; + readonly rxdbVersion = "15.18.2"; /** * Contains all known non-closed storage instances * that belong to this database. diff --git a/docs/404.html b/docs/404.html index d868fca206b..6c25fcf6358 100644 --- a/docs/404.html +++ b/docs/404.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/adapters.html b/docs/adapters.html index cc127fc09ca..232e00a570a 100644 --- a/docs/adapters.html +++ b/docs/adapters.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/alternatives.html b/docs/alternatives.html index b1424796747..099136de17e 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 31a16b2b448..0e987b14e07 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 c78022e69de..2b1da9df4a6 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 d103ec2a958..79bd4ca5523 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 58c0f1694bf..5ccf509a3f2 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 8d909a92df1..3063ec7a3d7 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 b042d3d2597..d75d7c4e975 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 3888c119868..8e31e9edba9 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 980321a7089..24d7f4236bb 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 6e7c7d29d5b..04a877d0332 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 fa47c1aa778..1fb241a9f36 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 b48651de349..f1febf8a527 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 4dadc5f9710..2de8f136348 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 065d7c490af..2a02183abe5 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 d8e6d3d5fcc..bebf9f9f027 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 df6371ed7e1..2b01c7bf026 100644 --- a/docs/articles/realtime-database.html +++ b/docs/articles/realtime-database.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/articles/websockets-sse-polling-webrtc-webtransport.html b/docs/articles/websockets-sse-polling-webrtc-webtransport.html index c7894156d77..41db2eb9ca8 100644 --- a/docs/articles/websockets-sse-polling-webrtc-webtransport.html +++ b/docs/articles/websockets-sse-polling-webrtc-webtransport.html @@ -15,8 +15,8 @@ - - + + diff --git a/docs/assets/js/0e268d20.60e1364a.js b/docs/assets/js/0e268d20.61206afa.js similarity index 99% rename from docs/assets/js/0e268d20.60e1364a.js rename to docs/assets/js/0e268d20.61206afa.js index cdef6388574..0ae3280436e 100644 --- a/docs/assets/js/0e268d20.60e1364a.js +++ b/docs/assets/js/0e268d20.61206afa.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 d=e=>{var t=typeof e;return null!==e&&("object"===t||"function"===t)},h=new Set(["__proto__","prototype","constructor"]),u=new Set("0123456789");function m(e){var t=[],r="",a="start",n=!1;for(var i of e)switch(i){case"\\":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");n&&(r+=i),a="property",n=!n;break;case".":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="property";break}if(n){n=!1,r+=i;break}if(h.has(r))return[];t.push(r),r="",a="property";break;case"[":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="index";break}if(n){n=!1,r+=i;break}if("property"===a){if(h.has(r))return[];t.push(r),r=""}a="index";break;case"]":if("index"===a){t.push(Number.parseInt(r,10)),r="",a="indexEnd";break}if("indexEnd"===a)throw new Error("Invalid character after an index");default:if("index"===a&&!u.has(i))throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");"start"===a&&(a="property"),n&&(n=!1,r+="\\"),r+=i}switch(n&&(r+="\\"),a){case"property":if(h.has(r))return[];t.push(r);break;case"index":throw new Error("Index was not closed");case"start":t.push("")}return t}function p(e,t){if("number"!=typeof t&&Array.isArray(e)){var r=Number.parseInt(t,10);return Number.isInteger(r)&&e[r]===e[t]}return!1}function f(e,t){if(p(e,t))throw new Error("Cannot use string index")}function v(e,t,r){if(Array.isArray(t)&&(t=t.join(".")),!t.includes(".")&&!t.includes("["))return e[t];if(!d(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}}])}((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}}])}((0,w.A)(TypeError));function R(e,t){return new D(e,j.tunnelErrorMessage(e),t)}function I(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 P=/\./g,C="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 R("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=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=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),de=String.fromCharCode(65535),he=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])),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,d=e.map((e=>{var t=r[e],n=t?Object.keys(t):[],i={};t&&n.length?n.forEach((e=>{if(me.has(e)){var r=function(e,t){switch(e){case"$eq":return{startKey:t,endKey:t,inclusiveEnd:!0,inclusiveStart:!0};case"$lte":return{endKey:t,inclusiveEnd:!0};case"$gte":return{startKey:t,inclusiveStart:!0};case"$lt":return{endKey:t,inclusiveEnd:!1};case"$gt":return{startKey:t,inclusiveStart:!1};default:throw new Error("SNH")}}(e,t[e]);i=Object.assign(i,r)}})):i={startKey:l?he:de,endKey:a?de:he,inclusiveStart:!0,inclusiveEnd:!0};return void 0===i.startKey&&(i.startKey=he),void 0===i.endKey&&(i.endKey=de),void 0===i.inclusiveStart&&(i.inclusiveStart=!0),void 0===i.inclusiveEnd&&(i.inclusiveEnd=!0),l&&!i.inclusiveStart&&(l=!1),a&&!i.inclusiveEnd&&(a=!1),i})),h=d.map((e=>e.startKey)),u=d.map((e=>e.endKey)),m={index:e,startKeys:h,endKeys:u,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!i.has(e))).join(","),selectorSatisfiedByIndex:ve(e,t.selector,h,u)},p=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},i=10,s=(0,g.Sd)(r.startKeys,(e=>e!==he&&e!==de));n(s*i);var o=(0,g.Sd)(r.startKeys,(e=>e!==de&&e!==he));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 R("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 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 l=Object.keys(c).filter((e=>pe.has(e)));if(l.length>1)return!1;var d=l[0];if(d&&s.add(o),"$eq"!==d){if(i.length>0)return!1;i.push(d)}}var h=[],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(h.length>0)return!1;h.push(v)}}var y=0;for(var g of e){for(var b of[s,u]){if(!b.has(g)&&b.size>0)return!1;b.delete(g)}if(r[y]!==a[y]&&s.size>0&&u.size>0)return!1;y++}return!0}var ye=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),Re=!1;function Ie(e){return Re||((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}),Re=!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 R("SNH",{query:t});var r=[];t.sort.forEach((e=>{var t,a,n,i=Object.keys(e)[0],s=Object.values(e)[0];r.push({key:i,direction:s,getValueFn:(t=i,a=t.split("."),n=a.length,1===n?e=>e[t]:e=>{for(var t=e,r=0;r{for(var a=0;ar.test(e)}function Ce(e){return e===he?-1/0:e}function Oe(e,t,r){return e.includes(t)?r===de||!0===r?"1":"0":r}function Ne(e,t,r){if(!r){if("undefined"==typeof window)throw new Error("IDBKeyRange missing");r=window.IDBKeyRange}var a=t.startKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Ce),n=t.endKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Ce);return r.bound(a,n,!t.inclusiveStart,!t.inclusiveEnd)}async function 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=Pe(e.schema,t.query));var c=Ne(r.booleanIndexes,s,r.dexieDb._options.IDBKeyRange),l=s.index,d=[];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)||d.push(n),s.sortSatisfiedByIndex&&d.length===i?e():a.continue()}else e()}}))})),!s.sortSatisfiedByIndex){var h=Ee(e.schema,t.query);d=d.sort(h)}return{documents:d=d.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?R("CONFLICT",{collection:e.name,id:t,writeError:a,data:r}):422===a.status?R("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 R("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 R("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 d=r.close.bind(r);r.close=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),d()};var h=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),h()}}}var Ye=(0,ce.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 R("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=[],d=[],h=[],u={id:O(10),events:[],checkpoint:null,context:n,startTime:(0,ce.t)(),endTime:0},m=u.events,p=[],f=[],v=[],y=r.size>0,g=a.length,b=function(){var e,n=a[x],u=n.document,g=n.previous,b=u[t],w=u._deleted,j=g&&g._deleted,k=void 0;if(y&&(k=r.get(b)),k){var D=k._rev;if(!g||g&&D!==g._rev){var _={isError:!0,status:409,documentId:b,writeRow:n,documentInDb:k};return h.push(_),1}var I=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(u._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(u._attachments).forEach((e=>{let[t,r]=e;var a=g?g._attachments[t]:void 0;if(a){var n=I.document._attachments[t].digest;r.data&&a.digest!==n&&v.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})}else p.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})})))),e?h.push(e):(c?(d.push(We(I)),s&&s(u)):(d.push(I),s&&s(u)),o=I);var S=null,E=null,P=null;if(j&&!w)P="INSERT",S=c?He(u):u;else if(!g||j||w){if(!w)throw R("SNH",{args:{writeRow:n}});P="DELETE",S=(0,le.ZN)(u),E=g}else P="UPDATE",S=c?He(u):u,E=g;var C={documentId:b,documentData:S,previousDocumentData:E,operation:P};m.push(C)}else{var O=!!w;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},h.push(e))})),e||(c?(l.push(We(n)),i&&i(u)):(l.push(n),i&&i(u)),o=n),!O){var N={documentId:b,operation:"INSERT",documentData:c?He(u):u,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.18.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 R("UT5",{args:{params:e}});if((t=e.schema).encrypted&&t.encrypted.length>0||t.attachments&&t.attachments.encrypted)throw R("UT6",{args:{params:e}});var t;if(e.schema.attachments&&e.schema.attachments.compression)throw R("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 R("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)))}}])}();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 dt=r(7708),ht=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+=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 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,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 d of a)try{l=await d.modifier(c(l))}catch(h){d.reject(h),d.reject=()=>{},d.resolve=()=>{}}try{await this.preWrite(l,o)}catch(h){return void a.forEach((e=>e.reject(h)))}e.push({previous:o,document:l})})));var r=e.length>0?await this.storageInstance.bulkWrite(e,"incremental-write"):{error:[],success:[]};return await Promise.all(r.success.map((e=>{var r=e[this.primaryPath];this.postWrite(e),n(t,r).forEach((t=>t.resolve(e)))}))),r.error.forEach((e=>{var r,a=e.documentId,s=n(t,a),o=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=R("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,dt.T)((e=>e._data._deleted)))},get deleted$$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,e.collection.database)},get deleted(){if(this.isInstanceOfRxDocument)return this._data._deleted},getLatest(){var e=this.collection._docCache.getLatestDocumentData(this.primary);return this.collection._docCache.getCachedRxDocument(e)},get $(){return this.collection.$.pipe((0,ht.p)((e=>!e.isLocal)),(0,ht.p)((e=>e.documentId===this.primary)),(0,dt.T)((e=>yt(e))),(0,ut.Z)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,dt.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,e.collection.database)},get$(e){if(j.isDevMode()){if(e.includes(".item."))throw R("DOC1",{path:e});if(e===this.primaryPath)throw R("DOC2");if(this.collection.schema.finalFields.includes(e))throw R("DOC3",{path:e});if(!M(this.collection.schema.jsonSchema,e))throw R("DOC4",{path:e})}return this.$.pipe((0,dt.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),this.collection.database)},populate(e){var t=M(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.$A;if(!t)throw R("DOC5",{path:e});if(!t.ref)throw R("DOC6",{path:e,schemaObj:t});var a=this.collection.database.collections[t.ref];if(!a)throw R("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 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 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 R("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(R("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 R("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),Rt=r(2442),It=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 Pt(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=Pe(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,It.kC)(t);return"runFullQueryAgain"===i||("doNothing"!==i?(s=!0,(0,It.Cs)(i,r,e,a,n),!1):void 0)}))?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:s,newResults:a}}var Ct=function(){function e(){this._map=new Map}return e.prototype.getByQuery=function(e){var t=e.toString();return i(this._map,t,(()=>e))},e}();function Ot(e,t){t.uncached=!0;var r=t.toString();e._map.delete(r)}function Nt(e){return e.refCount$.observers.length}var 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=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 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),d=i(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),h=d.byRev,u=h.get(l),m=u?u.deref():void 0;return m||(o=n(o),m=s(o),h.set(l,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,ft.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))}}])}();function qt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Ft=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=qt(this.collection._docCache,t)}),[{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 R("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 R("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Kt(this).then((()=>(0,Dt._)(this.$))).then((t=>{if(!t&&e)throw R("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 vt("update")},t.where=function(e){throw vt("query-builder")},t.sort=function(e){throw vt("query-builder")},t.skip=function(e){throw vt("query-builder")},t.limit=function(e){throw vt("query-builder")},(0,b.A)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,ht.p)((e=>!e.isLocal)),(0,ut.Z)(null),(0,Rt.Z)((()=>Kt(this))),(0,dt.T)((()=>this._result)),(0,pt.t)(le.bz),(0,mt.F)(((e,t)=>!(!e||e.time!==(0,le.ZN)(t).time))),(0,ht.p)((e=>!!e)),(0,dt.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,ht.p)((()=>!1))))}return this._$}},{key:"$$",get:function(){return this.collection.database.getReactivityFactory().fromObservable(this.$,void 0,this.collection.database)}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return l(this,"queryMatcher",Pe(0,Se(this.collection.schema.jsonSchema,this.mangoQuery)))}},{key:"asRxQuery",get:function(){return this}}])}();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=Pt(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 d=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(d,"rx-database-remove-collection-all")}}var nr=function(){function e(e){this.subs=[],this.limit=100,this.counter=0,this.eventCounterMap=new WeakMap,this.buffer=[],this.collection=e,this.subs.push(this.collection.$.pipe((0,ht.p)((e=>!e.isLocal))).subscribe((e=>this._handleChangeEvent(e))))}var t=e.prototype;return t._handleChangeEvent=function(e){for(this.counter++,this.buffer.push(e),this.eventCounterMap.set(e,this.counter);this.buffer.length>this.limit;)this.buffer.shift()},t.getArrayIndexByPointer=function(e){var t=this.buffer[0],r=this.eventCounterMap.get(t);return et(e)))},t.reduceByLastOfDoc=function(e){return e.slice(0)},t.destroy=function(){this.subs.forEach((e=>e.unsubscribe()))},e}();var 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"],dr=["insert","save","remove","create"],hr=!1,ur=function(){function e(e,t,r,a,n,i,s,o,c,l,d,h){void 0===n&&(n={}),void 0===i&&(i={}),void 0===s&&(s={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===l&&(l=Bt),void 0===d&&(d={}),void 0===h&&(h=cr),this.storageInstance={},this.timeouts=new Set,this.incrementalWriteQueue={},this._incrementalUpsertQueues=new Map,this.synced=!1,this.hooks={},this._subs=[],this._docCache={},this._queryCache=new Ct,this.$={},this.checkpoint$={},this._changeEventBuffer={},this.onDestroy=[],this.destroyed=!1,this.database=e,this.name=t,this.schema=r,this.internalStorageInstance=a,this.instanceCreationOptions=n,this.migrationStrategies=i,this.methods=s,this.attachments=o,this.options=c,this.cacheReplacementPolicy=l,this.statics=d,this.conflictHandler=h,function(e){if(hr)return;hr=!0;var t=Object.getPrototypeOf(e);dr.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,ht.p)((e=>e.collectionName===this.name)));this.$=t.pipe((0,Rt.Z)((e=>e.events))),this.checkpoint$=t.pipe((0,dt.T)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Tt(this.schema.primaryPath,this.$.pipe((0,ht.p)((e=>!e.isLocal))),(e=>or(this.asRxCollection,e)));var r=await this.database.storageToken,a=this.storageInstance.changeStream().subscribe((e=>{var t={id:e.id,internal:!1,collectionName:this.name,storageToken:r,events:e.events.map((e=>Fe(!1,e,this))),databaseToken:this.database.token,checkpoint:e.checkpoint,context:e.context,endTime:e.endTime,startTime:e.startTime};this.database.$emit(t)}));return this._subs.push(a),this._subs.push(this.storageInstance.conflictResultionTasks().subscribe((e=>{this.conflictHandler(e.input,e.context).then((t=>{this.storageInstance.resolveConflictResultionTask({id:e.id,output:t})}))}))),ft.em},t.cleanup=function(e){throw vt("cleanup")},t.migrationNeeded=function(){throw vt("migration-schema")},t.getMigrationState=function(){throw vt("migration-schema")},t.startMigration=function(e){return void 0===e&&(e=10),this.getMigrationState().startMigration(e)},t.migratePromise=function(e){return void 0===e&&(e=10),this.getMigrationState().migratePromise(e)},t.insert=async function(e){var t=await this.bulkInsert([e]),r=t.error[0];return 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 R("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 R("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 R("COL5",{queryObj:e});return e||(e={selector:{}}),Ht("find",e,this)},t.findOne=function(e){if("number"==typeof e||Array.isArray(e))throw I("COL6",{queryObj:e});var t;if("string"==typeof e)t=Ht("findOne",{selector:{[this.schema.primaryPath]:e},limit:1},this);else{if(e||(e={selector:{}}),e.limit)throw R("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 I("COL7",{key:t,when:e});if(!lr.includes(e))throw I("COL8",{key:t,when:e});if(!dr.includes(t))throw R("COL9",{key:t});if("post"===e&&"create"===t&&!0===a)throw R("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,ht.p)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,ht.p)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,ht.p)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}])}();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),yr=new Set,gr=function(){function e(e,t,r,a,n,i,s,o,c,l,d,h,u){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,Rt.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=i,this.eventReduce=s,this.options=o,this.internalStore=c,this.hashFunction=l,this.cleanupPolicy=d,this.allowSlowCount=h,this.reactivity=u,"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 R("DM5",{args:{database:e.name,databaseStateVersion:s.documentInDb.data.rxdbVersion,codeVersion:e.rxdbVersion}});if(r&&r!==s.documentInDb.data.passwordHash)throw R("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 R("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 R("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 d=lt(l,this.hashFunction);if(r[c]=d,this.collections[i])throw R("DB3",{name:i});var h=tr(i,l),u={id:Gt(h,Zt),key:h,context:Zt,data:{name:c,schemaHash:await d.hash,schema:d.jsonSchema,version:d.version,connectedStorages:[]},_deleted:!1,_meta:B(),_rev:"",_attachments:{}};a.push({document:u});var m=Object.assign({},o,{name:c,schema:d,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 R("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 R("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:d={},localDocuments:h=!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: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 ur(t,r,a,e,n,i,c,l,d,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 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:d,cacheReplacementPolicy:u,localDocuments:h,statics:o}}),p))).catch((t=>e.close().then((()=>Promise.reject(t)))))}))}(t);o[e]=r,this.collections[e]=r,this[e]||Object.defineProperty(this,e,{get:()=>this.collections[e]})}))),o},t.lockedRun=function(e){return this.idleQueue.wrapCall(e)},t.requestIdlePromise=function(){return this.idleQueue.requestIdlePromise()},t.exportJSON=function(e){throw vt("json-dump")},t.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((()=>yr.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}}])}();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:d=!1,localDocuments:h=!1,hashFunction:u=fr,reactivity:m}=e;st("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:h}),o||function(e,t){var r=t.name+"|"+e;if(yr.has(r))throw R("DB8",{name:e,storage:t.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}(a,t),yr.add(t.name+"|"+a);var p=O(10);return br(p,t,a,r,i,n).catch((e=>{throw yr.delete(t.name+"|"+a),e})).then((e=>{var f=new gr(a,p,t,r,n,i,s,c,e,u,l,d,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:h}}).then((()=>f))}))}var wr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Wt.prototype,RxCollection:ur.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 R("LD1",{document:this})},get primaryPath(){return"id"},get primary(){return this.id},get $(){var e=n(Pr,this.parent);return this.parent.$.pipe((0,ht.p)((e=>e.documentId===this.primary)),(0,ht.p)((e=>e.isLocal)),(0,dt.T)((e=>yt(e))),(0,ut.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,dt.T)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.t)(le.bz))},get $$(){var e=this,t=Sr(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Sr(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},getLatest(){var e=n(Pr,this.parent),t=e.docCache.getLatestDocumentData(this.primary);return e.docCache.getCachedRxDocument(t)},get(e){if(e="data."+e,this._data){if("string"!=typeof e)throw I("LD2",{objPath:e});var t=v(this._data,e);return t=j.deepFreezeWhenDevMode(t)}},get$(e){if(e="data."+e,j.isDevMode()){if(e.includes(".item."))throw R("LD3",{objPath:e});if(e===this.primaryPath)throw R("LD4")}return this.$.pipe((0,dt.T)((e=>e._data)),(0,dt.T)((t=>v(t,e))),(0,mt.F)())},get$$(e){var t=Sr(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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)))}},Rr=!1,Ir=()=>{if(!Rr){Rr=!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 R("LD6",{functionName:e})})(e)))}};function Sr(e){var t=e.parent;return t instanceof gr?t:t.database}var Er=new WeakMap,Pr=new WeakMap;function Cr(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,ht.p)((e=>e.isLocal))),(t=>function(e,t){Ir();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 Pr.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 R("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,ut.Z)(null),(0,Rt.Z)((async t=>t?{changeEvent:t}:{doc:await this.getLocal(e)})),(0,Rt.Z)((async t=>{if(t.changeEvent){var r=t.changeEvent;return r.isLocal&&r.documentId===e?{use:!0,doc:await this.getLocal(e)}:{use:!1}}return{use:!0,doc:t.doc}})),(0,ht.p)((e=>e.use)),(0,dt.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&&Cr(e.database)}},createRxCollection:{before:e=>{e.creator.localDocuments&&Cr(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 R("PL3",{name:e.name,plugin:e});if(jr.add(e),kr.add(e.name),!e.rxdb)throw I("PL1",{plugin:e});e.init&&e.init(),e.prototypes&&Object.entries(e.prototypes).forEach((e=>{let[t,r]=e;return r(wr[t])})),e.overwritable&&Object.assign(j,e.overwritable),e.hooks&&Object.entries(e.hooks).forEach((e=>{let[t,r]=e;r.after&&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:()=>y,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}],d={browser:.4,native:.4,performance:.35,server:.25,sourcecode:0,perpetual:0},h=.05;var u=r(1527),m=r(2658),p=r(2303),f=r(4848);function v(e){let{children:t,fallback:r}=e;return(0,p.A)()?(0,f.jsx)(f.Fragment,{children:t?.()}):r??null}const y="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(y);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(d).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)("a",{href:"/rx-server.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:"RxServer Fastify Adapter"}),(0,f.jsx)("p",{children:"An adapter to use the RxServer with fastify instead of express. Used to have better performance when serving requests."})]})})}),(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:"RxServer Koa Adapter"}),(0,f.jsx)("p",{children:"An adapter to use the RxServer with Koa instead of express. Used to have better performance when serving requests."})]})})}),(0,f.jsx)("a",{href:"/reactivity.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:"Reactivity Vue"}),(0,f.jsx)("p",{children:"An extension for Vue.js to get vue shallow-ref objects to observe RxDB state instead of rxjs observables."})]})})}),(0,f.jsx)("a",{href:"/reactivity.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:"Reactivity Preact Signals"}),(0,f.jsx)("p",{children:"An extension for react/preact to get preact signals to observe RxDB state instead of rxjs observables."})]})})})]})]})}),(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-server",type:"checkbox",className:"package-checkbox",defaultChecked:!0}),(0,f.jsx)("h4",{children:"Server Package"}),(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-server.html",target:"_blank",children:"RxServer Adapter Fastify"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-server.html",target:"_blank",children:"RxServer Adapter Koa"})})]})]})}),(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.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/logger.html",target:"_blank",children:"Logger"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/reactivity.html",target:"_blank",children:"Reactivity Vue"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/reactivity.html",target:"_blank",children:"Reactivity Preact Signals"})})]})]})}),(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,u.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=d[e];r+=t})),console.log("aimInPercent: "+r);let a=350+1.4*t*(r/100);if(2===e.packages.length?a*=.95:e.packages.length>2&&(a*=.9),e.companySize>1){let t=1+Math.pow(1*e.companySize-1,.45)/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")),v=(e,t)=>{console.log("setPrice:"),console.dir(t),e.innerHTML=Math.ceil(t).toString()},g=s.totalPrice/i.licensePeriod;v(f,"infinity"!==i.projectAmount?g/parseInt(i.projectAmount,10)/12:0);const b=await(0,m.C3)();await b.upsertLocal(y,{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)(v,{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:()=>d,dY:()=>a,em:()=>o,h$:()=>h,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 d(e){return void 0===e&&(e=void 0),l=l.then((()=>c(e)))}function h(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},5734:(e,t,r)=>{r.d(t,{t:()=>n});var a=0;function n(){var e=Date.now();(e+=.01)<=a&&(e=a+.01);var t=parseFloat(e.toFixed(2));return a=t,t}}}]); \ No newline at end of file +"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 d=e=>{var t=typeof e;return null!==e&&("object"===t||"function"===t)},h=new Set(["__proto__","prototype","constructor"]),u=new Set("0123456789");function m(e){var t=[],r="",a="start",n=!1;for(var i of e)switch(i){case"\\":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");n&&(r+=i),a="property",n=!n;break;case".":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="property";break}if(n){n=!1,r+=i;break}if(h.has(r))return[];t.push(r),r="",a="property";break;case"[":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="index";break}if(n){n=!1,r+=i;break}if("property"===a){if(h.has(r))return[];t.push(r),r=""}a="index";break;case"]":if("index"===a){t.push(Number.parseInt(r,10)),r="",a="indexEnd";break}if("indexEnd"===a)throw new Error("Invalid character after an index");default:if("index"===a&&!u.has(i))throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");"start"===a&&(a="property"),n&&(n=!1,r+="\\"),r+=i}switch(n&&(r+="\\"),a){case"property":if(h.has(r))return[];t.push(r);break;case"index":throw new Error("Index was not closed");case"start":t.push("")}return t}function p(e,t){if("number"!=typeof t&&Array.isArray(e)){var r=Number.parseInt(t,10);return Number.isInteger(r)&&e[r]===e[t]}return!1}function f(e,t){if(p(e,t))throw new Error("Cannot use string index")}function v(e,t,r){if(Array.isArray(t)&&(t=t.join(".")),!t.includes(".")&&!t.includes("["))return e[t];if(!d(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}}])}((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}}])}((0,w.A)(TypeError));function R(e,t){return new D(e,j.tunnelErrorMessage(e),t)}function I(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 P=/\./g,C="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 R("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=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=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),de=String.fromCharCode(65535),he=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])),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,d=e.map((e=>{var t=r[e],n=t?Object.keys(t):[],i={};t&&n.length?n.forEach((e=>{if(me.has(e)){var r=function(e,t){switch(e){case"$eq":return{startKey:t,endKey:t,inclusiveEnd:!0,inclusiveStart:!0};case"$lte":return{endKey:t,inclusiveEnd:!0};case"$gte":return{startKey:t,inclusiveStart:!0};case"$lt":return{endKey:t,inclusiveEnd:!1};case"$gt":return{startKey:t,inclusiveStart:!1};default:throw new Error("SNH")}}(e,t[e]);i=Object.assign(i,r)}})):i={startKey:l?he:de,endKey:a?de:he,inclusiveStart:!0,inclusiveEnd:!0};return void 0===i.startKey&&(i.startKey=he),void 0===i.endKey&&(i.endKey=de),void 0===i.inclusiveStart&&(i.inclusiveStart=!0),void 0===i.inclusiveEnd&&(i.inclusiveEnd=!0),l&&!i.inclusiveStart&&(l=!1),a&&!i.inclusiveEnd&&(a=!1),i})),h=d.map((e=>e.startKey)),u=d.map((e=>e.endKey)),m={index:e,startKeys:h,endKeys:u,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!i.has(e))).join(","),selectorSatisfiedByIndex:ve(e,t.selector,h,u)},p=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},i=10,s=(0,g.Sd)(r.startKeys,(e=>e!==he&&e!==de));n(s*i);var o=(0,g.Sd)(r.startKeys,(e=>e!==de&&e!==he));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 R("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 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 l=Object.keys(c).filter((e=>pe.has(e)));if(l.length>1)return!1;var d=l[0];if(d&&s.add(o),"$eq"!==d){if(i.length>0)return!1;i.push(d)}}var h=[],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(h.length>0)return!1;h.push(v)}}var y=0;for(var g of e){for(var b of[s,u]){if(!b.has(g)&&b.size>0)return!1;b.delete(g)}if(r[y]!==a[y]&&s.size>0&&u.size>0)return!1;y++}return!0}var ye=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),Re=!1;function Ie(e){return Re||((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}),Re=!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 R("SNH",{query:t});var r=[];t.sort.forEach((e=>{var t,a,n,i=Object.keys(e)[0],s=Object.values(e)[0];r.push({key:i,direction:s,getValueFn:(t=i,a=t.split("."),n=a.length,1===n?e=>e[t]:e=>{for(var t=e,r=0;r{for(var a=0;ar.test(e)}function Ce(e){return e===he?-1/0:e}function Oe(e,t,r){return e.includes(t)?r===de||!0===r?"1":"0":r}function Ne(e,t,r){if(!r){if("undefined"==typeof window)throw new Error("IDBKeyRange missing");r=window.IDBKeyRange}var a=t.startKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Ce),n=t.endKeys.map(((r,a)=>{var n=t.index[a];return Oe(e,n,r)})).map(Ce);return r.bound(a,n,!t.inclusiveStart,!t.inclusiveEnd)}async function 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=Pe(e.schema,t.query));var c=Ne(r.booleanIndexes,s,r.dexieDb._options.IDBKeyRange),l=s.index,d=[];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)||d.push(n),s.sortSatisfiedByIndex&&d.length===i?e():a.continue()}else e()}}))})),!s.sortSatisfiedByIndex){var h=Ee(e.schema,t.query);d=d.sort(h)}return{documents:d=d.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?R("CONFLICT",{collection:e.name,id:t,writeError:a,data:r}):422===a.status?R("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 R("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 R("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 d=r.close.bind(r);r.close=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),d()};var h=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),h()}}}var Ye=(0,ce.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 R("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=[],d=[],h=[],u={id:O(10),events:[],checkpoint:null,context:n,startTime:(0,ce.t)(),endTime:0},m=u.events,p=[],f=[],v=[],y=r.size>0,g=a.length,b=function(){var e,n=a[x],u=n.document,g=n.previous,b=u[t],w=u._deleted,j=g&&g._deleted,k=void 0;if(y&&(k=r.get(b)),k){var D=k._rev;if(!g||g&&D!==g._rev){var _={isError:!0,status:409,documentId:b,writeRow:n,documentInDb:k};return h.push(_),1}var I=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(u._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(u._attachments).forEach((e=>{let[t,r]=e;var a=g?g._attachments[t]:void 0;if(a){var n=I.document._attachments[t].digest;r.data&&a.digest!==n&&v.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})}else p.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})})))),e?h.push(e):(c?(d.push(We(I)),s&&s(u)):(d.push(I),s&&s(u)),o=I);var S=null,E=null,P=null;if(j&&!w)P="INSERT",S=c?He(u):u;else if(!g||j||w){if(!w)throw R("SNH",{args:{writeRow:n}});P="DELETE",S=(0,le.ZN)(u),E=g}else P="UPDATE",S=c?He(u):u,E=g;var C={documentId:b,documentData:S,previousDocumentData:E,operation:P};m.push(C)}else{var O=!!w;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},h.push(e))})),e||(c?(l.push(We(n)),i&&i(u)):(l.push(n),i&&i(u)),o=n),!O){var N={documentId:b,operation:"INSERT",documentData:c?He(u):u,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.18.2",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 R("UT5",{args:{params:e}});if((t=e.schema).encrypted&&t.encrypted.length>0||t.attachments&&t.attachments.encrypted)throw R("UT6",{args:{params:e}});var t;if(e.schema.attachments&&e.schema.attachments.compression)throw R("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 R("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)))}}])}();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 dt=r(7708),ht=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+=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 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,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 d of a)try{l=await d.modifier(c(l))}catch(h){d.reject(h),d.reject=()=>{},d.resolve=()=>{}}try{await this.preWrite(l,o)}catch(h){return void a.forEach((e=>e.reject(h)))}e.push({previous:o,document:l})})));var r=e.length>0?await this.storageInstance.bulkWrite(e,"incremental-write"):{error:[],success:[]};return await Promise.all(r.success.map((e=>{var r=e[this.primaryPath];this.postWrite(e),n(t,r).forEach((t=>t.resolve(e)))}))),r.error.forEach((e=>{var r,a=e.documentId,s=n(t,a),o=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=R("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,dt.T)((e=>e._data._deleted)))},get deleted$$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,e.collection.database)},get deleted(){if(this.isInstanceOfRxDocument)return this._data._deleted},getLatest(){var e=this.collection._docCache.getLatestDocumentData(this.primary);return this.collection._docCache.getCachedRxDocument(e)},get $(){return this.collection.$.pipe((0,ht.p)((e=>!e.isLocal)),(0,ht.p)((e=>e.documentId===this.primary)),(0,dt.T)((e=>yt(e))),(0,ut.Z)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,dt.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,e.collection.database)},get$(e){if(j.isDevMode()){if(e.includes(".item."))throw R("DOC1",{path:e});if(e===this.primaryPath)throw R("DOC2");if(this.collection.schema.finalFields.includes(e))throw R("DOC3",{path:e});if(!M(this.collection.schema.jsonSchema,e))throw R("DOC4",{path:e})}return this.$.pipe((0,dt.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),this.collection.database)},populate(e){var t=M(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.$A;if(!t)throw R("DOC5",{path:e});if(!t.ref)throw R("DOC6",{path:e,schemaObj:t});var a=this.collection.database.collections[t.ref];if(!a)throw R("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 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 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 R("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(R("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 R("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),Rt=r(2442),It=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 Pt(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=Pe(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,It.kC)(t);return"runFullQueryAgain"===i||("doNothing"!==i?(s=!0,(0,It.Cs)(i,r,e,a,n),!1):void 0)}))?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:s,newResults:a}}var Ct=function(){function e(){this._map=new Map}return e.prototype.getByQuery=function(e){var t=e.toString();return i(this._map,t,(()=>e))},e}();function Ot(e,t){t.uncached=!0;var r=t.toString();e._map.delete(r)}function Nt(e){return e.refCount$.observers.length}var 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=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 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),d=i(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),h=d.byRev,u=h.get(l),m=u?u.deref():void 0;return m||(o=n(o),m=s(o),h.set(l,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,ft.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))}}])}();function qt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Ft=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=qt(this.collection._docCache,t)}),[{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 R("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 R("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Kt(this).then((()=>(0,Dt._)(this.$))).then((t=>{if(!t&&e)throw R("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 vt("update")},t.where=function(e){throw vt("query-builder")},t.sort=function(e){throw vt("query-builder")},t.skip=function(e){throw vt("query-builder")},t.limit=function(e){throw vt("query-builder")},(0,b.A)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,ht.p)((e=>!e.isLocal)),(0,ut.Z)(null),(0,Rt.Z)((()=>Kt(this))),(0,dt.T)((()=>this._result)),(0,pt.t)(le.bz),(0,mt.F)(((e,t)=>!(!e||e.time!==(0,le.ZN)(t).time))),(0,ht.p)((e=>!!e)),(0,dt.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,ht.p)((()=>!1))))}return this._$}},{key:"$$",get:function(){return this.collection.database.getReactivityFactory().fromObservable(this.$,void 0,this.collection.database)}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return l(this,"queryMatcher",Pe(0,Se(this.collection.schema.jsonSchema,this.mangoQuery)))}},{key:"asRxQuery",get:function(){return this}}])}();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=Pt(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 d=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(d,"rx-database-remove-collection-all")}}var nr=function(){function e(e){this.subs=[],this.limit=100,this.counter=0,this.eventCounterMap=new WeakMap,this.buffer=[],this.collection=e,this.subs.push(this.collection.$.pipe((0,ht.p)((e=>!e.isLocal))).subscribe((e=>this._handleChangeEvent(e))))}var t=e.prototype;return t._handleChangeEvent=function(e){for(this.counter++,this.buffer.push(e),this.eventCounterMap.set(e,this.counter);this.buffer.length>this.limit;)this.buffer.shift()},t.getArrayIndexByPointer=function(e){var t=this.buffer[0],r=this.eventCounterMap.get(t);return et(e)))},t.reduceByLastOfDoc=function(e){return e.slice(0)},t.destroy=function(){this.subs.forEach((e=>e.unsubscribe()))},e}();var 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"],dr=["insert","save","remove","create"],hr=!1,ur=function(){function e(e,t,r,a,n,i,s,o,c,l,d,h){void 0===n&&(n={}),void 0===i&&(i={}),void 0===s&&(s={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===l&&(l=Bt),void 0===d&&(d={}),void 0===h&&(h=cr),this.storageInstance={},this.timeouts=new Set,this.incrementalWriteQueue={},this._incrementalUpsertQueues=new Map,this.synced=!1,this.hooks={},this._subs=[],this._docCache={},this._queryCache=new Ct,this.$={},this.checkpoint$={},this._changeEventBuffer={},this.onDestroy=[],this.destroyed=!1,this.database=e,this.name=t,this.schema=r,this.internalStorageInstance=a,this.instanceCreationOptions=n,this.migrationStrategies=i,this.methods=s,this.attachments=o,this.options=c,this.cacheReplacementPolicy=l,this.statics=d,this.conflictHandler=h,function(e){if(hr)return;hr=!0;var t=Object.getPrototypeOf(e);dr.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,ht.p)((e=>e.collectionName===this.name)));this.$=t.pipe((0,Rt.Z)((e=>e.events))),this.checkpoint$=t.pipe((0,dt.T)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Tt(this.schema.primaryPath,this.$.pipe((0,ht.p)((e=>!e.isLocal))),(e=>or(this.asRxCollection,e)));var r=await this.database.storageToken,a=this.storageInstance.changeStream().subscribe((e=>{var t={id:e.id,internal:!1,collectionName:this.name,storageToken:r,events:e.events.map((e=>Fe(!1,e,this))),databaseToken:this.database.token,checkpoint:e.checkpoint,context:e.context,endTime:e.endTime,startTime:e.startTime};this.database.$emit(t)}));return this._subs.push(a),this._subs.push(this.storageInstance.conflictResultionTasks().subscribe((e=>{this.conflictHandler(e.input,e.context).then((t=>{this.storageInstance.resolveConflictResultionTask({id:e.id,output:t})}))}))),ft.em},t.cleanup=function(e){throw vt("cleanup")},t.migrationNeeded=function(){throw vt("migration-schema")},t.getMigrationState=function(){throw vt("migration-schema")},t.startMigration=function(e){return void 0===e&&(e=10),this.getMigrationState().startMigration(e)},t.migratePromise=function(e){return void 0===e&&(e=10),this.getMigrationState().migratePromise(e)},t.insert=async function(e){var t=await this.bulkInsert([e]),r=t.error[0];return 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 R("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 R("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 R("COL5",{queryObj:e});return e||(e={selector:{}}),Ht("find",e,this)},t.findOne=function(e){if("number"==typeof e||Array.isArray(e))throw I("COL6",{queryObj:e});var t;if("string"==typeof e)t=Ht("findOne",{selector:{[this.schema.primaryPath]:e},limit:1},this);else{if(e||(e={selector:{}}),e.limit)throw R("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 I("COL7",{key:t,when:e});if(!lr.includes(e))throw I("COL8",{key:t,when:e});if(!dr.includes(t))throw R("COL9",{key:t});if("post"===e&&"create"===t&&!0===a)throw R("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,ht.p)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,ht.p)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,ht.p)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}])}();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),yr=new Set,gr=function(){function e(e,t,r,a,n,i,s,o,c,l,d,h,u){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,Rt.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=i,this.eventReduce=s,this.options=o,this.internalStore=c,this.hashFunction=l,this.cleanupPolicy=d,this.allowSlowCount=h,this.reactivity=u,"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 R("DM5",{args:{database:e.name,databaseStateVersion:s.documentInDb.data.rxdbVersion,codeVersion:e.rxdbVersion}});if(r&&r!==s.documentInDb.data.passwordHash)throw R("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 R("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 R("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 d=lt(l,this.hashFunction);if(r[c]=d,this.collections[i])throw R("DB3",{name:i});var h=tr(i,l),u={id:Gt(h,Zt),key:h,context:Zt,data:{name:c,schemaHash:await d.hash,schema:d.jsonSchema,version:d.version,connectedStorages:[]},_deleted:!1,_meta:B(),_rev:"",_attachments:{}};a.push({document:u});var m=Object.assign({},o,{name:c,schema:d,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 R("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 R("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:d={},localDocuments:h=!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: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 ur(t,r,a,e,n,i,c,l,d,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 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:d,cacheReplacementPolicy:u,localDocuments:h,statics:o}}),p))).catch((t=>e.close().then((()=>Promise.reject(t)))))}))}(t);o[e]=r,this.collections[e]=r,this[e]||Object.defineProperty(this,e,{get:()=>this.collections[e]})}))),o},t.lockedRun=function(e){return this.idleQueue.wrapCall(e)},t.requestIdlePromise=function(){return this.idleQueue.requestIdlePromise()},t.exportJSON=function(e){throw vt("json-dump")},t.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((()=>yr.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}}])}();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:d=!1,localDocuments:h=!1,hashFunction:u=fr,reactivity:m}=e;st("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:h}),o||function(e,t){var r=t.name+"|"+e;if(yr.has(r))throw R("DB8",{name:e,storage:t.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}(a,t),yr.add(t.name+"|"+a);var p=O(10);return br(p,t,a,r,i,n).catch((e=>{throw yr.delete(t.name+"|"+a),e})).then((e=>{var f=new gr(a,p,t,r,n,i,s,c,e,u,l,d,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:h}}).then((()=>f))}))}var wr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Wt.prototype,RxCollection:ur.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 R("LD1",{document:this})},get primaryPath(){return"id"},get primary(){return this.id},get $(){var e=n(Pr,this.parent);return this.parent.$.pipe((0,ht.p)((e=>e.documentId===this.primary)),(0,ht.p)((e=>e.isLocal)),(0,dt.T)((e=>yt(e))),(0,ut.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,dt.T)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.t)(le.bz))},get $$(){var e=this,t=Sr(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Sr(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},getLatest(){var e=n(Pr,this.parent),t=e.docCache.getLatestDocumentData(this.primary);return e.docCache.getCachedRxDocument(t)},get(e){if(e="data."+e,this._data){if("string"!=typeof e)throw I("LD2",{objPath:e});var t=v(this._data,e);return t=j.deepFreezeWhenDevMode(t)}},get$(e){if(e="data."+e,j.isDevMode()){if(e.includes(".item."))throw R("LD3",{objPath:e});if(e===this.primaryPath)throw R("LD4")}return this.$.pipe((0,dt.T)((e=>e._data)),(0,dt.T)((t=>v(t,e))),(0,mt.F)())},get$$(e){var t=Sr(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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)))}},Rr=!1,Ir=()=>{if(!Rr){Rr=!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 R("LD6",{functionName:e})})(e)))}};function Sr(e){var t=e.parent;return t instanceof gr?t:t.database}var Er=new WeakMap,Pr=new WeakMap;function Cr(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,ht.p)((e=>e.isLocal))),(t=>function(e,t){Ir();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 Pr.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 R("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,ut.Z)(null),(0,Rt.Z)((async t=>t?{changeEvent:t}:{doc:await this.getLocal(e)})),(0,Rt.Z)((async t=>{if(t.changeEvent){var r=t.changeEvent;return r.isLocal&&r.documentId===e?{use:!0,doc:await this.getLocal(e)}:{use:!1}}return{use:!0,doc:t.doc}})),(0,ht.p)((e=>e.use)),(0,dt.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&&Cr(e.database)}},createRxCollection:{before:e=>{e.creator.localDocuments&&Cr(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 R("PL3",{name:e.name,plugin:e});if(jr.add(e),kr.add(e.name),!e.rxdb)throw I("PL1",{plugin:e});e.init&&e.init(),e.prototypes&&Object.entries(e.prototypes).forEach((e=>{let[t,r]=e;return r(wr[t])})),e.overwritable&&Object.assign(j,e.overwritable),e.hooks&&Object.entries(e.hooks).forEach((e=>{let[t,r]=e;r.after&&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:()=>y,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}],d={browser:.4,native:.4,performance:.35,server:.25,sourcecode:0,perpetual:0},h=.05;var u=r(1527),m=r(2658),p=r(2303),f=r(4848);function v(e){let{children:t,fallback:r}=e;return(0,p.A)()?(0,f.jsx)(f.Fragment,{children:t?.()}):r??null}const y="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(y);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(d).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)("a",{href:"/rx-server.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:"RxServer Fastify Adapter"}),(0,f.jsx)("p",{children:"An adapter to use the RxServer with fastify instead of express. Used to have better performance when serving requests."})]})})}),(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:"RxServer Koa Adapter"}),(0,f.jsx)("p",{children:"An adapter to use the RxServer with Koa instead of express. Used to have better performance when serving requests."})]})})}),(0,f.jsx)("a",{href:"/reactivity.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:"Reactivity Vue"}),(0,f.jsx)("p",{children:"An extension for Vue.js to get vue shallow-ref objects to observe RxDB state instead of rxjs observables."})]})})}),(0,f.jsx)("a",{href:"/reactivity.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:"Reactivity Preact Signals"}),(0,f.jsx)("p",{children:"An extension for react/preact to get preact signals to observe RxDB state instead of rxjs observables."})]})})})]})]})}),(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-server",type:"checkbox",className:"package-checkbox",defaultChecked:!0}),(0,f.jsx)("h4",{children:"Server Package"}),(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-server.html",target:"_blank",children:"RxServer Adapter Fastify"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-server.html",target:"_blank",children:"RxServer Adapter Koa"})})]})]})}),(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.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/logger.html",target:"_blank",children:"Logger"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/reactivity.html",target:"_blank",children:"Reactivity Vue"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/reactivity.html",target:"_blank",children:"Reactivity Preact Signals"})})]})]})}),(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,u.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=d[e];r+=t})),console.log("aimInPercent: "+r);let a=350+1.4*t*(r/100);if(2===e.packages.length?a*=.95:e.packages.length>2&&(a*=.9),e.companySize>1){let t=1+Math.pow(1*e.companySize-1,.45)/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")),v=(e,t)=>{console.log("setPrice:"),console.dir(t),e.innerHTML=Math.ceil(t).toString()},g=s.totalPrice/i.licensePeriod;v(f,"infinity"!==i.projectAmount?g/parseInt(i.projectAmount,10)/12:0);const b=await(0,m.C3)();await b.upsertLocal(y,{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)(v,{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:()=>d,dY:()=>a,em:()=>o,h$:()=>h,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 d(e){return void 0===e&&(e=void 0),l=l.then((()=>c(e)))}function h(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},5734:(e,t,r)=>{r.d(t,{t:()=>n});var a=0;function n(){var e=Date.now();(e+=.01)<=a&&(e=a+.01);var t=parseFloat(e.toFixed(2));return a=t,t}}}]); \ No newline at end of file diff --git a/docs/assets/js/1df93b7f.0b4dbce7.js b/docs/assets/js/1df93b7f.38923739.js similarity index 99% rename from docs/assets/js/1df93b7f.0b4dbce7.js rename to docs/assets/js/1df93b7f.38923739.js index 0821a2e5afa..a4b96543548 100644 --- a/docs/assets/js/1df93b7f.0b4dbce7.js +++ b/docs/assets/js/1df93b7f.38923739.js @@ -1 +1 @@ -"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[4583],{2658:(e,t,r)=>{r.d(t,{Tj:()=>Kr,C3:()=>Hr,IA:()=>zr});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 d=e=>{var t=typeof e;return null!==e&&("object"===t||"function"===t)},h=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(h.has(r))return[];t.push(r),r="",a="property";break;case"[":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="index";break}if(n){n=!1,r+=s;break}if("property"===a){if(h.has(r))return[];t.push(r),r=""}a="index";break;case"]":if("index"===a){t.push(Number.parseInt(r,10)),r="",a="indexEnd";break}if("indexEnd"===a)throw new Error("Invalid character after an index");default:if("index"===a&&!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(h.has(r))return[];t.push(r);break;case"index":throw new Error("Index was not closed");case"start":t.push("")}return t}function p(e,t){if("number"!=typeof t&&Array.isArray(e)){var r=Number.parseInt(t,10);return Number.isInteger(r)&&e[r]===e[t]}return!1}function f(e,t){if(p(e,t))throw new Error("Cannot use string index")}function v(e,t,r){if(Array.isArray(t)&&(t=t.join(".")),!t.includes(".")&&!t.includes("["))return e[t];if(!d(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}}])}((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}}])}((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 z="docs",H="changes",K="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),de=String.fromCharCode(65535),he=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,d=e.map((e=>{var t=r[e],n=t?Object.keys(t):[],s={};t&&n.length?n.forEach((e=>{if(me.has(e)){var r=function(e,t){switch(e){case"$eq":return{startKey:t,endKey:t,inclusiveEnd:!0,inclusiveStart:!0};case"$lte":return{endKey:t,inclusiveEnd:!0};case"$gte":return{startKey:t,inclusiveStart:!0};case"$lt":return{endKey:t,inclusiveEnd:!1};case"$gt":return{startKey:t,inclusiveStart:!1};default:throw new Error("SNH")}}(e,t[e]);s=Object.assign(s,r)}})):s={startKey:l?he:de,endKey:a?de:he,inclusiveStart:!0,inclusiveEnd:!0};return void 0===s.startKey&&(s.startKey=he),void 0===s.endKey&&(s.endKey=de),void 0===s.inclusiveStart&&(s.inclusiveStart=!0),void 0===s.inclusiveEnd&&(s.inclusiveEnd=!0),l&&!s.inclusiveStart&&(l=!1),a&&!s.inclusiveEnd&&(a=!1),s})),h=d.map((e=>e.startKey)),u=d.map((e=>e.endKey)),m={index:e,startKeys:h,endKeys:u,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!s.has(e))).join(","),selectorSatisfiedByIndex:ve(e,t.selector,h,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!==he&&e!==de));n(i*s);var o=(0,y.Sd)(r.startKeys,(e=>e!==de&&e!==he));n(o*s);var c=(0,y.Sd)(r.startKeys,((e,t)=>e===r.endKeys[t]));n(c*s*1.5);var l=r.sortSatisfiedByIndex?5:0;return n(l),a}(0,0,m);(p>=c||t.index)&&(c=p,i=m)})),!i)throw 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 d=l[0];if(d&&i.add(o),"$eq"!==d){if(s.length>0)return!1;s.push(d)}}var h=[],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(h.length>0)return!1;h.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===he?-1/0:e}function Oe(e,t,r){return e.includes(t)?r===de||!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,d=[];if(await r.dexieDb.transaction("r",r.dexieTable,(async e=>{var t,a=e.idbtrans.objectStore(z);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)||d.push(n),i.sortSatisfiedByIndex&&d.length===s?e():a.continue()}else e()}}))})),!i.sortSatisfiedByIndex){var h=Ee(e.schema,t.query);d=d.sort(h)}return{documents:d=d.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:ze(e.document)}}function ze(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 He(e){var t=i(e);return t._meta=i(e._meta),t}function Ke(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 d=r.close.bind(r);r.close=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",i),a||await Ve(t.databaseInstanceToken,r),d()};var h=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",i),a||await Ve(t.databaseInstanceToken,r),h()}}}var Ye=(0,ce.t)(),Xe=function(){function e(e,t,r,a,n,s,i){this.changes$=new oe.B,this.instanceId=Ye++,this.storage=e,this.databaseName=t,this.collectionName=r,this.schema=a,this.internals=n,this.options=s,this.settings=i,this.primaryPath=q(this.schema.primaryKey)}var t=e.prototype;return t.bulkWrite=async function(e,t){tt(this),e.forEach((e=>{if(!e.document._rev||e.previous&&!e.previous._rev)throw 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=[],d=[],h=[],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 h.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?h.push(e):(c?(d.push(Qe(R)),i&&i(u)):(d.push(R),i&&i(u)),o=R);var I=null,E=null,C=null;if(w&&!j)C="INSERT",I=c?ze(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?ze(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},h.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?ze(u):u,previousDocumentData:c&&y?ze(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(z);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={[z]:ae(n),[H]:"++sequence, id",[K]:"id"};return t.version(1).stores(s),await t.open(),{dexieDb:t,dexieTable:t[z],dexieAttachmentsTable:t[K],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.18.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)))}}])}();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 dt=r(7708),ht=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 d of a)try{l=await d.modifier(c(l))}catch(h){d.reject(h),d.reject=()=>{},d.resolve=()=>{}}try{await this.preWrite(l,o)}catch(h){return void a.forEach((e=>e.reject(h)))}e.push({previous:o,document:l})})));var r=e.length>0?await this.storageInstance.bulkWrite(e,"incremental-write"):{error:[],success:[]};return await Promise.all(r.success.map((e=>{var r=e[this.primaryPath];this.postWrite(e),n(t,r).forEach((t=>t.resolve(e)))}))),r.error.forEach((e=>{var r,a=e.documentId,i=n(t,a),o=I(e);if(o){var c=s(this.queueByDocId,a,(()=>[]));i.reverse().forEach((e=>{e.lastKnownDocumentState=(0,le.ZN)(o.documentInDb),(0,le.ZN)(c).unshift(e)}))}else{var l=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,dt.T)((e=>e._data._deleted)))},get deleted$$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,e.collection.database)},get deleted(){if(this.isInstanceOfRxDocument)return this._data._deleted},getLatest(){var e=this.collection._docCache.getLatestDocumentData(this.primary);return this.collection._docCache.getCachedRxDocument(e)},get $(){return this.collection.$.pipe((0,ht.p)((e=>!e.isLocal)),(0,ht.p)((e=>e.documentId===this.primary)),(0,dt.T)((e=>gt(e))),(0,ut.Z)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,dt.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,e.collection.database)},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,dt.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),this.collection.database)},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),d=s(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),h=d.byRev,u=h.get(l),m=u?u.deref():void 0;return m||(o=n(o),m=i(o),h.set(l,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,ft.vN)().then((()=>{e.registerIdlePromise=void 0;var t=e.registerIdleTasks;0!==t.length&&(e.registerIdleTasks=[],t.forEach((e=>{a.register(e,{docId:e.primary,revisionHeight:Be(e.revision)})})))}))))),m};return o}(this))}}])}();function qt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Wt=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=qt(this.collection._docCache,t)}),[{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 Kt(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,ht.p)((e=>!e.isLocal)),(0,ut.Z)(null),(0,Dt.Z)((()=>Kt(this))),(0,dt.T)((()=>this._result)),(0,pt.t)(le.bz),(0,mt.F)(((e,t)=>!(!e||e.time!==(0,le.ZN)(t).time))),(0,ht.p)((e=>!!e)),(0,dt.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,ht.p)((()=>!1))))}return this._$}},{key:"$$",get:function(){return this.collection.database.getReactivityFactory().fromObservable(this.$,void 0,this.collection.database)}},{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}}])}();function zt(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 Ht(e){var t=e.asRxQuery.collection._changeEventBuffer.counter;return e._latestChangeEvent>=t}function Kt(e){return e.collection.database.destroyed||Ht(e)?ft.Dr:(e._ensureEqualQueue=e._ensureEqualQueue.then((()=>function(e){if(e._lastEnsureEqual=(0,ce.t)(),e.collection.database.destroyed||Ht(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 d=o.map((e=>{var t=He(e);return t._deleted=!0,t._meta.lwt=(0,ce.t)(),t._rev=Ae(r,e),{previous:e,document:t}}));await t.bulkWrite(d,"rx-database-remove-collection-all")}}var nr=function(){function e(e){this.subs=[],this.limit=100,this.counter=0,this.eventCounterMap=new WeakMap,this.buffer=[],this.collection=e,this.subs.push(this.collection.$.pipe((0,ht.p)((e=>!e.isLocal))).subscribe((e=>this._handleChangeEvent(e))))}var t=e.prototype;return t._handleChangeEvent=function(e){for(this.counter++,this.buffer.push(e),this.eventCounterMap.set(e,this.counter);this.buffer.length>this.limit;)this.buffer.shift()},t.getArrayIndexByPointer=function(e){var t=this.buffer[0],r=this.eventCounterMap.get(t);return et(e)))},t.reduceByLastOfDoc=function(e){return e.slice(0)},t.destroy=function(){this.subs.forEach((e=>e.unsubscribe()))},e}();var sr=new WeakMap;function ir(e){var t=e.schema.getDocumentPrototype(),r=function(e){var t={};return Object.entries(e.methods).forEach((e=>{let[r,a]=e;t[r]=a})),t}(e),a={};return[t,r,xt].forEach((e=>{Object.getOwnPropertyNames(e).forEach((t=>{var r=Object.getOwnPropertyDescriptor(e,t),n=!0;(t.startsWith("_")||t.endsWith("_")||t.startsWith("$")||t.endsWith("$"))&&(n=!1),"function"==typeof r.value?Object.defineProperty(a,t,{get(){return r.value.bind(this)},enumerable:n,configurable:!1}):(r.enumerable=n,r.configurable=!1,r.writable&&(r.writable=!1),Object.defineProperty(a,t,r))}))})),a}function or(e,t){var r=function(e,t,r){var a=new e(t,r);return it("createRxDocument",a),a}(function(e){return s(sr,e,(()=>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(ze(e.newDocumentState),ze(e.realMasterState))?Promise.resolve({isEqual:!0}):Promise.resolve({isEqual:!1,documentData:e.realMasterState})};var lr=["pre","post"],dr=["insert","save","remove","create"],hr=!1,ur=function(){function e(e,t,r,a,n,s,i,o,c,l,d,h){void 0===n&&(n={}),void 0===s&&(s={}),void 0===i&&(i={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===l&&(l=Bt),void 0===d&&(d={}),void 0===h&&(h=cr),this.storageInstance={},this.timeouts=new Set,this.incrementalWriteQueue={},this._incrementalUpsertQueues=new Map,this.synced=!1,this.hooks={},this._subs=[],this._docCache={},this._queryCache=new 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=d,this.conflictHandler=h,function(e){if(hr)return;hr=!0;var t=Object.getPrototypeOf(e);dr.forEach((e=>{lr.map((r=>{var a=r+P(e);t[a]=function(t,a){return this.addHook(r,e,t,a)}}))}))}(this.asRxCollection)}var t=e.prototype;return t.prepare=async function(){this.storageInstance=Ke(this.database,this.internalStorageInstance,this.schema.jsonSchema),this.incrementalWriteQueue=new yt(this.storageInstance,this.schema.primaryPath,((e,t)=>wt(this,e,t)),(e=>this._runHooks("post","save",e)));var e,t=this.database.eventBulks$.pipe((0,ht.p)((e=>e.collectionName===this.name)));this.$=t.pipe((0,Dt.Z)((e=>e.events))),this.checkpoint$=t.pipe((0,dt.T)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Mt(this.schema.primaryPath,this.$.pipe((0,ht.p)((e=>!e.isLocal))),(e=>or(this.asRxCollection,e)));var r=await this.database.storageToken,a=this.storageInstance.changeStream().subscribe((e=>{var t={id:e.id,internal:!1,collectionName:this.name,storageToken:r,events:e.events.map((e=>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:{}}),zt("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=zt("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=zt("findOne",e,this)}return t},t.count=function(e){return e||(e={selector:{}}),zt("count",e,this)},t.findByIds=function(e){return zt("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(!dr.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,ht.p)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,ht.p)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,ht.p)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}])}();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,d,h,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=d,this.allowSlowCount=h,this.reactivity=u,"pseudoInstance"!==this.name&&(this.internalStore=Ke(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=He(r);a._deleted=!0,await this.internalStore.bulkWrite([{document:a,previous:r}],"rx-database-remove-collection")},t.addCollections=async function(e){var t={},r={},a=[],n={};await Promise.all(Object.entries(e).map((async e=>{let[s,o]=e;var c=s,l=o.schema;t[c]=l;var d=lt(l,this.hashFunction);if(r[c]=d,this.collections[s])throw D("DB3",{name:s});var h=tr(s,l),u={id:Gt(h,Ut),key:h,context:Ut,data:{name:c,schemaHash:await d.hash,schema:d.jsonSchema,version:d.version,connectedStorages:[]},_deleted:!1,_meta:B(),_rev:"",_attachments:{}};a.push({document:u});var m=Object.assign({},o,{name:c,schema:d,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:d={},localDocuments:h=!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,d,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:d,cacheReplacementPolicy:u,localDocuments:h,statics:o}}),p))).catch((t=>e.close().then((()=>Promise.reject(t)))))}))}(t);o[e]=r,this.collections[e]=r,this[e]||Object.defineProperty(this,e,{get:()=>this.collections[e]})}))),o},t.lockedRun=function(e){return this.idleQueue.wrapCall(e)},t.requestIdlePromise=function(){return this.idleQueue.requestIdlePromise()},t.exportJSON=function(e){throw vt("json-dump")},t.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}}])}();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:d=!1,localDocuments:h=!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:h}),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,d,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:s,eventReduce:i,ignoreDuplicate:o,options:c,localDocuments:h}}).then((()=>f))}))}var 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,ht.p)((e=>e.documentId===this.primary)),(0,ht.p)((e=>e.isLocal)),(0,dt.T)((e=>gt(e))),(0,ut.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,dt.T)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.t)(le.bz))},get $$(){var e=this,t=Ir(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Ir(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},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,dt.T)((e=>e._data)),(0,dt.T)((t=>v(t,e))),(0,mt.F)())},get$$(e){var t=Ir(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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=Ke(t,a,Ar);var n=new Mt("id",e.$.pipe((0,ht.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,ht.p)((e=>e.use)),(0,dt.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 zr(){return"undefined"!=typeof window&&window.indexedDB}function Hr(){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 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})},6866:(e,t,r)=>{r.r(t),r.d(t,{default:()=>x});var a=r(4586),n=r(1595),s=r(5260),i=(r(6879),r(4157)),o=r(943),c=r(7708),l=r(5520),d=r(3337),h=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,d.ZN)(await e.getLocal("beatingvalues"));(async()=>{for(await(0,h.ND)(k);y;){const e=_(),r=(0,h.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,d.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.jsx)("a",{className:"button",href:"/premium#premium-request-form-block",onClick:()=>(0,f.h)("request_premium_main_page",3),target:"_blank",children:"Buy Premium"}),(0,g.jsx)("div",{className:"clear"}),(0,g.jsx)("br",{})]}),(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:"/code",target:"_blank",children:(0,g.jsxs)("div",{className:"trophy github",children:[(0,g.jsx)("img",{className:"lazyload","data-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 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 lazyload","data-src":"./files/companies/altgras.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 lazyload","data-src":"./files/companies/moreapp.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 lazyload","data-src":"./files/companies/woopos.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 lazyload","data-src":"./files/companies/atroo.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",{className:"lazyload","data-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",{"data-src":"./files/logo/logo.svg",alt:"RxDB",className:"replicate-logo tilt-to-mouse lazyload"}),(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",{"data-src":"./files/icons/graphql-text.svg",alt:"GraphQL",className:"protocol lazyload"})})}),(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",{"data-src":"./files/icons/couchdb-text.svg",alt:"CouchDB",className:"protocol lazyload"})})}),(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:"/chat",target:"_blank",children:(0,g.jsxs)("div",{className:"trophy discord",children:[(0,g.jsx)("img",{className:"lazyload","data-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 offline-first dark",children:[(0,g.jsx)("div",{className:"offline-image-wrapper",children:(0,g.jsx)("img",{"data-src":"files/icons/wifi/wifi_1a202c.svg",className:"offline-image beating-second lazyload",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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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:()=>d,dY:()=>a,em:()=>o,h$:()=>h,vN:()=>c});Promise.resolve(!0);var s=Promise.resolve(!1),i=Promise.resolve(null),o=Promise.resolve();function c(e){return void 0===e&&(e=1e4),"function"==typeof requestIdleCallback?new Promise((t=>{requestIdleCallback((()=>t()),{timeout:e})})):n(0)}var l=o;function d(e){return void 0===e&&(e=void 0),l=l.then((()=>c(e)))}function h(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},5734:(e,t,r)=>{r.d(t,{t:()=>n});var a=0;function n(){var e=Date.now();(e+=.01)<=a&&(e=a+.01);var t=parseFloat(e.toFixed(2));return a=t,t}}}]); \ No newline at end of file +"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[4583],{2658:(e,t,r)=>{r.d(t,{Tj:()=>Kr,C3:()=>Hr,IA:()=>zr});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 d=e=>{var t=typeof e;return null!==e&&("object"===t||"function"===t)},h=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(h.has(r))return[];t.push(r),r="",a="property";break;case"[":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="index";break}if(n){n=!1,r+=s;break}if("property"===a){if(h.has(r))return[];t.push(r),r=""}a="index";break;case"]":if("index"===a){t.push(Number.parseInt(r,10)),r="",a="indexEnd";break}if("indexEnd"===a)throw new Error("Invalid character after an index");default:if("index"===a&&!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(h.has(r))return[];t.push(r);break;case"index":throw new Error("Index was not closed");case"start":t.push("")}return t}function p(e,t){if("number"!=typeof t&&Array.isArray(e)){var r=Number.parseInt(t,10);return Number.isInteger(r)&&e[r]===e[t]}return!1}function f(e,t){if(p(e,t))throw new Error("Cannot use string index")}function v(e,t,r){if(Array.isArray(t)&&(t=t.join(".")),!t.includes(".")&&!t.includes("["))return e[t];if(!d(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}}])}((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}}])}((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 z="docs",H="changes",K="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),de=String.fromCharCode(65535),he=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,d=e.map((e=>{var t=r[e],n=t?Object.keys(t):[],s={};t&&n.length?n.forEach((e=>{if(me.has(e)){var r=function(e,t){switch(e){case"$eq":return{startKey:t,endKey:t,inclusiveEnd:!0,inclusiveStart:!0};case"$lte":return{endKey:t,inclusiveEnd:!0};case"$gte":return{startKey:t,inclusiveStart:!0};case"$lt":return{endKey:t,inclusiveEnd:!1};case"$gt":return{startKey:t,inclusiveStart:!1};default:throw new Error("SNH")}}(e,t[e]);s=Object.assign(s,r)}})):s={startKey:l?he:de,endKey:a?de:he,inclusiveStart:!0,inclusiveEnd:!0};return void 0===s.startKey&&(s.startKey=he),void 0===s.endKey&&(s.endKey=de),void 0===s.inclusiveStart&&(s.inclusiveStart=!0),void 0===s.inclusiveEnd&&(s.inclusiveEnd=!0),l&&!s.inclusiveStart&&(l=!1),a&&!s.inclusiveEnd&&(a=!1),s})),h=d.map((e=>e.startKey)),u=d.map((e=>e.endKey)),m={index:e,startKeys:h,endKeys:u,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!s.has(e))).join(","),selectorSatisfiedByIndex:ve(e,t.selector,h,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!==he&&e!==de));n(i*s);var o=(0,y.Sd)(r.startKeys,(e=>e!==de&&e!==he));n(o*s);var c=(0,y.Sd)(r.startKeys,((e,t)=>e===r.endKeys[t]));n(c*s*1.5);var l=r.sortSatisfiedByIndex?5:0;return n(l),a}(0,0,m);(p>=c||t.index)&&(c=p,i=m)})),!i)throw 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 d=l[0];if(d&&i.add(o),"$eq"!==d){if(s.length>0)return!1;s.push(d)}}var h=[],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(h.length>0)return!1;h.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===he?-1/0:e}function Oe(e,t,r){return e.includes(t)?r===de||!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,d=[];if(await r.dexieDb.transaction("r",r.dexieTable,(async e=>{var t,a=e.idbtrans.objectStore(z);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)||d.push(n),i.sortSatisfiedByIndex&&d.length===s?e():a.continue()}else e()}}))})),!i.sortSatisfiedByIndex){var h=Ee(e.schema,t.query);d=d.sort(h)}return{documents:d=d.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:ze(e.document)}}function ze(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 He(e){var t=i(e);return t._meta=i(e._meta),t}function Ke(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 d=r.close.bind(r);r.close=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",i),a||await Ve(t.databaseInstanceToken,r),d()};var h=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",i),a||await Ve(t.databaseInstanceToken,r),h()}}}var Ye=(0,ce.t)(),Xe=function(){function e(e,t,r,a,n,s,i){this.changes$=new oe.B,this.instanceId=Ye++,this.storage=e,this.databaseName=t,this.collectionName=r,this.schema=a,this.internals=n,this.options=s,this.settings=i,this.primaryPath=q(this.schema.primaryKey)}var t=e.prototype;return t.bulkWrite=async function(e,t){tt(this),e.forEach((e=>{if(!e.document._rev||e.previous&&!e.previous._rev)throw 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=[],d=[],h=[],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 h.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?h.push(e):(c?(d.push(Qe(R)),i&&i(u)):(d.push(R),i&&i(u)),o=R);var I=null,E=null,C=null;if(w&&!j)C="INSERT",I=c?ze(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?ze(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},h.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?ze(u):u,previousDocumentData:c&&y?ze(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(z);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={[z]:ae(n),[H]:"++sequence, id",[K]:"id"};return t.version(1).stores(s),await t.open(),{dexieDb:t,dexieTable:t[z],dexieAttachmentsTable:t[K],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.18.2",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)))}}])}();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 dt=r(7708),ht=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 d of a)try{l=await d.modifier(c(l))}catch(h){d.reject(h),d.reject=()=>{},d.resolve=()=>{}}try{await this.preWrite(l,o)}catch(h){return void a.forEach((e=>e.reject(h)))}e.push({previous:o,document:l})})));var r=e.length>0?await this.storageInstance.bulkWrite(e,"incremental-write"):{error:[],success:[]};return await Promise.all(r.success.map((e=>{var r=e[this.primaryPath];this.postWrite(e),n(t,r).forEach((t=>t.resolve(e)))}))),r.error.forEach((e=>{var r,a=e.documentId,i=n(t,a),o=I(e);if(o){var c=s(this.queueByDocId,a,(()=>[]));i.reverse().forEach((e=>{e.lastKnownDocumentState=(0,le.ZN)(o.documentInDb),(0,le.ZN)(c).unshift(e)}))}else{var l=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,dt.T)((e=>e._data._deleted)))},get deleted$$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,e.collection.database)},get deleted(){if(this.isInstanceOfRxDocument)return this._data._deleted},getLatest(){var e=this.collection._docCache.getLatestDocumentData(this.primary);return this.collection._docCache.getCachedRxDocument(e)},get $(){return this.collection.$.pipe((0,ht.p)((e=>!e.isLocal)),(0,ht.p)((e=>e.documentId===this.primary)),(0,dt.T)((e=>gt(e))),(0,ut.Z)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,dt.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,e.collection.database)},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,dt.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),this.collection.database)},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),d=s(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),h=d.byRev,u=h.get(l),m=u?u.deref():void 0;return m||(o=n(o),m=i(o),h.set(l,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,ft.vN)().then((()=>{e.registerIdlePromise=void 0;var t=e.registerIdleTasks;0!==t.length&&(e.registerIdleTasks=[],t.forEach((e=>{a.register(e,{docId:e.primary,revisionHeight:Be(e.revision)})})))}))))),m};return o}(this))}}])}();function qt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Wt=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=qt(this.collection._docCache,t)}),[{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 Kt(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,ht.p)((e=>!e.isLocal)),(0,ut.Z)(null),(0,Dt.Z)((()=>Kt(this))),(0,dt.T)((()=>this._result)),(0,pt.t)(le.bz),(0,mt.F)(((e,t)=>!(!e||e.time!==(0,le.ZN)(t).time))),(0,ht.p)((e=>!!e)),(0,dt.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,ht.p)((()=>!1))))}return this._$}},{key:"$$",get:function(){return this.collection.database.getReactivityFactory().fromObservable(this.$,void 0,this.collection.database)}},{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}}])}();function zt(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 Ht(e){var t=e.asRxQuery.collection._changeEventBuffer.counter;return e._latestChangeEvent>=t}function Kt(e){return e.collection.database.destroyed||Ht(e)?ft.Dr:(e._ensureEqualQueue=e._ensureEqualQueue.then((()=>function(e){if(e._lastEnsureEqual=(0,ce.t)(),e.collection.database.destroyed||Ht(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 d=o.map((e=>{var t=He(e);return t._deleted=!0,t._meta.lwt=(0,ce.t)(),t._rev=Ae(r,e),{previous:e,document:t}}));await t.bulkWrite(d,"rx-database-remove-collection-all")}}var nr=function(){function e(e){this.subs=[],this.limit=100,this.counter=0,this.eventCounterMap=new WeakMap,this.buffer=[],this.collection=e,this.subs.push(this.collection.$.pipe((0,ht.p)((e=>!e.isLocal))).subscribe((e=>this._handleChangeEvent(e))))}var t=e.prototype;return t._handleChangeEvent=function(e){for(this.counter++,this.buffer.push(e),this.eventCounterMap.set(e,this.counter);this.buffer.length>this.limit;)this.buffer.shift()},t.getArrayIndexByPointer=function(e){var t=this.buffer[0],r=this.eventCounterMap.get(t);return et(e)))},t.reduceByLastOfDoc=function(e){return e.slice(0)},t.destroy=function(){this.subs.forEach((e=>e.unsubscribe()))},e}();var sr=new WeakMap;function ir(e){var t=e.schema.getDocumentPrototype(),r=function(e){var t={};return Object.entries(e.methods).forEach((e=>{let[r,a]=e;t[r]=a})),t}(e),a={};return[t,r,xt].forEach((e=>{Object.getOwnPropertyNames(e).forEach((t=>{var r=Object.getOwnPropertyDescriptor(e,t),n=!0;(t.startsWith("_")||t.endsWith("_")||t.startsWith("$")||t.endsWith("$"))&&(n=!1),"function"==typeof r.value?Object.defineProperty(a,t,{get(){return r.value.bind(this)},enumerable:n,configurable:!1}):(r.enumerable=n,r.configurable=!1,r.writable&&(r.writable=!1),Object.defineProperty(a,t,r))}))})),a}function or(e,t){var r=function(e,t,r){var a=new e(t,r);return it("createRxDocument",a),a}(function(e){return s(sr,e,(()=>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(ze(e.newDocumentState),ze(e.realMasterState))?Promise.resolve({isEqual:!0}):Promise.resolve({isEqual:!1,documentData:e.realMasterState})};var lr=["pre","post"],dr=["insert","save","remove","create"],hr=!1,ur=function(){function e(e,t,r,a,n,s,i,o,c,l,d,h){void 0===n&&(n={}),void 0===s&&(s={}),void 0===i&&(i={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===l&&(l=Bt),void 0===d&&(d={}),void 0===h&&(h=cr),this.storageInstance={},this.timeouts=new Set,this.incrementalWriteQueue={},this._incrementalUpsertQueues=new Map,this.synced=!1,this.hooks={},this._subs=[],this._docCache={},this._queryCache=new 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=d,this.conflictHandler=h,function(e){if(hr)return;hr=!0;var t=Object.getPrototypeOf(e);dr.forEach((e=>{lr.map((r=>{var a=r+P(e);t[a]=function(t,a){return this.addHook(r,e,t,a)}}))}))}(this.asRxCollection)}var t=e.prototype;return t.prepare=async function(){this.storageInstance=Ke(this.database,this.internalStorageInstance,this.schema.jsonSchema),this.incrementalWriteQueue=new yt(this.storageInstance,this.schema.primaryPath,((e,t)=>wt(this,e,t)),(e=>this._runHooks("post","save",e)));var e,t=this.database.eventBulks$.pipe((0,ht.p)((e=>e.collectionName===this.name)));this.$=t.pipe((0,Dt.Z)((e=>e.events))),this.checkpoint$=t.pipe((0,dt.T)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Mt(this.schema.primaryPath,this.$.pipe((0,ht.p)((e=>!e.isLocal))),(e=>or(this.asRxCollection,e)));var r=await this.database.storageToken,a=this.storageInstance.changeStream().subscribe((e=>{var t={id:e.id,internal:!1,collectionName:this.name,storageToken:r,events:e.events.map((e=>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:{}}),zt("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=zt("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=zt("findOne",e,this)}return t},t.count=function(e){return e||(e={selector:{}}),zt("count",e,this)},t.findByIds=function(e){return zt("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(!dr.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,ht.p)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,ht.p)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,ht.p)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}])}();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,d,h,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=d,this.allowSlowCount=h,this.reactivity=u,"pseudoInstance"!==this.name&&(this.internalStore=Ke(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=He(r);a._deleted=!0,await this.internalStore.bulkWrite([{document:a,previous:r}],"rx-database-remove-collection")},t.addCollections=async function(e){var t={},r={},a=[],n={};await Promise.all(Object.entries(e).map((async e=>{let[s,o]=e;var c=s,l=o.schema;t[c]=l;var d=lt(l,this.hashFunction);if(r[c]=d,this.collections[s])throw D("DB3",{name:s});var h=tr(s,l),u={id:Gt(h,Ut),key:h,context:Ut,data:{name:c,schemaHash:await d.hash,schema:d.jsonSchema,version:d.version,connectedStorages:[]},_deleted:!1,_meta:B(),_rev:"",_attachments:{}};a.push({document:u});var m=Object.assign({},o,{name:c,schema:d,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:d={},localDocuments:h=!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,d,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:d,cacheReplacementPolicy:u,localDocuments:h,statics:o}}),p))).catch((t=>e.close().then((()=>Promise.reject(t)))))}))}(t);o[e]=r,this.collections[e]=r,this[e]||Object.defineProperty(this,e,{get:()=>this.collections[e]})}))),o},t.lockedRun=function(e){return this.idleQueue.wrapCall(e)},t.requestIdlePromise=function(){return this.idleQueue.requestIdlePromise()},t.exportJSON=function(e){throw vt("json-dump")},t.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}}])}();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:d=!1,localDocuments:h=!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:h}),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,d,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:s,eventReduce:i,ignoreDuplicate:o,options:c,localDocuments:h}}).then((()=>f))}))}var 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,ht.p)((e=>e.documentId===this.primary)),(0,ht.p)((e=>e.isLocal)),(0,dt.T)((e=>gt(e))),(0,ut.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,dt.T)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.t)(le.bz))},get $$(){var e=this,t=Ir(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Ir(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},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,dt.T)((e=>e._data)),(0,dt.T)((t=>v(t,e))),(0,mt.F)())},get$$(e){var t=Ir(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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=Ke(t,a,Ar);var n=new Mt("id",e.$.pipe((0,ht.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,ht.p)((e=>e.use)),(0,dt.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 zr(){return"undefined"!=typeof window&&window.indexedDB}function Hr(){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 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})},6866:(e,t,r)=>{r.r(t),r.d(t,{default:()=>x});var a=r(4586),n=r(1595),s=r(5260),i=(r(6879),r(4157)),o=r(943),c=r(7708),l=r(5520),d=r(3337),h=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,d.ZN)(await e.getLocal("beatingvalues"));(async()=>{for(await(0,h.ND)(k);y;){const e=_(),r=(0,h.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,d.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.jsx)("a",{className:"button",href:"/premium#premium-request-form-block",onClick:()=>(0,f.h)("request_premium_main_page",3),target:"_blank",children:"Buy Premium"}),(0,g.jsx)("div",{className:"clear"}),(0,g.jsx)("br",{})]}),(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:"/code",target:"_blank",children:(0,g.jsxs)("div",{className:"trophy github",children:[(0,g.jsx)("img",{className:"lazyload","data-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 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 lazyload","data-src":"./files/companies/altgras.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 lazyload","data-src":"./files/companies/moreapp.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 lazyload","data-src":"./files/companies/woopos.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 lazyload","data-src":"./files/companies/atroo.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",{className:"lazyload","data-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",{"data-src":"./files/logo/logo.svg",alt:"RxDB",className:"replicate-logo tilt-to-mouse lazyload"}),(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",{"data-src":"./files/icons/graphql-text.svg",alt:"GraphQL",className:"protocol lazyload"})})}),(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",{"data-src":"./files/icons/couchdb-text.svg",alt:"CouchDB",className:"protocol lazyload"})})}),(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:"/chat",target:"_blank",children:(0,g.jsxs)("div",{className:"trophy discord",children:[(0,g.jsx)("img",{className:"lazyload","data-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 offline-first dark",children:[(0,g.jsx)("div",{className:"offline-image-wrapper",children:(0,g.jsx)("img",{"data-src":"files/icons/wifi/wifi_1a202c.svg",className:"offline-image beating-second lazyload",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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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",{className:"lazyload","data-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:()=>d,dY:()=>a,em:()=>o,h$:()=>h,vN:()=>c});Promise.resolve(!0);var s=Promise.resolve(!1),i=Promise.resolve(null),o=Promise.resolve();function c(e){return void 0===e&&(e=1e4),"function"==typeof requestIdleCallback?new Promise((t=>{requestIdleCallback((()=>t()),{timeout:e})})):n(0)}var l=o;function d(e){return void 0===e&&(e=void 0),l=l.then((()=>c(e)))}function h(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},5734:(e,t,r)=>{r.d(t,{t:()=>n});var a=0;function n(){var e=Date.now();(e+=.01)<=a&&(e=a+.01);var t=parseFloat(e.toFixed(2));return a=t,t}}}]); \ No newline at end of file diff --git a/docs/assets/js/280a2389.95c2e659.js b/docs/assets/js/280a2389.5b3df3d5.js similarity index 99% rename from docs/assets/js/280a2389.95c2e659.js rename to docs/assets/js/280a2389.5b3df3d5.js index 4f5563764c5..d9ad01ba29c 100644 --- a/docs/assets/js/280a2389.95c2e659.js +++ b/docs/assets/js/280a2389.5b3df3d5.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}}])}((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}}])}((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.18.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)))}}])}();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,e.collection.database)},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,e.collection.database)},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),this.collection.database)},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))}}])}();function Bt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Qt=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=Bt(this.collection._docCache,t)}),[{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,this.collection.database)}},{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}}])}();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}}])}();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}}])}();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,t=Rr(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Rr(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},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){var t=Rr(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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(2303),i=r(1595),s=r(6540),o=r(2658),c=r(4848);const u="meeting-link-clicked";function h(){const{siteConfig:e}=(0,a.A)(),t=(0,n.A)();return(0,s.useEffect)((()=>{t&&(0,o.IA)()&&(async()=>{const e=await(0,o.C3)();await e.getLocal(u)?console.log("# already tracked "+u):(window.trigger(u,40),await e.upsertLocal(u,{}))})()})),(0,c.jsx)(i.A,{title:`Meeting - ${e.title}`,description:"RxDB 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:"https://rxdb.pipedrive.com/scheduler/QBbGlDC4/schedulr",children:"Click here"})}),(0,c.jsx)("meta",{httpEquiv:"Refresh",content:"0; url=https://rxdb.pipedrive.com/scheduler/QBbGlDC4/schedulr"})]})})})}},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}}])}((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}}])}((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.18.2",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)))}}])}();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,e.collection.database)},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,e.collection.database)},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),this.collection.database)},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))}}])}();function Bt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Qt=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=Bt(this.collection._docCache,t)}),[{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,this.collection.database)}},{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}}])}();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}}])}();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}}])}();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,t=Rr(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Rr(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},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){var t=Rr(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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(2303),i=r(1595),s=r(6540),o=r(2658),c=r(4848);const u="meeting-link-clicked";function h(){const{siteConfig:e}=(0,a.A)(),t=(0,n.A)();return(0,s.useEffect)((()=>{t&&(0,o.IA)()&&(async()=>{const e=await(0,o.C3)();await e.getLocal(u)?console.log("# already tracked "+u):(window.trigger(u,40),await e.upsertLocal(u,{}))})()})),(0,c.jsx)(i.A,{title:`Meeting - ${e.title}`,description:"RxDB 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:"https://rxdb.pipedrive.com/scheduler/QBbGlDC4/schedulr",children:"Click here"})}),(0,c.jsx)("meta",{httpEquiv:"Refresh",content:"0; url=https://rxdb.pipedrive.com/scheduler/QBbGlDC4/schedulr"})]})})})}},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/4f17bbdd.dffc1562.js b/docs/assets/js/4f17bbdd.ff63f20a.js similarity index 99% rename from docs/assets/js/4f17bbdd.dffc1562.js rename to docs/assets/js/4f17bbdd.ff63f20a.js index df929bf3755..25c6b54f0a4 100644 --- a/docs/assets/js/4f17bbdd.dffc1562.js +++ b/docs/assets/js/4f17bbdd.ff63f20a.js @@ -1 +1 @@ -"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[2373],{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}}])}((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}}])}((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.18.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)))}}])}();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,e.collection.database)},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,e.collection.database)},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),this.collection.database)},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))}}])}();function Bt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Qt=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=Bt(this.collection._docCache,t)}),[{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,this.collection.database)}},{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}}])}();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}}])}();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}}])}();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,t=Rr(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Rr(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},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){var t=Rr(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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"]},1206:(e,t,r)=>{r.r(t),r.d(t,{default:()=>h});var a=r(4586),n=r(2303),i=r(1595),s=r(6540),o=r(2658),c=r(4848);const u="paid-meeting-link-clicked";function h(){const{siteConfig:e}=(0,a.A)(),t=(0,n.A)();return(0,s.useEffect)((()=>{t&&(0,o.IA)()&&(async()=>{const e=await(0,o.C3)();await e.getLocal(u)?console.log("# already tracked "+u):(window.trigger(u,100),await e.upsertLocal(u,{}))})()})),(0,c.jsx)(i.A,{title:`Meeting - ${e.title}`,description:"RxDB 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:"https://rxdb.pipedrive.com/scheduler/Z6A0M1sr/rxdb-1h-paid-consulting-session",children:"Click here"})}),(0,c.jsx)("meta",{httpEquiv:"Refresh",content:"0; url=https://rxdb.pipedrive.com/scheduler/Z6A0M1sr/rxdb-1h-paid-consulting-session"})]})})})}},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([[2373],{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}}])}((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}}])}((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.18.2",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)))}}])}();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,e.collection.database)},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,e.collection.database)},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),this.collection.database)},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))}}])}();function Bt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Qt=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=Bt(this.collection._docCache,t)}),[{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,this.collection.database)}},{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}}])}();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}}])}();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}}])}();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,t=Rr(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Rr(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},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){var t=Rr(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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"]},1206:(e,t,r)=>{r.r(t),r.d(t,{default:()=>h});var a=r(4586),n=r(2303),i=r(1595),s=r(6540),o=r(2658),c=r(4848);const u="paid-meeting-link-clicked";function h(){const{siteConfig:e}=(0,a.A)(),t=(0,n.A)();return(0,s.useEffect)((()=>{t&&(0,o.IA)()&&(async()=>{const e=await(0,o.C3)();await e.getLocal(u)?console.log("# already tracked "+u):(window.trigger(u,100),await e.upsertLocal(u,{}))})()})),(0,c.jsx)(i.A,{title:`Meeting - ${e.title}`,description:"RxDB 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:"https://rxdb.pipedrive.com/scheduler/Z6A0M1sr/rxdb-1h-paid-consulting-session",children:"Click here"})}),(0,c.jsx)("meta",{httpEquiv:"Refresh",content:"0; url=https://rxdb.pipedrive.com/scheduler/Z6A0M1sr/rxdb-1h-paid-consulting-session"})]})})})}},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/7bbb96fd.b645735e.js b/docs/assets/js/7bbb96fd.b49e06ee.js similarity index 99% rename from docs/assets/js/7bbb96fd.b645735e.js rename to docs/assets/js/7bbb96fd.b49e06ee.js index ced0866f34b..67d396811b5 100644 --- a/docs/assets/js/7bbb96fd.b645735e.js +++ b/docs/assets/js/7bbb96fd.b49e06ee.js @@ -1 +1 @@ -"use strict";(self.webpackChunkrxdb=self.webpackChunkrxdb||[]).push([[3495],{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}}])}((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}}])}((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 j={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var C=/\./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"===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 je(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=Ce(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=je(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 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,j=null,C=null;if(x&&!D)C="INSERT",R=c?He(d):d;else if(!g||x||D){if(!D)throw E("SNH",{args:{writeRow:n}});C="DELETE",R=(0,ue.ZN)(d),j=g}else C="UPDATE",R=c?He(d):d,j=g;var S={documentId:b,documentData:R,previousDocumentData:j,operation:C};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.18.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=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)))}}])}();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:j[(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,e.collection.database)},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,e.collection.database)},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),this.collection.database)},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 jt=new WeakMap;function Ct(e,t){if(!e.collection.database.eventReduce)return{runFullQueryAgain:!0};var r=function(e){return i(jt,e,(()=>{var t=e.collection,r=Re(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=je(t.schema.jsonSchema,r),i=Ce(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))}}])}();function Bt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Qt=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=Bt(this.collection._docCache,t)}),[{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,this.collection.database)}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return u(this,"queryMatcher",Ce(0,Re(this.collection.schema.jsonSchema,this.mangoQuery)))}},{key:"asRxQuery",get:function(){return this}}])}();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=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 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}}])}();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}}])}();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(Cr,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,t=Rr(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Rr(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},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 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){var t=Rr(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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 jr=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 $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 Cr.set(e,c),c})();jr.set(e,a)}function Pr(e){var t=jr.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=jr.get(e);if(t)return jr.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"]},8435:(e,t,r)=>{r.r(t),r.d(t,{default:()=>h});var a=r(4586),n=r(2303),i=r(1595),s=r(6540),o=r(2658),c=r(4848);const u="paid-meeting-link-clicked";function h(){const{siteConfig:e}=(0,a.A)(),t=(0,n.A)();return(0,s.useEffect)((()=>{t&&(0,o.IA)()&&(async()=>{const e=await(0,o.C3)();await e.getLocal(u)?console.log("# already tracked "+u):(window.trigger(u,100),await e.upsertLocal(u,{}))})()})),(0,c.jsx)(i.A,{title:`Service Request Submitted - ${e.title}`,description:"RxDB Meeting Scheduler",children:(0,c.jsxs)("main",{children:[(0,c.jsx)("br",{}),(0,c.jsx)("br",{}),(0,c.jsx)("br",{}),(0,c.jsx)("br",{}),(0,c.jsxs)("div",{className:"redirectBox",style:{textAlign:"center"},children:[(0,c.jsx)("a",{href:"/",target:"_blank",children:(0,c.jsx)("div",{className:"logo",children:(0,c.jsx)("img",{src:"/files/logo/logo_text.svg",alt:"RxDB",width:120})})}),(0,c.jsx)("br",{}),(0,c.jsx)("br",{}),(0,c.jsx)("h1",{children:"RxDB Service Form Submitted"}),(0,c.jsx)("br",{}),(0,c.jsxs)("p",{style:{padding:50},children:["Thank you for submitting the form. You will directly get a confirmation email.",(0,c.jsx)("br",{}),(0,c.jsx)("b",{children:"Please check your spam folder!"}),".",(0,c.jsx)("br",{}),"In the next 24 hours you will get a full answer via email."]}),(0,c.jsx)("br",{}),(0,c.jsx)("br",{})]})]})})}},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([[3495],{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}}])}((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}}])}((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 j={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};var C=/\./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"===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 je(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=Ce(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=je(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 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,j=null,C=null;if(x&&!D)C="INSERT",R=c?He(d):d;else if(!g||x||D){if(!D)throw E("SNH",{args:{writeRow:n}});C="DELETE",R=(0,ue.ZN)(d),j=g}else C="UPDATE",R=c?He(d):d,j=g;var S={documentId:b,documentData:R,previousDocumentData:j,operation:C};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.18.2",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=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)))}}])}();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:j[(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,e.collection.database)},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,e.collection.database)},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),this.collection.database)},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 jt=new WeakMap;function Ct(e,t){if(!e.collection.database.eventReduce)return{runFullQueryAgain:!0};var r=function(e){return i(jt,e,(()=>{var t=e.collection,r=Re(t.storageInstance.schema,c(e.mangoQuery)),a=t.schema.primaryPath,n=je(t.schema.jsonSchema,r),i=Ce(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))}}])}();function Bt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Qt=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=Bt(this.collection._docCache,t)}),[{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,this.collection.database)}},{key:"queryMatcher",get:function(){this.collection.schema.jsonSchema;return u(this,"queryMatcher",Ce(0,Re(this.collection.schema.jsonSchema,this.mangoQuery)))}},{key:"asRxQuery",get:function(){return this}}])}();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=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 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}}])}();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}}])}();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(Cr,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,t=Rr(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Rr(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},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 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){var t=Rr(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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 jr=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 $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 Cr.set(e,c),c})();jr.set(e,a)}function Pr(e){var t=jr.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=jr.get(e);if(t)return jr.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"]},8435:(e,t,r)=>{r.r(t),r.d(t,{default:()=>h});var a=r(4586),n=r(2303),i=r(1595),s=r(6540),o=r(2658),c=r(4848);const u="paid-meeting-link-clicked";function h(){const{siteConfig:e}=(0,a.A)(),t=(0,n.A)();return(0,s.useEffect)((()=>{t&&(0,o.IA)()&&(async()=>{const e=await(0,o.C3)();await e.getLocal(u)?console.log("# already tracked "+u):(window.trigger(u,100),await e.upsertLocal(u,{}))})()})),(0,c.jsx)(i.A,{title:`Service Request Submitted - ${e.title}`,description:"RxDB Meeting Scheduler",children:(0,c.jsxs)("main",{children:[(0,c.jsx)("br",{}),(0,c.jsx)("br",{}),(0,c.jsx)("br",{}),(0,c.jsx)("br",{}),(0,c.jsxs)("div",{className:"redirectBox",style:{textAlign:"center"},children:[(0,c.jsx)("a",{href:"/",target:"_blank",children:(0,c.jsx)("div",{className:"logo",children:(0,c.jsx)("img",{src:"/files/logo/logo_text.svg",alt:"RxDB",width:120})})}),(0,c.jsx)("br",{}),(0,c.jsx)("br",{}),(0,c.jsx)("h1",{children:"RxDB Service Form Submitted"}),(0,c.jsx)("br",{}),(0,c.jsxs)("p",{style:{padding:50},children:["Thank you for submitting the form. You will directly get a confirmation email.",(0,c.jsx)("br",{}),(0,c.jsx)("b",{children:"Please check your spam folder!"}),".",(0,c.jsx)("br",{}),"In the next 24 hours you will get a full answer via email."]}),(0,c.jsx)("br",{}),(0,c.jsx)("br",{})]})]})})}},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/cde77f4f.e330432a.js b/docs/assets/js/cde77f4f.82016b37.js similarity index 99% rename from docs/assets/js/cde77f4f.e330432a.js rename to docs/assets/js/cde77f4f.82016b37.js index e93dda16263..fe3b09f3a0f 100644 --- a/docs/assets/js/cde77f4f.e330432a.js +++ b/docs/assets/js/cde77f4f.82016b37.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 d=e=>{var t=typeof e;return null!==e&&("object"===t||"function"===t)},h=new Set(["__proto__","prototype","constructor"]),u=new Set("0123456789");function m(e){var t=[],r="",a="start",n=!1;for(var i of e)switch(i){case"\\":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");n&&(r+=i),a="property",n=!n;break;case".":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="property";break}if(n){n=!1,r+=i;break}if(h.has(r))return[];t.push(r),r="",a="property";break;case"[":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="index";break}if(n){n=!1,r+=i;break}if("property"===a){if(h.has(r))return[];t.push(r),r=""}a="index";break;case"]":if("index"===a){t.push(Number.parseInt(r,10)),r="",a="indexEnd";break}if("indexEnd"===a)throw new Error("Invalid character after an index");default:if("index"===a&&!u.has(i))throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");"start"===a&&(a="property"),n&&(n=!1,r+="\\"),r+=i}switch(n&&(r+="\\"),a){case"property":if(h.has(r))return[];t.push(r);break;case"index":throw new Error("Index was not closed");case"start":t.push("")}return t}function p(e,t){if("number"!=typeof t&&Array.isArray(e)){var r=Number.parseInt(t,10);return Number.isInteger(r)&&e[r]===e[t]}return!1}function f(e,t){if(p(e,t))throw new Error("Cannot use string index")}function v(e,t,r){if(Array.isArray(t)&&(t=t.join(".")),!t.includes(".")&&!t.includes("["))return e[t];if(!d(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 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}}])}((0,w.A)(Error)),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"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}])}((0,w.A)(TypeError));function R(e,t){return new _(e,j.tunnelErrorMessage(e),t)}function I(e,t){return new D(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=v(t,e);if(void 0===r)throw R("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:B,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=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=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),de=String.fromCharCode(65535),he=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])),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,d=e.map((e=>{var t=r[e],n=t?Object.keys(t):[],i={};t&&n.length?n.forEach((e=>{if(me.has(e)){var r=function(e,t){switch(e){case"$eq":return{startKey:t,endKey:t,inclusiveEnd:!0,inclusiveStart:!0};case"$lte":return{endKey:t,inclusiveEnd:!0};case"$gte":return{startKey:t,inclusiveStart:!0};case"$lt":return{endKey:t,inclusiveEnd:!1};case"$gt":return{startKey:t,inclusiveStart:!1};default:throw new Error("SNH")}}(e,t[e]);i=Object.assign(i,r)}})):i={startKey:l?he:de,endKey:a?de:he,inclusiveStart:!0,inclusiveEnd:!0};return void 0===i.startKey&&(i.startKey=he),void 0===i.endKey&&(i.endKey=de),void 0===i.inclusiveStart&&(i.inclusiveStart=!0),void 0===i.inclusiveEnd&&(i.inclusiveEnd=!0),l&&!i.inclusiveStart&&(l=!1),a&&!i.inclusiveEnd&&(a=!1),i})),h=d.map((e=>e.startKey)),u=d.map((e=>e.endKey)),m={index:e,startKeys:h,endKeys:u,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!i.has(e))).join(","),selectorSatisfiedByIndex:ve(e,t.selector,h,u)},p=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},i=10,s=(0,g.Sd)(r.startKeys,(e=>e!==he&&e!==de));n(s*i);var o=(0,g.Sd)(r.startKeys,(e=>e!==de&&e!==he));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 R("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 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 l=Object.keys(c).filter((e=>pe.has(e)));if(l.length>1)return!1;var d=l[0];if(d&&s.add(o),"$eq"!==d){if(i.length>0)return!1;i.push(d)}}var h=[],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(h.length>0)return!1;h.push(v)}}var y=0;for(var g of e){for(var b of[s,u]){if(!b.has(g)&&b.size>0)return!1;b.delete(g)}if(r[y]!==a[y]&&s.size>0&&u.size>0)return!1;y++}return!0}var ye=r(744),ge=r(2779),be=r(1692),xe=r(4903),we=r(7705),je=r(2403),ke=r(6776),_e=r(6950),De=r(6823),Re=!1;function Ie(e){return Re||((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:_e.Jy,$exists:De.P,$gt:je.MR,$gte:je.fy,$in:je.oZ,$lt:je.NV,$lte:je.Q_,$ne:je.C5,$nin:je.GU,$mod:ke.Pp,$nor:we.q3,$not:we.En,$or:we.sU,$regex:ke.WP,$size:_e.Ig,$type:De.T}),Re=!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 R("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===he?-1/0:e}function Oe(e,t,r){return e.includes(t)?r===de||!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,d=[];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)||d.push(n),s.sortSatisfiedByIndex&&d.length===i?e():a.continue()}else e()}}))})),!s.sortSatisfiedByIndex){var h=Ee(e.schema,t.query);d=d.sort(h)}return{documents:d=d.slice(n,i)}}function Be(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 $e(e){return parseInt(e.split("-")[0],10)}function Me(e,t){var r=t?t._rev:null;return(r?Be(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?R("CONFLICT",{collection:e.name,id:t,writeError:a,data:r}):422===a.status?R("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 R("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 R("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:$(),_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 d=r.close.bind(r);r.close=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),d()};var h=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),h()}}}var Ye=(0,ce.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 R("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=[],d=[],h=[],u={id:O(10),events:[],checkpoint:null,context:n,startTime:(0,ce.t)(),endTime:0},m=u.events,p=[],f=[],v=[],y=r.size>0,g=a.length,b=function(){var e,n=a[x],u=n.document,g=n.previous,b=u[t],w=u._deleted,j=g&&g._deleted,k=void 0;if(y&&(k=r.get(b)),k){var _=k._rev;if(!g||g&&_!==g._rev){var D={isError:!0,status:409,documentId:b,writeRow:n,documentInDb:k};return h.push(D),1}var I=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(u._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(u._attachments).forEach((e=>{let[t,r]=e;var a=g?g._attachments[t]:void 0;if(a){var n=I.document._attachments[t].digest;r.data&&a.digest!==n&&v.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})}else p.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})})))),e?h.push(e):(c?(d.push(We(I)),s&&s(u)):(d.push(I),s&&s(u)),o=I);var S=null,E=null,C=null;if(j&&!w)C="INSERT",S=c?He(u):u;else if(!g||j||w){if(!w)throw R("SNH",{args:{writeRow:n}});C="DELETE",S=(0,le.ZN)(u),E=g}else C="UPDATE",S=c?He(u):u,E=g;var P={documentId:b,documentData:S,previousDocumentData:E,operation:C};m.push(P)}else{var O=!!w;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},h.push(e))})),e||(c?(l.push(We(n)),i&&i(u)):(l.push(n),i&&i(u)),o=n),!O){var N={documentId:b,operation:"INSERT",documentData:c?He(u):u,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.18.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 R("UT5",{args:{params:e}});if((t=e.schema).encrypted&&t.encrypted.length>0||t.attachments&&t.attachments.encrypted)throw R("UT6",{args:{params:e}});var t;if(e.schema.attachments&&e.schema.attachments.compression)throw R("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 R("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)))}}])}();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 dt=r(7708),ht=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+=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 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,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=Be(i._rev).height,n.forEach((e=>{var t=Be(e._rev).height;t>s&&(i=e,s=t)})),i),l=o;for(var d of a)try{l=await d.modifier(c(l))}catch(h){d.reject(h),d.reject=()=>{},d.resolve=()=>{}}try{await this.preWrite(l,o)}catch(h){return void a.forEach((e=>e.reject(h)))}e.push({previous:o,document:l})})));var r=e.length>0?await this.storageInstance.bulkWrite(e,"incremental-write"):{error:[],success:[]};return await Promise.all(r.success.map((e=>{var r=e[this.primaryPath];this.postWrite(e),n(t,r).forEach((t=>t.resolve(e)))}))),r.error.forEach((e=>{var r,a=e.documentId,s=n(t,a),o=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=R("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,dt.T)((e=>e._data._deleted)))},get deleted$$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,e.collection.database)},get deleted(){if(this.isInstanceOfRxDocument)return this._data._deleted},getLatest(){var e=this.collection._docCache.getLatestDocumentData(this.primary);return this.collection._docCache.getCachedRxDocument(e)},get $(){return this.collection.$.pipe((0,ht.p)((e=>!e.isLocal)),(0,ht.p)((e=>e.documentId===this.primary)),(0,dt.T)((e=>yt(e))),(0,ut.Z)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,dt.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,e.collection.database)},get$(e){if(j.isDevMode()){if(e.includes(".item."))throw R("DOC1",{path:e});if(e===this.primaryPath)throw R("DOC2");if(this.collection.schema.finalFields.includes(e))throw R("DOC3",{path:e});if(!M(this.collection.schema.jsonSchema,e))throw R("DOC4",{path:e})}return this.$.pipe((0,dt.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),this.collection.database)},populate(e){var t=M(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.$A;if(!t)throw R("DOC5",{path:e});if(!t.ref)throw R("DOC6",{path:e,schemaObj:t});var a=this.collection.database.collections[t.ref];if(!a)throw R("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 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 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 R("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(R("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 R("DOC14")}};function wt(e){void 0===e&&(e=xt);var t=function(e,t){this.collection=e,this._data=t,this._propertyCache=new Map,this.isInstanceOfRxDocument=!0};return t.prototype=e,t}function jt(e,t,r){return t._meta=Object.assign({},r._meta,t._meta),j.isDevMode()&&e.schema.validateChange(r,t),e._runHooks("pre","save",t,r)}var kt=r(2198),_t=r(511),Dt=r(4157),Rt=r(2442),It=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,It.kC)(t);return"runFullQueryAgain"===i||("doNothing"!==i?(s=!0,(0,It.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,Bt,$t=(At=100,Bt=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=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 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=$e(o._rev),d=i(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),h=d.byRev,u=h.get(l),m=u?u.deref():void 0;return m||(o=n(o),m=s(o),h.set(l,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,ft.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:$e(e.revision)})})))}))))),m};return o}(this))}}])}();function qt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Ft=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=qt(this.collection._docCache,t)}),[{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 R("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 R("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Kt(this).then((()=>(0,_t._)(this.$))).then((t=>{if(!t&&e)throw R("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 vt("update")},t.where=function(e){throw vt("query-builder")},t.sort=function(e){throw vt("query-builder")},t.skip=function(e){throw vt("query-builder")},t.limit=function(e){throw vt("query-builder")},(0,b.A)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,ht.p)((e=>!e.isLocal)),(0,ut.Z)(null),(0,Rt.Z)((()=>Kt(this))),(0,dt.T)((()=>this._result)),(0,pt.t)(le.bz),(0,mt.F)(((e,t)=>!(!e||e.time!==(0,le.ZN)(t).time))),(0,ht.p)((e=>!!e)),(0,dt.T)((e=>{var t=(0,le.ZN)(e);return"count"===this.op?t.count:"findOne"===this.op?0===t.documents.length?null:t.documents[0]:"findByIds"===this.op?t.docsMap:t.documents.slice(0)})));this._$=(0,Dt.h)(e,this.refCount$.pipe((0,ht.p)((()=>!1))))}return this._$}},{key:"$$",get:function(){return this.collection.database.getReactivityFactory().fromObservable(this.$,void 0,this.collection.database)}},{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}}])}();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 d=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(d,"rx-database-remove-collection-all")}}var nr=function(){function e(e){this.subs=[],this.limit=100,this.counter=0,this.eventCounterMap=new WeakMap,this.buffer=[],this.collection=e,this.subs.push(this.collection.$.pipe((0,ht.p)((e=>!e.isLocal))).subscribe((e=>this._handleChangeEvent(e))))}var t=e.prototype;return t._handleChangeEvent=function(e){for(this.counter++,this.buffer.push(e),this.eventCounterMap.set(e,this.counter);this.buffer.length>this.limit;)this.buffer.shift()},t.getArrayIndexByPointer=function(e){var t=this.buffer[0],r=this.eventCounterMap.get(t);return et(e)))},t.reduceByLastOfDoc=function(e){return e.slice(0)},t.destroy=function(){this.subs.forEach((e=>e.unsubscribe()))},e}();var 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"],dr=["insert","save","remove","create"],hr=!1,ur=function(){function e(e,t,r,a,n,i,s,o,c,l,d,h){void 0===n&&(n={}),void 0===i&&(i={}),void 0===s&&(s={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===l&&(l=$t),void 0===d&&(d={}),void 0===h&&(h=cr),this.storageInstance={},this.timeouts=new Set,this.incrementalWriteQueue={},this._incrementalUpsertQueues=new Map,this.synced=!1,this.hooks={},this._subs=[],this._docCache={},this._queryCache=new 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=d,this.conflictHandler=h,function(e){if(hr)return;hr=!0;var t=Object.getPrototypeOf(e);dr.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,ht.p)((e=>e.collectionName===this.name)));this.$=t.pipe((0,Rt.Z)((e=>e.events))),this.checkpoint$=t.pipe((0,dt.T)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Tt(this.schema.primaryPath,this.$.pipe((0,ht.p)((e=>!e.isLocal))),(e=>or(this.asRxCollection,e)));var r=await this.database.storageToken,a=this.storageInstance.changeStream().subscribe((e=>{var t={id:e.id,internal:!1,collectionName:this.name,storageToken:r,events:e.events.map((e=>Fe(!1,e,this))),databaseToken:this.database.token,checkpoint:e.checkpoint,context:e.context,endTime:e.endTime,startTime:e.startTime};this.database.$emit(t)}));return this._subs.push(a),this._subs.push(this.storageInstance.conflictResultionTasks().subscribe((e=>{this.conflictHandler(e.input,e.context).then((t=>{this.storageInstance.resolveConflictResultionTask({id:e.id,output:t})}))}))),ft.em},t.cleanup=function(e){throw vt("cleanup")},t.migrationNeeded=function(){throw vt("migration-schema")},t.getMigrationState=function(){throw vt("migration-schema")},t.startMigration=function(e){return void 0===e&&(e=10),this.getMigrationState().startMigration(e)},t.migratePromise=function(e){return void 0===e&&(e=10),this.getMigrationState().migratePromise(e)},t.insert=async function(e){var t=await this.bulkInsert([e]),r=t.error[0];return 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 R("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 R("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 R("COL5",{queryObj:e});return e||(e={selector:{}}),Ht("find",e,this)},t.findOne=function(e){if("number"==typeof e||Array.isArray(e))throw I("COL6",{queryObj:e});var t;if("string"==typeof e)t=Ht("findOne",{selector:{[this.schema.primaryPath]:e},limit:1},this);else{if(e||(e={selector:{}}),e.limit)throw R("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 I("COL7",{key:t,when:e});if(!lr.includes(e))throw I("COL8",{key:t,when:e});if(!dr.includes(t))throw R("COL9",{key:t});if("post"===e&&"create"===t&&!0===a)throw R("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,ht.p)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,ht.p)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,ht.p)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}])}();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),yr=new Set,gr=function(){function e(e,t,r,a,n,i,s,o,c,l,d,h,u){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,Rt.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=i,this.eventReduce=s,this.options=o,this.internalStore=c,this.hashFunction=l,this.cleanupPolicy=d,this.allowSlowCount=h,this.reactivity=u,"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:$(),_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 R("DM5",{args:{database:e.name,databaseStateVersion:s.documentInDb.data.rxdbVersion,codeVersion:e.rxdbVersion}});if(r&&r!==s.documentInDb.data.passwordHash)throw R("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 R("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 R("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 d=lt(l,this.hashFunction);if(r[c]=d,this.collections[i])throw R("DB3",{name:i});var h=tr(i,l),u={id:Gt(h,Zt),key:h,context:Zt,data:{name:c,schemaHash:await d.hash,schema:d.jsonSchema,version:d.version,connectedStorages:[]},_deleted:!1,_meta:$(),_rev:"",_attachments:{}};a.push({document:u});var m=Object.assign({},o,{name:c,schema:d,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 R("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 R("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:d={},localDocuments:h=!1,cacheReplacementPolicy:u=$t,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 ur(t,r,a,e,n,i,c,l,d,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 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:d,cacheReplacementPolicy:u,localDocuments:h,statics:o}}),p))).catch((t=>e.close().then((()=>Promise.reject(t)))))}))}(t);o[e]=r,this.collections[e]=r,this[e]||Object.defineProperty(this,e,{get:()=>this.collections[e]})}))),o},t.lockedRun=function(e){return this.idleQueue.wrapCall(e)},t.requestIdlePromise=function(){return this.idleQueue.requestIdlePromise()},t.exportJSON=function(e){throw vt("json-dump")},t.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((()=>yr.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}}])}();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:d=!1,localDocuments:h=!1,hashFunction:u=fr,reactivity:m}=e;st("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:h}),o||function(e,t){var r=t.name+"|"+e;if(yr.has(r))throw R("DB8",{name:e,storage:t.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}(a,t),yr.add(t.name+"|"+a);var p=O(10);return br(p,t,a,r,i,n).catch((e=>{throw yr.delete(t.name+"|"+a),e})).then((e=>{var f=new gr(a,p,t,r,n,i,s,c,e,u,l,d,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:h}}).then((()=>f))}))}var wr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Wt.prototype,RxCollection:ur.prototype,RxDatabase:gr.prototype},jr=new Set,kr=new Set;var _r=function(e){function t(t,r,a){var n;return(n=e.call(this,null,r)||this).id=t,n.parent=a,n}return(0,x.A)(t,e),t}(wt()),Dr={get isLocal(){return!0},get allAttachments$(){throw R("LD1",{document:this})},get primaryPath(){return"id"},get primary(){return this.id},get $(){var e=n(Cr,this.parent);return this.parent.$.pipe((0,ht.p)((e=>e.documentId===this.primary)),(0,ht.p)((e=>e.isLocal)),(0,dt.T)((e=>yt(e))),(0,ut.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,dt.T)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.t)(le.bz))},get $$(){var e=this,t=Sr(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Sr(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},getLatest(){var e=n(Cr,this.parent),t=e.docCache.getLatestDocumentData(this.primary);return e.docCache.getCachedRxDocument(t)},get(e){if(e="data."+e,this._data){if("string"!=typeof e)throw I("LD2",{objPath:e});var t=v(this._data,e);return t=j.deepFreezeWhenDevMode(t)}},get$(e){if(e="data."+e,j.isDevMode()){if(e.includes(".item."))throw R("LD3",{objPath:e});if(e===this.primaryPath)throw R("LD4")}return this.$.pipe((0,dt.T)((e=>e._data)),(0,dt.T)((t=>v(t,e))),(0,mt.F)())},get$$(e){var t=Sr(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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:$(),_rev:"",_attachments:{}};return Le(e.storageInstance,{previous:this._data,document:t},"local-document-remove").then((t=>e.docCache.getCachedRxDocument(t)))}},Rr=!1,Ir=()=>{if(!Rr){Rr=!0;var e=xt;Object.getOwnPropertyNames(e).forEach((t=>{if(!Object.getOwnPropertyDescriptor(Dr,t)){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(Dr,t,r)}}));["populate","update","putAttachment","getAttachment","allAttachments"].forEach((e=>Dr[e]=(e=>()=>{throw R("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,ht.p)((e=>e.isLocal))),(t=>function(e,t){Ir();var r=new _r(e.id,e,t);return Object.setPrototypeOf(r,Dr),r.prototype=Dr,r}(t,e))),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 R("LD8",{database:r.name,collection:a})}return t}function Nr(e,t,r,a,n,i){return t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:$r(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 Br(e,t,r){var a=O(10),n=await Nr(a,e,t,r,{},!1);await n.remove()}function $r(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:$(),_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,ut.Z)(null),(0,Rt.Z)((async t=>t?{changeEvent:t}:{doc:await this.getLocal(e)})),(0,Rt.Z)((async t=>{if(t.changeEvent){var r=t.changeEvent;return r.isLocal&&r.documentId===e?{use:!0,doc:await this.getLocal(e)}:{use:!1}}return{use:!0,doc:t.doc}})),(0,ht.p)((e=>e.use)),(0,dt.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=>Br(e.storage,e.databaseName,"")},postRemoveRxCollection:{after:e=>Br(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 R("PL3",{name:e.name,plugin:e});if(jr.add(e),kr.add(e.name),!e.rxdb)throw I("PL1",{plugin:e});e.init&&e.init(),e.prototypes&&Object.entries(e.prototypes).forEach((e=>{let[t,r]=e;return r(wr[t])})),e.overwritable&&Object.assign(j,e.overwritable),e.hooks&&Object.entries(e.hooks).forEach((e=>{let[t,r]=e;r.after&&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:()=>y,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}],d={browser:.4,native:.4,performance:.35,server:.25,sourcecode:0,perpetual:0},h=.05;var u=r(1527),m=r(2658),p=r(2303),f=r(4848);function v(e){let{children:t,fallback:r}=e;return(0,p.A)()?(0,f.jsx)(f.Fragment,{children:t?.()}):r??null}const y="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(y);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(d).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)("a",{href:"/rx-server.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:"RxServer Fastify Adapter"}),(0,f.jsx)("p",{children:"An adapter to use the RxServer with fastify instead of express. Used to have better performance when serving requests."})]})})}),(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:"RxServer Koa Adapter"}),(0,f.jsx)("p",{children:"An adapter to use the RxServer with Koa instead of express. Used to have better performance when serving requests."})]})})}),(0,f.jsx)("a",{href:"/reactivity.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:"Reactivity Vue"}),(0,f.jsx)("p",{children:"An extension for Vue.js to get vue shallow-ref objects to observe RxDB state instead of rxjs observables."})]})})}),(0,f.jsx)("a",{href:"/reactivity.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:"Reactivity Preact Signals"}),(0,f.jsx)("p",{children:"An extension for react/preact to get preact signals to observe RxDB state instead of rxjs observables."})]})})})]})]})}),(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-server",type:"checkbox",className:"package-checkbox",defaultChecked:!0}),(0,f.jsx)("h4",{children:"Server Package"}),(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-server.html",target:"_blank",children:"RxServer Adapter Fastify"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-server.html",target:"_blank",children:"RxServer Adapter Koa"})})]})]})}),(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.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/logger.html",target:"_blank",children:"Logger"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/reactivity.html",target:"_blank",children:"Reactivity Vue"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/reactivity.html",target:"_blank",children:"Reactivity Preact Signals"})})]})]})}),(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,u.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=d[e];r+=t})),console.log("aimInPercent: "+r);let a=350+1.4*t*(r/100);if(2===e.packages.length?a*=.95:e.packages.length>2&&(a*=.9),e.companySize>1){let t=1+Math.pow(1*e.companySize-1,.45)/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")),v=(e,t)=>{console.log("setPrice:"),console.dir(t),e.innerHTML=Math.ceil(t).toString()},g=s.totalPrice/i.licensePeriod;v(f,"infinity"!==i.projectAmount?g/parseInt(i.projectAmount,10)/12:0);const b=await(0,m.C3)();await b.upsertLocal(y,{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)(v,{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:()=>d,dY:()=>a,em:()=>o,h$:()=>h,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 d(e){return void 0===e&&(e=void 0),l=l.then((()=>c(e)))}function h(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},5734:(e,t,r)=>{r.d(t,{t:()=>n});var a=0;function n(){var e=Date.now();(e+=.01)<=a&&(e=a+.01);var t=parseFloat(e.toFixed(2));return a=t,t}}}]); \ No newline at end of file +"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 d=e=>{var t=typeof e;return null!==e&&("object"===t||"function"===t)},h=new Set(["__proto__","prototype","constructor"]),u=new Set("0123456789");function m(e){var t=[],r="",a="start",n=!1;for(var i of e)switch(i){case"\\":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");n&&(r+=i),a="property",n=!n;break;case".":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="property";break}if(n){n=!1,r+=i;break}if(h.has(r))return[];t.push(r),r="",a="property";break;case"[":if("index"===a)throw new Error("Invalid character in an index");if("indexEnd"===a){a="index";break}if(n){n=!1,r+=i;break}if("property"===a){if(h.has(r))return[];t.push(r),r=""}a="index";break;case"]":if("index"===a){t.push(Number.parseInt(r,10)),r="",a="indexEnd";break}if("indexEnd"===a)throw new Error("Invalid character after an index");default:if("index"===a&&!u.has(i))throw new Error("Invalid character in an index");if("indexEnd"===a)throw new Error("Invalid character after an index");"start"===a&&(a="property"),n&&(n=!1,r+="\\"),r+=i}switch(n&&(r+="\\"),a){case"property":if(h.has(r))return[];t.push(r);break;case"index":throw new Error("Index was not closed");case"start":t.push("")}return t}function p(e,t){if("number"!=typeof t&&Array.isArray(e)){var r=Number.parseInt(t,10);return Number.isInteger(r)&&e[r]===e[t]}return!1}function f(e,t){if(p(e,t))throw new Error("Cannot use string index")}function v(e,t,r){if(Array.isArray(t)&&(t=t.join(".")),!t.includes(".")&&!t.includes("["))return e[t];if(!d(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 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}}])}((0,w.A)(Error)),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"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}])}((0,w.A)(TypeError));function R(e,t){return new _(e,j.tunnelErrorMessage(e),t)}function I(e,t){return new D(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=v(t,e);if(void 0===r)throw R("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:B,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=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=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),de=String.fromCharCode(65535),he=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])),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,d=e.map((e=>{var t=r[e],n=t?Object.keys(t):[],i={};t&&n.length?n.forEach((e=>{if(me.has(e)){var r=function(e,t){switch(e){case"$eq":return{startKey:t,endKey:t,inclusiveEnd:!0,inclusiveStart:!0};case"$lte":return{endKey:t,inclusiveEnd:!0};case"$gte":return{startKey:t,inclusiveStart:!0};case"$lt":return{endKey:t,inclusiveEnd:!1};case"$gt":return{startKey:t,inclusiveStart:!1};default:throw new Error("SNH")}}(e,t[e]);i=Object.assign(i,r)}})):i={startKey:l?he:de,endKey:a?de:he,inclusiveStart:!0,inclusiveEnd:!0};return void 0===i.startKey&&(i.startKey=he),void 0===i.endKey&&(i.endKey=de),void 0===i.inclusiveStart&&(i.inclusiveStart=!0),void 0===i.inclusiveEnd&&(i.inclusiveEnd=!0),l&&!i.inclusiveStart&&(l=!1),a&&!i.inclusiveEnd&&(a=!1),i})),h=d.map((e=>e.startKey)),u=d.map((e=>e.endKey)),m={index:e,startKeys:h,endKeys:u,inclusiveEnd:a,inclusiveStart:l,sortSatisfiedByIndex:!n&&o===e.filter((e=>!i.has(e))).join(","),selectorSatisfiedByIndex:ve(e,t.selector,h,u)},p=function(e,t,r){var a=0,n=e=>{e>0&&(a+=e)},i=10,s=(0,g.Sd)(r.startKeys,(e=>e!==he&&e!==de));n(s*i);var o=(0,g.Sd)(r.startKeys,(e=>e!==de&&e!==he));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 R("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 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 l=Object.keys(c).filter((e=>pe.has(e)));if(l.length>1)return!1;var d=l[0];if(d&&s.add(o),"$eq"!==d){if(i.length>0)return!1;i.push(d)}}var h=[],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(h.length>0)return!1;h.push(v)}}var y=0;for(var g of e){for(var b of[s,u]){if(!b.has(g)&&b.size>0)return!1;b.delete(g)}if(r[y]!==a[y]&&s.size>0&&u.size>0)return!1;y++}return!0}var ye=r(744),ge=r(2779),be=r(1692),xe=r(4903),we=r(7705),je=r(2403),ke=r(6776),_e=r(6950),De=r(6823),Re=!1;function Ie(e){return Re||((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:_e.Jy,$exists:De.P,$gt:je.MR,$gte:je.fy,$in:je.oZ,$lt:je.NV,$lte:je.Q_,$ne:je.C5,$nin:je.GU,$mod:ke.Pp,$nor:we.q3,$not:we.En,$or:we.sU,$regex:ke.WP,$size:_e.Ig,$type:De.T}),Re=!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 R("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===he?-1/0:e}function Oe(e,t,r){return e.includes(t)?r===de||!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,d=[];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)||d.push(n),s.sortSatisfiedByIndex&&d.length===i?e():a.continue()}else e()}}))})),!s.sortSatisfiedByIndex){var h=Ee(e.schema,t.query);d=d.sort(h)}return{documents:d=d.slice(n,i)}}function Be(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 $e(e){return parseInt(e.split("-")[0],10)}function Me(e,t){var r=t?t._rev:null;return(r?Be(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?R("CONFLICT",{collection:e.name,id:t,writeError:a,data:r}):422===a.status?R("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 R("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 R("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:$(),_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 d=r.close.bind(r);r.close=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),d()};var h=r.remove.bind(r);r.remove=async function(){return c=!0,l.unsubscribe(),n.removeEventListener("message",s),a||await Je(t.databaseInstanceToken,r),h()}}}var Ye=(0,ce.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 R("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=[],d=[],h=[],u={id:O(10),events:[],checkpoint:null,context:n,startTime:(0,ce.t)(),endTime:0},m=u.events,p=[],f=[],v=[],y=r.size>0,g=a.length,b=function(){var e,n=a[x],u=n.document,g=n.previous,b=u[t],w=u._deleted,j=g&&g._deleted,k=void 0;if(y&&(k=r.get(b)),k){var _=k._rev;if(!g||g&&_!==g._rev){var D={isError:!0,status:409,documentId:b,writeRow:n,documentInDb:k};return h.push(D),1}var I=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(u._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(u._attachments).forEach((e=>{let[t,r]=e;var a=g?g._attachments[t]:void 0;if(a){var n=I.document._attachments[t].digest;r.data&&a.digest!==n&&v.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})}else p.push({documentId:b,attachmentId:t,attachmentData:r,digest:r.digest})})))),e?h.push(e):(c?(d.push(We(I)),s&&s(u)):(d.push(I),s&&s(u)),o=I);var S=null,E=null,C=null;if(j&&!w)C="INSERT",S=c?He(u):u;else if(!g||j||w){if(!w)throw R("SNH",{args:{writeRow:n}});C="DELETE",S=(0,le.ZN)(u),E=g}else C="UPDATE",S=c?He(u):u,E=g;var P={documentId:b,documentData:S,previousDocumentData:E,operation:C};m.push(P)}else{var O=!!w;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},h.push(e))})),e||(c?(l.push(We(n)),i&&i(u)):(l.push(n),i&&i(u)),o=n),!O){var N={documentId:b,operation:"INSERT",documentData:c?He(u):u,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.18.2",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 R("UT5",{args:{params:e}});if((t=e.schema).encrypted&&t.encrypted.length>0||t.attachments&&t.attachments.encrypted)throw R("UT6",{args:{params:e}});var t;if(e.schema.attachments&&e.schema.attachments.compression)throw R("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 R("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)))}}])}();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 dt=r(7708),ht=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+=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 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,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=Be(i._rev).height,n.forEach((e=>{var t=Be(e._rev).height;t>s&&(i=e,s=t)})),i),l=o;for(var d of a)try{l=await d.modifier(c(l))}catch(h){d.reject(h),d.reject=()=>{},d.resolve=()=>{}}try{await this.preWrite(l,o)}catch(h){return void a.forEach((e=>e.reject(h)))}e.push({previous:o,document:l})})));var r=e.length>0?await this.storageInstance.bulkWrite(e,"incremental-write"):{error:[],success:[]};return await Promise.all(r.success.map((e=>{var r=e[this.primaryPath];this.postWrite(e),n(t,r).forEach((t=>t.resolve(e)))}))),r.error.forEach((e=>{var r,a=e.documentId,s=n(t,a),o=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=R("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,dt.T)((e=>e._data._deleted)))},get deleted$$(){var e=this;return e.collection.database.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,e.collection.database)},get deleted(){if(this.isInstanceOfRxDocument)return this._data._deleted},getLatest(){var e=this.collection._docCache.getLatestDocumentData(this.primary);return this.collection._docCache.getCachedRxDocument(e)},get $(){return this.collection.$.pipe((0,ht.p)((e=>!e.isLocal)),(0,ht.p)((e=>e.documentId===this.primary)),(0,dt.T)((e=>yt(e))),(0,ut.Z)(this.collection._docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,dt.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,e.collection.database)},get$(e){if(j.isDevMode()){if(e.includes(".item."))throw R("DOC1",{path:e});if(e===this.primaryPath)throw R("DOC2");if(this.collection.schema.finalFields.includes(e))throw R("DOC3",{path:e});if(!M(this.collection.schema.jsonSchema,e))throw R("DOC4",{path:e})}return this.$.pipe((0,dt.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),this.collection.database)},populate(e){var t=M(this.collection.schema.jsonSchema,e),r=this.get(e);if(!r)return ft.$A;if(!t)throw R("DOC5",{path:e});if(!t.ref)throw R("DOC6",{path:e,schemaObj:t});var a=this.collection.database.collections[t.ref];if(!a)throw R("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 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 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 R("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(R("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 R("DOC14")}};function wt(e){void 0===e&&(e=xt);var t=function(e,t){this.collection=e,this._data=t,this._propertyCache=new Map,this.isInstanceOfRxDocument=!0};return t.prototype=e,t}function jt(e,t,r){return t._meta=Object.assign({},r._meta,t._meta),j.isDevMode()&&e.schema.validateChange(r,t),e._runHooks("pre","save",t,r)}var kt=r(2198),_t=r(511),Dt=r(4157),Rt=r(2442),It=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,It.kC)(t);return"runFullQueryAgain"===i||("doNothing"!==i?(s=!0,(0,It.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,Bt,$t=(At=100,Bt=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=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 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=$e(o._rev),d=i(r,c,(()=>function(e){return{byRev:new Map,last:e}}(o))),h=d.byRev,u=h.get(l),m=u?u.deref():void 0;return m||(o=n(o),m=s(o),h.set(l,Lt(m)),a&&(e.registerIdleTasks.push(m),e.registerIdlePromise||(e.registerIdlePromise=(0,ft.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:$e(e.revision)})})))}))))),m};return o}(this))}}])}();function qt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Ft=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=qt(this.collection._docCache,t)}),[{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 R("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 R("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return Kt(this).then((()=>(0,_t._)(this.$))).then((t=>{if(!t&&e)throw R("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 vt("update")},t.where=function(e){throw vt("query-builder")},t.sort=function(e){throw vt("query-builder")},t.skip=function(e){throw vt("query-builder")},t.limit=function(e){throw vt("query-builder")},(0,b.A)(e,[{key:"$",get:function(){if(!this._$){var e=this.collection.$.pipe((0,ht.p)((e=>!e.isLocal)),(0,ut.Z)(null),(0,Rt.Z)((()=>Kt(this))),(0,dt.T)((()=>this._result)),(0,pt.t)(le.bz),(0,mt.F)(((e,t)=>!(!e||e.time!==(0,le.ZN)(t).time))),(0,ht.p)((e=>!!e)),(0,dt.T)((e=>{var t=(0,le.ZN)(e);return"count"===this.op?t.count:"findOne"===this.op?0===t.documents.length?null:t.documents[0]:"findByIds"===this.op?t.docsMap:t.documents.slice(0)})));this._$=(0,Dt.h)(e,this.refCount$.pipe((0,ht.p)((()=>!1))))}return this._$}},{key:"$$",get:function(){return this.collection.database.getReactivityFactory().fromObservable(this.$,void 0,this.collection.database)}},{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}}])}();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 d=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(d,"rx-database-remove-collection-all")}}var nr=function(){function e(e){this.subs=[],this.limit=100,this.counter=0,this.eventCounterMap=new WeakMap,this.buffer=[],this.collection=e,this.subs.push(this.collection.$.pipe((0,ht.p)((e=>!e.isLocal))).subscribe((e=>this._handleChangeEvent(e))))}var t=e.prototype;return t._handleChangeEvent=function(e){for(this.counter++,this.buffer.push(e),this.eventCounterMap.set(e,this.counter);this.buffer.length>this.limit;)this.buffer.shift()},t.getArrayIndexByPointer=function(e){var t=this.buffer[0],r=this.eventCounterMap.get(t);return et(e)))},t.reduceByLastOfDoc=function(e){return e.slice(0)},t.destroy=function(){this.subs.forEach((e=>e.unsubscribe()))},e}();var 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"],dr=["insert","save","remove","create"],hr=!1,ur=function(){function e(e,t,r,a,n,i,s,o,c,l,d,h){void 0===n&&(n={}),void 0===i&&(i={}),void 0===s&&(s={}),void 0===o&&(o={}),void 0===c&&(c={}),void 0===l&&(l=$t),void 0===d&&(d={}),void 0===h&&(h=cr),this.storageInstance={},this.timeouts=new Set,this.incrementalWriteQueue={},this._incrementalUpsertQueues=new Map,this.synced=!1,this.hooks={},this._subs=[],this._docCache={},this._queryCache=new 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=d,this.conflictHandler=h,function(e){if(hr)return;hr=!0;var t=Object.getPrototypeOf(e);dr.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,ht.p)((e=>e.collectionName===this.name)));this.$=t.pipe((0,Rt.Z)((e=>e.events))),this.checkpoint$=t.pipe((0,dt.T)((e=>e.checkpoint))),this._changeEventBuffer=(e=this.asRxCollection,new nr(e)),this._docCache=new Tt(this.schema.primaryPath,this.$.pipe((0,ht.p)((e=>!e.isLocal))),(e=>or(this.asRxCollection,e)));var r=await this.database.storageToken,a=this.storageInstance.changeStream().subscribe((e=>{var t={id:e.id,internal:!1,collectionName:this.name,storageToken:r,events:e.events.map((e=>Fe(!1,e,this))),databaseToken:this.database.token,checkpoint:e.checkpoint,context:e.context,endTime:e.endTime,startTime:e.startTime};this.database.$emit(t)}));return this._subs.push(a),this._subs.push(this.storageInstance.conflictResultionTasks().subscribe((e=>{this.conflictHandler(e.input,e.context).then((t=>{this.storageInstance.resolveConflictResultionTask({id:e.id,output:t})}))}))),ft.em},t.cleanup=function(e){throw vt("cleanup")},t.migrationNeeded=function(){throw vt("migration-schema")},t.getMigrationState=function(){throw vt("migration-schema")},t.startMigration=function(e){return void 0===e&&(e=10),this.getMigrationState().startMigration(e)},t.migratePromise=function(e){return void 0===e&&(e=10),this.getMigrationState().migratePromise(e)},t.insert=async function(e){var t=await this.bulkInsert([e]),r=t.error[0];return 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 R("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 R("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 R("COL5",{queryObj:e});return e||(e={selector:{}}),Ht("find",e,this)},t.findOne=function(e){if("number"==typeof e||Array.isArray(e))throw I("COL6",{queryObj:e});var t;if("string"==typeof e)t=Ht("findOne",{selector:{[this.schema.primaryPath]:e},limit:1},this);else{if(e||(e={selector:{}}),e.limit)throw R("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 I("COL7",{key:t,when:e});if(!lr.includes(e))throw I("COL8",{key:t,when:e});if(!dr.includes(t))throw R("COL9",{key:t});if("post"===e&&"create"===t&&!0===a)throw R("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,ht.p)((e=>"INSERT"===e.operation)))}},{key:"update$",get:function(){return this.$.pipe((0,ht.p)((e=>"UPDATE"===e.operation)))}},{key:"remove$",get:function(){return this.$.pipe((0,ht.p)((e=>"DELETE"===e.operation)))}},{key:"asRxCollection",get:function(){return this}}])}();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),yr=new Set,gr=function(){function e(e,t,r,a,n,i,s,o,c,l,d,h,u){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,Rt.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=i,this.eventReduce=s,this.options=o,this.internalStore=c,this.hashFunction=l,this.cleanupPolicy=d,this.allowSlowCount=h,this.reactivity=u,"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:$(),_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 R("DM5",{args:{database:e.name,databaseStateVersion:s.documentInDb.data.rxdbVersion,codeVersion:e.rxdbVersion}});if(r&&r!==s.documentInDb.data.passwordHash)throw R("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 R("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 R("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 d=lt(l,this.hashFunction);if(r[c]=d,this.collections[i])throw R("DB3",{name:i});var h=tr(i,l),u={id:Gt(h,Zt),key:h,context:Zt,data:{name:c,schemaHash:await d.hash,schema:d.jsonSchema,version:d.version,connectedStorages:[]},_deleted:!1,_meta:$(),_rev:"",_attachments:{}};a.push({document:u});var m=Object.assign({},o,{name:c,schema:d,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 R("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 R("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:d={},localDocuments:h=!1,cacheReplacementPolicy:u=$t,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 ur(t,r,a,e,n,i,c,l,d,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 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:d,cacheReplacementPolicy:u,localDocuments:h,statics:o}}),p))).catch((t=>e.close().then((()=>Promise.reject(t)))))}))}(t);o[e]=r,this.collections[e]=r,this[e]||Object.defineProperty(this,e,{get:()=>this.collections[e]})}))),o},t.lockedRun=function(e){return this.idleQueue.wrapCall(e)},t.requestIdlePromise=function(){return this.idleQueue.requestIdlePromise()},t.exportJSON=function(e){throw vt("json-dump")},t.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((()=>yr.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}}])}();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:d=!1,localDocuments:h=!1,hashFunction:u=fr,reactivity:m}=e;st("preCreateRxDatabase",{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:h}),o||function(e,t){var r=t.name+"|"+e;if(yr.has(r))throw R("DB8",{name:e,storage:t.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}(a,t),yr.add(t.name+"|"+a);var p=O(10);return br(p,t,a,r,i,n).catch((e=>{throw yr.delete(t.name+"|"+a),e})).then((e=>{var f=new gr(a,p,t,r,n,i,s,c,e,u,l,d,m);return ot("createRxDatabase",{database:f,creator:{storage:t,instanceCreationOptions:r,name:a,password:n,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:c,localDocuments:h}}).then((()=>f))}))}var wr={RxSchema:ct.prototype,RxDocument:xt,RxQuery:Wt.prototype,RxCollection:ur.prototype,RxDatabase:gr.prototype},jr=new Set,kr=new Set;var _r=function(e){function t(t,r,a){var n;return(n=e.call(this,null,r)||this).id=t,n.parent=a,n}return(0,x.A)(t,e),t}(wt()),Dr={get isLocal(){return!0},get allAttachments$(){throw R("LD1",{document:this})},get primaryPath(){return"id"},get primary(){return this.id},get $(){var e=n(Cr,this.parent);return this.parent.$.pipe((0,ht.p)((e=>e.documentId===this.primary)),(0,ht.p)((e=>e.isLocal)),(0,dt.T)((e=>yt(e))),(0,ut.Z)(e.docCache.getLatestDocumentData(this.primary)),(0,mt.F)(((e,t)=>e._rev===t._rev)),(0,dt.T)((t=>e.docCache.getCachedRxDocument(t))),(0,pt.t)(le.bz))},get $$(){var e=this,t=Sr(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Sr(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},getLatest(){var e=n(Cr,this.parent),t=e.docCache.getLatestDocumentData(this.primary);return e.docCache.getCachedRxDocument(t)},get(e){if(e="data."+e,this._data){if("string"!=typeof e)throw I("LD2",{objPath:e});var t=v(this._data,e);return t=j.deepFreezeWhenDevMode(t)}},get$(e){if(e="data."+e,j.isDevMode()){if(e.includes(".item."))throw R("LD3",{objPath:e});if(e===this.primaryPath)throw R("LD4")}return this.$.pipe((0,dt.T)((e=>e._data)),(0,dt.T)((t=>v(t,e))),(0,mt.F)())},get$$(e){var t=Sr(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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:$(),_rev:"",_attachments:{}};return Le(e.storageInstance,{previous:this._data,document:t},"local-document-remove").then((t=>e.docCache.getCachedRxDocument(t)))}},Rr=!1,Ir=()=>{if(!Rr){Rr=!0;var e=xt;Object.getOwnPropertyNames(e).forEach((t=>{if(!Object.getOwnPropertyDescriptor(Dr,t)){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(Dr,t,r)}}));["populate","update","putAttachment","getAttachment","allAttachments"].forEach((e=>Dr[e]=(e=>()=>{throw R("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,ht.p)((e=>e.isLocal))),(t=>function(e,t){Ir();var r=new _r(e.id,e,t);return Object.setPrototypeOf(r,Dr),r.prototype=Dr,r}(t,e))),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 R("LD8",{database:r.name,collection:a})}return t}function Nr(e,t,r,a,n,i){return t.createStorageInstance({databaseInstanceToken:e,databaseName:r,collectionName:$r(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 Br(e,t,r){var a=O(10),n=await Nr(a,e,t,r,{},!1);await n.remove()}function $r(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:$(),_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,ut.Z)(null),(0,Rt.Z)((async t=>t?{changeEvent:t}:{doc:await this.getLocal(e)})),(0,Rt.Z)((async t=>{if(t.changeEvent){var r=t.changeEvent;return r.isLocal&&r.documentId===e?{use:!0,doc:await this.getLocal(e)}:{use:!1}}return{use:!0,doc:t.doc}})),(0,ht.p)((e=>e.use)),(0,dt.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=>Br(e.storage,e.databaseName,"")},postRemoveRxCollection:{after:e=>Br(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 R("PL3",{name:e.name,plugin:e});if(jr.add(e),kr.add(e.name),!e.rxdb)throw I("PL1",{plugin:e});e.init&&e.init(),e.prototypes&&Object.entries(e.prototypes).forEach((e=>{let[t,r]=e;return r(wr[t])})),e.overwritable&&Object.assign(j,e.overwritable),e.hooks&&Object.entries(e.hooks).forEach((e=>{let[t,r]=e;r.after&&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:()=>y,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}],d={browser:.4,native:.4,performance:.35,server:.25,sourcecode:0,perpetual:0},h=.05;var u=r(1527),m=r(2658),p=r(2303),f=r(4848);function v(e){let{children:t,fallback:r}=e;return(0,p.A)()?(0,f.jsx)(f.Fragment,{children:t?.()}):r??null}const y="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(y);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(d).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)("a",{href:"/rx-server.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:"RxServer Fastify Adapter"}),(0,f.jsx)("p",{children:"An adapter to use the RxServer with fastify instead of express. Used to have better performance when serving requests."})]})})}),(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:"RxServer Koa Adapter"}),(0,f.jsx)("p",{children:"An adapter to use the RxServer with Koa instead of express. Used to have better performance when serving requests."})]})})}),(0,f.jsx)("a",{href:"/reactivity.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:"Reactivity Vue"}),(0,f.jsx)("p",{children:"An extension for Vue.js to get vue shallow-ref objects to observe RxDB state instead of rxjs observables."})]})})}),(0,f.jsx)("a",{href:"/reactivity.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:"Reactivity Preact Signals"}),(0,f.jsx)("p",{children:"An extension for react/preact to get preact signals to observe RxDB state instead of rxjs observables."})]})})})]})]})}),(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-server",type:"checkbox",className:"package-checkbox",defaultChecked:!0}),(0,f.jsx)("h4",{children:"Server Package"}),(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-server.html",target:"_blank",children:"RxServer Adapter Fastify"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/rx-server.html",target:"_blank",children:"RxServer Adapter Koa"})})]})]})}),(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.jsxs)("ul",{children:[(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/logger.html",target:"_blank",children:"Logger"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/reactivity.html",target:"_blank",children:"Reactivity Vue"})}),(0,f.jsx)("li",{children:(0,f.jsx)("a",{href:"/reactivity.html",target:"_blank",children:"Reactivity Preact Signals"})})]})]})}),(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,u.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=d[e];r+=t})),console.log("aimInPercent: "+r);let a=350+1.4*t*(r/100);if(2===e.packages.length?a*=.95:e.packages.length>2&&(a*=.9),e.companySize>1){let t=1+Math.pow(1*e.companySize-1,.45)/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")),v=(e,t)=>{console.log("setPrice:"),console.dir(t),e.innerHTML=Math.ceil(t).toString()},g=s.totalPrice/i.licensePeriod;v(f,"infinity"!==i.projectAmount?g/parseInt(i.projectAmount,10)/12:0);const b=await(0,m.C3)();await b.upsertLocal(y,{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)(v,{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:()=>d,dY:()=>a,em:()=>o,h$:()=>h,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 d(e){return void 0===e&&(e=void 0),l=l.then((()=>c(e)))}function h(e,t){return e.reduce(((e,t)=>e.then(t)),Promise.resolve(t))}},5734:(e,t,r)=>{r.d(t,{t:()=>n});var a=0;function n(){var e=Date.now();(e+=.01)<=a&&(e=a+.01);var t=parseFloat(e.toFixed(2));return a=t,t}}}]); \ No newline at end of file diff --git a/docs/assets/js/db34d6b0.18d7964e.js b/docs/assets/js/db34d6b0.8ce45070.js similarity index 99% rename from docs/assets/js/db34d6b0.18d7964e.js rename to docs/assets/js/db34d6b0.8ce45070.js index cf3cc374ed8..9024e32bbf6 100644 --- a/docs/assets/js/db34d6b0.18d7964e.js +++ b/docs/assets/js/db34d6b0.8ce45070.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}}])}((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}}])}((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"===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 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.18.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=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)))}}])}();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,e.collection.database)},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,e.collection.database)},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),this.collection.database)},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))}}])}();function Bt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Qt=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=Bt(this.collection._docCache,t)}),[{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,this.collection.database)}},{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}}])}();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}}])}();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}}])}();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,t=Rr(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Rr(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},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){var t=Rr(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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"]},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,r]=(0,i.useState)(null),h=(0,s.A)();return(0,i.useEffect)((()=>{console.log("use effect"),h&&(0,o.IA)()&&(async()=>{try{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,{})}}catch(a){console.log(a)}const e="https://rxdb.pipedrive.com/documents/p/"+new URLSearchParams(window.location.search).get("f");t!==e&&(r(e),setTimeout((()=>window.location.href=e),1e3))})()})),(0,c.jsx)(n.A,{title:`License Preview - ${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."})}),!!t&&(0,c.jsx)(c.Fragment,{children:(0,c.jsx)("p",{children:(0,c.jsx)("a",{href:t,children:"Click here to open the license agreement directly."})})})]})})})}},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}}])}((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}}])}((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"===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 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.18.2",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=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)))}}])}();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,e.collection.database)},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,e.collection.database)},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),this.collection.database)},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))}}])}();function Bt(e,t){for(var r=e.getCachedRxDocument,a=[],n=0;ne}};var Qt=function(){return(0,b.A)((function(e,t,r){this.time=(0,ce.t)(),this.collection=e,this.count=r,this.documents=Bt(this.collection._docCache,t)}),[{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,this.collection.database)}},{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}}])}();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}}])}();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}}])}();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,t=Rr(e);return t.getReactivityFactory().fromObservable(e.$,e.getLatest()._data,t)},get deleted$$(){var e=this,t=Rr(e);return t.getReactivityFactory().fromObservable(e.deleted$,e.getLatest().deleted,t)},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){var t=Rr(this);return t.getReactivityFactory().fromObservable(this.get$(e),this.getLatest().get(e),t)},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"]},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,r]=(0,i.useState)(null),h=(0,s.A)();return(0,i.useEffect)((()=>{console.log("use effect"),h&&(0,o.IA)()&&(async()=>{try{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,{})}}catch(a){console.log(a)}const e="https://rxdb.pipedrive.com/documents/p/"+new URLSearchParams(window.location.search).get("f");t!==e&&(r(e),setTimeout((()=>window.location.href=e),1e3))})()})),(0,c.jsx)(n.A,{title:`License Preview - ${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."})}),!!t&&(0,c.jsx)(c.Fragment,{children:(0,c.jsx)("p",{children:(0,c.jsx)("a",{href:t,children:"Click here to open the license agreement directly."})})})]})})})}},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.e87ecdb8.js b/docs/assets/js/main.f7f42393.js similarity index 99% rename from docs/assets/js/main.e87ecdb8.js rename to docs/assets/js/main.f7f42393.js index 825a73afb5b..3854f599d2b 100644 --- a/docs/assets/js/main.e87ecdb8.js +++ b/docs/assets/js/main.f7f42393.js @@ -1,2 +1,2 @@ -/*! For license information please see main.e87ecdb8.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(9425),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],"4f17bbdd":[()=>Promise.all([n.e(5106),n.e(2373)]).then(n.bind(n,1206)),"@site/src/pages/meeting-paid.tsx",1206],"502d8946":[()=>n.e(7817).then(n.bind(n,732)),"@site/src/pages/legal-notice.tsx",732],"51014a8a":[()=>n.e(9460).then(n.bind(n,262)),"@site/docs/articles/websockets-sse-polling-webrtc-webtransport.md",262],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],"7bbb96fd":[()=>Promise.all([n.e(5106),n.e(3495)]).then(n.bind(n,8435)),"@site/src/pages/service-submitted.tsx",8435],"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:"/meeting-paid",component:d("/meeting-paid","e3c"),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:"/service-submitted",component:d("/service-submitted","368"),exact:!0},{path:"/survey",component:d("/survey","9e0"),exact:!0},{path:"/",component:d("/","d82"),exact:!0},{path:"/",component:d("/","bd4"),routes:[{path:"/",component:d("/","a50"),routes:[{path:"/",component:d("/","bac"),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:"/articles/websockets-sse-polling-webrtc-webtransport.html",component:d("/articles/websockets-sse-polling-webrtc-webtransport.html","864"),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","b8d"),exact:!0,sidebar:"tutorialSidebar"},{path:"/slow-indexeddb.html",component:d("/slow-indexeddb.html","a40"),exact:!0,sidebar:"tutorialSidebar"},{path:"/third-party-plugins.html",component:d("/third-party-plugins.html","549"),exact:!0,sidebar:"tutorialSidebar"},{path:"/transactions-conflicts-revisions.html",component:d("/transactions-conflicts-revisions.html","53a"),exact:!0,sidebar:"tutorialSidebar"},{path:"/tutorials/typescript.html",component:d("/tutorials/typescript.html","a33"),exact:!0,sidebar:"tutorialSidebar"},{path:"/why-nosql.html",component:d("/why-nosql.html","ad0"),exact:!0,sidebar:"tutorialSidebar"}]}]}]},{path:"*",component:d("*")}]},6125:(e,t,n)=>{"use strict";n.d(t,{o:()=>o,x:()=>i});var r=n(6540),a=n(4848);const o=r.createContext(!1);function i(e){let{children:t}=e;const[n,i]=(0,r.useState)(!1);return(0,r.useEffect)((()=>{i(!0)}),[]),(0,a.jsx)(o.Provider,{value:n,children:t})}},8522:(e,t,n)=>{"use strict";var r=n(6540),a=n(5338),o=n(4625),i=n(545),l=n(8193);const s=[n(1911),n(119),n(6134),n(6294),n(1043)];var c=n(8328),u=n(6347),d=n(2831),p=n(2303),f=n(4848);function m(e){let{children:t}=e;const n=(0,p.A)();return(0,r.useEffect)((()=>{n&&(function(){const e="fixed-chat-button";if(document.getElementById(e))return;const t=document.createElement("a");t.id=e,t.href="/chat",t.target="_blank",t.innerHTML="\ud83d\udcac Community Chat";const n=document.createElement("style");n.type="text/css",n.innerText="#"+e+" {color: white;position: fixed;right: 0;bottom: 0;background-color: var(--color-top);padding-left: 17px;padding-right: 17px;padding-top: 10px;padding-bottom: 5px;text-align: center;margin-right: 50px;font-weight: bold;border-top-left-radius: 9px;border-top-right-radius: 9px;z-index: 11;}#fixed-chat-button:hover {box-shadow: 2px 2px 13px #ca007c, -2px -1px 14px #ff009e;text-decoration: underline;}",document.head.appendChild(n),document.body.appendChild(t)}(),function(){if("/"===location.pathname)return;const e=[{text:"Follow",keyword:"@twitter",url:"https://twitter.com/intent/user?screen_name=rxdbjs",icon:"\ud83d\udc26"},{text:"Follow",keyword:"@LinkedIn",url:"https://www.linkedin.com/company/rxdb",icon:"[in]"},{text:"Chat",keyword:"@discord",url:"https://rxdb.info/chat",icon:"\ud83d\udcac"},{text:"Star",keyword:"@github",url:"https://rxdb.info/code",icon:"\ud83d\udc19\ud83d\udcbb"},{text:"Subscribe",keyword:"@newsletter",url:"https://rxdb.info/newsletter",icon:"\ud83d\udcf0"}];function t(e,t){e.parentNode.insertBefore(t,e.nextSibling)}const n="rxdb-call-to-action-button";function r(){console.log("set call to action button");const r=6e5,a=Date.now(),o=(a-a%r)/r;console.log("timeslot "+o);const i=o%e.length;console.log("randid: "+i);const l=e[i],s=document.querySelector(".call-to-action");s&&s.parentNode.removeChild(s);const c=document.querySelector(".navbar__items");if(!c)return;const u=document.createElement("div");u.classList.add("call-to-action");const d=document.createElement("a");d.onclick=()=>{window.trigger("call-to-action",.35)},d.classList.add("hover-shadow-top"),d.id=n,d.innerHTML=l.text+' '+l.keyword+''+l.icon+"",d.href=l.url,d.target="_blank",u.append(d),t(c,u)}r()}())})),(0,f.jsx)(f.Fragment,{children:t})}var h=n(5260),g=n(4586),b=n(6025),y=n(6342),v=n(1003),w=n(2131),x=n(4090),k=n(2967),S=n(440),E=n(1463);function _(){const{i18n:{currentLocale:e,defaultLocale:t,localeConfigs:n}}=(0,g.A)(),r=(0,w.o)(),a=n[e].htmlLang,o=e=>e.replace("-","_");return(0,f.jsxs)(h.A,{children:[Object.entries(n).map((e=>{let[t,{htmlLang:n}]=e;return(0,f.jsx)("link",{rel:"alternate",href:r.createUrl({locale:t,fullyQualified:!0}),hrefLang:n},t)})),(0,f.jsx)("link",{rel:"alternate",href:r.createUrl({locale:t,fullyQualified:!0}),hrefLang:"x-default"}),(0,f.jsx)("meta",{property:"og:locale",content:o(a)}),Object.values(n).filter((e=>a!==e.htmlLang)).map((e=>(0,f.jsx)("meta",{property:"og:locale:alternate",content:o(e.htmlLang)},`meta-og-${e.htmlLang}`)))]})}function C(e){let{permalink:t}=e;const{siteConfig:{url:n}}=(0,g.A)(),r=function(){const{siteConfig:{url:e,baseUrl:t,trailingSlash:n}}=(0,g.A)(),{pathname:r}=(0,u.zy)();return e+(0,S.applyTrailingSlash)((0,b.A)(r),{trailingSlash:n,baseUrl:t})}(),a=t?`${n}${t}`:r;return(0,f.jsxs)(h.A,{children:[(0,f.jsx)("meta",{property:"og:url",content:a}),(0,f.jsx)("link",{rel:"canonical",href:a})]})}function T(){const{i18n:{currentLocale:e}}=(0,g.A)(),{metadata:t,image:n}=(0,y.p)();return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(h.A,{children:[(0,f.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),(0,f.jsx)("body",{className:x.w})]}),n&&(0,f.jsx)(v.be,{image:n}),(0,f.jsx)(C,{}),(0,f.jsx)(_,{}),(0,f.jsx)(E.A,{tag:k.Cy,locale:e}),(0,f.jsx)(h.A,{children:t.map(((e,t)=>(0,f.jsx)("meta",{...e},t)))})]})}const A=new Map;function j(e){if(A.has(e.pathname))return{...e,pathname:A.get(e.pathname)};if((0,d.u)(c.A,e.pathname).some((e=>{let{route:t}=e;return!0===t.exact})))return A.set(e.pathname,e.pathname),e;const t=e.pathname.trim().replace(/(?:\/index)?\.html$/,"")||"/";return A.set(e.pathname,t),{...e,pathname:t}}var N=n(6125),R=n(6988),L=n(205);function P(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{const r=t.default?.[e]??t[e];return r?.(...n)}));return()=>a.forEach((e=>e?.()))}const O=function(e){let{children:t,location:n,previousLocation:r}=e;return(0,L.A)((()=>{r!==n&&(!function(e){let{location:t,previousLocation:n}=e;if(!n)return;const r=t.pathname===n.pathname,a=t.hash===n.hash,o=t.search===n.search;if(r&&a&&!o)return;const{hash:i}=t;if(i){const e=decodeURIComponent(i.substring(1)),t=document.getElementById(e);t?.scrollIntoView()}else window.scrollTo(0,0)}({location:n,previousLocation:r}),P("onRouteDidUpdate",{previousLocation:r,location:n}))}),[r,n]),t};function I(e){const t=Array.from(new Set([e,decodeURI(e)])).map((e=>(0,d.u)(c.A,e))).flat();return Promise.all(t.map((e=>e.route.component.preload?.())))}class D extends r.Component{previousLocation;routeUpdateCleanupCb;constructor(e){super(e),this.previousLocation=null,this.routeUpdateCleanupCb=l.A.canUseDOM?P("onRouteUpdate",{previousLocation:null,location:this.props.location}):()=>{},this.state={nextRouteHasLoaded:!0}}shouldComponentUpdate(e,t){if(e.location===this.props.location)return t.nextRouteHasLoaded;const n=e.location;return this.previousLocation=this.props.location,this.setState({nextRouteHasLoaded:!1}),this.routeUpdateCleanupCb=P("onRouteUpdate",{previousLocation:this.previousLocation,location:n}),I(n.pathname).then((()=>{this.routeUpdateCleanupCb(),this.setState({nextRouteHasLoaded:!0})})).catch((e=>{console.warn(e),window.location.reload()})),!1}render(){const{children:e,location:t}=this.props;return(0,f.jsx)(O,{previousLocation:this.previousLocation,location:t,children:(0,f.jsx)(u.qh,{location:t,render:()=>e})})}}const M=D,F="__docusaurus-base-url-issue-banner-container",z="__docusaurus-base-url-issue-banner",B="__docusaurus-base-url-issue-banner-suggestion-container";function $(e){return`\ndocument.addEventListener('DOMContentLoaded', function maybeInsertBanner() {\n var shouldInsert = typeof window['docusaurus'] === 'undefined';\n shouldInsert && insertBanner();\n});\n\nfunction insertBanner() {\n var bannerContainer = document.createElement('div');\n bannerContainer.id = '${F}';\n var bannerHtml = ${JSON.stringify(function(e){return`\n
\n

Your Docusaurus site did not load properly.

\n

A very common reason is a wrong site baseUrl configuration.

\n

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

\n

We suggest trying baseUrl =

\n
\n`}(e)).replace(/{if("undefined"==typeof document)return void n();const r=document.createElement("link");r.setAttribute("rel","prefetch"),r.setAttribute("href",e),r.onload=()=>t(),r.onerror=()=>n();const a=document.getElementsByTagName("head")[0]??document.getElementsByName("script")[0]?.parentNode;a?.appendChild(r)}))}:function(e){return new Promise(((t,n)=>{const r=new XMLHttpRequest;r.open("GET",e,!0),r.withCredentials=!0,r.onload=()=>{200===r.status?t():n()},r.send(null)}))};var Y=n(6921);const J=new Set,Z=new Set,X=()=>navigator.connection?.effectiveType.includes("2g")||navigator.connection?.saveData,ee={prefetch(e){if(!(e=>!X()&&!Z.has(e)&&!J.has(e))(e))return!1;J.add(e);const t=(0,d.u)(c.A,e).flatMap((e=>{return t=e.route.path,Object.entries(Q).filter((e=>{let[n]=e;return n.replace(/-[^-]+$/,"")===t})).flatMap((e=>{let[,t]=e;return Object.values((0,Y.A)(t))}));var t}));return Promise.all(t.map((e=>{const t=n.gca(e);return t&&!t.includes("undefined")?K(t).catch((()=>{})):Promise.resolve()})))},preload:e=>!!(e=>!X()&&!Z.has(e))(e)&&(Z.add(e),I(e))},te=Object.freeze(ee),ne=Boolean(!0);if(l.A.canUseDOM){window.docusaurus=te;const e=document.getElementById("__docusaurus"),t=(0,f.jsx)(i.vd,{children:(0,f.jsx)(o.Kd,{children:(0,f.jsx)(V,{})})}),n=(e,t)=>{console.error("Docusaurus React Root onRecoverableError:",e,t)},l=()=>{if(ne)r.startTransition((()=>{a.hydrateRoot(e,t,{onRecoverableError:n})}));else{const o=a.createRoot(e,{onRecoverableError:n});r.startTransition((()=>{o.render(t)}))}};I(window.location.pathname).then(l)}},6988:(e,t,n)=>{"use strict";n.d(t,{o:()=>d,l:()=>p});var r=n(6540),a=n(4784);const o=JSON.parse('{"docusaurus-plugin-google-tag-manager":{"default":{"containerId":"GTM-PL63TR5","id":"default"}},"docusaurus-lunr-search":{"default":{"fileNames":{"searchDoc":"search-doc-1713968233231.json","lunrIndex":"lunr-index-1713968233231.json"}}},"docusaurus-plugin-google-gtag":{"default":{"trackingID":["G-62D63SY3S0"],"anonymizeIP":false,"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":"articles/websockets-sse-polling-webrtc-webtransport","path":"/articles/websockets-sse-polling-webrtc-webtransport.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","sidebar":"tutorialSidebar"},{"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