@chaibuilder/pages 0.16.13 → 0.16.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/{2AITGKQY-D1mM4eEh.js → 2AITGKQY-2rt9M99C.js} +5 -5
  2. package/dist/{2AITGKQY-AK2WgbeT.cjs → 2AITGKQY-Cs6RBSPQ.cjs} +1 -1
  3. package/dist/{NCMVHL6D-DItDf9IY.cjs → NCMVHL6D-CsC6nsSQ.cjs} +1 -1
  4. package/dist/{NCMVHL6D-BeRsWdGV.js → NCMVHL6D-vUfYKc6i.js} +2 -2
  5. package/dist/{ZDWCUMSJ-COSBY-at.cjs → ZDWCUMSJ-B2OZjsr6.cjs} +1 -1
  6. package/dist/{ZDWCUMSJ-D6caRaY7.js → ZDWCUMSJ-CzEWKlEU.js} +1 -1
  7. package/dist/active-in-another-tab-B0N5S-Bh.js +34 -0
  8. package/dist/active-in-another-tab-BK3cZf-x.cjs +1 -0
  9. package/dist/{add-new-language-page-CQcFi0Tp.cjs → add-new-language-page-Dt1j-8Zg.cjs} +1 -1
  10. package/dist/{add-new-language-page-nnaUe-qk.js → add-new-language-page-YlqcCdlK.js} +20 -20
  11. package/dist/{add-new-page-DxObnvo_.cjs → add-new-page-DqhQUQBz.cjs} +1 -1
  12. package/dist/{add-new-page-Ba1fq6LH.js → add-new-page-aYomeid4.js} +1 -1
  13. package/dist/ai-panel-content-C6cH9rrC.js +123 -0
  14. package/dist/ai-panel-content-MOZmNIKP.cjs +1 -0
  15. package/dist/ai-panel-default-lang-BZHkFsox.js +317 -0
  16. package/dist/ai-panel-default-lang-DOk_Q0IO.cjs +3 -0
  17. package/dist/{ai-panel-other-lang-B4euTuod.js → ai-panel-other-lang-D2A46FTg.js} +10 -9
  18. package/dist/ai-panel-other-lang-qHrdvAMa.cjs +1 -0
  19. package/dist/ai-prompt-input-BZSjjNJd.cjs +1 -0
  20. package/dist/ai-prompt-input-C6gDvvLQ.js +1071 -0
  21. package/dist/{ai-translation-prompt-Ip7w2_Ey.cjs → ai-translation-prompt-BqXo2CLp.cjs} +1 -1
  22. package/dist/{ai-translation-prompt-CVuPbgXw.js → ai-translation-prompt-DTR0wbGt.js} +1 -1
  23. package/dist/continue-editing-in-this-client-C3T6Jzhi.cjs +1 -0
  24. package/dist/continue-editing-in-this-client-D2S1yCOM.js +24 -0
  25. package/dist/delete-page-BF1k60U2.js +70 -0
  26. package/dist/delete-page-x0DWKzsR.cjs +1 -0
  27. package/dist/{digital-asset-manager-CIMo79Di.cjs → digital-asset-manager-BmlFt2T_.cjs} +1 -1
  28. package/dist/{digital-asset-manager-SAFNO_mx.js → digital-asset-manager-C8udwDBW.js} +1 -1
  29. package/dist/{duplicate-page-CXK2HcxD.cjs → duplicate-page-Dt_QZkTk.cjs} +1 -1
  30. package/dist/{duplicate-page-5SwLvmkX.js → duplicate-page-u_6vUVo1.js} +7 -7
  31. package/dist/{dynamic-page-selector-Crd3y4Hk.cjs → dynamic-page-selector-Cgs_Y_Kl.cjs} +1 -1
  32. package/dist/{dynamic-page-selector-DfcuTqRN.js → dynamic-page-selector-DxBHmglP.js} +1 -1
  33. package/dist/index-BeWL6Sj6.cjs +5 -0
  34. package/dist/index-DI2Rwk5v.js +4820 -0
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.d.ts +1 -34
  37. package/dist/index.js +21 -22
  38. package/dist/{json-diff-viewer-D34kDA_c.cjs → json-diff-viewer-D2g0Yab2.cjs} +1 -1
  39. package/dist/{json-diff-viewer-CDwpbuag.js → json-diff-viewer-QdUwk7yF.js} +6 -6
  40. package/dist/{lang-panel-CUIeO5bb.js → lang-panel-B8OD0GiA.js} +24 -24
  41. package/dist/{lang-panel-CaFrYllL.cjs → lang-panel-M2Zb01lF.cjs} +1 -1
  42. package/dist/{mark-as-template-D0dLQaIB.js → mark-as-template-CJ1mlxYT.js} +7 -7
  43. package/dist/{mark-as-template-v182tmN6.cjs → mark-as-template-DONU52b1.cjs} +1 -1
  44. package/dist/{no-language-page-content-Bk4fEx_p.cjs → no-language-page-content-DD9Ok2Ku.cjs} +1 -1
  45. package/dist/{no-language-page-content-ByRFD_qA.js → no-language-page-content-Dtm37LTJ.js} +1 -1
  46. package/dist/no-language-page-dialog-D3dvenZ7.cjs +1 -0
  47. package/dist/no-language-page-dialog-Dj_z2_hF.js +10 -0
  48. package/dist/{page-creator-Bh0IUGR3.js → page-creator-DIMFISo4.js} +52 -52
  49. package/dist/{page-creator-BnvaGZVI.cjs → page-creator-DTC66ujU.cjs} +1 -1
  50. package/dist/page-lock-CI6BYvF_.cjs +1 -0
  51. package/dist/page-lock-DUlNr3os.js +30 -0
  52. package/dist/page-locked-dialog-BKwULMV7.js +133 -0
  53. package/dist/page-locked-dialog-DorIbva0.cjs +1 -0
  54. package/dist/page-manager-new-lNVrLOJp.cjs +1 -0
  55. package/dist/page-manager-new-znvqI9_L.js +354 -0
  56. package/dist/{page-manager-search-and-filter-BETHSa3y.js → page-manager-search-and-filter-C-_w7N27.js} +1 -1
  57. package/dist/{page-manager-search-and-filter-hyUIHOD_.cjs → page-manager-search-and-filter-pe0q0qnZ.cjs} +1 -1
  58. package/dist/{page-revisions-content-BCMjvZRZ.cjs → page-revisions-content-Caaj5TEI.cjs} +1 -1
  59. package/dist/{page-revisions-content-VWthKL7O.js → page-revisions-content-CyLjyxNU.js} +16 -16
  60. package/dist/pages.css +1 -1
  61. package/dist/publish-pages-content-Bih1W9C4.js +178 -0
  62. package/dist/publish-pages-content-D5beVcQI.cjs +1 -0
  63. package/dist/{save-to-lib-YYBxY7MV.js → save-to-lib-BwpkJcT2.js} +1 -1
  64. package/dist/{save-to-lib-CtGpDkC6.cjs → save-to-lib-DPAERsi4.cjs} +1 -1
  65. package/dist/{selected-block-display-DdW-DWF1.js → selected-block-display-GXSf3y2s.js} +1 -1
  66. package/dist/{selected-block-display-BEbuJn0l.cjs → selected-block-display-s99Y91qI.cjs} +1 -1
  67. package/dist/{seo-panel-CqJDhbj-.js → seo-panel-BurZA566.js} +61 -61
  68. package/dist/{seo-panel-B9P7fXjo.cjs → seo-panel-BxUfalVy.cjs} +1 -1
  69. package/dist/server.cjs +1 -1
  70. package/dist/server.js +39 -39
  71. package/dist/{shared-json-ld-CyxmC9y5.cjs → shared-json-ld-BYAdrPeC.cjs} +1 -1
  72. package/dist/{shared-json-ld-DxEPILj_.js → shared-json-ld-DHWdJvQd.js} +39 -39
  73. package/dist/{slug-input-RNiSrU3p.cjs → slug-input-CR2B1kDJ.cjs} +1 -1
  74. package/dist/{slug-input-j5z5ZQn9.js → slug-input-Z_ny7bgX.js} +1 -1
  75. package/dist/take-over-request-CnEpToCM.cjs +1 -0
  76. package/dist/take-over-request-DF2JsIes.js +63 -0
  77. package/dist/{theme-panel-footer-DD2yalfG.js → theme-panel-footer-5mxFeEua.js} +4 -4
  78. package/dist/{theme-panel-footer-CCsiDIVl.cjs → theme-panel-footer-C2CjHoBu.cjs} +1 -1
  79. package/dist/{unmark-as-template-DXjLbqOM.cjs → unmark-as-template-Dn90g1eh.cjs} +1 -1
  80. package/dist/{unmark-as-template-B2hKhAHn.js → unmark-as-template-JRRUYTOY.js} +1 -1
  81. package/dist/{unpublish-page-BdJScWMX.cjs → unpublish-page-C3C_rTRd.cjs} +1 -1
  82. package/dist/{unpublish-page-BvB1PGSz.js → unpublish-page-FZ8rbi7u.js} +9 -9
  83. package/dist/{web-preview-CwVpkcwU.js → web-preview-CGBKG162.js} +1 -1
  84. package/dist/{web-preview-BI4jd0O7.cjs → web-preview-NdxC92Fk.cjs} +1 -1
  85. package/package.json +3 -3
  86. package/dist/ai-panel-content-B2AgBWqo.cjs +0 -1
  87. package/dist/ai-panel-content-M1UnzG_f.js +0 -54
  88. package/dist/ai-panel-default-lang-CHOFEwmV.js +0 -313
  89. package/dist/ai-panel-default-lang-sy6vkQJh.cjs +0 -3
  90. package/dist/ai-panel-other-lang-BwjSDD3L.cjs +0 -1
  91. package/dist/ai-prompt-input-B_NRADBT.js +0 -988
  92. package/dist/ai-prompt-input-DcyVXcLG.cjs +0 -1
  93. package/dist/delete-page-CbY8q5M3.cjs +0 -1
  94. package/dist/delete-page-SX9X35nA.js +0 -40
  95. package/dist/index-Bz7smSC0.cjs +0 -5
  96. package/dist/index-EnM7J19_.js +0 -4960
  97. package/dist/page-lock-request-C2b1kqyA.cjs +0 -1
  98. package/dist/page-lock-request-CaNqxfD6.js +0 -75
  99. package/dist/page-locked-by-dialog--WLDdkw9.js +0 -68
  100. package/dist/page-locked-by-dialog-90ElC8aG.cjs +0 -1
  101. package/dist/page-manager-new-Bo4-zwfW.js +0 -354
  102. package/dist/page-manager-new-SNRQn7Az.cjs +0 -1
  103. package/dist/publish-pages-content-6N7aEcM1.js +0 -178
  104. package/dist/publish-pages-content-CaBwfekc.cjs +0 -1
