@chaibuilder/pages 0.16.13 → 0.16.14

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 (83) hide show
  1. package/dist/{2AITGKQY-D1mM4eEh.js → 2AITGKQY-B7xwscsX.js} +2 -2
  2. package/dist/{2AITGKQY-AK2WgbeT.cjs → 2AITGKQY-B9AnRLq_.cjs} +1 -1
  3. package/dist/{NCMVHL6D-BeRsWdGV.js → NCMVHL6D-B1mwht0Q.js} +4 -4
  4. package/dist/{NCMVHL6D-DItDf9IY.cjs → NCMVHL6D-CRMC-wXy.cjs} +1 -1
  5. package/dist/{ZDWCUMSJ-COSBY-at.cjs → ZDWCUMSJ-BqqPEOij.cjs} +1 -1
  6. package/dist/{ZDWCUMSJ-D6caRaY7.js → ZDWCUMSJ-CxKNtXtp.js} +1 -1
  7. package/dist/{add-new-language-page-CQcFi0Tp.cjs → add-new-language-page-D2a6GK-7.cjs} +1 -1
  8. package/dist/{add-new-language-page-nnaUe-qk.js → add-new-language-page-DD0qvJJs.js} +2 -2
  9. package/dist/{add-new-page-DxObnvo_.cjs → add-new-page-01GDCaa4.cjs} +1 -1
  10. package/dist/{add-new-page-Ba1fq6LH.js → add-new-page-CYtuChN1.js} +1 -1
  11. package/dist/ai-panel-content-DfdnvlS8.js +123 -0
  12. package/dist/ai-panel-content-Ouz6pu_0.cjs +1 -0
  13. package/dist/ai-panel-default-lang-Bi2fH1so.js +317 -0
  14. package/dist/ai-panel-default-lang-N1pb8rzQ.cjs +3 -0
  15. package/dist/{ai-panel-other-lang-B4euTuod.js → ai-panel-other-lang-2JPRSyO1.js} +10 -9
  16. package/dist/ai-panel-other-lang-BysU1464.cjs +1 -0
  17. package/dist/ai-prompt-input-DadL_cng.js +1071 -0
  18. package/dist/ai-prompt-input-JeIqWZco.cjs +1 -0
  19. package/dist/{ai-translation-prompt-CVuPbgXw.js → ai-translation-prompt-B0si-R0R.js} +1 -1
  20. package/dist/{ai-translation-prompt-Ip7w2_Ey.cjs → ai-translation-prompt-CQb1L7NM.cjs} +1 -1
  21. package/dist/{delete-page-CbY8q5M3.cjs → delete-page-C8Nt7IYF.cjs} +1 -1
  22. package/dist/{delete-page-SX9X35nA.js → delete-page-_96Di9yN.js} +1 -1
  23. package/dist/{digital-asset-manager-CIMo79Di.cjs → digital-asset-manager-B5FQGtGY.cjs} +1 -1
  24. package/dist/{digital-asset-manager-SAFNO_mx.js → digital-asset-manager-jfnmWRJj.js} +1 -1
  25. package/dist/{duplicate-page-CXK2HcxD.cjs → duplicate-page-BNjfZ7Wd.cjs} +1 -1
  26. package/dist/{duplicate-page-5SwLvmkX.js → duplicate-page-CERjaPIW.js} +9 -9
  27. package/dist/{dynamic-page-selector-Crd3y4Hk.cjs → dynamic-page-selector-Bpz_bvRu.cjs} +1 -1
  28. package/dist/{dynamic-page-selector-DfcuTqRN.js → dynamic-page-selector-XEWV4iCf.js} +1 -1
  29. package/dist/{index-Bz7smSC0.cjs → index-Pdb5tSRL.cjs} +2 -2
  30. package/dist/{index-EnM7J19_.js → index-e9WlBH0R.js} +70 -70
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.js +4 -4
  33. package/dist/{json-diff-viewer-CDwpbuag.js → json-diff-viewer-DyvKomxd.js} +1 -1
  34. package/dist/{json-diff-viewer-D34kDA_c.cjs → json-diff-viewer-H-2DkGza.cjs} +1 -1
  35. package/dist/{lang-panel-CUIeO5bb.js → lang-panel-BWP5A-FD.js} +2 -2
  36. package/dist/{lang-panel-CaFrYllL.cjs → lang-panel-DcZ7u4em.cjs} +1 -1
  37. package/dist/{mark-as-template-D0dLQaIB.js → mark-as-template-1oVraE1x.js} +1 -1
  38. package/dist/{mark-as-template-v182tmN6.cjs → mark-as-template-B_FyVRRO.cjs} +1 -1
  39. package/dist/{no-language-page-content-ByRFD_qA.js → no-language-page-content-CEci_4j7.js} +1 -1
  40. package/dist/{no-language-page-content-Bk4fEx_p.cjs → no-language-page-content-JO4YYUx7.cjs} +1 -1
  41. package/dist/{page-creator-BnvaGZVI.cjs → page-creator-BGgoOA92.cjs} +1 -1
  42. package/dist/{page-creator-Bh0IUGR3.js → page-creator-DJJFl7px.js} +2 -2
  43. package/dist/{page-lock-request-C2b1kqyA.cjs → page-lock-request-BoYzkcyt.cjs} +1 -1
  44. package/dist/{page-lock-request-CaNqxfD6.js → page-lock-request-WzpcD2ZN.js} +6 -6
  45. package/dist/{page-locked-by-dialog--WLDdkw9.js → page-locked-by-dialog-Djvjp2Hx.js} +1 -1
  46. package/dist/{page-locked-by-dialog-90ElC8aG.cjs → page-locked-by-dialog-bvI27OZ6.cjs} +1 -1
  47. package/dist/{page-manager-new-SNRQn7Az.cjs → page-manager-new-CMfGorRQ.cjs} +1 -1
  48. package/dist/{page-manager-new-Bo4-zwfW.js → page-manager-new-DmVX0qLk.js} +14 -14
  49. package/dist/{page-manager-search-and-filter-BETHSa3y.js → page-manager-search-and-filter-DbUoW8Di.js} +1 -1
  50. package/dist/{page-manager-search-and-filter-hyUIHOD_.cjs → page-manager-search-and-filter-Dgh8iyGp.cjs} +1 -1
  51. package/dist/{page-revisions-content-BCMjvZRZ.cjs → page-revisions-content-CwoXXE53.cjs} +1 -1
  52. package/dist/{page-revisions-content-VWthKL7O.js → page-revisions-content-CxEJGxLY.js} +18 -18
  53. package/dist/pages.css +1 -1
  54. package/dist/{publish-pages-content-CaBwfekc.cjs → publish-pages-content-BRu7qwAo.cjs} +1 -1
  55. package/dist/{publish-pages-content-6N7aEcM1.js → publish-pages-content-CfAlmivf.js} +6 -6
  56. package/dist/{save-to-lib-YYBxY7MV.js → save-to-lib-BCaBfh0I.js} +1 -1
  57. package/dist/{save-to-lib-CtGpDkC6.cjs → save-to-lib-DpyJA0y1.cjs} +1 -1
  58. package/dist/{selected-block-display-DdW-DWF1.js → selected-block-display-BmNhvYKu.js} +1 -1
  59. package/dist/{selected-block-display-BEbuJn0l.cjs → selected-block-display-CqnwyGRp.cjs} +1 -1
  60. package/dist/{seo-panel-CqJDhbj-.js → seo-panel-BH8fcGqr.js} +1 -1
  61. package/dist/{seo-panel-B9P7fXjo.cjs → seo-panel-D-nKfsRJ.cjs} +1 -1
  62. package/dist/server.cjs +1 -1
  63. package/dist/server.js +39 -39
  64. package/dist/{shared-json-ld-CyxmC9y5.cjs → shared-json-ld-m_OsVv8h.cjs} +1 -1
  65. package/dist/{shared-json-ld-DxEPILj_.js → shared-json-ld-zTDoJzUv.js} +1 -1
  66. package/dist/{slug-input-j5z5ZQn9.js → slug-input-CumDDlCk.js} +1 -1
  67. package/dist/{slug-input-RNiSrU3p.cjs → slug-input-vzNtu37S.cjs} +1 -1
  68. package/dist/{theme-panel-footer-CCsiDIVl.cjs → theme-panel-footer-CKccBcd9.cjs} +1 -1
  69. package/dist/{theme-panel-footer-DD2yalfG.js → theme-panel-footer-CdUmjB-e.js} +1 -1
  70. package/dist/{unmark-as-template-B2hKhAHn.js → unmark-as-template-6ew-7bf8.js} +1 -1
  71. package/dist/{unmark-as-template-DXjLbqOM.cjs → unmark-as-template-BNFOsxIg.cjs} +1 -1
  72. package/dist/{unpublish-page-BdJScWMX.cjs → unpublish-page-BZQpTpU3.cjs} +1 -1
  73. package/dist/{unpublish-page-BvB1PGSz.js → unpublish-page-BomE76Wg.js} +1 -1
  74. package/dist/{web-preview-BI4jd0O7.cjs → web-preview-C5QTX7bS.cjs} +1 -1
  75. package/dist/{web-preview-CwVpkcwU.js → web-preview-jo8lnpEx.js} +1 -1
  76. package/package.json +1 -1
  77. package/dist/ai-panel-content-B2AgBWqo.cjs +0 -1
  78. package/dist/ai-panel-content-M1UnzG_f.js +0 -54
  79. package/dist/ai-panel-default-lang-CHOFEwmV.js +0 -313
  80. package/dist/ai-panel-default-lang-sy6vkQJh.cjs +0 -3
  81. package/dist/ai-panel-other-lang-BwjSDD3L.cjs +0 -1
  82. package/dist/ai-prompt-input-B_NRADBT.js +0 -988
  83. package/dist/ai-prompt-input-DcyVXcLG.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-Pdb5tSRL.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,7 +1,7 @@
