@blocklet/pages-kit-inner-components 0.6.76 → 0.6.77

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 (32) hide show
  1. package/lib/cjs/add-component.js +1 -1
  2. package/lib/cjs/chunks/{draft-data-1hI-ev3X.js → draft-data-CkVvOh60.js} +1 -1
  3. package/lib/cjs/chunks/{home-BEBAcHLJ.js → home-CjhOAEa7.js} +2 -2
  4. package/lib/cjs/chunks/html-xfTPTsl5.js +1 -0
  5. package/lib/cjs/chunks/{index-DC4XWhpO.js → index-CiYwdeK9.js} +1 -1
  6. package/lib/cjs/chunks/{publish-button-Brxy74Ql.js → publish-button-DV23sfgB.js} +1 -1
  7. package/lib/cjs/chunks/site-state-CtiXHtSX.js +1 -0
  8. package/lib/cjs/chunks/state-BdtFHk36.js +1 -0
  9. package/lib/cjs/home.js +1 -1
  10. package/lib/cjs/locales.js +2 -2
  11. package/lib/cjs/project-html.js +1 -1
  12. package/lib/cjs/resources.js +1 -1
  13. package/lib/cjs/setting.js +2 -2
  14. package/lib/cjs/site-state.js +1 -1
  15. package/lib/es/add-component.js +2 -2
  16. package/lib/es/chunks/{draft-data--WtLtXxy.js → draft-data-BOoVhbon.js} +1 -1
  17. package/lib/es/chunks/{home-iBLOByRu.js → home-BZB9zOlO.js} +3 -3
  18. package/lib/es/chunks/{html-DfzaaIYa.js → html-DOgzvdOd.js} +11 -10
  19. package/lib/es/chunks/{index-BlZcgfTW.js → index-Bggolyu_.js} +2 -2
  20. package/lib/es/chunks/{publish-button-CHmiGlT7.js → publish-button-Dm2Nce-b.js} +3 -3
  21. package/lib/es/chunks/{site-state-BXM-5tZw.js → site-state-D4wvb7PN.js} +300 -300
  22. package/lib/es/chunks/{state-DS2djQbR.js → state-DNdwHwty.js} +173 -165
  23. package/lib/es/home.js +3 -3
  24. package/lib/es/locales.js +2 -0
  25. package/lib/es/project-html.js +1 -1
  26. package/lib/es/resources.js +1 -1
  27. package/lib/es/setting.js +680 -670
  28. package/lib/es/site-state.js +1 -1
  29. package/package.json +3 -3
  30. package/lib/cjs/chunks/html-JOhPskS4.js +0 -1
  31. package/lib/cjs/chunks/site-state-CcYU6tKv.js +0 -1
  32. package/lib/cjs/chunks/state-BAjDjwwp.js +0 -1
@@ -10,8 +10,8 @@ import "@mui/material";
10
10
  import Se, { getYjsDoc as Ie } from "@syncedstore/core";
11
11
  import { useSyncedStore as Pe } from "@syncedstore/react";
12
12
  import { useLocalStorageState as ye } from "ahooks";
13
- import { produce as $ } from "immer";
14
- import _ from "lodash/cloneDeep";
13
+ import { produce as _ } from "immer";
14
+ import R from "lodash/cloneDeep";
15
15
  import ee from "lodash/debounce";
16
16
  import { createContext as we, useState as W, useRef as te, useMemo as j, useCallback as M, useEffect as V, useContext as Ce } from "react";
17
17
  import { useParams as he, useNavigate as ve } from "react-router-dom";
@@ -20,10 +20,10 @@ import { WebsocketProvider as be } from "y-websocket";
20
20
  import { UndoManager as xe } from "yjs";
21
21
  import "@blocklet/pages-kit/types";
22
22
  function Ee() {
23
- const { pathname: o } = window.location, P = o.match(/\/admin\/(maker|previewer)\/([^/]+)/)?.[2], f = window.__PROJECT_ID__;
24
- if (!P && !f)
23
+ const { pathname: o } = window.location, I = o.match(/\/admin\/(maker|previewer)\/([^/]+)/)?.[2], f = window.__PROJECT_ID__;
24
+ if (!I && !f)
25
25
  throw new Error("Unable to get projectId from pathname");
26
- return P || f;
26
+ return I || f;
27
27
  }