package/dist/server.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var U = Object.defineProperty;
2
2
  var D = (s, e, a) => e in s ? U(s, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : s[e] = a;
3
3
  var g = (s, e, a) => D(s, typeof e != "symbol" ? e + "" : e, a);
4
- import { has as k, get as w, noop as R, isEmpty as x, isFunction as b, omit as _, startsWith as G } from "lodash-es";
4
+ import { has as k, get as w, noop as O, isEmpty as x, isFunction as b, omit as _, startsWith as G } from "lodash-es";
5
5
  import { streamText as H } from "ai";
6
6
  import { getRegisteredChaiBlock as B } from "@chaibuilder/runtime";
7
7
  const K = `You are an expert language translator specializing in preserving data structure integrity while translating content.
@@ -78,7 +78,7 @@ CRITICAL REQUIREMENTS (Content Modification):
78
78
  5. Preserve all other language variants and properties unchanged
79
79
  6. Apply changes consistently across related properties when applicable
80
80
 
81
- OUTPUT FORMAT: Valid JSON only, ready to be parsed directly.`, O = `
81
+ OUTPUT FORMAT: Valid JSON only, ready to be parsed directly.`, R = `
82
82
  🚨 CRITICAL FORMAT REQUIREMENT: Your response MUST start with '--START--' immediately. NEVER include any text, thinking, or reasoning before '--START--'. 🚨
83
83
 
84
84
 
@@ -290,14 +290,14 @@ function V(s = null) {
290
290
  case "UPDATE_CONTENT":
291
291
  return F;
292
292
  default:
293
- return O;
293
+ return R;
294
294
  }
295
- return O;
295
+ return R;
296
296
  }
297
297
  let L = async (s) => ({
298
298
  ...s
299
299
  });
300
- const te = (s) => {
300
+ const ae = (s) => {
301
301
  L = s;
302
302
  }, P = async (s) => {
303
303
  try {
@@ -310,26 +310,26 @@ const te = (s) => {
310
310
  }, z = (s, e) => {
311
311
  C[s] = { key: s, ...e, hasSlug: !1 };
312
312
  }, I = {};
313
- function ae(s, e) {
313
+ function ne(s, e) {
314
314
  k(I, s) && console.warn(`Collection ${s} already registered`), I[s] = { ...e, id: s };
315
315
  }
316
- const j = () => Object.values(I), M = (s) => w(I, s);
317
- class J {
316
+ const j = () => Object.values(I), M = (s) => w(I, s), J = "google/gemini-2.5-flash";
317
+ class q {
318
318
  constructor(e) {
319
- g(this, "model", "google/gemini-2.5-pro");
319
+ g(this, "model", J);
320
320
  g(this, "temperature", 0.7);
321
321
  this.options = e, this.model = (e == null ? void 0 : e.model) ?? this.model;
322
322
  }
323
323
  async handleRequest(e, a) {
324
324
  var d, A;
325
- const { messages: n, image: t, initiator: i = null, model: o } = e, c = o || this.model, h = n.filter((l) => l.role !== "system"), m = h[h.length - 1], f = t ? [
325
+ const { messages: n, image: t, initiator: i = null, model: o } = e, c = o || this.model, h = n.filter((l) => l.role !== "system"), p = h[h.length - 1], f = t ? [
326
326
  ...h.slice(0, -1),
327
327
  {
328
328
  role: "user",
329
329
  content: [
330
330
  {
331
331
  type: "text",
332
- text: m.content
332
+ text: p.content
333
333
  },
334
334
  {
335
335
  type: "image",
@@ -337,21 +337,21 @@ class J {
337
337
  }
338
338
  ]
339
339
  }
340
- ] : n, p = H({
340
+ ] : n, m = H({
341
341
  model: c,
342
342
  system: V(i),
343
343
  messages: f,
344
344
  temperature: this.temperature,
345
- onFinish: ((d = this.options) == null ? void 0 : d.onFinish) ?? R,
346
- onError: ((A = this.options) == null ? void 0 : A.onError) ?? R
345
+ onFinish: ((d = this.options) == null ? void 0 : d.onFinish) ?? O,
346
+ onError: ((A = this.options) == null ? void 0 : A.onError) ?? O
347
347
  });
348
- return a && p.pipeTextStreamToResponse(a), p;
348
+ return a && m.pipeTextStreamToResponse(a), m;
349
349
  }
350
350
  isConfigured() {
351
351
  return !0;
352
352
  }
353
353
  }
354
- class q {
354
+ class $ {
355
355
  constructor(e) {
356
356
  this.backend = e;
357
357
  }
@@ -420,7 +420,7 @@ class q {
420
420
  );
421
421
  }
422
422
  }
423
- class $ {
423
+ class W {
424
424
  constructor(e) {
425
425
  this.backend = e;
426
426
  }
@@ -481,7 +481,7 @@ class $ {
481
481
  ));
482
482
  }
483
483
  }
484
- class ne {
484
+ class re {
485
485
  constructor(e) {
486
486
  g(this, "fallbackLang", "");
487
487
  g(this, "draftMode", !1);
@@ -489,7 +489,7 @@ class ne {
489
489
  g(this, "chaiUsers");
490
490
  g(this, "chaiAssets");
491
491
  g(this, "chaiAI");
492
- this.backend = e.backend, this._registerDefaultPageTypes(), this.chaiUsers = e.users ?? new $(this.backend), this.chaiAssets = e.assets ?? new q(this.backend), this.chaiAI = e.ai ?? new J();
492
+ this.backend = e.backend, this._registerDefaultPageTypes(), this.chaiUsers = e.users ?? new W(this.backend), this.chaiAssets = e.assets ?? new $(this.backend), this.chaiAI = e.ai ?? new q();
493
493
  }
494
494
  _registerDefaultPageTypes() {
495
495
  Y("page", {
@@ -516,7 +516,7 @@ class ne {
516
516
  return this.draftMode;
517
517
  }
518
518
  async handle(e, a, n) {
519
- var i, o, c, h, m, f, p, d, A, l, u, E;
519
+ var i, o, c, h, p, f, m, d, A, l, u, E;
520
520
  switch (e.action) {
521
521
  // Media
522
522
  case "UPLOAD_ASSET":
@@ -536,12 +536,12 @@ class ne {
536
536
  case "DELETE_ASSET":
537
537
  return (h = this.chaiAssets) == null ? void 0 : h.deleteAsset(e.data, a);
538
538
  case "UPDATE_ASSET":
539
- return (m = this.chaiAssets) == null ? void 0 : m.updateAsset(e.data, a);
539
+ return (p = this.chaiAssets) == null ? void 0 : p.updateAsset(e.data, a);
540
540
  // Users
541
541
  case "REFRESH_TOKEN":
542
542
  return (f = this.chaiUsers) == null ? void 0 : f.refreshToken(e.data);
543
543
  case "LOGIN":
544
- return (p = this.chaiUsers) == null ? void 0 : p.login(e.data);
544
+ return (m = this.chaiUsers) == null ? void 0 : m.login(e.data);
545
545
  case "LOGOUT":
546
546
  return (d = this.chaiUsers) == null ? void 0 : d.logout();
547
547
  case "CHECK_USER_STATUS":
@@ -705,7 +705,7 @@ class ne {
705
705
  pageProps: n,
706
706
  lang: t
707
707
  }) {
708
- var p;
708
+ var m;
709
709
  const i = this.isDraftMode(), o = T(a), c = e.filter(
710
710
  (d) => d._type === "Repeater" && (d == null ? void 0 : d.repeaterItems.includes("{{#"))
711
711
  );
@@ -736,9 +736,9 @@ class ne {
736
736
  })
737
737
  )).reduce((l, u) => ({ ...l, ...u }), {});
738
738
  }
739
- const [m, f] = await Promise.all([
739
+ const [p, f] = await Promise.all([
740
740
  this.getGlobalData(t),
741
- ((p = o == null ? void 0 : o.dataProvider) == null ? void 0 : p.call(o, {
741
+ ((m = o == null ? void 0 : o.dataProvider) == null ? void 0 : m.call(o, {
742
742
  lang: t,
743
743
  draft: i,
744
744
  inBuilder: !1,
@@ -747,9 +747,9 @@ class ne {
747
747
  ]);
748
748
  return o ? {
749
749
  ...f,
750
- global: m,
750
+ global: p,
751
751
  ...h
752
- } : { global: m, ...h };
752
+ } : { global: p, ...h };
753
753
  }
754
754
  async getGlobalData(e) {
755
755
  return await P({
@@ -768,8 +768,8 @@ class ne {
768
768
  return this.chaiAI;
769
769
  }
770
770
  }
771
- class re {
772
- constructor(e = "", a = W) {
771
+ class se {
772
+ constructor(e = "", a = Z) {
773
773
  this.apiKey = e, this.apiUrl = a;
774
774
  }
775
775
  async handleUsersAction(e, a) {
@@ -805,7 +805,7 @@ class re {
805
805
  })).json();
806
806
  }
807
807
  }
808
- const se = {
808
+ const ie = {
809
809
  ab: "Abkhazian",
810
810
  aa: "Afar",
811
811
  af: "Afrikaans",
@@ -993,21 +993,21 @@ const se = {
993
993
  yo: "Yoruba",
994
994
  za: "Zhuang, Chuang",
995
995
  zu: "Zulu"
996
- }, W = "https://api.chaibuilder.com";
996
+ }, Z = "https://api.chaibuilder.com";
997
997
  export {
998
- W as API_URL,
999
- J as ChaiAIChatHandler,
1000
- ne as ChaiBuilderPages,
1001
- re as ChaiBuilderPagesBackend,
1002
- $ as ChaiBuilderPagesUserManagement,
1003
- se as LANGUAGES,
998
+ Z as API_URL,
999
+ q as ChaiAIChatHandler,
1000
+ re as ChaiBuilderPages,
1001
+ se as ChaiBuilderPagesBackend,
1002
+ W as ChaiBuilderPagesUserManagement,
1003
+ ie as LANGUAGES,
1004
1004
  V as getAskAiSystemPrompt,
1005
1005
  M as getChaiCollection,
1006
1006
  j as getChaiCollections,
1007
1007
  T as getChaiPageType,
1008
1008
  v as getChaiPageTypes,
1009
- ae as registerChaiCollection,
1010
- te as registerChaiGlobalDataProvider,
1009
+ ne as registerChaiCollection,
1010
+ ae as registerChaiGlobalDataProvider,
1011
1011
  Y as registerChaiPageType,
1012
1012
  z as registerChaiPartialType
1013
1013
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@chaibuilder/sdk"),I=require("@tanstack/react-query"),c=require("./index-Bz7smSC0.cjs"),s=require("@chaibuilder/sdk/ui"),G=require("lodash-es"),f=require("lucide-react"),x=require("react"),E=require("sonner"),q=()=>{const t=c.useApiUrl(),d=c.useFetch();return I.useQuery({queryKey:[c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS],queryFn:async()=>d(t,{action:c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS})})},U=({show:t,onClose:d,initialData:n})=>e.jsx(s.Dialog,{open:t,onOpenChange:()=>d(),children:t&&e.jsx(_,{show:t,onClose:d,initialData:n})}),_=({show:t,onClose:d,initialData:n})=>{const[r,p]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[N,C]=x.useState(!1),{data:g}=c.useCurrentPage(),{mutateAsync:A,isPending:j}=c.useAddGlobalSchema(),{mutateAsync:u}=c.useTogglePageGlobalSchema(),v=I.useQueryClient();x.useEffect(()=>{p(n?{name:n.name,description:n.description,content:JSON.stringify(n.jsonld,null,2),enabledByDefaultForNewPages:!1}:{name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),C(!1)},[t,n]);const i=async()=>{if(!r.name||!r.content){E.toast.error("Please enter a name and content");return}const l=c.parseJSONWithPlaceholders(r.content);if(!l.isValid){E.toast.error("Invalid JSON-LD content");return}const b={name:r.name,jsonld:l.parsed,addToExistingPages:N,addToNewPages:r.enabledByDefaultForNewPages,description:r.description};n!=null&&n.primaryPageId&&(b.primaryPage=n.primaryPageId);const w=await A(b);g!=null&&g.id&&(w!=null&&w.id)&&!(n!=null&&n.primaryPageId)&&(await u({schemaId:w.id,pageId:g.id,enabled:!0}),v.invalidateQueries({queryKey:[c.ACTIONS.GET_LANGUAGE_PAGES,g.id]})),d()};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Add New Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[(n==null?void 0:n.languageCode)&&e.jsxs(s.Alert,{className:"border-blue-200 bg-blue-50",children:[e.jsx(f.Info,{className:"h-4 w-4 text-blue-600"}),e.jsxs(s.AlertDescription,{className:"text-sm text-blue-800",children:["You are creating a ",e.jsx("span",{className:"font-semibold",children:n.languageCode})," language version of this schema. This will be linked to the default language schema."]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(s.Input,{id:"new-name",value:r.name,onChange:l=>p({...r,name:l.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-description",children:"Description"}),e.jsx(s.Input,{id:"new-description",value:r.description||"",onChange:l=>p({...r,description:l.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"new-content",value:r.content||"{}",onChange:l=>p({...r,content:l}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!(n!=null&&n.primaryPageId)&&e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"add-to-all-existing",checked:N,onChange:l=>C(l.target.checked),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"add-to-all-existing",children:[e.jsx("div",{children:"Add to all existing pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"This schema will be added to all existing pages on your site"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-enabled",checked:r.enabledByDefaultForNewPages,onChange:l=>p({...r,enabledByDefaultForNewPages:l.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"new-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(s.Button,{disabled:j,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(s.Button,{disabled:j,type:"button",size:"sm",onClick:i,children:j?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"})," Adding"]}):e.jsxs(e.Fragment,{children:["Add Schema",(n==null?void 0:n.languageCode)&&` (${n.languageCode})`]})})]})})]})]})},H=({id:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:()=>d(),children:t&&e.jsx(Q,{id:t,onClose:d})}),Q=({id:t,onClose:d})=>{const[n,r]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[p,N]=x.useState(!1),[C,g]=x.useState(!1),[A,j]=x.useState(!1),{data:u}=q(),{mutateAsync:v,isPending:i}=c.useUpdateGlobalSchema(),{mutateAsync:l}=c.useApplySchemaToAllPages(),{mutateAsync:b}=c.useRemoveSchemaFromAllPages();x.useEffect(()=>{var m,D;if(t&&u){const y=u.find(P=>P.id===t);y&&(r({name:y.name,description:((m=y.metadata)==null?void 0:m.description)||"",content:JSON.stringify(y.jsonld,null,2),enabledByDefaultForNewPages:((D=y.metadata)==null?void 0:D.addToNewPages)||!1}),j(!!y.primaryPage))}},[t,u]);const w=async()=>{if(!n.name||!n.content){E.toast.error("Please enter a name and content");return}const m=c.parseJSONWithPlaceholders(n.content);if(!m.isValid){E.toast.error("Invalid JSON-LD content");return}const D={id:t,name:n.name,jsonld:m.parsed,addToNewPages:n.enabledByDefaultForNewPages,description:n.description};await v(D),d()},F=async()=>{try{await l(t)}finally{N(!1)}},T=async()=>{try{await b(t)}finally{g(!1)}};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Edit Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[!A&&e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-blue-900",children:"Manage Existing Pages"}),e.jsx("div",{className:"text-xs text-blue-700",children:"Add or remove this schema from all existing pages on your site"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{size:"sm",className:"text-xs",variant:"outline",onClick:()=>N(!0),children:"Add to all existing"}),e.jsx(s.Button,{size:"sm",variant:"ghost",className:"text-xs",onClick:()=>g(!0),children:"Remove from all"})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-name",children:"Schema Name"}),e.jsx(s.Input,{id:"edit-name",value:n.name,onChange:m=>r({...n,name:m.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-description",children:"Description"}),e.jsx(s.Input,{id:"edit-description",value:n.description||"",onChange:m=>r({...n,description:m.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"edit-content",value:n.content||"{}",onChange:m=>r({...n,content:m}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!A&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"edit-enabled",checked:n.enabledByDefaultForNewPages,onChange:m=>r({...n,enabledByDefaultForNewPages:m.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"edit-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(s.Button,{disabled:i,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(s.Button,{disabled:i,type:"button",size:"sm",onClick:w,children:i?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"})," Updating"]}):"Update Schema"})]})})]}),e.jsx(s.AlertDialog,{open:p,onOpenChange:N,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Add to All Existing Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will add the schema ",e.jsx("span",{className:"font-medium",children:n.name})," to all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:F,children:"Add to All"})]})]})}),e.jsx(s.AlertDialog,{open:C,onOpenChange:g,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Remove from All Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will remove the schema ",e.jsx("span",{className:"font-medium",children:n.name})," from all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:T,className:"bg-red-500 hover:bg-red-600",children:"Remove from All"})]})]})})]})};function V(){const[t,d]=x.useState(!1),[n,r]=x.useState(void 0),[p,N]=x.useState(null),[C,g]=x.useState(null),[A,j]=x.useState(null),{data:u,isLoading:v}=q(),{selectedLang:i}=M.useLanguages(),{data:l}=c.useCurrentPage(),{data:b}=c.useLanguagePages(),{mutateAsync:w}=c.useDeleteGlobalSchema(),{mutateAsync:F}=c.useTogglePageGlobalSchema(),T=x.useMemo(()=>b==null?void 0:b.find(a=>!a.primaryPage&&a.lang===""),[b]),m=x.useMemo(()=>(T==null?void 0:T.globalJsonLds)||[],[T]),D=x.useMemo(()=>u?G.filter(u,o=>o.primaryPage===null&&o.lang==="").map(o=>{const h=i?G.find(u,S=>S.primaryPage===o.id&&S.lang===i):null;return{defaultSchema:o,languageVersion:h,displayItem:h||o,hasLanguageVersion:!!h}}):[],[u,i]),[y,P]=x.useState([]),L=y.length>0?y:(l==null?void 0:l.globalJsonLds)||[];x.useEffect(()=>{l!=null&&l.globalJsonLds&&P(l.globalJsonLds)},[l==null?void 0:l.globalJsonLds]);const z=async a=>{if(!(l!=null&&l.id))return;j(a);const o=L.includes(a),h=o?L.filter(S=>S!==a):[...L,a];P(h);try{await F({schemaId:a,pageId:l.id,enabled:!o})}catch{P(l.globalJsonLds)}finally{j(null)}},R=async a=>{j(a);try{await w(a)}finally{j(null)}};return e.jsxs("div",{className:"rounded border bg-muted p-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:"Shared JSON-LD Templates"}),e.jsx("div",{className:"w-full text-xs text-gray-500",children:"Manage reusable JSON-LD schemas that can be applied across multiple pages"})]}),!i&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:v,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:a=>{a.stopPropagation(),d(!0)},children:v?e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(f.Plus,{className:"h-4 w-4"})}),e.jsx(s.TooltipContent,{children:"Add new schema"})]})]}),e.jsxs(s.ScrollArea,{className:"max-h-96 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[(!u||(u==null?void 0:u.length)===0)&&!v&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),D.map(({defaultSchema:a,displayItem:o,hasLanguageVersion:h})=>{var k,B;const S=L.includes(o.id),O=m.includes(a.id),J=h&&i?O:S;return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${A===o.id?"pointer-events-none":""}`,children:[A===o.id&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80",children:e.jsx(f.Loader,{className:"h-5 w-5 animate-spin text-primary"})}),e.jsx(s.CardHeader,{className:"p-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(h||!i)&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("input",{type:"checkbox",checked:J,onChange:()=>z(a.id),disabled:!!(h&&i),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"})}),h&&i&&e.jsx(s.TooltipContent,{children:"Using the default language state"})]}),e.jsxs("div",{children:[e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:[o.name,h&&i&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(",i,")"]}),J&&e.jsx("span",{className:"sr-only text-xs font-normal text-muted-foreground",children:"Enabled"})]}),((k=o==null?void 0:o.metadata)==null?void 0:k.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:(B=o==null?void 0:o.metadata)==null?void 0:B.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"mx-2 h-6 w-px bg-border"}),e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>g(o.id),children:e.jsx(f.Eye,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"View schema"})]}),(h||!i)&&e.jsxs(e.Fragment,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>N(o.id),children:e.jsx(f.Edit,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Edit schema"})]}),e.jsxs(s.AlertDialog,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.AlertDialogTrigger,{className:"flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800",children:e.jsx(f.Trash,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Delete schema"})]}),e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Schema"}),e.jsxs(s.AlertDialogDescription,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium",children:o.name}),"? This action cannot be undone."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{type:"button",children:"Cancel"}),e.jsx(s.AlertDialogAction,{type:"button",onClick:()=>R(o.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})]})}),!h&&i&&e.jsx(s.CardContent,{className:"px-2 pb-2",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"max-w-xl text-center text-xs text-gray-500",children:["Not available in '",i,"' language. Default language JSONLD will be used."]}),O&&e.jsx("span",{className:"rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700",children:"Enabled in default"})]}),e.jsx(s.Button,{type:"button",size:"sm",variant:"outline",className:"mt-2",onClick:()=>{r({name:a.name,description:a.description||"",jsonld:a.jsonld,languageCode:i,primaryPageId:a.id}),d(!0)},children:"Copy & Edit from default language"})]})})]},a.id)})]}),v&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(f.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(U,{show:t,onClose:()=>{d(!1),r(void 0)},initialData:n}),e.jsx(H,{id:p,onClose:()=>N(null)}),e.jsx(K,{schema:u==null?void 0:u.find(a=>a.id===C),onClose:()=>g(null)})]})}const K=({schema:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:d,children:e.jsxs(s.DialogContent,{className:"max-w-2xl",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[t==null?void 0:t.name,(t==null?void 0:t.lang)&&e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",t.lang,")"]})]})}),e.jsxs("div",{className:"space-y-3",children:[(t==null?void 0:t.description)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Description"}),e.jsx("div",{className:"text-sm",children:t.description})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"JSON-LD Schema"}),e.jsx(s.Textarea,{value:JSON.stringify(t==null?void 0:t.jsonld,null,2),readOnly:!0,className:"font-mono text-xs",rows:15})]})]})]})});exports.default=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@chaibuilder/sdk"),I=require("@tanstack/react-query"),c=require("./index-BeWL6Sj6.cjs"),s=require("@chaibuilder/sdk/ui"),G=require("lodash-es"),f=require("lucide-react"),x=require("react"),E=require("sonner"),q=()=>{const t=c.useApiUrl(),d=c.useFetch();return I.useQuery({queryKey:[c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS],queryFn:async()=>d(t,{action:c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS})})},U=({show:t,onClose:d,initialData:n})=>e.jsx(s.Dialog,{open:t,onOpenChange:()=>d(),children:t&&e.jsx(_,{show:t,onClose:d,initialData:n})}),_=({show:t,onClose:d,initialData:n})=>{const[r,p]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[N,C]=x.useState(!1),{data:g}=c.useCurrentPage(),{mutateAsync:A,isPending:j}=c.useAddGlobalSchema(),{mutateAsync:u}=c.useTogglePageGlobalSchema(),v=I.useQueryClient();x.useEffect(()=>{p(n?{name:n.name,description:n.description,content:JSON.stringify(n.jsonld,null,2),enabledByDefaultForNewPages:!1}:{name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),C(!1)},[t,n]);const i=async()=>{if(!r.name||!r.content){E.toast.error("Please enter a name and content");return}const l=c.parseJSONWithPlaceholders(r.content);if(!l.isValid){E.toast.error("Invalid JSON-LD content");return}const b={name:r.name,jsonld:l.parsed,addToExistingPages:N,addToNewPages:r.enabledByDefaultForNewPages,description:r.description};n!=null&&n.primaryPageId&&(b.primaryPage=n.primaryPageId);const w=await A(b);g!=null&&g.id&&(w!=null&&w.id)&&!(n!=null&&n.primaryPageId)&&(await u({schemaId:w.id,pageId:g.id,enabled:!0}),v.invalidateQueries({queryKey:[c.ACTIONS.GET_LANGUAGE_PAGES,g.id]})),d()};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Add New Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[(n==null?void 0:n.languageCode)&&e.jsxs(s.Alert,{className:"border-blue-200 bg-blue-50",children:[e.jsx(f.Info,{className:"h-4 w-4 text-blue-600"}),e.jsxs(s.AlertDescription,{className:"text-sm text-blue-800",children:["You are creating a ",e.jsx("span",{className:"font-semibold",children:n.languageCode})," language version of this schema. This will be linked to the default language schema."]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(s.Input,{id:"new-name",value:r.name,onChange:l=>p({...r,name:l.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-description",children:"Description"}),e.jsx(s.Input,{id:"new-description",value:r.description||"",onChange:l=>p({...r,description:l.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"new-content",value:r.content||"{}",onChange:l=>p({...r,content:l}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!(n!=null&&n.primaryPageId)&&e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"add-to-all-existing",checked:N,onChange:l=>C(l.target.checked),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"add-to-all-existing",children:[e.jsx("div",{children:"Add to all existing pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"This schema will be added to all existing pages on your site"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-enabled",checked:r.enabledByDefaultForNewPages,onChange:l=>p({...r,enabledByDefaultForNewPages:l.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"new-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(s.Button,{disabled:j,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(s.Button,{disabled:j,type:"button",size:"sm",onClick:i,children:j?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"})," Adding"]}):e.jsxs(e.Fragment,{children:["Add Schema",(n==null?void 0:n.languageCode)&&` (${n.languageCode})`]})})]})})]})]})},H=({id:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:()=>d(),children:t&&e.jsx(Q,{id:t,onClose:d})}),Q=({id:t,onClose:d})=>{const[n,r]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[p,N]=x.useState(!1),[C,g]=x.useState(!1),[A,j]=x.useState(!1),{data:u}=q(),{mutateAsync:v,isPending:i}=c.useUpdateGlobalSchema(),{mutateAsync:l}=c.useApplySchemaToAllPages(),{mutateAsync:b}=c.useRemoveSchemaFromAllPages();x.useEffect(()=>{var m,D;if(t&&u){const y=u.find(P=>P.id===t);y&&(r({name:y.name,description:((m=y.metadata)==null?void 0:m.description)||"",content:JSON.stringify(y.jsonld,null,2),enabledByDefaultForNewPages:((D=y.metadata)==null?void 0:D.addToNewPages)||!1}),j(!!y.primaryPage))}},[t,u]);const w=async()=>{if(!n.name||!n.content){E.toast.error("Please enter a name and content");return}const m=c.parseJSONWithPlaceholders(n.content);if(!m.isValid){E.toast.error("Invalid JSON-LD content");return}const D={id:t,name:n.name,jsonld:m.parsed,addToNewPages:n.enabledByDefaultForNewPages,description:n.description};await v(D),d()},F=async()=>{try{await l(t)}finally{N(!1)}},T=async()=>{try{await b(t)}finally{g(!1)}};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Edit Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[!A&&e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-blue-900",children:"Manage Existing Pages"}),e.jsx("div",{className:"text-xs text-blue-700",children:"Add or remove this schema from all existing pages on your site"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{size:"sm",className:"text-xs",variant:"outline",onClick:()=>N(!0),children:"Add to all existing"}),e.jsx(s.Button,{size:"sm",variant:"ghost",className:"text-xs",onClick:()=>g(!0),children:"Remove from all"})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-name",children:"Schema Name"}),e.jsx(s.Input,{id:"edit-name",value:n.name,onChange:m=>r({...n,name:m.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-description",children:"Description"}),e.jsx(s.Input,{id:"edit-description",value:n.description||"",onChange:m=>r({...n,description:m.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"edit-content",value:n.content||"{}",onChange:m=>r({...n,content:m}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!A&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"edit-enabled",checked:n.enabledByDefaultForNewPages,onChange:m=>r({...n,enabledByDefaultForNewPages:m.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"edit-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(s.Button,{disabled:i,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(s.Button,{disabled:i,type:"button",size:"sm",onClick:w,children:i?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"})," Updating"]}):"Update Schema"})]})})]}),e.jsx(s.AlertDialog,{open:p,onOpenChange:N,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Add to All Existing Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will add the schema ",e.jsx("span",{className:"font-medium",children:n.name})," to all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:F,children:"Add to All"})]})]})}),e.jsx(s.AlertDialog,{open:C,onOpenChange:g,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Remove from All Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will remove the schema ",e.jsx("span",{className:"font-medium",children:n.name})," from all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:T,className:"bg-red-500 hover:bg-red-600",children:"Remove from All"})]})]})})]})};function V(){const[t,d]=x.useState(!1),[n,r]=x.useState(void 0),[p,N]=x.useState(null),[C,g]=x.useState(null),[A,j]=x.useState(null),{data:u,isLoading:v}=q(),{selectedLang:i}=M.useLanguages(),{data:l}=c.useCurrentPage(),{data:b}=c.useLanguagePages(),{mutateAsync:w}=c.useDeleteGlobalSchema(),{mutateAsync:F}=c.useTogglePageGlobalSchema(),T=x.useMemo(()=>b==null?void 0:b.find(a=>!a.primaryPage&&a.lang===""),[b]),m=x.useMemo(()=>(T==null?void 0:T.globalJsonLds)||[],[T]),D=x.useMemo(()=>u?G.filter(u,o=>o.primaryPage===null&&o.lang==="").map(o=>{const h=i?G.find(u,S=>S.primaryPage===o.id&&S.lang===i):null;return{defaultSchema:o,languageVersion:h,displayItem:h||o,hasLanguageVersion:!!h}}):[],[u,i]),[y,P]=x.useState([]),L=y.length>0?y:(l==null?void 0:l.globalJsonLds)||[];x.useEffect(()=>{l!=null&&l.globalJsonLds&&P(l.globalJsonLds)},[l==null?void 0:l.globalJsonLds]);const z=async a=>{if(!(l!=null&&l.id))return;j(a);const o=L.includes(a),h=o?L.filter(S=>S!==a):[...L,a];P(h);try{await F({schemaId:a,pageId:l.id,enabled:!o})}catch{P(l.globalJsonLds)}finally{j(null)}},R=async a=>{j(a);try{await w(a)}finally{j(null)}};return e.jsxs("div",{className:"rounded border bg-muted p-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:"Shared JSON-LD Templates"}),e.jsx("div",{className:"w-full text-xs text-gray-500",children:"Manage reusable JSON-LD schemas that can be applied across multiple pages"})]}),!i&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:v,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:a=>{a.stopPropagation(),d(!0)},children:v?e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(f.Plus,{className:"h-4 w-4"})}),e.jsx(s.TooltipContent,{children:"Add new schema"})]})]}),e.jsxs(s.ScrollArea,{className:"max-h-96 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[(!u||(u==null?void 0:u.length)===0)&&!v&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),D.map(({defaultSchema:a,displayItem:o,hasLanguageVersion:h})=>{var k,B;const S=L.includes(o.id),O=m.includes(a.id),J=h&&i?O:S;return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${A===o.id?"pointer-events-none":""}`,children:[A===o.id&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80",children:e.jsx(f.Loader,{className:"h-5 w-5 animate-spin text-primary"})}),e.jsx(s.CardHeader,{className:"p-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(h||!i)&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("input",{type:"checkbox",checked:J,onChange:()=>z(a.id),disabled:!!(h&&i),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"})}),h&&i&&e.jsx(s.TooltipContent,{children:"Using the default language state"})]}),e.jsxs("div",{children:[e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:[o.name,h&&i&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(",i,")"]}),J&&e.jsx("span",{className:"sr-only text-xs font-normal text-muted-foreground",children:"Enabled"})]}),((k=o==null?void 0:o.metadata)==null?void 0:k.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:(B=o==null?void 0:o.metadata)==null?void 0:B.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"mx-2 h-6 w-px bg-border"}),e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>g(o.id),children:e.jsx(f.Eye,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"View schema"})]}),(h||!i)&&e.jsxs(e.Fragment,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>N(o.id),children:e.jsx(f.Edit,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Edit schema"})]}),e.jsxs(s.AlertDialog,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.AlertDialogTrigger,{className:"flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800",children:e.jsx(f.Trash,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Delete schema"})]}),e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Schema"}),e.jsxs(s.AlertDialogDescription,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium",children:o.name}),"? This action cannot be undone."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{type:"button",children:"Cancel"}),e.jsx(s.AlertDialogAction,{type:"button",onClick:()=>R(o.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})]})}),!h&&i&&e.jsx(s.CardContent,{className:"px-2 pb-2",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"max-w-xl text-center text-xs text-gray-500",children:["Not available in '",i,"' language. Default language JSONLD will be used."]}),O&&e.jsx("span",{className:"rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700",children:"Enabled in default"})]}),e.jsx(s.Button,{type:"button",size:"sm",variant:"outline",className:"mt-2",onClick:()=>{r({name:a.name,description:a.description||"",jsonld:a.jsonld,languageCode:i,primaryPageId:a.id}),d(!0)},children:"Copy & Edit from default language"})]})})]},a.id)})]}),v&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(f.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(U,{show:t,onClose:()=>{d(!1),r(void 0)},initialData:n}),e.jsx(H,{id:p,onClose:()=>N(null)}),e.jsx(K,{schema:u==null?void 0:u.find(a=>a.id===C),onClose:()=>g(null)})]})}const K=({schema:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:d,children:e.jsxs(s.DialogContent,{className:"max-w-2xl",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[t==null?void 0:t.name,(t==null?void 0:t.lang)&&e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",t.lang,")"]})]})}),e.jsxs("div",{className:"space-y-3",children:[(t==null?void 0:t.description)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Description"}),e.jsx("div",{className:"text-sm",children:t.description})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"JSON-LD Schema"}),e.jsx(s.Textarea,{value:JSON.stringify(t==null?void 0:t.jsonld,null,2),readOnly:!0,className:"font-mono text-xs",rows:15})]})]})]})});exports.default=V;
@@ -1,10 +1,10 @@
1
- import { jsx as e, jsxs as n, Fragment as j } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as n, Fragment as G } from "react/jsx-runtime";
2
2
  import { useLanguages as me } from "@chaibuilder/sdk";
3
3
  import { useQuery as he, useQueryClient as ue } from "@tanstack/react-query";
4
- import { al as ge, am as fe, A as U, aq as te, av as pe, aw as se, ax as re, ay as de, az as xe, aA as Ne, aB as be, g as ye, aC as ve } from "./index-EnM7J19_.js";
5
- import { Dialog as $, DialogContent as W, DialogHeader as Y, DialogTitle as X, Alert as we, AlertDescription as Ae, Label as y, Input as G, Button as v, AlertDialog as _, AlertDialogContent as R, AlertDialogHeader as q, AlertDialogTitle as M, AlertDialogDescription as H, AlertDialogFooter as Q, AlertDialogCancel as V, AlertDialogAction as K, Tooltip as E, TooltipTrigger as J, TooltipContent as O, ScrollArea as Ce, Card as Se, CardHeader as Pe, CardTitle as Te, AlertDialogTrigger as De, CardContent as Le, Textarea as Ee } from "@chaibuilder/sdk/ui";
6
- import { filter as Je, find as Oe } from "lodash-es";
7
- import { Info as Fe, Loader as F, Plus as ke, Eye as je, Edit as Ge, Trash as Be } from "lucide-react";
4
+ import { aq as ge, ar as fe, A as U, aw as te, aC as pe, aD as se, aE as re, aF as de, aG as xe, aH as Ne, aI as be, l as ye, aJ as ve } from "./index-DI2Rwk5v.js";
5
+ import { Dialog as $, DialogContent as W, DialogHeader as Y, DialogTitle as X, Alert as we, AlertDescription as Ae, Label as y, Input as j, Button as v, AlertDialog as _, AlertDialogContent as R, AlertDialogHeader as q, AlertDialogTitle as M, AlertDialogDescription as H, AlertDialogFooter as Q, AlertDialogCancel as V, AlertDialogAction as K, Tooltip as L, TooltipTrigger as J, TooltipContent as F, ScrollArea as Ce, Card as Se, CardHeader as Pe, CardTitle as Te, AlertDialogTrigger as De, CardContent as Ee, Textarea as Le } from "@chaibuilder/sdk/ui";
6
+ import { filter as Je, find as Fe } from "lodash-es";
7
+ import { Info as Oe, Loader as O, Plus as ke, Eye as Ge, Edit as je, Trash as Be } from "lucide-react";
8
8
  import { useState as g, useEffect as Z, useMemo as z } from "react";
9
9
  import { toast as B } from "sonner";
10
10
  const oe = () => {
@@ -67,7 +67,7 @@ const oe = () => {
67
67
  /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ e(X, { children: "Add New Shared JSON-LD Schema" }) }),
68
68
  /* @__PURE__ */ n("div", { className: "flex max-h-[75vh] flex-col space-y-2 overflow-y-auto", children: [
69
69
  (a == null ? void 0 : a.languageCode) && /* @__PURE__ */ n(we, { className: "border-blue-200 bg-blue-50", children: [
70
- /* @__PURE__ */ e(Fe, { className: "h-4 w-4 text-blue-600" }),
70
+ /* @__PURE__ */ e(Oe, { className: "h-4 w-4 text-blue-600" }),
71
71
  /* @__PURE__ */ n(Ae, { className: "text-sm text-blue-800", children: [
72
72
  "You are creating a ",
73
73
  /* @__PURE__ */ e("span", { className: "font-semibold", children: a.languageCode }),
@@ -77,7 +77,7 @@ const oe = () => {
77
77
  /* @__PURE__ */ n("div", { children: [
78
78
  /* @__PURE__ */ e(y, { htmlFor: "new-name", children: "Schema Name" }),
79
79
  /* @__PURE__ */ e(
80
- G,
80
+ j,
81
81
  {
82
82
  id: "new-name",
83
83
  value: d.name,
@@ -90,7 +90,7 @@ const oe = () => {
90
90
  /* @__PURE__ */ n("div", { children: [
91
91
  /* @__PURE__ */ e(y, { htmlFor: "new-description", children: "Description" }),
92
92
  /* @__PURE__ */ e(
93
- G,
93
+ j,
94
94
  {
95
95
  id: "new-description",
96
96
  value: d.description || "",
@@ -148,10 +148,10 @@ const oe = () => {
148
148
  ] }),
149
149
  /* @__PURE__ */ e("div", { className: "border-t pt-3", children: /* @__PURE__ */ n("div", { className: "flex items-center justify-end gap-2", children: [
150
150
  /* @__PURE__ */ e(v, { disabled: p, variant: "outline", type: "button", size: "sm", onClick: () => i(), children: "Cancel" }),
151
- /* @__PURE__ */ e(v, { disabled: p, type: "button", size: "sm", onClick: o, children: p ? /* @__PURE__ */ n(j, { children: [
152
- /* @__PURE__ */ e(F, { className: "h-4 w-4 animate-spin" }),
151
+ /* @__PURE__ */ e(v, { disabled: p, type: "button", size: "sm", onClick: o, children: p ? /* @__PURE__ */ n(G, { children: [
152
+ /* @__PURE__ */ e(O, { className: "h-4 w-4 animate-spin" }),
153
153
  " Adding"
154
- ] }) : /* @__PURE__ */ n(j, { children: [
154
+ ] }) : /* @__PURE__ */ n(G, { children: [
155
155
  "Add Schema",
156
156
  (a == null ? void 0 : a.languageCode) && ` (${a.languageCode})`
157
157
  ] }) })
@@ -168,7 +168,7 @@ const oe = () => {
168
168
  Z(() => {
169
169
  var m, D;
170
170
  if (l && c) {
171
- const b = c.find((L) => L.id === l);
171
+ const b = c.find((E) => E.id === l);
172
172
  b && (d({
173
173
  name: b.name,
174
174
  description: ((m = b.metadata) == null ? void 0 : m.description) || "",
@@ -224,7 +224,7 @@ const oe = () => {
224
224
  /* @__PURE__ */ n("div", { children: [
225
225
  /* @__PURE__ */ e(y, { htmlFor: "edit-name", children: "Schema Name" }),
226
226
  /* @__PURE__ */ e(
227
- G,
227
+ j,
228
228
  {
229
229
  id: "edit-name",
230
230
  value: a.name,
@@ -237,7 +237,7 @@ const oe = () => {
237
237
  /* @__PURE__ */ n("div", { children: [
238
238
  /* @__PURE__ */ e(y, { htmlFor: "edit-description", children: "Description" }),
239
239
  /* @__PURE__ */ e(
240
- G,
240
+ j,
241
241
  {
242
242
  id: "edit-description",
243
243
  value: a.description || "",
@@ -277,8 +277,8 @@ const oe = () => {
277
277
  ] }),
278
278
  /* @__PURE__ */ e("div", { className: "border-t pt-3", children: /* @__PURE__ */ n("div", { className: "flex items-center justify-end gap-2", children: [
279
279
  /* @__PURE__ */ e(v, { disabled: o, variant: "outline", type: "button", size: "sm", onClick: () => i(), children: "Cancel" }),
280
- /* @__PURE__ */ e(v, { disabled: o, type: "button", size: "sm", onClick: A, children: o ? /* @__PURE__ */ n(j, { children: [
281
- /* @__PURE__ */ e(F, { className: "h-4 w-4 animate-spin" }),
280
+ /* @__PURE__ */ e(v, { disabled: o, type: "button", size: "sm", onClick: A, children: o ? /* @__PURE__ */ n(G, { children: [
281
+ /* @__PURE__ */ e(O, { className: "h-4 w-4 animate-spin" }),
282
282
  " Updating"
283
283
  ] }) : "Update Schema" })
284
284
  ] }) })
@@ -315,7 +315,7 @@ const oe = () => {
315
315
  };
316
316
  function Xe() {
317
317
  const [l, i] = g(!1), [a, d] = g(void 0), [f, x] = g(null), [P, u] = g(null), [C, p] = g(null), { data: c, isLoading: w } = oe(), { selectedLang: o } = me(), { data: t } = te(), { data: N } = ye(), { mutateAsync: A } = ve(), { mutateAsync: I } = se(), T = z(() => N == null ? void 0 : N.find((s) => !s.primaryPage && s.lang === ""), [N]), m = z(() => (T == null ? void 0 : T.globalJsonLds) || [], [T]), D = z(() => c ? Je(c, (r) => r.primaryPage === null && r.lang === "").map((r) => {
318
- const h = o ? Oe(c, (S) => S.primaryPage === r.id && S.lang === o) : null;
318
+ const h = o ? Fe(c, (S) => S.primaryPage === r.id && S.lang === o) : null;
319
319
  return {
320
320
  defaultSchema: r,
321
321
  languageVersion: h,
@@ -323,15 +323,15 @@ function Xe() {
323
323
  displayItem: h || r,
324
324
  hasLanguageVersion: !!h
325
325
  };
326
- }) : [], [c, o]), [b, L] = g([]), k = b.length > 0 ? b : (t == null ? void 0 : t.globalJsonLds) || [];
326
+ }) : [], [c, o]), [b, E] = g([]), k = b.length > 0 ? b : (t == null ? void 0 : t.globalJsonLds) || [];
327
327
  Z(() => {
328
- t != null && t.globalJsonLds && L(t.globalJsonLds);
328
+ t != null && t.globalJsonLds && E(t.globalJsonLds);
329
329
  }, [t == null ? void 0 : t.globalJsonLds]);
330
330
  const ie = async (s) => {
331
331
  if (!(t != null && t.id)) return;
332
332
  p(s);
333
333
  const r = k.includes(s), h = r ? k.filter((S) => S !== s) : [...k, s];
334
- L(h);
334
+ E(h);
335
335
  try {
336
336
  await I({
337
337
  schemaId: s,
@@ -339,7 +339,7 @@ function Xe() {
339
339
  enabled: !r
340
340
  });
341
341
  } catch {
342
- L(t.globalJsonLds);
342
+ E(t.globalJsonLds);
343
343
  } finally {
344
344
  p(null);
345
345
  }
@@ -357,7 +357,7 @@ function Xe() {
357
357
  /* @__PURE__ */ e("div", { className: "text-xs font-medium", children: "Shared JSON-LD Templates" }),
358
358
  /* @__PURE__ */ e("div", { className: "w-full text-xs text-gray-500", children: "Manage reusable JSON-LD schemas that can be applied across multiple pages" })
359
359
  ] }),
360
- !o && /* @__PURE__ */ n(E, { delayDuration: 0, children: [
360
+ !o && /* @__PURE__ */ n(L, { delayDuration: 0, children: [
361
361
  /* @__PURE__ */ e(
362
362
  J,
363
363
  {
@@ -367,10 +367,10 @@ function Xe() {
367
367
  onClick: (s) => {
368
368
  s.stopPropagation(), i(!0);
369
369
  },
370
- children: w ? /* @__PURE__ */ e(F, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(ke, { className: "h-4 w-4" })
370
+ children: w ? /* @__PURE__ */ e(O, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(ke, { className: "h-4 w-4" })
371
371
  }
372
372
  ),
373
- /* @__PURE__ */ e(O, { children: "Add new schema" })
373
+ /* @__PURE__ */ e(F, { children: "Add new schema" })
374
374
  ] })
375
375
  ] }),
376
376
  /* @__PURE__ */ n(Ce, { className: "max-h-96 overflow-y-auto", children: [
@@ -384,10 +384,10 @@ function Xe() {
384
384
  {
385
385
  className: `relative border-gray-300 p-0 shadow-none transition-all ${C === r.id ? "pointer-events-none" : ""}`,
386
386
  children: [
387
- C === r.id && /* @__PURE__ */ e("div", { className: "absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80", children: /* @__PURE__ */ e(F, { className: "h-5 w-5 animate-spin text-primary" }) }),
387
+ C === r.id && /* @__PURE__ */ e("div", { className: "absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80", children: /* @__PURE__ */ e(O, { className: "h-5 w-5 animate-spin text-primary" }) }),
388
388
  /* @__PURE__ */ e(Pe, { className: "p-2", children: /* @__PURE__ */ n("div", { className: "flex items-center justify-between", children: [
389
389
  /* @__PURE__ */ n("div", { className: "flex items-center gap-3", children: [
390
- (h || !o) && /* @__PURE__ */ n(E, { delayDuration: 0, children: [
390
+ (h || !o) && /* @__PURE__ */ n(L, { delayDuration: 0, children: [
391
391
  /* @__PURE__ */ e(J, { asChild: !0, children: /* @__PURE__ */ e(
392
392
  "input",
393
393
  {
@@ -398,7 +398,7 @@ function Xe() {
398
398
  className: "h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"
399
399
  }
400
400
  ) }),
401
- h && o && /* @__PURE__ */ e(O, { children: "Using the default language state" })
401
+ h && o && /* @__PURE__ */ e(F, { children: "Using the default language state" })
402
402
  ] }),
403
403
  /* @__PURE__ */ n("div", { children: [
404
404
  /* @__PURE__ */ n(Te, { className: "flex items-center gap-2 text-sm leading-none", children: [
@@ -415,7 +415,7 @@ function Xe() {
415
415
  ] }),
416
416
  /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
417
417
  /* @__PURE__ */ e("div", { className: "mx-2 h-6 w-px bg-border" }),
418
- /* @__PURE__ */ n(E, { delayDuration: 0, children: [
418
+ /* @__PURE__ */ n(L, { delayDuration: 0, children: [
419
419
  /* @__PURE__ */ e(J, { asChild: !0, children: /* @__PURE__ */ e(
420
420
  v,
421
421
  {
@@ -424,13 +424,13 @@ function Xe() {
424
424
  size: "icon",
425
425
  className: "h-5 w-5 p-0",
426
426
  onClick: () => u(r.id),
427
- children: /* @__PURE__ */ e(je, { className: "h-4 w-4" })
427
+ children: /* @__PURE__ */ e(Ge, { className: "h-4 w-4" })
428
428
  }
429
429
  ) }),
430
- /* @__PURE__ */ e(O, { children: "View schema" })
430
+ /* @__PURE__ */ e(F, { children: "View schema" })
431
431
  ] }),
432
- (h || !o) && /* @__PURE__ */ n(j, { children: [
433
- /* @__PURE__ */ n(E, { delayDuration: 0, children: [
432
+ (h || !o) && /* @__PURE__ */ n(G, { children: [
433
+ /* @__PURE__ */ n(L, { delayDuration: 0, children: [
434
434
  /* @__PURE__ */ e(J, { asChild: !0, children: /* @__PURE__ */ e(
435
435
  v,
436
436
  {
@@ -439,15 +439,15 @@ function Xe() {
439
439
  size: "icon",
440
440
  className: "h-5 w-5 p-0",
441
441
  onClick: () => x(r.id),
442
- children: /* @__PURE__ */ e(Ge, { className: "h-4 w-4" })
442
+ children: /* @__PURE__ */ e(je, { className: "h-4 w-4" })
443
443
  }
444
444
  ) }),
445
- /* @__PURE__ */ e(O, { children: "Edit schema" })
445
+ /* @__PURE__ */ e(F, { children: "Edit schema" })
446
446
  ] }),
447
447
  /* @__PURE__ */ n(_, { children: [
448
- /* @__PURE__ */ n(E, { delayDuration: 0, children: [
448
+ /* @__PURE__ */ n(L, { delayDuration: 0, children: [
449
449
  /* @__PURE__ */ e(J, { asChild: !0, children: /* @__PURE__ */ e(De, { className: "flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800", children: /* @__PURE__ */ e(Be, { className: "h-4 w-4" }) }) }),
450
- /* @__PURE__ */ e(O, { children: "Delete schema" })
450
+ /* @__PURE__ */ e(F, { children: "Delete schema" })
451
451
  ] }),
452
452
  /* @__PURE__ */ n(R, { children: [
453
453
  /* @__PURE__ */ n(q, { children: [
@@ -476,7 +476,7 @@ function Xe() {
476
476
  ] })
477
477
  ] })
478
478
  ] }) }),
479
- !h && o && /* @__PURE__ */ e(Le, { className: "px-2 pb-2", children: /* @__PURE__ */ n("div", { className: "flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3", children: [
479
+ !h && o && /* @__PURE__ */ e(Ee, { className: "px-2 pb-2", children: /* @__PURE__ */ n("div", { className: "flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3", children: [
480
480
  /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
481
481
  /* @__PURE__ */ n("div", { className: "max-w-xl text-center text-xs text-gray-500", children: [
482
482
  "Not available in '",
@@ -511,7 +511,7 @@ function Xe() {
511
511
  );
512
512
  })
513
513
  ] }),
514
- w && /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ e(F, { className: "h-5 w-5 animate-spin" }) })
514
+ w && /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ e(O, { className: "h-5 w-5 animate-spin" }) })
515
515
  ] }),
516
516
  /* @__PURE__ */ e(
517
517
  Ie,
@@ -550,7 +550,7 @@ const Re = ({ schema: l, onClose: i }) => /* @__PURE__ */ e($, { open: !!l, onOp
550
550
  /* @__PURE__ */ n("div", { children: [
551
551
  /* @__PURE__ */ e("div", { className: "mb-2 text-xs font-medium text-muted-foreground", children: "JSON-LD Schema" }),
552
552
  /* @__PURE__ */ e(
553
- Ee,
553
+ Le,
554
554
  {
555
555
  value: JSON.stringify(l == null ? void 0 : l.jsonld, null, 2),
556
556
  readOnly: !0,
@@ -1 +1 @@
1
- "use strict";const s=require("react/jsx-runtime"),u=require("./index-Bz7smSC0.cjs"),b=require("@chaibuilder/sdk/ui"),d=require("react"),j=e=>{if(!e)return{base:e,extension:null};const n=e.lastIndexOf(".");if(n<=0)return{base:e,extension:null};const t=e.substring(n);return{base:e.substring(0,n),extension:t}},x=e=>{if(!e)return e;const{base:n}=j(e);return n};function E(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const i=t.pop()||"";if(u.LANGUAGES[i])a=!0;else{r=i;const l=t.pop()||"";a=!!u.LANGUAGES[l]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const i=t.pop()||"";a=!!u.LANGUAGES[i]}return{initSlug:r,prefix:a}}const v=e=>e&&x(e),C=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function A({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:i=!1,fullSlug:l}){const[g,p]=d.useState(e),[o,f]=d.useState(null);d.useEffect(()=>{p(e)},[e]);const h=S=>{const c=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(c.match(/\./g)||[]).length,N=m<=1;m>1?f("Invalid slug. Only one dot (.) is allowed in the slug"):f(null),a&&a(N),p(c),n(c)};return s.jsxs("div",{children:[r&&s.jsx("div",{className:"mb-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Parent: ",s.jsx("span",{className:"font-mono text-gray-900",children:v(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(b.Input,{disabled:i,value:g,onChange:h,placeholder:t,className:o?"border-red-500":""}),o&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:o})]}),l&&l!=="undefined"&&s.jsx("div",{className:"mt-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Complete Slug: ",s.jsx("span",{className:"font-mono text-gray-900",children:l})]})})]})}exports.SlugInput=A;exports.combineParentChildSlugs=C;exports.parseSlugForEdit=E;exports.removeSlugExtension=x;
1
+ "use strict";const s=require("react/jsx-runtime"),u=require("./index-BeWL6Sj6.cjs"),b=require("@chaibuilder/sdk/ui"),d=require("react"),j=e=>{if(!e)return{base:e,extension:null};const n=e.lastIndexOf(".");if(n<=0)return{base:e,extension:null};const t=e.substring(n);return{base:e.substring(0,n),extension:t}},x=e=>{if(!e)return e;const{base:n}=j(e);return n};function E(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const i=t.pop()||"";if(u.LANGUAGES[i])a=!0;else{r=i;const l=t.pop()||"";a=!!u.LANGUAGES[l]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const i=t.pop()||"";a=!!u.LANGUAGES[i]}return{initSlug:r,prefix:a}}const v=e=>e&&x(e),C=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function A({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:i=!1,fullSlug:l}){const[g,p]=d.useState(e),[o,f]=d.useState(null);d.useEffect(()=>{p(e)},[e]);const h=S=>{const c=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(c.match(/\./g)||[]).length,N=m<=1;m>1?f("Invalid slug. Only one dot (.) is allowed in the slug"):f(null),a&&a(N),p(c),n(c)};return s.jsxs("div",{children:[r&&s.jsx("div",{className:"mb-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Parent: ",s.jsx("span",{className:"font-mono text-gray-900",children:v(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(b.Input,{disabled:i,value:g,onChange:h,placeholder:t,className:o?"border-red-500":""}),o&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:o})]}),l&&l!=="undefined"&&s.jsx("div",{className:"mt-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Complete Slug: ",s.jsx("span",{className:"font-mono text-gray-900",children:l})]})})]})}exports.SlugInput=A;exports.combineParentChildSlugs=C;exports.parseSlugForEdit=E;exports.removeSlugExtension=x;
@@ -1,5 +1,5 @@
1
1
  import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
- import { L as d } from "./index-EnM7J19_.js";
2
+ import { L as d } from "./index-DI2Rwk5v.js";
3
3
  import { Input as v } from "@chaibuilder/sdk/ui";
4
4
  import { useState as x, useEffect as C } from "react";
5
5
  const y = (e) => {
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-BeWL6Sj6.cjs"),m=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),l=require("lucide-react"),j=require("react"),p=()=>{const i=t.useSendRealtimeEvent(),{pageLockMeta:r}=t.usePageLockMeta(),{setPageStatus:d}=t.usePageLockStatus(),{savePageAsync:x}=m.useSavePage(),h=r==null?void 0:r.requestingUserId,{data:s,isFetching:g}=t.useChaiUserInfo(h||""),o=g?"Fetching user...":(s==null?void 0:s.name)||"Current editor",[u,c]=j.useState(!1),N=async()=>{c(!0),await x(),i(t.EVENT.CONTINUE_EDITING_IN_THIS_CLIENT,r),d(t.PAGE_STATUS.CHECKING),setTimeout(()=>c(!1),2e3)},f=()=>{c(!0),i(t.EVENT.TAKE_OVER_REJECTED,r),d(t.PAGE_STATUS.EDITING),setTimeout(()=>c(!1),2e3)},{t:n}=m.useTranslation();return e.jsx(t.BlurContainer,{children:e.jsxs(a.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(a.CardHeader,{className:"space-y-1",children:e.jsxs(a.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(l.AlertCircle,{className:"h-8 w-8 rounded-md bg-amber-500/20 p-1.5 text-amber-500"}),n("Take Over Requested")]})}),e.jsxs(a.CardContent,{className:"space-y-4",children:[e.jsxs("div",{className:"relative rounded-md border border-green-500 px-2 pb-2 pt-4",children:[e.jsx("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:"Requested by"}),e.jsxs("div",{className:"flex items-center space-x-4 p-1",children:[s!=null&&s.avatar?e.jsx("img",{src:s.avatar,alt:s.name,className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}):e.jsx(l.UserIcon,{className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}),e.jsxs("div",{className:"flex-1 space-y-0",children:[e.jsx("div",{className:"truncate font-medium leading-tight text-black",children:o}),(s==null?void 0:s.email)&&e.jsx("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:s.email})]})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-gray-700",children:o})," ",n("has requested to")," ",e.jsx("span",{className:"font-medium text-gray-500",children:"take over"})," ",n("editing this page."),"."," ",n("Do you want to allow them to continue?")]})]}),e.jsxs(a.CardFooter,{className:"flex gap-2",children:[e.jsxs(a.Button,{disabled:u,variant:"default",onClick:N,className:"flex-1 gap-2",children:[e.jsx(l.Check,{className:"h-4 w-4"}),n("Accept")]}),e.jsxs(a.Button,{disabled:u,variant:"outline",onClick:f,className:"flex-1 gap-2",children:[e.jsx(l.X,{className:"h-4 w-4"}),n("Reject")]})]})]})})};exports.default=p;