1
1
  import { jsx as e, jsxs as n, Fragment as j } 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";
4
+ import { ak as ge, al 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-e9WlBH0R.js";
5
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
6
  import { filter as Je, find as Oe } from "lodash-es";
7
7
  import { Info as Fe, Loader as F, Plus as ke, Eye as je, Edit as Ge, Trash as Be } from "lucide-react";
@@ -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-e9WlBH0R.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) => {
@@ -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-Pdb5tSRL.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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-Bz7smSC0.cjs"),o=require("@chaibuilder/sdk"),r=require("@chaibuilder/sdk/ui"),h=()=>{const[t]=o.useTheme(),{mutate:c,isPending:i}=s.usePublishPages(),{mutateAsync:n,isPending:u}=s.useUpdateWebsiteSettings(),{t:a}=o.useTranslation(),l=()=>{n({settings:{theme:t}})},d=async()=>{await n({settings:{theme:t}}),c({ids:["THEME"]},{onSuccess:()=>{s.throwConfetti("BOTTOM_RIGHT")}})};return e.jsxs("div",{className:"flex items-center justify-center gap-x-3 border-t bg-white py-3",children:[e.jsx(r.Button,{size:"sm",variant:"outline",disabled:i||u,onClick:l,children:a("Save draft")}),e.jsx(r.Button,{size:"sm",disabled:i||u,onClick:d,children:a("Publish")})]})};exports.default=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-Pdb5tSRL.cjs"),o=require("@chaibuilder/sdk"),r=require("@chaibuilder/sdk/ui"),h=()=>{const[t]=o.useTheme(),{mutate:c,isPending:i}=s.usePublishPages(),{mutateAsync:n,isPending:u}=s.useUpdateWebsiteSettings(),{t:a}=o.useTranslation(),l=()=>{n({settings:{theme:t}})},d=async()=>{await n({settings:{theme:t}}),c({ids:["THEME"]},{onSuccess:()=>{s.throwConfetti("BOTTOM_RIGHT")}})};return e.jsxs("div",{className:"flex items-center justify-center gap-x-3 border-t bg-white py-3",children:[e.jsx(r.Button,{size:"sm",variant:"outline",disabled:i||u,onClick:l,children:a("Save draft")}),e.jsx(r.Button,{size:"sm",disabled:i||u,onClick:d,children:a("Publish")})]})};exports.default=h;
@@ -1,5 +1,5 @@
1
1
  import { jsxs as c, jsx as a } from "react/jsx-runtime";
