@blocklet/pages-kit-inner-components 0.4.141 → 0.4.143

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 (38) hide show
  1. package/lib/.nojekyll +0 -0
  2. package/lib/cjs/add-component.js +398 -0
  3. package/lib/cjs/chunks/array-D-LDfLBW.js +441 -0
  4. package/lib/cjs/chunks/config-string-BMi-8GXv.js +1 -0
  5. package/lib/cjs/chunks/draft-data-C-aBMmuZ.js +1 -0
  6. package/lib/cjs/chunks/home-BJQNqMrM.js +38 -0
  7. package/lib/cjs/chunks/publish-button-3_BAbHTk.js +1 -0
  8. package/lib/cjs/chunks/site-state-W1QFSZu4.js +57 -0
  9. package/lib/cjs/chunks/state-DPSTH2vo.js +1 -0
  10. package/lib/cjs/chunks-map.json +1 -0
  11. package/lib/cjs/components.js +1 -0
  12. package/lib/cjs/home.js +1 -0
  13. package/lib/cjs/locales.js +1 -0
  14. package/lib/cjs/project-html.js +23 -0
  15. package/lib/cjs/resources.js +1 -0
  16. package/lib/cjs/setting.js +11 -0
  17. package/lib/cjs/site-state.js +1 -0
  18. package/lib/cjs/theme.js +239 -0
  19. package/lib/cjs/uploader.js +1 -0
  20. package/lib/es/add-component.js +3017 -0
  21. package/lib/es/chunks/array-BfSgATE1.js +1971 -0
  22. package/lib/es/chunks/config-string-BObBTkZS.js +88 -0
  23. package/lib/es/chunks/draft-data-PScFOAJJ.js +13 -0
  24. package/lib/es/chunks/home-DCFkaVAX.js +533 -0
  25. package/lib/es/chunks/publish-button-DOPF0sFB.js +455 -0
  26. package/lib/es/chunks/site-state-BvVjkzSF.js +1829 -0
  27. package/lib/es/chunks/state-DGyH1TW3.js +456 -0
  28. package/lib/es/chunks-map.json +1 -0
  29. package/lib/es/components.js +22 -0
  30. package/lib/es/home.js +34 -0
  31. package/lib/es/locales.js +976 -0
  32. package/lib/es/project-html.js +220 -0
  33. package/lib/es/resources.js +168 -0
  34. package/lib/es/setting.js +1728 -0
  35. package/lib/es/site-state.js +49 -0
  36. package/lib/es/theme.js +769 -0
  37. package/lib/es/uploader.js +8 -0
  38. package/package.json +7 -7
