@chaibuilder/sdk 2.4.3 → 2.4.5
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/{code-editor-CJfScsxg.js → code-editor-0HrsuGAE.js} +1 -1
- package/dist/{code-editor-Dy-oKXKY.cjs → code-editor-67qfXwGU.cjs} +1 -1
- package/dist/core.cjs +4 -16
- package/dist/core.js +1229 -1315
- package/dist/css-import-modal-CcUf6F6T.js +296 -0
- package/dist/css-import-modal-CdOK43Be.cjs +13 -0
- package/dist/render.cjs +2 -2
- package/dist/render.js +101 -112
- package/dist/{toggle-D0REpYUl.cjs → toggle-BgZfmuec.cjs} +1 -1
- package/dist/{toggle-BKtuoy5e.js → toggle-CyXEVUOu.js} +241 -244
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +1 -1
- package/package.json +6 -5
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { jsx as c, jsxs as g } from "react/jsx-runtime";
|
|
2
|
+
import * as C from "react";
|
|
3
|
+
import { a1 as T, a3 as w, a6 as R, a9 as E, a4 as N, au as I, b1 as D, a5 as A, v as x } from "./toggle-CyXEVUOu.js";
|
|
4
|
+
import * as y from "culori";
|
|
5
|
+
import { getAllRegisteredFonts as P } from "@chaibuilder/runtime";
|
|
6
|
+
import { useTranslation as H } from "react-i18next";
|
|
7
|
+
const f = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${f(o.h)} ${f(o.s * 100)}% ${f(o.l * 100)}%)`, M = (o, e = "hsl", s = "4") => {
|
|
8
|
+
try {
|
|
9
|
+
const r = y.parse(o);
|
|
10
|
+
if (!r) throw new Error("Invalid color input");
|
|
11
|
+
switch (e) {
|
|
12
|
+
case "hsl": {
|
|
13
|
+
const t = y.converter("hsl")(r);
|
|
14
|
+
return s === "4" ? L(t) : `${f(t.h)} ${f(t.s * 100)}% ${f(t.l * 100)}%`;
|
|
15
|
+
}
|
|
16
|
+
case "rgb":
|
|
17
|
+
return y.formatRgb(r);
|
|
18
|
+
case "oklch": {
|
|
19
|
+
const t = y.converter("oklch")(r);
|
|
20
|
+
return `oklch(${f(t.l)} ${f(t.c)} ${f(t.h)})`;
|
|
21
|
+
}
|
|
22
|
+
case "hex":
|
|
23
|
+
return y.formatHex(r);
|
|
24
|
+
default:
|
|
25
|
+
return o;
|
|
26
|
+
}
|
|
27
|
+
} catch (r) {
|
|
28
|
+
return console.error(`Failed to convert color: ${o}`, r), o;
|
|
29
|
+
}
|
|
30
|
+
}, S = (o) => M(o, "hex"), B = (o) => {
|
|
31
|
+
const e = {
|
|
32
|
+
fontFamily: {
|
|
33
|
+
heading: "",
|
|
34
|
+
body: ""
|
|
35
|
+
},
|
|
36
|
+
borderRadius: "",
|
|
37
|
+
colors: {}
|
|
38
|
+
};
|
|
39
|
+
try {
|
|
40
|
+
const s = V(o);
|
|
41
|
+
if (!s.isValid)
|
|
42
|
+
return console.warn("CSS validation failed:", s.error), F();
|
|
43
|
+
const r = v(o, ":root"), t = v(o, ".dark"), a = u(r, "--font-sans") || u(r, "--font-family") || u(r, "--font-heading") || u(r, "--font-body"), n = q(a);
|
|
44
|
+
e.fontFamily = {
|
|
45
|
+
heading: n,
|
|
46
|
+
body: n
|
|
47
|
+
};
|
|
48
|
+
const d = u(r, "--radius") || u(r, "--border-radius") || "0.5rem";
|
|
49
|
+
e.borderRadius = W(d), [
|
|
50
|
+
"background",
|
|
51
|
+
"foreground",
|
|
52
|
+
"primary",
|
|
53
|
+
"primary-foreground",
|
|
54
|
+
"secondary",
|
|
55
|
+
"secondary-foreground",
|
|
56
|
+
"muted",
|
|
57
|
+
"muted-foreground",
|
|
58
|
+
"accent",
|
|
59
|
+
"accent-foreground",
|
|
60
|
+
"destructive",
|
|
61
|
+
"destructive-foreground",
|
|
62
|
+
"border",
|
|
63
|
+
"input",
|
|
64
|
+
"ring",
|
|
65
|
+
"card",
|
|
66
|
+
"card-foreground",
|
|
67
|
+
"popover",
|
|
68
|
+
"popover-foreground"
|
|
69
|
+
].forEach((i) => {
|
|
70
|
+
const h = u(r, `--${i}`), p = u(t, `--${i}`);
|
|
71
|
+
if (h || p) {
|
|
72
|
+
const l = h ? $(h) : "#000000", b = p ? $(p) : l;
|
|
73
|
+
e.colors[i] = [l, b];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
} catch (s) {
|
|
77
|
+
return console.error("Error parsing CSS to ChaiThemeValues:", s), F();
|
|
78
|
+
}
|
|
79
|
+
return e;
|
|
80
|
+
}, v = (o, e) => {
|
|
81
|
+
var r, t;
|
|
82
|
+
const s = new RegExp(`${k(e)}\\s*{([^}]+)}`);
|
|
83
|
+
return ((t = (r = o.match(s)) == null ? void 0 : r[1]) == null ? void 0 : t.trim()) || null;
|
|
84
|
+
}, u = (o, e) => {
|
|
85
|
+
var t;
|
|
86
|
+
if (!o) return null;
|
|
87
|
+
const s = new RegExp(`${k(e)}\\s*:\\s*([^;]+)`), r = o.match(s);
|
|
88
|
+
return ((t = r == null ? void 0 : r[1]) == null ? void 0 : t.trim()) || null;
|
|
89
|
+
}, $ = (o) => {
|
|
90
|
+
if (!o || typeof o != "string")
|
|
91
|
+
return "#000000";
|
|
92
|
+
try {
|
|
93
|
+
const e = o.replace(/var\([^)]+\)/g, "").trim();
|
|
94
|
+
if (!e) return "#000000";
|
|
95
|
+
if (/^[a-z]+$/i.test(e))
|
|
96
|
+
return S(e) || "#000000";
|
|
97
|
+
if (/^#?([0-9A-F]{3,4}|[0-9A-F]{6}|[0-9A-F]{8})$/i.test(e.replace(/#/g, ""))) {
|
|
98
|
+
const r = e.startsWith("#") ? e : `#${e}`;
|
|
99
|
+
return r.length <= 5 ? `#${r.slice(1).split("").map((t) => t + t).join("")}`.slice(0, 7) : r.length > 7 ? r.slice(0, 7) : r;
|
|
100
|
+
}
|
|
101
|
+
if (/^(rgb|hsl|oklch)a?\(/i.test(e))
|
|
102
|
+
return S(e) || "#000000";
|
|
103
|
+
const s = e.match(/^(\d+\.?\d*)\s+(\d+\.?\d*)%\s+(\d+\.?\d*)%$/);
|
|
104
|
+
if (s) {
|
|
105
|
+
const [r, t, a, n] = s, d = `hsl(${t} ${a}% ${n}%)`;
|
|
106
|
+
return S(d) || "#000000";
|
|
107
|
+
}
|
|
108
|
+
if (/^[\d.]+[\s,]+[\d.]+[\s,]+[\d.]+(?:[\s,/]+[\d.]+)?$/.test(e)) {
|
|
109
|
+
const r = e.split(/[\s,]+/).filter(Boolean);
|
|
110
|
+
if (r.length >= 3) {
|
|
111
|
+
const a = r.some((n) => n.includes("%")) ? `hsl(${r[0]} ${r[1]} ${r[2]})` : `rgb(${r[0]}, ${r[1]}, ${r[2]})`;
|
|
112
|
+
return S(a) || "#000000";
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return S(e) || "#000000";
|
|
116
|
+
} catch (e) {
|
|
117
|
+
return console.warn("Failed to process color:", o, e), "#000000";
|
|
118
|
+
}
|
|
119
|
+
}, q = (o) => {
|
|
120
|
+
const e = P();
|
|
121
|
+
if (!o)
|
|
122
|
+
return "ui-sans-serif, system-ui, sans-serif";
|
|
123
|
+
try {
|
|
124
|
+
const r = o.replace(/["']/g, "").trim().split(",")[0].trim(), t = e.find((a) => a.family.toLowerCase() === r.toLowerCase());
|
|
125
|
+
return (t == null ? void 0 : t.family) || "ui-sans-serif, system-ui, sans-serif";
|
|
126
|
+
} catch (s) {
|
|
127
|
+
return console.warn("Error processing font family:", o, s), "ui-sans-serif, system-ui, sans-serif";
|
|
128
|
+
}
|
|
129
|
+
}, W = (o) => {
|
|
130
|
+
if (!o)
|
|
131
|
+
return "8px";
|
|
132
|
+
try {
|
|
133
|
+
const e = o.trim();
|
|
134
|
+
if (e.endsWith("px"))
|
|
135
|
+
return e;
|
|
136
|
+
if (e.endsWith("rem")) {
|
|
137
|
+
const r = parseFloat(e.replace("rem", ""));
|
|
138
|
+
if (!isNaN(r))
|
|
139
|
+
return `${Math.round(r * 16)}px`;
|
|
140
|
+
}
|
|
141
|
+
if (e.endsWith("em")) {
|
|
142
|
+
const r = parseFloat(e.replace("em", ""));
|
|
143
|
+
if (!isNaN(r))
|
|
144
|
+
return `${Math.round(r * 16)}px`;
|
|
145
|
+
}
|
|
146
|
+
const s = parseFloat(e);
|
|
147
|
+
return isNaN(s) ? "8px" : `${Math.round(s)}px`;
|
|
148
|
+
} catch (e) {
|
|
149
|
+
return console.warn("Error converting border radius to px:", o, e), "8px";
|
|
150
|
+
}
|
|
151
|
+
}, F = () => ({
|
|
152
|
+
fontFamily: {
|
|
153
|
+
heading: "ui-sans-serif, system-ui, sans-serif",
|
|
154
|
+
body: "ui-sans-serif, system-ui, sans-serif"
|
|
155
|
+
},
|
|
156
|
+
borderRadius: "8px",
|
|
157
|
+
colors: {
|
|
158
|
+
background: ["#ffffff", "#000000"],
|
|
159
|
+
foreground: ["#000000", "#ffffff"],
|
|
160
|
+
primary: ["#3b82f6", "#60a5fa"],
|
|
161
|
+
"primary-foreground": ["#ffffff", "#1e293b"],
|
|
162
|
+
secondary: ["#f1f5f9", "#334155"],
|
|
163
|
+
"secondary-foreground": ["#0f172a", "#f8fafc"],
|
|
164
|
+
muted: ["#f8fafc", "#1e293b"],
|
|
165
|
+
"muted-foreground": ["#64748b", "#94a3b8"],
|
|
166
|
+
accent: ["#f1f5f9", "#334155"],
|
|
167
|
+
"accent-foreground": ["#0f172a", "#f8fafc"],
|
|
168
|
+
destructive: ["#ef4444", "#f87171"],
|
|
169
|
+
"destructive-foreground": ["#ffffff", "#1e293b"],
|
|
170
|
+
border: ["#e2e8f0", "#475569"],
|
|
171
|
+
input: ["#e2e8f0", "#475569"],
|
|
172
|
+
ring: ["#3b82f6", "#60a5fa"],
|
|
173
|
+
card: ["#ffffff", "#0f172a"],
|
|
174
|
+
"card-foreground": ["#000000", "#f8fafc"],
|
|
175
|
+
popover: ["#ffffff", "#0f172a"],
|
|
176
|
+
"popover-foreground": ["#000000", "#f8fafc"]
|
|
177
|
+
}
|
|
178
|
+
}), k = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), j = (o) => ["background", "foreground", "primary", "primary-foreground"].every(
|
|
179
|
+
(r) => o.colors[r] && Array.isArray(o.colors[r]) && o.colors[r].length >= 2
|
|
180
|
+
) && !!o.fontFamily.heading && !!o.fontFamily.body && !!o.borderRadius, V = (o) => {
|
|
181
|
+
if (!o || typeof o != "string")
|
|
182
|
+
return { isValid: !1, error: "Please enter valid CSS content" };
|
|
183
|
+
const e = o.trim();
|
|
184
|
+
if (!e)
|
|
185
|
+
return { isValid: !1, error: "Please enter CSS content" };
|
|
186
|
+
try {
|
|
187
|
+
if (!e.includes("{") || !e.includes("}"))
|
|
188
|
+
return {
|
|
189
|
+
isValid: !1,
|
|
190
|
+
error: "Invalid CSS format. CSS should contain proper block structure with { }"
|
|
191
|
+
};
|
|
192
|
+
const s = (e.match(/{/g) || []).length, r = (e.match(/}/g) || []).length;
|
|
193
|
+
return s !== r ? {
|
|
194
|
+
isValid: !1,
|
|
195
|
+
error: "Invalid CSS format. Unmatched braces detected"
|
|
196
|
+
} : !e.includes("--") || !e.includes(":") ? {
|
|
197
|
+
isValid: !1,
|
|
198
|
+
error: "Invalid CSS format. CSS should contain variable definitions like --primary: #color"
|
|
199
|
+
} : !e.includes(":root") && !e.includes(".dark") ? {
|
|
200
|
+
isValid: !1,
|
|
201
|
+
error: "CSS should contain at least :root or .dark selector with theme variables"
|
|
202
|
+
} : { isValid: !0 };
|
|
203
|
+
} catch (s) {
|
|
204
|
+
return console.error("CSS validation error:", s), { isValid: !1, error: "Failed to parse CSS. Please check your syntax." };
|
|
205
|
+
}
|
|
206
|
+
}, z = `:root {
|
|
207
|
+
--background: 0 0% 100%;
|
|
208
|
+
--foreground: oklch(0.52 0.13 144.17);
|
|
209
|
+
--primary: #3e2723;
|
|
210
|
+
--primary-foreground: #ffffff;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.dark {
|
|
214
|
+
--background: 222.2 84% 4.9%;
|
|
215
|
+
--foreground: hsl(37.50 36.36% 95.69%);
|
|
216
|
+
--primary: rgb(46, 125, 50);
|
|
217
|
+
--primary-foreground: #ffffff;
|
|
218
|
+
}`, J = ({
|
|
219
|
+
open: o,
|
|
220
|
+
onOpenChange: e,
|
|
221
|
+
onImport: s
|
|
222
|
+
}) => {
|
|
223
|
+
const [r, t] = C.useState(""), [a, n] = C.useState(null), [d, m] = C.useState(!1), { t: i } = H(), h = async () => {
|
|
224
|
+
m(!0), n(null);
|
|
225
|
+
try {
|
|
226
|
+
const l = V(r);
|
|
227
|
+
if (!l.isValid) {
|
|
228
|
+
n(l.error || "Invalid CSS format"), setTimeout(() => {
|
|
229
|
+
n(null);
|
|
230
|
+
}, 5e3), m(!1);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const b = B(r);
|
|
234
|
+
if (!j(b)) {
|
|
235
|
+
n("The CSS doesn't contain enough theme information. Please ensure it includes at least background, foreground, primary, and primary-foreground colors."), setTimeout(() => {
|
|
236
|
+
n(null);
|
|
237
|
+
}, 5e3), m(!1);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
s(b), t(""), n(null), e(!1);
|
|
241
|
+
} catch (l) {
|
|
242
|
+
console.error("Error importing CSS:", l), n("Failed to parse CSS. Please check your syntax and try again."), setTimeout(() => {
|
|
243
|
+
n(null);
|
|
244
|
+
}, 5e3);
|
|
245
|
+
} finally {
|
|
246
|
+
m(!1);
|
|
247
|
+
}
|
|
248
|
+
}, p = () => {
|
|
249
|
+
t(""), n(null), e(!1);
|
|
250
|
+
};
|
|
251
|
+
return /* @__PURE__ */ c(T, { open: o, onOpenChange: e, children: /* @__PURE__ */ g(w, { className: "max-w-2xl max-h-[80vh] flex flex-col", children: [
|
|
252
|
+
/* @__PURE__ */ g(R, { children: [
|
|
253
|
+
/* @__PURE__ */ c(E, { children: i("Import CSS Theme") }),
|
|
254
|
+
/* @__PURE__ */ c(N, { children: i("Paste your CSS variables to import a custom theme. The CSS should contain :root and .dark blocks with CSS custom properties.") })
|
|
255
|
+
] }),
|
|
256
|
+
/* @__PURE__ */ g("div", { className: "flex-1 space-y-4 overflow-hidden", children: [
|
|
257
|
+
/* @__PURE__ */ g("div", { className: "space-y-2", children: [
|
|
258
|
+
/* @__PURE__ */ c(I, { htmlFor: "css-input", children: i("CSS Variables") }),
|
|
259
|
+
/* @__PURE__ */ c(
|
|
260
|
+
D,
|
|
261
|
+
{
|
|
262
|
+
id: "css-input",
|
|
263
|
+
placeholder: z,
|
|
264
|
+
value: r,
|
|
265
|
+
onChange: (l) => t(l.target.value),
|
|
266
|
+
className: "min-h-[300px] font-mono text-sm resize-none",
|
|
267
|
+
disabled: d
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
] }),
|
|
271
|
+
a && /* @__PURE__ */ c("div", { className: "rounded-md border border-red-200 bg-red-50 p-3", children: /* @__PURE__ */ c("p", { className: "text-sm text-red-600", children: a }) })
|
|
272
|
+
] }),
|
|
273
|
+
/* @__PURE__ */ g(A, { className: "gap-2", children: [
|
|
274
|
+
/* @__PURE__ */ c(
|
|
275
|
+
x,
|
|
276
|
+
{
|
|
277
|
+
variant: "outline",
|
|
278
|
+
onClick: p,
|
|
279
|
+
disabled: d,
|
|
280
|
+
children: i("Cancel")
|
|
281
|
+
}
|
|
282
|
+
),
|
|
283
|
+
/* @__PURE__ */ c(
|
|
284
|
+
x,
|
|
285
|
+
{
|
|
286
|
+
onClick: h,
|
|
287
|
+
disabled: !r.trim() || d,
|
|
288
|
+
children: i(d ? "Importing..." : "Import Theme")
|
|
289
|
+
}
|
|
290
|
+
)
|
|
291
|
+
] })
|
|
292
|
+
] }) });
|
|
293
|
+
};
|
|
294
|
+
export {
|
|
295
|
+
J as CssImportModal
|
|
296
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),V=require("react"),l=require("./toggle-BgZfmuec.cjs"),T=require("culori"),w=require("@chaibuilder/runtime"),R=require("react-i18next");function k(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const x=k(V),y=k(T),d=e=>e?e%1===0?e:e.toFixed(4):"0",N=e=>`hsl(${d(e.h)} ${d(e.s*100)}% ${d(e.l*100)}%)`,E=(e,o="hsl",t="4")=>{try{const r=y.parse(e);if(!r)throw new Error("Invalid color input");switch(o){case"hsl":{const s=y.converter("hsl")(r);return t==="4"?N(s):`${d(s.h)} ${d(s.s*100)}% ${d(s.l*100)}%`}case"rgb":return y.formatRgb(r);case"oklch":{const s=y.converter("oklch")(r);return`oklch(${d(s.l)} ${d(s.c)} ${d(s.h)})`}case"hex":return y.formatHex(r);default:return e}}catch(r){return console.error(`Failed to convert color: ${e}`,r),e}},b=e=>E(e,"hex"),I=e=>{const o={fontFamily:{heading:"",body:""},borderRadius:"",colors:{}};try{const t=j(e);if(!t.isValid)return console.warn("CSS validation failed:",t.error),$();const r=C(e,":root"),s=C(e,".dark"),i=m(r,"--font-sans")||m(r,"--font-family")||m(r,"--font-heading")||m(r,"--font-body"),n=D(i);o.fontFamily={heading:n,body:n};const u=m(r,"--radius")||m(r,"--border-radius")||"0.5rem";o.borderRadius=P(u),["background","foreground","primary","primary-foreground","secondary","secondary-foreground","muted","muted-foreground","accent","accent-foreground","destructive","destructive-foreground","border","input","ring","card","card-foreground","popover","popover-foreground"].forEach(c=>{const p=m(r,`--${c}`),g=m(s,`--${c}`);if(p||g){const f=p?v(p):"#000000",S=g?v(g):f;o.colors[c]=[f,S]}})}catch(t){return console.error("Error parsing CSS to ChaiThemeValues:",t),$()}return o},C=(e,o)=>{var r,s;const t=new RegExp(`${F(o)}\\s*{([^}]+)}`);return((s=(r=e.match(t))==null?void 0:r[1])==null?void 0:s.trim())||null},m=(e,o)=>{var s;if(!e)return null;const t=new RegExp(`${F(o)}\\s*:\\s*([^;]+)`),r=e.match(t);return((s=r==null?void 0:r[1])==null?void 0:s.trim())||null},v=e=>{if(!e||typeof e!="string")return"#000000";try{const o=e.replace(/var\([^)]+\)/g,"").trim();if(!o)return"#000000";if(/^[a-z]+$/i.test(o))return b(o)||"#000000";if(/^#?([0-9A-F]{3,4}|[0-9A-F]{6}|[0-9A-F]{8})$/i.test(o.replace(/#/g,""))){const r=o.startsWith("#")?o:`#${o}`;return r.length<=5?`#${r.slice(1).split("").map(s=>s+s).join("")}`.slice(0,7):r.length>7?r.slice(0,7):r}if(/^(rgb|hsl|oklch)a?\(/i.test(o))return b(o)||"#000000";const t=o.match(/^(\d+\.?\d*)\s+(\d+\.?\d*)%\s+(\d+\.?\d*)%$/);if(t){const[r,s,i,n]=t,u=`hsl(${s} ${i}% ${n}%)`;return b(u)||"#000000"}if(/^[\d.]+[\s,]+[\d.]+[\s,]+[\d.]+(?:[\s,/]+[\d.]+)?$/.test(o)){const r=o.split(/[\s,]+/).filter(Boolean);if(r.length>=3){const i=r.some(n=>n.includes("%"))?`hsl(${r[0]} ${r[1]} ${r[2]})`:`rgb(${r[0]}, ${r[1]}, ${r[2]})`;return b(i)||"#000000"}}return b(o)||"#000000"}catch(o){return console.warn("Failed to process color:",e,o),"#000000"}},D=e=>{const o=w.getAllRegisteredFonts();if(!e)return"ui-sans-serif, system-ui, sans-serif";try{const r=e.replace(/["']/g,"").trim().split(",")[0].trim(),s=o.find(i=>i.family.toLowerCase()===r.toLowerCase());return(s==null?void 0:s.family)||"ui-sans-serif, system-ui, sans-serif"}catch(t){return console.warn("Error processing font family:",e,t),"ui-sans-serif, system-ui, sans-serif"}},P=e=>{if(!e)return"8px";try{const o=e.trim();if(o.endsWith("px"))return o;if(o.endsWith("rem")){const r=parseFloat(o.replace("rem",""));if(!isNaN(r))return`${Math.round(r*16)}px`}if(o.endsWith("em")){const r=parseFloat(o.replace("em",""));if(!isNaN(r))return`${Math.round(r*16)}px`}const t=parseFloat(o);return isNaN(t)?"8px":`${Math.round(t)}px`}catch(o){return console.warn("Error converting border radius to px:",e,o),"8px"}},$=()=>({fontFamily:{heading:"ui-sans-serif, system-ui, sans-serif",body:"ui-sans-serif, system-ui, sans-serif"},borderRadius:"8px",colors:{background:["#ffffff","#000000"],foreground:["#000000","#ffffff"],primary:["#3b82f6","#60a5fa"],"primary-foreground":["#ffffff","#1e293b"],secondary:["#f1f5f9","#334155"],"secondary-foreground":["#0f172a","#f8fafc"],muted:["#f8fafc","#1e293b"],"muted-foreground":["#64748b","#94a3b8"],accent:["#f1f5f9","#334155"],"accent-foreground":["#0f172a","#f8fafc"],destructive:["#ef4444","#f87171"],"destructive-foreground":["#ffffff","#1e293b"],border:["#e2e8f0","#475569"],input:["#e2e8f0","#475569"],ring:["#3b82f6","#60a5fa"],card:["#ffffff","#0f172a"],"card-foreground":["#000000","#f8fafc"],popover:["#ffffff","#0f172a"],"popover-foreground":["#000000","#f8fafc"]}}),F=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),q=e=>["background","foreground","primary","primary-foreground"].every(r=>e.colors[r]&&Array.isArray(e.colors[r])&&e.colors[r].length>=2)&&!!e.fontFamily.heading&&!!e.fontFamily.body&&!!e.borderRadius,j=e=>{if(!e||typeof e!="string")return{isValid:!1,error:"Please enter valid CSS content"};const o=e.trim();if(!o)return{isValid:!1,error:"Please enter CSS content"};try{if(!o.includes("{")||!o.includes("}"))return{isValid:!1,error:"Invalid CSS format. CSS should contain proper block structure with { }"};const t=(o.match(/{/g)||[]).length,r=(o.match(/}/g)||[]).length;return t!==r?{isValid:!1,error:"Invalid CSS format. Unmatched braces detected"}:!o.includes("--")||!o.includes(":")?{isValid:!1,error:"Invalid CSS format. CSS should contain variable definitions like --primary: #color"}:!o.includes(":root")&&!o.includes(".dark")?{isValid:!1,error:"CSS should contain at least :root or .dark selector with theme variables"}:{isValid:!0}}catch(t){return console.error("CSS validation error:",t),{isValid:!1,error:"Failed to parse CSS. Please check your syntax."}}},M=`:root {
|
|
2
|
+
--background: 0 0% 100%;
|
|
3
|
+
--foreground: oklch(0.52 0.13 144.17);
|
|
4
|
+
--primary: #3e2723;
|
|
5
|
+
--primary-foreground: #ffffff;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.dark {
|
|
9
|
+
--background: 222.2 84% 4.9%;
|
|
10
|
+
--foreground: hsl(37.50 36.36% 95.69%);
|
|
11
|
+
--primary: rgb(46, 125, 50);
|
|
12
|
+
--primary-foreground: #ffffff;
|
|
13
|
+
}`,A=({open:e,onOpenChange:o,onImport:t})=>{const[r,s]=x.useState(""),[i,n]=x.useState(null),[u,h]=x.useState(!1),{t:c}=R.useTranslation(),p=async()=>{h(!0),n(null);try{const f=j(r);if(!f.isValid){n(f.error||"Invalid CSS format"),setTimeout(()=>{n(null)},5e3),h(!1);return}const S=I(r);if(!q(S)){n("The CSS doesn't contain enough theme information. Please ensure it includes at least background, foreground, primary, and primary-foreground colors."),setTimeout(()=>{n(null)},5e3),h(!1);return}t(S),s(""),n(null),o(!1)}catch(f){console.error("Error importing CSS:",f),n("Failed to parse CSS. Please check your syntax and try again."),setTimeout(()=>{n(null)},5e3)}finally{h(!1)}},g=()=>{s(""),n(null),o(!1)};return a.jsx(l.Dialog,{open:e,onOpenChange:o,children:a.jsxs(l.DialogContent,{className:"max-w-2xl max-h-[80vh] flex flex-col",children:[a.jsxs(l.DialogHeader,{children:[a.jsx(l.DialogTitle,{children:c("Import CSS Theme")}),a.jsx(l.DialogDescription,{children:c("Paste your CSS variables to import a custom theme. The CSS should contain :root and .dark blocks with CSS custom properties.")})]}),a.jsxs("div",{className:"flex-1 space-y-4 overflow-hidden",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(l.Label,{htmlFor:"css-input",children:c("CSS Variables")}),a.jsx(l.Textarea,{id:"css-input",placeholder:M,value:r,onChange:f=>s(f.target.value),className:"min-h-[300px] font-mono text-sm resize-none",disabled:u})]}),i&&a.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-3",children:a.jsx("p",{className:"text-sm text-red-600",children:i})})]}),a.jsxs(l.DialogFooter,{className:"gap-2",children:[a.jsx(l.Button,{variant:"outline",onClick:g,disabled:u,children:c("Cancel")}),a.jsx(l.Button,{onClick:p,disabled:!r.trim()||u,children:c(u?"Importing...":"Import Theme")})]})]})})};exports.CssImportModal=A;
|
package/dist/render.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./plugin-CSgw-f78.cjs"),p=require("./apply-binding-DpBwzIf9.cjs"),t=require("lodash-es"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./plugin-CSgw-f78.cjs"),p=require("./apply-binding-DpBwzIf9.cjs"),t=require("lodash-es"),I=require("@tailwindcss/aspect-ratio"),q=require("@tailwindcss/forms"),$=require("@tailwindcss/typography");require("tailwindcss-animate");const E=require("./get-chai-builder-theme-B1tr_NJB.cjs"),F=require("@mhsdesign/jit-browser-tailwindcss"),L=require("@tailwindcss/container-queries"),m=require("react/jsx-runtime"),u=require("react"),R=require("@chaibuilder/runtime");function D(e,r){const a=e.filter(({_type:i})=>i==="GlobalBlock"||i==="PartialBlock");for(let i=0;i<a.length;i++){const l=a[i],s=t.get(l,"partialBlockId",t.get(l,"globalBlock",""));if(s==="")continue;let n=t.cloneDeep(t.get(r,s,[]));l._parent&&(n==null?void 0:n.length)>0&&(n=n.map(c=>(t.isEmpty(c._parent)&&(c._parent=l._parent),c)));const o=e.indexOf(l);e.splice(o,1,...n)}return e}const j=e=>{if(!e)return[];try{return JSON.parse(M(e)).filter(a=>!a._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function M(e){const r=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(r,a=>{const i=decodeURIComponent(a),l=i.indexOf("public");return l!==-1?i.substring(l+6):i})}async function O(e,r,a=[],i="",l){return await F.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:a,theme:{extend:E.getChaiBuilderTheme(e)},plugins:[q,$,I,L,y.chaiBuilderPlugin],corePlugins:{preflight:l},...i?{prefix:`${i}`}:{}}}).generateStylesFromContent(` ${l?"@tailwind base;":""}
|
|
2
2
|
@tailwind components;
|
|
3
|
-
@tailwind utilities;`,
|
|
3
|
+
@tailwind utilities;`,r)}const A=(e,r,a)=>{const i=JSON.stringify(e).replace(/#styles:([^"]*)/g,(l,s)=>`#styles:${s.replace(/,/g," ")}`.replace(/#styles:/g,""));return O(r,[i],[],"",a)},K=async(e,r=y.defaultThemeOptions,a=!1)=>await A(e,r,a);async function N(e){const r={pageProps:e.pageProps,block:e.block,lang:e.lang,draft:e.draft,inBuilder:!1},a=await e.dataProvider(r);return t.has(a,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,a.$metadata),e.children({...t.omit(a,"$metadata")})}const J=()=>m.jsx("div",{}),V=e=>{const{block:r,lang:a,fallbackLang:i,children:l,externalData:s,blocks:n,draft:o,pageProps:c,dataProviderMetadataCallback:h}=e,d=R.getRegisteredChaiBlock(r._type),f=t.get(d,"component",null),k=t.get(e.repeaterData,"index",-1),b=t.get(e.repeaterData,"dataKey",""),C=a===i?"":a,g=p.applyBindingToBlockProps(p.applyLanguage(r,C,d),s,{index:k,key:b}),w=p.getBlockTagAttributes(r,!1),S=U(n,r._id,p.getBlockRuntimeProps(r._type)),T=t.has(d,"dataProvider")&&t.isFunction(d.dataProvider),_={...g,...w,...S},P={blockProps:{},inBuilder:!1,lang:a||i,..._};if(t.isNull(f))return null;if(T){const v=t.get(d,"suspenseFallback",J);return m.jsx(u.Suspense,{fallback:u.createElement(v),children:m.jsx(N,{lang:a,pageProps:c,block:_,dataProvider:d.dataProvider,...h?{dataProviderMetadataCallback:h}:{},draft:o,children:x=>u.createElement(f,{...P,...x,children:l({_id:r._id,_type:r._type,...t.isArray(g.repeaterItems)?{repeaterItems:p.applyLimit(g.repeaterItems,r),$repeaterItemsKey:g.$repeaterItemsKey}:{}})})})})}return m.jsx(u.Suspense,{children:u.createElement(f,{...P,children:l({_id:r._id,_type:r._type,...t.isArray(g.repeaterItems)?{repeaterItems:p.applyLimit(g.repeaterItems,r),$repeaterItemsKey:g.$repeaterItemsKey}:{}})})})},B=e=>{const{blocks:r,parent:a,repeaterData:i}=e;let l=t.uniqBy(t.filter(r,n=>t.has(n,"_id")&&(t.isEmpty(a)?!n._parent:n._parent===a)),"_id");const s=n=>t.filter(r,o=>o._parent===n).length>0;return t.map(l,n=>n?u.createElement(V,{...e,key:n._id,block:n},({_id:o,_type:c,repeaterItems:h,$repeaterItemsKey:d})=>c==="Repeater"?t.isArray(h)&&h.map((f,k)=>u.createElement(B,{...e,parent:n._id,key:`${t.get(n,"_parent","root")}-${n._id}-${k}`,repeaterData:{index:k,dataKey:d}})):s(o)?u.createElement(B,{...e,parent:n._id,key:`${t.get(n,"_parent","root")}-${n._id}`,repeaterData:i}):null):null)},U=(e,r,a)=>t.isEmpty(a)?{}:Object.entries(a).reduce((i,[l,s])=>{const n=[];let o=t.find(e,{_id:r});for(;o;)n.push(o),o=t.find(e,{_id:o._parent});const c=t.find(n,{_type:s.block});return c&&(i[l]=t.get(c,t.get(s,"prop"),null)),i},{});function W(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const r=e.lang??"en",a=e.fallbackLang??r;return m.jsx(B,{...e,lang:r,fallbackLang:a})}exports.getChaiThemeCssVariables=y.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=y.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=y.getThemeFontsLinkMarkup;exports.applyChaiDataBinding=p.applyChaiDataBinding;exports.RenderChaiBlocks=W;exports.convertToBlocks=j;exports.getMergedPartialBlocks=D;exports.getStylesForBlocks=K;
|
package/dist/render.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { d as F, c as
|
|
2
|
-
import { a as
|
|
3
|
-
import { a as
|
|
4
|
-
import { e as
|
|
5
|
-
import { get as s, cloneDeep as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import { d as F, c as O } from "./plugin-BOcGV_IY.js";
|
|
2
|
+
import { a as ve, b as Se, e as xe } from "./plugin-BOcGV_IY.js";
|
|
3
|
+
import { a as K, b as A, g as M, c as N, d as C } from "./apply-binding-CkrtJykq.js";
|
|
4
|
+
import { e as $e } from "./apply-binding-CkrtJykq.js";
|
|
5
|
+
import { get as s, cloneDeep as J, isEmpty as u, has as b, isFunction as x, omit as E, isNull as j, isArray as _, uniqBy as q, filter as v, map as U, find as y } from "lodash-es";
|
|
6
|
+
import V from "@tailwindcss/aspect-ratio";
|
|
7
|
+
import W from "@tailwindcss/forms";
|
|
8
|
+
import G from "@tailwindcss/typography";
|
|
9
9
|
import "tailwindcss-animate";
|
|
10
|
-
import { g as
|
|
11
|
-
import { createTailwindcss as
|
|
12
|
-
import
|
|
13
|
-
import { jsx as
|
|
14
|
-
import { Suspense as
|
|
15
|
-
import { getRegisteredChaiBlock as
|
|
16
|
-
function
|
|
17
|
-
const a = e.filter(({ _type:
|
|
18
|
-
for (let
|
|
19
|
-
const i = a[
|
|
20
|
-
if (
|
|
21
|
-
let
|
|
22
|
-
i._parent && (
|
|
23
|
-
const
|
|
24
|
-
e.splice(
|
|
10
|
+
import { g as z } from "./get-chai-builder-theme-BarMkcGH.js";
|
|
11
|
+
import { createTailwindcss as H } from "@mhsdesign/jit-browser-tailwindcss";
|
|
12
|
+
import Q from "@tailwindcss/container-queries";
|
|
13
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
14
|
+
import { Suspense as S, createElement as g } from "react";
|
|
15
|
+
import { getRegisteredChaiBlock as X } from "@chaibuilder/runtime";
|
|
16
|
+
function _e(e, t) {
|
|
17
|
+
const a = e.filter(({ _type: n }) => n === "GlobalBlock" || n === "PartialBlock");
|
|
18
|
+
for (let n = 0; n < a.length; n++) {
|
|
19
|
+
const i = a[n], l = s(i, "partialBlockId", s(i, "globalBlock", ""));
|
|
20
|
+
if (l === "") continue;
|
|
21
|
+
let r = J(s(t, l, []));
|
|
22
|
+
i._parent && (r == null ? void 0 : r.length) > 0 && (r = r.map((c) => (u(c._parent) && (c._parent = i._parent), c)));
|
|
23
|
+
const o = e.indexOf(i);
|
|
24
|
+
e.splice(o, 1, ...r);
|
|
25
25
|
}
|
|
26
26
|
return e;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
28
|
+
const Pe = (e) => {
|
|
29
29
|
if (!e) return [];
|
|
30
30
|
try {
|
|
31
|
-
return JSON.parse(
|
|
31
|
+
return JSON.parse(Y(e)).filter((a) => !a._type.startsWith("@chai"));
|
|
32
32
|
} catch {
|
|
33
33
|
return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
function
|
|
36
|
+
function Y(e) {
|
|
37
37
|
const t = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
|
|
38
38
|
return e.replace(t, (a) => {
|
|
39
|
-
const
|
|
40
|
-
return i !== -1 ?
|
|
39
|
+
const n = decodeURIComponent(a), i = n.indexOf("public");
|
|
40
|
+
return i !== -1 ? n.substring(i + 6) : n;
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
async function
|
|
44
|
-
return await
|
|
43
|
+
async function Z(e, t, a = [], n = "", i) {
|
|
44
|
+
return await H({
|
|
45
45
|
tailwindConfig: {
|
|
46
46
|
darkMode: "class",
|
|
47
47
|
safelist: a,
|
|
48
|
-
theme: { extend:
|
|
49
|
-
plugins: [
|
|
48
|
+
theme: { extend: z(e) },
|
|
49
|
+
plugins: [W, G, V, Q, O],
|
|
50
50
|
corePlugins: { preflight: i },
|
|
51
|
-
...
|
|
51
|
+
...n ? { prefix: `${n}` } : {}
|
|
52
52
|
}
|
|
53
53
|
}).generateStylesFromContent(
|
|
54
54
|
` ${i ? "@tailwind base;" : ""}
|
|
@@ -57,68 +57,57 @@ async function te(e, t, a = [], r = "", i) {
|
|
|
57
57
|
t
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
return
|
|
63
|
-
},
|
|
64
|
-
function
|
|
65
|
-
return JSON.stringify({
|
|
66
|
-
blockType: $(e.block, "_id", "_name", "_parent"),
|
|
67
|
-
lang: e.lang
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
async function ne(e) {
|
|
60
|
+
const ee = (e, t, a) => {
|
|
61
|
+
const n = JSON.stringify(e).replace(/#styles:([^"]*)/g, (i, l) => `#styles:${l.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
|
|
62
|
+
return Z(t, [n], [], "", a);
|
|
63
|
+
}, be = async (e, t = F, a = !1) => await ee(e, t, a);
|
|
64
|
+
async function te(e) {
|
|
71
65
|
const t = {
|
|
72
66
|
pageProps: e.pageProps,
|
|
73
67
|
block: e.block,
|
|
74
68
|
lang: e.lang,
|
|
75
69
|
draft: e.draft,
|
|
76
70
|
inBuilder: !1
|
|
77
|
-
}, a =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
_.delete(a);
|
|
81
|
-
}, 5 * 1e3));
|
|
82
|
-
const i = await r;
|
|
83
|
-
return B(i, "$metadata") && I(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, i.$metadata), e.children({
|
|
84
|
-
...$(i, "$metadata")
|
|
71
|
+
}, a = await e.dataProvider(t);
|
|
72
|
+
return b(a, "$metadata") && x(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, a.$metadata), e.children({
|
|
73
|
+
...E(a, "$metadata")
|
|
85
74
|
});
|
|
86
75
|
}
|
|
87
|
-
const
|
|
88
|
-
const { block: t, lang: a, fallbackLang:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
{ index: k, key:
|
|
92
|
-
),
|
|
76
|
+
const ae = () => /* @__PURE__ */ m("div", {}), re = (e) => {
|
|
77
|
+
const { block: t, lang: a, fallbackLang: n, children: i, externalData: l, blocks: r, draft: o, pageProps: c, dataProviderMetadataCallback: f } = e, d = X(t._type), h = s(d, "component", null), k = s(e.repeaterData, "index", -1), I = s(e.repeaterData, "dataKey", ""), p = K(
|
|
78
|
+
A(t, a === n ? "" : a, d),
|
|
79
|
+
l,
|
|
80
|
+
{ index: k, key: I }
|
|
81
|
+
), $ = M(t, !1), T = ne(r, t._id, N(t._type)), L = b(d, "dataProvider") && x(d.dataProvider), B = {
|
|
93
82
|
...p,
|
|
94
|
-
|
|
95
|
-
...
|
|
96
|
-
},
|
|
83
|
+
...$,
|
|
84
|
+
...T
|
|
85
|
+
}, w = {
|
|
97
86
|
blockProps: {},
|
|
98
87
|
inBuilder: !1,
|
|
99
|
-
lang: a ||
|
|
100
|
-
...
|
|
88
|
+
lang: a || n,
|
|
89
|
+
...B
|
|
101
90
|
};
|
|
102
|
-
if (
|
|
103
|
-
if (
|
|
104
|
-
const
|
|
105
|
-
return /* @__PURE__ */
|
|
106
|
-
|
|
91
|
+
if (j(h)) return null;
|
|
92
|
+
if (L) {
|
|
93
|
+
const D = s(d, "suspenseFallback", ae);
|
|
94
|
+
return /* @__PURE__ */ m(S, { fallback: g(D), children: /* @__PURE__ */ m(
|
|
95
|
+
te,
|
|
107
96
|
{
|
|
108
97
|
lang: a,
|
|
109
98
|
pageProps: c,
|
|
110
|
-
block:
|
|
99
|
+
block: B,
|
|
111
100
|
dataProvider: d.dataProvider,
|
|
112
|
-
...
|
|
113
|
-
draft:
|
|
114
|
-
children: (R) =>
|
|
115
|
-
...
|
|
101
|
+
...f ? { dataProviderMetadataCallback: f } : {},
|
|
102
|
+
draft: o,
|
|
103
|
+
children: (R) => g(h, {
|
|
104
|
+
...w,
|
|
116
105
|
...R,
|
|
117
106
|
children: i({
|
|
118
107
|
_id: t._id,
|
|
119
108
|
_type: t._type,
|
|
120
|
-
...
|
|
121
|
-
repeaterItems:
|
|
109
|
+
..._(p.repeaterItems) ? {
|
|
110
|
+
repeaterItems: C(p.repeaterItems, t),
|
|
122
111
|
$repeaterItemsKey: p.$repeaterItemsKey
|
|
123
112
|
} : {}
|
|
124
113
|
})
|
|
@@ -126,64 +115,64 @@ const ie = () => /* @__PURE__ */ f("div", {}), oe = (e) => {
|
|
|
126
115
|
}
|
|
127
116
|
) });
|
|
128
117
|
}
|
|
129
|
-
return /* @__PURE__ */
|
|
130
|
-
...
|
|
118
|
+
return /* @__PURE__ */ m(S, { children: g(h, {
|
|
119
|
+
...w,
|
|
131
120
|
children: i({
|
|
132
121
|
_id: t._id,
|
|
133
122
|
_type: t._type,
|
|
134
|
-
...
|
|
135
|
-
repeaterItems:
|
|
123
|
+
..._(p.repeaterItems) ? {
|
|
124
|
+
repeaterItems: C(p.repeaterItems, t),
|
|
136
125
|
$repeaterItemsKey: p.$repeaterItemsKey
|
|
137
126
|
} : {}
|
|
138
127
|
})
|
|
139
128
|
}) });
|
|
140
|
-
},
|
|
141
|
-
const { blocks: t, parent: a, repeaterData:
|
|
142
|
-
let i =
|
|
143
|
-
|
|
129
|
+
}, P = (e) => {
|
|
130
|
+
const { blocks: t, parent: a, repeaterData: n } = e;
|
|
131
|
+
let i = q(
|
|
132
|
+
v(t, (r) => b(r, "_id") && (u(a) ? !r._parent : r._parent === a)),
|
|
144
133
|
"_id"
|
|
145
134
|
);
|
|
146
|
-
const
|
|
147
|
-
return
|
|
148
|
-
|
|
135
|
+
const l = (r) => v(t, (o) => o._parent === r).length > 0;
|
|
136
|
+
return U(i, (r) => r ? /* @__PURE__ */ g(re, { ...e, key: r._id, block: r }, ({ _id: o, _type: c, repeaterItems: f, $repeaterItemsKey: d }) => c === "Repeater" ? _(f) && f.map((h, k) => /* @__PURE__ */ g(
|
|
137
|
+
P,
|
|
149
138
|
{
|
|
150
139
|
...e,
|
|
151
|
-
parent:
|
|
152
|
-
key: `${s(
|
|
140
|
+
parent: r._id,
|
|
141
|
+
key: `${s(r, "_parent", "root")}-${r._id}-${k}`,
|
|
153
142
|
repeaterData: { index: k, dataKey: d }
|
|
154
143
|
}
|
|
155
|
-
)) : o
|
|
156
|
-
|
|
144
|
+
)) : l(o) ? /* @__PURE__ */ g(
|
|
145
|
+
P,
|
|
157
146
|
{
|
|
158
147
|
...e,
|
|
159
|
-
parent:
|
|
160
|
-
key: `${s(
|
|
161
|
-
repeaterData:
|
|
148
|
+
parent: r._id,
|
|
149
|
+
key: `${s(r, "_parent", "root")}-${r._id}`,
|
|
150
|
+
repeaterData: n
|
|
162
151
|
}
|
|
163
152
|
) : null) : null);
|
|
164
|
-
},
|
|
165
|
-
const
|
|
166
|
-
let
|
|
167
|
-
for (;
|
|
168
|
-
|
|
169
|
-
const c = y(
|
|
170
|
-
return c && (
|
|
153
|
+
}, ne = (e, t, a) => u(a) ? {} : Object.entries(a).reduce((n, [i, l]) => {
|
|
154
|
+
const r = [];
|
|
155
|
+
let o = y(e, { _id: t });
|
|
156
|
+
for (; o; )
|
|
157
|
+
r.push(o), o = y(e, { _id: o._parent });
|
|
158
|
+
const c = y(r, { _type: l.block });
|
|
159
|
+
return c && (n[i] = s(c, s(l, "prop"), null)), n;
|
|
171
160
|
}, {});
|
|
172
|
-
function
|
|
173
|
-
if (
|
|
161
|
+
function Be(e) {
|
|
162
|
+
if (u(e.lang) && !u(e.fallbackLang))
|
|
174
163
|
throw new Error("lang prop is required when fallbackLang is provided");
|
|
175
|
-
if (
|
|
164
|
+
if (u(e.blocks))
|
|
176
165
|
return null;
|
|
177
166
|
const t = e.lang ?? "en", a = e.fallbackLang ?? t;
|
|
178
|
-
return /* @__PURE__ */
|
|
167
|
+
return /* @__PURE__ */ m(P, { ...e, lang: t, fallbackLang: a });
|
|
179
168
|
}
|
|
180
169
|
export {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
170
|
+
Be as RenderChaiBlocks,
|
|
171
|
+
$e as applyChaiDataBinding,
|
|
172
|
+
Pe as convertToBlocks,
|
|
173
|
+
ve as getChaiThemeCssVariables,
|
|
174
|
+
_e as getMergedPartialBlocks,
|
|
175
|
+
be as getStylesForBlocks,
|
|
176
|
+
Se as getThemeFontsCSSImport,
|
|
177
|
+
xe as getThemeFontsLinkMarkup
|
|
189
178
|
};
|