@kedem/okdb 1.0.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/LICENSE +57 -0
- package/README.md +344 -0
- package/banner.jpg +0 -0
- package/bin/okdb.js +2 -0
- package/docs/OKDB-ARCHITECTURE.md +1036 -0
- package/docs/auth-and-sync.md +558 -0
- package/docs/auth-permissions.md +143 -0
- package/docs/change-log.md +169 -0
- package/docs/data-model.md +174 -0
- package/docs/embeddings.md +338 -0
- package/docs/files.md +131 -0
- package/docs/fts.md +139 -0
- package/docs/functions.md +514 -0
- package/docs/getting-started.md +233 -0
- package/docs/http-api.md +705 -0
- package/docs/index.md +115 -0
- package/docs/indexes.md +207 -0
- package/docs/logging.md +116 -0
- package/docs/manifest.json +38 -0
- package/docs/migration.md +154 -0
- package/docs/pipelines.md +598 -0
- package/docs/plugins.md +144 -0
- package/docs/querying.md +204 -0
- package/docs/queue.md +637 -0
- package/docs/sync.md +156 -0
- package/docs/transactions.md +140 -0
- package/docs/ttl.md +375 -0
- package/okdb.js +1 -0
- package/package.json +26 -0
- package/public/admin-app.js +1 -0
- package/public/android-chrome-192x192.png +0 -0
- package/public/android-chrome-512x512.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/components/admin-route-host.ok.js +1 -0
- package/public/components/env-picker.ok.js +1 -0
- package/public/components/field-path-input.ok.js +1 -0
- package/public/components/field.html +6 -0
- package/public/components/geo-map.ok.js +1 -0
- package/public/components/ok-cron-input.ok.js +1 -0
- package/public/components/ok-dropzone.ok.js +1 -0
- package/public/components/ok-js-input.ok.js +1 -0
- package/public/components/ok-json-input.ok.js +1 -0
- package/public/components/ok-text-monaco-input.ok.js +1 -0
- package/public/components/theme-toggle.ok.js +1 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/images/logo.png +0 -0
- package/public/images/logo.svg +333 -0
- package/public/index.html +6 -0
- package/public/layouts/_default.ok.html +1 -0
- package/public/layouts/okdb-cube.ok.html +1 -0
- package/public/login-app.js +1 -0
- package/public/login.html +1 -0
- package/public/modules/ok.js +1 -0
- package/public/sections/api/index.ok.html +1 -0
- package/public/sections/api/parts/api-endpoint.ok.js +1 -0
- package/public/sections/auth/index.ok.html +1 -0
- package/public/sections/auth/modals/create-token-modal.ok.js +1 -0
- package/public/sections/auth/modals/edit-token-modal.ok.js +1 -0
- package/public/sections/auth/modals/perm-info-popover.ok.js +1 -0
- package/public/sections/auth/parts/token-detail.ok.js +1 -0
- package/public/sections/auth/parts/token-list.ok.js +1 -0
- package/public/sections/db/index.ok.html +1 -0
- package/public/sections/db/modals/add-item-modal.ok.js +1 -0
- package/public/sections/db/modals/create-env-modal.ok.js +1 -0
- package/public/sections/db/modals/create-fts-modal.ok.js +1 -0
- package/public/sections/db/modals/create-index-modal.ok.js +1 -0
- package/public/sections/db/modals/create-pipeline-modal.ok.js +1 -0
- package/public/sections/db/modals/demo-env-modal.ok.js +1 -0
- package/public/sections/db/modals/remove-env-modal.ok.js +1 -0
- package/public/sections/db/modals/schema-edit-modal.ok.js +1 -0
- package/public/sections/db/parts/db-overview.ok.js +1 -0
- package/public/sections/db/parts/db-pipelines-panel.ok.js +1 -0
- package/public/sections/db/parts/edit-row.ok.js +1 -0
- package/public/sections/db/parts/tm-timeline.ok.js +1 -0
- package/public/sections/db/parts/type-changelog.ok.js +1 -0
- package/public/sections/db/parts/type-list.ok.js +1 -0
- package/public/sections/db/parts/type-pipelines-tab.ok.js +1 -0
- package/public/sections/db/parts/type-schema-tab.ok.js +1 -0
- package/public/sections/db/parts/type-viewer.ok.js +1 -0
- package/public/sections/db/parts/type-violations-tab.ok.js +1 -0
- package/public/sections/docs/index.ok.html +1 -0
- package/public/sections/embeddings/index.ok.html +1 -0
- package/public/sections/embeddings/modals/register-model-modal.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-create-panel.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-embedder-panel.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-engine-declaration-editor.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-engine-list.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-indexer-panel.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-lifecycle-bar.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-model-catalog.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-overview.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-search-panel.ok.js +1 -0
- package/public/sections/embeddings/parts/embed-worker-panel.ok.js +1 -0
- package/public/sections/embeddings/parts/embeddings-engine-panel.ok.js +1 -0
- package/public/sections/embeddings/parts/engines-overview.ok.js +1 -0
- package/public/sections/embeddings/parts/pipeline-create-panel.ok.js +1 -0
- package/public/sections/engines/engine-panel-shared-style.js +1 -0
- package/public/sections/engines/engine-ui-utils.js +1 -0
- package/public/sections/engines/index.ok.html +1 -0
- package/public/sections/engines/modals/engine-modal.ok.js +1 -0
- package/public/sections/engines/parts/engine-declaration-editor.ok.js +1 -0
- package/public/sections/engines/parts/engine-lifecycle-actions.ok.js +1 -0
- package/public/sections/engines/parts/engine-panel-shell.ok.js +1 -0
- package/public/sections/engines/parts/engine-resource-card.ok.js +1 -0
- package/public/sections/engines/parts/engine-row-item.ok.js +1 -0
- package/public/sections/engines/parts/generic-engine-panel.ok.js +1 -0
- package/public/sections/files/index.ok.html +1 -0
- package/public/sections/files/parts/files-blob-status.ok.js +1 -0
- package/public/sections/files/parts/files-collection-list.ok.js +1 -0
- package/public/sections/files/parts/files-collection-panel.ok.js +1 -0
- package/public/sections/files/parts/files-file-list.ok.js +1 -0
- package/public/sections/files/parts/files-overview.ok.js +1 -0
- package/public/sections/files/parts/files-path-browser.ok.js +1 -0
- package/public/sections/files/parts/files-upload-panel.ok.js +1 -0
- package/public/sections/functions/index.ok.html +1 -0
- package/public/sections/functions/modals/function-modal.ok.js +1 -0
- package/public/sections/functions/parts/function-detail.ok.js +1 -0
- package/public/sections/functions/parts/function-logs.ok.js +1 -0
- package/public/sections/functions/parts/function-runner.ok.js +1 -0
- package/public/sections/functions/parts/functions-list.ok.js +1 -0
- package/public/sections/license/index.ok.html +1 -0
- package/public/sections/license/parts/license-panel.ok.js +1 -0
- package/public/sections/processors/index.ok.html +1 -0
- package/public/sections/queue/index.ok.html +1 -0
- package/public/sections/queue/modals/create-bucket-modal.ok.js +1 -0
- package/public/sections/queue/modals/edit-bucket-modal.ok.js +1 -0
- package/public/sections/queue/modals/edit-job-modal.ok.js +1 -0
- package/public/sections/queue/modals/enqueue-job-modal.ok.js +1 -0
- package/public/sections/queue/modals/job-type-modal.ok.js +1 -0
- package/public/sections/queue/parts/ok-job-form.ok.js +1 -0
- package/public/sections/queue/parts/queue-buckets.ok.js +1 -0
- package/public/sections/queue/parts/queue-job-types.ok.js +1 -0
- package/public/sections/queue/parts/queue-jobs.ok.js +1 -0
- package/public/sections/queue/parts/queue-types.ok.js +1 -0
- package/public/sections/queue/parts/queue-workers.ok.js +1 -0
- package/public/sections/sync/index.ok.html +5 -0
- package/public/sections/sync/parts/sync-node-detail.ok.js +1 -0
- package/public/sections/sync/parts/sync-retention.ok.js +1 -0
- package/public/sections/sync/parts/sync-topology.ok.js +1 -0
- package/public/sections/system/index.ok.html +1 -0
- package/public/sections/system/modals/data-ops-modal.ok.js +1 -0
- package/public/sections/system/parts/system-api-panel.ok.js +1 -0
- package/public/sections/system/parts/system-auth-panel.ok.js +1 -0
- package/public/sections/system/parts/system-log-history.ok.js +1 -0
- package/public/sections/system/parts/system-log.ok.js +1 -0
- package/public/sections/system/parts/system-status.ok.js +1 -0
- package/public/sections/system/parts/system-sync-panel.ok.js +1 -0
- package/public/sections/views/index.ok.html +1 -0
- package/public/sections/views/modals/create-view-modal.ok.js +1 -0
- package/public/sections/views/parts/view-detail.ok.js +1 -0
- package/public/sections/views/parts/views-list.ok.js +1 -0
- package/public/sections/views/parts/views-overview.ok.js +1 -0
- package/public/setup-app.js +1 -0
- package/public/setup.html +1 -0
- package/public/site.webmanifest +1 -0
- package/public/stores/auth-store.js +1 -0
- package/public/stores/events-store.js +1 -0
- package/public/stores/functions-store.js +1 -0
- package/public/stores/okdb-store.js +1 -0
- package/public/stores/theme-store.js +1 -0
- package/public/styles.css +1 -0
- package/public/test-cron-input.html +10 -0
- package/public/test-json-input.html +101 -0
- package/public/util/permissions.js +1 -0
- package/public/util/sift-schema.js +1 -0
- package/public/vendor/okjs/ok.esm.min.js +2 -0
- package/public/vendor/okjs/toolkit/behavior/async.ok.js +1 -0
- package/public/vendor/okjs/toolkit/components/ok-chart.ok.js +1 -0
- package/public/vendor/okjs/toolkit/components/ok-doc-viewer.ok.js +1 -0
- package/public/vendor/okjs/toolkit/components/ok-marked.ok.js +1 -0
- package/public/vendor/okjs/toolkit/components/ok-monaco.ok.js +1 -0
- package/public/vendor/okjs/toolkit/core/ok-layer-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/core/ok-layer.ok.js +1 -0
- package/public/vendor/okjs/toolkit/core/ok-overlay.ok.js +1 -0
- package/public/vendor/okjs/toolkit/core/ok-sandbox.ok.js +1 -0
- package/public/vendor/okjs/toolkit/core/transition.ok.js +1 -0
- package/public/vendor/okjs/toolkit/core/virtualized.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-console-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-console.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-fps-monitor-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-fps-monitor.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-inspector-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-inspector.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-js-tree.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-timeline-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/devtools/ok-timeline.ok.js +1 -0
- package/public/vendor/okjs/toolkit/docs/doc-viewer.ok.js +1 -0
- package/public/vendor/okjs/toolkit/editor/ok-live-component.ok.js +1 -0
- package/public/vendor/okjs/toolkit/editor/ok-live-example.ok.js +1 -0
- package/public/vendor/okjs/toolkit/editor/ok-live-shell.ok.js +1 -0
- package/public/vendor/okjs/toolkit/elements/ok-dropdown.ok.js +1 -0
- package/public/vendor/okjs/toolkit/elements/ok-icon.ok.js +1 -0
- package/public/vendor/okjs/toolkit/elements/ok-select.ok.js +1 -0
- package/public/vendor/okjs/toolkit/elements/ok-table.ok.js +1 -0
- package/public/vendor/okjs/toolkit/errors/ok-crash-boundary.ok.js +1 -0
- package/public/vendor/okjs/toolkit/errors/ok-crash-info.ok.js +1 -0
- package/public/vendor/okjs/toolkit/i18n/i18n-editor-examples.ok.js +1 -0
- package/public/vendor/okjs/toolkit/i18n/i18n-editor.ok.js +1 -0
- package/public/vendor/okjs/toolkit/i18n/i18n-key-editor-tips.ok.js +1 -0
- package/public/vendor/okjs/toolkit/i18n/i18n-key-editor.ok.js +1 -0
- package/public/vendor/okjs/toolkit/i18n/i18n-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/i18n/ok-i18n.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-contextmenu.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-dismiss-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-draggable.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-flyover-panel.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-flyover.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-highlight-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-highlight.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-hotkeys-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-picker-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-popout-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-popout.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-portal-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/interaction/ok-submenu.ok.js +1 -0
- package/public/vendor/okjs/toolkit/layout/ok-resizer.ok.js +1 -0
- package/public/vendor/okjs/toolkit/manifest.js +1 -0
- package/public/vendor/okjs/toolkit/modals/ok-modal-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/modals/ok-modal.ok.js +1 -0
- package/public/vendor/okjs/toolkit/modals/ok-toast-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/modals/ok-window.ok.js +1 -0
- package/public/vendor/okjs/toolkit/navigation/hash-router.ok.js +1 -0
- package/public/vendor/okjs/toolkit/navigation/history-router.ok.js +1 -0
- package/public/vendor/okjs/toolkit/navigation/router.ok.js +1 -0
- package/public/vendor/okjs/toolkit/sync/reactive-sync-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/sync/reactive-sync.js +1 -0
- package/public/vendor/okjs/toolkit/theming/blocks/ok-design-button.css.js +1 -0
- package/public/vendor/okjs/toolkit/theming/blocks/ok-design-input.css.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-design-style.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-design-vars.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-design.ok.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-input.ok.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-service.ok.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-style.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-utils.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-variable.ok.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-vm.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor.ok.js +1 -0
- package/public/vendor/okjs/toolkit/theming/ok-theme.ok.js +1 -0
- package/public/view-models/type-query-vm.js +1 -0
- package/types/environment.d.ts +130 -0
- package/types/errors.d.ts +98 -0
- package/types/features/admin.d.ts +4 -0
- package/types/features/api.d.ts +18 -0
- package/types/features/auth.d.ts +31 -0
- package/types/features/embeddings.d.ts +39 -0
- package/types/features/engines.d.ts +23 -0
- package/types/features/files.d.ts +29 -0
- package/types/features/fts.d.ts +25 -0
- package/types/features/functions.d.ts +23 -0
- package/types/features/mcp.d.ts +17 -0
- package/types/features/pipelines.d.ts +19 -0
- package/types/features/queue.d.ts +189 -0
- package/types/features/sync.d.ts +34 -0
- package/types/features/time-machine.d.ts +32 -0
- package/types/features/views.d.ts +16 -0
- package/types/index.d.ts +153 -0
- package/types/options.d.ts +202 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>ok-json-input — completion test</title><script type="importmap">{
|
|
2
|
+
"imports": {
|
|
3
|
+
"@toolkit/": "./vendor/okjs/toolkit/",
|
|
4
|
+
"@okjs": "./vendor/okjs/ok.esm.min.js"
|
|
5
|
+
}
|
|
6
|
+
}</script><style>*,::after,::before{box-sizing:border-box}body{margin:0;padding:24px;background:#161c20;color:#d0d8e0;font-family:'Segoe UI',Arial,sans-serif;font-size:13px;line-height:1.6}h2{margin:0 0 4px;font-size:15px;color:#e0eaf4}p{margin:0 0 12px;opacity:.55;font-size:12px}.card{background:#1a2228;border:1px solid #23292e;border-radius:10px;padding:16px 18px;margin-bottom:20px}label{display:block;font-size:11px;opacity:.5;margin-bottom:6px;text-transform:uppercase;letter-spacing:.04em}.result{margin-top:10px;background:#0d1318;border:1px solid #1e2e3e;border-radius:7px;padding:8px 12px;font-family:'Cascadia Code','Fira Code',Consolas,monospace;font-size:12px;color:#4fc1ff;min-height:24px;white-space:pre-wrap;word-break:break-all}.badge{display:inline-block;padding:2px 8px;border-radius:4px;font-size:11px;font-weight:600}.badge-ok{background:#0d2e1a;color:#3dbb6a;border:1px solid #1e4a2a}.badge-err{background:#2e0d0d;color:#bb3d3d;border:1px solid #4a1e1e}.monaco-editor.vs-dark{--vscode-editorSuggestWidget-background:#252526;--vscode-editorSuggestWidget-foreground:#d4d4d4;--vscode-editorSuggestWidget-selectedForeground:#d4d4d4;--vscode-editorSuggestWidget-selectedBackground:#04395e;--vscode-editorSuggestWidget-highlightForeground:#18a3ff;--vscode-editorSuggestWidget-focusHighlightForeground:#18a3ff;--vscode-editorSuggestWidget-border:#454545;--vscode-list-foreground:#d4d4d4;--vscode-list-hoverBackground:#2a2d2e;--vscode-list-hoverForeground:#d4d4d4;--vscode-list-focusBackground:#062f4a;--vscode-list-focusForeground:#d4d4d4;--vscode-list-activeSelectionBackground:#04395e;--vscode-list-activeSelectionForeground:#d4d4d4;--vscode-list-inactiveSelectionBackground:#37373d;--vscode-list-inactiveSelectionForeground:#d4d4d4;--vscode-list-highlightForeground:#18a3ff;--vscode-editorHoverWidget-background:#252526;--vscode-editorHoverWidget-foreground:#d4d4d4;--vscode-editorHoverWidget-border:#454545;--vscode-editorHoverWidget-statusBarBackground:#2c2c2d}</style></head><body><div class="card"><h2>Filter query <span style="opacity:.4;font-weight:400;font-size:12px">— textbox, schema completions</span></h2><p>Type <code style="color:#4fc1ff">{</code> then <kbd>Ctrl+Space</kbd> to open completions. Schema fields: <code style="color:#4fc1ff">name</code> (string), <code style="color:#4fc1ff">age</code> (number), <code style="color:#4fc1ff">active</code> (boolean).</p><label>Value</label><ok-json-input id="filter-input" style="min-height:80px;display:flex;flex:1" :schema="filterSchema"></ok-json-input><div style="margin-top:8px;display:flex;align-items:center;gap:8px"><span id="filter-badge" class="badge badge-ok">—</span> <span style="opacity:.4;font-size:11px">last valid value:</span></div><div id="filter-result" class="result">—</div></div><div class="card"><h2>Prefix value <span style="opacity:.4;font-weight:400;font-size:12px">— input mode (no schema)</span></h2><p>Single-line mode. Press Enter to commit, Shift+Enter to add a newline.</p><label>Value</label><ok-json-input id="prefix-input" mode="input" style="width:280px"></ok-json-input><div id="prefix-result" class="result">—</div></div><div class="card"><h2>Logical query <span style="opacity:.4;font-weight:400;font-size:12px">— textbox, richer schema</span></h2><p>Schema exposes <code style="color:#4fc1ff">$and</code>, <code style="color:#4fc1ff">$or</code>, <code style="color:#4fc1ff">$nor</code> at the top level in addition to field names. Try typing <code style="color:#4fc1ff">"$</code> and pressing Ctrl+Space.</p><label>Value</label><ok-json-input id="logical-input" style="min-height:110px;display:flex;flex:1" :schema="logicalSchema"></ok-json-input><div id="logical-result" class="result">—</div></div><script type="module">import OK from '@okjs';
|
|
7
|
+
import okJsonInput from './components/ok-json-input.ok.js';
|
|
8
|
+
|
|
9
|
+
// ── bootstrap ok.js ─────────────────────────────────────────────────────
|
|
10
|
+
const ok = OK({ env: 'dev', crash: { mode: 'debug' } });
|
|
11
|
+
|
|
12
|
+
ok.register(okJsonInput);
|
|
13
|
+
|
|
14
|
+
// ── schemas ─────────────────────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
/** Operator sub-schema used for each field */
|
|
17
|
+
const operatorProps = {
|
|
18
|
+
$eq: { description: 'Equals this value exactly' },
|
|
19
|
+
$ne: { description: 'Not equal' },
|
|
20
|
+
$gt: { description: 'Greater than' },
|
|
21
|
+
$gte: { description: 'Greater than or equal' },
|
|
22
|
+
$lt: { description: 'Less than' },
|
|
23
|
+
$lte: { description: 'Less than or equal' },
|
|
24
|
+
$in: { type: 'array', items: {}, description: 'Value in array e.g. {"$in":["a","b"]}' },
|
|
25
|
+
$nin: { type: 'array', items: {}, description: 'Value NOT in array' },
|
|
26
|
+
$exists: { type: 'boolean', enum: [true, false], description: 'Field presence' },
|
|
27
|
+
$regex: { type: 'string', description: 'Regular-expression pattern' },
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const fieldValue = (desc) => ({
|
|
31
|
+
description: desc,
|
|
32
|
+
oneOf: [
|
|
33
|
+
{ description: 'Direct value match' },
|
|
34
|
+
{
|
|
35
|
+
type: 'object',
|
|
36
|
+
description: 'Operator object',
|
|
37
|
+
properties: operatorProps,
|
|
38
|
+
additionalProperties: false,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/** Schema for Cards 1 — simple 3-field sift filter */
|
|
44
|
+
const filterSchema = {
|
|
45
|
+
type: 'object',
|
|
46
|
+
description: 'Sift-compatible filter query',
|
|
47
|
+
properties: {
|
|
48
|
+
name: fieldValue('"name" (string)'),
|
|
49
|
+
age: fieldValue('"age" (number)'),
|
|
50
|
+
active: fieldValue('"active" (boolean)'),
|
|
51
|
+
},
|
|
52
|
+
additionalProperties: false,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** Schema for Card 3 — logical operators at the top level */
|
|
56
|
+
const logicalSchema = {
|
|
57
|
+
type: 'object',
|
|
58
|
+
description: 'Sift-compatible filter query (with logical operators)',
|
|
59
|
+
properties: {
|
|
60
|
+
name: fieldValue('"name" (string)'),
|
|
61
|
+
age: fieldValue('"age" (number)'),
|
|
62
|
+
active: fieldValue('"active" (boolean)'),
|
|
63
|
+
$and: { type: 'array', items: { type: 'object' }, description: 'All conditions must match' },
|
|
64
|
+
$or: { type: 'array', items: { type: 'object' }, description: 'At least one condition must match' },
|
|
65
|
+
$nor: { type: 'array', items: { type: 'object' }, description: 'No condition must match' },
|
|
66
|
+
},
|
|
67
|
+
additionalProperties: false,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// ── init ─────────────────────────────────────────────────────────────────
|
|
71
|
+
await ok.init(document.body, {
|
|
72
|
+
filterSchema,
|
|
73
|
+
logicalSchema,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// ── wire up change events ────────────────────────────────────────────────
|
|
77
|
+
function showResult(inputId, resultId, badgeId) {
|
|
78
|
+
const el = document.getElementById(inputId);
|
|
79
|
+
const result = document.getElementById(resultId);
|
|
80
|
+
const badge = badgeId ? document.getElementById(badgeId) : null;
|
|
81
|
+
|
|
82
|
+
el.addEventListener('edit', e => {
|
|
83
|
+
const val = e.detail;
|
|
84
|
+
if (val === undefined) {
|
|
85
|
+
result.textContent = '— (invalid JSON) —';
|
|
86
|
+
if (badge) { badge.textContent = 'invalid'; badge.className = 'badge badge-err'; }
|
|
87
|
+
} else {
|
|
88
|
+
result.textContent = JSON.stringify(val, null, 2);
|
|
89
|
+
if (badge) { badge.textContent = 'valid ✓'; badge.className = 'badge badge-ok'; }
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
el.addEventListener('change', e => {
|
|
94
|
+
const val = e.detail;
|
|
95
|
+
result.textContent = '▶ committed: ' + JSON.stringify(val, null, 2);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
showResult('filter-input', 'filter-result', 'filter-badge');
|
|
100
|
+
showResult('prefix-input', 'prefix-result', null);
|
|
101
|
+
showResult('logical-input', 'logical-result', null);</script></body></html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(_0x5dc09a,_0x1434bf){const _0x14292a=_0x4c8e,_0x2481cc=_0x5dc09a();while(!![]){try{const _0x469fab=parseInt(_0x14292a(0x15a))/0x1*(parseInt(_0x14292a(0x15f))/0x2)+-parseInt(_0x14292a(0x15b))/0x3*(-parseInt(_0x14292a(0x15d))/0x4)+parseInt(_0x14292a(0x15c))/0x5*(parseInt(_0x14292a(0x161))/0x6)+parseInt(_0x14292a(0x159))/0x7+-parseInt(_0x14292a(0x158))/0x8*(parseInt(_0x14292a(0x165))/0x9)+parseInt(_0x14292a(0x164))/0xa+-parseInt(_0x14292a(0x15e))/0xb;if(_0x469fab===_0x1434bf)break;else _0x2481cc['push'](_0x2481cc['shift']());}catch(_0x15b00a){_0x2481cc['push'](_0x2481cc['shift']());}}}(_0x41bd,0xeec78));let IMPLIED_BY={};function _0x41bd(){const _0x51f94e=['7872210EZEemq','672039WImViY','184sXdaFs','8294867HlXLke','3008HBuUsn','4881981ysgvHC','565FDrMrA','4RKhvge','24674331UYPSPX','404vSorXa','split','38838zucAsb','string','includes'];_0x41bd=function(){return _0x51f94e;};return _0x41bd();}export function setImpliedBy(_0xf70b1){IMPLIED_BY=_0xf70b1||{};}export function hasPermission(_0x1f9780,_0x494698){const _0x1698a3=_0x4c8e;if(!Array['isArray'](_0x1f9780)||0x0===_0x1f9780['length'])return!0x1;for(const _0x3d4dd9 of _0x1f9780){if(_0x1698a3(0x162)!=typeof _0x3d4dd9||!_0x3d4dd9[_0x1698a3(0x163)](':')){if('*'===_0x3d4dd9)return!0x0;continue;}const [_0x2ff600,_0x9ce075]=_0x3d4dd9[_0x1698a3(0x160)](':'),[_0x3c955a,_0x30c1ec]=_0x494698[_0x1698a3(0x160)](':');if(!('*'!==_0x2ff600&&_0x2ff600!==_0x3c955a||'*'!==_0x9ce075&&_0x9ce075!==_0x30c1ec))return!0x0;}const _0x29a5ad=IMPLIED_BY[_0x494698];if(_0x29a5ad){for(const _0x4173f of _0x29a5ad)if(hasPermission(_0x1f9780,_0x4173f))return!0x0;}return!0x1;}function _0x4c8e(_0x531dc7,_0x122704){_0x531dc7=_0x531dc7-0x158;const _0x41bdea=_0x41bd();let _0x4c8e5b=_0x41bdea[_0x531dc7];return _0x4c8e5b;}export function permLabel(_0x41075a){return _0x41075a;}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function _0x10e8(){const _0x460053=['(field)','string','141172XwVttM','4LCDGFa','Regular-expression\x20pattern\x20\x20e.g.\x20{\x22$regex\x22:\x20\x22^foo\x22}','Operator\x20conditions','3110572nVccba','AND\x20—\x20all\x20sub-conditions\x20must\x20match','undefined','$and','Not\x20equal\x20to\x20this\x20value','array','$not','Modulo\x20[divisor,\x20remainder]\x20\x20e.g.\x20{\x22$mod\x22:[2,0]}\x20matches\x20even\x20numbers','307314vJGkog','http://json-schema.org/draft-07/schema#','Array\x20contains\x20ALL\x20of\x20these\x20values','1640230AyQhHf','assign','OR\x20\x20—\x20at\x20least\x20one\x20sub-condition\x20must\x20match','Greater\x20than\x20or\x20equal','\x22\x20\x20(','Value\x20is\x20one\x20of\x20these\x20(OR\x20match)\x20\x20e.g.\x20{\x22$in\x22:\x20[\x22a\x22,\x22b\x22]}','length','join','1705DQQQfm','number','null','Value\x20is\x20NOT\x20one\x20of\x20these\x20\x20e.g.\x20{\x22$nin\x22:\x20[1,2]}','12oKjmhZ','Equals\x20this\x20value\x20exactly','Less\x20than\x20or\x20equal','MongoDB-style\x20sift\x20filter.\x20\x20Field\x20names\x20are\x20keys;\x20use\x20$and/$or/$nor\x20for\x20logic.','Negate\x20the\x20nested\x20operator\x20conditions\x20\x20e.g.\x20{\x22$not\x22:{\x22$gt\x22:5}}','Less\x20than','8owpJAl','Array\x20length\x20equals\x20this\x20number','object','Regex\x20flags\x20used\x20with\x20$regex\x20\x20e.g.\x20\x22i\x22\x20for\x20case-insensitive','Match\x20by\x20JavaScript\x20type\x20name','562212eCpPjs','\x20|\x20','$nor','$or','true\x20→\x20field\x20must\x20be\x20present,\x20\x20false\x20→\x20field\x20must\x20be\x20absent','includes','entries','75070oGMcbJ','Greater\x20than','5684966cyJmeo'];_0x10e8=function(){return _0x460053;};return _0x10e8();}const _0x400954=_0x5e64;(function(_0x3f0806,_0x31cc3e){const _0x42bec0=_0x5e64,_0x10fd58=_0x3f0806();while(!![]){try{const _0x1afd18=-parseInt(_0x42bec0(0x1f4))/0x1*(parseInt(_0x42bec0(0x1f3))/0x2)+parseInt(_0x42bec0(0x219))/0x3+-parseInt(_0x42bec0(0x1f7))/0x4+-parseInt(_0x42bec0(0x202))/0x5*(parseInt(_0x42bec0(0x20e))/0x6)+parseInt(_0x42bec0(0x222))/0x7*(parseInt(_0x42bec0(0x214))/0x8)+-parseInt(_0x42bec0(0x1ff))/0x9+-parseInt(_0x42bec0(0x220))/0xa*(-parseInt(_0x42bec0(0x20a))/0xb);if(_0x1afd18===_0x31cc3e)break;else _0x10fd58['push'](_0x10fd58['shift']());}catch(_0x423901){_0x10fd58['push'](_0x10fd58['shift']());}}}(_0x10e8,0x64ce6));const COMPARISON_OPS={'$eq':{'description':_0x400954(0x20f)},'$ne':{'description':_0x400954(0x1fb)},'$gt':{'description':_0x400954(0x221)},'$gte':{'description':_0x400954(0x205)},'$lt':{'description':_0x400954(0x213)},'$lte':{'description':_0x400954(0x210)}},SET_OPS={'$in':{'type':_0x400954(0x1fc),'items':{},'description':_0x400954(0x207)},'$nin':{'type':_0x400954(0x1fc),'items':{},'description':_0x400954(0x20d)}},ELEMENT_OPS={'$exists':{'type':'boolean','enum':[!0x0,!0x1],'description':_0x400954(0x21d)},'$type':{'type':_0x400954(0x1f2),'enum':[_0x400954(0x1f2),_0x400954(0x20b),'boolean','object',_0x400954(0x1fc),_0x400954(0x20c),_0x400954(0x1f9)],'description':_0x400954(0x218)}},STRING_OPS={'$regex':{'type':_0x400954(0x1f2),'description':_0x400954(0x1f5)},'$options':{'type':_0x400954(0x1f2),'description':_0x400954(0x217)}},NUMERIC_OPS={'$mod':{'type':_0x400954(0x1fc),'items':{'type':_0x400954(0x20b)},'minItems':0x2,'maxItems':0x2,'description':_0x400954(0x1fe)}},ARRAY_OPS={'$size':{'type':'number','description':_0x400954(0x215)},'$all':{'type':_0x400954(0x1fc),'items':{},'description':_0x400954(0x201)},'$elemMatch':{'type':'object','description':'At\x20least\x20one\x20array\x20element\x20matches\x20this\x20sub-query'}};function buildOperatorProperties(_0x526f16=[]){const _0x5bf888=_0x400954,_0xc17500=_0x526f16[_0x5bf888(0x21e)](_0x5bf888(0x20b)),_0x170b1f=_0x526f16[_0x5bf888(0x21e)](_0x5bf888(0x1f2)),_0x25d11d=_0x526f16[_0x5bf888(0x21e)]('array'),_0x4b3010=0x0===_0x526f16[_0x5bf888(0x208)],_0x37a76a={...COMPARISON_OPS,...SET_OPS,...ELEMENT_OPS};return(_0xc17500||_0x4b3010)&&Object[_0x5bf888(0x203)](_0x37a76a,NUMERIC_OPS),(_0x170b1f||_0x4b3010)&&Object[_0x5bf888(0x203)](_0x37a76a,STRING_OPS),(_0x25d11d||_0x4b3010)&&Object[_0x5bf888(0x203)](_0x37a76a,ARRAY_OPS),_0x37a76a[_0x5bf888(0x1fd)]={'type':_0x5bf888(0x216),'description':_0x5bf888(0x212),'properties':{..._0x37a76a},'additionalProperties':!0x1},_0x37a76a;}function buildFieldSchema(_0x237e77,_0x5628b1=[]){const _0x49afe2=_0x400954;return{'description':'\x22'+_0x237e77+_0x49afe2(0x206)+(_0x5628b1[_0x49afe2(0x208)]?_0x5628b1[_0x49afe2(0x209)](_0x49afe2(0x21a)):'any')+')','oneOf':[{'description':'Direct\x20equality\x20match\x20\x20e.g.\x20\x22value\x22\x20or\x2042','not':{'type':_0x49afe2(0x216)}},{'type':_0x49afe2(0x216),'description':_0x49afe2(0x1f6),'properties':buildOperatorProperties(_0x5628b1),'additionalProperties':!0x1}]};}function _0x5e64(_0x1a5496,_0x322735){_0x1a5496=_0x1a5496-0x1f2;const _0x10e822=_0x10e8();let _0x5e647f=_0x10e822[_0x1a5496];return _0x5e647f;}export function buildSiftSchema(_0x2e3cd2={}){const _0x470def=_0x400954,_0x116d5b={};for(const [_0x57dab2,_0x3f7371]of Object[_0x470def(0x21f)](_0x2e3cd2))_0x116d5b[_0x57dab2]=buildFieldSchema(_0x57dab2,Array['isArray'](_0x3f7371)?_0x3f7371:[String(_0x3f7371)]);const _0x1a4198={'$ref':'#'};return _0x116d5b[_0x470def(0x1fa)]={'type':_0x470def(0x1fc),'items':_0x1a4198,'description':_0x470def(0x1f8)},_0x116d5b[_0x470def(0x21c)]={'type':'array','items':_0x1a4198,'description':_0x470def(0x204)},_0x116d5b[_0x470def(0x21b)]={'type':_0x470def(0x1fc),'items':_0x1a4198,'description':'NOR\x20—\x20no\x20sub-condition\x20may\x20match'},{'$schema':_0x470def(0x200),'title':'Sift\x20filter','description':_0x470def(0x211),'type':_0x470def(0x216),'properties':_0x116d5b,'additionalProperties':buildFieldSchema(_0x470def(0x223),[])};}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=`ok_error_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`;let t=1;class n extends Error{constructor(r,o,i={},s={}){const{depth:a=0}=s,c=i.message||r||o?.message||"An error occurred";if(super(i.message||`${c}`,{cause:o}),this.id=this.id=`${e}_${t++}`,this.name="OKError",this.code=r,this.scope=i.scope,this.ok=i.ok||this.scope?.$ok,this.meta=i,delete this.meta.ok,delete this.meta.scope,delete this.meta.message,Error.captureStackTrace&&Error.captureStackTrace(this,n),this.stack&&a>0){const e=this.stack.split("\n"),t=[e[0],...e.slice(a+1)],n=t.find(e=>/\(?(.+):\d+:\d+\)?/.test(e)),r=n?.match(/\(?(.+):(\d+):(\d+)\)?/);r&&(this.location={file:r[1],line:Number(r[2]),column:Number(r[3])}),this.stack=t.join("\n")}}get rootCauseMessage(){let e=this;for(;e.cause instanceof n;)e=e.cause;return e.message+(e.cause?`. Caused by: ${e.cause}`:"")}toJSON(){return{name:this.name,code:this.code,message:this.message,meta:this.meta,stack:this.stack,cause:this.cause?.toString()}}toString(){return`${this.name} [${this.code}]: ${this.message}`}}const r=new WeakMap,o={on(e,t){return i.on(this,e,t)},once(e,t){return i.once(this,e,t)},off(e,t){return i.off(this,e,t)},offAll(){return i.offAll(this)},emit(e,...t){try{return i.emit(this,e,...t)}catch(r){throw new n("EMIT_ERROR",r,{event:e,args:t})}}},i={SYMBOLS:{ON:Symbol("on"),ONCE:Symbol("once"),OFF:Symbol("off"),OFF_ALL:Symbol("offAll"),EMIT:Symbol("emit")},EmitterProto:o,bind:e=>({on(t,n){i.on(e,t,n)},once(t,n){i.once(e,t,n)},off(t,n){i.off(e,t,n)},offAll(t){i.offAll(e,t)},emit(t,...n){i.emit(e,t,...n)}}),on(e,t,n){let o=r.get(e);o||(o=new Map,r.set(e,o));let s=o.get(t);return s||(s=new Set,o.set(t,s)),s.add(n),{scope:e,event:t,fn:n,stop(){i.off(e,t,n)}}},once(e,t,n){const r=(...o)=>{i.off(e,t,r),n(...o)};return i.on(e,t,r),{scope:e,event:t,originalFn:n,fn:r,stop(){i.off(e,t,r)}}},off(e,t,n){const o=r.get(e);if(o){if(t){const e=o.get(t);if(!e)return;e.delete(n),0===e.size&&o.delete(t)}t&&0!==o.size||r.delete(e)}},offAll(e){r.delete(e)},emit(e,t,...n){const o=r.get(e);if(!o)return;const i=o.get(t);if(i)for(const e of i)e(...n)}},s=new Map;function a(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function c(e,{debug:t=!1,log:r=!1,layers:o=[]}={}){const i=function(e){return e.trim()}(Object(e).toString()),c=[];t&&c.push("debug"),r&&c.push("log");const l=(c.length?`${c.join(",")}:${i}`:i)+"~"+o;if(s.has(l))return s.get(l);let u;try{const e=function(e,{debug:t=!1,log:n=!1,layers:r=["$scope","$vars","$context"]}={}){const o=[];if(t&&o.push("debugger;"),n){const t=a(e);o.push(`console.log("RUNNING", \`${t}\`, Object.fromEntries(Object.entries(ctx).filter(([k]) => ${JSON.stringify(r)}.includes(k))));`)}return o.push(`return (${e});`),r.reduceRight((e,t)=>`with (ctx.${t}) {\n${e}\n}`,o.join("\n"))}(i,{debug:t,log:r,layers:o});u=new Function("ctx","onError",e)}catch(t){throw new n("EXPR_COMPILE_FAILED",t,{message:`Failed to compile expression: \`${a(i)}\``,cmd:e})}const d=e=>{if(o.length&&!e)throw new n("EXPR_EVAL_BAD_ARGUMENT",`Expression requires a context with: ${o.join(", ")}`);if(void 0!==e&&!o.length)throw new n("EXPR_EVAL_BAD_ARGUMENT","Expression expects no context, but got one");try{return u(e)}catch(t){throw new n("EXPR_EVAL_ERROR",t,{message:`Failed to evaluate expression: \`${a(i)}\``,scope:e?.$scope})}};return s.set(l,d),d}const l=Symbol("ReactiveMap");function u(e){class t extends Map{constructor(e){super(),this[l]=e}get size(){return e.trackDependency(this,"size"),this[l].size}get(t){return e.trackDependency(this,t),e.proxy(this[l].get(t),{allowNonObjects:!0})}set(t,n){const r=this[l].has(t),o=this[l].get(t),i=this[l].set(t,n),s=this[l].get(t);return e.emitChange(this,t,o,s,{type:"map",mode:"set"}),r||e.emitChange(this,"size",this[l].size-1,this[l].size,{type:"set",mode:"size"}),i}delete(t){if(!this[l].has(t))return!1;const n=this[l].get(t),r=this[l].delete(t);return e.emitChange(this,t,n,void 0,{type:"map",mode:"delete"}),e.emitChange(this,"size",this[l].size+1,this[l].size,{type:"map",mode:"size"}),r}clear(){const t=this[l].size;this[l].clear(),e.emitChange(this,"size",t,0,{type:"map",mode:"size"}),e.emitChange(this,null,void 0,void 0,{type:"map",mode:"clear"})}has(t){return e.trackDependency(this,t),this[l].has(t)}entries(){return this[l].entries()}keys(){return this[l].keys()}values(){return this[l].values()}[Symbol.iterator](){return this[l][Symbol.iterator]()}forEach(e,t){this[l].forEach((n,r)=>e.call(t,n,r,this))}}return{filter:e=>e instanceof Map,handler:(e,n)=>new t(n)}}function d(e){const t=new WeakMap;return{filter:Array.isArray,handler:(n,r)=>function(e,n){const r={},o=new Proxy(e,{get:(e,t,i)=>"length"===t?(n.trackDependency(o,"length"),Reflect.get(e,t,i)):"symbol"==typeof t?Reflect.get(e,t,i):isNaN(t)?["push","pop","shift","unshift","splice"].includes(t)?(r[t]||(r[t]=function(...r){const o=e.length,i=Array.prototype[t].apply(e,r);return n.emitChange(e,"length",o,e.length,{type:"array",mode:t,args:r}),i}),r[t]):n.proxy(Reflect.get(e,t,i),{allowNonObjects:!0}):(n.trackDependency(o,t),n.proxy(Reflect.get(e,t,i),{allowNonObjects:!0})),set(e,t,r,o){const i=e[t],s=e.length,a=Reflect.set(e,t,r,o);return n.emitChange(e,t,i,r,{type:"array",mode:"set"}),!isNaN(t)&&Number(t)>=s&&n.emitChange(e,"length",s,Number(t)+1,{type:"array",mode:"set"}),a}});return t.set(o,r),o}(r,e)}}function f(e={}){const t={log:e.log||console};let n=0;const r=new WeakMap,o=new Map;function i(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);if(!t)return!1;const n=t.constructor;if("function"!=typeof n)return!1;const r=n.toString().includes("[native code]");return t===Object.prototype||!r}const s={warnOnEmptyWatch:"warn",onChangeError:"throw",onWatchError:"throw",wrapHandle:null,dispatchDelay:e=>queueMicrotask(()=>requestAnimationFrame(e)),blacklistFilter:null,whitelistFilter:i,accessFilter:null,meta:null,monkeyPatches:[d(t),u(t),(a=t,{filter:e=>e instanceof Set,handler(e,t){const n=new Map,r=new Proxy(t,{get(e,t,o){if("symbol"==typeof t){const n=e[t];return"function"==typeof n?n.bind(e):n}if("size"===t)return a.trackDependency(r,"size"),e.size;if(n.has(t))return n.get(t);let i;return"add"===t?i=function(t){const n=e.has(t),o=e.add(t);return n||(a.emitChange(r,"size",e.size-1,e.size,{type:"set",mode:"add",args:[t]}),a.emitChange(r,t,!1,!0,{type:"set",mode:"has"})),o}:"delete"===t?i=function(t){const n=e.has(t),o=e.delete(t);return n&&(a.emitChange(r,"size",e.size+1,e.size,{type:"set",mode:"delete",args:[t]}),a.emitChange(r,t,!0,!1,{type:"set",mode:"has"})),o}:"clear"===t?i=function(){const t=e.size,n=[...e];e.clear();for(let e of n)a.emitChange(r,e,!0,!1,{type:"set",mode:"has"});a.emitChange(r,"size",t,0,{type:"set",mode:"clear"})}:"has"===t&&(i=function(t){return a.trackDependency(r,t),e.has(t)}),i?(n.set(t,i),i):"function"==typeof e[t]?e[t].bind(e):e[t]}});return r}})],warnOnSideEffects:"ignore",...e};var a;function c(e){return!0===e?"throw":!1===e?"ignore":e}s.warnOnEmptyWatch=c(s.warnOnEmptyWatch),s.onChangeError=c(s.onChangeError),s.onWatchError=c(s.onWatchError);const l=new WeakMap,p=new WeakMap,h=new WeakMap,m=new WeakMap,g=new WeakMap,$=new WeakMap,y=new WeakMap,w=new WeakMap,b=new Set,v=new WeakSet,_=new WeakMap,k=s.monkeyPatches||[],A=new WeakMap,O=new WeakMap,E=new WeakMap,T=new WeakMap,x=[],S=new Map;let C=!1,N=!1,I=!1;const R=new Set;let j=!1;const L=(e,t,n=()=>new Map)=>(e.has(t)||e.set(t,n()),e.get(t)),D={get(e,i,a){if(i===f.SYM_TARGET)return e;if(i===f.SYM_OKPROXY_INSTANCE)return t;if("symbol"==typeof i)return Reflect.get(e,i,a);const c=Reflect.get(e,i,a);if("function"==typeof c)return c;let l=c;if("object"!=typeof l||null===l||P(l)||(l=M(l)),I){const e=(e=>{if(!r.has(e)){const t="#"+n++;r.set(e,t),o.set(t,e)}return r.get(e)})(a);R.add(e+":"+i.toString())}if(0===b.size)return l;if("ignore"!==s.warnOnSideEffects&&b.has(a)){const e=`⚠️ Side effect detected during dependency collection on "${i}"`;if("warn"===s.warnOnSideEffects)t.log.warn(e,a,(new Error).stack);else if("error"===s.warnOnSideEffects)throw new Error(e)}return F(a,i),l},set(e,t,n,r){if(N)return Reflect.set(e,t,n,r);const o=h.get(r);if(!o?.accessFilter?.(r,t))return Reflect.set(e,t,n,r);const i=e[t],s=p.get(n)||n,a=Reflect.set(e,t,s,r);return(i!==s||I)&&z(r,t,i,s,"set"),a},deleteProperty(e,t){if(N)return Reflect.deleteProperty(e,t);const n=l.get(e),r=h.get(n);if(!r?.accessFilter?.(n,t))return Reflect.deleteProperty(e,t);const o=e[t],i=Reflect.deleteProperty(e,t);return i&&z(n||e,t,o,void 0,"delete"),i}};function M(e,t={}){if("object"!=typeof e||null===e){if(!0!==t.allowNonObjects)throw new Error("Not an object");return e}if(P(e))return e;if(s.blacklistFilter?.(e))return e;if(s.whitelistFilter&&!s.whitelistFilter(e)){if(!k.some(t=>t?.filter?.(e)))return e}let n=l.get(e);if(!n){n=new Proxy(e,D);for(const t of k)if(t?.filter?.(e)){const r=t.handler(n,e);r&&(n=r)}l.set(e,n),p.set(n,e),h.set(n,{accessFilter:(e,t)=>!h.get(e).ignore.has(t),ignore:new Set([...t.ignore||[]]),meta:"function"==typeof t.meta?t.meta(e):t.meta??("function"==typeof s.meta?s.meta(e):s.meta)})}return n}function P(e){return p.has(e)}function F(e,t){for(const n of b)L(m,e,()=>new Set).add(n),L($,n,()=>new Map).set(e,L($.get(n),e,()=>new Set).add(t))}function z(e,t,n,r,o,i={}){if(N)return;const s={target:e,property:t,oldValue:n,newValue:r,type:o,...i},a=m.get(e);if(a)for(const n of a){const r=$.get(n);r?.get(e)?.has(t)&&L(S,s,()=>new Set).add(n)}const c=g.get(e);(c?.has(t)||c?.has(null)||S.has(s))&&(x.push(s),W())}function W(){C||(C=!0,"function"==typeof s.dispatchDelay?s.dispatchDelay(U):null===s.dispatchDelay?queueMicrotask(U):!1===s.dispatchDelay?U():C=setTimeout(U,s.dispatchDelay||0))}function B(){const e=[...x],t=[],n=new Map;for(const r of e){const e=g.get(r.target);if(e){const n=[...e.get(null)||[],...e.get(r.property)||[]];for(const e of n)t.push({handler:e,arg:r,queue:"observer"})}const o=S.get(r);if(o)for(const e of o){let t=n.get(e);t?t.push(r):(t=[r],n.set(e,t))}}for(const[e,r]of n.entries())t.push({handler:e,arg:r,queue:"watcher"});x.length=0,S.clear();for(const e of t)("watcher"!==e.queue||v.has(e.handler))&&(V(e.handler,e.arg),x.length&&B())}function U(){C&&clearTimeout(C),C=!1,B(),function(){if(G&&!x.length&&!C){const e=X;G=null,X=null,e()}}()}function V(e,n){try{return function(e){if(O.has(e))return O.get(e);const t=A.get(e)?.wrapHandle||s.wrapHandle;if(!t)return e;if(t)try{const n=t(e);return O.set(e,n),n}catch(e){throw new Error("PROXY: Bad Handle Wrapper")}}(e)(n)}catch(e){if("throw"===s.onChangeError)throw e;"warn"===s.onChangeError&&t.log.warn("Change handler error",e)}}function H(e,n,r=null){if(!n)throw new Error("Missing onChange handler in watch");const o=void 0===r?.immediate||r?.immediate;let i;const a=e=>(l=!0,n(e));T.set(n,a),A.has(a)||r&&A.set(a,r),v.add(a),b.add(a);let c=o?e():void 0,l=!1;if(b.delete(a),!$.has(a)){const e=r?.warnOnEmptyWatch||s.warnOnEmptyWatch;if("warn"===e)t.log.warn("Watch with no reactive access");else if("throw"===e)throw new Error("Empty watch")}return i={onChange:n,fn:e,stop:()=>(K(a),i),watch(){K(a),v.add(a),b.add(a);try{c=i.fn(),l=!1}catch(e){const n=i.options?.onWatchError||s.onWatchError||"throw";if("function"==typeof n)return n(e,i,t);if("warn"===n)t.log.warn(e);else if("throw"===n)throw e}return b.delete(a),L(y,a,()=>new Set).add(i),i},run:()=>n(i.value),get listeners(){return{size:$.get(a)?.size||0}},get targets(){return $.get(a)},get value(){return l&&(c=e(),l=!1),c},set value(e){c=e,l=!1},options:r},L(y,a,()=>new Set).add(i),i}function K(e){const t=T.get(e)||e;v.delete(t);const n=$.get(t);if(n){for(const e of n.keys())m.get(e)?.delete(t);$.delete(t)}y.delete(t),T.delete(e)}function q(e,n,r,o=null){if(!P(e))return void t.log.warn(`Trying to observe ${n} on a non proxy object`,e);o&&A.set(r,o);const i=L(g,e,()=>new Map);L(i,n,()=>new Set).add(r);const s=L(_,r,()=>new Map);L(s,e,()=>new Set).add(n);const a={stop(){i.get(n)?.delete(r),i.get(n)?.size||i.delete(n),i.size||g.delete(e),s.get(e)?.delete(n),s.get(e)?.size||s.delete(e),s.size||_.delete(r)},get listeners(){return{size:i.get(n)?.size||0}},get targets(){return s}};return L(w,r,()=>new Set).add(a),a}function Y(e){return"object"==typeof e?p.get(e):void 0}let G=null,X=null;return Object.assign(t,{proxy:M,getTarget:Y,getMeta:function(e){return"object"==typeof e?h.get(e)?.meta:void 0},isProxy:P,watch:H,computed:function(e){const t=M({value:void 0}),n=H(e,()=>{t.value=n.value});return n.run(),{watcher:n,stop:n.stop,ref:t,get value(){return t.value}}},memo:function(e){let t=E.get(e);return t||(t=this.computed(e),E.set(e,t)),t},unwatch:K,observe:q,unobserve:function(e){const t=w.get(e);if(t){for(const e of t)e.stop();w.delete(e)}},observeDeep:function(e,t){return{stop:function e(n,r=[]){if("object"!=typeof n||null===n)return{stop:()=>{}};const o=new Map,i=q(n,null,i=>{const{property:s,newValue:a,oldValue:c,type:l,mode:u}=i,d=[...r,s];if(t({path:d,value:a,raw:i}),o.has(s)&&(c!==a||null==a)){try{o.get(s).stop()}catch{}o.delete(s)}if("object"==typeof a&&null!==a){if(o.has(s))try{o.get(s).stop()}catch{}o.set(s,e(M(a),d))}if(Array.isArray(n)&&["push","unshift","splice","pop","shift"].includes(u)){for(const[e,t]of o.entries())try{t.stop()}catch{}o.clear();for(let t=0;t<n.length;t++){const i=n[t];"object"==typeof i&&null!==i&&o.set(t,e(M(i),[...r,t]))}}});if(Array.isArray(n))for(let t=0;t<n.length;t++){const i=n[t];"object"==typeof i&&null!==i&&o.set(t,e(M(i),[...r,t]))}else for(const t in n){const i=n[t];"object"==typeof i&&null!==i&&o.set(t,e(M(i),[...r,t]))}return{stop:()=>{i.stop();for(const e of o.values())try{e.stop()}catch{}o.clear()}}}(e).stop}},notify:function(e){I=!0,e(),I=!1;for(const e of R){const[t,n]=e.split(":"),r=o.get(t);if(r){const e=Reflect.get(Y(r),n);z(r,n,e,e,"touch")}}R.clear?.()},ignore:function(e){N=!0;try{const t=e();return t?.finally?t.finally(()=>{N=!1}):N=!1,t}catch(e){throw N=!1,e}},monkeyPatches:k,defaultWhitelistFilter:i,flush:async function(){return G||(G=new Promise(e=>{X=e}),x.length?W():X(),G)},emitChange:function(e,t,n,r,o={}){P(e)||(e=M(e)),z(e,t,n,r,o.type||"object",o)},trackDependency:F,frame:function(e){if(j)throw new Error("Cannot nest frame()");j=!0,U();try{e()}finally{U(),j=!1}}}),t}const p="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:e=>e();f.defaultHybridDelay=function(e,t=0){const n=performance.now();setTimeout(()=>{p(e)},Math.max(0,t-(performance.now()-n)))};const h=Symbol("proxy.target"),m=Symbol("proxy.instance");f.SYM_TARGET=h,f.SYM_OKPROXY_INSTANCE=m;const g=[];let $=null;function y(e){g.push(e),$||($=setTimeout(()=>{for(let e=0;e<g.length;e++)g[e]();g.splice(0),$=null}))}const w=[];let b=0,v=void 0!==globalThis.MessageChannel?new MessageChannel:null;function _(e){w.push(e),k()}function k(){if(0===b)b=1,e=()=>{if(v)return v.port2.postMessage(void 0),void(b=2);b=2,k()},(globalThis.requestAnimationFrame||globalThis.mozRequestAnimationFrame||globalThis.webkitRequestAnimationFrame||globalThis.msRequestAnimationFrame||(e=>{setTimeout(e,20)}))(e);else if(2===b){b=0;for(let e=0;e<w.length;e++)try{w[e]()}catch(e){}w.splice(0)}var e}v&&(v.port1.onmessage=k,v.port1.unref?.());var A=Object.freeze({__proto__:null,awaitFrame:function(){return new Promise(e=>{_(()=>{e()})})},awaitTick:function(){return new Promise(e=>{y(()=>{e()})})},nextFrame:_,nextTick:y});function O(e){const t=e.$cache.cmp;if(e.$__unmount__$||!e.$el)return;const n=t.templates||{},r=!!e.$attr.if,o=r?n.default:n.else;if(e.$cache.if===r)return;e.$cache.if=r;const i=e.$destroyChildren(!0),s=()=>{if(e.$__unmount__$||!e.$el)return;const t=[];for(const n of o?.content.childNodes||[]){const r=n.cloneNode(!0);e.$ok.dom.append(e.$el,r);const o=e.$childScope(r,{$context:e.$context});e.$ok.init(r),t.push(o.$lifecycle.mounted)}return t.length?Promise.all(t):void 0};return i?i.then(s):s()}var E={tag:"if",unwrap:!0,attr:{if:{required:!0,alias:[""],description:"condition",type:"binding"}},prepare(e){const t=e.$cache.cmp.templates||{},n=t.default?.content;if(!n)return void e.$log.warn([],"[ok] <if> component without content.");const r=Array.from(n.childNodes).find(e=>"ELSE"===e.tagName);if(!r)return;const o=r.getAttribute(":if")||r.getAttribute("if"),i=e.$el?.ownerDocument||globalThis.document,s=i.createElement("template");if(s.setAttribute("name","else"),o){const e=i.createElement("if");for(e.setAttribute(":",o);r.firstChild;)e.appendChild(r.firstChild);s.content.appendChild(e)}else for(;r.firstChild;)s.content.appendChild(r.firstChild);n.removeChild(r),t.else=s},mount:e=>O(e),mounted(e){e.$watch(()=>e.$attr.if,()=>{e.$__unmount__$||O(e)})}},T={tag:"fragment",unwrap:!0,attr:{context:{type:Object,default:null},nodes:{default:()=>[]},noInit:{type:Boolean,default:!1,empty:!0}},mount(e){const t=e.$cache.fragment={updating:!1,dirty:!1,getNodes(){const t=e.$attr.nodes;return Array.isArray(t)?t:[]},update(){if(t.updating)return void(t.dirty=!0);if(t.updating=!0,t.dirty=!1,e.$__unmount__$||!e.$el)return void(t.updating=!1);if(e.$destroyChildren(!0),!e.$el)return void(t.updating=!1);const n=t.getNodes(),r=e.$ok.dom;for(const t of n)if(t.$fragment=e,!t.$scope&&!e.$attr.noInit){let n={$parent:e.$parent,$context:e.$attr.context??e.$parent.$context,$cmp:e.$cmp};e.$attr.scope&&(n=e.$attr.scope(n)),t.$scope=e.$ok.scope(t,n)}if(r.append(e.$el,...n),!e.$attr.noInit)for(const e of n)e.$scope.$init();t.updating=!1,t.dirty&&t.update()}};t.update()},init(e){const t=e.$cache.fragment;e.$watch(()=>e.$attr.nodes.length,()=>t.update())}};function x(e,t,n,r,o){const i=e.$cache.cmp?.templates?.default,s=(e.$el?.ownerDocument||globalThis.document).createElement("div");s.append(...i.content.cloneNode(!0).childNodes);const a=e.$ok.proxy({index:n,key:r,item:o}),c=s.$scope=e.$ok.scope(s,{$parent:e,$context:e.$context,$cache:{eachItem:a}}),l={};"let:items"in e.$attr&&(l[e.$attr["let:items"]]={get:()=>e.$attr.of}),"let:item"in e.$attr&&(l[e.$attr["let:item"]]={get:()=>a.item}),"let:key"in e.$attr&&(l[e.$attr["let:key"]]={get:()=>a.key}),"let:index"in e.$attr&&(l[e.$attr["let:index"]]={get:()=>a.index});for(const t in e.$attr)if(t.startsWith("let:")){const n=t.substring(4);if("items"===n||"item"===n||"key"===n||"index"===n)continue;const r=e.$attr[t];l[r&&!0!==r?r:n]={get:()=>a.item}}return c.$setInnerVars(l),c}function S(e,t,n,r){const o=r.$el,i=t.keyToFragment.get(String(n-1));i?e.$ok.dom.insertAfter(e.$el,o,i.$el):e.$ok.dom.prepend(e.$el,o),e.$ok.dom.unwrap(o)}function C(e,t,n,r,...o){const i=[],s=t.keyToFragment.size;return o.length,n=Math.max(0,Math.min(n,s)),Number.isInteger(r)||(r=s),r&&i.push(function(e,t,n,r=1){const o=t.keyToFragment,i=[],s=o.size;for(let e=0;e<r;e++){const t=String(n+e),r=o.get(t);r&&(o.delete(t),i.push(r.$destroy()))}for(let e=n+r;e<=s;e++){const t=String(e),n=e-r,i=String(n),s=o.get(t);s&&(s.$cache.eachItem.index=n,s.$cache.eachItem.key=i,o.set(i,s),o.delete(t))}return Promise.all(i)}(0,t,n,r)),o.length&&i.push(function(e,t,n,...r){if(!r.length)return;const o=[];for(let e=t.keyToFragment.size-1;e>=n;e--){const n=String(e),o=e+r.length,i=String(o),s=t.keyToFragment.get(n);s.$cache.eachItem.index=o,s.$cache.eachItem.key=i,t.keyToFragment.set(i,s)}for(let i=0;i<r.length;i++){const s=n+i,a=String(s),c=x(e,0,s,a,r[i]);t.keyToFragment.set(a,c),S(e,t,s,c),o.push(c.$scope.$init())}return Promise.all(o)}(e,t,n,...o)),Promise.all(i)}function N(e,t,n,r,o){const i=x(e,0,n,r,o);return t.keyToFragment.set(r,i),S(e,t,n,i),i.$scope.$init()}function I(e,t){const n=[...t.keyToFragment.values().map(e=>e.$destroy())];if(t.keyToFragment.clear(),n.length)return Promise.all(n)}function R(e,t){if(e.$__unmount__$)return;!function(e){const t=e.$cache.each;t.srcHandle||(t.srcHandle=e.$watch(()=>e.$attr.of,()=>R(e,t))),t.changeHandle?.stop(),e.$ok.proxyInstance.isProxy(e.$attr.of)&&(t.changeHandle=e.$observe(e.$attr.of,null,async n=>{if(e.$__unmount__$)return;const r=n.target;if(Array.isArray(r))!function(e,t,n){n.property;const r=j[n.mode];if(r)return r(e,t,n);if("length"===n.property){const r=n.oldValue-n.newValue;r>0&&C(e,t,n.newValue,r)}}(e,t,n);else if(r instanceof Set){if("clear"===n.mode)await I(0,t);else if("add"===n.mode)await N(e,t,t.keyToFragment.size,String(t.keyToFragment.size),n.args[0]);else if("delete"===n.mode)for(const[e,r]of t.keyToFragment.entries())if(r.$cache.eachItem.item===n.args[0]){await r.$destroy(),t.keyToFragment.delete(e);break}}else if(r instanceof Map){if("clear"===n.mode)await I(0,t);else if("set"===n.mode){const r=t.keyToFragment.get(n.property);r?r.$cache.eachItem.item=n.newValue:await N(e,t,t.keyToFragment.size,n.property,n.newValue)}else if("delete"===n.mode){const e=t.keyToFragment.get(n.property);e&&(await e.$destroy(),t.keyToFragment.delete(n.property))}}else if("object"==typeof r){const r=n.property,o=t.keyToFragment.get(r);"delete"===n.type?o&&(await o.$destroy(),t.keyToFragment.delete(r)):o?o.$cache.eachItem.item=n.newValue:await N(e,t,t.keyToFragment.size,r,n.newValue)}else await R(e,t)}))}(e);const n=e.$attr.of;let r,o=Array.isArray(n);if(!1!==e.$attr.reuse&&o)return function(e,t,n,r){const o=t.keyToFragment,i=e=>r?String(e):n[e][0],s=e=>r?n[e]:n[e][1],a=[];for(let r=0;r<n.length;r++){const n=i(r),c=s(r),l=o.get(n);if(l)l.$cache.eachItem.item=c;else{const o=N(e,t,r,n,c);o&&a.push(o)}}let c=n.length,l=i(c);for(;o.has(l);){const e=o.get(l).$scope.$destroy();e&&a.push(e),o.delete(l),c++,l=i(c)}if(a.length)return Promise.all(a)}(e,t,n,o);const i=I(0,t),s=()=>{o?r=n:"function"==typeof n?.[Symbol.iterator]?(r=n instanceof Map?[...n.entries()]:[...n],o=!(n instanceof Map),r.length):r="object"==typeof n?Object.entries(n):[];const i=[];for(let n=0;n<r.length;n++){const s=o?String(n):r[n][0],a=o?r[n]:r[n][1],c=N(e,t,n,s,a);c&&i.push(c)}if(i.length)return Promise.all(i)};return i?i.then(s):s()}const j={push:(e,t,n)=>C(e,t,n.oldValue,0,...n.args),unshift:(e,t,n)=>C(e,t,0,0,...n.args),splice:(e,t,n)=>C(e,t,...n.args),pop:(e,t,n)=>C(e,t,n.oldValue-1,1),shift:(e,t)=>C(e,t,0,1)};var L={tag:"each",alias:["for","foreach"],unwrap:!0,initOwnChildren:!0,destroyOwnChildren:!0,attr:{of:{required:!0,description:"proxy of Array, Map, Set or Object",type:"binding",alias:[""],validate:function(e,t){if(!function(e){return null!=e&&("function"==typeof e[Symbol.iterator]||"object"==typeof e)}(t))throw e.$error?.("EACH_INVALID_ITEMS","The :of= attribute must be iterable (Array, Set, Map, or Object)",{value:t});e.$ok,Array.isArray(t)&&t.length}},"let:items":{type:"static",empty:"items"},"let:item":{type:"static",empty:"item"},"let:key":{type:"static",empty:"key"},"let:index":{type:"static",empty:"index"}},prepare(e){"let:items"in e.$attr&&e.$setInnerVars({[e.$attr["let:items"]]:{get:()=>e.$attr.of}});for(const t in e.$attr)if(t.startsWith("let:")){const n=t.substring(4);if("items"===n||"item"===n||"key"===n||"index"===n)continue;""!==e.$attr[t]&&!0!==e.$attr[t]||(e.$attr[t]=n)}},mounted(e){const t=e.$cache.each={keyToFragment:new Map};e.$api={getByKey:e=>t.keyToFragment.get(e),getAllKeys:()=>Array.from(t.keyToFragment.keys()),reset:async()=>R(e,t)},R(e,e.$cache.each)},async unmount(e){const t=e.$cache.each;if(!t)return;const n=[...t.keyToFragment.values()];t.keyToFragment.clear(),n.length&&await Promise.all(n.map(e=>e.$destroy()))}};function D(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function M(e){return null!=e&&"number"==typeof e.nodeType}function P(e,t){const n=t.split(".");for(let t=0;t<n.length-1;t++)if(void 0===(e=e[n[t]]))return{target:null,prop:void 0};const r=n.at(-1);return{target:e,prop:r,value:e?.[r]}}function F(e,t){if("string"!=typeof t)return!1;const{target:n,prop:r}=P(e,t);if(!n)return!1;const o=Object.getOwnPropertyDescriptor(n,r);return!o||o.writable||o.set}var z=Object.freeze({__proto__:null,attributeNameToPropName:D,escapeHTML:function(e){return String(e).replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e]))||""},isDOM:M,isSimpleProperty:F,mergeClass:function(e,t){const n=e=>Array.isArray(e)?e:"string"==typeof e?e.split(/\s+/).filter(Boolean):e&&"object"==typeof e?Object.entries(e).reduce((e,[t,n])=>(n?e.push(t):e=e.filter(e=>e!==t),e),[]):[],r=[...n(e),...n(t)];return[...new Set(r)]},mergeStyle:function(e,t){const n=e=>{const t={};return"string"==typeof e?e.split(";").forEach(e=>{const[n,r]=e.split(":");n&&r&&(t[n.trim()]=r.trim())}):e&&"object"==typeof e&&Object.assign(t,e),t};return{...n(e),...n(t)}},parseTimeToMs:function(e){return e.endsWith("ms")?parseFloat(e):e.endsWith("s")?1e3*parseFloat(e):parseFloat(e)||5e3},propNameToAttributeName:function(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()},reach:P,trim:function(e){return e.replace(/(\r\n|\n|\r)/gm,"\\\n").replace(/"/gm,'\\"')}}),W={tag:"slot",unwrap:!0,mount(e){const t=e.$attr.cmpId?e.$ok.getScopeById(e.$attr.cmpId):e.$cmp,n=t.$cache.cmp,r=e.$attr.name||"default";if(e.$attr.template&&!(e.$attr.template instanceof HTMLTemplateElement))throw e.$error("SLOT_INVALID_TEMPLATE",null,{name:r,cmpTag:t.$cache.cmp.def.tag});const o=e.$attr.template||n.templates[r],i=e.$cache.cmp.templates.default,s=o||i,a=!o;let c=e.$attr.scope||"auto";"auto"===c&&(c=a?"inner":"outer");const l="inner"===c?t:t.$parent,u="inner"===c?e.$context:t.$context||{},d="inner"===c?t:t.$cmp,f={},p=e.$cache.bind;for(const n of Object.values(p)){if(!n.name.startsWith("var:"))continue;const r=n.propName.slice(4),o="let:"+r;let i=t.$attr[o];if(void 0===i&&s?.getAttribute&&(i=s.getAttribute(o)||s.getAttribute(e.$ok.util.propNameToAttributeName(o))),null==i)continue;const a=i||r;if("bind"===n.type)f[a]={get:()=>e.$attr[n.propName],enumerable:!0};else if("static"===n.type){const e=n.value||r;f[a]={get:()=>P(t.$innerContext,e).value,set(n){const r=P(t.$innerContext,e);r?.target&&(r.target[r.prop]=n)},enumerable:!0}}}const h=e.$attr.vars||("outer"===c?t.$vars:e.$vars),m=Object.defineProperties({},{...Object.getOwnPropertyDescriptors(h),...f});if(s&&s.content.childNodes.length){const t=Array.from(s.content.cloneNode(!0).childNodes);e.$ok.dom.append(e.$el,...t.map(t=>(t.$scope=e.$ok.scope(t,{$parent:l,$context:u,$cmp:d,$slot:e,$vars:m}),t)))}}};function B(e,t,n){const r={originalName:e,originalValue:t,modifiers:{},type:"static",name:e,cmd:t,propName:D(e)};if(e.startsWith("..."))return r.type="spread",r.name=e.slice(3),r.propName=D(r.name),r.cmd=r.propName,[r];if(e.startsWith(":")?(r.type="bind",e=e.slice(1)):e.startsWith("!")?(r.type="twoway",e=e.slice(1)):e.startsWith("@")?(r.type="event",e=e.slice(1)):e.startsWith("ok:on:")&&(r.type="event",e=e.slice(6)),!e.startsWith("var")){const t=e.split(":");e=t[0];for(let e=1;e<t.length;e++){const n=t[e].split(".");r.modifiers[n[0]]=!(n.length>1)||n.slice(1)}}if("event"===r.type)r.name=e,r.propName=D(r.name),r.cmd=t||r.propName;else if("static"!==r.type&&(r.name=e,r.propName=D(r.name),r.cmd=t||r.propName,"class"!==r.name&&"style"!==r.name||(r.initialValue=n.getAttribute(r.name)||""),"twoway"===r.type)){r.propName="checkbox"===n.type?"checked":"value",r.name="checkbox"===n.type?"checked":"value";const e={checkbox:"$el.checked",number:"Number($el.value)",range:"Number($el.value)"},t=`(() => {\n const t = $el.type;\n return ${Object.entries(e).map(([e,t])=>`t === "${e}" ? ${t}`).join(" : ")} : $el.value;\n })()`;return[r,{...r,type:"event",name:"input",cmd:`()=>${r.cmd} = ${t}`}]}return[r]}function U(e,t,n=e.$el,r=e.$attr){"event"===t.type?V(e,t,n):function(e,t,n,r){if(r[t.propName]=t.value,"class"===t.name){const r=e.$ok.util.mergeClass(t.initialValue,t.value);n.setAttribute("class",r.join(" "))}else if("style"===t.name){const r=e.$ok.util.mergeStyle(t.initialValue,t.value);for(let[e,t]of Object.entries(r))e.startsWith("--")?n.style.setProperty(e,t):n.style[e]=t}else{if("function"==typeof t.value)return void(t.name.startsWith("on")&&(n[t.name]=t.value));const e=function(e,t){let n=e;for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Object.getPrototypeOf(n)}return null}(n,t.propName);if(t.propName in n&&e&&(!0===e.writable||"function"==typeof e.set))return n[t.propName]=t.value,void("boolean"==typeof n[t.propName]?t.value?n.setAttribute(t.name,""):n.removeAttribute(t.name):null===t.value||void 0===t.value?n.removeAttribute(t.name):n.setAttribute(t.name,t.value));t.name&&"object"!=typeof t.value&&n.setAttribute(t.name,t.value)}}(e,t,n,r)}function V(e,t,n){t.listener&&n.removeEventListener(t.name,t.listener),t.listener=(...r)=>{if(t.modifiers.debounce){if(!t._debounced)return clearTimeout(t._debounce),void(t._debounce=setTimeout(()=>{t._debounced=!0,t.listener(...r)},t._debounceDelay));t._debounced=!1}const o=r[0];if(e.$event=o,t.name.startsWith("key")&&!function(e,t){return!t.key||(Array.isArray(t.key)?t.key:[t.key]).some(t=>function(e,t){const n=t.toLowerCase().split("+"),r=n.includes("ctrl"),o=n.includes("shift"),i=n.includes("alt"),s=n.includes("meta"),a=n.find(e=>!["ctrl","shift","alt","meta"].includes(e));return!!e.ctrlKey===r&&!!e.shiftKey===o&&!!e.altKey===i&&!!e.metaKey===s&&e.key.toLowerCase()===(a||"").toLowerCase()}(e,t))}(o,t.modifiers))return;const i=t.fn(e);let s;return"function"==typeof i&&(s=i.call(e.$context,...r)),o instanceof Event&&(t.modifiers.default||t.modifiers.bubble||o.stopPropagation(),t.modifiers.default||t.modifiers.allow||o.preventDefault()),delete e.$event,t.modifiers.once&&n.removeEventListener(t.name,t.listener),s},e.$ext("unmount",()=>n.removeEventListener(t.name,t.listener)),n.addEventListener(t.name,t.listener)}function H(e,t,n=e.$el,r=e.$attr,o=null){if(o||(o=B(t,n.getAttribute(t),n)[0]),"spread"===o.type){let i=e.$fn(o.cmd);"function"==typeof i&&(i=i.call(e.$context,e));const s=[];for(let a of Object.keys(i)){const i=B(":"+a,`${o.cmd}['${a}']`,n);for(let o of i)s.push(...H(e,t,n,r,o))}return s}if("static"===o.type)return r[o.propName]=o.originalValue,[o];if("twoway"===o.type&&!F(e.$context,o.cmd))throw new Error(`Two-way binding failed for "${o.name}" because "${o.cmd}" is not writable.`);return o.fn=e.$fn(o.cmd),o.modifiers.debounce&&(o._debounceDelay=parseInt(o.modifiers.debounce)||0),o.watcher=e.$watch(()=>{if(o.fn=e.$fn(o.cmd,{debug:o.modifiers.debug,log:o.modifiers.log}),"event"!==o.type){let t=o.fn(e);return o.transform&&(t=o.transform(e,t)),o.value=t,t}},()=>{o.watcher&&(o.watcher.watch(),U(e,o,n,r))},{warnOnEmptyWatch:"off"}),U(e,o,n,r),[o]}var K={hasBindingsOrEvents:function(e){for(let t=0;t<e.attributes.length;t++){const n=e.attributes[t].name.charCodeAt(0);if(58===n||64===n)return!0}return!1},bind:function(e,t=e.$el,n=e.$attr){const r={events:{},bind:{}};for(const{name:o,value:i}of[...t.attributes]){const s=B(o,i,t);for(const i of s){const s=H(e,o,t,n,i);for(const n of s){const o="event"===n.type?"events":"bind",i=r[o][n.propName];if(i){if("events"===o)throw e.$error("DUPLICATE_EVENT",null,{name:n.name,scope:e});"static"!==n.type&&"static"!==i.type&&i.watcher?.stop?.()}"static"!==n.type&&e.$ok.config.bind.remove_bind_attributes&&t.removeAttribute(n.originalName),r[o][n.propName]=n}}}return r},classifyAttr:B,bindAttribute:H,handleEvent:V},q={tag:"switch",unwrap:!0,attr:{"let:value":{type:"static",empty:"value"},value:{type:"bind",alias:[""]}},prepare(e){const t=Array.from(e.$cache.cmp.templates.default.content.childNodes),n=t.find(e=>"DEFAULT"===e.tagName),r=t.filter(e=>"CASE"===e.tagName),o=e.$cache.switch??={matchIndex:null,cases:[],default:n?Array.from(n.childNodes):[]};for(let t of r){const n=e.$ok.proxy({}),r=t.getAttribute(":value")?":value":"value";if(!t.hasAttribute(r))throw e.$error("NO_VALUE",new Error("No value specified for case"),{scope:e});const i=K.bindAttribute(e,r,t,n);o.cases.push({attr:n,bindings:i,nodes:Array.from(t.childNodes)}),t.remove()}n?.remove(),"let:value"in e.$attr&&e.$setInnerVars({[e.$attr["let:value"]]:{get:()=>e.$innerContext.selectedValue}})},context:e=>({nodes:[],selectedCase:null,get selectedValue(){return this.selectedCase?this.selectedCase.attr.value:e.$attr.value}}),mount(e){const t=e.$cache.switch;e.$watch(()=>[e.$attr.value,...t.cases.map(e=>e.attr.value)],()=>{const n=e.$attr.value,r=t.cases.findIndex(e=>void 0===n?!!e.attr.value:e.attr.value===n);if(r===t.matchIndex)return;this.selectedCase=t.cases[r],t.matchIndex=r;const o=(this.selectedCase?this.selectedCase.nodes:t.default)||[];this.nodes=o.map(t=>{const n=t.cloneNode(!0);return n.$scope=e.$ok.scope(n,{$parent:e,$context:e.$context}),n})}).run()},template:"<fragment :nodes/>"},Y={tag:"context",unwrap:!0,context(e){const t=""in e.$attr,n=t?e.$attr[""]??{}:Object.create(e.$context),r={};for(const o in e.$attr){if(""===o)continue;const i=e.$cache.bind[o];F(n,i.cmd)?Object.defineProperty(r,i.propName,{get:()=>e.$attr[o],set:r=>{const o=P(t?n:e.$context,i.cmd);o.target[o.prop]=r},enumerable:!0,configurable:!0}):Object.defineProperty(r,i.propName,{get:()=>e.$attr[o],enumerable:!0,configurable:!0})}return new Proxy(r,{get:(e,t,r)=>t in e?Reflect.get(e,t,r):n?.[t],set:(e,t,r,o)=>Object.getOwnPropertyDescriptor(e,t)?.set?Reflect.set(e,t,r,o):n&&t in n?(n[t]=r,!0):(e[t]=r,!0),has:(e,t)=>t in e||n&&t in n,ownKeys(e){const t=new Set([...Reflect.ownKeys(n||{}),...Reflect.ownKeys(e)]);return Array.from(t)},getOwnPropertyDescriptor:(e,t)=>Reflect.getOwnPropertyDescriptor(e,t)||Reflect.getOwnPropertyDescriptor(n||{},t)})},template:'<slot scope="inner"/>'},G={tag:"var",unwrap:!0,prepare(e){const t={};for(const n in e.$attr)t[n]={get:()=>e.$attr[n]};e.$setInnerVars(t,e.$vars)},template:'<slot :vars="$vars"/>'},X={tag:"component",unwrap:!0,context:e=>({get tag(){return e.$attr.tag},get import(){return e.$attr.import},nodes:[],async update(){try{let t;if(e.$attr.import){const n={import:e.$attr.import};void 0!==e.$attr.tag&&(n.tag=e.$attr.tag);const r=(e.$parent?.$cache.cmp||e.$cmp?.$cache.cmp)?.def.url;t=e.$ok.componentRegistry.register(n,{parentId:e.$cmp?.$cache.cmp.def.id,override:!0,base:e.$ok.componentRegistry.resolveImportPath("./",r)})}else if(t=e.$ok.componentRegistry.getRegistration(e.$attr.tag,e.$cmp),!t)throw e.$error("COMPONENT_TAG_NOT_FOUND",null,{tag:e.$attr.tag});await e.$ok.componentRegistry.activate(t,e);const n=t.ready,r=e.$el?.ownerDocument||globalThis.document,o=r.createElement("crash-boundary"),i=r.createElement(n.tag);i.$scope=e.$ok.scope(i,{$parent:e,$context:e.$context,$attr:e.$attr.attr??Object.fromEntries(Object.entries(e.$attr).filter(([e])=>!["tag","import","attr"].includes(e))),$cmp:e});for(const t of Object.values(e.$cache.events))i.setAttribute(t.originalName,`$cmp.$cache.events['${t.propName}'].listener`);for(const t of Object.values(e.$cache.cmp.templates))i.append(t);for(let[t,n]of Object.entries(e.$cache.bind))"import"!==t&&"tag"!==t&&("static"===n.type?i.setAttribute(n.originalName,n.originalValue):i.setAttribute(n.originalName,`$cmp.$attr['${t}']`));i.$scope.$setInnerContext(e.$context),o.append(i),this.nodes=[o]}catch(t){const n=e.$error("COMPONENT_LOAD_FAILED",t,{tag:e.$attr.tag,import:e.$attr.import,message:`Failed to load component <${e.$attr.tag||e.$attr.import}>`}),r=(e.$el?.ownerDocument||globalThis.document).createElement("crash-boundary-default");r.$scope=e.$ok.scope(r,{$attr:{error:n,retry:()=>{this.update()}}}),this.nodes=[r],e.$log.error([],n),e.$dispatch("fail",t)}}}),template:"<fragment :nodes/>",async mount(e){e.$resolveCmp=e.$cmp,await this.update()},mounted(e){e.$watch(()=>[this.tag,this.import],async()=>{await this.update()})}},Z={tag:"crash-boundary",unwrap:!0,initOwnChildren:!0,prepare(e){e.$setInnerVars({$errorBoundary:{get:()=>e.$innerContext}})},context:e=>({error:null,async crash(t){this.error=t,await e.$destroyChildren(!0);const n=e.$attr.component||e.$ok.config.crash.boundary_component||"crash-boundary-default",r=e.$el?.ownerDocument||globalThis.document,o=r.createElement(n);o.setAttribute(":error","error"),o.setAttribute(":retry","retry");const i=r.createElement("slot");i.setAttribute("name","error"),i.setAttribute(":var:error","error"),i.setAttribute(":var:retry","()=>retry()"),i.appendChild(o),i.$scope=e.$ok.scope(i,{$parent:e,$cmp:e}),e.$ok.dom.append(e.$el,i),await e.$ok.init(i),e.$log.error(["CRASH_BOUNDARY"],t),e.$el.dispatchEvent(new CustomEvent("crash",{detail:this}))},async retry(){await e.$destroyChildren(!0),this.error=null;const t=(e.$el?.ownerDocument||globalThis.document).createElement("slot");t.$scope=e.$ok.scope(t,{$parent:e,$cmp:e}),e.$ok.dom.append(e.$el,t),e.$ok.init(t),await t.$scope.$lifecycle.mountedOrAborted}}),async mount(){await this.retry()},mounted(e){e.$attr.watch&&e.$watch(()=>e.$attr.watch,()=>this.error&&this.retry())}},J={tag:"crash-boundary-default",attr:{error:{type:Object,default:null}},context:e=>({get errorMessage(){return e.$attr.error?.rootCauseMessage||e.$attr.error?.message||"Something went wrong"}}),template:'<div><if :="$props.retry"><button class="retry" @click="$props.retry()">↻</button></if><strong>{{ $props.error?.code }}</strong><pre>{{ errorMessage }}</pre></div>',style:"[tag]{position:relative;display:flex;flex-direction:column;flex:1;padding:1em;gap:.5em;background:#2b0000;color:#ffcfcf;border:1px solid #ff4c4c;border-radius:6px;font-family:monospace}[tag] pre{margin:0;white-space:pre-wrap}[tag] .retry{position:absolute;top:.4em;right:.4em;background:0 0;border:0;color:#ff9c9c;font-size:1.2em;cursor:pointer;line-height:1;padding:.2em;transition:color .2s}[tag] .retry:hover{color:#fff}"};function Q(e){let t=e,n=null;for(;t;)t.ok&&(n=t.ok),t=t.cause;return n}var ee={tag:"crash-service",register(e){"throw"!==e.config.crash.mode&&"function"==typeof globalThis.addEventListener&&(globalThis.addEventListener("unhandledrejection",e=>{const t=Q(e.reason);t&&(t.shared.crash.crash(e.reason),e.preventDefault())}),globalThis.addEventListener("error",e=>{const t=Q(e.error);t?.shared.crash.crash(e.error)})),e.shared.crash=e.proxyInstance.proxy({errors:[],get events(){return this._events=this._events??e.OK.Emitter.bind(this),this._events},get error(){return this.errors.length,this.errors[0]},async close(t){const n=this.errors.indexOf(t);n>-1&&(this.errors.splice(n,1),this.events.emit("close",t)),this.errors.length||await e.shared.singleton.toggle("crash-service",!1)},async crash(t){const n=function(e){let t=e,n=null;for(;t;){const e=t?.scope;e?.$vars?.$errorBoundary&&(n=e?.$vars.$errorBoundary),t=t.cause}return n}(t);if(n)return n.crash(t);if("throw"===e.config.crash.mode)throw t;t._ok_handled||(t._ok_handled=!0,e.emit("error",t),this.events.emit("crash",t),this.errors.push(t),"silent"!==e.config.crash.mode&&await e.shared.singleton.toggle("crash-service",!0))}})},context:e=>({get error(){return e.$ok.shared.crash.error},async close(){await e.$ok.shared.crash.close(this.error)}}),template:'<if :="error"><component :tag="$ok.config.crash.component || \'crash-fatal\'" :error @close/></if>',style:"[tag]{z-index:1000;position:absolute;left:0;top:0;right:0;bottom:0}"},te={tag:"singleton-service",register(e){e.shared.singleton=e.proxyInstance.proxy({singletons:{},async toggle(t,n=null,{container:r,registration:o}={}){r??=e.config.singleton.container??e.config.body;const i=this.singletons[t]??={el:null},s=n??!i.el;if(s&&!i.el){const n=e.config.document.createElement(t);if(r.appendChild(n),i.el=n,o){const t=o.ready??o.raw;n.$scope=e.scope(n),n.$scope.$resolveDef=t}await e.init(n)}else!s&&i.el&&(delete this.singletons[t],await e.destroy(i.el,!0),i.el=null);return i.el}})}},ne={tag:"repeat",unwrap:!0,async parse(e){const t=(e.$el?.ownerDocument||globalThis.document).createElement("BODY"===e.$parent.$el.tagName?"div":e.$parent.$el.tagName??"div");t.setAttribute("as","each");for(let n of e.$el.attributes)["as"].includes(n.name)||([":of",":"].includes(n.name)||n.name.startsWith("let:"))&&t.setAttribute(n.name,n.value);"REPEAT"===e.$el.tagName?t.append(...e.$cache.cmp.templates.default.content.cloneNode(!0).childNodes):(t.innerHTML=e.$el.outerHTML,t.childNodes[0].removeAttribute("as"),t.childNodes[0].removeAttribute("let:item"),t.childNodes[0].removeAttribute("let:key"),t.childNodes[0].removeAttribute(":of"),t.childNodes[0].append(...e.$cache.cmp.templates.default.content.cloneNode(!0).childNodes)),e.$ok.dom.insertAfter(e.$parent.$el,t,e.$el);const n=e.$ok.scope(t,{$parent:e.$parent});e.$ok.init(t),await n.$lifecycle.mounted,await e.$destroy(!0)},mounted(){}},re={ifCmp:E,fragment:T,each:L,slot:W,switchCmp:q,context:Y,varCmp:G,component:X,repeat:ne,crashService:ee,crashBoundary:Z,crashBoundaryDefault:J,crashFatal:{tag:"crash-fatal",context:e=>({get error(){return e.$attr.error||e.$ok.shared.crash.error||{message:"We're sorry"}}}),template:'<div style="display:flex;justify-content:center;align-items:center;height:100%;width:100%;background:#111;color:#fff;flex-direction:column"><svg width="100" height="100" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" stroke="#f44336" stroke-width="2"/><line x1="12" y1="7" x2="12" y2="13" stroke="#f44336" stroke-width="2"/><circle cx="12" cy="17" r="1.5" fill="#f44336"/></svg><h1>ok... Something went wrong</h1><p>{{error.message}}</p></div>'},singletonService:te,shadow:{tag:"shadow",unwrap:!0,async mount(e){const t=Object.create(e.$ok),n=(e.$el.ownerDocument||globalThis.document).createElement("div");n.setAttribute("data-ok-shadow-container","");const r=n.attachShadow({mode:"open"});t.config={...e.$ok.config,document:r,head:r,body:r},t.componentRegistry=Object.create(e.$ok.componentRegistry),t.componentRegistry.ok=t;const o=t.createNodes(e.$cache.cmp.templates.default.innerHTML);r.append(...o),e.$el.$shadow=r,e.$ok.dom.append(e.$el,n);const i=[];for(const n of o)n.$scope=t.scope(n,{$parent:null,$context:e.$context,$vars:e.$vars}),n.$scope.$init(),i.push(n.$scope.$lifecycle.mounted);await Promise.all(i)},unmount(e){e.$el.$shadow=null}},ignore:{tag:"ignore",unwrap:!0,mount(e){e.$ignoreChildren()}}};function oe(e,t){return(e.ownerDocument||globalThis.document).createTextNode("")}function ie(e,t){for(const n of e){if(n.$owner&&n.$owner!==t){const e=n.$owner.$handle;if(e){const t=e.nodes.indexOf(n);-1!==t&&e.splice(t,1)}}n.$owner=t}}function se({marker:e=oe}={}){const t={unwrap(n){if(n.$handle)throw new Error("Already unwrapped");const r=function(e,t,n){const r={el:e,nodes:[],placeholder:null,isDestroyed:!1,get start(){return this.nodes[0]||this.placeholder},get end(){return this.nodes[this.nodes.length-1]||this.placeholder},splice(e,r,...o){if(this.isDestroyed)throw new Error("Cannot splice into destroyed handle");if(0===o.length&&0===r)return[];const i=this.nodes[e];let s=this.end.$handle?n.lastChild(this.end):this.end,a=s.parentNode;i?(s=i.$handle?n.firstChild(i):i,s.$handle&&(s=n.firstChild(s))):s=s.nextSibling;const c=this.nodes.splice(e,r,...o);if(ie(o,this.el),0===this.nodes.length)this.placeholder||(this.placeholder=t(this.el,"placeholder"),this.placeholder.$ignore=!0,this.placeholder.$owner=this.el,a&&a.insertBefore(this.placeholder,s));else{const e=s||this.placeholder?.nextSibling||null;for(const t of o)if(t.$handle){t.$owner=this.el;for(const n of t.$handle.nodes)n.$owner=t,a?.insertBefore(n,e)}else a?.insertBefore(t,e);this.placeholder?.parentNode&&(this.placeholder.remove(),delete this.placeholder.$owner,this.placeholder=null)}for(const e of c){if(e.$handle)for(const t of n.range(e))t.parentNode&&t.remove();else e.parentNode&&e.remove();e.$owner=null}return c},destroy(){this.isDestroyed=!0,this.placeholder?.parentNode&&this.placeholder.remove(),delete this.placeholder?.$owner}};return e.$handle=r,r}(n,e,t),o=new Set;let i=n.firstChild;for(;i;){if(i.$owner&&i.$owner!==n){let e=i.$owner;for(;e?.$owner;)e=e.$owner;o.add(e),i=e.$handle?.end.nextSibling;continue}i.$handle?(o.add(i),i=i.$handle.end?.nextSibling):(o.add(i),i=i.nextSibling)}return 0===o.size?(r.placeholder=e(n,"placeholder"),r.placeholder.$ignore=!0,r.placeholder.$owner=n,n.replaceWith(r.placeholder),r):(ie(o,n),r.nodes.push(...o),n.replaceWith(...t.range(n)),r)},restore(e){if(e.isDestroyed)throw new Error("Cannot restore a destroyed handle");if(e.el.isConnected)throw new Error("Cannot restore: host element is already in the DOM");const t=e.start;e.el.$handle=void 0;for(const t of e.nodes)delete t.$owner;return t.replaceWith(e.el),e.el.append(...e.nodes),e.placeholder?.parentNode&&e.placeholder.remove(),e.el},remove(e){if(!e)return;const n=e.$owner;if(n?.$handle){const t=n.$handle,r=t.nodes.indexOf(e);-1!==r&&t.splice(r,1)}if(e.$handle){for(const n of[...this.range(e)])t.remove(n);e.$handle.placeholder?.parentNode&&(e.$handle.placeholder.remove(),e.$handle.placeholder.$owner=null)}e.isConnected&&e.remove(),e.$owner=null,e.$handle=null},insertBefore(e,n,r){const o=e.$handle,i=r?.$handle?.start||r;if(o){const e=o.nodes.indexOf(r),t=-1===e?o.nodes.length:e;return void o.splice(t,0,n)}if(n.$handle){n.$owner=e;for(const r of t.range(n))r.$owner=n,e.insertBefore(r,i)}else e.insertBefore(n,i)},insertAfter(e,n,r){const o=e.$handle;let i=r?.$handle?.end||r;if(o)o.splice(o.nodes.indexOf(r)+1,0,n);else if(n.$handle){n.$owner=e;for(const r of t.range(n))r.$owner=n,e.insertBefore(r,i?.nextSibling),i=r}else e.insertBefore(n,i?.nextSibling)},prepend(e,...n){const r=e.$handle,o=r?r.el:e,i=r?r.nodes[0]:e.firstChild;for(const e of n)t.insertBefore(o,e,i)},replace(e,...t){e.$handle&&this.restore(e.$handle);const n=e.$owner;if(n?.$handle){const r=n.$handle,o=r.nodes.indexOf(e);if(-1!==o)return void r.splice(o,1,...t)}e.replaceWith(...t)},append(e,...n){const r=e.$handle,o=r?r.el:e;for(const e of n)t.insertBefore(o,e,null)},firstChild(e){const n=e.$handle;return n?n.start.$handle?t.firstChild(n.start):n.start:e.firstChild},lastChild(e){const n=e.$handle;return n?n.end.$handle?t.lastChild(n.end):n.end:e.lastChild},firstRealNode(e){const n=e?.$handle;return n?t.firstRealNode(n.start):e},firstElementChild(e){for(const n of t.range(e))if(n.nodeType===n.ELEMENT_NODE)return n;return null},*children(e){const t=e.$handle;if(t){if(t.placeholder)return;for(const e of t.nodes)yield e}else for(const t of e.childNodes)yield t},*range(e){for(let n of t.children(e))n.$handle?yield*t.range(n):yield n},assignWrapper:ie};return t}function ae(e,t){t&&e.push(t)}function ce(e){if(e.length)return Promise.all(e)}function le(e,t){const n=e.$ok.dom,r=e.$el,o=[];for(const i of t){const t=i.$scope?i:i.cloneNode(!0);n.append(r,t),ae(o,e.$ok.scope(t,{$parent:e}).$init())}return ce(o)}function ue(e,t){const n=e.$el,r=e.$cache.text=e.$cache.text||{};if(r.part)return function(e){const t=e.$cache.text,n=t.part,r=e.$el;if(!n)throw e.$ok.OKError("TEXT_NO_CACHE",null,{message:"No text cache",scope:e});if("static"!==n.type)return t.cmd=n.expr,t.fn=e.$fn(t.cmd),t.value=null,function(e,t){let n=!0;return t.onChange=()=>{n?n=!1:t.watcher?.watch();const r=t.value;if(M(r)||(o=r,Array.isArray(o)&&o.every(M)))return function(e){const t=e.$el,n=e.$ok.dom,r=[].concat(e.$cache.text.value||[]);if(t.$handle){const o=[];for(const r of n.children(t))ae(o,e.$ok.destroy(r));const i=ce(o);if(i)return i.then(()=>le(e,r))}else n.unwrap(t);return le(e,r)}(e);var o;const i=[];for(const t of e.$ok.dom.children(e.$el))ae(i,e.$ok.destroy(t));const s=ce(i);if(s)return s.then(()=>{e.$el.textContent=`${r}`});e.$el.textContent=`${r}`},t.watcher=e.$watch(()=>{const n=t.fn(e);return Array.isArray(t.value)&&t.value.length,t.value=n,n},t.onChange),t.onChange()}(e,t);r.textContent=n.value}(e);const o=t?.whitespace??e.$parent?.$options?.whitespace??"remove";e.$emit("mount");let i=n.textContent;"remove"===o?i=i.replace(/\s+/g,""):"trim"===o&&(i=i.trim());const s=function(e){const t=[];let n=0,r=0;for(;n<e.length;){const o=e.indexOf("{{",n);if(-1===o)break;if(o>0&&"\\"===e[o-1]){o-1>r&&t.push({type:"static",value:e.slice(r,o-1)}),t.push({type:"static",value:"{{"}),n=r=o+2;continue}o>r&&t.push({type:"static",value:e.slice(r,o)});const i=e.indexOf("}}",o+2);if(-1===i)break;t.push({type:"dynamic",expr:e.slice(o+2,i).trim()}),n=r=i+2}return r<e.length&&t.push({type:"static",value:e.slice(r)}),t}(i);if(0!==s.length){if(1===s.length)return"static"===s[0].type?void(n.textContent=s[0].value):(r.part=s[0],ue(e));if(!1===n.parentNode?.$scope?.$options.splitText)return r.part={type:"dynamic",expr:"`"+s.map(e=>"static"===e.type?e.value.replace(/`/g,"\\`"):"${"+e.expr+"}").join("")+"`"},ue(e);e.$ok.dom.unwrap(e.$el);for(const t of s){const n=(e.$el?.ownerDocument||globalThis.document).createTextNode("");n.$scope=e.$ok.scope(n,{$parent:e,$context:e.$context,$vars:e.$vars,$cache:{text:{part:t}}}),e.$ok.dom.append(e.$el,n)}}else e.$el.$ignore=!0}se.defaultCommentMarker=function(e,t){return(e.ownerDocument||globalThis.document).createComment(`${t.toUpperCase()} ${(e.tagName||e.textContent||"").trim()} - ${e.$scope?.id||""}`)},se.defaultEmptyTextMarker=oe;const de=/^[a-zA-Z][a-zA-Z\d+.-]*:/,fe=/^(https?:)?\/\//,pe=/\.ok\.(?:js|mjs|html)(?:[?#].*)?$/i,he=new WeakMap,me=new WeakMap;function ge(){return globalThis.document??null}function $e(e=ge()){return e?.baseURI||e?.querySelector?.("base")?.href||globalThis.window?.location?.href||null}function ye(e){return"string"==typeof e&&(e.startsWith("./")||e.startsWith("../"))}function we(e){return"string"==typeof e&&e.startsWith("/")}function be(e){return"string"==typeof e&&(fe.test(e)||de.test(e))}function ve(e){return"string"==typeof e&&e.length>0&&!ye(e)&&!we(e)&&!be(e)}function _e(e){return String(e).split("#")[0].split("?")[0]}function ke(e=null,t=ge()){return e||$e(t)}function Ae(e,t=null,n=ge()){if(fe.test(e))return e;if(de.test(e))return e;const r=ke(t,n);if(!r)throw new Error(`Cannot resolve import specifier "${e}" without a base URL.`);return new URL(e,r).href}function Oe(e,t){return"string"==typeof e&&e?Ae(e,t,null):null}function Ee(e={},t){const n=new Map;for(const[r,o]of Object.entries(e||{})){const e=Oe(o,t);e&&n.set(r,e)}return n}function Te(e,t){const n=Ee(e?.imports,t),r=new Map;for(const[n,o]of Object.entries(e?.scopes||{})){const e=Ae(n,t,null);r.set(e,Ee(o,t))}return{imports:n,scopes:r,baseURL:t}}function xe(e,t){if(!t?.size)return null;if(t.has(e))return t.get(e);let n=null;for(const r of t.keys())r.endsWith("/")&&e.startsWith(r)&&(!n||r.length>n.length)&&(n=r);if(!n)return null;const r=t.get(n),o=e.slice(n.length);return new URL(o,r).href}function Se(e,{base:t=null,document:n=ge(),importMap:r=null,allowBareFallback:o=!0,allowUnmappedBare:i=!1}={}){if("string"!=typeof e||!e.trim())throw new Error("Import specifier must be a non-empty string.");const s=e.trim();if(!ve(s))return Ae(s,t,n);const{bare:a,suffix:c}=function(e){const t=/([?#].*)$/.exec(e);return{bare:t?e.slice(0,t.index):e,suffix:t?.[1]||""}}(s),l=function(e,t,n=null){if(!t)return null;if(n&&t.scopes?.size){const r=Array.from(t.scopes.keys()).filter(e=>n.startsWith(e)).sort((e,t)=>t.length-e.length);for(const n of r){const r=xe(e,t.scopes.get(n));if(r)return r}}return xe(e,t.imports)}(a,function(e,t=ge(),n=ke(null,t)){if(!e)return function(e=ge()){if(!e)return null;const t=Array.from(e.querySelectorAll?.('script[type="importmap"]')||[]);if(!t.length)return null;const n=he.get(e),r=t.map(e=>e.textContent||"").join("\n---\n");if(n?.signature===r)return n.value;const o={imports:{},scopes:{}};for(const e of t){const t=e.textContent?.trim();if(!t)continue;const n=JSON.parse(t);Object.assign(o.imports,n.imports||{});for(const[e,t]of Object.entries(n.scopes||{}))o.scopes[e]={...o.scopes[e]||{},...t}}const i=Te(o,$e(e));return he.set(e,{signature:r,value:i}),i}(t);if(e instanceof Map)return e;if("string"==typeof e)return Te(JSON.parse(e),n);if("object"==typeof e){const t=me.get(e);if(t?.baseURL===n)return t.value;const r=Te(e,n);return me.set(e,{baseURL:n,value:r}),r}return null}(r,n,ke(t,n)),ke(t,n));if(l)return`${l}${c}`;if(o&&function(e,{bare:t,resolvedFromMap:n}={}){if(n)return!1;if(!ve(e))return!1;const r=t||_e(e);return pe.test(r)}(s,{bare:a}))return Ae(s,t,n);if(i)return s;throw new Error(`Unable to resolve bare import specifier "${s}". Add it to an import map or use an explicit URL/path.`)}const Ce=/^[A-Za-z][A-Za-z0-9._:-]*$/,Ne=/(?:\.ok\.(?:js|mjs|html)|\.(?:js|mjs))$/i;function Ie(e){return"string"==typeof e&&Ce.test(e)}function Re(e){return"string"==typeof e&&e.length>0&&(ye(e)||we(e)||be(e)||ve(e)||Ne.test(_e(e)))}function je(e){return e&&"object"==typeof e&&"string"==typeof e.import}function Le(e){return e&&"object"==typeof e&&Ie(e.tag)&&1===Object.keys(e).length}function De(e){return e&&"object"==typeof e&&!("import"in e)&&!e.loaded}function Me(e){return e&&"object"==typeof e&&!0===e.loaded}function Pe(e,t={}){const{mode:n="dynamic",onInvalidUrl:r=()=>{}}=t,o=new Set(["import","tag","lazy","t"]);for(const t in e)if(!o.has(t))throw new Error(`Unexpected field '${t}' in import definition`);if(!e.import||"string"!=typeof e.import)throw new Error("Import definition must include a valid `import` string.");if(e.lazy&&!e.tag)throw new Error("Lazy import definitions must include a `tag`.");if(e.tag&&!Ie(e.tag))throw new Error(`Invalid tag name: ${e.tag}`);return Re(e.import)||r("import",e.import,e),e}const Fe=new Set(["html","head","body","base","link","meta","main","style","title","address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","hr","nav","section","div","span","p","pre","a","em","strong","small","s","cite","q","dfn","abbr","data","time","code","var","samp","kbd","sub","sup","i","b","u","mark","ruby","rt","rp","bdi","bdo","br","wbr","ins","del","img","iframe","embed","object","param","video","audio","source","track","canvas","map","area","svg","math","table","caption","colgroup","col","tbody","thead","tfoot","tr","td","th","form","fieldset","legend","label","input","button","select","datalist","optgroup","option","textarea","output","progress","meter","details","summary","dialog","script","noscript","template","slot","ul","li"]),ze=new Set(["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","textPath","defs","marker","mask","clipPath","pattern","symbol","use","view","image","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","animate","animateTransform","animateMotion","set","foreignObject","desc","title","metadata","switch"]);function We(e,t,n){if(!t.preserve_whitespace)for(const e of n)e.remove();let r=t.parse?.(e);return r?r.then(()=>Be(e,t)):Be(e,t)}function Be(e,t){if(e.$ignore||e.$__unmount__$)return;Object.assign(e.$cache,K.bind(e)),function(e,t,{onUnused:n=(e,t,n)=>{}}={onUnused:null}){const r=t.attr||{},o=new Set;for(const[t,n]of Object.entries(r)){const r=n.alias||[],i=[];let s=null;for(const t of r)t in e.$attr&&(i.push(t),null==s&&(s=t));const a=t in e.$attr;if(a&&i.push(t),i.length>1)throw e.$error?.("ATTR_ALIAS_CONFLICT",`Only one of [${[t,...r].join(", ")}] should be used`,{key:t,aliases:r,used:i});if(i.length){const r=a?t:s;""===e.$attr[r]&&"empty"in n?e.$attr[t]=n.empty:a||null==s||Object.defineProperty(e.$attr,t,{get:()=>e.$attr[s],enumerable:!0,configurable:!0}),o.add(t)}else"default"in n&&(e.$attr[t]=n.default,o.add(t));if(n.required&&!(t in e.$attr))throw e.$error?.("MISSING_ATTR",`Missing required attribute :${t}=`,{key:t,aliases:r});n.validate&&t in e.$attr&&n.validate(e,e.$attr[t])}if(n)for(const[e,i]of Object.entries(r))o.has(e)||i.required||"default"in i||n(e,i,t)}(e,t,{onUnused(){}});const n=e.$cache.cmp;if(n.context=e.$ok.proxy(t.context?.(e)||{}),e.$innerContext=n.context,t.attr)for(const[r,o]of Object.entries(t.attr))if(void 0!==o.transform){let t=e.$cache.bind[r];t&&"static"!==t.type||([t]=K.classifyAttr(":"+r,"undefined",e.$el),K.bindAttribute(e,r,e.$el,e.$attr,t)),t.transform=(e,t)=>"function"==typeof o.transform?o.transform.call(n.context,e,t):o.transform,t.watcher.run()}return function(e,t){const n=e.$cache.cmp.registration.dependencies,r=[];for(const t of n){const n=t?.ready?.prepareDep?.(e,t.ready,e.$cache.cmp.def);n&&r.push(n)}return r.length?Promise.all(r).then(()=>Ue(e,t)):Ue(e,t)}(e,t)}function Ue(e,t){let n=t.prepare?.(e);return n?n.then(()=>Ve(e,t)):Ve(e,t)}function Ve(e,t){e.$cache.events.prepare?.fn(e),e.$innerVars||e.$setInnerVars({}),e.$__locked__$=!0;const n=e.$el;n.append(t.template.content.cloneNode(!0));for(const t of n.querySelectorAll("slot"))t.setAttribute("cmp-id",e.$id);for(const t of n.childNodes)t.$scope||(t.$scope=e.$ok.scope(t,{$parent:e,$cmp:e}));const r=e.$invoke("mount");return r?r.then(()=>He(e,t)):He(e,t)}function He(e,t){e.$__unmount__$||t.unwrap&&e.$ok.dom.unwrap(e.$el)}function Ke(e){return!!e.$ignore||!(1!==e.nodeType||!e.hasAttribute("ok:ignore"))&&(e.$ignore=!0,!0)}async function qe(e){if(e.$__init__$)throw e.$error("DOUBLE_INITIALIZATION","Node was already initialized before");1===e.$el.nodeType&&e.$el.hasAttribute("ok:ignore")&&(e.$el.$ignore=!0),e.$__init__$=performance.now(),e.$ok.registerScope(e),e.$emit("mount"),e.$state="mounting";try{e.$ok.componentRegistry.pendingInit.size&&await e.$ok.componentRegistry.initPendingRegistrations(e);const t=e.$el;let n;if(t.nodeType===t.TEXT_NODE)n=ue(e,{whitespace:e.$ok.config.whitespace||"ignore"});else if(t.nodeType===t.ELEMENT_NODE){const t=e.$ok.componentRegistry.getRegistration(e.$el.getAttribute("as")||e.$el.tagName,e);t?(e.$el.setAttribute("data-ok",""),n=function(e,t){const n=e.$el;t._instances.add(e),e.$ext("unmount",()=>{t._instances.delete(e)});const r=e.$cache.cmp={registration:t,get def(){return t.ready||t.raw},templates:{},fragment:null},o=Array.from(n.childNodes),i=[],s=[],a=!!r.def,c=a&&r.def.preserve_whitespace;for(const e of o)if(1===e.nodeType&&"TEMPLATE"===e.tagName){const t=e.getAttribute("name")||"default";r.templates[t]=e,e.remove()}else 3===e.nodeType&&""===e.textContent.trim()?(a||s.push(e),c&&i.push(e)):i.push(e);if(!r.templates.default&&i.length){const e=(n.ownerDocument||globalThis.document).createElement("TEMPLATE");e.content.append(...i),r.templates.default=e}else for(const e of i)e.remove();const l=e.$ok.componentRegistry.activate(t,e);return l?l.then(t=>We(e,t,s)):We(e,r.def,s)}(e,t)):(e.$parent||e.$el.setAttribute("data-ok",""),n=function(e){const t=e.$el.tagName.toLowerCase();if("svg"===t&&e.$setInnerVars({$svg:{get:()=>!0}}),!(function(e){return Fe.has(e.toLowerCase())}(t)||e.$vars.$svg&&function(e){return ze.has(e.toLowerCase())}(t))){const n=e._warnedUnregistered??=new Set;n.has(t)||(n.add(t),e.$log.warn(["init"],`[ok] Unregistered component <${t}> in <${e.$parent?.$el.tagName||"root"}> at ${e.$cmp?.$el.tagName||"root"}`))}return Object.assign(e.$cache,K.bind(e)),e.$__locked__$=!0,e.$invoke("mount")}(e))}if(n&&await n,"mounting"!==e.$state)return;let r=[];return"SCRIPT"===e.$el.tagName||e.$el.$ignore||(r=function(e){const t=[],n=[...e.$ok.dom.children(e.$el)];for(let r of n){if(Ke(r))continue;let n=r.$scope||(r.$scope=e.$childScope(r));t.push(n),"pending"===n.$state&&qe(n).catch(e=>{if("ACTIVATION_FAILED"===e?.code&&n.$__unmount__$)return;const t=e?.ok?.shared?.crash;if(!t)throw e;t.crash(e)})}return t}(e)),await Promise.all(r.map(e=>e.$lifecycle.mountedOrAborted)),e.$hasInvoke("mounted")&&await e.$invoke("mounted"),e.$state="mounted",e.$lifecycle.mounted.resolve(),e.$emit("mounted"),await(e.$parent?.$lifecycle.ready),e.$ok.nextFrame(async()=>{e.$hasInvoke("ready")&&await e.$invoke("ready"),e.$state="ready",e.$lifecycle.ready.resolve(),e.$emit("ready"),r.forEach(e=>{e.$lifecycle.ready.resolve()}),await Promise.all(r.map(e=>e.$lifecycle.initializedOrAborted)),e.$__unmount__$||(e.$state="initializing",e.$hasInvoke("init")&&await e.$invoke("init"),e.$lifecycle.initialized.resolve(),e.$state="initialized",e.$emit("initialized"))}),e.$lifecycle.initialized}catch(t){if(e.$__unmount__$)return;throw e.$lifecycle.unmount.resolve(),e.$error("ACTIVATION_FAILED",t,{})}}const Ye=Symbol("OKScope"),Ge=Object.create({[Ye]:!0,$ext(e,t){this.$cache.extends||(this.$cache.extends={}),(this.$cache.extends[e]||=[]).push(t)},$destroyChildren(e=!1){return function(e,t=!1){const n=[],r=new Set,o=e.$ok.dom.children(e.$el);for(let i of o){if(r.has(i))continue;let o=i.$owner;if(o&&o!==e.$el){for(;o.$owner&&o.$owner!==e.$el;)o=o.$owner;const i=o.$handle;if(i&&i.start&&!r.has(i.start)){n.push(o.$scope.$destroy(t));for(const t of e.$ok.dom.range(o))r.add(t)}continue}Ke(i)||i.$scope&&!i.$scope.$__unmount__$&&(n.push(i.$scope.$destroy(t)),r.add(i))}if(n)return Promise.all(n)}(this,e)},$ignoreChildren(){this.$el&&(this.$el.$ignore=!0)},$init(){return qe(this)},$destroy(e=!0){return async function(e,t=!0){if(!e.$__init__$)return;if(e.$__unmount__$)return;e.$__unmount__$=performance.now(),e.$emit("unmount"),e.$lifecycle.unmount.resolve(),e.$state="unmounting";const n=t=>{if("$__unmountPromise__$"in t||t!==e&&t.$__unmount__$)return t.$__unmountPromise__$;t.$__unmountPromise__$=t.$invoke("unmount");for(const e of t.$children)n(e.$scope);return t.$__unmountPromise__$},r=n(e);await r,delete e.$__unmountPromise__$,e.$cache.cmp?.def?.destroyOwnChildren||await e.$destroyChildren(t),await e.$invoke("unmounted"),e.$lifecycle.unmounted.resolve(),e.$state="unmounted",e.$emit("unmounted"),t&&e.$ok.dom.remove(e.$el),e.$ok.unregisterScope(e),e.$offAll(),e.$el.$scope=null,e.$el=null,e.$state="dead",e.$__RIP__$=!0,e.$ok.emit("scope@destroyed",{id:e.$id})}(this,e)},$hasInvoke(e){return this.$cache.cmp?.def?.[e]||this.$cache.events?.[e]||this.$cache.extends?.[e]},$invoke(e,...t){const n=[],r=e=>{if(!e)return;const r=e.call(this.$innerContext,this,...t);r&&"function"==typeof r.then&&n.push(r)};r(this.$cache.cmp?.def?.[e]),r(this.$cache.events?.[e]?.listener);for(const t of this.$cache.extends?.[e]||[])r(t);if(n.length)return n.length?Promise.all(n):void 0},$watch(e,t,n={}){const r=this.$ok.proxyInstance.watch(e,t,{...n,wrapHandle:e=>(...t)=>{try{return e(...t)}catch(e){if("SCOPED_WATCHER_ERROR"===e.code)throw e;throw this.$error("SCOPED_WATCHER_ERROR",e)}}});return this.$ext("unmount",r.stop),r},$observe(e,t,n=null,r){const o=this.$ok.proxyInstance.observe(e,t,n,{...r,wrapHandle:e=>(...t)=>{try{return e(...t)}catch(e){if("SCOPED_OBSERVER_ERROR"===e.code)throw e;throw this.$error("SCOPED_OBSERVER_ERROR",e)}}});return o&&this.$ext("unmount",o.stop),o},$observeDeep(e,t){const{stop:n}=this.$ok.proxyInstance.observeDeep(e,t);return this.$ext("unmount",n),{stop:n}},$memo(e){const t=this.$ok.proxyInstance.memo(e);return t._cleanup||(t._cleanup=!0,this.$ext?.("unmount",()=>t.stop())),t},$fn(e,t={}){return this.$ok.func(e,{...t,layers:["$scope","$vars","$context"]}).bind(this.$context)},$error(e,t,n){return new this.$ok.OK.OKError(e,t,{scope:this,...n})},$setInnerVars(e,t=this.$vars||{}){if(this.$__locked__$)throw this.$error("SCOPE_LOCKED","$innerVars can only be set before mounting children");const n={};for(const e of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,e);r&&(n[e]={...r,configurable:!0})}for(const[t,r]of Object.entries(e)){if(!r||"function"!=typeof r.get)throw this.$error("BAD_VARS",`$vars["${String(t)}"] must be an object with a getter`,{value:r});n[t]={get:r.get,set:r.set||(()=>{throw this.$error("READONLY_VAR",`Variable "${t}" is read-only`)}),enumerable:!0,configurable:!0}}this.$innerVars=Object.defineProperties({},n)},$setInnerContext(e={}){if(this.$__locked__$)throw this.$error("SCOPE_LOCKED","$innerContext can only be set before mounting children");this.$innerContext=this.$ok.proxy(e)},$childScope(e,t={}){if(t.$parent&&t.$parent!==this)throw this.$error("BAD_PARENT","$parent is not allowed",{node:e});return this.$ok.scope(e,{$parent:this,...t})},get $on(){return this[i.SYMBOLS.ON]??=i.on.bind(null,this)},get $once(){return this[i.SYMBOLS.ONCE]??=i.once.bind(null,this)},get $off(){return this[i.SYMBOLS.OFF]??=i.off.bind(null,this)},get $emit(){return this[i.SYMBOLS.EMIT]??=(e,...t)=>{i.emit(this,e,...t),i.emit(this.$ok,"scope@"+e,this,...t)}},get $offAll(){return this[i.SYMBOLS.OFF_ALL]??=i.offAll.bind(null,this)},get $slots(){return this.$cmp?.$cache.cmp?.templates||{}},get $isCmp(){return!!this.$cache.cmp},get $props(){return this.$cmp?.$attr},$dispatch(e,t,n){this.$el&&this.$el.dispatchEvent(new CustomEvent(e,{detail:t,...n}))},$listen(e,t,n,r=void 0){const o="boolean"==typeof r?r:!!r?.capture;this._listeners||=[];for(const r of this._listeners){const i="boolean"==typeof r.options?r.options:!!r.options?.capture;if(r.el===e&&r.type===t&&r.handler===n&&i===o)return r}const i={el:e,type:t,handler:n,options:r,active:!0,start(){this.active||(e.addEventListener(t,n,r),this.active=!0)},stop(){this.active&&(e.removeEventListener(t,n,r),this.active=!1)}};return e.addEventListener(t,n,r),this._listeners.push(i),this._hasListenerCleanup||(this.$ext("unmount",()=>{for(const e of this._listeners)e.stop();this._listeners=[]}),this._hasListenerCleanup=!0),i},$unlisten(e,t,n,r){const o="boolean"==typeof r?r:!!r?.capture;this._listeners&&(this._listeners=this._listeners.filter(r=>{const i="boolean"==typeof r.options?r.options:!!r.options?.capture,s=r.el===e&&r.type===t&&r.handler===n&&i===o;return s&&r.stop(),!s}))},$clone(){const e=(this.$el.ownerDocument||globalThis.document).createElement(this.$el.tagName);if(this.$cache.bind)for(const[t,n]of Object.entries(this.$cache.bind))e.setAttribute(n.originalName,n.originalValue);if(this.$cache.events)for(const[t,n]of Object.entries(this.$cache.events))e.setAttribute(n.originalName,n.originalValue);if(this.$cache.cmp?.templates)for(const t of Object.values(this.$cache.cmp.templates))e.appendChild(t.cloneNode(!0));return Je(this.$ok,e,{$parent:this.$parent,$context:this.$context,$vars:this.$vars,$cmp:this.$cmp,$slot:this.$slot,$attr:this.$attr,$options:this.$options})},async $reload(){if(!this.$isCmp&&!this.$_failedReload)throw this.$error("NOT_A_COMPONENT","$reload can only be called on component scopes");const e=this.$clone();e.$_reloadCloneEl=e.$el;const t=this.$el,n=this.$_reloadCloneEl||e.$el;await this.$destroy(!1),t.innerHTML="";for(const e of Array.from(t.attributes))t.removeAttribute(e.name);for(const e of Array.from(n.attributes))t.setAttribute(e.name,e.value);for(;n.firstChild;)t.appendChild(n.firstChild);t.$scope=e,e.$el=t;let r=this.$_reloadRegistrationId||this.$cache.cmp?.registration?.id;const o=e.$ok.componentRegistry.cache.get(r);e.$_reloadRegistrationId=r,o._instances.add(e),this.$_failedReload&&(this.$ok.dom.replace(this.$_failedReload,e.$el),await this.$ok.destroy(this.$_failedReload),delete this.$_failedReload);try{return await e.$init(),delete e.$_reloadRegistrationId,delete e.$_reloadCloneEl,this.$log.info(["RELOADED"],"Component reloaded successfully"),e}catch(t){((e,t)=>{const n=(e.$el?.ownerDocument||globalThis.document).createElement("crash-boundary-default");e.$ok.dom.replace(e.$el,n),n.$scope=e.$ok.scope(n,{$parent:e.$parent,$context:e.$context,$attr:{error:t}}),n.$scope.$init(),e.$_failedReload=n,e.$log.error(["RELOAD_FAILED"],t)})(e,t)}}});function Xe(e,t){if(e[t])return e[t];let n,r;const o=new Promise((e,t)=>{n=e,r=t});return o.resolve=()=>{o.timestamp=performance.now(),o.resolved=!0,n()},o.reject=e=>{o.timestamp=performance.now(),o.rejected=!0,r(e)},e[t]=o,o}function Ze(e,t,...n){return e[t]?e[t]:e[t]=Promise.race(n)}function Je(e,t,n={}){if(t.$scope)throw e.error("NODE_ALREADY_SCOPED","createScope on a node that already has a scope",{node:t});const r=void 0!==n.$parent?n.$parent:t.parentNode?.$scope||null,o=r||{},i=Object.create(Ge);Object.defineProperty(i,"$id",{value:++e._scopeIdCounter,writable:!1}),Object.assign(i,{$el:t,$root:o.$root||r||null,$parent:r,$children:new Set,$state:"pending",$context:e.proxy(n.$context||o.$innerContext||o.$context||{}),$vars:n.$vars||o.$innerVars||o.$vars||{},$attr:e.proxy(n.$attr||{}),$cmp:n.$cmp||o.$cmp||null,$slot:n.$slot||o.$slot||null,$cache:n.$cache||{},$scope:i,$options:n.$options||{},$ok:e,$innerVars:null,$innerContext:null});const s=void 0!==n.$owner?n.$owner:o.$owner;s&&(i.$owner=s);const a=void 0!==n.$resolveDef?n.$resolveDef:o.$resolveDef;a&&(i.$resolveDef=a);const c={};Object.defineProperty(i,"$lifecycle",{value:{get mounted(){return Xe(c,"mounted")},get ready(){return Xe(c,"ready")},get initialized(){return Xe(c,"initialized")},get unmount(){return Xe(c,"unmount")},get unmounted(){return Xe(c,"unmounted")},get mountedOrAborted(){return Ze(c,"mountedOrAborted",this.mounted,this.unmount)},get readyOrAborted(){return Ze(c,"readyOrAborted",this.ready,this.unmount)},get initializedOrAborted(){return Ze(c,"initializedOrAborted",this.initialized,this.unmount)}},enumerable:!0});const l=t.tagName?.toLowerCase()||(t.nodeType===t.TEXT_NODE?"#text":"#unknown");return Object.defineProperty(i,"$log",{value:e.createLogger(e,i,["scope:"+i.$id,"tag:"+l]),enumerable:!0,configurable:!0}),t.$scope=i,i.$parent?.$children.add(i),i}Je.OK_SCOPE_SYMBOL=Ye;const Qe=e=>[...new Set(e.filter(Boolean).map(String))],et=Symbol("OKLogger"),tt=Symbol("INFO"),nt=Symbol("ERROR"),rt=Symbol("WARN"),ot=Symbol("DEBUG"),it=Symbol("LOG"),st=Object.create({[et]:!0,get log(){return this[it]??=this._emitLog.bind(this,this.channel,"log",this.rootTags,this.source)},get error(){return this[nt]??=this._emitLog.bind(this,this.channel,"error",this.rootTags,this.source)},get info(){return this[tt]??=this._emitLog.bind(this,this.channel,"info",this.rootTags,this.source)},get warn(){return this[rt]??=this._emitLog.bind(this,this.channel,"warn",this.rootTags,this.source)},get debug(){return this[ot]??=this._emitLog.bind(this,this.channel,"debug",this.rootTags,this.source)},extend(e,t){return at(this.channel,e,[...this.rootTags,...t])},asConsole(e,t){const n=this.extend(e,t);return{logger:n,log(...e){n.log([],e)},info(...e){n.info([],e)},error(...e){n.error([],e)},warn(...e){n.warn([],e)},debug(...e){n.debug([],e)}}},_emitLog(e,t=null,n,r,o,s,a=Date.now()){const c={channel:e,source:r,tags:[...Qe([t,...n,...o])],data:s,timestamp:a};return i.emit(e,"log",c),c},printToConsole(e){const t=e.tags.includes("error")?"error":e.tags.includes("warn")?"warn":e.tags.includes("info")?"info":e.tags.includes("debug")?"debug":"log",n=new Date(e.timestamp).toISOString(),r=e.data?.args??[e.data];(console[t]??console.log)(n,e.tags,...r)}});function at(e={},t=null,n=[]){const r=Object.create(st);return r.channel=e,r.source=t,r.rootTags=n,r}function ct(e,t=null,{selfClosing:n="allow",tag:r=null,href:o=null,onWarn:i=null,onError:s=null,line:a=1,offset:c=0,document:l=null}={}){if(!l){if(!globalThis.document)throw new Error("parseTemplate: no document available (running in Node without a DOM).\nYou must pass { document: yourDOM } when calling parseTemplate in a build tool.");l=globalThis.document}const u=function(e,{selfClosing:t="allow",tag:n=null,href:r=null,onWarn:o=null,onError:i=null}={}){const s=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);return e.replace(/<([a-zA-Z0-9-]+)([^<>]*)\/>/g,(e,a,c)=>{const l=a.toUpperCase();if(s.has(l))return e;if("throw"===t)throw i&&i(a,n,r),new Error(`<${a}/> is not a valid self-closing tag`);return"warn"===t&&o&&o(a,n,r),`<${a}${c}></${a}>`})}(e,{selfClosing:n,tag:r,href:o,onWarn:(e,n,r)=>{if(i)i(e,n,r);else if(t?.log){const o=r?` from ${r}`:"";t.log.warn(["parseTemplate"],`[ok] <${e}/> auto-expanded inside <${n}>${o}`)}},onError:(e,n,r)=>{if(!s)throw t?.error?t.error("INVALID_SELF_CLOSING_TAG",`<${e}/> is not a valid self-closing tag`,{tag:n,href:r}):new Error(`<${e}/> is not a valid self-closing tag`);s(e,n,r)}}),d=l.createElement("template");return d.innerHTML=u,d}async function lt(e,t=null){const n=await fetch(e);if(!n.ok)throw t.error("IMPORT_FETCH_FAILED",`${n.status} ${n.statusText}: ${e}`,{href:e,status:n.status,res:n});const r=await n.text();try{return async function(e,t,n){const r=Object.fromEntries(e.map(e=>[e.role||e.tag,e]));let o=r.script?.content||"",i={style:r.style?.content||"",template:r.template?.content||"",__blocks:r};if(r.dependencies)try{i.dependencies=JSON.parse(r.dependencies.content||"[]")}catch(e){throw t.error("PARSE_FAILED","Failed to parse dependencies JSON",{cause:e,content:r.dependencies.content})}if(o){o=function(e,t,n=null){const r=e=>{if(!n)return e.startsWith("./")||e.startsWith("../")?new URL(e,t).href:e;try{return n(e,t)}catch{return e}};let o=e.replace(/(import\s+[\s\S]*?from\s*|import\s*|export\s+[\s\S]*?from\s*)["']([^"']+)["']/g,(e,t,n)=>`${t}"${r(n)}"`);return o=o.replace(/(import\s*\(\s*)["']([^"']+)["'](\s*\))/g,(e,t,n,o)=>`${t}"${r(n)}"${o}`),o}(o,n,(e,n)=>{const r=t?.componentRegistry;return r?.resolveImportPath?r.resolveImportPath(e,n,{allowUnmappedBare:!0,allowBareFallback:!1}):e.startsWith("./")||e.startsWith("../")?new URL(e,n).href:e});const e=["\n".repeat(r.script.startLine-1),o,`\n//# sourceURL=${n}`].join(""),s=!!globalThis.process?.versions?.node,a=s?`data:text/javascript;base64,${Buffer.from(e,"utf8").toString("base64")}`:URL.createObjectURL(new Blob([e],{type:"text/javascript"}));let c;try{c=o?await import(a):{}}finally{s||URL.revokeObjectURL(a)}i={...i,...c.default,url:n}}return i}(function(e){const t=[],n=e.length;let r=0,o=1;const i=()=>{const t=e[r++];return"\n"===t&&o++,t},s=()=>e[r],a=e=>/[a-zA-Z]/.test(e);function c(t,n=!1){const o=e.slice(r,r+t.length);return(n?o.toLowerCase():o)===t}function l(t,a,l,u){let d=null,f=!1,p=null,h="template"===t?1:0;const m=r;for(;r<n;){if("<"===e[r])if("template"===t)if(c("</template>",!0)){if(h--,0===h){const n=r;for(let e=0;e<11;e++)i();const s=r;return{tag:t,openTag:a,closeTag:"</template>",content:e.slice(m,n),start:l,end:s,startLine:u,endLine:o}}}else c("<template",!0)&&h++;else{const n=`</${t}>`;if(c(n,!0)){const s=r;for(let e=0;e<n.length;e++)i();const c=r;return{tag:t,openTag:a,closeTag:n,content:e.slice(m,s),start:l,end:c,startLine:u,endLine:o}}}const n=i();if(p){if("--"===p&&c("--\x3e")||"//"===p&&"\n"===n||"/*"===p&&c("*/")){if("--"===p)for(let e=0;e<3;e++)i();else if("/*"===p)for(let e=0;e<2;e++)i();p=null}}else if(d)f?f=!1:"\\"===n?f=!0:n===d&&(d=null);else if('"'!==n&&"'"!==n)if("<"===n&&c("!--")){for(let e=0;e<3;e++)i();p="--"}else"/"!==n||"/"!==s()?"/"!==n||"*"!==s()||(i(),p="/*"):(i(),p="//");else d=n}throw new Error(`Unclosed <${t}> starting at line ${u}`)}for(;r<n;){if("<"===e[r]&&a(e[r+1])){const s=r+1;let a=s;for(;a<n&&/[a-zA-Z0-9_-]/.test(e[a]);)a++;const c=e.slice(s,a).toLowerCase();if(["script","style","template","part"].includes(c)){const s=r,a=o;for(;r<n&&">"!==e[r];)i();i();const u=e.slice(s,r);let d=null,f=null;if("part"===c){const e=/\brole\s*=\s*["']([^"']+)["']/.exec(u),t=/\bformat\s*=\s*["']([^"']+)["']/.exec(u);if(d=e?.[1]||null,f=t?.[1]||null,!d)throw new Error(`<part> block is missing required "role" attribute (line ${a})`)}const p=l(c,u,s,a);if("part"!==c&&t.find(e=>e.tag===c))throw new Error(`Multiple <${c}> blocks found (first at line ${t.find(e=>e.tag===c).startLine}, again at line ${a})`);for(const e of t)if(p.start>=e.start&&p.start<e.end||e.start>=p.start&&e.start<p.end)throw new Error(`Overlapping blocks: <${e.tag}> (line ${e.startLine}) overlaps with <${p.tag}> (line ${p.startLine})`);"part"===c?(p.role=d,p.format=f):"template"===c?(p.role="template",p.format="html"):"script"===c?(p.role="script",p.format="javascript"):"style"===c&&(p.role="style",p.format="css"),t.push(p),r=p.end,o=p.endLine;continue}}i()}return t}(r),t,e)}catch(n){throw t.error("PARSE_FAILED",`Failed to parse .ok.html structure: ${e}`,{href:e,cause:n})}}const ut=new Map,dt=new WeakMap,ft=new WeakMap,pt=new Map;function ht(e,t=null){const n=t||e?.config?.resolveImportURL;return"function"!=typeof n?null:n}function mt(e){const t=[e.tagName,e.getAttribute("data-ok-tag")||"",e.getAttribute("data-ok-src")||""];return"LINK"===e.tagName?t.push(e.getAttribute("rel")||"",e.getAttribute("href")||""):t.push(e.textContent||""),t.join("::")}function gt(e){const t=Object.create(i.EmitterProto),n=Object.create(t);return Object.assign(n,{ok:e,resolveImportPath:(t,n,r={})=>function(e,t,{ok:n=null,document:r=n?.config?.document||globalThis.document||null,importMap:o=n?.config?.importMap||n?.config?.importmap||null,resolveImportURL:i=n?.config?.resolveImportURL||null,allowUnmappedBare:s=!1,allowBareFallback:a=!0}={}){const c=ht(n,i);if("function"==typeof c)try{return c(e,t||(n.config.document||globalThis.document)?.baseURI||null)}catch{}return Se(e,{base:t,document:n.config.document||globalThis.document,importMap:o,allowUnmappedBare:s,allowBareFallback:a})}(t,n,{ok:e,...r}),cache:new Map,pendingInit:new Set,async fetchDefinition(t,{force:n=!1,t:r=null}={}){n&&ut.delete(t);const o=ut.get(t);if(o)return o;if(!function(e){return"string"==typeof e&&e.length>0&&(ye(e)||we(e)||be(e))&&Ne.test(_e(e))}(t))throw this.ok.error("BAD_URL","invalid import url for component. must be .ok.js, .ok.mjs or .ok.html",{url:t});let i=t;if(null!==r){const e=t.includes("?")?"&":"?";i=`${t}${e}t=${r}`}const s=ht(this.ok);if(s)try{i=s(i,null)}catch{if(i=t,null!==r){const e=t.includes("?")?"&":"?";i=`${t}${e}t=${r}`}}const a=(async()=>{const n=t.endsWith(".ok.html")?await lt(i,e):(await import(i)).default;return n.url=t,ut.set(t,n),n})();return ut.set(t,a),a},async _doImport(e){if("pending"!==e.state)throw e.ok.error("INVALID_STATE",`Cannot import component in state "${e.state}"`,{registration:e});e.state="importing";const t=this.resolveImportPath(e.config.import,e.base),n=await this.fetchDefinition(t,{t:e.config.t});if(Array.isArray(n)){e.type="bundle",e.state="ready",e.bundle=n,delete n.url;for(const n of e.bundle)this.register(n,{base:t});return null}e.state="imported",e.raw=n,e.config?.tag&&e.config.tag!==e.raw.tag&&(e.raw={...e.raw,tag:e.config.tag,originalTag:e.raw.tag,url:t});const r=e.id;e.id=(e.parent?e.parent.id+"~":"")+e.raw.tag.toUpperCase(),this.cache.delete(r);const o=this.cache.get(e.id);o&&o!==e&&this.unregister(e.id),this.cache.set(e.id,e),this.registerRaw(e),await this._doInit(e)},async _doInit(t){if("ready"===t.state)return;for(const e of t.dependencies||[])(e.config.tag||e.raw?.tag)&&e.config.lazy||await this.init(e);const n=t.ready??={...t.raw,id:t.id,loaded:!0,_activatedHeads:new Set,_injectedStyles:new Map};n.template=ct(t.raw.template||"",e,{selfClosing:this.ok.config.self_closing||"allow"}),function(e,t){const n=(e,t)=>e.replace(/\[\[(.*?)]]/g,(e,n)=>new URL(n.trim(),t).href);"string"==typeof e.template&&(e.template=n(e.template,t)),"string"==typeof e.style&&(e.style=n(e.style,t)),Array.isArray(e.style)&&(e.style=e.style.map(e=>"string"==typeof e?n(e,t):e))}(n,t.raw.url||t.base),function(e,t){const n=e.raw;let r=dt.get(e.raw);r.tagToStyles=r.tagToStyles||new Map;const o=r.tagToStyles.get(e.ready.tag);if(o)return e.ready.style=o,o;const i=[],s=Array.isArray(n.style)?n.style:n.style?[n.style]:[];for(const r of s){let o;if("string"==typeof r)o=t.createElement("style"),o.textContent=r.replaceAll("[tag]",e.ready.tag),i.push(o);else{if(!r?.href)throw new Error("Invalid style definition in component: "+n.tag);if(o=Object.assign(t.createElement("link"),{rel:"stylesheet",href:r.href}),!pt.has(r.href)){const e=new Promise(e=>{o.onload=()=>{o.remove(),e()},o.onerror=t=>{o.remove(),e()}});pt.set(r.href,e),t.head.appendChild(o)}i.push(o)}o.setAttribute("data-ok",""),o.setAttribute("data-ok-tag",e.ready.tag),o.setAttribute("data-ok-src",e.ready.url)}e.ready.style=i,r.tagToStyles.set(e.ready.tag,i)}(t,e.config.document||globalThis.document);const r=dt.get(t.raw);r&&!r.ranRegister.has(e)&&(r.ranRegister.add(e),t.raw.register?.(e,t)),t.state="ready",this.emit("ready",t)},async init(e){return e._initPromise||(e._initPromise=(async()=>{if("import"===e.type&&"pending"===e.state&&await this._doImport(e),"bundle"!==e.type){if(!e.raw)throw this.ok.error("INVALID_STATE",`Cannot init component in state "${e.state}"`,{registration:e});await this._doInit(e)}})(),await e._initPromise,this.emit("initialized",e.raw)),e._initPromise},_activateInjectStyles(e,t){if("ready"!==e.state)throw e.ok.error("INVALID_STATE",`Cannot inject styles for component in state "${e.state}"`,{registration:e});const n=[],r=t?.$ok.config.head,o=e.ready;if(!o.style||0===o.style.length)return;const i=function(e,t){const n=function(e){return e.url+":"+e.tag}(t);let r=ft.get(e);r||(r=new Map,ft.set(e,r));let o=r.get(n);return o&&o.parentNode===e||(o=function(e,t){for(const n of e.childNodes||[])if(8===n.nodeType&&n.nodeValue===t)return n;return null}(e,n),o||(o=e.ownerDocument.createComment(n),e.appendChild(o)),r.set(n,o)),o}(r,o);let s=o._injectedStyles.get(r);s||(s=new Map,o._injectedStyles.set(r,s));const a=function(e,t){const n=new Map;for(const r of e.querySelectorAll("style[data-ok], link[data-ok]")){if(r.getAttribute("data-ok-tag")!==(t.tag??""))continue;if(r.getAttribute("data-ok-src")!==String(t.url))continue;const e=mt(r);let o=n.get(e);o||(o=[],n.set(e,o)),o.push(r)}return n}(r,o);for(const e of o.style){let t=s.get(e);if(t)continue;const o=mt(e),c=a.get(o)?.shift();if(c){s.set(e,new Set([c]));continue}t=new Set;const l=e.cloneNode(!0);if(r.insertBefore(l,i),t.add(l),s.set(e,t),"LINK"===e.tagName){const t=pt.get(e.href);t&&n.push(t)}}return 0===n.length?(e.ready._activatedHeads.add(r),void this.emit("activated-head",e.ready,r)):Promise.all(n).then(()=>{e.ready._activatedHeads.add(r),this.emit("activated-head",e.ready,r)})},activate(e,t){if(!t)throw this.ok.error("MISSING_PARAMETER","Scope parameter is required to activate a component.",{registration:e});let n;if("ready"!==e.state&&(n=this.init(e)),n)return n.then(async()=>{if("ready"!==e.state)throw this.ok.error("INVALID_STATE",`Cannot activate component in state "${e.state}"`,{registration:e});await this._activateInjectStyles(e,t),this.emit("activated",e,t)});{if("ready"!==e.state)throw this.ok.error("INVALID_STATE",`Cannot activate component in state "${e.state}"`,{registration:e});const n=this._activateInjectStyles(e,t);if(n)return n.then(()=>{this.emit("activated",e,t)});this.emit("activated",e,t)}},registerRaw(e){if(!e.raw)throw this.ok.error("BAD_REGISTRATION",`Cannot register component with tag "${e.config?.tag}" because its raw definition is missing.`);!function(e,t={}){const{onInvalidUrl:n=()=>{}}=t;if(!e||"object"!=typeof e)throw new Error("Definition must be an object");if("import"in e)throw new Error("Raw definitions cannot include `import`");if(!e.tag||"string"!=typeof e.tag)throw new Error("Raw definitions must include a `tag`");if(!Ie(e.tag))throw new Error(`Invalid tag name: ${e.tag}`);if(e.original_tag&&!Ie(e.original_tag))throw new Error(`Invalid original_tag: ${e.original_tag}`);if(void 0!==e.template&&"string"!=typeof e.template)throw new Error(`Template for ${e.tag} must be a string`);if(!(e.template||e.context||e.register||e.parse||e.prepare||e.mount||e.mounted||e.ready||e.init||e.unmount||e.unmounted||e.destroy||e.style))throw new Error(`Definition for ${e.tag} must include logic or template`);if(e.style){const t=Array.isArray(e.style)?e.style:[e.style];for(const n of t){const t="string"==typeof n,r=n&&"object"==typeof n&&"string"==typeof n.href;if(!t&&!r)throw new Error(`Invalid style entry in component ${e.tag}`)}}if(e.dependencies){if(!Array.isArray(e.dependencies))throw new Error(`Dependencies for ${e.tag} must be an array`);for(const t of e.dependencies)if("string"==typeof t)Re(t)||n("dependency",t,e);else if(je(t))Pe(t,{onInvalidUrl:n});else if(Le(t)||Me(t));else if(!De(t))throw new Error(`Invalid dependency in ${e.tag}`)}(function(e){if(e.attr){if("object"!=typeof e.attr||Array.isArray(e.attr))throw new Error("Attribute definitions must be an object");for(const[t,n]of Object.entries(e.attr)){if("string"!=typeof t||"object"!=typeof n||null==n||Array.isArray(n))throw new Error(`Attribute definition "${t}" must be a valid object`);const{required:e,alias:r,validate:o,default:i,empty:s,description:a}=n;if("required"in n&&"boolean"!=typeof e)throw new Error(`"required" in attr "${t}" must be a boolean`);if("alias"in n&&(!Array.isArray(r)||!r.every(e=>"string"==typeof e)))throw new Error(`"alias" in attr "${t}" must be an array of strings`);if("validate"in n&&"function"!=typeof o)throw new Error(`"validate" in attr "${t}" must be a function`);if("description"in n&&"string"!=typeof a)throw new Error(`"description" in attr "${t}" must be a string`)}}})(e),e.unwrap=void 0!==e.unwrap&&e.unwrap,e.initOwnChildren=void 0!==e.initOwnChildren&&e.initOwnChildren,e.loaded=!1}(e.raw);let t=dt.get(e.raw);t||(t={registered:new WeakSet,ready:!1,readyPromise:null,ranRegister:new WeakSet},dt.set(e.raw,t));for(let t of e.raw.dependencies||[]){if(t===e.raw.tag)throw this.ok.error("BAD_DEFINITION",`Component with tag "${e.raw.tag}" cannot depend on itself.`);this.register(t,{parentId:e.id,base:e.raw.url})}if(e.state="raw",t.registered.add(this.ok),e.raw.alias&&Array.isArray(e.raw.alias))for(const t of e.raw.alias){if(!t||"string"!=typeof t)continue;const n=(e.parent?e.parent.id+"~":"")+t.toUpperCase();this.cache.has(n)||this.cache.set(n,e)}},unregister(e){const t=this.cache.get(e);if(!t)return;for(const e of t.dependencies)this.unregister(e.id);if(t.parent?.dependencies.delete(t),t.ready){for(const[e,n]of t.ready._injectedStyles)for(const e of n.values())for(const t of e)t.remove();t.ready._injectedStyles.clear(),t.ready._activatedHeads.clear()}let n=!0;for(const e of this.cache.values())if(t.config?.import===e.config?.import&&t!==e){n=!1;break}n&&(dt.delete(t.raw),ut.delete(t.url||t.config?.import)),this.cache.delete(e),this.emit("unregistered",t)},register(e,{parentId:t=null,base:n=null,override:r=!1,linkOnly:o=!1}={}){if(Array.isArray(e)){for(const i of e)this.register(i,{parentId:t,base:n,override:r,linkOnly:o});return}"string"==typeof e&&(e={import:e,lazy:!1});const i=t&&this.cache.get(t);if(t&&!i)throw this.ok.error("BAD_REGISTRATION",`Cannot register component with tag "${e.tag}" in the local scope of "${t}" because "${t}" is not registered.`);const s=e.tag||e.module?.tag,a=(t?t+"~":"")+(s?.toUpperCase()||"IMPORT_"+e.import),c=this.cache.get(a);if(c){if(o){const e=t&&this.cache.get(t);return e&&e.dependencies.add(c),c}if(!r)throw this.ok.error("BAD_REGISTRATION",`Component with tag "${s}" is already registered${t?` in the local scope of "${t}"`:" in the global scope"}.`);this.unregister(a)}const l={id:a,base:n||i?.base||null,parent:i,dependencies:new Set,type:"unknown",state:"pending",config:e,options:{base:n,override:r},raw:null,ready:null,_instances:new Set};try{l.url=e.import?this.resolveImportPath(e.import,l.base):null}catch(e){}this.cache.set(a,l);try{if(je(e))Pe(e),l.type="import";else if(Le(e)){if(!Ie(e.tag))throw this.ok.error("BAD_DEFINITION",`Invalid tag name: ${e.tag}`);if(!i)throw this.ok.error("BAD_DEFINITION",`Component with tag "${e.tag}" is not registered and cannot be used as a dependency.`);l.type="link",l.raw=this.cache.get(e.tag.toUpperCase())?.raw,this.registerRaw(l)}else e.module?(l.type="module",l.raw=e.module,this.registerRaw(l)):De(e)&&(l.type="raw",l.raw=e,this.registerRaw(l));i&&i.dependencies.add(l)}catch(e){throw l.state="error",l.error=e,e}return i&&l.config.lazy||this.pendingInit.add(l),l},_resolveFromDef(e,t){return e?e.tag.toUpperCase()===t.toUpperCase()?this.cache.get(e.id):this.cache.get(e.id+"~"+t.toUpperCase()):null},getRegistration(e,t=null){if(t?.$owner&&!t.$owner.$__unmount__$){const n=t.$owner,r=n.$cache?.cmp?.def??n.$cmp?.$cache?.cmp?.def??null,o=this._resolveFromDef(r,e);if(o)return o}if(t?.$resolveDef){const n=this._resolveFromDef(t.$resolveDef,e);if(n)return n}const n=t?.$cmp,r=n?.$resolveCmp;let o=n?.$cache.cmp?.def,i=this._resolveFromDef(o,e);return i||(r&&(o=r.$cache.cmp?.def,i=this._resolveFromDef(o,e),i)?i:this.cache.get(e.toUpperCase()))},async initPendingRegistrations(e){if(this.pendingInit.size){const e=[];for(const t of this.pendingInit)e.push(this.init(t)),this.pendingInit.delete(t);await Promise.all(e)}},refreshImports(e=[]){const t=new Set;for(const{url:n,token:r=null}of e)if(n&&ut.has(n)){for(const e of[...this.cache.values()]){if(e.url!==n||"import"!==e.type)continue;const o={...e.config,t:r};!o.tag&&e.raw?.tag&&(o.tag=e.raw.tag);const i=e.parent?.id,s=e.base,a=[...e._instances];this.unregister(e.id),this.register(o,{parentId:i,base:s,override:!0});for(const e of a)t.add(e)}ut.delete(n)}return t}})}const $t=e=>({mode:"debug"===e?"throw":"default",component:null,boundary_component:null}),yt={self_closing_tag:"allow"},wt={whiteSpace:"remove"},bt={warnLimit:1e3},vt={},_t={},kt={container:null},At=e=>({remove_bind_attributes:"prod"===e,set_bind_attributes:"prod"!==e}),Ot=e=>({console:"prod"!==e});function Et(e){return Array.isArray(e)?e.filter(e=>"function"==typeof e):[]}function Tt(...e){const t={init:{prepare:[],resolveTarget:[],after:[],error:[]}};for(const n of e)n&&(t.init.prepare.push(...Et(n.init?.prepare)),t.init.resolveTarget.push(...Et(n.init?.resolveTarget)),t.init.after.push(...Et(n.init?.after)),t.init.error.push(...Et(n.init?.error)));return t}function xt(e,t){t&&"object"==typeof t&&(Object.prototype.hasOwnProperty.call(t,"node")&&(e.node=t.node),Object.prototype.hasOwnProperty.call(t,"context")&&(e.context=t.context),Object.prototype.hasOwnProperty.call(t,"result")&&(e.result=t.result),t.meta&&"object"==typeof t.meta&&Object.assign(e.meta,t.meta))}function St(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function Ct(e,t){const n={...t};for(const r in e)St(e[r])&&St(t[r])?n[r]=Ct(e[r],t[r]):n[r]=e[r];return n}const Nt=Symbol("OK");function It(e){return e}const Rt=(e={env:"dev"})=>{const t=Rt.defaultConfig||{},r=t.hooks,o=e.hooks;e=Ct(e,t);const s=Tt(Rt.defaultHooks,globalThis.__OK_HMR__?.hooks,globalThis.__OK_SSG__?.hooks,r,o);var a;e={env:"dev",window:e.window||globalThis.window,document:e.document||e.window?.document||globalThis.document,head:e.head||e.document?.head||globalThis.document?.head,body:e.body||e.document?.body||globalThis.document?.body,resolveImportURL:e.resolveImportURL||globalThis.__OK_SSG__?.resolveImportURL||void 0,...e,proxy:Ct(e.proxy??{},vt),component:Ct(e.component??{},yt),dom:Ct(e.dom??{},(a=e.env,{marker:"prod"===a?se.defaultEmptyTextMarker:se.defaultCommentMarker})),crash:Ct(e.crash??{},$t(e.env)),singleton:Ct(e.singleton??{},kt),text:Ct(e.text??{},wt),each:Ct(e.each??{},bt),bind:Ct(e.bind??{},At(e.env)),shared:Ct(e.shared??{},_t),log:Ct(e.log??{},Ot(e.env)),hooks:s};const l={[Nt]:!0,OK:Rt,createLogger:at,_scopeIdCounter:0,dom:se(e.dom),util:z,config:e,hooks:e.hooks,error:(e,t,r={})=>new n(e,t,{ok:l,...r},{depth:1}),func:c,scope(e,t={}){const n=Je(this,e,t);return this._scopeEnhancers.forEach(e=>{try{e(n)}catch(t){throw this.error("SCOPE_ENHANCER_CRASH",t,{fn:e,scope:n})}}),n},_scopeEnhancers:[],enhanceScope(e){if("function"!=typeof e)throw this.error("SCOPE_ENHANCER_NOT_A_FUNCTION",null,{fn:e});return this._scopeEnhancers.push(e),()=>{const t=this._scopeEnhancers.indexOf(e);-1!==t&&this._scopeEnhancers.splice(t,1)}},addHook(e,t){if("function"!=typeof t)throw this.error("BAD_HOOK","Hook must be a function",{path:e,fn:t});const n=String(e||"").split(".");let r=this.hooks;for(let e=0;e<n.length-1;e++)r=r?.[n[e]];const o=r?.[n[n.length-1]];if(!Array.isArray(o))throw this.error("BAD_HOOK_PATH","Unknown hook path",{path:e});return o.push(t),()=>{const e=o.indexOf(t);-1!==e&&o.splice(e,1)}},async _runInitHooks(e,t){const n=this.hooks?.init?.[e]||[];for(const e of n)xt(t,await e(t))},async _initDirect(e=this.config.body,t=null){return Ke(e)||(e.$scope||(e.$scope=this.scope(e,{$ok:this,$context:t||void 0})),e.$scope?.$__init__$||await(e.$scope?.$init())),e},async init(e=this.config.body,t=null){const n={ok:this,requestedNode:e,node:e,context:t,result:null,meta:{}};try{return await this._runInitHooks("prepare",n),await this._runInitHooks("resolveTarget",n),null==n.result&&(n.result=await this._initDirect(n.node,n.context)),await this._runInitHooks("after",n),n.result}catch(e){throw n.error=e,await this._runInitHooks("error",n),e}},async destroy(e,t=!0){await(e.$scope?.$destroy(t)),t&&this.dom.remove(e)},...A,createNodes(e){if(null==e)return[];if(e instanceof HTMLTemplateElement)return Array.from(e.content.cloneNode(!0).childNodes);if(null!=e&&"number"==typeof e.nodeType)return[e];const t=ct(String(e),{self_closing_tag:this.config.component.self_closing_tag});return Array.from(t.content.childNodes)},scopeToId:new Map,idToScope:new Map,registerScope(e){const t=e.$id;return this.scopeToId.set(e,t),this.idToScope.set(t,e),t},unregisterScope(e){const t=this.scopeToId.get(e);return t?(this.scopeToId.delete(e),this.idToScope.delete(t),!0):null},getScopeById(e){return this.idToScope.get(+e)||null},get on(){return this[i.SYMBOLS.ON]??=i.on.bind(null,this)},get once(){return this[i.SYMBOLS.ON]??=i.once.bind(null,this)},get off(){return this[i.SYMBOLS.OFF]??=i.off.bind(null,this)},get emit(){return this[i.SYMBOLS.EMIT]??=(...e)=>{try{i.emit.call(null,this,...e)}catch(t){throw new n("EMIT_ERROR",t,{message:"Failed to emit event",event:event,args:e})}}},get offAll(){return this[i.SYMBOLS.OFF_ALL]??=i.offAll.bind(null,this)},_scopePerf(e){const t=e.$lifecycle;if(!t||!e.$__init__$)return null;const n=e.$__init__$,r=t.mounted?.timestamp,o=t.ready?.timestamp,i=t.initialized?.timestamp,s=t.unmounted?.timestamp;return{id:e.$id,node:e.$el,tag:e.$el?.tagName?.toLowerCase()||"#text",start:n,mount:r,ready:o,init:i,destroy:s,duration:{mount:r&&n?r-n:null,ready:o&&r?o-r:null,init:i&&o?i-o:null,total:i&&n?i-n:null,alive:s&&n?s-n:null},state:e.$state}},perfDump({sortBy:e="total",limit:t=null}={}){const n=[];for(const e of this.scopeToId.keys()){const t=this._scopePerf(e);t&&n.push(t)}if(!n.length)return[];const r=t=>t.duration?.[e]??1/0;return n.sort((e,t)=>r(t)-r(e)),t&&(n.length=Math.min(t,n.length)),n}},u=at(l,null,["ok"]);e.log.console&&i.on(l,"log",e=>{l.log.printToConsole(e)});const d=f({...e.proxy,wrapHandle:e=>(...t)=>{try{return e(...t)}catch(e){throw l.error("OK_PROXY_HANDLE_CRASH",e)}}});d.log=u.asConsole(d,["proxy"]);const p=gt(l);return Object.assign(l,{proxyInstance:d,proxy:d.proxy.bind(d),log:u,flush:d.flush.bind(d),componentRegistry:p,register:p.register.bind(p)}),l.shared=d.proxy({}),Object.keys(re).forEach(e=>{re[e]._primitive=!0,p.register(re[e])}),l};Rt.OKProxy=f,Rt.OKDom=se,Rt.OKError=n,Rt.OK_SYMBOL=Nt,Rt.Emitter=i,Rt.OKScope=Je,Rt.createHooks=function(){return{init:{prepare:[],resolveTarget:[],after:[],error:[]}}},Rt.mergeHooks=Tt,Rt.defineComponent=It,Rt.defaultHooks={init:{prepare:[],resolveTarget:[],after:[],error:[]}},Rt.defaultConfig={},Rt.url=import.meta.url,Rt.init=async(e=globalThis.document?.body,t=null,n={})=>{const r=Rt(n);return await r.init(e,t),r};export{Rt as default,It as defineComponent};
|
|
2
|
+
//# sourceMappingURL=ok.esm.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t={tag:"async",unwrap:!0,prepare(t){const e=t.$cache.cmp.templates||{},r=e.default.content;for(let t of Array.from(r.childNodes)){const a=t.tagName?.toLowerCase();if("then"===a||"catch"===a){const s=document.createElement("template");s.setAttribute("name",a);for(let e of t.attributes)s.setAttribute(e.name,e.value);s.content.append(...t.childNodes),e[a]=s,r.removeChild(t)}}},context:t=>({busy:!0,error:null,result:null,async run(){this.busy=!0,this.error=null,this.result=null;try{const e="function"==typeof t.$attr.await?t.$attr.await():t.$attr.await;this.result=await e}catch(t){this.error=t}this.busy=!1}}),mount(t){this.run()},template:'<if :="busy"><slot/><else :if="error"><slot name="catch" scope="inner" var:error/><else><slot scope="inner" name="then" var:result/></else></else></if>'};export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let t=null;var a={tag:"ok-chart",attr:{type:{type:"string",default:"line"},data:{type:"object",default:()=>({labels:[],datasets:[]})},options:{type:"object",default:()=>({})},autoColor:{type:"boolean",default:!0}},context:a=>({loading:!0,error:null,chart:null,getDefaultOptions:()=>({responsive:!0,maintainAspectRatio:!1,scales:{x:{type:"category",ticks:{color:"#aaa"},grid:{color:"rgba(255,255,255,0.05)"}},y:{type:"linear",ticks:{color:"#aaa"},grid:{color:"rgba(255,255,255,0.05)"}}},plugins:{legend:{labels:{color:"#ccc",boxWidth:12}},tooltip:{backgroundColor:"#1a1830",borderRadius:8,titleColor:"#fff",bodyColor:"#ccc"}},elements:{line:{borderWidth:2},point:{radius:3,hoverRadius:4}}}),applyAutoColors(t){if(!a.$attr.autoColor||!t.datasets)return t;const r=["#4dc0ff","#8f5","#f49","#ffcc00","#a0a0ff","#ffa07a"];return{...t,datasets:t.datasets.map((t,a)=>({...t,borderColor:t.borderColor||r[a%r.length],backgroundColor:t.backgroundColor||(t.borderColor||r[a%r.length])+"33",tension:t.tension??.3}))}},async initChart(){this.loading=!0,this.error=null;try{if(!t){const a=await import("https://cdn.jsdelivr.net/npm/chart.js@4.5.1/+esm"),{Chart:r,CategoryScale:e,LinearScale:o,BarController:i,LineController:l,PointElement:s,LineElement:n,BarElement:c,Title:d,Tooltip:h,Legend:p,Filler:u}=a;r.register(e,o,i,l,s,n,c,d,h,p,u),t=a}const{Chart:r}=t,e=a.$el.querySelector("canvas");if(!e)throw new Error("Canvas element not found");const o=e.getContext("2d"),i=this.applyAutoColors(a.$attr.data),l={...this.getDefaultOptions(),...a.$attr.options||{}};this.chart&&this.chart.destroy(),this.chart=new r(o,{type:a.$attr.type,data:i,options:l}),this.loading=!1}catch(t){a.$log?.error?.(["Chart initialization failed"],{err:t}),this.error=t.message||"Failed to load chart",this.loading=!1}},updateChart(){if(this.chart)try{const t=this.applyAutoColors(a.$attr.data),r={...this.getDefaultOptions(),...a.$attr.options||{}};this.chart.config.type=a.$attr.type,this.chart.data=t,this.chart.options=r,this.chart.update()}catch(t){a.$log?.error?.(["Chart update failed"],{err:t})}}}),async mounted(t){await this.initChart(),t.$watch(()=>[t.$attr.type,t.$attr.data,t.$attr.options],()=>{this.updateChart()},{deep:!0})},unmounted(t){this.chart&&(this.chart.destroy(),this.chart=null)},template:'<div class="chart-container"><if :="loading"><div class="chart-loader">Loading chart…</div></if><if :="error"><div class="chart-error">⚠️ {{ error }}</div></if><canvas/></div>',style:"[tag],canvas{width:100%;height:100%}[tag]{position:relative;display:flex}.chart-container{position:relative;width:100%;height:100%}canvas{border-radius:6px;display:block}.chart-error,.chart-loader{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:.9rem;border-radius:6px;background:rgba(0,0,0,.15);backdrop-filter:blur(3px);z-index:10}.chart-loader{color:#aaa}.chart-error{color:#f66}"};export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./ok-marked.ok.js";function t(e,t){const n=Array.isArray(t)?t.join("|"):t,o=new RegExp("```(?:"+n+")[^\\n]*\\n([\\s\\S]*?)```","i"),r=e.match(o);return r?r[1].trim():null}function n(e){const t=[];for(const o of e)o.file&&t.push(o),o.children?.length&&t.push(...n(o.children));return t}const o=[{name:["note","warning","tip"],render({name:e,content:t}){const n=t.trim().split("\n");let o=null,r=t.trim();const a=n[0]?.trim();a&&!a.startsWith("<")&&(o=a,r=n.slice(1).join("\n").trim());const i=document.createElement("div");i.className=`ok-callout ok-callout--${e}`;const l=document.createElement("div");l.className="ok-callout__icon",l.innerHTML=`<ok-icon name="${{note:"info",warning:"alert-triangle",tip:"lightbulb"}[e]}"></ok-icon>`;const c=document.createElement("div");if(c.className="ok-callout__content",o){const e=document.createElement("div");e.className="ok-callout__title",e.textContent=o,c.appendChild(e)}const s=document.createElement("div");return s.className="ok-callout__body",s.innerHTML=r,c.appendChild(s),i.appendChild(l),i.appendChild(c),i}},{name:"raw",render({content:e}){const t=document.createElement("div");return t.innerHTML=e.trim(),[...t.childNodes]}}],r={async render({lang:e,code:t,scope:n}){const o=document.createElement("div");o.className="ok-code-block";const r=document.createElement("div");r.className="ok-code-block__header";const a=document.createElement("span");a.className="lang",a.textContent=e.toUpperCase();const i=document.createElement("span");i.className="copy",i.textContent="Copy",i.addEventListener("click",()=>{navigator.clipboard.writeText(t.innerText?.trim()),i.textContent="Copied!",setTimeout(()=>i.textContent="Copy",1200)}),r.appendChild(a),r.appendChild(i);const l=document.createElement("pre");o.appendChild(r),o.appendChild(l);try{await n.$ok.componentRegistry.activate(n.$ok.componentRegistry.getRegistration("ok-monaco"),n);const o=await n.$ok.shared.monaco.load();t.setAttribute("data-lang","js"===e?"javascript":e);const r=getComputedStyle(n.$el).getPropertyValue("--ok-monaco-theme").trim()||"vs-dark";t.dataset.monacoSource=t.textContent,await o.editor.colorizeElement(t,{theme:r});const a=t.querySelectorAll("br");a[a.length-1]?.remove()}catch(e){}return l.append(t),o}};var a={tag:"ok-doc-viewer",dependencies:[e],attr:{anchor:{},file:{},root:{default:"/docs/"},prefix:{default:"#/docs/"},blocks:{default:()=>[]},codeBlock:{default:null},preprocess:{default:null},postprocess:{default:null},noDefaultBlocks:{default:!1,empty:!0},headingLevels:{default:()=>[1,2,3]},sidebarTitle:{default:"On this page"},scrollOffset:{default:80},iconSet:{default:"lucide"},manifest:{default:null}},context(e){const a=()=>new URL(e.$attr.root,document.baseURI).href;function i(){const t=e.$attr.headingLevels;return Array.isArray(t)?t.map(Number):"string"==typeof t?t.split(",").map(e=>Number(e.trim())):[1,2,3]}function l(n){const r={blocks:[],index:0};return n=function(e,n,o){for(const r of o){const o=Array.isArray(r.name)?r.name.join("|"):r.name,a=new RegExp(`:::[ \\t]*(${o})\\b([\\s\\S]*?):::`,"g");e=e.replace(a,(e,o,a)=>{const i=n.index++,l="params"in r?Object.fromEntries(Object.entries(r.params).map(([e,n])=>[e,t(a,n)])):void 0;return n.blocks.push({id:i,block:r,options:{name:o,content:a,fence:e=>t(a,e),params:l}}),`<span class="ok-docs-block" data-block="${i}"></span>`})}return e}(n,r,e.$attr.noDefaultBlocks?[...e.$attr.blocks]:[...o,...e.$attr.blocks]),n=function(e,t,n="lucide"){const o=[];return e.replace(/(```[\s\S]*?```|`[^`\n]+`)/g,e=>(o.push(e),`\0${o.length-1}\0`)).replace(/:([a-z0-9_-]+(?:\/[a-z0-9_-]+)?):/gi,(e,o)=>{const r=o.indexOf("/"),a=-1!==r?o.slice(0,r):n,i=-1!==r?o.slice(r+1):o,l=t.index++;return t.blocks.push({id:l,inline:!0,renderInline(){const e=document.createElement("ok-icon");return e.setAttribute("name",i),e.setAttribute("set",a),e}}),`<span class="ok-docs-block" data-block="${l}"></span>`}).replace(/\x00(\d+)\x00/g,(e,t)=>o[Number(t)])}(n,r,e.$attr.iconSet||"lucide"),{md:n,bag:r}}async function c(t,n){const o=a(),i=new URL(a()+e.$attr.file,document.baseURI).href;t.querySelectorAll("a[href]").forEach(t=>{const n=t.getAttribute("href");if(!n||/^(https?:)?\/\//.test(n)||n.startsWith("#"))return;const r=new URL(n,i);if(!r.href.startsWith(o))return;let a=r.href.replace(o,"").replace(/^\//,"");a.endsWith(".md")&&(a=a.slice(0,-3)),t.setAttribute("href",e.$attr.prefix+a+r.hash)});for(const o of n.blocks){const n=t.querySelector(`.ok-docs-block[data-block="${o.id}"]`);if(!n)continue;let r;if(o.inline)r=[o.renderInline()];else{const e=await o.block.render(o.options);r=Array.isArray(e)?e:[e]}n.replaceWith(...r);for(const t of r)await e.$ok.init(t)}const l=e.$attr.codeBlock||r;for(const n of[...t.querySelectorAll("pre code")]){if(!n.textContent.includes("\n"))continue;const t=n.closest("pre"),o=[...n.classList].find(e=>e.startsWith("language-"))?.replace("language-","")||"plaintext",r=await l.render({lang:o,code:n,scope:e}),a=Array.isArray(r)?r:[r];t.replaceWith(...a)}return[...t.childNodes]}let s=null,d=null,p=!1,m=!1,g=null,f=e.$attr.file;const u={markedEl:null,sidebarEl:null,headings:[],loading:!!e.$attr.file,error:null,get filteredHeadings(){const e=i();return this.headings.filter(t=>e.includes(t.level))},get prevDoc(){const t=e.$attr.manifest;if(!t?.length)return null;const o=n(t),r=(e.$attr.file||"").replace(/\.md$/,""),a=o.findIndex(e=>(e.file||"").replace(/\.md$/,"")===r);if(a<=0)return null;const i=o[a-1];return{...i,href:e.$attr.prefix+(i.file||"").replace(/\.md$/,"")}},get nextDoc(){const t=e.$attr.manifest;if(!t?.length)return null;const o=n(t),r=(e.$attr.file||"").replace(/\.md$/,""),a=o.findIndex(e=>(e.file||"").replace(/\.md$/,"")===r);if(a<0||a>=o.length-1)return null;const i=o[a+1];return{...i,href:e.$attr.prefix+(i.file||"").replace(/\.md$/,"")}},preprocessFn:t=>e.$attr.preprocess?e.$attr.preprocess(t,l):l(t),postprocessFn:async(t,n)=>e.$attr.postprocess?e.$attr.postprocess(t,n,c):c(t,n),get src(){return a()+e.$attr.file},resetHeadings(e){this.headings=[...e.querySelectorAll("h1,h2,h3,h4,h5,h6")].map(e=>(e.id||(e.id=e.textContent.trim().toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")),{level:Number(e.tagName[1]),text:e.textContent.trim(),id:e.id}))},resetAnchors(t){const n=i().map(e=>`h${e}`).join(","),o=[...t.querySelectorAll(n)];s?.stop(),g=function(e){for(;e&&e!==document.body;){if(/auto|scroll/.test(getComputedStyle(e).overflowY))return e;e=e.parentElement}return window}(t),s=e.$listen(g,"scroll",()=>{if(p)return clearTimeout(d),void(d=setTimeout(()=>p=!1,500));const t=function(t,n){const o=(n===window?0:n.getBoundingClientRect().top)+(Number(e.$attr.scrollOffset)||80);let r=null;for(const e of t){if(!(e.getBoundingClientRect().top<=o))break;r=e}return r}(o,g);if(!t)return;const n=t.id;e.$attr.anchor!==n&&(m=!0,e.$dispatch("anchor-change",n))})},anchorChanged(t=!1){p=!0;const n=e.$attr.anchor;if(n){const e=this.markedEl?.querySelector(`[id="${n}"]`);e&&e.scrollIntoView({behavior:t?"instant":"smooth",block:"start"})}else g&&g!==window?g.scrollTo({top:0,behavior:t?"instant":"smooth"}):window.scrollTo({top:0,behavior:t?"instant":"smooth"});clearTimeout(d),d=setTimeout(()=>p=!1,500)},loaded(t){p=!0,this.loading=!1,this.error=null,f=e.$attr.file,this.resetHeadings(t),this.resetAnchors(t),e.$dispatch("loaded",{container:t,headings:this.headings}),t.$scope.$ok.nextFrame(()=>{u.anchorChanged(!0),clearTimeout(d),d=setTimeout(()=>p=!1,500)})},onError(t){this.loading=!1,this.error=t?.error?.message||t?.message||"Failed to load document",e.$dispatch("error",t)},sidebarClick(t,n){n?.preventDefault(),e.$dispatch("heading-click",{id:t.id,text:t.text,level:t.level}),e.$dispatch("anchor-change",t.id)}};return e.$watch(()=>[e.$attr.file,e.$attr.anchor],()=>m?(m=!1,void requestAnimationFrame(()=>{u.sidebarEl?.querySelector(".sidebar__link.active")?.scrollIntoView({block:"nearest",behavior:"smooth"})})):e.$attr.file!==f?(u.loading=!0,void(u.error=null)):void u.anchorChanged()),u},mounted(e){e.$listen(e.$el,"transitionstart",t=>{if("--ok-monaco-theme"!==t.propertyName)return;const n=getComputedStyle(e.$el).getPropertyValue("--ok-monaco-theme").trim()||"vs-dark";for(const t of e.$el.querySelectorAll("[data-lang]"))t.dataset.monacoSource&&(t.textContent=t.dataset.monacoSource),window.monaco?.editor.colorizeElement(t,{theme:n})})},template:'<div class="doc-viewer__layout"><div class="doc-viewer__main"><if :="loading"><div class="doc-viewer__loading"><div class="doc-viewer__spinner"/></div></if><if :="error"><div class="doc-viewer__error"><div class="doc-viewer__error-icon">⚠</div><div class="doc-viewer__error-message">{{ error }}</div></div></if><ok-marked class="doc-viewer__content md" :class="{ \'doc-viewer__content--hidden\': loading || !!error }" @mount="markedEl = $el" @loaded="loaded($event.detail.container)" @error="onError($event.detail)" :src :preprocess="preprocessFn" :postprocess="postprocessFn"/><if :="prevDoc || nextDoc"><nav class="doc-viewer__nav"><if :="prevDoc"><a class="doc-viewer__nav-link doc-viewer__nav-prev" :href="prevDoc.href">← {{ prevDoc.label }}</a></if><if :="nextDoc"><a class="doc-viewer__nav-link doc-viewer__nav-next" :href="nextDoc.href">{{ nextDoc.label }} →</a></if></nav></if></div><if :="filteredHeadings.length > 0"><div class="doc-viewer__sidebar" :ref="sidebarEl = $el"><slot name="sidebar-top"/><div class="sidebar__title">{{ $props.sidebarTitle }}</div><each :of="filteredHeadings" let:item="h"><a class="sidebar__link" :class="{ active: $props.anchor === h.id }" :style="{ \'--level\': h.level }" :level="h.level" :href="\'#\' + h.id" @click="sidebarClick(h, $event)">{{ h.text }}</a></each><slot name="sidebar-bottom"/></div></if></div>',style:['\n@property --ok-monaco-theme {\n syntax: \'<custom-ident>\';\n inherits: true;\n initial-value: vs-dark;\n}\n[tag] { display: block; width: 100%; transition: --ok-monaco-theme 1ms allow-discrete; }\n\n[tag] .doc-viewer__layout {\n display: flex;\n align-items: flex-start;\n gap: 2rem;\n padding: 2rem;\n box-sizing: border-box;\n}\n\n[tag] .doc-viewer__main {\n flex: 1;\n min-width: 0;\n max-width: 760px;\n}\n\n[tag] .doc-viewer__sidebar {\n position: sticky;\n top: 100px;\n max-width: 240px;\n max-height: calc(100vh - 120px);\n padding-left: 1.2rem;\n padding-right: 0.4rem;\n display: flex;\n flex-direction: column;\n overflow-y: auto;\n border-left: 1px solid var(--ok_color-muted-border, #333);\n scrollbar-width: thin;\n align-self: flex-start;\n}\n\n[tag] .sidebar__title {\n font-size: 11px;\n letter-spacing: 1px;\n color: var(--ok_color-muted-fg, #888);\n margin-bottom: 8px;\n text-transform: uppercase;\n opacity: 0.8;\n flex-shrink: 0;\n}\n\n[tag] .sidebar__link {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 3px 0;\n cursor: pointer;\n font-size: 13px;\n color: var(--ok_color-fg, #eee);\n text-decoration: none;\n transition: color .15s ease;\n position: relative;\n margin-left: calc((var(--level, 1) - 1) * 12px);\n}\n\n[tag] .sidebar__link::before {\n content: "";\n position: absolute;\n left: -10px;\n width: 2px;\n height: 100%;\n background: transparent;\n transition: background .15s ease;\n border-radius: 1px;\n}\n\n[tag] .sidebar__link.active::before { background: var(--ok_color-accent, #4ea1ff); }\n[tag] .sidebar__link:hover { color: var(--ok_color-accent, #4ea1ff); }\n[tag] .sidebar__link[level="1"] { font-weight: 600; opacity: 0.9; margin-top: 4px; }\n\n/* ── Loading ─────────────────────────────────────────────────────────── */\n[tag] .doc-viewer__loading {\n display: flex;\n justify-content: center;\n padding: 4rem 0;\n}\n[tag] .doc-viewer__spinner {\n width: 28px;\n height: 28px;\n border: 3px solid rgba(255,255,255,0.08);\n border-top-color: var(--ok_color-accent, #4ea1ff);\n border-radius: 50%;\n animation: ok-dv-spin 0.7s linear infinite;\n}\n@keyframes ok-dv-spin { to { transform: rotate(360deg); } }\n\n/* ── Error ───────────────────────────────────────────────────────────── */\n[tag] .doc-viewer__error {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 0.75rem;\n padding: 4rem 0;\n color: var(--ok_color-fg, #eee);\n opacity: 0.65;\n text-align: center;\n}\n[tag] .doc-viewer__error-icon { font-size: 2rem; }\n[tag] .doc-viewer__error-message { font-size: 0.9rem; }\n[tag] .doc-viewer__content--hidden { display: none; }\n\n/* ── Prev / Next nav ─────────────────────────────────────────────────── */\n[tag] .doc-viewer__nav {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n margin-top: 3rem;\n padding-top: 1.5rem;\n border-top: 1px solid var(--ok_color-muted-border, #333);\n gap: 1rem;\n}\n[tag] .doc-viewer__nav-link {\n color: var(--ok_color-accent, #4ea1ff);\n text-decoration: none;\n font-size: 0.9rem;\n opacity: 0.85;\n transition: opacity 0.15s;\n max-width: 45%;\n}\n[tag] .doc-viewer__nav-link:hover { opacity: 1; }\n[tag] .doc-viewer__nav-next { margin-left: auto; text-align: right; }\n\n/* ── Responsive ──────────────────────────────────────────────────────── */\n@media (max-width: 768px) {\n [tag] .doc-viewer__layout { flex-direction: column; padding: 1rem; gap: 1.5rem; }\n [tag] .doc-viewer__main { max-width: 100%; }\n [tag] .doc-viewer__sidebar {\n position: static;\n max-width: 100%;\n max-height: none;\n border-left: none;\n border-top: 1px solid var(--ok_color-muted-border, #333);\n padding: 0.8rem 0 0;\n overflow-y: visible;\n flex-direction: row;\n flex-wrap: wrap;\n gap: 2px 8px;\n }\n [tag] .sidebar__title { width: 100%; margin-bottom: 4px; }\n [tag] .sidebar__link { margin-left: 0 !important; font-size: 12px; }\n [tag] .sidebar__link::before { display: none; }\n}\n',"\n[tag] .md { line-height: 1.6; }\n\n[tag] .md h1, [tag] .md h2, [tag] .md h3 { font-weight: 600; line-height: 1.25; margin: 2rem 0 0.8rem; }\n[tag] .md h1 { font-size: 2rem; }\n[tag] .md h2 { font-size: 1.55rem; color: var(--ok_color-accent, #4ea1ff); }\n[tag] .md h3 { font-size: 1.25rem; }\n[tag] .md h4 { font-size: 1.1rem; margin: 1.2rem 0 0.6rem; font-weight: 600; }\n[tag] .md h5 { font-size: 1rem; margin: 1rem 0 0.6rem; font-weight: 600; opacity: 0.9; }\n[tag] .md h6 { font-size: 0.9rem; margin: 0.8rem 0 0.5rem; font-weight: 500; opacity: 0.85; }\n\n[tag] .md p { margin: 0.8rem 0; color: var(--ok_color-fg, #eee); }\n[tag] .md ul, [tag] .md ol { padding-left: 1.4rem; margin: 0.8rem 0; }\n[tag] .md li { margin: 0.3rem 0; }\n\n[tag] .md hr {\n border: 0; height: 1px; margin: 2rem 0;\n background: linear-gradient(to right, transparent, #444, transparent);\n opacity: 0.7;\n}\n\n[tag] .md pre {\n margin: 1.4rem 0;\n background: rgba(255,255,255,0.05);\n border-radius: 6px;\n box-shadow: 0 0 0 1px rgba(255,255,255,0.08);\n}\n[tag] .md pre, [tag] .md blockquote { margin: 1.4rem 0; }\n[tag] .md code { font-size: 0.95em; font-family: var(--font-mono, monospace); overflow-x: auto; }\n[tag] .md ok-icon { vertical-align: middle; }\n\n[tag] .ok-code-block {\n margin: 1.4rem 0;\n border-radius: 8px;\n overflow: hidden;\n background: var(--ok_color-code-bg, #1e1e1e);\n border: 1px solid var(--ok_color-code-border, rgba(255,255,255,0.06));\n}\n\n[tag] .ok-code-block__header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n background: var(--ok_color-code-header-bg, #252525);\n padding: 6px 10px;\n font-size: 11px;\n color: var(--ok_color-code-text, #cfcfcf);\n font-family: var(--font-mono, monospace);\n border-bottom: 1px solid var(--ok_color-code-header-border, rgba(255,255,255,0.07));\n}\n\n[tag] .ok-code-block .lang { opacity: 0.8; letter-spacing: 0.03em; }\n\n[tag] .ok-code-block .copy {\n cursor: pointer; color: var(--ok_color-code-copy, #aaa); font-size: 11px;\n padding: 2px 6px; border-radius: 4px; transition: 0.15s; user-select: none;\n}\n[tag] .ok-code-block .copy:hover { color: var(--ok_color-code-copy-hover, white); background: var(--ok_color-code-copy-hover-bg, rgba(255,255,255,0.08)); }\n[tag] .ok-code-block pre { margin: 0 !important; padding: 0.6rem 0.8rem !important; background: transparent !important; }\n\n[tag] .ok-callout {\n display: flex; gap: 0.75rem; padding: 1rem 1.2rem; margin: 1.4rem 0;\n border-radius: 8px; border: 1px solid rgba(255,255,255,0.06);\n background: rgba(255,255,255,0.035);\n}\n[tag] .ok-callout__icon ok-icon { width: 20px; height: 20px; opacity: 0.9; }\n[tag] .ok-callout__content { flex: 1; }\n[tag] .ok-callout__title { font-weight: 600; margin-bottom: 0.25rem; font-size: 0.95rem; }\n[tag] .ok-callout__body { line-height: 1.5; opacity: 0.9; }\n[tag] .ok-callout--note { border-left: 4px solid var(--ok_color-accent, #4ea1ff); }\n[tag] .ok-callout--warning { border-left: 4px solid #ffb24e; background: rgba(255,178,78,0.06); }\n[tag] .ok-callout--tip { border-left: 4px solid #44d07a; background: rgba(68,208,122,0.06); }\n"]};export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let t=null,r=null;var e={tag:"ok-marked",attr:{src:{},text:{},map:{}},context:e=>({loading:!1,error:null,html:"",nodes:[],container:null,async load(){if(e.$attr.text||e.$attr.src){this.error=null,this.loading=!0;try{const a=await(r?Promise.resolve(r):t||(t=import("https://cdn.jsdelivr.net/npm/marked@17.0.0/+esm").then(t=>(r=t.marked||t.default||t,r.setOptions({gfm:!0,breaks:!0,headerIds:!1,mangle:!1}),r)).catch(t=>{throw t}),t)),s=e.$attr.text||await(await fetch(e.$attr.src)).text(),{md:n,bag:i}=e.$attr.preprocess?.(s),o=a.parse(n),d=document.createElement("div");d.innerHTML=o,this.nodes=await(e.$attr.postprocess?.(d,i))||Array.from(d.childNodes),this.container.innerHTML="",this.container.append(...this.nodes),this.loading=!1,e.$dispatch("loaded",{md:n,container:this.container})}catch(t){this.loading=!1,this.error=t?.message||String(t),e.$dispatch("error",{error:t,src:e.$attr.src})}}}}),mounted(t){this.load(),t.$watch(()=>[t.$attr.text,t.$attr.src],()=>{this.load()})},template:'<if :="loading"/><div :ref="container = $el"/>'};export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=null;const t="https://cdn.jsdelivr.net/npm/monaco-editor@latest/min/vs/loader.js";function o(e){require.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@latest/min/vs"}}),require(["vs/editor/editor.main"],()=>{for(const e of window.__monacoLoaderPending||[])e(window.monaco);delete window.__monacoLoaderPending,e(window.monaco)})}function n(e){return null!=e.$attr.theme?e.$attr.theme:getComputedStyle(e.$el).getPropertyValue("--ok-monaco-theme").trim()||"vs-dark"}function a(){return window.monaco?window.monaco:e||(e=new Promise((e,n)=>{if(window.__monacoLoaderPending)return void window.__monacoLoaderPending.push(e);window.__monacoLoaderPending=[e];const a=document.querySelector(`script[src="${t}"]`);if(a)return window.require?.config?void o(e):(a.addEventListener("load",()=>{o(e)},{once:!0}),void a.addEventListener("error",n,{once:!0}));const i=document.createElement("script");i.src=t,i.onload=()=>{o(e)},i.onerror=n,document.head.appendChild(i)}),e)}var i={tag:"ok-monaco",attr:{value:{default:""},language:{default:"javascript"},suggestions:{default:[]},theme:{default:null},options:{},autogrow:{default:!1,empty:!0}},register(e){e.shared.monaco={load:a}},context:e=>(Object.defineProperty(e.$el,"value",{get:()=>e.$innerContext.value,set(t){e.$innerContext.set(t)},enumerable:!0,configurable:!0}),e.$cache.completionDisposable=null,{get suggestions(){return e.$attr.suggestions||[]},get language(){return e.$attr.language},value:e.$attr.value||"",editor:null,container:null,ready:!1,set(t){this.value=t,e.$cache.editor&&e.$cache.editor.getValue()!==t&&e.$cache.editor.setValue(""+t)},get(){return this.value},registerSuggestions(){window.monaco&&this.language&&this.suggestions.length&&(e.$cache.completionDisposable?.dispose(),e.$cache.completionDisposable=monaco.languages.registerCompletionItemProvider(this.language,{provideCompletionItems:()=>{const e="html"===this.language,t="css"===this.language;return{suggestions:this.suggestions.map(o=>e?{label:`<${o}>`,kind:monaco.languages.CompletionItemKind.Snippet,insertText:`<${o}>\n\t$0\n</${o}>`,insertTextRules:monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,documentation:`Component: ${o}`}:t?{label:o,kind:monaco.languages.CompletionItemKind.Keyword,insertText:o,documentation:`Selector: ${o}`}:{label:o,kind:monaco.languages.CompletionItemKind.Text,insertText:o})}}}))},async initEditor(){try{await a()}catch(t){throw e.$error("MONACO_LOAD_FAILED",t)}if(this.registerSuggestions(),e.$cache.editor=monaco.editor.create(this.container,{value:this.value,language:this.language,theme:n(e),automaticLayout:!0,fontSize:14,scrollBeyondLastLine:!1,minimap:{enabled:!1},lineNumbersMinChars:2,...e.$attr.options||{}}),e.$attr.autogrow){const t=e.$cache.editor,o=()=>{const e=t.getContentHeight();this.container.style.height=e+"px",t.layout()};t.onDidContentSizeChange(o),e.$attr.readonly&&t.updateOptions({readOnly:!0,renderLineHighlight:"none",occurrencesHighlight:!1,selectionHighlight:!1}),o()}e.$cache.editor.onDidChangeModelContent(()=>{const t=e.$cache.editor.getValue();t!==this.value&&(this.value=t,e.$dispatch("editor-change",this.value))});const t=monaco.KeyMod.CtrlCmd|monaco.KeyCode.KeyS;e.$cache.editor.addCommand(t,()=>{e.$dispatch("editor-save",{value:e.$cache.editor.getValue()})}),this.ready=!0}}),mounted(e){e.$watch(()=>e.$attr.value,t=>{if(e.$cache.editor){const t=e.$cache.editor,o=t.getValue(),n=e.$attr.value||"";if(o!==n){const e=t.getPosition(),o=t.getScrollTop(),a=t.getScrollLeft();t.setValue(""+n),e&&t.setPosition(e),t.setScrollTop(o),t.setScrollLeft(a)}}}),e.$watch(()=>e.$attr.suggestions,e=>{this.registerSuggestions()}),e.$watch(()=>e.$attr.language,t=>{e.$cache.editor&&e.$cache.editor.getModel()&&(monaco.editor.setModelLanguage(e.$cache.editor.getModel(),t[0].newValue),this.registerSuggestions())}),e.$watch(()=>e.$attr.theme,()=>{e.$cache.editor?.updateOptions({theme:n(e)})})},async init(e){await this.initEditor();const t=t=>{"--ok-monaco-theme"===t.propertyName&&null==e.$attr.theme&&e.$cache.editor?.updateOptions({theme:n(e)})};e.$el.addEventListener("transitionstart",t),e.$cache.themeListener=t},unmounted(e){e.$el.removeEventListener("transitionstart",e.$cache.themeListener),e.$cache.completionDisposable?.dispose(),e.$cache.editor?.dispose()},template:'<div style="width:100%;height:100%" :ref="container = $el"/>',style:'@property --ok-monaco-theme{syntax:"<custom-ident>";inherits:true;initial-value:vs-dark}[tag]{display:flex;flex-direction:column;flex:1;min-height:0;min-width:0;transition:--ok-monaco-theme 1ms allow-discrete}'};export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./ok-layer.ok.js";var t={tag:"ok-layer-service",dependencies:[e],template:"",mounted(e){e.$ok.shared.layer?.__setContainer(e.$el)},unmounted(e){e.$ok.shared.layer?.__clearContainer(e.$el)},register(e,t){if(e.shared.layer?.__okLayerService)return;const r={dropdown:1e3,window:2e3,modal:3e3,flyover:3100,contextmenu:3200,highlight:3500,toast:4e3,tooltip:5e3},n={surface:0,dropdown:10,flyover:20,contextmenu:30,tooltip:40,modal:0,highlight:0,toast:0};let a=null,o=null;const l=new Map;let i=new WeakMap;const s=e=>e?e instanceof Element?e:e.currentTarget instanceof Element?e.currentTarget:e.target instanceof Element?e.target:null:null,y=(e,t)=>{e.dataset.okLayerOwner=t.type,null!=t.tier&&(e.dataset.okLayerTier=t.tier),e.dataset.okLayerZ=String(t.z??0),e.style.setProperty("--ok-layer-owner-z",String(t.z??0))};e.shared.layer=e.proxy({__okLayerService:!0,__setContainer(e){a=e},__clearContainer(e){a===e&&(a=null,l.clear(),i=new WeakMap)},get container(){return a},awaitContainer:async()=>(a?.isConnected||(o||(o=e.shared.singleton.toggle("ok-layer-service",!0,{registration:t}).finally(()=>{o=null})),await o),a),async createLayer({type:t="global",tier:r=t,zIndex:n=null,owner:a=null}={}){const o=await this.awaitContainer();if(!o)return null;const l=e.config.document.createElement("ok-layer");return l.setAttribute("type",t),null!=r&&l.setAttribute("tier",r),l.dataset.okLayer=t,null!=r&&(l.dataset.okLayerTier=r),l.style.zIndex=String(n??this.resolveLayerZ(r)),o.appendChild(l),await e.init(l),l},async globalLayer(e="layer"){const t=String(e??"layer"),r=l.get(t);if(r?.isConnected)return r;if(r?.layer?.isConnected)return r.layer;if(r?.promise)return r.promise;const n=(async()=>{const e=await this.createLayer({type:"global",tier:t,zIndex:this.resolveLayerZ(t)});return l.set(t,{layer:e}),e})();return l.set(t,{promise:n}),n},async ownerLayer(e,{type:t="owner",tier:r="window",zIndex:n=null}={}){const a=s(e);if(!a)return null;const o=i.get(a);if(o?.layer?.isConnected)return o.layer;if(o?.promise)return o.promise;const l=n??o?.z??this.resolveLayerZ(r),u=(async()=>{const e=await this.createLayer({type:t,tier:r,zIndex:l,owner:a}),{promise:n,...o}=i.get(a)??{},s={...o,layer:e,type:t,tier:r,z:l};return i.set(a,s),y(a,s),a.dispatchEvent(new CustomEvent("ok-layer-owner-change",{bubbles:!0,detail:{owner:a,type:t,tier:r,z:l,layer:e}})),e})();return i.set(a,{...o,promise:u,type:t,tier:r,z:l}),u},ownerLayerOf(e){const t=s(e);return t?i.get(t)?.layer??null:null},async containerFor(e=null,t="layer"){const r=this.ownerOf(e),n=this.ownerLayerOf(r);if(n?.isConnected)return n;if(r){const e=i.get(r),t=e?.tier||r.dataset.okLayerTier||"window";return this.ownerLayer(r,{type:e?.type||r.dataset.okLayerOwner||"owner",tier:t,zIndex:e?.z??Number(r.dataset.okLayerZ||this.resolveLayerZ(t))})}return this.globalLayer(t)},async toggle(t,r=null,{registration:n,container:a,layer:o=null,tier:l=o,owner:i=null,zIndex:s=null}={}){const y=l??o;!1!==r&&(a??=await this.containerFor(i,y??t));const u=await e.shared.singleton.toggle(t,r,{registration:n,container:a});if(u&&(null!=s||null!=y)){const e=s??this.resolveLocalZ(y);u.style.zIndex=String(e)}return u},resolveLayerZ(e){if("number"==typeof e)return e;const t=Number(e);return isNaN(t)||""===String(e).trim()?r[e]??9e3:t},resolveLocalZ(e){if("number"==typeof e)return e;const t=Number(e);return isNaN(t)||""===String(e).trim()?n[e]??n.surface:t},markOwner(e,{type:t="owner",tier:r=null,z:n=0}={}){const a=s(e);if(!a)return null;const o=i.get(a)??{},l={...o,type:t,tier:r??o.tier??a.dataset.okLayerTier??t,z:Number(n)};return"OK-LAYER"===a.tagName&&(l.layer=a),i.set(a,l),y(a,l),l.layer?.isConnected&&(l.layer.style.zIndex=String(l.z)),a.dispatchEvent(new CustomEvent("ok-layer-owner-change",{bubbles:!0,detail:{owner:a,type:l.type,tier:l.tier,z:l.z,layer:l.layer??null}})),a},restackOwner(e,{type:t="owner",tier:r=null,z:n=0}={}){const a=this.markOwner(e,{type:t,tier:r,z:n});if(!a)return null;const o=i.get(a);return"OK-LAYER"===a.tagName?a.style.zIndex=String(o.z):o?.layer?.isConnected?(o.layer.style.zIndex=String(o.z),a.style.zIndex=String(this.resolveLocalZ("surface"))):a.style.zIndex=String(o.z),o},clearOwner(e){const t=s(e);if(!t)return!1;delete t.dataset.okLayerOwner,delete t.dataset.okLayerTier,delete t.dataset.okLayerZ,t.style.removeProperty("--ok-layer-owner-z");const r=i.get(t),n=r?.layer;return n!==t&&n?.parentNode&&n.remove(),i.delete(t),requestAnimationFrame(()=>this.pruneEmpty()),!0},pruneEmpty(){a?.querySelectorAll?.('ok-layer[data-ok-layer]:not([data-ok-layer="global"])').forEach(e=>{e.children.length||e.remove()});for(const[e,t]of l)t.layer&&!t.layer.isConnected&&l.delete(e)},ownerOf(e){const t=s(e);return t?.closest?.("[data-ok-layer-owner]")??null},defineLayerZ(e,t){r[e]=Number(t)},defineLocalZ(e,t){n[e]=Number(t)},async dispose(){const t=a;o=null,t&&(await(e.shared.singleton?.toggle?.("ok-layer-service",!1)),t.remove?.()),a=null,l.clear(),i=new WeakMap},get tiers(){return{...r}},get localTiers(){return{...n}}})},style:"[tag]{position:fixed;inset:0;z-index:9999;pointer-events:none}"};export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../interaction/ok-portal-service.ok.js";var t={tag:"ok-layer",dependencies:[e],template:"<slot/>",attr:{type:{default:"layer"},tier:{default:null},order:{default:0},noPortal:{empty:!0},owner:{default:!0,empty:!0}},context(e){const t=()=>{const t=e.$ok.shared.layer,r=e.$attr.type||"layer",a=e.$attr.tier??r,o=Number(e.$attr.order||0);e.$el.dataset.okLayer=r,null!=a&&(e.$el.dataset.okLayerTier=a);const l=(t?.resolveLayerZ?.(a)??0)+o;e.$el.style.zIndex=String(l);const n=String(t?.resolveLocalZ?.("surface")??0);if(e.$el.style.setProperty("--ok-layer_surface-z",n),e.$el.style.setProperty("--ok-overlay_z",n),e.$el.style.setProperty("--ok-z-modal",n),e.$el.style.setProperty("--ok-window_z",n),!1!==e.$attr.owner&&"global"!==r&&t?.markOwner?.(e.$el,{type:r,tier:a,z:l}),e.$attr.noPortal)return;const s=e.$ok.shared.portal;t&&s&&t.awaitContainer().then(t=>{!t||e.$__unmount__$||e.$attr.noPortal||(s.to(e.$el,t),e.$cache.layerPortalActive=!0)})};return e.$watch(()=>[e.$attr.type,e.$attr.tier,e.$attr.order,e.$attr.noPortal,e.$attr.owner],()=>{t()}),{sync:t}},mounted(e){this.sync()},unmounted(e){e.$cache.layerPortalActive&&(e.$ok.shared.portal?.back(e.$el),e.$cache.layerPortalActive=!1),e.$ok.shared.layer?.clearOwner?.(e.$el)},style:"[tag]{position:fixed;inset:0;pointer-events:none;isolation:isolate;--ok-layer_surface-z:0;--ok-overlay_z:var(--ok-layer_surface-z);--ok-z-modal:var(--ok-layer_surface-z);--ok-window_z:var(--ok-layer_surface-z)}[tag]>*{pointer-events:auto}"};export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={tag:"ok-overlay",attr:{backdropAction:{default:"close"}},plugins:{theme:{expose:{"--ok-overlay_bg":{default:"rgba(0,0,0,0.3)",type:"color",description:"Overlay background color",category:"Colors"}}}},template:"<slot/>",mount(e){const t=()=>{const t="pass-through"===e.$attr.backdropAction||"click-through"===e.$attr.backdropAction;e.$el.style.pointerEvents=t?"none":"auto"};t(),e.$watch(()=>e.$attr.backdropAction,t),e.$el.setAttribute("tabindex","-1"),e.$cache.prevFocus=document.activeElement,e.$el.focus(),e.$listen(e.$el,"keydown",t=>{"Tab"===t.key&&t.srcElement===e.$el&&(t.$el.firstElementChild()?.focus(),t.preventDefault()),"Escape"===t.key&&(e.$dispatch("request-close"),t.preventDefault())});const o=t=>{e.$cache.backdropPressStarted=t.target===e.$el};e.$listen(e.$el,"pointerdown",o,!0),e.$listen(e.$el,"mousedown",o,!0),e.$listen(e.$el,"click",t=>{const o=e.$attr.backdropAction,a=e.$cache.backdropPressStarted;e.$cache.backdropPressStarted=null,"pass-through"!==o&&"click-through"!==o&&(t.target===e.$el&&"close"===o&&!1!==a?(e.$dispatch("request-close"),t.preventDefault(),t.stopPropagation()):t.target===e.$el&&(t.preventDefault(),t.stopPropagation()))})},unmounted(e){e.$cache.prevFocus?.focus()},style:"[tag]{position:absolute;left:0;top:0;right:0;bottom:0;display:block;background:var(--ok-overlay_bg);z-index:var(--ok-overlay_z, 1000)}[tag]>*{pointer-events:auto}"};export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={tag:"ok-sandbox",init(e){const o=e.$ok.createNodes(e.$cache.cmp.templates.default),t=e.$el.attachShadow({mode:"open"}),a=e.$ok.OK({env:"sandbox",head:t,body:t});a.componentRegistry.cache=e.$ok.componentRegistry.cache,t.append(...o),t.$scope=a.scope(t,{$parent:null,$context:e.$context,$vars:e.$vars}),a.init(t)}};export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t){return new Promise(a=>{const e=()=>{i(),a()},i=()=>{clearTimeout(p),t.removeEventListener("transitionend",e),t.removeEventListener("animationend",e)};t.addEventListener("transitionend",e),t.addEventListener("animationend",e);const n=getComputedStyle(t),r=n.transitionDuration.split(",").map(parseFloat),o=n.transitionDelay.split(",").map(parseFloat),s=n.animationDuration.split(",").map(parseFloat),l=n.animationDelay.split(",").map(parseFloat),d=Math.max(...o.map((t,a)=>t+(r[a]||0))),m=Math.max(...l.map((t,a)=>t+(s[a]||0)));let c=1e3*Math.max(d,m);isFinite(c)&&0!==c||(c=0);const p=setTimeout(e,c)})}var a={tag:"transition",lazy:!0,attr:{noEnter:{empty:!0},noLeave:{empty:!0},disabled:{empty:!0},name:{default:"ok"}},mount(t){if(t.$attr.noEnter||t.$attr.disabled)return;const a=t.$el,e=t.$attr.name;a.classList.add(`${e}-enter`)},async ready(a){if(a.$attr.noEnter||a.$attr.disabled)return;const e=a.$el,i=a.$attr.name;e.classList.add(`${i}-enter-active`),await t(e),e.classList.remove(`${i}-enter`),e.classList.remove(`${i}-enter-active`),e.style.transitionDuration=""},async unmount(a){if(a.$attr.noLeave||a.$attr.disabled)return;const e=a.$el;if(!e)return;const i=a.$attr.name;e.classList.add(`${i}-leave`),await a.$ok.awaitFrame(),e.classList.add(`${i}-leave-active`),await t(e)},unmounted(t){if(t.$attr.noLeave||t.$attr.disabled)return;const a=t.$el;if(!a)return;const e=t.$attr.name;a.classList.remove(`${e}-leave`),a.classList.remove(`${e}-leave-active`)},plugins:{theme:{expose:{"--ok-transition-duration":{default:"0.3s"}}}},template:'<slot :ref="slotRef=$el"/>',style:"[data-ok].fade-enter{opacity:0}[data-ok].fade-enter-active{opacity:1;transition:opacity .3s ease}[data-ok].fade-leave{opacity:1}[data-ok].fade-leave-active{opacity:0;transition:opacity .3s ease}[data-ok].grow-enter{display:grid!important;overflow:hidden;grid-template-rows:minmax(0,0fr)}[data-ok].grow-enter-active{will-change:transform,opacity;backface-visibility:hidden;transform:translateZ(0);grid-template-rows:minmax(0,1fr);opacity:1;transition:grid-template-rows .3s ease,opacity .3s ease}[data-ok].grow-leave{display:grid!important;overflow:hidden;grid-template-rows:minmax(0,1fr)}[data-ok].grow-leave-active{will-change:transform,opacity;backface-visibility:hidden;transform:translateZ(0);grid-template-rows:minmax(0,0fr);transition:grid-template-rows .3s ease,opacity .3s ease}[data-ok].grow-inline-enter{display:inline-grid!important;overflow:hidden;grid-template-columns:minmax(0,0fr)}[data-ok].grow-inline-enter-active{grid-template-columns:minmax(0,1fr);transition:grid-template-columns 0 ease}[data-ok].grow-inline-leave{display:inline-grid!important;overflow:hidden;grid-template-columns:minmax(0,1fr)}[data-ok].grow-inline-leave-active{grid-template-columns:minmax(0,0fr);transition:grid-template-columns 3s ease}"};export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t,e){let s=0,i=t.length-1;for(;s<=i;){const l=Math.floor((s+i)/2);t[l]<e?s=l+1:i=l-1}return s}var e={tag:"virtualized",attr:{items:{alias:[""],default:[]}},context(e){const s=[],i=[];let l=0,h=0,r=new Set,a=0,o=!1,n=!1;return{get firstLoad(){return e.$attr.firstLoad||10},get overscan(){return Math.max(e.$attr.overscan||2,1)},get defaultHeight(){return Number.parseInt(e.$attr.defaultHeight??50)},get averageHeight(){return null!=e.$attr.defaultHeight?this.defaultHeight:h>0?l/h:50},get items(){return e.$attr.items||[]},get itemClass(){return e.$attr.itemClass||"virtualized-item"},atTop:!0,atBottom:!1,scrollTop:0,offsetTop:0,offsetBottom:0,start:0,startVisible:0,endVisible:0,end:0,view:[],scroller:null,syncHeights(){const t=this.averageHeight,e=this.items.length;s.length=e,i.length=e;for(let l=0;l<e;l++)s[l]=s[l]??t,i[l]=(i[l-1]||0)+s[l]},handleUnshift(t){const e=this.averageHeight;for(let l=0;l<t;l++)s.unshift(e),i.unshift((i[0]||0)+e)},handlePush(t){const e=this.averageHeight;for(let l=0;l<t;l++){const t=i.length>0?i[i.length-1]:0;s.push(e),i.push(t+e)}},handlePop(){s.pop(),i.pop()},handleShift(){s.shift(),i.shift();for(let t=0;t<i.length;t++)i[t]=(i[t-1]||0)+s[t]},handleSplice(t,e,l){const h=this.averageHeight;s.splice(t,e,...Array(l).fill(h)),i.length=0;for(let t=0;t<s.length;t++)i[t]=(i[t-1]||0)+s[t]},handleReplace(){const t=this.averageHeight,e=this.items.length;s.length=e,i.length=e;for(let l=0;l<e;l++)s[l]=t,i[l]=(i[l-1]||0)+t},scheduleUpdate(t=!1){o||=t,n||(n=!0,setTimeout(()=>{n=!1,this.update(o),o=!1},100))},update(s){if(!this.scroller)return;let l=null!=a?a:this.scrollTop;if(l>=i[this.items.length-1]&&(l=i[this.items.length-1]-this.scroller.clientHeight),!s&&l===this.scrollTop&&this.view.length>0)return;const h=t(i,l),r=t(i,l+this.scroller.clientHeight),o=Math.max(h-this.overscan,0),n=Math.min(r+this.overscan,this.items.length-1);if(o===this.start&&n===this.end&&!s)return;this.scrollTop=l,this.start=o,this.end=n,this.startVisible=Math.max(o,h),this.endVisible=Math.min(n,r),this.offsetTop=(i[this.startVisible]||0)-(i[this.start]||0),this.offsetTop+=this.scrollTop-(i[this.startVisible-1]||0),this.offsetBottom=(i[i.length-1]||0)-(i[this.endVisible]||0),this.view=this.items.slice(this.start,this.end+1);const c=i[i.length-1]||0,d=getComputedStyle(e.$el),g=parseFloat(d.minHeight)||0,p=parseFloat(d.maxHeight)||1/0,u=Math.max(g,Math.min(c,p));this.scroller.style.height=u+1+"px",this.atTop=this.scrollTop<=5,this.atBottom=this.scrollTop+this.scroller.clientHeight>=this.scroller.scrollHeight-1},updateItemSize(t){const e=t.$vars.index+this.start;if(e>=this.items.length)return;const r=t.$el.offsetHeight,a=s[e];if(a!==r){l+=r-(a||0),a||h++,s[e]=r,i[e]=(i[e-1]||0)+r;for(let t=e+1;t<i.length;t++)i[t]=(i[t-1]||0)+(s[t]??this.averageHeight);this.scheduleUpdate(!0)}else this.scheduleUpdate()},itemMounted(t){r.add(t),e.$ok.nextFrame(()=>{r.delete(t),this.updateItemSize(t);const s=t.$el;e.$cache.virtualized.resizeMap.set(s,t),e.$cache.virtualized.resizeObserver.observe(s)})},itemUnmounted(t){const s=e.$cache.virtualized;t?.$el&&s.resizeObserver&&(s.resizeObserver.unobserve(t.$el),s.resizeMap.delete(t.$el))},onScroll(t){a=t.target.scrollTop,this.scheduleUpdate()}}},mount(t){const e=t.$cache.virtualized={resizeMap:new WeakMap,resizeObserver:null};e.resizeObserver=new ResizeObserver(s=>{t.$ok.nextFrame(()=>{for(const t of s){const s=e.resizeMap.get(t.target);s&&this.updateItemSize(s)}})});const s=t=>{if(Array.isArray(t.target))if("length"===t.property){switch(t.mode){case"splice":const[e,s,...i]=t.args;this.handleSplice(e,s,i.length);break;case"push":this.handlePush(t.args.length);break;case"pop":this.handlePop();break;case"shift":this.handleShift();break;case"unshift":this.handleUnshift(t.args.length);break;default:this.handleReplace()}this.scheduleUpdate(!0)}else"set"===t.mode&&this.scheduleUpdate(!0)};t.$watch(()=>this.items,()=>{this.syncHeights(),this.scheduleUpdate(!0),t.$observe(this.items,null,s)}).run()},template:'<slot name="before"/><div :ref="scroller=$el" style="min-height:100%;overflow:auto;margin:0;position:relative" @scroll="onScroll"><div style="position:absolute;width:100%" :style="{ \'top\': -offsetTop + \'px\' }"><div class="spacer-top" :style="{ \'padding-bottom\': scrollTop + \'px\' }"/><slot name="top"/><each :of="view" let:item let:index><div @mounted="itemMounted" @unmounted="itemUnmounted" :class="{[itemClass]: true, \'--visible\': item >= startVisible && item <= endVisible }"><slot :var:item="item" :var:index="index + start"/></div></each><slot name="bottom"/><div class="spacer-bottom" :style="({ \'padding-top\': offsetBottom + \'px\' })"/></div></div><slot name="after"/>',style:"[tag]{position:relative;overflow:hidden;flex-grow:1;max-height:100%}"};export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s={tag:"console-service",register(s){const o=s.proxy({logs:[]});s.shared.console={get logs(){return o.logs},max:s.config.shared.console?.max??1e3,print:s.config.shared.console?.print??"prod"!==s.config.env,collect:s.config.shared.console?.collect??"prod"!==s.config.env,_off:null,start(){this._off||(this._off=s.on("log",o=>{this.print&&!s.config.log.console&&s.log.printToConsole(o),this.collect&&(this.logs.push(o),this.logs.length>this.max&&this.logs.splice(0,this.logs.length-this.max))}))},stop(){this._off?.stop(),this._off=null},remove(s){const o=this.logs.indexOf(s);-1!==o&&this.logs.splice(o,1)},clear(s=[],o=null){if(s?.length||o)for(let l=this.logs.length-1;l>=0;l--){const e=this.logs[l],t=!s?.length||s.every(s=>e.tags.includes(s)),n=!o||o(e);t&&n&&this.logs.splice(l,1)}else this.logs.splice(0)},has(s=[],o=null){return this.logs.some(l=>(!s?.length||s.every(s=>l.tags.includes(s)))&&(!o||o(l)))},get(s=[],o=null){return this.logs.filter(l=>(!s?.length||s.every(s=>l.tags.includes(s)))&&(!o||o(l)))}},s.shared.console.start()}};export{s as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={tag:"console",dependencies:["./ok-console-service.ok.js"],context:e=>({query:"",collapsed:new WeakSet,activeTag:null,get logs(){const o=e.$ok.shared.console.logs;if(this.activeTag)return o.filter(e=>e.tags.includes(this.activeTag));if(!this.query)return o;const a=this.query.toLowerCase();return o.filter(e=>e.tags.some(e=>e.toLowerCase().includes(a))||JSON.stringify(e.data).toLowerCase().includes(a))},get allTags(){const o=new Set;for(const a of e.$ok.shared.console.logs)for(const e of a.tags)o.add(e);return[...o].sort()},toggle(e){this.collapsed.has(e)?this.collapsed.delete(e):this.collapsed.add(e)},isCollapsed(e){return this.collapsed.has(e)},clear(){e.$ok.shared.console.clear()},remove(o){e.$ok.shared.console.remove(o)},filterBy(e){this.activeTag=this.activeTag===e?null:e,this.query=""}}),mounted(e){const o=new MutationObserver(()=>{const o=e.$el.querySelector(".logs");o.scrollTop=o.scrollHeight});e.$ext("unmount",()=>o.disconnect())},template:'<div class="toolbar"><input type="text" :bind="query" placeholder="Search logs..."><button @click="clear">Clear</button></div><div class="tags"><each :="allTags" let:item="tag"><button class="tag-btn" :class="{ active: activeTag === tag }" @click="filterBy(tag)">{{ tag }}</button></each></div><div class="logs"><virtualized :="logs" let:item="log"><div class="log" :class="[ log.tags.includes(\'error\') && \'error\', log.tags.includes(\'warn\') && \'warn\', log.tags.includes(\'info\') && \'info\', log.tags.includes(\'verbose\') && \'verbose\', isCollapsed(log) && \'collapsed\' ]"><div class="header" @click="toggle(log)"><span class="tags"><each :="log.tags" let:item="tag"><span class="tag">{{ tag }}</span></each></span><span class="time">{{ new Date(log.timestamp).toLocaleTimeString() }}</span> <button class="remove" @click="remove(log)">✕</button></div><if :="log.data instanceof Error"><ok-crash-info no-close :error="log.data" style="max-height:100%"/><else><pre class="data">{{ JSON.stringify(log.data, null, 2) }}</pre></else></if></div></virtualized></div>',style:"[tag]{display:flex;flex-direction:column;flex:1;min-height:0;min-width:0;font-family:monospace}.tags,.toolbar{display:flex;padding:4px}.toolbar{gap:6px;background:#222}.toolbar input{flex:1;padding:2px 6px;background:#111;color:#eee;border:1px solid #444}.toolbar button{background:#333;color:#eee;border:0;padding:4px 8px;cursor:pointer}.tags{flex-wrap:wrap;gap:4px;background:#181818}.tag-btn{padding:2px 6px;border:0;background:#333;color:#ccc;cursor:pointer;border-radius:4px;font-size:.85em}.tag-btn.active{background:#555;color:#fff;font-weight:700}.logs{flex:1;overflow:auto;background:#111;color:#eee}.log{border-bottom:1px solid #333}.log .header{display:flex;justify-content:space-between;align-items:center;padding:4px;cursor:pointer;background:#181818}.log.collapsed .data{display:none}.log .tags{display:flex;gap:6px;flex-wrap:wrap}.log .tag{background:#333;color:#9cf;padding:2px 6px;border-radius:4px;font-size:.85em}.log .time{font-size:.75em;color:#aaa;margin-left:auto;margin-right:8px}.log .remove{background:0 0;border:0;color:#f66;font-size:1em;cursor:pointer}.log .data{padding:4px 8px;white-space:pre-wrap;word-break:break-word;background:#1a1a1a}.log.info .tag{background:#224;color:#6cf}.log.warn .tag{background:#442;color:#fd4}.log.error .tag{background:#411;color:#f66}.log.verbose .tag{background:#113;color:#aaa}"};export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"./ok-fps-monitor.ok.js";import e from"../modals/ok-window.ok.js";import t from"../interaction/ok-hotkeys-service.ok.js";var i={tag:"ok-fps-monitor-service",dependencies:[o,e,t],register(o,e){o.shared.fps={toggle:async(t=null)=>o.shared.layer.toggle("ok-fps-monitor-service",t,{registration:e,tier:"window"})},("dev"===o.config.env||!0===o.config.shared.fps?.register)&&o.shared.hotkeys.register(["ctrl","shift","f"],{description:"Toggle FPS Monitor",keydown(e){e.repeat||o.shared.fps.toggle()}})},template:'<ok-window no-portal title="FPS" no-maximize autohidehud style="--ok-window_padding:0;max-height:fit-content;max-width:fit-content;min-width:fit-content" @close="$ok.shared.fps.toggle(false)"><ok-fps-monitor/></ok-window>'};export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o={tag:"ok-fps-monitor",context:()=>({rafFps:0,rafFrameCount:0,lastRafTime:performance.now(),rafHistory:[],maxPoints:50,running:!0,get rafPoints(){return this.rafHistory.map((o,i)=>`${2*i},${40-o*(40/144)}`).join(" ")},tickRaf(){this.running&&requestAnimationFrame(()=>{const o=performance.now();this.rafFrameCount++,o-this.lastRafTime>=1e3&&(this.rafFps=this.rafFrameCount,this.rafHistory.push(Math.min(this.rafFps,144)),this.rafHistory.length>this.maxPoints&&this.rafHistory.shift(),this.rafFrameCount=0,this.lastRafTime=o),this.tickRaf()})}}),mount(o){this.tickRaf()},unmount(o){this.running=!1},template:'<div><div>FPS: {{ rafFps }}</div><svg width="100" height="40"><line x1="0" y1="0.5" x2="100" y2="0.5"/><line x1="0" y1="23.3" x2="100" y2="23.3"/><line x1="0" y1="39.5" x2="100" y2="39.5"/><polyline :points="rafPoints"/></svg></div>',style:"[tag]{display:inline-block;background:var(--ok-fps-monitor-bg, #000);color:var(--ok-fps-monitor-color, #0f0);font-family:monospace;font-size:14px;padding:.5rem 1rem}svg line:first-child{stroke:var(--ok-fps-monitor-grid, #333)}svg line:nth-child(2){stroke:var(--ok-fps-monitor-grid-mid, #555)}svg line:last-child{stroke:var(--ok-fps-monitor-grid, #333)}svg polyline{stroke:var(--ok-fps-monitor-line, #0f0);fill:none}",plugins:{theme:{expose:{"--ok-fps-monitor-bg":{default:"#000",type:"color",description:"Background color",category:"FPS Monitor"},"--ok-fps-monitor-color":{default:"#0f0",type:"color",description:"Text color",category:"FPS Monitor"},"--ok-fps-monitor-line":{default:"#0f0",type:"color",description:"FPS line color",category:"FPS Monitor"},"--ok-fps-monitor-grid":{default:"#333",type:"color",description:"Grid line color",category:"FPS Monitor"},"--ok-fps-monitor-grid-mid":{default:"#555",type:"color",description:"Middle dashed line color",category:"FPS Monitor"}}}}};export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../modals/ok-window.ok.js";import o from"./ok-inspector.ok.js";import t from"../interaction/ok-hotkeys-service.ok.js";import s from"../interaction/ok-picker-service.ok.js";var i={tag:"ok-inspector-service",dependencies:[t,s,e,o],plugins:{theme:{set:{"--ok-window_header-bg":"#717171"}}},register(e,o){e.shared.inspector={window:null,scope:null,async toggle(t=null,s={}){const i=await e.shared.layer.toggle("ok-inspector-service",t,{registration:o,tier:"window"});if(i){const o=i.querySelector("ok-inspector");this.window=i.$scope,this.scope=o?.$scope??null,s.pick&&e.shared.picker.start({onPick:e=>{this.scope.$innerContext.selectElement(e)}})}else this.window=null,this.scope=null},async inspect(e){e instanceof Node&&(!e.nodeType!==Node.ELEMENT_NODE&&(e=e.parentNode),await this.toggle(!0),this.scope?.$innerContext.selectElement(e))}},"dev"!==e.config.env&&!0!==e.config.shared.inspector?.register||e.shared.hotkeys.register(["ctrl","shift","alt"],{description:"Toggle Inspector Picker",keydown(o){o.repeat||e.shared.picker.start({onPick:o=>{e.shared.inspector.toggle(!0).then(()=>{e.shared.inspector.scope?.$innerContext.selectElement(o)})}})},keyup(){e.shared.picker.stop()}})},template:'<ok-window no-portal style="--ok-window_padding:0" @close="$ok.shared.inspector.toggle(false)" title="Inspector"><ok-inspector/></ok-window>'};export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={tag:"ok-inspector",dependencies:["../theming/ok-design.ok.js",{tag:"ok-js-tree",import:"./ok-js-tree.ok.js"},"../interaction/ok-picker-service.ok.js","../interaction/ok-highlight-service.ok.js"],context(e){const t=e.$ok.proxy({selectedEl:null,selectedScope:null,tree:{parent:null,siblings:[],children:[],currentIndex:-1},selectElement(e){if(!(e instanceof Element))return;t.clearOutline(),t.selectedEl=e,t.selectedScope=e.$scope||null,e&&(e.___oldOutline=e.style.outline,e.style.outline="2px solid #0f0");const l=e.parentElement?.$scope,i=Array.from(e.parentElement?.children||[]).filter(e=>e.$scope),o=i.findIndex(t=>t===e),s=Array.from(e.children||[]).filter(e=>e.$scope);t.tree={parent:l,siblings:i,children:s,currentIndex:o}},clearOutline(){t.selectedEl&&(t.selectedEl.style.outline=t.selectedEl.___oldOutline||"",delete t.selectedEl.___oldOutline)},close(){t.clearOutline(),t.selectedEl=null,t.selectedScope=null},onKeydown(e){if(!t.selectedEl)return;let l=null;switch(e.key){case"Escape":return void t.close();case"ArrowUp":l=t.tree.parent?.$el;break;case"ArrowLeft":l=t.tree.siblings[t.tree.currentIndex-1];break;case"ArrowRight":l=t.tree.siblings[t.tree.currentIndex+1];break;case"ArrowDown":l=t.tree.children[0]}l&&t.selectElement(l)},highlight(){e.$ok.shared.highlight.show(t.selectedEl)},async reload(){const e=await this.selectedScope.$reload();this.selectElement(e.$el)},get canReload(){return!(!this.selectedScope||!this.selectedScope.$isCmp)}});return t},mounted(e){e.$listen(window,"keydown",this.onKeydown)},unmounted(e){this.close()},template:'<div><div style="display:flex;justify-content:space-between;margin-bottom:.5rem"><strong>Inspector</strong><div style="display:flex;gap:.5rem"><button @click="highlight" class="ok-inspector__button">Highlight</button> <button @click="$ok.shared.picker.start({ onPick: selectElement })" class="ok-inspector__button">Pick</button> <button :disabled="!canReload" @click="reload" class="ok-inspector__button">Reload</button></div></div><if :="selectedEl"><div><strong>Tag:</strong> {{ selectedEl?.nodeType === 3 ? \'[Text]\' : selectedEl?.tagName }}</div><if :="selectedScope"><div><strong>ID:</strong> {{ selectedScope?.id }}</div><div><strong>State:</strong> {{ selectedScope?.$state }}</div><div><strong>$vars:</strong></div><each :="selectedScope?.$vars || {}" let:key let:item><ok-js-tree :key :item :parent="selectedScope?.$vars" editable/></each><div><strong>$context:</strong></div><each :="selectedScope?.$context || {}" let:key let:item><ok-js-tree :key :item :parent="selectedScope?.$context" editable/></each><div><strong>$attr:</strong></div><each :="selectedScope?.$attr || {}" let:key let:item><ok-js-tree :key :item :parent="selectedScope?.$attr"/></each><else>No scope available for this element.</else></if><hr><div><div><strong>Parent</strong></div><div @click="selectElement(tree.parent?.$el)" style="padding:.5em">{{ tree.parent?.$el?.tagName || \'[None]\' }}</div><div><strong>Siblings</strong></div><each :="tree.siblings" let:item let:index><div @click="selectElement(item)" :style="{ background: item === selectedEl ? \'#333\' : \'\' }" style="padding:.25em">{{ item.tagName || \'[None]\' }}</div></each><div><strong>Children</strong></div><each :="tree.children" let:item><div @click="selectElement(item)" style="padding:.25em">{{ item?.tagName }}</div></each></div><else><div style="opacity:.7">No element selected.</div></else></if></div>',style:"[tag]{display:flex;flex-grow:1;flex-direction:column;background:var(--ok-inspector-bg, #111);color:var(--ok-inspector-fg, #0f0);padding:1rem;font-family:monospace;font-size:13px;overflow:auto;border:var(--ok_border, 1px solid #333)}",plugins:{theme:{expose:{"--ok-inspector-fg":{default:"#0f0",type:"color"},"--ok-inspector-bg":{default:"#111",type:"color"}},define:{default:{}}}}};export{e as default};
|