2
- import { u, a as d, t as h } from "./index-EnM7J19_.js";
2
+ import { u, a as d, t as h } from "./index-e9WlBH0R.js";
3
3
  import { useTheme as b, useTranslation as g } from "@chaibuilder/sdk";
4
4
  import { Button as o } from "@chaibuilder/sdk/ui";
5
5
  const x = () => {
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as o } from "react/jsx-runtime";
2
- import { o as p } from "./index-EnM7J19_.js";
2
+ import { o as p } from "./index-e9WlBH0R.js";
3
3
  import { useTranslation as u } from "@chaibuilder/sdk";
4
4
  import { Dialog as d, DialogContent as g, DialogHeader as h, DialogTitle as f, DialogDescription as k, DialogFooter as D, Button as s } from "@chaibuilder/sdk/ui";
5
5
  import { useState as x } from "react";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-Bz7smSC0.cjs"),d=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),m=require("react"),p=({page:i,onClose:n})=>{const{t:a}=d.useTranslation(),[r,s]=m.useState(!1),o=u.useUnmarkAsTemplate(),l=()=>{s(!0),o.mutate(i,{onSuccess:()=>{s(!1),n()},onError:()=>{s(!1)}})};return e.jsx(t.Dialog,{open:!0,onOpenChange:n,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:a("Unmark as template")}),e.jsx(t.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:a("Are you sure you want to unmark this page as a template?")})]}),e.jsxs(t.DialogFooter,{className:r?"pointer-events-none opacity-75":"",children:[e.jsx(t.Button,{variant:"outline",onClick:c=>{c.stopPropagation(),n()},children:a("Cancel")}),e.jsx(t.Button,{variant:"default",disabled:r,onClick:l,children:a("Unmark as template")})]})]})})};exports.default=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-Pdb5tSRL.cjs"),d=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),m=require("react"),p=({page:i,onClose:n})=>{const{t:a}=d.useTranslation(),[r,s]=m.useState(!1),o=u.useUnmarkAsTemplate(),l=()=>{s(!0),o.mutate(i,{onSuccess:()=>{s(!1),n()},onError:()=>{s(!1)}})};return e.jsx(t.Dialog,{open:!0,onOpenChange:n,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:a("Unmark as template")}),e.jsx(t.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:a("Are you sure you want to unmark this page as a template?")})]}),e.jsxs(t.DialogFooter,{className:r?"pointer-events-none opacity-75":"",children:[e.jsx(t.Button,{variant:"outline",onClick:c=>{c.stopPropagation(),n()},children:a("Cancel")}),e.jsx(t.Button,{variant:"default",disabled:r,onClick:l,children:a("Unmark as template")})]})]})})};exports.default=p;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),u=require("./index-Bz7smSC0.cjs"),c=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),d=({page:i,onClose:t})=>{const{t:e}=c.useTranslation(),{mutate:r,isPending:l}=u.useUnpublishPage(),o=async()=>{r(i,{onSuccess:t})};return n.jsx(s.Dialog,{open:!!i,onOpenChange:t,children:n.jsxs(s.DialogContent,{children:[n.jsxs(s.DialogHeader,{children:[n.jsx(s.DialogTitle,{children:e("Confirm action")}),n.jsxs(s.DialogDescription,{children:[e("Are you sure you want to unpublish")," ",n.jsx("b",{children:(i==null?void 0:i.name)??(i==null?void 0:i.slug)}),"?"]})]}),n.jsxs(s.DialogFooter,{children:[n.jsx(s.Button,{variant:"outline",onClick:t,children:e("Cancel")}),n.jsx(s.Button,{variant:"destructive",disabled:l,onClick:o,children:e(l?"Updating...":"Unpublish")})]})]})})};exports.default=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),u=require("./index-Pdb5tSRL.cjs"),c=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),d=({page:i,onClose:t})=>{const{t:e}=c.useTranslation(),{mutate:r,isPending:l}=u.useUnpublishPage(),o=async()=>{r(i,{onSuccess:t})};return n.jsx(s.Dialog,{open:!!i,onOpenChange:t,children:n.jsxs(s.DialogContent,{children:[n.jsxs(s.DialogHeader,{children:[n.jsx(s.DialogTitle,{children:e("Confirm action")}),n.jsxs(s.DialogDescription,{children:[e("Are you sure you want to unpublish")," ",n.jsx("b",{children:(i==null?void 0:i.name)??(i==null?void 0:i.slug)}),"?"]})]}),n.jsxs(s.DialogFooter,{children:[n.jsx(s.Button,{variant:"outline",onClick:t,children:e("Cancel")}),n.jsx(s.Button,{variant:"destructive",disabled:l,onClick:o,children:e(l?"Updating...":"Unpublish")})]})]})})};exports.default=d;
