@marimo-team/islands 0.23.16-dev6 → 0.23.16-dev62
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/dist/{ConnectedDataExplorerComponent-CJaUI-S-.js → ConnectedDataExplorerComponent-f9vLjQiF.js} +13 -13
- package/dist/{ErrorBoundary-DXlxsrTF.js → ErrorBoundary-DhLqwSWA.js} +3 -3
- package/dist/{any-language-editor-P9tjkj4n.js → any-language-editor-DifE-fl7.js} +5 -5
- package/dist/{button-BcSml68y.js → button-BSm8IXRU.js} +2 -4
- package/dist/{capabilities-BYLFYTYv.js → capabilities-C6OQ5YBO.js} +1 -1
- package/dist/{chat-ui-BdSDiVjk.js → chat-ui-DsZJj75A.js} +3117 -3120
- package/dist/{check-Cs-KV5XY.js → check-DP7U0H0G.js} +1 -1
- package/dist/{code-visibility-CfBftiVM.js → common-Bpnmu1Yz.js} +1085 -1053
- package/dist/{copy-Cs3yt6Vt.js → copy-DNq8q3zw.js} +2 -2
- package/dist/{dist-B96tMAst.js → dist-DIlxLFXG.js} +2 -2
- package/dist/{error-banner-DR7o3CbX.js → error-banner-B_GQfxxD.js} +2 -2
- package/dist/{esm-k8PIvuZW.js → esm-DzZVaNH4.js} +1 -1
- package/dist/{extends-Cq2JYHKy.js → extends-w2_S44bV.js} +4 -4
- package/dist/{formats-BFhkZJwd.js → formats-Dwq1THhr.js} +3 -3
- package/dist/{glide-data-editor--CaN-f27.js → glide-data-editor-B9K6-MJe.js} +9 -9
- package/dist/{html-to-image-DDENewl2.js → html-to-image-CZ1kLKkq.js} +7350 -6356
- package/dist/{input-DStQIuqD.js → input-C5K4VBvB.js} +7 -7
- package/dist/{label-DIk0QoFe.js → label-DjoYwqmj.js} +2 -2
- package/dist/{loader-CTHCI-qe.js → loader-DX-IDS7n.js} +1 -1
- package/dist/main.js +259 -194
- package/dist/{mermaid-CdSvixW2.js → mermaid-hv6IckVw.js} +5 -5
- package/dist/{node-sql-parser-DLl_zNw0.js → node-sql-parser-v1Vi-Fft.js} +16867 -16665
- package/dist/{process-output-2QPcgBQg.js → process-output-bVfbcx5_.js} +32 -28
- package/dist/{reveal-component-BclLkYnV.js → reveal-component-JIt3oSeU.js} +642 -634
- package/dist/{spec-CnaxwDqy.js → spec-CQKL_D3i.js} +4 -4
- package/dist/{strings-BYAhZnQi.js → strings-DIy9NAmg.js} +4 -4
- package/dist/style.css +1 -1
- package/dist/{swiper-component-DE94711u.js → swiper-component-CEdAYjb7.js} +2 -2
- package/dist/toDate-CqhBWjvO.js +713 -0
- package/dist/{tooltip-B-qh7UPB.js → tooltip-f-qR0iUx.js} +3 -3
- package/dist/{types-DQl7jVYK.js → types-DicH9Oi0.js} +1 -1
- package/dist/{useAsyncData-CvO8WUy3.js → useAsyncData-CYOQb1EW.js} +1 -1
- package/dist/{useDateFormatter-BSoGim-G.js → useDateFormatter-Bt2qr_XS.js} +2 -2
- package/dist/{useDeepCompareMemoize-J3MKRdA4.js → useDeepCompareMemoize-CSHQeQEI.js} +1 -1
- package/dist/{useIframeCapabilities-POcFXHbw.js → useIframeCapabilities-kA09ykNq.js} +1 -1
- package/dist/{useLifecycle-DqPxHgAN.js → useLifecycle-CMJGqBaY.js} +3 -3
- package/dist/{useTheme-XMq9mNf_.js → useTheme-DYfby65G.js} +2 -2
- package/dist/{vega-component-CrFoZT1S.js → vega-component-C7nO5zcf.js} +10 -10
- package/dist/{zod-D0yOqoGe.js → zod-BUcyXSdR.js} +1 -1
- package/package.json +3 -4
- package/src/__mocks__/requests.ts +56 -4
- package/src/components/data-table/__tests__/__snapshots__/chart-spec-model.test.ts.snap +174 -21
- package/src/components/data-table/__tests__/chart-spec-model.test.ts +102 -1
- package/src/components/data-table/__tests__/columns.test.tsx +9 -1
- package/src/components/data-table/column-summary/chart-spec-model.tsx +163 -103
- package/src/components/data-table/column-summary/legacy-chart-spec.ts +15 -7
- package/src/components/data-table/column-summary/utils.ts +26 -7
- package/src/components/data-table/columns.tsx +11 -1
- package/src/components/data-table/types.ts +1 -1
- package/src/components/editor/__tests__/viewer-banner.test.tsx +14 -0
- package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +99 -18
- package/src/components/editor/actions/__tests__/pdf-export.test.ts +32 -13
- package/src/components/editor/actions/pair-with-agent-commands.ts +21 -10
- package/src/components/editor/actions/pair-with-agent-modal.tsx +2 -2
- package/src/components/editor/actions/pdf-export.ts +11 -14
- package/src/components/editor/actions/useNotebookActions.tsx +28 -19
- package/src/components/editor/cell/code/__tests__/cell-editor-activity-lifecycle.test.ts +250 -0
- package/src/components/editor/cell/code/cell-editor.tsx +13 -7
- package/src/components/editor/chrome/__tests__/state.test.ts +7 -1
- package/src/components/editor/chrome/panels/__tests__/logs-panel.test.tsx +25 -0
- package/src/components/editor/chrome/panels/__tests__/panel-accordion-state.test.ts +42 -0
- package/src/components/editor/chrome/panels/file-explorer-panel.tsx +6 -17
- package/src/components/editor/chrome/panels/logs-panel.tsx +12 -2
- package/src/components/editor/chrome/panels/panel-accordion-state.ts +51 -0
- package/src/components/editor/chrome/panels/session-panel.tsx +5 -16
- package/src/components/editor/chrome/panels/write-secret-modal.tsx +40 -12
- package/src/components/editor/chrome/state.ts +10 -0
- package/src/components/editor/connections/__tests__/json-credentials.test.ts +114 -0
- package/src/components/editor/connections/__tests__/paths.test.ts +39 -0
- package/src/components/editor/connections/__tests__/quick-add-data-sources.test.tsx +113 -0
- package/src/components/editor/connections/add-connection-dialog.tsx +2 -0
- package/src/components/editor/connections/components.tsx +6 -2
- package/src/components/editor/connections/database/__tests__/__snapshots__/as-code.test.ts.snap +27 -5
- package/src/components/editor/connections/database/__tests__/as-code.test.ts +33 -0
- package/src/components/editor/connections/database/as-code.ts +37 -13
- package/src/components/editor/connections/database/schemas.ts +6 -5
- package/src/components/editor/connections/form-renderers.tsx +99 -1
- package/src/components/editor/connections/json-credentials.ts +57 -0
- package/src/components/editor/connections/paths.ts +21 -0
- package/src/components/editor/connections/quick-add-data-sources.tsx +106 -0
- package/src/components/editor/connections/secret-combobox.tsx +41 -20
- package/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap +88 -2
- package/src/components/editor/connections/storage/__tests__/as-code.test.ts +128 -8
- package/src/components/editor/connections/storage/as-code.ts +79 -36
- package/src/components/editor/connections/storage/schemas.ts +85 -44
- package/src/components/editor/file-tree/__tests__/renderers.test.ts +31 -0
- package/src/components/editor/file-tree/file-viewer.tsx +11 -7
- package/src/components/editor/file-tree/renderers.tsx +21 -0
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +2 -2
- package/src/components/editor/viewer-banner.tsx +6 -1
- package/src/components/forms/form.tsx +59 -24
- package/src/components/forms/options.ts +2 -1
- package/src/components/slides/__tests__/cell-output-block.test.tsx +40 -0
- package/src/components/slides/__tests__/slide-cell-view.test.tsx +33 -0
- package/src/components/slides/reveal-component.tsx +22 -17
- package/src/components/slides/slide-cell-view.tsx +1 -1
- package/src/components/slides/slides.css +4 -2
- package/src/components/static-html/share-modal.tsx +1 -1
- package/src/components/ui/input.tsx +1 -1
- package/src/core/ai/context/providers/file.ts +8 -29
- package/src/core/cells/__tests__/cells.test.ts +12 -2
- package/src/core/cells/__tests__/logs.test.ts +5 -5
- package/src/core/cells/cells.ts +17 -4
- package/src/core/cells/document-changes.ts +1 -0
- package/src/core/cells/logs.ts +14 -4
- package/src/core/codemirror/cm.ts +3 -0
- package/src/core/codemirror/code-lens/__tests__/actions.test.ts +68 -0
- package/src/core/codemirror/code-lens/__tests__/analyzer.test.ts +224 -0
- package/src/core/codemirror/code-lens/__tests__/entities.test.ts +175 -0
- package/src/core/codemirror/code-lens/__tests__/extension.test.ts +325 -0
- package/src/core/codemirror/code-lens/__tests__/perf.test.ts +121 -0
- package/src/core/codemirror/code-lens/__tests__/popover.test.ts +93 -0
- package/src/core/codemirror/code-lens/actions.ts +33 -0
- package/src/core/codemirror/code-lens/analyzer.ts +284 -0
- package/src/core/codemirror/code-lens/entities.ts +123 -0
- package/src/core/codemirror/code-lens/extension.ts +298 -0
- package/src/core/codemirror/code-lens/icons.ts +36 -0
- package/src/core/codemirror/code-lens/popover.tsx +240 -0
- package/src/core/codemirror/copilot/__tests__/language-server.test.ts +396 -100
- package/src/core/codemirror/copilot/__tests__/transport.test.ts +128 -540
- package/src/core/codemirror/copilot/language-server.ts +182 -70
- package/src/core/codemirror/copilot/transport.ts +15 -207
- package/src/core/codemirror/copilot/types.ts +9 -2
- package/src/core/codemirror/find-replace/__tests__/navigate.test.ts +42 -30
- package/src/core/codemirror/find-replace/navigate.ts +2 -0
- package/src/core/codemirror/go-to-definition/__tests__/commands.test.ts +24 -3
- package/src/core/codemirror/go-to-definition/commands.ts +93 -90
- package/src/core/codemirror/keymaps/__tests__/keymaps.test.ts +31 -2
- package/src/core/codemirror/keymaps/keymaps.ts +12 -0
- package/src/core/codemirror/language/__tests__/sql.test.ts +627 -61
- package/src/core/codemirror/language/languages/python.ts +23 -11
- package/src/core/codemirror/language/languages/sql/completion-store.ts +5 -1
- package/src/core/codemirror/language/languages/sql/renderers.tsx +3 -3
- package/src/core/codemirror/language/languages/sql/sql.ts +251 -16
- package/src/core/codemirror/lsp/__tests__/federated-lsp.test.ts +161 -0
- package/src/core/codemirror/lsp/__tests__/log-messages.test.ts +53 -0
- package/src/core/codemirror/lsp/__tests__/normalize-markdown-math.test.ts +25 -0
- package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +598 -156
- package/src/core/codemirror/lsp/__tests__/transports.test.ts +112 -0
- package/src/core/codemirror/lsp/federated-lsp.ts +76 -23
- package/src/core/codemirror/lsp/log-messages.ts +37 -0
- package/src/core/codemirror/lsp/normalize-markdown-math.ts +8 -4
- package/src/core/codemirror/lsp/notebook-lsp.ts +220 -56
- package/src/core/codemirror/lsp/transports.ts +8 -1
- package/src/core/codemirror/lsp/types.ts +68 -8
- package/src/core/codemirror/lsp/utils.ts +14 -0
- package/src/core/codemirror/python-node-names.ts +90 -0
- package/src/core/codemirror/reactive-references/analyzer.ts +52 -57
- package/src/core/codemirror/utils.ts +28 -0
- package/src/core/config/feature-flag.tsx +3 -1
- package/src/core/datasets/data-source-discovery.ts +5 -0
- package/src/core/datasets/request-registry.ts +11 -0
- package/src/core/edit-app.tsx +1 -2
- package/src/core/export/__tests__/hooks.test.ts +2 -4
- package/src/core/export/hooks.ts +4 -3
- package/src/core/hotkeys/hotkeys.ts +0 -2
- package/src/core/islands/__tests__/bridge.test.ts +107 -0
- package/src/core/islands/bootstrap.ts +1 -0
- package/src/core/islands/bridge.ts +18 -0
- package/src/core/kernel/messages.ts +2 -0
- package/src/core/lsp/__tests__/transport.test.ts +509 -337
- package/src/core/lsp/transport.ts +304 -132
- package/src/core/mode.ts +10 -0
- package/src/core/network/__tests__/api.test.ts +42 -0
- package/src/core/network/__tests__/connection.test.ts +45 -0
- package/src/core/network/__tests__/requests-lazy.test.ts +47 -1
- package/src/core/network/__tests__/requests-network.test.ts +48 -0
- package/src/core/network/api.ts +27 -0
- package/src/core/network/connection.ts +15 -0
- package/src/core/network/requests-lazy.ts +3 -0
- package/src/core/network/requests-network.ts +31 -8
- package/src/core/network/requests-static.ts +3 -0
- package/src/core/network/requests-toasting.tsx +3 -0
- package/src/core/network/types.ts +27 -6
- package/src/core/rtc/state.ts +9 -0
- package/src/core/static/download-html.ts +5 -14
- package/src/core/wasm/__tests__/bridge.test.ts +99 -5
- package/src/core/wasm/bridge.ts +42 -9
- package/src/core/wasm/worker/types.ts +10 -3
- package/src/core/wasm/worker/worker.ts +7 -8
- package/src/core/websocket/useMarimoKernelConnection.tsx +4 -0
- package/src/css/app/codemirror.css +16 -2
- package/src/hooks/__tests__/useDataSourceDiscovery.test.ts +80 -0
- package/src/hooks/useDataSourceDiscovery.ts +18 -0
- package/src/plugins/impl/DataTablePlugin.tsx +4 -1
- package/src/plugins/impl/FormPlugin.tsx +1 -1
- package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +158 -0
- package/src/plugins/impl/__tests__/FormPlugin.test.tsx +162 -0
- package/src/plugins/impl/anywidget/__tests__/model.test.ts +55 -0
- package/src/plugins/impl/anywidget/model.ts +20 -5
- package/src/plugins/impl/data-frames/forms/__tests__/__snapshots__/form.test.tsx.snap +33 -21
- package/src/plugins/impl/data-frames/forms/renderers.tsx +11 -8
- package/src/stories/log-viewer.stories.tsx +12 -6
- package/src/utils/__tests__/blob.test.ts +27 -1
- package/src/utils/__tests__/download.test.tsx +44 -4
- package/src/utils/blob.ts +24 -1
- package/src/utils/download.ts +14 -15
- package/dist/toDate-B3IRfHhw.js +0 -692
|
@@ -0,0 +1,713 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { t as __commonJSMin } from "./chunk-BNovOVIE.js";
|
|
5
|
+
import { g as Logger } from "./button-BSm8IXRU.js";
|
|
6
|
+
import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
7
|
+
import { u as createLucideIcon } from "./dist-DIlxLFXG.js";
|
|
8
|
+
import { S as useAtomValue, T as atom, a as KnownQueryParams, g as store, v as waitFor, y as isIslands } from "./useTheme-DYfby65G.js";
|
|
9
|
+
import { t as invariant } from "./invariant-wRzNXIsJ.js";
|
|
10
|
+
var CircleQuestionMark = createLucideIcon("circle-question-mark", [
|
|
11
|
+
["circle", {
|
|
12
|
+
cx: "12",
|
|
13
|
+
cy: "12",
|
|
14
|
+
r: "10",
|
|
15
|
+
key: "1mglay"
|
|
16
|
+
}],
|
|
17
|
+
["path", {
|
|
18
|
+
d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",
|
|
19
|
+
key: "1u773s"
|
|
20
|
+
}],
|
|
21
|
+
["path", {
|
|
22
|
+
d: "M12 17h.01",
|
|
23
|
+
key: "p32p05"
|
|
24
|
+
}]
|
|
25
|
+
]);
|
|
26
|
+
function assertExists(e, S) {
|
|
27
|
+
if (e == null) throw S ? Error(S) : Error(`Expected value but got ${e}`);
|
|
28
|
+
}
|
|
29
|
+
function isWasm() {
|
|
30
|
+
return typeof document < "u" && document.querySelector("marimo-wasm") !== null;
|
|
31
|
+
}
|
|
32
|
+
var Deferred = class {
|
|
33
|
+
constructor() {
|
|
34
|
+
__publicField(this, "status", "pending");
|
|
35
|
+
__publicField(this, "value");
|
|
36
|
+
this.promise = new Promise((e, S) => {
|
|
37
|
+
this.reject = (e2) => {
|
|
38
|
+
this.status = "rejected", S(e2);
|
|
39
|
+
}, this.resolve = (S2) => {
|
|
40
|
+
this.status = "resolved", isPromiseLike(S2) || (this.value = S2), e(S2);
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
function isPromiseLike(e) {
|
|
46
|
+
return typeof e == "object" && !!e && "then" in e && typeof e.then == "function";
|
|
47
|
+
}
|
|
48
|
+
function getInitialAppMode() {
|
|
49
|
+
let e = store.get(initialModeAtom);
|
|
50
|
+
return assertExists(e, "internal-error: initial mode not found"), invariant(e !== "present", "internal-error: initial mode cannot be 'present'"), e;
|
|
51
|
+
}
|
|
52
|
+
const viewStateAtom = atom({
|
|
53
|
+
mode: isIslands() ? "read" : "not-set",
|
|
54
|
+
cellAnchor: null
|
|
55
|
+
}), initialModeAtom = atom(void 0), kioskModeAtom = atom(false);
|
|
56
|
+
function useInstallAllowed() {
|
|
57
|
+
let { mode: e } = useAtomValue(viewStateAtom);
|
|
58
|
+
return e !== "read";
|
|
59
|
+
}
|
|
60
|
+
const WebSocketState = {
|
|
61
|
+
NOT_STARTED: "NOT_STARTED",
|
|
62
|
+
CONNECTING: "CONNECTING",
|
|
63
|
+
OPEN: "OPEN",
|
|
64
|
+
CLOSING: "CLOSING",
|
|
65
|
+
CLOSED: "CLOSED"
|
|
66
|
+
}, connectionAtom = atom({ state: WebSocketState.NOT_STARTED });
|
|
67
|
+
function waitForConnectionOpen() {
|
|
68
|
+
return waitFor(connectionAtom, (e) => e.state === WebSocketState.OPEN);
|
|
69
|
+
}
|
|
70
|
+
atom((e) => e(connectionAtom).state === WebSocketState.CONNECTING), atom((e) => e(connectionAtom).state === WebSocketState.OPEN), atom((e) => {
|
|
71
|
+
let S = e(connectionAtom);
|
|
72
|
+
return S.state === WebSocketState.OPEN || S.state === WebSocketState.NOT_STARTED;
|
|
73
|
+
}), atom((e) => e(connectionAtom).state === WebSocketState.CLOSED), atom((e) => e(connectionAtom).state === WebSocketState.NOT_STARTED);
|
|
74
|
+
var require__u64 = /* @__PURE__ */ __commonJSMin(((e) => {
|
|
75
|
+
Object.defineProperty(e, "__esModule", { value: true }), e.toBig = e.shrSL = e.shrSH = e.rotrSL = e.rotrSH = e.rotrBL = e.rotrBH = e.rotr32L = e.rotr32H = e.rotlSL = e.rotlSH = e.rotlBL = e.rotlBH = e.add5L = e.add5H = e.add4L = e.add4H = e.add3L = e.add3H = void 0, e.add = z, e.fromBig = w, e.split = T;
|
|
76
|
+
var S = /* @__PURE__ */ BigInt(2 ** 32 - 1), C = /* @__PURE__ */ BigInt(32);
|
|
77
|
+
function w(e2, w2 = false) {
|
|
78
|
+
return w2 ? {
|
|
79
|
+
h: Number(e2 & S),
|
|
80
|
+
l: Number(e2 >> C & S)
|
|
81
|
+
} : {
|
|
82
|
+
h: Number(e2 >> C & S) | 0,
|
|
83
|
+
l: Number(e2 & S) | 0
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function T(e2, S2 = false) {
|
|
87
|
+
let C2 = e2.length, T2 = new Uint32Array(C2), E2 = new Uint32Array(C2);
|
|
88
|
+
for (let D2 = 0; D2 < C2; D2++) {
|
|
89
|
+
let { h: C3, l: O2 } = w(e2[D2], S2);
|
|
90
|
+
[T2[D2], E2[D2]] = [C3, O2];
|
|
91
|
+
}
|
|
92
|
+
return [T2, E2];
|
|
93
|
+
}
|
|
94
|
+
var E = (e2, S2) => BigInt(e2 >>> 0) << C | BigInt(S2 >>> 0);
|
|
95
|
+
e.toBig = E;
|
|
96
|
+
var D = (e2, S2, C2) => e2 >>> C2;
|
|
97
|
+
e.shrSH = D;
|
|
98
|
+
var O = (e2, S2, C2) => e2 << 32 - C2 | S2 >>> C2;
|
|
99
|
+
e.shrSL = O;
|
|
100
|
+
var k = (e2, S2, C2) => e2 >>> C2 | S2 << 32 - C2;
|
|
101
|
+
e.rotrSH = k;
|
|
102
|
+
var A = (e2, S2, C2) => e2 << 32 - C2 | S2 >>> C2;
|
|
103
|
+
e.rotrSL = A;
|
|
104
|
+
var j = (e2, S2, C2) => e2 << 64 - C2 | S2 >>> C2 - 32;
|
|
105
|
+
e.rotrBH = j;
|
|
106
|
+
var M = (e2, S2, C2) => e2 >>> C2 - 32 | S2 << 64 - C2;
|
|
107
|
+
e.rotrBL = M;
|
|
108
|
+
var N = (e2, S2) => S2;
|
|
109
|
+
e.rotr32H = N;
|
|
110
|
+
var P = (e2, S2) => e2;
|
|
111
|
+
e.rotr32L = P;
|
|
112
|
+
var F = (e2, S2, C2) => e2 << C2 | S2 >>> 32 - C2;
|
|
113
|
+
e.rotlSH = F;
|
|
114
|
+
var I = (e2, S2, C2) => S2 << C2 | e2 >>> 32 - C2;
|
|
115
|
+
e.rotlSL = I;
|
|
116
|
+
var L = (e2, S2, C2) => S2 << C2 - 32 | e2 >>> 64 - C2;
|
|
117
|
+
e.rotlBH = L;
|
|
118
|
+
var R = (e2, S2, C2) => e2 << C2 - 32 | S2 >>> 64 - C2;
|
|
119
|
+
e.rotlBL = R;
|
|
120
|
+
function z(e2, S2, C2, w2) {
|
|
121
|
+
let T2 = (S2 >>> 0) + (w2 >>> 0);
|
|
122
|
+
return {
|
|
123
|
+
h: e2 + C2 + (T2 / 2 ** 32 | 0) | 0,
|
|
124
|
+
l: T2 | 0
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
var B = (e2, S2, C2) => (e2 >>> 0) + (S2 >>> 0) + (C2 >>> 0);
|
|
128
|
+
e.add3L = B;
|
|
129
|
+
var V = (e2, S2, C2, w2) => S2 + C2 + w2 + (e2 / 2 ** 32 | 0) | 0;
|
|
130
|
+
e.add3H = V;
|
|
131
|
+
var H = (e2, S2, C2, w2) => (e2 >>> 0) + (S2 >>> 0) + (C2 >>> 0) + (w2 >>> 0);
|
|
132
|
+
e.add4L = H;
|
|
133
|
+
var U = (e2, S2, C2, w2, T2) => S2 + C2 + w2 + T2 + (e2 / 2 ** 32 | 0) | 0;
|
|
134
|
+
e.add4H = U;
|
|
135
|
+
var W = (e2, S2, C2, w2, T2) => (e2 >>> 0) + (S2 >>> 0) + (C2 >>> 0) + (w2 >>> 0) + (T2 >>> 0);
|
|
136
|
+
e.add5L = W;
|
|
137
|
+
var G = (e2, S2, C2, w2, T2, E2) => S2 + C2 + w2 + T2 + E2 + (e2 / 2 ** 32 | 0) | 0;
|
|
138
|
+
e.add5H = G, e.default = {
|
|
139
|
+
fromBig: w,
|
|
140
|
+
split: T,
|
|
141
|
+
toBig: E,
|
|
142
|
+
shrSH: D,
|
|
143
|
+
shrSL: O,
|
|
144
|
+
rotrSH: k,
|
|
145
|
+
rotrSL: A,
|
|
146
|
+
rotrBH: j,
|
|
147
|
+
rotrBL: M,
|
|
148
|
+
rotr32H: N,
|
|
149
|
+
rotr32L: P,
|
|
150
|
+
rotlSH: F,
|
|
151
|
+
rotlSL: I,
|
|
152
|
+
rotlBH: L,
|
|
153
|
+
rotlBL: R,
|
|
154
|
+
add: z,
|
|
155
|
+
add3L: B,
|
|
156
|
+
add3H: V,
|
|
157
|
+
add4L: H,
|
|
158
|
+
add4H: U,
|
|
159
|
+
add5H: G,
|
|
160
|
+
add5L: W
|
|
161
|
+
};
|
|
162
|
+
})), require_crypto = /* @__PURE__ */ __commonJSMin(((e) => {
|
|
163
|
+
Object.defineProperty(e, "__esModule", { value: true }), e.crypto = void 0, e.crypto = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
164
|
+
})), require_utils = /* @__PURE__ */ __commonJSMin(((e) => {
|
|
165
|
+
Object.defineProperty(e, "__esModule", { value: true }), e.wrapXOFConstructorWithOpts = e.wrapConstructorWithOpts = e.wrapConstructor = e.Hash = e.nextTick = e.swap32IfBE = e.byteSwapIfBE = e.swap8IfBE = e.isLE = void 0, e.isBytes = C, e.anumber = w, e.abytes = T, e.ahash = E, e.aexists = D, e.aoutput = O, e.u8 = k, e.u32 = A, e.clean = j, e.createView = M, e.rotr = N, e.rotl = P, e.byteSwap = F, e.byteSwap32 = I, e.bytesToHex = z, e.hexToBytes = H, e.asyncLoop = U, e.utf8ToBytes = W, e.bytesToUtf8 = G, e.toBytes = K, e.kdfInputToBytes = q, e.concatBytes = J, e.checkOpts = Y, e.createHasher = X, e.createOptHasher = Z, e.createXOFer = Q, e.randomBytes = $;
|
|
166
|
+
var S = require_crypto();
|
|
167
|
+
function C(e2) {
|
|
168
|
+
return e2 instanceof Uint8Array || ArrayBuffer.isView(e2) && e2.constructor.name === "Uint8Array";
|
|
169
|
+
}
|
|
170
|
+
function w(e2) {
|
|
171
|
+
if (!Number.isSafeInteger(e2) || e2 < 0) throw Error("positive integer expected, got " + e2);
|
|
172
|
+
}
|
|
173
|
+
function T(e2, ...S2) {
|
|
174
|
+
if (!C(e2)) throw Error("Uint8Array expected");
|
|
175
|
+
if (S2.length > 0 && !S2.includes(e2.length)) throw Error("Uint8Array expected of length " + S2 + ", got length=" + e2.length);
|
|
176
|
+
}
|
|
177
|
+
function E(e2) {
|
|
178
|
+
if (typeof e2 != "function" || typeof e2.create != "function") throw Error("Hash should be wrapped by utils.createHasher");
|
|
179
|
+
w(e2.outputLen), w(e2.blockLen);
|
|
180
|
+
}
|
|
181
|
+
function D(e2, S2 = true) {
|
|
182
|
+
if (e2.destroyed) throw Error("Hash instance has been destroyed");
|
|
183
|
+
if (S2 && e2.finished) throw Error("Hash#digest() has already been called");
|
|
184
|
+
}
|
|
185
|
+
function O(e2, S2) {
|
|
186
|
+
T(e2);
|
|
187
|
+
let C2 = S2.outputLen;
|
|
188
|
+
if (e2.length < C2) throw Error("digestInto() expects output buffer of length at least " + C2);
|
|
189
|
+
}
|
|
190
|
+
function k(e2) {
|
|
191
|
+
return new Uint8Array(e2.buffer, e2.byteOffset, e2.byteLength);
|
|
192
|
+
}
|
|
193
|
+
function A(e2) {
|
|
194
|
+
return new Uint32Array(e2.buffer, e2.byteOffset, Math.floor(e2.byteLength / 4));
|
|
195
|
+
}
|
|
196
|
+
function j(...e2) {
|
|
197
|
+
for (let S2 = 0; S2 < e2.length; S2++) e2[S2].fill(0);
|
|
198
|
+
}
|
|
199
|
+
function M(e2) {
|
|
200
|
+
return new DataView(e2.buffer, e2.byteOffset, e2.byteLength);
|
|
201
|
+
}
|
|
202
|
+
function N(e2, S2) {
|
|
203
|
+
return e2 << 32 - S2 | e2 >>> S2;
|
|
204
|
+
}
|
|
205
|
+
function P(e2, S2) {
|
|
206
|
+
return e2 << S2 | e2 >>> 32 - S2 >>> 0;
|
|
207
|
+
}
|
|
208
|
+
e.isLE = (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
209
|
+
function F(e2) {
|
|
210
|
+
return e2 << 24 & 4278190080 | e2 << 8 & 16711680 | e2 >>> 8 & 65280 | e2 >>> 24 & 255;
|
|
211
|
+
}
|
|
212
|
+
e.swap8IfBE = e.isLE ? (e2) => e2 : (e2) => F(e2), e.byteSwapIfBE = e.swap8IfBE;
|
|
213
|
+
function I(e2) {
|
|
214
|
+
for (let S2 = 0; S2 < e2.length; S2++) e2[S2] = F(e2[S2]);
|
|
215
|
+
return e2;
|
|
216
|
+
}
|
|
217
|
+
e.swap32IfBE = e.isLE ? (e2) => e2 : I;
|
|
218
|
+
var L = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function")(), R = /* @__PURE__ */ Array.from({ length: 256 }, (e2, S2) => S2.toString(16).padStart(2, "0"));
|
|
219
|
+
function z(e2) {
|
|
220
|
+
if (T(e2), L) return e2.toHex();
|
|
221
|
+
let S2 = "";
|
|
222
|
+
for (let C2 = 0; C2 < e2.length; C2++) S2 += R[e2[C2]];
|
|
223
|
+
return S2;
|
|
224
|
+
}
|
|
225
|
+
var B = {
|
|
226
|
+
_0: 48,
|
|
227
|
+
_9: 57,
|
|
228
|
+
A: 65,
|
|
229
|
+
F: 70,
|
|
230
|
+
a: 97,
|
|
231
|
+
f: 102
|
|
232
|
+
};
|
|
233
|
+
function V(e2) {
|
|
234
|
+
if (e2 >= B._0 && e2 <= B._9) return e2 - B._0;
|
|
235
|
+
if (e2 >= B.A && e2 <= B.F) return e2 - (B.A - 10);
|
|
236
|
+
if (e2 >= B.a && e2 <= B.f) return e2 - (B.a - 10);
|
|
237
|
+
}
|
|
238
|
+
function H(e2) {
|
|
239
|
+
if (typeof e2 != "string") throw Error("hex string expected, got " + typeof e2);
|
|
240
|
+
if (L) return Uint8Array.fromHex(e2);
|
|
241
|
+
let S2 = e2.length, C2 = S2 / 2;
|
|
242
|
+
if (S2 % 2) throw Error("hex string expected, got unpadded hex of length " + S2);
|
|
243
|
+
let w2 = new Uint8Array(C2);
|
|
244
|
+
for (let S3 = 0, T2 = 0; S3 < C2; S3++, T2 += 2) {
|
|
245
|
+
let C3 = V(e2.charCodeAt(T2)), E2 = V(e2.charCodeAt(T2 + 1));
|
|
246
|
+
if (C3 === void 0 || E2 === void 0) {
|
|
247
|
+
let S4 = e2[T2] + e2[T2 + 1];
|
|
248
|
+
throw Error('hex string expected, got non-hex character "' + S4 + '" at index ' + T2);
|
|
249
|
+
}
|
|
250
|
+
w2[S3] = C3 * 16 + E2;
|
|
251
|
+
}
|
|
252
|
+
return w2;
|
|
253
|
+
}
|
|
254
|
+
e.nextTick = async () => {
|
|
255
|
+
};
|
|
256
|
+
async function U(S2, C2, w2) {
|
|
257
|
+
let T2 = Date.now();
|
|
258
|
+
for (let E2 = 0; E2 < S2; E2++) {
|
|
259
|
+
w2(E2);
|
|
260
|
+
let S3 = Date.now() - T2;
|
|
261
|
+
S3 >= 0 && S3 < C2 || (await (0, e.nextTick)(), T2 += S3);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function W(e2) {
|
|
265
|
+
if (typeof e2 != "string") throw Error("string expected");
|
|
266
|
+
return new Uint8Array(new TextEncoder().encode(e2));
|
|
267
|
+
}
|
|
268
|
+
function G(e2) {
|
|
269
|
+
return new TextDecoder().decode(e2);
|
|
270
|
+
}
|
|
271
|
+
function K(e2) {
|
|
272
|
+
return typeof e2 == "string" && (e2 = W(e2)), T(e2), e2;
|
|
273
|
+
}
|
|
274
|
+
function q(e2) {
|
|
275
|
+
return typeof e2 == "string" && (e2 = W(e2)), T(e2), e2;
|
|
276
|
+
}
|
|
277
|
+
function J(...e2) {
|
|
278
|
+
let S2 = 0;
|
|
279
|
+
for (let C3 = 0; C3 < e2.length; C3++) {
|
|
280
|
+
let w2 = e2[C3];
|
|
281
|
+
T(w2), S2 += w2.length;
|
|
282
|
+
}
|
|
283
|
+
let C2 = new Uint8Array(S2);
|
|
284
|
+
for (let S3 = 0, w2 = 0; S3 < e2.length; S3++) {
|
|
285
|
+
let T2 = e2[S3];
|
|
286
|
+
C2.set(T2, w2), w2 += T2.length;
|
|
287
|
+
}
|
|
288
|
+
return C2;
|
|
289
|
+
}
|
|
290
|
+
function Y(e2, S2) {
|
|
291
|
+
if (S2 !== void 0 && {}.toString.call(S2) !== "[object Object]") throw Error("options should be object or undefined");
|
|
292
|
+
return Object.assign(e2, S2);
|
|
293
|
+
}
|
|
294
|
+
e.Hash = class {
|
|
295
|
+
};
|
|
296
|
+
function X(e2) {
|
|
297
|
+
let S2 = (S3) => e2().update(K(S3)).digest(), C2 = e2();
|
|
298
|
+
return S2.outputLen = C2.outputLen, S2.blockLen = C2.blockLen, S2.create = () => e2(), S2;
|
|
299
|
+
}
|
|
300
|
+
function Z(e2) {
|
|
301
|
+
let S2 = (S3, C3) => e2(C3).update(K(S3)).digest(), C2 = e2({});
|
|
302
|
+
return S2.outputLen = C2.outputLen, S2.blockLen = C2.blockLen, S2.create = (S3) => e2(S3), S2;
|
|
303
|
+
}
|
|
304
|
+
function Q(e2) {
|
|
305
|
+
let S2 = (S3, C3) => e2(C3).update(K(S3)).digest(), C2 = e2({});
|
|
306
|
+
return S2.outputLen = C2.outputLen, S2.blockLen = C2.blockLen, S2.create = (S3) => e2(S3), S2;
|
|
307
|
+
}
|
|
308
|
+
e.wrapConstructor = X, e.wrapConstructorWithOpts = Z, e.wrapXOFConstructorWithOpts = Q;
|
|
309
|
+
function $(e2 = 32) {
|
|
310
|
+
if (S.crypto && typeof S.crypto.getRandomValues == "function") return S.crypto.getRandomValues(new Uint8Array(e2));
|
|
311
|
+
if (S.crypto && typeof S.crypto.randomBytes == "function") return Uint8Array.from(S.crypto.randomBytes(e2));
|
|
312
|
+
throw Error("crypto.getRandomValues must be defined");
|
|
313
|
+
}
|
|
314
|
+
})), require_sha3 = /* @__PURE__ */ __commonJSMin(((e) => {
|
|
315
|
+
Object.defineProperty(e, "__esModule", { value: true }), e.shake256 = e.shake128 = e.keccak_512 = e.keccak_384 = e.keccak_256 = e.keccak_224 = e.sha3_512 = e.sha3_384 = e.sha3_256 = e.sha3_224 = e.Keccak = void 0, e.keccakP = R;
|
|
316
|
+
var S = require__u64(), C = require_utils(), w = BigInt(0), T = BigInt(1), E = BigInt(2), D = BigInt(7), O = BigInt(256), k = BigInt(113), A = [], j = [], M = [];
|
|
317
|
+
for (let e2 = 0, S2 = T, C2 = 1, N2 = 0; e2 < 24; e2++) {
|
|
318
|
+
[C2, N2] = [N2, (2 * C2 + 3 * N2) % 5], A.push(2 * (5 * N2 + C2)), j.push((e2 + 1) * (e2 + 2) / 2 % 64);
|
|
319
|
+
let P2 = w;
|
|
320
|
+
for (let e3 = 0; e3 < 7; e3++) S2 = (S2 << T ^ (S2 >> D) * k) % O, S2 & E && (P2 ^= T << (T << /* @__PURE__ */ BigInt(e3)) - T);
|
|
321
|
+
M.push(P2);
|
|
322
|
+
}
|
|
323
|
+
var N = (0, S.split)(M, true), P = N[0], F = N[1], I = (e2, C2, w2) => w2 > 32 ? (0, S.rotlBH)(e2, C2, w2) : (0, S.rotlSH)(e2, C2, w2), L = (e2, C2, w2) => w2 > 32 ? (0, S.rotlBL)(e2, C2, w2) : (0, S.rotlSL)(e2, C2, w2);
|
|
324
|
+
function R(e2, S2 = 24) {
|
|
325
|
+
let w2 = new Uint32Array(10);
|
|
326
|
+
for (let C2 = 24 - S2; C2 < 24; C2++) {
|
|
327
|
+
for (let S4 = 0; S4 < 10; S4++) w2[S4] = e2[S4] ^ e2[S4 + 10] ^ e2[S4 + 20] ^ e2[S4 + 30] ^ e2[S4 + 40];
|
|
328
|
+
for (let S4 = 0; S4 < 10; S4 += 2) {
|
|
329
|
+
let C3 = (S4 + 8) % 10, T3 = (S4 + 2) % 10, E2 = w2[T3], D2 = w2[T3 + 1], O2 = I(E2, D2, 1) ^ w2[C3], k2 = L(E2, D2, 1) ^ w2[C3 + 1];
|
|
330
|
+
for (let C4 = 0; C4 < 50; C4 += 10) e2[S4 + C4] ^= O2, e2[S4 + C4 + 1] ^= k2;
|
|
331
|
+
}
|
|
332
|
+
let S3 = e2[2], T2 = e2[3];
|
|
333
|
+
for (let C3 = 0; C3 < 24; C3++) {
|
|
334
|
+
let w3 = j[C3], E2 = I(S3, T2, w3), D2 = L(S3, T2, w3), O2 = A[C3];
|
|
335
|
+
S3 = e2[O2], T2 = e2[O2 + 1], e2[O2] = E2, e2[O2 + 1] = D2;
|
|
336
|
+
}
|
|
337
|
+
for (let S4 = 0; S4 < 50; S4 += 10) {
|
|
338
|
+
for (let C3 = 0; C3 < 10; C3++) w2[C3] = e2[S4 + C3];
|
|
339
|
+
for (let C3 = 0; C3 < 10; C3++) e2[S4 + C3] ^= ~w2[(C3 + 2) % 10] & w2[(C3 + 4) % 10];
|
|
340
|
+
}
|
|
341
|
+
e2[0] ^= P[C2], e2[1] ^= F[C2];
|
|
342
|
+
}
|
|
343
|
+
(0, C.clean)(w2);
|
|
344
|
+
}
|
|
345
|
+
var z = class e2 extends C.Hash {
|
|
346
|
+
constructor(e3, S2, w2, T2 = false, E2 = 24) {
|
|
347
|
+
if (super(), this.pos = 0, this.posOut = 0, this.finished = false, this.destroyed = false, this.enableXOF = false, this.blockLen = e3, this.suffix = S2, this.outputLen = w2, this.enableXOF = T2, this.rounds = E2, (0, C.anumber)(w2), !(0 < e3 && e3 < 200)) throw Error("only keccak-f1600 function is supported");
|
|
348
|
+
this.state = new Uint8Array(200), this.state32 = (0, C.u32)(this.state);
|
|
349
|
+
}
|
|
350
|
+
clone() {
|
|
351
|
+
return this._cloneInto();
|
|
352
|
+
}
|
|
353
|
+
keccak() {
|
|
354
|
+
(0, C.swap32IfBE)(this.state32), R(this.state32, this.rounds), (0, C.swap32IfBE)(this.state32), this.posOut = 0, this.pos = 0;
|
|
355
|
+
}
|
|
356
|
+
update(e3) {
|
|
357
|
+
(0, C.aexists)(this), e3 = (0, C.toBytes)(e3), (0, C.abytes)(e3);
|
|
358
|
+
let { blockLen: S2, state: w2 } = this, T2 = e3.length;
|
|
359
|
+
for (let C2 = 0; C2 < T2; ) {
|
|
360
|
+
let E2 = Math.min(S2 - this.pos, T2 - C2);
|
|
361
|
+
for (let S3 = 0; S3 < E2; S3++) w2[this.pos++] ^= e3[C2++];
|
|
362
|
+
this.pos === S2 && this.keccak();
|
|
363
|
+
}
|
|
364
|
+
return this;
|
|
365
|
+
}
|
|
366
|
+
finish() {
|
|
367
|
+
if (this.finished) return;
|
|
368
|
+
this.finished = true;
|
|
369
|
+
let { state: e3, suffix: S2, pos: C2, blockLen: w2 } = this;
|
|
370
|
+
e3[C2] ^= S2, S2 & 128 && C2 === w2 - 1 && this.keccak(), e3[w2 - 1] ^= 128, this.keccak();
|
|
371
|
+
}
|
|
372
|
+
writeInto(e3) {
|
|
373
|
+
(0, C.aexists)(this, false), (0, C.abytes)(e3), this.finish();
|
|
374
|
+
let S2 = this.state, { blockLen: w2 } = this;
|
|
375
|
+
for (let C2 = 0, T2 = e3.length; C2 < T2; ) {
|
|
376
|
+
this.posOut >= w2 && this.keccak();
|
|
377
|
+
let E2 = Math.min(w2 - this.posOut, T2 - C2);
|
|
378
|
+
e3.set(S2.subarray(this.posOut, this.posOut + E2), C2), this.posOut += E2, C2 += E2;
|
|
379
|
+
}
|
|
380
|
+
return e3;
|
|
381
|
+
}
|
|
382
|
+
xofInto(e3) {
|
|
383
|
+
if (!this.enableXOF) throw Error("XOF is not possible for this instance");
|
|
384
|
+
return this.writeInto(e3);
|
|
385
|
+
}
|
|
386
|
+
xof(e3) {
|
|
387
|
+
return (0, C.anumber)(e3), this.xofInto(new Uint8Array(e3));
|
|
388
|
+
}
|
|
389
|
+
digestInto(e3) {
|
|
390
|
+
if ((0, C.aoutput)(e3, this), this.finished) throw Error("digest() was already called");
|
|
391
|
+
return this.writeInto(e3), this.destroy(), e3;
|
|
392
|
+
}
|
|
393
|
+
digest() {
|
|
394
|
+
return this.digestInto(new Uint8Array(this.outputLen));
|
|
395
|
+
}
|
|
396
|
+
destroy() {
|
|
397
|
+
this.destroyed = true, (0, C.clean)(this.state);
|
|
398
|
+
}
|
|
399
|
+
_cloneInto(S2) {
|
|
400
|
+
let { blockLen: C2, suffix: w2, outputLen: T2, rounds: E2, enableXOF: D2 } = this;
|
|
401
|
+
return S2 || (S2 = new e2(C2, w2, T2, D2, E2)), S2.state32.set(this.state32), S2.pos = this.pos, S2.posOut = this.posOut, S2.finished = this.finished, S2.rounds = E2, S2.suffix = w2, S2.outputLen = T2, S2.enableXOF = D2, S2.destroyed = this.destroyed, S2;
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
e.Keccak = z;
|
|
405
|
+
var B = (e2, S2, w2) => (0, C.createHasher)(() => new z(S2, e2, w2));
|
|
406
|
+
e.sha3_224 = (() => B(6, 144, 224 / 8))(), e.sha3_256 = (() => B(6, 136, 256 / 8))(), e.sha3_384 = (() => B(6, 104, 384 / 8))(), e.sha3_512 = (() => B(6, 72, 512 / 8))(), e.keccak_224 = (() => B(1, 144, 224 / 8))(), e.keccak_256 = (() => B(1, 136, 256 / 8))(), e.keccak_384 = (() => B(1, 104, 384 / 8))(), e.keccak_512 = (() => B(1, 72, 512 / 8))();
|
|
407
|
+
var V = (e2, S2, w2) => (0, C.createXOFer)((C2 = {}) => new z(S2, e2, C2.dkLen === void 0 ? w2 : C2.dkLen, true));
|
|
408
|
+
e.shake128 = (() => V(31, 168, 128 / 8))(), e.shake256 = (() => V(31, 136, 256 / 8))();
|
|
409
|
+
})), require_src = /* @__PURE__ */ __commonJSMin(((e, S) => {
|
|
410
|
+
var { sha3_512: C } = require_sha3(), w = 24, T = 32, E = (e2 = 4, S2 = Math.random) => {
|
|
411
|
+
let C2 = "";
|
|
412
|
+
for (; C2.length < e2; ) C2 += Math.floor(S2() * 36).toString(36);
|
|
413
|
+
return C2;
|
|
414
|
+
};
|
|
415
|
+
function D(e2) {
|
|
416
|
+
let S2 = 0n;
|
|
417
|
+
for (let C2 of e2.values()) {
|
|
418
|
+
let e3 = BigInt(C2);
|
|
419
|
+
S2 = (S2 << 8n) + e3;
|
|
420
|
+
}
|
|
421
|
+
return S2;
|
|
422
|
+
}
|
|
423
|
+
var O = (e2 = "") => D(C(e2)).toString(36).slice(1), k = Array.from({ length: 26 }, (e2, S2) => String.fromCharCode(S2 + 97)), A = (e2) => k[Math.floor(e2() * k.length)], j = ({ globalObj: e2 = typeof global < "u" ? global : typeof window < "u" ? window : {}, random: S2 = Math.random } = {}) => {
|
|
424
|
+
let C2 = Object.keys(e2).toString();
|
|
425
|
+
return O(C2.length ? C2 + E(T, S2) : E(T, S2)).substring(0, T);
|
|
426
|
+
}, M = (e2) => () => e2++, N = 476782367, P = ({ random: e2 = Math.random, counter: S2 = M(Math.floor(e2() * N)), length: C2 = w, fingerprint: T2 = j({ random: e2 }) } = {}) => function() {
|
|
427
|
+
let w2 = A(e2), D2 = Date.now().toString(36), k2 = S2().toString(36);
|
|
428
|
+
return `${w2 + O(`${D2 + E(C2, e2) + k2 + T2}`).substring(1, C2)}`;
|
|
429
|
+
}, F = P(), I = (e2, { minLength: S2 = 2, maxLength: C2 = T } = {}) => {
|
|
430
|
+
let w2 = e2.length, E2 = /^[0-9a-z]+$/;
|
|
431
|
+
try {
|
|
432
|
+
if (typeof e2 == "string" && w2 >= S2 && w2 <= C2 && E2.test(e2)) return true;
|
|
433
|
+
} finally {
|
|
434
|
+
}
|
|
435
|
+
return false;
|
|
436
|
+
};
|
|
437
|
+
S.exports.getConstants = () => ({
|
|
438
|
+
defaultLength: w,
|
|
439
|
+
bigLength: T
|
|
440
|
+
}), S.exports.init = P, S.exports.createId = F, S.exports.bufToBigInt = D, S.exports.createCounter = M, S.exports.createFingerprint = j, S.exports.isCuid = I;
|
|
441
|
+
})), require_cuid2 = /* @__PURE__ */ __commonJSMin(((e, S) => {
|
|
442
|
+
var { createId: C, init: w, getConstants: T, isCuid: E } = require_src();
|
|
443
|
+
S.exports.createId = C, S.exports.init = w, S.exports.getConstants = T, S.exports.isCuid = E;
|
|
444
|
+
}));
|
|
445
|
+
function updateQueryParams(e) {
|
|
446
|
+
let S = new URL(window.location.href);
|
|
447
|
+
e(S.searchParams), window.history.replaceState({}, "", S.toString());
|
|
448
|
+
}
|
|
449
|
+
var urlRegex = /^(https?:\/\/\S+)$/;
|
|
450
|
+
function isUrl(e) {
|
|
451
|
+
return typeof e == "string" && urlRegex.test(e);
|
|
452
|
+
}
|
|
453
|
+
function appendQueryParams({ href: e, queryParams: S, keys: C }) {
|
|
454
|
+
let w = typeof S == "string" ? new URLSearchParams(S) : S;
|
|
455
|
+
if (w.size === 0 || e.startsWith("http://") || e.startsWith("https://")) return e;
|
|
456
|
+
let T = e.startsWith("#"), E = T && e.includes("?");
|
|
457
|
+
if (T && !E) {
|
|
458
|
+
let S2 = C ? [...w.entries()].filter(([e2]) => C.includes(e2)) : [...w.entries()], T2 = new URLSearchParams();
|
|
459
|
+
for (let [e2, C2] of S2) T2.set(e2, C2);
|
|
460
|
+
let E2 = T2.toString();
|
|
461
|
+
return E2 ? `/?${E2}${e}` : e;
|
|
462
|
+
}
|
|
463
|
+
let D = e, O = "", k = new URLSearchParams(), A = T ? 1 : 0, j = e.indexOf("#", A);
|
|
464
|
+
j !== -1 && (O = e.slice(j), D = e.slice(0, j));
|
|
465
|
+
let M = D.indexOf("?");
|
|
466
|
+
M !== -1 && (k = new URLSearchParams(D.slice(M + 1)), D = D.slice(0, M));
|
|
467
|
+
let N = new URLSearchParams(k), P = C ? [...w.entries()].filter(([e2]) => C.includes(e2)) : [...w.entries()];
|
|
468
|
+
for (let [e2, S2] of P) N.set(e2, S2);
|
|
469
|
+
let F = N.toString();
|
|
470
|
+
return F ? `${D}?${F}${O}` : e;
|
|
471
|
+
}
|
|
472
|
+
var createId = (0, require_cuid2().init)({ length: 6 });
|
|
473
|
+
function generateSessionId() {
|
|
474
|
+
return `s_${createId()}`;
|
|
475
|
+
}
|
|
476
|
+
function isSessionId(e) {
|
|
477
|
+
return e ? /^s_[\da-z]{6}$/.test(e) : false;
|
|
478
|
+
}
|
|
479
|
+
var sessionId = (() => {
|
|
480
|
+
let e = new URL(window.location.href).searchParams.get(KnownQueryParams.sessionId);
|
|
481
|
+
return isSessionId(e) ? (updateQueryParams((e2) => {
|
|
482
|
+
e2.has(KnownQueryParams.kiosk) || e2.delete(KnownQueryParams.sessionId);
|
|
483
|
+
}), Logger.debug("Connecting to existing session", { sessionId: e }), e) : (Logger.debug("Starting a new session", { sessionId: e }), generateSessionId());
|
|
484
|
+
})();
|
|
485
|
+
function getSessionId() {
|
|
486
|
+
return sessionId;
|
|
487
|
+
}
|
|
488
|
+
function isStringToStringRecord(e) {
|
|
489
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return false;
|
|
490
|
+
for (let S of Object.values(e)) if (typeof S != "string") return false;
|
|
491
|
+
return true;
|
|
492
|
+
}
|
|
493
|
+
function isMarimoStaticState(e) {
|
|
494
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return false;
|
|
495
|
+
let S = e;
|
|
496
|
+
return !(!isStringToStringRecord(S.files) || S.modelNotifications !== void 0 && !Array.isArray(S.modelNotifications));
|
|
497
|
+
}
|
|
498
|
+
function getMarimoStaticState() {
|
|
499
|
+
let e = typeof window > "u" ? void 0 : window.__MARIMO_STATIC__;
|
|
500
|
+
return isMarimoStaticState(e) ? e : void 0;
|
|
501
|
+
}
|
|
502
|
+
function isStaticNotebook() {
|
|
503
|
+
return getMarimoStaticState() !== void 0;
|
|
504
|
+
}
|
|
505
|
+
function getStaticVirtualFiles() {
|
|
506
|
+
let e = getMarimoStaticState();
|
|
507
|
+
return invariant(e !== void 0, "Not a static notebook"), e.files;
|
|
508
|
+
}
|
|
509
|
+
var RuntimeManager = class {
|
|
510
|
+
constructor(e, S = false) {
|
|
511
|
+
__publicField(this, "initialHealthyCheck", new Deferred());
|
|
512
|
+
this.config = e, this.lazy = S;
|
|
513
|
+
try {
|
|
514
|
+
new URL(this.config.url);
|
|
515
|
+
} catch (e2) {
|
|
516
|
+
throw Error(`Invalid runtime URL: ${this.config.url}. ${e2 instanceof Error ? e2.message : "Unknown error"}`, { cause: e2 });
|
|
517
|
+
}
|
|
518
|
+
this.lazy || this.init();
|
|
519
|
+
}
|
|
520
|
+
get isLazy() {
|
|
521
|
+
return this.lazy;
|
|
522
|
+
}
|
|
523
|
+
get httpURL() {
|
|
524
|
+
return new URL(this.config.url);
|
|
525
|
+
}
|
|
526
|
+
get isSameOrigin() {
|
|
527
|
+
return this.httpURL.origin === window.location.origin;
|
|
528
|
+
}
|
|
529
|
+
get isServerless() {
|
|
530
|
+
return isWasm() || isIslands() || isStaticNotebook();
|
|
531
|
+
}
|
|
532
|
+
formatHttpURL({ path: e = "", searchParams: S, restrictToKnownQueryParams: C = true }) {
|
|
533
|
+
let w = this.httpURL, T = new URLSearchParams(window.location.search);
|
|
534
|
+
if (S) for (let [e2, C2] of S.entries()) w.searchParams.set(e2, C2);
|
|
535
|
+
for (let [e2, S2] of T.entries()) C && !Object.values(KnownQueryParams).includes(e2) || w.searchParams.set(e2, S2);
|
|
536
|
+
return w.pathname = `${w.pathname.replace(/\/$/, "")}/${e.replace(/^\//, "")}`, w.hash = "", w;
|
|
537
|
+
}
|
|
538
|
+
appendCrossOriginAuth(e) {
|
|
539
|
+
return !this.isSameOrigin && this.config.authToken && e.searchParams.set(KnownQueryParams.accessToken, this.config.authToken), e;
|
|
540
|
+
}
|
|
541
|
+
formatNavigableHttpURL(e, S) {
|
|
542
|
+
let C = this.formatHttpURL({
|
|
543
|
+
path: e,
|
|
544
|
+
searchParams: S
|
|
545
|
+
});
|
|
546
|
+
return C.searchParams.delete(KnownQueryParams.accessToken), this.appendCrossOriginAuth(C);
|
|
547
|
+
}
|
|
548
|
+
formatWsURL(e, S) {
|
|
549
|
+
let C = this.formatHttpURL({
|
|
550
|
+
path: e,
|
|
551
|
+
searchParams: S,
|
|
552
|
+
restrictToKnownQueryParams: false
|
|
553
|
+
});
|
|
554
|
+
return asWsUrl(this.appendCrossOriginAuth(C).toString());
|
|
555
|
+
}
|
|
556
|
+
getSessionSearchParams(e) {
|
|
557
|
+
let S = new URL(this.config.url), C = new URLSearchParams(S.search);
|
|
558
|
+
return new URLSearchParams(window.location.search).forEach((e2, S2) => {
|
|
559
|
+
C.has(S2) || C.set(S2, e2);
|
|
560
|
+
}), C.set(KnownQueryParams.sessionId, e), C;
|
|
561
|
+
}
|
|
562
|
+
getWsURL(e) {
|
|
563
|
+
return this.formatWsURL("/ws", this.getSessionSearchParams(e));
|
|
564
|
+
}
|
|
565
|
+
getSseURL(e) {
|
|
566
|
+
let S = this.formatHttpURL({
|
|
567
|
+
path: "/sse",
|
|
568
|
+
searchParams: this.getSessionSearchParams(e),
|
|
569
|
+
restrictToKnownQueryParams: false
|
|
570
|
+
});
|
|
571
|
+
return S.searchParams.delete(KnownQueryParams.accessToken), S;
|
|
572
|
+
}
|
|
573
|
+
getWsSyncURL(e) {
|
|
574
|
+
return this.formatWsURL("/ws_sync", this.getSessionSearchParams(e));
|
|
575
|
+
}
|
|
576
|
+
getTerminalWsURL() {
|
|
577
|
+
return this.formatWsURL("/terminal/ws");
|
|
578
|
+
}
|
|
579
|
+
getLSPURL(e) {
|
|
580
|
+
if (e === "copilot") {
|
|
581
|
+
let S = this.formatWsURL(`/lsp/${e}`), C = S.searchParams.get(KnownQueryParams.accessToken);
|
|
582
|
+
return S.search = "", C && S.searchParams.set(KnownQueryParams.accessToken, C), S;
|
|
583
|
+
}
|
|
584
|
+
return this.formatWsURL(`/lsp/${e}`);
|
|
585
|
+
}
|
|
586
|
+
getAiURL(e) {
|
|
587
|
+
return this.formatHttpURL({ path: `/api/ai/${e}` });
|
|
588
|
+
}
|
|
589
|
+
healthURL() {
|
|
590
|
+
return this.formatHttpURL({ path: "/health" });
|
|
591
|
+
}
|
|
592
|
+
async fetchHealth() {
|
|
593
|
+
try {
|
|
594
|
+
return await fetch(this.healthURL().toString());
|
|
595
|
+
} catch (e) {
|
|
596
|
+
return Logger.error(`Failed to check health: ${e instanceof Error ? e.message : "Unknown error"}`, { cause: e }), null;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
async reconcileFromHealth() {
|
|
600
|
+
if (this.isServerless) return true;
|
|
601
|
+
let e = await this.fetchHealth();
|
|
602
|
+
if (!e) return false;
|
|
603
|
+
if (e.redirected) {
|
|
604
|
+
Logger.debug(`Runtime redirected to ${e.url}`);
|
|
605
|
+
let C = new URL(e.url);
|
|
606
|
+
C.pathname = C.pathname.replace(/\/health$/, ""), this.config.url = C.toString();
|
|
607
|
+
}
|
|
608
|
+
return e.ok && this.setDOMBaseUri(this.config.url), e.ok;
|
|
609
|
+
}
|
|
610
|
+
async probeHealth() {
|
|
611
|
+
var _a;
|
|
612
|
+
return this.isServerless ? true : ((_a = await this.fetchHealth()) == null ? void 0 : _a.ok) ?? false;
|
|
613
|
+
}
|
|
614
|
+
setDOMBaseUri(e) {
|
|
615
|
+
e = e.split("?", 1)[0], e.endsWith("/") || (e += "/");
|
|
616
|
+
let S = document.querySelector("base");
|
|
617
|
+
S ? S.setAttribute("href", e) : (S = document.createElement("base"), S.setAttribute("href", e), document.head.append(S));
|
|
618
|
+
}
|
|
619
|
+
async init(e) {
|
|
620
|
+
Logger.debug("Initializing runtime...");
|
|
621
|
+
let C = 0;
|
|
622
|
+
for (; !await this.reconcileFromHealth(); ) {
|
|
623
|
+
if (C >= 25) {
|
|
624
|
+
Logger.error("Failed to connect after 25 retries"), this.initialHealthyCheck.reject(/* @__PURE__ */ Error("Failed to connect after 25 retries"));
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (!(e == null ? void 0 : e.disableRetryDelay)) {
|
|
628
|
+
let e2 = Math.min(100 * 1.2 ** C, 2e3);
|
|
629
|
+
await new Promise((S) => setTimeout(S, e2));
|
|
630
|
+
}
|
|
631
|
+
C++;
|
|
632
|
+
}
|
|
633
|
+
Logger.debug("Runtime is healthy"), this.initialHealthyCheck.resolve();
|
|
634
|
+
}
|
|
635
|
+
async waitForHealthy() {
|
|
636
|
+
return this.initialHealthyCheck.promise;
|
|
637
|
+
}
|
|
638
|
+
headers() {
|
|
639
|
+
let e = {
|
|
640
|
+
"Marimo-Session-Id": getSessionId(),
|
|
641
|
+
"Marimo-Server-Token": this.config.serverToken ?? "",
|
|
642
|
+
"x-runtime-url": this.httpURL.toString()
|
|
643
|
+
};
|
|
644
|
+
return this.config.authToken && (e.Authorization = `Bearer ${this.config.authToken}`), e;
|
|
645
|
+
}
|
|
646
|
+
sessionHeaders() {
|
|
647
|
+
return { "Marimo-Session-Id": getSessionId() };
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
function asWsUrl(e) {
|
|
651
|
+
if (!e.startsWith("http")) {
|
|
652
|
+
Logger.warn(`URL must start with http: ${e}`);
|
|
653
|
+
let C = new URL(e);
|
|
654
|
+
return C.protocol = "ws", C;
|
|
655
|
+
}
|
|
656
|
+
return new URL(e.replace(/^http/, "ws"));
|
|
657
|
+
}
|
|
658
|
+
require_compiler_runtime();
|
|
659
|
+
function getBaseURI() {
|
|
660
|
+
let e = new URL(document.baseURI);
|
|
661
|
+
return e.search = "", e.hash = "", e.toString();
|
|
662
|
+
}
|
|
663
|
+
const runtimeConfigAtom = atom({
|
|
664
|
+
lazy: true,
|
|
665
|
+
url: getBaseURI()
|
|
666
|
+
});
|
|
667
|
+
var runtimeManagerAtom = atom((e) => {
|
|
668
|
+
let S = e(runtimeConfigAtom);
|
|
669
|
+
return new RuntimeManager(S, S.lazy);
|
|
670
|
+
});
|
|
671
|
+
function getRuntimeManager() {
|
|
672
|
+
return store.get(runtimeManagerAtom);
|
|
673
|
+
}
|
|
674
|
+
function asRemoteURL(e) {
|
|
675
|
+
if (e.startsWith("http")) return new URL(e);
|
|
676
|
+
let S = getRuntimeManager().httpURL.toString();
|
|
677
|
+
return S.startsWith("blob:") && (S = S.replace("blob:", "")), new URL(e, S);
|
|
678
|
+
}
|
|
679
|
+
const millisecondsInWeek = 6048e5, millisecondsInDay = 864e5, millisecondsInMinute = 6e4, millisecondsInHour = 36e5, millisecondsInSecond = 1e3, secondsInDay = 3600 * 24;
|
|
680
|
+
secondsInDay * 7, secondsInDay * 365.2425;
|
|
681
|
+
const constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
|
|
682
|
+
function constructFrom(e, S) {
|
|
683
|
+
return typeof e == "function" ? e(S) : e && typeof e == "object" && constructFromSymbol in e ? e[constructFromSymbol](S) : e instanceof Date ? new e.constructor(S) : new Date(S);
|
|
684
|
+
}
|
|
685
|
+
function toDate(e, S) {
|
|
686
|
+
return constructFrom(S || e, e);
|
|
687
|
+
}
|
|
688
|
+
export {
|
|
689
|
+
assertExists as C,
|
|
690
|
+
isWasm as S,
|
|
691
|
+
initialModeAtom as _,
|
|
692
|
+
millisecondsInMinute as a,
|
|
693
|
+
viewStateAtom as b,
|
|
694
|
+
asRemoteURL as c,
|
|
695
|
+
isStaticNotebook as d,
|
|
696
|
+
appendQueryParams as f,
|
|
697
|
+
getInitialAppMode as g,
|
|
698
|
+
waitForConnectionOpen as h,
|
|
699
|
+
millisecondsInHour as i,
|
|
700
|
+
getRuntimeManager as l,
|
|
701
|
+
require_cuid2 as m,
|
|
702
|
+
constructFrom as n,
|
|
703
|
+
millisecondsInSecond as o,
|
|
704
|
+
isUrl as p,
|
|
705
|
+
millisecondsInDay as r,
|
|
706
|
+
millisecondsInWeek as s,
|
|
707
|
+
toDate as t,
|
|
708
|
+
getStaticVirtualFiles as u,
|
|
709
|
+
kioskModeAtom as v,
|
|
710
|
+
CircleQuestionMark as w,
|
|
711
|
+
Deferred as x,
|
|
712
|
+
useInstallAllowed as y
|
|
713
|
+
};
|