@algorisys/yappydraw 0.8.253

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 (43) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +45 -0
  3. package/chunks/AllPackages-DNX4gUvL.js +6879 -0
  4. package/chunks/BaseConfiguration-iE_YypNt.js +4401 -0
  5. package/chunks/Entities-XwxJEcR3.js +467 -0
  6. package/chunks/Factory--zguTNZ7.js +2768 -0
  7. package/chunks/InputJax-BYq2tqUz.js +42 -0
  8. package/chunks/MathItem-DD5NNBjZ.js +76 -0
  9. package/chunks/Options-BStFr0zv.js +199 -0
  10. package/chunks/PrioritizedList-TjDg4i-s.js +39 -0
  11. package/chunks/Styles-DdTYCumM.js +397 -0
  12. package/chunks/TeXAtom-Bp5xoo7F.js +2175 -0
  13. package/chunks/ai-providers-CycU8sO1.js +229 -0
  14. package/chunks/canva-ai-BREIRXSl.js +285 -0
  15. package/chunks/design-generator-C89SKTqv.js +149 -0
  16. package/chunks/drawing-engine-DLFI-cNg.js +903 -0
  17. package/chunks/drawings-store-C-PoHakg.js +109 -0
  18. package/chunks/ds-operations-D5B9Z5vO.js +253 -0
  19. package/chunks/export-game-DOlM1w0F.js +104 -0
  20. package/chunks/game-runtime-Hn9umSvi.js +346 -0
  21. package/chunks/gifenc.esm-48qFK9lH.js +278 -0
  22. package/chunks/html-DxnOvKy4.js +1694 -0
  23. package/chunks/image-utils-CJQBaGoQ.js +37 -0
  24. package/chunks/index-Bm3Inzn8.js +62744 -0
  25. package/chunks/lengths-DNFHULBn.js +70 -0
  26. package/chunks/liteAdaptor-BZby1Qz2.js +919 -0
  27. package/chunks/lucide-solid-D_6t_rbY.js +35452 -0
  28. package/chunks/markdown-to-slides-_1GIcD8M.js +96 -0
  29. package/chunks/mathjax-CnUrFnFS.js +117 -0
  30. package/chunks/mathjax-D6cR72fZ.js +26 -0
  31. package/chunks/morph-animator-7qX2s9j_.js +25 -0
  32. package/chunks/onboarding-tour-CthiVc3W.js +192 -0
  33. package/chunks/rocket-settings-CU8w9S9I.js +100 -0
  34. package/chunks/search-CnWoMV6A.js +384 -0
  35. package/chunks/slide-generator-BG0Oacui.js +553 -0
  36. package/chunks/svg-BvVc02XL.js +12498 -0
  37. package/chunks/tex-Cfi4Kfun.js +442 -0
  38. package/chunks/tinyfly-engine-Wfa50sVI.js +1804 -0
  39. package/chunks/turntable-ai-Bfq-oSsD.js +120 -0
  40. package/chunks/yappy-NspTXSPk.css +1 -0
  41. package/package.json +21 -0
  42. package/yappy.d.ts +34 -0
  43. package/yappy.js +9 -0