28
28
  function st(o) {
29
29
  return `${o}:pages:version`;
@@ -39,9 +39,9 @@ function dt(o) {
39
39
  return o && !/^(https?:\/\/|\/)/.test(o) ? window.location.origin + F(Q, "uploads", o) : o;
40
40
  }
41
41
  const Ne = window.innerWidth <= 750;
42
- function ut(o, n, P) {
42
+ function ut(o, n, I) {
43
43
  if (!o || /\.gif/.test(o)) return o;
44
- const f = (Ne ? n / 1.5 : n) * (P === "quality" ? 1.5 : 1);
44
+ const f = (Ne ? n / 1.5 : n) * (I === "quality" ? 1.5 : 1);
45
45
  return Le(o, { imageFilter: "resize", w: f, f: "webp" });
46
46
  }
47
47
  function Le(o, n) {
@@ -55,17 +55,17 @@ async function Me(o) {
55
55
  }
56
56
  const q = "@COMPONENT-TEMPLATE-", X = (o) => `${q}${o}`, K = (o) => o.startsWith(q), Z = (o) => K(o) ? o.slice(q.length) : null;
57
57
  function ne(o, n = {}) {
58
- return n[o.id] = o, o.sectionIds && o.sections && o.sectionIds.forEach((P) => {
59
- const f = o.sections?.[P];
58
+ return n[o.id] = o, o.sectionIds && o.sections && o.sectionIds.forEach((I) => {
59
+ const f = o.sections?.[I];
60
60
  f && ne(f, n);
61
61
  }), n;
62
62
  }
63
63
  function Ae(o, n) {
64
- const P = X(o.id), f = n.section, O = ne(f);
64
+ const I = X(o.id), f = n.section, O = ne(f);
65
65
  n.dataSource ??= {};
66
66
  const w = n.dataSource;
67
67
  return {
68
- id: P,
68
+ id: I,
69
69
  createdAt: o.createdAt,
70
70
  updatedAt: o.updatedAt,
71
71
  publishedAt: o.updatedAt,
@@ -78,19 +78,19 @@ function Ae(o, n) {
78
78
  dataSource: w
79
79
  };
80
80
  }
81
- const De = 500, ce = we(null);
81
+ const De = 500, re = we(null);
82
82
  function lt({
83
83
  url: o,
84
84
  name: n,
85
- children: P,
85
+ children: I,
86
86
  waitingSynced: f
87
87
  }) {
88
- const [O, w] = W(!1), { locale: A } = fe(), h = re(), k = `${h}:MakerLocalState`, b = `${h}:${n}`, [v, S] = ye(k, {
88
+ const [O, w] = W(!1), { locale: A } = fe(), h = ce(), k = `${h}:MakerLocalState`, b = `${h}:${n}`, [v, S] = ye(k, {
89
89
  defaultValue: {},
90
90
  listenStorageChange: !0
91
- }), R = te(v);
92
- R.current = v;
93
- const J = j(
91
+ }), J = te(v);
92
+ J.current = v;
93
+ const $ = j(
94
94
  () => Se({
95
95
  dataSourceIds: [],
96
96
  dataSources: {},
@@ -104,7 +104,7 @@ function lt({
104
104
  resources: {}
105
105
  }),
106
106
  []
107
- ), y = j(() => Ie(J), [J]);
107
+ ), y = j(() => Ie($), [$]);
108
108
  j(() => new Oe(b, y), [b, y]);
109
109
  const C = j(
110
110
  () => new be(o, b, y, {
@@ -129,12 +129,12 @@ function lt({
129
129
  { doc: y }
130
130
  ),
131
131
  [y]
132
- ), [t, c] = W(null), [r, d] = W(!1), [i, l] = W(void 0), m = M(async () => {
132
+ ), [t, r] = W(null), [c, d] = W(!1), [i, l] = W(void 0), m = M(async () => {
133
133
  if (h) {
134
134
  d(!0);
135
135
  try {
136
136
  const s = await je(h);
137
- c(s);
137
+ r(s);
138
138
  } catch (s) {
139
139
  console.error("Failed to fetch project:", s);
140
140
  } finally {
@@ -144,7 +144,7 @@ function lt({
144
144
  }, [h]), u = M(
145
145
  async (s, a) => {
146
146
  if (l(void 0), !!h) {
147
- a?.optimisticUpdate && t && c((g) => ({
147
+ a?.optimisticUpdate && t && r((g) => ({
148
148
  ...g,
149
149
  ...s
150
150
  }));
@@ -152,9 +152,9 @@ function lt({
152
152
  const g = await Me({
153
153
  ...s
154
154
  });
155
- c(g);
155
+ r(g);
156
156
  } catch (g) {
157
- console.error("Failed to update project:", g), a?.optimisticUpdate && c(t), l(g?.response?.data);
157
+ console.error("Failed to update project:", g), a?.optimisticUpdate && r(t), l(g?.response?.data);
158
158
  }
159
159
  }
160
160
  },
@@ -166,7 +166,7 @@ function lt({
166
166
  const p = j(
167
167
  () => ({
168
168
  doc: y,
169
- state: J,
169
+ state: $,
170
170
  localState: {
171
171
  ...v,
172
172
  // always use the locale from the context
@@ -176,7 +176,7 @@ function lt({
176
176
  undoManager: e,
177
177
  projectState: {
178
178
  project: t,
179
- isLoadingProject: r,
179
+ isLoadingProject: c,
180
180
  error: i
181
181
  },
182
182
  updateProject: u,
@@ -185,13 +185,13 @@ function lt({
185
185
  // eslint-disable-next-line react-hooks/exhaustive-deps
186
186
  [
187
187
  y,
188
- J,
188
+ $,
189
189
  JSON.stringify(v),
190
190
  // resolve the problem of react warning
191
191
  S,
192
192
  e,
193
193
  t,
194
- r,
194
+ c,
195
195
  u,
196
196
  i,
197
197
  A,
@@ -200,8 +200,8 @@ function lt({
200
200
  );
201
201
  return V(() => {
202
202
  e.on("stack-item-added", ({ stackItem: s }) => {
203
- const { currentPageId: a, currentLocale: g, pages: I } = R.current;
204
- s.meta.set("localState", { currentPageId: a, currentLocale: g, pages: I });
203
+ const { currentPageId: a, currentLocale: g, pages: P } = J.current;
204
+ s.meta.set("localState", { currentPageId: a, currentLocale: g, pages: P });
205
205
  }), e.on("stack-item-popped", ({ stackItem: s }) => {
206
206
  const a = s.meta.get("localState");
207
207
  a && S((g) => ({ ...g, ...a }));
@@ -213,7 +213,7 @@ function lt({
213
213
  w(!0);
214
214
  });
215
215
  let s = 0, a = null;
216
- const g = 3, I = 5e3, N = 15e3, x = () => {
216
+ const g = 3, P = 5e3, N = 15e3, x = () => {
217
217
  s = 0, S((T) => ({
218
218
  ...T,
219
219
  networkStatus: void 0
@@ -230,7 +230,7 @@ function lt({
230
230
  if (s++, !a) {
231
231
  const se = Date.now();
232
232
  let H = 0;
233
- const ie = Math.ceil(N / I), Y = () => {
233
+ const ie = Math.ceil(N / P), Y = () => {
234
234
  H++;
235
235
  const ae = Date.now() - se;
236
236
  if (C.wsconnected) {
@@ -241,9 +241,9 @@ function lt({
241
241
  E();
242
242
  return;
243
243
  }
244
- a = setTimeout(Y, I);
244
+ a = setTimeout(Y, P);
245
245
  };
246
- a = setTimeout(Y, I);
246
+ a = setTimeout(Y, P);
247
247
  }
248
248
  s >= g && E();
249
249
  }
@@ -255,13 +255,13 @@ function lt({
255
255
  return C.on("status", L), window.addEventListener("online", D), window.addEventListener("offline", G), C.wsconnected && x(), () => {
256
256
  a && clearTimeout(a), C.off("status", L), window.removeEventListener("online", D), window.removeEventListener("offline", G);
257
257
  };
258
- }, [C, S]), f && !O ? null : /* @__PURE__ */ de(ce.Provider, { value: p, children: P });
258
+ }, [C, S]), f && !O ? null : /* @__PURE__ */ de(re.Provider, { value: p, children: I });
259
259
  }
260
260
  const _e = () => {
261
- const o = Ce(ce);
261
+ const o = Ce(re);
262
262
  if (!o)
263
263
  throw new Error("Context is null");
264
- const n = Pe(o.state), { setLocalState: P, localState: f } = o, O = ve(), w = re(), A = te({}), h = M(
264
+ const n = Pe(o.state), { setLocalState: I, localState: f } = o, O = ve(), w = ce(), A = te({}), h = M(
265
265
  (e) => {
266
266
  const t = n.components[e]?.data;
267
267
  return !t || t.renderer?.type !== "component-template" ? void 0 : (A.current[e] || (A.current[e] = {
@@ -274,13 +274,13 @@ const _e = () => {
274
274
  const t = n.components[e]?.data;
275
275
  if (!t || t.renderer?.type !== "component-template")
276
276
  return;
277
- const c = h(e);
278
- if (c)
277
+ const r = h(e);
278
+ if (r)
279
279
  return {
280
280
  componentId: e,
281
281
  component: t,
282
282
  renderer: t.renderer,
283
- page: c
283
+ page: r
284
284
  };
285
285
  },
286
286
  [h, n.components]
@@ -291,18 +291,18 @@ const _e = () => {
291
291
  return { kind: "page", pageId: e, page: t };
292
292
  if (!K(e))
293
293
  return;
294
- const c = Z(e);
295
- if (!c)
294
+ const r = Z(e);
295
+ if (!r)
296
296
  return;
297
- const r = k(c);
298
- if (r)
297
+ const c = k(r);
298
+ if (c)
299
299
  return {
300
300
  kind: "component-template",
301
301
  pageId: e,
302
- page: r.page,
303
- componentId: r.componentId,
304
- component: r.component,
305
- renderer: r.renderer
302
+ page: c.page,
303
+ componentId: c.componentId,
304
+ component: c.component,
305
+ renderer: c.renderer
306
306
  };
307
307
  },
308
308
  [k, n.pages]
@@ -321,36 +321,36 @@ const _e = () => {
321
321
  localState: { currentPageId: e, currentComponentId: t }
322
322
  } = o;
323
323
  if (e) {
324
- const c = b(e);
325
- if (c)
326
- return c.page;
324
+ const r = b(e);
325
+ if (r)
326
+ return r.page;
327
327
  }
328
328
  if (t) {
329
- const c = k(t);
330
- if (c)
331
- return c.page;
329
+ const r = k(t);
330
+ if (r)
331
+ return r.page;
332
332
  }
333
333
  },
334
334
  get currentSection() {
335
335
  const {
336
336
  localState: { currentPageId: e, ...t }
337
- } = o, { currentPage: c } = this;
338
- if (!c || !e)
337
+ } = o, { currentPage: r } = this;
338
+ if (!r || !e)
339
339
  return;
340
- const r = t.pages?.[e]?.currentSectionId;
341
- if (r)
342
- return c.sections?.[r] ?? this.currentPageModel?.getComponentById(r)?.model;
340
+ const c = t.pages?.[e]?.currentSectionId;
341
+ if (c)
342
+ return r.sections?.[c] ?? this.currentPageModel?.getComponentById(c)?.model;
343
343
  },
344
344
  get currentSectionProperties() {
345
345
  const {
346
346
  localState: { currentPageId: e, ...t }
347
- } = o, { currentPage: c } = this;
348
- if (!c || !e)
347
+ } = o, { currentPage: r } = this;
348
+ if (!r || !e)
349
349
  return;
350
- const r = t.pages?.[e]?.currentSectionId;
351
- if (!r)
350
+ const c = t.pages?.[e]?.currentSectionId;
351
+ if (!c)
352
352
  return;
353
- const d = c.dataSource?.[r];
353
+ const d = r.dataSource?.[c];
354
354
  if (!d)
355
355
  return;
356
356
  const { currentLocale: i } = this.currentLocaleMap;
@@ -359,13 +359,13 @@ const _e = () => {
359
359
  get currentSectionPropertiesWithFallback() {
360
360
  const {
361
361
  localState: { currentPageId: e, ...t }
362
- } = o, { currentPage: c } = this;
363
- if (!c || !e)
362
+ } = o, { currentPage: r } = this;
363
+ if (!r || !e)
364
364
  return;
365
- const r = t.pages?.[e]?.currentSectionId;
366
- if (!r)
365
+ const c = t.pages?.[e]?.currentSectionId;
366
+ if (!c)
367
367
  return;
368
- const d = c.dataSource?.[r];
368
+ const d = r.dataSource?.[c];
369
369
  if (!d)
370
370
  return;
371
371
  const { currentLocale: i, defaultLocale: l, fallbackLocale: m } = this.currentLocaleMap;
@@ -381,12 +381,12 @@ const _e = () => {
381
381
  localState: { currentLocale: e },
382
382
  state: {
383
383
  supportedLocales: t,
384
- config: { defaultLocale: c }
384
+ config: { defaultLocale: r }
385
385
  }
386
386
  } = o;
387
387
  return {
388
388
  currentLocale: e,
389
- defaultLocale: c,
389
+ defaultLocale: r,
390
390
  fallbackLocale: t?.[0]?.locale ?? "en"
391
391
  };
392
392
  },
@@ -403,7 +403,7 @@ const _e = () => {
403
403
  }
404
404
  }),
405
405
  [JSON.stringify(f), n]
406
- ), R = j(() => {
406
+ ), J = j(() => {
407
407
  if (f.currentPageId) {
408
408
  const e = b(f.currentPageId);
409
409
  if (e?.kind === "component-template")
@@ -421,31 +421,39 @@ const _e = () => {
421
421
  renderer: e.renderer
422
422
  };
423
423
  }
424
- }, [f.currentPageId, f.currentComponentId, b, k]), J = M(
425
- () => R?.kind === "component-template" ? R : void 0,
426
- [R]
424
+ }, [f.currentPageId, f.currentComponentId, b, k]), $ = M(
425
+ () => J?.kind === "component-template" ? J : void 0,
426
+ [J]
427
427
  ), y = j(
428
428
  () => ({
429
429
  setCurrentSectionId: (e, t) => {
430
- const c = K(e), r = c ? Z(e) : null;
431
- e === f.currentPageId && t === f.pages?.[e]?.currentSectionId && (!c || r === f.currentComponentId) || (O(c && r ? F("/admin/maker", w ?? "", "components", r) : F("/admin/maker", w ?? "", "pages", e)), P(
432
- (d) => $(d, (i) => {
433
- i.currentPageId = e, c ? r && (i.currentComponentId = r) : i.currentComponentId = void 0, i.pages ??= {}, i.pages[e] ??= {}, i.pages[e].currentSectionId = t ?? void 0, t ? window.sessionStorage.setItem("iframe_show_id", `"${t}"`) : window.sessionStorage.removeItem("iframe_show_id");
430
+ const r = K(e), c = r ? Z(e) : null;
431
+ e === f.currentPageId && t === f.pages?.[e]?.currentSectionId && (!r || c === f.currentComponentId) || (O(r && c ? F("/admin/maker", w ?? "", "components", c) : F("/admin/maker", w ?? "", "pages", e)), I(
432
+ (d) => _(d, (i) => {
433
+ i.currentPageId = e, r ? c && (i.currentComponentId = c) : i.currentComponentId = void 0, i.pages ??= {}, i.pages[e] ??= {}, i.pages[e].currentSectionId = t ?? void 0, t ? window.sessionStorage.setItem("iframe_show_id", `"${t}"`) : window.sessionStorage.removeItem("iframe_show_id");
434
434
  })
435
435
  ));
436
436
  },
437
437
  setCurrentComponentId: (e) => {
438
- const c = n.components[e]?.data?.renderer?.type === "component-template", r = c ? X(e) : void 0;
439
- e === f.currentComponentId && (!c || f.currentPageId === r) || (O(F("/admin/maker", w ?? "", "components", e)), P(
440
- (d) => $(d, (i) => {
441
- i.currentComponentId = e, c && r ? (i.currentPageId = r, i.pages ??= {}, i.pages[r] ??= {}) : i.currentPageId && K(i.currentPageId) && (i.currentPageId = void 0);
438
+ if (!e) {
439
+ I(
440
+ (d) => _(d, (i) => {
441
+ i.currentComponentId = void 0;
442
+ })
443
+ );
444
+ return;
445
+ }
446
+ const r = n.components[e]?.data?.renderer?.type === "component-template", c = r ? X(e) : void 0;
447
+ e === f.currentComponentId && (!r || f.currentPageId === c) || (O(F("/admin/maker", w ?? "", "components", e)), I(
448
+ (d) => _(d, (i) => {
449
+ i.currentComponentId = e, r && c ? (i.currentPageId = c, i.pages ??= {}, i.pages[c] ??= {}) : i.currentPageId && K(i.currentPageId) && (i.currentPageId = void 0);
442
450
  })
443
451
  ));
444
452
  },
445
453
  setCurrentRouteId: ({ routeId: e, dynamicParams: t }) => {
446
- P(
447
- (c) => $(c, (r) => {
448
- r.currentRouteId = e, r.currentDynamicParams = t;
454
+ I(
455
+ (r) => _(r, (c) => {
456
+ c.currentRouteId = e, c.currentDynamicParams = t;
449
457
  })
450
458
  );
451
459
  },
@@ -453,34 +461,34 @@ const _e = () => {
453
461
  setCustomComponentPreviewerProperties: (() => {
454
462
  const e = {};
455
463
  let t = "";
456
- const c = ee(() => {
457
- P(
458
- (r) => $(r, (d) => {
464
+ const r = ee(() => {
465
+ I(
466
+ (c) => _(c, (d) => {
459
467
  d.customComponentPreviewerProperties ??= {}, d.customComponentPreviewerProperties[t] = {
460
468
  ...d.customComponentPreviewerProperties[t],
461
- ..._(e[t])
469
+ ...R(e[t])
462
470
  }, delete e[t];
463
471
  })
464
472
  );
465
473
  }, 5);
466
- return (r, d) => {
467
- const i = e[r] ?? {};
468
- Object.assign(i, d), e[r] = i, t = r, c();
474
+ return (c, d) => {
475
+ const i = e[c] ?? {};
476
+ Object.assign(i, d), e[c] = i, t = c, r();
469
477
  };
470
478
  })(),
471
479
  setRouteGenerateProcess: (e) => {
472
- P(
473
- (t) => $(t, (c) => {
474
- e ? c.routeGenerateProcess = {
475
- ...c.routeGenerateProcess,
480
+ I(
481
+ (t) => _(t, (r) => {
482
+ e ? r.routeGenerateProcess = {
483
+ ...r.routeGenerateProcess,
476
484
  ...e
477
- } : c.routeGenerateProcess = {};
485
+ } : r.routeGenerateProcess = {};
478
486
  })
479
487
  );
480
488
  },
481
489
  resetRouteGenerateProcess: () => {
482
- P(
483
- (e) => $(e, (t) => {
490
+ I(
491
+ (e) => _(e, (t) => {
484
492
  t.routeGenerateProcess = {
485
493
  progress: "complete"
486
494
  };
@@ -488,10 +496,10 @@ const _e = () => {
488
496
  );
489
497
  }
490
498
  }),
491
- [P, O, w, S]
499
+ [I, O, w, S]
492
500
  ), C = M(
493
- (e, t, c, r, d) => {
494
- const i = v(e), { page: l } = i, m = _(t), u = c ? _(c) : void 0, p = z(m);
501
+ (e, t, r, c, d) => {
502
+ const i = v(e), { page: l } = i, m = R(t), u = r ? R(r) : void 0, p = z(m);
495
503
  return o.doc.transact(() => {
496
504
  if (d && d.component === "layout-block") {
497
505
  const s = S.currentPageModel?.getComponentById(d.id);
@@ -500,12 +508,12 @@ const _e = () => {
500
508
  const s = i.renderer.section;
501
509
  s.sections ??= {}, s.sections[p.id] = p, s.sectionIds ??= [], s.sectionIds.push(p.id);
502
510
  } else
503
- l.sections[p.id] = p, l.sectionIds.splice(r ?? l.sectionIds.length, 0, p.id);
511
+ l.sections[p.id] = p, l.sectionIds.splice(c ?? l.sectionIds.length, 0, p.id);
504
512
  if (u) {
505
513
  l.dataSource ??= {};
506
514
  const s = (a, g) => {
507
- const I = u[a.id];
508
- I && (l.dataSource[g.id] = _(I)), a.component === "layout-block" && a.sectionIds?.length && a.sectionIds.forEach((N, x) => {
515
+ const P = u[a.id];
516
+ P && (l.dataSource[g.id] = R(P)), a.component === "layout-block" && a.sectionIds?.length && a.sectionIds.forEach((N, x) => {
509
517
  const E = a.sections?.[N], L = g.sectionIds?.[x], D = L ? g.sections?.[L] : void 0;
510
518
  E && D && s(E, D);
511
519
  });
@@ -518,13 +526,13 @@ const _e = () => {
518
526
  ), U = j(
519
527
  () => ({
520
528
  addPage: (e, t) => {
521
- const c = e?.id ?? B(), r = {
529
+ const r = e?.id ?? B(), c = {
522
530
  ...e,
523
- id: c,
531
+ id: r,
524
532
  createdAt: e?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
525
533
  updatedAt: e?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
526
534
  publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
527
- slug: e?.slug ?? `/${c}`,
535
+ slug: e?.slug ?? `/${r}`,
528
536
  sections: e?.sections ?? {},
529
537
  sectionIds: e?.sectionIds ?? [],
530
538
  isPublic: e?.isPublic ?? !0,
@@ -538,17 +546,17 @@ const _e = () => {
538
546
  }
539
547
  };
540
548
  return o.doc.transact(() => {
541
- n.pages[r.id] = r, n.pageIds.splice(t ?? n.pageIds.length, 0, r.id);
542
- }), r;
549
+ n.pages[c.id] = c, n.pageIds.splice(t ?? n.pageIds.length, 0, c.id);
550
+ }), c;
543
551
  },
544
552
  addRoute: (e, t) => {
545
- const c = e?.id ?? B(), r = {
553
+ const r = e?.id ?? B(), c = {
546
554
  ...e,
547
- id: c,
555
+ id: r,
548
556
  createdAt: e?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
549
557
  updatedAt: e?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
550
558
  publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
551
- path: e?.path ?? `/${c}`,
559
+ path: e?.path ?? `/${r}`,
552
560
  handler: e?.handler ?? "Pages Kit",
553
561
  isPublic: e?.isPublic ?? !0,
554
562
  params: e?.params ?? [],
@@ -557,8 +565,8 @@ const _e = () => {
557
565
  dataSource: e?.dataSource ?? {}
558
566
  };
559
567
  return o.doc.transact(() => {
560
- n.routes ??= {}, n.routeIds ??= [], n.routes[r.id] = r, n.routeIds.splice(t ?? n.routeIds.length, 0, r.id);
561
- }), r;
568
+ n.routes ??= {}, n.routeIds ??= [], n.routes[c.id] = c, n.routeIds.splice(t ?? n.routeIds.length, 0, c.id);
569
+ }), c;
562
570
  },
563
571
  deleteRoute: (e) => {
564
572
  if (!e)
@@ -575,15 +583,15 @@ const _e = () => {
575
583
  });
576
584
  },
577
585
  movePage: (e, t) => {
578
- const { pageIds: c } = n, r = c.indexOf(e);
579
- r >= 0 && c.splice(t, 0, ...c.splice(r, 1));
586
+ const { pageIds: r } = n, c = r.indexOf(e);
587
+ c >= 0 && r.splice(t, 0, ...r.splice(c, 1));
580
588
  },
581
- addSection: (e, t, c, r) => {
589
+ addSection: (e, t, r, c) => {
582
590
  const d = v(e), { page: i } = d, l = t?.config, m = typeof l?.componentId == "string" ? l.componentId : void 0;
583
591
  if (t.component === "custom-component" && m) {
584
592
  const a = (n.components[m]?.data ?? n.resources?.components?.[m]?.component)?.renderer;
585
593
  if (a?.type === "component-template")
586
- return C(e, a.section, a.dataSource, c, r);
594
+ return C(e, a.section, a.dataSource, r, c);
587
595
  }
588
596
  const u = {
589
597
  ...t,
@@ -591,21 +599,21 @@ const _e = () => {
591
599
  isTemplateSection: t.isTemplateSection ?? !0
592
600
  /** @deprecated 已经废弃,llmConfig 从 component / resources.component 中获取 */
593
601
  // llmConfig: section.llmConfig ?? {},
594
- }, p = _(u.locales);
602
+ }, p = R(u.locales);
595
603
  return delete u.locales, o.doc.transact(() => {
596
- if (r && r.component === "layout-block") {
597
- const s = S.currentPageModel?.getComponentById(r.id);
604
+ if (c && c.component === "layout-block") {
605
+ const s = S.currentPageModel?.getComponentById(c.id);
598
606
  s && (s.model.sections ??= {}, s.model.sections[u.id] = u, s.model.sectionIds ??= [], s.model.sectionIds.push(u.id));
599
607
  } else if (d.kind === "component-template") {
600
608
  const s = d.renderer.section;
601
609
  s.sections ??= {}, s.sections[u.id] = u, s.sectionIds ??= [], s.sectionIds.push(u.id);
602
610
  } else
603
- i.sections[u.id] = u, i.sectionIds.splice(c ?? i.sectionIds.length, 0, u.id);
611
+ i.sections[u.id] = u, i.sectionIds.splice(r ?? i.sectionIds.length, 0, u.id);
604
612
  p && (i.dataSource ??= {}, i.dataSource[u.id] = p);
605
613
  }), u;
606
614
  },
607
615
  deleteSection: (e, t) => {
608
- const c = v(e), { page: r } = c;
616
+ const r = v(e), { page: c } = r;
609
617
  o.doc.transact(() => {
610
618
  const d = [], i = S.currentPageModel?.getComponentById(t), l = i?.parent;
611
619
  if (i && (d.push(i.model.id, ...i.all().map((m) => m.model.id)), l?.model.component === "layout-block")) {
@@ -618,22 +626,22 @@ const _e = () => {
618
626
  }), l.model.config?.backgroundSectionId === t && (l.model.config.backgroundSectionId = void 0);
619
627
  }
620
628
  d.forEach((m) => {
621
- const u = r.sectionIds.indexOf(m);
622
- u !== -1 && r.sectionIds.splice(u, 1), r.sections[m] && delete r.sections[m], r.dataSource?.[m] && delete r.dataSource?.[m];
629
+ const u = c.sectionIds.indexOf(m);
630
+ u !== -1 && c.sectionIds.splice(u, 1), c.sections[m] && delete c.sections[m], c.dataSource?.[m] && delete c.dataSource?.[m];
623
631
  });
624
632
  });
625
633
  },
626
634
  lockSection: (e, t) => {
627
635
  v(e);
628
- const c = S.currentPageModel?.getComponentById(t)?.model;
629
- c && (c.locked = !c.locked);
636
+ const r = S.currentPageModel?.getComponentById(t)?.model;
637
+ r && (r.locked = !r.locked);
630
638
  },
631
- toggleSectionVisibility: (e, t, c) => {
639
+ toggleSectionVisibility: (e, t, r) => {
632
640
  v(e);
633
- const r = S.currentPageModel?.getComponentById(t)?.model;
634
- r && (r.visibility = c);
641
+ const c = S.currentPageModel?.getComponentById(t)?.model;
642
+ c && (c.visibility = r);
635
643
  },
636
- moveSection: (e, t, c, r) => {
644
+ moveSection: (e, t, r, c) => {
637
645
  const d = v(e), { page: i } = d, l = S.currentPageModel;
638
646
  if (!l)
639
647
  throw new Error(`Page model for ${e} is not available`);
@@ -648,20 +656,20 @@ const _e = () => {
648
656
  containerType: "root",
649
657
  index: i.sectionIds.indexOf(p)
650
658
  };
651
- const I = g.model;
659
+ const P = g.model;
652
660
  return {
653
661
  section: a,
654
- container: I,
662
+ container: P,
655
663
  containerType: "layout-block",
656
- index: I.sectionIds.indexOf(p)
664
+ index: P.sectionIds.indexOf(p)
657
665
  };
658
666
  }, u = m(t);
659
667
  if (!u)
660
668
  throw new Error(`Section ${t} not found`);
661
669
  o.doc.transact(() => {
662
- if (c.startsWith("layout-")) {
663
- const a = c.replace("layout-", ""), I = l.getComponentById(a)?.model;
664
- if (!I || I.component !== "layout-block")
670
+ if (r.startsWith("layout-")) {
671
+ const a = r.replace("layout-", ""), P = l.getComponentById(a)?.model;
672
+ if (!P || P.component !== "layout-block")
665
673
  throw new Error(`Layout block ${a} not found`);
666
674
  if (a === t || ((E, L) => {
667
675
  const D = l.getComponentById(E), G = l.getComponentById(L);
@@ -677,14 +685,14 @@ const _e = () => {
677
685
  })(t, a))
678
686
  return;
679
687
  const x = JSON.parse(JSON.stringify(u.section));
680
- I.sections || (I.sections = {}), I.sectionIds || (I.sectionIds = []), I.sections[t] = x, I.sectionIds.push(t), u.container.sectionIds.splice(u.index, 1), u.containerType === "layout-block" && delete u.container.sections[t];
688
+ P.sections || (P.sections = {}), P.sectionIds || (P.sectionIds = []), P.sections[t] = x, P.sectionIds.push(t), u.container.sectionIds.splice(u.index, 1), u.containerType === "layout-block" && delete u.container.sections[t];
681
689
  return;
682
690
  }
683
- const p = m(c);
691
+ const p = m(r);
684
692
  if (!p)
685
- throw new Error(`Target section ${c} not found`);
693
+ throw new Error(`Target section ${r} not found`);
686
694
  let s = p.index;
687
- if (r === "bottom" && (s = p.index + 1), u.container === p.container) {
695
+ if (c === "bottom" && (s = p.index + 1), u.container === p.container) {
688
696
  const { sectionIds: a } = u.container;
689
697
  a.splice(u.index, 1), u.index < s && (s -= 1), a.splice(s, 0, t);
690
698
  } else {
@@ -695,18 +703,18 @@ const _e = () => {
695
703
  },
696
704
  copySection: (e, t) => {
697
705
  v(e);
698
- const c = S.currentPageModel?.getComponentById(t);
699
- if (!c?.model)
706
+ const r = S.currentPageModel?.getComponentById(t);
707
+ if (!r?.model)
700
708
  throw new Error(`Section ${t} is not exists`);
701
- const r = JSON.parse(JSON.stringify(c.model)), d = z(r), i = d.id, l = c?.parent;
709
+ const c = JSON.parse(JSON.stringify(r.model)), d = z(c), i = d.id, l = r?.parent;
702
710
  if (l) {
703
711
  if (l.model.sections[i] = d, l.model.sectionIds.push(i), S.currentPage?.dataSource?.[t] && (S.currentPage.dataSource[i] = JSON.parse(
704
712
  JSON.stringify(S.currentPage.dataSource[t])
705
713
  ), d.component === "layout-block")) {
706
714
  const m = (u, p) => {
707
715
  const s = u.sectionIds, a = p.sectionIds;
708
- s?.forEach((g, I) => {
709
- const N = a?.[I];
716
+ s?.forEach((g, P) => {
717
+ const N = a?.[P];
710
718
  if (N) {
711
719
  if (N && S.currentPage?.dataSource) {
712
720
  const L = S.currentPage.dataSource[N];
@@ -717,14 +725,14 @@ const _e = () => {
717
725
  }
718
726
  });
719
727
  };
720
- d.sectionIds && r.sectionIds && m(d, r);
728
+ d.sectionIds && c.sectionIds && m(d, c);
721
729
  }
722
730
  y.setCurrentSectionId(e, i);
723
731
  }
724
732
  return d;
725
733
  },
726
734
  extractSectionToComponentTemplate: (e, t) => {
727
- const c = v(e), { page: r } = c, i = S.currentPageModel?.getComponentById(t)?.model;
735
+ const r = v(e), { page: c } = r, i = S.currentPageModel?.getComponentById(t)?.model;
728
736
  if (!i) {
729
737
  console.warn(`Section ${t} is not exists`);
730
738
  return;
@@ -735,11 +743,11 @@ const _e = () => {
735
743
  return;
736
744
  }
737
745
  const m = (s, a = []) => (s && (a.push(s.id), s.sectionIds?.forEach((g) => {
738
- const I = s.sections?.[g];
739
- m(I, a);
746
+ const P = s.sections?.[g];
747
+ m(P, a);
740
748
  })), a), p = m(i).reduce(
741
749
  (s, a) => {
742
- const g = r.dataSource?.[a];
750
+ const g = c.dataSource?.[a];
743
751
  return g && (s[a] = JSON.parse(JSON.stringify(g))), s;
744
752
  },
745
753
  {}
@@ -752,10 +760,10 @@ const _e = () => {
752
760
  addComponentTemplate: ({
753
761
  name: e,
754
762
  description: t,
755
- section: c,
756
- dataSource: r
763
+ section: r,
764
+ dataSource: c
757
765
  }) => {
758
- const d = B(), i = (/* @__PURE__ */ new Date()).toISOString(), l = _(c), m = r ? _(r) : void 0;
766
+ const d = B(), i = (/* @__PURE__ */ new Date()).toISOString(), l = R(r), m = c ? R(c) : void 0;
759
767
  return o.doc.transact(() => {
760
768
  const u = Object.values(n.components).length;
761
769
  n.components[d] = {
@@ -776,13 +784,13 @@ const _e = () => {
776
784
  }), n.components[d];
777
785
  },
778
786
  addDataSource: (e) => {
779
- const t = e.id ?? B(), c = {
787
+ const t = e.id ?? B(), r = {
780
788
  ...e ?? {},
781
789
  id: t,
782
790
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
783
791
  };
784
792
  return o.doc.transact(() => {
785
- n.dataSourceIds ??= [], n.dataSources ??= {}, n.dataSourceIds.push(t), n.dataSources[t] = c;
793
+ n.dataSourceIds ??= [], n.dataSources ??= {}, n.dataSourceIds.push(t), n.dataSources[t] = r;
786
794
  }), n.dataSources[t];
787
795
  },
788
796
  deleteDataSource: (e) => {
@@ -800,9 +808,9 @@ const _e = () => {
800
808
  actions: U,
801
809
  localActions: y,
802
810
  ...S,
803
- getComponentTemplateContext: J
811
+ getComponentTemplateContext: $
804
812
  };
805
- }, re = () => {
813
+ }, ce = () => {
806
814
  const { projectId: o } = he();
807
815
  return o ?? Ee() ?? "";
808
816
  }, pt = () => window.__PROJECT_SLUG__ ?? "";
@@ -810,13 +818,13 @@ function Re(o) {
810
818
  const { resources: n } = o;
811
819
  if (!n.components)
812
820
  return {};
813
- const P = {};
821
+ const I = {};
814
822
  return window?.blocklet?.componentMountPoints?.forEach((f) => {
815
- P[f.did] = f;
823
+ I[f.did] = f;
816
824
  }), Object.fromEntries(
817
825
  Object.entries(n.components).map(([f, { blockletId: O, component: w }]) => [
818
826
  f,
819
- { data: w, blockletId: O, blockletTitle: P[O]?.title || O }
827
+ { data: w, blockletId: O, blockletTitle: I[O]?.title || O }
820
828
  ])
821
829
  );
822
830
  }
@@ -832,7 +840,7 @@ function $e(o) {
832
840
  }
833
841
  const mt = () => $e(_e().state);
834
842
  function z(o) {
835
- const n = JSON.parse(JSON.stringify(o)), P = B();
843
+ const n = JSON.parse(JSON.stringify(o)), I = B();
836
844
  if (n.component === "layout-block") {
837
845
  const f = { ...n.config ?? {} }, O = n.sectionIds?.map((w) => {
838
846
  const A = n.sections?.[w], h = z(n.sections?.[w]), k = h.id;
@@ -850,7 +858,7 @@ function z(o) {
850
858
  }
851
859
  return {
852
860
  ...n,
853
- id: P
861
+ id: I
854
862
  };
855
863
  }
856
864
  export {
@@ -869,5 +877,5 @@ export {
869
877
  Je as l,
870
878
  Re as m,
871
879
  it as t,
872
- re as u
880
+ ce as u
873
881
  };