@@ -1,5 +1,5 @@
1
1
  import { jsx as o, jsxs as l } from "react/jsx-runtime";
2
- import { l as u } from "./index-EnM7J19_.js";
2
+ import { l as u } from "./index-e9WlBH0R.js";
3
3
  import { useTranslation as a } from "@chaibuilder/sdk";
4
4
  import { Dialog as h, DialogContent as d, DialogHeader as m, DialogTitle as b, DialogDescription as D, DialogFooter as f, Button as s } from "@chaibuilder/sdk/ui";
5
5
  const g = ({ page: n, onClose: t }) => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),a=require("@chaibuilder/sdk/ui"),h=require("jotai"),x=require("lodash-es"),n=require("lucide-react"),c=require("./index-Bz7smSC0.cjs"),m=[{title:"mobile_xs_title",content:"mobile_xs_content",icon:e.jsx(n.Smartphone,{className:"h-4 w-4"}),width:400},{title:"tablet_md_title",content:"tablet_md_content",icon:e.jsx(n.Tablet,{className:"h-4 w-4"}),width:800},{title:"desktop_xl_title",content:"desktop_xl_content",icon:e.jsx(n.Laptop,{className:"h-4 w-4"}),width:1200},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",icon:e.jsx(n.LaptopMinimal,{className:"h-4 w-4"}),width:1600}],w=({currentWidth:t,width:s,icon:l,setIframeWidth:i})=>e.jsx(a.Button,{className:"px-3 py-3",onClick:()=>i(s),variant:s===t?"default":"ghost",children:l}),p=()=>{const[t,s]=o.useState(1200),l=r=>s(r),[i,d]=h.useAtom(c.previewUrlAtom);if(!i)return null;const u=()=>{d("")};return e.jsxs("div",{className:"absolute inset-0 z-[999999] flex h-screen w-screen flex-col overflow-hidden bg-gray-100",children:[e.jsxs("div",{className:"flex h-[50px] items-center justify-center border-b border-gray-200 px-4 shadow-sm",children:[e.jsx("div",{className:"flex items-center justify-center rounded-md border border-gray-300",children:x.map(m,r=>o.createElement(w,{...r,setIframeWidth:l,key:r.title,currentWidth:t}))})," ",e.jsx(c.Tooltip,{content:"Exit Preview",delayDuration:0,children:e.jsx(a.Button,{variant:"destructive",size:"sm",onClick:u,children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M2 3C2 2.44772 2.44772 2 3 2H12C12.5523 2 13 2.44772 13 3V12C13 12.5523 12.5523 13 12 13H3C2.44772 13 2 12.5523 2 12V3ZM12 3H3V12H12V3Z",fill:"currentColor",fillRule:"evenodd","clip-rule":"evenodd"})})})})]}),e.jsx("iframe",{style:{width:`${t}px`,transition:"width 0.3s ease-in-out"},className:"no-scrollbar mx-auto h-full overflow-y-auto border bg-white",src:i})]})};exports.default=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),a=require("@chaibuilder/sdk/ui"),h=require("jotai"),x=require("lodash-es"),n=require("lucide-react"),c=require("./index-Pdb5tSRL.cjs"),m=[{title:"mobile_xs_title",content:"mobile_xs_content",icon:e.jsx(n.Smartphone,{className:"h-4 w-4"}),width:400},{title:"tablet_md_title",content:"tablet_md_content",icon:e.jsx(n.Tablet,{className:"h-4 w-4"}),width:800},{title:"desktop_xl_title",content:"desktop_xl_content",icon:e.jsx(n.Laptop,{className:"h-4 w-4"}),width:1200},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",icon:e.jsx(n.LaptopMinimal,{className:"h-4 w-4"}),width:1600}],w=({currentWidth:t,width:s,icon:l,setIframeWidth:i})=>e.jsx(a.Button,{className:"px-3 py-3",onClick:()=>i(s),variant:s===t?"default":"ghost",children:l}),p=()=>{const[t,s]=o.useState(1200),l=r=>s(r),[i,d]=h.useAtom(c.previewUrlAtom);if(!i)return null;const u=()=>{d("")};return e.jsxs("div",{className:"absolute inset-0 z-[999999] flex h-screen w-screen flex-col overflow-hidden bg-gray-100",children:[e.jsxs("div",{className:"flex h-[50px] items-center justify-center border-b border-gray-200 px-4 shadow-sm",children:[e.jsx("div",{className:"flex items-center justify-center rounded-md border border-gray-300",children:x.map(m,r=>o.createElement(w,{...r,setIframeWidth:l,key:r.title,currentWidth:t}))})," ",e.jsx(c.Tooltip,{content:"Exit Preview",delayDuration:0,children:e.jsx(a.Button,{variant:"destructive",size:"sm",onClick:u,children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M2 3C2 2.44772 2.44772 2 3 2H12C12.5523 2 13 2.44772 13 3V12C13 12.5523 12.5523 13 12 13H3C2.44772 13 2 12.5523 2 12V3ZM12 3H3V12H12V3Z",fill:"currentColor",fillRule:"evenodd","clip-rule":"evenodd"})})})})]}),e.jsx("iframe",{style:{width:`${t}px`,transition:"width 0.3s ease-in-out"},className:"no-scrollbar mx-auto h-full overflow-y-auto border bg-white",src:i})]})};exports.default=p;
