@marimo-team/islands 0.25.3-dev3 → 0.25.3-dev30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/dist/{ConnectedDataExplorerComponent-CNSxdKyJ.js → ConnectedDataExplorerComponent-7EaP9VWb.js} +12 -12
  2. package/dist/{ErrorBoundary-iHE9DnZC.js → ErrorBoundary-2Tp_7IgE.js} +8 -8
  3. package/dist/{abnfDiagram-VCTEODGH-DQDjNXt3.js → abnfDiagram-VCTEODGH-z_OSynK8.js} +2 -2
  4. package/dist/{any-language-editor-B9REGlD9.js → any-language-editor-D4q-IFcM.js} +2 -2
  5. package/dist/{architectureDiagram-5GKGNRK7-Nmls7Wxn.js → architectureDiagram-5GKGNRK7-Cs8J8BZr.js} +1 -1
  6. package/dist/{chat-ui-BDpymeoe.js → chat-ui-BeKQyQQI.js} +1151 -1152
  7. package/dist/{check-EDwSwP89.js → check-BMKBBrdc.js} +1 -1
  8. package/dist/{chunk-IMKFNOWR-CoIFEo-1.js → chunk-IMKFNOWR-aoSFasqF.js} +1 -1
  9. package/dist/{chunk-SHT3W25Y-lHiGx3ZC.js → chunk-SHT3W25Y-CMaybO3O.js} +1 -1
  10. package/dist/{chunk-SVP7TREG-BvsHIrY_.js → chunk-SVP7TREG-BNBrTAw1.js} +1 -1
  11. package/dist/{chunk-TICWLB2K-BC8YIm_n.js → chunk-TICWLB2K-DXNxvUJn.js} +1 -1
  12. package/dist/{chunk-YOKDWASO-DPZk8vhS.js → chunk-YOKDWASO-DKplTrBY.js} +20 -20
  13. package/dist/{classDiagram-ZZMXUADV-Bt98lkkv.js → classDiagram-ZZMXUADV-DXdCCDOg.js} +2 -2
  14. package/dist/{classDiagram-v2-VYDZK3BY-D9bfbcC3.js → classDiagram-v2-VYDZK3BY-DyZqrtLP.js} +2 -2
  15. package/dist/{code-visibility-BCpXa0Xh.js → code-visibility-891-xGjh.js} +16 -16
  16. package/dist/{common-BrBUdtPy.js → common-_IunO2z-.js} +5737 -5439
  17. package/dist/{copy-icon-Ft7t9bqz.js → copy-icon-BgUO8jsi.js} +2 -2
  18. package/dist/{cynefinDiagram-5FMLGOSQ-CgWra7wt.js → cynefinDiagram-5FMLGOSQ-DWHuKJs8.js} +1 -1
  19. package/dist/{dagre-GXQ25YYZ-CFZ8-35c.js → dagre-GXQ25YYZ-DYLu-OCU.js} +1 -1
  20. package/dist/{data-grid-overlay-editor-Ch2SgmvG.js → data-grid-overlay-editor-TVf1Kaxm.js} +5 -5
  21. package/dist/{data-grid-types-BH_r7g7l.js → data-grid-types-0PJ-9N5n.js} +1 -1
  22. package/dist/{diagram-S7CK7UJ4-lCNQrW7d.js → diagram-S7CK7UJ4-PwwcUOHP.js} +1 -1
  23. package/dist/{diagram-UQ7AKVKN-CQPQ6pP_.js → diagram-UQ7AKVKN-CvJbL_IM.js} +1 -1
  24. package/dist/{diagram-VX7I27RA-Cf3b0llz.js → diagram-VX7I27RA-B5RkqnzN.js} +1 -1
  25. package/dist/{diagram-Z3DM3KII-Bt4QLrpn.js → diagram-Z3DM3KII-CyijwTR2.js} +1 -1
  26. package/dist/{dialog-CEBFZNyc.js → dialog-Cc479ZEH.js} +24 -24
  27. package/dist/{dist-DpBpA_n1.js → dist-Lm-D-Vr6.js} +3 -3
  28. package/dist/{dropdown-menu-CP_qCYHC.js → dropdown-menu-BuE2b8Yb.js} +790 -790
  29. package/dist/{ebnfDiagram-PWID7BFC-D3NAyPFY.js → ebnfDiagram-PWID7BFC-DG90ELFp.js} +2 -2
  30. package/dist/{erDiagram-RLTQ6QDP-Tlu09_Nm.js → erDiagram-RLTQ6QDP-FMo_SpyX.js} +1 -1
  31. package/dist/{error-banner-Da600cwz.js → error-banner-CFPHFw4h.js} +26 -21
  32. package/dist/{cells-C8iCYvLU.js → error-entries-CnqKxhU9.js} +1370 -1314
  33. package/dist/{feedback-button-DxXNcC6q.js → feedback-button-DlBBr16w.js} +121 -122
  34. package/dist/{flowDiagram-HODETNUW-CAYbpJmV.js → flowDiagram-HODETNUW-DQ4JuadE.js} +2 -2
  35. package/dist/{formats-BGh2thRc.js → formats-DRHUWwSK.js} +2 -2
  36. package/dist/{ganttDiagram-EL5Y4UJY-BQT16JSc.js → ganttDiagram-EL5Y4UJY-Dh_4cBJZ.js} +2 -2
  37. package/dist/{glide-data-editor-BQ7uKbeo.js → glide-data-editor-ugYWecYd.js} +55 -55
  38. package/dist/{glide-utils-DJyqh0EM.js → glide-utils-pisbYVjH.js} +3 -3
  39. package/dist/{globals-DSavh2ZB.js → globals-BdBjL67a.js} +3 -3
  40. package/dist/{highlighted-body-KPVGNVTW-zwjq21tf.js → highlighted-body-KPVGNVTW-3Ziwfz-V.js} +2 -2
  41. package/dist/{html-to-image-CZY1pIZH.js → html-to-image-BsG_zyNW.js} +68 -68
  42. package/dist/{infoDiagram-27XIBGKW-XrDxhr0x.js → infoDiagram-27XIBGKW-CRSDtRrd.js} +1 -1
  43. package/dist/{ishikawaDiagram-5VMMS53U-CD1muzov.js → ishikawaDiagram-5VMMS53U-DxLEUldB.js} +1 -1
  44. package/dist/{kanban-definition-UXKFOSKX-Dg9W142_.js → kanban-definition-UXKFOSKX-BLhvu8o4.js} +1 -1
  45. package/dist/{label-BDKF3Afc.js → label-DoysmLMW.js} +1 -1
  46. package/dist/{linear-Cnaq3Tfb.js → linear-DWERh7eI.js} +121 -73
  47. package/dist/{loader-BQOfjTIJ.js → loader-BPdQhmlq.js} +10 -10
  48. package/dist/main.js +759 -759
  49. package/dist/{mermaid-CiAXjLpA.js → mermaid-Bjm6C1qN.js} +37 -37
  50. package/dist/mermaid-HWGCJPDP-Du3-HPQA.js +2 -0
  51. package/dist/{mindmap-definition-YA3MSWOX-DgCidgYJ.js → mindmap-definition-YA3MSWOX-g2LwxnYQ.js} +1 -1
  52. package/dist/{number-overlay-editor-D6kYaqh5.js → number-overlay-editor-I4AHjcHG.js} +3 -3
  53. package/dist/{pegDiagram-XKGWAZYB-coOYYKB6.js → pegDiagram-XKGWAZYB-CpMAt3Qs.js} +2 -2
  54. package/dist/{pieDiagram-E7YTZNPT-BnXTc3bj.js → pieDiagram-E7YTZNPT-CVTthoZo.js} +1 -1
  55. package/dist/precisionRound-DhAzeRcm.js +49 -0
  56. package/dist/{process-output-e4jj9Ijt.js → process-output-DgQrilBD.js} +5 -5
  57. package/dist/{quadrantDiagram-AXDQQJYC-Ccw0xMjN.js → quadrantDiagram-AXDQQJYC-Blrm7V7_.js} +1 -1
  58. package/dist/{railroadDiagram-O6MQD6OU-B28-u83n.js → railroadDiagram-O6MQD6OU-ao8cqqFB.js} +2 -2
  59. package/dist/{react-vega-BED0DjiB.js → react-vega-BDpbvBCb.js} +12284 -12270
  60. package/dist/{requirementDiagram-BXWQKSXE-CdYCTMu0.js → requirementDiagram-BXWQKSXE--J8vyfm-.js} +1 -1
  61. package/dist/{reveal-component-BTBfJ3ju.js → reveal-component-Bb5vzlMs.js} +9 -9
  62. package/dist/{select-BButFi-d.js → select-DemoKT4G.js} +199 -199
  63. package/dist/{sequenceDiagram-WJ2MYXX4-CM3aRAe_.js → sequenceDiagram-WJ2MYXX4-CiQbn62x.js} +1 -1
  64. package/dist/{spec-BwarBpUJ.js → spec-D_u2ipzF.js} +4 -4
  65. package/dist/{stateDiagram-D77RDMKH-DOZUMVj8.js → stateDiagram-D77RDMKH-DVEeGs5b.js} +2 -2
  66. package/dist/{stateDiagram-v2-MP3YSRHH-CISYxma6.js → stateDiagram-v2-MP3YSRHH-1OQRe6iA.js} +2 -2
  67. package/dist/style.css +1 -1
  68. package/dist/{swimlanes-42K2YHIH-BkSppxp8.js → swimlanes-42K2YHIH-CqkGoGqn.js} +1 -1
  69. package/dist/{swimlanesDiagram-VR7AAH4N-c8G5pGxC.js → swimlanesDiagram-VR7AAH4N-CszjkrKo.js} +2 -2
  70. package/dist/{time-BieKwdYS.js → time-BaMbJs4z.js} +18 -18
  71. package/dist/{timeline-definition-24CTP7MA-CaMQayqK.js → timeline-definition-24CTP7MA-DLRUNVAx.js} +1 -1
  72. package/dist/toDate-gyi35XS2.js +1185 -0
  73. package/dist/{toast-B9UMEi8u.js → toast-PkdZraM8.js} +221 -221
  74. package/dist/{tooltip-BO1REbqs.js → tooltip-CtBZ5q8p.js} +51 -51
  75. package/dist/{use-restore-focus-BEM7sFWl.js → use-restore-focus-CKjfFjLM.js} +1 -1
  76. package/dist/{useAsyncData-Deh5kszT.js → useAsyncData-BneN349z.js} +1 -1
  77. package/dist/{useDateFormatter-D8XruNGG.js → useDateFormatter-DkajGwwd.js} +2 -2
  78. package/dist/{useDeepCompareMemoize-DXwzRINI.js → useDeepCompareMemoize-Z_7R8wTt.js} +1 -1
  79. package/dist/{useLifecycle-j7D9uD1o.js → useLifecycle-Dfq8UD-b.js} +2 -2
  80. package/dist/{useTheme-CRnjkku0.js → useTheme-Bu5bBgrh.js} +86 -86
  81. package/dist/{vega-component-DG29TAB7.js → vega-component-1lFfDE_8.js} +10 -10
  82. package/dist/{vega-embed-container-BNHE18G9.js → vega-embed-container-BgKnsDbB.js} +2 -2
  83. package/dist/{vega-loader.browser-DNST6uVf.js → vega-loader.browser-CpbZAXub.js} +297 -506
  84. package/dist/{vennDiagram-4TSXK5OY-CF8pfaK3.js → vennDiagram-4TSXK5OY-CypgoBVZ.js} +1 -1
  85. package/dist/{wardleyDiagram-VM6X3IG4-dGPu39d-.js → wardleyDiagram-VM6X3IG4-B6xjiQ_g.js} +1 -1
  86. package/dist/{xychartDiagram-S5SC5T6Z-CP6-9q56.js → xychartDiagram-S5SC5T6Z-e0PefDVs.js} +2 -2
  87. package/package.json +2 -1
  88. package/src/__tests__/fixtures/{pair-preview.ts → pair-config.ts} +3 -2
  89. package/src/__tests__/mount.test.ts +28 -8
  90. package/src/components/data-table/__tests__/context-menu.test.ts +176 -0
  91. package/src/components/data-table/__tests__/date-filter-inputs.test.tsx +24 -1
  92. package/src/components/data-table/__tests__/export-actions.test.tsx +329 -6
  93. package/src/components/data-table/context-menu.tsx +125 -26
  94. package/src/components/data-table/date-filter-inputs.tsx +15 -42
  95. package/src/components/data-table/export-actions.tsx +192 -116
  96. package/src/components/data-table/schemas.ts +14 -36
  97. package/src/components/data-table/utils.ts +18 -0
  98. package/src/components/editor/Output.tsx +9 -2
  99. package/src/components/editor/__tests__/dynamic-favicon.test.tsx +111 -18
  100. package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +80 -252
  101. package/src/components/editor/actions/__tests__/pair-with-agent-modal.test.tsx +186 -34
  102. package/src/components/editor/actions/pair-with-agent-commands.ts +42 -51
  103. package/src/components/editor/actions/pair-with-agent-modal.tsx +96 -36
  104. package/src/components/editor/chrome/panels/error-panel.tsx +1 -0
  105. package/src/components/editor/chrome/wrapper/__tests__/attachment-status.test.tsx +366 -0
  106. package/src/components/editor/chrome/wrapper/footer-item.tsx +32 -24
  107. package/src/components/editor/chrome/wrapper/footer-items/attachment-status.tsx +237 -0
  108. package/src/components/editor/chrome/wrapper/footer.tsx +2 -0
  109. package/src/components/editor/controls/__tests__/command-palette.test.tsx +53 -0
  110. package/src/components/editor/controls/command-palette.tsx +22 -10
  111. package/src/components/editor/dynamic-favicon.tsx +21 -40
  112. package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +537 -0
  113. package/src/components/editor/errors/send-error-report-button.tsx +69 -0
  114. package/src/components/editor/output/MarimoErrorOutput.tsx +21 -5
  115. package/src/components/editor/output/MarimoTracebackOutput.tsx +35 -20
  116. package/src/components/editor/output/__tests__/ansi-reduce.test.ts +18 -0
  117. package/src/components/editor/output/ansi-reduce.ts +6 -0
  118. package/src/core/attachments/__tests__/toast.test.tsx +58 -0
  119. package/src/core/attachments/state.ts +18 -0
  120. package/src/core/attachments/toast.ts +15 -0
  121. package/src/core/cells/__tests__/cells.test.ts +52 -0
  122. package/src/core/cells/__tests__/error-report.test.ts +139 -0
  123. package/src/core/cells/__tests__/notebook-outline.test.ts +113 -0
  124. package/src/core/cells/__tests__/session.test.ts +50 -1
  125. package/src/core/cells/cells.ts +2 -1
  126. package/src/core/cells/error-report.ts +63 -0
  127. package/src/core/cells/session.ts +28 -1
  128. package/src/core/config/pair.ts +5 -3
  129. package/src/core/edit-app.tsx +2 -2
  130. package/src/core/host/AGENTS.md +5 -0
  131. package/src/core/host/__tests__/attachments.test.ts +57 -0
  132. package/src/core/host/__tests__/document.test.ts +124 -0
  133. package/src/core/host/__tests__/events.test.ts +46 -0
  134. package/src/core/host/__tests__/fixtures.ts +39 -0
  135. package/src/core/host/__tests__/notebook-client.test.ts +433 -0
  136. package/src/core/host/__tests__/protocol.test.ts +15 -0
  137. package/src/core/host/__tests__/stream.test.ts +209 -0
  138. package/src/core/host/connection.ts +81 -0
  139. package/src/core/host/events.ts +61 -0
  140. package/src/core/host/notebook-client.ts +290 -0
  141. package/src/core/host/protocol.ts +11 -6
  142. package/src/core/host/resources/attachments.ts +19 -0
  143. package/src/core/host/resources/document.ts +101 -0
  144. package/src/core/host/resources/resource.ts +47 -0
  145. package/src/core/host/stream.ts +211 -0
  146. package/src/core/network/connection.ts +4 -2
  147. package/src/core/run-app.tsx +2 -2
  148. package/src/core/runtime/__tests__/runtime.test.ts +55 -11
  149. package/src/core/runtime/runtime.ts +15 -1
  150. package/src/core/runtime/types.ts +2 -0
  151. package/src/core/websocket/__tests__/{useMarimoKernelConnection.test.ts → connection-state.test.ts} +15 -17
  152. package/src/core/websocket/__tests__/{useWebSocket.test.ts → createConnectionTransport.test.ts} +1 -1
  153. package/src/core/websocket/__tests__/useNotebookClient.hook.test.tsx +170 -0
  154. package/src/core/websocket/__tests__/{useMarimoKernelConnection.hook.test.tsx → useNotebookSession.hook.test.tsx} +181 -65
  155. package/src/core/websocket/connection-state.ts +70 -0
  156. package/src/core/websocket/state.ts +7 -0
  157. package/src/core/websocket/transports/__tests__/sse.test.ts +1 -4
  158. package/src/core/websocket/transports/create.ts +31 -0
  159. package/src/core/websocket/transports/transport.ts +12 -23
  160. package/src/core/websocket/types.ts +9 -39
  161. package/src/core/websocket/useNotebookClient.ts +88 -0
  162. package/src/core/websocket/{useMarimoKernelConnection.tsx → useNotebookSession.tsx} +59 -225
  163. package/src/mount.tsx +7 -3
  164. package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +84 -0
  165. package/src/utils/__tests__/dates.test.ts +116 -0
  166. package/src/utils/dates.ts +94 -0
  167. package/src/utils/once.ts +19 -19
  168. package/dist/error-entries-CzoYkIQZ.js +0 -56
  169. package/dist/mermaid-HWGCJPDP-ByCsZnYF.js +0 -2
  170. package/dist/precisionRound-DMIVQrt2.js +0 -97
  171. package/dist/toDate-BNJf01u1.js +0 -703
  172. package/src/core/websocket/useWebSocket.tsx +0 -88
