@nextblock-cms/cortex 0.14.3 → 0.14.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- import { tool as S } from "ai";
2
- import { createCortexDatabaseAgentTools as an } from "./ai-global-agent-db-tools.es.js";
3
- import { createCortexCustomBlockTools as sn } from "./ai-global-agent-custom-block-tools.es.js";
4
- import { editorDocumentFromHtml as pt } from "./editor-document-from-html.es.js";
1
+ import { tool as v } from "ai";
2
+ import { createCortexDatabaseAgentTools as cn } from "./ai-global-agent-db-tools.es.js";
3
+ import { createCortexCustomBlockTools as ln } from "./ai-global-agent-custom-block-tools.es.js";
4
+ import { editorDocumentFromHtml as gt } from "./editor-document-from-html.es.js";
5
5
  import "./zod-config.es.js";
6
6
  import { z as i } from "zod";
7
- const K = [
7
+ const V = [
8
8
  "text",
9
9
  "heading",
10
10
  "image",
@@ -19,7 +19,25 @@ const K = [
19
19
  "cart",
20
20
  "checkout",
21
21
  "product_details"
22
- ], ln = 1e4, cn = {
22
+ ];
23
+ async function J(e, t, n) {
24
+ if (e?.recordRevision)
25
+ try {
26
+ return await e.recordRevision({ contentType: t, entityId: n, phase: "capture" });
27
+ } catch (r) {
28
+ console.error("Cortex AI: failed to capture revision baseline", r);
29
+ return;
30
+ }
31
+ }
32
+ async function G(e, t, n, r) {
33
+ if (!(!e?.recordRevision || r === void 0))
34
+ try {
35
+ await e.recordRevision({ baseline: r, contentType: t, entityId: n, phase: "commit" });
36
+ } catch (o) {
37
+ console.error("Cortex AI: failed to record revision", o);
38
+ }
39
+ }
40
+ const un = 1e4, dn = {
23
41
  arabic: "ar",
24
42
  chinese: "zh",
25
43
  dutch: "nl",
@@ -34,40 +52,40 @@ const K = [
34
52
  portuguese: "pt",
35
53
  russian: "ru",
36
54
  spanish: "es"
37
- }, mt = i.string().trim().min(1).max(2048).refine(
55
+ }, ft = i.string().trim().min(1).max(2048).refine(
38
56
  (e) => e.startsWith("/") || e.startsWith("#") || e.startsWith("http://") || e.startsWith("https://") || e.startsWith("mailto:") || e.startsWith("tel:"),
39
57
  "URL must be a relative path, hash link, http(s) URL, mailto URL, or tel URL."
40
- ), Xe = i.strictObject({
58
+ ), Ze = i.strictObject({
41
59
  label: i.string().trim().min(1).max(120),
42
60
  target: i.enum(["_self", "_blank"]).optional(),
43
- url: mt
44
- }), gt = Xe.extend({
45
- children: i.array(Xe).max(20).optional()
46
- }), un = i.strictObject({
61
+ url: ft
62
+ }), ht = Ze.extend({
63
+ children: i.array(Ze).max(20).optional()
64
+ }), pn = i.strictObject({
47
65
  label: i.string().trim().min(1).max(120).optional(),
48
- url: mt.optional()
66
+ url: ft.optional()
49
67
  }).refine((e) => !!(e.label || e.url), {
50
68
  message: "Navigation item match requires label or url."
51
- }), de = i.strictObject({
52
- items: i.array(gt).min(1).max(30),
69
+ }), ge = i.strictObject({
70
+ items: i.array(ht).min(1).max(30),
53
71
  languageCode: i.string().trim().min(2).max(80).default("en").describe('Locale code or language name, for example "en", "fr", "English", or "French".'),
54
- match: un.optional().describe('For mode "update", identifies the existing navigation item to update.'),
72
+ match: pn.optional().describe('For mode "update", identifies the existing navigation item to update.'),
55
73
  mode: i.enum(["append", "replace", "update"]).default("append")
56
- }), pe = i.strictObject({
74
+ }), fe = i.strictObject({
57
75
  copyright: i.record(i.string().trim().min(2).max(12), i.string().trim().min(1).max(500)).optional(),
58
76
  languageCode: i.string().trim().min(2).max(80).default("en").describe('Locale code or language name, for example "en", "fr", "English", or "French".'),
59
- links: i.array(gt).min(1).max(30).optional()
60
- }), je = i.strictObject({
77
+ links: i.array(ht).min(1).max(30).optional()
78
+ }), Be = i.strictObject({
61
79
  limit: i.number().int().min(1).max(8).default(4),
62
80
  query: i.string().trim().min(2).max(300)
63
- }), ft = i.object({
81
+ }), yt = i.object({
64
82
  currency: i.string().trim().min(3).max(3).optional().describe(
65
83
  "Optional currency code for currency-specific monetary reports (e.g., USD, CAD). Do not set this for plain order-status counts unless the user asks for a currency."
66
84
  ),
67
85
  query: i.string().describe("The analytical question about orders, products, or revenue."),
68
86
  reportType: i.enum(["revenue", "orders", "products", "general"]).optional().default("general").describe("The focus area of the statistical report."),
69
87
  timeRange: i.enum(["today", "this_month", "last_7_days", "last_30_days", "last_month", "last_90_days", "all_time"]).optional().default("all_time").describe("The time period for the report. Use all_time for current order-status counts unless the user names a specific period.")
70
- }), ht = i.strictObject({
88
+ }), _t = i.strictObject({
71
89
  contentType: i.enum(["page", "post", "product"]),
72
90
  currentEditor: i.strictObject({
73
91
  blockId: i.union([i.number().int().positive(), i.string().trim().min(1).max(120)]).nullable().optional(),
@@ -79,10 +97,10 @@ const K = [
79
97
  slug: i.string().trim().min(1).max(300).nullable().optional(),
80
98
  title: i.string().trim().min(1).max(300).nullable().optional(),
81
99
  translationGroupId: i.string().trim().min(1).max(120).nullable().optional()
82
- }), yt = i.strictObject({
100
+ }), bt = i.strictObject({
83
101
  includeBlockContent: i.boolean().default(!1),
84
102
  includeBlocks: i.boolean().default(!0)
85
- }), me = i.strictObject({
103
+ }), he = i.strictObject({
86
104
  fields: i.strictObject({
87
105
  // Accepts an HTML string as well as an editor document — see
88
106
  // validateProductDescriptionJson.
@@ -99,36 +117,36 @@ const K = [
99
117
  subtitle: i.string().max(300).nullable().optional(),
100
118
  title: i.string().trim().min(1).max(300).optional()
101
119
  }).partial()
102
- }), ge = i.strictObject({
120
+ }), ye = i.strictObject({
103
121
  blockId: i.number().int().positive(),
104
- blockType: i.enum(K).optional(),
122
+ blockType: i.enum(V).optional(),
105
123
  content: i.record(i.string(), i.unknown())
106
- }), fe = i.strictObject({
124
+ }), _e = i.strictObject({
107
125
  blockIndex: i.number().int().min(0),
108
- blockType: i.enum(K).optional(),
126
+ blockType: i.enum(V).optional(),
109
127
  columnIndex: i.number().int().min(0),
110
128
  content: i.record(i.string(), i.unknown()),
111
129
  parentBlockId: i.number().int().positive()
112
- }), dn = i.enum(["page", "post", "product"]), H = i.strictObject({
113
- contentType: dn.optional(),
130
+ }), mn = i.enum(["page", "post", "product"]), W = i.strictObject({
131
+ contentType: mn.optional(),
114
132
  entityId: i.union([i.number().int().positive(), i.string().trim().min(1).max(120)]).optional(),
115
133
  slug: i.string().trim().min(1).max(300).optional(),
116
134
  title: i.string().trim().min(1).max(300).optional()
117
- }), Q = i.strictObject({
118
- blockType: i.enum(K),
135
+ }), te = i.strictObject({
136
+ blockType: i.enum(V),
119
137
  content: i.record(i.string(), i.unknown()),
120
138
  order: i.number().int().min(0).optional()
121
- }), he = H.extend({
139
+ }), be = W.extend({
122
140
  images: i.array(i.string().trim().min(1).max(2048)).min(1).max(12).describe(
123
141
  "External https image URLs (imported into the media library automatically) and/or existing media library ids. The first entry is the feature image (pages/posts) or the main product image (products)."
124
142
  )
125
- }), ye = H.extend({
143
+ }), we = W.extend({
126
144
  anchorBlockId: i.number().int().positive().optional(),
127
- anchorBlockType: i.enum(K).optional(),
128
- block: Q,
145
+ anchorBlockType: i.enum(V).optional(),
146
+ block: te,
129
147
  position: i.enum(["before", "after", "start", "end"]).default("end")
130
- }), _e = i.strictObject({
131
- blocks: i.array(Q).max(20).optional(),
148
+ }), ke = i.strictObject({
149
+ blocks: i.array(te).max(20).optional(),
132
150
  contactEmail: i.string().email().optional(),
133
151
  feature_image_id: i.string().trim().min(1).max(2048).nullable().optional(),
134
152
  languageCode: i.string().trim().min(2).max(80).optional(),
@@ -138,8 +156,8 @@ const K = [
138
156
  status: i.enum(["draft", "published", "archived"]).default("draft"),
139
157
  title: i.string().trim().min(1).max(300),
140
158
  translationGroupId: i.string().trim().min(1).max(120).optional()
141
- }), be = i.strictObject({
142
- blocks: i.array(Q).max(20).optional(),
159
+ }), Ie = i.strictObject({
160
+ blocks: i.array(te).max(20).optional(),
143
161
  excerpt: i.string().max(2e3).nullable().optional(),
144
162
  feature_image_id: i.string().trim().min(1).max(2048).nullable().optional(),
145
163
  label: i.string().max(120).nullable().optional(),
@@ -152,11 +170,11 @@ const K = [
152
170
  subtitle: i.string().max(300).nullable().optional(),
153
171
  title: i.string().trim().min(1).max(300),
154
172
  translationGroupId: i.string().trim().min(1).max(120).optional()
155
- }), ke = i.strictObject({
173
+ }), Te = i.strictObject({
156
174
  // Products render "Product Description Blocks" exactly like pages/posts render
157
175
  // their blocks (blocks.product_id). This is the richest body and takes
158
176
  // precedence over description_html on the public product page.
159
- blocks: i.array(Q).max(20).optional().describe(
177
+ blocks: i.array(te).max(20).optional().describe(
160
178
  "Content blocks for the product description area, same block vocabulary as create_cms_page. Rendered on the public product page in place of the plain description."
161
179
  ),
162
180
  // Fallback body input. A plain string is something every model can produce
@@ -190,53 +208,53 @@ const K = [
190
208
  trial_requires_payment_method: i.boolean().default(!1),
191
209
  translationGroupId: i.string().trim().min(1).max(120).optional(),
192
210
  upc: i.string().max(120).nullable().optional()
193
- }), we = H.extend({
211
+ }), xe = W.extend({
194
212
  currencyCode: i.string().trim().min(3).max(3).optional(),
195
213
  endsAt: i.string().max(80).nullable().optional(),
196
214
  field: i.string().trim().min(1).max(120),
197
215
  startsAt: i.string().max(80).nullable().optional(),
198
216
  value: i.unknown()
199
- }), _t = H, Ie = H, bt = i.discriminatedUnion("tool", [
200
- i.strictObject({ input: _e, tool: i.literal("create_cms_page") }),
201
- i.strictObject({ input: be, tool: i.literal("create_cms_post") }),
202
- i.strictObject({ input: ke, tool: i.literal("create_cms_product") }),
203
- i.strictObject({ input: Ie, tool: i.literal("delete_cms_item") }),
204
- i.strictObject({ input: we, tool: i.literal("update_cms_item_field") }),
205
- i.strictObject({ input: ge, tool: i.literal("update_content_block") }),
206
- i.strictObject({ input: ye, tool: i.literal("insert_content_block") }),
207
- i.strictObject({ input: me, tool: i.literal("update_current_cms_fields") }),
208
- i.strictObject({ input: pe, tool: i.literal("update_footer") }),
209
- i.strictObject({ input: de, tool: i.literal("update_navigation_bar") }),
210
- i.strictObject({ input: fe, tool: i.literal("update_section_column_block") }),
211
- i.strictObject({ input: he, tool: i.literal("set_content_images") })
212
- ]), pn = i.union([
213
- _e.extend({ tool: i.literal("create_cms_page") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
214
- be.extend({ tool: i.literal("create_cms_post") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
215
- ke.extend({ tool: i.literal("create_cms_product") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
216
- Ie.extend({ tool: i.literal("delete_cms_item") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
217
- we.extend({ tool: i.literal("update_cms_item_field") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
218
- ge.extend({ tool: i.literal("update_content_block") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
219
- ye.extend({ tool: i.literal("insert_content_block") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
220
- me.extend({ tool: i.literal("update_current_cms_fields") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
221
- pe.extend({ tool: i.literal("update_footer") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
222
- de.extend({ tool: i.literal("update_navigation_bar") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
223
- fe.extend({ tool: i.literal("update_section_column_block") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
224
- he.extend({ tool: i.literal("set_content_images") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e }))
225
- ]), mn = i.string().transform((e, t) => {
226
- const n = _n(e);
217
+ }), wt = W, Ce = W, kt = i.discriminatedUnion("tool", [
218
+ i.strictObject({ input: ke, tool: i.literal("create_cms_page") }),
219
+ i.strictObject({ input: Ie, tool: i.literal("create_cms_post") }),
220
+ i.strictObject({ input: Te, tool: i.literal("create_cms_product") }),
221
+ i.strictObject({ input: Ce, tool: i.literal("delete_cms_item") }),
222
+ i.strictObject({ input: xe, tool: i.literal("update_cms_item_field") }),
223
+ i.strictObject({ input: ye, tool: i.literal("update_content_block") }),
224
+ i.strictObject({ input: we, tool: i.literal("insert_content_block") }),
225
+ i.strictObject({ input: he, tool: i.literal("update_current_cms_fields") }),
226
+ i.strictObject({ input: fe, tool: i.literal("update_footer") }),
227
+ i.strictObject({ input: ge, tool: i.literal("update_navigation_bar") }),
228
+ i.strictObject({ input: _e, tool: i.literal("update_section_column_block") }),
229
+ i.strictObject({ input: be, tool: i.literal("set_content_images") })
230
+ ]), gn = i.union([
231
+ ke.extend({ tool: i.literal("create_cms_page") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
232
+ Ie.extend({ tool: i.literal("create_cms_post") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
233
+ Te.extend({ tool: i.literal("create_cms_product") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
234
+ Ce.extend({ tool: i.literal("delete_cms_item") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
235
+ xe.extend({ tool: i.literal("update_cms_item_field") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
236
+ ye.extend({ tool: i.literal("update_content_block") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
237
+ we.extend({ tool: i.literal("insert_content_block") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
238
+ he.extend({ tool: i.literal("update_current_cms_fields") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
239
+ fe.extend({ tool: i.literal("update_footer") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
240
+ ge.extend({ tool: i.literal("update_navigation_bar") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
241
+ _e.extend({ tool: i.literal("update_section_column_block") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e })),
242
+ be.extend({ tool: i.literal("set_content_images") }).transform(({ tool: e, ...t }) => ({ input: t, tool: e }))
243
+ ]), fn = i.string().transform((e, t) => {
244
+ const n = wn(e);
227
245
  return n.success ? n.action : (t.addIssue({
228
246
  code: "custom",
229
247
  message: n.message
230
248
  }), i.NEVER);
231
- }), gn = i.union([
232
- bt,
233
- pn,
234
- mn
235
- ]), kt = i.strictObject({
236
- actions: i.array(gn).min(1).max(8),
249
+ }), hn = i.union([
250
+ kt,
251
+ gn,
252
+ fn
253
+ ]), It = i.strictObject({
254
+ actions: i.array(hn).min(1).max(8),
237
255
  summary: i.string().trim().min(1).max(500).optional()
238
256
  });
239
- function fn(e) {
257
+ function yn(e) {
240
258
  const t = [];
241
259
  let n = "", r = 0, o = null, a = !1;
242
260
  for (const s of e) {
@@ -264,7 +282,7 @@ function fn(e) {
264
282
  }
265
283
  return n.trim() && t.push(n.trim()), t;
266
284
  }
267
- function Qe(e) {
285
+ function et(e) {
268
286
  let t = "";
269
287
  for (let n = 0; n < e.length; n++) {
270
288
  const r = e[n];
@@ -291,24 +309,24 @@ function Qe(e) {
291
309
  }
292
310
  return t.replace(/\bTrue\b/g, "true").replace(/\bFalse\b/g, "false").replace(/\bNone\b/g, "null");
293
311
  }
294
- function hn(e) {
312
+ function _n(e) {
295
313
  const t = e.trim();
296
- return t.startsWith("'") && t.endsWith("'") || t.startsWith('"') && t.endsWith('"') || t.startsWith("[") || t.startsWith("{") ? JSON.parse(Qe(t)) : /^-?\d+(?:\.\d+)?$/.test(t) ? Number(t) : t === "true" || t === "True" ? !0 : t === "false" || t === "False" ? !1 : t === "null" || t === "None" ? null : t;
314
+ return t.startsWith("'") && t.endsWith("'") || t.startsWith('"') && t.endsWith('"') || t.startsWith("[") || t.startsWith("{") ? JSON.parse(et(t)) : /^-?\d+(?:\.\d+)?$/.test(t) ? Number(t) : t === "true" || t === "True" ? !0 : t === "false" || t === "False" ? !1 : t === "null" || t === "None" ? null : t;
297
315
  }
298
- function yn(e) {
316
+ function bn(e) {
299
317
  const t = {};
300
- for (const n of fn(e)) {
318
+ for (const n of yn(e)) {
301
319
  const r = n.indexOf("=");
302
320
  if (r <= 0)
303
321
  throw new Error(`Expected key=value argument, received "${n}".`);
304
322
  const o = n.slice(0, r).trim();
305
323
  if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(o))
306
324
  throw new Error(`Invalid argument name "${o}".`);
307
- t[o] = hn(n.slice(r + 1));
325
+ t[o] = _n(n.slice(r + 1));
308
326
  }
309
327
  return t;
310
328
  }
311
- function _n(e) {
329
+ function wn(e) {
312
330
  const n = e.trim().match(/^([a-z_]+)\(([\s\S]*)\)$/);
313
331
  if (!n)
314
332
  return {
@@ -318,37 +336,37 @@ function _n(e) {
318
336
  const r = n[1];
319
337
  let o;
320
338
  try {
321
- o = yn(n[2]);
322
- } catch (l) {
339
+ o = bn(n[2]);
340
+ } catch (c) {
323
341
  return {
324
- message: l instanceof Error ? l.message : "Could not parse action-plan command arguments.",
342
+ message: c instanceof Error ? c.message : "Could not parse action-plan command arguments.",
325
343
  success: !1
326
344
  };
327
345
  }
328
- const a = { input: o, tool: r }, s = bt.safeParse(a);
346
+ const a = { input: o, tool: r }, s = kt.safeParse(a);
329
347
  return s.success ? {
330
348
  action: s.data,
331
349
  success: !0
332
350
  } : {
333
- message: `Invalid action-plan command "${r}": ${s.error.issues.map((l) => l.message).join("; ")}`,
351
+ message: `Invalid action-plan command "${r}": ${s.error.issues.map((c) => c.message).join("; ")}`,
334
352
  success: !1
335
353
  };
336
354
  }
337
- function bn(e) {
355
+ function kn(e) {
338
356
  return e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/\s+/g, " ").trim();
339
357
  }
340
- function ne(e, t) {
358
+ function ie(e, t) {
341
359
  return t.some((n) => e.includes(n));
342
360
  }
343
- function so(e) {
344
- const t = bn(e), n = ne(t, ["add ", "insert ", "put ", "create "]), r = ne(t, [
361
+ function lo(e) {
362
+ const t = kn(e), n = ie(t, ["add ", "insert ", "put ", "create "]), r = ie(t, [
345
363
  "title",
346
364
  "heading",
347
365
  "description",
348
366
  "intro",
349
367
  "copy",
350
368
  "paragraph"
351
- ]), o = t.includes("form") && ne(t, ["above", "before"]), a = t.includes("contact page") || t.includes("contact pages") || t.includes("contact us") || t.includes("contactez-nous"), s = t.includes("english") && ne(t, ["french", "francais", "francaise"]);
369
+ ]), o = t.includes("form") && ie(t, ["above", "before"]), a = t.includes("contact page") || t.includes("contact pages") || t.includes("contact us") || t.includes("contactez-nous"), s = t.includes("english") && ie(t, ["french", "francais", "francaise"]);
352
370
  return !n || !r || !o || !a || !s ? null : {
353
371
  actions: [
354
372
  {
@@ -385,12 +403,12 @@ function so(e) {
385
403
  summary: "Add visible title and description copy above the forms on the English and French Contact pages."
386
404
  };
387
405
  }
388
- const kn = i.enum(K), Ze = i.object({
406
+ const In = i.enum(V), tt = i.object({
389
407
  direction: i.string().optional(),
390
408
  stops: i.array(i.object({ color: i.string(), position: i.number() })),
391
409
  type: i.enum(["linear", "radial"])
392
- }), wn = i.object({
393
- gradient: Ze.optional(),
410
+ }), Tn = i.object({
411
+ gradient: tt.optional(),
394
412
  image: i.object({
395
413
  alt_text: i.string().optional(),
396
414
  blur_data_url: i.string().optional(),
@@ -399,7 +417,7 @@ const kn = i.enum(K), Ze = i.object({
399
417
  media_id: i.string().optional(),
400
418
  object_key: i.string().optional(),
401
419
  overlay: i.object({
402
- gradient: Ze,
420
+ gradient: tt,
403
421
  type: i.literal("gradient")
404
422
  }).optional(),
405
423
  position: i.enum(["center", "top", "bottom", "left", "right"]),
@@ -411,13 +429,13 @@ const kn = i.enum(K), Ze = i.object({
411
429
  solid_color: i.string().optional(),
412
430
  theme: i.enum(["primary", "secondary", "muted", "accent", "destructive"]).optional(),
413
431
  type: i.enum(["none", "theme", "solid", "gradient", "image"])
414
- }), In = i.object({
415
- block_type: kn,
432
+ }), xn = i.object({
433
+ block_type: In,
416
434
  content: i.record(i.string(), i.any()),
417
435
  temp_id: i.string().optional()
418
- }), Tn = i.object({
419
- background: wn,
420
- column_blocks: i.array(i.array(In)),
436
+ }), Cn = i.object({
437
+ background: Tn,
438
+ column_blocks: i.array(i.array(xn)),
421
439
  column_gap: i.enum(["none", "sm", "md", "lg", "xl"]),
422
440
  container_type: i.enum(["full-width", "container", "container-sm", "container-lg", "container-xl"]),
423
441
  padding: i.object({
@@ -430,7 +448,7 @@ const kn = i.enum(K), Ze = i.object({
430
448
  tablet: i.union([i.literal(1), i.literal(2), i.literal(3)])
431
449
  }),
432
450
  vertical_alignment: i.enum(["start", "center", "end", "stretch"]).optional()
433
- }), xn = {
451
+ }), vn = {
434
452
  button: i.object({
435
453
  position: i.enum(["left", "center", "right"]).optional(),
436
454
  size: i.enum(["default", "sm", "lg", "full"]).optional(),
@@ -501,7 +519,7 @@ const kn = i.enum(K), Ze = i.object({
501
519
  title: i.string().optional(),
502
520
  type: i.enum(["latest", "category", "manual"]).default("latest")
503
521
  }),
504
- section: Tn,
522
+ section: Cn,
505
523
  testimonial: i.object({
506
524
  author_name: i.string().min(1),
507
525
  author_title: i.string().optional(),
@@ -518,17 +536,17 @@ const kn = i.enum(K), Ze = i.object({
518
536
  url: i.string()
519
537
  })
520
538
  };
521
- function Cn(e) {
522
- return K.includes(e);
523
- }
524
539
  function Sn(e) {
540
+ return V.includes(e);
541
+ }
542
+ function En(e) {
525
543
  return typeof e?.validateBlockContent == "function" ? e.validateBlockContent : null;
526
544
  }
527
- function vn(e, t, n) {
528
- const r = Sn(n);
545
+ function $n(e, t, n) {
546
+ const r = En(n);
529
547
  if (r)
530
548
  return r(e, t);
531
- const o = xn[e].safeParse(t);
549
+ const o = vn[e].safeParse(t);
532
550
  return o.success ? { errors: [], isValid: !0, warnings: [] } : {
533
551
  errors: o.error.issues.map((a) => {
534
552
  const s = a.path.join(".");
@@ -538,13 +556,13 @@ function vn(e, t, n) {
538
556
  warnings: []
539
557
  };
540
558
  }
541
- function et() {
559
+ function nt() {
542
560
  return i.object({
543
561
  content: i.array(i.any()).optional(),
544
562
  type: i.literal("doc")
545
563
  });
546
564
  }
547
- function Le() {
565
+ function Re() {
548
566
  try {
549
567
  const { revalidatePath: e } = require("next/cache");
550
568
  return e;
@@ -557,7 +575,7 @@ function C(e) {
557
575
  throw new Error("A Supabase service client is required to execute Cortex AI global tools.");
558
576
  return e.supabase;
559
577
  }
560
- function En(e, t, n) {
578
+ function An(e, t, n) {
561
579
  let r;
562
580
  const o = new Promise((a) => {
563
581
  r = setTimeout(() => a(n()), t);
@@ -569,38 +587,38 @@ function En(e, t, n) {
569
587
  o
570
588
  ]);
571
589
  }
572
- function V(e) {
573
- const t = ht.safeParse(e?.pageContext);
590
+ function Y(e) {
591
+ const t = _t.safeParse(e?.pageContext);
574
592
  if (!t.success)
575
593
  throw new Error(
576
594
  "No current CMS page context is available. Open a page, post, or product edit screen before using this editing tool."
577
595
  );
578
596
  return t.data;
579
597
  }
580
- function Be(e) {
598
+ function qe(e) {
581
599
  const t = typeof e.entityId == "number" ? e.entityId : Number.parseInt(e.entityId, 10);
582
600
  if (!Number.isInteger(t) || t <= 0)
583
601
  throw new Error(`Current ${e.contentType} id must be a positive integer.`);
584
602
  return t;
585
603
  }
586
- function wt(e) {
604
+ function Tt(e) {
587
605
  const t = String(e.entityId || "").trim();
588
606
  if (!t)
589
607
  throw new Error(`Current ${e.contentType} id is missing.`);
590
608
  return t;
591
609
  }
592
- function Te(e) {
593
- return e.contentType === "product" ? wt(e) : Be(e);
610
+ function q(e) {
611
+ return e.contentType === "product" ? Tt(e) : qe(e);
594
612
  }
595
- const $n = /^https?:\/\//i, An = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
596
- async function Z(e, t, n) {
613
+ const Pn = /^https?:\/\//i, Nn = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
614
+ async function ne(e, t, n) {
597
615
  if (typeof e != "string")
598
616
  return null;
599
617
  const r = e.trim();
600
618
  if (!r)
601
619
  return null;
602
- if (!$n.test(r)) {
603
- if (An.test(r))
620
+ if (!Pn.test(r)) {
621
+ if (Nn.test(r))
604
622
  return r;
605
623
  throw new Error(
606
624
  `"${r}" is not a usable image reference — provide an https:// image URL or a media library id.`
@@ -616,10 +634,10 @@ async function Z(e, t, n) {
616
634
  throw new Error(`I could not import the image from that URL: ${a.error}`);
617
635
  return a.id;
618
636
  }
619
- async function It(e, t, n) {
637
+ async function xt(e, t, n) {
620
638
  const r = [];
621
639
  for (let o = 0; o < e.length; o += 1) {
622
- const a = await Z(
640
+ const a = await ne(
623
641
  e[o],
624
642
  t,
625
643
  `${n} image ${o + 1}`
@@ -628,11 +646,11 @@ async function It(e, t, n) {
628
646
  }
629
647
  return r;
630
648
  }
631
- async function Pn(e) {
649
+ async function Un(e) {
632
650
  const t = [...new Set(e.mediaIds)], { error: n } = await e.supabase.from("product_media").delete().eq("product_id", e.productId);
633
651
  if (n)
634
652
  throw new Error(
635
- `Could not clear the product's existing images: ${_(n)}`
653
+ `Could not clear the product's existing images: ${y(n)}`
636
654
  );
637
655
  if (t.length > 0) {
638
656
  const { error: r } = await e.supabase.from("product_media").insert(
@@ -643,79 +661,79 @@ async function Pn(e) {
643
661
  }))
644
662
  );
645
663
  if (r)
646
- throw new Error(`Could not save the product images: ${_(r)}`);
664
+ throw new Error(`Could not save the product images: ${y(r)}`);
647
665
  }
648
666
  return t;
649
667
  }
650
- async function xe(e) {
668
+ async function ve(e) {
651
669
  if (!e.productId)
652
670
  return !1;
653
671
  const { data: t, error: n } = await e.supabase.from("product_drafts").select("id, blocks, meta").eq("product_id", e.productId).maybeSingle();
654
672
  if (n || !t)
655
673
  return !1;
656
674
  const r = e.patch({
657
- blocks: Array.isArray(t.blocks) ? z(t.blocks) : [],
658
- meta: $(t.meta) ? z(t.meta) : {}
675
+ blocks: Array.isArray(t.blocks) ? K(t.blocks) : [],
676
+ meta: E(t.meta) ? K(t.meta) : {}
659
677
  }), o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
660
678
  if (r.blocks && (o.blocks = r.blocks), r.meta && (o.meta = r.meta), Object.keys(o).length === 1)
661
679
  return !1;
662
680
  const { error: a } = await e.supabase.from("product_drafts").update(o).eq("id", t.id);
663
681
  if (a)
664
682
  throw new Error(
665
- `The product was updated, but its open draft could not be kept in sync: ${_(
683
+ `The product was updated, but its open draft could not be kept in sync: ${y(
666
684
  a
667
685
  )}. Publishing that draft would undo this change — publish or discard it in the product editor first.`
668
686
  );
669
687
  return !0;
670
688
  }
671
- function Tt(e) {
689
+ function Ct(e) {
672
690
  return typeof e == "string" ? e.trim().replace(/^\/+|\/+$/g, "") : "";
673
691
  }
674
- function Nn(e, t) {
675
- const n = Tt(t ?? e.slug);
692
+ function On(e, t) {
693
+ const n = Ct(t ?? e.slug);
676
694
  return n ? e.contentType === "page" ? n === "home" ? "/" : `/${n}` : e.contentType === "post" ? `/article/${n}` : `/product/${n}` : null;
677
695
  }
678
- function Un(e) {
696
+ function Fn(e) {
679
697
  const t = String(e.entityId);
680
698
  return e.contentType === "page" ? `/cms/pages/${t}/edit` : e.contentType === "post" ? `/cms/posts/${t}/edit` : `/cms/products/${t}/edit`;
681
699
  }
682
- function U(e, t, n) {
683
- const r = e?.revalidatePath ?? Le();
700
+ function O(e, t, n) {
701
+ const r = e?.revalidatePath ?? Re();
684
702
  if (!r)
685
703
  return;
686
- r(Un(t));
687
- const o = Nn(t, n);
704
+ r(Fn(t));
705
+ const o = On(t, n);
688
706
  o && r(o), t.contentType === "page" && o !== "/" && r("/"), t.contentType === "product" && r("/cms/products");
689
707
  }
690
- function xt(e) {
691
- const t = e?.revalidatePath ?? Le();
708
+ function vt(e) {
709
+ const t = e?.revalidatePath ?? Re();
692
710
  t && (t("/", "layout"), t("/cms/navigation"));
693
711
  }
694
- function _(e) {
712
+ function y(e) {
695
713
  return e ? typeof e == "object" && "message" in e ? String(e.message || "Unknown database error.") : String(e) : "Unknown database error.";
696
714
  }
697
- async function On() {
715
+ async function jn() {
698
716
  return import("./ai-global-agent-ecommerce.es.js");
699
717
  }
700
- function Ee(e) {
701
- return e === null || typeof e != "object" ? JSON.stringify(e) : Array.isArray(e) ? `[${e.map((t) => Ee(t)).join(",")}]` : `{${Object.keys(e).filter((t) => t !== "temp_id").sort().map((t) => `${JSON.stringify(t)}:${Ee(e[t])}`).join(",")}}`;
718
+ function Ae(e) {
719
+ return e === null || typeof e != "object" ? JSON.stringify(e) : Array.isArray(e) ? `[${e.map((t) => Ae(t)).join(",")}]` : `{${Object.keys(e).filter((t) => t !== "temp_id").sort().map((t) => `${JSON.stringify(t)}:${Ae(e[t])}`).join(",")}}`;
702
720
  }
703
- function Fn(e) {
721
+ function Ln(e) {
704
722
  let t = 2166136261;
705
- const n = Ee(e);
723
+ const n = Ae(e);
706
724
  for (let r = 0; r < n.length; r++)
707
725
  t ^= n.charCodeAt(r), t = Math.imul(t, 16777619);
708
726
  return (t >>> 0).toString(16).padStart(8, "0");
709
727
  }
710
- function $e(e) {
728
+ function Pe(e) {
711
729
  return e.replace(/\s+/g, " ").trim().toUpperCase();
712
730
  }
713
- function jn(e, t, n) {
714
- return `${$e(`CONFIRM ${e} ${t}`)} #${Fn(n)}`;
731
+ function Bn(e, t, n) {
732
+ return `${Pe(`CONFIRM ${e} ${t}`)} #${Ln(n)}`;
715
733
  }
716
- function Ct(e) {
734
+ function St(e) {
717
735
  return {
718
- confirmationPhrase: jn(
736
+ confirmationPhrase: Bn(
719
737
  e.action,
720
738
  e.subject,
721
739
  e.payload
@@ -726,63 +744,63 @@ function Ct(e) {
726
744
  success: !0
727
745
  };
728
746
  }
729
- function O(e, t) {
747
+ function F(e, t) {
730
748
  const n = e[t];
731
749
  return typeof n == "string" && n.trim() ? n.trim() : null;
732
750
  }
733
- function M(e, t) {
751
+ function D(e, t) {
734
752
  const n = Number(e[t]);
735
753
  return Number.isFinite(n) ? n : null;
736
754
  }
737
- function N(e, t, n = `${t}s`) {
755
+ function U(e, t, n = `${t}s`) {
738
756
  return `${e} ${e === 1 ? t : n}`;
739
757
  }
740
- function Ln(e, t) {
741
- const n = O(t, "summary");
758
+ function Rn(e, t) {
759
+ const n = F(t, "summary");
742
760
  if (n)
743
761
  return n;
744
- const r = O(t, "title"), o = O(t, "slug"), a = O(t, "status"), s = O(t, "contentType"), l = O(t, "field"), u = O(t, "mode"), d = O(t, "languageCode"), c = M(t, "blockCount"), m = M(t, "itemCount"), h = M(t, "affectedCount");
762
+ const r = F(t, "title"), o = F(t, "slug"), a = F(t, "status"), s = F(t, "contentType"), c = F(t, "field"), u = F(t, "mode"), d = F(t, "languageCode"), l = D(t, "blockCount"), m = D(t, "itemCount"), h = D(t, "affectedCount");
745
763
  if (e === "create_cms_page" || e === "create_cms_post")
746
- return `Create ${a || "draft"} ${e === "create_cms_page" ? "page" : "post"} "${r || o || "Untitled"}"${o ? ` at slug "${o}"` : ""}${c !== null ? ` with ${N(c, "content block")}` : ""}.`;
764
+ return `Create ${a || "draft"} ${e === "create_cms_page" ? "page" : "post"} "${r || o || "Untitled"}"${o ? ` at slug "${o}"` : ""}${l !== null ? ` with ${U(l, "content block")}` : ""}.`;
747
765
  if (e === "create_cms_product") {
748
- const p = M(t, "imageCount"), g = M(t, "blockCount"), f = [
749
- p ? N(p, "image") : null,
750
- g ? N(g, "description block") : M(t, "descriptionLength") ? "a full description" : null
766
+ const p = D(t, "imageCount"), f = D(t, "blockCount"), g = [
767
+ p ? U(p, "image") : null,
768
+ f ? U(f, "description block") : D(t, "descriptionLength") ? "a full description" : null
751
769
  ].filter(Boolean);
752
- return `Create ${a || "draft"} product "${r || o || "Untitled"}"${o ? ` at slug "${o}"` : ""}${f.length ? ` with ${f.join(" and ")}` : ""}.`;
770
+ return `Create ${a || "draft"} product "${r || o || "Untitled"}"${o ? ` at slug "${o}"` : ""}${g.length ? ` with ${g.join(" and ")}` : ""}.`;
753
771
  }
754
772
  if (e === "update_cms_item_field")
755
- return `Update ${l || "one field"} on the ${s || "CMS item"} "${r || o || "selected item"}".`;
773
+ return `Update ${c || "one field"} on the ${s || "CMS item"} "${r || o || "selected item"}".`;
756
774
  if (e === "update_navigation_bar")
757
- return `${u === "append" ? "Add" : u === "update" ? "Update" : "Replace"} ${m !== null ? N(m, "navigation item") : "navigation items"} in the ${d || "selected"} header navigation.`;
775
+ return `${u === "append" ? "Add" : u === "update" ? "Update" : "Replace"} ${m !== null ? U(m, "navigation item") : "navigation items"} in the ${d || "selected"} header navigation.`;
758
776
  if (e === "update_footer") {
759
- const p = M(t, "linkCount");
760
- return `Update the ${d || "selected"} footer${p !== null ? ` with ${N(p, "link")}` : ""}.`;
777
+ const p = D(t, "linkCount");
778
+ return `Update the ${d || "selected"} footer${p !== null ? ` with ${U(p, "link")}` : ""}.`;
761
779
  }
762
- return e === "update_content_block" ? `Update the selected ${O(t, "blockType") || "content"} block.` : e === "insert_content_block" ? `Insert ${O(t, "blockType") || "content"} block on the ${s || "CMS item"} "${r || o || "selected item"}".` : e === "update_section_column_block" ? `Update the selected nested ${O(t, "nestedBlockType") || "section"} block.` : e === "delete_cms_item" || e === "prepare_delete_cms_item" ? `Delete ${h !== null ? N(h, s || "CMS item") : `the selected ${s || "CMS item"}`}${r || o ? ` for "${r || o}"` : ""}.` : "Complete the requested CMS change.";
780
+ return e === "update_content_block" ? `Update the selected ${F(t, "blockType") || "content"} block.` : e === "insert_content_block" ? `Insert ${F(t, "blockType") || "content"} block on the ${s || "CMS item"} "${r || o || "selected item"}".` : e === "update_section_column_block" ? `Update the selected nested ${F(t, "nestedBlockType") || "section"} block.` : e === "delete_cms_item" || e === "prepare_delete_cms_item" ? `Delete ${h !== null ? U(h, s || "CMS item") : `the selected ${s || "CMS item"}`}${r || o ? ` for "${r || o}"` : ""}.` : "Complete the requested CMS change.";
763
781
  }
764
- function P(e) {
782
+ function N(e) {
765
783
  if (e.context?.skipConfirmation)
766
784
  return null;
767
- const t = Ct(e), n = $e(e.context?.latestUserMessage || ""), r = $e(t.confirmationPhrase);
785
+ const t = St(e), n = Pe(e.context?.latestUserMessage || ""), r = Pe(t.confirmationPhrase);
768
786
  return n.includes(r) ? null : t;
769
787
  }
770
- function qe(e) {
788
+ function Me(e) {
771
789
  const t = e?.actorUserId;
772
790
  if (!t)
773
791
  throw new Error("A confirmed CMS mutation requires an authenticated admin actor.");
774
792
  return t;
775
793
  }
776
- function Re() {
794
+ function De() {
777
795
  return globalThis.crypto?.randomUUID?.() || `id-${Date.now()}-${Math.random().toString(36).slice(2)}`;
778
796
  }
779
- function q(e) {
797
+ function M(e) {
780
798
  return e.toLowerCase().trim().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 300);
781
799
  }
782
- function Me(e) {
800
+ function ze(e) {
783
801
  return (e || "USD").trim().toUpperCase();
784
802
  }
785
- const Bn = /* @__PURE__ */ new Set([
803
+ const qn = /* @__PURE__ */ new Set([
786
804
  "BIF",
787
805
  "CLP",
788
806
  "DJF",
@@ -800,131 +818,131 @@ const Bn = /* @__PURE__ */ new Set([
800
818
  "XOF",
801
819
  "XPF"
802
820
  ]);
803
- function qn(e) {
804
- return Bn.has(Me(e)) ? 0 : 2;
821
+ function Mn(e) {
822
+ return qn.has(ze(e)) ? 0 : 2;
805
823
  }
806
- function St(e, t) {
807
- return Math.round(e * 10 ** qn(t));
824
+ function Et(e, t) {
825
+ return Math.round(e * 10 ** Mn(t));
808
826
  }
809
- function Rn(e, t) {
827
+ function Dn(e, t) {
810
828
  return !e || typeof e != "object" || Array.isArray(e) ? {} : Object.entries(e).reduce(
811
829
  (n, [r, o]) => {
812
830
  if (typeof o == "number" && Number.isFinite(o) && o >= 0) {
813
- const a = Me(r || t);
814
- n[a] = St(o, a);
831
+ const a = ze(r || t);
832
+ n[a] = Et(o, a);
815
833
  }
816
834
  return n;
817
835
  },
818
836
  {}
819
837
  );
820
838
  }
821
- function ee(e, t) {
822
- if (!$(e))
839
+ function re(e, t) {
840
+ if (!E(e))
823
841
  throw new Error(`${t} content must be a JSON object.`);
824
842
  return JSON.parse(JSON.stringify(e));
825
843
  }
826
- function z(e) {
844
+ function K(e) {
827
845
  return JSON.parse(JSON.stringify(e));
828
846
  }
829
- function $(e) {
847
+ function E(e) {
830
848
  return !!(e && typeof e == "object" && !Array.isArray(e));
831
849
  }
832
- function Ae(e, t) {
833
- const n = z(e);
850
+ function Ne(e, t) {
851
+ const n = K(e);
834
852
  for (const [r, o] of Object.entries(t))
835
853
  if (o !== void 0) {
836
- if ($(o) && $(n[r])) {
837
- n[r] = Ae(n[r], o);
854
+ if (E(o) && E(n[r])) {
855
+ n[r] = Ne(n[r], o);
838
856
  continue;
839
857
  }
840
- n[r] = z(o);
858
+ n[r] = K(o);
841
859
  }
842
860
  return n;
843
861
  }
844
- function vt(e, t) {
862
+ function $t(e, t) {
845
863
  if (t.contentType === "product") {
846
- if (String(e.product_id ?? "") !== String(wt(t)))
864
+ if (String(e.product_id ?? "") !== String(Tt(t)))
847
865
  throw new Error(`Block ${e.id} does not belong to the current product being edited.`);
848
866
  return;
849
867
  }
850
- const n = Be(t);
868
+ const n = qe(t);
851
869
  if ((t.contentType === "page" ? Number(e.page_id) : Number(e.post_id)) !== n)
852
870
  throw new Error(
853
871
  `Block ${e.id} does not belong to the current ${t.contentType} being edited.`
854
872
  );
855
873
  }
856
- function ae(e, t) {
874
+ function le(e, t) {
857
875
  const n = typeof e == "string" ? e : "";
858
- if (!Cn(n))
876
+ if (!Sn(n))
859
877
  throw new Error(`${t} has unsupported block type "${n || "unknown"}".`);
860
878
  return n;
861
879
  }
862
- function Et(e, t, n) {
880
+ function At(e, t, n) {
863
881
  if (e && e !== t)
864
882
  throw new Error(
865
883
  `${n} is a "${t}" block. Refusing to update it as "${e}".`
866
884
  );
867
885
  }
868
- function D(e, t, n, r) {
869
- const o = vn(e, t, r);
886
+ function z(e, t, n, r) {
887
+ const o = $n(e, t, r);
870
888
  if (!o.isValid)
871
889
  throw new Error(
872
890
  `${n} content is invalid for block type "${e}": ${o.errors.join("; ")}`
873
891
  );
874
892
  }
875
- function $t(e) {
893
+ function Pt(e) {
876
894
  return e === "section";
877
895
  }
878
- function Mn(e) {
896
+ function zn(e) {
879
897
  return typeof e.html_content == "string" ? "text" : typeof e.text == "string" && typeof e.url == "string" ? "button" : typeof e.text_content == "string" ? "heading" : "media_id" in e || "object_key" in e || "external_url" in e ? "image" : typeof e.quote == "string" && typeof e.author_name == "string" ? "testimonial" : typeof e.url == "string" && ("controls" in e || "autoplay" in e || "title" in e) ? "video_embed" : Array.isArray(e.fields) || typeof e.recipient_email == "string" ? "form" : "postsPerPage" in e || "showPagination" in e ? "posts_grid" : typeof e.productId == "string" ? "featured_product" : "limit" in e && "type" in e ? "product_grid" : null;
880
898
  }
881
- function se(e) {
899
+ function ue(e) {
882
900
  return `ai-${e}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
883
901
  }
884
- function Pe(e, t, n) {
885
- if (!$(e))
902
+ function Ue(e, t, n) {
903
+ if (!E(e))
886
904
  throw new Error(`${t} must be a JSON object.`);
887
- const r = e.block_type ?? e.blockType, o = ae(r, t);
888
- if ($t(o))
905
+ const r = e.block_type ?? e.blockType, o = le(r, t);
906
+ if (Pt(o))
889
907
  throw new Error(`${t} cannot be a nested ${o} block.`);
890
- const a = Ut(
908
+ const a = Ft(
891
909
  o,
892
- ee(e.content, t),
910
+ re(e.content, t),
893
911
  t,
894
912
  n
895
- ), s = e.temp_id ?? e.tempId, l = typeof s == "string" && s.trim() ? s : se(o);
913
+ ), s = e.temp_id ?? e.tempId, c = typeof s == "string" && s.trim() ? s : ue(o);
896
914
  return {
897
915
  block_type: o,
898
916
  content: a,
899
- temp_id: l
917
+ temp_id: c
900
918
  };
901
919
  }
902
- function Dn(e, t) {
920
+ function Gn(e, t) {
903
921
  const n = [];
904
- if ("append_block" in e && n.push(Pe(e.append_block, "Nested block to append", t)), "append_blocks" in e) {
922
+ if ("append_block" in e && n.push(Ue(e.append_block, "Nested block to append", t)), "append_blocks" in e) {
905
923
  const r = e.append_blocks;
906
924
  if (!Array.isArray(r))
907
925
  throw new Error("append_blocks must be an array of nested block objects.");
908
926
  r.forEach((o, a) => {
909
- n.push(Pe(o, `Nested block to append ${a}`, t));
927
+ n.push(Ue(o, `Nested block to append ${a}`, t));
910
928
  });
911
929
  }
912
930
  return n;
913
931
  }
914
- function zn(e, t) {
932
+ function Kn(e, t) {
915
933
  if ("append_block" in e || "append_blocks" in e || "background" in e || "column_blocks" in e || "column_gap" in e || "container_type" in e || "padding" in e || "responsive_columns" in e || "vertical_alignment" in e)
916
934
  return null;
917
- const n = Mn(e);
935
+ const n = zn(e);
918
936
  if (!n)
919
937
  return null;
920
- const r = ee(e, `Nested ${n} block`);
921
- return D(n, r, `Nested ${n} block`, t), {
938
+ const r = re(e, `Nested ${n} block`);
939
+ return z(n, r, `Nested ${n} block`, t), {
922
940
  block_type: n,
923
941
  content: r,
924
- temp_id: se(n)
942
+ temp_id: ue(n)
925
943
  };
926
944
  }
927
- function Gn(e, t) {
945
+ function Hn(e, t) {
928
946
  const n = e.append_column_index ?? e.column_index;
929
947
  if (n === void 0)
930
948
  return 0;
@@ -936,24 +954,24 @@ function Gn(e, t) {
936
954
  );
937
955
  return n;
938
956
  }
939
- function Kn(e, t, n, r) {
940
- if (!$t(e))
941
- return Ae(t, n);
942
- const o = { ...n }, a = Dn(o, r), s = zn(o, r);
957
+ function Vn(e, t, n, r) {
958
+ if (!Pt(e))
959
+ return Ne(t, n);
960
+ const o = { ...n }, a = Gn(o, r), s = Kn(o, r);
943
961
  s && a.push(s), delete o.append_block, delete o.append_blocks, delete o.append_column_index, delete o.column_index;
944
- const l = Ae(t, o);
962
+ const c = Ne(t, o);
945
963
  if (a.length > 0) {
946
- const u = Array.isArray(t.column_blocks) ? z(t.column_blocks) : [], d = Gn(n, u.length), c = u.length > 0 ? u : [[]];
947
- for (; c.length <= d; )
948
- c.push([]);
949
- c[d] = [
950
- ...c[d] || [],
964
+ const u = Array.isArray(t.column_blocks) ? K(t.column_blocks) : [], d = Hn(n, u.length), l = u.length > 0 ? u : [[]];
965
+ for (; l.length <= d; )
966
+ l.push([]);
967
+ l[d] = [
968
+ ...l[d] || [],
951
969
  ...a
952
- ], l.column_blocks = c;
970
+ ], c.column_blocks = l;
953
971
  }
954
- return l;
972
+ return c;
955
973
  }
956
- function Hn(e, t) {
974
+ function Jn(e, t) {
957
975
  return {
958
976
  blockType: e.block_type,
959
977
  content: t ? e.content : void 0,
@@ -964,30 +982,30 @@ function Hn(e, t) {
964
982
  postId: e.post_id
965
983
  };
966
984
  }
967
- function G(e) {
985
+ function H(e) {
968
986
  return typeof e == "string" ? e.trim().toLowerCase() : "";
969
987
  }
970
- function tt(e) {
988
+ function rt(e) {
971
989
  return typeof e == "string" ? e.trim().toLowerCase() : "";
972
990
  }
973
- function At(e) {
991
+ function Nt(e) {
974
992
  return e.reduce((t, n) => t + 1 + (n.children?.length || 0), 0);
975
993
  }
976
- function ie(e) {
994
+ function ce(e) {
977
995
  return typeof e == "string" ? e.trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") : "";
978
996
  }
979
- async function J(e, t) {
980
- const n = t.trim(), r = ie(n), o = cn[r], { data: a, error: s } = await e.from("languages").select("id, code, name, is_active");
997
+ async function X(e, t) {
998
+ const n = t.trim(), r = ce(n), o = dn[r], { data: a, error: s } = await e.from("languages").select("id, code, name, is_active");
981
999
  if (s)
982
- throw new Error(`Failed to load language "${t}": ${_(s)}`);
983
- const u = (Array.isArray(a) ? a : []).filter((c) => c.is_active !== !1), d = u.find((c) => {
984
- const m = ie(c.code), h = ie(c.name);
1000
+ throw new Error(`Failed to load language "${t}": ${y(s)}`);
1001
+ const u = (Array.isArray(a) ? a : []).filter((l) => l.is_active !== !1), d = u.find((l) => {
1002
+ const m = ce(l.code), h = ce(l.name);
985
1003
  return m === r || m === o || h === r;
986
1004
  });
987
1005
  if (!d?.id || !d?.code) {
988
- const c = u.map((m) => m.code).filter(Boolean).join(", ");
1006
+ const l = u.map((m) => m.code).filter(Boolean).join(", ");
989
1007
  throw new Error(
990
- `Language "${t}" was not found.${c ? ` Available languages: ${c}.` : ""}`
1008
+ `Language "${t}" was not found.${l ? ` Available languages: ${l}.` : ""}`
991
1009
  );
992
1010
  }
993
1011
  return {
@@ -995,15 +1013,15 @@ async function J(e, t) {
995
1013
  id: Number(d.id)
996
1014
  };
997
1015
  }
998
- async function Ce(e, t) {
1016
+ async function Se(e, t) {
999
1017
  if (t)
1000
- return J(e, t);
1018
+ return X(e, t);
1001
1019
  const { data: n, error: r } = await e.from("languages").select("id, code, name, is_active, is_default");
1002
1020
  if (r)
1003
- throw new Error(`Failed to load active languages: ${_(r)}`);
1021
+ throw new Error(`Failed to load active languages: ${y(r)}`);
1004
1022
  const o = (Array.isArray(n) ? n : []).filter(
1005
1023
  (s) => s.is_active !== !1
1006
- ), a = o.find((s) => s.is_default) || o.find((s) => ie(s.code) === "en") || o[0];
1024
+ ), a = o.find((s) => s.is_default) || o.find((s) => ce(s.code) === "en") || o[0];
1007
1025
  if (!a?.id || !a?.code)
1008
1026
  throw new Error("No active CMS language is available for Cortex AI content creation.");
1009
1027
  return {
@@ -1011,25 +1029,25 @@ async function Ce(e, t) {
1011
1029
  id: Number(a.id)
1012
1030
  };
1013
1031
  }
1014
- async function nt(e) {
1032
+ async function ot(e) {
1015
1033
  try {
1016
1034
  const { data: t, error: n } = await e.from("currencies").select("code, is_default, is_active").eq("is_active", !0);
1017
1035
  if (n)
1018
1036
  return "USD";
1019
1037
  const r = Array.isArray(t) ? t : [], o = r.find((a) => a.is_default) || r[0];
1020
- return Me(o?.code || "USD");
1038
+ return ze(o?.code || "USD");
1021
1039
  } catch {
1022
1040
  return "USD";
1023
1041
  }
1024
1042
  }
1025
- async function Vn(e) {
1043
+ async function Wn(e) {
1026
1044
  const t = e.contentType === "page" ? "pages" : e.contentType === "post" ? "posts" : "products";
1027
1045
  let n = "id", r = e.entityId;
1028
1046
  if (r === void 0 && e.slug && (n = "slug", r = e.slug), r === void 0 && e.title && (n = "title", r = e.title), r === void 0)
1029
1047
  throw new Error(`A ${e.contentType} target requires an id, slug, title, or current edit context.`);
1030
1048
  const { data: o, error: a } = await e.supabase.from(t).select("*").eq(n, r);
1031
1049
  if (a)
1032
- throw new Error(`Failed to resolve ${e.contentType}: ${_(a)}`);
1050
+ throw new Error(`Failed to resolve ${e.contentType}: ${y(a)}`);
1033
1051
  const s = Array.isArray(o) ? o : o ? [o] : [];
1034
1052
  if (s.length !== 1)
1035
1053
  throw new Error(
@@ -1037,24 +1055,24 @@ async function Vn(e) {
1037
1055
  );
1038
1056
  return s[0];
1039
1057
  }
1040
- async function te(e, t) {
1041
- const n = ht.safeParse(t?.pageContext).success ? t?.pageContext : null, r = e.contentType || n?.contentType;
1058
+ async function oe(e, t) {
1059
+ const n = _t.safeParse(t?.pageContext).success ? t?.pageContext : null, r = e.contentType || n?.contentType;
1042
1060
  if (!r)
1043
1061
  throw new Error("Target contentType is required when no current CMS edit context exists.");
1044
- const o = e.entityId !== void 0 || !!e.slug || !!e.title, a = e.entityId ?? (o ? void 0 : n?.entityId), s = e.slug ?? (o ? void 0 : n?.slug ?? void 0), l = e.title ?? (o ? void 0 : n?.title ?? void 0), u = await Vn({
1062
+ const o = e.entityId !== void 0 || !!e.slug || !!e.title, a = e.entityId ?? (o ? void 0 : n?.entityId), s = e.slug ?? (o ? void 0 : n?.slug ?? void 0), c = e.title ?? (o ? void 0 : n?.title ?? void 0), u = await Wn({
1045
1063
  contentType: r,
1046
1064
  entityId: a,
1047
1065
  slug: a === void 0 && s || void 0,
1048
1066
  supabase: C(t),
1049
- title: a === void 0 && !s && l || void 0
1067
+ title: a === void 0 && !s && c || void 0
1050
1068
  });
1051
1069
  return {
1052
1070
  contentType: r,
1053
1071
  item: u
1054
1072
  };
1055
1073
  }
1056
- async function le(e) {
1057
- const t = await Wn({
1074
+ async function de(e) {
1075
+ const t = await Xn({
1058
1076
  item: e.item,
1059
1077
  languageId: e.languageId,
1060
1078
  menuKey: e.menuKey,
@@ -1070,39 +1088,39 @@ async function le(e) {
1070
1088
  url: e.item.url
1071
1089
  }, { data: r, error: o } = await e.supabase.from("navigation_items").insert(n).select("id").single();
1072
1090
  if (o)
1073
- throw new Error(`Failed to insert ${e.menuKey} navigation item: ${_(o)}`);
1091
+ throw new Error(`Failed to insert ${e.menuKey} navigation item: ${y(o)}`);
1074
1092
  return Number(r.id);
1075
1093
  }
1076
- function Jn(e) {
1094
+ function Yn(e) {
1077
1095
  const t = e.trim();
1078
1096
  if (!t.startsWith("/") || t.startsWith("//"))
1079
1097
  return null;
1080
1098
  const n = t.split("?")[0]?.split("#")[0] || "", r = n === "/" ? "home" : n.replace(/^\/+|\/+$/g, "");
1081
1099
  return r && !r.includes("/") ? r : null;
1082
1100
  }
1083
- async function Wn(e) {
1084
- const t = Jn(e.item.url);
1101
+ async function Xn(e) {
1102
+ const t = Yn(e.item.url);
1085
1103
  if (!t)
1086
1104
  return null;
1087
1105
  const { data: n, error: r } = await e.supabase.from("pages").select("id, slug, translation_group_id, language_id").eq("slug", t).eq("language_id", e.languageId);
1088
1106
  if (r)
1089
- throw new Error(`Failed to resolve linked page for navigation item: ${_(r)}`);
1107
+ throw new Error(`Failed to resolve linked page for navigation item: ${y(r)}`);
1090
1108
  const o = Array.isArray(n) ? n[0] : n;
1091
1109
  if (!o?.id)
1092
1110
  return null;
1093
- let a = Re();
1111
+ let a = De();
1094
1112
  if (o.translation_group_id) {
1095
- const { data: s, error: l } = await e.supabase.from("pages").select("id").eq("translation_group_id", o.translation_group_id);
1096
- if (l)
1113
+ const { data: s, error: c } = await e.supabase.from("pages").select("id").eq("translation_group_id", o.translation_group_id);
1114
+ if (c)
1097
1115
  throw new Error(
1098
- `Failed to inspect linked page translations for navigation item: ${_(l)}`
1116
+ `Failed to inspect linked page translations for navigation item: ${y(c)}`
1099
1117
  );
1100
1118
  const u = new Set(
1101
1119
  (Array.isArray(s) ? s : []).map((h) => String(h.id)).filter(Boolean)
1102
- ), { data: d, error: c } = await e.supabase.from("navigation_items").select("id, page_id, translation_group_id, menu_key").eq("menu_key", e.menuKey);
1103
- if (c)
1120
+ ), { data: d, error: l } = await e.supabase.from("navigation_items").select("id, page_id, translation_group_id, menu_key").eq("menu_key", e.menuKey);
1121
+ if (l)
1104
1122
  throw new Error(
1105
- `Failed to inspect related navigation translations: ${_(c)}`
1123
+ `Failed to inspect related navigation translations: ${y(l)}`
1106
1124
  );
1107
1125
  const m = (Array.isArray(d) ? d : []).find((h) => h.translation_group_id && u.has(String(h.page_id)));
1108
1126
  m?.translation_group_id && (a = m.translation_group_id);
@@ -1112,35 +1130,35 @@ async function Wn(e) {
1112
1130
  pageId: Number(o.id)
1113
1131
  };
1114
1132
  }
1115
- async function Pt(e) {
1116
- const t = await J(e.supabase, e.languageCode), { data: n, error: r } = await e.supabase.from("navigation_items").select("id, parent_id").eq("menu_key", e.menuKey).eq("language_id", t.id);
1133
+ async function Ut(e) {
1134
+ const t = await X(e.supabase, e.languageCode), { data: n, error: r } = await e.supabase.from("navigation_items").select("id, parent_id").eq("menu_key", e.menuKey).eq("language_id", t.id);
1117
1135
  if (r)
1118
1136
  throw new Error(
1119
- `Failed to inspect existing ${e.menuKey} navigation items: ${_(r)}`
1137
+ `Failed to inspect existing ${e.menuKey} navigation items: ${y(r)}`
1120
1138
  );
1121
- const o = Array.isArray(n) ? n : [], a = o.filter((d) => d.parent_id == null).length, s = At(e.items);
1122
- Nt({
1139
+ const o = Array.isArray(n) ? n : [], a = o.filter((d) => d.parent_id == null).length, s = Nt(e.items);
1140
+ Ot({
1123
1141
  existingItemCount: o.length,
1124
1142
  existingTopLevelCount: a,
1125
1143
  languageCode: t.code,
1126
1144
  menuKey: e.menuKey,
1127
1145
  replacementItemCount: s
1128
1146
  });
1129
- const { error: l } = await e.supabase.from("navigation_items").delete().eq("menu_key", e.menuKey).eq("language_id", t.id);
1130
- if (l)
1131
- throw new Error(`Failed to clear ${e.menuKey} navigation items: ${_(l)}`);
1147
+ const { error: c } = await e.supabase.from("navigation_items").delete().eq("menu_key", e.menuKey).eq("language_id", t.id);
1148
+ if (c)
1149
+ throw new Error(`Failed to clear ${e.menuKey} navigation items: ${y(c)}`);
1132
1150
  let u = 0;
1133
- for (const [d, c] of e.items.entries()) {
1134
- const m = await le({
1135
- item: c,
1151
+ for (const [d, l] of e.items.entries()) {
1152
+ const m = await de({
1153
+ item: l,
1136
1154
  languageId: t.id,
1137
1155
  menuKey: e.menuKey,
1138
1156
  order: d,
1139
1157
  supabase: e.supabase
1140
1158
  });
1141
1159
  u++;
1142
- for (const [h, p] of (c.children ?? []).entries())
1143
- await le({
1160
+ for (const [h, p] of (l.children ?? []).entries())
1161
+ await de({
1144
1162
  item: p,
1145
1163
  languageId: t.id,
1146
1164
  menuKey: e.menuKey,
@@ -1157,37 +1175,37 @@ async function Pt(e) {
1157
1175
  updatedCount: 0
1158
1176
  };
1159
1177
  }
1160
- function Nt(e) {
1178
+ function Ot(e) {
1161
1179
  if (!(e.existingItemCount === 0 || e.replacementItemCount >= e.existingItemCount))
1162
1180
  throw new Error(
1163
1181
  `Refusing destructive ${e.menuKey} navigation replacement for ${e.languageCode}: existing menu has ${e.existingItemCount} items (${e.existingTopLevelCount} top-level), but the replacement only contains ${e.replacementItemCount}. Use mode "update" for renaming or changing a single link, or provide the full menu.`
1164
1182
  );
1165
1183
  }
1166
- async function Yn(e) {
1167
- const t = await J(e.supabase, e.languageCode), { data: n, error: r } = await e.supabase.from("navigation_items").select("id, parent_id").eq("menu_key", e.menuKey).eq("language_id", t.id);
1184
+ async function Qn(e) {
1185
+ const t = await X(e.supabase, e.languageCode), { data: n, error: r } = await e.supabase.from("navigation_items").select("id, parent_id").eq("menu_key", e.menuKey).eq("language_id", t.id);
1168
1186
  if (r)
1169
1187
  throw new Error(
1170
- `Failed to inspect existing ${e.menuKey} navigation items: ${_(r)}`
1188
+ `Failed to inspect existing ${e.menuKey} navigation items: ${y(r)}`
1171
1189
  );
1172
1190
  const o = Array.isArray(n) ? n : [];
1173
- Nt({
1191
+ Ot({
1174
1192
  existingItemCount: o.length,
1175
1193
  existingTopLevelCount: o.filter((a) => a.parent_id == null).length,
1176
1194
  languageCode: t.code,
1177
1195
  menuKey: e.menuKey,
1178
- replacementItemCount: At(e.items)
1196
+ replacementItemCount: Nt(e.items)
1179
1197
  });
1180
1198
  }
1181
- async function Xn(e) {
1199
+ async function Zn(e) {
1182
1200
  if (e.items.length !== 1)
1183
1201
  throw new Error('mode "update" requires exactly one navigation item.');
1184
- const t = await J(e.supabase, e.languageCode), n = e.items[0], r = G(e.match?.url) || G(n.url), o = tt(e.match?.label), { data: a, error: s } = await e.supabase.from("navigation_items").select("id, label, url, parent_id, order").eq("menu_key", e.menuKey).eq("language_id", t.id);
1202
+ const t = await X(e.supabase, e.languageCode), n = e.items[0], r = H(e.match?.url) || H(n.url), o = rt(e.match?.label), { data: a, error: s } = await e.supabase.from("navigation_items").select("id, label, url, parent_id, order").eq("menu_key", e.menuKey).eq("language_id", t.id);
1185
1203
  if (s)
1186
1204
  throw new Error(
1187
- `Failed to load existing ${e.menuKey} navigation items: ${_(s)}`
1205
+ `Failed to load existing ${e.menuKey} navigation items: ${y(s)}`
1188
1206
  );
1189
- const u = (Array.isArray(a) ? a : []).find((c) => {
1190
- const m = G(c.url), h = tt(c.label);
1207
+ const u = (Array.isArray(a) ? a : []).find((l) => {
1208
+ const m = H(l.url), h = rt(l.label);
1191
1209
  return !!(r && m === r || o && h === o);
1192
1210
  });
1193
1211
  if (!u?.id)
@@ -1199,7 +1217,7 @@ async function Xn(e) {
1199
1217
  url: n.url
1200
1218
  }).eq("id", u.id);
1201
1219
  if (d)
1202
- throw new Error(`Failed to update ${e.menuKey} navigation item: ${_(d)}`);
1220
+ throw new Error(`Failed to update ${e.menuKey} navigation item: ${y(d)}`);
1203
1221
  return {
1204
1222
  insertedCount: 0,
1205
1223
  languageCode: t.code,
@@ -1208,46 +1226,46 @@ async function Xn(e) {
1208
1226
  updatedCount: 1
1209
1227
  };
1210
1228
  }
1211
- async function Qn(e) {
1212
- const t = await J(e.supabase, e.languageCode), { data: n, error: r } = await e.supabase.from("navigation_items").select("id, url, parent_id, order").eq("menu_key", e.menuKey).eq("language_id", t.id);
1229
+ async function er(e) {
1230
+ const t = await X(e.supabase, e.languageCode), { data: n, error: r } = await e.supabase.from("navigation_items").select("id, url, parent_id, order").eq("menu_key", e.menuKey).eq("language_id", t.id);
1213
1231
  if (r)
1214
1232
  throw new Error(
1215
- `Failed to load existing ${e.menuKey} navigation items: ${_(r)}`
1233
+ `Failed to load existing ${e.menuKey} navigation items: ${y(r)}`
1216
1234
  );
1217
1235
  let o = 0, a = 0;
1218
- const s = Array.isArray(n) ? n : [], l = new Set(
1219
- s.map((c) => G(c.url)).filter(Boolean)
1220
- ), u = s.filter((c) => c.parent_id == null).map((c) => Number(c.order)).filter(Number.isFinite);
1236
+ const s = Array.isArray(n) ? n : [], c = new Set(
1237
+ s.map((l) => H(l.url)).filter(Boolean)
1238
+ ), u = s.filter((l) => l.parent_id == null).map((l) => Number(l.order)).filter(Number.isFinite);
1221
1239
  let d = u.length > 0 ? Math.max(...u) + 1 : s.length;
1222
- for (const c of e.items) {
1223
- const m = G(c.url);
1224
- if (m && l.has(m)) {
1240
+ for (const l of e.items) {
1241
+ const m = H(l.url);
1242
+ if (m && c.has(m)) {
1225
1243
  a++;
1226
1244
  continue;
1227
1245
  }
1228
- const h = await le({
1229
- item: c,
1246
+ const h = await de({
1247
+ item: l,
1230
1248
  languageId: t.id,
1231
1249
  menuKey: e.menuKey,
1232
1250
  order: d,
1233
1251
  supabase: e.supabase
1234
1252
  });
1235
- o++, d++, m && l.add(m);
1253
+ o++, d++, m && c.add(m);
1236
1254
  let p = 0;
1237
- for (const g of c.children ?? []) {
1238
- const f = G(g.url);
1239
- if (f && l.has(f)) {
1255
+ for (const f of l.children ?? []) {
1256
+ const g = H(f.url);
1257
+ if (g && c.has(g)) {
1240
1258
  a++;
1241
1259
  continue;
1242
1260
  }
1243
- await le({
1244
- item: g,
1261
+ await de({
1262
+ item: f,
1245
1263
  languageId: t.id,
1246
1264
  menuKey: e.menuKey,
1247
1265
  order: p,
1248
1266
  parentId: h,
1249
1267
  supabase: e.supabase
1250
- }), o++, p++, f && l.add(f);
1268
+ }), o++, p++, g && c.add(g);
1251
1269
  }
1252
1270
  }
1253
1271
  return {
@@ -1258,76 +1276,76 @@ async function Qn(e) {
1258
1276
  updatedCount: 0
1259
1277
  };
1260
1278
  }
1261
- function v(e) {
1279
+ function S(e) {
1262
1280
  return typeof e == "string" && e.trim() ? e.trim() : "";
1263
1281
  }
1264
- function Zn(e) {
1282
+ function tr(e) {
1265
1283
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1266
1284
  }
1267
- function er(e) {
1268
- const t = v(e.field_type ?? e.fieldType ?? e.type ?? e.input_type).toLowerCase().replace(/\s+/g, "_"), n = v(e.label ?? e.name ?? e.placeholder).toLowerCase();
1285
+ function nr(e) {
1286
+ const t = S(e.field_type ?? e.fieldType ?? e.type ?? e.input_type).toLowerCase().replace(/\s+/g, "_"), n = S(e.label ?? e.name ?? e.placeholder).toLowerCase();
1269
1287
  return ["email", "textarea", "select", "radio", "checkbox", "text"].includes(t) ? t : n.includes("email") ? "email" : n.includes("message") || n.includes("comment") || n.includes("details") ? "textarea" : "text";
1270
1288
  }
1271
- function tr(e) {
1289
+ function rr(e) {
1272
1290
  return (Array.isArray(e) && e.length > 0 ? e : [
1273
1291
  { field_type: "text", is_required: !0, label: "Name", placeholder: "Your name" },
1274
1292
  { field_type: "email", is_required: !0, label: "Email", placeholder: "you@example.com" },
1275
1293
  { field_type: "textarea", is_required: !0, label: "Message", placeholder: "How can we help?" }
1276
1294
  ]).map((n, r) => {
1277
- const o = $(n) ? n : {}, a = v(o.label ?? o.name) || (r === 0 ? "Name" : r === 1 ? "Email" : "Message"), s = er({ ...o, label: a }), l = o.is_required ?? o.isRequired ?? o.required;
1295
+ const o = E(n) ? n : {}, a = S(o.label ?? o.name) || (r === 0 ? "Name" : r === 1 ? "Email" : "Message"), s = nr({ ...o, label: a }), c = o.is_required ?? o.isRequired ?? o.required;
1278
1296
  return {
1279
1297
  field_type: s,
1280
- is_required: typeof l == "boolean" ? l : !0,
1298
+ is_required: typeof c == "boolean" ? c : !0,
1281
1299
  label: a,
1282
1300
  options: Array.isArray(o.options) ? o.options : void 0,
1283
- placeholder: v(o.placeholder) || void 0,
1284
- temp_id: v(o.temp_id ?? o.tempId ?? o.id) || `field-${r + 1}`
1301
+ placeholder: S(o.placeholder) || void 0,
1302
+ temp_id: S(o.temp_id ?? o.tempId ?? o.id) || `field-${r + 1}`
1285
1303
  };
1286
1304
  });
1287
1305
  }
1288
- const nr = /* @__PURE__ */ new Set(["none", "sm", "md", "lg", "xl"]), rt = /* @__PURE__ */ new Set(["none", "sm", "md", "lg", "xl"]), rr = /* @__PURE__ */ new Set([
1306
+ const or = /* @__PURE__ */ new Set(["none", "sm", "md", "lg", "xl"]), it = /* @__PURE__ */ new Set(["none", "sm", "md", "lg", "xl"]), ir = /* @__PURE__ */ new Set([
1289
1307
  "full-width",
1290
1308
  "container",
1291
1309
  "container-sm",
1292
1310
  "container-lg",
1293
1311
  "container-xl"
1294
- ]), or = /* @__PURE__ */ new Set(["start", "center", "end", "stretch"]), ir = /* @__PURE__ */ new Set(["none", "theme", "solid", "gradient", "image"]), ar = /* @__PURE__ */ new Set(["primary", "secondary", "muted", "accent", "destructive"]), sr = /* @__PURE__ */ new Set(["center", "top", "bottom", "left", "right"]);
1295
- function lr(e) {
1312
+ ]), ar = /* @__PURE__ */ new Set(["start", "center", "end", "stretch"]), sr = /* @__PURE__ */ new Set(["none", "theme", "solid", "gradient", "image"]), cr = /* @__PURE__ */ new Set(["primary", "secondary", "muted", "accent", "destructive"]), lr = /* @__PURE__ */ new Set(["center", "top", "bottom", "left", "right"]);
1313
+ function ur(e) {
1296
1314
  return typeof e == "string" && /^https?:\/\//i.test(e.trim());
1297
1315
  }
1298
- function B(e, t, n) {
1316
+ function R(e, t, n) {
1299
1317
  return typeof e == "string" && t.has(e) ? e : n;
1300
1318
  }
1301
- function cr(e) {
1319
+ function dr(e) {
1302
1320
  return Number.isFinite(e) ? Math.min(4, Math.max(1, Math.round(e))) : 1;
1303
1321
  }
1304
- function ur(e) {
1322
+ function pr(e) {
1305
1323
  const t = [
1306
1324
  { color: "#1e3a8a", position: 0 },
1307
1325
  { color: "#3b82f6", position: 100 }
1308
1326
  ];
1309
- if (!$(e))
1327
+ if (!E(e))
1310
1328
  return { direction: "to bottom right", stops: t, type: "linear" };
1311
1329
  const n = e.type === "radial" ? "radial" : "linear", r = Array.isArray(e.stops) && e.stops.length >= 2 ? e.stops : t;
1312
1330
  return { direction: typeof e.direction == "string" && e.direction.trim() ? e.direction : n === "radial" ? "circle at center" : "to bottom right", stops: r, type: n };
1313
1331
  }
1314
- function dr(e) {
1315
- if (!$(e))
1332
+ function mr(e) {
1333
+ if (!E(e))
1316
1334
  return { type: "none" };
1317
- const t = B(e.type, ir, "none"), n = typeof e.min_height == "string" && e.min_height.trim() ? { min_height: e.min_height } : {};
1335
+ const t = R(e.type, sr, "none"), n = typeof e.min_height == "string" && e.min_height.trim() ? { min_height: e.min_height } : {};
1318
1336
  if (t === "theme")
1319
- return { theme: B(e.theme, ar, "muted"), type: t, ...n };
1337
+ return { theme: R(e.theme, cr, "muted"), type: t, ...n };
1320
1338
  if (t === "solid")
1321
1339
  return typeof e.solid_color == "string" && e.solid_color.trim() ? { solid_color: e.solid_color, type: t, ...n } : { type: "none" };
1322
1340
  if (t === "gradient")
1323
- return { gradient: ur(e.gradient), type: t, ...n };
1341
+ return { gradient: pr(e.gradient), type: t, ...n };
1324
1342
  if (t === "image") {
1325
- const r = $(e.image) ? e.image : null, o = r && lr(r.external_url) ? r.external_url.trim() : null, a = !!(r && typeof r.media_id == "string" && r.media_id.trim() && typeof r.object_key == "string" && r.object_key.trim());
1343
+ const r = E(e.image) ? e.image : null, o = r && ur(r.external_url) ? r.external_url.trim() : null, a = !!(r && typeof r.media_id == "string" && r.media_id.trim() && typeof r.object_key == "string" && r.object_key.trim());
1326
1344
  return r && (o || a) ? {
1327
1345
  image: {
1328
1346
  ...r,
1329
1347
  ...o ? { external_url: o } : {},
1330
- position: B(r.position, sr, "center"),
1348
+ position: R(r.position, lr, "center"),
1331
1349
  size: r.size === "contain" ? "contain" : "cover"
1332
1350
  },
1333
1351
  type: t,
@@ -1336,47 +1354,47 @@ function dr(e) {
1336
1354
  }
1337
1355
  return { type: "none", ...n };
1338
1356
  }
1339
- function pr(e, t, n) {
1357
+ function gr(e, t, n) {
1340
1358
  const r = e.is_hero === !0;
1341
1359
  let o = Array.isArray(e.column_blocks) ? e.column_blocks : [];
1342
- o.length > 0 && o.every((f) => $(f) && !Array.isArray(f)) && (o = [o]);
1343
- const a = o.map((f, k) => (Array.isArray(f) ? f : []).map(
1344
- (w, b) => Pe(w, `${t} column ${k} block ${b}`, n)
1345
- )), s = a.length > 0 ? a : [[]], l = cr(s.length), u = $(e.responsive_columns) ? e.responsive_columns : {}, d = Number(u.tablet), c = Number(u.mobile), m = Number.isFinite(d) ? Math.min(3, Math.max(1, Math.min(l, d))) : Math.min(3, l), h = Number.isFinite(c) ? Math.min(2, Math.max(1, c)) : 1, p = $(e.padding) ? e.padding : {}, g = {
1360
+ o.length > 0 && o.every((g) => E(g) && !Array.isArray(g)) && (o = [o]);
1361
+ const a = o.map((g, b) => (Array.isArray(g) ? g : []).map(
1362
+ (w, k) => Ue(w, `${t} column ${b} block ${k}`, n)
1363
+ )), s = a.length > 0 ? a : [[]], c = dr(s.length), u = E(e.responsive_columns) ? e.responsive_columns : {}, d = Number(u.tablet), l = Number(u.mobile), m = Number.isFinite(d) ? Math.min(3, Math.max(1, Math.min(c, d))) : Math.min(3, c), h = Number.isFinite(l) ? Math.min(2, Math.max(1, l)) : 1, p = E(e.padding) ? e.padding : {}, f = {
1346
1364
  ...e,
1347
- background: dr(e.background),
1365
+ background: mr(e.background),
1348
1366
  column_blocks: s,
1349
- column_gap: B(e.column_gap, nr, "lg"),
1350
- container_type: B(e.container_type, rr, "container"),
1367
+ column_gap: R(e.column_gap, or, "lg"),
1368
+ container_type: R(e.container_type, ir, "container"),
1351
1369
  padding: {
1352
- bottom: B(p.bottom, rt, "xl"),
1353
- top: B(p.top, rt, "xl")
1370
+ bottom: R(p.bottom, it, "xl"),
1371
+ top: R(p.top, it, "xl")
1354
1372
  },
1355
- responsive_columns: { desktop: l, mobile: h, tablet: m },
1356
- vertical_alignment: B(
1373
+ responsive_columns: { desktop: c, mobile: h, tablet: m },
1374
+ vertical_alignment: R(
1357
1375
  e.vertical_alignment,
1358
- or,
1376
+ ar,
1359
1377
  r ? "center" : "start"
1360
1378
  )
1361
1379
  };
1362
- return g.slider === !0 && !(Array.isArray(g.slides) && g.slides.length > 0) && (g.slider = !1), g;
1380
+ return f.slider === !0 && !(Array.isArray(f.slides) && f.slides.length > 0) && (f.slider = !1), f;
1363
1381
  }
1364
- function Ut(e, t, n, r) {
1382
+ function Ft(e, t, n, r) {
1365
1383
  if (e === "section") {
1366
- const a = pr(t, n, r);
1367
- return D(e, a, n, r), a;
1384
+ const a = gr(t, n, r);
1385
+ return z(e, a, n, r), a;
1368
1386
  }
1369
- const o = z(t);
1370
- if (e === "heading" && (o.text_content = v(o.text_content) || v(o.text) || v(o.title) || v(o.heading) || "Untitled", o.level = typeof o.level == "number" ? o.level : 1), e === "text") {
1371
- const a = v(o.html_content) || v(o.html) || v(o.content) || v(o.text);
1372
- a && (o.html_content = /<\/?[a-z][\s\S]*>/i.test(a) ? a : `<p>${Zn(a)}</p>`);
1387
+ const o = K(t);
1388
+ if (e === "heading" && (o.text_content = S(o.text_content) || S(o.text) || S(o.title) || S(o.heading) || "Untitled", o.level = typeof o.level == "number" ? o.level : 1), e === "text") {
1389
+ const a = S(o.html_content) || S(o.html) || S(o.content) || S(o.text);
1390
+ a && (o.html_content = /<\/?[a-z][\s\S]*>/i.test(a) ? a : `<p>${tr(a)}</p>`);
1373
1391
  }
1374
- return e === "button" && (o.text = v(o.text) || v(o.label) || v(o.title) || "Learn More", o.url = v(o.url) || v(o.href) || v(o.link) || "#"), e === "form" && (o.fields = tr(o.fields), o.submit_button_text = v(o.submit_button_text ?? o.submitButtonText ?? o.button_text) || "Send Message", o.success_message = v(o.success_message ?? o.successMessage) || "Thanks for reaching out. We will reply as soon as possible."), D(e, o, n, r), o;
1392
+ return e === "button" && (o.text = S(o.text) || S(o.label) || S(o.title) || "Learn More", o.url = S(o.url) || S(o.href) || S(o.link) || "#"), e === "form" && (o.fields = rr(o.fields), o.submit_button_text = S(o.submit_button_text ?? o.submitButtonText ?? o.button_text) || "Send Message", o.success_message = S(o.success_message ?? o.successMessage) || "Thanks for reaching out. We will reply as soon as possible."), z(e, o, n, r), o;
1375
1393
  }
1376
- function ce(e, t, n) {
1377
- const r = Ut(
1394
+ function pe(e, t, n) {
1395
+ const r = Ft(
1378
1396
  e.blockType,
1379
- ee(e.content, `Block ${t}`),
1397
+ re(e.content, `Block ${t}`),
1380
1398
  `Block ${t}`,
1381
1399
  n
1382
1400
  );
@@ -1386,9 +1404,9 @@ function ce(e, t, n) {
1386
1404
  order: e.order ?? t
1387
1405
  };
1388
1406
  }
1389
- function mr(e, t = "Contact Us", n) {
1407
+ function fr(e, t = "Contact Us", n) {
1390
1408
  return [
1391
- ce(
1409
+ pe(
1392
1410
  {
1393
1411
  blockType: "section",
1394
1412
  content: {
@@ -1403,14 +1421,14 @@ function mr(e, t = "Contact Us", n) {
1403
1421
  textAlign: "center",
1404
1422
  text_content: t
1405
1423
  },
1406
- temp_id: se("heading")
1424
+ temp_id: ue("heading")
1407
1425
  },
1408
1426
  {
1409
1427
  block_type: "text",
1410
1428
  content: {
1411
1429
  html_content: "<p>Have a question, project, or support request? Send us a note and we will get back to you soon.</p>"
1412
1430
  },
1413
- temp_id: se("text")
1431
+ temp_id: ue("text")
1414
1432
  }
1415
1433
  ]
1416
1434
  ],
@@ -1424,7 +1442,7 @@ function mr(e, t = "Contact Us", n) {
1424
1442
  0,
1425
1443
  n
1426
1444
  ),
1427
- ce(
1445
+ pe(
1428
1446
  {
1429
1447
  blockType: "form",
1430
1448
  content: {
@@ -1461,13 +1479,13 @@ function mr(e, t = "Contact Us", n) {
1461
1479
  )
1462
1480
  ];
1463
1481
  }
1464
- function Se(e, t, n, r) {
1465
- return (!e || e.length === 0) && t ? mr(t, n, r) : (e || []).map((o, a) => ce(o, a, r));
1482
+ function Ee(e, t, n, r) {
1483
+ return (!e || e.length === 0) && t ? fr(t, n, r) : (e || []).map((o, a) => pe(o, a, r));
1466
1484
  }
1467
- async function De(e) {
1485
+ async function Ge(e) {
1468
1486
  const t = e.contentType === "page" ? "pages" : e.contentType === "post" ? "posts" : "products", { data: n, error: r } = await e.supabase.from(t).select("id, title, slug, language_id").eq("slug", e.slug).eq("language_id", e.languageId);
1469
1487
  if (r)
1470
- throw new Error(`Failed to check ${e.contentType} slug uniqueness: ${_(r)}`);
1488
+ throw new Error(`Failed to check ${e.contentType} slug uniqueness: ${y(r)}`);
1471
1489
  const o = Array.isArray(n) ? n : [];
1472
1490
  return o.length > 0 ? {
1473
1491
  duplicate: !0,
@@ -1477,7 +1495,7 @@ async function De(e) {
1477
1495
  message: `A ${e.contentType} with slug "${e.slug}" already exists for this language.`
1478
1496
  } : null;
1479
1497
  }
1480
- async function ze(e) {
1498
+ async function Ke(e) {
1481
1499
  if (!e.suppliedTranslationGroupId)
1482
1500
  return {
1483
1501
  translationGroupId: void 0
@@ -1485,7 +1503,7 @@ async function ze(e) {
1485
1503
  const t = e.contentType === "page" ? "pages" : e.contentType === "post" ? "posts" : "products", { data: n, error: r } = await e.supabase.from(t).select("id, title, slug, language_id, translation_group_id").eq("translation_group_id", e.suppliedTranslationGroupId);
1486
1504
  if (r)
1487
1505
  throw new Error(
1488
- `Failed to inspect ${e.contentType} translation group: ${_(r)}`
1506
+ `Failed to inspect ${e.contentType} translation group: ${y(r)}`
1489
1507
  );
1490
1508
  const o = Array.isArray(n) ? n : [];
1491
1509
  if (o.length === 0)
@@ -1513,7 +1531,7 @@ async function ze(e) {
1513
1531
  translationGroupId: e.suppliedTranslationGroupId
1514
1532
  };
1515
1533
  }
1516
- async function Ge(e) {
1534
+ async function He(e) {
1517
1535
  if (e.blocks.length === 0)
1518
1536
  return [];
1519
1537
  const t = e.blocks.map((o, a) => ({
@@ -1526,28 +1544,28 @@ async function Ge(e) {
1526
1544
  product_id: e.contentType === "product" ? e.itemId : null
1527
1545
  })), { data: n, error: r } = await e.supabase.from("blocks").insert(t).select("*");
1528
1546
  if (r)
1529
- throw new Error(`Failed to insert ${e.contentType} blocks: ${_(r)}`);
1530
- return ve(e.blocks, e.supabase), Array.isArray(n) ? n : [];
1547
+ throw new Error(`Failed to insert ${e.contentType} blocks: ${y(r)}`);
1548
+ return $e(e.blocks, e.supabase), Array.isArray(n) ? n : [];
1531
1549
  }
1532
- async function Ke(e) {
1550
+ async function Ve(e) {
1533
1551
  const t = e.contentType === "page" ? "pages" : e.contentType === "post" ? "posts" : "products";
1534
1552
  await e.supabase.from(t).delete().eq("id", e.itemId);
1535
1553
  }
1536
- function He(e, t) {
1554
+ function Je(e, t) {
1537
1555
  return e === "page" ? `/cms/pages/${t}/edit` : e === "post" ? `/cms/posts/${t}/edit` : `/cms/products/${t}/edit`;
1538
1556
  }
1539
- function ot(e) {
1557
+ function at(e) {
1540
1558
  return e === "page" ? "/cms/pages" : e === "post" ? "/cms/posts" : "/cms/products";
1541
1559
  }
1542
- async function Ot(e, t) {
1543
- const n = de.parse(e), r = C(t);
1544
- n.mode === "replace" && await Yn({
1560
+ async function jt(e, t) {
1561
+ const n = ge.parse(e), r = C(t);
1562
+ n.mode === "replace" && await Qn({
1545
1563
  items: n.items,
1546
1564
  languageCode: n.languageCode,
1547
1565
  menuKey: "HEADER",
1548
1566
  supabase: r
1549
1567
  });
1550
- const o = P({
1568
+ const o = N({
1551
1569
  action: "UPDATE NAVIGATION",
1552
1570
  context: t,
1553
1571
  payload: { input: n, tool: "update_navigation_bar" },
@@ -1561,35 +1579,35 @@ async function Ot(e, t) {
1561
1579
  });
1562
1580
  if (o)
1563
1581
  return o;
1564
- const a = n.mode === "update" ? await Xn({
1582
+ const a = n.mode === "update" ? await Zn({
1565
1583
  items: n.items,
1566
1584
  languageCode: n.languageCode,
1567
1585
  match: n.match,
1568
1586
  menuKey: "HEADER",
1569
1587
  supabase: r
1570
- }) : n.mode === "append" ? await Qn({
1588
+ }) : n.mode === "append" ? await er({
1571
1589
  items: n.items,
1572
1590
  languageCode: n.languageCode,
1573
1591
  menuKey: "HEADER",
1574
1592
  supabase: r
1575
- }) : await Pt({
1593
+ }) : await Ut({
1576
1594
  items: n.items,
1577
1595
  languageCode: n.languageCode,
1578
1596
  menuKey: "HEADER",
1579
1597
  supabase: r
1580
1598
  });
1581
- return xt(t), {
1599
+ return vt(t), {
1582
1600
  ...a,
1583
1601
  mutationExecuted: !0,
1584
1602
  mode: n.mode,
1585
1603
  success: !0
1586
1604
  };
1587
1605
  }
1588
- async function Ft(e, t) {
1589
- const n = pe.parse(e);
1606
+ async function Lt(e, t) {
1607
+ const n = fe.parse(e);
1590
1608
  if (!n.links?.length && !n.copyright)
1591
1609
  throw new Error("update_footer requires links or copyright.");
1592
- const r = C(t), o = P({
1610
+ const r = C(t), o = N({
1593
1611
  action: "UPDATE FOOTER",
1594
1612
  context: t,
1595
1613
  payload: { input: n, tool: "update_footer" },
@@ -1604,7 +1622,7 @@ async function Ft(e, t) {
1604
1622
  if (o)
1605
1623
  return o;
1606
1624
  let a = null;
1607
- if (n.links?.length && (a = await Pt({
1625
+ if (n.links?.length && (a = await Ut({
1608
1626
  items: n.links,
1609
1627
  languageCode: n.languageCode,
1610
1628
  menuKey: "FOOTER",
@@ -1615,57 +1633,57 @@ async function Ft(e, t) {
1615
1633
  value: n.copyright
1616
1634
  });
1617
1635
  if (s)
1618
- throw new Error(`Failed to update footer copyright: ${_(s)}`);
1636
+ throw new Error(`Failed to update footer copyright: ${y(s)}`);
1619
1637
  }
1620
- return xt(t), {
1638
+ return vt(t), {
1621
1639
  copyrightUpdated: !!n.copyright,
1622
1640
  footerNavigation: a,
1623
1641
  mutationExecuted: !0,
1624
1642
  success: !0
1625
1643
  };
1626
1644
  }
1627
- function jt(e) {
1645
+ function Bt(e) {
1628
1646
  return typeof e == "string" ? e.toLowerCase() : "";
1629
1647
  }
1630
- function gr(e, t) {
1631
- const n = t.map(jt).join(" ");
1648
+ function hr(e, t) {
1649
+ const n = t.map(Bt).join(" ");
1632
1650
  return e.reduce((r, o) => r + (n.includes(o) ? 1 : 0), 0);
1633
1651
  }
1634
- function it(e, t) {
1652
+ function st(e, t) {
1635
1653
  return (e.find(
1636
- (n) => t.some((r) => jt(n).includes(r))
1654
+ (n) => t.some((r) => Bt(n).includes(r))
1637
1655
  ) || e.find((n) => n.trim().length > 0) || "No excerpt available.").slice(0, 500);
1638
1656
  }
1639
- async function fr(e, t) {
1640
- const n = je.parse(e), r = C(t), o = n.query.toLowerCase().split(/\s+/).map((c) => c.trim()).filter(Boolean), [a, s] = await Promise.all([
1657
+ async function yr(e, t) {
1658
+ const n = Be.parse(e), r = C(t), o = n.query.toLowerCase().split(/\s+/).map((l) => l.trim()).filter(Boolean), [a, s] = await Promise.all([
1641
1659
  r.from("posts").select("id, title, slug, excerpt, subtitle, meta_description, status, updated_at").eq("status", "published").limit(100),
1642
1660
  r.from("pages").select("id, title, slug, meta_description, status, updated_at").eq("status", "published").limit(100)
1643
1661
  ]);
1644
1662
  if (a.error)
1645
- throw new Error(`Failed to search documentation posts: ${_(a.error)}`);
1663
+ throw new Error(`Failed to search documentation posts: ${y(a.error)}`);
1646
1664
  if (s.error)
1647
- throw new Error(`Failed to search documentation pages: ${_(s.error)}`);
1648
- const l = (a.data ?? []).map((c) => ({
1649
- excerpt: it(
1650
- [c.excerpt, c.subtitle, c.meta_description, c.slug].filter(Boolean),
1665
+ throw new Error(`Failed to search documentation pages: ${y(s.error)}`);
1666
+ const c = (a.data ?? []).map((l) => ({
1667
+ excerpt: st(
1668
+ [l.excerpt, l.subtitle, l.meta_description, l.slug].filter(Boolean),
1651
1669
  o
1652
1670
  ),
1653
1671
  source: "post",
1654
- title: c.title,
1655
- url: `/article/${c.slug}`
1656
- })), u = (s.data ?? []).map((c) => ({
1657
- excerpt: it([c.meta_description, c.slug].filter(Boolean), o),
1672
+ title: l.title,
1673
+ url: `/article/${l.slug}`
1674
+ })), u = (s.data ?? []).map((l) => ({
1675
+ excerpt: st([l.meta_description, l.slug].filter(Boolean), o),
1658
1676
  source: "page",
1659
- title: c.title,
1660
- url: c.slug === "home" ? "/" : `/${c.slug}`
1661
- })), d = [...l, ...u].map((c) => ({
1662
- ...c,
1663
- score: gr(o, [c.title, c.excerpt, c.url])
1664
- })).filter((c) => c.score > 0).sort((c, m) => m.score - c.score).slice(0, n.limit).map((c) => ({
1665
- excerpt: c.excerpt,
1666
- source: c.source,
1667
- title: c.title,
1668
- url: c.url
1677
+ title: l.title,
1678
+ url: l.slug === "home" ? "/" : `/${l.slug}`
1679
+ })), d = [...c, ...u].map((l) => ({
1680
+ ...l,
1681
+ score: hr(o, [l.title, l.excerpt, l.url])
1682
+ })).filter((l) => l.score > 0).sort((l, m) => m.score - l.score).slice(0, n.limit).map((l) => ({
1683
+ excerpt: l.excerpt,
1684
+ source: l.source,
1685
+ title: l.title,
1686
+ url: l.url
1669
1687
  }));
1670
1688
  return {
1671
1689
  query: n.query,
@@ -1673,10 +1691,10 @@ async function fr(e, t) {
1673
1691
  success: !0
1674
1692
  };
1675
1693
  }
1676
- async function hr(e, t, n = ln) {
1677
- const r = je.safeParse(e), o = r.success ? r.data.query : "";
1678
- return En(
1679
- fr(e, t),
1694
+ async function _r(e, t, n = un) {
1695
+ const r = Be.safeParse(e), o = r.success ? r.data.query : "";
1696
+ return An(
1697
+ yr(e, t),
1680
1698
  n,
1681
1699
  () => ({
1682
1700
  message: "Documentation search took too long to respond. Please try again or ask a more specific question.",
@@ -1687,7 +1705,7 @@ async function hr(e, t, n = ln) {
1687
1705
  })
1688
1706
  );
1689
1707
  }
1690
- const yr = [
1708
+ const br = [
1691
1709
  "pending",
1692
1710
  "trial",
1693
1711
  "paid",
@@ -1695,7 +1713,7 @@ const yr = [
1695
1713
  "cancelled",
1696
1714
  "refunded",
1697
1715
  "failed"
1698
- ], _r = {
1716
+ ], wr = {
1699
1717
  awaiting: "pending",
1700
1718
  canceled: "cancelled",
1701
1719
  cancelled: "cancelled",
@@ -1712,34 +1730,34 @@ const yr = [
1712
1730
  trial: "trial",
1713
1731
  trials: "trial"
1714
1732
  };
1715
- function br(e) {
1733
+ function kr(e) {
1716
1734
  return String(e ?? "unknown").trim().toLowerCase() || "unknown";
1717
1735
  }
1718
- function at(e) {
1736
+ function ct(e) {
1719
1737
  const t = Object.fromEntries(
1720
- yr.map((n) => [n, 0])
1738
+ br.map((n) => [n, 0])
1721
1739
  );
1722
1740
  for (const n of e) {
1723
- const r = br(n.status);
1741
+ const r = kr(n.status);
1724
1742
  t[r] = (t[r] ?? 0) + 1;
1725
1743
  }
1726
1744
  return t;
1727
1745
  }
1728
- function kr(e) {
1746
+ function Ir(e) {
1729
1747
  const n = e.toLowerCase().replace(/[^a-z0-9_]+/g, " ").split(/\s+/).filter(Boolean);
1730
1748
  for (const r of n) {
1731
- const o = _r[r];
1749
+ const o = wr[r];
1732
1750
  if (o)
1733
1751
  return o;
1734
1752
  }
1735
1753
  return null;
1736
1754
  }
1737
- function X(e) {
1755
+ function ee(e) {
1738
1756
  const t = Number(e);
1739
1757
  return Number.isFinite(t) ? t : 0;
1740
1758
  }
1741
- async function wr(e, t) {
1742
- const n = ft.parse(e), r = C(t), o = /* @__PURE__ */ new Date();
1759
+ async function Tr(e, t) {
1760
+ const n = yt.parse(e), r = C(t), o = /* @__PURE__ */ new Date();
1743
1761
  let a = null, s = null;
1744
1762
  switch (n.timeRange) {
1745
1763
  case "today":
@@ -1764,8 +1782,8 @@ async function wr(e, t) {
1764
1782
  a = null;
1765
1783
  break;
1766
1784
  }
1767
- const l = n.currency?.toUpperCase(), u = kr(n.query), d = r.from("orders").select("id, status, total, currency, created_at, paid_at");
1768
- l && d.eq("currency", l), a && d.gte("created_at", a.toISOString()), s && d.lte("created_at", s.toISOString());
1785
+ const c = n.currency?.toUpperCase(), u = Ir(n.query), d = r.from("orders").select("id, status, total, currency, created_at, paid_at");
1786
+ c && d.eq("currency", c), a && d.gte("created_at", a.toISOString()), s && d.lte("created_at", s.toISOString());
1769
1787
  const m = n.reportType === "products" || n.reportType === "revenue" || n.reportType === "general" ? r.from("order_items").select(`
1770
1788
  quantity,
1771
1789
  price_at_purchase,
@@ -1781,92 +1799,92 @@ async function wr(e, t) {
1781
1799
  currency
1782
1800
  )
1783
1801
  `).eq("orders.status", "paid") : null;
1784
- m && (l && m.eq("orders.currency", l), a && m.gte("orders.paid_at", a.toISOString()), s && m.lte("orders.paid_at", s.toISOString()));
1802
+ m && (c && m.eq("orders.currency", c), a && m.gte("orders.paid_at", a.toISOString()), s && m.lte("orders.paid_at", s.toISOString()));
1785
1803
  const p = n.timeRange !== "all_time" && (n.reportType === "orders" || u) ? r.from("orders").select("id, status, currency") : null;
1786
- p && l && p.eq("currency", l);
1804
+ p && c && p.eq("currency", c);
1787
1805
  const [
1788
- { data: g, error: f },
1789
- { data: k, error: y },
1806
+ { data: f, error: g },
1807
+ { data: b, error: _ },
1790
1808
  w
1791
1809
  ] = await Promise.all([
1792
1810
  d,
1793
1811
  m ?? Promise.resolve({ data: [], error: null }),
1794
1812
  p ?? Promise.resolve({ data: null, error: null })
1795
1813
  ]);
1796
- if (f)
1797
- throw new Error(`Failed to fetch ecommerce stats: ${_(f)}`);
1798
- if (y)
1799
- throw new Error(`Failed to fetch ecommerce stats: ${_(y)}`);
1814
+ if (g)
1815
+ throw new Error(`Failed to fetch ecommerce stats: ${y(g)}`);
1816
+ if (_)
1817
+ throw new Error(`Failed to fetch ecommerce stats: ${y(_)}`);
1800
1818
  if (w.error)
1801
- throw new Error(`Failed to fetch ecommerce stats: ${_(w.error)}`);
1802
- const b = Array.isArray(g) ? g : [], I = Array.isArray(k) ? k : [], x = at(b), E = Array.isArray(w.data) ? w.data : null, L = E ? at(E) : null, R = {};
1803
- for (const T of I) {
1804
- const A = Array.isArray(T.orders) ? T.orders[0] : T.orders, j = String(A?.currency || l || "unknown").toUpperCase();
1805
- R[j] = (R[j] ?? 0) + X(T.quantity) * X(T.price_at_purchase) / 100;
1819
+ throw new Error(`Failed to fetch ecommerce stats: ${y(w.error)}`);
1820
+ const k = Array.isArray(f) ? f : [], T = Array.isArray(b) ? b : [], I = ct(k), $ = Array.isArray(w.data) ? w.data : null, P = $ ? ct($) : null, L = {};
1821
+ for (const x of T) {
1822
+ const A = Array.isArray(x.orders) ? x.orders[0] : x.orders, B = String(A?.currency || c || "unknown").toUpperCase();
1823
+ L[B] = (L[B] ?? 0) + ee(x.quantity) * ee(x.price_at_purchase) / 100;
1806
1824
  }
1807
- const W = {
1808
- currency: l ?? null,
1809
- currencyFiltered: !!l,
1810
- orderStatusCounts: x,
1811
- paidOrderCount: x.paid ?? 0,
1825
+ const Q = {
1826
+ currency: c ?? null,
1827
+ currencyFiltered: !!c,
1828
+ orderStatusCounts: I,
1829
+ paidOrderCount: I.paid ?? 0,
1812
1830
  query: n.query,
1813
1831
  reportType: n.reportType,
1814
- revenueByCurrency: R,
1832
+ revenueByCurrency: L,
1815
1833
  timeRange: n.timeRange,
1816
- totalOrders: b.length,
1817
- totalRevenue: Object.values(R).reduce(
1818
- (T, A) => T + A,
1834
+ totalOrders: k.length,
1835
+ totalRevenue: Object.values(L).reduce(
1836
+ (x, A) => x + A,
1819
1837
  0
1820
1838
  )
1821
1839
  };
1822
- if (L && (W.allTimeOrderStatusCounts = L), u && (W.matchingOrderStatus = {
1823
- allTimeCount: L?.[u] ?? x[u] ?? 0,
1824
- count: x[u] ?? 0,
1840
+ if (P && (Q.allTimeOrderStatusCounts = P), u && (Q.matchingOrderStatus = {
1841
+ allTimeCount: P?.[u] ?? I[u] ?? 0,
1842
+ count: I[u] ?? 0,
1825
1843
  status: u,
1826
1844
  timeRange: n.timeRange
1827
1845
  }), n.reportType === "products" || n.reportType === "revenue" || n.reportType === "general") {
1828
- const T = {};
1829
- for (const A of I) {
1830
- const j = Array.isArray(A.products) ? A.products[0] : A.products;
1831
- if (!j?.id)
1846
+ const x = {};
1847
+ for (const A of T) {
1848
+ const B = Array.isArray(A.products) ? A.products[0] : A.products;
1849
+ if (!B?.id)
1832
1850
  continue;
1833
- const Y = j.id;
1834
- T[Y] || (T[Y] = {
1835
- id: Y,
1851
+ const Z = B.id;
1852
+ x[Z] || (x[Z] = {
1853
+ id: Z,
1836
1854
  quantity: 0,
1837
1855
  revenue: 0,
1838
- title: j.title,
1839
- type: j.product_type
1840
- }), T[Y].quantity += X(A.quantity), T[Y].revenue += X(A.quantity) * X(A.price_at_purchase) / 100;
1856
+ title: B.title,
1857
+ type: B.product_type
1858
+ }), x[Z].quantity += ee(A.quantity), x[Z].revenue += ee(A.quantity) * ee(A.price_at_purchase) / 100;
1841
1859
  }
1842
- W.topProducts = Object.values(T).sort((A, j) => j.revenue - A.revenue).slice(0, 10);
1860
+ Q.topProducts = Object.values(x).sort((A, B) => B.revenue - A.revenue).slice(0, 10);
1843
1861
  }
1844
1862
  return {
1845
- report: W,
1863
+ report: Q,
1846
1864
  success: !0
1847
1865
  };
1848
1866
  }
1849
- async function Ir(e, t) {
1850
- const n = yt.parse(e), r = C(t), o = V(t), a = Te(o), s = o.contentType === "page" ? "pages" : o.contentType === "post" ? "posts" : "products", { data: l, error: u } = await r.from(s).select("*").eq("id", a).single();
1851
- if (u || !l)
1867
+ async function xr(e, t) {
1868
+ const n = bt.parse(e), r = C(t), o = Y(t), a = q(o), s = o.contentType === "page" ? "pages" : o.contentType === "post" ? "posts" : "products", { data: c, error: u } = await r.from(s).select("*").eq("id", a).single();
1869
+ if (u || !c)
1852
1870
  throw new Error(
1853
- `Failed to read current ${o.contentType}: ${_(u)}`
1871
+ `Failed to read current ${o.contentType}: ${y(u)}`
1854
1872
  );
1855
1873
  let d = [];
1856
1874
  if (n.includeBlocks) {
1857
- const c = o.contentType === "page" ? "page_id" : o.contentType === "post" ? "post_id" : "product_id", { data: m, error: h } = await r.from("blocks").select("id, page_id, post_id, product_id, language_id, block_type, content, order").eq(c, a);
1875
+ const l = o.contentType === "page" ? "page_id" : o.contentType === "post" ? "post_id" : "product_id", { data: m, error: h } = await r.from("blocks").select("id, page_id, post_id, product_id, language_id, block_type, content, order").eq(l, a);
1858
1876
  if (h)
1859
- throw new Error(`Failed to read current ${o.contentType} blocks: ${_(h)}`);
1860
- d = (Array.isArray(m) ? m : []).slice().sort((p, g) => Number(p.order) - Number(g.order)).map((p) => Hn(p, n.includeBlockContent));
1877
+ throw new Error(`Failed to read current ${o.contentType} blocks: ${y(h)}`);
1878
+ d = (Array.isArray(m) ? m : []).slice().sort((p, f) => Number(p.order) - Number(f.order)).map((p) => Jn(p, n.includeBlockContent));
1861
1879
  }
1862
1880
  return {
1863
1881
  blocks: d,
1864
1882
  context: o,
1865
- item: l,
1883
+ item: c,
1866
1884
  success: !0
1867
1885
  };
1868
1886
  }
1869
- const Lt = /* @__PURE__ */ new Set([
1887
+ const Rt = /* @__PURE__ */ new Set([
1870
1888
  "feature_image_id",
1871
1889
  "language_id",
1872
1890
  "meta_description",
@@ -1874,7 +1892,7 @@ const Lt = /* @__PURE__ */ new Set([
1874
1892
  "slug",
1875
1893
  "status",
1876
1894
  "title"
1877
- ]), Bt = /* @__PURE__ */ new Set([
1895
+ ]), qt = /* @__PURE__ */ new Set([
1878
1896
  "excerpt",
1879
1897
  "feature_image_id",
1880
1898
  "label",
@@ -1886,7 +1904,7 @@ const Lt = /* @__PURE__ */ new Set([
1886
1904
  "status",
1887
1905
  "subtitle",
1888
1906
  "title"
1889
- ]), Tr = /* @__PURE__ */ new Set([
1907
+ ]), Cr = /* @__PURE__ */ new Set([
1890
1908
  "description_json",
1891
1909
  "language_id",
1892
1910
  "meta_description",
@@ -1895,7 +1913,7 @@ const Lt = /* @__PURE__ */ new Set([
1895
1913
  "slug",
1896
1914
  "status",
1897
1915
  "title"
1898
- ]), xr = /* @__PURE__ */ new Set([
1916
+ ]), vr = /* @__PURE__ */ new Set([
1899
1917
  "excerpt",
1900
1918
  "feature_image_id",
1901
1919
  "label",
@@ -1905,13 +1923,13 @@ const Lt = /* @__PURE__ */ new Set([
1905
1923
  "short_description",
1906
1924
  "subtitle"
1907
1925
  ]);
1908
- function Cr(e) {
1909
- return e === "page" ? Lt : e === "post" ? Bt : Tr;
1926
+ function Sr(e) {
1927
+ return e === "page" ? Rt : e === "post" ? qt : Cr;
1910
1928
  }
1911
- function qt(e, t) {
1912
- return xr.has(e) && t === "" ? null : t;
1929
+ function Mt(e, t) {
1930
+ return vr.has(e) && t === "" ? null : t;
1913
1931
  }
1914
- function Ne(e, t) {
1932
+ function Oe(e, t) {
1915
1933
  if (typeof t != "string")
1916
1934
  return;
1917
1935
  const n = e === "product" ? ["active", "archived", "draft"] : ["archived", "draft", "published"];
@@ -1920,23 +1938,23 @@ function Ne(e, t) {
1920
1938
  `Status "${t}" is not valid for ${e}. Allowed statuses: ${n.join(", ")}.`
1921
1939
  );
1922
1940
  }
1923
- function Sr(e, t) {
1924
- const n = Cr(t.contentType), r = {};
1941
+ function Er(e, t) {
1942
+ const n = Sr(t.contentType), r = {};
1925
1943
  for (const [o, a] of Object.entries(e))
1926
1944
  if (a !== void 0) {
1927
1945
  if (!n.has(o))
1928
1946
  throw new Error(
1929
1947
  `Field "${o}" cannot be updated for ${t.contentType} content.`
1930
1948
  );
1931
- o === "status" && Ne(t.contentType, a), r[o] = qt(o, a);
1949
+ o === "status" && Oe(t.contentType, a), r[o] = Mt(o, a);
1932
1950
  }
1933
1951
  return r;
1934
1952
  }
1935
- async function Rt(e, t) {
1936
- const n = me.parse(e), r = C(t), o = V(t), a = Te(o), s = Sr(n.fields, o), l = Object.keys(s);
1937
- if (l.length === 0)
1953
+ async function Dt(e, t) {
1954
+ const n = he.parse(e), r = C(t), o = Y(t), a = q(o), s = Er(n.fields, o), c = Object.keys(s);
1955
+ if (c.length === 0)
1938
1956
  throw new Error("update_current_cms_fields requires at least one supported field.");
1939
- const u = P({
1957
+ const u = N({
1940
1958
  action: "UPDATE CMS FIELDS",
1941
1959
  context: t,
1942
1960
  payload: {
@@ -1948,7 +1966,7 @@ async function Rt(e, t) {
1948
1966
  preview: {
1949
1967
  contentType: o.contentType,
1950
1968
  entityId: a,
1951
- fields: l,
1969
+ fields: c,
1952
1970
  slug: o.slug,
1953
1971
  title: o.title
1954
1972
  },
@@ -1956,113 +1974,123 @@ async function Rt(e, t) {
1956
1974
  });
1957
1975
  if (u)
1958
1976
  return u;
1959
- typeof s.feature_image_id == "string" && (s.feature_image_id = await Z(
1977
+ const d = await J(t, o.contentType, a);
1978
+ typeof s.feature_image_id == "string" && (s.feature_image_id = await ne(
1960
1979
  s.feature_image_id,
1961
1980
  t,
1962
1981
  typeof o.title == "string" ? o.title : void 0
1963
1982
  ));
1964
- const d = o.contentType === "page" ? "pages" : o.contentType === "post" ? "posts" : "products", { data: c, error: m } = await r.from(d).update({
1983
+ const l = o.contentType === "page" ? "pages" : o.contentType === "post" ? "posts" : "products", { data: m, error: h } = await r.from(l).update({
1965
1984
  ...s,
1966
1985
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1967
1986
  }).eq("id", a).select("id, language_id, slug, status, title").single();
1968
- if (m || !c)
1987
+ if (h || !m)
1969
1988
  throw new Error(
1970
- `Failed to update current ${o.contentType}: ${_(m)}`
1989
+ `Failed to update current ${o.contentType}: ${y(h)}`
1971
1990
  );
1972
- return U(t, o, c.slug), {
1991
+ return await G(t, o.contentType, a, d), O(t, o, m.slug), {
1973
1992
  contentType: o.contentType,
1974
1993
  entityId: a,
1975
1994
  mutationExecuted: !0,
1976
- slug: c.slug,
1995
+ slug: m.slug,
1977
1996
  success: !0,
1978
- updatedFields: l
1997
+ updatedFields: c
1979
1998
  };
1980
1999
  }
1981
- async function Mt(e, t) {
1982
- const n = ge.parse(e), r = C(t), o = V(t), { data: a, error: s } = await r.from("blocks").select("id, page_id, post_id, product_id, language_id, block_type, content, order").eq("id", n.blockId).single();
2000
+ async function zt(e, t) {
2001
+ const n = ye.parse(e), r = C(t), o = Y(t), { data: a, error: s } = await r.from("blocks").select("id, page_id, post_id, product_id, language_id, block_type, content, order").eq("id", n.blockId).single();
1983
2002
  if (s || !a)
1984
- throw new Error(`Failed to read block ${n.blockId}: ${_(s)}`);
1985
- vt(a, o);
1986
- const l = ae(a.block_type, `Block ${n.blockId}`);
1987
- Et(n.blockType, l, `Block ${n.blockId}`);
1988
- const u = ee(a.content, `Block ${n.blockId}`), d = Kn(
1989
- l,
2003
+ throw new Error(`Failed to read block ${n.blockId}: ${y(s)}`);
2004
+ $t(a, o);
2005
+ const c = le(a.block_type, `Block ${n.blockId}`);
2006
+ At(n.blockType, c, `Block ${n.blockId}`);
2007
+ const u = re(a.content, `Block ${n.blockId}`), d = Vn(
2008
+ c,
1990
2009
  u,
1991
2010
  n.content,
1992
2011
  t
1993
2012
  );
1994
- D(l, d, `Block ${n.blockId}`, t);
1995
- const c = P({
2013
+ z(c, d, `Block ${n.blockId}`, t);
2014
+ const l = N({
1996
2015
  action: "UPDATE CONTENT BLOCK",
1997
2016
  context: t,
1998
2017
  payload: {
1999
2018
  blockId: n.blockId,
2000
- blockType: l,
2019
+ blockType: c,
2001
2020
  content: d,
2002
2021
  tool: "update_content_block"
2003
2022
  },
2004
2023
  preview: {
2005
2024
  blockId: n.blockId,
2006
- blockType: l,
2025
+ blockType: c,
2007
2026
  contentType: o.contentType,
2008
- entityId: Te(o)
2027
+ entityId: q(o)
2009
2028
  },
2010
- subject: `${l} block ${n.blockId}`
2029
+ subject: `${c} block ${n.blockId}`
2011
2030
  });
2012
- if (c)
2013
- return c;
2014
- const { data: m, error: h } = await r.from("blocks").update({
2031
+ if (l)
2032
+ return l;
2033
+ const m = await J(
2034
+ t,
2035
+ o.contentType,
2036
+ q(o)
2037
+ ), { data: h, error: p } = await r.from("blocks").update({
2015
2038
  content: d,
2016
2039
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2017
2040
  }).eq("id", n.blockId).select("id, block_type, order").single();
2018
- if (h || !m)
2019
- throw new Error(`Failed to update block ${n.blockId}: ${_(h)}`);
2020
- return await xe({
2021
- patch: ({ blocks: p }) => ({
2022
- blocks: p.map(
2041
+ if (p || !h)
2042
+ throw new Error(`Failed to update block ${n.blockId}: ${y(p)}`);
2043
+ return await G(
2044
+ t,
2045
+ o.contentType,
2046
+ q(o),
2047
+ m
2048
+ ), await ve({
2049
+ patch: ({ blocks: f }) => ({
2050
+ blocks: f.map(
2023
2051
  (g) => String(g?.id) === String(n.blockId) ? { ...g, content: d } : g
2024
2052
  )
2025
2053
  }),
2026
2054
  productId: a.product_id,
2027
2055
  supabase: r
2028
- }), ve([{ content: d }], r), U(t, o), {
2029
- blockId: m.id,
2030
- blockType: m.block_type,
2056
+ }), $e([{ content: d }], r), O(t, o), {
2057
+ blockId: h.id,
2058
+ blockType: h.block_type,
2031
2059
  contentUpdated: !0,
2032
2060
  mutationExecuted: !0,
2033
2061
  success: !0
2034
2062
  };
2035
2063
  }
2036
- async function Dt(e, t) {
2037
- const n = ye.parse(e), r = C(t), o = await te(n, t), a = o.contentType === "product" ? o.item.id : Number(o.item.id), s = o.contentType === "page" ? "page_id" : o.contentType === "post" ? "post_id" : "product_id", l = async () => {
2038
- const { data: b, error: I } = await r.from("blocks").select("id, page_id, post_id, product_id, language_id, block_type, content, order").eq(s, a);
2064
+ async function Gt(e, t) {
2065
+ const n = we.parse(e), r = C(t), o = await oe(n, t), a = o.contentType === "product" ? o.item.id : Number(o.item.id), s = o.contentType === "page" ? "page_id" : o.contentType === "post" ? "post_id" : "product_id", c = async () => {
2066
+ const { data: T, error: I } = await r.from("blocks").select("id, page_id, post_id, product_id, language_id, block_type, content, order").eq(s, a);
2039
2067
  if (I)
2040
- throw new Error(`Failed to read ${o.contentType} blocks: ${_(I)}`);
2041
- return (Array.isArray(b) ? b : []).sort(
2042
- (x, E) => Number(x.order) - Number(E.order)
2068
+ throw new Error(`Failed to read ${o.contentType} blocks: ${y(I)}`);
2069
+ return (Array.isArray(T) ? T : []).sort(
2070
+ ($, P) => Number($.order) - Number(P.order)
2043
2071
  );
2044
- }, u = (b) => {
2072
+ }, u = (T) => {
2045
2073
  if (n.position === "start")
2046
2074
  return 0;
2047
2075
  if (n.position === "end") {
2048
- const E = b.map((L) => Number(L.order)).filter(Number.isFinite);
2049
- return E.length > 0 ? Math.max(...E) + 1 : 0;
2076
+ const P = T.map((L) => Number(L.order)).filter(Number.isFinite);
2077
+ return P.length > 0 ? Math.max(...P) + 1 : 0;
2050
2078
  }
2051
- const I = n.anchorBlockId ? b.find((E) => Number(E.id) === n.anchorBlockId) : n.anchorBlockType ? b.find((E) => E.block_type === n.anchorBlockType) : null;
2079
+ const I = n.anchorBlockId ? T.find((P) => Number(P.id) === n.anchorBlockId) : n.anchorBlockType ? T.find((P) => P.block_type === n.anchorBlockType) : null;
2052
2080
  if (!I)
2053
2081
  throw new Error(
2054
2082
  n.anchorBlockType ? `Could not find a ${n.anchorBlockType} block to insert ${n.position}.` : `Could not find block ${n.anchorBlockId} to insert ${n.position}.`
2055
2083
  );
2056
- const x = Number(I.order);
2057
- return n.position === "before" ? x : x + 1;
2058
- }, d = ce(n.block, 0, t), c = await l(), m = u(c), h = {
2084
+ const $ = Number(I.order);
2085
+ return n.position === "before" ? $ : $ + 1;
2086
+ }, d = pe(n.block, 0, t), l = await c(), m = u(l), h = {
2059
2087
  contentType: o.contentType,
2060
2088
  entityId: o.item.id,
2061
2089
  languageId: o.item.language_id,
2062
2090
  slug: o.item.slug,
2063
2091
  title: o.item.title,
2064
2092
  translationGroupId: o.item.translation_group_id
2065
- }, p = P({
2093
+ }, p = N({
2066
2094
  action: "INSERT CONTENT BLOCK",
2067
2095
  context: t,
2068
2096
  payload: {
@@ -2090,118 +2118,118 @@ async function Dt(e, t) {
2090
2118
  });
2091
2119
  if (p)
2092
2120
  return p;
2093
- const g = await l(), f = u(g), k = g.filter((b) => Number(b.order) >= f).sort((b, I) => Number(I.order) - Number(b.order));
2094
- for (const b of k) {
2121
+ const f = await c(), g = u(f), b = f.filter((T) => Number(T.order) >= g).sort((T, I) => Number(I.order) - Number(T.order)), _ = await J(t, o.contentType, a);
2122
+ for (const T of b) {
2095
2123
  const { error: I } = await r.from("blocks").update({
2096
- order: Number(b.order) + 1,
2124
+ order: Number(T.order) + 1,
2097
2125
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2098
- }).eq("id", b.id);
2126
+ }).eq("id", T.id);
2099
2127
  if (I)
2100
- throw new Error(`Failed to shift block ${b.id}: ${_(I)}`);
2128
+ throw new Error(`Failed to shift block ${T.id}: ${y(I)}`);
2101
2129
  }
2102
- const { data: y, error: w } = await r.from("blocks").insert({
2130
+ const { data: w, error: k } = await r.from("blocks").insert({
2103
2131
  block_type: d.block_type,
2104
2132
  content: d.content,
2105
2133
  language_id: o.item.language_id,
2106
- order: f,
2134
+ order: g,
2107
2135
  page_id: o.contentType === "page" ? a : null,
2108
2136
  post_id: o.contentType === "post" ? a : null,
2109
2137
  product_id: o.contentType === "product" ? a : null
2110
2138
  }).select("id, block_type, order").single();
2111
- if (w || !y)
2112
- throw new Error(`Failed to insert content block: ${_(w)}`);
2113
- return o.contentType === "product" && await xe({
2114
- patch: ({ blocks: b }) => ({
2139
+ if (k || !w)
2140
+ throw new Error(`Failed to insert content block: ${y(k)}`);
2141
+ return o.contentType === "product" && await ve({
2142
+ patch: ({ blocks: T }) => ({
2115
2143
  blocks: [
2116
- ...b.map(
2117
- (I) => Number(I?.order) >= f ? { ...I, order: Number(I.order) + 1 } : I
2144
+ ...T.map(
2145
+ (I) => Number(I?.order) >= g ? { ...I, order: Number(I.order) + 1 } : I
2118
2146
  ),
2119
2147
  {
2120
2148
  block_type: d.block_type,
2121
2149
  content: d.content,
2122
- id: y.id,
2150
+ id: w.id,
2123
2151
  language_id: o.item.language_id,
2124
- order: f,
2152
+ order: g,
2125
2153
  page_id: null,
2126
2154
  post_id: null,
2127
2155
  product_id: a
2128
2156
  }
2129
- ].sort((I, x) => Number(I.order) - Number(x.order))
2157
+ ].sort((I, $) => Number(I.order) - Number($.order))
2130
2158
  }),
2131
2159
  productId: a,
2132
2160
  supabase: r
2133
- }), ve([d], r), U(t, h), {
2134
- blockId: y.id,
2135
- blockType: y.block_type,
2161
+ }), await G(t, o.contentType, a, _), $e([d], r), O(t, h), {
2162
+ blockId: w.id,
2163
+ blockType: w.block_type,
2136
2164
  contentType: o.contentType,
2137
2165
  entityId: o.item.id,
2138
2166
  mutationExecuted: !0,
2139
- order: y.order,
2167
+ order: w.order,
2140
2168
  success: !0
2141
2169
  };
2142
2170
  }
2143
- async function zt(e, t) {
2144
- const n = fe.parse(e), r = C(t), o = V(t), { data: a, error: s } = await r.from("blocks").select("id, page_id, post_id, product_id, language_id, block_type, content, order").eq("id", n.parentBlockId).single();
2171
+ async function Kt(e, t) {
2172
+ const n = _e.parse(e), r = C(t), o = Y(t), { data: a, error: s } = await r.from("blocks").select("id, page_id, post_id, product_id, language_id, block_type, content, order").eq("id", n.parentBlockId).single();
2145
2173
  if (s || !a)
2146
2174
  throw new Error(
2147
- `Failed to read parent block ${n.parentBlockId}: ${_(s)}`
2175
+ `Failed to read parent block ${n.parentBlockId}: ${y(s)}`
2148
2176
  );
2149
- vt(a, o);
2150
- const l = ae(
2177
+ $t(a, o);
2178
+ const c = le(
2151
2179
  a.block_type,
2152
2180
  `Parent block ${n.parentBlockId}`
2153
2181
  );
2154
- if (l !== "section")
2182
+ if (c !== "section")
2155
2183
  throw new Error(
2156
- `Parent block ${n.parentBlockId} must be a section block, not "${l}".`
2184
+ `Parent block ${n.parentBlockId} must be a section block, not "${c}".`
2157
2185
  );
2158
- const u = ee(
2186
+ const u = re(
2159
2187
  a.content,
2160
2188
  `Parent block ${n.parentBlockId}`
2161
2189
  );
2162
- D(
2163
- l,
2190
+ z(
2191
+ c,
2164
2192
  u,
2165
2193
  `Parent block ${n.parentBlockId}`,
2166
2194
  t
2167
2195
  );
2168
- const c = u.column_blocks?.[n.columnIndex]?.[n.blockIndex];
2169
- if (!c)
2196
+ const l = u.column_blocks?.[n.columnIndex]?.[n.blockIndex];
2197
+ if (!l)
2170
2198
  throw new Error(
2171
2199
  `Nested block was not found at column ${n.columnIndex}, index ${n.blockIndex}.`
2172
2200
  );
2173
- const m = ae(
2174
- c.block_type,
2201
+ const m = le(
2202
+ l.block_type,
2175
2203
  `Nested block ${n.columnIndex}:${n.blockIndex}`
2176
2204
  );
2177
- Et(
2205
+ At(
2178
2206
  n.blockType,
2179
2207
  m,
2180
2208
  `Nested block ${n.columnIndex}:${n.blockIndex}`
2181
- ), D(
2209
+ ), z(
2182
2210
  m,
2183
2211
  n.content,
2184
2212
  `Nested block ${n.columnIndex}:${n.blockIndex}`,
2185
2213
  t
2186
2214
  );
2187
2215
  const h = u.column_blocks.map(
2188
- (y, w) => w === n.columnIndex ? y.map(
2189
- (b, I) => I === n.blockIndex ? {
2190
- ...b,
2216
+ (w, k) => k === n.columnIndex ? w.map(
2217
+ (T, I) => I === n.blockIndex ? {
2218
+ ...T,
2191
2219
  content: n.content
2192
- } : b
2193
- ) : y
2220
+ } : T
2221
+ ) : w
2194
2222
  ), p = {
2195
2223
  ...u,
2196
2224
  column_blocks: h
2197
2225
  };
2198
- D(
2199
- l,
2226
+ z(
2227
+ c,
2200
2228
  p,
2201
2229
  `Updated parent block ${n.parentBlockId}`,
2202
2230
  t
2203
2231
  );
2204
- const g = P({
2232
+ const f = N({
2205
2233
  action: "UPDATE NESTED BLOCK",
2206
2234
  context: t,
2207
2235
  payload: {
@@ -2217,40 +2245,49 @@ async function zt(e, t) {
2217
2245
  columnIndex: n.columnIndex,
2218
2246
  nestedBlockType: m,
2219
2247
  parentBlockId: n.parentBlockId,
2220
- parentBlockType: l
2248
+ parentBlockType: c
2221
2249
  },
2222
2250
  subject: `${m} nested block ${n.columnIndex}:${n.blockIndex}`
2223
2251
  });
2224
- if (g)
2225
- return g;
2226
- const { data: f, error: k } = await r.from("blocks").update({
2252
+ if (f)
2253
+ return f;
2254
+ const g = await J(
2255
+ t,
2256
+ o.contentType,
2257
+ q(o)
2258
+ ), { data: b, error: _ } = await r.from("blocks").update({
2227
2259
  content: p,
2228
2260
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2229
2261
  }).eq("id", n.parentBlockId).select("id, block_type").single();
2230
- if (k || !f)
2262
+ if (_ || !b)
2231
2263
  throw new Error(
2232
- `Failed to update parent block ${n.parentBlockId}: ${_(k)}`
2264
+ `Failed to update parent block ${n.parentBlockId}: ${y(_)}`
2233
2265
  );
2234
- return await xe({
2235
- patch: ({ blocks: y }) => ({
2236
- blocks: y.map(
2237
- (w) => String(w?.id) === String(n.parentBlockId) ? { ...w, content: p } : w
2266
+ return await ve({
2267
+ patch: ({ blocks: w }) => ({
2268
+ blocks: w.map(
2269
+ (k) => String(k?.id) === String(n.parentBlockId) ? { ...k, content: p } : k
2238
2270
  )
2239
2271
  }),
2240
2272
  productId: a.product_id,
2241
2273
  supabase: r
2242
- }), U(t, o), {
2274
+ }), await G(
2275
+ t,
2276
+ o.contentType,
2277
+ q(o),
2278
+ g
2279
+ ), O(t, o), {
2243
2280
  blockIndex: n.blockIndex,
2244
2281
  columnIndex: n.columnIndex,
2245
2282
  mutationExecuted: !0,
2246
2283
  nestedBlockType: m,
2247
- parentBlockId: f.id,
2248
- parentBlockType: f.block_type,
2284
+ parentBlockId: b.id,
2285
+ parentBlockType: b.block_type,
2249
2286
  success: !0
2250
2287
  };
2251
2288
  }
2252
- async function Ve(e, t) {
2253
- const n = _e.parse(e), r = C(t), o = qe(t), a = await Ce(r, n.languageCode), s = q(n.slug || n.title), l = Se(n.blocks, n.contactEmail, n.title, t), u = await De({
2289
+ async function We(e, t) {
2290
+ const n = ke.parse(e), r = C(t), o = Me(t), a = await Se(r, n.languageCode), s = M(n.slug || n.title), c = Ee(n.blocks, n.contactEmail, n.title, t), u = await Ge({
2254
2291
  contentType: "page",
2255
2292
  languageId: a.id,
2256
2293
  slug: s,
@@ -2258,7 +2295,7 @@ async function Ve(e, t) {
2258
2295
  });
2259
2296
  if (u)
2260
2297
  return u;
2261
- const d = await ze({
2298
+ const d = await Ke({
2262
2299
  contentType: "page",
2263
2300
  languageCode: a.code,
2264
2301
  languageId: a.id,
@@ -2267,8 +2304,8 @@ async function Ve(e, t) {
2267
2304
  });
2268
2305
  if (d.result)
2269
2306
  return d.result;
2270
- const c = {
2271
- blocks: l,
2307
+ const l = {
2308
+ blocks: c,
2272
2309
  item: {
2273
2310
  feature_image_id: n.feature_image_id ?? null,
2274
2311
  language_id: a.id,
@@ -2280,12 +2317,12 @@ async function Ve(e, t) {
2280
2317
  translation_group_id: d.translationGroupId
2281
2318
  },
2282
2319
  tool: "create_cms_page"
2283
- }, m = P({
2320
+ }, m = N({
2284
2321
  action: "CREATE PAGE",
2285
2322
  context: t,
2286
- payload: c,
2323
+ payload: l,
2287
2324
  preview: {
2288
- blockCount: l.length,
2325
+ blockCount: c.length,
2289
2326
  languageCode: a.code,
2290
2327
  slug: s,
2291
2328
  status: n.status,
@@ -2296,47 +2333,47 @@ async function Ve(e, t) {
2296
2333
  });
2297
2334
  if (m)
2298
2335
  return m;
2299
- const h = d.translationGroupId || Re(), p = await Z(
2300
- c.item.feature_image_id,
2336
+ const h = d.translationGroupId || De(), p = await ne(
2337
+ l.item.feature_image_id,
2301
2338
  t,
2302
2339
  n.title
2303
- ), { data: g, error: f } = await r.from("pages").insert({
2304
- ...c.item,
2340
+ ), { data: f, error: g } = await r.from("pages").insert({
2341
+ ...l.item,
2305
2342
  author_id: o,
2306
2343
  feature_image_id: p,
2307
2344
  translation_group_id: h
2308
2345
  }).select("id, language_id, slug, status, title, translation_group_id").single();
2309
- if (f || !g?.id)
2310
- throw new Error(`Failed to create page: ${_(f)}`);
2346
+ if (g || !f?.id)
2347
+ throw new Error(`Failed to create page: ${y(g)}`);
2311
2348
  try {
2312
- await Ge({
2313
- blocks: l,
2349
+ await He({
2350
+ blocks: c,
2314
2351
  contentType: "page",
2315
- itemId: Number(g.id),
2352
+ itemId: Number(f.id),
2316
2353
  languageId: a.id,
2317
2354
  supabase: r
2318
2355
  });
2319
- } catch (k) {
2320
- throw await Ke({ contentType: "page", itemId: Number(g.id), supabase: r }), k;
2356
+ } catch (b) {
2357
+ throw await Ve({ contentType: "page", itemId: Number(f.id), supabase: r }), b;
2321
2358
  }
2322
- return U(
2359
+ return O(
2323
2360
  t,
2324
- { contentType: "page", entityId: Number(g.id), languageId: a.id, slug: s, title: n.title },
2361
+ { contentType: "page", entityId: Number(f.id), languageId: a.id, slug: s, title: n.title },
2325
2362
  s
2326
2363
  ), t?.revalidatePath?.("/cms/pages"), {
2327
- blockCount: l.length,
2364
+ blockCount: c.length,
2328
2365
  contentType: "page",
2329
- editPath: He("page", g.id),
2330
- entityId: g.id,
2366
+ editPath: Je("page", f.id),
2367
+ entityId: f.id,
2331
2368
  mutationExecuted: !0,
2332
2369
  slug: s,
2333
2370
  success: !0,
2334
2371
  title: n.title,
2335
- translationGroupId: g.translation_group_id
2372
+ translationGroupId: f.translation_group_id
2336
2373
  };
2337
2374
  }
2338
- async function Je(e, t) {
2339
- const n = be.parse(e), r = C(t), o = qe(t), a = await Ce(r, n.languageCode), s = q(n.slug || n.title), l = Se(n.blocks, void 0, void 0, t), u = await De({
2375
+ async function Ye(e, t) {
2376
+ const n = Ie.parse(e), r = C(t), o = Me(t), a = await Se(r, n.languageCode), s = M(n.slug || n.title), c = Ee(n.blocks, void 0, void 0, t), u = await Ge({
2340
2377
  contentType: "post",
2341
2378
  languageId: a.id,
2342
2379
  slug: s,
@@ -2344,7 +2381,7 @@ async function Je(e, t) {
2344
2381
  });
2345
2382
  if (u)
2346
2383
  return u;
2347
- const d = await ze({
2384
+ const d = await Ke({
2348
2385
  contentType: "post",
2349
2386
  languageCode: a.code,
2350
2387
  languageId: a.id,
@@ -2353,8 +2390,8 @@ async function Je(e, t) {
2353
2390
  });
2354
2391
  if (d.result)
2355
2392
  return d.result;
2356
- const c = n.published_at && !Number.isNaN(new Date(n.published_at).getTime()) ? new Date(n.published_at).toISOString() : n.published_at ?? null, m = {
2357
- blocks: l,
2393
+ const l = n.published_at && !Number.isNaN(new Date(n.published_at).getTime()) ? new Date(n.published_at).toISOString() : n.published_at ?? null, m = {
2394
+ blocks: c,
2358
2395
  item: {
2359
2396
  excerpt: n.excerpt ?? null,
2360
2397
  feature_image_id: n.feature_image_id ?? null,
@@ -2362,7 +2399,7 @@ async function Je(e, t) {
2362
2399
  language_id: a.id,
2363
2400
  meta_description: n.meta_description ?? null,
2364
2401
  meta_title: n.meta_title ?? null,
2365
- published_at: c,
2402
+ published_at: l,
2366
2403
  slug: s,
2367
2404
  status: n.status,
2368
2405
  subtitle: n.subtitle ?? null,
@@ -2370,12 +2407,12 @@ async function Je(e, t) {
2370
2407
  translation_group_id: d.translationGroupId
2371
2408
  },
2372
2409
  tool: "create_cms_post"
2373
- }, h = P({
2410
+ }, h = N({
2374
2411
  action: "CREATE POST",
2375
2412
  context: t,
2376
2413
  payload: m,
2377
2414
  preview: {
2378
- blockCount: l.length,
2415
+ blockCount: c.length,
2379
2416
  languageCode: a.code,
2380
2417
  slug: s,
2381
2418
  status: n.status,
@@ -2386,57 +2423,57 @@ async function Je(e, t) {
2386
2423
  });
2387
2424
  if (h)
2388
2425
  return h;
2389
- const p = d.translationGroupId || Re(), g = await Z(
2426
+ const p = d.translationGroupId || De(), f = await ne(
2390
2427
  m.item.feature_image_id,
2391
2428
  t,
2392
2429
  n.title
2393
- ), { data: f, error: k } = await r.from("posts").insert({
2430
+ ), { data: g, error: b } = await r.from("posts").insert({
2394
2431
  ...m.item,
2395
2432
  author_id: o,
2396
- feature_image_id: g,
2433
+ feature_image_id: f,
2397
2434
  translation_group_id: p
2398
2435
  }).select("id, language_id, slug, status, title, translation_group_id").single();
2399
- if (k || !f?.id)
2400
- throw new Error(`Failed to create post: ${_(k)}`);
2436
+ if (b || !g?.id)
2437
+ throw new Error(`Failed to create post: ${y(b)}`);
2401
2438
  try {
2402
- await Ge({
2403
- blocks: l,
2439
+ await He({
2440
+ blocks: c,
2404
2441
  contentType: "post",
2405
- itemId: Number(f.id),
2442
+ itemId: Number(g.id),
2406
2443
  languageId: a.id,
2407
2444
  supabase: r
2408
2445
  });
2409
- } catch (y) {
2410
- throw await Ke({ contentType: "post", itemId: Number(f.id), supabase: r }), y;
2446
+ } catch (_) {
2447
+ throw await Ve({ contentType: "post", itemId: Number(g.id), supabase: r }), _;
2411
2448
  }
2412
- return U(
2449
+ return O(
2413
2450
  t,
2414
- { contentType: "post", entityId: Number(f.id), languageId: a.id, slug: s, title: n.title },
2451
+ { contentType: "post", entityId: Number(g.id), languageId: a.id, slug: s, title: n.title },
2415
2452
  s
2416
2453
  ), t?.revalidatePath?.("/cms/posts"), t?.revalidatePath?.("/articles"), {
2417
- blockCount: l.length,
2454
+ blockCount: c.length,
2418
2455
  contentType: "post",
2419
- editPath: He("post", f.id),
2420
- entityId: f.id,
2456
+ editPath: Je("post", g.id),
2457
+ entityId: g.id,
2421
2458
  mutationExecuted: !0,
2422
2459
  slug: s,
2423
2460
  success: !0,
2424
2461
  title: n.title,
2425
- translationGroupId: f.translation_group_id
2462
+ translationGroupId: g.translation_group_id
2426
2463
  };
2427
2464
  }
2428
- function vr(e, t) {
2429
- return (t || q(e) || "product").replace(/-/g, "").slice(0, 24).toUpperCase();
2465
+ function $r(e, t) {
2466
+ return (t || M(e) || "product").replace(/-/g, "").slice(0, 24).toUpperCase();
2430
2467
  }
2431
- function Gt(e) {
2468
+ function Ht(e) {
2432
2469
  if (e == null)
2433
2470
  return;
2434
2471
  if (typeof e == "string")
2435
- return pt(e) ?? void 0;
2436
- const t = Array.isArray(e) ? { content: e, type: "doc" } : $(e) && e.type !== "doc" && Array.isArray(e.content) ? { ...e, type: "doc" } : e, n = et().safeParse(t);
2472
+ return gt(e) ?? void 0;
2473
+ const t = Array.isArray(e) ? { content: e, type: "doc" } : E(e) && e.type !== "doc" && Array.isArray(e.content) ? { ...e, type: "doc" } : e, n = nt().safeParse(t);
2437
2474
  if (!n.success) {
2438
- if ($(e) && typeof e.type == "string") {
2439
- const r = et().safeParse({
2475
+ if (E(e) && typeof e.type == "string") {
2476
+ const r = nt().safeParse({
2440
2477
  content: [e],
2441
2478
  type: "doc"
2442
2479
  });
@@ -2449,23 +2486,23 @@ function Gt(e) {
2449
2486
  }
2450
2487
  return n.data;
2451
2488
  }
2452
- function Er(e) {
2453
- const t = (o) => !!(o && Array.isArray(o.content) && o.content.length > 0), n = Gt(e.description_json);
2489
+ function Ar(e) {
2490
+ const t = (o) => !!(o && Array.isArray(o.content) && o.content.length > 0), n = Ht(e.description_json);
2454
2491
  if (t(n))
2455
2492
  return n;
2456
- const r = e.description_html ? pt(e.description_html) : null;
2493
+ const r = e.description_html ? gt(e.description_html) : null;
2457
2494
  return t(r) ? r : void 0;
2458
2495
  }
2459
- async function Kt(e, t) {
2460
- const n = ke.parse(e), r = C(t), o = await Ce(r, n.languageCode), a = q(n.slug || n.title), s = Se(n.blocks, void 0, void 0, t), l = await De({
2496
+ async function Vt(e, t) {
2497
+ const n = Te.parse(e), r = C(t), o = await Se(r, n.languageCode), a = M(n.slug || n.title), s = Ee(n.blocks, void 0, void 0, t), c = await Ge({
2461
2498
  contentType: "product",
2462
2499
  languageId: o.id,
2463
2500
  slug: a,
2464
2501
  supabase: r
2465
2502
  });
2466
- if (l)
2467
- return l;
2468
- const u = await ze({
2503
+ if (c)
2504
+ return c;
2505
+ const u = await Ke({
2469
2506
  contentType: "product",
2470
2507
  languageCode: o.code,
2471
2508
  languageId: o.id,
@@ -2474,8 +2511,8 @@ async function Kt(e, t) {
2474
2511
  });
2475
2512
  if (u.result)
2476
2513
  return u.result;
2477
- const { createProduct: d, productSchema: c } = await On(), h = n.product_type === "digital" && n.payment_provider === "freemius" ? n.trial_period_days : 0, p = c.parse({
2478
- description_json: Er(n),
2514
+ const { createProduct: d, productSchema: l } = await jn(), h = n.product_type === "digital" && n.payment_provider === "freemius" ? n.trial_period_days : 0, p = l.parse({
2515
+ description_json: Ar(n),
2479
2516
  freemius_plan_id: n.freemius_plan_id || "",
2480
2517
  freemius_product_id: n.freemius_product_id || "",
2481
2518
  is_taxable: n.is_taxable,
@@ -2490,7 +2527,7 @@ async function Kt(e, t) {
2490
2527
  sale_price: n.sale_price ?? null,
2491
2528
  sale_prices: n.sale_prices || {},
2492
2529
  short_description: n.short_description ?? "",
2493
- sku: n.sku || vr(n.title, a),
2530
+ sku: n.sku || $r(n.title, a),
2494
2531
  slug: a,
2495
2532
  status: n.status,
2496
2533
  stock: n.stock,
@@ -2501,14 +2538,14 @@ async function Kt(e, t) {
2501
2538
  upc: n.upc ?? "",
2502
2539
  variation_attributes: [],
2503
2540
  variants: []
2504
- }), g = n.images ?? [], f = P({
2541
+ }), f = n.images ?? [], g = N({
2505
2542
  action: "CREATE PRODUCT",
2506
2543
  context: t,
2507
- payload: { blocks: s, images: g, item: p, tool: "create_cms_product" },
2544
+ payload: { blocks: s, images: f, item: p, tool: "create_cms_product" },
2508
2545
  preview: {
2509
2546
  blockCount: s.length,
2510
2547
  descriptionLength: p.description_json ? JSON.stringify(p.description_json).length : 0,
2511
- imageCount: g.length,
2548
+ imageCount: f.length,
2512
2549
  languageCode: o.code,
2513
2550
  price: p.price,
2514
2551
  sku: p.sku,
@@ -2520,45 +2557,45 @@ async function Kt(e, t) {
2520
2557
  },
2521
2558
  subject: a
2522
2559
  });
2523
- if (f)
2524
- return f;
2525
- let k = [], y = null;
2526
- if (g.length > 0)
2560
+ if (g)
2561
+ return g;
2562
+ let b = [], _ = null;
2563
+ if (f.length > 0)
2527
2564
  try {
2528
- if (k = [...new Set(await It(g, t, n.title))], k.length === 0)
2565
+ if (b = [...new Set(await xt(f, t, n.title))], b.length === 0)
2529
2566
  throw new Error("None of the provided images could be resolved to a media item.");
2530
- } catch (b) {
2531
- y = b instanceof Error ? b.message : String(b);
2567
+ } catch (k) {
2568
+ _ = k instanceof Error ? k.message : String(k);
2532
2569
  }
2533
2570
  const w = await d(r, {
2534
2571
  ...p,
2535
2572
  // First entry is the main product image; the rest become the gallery in order.
2536
- product_media: k.map((b) => ({ media_id: b }))
2573
+ product_media: b.map((k) => ({ media_id: k }))
2537
2574
  });
2538
2575
  if (!w?.id)
2539
2576
  throw new Error("Failed to create product.");
2540
2577
  try {
2541
- await Ge({
2578
+ await He({
2542
2579
  blocks: s,
2543
2580
  contentType: "product",
2544
2581
  itemId: w.id,
2545
2582
  languageId: o.id,
2546
2583
  supabase: r
2547
2584
  });
2548
- } catch (b) {
2549
- throw await Ke({ contentType: "product", itemId: w.id, supabase: r }), b;
2585
+ } catch (k) {
2586
+ throw await Ve({ contentType: "product", itemId: w.id, supabase: r }), k;
2550
2587
  }
2551
- return U(
2588
+ return O(
2552
2589
  t,
2553
2590
  { contentType: "product", entityId: w.id, languageId: o.id, slug: a, title: n.title },
2554
2591
  a
2555
2592
  ), t?.revalidatePath?.("/cms/products"), {
2556
2593
  blockCount: s.length,
2557
2594
  contentType: "product",
2558
- editPath: He("product", w.id),
2595
+ editPath: Je("product", w.id),
2559
2596
  entityId: w.id,
2560
- imageCount: k.length,
2561
- ...y ? { imageError: y } : {},
2597
+ imageCount: b.length,
2598
+ ..._ ? { imageError: _ } : {},
2562
2599
  mutationExecuted: !0,
2563
2600
  slug: a,
2564
2601
  success: !0,
@@ -2566,32 +2603,32 @@ async function Kt(e, t) {
2566
2603
  translationGroupId: w.translation_group_id
2567
2604
  };
2568
2605
  }
2569
- function We(e) {
2606
+ function Xe(e) {
2570
2607
  return e.trim().replace(/[\s-]+/g, "_").toLowerCase();
2571
2608
  }
2572
- function $r(e, t) {
2573
- const n = typeof t == "string" ? We(t) : t;
2609
+ function Pr(e, t) {
2610
+ const n = typeof t == "string" ? Xe(t) : t;
2574
2611
  return e === "product" ? n === "public" || n === "publish" || n === "published" ? "active" : n : n === "public" || n === "active" || n === "publish" ? "published" : n;
2575
2612
  }
2576
- function Ar(e) {
2577
- const t = We(e.field);
2613
+ function Nr(e) {
2614
+ const t = Xe(e.field);
2578
2615
  return !!(e.startsAt || e.endsAt || t.includes("start") || t.includes("end") || t.includes("schedule") || t.includes("special_date"));
2579
2616
  }
2580
- async function Pr(e, t, n) {
2617
+ async function Ur(e, t, n) {
2581
2618
  if (e === "price" || e === "sale_price") {
2582
2619
  if (t == null)
2583
2620
  return { [e]: null };
2584
- const r = await nt(n);
2585
- return { [e]: St(Number(t), r) };
2621
+ const r = await ot(n);
2622
+ return { [e]: Et(Number(t), r) };
2586
2623
  }
2587
2624
  if (e === "prices" || e === "sale_prices") {
2588
- const r = await nt(n);
2589
- return { [e]: Rn(t, r) };
2625
+ const r = await ot(n);
2626
+ return { [e]: Dn(t, r) };
2590
2627
  }
2591
- return e === "description_json" ? { description_json: Gt(t) } : { [e]: t };
2628
+ return e === "description_json" ? { description_json: Ht(t) } : { [e]: t };
2592
2629
  }
2593
- function Nr(e, t) {
2594
- const n = We(e.field), r = n === "status" ? $r(t.contentType, e.value) : e.value, a = {
2630
+ function Or(e, t) {
2631
+ const n = Xe(e.field), r = n === "status" ? Pr(t.contentType, e.value) : e.value, a = {
2595
2632
  description: "description_json",
2596
2633
  feature_image: "feature_image_id",
2597
2634
  feature_image_id: "feature_image_id",
@@ -2611,12 +2648,12 @@ function Nr(e, t) {
2611
2648
  type: "product_type"
2612
2649
  }[n] || n;
2613
2650
  if (t.contentType !== "product") {
2614
- if (!(t.contentType === "page" ? Lt : Bt).has(a))
2651
+ if (!(t.contentType === "page" ? Rt : qt).has(a))
2615
2652
  throw new Error(`Field "${e.field}" cannot be updated for ${t.contentType}.`);
2616
- return a === "status" && Ne(t.contentType, r), {
2653
+ return a === "status" && Oe(t.contentType, r), {
2617
2654
  field: a,
2618
2655
  payload: {
2619
- [a]: qt(a, r)
2656
+ [a]: Mt(a, r)
2620
2657
  }
2621
2658
  };
2622
2659
  }
@@ -2645,7 +2682,7 @@ function Nr(e, t) {
2645
2682
  "upc"
2646
2683
  ])).has(a))
2647
2684
  throw new Error(`Field "${e.field}" cannot be updated for product.`);
2648
- if (a === "status" && Ne("product", r), (a === "price" || a === "sale_price") && r !== null && (typeof r != "number" || r < 0))
2685
+ if (a === "status" && Oe("product", r), (a === "price" || a === "sale_price") && r !== null && (typeof r != "number" || r < 0))
2649
2686
  throw new Error(`${a} must be a non-negative number or null.`);
2650
2687
  if (a === "stock" && (!Number.isInteger(r) || Number(r) < 0))
2651
2688
  throw new Error("stock must be a non-negative integer.");
@@ -2660,25 +2697,25 @@ function Nr(e, t) {
2660
2697
  }
2661
2698
  };
2662
2699
  }
2663
- async function Ht(e, t) {
2664
- const n = we.parse(e);
2665
- if (Ar(n))
2700
+ async function Jt(e, t) {
2701
+ const n = xe.parse(e);
2702
+ if (Nr(n))
2666
2703
  return {
2667
2704
  message: "Scheduled product specials are not supported by the current product schema yet. I can set or clear sale_price now, but not start/end dates.",
2668
2705
  mutationExecuted: !1,
2669
2706
  success: !1,
2670
2707
  unsupported: !0
2671
2708
  };
2672
- const r = await te(n, t), o = Nr(n, r), a = o.field;
2709
+ const r = await oe(n, t), o = Or(n, r), a = o.field;
2673
2710
  let s = o.payload;
2674
2711
  if (a === "language_id" && typeof s.language_id == "string") {
2675
- const m = await J(C(t), s.language_id);
2712
+ const h = await X(C(t), s.language_id);
2676
2713
  s = {
2677
2714
  ...s,
2678
- language_id: m.id
2715
+ language_id: h.id
2679
2716
  };
2680
2717
  }
2681
- const l = P({
2718
+ const c = N({
2682
2719
  action: "UPDATE FIELD",
2683
2720
  context: t,
2684
2721
  payload: {
@@ -2698,75 +2735,80 @@ async function Ht(e, t) {
2698
2735
  },
2699
2736
  subject: `${r.contentType} ${r.item.slug || r.item.id} ${a}`
2700
2737
  });
2701
- if (l)
2702
- return l;
2738
+ if (c)
2739
+ return c;
2740
+ const u = await J(
2741
+ t,
2742
+ r.contentType,
2743
+ r.item.id
2744
+ );
2703
2745
  if (r.contentType === "product") {
2704
- const m = C(t), h = await Pr(a, s[a], m), { data: p, error: g } = await m.from("products").update({
2705
- ...h,
2746
+ const h = C(t), p = await Ur(a, s[a], h), { data: f, error: g } = await h.from("products").update({
2747
+ ...p,
2706
2748
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2707
2749
  }).eq("id", r.item.id).select("id, language_id, slug, status, title").single();
2708
- if (g || !p)
2709
- throw new Error(`Failed to update product: ${_(g)}`);
2710
- return U(
2750
+ if (g || !f)
2751
+ throw new Error(`Failed to update product: ${y(g)}`);
2752
+ return O(
2711
2753
  t,
2712
2754
  {
2713
2755
  contentType: "product",
2714
- entityId: String(p.id),
2715
- languageId: p.language_id,
2716
- slug: p.slug,
2717
- title: p.title
2756
+ entityId: String(f.id),
2757
+ languageId: f.language_id,
2758
+ slug: f.slug,
2759
+ title: f.title
2718
2760
  },
2719
- p.slug
2720
- ), {
2761
+ f.slug
2762
+ ), await G(t, "product", f.id, u), {
2721
2763
  contentType: "product",
2722
- entityId: p.id,
2764
+ entityId: f.id,
2723
2765
  field: a,
2724
2766
  mutationExecuted: !0,
2725
- slug: p.slug,
2767
+ slug: f.slug,
2726
2768
  success: !0,
2727
2769
  updatedFields: [a]
2728
2770
  };
2729
2771
  }
2730
2772
  a === "feature_image_id" && typeof s.feature_image_id == "string" && (s = {
2731
2773
  ...s,
2732
- feature_image_id: await Z(
2774
+ feature_image_id: await ne(
2733
2775
  s.feature_image_id,
2734
2776
  t,
2735
2777
  typeof r.item.title == "string" ? r.item.title : void 0
2736
2778
  )
2737
2779
  });
2738
- const u = r.contentType === "page" ? "pages" : "posts", { data: d, error: c } = await C(t).from(u).update({
2780
+ const d = r.contentType === "page" ? "pages" : "posts", { data: l, error: m } = await C(t).from(d).update({
2739
2781
  ...s,
2740
2782
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2741
2783
  }).eq("id", r.item.id).select("id, language_id, slug, status, title").single();
2742
- if (c || !d)
2743
- throw new Error(`Failed to update ${r.contentType}: ${_(c)}`);
2744
- return U(
2784
+ if (m || !l)
2785
+ throw new Error(`Failed to update ${r.contentType}: ${y(m)}`);
2786
+ return O(
2745
2787
  t,
2746
2788
  {
2747
2789
  contentType: r.contentType,
2748
- entityId: Number(d.id),
2749
- languageId: d.language_id,
2750
- slug: d.slug,
2751
- title: d.title
2790
+ entityId: Number(l.id),
2791
+ languageId: l.language_id,
2792
+ slug: l.slug,
2793
+ title: l.title
2752
2794
  },
2753
- d.slug
2754
- ), {
2795
+ l.slug
2796
+ ), await G(t, r.contentType, l.id, u), {
2755
2797
  contentType: r.contentType,
2756
- entityId: d.id,
2798
+ entityId: l.id,
2757
2799
  field: a,
2758
2800
  mutationExecuted: !0,
2759
- slug: d.slug,
2801
+ slug: l.slug,
2760
2802
  success: !0,
2761
2803
  updatedFields: [a]
2762
2804
  };
2763
2805
  }
2764
- async function Vt(e, t) {
2765
- const n = _t.parse(e), r = await te(n, t);
2806
+ async function Wt(e, t) {
2807
+ const n = wt.parse(e), r = await oe(n, t);
2766
2808
  if (r.contentType === "product")
2767
2809
  return {
2768
2810
  affectedCount: 1,
2769
- collectionPath: ot("product"),
2811
+ collectionPath: at("product"),
2770
2812
  contentType: "product",
2771
2813
  item: r.item,
2772
2814
  navigationLinkCount: 0,
@@ -2775,39 +2817,39 @@ async function Vt(e, t) {
2775
2817
  };
2776
2818
  const o = r.contentType === "page" ? "pages" : "posts", { data: a, error: s } = await C(t).from(o).select("id, slug, title, translation_group_id").eq("translation_group_id", r.item.translation_group_id);
2777
2819
  if (s)
2778
- throw new Error(`Failed to inspect related ${r.contentType}s: ${_(s)}`);
2779
- const l = Array.isArray(a) ? a : [], u = l.map(
2820
+ throw new Error(`Failed to inspect related ${r.contentType}s: ${y(s)}`);
2821
+ const c = Array.isArray(a) ? a : [], u = c.map(
2780
2822
  (p) => r.contentType === "page" ? p.slug === "home" ? "/" : `/${p.slug}` : `/article/${p.slug}`
2781
- ).filter(Boolean), d = new Set(u), { data: c, error: m } = await C(t).from("navigation_items").select("id, url");
2823
+ ).filter(Boolean), d = new Set(u), { data: l, error: m } = await C(t).from("navigation_items").select("id, url");
2782
2824
  if (m)
2783
- throw new Error(`Failed to inspect related navigation links: ${_(m)}`);
2784
- const h = (Array.isArray(c) ? c : []).filter(
2825
+ throw new Error(`Failed to inspect related navigation links: ${y(m)}`);
2826
+ const h = (Array.isArray(l) ? l : []).filter(
2785
2827
  (p) => d.has(p.url)
2786
2828
  ).length;
2787
2829
  return {
2788
- affectedCount: l.length,
2789
- collectionPath: ot(r.contentType),
2830
+ affectedCount: c.length,
2831
+ collectionPath: at(r.contentType),
2790
2832
  contentType: r.contentType,
2791
2833
  item: r.item,
2792
2834
  navigationLinkCount: h,
2793
2835
  publicPaths: u,
2794
- targetIds: l.map((p) => p.id)
2836
+ targetIds: c.map((p) => p.id)
2795
2837
  };
2796
2838
  }
2797
- function Jt(e) {
2839
+ function Yt(e) {
2798
2840
  const t = e.item.title || e.item.slug || "selected item", n = e.item.slug ? ` (${e.item.slug})` : "";
2799
2841
  if (e.contentType === "product")
2800
2842
  return `Delete product "${t}"${n}.`;
2801
2843
  const r = [
2802
- `${N(e.affectedCount, "language version")}`,
2803
- e.navigationLinkCount > 0 ? `${N(e.navigationLinkCount, "navigation link")}` : null
2844
+ `${U(e.affectedCount, "language version")}`,
2845
+ e.navigationLinkCount > 0 ? `${U(e.navigationLinkCount, "navigation link")}` : null
2804
2846
  ].filter(Boolean);
2805
2847
  return `Delete ${e.contentType} "${t}"${n}, including ${r.join(" and ")}.`;
2806
2848
  }
2807
- async function Ur(e, t) {
2808
- const n = await Vt(e, t);
2849
+ async function Fr(e, t) {
2850
+ const n = await Wt(e, t);
2809
2851
  return {
2810
- ...Ct({
2852
+ ...St({
2811
2853
  action: `DELETE ${n.contentType}`,
2812
2854
  payload: {
2813
2855
  affectedCount: n.affectedCount,
@@ -2822,7 +2864,7 @@ async function Ur(e, t) {
2822
2864
  navigationLinkCount: n.navigationLinkCount,
2823
2865
  publicPaths: n.publicPaths,
2824
2866
  slug: n.item.slug,
2825
- summary: Jt(n),
2867
+ summary: Yt(n),
2826
2868
  title: n.item.title
2827
2869
  },
2828
2870
  subject: `${n.item.id} ${n.item.slug || ""}`
@@ -2830,8 +2872,8 @@ async function Ur(e, t) {
2830
2872
  preparedDelete: !0
2831
2873
  };
2832
2874
  }
2833
- async function Wt(e, t) {
2834
- const n = Ie.parse(e), r = await Vt(n, t), o = P({
2875
+ async function Xt(e, t) {
2876
+ const n = Ce.parse(e), r = await Wt(n, t), o = N({
2835
2877
  action: `DELETE ${r.contentType}`,
2836
2878
  context: t,
2837
2879
  payload: {
@@ -2847,7 +2889,7 @@ async function Wt(e, t) {
2847
2889
  navigationLinkCount: r.navigationLinkCount,
2848
2890
  publicPaths: r.publicPaths,
2849
2891
  slug: r.item.slug,
2850
- summary: Jt(r),
2892
+ summary: Yt(r),
2851
2893
  title: r.item.title
2852
2894
  },
2853
2895
  subject: `${r.item.id} ${r.item.slug || ""}`
@@ -2856,18 +2898,18 @@ async function Wt(e, t) {
2856
2898
  return o;
2857
2899
  const a = C(t);
2858
2900
  if (r.contentType === "product") {
2859
- const { error: l } = await a.from("products").delete().eq("id", r.item.id);
2860
- if (l)
2861
- throw new Error(`Failed to delete product: ${_(l)}`);
2901
+ const { error: c } = await a.from("products").delete().eq("id", r.item.id);
2902
+ if (c)
2903
+ throw new Error(`Failed to delete product: ${y(c)}`);
2862
2904
  } else {
2863
2905
  for (const d of r.publicPaths)
2864
2906
  await a.from("navigation_items").delete().eq("url", d);
2865
- const l = r.contentType === "page" ? "pages" : "posts", { error: u } = await a.from(l).delete().eq("translation_group_id", r.item.translation_group_id);
2907
+ const c = r.contentType === "page" ? "pages" : "posts", { error: u } = await a.from(c).delete().eq("translation_group_id", r.item.translation_group_id);
2866
2908
  if (u)
2867
- throw new Error(`Failed to delete ${r.contentType}: ${_(u)}`);
2909
+ throw new Error(`Failed to delete ${r.contentType}: ${y(u)}`);
2868
2910
  }
2869
- const s = t?.revalidatePath ?? Le();
2870
- return s && (s(r.collectionPath), s("/cms/navigation"), r.publicPaths.forEach((l) => s(l))), {
2911
+ const s = t?.revalidatePath ?? Re();
2912
+ return s && (s(r.collectionPath), s("/cms/navigation"), r.publicPaths.forEach((c) => s(c))), {
2871
2913
  affectedCount: r.affectedCount,
2872
2914
  collectionPath: r.collectionPath,
2873
2915
  contentType: r.contentType,
@@ -2876,35 +2918,35 @@ async function Wt(e, t) {
2876
2918
  success: !0
2877
2919
  };
2878
2920
  }
2879
- async function st(e, t) {
2921
+ async function lt(e, t) {
2880
2922
  switch (e.tool) {
2881
2923
  case "create_cms_page":
2882
- return Ve(e.input, t);
2924
+ return We(e.input, t);
2883
2925
  case "create_cms_post":
2884
- return Je(e.input, t);
2926
+ return Ye(e.input, t);
2885
2927
  case "create_cms_product":
2886
- return Kt(e.input, t);
2928
+ return Vt(e.input, t);
2887
2929
  case "delete_cms_item":
2888
- return Wt(e.input, t);
2930
+ return Xt(e.input, t);
2889
2931
  case "update_cms_item_field":
2890
- return Ht(e.input, t);
2932
+ return Jt(e.input, t);
2891
2933
  case "update_content_block":
2892
- return Mt(e.input, t);
2934
+ return zt(e.input, t);
2893
2935
  case "insert_content_block":
2894
- return Dt(e.input, t);
2936
+ return Gt(e.input, t);
2895
2937
  case "update_current_cms_fields":
2896
- return Rt(e.input, t);
2938
+ return Dt(e.input, t);
2897
2939
  case "update_footer":
2898
- return Ft(e.input, t);
2940
+ return Lt(e.input, t);
2899
2941
  case "update_navigation_bar":
2900
- return Ot(e.input, t);
2942
+ return jt(e.input, t);
2901
2943
  case "update_section_column_block":
2902
- return zt(e.input, t);
2944
+ return Kt(e.input, t);
2903
2945
  case "set_content_images":
2904
- return on(e.input, t);
2946
+ return sn(e.input, t);
2905
2947
  }
2906
2948
  }
2907
- function Or(e, t) {
2949
+ function jr(e, t) {
2908
2950
  if (e.tool !== "create_cms_page" && e.tool !== "create_cms_post" && e.tool !== "create_cms_product" || e.input.translationGroupId || !e.input.languageCode)
2909
2951
  return e;
2910
2952
  const n = t[e.tool];
@@ -2916,17 +2958,17 @@ function Or(e, t) {
2916
2958
  }
2917
2959
  } : e;
2918
2960
  }
2919
- function lt(e) {
2961
+ function ut(e) {
2920
2962
  return e === "create_cms_page" ? "page" : e === "create_cms_post" ? "post" : "product";
2921
2963
  }
2922
- function Fr(e, t, n) {
2964
+ function Lr(e, t, n) {
2923
2965
  if (e.tool !== "set_content_images")
2924
2966
  return e;
2925
2967
  const r = e.input;
2926
2968
  if (r.entityId !== void 0)
2927
2969
  return e;
2928
2970
  const o = r.slug ? t.get(
2929
- `${r.contentType || "product"}:${q(r.slug)}`
2971
+ `${r.contentType || "product"}:${M(r.slug)}`
2930
2972
  ) : n;
2931
2973
  return o ? {
2932
2974
  ...e,
@@ -2937,91 +2979,91 @@ function Fr(e, t, n) {
2937
2979
  }
2938
2980
  } : e;
2939
2981
  }
2940
- async function jr(e, t) {
2941
- const n = kt.parse(e), r = new Set(
2982
+ async function Br(e, t) {
2983
+ const n = It.parse(e), r = new Set(
2942
2984
  n.actions.filter(
2943
2985
  (p) => p.tool === "create_cms_page" || p.tool === "create_cms_post" || p.tool === "create_cms_product"
2944
2986
  ).map((p) => {
2945
- const g = p.input;
2946
- return `${lt(p.tool)}:${q(g.slug || g.title || "")}`;
2987
+ const f = p.input;
2988
+ return `${ut(p.tool)}:${M(f.slug || f.title || "")}`;
2947
2989
  })
2948
2990
  ), o = (p) => {
2949
2991
  if (p.tool !== "set_content_images")
2950
2992
  return !1;
2951
- const g = p.input;
2952
- return g.slug ? r.has(
2953
- `${g.contentType || "product"}:${q(g.slug)}`
2993
+ const f = p.input;
2994
+ return f.slug ? r.has(
2995
+ `${f.contentType || "product"}:${M(f.slug)}`
2954
2996
  ) : r.size > 0;
2955
2997
  };
2956
2998
  if (!t?.skipConfirmation) {
2957
2999
  const p = [];
2958
- for (const k of n.actions) {
2959
- if (o(k)) {
2960
- const w = k.input;
3000
+ for (const b of n.actions) {
3001
+ if (o(b)) {
3002
+ const w = b.input;
2961
3003
  p.push(
2962
- `Set ${N(w.images.length, "image")} on the ${w.slug ? `"${w.slug}"` : "new"} item created in this plan.`
3004
+ `Set ${U(w.images.length, "image")} on the ${w.slug ? `"${w.slug}"` : "new"} item created in this plan.`
2963
3005
  );
2964
3006
  continue;
2965
3007
  }
2966
- const y = await st(k, {
3008
+ const _ = await lt(b, {
2967
3009
  ...t,
2968
3010
  latestUserMessage: null
2969
3011
  });
2970
- if (!y || typeof y != "object")
3012
+ if (!_ || typeof _ != "object")
2971
3013
  return {
2972
3014
  message: `Could not prepare action ${p.length + 1}.`,
2973
3015
  mutationExecuted: !1,
2974
3016
  success: !1
2975
3017
  };
2976
- if (y.success === !1 || y.unsupported === !0)
2977
- return y;
2978
- y.requiresConfirmation === !0 && y.preview ? p.push(
2979
- Ln(k.tool, y.preview)
2980
- ) : p.push(`Run ${k.tool.replace(/_/g, " ")}.`);
3018
+ if (_.success === !1 || _.unsupported === !0)
3019
+ return _;
3020
+ _.requiresConfirmation === !0 && _.preview ? p.push(
3021
+ Rn(b.tool, _.preview)
3022
+ ) : p.push(`Run ${b.tool.replace(/_/g, " ")}.`);
2981
3023
  }
2982
- const g = n.summary || `Complete ${N(n.actions.length, "CMS action")}.`, f = P({
3024
+ const f = n.summary || `Complete ${U(n.actions.length, "CMS action")}.`, g = N({
2983
3025
  action: "EXECUTE CMS ACTION PLAN",
2984
3026
  context: t,
2985
3027
  payload: { actions: n.actions, tool: "execute_cms_action_plan" },
2986
3028
  preview: {
2987
3029
  actionCount: n.actions.length,
2988
3030
  actionSummaries: p,
2989
- summary: g
3031
+ summary: f
2990
3032
  },
2991
3033
  subject: `${n.actions.length} actions`
2992
3034
  });
2993
- if (f)
2994
- return f;
3035
+ if (g)
3036
+ return g;
2995
3037
  }
2996
3038
  const a = {
2997
3039
  ...t,
2998
3040
  skipConfirmation: !0
2999
3041
  }, s = [];
3000
- let l = !1, u = null, d = null;
3001
- const c = {}, m = /* @__PURE__ */ new Map();
3042
+ let c = !1, u = null, d = null;
3043
+ const l = {}, m = /* @__PURE__ */ new Map();
3002
3044
  let h = null;
3003
- for (const [p, g] of n.actions.entries()) {
3004
- const f = Fr(
3005
- Or(g, c),
3045
+ for (const [p, f] of n.actions.entries()) {
3046
+ const g = Lr(
3047
+ jr(f, l),
3006
3048
  m,
3007
3049
  h
3008
- ), k = await st(f, a);
3009
- if (s.push({ output: k, tool: f.tool }), k && typeof k == "object") {
3010
- const y = k;
3011
- if (y.mutationExecuted === !0 && (l = !0), !u && typeof y.editPath == "string" && (u = y.editPath), typeof y.redirectPath == "string" && (d = y.redirectPath), (f.tool === "create_cms_page" || f.tool === "create_cms_post" || f.tool === "create_cms_product") && (typeof y.translationGroupId == "string" && (c[f.tool] = y.translationGroupId), y.entityId !== void 0 && y.entityId !== null)) {
3012
- const w = lt(f.tool), b = {
3050
+ ), b = await lt(g, a);
3051
+ if (s.push({ output: b, tool: g.tool }), b && typeof b == "object") {
3052
+ const _ = b;
3053
+ if (_.mutationExecuted === !0 && (c = !0), !u && typeof _.editPath == "string" && (u = _.editPath), typeof _.redirectPath == "string" && (d = _.redirectPath), (g.tool === "create_cms_page" || g.tool === "create_cms_post" || g.tool === "create_cms_product") && (typeof _.translationGroupId == "string" && (l[g.tool] = _.translationGroupId), _.entityId !== void 0 && _.entityId !== null)) {
3054
+ const w = ut(g.tool), k = {
3013
3055
  contentType: w,
3014
- entityId: y.entityId
3056
+ entityId: _.entityId
3015
3057
  };
3016
- h = b, typeof y.slug == "string" && m.set(`${w}:${y.slug}`, b);
3058
+ h = k, typeof _.slug == "string" && m.set(`${w}:${_.slug}`, k);
3017
3059
  }
3018
- if (y.success === !1 || y.unsupported === !0)
3060
+ if (_.success === !1 || _.unsupported === !0)
3019
3061
  return {
3020
3062
  actionCount: n.actions.length,
3021
3063
  failedActionIndex: p,
3022
- failedTool: f.tool,
3023
- message: typeof y.message == "string" ? y.message : `Action ${p + 1} failed.`,
3024
- mutationExecuted: l,
3064
+ failedTool: g.tool,
3065
+ message: typeof _.message == "string" ? _.message : `Action ${p + 1} failed.`,
3066
+ mutationExecuted: c,
3025
3067
  results: s,
3026
3068
  success: !1,
3027
3069
  ...u ? { editPath: u } : {},
@@ -3032,18 +3074,18 @@ async function jr(e, t) {
3032
3074
  return {
3033
3075
  actionCount: n.actions.length,
3034
3076
  editPath: d ? void 0 : u ?? void 0,
3035
- mutationExecuted: l,
3077
+ mutationExecuted: c,
3036
3078
  redirectPath: d ?? void 0,
3037
3079
  results: s,
3038
3080
  success: !0,
3039
3081
  summary: n.summary ?? null
3040
3082
  };
3041
3083
  }
3042
- const Yt = i.strictObject({
3084
+ const Qt = i.strictObject({
3043
3085
  maxChars: i.number().int().min(500).max(2e4).default(8e3).describe("Maximum characters of readable body text to return."),
3044
3086
  url: i.string().trim().min(1).max(2048).refine((e) => /^https?:\/\//i.test(e), "URL must start with http:// or https://.")
3045
- }), Lr = 12e3, ct = 2e6;
3046
- function ut(e) {
3087
+ }), Rr = 12e3, dt = 2e6;
3088
+ function pt(e) {
3047
3089
  const t = e.trim().toLowerCase().replace(/\.$/, "").replace(/^\[|\]$/g, "");
3048
3090
  if (!t || t === "localhost" || t.endsWith(".localhost") || t.endsWith(".local") || t.endsWith(".internal") || t === "metadata.google.internal" || t === "0.0.0.0" || t === "::1" || t.startsWith("fe80:") || t.startsWith("fc") || t.startsWith("fd"))
3049
3091
  return !0;
@@ -3055,17 +3097,17 @@ function ut(e) {
3055
3097
  }
3056
3098
  return !1;
3057
3099
  }
3058
- function re(e) {
3100
+ function ae(e) {
3059
3101
  return e.replace(/<[^>]+>/g, " ").replace(/&nbsp;/gi, " ").replace(/&amp;/gi, "&").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&quot;/gi, '"').replace(/&#39;/gi, "'").replace(/\s+/g, " ").trim();
3060
3102
  }
3061
- function Br(e) {
3103
+ function qr(e) {
3062
3104
  return e.trim().replace(/&amp;/gi, "&").replace(/&#38;/g, "&").replace(/&quot;/gi, '"').replace(/&#39;/g, "'");
3063
3105
  }
3064
- const Xt = /\.(avif|gif|jpe?g|png|webp)(?:[?#]|$)/i, Qt = /(?:^|[/_-])(?:sprite|icon|favicon|logo|placeholder|pixel|spacer|blank|avatar|badge|flag|loader|spinner|1x1|transparent|watermark|payment|visa|mastercard|paypal|amex|social|share|facebook|twitter|instagram|youtube|pinterest|linkedin)(?:[/_.-]|$)/i;
3065
- function ue(e, t) {
3106
+ const Zt = /\.(avif|gif|jpe?g|png|webp)(?:[?#]|$)/i, en = /(?:^|[/_-])(?:sprite|icon|favicon|logo|placeholder|pixel|spacer|blank|avatar|badge|flag|loader|spinner|1x1|transparent|watermark|payment|visa|mastercard|paypal|amex|social|share|facebook|twitter|instagram|youtube|pinterest|linkedin)(?:[/_.-]|$)/i;
3107
+ function me(e, t) {
3066
3108
  if (typeof e != "string")
3067
3109
  return null;
3068
- const n = Br(e);
3110
+ const n = qr(e);
3069
3111
  if (!n || n.startsWith("data:"))
3070
3112
  return null;
3071
3113
  try {
@@ -3075,45 +3117,45 @@ function ue(e, t) {
3075
3117
  return null;
3076
3118
  }
3077
3119
  }
3078
- function qr(e) {
3120
+ function Mr(e) {
3079
3121
  let t = null;
3080
3122
  for (const n of e.split(",")) {
3081
3123
  const r = n.trim().split(/\s+/), o = r[0];
3082
3124
  if (!o)
3083
3125
  continue;
3084
- const a = r[1] || "", s = a.match(/^(\d+(?:\.\d+)?)w$/i), l = a.match(/^(\d+(?:\.\d+)?)x$/i), u = s ? Number(s[1]) : l ? Number(l[1]) * 1e3 : 1;
3126
+ const a = r[1] || "", s = a.match(/^(\d+(?:\.\d+)?)w$/i), c = a.match(/^(\d+(?:\.\d+)?)x$/i), u = s ? Number(s[1]) : c ? Number(c[1]) * 1e3 : 1;
3085
3127
  (!t || u > t.weight) && (t = { url: o, weight: u });
3086
3128
  }
3087
3129
  return t?.url ?? null;
3088
3130
  }
3089
- function F(e, t) {
3131
+ function j(e, t) {
3090
3132
  const n = e.match(
3091
3133
  new RegExp(`\\b${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i")
3092
3134
  );
3093
3135
  return n ? n[1] ?? n[2] ?? n[3] ?? null : null;
3094
3136
  }
3095
- function Rr(e, t) {
3096
- const n = [], r = [], o = (l, u) => {
3097
- if (typeof l == "string") {
3098
- const d = ue(l, t);
3137
+ function Dr(e, t) {
3138
+ const n = [], r = [], o = (c, u) => {
3139
+ if (typeof c == "string") {
3140
+ const d = me(c, t);
3099
3141
  d && u.push(d);
3100
3142
  return;
3101
3143
  }
3102
- if (Array.isArray(l)) {
3103
- for (const d of l)
3144
+ if (Array.isArray(c)) {
3145
+ for (const d of c)
3104
3146
  o(d, u);
3105
3147
  return;
3106
3148
  }
3107
- l && typeof l == "object" && (o(l.url, u), o(l.contentUrl, u));
3108
- }, a = (l, u) => {
3109
- if (u > 8 || !l || typeof l != "object")
3149
+ c && typeof c == "object" && (o(c.url, u), o(c.contentUrl, u));
3150
+ }, a = (c, u) => {
3151
+ if (u > 8 || !c || typeof c != "object")
3110
3152
  return;
3111
- if (Array.isArray(l)) {
3112
- for (const p of l)
3153
+ if (Array.isArray(c)) {
3154
+ for (const p of c)
3113
3155
  a(p, u + 1);
3114
3156
  return;
3115
3157
  }
3116
- const d = l, c = d["@type"], h = (Array.isArray(c) ? c : [c]).filter((p) => typeof p == "string").map((p) => p.toLowerCase()).some(
3158
+ const d = c, l = d["@type"], h = (Array.isArray(l) ? l : [l]).filter((p) => typeof p == "string").map((p) => p.toLowerCase()).some(
3117
3159
  (p) => p === "product" || p === "productgroup" || p === "itempage"
3118
3160
  );
3119
3161
  "image" in d && o(d.image, h ? n : r);
@@ -3122,8 +3164,8 @@ function Rr(e, t) {
3122
3164
  }, s = e.matchAll(
3123
3165
  /<script\b[^>]*type\s*=\s*["']application\/ld\+json["'][^>]*>([\s\S]*?)<\/script>/gi
3124
3166
  );
3125
- for (const l of s) {
3126
- const u = (l[1] || "").trim();
3167
+ for (const c of s) {
3168
+ const u = (c[1] || "").trim();
3127
3169
  if (u)
3128
3170
  try {
3129
3171
  a(JSON.parse(u), 0);
@@ -3132,8 +3174,8 @@ function Rr(e, t) {
3132
3174
  }
3133
3175
  return [...n, ...r];
3134
3176
  }
3135
- const Zt = /(?:^|[/_-])(?:thumbnails?|thumbs?|small|mini)(?:[/_.-]|$)/i;
3136
- function en(e) {
3177
+ const tn = /(?:^|[/_-])(?:thumbnails?|thumbs?|small|mini)(?:[/_.-]|$)/i;
3178
+ function nn(e) {
3137
3179
  try {
3138
3180
  const { pathname: t } = new URL(e);
3139
3181
  return decodeURIComponent(t.slice(t.lastIndexOf("/") + 1)).toLowerCase() || null;
@@ -3141,80 +3183,80 @@ function en(e) {
3141
3183
  return null;
3142
3184
  }
3143
3185
  }
3144
- function Mr(e, t) {
3186
+ function zr(e, t) {
3145
3187
  const n = /* @__PURE__ */ new Map();
3146
3188
  for (const r of e.matchAll(/<a\b[^>]*>/gi)) {
3147
- const o = ue(F(r[0], "href"), t);
3148
- if (!o || !Xt.test(o) || Zt.test(o) || Qt.test(o))
3189
+ const o = me(j(r[0], "href"), t);
3190
+ if (!o || !Zt.test(o) || tn.test(o) || en.test(o))
3149
3191
  continue;
3150
- const a = en(o);
3192
+ const a = nn(o);
3151
3193
  a && !n.has(a) && n.set(a, o);
3152
3194
  }
3153
3195
  return n;
3154
3196
  }
3155
- function Dr(e, t) {
3156
- const n = [...Rr(e, t)], r = [
3197
+ function Gr(e, t) {
3198
+ const n = [...Dr(e, t)], r = [
3157
3199
  /<meta\b[^>]*\b(?:property|name)\s*=\s*["'](?:og:image:secure_url|og:image:url|og:image)["'][^>]*>/gi,
3158
3200
  /<meta\b[^>]*\b(?:property|name)\s*=\s*["'](?:twitter:image:src|twitter:image)["'][^>]*>/gi,
3159
3201
  /<meta\b[^>]*\bitemprop\s*=\s*["']image["'][^>]*>/gi,
3160
3202
  /<link\b[^>]*\brel\s*=\s*["']image_src["'][^>]*>/gi
3161
3203
  ];
3162
- for (const c of r)
3163
- for (const m of e.matchAll(c)) {
3164
- const h = m[0], p = ue(
3165
- F(h, "content") || F(h, "href"),
3204
+ for (const l of r)
3205
+ for (const m of e.matchAll(l)) {
3206
+ const h = m[0], p = me(
3207
+ j(h, "content") || j(h, "href"),
3166
3208
  t
3167
3209
  );
3168
3210
  p && n.push(p);
3169
3211
  }
3170
3212
  const o = [];
3171
- for (const c of e.matchAll(/<img\b[^>]*>/gi)) {
3172
- const m = c[0], h = F(m, "srcset") || F(m, "data-srcset"), p = [
3173
- h ? qr(h) : null,
3174
- F(m, "src"),
3175
- F(m, "data-src"),
3176
- F(m, "data-original"),
3177
- F(m, "data-lazy-src"),
3178
- F(m, "data-image")
3213
+ for (const l of e.matchAll(/<img\b[^>]*>/gi)) {
3214
+ const m = l[0], h = j(m, "srcset") || j(m, "data-srcset"), p = [
3215
+ h ? Mr(h) : null,
3216
+ j(m, "src"),
3217
+ j(m, "data-src"),
3218
+ j(m, "data-original"),
3219
+ j(m, "data-lazy-src"),
3220
+ j(m, "data-image")
3179
3221
  ];
3180
- let g = null;
3181
- for (const k of p)
3182
- if (g = ue(k, t), g)
3222
+ let f = null;
3223
+ for (const b of p)
3224
+ if (f = me(b, t), f)
3183
3225
  break;
3184
- if (!g || Qt.test(g))
3226
+ if (!f || en.test(f))
3185
3227
  continue;
3186
- const f = Number(F(m, "width"));
3187
- Number.isFinite(f) && f > 0 && f < 200 || o.push(g);
3228
+ const g = Number(j(m, "width"));
3229
+ Number.isFinite(g) && g > 0 && g < 200 || o.push(f);
3188
3230
  }
3189
- const a = (c) => Xt.test(c);
3190
- n.push(...o.filter(a), ...o.filter((c) => !a(c)));
3191
- const s = Mr(e, t), l = (c) => {
3192
- if (!Zt.test(c))
3193
- return c;
3194
- const m = en(c);
3195
- return m && s.get(m) || c;
3231
+ const a = (l) => Zt.test(l);
3232
+ n.push(...o.filter(a), ...o.filter((l) => !a(l)));
3233
+ const s = zr(e, t), c = (l) => {
3234
+ if (!tn.test(l))
3235
+ return l;
3236
+ const m = nn(l);
3237
+ return m && s.get(m) || l;
3196
3238
  }, u = /* @__PURE__ */ new Set(), d = [];
3197
- for (const c of n) {
3198
- const m = l(c);
3239
+ for (const l of n) {
3240
+ const m = c(l);
3199
3241
  if (!u.has(m) && (u.add(m), d.push(m), d.length >= 12))
3200
3242
  break;
3201
3243
  }
3202
3244
  return { images: d, mainImage: d[0] ?? null };
3203
3245
  }
3204
- function zr(e, t, n) {
3205
- const r = e.replace(/<script\b[\s\S]*?<\/script>/gi, " ").replace(/<style\b[\s\S]*?<\/style>/gi, " ").replace(/<noscript\b[\s\S]*?<\/noscript>/gi, " ").replace(/<svg\b[\s\S]*?<\/svg>/gi, " "), { images: o, mainImage: a } = Dr(e, n), s = e.match(/<title\b[^>]*>([\s\S]*?)<\/title>/i), l = e.match(/<meta[^>]+name=["']description["'][^>]*content=["']([^"']*)["'][^>]*>/i) || e.match(/<meta[^>]+content=["']([^"']*)["'][^>]*name=["']description["'][^>]*>/i), u = [...r.matchAll(/<h([1-3])\b[^>]*>([\s\S]*?)<\/h\1>/gi)].map((m) => re(m[2])).filter(Boolean).slice(0, 40), d = r.match(/<body\b[^>]*>([\s\S]*?)<\/body>/i), c = re(d?.[1] ?? r);
3246
+ function Kr(e, t, n) {
3247
+ const r = e.replace(/<script\b[\s\S]*?<\/script>/gi, " ").replace(/<style\b[\s\S]*?<\/style>/gi, " ").replace(/<noscript\b[\s\S]*?<\/noscript>/gi, " ").replace(/<svg\b[\s\S]*?<\/svg>/gi, " "), { images: o, mainImage: a } = Gr(e, n), s = e.match(/<title\b[^>]*>([\s\S]*?)<\/title>/i), c = e.match(/<meta[^>]+name=["']description["'][^>]*content=["']([^"']*)["'][^>]*>/i) || e.match(/<meta[^>]+content=["']([^"']*)["'][^>]*name=["']description["'][^>]*>/i), u = [...r.matchAll(/<h([1-3])\b[^>]*>([\s\S]*?)<\/h\1>/gi)].map((m) => ae(m[2])).filter(Boolean).slice(0, 40), d = r.match(/<body\b[^>]*>([\s\S]*?)<\/body>/i), l = ae(d?.[1] ?? r);
3206
3248
  return {
3207
- description: l ? re(l[1]) : "",
3249
+ description: c ? ae(c[1]) : "",
3208
3250
  headings: u,
3209
3251
  images: o,
3210
3252
  mainImage: a,
3211
- text: c.slice(0, t),
3212
- title: s ? re(s[1]) : "",
3213
- truncated: c.length > t
3253
+ text: l.slice(0, t),
3254
+ title: s ? ae(s[1]) : "",
3255
+ truncated: l.length > t
3214
3256
  };
3215
3257
  }
3216
- async function Gr(e) {
3217
- const t = Yt.parse(e);
3258
+ async function Hr(e) {
3259
+ const t = Qt.parse(e);
3218
3260
  let n;
3219
3261
  try {
3220
3262
  n = new URL(t.url);
@@ -3223,13 +3265,13 @@ async function Gr(e) {
3223
3265
  }
3224
3266
  if (n.protocol !== "http:" && n.protocol !== "https:")
3225
3267
  return { message: "Only http and https URLs can be fetched.", success: !1, url: t.url };
3226
- if (ut(n.hostname))
3268
+ if (pt(n.hostname))
3227
3269
  return {
3228
3270
  message: "Refusing to fetch a local, private, or internal address.",
3229
3271
  success: !1,
3230
3272
  url: t.url
3231
3273
  };
3232
- const r = new AbortController(), o = setTimeout(() => r.abort(), Lr);
3274
+ const r = new AbortController(), o = setTimeout(() => r.abort(), Rr);
3233
3275
  try {
3234
3276
  const a = await fetch(n.toString(), {
3235
3277
  headers: {
@@ -3248,7 +3290,7 @@ async function Gr(e) {
3248
3290
  };
3249
3291
  const s = a.url || n.toString();
3250
3292
  try {
3251
- if (ut(new URL(s).hostname))
3293
+ if (pt(new URL(s).hostname))
3252
3294
  return {
3253
3295
  message: "The URL redirected to a blocked internal address.",
3254
3296
  success: !1,
@@ -3256,34 +3298,34 @@ async function Gr(e) {
3256
3298
  };
3257
3299
  } catch {
3258
3300
  }
3259
- const l = a.headers.get("content-type") || "";
3260
- if (!/text\/html|text\/plain|application\/xhtml/i.test(l))
3301
+ const c = a.headers.get("content-type") || "";
3302
+ if (!/text\/html|text\/plain|application\/xhtml/i.test(c))
3261
3303
  return {
3262
- contentType: l,
3263
- message: `The URL is not an HTML or text page (content-type: ${l || "unknown"}).`,
3304
+ contentType: c,
3305
+ message: `The URL is not an HTML or text page (content-type: ${c || "unknown"}).`,
3264
3306
  success: !1,
3265
3307
  url: t.url
3266
3308
  };
3267
- const u = await a.text(), d = u.length > ct ? u.slice(0, ct) : u, c = zr(d, t.maxChars, s);
3268
- return !c.text && !c.title ? { message: "The URL returned no readable text content.", success: !1, url: t.url } : {
3269
- description: c.description,
3309
+ const u = await a.text(), d = u.length > dt ? u.slice(0, dt) : u, l = Kr(d, t.maxChars, s);
3310
+ return !l.text && !l.title ? { message: "The URL returned no readable text content.", success: !1, url: t.url } : {
3311
+ description: l.description,
3270
3312
  finalUrl: s,
3271
- headings: c.headings,
3313
+ headings: l.headings,
3272
3314
  // Ranked best-first (schema.org Product image > og:image > in-body <img>).
3273
3315
  // `mainImage` is the page's subject image and can be passed straight into
3274
3316
  // create_cms_product `images` / feature_image_id — it is imported into the
3275
3317
  // media library automatically.
3276
- images: c.images,
3277
- mainImage: c.mainImage,
3318
+ images: l.images,
3319
+ mainImage: l.mainImage,
3278
3320
  success: !0,
3279
- text: c.text,
3280
- title: c.title,
3281
- truncated: c.truncated,
3321
+ text: l.text,
3322
+ title: l.title,
3323
+ truncated: l.truncated,
3282
3324
  url: t.url
3283
3325
  };
3284
3326
  } catch (a) {
3285
3327
  return {
3286
- message: a instanceof Error && (a.name === "AbortError" || /abort/i.test(a.message)) ? "Fetching the URL timed out." : `Failed to fetch the URL: ${_(a)}`,
3328
+ message: a instanceof Error && (a.name === "AbortError" || /abort/i.test(a.message)) ? "Fetching the URL timed out." : `Failed to fetch the URL: ${y(a)}`,
3287
3329
  success: !1,
3288
3330
  url: t.url
3289
3331
  };
@@ -3291,36 +3333,36 @@ async function Gr(e) {
3291
3333
  clearTimeout(o);
3292
3334
  }
3293
3335
  }
3294
- const tn = i.strictObject({
3336
+ const rn = i.strictObject({
3295
3337
  count: i.number().int().min(1).max(15).default(6),
3296
3338
  orientation: i.enum(["landscape", "portrait", "square"]).optional().describe("Preferred image orientation. Use landscape for hero/section backgrounds."),
3297
3339
  query: i.string().trim().min(2).max(200).describe('What the photos should depict, e.g. "herbal supplements".')
3298
- }), Kr = 12e3;
3299
- async function Ye(e) {
3340
+ }), Vr = 12e3;
3341
+ async function Qe(e) {
3300
3342
  let t = null, n = null;
3301
3343
  if (e)
3302
3344
  try {
3303
- const { CORTEX_AI_PEXELS_SETTING_KEY: o, CORTEX_AI_UNSPLASH_SETTING_KEY: a, decryptStoredOpenRouterApiKey: s } = await import("./ai-config.es.js"), l = (c) => {
3304
- if (!c)
3345
+ const { CORTEX_AI_PEXELS_SETTING_KEY: o, CORTEX_AI_UNSPLASH_SETTING_KEY: a, decryptStoredOpenRouterApiKey: s } = await import("./ai-config.es.js"), c = (l) => {
3346
+ if (!l)
3305
3347
  return null;
3306
3348
  try {
3307
- const m = s(c);
3349
+ const m = s(l);
3308
3350
  return typeof m == "string" && m.trim() ? m.trim() : null;
3309
3351
  } catch {
3310
3352
  return null;
3311
3353
  }
3312
3354
  }, { data: u } = await e.from("site_settings").select("key, value").in("key", [o, a]), d = Array.isArray(u) ? u : [];
3313
- t = l(d.find((c) => c.key === o)?.value), n = l(d.find((c) => c.key === a)?.value);
3355
+ t = c(d.find((l) => l.key === o)?.value), n = c(d.find((l) => l.key === a)?.value);
3314
3356
  } catch {
3315
3357
  }
3316
3358
  t || (t = process.env.PEXELS_API_KEY?.trim() || null), n || (n = process.env.UNSPLASH_ACCESS_KEY?.trim() || null);
3317
3359
  const r = [];
3318
3360
  return t && r.push({ apiKey: t, provider: "pexels" }), n && r.push({ apiKey: n, provider: "unsplash" }), r;
3319
3361
  }
3320
- async function lo(e) {
3321
- return (await Ye(e))[0] ?? null;
3362
+ async function uo(e) {
3363
+ return (await Qe(e))[0] ?? null;
3322
3364
  }
3323
- async function Hr(e) {
3365
+ async function Jr(e) {
3324
3366
  if (e)
3325
3367
  try {
3326
3368
  const { CORTEX_AI_UNSPLASH_APP_NAME_SETTING_KEY: t } = await import("./ai-config.es.js"), { data: n } = await e.from("site_settings").select("value").eq("key", t).maybeSingle(), r = n?.value;
@@ -3330,8 +3372,8 @@ async function Hr(e) {
3330
3372
  }
3331
3373
  return process.env.UNSPLASH_APP_NAME?.trim() || null;
3332
3374
  }
3333
- async function dt(e, t) {
3334
- const n = new AbortController(), r = setTimeout(() => n.abort(), Kr);
3375
+ async function mt(e, t) {
3376
+ const n = new AbortController(), r = setTimeout(() => n.abort(), Vr);
3335
3377
  try {
3336
3378
  const o = await fetch(e, { headers: t, signal: n.signal });
3337
3379
  if (!o.ok)
@@ -3341,34 +3383,34 @@ async function dt(e, t) {
3341
3383
  clearTimeout(r);
3342
3384
  }
3343
3385
  }
3344
- function oe(e) {
3386
+ function se(e) {
3345
3387
  const t = Number(e);
3346
3388
  return Number.isFinite(t) && t > 0 ? t : null;
3347
3389
  }
3348
- function Ue(e, t) {
3349
- if (!$(e))
3390
+ function Fe(e, t) {
3391
+ if (!E(e))
3350
3392
  return;
3351
3393
  const n = (r) => {
3352
- $(r) && r.provider === "unsplash" && typeof r.downloadLocation == "string" && r.downloadLocation.trim() && t.add(r.downloadLocation.trim());
3394
+ E(r) && r.provider === "unsplash" && typeof r.downloadLocation == "string" && r.downloadLocation.trim() && t.add(r.downloadLocation.trim());
3353
3395
  };
3354
- if (n(e.attribution), $(e.background) && $(e.background.image) && n(e.background.image.attribution), Array.isArray(e.column_blocks)) {
3396
+ if (n(e.attribution), E(e.background) && E(e.background.image) && n(e.background.image.attribution), Array.isArray(e.column_blocks)) {
3355
3397
  for (const r of e.column_blocks)
3356
3398
  if (Array.isArray(r))
3357
3399
  for (const o of r)
3358
- $(o) && Ue(o.content, t);
3400
+ E(o) && Fe(o.content, t);
3359
3401
  }
3360
3402
  if (Array.isArray(e.slides))
3361
3403
  for (const r of e.slides)
3362
- Ue(r, t);
3404
+ Fe(r, t);
3363
3405
  }
3364
- async function ve(e, t) {
3406
+ async function $e(e, t) {
3365
3407
  try {
3366
3408
  const n = /* @__PURE__ */ new Set();
3367
3409
  for (const a of e)
3368
- Ue(a?.content, n);
3410
+ Fe(a?.content, n);
3369
3411
  if (n.size === 0)
3370
3412
  return;
3371
- const o = (await Ye(t)).find((a) => a.provider === "unsplash");
3413
+ const o = (await Qe(t)).find((a) => a.provider === "unsplash");
3372
3414
  if (!o)
3373
3415
  return;
3374
3416
  await Promise.all(
@@ -3382,34 +3424,34 @@ async function ve(e, t) {
3382
3424
  } catch {
3383
3425
  }
3384
3426
  }
3385
- async function Vr(e, t, n) {
3427
+ async function Wr(e, t, n) {
3386
3428
  const r = new URLSearchParams({
3387
3429
  per_page: String(t.count),
3388
3430
  query: t.query
3389
3431
  });
3390
3432
  if (t.orientation && r.set("orientation", t.orientation), e.provider === "pexels") {
3391
- const a = await dt(
3433
+ const a = await mt(
3392
3434
  `https://api.pexels.com/v1/search?${r.toString()}`,
3393
3435
  { Authorization: e.apiKey }
3394
3436
  );
3395
3437
  return (Array.isArray(a?.photos) ? a.photos : []).map((s) => {
3396
- const l = typeof s?.photographer == "string" ? s.photographer : null;
3438
+ const c = typeof s?.photographer == "string" ? s.photographer : null;
3397
3439
  return {
3398
3440
  alt: typeof s?.alt == "string" && s.alt.trim() ? s.alt.trim() : t.query,
3399
- credit: l ? `Photo by ${l} on Pexels` : "Photo on Pexels",
3441
+ credit: c ? `Photo by ${c} on Pexels` : "Photo on Pexels",
3400
3442
  downloadLocation: null,
3401
- height: oe(s?.height),
3402
- photographer: l,
3443
+ height: se(s?.height),
3444
+ photographer: c,
3403
3445
  photographerUrl: typeof s?.photographer_url == "string" ? s.photographer_url : null,
3404
3446
  provider: "pexels",
3405
3447
  sourceUrl: typeof s?.url == "string" ? s.url : null,
3406
3448
  thumbnailUrl: s?.src?.medium || s?.src?.large || null,
3407
3449
  url: s?.src?.large2x || s?.src?.large || s?.src?.original || null,
3408
- width: oe(s?.width)
3450
+ width: se(s?.width)
3409
3451
  };
3410
3452
  }).filter((s) => typeof s.url == "string");
3411
3453
  }
3412
- const o = await dt(
3454
+ const o = await mt(
3413
3455
  `https://api.unsplash.com/search/photos?${r.toString()}`,
3414
3456
  { Authorization: `Client-ID ${e.apiKey}` }
3415
3457
  );
@@ -3421,7 +3463,7 @@ async function Vr(e, t, n) {
3421
3463
  // Unsplash requires triggering this endpoint when the photo is actually
3422
3464
  // used; carry it so the block-persist path can fire it.
3423
3465
  downloadLocation: typeof a?.links?.download_location == "string" ? a.links.download_location : null,
3424
- height: oe(a?.height),
3466
+ height: se(a?.height),
3425
3467
  photographer: s,
3426
3468
  photographerUrl: typeof a?.user?.links?.html == "string" ? a.user.links.html : null,
3427
3469
  provider: "unsplash",
@@ -3430,32 +3472,32 @@ async function Vr(e, t, n) {
3430
3472
  url: a?.urls?.regular || a?.urls?.full || a?.urls?.raw || null,
3431
3473
  // The operator's registered Unsplash app name for the attribution utm_source.
3432
3474
  utmSource: n || null,
3433
- width: oe(a?.width)
3475
+ width: se(a?.width)
3434
3476
  };
3435
3477
  }).filter((a) => typeof a.url == "string");
3436
3478
  }
3437
- async function Jr(e, t) {
3438
- const n = tn.parse(e), r = await Ye(t?.supabase);
3479
+ async function Yr(e, t) {
3480
+ const n = rn.parse(e), r = await Qe(t?.supabase);
3439
3481
  if (r.length === 0)
3440
3482
  return {
3441
3483
  message: "No stock photo provider is configured. Add a free Pexels or Unsplash API key in /cms/settings/cortex-ai (or set PEXELS_API_KEY / UNSPLASH_ACCESS_KEY).",
3442
3484
  photos: [],
3443
3485
  success: !1
3444
3486
  };
3445
- const o = r.some((l) => l.provider === "unsplash") ? await Hr(t?.supabase) : null, a = [];
3487
+ const o = r.some((c) => c.provider === "unsplash") ? await Jr(t?.supabase) : null, a = [];
3446
3488
  let s = null;
3447
- for (const l of r) {
3448
- a.push(l.provider);
3489
+ for (const c of r) {
3490
+ a.push(c.provider);
3449
3491
  try {
3450
- const u = await Vr(l, n, o);
3492
+ const u = await Wr(c, n, o);
3451
3493
  if (u.length > 0)
3452
3494
  return {
3453
3495
  attemptedProviders: a,
3454
3496
  photos: u,
3455
- provider: l.provider,
3497
+ provider: c.provider,
3456
3498
  query: n.query,
3457
3499
  success: !0,
3458
- usageGuidance: l.provider === "unsplash" ? 'Unsplash photos: keep them hotlinked (use `url` as external_url; never save an Unsplash photo to the media library) and attribute each one — copy the photo\'s attribution fields into the image content\'s `attribution` (photographer, photographerUrl, sourceUrl, downloadLocation, utmSource, provider "unsplash"). The site renders the "Photo by … on Unsplash" credit from `attribution` automatically, so do NOT also copy the credit into `caption` (leave caption empty unless you have a genuine descriptive caption).' : 'Set the image content\'s `attribution` (photographer, photographerUrl, sourceUrl, provider "pexels"). The site renders the "Photo by … on Pexels" credit from `attribution` automatically, so do NOT also copy the credit into `caption` (leave caption empty unless you have a genuine descriptive caption). Pexels attribution is appreciated but optional.'
3500
+ usageGuidance: c.provider === "unsplash" ? 'Unsplash photos: keep them hotlinked (use `url` as external_url; never save an Unsplash photo to the media library) and attribute each one — copy the photo\'s attribution fields into the image content\'s `attribution` (photographer, photographerUrl, sourceUrl, downloadLocation, utmSource, provider "unsplash"). The site renders the "Photo by … on Unsplash" credit from `attribution` automatically, so do NOT also copy the credit into `caption` (leave caption empty unless you have a genuine descriptive caption).' : 'Set the image content\'s `attribution` (photographer, photographerUrl, sourceUrl, provider "pexels"). The site renders the "Photo by … on Pexels" credit from `attribution` automatically, so do NOT also copy the credit into `caption` (leave caption empty unless you have a genuine descriptive caption). Pexels attribution is appreciated but optional.'
3459
3501
  };
3460
3502
  } catch (u) {
3461
3503
  s = u;
@@ -3463,13 +3505,13 @@ async function Jr(e, t) {
3463
3505
  }
3464
3506
  return {
3465
3507
  attemptedProviders: a,
3466
- message: s ? `Stock photo search failed across ${a.join(", ")}: ${_(s)}` : `No matching stock photos found for "${n.query}".`,
3508
+ message: s ? `Stock photo search failed across ${a.join(", ")}: ${y(s)}` : `No matching stock photos found for "${n.query}".`,
3467
3509
  photos: [],
3468
3510
  success: !1
3469
3511
  };
3470
3512
  }
3471
- const nn = H.extend({
3472
- blocks: i.array(Q).min(1).max(20),
3513
+ const on = W.extend({
3514
+ blocks: i.array(te).min(1).max(20),
3473
3515
  meta: i.strictObject({
3474
3516
  meta_description: i.string().max(500).nullable().optional(),
3475
3517
  meta_title: i.string().max(160).nullable().optional(),
@@ -3477,7 +3519,7 @@ const nn = H.extend({
3477
3519
  status: i.enum(["draft", "published", "archived"]).optional(),
3478
3520
  title: i.string().trim().min(1).max(300).optional()
3479
3521
  }).partial().optional()
3480
- }), Wr = [
3522
+ }), Xr = [
3481
3523
  "custom_canonical",
3482
3524
  "excerpt",
3483
3525
  "feature_image_id",
@@ -3492,91 +3534,91 @@ const nn = H.extend({
3492
3534
  "title",
3493
3535
  "translation_group_id"
3494
3536
  ];
3495
- function Yr(e) {
3537
+ function Qr(e) {
3496
3538
  const t = {};
3497
- for (const n of Wr)
3539
+ for (const n of Xr)
3498
3540
  n in e && e[n] !== void 0 && (t[n] = e[n]);
3499
3541
  return t;
3500
3542
  }
3501
- function Xr(e, t) {
3543
+ function Zr(e, t) {
3502
3544
  if (!t)
3503
3545
  return null;
3504
3546
  const n = e === "page" ? t === "home" ? "/" : `/${t}` : `/article/${t}`;
3505
3547
  return `/api/draft/start?path=${encodeURIComponent(n)}`;
3506
3548
  }
3507
- async function Qr(e, t) {
3508
- const n = nn.parse(e), r = C(t), o = qe(t), a = await te(n, t);
3549
+ async function eo(e, t) {
3550
+ const n = on.parse(e), r = C(t), o = Me(t), a = await oe(n, t);
3509
3551
  if (a.contentType === "product")
3510
3552
  throw new Error(
3511
3553
  "rewrite_page_draft supports pages and posts only. Products use description_json, not page blocks."
3512
3554
  );
3513
- const s = a.contentType, l = Number(a.item.id);
3514
- if (!Number.isInteger(l) || l <= 0)
3555
+ const s = a.contentType, c = Number(a.item.id);
3556
+ if (!Number.isInteger(c) || c <= 0)
3515
3557
  throw new Error("Could not resolve a valid page/post id for the draft rewrite.");
3516
3558
  const u = Number(a.item.language_id);
3517
3559
  if (!Number.isInteger(u) || u <= 0)
3518
3560
  throw new Error("The target page/post is missing a language id.");
3519
- const c = Se(n.blocks, void 0, void 0, t).map((x, E) => ({
3520
- block_type: x.block_type,
3521
- content: x.content,
3561
+ const l = Ee(n.blocks, void 0, void 0, t).map((I, $) => ({
3562
+ block_type: I.block_type,
3563
+ content: I.content,
3522
3564
  language_id: u,
3523
- order: E,
3524
- page_id: s === "page" ? l : null,
3525
- post_id: s === "post" ? l : null,
3565
+ order: $,
3566
+ page_id: s === "page" ? c : null,
3567
+ post_id: s === "post" ? c : null,
3526
3568
  product_id: null
3527
- })), m = Yr(a.item);
3569
+ })), m = Qr(a.item);
3528
3570
  if (n.meta)
3529
- for (const [x, E] of Object.entries(n.meta))
3530
- E !== void 0 && (m[x] = E);
3531
- const h = Tt(
3571
+ for (const [I, $] of Object.entries(n.meta))
3572
+ $ !== void 0 && (m[I] = $);
3573
+ const h = Ct(
3532
3574
  typeof m.slug == "string" ? m.slug : a.item.slug
3533
- ), p = typeof m.title == "string" && m.title.trim() ? m.title : String(a.item.title || h || "Untitled"), g = s === "page" ? `/cms/pages/${l}/edit` : `/cms/posts/${l}/edit`, f = Xr(s, h), y = P({
3575
+ ), p = typeof m.title == "string" && m.title.trim() ? m.title : String(a.item.title || h || "Untitled"), f = s === "page" ? `/cms/pages/${c}/edit` : `/cms/posts/${c}/edit`, g = Zr(s, h), _ = N({
3534
3576
  action: "REWRITE DRAFT",
3535
3577
  context: t,
3536
3578
  payload: {
3537
- blocks: c,
3579
+ blocks: l,
3538
3580
  meta: m,
3539
- parent_id: l,
3581
+ parent_id: c,
3540
3582
  parent_type: s,
3541
3583
  tool: "rewrite_page_draft"
3542
3584
  },
3543
3585
  preview: {
3544
- blockCount: c.length,
3586
+ blockCount: l.length,
3545
3587
  contentType: s,
3546
3588
  slug: h,
3547
- summary: `Stage a Live Draft that replaces the ${s} "${p}" with ${N(
3548
- c.length,
3589
+ summary: `Stage a Live Draft that replaces the ${s} "${p}" with ${U(
3590
+ l.length,
3549
3591
  "new block"
3550
3592
  )}. Nothing goes live until you review the draft and click Publish (which also saves a revision snapshot).`,
3551
3593
  title: p
3552
3594
  },
3553
- subject: `${s}-${l}`
3595
+ subject: `${s}-${c}`
3554
3596
  });
3555
- if (y)
3556
- return y;
3557
- const w = Number(a.item.version) || 1, { error: b } = await r.from("content_drafts").delete().eq("parent_type", s).eq("parent_id", l);
3558
- if (b)
3559
- throw new Error(`Failed to clear the existing draft: ${_(b)}`);
3560
- const { error: I } = await r.from("content_drafts").insert({
3597
+ if (_)
3598
+ return _;
3599
+ const w = Number(a.item.version) || 1, { error: k } = await r.from("content_drafts").delete().eq("parent_type", s).eq("parent_id", c);
3600
+ if (k)
3601
+ throw new Error(`Failed to clear the existing draft: ${y(k)}`);
3602
+ const { error: T } = await r.from("content_drafts").insert({
3561
3603
  author_id: o,
3562
3604
  base_version: w,
3563
- blocks: c,
3605
+ blocks: l,
3564
3606
  meta: m,
3565
- parent_id: l,
3607
+ parent_id: c,
3566
3608
  parent_type: s
3567
3609
  });
3568
- if (I)
3569
- throw new Error(`Failed to save the draft: ${_(I)}`);
3570
- return ve(c, r), U(
3610
+ if (T)
3611
+ throw new Error(`Failed to save the draft: ${y(T)}`);
3612
+ return $e(l, r), O(
3571
3613
  t,
3572
- { contentType: s, entityId: l, slug: h },
3614
+ { contentType: s, entityId: c, slug: h },
3573
3615
  h
3574
3616
  ), {
3575
- blockCount: c.length,
3617
+ blockCount: l.length,
3576
3618
  contentType: s,
3577
- draftPreviewPath: f,
3578
- editPath: g,
3579
- entityId: l,
3619
+ draftPreviewPath: g,
3620
+ editPath: f,
3621
+ entityId: c,
3580
3622
  isDraft: !0,
3581
3623
  mutationExecuted: !0,
3582
3624
  slug: h,
@@ -3584,7 +3626,7 @@ async function Qr(e, t) {
3584
3626
  title: p
3585
3627
  };
3586
3628
  }
3587
- const Zr = /* @__PURE__ */ new Set([
3629
+ const to = /* @__PURE__ */ new Set([
3588
3630
  "alt_text",
3589
3631
  "author_name",
3590
3632
  "author_title",
@@ -3599,7 +3641,7 @@ const Zr = /* @__PURE__ */ new Set([
3599
3641
  "text_content",
3600
3642
  "title"
3601
3643
  ]);
3602
- function Oe(e, t, n) {
3644
+ function je(e, t, n) {
3603
3645
  if (!e)
3604
3646
  return e;
3605
3647
  if (Object.prototype.hasOwnProperty.call(t, e))
@@ -3612,93 +3654,93 @@ function Oe(e, t, n) {
3612
3654
  a && o.includes(a) && (o = o.split(a).join(s));
3613
3655
  return o;
3614
3656
  }
3615
- function Fe(e, t, n) {
3657
+ function Le(e, t, n) {
3616
3658
  if (Array.isArray(e))
3617
- return e.map((r) => Fe(r, t, n));
3659
+ return e.map((r) => Le(r, t, n));
3618
3660
  if (e && typeof e == "object") {
3619
3661
  const r = {};
3620
3662
  for (const [o, a] of Object.entries(e))
3621
- typeof a == "string" && Zr.has(o) ? r[o] = Oe(a, t, n) : a && typeof a == "object" ? r[o] = Fe(a, t, n) : r[o] = a;
3663
+ typeof a == "string" && to.has(o) ? r[o] = je(a, t, n) : a && typeof a == "object" ? r[o] = Le(a, t, n) : r[o] = a;
3622
3664
  return r;
3623
3665
  }
3624
3666
  return e;
3625
3667
  }
3626
- const rn = i.strictObject({
3668
+ const an = i.strictObject({
3627
3669
  targetLanguageCode: i.string().trim().min(2).max(80).describe('Target language code or name, e.g. "fr" or "French".'),
3628
3670
  title: i.string().trim().min(1).max(300).optional().describe("Translated page title (defaults to translating the source title)."),
3629
3671
  translations: i.record(i.string(), i.string()).describe(
3630
3672
  'Map of every visible source string to its translation, e.g. { "Explore Our Products": "Explorez nos produits" }. Include headings, paragraph text, button labels, image alt text, captions, and form labels.'
3631
3673
  )
3632
3674
  });
3633
- async function eo(e, t) {
3634
- const n = rn.parse(e), r = V(t);
3675
+ async function no(e, t) {
3676
+ const n = an.parse(e), r = Y(t);
3635
3677
  if (r.contentType === "product")
3636
3678
  throw new Error("translate_page supports pages and posts only.");
3637
- const o = C(t), a = Be(r), s = r.contentType === "page" ? "pages" : "posts", l = r.contentType === "page" ? "page_id" : "post_id", { data: u, error: d } = await o.from(s).select("*").eq("id", a).single();
3679
+ const o = C(t), a = qe(r), s = r.contentType === "page" ? "pages" : "posts", c = r.contentType === "page" ? "page_id" : "post_id", { data: u, error: d } = await o.from(s).select("*").eq("id", a).single();
3638
3680
  if (d || !u)
3639
3681
  throw new Error(
3640
- `Could not read the source ${r.contentType} to translate: ${_(d)}`
3682
+ `Could not read the source ${r.contentType} to translate: ${y(d)}`
3641
3683
  );
3642
- const { data: c, error: m } = await o.from("blocks").select("id, block_type, content, order").eq(l, a);
3684
+ const { data: l, error: m } = await o.from("blocks").select("id, block_type, content, order").eq(c, a);
3643
3685
  if (m)
3644
- throw new Error(`Could not read the source blocks: ${_(m)}`);
3645
- const h = (Array.isArray(c) ? c : []).slice().sort((T, A) => Number(T.order) - Number(A.order));
3686
+ throw new Error(`Could not read the source blocks: ${y(m)}`);
3687
+ const h = (Array.isArray(l) ? l : []).slice().sort((x, A) => Number(x.order) - Number(A.order));
3646
3688
  if (h.length === 0)
3647
3689
  throw new Error(`The source ${r.contentType} has no content blocks to translate.`);
3648
- const p = n.translations || {}, g = Object.entries(p).filter(([T]) => !!T).sort((T, A) => A[0].length - T[0].length), f = h.map((T, A) => ({
3649
- blockType: T.block_type,
3650
- content: Fe(z(T.content), p, g),
3690
+ const p = n.translations || {}, f = Object.entries(p).filter(([x]) => !!x).sort((x, A) => A[0].length - x[0].length), g = h.map((x, A) => ({
3691
+ blockType: x.block_type,
3692
+ content: Le(K(x.content), p, f),
3651
3693
  order: A
3652
- })), k = await Ce(o, n.targetLanguageCode), y = String(u.title || ""), w = n.title || Oe(y, p, g) || y || "Untitled", b = (T) => typeof T == "string" && T.trim() ? Oe(T, p, g) : void 0, I = q(w) || u.slug || "translated-page", x = {
3653
- blocks: f,
3694
+ })), b = await Se(o, n.targetLanguageCode), _ = String(u.title || ""), w = n.title || je(_, p, f) || _ || "Untitled", k = (x) => typeof x == "string" && x.trim() ? je(x, p, f) : void 0, T = M(w) || u.slug || "translated-page", I = {
3695
+ blocks: g,
3654
3696
  feature_image_id: u.feature_image_id ?? void 0,
3655
- languageCode: k.code,
3656
- meta_description: b(u.meta_description),
3657
- meta_title: b(u.meta_title),
3658
- slug: I,
3697
+ languageCode: b.code,
3698
+ meta_description: k(u.meta_description),
3699
+ meta_title: k(u.meta_title),
3700
+ slug: T,
3659
3701
  // Publish the translation immediately so it goes live the moment the owner
3660
3702
  // confirms — the localized homepage/page is then reachable and the public
3661
3703
  // language switcher can find it (drafts are filtered out of public lookups).
3662
3704
  status: "published",
3663
3705
  title: w,
3664
3706
  translationGroupId: u.translation_group_id || void 0
3665
- }, E = r.contentType === "post" ? {
3666
- ...x,
3667
- excerpt: b(u.excerpt),
3668
- label: b(u.label),
3707
+ }, $ = r.contentType === "post" ? {
3708
+ ...I,
3709
+ excerpt: k(u.excerpt),
3710
+ label: k(u.label),
3669
3711
  // Inherit the source post's publish date (or "now" if it has none) so a
3670
3712
  // published translation sorts alongside its original in the article list
3671
3713
  // instead of jumping to the top with a null published_at.
3672
3714
  published_at: u.published_at ?? (/* @__PURE__ */ new Date()).toISOString(),
3673
- subtitle: b(u.subtitle)
3674
- } : x, L = P({
3715
+ subtitle: k(u.subtitle)
3716
+ } : I, P = N({
3675
3717
  action: "TRANSLATE",
3676
3718
  context: t,
3677
- payload: { createInput: E, sourceId: u.id, tool: "translate_page" },
3719
+ payload: { createInput: $, sourceId: u.id, tool: "translate_page" },
3678
3720
  preview: {
3679
- blockCount: f.length,
3721
+ blockCount: g.length,
3680
3722
  contentType: r.contentType,
3681
- languageCode: k.code,
3682
- slug: x.slug,
3683
- status: x.status,
3684
- summary: `Publish a ${k.code.toUpperCase()} translation of "${y}" — it goes live immediately, linked to the original ${r.contentType}, at /${x.slug} with ${N(
3685
- f.length,
3723
+ languageCode: b.code,
3724
+ slug: I.slug,
3725
+ status: I.status,
3726
+ summary: `Publish a ${b.code.toUpperCase()} translation of "${_}" — it goes live immediately, linked to the original ${r.contentType}, at /${I.slug} with ${U(
3727
+ g.length,
3686
3728
  "translated block"
3687
3729
  )}.`,
3688
3730
  title: w
3689
3731
  },
3690
- subject: `translate ${r.contentType} ${u.id} to ${k.code}`
3732
+ subject: `translate ${r.contentType} ${u.id} to ${b.code}`
3691
3733
  });
3692
- if (L)
3693
- return L;
3694
- const R = { ...t, skipConfirmation: !0 };
3695
- return { ...r.contentType === "post" ? await Je(E, R) : await Ve(E, R), isTranslation: !0, languageCode: k.code };
3734
+ if (P)
3735
+ return P;
3736
+ const L = { ...t, skipConfirmation: !0 };
3737
+ return { ...r.contentType === "post" ? await Ye($, L) : await We($, L), isTranslation: !0, languageCode: b.code };
3696
3738
  }
3697
- async function on(e, t) {
3698
- const n = he.parse(e), r = n.entityId !== void 0 || !!n.slug || !!n.title, o = C(t);
3739
+ async function sn(e, t) {
3740
+ const n = be.parse(e), r = n.entityId !== void 0 || !!n.slug || !!n.title, o = C(t);
3699
3741
  let a, s;
3700
3742
  if (r) {
3701
- const g = await te(
3743
+ const g = await oe(
3702
3744
  {
3703
3745
  contentType: n.contentType,
3704
3746
  entityId: n.entityId,
@@ -3706,16 +3748,16 @@ async function on(e, t) {
3706
3748
  title: n.title
3707
3749
  },
3708
3750
  t
3709
- ), f = g.item;
3710
- s = f.id, a = {
3751
+ ), b = g.item;
3752
+ s = b.id, a = {
3711
3753
  contentType: g.contentType,
3712
3754
  entityId: s,
3713
- slug: typeof f.slug == "string" ? f.slug : "",
3714
- title: typeof f.title == "string" ? f.title : ""
3755
+ slug: typeof b.slug == "string" ? b.slug : "",
3756
+ title: typeof b.title == "string" ? b.title : ""
3715
3757
  };
3716
3758
  } else
3717
- a = V(t), s = Te(a);
3718
- const l = a.title || a.slug || "current item", u = a.contentType === "product", d = P({
3759
+ a = Y(t), s = q(a);
3760
+ const c = a.title || a.slug || "current item", u = a.contentType === "product", d = N({
3719
3761
  action: "SET IMAGES",
3720
3762
  context: t,
3721
3763
  payload: {
@@ -3728,43 +3770,43 @@ async function on(e, t) {
3728
3770
  contentType: a.contentType,
3729
3771
  imageCount: n.images.length,
3730
3772
  slug: a.slug,
3731
- summary: u ? `Set ${N(
3773
+ summary: u ? `Set ${U(
3732
3774
  n.images.length,
3733
3775
  "image"
3734
- )} on product "${l}" (the first becomes the main product image, the rest the gallery).` : `Set the feature image on the ${a.contentType} "${l}".`,
3776
+ )} on product "${c}" (the first becomes the main product image, the rest the gallery).` : `Set the feature image on the ${a.contentType} "${c}".`,
3735
3777
  title: a.title
3736
3778
  },
3737
3779
  subject: `set images on ${a.contentType} ${String(s)}`
3738
3780
  });
3739
3781
  if (d)
3740
3782
  return d;
3741
- const c = await It(n.images, t, l);
3742
- if (c.length === 0)
3783
+ const l = await xt(n.images, t, c);
3784
+ if (l.length === 0)
3743
3785
  throw new Error("None of the provided images could be resolved to a media item.");
3744
3786
  if (u) {
3745
- const { data: g, error: f } = await o.from("products").select("id, slug, language_id, title").eq("id", s).maybeSingle();
3746
- if (f || !g)
3787
+ const { data: g, error: b } = await o.from("products").select("id, slug, language_id, title").eq("id", s).maybeSingle();
3788
+ if (b || !g)
3747
3789
  throw new Error(
3748
- `Could not load the product to set images: ${_(f)}`
3790
+ `Could not load the product to set images: ${y(b)}`
3749
3791
  );
3750
- const k = await Pn({
3751
- mediaIds: c,
3792
+ const _ = await Un({
3793
+ mediaIds: l,
3752
3794
  productId: s,
3753
3795
  supabase: o
3754
3796
  });
3755
- return await xe({
3756
- patch: ({ meta: y }) => Array.isArray(y.product_media) ? {
3797
+ return await ve({
3798
+ patch: ({ meta: w }) => Array.isArray(w.product_media) ? {
3757
3799
  meta: {
3758
- ...y,
3759
- product_media: k.map((w, b) => ({
3760
- media_id: w,
3761
- sort_order: b
3800
+ ...w,
3801
+ product_media: _.map((k, T) => ({
3802
+ media_id: k,
3803
+ sort_order: T
3762
3804
  }))
3763
3805
  }
3764
3806
  } : {},
3765
3807
  productId: s,
3766
3808
  supabase: o
3767
- }), U(
3809
+ }), O(
3768
3810
  t,
3769
3811
  {
3770
3812
  contentType: "product",
@@ -3777,210 +3819,210 @@ async function on(e, t) {
3777
3819
  ), t?.revalidatePath?.("/cms/products"), {
3778
3820
  contentType: "product",
3779
3821
  entityId: s,
3780
- imageCount: k.length,
3822
+ imageCount: _.length,
3781
3823
  mutationExecuted: !0,
3782
3824
  slug: g.slug,
3783
3825
  success: !0
3784
3826
  };
3785
3827
  }
3786
- const m = a.contentType === "page" ? "pages" : "posts", { data: h, error: p } = await o.from(m).update({
3787
- feature_image_id: c[0],
3828
+ const m = await J(t, a.contentType, s), h = a.contentType === "page" ? "pages" : "posts", { data: p, error: f } = await o.from(h).update({
3829
+ feature_image_id: l[0],
3788
3830
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
3789
3831
  }).eq("id", s).select("id, language_id, slug, status, title").single();
3790
- if (p || !h)
3791
- throw new Error(`Failed to set the feature image: ${_(p)}`);
3792
- return U(t, a, h.slug), {
3832
+ if (f || !p)
3833
+ throw new Error(`Failed to set the feature image: ${y(f)}`);
3834
+ return await G(t, a.contentType, s, m), O(t, a, p.slug), {
3793
3835
  contentType: a.contentType,
3794
3836
  entityId: s,
3795
- extraImagesIgnored: c.length - 1,
3837
+ extraImagesIgnored: l.length - 1,
3796
3838
  imageCount: 1,
3797
3839
  mutationExecuted: !0,
3798
- slug: h.slug,
3840
+ slug: p.slug,
3799
3841
  success: !0
3800
3842
  };
3801
3843
  }
3802
- function co(e) {
3844
+ function po(e) {
3803
3845
  return {
3804
- ...an(e),
3805
- ...sn(e),
3806
- fetch_ecommerce_stats: S({
3846
+ ...cn(e),
3847
+ ...ln(e),
3848
+ fetch_ecommerce_stats: v({
3807
3849
  description: "Fetch quantitative ecommerce statistics and reports from the database. Use this to answer questions about revenue, order counts, order status counts such as pending or trial, and top-selling products over a time range. This tool is read-only and does not require confirmation.",
3808
- execute: (t) => wr(t, e),
3809
- inputSchema: ft,
3850
+ execute: (t) => Tr(t, e),
3851
+ inputSchema: yt,
3810
3852
  strict: !0
3811
3853
  }),
3812
- read_current_cms_item: S({
3854
+ read_current_cms_item: v({
3813
3855
  description: "Read the CMS item currently being edited. Requires pageContext and returns page/post/product metadata plus page/post block summaries or content.",
3814
- execute: (t) => Ir(t, e),
3815
- inputSchema: yt,
3856
+ execute: (t) => xr(t, e),
3857
+ inputSchema: bt,
3816
3858
  strict: !0
3817
3859
  }),
3818
- search_documentation: S({
3860
+ search_documentation: v({
3819
3861
  description: "Search the NextBlock documentation database and return concise source snippets for factual CMS guidance.",
3820
- execute: (t) => hr(t, e),
3821
- inputSchema: je,
3862
+ execute: (t) => _r(t, e),
3863
+ inputSchema: Be,
3822
3864
  strict: !0
3823
3865
  }),
3824
- fetch_url_content: S({
3866
+ fetch_url_content: v({
3825
3867
  description: "Fetch an external web page and return its title, meta description, headings, body text, AND its images: `mainImage` (the page's subject image — schema.org Product image, else og:image, else the best in-body <img>) plus a ranked `images` list, all as absolute URLs. Read-only, no confirmation. Use this first whenever the user references an external URL to copy, adapt, clone, or draw inspiration from. To reuse the source page's image, pass `mainImage` straight into create_cms_product `images` or a page/post `feature_image_id` — it is imported into the media library automatically. Never invent an image URL: if `mainImage` is null, the page had none.",
3826
- execute: (t) => Gr(t),
3827
- inputSchema: Yt,
3868
+ execute: (t) => Hr(t),
3869
+ inputSchema: Qt,
3828
3870
  strict: !0
3829
3871
  }),
3830
- search_stock_photos: S({
3872
+ search_stock_photos: v({
3831
3873
  description: "Find relevant, free, high-quality stock photos (Unsplash/Pexels) for page imagery. Returns a list of photos each with a direct image `url`, `width`, `height`, `alt`, and `photographer`. Read-only, zero cost. Use the returned `url` directly as an image block's external_url or a section image background's image.external_url when building or revamping pages, so layouts show real photos instantly. Set orientation \"landscape\" for hero/section backgrounds.",
3832
- execute: (t) => Jr(t, e),
3833
- inputSchema: tn,
3874
+ execute: (t) => Yr(t, e),
3875
+ inputSchema: rn,
3834
3876
  strict: !0
3835
3877
  }),
3836
- rewrite_page_draft: S({
3878
+ rewrite_page_draft: v({
3837
3879
  description: 'Replace ALL blocks of an existing page or post with a brand-new set of blocks, staged as a Live Draft (content_drafts) that the user previews before publishing. Use this for whole-page redesigns/rewrites such as "rewrite my home page with 5 sections". Provide the complete new list of top-level blocks in `blocks` (usually section blocks for a landing/home page, each with nested heading/text/button blocks). Nothing goes live until the user publishes the draft, and publishing auto-creates a revision snapshot so the change is reversible. Mutating: first returns a confirmation phrase; only stages the draft after the user replies with the exact phrase.',
3838
- execute: (t) => Qr(t, e),
3839
- inputSchema: nn,
3880
+ execute: (t) => eo(t, e),
3881
+ inputSchema: on,
3840
3882
  strict: !0
3841
3883
  }),
3842
- translate_page: S({
3884
+ translate_page: v({
3843
3885
  description: 'Translate the CURRENT page or post into another language. This copies the source page\'s entire structure, layout, and images automatically and links the new page to the original as a translation — you ONLY supply the text translations. Provide targetLanguageCode (e.g. "fr") and a `translations` map of every visible source string to its translation (headings, paragraph text, button labels, image alt text, captions, form labels). Do NOT rebuild the layout or call search_stock_photos for a translation. Requires an open page/post. Mutating: first returns a confirmation phrase; only creates the translation after exact confirmation.',
3844
- execute: (t) => eo(t, e),
3845
- inputSchema: rn,
3886
+ execute: (t) => no(t, e),
3887
+ inputSchema: an,
3846
3888
  strict: !0
3847
3889
  }),
3848
- set_content_images: S({
3890
+ set_content_images: v({
3849
3891
  description: "Set the feature image for a page or post, or the image gallery for a product. Pass `images`: a list of image URLs (e.g. `mainImage` from fetch_url_content or `url` values from search_stock_photos) and/or existing media library IDs. External URLs are imported into the media library automatically — NEVER put an image URL directly into feature_image_id. The FIRST image becomes the feature image (pages/posts) or the main product image (products); for a product the remaining images become its gallery in order (this REPLACES the product's current images). Targets the currently open page/post/product by default; to target any other item (for example a product you just created from the dashboard) pass contentType plus slug, entityId, or title — no open editor needed. Mutating: first returns a confirmation phrase; only applies after exact confirmation.",
3850
- execute: (t) => on(t, e),
3851
- inputSchema: he,
3892
+ execute: (t) => sn(t, e),
3893
+ inputSchema: be,
3852
3894
  strict: !0
3853
3895
  }),
3854
- create_cms_page: S({
3896
+ create_cms_page: v({
3855
3897
  description: "Create a new CMS page with metadata and optional validated page blocks. Mutating: first returns a confirmation phrase; only executes after the user replies with the exact phrase. For translations, pass translationGroupId from the source page/post/product context so the new language is linked to the same backend translation group. For contact pages, provide contactEmail or a form block with recipient_email and fields.",
3856
- execute: (t) => Ve(t, e),
3857
- inputSchema: _e,
3898
+ execute: (t) => We(t, e),
3899
+ inputSchema: ke,
3858
3900
  strict: !0
3859
3901
  }),
3860
- create_cms_post: S({
3902
+ create_cms_post: v({
3861
3903
  description: "Create a new CMS post with metadata and optional validated post blocks. Mutating: first returns a confirmation phrase; only executes after the user replies with the exact phrase. For translations, pass translationGroupId from the source post context so the new language is linked to the same backend translation group.",
3862
- execute: (t) => Je(t, e),
3863
- inputSchema: be,
3904
+ execute: (t) => Ye(t, e),
3905
+ inputSchema: Ie,
3864
3906
  strict: !0
3865
3907
  }),
3866
- create_cms_product: S({
3908
+ create_cms_product: v({
3867
3909
  description: "Create a new draft-capable product, complete with its images and its body copy in ONE call. Pass `images` to set the main product image and gallery (external https URLs are imported into the media library automatically — use `mainImage` from fetch_url_content to reuse a source page's photo). Pass `blocks` to build the product's \"Product Description Blocks\" — the SAME block vocabulary and section-based design rules as create_cms_page, rendered on the public product page. This is the richest product body and is what you should produce whenever the user asks to copy or write real product content. Also pass `short_description` for the one-line summary shown on product cards. `description_html` is a plain-HTML fallback body used only when no blocks are supplied. Defaults missing fields safely: physical Stripe product, generated SKU, price 0, stock 0, taxable, draft. `price` is in major units (25 = $25.00). For translations, pass translationGroupId from the source product context. Mutating: first returns a confirmation phrase; only executes after exact confirmation.",
3868
- execute: (t) => Kt(t, e),
3869
- inputSchema: ke,
3910
+ execute: (t) => Vt(t, e),
3911
+ inputSchema: Te,
3870
3912
  strict: !0
3871
3913
  }),
3872
- delete_cms_item: S({
3914
+ delete_cms_item: v({
3873
3915
  description: "Delete a resolved page, post, or product after exact confirmation. Pages/posts delete all translations in the translation group and related navigation links. Mutating: refuses unless the latest user message includes the exact confirmation phrase.",
3874
- execute: (t) => Wt(t, e),
3875
- inputSchema: Ie,
3916
+ execute: (t) => Xt(t, e),
3917
+ inputSchema: Ce,
3876
3918
  strict: !0
3877
3919
  }),
3878
- prepare_delete_cms_item: S({
3920
+ prepare_delete_cms_item: v({
3879
3921
  description: "Inspect the page, post, or product that would be deleted and return the exact confirmation phrase. This tool does not mutate data.",
3880
- execute: (t) => Ur(t, e),
3881
- inputSchema: _t,
3922
+ execute: (t) => Fr(t, e),
3923
+ inputSchema: wt,
3882
3924
  strict: !0
3883
3925
  }),
3884
- update_footer: S({
3926
+ update_footer: v({
3885
3927
  description: "Replace the public footer links and/or footer copyright settings for a locale. Use links for footer navigation and copyright for locale text templates. Mutating: first returns a confirmation phrase; only executes after exact confirmation.",
3886
- execute: (t) => Ft(t, e),
3887
- inputSchema: pe,
3928
+ execute: (t) => Lt(t, e),
3929
+ inputSchema: fe,
3888
3930
  strict: !0
3889
3931
  }),
3890
- update_content_block: S({
3932
+ update_content_block: v({
3891
3933
  description: 'Update the JSON content of an existing top-level page/post block that belongs to the current CMS edit context. Content is merged with the existing block before validation. For section blocks, add nested blocks with content.append_block or content.append_blocks using objects like { block_type: "button", content: { text: "Contact Us", url: "/contact" } }; existing column_blocks and layout fields are preserved. Mutating: first returns a confirmation phrase; only executes after exact confirmation.',
3892
- execute: (t) => Mt(t, e),
3893
- inputSchema: ge,
3934
+ execute: (t) => zt(t, e),
3935
+ inputSchema: ye,
3894
3936
  strict: !0
3895
3937
  }),
3896
- insert_content_block: S({
3938
+ insert_content_block: v({
3897
3939
  description: 'Insert a new validated top-level page/post block before or after an existing block, or at the start/end. Use this for visible content additions like adding a rich text title and paragraph above a form. For "above the form", use position "before" with anchorBlockType "form" and blockType "text" containing html_content. Mutating: first returns a confirmation phrase; only executes after exact confirmation.',
3898
- execute: (t) => Dt(t, e),
3899
- inputSchema: ye,
3940
+ execute: (t) => Gt(t, e),
3941
+ inputSchema: we,
3900
3942
  strict: !0
3901
3943
  }),
3902
- update_current_cms_fields: S({
3944
+ update_current_cms_fields: v({
3903
3945
  description: "Update validated metadata fields on the current page, post, or product. For products, description_json must be a valid NextBlock editor document JSON object. Mutating: first returns a confirmation phrase; only executes after exact confirmation.",
3904
- execute: (t) => Rt(t, e),
3905
- inputSchema: me,
3946
+ execute: (t) => Dt(t, e),
3947
+ inputSchema: he,
3906
3948
  strict: !0
3907
3949
  }),
3908
- update_cms_item_field: S({
3950
+ update_cms_item_field: v({
3909
3951
  description: "Update one field on a page, post, or product, resolving by current edit context, id, slug, or exact title. Use this for requests like changing price, stock, title, slug, status, sale_price, or meta fields. Interpret public as published for pages/posts and active for products. Scheduled sale date ranges are not supported and will be refused without mutation. Mutating: first returns a confirmation phrase; only executes after exact confirmation.",
3910
- execute: (t) => Ht(t, e),
3911
- inputSchema: we,
3952
+ execute: (t) => Jt(t, e),
3953
+ inputSchema: xe,
3912
3954
  strict: !0
3913
3955
  }),
3914
- update_navigation_bar: S({
3956
+ update_navigation_bar: v({
3915
3957
  description: 'Update the public header navigation bar for a locale. Use mode "append" when adding links while preserving existing navigation. Use mode "update" when renaming or changing an existing single link. Use mode "replace" only when the user asks to rebuild the complete header and you provide the full menu; destructive partial replacements are refused. Mutating: first returns a confirmation phrase; only executes after exact confirmation.',
3916
- execute: (t) => Ot(t, e),
3917
- inputSchema: de,
3958
+ execute: (t) => jt(t, e),
3959
+ inputSchema: ge,
3918
3960
  strict: !0
3919
3961
  }),
3920
- update_section_column_block: S({
3962
+ update_section_column_block: v({
3921
3963
  description: "Update the content of one existing nested block inside a section block that belongs to the current CMS edit context. This tool must not change the nested block type. To add a new nested block, update the parent section with update_content_block and preserve existing column_blocks. Mutating: first returns a confirmation phrase; only executes after exact confirmation.",
3922
- execute: (t) => zt(t, e),
3923
- inputSchema: fe,
3964
+ execute: (t) => Kt(t, e),
3965
+ inputSchema: _e,
3924
3966
  strict: !0
3925
3967
  }),
3926
- execute_cms_action_plan: S({
3968
+ execute_cms_action_plan: v({
3927
3969
  description: "Execute multiple CMS mutations as one confirmed plan. Use this whenever the user asks for more than one change in the same prompt, such as creating a page and adding a navigation link. First returns one combined confirmation preview and Confirm button; after confirmation, runs each action in order and stops on the first failure.",
3928
- execute: (t) => jr(t, e),
3929
- inputSchema: kt,
3970
+ execute: (t) => Br(t, e),
3971
+ inputSchema: It,
3930
3972
  strict: !0
3931
3973
  })
3932
3974
  };
3933
3975
  }
3934
3976
  export {
3935
- K as availableCortexAiBlockTypes,
3936
- so as buildVisibleContactIntroActionPlan,
3937
- ht as cortexAiPageContextSchema,
3938
- _e as createCmsPageInputSchema,
3939
- be as createCmsPostInputSchema,
3940
- ke as createCmsProductInputSchema,
3941
- co as createCortexGlobalAgentTools,
3942
- Ie as deleteCmsItemInputSchema,
3943
- jr as executeCmsActionPlan,
3944
- kt as executeCmsActionPlanInputSchema,
3945
- Ve as executeCreateCmsPage,
3946
- Je as executeCreateCmsPost,
3947
- Kt as executeCreateCmsProduct,
3948
- Wt as executeDeleteCmsItem,
3949
- wr as executeFetchEcommerceStats,
3950
- Gr as executeFetchUrlContent,
3951
- Dt as executeInsertContentBlock,
3952
- Ur as executePrepareDeleteCmsItem,
3953
- Ir as executeReadCurrentCmsItem,
3954
- Qr as executeRewritePageDraft,
3955
- fr as executeSearchDocumentation,
3956
- hr as executeSearchDocumentationWithTimeout,
3957
- Jr as executeSearchStockPhotos,
3958
- on as executeSetContentImages,
3959
- eo as executeTranslatePage,
3960
- Ht as executeUpdateCmsItemField,
3961
- Mt as executeUpdateContentBlock,
3962
- Rt as executeUpdateCurrentCmsFields,
3963
- Ft as executeUpdateFooter,
3964
- Ot as executeUpdateNavigationBar,
3965
- zt as executeUpdateSectionColumnBlock,
3966
- ft as fetchEcommerceStatsInputSchema,
3967
- Yt as fetchUrlContentInputSchema,
3968
- ye as insertContentBlockInputSchema,
3969
- ve as maybeTriggerStockPhotoDownloads,
3970
- gt as navigationItemInputSchema,
3971
- _t as prepareDeleteCmsItemInputSchema,
3972
- yt as readCurrentCmsItemInputSchema,
3973
- lo as resolveCortexAiStockPhotoProvider,
3974
- Ye as resolveCortexAiStockPhotoProviders,
3975
- nn as rewritePageDraftInputSchema,
3976
- je as searchDocumentationInputSchema,
3977
- tn as searchStockPhotosInputSchema,
3978
- he as setContentImagesInputSchema,
3979
- rn as translatePageInputSchema,
3980
- we as updateCmsItemFieldInputSchema,
3981
- ge as updateContentBlockInputSchema,
3982
- me as updateCurrentCmsFieldsInputSchema,
3983
- pe as updateFooterInputSchema,
3984
- de as updateNavigationBarInputSchema,
3985
- fe as updateSectionColumnBlockInputSchema
3977
+ V as availableCortexAiBlockTypes,
3978
+ lo as buildVisibleContactIntroActionPlan,
3979
+ _t as cortexAiPageContextSchema,
3980
+ ke as createCmsPageInputSchema,
3981
+ Ie as createCmsPostInputSchema,
3982
+ Te as createCmsProductInputSchema,
3983
+ po as createCortexGlobalAgentTools,
3984
+ Ce as deleteCmsItemInputSchema,
3985
+ Br as executeCmsActionPlan,
3986
+ It as executeCmsActionPlanInputSchema,
3987
+ We as executeCreateCmsPage,
3988
+ Ye as executeCreateCmsPost,
3989
+ Vt as executeCreateCmsProduct,
3990
+ Xt as executeDeleteCmsItem,
3991
+ Tr as executeFetchEcommerceStats,
3992
+ Hr as executeFetchUrlContent,
3993
+ Gt as executeInsertContentBlock,
3994
+ Fr as executePrepareDeleteCmsItem,
3995
+ xr as executeReadCurrentCmsItem,
3996
+ eo as executeRewritePageDraft,
3997
+ yr as executeSearchDocumentation,
3998
+ _r as executeSearchDocumentationWithTimeout,
3999
+ Yr as executeSearchStockPhotos,
4000
+ sn as executeSetContentImages,
4001
+ no as executeTranslatePage,
4002
+ Jt as executeUpdateCmsItemField,
4003
+ zt as executeUpdateContentBlock,
4004
+ Dt as executeUpdateCurrentCmsFields,
4005
+ Lt as executeUpdateFooter,
4006
+ jt as executeUpdateNavigationBar,
4007
+ Kt as executeUpdateSectionColumnBlock,
4008
+ yt as fetchEcommerceStatsInputSchema,
4009
+ Qt as fetchUrlContentInputSchema,
4010
+ we as insertContentBlockInputSchema,
4011
+ $e as maybeTriggerStockPhotoDownloads,
4012
+ ht as navigationItemInputSchema,
4013
+ wt as prepareDeleteCmsItemInputSchema,
4014
+ bt as readCurrentCmsItemInputSchema,
4015
+ uo as resolveCortexAiStockPhotoProvider,
4016
+ Qe as resolveCortexAiStockPhotoProviders,
4017
+ on as rewritePageDraftInputSchema,
4018
+ Be as searchDocumentationInputSchema,
4019
+ rn as searchStockPhotosInputSchema,
4020
+ be as setContentImagesInputSchema,
4021
+ an as translatePageInputSchema,
4022
+ xe as updateCmsItemFieldInputSchema,
4023
+ ye as updateContentBlockInputSchema,
4024
+ he as updateCurrentCmsFieldsInputSchema,
4025
+ fe as updateFooterInputSchema,
4026
+ ge as updateNavigationBarInputSchema,
4027
+ _e as updateSectionColumnBlockInputSchema
3986
4028
  };