@kedem/okdb 2.2.1 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +287 -0
  2. package/algorithm-worker-thread.js +1 -1
  3. package/bin/okdb.js +1 -1
  4. package/docs/embeddings.md +83 -5
  5. package/docs/fts.md +1 -1
  6. package/docs/licensing.md +75 -14
  7. package/docs/manifest.json +1 -0
  8. package/docs/resolved-fields.md +79 -0
  9. package/okdb-functions-sandbox-worker.js +1 -1
  10. package/okdb-http-worker-child.js +1 -1
  11. package/okdb-views-bootstrap-worker.js +1 -1
  12. package/okdb.js +1 -1
  13. package/package.json +1 -1
  14. package/public/modules/ok.js +1 -1
  15. package/public/sections/db/modals/create-env-modal.ok.js +1 -1
  16. package/public/sections/db/modals/remove-env-modal.ok.js +1 -1
  17. package/public/sections/db/modals/schema-edit-modal.ok.js +1 -1
  18. package/public/sections/embeddings/parts/embed-create-panel.ok.js +1 -1
  19. package/public/sections/embeddings/parts/embed-search-panel.ok.js +1 -1
  20. package/public/sections/embeddings/parts/pipeline-try-search.ok.js +1 -1
  21. package/public/sections/license/parts/license-panel.ok.js +1 -1
  22. package/public/sections/queue/modals/create-bucket-modal.ok.js +1 -1
  23. package/public/sections/queue/modals/edit-bucket-modal.ok.js +1 -1
  24. package/public/sections/sync/index.ok.html +2 -2
  25. package/public/sections/sync/modals/connect-peer-modal.ok.js +1 -1
  26. package/public/sections/system/parts/system-sync-panel.ok.js +1 -1
  27. package/public/vendor/okjs/ok.esm.min.js +1 -1
  28. package/public/vendor/okjs/toolkit/devtools/devtools-window.js +1 -0
  29. package/public/vendor/okjs/toolkit/devtools/ok-console.ok.js +1 -1
  30. package/public/vendor/okjs/toolkit/devtools/ok-crash-explorer-service.ok.js +1 -0
  31. package/public/vendor/okjs/toolkit/devtools/ok-crash-explorer.ok.js +1 -0
  32. package/public/vendor/okjs/toolkit/elements/ok-icon.ok.js +1 -1
  33. package/public/vendor/okjs/toolkit/errors/crash-minimal.ok.js +1 -0
  34. package/public/vendor/okjs/toolkit/errors/ok-crash-boundary.ok.js +1 -1
  35. package/public/vendor/okjs/toolkit/errors/ok-crash-info.ok.js +1 -1
  36. package/public/vendor/okjs/toolkit/manifest.js +1 -1
  37. package/types/environment.d.ts +26 -0
  38. package/types/features/licenses.d.ts +86 -0
  39. package/types/index.d.ts +11 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,293 @@ All notable changes to `@kedem/okdb` are documented here. Format loosely follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.0.0/); versions follow [SemVer](https://semver.org/).
5
5
  Dates are release dates.
6
6
 
7
+ ## [2.3.2] - 2026-09-24
8
+
9
+ ### Changed
10
+
11
+ - **An index-maintenance error now aborts the write.** Secondary-index upkeep runs inside the
12
+ writer's transaction; an error there used to be logged and swallowed, so the document committed
13
+ without its index row (a unique index then silently stopped enforcing uniqueness for that key).
14
+ The error now fails the commit and the whole transaction rolls back. Writes that used to
15
+ "succeed" while silently skipping the index will now throw.
16
+ - **A non-scalar value in an indexed field is rejected with `INVALID_INDEX_KEY`.** An object,
17
+ array or `Date` in an indexed field could never be indexed; such writes committed without an
18
+ index row and now fail (see above). Index fields take `null`/missing, strings, numbers,
19
+ booleans, bigints or Buffers. A document already stored with such a value (from an earlier
20
+ version) stays updatable and removable: an unindexable old value is treated as having no row.
21
+ - **The console log sink honours `OKDB_LOG_LEVEL` (default `info`).** It printed every level, so
22
+ debug lines such as the queue's per-job "job claimed" reached the console. Set
23
+ `OKDB_LOG_LEVEL=debug` to get them back. The `~log` and relay sinks are unchanged.
24
+ - **The embeddings `_durable*` accessors are async.** `_durableIndexerStats`,
25
+ `_durableIndexerDocs`, `_durableIndexerDoc` and `_durableWorkerStats` now return promises (see
26
+ Fixed); callers must `await` them. The HTTP routes and pipeline inspect already do.
27
+
28
+ ### Fixed
29
+
30
+ - **Unique indexes lost their row under a stale lmdb key buffer.** lmdb-js `getValues()` inside a
31
+ write transaction decodes a discarded key from a shared buffer that can still hold the previous
32
+ write's bytes; when those looked like an ordered-binary number the read threw ("The number
33
+ 4.7e-66 cannot be converted to a BigInt"). The unique-index check hit it right after its own
34
+ write, and with the error swallowed the job committed without its index row, so the queue's
35
+ idempotency dedup was bypassed (seen while claiming embedding jobs in bulk). Duplicate-value
36
+ reads that can run in a write transaction (index uniqueness, views' live map, time machine,
37
+ FTS live tiers) now use key-bounded range reads that never decode stale bytes. Vacating a
38
+ `null` index key no longer counts the whole `null`-key duplicate set (every claimed queue job
39
+ did this).
40
+ - **The embeddings indexer no longer fails a drain on a duplicate job.** Queue-mode indexing
41
+ enqueues a batch in one transaction, so the queue's idempotency fallback didn't apply: a peer
42
+ enqueueing the same doc between the check and the commit failed the batch ("processor drain
43
+ error … Unique constraint violated") and the drain retried. The duplicate now folds into the
44
+ pending job, as a single `enqueue` does.
45
+ - **Queue: a job deleted mid-claim is skipped.** A job removed between the claim scan and the
46
+ claim update threw `NOT_FOUND`, which the consumer logged as "worker loop crashed". It is now a
47
+ lost race like a version conflict: the job is skipped and the next one claimed. Both lost-race
48
+ paths return the bucket tokens taken for that job (previously leaked on a version conflict).
49
+ - **A drain waiting for a resolver no longer spins.** On reopen of a store with FTS or an
50
+ embeddings indexer over a `resolveField` field, the processor drained before the app registered
51
+ the resolver and retried in a hot loop (~800 "processor drain error" warnings in 1.5 s). It now
52
+ holds quietly (cursor unchanged, `status().waiting` set, one debug line) and resumes when the
53
+ resolver is registered, on the next write, or on the catch-up tick. A holding process yields
54
+ its lease at once to a peer that wants it.
55
+ - **Embeddings durable stats see pipelines created by another process.** The durable indexer and
56
+ worker stats looked for the pipeline's sub-env only among envs already open, so a process that
57
+ attached before another process created the pipeline reported `done 0 / pending N`. They now
58
+ open the sub-env on demand.
59
+ - **The embeddings restart safety net resets only when vectors are really lost.** It reset the
60
+ cursor whenever the vector store was empty, so a pipeline whose docs legitimately yield no
61
+ vectors re-ran every doc on every restart. It now resets only when `doc_status` is missing or a
62
+ done, non-empty doc expects a vector that isn't there — and that reset now actually re-indexes
63
+ (it drops `doc_status` first, as `rebuild()` does; before, surviving done rows skipped every
64
+ doc).
65
+
66
+ ## [2.3.1] - 2026-09-24
67
+
68
+ ### Fixed
69
+
70
+ - **`ensureType` is race-safe across processes.** It checked for the type and then registered it
71
+ in a separate step, so two processes creating the same type in a shared env raced and the loser
72
+ threw "Register Type Error: <type> already registered" (seen when two processes opened the same
73
+ fresh env at first boot). The existence check now runs inside the write transaction, and a
74
+ peer's win counts as success. Indexes passed to `ensureType` get the same treatment: an index a
75
+ peer registered is adopted instead of being created or rebuilt a second time. Internal
76
+ check-then-register sites (`~envs`, `~engines`, `~pipelines`, functions, views, process
77
+ registry, `doc_status`, …) now use `ensureType`. An explicit `registerType` of an existing type
78
+ still throws.
79
+ - **The embeddings indexer commits as it goes.** An inline drain embedded every text of its batch
80
+ (up to 1 000 docs) before writing any vector or `doc_status` row. A large bootstrap showed zero
81
+ progress for many minutes (about 19 min for 372 source files on a local model), and a restart in
82
+ that window lost all of it. Vectors and `DONE` rows are now written every ~128 texts
83
+ (`batch` × 4), so progress is visible and durable, and a re-run skips committed docs.
84
+ - **A slow embeddings backlog no longer freezes the rest of the instance.** The indexer drained in
85
+ 5 000-change quanta, so a backlog of network-bound embed calls held the instance's processor
86
+ gate for the whole build (FTS and other pipelines' indexers sat still) and tripped the 60 s
87
+ drain deadline into error/retry cycles. It now drains in 32-change quanta, releasing the gate
88
+ between them, with a 10-minute drain deadline. Both can be overridden per pipeline
89
+ (`config.flushQuantum`, `config.drainDeadlineMs`).
90
+ - **`createPipeline` repairs a pipeline whose member engines are missing.** An existing pipeline
91
+ record always refused with "Pipeline already exists", so a record left pointing at engines that
92
+ were gone (removed, or lost to an interrupted create in another process) could never index and
93
+ could not be recovered by re-running an idempotent create. Missing members are now re-created
94
+ (existing ones reused) and a warning names them. A complete pipeline still refuses.
95
+ - **Named processor handlers work with two OKDB instances in one process.** The named-handler
96
+ registry is process-global, but the indexer, pipeline-processor and materializer drivers keep
97
+ their runtime per instance. A processor registered on the first instance after a second
98
+ instance opened dispatched to the second instance's handler, found nothing to do, and advanced
99
+ its cursor anyway, so those changes were silently never processed (e.g. a new pipeline or an
100
+ engine restart on a host's own store while an embedded library's store is also open). Handlers
101
+ now resolve their instance through a driver id carried in the processor payload.
102
+
103
+ ## [2.3.0] - 2026-09-24
104
+
105
+ ### Added
106
+
107
+ - **Resolved fields** (`env.resolveField(type, field, fn)`): index content okdb never stores.
108
+ FTS (live drain and builds), the embeddings indexer and search-result chunk text read the field
109
+ through an app-registered resolver when a row has no stored value — e.g. rows of `{ rel, hash }`
110
+ with file text served from disk. The declaration is durable; a process that runs those indexes
111
+ without the resolver holds them with `FIELD_RESOLVER_MISSING` (the drain waits for the resolver;
112
+ no doc is marked failed) instead of indexing empty text. A resolver error fails that item only. Also `unresolveField`, `resolvedFields`, `readField`.
113
+ **Batch resolvers** (`resolveField(type, field, fn, { batch, batchSize })`) resolve many rows per
114
+ call — FTS drains/builds and the embeddings indexer prefetch a whole batch in one call (for a
115
+ remote source: one round trip per batch instead of per row).
116
+ Measured on okdb's own `src/` (265 files, 5.2 MB): identical FTS and vector results, source
117
+ env 2.6 MB → 0.27 MB. See `docs/resolved-fields.md`.
118
+ - Vector search views: `algorithm_config.idleEvictMs` (or `OKDB_VECTOR_VIEW_IDLE_EVICT_MS`) sets
119
+ a view's idle-eviction delay (default 5 min; `0` keeps it resident; `stats()` reports it), and
120
+ usearch `algorithm_config.snapshotMaxLagMs` bounds reader lag (see Fixed).
121
+ - `okdb.embeddings.getEmbedderFactory(type)` / `getEmbedderSchema(type)`: the factory (built-in or
122
+ registered) and field schema of an embedder type, e.g. to wrap a built-in provider and supply its
123
+ API key at runtime instead of storing it in the pipeline's durable config.
124
+ - **`db.licenses`** — install and inspect licenses from code (after `open()`): `add(input)` takes
125
+ a license blob, an activation token (auto-detected) or `{ blob, activation }`, takes effect
126
+ immediately, and is idempotent (re-adding a stored license returns it with `changed:false`);
127
+ `activate(token)`, `remove(id)`, `list()`, `get(id)`, and `effective()` (the active license or
128
+ the free tier, with `enforced`). Results are summaries (`id`, `type`, `status`,
129
+ `needsActivation`, `pin`, `expiresAt`, `features`, `limits`) — never the blob or token. The
130
+ admin license routes and `okdb license` now go through it. See `docs/licensing.md`.
131
+ - **`OKDB_LICENSE_FILE`**: `open()` installs the license in that file (blob, token, or both)
132
+ through the same idempotent path, before license-gated features and engines start. A missing or
133
+ invalid file is a warning (error code only, never the content); `open()` continues.
134
+
135
+ ### Changed
136
+
137
+ - **Free tier covers embeddings pipelines and 5 environments** (unlicensed prod builds), so an
138
+ embedded code index — a management env plus one env per workspace, each with an embeddings
139
+ pipeline — works out of the box for up to three workspaces. `embeddings` is on: the members of
140
+ an embeddings pipeline (embedder, indexer, vector-search, embed-worker engines) are licensed by
141
+ `embeddings` as well as `engines`, and load at open when either is enabled (previously an
142
+ unlicensed boot skipped every engine). A new free-tier-only limit, `pipelinesPerEnv` (2), bounds
143
+ them — counted as the env's indexer engines, refused before any member is created. `envs`
144
+ (which counts `default`) is 5, was 2. The generic `engines` platform (custom drivers,
145
+ standalone engines of other types) stays licensed. Paid licenses are unaffected: the license
146
+ format has no `pipelinesPerEnv` field, so a license is never bounded by it; a license with
147
+ `embeddings` but not `engines` can now actually run pipelines. Internal (`~`) envs, which the
148
+ `envs` limit never counted, are no longer refused by it either (a pipeline's
149
+ `~<env>:emb:<type>` env failed once the user envs were at the limit). See `docs/licensing.md`.
150
+ - Admin license routes (`POST /admin/license`, `POST /admin/license/:id/activate`) return the
151
+ license summary (no raw blob/token), and re-adding a stored license is an idempotent success
152
+ (was a 400 "License already stored"). `okdb license <blob>` likewise reports "already stored"
153
+ instead of failing. Internally a duplicate add is `LICENSE_ALREADY_STORED` (was
154
+ `LICENSE_INVALID`, the same code as a bad signature).
155
+ - **Embeddings indexing rebuilt around one idempotent `reconcile`.** For each document the
156
+ indexer compares the chunk content hashes the source doc calls for with the vectors actually
157
+ stored, embeds only the missing ones, deletes the stale ones, and records the outcome. Inline
158
+ drains and queue workers share it. Measured on 100 docs × 768 dims, half of them edited once:
159
+ the embeddings env per doc went from 100 → 34 KB (queue, chunked), 61 → 30 KB (inline,
160
+ chunked), 13 → 9 KB (queue, unchunked).
161
+ - Queue jobs are references: payload `{ key }` only (was the full job context plus a copy of
162
+ the chunk text), one job per doc (was one per chunk), write bursts folded into the pending
163
+ job (`idempotency_scope: 'pending'`, see below). New `debounce` option (ms) holds jobs back so
164
+ an edit burst embeds only the final text.
165
+ - Embed requests are batched (`batch`, default 32), across documents in inline mode.
166
+ `embedBatch(texts)` is a new optional embedder hook; the built-in `openai` and `ollama`
167
+ embedders implement it natively (one HTTP request per batch).
168
+ - Editing a field the pipeline doesn't embed costs no embed call and no write (was a full
169
+ re-embed). Non-chunked docs record a content `hash` for this.
170
+ - The hash→vector cache is a bounded LRU (`cache`, default 1024) instead of every stored vector
171
+ loaded into memory at startup.
172
+ - **Vectors are stored as raw float32 bytes** (3 KB per 768-dim vector, was ~6.9 KB as a msgpack
173
+ float64 array). A raw `vec:` row read through the generic data API is now a byte buffer, not a
174
+ number array — use `okdb.embeddings.getVector()`. Pre-2.3 rows still decode (the migration
175
+ keeps them); they convert as they're rewritten.
176
+ - **`doc_status` rows are trimmed** to `source_key`, `status`, `version`, `clock`, `updated`,
177
+ `error`, `empty`, and `hash` (unchunked) or `chunks[{hash,start,end}]`. Gone: `engine_key`, `mode`, `created`,
178
+ `chunk_strategy`, `total_chunks`, chunk text. `error`/`empty` are present only when set.
179
+ Rows are ordered by the source doc `version` and never regress.
180
+ - **Deleting a source doc deletes its `doc_status` row** (no `deleted` tombstones kept forever).
181
+ - **`chunk_status:<storage_key>` is gone** (a second copy of every chunk manifest, rewritten per
182
+ chunk). `listDocStatus` still reports `chunk_done` for chunked docs.
183
+ - **`chunk.storeText` is ignored**: chunk text is no longer copied into `doc_status`; search
184
+ results derive it from the current source doc (`okdb.embeddings.describeChunk()`). The admin
185
+ UI's "Store chunk text" checkbox (on by default) is removed.
186
+ - **Storage migration `2.3.0` / `embeddings-lean-layout`** (runs once on first open, before
187
+ engines boot, recorded in `~migrations`): drops each pipeline's pre-2.3 `doc_status`,
188
+ `chunk_status` and queued embedding jobs, removes vectors whose source doc no longer exists,
189
+ and resets the indexer to replay from clock 0.
190
+ Vectors are kept — chunked docs rebuild their status from the stored chunk hashes with **no
191
+ embed calls** and search keeps serving throughout; unchunked docs re-embed once (pre-2.3 rows
192
+ carry no content hash). `OKDB_EMBEDDINGS_REEMBED=1` also drops the vectors for a full
193
+ re-embed. The store is stamped `2.3.0`, so okdb 2.2.x refuses to open it (it cannot read
194
+ the new vector encoding).
195
+ - `okdb.embeddings.describeChunk()` is now async (it may read a resolved field).
196
+ - Indexer API: `reconcile(key, { heartbeat })` added (the embed-worker's entry point);
197
+ `markDone` no longer takes a `chunks` manifest; `markDelete` removes the row.
198
+ - Queue: `enqueue(..., { idempotency_scope: 'pending' })` — the idempotency key dedups against
199
+ pending jobs only and is released at claim, so a change arriving while a job runs enqueues a
200
+ follow-up instead of folding into the running job.
201
+
202
+ ### Fixed
203
+
204
+ - **Queue calls wait out a peer's compaction instead of failing.** When another process
205
+ compacted the env, this process closed its handle for the ~seconds-long swap, and any queue call
206
+ in that window (`enqueue`, `markJobComplete`/`Fail`, `releaseClaim`, `getJob`, …) threw
207
+ `INVALID_STATE` "OKDB not opened" from its first read before reaching the write path's drain
208
+ park. Enqueues were lost, and finished jobs stayed `running` until their claim expired. Queue
209
+ entrypoints now wait for the reopen, as `env.put`/`txn` already did; a genuinely closed env still
210
+ fails immediately.
211
+
212
+ - **Vector search views now always converge to the stored vectors** (usearch and hnsw; flat
213
+ already did). A view that idle-evicted (5 min without a search) skipped live updates while
214
+ unloaded, and its next load served its own stale snapshot without replaying the stored
215
+ vectors — anything embedded while it was unloaded was missing from the graph for good (load 5,
216
+ evict, add 10, reload → 5 of 15). Every load (and every reader→writer promotion) now diffs the
217
+ snapshot against the `vec:` rows via per-key vector fingerprints stored with the snapshot
218
+ (labels v2) and applies the missing adds, replaced vectors and removes. A pre-2.3 snapshot
219
+ (no fingerprints) is rebuilt from the rows once.
220
+ - **usearch: a process holding `WRITER.LOCK` could be a reader, leaving nobody to write the
221
+ graph** (~2 in 10 evictions landing near a change-count publish). Ownership was by pid, so an
222
+ evicted view's replacement worker in the same process didn't recognise — or could release —
223
+ its sibling's lock; and a live update delivered to the not-yet-loaded replacement promoted it
224
+ to writer, after which its own load saw its fresh lock and turned reader while its heartbeat
225
+ kept the lock alive. The lock is now owned by a per-instance token (a writer whose lock was
226
+ taken over demotes itself), writes to an unloaded instance are dropped (the load reconciles
227
+ them), the fanout tail pins the instance for a batch, and a reload waits for the evicted
228
+ instance to publish and release first. A reader whose writer is gone takes over on its next
229
+ search instead of serving the last snapshot forever.
230
+ - **usearch/hnsw: change-count snapshot publishes stopped after the first eviction.** Snapshot
231
+ ids mixed two clocks — the changelog counter (change-count publishes) and `Date.now()`
232
+ (stop/eviction/explicit publishes) — so after one wall-clock publish every change-count publish
233
+ was rejected as stale, readers froze at that snapshot, and every later add re-saved the whole
234
+ index into a tmp dir that was then discarded. Internal publishes now use one monotonic id.
235
+ - **usearch readers are fresh within `snapshotMaxLagMs` (new, default 10 s)**: the writer
236
+ publishes once the oldest unpublished change is that old, stretched to 10× the last publish's
237
+ duration so a large index spends at most ~10% of its time saving. `snapshotEveryChanges`
238
+ (still 50 000) is now only a burst cap; as the only trigger it meant a reader of a typical
239
+ (< 50k) index never saw a publish until the writer's view was evicted.
240
+ - hnsw: growing past capacity rebuilt the graph from the rows captured at load, dropping every
241
+ vector added since; it now resizes in place.
242
+ - A usearch reader's cold load no longer reads and ships every stored vector to its worker
243
+ thread (the algorithm pulls rows only when it needs them); vectors cross to the worker as
244
+ Float32Arrays instead of boxed arrays.
245
+ - Search view `rebuild()` on an unloaded view marked it loaded without loading it.
246
+ - `removeEnvironment` deleted sub-environment directories (e.g. the embeddings env
247
+ `~<env>:emb:<type>`) using their RELATIVE registry path, i.e. relative to `process.cwd()`:
248
+ the real directory was left behind, and a same-named directory in the current working
249
+ directory would have been deleted instead. Paths now resolve under the store root, and a
250
+ non-absolute path is refused.
251
+ - Chunked queue-mode pipelines left the previous version's chunk vectors in place on every update
252
+ (a doc edited once held twice its vectors; search could match text the doc no longer has),
253
+ embedded superseded versions from queued jobs, and could report a doc DONE for an older
254
+ version while its current chunks were still pending.
255
+ - Deleting a source doc from a chunked queue-mode pipeline never removed its vectors (the delete
256
+ path called a storage `scan()` that the vector store doesn't have), so deleted docs stayed
257
+ searchable. The 2.3.0 migration removes the leftovers.
258
+ - `durableRetryDoc`/`durableRetryFailed`/`durableRebuild` now work for chunked queue-mode
259
+ pipelines too.
260
+ - Queue-mode embedding pipelines kept every completed job and its payload forever
261
+ (`~queue_jobs` / `~queue_payloads` in `~<env>:emb:<type>`) — one row pair per document, or
262
+ per chunk for chunked pipelines (whose payloads carry a copy of `chunk_text`), re-added on
263
+ every source update and "Re-embed all". Embedding jobs are now enqueued with `done_ttl: 0`
264
+ (deleted on completion; `doc_status` remains the durable record); jobs left by older builds
265
+ are dropped by the 2.3.0 migration. Failed jobs are still kept for inspection/retry. Side effect: the worker's "Queue" metric
266
+ now shows the real backlog instead of every job ever enqueued.
267
+ - **Writer: a transaction issued while another was held open ran nested inside it.** lmdb-js keeps
268
+ an async write txn open while its callback's promise is pending (FTS holds its post txn across
269
+ the docs commit); a `childTransaction` issued in that window ran synchronously inside the
270
+ holder's txn — the write silently joined it (lost if the holder aborted) and the writer crashed
271
+ on the non-promise result. New transactions on that writer now wait for the hold to settle; a
272
+ nested result from a caller outside the writer is accounted for and warned instead of crashing.
273
+ - **A failed FTS build left the index stuck in `RESETTING`** and `fts.ready()` waiting forever. The
274
+ index now goes to the `error` state (message in `fts.list(type)[i].error`) and `ready()` rejects
275
+ with `FTS_BUILD_FAILED`; `fts.reset()` or the next `open()` retries the build.
276
+ - A pending FTS reset racing a type drop crashed on its own "dropped before the reset completed"
277
+ guard.
278
+ - `removeEnvironment` (and env close) now deregisters the env's engines in-process — re-creating
279
+ the env and its pipeline in the same process failed with "Engine already exists".
280
+ - `pipelines.remove` now drops the pipeline's vectors and resets its indexer cursor (vectors were
281
+ kept forever, and a re-created pipeline skipped docs it had indexed before); `indexer.rebuild()`
282
+ on the lazy vector adapter really drops the vectors now.
283
+ - `embeddings.durableRebuild()` from a passive (`processors:false`/`engines:false`) process now
284
+ reaches the live indexer in the owning process (durable command epoch + a processor hint)
285
+ and makes it re-embed (the live indexer never noticed); a restart does not replay the reset.
286
+ Processors no longer re-run their last command at every registration, and a registration
287
+ stopped while acquiring its lease no longer leaks a heartbeating lease.
288
+ - `bus.stop()` flushes pending sends — hints sent right before close/exit were lost.
289
+ - Admin UI: works with `@kedem/okjs` 1.3 (its import of the removed `ok-crash-info` component
290
+ failed the whole module graph; the crash screen's details now come from
291
+ `ok-crash-explorer-service`), and Enter-to-submit works again in 10 dialogs
292
+ (`@keydown:enter` — `@keydown.enter` never bound a key filter).
293
+
7
294
  ## [2.2.1] - 2026-08-25
8
295
 
9
296
  ### Fixed
@@ -1 +1 @@
1
- 'use strict';const _0x2f1a82=_0x2846;(function(_0x2aea6c,_0x4fc697){const _0x371a7e=_0x2846,_0xf58f19=_0x2aea6c();while(!![]){try{const _0x585fa8=parseInt(_0x371a7e(0x1b8))/0x1*(-parseInt(_0x371a7e(0x1a4))/0x2)+parseInt(_0x371a7e(0x16d))/0x3*(parseInt(_0x371a7e(0x1e2))/0x4)+-parseInt(_0x371a7e(0x1bf))/0x5*(-parseInt(_0x371a7e(0x1a6))/0x6)+-parseInt(_0x371a7e(0x1be))/0x7*(parseInt(_0x371a7e(0x14c))/0x8)+parseInt(_0x371a7e(0x18b))/0x9*(parseInt(_0x371a7e(0x175))/0xa)+parseInt(_0x371a7e(0x1af))/0xb+-parseInt(_0x371a7e(0x169))/0xc*(parseInt(_0x371a7e(0x1e7))/0xd);if(_0x585fa8===_0x4fc697)break;else _0xf58f19['push'](_0xf58f19['shift']());}catch(_0x4f886d){_0xf58f19['push'](_0xf58f19['shift']());}}}(_0x370a,0x2c043));var require$$0$1=require(_0x2f1a82(0x1bd)),require$$0=require('fs'),require$$1=require('path'),require$$2=require('os'),require$$3=require(_0x2f1a82(0x159));function getDefaultExportFromCjs(_0x3f4552){const _0x6cf357=_0x2f1a82;return _0x3f4552&&_0x3f4552[_0x6cf357(0x1e1)]&&Object[_0x6cf357(0x162)][_0x6cf357(0x195)]['call'](_0x3f4552,'default')?_0x3f4552[_0x6cf357(0x187)]:_0x3f4552;}var algorithmWorkerThread$1={},snapshotStore,hasRequiredSnapshotStore;function requireSnapshotStore(){const _0x4af8a2=_0x2f1a82;if(hasRequiredSnapshotStore)return snapshotStore;hasRequiredSnapshotStore=0x1;const _0x290754=require$$0,_0x2884fc=require$$1,_0x4e3458=require$$2,_0x1146cb=require$$3;function _0x52951d(){const _0x29b424=_0x2846;return Date[_0x29b424(0x151)]();}function _0x20c3c6(_0x4858a6){const _0x4cf8db=_0x2846;try{return _0x290754[_0x4cf8db(0x172)](_0x4858a6);}catch{return![];}}function _0x50d3b7(_0x1be124){const _0x1deb48=_0x2846;try{return _0x290754[_0x1deb48(0x1ef)](_0x1be124,_0x1deb48(0x16b));}catch{return null;}}function _0x172b70(_0x2dc9fa,_0x347e6f){const _0x5f4a2b=_0x2846,_0x53028b=_0x2dc9fa+_0x5f4a2b(0x1e6)+_0x1146cb[_0x5f4a2b(0x1ac)](0x6)[_0x5f4a2b(0x1fd)]('hex');_0x290754[_0x5f4a2b(0x147)](_0x53028b,_0x347e6f),_0x290754[_0x5f4a2b(0x142)](_0x53028b,_0x2dc9fa);}function _0x3ea149(_0x151c97,_0x1af740=0x10){const _0x432520=_0x2846,_0x24f6eb=String(Math[_0x432520(0x152)](0x0,Math[_0x432520(0x166)](_0x151c97||0x0)));return _0x24f6eb[_0x432520(0x1aa)]>=_0x1af740?_0x24f6eb:'0'[_0x432520(0x1f2)](_0x1af740-_0x24f6eb[_0x432520(0x1aa)])+_0x24f6eb;}return snapshotStore=class _0x546e90{constructor({dir:_0x1802f1,keepSnapshots:keepSnapshots=0x3,log:log=null}={}){const _0x55b84e=_0x2846;if(!_0x1802f1)throw new Error(_0x55b84e(0x1c8));this[_0x55b84e(0x19d)]=_0x1802f1,this[_0x55b84e(0x15e)]=_0x2884fc[_0x55b84e(0x1a8)](_0x1802f1,'snapshots'),this['currentPath']=_0x2884fc[_0x55b84e(0x1a8)](_0x1802f1,_0x55b84e(0x16f)),this[_0x55b84e(0x1fe)]=_0x2884fc[_0x55b84e(0x1a8)](_0x1802f1,'SNAPSHOT.LOCK'),this[_0x55b84e(0x1ce)]=keepSnapshots,this[_0x55b84e(0x1d5)]=log,_0x290754[_0x55b84e(0x15c)](this[_0x55b84e(0x19d)],{'recursive':!![]}),_0x290754[_0x55b84e(0x15c)](this[_0x55b84e(0x15e)],{'recursive':!![]});}[_0x4af8a2(0x1d0)](_0x2eed42){const _0x2f7cfb=_0x4af8a2;return _0x2884fc[_0x2f7cfb(0x1a8)](this[_0x2f7cfb(0x15e)],_0x2eed42);}[_0x4af8a2(0x189)](_0x2fab5b){const _0x1c1d1f=_0x4af8a2,_0x305df7=this[_0x1c1d1f(0x1d0)](_0x2fab5b);return{'dir':_0x305df7,'index':_0x2884fc[_0x1c1d1f(0x1a8)](_0x305df7,_0x1c1d1f(0x167)),'labels':_0x2884fc[_0x1c1d1f(0x1a8)](_0x305df7,_0x1c1d1f(0x17c)),'state':_0x2884fc[_0x1c1d1f(0x1a8)](_0x305df7,_0x1c1d1f(0x1f4))};}[_0x4af8a2(0x1b3)](){const _0x3074a4=_0x4af8a2;if(!_0x20c3c6(this[_0x3074a4(0x14f)]))return null;const _0x4e5d8f=_0x50d3b7(this[_0x3074a4(0x14f)]);if(!_0x4e5d8f)return null;const _0x44d117=String(_0x4e5d8f)[_0x3074a4(0x198)]();return _0x44d117||null;}[_0x4af8a2(0x16e)](){const _0x54be46=_0x4af8a2,_0x21e06b=this[_0x54be46(0x1b3)]();if(!_0x21e06b)return 0x0;const _0x5e2392=Number(_0x21e06b);return Number[_0x54be46(0x148)](_0x5e2392)?_0x5e2392:0x0;}[_0x4af8a2(0x1c5)](){const _0x141878=_0x4af8a2;try{return _0x290754[_0x141878(0x1ee)](this['snapshotsDir'],{'withFileTypes':!![]})[_0x141878(0x17d)](_0x28f6f7=>_0x28f6f7['isDirectory']())['map'](_0x1980b7=>_0x1980b7[_0x141878(0x14e)])['filter'](_0x49bc9a=>!_0x49bc9a[_0x141878(0x1a1)](_0x141878(0x1e6)))[_0x141878(0x17d)](_0x3524ff=>!_0x3524ff[_0x141878(0x1a1)](_0x141878(0x1a2)))[_0x141878(0x156)]();}catch{return[];}}[_0x4af8a2(0x19b)](){const _0x2b1466=_0x4af8a2,_0x5ae4a4=this[_0x2b1466(0x1b3)]();if(_0x5ae4a4)return _0x5ae4a4;const _0x31ee34=this[_0x2b1466(0x1c5)]();if(!_0x31ee34[_0x2b1466(0x1aa)])return null;return _0x31ee34[_0x31ee34['length']-0x1];}[_0x4af8a2(0x173)]({maxAgeMs:maxAgeMs=0x6*0x36ee80}={}){const _0x32f38e=_0x4af8a2;let _0x524d11;try{_0x524d11=_0x290754['readdirSync'](this[_0x32f38e(0x15e)],{'withFileTypes':!![]});}catch{return;}const _0x32aac2=_0x52951d()-maxAgeMs;for(const _0x598d50 of _0x524d11){if(!_0x598d50[_0x32f38e(0x19e)]())continue;const _0x17662c=_0x598d50[_0x32f38e(0x14e)];if(!_0x17662c[_0x32f38e(0x1a1)](_0x32f38e(0x1e6))&&!_0x17662c[_0x32f38e(0x1a1)]('_tmp-'))continue;const _0x2a4b70=_0x2884fc['join'](this[_0x32f38e(0x15e)],_0x17662c);try{const _0x3db0c1=_0x290754[_0x32f38e(0x190)](_0x2a4b70);if(_0x3db0c1[_0x32f38e(0x1dc)]>_0x32aac2)continue;}catch{}try{_0x290754[_0x32f38e(0x1c0)](_0x2a4b70,{'recursive':!![],'force':!![]});}catch{}}}['prune']({keep:keep=null}={}){const _0x2099fc=_0x4af8a2,_0x4ef4c1=Math[_0x2099fc(0x152)](0x1,Math[_0x2099fc(0x166)](keep??this[_0x2099fc(0x1ce)]??0x3)),_0x240cf4=this[_0x2099fc(0x1c5)]();if(_0x240cf4[_0x2099fc(0x1aa)]<=_0x4ef4c1)return;const _0x7d6f67=this[_0x2099fc(0x1b3)](),_0x523ca7=_0x240cf4[_0x2099fc(0x1a5)](0x0,Math[_0x2099fc(0x152)](0x0,_0x240cf4[_0x2099fc(0x1aa)]-_0x4ef4c1));for(const _0x3869a1 of _0x523ca7){if(_0x7d6f67&&_0x3869a1===_0x7d6f67)continue;const _0x42c47d=this[_0x2099fc(0x1d0)](_0x3869a1);try{_0x290754[_0x2099fc(0x1c0)](_0x42c47d,{'recursive':!![],'force':!![]});}catch{}}}async[_0x4af8a2(0x168)](_0x35c8d9,_0x5f3eba){const _0x264387=_0x4af8a2;if(!_0x35c8d9)throw new Error(_0x264387(0x153));const _0x5d38ac=this['_snapshotPaths'](_0x35c8d9);if(!_0x20c3c6(_0x5d38ac[_0x264387(0x1cc)])||!_0x20c3c6(_0x5d38ac[_0x264387(0x186)])||!_0x20c3c6(_0x5d38ac['state']))throw new Error(_0x264387(0x1f6)+_0x35c8d9);const _0x40b67e=await _0x5f3eba(_0x5d38ac);return _0x40b67e||{};}async[_0x4af8a2(0x1b9)](_0x518c63,_0x21ef18,{keep:keep=null,lockTimeoutMs:lockTimeoutMs=0x0,staleLockMaxAgeMs:staleLockMaxAgeMs=0xea60}={}){const _0x3ccbbf=_0x4af8a2,_0x286f6b=Number(_0x518c63);if(!Number[_0x3ccbbf(0x148)](_0x286f6b)||_0x286f6b<0x0)throw new Error(_0x3ccbbf(0x17f));const _0x3bebd2=_0x3ea149(_0x286f6b),_0x2ed883=this['_snapshotDir'](_0x3bebd2),_0x5946f0=_0x2884fc['join'](this[_0x3ccbbf(0x15e)],_0x3ccbbf(0x1e6)+_0x3bebd2+'-'+_0x1146cb[_0x3ccbbf(0x1ac)](0x6)[_0x3ccbbf(0x1fd)](_0x3ccbbf(0x19c)));_0x290754['mkdirSync'](_0x5946f0,{'recursive':!![]});const _0x37022a={'dir':_0x5946f0,'index':_0x2884fc[_0x3ccbbf(0x1a8)](_0x5946f0,_0x3ccbbf(0x167)),'labels':_0x2884fc[_0x3ccbbf(0x1a8)](_0x5946f0,_0x3ccbbf(0x17c)),'state':_0x2884fc[_0x3ccbbf(0x1a8)](_0x5946f0,'state.json')};await _0x21ef18(_0x37022a,{'id':_0x3bebd2,'clock':_0x286f6b});const _0x5d5594=JSON[_0x3ccbbf(0x1e0)]({'pid':process[_0x3ccbbf(0x1f5)],'host':_0x4e3458[_0x3ccbbf(0x1b2)](),'at':_0x52951d()}),_0x4b7eea=_0x52951d();let _0x1c2d24=null;const _0x1778ec=()=>{const _0x1cc440=_0x3ccbbf;try{const _0x532a7e=JSON[_0x1cc440(0x1ea)](_0x290754[_0x1cc440(0x1ef)](this['lockPath'],_0x1cc440(0x16b)));if(_0x532a7e['at']&&_0x52951d()-_0x532a7e['at']>staleLockMaxAgeMs){const _0x21d864=_0x52951d()-_0x532a7e['at'],_0x18f970='Breaking\x20stale\x20snapshot\x20lock\x20(age:\x20'+Math[_0x1cc440(0x19f)](_0x21d864/0x3e8)+_0x1cc440(0x1db)+_0x532a7e[_0x1cc440(0x1f5)]+_0x1cc440(0x15b)+_0x532a7e[_0x1cc440(0x202)]+_0x1cc440(0x1b4)+_0x1cc440(0x18d);this[_0x1cc440(0x1d5)]?.[_0x1cc440(0x185)]?this[_0x1cc440(0x1d5)]['warn'](_0x18f970):console[_0x1cc440(0x185)](_0x1cc440(0x1f3),_0x18f970);try{_0x290754['unlinkSync'](this[_0x1cc440(0x1fe)]);}catch{}return!![];}}catch{try{_0x290754[_0x1cc440(0x16a)](this[_0x1cc440(0x1fe)]);}catch{}}return![];},_0x3a5fd1=()=>{const _0x2553af=_0x3ccbbf;try{return _0x1c2d24=_0x290754['openSync'](this[_0x2553af(0x1fe)],'wx'),_0x290754[_0x2553af(0x147)](_0x1c2d24,_0x5d5594),!![];}catch(_0x55655a){if(_0x55655a&&_0x55655a['code']===_0x2553af(0x1dd))return![];throw _0x55655a;}};if(!_0x3a5fd1()){_0x1778ec(),_0x3a5fd1();if(_0x1c2d24==null&&lockTimeoutMs>0x0)while(_0x52951d()-_0x4b7eea<lockTimeoutMs){await new Promise(_0x319c38=>setTimeout(_0x319c38,0x19));if(_0x3a5fd1())break;_0x1778ec();}}if(_0x1c2d24==null){try{_0x290754[_0x3ccbbf(0x1c0)](_0x5946f0,{'recursive':!![],'force':!![]});}catch{}return{'published':![],'reason':_0x3ccbbf(0x1ba)};}try{const _0x41c0d5=this[_0x3ccbbf(0x16e)]();if(_0x286f6b<=_0x41c0d5){try{_0x290754[_0x3ccbbf(0x1c0)](_0x5946f0,{'recursive':!![],'force':!![]});}catch{}return{'published':![],'reason':_0x3ccbbf(0x150),'currentClock':_0x41c0d5};}if(!_0x20c3c6(_0x2ed883))_0x290754['renameSync'](_0x5946f0,_0x2ed883);else try{_0x290754[_0x3ccbbf(0x1c0)](_0x5946f0,{'recursive':!![],'force':!![]});}catch{}return _0x172b70(this[_0x3ccbbf(0x14f)],_0x3bebd2+'\x0a'),this[_0x3ccbbf(0x1c3)]({'keep':keep}),{'published':!![],'currentClock':_0x286f6b};}finally{try{_0x290754[_0x3ccbbf(0x141)](_0x1c2d24);}catch{}try{_0x290754[_0x3ccbbf(0x16a)](this[_0x3ccbbf(0x1fe)]);}catch{}}}},snapshotStore;}var labelMap,hasRequiredLabelMap;function requireLabelMap(){const _0x42ffc7=_0x2f1a82;if(hasRequiredLabelMap)return labelMap;hasRequiredLabelMap=0x1;const _0x311ec8=require$$0;class _0x5ec987{constructor(){const _0x533b6c=_0x2846;this[_0x533b6c(0x1df)]=new Map(),this[_0x533b6c(0x174)]=new Map(),this[_0x533b6c(0x1e4)]=0x0,this['_tombstoneCount']=0x0;}async[_0x42ffc7(0x1d9)](){const _0x1d2cdd=_0x42ffc7;this[_0x1d2cdd(0x1df)]=new Map(),this[_0x1d2cdd(0x174)]=new Map(),this[_0x1d2cdd(0x1e4)]=0x0,this[_0x1d2cdd(0x1f7)]=0x0;}async[_0x42ffc7(0x183)](_0x280b9b){const _0x343ef9=_0x42ffc7;if(!_0x280b9b||!_0x311ec8[_0x343ef9(0x172)](_0x280b9b))return await this[_0x343ef9(0x1d9)](),!![];let _0x2938a0;try{_0x2938a0=_0x311ec8[_0x343ef9(0x1ef)](_0x280b9b,'utf8');}catch{return await this[_0x343ef9(0x1d9)](),!![];}let _0x17da1c;try{_0x17da1c=JSON[_0x343ef9(0x1ea)](_0x2938a0);}catch{return await this[_0x343ef9(0x1d9)](),!![];}const _0x595942=Array[_0x343ef9(0x18f)](_0x17da1c?.['entries'])?_0x17da1c[_0x343ef9(0x1c2)]:[],_0x1de8d6=Number[_0x343ef9(0x182)](_0x17da1c?.[_0x343ef9(0x1e4)])?_0x17da1c['nextLabel']:0x0,_0x3770f5=new Map(),_0x392186=new Map();let _0x211d57=-0x1;for(const _0x3a1de7 of _0x595942){if(!Array[_0x343ef9(0x18f)](_0x3a1de7)||_0x3a1de7[_0x343ef9(0x1aa)]!==0x2)continue;const _0x540a99=Number(_0x3a1de7[0x0]),_0x44c427=String(_0x3a1de7[0x1]??'');if(!Number[_0x343ef9(0x182)](_0x540a99)||_0x540a99<0x0)continue;if(!_0x44c427)continue;_0x3770f5['set'](_0x44c427,_0x540a99),_0x392186[_0x343ef9(0x1c1)](_0x540a99,_0x44c427);if(_0x540a99>_0x211d57)_0x211d57=_0x540a99;}return this['keyToLabel']=_0x3770f5,this[_0x343ef9(0x174)]=_0x392186,this[_0x343ef9(0x1e4)]=Math['max'](_0x1de8d6,_0x211d57+0x1,0x0),this[_0x343ef9(0x1f7)]=0x0,!![];}[_0x42ffc7(0x1d6)](_0x528398){const _0x522270=_0x42ffc7;return this[_0x522270(0x1df)][_0x522270(0x15f)](_0x528398);}[_0x42ffc7(0x1ed)](_0xd9ba14){const _0x276c33=_0x42ffc7;let _0xcd43f=this[_0x276c33(0x1df)][_0x276c33(0x15f)](_0xd9ba14);if(_0xcd43f!==undefined)return _0xcd43f;return _0xcd43f=this[_0x276c33(0x1e4)]++,this[_0x276c33(0x1df)][_0x276c33(0x1c1)](_0xd9ba14,_0xcd43f),this['labelToKey']['set'](_0xcd43f,_0xd9ba14),_0xcd43f;}['tombstone'](_0x5a5c6e){const _0x5cf618=_0x42ffc7,_0x439425=this[_0x5cf618(0x1df)]['get'](_0x5a5c6e);if(_0x439425===undefined)return;this[_0x5cf618(0x1df)][_0x5cf618(0x199)](_0x5a5c6e),this[_0x5cf618(0x174)]['delete'](_0x439425),this[_0x5cf618(0x1f7)]++;}[_0x42ffc7(0x1b5)](_0x627b4b){const _0x50460b=_0x42ffc7;return this[_0x50460b(0x174)][_0x50460b(0x15f)](_0x627b4b)??null;}[_0x42ffc7(0x194)](){const _0x11cef1=_0x42ffc7;return this[_0x11cef1(0x1df)]['size'];}[_0x42ffc7(0x13f)](){const _0x428c52=_0x42ffc7;return this[_0x428c52(0x1f7)];}async[_0x42ffc7(0x157)](_0x52d5bc){const _0x1c0d10=_0x42ffc7,_0x4a9712=_0x52d5bc+'.tmp',_0x1aa552=[];for(const [_0x585707,_0x56d5c1]of this['labelToKey'][_0x1c0d10(0x1c2)]()){_0x1aa552['push']([_0x585707,_0x56d5c1]);}_0x1aa552[_0x1c0d10(0x156)]((_0x1ee77b,_0x18cf90)=>_0x1ee77b[0x0]-_0x18cf90[0x0]);const _0x5e1594={'version':0x1,'nextLabel':this[_0x1c0d10(0x1e4)],'entries':_0x1aa552};_0x311ec8[_0x1c0d10(0x147)](_0x4a9712,JSON[_0x1c0d10(0x1e0)](_0x5e1594)),_0x311ec8[_0x1c0d10(0x142)](_0x4a9712,_0x52d5bc);}}return labelMap=_0x5ec987,labelMap;}var hnsw,hasRequiredHnsw;function requireHnsw(){if(hasRequiredHnsw)return hnsw;hasRequiredHnsw=0x1;const _0x1a1c9e=requireSnapshotStore(),_0x58301f=requireLabelMap(),_0x9eae49=0x1;let _0x175d4a=null;function _0x45376c(){const _0x1693fd=_0x2846;if(_0x175d4a)return _0x175d4a;try{return _0x175d4a=require(_0x1693fd(0x158)),_0x175d4a;}catch(_0x385860){const _0x4e4aae=new Error(_0x1693fd(0x181)+('for\x20Node\x20'+process[_0x1693fd(0x15a)]['node']+_0x1693fd(0x18a)+process[_0x1693fd(0x1bc)]+'/'+process[_0x1693fd(0x155)]+'.\x20')+'Install\x20compatible\x20bindings\x20or\x20use\x20algorithm\x20\x22flat\x22\x20instead.\x20'+(_0x1693fd(0x1de)+(_0x385860?.[_0x1693fd(0x143)]||String(_0x385860))));_0x4e4aae[_0x1693fd(0x14a)]='HNSW_BINDINGS_UNAVAILABLE',_0x4e4aae['cause']=_0x385860;throw _0x4e4aae;}}return hnsw=function _0x73344d(_0x59ab68={},{dims:_0x3cdb63,dir:_0x52b725}){const _0x4829e9=_0x2846,_0x263f57=_0x45376c();if(!_0x3cdb63||_0x3cdb63<=0x0)throw new Error('hnsw\x20algorithm\x20requires\x20dims\x20>\x200');if(!_0x52b725)throw new Error(_0x4829e9(0x1d8));const _0x4754c9={'metric':_0x59ab68[_0x4829e9(0x15d)]??_0x4829e9(0x1a7),'M':_0x59ab68['M']??0x10,'efConstruction':_0x59ab68[_0x4829e9(0x191)]??0xc8,'efSearch':_0x59ab68[_0x4829e9(0x1fc)]??0x40,'maxElements':_0x59ab68['maxElements']??0x400,'growFactor':_0x59ab68[_0x4829e9(0x1f1)]??0x2,'snapshotEveryChanges':_0x59ab68['snapshotEveryChanges']??0xc350,'keepSnapshots':_0x59ab68['keepSnapshots']??0x2,'tmpMaxAgeMs':_0x59ab68[_0x4829e9(0x178)]??0x6*0x36ee80},_0x27ea57=new _0x1a1c9e({'dir':_0x52b725,'keepSnapshots':_0x4754c9[_0x4829e9(0x1ce)]}),_0x4afa80=new _0x58301f();let _0x41471f=null,_0x50fdba=0x0,_0x220482=null,_0x41baf2=Promise[_0x4829e9(0x160)]();const _0x26b730=_0x37de0e=>{const _0x41c831=_0x4829e9;return _0x41baf2=_0x41baf2[_0x41c831(0x1c9)](_0x37de0e),_0x41baf2;};async function _0x4baa16(_0x2434c5){const _0x57b300=_0x4829e9;await _0x4afa80[_0x57b300(0x1d9)]();const _0x1e70f4=_0x2434c5?await _0x2434c5():[],_0x558b2d=Math[_0x57b300(0x152)](_0x4754c9[_0x57b300(0x165)],Math['ceil'](_0x1e70f4[_0x57b300(0x1aa)]*(_0x4754c9[_0x57b300(0x1f1)]||1.2)),0x1);_0x41471f=new _0x263f57['HierarchicalNSW'](_0x4754c9[_0x57b300(0x15d)],_0x3cdb63),_0x41471f['initIndex']({'maxElements':_0x558b2d,'efConstruction':_0x4754c9[_0x57b300(0x191)],'M':_0x4754c9['M']});for(const {key:_0x457d98,vector:_0xbe283e}of _0x1e70f4){if(!(_0xbe283e instanceof Float32Array)||_0xbe283e[_0x57b300(0x1aa)]!==_0x3cdb63)continue;const _0x2b5c0c=_0x4afa80[_0x57b300(0x1ed)](_0x457d98);_0x41471f['addPoint'](Array[_0x57b300(0x203)](_0xbe283e),_0x2b5c0c);}_0x41471f[_0x57b300(0x1f8)](_0x4754c9[_0x57b300(0x1fc)]),_0x50fdba=0x0;}async function _0x37f2e6(_0x4389a5){const _0x1638b6=_0x4829e9;if(!_0x41471f||!_0x4389a5)return![];const _0x10a851=await _0x27ea57[_0x1638b6(0x1b9)](_0x4389a5,async _0x2ba27a=>{const _0x39504f=_0x1638b6;_0x41471f[_0x39504f(0x180)](_0x2ba27a[_0x39504f(0x1cc)]),await _0x4afa80['snapshotTo'](_0x2ba27a[_0x39504f(0x186)]);const _0x1fc22a=require$$0;_0x1fc22a['writeFileSync'](_0x2ba27a['state'],JSON[_0x39504f(0x1e0)]({'manifestVersion':_0x9eae49,'dims':_0x3cdb63,'metric':_0x4754c9[_0x39504f(0x15d)],'clock':_0x4389a5,'snapshotAt':Date[_0x39504f(0x151)]()},null,0x2));},{'keep':_0x4754c9[_0x1638b6(0x1ce)]});if(_0x10a851?.[_0x1638b6(0x14d)])_0x50fdba=0x0;return _0x10a851?.[_0x1638b6(0x14d)]??![];}async function _0x1842b7(){const _0xa2fc6a=_0x4829e9,_0x270a72=_0x27ea57[_0xa2fc6a(0x1b3)]()||_0x27ea57[_0xa2fc6a(0x19b)]();if(!_0x270a72)return null;let _0xb57bf2,_0x25fdd0=![];return await _0x27ea57[_0xa2fc6a(0x168)](_0x270a72,async _0x48d86e=>{const _0x440482=_0xa2fc6a,_0x115e9a=require$$0;_0xb57bf2=JSON[_0x440482(0x1ea)](_0x115e9a[_0x440482(0x1ef)](_0x48d86e[_0x440482(0x193)],'utf8'));if(_0xb57bf2['manifestVersion']!==_0x9eae49||_0xb57bf2[_0x440482(0x1ca)]!==_0x3cdb63||_0xb57bf2[_0x440482(0x15d)]!==_0x4754c9[_0x440482(0x15d)]){_0xb57bf2=null;return;}await _0x4afa80[_0x440482(0x183)](_0x48d86e[_0x440482(0x186)]),_0x41471f=new _0x263f57['HierarchicalNSW'](_0x4754c9[_0x440482(0x15d)],_0x3cdb63),_0x41471f['readIndexSync'](_0x48d86e[_0x440482(0x1cc)]),_0x41471f[_0x440482(0x1f8)](_0x4754c9['efSearch']),_0x25fdd0=!![];}),_0x25fdd0?_0xb57bf2?.[_0xa2fc6a(0x14b)]??0x0:null;}return{async 'load'(_0x27c301){return _0x26b730(async()=>{const _0x5ee368=_0x2846;_0x27ea57[_0x5ee368(0x173)]({'maxAgeMs':_0x4754c9[_0x5ee368(0x178)]}),_0x220482=_0x27c301??null;const _0x30487c=await _0x1842b7();if(_0x30487c!=null)return _0x30487c;return await _0x4baa16(_0x27c301),null;});},async 'add'(_0x232211,_0x4c165e,_0x10ca81){return _0x26b730(async()=>{const _0x40eb8a=_0x2846;if(!_0x41471f)return;const _0x49ada6=_0x4afa80[_0x40eb8a(0x1ed)](_0x232211);try{_0x41471f[_0x40eb8a(0x18e)](_0x49ada6);}catch{}_0x41471f[_0x40eb8a(0x1d7)]()>=_0x41471f[_0x40eb8a(0x1bb)]()&&(_0x4754c9['maxElements']=Math[_0x40eb8a(0x204)](_0x41471f[_0x40eb8a(0x1bb)]()*(_0x4754c9[_0x40eb8a(0x1f1)]||0x2)),await _0x4baa16(_0x220482)),_0x41471f['addPoint'](Array[_0x40eb8a(0x203)](_0x4c165e),_0x49ada6),_0x50fdba++,_0x50fdba>=_0x4754c9[_0x40eb8a(0x197)]&&await _0x37f2e6(_0x10ca81??Date[_0x40eb8a(0x151)]());});},async 'remove'(_0x37e79f){return _0x26b730(async()=>{const _0x35c143=_0x2846;if(!_0x41471f)return;const _0xebf3e0=_0x4afa80[_0x35c143(0x1d6)](_0x37e79f);if(_0xebf3e0===undefined)return;try{_0x41471f[_0x35c143(0x18e)](_0xebf3e0);}catch{}_0x4afa80[_0x35c143(0x201)](_0x37e79f),_0x50fdba++;});},'search'(_0x38940d,{limit:limit=0xa,efSearch:_0x5eb1cb}={}){const _0x11534c=_0x4829e9;if(!_0x41471f)return[];if(Number[_0x11534c(0x182)](_0x5eb1cb))_0x41471f[_0x11534c(0x1f8)](_0x5eb1cb);const _0x3dfa73=Math[_0x11534c(0x1f9)](limit,_0x41471f[_0x11534c(0x1d7)]()||0x1),{neighbors:_0x665cb3,distances:_0x252474}=_0x41471f[_0x11534c(0x154)](Array[_0x11534c(0x203)](_0x38940d),_0x3dfa73),_0x314765=[];for(let _0x3da042=0x0;_0x3da042<_0x665cb3[_0x11534c(0x1aa)];_0x3da042++){const _0x55b10c=_0x4afa80['keyForLabel'](_0x665cb3[_0x3da042]);if(!_0x55b10c)continue;const _0x702c10=_0x4754c9[_0x11534c(0x15d)]===_0x11534c(0x1a7)?Math[_0x11534c(0x152)](0x0,0x1-_0x252474[_0x3da042]):0x1/(0x1+_0x252474[_0x3da042]);_0x314765[_0x11534c(0x200)]({'key':_0x55b10c,'score':_0x702c10});}return _0x314765;},async 'snapshot'(_0x446c02=Date[_0x4829e9(0x151)]()){return _0x26b730(()=>_0x37f2e6(_0x446c02));},async 'rebuild'(_0x78fd1){return _0x26b730(()=>{if(_0x78fd1!=null)_0x220482=_0x78fd1;return _0x4baa16(_0x78fd1??_0x220482);});},async 'stop'(){const _0xf450aa=_0x4829e9;return _0x26b730(()=>_0x37f2e6(Date[_0xf450aa(0x151)]()));},'count'(){const _0x19eecb=_0x4829e9;return _0x4afa80[_0x19eecb(0x194)]();},'info'(){const _0x174b20=_0x4829e9;return{'algorithm':_0x174b20(0x177),'metric':_0x4754c9[_0x174b20(0x15d)],'M':_0x4754c9['M'],'efConstruction':_0x4754c9[_0x174b20(0x191)],'efSearch':_0x4754c9[_0x174b20(0x1fc)],'maxElements':_0x41471f?.[_0x174b20(0x1bb)]()??_0x4754c9['maxElements'],'count':_0x4afa80[_0x174b20(0x194)](),'changesSince':_0x50fdba,'snapshotDir':_0x52b725,'latestSnapshot':_0x27ea57[_0x174b20(0x1b3)]()??null};}};},hnsw;}function _0x370a(){const _0x5b10f0=['Unknown\x20op:\x20\x22','ScalarKind','2699yuhmmI','publishSnapshot','lock_busy','getMaxElements','platform','worker_threads','21CXckPN','25pvyUyZ','rmSync','set','entries','prune','Cos','listSnapshotIds','load','usearch\x20algorithm\x20requires\x20dims\x20>\x200','SnapshotStore\x20requires\x20dir','then','dims','count','index','MetricKind','keepSnapshots','search','_snapshotDir','viewRefreshMs','capacity','openSync','distances','log','labelForExisting','getCurrentCount','hnsw\x20algorithm\x20requires\x20dir\x20for\x20snapshot\x20storage','reset','postMessage','s,\x20pid:\x20','mtimeMs','EEXIST','Original\x20error:\x20','keyToLabel','stringify','__esModule','102244vmGDzt','stop','nextLabel','connectivity','.tmp-','691613LbXFTz','heartbeatIntervalMs','view','parse','vector','unref','labelForEphemeral','readdirSync','readFileSync','remove','growFactor','repeat','[SnapshotStore]','state.json','pid','snapshot\x20incomplete:\x20','_tombstoneCount','setEf','min','opts','flat','efSearch','toString','lockPath','usearch\x20algorithm\x20unavailable:\x20the\x20native\x20\x22usearch\x22\x20bindings\x20could\x20not\x20be\x20loaded\x20','push','tombstone','host','from','ceil','tombstoneCount','add','closeSync','renameSync','message','map','queryVec','F32','writeFileSync','isFinite','for\x20Node\x20','code','clock','69160McEEkM','published','name','currentPath','stale','now','max','snapshot\x20id\x20required','searchKnn','arch','sort','snapshotTo','hnswlib-node','crypto','versions',',\x20host:\x20','mkdirSync','metric','snapshotsDir','get','resolve','usearch','prototype','node','memoryUsage','maxElements','trunc','index.hnsw','loadSnapshot','12kXqhsz','unlinkSync','utf8','cause','18fbYuAh','readCurrentClock','CURRENT','WRITER.LOCK','reader','existsSync','cleanupTmpDirs','labelToKey','10UDkyPM','writerLockMaxAgeMs','hnsw','tmpMaxAgeMs','save','snapshot','info','labels.json','filter','algorithm','candidateClock\x20must\x20be\x20finite\x20>=\x200','writeIndexSync','HNSW\x20algorithm\x20unavailable:\x20the\x20native\x20\x22hnswlib-node\x22\x20bindings\x20could\x20not\x20be\x20loaded\x20','isInteger','loadFrom','keys','warn','labels','default','expansionSearch','_snapshotPaths','\x20on\x20','120123WkyGzo','USEARCH_BINDINGS_UNAVAILABLE','This\x20is\x20risky\x20on\x20slow\x20disks\x20or\x20overloaded\x20machines.\x20Consider\x20increasing\x20staleLockMaxAgeMs\x20if\x20this\x20happens\x20frequently.','markDelete','isArray','statSync','efConstruction','vectors','state','size','hasOwnProperty','sqrt','snapshotEveryChanges','trim','delete','manifestVersion','latestSnapshotId','hex','dir','isDirectory','round','rebuild','startsWith','_tmp-','clear','78PIZNLN','slice','101526OnOCZp','cosine','join','exports','length','Index','randomBytes','score','expansionAdd','1247070uWwCHD','key','ready','hostname','readCurrentId',').\x20','keyForLabel'];_0x370a=function(){return _0x5b10f0;};return _0x370a();}var flat,hasRequiredFlat;function requireFlat(){if(hasRequiredFlat)return flat;hasRequiredFlat=0x1,flat=function _0xb27747(_0x57de50={}){const _0x3f1663=new Map();return{async 'load'(_0x1d5096){const _0x5bc54b=_0x2846;_0x3f1663[_0x5bc54b(0x1a3)]();if(_0x1d5096)for(const {key:_0x2b2b2d,vector:_0x420819}of await _0x1d5096()){_0x3f1663[_0x5bc54b(0x1c1)](_0x2b2b2d,_0x420819);}},async 'add'(_0x56712f,_0x4214bb,_0x557cd5){const _0x270610=_0x2846;_0x3f1663[_0x270610(0x1c1)](_0x56712f,_0x4214bb);},async 'remove'(_0x150a2c){const _0x5abcb2=_0x2846;_0x3f1663[_0x5abcb2(0x199)](_0x150a2c);},'search'(_0xb9803a,{limit:limit=0xa,threshold:threshold=0x0}={}){const _0x2b8bdd=_0x2846,_0x578879=[];for(const [_0x40ed63,_0x2cdf33]of _0x3f1663){const _0x298d8c=_0x206f63(_0xb9803a,_0x2cdf33);if(_0x298d8c>=threshold)_0x578879[_0x2b8bdd(0x200)]({'key':_0x40ed63,'score':_0x298d8c});}return _0x578879[_0x2b8bdd(0x156)]((_0x4706c6,_0x2f3c9a)=>_0x2f3c9a[_0x2b8bdd(0x1ad)]-_0x4706c6[_0x2b8bdd(0x1ad)]),_0x578879[_0x2b8bdd(0x1a5)](0x0,limit);},async 'snapshot'(){return![];},async 'rebuild'(_0x5b12f1){const _0x3c953c=_0x2846;await this[_0x3c953c(0x1c6)](_0x5b12f1);},async 'stop'(){},'count'(){const _0x32a464=_0x2846;return _0x3f1663[_0x32a464(0x194)];},'info'(){const _0x3e6b66=_0x2846;return{'algorithm':_0x3e6b66(0x1fb),'count':_0x3f1663[_0x3e6b66(0x194)]};}};};function _0x206f63(_0x18b240,_0x30379){const _0x141c1a=_0x2846;let _0x524f75=0x0,_0x12afa4=0x0,_0x1195f5=0x0;for(let _0x3911bd=0x0;_0x3911bd<_0x18b240[_0x141c1a(0x1aa)];_0x3911bd++){_0x524f75+=_0x18b240[_0x3911bd]*_0x30379[_0x3911bd],_0x12afa4+=_0x18b240[_0x3911bd]*_0x18b240[_0x3911bd],_0x1195f5+=_0x30379[_0x3911bd]*_0x30379[_0x3911bd];}const _0x51d31a=Math[_0x141c1a(0x196)](_0x12afa4)*Math['sqrt'](_0x1195f5);return _0x51d31a===0x0?0x0:_0x524f75/_0x51d31a;}return flat;}function _0x2846(_0x1a348f,_0x299a6e){_0x1a348f=_0x1a348f-0x13f;const _0x370a34=_0x370a();let _0x284677=_0x370a34[_0x1a348f];return _0x284677;}var usearch,hasRequiredUsearch;function requireUsearch(){if(hasRequiredUsearch)return usearch;hasRequiredUsearch=0x1;const _0x42b739=require$$0,_0x379a77=require$$1,_0x321b5c=requireSnapshotStore(),_0x45e684=requireLabelMap(),_0x5ab985=0x1;let _0x119c43=null;function _0x542525(){const _0x5ef145=_0x2846;if(_0x119c43)return _0x119c43;try{return _0x119c43=require(_0x5ef145(0x161)),_0x119c43;}catch(_0x2a76cc){const _0x4e4d64=new Error(_0x5ef145(0x1ff)+(_0x5ef145(0x149)+process['versions'][_0x5ef145(0x163)]+_0x5ef145(0x18a)+process['platform']+'/'+process['arch']+'.\x20')+'Install\x20compatible\x20bindings\x20or\x20use\x20algorithm\x20\x22flat\x22/\x22hnsw\x22\x20instead.\x20'+(_0x5ef145(0x1de)+(_0x2a76cc?.['message']||String(_0x2a76cc))));_0x4e4d64[_0x5ef145(0x14a)]=_0x5ef145(0x18c),_0x4e4d64[_0x5ef145(0x16c)]=_0x2a76cc;throw _0x4e4d64;}}function _0xc9ab26(_0x27cba5,_0x444a41){const _0x2b3511=_0x2846;switch(_0x27cba5){case'cosine':return _0x444a41[_0x2b3511(0x1cd)][_0x2b3511(0x1c4)];case'l2':return _0x444a41[_0x2b3511(0x1cd)]['L2sq'];case'ip':return _0x444a41['MetricKind']['IP'];default:return _0x444a41['MetricKind'][_0x2b3511(0x1c4)];}}return usearch=function _0x503351(_0x1ce51e={},{dims:_0x50fc82,dir:_0x407d07}){const _0x5846b1=_0x2846,_0x12c854=_0x542525();if(!_0x50fc82||_0x50fc82<=0x0)throw new Error(_0x5846b1(0x1c7));if(!_0x407d07)throw new Error('usearch\x20algorithm\x20requires\x20dir\x20for\x20snapshot\x20storage');const _0x53941c={'metric':_0x1ce51e[_0x5846b1(0x15d)]??_0x5846b1(0x1a7),'connectivity':_0x1ce51e[_0x5846b1(0x1e5)]??0x10,'expansionAdd':_0x1ce51e[_0x5846b1(0x1ae)]??0x80,'expansionSearch':_0x1ce51e[_0x5846b1(0x188)]??0x40,'snapshotEveryChanges':_0x1ce51e[_0x5846b1(0x197)]??0xc350,'keepSnapshots':_0x1ce51e[_0x5846b1(0x1ce)]??0x2,'tmpMaxAgeMs':_0x1ce51e[_0x5846b1(0x178)]??0x6*0x36ee80,'heartbeatIntervalMs':_0x1ce51e[_0x5846b1(0x1e8)]??0x1388,'writerLockMaxAgeMs':_0x1ce51e[_0x5846b1(0x176)]??0x3a98,'viewRefreshMs':_0x1ce51e[_0x5846b1(0x1d1)]??0x3e8},_0x28a7e2=new _0x321b5c({'dir':_0x407d07,'keepSnapshots':_0x53941c[_0x5846b1(0x1ce)]}),_0x3bf794=_0x379a77[_0x5846b1(0x1a8)](_0x407d07,_0x5846b1(0x170));let _0x1567e7=new _0x45e684(),_0x41deb5=null,_0xd34213=0x0,_0x3a9033=null,_0x4cd784=![],_0x14dc35=null,_0x28f21a=null,_0x4be533=0x0,_0xabcfb8=![],_0x10b3fa=Promise[_0x5846b1(0x160)]();const _0x5446ac=_0x1722b4=>{const _0x195032=_0x5846b1;return _0x10b3fa=_0x10b3fa[_0x195032(0x1c9)](_0x1722b4),_0x10b3fa;};function _0x115a24(){const _0xc99bd=_0x5846b1;return new _0x12c854[(_0xc99bd(0x1ab))]({'dimensions':_0x50fc82,'metric':_0xc9ab26(_0x53941c[_0xc99bd(0x15d)],_0x12c854),'quantization':_0x12c854[_0xc99bd(0x1b7)][_0xc99bd(0x146)],'connectivity':_0x53941c[_0xc99bd(0x1e5)],'expansion_add':_0x53941c[_0xc99bd(0x1ae)],'expansion_search':_0x53941c['expansionSearch'],'multi':![]});}function _0x540406(_0x5a7417){return _0x5a7417 instanceof Float32Array?_0x5a7417:new Float32Array(_0x5a7417);}function _0x326d70(){const _0x249659=_0x5846b1,_0x54d417=JSON['stringify']({'pid':process[_0x249659(0x1f5)],'at':Date[_0x249659(0x151)]()}),_0x2205ba=()=>{const _0x82f73=_0x249659;try{const _0x1541b4=_0x42b739[_0x82f73(0x1d3)](_0x3bf794,'wx');return _0x42b739[_0x82f73(0x147)](_0x1541b4,_0x54d417),_0x42b739[_0x82f73(0x141)](_0x1541b4),!![];}catch(_0x37a731){if(_0x37a731?.[_0x82f73(0x14a)]===_0x82f73(0x1dd))return![];throw _0x37a731;}};if(_0x2205ba())return!![];try{const _0x262b55=JSON[_0x249659(0x1ea)](_0x42b739[_0x249659(0x1ef)](_0x3bf794,_0x249659(0x16b))),_0x27d828=Date[_0x249659(0x151)]()-(_0x262b55['at']??0x0);if(_0x27d828<_0x53941c['writerLockMaxAgeMs'])return![];}catch{}try{_0x42b739['unlinkSync'](_0x3bf794);}catch{}return _0x2205ba();}function _0x3d0b3f(){const _0x140814=_0x5846b1;if(_0x14dc35)clearInterval(_0x14dc35);_0x14dc35=setInterval(()=>{const _0x554477=_0x2846;try{_0x42b739[_0x554477(0x147)](_0x3bf794,JSON['stringify']({'pid':process['pid'],'at':Date[_0x554477(0x151)]()}));}catch{}},_0x53941c[_0x140814(0x1e8)]),_0x14dc35[_0x140814(0x1ec)]();}function _0x1ed0d6(){const _0x1afa81=_0x5846b1;_0x14dc35&&(clearInterval(_0x14dc35),_0x14dc35=null);try{const _0x1e1519=JSON[_0x1afa81(0x1ea)](_0x42b739[_0x1afa81(0x1ef)](_0x3bf794,'utf8'));if(_0x1e1519[_0x1afa81(0x1f5)]===process[_0x1afa81(0x1f5)])_0x42b739['unlinkSync'](_0x3bf794);}catch{}}async function _0x5c19c3(_0x233065){const _0x337c42=_0x5846b1;_0x1567e7=new _0x45e684(),await _0x1567e7[_0x337c42(0x1d9)](),_0x41deb5=_0x115a24();const _0x1ab104=_0x233065?await _0x233065():[];for(const {key:_0x187a73,vector:_0x3db4bf}of _0x1ab104){if(!(_0x3db4bf instanceof Float32Array)||_0x3db4bf['length']!==_0x50fc82)continue;const _0x3a518c=_0x1567e7['labelForEphemeral'](_0x187a73);_0x41deb5[_0x337c42(0x140)](BigInt(_0x3a518c),_0x3db4bf);}_0xd34213=0x0;}async function _0xd51111(_0x2be25e){const _0x36c650=_0x5846b1;if(!_0x41deb5||!_0x2be25e)return![];const _0x2c33b0=await _0x28a7e2[_0x36c650(0x1b9)](_0x2be25e,async _0x37d4fe=>{const _0x36f51c=_0x36c650;_0x41deb5[_0x36f51c(0x179)](_0x37d4fe[_0x36f51c(0x1cc)]),await _0x1567e7[_0x36f51c(0x157)](_0x37d4fe[_0x36f51c(0x186)]),_0x42b739['writeFileSync'](_0x37d4fe[_0x36f51c(0x193)],JSON['stringify']({'manifestVersion':_0x5ab985,'algorithm':_0x36f51c(0x161),'dims':_0x50fc82,'metric':_0x53941c[_0x36f51c(0x15d)],'clock':_0x2be25e,'snapshotAt':Date['now']()},null,0x2));},{'keep':_0x53941c[_0x36c650(0x1ce)]});if(_0x2c33b0?.['published'])_0xd34213=0x0;return _0x2c33b0?.[_0x36c650(0x14d)]??![];}async function _0x5899bf(){const _0x23c144=_0x5846b1,_0x190a5f=_0x28a7e2[_0x23c144(0x1b3)]()||_0x28a7e2['latestSnapshotId']();if(!_0x190a5f)return null;let _0x404d45,_0x54e1c5=![];return await _0x28a7e2[_0x23c144(0x168)](_0x190a5f,async _0x12579f=>{const _0x4f731d=_0x23c144;_0x404d45=JSON[_0x4f731d(0x1ea)](_0x42b739[_0x4f731d(0x1ef)](_0x12579f[_0x4f731d(0x193)],_0x4f731d(0x16b)));if(_0x404d45[_0x4f731d(0x19a)]!==_0x5ab985||_0x404d45['algorithm']!==_0x4f731d(0x161)||_0x404d45[_0x4f731d(0x1ca)]!==_0x50fc82||_0x404d45[_0x4f731d(0x15d)]!==_0x53941c[_0x4f731d(0x15d)]){_0x404d45=null;return;}_0x1567e7=new _0x45e684(),await _0x1567e7['loadFrom'](_0x12579f[_0x4f731d(0x186)]),_0x41deb5=_0x115a24(),_0x41deb5[_0x4f731d(0x1c6)](_0x12579f[_0x4f731d(0x1cc)]),_0x54e1c5=!![];}),_0x54e1c5?_0x404d45?.['clock']??0x0:null;}async function _0x1816ac(_0x2e2560){const _0x29378d=_0x5846b1;if(!_0x2e2560)return![];let _0xacba7c=![];try{await _0x28a7e2[_0x29378d(0x168)](_0x2e2560,async _0x39832a=>{const _0x43df2b=_0x29378d,_0x38c829=JSON['parse'](_0x42b739[_0x43df2b(0x1ef)](_0x39832a[_0x43df2b(0x193)],_0x43df2b(0x16b)));if(_0x38c829[_0x43df2b(0x19a)]!==_0x5ab985||_0x38c829[_0x43df2b(0x17e)]!==_0x43df2b(0x161)||_0x38c829[_0x43df2b(0x1ca)]!==_0x50fc82||_0x38c829[_0x43df2b(0x15d)]!==_0x53941c[_0x43df2b(0x15d)])return;const _0x21de61=new _0x45e684();await _0x21de61['loadFrom'](_0x39832a[_0x43df2b(0x186)]);const _0x3c109c=_0x115a24();_0x3c109c[_0x43df2b(0x1e9)](_0x39832a['index']),_0x41deb5=_0x3c109c,_0x1567e7=_0x21de61,_0x28f21a=_0x2e2560,_0xacba7c=!![];});}catch{}return _0xacba7c;}async function _0x1b712b(_0x5dd5fe){try{await _0x1816ac(_0x5dd5fe);}finally{_0xabcfb8=![];}}function _0x45f63c(){const _0x2b42cb=_0x5846b1,_0x13d6aa=Date[_0x2b42cb(0x151)]();if(_0x13d6aa-_0x4be533<_0x53941c[_0x2b42cb(0x1d1)])return;_0x4be533=_0x13d6aa;if(_0xabcfb8)return;const _0x59ac34=_0x28a7e2[_0x2b42cb(0x1b3)]()||_0x28a7e2[_0x2b42cb(0x19b)]();if(!_0x59ac34||_0x59ac34===_0x28f21a)return;_0xabcfb8=!![],_0x1b712b(_0x59ac34);}async function _0x400880(){const _0x4f2e7c=_0x5846b1;_0x4cd784=!![],_0x3d0b3f();if(_0x28f21a)try{const _0x5c85cf=new _0x45e684();let _0x29301a=![];await _0x28a7e2[_0x4f2e7c(0x168)](_0x28f21a,async _0x1bbfd7=>{const _0x16e55b=_0x4f2e7c;await _0x5c85cf[_0x16e55b(0x183)](_0x1bbfd7[_0x16e55b(0x186)]);const _0x2677cf=_0x115a24();_0x2677cf[_0x16e55b(0x1c6)](_0x1bbfd7[_0x16e55b(0x1cc)]),_0x41deb5=_0x2677cf,_0x1567e7=_0x5c85cf,_0x29301a=!![];});if(_0x29301a)return;}catch{}await _0x5c19c3(_0x3a9033);}return{async 'load'(_0x9971a5){return _0x5446ac(async()=>{const _0x50e2d3=_0x2846;_0x28a7e2[_0x50e2d3(0x173)]({'maxAgeMs':_0x53941c[_0x50e2d3(0x178)]}),_0x3a9033=_0x9971a5??null,_0x4cd784=_0x326d70();if(_0x4cd784){_0x3d0b3f();const _0x4c77dc=await _0x5899bf();if(_0x4c77dc!=null)return _0x4c77dc;return await _0x5c19c3(_0x9971a5),null;}const _0x142073=_0x28a7e2['readCurrentId']()||_0x28a7e2[_0x50e2d3(0x19b)]();return await _0x1816ac(_0x142073),null;});},async 'add'(_0xac46ac,_0x2fac5,_0x5730a2){return _0x5446ac(async()=>{const _0x56e895=_0x2846;if(!_0x4cd784){if(!_0x326d70())return;await _0x400880();}if(!_0x41deb5)return;const _0x2b30ce=_0x1567e7['labelForExisting'](_0xac46ac);if(_0x2b30ce!==undefined)try{_0x41deb5[_0x56e895(0x1f0)](BigInt(_0x2b30ce));}catch{}const _0x2d3148=_0x1567e7[_0x56e895(0x1ed)](_0xac46ac);_0x41deb5[_0x56e895(0x140)](BigInt(_0x2d3148),_0x540406(_0x2fac5)),_0xd34213++,_0xd34213>=_0x53941c[_0x56e895(0x197)]&&await _0xd51111(_0x5730a2??Date['now']());});},async 'remove'(_0x40bb9){return _0x5446ac(async()=>{const _0x5bf21f=_0x2846;if(!_0x4cd784){if(!_0x326d70())return;await _0x400880();}if(!_0x41deb5)return;const _0x5e62ec=_0x1567e7[_0x5bf21f(0x1d6)](_0x40bb9);if(_0x5e62ec===undefined)return;try{_0x41deb5[_0x5bf21f(0x1f0)](BigInt(_0x5e62ec));}catch{}_0x1567e7[_0x5bf21f(0x201)](_0x40bb9),_0xd34213++;});},'search'(_0x49f66b,{limit:limit=0xa}={}){const _0x3991ba=_0x5846b1;if(!_0x4cd784)_0x45f63c();if(!_0x41deb5)return[];const _0x4fb786=_0x41deb5[_0x3991ba(0x194)]();if(_0x4fb786===0x0)return[];const _0x416725=Math[_0x3991ba(0x1f9)](limit,_0x4fb786),_0x3d5644=_0x41deb5[_0x3991ba(0x1cf)](_0x540406(_0x49f66b),_0x416725,0x0),_0x4e247f=[],_0x5106de=_0x3d5644[_0x3991ba(0x184)],_0x49c3a1=_0x3d5644[_0x3991ba(0x1d4)];for(let _0x36903b=0x0;_0x36903b<_0x5106de[_0x3991ba(0x1aa)];_0x36903b++){const _0x4d587b=_0x5106de[_0x36903b];if(_0x4d587b===0xffffffffffffffffn)continue;const _0x1f8851=Number(_0x4d587b),_0x47a5f1=_0x1567e7[_0x3991ba(0x1b5)](_0x1f8851);if(!_0x47a5f1)continue;const _0x434bd1=_0x49c3a1[_0x36903b];let _0x1ddf8f;if(_0x53941c['metric']===_0x3991ba(0x1a7))_0x1ddf8f=Math[_0x3991ba(0x152)](0x0,0x1-_0x434bd1);else{if(_0x53941c[_0x3991ba(0x15d)]==='ip')_0x1ddf8f=-_0x434bd1;else _0x1ddf8f=0x1/(0x1+_0x434bd1);}_0x4e247f[_0x3991ba(0x200)]({'key':_0x47a5f1,'score':_0x1ddf8f});}return _0x4e247f;},async 'snapshot'(_0x543654=Date[_0x5846b1(0x151)]()){if(!_0x4cd784)return![];return _0x5446ac(()=>_0xd51111(_0x543654));},async 'rebuild'(_0x2fa7a3){if(!_0x4cd784)return;return _0x5446ac(()=>{if(_0x2fa7a3!=null)_0x3a9033=_0x2fa7a3;return _0x5c19c3(_0x2fa7a3??_0x3a9033);});},async 'stop'(){return _0x5446ac(async()=>{_0x4cd784&&(await _0xd51111(Date['now']()),_0x1ed0d6());});},'count'(){const _0x481e62=_0x5846b1;return _0x1567e7[_0x481e62(0x194)]();},'info'(){const _0x590538=_0x5846b1;return{'algorithm':'usearch','role':_0x4cd784?'writer':_0x590538(0x171),'metric':_0x53941c[_0x590538(0x15d)],'connectivity':_0x53941c[_0x590538(0x1e5)],'expansionAdd':_0x53941c[_0x590538(0x1ae)],'expansionSearch':_0x53941c[_0x590538(0x188)],'count':_0x1567e7[_0x590538(0x194)](),'size':_0x41deb5?.[_0x590538(0x194)]?.()??0x0,'capacity':_0x41deb5?.[_0x590538(0x1d2)]?.()??0x0,'changesSince':_0x4cd784?_0xd34213:null,'viewedSnapshot':_0x28f21a??null,'snapshotDir':_0x407d07,'latestSnapshot':_0x28a7e2[_0x590538(0x1b3)]()??null};}};},usearch;}var hasRequiredAlgorithmWorkerThread;function requireAlgorithmWorkerThread(){const _0x10d3c9=_0x2f1a82;if(hasRequiredAlgorithmWorkerThread)return algorithmWorkerThread$1;hasRequiredAlgorithmWorkerThread=0x1;const {parentPort:_0x40c05e,workerData:_0x2d278a}=require$$0$1,{algorithmName:_0x3e8431,algorithmConfig:_0x274821,dims:_0x590ecd,dir:_0xce54bd}=_0x2d278a;let _0x5287c5;if(_0x3e8431==='hnsw')_0x5287c5=requireHnsw()(_0x274821,{'dims':_0x590ecd,'dir':_0xce54bd});else{if(_0x3e8431===_0x10d3c9(0x1fb))_0x5287c5=requireFlat()(_0x274821,{'dims':_0x590ecd,'dir':_0xce54bd});else{if(_0x3e8431==='usearch')_0x5287c5=requireUsearch()(_0x274821,{'dims':_0x590ecd,'dir':_0xce54bd});else throw new Error('Unknown\x20algorithm:\x20\x22'+_0x3e8431+'\x22');}}function _0x24fe62(){const _0x5ec1c2=_0x10d3c9;try{_0x40c05e[_0x5ec1c2(0x1da)]({'op':'sync','count':_0x5287c5[_0x5ec1c2(0x1cb)](),'info':_0x5287c5[_0x5ec1c2(0x17b)](),'memory':process[_0x5ec1c2(0x164)]()});}catch{}}return _0x40c05e['on'](_0x10d3c9(0x143),async _0x4f7b9b=>{const _0x55f3af=_0x10d3c9,{id:_0x2d8097,op:_0x54eb41,args:_0x43a19e}=_0x4f7b9b;try{let _0x5a6c7e;switch(_0x54eb41){case'load':{const _0x25c80a=(_0x43a19e[_0x55f3af(0x192)]||[])[_0x55f3af(0x144)](_0x26ff28=>({'key':_0x26ff28['key'],'vector':_0x26ff28['vector']instanceof Float32Array?_0x26ff28[_0x55f3af(0x1eb)]:new Float32Array(_0x26ff28[_0x55f3af(0x1eb)])}));_0x5a6c7e=await _0x5287c5[_0x55f3af(0x1c6)](async()=>_0x25c80a),_0x24fe62();break;}case _0x55f3af(0x140):{const _0xb44930=_0x43a19e[_0x55f3af(0x1eb)]instanceof Float32Array?_0x43a19e[_0x55f3af(0x1eb)]:new Float32Array(_0x43a19e['vector']);await _0x5287c5['add'](_0x43a19e[_0x55f3af(0x1b0)],_0xb44930,_0x43a19e[_0x55f3af(0x14b)]??undefined),_0x24fe62(),_0x5a6c7e=null;break;}case _0x55f3af(0x1f0):{await _0x5287c5['remove'](_0x43a19e['key']),_0x24fe62(),_0x5a6c7e=null;break;}case _0x55f3af(0x1cf):{const _0x38786d=_0x43a19e[_0x55f3af(0x145)]instanceof Float32Array?_0x43a19e[_0x55f3af(0x145)]:new Float32Array(_0x43a19e[_0x55f3af(0x145)]);_0x5a6c7e=_0x5287c5['search'](_0x38786d,_0x43a19e[_0x55f3af(0x1fa)]||{});break;}case _0x55f3af(0x17a):{_0x5a6c7e=await _0x5287c5['snapshot'](_0x43a19e['clock']),_0x24fe62();break;}case _0x55f3af(0x1a0):{const _0x2aaa2a=(_0x43a19e[_0x55f3af(0x192)]||[])[_0x55f3af(0x144)](_0x3adbd0=>({'key':_0x3adbd0[_0x55f3af(0x1b0)],'vector':_0x3adbd0[_0x55f3af(0x1eb)]instanceof Float32Array?_0x3adbd0[_0x55f3af(0x1eb)]:new Float32Array(_0x3adbd0[_0x55f3af(0x1eb)])}));await _0x5287c5[_0x55f3af(0x1a0)](async()=>_0x2aaa2a),_0x24fe62(),_0x5a6c7e=null;break;}case _0x55f3af(0x1e3):{await _0x5287c5[_0x55f3af(0x1e3)](),_0x24fe62(),_0x5a6c7e=null;break;}case _0x55f3af(0x1cb):{_0x5a6c7e=_0x5287c5['count']();break;}case _0x55f3af(0x17b):{_0x5a6c7e=_0x5287c5[_0x55f3af(0x17b)]();break;}default:throw new Error(_0x55f3af(0x1b6)+_0x54eb41+'\x22');}_0x40c05e['postMessage']({'id':_0x2d8097,'result':_0x5a6c7e});}catch(_0xeaffec){_0x40c05e[_0x55f3af(0x1da)]({'id':_0x2d8097,'error':{'message':_0xeaffec?.[_0x55f3af(0x143)]||String(_0xeaffec),'code':_0xeaffec?.['code']}});}}),_0x40c05e['postMessage']({'op':_0x10d3c9(0x1b1)}),algorithmWorkerThread$1;}var algorithmWorkerThreadExports=requireAlgorithmWorkerThread(),algorithmWorkerThread=getDefaultExportFromCjs(algorithmWorkerThreadExports);module[_0x2f1a82(0x1a9)]=algorithmWorkerThread;
1
+ 'use strict';const _0x5db5a4=_0x5717;(function(_0x49f6a0,_0x36351a){const _0x1cb2db=_0x5717,_0x1d6dd8=_0x49f6a0();while(!![]){try{const _0xbd9563=parseInt(_0x1cb2db(0x1a4))/0x1+-parseInt(_0x1cb2db(0x177))/0x2+-parseInt(_0x1cb2db(0x1c6))/0x3*(parseInt(_0x1cb2db(0x1a6))/0x4)+-parseInt(_0x1cb2db(0x210))/0x5*(-parseInt(_0x1cb2db(0x23f))/0x6)+parseInt(_0x1cb2db(0x17b))/0x7+parseInt(_0x1cb2db(0x234))/0x8*(-parseInt(_0x1cb2db(0x185))/0x9)+parseInt(_0x1cb2db(0x1d6))/0xa*(parseInt(_0x1cb2db(0x220))/0xb);if(_0xbd9563===_0x36351a)break;else _0x1d6dd8['push'](_0x1d6dd8['shift']());}catch(_0x229aac){_0x1d6dd8['push'](_0x1d6dd8['shift']());}}}(_0x1f5b,0xc1584));var require$$0$1=require('worker_threads'),require$$0=require('fs'),require$$1=require('path'),require$$2=require('os'),require$$3=require('crypto');function getDefaultExportFromCjs(_0x2111df){const _0x5f33d9=_0x5717;return _0x2111df&&_0x2111df[_0x5f33d9(0x239)]&&Object[_0x5f33d9(0x1e9)][_0x5f33d9(0x1ca)][_0x5f33d9(0x1aa)](_0x2111df,_0x5f33d9(0x1ef))?_0x2111df[_0x5f33d9(0x1ef)]:_0x2111df;}var algorithmWorkerThread$1={},snapshotStore,hasRequiredSnapshotStore;function requireSnapshotStore(){const _0x1be4a1=_0x5717;if(hasRequiredSnapshotStore)return snapshotStore;hasRequiredSnapshotStore=0x1;const _0x233d7b=require$$0,_0x2d237f=require$$1,_0x3df377=require$$2,_0x456141=require$$3;function _0x5e2463(){const _0x3be10d=_0x5717;return Date[_0x3be10d(0x17a)]();}function _0x282af4(_0x418ba7){try{return _0x233d7b['existsSync'](_0x418ba7);}catch{return![];}}function _0x35d8a8(_0x29ca7c){const _0xbc3129=_0x5717;try{return _0x233d7b[_0xbc3129(0x1d1)](_0x29ca7c,'utf8');}catch{return null;}}function _0x5f1875(_0x5e4ca2,_0x28a3c6){const _0x1660da=_0x5717,_0x5d6768=_0x5e4ca2+_0x1660da(0x1f7)+_0x456141['randomBytes'](0x6)[_0x1660da(0x172)](_0x1660da(0x1e8));_0x233d7b[_0x1660da(0x238)](_0x5d6768,_0x28a3c6),_0x233d7b['renameSync'](_0x5d6768,_0x5e4ca2);}function _0x5a5b03(_0x17a989,_0x4b9eb3=0x10){const _0x538764=_0x5717,_0x1a3898=String(Math['max'](0x0,Math['trunc'](_0x17a989||0x0)));return _0x1a3898[_0x538764(0x232)]>=_0x4b9eb3?_0x1a3898:'0'[_0x538764(0x1dd)](_0x4b9eb3-_0x1a3898[_0x538764(0x232)])+_0x1a3898;}return snapshotStore=class _0x302020{constructor({dir:_0xf78024,keepSnapshots:keepSnapshots=0x3,log:log=null}={}){const _0x1701fa=_0x5717;if(!_0xf78024)throw new Error('SnapshotStore\x20requires\x20dir');this[_0x1701fa(0x1e3)]=_0xf78024,this[_0x1701fa(0x18e)]=_0x2d237f[_0x1701fa(0x20e)](_0xf78024,_0x1701fa(0x1b3)),this['currentPath']=_0x2d237f[_0x1701fa(0x20e)](_0xf78024,_0x1701fa(0x1c2)),this['lockPath']=_0x2d237f['join'](_0xf78024,_0x1701fa(0x206)),this[_0x1701fa(0x181)]=keepSnapshots,this['log']=log,_0x233d7b[_0x1701fa(0x235)](this[_0x1701fa(0x1e3)],{'recursive':!![]}),_0x233d7b[_0x1701fa(0x235)](this[_0x1701fa(0x18e)],{'recursive':!![]});}[_0x1be4a1(0x1a3)](_0x1525c8){const _0x785d2c=_0x1be4a1;return _0x2d237f[_0x785d2c(0x20e)](this['snapshotsDir'],_0x1525c8);}[_0x1be4a1(0x228)](_0x355e49){const _0x209e3d=_0x1be4a1,_0x41d78e=this[_0x209e3d(0x1a3)](_0x355e49);return{'dir':_0x41d78e,'index':_0x2d237f[_0x209e3d(0x20e)](_0x41d78e,_0x209e3d(0x1fe)),'labels':_0x2d237f['join'](_0x41d78e,_0x209e3d(0x1a1)),'state':_0x2d237f[_0x209e3d(0x20e)](_0x41d78e,_0x209e3d(0x1dc))};}[_0x1be4a1(0x1b6)](){const _0x15104f=_0x1be4a1;if(!_0x282af4(this['currentPath']))return null;const _0x2e05ef=_0x35d8a8(this['currentPath']);if(!_0x2e05ef)return null;const _0x66ec79=String(_0x2e05ef)[_0x15104f(0x213)]();return _0x66ec79||null;}[_0x1be4a1(0x217)](){const _0x1d0b6f=_0x1be4a1,_0x1ad11c=this['readCurrentId']();if(!_0x1ad11c)return 0x0;const _0x52ca1c=Number(_0x1ad11c);return Number[_0x1d0b6f(0x191)](_0x52ca1c)?_0x52ca1c:0x0;}[_0x1be4a1(0x1f3)](){const _0x4adf9e=_0x1be4a1;try{return _0x233d7b[_0x4adf9e(0x189)](this[_0x4adf9e(0x18e)],{'withFileTypes':!![]})[_0x4adf9e(0x230)](_0x5c5043=>_0x5c5043['isDirectory']())[_0x4adf9e(0x21d)](_0x391ada=>_0x391ada[_0x4adf9e(0x22c)])[_0x4adf9e(0x230)](_0x6c05c5=>!_0x6c05c5[_0x4adf9e(0x1d7)](_0x4adf9e(0x1f7)))[_0x4adf9e(0x230)](_0x4bedd3=>!_0x4bedd3[_0x4adf9e(0x1d7)]('_tmp-'))[_0x4adf9e(0x187)]();}catch{return[];}}[_0x1be4a1(0x1cc)](){const _0x2eee4f=_0x1be4a1,_0x2dd1ee=this[_0x2eee4f(0x1b6)]();if(_0x2dd1ee)return _0x2dd1ee;const _0x42e9f2=this['listSnapshotIds']();if(!_0x42e9f2['length'])return null;return _0x42e9f2[_0x42e9f2[_0x2eee4f(0x232)]-0x1];}[_0x1be4a1(0x1d3)]({maxAgeMs:maxAgeMs=0x6*0x36ee80}={}){const _0x2032e7=_0x1be4a1;let _0xef8288;try{_0xef8288=_0x233d7b['readdirSync'](this[_0x2032e7(0x18e)],{'withFileTypes':!![]});}catch{return;}const _0xd978c9=_0x5e2463()-maxAgeMs;for(const _0x8bf312 of _0xef8288){if(!_0x8bf312[_0x2032e7(0x1d5)]())continue;const _0xa91635=_0x8bf312[_0x2032e7(0x22c)];if(!_0xa91635[_0x2032e7(0x1d7)](_0x2032e7(0x1f7))&&!_0xa91635[_0x2032e7(0x1d7)]('_tmp-'))continue;const _0x4256de=_0x2d237f[_0x2032e7(0x20e)](this['snapshotsDir'],_0xa91635);try{const _0x53c15e=_0x233d7b[_0x2032e7(0x199)](_0x4256de);if(_0x53c15e[_0x2032e7(0x168)]>_0xd978c9)continue;}catch{}try{_0x233d7b[_0x2032e7(0x21e)](_0x4256de,{'recursive':!![],'force':!![]});}catch{}}}['prune']({keep:keep=null}={}){const _0x526af6=_0x1be4a1,_0x2d7531=Math[_0x526af6(0x222)](0x1,Math['trunc'](keep??this[_0x526af6(0x181)]??0x3)),_0x4c0220=this[_0x526af6(0x1f3)]();if(_0x4c0220[_0x526af6(0x232)]<=_0x2d7531)return;const _0x5ba917=this[_0x526af6(0x1b6)](),_0x5f333f=_0x4c0220['slice'](0x0,Math[_0x526af6(0x222)](0x0,_0x4c0220['length']-_0x2d7531));for(const _0x75b436 of _0x5f333f){if(_0x5ba917&&_0x75b436===_0x5ba917)continue;const _0x3005f6=this[_0x526af6(0x1a3)](_0x75b436);try{_0x233d7b[_0x526af6(0x21e)](_0x3005f6,{'recursive':!![],'force':!![]});}catch{}}}async[_0x1be4a1(0x1e0)](_0x4baf78,_0x41c839){const _0x51d009=_0x1be4a1;if(!_0x4baf78)throw new Error(_0x51d009(0x1ee));const _0x1ca371=this['_snapshotPaths'](_0x4baf78);if(!_0x282af4(_0x1ca371[_0x51d009(0x221)])||!_0x282af4(_0x1ca371[_0x51d009(0x227)])||!_0x282af4(_0x1ca371['state']))throw new Error('snapshot\x20incomplete:\x20'+_0x4baf78);const _0x18d24f=await _0x41c839(_0x1ca371);return _0x18d24f||{};}async[_0x1be4a1(0x17e)](_0x3e7fd4,_0x4f3043,{keep:keep=null,lockTimeoutMs:lockTimeoutMs=0x0,staleLockMaxAgeMs:staleLockMaxAgeMs=0xea60}={}){const _0x9eb37f=_0x1be4a1,_0x367f0e=Number(_0x3e7fd4);if(!Number[_0x9eb37f(0x191)](_0x367f0e)||_0x367f0e<0x0)throw new Error('candidateClock\x20must\x20be\x20finite\x20>=\x200');const _0x1561e4=_0x5a5b03(_0x367f0e),_0x106d8f=this[_0x9eb37f(0x1a3)](_0x1561e4),_0x3dda6a=_0x2d237f[_0x9eb37f(0x20e)](this[_0x9eb37f(0x18e)],'.tmp-'+_0x1561e4+'-'+_0x456141[_0x9eb37f(0x1eb)](0x6)[_0x9eb37f(0x172)](_0x9eb37f(0x1e8)));_0x233d7b[_0x9eb37f(0x235)](_0x3dda6a,{'recursive':!![]});const _0x3067f9={'dir':_0x3dda6a,'index':_0x2d237f['join'](_0x3dda6a,_0x9eb37f(0x1fe)),'labels':_0x2d237f[_0x9eb37f(0x20e)](_0x3dda6a,'labels.json'),'state':_0x2d237f[_0x9eb37f(0x20e)](_0x3dda6a,_0x9eb37f(0x1dc))};await _0x4f3043(_0x3067f9,{'id':_0x1561e4,'clock':_0x367f0e});const _0x37970e=JSON[_0x9eb37f(0x200)]({'pid':process[_0x9eb37f(0x197)],'host':_0x3df377[_0x9eb37f(0x1ed)](),'at':_0x5e2463()}),_0x3e22f5=_0x5e2463();let _0x38a26a=null;const _0x259d66=()=>{const _0x229db9=_0x9eb37f;try{const _0x557d78=JSON['parse'](_0x233d7b[_0x229db9(0x1d1)](this[_0x229db9(0x1c1)],_0x229db9(0x17f)));if(_0x557d78['at']&&_0x5e2463()-_0x557d78['at']>staleLockMaxAgeMs){const _0x5f4410=_0x5e2463()-_0x557d78['at'],_0x315c95=_0x229db9(0x20f)+Math[_0x229db9(0x196)](_0x5f4410/0x3e8)+_0x229db9(0x1f1)+_0x557d78[_0x229db9(0x197)]+',\x20host:\x20'+_0x557d78[_0x229db9(0x1de)]+_0x229db9(0x1be)+_0x229db9(0x1ec);this['log']?.[_0x229db9(0x1b2)]?this[_0x229db9(0x16f)]['warn'](_0x315c95):console['warn'](_0x229db9(0x1f5),_0x315c95);try{_0x233d7b[_0x229db9(0x1e2)](this['lockPath']);}catch{}return!![];}}catch{try{_0x233d7b[_0x229db9(0x1e2)](this[_0x229db9(0x1c1)]);}catch{}}return![];},_0x1df8af=()=>{const _0xb922d1=_0x9eb37f;try{return _0x38a26a=_0x233d7b[_0xb922d1(0x1d2)](this[_0xb922d1(0x1c1)],'wx'),_0x233d7b[_0xb922d1(0x238)](_0x38a26a,_0x37970e),!![];}catch(_0xa01e50){if(_0xa01e50&&_0xa01e50[_0xb922d1(0x1a0)]===_0xb922d1(0x1a7))return![];throw _0xa01e50;}};if(!_0x1df8af()){_0x259d66(),_0x1df8af();if(_0x38a26a==null&&lockTimeoutMs>0x0)while(_0x5e2463()-_0x3e22f5<lockTimeoutMs){await new Promise(_0xc4c388=>setTimeout(_0xc4c388,0x19));if(_0x1df8af())break;_0x259d66();}}if(_0x38a26a==null){try{_0x233d7b[_0x9eb37f(0x21e)](_0x3dda6a,{'recursive':!![],'force':!![]});}catch{}return{'published':![],'reason':'lock_busy'};}try{const _0x18b2f2=this['readCurrentClock']();if(_0x367f0e<=_0x18b2f2){try{_0x233d7b['rmSync'](_0x3dda6a,{'recursive':!![],'force':!![]});}catch{}return{'published':![],'reason':_0x9eb37f(0x1bc),'currentClock':_0x18b2f2};}if(!_0x282af4(_0x106d8f))_0x233d7b[_0x9eb37f(0x1e1)](_0x3dda6a,_0x106d8f);else try{_0x233d7b['rmSync'](_0x3dda6a,{'recursive':!![],'force':!![]});}catch{}return _0x5f1875(this[_0x9eb37f(0x186)],_0x1561e4+'\x0a'),this[_0x9eb37f(0x202)]({'keep':keep}),{'published':!![],'currentClock':_0x367f0e};}finally{try{_0x233d7b[_0x9eb37f(0x1ac)](_0x38a26a);}catch{}try{_0x233d7b[_0x9eb37f(0x1e2)](this[_0x9eb37f(0x1c1)]);}catch{}}}},snapshotStore;}var labelMap,hasRequiredLabelMap;function requireLabelMap(){const _0x1bb8a6=_0x5717;if(hasRequiredLabelMap)return labelMap;hasRequiredLabelMap=0x1;const _0x5e7a7e=require$$0;class _0x3d9ac4{constructor(){const _0x1c79e2=_0x5717;this[_0x1c79e2(0x21c)]=new Map(),this['labelToKey']=new Map(),this[_0x1c79e2(0x1c9)]=0x0,this['_tombstoneCount']=0x0,this['keyToFp']=new Map(),this[_0x1c79e2(0x1d4)]=!![];}async[_0x1bb8a6(0x1f0)](){const _0x2a9566=_0x1bb8a6;this['keyToLabel']=new Map(),this['labelToKey']=new Map(),this[_0x2a9566(0x1e5)]=new Map(),this['hasFingerprints']=!![],this[_0x2a9566(0x1c9)]=0x0,this[_0x2a9566(0x1a5)]=0x0;}async[_0x1bb8a6(0x1a2)](_0x3fce6a){const _0x65a7f5=_0x1bb8a6;if(!_0x3fce6a||!_0x5e7a7e[_0x65a7f5(0x1fc)](_0x3fce6a))return await this[_0x65a7f5(0x1f0)](),!![];let _0x409df4;try{_0x409df4=_0x5e7a7e[_0x65a7f5(0x1d1)](_0x3fce6a,'utf8');}catch{return await this[_0x65a7f5(0x1f0)](),!![];}let _0x32cf8a;try{_0x32cf8a=JSON['parse'](_0x409df4);}catch{return await this[_0x65a7f5(0x1f0)](),!![];}const _0x5a32de=Array[_0x65a7f5(0x1b8)](_0x32cf8a?.[_0x65a7f5(0x22b)])?_0x32cf8a[_0x65a7f5(0x22b)]:[],_0x40a813=Number['isInteger'](_0x32cf8a?.[_0x65a7f5(0x1c9)])?_0x32cf8a[_0x65a7f5(0x1c9)]:0x0,_0x32e989=new Map(),_0x524024=new Map(),_0x4f896b=new Map(),_0x27924c=_0x32cf8a?.['version']>=0x2;let _0xad997d=-0x1;for(const _0x552c50 of _0x5a32de){if(!Array['isArray'](_0x552c50)||_0x552c50[_0x65a7f5(0x232)]<0x2)continue;const _0xfc995e=Number(_0x552c50[0x0]),_0x5a62ee=String(_0x552c50[0x1]??'');if(!Number[_0x65a7f5(0x192)](_0xfc995e)||_0xfc995e<0x0)continue;if(!_0x5a62ee)continue;_0x32e989[_0x65a7f5(0x225)](_0x5a62ee,_0xfc995e),_0x524024[_0x65a7f5(0x225)](_0xfc995e,_0x5a62ee);if(_0x27924c&&typeof _0x552c50[0x2]==='number')_0x4f896b[_0x65a7f5(0x225)](_0x5a62ee,_0x552c50[0x2]);if(_0xfc995e>_0xad997d)_0xad997d=_0xfc995e;}return this['keyToLabel']=_0x32e989,this[_0x65a7f5(0x20d)]=_0x524024,this['keyToFp']=_0x4f896b,this[_0x65a7f5(0x1d4)]=_0x27924c,this[_0x65a7f5(0x1c9)]=Math[_0x65a7f5(0x222)](_0x40a813,_0xad997d+0x1,0x0),this[_0x65a7f5(0x1a5)]=0x0,!![];}[_0x1bb8a6(0x188)](_0x243c7b){const _0x4e4a7a=_0x1bb8a6;return this['keyToLabel'][_0x4e4a7a(0x23e)](_0x243c7b);}['labelForEphemeral'](_0x2305dd){const _0x59b37b=_0x1bb8a6;let _0xada9cb=this[_0x59b37b(0x21c)][_0x59b37b(0x23e)](_0x2305dd);if(_0xada9cb!==undefined)return _0xada9cb;return _0xada9cb=this[_0x59b37b(0x1c9)]++,this[_0x59b37b(0x21c)][_0x59b37b(0x225)](_0x2305dd,_0xada9cb),this[_0x59b37b(0x20d)]['set'](_0xada9cb,_0x2305dd),_0xada9cb;}['setFingerprint'](_0x28ec0a,_0x13fa59){const _0x273a7e=_0x1bb8a6;if(_0x13fa59==null)this['keyToFp'][_0x273a7e(0x175)](_0x28ec0a);else this[_0x273a7e(0x1e5)][_0x273a7e(0x225)](_0x28ec0a,_0x13fa59);}[_0x1bb8a6(0x1a9)](_0xae167){const _0x656a37=_0x1bb8a6;return this[_0x656a37(0x1e5)]['get'](_0xae167);}[_0x1bb8a6(0x195)](){const _0x4043f4=_0x1bb8a6;return this[_0x4043f4(0x21c)]['keys']();}[_0x1bb8a6(0x17c)](_0x4cde0f){const _0x34fb67=_0x1bb8a6,_0x22c30b=this[_0x34fb67(0x21c)][_0x34fb67(0x23e)](_0x4cde0f);if(_0x22c30b===undefined)return;this[_0x34fb67(0x1e5)]['delete'](_0x4cde0f),this[_0x34fb67(0x21c)][_0x34fb67(0x175)](_0x4cde0f),this[_0x34fb67(0x20d)][_0x34fb67(0x175)](_0x22c30b),this['_tombstoneCount']++;}[_0x1bb8a6(0x1fd)](_0x386e74){return this['labelToKey']['get'](_0x386e74)??null;}[_0x1bb8a6(0x201)](){const _0x40ed9d=_0x1bb8a6;return this[_0x40ed9d(0x21c)][_0x40ed9d(0x201)];}[_0x1bb8a6(0x170)](){return this['_tombstoneCount'];}async[_0x1bb8a6(0x23d)](_0x253173){const _0x258446=_0x1bb8a6,_0x347daf=_0x253173+'.tmp',_0x5eb3e9=[];for(const [_0x5500e8,_0x266d9e]of this[_0x258446(0x20d)][_0x258446(0x22b)]()){const _0xf6fce4=this[_0x258446(0x1e5)][_0x258446(0x23e)](_0x266d9e);_0x5eb3e9['push'](_0xf6fce4==null?[_0x5500e8,_0x266d9e]:[_0x5500e8,_0x266d9e,_0xf6fce4]);}_0x5eb3e9[_0x258446(0x187)]((_0x10e5cc,_0x10a9fb)=>_0x10e5cc[0x0]-_0x10a9fb[0x0]);const _0x11d025={'version':0x2,'nextLabel':this[_0x258446(0x1c9)],'entries':_0x5eb3e9};_0x5e7a7e[_0x258446(0x238)](_0x347daf,JSON[_0x258446(0x200)](_0x11d025)),_0x5e7a7e[_0x258446(0x1e1)](_0x347daf,_0x253173);}}return labelMap=_0x3d9ac4,labelMap;}var indexConvergence,hasRequiredIndexConvergence;function requireIndexConvergence(){if(hasRequiredIndexConvergence)return indexConvergence;hasRequiredIndexConvergence=0x1;function _0x54d5f4(_0x512865){const _0x30052f=_0x5717,_0x470b4c=new Uint32Array(_0x512865[_0x30052f(0x1c8)],_0x512865[_0x30052f(0x190)],_0x512865[_0x30052f(0x232)]);let _0x33a15a=0x811c9dc5,_0x1be3f9=0x9747b28c;for(let _0x541a86=0x0;_0x541a86<_0x470b4c['length'];_0x541a86++){const _0x32c8ad=_0x470b4c[_0x541a86];_0x33a15a=Math['imul'](_0x33a15a^_0x32c8ad,0x1000193)>>>0x0;let _0x264864=Math[_0x30052f(0x23a)](_0x32c8ad,0xcc9e2d51);_0x264864=_0x264864<<0xf|_0x264864>>>0x11,_0x1be3f9=Math[_0x30052f(0x23a)](_0x1be3f9^Math[_0x30052f(0x23a)](_0x264864,0x1b873593),0x5)+0xe6546b64,_0x1be3f9>>>=0x0;}return _0x1be3f9=Math['imul'](_0x1be3f9^_0x1be3f9>>>0x10,0x85ebca6b)>>>0x0,(_0x33a15a>>>0x0)*0x100000+(_0x1be3f9&0xfffff);}function _0x4842b5(_0x505d79,_0x4df428,_0xfa346c,{upsert:_0x3c0df7,remove:_0xd4ce2c}){const _0x535d52=_0x5717,_0x247774=new Set();let _0x8c301=0x0,_0x33c9e0=0x0,_0x17a4c1=0x0;for(const {key:_0x25c7ae,vector:_0x1da366}of _0x4df428){if(!(_0x1da366 instanceof Float32Array)||_0x1da366['length']!==_0xfa346c)continue;_0x247774[_0x535d52(0x1a8)](_0x25c7ae);const _0xe84592=_0x54d5f4(_0x1da366),_0x404b1f=_0x505d79[_0x535d52(0x188)](_0x25c7ae)!==undefined;if(_0x404b1f&&_0x505d79[_0x535d52(0x1a9)](_0x25c7ae)===_0xe84592)continue;_0x3c0df7(_0x25c7ae,_0x1da366,_0xe84592);if(_0x404b1f)_0x33c9e0++;else _0x8c301++;}for(const _0x54e1bb of[..._0x505d79[_0x535d52(0x195)]()]){if(_0x247774['has'](_0x54e1bb))continue;_0xd4ce2c(_0x54e1bb),_0x17a4c1++;}return{'added':_0x8c301,'changed':_0x33c9e0,'removed':_0x17a4c1};}return indexConvergence={'fingerprint':_0x54d5f4,'reconcileIndex':_0x4842b5},indexConvergence;}var hnsw,hasRequiredHnsw;function requireHnsw(){if(hasRequiredHnsw)return hnsw;hasRequiredHnsw=0x1;const _0x30a178=requireSnapshotStore(),_0x69cd21=requireLabelMap(),{fingerprint:_0xcbc21f,reconcileIndex:_0x364cd8}=requireIndexConvergence(),_0xe5e7c8=0x1;let _0x22f04a=null;function _0x3f7a0c(){const _0x465499=_0x5717;if(_0x22f04a)return _0x22f04a;try{return _0x22f04a=require('hnswlib-node'),_0x22f04a;}catch(_0x44c8b1){const _0x40bb98=new Error(_0x465499(0x176)+(_0x465499(0x18d)+process['versions'][_0x465499(0x1c0)]+_0x465499(0x1fb)+process['platform']+'/'+process[_0x465499(0x16b)]+'.\x20')+'Install\x20compatible\x20bindings\x20or\x20use\x20algorithm\x20\x22flat\x22\x20instead.\x20'+(_0x465499(0x1af)+(_0x44c8b1?.[_0x465499(0x19d)]||String(_0x44c8b1))));_0x40bb98[_0x465499(0x1a0)]=_0x465499(0x219),_0x40bb98['cause']=_0x44c8b1;throw _0x40bb98;}}return hnsw=function _0x46744c(_0x46924c={},{dims:_0x451b1e,dir:_0x463c2b}){const _0x243395=_0x5717,_0x37ae7d=_0x3f7a0c();if(!_0x451b1e||_0x451b1e<=0x0)throw new Error(_0x243395(0x20a));if(!_0x463c2b)throw new Error(_0x243395(0x20c));const _0x4519f2={'metric':_0x46924c['metric']??'cosine','M':_0x46924c['M']??0x10,'efConstruction':_0x46924c[_0x243395(0x18c)]??0xc8,'efSearch':_0x46924c[_0x243395(0x16a)]??0x40,'maxElements':_0x46924c[_0x243395(0x1ff)]??0x400,'growFactor':_0x46924c[_0x243395(0x198)]??0x2,'snapshotEveryChanges':_0x46924c[_0x243395(0x19a)]??0xc350,'keepSnapshots':_0x46924c['keepSnapshots']??0x2,'tmpMaxAgeMs':_0x46924c[_0x243395(0x180)]??0x6*0x36ee80},_0x3c8729=new _0x30a178({'dir':_0x463c2b,'keepSnapshots':_0x4519f2[_0x243395(0x181)]}),_0xcc8e9b=new _0x69cd21();let _0x3775dd=null,_0x59a693=0x0,_0x40f8b5=null,_0x558792=Promise[_0x243395(0x169)]();const _0x3ca46b=_0x102681=>{const _0x853119=_0x243395,_0xfaab1a=_0x558792[_0x853119(0x1b5)](_0x102681);return _0x558792=_0xfaab1a[_0x853119(0x1bd)](()=>{}),_0xfaab1a;};async function _0x338b5d(_0x2cd8a8){const _0x1241e7=_0x243395;await _0xcc8e9b[_0x1241e7(0x1f0)](),_0x2cd8a8=_0x2cd8a8??[];const _0x5800f9=Math[_0x1241e7(0x222)](_0x4519f2[_0x1241e7(0x1ff)],Math[_0x1241e7(0x1d8)](_0x2cd8a8[_0x1241e7(0x232)]*(_0x4519f2[_0x1241e7(0x198)]||1.2)),0x1);_0x3775dd=new _0x37ae7d[(_0x1241e7(0x204))](_0x4519f2['metric'],_0x451b1e),_0x3775dd['initIndex']({'maxElements':_0x5800f9,'efConstruction':_0x4519f2[_0x1241e7(0x18c)],'M':_0x4519f2['M']});for(const {key:_0x1d2ca1,vector:_0x28b40c}of _0x2cd8a8){if(!(_0x28b40c instanceof Float32Array)||_0x28b40c[_0x1241e7(0x232)]!==_0x451b1e)continue;_0x4c5d22(_0x1d2ca1,_0x28b40c);}_0x3775dd[_0x1241e7(0x18b)](_0x4519f2[_0x1241e7(0x16a)]),_0x59a693=0x0;}async function _0x3b480a(_0x278652){return _0x338b5d(_0x278652?await _0x278652():[]);}function _0x2e89ce(){const _0x363115=_0x243395;if(_0x3775dd['getCurrentCount']()<_0x3775dd[_0x363115(0x21f)]())return;const _0x5965df=Math[_0x363115(0x1d8)](_0x3775dd['getMaxElements']()*(_0x4519f2[_0x363115(0x198)]||0x2));_0x3775dd[_0x363115(0x1ab)](_0x5965df),_0x4519f2[_0x363115(0x1ff)]=_0x5965df;}function _0x4c5d22(_0x14dd7f,_0x55ed30,_0x2d0365){const _0x209091=_0x243395,_0x4f20fc=_0xcc8e9b[_0x209091(0x216)](_0x14dd7f);try{_0x3775dd[_0x209091(0x1cb)](_0x4f20fc);}catch{}_0x2e89ce(),_0x3775dd[_0x209091(0x1b1)](Array['from'](_0x55ed30),_0x4f20fc),_0xcc8e9b['setFingerprint'](_0x14dd7f,_0x2d0365??_0xcbc21f(_0x55ed30));}function _0x31c524(_0x48eb9d){const _0x30d69f=_0x243395,_0x397833=_0xcc8e9b['labelForExisting'](_0x48eb9d);if(_0x397833===undefined)return![];try{_0x3775dd[_0x30d69f(0x1cb)](_0x397833);}catch{}return _0xcc8e9b['tombstone'](_0x48eb9d),!![];}function _0x303d6b(){const _0x17e6a6=_0x243395;return Math[_0x17e6a6(0x222)](Date['now'](),_0x3c8729[_0x17e6a6(0x217)]()+0x1);}async function _0x484ec(_0x1504e2){const _0x549b70=_0x243395;if(!_0x3775dd||!_0x1504e2)return![];const _0x2c2d07=await _0x3c8729['publishSnapshot'](_0x1504e2,async _0x19d969=>{const _0x535ce7=_0x5717;_0x3775dd[_0x535ce7(0x1e6)](_0x19d969[_0x535ce7(0x221)]),await _0xcc8e9b[_0x535ce7(0x23d)](_0x19d969[_0x535ce7(0x227)]);const _0x56326e=require$$0;_0x56326e[_0x535ce7(0x238)](_0x19d969['state'],JSON['stringify']({'manifestVersion':_0xe5e7c8,'dims':_0x451b1e,'metric':_0x4519f2[_0x535ce7(0x21b)],'clock':_0x1504e2,'snapshotAt':Date[_0x535ce7(0x17a)]()},null,0x2));},{'keep':_0x4519f2[_0x549b70(0x181)]});if(_0x2c2d07?.[_0x549b70(0x1c5)])_0x59a693=0x0;return _0x2c2d07?.[_0x549b70(0x1c5)]??![];}async function _0x37a30e(){const _0x3a576e=_0x243395,_0x47454b=_0x3c8729['readCurrentId']()||_0x3c8729[_0x3a576e(0x1cc)]();if(!_0x47454b)return null;let _0x1c594f,_0x4e8fe6=![];return await _0x3c8729[_0x3a576e(0x1e0)](_0x47454b,async _0x17280c=>{const _0xe6b39e=_0x3a576e,_0x3bcf95=require$$0;_0x1c594f=JSON[_0xe6b39e(0x1c4)](_0x3bcf95['readFileSync'](_0x17280c[_0xe6b39e(0x1e4)],_0xe6b39e(0x17f)));if(_0x1c594f[_0xe6b39e(0x1f8)]!==_0xe5e7c8||_0x1c594f[_0xe6b39e(0x233)]!==_0x451b1e||_0x1c594f[_0xe6b39e(0x21b)]!==_0x4519f2['metric']){_0x1c594f=null;return;}await _0xcc8e9b[_0xe6b39e(0x1a2)](_0x17280c[_0xe6b39e(0x227)]),_0x3775dd=new _0x37ae7d['HierarchicalNSW'](_0x4519f2[_0xe6b39e(0x21b)],_0x451b1e),_0x3775dd[_0xe6b39e(0x1f4)](_0x17280c[_0xe6b39e(0x221)]),_0x3775dd[_0xe6b39e(0x18b)](_0x4519f2[_0xe6b39e(0x16a)]),_0x4e8fe6=!![];}),_0x4e8fe6?_0x1c594f?.[_0x3a576e(0x19e)]??0x0:null;}return{async 'load'(_0x2b8145){return _0x3ca46b(async()=>{const _0x3fc04e=_0x5717;_0x3c8729['cleanupTmpDirs']({'maxAgeMs':_0x4519f2[_0x3fc04e(0x180)]}),_0x40f8b5=_0x2b8145??null;const _0x42858d=await _0x37a30e(),_0x19446f=_0x2b8145?await _0x2b8145():null;if(_0x42858d!=null){if(_0x19446f){if(!_0xcc8e9b[_0x3fc04e(0x1d4)])return await _0x338b5d(_0x19446f),null;const _0x11dae9=_0x364cd8(_0xcc8e9b,_0x19446f,_0x451b1e,{'upsert':_0x4c5d22,'remove':_0x31c524});_0x59a693+=_0x11dae9[_0x3fc04e(0x193)]+_0x11dae9[_0x3fc04e(0x224)]+_0x11dae9[_0x3fc04e(0x236)];}return _0x42858d;}return await _0x338b5d(_0x19446f),null;});},async 'add'(_0x2d2ec2,_0x2ee76d,_0x4bf22b){return _0x3ca46b(async()=>{const _0x4991ce=_0x5717;if(!_0x3775dd)return;const _0x13341a=_0x2ee76d instanceof Float32Array?_0x2ee76d:new Float32Array(_0x2ee76d),_0x450a58=_0xcbc21f(_0x13341a);if(_0xcc8e9b[_0x4991ce(0x1a9)](_0x2d2ec2)===_0x450a58)return;_0x4c5d22(_0x2d2ec2,_0x13341a,_0x450a58),_0x59a693++,_0x59a693>=_0x4519f2[_0x4991ce(0x19a)]&&await _0x484ec(_0x303d6b());});},async 'remove'(_0x487269){return _0x3ca46b(async()=>{if(!_0x3775dd)return;if(_0x31c524(_0x487269))_0x59a693++;});},'search'(_0x322dce,{limit:limit=0xa,efSearch:_0x5a911d}={}){const _0x113d21=_0x243395;if(!_0x3775dd)return[];if(Number['isInteger'](_0x5a911d))_0x3775dd['setEf'](_0x5a911d);const _0x3858d6=Math[_0x113d21(0x1bf)](limit,_0x3775dd[_0x113d21(0x19f)]()||0x1),{neighbors:_0x5126f8,distances:_0x20be8f}=_0x3775dd[_0x113d21(0x1df)](Array[_0x113d21(0x237)](_0x322dce),_0x3858d6),_0x1ad5b3=[];for(let _0x1db287=0x0;_0x1db287<_0x5126f8[_0x113d21(0x232)];_0x1db287++){const _0x5beb61=_0xcc8e9b[_0x113d21(0x1fd)](_0x5126f8[_0x1db287]);if(!_0x5beb61)continue;const _0x368ac9=_0x4519f2['metric']===_0x113d21(0x1d9)?Math[_0x113d21(0x222)](0x0,0x1-_0x20be8f[_0x1db287]):0x1/(0x1+_0x20be8f[_0x1db287]);_0x1ad5b3[_0x113d21(0x212)]({'key':_0x5beb61,'score':_0x368ac9});}return _0x1ad5b3;},async 'snapshot'(_0x5a838f){return _0x3ca46b(()=>_0x484ec(_0x5a838f??_0x303d6b()));},async 'rebuild'(_0x4b5434){return _0x3ca46b(()=>{if(_0x4b5434!=null)_0x40f8b5=_0x4b5434;return _0x3b480a(_0x4b5434??_0x40f8b5);});},async 'stop'(){const _0x43449c=_0x243395;return _0x3ca46b(()=>_0x59a693>0x0||!_0x3c8729[_0x43449c(0x1b6)]()?_0x484ec(_0x303d6b()):![]);},'count'(){const _0x3e36c2=_0x243395;return _0xcc8e9b[_0x3e36c2(0x201)]();},'info'(){const _0x82981e=_0x243395;return{'algorithm':_0x82981e(0x1f9),'metric':_0x4519f2[_0x82981e(0x21b)],'M':_0x4519f2['M'],'efConstruction':_0x4519f2['efConstruction'],'efSearch':_0x4519f2[_0x82981e(0x16a)],'maxElements':_0x3775dd?.[_0x82981e(0x21f)]()??_0x4519f2[_0x82981e(0x1ff)],'count':_0xcc8e9b[_0x82981e(0x201)](),'changesSince':_0x59a693,'snapshotDir':_0x463c2b,'latestSnapshot':_0x3c8729['readCurrentId']()??null};}};},hnsw;}var flat,hasRequiredFlat;function _0x5717(_0x194693,_0x563122){_0x194693=_0x194693-0x168;const _0x1f5bcc=_0x1f5b();let _0x5717ec=_0x1f5bcc[_0x194693];return _0x5717ec;}function _0x1f5b(){const _0x5800d8=['900981yfCchL','currentPath','sort','labelForExisting','readdirSync','vector','setEf','efConstruction','for\x20Node\x20','snapshotsDir','postMessage','byteOffset','isFinite','isInteger','added','key','keys','round','pid','growFactor','statSync','snapshotEveryChanges','writer','finally','message','clock','getCurrentCount','code','labels.json','loadFrom','_snapshotDir','505016cbhnOM','_tombstoneCount','12fCKCEM','EEXIST','add','fingerprintOf','call','resizeIndex','closeSync','rebuild','opts','Original\x20error:\x20','ready','addPoint','warn','snapshots','snapshot','then','readCurrentId','Index','isArray','unreadable','slice','token','stale','catch',').\x20','min','node','lockPath','CURRENT','expansionAdd','parse','published','419937etrAKn','vectors','buffer','nextLabel','hasOwnProperty','markDelete','latestSnapshotId','Install\x20compatible\x20bindings\x20or\x20use\x20algorithm\x20\x22flat\x22/\x22hnsw\x22\x20instead.\x20','reject','acquire','info','readFileSync','openSync','cleanupTmpDirs','hasFingerprints','isDirectory','10MouAQR','startsWith','ceil','cosine','WRITER.LOCK','connectivity','state.json','repeat','host','searchKnn','loadSnapshot','renameSync','unlinkSync','dir','state','keyToFp','writeIndexSync','Unknown\x20algorithm:\x20\x22','hex','prototype','count','randomBytes','This\x20is\x20risky\x20on\x20slow\x20disks\x20or\x20overloaded\x20machines.\x20Consider\x20increasing\x20staleLockMaxAgeMs\x20if\x20this\x20happens\x20frequently.','hostname','snapshot\x20id\x20required','default','reset','s,\x20pid:\x20','capacity','listSnapshotIds','readIndexSync','[SnapshotStore]','writerLockMaxAgeMs','.tmp-','manifestVersion','hnsw','release','\x20on\x20','existsSync','keyForLabel','index.hnsw','maxElements','stringify','size','prune','search','HierarchicalNSW','algorithm','SNAPSHOT.LOCK','view','error','fetchAll','hnsw\x20algorithm\x20requires\x20dims\x20>\x200','load','hnsw\x20algorithm\x20requires\x20dir\x20for\x20snapshot\x20storage','labelToKey','join','Breaking\x20stale\x20snapshot\x20lock\x20(age:\x20','104180aKGgqa','MetricKind','push','trim','versions','expansionSearch','labelForEphemeral','readCurrentClock','isFree','HNSW_BINDINGS_UNAVAILABLE','sqrt','metric','keyToLabel','map','rmSync','getMaxElements','15607339hGoNha','index','max','heartbeatIntervalMs','changed','set','unref','labels','_snapshotPaths','platform','score','entries','name','distances','Cos','viewRefreshMs','filter','stop','length','dims','104UGgLXS','mkdirSync','removed','from','writeFileSync','__esModule','imul','ScalarKind','exports','snapshotTo','get','48LjQtMy','mtimeMs','resolve','efSearch','arch','fetchAllResult','setFingerprint','reader','log','tombstoneCount','queryVec','toString','flat','remove','delete','HNSW\x20algorithm\x20unavailable:\x20the\x20native\x20\x22hnswlib-node\x22\x20bindings\x20could\x20not\x20be\x20loaded\x20','1630728MspAmX','fid','snapshotMaxLagMs','now','8666735JuLMnw','tombstone','ENOENT','publishSnapshot','utf8','tmpMaxAgeMs','keepSnapshots','usearch\x20algorithm\x20unavailable:\x20the\x20native\x20\x22usearch\x22\x20bindings\x20could\x20not\x20be\x20loaded\x20','Unknown\x20op:\x20\x22','usearch'];_0x1f5b=function(){return _0x5800d8;};return _0x1f5b();}function requireFlat(){if(hasRequiredFlat)return flat;hasRequiredFlat=0x1,flat=function _0x1b2328(_0x3298d1={}){const _0xbdf55c=new Map();return{async 'load'(_0x33af80){_0xbdf55c['clear']();if(_0x33af80)for(const {key:_0x5797b4,vector:_0x3e9d33}of await _0x33af80()){_0xbdf55c['set'](_0x5797b4,_0x3e9d33);}},async 'add'(_0x183ea4,_0x15e176,_0x31a749){const _0x414406=_0x5717;_0xbdf55c[_0x414406(0x225)](_0x183ea4,_0x15e176);},async 'remove'(_0x3912e1){const _0x556e88=_0x5717;_0xbdf55c[_0x556e88(0x175)](_0x3912e1);},'search'(_0x3f92cb,{limit:limit=0xa,threshold:threshold=0x0}={}){const _0x3e4fbd=_0x5717,_0x468491=[];for(const [_0x34e826,_0x1d3fe8]of _0xbdf55c){const _0x4e1131=_0x41c027(_0x3f92cb,_0x1d3fe8);if(_0x4e1131>=threshold)_0x468491[_0x3e4fbd(0x212)]({'key':_0x34e826,'score':_0x4e1131});}return _0x468491[_0x3e4fbd(0x187)]((_0xe040ea,_0x306590)=>_0x306590[_0x3e4fbd(0x22a)]-_0xe040ea['score']),_0x468491[_0x3e4fbd(0x1ba)](0x0,limit);},async 'snapshot'(){return![];},async 'rebuild'(_0x5320d4){const _0x3b748c=_0x5717;await this[_0x3b748c(0x20b)](_0x5320d4);},async 'stop'(){},'count'(){const _0x147a65=_0x5717;return _0xbdf55c[_0x147a65(0x201)];},'info'(){const _0x1c7008=_0x5717;return{'algorithm':_0x1c7008(0x173),'count':_0xbdf55c[_0x1c7008(0x201)]};}};};function _0x41c027(_0x443171,_0x35df07){const _0x37e483=_0x5717;let _0x52fb20=0x0,_0x3e6133=0x0,_0x212cf9=0x0;for(let _0x3fc2dd=0x0;_0x3fc2dd<_0x443171[_0x37e483(0x232)];_0x3fc2dd++){_0x52fb20+=_0x443171[_0x3fc2dd]*_0x35df07[_0x3fc2dd],_0x3e6133+=_0x443171[_0x3fc2dd]*_0x443171[_0x3fc2dd],_0x212cf9+=_0x35df07[_0x3fc2dd]*_0x35df07[_0x3fc2dd];}const _0x24b219=Math['sqrt'](_0x3e6133)*Math[_0x37e483(0x21a)](_0x212cf9);return _0x24b219===0x0?0x0:_0x52fb20/_0x24b219;}return flat;}var writerLock,hasRequiredWriterLock;function requireWriterLock(){if(hasRequiredWriterLock)return writerLock;hasRequiredWriterLock=0x1;const _0x4a23cf=require$$0,_0x3dcb7f=require$$1,_0x2f0cb6=require$$3;return writerLock=function _0x2756b8(_0x14eb2f,{maxAgeMs:maxAgeMs=0x3a98,heartbeatMs:heartbeatMs=0x1388,onLost:onLost=null}={}){const _0xfe2552=_0x5717,_0x2165bf=_0x3dcb7f[_0xfe2552(0x20e)](_0x14eb2f,_0xfe2552(0x1da)),_0x57bb3b=_0x2f0cb6[_0xfe2552(0x1eb)](0x8)[_0xfe2552(0x172)](_0xfe2552(0x1e8));let _0x5b47a6=![],_0x1b747c=null;const _0x32b7dd=()=>JSON[_0xfe2552(0x200)]({'pid':process['pid'],'token':_0x57bb3b,'at':Date[_0xfe2552(0x17a)]()});function _0x340934(){const _0xb5c59d=_0xfe2552;try{return JSON[_0xb5c59d(0x1c4)](_0x4a23cf[_0xb5c59d(0x1d1)](_0x2165bf,_0xb5c59d(0x17f)));}catch(_0x445b55){return _0x445b55?.['code']===_0xb5c59d(0x17d)?null:{'unreadable':!![]};}}function _0x90ce6f(){const _0x5f408b=_0xfe2552;try{const _0x39994e=_0x4a23cf[_0x5f408b(0x1d2)](_0x2165bf,'wx');try{_0x4a23cf['writeFileSync'](_0x39994e,_0x32b7dd());}finally{_0x4a23cf['closeSync'](_0x39994e);}return!![];}catch(_0x221cef){if(_0x221cef?.[_0x5f408b(0x1a0)]===_0x5f408b(0x1a7))return![];throw _0x221cef;}}function _0x524aeb(_0x2229c0){const _0x46a5d4=_0xfe2552;if(!_0x2229c0)return!![];if(_0x2229c0[_0x46a5d4(0x1b9)])return!![];return Date[_0x46a5d4(0x17a)]()-(_0x2229c0['at']??0x0)>=maxAgeMs;}function _0x284f2c(){if(_0x1b747c)clearInterval(_0x1b747c);_0x1b747c=null;}function _0x3e0064(){_0x284f2c(),_0x1b747c=setInterval(()=>{const _0x572108=_0x5717,_0xa017e2=_0x340934();if(_0xa017e2&&!_0xa017e2[_0x572108(0x1b9)]&&_0xa017e2['token']!==_0x57bb3b){_0x5b47a6=![],_0x284f2c();try{onLost?.();}catch{}return;}try{_0x4a23cf['writeFileSync'](_0x2165bf,_0x32b7dd());}catch{}},heartbeatMs),_0x1b747c['unref']?.();}function _0x58cf82(){const _0x45d294=_0x340934();return!!_0x45d294&&_0x45d294['token']===_0x57bb3b;}return{'path':_0x2165bf,'token':_0x57bb3b,'acquire'(){const _0x1895e9=_0xfe2552,_0x1749dd=_0x340934();if(_0x1749dd&&_0x1749dd['token']===_0x57bb3b){_0x5b47a6=!![];if(!_0x1b747c)_0x3e0064();return!![];}let _0x35daa5=_0x90ce6f();if(!_0x35daa5&&_0x524aeb(_0x340934())){try{_0x4a23cf[_0x1895e9(0x1e2)](_0x2165bf);}catch{}_0x35daa5=_0x90ce6f();}if(_0x35daa5&&!_0x58cf82())_0x35daa5=![];_0x5b47a6=_0x35daa5;if(_0x35daa5)_0x3e0064();return _0x35daa5;},'held'(){return _0x5b47a6;},'isFree'(){const _0x200d63=_0xfe2552,_0x2b4599=_0x340934();if(_0x2b4599&&_0x2b4599[_0x200d63(0x1bb)]===_0x57bb3b)return![];return _0x524aeb(_0x2b4599);},'release'(){const _0x2855ac=_0xfe2552;_0x284f2c();if(!_0x5b47a6)return;_0x5b47a6=![];if(_0x58cf82())try{_0x4a23cf[_0x2855ac(0x1e2)](_0x2165bf);}catch{}}};},writerLock;}var usearch,hasRequiredUsearch;function requireUsearch(){if(hasRequiredUsearch)return usearch;hasRequiredUsearch=0x1;const _0x188e02=require$$0,_0x29bfac=requireSnapshotStore(),_0x5ce840=requireLabelMap(),_0x4db71e=requireWriterLock(),{fingerprint:_0x4cb014,reconcileIndex:_0x4b1132}=requireIndexConvergence(),_0xd937b7=0x1;let _0x3574d0=null;function _0x2d78e9(){const _0x5a1a53=_0x5717;if(_0x3574d0)return _0x3574d0;try{return _0x3574d0=require('usearch'),_0x3574d0;}catch(_0x3ccb77){const _0x547baf=new Error(_0x5a1a53(0x182)+(_0x5a1a53(0x18d)+process[_0x5a1a53(0x214)]['node']+_0x5a1a53(0x1fb)+process[_0x5a1a53(0x229)]+'/'+process['arch']+'.\x20')+_0x5a1a53(0x1cd)+('Original\x20error:\x20'+(_0x3ccb77?.[_0x5a1a53(0x19d)]||String(_0x3ccb77))));_0x547baf[_0x5a1a53(0x1a0)]='USEARCH_BINDINGS_UNAVAILABLE',_0x547baf['cause']=_0x3ccb77;throw _0x547baf;}}function _0x325064(_0x3006fb,_0x545faf){const _0x3b351f=_0x5717;switch(_0x3006fb){case _0x3b351f(0x1d9):return _0x545faf[_0x3b351f(0x211)]['Cos'];case'l2':return _0x545faf['MetricKind']['L2sq'];case'ip':return _0x545faf[_0x3b351f(0x211)]['IP'];default:return _0x545faf[_0x3b351f(0x211)][_0x3b351f(0x22e)];}}return usearch=function _0x3025d0(_0x3e9b76={},{dims:_0x39ca96,dir:_0x3a7e15,fetchAll:fetchAll=null,onChange:onChange=null}={}){const _0x16c739=_0x5717,_0x441028=_0x2d78e9();if(!_0x39ca96||_0x39ca96<=0x0)throw new Error('usearch\x20algorithm\x20requires\x20dims\x20>\x200');if(!_0x3a7e15)throw new Error('usearch\x20algorithm\x20requires\x20dir\x20for\x20snapshot\x20storage');const _0x2098a0={'metric':_0x3e9b76['metric']??'cosine','connectivity':_0x3e9b76[_0x16c739(0x1db)]??0x10,'expansionAdd':_0x3e9b76[_0x16c739(0x1c3)]??0x80,'expansionSearch':_0x3e9b76['expansionSearch']??0x40,'snapshotEveryChanges':_0x3e9b76[_0x16c739(0x19a)]??0xc350,'snapshotMaxLagMs':_0x3e9b76['snapshotMaxLagMs']??0x2710,'keepSnapshots':_0x3e9b76['keepSnapshots']??0x2,'tmpMaxAgeMs':_0x3e9b76['tmpMaxAgeMs']??0x6*0x36ee80,'heartbeatIntervalMs':_0x3e9b76[_0x16c739(0x223)]??0x1388,'writerLockMaxAgeMs':_0x3e9b76['writerLockMaxAgeMs']??0x3a98,'viewRefreshMs':_0x3e9b76['viewRefreshMs']??0x3e8},_0x114387=new _0x29bfac({'dir':_0x3a7e15,'keepSnapshots':_0x2098a0[_0x16c739(0x181)]}),_0x495aff=_0x4db71e(_0x3a7e15,{'maxAgeMs':_0x2098a0[_0x16c739(0x1f6)],'heartbeatMs':_0x2098a0[_0x16c739(0x223)],'onLost':()=>{const _0x5b6b39=_0x16c739;_0x3571ac(_0x2235e7)[_0x5b6b39(0x1bd)](()=>{});}});let _0x3687b1=new _0x5ce840(),_0x234e36=null,_0x2d0049=0x0,_0xb6d3d3=null,_0x509561=![],_0x41a7b7=![],_0x81c4b5=null,_0x5e7c0b=0x0,_0x397d12=null,_0x48f2a5=0x0,_0x2b61dd=![],_0x1cfed5=Promise[_0x16c739(0x169)]();const _0x3571ac=_0x4f6a37=>{const _0x34197e=_0x16c739,_0x19a7b7=_0x1cfed5[_0x34197e(0x1b5)](_0x4f6a37);return _0x1cfed5=_0x19a7b7[_0x34197e(0x1bd)](()=>{}),_0x19a7b7;},_0x477821=()=>{try{onChange?.();}catch{}};function _0x333503(){const _0x2c58f8=_0x16c739;return new _0x441028[(_0x2c58f8(0x1b7))]({'dimensions':_0x39ca96,'metric':_0x325064(_0x2098a0[_0x2c58f8(0x21b)],_0x441028),'quantization':_0x441028[_0x2c58f8(0x23b)]['F32'],'connectivity':_0x2098a0['connectivity'],'expansion_add':_0x2098a0[_0x2c58f8(0x1c3)],'expansion_search':_0x2098a0[_0x2c58f8(0x215)],'multi':![]});}function _0x546ab5(_0x357f5f){return _0x357f5f instanceof Float32Array?_0x357f5f:new Float32Array(_0x357f5f);}function _0x27164a(){if(fetchAll)return fetchAll();if(_0xb6d3d3)return _0xb6d3d3();return Promise['resolve'](null);}function _0x4ccb38(_0x47ee10,_0x23ba1c,_0x53ef78){const _0x13ca61=_0x16c739,_0x472320=_0x3687b1[_0x13ca61(0x188)](_0x47ee10);if(_0x472320!==undefined)try{_0x234e36[_0x13ca61(0x174)](BigInt(_0x472320));}catch{}const _0x5826a2=_0x3687b1[_0x13ca61(0x216)](_0x47ee10);_0x234e36['add'](BigInt(_0x5826a2),_0x23ba1c),_0x3687b1[_0x13ca61(0x16d)](_0x47ee10,_0x53ef78??_0x4cb014(_0x23ba1c));}function _0x56422f(_0x1187b3){const _0xedc47=_0x16c739,_0x1c3126=_0x3687b1[_0xedc47(0x188)](_0x1187b3);if(_0x1c3126===undefined)return![];try{_0x234e36[_0xedc47(0x174)](BigInt(_0x1c3126));}catch{}return _0x3687b1['tombstone'](_0x1187b3),!![];}function _0x13285f(_0x4d66d8){const _0x44dca9=_0x16c739;_0x3687b1=new _0x5ce840(),_0x234e36=_0x333503();for(const {key:_0x2b74ad,vector:_0x1da19d}of _0x4d66d8??[]){if(!(_0x1da19d instanceof Float32Array)||_0x1da19d[_0x44dca9(0x232)]!==_0x39ca96)continue;_0x4ccb38(_0x2b74ad,_0x1da19d);}_0x2d0049=0x0;}function _0x3d7856(){const _0x382819=_0x16c739;return Math['max'](Date[_0x382819(0x17a)](),_0x114387[_0x382819(0x217)]()+0x1);}function _0x33143b(){if(_0x81c4b5)clearTimeout(_0x81c4b5);_0x81c4b5=null;}function _0x293e8a(){const _0x45a7e1=_0x16c739;if(!_0x2098a0['snapshotMaxLagMs']||_0x81c4b5||!_0x41a7b7||_0x2d0049<=0x0)return;const _0x30e615=Math[_0x45a7e1(0x222)](_0x2098a0[_0x45a7e1(0x179)],0xa*_0x5e7c0b);_0x81c4b5=setTimeout(()=>{const _0x6de410=_0x45a7e1;_0x81c4b5=null,_0x3571ac(async()=>{if(_0x41a7b7&&_0x2d0049>0x0)await _0x12d40c();_0x293e8a(),_0x477821();})[_0x6de410(0x1bd)](()=>{});},_0x30e615),_0x81c4b5[_0x45a7e1(0x226)]?.();}async function _0x12d40c(_0x3f369d){const _0x2cb75d=_0x16c739;if(!_0x234e36)return![];const _0x1a66aa=_0x3f369d??_0x3d7856(),_0x44dc9d=Date[_0x2cb75d(0x17a)](),_0x121585=await _0x114387[_0x2cb75d(0x17e)](_0x1a66aa,async _0x4912fb=>{const _0x311851=_0x2cb75d;_0x234e36['save'](_0x4912fb[_0x311851(0x221)]),await _0x3687b1['snapshotTo'](_0x4912fb[_0x311851(0x227)]),_0x188e02[_0x311851(0x238)](_0x4912fb[_0x311851(0x1e4)],JSON[_0x311851(0x200)]({'manifestVersion':_0xd937b7,'algorithm':'usearch','dims':_0x39ca96,'metric':_0x2098a0[_0x311851(0x21b)],'clock':_0x1a66aa,'snapshotAt':Date['now']()},null,0x2));},{'keep':_0x2098a0[_0x2cb75d(0x181)]});return _0x5e7c0b=Date[_0x2cb75d(0x17a)]()-_0x44dc9d,_0x121585?.[_0x2cb75d(0x1c5)]&&(_0x2d0049=0x0,_0x33143b()),_0x121585?.[_0x2cb75d(0x1c5)]??![];}function _0x4b8e9a(){const _0xcbba8c=_0x16c739;_0x2d0049++;if(_0x2d0049>=_0x2098a0[_0xcbba8c(0x19a)])return _0x12d40c();return _0x293e8a(),null;}async function _0x378db3(){const _0x25393f=_0x16c739,_0x504578=_0x114387[_0x25393f(0x1b6)]()||_0x114387['latestSnapshotId']();if(!_0x504578)return null;let _0xe07b1f,_0x5eea38=![];try{await _0x114387[_0x25393f(0x1e0)](_0x504578,async _0x28e1ec=>{const _0x3b47e5=_0x25393f;_0xe07b1f=JSON[_0x3b47e5(0x1c4)](_0x188e02['readFileSync'](_0x28e1ec[_0x3b47e5(0x1e4)],_0x3b47e5(0x17f)));if(_0xe07b1f['manifestVersion']!==_0xd937b7||_0xe07b1f[_0x3b47e5(0x205)]!==_0x3b47e5(0x184)||_0xe07b1f[_0x3b47e5(0x233)]!==_0x39ca96||_0xe07b1f['metric']!==_0x2098a0[_0x3b47e5(0x21b)]){_0xe07b1f=null;return;}const _0x5964ef=new _0x5ce840();await _0x5964ef['loadFrom'](_0x28e1ec['labels']);const _0x452afd=_0x333503();_0x452afd[_0x3b47e5(0x20b)](_0x28e1ec[_0x3b47e5(0x221)]),_0x3687b1=_0x5964ef,_0x234e36=_0x452afd,_0x5eea38=!![];});}catch{return null;}return _0x5eea38?_0xe07b1f?.[_0x25393f(0x19e)]??0x0:null;}async function _0x2b10b9(_0x3eb011){const _0x220a8a=_0x16c739;_0x397d12=null;const _0x1e7278=await _0x378db3();if(_0x1e7278!=null){_0x2d0049=0x0;if(_0x3eb011){if(!_0x3687b1[_0x220a8a(0x1d4)])return _0x13285f(_0x3eb011),await _0x12d40c(),null;const _0x5a5689=_0x4b1132(_0x3687b1,_0x3eb011,_0x39ca96,{'upsert':_0x4ccb38,'remove':_0x56422f}),_0x2d29b2=_0x5a5689[_0x220a8a(0x193)]+_0x5a5689['changed']+_0x5a5689[_0x220a8a(0x236)];_0x2d29b2>0x0&&(_0x2d0049+=_0x2d29b2,await _0x12d40c());}return _0x1e7278;}_0x13285f(_0x3eb011??[]);if(_0x234e36[_0x220a8a(0x201)]()>0x0)await _0x12d40c();return null;}async function _0x252b54(){_0x41a7b7=!![],await _0x2b10b9(await _0x27164a());}async function _0x2235e7(){if(!_0x41a7b7)return;_0x41a7b7=![],_0x33143b(),_0x2d0049=0x0;const _0x3403f1=_0x114387['readCurrentId']()||_0x114387['latestSnapshotId']();await _0x48c768(_0x3403f1),_0x477821();}async function _0x48c768(_0x4760c1){const _0x470a06=_0x16c739;if(!_0x4760c1)return![];let _0x432bfb=![];try{await _0x114387[_0x470a06(0x1e0)](_0x4760c1,async _0x2724cc=>{const _0x128c1f=_0x470a06,_0x2cd90f=JSON[_0x128c1f(0x1c4)](_0x188e02[_0x128c1f(0x1d1)](_0x2724cc[_0x128c1f(0x1e4)],_0x128c1f(0x17f)));if(_0x2cd90f[_0x128c1f(0x1f8)]!==_0xd937b7||_0x2cd90f['algorithm']!=='usearch'||_0x2cd90f[_0x128c1f(0x233)]!==_0x39ca96||_0x2cd90f[_0x128c1f(0x21b)]!==_0x2098a0[_0x128c1f(0x21b)])return;const _0x2640e4=new _0x5ce840();await _0x2640e4['loadFrom'](_0x2724cc[_0x128c1f(0x227)]);const _0x191745=_0x333503();_0x191745[_0x128c1f(0x207)](_0x2724cc[_0x128c1f(0x221)]),_0x234e36=_0x191745,_0x3687b1=_0x2640e4,_0x397d12=_0x4760c1,_0x432bfb=!![];});}catch{}return _0x432bfb;}function _0x3ef21d(){const _0x2a0780=_0x16c739,_0x295b6f=Date[_0x2a0780(0x17a)]();if(_0x295b6f-_0x48f2a5<_0x2098a0[_0x2a0780(0x22f)])return;_0x48f2a5=_0x295b6f;if(_0x2b61dd)return;if(_0x495aff[_0x2a0780(0x218)]()){_0x2b61dd=!![],_0x3571ac(async()=>{const _0xf8924c=_0x2a0780;!_0x41a7b7&&_0x509561&&_0x495aff[_0xf8924c(0x1cf)]()&&(await _0x252b54(),_0x477821());})['catch'](()=>{})[_0x2a0780(0x19c)](()=>{_0x2b61dd=![];});return;}const _0x282601=_0x114387[_0x2a0780(0x1b6)]()||_0x114387[_0x2a0780(0x1cc)]();if(!_0x282601||_0x282601===_0x397d12)return;_0x2b61dd=!![],_0x3571ac(async()=>{if(!_0x41a7b7&&await _0x48c768(_0x282601))_0x477821();})[_0x2a0780(0x1bd)](()=>{})[_0x2a0780(0x19c)](()=>{_0x2b61dd=![];});}return{async 'load'(_0x6ede51){return _0x3571ac(async()=>{const _0x1fe31b=_0x5717;_0x114387[_0x1fe31b(0x1d3)]({'maxAgeMs':_0x2098a0['tmpMaxAgeMs']}),_0xb6d3d3=_0x6ede51??null,_0x41a7b7=_0x495aff[_0x1fe31b(0x1cf)]();let _0x439ec4=null;if(_0x41a7b7)_0x439ec4=await _0x2b10b9(_0x6ede51?await _0x6ede51():null);else{const _0x19dc71=_0x114387[_0x1fe31b(0x1b6)]()||_0x114387[_0x1fe31b(0x1cc)]();await _0x48c768(_0x19dc71);}return _0x509561=!![],_0x439ec4;});},async 'add'(_0x44be87,_0x2cf90a,_0x4a7b34){return _0x3571ac(async()=>{const _0xe06931=_0x5717;if(!_0x509561)return;const _0x3c20f4=_0x546ab5(_0x2cf90a);if(!_0x41a7b7){if(!_0x495aff[_0xe06931(0x1cf)]())return;await _0x252b54();}if(!_0x234e36)return;const _0x47a6fb=_0x4cb014(_0x3c20f4);if(_0x3687b1[_0xe06931(0x1a9)](_0x44be87)===_0x47a6fb)return;_0x4ccb38(_0x44be87,_0x3c20f4,_0x47a6fb),await _0x4b8e9a();});},async 'remove'(_0x3bdf44){return _0x3571ac(async()=>{const _0x6ee5fe=_0x5717;if(!_0x509561)return;if(!_0x41a7b7){if(!_0x495aff[_0x6ee5fe(0x1cf)]())return;await _0x252b54();}if(!_0x234e36)return;if(_0x56422f(_0x3bdf44))await _0x4b8e9a();});},'search'(_0x2ee448,{limit:limit=0xa}={}){const _0x2277e1=_0x16c739;if(!_0x41a7b7&&_0x509561)_0x3ef21d();if(!_0x234e36)return[];const _0x13ac07=_0x234e36[_0x2277e1(0x201)]();if(_0x13ac07===0x0)return[];const _0x1c090f=Math[_0x2277e1(0x1bf)](limit,_0x13ac07),_0x4cb84d=_0x234e36[_0x2277e1(0x203)](_0x546ab5(_0x2ee448),_0x1c090f,0x0),_0x43d5c5=[],_0x5cf998=_0x4cb84d[_0x2277e1(0x195)],_0x5b9bd9=_0x4cb84d[_0x2277e1(0x22d)];for(let _0x112706=0x0;_0x112706<_0x5cf998[_0x2277e1(0x232)];_0x112706++){const _0x2999ae=_0x5cf998[_0x112706];if(_0x2999ae===0xffffffffffffffffn)continue;const _0x56311e=Number(_0x2999ae),_0x5b1061=_0x3687b1[_0x2277e1(0x1fd)](_0x56311e);if(!_0x5b1061)continue;const _0x12c4e5=_0x5b9bd9[_0x112706];let _0x2938e5;if(_0x2098a0['metric']==='cosine')_0x2938e5=Math[_0x2277e1(0x222)](0x0,0x1-_0x12c4e5);else{if(_0x2098a0['metric']==='ip')_0x2938e5=-_0x12c4e5;else _0x2938e5=0x1/(0x1+_0x12c4e5);}_0x43d5c5[_0x2277e1(0x212)]({'key':_0x5b1061,'score':_0x2938e5});}return _0x43d5c5;},async 'snapshot'(_0x25d46c){return _0x3571ac(()=>_0x41a7b7?_0x12d40c(_0x25d46c??undefined):![]);},async 'rebuild'(_0x434e1f){return _0x3571ac(async()=>{const _0x140320=_0x5717;if(_0x434e1f!=null)_0xb6d3d3=_0x434e1f;if(!_0x41a7b7){if(!_0x495aff[_0x140320(0x1cf)]())return;_0x41a7b7=!![];}const _0x2d0158=_0x434e1f?await _0x434e1f():await _0x27164a();_0x13285f(_0x2d0158??[]),_0x509561=!![],await _0x12d40c();});},async 'stop'(){return _0x3571ac(async()=>{const _0x18c3f3=_0x5717;_0x33143b();if(_0x41a7b7){if(_0x2d0049>0x0||!_0x114387[_0x18c3f3(0x1b6)]())await _0x12d40c();_0x495aff[_0x18c3f3(0x1fa)]();}_0x41a7b7=![],_0x509561=![];});},'count'(){return _0x3687b1['size']();},'info'(){const _0x2b8941=_0x16c739;return{'algorithm':_0x2b8941(0x184),'role':_0x41a7b7?_0x2b8941(0x19b):_0x2b8941(0x16e),'metric':_0x2098a0[_0x2b8941(0x21b)],'connectivity':_0x2098a0[_0x2b8941(0x1db)],'expansionAdd':_0x2098a0['expansionAdd'],'expansionSearch':_0x2098a0[_0x2b8941(0x215)],'snapshotEveryChanges':_0x2098a0[_0x2b8941(0x19a)],'snapshotMaxLagMs':_0x2098a0[_0x2b8941(0x179)],'count':_0x3687b1[_0x2b8941(0x201)](),'size':_0x234e36?.[_0x2b8941(0x201)]?.()??0x0,'capacity':_0x234e36?.[_0x2b8941(0x1f2)]?.()??0x0,'changesSince':_0x41a7b7?_0x2d0049:null,'viewedSnapshot':_0x397d12??null,'snapshotDir':_0x3a7e15,'latestSnapshot':_0x114387[_0x2b8941(0x1b6)]()??null};}};},usearch;}var hasRequiredAlgorithmWorkerThread;function requireAlgorithmWorkerThread(){const _0x1929bc=_0x5717;if(hasRequiredAlgorithmWorkerThread)return algorithmWorkerThread$1;hasRequiredAlgorithmWorkerThread=0x1;const {parentPort:_0x169156,workerData:_0x24ec54}=require$$0$1,{algorithmName:_0x125829,algorithmConfig:_0x3c3bb3,dims:_0x162de7,dir:_0x41944d}=_0x24ec54;let _0x1484ea=0x1;const _0x15e9bc=new Map();function _0x27299f(){const _0x5541a3=_0x1484ea++;return new Promise((_0xa4e217,_0xa0673d)=>{const _0x489c2a=_0x5717;_0x15e9bc[_0x489c2a(0x225)](_0x5541a3,{'resolve':_0xa4e217,'reject':_0xa0673d}),_0x169156[_0x489c2a(0x18f)]({'op':_0x489c2a(0x209),'fid':_0x5541a3});});}const _0x1d0bb1={'dims':_0x162de7,'dir':_0x41944d,'fetchAll':_0x27299f,'onChange':()=>_0x1aeeb1()};let _0x54a9f6;if(_0x125829===_0x1929bc(0x1f9))_0x54a9f6=requireHnsw()(_0x3c3bb3,_0x1d0bb1);else{if(_0x125829===_0x1929bc(0x173))_0x54a9f6=requireFlat()(_0x3c3bb3,_0x1d0bb1);else{if(_0x125829===_0x1929bc(0x184))_0x54a9f6=requireUsearch()(_0x3c3bb3,_0x1d0bb1);else throw new Error(_0x1929bc(0x1e7)+_0x125829+'\x22');}}function _0x1aeeb1(){const _0x5c3b38=_0x1929bc;try{_0x169156['postMessage']({'op':'sync','count':_0x54a9f6[_0x5c3b38(0x1ea)](),'info':_0x54a9f6[_0x5c3b38(0x1d0)](),'memory':process['memoryUsage']()});}catch{}}function _0x278527(_0x22b399){const _0x6292f5=_0x1929bc;return(_0x22b399||[])['map'](_0x142fc4=>({'key':_0x142fc4[_0x6292f5(0x194)],'vector':_0x142fc4[_0x6292f5(0x18a)]instanceof Float32Array?_0x142fc4['vector']:new Float32Array(_0x142fc4['vector'])}));}return _0x169156['on'](_0x1929bc(0x19d),async _0x276a6d=>{const _0x10e805=_0x1929bc;if(_0x276a6d['op']===_0x10e805(0x16c)){const _0xf3682a=_0x15e9bc[_0x10e805(0x23e)](_0x276a6d[_0x10e805(0x178)]);if(!_0xf3682a)return;_0x15e9bc[_0x10e805(0x175)](_0x276a6d[_0x10e805(0x178)]);if(_0x276a6d[_0x10e805(0x208)])_0xf3682a[_0x10e805(0x1ce)](new Error(_0x276a6d['error']));else _0xf3682a[_0x10e805(0x169)](_0x278527(_0x276a6d[_0x10e805(0x1c7)]));return;}const {id:_0x22bb54,op:_0x44a6cd,args:_0x189a6d}=_0x276a6d;try{let _0x304606;switch(_0x44a6cd){case _0x10e805(0x20b):{_0x304606=await _0x54a9f6[_0x10e805(0x20b)](_0x189a6d['hasRows']?_0x27299f:null),_0x1aeeb1();break;}case _0x10e805(0x1a8):{const _0x4e826d=_0x189a6d[_0x10e805(0x18a)]instanceof Float32Array?_0x189a6d['vector']:new Float32Array(_0x189a6d['vector']);await _0x54a9f6[_0x10e805(0x1a8)](_0x189a6d['key'],_0x4e826d,_0x189a6d['clock']??undefined),_0x1aeeb1(),_0x304606=null;break;}case'remove':{await _0x54a9f6[_0x10e805(0x174)](_0x189a6d[_0x10e805(0x194)]),_0x1aeeb1(),_0x304606=null;break;}case'search':{const _0x113a56=_0x189a6d['queryVec']instanceof Float32Array?_0x189a6d[_0x10e805(0x171)]:new Float32Array(_0x189a6d[_0x10e805(0x171)]);_0x304606=_0x54a9f6[_0x10e805(0x203)](_0x113a56,_0x189a6d[_0x10e805(0x1ae)]||{});break;}case'snapshot':{_0x304606=await _0x54a9f6[_0x10e805(0x1b4)](_0x189a6d['clock']),_0x1aeeb1();break;}case _0x10e805(0x1ad):{const _0x3e62cf=_0x278527(_0x189a6d[_0x10e805(0x1c7)]);await _0x54a9f6[_0x10e805(0x1ad)](async()=>_0x3e62cf),_0x1aeeb1(),_0x304606=null;break;}case _0x10e805(0x231):{await _0x54a9f6['stop'](),_0x1aeeb1(),_0x304606=null;break;}case _0x10e805(0x1ea):{_0x304606=_0x54a9f6[_0x10e805(0x1ea)]();break;}case'info':{_0x304606=_0x54a9f6[_0x10e805(0x1d0)]();break;}default:throw new Error(_0x10e805(0x183)+_0x44a6cd+'\x22');}_0x169156[_0x10e805(0x18f)]({'id':_0x22bb54,'result':_0x304606});}catch(_0x3325d3){_0x169156['postMessage']({'id':_0x22bb54,'error':{'message':_0x3325d3?.[_0x10e805(0x19d)]||String(_0x3325d3),'code':_0x3325d3?.[_0x10e805(0x1a0)]}});}}),_0x169156[_0x1929bc(0x18f)]({'op':_0x1929bc(0x1b0)}),algorithmWorkerThread$1;}var algorithmWorkerThreadExports=requireAlgorithmWorkerThread(),algorithmWorkerThread=getDefaultExportFromCjs(algorithmWorkerThreadExports);module[_0x5db5a4(0x23c)]=algorithmWorkerThread;