@vireo-ai/trellis-ui 0.1.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.
Files changed (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/package.json +84 -0
  4. package/src/theme.css +536 -0
  5. package/trellis_ui/static/trellis_ui/css/styles.css +4382 -0
  6. package/trellis_ui/static/trellis_ui/js/esm/chunks/cally-TZl4LpyH.js +1134 -0
  7. package/trellis_ui/static/trellis_ui/js/esm/chunks/cally-TZl4LpyH.js.map +1 -0
  8. package/trellis_ui/static/trellis_ui/js/esm/chunks/dist-DMX3Q5Zu.js +551 -0
  9. package/trellis_ui/static/trellis_ui/js/esm/chunks/dist-DMX3Q5Zu.js.map +1 -0
  10. package/trellis_ui/static/trellis_ui/js/esm/index.js +14181 -0
  11. package/trellis_ui/static/trellis_ui/js/esm/index.js.map +1 -0
  12. package/trellis_ui/static/trellis_ui/js/index.js +10 -0
  13. package/types/bindings/disclosure.d.ts +3 -0
  14. package/types/bindings/index.d.ts +7 -0
  15. package/types/bindings/motion.d.ts +3 -0
  16. package/types/bindings/state.d.ts +3 -0
  17. package/types/bindings/types.d.ts +35 -0
  18. package/types/components/accordion/contract.d.ts +29 -0
  19. package/types/components/accordion/index.d.ts +44 -0
  20. package/types/components/action/contract.d.ts +14 -0
  21. package/types/components/action/index.d.ts +2 -0
  22. package/types/components/app/contract.d.ts +29 -0
  23. package/types/components/app/index.d.ts +2 -0
  24. package/types/components/badge/contract.d.ts +42 -0
  25. package/types/components/badge/index.d.ts +0 -0
  26. package/types/components/box/contract.d.ts +44 -0
  27. package/types/components/box/index.d.ts +2 -0
  28. package/types/components/brand/contract.d.ts +18 -0
  29. package/types/components/brand/index.d.ts +0 -0
  30. package/types/components/button/contract.d.ts +34 -0
  31. package/types/components/button/index.d.ts +3 -0
  32. package/types/components/card/contract.d.ts +56 -0
  33. package/types/components/card/index.d.ts +0 -0
  34. package/types/components/checkbox/contract.d.ts +85 -0
  35. package/types/components/checkbox/index.d.ts +34 -0
  36. package/types/components/combobox/contract.d.ts +57 -0
  37. package/types/components/combobox/index.d.ts +74 -0
  38. package/types/components/common.d.ts +61 -0
  39. package/types/components/date-picker/contract.d.ts +86 -0
  40. package/types/components/date-picker/index.d.ts +70 -0
  41. package/types/components/dropdown/contract.d.ts +18 -0
  42. package/types/components/dropdown/index.d.ts +53 -0
  43. package/types/components/field/contract.d.ts +67 -0
  44. package/types/components/field/index.d.ts +11 -0
  45. package/types/components/file-upload/contract.d.ts +60 -0
  46. package/types/components/file-upload/index.d.ts +35 -0
  47. package/types/components/frame/contract.d.ts +60 -0
  48. package/types/components/frame/index.d.ts +2 -0
  49. package/types/components/heading/contract.d.ts +8 -0
  50. package/types/components/heading/index.d.ts +0 -0
  51. package/types/components/image/contract.d.ts +19 -0
  52. package/types/components/image/index.d.ts +1 -0
  53. package/types/components/index.d.ts +1 -0
  54. package/types/components/input/contract.d.ts +49 -0
  55. package/types/components/input/index.d.ts +17 -0
  56. package/types/components/menu/contract.d.ts +34 -0
  57. package/types/components/menu/index.d.ts +0 -0
  58. package/types/components/modal/contract.d.ts +56 -0
  59. package/types/components/modal/index.d.ts +85 -0
  60. package/types/components/overlay/contract.d.ts +13 -0
  61. package/types/components/overlay/index.d.ts +0 -0
  62. package/types/components/radio/contract.d.ts +55 -0
  63. package/types/components/radio/index.d.ts +28 -0
  64. package/types/components/runtime.d.ts +35 -0
  65. package/types/components/scroll-area/contract.d.ts +23 -0
  66. package/types/components/scroll-area/index.d.ts +68 -0
  67. package/types/components/select/contract.d.ts +90 -0
  68. package/types/components/select/index.d.ts +92 -0
  69. package/types/components/separator/contract.d.ts +7 -0
  70. package/types/components/separator/index.d.ts +0 -0
  71. package/types/components/sidebar/contract.d.ts +66 -0
  72. package/types/components/sidebar/index.d.ts +106 -0
  73. package/types/components/slider/contract.d.ts +56 -0
  74. package/types/components/slider/index.d.ts +40 -0
  75. package/types/components/spacer/index.d.ts +0 -0
  76. package/types/components/stream/index.d.ts +0 -0
  77. package/types/components/switch/contract.d.ts +57 -0
  78. package/types/components/switch/index.d.ts +24 -0
  79. package/types/components/table/contract.d.ts +99 -0
  80. package/types/components/table/index.d.ts +2 -0
  81. package/types/components/tabs/contract.d.ts +25 -0
  82. package/types/components/tabs/index.d.ts +60 -0
  83. package/types/components/text/contract.d.ts +10 -0
  84. package/types/components/text/index.d.ts +0 -0
  85. package/types/components/textarea/contract.d.ts +22 -0
  86. package/types/components/textarea/index.d.ts +0 -0
  87. package/types/components/theme/contract.d.ts +6 -0
  88. package/types/components/theme/index.d.ts +0 -0
  89. package/types/components/toast/contract.d.ts +28 -0
  90. package/types/components/toast/index.d.ts +27 -0
  91. package/types/index.d.ts +46 -0
  92. package/types/motion/animate.d.ts +49 -0
  93. package/types/motion/index.d.ts +24 -0
  94. package/types/motion/presence.d.ts +34 -0
  95. package/types/motion/reduced-motion.d.ts +9 -0
  96. package/types/motion/stream.d.ts +18 -0
  97. package/types/motion/targets.d.ts +31 -0
  98. package/types/motion/view.d.ts +22 -0
  99. package/types/runtime/anchored-popover.d.ts +20 -0
  100. package/types/runtime/class-name.d.ts +9 -0
  101. package/types/runtime/codecs.d.ts +66 -0
  102. package/types/runtime/collection-navigation.d.ts +33 -0
  103. package/types/runtime/confirm.d.ts +18 -0
  104. package/types/runtime/create.d.ts +8 -0
  105. package/types/runtime/dismissable-layer.d.ts +8 -0
  106. package/types/runtime/dom.d.ts +39 -0
  107. package/types/runtime/form-control.d.ts +44 -0
  108. package/types/runtime/index.d.ts +85 -0
  109. package/types/runtime/manifest.d.ts +49 -0
  110. package/types/runtime/option-data.d.ts +5 -0
  111. package/types/runtime/props.d.ts +9 -0
  112. package/types/runtime/resizable.d.ts +36 -0
  113. package/types/runtime/scroll-lock.d.ts +3 -0
  114. package/types/runtime/stream.d.ts +47 -0
  115. package/types/runtime/styles.d.ts +28 -0
  116. package/types/runtime/theme.d.ts +17 -0
@@ -0,0 +1,551 @@
1
+ //#region node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
2
+ var e = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/, t = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/, n = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
3
+ function r(e, t) {
4
+ if (e === "__proto__" || e === "constructor" && t && typeof t == "object" && "prototype" in t) {
5
+ i(e);
6
+ return;
7
+ }
8
+ return t;
9
+ }
10
+ function i(e) {
11
+ console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`);
12
+ }
13
+ function a(i, a = {}) {
14
+ if (typeof i != "string") return i;
15
+ if (i[0] === "\"" && i[i.length - 1] === "\"" && i.indexOf("\\") === -1) return i.slice(1, -1);
16
+ let o = i.trim();
17
+ if (o.length <= 9) switch (o.toLowerCase()) {
18
+ case "true": return !0;
19
+ case "false": return !1;
20
+ case "undefined": return;
21
+ case "null": return null;
22
+ case "nan": return NaN;
23
+ case "infinity": return Infinity;
24
+ case "-infinity": return -Infinity;
25
+ }
26
+ if (!n.test(i)) {
27
+ if (a.strict) throw SyntaxError("[destr] Invalid JSON");
28
+ return i;
29
+ }
30
+ try {
31
+ if (e.test(i) || t.test(i)) {
32
+ if (a.strict) throw Error("[destr] Possible prototype pollution");
33
+ return JSON.parse(i, r);
34
+ }
35
+ return JSON.parse(i);
36
+ } catch (e) {
37
+ if (a.strict) throw e;
38
+ return i;
39
+ }
40
+ }
41
+ String.fromCharCode;
42
+ var o = /#/g, s = /&/g, c = /\//g, l = /=/g, u = /\+/g, d = /%5e/gi, f = /%60/gi, p = /%7c/gi, m = /%20/gi;
43
+ function h(e) {
44
+ return encodeURI("" + e).replace(p, "|");
45
+ }
46
+ function g(e) {
47
+ return h(typeof e == "string" ? e : JSON.stringify(e)).replace(u, "%2B").replace(m, "+").replace(o, "%23").replace(s, "%26").replace(f, "`").replace(d, "^").replace(c, "%2F");
48
+ }
49
+ function _(e) {
50
+ return g(e).replace(l, "%3D");
51
+ }
52
+ function v(e = "") {
53
+ try {
54
+ return decodeURIComponent("" + e);
55
+ } catch {
56
+ return "" + e;
57
+ }
58
+ }
59
+ function y(e) {
60
+ return v(e.replace(u, " "));
61
+ }
62
+ function b(e) {
63
+ return v(e.replace(u, " "));
64
+ }
65
+ function x(e = "") {
66
+ let t = /* @__PURE__ */ Object.create(null);
67
+ e[0] === "?" && (e = e.slice(1));
68
+ for (let n of e.split("&")) {
69
+ let e = n.match(/([^=]+)=?(.*)/) || [];
70
+ if (e.length < 2) continue;
71
+ let r = y(e[1]);
72
+ if (r === "__proto__" || r === "constructor") continue;
73
+ let i = b(e[2] || "");
74
+ t[r] === void 0 ? t[r] = i : Array.isArray(t[r]) ? t[r].push(i) : t[r] = [t[r], i];
75
+ }
76
+ return t;
77
+ }
78
+ function S(e, t) {
79
+ return (typeof t == "number" || typeof t == "boolean") && (t = String(t)), t ? Array.isArray(t) ? t.map((t) => `${_(e)}=${g(t)}`).join("&") : `${_(e)}=${g(t)}` : _(e);
80
+ }
81
+ function ee(e) {
82
+ return Object.keys(e).filter((t) => e[t] !== void 0).map((t) => S(t, e[t])).filter(Boolean).join("&");
83
+ }
84
+ var te = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/, ne = /^[\s\w\0+.-]{2,}:([/\\]{2})?/, re = /^([/\\]\s*){2,}[^/\\]/, ie = /\/$|\/\?|\/#/, C = /^\.?\//;
85
+ function w(e, t = {}) {
86
+ return typeof t == "boolean" && (t = { acceptRelative: t }), t.strict ? te.test(e) : ne.test(e) || (t.acceptRelative ? re.test(e) : !1);
87
+ }
88
+ function T(e = "", t) {
89
+ return t ? ie.test(e) : e.endsWith("/");
90
+ }
91
+ function E(e = "", t) {
92
+ if (!t) return (T(e) ? e.slice(0, -1) : e) || "/";
93
+ if (!T(e, !0)) return e || "/";
94
+ let n = e, r = "", i = e.indexOf("#");
95
+ i !== -1 && (n = e.slice(0, i), r = e.slice(i));
96
+ let [a, ...o] = n.split("?");
97
+ return ((a.endsWith("/") ? a.slice(0, -1) : a) || "/") + (o.length > 0 ? `?${o.join("?")}` : "") + r;
98
+ }
99
+ function D(e = "", t) {
100
+ if (!t) return e.endsWith("/") ? e : e + "/";
101
+ if (T(e, !0)) return e || "/";
102
+ let n = e, r = "", i = e.indexOf("#");
103
+ if (i !== -1 && (n = e.slice(0, i), r = e.slice(i), !n)) return r;
104
+ let [a, ...o] = n.split("?");
105
+ return a + "/" + (o.length > 0 ? `?${o.join("?")}` : "") + r;
106
+ }
107
+ function O(e, t) {
108
+ if (A(t) || w(e)) return e;
109
+ let n = E(t);
110
+ if (e.startsWith(n)) {
111
+ let t = e[n.length];
112
+ if (!t || t === "/" || t === "?") return e;
113
+ }
114
+ return M(n, e);
115
+ }
116
+ function k(e, t) {
117
+ let n = P(e);
118
+ return n.search = ee({
119
+ ...x(n.search),
120
+ ...t
121
+ }), I(n);
122
+ }
123
+ function A(e) {
124
+ return !e || e === "/";
125
+ }
126
+ function j(e) {
127
+ return e && e !== "/";
128
+ }
129
+ function M(e, ...t) {
130
+ let n = e || "";
131
+ for (let e of t.filter((e) => j(e))) if (n) {
132
+ let t = e.replace(C, "");
133
+ n = D(n) + t;
134
+ } else n = e;
135
+ return n;
136
+ }
137
+ var N = Symbol.for("ufo:protocolRelative");
138
+ function P(e = "", t) {
139
+ let n = e.match(/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i);
140
+ if (n) {
141
+ let [, e, t = ""] = n;
142
+ return {
143
+ protocol: e.toLowerCase(),
144
+ pathname: t,
145
+ href: e + t,
146
+ auth: "",
147
+ host: "",
148
+ search: "",
149
+ hash: ""
150
+ };
151
+ }
152
+ if (!w(e, { acceptRelative: !0 })) return t ? P(t + e) : F(e);
153
+ let [, r = "", i, a = ""] = e.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [], [, o = "", s = ""] = a.match(/([^#/?]*)(.*)?/) || [];
154
+ r === "file:" && (s = s.replace(/\/(?=[A-Za-z]:)/, ""));
155
+ let { pathname: c, search: l, hash: u } = F(s);
156
+ return {
157
+ protocol: r.toLowerCase(),
158
+ auth: i ? i.slice(0, Math.max(0, i.length - 1)) : "",
159
+ host: o,
160
+ pathname: c,
161
+ search: l,
162
+ hash: u,
163
+ [N]: !r
164
+ };
165
+ }
166
+ function F(e = "") {
167
+ let [t = "", n = "", r = ""] = (e.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
168
+ return {
169
+ pathname: t,
170
+ search: n,
171
+ hash: r
172
+ };
173
+ }
174
+ function I(e) {
175
+ let t = e.pathname || "", n = e.search ? (e.search.startsWith("?") ? "" : "?") + e.search : "", r = e.hash || "", i = e.auth ? e.auth + "@" : "", a = e.host || "";
176
+ return (e.protocol || e[N] ? (e.protocol || "") + "//" : "") + i + a + t + n + r;
177
+ }
178
+ //#endregion
179
+ //#region node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs
180
+ var L = class extends Error {
181
+ constructor(e, t) {
182
+ super(e, t), this.name = "FetchError", t?.cause && !this.cause && (this.cause = t.cause);
183
+ }
184
+ };
185
+ function R(e) {
186
+ let t = e.error?.message || e.error?.toString() || "", n = e.request?.method || e.options?.method || "GET", r = e.request?.url || String(e.request) || "/", i = new L(`${`[${n}] ${JSON.stringify(r)}`}: ${e.response ? `${e.response.status} ${e.response.statusText}` : "<no response>"}${t ? ` ${t}` : ""}`, e.error ? { cause: e.error } : void 0);
187
+ for (let t of [
188
+ "request",
189
+ "options",
190
+ "response"
191
+ ]) Object.defineProperty(i, t, { get() {
192
+ return e[t];
193
+ } });
194
+ for (let [t, n] of [
195
+ ["data", "_data"],
196
+ ["status", "status"],
197
+ ["statusCode", "status"],
198
+ ["statusText", "statusText"],
199
+ ["statusMessage", "statusText"]
200
+ ]) Object.defineProperty(i, t, { get() {
201
+ return e.response && e.response[n];
202
+ } });
203
+ return i;
204
+ }
205
+ var z = new Set(Object.freeze([
206
+ "PATCH",
207
+ "POST",
208
+ "PUT",
209
+ "DELETE"
210
+ ]));
211
+ function B(e = "GET") {
212
+ return z.has(e.toUpperCase());
213
+ }
214
+ function V(e) {
215
+ if (e === void 0) return !1;
216
+ let t = typeof e;
217
+ return t === "string" || t === "number" || t === "boolean" || t === null ? !0 : t === "object" ? Array.isArray(e) ? !0 : e.buffer || e instanceof FormData || e instanceof URLSearchParams ? !1 : e.constructor && e.constructor.name === "Object" || typeof e.toJSON == "function" : !1;
218
+ }
219
+ var H = /* @__PURE__ */ new Set([
220
+ "image/svg",
221
+ "application/xml",
222
+ "application/xhtml",
223
+ "application/html"
224
+ ]), ae = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
225
+ function U(e = "") {
226
+ if (!e) return "json";
227
+ let t = e.split(";").shift() || "";
228
+ return ae.test(t) ? "json" : t === "text/event-stream" ? "stream" : H.has(t) || t.startsWith("text/") ? "text" : "blob";
229
+ }
230
+ function W(e, t, n, r) {
231
+ let i = G(t?.headers ?? e?.headers, n?.headers, r), a;
232
+ return (n?.query || n?.params || t?.params || t?.query) && (a = {
233
+ ...n?.params,
234
+ ...n?.query,
235
+ ...t?.params,
236
+ ...t?.query
237
+ }), {
238
+ ...n,
239
+ ...t,
240
+ query: a,
241
+ params: a,
242
+ headers: i
243
+ };
244
+ }
245
+ function G(e, t, n) {
246
+ if (!t) return new n(e);
247
+ let r = new n(t);
248
+ if (e) for (let [t, i] of Symbol.iterator in e || Array.isArray(e) ? e : new n(e)) r.set(t, i);
249
+ return r;
250
+ }
251
+ async function K(e, t) {
252
+ if (t) if (Array.isArray(t)) for (let n of t) await n(e);
253
+ else await t(e);
254
+ }
255
+ var q = /* @__PURE__ */ new Set([
256
+ 408,
257
+ 409,
258
+ 425,
259
+ 429,
260
+ 500,
261
+ 502,
262
+ 503,
263
+ 504
264
+ ]), J = /* @__PURE__ */ new Set([
265
+ 101,
266
+ 204,
267
+ 205,
268
+ 304
269
+ ]);
270
+ function Y(e = {}) {
271
+ let { fetch: t = globalThis.fetch, Headers: n = globalThis.Headers, AbortController: r = globalThis.AbortController } = e;
272
+ async function i(e) {
273
+ let t = e.error && e.error.name === "AbortError" && !e.options.timeout || !1;
274
+ if (e.options.retry !== !1 && !t) {
275
+ let t;
276
+ t = typeof e.options.retry == "number" ? e.options.retry : +!B(e.options.method);
277
+ let n = e.response && e.response.status || 500;
278
+ if (t > 0 && (Array.isArray(e.options.retryStatusCodes) ? e.options.retryStatusCodes.includes(n) : q.has(n))) {
279
+ let n = typeof e.options.retryDelay == "function" ? e.options.retryDelay(e) : e.options.retryDelay || 0;
280
+ return n > 0 && await new Promise((e) => setTimeout(e, n)), o(e.request, {
281
+ ...e.options,
282
+ retry: t - 1
283
+ });
284
+ }
285
+ }
286
+ let n = R(e);
287
+ throw Error.captureStackTrace && Error.captureStackTrace(n, o), n;
288
+ }
289
+ let o = async function(o, s = {}) {
290
+ let c = {
291
+ request: o,
292
+ options: W(o, s, e.defaults, n),
293
+ response: void 0,
294
+ error: void 0
295
+ };
296
+ if (c.options.method && (c.options.method = c.options.method.toUpperCase()), c.options.onRequest && (await K(c, c.options.onRequest), c.options.headers instanceof n || (c.options.headers = new n(c.options.headers || {}))), typeof c.request == "string" && (c.options.baseURL && (c.request = O(c.request, c.options.baseURL)), c.options.query && (c.request = k(c.request, c.options.query), delete c.options.query), "query" in c.options && delete c.options.query, "params" in c.options && delete c.options.params), c.options.body && B(c.options.method)) if (V(c.options.body)) {
297
+ let e = c.options.headers.get("content-type");
298
+ typeof c.options.body != "string" && (c.options.body = e === "application/x-www-form-urlencoded" ? new URLSearchParams(c.options.body).toString() : JSON.stringify(c.options.body)), e || c.options.headers.set("content-type", "application/json"), c.options.headers.has("accept") || c.options.headers.set("accept", "application/json");
299
+ } else ("pipeTo" in c.options.body && typeof c.options.body.pipeTo == "function" || typeof c.options.body.pipe == "function") && ("duplex" in c.options || (c.options.duplex = "half"));
300
+ let l;
301
+ if (!c.options.signal && c.options.timeout) {
302
+ let e = new r();
303
+ l = setTimeout(() => {
304
+ let t = /* @__PURE__ */ Error("[TimeoutError]: The operation was aborted due to timeout");
305
+ t.name = "TimeoutError", t.code = 23, e.abort(t);
306
+ }, c.options.timeout), c.options.signal = e.signal;
307
+ }
308
+ try {
309
+ c.response = await t(c.request, c.options);
310
+ } catch (e) {
311
+ return c.error = e, c.options.onRequestError && await K(c, c.options.onRequestError), await i(c);
312
+ } finally {
313
+ l && clearTimeout(l);
314
+ }
315
+ if ((c.response.body || c.response._bodyInit) && !J.has(c.response.status) && c.options.method !== "HEAD") {
316
+ let e = (c.options.parseResponse ? "json" : c.options.responseType) || U(c.response.headers.get("content-type") || "");
317
+ switch (e) {
318
+ case "json": {
319
+ let e = await c.response.text(), t = c.options.parseResponse || a;
320
+ c.response._data = t(e);
321
+ break;
322
+ }
323
+ case "stream":
324
+ c.response._data = c.response.body || c.response._bodyInit;
325
+ break;
326
+ default: c.response._data = await c.response[e]();
327
+ }
328
+ }
329
+ return c.options.onResponse && await K(c, c.options.onResponse), !c.options.ignoreResponseError && c.response.status >= 400 && c.response.status < 600 ? (c.options.onResponseError && await K(c, c.options.onResponseError), await i(c)) : c.response;
330
+ }, s = async function(e, t) {
331
+ return (await o(e, t))._data;
332
+ };
333
+ return s.raw = o, s.native = (...e) => t(...e), s.create = (t = {}, n = {}) => Y({
334
+ ...e,
335
+ ...n,
336
+ defaults: {
337
+ ...e.defaults,
338
+ ...n.defaults,
339
+ ...t
340
+ }
341
+ }), s;
342
+ }
343
+ //#endregion
344
+ //#region node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/index.mjs
345
+ var X = (function() {
346
+ if (typeof globalThis < "u") return globalThis;
347
+ if (typeof self < "u") return self;
348
+ if (typeof window < "u") return window;
349
+ if (typeof global < "u") return global;
350
+ throw Error("unable to locate global object");
351
+ })(), oe = X.fetch ? (...e) => X.fetch(...e) : () => Promise.reject(/* @__PURE__ */ Error("[ofetch] global.fetch is not supported!")), se = X.Headers, ce = X.AbortController, le = Y({
352
+ fetch: oe,
353
+ Headers: se,
354
+ AbortController: ce
355
+ });
356
+ //#endregion
357
+ //#region node_modules/.pnpm/event-source-plus@0.1.15/node_modules/event-source-plus/dist/index.mjs
358
+ async function ue(e) {
359
+ return new Promise((t) => {
360
+ setTimeout(() => {
361
+ t(!0);
362
+ }, e);
363
+ });
364
+ }
365
+ function de(e) {
366
+ let t = [], n = "", r = !1, i, a, o, s, c, l = 0, u = !1;
367
+ function d(e) {
368
+ let r = Z(n);
369
+ i = r.data ?? i, a = r.id ?? a, o = r.event ?? o, s = r.retry ?? s, u && (typeof i == "string" && t.push({
370
+ id: a,
371
+ data: i,
372
+ event: o ?? "message",
373
+ retry: s
374
+ }), a = void 0, i = void 0, o = void 0, s = void 0, l = e), n = "";
375
+ }
376
+ for (let t = 0; t < e.length; t++) {
377
+ let i = e[t];
378
+ switch (i) {
379
+ case "\r":
380
+ u = c === "\n" || c === "\r", r = !0, d(e[t + 1] === "\n" ? t + 2 : t + 1);
381
+ break;
382
+ case "\n":
383
+ if (r) {
384
+ r = !1;
385
+ break;
386
+ }
387
+ u = c === "\n", d(t + 1);
388
+ break;
389
+ default:
390
+ n += i;
391
+ break;
392
+ }
393
+ c = i;
394
+ }
395
+ return {
396
+ messages: t,
397
+ leftoverData: e.substring(l)
398
+ };
399
+ }
400
+ function Z(e) {
401
+ if (e.startsWith("data:")) return { data: e.substring(5).trim() };
402
+ if (e.startsWith("id:")) return { id: e.substring(3).trim() };
403
+ if (e.startsWith("event:")) return { event: e.substring(6).trim() };
404
+ if (e.startsWith("retry:")) {
405
+ let t = Number(e.substring(6).trim());
406
+ if (!Number.isNaN(t)) return Number.isInteger(t) ? { retry: t } : { retry: Math.round(t) };
407
+ }
408
+ return {};
409
+ }
410
+ async function fe(e, t, n) {
411
+ let r = t.getReader(), i;
412
+ for (; !e.signal.aborted && !(i = await r.read()).done;) n(i.value);
413
+ }
414
+ var Q = "text/event-stream", pe = "last-event-id", me = class {
415
+ url;
416
+ lastEventId;
417
+ options;
418
+ retryCount = 0;
419
+ retryInterval = 0;
420
+ maxRetryCount;
421
+ maxRetryInterval;
422
+ fetch;
423
+ timeoutDurationMs;
424
+ timeout;
425
+ constructor(e, t = {}) {
426
+ this.url = e, this.options = t, this.maxRetryCount = t.maxRetryCount, this.maxRetryInterval = t.maxRetryInterval ?? 3e4, this.fetch = Y({ fetch: t.fetch }) ?? le, this.timeoutDurationMs = t.timeout;
427
+ }
428
+ async _handleRetry(e, t) {
429
+ if (this.retryCount++, typeof this.maxRetryCount == "number" && this.retryCount >= this.maxRetryCount) {
430
+ e._emitEvent({
431
+ type: "error",
432
+ reason: "max retry count reached"
433
+ });
434
+ return;
435
+ }
436
+ this.retryInterval === 0 ? this.retryInterval = 2 : this.retryInterval > 0 && (this.retryInterval *= 2, this.retryInterval >= this.maxRetryInterval && (this.retryInterval = this.maxRetryInterval)), await ue(this.retryInterval), e._abortController.abort(), e._abortController = new AbortController(), await this._handleConnection(e, t);
437
+ }
438
+ async _handleConnection(e, t) {
439
+ let n, r = e._abortController.signal;
440
+ if (typeof this.options.headers == "function") {
441
+ let e = this.options.headers();
442
+ n = "then" in e && typeof e.then == "function" ? new Headers(await e.then((e) => e)) : new Headers(e);
443
+ } else n = new Headers(this.options.headers ?? {});
444
+ typeof n.get("accept") != "string" && n.set("accept", Q), typeof this.lastEventId == "string" && n.set(pe, this.lastEventId);
445
+ let i, a = {
446
+ ...this.options,
447
+ method: this.options.method ?? "get",
448
+ responseType: "stream",
449
+ headers: n,
450
+ signal: r,
451
+ retry: !1,
452
+ onRequest: (n) => {
453
+ if (!(e.signal.aborted || r.aborted) && !$(n.error)) return t.onRequest?.(n);
454
+ },
455
+ onRequestError: async (n) => {
456
+ if (!(e.signal.aborted || r.aborted) && !$(n.error)) return t.onRequestError?.(n);
457
+ },
458
+ onResponse: async (e) => (i = e, ge(e, t)),
459
+ onResponseError: async (e) => {
460
+ if (!r.aborted && !$(e.error)) throw e.error === void 0 && (e.error = new L(`${e.response.status} ${e.response.statusText}`)), await t.onResponseError?.(e), e.error;
461
+ }
462
+ };
463
+ try {
464
+ this.timeoutDurationMs && (this.timeout = setTimeout(() => {
465
+ e._emitEvent({
466
+ type: "error",
467
+ reason: `Timeout of ${this.timeoutDurationMs}ms exceeded`
468
+ });
469
+ }, this.timeoutDurationMs));
470
+ let n = await this.fetch.raw(this.url, a);
471
+ clearTimeout(this.timeout), this.timeout = void 0, this.retryCount = 0, this.retryInterval = 0;
472
+ let r = new TextDecoder(), o = "", s = n.body;
473
+ if (!s) {
474
+ let e = /* @__PURE__ */ Error("Expected response body to contain ReadableStream");
475
+ throw i.response = n, i.error = e, await t.onResponseError?.(i), e;
476
+ }
477
+ await fe(e, s, (e) => {
478
+ let n = de(o + r.decode(e, { stream: !0 }));
479
+ o = n.leftoverData ?? "";
480
+ for (let e of n.messages) typeof e.id == "string" && e.id.length > 0 && (this.lastEventId = e.id), t.onMessage(e);
481
+ });
482
+ } catch (n) {
483
+ return r.aborted || e.signal.aborted || $(n) ? void 0 : this._handleRetry(e, t);
484
+ }
485
+ if (!(e.signal.aborted || r.aborted)) {
486
+ if (this.options.retryStrategy === "on-error") {
487
+ e._emitEvent({
488
+ type: "end-of-stream",
489
+ reason: "Stream has ended"
490
+ });
491
+ return;
492
+ }
493
+ return this._handleRetry(e, t);
494
+ }
495
+ }
496
+ listen(e) {
497
+ let t = new he(new AbortController(), (n) => {
498
+ if (n === void 0) {
499
+ this._handleConnection(t, e);
500
+ return;
501
+ }
502
+ this._handleConnection(t, {
503
+ ...e,
504
+ ...n
505
+ });
506
+ });
507
+ return this._handleConnection(t, e), t;
508
+ }
509
+ };
510
+ function $(e) {
511
+ return e instanceof DOMException && e.name === "AbortError";
512
+ }
513
+ var he = class {
514
+ didAbort = !1;
515
+ _abortController;
516
+ _connect;
517
+ constructor(e, t) {
518
+ this._abortController = e ?? new AbortController(), this._connect = t;
519
+ }
520
+ abort(e) {
521
+ this._emitEvent({
522
+ type: "manual",
523
+ reason: e
524
+ });
525
+ }
526
+ reconnect(e) {
527
+ this.didAbort = !1, this._abortController.abort(), this._abortController = new AbortController(), this._connect?.(e);
528
+ }
529
+ _abortHook;
530
+ _emitEvent(e) {
531
+ this.didAbort || (this.didAbort = !0, this._abortHook?.(e), this._abortController.abort(e.reason));
532
+ }
533
+ onAbort(e) {
534
+ this._abortHook = e;
535
+ }
536
+ get signal() {
537
+ return this._abortController.signal;
538
+ }
539
+ };
540
+ async function ge(e, t) {
541
+ if (typeof t.onResponse == "function" && await t.onResponse(e), !e.response.ok) return;
542
+ let n = e.response.headers.get("Content-Type");
543
+ if (typeof n != "string" || !n.includes("text/event-stream")) {
544
+ let r = /* @__PURE__ */ Error(`Expected server to response with Content-Type: '${Q}'. Got '${n}'`);
545
+ throw e.error = r, typeof t.onResponseError == "function" && await t.onResponseError(e), r;
546
+ }
547
+ }
548
+ //#endregion
549
+ export { me as EventSourcePlus };
550
+
551
+ //# sourceMappingURL=dist-DMX3Q5Zu.js.map