@4ier/neo 0.4.0
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.
- package/README.md +356 -0
- package/extension-dist/background.js +3 -0
- package/extension-dist/content.js +1 -0
- package/extension-dist/inject.js +4 -0
- package/extension-dist/manifest.json +51 -0
- package/package.json +46 -0
- package/tools/neo.cjs +5985 -0
package/README.md
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
# Neo
|
|
2
|
+
|
|
3
|
+
**Turn any web app into an API.** No official API needed. No browser automation.
|
|
4
|
+
|
|
5
|
+
Neo is a Chrome extension that passively captures every API call your browser makes, learns the patterns, and lets AI (or you) replay them directly.
|
|
6
|
+
|
|
7
|
+
## The Problem
|
|
8
|
+
|
|
9
|
+
AI agents operating web apps today have two options, both bad:
|
|
10
|
+
|
|
11
|
+
| Approach | Pain |
|
|
12
|
+
|----------|------|
|
|
13
|
+
| **Official APIs** | Most SaaS doesn't have one, or only exposes 10% of features |
|
|
14
|
+
| **Browser automation** | Screenshot → OCR → click. Slow, fragile, breaks on every UI change |
|
|
15
|
+
|
|
16
|
+
**Neo is the third way.** Every web app already has a complete internal API — the frontend calls it every time you click something. Neo captures those calls and makes them replayable.
|
|
17
|
+
|
|
18
|
+
**v2: Now with UI automation.** Neo v2 adds an accessibility-tree-based UI layer — `snapshot`, `click`, `fill`, `type`, `press`, `hover`, `scroll`, `select`, `screenshot`, `get`, `wait`. When an API exists, use it directly. When it doesn't, Neo can drive the UI through the same CLI. One tool, both layers.
|
|
19
|
+
|
|
20
|
+
## How It Works
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
Browse normally → Neo records all API traffic → Schema auto-generated → AI replays APIs directly
|
|
24
|
+
→ Or drives UI via a11y tree
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 1. Capture (always-on)
|
|
28
|
+
|
|
29
|
+
The Chrome extension intercepts every `fetch()` and `XMLHttpRequest` — URLs, headers, request/response bodies, timing, even which DOM element triggered the call.
|
|
30
|
+
|
|
31
|
+
### 2. Learn
|
|
32
|
+
|
|
33
|
+
Run `neo-schema` on a domain to auto-generate its API map: endpoints, required auth headers, query parameters, response structure, error codes.
|
|
34
|
+
|
|
35
|
+
### 3. Execute
|
|
36
|
+
|
|
37
|
+
Run API calls inside the browser tab's context via Chrome DevTools Protocol. Cookies, CSRF tokens, session auth — all inherited automatically. No token management needed.
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/4ier/neo.git
|
|
43
|
+
cd neo && npm install && npm run build
|
|
44
|
+
npm link # makes `neo` available globally
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Load the extension:
|
|
48
|
+
1. Open `chrome://extensions`
|
|
49
|
+
2. Enable "Developer mode"
|
|
50
|
+
3. Click "Load unpacked" → select `extension/dist/`
|
|
51
|
+
4. Browse any website — Neo starts capturing immediately
|
|
52
|
+
|
|
53
|
+
## CLI Tools
|
|
54
|
+
|
|
55
|
+
All commands go through a single CLI: `neo <command>`.
|
|
56
|
+
|
|
57
|
+
Requires a browser with CDP (Chrome DevTools Protocol) enabled.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# --- Connection & Sessions ---
|
|
61
|
+
neo connect [port] # Connect to CDP, save session
|
|
62
|
+
neo connect --electron <app-name> # Auto-discover Electron app's CDP port
|
|
63
|
+
neo launch <app> [--port N] # Launch Electron app with CDP enabled
|
|
64
|
+
neo discover # Find reachable CDP endpoints on localhost
|
|
65
|
+
neo sessions # List saved sessions
|
|
66
|
+
neo tab # List CDP targets in active session
|
|
67
|
+
neo tab <index> | neo tab --url <pattern> # Switch active tab target
|
|
68
|
+
neo inject [--persist] [--tab pattern] # Inject Neo capture script into target
|
|
69
|
+
|
|
70
|
+
# --- Capture & Traffic ---
|
|
71
|
+
neo status # Overview of captured data
|
|
72
|
+
neo capture summary # Quick overview
|
|
73
|
+
neo capture list github.com --limit 10 # Shows IDs for replay/detail
|
|
74
|
+
neo capture list --since 1h # Time-filtered
|
|
75
|
+
neo capture domains
|
|
76
|
+
neo capture search "CreateTweet" --method POST
|
|
77
|
+
neo capture watch x.com # Live tail (like tail -f)
|
|
78
|
+
neo capture stats x.com # Method/status/timing breakdown
|
|
79
|
+
neo capture export x.com --since 2h > x.json
|
|
80
|
+
neo capture export x.com --format har > x.har # HAR 1.2 for Postman/devtools
|
|
81
|
+
neo capture import x-captures.json
|
|
82
|
+
neo capture prune --older-than 7d
|
|
83
|
+
neo capture gc x.com [--dry-run] # Smart dedup
|
|
84
|
+
|
|
85
|
+
# --- API Replay & Execution ---
|
|
86
|
+
neo replay <capture-id> --tab x.com # Replay a captured call
|
|
87
|
+
neo exec <url> --method POST --body '{...}' --tab example.com --auto-headers
|
|
88
|
+
neo api x.com HomeTimeline # Smart call (schema lookup + auto-auth)
|
|
89
|
+
|
|
90
|
+
# --- Schema & Analysis ---
|
|
91
|
+
neo schema generate x.com # Generate from captures
|
|
92
|
+
neo schema generate --all # Batch all domains
|
|
93
|
+
neo schema show x.com [--json]
|
|
94
|
+
neo schema openapi x.com # Export OpenAPI 3.0 spec
|
|
95
|
+
neo schema diff x.com # Changes from previous version
|
|
96
|
+
neo schema coverage # Domains with/without schemas
|
|
97
|
+
neo label x.com [--dry-run] # Semantic endpoint labels
|
|
98
|
+
neo flows x.com [--window 5000] # API call sequence patterns
|
|
99
|
+
neo deps x.com [--min-confidence 1] # Response→request data dependencies
|
|
100
|
+
neo workflow discover|show|run <name> # Multi-step workflow discovery & replay
|
|
101
|
+
neo suggest x.com # AI capability analysis
|
|
102
|
+
neo export-skill x.com # Generate agent-ready SKILL.md
|
|
103
|
+
|
|
104
|
+
# --- UI Automation (v2) ---
|
|
105
|
+
neo snapshot [-i] [-C] [--json] # A11y tree with @ref mapping
|
|
106
|
+
neo click @ref [--new-tab] # Click element by @ref
|
|
107
|
+
neo fill @ref "text" # Clear + fill input
|
|
108
|
+
neo type @ref "text" # Append text to input
|
|
109
|
+
neo press <key> # Keyboard key (supports Ctrl+a, Enter, etc.)
|
|
110
|
+
neo hover @ref # Hover over element
|
|
111
|
+
neo scroll <dir> [px] [--selector css] # Scroll by direction
|
|
112
|
+
neo select @ref "value" # Set dropdown value
|
|
113
|
+
neo screenshot [path] [--full] [--annotate] # Capture screenshot
|
|
114
|
+
neo get text @ref | neo get url | neo get title # Extract info
|
|
115
|
+
neo wait @ref | neo wait --load networkidle | neo wait <ms> # Wait for element/load/time
|
|
116
|
+
|
|
117
|
+
# --- Page Interaction ---
|
|
118
|
+
neo read github.com # Extract readable text
|
|
119
|
+
neo eval "document.title" --tab github.com # Run JS in page
|
|
120
|
+
neo open https://example.com # Open URL
|
|
121
|
+
|
|
122
|
+
# --- Mock & Bridge ---
|
|
123
|
+
neo mock x.com [--port 8080 --latency 200] # Mock server from schema
|
|
124
|
+
neo bridge [--json] [--interactive] # Real-time WebSocket capture stream
|
|
125
|
+
|
|
126
|
+
# --- Diagnostics ---
|
|
127
|
+
neo doctor # Check Chrome, extension, schemas
|
|
128
|
+
neo reload # Reload extension from CLI
|
|
129
|
+
neo tabs [filter] # List open Chrome tabs
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Sessions & Multi-App Support
|
|
133
|
+
|
|
134
|
+
Neo isn't just for Chrome. Any app with CDP support works — including Electron apps:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Launch VS Code with CDP and connect
|
|
138
|
+
neo launch code --port 9230
|
|
139
|
+
neo snapshot # See VS Code's accessibility tree
|
|
140
|
+
neo click @14 # Click a menu item
|
|
141
|
+
|
|
142
|
+
# Or connect to an already-running Electron app
|
|
143
|
+
neo connect --electron slack
|
|
144
|
+
|
|
145
|
+
# Inject Neo's capture script into any CDP target
|
|
146
|
+
neo inject --persist # Survives page navigation
|
|
147
|
+
neo inject --tab slack # Target specific tab
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Sessions are saved automatically. Switch between them with `--session`:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
neo --session vscode snapshot
|
|
154
|
+
neo --session chrome api x.com HomeTimeline
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### UI Automation (v2)
|
|
158
|
+
|
|
159
|
+
Neo v2 adds a full UI interaction layer built on the accessibility tree — no screenshots, no coordinates, no pixel-matching:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# 1. Take a snapshot — each interactive element gets a @ref
|
|
163
|
+
neo snapshot
|
|
164
|
+
# @1 button "Sign in"
|
|
165
|
+
# @2 textbox "Search"
|
|
166
|
+
# @3 link "Pricing"
|
|
167
|
+
|
|
168
|
+
# 2. Interact by @ref
|
|
169
|
+
neo click @1
|
|
170
|
+
neo fill @2 "AI agents"
|
|
171
|
+
neo press Enter
|
|
172
|
+
neo screenshot results.png --full
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
This gives AI agents a fast, semantic way to interact with any UI. Combine with API capture for a dual-channel approach: use APIs when they exist, fall back to UI when they don't.
|
|
176
|
+
|
|
177
|
+
The bridge creates a persistent WebSocket channel between the extension and CLI. The extension auto-connects to `ws://127.0.0.1:9234` and streams every capture in real-time. In interactive mode, you can query the extension directly: `ping`, `status`, `capture.count`, `capture.list`, `capture.domains`, `capture.search`, `capture.clear`.
|
|
178
|
+
|
|
179
|
+
## Architecture
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
┌─────────────────────────────────────┐
|
|
183
|
+
│ Chrome / Electron App (CDP) │
|
|
184
|
+
│ │
|
|
185
|
+
│ inject/interceptor.ts │
|
|
186
|
+
│ ├─ Monkey-patches fetch & XHR │
|
|
187
|
+
│ ├─ Intercepts WebSocket/SSE │
|
|
188
|
+
│ ├─ Tracks DOM triggers (click → │
|
|
189
|
+
│ │ API correlation) │
|
|
190
|
+
│ └─ Records full request/response │
|
|
191
|
+
│ │
|
|
192
|
+
│ content/index.ts │
|
|
193
|
+
│ └─ Bridges page ↔ extension │
|
|
194
|
+
│ │
|
|
195
|
+
│ background/index.ts │
|
|
196
|
+
│ ├─ Persists to IndexedDB (Dexie) │
|
|
197
|
+
│ ├─ Per-domain cap (500 entries) │
|
|
198
|
+
│ └─ WebSocket Bridge client │
|
|
199
|
+
│ │
|
|
200
|
+
└──────────────┬──────────────────────┘
|
|
201
|
+
│ Chrome DevTools Protocol
|
|
202
|
+
┌──────────────┴──────────────────────┐
|
|
203
|
+
│ CLI: neo (Node.js) │
|
|
204
|
+
│ │
|
|
205
|
+
│ Layer 1: API Capture & Replay │
|
|
206
|
+
│ ├─ neo capture → traffic management │
|
|
207
|
+
│ ├─ neo schema → API discovery │
|
|
208
|
+
│ ├─ neo exec → execute in browser │
|
|
209
|
+
│ ├─ neo api → smart schema call │
|
|
210
|
+
│ ├─ neo replay → re-run captured │
|
|
211
|
+
│ └─ neo flows/deps → pattern analysis│
|
|
212
|
+
│ │
|
|
213
|
+
│ Layer 2: UI Automation (v2) │
|
|
214
|
+
│ ├─ neo snapshot → a11y tree + @refs │
|
|
215
|
+
│ ├─ neo click/fill/type/press/hover │
|
|
216
|
+
│ ├─ neo scroll/select/screenshot │
|
|
217
|
+
│ └─ neo get/wait │
|
|
218
|
+
│ │
|
|
219
|
+
│ Session Management │
|
|
220
|
+
│ ├─ neo connect/launch/discover │
|
|
221
|
+
│ ├─ neo tab → target switching │
|
|
222
|
+
│ └─ neo inject → script injection │
|
|
223
|
+
│ │
|
|
224
|
+
└──────────────┬──────────────────────┘
|
|
225
|
+
│
|
|
226
|
+
┌──────────────┴──────────────────────┐
|
|
227
|
+
│ AI Agent (OpenClaw / any LLM) │
|
|
228
|
+
│ ├─ API-first: schema → exec/api │
|
|
229
|
+
│ ├─ UI fallback: snapshot → click │
|
|
230
|
+
│ └─ Dual-channel automation │
|
|
231
|
+
└──────────────────────────────────────┘
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Real-World Demo
|
|
235
|
+
|
|
236
|
+
### Post a tweet via captured API
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# 1. Browse X normally — Neo captures GraphQL mutations
|
|
240
|
+
neo schema show api.x.com
|
|
241
|
+
|
|
242
|
+
# 2. Find the CreateTweet endpoint
|
|
243
|
+
neo capture search "CreateTweet" --method POST
|
|
244
|
+
|
|
245
|
+
# 3. Replay with the original auth (cookies inherited automatically)
|
|
246
|
+
neo replay abc123 --tab x.com
|
|
247
|
+
|
|
248
|
+
# 4. Or craft a new call with auto-detected auth headers
|
|
249
|
+
neo exec "https://x.com/i/api/graphql/.../CreateTweet" \
|
|
250
|
+
--method POST --auto-headers \
|
|
251
|
+
--body '{"variables":{"tweet_text":"Hello from Neo!"},...}'
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Understand what a button does
|
|
255
|
+
|
|
256
|
+
Neo's trigger tracking maps UI interactions to API calls:
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
neo schema show github.com
|
|
260
|
+
# Output includes:
|
|
261
|
+
# POST /repos/:owner/:repo/star (3x, 280ms)
|
|
262
|
+
# ← click button.js-social-form "Star" (3x)
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Live-monitor API traffic
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
neo capture watch api.openai.com
|
|
269
|
+
# 14:23:01 POST 200 /v1/chat/completions (1230ms)
|
|
270
|
+
# 14:23:05 SSE_MSG 200 /v1/chat/completions (0ms) [sse]
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Storage
|
|
274
|
+
|
|
275
|
+
- **Per-domain cap**: 500 captures max per domain, oldest auto-cleaned
|
|
276
|
+
- **Body truncation**: Response bodies capped at 100KB
|
|
277
|
+
- **Location**: Chrome's IndexedDB (`neo-capture-v01` database)
|
|
278
|
+
- **Schemas**: Exportable as JSON files for persistence across devices
|
|
279
|
+
|
|
280
|
+
## Smart Filtering
|
|
281
|
+
|
|
282
|
+
The interceptor ignores noise automatically:
|
|
283
|
+
- Static assets (images, fonts, CSS, JS bundles)
|
|
284
|
+
- Analytics/tracking (Google Analytics, Meta Pixel, Sentry, etc.)
|
|
285
|
+
- Browser internals (chrome-extension://, data:, blob:)
|
|
286
|
+
- **Rate limiting**: Max 3 captures per URL pattern per minute (prevents polling endpoint bloat)
|
|
287
|
+
|
|
288
|
+
## Security & Privacy
|
|
289
|
+
|
|
290
|
+
Neo runs entirely locally — no external servers, no telemetry, no data leaves your machine.
|
|
291
|
+
|
|
292
|
+
**What Neo captures:** Every fetch/XHR/WebSocket call your browser makes on every website. This is powerful but invasive by design.
|
|
293
|
+
|
|
294
|
+
**Auth header redaction (v1.1.0+):** Auth header values (Bearer tokens, CSRF tokens, cookies, session IDs) are redacted at capture time before storage. IndexedDB only stores header *names*, not values. When `--auto-headers` executes an API call, it fetches live auth headers from the browser in real-time via CDP — never replays stored credentials.
|
|
295
|
+
|
|
296
|
+
**What you should know:**
|
|
297
|
+
|
|
298
|
+
| Aspect | Detail |
|
|
299
|
+
|--------|--------|
|
|
300
|
+
| **Capture scope** | `<all_urls>` — Neo sees traffic on *every* website, including banking, email, medical portals |
|
|
301
|
+
| **Content script** | Runs in `MAIN` world (shares JS context with pages) to intercept fetch/XHR |
|
|
302
|
+
| **CDP port** | CLI requires Chrome on port 9222 — any local process can connect to this port |
|
|
303
|
+
| **Response bodies** | Stored in IndexedDB (truncated to 100KB) — may contain personal data from API responses |
|
|
304
|
+
| **Schema files** | Store only endpoint structure (paths, header names, response shapes) — no credentials or user data |
|
|
305
|
+
| **Export** | `neo capture export` redacts auth by default; `--include-auth` requires explicit opt-in |
|
|
306
|
+
|
|
307
|
+
**Recommendations:**
|
|
308
|
+
|
|
309
|
+
- Review captured domains periodically: `neo capture domains`
|
|
310
|
+
- Prune sensitive captures: `neo capture clear banksite.com`
|
|
311
|
+
- Don't install Neo on shared machines where others have local access
|
|
312
|
+
- The CDP port (9222) should not be exposed beyond localhost
|
|
313
|
+
|
|
314
|
+
Neo is a developer tool that trades privacy surface for capability. Use it knowingly.
|
|
315
|
+
|
|
316
|
+
## Tech Stack
|
|
317
|
+
|
|
318
|
+
- TypeScript, Vite (multi-entry build)
|
|
319
|
+
- Chrome Manifest V3
|
|
320
|
+
- Dexie.js (IndexedDB wrapper)
|
|
321
|
+
- Chrome DevTools Protocol for CLI ↔ browser communication
|
|
322
|
+
- No backend server, no external dependencies at runtime
|
|
323
|
+
|
|
324
|
+
## Roadmap
|
|
325
|
+
|
|
326
|
+
- [x] Extension: capture + store + command-driven workflow
|
|
327
|
+
- [x] CLI tools: unified `neo` CLI with subcommands
|
|
328
|
+
- [x] Storage management: per-domain caps, auto-cleanup, rate limiting
|
|
329
|
+
- [x] Schema: browser-side analysis, URL normalization, body structure extraction
|
|
330
|
+
- [x] Smart filtering: static assets, analytics, duplicate suppression
|
|
331
|
+
- [x] WebSocket capture (open/close/send/recv with throttling)
|
|
332
|
+
- [x] Capture replay: `neo replay <id>` re-executes captured calls
|
|
333
|
+
- [x] Import/export: cross-device capture migration
|
|
334
|
+
- [x] Smart API call: `neo api` with schema lookup + auto-auth
|
|
335
|
+
- [x] Flow analysis: `neo flows` discovers API call sequences
|
|
336
|
+
- [x] Dependency chains: `neo deps` finds response→request data flow
|
|
337
|
+
- [x] Schema versioning with diff detection and history
|
|
338
|
+
- [x] Diagnostics: `neo doctor` for setup verification
|
|
339
|
+
- [x] Pure function extraction + 73 unit tests + CI
|
|
340
|
+
- [x] Agent skill export: `neo export-skill` generates SKILL.md
|
|
341
|
+
- [x] Mock server: `neo mock` generates local HTTP server from schema
|
|
342
|
+
- [x] HAR 1.2 export format for Postman/Charles/devtools interop
|
|
343
|
+
- [x] OpenAPI 3.0 spec generation from captured schemas
|
|
344
|
+
- [x] Batch schema generation (`--all`)
|
|
345
|
+
- [x] Semantic endpoint labeling (`neo label`)
|
|
346
|
+
- [x] Multi-step workflow discovery and execution (`neo workflow`)
|
|
347
|
+
- [x] Session management: `neo connect`, `neo sessions`, `--session` flag
|
|
348
|
+
- [x] Electron support: `neo launch`, `neo connect --electron`
|
|
349
|
+
- [x] Tab management: `neo tab` list/switch targets
|
|
350
|
+
- [x] Script injection: `neo inject` with `--persist` and `--tab`
|
|
351
|
+
- [x] **v2 UI layer**: `snapshot`, `click`, `fill`, `type`, `press`, `hover`, `scroll`, `select`, `screenshot`, `get`, `wait`
|
|
352
|
+
- [ ] Dual-channel: Neo API-first → UI fallback (automatic)
|
|
353
|
+
|
|
354
|
+
## License
|
|
355
|
+
|
|
356
|
+
MIT
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var bo=Object.defineProperty;var go=(C,I,D)=>I in C?bo(C,I,{enumerable:!0,configurable:!0,writable:!0,value:D}):C[I]=D;var Pr=(C,I,D)=>go(C,typeof I!="symbol"?I+"":I,D);var wo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _o(C){return C&&C.__esModule&&Object.prototype.hasOwnProperty.call(C,"default")?C.default:C}var zt={exports:{}},xo=zt.exports,Er;function ko(){return Er||(Er=1,(function(C,I){((D,R)=>{C.exports=R()})(xo,function(){var D=function(e,t){return(D=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(n,r){n.__proto__=r}:function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])}))(e,t)},R=function(){return(R=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function ce(e,t,n){for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||((r=r||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var z=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:wo,$=Object.keys,V=Array.isArray;function oe(e,t){return typeof t=="object"&&$(t).forEach(function(n){e[n]=t[n]}),e}typeof Promise>"u"||z.Promise||(z.Promise=Promise);var me=Object.getPrototypeOf,Y={}.hasOwnProperty;function M(e,t){return Y.call(e,t)}function ee(e,t){typeof t=="function"&&(t=t(me(e))),(typeof Reflect>"u"?$:Reflect.ownKeys)(t).forEach(function(n){G(e,n,t[n])})}var le=Object.defineProperty;function G(e,t,n,r){le(e,t,oe(n&&M(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function Le(e){return{from:function(t){return e.prototype=Object.create(t.prototype),G(e.prototype,"constructor",e),{extend:ee.bind(null,e.prototype)}}}}var Ir=Object.getOwnPropertyDescriptor,Tr=[].slice;function bt(e,t,n){return Tr.call(e,t,n)}function Bn(e,t){return t(e)}function nt(e){if(!e)throw new Error("Assertion Failed")}function Nn(e){z.setImmediate?setImmediate(e):setTimeout(e,0)}function ve(e,t){if(typeof t=="string"&&M(e,t))return e[t];if(!t)return e;if(typeof t!="string"){for(var n=[],r=0,o=t.length;r<o;++r){var i=ve(e,t[r]);n.push(i)}return n}var a,u=t.indexOf(".");return u===-1||(a=e[t.substr(0,u)])==null?void 0:ve(a,t.substr(u+1))}function ae(e,t,n){if(e&&t!==void 0&&!("isFrozen"in Object&&Object.isFrozen(e)))if(typeof t!="string"&&"length"in t){nt(typeof n!="string"&&"length"in n);for(var r=0,o=t.length;r<o;++r)ae(e,t[r],n[r])}else{var i,a,u=t.indexOf(".");u!==-1?(i=t.substr(0,u),(u=t.substr(u+1))===""?n===void 0?V(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=n:ae(a=(a=e[i])&&M(e,i)?a:e[i]={},u,n)):n===void 0?V(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function Mn(e){var t,n={};for(t in e)M(e,t)&&(n[t]=e[t]);return n}var Dr=[].concat;function Fn(e){return Dr.apply([],e)}var ge="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(Fn([8,16,32,64].map(function(e){return["Int","Uint","Float"].map(function(t){return t+e+"Array"})}))).filter(function(e){return z[e]}),Ln=new Set(ge.map(function(e){return z[e]})),rt=null;function Ce(e){return rt=new WeakMap,e=(function t(n){if(!n||typeof n!="object")return n;var r=rt.get(n);if(r)return r;if(V(n)){r=[],rt.set(n,r);for(var o=0,i=n.length;o<i;++o)r.push(t(n[o]))}else if(Ln.has(n.constructor))r=n;else{var a,u=me(n);for(a in r=u===Object.prototype?{}:Object.create(u),rt.set(n,r),n)M(n,a)&&(r[a]=t(n[a]))}return r})(e),rt=null,e}var Br={}.toString;function Yt(e){return Br.call(e).slice(8,-1)}var Gt=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Nr=typeof Gt=="symbol"?function(e){var t;return e!=null&&(t=e[Gt])&&t.apply(e)}:function(){return null};function Ae(e,t){t=e.indexOf(t),0<=t&&e.splice(t,1)}var Ue={};function be(e){var t,n,r,o;if(arguments.length===1){if(V(e))return e.slice();if(this===Ue&&typeof e=="string")return[e];if(o=Nr(e))for(n=[];!(r=o.next()).done;)n.push(r.value);else{if(e==null)return[e];if(typeof(t=e.length)!="number")return[e];for(n=new Array(t);t--;)n[t]=e[t]}}else for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var Qt=typeof Symbol<"u"?function(e){return e[Symbol.toStringTag]==="AsyncFunction"}:function(){return!1},ge=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],ue=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(ge),Mr={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function Ve(e,t){this.name=e,this.message=t}function Un(e,t){return e+". Errors: "+Object.keys(t).map(function(n){return t[n].toString()}).filter(function(n,r,o){return o.indexOf(n)===r}).join(`
|
|
2
|
+
`)}function gt(e,t,n,r){this.failures=t,this.failedKeys=r,this.successCount=n,this.message=Un(e,t)}function We(e,t){this.name="BulkError",this.failures=Object.keys(t).map(function(n){return t[n]}),this.failuresByPos=t,this.message=Un(e,this.failures)}Le(Ve).from(Error).extend({toString:function(){return this.name+": "+this.message}}),Le(gt).from(Ve),Le(We).from(Ve);var Xt=ue.reduce(function(e,t){return e[t]=t+"Error",e},{}),Fr=Ve,q=ue.reduce(function(e,t){var n=t+"Error";function r(o,i){this.name=n,o?typeof o=="string"?(this.message="".concat(o).concat(i?`
|
|
3
|
+
`+i:""),this.inner=i||null):typeof o=="object"&&(this.message="".concat(o.name," ").concat(o.message),this.inner=o):(this.message=Mr[t]||n,this.inner=null)}return Le(r).from(Fr),e[t]=r,e},{}),Vn=(q.Syntax=SyntaxError,q.Type=TypeError,q.Range=RangeError,ge.reduce(function(e,t){return e[t+"Error"]=q[t],e},{}));ge=ue.reduce(function(e,t){return["Syntax","Type","Range"].indexOf(t)===-1&&(e[t+"Error"]=q[t]),e},{});function U(){}function ot(e){return e}function Lr(e,t){return e==null||e===ot?t:function(n){return t(e(n))}}function qe(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function Ur(e,t){return e===U?t:function(){var n=e.apply(this,arguments),r=(n!==void 0&&(arguments[0]=n),this.onsuccess),o=this.onerror,i=(this.onsuccess=null,this.onerror=null,t.apply(this,arguments));return r&&(this.onsuccess=this.onsuccess?qe(r,this.onsuccess):r),o&&(this.onerror=this.onerror?qe(o,this.onerror):o),i!==void 0?i:n}}function Vr(e,t){return e===U?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?qe(n,this.onsuccess):n),r&&(this.onerror=this.onerror?qe(r,this.onerror):r)}}function Wr(e,t){return e===U?t:function(o){var r=e.apply(this,arguments),o=(oe(o,r),this.onsuccess),i=this.onerror,a=(this.onsuccess=null,this.onerror=null,t.apply(this,arguments));return o&&(this.onsuccess=this.onsuccess?qe(o,this.onsuccess):o),i&&(this.onerror=this.onerror?qe(i,this.onerror):i),r===void 0?a===void 0?void 0:a:oe(r,a)}}function zr(e,t){return e===U?t:function(){return t.apply(this,arguments)!==!1&&e.apply(this,arguments)}}function Ht(e,t){return e===U?t:function(){var n=e.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,o=arguments.length,i=new Array(o);o--;)i[o]=arguments[o];return n.then(function(){return t.apply(r,i)})}return t.apply(this,arguments)}}ge.ModifyError=gt,ge.DexieError=Ve,ge.BulkError=We;var de=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Wn(e){de=e}var it={},zn=100,at=typeof Promise>"u"?[]:(ue=Promise.resolve(),typeof crypto<"u"&&crypto.subtle?[at=crypto.subtle.digest("SHA-512",new Uint8Array([0])),me(at),ue]:[ue,me(ue),ue]),ue=at[0],Je=at[1],Je=Je&&Je.then,je=ue&&ue.constructor,Jt=!!at[2],ut=function(e,t){st.push([e,t]),wt&&(queueMicrotask(Yr),wt=!1)},Zt=!0,wt=!0,Re=[],_t=[],en=ot,xe={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:U,pgp:!1,env:{},finalize:U},A=xe,st=[],Ie=0,xt=[];function P(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=A;if(typeof e!="function"){if(e!==it)throw new TypeError("Not a function");this._state=arguments[1],this._value=arguments[2],this._state===!1&&nn(this,this._value)}else this._state=null,this._value=null,++t.ref,(function n(r,o){try{o(function(i){if(r._state===null){if(i===r)throw new TypeError("A promise cannot be resolved with itself.");var a=r._lib&&ze();i&&typeof i.then=="function"?n(r,function(u,l){i instanceof P?i._then(u,l):i.then(u,l)}):(r._state=!0,r._value=i,Yn(r)),a&&$e()}},nn.bind(null,r))}catch(i){nn(r,i)}})(this,e)}var tn={get:function(){var e=A,t=Et;function n(r,o){var i=this,a=!e.global&&(e!==A||t!==Et),u=a&&!Oe(),l=new P(function(m,f){rn(i,new $n(Qn(r,e,a,u),Qn(o,e,a,u),m,f,e))});return this._consoleTask&&(l._consoleTask=this._consoleTask),l}return n.prototype=it,n},set:function(e){G(this,"then",e&&e.prototype===it?tn:{get:function(){return e},set:tn.set})}};function $n(e,t,n,r,o){this.onFulfilled=typeof e=="function"?e:null,this.onRejected=typeof t=="function"?t:null,this.resolve=n,this.reject=r,this.psd=o}function nn(e,t){var n,r;_t.push(t),e._state===null&&(n=e._lib&&ze(),t=en(t),e._state=!1,e._value=t,r=e,Re.some(function(o){return o._value===r._value})||Re.push(r),Yn(e),n)&&$e()}function Yn(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)rn(e,t[n]);var o=e._PSD;--o.ref||o.finalize(),Ie===0&&(++Ie,ut(function(){--Ie==0&&on()},[]))}function rn(e,t){if(e._state===null)e._listeners.push(t);else{var n=e._state?t.onFulfilled:t.onRejected;if(n===null)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++Ie,ut($r,[n,e,t])}}function $r(e,t,n){try{var r,o=t._value;!t._state&&_t.length&&(_t=[]),r=de&&t._consoleTask?t._consoleTask.run(function(){return e(o)}):e(o),t._state||_t.indexOf(o)!==-1||(i=>{for(var a=Re.length;a;)if(Re[--a]._value===i._value)return Re.splice(a,1)})(t),n.resolve(r)}catch(i){n.reject(i)}finally{--Ie==0&&on(),--n.psd.ref||n.psd.finalize()}}function Yr(){Te(xe,function(){ze()&&$e()})}function ze(){var e=Zt;return wt=Zt=!1,e}function $e(){var e,t,n;do for(;0<st.length;)for(e=st,st=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}while(0<st.length);wt=Zt=!0}function on(){for(var e=Re,t=(Re=[],e.forEach(function(r){r._PSD.onunhandled.call(null,r._value,r)}),xt.slice(0)),n=t.length;n;)t[--n]()}function kt(e){return new P(it,!1,e)}function Q(e,t){var n=A;return function(){var r=ze(),o=A;try{return Pe(n,!0),e.apply(this,arguments)}catch(i){t&&t(i)}finally{Pe(o,!1),r&&$e()}}}ee(P.prototype,{then:tn,_then:function(e,t){rn(this,new $n(null,null,e,t,A))},catch:function(e){var t,n;return arguments.length===1?this.then(null,e):(t=e,n=arguments[1],typeof t=="function"?this.then(null,function(r){return(r instanceof t?n:kt)(r)}):this.then(null,function(r){return(r&&r.name===t?n:kt)(r)}))},finally:function(e){return this.then(function(t){return P.resolve(e()).then(function(){return t})},function(t){return P.resolve(e()).then(function(){return kt(t)})})},timeout:function(e,t){var n=this;return e<1/0?new P(function(r,o){var i=setTimeout(function(){return o(new q.Timeout(t))},e);n.then(r,o).finally(clearTimeout.bind(null,i))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&G(P.prototype,Symbol.toStringTag,"Dexie.Promise"),xe.env=Gn(),ee(P,{all:function(){var e=be.apply(null,arguments).map(St);return new P(function(t,n){e.length===0&&t([]);var r=e.length;e.forEach(function(o,i){return P.resolve(o).then(function(a){e[i]=a,--r||t(e)},n)})})},resolve:function(e){return e instanceof P?e:e&&typeof e.then=="function"?new P(function(t,n){e.then(t,n)}):new P(it,!0,e)},reject:kt,race:function(){var e=be.apply(null,arguments).map(St);return new P(function(t,n){e.map(function(r){return P.resolve(r).then(t,n)})})},PSD:{get:function(){return A},set:function(e){return A=e}},totalEchoes:{get:function(){return Et}},newPSD:ke,usePSD:Te,scheduler:{get:function(){return ut},set:function(e){ut=e}},rejectionMapper:{get:function(){return en},set:function(e){en=e}},follow:function(e,t){return new P(function(n,r){return ke(function(o,i){var a=A;a.unhandleds=[],a.onunhandled=i,a.finalize=qe(function(){var u,l=this;u=function(){l.unhandleds.length===0?o():i(l.unhandleds[0])},xt.push(function m(){u(),xt.splice(xt.indexOf(m),1)}),++Ie,ut(function(){--Ie==0&&on()},[])},a.finalize),e()},t,n,r)})}}),je&&(je.allSettled&&G(P,"allSettled",function(){var e=be.apply(null,arguments).map(St);return new P(function(t){e.length===0&&t([]);var n=e.length,r=new Array(n);e.forEach(function(o,i){return P.resolve(o).then(function(a){return r[i]={status:"fulfilled",value:a}},function(a){return r[i]={status:"rejected",reason:a}}).then(function(){return--n||t(r)})})})}),je.any&&typeof AggregateError<"u"&&G(P,"any",function(){var e=be.apply(null,arguments).map(St);return new P(function(t,n){e.length===0&&n(new AggregateError([]));var r=e.length,o=new Array(r);e.forEach(function(i,a){return P.resolve(i).then(function(u){return t(u)},function(u){o[a]=u,--r||n(new AggregateError(o))})})})}),je.withResolvers)&&(P.withResolvers=je.withResolvers);var te={awaits:0,echoes:0,id:0},Gr=0,Ot=[],Pt=0,Et=0,Qr=0;function ke(e,a,n,r){var o=A,i=Object.create(o),a=(i.parent=o,i.ref=0,i.global=!1,i.id=++Qr,xe.env,i.env=Jt?{Promise:P,PromiseProp:{value:P,configurable:!0,writable:!0},all:P.all,race:P.race,allSettled:P.allSettled,any:P.any,resolve:P.resolve,reject:P.reject}:{},a&&oe(i,a),++o.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()},Te(i,e,n,r));return i.ref===0&&i.finalize(),a}function Ye(){return te.id||(te.id=++Gr),++te.awaits,te.echoes+=zn,te.id}function Oe(){return!!te.awaits&&(--te.awaits==0&&(te.id=0),te.echoes=te.awaits*zn,!0)}function St(e){return te.echoes&&e&&e.constructor===je?(Ye(),e.then(function(t){return Oe(),t},function(t){return Oe(),J(t)})):e}function Xr(){var e=Ot[Ot.length-1];Ot.pop(),Pe(e,!1)}function Pe(e,t){var n,r,o=A;(t?!te.echoes||Pt++&&e===A:!Pt||--Pt&&e===A)||queueMicrotask(t?(function(i){++Et,te.echoes&&--te.echoes!=0||(te.echoes=te.awaits=te.id=0),Ot.push(A),Pe(i,!0)}).bind(null,e):Xr),e!==A&&(A=e,o===xe&&(xe.env=Gn()),Jt)&&(n=xe.env.Promise,r=e.env,o.global||e.global)&&(Object.defineProperty(z,"Promise",r.PromiseProp),n.all=r.all,n.race=r.race,n.resolve=r.resolve,n.reject=r.reject,r.allSettled&&(n.allSettled=r.allSettled),r.any)&&(n.any=r.any)}function Gn(){var e=z.Promise;return Jt?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(z,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function Te(e,t,n,r,o){var i=A;try{return Pe(e,!0),t(n,r,o)}finally{Pe(i,!1)}}function Qn(e,t,n,r){return typeof e!="function"?e:function(){var o=A;n&&Ye(),Pe(t,!0);try{return e.apply(this,arguments)}finally{Pe(o,!1),r&&queueMicrotask(Oe)}}}function an(e){Promise===je&&te.echoes===0?Pt===0?e():enqueueNativeMicroTask(e):setTimeout(e,0)}(""+Je).indexOf("[native code]")===-1&&(Ye=Oe=U);var J=P.reject,De="",we="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Xn="String expected.",Ge=[],Kt="__dbnames",un="readonly",sn="readwrite";function Be(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var Hn={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Ct(e){return typeof e!="string"||/\./.test(e)?function(t){return t}:function(t){return t[e]===void 0&&e in t&&delete(t=Ce(t))[e],t}}function Jn(){throw q.Type("Entity instances must never be new:ed. Instances are generated by the framework bypassing the constructor.")}function B(e,t){try{var n=Zn(e),r=Zn(t);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t<e?1:e<t?-1:0;case"binary":for(var o=er(e),i=er(t),a=o.length,u=i.length,l=a<u?a:u,m=0;m<l;++m)if(o[m]!==i[m])return o[m]<i[m]?-1:1;return a===u?0:a<u?-1:1;case"Array":for(var f=e,s=t,d=f.length,p=s.length,h=d<p?d:p,c=0;c<h;++c){var v=B(f[c],s[c]);if(v!==0)return v}return d===p?0:d<p?-1:1}}catch{}return NaN}function Zn(e){var t=typeof e;return t=="object"&&(ArrayBuffer.isView(e)||(t=Yt(e))==="ArrayBuffer")?"binary":t}function er(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}function At(e,t,n){var r=e.schema.yProps;return r?(t&&0<n.numFailures&&(t=t.filter(function(o,i){return!n.failures[i]})),Promise.all(r.map(function(o){return o=o.updatesTable,t?e.db.table(o).where("k").anyOf(t).delete():e.db.table(o).clear()})).then(function(){return n})):n}tr.prototype.execute=function(e){var t=this["@@propmod"];if(t.add!==void 0){var n=t.add;if(V(n))return ce(ce([],V(e)?e:[],!0),n).sort();if(typeof n=="number")return(Number(e)||0)+n;if(typeof n=="bigint")try{return BigInt(e)+n}catch{return BigInt(0)+n}throw new TypeError("Invalid term ".concat(n))}if(t.remove!==void 0){var r=t.remove;if(V(r))return V(e)?e.filter(function(o){return!r.includes(o)}).sort():[];if(typeof r=="number")return Number(e)-r;if(typeof r=="bigint")try{return BigInt(e)-r}catch{return BigInt(0)-r}throw new TypeError("Invalid subtrahend ".concat(r))}return n=(n=t.replacePrefix)==null?void 0:n[0],n&&typeof e=="string"&&e.startsWith(n)?t.replacePrefix[1]+e.substring(n.length):e};var ct=tr;function tr(e){this["@@propmod"]=e}function nr(e,t){for(var n=$(t),r=n.length,o=!1,i=0;i<r;++i){var a=n[i],u=t[a],l=ve(e,a);u instanceof ct?(ae(e,a,u.execute(l)),o=!0):l!==u&&(ae(e,a,u),o=!0)}return o}W.prototype._trans=function(e,t,n){var r=this._tx||A.trans,o=this.name,i=de&&typeof console<"u"&&console.createTask&&console.createTask("Dexie: ".concat(e==="readonly"?"read":"write"," ").concat(this.name));function a(m,f,s){if(s.schema[o])return t(s.idbtrans,s);throw new q.NotFound("Table "+o+" not part of transaction")}var u=ze();try{var l=r&&r.db._novip===this.db._novip?r===A.trans?r._promise(e,a,n):ke(function(){return r._promise(e,a,n)},{trans:r,transless:A.transless||A}):(function m(f,s,d,p){if(f.idbdb&&(f._state.openComplete||A.letThrough||f._vip)){var h=f._createTransaction(s,d,f._dbSchema);try{h.create(),f._state.PR1398_maxLoop=3}catch(c){return c.name===Xt.InvalidState&&f.isOpen()&&0<--f._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),f.close({disableAutoOpen:!1}),f.open().then(function(){return m(f,s,d,p)})):J(c)}return h._promise(s,function(c,v){return ke(function(){return A.trans=h,p(c,v,h)})}).then(function(c){if(s==="readwrite")try{h.idbtrans.commit()}catch{}return s==="readonly"?c:h._completion.then(function(){return c})})}if(f._state.openComplete)return J(new q.DatabaseClosed(f._state.dbOpenError));if(!f._state.isBeingOpened){if(!f._state.autoOpen)return J(new q.DatabaseClosed);f.open().catch(U)}return f._state.dbReadyPromise.then(function(){return m(f,s,d,p)})})(this.db,e,[this.name],a);return i&&(l._consoleTask=i,l=l.catch(function(m){return console.trace(m),J(m)})),l}finally{u&&$e()}},W.prototype.get=function(e,t){var n=this;return e&&e.constructor===Object?this.where(e).first(t):e==null?J(new q.Type("Invalid argument to Table.get()")):this._trans("readonly",function(r){return n.core.get({trans:r,key:e}).then(function(o){return n.hook.reading.fire(o)})}).then(t)},W.prototype.where=function(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(V(e))return new this.db.WhereClause(this,"[".concat(e.join("+"),"]"));var t=$(e);if(t.length===1)return this.where(t[0]).equals(e[t[0]]);var n=this.schema.indexes.concat(this.schema.primKey).filter(function(u){if(u.compound&&t.every(function(m){return 0<=u.keyPath.indexOf(m)})){for(var l=0;l<t.length;++l)if(t.indexOf(u.keyPath[l])===-1)return!1;return!0}return!1}).sort(function(u,l){return u.keyPath.length-l.keyPath.length})[0];if(n&&this.db._maxKey!==De)return a=n.keyPath.slice(0,t.length),this.where(a).equals(a.map(function(u){return e[u]}));!n&&de&&console.warn("The query ".concat(JSON.stringify(e)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(t.join("+"),"]"));var r=this.schema.idxByName;function o(u,l){return B(u,l)===0}var a=t.reduce(function(f,l){var m=f[0],f=f[1],s=r[l],d=e[l];return[m||s,m||!s?Be(f,s&&s.multi?function(p){return p=ve(p,l),V(p)&&p.some(function(h){return o(d,h)})}:function(p){return o(d,ve(p,l))}):f]},[null,null]),i=a[0],a=a[1];return i?this.where(i.name).equals(e[i.keyPath]).filter(a):n?this.filter(a):this.where(t).equals("")},W.prototype.filter=function(e){return this.toCollection().and(e)},W.prototype.count=function(e){return this.toCollection().count(e)},W.prototype.offset=function(e){return this.toCollection().offset(e)},W.prototype.limit=function(e){return this.toCollection().limit(e)},W.prototype.each=function(e){return this.toCollection().each(e)},W.prototype.toArray=function(e){return this.toCollection().toArray(e)},W.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},W.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,V(e)?"[".concat(e.join("+"),"]"):e))},W.prototype.reverse=function(){return this.toCollection().reverse()},W.prototype.mapToClass=function(e){for(var t=this.db,n=this.name,r=((this.schema.mappedClass=e).prototype instanceof Jn&&(e=(a=>{var u=f,l=a;if(typeof l!="function"&&l!==null)throw new TypeError("Class extends value "+String(l)+" is not a constructor or null");function m(){this.constructor=u}function f(){return a!==null&&a.apply(this,arguments)||this}return D(u,l),u.prototype=l===null?Object.create(l):(m.prototype=l.prototype,new m),Object.defineProperty(f.prototype,"db",{get:function(){return t},enumerable:!1,configurable:!0}),f.prototype.table=function(){return n},f})(e)),new Set),o=e.prototype;o;o=me(o))Object.getOwnPropertyNames(o).forEach(function(a){return r.add(a)});function i(a){if(!a)return a;var u,l=Object.create(e.prototype);for(u in a)if(!r.has(u))try{l[u]=a[u]}catch{}return l}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=i,this.hook("reading",i),e},W.prototype.defineClass=function(){return this.mapToClass(function(e){oe(this,e)})},W.prototype.add=function(e,t){var n=this,r=this.schema.primKey,o=r.auto,i=r.keyPath,a=e;return i&&o&&(a=Ct(i)(e)),this._trans("readwrite",function(u){return n.core.mutate({trans:u,type:"add",keys:t!=null?[t]:null,values:[a]})}).then(function(u){return u.numFailures?P.reject(u.failures[0]):u.lastResult}).then(function(u){if(i)try{ae(e,i,u)}catch{}return u})},W.prototype.upsert=function(e,t){var n=this,r=this.schema.primKey.keyPath;return this._trans("readwrite",function(o){return n.core.get({trans:o,key:e}).then(function(i){var a=i??{};return nr(a,t),r&&ae(a,r,e),n.core.mutate({trans:o,type:"put",values:[a],keys:[e],upsert:!0,updates:{keys:[e],changeSpecs:[t]}}).then(function(u){return u.numFailures?P.reject(u.failures[0]):!!i})})})},W.prototype.update=function(e,t){return typeof e!="object"||V(e)?this.where(":id").equals(e).modify(t):(e=ve(e,this.schema.primKey.keyPath))===void 0?J(new q.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t)},W.prototype.put=function(e,t){var n=this,r=this.schema.primKey,o=r.auto,i=r.keyPath,a=e;return i&&o&&(a=Ct(i)(e)),this._trans("readwrite",function(u){return n.core.mutate({trans:u,type:"put",values:[a],keys:t!=null?[t]:null})}).then(function(u){return u.numFailures?P.reject(u.failures[0]):u.lastResult}).then(function(u){if(i)try{ae(e,i,u)}catch{}return u})},W.prototype.delete=function(e){var t=this;return this._trans("readwrite",function(n){return t.core.mutate({trans:n,type:"delete",keys:[e]}).then(function(r){return At(t,[e],r)}).then(function(r){return r.numFailures?P.reject(r.failures[0]):void 0})})},W.prototype.clear=function(){var e=this;return this._trans("readwrite",function(t){return e.core.mutate({trans:t,type:"deleteRange",range:Hn}).then(function(n){return At(e,null,n)})}).then(function(t){return t.numFailures?P.reject(t.failures[0]):void 0})},W.prototype.bulkGet=function(e){var t=this;return this._trans("readonly",function(n){return t.core.getMany({keys:e,trans:n}).then(function(r){return r.map(function(o){return t.hook.reading.fire(o)})})})},W.prototype.bulkAdd=function(e,t,n){var r=this,o=Array.isArray(t)?t:void 0,i=(n=n||(o?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(a){var u=r.schema.primKey,m=u.auto,u=u.keyPath;if(u&&o)throw new q.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new q.InvalidArgument("Arguments objects and keys must have the same length");var l=e.length,m=u&&m?e.map(Ct(u)):e;return r.core.mutate({trans:a,type:"add",keys:o,values:m,wantResults:i}).then(function(f){var s=f.numFailures,d=f.failures;if(s===0)return i?f.results:f.lastResult;throw new We("".concat(r.name,".bulkAdd(): ").concat(s," of ").concat(l," operations failed"),d)})})},W.prototype.bulkPut=function(e,t,n){var r=this,o=Array.isArray(t)?t:void 0,i=(n=n||(o?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(a){var u=r.schema.primKey,m=u.auto,u=u.keyPath;if(u&&o)throw new q.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new q.InvalidArgument("Arguments objects and keys must have the same length");var l=e.length,m=u&&m?e.map(Ct(u)):e;return r.core.mutate({trans:a,type:"put",keys:o,values:m,wantResults:i}).then(function(f){var s=f.numFailures,d=f.failures;if(s===0)return i?f.results:f.lastResult;throw new We("".concat(r.name,".bulkPut(): ").concat(s," of ").concat(l," operations failed"),d)})})},W.prototype.bulkUpdate=function(e){var t=this,n=this.core,r=e.map(function(a){return a.key}),o=e.map(function(a){return a.changes}),i=[];return this._trans("readwrite",function(a){return n.getMany({trans:a,keys:r,cache:"clone"}).then(function(u){var l=[],m=[],f=(e.forEach(function(s,d){var p=s.key,h=s.changes,c=u[d];if(c){for(var v=0,b=Object.keys(h);v<b.length;v++){var y=b[v],g=h[y];if(y===t.schema.primKey.keyPath){if(B(g,p)!==0)throw new q.Constraint("Cannot update primary key in bulkUpdate()")}else ae(c,y,g)}i.push(d),l.push(p),m.push(c)}}),l.length);return n.mutate({trans:a,type:"put",keys:l,values:m,updates:{keys:r,changeSpecs:o}}).then(function(s){var d=s.numFailures,p=s.failures;if(d===0)return f;for(var h=0,c=Object.keys(p);h<c.length;h++){var v,b=c[h],y=i[Number(b)];y!=null&&(v=p[b],delete p[b],p[y]=v)}throw new We("".concat(t.name,".bulkUpdate(): ").concat(d," of ").concat(f," operations failed"),p)})})})},W.prototype.bulkDelete=function(e){var t=this,n=e.length;return this._trans("readwrite",function(r){return t.core.mutate({trans:r,type:"delete",keys:e}).then(function(o){return At(t,e,o)})}).then(function(r){var o=r.numFailures,i=r.failures;if(o===0)return r.lastResult;throw new We("".concat(t.name,".bulkDelete(): ").concat(o," of ").concat(n," operations failed"),i)})};var rr=W;function W(){}function lt(e){function t(a,u){if(u){for(var l=arguments.length,m=new Array(l-1);--l;)m[l-1]=arguments[l];return n[a].subscribe.apply(null,m),e}if(typeof a=="string")return n[a]}var n={};t.addEventType=i;for(var r=1,o=arguments.length;r<o;++r)i(arguments[r]);return t;function i(a,u,l){var m,f;if(typeof a!="object")return u=u||zr,f={subscribers:[],fire:l=l||U,subscribe:function(s){f.subscribers.indexOf(s)===-1&&(f.subscribers.push(s),f.fire=u(f.fire,s))},unsubscribe:function(s){f.subscribers=f.subscribers.filter(function(d){return d!==s}),f.fire=f.subscribers.reduce(u,l)}},n[a]=t[a]=f;$(m=a).forEach(function(s){var d=m[s];if(V(d))i(s,m[s][0],m[s][1]);else{if(d!=="asap")throw new q.InvalidArgument("Invalid event config");var p=i(s,ot,function(){for(var h=arguments.length,c=new Array(h);h--;)c[h]=arguments[h];p.subscribers.forEach(function(v){Nn(function(){v.apply(null,c)})})})}})}}function ft(e,t){return Le(t).from({prototype:e}),t}function Qe(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function cn(e,t){e.filter=Be(e.filter,t)}function ln(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return Be(r(),t())}:t,e.justLimit=n&&!r}function qt(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(n)return n;throw new q.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed")}function or(e,t,n){var r=qt(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:e.dir==="prev",unique:!!e.unique,query:{index:r,range:e.range}})}function jt(e,t,n,r){var o,i,a=e.replayFilter?Be(e.filter,e.replayFilter()):e.filter;return e.or?(o={},i=function(u,l,m){var f,s;a&&!a(l,m,function(d){return l.stop(d)},function(d){return l.fail(d)})||((s=""+(f=l.primaryKey))=="[object ArrayBuffer]"&&(s=""+new Uint8Array(f)),M(o,s))||(o[s]=!0,t(u,l,m))},Promise.all([e.or._iterate(i,n),ir(or(e,r,n),e.algorithm,i,!e.keysOnly&&e.valueMapper)])):ir(or(e,r,n),Be(e.algorithm,a),t,!e.keysOnly&&e.valueMapper)}function ir(e,t,n,r){var o=Q(r?function(i,a,u){return n(r(i),a,u)}:n);return e.then(function(i){if(i)return i.start(function(){var a=function(){return i.continue()};t&&!t(i,function(u){return a=u},function(u){i.stop(u),a=U},function(u){i.fail(u),a=U})||o(i.value,i,function(u){return a=u}),a()})})}F.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,J.bind(null,n.error)):n.table._trans("readonly",e).then(t)},F.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,J.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},F.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=Be(t.algorithm,e)},F.prototype._iterate=function(e,t){return jt(this._ctx,e,t,this._ctx.table.core)},F.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&oe(n,e),t._ctx=n,t},F.prototype.raw=function(){return this._ctx.valueMapper=null,this},F.prototype.each=function(e){var t=this._ctx;return this._read(function(n){return jt(t,e,n,t.table.core)})},F.prototype.count=function(e){var t=this;return this._read(function(n){var r,o=t._ctx,i=o.table.core;return Qe(o,!0)?i.count({trans:n,query:{index:qt(o,i.schema),range:o.range}}).then(function(a){return Math.min(a,o.limit)}):(r=0,jt(o,function(){return++r,!1},n,i).then(function(){return r}))}).then(e)},F.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),r=n[0],o=n.length-1;function i(l,m){return m?i(l[n[m]],m-1):l[r]}var a=this._ctx.dir==="next"?1:-1;function u(l,m){return B(i(l,o),i(m,o))*a}return this.toArray(function(l){return l.sort(u)}).then(t)},F.prototype.toArray=function(e){var t=this;return this._read(function(n){var r,o,i,a=t._ctx;return a.dir==="next"&&Qe(a,!0)&&0<a.limit?(r=a.valueMapper,o=qt(a,a.table.core.schema),a.table.core.query({trans:n,limit:a.limit,values:!0,query:{index:o,range:a.range}}).then(function(u){return u=u.result,r?u.map(r):u})):(i=[],jt(a,function(u){return i.push(u)},n,a.table.core).then(function(){return i}))},e)},F.prototype.offset=function(e){var t=this._ctx;return e<=0||(t.offset+=e,Qe(t)?ln(t,function(){var n=e;return function(r,o){return n===0||(n===1?--n:o(function(){r.advance(n),n=0}),!1)}}):ln(t,function(){var n=e;return function(){return--n<0}})),this},F.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),ln(this._ctx,function(){var t=e;return function(n,r,o){return--t<=0&&r(o),0<=t}},!0),this},F.prototype.until=function(e,t){return cn(this._ctx,function(n,r,o){return!e(n.value)||(r(o),t)}),this},F.prototype.first=function(e){return this.limit(1).toArray(function(t){return t[0]}).then(e)},F.prototype.last=function(e){return this.reverse().first(e)},F.prototype.filter=function(e){var t;return cn(this._ctx,function(n){return e(n.value)}),(t=this._ctx).isMatch=Be(t.isMatch,e),this},F.prototype.and=function(e){return this.filter(e)},F.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},F.prototype.reverse=function(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},F.prototype.desc=function(){return this.reverse()},F.prototype.eachKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(n,r){e(r.key,r)})},F.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},F.prototype.eachPrimaryKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(n,r){e(r.primaryKey,r)})},F.prototype.keys=function(e){var t=this._ctx,n=(t.keysOnly=!t.isMatch,[]);return this.each(function(r,o){n.push(o.key)}).then(function(){return n}).then(e)},F.prototype.primaryKeys=function(e){var t=this._ctx;if(t.dir==="next"&&Qe(t,!0)&&0<t.limit)return this._read(function(r){var o=qt(t,t.table.core.schema);return t.table.core.query({trans:r,values:!1,limit:t.limit,query:{index:o,range:t.range}})}).then(function(r){return r.result}).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(r,o){n.push(o.primaryKey)}).then(function(){return n}).then(e)},F.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},F.prototype.firstKey=function(e){return this.limit(1).keys(function(t){return t[0]}).then(e)},F.prototype.lastKey=function(e){return this.reverse().firstKey(e)},F.prototype.distinct=function(){var e,t=this._ctx,t=t.index&&t.table.schema.idxByName[t.index];return t&&t.multi&&(e={},cn(this._ctx,function(r){var r=r.primaryKey.toString(),o=M(e,r);return e[r]=!0,!o})),this},F.prototype.modify=function(e){var t=this,n=this._ctx;return this._write(function(r){function o(c,v){var b=v.failures;d+=c-v.numFailures;for(var y=0,g=$(b);y<g.length;y++){var w=g[y];s.push(b[w])}}var i=typeof e=="function"?e:function(c){return nr(c,e)},a=n.table.core,f=a.schema.primaryKey,u=f.outbound,l=f.extractKey,m=200,f=t.db._options.modifyChunkSize,s=(f&&(m=typeof f=="object"?f[a.name]||f["*"]||200:f),[]),d=0,p=[],h=e===ar;return t.clone().primaryKeys().then(function(c){function v(y){var g=Math.min(m,c.length-y),w=c.slice(y,y+g);return(h?Promise.resolve([]):a.getMany({trans:r,keys:w,cache:"immutable"})).then(function(k){var O=[],_=[],S=u?[]:null,E=h?w:[];if(!h)for(var x=0;x<g;++x){var K=k[x],N={value:Ce(K),primKey:c[y+x]};i.call(N,N.value,N)!==!1&&(N.value==null?E.push(c[y+x]):u||B(l(K),l(N.value))===0?(_.push(N.value),u&&S.push(c[y+x])):(E.push(c[y+x]),O.push(N.value)))}return Promise.resolve(0<O.length&&a.mutate({trans:r,type:"add",values:O}).then(function(L){for(var j in L.failures)E.splice(parseInt(j),1);o(O.length,L)})).then(function(){return(0<_.length||b&&typeof e=="object")&&a.mutate({trans:r,type:"put",keys:S,values:_,criteria:b,changeSpec:typeof e!="function"&&e,isAdditionalChunk:0<y}).then(function(L){return o(_.length,L)})}).then(function(){return(0<E.length||b&&h)&&a.mutate({trans:r,type:"delete",keys:E,criteria:b,isAdditionalChunk:0<y}).then(function(L){return At(n.table,E,L)}).then(function(L){return o(E.length,L)})}).then(function(){return c.length>y+g&&v(y+m)})})}var b=Qe(n)&&n.limit===1/0&&(typeof e!="function"||h)&&{index:n.index,range:n.range};return v(0).then(function(){if(0<s.length)throw new gt("Error modifying one or more objects",s,d,p);return c.length})})})},F.prototype.delete=function(){var e=this._ctx,t=e.range;return!Qe(e)||e.table.schema.yProps||!e.isPrimKey&&t.type!==3?this.modify(ar):this._write(function(n){var r=e.table.core.schema.primaryKey,o=t;return e.table.core.count({trans:n,query:{index:r,range:o}}).then(function(i){return e.table.core.mutate({trans:n,type:"deleteRange",range:o}).then(function(l){var u=l.failures,l=l.numFailures;if(l)throw new gt("Could not delete some values",Object.keys(u).map(function(m){return u[m]}),i-l);return i-l})})})};var Hr=F;function F(){}var ar=function(e,t){return t.value=null};function Jr(e,t){return e<t?-1:e===t?0:1}function Zr(e,t){return t<e?-1:e===t?0:1}function se(e,t,n){return e=e instanceof sr?new e.Collection(e):e,e._ctx.error=new(n||TypeError)(t),e}function Xe(e){return new e.Collection(e,function(){return ur("")}).limit(0)}function Rt(p,t,n,r){var o,i,a,u,l,m,f,s=n.length;if(!n.every(function(c){return typeof c=="string"}))return se(p,Xn);function d(c){o=c==="next"?function(b){return b.toUpperCase()}:function(b){return b.toLowerCase()},i=c==="next"?function(b){return b.toLowerCase()}:function(b){return b.toUpperCase()},a=c==="next"?Jr:Zr;var v=n.map(function(b){return{lower:i(b),upper:o(b)}}).sort(function(b,y){return a(b.lower,y.lower)});u=v.map(function(b){return b.upper}),l=v.map(function(b){return b.lower}),f=(m=c)==="next"?"":r}d("next");var p=new p.Collection(p,function(){return Ee(u[0],l[s-1]+r)}),h=(p._ondirectionchange=function(c){d(c)},0);return p._addAlgorithm(function(c,v,b){var y=c.key;if(typeof y=="string"){var g=i(y);if(t(g,l,h))return!0;for(var w=null,k=h;k<s;++k){var O=((_,S,E,x,K,N)=>{for(var L=Math.min(_.length,x.length),j=-1,T=0;T<L;++T){var X=S[T];if(X!==x[T])return K(_[T],E[T])<0?_.substr(0,T)+E[T]+E.substr(T+1):K(_[T],x[T])<0?_.substr(0,T)+x[T]+E.substr(T+1):0<=j?_.substr(0,j)+S[j]+E.substr(j+1):null;K(_[T],X)<0&&(j=T)}return L<x.length&&N==="next"?_+E.substr(_.length):L<_.length&&N==="prev"?_.substr(0,E.length):j<0?null:_.substr(0,j)+x[j]+E.substr(j+1)})(y,g,u[k],l[k],a,m);O===null&&w===null?h=k+1:(w===null||0<a(w,O))&&(w=O)}v(w!==null?function(){c.continue(w+f)}:b)}return!1}),p}function Ee(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function ur(e){return{type:1,lower:e,upper:e}}Object.defineProperty(ne.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),ne.prototype.between=function(e,t,n,r){n=n!==!1,r=r===!0;try{return 0<this._cmp(e,t)||this._cmp(e,t)===0&&(n||r)&&(!n||!r)?Xe(this):new this.Collection(this,function(){return Ee(e,t,!n,!r)})}catch{return se(this,we)}},ne.prototype.equals=function(e){return e==null?se(this,we):new this.Collection(this,function(){return ur(e)})},ne.prototype.above=function(e){return e==null?se(this,we):new this.Collection(this,function(){return Ee(e,void 0,!0)})},ne.prototype.aboveOrEqual=function(e){return e==null?se(this,we):new this.Collection(this,function(){return Ee(e,void 0,!1)})},ne.prototype.below=function(e){return e==null?se(this,we):new this.Collection(this,function(){return Ee(void 0,e,!1,!0)})},ne.prototype.belowOrEqual=function(e){return e==null?se(this,we):new this.Collection(this,function(){return Ee(void 0,e)})},ne.prototype.startsWith=function(e){return typeof e!="string"?se(this,Xn):this.between(e,e+De,!0,!0)},ne.prototype.startsWithIgnoreCase=function(e){return e===""?this.startsWith(e):Rt(this,function(t,n){return t.indexOf(n[0])===0},[e],De)},ne.prototype.equalsIgnoreCase=function(e){return Rt(this,function(t,n){return t===n[0]},[e],"")},ne.prototype.anyOfIgnoreCase=function(){var e=be.apply(Ue,arguments);return e.length===0?Xe(this):Rt(this,function(t,n){return n.indexOf(t)!==-1},e,"")},ne.prototype.startsWithAnyOfIgnoreCase=function(){var e=be.apply(Ue,arguments);return e.length===0?Xe(this):Rt(this,function(t,n){return n.some(function(r){return t.indexOf(r)===0})},e,De)},ne.prototype.anyOf=function(){var e,t,n=this,r=be.apply(Ue,arguments),o=this._cmp;try{r.sort(o)}catch{return se(this,we)}return r.length===0?Xe(this):((e=new this.Collection(this,function(){return Ee(r[0],r[r.length-1])}))._ondirectionchange=function(i){o=i==="next"?n._ascending:n._descending,r.sort(o)},t=0,e._addAlgorithm(function(i,a,u){for(var l=i.key;0<o(l,r[t]);)if(++t===r.length)return a(u),!1;return o(l,r[t])===0||(a(function(){i.continue(r[t])}),!1)}),e)},ne.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},ne.prototype.noneOf=function(){var e=be.apply(Ue,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return se(this,we)}var t=e.reduce(function(n,r){return n?n.concat([[n[n.length-1][1],r]]):[[-1/0,r]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},ne.prototype.inAnyRange=function(e,b){var n=this,r=this._cmp,o=this._ascending,i=this._descending,a=this._min,u=this._max;if(e.length===0)return Xe(this);if(!e.every(function(y){return y[0]!==void 0&&y[1]!==void 0&&o(y[0],y[1])<=0}))return se(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",q.InvalidArgument);var l=!b||b.includeLowers!==!1,m=b&&b.includeUppers===!0,f,s=o;function d(y,g){return s(y[0],g[0])}try{(f=e.reduce(function(y,g){for(var w=0,k=y.length;w<k;++w){var O=y[w];if(r(g[0],O[1])<0&&0<r(g[1],O[0])){O[0]=a(O[0],g[0]),O[1]=u(O[1],g[1]);break}}return w===k&&y.push(g),y},[])).sort(d)}catch{return se(this,we)}var p=0,h=m?function(y){return 0<o(y,f[p][1])}:function(y){return 0<=o(y,f[p][1])},c=l?function(y){return 0<i(y,f[p][0])}:function(y){return 0<=i(y,f[p][0])},v=h,b=new this.Collection(this,function(){return Ee(f[0][0],f[f.length-1][1],!l,!m)});return b._ondirectionchange=function(y){s=y==="next"?(v=h,o):(v=c,i),f.sort(d)},b._addAlgorithm(function(y,g,w){for(var k,O=y.key;v(O);)if(++p===f.length)return g(w),!1;return!h(k=O)&&!c(k)||(n._cmp(O,f[p][1])===0||n._cmp(O,f[p][0])===0||g(function(){s===o?y.continue(f[p][0]):y.continue(f[p][1])}),!1)}),b},ne.prototype.startsWithAnyOf=function(){var e=be.apply(Ue,arguments);return e.every(function(t){return typeof t=="string"})?e.length===0?Xe(this):this.inAnyRange(e.map(function(t){return[t,t+De]})):se(this,"startsWithAnyOf() only works with strings")};var sr=ne;function ne(){}function pe(e){return Q(function(t){return ht(t),e(t.target.error),!1})}function ht(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var dt="storagemutated",fn="x-storagemutated-1",Se=lt(null,dt),eo=(ye.prototype._lock=function(){return nt(!A.global),++this._reculock,this._reculock!==1||A.global||(A.lockOwnerFor=this),this},ye.prototype._unlock=function(){if(nt(!A.global),--this._reculock==0)for(A.global||(A.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{Te(e[1],e[0])}catch{}}return this},ye.prototype._locked=function(){return this._reculock&&A.lockOwnerFor!==this},ye.prototype.create=function(e){var t=this;if(this.mode){var n=this.db.idbdb,r=this.db._state.dbOpenError;if(nt(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new q.DatabaseClosed(r);case"MissingAPIError":throw new q.MissingAPI(r.message,r);default:throw new q.OpenFailed(r)}if(!this.active)throw new q.TransactionInactive;nt(this._completion._state===null),(e=this.idbtrans=e||(this.db.core||n).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=Q(function(o){ht(o),t._reject(e.error)}),e.onabort=Q(function(o){ht(o),t.active&&t._reject(new q.Abort(e.error)),t.active=!1,t.on("abort").fire(o)}),e.oncomplete=Q(function(){t.active=!1,t._resolve(),"mutatedParts"in e&&Se.storagemutated.fire(e.mutatedParts)})}return this},ye.prototype._promise=function(e,t,n){var r,o=this;return e==="readwrite"&&this.mode!=="readwrite"?J(new q.ReadOnly("Transaction is readonly")):this.active?this._locked()?new P(function(i,a){o._blockedFuncs.push([function(){o._promise(e,t,n).then(i,a)},A])}):n?ke(function(){var i=new P(function(a,u){o._lock();var l=t(a,u,o);l&&l.then&&l.then(a,u)});return i.finally(function(){return o._unlock()}),i._lib=!0,i}):((r=new P(function(i,a){var u=t(i,a,o);u&&u.then&&u.then(i,a)}))._lib=!0,r):J(new q.TransactionInactive)},ye.prototype._root=function(){return this.parent?this.parent._root():this},ye.prototype.waitFor=function(e){var t,n=this._root(),r=P.resolve(e),o=(n._waitingFor?n._waitingFor=n._waitingFor.then(function(){return r}):(n._waitingFor=r,n._waitingQueue=[],t=n.idbtrans.objectStore(n.storeNames[0]),(function i(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(t.get(-1/0).onsuccess=i)})()),n._waitingFor);return new P(function(i,a){r.then(function(u){return n._waitingQueue.push(Q(i.bind(null,u)))},function(u){return n._waitingQueue.push(Q(a.bind(null,u)))}).finally(function(){n._waitingFor===o&&(n._waitingFor=null)})})},ye.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new q.Abort))},ye.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(M(t,e))return t[e];var n=this.schema[e];if(n)return(n=new this.db.Table(e,n,this)).core=this.db.core.table(e),t[e]=n;throw new q.NotFound("Table "+e+" not part of transaction")},ye);function ye(){}function hn(e,t,n,r,o,i,a,u){return{name:e,keyPath:t,unique:n,multi:r,auto:o,compound:i,src:(n&&!a?"&":"")+(r?"*":"")+(o?"++":"")+cr(t),type:u}}function cr(e){return typeof e=="string"?e:e?"["+[].join.call(e,"+")+"]":""}function dn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(r=function(o){return[o.name,o]},n.reduce(function(o,i,a){return i=r(i,a),i&&(o[i[0]]=i[1]),o},{}))};var r}var pt=function(e){try{return e.only([[]]),pt=function(){return[[]]},[[]]}catch{return pt=function(){return De},De}};function pn(e){return e==null?function(){}:typeof e=="string"?(t=e).split(".").length===1?function(n){return n[t]}:function(n){return ve(n,t)}:function(n){return ve(n,e)};var t}function lr(e){return[].slice.call(e)}var to=0;function yt(e){return e==null?":id":typeof e=="string"?e:"[".concat(e.join("+"),"]")}function no(e,t,l){function r(h){if(h.type===3)return null;if(h.type===4)throw new Error("Cannot convert never type to IDBKeyRange");var s=h.lower,d=h.upper,p=h.lowerOpen,h=h.upperOpen;return s===void 0?d===void 0?null:t.upperBound(d,!!h):d===void 0?t.lowerBound(s,!!p):t.bound(s,d,!!p,!!h)}function o(f){var s,d=f.name;return{name:d,schema:f,mutate:function(p){var h=p.trans,c=p.type,v=p.keys,b=p.values,y=p.range;return new Promise(function(g,w){g=Q(g);var k=h.objectStore(d),O=k.keyPath==null,_=c==="put"||c==="add";if(!_&&c!=="delete"&&c!=="deleteRange")throw new Error("Invalid operation type: "+c);var S,E=(v||b||{length:1}).length;if(v&&b&&v.length!==b.length)throw new Error("Given keys array must have same length as given values array.");if(E===0)return g({numFailures:0,failures:{},results:[],lastResult:void 0});function x(H){++L,ht(H)}var K=[],N=[],L=0;if(c==="deleteRange"){if(y.type===4)return g({numFailures:L,failures:N,results:[],lastResult:void 0});y.type===3?K.push(S=k.clear()):K.push(S=k.delete(r(y)))}else{var O=_?O?[b,v]:[b,null]:[v,null],j=O[0],T=O[1];if(_)for(var X=0;X<E;++X)K.push(S=T&&T[X]!==void 0?k[c](j[X],T[X]):k[c](j[X])),S.onerror=x;else for(X=0;X<E;++X)K.push(S=k[c](j[X])),S.onerror=x}function fe(H){H=H.target.result,K.forEach(function(Fe,jn){return Fe.error!=null&&(N[jn]=Fe.error)}),g({numFailures:L,failures:N,results:c==="delete"?v:K.map(function(Fe){return Fe.result}),lastResult:H})}S.onerror=function(H){x(H),fe(H)},S.onsuccess=fe})},getMany:function(p){var h=p.trans,c=p.keys;return new Promise(function(v,b){v=Q(v);for(var y,g=h.objectStore(d),w=c.length,k=new Array(w),O=0,_=0,S=function(K){K=K.target,k[K._pos]=K.result,++_===O&&v(k)},E=pe(b),x=0;x<w;++x)c[x]!=null&&((y=g.get(c[x]))._pos=x,y.onsuccess=S,y.onerror=E,++O);O===0&&v(k)})},get:function(p){var h=p.trans,c=p.key;return new Promise(function(v,b){v=Q(v);var y=h.objectStore(d).get(c);y.onsuccess=function(g){return v(g.target.result)},y.onerror=pe(b)})},query:(s=u,function(p){return new Promise(function(h,c){h=Q(h);var v,b,y,_=p.trans,g=p.values,w=p.limit,O=p.query,k=w===1/0?void 0:w,S=O.index,O=O.range,_=_.objectStore(d),_=S.isPrimaryKey?_:_.index(S.name),S=r(O);if(w===0)return h({result:[]});s?((O=g?_.getAll(S,k):_.getAllKeys(S,k)).onsuccess=function(E){return h({result:E.target.result})},O.onerror=pe(c)):(v=0,b=!g&&"openKeyCursor"in _?_.openKeyCursor(S):_.openCursor(S),y=[],b.onsuccess=function(E){var x=b.result;return!x||(y.push(g?x.value:x.primaryKey),++v===w)?h({result:y}):void x.continue()},b.onerror=pe(c))})}),openCursor:function(p){var h=p.trans,c=p.values,v=p.query,b=p.reverse,y=p.unique;return new Promise(function(g,w){g=Q(g);var _=v.index,k=v.range,O=h.objectStore(d),O=_.isPrimaryKey?O:O.index(_.name),_=b?y?"prevunique":"prev":y?"nextunique":"next",S=!c&&"openKeyCursor"in O?O.openKeyCursor(r(k),_):O.openCursor(r(k),_);S.onerror=pe(w),S.onsuccess=Q(function(E){var x,K,N,L,j=S.result;j?(j.___id=++to,j.done=!1,x=j.continue.bind(j),K=(K=j.continuePrimaryKey)&&K.bind(j),N=j.advance.bind(j),L=function(){throw new Error("Cursor not stopped")},j.trans=h,j.stop=j.continue=j.continuePrimaryKey=j.advance=function(){throw new Error("Cursor not started")},j.fail=Q(w),j.next=function(){var T=this,X=1;return this.start(function(){return X--?T.continue():T.stop()}).then(function(){return T})},j.start=function(T){function X(){if(S.result)try{T()}catch(H){j.fail(H)}else j.done=!0,j.start=function(){throw new Error("Cursor behind last entry")},j.stop()}var fe=new Promise(function(H,Fe){H=Q(H),S.onerror=pe(Fe),j.fail=Fe,j.stop=function(jn){j.stop=j.continue=j.continuePrimaryKey=j.advance=L,H(jn)}});return S.onsuccess=Q(function(H){S.onsuccess=X,X()}),j.continue=x,j.continuePrimaryKey=K,j.advance=N,X(),fe},g(j)):g(null)},w)})},count:function(p){var h=p.query,c=p.trans,v=h.index,b=h.range;return new Promise(function(y,g){var w=c.objectStore(d),w=v.isPrimaryKey?w:w.index(v.name),k=r(b),k=k?w.count(k):w.count();k.onsuccess=Q(function(O){return y(O.target.result)}),k.onerror=pe(g)})}}}i=l,a=lr((l=e).objectStoreNames);var i,l={schema:{name:l.name,tables:a.map(function(f){return i.objectStore(f)}).map(function(f){var s=f.keyPath,d=f.autoIncrement,h=V(s),p={},h={name:f.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:s==null,compound:h,keyPath:s,autoIncrement:d,unique:!0,extractKey:pn(s)},indexes:lr(f.indexNames).map(function(c){return f.index(c)}).map(function(y){var g=y.name,v=y.unique,b=y.multiEntry,y=y.keyPath,g={name:g,compound:V(y),keyPath:y,unique:v,multiEntry:b,extractKey:pn(y)};return p[yt(y)]=g}),getIndexByKeyPath:function(c){return p[yt(c)]}};return p[":id"]=h.primaryKey,s!=null&&(p[yt(s)]=h.primaryKey),h})},hasGetAll:0<a.length&&"getAll"in i.objectStore(a[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)},a=l.schema,u=l.hasGetAll,l=a.tables.map(o),m={};return l.forEach(function(f){return m[f.name]=f}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(f){if(m[f])return m[f];throw new Error("Table '".concat(f,"' not found"))},MIN_KEY:-1/0,MAX_KEY:pt(t),schema:a}}function ro(e,t,n,r){return n=n.IDBKeyRange,t=no(t,n,r),{dbcore:e.dbcore.reduce(function(o,i){return i=i.create,R(R({},o),i(o))},t)}}function It(e,t){var n=t.db,n=ro(e._middlewares,n,e._deps,t);e.core=n.dbcore,e.tables.forEach(function(r){var o=r.name;e.core.schema.tables.some(function(i){return i.name===o})&&(r.core=e.core.table(o),e[o]instanceof e.Table)&&(e[o].core=r.core)})}function Tt(e,t,n,r){n.forEach(function(o){var i=r[o];t.forEach(function(a){var u=(function l(m,f){return Ir(m,f)||(m=me(m))&&l(m,f)})(a,o);(!u||"value"in u&&u.value===void 0)&&(a===e.Transaction.prototype||a instanceof e.Transaction?G(a,o,{get:function(){return this.table(o)},set:function(l){le(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):a[o]=new e.Table(o,i))})})}function yn(e,t){t.forEach(function(n){for(var r in n)n[r]instanceof e.Table&&delete n[r]})}function oo(e,t){return e._cfg.version-t._cfg.version}function io(e,t,n,r){var o=e._dbSchema,i=(n.objectStoreNames.contains("$meta")&&!o.$meta&&(o.$meta=dn("$meta",hr("")[0],[]),e._storeNames.push("$meta")),e._createTransaction("readwrite",e._storeNames,o)),a=(i.create(n),i._completion.catch(r),i._reject.bind(i)),u=A.transless||A;ke(function(){if(A.trans=i,A.transless=u,t!==0)return It(e,n),m=t,((l=i).storeNames.includes("$meta")?l.table("$meta").get("version").then(function(f){return f??m}):P.resolve(m)).then(function(v){var s=e,d=v,p=i,h=n,c=[],v=s._versions,b=s._dbSchema=Bt(0,s.idbdb,h);return(v=v.filter(function(y){return y._cfg.version>=d})).length===0?P.resolve():(v.forEach(function(y){c.push(function(){var g,w,k,O=b,_=y._cfg.dbschema,S=(Nt(s,O,h),Nt(s,_,h),b=s._dbSchema=_,mn(O,_)),E=(S.add.forEach(function(x){vn(h,x[0],x[1].primKey,x[1].indexes)}),S.change.forEach(function(x){if(x.recreate)throw new q.Upgrade("Not yet support for changing primary key");var K=h.objectStore(x.name);x.add.forEach(function(N){return Dt(K,N)}),x.change.forEach(function(N){K.deleteIndex(N.name),Dt(K,N)}),x.del.forEach(function(N){return K.deleteIndex(N)})}),y._cfg.contentUpgrade);if(E&&y._cfg.version>d)return It(s,h),p._memoizedTables={},g=Mn(_),S.del.forEach(function(x){g[x]=O[x]}),yn(s,[s.Transaction.prototype]),Tt(s,[s.Transaction.prototype],$(g),g),p.schema=g,(w=Qt(E))&&Ye(),_=P.follow(function(){var x;(k=E(p))&&w&&(x=Oe.bind(null,null),k.then(x,x))}),k&&typeof k.then=="function"?P.resolve(k):_.then(function(){return k})}),c.push(function(g){var w,k,O=y._cfg.dbschema;w=O,k=g,[].slice.call(k.db.objectStoreNames).forEach(function(_){return w[_]==null&&k.db.deleteObjectStore(_)}),yn(s,[s.Transaction.prototype]),Tt(s,[s.Transaction.prototype],s._storeNames,s._dbSchema),p.schema=s._dbSchema}),c.push(function(g){s.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(s.idbdb.version/10)===y._cfg.version?(s.idbdb.deleteObjectStore("$meta"),delete s._dbSchema.$meta,s._storeNames=s._storeNames.filter(function(w){return w!=="$meta"})):g.objectStore("$meta").put(y._cfg.version,"version"))})}),(function y(){return c.length?P.resolve(c.shift()(p.idbtrans)).then(y):P.resolve()})().then(function(){fr(b,h)}))}).catch(a);var l,m;$(o).forEach(function(f){vn(n,f,o[f].primKey,o[f].indexes)}),It(e,n),P.follow(function(){return e.on.populate.fire(i)}).catch(a)})}function ao(e,t){fr(e._dbSchema,t),t.db.version%10!=0||t.objectStoreNames.contains("$meta")||t.db.createObjectStore("$meta").add(Math.ceil(t.db.version/10-1),"version");var n=Bt(0,e.idbdb,t);Nt(e,e._dbSchema,t);for(var r=0,o=mn(n,e._dbSchema).change;r<o.length;r++){var i=(a=>{if(a.change.length||a.recreate)return console.warn("Unable to patch indexes of table ".concat(a.name," because it has changes on the type of index or primary key.")),{value:void 0};var u=t.objectStore(a.name);a.add.forEach(function(l){de&&console.debug("Dexie upgrade patch: Creating missing index ".concat(a.name,".").concat(l.src)),Dt(u,l)})})(o[r]);if(typeof i=="object")return i.value}}function mn(e,t){var n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){var o=e[n],i=t[n];if(o){var a={name:n,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||o.primKey.auto!==i.primKey.auto)a.recreate=!0,r.change.push(a);else{var u=o.idxByName,l=i.idxByName,m=void 0;for(m in u)l[m]||a.del.push(m);for(m in l){var f=u[m],s=l[m];f?f.src!==s.src&&a.change.push(s):a.add.push(s)}(0<a.del.length||0<a.add.length||0<a.change.length)&&r.change.push(a)}}else r.add.push([n,i])}return r}function vn(e,t,n,r){var o=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});r.forEach(function(i){return Dt(o,i)})}function fr(e,t){$(e).forEach(function(n){t.db.objectStoreNames.contains(n)||(de&&console.debug("Dexie: Creating missing table",n),vn(t,n,e[n].primKey,e[n].indexes))})}function Dt(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function Bt(e,t,n){var r={};return bt(t.objectStoreNames,0).forEach(function(o){for(var i=n.objectStore(o),a=hn(cr(m=i.keyPath),m||"",!0,!1,!!i.autoIncrement,m&&typeof m!="string",!0),u=[],l=0;l<i.indexNames.length;++l){var f=i.index(i.indexNames[l]),m=f.keyPath,f=hn(f.name,m,!!f.unique,!!f.multiEntry,!1,m&&typeof m!="string",!1);u.push(f)}r[o]=dn(o,a,u)}),r}function Nt(e,t,n){for(var r=n.db.objectStoreNames,o=0;o<r.length;++o){var i=r[o],a=n.objectStore(i);e._hasGetAll="getAll"in a;for(var u=0;u<a.indexNames.length;++u){var l,m=a.indexNames[u],f=a.index(m).keyPath,f=typeof f=="string"?f:"["+bt(f).join("+")+"]";t[i]&&(l=t[i].idxByName[f])&&(l.name=m,delete t[i].idxByName[f],t[i].idxByName[m]=l)}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&z.WorkerGlobalScope&&z instanceof z.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}function hr(e){return e.split(",").map(function(t,n){var o=t.split(":"),r=(r=o[1])==null?void 0:r.trim(),o=(t=o[0].trim()).replace(/([&*]|\+\+)/g,""),i=/^\[/.test(o)?o.match(/^\[(.*)\]$/)[1].split("+"):o;return hn(o,i||null,/\&/.test(t),/\*/.test(t),/\+\+/.test(t),V(i),n===0,r)})}He.prototype._createTableSchema=dn,He.prototype._parseIndexSyntax=hr,He.prototype._parseStoresSpec=function(e,t){var n=this;$(e).forEach(function(r){if(e[r]!==null){var o=n._parseIndexSyntax(e[r]),i=o.shift();if(!i)throw new q.Schema("Invalid schema for table "+r+": "+e[r]);if(i.unique=!0,i.multi)throw new q.Schema("Primary key cannot be multiEntry*");o.forEach(function(a){if(a.auto)throw new q.Schema("Only primary key can be marked as autoIncrement (++)");if(!a.keyPath)throw new q.Schema("Index must have a name and cannot be an empty string")}),i=n._createTableSchema(r,i,o),t[r]=i}})},He.prototype.stores=function(n){var t=this.db,n=(this._cfg.storesSource=this._cfg.storesSource?oe(this._cfg.storesSource,n):n,t._versions),r={},o={};return n.forEach(function(i){oe(r,i._cfg.storesSource),o=i._cfg.dbschema={},i._parseStoresSpec(r,o)}),t._dbSchema=o,yn(t,[t._allTables,t,t.Transaction.prototype]),Tt(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],$(o),o),t._storeNames=$(o),this},He.prototype.upgrade=function(e){return this._cfg.contentUpgrade=Ht(this._cfg.contentUpgrade||U,e),this};var uo=He;function He(){}function bn(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new _e(Kt,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function gn(e){return e&&typeof e.databases=="function"}function wn(e){return ke(function(){return A.letThrough=!0,e()})}function _n(e){return!("from"in e)}var ie=function(e,t){var n;if(!this)return n=new ie,e&&"d"in e&&oe(n,e),n;oe(this,arguments.length?{d:1,from:e,to:1<arguments.length?t:e}:{d:0})};function mt(e,t,n){var r=B(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(_n(e))return oe(e,{from:t,to:n,d:1});var r=e.l,o=e.r;if(B(n,e.from)<0)return r?mt(r,t,n):e.l={from:t,to:n,d:1,l:null,r:null},pr(e);if(0<B(t,e.to))return o?mt(o,t,n):e.r={from:t,to:n,d:1,l:null,r:null},pr(e);B(t,e.from)<0&&(e.from=t,e.l=null,e.d=o?o.d+1:1),0<B(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1),t=!e.r,r&&!e.l&&vt(e,r),o&&t&&vt(e,o)}}function vt(e,t){_n(t)||(function n(r,o){var i=o.from,a=o.l,u=o.r;mt(r,i,o.to),a&&n(r,a),u&&n(r,u)})(e,t)}function dr(e,t){var n=Mt(t),r=n.next();if(!r.done)for(var o=r.value,i=Mt(e),a=i.next(o.from),u=a.value;!r.done&&!a.done;){if(B(u.from,o.to)<=0&&0<=B(u.to,o.from))return!0;B(o.from,u.from)<0?o=(r=n.next(u.from)).value:u=(a=i.next(o.from)).value}return!1}function Mt(e){var t=_n(e)?null:{s:0,n:e};return{next:function(n){for(var r=0<arguments.length;t;)switch(t.s){case 0:if(t.s=1,r)for(;t.n.l&&B(n,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!r||B(n,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function pr(e){var t,n,r,o=(((o=e.r)==null?void 0:o.d)||0)-(((o=e.l)==null?void 0:o.d)||0),o=1<o?"r":o<-1?"l":"";o&&(t=o=="r"?"l":"r",n=R({},e),r=e[o],e.from=r.from,e.to=r.to,e[o]=r[o],n[o]=r[t],(e[t]=n).d=yr(n)),e.d=yr(e)}function yr(n){var t=n.r,n=n.l;return(t?n?Math.max(t.d,n.d):t.d:n?n.d:0)+1}function Ft(e,t){return $(t).forEach(function(n){e[n]?vt(e[n],t[n]):e[n]=(function r(o){var i,a,u={};for(i in o)M(o,i)&&(a=o[i],u[i]=!a||typeof a!="object"||Ln.has(a.constructor)?a:r(a));return u})(t[n])}),e}function xn(e,t){return e.all||t.all||Object.keys(e).some(function(n){return t[n]&&dr(t[n],e[n])})}ee(ie.prototype,((ue={add:function(e){return vt(this,e),this},addKey:function(e){return mt(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(n){return mt(t,n,n)}),this},hasKey:function(e){var t=Mt(this).next(e).value;return t&&B(t.from,e)<=0&&0<=B(t.to,e)}})[Gt]=function(){return Mt(this)},ue));var Ne={},kn={},On=!1;function Lt(e){Ft(kn,e),On||(On=!0,setTimeout(function(){On=!1,Pn(kn,!(kn={}))},0))}function Pn(e,t){t===void 0&&(t=!1);var n=new Set;if(e.all)for(var r=0,o=Object.values(Ne);r<o.length;r++)mr(u=o[r],e,n,t);else for(var i in e){var a,u,i=/^idb\:\/\/(.*)\/(.*)\//.exec(i);i&&(a=i[1],i=i[2],u=Ne["idb://".concat(a,"/").concat(i)])&&mr(u,e,n,t)}n.forEach(function(l){return l()})}function mr(e,t,n,r){for(var o=[],i=0,a=Object.entries(e.queries.query);i<a.length;i++){for(var u=a[i],l=u[0],m=[],f=0,s=u[1];f<s.length;f++){var d=s[f];xn(t,d.obsSet)?d.subscribers.forEach(function(v){return n.add(v)}):r&&m.push(d)}r&&o.push([l,m])}if(r)for(var p=0,h=o;p<h.length;p++){var c=h[p],l=c[0],m=c[1];e.queries.query[l]=m}}function so(e){var t=e._state,n=e._deps.indexedDB;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(function(){return t.dbOpenError?J(t.dbOpenError):e});t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;var r=t.openCanceller,o=Math.round(10*e.verno),i=!1;function a(){if(t.openCanceller!==r)throw new q.DatabaseClosed("db.open() was cancelled")}function u(){return new P(function(d,p){if(a(),!n)throw new q.MissingAPI;var h=e.name,c=t.autoSchema||!o?n.open(h):n.open(h,o);if(!c)throw new q.MissingAPI;c.onerror=pe(p),c.onblocked=Q(e._fireOnBlocked),c.onupgradeneeded=Q(function(v){var b;f=c.transaction,t.autoSchema&&!e._options.allowEmptyDB?(c.onerror=ht,f.abort(),c.result.close(),(b=n.deleteDatabase(h)).onsuccess=b.onerror=Q(function(){p(new q.NoSuchDatabase("Database ".concat(h," doesnt exist")))})):(f.onerror=pe(p),b=v.oldVersion>Math.pow(2,62)?0:v.oldVersion,s=b<1,e.idbdb=c.result,i&&ao(e,f),io(e,b/10,f,p))},p),c.onsuccess=Q(function(){f=null;var v,b,y,g,w,k,O=e.idbdb=c.result,_=bt(O.objectStoreNames);if(0<_.length)try{var S=O.transaction((w=_).length===1?w[0]:w,"readonly");if(t.autoSchema)k=O,g=S,(y=e).verno=k.version/10,g=y._dbSchema=Bt(0,k,g),y._storeNames=bt(k.objectStoreNames,0),Tt(y,[y._allTables],$(g),g);else if(Nt(e,e._dbSchema,S),b=S,((b=mn(Bt(0,(v=e).idbdb,b),v._dbSchema)).add.length||b.change.some(function(E){return E.add.length||E.change.length}))&&!i)return console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Dexie will add missing parts and increment native version number to workaround this."),O.close(),o=O.version+1,i=!0,d(u());It(e,S)}catch{}Ge.push(e),O.onversionchange=Q(function(E){t.vcFired=!0,e.on("versionchange").fire(E)}),O.onclose=Q(function(){e.close({disableAutoOpen:!1})}),s&&(_=e._deps,w=h,gn(k=_.indexedDB)||w===Kt||bn(k,_.IDBKeyRange).put({name:w}).catch(U)),d()},p)}).catch(function(d){switch(d==null?void 0:d.name){case"UnknownError":if(0<t.PR1398_maxLoop)return t.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),u();break;case"VersionError":if(0<o)return o=0,u()}return P.reject(d)})}var l,m=t.dbReadyResolve,f=null,s=!1;return P.race([r,(typeof navigator>"u"?P.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(d){function p(){return indexedDB.databases().finally(d)}l=setInterval(p,100),p()}).finally(function(){return clearInterval(l)}):Promise.resolve()).then(u)]).then(function(){return a(),t.onReadyBeingFired=[],P.resolve(wn(function(){return e.on.ready.fire(e.vip)})).then(function d(){var p;if(0<t.onReadyBeingFired.length)return p=t.onReadyBeingFired.reduce(Ht,U),t.onReadyBeingFired=[],P.resolve(wn(function(){return p(e.vip)})).then(d)})}).finally(function(){t.openCanceller===r&&(t.onReadyBeingFired=null,t.isBeingOpened=!1)}).catch(function(d){t.dbOpenError=d;try{f&&f.abort()}catch{}return r===t.openCanceller&&e._close(),J(d)}).finally(function(){t.openComplete=!0,m()}).then(function(){var d;return s&&(d={},e.tables.forEach(function(p){p.schema.indexes.forEach(function(h){h.name&&(d["idb://".concat(e.name,"/").concat(p.name,"/").concat(h.name)]=new ie(-1/0,[[[]]]))}),d["idb://".concat(e.name,"/").concat(p.name,"/")]=d["idb://".concat(e.name,"/").concat(p.name,"/:dels")]=new ie(-1/0,[[[]]])}),Se(dt).fire(d),Pn(d,!0)),e})}function En(e){function t(i){return e.next(i)}var n=o(t),r=o(function(i){return e.throw(i)});function o(i){return function(u){var u=i(u),l=u.value;return u.done?l:l&&typeof l.then=="function"?l.then(n,r):V(l)?Promise.all(l).then(n,r):n(l)}}return o(t)()}function Ut(e,t,n){for(var r=V(e)?e.slice():[e],o=0;o<n;++o)r.push(t);return r}var co={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return R(R({},e),{table:function(r){var n=e.table(r),r=n.schema,o={},i=[];function a(d,p,h){var y=yt(d),c=o[y]=o[y]||[],v=d==null?0:typeof d=="string"?1:d.length,b=0<p,y=R(R({},h),{name:b?"".concat(y,"(virtual-from:").concat(h.name,")"):h.name,lowLevelIndex:h,isVirtual:b,keyTail:p,keyLength:v,extractKey:pn(d),unique:!b&&h.unique});return c.push(y),y.isPrimaryKey||i.push(y),1<v&&a(v===2?d[0]:d.slice(0,v-1),p+1,h),c.sort(function(g,w){return g.keyTail-w.keyTail}),y}var u=a(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[u];for(var l=0,m=r.indexes;l<m.length;l++){var f=m[l];a(f.keyPath,0,f)}function s(d){var p,h=d.query.index;return h.isVirtual?R(R({},d),{query:{index:h.lowLevelIndex,range:(p=d.query.range,h=h.keyTail,{type:p.type===1?2:p.type,lower:Ut(p.lower,p.lowerOpen?e.MAX_KEY:e.MIN_KEY,h),lowerOpen:!0,upper:Ut(p.upper,p.upperOpen?e.MIN_KEY:e.MAX_KEY,h),upperOpen:!0})}}):d}return R(R({},n),{schema:R(R({},r),{primaryKey:u,indexes:i,getIndexByKeyPath:function(d){return(d=o[yt(d)])&&d[0]}}),count:function(d){return n.count(s(d))},query:function(d){return n.query(s(d))},openCursor:function(d){var p=d.query.index,h=p.keyTail,c=p.keyLength;return p.isVirtual?n.openCursor(s(d)).then(function(b){return b&&v(b)}):n.openCursor(d);function v(b){return Object.create(b,{continue:{value:function(y){y!=null?b.continue(Ut(y,d.reverse?e.MAX_KEY:e.MIN_KEY,h)):d.unique?b.continue(b.key.slice(0,c).concat(d.reverse?e.MIN_KEY:e.MAX_KEY,h)):b.continue()}},continuePrimaryKey:{value:function(y,g){b.continuePrimaryKey(Ut(y,e.MAX_KEY,h),g)}},primaryKey:{get:function(){return b.primaryKey}},key:{get:function(){var y=b.key;return c===1?y[0]:y.slice(0,c)}},value:{get:function(){return b.value}}})}}})}})}};function Sn(e,t,n,r){return n=n||{},r=r||"",$(e).forEach(function(o){var i,a,u;M(t,o)?(i=e[o],a=t[o],typeof i=="object"&&typeof a=="object"&&i&&a?(u=Yt(i))!==Yt(a)?n[r+o]=t[o]:u==="Object"?Sn(i,a,n,r+o+"."):i!==a&&(n[r+o]=t[o]):i!==a&&(n[r+o]=t[o])):n[r+o]=void 0}),$(t).forEach(function(o){M(e,o)||(n[r+o]=t[o])}),n}function Kn(e,t){return t.type==="delete"?t.keys:t.keys||t.values.map(e.extractKey)}var lo={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return R(R({},e),{table:function(t){var n=e.table(t),r=n.schema.primaryKey;return R(R({},n),{mutate:function(o){var i=A.trans,a=i.table(t).hook,u=a.deleting,l=a.creating,m=a.updating;switch(o.type){case"add":if(l.fire===U)break;return i._promise("readwrite",function(){return f(o)},!0);case"put":if(l.fire===U&&m.fire===U)break;return i._promise("readwrite",function(){return f(o)},!0);case"delete":if(u.fire===U)break;return i._promise("readwrite",function(){return f(o)},!0);case"deleteRange":if(u.fire===U)break;return i._promise("readwrite",function(){return(function s(d,p,h){return n.query({trans:d,values:!1,query:{index:r,range:p},limit:h}).then(function(c){var v=c.result;return f({type:"delete",keys:v,trans:d}).then(function(b){return 0<b.numFailures?Promise.reject(b.failures[0]):v.length<h?{failures:[],numFailures:0,lastResult:void 0}:s(d,R(R({},p),{lower:v[v.length-1],lowerOpen:!0}),h)})})})(o.trans,o.range,1e4)},!0)}return n.mutate(o);function f(s){var d,p,h,c=A.trans,v=s.keys||Kn(r,s);if(v)return(s=s.type==="add"||s.type==="put"?R(R({},s),{keys:v}):R({},s)).type!=="delete"&&(s.values=ce([],s.values)),s.keys&&(s.keys=ce([],s.keys)),d=n,h=v,((p=s).type==="add"?Promise.resolve([]):d.getMany({trans:p.trans,keys:h,cache:"immutable"})).then(function(b){var y=v.map(function(g,w){var k,O,_,S=b[w],E={onerror:null,onsuccess:null};return s.type==="delete"?u.fire.call(E,g,S,c):s.type==="add"||S===void 0?(k=l.fire.call(E,g,s.values[w],c),g==null&&k!=null&&(s.keys[w]=g=k,r.outbound||ae(s.values[w],r.keyPath,g))):(k=Sn(S,s.values[w]),(O=m.fire.call(E,k,g,S,c))&&(_=s.values[w],Object.keys(O).forEach(function(x){M(_,x)?_[x]=O[x]:ae(_,x,O[x])}))),E});return n.mutate(s).then(function(g){for(var w=g.failures,k=g.results,O=g.numFailures,g=g.lastResult,_=0;_<v.length;++_){var S=(k||v)[_],E=y[_];S==null?E.onerror&&E.onerror(w[_]):E.onsuccess&&E.onsuccess(s.type==="put"&&b[_]?s.values[_]:S)}return{failures:w,results:k,numFailures:O,lastResult:g}}).catch(function(g){return y.forEach(function(w){return w.onerror&&w.onerror(g)}),Promise.reject(g)})});throw new Error("Keys missing")}}})}})}};function vr(e,t,n){try{if(!t||t.keys.length<e.length)return null;for(var r=[],o=0,i=0;o<t.keys.length&&i<e.length;++o)B(t.keys[o],e[i])===0&&(r.push(n?Ce(t.values[o]):t.values[o]),++i);return r.length===e.length?r:null}catch{return null}}var fo={stack:"dbcore",level:-1,create:function(e){return{table:function(t){var n=e.table(t);return R(R({},n),{getMany:function(r){var o;return r.cache?(o=vr(r.keys,r.trans._cache,r.cache==="clone"))?P.resolve(o):n.getMany(r).then(function(i){return r.trans._cache={keys:r.keys,values:r.cache==="clone"?Ce(i):i},i}):n.getMany(r)},mutate:function(r){return r.type!=="add"&&(r.trans._cache=null),n.mutate(r)}})}}}};function br(e,t){return e.trans.mode==="readonly"&&!!e.subscr&&!e.trans.explicit&&e.trans.db._options.cache!=="disabled"&&!t.schema.primaryKey.outbound}function gr(e,t){switch(e){case"query":return t.values&&!t.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var ho={stack:"dbcore",level:0,name:"Observability",create:function(e){var t=e.schema.name,n=new ie(e.MIN_KEY,e.MAX_KEY);return R(R({},e),{transaction:function(r,o,i){if(A.subscr&&o!=="readonly")throw new q.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(A.querier));return e.transaction(r,o,i)},table:function(r){function o(v){var c,v=v.query;return[c=v.index,new ie((c=(v=v.range).lower)!=null?c:e.MIN_KEY,(c=v.upper)!=null?c:e.MAX_KEY)]}var i=e.table(r),a=i.schema,u=a.primaryKey,l=a.indexes,m=u.extractKey,f=u.outbound,s=u.autoIncrement&&l.filter(function(h){return h.compound&&h.keyPath.includes(u.keyPath)}),d=R(R({},i),{mutate:function(h){function c(K){return K="idb://".concat(t,"/").concat(r,"/").concat(K),w[K]||(w[K]=new ie)}var v,b,y,g=h.trans,w=h.mutatedParts||(h.mutatedParts={}),k=c(""),O=c(":dels"),_=h.type,E=h.type==="deleteRange"?[h.range]:h.type==="delete"?[h.keys]:h.values.length<50?[Kn(u,h).filter(function(K){return K}),h.values]:[],S=E[0],E=E[1],x=h.trans._cache;return V(S)?(k.addKeys(S),(_=_==="delete"||S.length===E.length?vr(S,x):null)||O.addKeys(S),(_||E)&&(v=c,b=_,y=E,a.indexes.forEach(function(K){var N=v(K.name||"");function L(T){return T!=null?K.extractKey(T):null}function j(T){K.multiEntry&&V(T)?T.forEach(function(X){return N.addKey(X)}):N.addKey(T)}(b||y).forEach(function(T,H){var fe=b&&L(b[H]),H=y&&L(y[H]);B(fe,H)!==0&&(fe!=null&&j(fe),H!=null)&&j(H)})}))):S?(E={from:(x=S.lower)!=null?x:e.MIN_KEY,to:(_=S.upper)!=null?_:e.MAX_KEY},O.add(E),k.add(E)):(k.add(n),O.add(n),a.indexes.forEach(function(K){return c(K.name).add(n)})),i.mutate(h).then(function(K){return!S||h.type!=="add"&&h.type!=="put"||(k.addKeys(K.results),s&&s.forEach(function(N){for(var L=h.values.map(function(fe){return N.extractKey(fe)}),j=N.keyPath.findIndex(function(fe){return fe===u.keyPath}),T=0,X=K.results.length;T<X;++T)L[T][j]=K.results[T];c(N.name).addKeys(L)})),g.mutatedParts=Ft(g.mutatedParts||{},w),K})}}),p={get:function(h){return[u,new ie(h.key)]},getMany:function(h){return[u,new ie().addKeys(h.keys)]},count:o,query:o,openCursor:o};return $(p).forEach(function(h){d[h]=function(c){var v=A.subscr,b=!!v,y=br(A,i)&&gr(h,c)?c.obsSet={}:v;if(b){var g,v=function(E){return E="idb://".concat(t,"/").concat(r,"/").concat(E),y[E]||(y[E]=new ie)},w=v(""),k=v(":dels"),b=p[h](c),O=b[0],b=b[1];if((h==="query"&&O.isPrimaryKey&&!c.values?k:v(O.name||"")).add(b),!O.isPrimaryKey){if(h!=="count")return g=h==="query"&&f&&c.values&&i.query(R(R({},c),{values:!1})),i[h].apply(this,arguments).then(function(E){if(h==="query"){if(f&&c.values)return g.then(function(L){return L=L.result,w.addKeys(L),E});var x=c.values?E.result.map(m):E.result;(c.values?w:k).addKeys(x)}else{var K,N;if(h==="openCursor")return N=c.values,(K=E)&&Object.create(K,{key:{get:function(){return k.addKey(K.primaryKey),K.key}},primaryKey:{get:function(){var L=K.primaryKey;return k.addKey(L),L}},value:{get:function(){return N&&w.addKey(K.primaryKey),K.value}}})}return E});k.add(n)}}return i[h].apply(this,arguments)}}),d}})}};function wr(e,t,n){var r;return n.numFailures===0?t:t.type==="deleteRange"||(r=t.keys?t.keys.length:"values"in t&&t.values?t.values.length:1,n.numFailures===r)?null:(r=R({},t),V(r.keys)&&(r.keys=r.keys.filter(function(o,i){return!(i in n.failures)})),"values"in r&&V(r.values)&&(r.values=r.values.filter(function(o,i){return!(i in n.failures)})),r)}function Cn(e,t){return n=e,((r=t).lower===void 0||(r.lowerOpen?0<B(n,r.lower):0<=B(n,r.lower)))&&(n=e,(r=t).upper===void 0||(r.upperOpen?B(n,r.upper)<0:B(n,r.upper)<=0));var n,r}function _r(e,t,n,r,o,i){var a,u,l,m,f,s;return!n||n.length===0||(a=t.query.index,u=a.multiEntry,l=t.query.range,m=r.schema.primaryKey.extractKey,f=a.extractKey,s=(a.lowLevelIndex||a).extractKey,(r=n.reduce(function(d,p){var h=d,c=[];if(p.type==="add"||p.type==="put")for(var v=new ie,b=p.values.length-1;0<=b;--b){var y,g=p.values[b],w=m(g);!v.hasKey(w)&&(y=f(g),u&&V(y)?y.some(function(E){return Cn(E,l)}):Cn(y,l))&&(v.addKey(w),c.push(g))}switch(p.type){case"add":var k=new ie().addKeys(t.values?d.map(function(x){return m(x)}):d),h=d.concat(t.values?c.filter(function(x){return x=m(x),!k.hasKey(x)&&(k.addKey(x),!0)}):c.map(function(x){return m(x)}).filter(function(x){return!k.hasKey(x)&&(k.addKey(x),!0)}));break;case"put":var O=new ie().addKeys(p.values.map(function(x){return m(x)}));h=d.filter(function(x){return!O.hasKey(t.values?m(x):x)}).concat(t.values?c:c.map(function(x){return m(x)}));break;case"delete":var _=new ie().addKeys(p.keys);h=d.filter(function(x){return!_.hasKey(t.values?m(x):x)});break;case"deleteRange":var S=p.range;h=d.filter(function(x){return!Cn(m(x),S)})}return h},e))===e)?e:(r.sort(function(d,p){return B(s(d),s(p))||B(m(d),m(p))}),t.limit&&t.limit<1/0&&(r.length>t.limit?r.length=t.limit:e.length===t.limit&&r.length<t.limit&&(o.dirty=!0)),i?Object.freeze(r):r)}function xr(e,t){return B(e.lower,t.lower)===0&&B(e.upper,t.upper)===0&&!!e.lowerOpen==!!t.lowerOpen&&!!e.upperOpen==!!t.upperOpen}function po(e,t){return((n,r,o,i)=>{if(n===void 0)return r!==void 0?-1:0;if(r===void 0)return 1;if((n=B(n,r))===0){if(o&&i)return 0;if(o)return 1;if(i)return-1}return n})(e.lower,t.lower,e.lowerOpen,t.lowerOpen)<=0&&0<=((n,r,o,i)=>{if(n===void 0)return r!==void 0?1:0;if(r===void 0)return-1;if((n=B(n,r))===0){if(o&&i)return 0;if(o)return-1;if(i)return 1}return n})(e.upper,t.upper,e.upperOpen,t.upperOpen)}function yo(e,t,n,r){e.subscribers.add(n),r.addEventListener("abort",function(){var o,i;e.subscribers.delete(n),e.subscribers.size===0&&(o=e,i=t,setTimeout(function(){o.subscribers.size===0&&Ae(i,o)},3e3))})}var mo={stack:"dbcore",level:0,name:"Cache",create:function(e){var t=e.schema.name;return R(R({},e),{transaction:function(n,r,o){var i,a,u=e.transaction(n,r,o);return r==="readwrite"&&(o=(i=new AbortController).signal,u.addEventListener("abort",(a=function(l){return function(){if(i.abort(),r==="readwrite"){for(var m=new Set,f=0,s=n;f<s.length;f++){var d=s[f],p=Ne["idb://".concat(t,"/").concat(d)];if(p){var h=e.table(d),c=p.optimisticOps.filter(function(K){return K.trans===u});if(u._explicit&&l&&u.mutatedParts)for(var v=0,b=Object.values(p.queries.query);v<b.length;v++)for(var y=0,g=(O=b[v]).slice();y<g.length;y++)xn((_=g[y]).obsSet,u.mutatedParts)&&(Ae(O,_),_.subscribers.forEach(function(K){return m.add(K)}));else if(0<c.length){p.optimisticOps=p.optimisticOps.filter(function(K){return K.trans!==u});for(var w=0,k=Object.values(p.queries.query);w<k.length;w++)for(var O,_,S,E=0,x=(O=k[w]).slice();E<x.length;E++)(_=x[E]).res!=null&&u.mutatedParts&&(l&&!_.dirty?(S=Object.isFrozen(_.res),S=_r(_.res,_.req,c,h,_,S),_.dirty?(Ae(O,_),_.subscribers.forEach(function(K){return m.add(K)})):S!==_.res&&(_.res=S,_.promise=P.resolve({result:S}))):(_.dirty&&Ae(O,_),_.subscribers.forEach(function(K){return m.add(K)})))}}}m.forEach(function(K){return K()})}}})(!1),{signal:o}),u.addEventListener("error",a(!1),{signal:o}),u.addEventListener("complete",a(!0),{signal:o})),u},table:function(n){var r=e.table(n),o=r.schema.primaryKey;return R(R({},r),{mutate:function(i){var a,u=A.trans;return!o.outbound&&u.db._options.cache!=="disabled"&&!u.explicit&&u.idbtrans.mode==="readwrite"&&(a=Ne["idb://".concat(t,"/").concat(n)])?(u=r.mutate(i),i.type!=="add"&&i.type!=="put"||!(50<=i.values.length||Kn(o,i).some(function(l){return l==null}))?(a.optimisticOps.push(i),i.mutatedParts&&Lt(i.mutatedParts),u.then(function(l){0<l.numFailures&&(Ae(a.optimisticOps,i),(l=wr(0,i,l))&&a.optimisticOps.push(l),i.mutatedParts)&&Lt(i.mutatedParts)}),u.catch(function(){Ae(a.optimisticOps,i),i.mutatedParts&&Lt(i.mutatedParts)})):u.then(function(l){var m=wr(0,R(R({},i),{values:i.values.map(function(f,s){var d;return l.failures[s]?f:(ae(d=(d=o.keyPath)!=null&&d.includes(".")?Ce(f):R({},f),o.keyPath,l.results[s]),d)})}),l);a.optimisticOps.push(m),queueMicrotask(function(){return i.mutatedParts&&Lt(i.mutatedParts)})}),u):r.mutate(i)},query:function(i){var a,u,l,m,f,s,d;return br(A,r)&&gr("query",i)?(a=((l=A.trans)==null?void 0:l.db._options.cache)==="immutable",u=(l=A).requery,l=l.signal,s=((p,h,c,v)=>{var b=Ne["idb://".concat(p,"/").concat(h)];if(!b)return[];if(!(p=b.queries[c]))return[null,!1,b,null];var y=p[(v.query?v.query.index.name:null)||""];if(!y)return[null,!1,b,null];switch(c){case"query":var g=y.find(function(w){return w.req.limit===v.limit&&w.req.values===v.values&&xr(w.req.query.range,v.query.range)});return g?[g,!0,b,y]:[y.find(function(w){return("limit"in w.req?w.req.limit:1/0)>=v.limit&&(!v.values||w.req.values)&&po(w.req.query.range,v.query.range)}),!1,b,y];case"count":return g=y.find(function(w){return xr(w.req.query.range,v.query.range)}),[g,!!g,b,y]}})(t,n,"query",i),d=s[0],m=s[2],f=s[3],d&&s[1]?d.obsSet=i.obsSet:(s=r.query(i).then(function(p){var h=p.result;if(d&&(d.res=h),a){for(var c=0,v=h.length;c<v;++c)Object.freeze(h[c]);Object.freeze(h)}else p.result=Ce(h);return p}).catch(function(p){return f&&d&&Ae(f,d),Promise.reject(p)}),d={obsSet:i.obsSet,promise:s,subscribers:new Set,type:"query",req:i,dirty:!1},f?f.push(d):(f=[d],(m=m||(Ne["idb://".concat(t,"/").concat(n)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[i.query.index.name||""]=f)),yo(d,f,u,l),d.promise.then(function(p){return{result:_r(p.result,i,m==null?void 0:m.optimisticOps,r,d,a)}})):r.query(i)}})}})}};function Vt(e,t){return new Proxy(e,{get:function(n,r,o){return r==="db"?t:Reflect.get(n,r,o)}})}Z.prototype.version=function(e){if(isNaN(e)||e<.1)throw new q.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new q.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);var t=this._versions,n=t.filter(function(r){return r._cfg.version===e})[0];return n||(n=new this.Version(e),t.push(n),t.sort(oo),n.stores({}),this._state.autoSchema=!1),n},Z.prototype._whenReady=function(e){var t=this;return this.idbdb&&(this._state.openComplete||A.letThrough||this._vip)?e():new P(function(n,r){if(t._state.openComplete)return r(new q.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._state.autoOpen)return void r(new q.DatabaseClosed);t.open().catch(U)}t._state.dbReadyPromise.then(n,r)}).then(e)},Z.prototype.use=function(o){var t=o.stack,n=o.create,r=o.level,o=o.name,i=(o&&this.unuse({stack:t,name:o}),this._middlewares[t]||(this._middlewares[t]=[]));return i.push({stack:t,create:n,level:r??10,name:o}),i.sort(function(a,u){return a.level-u.level}),this},Z.prototype.unuse=function(e){var t=e.stack,n=e.name,r=e.create;return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(function(o){return r?o.create!==r:!!n&&o.name!==n})),this},Z.prototype.open=function(){var e=this;return Te(xe,function(){return so(e)})},Z.prototype._close=function(){this.on.close.fire(new CustomEvent("close"));var e=this._state,t=Ge.indexOf(this);if(0<=t&&Ge.splice(t,1),this.idbdb){try{this.idbdb.close()}catch{}this.idbdb=null}e.isBeingOpened||(e.dbReadyPromise=new P(function(n){e.dbReadyResolve=n}),e.openCanceller=new P(function(n,r){e.cancelOpen=r}))},Z.prototype.close=function(t){var t=(t===void 0?{disableAutoOpen:!0}:t).disableAutoOpen,n=this._state;t?(n.isBeingOpened&&n.cancelOpen(new q.DatabaseClosed),this._close(),n.autoOpen=!1,n.dbOpenError=new q.DatabaseClosed):(this._close(),n.autoOpen=this._options.autoOpen||n.isBeingOpened,n.openComplete=!1,n.dbOpenError=null)},Z.prototype.delete=function(e){var t=this,n=(e===void 0&&(e={disableAutoOpen:!0}),0<arguments.length&&typeof arguments[0]!="object"),r=this._state;return new P(function(o,i){function a(){t.close(e);var u=t._deps.indexedDB.deleteDatabase(t.name);u.onsuccess=Q(function(){var l,m,f;l=t._deps,m=t.name,gn(f=l.indexedDB)||m===Kt||bn(f,l.IDBKeyRange).delete(m).catch(U),o()}),u.onerror=pe(i),u.onblocked=t._fireOnBlocked}if(n)throw new q.InvalidArgument("Invalid closeOptions argument to db.delete()");r.isBeingOpened?r.dbReadyPromise.then(a):a()})},Z.prototype.backendDB=function(){return this.idbdb},Z.prototype.isOpen=function(){return this.idbdb!==null},Z.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"},Z.prototype.hasFailed=function(){return this._state.dbOpenError!==null},Z.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(Z.prototype,"tables",{get:function(){var e=this;return $(this._allTables).map(function(t){return e._allTables[t]})},enumerable:!1,configurable:!0}),Z.prototype.transaction=function(){var e=(function(t,n,r){var o=arguments.length;if(o<2)throw new q.InvalidArgument("Too few arguments");for(var i=new Array(o-1);--o;)i[o-1]=arguments[o];return r=i.pop(),[t,Fn(i),r]}).apply(this,arguments);return this._transaction.apply(this,e)},Z.prototype._transaction=function(e,t,n){var r,o,i=this,a=A.trans,u=(a&&a.db===this&&e.indexOf("!")===-1||(a=null),e.indexOf("?")!==-1);e=e.replace("!","").replace("?","");try{if(o=t.map(function(m){if(m=m instanceof i.Table?m.name:m,typeof m!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return m}),e=="r"||e===un)r=un;else{if(e!="rw"&&e!=sn)throw new q.InvalidArgument("Invalid transaction mode: "+e);r=sn}if(a){if(a.mode===un&&r===sn){if(!u)throw new q.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");a=null}a&&o.forEach(function(m){if(a&&a.storeNames.indexOf(m)===-1){if(!u)throw new q.SubTransaction("Table "+m+" not included in parent transaction.");a=null}}),u&&a&&!a.active&&(a=null)}}catch(m){return a?a._promise(null,function(f,s){s(m)}):J(m)}var l=(function m(f,s,d,p,h){return P.resolve().then(function(){var y=A.transless||A,c=f._createTransaction(s,d,f._dbSchema,p),y=(c.explicit=!0,{trans:c,transless:y});if(p)c.idbtrans=p.idbtrans;else try{c.create(),c.idbtrans._explicit=!0,f._state.PR1398_maxLoop=3}catch(g){return g.name===Xt.InvalidState&&f.isOpen()&&0<--f._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),f.close({disableAutoOpen:!1}),f.open().then(function(){return m(f,s,d,null,h)})):J(g)}var v,b=Qt(h),y=(b&&Ye(),P.follow(function(){var g;(v=h.call(c,c))&&(b?(g=Oe.bind(null,null),v.then(g,g)):typeof v.next=="function"&&typeof v.throw=="function"&&(v=En(v)))},y));return(v&&typeof v.then=="function"?P.resolve(v).then(function(g){return c.active?g:J(new q.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):y.then(function(){return v})).then(function(g){return p&&c._resolve(),c._completion.then(function(){return g})}).catch(function(g){return c._reject(g),J(g)})})}).bind(null,this,r,o,a,n);return a?a._promise(r,l,"lock"):A.trans?Te(A.transless,function(){return i._whenReady(l)}):this._whenReady(l)},Z.prototype.table=function(e){if(M(this._allTables,e))return this._allTables[e];throw new q.InvalidTable("Table ".concat(e," does not exist"))};var _e=Z;function Z(e,t){var n,r,o,i,a,u=this,l=(this._middlewares={},this.verno=0,Z.dependencies),l=(this._options=t=R({addons:Z.addons,autoOpen:!0,indexedDB:l.indexedDB,IDBKeyRange:l.IDBKeyRange,cache:"cloned"},t),this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange},t.addons),m=(this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this,{dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:U,dbReadyPromise:null,cancelOpen:U,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:t.autoOpen}),f=(m.dbReadyPromise=new P(function(s){m.dbReadyResolve=s}),m.openCanceller=new P(function(s,d){m.cancelOpen=d}),this._state=m,this.name=e,this.on=lt(this,"populate","blocked","versionchange","close",{ready:[Ht,U]}),this.once=function(s,d){var p=function(){for(var h=[],c=0;c<arguments.length;c++)h[c]=arguments[c];u.on(s).unsubscribe(p),d.apply(u,h)};return u.on(s,p)},this.on.ready.subscribe=Bn(this.on.ready.subscribe,function(s){return function(d,p){Z.vip(function(){var h,c=u._state;c.openComplete?(c.dbOpenError||P.resolve().then(d),p&&s(d)):c.onReadyBeingFired?(c.onReadyBeingFired.push(d),p&&s(d)):(s(d),h=u,p||s(function v(){h.on.ready.unsubscribe(d),h.on.ready.unsubscribe(v)}))})}}),this.Collection=(n=this,ft(Hr.prototype,function(v,c){this.db=n;var p=Hn,h=null;if(c)try{p=c()}catch(y){h=y}var c=v._ctx,v=c.table,b=v.hook.reading.fire;this._ctx={table:v,index:c.index,isPrimKey:!c.index||v.schema.primKey.keyPath&&c.index===v.schema.primKey.name,range:p,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:h,or:c.or,valueMapper:b!==ot?b:null}})),this.Table=(r=this,ft(rr.prototype,function(s,d,p){this.db=r,this._tx=p,this.name=s,this.schema=d,this.hook=r._allTables[s]?r._allTables[s].hook:lt(null,{creating:[Ur,U],reading:[Lr,ot],updating:[Wr,U],deleting:[Vr,U]})})),this.Transaction=(o=this,ft(eo.prototype,function(s,d,p,h,c){var v=this;s!=="readonly"&&d.forEach(function(b){b=(b=p[b])==null?void 0:b.yProps,b&&(d=d.concat(b.map(function(y){return y.updatesTable})))}),this.db=o,this.mode=s,this.storeNames=d,this.schema=p,this.chromeTransactionDurability=h,this.idbtrans=null,this.on=lt(this,"complete","error","abort"),this.parent=c||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new P(function(b,y){v._resolve=b,v._reject=y}),this._completion.then(function(){v.active=!1,v.on.complete.fire()},function(b){var y=v.active;return v.active=!1,v.on.error.fire(b),v.parent?v.parent._reject(b):y&&v.idbtrans&&v.idbtrans.abort(),J(b)})})),this.Version=(i=this,ft(uo.prototype,function(s){this.db=i,this._cfg={version:s,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(a=this,ft(sr.prototype,function(s,d,p){if(this.db=a,this._ctx={table:s,index:d===":id"?null:d,or:p},this._cmp=this._ascending=B,this._descending=function(h,c){return B(c,h)},this._max=function(h,c){return 0<B(h,c)?h:c},this._min=function(h,c){return B(h,c)<0?h:c},this._IDBKeyRange=a._deps.IDBKeyRange,!this._IDBKeyRange)throw new q.MissingAPI})),this.on("versionchange",function(s){0<s.newVersion?console.warn("Another connection wants to upgrade database '".concat(u.name,"'. Closing db now to resume the upgrade.")):console.warn("Another connection wants to delete database '".concat(u.name,"'. Closing db now to resume the delete request.")),u.close({disableAutoOpen:!1})}),this.on("blocked",function(s){!s.newVersion||s.newVersion<s.oldVersion?console.warn("Dexie.delete('".concat(u.name,"') was blocked")):console.warn("Upgrade '".concat(u.name,"' blocked by other connection holding version ").concat(s.oldVersion/10))}),this._maxKey=pt(t.IDBKeyRange),this._createTransaction=function(s,d,p,h){return new u.Transaction(s,d,p,u._options.chromeTransactionDurability,h)},this._fireOnBlocked=function(s){u.on("blocked").fire(s),Ge.filter(function(d){return d.name===u.name&&d!==u&&!d._state.vcFired}).map(function(d){return d.on("versionchange").fire(s)})},this.use(fo),this.use(mo),this.use(ho),this.use(co),this.use(lo),new Proxy(this,{get:function(s,d,p){var h;return d==="_vip"||(d==="table"?function(c){return Vt(u.table(c),f)}:(h=Reflect.get(s,d,p))instanceof rr?Vt(h,f):d==="tables"?h.map(function(c){return Vt(c,f)}):d==="_createTransaction"?function(){return Vt(h.apply(this,arguments),f)}:h)}}));this.vip=f,l.forEach(function(s){return s(u)})}var Wt,Je=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable",vo=(An.prototype.subscribe=function(e,t,n){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:t,complete:n})},An.prototype[Je]=function(){return this},An);function An(e){this._subscribe=e}try{Wt={indexedDB:z.indexedDB||z.mozIndexedDB||z.webkitIndexedDB||z.msIndexedDB,IDBKeyRange:z.IDBKeyRange||z.webkitIDBKeyRange}}catch{Wt={indexedDB:null,IDBKeyRange:null}}function kr(e){var t,n=!1,r=new vo(function(o){var i=Qt(e),a,u=!1,l={},m={},f={get closed(){return u},unsubscribe:function(){u||(u=!0,a&&a.abort(),s&&Se.storagemutated.unsubscribe(p))}},s=(o.start&&o.start(f),!1),d=function(){return an(h)},p=function(c){Ft(l,c),xn(m,l)&&d()},h=function(){var c,v,b;!u&&Wt.indexedDB&&(l={},c={},a&&a.abort(),a=new AbortController,b=(y=>{var g=ze();try{i&&Ye();var w=ke(e,y);return w=i?w.finally(Oe):w}finally{g&&$e()}})(v={subscr:c,signal:a.signal,requery:d,querier:e,trans:null}),Promise.resolve(b).then(function(y){n=!0,t=y,u||v.signal.aborted||(l={},(g=>{for(var w in g)if(M(g,w))return;return 1})(m=c)||s||(Se(dt,p),s=!0),an(function(){return!u&&o.next&&o.next(y)}))},function(y){n=!1,["DatabaseClosedError","AbortError"].includes(y==null?void 0:y.name)||u||an(function(){u||o.error&&o.error(y)})}))};return setTimeout(d,0),f});return r.hasValue=function(){return n},r.getValue=function(){return t},r}var Me=_e;function qn(e){var t=Ke;try{Ke=!0,Se.storagemutated.fire(e),Pn(e,!0)}finally{Ke=t}}ee(Me,R(R({},ge),{delete:function(e){return new Me(e,{addons:[]}).delete()},exists:function(e){return new Me(e,{addons:[]}).open().then(function(t){return t.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return t=Me.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(gn(n)?Promise.resolve(n.databases()).then(function(r){return r.map(function(o){return o.name}).filter(function(o){return o!==Kt})}):bn(n,t).toCollection().primaryKeys()).then(e)}catch{return J(new q.MissingAPI)}var t,n},defineClass:function(){return function(e){oe(this,e)}},ignoreTransaction:function(e){return A.trans?Te(A.transless,e):e()},vip:wn,async:function(e){return function(){try{var t=En(e.apply(this,arguments));return t&&typeof t.then=="function"?t:P.resolve(t)}catch(n){return J(n)}}},spawn:function(e,t,n){try{var r=En(e.apply(n,t||[]));return r&&typeof r.then=="function"?r:P.resolve(r)}catch(o){return J(o)}},currentTransaction:{get:function(){return A.trans||null}},waitFor:function(e,t){return e=P.resolve(typeof e=="function"?Me.ignoreTransaction(e):e).timeout(t||6e4),A.trans?A.trans.waitFor(e):e},Promise:P,debug:{get:function(){return de},set:function(e){Wn(e)}},derive:Le,extend:oe,props:ee,override:Bn,Events:lt,on:Se,liveQuery:kr,extendObservabilitySet:Ft,getByKeyPath:ve,setByKeyPath:ae,delByKeyPath:function(e,t){typeof t=="string"?ae(e,t,void 0):"length"in t&&[].map.call(t,function(n){ae(e,n,void 0)})},shallowClone:Mn,deepClone:Ce,getObjectDiff:Sn,cmp:B,asap:Nn,minKey:-1/0,addons:[],connections:Ge,errnames:Xt,dependencies:Wt,cache:Ne,semVer:"4.3.0",version:"4.3.0".split(".").map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/Math.pow(10,2*n)})})),Me.maxKey=pt(Me.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(Se(dt,function(e){Ke||(e=new CustomEvent(fn,{detail:e}),Ke=!0,dispatchEvent(e),Ke=!1)}),addEventListener(fn,function(e){e=e.detail,Ke||qn(e)}));var Ze,Ke=!1,Or=function(){};return typeof BroadcastChannel<"u"&&((Or=function(){(Ze=new BroadcastChannel(fn)).onmessage=function(e){return e.data&&qn(e.data)}})(),typeof Ze.unref=="function"&&Ze.unref(),Se(dt,function(e){Ke||Ze.postMessage(e)})),typeof addEventListener<"u"&&(addEventListener("pagehide",function(e){if(!_e.disableBfCache&&e.persisted){de&&console.debug("Dexie: handling persisted pagehide"),Ze!=null&&Ze.close();for(var t=0,n=Ge;t<n.length;t++)n[t].close({disableAutoOpen:!1})}}),addEventListener("pageshow",function(e){!_e.disableBfCache&&e.persisted&&(de&&console.debug("Dexie: handling persisted pageshow"),Or(),qn({all:new ie(-1/0,[[]])}))})),P.rejectionMapper=function(e,t){return!e||e instanceof Ve||e instanceof TypeError||e instanceof SyntaxError||!e.name||!Vn[e.name]?e:(t=new Vn[e.name](t||e.message,e),"stack"in e&&G(t,"stack",{get:function(){return this.inner.stack}}),t)},Wn(de),R(_e,Object.freeze({__proto__:null,Dexie:_e,Entity:Jn,PropModification:ct,RangeSet:ie,add:function(e){return new ct({add:e})},cmp:B,default:_e,liveQuery:kr,mergeRanges:vt,rangesOverlap:dr,remove:function(e){return new ct({remove:e})},replacePrefix:function(e,t){return new ct({replacePrefix:[e,t]})}}),{default:_e}),_e})})(zt)),zt.exports}var Oo=ko();const In=_o(Oo),Sr=Symbol.for("Dexie"),et=globalThis[Sr]||(globalThis[Sr]=In);if(In.semVer!==et.semVer)throw new Error(`Two different versions of Dexie loaded in the same app: ${In.semVer} and ${et.semVer}`);const{liveQuery:Do,mergeRanges:Bo,rangesOverlap:No,RangeSet:Mo,cmp:Fo,Entity:Lo,PropModification:Uo,replacePrefix:Vo,add:Wo,remove:zo,DexieYProvider:$o}=et,Po="__neo_",Ar=`${Po}capture_request`,Kr=500,Eo=C=>!!C&&typeof C=="object"&&C.type===Ar&&!!C.payload;class So extends et{constructor(){super("neo-capture-v01");Pr(this,"capturedRequests");this.version(1).stores({capturedRequests:"id, tabId, domain, timestamp, method, [domain+timestamp]"})}}const re=new So;async function Ko(C){const I=await re.capturedRequests.add({...C,createdAt:Date.now()});return Co(C.domain),I}async function Co(C){try{const I=await re.capturedRequests.where("domain").equals(C).count();if(I<=Kr)return;const D=I-Kr,ce=(await re.capturedRequests.where("[domain+timestamp]").between([C,et.minKey],[C,et.maxKey]).limit(D).toArray()).map(z=>z.id);ce.length>0&&await re.capturedRequests.bulkDelete(ce)}catch{}}const tt=new Map,Ao="ws://127.0.0.1:9234",qr=5e3,qo=6e4;let he=null,$t=qr,Rn=null;function jr(){if(!(he&&(he.readyState===WebSocket.CONNECTING||he.readyState===WebSocket.OPEN))){try{he=new WebSocket(Ao)}catch{Cr();return}he.onopen=()=>{$t=qr,console.log("[Neo Bridge] connected")},he.onclose=()=>{he=null,Cr()},he.onerror=()=>{},he.onmessage=C=>{jo(C.data)}}}function Cr(){Rn||(Rn=setTimeout(()=>{Rn=null,jr()},$t),$t=Math.min($t*1.5,qo))}function Rr(C,I){if(!(!he||he.readyState!==WebSocket.OPEN))try{he.send(JSON.stringify({type:C,data:I}))}catch{}}async function jo(C){var R,ce,z,$,V,oe,me;let I;try{I=JSON.parse(C)}catch{return}const D=(Y,M)=>{Rr("response",{id:I.id,result:Y,error:M})};try{switch(I.cmd){case"ping":D("pong");break;case"status":{const Y=await re.capturedRequests.count(),M=new Map;await re.capturedRequests.each(ee=>{M.set(ee.domain,(M.get(ee.domain)||0)+1)}),D({count:Y,domains:Object.fromEntries(M)});break}case"capture.count":D(await re.capturedRequests.count());break;case"capture.list":{const Y=(R=I.args)==null?void 0:R.domain,M=((ce=I.args)==null?void 0:ce.limit)||50,le=await(Y?re.capturedRequests.where("domain").equals(Y):re.capturedRequests.toCollection()).reverse().limit(M).toArray();D(le.map(G=>({id:G.id,method:G.method,url:G.url,status:G.responseStatus,duration:G.duration,source:G.source,timestamp:G.timestamp})));break}case"capture.detail":{const Y=(z=I.args)==null?void 0:z.id;if(!Y){D(null,"missing id");break}const M=await re.capturedRequests.get(Y);D(M||null);break}case"capture.domains":{const Y=new Map;await re.capturedRequests.each(ee=>{Y.set(ee.domain,(Y.get(ee.domain)||0)+1)});const M=[...Y.entries()].sort((ee,le)=>le[1]-ee[1]);D(M.map(([ee,le])=>({domain:ee,count:le})));break}case"capture.clear":{const Y=($=I.args)==null?void 0:$.domain;if(Y){const M=await re.capturedRequests.where("domain").equals(Y).primaryKeys();await re.capturedRequests.bulkDelete(M),D({cleared:M.length,domain:Y})}else await re.capturedRequests.clear(),D({cleared:"all"});break}case"capture.search":{const Y=(((V=I.args)==null?void 0:V.query)||"").toLowerCase(),M=(oe=I.args)==null?void 0:oe.method,ee=((me=I.args)==null?void 0:me.limit)||20,le=[];await re.capturedRequests.reverse().each(G=>{le.length>=ee||Y&&!G.url.toLowerCase().includes(Y)||M&&G.method.toUpperCase()!==M.toUpperCase()||le.push({id:G.id,method:G.method,url:G.url,status:G.responseStatus,timestamp:G.timestamp})}),D(le);break}default:D(null,`unknown command: ${I.cmd}`)}}catch(Y){D(null,String(Y))}}jr();chrome.runtime.onMessage.addListener((C,I)=>{var z,$;if(!Eo(C))return;const D=C.payload,R=typeof D.tabId=="number"?D.tabId:((z=I.tab)==null?void 0:z.id)??-1,ce={...D,tabId:R,tabUrl:D.tabUrl||(($=I.tab)==null?void 0:$.url)||""};Io(ce)});chrome.tabs.onActivated.addListener(({tabId:C})=>{Dn(C)});chrome.tabs.onRemoved.addListener(C=>{tt.delete(C)});chrome.runtime.onInstalled.addListener(()=>{Tn()});chrome.runtime.onStartup.addListener(()=>{Tn()});Tn();async function Tn(){try{const C=await chrome.tabs.query({});for(const I of C){if(typeof I.id!="number")continue;const D=await re.capturedRequests.where("tabId").equals(I.id).count();D>0&&tt.set(I.id,D)}await Dn()}catch(C){console.error("[Neo] hydrateCounts failed:",C)}}async function Dn(C){const I=typeof C=="number"&&C>0?C:await Ro();if(typeof I!="number"||I<0)return;const D=tt.get(I)??await re.capturedRequests.where("tabId").equals(I).count();tt.set(I,D),await chrome.action.setBadgeText({tabId:I,text:D>0?String(D):""}),await chrome.action.setBadgeBackgroundColor({color:"#2563EB",tabId:I})}async function Ro(){var I;return(I=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:I.id}async function Io(C){try{if(await Ko(C),C.tabId>-1){const I=tt.get(C.tabId)||0;tt.set(C.tabId,I+1)}await Dn(C.tabId),Rr("capture",{id:C.id,method:C.method,url:C.url,domain:C.domain,status:C.responseStatus,duration:C.duration,source:C.source,trigger:C.trigger,timestamp:C.timestamp,tabUrl:C.tabUrl})}catch(I){console.error("[Neo] persistCapture failed:",I)}}console.log(Ar);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";const l="__neo_",u=`${l}capture_request`,E=150,h=500,g=8e3,o=[],f=window;f.__neoContentScriptInstalled||(f.__neoContentScriptInstalled=!0,_(),window.addEventListener("message",N,!1));function _(){document.addEventListener("click",t=>a("click",t),!0),document.addEventListener("input",t=>a("input",t),!0),document.addEventListener("submit",t=>a("submit",t),!0)}function a(t,n){const e=n.target instanceof Element?n.target:null,i=e?T(e):"unknown",s=e?y(e.textContent||e.getAttribute("aria-label")):void 0;o.push({event:t,selector:i,text:s,timestamp:Date.now()}),o.length>E&&o.shift(),m()}function m(){const t=Date.now()-g;for(;o.length>0&&o[0].timestamp<t;)o.shift()}function N(t){if(t.source!==window||!t.data||typeof t.data!="object"||typeof t.data.type!="string"||!t.data.type.startsWith(l)||t.data.type!==u)return;const n=t.data.payload;if(!n||typeof n!="object")return;const e={...n,tabId:-1,tabUrl:n.tabUrl||window.location.href,trigger:n.trigger||w(n.timestamp)};chrome.runtime.sendMessage({type:u,payload:e}).catch(()=>{})}function w(t){m();for(let n=o.length-1;n>=0;n--){const e=o[n],i=t-e.timestamp;if(i>=0&&i<=h)return{event:e.event,selector:e.selector,text:e.text,timestamp:e.timestamp}}}function T(t){if(t.id)return`#${t.id}`;const n=[];let e=t,i=0;for(;e&&e.nodeType===Node.ELEMENT_NODE&&i<8;){let s=e.nodeName.toLowerCase();const c=e.parentElement;if(e.className&&typeof e.className=="string"){const r=e.className.split(" ").filter(Boolean).slice(0,2);r.length>0&&(s+=`.${r.join(".")}`)}if(c){const r=e,p=[...c.children].filter(d=>d.nodeName===r.nodeName);if(p.length>1){const d=p.indexOf(e);s+=`:nth-child(${d+1})`}}n.unshift(s),e=c,i+=1}return n.join(" > ")}function y(t){if(!t)return;const n=t.trim();if(n)return n.slice(0,120)}})();
|