@@ -0,0 +1,1728 @@
1
+ import { jsx as t, jsxs as O, Fragment as X } from "react/jsx-runtime";
2
+ import { t as ye, g as Te, b as ce, E as ot, n as Ke, f as ve } from "./chunks/state-DGyH1TW3.js";
3
+ import de from "@arcblock/ux/lib/Empty";
4
+ import { useLocaleContext as C } from "@arcblock/ux/lib/Locale/context";
5
+ import { CodeEditor as xe } from "@blocklet/code-editor";
6
+ import nt from "@mui/icons-material/AddRounded";
7
+ import st from "@mui/icons-material/ArrowDownward";
8
+ import ct from "@mui/icons-material/ArrowUpward";
9
+ import dt from "@mui/icons-material/DeleteOutline";
10
+ import { Typography as M, TextField as V, Stack as R, FormLabel as ie, Box as j, TableContainer as at, Paper as Z, Table as Be, TableHead as Fe, TableRow as le, TableCell as oe, TableBody as Je, Button as E, IconButton as ae, InputAdornment as ge, alpha as ue, Tooltip as G, buttonClasses as ut, Dialog as Me, Autocomplete as $e, FormControlLabel as pt, Switch as mt, MenuItem as pe, DialogTitle as ft, DialogContent as ht, DialogActions as bt, Collapse as yt, Divider as vt, Popper as xt } from "@mui/material";
11
+ import A from "lodash/sortBy";
12
+ import { useCallback as D, useMemo as ne, useRef as F, useId as gt, useEffect as $, useState as Q } from "react";
13
+ import { useUpdate as _e } from "react-use";
14
+ import { ColorItem as Pt, ConfigColorDialog as wt } from "@blocklet/pages-kit/builtin/color-picker";
15
+ import { C as kt } from "./chunks/config-string-BObBTkZS.js";
16
+ import Pe from "lodash/isEmpty";
17
+ import He from "lodash/set";
18
+ import * as me from "yaml";
19
+ import { UploaderButton as Ye, UploaderProvider as we, useUploader as It, getImageSize as St, getVideoSize as Ot } from "@blocklet/pages-kit/builtin/uploader";
20
+ import jt from "lodash/cloneDeep";
21
+ import fe from "@arcblock/ux/lib/Toast";
22
+ import { CustomComponentRenderer as qe, transpileAndLoadScript as Rt, getPropertiesFromCode as zt } from "@blocklet/pages-kit/components";
23
+ import { parsePropertyValue as Nt } from "@blocklet/pages-kit/utils/property";
24
+ import { unstable_useNumberInput as Vt, ClickAwayListener as Ct } from "@mui/base";
25
+ import { VisibilityOffRounded as Dt, VisibilityRounded as Et, DeleteOutlineRounded as At, DragIndicatorRounded as Tt, TranslateRounded as Le, AddRounded as Ge, InfoRounded as Qe, StarRounded as Ut, SettingsRounded as Xe } from "@mui/icons-material";
26
+ import { getYjsValue as ee } from "@syncedstore/core";
27
+ import { useUpdate as Wt, useReactive as Kt } from "ahooks";
28
+ import Bt from "lodash/assign";
29
+ import Ft from "lodash/get";
30
+ import Jt from "lodash/has";
31
+ import Mt from "lodash/isEqual";
32
+ import se from "lodash/isNil";
33
+ import $t from "lodash/isObject";
34
+ import _t from "lodash/keyBy";
35
+ import Ht from "lodash/omit";
36
+ import Yt from "lodash/pick";
37
+ import qt from "lodash/reduce";
38
+ import { usePopupState as ke, bindTrigger as Ie, bindDialog as Ze, bindPopper as Lt } from "material-ui-popup-state/hooks";
39
+ import { ErrorBoundary as Gt } from "react-error-boundary";
40
+ import { cx as Qt } from "@emotion/css";
41
+ import { useDrop as et, useDrag as Xt } from "react-dnd";
42
+ function Zt({
43
+ onClick: e,
44
+ disabled: r,
45
+ sx: i,
46
+ ...l
47
+ }) {
48
+ return /* @__PURE__ */ t(ae, { size: "small", color: "warning", variant: "outlined", disabled: r, onClick: e, ...l, children: /* @__PURE__ */ t(dt, { fontSize: "small" }) });
49
+ }
50
+ function er({
51
+ onClick: e,
52
+ disabled: r,
53
+ sx: i,
54
+ ...l
55
+ }) {
56
+ return /* @__PURE__ */ t(ae, { size: "small", color: "primary", disabled: r, onClick: e, ...l, children: /* @__PURE__ */ t(ct, { fontSize: "small" }) });
57
+ }
58
+ function tr({
59
+ onClick: e,
60
+ disabled: r,
61
+ sx: i,
62
+ ...l
63
+ }) {
64
+ return /* @__PURE__ */ t(ae, { size: "small", color: "primary", disabled: r, onClick: e, ...l, children: /* @__PURE__ */ t(st, { fontSize: "small" }) });
65
+ }
66
+ function rr({
67
+ label: e,
68
+ value: r,
69
+ onChange: i,
70
+ disabled: l = !1,
71
+ itemLabel: u = "",
72
+ emptyHeight: y = 40,
73
+ property: a,
74
+ renderItem: x,
75
+ ...g
76
+ }) {
77
+ const { t: b, locale: k } = C(), v = _e(), o = D(
78
+ (p) => {
79
+ i(ye(p, a.type));
80
+ },
81
+ [i, a.type]
82
+ ), n = ne(() => Array.isArray(r) ? r : [], [r]), s = D(() => {
83
+ const p = [...n, ""];
84
+ o(p), v();
85
+ }, [n, o, v]), d = D(() => {
86
+ if (!a || !a.subProperties)
87
+ return s();
88
+ const p = {};
89
+ A(Object.values(a.subProperties), "index").forEach(({ data: N }) => {
90
+ var U, W;
91
+ if (!N.key) return;
92
+ const T = ((W = (U = N.locales) == null ? void 0 : U[k]) == null ? void 0 : W.defaultValue) ?? "";
93
+ p[N.key] = T;
94
+ });
95
+ const z = [...n, p];
96
+ o(z), v();
97
+ }, [n, o, v, a, k, s]), m = D(
98
+ (p) => {
99
+ try {
100
+ const I = JSON.parse(p);
101
+ Array.isArray(I) ? o(I) : console.error("JSON解析结果不是数组");
102
+ } catch (I) {
103
+ console.error("JSON解析错误:", I);
104
+ }
105
+ },
106
+ [o]
107
+ ), w = D(
108
+ (p) => {
109
+ const I = n.filter((z, N) => N !== p);
110
+ o(I), v();
111
+ },
112
+ [n, o, v]
113
+ ), c = D(
114
+ (p) => {
115
+ if (p <= 0) return;
116
+ const I = [...n], z = I[p];
117
+ I[p] = I[p - 1], I[p - 1] = z, o(I), v();
118
+ },
119
+ [n, o, v]
120
+ ), h = D(
121
+ (p) => {
122
+ if (p >= n.length - 1) return;
123
+ const I = [...n], z = I[p];
124
+ I[p] = I[p + 1], I[p + 1] = z, o(I), v();
125
+ },
126
+ [n, o, v]
127
+ ), f = D(
128
+ (p, I) => {
129
+ const z = [...n];
130
+ z[p] = I, o(z);
131
+ },
132
+ [n, o]
133
+ ), P = a && a.subProperties && Object.keys(a.subProperties).length > 0, S = ne(() => [
134
+ {
135
+ field: "index",
136
+ headerName: "#",
137
+ width: 40,
138
+ align: "center",
139
+ renderCell: ({ index: p }) => /* @__PURE__ */ t(
140
+ M,
141
+ {
142
+ variant: "body1",
143
+ sx: {
144
+ bgcolor: "action.hover",
145
+ borderRadius: "50%",
146
+ width: 24,
147
+ height: 24,
148
+ display: "flex",
149
+ alignItems: "center",
150
+ justifyContent: "center",
151
+ color: "text.secondary"
152
+ },
153
+ children: p + 1
154
+ }
155
+ )
156
+ },
157
+ {
158
+ field: "content",
159
+ headerName: "",
160
+ renderCell: ({ row: p, index: I }) => x && P ? x({
161
+ item: p,
162
+ index: I,
163
+ property: a,
164
+ onChange: (z) => f(I, z)
165
+ }) : /* @__PURE__ */ t(
166
+ V,
167
+ {
168
+ fullWidth: !0,
169
+ size: "small",
170
+ disabled: l,
171
+ value: p,
172
+ placeholder: u || `${b("item")} ${I + 1}`,
173
+ onChange: (z) => f(I, z.target.value),
174
+ ...g
175
+ }
176
+ )
177
+ },
178
+ {
179
+ field: "actions",
180
+ headerName: "",
181
+ width: 30,
182
+ // 增加宽度以容纳更多按钮
183
+ align: "center",
184
+ renderCell: ({ index: p }) => /* @__PURE__ */ O(R, { direction: "column", spacing: 0.25, children: [
185
+ /* @__PURE__ */ t(er, { disabled: l || p === 0, onClick: () => c(p) }),
186
+ /* @__PURE__ */ t(
187
+ tr,
188
+ {
189
+ disabled: l || p === n.length - 1,
190
+ onClick: () => h(p)
191
+ }
192
+ ),
193
+ /* @__PURE__ */ t(Zt, { disabled: l, onClick: () => w(p) })
194
+ ] })
195
+ }
196
+ ], [
197
+ x,
198
+ P,
199
+ a,
200
+ f,
201
+ u,
202
+ b,
203
+ l,
204
+ g,
205
+ w,
206
+ c,
207
+ h,
208
+ n.length
209
+ ]);
210
+ return P ? /* @__PURE__ */ O(R, { width: "100%", gap: 1, children: [
211
+ e && /* @__PURE__ */ t(ie, { children: e }),
212
+ n.length > 0 ? /* @__PURE__ */ t(at, { component: Z, variant: "outlined", sx: { borderRadius: 1, mb: 1 }, children: /* @__PURE__ */ O(
213
+ Be,
214
+ {
215
+ size: "small",
216
+ sx: {
217
+ "& .MuiTableCell-root": {
218
+ py: 0.25,
219
+ px: 1,
220
+ whiteSpace: "nowrap"
221
+ },
222
+ "& .MuiTableCell-head": {
223
+ backgroundColor: "action.hover",
224
+ py: 0.25,
225
+ px: 1
226
+ },
227
+ borderCollapse: "collapse"
228
+ },
229
+ children: [
230
+ /* @__PURE__ */ t(Fe, { sx: { display: "none" }, children: /* @__PURE__ */ t(le, { children: S.map((p) => /* @__PURE__ */ t(
231
+ oe,
232
+ {
233
+ width: p.width,
234
+ align: p.align || "left",
235
+ sx: { fontWeight: "bold" },
236
+ children: p.renderHeader ? p.renderHeader() : p.headerName
237
+ },
238
+ p.field
239
+ )) }) }),
240
+ /* @__PURE__ */ t(Je, { children: n.map((p, I, z) => /* @__PURE__ */ t(
241
+ le,
242
+ {
243
+ sx: {
244
+ borderBottom: I < z.length - 1 ? "1px solid" : "none",
245
+ borderColor: "divider",
246
+ "&:hover": {
247
+ backgroundColor: "action.hover"
248
+ }
249
+ },
250
+ children: S.map((N) => /* @__PURE__ */ t(
251
+ oe,
252
+ {
253
+ width: N.width,
254
+ align: N.align || "left",
255
+ sx: {
256
+ borderBottom: "none"
257
+ },
258
+ children: N.renderCell({
259
+ row: p,
260
+ index: I,
261
+ onChange: (T) => f(I, T)
262
+ })
263
+ },
264
+ `${I}-${N.field}`
265
+ ))
266
+ },
267
+ I
268
+ )) })
269
+ ]
270
+ }
271
+ ) }) : /* @__PURE__ */ t(de, { style: { fontSize: 12, height: y }, children: b("maker.properties.arrayEmpty") }),
272
+ /* @__PURE__ */ t(
273
+ E,
274
+ {
275
+ fullWidth: !0,
276
+ size: "small",
277
+ variant: "outlined",
278
+ disabled: l,
279
+ startIcon: /* @__PURE__ */ t(nt, {}),
280
+ onClick: d,
281
+ children: b("maker.properties.addArrayItem")
282
+ }
283
+ )
284
+ ] }) : /* @__PURE__ */ O(R, { width: "100%", gap: 1, children: [
285
+ e && /* @__PURE__ */ t(ie, { children: e }),
286
+ /* @__PURE__ */ t(j, { sx: { border: 1, borderColor: "divider", borderRadius: 1, minHeight: 150 }, children: /* @__PURE__ */ t(
287
+ xe,
288
+ {
289
+ keyId: a.id,
290
+ locale: k,
291
+ language: "json",
292
+ value: JSON.stringify(n, null, 2),
293
+ onChange: (p) => m(p || ""),
294
+ fullScreenOptions: {
295
+ enableEscExit: !0,
296
+ targetContainer: () => document.getElementById("parameters-config-dialog") || null
297
+ }
298
+ },
299
+ a.id
300
+ ) })
301
+ ] });
302
+ }
303
+ function ir({
304
+ value: e,
305
+ onChange: r,
306
+ ...i
307
+ }) {
308
+ const l = F(null);
309
+ return /* @__PURE__ */ O(X, { children: [
310
+ /* @__PURE__ */ t(
311
+ kt,
312
+ {
313
+ ...i,
314
+ value: e,
315
+ onChange: r,
316
+ InputProps: {
317
+ endAdornment: /* @__PURE__ */ t(ge, { position: "end", children: /* @__PURE__ */ t(
318
+ Pt,
319
+ {
320
+ color: e ?? "",
321
+ style: { width: "1.5rem", height: "1.5rem", padding: 0 },
322
+ onClick: () => {
323
+ var u;
324
+ (u = l.current) == null || u.open({ value: e ?? "" });
325
+ }
326
+ }
327
+ ) })
328
+ }
329
+ }
330
+ ),
331
+ /* @__PURE__ */ t(
332
+ wt,
333
+ {
334
+ ref: l,
335
+ onSave: ({ value: u }, y) => {
336
+ r(u), y();
337
+ }
338
+ }
339
+ )
340
+ ] });
341
+ }
342
+ function lr({
343
+ label: e,
344
+ value: r,
345
+ onChange: i,
346
+ property: l,
347
+ component: u,
348
+ defaultLocale: y,
349
+ allComponents: a,
350
+ PropertyValueField: x,
351
+ onUpload: g
352
+ }) {
353
+ const { locale: b } = C(), k = F(null);
354
+ if (!Pe(l.subProperties)) {
355
+ const o = A(Object.values(l.subProperties || {}), "index").filter(
356
+ (n) => n.data.visible !== !1 && n.data.key
357
+ );
358
+ return /* @__PURE__ */ O(R, { width: "100%", children: [
359
+ /* @__PURE__ */ t(ie, { sx: { px: 0.25, py: 0.5 }, children: e }),
360
+ /* @__PURE__ */ t(j, { children: /* @__PURE__ */ t(j, { sx: { position: "relative" }, children: o.map((n, s) => {
361
+ const { data: d } = n, m = d.key ?? d.id, w = s === o.length - 1;
362
+ let c = null;
363
+ try {
364
+ r && typeof r == "object" ? c = r[m] : typeof r == "string" && (c = (l.type === "yaml" ? me.parse(r || "") : JSON.parse(r || "{}"))[m]);
365
+ } catch {
366
+ }
367
+ c == null && (d.locales && b && d.locales[b] ? c = d.locales[b].defaultValue : d.locales && y && d.locales[y] && (c = d.locales[y].defaultValue));
368
+ const h = (P) => {
369
+ try {
370
+ let S = {};
371
+ if (typeof r == "string")
372
+ try {
373
+ S = l.type === "yaml" ? me.parse(r || "") : JSON.parse(r || "{}");
374
+ } catch {
375
+ }
376
+ else typeof r == "object" && r !== null && (S = { ...r });
377
+ He(S, m, P);
378
+ const p = ye(S, l.type);
379
+ i == null || i(p);
380
+ } catch (S) {
381
+ console.error("Error updating property:", S);
382
+ }
383
+ }, f = 8;
384
+ return /* @__PURE__ */ O(
385
+ j,
386
+ {
387
+ sx: {
388
+ mb: w ? 0 : 1,
389
+ // 底部边距,最后一项不需要
390
+ display: "flex",
391
+ flexDirection: "row"
392
+ },
393
+ children: [
394
+ /* @__PURE__ */ O(
395
+ j,
396
+ {
397
+ sx: {
398
+ position: "relative",
399
+ width: 24,
400
+ flexShrink: 0
401
+ },
402
+ children: [
403
+ /* @__PURE__ */ t(
404
+ j,
405
+ {
406
+ sx: {
407
+ position: "absolute",
408
+ left: f,
409
+ top: 0,
410
+ height: 16,
411
+ // 连接到字段中点的高度
412
+ width: 0,
413
+ borderLeft: "1px dashed",
414
+ borderColor: "divider"
415
+ }
416
+ }
417
+ ),
418
+ /* @__PURE__ */ t(
419
+ j,
420
+ {
421
+ sx: {
422
+ position: "absolute",
423
+ left: f,
424
+ top: 16,
425
+ // 连接到字段中点
426
+ width: 12,
427
+ height: 0,
428
+ borderTop: "1px dashed",
429
+ borderColor: "divider"
430
+ }
431
+ }
432
+ ),
433
+ !w && /* @__PURE__ */ t(
434
+ j,
435
+ {
436
+ sx: {
437
+ position: "absolute",
438
+ left: f,
439
+ top: 16,
440
+ // 从当前项中点
441
+ bottom: -8,
442
+ // 延伸到下一项
443
+ width: 0,
444
+ borderLeft: "1px dashed",
445
+ borderColor: "divider"
446
+ }
447
+ }
448
+ )
449
+ ]
450
+ }
451
+ ),
452
+ /* @__PURE__ */ t(j, { sx: { flexGrow: 1 }, children: /* @__PURE__ */ t(
453
+ x,
454
+ {
455
+ component: u,
456
+ property: d,
457
+ value: c,
458
+ onChange: h,
459
+ size: "small",
460
+ fullWidth: !0,
461
+ defaultLocale: y,
462
+ allComponents: a
463
+ }
464
+ ) })
465
+ ]
466
+ },
467
+ d.id
468
+ );
469
+ }) }) })
470
+ ] });
471
+ }
472
+ return /* @__PURE__ */ t(R, { width: "100%", gap: 2, children: /* @__PURE__ */ O(
473
+ R,
474
+ {
475
+ sx: {
476
+ width: "100%",
477
+ position: "relative",
478
+ pt: 1,
479
+ pb: "6px",
480
+ px: "1px",
481
+ minHeight: 50,
482
+ ".monaco-editor,.overflow-guard": { borderRadius: 1 }
483
+ },
484
+ children: [
485
+ /* @__PURE__ */ t(
486
+ ie,
487
+ {
488
+ sx: {
489
+ position: "absolute",
490
+ left: 0,
491
+ top: 0,
492
+ transform: "translate(0px, -7px) scale(0.75)"
493
+ },
494
+ children: e
495
+ }
496
+ ),
497
+ /* @__PURE__ */ t(
498
+ xe,
499
+ {
500
+ keyId: l.id,
501
+ locale: b,
502
+ language: l.type === "yaml" ? "yaml" : "json",
503
+ value: typeof r == "string" ? r : "",
504
+ onChange: (o) => {
505
+ i == null || i(o);
506
+ },
507
+ onUpload: (o) => {
508
+ k.current = o, g && g(o);
509
+ },
510
+ fullScreenOptions: {
511
+ enableEscExit: !0,
512
+ targetContainer: () => document.getElementById("parameters-config-dialog") || null
513
+ }
514
+ },
515
+ l.id
516
+ ),
517
+ /* @__PURE__ */ t(
518
+ j,
519
+ {
520
+ component: "fieldset",
521
+ sx: {
522
+ pointerEvents: "none",
523
+ position: "absolute",
524
+ left: 0,
525
+ top: -5,
526
+ width: "100%",
527
+ height: "100%",
528
+ border: 1,
529
+ borderColor: "rgba(0, 0, 0, 0.23)",
530
+ borderRadius: 1,
531
+ px: 1,
532
+ py: 0
533
+ },
534
+ children: /* @__PURE__ */ t(j, { component: "legend", sx: { fontSize: "0.75em" }, children: /* @__PURE__ */ t(j, { component: "span", sx: { opacity: 0 }, children: e }) })
535
+ }
536
+ )
537
+ ]
538
+ }
539
+ ) });
540
+ }
541
+ const or = ["string", "multiline", "json", "yaml", "url", "component", "custom"];
542
+ function Ue(e) {
543
+ return e.type ? !or.includes(e.type) : !1;
544
+ }
545
+ function tt({
546
+ disabled: e,
547
+ list: r,
548
+ renderItem: i,
549
+ ...l
550
+ }) {
551
+ const u = F(null), y = gt(), a = Wt(), x = A(Object.entries(r), (n) => n[1].index).map((n) => n[0]), g = F(x), b = D(
552
+ (n) => {
553
+ g.current = n, a();
554
+ },
555
+ [a]
556
+ ), k = D(
557
+ ({ index: n }, { index: s }) => {
558
+ const d = [...g.current];
559
+ d.splice(s, 0, ...d.splice(n, 1)), b(d);
560
+ },
561
+ [b]
562
+ );
563
+ $(() => {
564
+ b(x);
565
+ }, [x.join("-")]);
566
+ const [{ isOver: v }, o] = et({
567
+ accept: y,
568
+ collect: (n) => ({
569
+ isOver: n.isOver()
570
+ }),
571
+ canDrop: () => !e,
572
+ drop: () => {
573
+ var d;
574
+ const n = () => {
575
+ g.current.forEach((m, w) => {
576
+ const c = r[m];
577
+ c && (c.index = w);
578
+ });
579
+ }, s = (d = ee(r)) == null ? void 0 : d.doc;
580
+ s ? s.transact(() => {
581
+ n();
582
+ }) : n();
583
+ }
584
+ });
585
+ return $(() => {
586
+ v || b(x);
587
+ }, [v]), o(u), /* @__PURE__ */ t(j, { ...l, ref: u, className: Qt(v && "isDragging"), children: g.current.map((n, s) => /* @__PURE__ */ t(
588
+ nr,
589
+ {
590
+ type: y,
591
+ disabled: e,
592
+ id: n,
593
+ index: s,
594
+ itemIndex: (d) => g.current.indexOf(d),
595
+ move: k,
596
+ children: (d) => {
597
+ const m = r[n];
598
+ return m ? i(m.data, s, d) : null;
599
+ }
600
+ },
601
+ n
602
+ )) });
603
+ }
604
+ function nr({
605
+ disabled: e,
606
+ id: r,
607
+ index: i,
608
+ type: l,
609
+ children: u,
610
+ itemIndex: y,
611
+ move: a
612
+ }) {
613
+ const x = F(), [{ isDragging: g }, b, k] = Xt({
614
+ type: l,
615
+ item: () => ({ id: r }),
616
+ canDrag: () => !e,
617
+ collect: (o) => ({ isDragging: o.isDragging() })
618
+ }), [, v] = et({
619
+ accept: l,
620
+ canDrop: () => !e,
621
+ hover(o, n) {
622
+ var f;
623
+ if (!x.current)
624
+ return;
625
+ const s = y(o.id), d = i;
626
+ if (s === d)
627
+ return;
628
+ const m = (f = x.current) == null ? void 0 : f.getBoundingClientRect(), w = (m.bottom - m.top) / 2, h = n.getClientOffset().y - m.top;
629
+ s < d && h < w || s > d && h > w || a({ id: o.id, index: s }, { id: r, index: i });
630
+ }
631
+ });
632
+ return typeof u == "function" ? u({
633
+ isDragging: g,
634
+ drag: b,
635
+ drop: (o) => (x.current = o, v(o)),
636
+ preview: k
637
+ }) : (b(v(k(x))), /* @__PURE__ */ t(j, { ref: x, children: u }));
638
+ }
639
+ function sr({
640
+ drop: e,
641
+ preview: r,
642
+ drag: i,
643
+ disabled: l,
644
+ isDragging: u,
645
+ children: y,
646
+ onDelete: a,
647
+ onVisibilityChange: x,
648
+ visible: g = !0,
649
+ actions: b,
650
+ alwaysShowActions: k = !1
651
+ }) {
652
+ const { t: v } = C();
653
+ return /* @__PURE__ */ t(
654
+ j,
655
+ {
656
+ ref: e,
657
+ sx: {
658
+ ":hover .hover-visible": { maxWidth: "100%" },
659
+ opacity: g ? 1 : 0.5
660
+ },
661
+ children: /* @__PURE__ */ O(j, { sx: { position: "relative" }, children: [
662
+ /* @__PURE__ */ t(
663
+ j,
664
+ {
665
+ ref: r,
666
+ sx: {
667
+ flex: 1,
668
+ borderRadius: 0.5,
669
+ bgcolor: u ? "action.hover" : "background.paper",
670
+ opacity: 0.9999
671
+ // NOTE: make preview effective
672
+ },
673
+ children: y
674
+ }
675
+ ),
676
+ !l && /* @__PURE__ */ t(
677
+ j,
678
+ {
679
+ className: k ? "" : "hover-visible",
680
+ sx: {
681
+ maxWidth: k ? "100%" : 0,
682
+ overflow: "hidden",
683
+ position: "absolute",
684
+ right: 2,
685
+ top: 2,
686
+ transition: "max-width 0.3s ease-in-out"
687
+ },
688
+ children: /* @__PURE__ */ O(
689
+ R,
690
+ {
691
+ direction: "row",
692
+ sx: {
693
+ bgcolor: (o) => ue(o.palette.grey[200], 0.9),
694
+ borderRadius: 1,
695
+ p: 0.5,
696
+ [`.${ut.root}`]: {
697
+ minWidth: 24,
698
+ width: 24,
699
+ height: 24,
700
+ p: 0
701
+ }
702
+ },
703
+ children: [
704
+ b,
705
+ x && /* @__PURE__ */ t(G, { title: v(g ? "hideParameter" : "showParameter"), disableInteractive: !0, placement: "top", children: /* @__PURE__ */ t(E, { onClick: () => x(!g), children: g ? /* @__PURE__ */ t(Dt, { sx: { fontSize: "1.25rem", color: "grey.500" } }) : /* @__PURE__ */ t(Et, { sx: { fontSize: "1.25rem", color: "grey.500" } }) }) }),
706
+ a && /* @__PURE__ */ t(G, { title: v("delete"), disableInteractive: !0, placement: "top", children: /* @__PURE__ */ t(E, { onClick: a, children: /* @__PURE__ */ t(At, { sx: { fontSize: "1.25rem", color: "grey.500" } }) }) }),
707
+ /* @__PURE__ */ t(G, { title: v("dragSort"), disableInteractive: !0, placement: "top", children: /* @__PURE__ */ t(E, { ref: i, children: /* @__PURE__ */ t(Tt, { sx: { color: "grey.500" } }) }) })
708
+ ]
709
+ }
710
+ )
711
+ }
712
+ )
713
+ ] })
714
+ }
715
+ );
716
+ }
717
+ function cr({
718
+ label: e,
719
+ value: r,
720
+ onChange: i
721
+ }) {
722
+ const [l, u] = Q(!1);
723
+ return /* @__PURE__ */ O(R, { gap: 1, children: [
724
+ /* @__PURE__ */ t(
725
+ V,
726
+ {
727
+ label: e,
728
+ size: "small",
729
+ value: r,
730
+ onChange: (y) => i == null ? void 0 : i(y.target.value),
731
+ InputProps: {
732
+ endAdornment: /* @__PURE__ */ t(
733
+ Ye,
734
+ {
735
+ onChange: ({ response: y }) => {
736
+ var x;
737
+ const a = (x = y == null ? void 0 : y.data) == null ? void 0 : x.filename;
738
+ a && (i == null || i(a));
739
+ }
740
+ }
741
+ )
742
+ }
743
+ }
744
+ ),
745
+ r && /* @__PURE__ */ t(
746
+ j,
747
+ {
748
+ component: "img",
749
+ sx: { objectFit: "contain", borderRadius: 1, cursor: "pointer" },
750
+ src: Te(r),
751
+ alt: e,
752
+ maxWidth: 100,
753
+ maxHeight: 100,
754
+ width: "100%",
755
+ onClick: () => u(!0)
756
+ }
757
+ ),
758
+ /* @__PURE__ */ t(Me, { open: l, onClose: () => u(!1), children: /* @__PURE__ */ t(j, { component: "img", sx: { objectFit: "contain" }, src: Te(r), alt: e }) })
759
+ ] });
760
+ }
761
+ function he(e, r = "") {
762
+ return qt(e, (i, l, u) => {
763
+ const y = r ? `${r}.${u}` : u;
764
+ return $t(l) ? Bt(i, he(l, y)) : i[y] = l, i;
765
+ }, {});
766
+ }
767
+ const dr = [
768
+ { value: "string", label: "Text" },
769
+ { value: "multiline", label: "Text (Multiline)" },
770
+ { value: "number", label: "Number" },
771
+ { value: "decimal", label: "Decimal" },
772
+ { value: "boolean", label: "Boolean" },
773
+ { value: "color", label: "Color" },
774
+ { value: "url", label: "URL (Upload)" },
775
+ { value: "json", label: "JSON" },
776
+ { value: "yaml", label: "YAML" },
777
+ { value: "array", label: "Array" },
778
+ { value: "component", label: "Component" },
779
+ { value: "custom", label: "Custom (Render by a Component)" }
780
+ ];
781
+ function re(e, r, i) {
782
+ return !e || !i ? !1 : Object.values(e).some(({ data: l }) => l.id !== r && l.key === i);
783
+ }
784
+ function be(e, r) {
785
+ var i;
786
+ return !e || !r ? !1 : ((i = e[r]) == null ? void 0 : i.data.visible) ?? !0;
787
+ }
788
+ function ci({ componentId: e }) {
789
+ const { state: { components: r } } = ce(), i = r[e], l = i == null ? void 0 : i.data;
790
+ return l ? /* @__PURE__ */ t(R, { maxHeight: "100%", overflow: "auto", children: /* @__PURE__ */ t(j, { p: 2, children: /* @__PURE__ */ t(Gt, { FallbackComponent: ot, resetKeys: [e], children: /* @__PURE__ */ t(ar, { value: l }) }) }) }) : null;
791
+ }
792
+ function ar({ value: e }) {
793
+ var b, k, v;
794
+ const { t: r } = C(), { localState: { currentLocale: i, customComponentPreviewerProperties: l }, state: { config: { defaultLocale: u } }, localActions: { setCustomComponentPreviewerProperties: y } } = ce(), a = ee(e).doc, x = ve(), g = Kt({
795
+ propertiesValue: {
796
+ ...y
797
+ }
798
+ });
799
+ return $(() => {
800
+ const o = Object.fromEntries(Object.values(e.properties ?? {}).map(({ data: n }) => {
801
+ var s, d, m, w, c;
802
+ return [
803
+ n.id,
804
+ {
805
+ value: ((s = g.propertiesValue[n.id]) == null ? void 0 : s.value) ?? Nt(n, ((m = (d = n.locales) == null ? void 0 : d[i]) == null ? void 0 : m.defaultValue) ?? ((c = (w = n.locales) == null ? void 0 : w[u]) == null ? void 0 : c.defaultValue), {
806
+ locale: i,
807
+ defaultLocale: u
808
+ })
809
+ }
810
+ ];
811
+ }));
812
+ y(o);
813
+ }, [JSON.stringify(g.propertiesValue)]), /* @__PURE__ */ t(R, { height: "100%", children: /* @__PURE__ */ O(R, { gap: 2, children: [
814
+ /* @__PURE__ */ t(ur, { config: e }),
815
+ /* @__PURE__ */ t(mr, {
816
+ config: e,
817
+ currentLocale: i,
818
+ defaultLocale: u,
819
+ allComponents: x,
820
+ onUpdateConfig: (o) => {
821
+ a.transact(() => {
822
+ o(e);
823
+ });
824
+ }
825
+ }),
826
+ /* @__PURE__ */ O(R, { gap: 2, direction: "row", justifyContent: "space-between", alignItems: "center", children: [
827
+ /* @__PURE__ */ t(M, { variant: "subtitle1", children: r("renderer") }),
828
+ /* @__PURE__ */ O(V, {
829
+ hiddenLabel: !0,
830
+ size: "small",
831
+ select: !0,
832
+ SelectProps: { autoWidth: !0 },
833
+ value: ((b = e.renderer) == null ? void 0 : b.type) || "react-component",
834
+ onChange: (o) => {
835
+ a.transact(() => {
836
+ const n = o.target.value;
837
+ e.renderer ?? (e.renderer = { type: n }), e.renderer.type = n;
838
+ });
839
+ },
840
+ children: [
841
+ /* @__PURE__ */ t(pe, { value: "react-component", children: "React Component" }),
842
+ /* @__PURE__ */ t(pe, { value: "component", children: "Custom Component" })
843
+ ]
844
+ })
845
+ ] }),
846
+ ((k = e.renderer) == null ? void 0 : k.type) === "component" && /* @__PURE__ */ t(Pr, { value: e }),
847
+ ((v = e.renderer) == null ? void 0 : v.type) === "react-component" && /* @__PURE__ */ t(gr, { value: e }),
848
+ /* @__PURE__ */ t(lt, {
849
+ config: e,
850
+ currentLocale: i,
851
+ defaultLocale: u,
852
+ allComponents: x,
853
+ propertiesValue: l,
854
+ onChange: ({ value: o, id: n, path: s }) => {
855
+ const d = [...s, "data"];
856
+ if (!Ft(e, d)) {
857
+ fe.warning(r("cannotFindPropertyKey", {
858
+ key: d.join(".")
859
+ }));
860
+ return;
861
+ }
862
+ g.propertiesValue[n] = {
863
+ value: o.value
864
+ };
865
+ }
866
+ })
867
+ ] }) });
868
+ }
869
+ function ur({ config: e }) {
870
+ const { t: r } = C();
871
+ return /* @__PURE__ */ t(we, { children: /* @__PURE__ */ O(R, { gap: 2, children: [
872
+ /* @__PURE__ */ t(M, { variant: "subtitle1", children: r("basicInfo") }),
873
+ /* @__PURE__ */ t(V, {
874
+ label: r("name"),
875
+ size: "small",
876
+ value: e.name || "",
877
+ onChange: (i) => e.name = i.target.value
878
+ }),
879
+ /* @__PURE__ */ t(V, {
880
+ label: r("description"),
881
+ size: "small",
882
+ multiline: !0,
883
+ minRows: 2,
884
+ maxRows: 10,
885
+ inputProps: { maxLength: 200 },
886
+ value: e.description || "",
887
+ onChange: (i) => e.description = i.target.value
888
+ }),
889
+ /* @__PURE__ */ t($e, {
890
+ size: "small",
891
+ options: [],
892
+ multiple: !0,
893
+ freeSolo: !0,
894
+ value: e.tags ?? [],
895
+ onChange: (i, l) => e.tags = l,
896
+ renderInput: (i) => /* @__PURE__ */ t(V, { label: r("tags"), ...i })
897
+ }),
898
+ /* @__PURE__ */ t(cr, {
899
+ label: r("previewImage"),
900
+ value: e.previewImage || "",
901
+ onChange: (i) => e.previewImage = i
902
+ })
903
+ ] }) });
904
+ }
905
+ function rt({ data: e, params: r, visible: i, config: l, currentLocale: u, defaultLocale: y, allComponents: a, onUpdateConfig: x }) {
906
+ var k, v, o, n, s, d;
907
+ const { t: g } = C(), b = ne(() => e.type === "json" || e.type === "yaml" || e.type === "array" ? br : J, [e.type]);
908
+ return /* @__PURE__ */ t(sr, {
909
+ preview: r.preview,
910
+ drop: r.drop,
911
+ drag: r.drag,
912
+ isDragging: r.isDragging,
913
+ onDelete: () => {
914
+ x((m) => {
915
+ if (m.properties) {
916
+ const c = Object.entries(m.properties).sort(([, f], [, P]) => f.index - P.index);
917
+ delete m.properties[e.id], c.filter(([f]) => f !== e.id).forEach(([, f], P) => {
918
+ f.index = P;
919
+ });
920
+ }
921
+ });
922
+ },
923
+ visible: i,
924
+ onVisibilityChange: (m) => {
925
+ x((w) => {
926
+ const c = w.properties[e.id].data;
927
+ c.visible = m;
928
+ });
929
+ },
930
+ alwaysShowActions: !0,
931
+ children: /* @__PURE__ */ O(R, { direction: "column", gap: 2, children: [
932
+ /* @__PURE__ */ t(V, {
933
+ label: g("key"),
934
+ size: "small",
935
+ required: !0,
936
+ sx: {
937
+ width: "calc(100% - 80px - 8px)",
938
+ flex: 1,
939
+ "& .MuiOutlinedInput-root": {
940
+ borderColor: e.key ? re(l.properties, e.id, e.key) ? "warning.main" : void 0 : "error.main"
941
+ },
942
+ "& .MuiFormLabel-root": {
943
+ color: e.key ? re(l.properties, e.id, e.key) ? "warning.main" : "text.secondary" : "error.main"
944
+ },
945
+ "& .MuiFormLabel-root.Mui-focused": {
946
+ color: e.key ? re(l.properties, e.id, e.key) ? "warning.main" : "primary.main" : "error.main"
947
+ }
948
+ },
949
+ value: e.key || "",
950
+ onChange: (m) => {
951
+ x((w) => {
952
+ const c = w.properties[e.id].data;
953
+ c.key = m.target.value.trim();
954
+ });
955
+ },
956
+ InputProps: {
957
+ endAdornment: !e.key || e.key && re(l.properties, e.id, e.key) ? /* @__PURE__ */ t(ge, {
958
+ position: "end",
959
+ sx: {
960
+ width: 16,
961
+ ml: 0
962
+ },
963
+ children: /* @__PURE__ */ t(G, { title: e.key ? g("duplicateKey") : g("requiredKey"), children: /* @__PURE__ */ t(Qe, {
964
+ sx: {
965
+ color: e.key ? "warning.main" : "error.main",
966
+ fontSize: 16
967
+ }
968
+ }) })
969
+ }) : null
970
+ }
971
+ }),
972
+ /* @__PURE__ */ O(R, { direction: "row", gap: 1, children: [
973
+ /* @__PURE__ */ t(V, {
974
+ label: g("label"),
975
+ size: "small",
976
+ sx: { flex: 1 },
977
+ value: (((v = (k = e.locales) == null ? void 0 : k[u]) == null ? void 0 : v.name) ?? ((n = (o = e.locales) == null ? void 0 : o[y]) == null ? void 0 : n.name)) || "",
978
+ onChange: (m) => {
979
+ x((w) => {
980
+ var h;
981
+ const c = w.properties[e.id].data;
982
+ c.locales ?? (c.locales = {}), (h = c.locales)[u] ?? (h[u] = {}), c.locales[u].name = m.target.value;
983
+ });
984
+ }
985
+ }),
986
+ /* @__PURE__ */ t(V, {
987
+ label: g("type"),
988
+ size: "small",
989
+ select: !0,
990
+ sx: { flex: 1 },
991
+ value: e.type === "string" && e.multiline ? "multiline" : e.type || "string",
992
+ onChange: (m) => {
993
+ x((w) => {
994
+ const c = w.properties[e.id].data;
995
+ if (c.locales)
996
+ for (const f of Object.keys(c.locales))
997
+ c.locales[f].defaultValue = void 0;
998
+ const h = m.target.value;
999
+ h === "multiline" ? (c.type = "string", c.multiline = !0) : (typeof c.multiline < "u" && delete c.multiline, c.type = h);
1000
+ });
1001
+ },
1002
+ children: dr.map((m) => /* @__PURE__ */ t(pe, { value: m.value, children: m.label }, m.value))
1003
+ })
1004
+ ] }),
1005
+ /* @__PURE__ */ O(R, { direction: "row", gap: 1, children: [
1006
+ /* @__PURE__ */ t(b, {
1007
+ allComponents: a,
1008
+ defaultLocale: y,
1009
+ component: l,
1010
+ property: e,
1011
+ label: g("defaultValue"),
1012
+ size: "small",
1013
+ fullWidth: !0,
1014
+ value: (d = (s = e.locales) == null ? void 0 : s[u]) == null ? void 0 : d.defaultValue,
1015
+ onChange: (m, w) => {
1016
+ x((c) => {
1017
+ var f;
1018
+ const h = c.properties[e.id].data;
1019
+ if (w != null && w.forceUpdateProperty) {
1020
+ const P = he(h), S = he(m);
1021
+ Object.keys(S).forEach((p) => {
1022
+ P[p] || He(h, p, S[p]);
1023
+ });
1024
+ } else
1025
+ h.locales ?? (h.locales = {}), (f = h.locales)[u] ?? (f[u] = {}), h.locales[u].defaultValue = m;
1026
+ });
1027
+ }
1028
+ }),
1029
+ e.type === "custom" ? /* @__PURE__ */ t(j, { children: /* @__PURE__ */ t(fr, { property: e, allComponents: a }) }) : null
1030
+ ] })
1031
+ ] })
1032
+ });
1033
+ }
1034
+ function pr(e, r) {
1035
+ const [i, l] = Q(0);
1036
+ return $(() => {
1037
+ const y = setTimeout(() => {
1038
+ if (e.current) {
1039
+ let a = e.current.parentElement, x = 0;
1040
+ for (; a; )
1041
+ a.classList.contains("property-container") && x++, a = a.parentElement;
1042
+ l(x);
1043
+ }
1044
+ }, 100);
1045
+ return () => clearTimeout(y);
1046
+ }, [e, r]), i;
1047
+ }
1048
+ function mr({ config: e, currentLocale: r, defaultLocale: i, allComponents: l, onUpdateConfig: u, useI18nEditor: y = !0 }) {
1049
+ const { t: a } = C(), x = ke({ variant: "dialog" }), g = e.properties && A(Object.values(e.properties), "index");
1050
+ return /* @__PURE__ */ t(we, { children: /* @__PURE__ */ O(R, { gap: 2, children: [
1051
+ /* @__PURE__ */ O(R, { direction: "row", gap: 1, alignItems: "center", justifyContent: "space-between", children: [
1052
+ /* @__PURE__ */ t(M, { variant: "subtitle1", children: a("properties") }),
1053
+ /* @__PURE__ */ t(j, { flex: 1 }),
1054
+ y && /* @__PURE__ */ t(E, { sx: { minWidth: 32, minHeight: 32, p: 0 }, ...Ie(x), children: /* @__PURE__ */ t(Le, { fontSize: "small" }) })
1055
+ ] }),
1056
+ e.properties && Object.keys(e.properties).length > 0 ? /* @__PURE__ */ t(tt, {
1057
+ component: R,
1058
+ gap: 2,
1059
+ list: e.properties,
1060
+ renderItem: (b, k, v) => {
1061
+ const o = be(e.properties, b.id);
1062
+ return /* @__PURE__ */ t(Z, {
1063
+ elevation: 0,
1064
+ className: "property-container",
1065
+ sx: {
1066
+ p: 1.25,
1067
+ borderRadius: 1,
1068
+ border: o ? "1px solid" : "1px dashed",
1069
+ borderColor: "divider"
1070
+ },
1071
+ children: /* @__PURE__ */ t(R, { gap: 2, children: /* @__PURE__ */ t(rt, {
1072
+ data: b,
1073
+ params: v,
1074
+ visible: o,
1075
+ config: e,
1076
+ currentLocale: r,
1077
+ defaultLocale: i,
1078
+ allComponents: l,
1079
+ onUpdateConfig: u
1080
+ }) })
1081
+ }, b.id);
1082
+ }
1083
+ }) : /* @__PURE__ */ t(de, { style: { fontSize: 12 }, children: a("maker.properties.noProperties") }),
1084
+ /* @__PURE__ */ t(E, {
1085
+ fullWidth: !0,
1086
+ variant: "outlined",
1087
+ className: "ignore-style-override",
1088
+ onClick: () => {
1089
+ u((b) => {
1090
+ var v;
1091
+ const k = Ke();
1092
+ b.properties ?? (b.properties = {}), (v = b.properties)[k] ?? (v[k] = { index: (g == null ? void 0 : g.length) || 0, data: { id: k } });
1093
+ });
1094
+ },
1095
+ startIcon: /* @__PURE__ */ t(Ge, {}),
1096
+ children: a("addObject", { object: a("property") })
1097
+ }),
1098
+ y && /* @__PURE__ */ t(it, { ...Ze(x), component: e })
1099
+ ] }) });
1100
+ }
1101
+ function fr({ property: e, allComponents: r }) {
1102
+ const i = ke({ variant: "popper" });
1103
+ return /* @__PURE__ */ O(X, { children: [
1104
+ /* @__PURE__ */ t(E, { sx: { minWidth: 0 }, ...Ie(i), children: /* @__PURE__ */ t(Xe, { fontSize: "small" }) }),
1105
+ /* @__PURE__ */ t(xt, { ...Lt(i), children: /* @__PURE__ */ t(Ct, { onClickAway: i.close, children: /* @__PURE__ */ t(Z, { children: /* @__PURE__ */ t(j, { width: 500, p: 2, children: /* @__PURE__ */ t(Se, {
1106
+ value: e.componentId,
1107
+ onChange: (l, u) => e.componentId = u,
1108
+ allComponents: r
1109
+ }) }) }) }) })
1110
+ ] });
1111
+ }
1112
+ function hr({ value: e, valueImmutable: r, onChange: i, defaultLocale: l, allComponents: u }) {
1113
+ var k;
1114
+ const [y, a] = Q(!1), { t: x, locale: g } = C(), b = typeof (e == null ? void 0 : e.componentId) == "string" ? (k = u[e.componentId]) == null ? void 0 : k.data : void 0;
1115
+ return b ? /* @__PURE__ */ O(j, { sx: { width: "100%", position: "relative" }, children: [
1116
+ /* @__PURE__ */ t(ae, {
1117
+ sx: { minWidth: 0 },
1118
+ disabled: !b,
1119
+ size: "small",
1120
+ onClick: () => a(!y),
1121
+ color: y ? "primary" : "default",
1122
+ children: /* @__PURE__ */ t(Xe, { fontSize: "small" })
1123
+ }),
1124
+ y && /* @__PURE__ */ t(yt, { in: y, timeout: "auto", unmountOnExit: !0, sx: { width: "100%", zIndex: 10 }, children: /* @__PURE__ */ O(Z, {
1125
+ elevation: 1,
1126
+ sx: {
1127
+ mt: 1,
1128
+ p: 2,
1129
+ borderRadius: 1,
1130
+ border: "1px solid",
1131
+ borderColor: "divider",
1132
+ width: "100%"
1133
+ },
1134
+ children: [
1135
+ /* @__PURE__ */ t(j, { width: "100%", mb: 2, children: /* @__PURE__ */ t(lt, {
1136
+ config: b,
1137
+ currentLocale: g,
1138
+ defaultLocale: l,
1139
+ allComponents: u,
1140
+ propertiesValue: e == null ? void 0 : e.properties,
1141
+ onChange: ({ id: v, value: o }) => {
1142
+ const n = jt(o.value), s = JSON.parse(JSON.stringify(e));
1143
+ s != null && s.componentId && (r ? i == null || i({ ...s, properties: { ...s.properties, [v]: { value: n } } }) : (s.properties = s.properties ?? {}, s.properties[v] = { value: n }, i == null || i(s)));
1144
+ }
1145
+ }) }),
1146
+ /* @__PURE__ */ t(E, { size: "small", onClick: () => a(!1), sx: { mt: 1 }, children: x("close") })
1147
+ ]
1148
+ }) })
1149
+ ] }) : null;
1150
+ }
1151
+ function it({ type: e = "properties", component: r, ...i }) {
1152
+ var v, o, n;
1153
+ const { t: l } = C(), { state: { components: u, supportedLocales: y, config: { defaultLocale: a } } } = ce(), x = ve(), g = ee(r).doc, b = e === "properties" ? r.properties : e === "parameters" && ((v = r.renderer) == null ? void 0 : v.type) === "component" ? (o = u[r.renderer.componentId]) == null ? void 0 : o.data.properties : void 0, k = ((n = r.renderer) == null ? void 0 : n.type) === "component" ? r : void 0;
1154
+ return /* @__PURE__ */ O(Me, { ...i, fullWidth: !0, maxWidth: "lg", children: [
1155
+ /* @__PURE__ */ t(ft, { children: l("i18nEditorTitle") }),
1156
+ /* @__PURE__ */ t(ht, { children: b && /* @__PURE__ */ t(R, { children: /* @__PURE__ */ O(Be, { stickyHeader: !0, sx: { td: { verticalAlign: "top" } }, children: [
1157
+ /* @__PURE__ */ t(Fe, { children: /* @__PURE__ */ t(le, { children: y.map(({ locale: s, name: d }) => /* @__PURE__ */ O(oe, { children: [
1158
+ d,
1159
+ a === s && /* @__PURE__ */ t(Ut, { sx: { fontSize: 12, color: "text.secondary" } })
1160
+ ] }, s)) }) }),
1161
+ /* @__PURE__ */ t(Je, { children: A(Object.values(b), "index").map(({ data: s }) => /* @__PURE__ */ t(le, { children: y.map(({ locale: d }) => {
1162
+ var m, w, c, h, f, P, S, p, I, z, N, T, U, W, te, _, H, Y, q, L, Oe, je, Re, ze, Ne, Ve;
1163
+ return /* @__PURE__ */ t(oe, { children: /* @__PURE__ */ t(R, { gap: 1, children: e === "properties" ? /* @__PURE__ */ O(X, { children: [
1164
+ /* @__PURE__ */ t(V, {
1165
+ size: "small",
1166
+ label: "Key",
1167
+ value: s.key || "",
1168
+ onChange: (B) => {
1169
+ g.transact(() => {
1170
+ s.key = B.target.value.trim();
1171
+ });
1172
+ }
1173
+ }),
1174
+ /* @__PURE__ */ t(V, {
1175
+ size: "small",
1176
+ label: l("label"),
1177
+ value: (((w = (m = s.locales) == null ? void 0 : m[d]) == null ? void 0 : w.name) ?? ((h = (c = s.locales) == null ? void 0 : c[a]) == null ? void 0 : h.name)) || "",
1178
+ onChange: (B) => {
1179
+ g.transact(() => {
1180
+ var K;
1181
+ s.locales ?? (s.locales = {}), (K = s.locales)[d] ?? (K[d] = {}), s.locales[d].name = B.target.value;
1182
+ });
1183
+ }
1184
+ }),
1185
+ /* @__PURE__ */ t(j, { children: /* @__PURE__ */ t(J, {
1186
+ allComponents: x,
1187
+ defaultLocale: a,
1188
+ component: r,
1189
+ property: s,
1190
+ size: "small",
1191
+ fullWidth: !0,
1192
+ label: "Default Value",
1193
+ valueImmutable: se((P = (f = s.locales) == null ? void 0 : f[d]) == null ? void 0 : P.defaultValue),
1194
+ value: ((p = (S = s.locales) == null ? void 0 : S[d]) == null ? void 0 : p.defaultValue) ?? ((z = (I = s.locales) == null ? void 0 : I[a]) == null ? void 0 : z.defaultValue),
1195
+ onChange: (B) => {
1196
+ g.transact(() => {
1197
+ var K;
1198
+ s.locales ?? (s.locales = {}), (K = s.locales)[d] ?? (K[d] = {}), s.locales[d].defaultValue = B;
1199
+ });
1200
+ }
1201
+ }) })
1202
+ ] }) : e === "parameters" && k ? /* @__PURE__ */ t(j, { children: /* @__PURE__ */ t(J, {
1203
+ allComponents: x,
1204
+ defaultLocale: a,
1205
+ component: r,
1206
+ property: s,
1207
+ size: "small",
1208
+ fullWidth: !0,
1209
+ valueImmutable: se((W = (U = (T = (N = k.renderer.properties) == null ? void 0 : N[s.id]) == null ? void 0 : T.locales) == null ? void 0 : U[d]) == null ? void 0 : W.value),
1210
+ value: ((Y = (H = (_ = (te = k.renderer.properties) == null ? void 0 : te[s.id]) == null ? void 0 : _.locales) == null ? void 0 : H[d]) == null ? void 0 : Y.value) ?? ((je = (Oe = (L = (q = k.renderer.properties) == null ? void 0 : q[s.id]) == null ? void 0 : L.locales) == null ? void 0 : Oe[a]) == null ? void 0 : je.value) ?? ((ze = (Re = s.locales) == null ? void 0 : Re[d]) == null ? void 0 : ze.defaultValue) ?? ((Ve = (Ne = s.locales) == null ? void 0 : Ne[a]) == null ? void 0 : Ve.defaultValue),
1211
+ onChange: (B) => {
1212
+ g.transact(() => {
1213
+ var K, Ce, De, Ee, Ae;
1214
+ (K = k.renderer).properties ?? (K.properties = {}), (Ce = k.renderer.properties)[De = s.id] ?? (Ce[De] = {}), (Ee = k.renderer.properties[s.id]).locales ?? (Ee.locales = {}), (Ae = k.renderer.properties[s.id].locales)[d] ?? (Ae[d] = {}), k.renderer.properties[s.id].locales[d].value = B;
1215
+ });
1216
+ }
1217
+ }) }) : null }, s.id) }, d);
1218
+ }) }, s.id)) })
1219
+ ] }) }) }),
1220
+ /* @__PURE__ */ t(bt, { children: /* @__PURE__ */ t(E, { onClick: (s) => {
1221
+ var d;
1222
+ return (d = i.onClose) == null ? void 0 : d.call(i, s, "escapeKeyDown");
1223
+ }, children: l("close") }) })
1224
+ ] });
1225
+ }
1226
+ const We = (e, r) => (i) => {
1227
+ const l = [
1228
+ i.palette.info.main,
1229
+ i.palette.primary.main,
1230
+ i.palette.secondary.main,
1231
+ i.palette.success.main,
1232
+ i.palette.warning.main
1233
+ ], u = Math.min(l.length - 1, e), y = l[u], a = ue(y, 0.5), x = ue(y, 1);
1234
+ return {
1235
+ // 保留原有的边框样式
1236
+ borderColor: `${a} !important`,
1237
+ borderLeft: "3px solid !important",
1238
+ // 稍粗的左侧边框
1239
+ borderLeftColor: a,
1240
+ // 使用透明度适应深色/浅色模式
1241
+ color: x,
1242
+ ...r
1243
+ };
1244
+ };
1245
+ function br({ property: e, onChange: r, defaultLocale: i, allComponents: l }) {
1246
+ const { t: u, locale: y } = C(), a = F(null), x = pr(a, e), g = D(() => {
1247
+ if (!(e.type !== "json" && e.type !== "yaml" && e.type !== "array") && e.subProperties)
1248
+ try {
1249
+ let b = {};
1250
+ A(Object.values(e.subProperties), "index").filter((o) => o.data.visible !== !1 && o.data.key).forEach(({ data: o }) => {
1251
+ var s, d, m, w;
1252
+ if (!o.key)
1253
+ return;
1254
+ let n = ((d = (s = o.locales) == null ? void 0 : s[y]) == null ? void 0 : d.defaultValue) ?? ((w = (m = o.locales) == null ? void 0 : m[i]) == null ? void 0 : w.defaultValue);
1255
+ if (o.type === "number")
1256
+ n = Number(n);
1257
+ else if (o.type === "boolean")
1258
+ n = n === !0 || n === "true";
1259
+ else if ((o.type === "json" || o.type === "yaml") && typeof n == "string")
1260
+ try {
1261
+ o.type === "json" ? n = JSON.parse(n) : n = me.parse(n);
1262
+ } catch (c) {
1263
+ console.error("Error parsing nested value", n, c), n = {};
1264
+ }
1265
+ b[o.key] = n;
1266
+ }), e.type === "array" && !Array.isArray(b) && (b = Pe(b) ? [] : [b]);
1267
+ const v = ye(b, e.type);
1268
+ r == null || r(v);
1269
+ } catch (b) {
1270
+ console.error("Error converting structure to text:", b);
1271
+ }
1272
+ }, [e, y, i, r]);
1273
+ return e.type !== "json" && e.type !== "yaml" && e.type !== "array" ? null : /* @__PURE__ */ O(R, { direction: "column", gap: 1.5, sx: { width: "100%" }, ref: a, children: [
1274
+ /* @__PURE__ */ t(vt, { sx: { mt: -1 }, children: /* @__PURE__ */ t(M, { variant: "caption", color: "text.secondary", children: u("maker.properties.subProperties") }) }),
1275
+ e.subProperties && Object.keys(e.subProperties).length > 0 ? /* @__PURE__ */ t(tt, {
1276
+ component: R,
1277
+ gap: 2,
1278
+ list: e.subProperties,
1279
+ renderItem: (b, k, v) => {
1280
+ const o = b.visible !== !1;
1281
+ return /* @__PURE__ */ t(Z, {
1282
+ elevation: 0,
1283
+ className: "property-container",
1284
+ sx: {
1285
+ p: 1.25,
1286
+ borderRadius: 1,
1287
+ border: o ? "1px solid" : "1px dashed",
1288
+ "&": We(x)
1289
+ },
1290
+ children: /* @__PURE__ */ t(R, { gap: 2, children: /* @__PURE__ */ t(rt, {
1291
+ data: b,
1292
+ params: v,
1293
+ visible: o,
1294
+ config: {
1295
+ properties: e.subProperties
1296
+ },
1297
+ currentLocale: y,
1298
+ defaultLocale: i,
1299
+ allComponents: l,
1300
+ onUpdateConfig: (n) => {
1301
+ try {
1302
+ const s = { properties: e.subProperties || {} };
1303
+ n(s);
1304
+ const d = {
1305
+ ...e,
1306
+ subProperties: s.properties
1307
+ };
1308
+ r == null || r(d, { forceUpdateProperty: !0 }), g();
1309
+ } catch (s) {
1310
+ console.error("Error updating property:", s);
1311
+ }
1312
+ }
1313
+ }) })
1314
+ }, b.id);
1315
+ }
1316
+ }) : /* @__PURE__ */ t(de, { style: { fontSize: 12, height: 100 }, children: u("maker.properties.noSubProperties") }),
1317
+ /* @__PURE__ */ t(E, {
1318
+ fullWidth: !0,
1319
+ variant: "outlined",
1320
+ className: "ignore-style-override",
1321
+ size: "small",
1322
+ startIcon: /* @__PURE__ */ t(Ge, {}),
1323
+ onClick: () => {
1324
+ try {
1325
+ const b = e.subProperties || {}, k = Ke(), o = {
1326
+ index: Object.values(b).length,
1327
+ data: {
1328
+ id: k,
1329
+ key: "",
1330
+ type: "string",
1331
+ visible: !0,
1332
+ locales: {
1333
+ [y]: {
1334
+ name: "",
1335
+ defaultValue: ""
1336
+ }
1337
+ },
1338
+ // 为嵌套属性预初始化
1339
+ subProperties: {}
1340
+ }
1341
+ }, n = {
1342
+ ...e,
1343
+ subProperties: {
1344
+ ...b,
1345
+ [k]: o
1346
+ }
1347
+ };
1348
+ r == null || r(n, { forceUpdateProperty: !0 }), g();
1349
+ } catch (b) {
1350
+ console.error("Error adding property:", b);
1351
+ }
1352
+ },
1353
+ sx: {
1354
+ "&": We(x, {
1355
+ // borderLeft: undefined,
1356
+ })
1357
+ },
1358
+ children: u("maker.properties.addSubProperty")
1359
+ })
1360
+ ] });
1361
+ }
1362
+ function J({ component: e, property: r, value: i, onChange: l, valueImmutable: u, defaultLocale: y, allComponents: a, ...x }) {
1363
+ var n, s, d, m, w;
1364
+ const { locale: g } = C(), b = It(), k = F(null), v = () => {
1365
+ var h;
1366
+ const c = (h = b == null ? void 0 : b.current) == null ? void 0 : h.getUploader();
1367
+ c == null || c.open(), k.current && c.onceUploadSuccess(({ response: f }) => {
1368
+ var S, p;
1369
+ let P = ((S = f == null ? void 0 : f.data) == null ? void 0 : S.filename) || "";
1370
+ P && (P = `mediakit://${P}`, i && !i.includes("mediakit://") && (P += " # please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address")), (p = k.current) == null || p.call(k, P);
1371
+ });
1372
+ }, o = x.label ?? (((s = (n = r.locales) == null ? void 0 : n[g]) == null ? void 0 : s.name) || ((m = (d = r.locales) == null ? void 0 : d[y]) == null ? void 0 : m.name) || r.key || r.id);
1373
+ if (r.type === "number")
1374
+ return /* @__PURE__ */ t(yr, {
1375
+ ...x,
1376
+ label: o,
1377
+ NumberProps: {
1378
+ value: ["number", "string"].includes(typeof i) ? i : null,
1379
+ onChange: (c, h) => l == null ? void 0 : l(h)
1380
+ }
1381
+ });
1382
+ if (r.type === "decimal")
1383
+ return /* @__PURE__ */ t(V, {
1384
+ ...x,
1385
+ label: o,
1386
+ type: "text",
1387
+ value: i ?? "",
1388
+ onChange: (c) => {
1389
+ const h = c.target.value;
1390
+ if (h === "" || h === "-") {
1391
+ l == null || l(h);
1392
+ return;
1393
+ }
1394
+ if (/^-?(?!.*\..*\.)[0-9]*(\.[0-9]{0,9})?$/.test(h)) {
1395
+ let P = h;
1396
+ /^-?[1-9]+[0-9]*(\.[0-9]{1,9})?$/.test(P) && (P = Number(P)), l == null || l(P);
1397
+ }
1398
+ }
1399
+ });
1400
+ if (r.type === "boolean")
1401
+ return /* @__PURE__ */ t(pt, {
1402
+ label: o,
1403
+ labelPlacement: "start",
1404
+ control: /* @__PURE__ */ t(mt, { checked: i === !0, onChange: (c, h) => l == null ? void 0 : l(h) })
1405
+ });
1406
+ if (r.type === "color")
1407
+ return /* @__PURE__ */ t(ir, {
1408
+ label: o,
1409
+ value: i,
1410
+ onChange: (c) => {
1411
+ l == null || l(c);
1412
+ }
1413
+ });
1414
+ if (r.type === "json" || r.type === "yaml")
1415
+ return /* @__PURE__ */ t(lr, {
1416
+ label: o,
1417
+ value: i,
1418
+ onChange: (c) => {
1419
+ l == null || l(c);
1420
+ },
1421
+ property: r,
1422
+ component: e,
1423
+ defaultLocale: y,
1424
+ allComponents: a,
1425
+ PropertyValueField: J,
1426
+ onUpload: (c) => {
1427
+ k.current = c, v();
1428
+ }
1429
+ });
1430
+ if (r.type === "custom") {
1431
+ const c = (w = a[r.componentId]) == null ? void 0 : w.data;
1432
+ return c ? /* @__PURE__ */ t(j, { width: "100%", children: /* @__PURE__ */ t(qe, {
1433
+ componentId: c.id,
1434
+ props: { label: o, value: i, onChange: l },
1435
+ locale: g,
1436
+ dev: {
1437
+ mode: "draft",
1438
+ components: a,
1439
+ defaultLocale: y
1440
+ }
1441
+ }) }) : /* @__PURE__ */ t(V, { ...x, label: o, disabled: !0, placeholder: "Click right button select a component" });
1442
+ }
1443
+ if (r.type === "component")
1444
+ return /* @__PURE__ */ O(R, { width: "100%", direction: "column", gap: 1, children: [
1445
+ /* @__PURE__ */ t(Se, {
1446
+ allComponents: a,
1447
+ label: o,
1448
+ value: i == null ? void 0 : i.componentId,
1449
+ onChange: (c, h) => {
1450
+ u || !i ? l == null || l({ ...i && JSON.parse(JSON.stringify(i)), componentId: h }) : typeof i == "object" && (i.componentId = h, l == null || l({ ...i && JSON.parse(JSON.stringify(i)), componentId: h }));
1451
+ }
1452
+ }),
1453
+ (i == null ? void 0 : i.componentId) && /* @__PURE__ */ t(hr, {
1454
+ value: i,
1455
+ valueImmutable: u,
1456
+ onChange: l,
1457
+ defaultLocale: y,
1458
+ allComponents: a
1459
+ })
1460
+ ] });
1461
+ if (!r.type || ["string", "url", "multiline"].includes(r.type)) {
1462
+ let c = r.type === "string" ? r.multiline : void 0;
1463
+ r.type === "multiline" && (c = !0);
1464
+ const h = r.type === "url" ? i == null ? void 0 : i.url : i;
1465
+ return /* @__PURE__ */ t(V, {
1466
+ ...x,
1467
+ label: o,
1468
+ value: typeof h == "string" ? h : "",
1469
+ multiline: c,
1470
+ minRows: c ? 2 : void 0,
1471
+ maxRows: c ? 10 : void 0,
1472
+ onChange: (f) => l == null ? void 0 : l(r.type === "url" ? { ...i, url: f.target.value, mediaKitUrl: f.target.value } : f.target.value),
1473
+ InputProps: r.type === "url" ? {
1474
+ sx: {
1475
+ pr: 0
1476
+ },
1477
+ endAdornment: /* @__PURE__ */ O(ge, { position: "end", children: [
1478
+ /* @__PURE__ */ t(Ye, {
1479
+ onChange: async ({ response: f }) => {
1480
+ var I, z, N;
1481
+ const P = ((I = f == null ? void 0 : f.data) == null ? void 0 : I.url) || ((z = f == null ? void 0 : f.data) == null ? void 0 : z.fileUrl);
1482
+ let S;
1483
+ P && (S = await St(P).catch(() => Ot(P)).catch(() => {
1484
+ }));
1485
+ let p = ((N = f == null ? void 0 : f.data) == null ? void 0 : N.filename) || "";
1486
+ p && (p = `mediakit://${p}`), l == null || l({
1487
+ url: P,
1488
+ mediaKitUrl: p,
1489
+ width: S == null ? void 0 : S.naturalWidth,
1490
+ height: S == null ? void 0 : S.naturalHeight
1491
+ });
1492
+ }
1493
+ }),
1494
+ /* @__PURE__ */ t(G, { title: "If you are using the 'mediaKitUrl' property, please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address.", children: /* @__PURE__ */ t(Qe, { sx: { cursor: "default", mr: 1 }, fontSize: "small" }) })
1495
+ ] })
1496
+ } : void 0
1497
+ });
1498
+ }
1499
+ return r.type === "array" ? /* @__PURE__ */ t(rr, {
1500
+ label: o,
1501
+ value: Array.isArray(i) ? i : [],
1502
+ onChange: (c) => l == null ? void 0 : l(c),
1503
+ property: r,
1504
+ renderItem: ({ item: c, index: h, onChange: f }) => r.subProperties && Object.keys(r.subProperties).length > 0 ? /* @__PURE__ */ t(R, { gap: 1, width: "100%", children: A(Object.values(r.subProperties), "index").filter((P) => P.data.visible !== !1).map(({ data: P }) => P.key ? /* @__PURE__ */ t(J, {
1505
+ component: e,
1506
+ property: P,
1507
+ value: c[P.key],
1508
+ onChange: (S) => {
1509
+ const p = { ...c, [P.key]: S };
1510
+ f(p);
1511
+ },
1512
+ size: "small",
1513
+ fullWidth: !0,
1514
+ defaultLocale: y,
1515
+ allComponents: a
1516
+ }, P.id) : null) }, h) : /* @__PURE__ */ t(V, { size: x.size, fullWidth: !0, value: c, onChange: (P) => f(P.target.value) })
1517
+ }) : (console.error("Unsupported property type", r.type), null);
1518
+ }
1519
+ function yr({ NumberProps: e, ...r }) {
1520
+ const { getInputProps: i } = Vt(e), l = i();
1521
+ return /* @__PURE__ */ t(V, { ...r, inputProps: l });
1522
+ }
1523
+ const vr = `import React from '@blocklet/pages-kit/builtin/react'
1524
+ import { Box } from '@blocklet/pages-kit/builtin/mui/material'
1525
+
1526
+ export default function () {
1527
+ return (
1528
+ <Box>
1529
+ Hello World
1530
+ </Box>
1531
+ )
1532
+ }`, xr = `console.log('hello')
1533
+ `;
1534
+ function gr({ value: e }) {
1535
+ const { locale: r } = C(), i = _e(), l = ee(e).doc;
1536
+ return $(() => {
1537
+ var u;
1538
+ (u = e.renderer) != null && u.script || (l.transact(() => {
1539
+ e.renderer.script = e.renderer.type === "react-component" ? vr : xr;
1540
+ }), i());
1541
+ }, [e]), /* @__PURE__ */ t(j, { sx: { border: 1, borderColor: "divider", borderRadius: 1, overflow: "hidden" }, children: /* @__PURE__ */ t(xe, {
1542
+ keyId: e.id,
1543
+ locale: r,
1544
+ language: "typescript",
1545
+ value: e.renderer.script || "",
1546
+ onChange: (u) => e.renderer.script = u,
1547
+ typeScriptNoValidation: !1,
1548
+ fullScreenOptions: {
1549
+ enableEscExit: !0
1550
+ }
1551
+ }, e.id) });
1552
+ }
1553
+ function Pr({ value: e }) {
1554
+ var k, v, o;
1555
+ const { t: r } = C(), i = ee(e).doc, { state: { components: l, config: { defaultLocale: u }, resources: y }, localState: { currentLocale: a } } = ce(), x = ve(), g = ((k = l[e.renderer.componentId]) == null ? void 0 : k.data) ?? ((o = (v = y.components) == null ? void 0 : v[e.renderer.componentId]) == null ? void 0 : o.component), b = ke({ variant: "dialog" });
1556
+ return /* @__PURE__ */ O(R, { gap: 1, children: [
1557
+ /* @__PURE__ */ t(Se, {
1558
+ allComponents: x,
1559
+ excludes: [e.id],
1560
+ value: e.renderer.componentId,
1561
+ onChange: (n, s) => e.renderer.componentId = s
1562
+ }),
1563
+ g && /* @__PURE__ */ O(X, { children: [
1564
+ /* @__PURE__ */ O(R, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [
1565
+ /* @__PURE__ */ t(M, { variant: "subtitle2", children: r("parameters") }),
1566
+ /* @__PURE__ */ t(E, { sx: { minWidth: 32, minHeight: 32, p: 0 }, ...Ie(b), children: /* @__PURE__ */ t(Le, { fontSize: "small" }) })
1567
+ ] }),
1568
+ g.properties && A(Object.values(g.properties), "index").map(({ data: n }) => {
1569
+ var s, d, m, w, c, h, f, P, S, p, I, z, N, T, U, W;
1570
+ return /* @__PURE__ */ t(j, { children: /* @__PURE__ */ t(J, {
1571
+ allComponents: x,
1572
+ defaultLocale: u,
1573
+ component: g,
1574
+ property: n,
1575
+ fullWidth: !0,
1576
+ size: "small",
1577
+ valueImmutable: se((w = (m = (d = (s = e.renderer.properties) == null ? void 0 : s[n.id]) == null ? void 0 : d.locales) == null ? void 0 : m[a]) == null ? void 0 : w.value),
1578
+ value: ((P = (f = (h = (c = e.renderer.properties) == null ? void 0 : c[n.id]) == null ? void 0 : h.locales) == null ? void 0 : f[a]) == null ? void 0 : P.value) ?? ((z = (I = (p = (S = e.renderer.properties) == null ? void 0 : S[n.id]) == null ? void 0 : p.locales) == null ? void 0 : I[u]) == null ? void 0 : z.value) ?? ((T = (N = n.locales) == null ? void 0 : N[a]) == null ? void 0 : T.defaultValue) ?? ((W = (U = n.locales) == null ? void 0 : U[u]) == null ? void 0 : W.defaultValue),
1579
+ onChange: (te) => {
1580
+ i.transact(() => {
1581
+ var _, H, Y, q, L;
1582
+ (_ = e.renderer).properties ?? (_.properties = {}), (H = e.renderer.properties)[Y = n.id] ?? (H[Y] = {}), (q = e.renderer.properties[n.id]).locales ?? (q.locales = {}), (L = e.renderer.properties[n.id].locales)[a] ?? (L[a] = {}), e.renderer.properties[n.id].locales[a].value = te;
1583
+ });
1584
+ }
1585
+ }) }, n.id);
1586
+ }),
1587
+ /* @__PURE__ */ t(it, { ...Ze(b), component: e, type: "parameters" })
1588
+ ] })
1589
+ ] });
1590
+ }
1591
+ function Se({ label: e, options: r, excludes: i, value: l, onChange: u, allComponents: y, ...a }) {
1592
+ var k;
1593
+ const { t: x } = C(), g = r ?? A(Object.values(Ht(y, ...i ?? [])), "index").map((v) => v.data), b = (typeof l == "string" ? (k = y[l]) == null ? void 0 : k.data : void 0) ?? null;
1594
+ return /* @__PURE__ */ t($e, {
1595
+ ...a,
1596
+ size: "small",
1597
+ options: g,
1598
+ autoHighlight: !0,
1599
+ isOptionEqualToValue: (v, o) => v.id === o.id,
1600
+ getOptionKey: (v) => v.id,
1601
+ getOptionLabel: (v) => v.name || v.id,
1602
+ renderInput: (v) => /* @__PURE__ */ t(V, { label: e || x("component"), ...v }),
1603
+ value: b,
1604
+ onChange: (v, o) => {
1605
+ var s, d, m, w, c, h;
1606
+ let n = {};
1607
+ o && (n = {
1608
+ blockletId: (s = y[o == null ? void 0 : o.id]) == null ? void 0 : s.blockletId,
1609
+ blockletTitle: (d = y[o == null ? void 0 : o.id]) == null ? void 0 : d.blockletTitle,
1610
+ componentName: ((w = (m = y[o == null ? void 0 : o.id]) == null ? void 0 : m.data) == null ? void 0 : w.name) || ((h = (c = y[o == null ? void 0 : o.id]) == null ? void 0 : c.data) == null ? void 0 : h.id)
1611
+ }), u == null || u(v, o == null ? void 0 : o.id, n);
1612
+ }
1613
+ });
1614
+ }
1615
+ function lt({ config: e, allComponents: r, defaultLocale: i, propertiesValue: l, currentLocale: u, onChange: y, props: a }) {
1616
+ const { t: x } = C(), [g, b] = Q(e == null ? void 0 : e.properties), [k, v] = Q(null);
1617
+ $(() => {
1618
+ (() => {
1619
+ var w, c;
1620
+ ((w = e == null ? void 0 : e.renderer) == null ? void 0 : w.type) === "react-component" && Pe(e == null ? void 0 : e.properties) ? Rt((c = e == null ? void 0 : e.renderer) == null ? void 0 : c.script).then((h) => {
1621
+ const f = zt(h);
1622
+ b(f);
1623
+ }) : b(e == null ? void 0 : e.properties);
1624
+ })();
1625
+ }, [JSON.stringify(e)]);
1626
+ const o = D(() => !e || !g ? {} : Object.values(g).reduce((m, { data: w }) => {
1627
+ var h, f, P, S, p;
1628
+ const c = w.key || w.id;
1629
+ return m[w.id] = {
1630
+ key: c,
1631
+ value: (a == null ? void 0 : a[c]) ?? ((h = l == null ? void 0 : l[w.id]) == null ? void 0 : h.value) ?? ((P = (f = w.locales) == null ? void 0 : f[u]) == null ? void 0 : P.defaultValue) ?? ((p = (S = w.locales) == null ? void 0 : S[i]) == null ? void 0 : p.defaultValue),
1632
+ id: w.id,
1633
+ type: w.type
1634
+ }, m;
1635
+ }, {}), [JSON.stringify(g), e, l, u, i]), n = ne(() => {
1636
+ if (!g)
1637
+ return {
1638
+ canUseProperties: [],
1639
+ visibleProperties: [],
1640
+ canUsePropertiesKeys: []
1641
+ };
1642
+ const m = A(Object.values(g), "index"), w = m.filter(({ data: f }) => f.key && be(g, f.id)), c = m.filter(({ data: f }) => f.key && f.type !== "component"), h = c.map(({ data: f }) => f.key);
1643
+ return {
1644
+ canUseProperties: c,
1645
+ visibleProperties: w,
1646
+ canUsePropertiesKeys: h
1647
+ };
1648
+ }, [JSON.stringify(g)]), s = o(), d = _t(s, "key");
1649
+ return /* @__PURE__ */ t(we, { children: /* @__PURE__ */ O(R, { gap: 2, children: [
1650
+ /* @__PURE__ */ t(M, { variant: "subtitle1", children: x("maker.properties.parameters") }),
1651
+ !e || n.canUsePropertiesKeys.length === 0 ? /* @__PURE__ */ t(de, { style: { fontSize: 12 }, children: x("maker.properties.noParameters") }) : /* @__PURE__ */ O(X, { children: [
1652
+ /* @__PURE__ */ t(R, { gap: 2, children: n.visibleProperties.map(({ data: m }) => {
1653
+ var w, c;
1654
+ return /* @__PURE__ */ t(j, { children: /* @__PURE__ */ t(J, {
1655
+ allComponents: r,
1656
+ defaultLocale: i,
1657
+ size: "small",
1658
+ fullWidth: !0,
1659
+ component: e,
1660
+ property: m,
1661
+ valueImmutable: se((w = l == null ? void 0 : l[m.id]) == null ? void 0 : w.value),
1662
+ value: (a == null ? void 0 : a[m.key || m.id]) ?? ((c = s[m.id]) == null ? void 0 : c.value),
1663
+ onChange: (h) => {
1664
+ y({
1665
+ path: ["properties", m.id],
1666
+ id: m.id,
1667
+ value: { value: h },
1668
+ shouldSync: Ue(m),
1669
+ excludeKeys: [],
1670
+ key: m.key || m.id
1671
+ });
1672
+ }
1673
+ }) }, m.id);
1674
+ }) }),
1675
+ /* @__PURE__ */ t(R, { gap: 2, sx: { width: "100%" }, children: /* @__PURE__ */ t(qe, {
1676
+ componentId: (e == null ? void 0 : e.id) || "",
1677
+ renderType: "setting",
1678
+ locale: u,
1679
+ properties: s,
1680
+ dev: { mode: "draft", components: r, defaultLocale: i },
1681
+ props: {
1682
+ ...Yt(a ?? {}, n.canUsePropertiesKeys),
1683
+ onChange: (m) => {
1684
+ const { canUsePropertiesKeys: w } = n;
1685
+ Object.keys(m).filter((h) => {
1686
+ var f;
1687
+ return !Mt(m[h], (f = d == null ? void 0 : d[h]) == null ? void 0 : f.value);
1688
+ }).filter((h) => {
1689
+ var f, P, S, p;
1690
+ return !(h === "locale" && !Jt(d[h], "locale") || ((f = d[h]) == null ? void 0 : f.type) === "component" || (((P = d[h]) == null ? void 0 : P.type) === "yaml" || ((S = d[h]) == null ? void 0 : S.type) === "json") && be(g, (p = d[h]) == null ? void 0 : p.id));
1691
+ }).reduce((h, f) => h.then(() => {
1692
+ const P = d[f], S = w.includes(f);
1693
+ if (P != null && P.id && S)
1694
+ return y({
1695
+ path: ["properties", P.id],
1696
+ id: P.id,
1697
+ value: { value: m[f] },
1698
+ shouldSync: Ue(P),
1699
+ excludeKeys: [],
1700
+ key: P.key || P.id
1701
+ }), Promise.resolve();
1702
+ const p = `propertyNotFound${f}`;
1703
+ if (k === p)
1704
+ return Promise.resolve();
1705
+ fe.close(k);
1706
+ const I = fe.warning(x("maker.properties.propertyNotFound", {
1707
+ key: f
1708
+ }), {
1709
+ key: p
1710
+ });
1711
+ return v(I), Promise.resolve();
1712
+ }), Promise.resolve());
1713
+ }
1714
+ }
1715
+ }) })
1716
+ ] })
1717
+ ] }) });
1718
+ }
1719
+ export {
1720
+ ur as BasicInfo,
1721
+ Se as CustomComponentAutocomplete,
1722
+ ci as CustomComponentSettings,
1723
+ vr as DefaultReactComponentScriptTemplate,
1724
+ xr as DefaultWebComponentScriptTemplate,
1725
+ lt as ParametersConfig,
1726
+ mr as PropertiesConfig,
1727
+ J as PropertyValueField
1728
+ };