@@ -4,7 +4,7 @@ import { Button as s } from "@chaibuilder/sdk/ui";
4
4
  import { useAtom as h } from "jotai";
5
5
  import { map as p } from "lodash-es";
6
6
  import { Smartphone as w, Tablet as f, Laptop as u, LaptopMinimal as x } from "lucide-react";
7
- import { p as v, T as _ } from "./index-EnM7J19_.js";
7
+ import { p as v, T as _ } from "./index-e9WlBH0R.js";
8
8
  const b = [
9
9
  {
10
10
  title: "mobile_xs_title",
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Suraj Air",
4
4
  "license": "Private",
5
5
  "homepage": "https://chaibuilder.com",
6
- "version": "0.16.13",
6
+ "version": "0.16.14",
7
7
  "type": "module",
8
8
  "files": [
9
9
  "dist"
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("./index-Bz7smSC0.cjs"),S=require("@chaibuilder/sdk"),N=require("@chaibuilder/sdk/ui"),k=require("lucide-react"),n=require("react"),M=require("sonner"),A=n.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-default-lang-sy6vkQJh.cjs"))),R=n.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-other-lang-BwjSDD3L.cjs"))),z=()=>{const{t:r}=S.useTranslation(),[m,a]=n.useState(""),[t,l]=n.useState([]),[c,i]=n.useState(!1),[u,d]=n.useState(null),[b,f]=n.useState(null),[p,P]=n.useState("google/gemini-2.5-pro"),{selectedLang:g,fallbackLang:q}=S.useLanguages(),v=j.useBuilderFetch(),[w]=j.useSearchParams(),C=w.get("page"),L=(t==null?void 0:t.filter(s=>s.role==="user").length)>=4,y=(t==null?void 0:t.filter(s=>s.role==="user").length)>=10;n.useEffect(()=>{l([])},[g,C]);const h=()=>{l([]),a(""),f(null),d(null),i(!1)},x={t:r,fetch:v,input:m,messages:t,setInput:a,isLoading:c,handleStop:()=>{u&&(u.abort(),d(null)),i(!1),a(""),f(null),l(s=>{const o=s[s.length-1];return o&&o.role==="assistant"&&o.isReasoning&&o.isStreaming?s.slice(0,-1):s}),M.toast.info(r("Generation stopped"))},handleReset:h,setMessages:l,setIsLoading:i,currentBlock:b,fallbackLang:q,abortController:u,setCurrentBlock:f,setAbortController:d,forceNewConversation:y,suggestNewConversation:L,selectedModel:p,onModelChange:P};return e.jsxs(e.Fragment,{children:[c&&e.jsx("div",{className:"fixed inset-0 left-0 top-0 z-40 flex h-screen w-screen flex-col items-center justify-center bg-transparent"}),e.jsxs("div",{className:"flex h-full w-full flex-col bg-white",children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("p",{className:"text-xs text-gray-500",children:r("Your conversation will not be saved")}),(t==null?void 0:t.length)>0&&e.jsx(N.Button,{variant:"outline",size:"icon",onClick:h,className:"h-6 w-6",disabled:c,children:e.jsx(k.Plus,{})})]}),e.jsx(n.Suspense,{fallback:e.jsx("div",{children:"Loading AI Panel..."}),children:g?e.jsx(R,{...x,selectedLang:g}):e.jsx(A,{...x})})]})]})};exports.default=z;
@@ -1,54 +0,0 @@
1
- import { jsxs as m, Fragment as M, jsx as n } from "react/jsx-runtime";
2
- import { q as j, i as y } from "./index-EnM7J19_.js";
3
- import { useTranslation as B, useLanguages as F } from "@chaibuilder/sdk";
4
- import { Button as z } from "@chaibuilder/sdk/ui";
5
- import { Plus as I } from "lucide-react";
6
- import { lazy as x, useState as o, useEffect as R, Suspense as q } from "react";
7
- import { toast as D } from "sonner";
8
- const E = x(() => import("./ai-panel-default-lang-CHOFEwmV.js")), G = x(() => import("./ai-panel-other-lang-B4euTuod.js")), V = () => {
9
- const { t: r } = B(), [b, a] = o(""), [e, l] = o([]), [i, c] = o(!1), [u, f] = o(null), [w, d] = o(null), [C, L] = o("google/gemini-2.5-pro"), { selectedLang: g, fallbackLang: P } = F(), N = j(), [S] = y(), v = S.get("page"), k = (e == null ? void 0 : e.filter((t) => t.role === "user").length) >= 4, A = (e == null ? void 0 : e.filter((t) => t.role === "user").length) >= 10;
10
- R(() => {
11
- l([]);
12
- }, [g, v]);
13
- const h = () => {
14
- l([]), a(""), d(null), f(null), c(!1);
15
- }, p = {
16
- t: r,
17
- fetch: N,
18
- input: b,
19
- messages: e,
20
- setInput: a,
21
- isLoading: i,
22
- handleStop: () => {
23
- u && (u.abort(), f(null)), c(!1), a(""), d(null), l((t) => {
24
- const s = t[t.length - 1];
25
- return s && s.role === "assistant" && s.isReasoning && s.isStreaming ? t.slice(0, -1) : t;
26
- }), D.info(r("Generation stopped"));
27
- },
28
- handleReset: h,
29
- setMessages: l,
30
- setIsLoading: c,
31
- currentBlock: w,
32
- fallbackLang: P,
33
- abortController: u,
34
- setCurrentBlock: d,
35
- setAbortController: f,
36
- forceNewConversation: A,
37
- suggestNewConversation: k,
38
- selectedModel: C,
39
- onModelChange: L
40
- };
41
- return /* @__PURE__ */ m(M, { children: [
42
- i && /* @__PURE__ */ n("div", { className: "fixed inset-0 left-0 top-0 z-40 flex h-screen w-screen flex-col items-center justify-center bg-transparent" }),
43
- /* @__PURE__ */ m("div", { className: "flex h-full w-full flex-col bg-white", children: [
44
- /* @__PURE__ */ m("div", { className: "flex w-full items-center justify-between", children: [
45
- /* @__PURE__ */ n("p", { className: "text-xs text-gray-500", children: r("Your conversation will not be saved") }),
46
- (e == null ? void 0 : e.length) > 0 && /* @__PURE__ */ n(z, { variant: "outline", size: "icon", onClick: h, className: "h-6 w-6", disabled: i, children: /* @__PURE__ */ n(I, {}) })
47
- ] }),
48
- /* @__PURE__ */ n(q, { fallback: /* @__PURE__ */ n("div", { children: "Loading AI Panel..." }), children: g ? /* @__PURE__ */ n(G, { ...p, selectedLang: g }) : /* @__PURE__ */ n(E, { ...p }) })
49
- ] })
50
- ] });
51
- };
52
- export {
53
- V as default
54
- };