@@ -1,703 +0,0 @@
1
- import { t as e } from "./rolldown-runtime-Cb76FRpK.js";
2
- import { g as t } from "./button-CvjkwdSk.js";
3
- import { t as n } from "./compiler-runtime-CldRdSsv.js";
4
- import { h as r } from "./tooltip-BO1REbqs.js";
5
- import { C as i, E as a, _ as o, a as s, b as c } from "./useTheme-CRnjkku0.js";
6
- import { t as l } from "./invariant-DLmrl-hA.js";
7
- var u = r("circle-question-mark", [
8
- ["circle", {
9
- cx: "12",
10
- cy: "12",
11
- r: "10",
12
- key: "1mglay"
13
- }],
14
- ["path", {
15
- d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",
16
- key: "1u773s"
17
- }],
18
- ["path", {
19
- d: "M12 17h.01",
20
- key: "p32p05"
21
- }]
22
- ]), d = n();
23
- function f(e, t) {
24
- if (e == null) throw Error(t || `Expected value but got ${e}`);
25
- }
26
- //#endregion
27
- //#region src/core/wasm/utils.ts
28
- function p() {
29
- return typeof document < "u" && document.querySelector("marimo-wasm") !== null;
30
- }
31
- //#endregion
32
- //#region src/utils/Deferred.ts
33
- var m = class {
34
- promise;
35
- resolve;
36
- reject;
37
- status = "pending";
38
- value = void 0;
39
- constructor() {
40
- this.promise = new Promise((e, t) => {
41
- this.reject = (e) => {
42
- this.status = "rejected", t(e);
43
- }, this.resolve = (t) => {
44
- this.status = "resolved", h(t) || (this.value = t), e(t);
45
- };
46
- });
47
- }
48
- };
49
- function h(e) {
50
- return typeof e == "object" && !!e && "then" in e && typeof e.then == "function";
51
- }
52
- //#endregion
53
- //#region src/core/mode.ts
54
- function g() {
55
- let e = o.get(v);
56
- return f(e, "internal-error: initial mode not found"), l(e !== "present", "internal-error: initial mode cannot be 'present'"), e;
57
- }
58
- var _ = a({
59
- mode: c() ? "read" : "not-set",
60
- cellAnchor: null
61
- }), v = a(void 0);
62
- function y() {
63
- let e = o.get(v);
64
- return e !== "home" && e !== "gallery";
65
- }
66
- var b = a(!1);
67
- function x() {
68
- let e = (0, d.c)(1), { mode: t } = i(_), n = i(b), r;
69
- return e[0] === Symbol.for("react.memo_cache_sentinel") ? (r = new URLSearchParams(window.location.search).get(s.kiosk), e[0] = r) : r = e[0], t !== "read" && !n && r !== "true";
70
- }
71
- //#endregion
72
- //#region ../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/_u64.js
73
- var S = /* @__PURE__ */ e(((e) => {
74
- Object.defineProperty(e, "__esModule", { value: !0 }), 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 = v, e.fromBig = r, e.split = i;
75
- var t = /* @__PURE__ */ BigInt(2 ** 32 - 1), n = /* @__PURE__ */ BigInt(32);
76
- function r(e, r = !1) {
77
- return r ? {
78
- h: Number(e & t),
79
- l: Number(e >> n & t)
80
- } : {
81
- h: Number(e >> n & t) | 0,
82
- l: Number(e & t) | 0
83
- };
84
- }
85
- function i(e, t = !1) {
86
- let n = e.length, i = new Uint32Array(n), a = new Uint32Array(n);
87
- for (let o = 0; o < n; o++) {
88
- let { h: n, l: s } = r(e[o], t);
89
- [i[o], a[o]] = [n, s];
90
- }
91
- return [i, a];
92
- }
93
- var a = (e, t) => BigInt(e >>> 0) << n | BigInt(t >>> 0);
94
- e.toBig = a;
95
- var o = (e, t, n) => e >>> n;
96
- e.shrSH = o;
97
- var s = (e, t, n) => e << 32 - n | t >>> n;
98
- e.shrSL = s;
99
- var c = (e, t, n) => e >>> n | t << 32 - n;
100
- e.rotrSH = c;
101
- var l = (e, t, n) => e << 32 - n | t >>> n;
102
- e.rotrSL = l;
103
- var u = (e, t, n) => e << 64 - n | t >>> n - 32;
104
- e.rotrBH = u;
105
- var d = (e, t, n) => e >>> n - 32 | t << 64 - n;
106
- e.rotrBL = d;
107
- var f = (e, t) => t;
108
- e.rotr32H = f;
109
- var p = (e, t) => e;
110
- e.rotr32L = p;
111
- var m = (e, t, n) => e << n | t >>> 32 - n;
112
- e.rotlSH = m;
113
- var h = (e, t, n) => t << n | e >>> 32 - n;
114
- e.rotlSL = h;
115
- var g = (e, t, n) => t << n - 32 | e >>> 64 - n;
116
- e.rotlBH = g;
117
- var _ = (e, t, n) => e << n - 32 | t >>> 64 - n;
118
- e.rotlBL = _;
119
- function v(e, t, n, r) {
120
- let i = (t >>> 0) + (r >>> 0);
121
- return {
122
- h: e + n + (i / 2 ** 32 | 0) | 0,
123
- l: i | 0
124
- };
125
- }
126
- var y = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0);
127
- e.add3L = y;
128
- var b = (e, t, n, r) => t + n + r + (e / 2 ** 32 | 0) | 0;
129
- e.add3H = b;
130
- var x = (e, t, n, r) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (r >>> 0);
131
- e.add4L = x;
132
- var S = (e, t, n, r, i) => t + n + r + i + (e / 2 ** 32 | 0) | 0;
133
- e.add4H = S;
134
- var C = (e, t, n, r, i) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (r >>> 0) + (i >>> 0);
135
- e.add5L = C;
136
- var w = (e, t, n, r, i, a) => t + n + r + i + a + (e / 2 ** 32 | 0) | 0;
137
- e.add5H = w, e.default = {
138
- fromBig: r,
139
- split: i,
140
- toBig: a,
141
- shrSH: o,
142
- shrSL: s,
143
- rotrSH: c,
144
- rotrSL: l,
145
- rotrBH: u,
146
- rotrBL: d,
147
- rotr32H: f,
148
- rotr32L: p,
149
- rotlSH: m,
150
- rotlSL: h,
151
- rotlBH: g,
152
- rotlBL: _,
153
- add: v,
154
- add3L: y,
155
- add3H: b,
156
- add4L: x,
157
- add4H: S,
158
- add5H: w,
159
- add5L: C
160
- };
161
- })), C = /* @__PURE__ */ e(((e) => {
162
- Object.defineProperty(e, "__esModule", { value: !0 }), e.crypto = void 0, e.crypto = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
163
- })), w = /* @__PURE__ */ e(((e) => {
164
- Object.defineProperty(e, "__esModule", { value: !0 }), e.wrapXOFConstructorWithOpts = e.wrapConstructorWithOpts = e.wrapConstructor = e.Hash = e.nextTick = e.swap32IfBE = e.byteSwapIfBE = e.swap8IfBE = e.isLE = void 0, e.isBytes = n, e.anumber = r, e.abytes = i, e.ahash = a, e.aexists = o, e.aoutput = s, e.u8 = c, e.u32 = l, e.clean = u, e.createView = d, e.rotr = f, e.rotl = p, e.byteSwap = m, e.byteSwap32 = h, e.bytesToHex = v, e.hexToBytes = x, e.asyncLoop = S, e.utf8ToBytes = w, e.bytesToUtf8 = T, e.toBytes = E, e.kdfInputToBytes = D, e.concatBytes = O, e.checkOpts = k, e.createHasher = A, e.createOptHasher = j, e.createXOFer = M, e.randomBytes = N;
165
- var t = C();
166
- function n(e) {
167
- return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
168
- }
169
- function r(e) {
170
- if (!Number.isSafeInteger(e) || e < 0) throw Error("positive integer expected, got " + e);
171
- }
172
- function i(e, ...t) {
173
- if (!n(e)) throw Error("Uint8Array expected");
174
- if (t.length > 0 && !t.includes(e.length)) throw Error("Uint8Array expected of length " + t + ", got length=" + e.length);
175
- }
176
- function a(e) {
177
- if (typeof e != "function" || typeof e.create != "function") throw Error("Hash should be wrapped by utils.createHasher");
178
- r(e.outputLen), r(e.blockLen);
179
- }
180
- function o(e, t = !0) {
181
- if (e.destroyed) throw Error("Hash instance has been destroyed");
182
- if (t && e.finished) throw Error("Hash#digest() has already been called");
183
- }
184
- function s(e, t) {
185
- i(e);
186
- let n = t.outputLen;
187
- if (e.length < n) throw Error("digestInto() expects output buffer of length at least " + n);
188
- }
189
- function c(e) {
190
- return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
191
- }
192
- function l(e) {
193
- return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
194
- }
195
- function u(...e) {
196
- for (let t = 0; t < e.length; t++) e[t].fill(0);
197
- }
198
- function d(e) {
199
- return new DataView(e.buffer, e.byteOffset, e.byteLength);
200
- }
201
- function f(e, t) {
202
- return e << 32 - t | e >>> t;
203
- }
204
- function p(e, t) {
205
- return e << t | e >>> 32 - t >>> 0;
206
- }
207
- e.isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
208
- function m(e) {
209
- return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
210
- }
211
- e.swap8IfBE = e.isLE ? (e) => e : (e) => m(e), e.byteSwapIfBE = e.swap8IfBE;
212
- function h(e) {
213
- for (let t = 0; t < e.length; t++) e[t] = m(e[t]);
214
- return e;
215
- }
216
- e.swap32IfBE = e.isLE ? (e) => e : h;
217
- var g = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", _ = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
218
- function v(e) {
219
- if (i(e), g) return e.toHex();
220
- let t = "";
221
- for (let n = 0; n < e.length; n++) t += _[e[n]];
222
- return t;
223
- }
224
- var y = {
225
- _0: 48,
226
- _9: 57,
227
- A: 65,
228
- F: 70,
229
- a: 97,
230
- f: 102
231
- };
232
- function b(e) {
233
- if (e >= y._0 && e <= y._9) return e - y._0;
234
- if (e >= y.A && e <= y.F) return e - (y.A - 10);
235
- if (e >= y.a && e <= y.f) return e - (y.a - 10);
236
- }
237
- function x(e) {
238
- if (typeof e != "string") throw Error("hex string expected, got " + typeof e);
239
- if (g) return Uint8Array.fromHex(e);
240
- let t = e.length, n = t / 2;
241
- if (t % 2) throw Error("hex string expected, got unpadded hex of length " + t);
242
- let r = new Uint8Array(n);
243
- for (let t = 0, i = 0; t < n; t++, i += 2) {
244
- let n = b(e.charCodeAt(i)), a = b(e.charCodeAt(i + 1));
245
- if (n === void 0 || a === void 0) {
246
- let t = e[i] + e[i + 1];
247
- throw Error("hex string expected, got non-hex character \"" + t + "\" at index " + i);
248
- }
249
- r[t] = n * 16 + a;
250
- }
251
- return r;
252
- }
253
- e.nextTick = async () => {};
254
- async function S(t, n, r) {
255
- let i = Date.now();
256
- for (let a = 0; a < t; a++) {
257
- r(a);
258
- let t = Date.now() - i;
259
- t >= 0 && t < n || (await (0, e.nextTick)(), i += t);
260
- }
261
- }
262
- function w(e) {
263
- if (typeof e != "string") throw Error("string expected");
264
- return new Uint8Array(new TextEncoder().encode(e));
265
- }
266
- function T(e) {
267
- return new TextDecoder().decode(e);
268
- }
269
- function E(e) {
270
- return typeof e == "string" && (e = w(e)), i(e), e;
271
- }
272
- function D(e) {
273
- return typeof e == "string" && (e = w(e)), i(e), e;
274
- }
275
- function O(...e) {
276
- let t = 0;
277
- for (let n = 0; n < e.length; n++) {
278
- let r = e[n];
279
- i(r), t += r.length;
280
- }
281
- let n = new Uint8Array(t);
282
- for (let t = 0, r = 0; t < e.length; t++) {
283
- let i = e[t];
284
- n.set(i, r), r += i.length;
285
- }
286
- return n;
287
- }
288
- function k(e, t) {
289
- if (t !== void 0 && {}.toString.call(t) !== "[object Object]") throw Error("options should be object or undefined");
290
- return Object.assign(e, t);
291
- }
292
- e.Hash = class {};
293
- function A(e) {
294
- let t = (t) => e().update(E(t)).digest(), n = e();
295
- return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
296
- }
297
- function j(e) {
298
- let t = (t, n) => e(n).update(E(t)).digest(), n = e({});
299
- return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = (t) => e(t), t;
300
- }
301
- function M(e) {
302
- let t = (t, n) => e(n).update(E(t)).digest(), n = e({});
303
- return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = (t) => e(t), t;
304
- }
305
- e.wrapConstructor = A, e.wrapConstructorWithOpts = j, e.wrapXOFConstructorWithOpts = M;
306
- function N(e = 32) {
307
- if (t.crypto && typeof t.crypto.getRandomValues == "function") return t.crypto.getRandomValues(new Uint8Array(e));
308
- if (t.crypto && typeof t.crypto.randomBytes == "function") return Uint8Array.from(t.crypto.randomBytes(e));
309
- throw Error("crypto.getRandomValues must be defined");
310
- }
311
- })), T = /* @__PURE__ */ e(((e) => {
312
- Object.defineProperty(e, "__esModule", { value: !0 }), 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 = _;
313
- var t = S(), n = w(), r = BigInt(0), i = BigInt(1), a = BigInt(2), o = BigInt(7), s = BigInt(256), c = BigInt(113), l = [], u = [], d = [];
314
- for (let e = 0, t = i, n = 1, f = 0; e < 24; e++) {
315
- [n, f] = [f, (2 * n + 3 * f) % 5], l.push(2 * (5 * f + n)), u.push((e + 1) * (e + 2) / 2 % 64);
316
- let p = r;
317
- for (let e = 0; e < 7; e++) t = (t << i ^ (t >> o) * c) % s, t & a && (p ^= i << (i << /* @__PURE__ */ BigInt(e)) - i);
318
- d.push(p);
319
- }
320
- var f = (0, t.split)(d, !0), p = f[0], m = f[1], h = (e, n, r) => r > 32 ? (0, t.rotlBH)(e, n, r) : (0, t.rotlSH)(e, n, r), g = (e, n, r) => r > 32 ? (0, t.rotlBL)(e, n, r) : (0, t.rotlSL)(e, n, r);
321
- function _(e, t = 24) {
322
- let r = /* @__PURE__ */ new Uint32Array(10);
323
- for (let n = 24 - t; n < 24; n++) {
324
- for (let t = 0; t < 10; t++) r[t] = e[t] ^ e[t + 10] ^ e[t + 20] ^ e[t + 30] ^ e[t + 40];
325
- for (let t = 0; t < 10; t += 2) {
326
- let n = (t + 8) % 10, i = (t + 2) % 10, a = r[i], o = r[i + 1], s = h(a, o, 1) ^ r[n], c = g(a, o, 1) ^ r[n + 1];
327
- for (let n = 0; n < 50; n += 10) e[t + n] ^= s, e[t + n + 1] ^= c;
328
- }
329
- let t = e[2], i = e[3];
330
- for (let n = 0; n < 24; n++) {
331
- let r = u[n], a = h(t, i, r), o = g(t, i, r), s = l[n];
332
- t = e[s], i = e[s + 1], e[s] = a, e[s + 1] = o;
333
- }
334
- for (let t = 0; t < 50; t += 10) {
335
- for (let n = 0; n < 10; n++) r[n] = e[t + n];
336
- for (let n = 0; n < 10; n++) e[t + n] ^= ~r[(n + 2) % 10] & r[(n + 4) % 10];
337
- }
338
- e[0] ^= p[n], e[1] ^= m[n];
339
- }
340
- (0, n.clean)(r);
341
- }
342
- var v = class e extends n.Hash {
343
- constructor(e, t, r, i = !1, a = 24) {
344
- if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = t, this.outputLen = r, this.enableXOF = i, this.rounds = a, (0, n.anumber)(r), !(0 < e && e < 200)) throw Error("only keccak-f1600 function is supported");
345
- this.state = /* @__PURE__ */ new Uint8Array(200), this.state32 = (0, n.u32)(this.state);
346
- }
347
- clone() {
348
- return this._cloneInto();
349
- }
350
- keccak() {
351
- (0, n.swap32IfBE)(this.state32), _(this.state32, this.rounds), (0, n.swap32IfBE)(this.state32), this.posOut = 0, this.pos = 0;
352
- }
353
- update(e) {
354
- (0, n.aexists)(this), e = (0, n.toBytes)(e), (0, n.abytes)(e);
355
- let { blockLen: t, state: r } = this, i = e.length;
356
- for (let n = 0; n < i;) {
357
- let a = Math.min(t - this.pos, i - n);
358
- for (let t = 0; t < a; t++) r[this.pos++] ^= e[n++];
359
- this.pos === t && this.keccak();
360
- }
361
- return this;
362
- }
363
- finish() {
364
- if (this.finished) return;
365
- this.finished = !0;
366
- let { state: e, suffix: t, pos: n, blockLen: r } = this;
367
- e[n] ^= t, t & 128 && n === r - 1 && this.keccak(), e[r - 1] ^= 128, this.keccak();
368
- }
369
- writeInto(e) {
370
- (0, n.aexists)(this, !1), (0, n.abytes)(e), this.finish();
371
- let t = this.state, { blockLen: r } = this;
372
- for (let n = 0, i = e.length; n < i;) {
373
- this.posOut >= r && this.keccak();
374
- let a = Math.min(r - this.posOut, i - n);
375
- e.set(t.subarray(this.posOut, this.posOut + a), n), this.posOut += a, n += a;
376
- }
377
- return e;
378
- }
379
- xofInto(e) {
380
- if (!this.enableXOF) throw Error("XOF is not possible for this instance");
381
- return this.writeInto(e);
382
- }
383
- xof(e) {
384
- return (0, n.anumber)(e), this.xofInto(new Uint8Array(e));
385
- }
386
- digestInto(e) {
387
- if ((0, n.aoutput)(e, this), this.finished) throw Error("digest() was already called");
388
- return this.writeInto(e), this.destroy(), e;
389
- }
390
- digest() {
391
- return this.digestInto(new Uint8Array(this.outputLen));
392
- }
393
- destroy() {
394
- this.destroyed = !0, (0, n.clean)(this.state);
395
- }
396
- _cloneInto(t) {
397
- let { blockLen: n, suffix: r, outputLen: i, rounds: a, enableXOF: o } = this;
398
- return t ||= new e(n, r, i, o, a), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = a, t.suffix = r, t.outputLen = i, t.enableXOF = o, t.destroyed = this.destroyed, t;
399
- }
400
- };
401
- e.Keccak = v;
402
- var y = (e, t, r) => (0, n.createHasher)(() => new v(t, e, r));
403
- e.sha3_224 = y(6, 144, 28), e.sha3_256 = y(6, 136, 32), e.sha3_384 = y(6, 104, 48), e.sha3_512 = y(6, 72, 64), e.keccak_224 = y(1, 144, 28), e.keccak_256 = y(1, 136, 32), e.keccak_384 = y(1, 104, 48), e.keccak_512 = y(1, 72, 64);
404
- var b = (e, t, r) => (0, n.createXOFer)((n = {}) => new v(t, e, n.dkLen === void 0 ? r : n.dkLen, !0));
405
- e.shake128 = b(31, 168, 16), e.shake256 = b(31, 136, 32);
406
- })), E = /* @__PURE__ */ e(((e, t) => {
407
- var { sha3_512: n } = T(), r = 24, i = 32, a = (e = 4, t = Math.random) => {
408
- let n = "";
409
- for (; n.length < e;) n += Math.floor(t() * 36).toString(36);
410
- return n;
411
- };
412
- function o(e) {
413
- let t = 0n;
414
- for (let n of e.values()) {
415
- let e = BigInt(n);
416
- t = (t << 8n) + e;
417
- }
418
- return t;
419
- }
420
- var s = (e = "") => o(n(e)).toString(36).slice(1), c = Array.from({ length: 26 }, (e, t) => String.fromCharCode(t + 97)), l = (e) => c[Math.floor(e() * c.length)], u = ({ globalObj: e = typeof global < "u" ? global : typeof window < "u" ? window : {}, random: t = Math.random } = {}) => {
421
- let n = Object.keys(e).toString();
422
- return s(n.length ? n + a(i, t) : a(i, t)).substring(0, i);
423
- }, d = (e) => () => e++, f = 476782367, p = ({ random: e = Math.random, counter: t = d(Math.floor(e() * f)), length: n = r, fingerprint: i = u({ random: e }) } = {}) => function() {
424
- let r = l(e), o = Date.now().toString(36), c = t().toString(36);
425
- return `${r + s(`${o + a(n, e) + c + i}`).substring(1, n)}`;
426
- }, m = p(), h = (e, { minLength: t = 2, maxLength: n = i } = {}) => {
427
- let r = e.length, a = /^[0-9a-z]+$/;
428
- try {
429
- if (typeof e == "string" && r >= t && r <= n && a.test(e)) return !0;
430
- } finally {}
431
- return !1;
432
- };
433
- t.exports.getConstants = () => ({
434
- defaultLength: r,
435
- bigLength: i
436
- }), t.exports.init = p, t.exports.createId = m, t.exports.bufToBigInt = o, t.exports.createCounter = d, t.exports.createFingerprint = u, t.exports.isCuid = h;
437
- })), D = /* @__PURE__ */ e(((e, t) => {
438
- var { createId: n, init: r, getConstants: i, isCuid: a } = E();
439
- t.exports.createId = n, t.exports.init = r, t.exports.getConstants = i, t.exports.isCuid = a;
440
- })), O = D();
441
- function k(e) {
442
- let t = new URL(window.location.href);
443
- e(t.searchParams), window.history.replaceState({}, "", t.toString());
444
- }
445
- var A = /^(https?:\/\/\S+)$/;
446
- function j(e) {
447
- return typeof e == "string" && A.test(e);
448
- }
449
- function M({ href: e, queryParams: t, keys: n }) {
450
- let r = typeof t == "string" ? new URLSearchParams(t) : t;
451
- if (r.size === 0 || e.startsWith("http://") || e.startsWith("https://")) return e;
452
- let i = e.startsWith("#"), a = i && e.includes("?");
453
- if (i && !a) {
454
- let t = n ? [...r.entries()].filter(([e]) => n.includes(e)) : [...r.entries()], i = new URLSearchParams();
455
- for (let [e, n] of t) i.set(e, n);
456
- let a = i.toString();
457
- return a ? `/?${a}${e}` : e;
458
- }
459
- let o = e, s = "", c = new URLSearchParams(), l = +!!i, u = e.indexOf("#", l);
460
- u !== -1 && (s = e.slice(u), o = e.slice(0, u));
461
- let d = o.indexOf("?");
462
- d !== -1 && (c = new URLSearchParams(o.slice(d + 1)), o = o.slice(0, d));
463
- let f = new URLSearchParams(c), p = n ? [...r.entries()].filter(([e]) => n.includes(e)) : [...r.entries()];
464
- for (let [e, t] of p) f.set(e, t);
465
- let m = f.toString();
466
- return m ? `${o}?${m}${s}` : e;
467
- }
468
- a(null);
469
- var N = (0, O.init)({ length: 6 });
470
- function P() {
471
- return `s_${N()}`;
472
- }
473
- function F(e) {
474
- return e ? /^s_[\da-z]{6}$/.test(e) : !1;
475
- }
476
- var I = null;
477
- function L() {
478
- let e = o.get(v) === "edit", n = new URL(window.location.href).searchParams.get(s.sessionId), r = F(n) ? n : null;
479
- return k((t) => {
480
- if (!e) {
481
- t.delete(s.sessionId), t.delete(s.kiosk);
482
- return;
483
- }
484
- t.has(s.kiosk) || t.delete(s.sessionId);
485
- }), r === null ? (t.debug("Starting a new session", { sessionId: n }), P()) : e ? (t.debug("Connecting to existing session", { sessionId: r }), r) : (t.debug("Ignoring session_id from URL outside the editor", { sessionId: r }), P());
486
- }
487
- function R() {
488
- return I === null && (I = L()), I;
489
- }
490
- //#endregion
491
- //#region src/core/static/static-state.ts
492
- function z(e) {
493
- if (typeof e != "object" || !e || Array.isArray(e)) return !1;
494
- for (let t of Object.values(e)) if (typeof t != "string") return !1;
495
- return !0;
496
- }
497
- function B(e) {
498
- if (typeof e != "object" || !e || Array.isArray(e)) return !1;
499
- let t = e;
500
- return !(!z(t.files) || t.modelNotifications !== void 0 && !Array.isArray(t.modelNotifications));
501
- }
502
- function V() {
503
- let e = typeof window > "u" ? void 0 : window.__MARIMO_STATIC__;
504
- return B(e) ? e : void 0;
505
- }
506
- function H() {
507
- return V() !== void 0;
508
- }
509
- function U() {
510
- let e = V();
511
- return l(e !== void 0, "Not a static notebook"), e.files;
512
- }
513
- //#endregion
514
- //#region src/core/runtime/runtime.ts
515
- var W = class {
516
- initialHealthyCheck = new m();
517
- config;
518
- lazy;
519
- constructor(e, t = !1) {
520
- this.config = e, this.lazy = t;
521
- try {
522
- new URL(this.config.url);
523
- } catch (e) {
524
- throw Error(`Invalid runtime URL: ${this.config.url}. ${e instanceof Error ? e.message : "Unknown error"}`, { cause: e });
525
- }
526
- this.lazy || this.init();
527
- }
528
- get isLazy() {
529
- return this.lazy;
530
- }
531
- get httpURL() {
532
- return new URL(this.config.url);
533
- }
534
- get isSameOrigin() {
535
- return this.httpURL.origin === window.location.origin;
536
- }
537
- get isServerless() {
538
- return p() || c() || H();
539
- }
540
- formatHttpURL({ path: e = "", searchParams: t, restrictToKnownQueryParams: n = !0 }) {
541
- let r = this.httpURL, i = new URLSearchParams(window.location.search);
542
- if (t) for (let [e, n] of t.entries()) r.searchParams.set(e, n);
543
- for (let [e, t] of i.entries()) n && !Object.values(s).includes(e) || r.searchParams.set(e, t);
544
- return r.pathname = `${r.pathname.replace(/\/$/, "")}/${e.replace(/^\//, "")}`, r.hash = "", r;
545
- }
546
- appendCrossOriginAuth(e) {
547
- return !this.isSameOrigin && this.config.authToken && e.searchParams.set(s.accessToken, this.config.authToken), e;
548
- }
549
- formatNavigableHttpURL(e, t) {
550
- let n = this.formatHttpURL({
551
- path: e,
552
- searchParams: t
553
- });
554
- return n.searchParams.delete(s.accessToken), this.appendCrossOriginAuth(n);
555
- }
556
- formatWsURL(e, t) {
557
- let n = this.formatHttpURL({
558
- path: e,
559
- searchParams: t,
560
- restrictToKnownQueryParams: !1
561
- });
562
- return G(this.appendCrossOriginAuth(n).toString());
563
- }
564
- getSessionSearchParams(e) {
565
- let t = new URL(this.config.url), n = new URLSearchParams(t.search);
566
- return new URLSearchParams(window.location.search).forEach((e, t) => {
567
- n.has(t) || n.set(t, e);
568
- }), n.set(s.sessionId, e), n;
569
- }
570
- getWsURL(e) {
571
- return this.formatWsURL("/ws", this.getSessionSearchParams(e));
572
- }
573
- getSseURL(e) {
574
- let t = this.formatHttpURL({
575
- path: "/sse",
576
- searchParams: this.getSessionSearchParams(e),
577
- restrictToKnownQueryParams: !1
578
- });
579
- return t.searchParams.delete(s.accessToken), t;
580
- }
581
- getWsSyncURL(e) {
582
- return this.formatWsURL("/ws_sync", this.getSessionSearchParams(e));
583
- }
584
- getTerminalWsURL(e) {
585
- let t = this.formatWsURL("/terminal/ws");
586
- return e && (t.searchParams.set("rows", String(e.rows)), t.searchParams.set("cols", String(e.cols))), t;
587
- }
588
- getLSPURL(e) {
589
- if (e === "copilot") {
590
- let t = this.formatWsURL(`/lsp/${e}`), n = t.searchParams.get(s.accessToken);
591
- return t.search = "", n && t.searchParams.set(s.accessToken, n), t;
592
- }
593
- return this.formatWsURL(`/lsp/${e}`);
594
- }
595
- getAiURL(e) {
596
- return this.formatHttpURL({ path: `/api/ai/${e}` });
597
- }
598
- healthURL() {
599
- return this.formatHttpURL({ path: "/health" });
600
- }
601
- async fetchHealth() {
602
- try {
603
- return await fetch(this.healthURL().toString());
604
- } catch (e) {
605
- return t.error(`Failed to check health: ${e instanceof Error ? e.message : "Unknown error"}`, { cause: e }), null;
606
- }
607
- }
608
- async reconcileFromHealth() {
609
- if (this.isServerless) return !0;
610
- let e = await this.fetchHealth();
611
- if (!e) return !1;
612
- if (e.redirected) {
613
- t.debug(`Runtime redirected to ${e.url}`);
614
- let n = new URL(e.url);
615
- n.pathname = n.pathname.replace(/\/health$/, ""), this.config.url = n.toString();
616
- }
617
- return e.ok && this.setDOMBaseUri(this.config.url), e.ok;
618
- }
619
- async probeHealth() {
620
- return this.isServerless ? !0 : (await this.fetchHealth())?.ok ?? !1;
621
- }
622
- setDOMBaseUri(e) {
623
- e = e.split("?", 1)[0], e.endsWith("/") || (e += "/");
624
- let t = document.querySelector("base");
625
- t ? t.setAttribute("href", e) : (t = document.createElement("base"), t.setAttribute("href", e), document.head.append(t));
626
- }
627
- async init(e) {
628
- t.debug("Initializing runtime...");
629
- let n = 0;
630
- for (; !await this.reconcileFromHealth();) {
631
- if (n >= 25) {
632
- t.error("Failed to connect after 25 retries"), this.initialHealthyCheck.reject(/* @__PURE__ */ Error("Failed to connect after 25 retries"));
633
- return;
634
- }
635
- if (!e?.disableRetryDelay) {
636
- let e = Math.min(100 * 1.2 ** n, 2e3);
637
- await new Promise((t) => setTimeout(t, e));
638
- }
639
- n++;
640
- }
641
- t.debug("Runtime is healthy"), this.initialHealthyCheck.resolve();
642
- }
643
- async waitForHealthy() {
644
- return this.initialHealthyCheck.promise;
645
- }
646
- headers() {
647
- let e = {
648
- "Marimo-Session-Id": R(),
649
- "Marimo-Server-Token": this.config.serverToken ?? "",
650
- "x-runtime-url": this.httpURL.toString()
651
- };
652
- return this.config.authToken && (e.Authorization = `Bearer ${this.config.authToken}`), e;
653
- }
654
- sessionHeaders() {
655
- return { "Marimo-Session-Id": R() };
656
- }
657
- };
658
- function G(e) {
659
- if (!e.startsWith("http")) {
660
- t.warn(`URL must start with http: ${e}`);
661
- let n = new URL(e);
662
- return n.protocol = "ws", n;
663
- }
664
- return new URL(e.replace(/^http/, "ws"));
665
- }
666
- //#endregion
667
- //#region src/core/runtime/config.ts
668
- function K() {
669
- let e = new URL(document.baseURI);
670
- return e.search = "", e.hash = "", e.toString();
671
- }
672
- var q = {
673
- lazy: !0,
674
- url: K()
675
- }, J = a(q), Y = a((e) => {
676
- let t = e(J);
677
- return new W(t, t.lazy);
678
- });
679
- function X() {
680
- return o.get(Y);
681
- }
682
- function ee(e) {
683
- if (e.startsWith("http")) return new URL(e);
684
- let t = X().httpURL.toString();
685
- return t.startsWith("blob:") && (t = t.replace("blob:", "")), new URL(e, t);
686
- }
687
- //#endregion
688
- //#region ../node_modules/.pnpm/date-fns@4.4.0/node_modules/date-fns/constants.js
689
- var te = 365.2425, ne = 6048e5, re = 864e5, Z = 86400;
690
- Z * 7, Z * te / 12 * 3;
691
- var Q = Symbol.for("constructDateFrom");
692
- //#endregion
693
- //#region ../node_modules/.pnpm/date-fns@4.4.0/node_modules/date-fns/constructFrom.js
694
- function $(e, t) {
695
- return typeof e == "function" ? e(t) : e && typeof e == "object" && Q in e ? e[Q](t) : e instanceof Date ? new e.constructor(t) : new Date(t);
696
- }
697
- //#endregion
698
- //#region ../node_modules/.pnpm/date-fns@4.4.0/node_modules/date-fns/toDate.js
699
- function ie(e, t) {
700
- return $(t || e, e);
701
- }
702
- //#endregion
703
- export { u as S, x as _, ee as a, p as b, H as c, k as d, D as f, b as g, y as h, ne as i, M as l, v as m, $ as n, X as o, g as p, re as r, U as s, ie as t, j as u, _ as v, f as x, m as y };