@@ -0,0 +1,96 @@
1
+ import { a5 as _, a6 as w, a7 as C, a3 as M, a8 as L, a2 as x, a4 as A } from "./index-Bm3Inzn8.js";
2
+ function v(r, T) {
3
+ const o = M[T || "minimalist"] || M.minimalist, a = r.split(`
4
+ `), c = [];
5
+ let t = null, u = [];
6
+ const h = () => {
7
+ t && (u.length > 0 && !t.bullets?.length && !t.body && !t.quoteText && (t.body = u.join(`
8
+ `).trim()), u = [], c.push(t), t = null);
9
+ }, n = (e, s = "content") => {
10
+ h(), t = { title: e, type: s };
11
+ };
12
+ for (let e = 0; e < a.length; e++) {
13
+ const i = a[e].trim();
14
+ if (/^---+\s*$/.test(i)) {
15
+ h();
16
+ continue;
17
+ }
18
+ const l = i.match(/^#\s+(.+)$/);
19
+ if (l) {
20
+ c.length === 0 && !t ? n(l[1], "title") : n(l[1]);
21
+ continue;
22
+ }
23
+ const m = i.match(/^##\s+(.+)$/);
24
+ if (m) {
25
+ n(m[1]);
26
+ continue;
27
+ }
28
+ const f = i.match(/^###\s+(.+)$/);
29
+ if (f) {
30
+ t ? u.push(f[1]) : n(f[1]);
31
+ continue;
32
+ }
33
+ const y = i.match(/^>\s*(.+)$/);
34
+ if (y) {
35
+ const E = [y[1]];
36
+ for (; e + 1 < a.length && /^>\s*/.test(a[e + 1].trim()); )
37
+ e++, E.push(a[e].trim().replace(/^>\s*/, ""));
38
+ const k = E.join(" ").trim(), b = k.match(/^(.+?)\s*[—–-]{1,2}\s*(.+)$/);
39
+ t && t.type !== "title" && h(), t || (t = { title: "", type: "quote" }), b ? (t.type = "quote", t.quoteText = b[1].trim(), t.quoteAttribution = b[2].trim()) : (t.type = "quote", t.quoteText = k);
40
+ continue;
41
+ }
42
+ const $ = i.match(/^[-*]\s+(.+)$/);
43
+ if ($) {
44
+ t || n(""), t.bullets || (t.bullets = []), t.bullets.push(d($[1]));
45
+ continue;
46
+ }
47
+ const q = i.match(/^\d+\.\s+(.+)$/);
48
+ if (q) {
49
+ t || n(""), t.bullets || (t.bullets = []), t.bullets.push(d(q[1]));
50
+ continue;
51
+ }
52
+ i !== "" && (t || n(""), u.push(d(i)));
53
+ }
54
+ h(), c.length === 0 && c.push({ title: "Untitled", type: "content", body: r.trim() });
55
+ const S = 2e3, p = [], g = [];
56
+ return c.forEach((e, s) => {
57
+ const i = s * S;
58
+ let l;
59
+ switch (e.type) {
60
+ case "title":
61
+ l = L(e.title, e.body || e.bullets?.[0], o);
62
+ break;
63
+ case "quote":
64
+ l = C(e.quoteText || "", e.quoteAttribution, o);
65
+ break;
66
+ case "closing":
67
+ l = w(e.title, e.body, o);
68
+ break;
69
+ default:
70
+ l = _(e.title, e.bullets, e.body, o);
71
+ break;
72
+ }
73
+ const m = x(l, i, 0);
74
+ p.push(...m), g.push({
75
+ id: A("slide"),
76
+ name: e.title || `Slide ${s + 1}`,
77
+ spatialPosition: { x: i, y: 0 },
78
+ dimensions: { width: 1920, height: 1080 },
79
+ order: s,
80
+ backgroundColor: o.background
81
+ });
82
+ }), {
83
+ version: 4,
84
+ metadata: { name: "Markdown Import", docType: "slides" },
85
+ elements: p,
86
+ layers: [{ id: "default-layer", name: "Layer 1", visible: !0, locked: !1, opacity: 1, order: 0, backgroundColor: "transparent" }],
87
+ slides: g,
88
+ globalSettings: {}
89
+ };
90
+ }
91
+ function d(r) {
92
+ return r.replace(/\*\*(.+?)\*\*/g, "$1").replace(/__(.+?)__/g, "$1").replace(/\*(.+?)\*/g, "$1").replace(/_(.+?)_/g, "$1").replace(/`(.+?)`/g, "$1").replace(/\[(.+?)\]\(.+?\)/g, "$1").trim();
93
+ }
94
+ export {
95
+ v as parseMarkdownToSlides
96
+ };
@@ -0,0 +1,117 @@
1
+ import { r as x } from "./PrioritizedList-TjDg4i-s.js";
2
+ var y = {}, v = {}, _;
3
+ function L() {
4
+ return _ || (_ = 1, Object.defineProperty(v, "__esModule", { value: !0 }), v.VERSION = void 0, v.VERSION = "3.2.1"), v;
5
+ }
6
+ var o = {}, p;
7
+ function O() {
8
+ if (p) return o;
9
+ p = 1;
10
+ var a = o && o.__extends || /* @__PURE__ */ (function() {
11
+ var e = function(t, r) {
12
+ return e = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, u) {
13
+ n.__proto__ = u;
14
+ } || function(n, u) {
15
+ for (var s in u) Object.prototype.hasOwnProperty.call(u, s) && (n[s] = u[s]);
16
+ }, e(t, r);
17
+ };
18
+ return function(t, r) {
19
+ if (typeof r != "function" && r !== null)
20
+ throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
21
+ e(t, r);
22
+ function n() {
23
+ this.constructor = t;
24
+ }
25
+ t.prototype = r === null ? Object.create(r) : (n.prototype = r.prototype, new n());
26
+ };
27
+ })(), c = o && o.__values || function(e) {
28
+ var t = typeof Symbol == "function" && Symbol.iterator, r = t && e[t], n = 0;
29
+ if (r) return r.call(e);
30
+ if (e && typeof e.length == "number") return {
31
+ next: function() {
32
+ return e && n >= e.length && (e = void 0), { value: e && e[n++], done: !e };
33
+ }
34
+ };
35
+ throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
36
+ };
37
+ Object.defineProperty(o, "__esModule", { value: !0 }), o.HandlerList = void 0;
38
+ var f = x(), i = (function(e) {
39
+ a(t, e);
40
+ function t() {
41
+ return e !== null && e.apply(this, arguments) || this;
42
+ }
43
+ return t.prototype.register = function(r) {
44
+ return this.add(r, r.priority);
45
+ }, t.prototype.unregister = function(r) {
46
+ this.remove(r);
47
+ }, t.prototype.handlesDocument = function(r) {
48
+ var n, u;
49
+ try {
50
+ for (var s = c(this), d = s.next(); !d.done; d = s.next()) {
51
+ var R = d.value, h = R.item;
52
+ if (h.handlesDocument(r))
53
+ return h;
54
+ }
55
+ } catch (w) {
56
+ n = { error: w };
57
+ } finally {
58
+ try {
59
+ d && !d.done && (u = s.return) && u.call(s);
60
+ } finally {
61
+ if (n) throw n.error;
62
+ }
63
+ }
64
+ throw new Error("Can't find handler for document");
65
+ }, t.prototype.document = function(r, n) {
66
+ return n === void 0 && (n = null), this.handlesDocument(r).create(r, n);
67
+ }, t;
68
+ })(f.PrioritizedList);
69
+ return o.HandlerList = i, o;
70
+ }
71
+ var l = {}, m;
72
+ function P() {
73
+ if (m) return l;
74
+ m = 1, Object.defineProperty(l, "__esModule", { value: !0 }), l.retryAfter = l.handleRetriesFor = void 0;
75
+ function a(f) {
76
+ return new Promise(function i(e, t) {
77
+ try {
78
+ e(f());
79
+ } catch (r) {
80
+ r.retry && r.retry instanceof Promise ? r.retry.then(function() {
81
+ return i(e, t);
82
+ }).catch(function(n) {
83
+ return t(n);
84
+ }) : r.restart && r.restart.isCallback ? MathJax.Callback.After(function() {
85
+ return i(e, t);
86
+ }, r.restart) : t(r);
87
+ }
88
+ });
89
+ }
90
+ l.handleRetriesFor = a;
91
+ function c(f) {
92
+ var i = new Error("MathJax retry");
93
+ throw i.retry = f, i;
94
+ }
95
+ return l.retryAfter = c, l;
96
+ }
97
+ var j;
98
+ function H() {
99
+ return j || (j = 1, (function(a) {
100
+ Object.defineProperty(a, "__esModule", { value: !0 }), a.mathjax = void 0;
101
+ var c = L(), f = O(), i = P();
102
+ a.mathjax = {
103
+ version: c.VERSION,
104
+ handlers: new f.HandlerList(),
105
+ document: function(e, t) {
106
+ return a.mathjax.handlers.document(e, t);
107
+ },
108
+ handleRetriesFor: i.handleRetriesFor,
109
+ retryAfter: i.retryAfter,
110
+ asyncLoad: null
111
+ };
112
+ })(y)), y;
113
+ }
114
+ export {
115
+ P as a,
116
+ H as r
117
+ };
@@ -0,0 +1,26 @@
1
+ import { g as s } from "./PrioritizedList-TjDg4i-s.js";
2
+ import { r as i } from "./mathjax-CnUrFnFS.js";
3
+ function c(r, n) {
4
+ for (var o = 0; o < n.length; o++) {
5
+ const e = n[o];
6
+ if (typeof e != "string" && !Array.isArray(e)) {
7
+ for (const t in e)
8
+ if (t !== "default" && !(t in r)) {
9
+ const a = Object.getOwnPropertyDescriptor(e, t);
10
+ a && Object.defineProperty(r, t, a.get ? a : {
11
+ enumerable: !0,
12
+ get: () => e[t]
13
+ });
14
+ }
15
+ }
16
+ }
17
+ return Object.freeze(Object.defineProperty(r, Symbol.toStringTag, { value: "Module" }));
18
+ }
19
+ var f = i();
20
+ const m = /* @__PURE__ */ s(f), g = /* @__PURE__ */ c({
21
+ __proto__: null,
22
+ default: m
23
+ }, [f]);
24
+ export {
25
+ g as m
26
+ };
@@ -0,0 +1,25 @@
1
+ import { s as d, a as o, a9 as f } from "./index-Bm3Inzn8.js";
2
+ class p {
3
+ /**
4
+ * Morph the current canvas to match the target DisplayState
5
+ */
6
+ static morphTo(c, t = 800) {
7
+ const a = d.elements, r = c.overrides, n = Object.keys(r), i = a.filter((e) => n.includes(e.id)).map((e) => e.id), m = n.filter((e) => !a.some((s) => s.id === e));
8
+ i.forEach((e) => {
9
+ const s = r[e];
10
+ s && o(e, s, {
11
+ duration: t,
12
+ easing: "easeInOutQuad"
13
+ });
14
+ }), m.forEach((e) => {
15
+ const s = r[e];
16
+ s && (f(e, t), o(e, s, {
17
+ duration: t,
18
+ easing: "easeInOutQuad"
19
+ }));
20
+ });
21
+ }
22
+ }
23
+ export {
24
+ p as MorphAnimator
25
+ };
@@ -0,0 +1,192 @@
1
+ import { h as T, i as it, o as nt, j as st, k as x, s as U, l as h, S as A, m as S, n as g, q as v, F as at, r as lt, v as C } from "./index-Bm3Inzn8.js";
2
+ var ct = /* @__PURE__ */ C("<svg><rect rx=10 fill=black></svg>", !1, !0, !1), ut = /* @__PURE__ */ C("<div class=tour-spotlight-ring>"), dt = /* @__PURE__ */ C('<div class=tour-overlay role=dialog aria-modal=true aria-label="Product tour"><svg class=tour-mask width=100% height=100%><defs><mask id=tour-spotlight><rect width=100% height=100% fill=white></rect></mask></defs><rect width=100% height=100% fill=rgba(0,0,0,0.6) mask=url(#tour-spotlight)></rect></svg><div class=tour-tooltip><div class=tour-tooltip-head><span class=tour-step-count> of </span><button class=tour-skip>Skip tour</button></div><h3 class=tour-title></h3><p class=tour-content></p><div class=tour-nav><button class="tour-btn tour-btn-secondary">Back</button><button class="tour-btn tour-btn-primary"></button></div><div class=tour-dots>'), ht = /* @__PURE__ */ C("<button class=tour-dot>");
3
+ const Q = "yappy:tour:seen", L = [{
4
+ id: "welcome",
5
+ title: "Welcome to YappyDraw 👋",
6
+ content: "A quick tour of the essentials — about a minute. Click Next to explore each area, or Skip anytime. You can replay this later from Help (?).",
7
+ target: ".text-logo",
8
+ position: "bottom"
9
+ }, {
10
+ id: "toolbar",
11
+ title: "Your tools",
12
+ content: "Pick shapes, pen, text, connectors, images and more here. Click a tool — or press its number key — to switch. Drag the handle to move the toolbar.",
13
+ target: ".toolbar-container",
14
+ position: "bottom"
15
+ }, {
16
+ id: "canvas",
17
+ title: "The canvas",
18
+ content: "This is your infinite canvas. Draw or drag to create, click to select, scroll to zoom, and hold Space + drag to pan around.",
19
+ target: ".canvas-drop-zone",
20
+ position: "center"
21
+ }, {
22
+ id: "properties",
23
+ title: "Properties",
24
+ content: "Select anything to fine-tune it here — fill, stroke, size, text, effects, animation and more. Toggle it with Alt+Enter, and dock, float or collapse it like any other panel.",
25
+ // The BUTTON, not the panel: Properties is a dock panel now, so the panel element only
26
+ // exists while it happens to be open — spotlighting it would silently no-op mid-tour.
27
+ target: ".topbar-properties-btn",
28
+ position: "bottom"
29
+ }, {
30
+ id: "utilities",
31
+ title: "Settings & Help",
32
+ content: "Global settings, the Properties toggle, and Help live up here in the top bar. Open Help for keyboard shortcuts and docs — both it and Settings are searchable.",
33
+ target: ".topbar-view-controls",
34
+ position: "bottom"
35
+ }, {
36
+ id: "finish",
37
+ title: "You're all set 🎨",
38
+ content: "That's the tour! Reopen it anytime from Help (?) → “Take the tour”. Have fun creating.",
39
+ target: ".help-btn",
40
+ position: "bottom"
41
+ }], [w, X] = T(!1), [f, $] = T(0), ft = w;
42
+ function pt() {
43
+ $(0), X(!0);
44
+ }
45
+ let Z = !1;
46
+ function tt() {
47
+ Z = !0;
48
+ try {
49
+ localStorage.setItem(Q, "1");
50
+ } catch {
51
+ }
52
+ }
53
+ function V(s = !0) {
54
+ X(!1), s && tt();
55
+ }
56
+ function J() {
57
+ if (Z) return !0;
58
+ try {
59
+ return localStorage.getItem(Q) === "1";
60
+ } catch {
61
+ return !1;
62
+ }
63
+ }
64
+ function gt() {
65
+ J() || U.appMode !== "presentation" && setTimeout(() => {
66
+ J() || U.appMode === "presentation" || (tt(), pt());
67
+ }, 900);
68
+ }
69
+ const m = 340, b = 200, p = 16, mt = () => {
70
+ const [s, P] = T(null), [H, R] = T({
71
+ top: 0,
72
+ left: 0
73
+ }), E = () => L[f()], D = () => L.length, M = () => f() === D() - 1, O = () => f() === 0, z = () => {
74
+ M() ? V(!0) : $((e) => e + 1);
75
+ }, I = () => {
76
+ O() || $((e) => e - 1);
77
+ }, q = () => V(!0), F = (e, l) => ({
78
+ top: Math.max(p, Math.min(e, window.innerHeight - b - p)),
79
+ left: Math.max(p, Math.min(l, window.innerWidth - m - p))
80
+ }), Y = () => {
81
+ const e = E();
82
+ if (!e) return;
83
+ const l = e.target ? document.querySelector(e.target) : null;
84
+ if (!l || e.position === "center") {
85
+ P(l ? l.getBoundingClientRect() : null), R(F(window.innerHeight / 2 - b / 2, window.innerWidth / 2 - m / 2));
86
+ return;
87
+ }
88
+ const r = l.getBoundingClientRect();
89
+ P(r);
90
+ let c = 0, a = 0;
91
+ switch (e.position ?? "bottom") {
92
+ case "top":
93
+ c = r.top - b - p, a = r.left + r.width / 2 - m / 2;
94
+ break;
95
+ case "bottom":
96
+ c = r.bottom + p, a = r.left + r.width / 2 - m / 2;
97
+ break;
98
+ case "left":
99
+ c = r.top + r.height / 2 - b / 2, a = r.left - m - p;
100
+ break;
101
+ case "right":
102
+ c = r.top + r.height / 2 - b / 2, a = r.right + p;
103
+ break;
104
+ }
105
+ R(F(c, a));
106
+ };
107
+ it(() => {
108
+ w() && (f(), requestAnimationFrame(() => requestAnimationFrame(Y)));
109
+ });
110
+ const k = () => {
111
+ w() && Y();
112
+ }, W = (e) => {
113
+ w() && (e.key === "Escape" ? (e.preventDefault(), q()) : e.key === "ArrowRight" || e.key === "Enter" ? (e.preventDefault(), z()) : e.key === "ArrowLeft" && (e.preventDefault(), I()));
114
+ };
115
+ return nt(() => {
116
+ window.addEventListener("resize", k), window.addEventListener("scroll", k, !0), document.addEventListener("keydown", W);
117
+ }), st(() => {
118
+ window.removeEventListener("resize", k), window.removeEventListener("scroll", k, !0), document.removeEventListener("keydown", W);
119
+ }), x(A, {
120
+ get when() {
121
+ return w();
122
+ },
123
+ get children() {
124
+ var e = dt(), l = e.firstChild, r = l.firstChild, c = r.firstChild;
125
+ c.firstChild;
126
+ var a = l.nextSibling, B = a.firstChild, y = B.firstChild, et = y.firstChild, ot = y.nextSibling, G = B.nextSibling, K = G.nextSibling, N = K.nextSibling, _ = N.firstChild, j = _.nextSibling, rt = N.nextSibling;
127
+ return h(c, x(A, {
128
+ get when() {
129
+ return s();
130
+ },
131
+ get children() {
132
+ var o = ct();
133
+ return S((t) => {
134
+ var n = s().left - 6, i = s().top - 6, u = s().width + 12, d = s().height + 12;
135
+ return n !== t.e && g(o, "x", t.e = n), i !== t.t && g(o, "y", t.t = i), u !== t.a && g(o, "width", t.a = u), d !== t.o && g(o, "height", t.o = d), t;
136
+ }, {
137
+ e: void 0,
138
+ t: void 0,
139
+ a: void 0,
140
+ o: void 0
141
+ }), o;
142
+ }
143
+ }), null), h(e, x(A, {
144
+ get when() {
145
+ return s();
146
+ },
147
+ get children() {
148
+ var o = ut();
149
+ return S((t) => {
150
+ var n = `${s().top - 6}px`, i = `${s().left - 6}px`, u = `${s().width + 12}px`, d = `${s().height + 12}px`;
151
+ return n !== t.e && v(o, "top", t.e = n), i !== t.t && v(o, "left", t.t = i), u !== t.a && v(o, "width", t.a = u), d !== t.o && v(o, "height", t.o = d), t;
152
+ }, {
153
+ e: void 0,
154
+ t: void 0,
155
+ a: void 0,
156
+ o: void 0
157
+ }), o;
158
+ }
159
+ }), a), h(y, () => f() + 1, et), h(y, D, null), ot.$$click = q, h(G, () => E()?.title), h(K, () => E()?.content), _.$$click = I, j.$$click = z, h(j, () => M() ? "Get started" : "Next"), h(rt, x(at, {
160
+ each: L,
161
+ children: (o, t) => (() => {
162
+ var n = ht();
163
+ return n.$$click = () => $(t()), S((i) => {
164
+ var u = t() === f(), d = `Go to step ${t() + 1}`;
165
+ return u !== i.e && n.classList.toggle("active", i.e = u), d !== i.t && g(n, "aria-label", i.t = d), i;
166
+ }, {
167
+ e: void 0,
168
+ t: void 0
169
+ }), n;
170
+ })()
171
+ })), S((o) => {
172
+ var t = `${H().top}px`, n = `${H().left}px`, i = O();
173
+ return t !== o.e && v(a, "top", o.e = t), n !== o.t && v(a, "left", o.t = n), i !== o.a && (_.disabled = o.a = i), o;
174
+ }, {
175
+ e: void 0,
176
+ t: void 0,
177
+ a: void 0
178
+ }), e;
179
+ }
180
+ });
181
+ };
182
+ lt(["click"]);
183
+ export {
184
+ mt as OnboardingTour,
185
+ mt as default,
186
+ V as endTour,
187
+ J as hasSeenTour,
188
+ ft as isTourActive,
189
+ gt as maybeAutoStartTour,
190
+ pt as startTour,
191
+ L as tourSteps
192
+ };
@@ -0,0 +1,100 @@
1
+ const i = "yappy:rocket:config";
2
+ function p(e) {
3
+ try {
4
+ return atob(e);
5
+ } catch {
6
+ return e;
7
+ }
8
+ }
9
+ function u() {
10
+ try {
11
+ const e = localStorage.getItem(i);
12
+ if (e) {
13
+ const t = JSON.parse(e);
14
+ return {
15
+ url: t.url || "",
16
+ email: t.email || "",
17
+ password: t.password ? p(t.password) : "",
18
+ appName: t.appName || ""
19
+ };
20
+ }
21
+ } catch {
22
+ }
23
+ return { url: "", email: "", password: "", appName: "" };
24
+ }
25
+ function l() {
26
+ const e = u();
27
+ return !!(e.url && e.email && e.password && e.appName);
28
+ }
29
+ async function m(e) {
30
+ try {
31
+ const t = await fetch(`${e.url.replace(/\/$/, "")}/api/_platform/auth/login`, {
32
+ method: "POST",
33
+ headers: { "Content-Type": "application/json" },
34
+ body: JSON.stringify({ email: e.email, password: e.password })
35
+ });
36
+ if (!t.ok) {
37
+ const s = await t.text().catch(() => "");
38
+ return { success: !1, error: `Login failed (${t.status}): ${s.slice(0, 200)}` };
39
+ }
40
+ const r = await t.json();
41
+ return { success: !0, accessToken: r.data?.access_token || r.access_token };
42
+ } catch (t) {
43
+ return { success: !1, error: `Connection failed: ${t.message}` };
44
+ }
45
+ }
46
+ async function d(e, t) {
47
+ const r = e.url.replace(/\/$/, "");
48
+ try {
49
+ const s = await fetch(`${r}/api/_platform/apps`, {
50
+ headers: { Authorization: `Bearer ${t}` }
51
+ });
52
+ if (s.ok) {
53
+ const o = await s.json(), c = o.data || o;
54
+ if (Array.isArray(c) && c.some((n) => n.name === e.appName))
55
+ return { success: !0 };
56
+ }
57
+ const a = await fetch(`${r}/api/_platform/apps`, {
58
+ method: "POST",
59
+ headers: {
60
+ "Content-Type": "application/json",
61
+ Authorization: `Bearer ${t}`
62
+ },
63
+ body: JSON.stringify({ name: e.appName })
64
+ });
65
+ if (!a.ok) {
66
+ const o = await a.text().catch(() => "");
67
+ return { success: !1, error: `Failed to create app (${a.status}): ${o.slice(0, 200)}` };
68
+ }
69
+ return { success: !0 };
70
+ } catch (s) {
71
+ return { success: !1, error: `App setup failed: ${s.message}` };
72
+ }
73
+ }
74
+ async function f(e, t, r) {
75
+ const s = e.url.replace(/\/$/, "");
76
+ try {
77
+ const a = await fetch(`${s}/api/${encodeURIComponent(e.appName)}/_admin/import`, {
78
+ method: "POST",
79
+ headers: {
80
+ "Content-Type": "application/json",
81
+ Authorization: `Bearer ${t}`
82
+ },
83
+ body: JSON.stringify(r)
84
+ });
85
+ if (!a.ok) {
86
+ const c = await a.text().catch(() => "");
87
+ return { success: !1, error: `Import failed (${a.status}): ${c.slice(0, 200)}` };
88
+ }
89
+ return { success: !0, summary: (await a.json()).data?.summary };
90
+ } catch (a) {
91
+ return { success: !1, error: `Import failed: ${a.message}` };
92
+ }
93
+ }
94
+ export {
95
+ l as hasRocketConfig,
96
+ u as loadRocketConfig,
97
+ d as rocketEnsureApp,
98
+ f as rocketImportSchema,
99
+ m as rocketLogin
100
+ };