@chaibuilder/pages 0.14.4 → 0.15.1

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 (69) hide show
  1. package/dist/{2AITGKQY-DWDDkd18.cjs → 2AITGKQY-GcbF_G3s.cjs} +1 -1
  2. package/dist/{2AITGKQY-DtQPkxBe.js → 2AITGKQY-a-BJOrVj.js} +2 -2
  3. package/dist/{NCMVHL6D-CksZXXOw.js → NCMVHL6D-CCFQEIik.js} +4 -4
  4. package/dist/{NCMVHL6D-6CkVnw0a.cjs → NCMVHL6D-fz7uxKMS.cjs} +1 -1
  5. package/dist/{ZDWCUMSJ-BXQ01VPt.js → ZDWCUMSJ-B87y4E-s.js} +1 -1
  6. package/dist/{ZDWCUMSJ-DoM-AA0C.cjs → ZDWCUMSJ-D40Aht5l.cjs} +1 -1
  7. package/dist/{add-new-language-page-D8iXtyLA.js → add-new-language-page-CxNpkd0L.js} +2 -2
  8. package/dist/{add-new-language-page-BA73lQnm.cjs → add-new-language-page-Dyh26P7i.cjs} +1 -1
  9. package/dist/{add-new-page-DESlqvED.js → add-new-page-DGQqN1GO.js} +1 -1
  10. package/dist/{add-new-page-EOMgMSeq.cjs → add-new-page-jWn3_pZ4.cjs} +1 -1
  11. package/dist/{delete-page-ZvnuEow6.cjs → delete-page-Bxl1t_Ue.cjs} +1 -1
  12. package/dist/{delete-page-BP1Df8QL.js → delete-page-WnsCggnJ.js} +1 -1
  13. package/dist/{digital-asset-manager-Bb81T3mS.js → digital-asset-manager-ClyooOJY.js} +135 -135
  14. package/dist/{digital-asset-manager-BxWb1j_y.cjs → digital-asset-manager-DrXotZ_n.cjs} +1 -1
  15. package/dist/{duplicate-page-W5xbmPSC.cjs → duplicate-page-CDtfdgyJ.cjs} +1 -1
  16. package/dist/{duplicate-page-B1j0H7gP.js → duplicate-page-DOloolXy.js} +8 -8
  17. package/dist/{dynamic-page-selector-Crjyco6l.js → dynamic-page-selector-B-8TUdTG.js} +1 -1
  18. package/dist/{dynamic-page-selector-BZKJmSx5.cjs → dynamic-page-selector-CcYIfKlO.cjs} +1 -1
  19. package/dist/index-CffopOpP.cjs +5 -0
  20. package/dist/{index-DFvsMFVH.js → index-CguzNa4U.js} +1710 -1938
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.ts +10 -14
  23. package/dist/index.js +12 -13
  24. package/dist/{json-diff-viewer-BGGSLqtx.js → json-diff-viewer-CxFGgqa_.js} +6 -6
  25. package/dist/{json-diff-viewer-DRkE-x_z.cjs → json-diff-viewer-DcR1gbkd.cjs} +1 -1
  26. package/dist/{lang-panel-B3tr2uhr.js → lang-panel-Bi427DLp.js} +2 -2
  27. package/dist/{lang-panel-9T8dIx2p.cjs → lang-panel-XonHaLBn.cjs} +1 -1
  28. package/dist/{mark-as-template-DPVPRgbi.cjs → mark-as-template-BtI1QfuI.cjs} +1 -1
  29. package/dist/{mark-as-template-L9cHzL84.js → mark-as-template-CS68JVP8.js} +1 -1
  30. package/dist/{no-language-page-content-DP7gmy0s.js → no-language-page-content-C5t9cDI4.js} +1 -1
  31. package/dist/{no-language-page-content-Cy_D-3jE.cjs → no-language-page-content-DMqw1cTK.cjs} +1 -1
  32. package/dist/{page-creator-Ctn5ixJE.js → page-creator-BY2w99Ez.js} +2 -2
  33. package/dist/{page-creator-DDaI1HYj.cjs → page-creator-BkKT_Xy1.cjs} +1 -1
  34. package/dist/{page-lock-request-BKrxnEtQ.cjs → page-lock-request-CIRTswpw.cjs} +1 -1
  35. package/dist/{page-lock-request-CjJFJKL2.js → page-lock-request-Z1sTGi6N.js} +10 -10
  36. package/dist/{page-locked-by-dialog-DmsSmAY2.js → page-locked-by-dialog-B2C1M_bK.js} +1 -1
  37. package/dist/{page-locked-by-dialog-b25_rn2m.cjs → page-locked-by-dialog-DpBpQ0oI.cjs} +1 -1
  38. package/dist/{page-manager-new-EsIg6iQn.js → page-manager-new-CSqFLJBd.js} +46 -46
  39. package/dist/{page-manager-new-DiZVY7Me.cjs → page-manager-new-tWV46glN.cjs} +1 -1
  40. package/dist/{page-manager-search-and-filter-Bt4T_dnB.js → page-manager-search-and-filter-B9VZzJQd.js} +2 -2
  41. package/dist/{page-manager-search-and-filter-CgY2qiXU.cjs → page-manager-search-and-filter-CwuukvKn.cjs} +1 -1
  42. package/dist/{page-revisions-content-DtI8CmtR.cjs → page-revisions-content-BWhJz0_7.cjs} +1 -1
  43. package/dist/{page-revisions-content-CsT6aF2I.js → page-revisions-content-WoIu0uan.js} +18 -18
  44. package/dist/{publish-pages-content-DpC7RcTw.cjs → publish-pages-content-BHDTLdGv.cjs} +1 -1
  45. package/dist/{publish-pages-content-KAuhOPv0.js → publish-pages-content-CkWvQGbm.js} +12 -12
  46. package/dist/{save-to-lib-CeWaSQdB.js → save-to-lib-AkbnWUxR.js} +13 -13
  47. package/dist/{save-to-lib-BGpWGHJo.cjs → save-to-lib-C0ZfwiAE.cjs} +1 -1
  48. package/dist/{seo-panel-JDQ_7bOx.cjs → seo-panel-CiKkn5Jp.cjs} +1 -1
  49. package/dist/{seo-panel-Dhhpe_7z.js → seo-panel-Gu3HZveQ.js} +34 -34
  50. package/dist/shared-json-ld-BPaeG1gf.cjs +1 -0
  51. package/dist/shared-json-ld-CsyZjZdT.js +557 -0
  52. package/dist/{slug-input-QxBMijHP.cjs → slug-input-B4w0Ihxn.cjs} +1 -1
  53. package/dist/{slug-input-hJdU8DaF.js → slug-input-BXNj3cZf.js} +1 -1
  54. package/dist/{theme-panel-footer-D2B7iYW2.js → theme-panel-footer-68bQaQeh.js} +1 -1
  55. package/dist/{theme-panel-footer-BZnPvTkM.cjs → theme-panel-footer-DnZs9SzB.cjs} +1 -1
  56. package/dist/{unmark-as-template-Byn2RRAp.cjs → unmark-as-template-DFxmzyx4.cjs} +1 -1
  57. package/dist/{unmark-as-template-Dcpkj7EZ.js → unmark-as-template-MpXMyb0Q.js} +1 -1
  58. package/dist/{unpublish-page-CPLlsfm4.js → unpublish-page-Bzouoco9.js} +1 -1
  59. package/dist/{unpublish-page-5Fi1wKXb.cjs → unpublish-page-CCPyMoaC.cjs} +1 -1
  60. package/dist/use-page-expand-manager-2KjeYfVS.cjs +1 -0
  61. package/dist/use-page-expand-manager-D6T75I11.js +184 -0
  62. package/dist/{web-preview-CVvxe5Ll.cjs → web-preview-B3-o8BoT.cjs} +1 -1
  63. package/dist/{web-preview-YuuoRaZn.js → web-preview-D9PcexXy.js} +1 -1
  64. package/package.json +1 -1
  65. package/dist/index-Qnh8Lkr0.cjs +0 -5
  66. package/dist/shared-json-ld-BYbdMttx.cjs +0 -1
  67. package/dist/shared-json-ld-BliIbNv9.js +0 -337
  68. package/dist/use-page-expand-manager-DkyBiNpx.js +0 -85
  69. package/dist/use-page-expand-manager-To-SsGy3.cjs +0 -1
@@ -1,11 +1,11 @@
1
1
  import { jsxs as n, jsx as t, Fragment as H } from "react/jsx-runtime";
2
- import { LanguageSelector as z } from "./page-manager-search-and-filter-Bt4T_dnB.js";
3
- import { ak as R, al as _, A as L, ay as $, f as K, h as Q, aq as J, T as A, t as V } from "./index-DFvsMFVH.js";
2
+ import { LanguageSelector as z } from "./page-manager-search-and-filter-B9VZzJQd.js";
3
+ import { al as R, am as _, A as L, au as $, f as K, h as Q, aj as J, T as A, t as V } from "./index-CguzNa4U.js";
4
4
  import { useQuery as W } from "@tanstack/react-query";
5
5
  import { DialogContent as X, DialogHeader as Y, DialogTitle as Z, DialogDescription as ee, DialogFooter as te, Button as F } from "@chaibuilder/sdk/ui";
6
6
  import { find as G, filter as a, map as y, includes as P, orderBy as b, isEmpty as se, first as le, uniq as U, concat as ne } from "lodash-es";
7
7
  import { Lock as ae, GlobeIcon as re, File as ce, Edit as oe } from "lucide-react";
8
- import { useState as O, useCallback as ie, useMemo as g, useEffect as j } from "react";
8
+ import { useState as j, useCallback as ie, useMemo as g, useEffect as O } from "react";
9
9
  const de = () => {
10
10
  const s = R(), d = _();
11
11
  return W({
@@ -54,7 +54,7 @@ const de = () => {
54
54
  isPending: d,
55
55
  publishPage: N
56
56
  }) => {
57
- const [h] = $(), [o, u] = O([]), i = K(), [r, x] = O(i), { data: k, isFetching: C } = de(), { data: m } = Q(), w = ie((e) => {
57
+ const [h] = $(), [o, u] = j([]), i = K(), [r, x] = j(i), { data: k, isFetching: C } = de(), { data: m } = Q(), w = ie((e) => {
58
58
  var l;
59
59
  return (l = G(m, { key: e })) == null ? void 0 : l.hasSlug;
60
60
  }, [m]), f = g(
@@ -70,10 +70,10 @@ const de = () => {
70
70
  () => a(c, (e) => f.includes(e.pageType)),
71
71
  [c, f]
72
72
  );
73
- j(() => {
73
+ O(() => {
74
74
  const e = y(a(c, { online: !0 }), "id");
75
75
  u(e);
76
- }, [c]), j(() => {
76
+ }, [c]), O(() => {
77
77
  const e = Object.keys(h);
78
78
  u((l) => a(l, (p) => !P(e, p)));
79
79
  }, [h]);
@@ -81,7 +81,7 @@ const de = () => {
81
81
  u((l) => P(l, e) ? a(l, (p) => p !== e) : ne(l, e));
82
82
  }, D = () => {
83
83
  u(E ? [] : y(c, "id"));
84
- }, q = () => {
84
+ }, I = () => {
85
85
  N(
86
86
  { ids: U(o) },
87
87
  {
@@ -90,11 +90,11 @@ const de = () => {
90
90
  }
91
91
  }
92
92
  );
93
- }, I = (e) => {
93
+ }, M = (e) => {
94
94
  if (e === "theme") return "Theme";
95
95
  const l = G(m, { key: e });
96
96
  return l ? l == null ? void 0 : l.name : e;
97
- }, M = g(() => {
97
+ }, q = g(() => {
98
98
  const e = [
99
99
  { label: "Updated", top: "pt-2" },
100
100
  ...b(a(T, { online: !0 }), "pageType"),
@@ -144,7 +144,7 @@ const de = () => {
144
144
  /* @__PURE__ */ t("th", { scope: "col", className: "w-[150px] px-4 py-3 text-right", children: "Status" })
145
145
  ] }) }),
146
146
  /* @__PURE__ */ t("tbody", { children: y(
147
- M,
147
+ q,
148
148
  (e) => e.label ? /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ n("td", { colSpan: 3, className: `relative px-6 py-2 text-xs font-medium text-gray-800 ${e.top}`, children: [
149
149
  /* @__PURE__ */ t("div", { className: "absolute inset-0 left-6 flex items-center", children: /* @__PURE__ */ t("div", { className: "order-gray-300 w-full" }) }),
150
150
  /* @__PURE__ */ t("div", { className: "relative flex justify-start", children: /* @__PURE__ */ t("span", { className: "bg-gray-50 pr-2", children: e.label }) })
@@ -154,7 +154,7 @@ const de = () => {
154
154
  page: e,
155
155
  selectedPages: o,
156
156
  handleCheckboxChange: B,
157
- getPageType: I,
157
+ getPageType: M,
158
158
  hasSlug: w,
159
159
  currentOwnerId: h[(e == null ? void 0 : e.primaryPage) || (e == null ? void 0 : e.id)]
160
160
  }
@@ -169,7 +169,7 @@ const de = () => {
169
169
  " Selected"
170
170
  ] }),
171
171
  /* @__PURE__ */ t(F, { disabled: d, variant: "outline", onClick: s, children: "Cancel" }),
172
- /* @__PURE__ */ t(F, { disabled: d || C || se(o), onClick: q, children: d ? "Publishing..." : "Publish Selected" })
172
+ /* @__PURE__ */ t(F, { disabled: d || C || se(o), onClick: I, children: d ? "Publishing..." : "Publish Selected" })
173
173
  ] })
174
174
  ] });
175
175
  };
@@ -1,11 +1,11 @@
1
1
  import { jsx as e, jsxs as i } from "react/jsx-runtime";
2
2
  import { useMutation as U, useQuery as z, useQueryClient as se } from "@tanstack/react-query";
3
3
  import { toast as B } from "sonner";
4
- import { ak as L, al as G, A as _, aw as ie } from "./index-DFvsMFVH.js";
4
+ import { al as L, am as G, A as _, as as ie } from "./index-CguzNa4U.js";
5
5
  import { useUpdateBlocksPropsRealtime as K, usePartailBlocksStore as oe, usePermissions as le, useLibraryBlocks as ce } from "@chaibuilder/sdk";
6
6
  import { Button as b, Popover as de, PopoverTrigger as ue, PopoverContent as me, Input as D, Label as P } from "@chaibuilder/sdk/ui";
7
7
  import { Trash2 as Y, Plus as pe, ImageIcon as he, X as fe, AlertCircle as ge } from "lucide-react";
8
- import { useState as f, useRef as V, useMemo as S, useEffect as I, useCallback as be } from "react";
8
+ import { useState as f, useRef as V, useMemo as S, useEffect as w, useCallback as be } from "react";
9
9
  import { c as ve } from "./image-compression-DsZ1oqpb.js";
10
10
  import { isEmpty as ye, set as ke, has as Ne } from "lodash-es";
11
11
  const Be = (a) => {
@@ -44,7 +44,7 @@ const Be = (a) => {
44
44
  },
45
45
  retry: !1
46
46
  });
47
- }, we = (a) => {
47
+ }, Ie = (a) => {
48
48
  const r = L(), o = G();
49
49
  return U({
50
50
  mutationFn: async (t) => o(r, {
@@ -60,7 +60,7 @@ const Be = (a) => {
60
60
  });
61
61
  }
62
62
  });
63
- }, Ie = ({
63
+ }, we = ({
64
64
  blockId: a,
65
65
  libBlockId: r,
66
66
  isOpen: o,
@@ -68,7 +68,7 @@ const Be = (a) => {
68
68
  blockName: u,
69
69
  trigger: p
70
70
  }) => {
71
- const [d, l] = f(!1), c = K(), v = we(() => {
71
+ const [d, l] = f(!1), c = K(), v = Ie(() => {
72
72
  c([a], { _libBlockId: void 0 }), B.success("Block deleted successfully"), l(!1), t();
73
73
  });
74
74
  return /* @__PURE__ */ i(de, { open: o, onOpenChange: (m) => !m && t(), children: [
@@ -144,7 +144,7 @@ const Be = (a) => {
144
144
  }) => {
145
145
  const [d, l] = f(!1);
146
146
  return /* @__PURE__ */ e(
147
- Ie,
147
+ we,
148
148
  {
149
149
  blockId: a,
150
150
  libBlockId: r,
@@ -257,13 +257,13 @@ const Be = (a) => {
257
257
  const N = { id: n, name: n };
258
258
  v((E) => [...E, N]), r(N.id), p(""), t(!1);
259
259
  };
260
- I(() => {
260
+ w(() => {
261
261
  o && d.current && d.current.focus();
262
262
  }, [o]);
263
263
  const m = (n) => {
264
264
  n.key === "Enter" && (n.preventDefault(), g());
265
265
  };
266
- return I(() => {
266
+ return w(() => {
267
267
  a && !h.some((n) => n.id === a) && r("");
268
268
  }, [a, h, r]), o ? /* @__PURE__ */ i("div", { className: "space-y-2", children: [
269
269
  /* @__PURE__ */ e(
@@ -371,15 +371,15 @@ const Be = (a) => {
371
371
  }, [r, u]), [h, g] = f(""), [m, n] = f(""), [N, E] = f(""), [x, A] = f(""), [C, W] = f({}), [Q, $] = f(!1), [H, q] = f(l), [X, J] = f(!1), { hasPermission: Z } = le(), ee = Z(ie.DELETE_LIBRARY_BLOCK), M = K(), te = () => {
372
372
  M([t], { _libBlockId: void 0 }), B.success("Block delinked from library"), o();
373
373
  }, {
374
- data: w,
374
+ data: I,
375
375
  isLoading: T,
376
376
  isError: O
377
377
  } = Ce(d);
378
- I(() => {
378
+ w(() => {
379
379
  O && l && (J(!0), q(!1));
380
- }, [O, l]), I(() => {
381
- w && !T && (g(w.name || ""), n(w.group || ""), E(w.description || ""), A(w.preview || ""), q(!1));
382
- }, [w, T]), I(() => {
380
+ }, [O, l]), w(() => {
381
+ I && !T && (g(I.name || ""), n(I.group || ""), E(I.description || ""), A(I.preview || ""), q(!1));
382
+ }, [I, T]), w(() => {
383
383
  const s = h.trim().length >= 2, y = m.trim() !== "";
384
384
  $(s && y);
385
385
  }, [h, m]);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),I=require("@tanstack/react-query"),k=require("sonner"),x=require("./index-Qnh8Lkr0.cjs"),E=require("@chaibuilder/sdk"),c=require("@chaibuilder/sdk/ui"),C=require("lucide-react"),i=require("react"),X=require("./image-compression-DZ9WMmyn.cjs"),R=require("lodash-es"),J=n=>{const s=x.useApiUrl(),l=x.useFetch();return I.useMutation({mutationFn:async t=>l(s,{action:x.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{n(t)},onError:t=>{console.error("Error saving block:",t),k.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},Z=n=>{const s=x.useApiUrl(),l=x.useFetch();return I.useQuery({staleTime:"static",queryKey:[x.ACTIONS.GET_LIBRARY_ITEM,n],enabled:!!n,queryFn:async()=>{if(!n)return null;try{return await l(s,{action:x.ACTIONS.GET_LIBRARY_ITEM,data:{id:n}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},ee=n=>{const s=x.useApiUrl(),l=x.useFetch();return I.useMutation({mutationFn:async t=>l(s,{action:x.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:t}}),onSuccess:()=>{n()},onError:t=>{console.error("Error deleting block:",t),k.toast.error("Failed to delete block",{description:t instanceof Error?t.message:"Unknown error"})}})},te=({blockId:n,libBlockId:s,isOpen:l,onClose:t,blockName:m,trigger:f})=>{const[u,o]=i.useState(!1),d=E.useUpdateBlocksPropsRealtime(),b=ee(()=>{d([n],{_libBlockId:void 0}),k.toast.success("Block deleted successfully"),o(!1),t()}),p=()=>{o(!0),b.mutate(s)},g=e.jsxs(c.Button,{type:"button",variant:"destructive",size:"sm",onClick:h=>h.preventDefault(),disabled:u,children:[e.jsx(C.Trash2,{className:"h-4 w-4 mr-2"}),"Delete"]});return e.jsxs(c.Popover,{open:l,onOpenChange:h=>!h&&t(),children:[e.jsx(c.PopoverTrigger,{asChild:!0,children:f||g}),e.jsx(c.PopoverContent,{className:"w-72 p-4 z-[9999]",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',m,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(c.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(c.Button,{type:"button",variant:"destructive",size:"sm",onClick:p,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},se=({blockId:n,libBlockId:s,blockName:l,size:t="sm",className:m="",close:f})=>{const[u,o]=i.useState(!1);return e.jsx(te,{blockId:n,libBlockId:s,isOpen:u,onClose:()=>{o(!1),f()},blockName:l,trigger:e.jsxs(c.Button,{type:"button",variant:"destructive",size:t,className:m,onClick:()=>o(!0),children:[e.jsx(C.Trash2,{className:"h-4 w-4 mr-2"}),"Delete"]})})},re=()=>{const n=x.useApiUrl(),s=x.useFetch(),l=I.useQueryClient(),{data:t=[],isLoading:m,error:f}=I.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await s(n,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=I.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return s(n,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),k.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),k.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:m,error:f,createGroup:u,isCreating:o}},ne=({value:n,onChange:s})=>{const[l,t]=i.useState(!1),[m,f]=i.useState(""),u=i.useRef(null),{groups:o}=re(),[d,b]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),p=i.useMemo(()=>[...o,...d.filter(r=>!o.some(j=>j.id===r.id))],[o,d]),g=()=>{const r=m.trim();if(!r)return;const j={id:r,name:r};b(w=>[...w,j]),s(j.id),f(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const h=r=>{r.key==="Enter"&&(r.preventDefault(),g())};return i.useEffect(()=>{n&&!p.some(r=>r.id===n)&&s("")},[n,p,s]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Input,{ref:u,placeholder:"Enter new group name",value:m,onChange:r=>f(r.target.value),onKeyDown:h}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(c.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(c.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:n,onChange:r=>s(r.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(r=>e.jsx("option",{value:r.id,children:r.name},`lib-${r.id}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.filter(r=>!o.some(j=>j.id===r.id)).map(r=>e.jsx("option",{value:r.id,children:r.name},`local-${r.id}`))})]}),e.jsx(c.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(C.Plus,{className:"h-4 w-4"})})]})},ae=({value:n,onChange:s})=>{const[l,t]=i.useState(!1),m=i.useRef(null),f=i.useCallback(async d=>{var p;const b=(p=d.target.files)==null?void 0:p[0];if(b)try{t(!0);let g=b;b.type.startsWith("image/")&&(g=await X.compressImageIfNeeded(b));const h=new FileReader;h.onloadend=()=>{s(h.result),t(!1)},h.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),k.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[s]),u=()=>{s(""),m.current&&(m.current.value="")},o=()=>{var d;(d=m.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c.Input,{type:"file",ref:m,onChange:f,accept:"image/*",className:"hidden"}),e.jsx(c.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(C.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),n&&e.jsx(c.Button,{type:"button",variant:"outline",size:"icon",onClick:u,children:e.jsx(C.X,{className:"h-4 w-4"})})]}),n&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:n,alt:"Preview",className:"h-full w-full object-contain"})})]})},oe=n=>{const{blocks:s,close:l,blockId:t}=n,{getPartailBlocks:m}=E.usePartailBlocksStore(),f=s.find(a=>a._id===t),u=f==null?void 0:f._libBlockId,o=!!u,d=i.useMemo(()=>s.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[s]),b=i.useMemo(()=>{let a=[];for(const y of s)if(y._type==="PartialBlock"||y._type==="GlobalBlock"){let v=m(y.partialBlockId);y._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",y._parent),T))),a=[...a,...v]}else a.push(y);return a},[s,m]),[p,g]=i.useState(""),[h,r]=i.useState(""),[j,w]=i.useState(""),[S,_]=i.useState(""),[N,A]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=E.usePermissions(),Q=Y(x.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=E.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),k.toast.success("Block delinked from library"),l()},{data:B,isLoading:P,isError:G}=Z(u);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{B&&!P&&(g(B.name||""),r(B.group||""),w(B.description||""),_(B.preview||""),F(!1))},[B,P]),i.useEffect(()=>{const a=p.trim().length>=2,y=h.trim()!=="";M(a&&y)},[p,h]);const W=()=>{const a={};return p.trim()?p.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",h||(a.group="Group is required"),A(a),Object.keys(a).length===0},{resetLibrary:$}=E.useLibraryBlocks({id:""}),U=J(a=>{o||D([t],{_libBlockId:a.id}),k.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const y=b.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));U.mutate({name:p.trim(),group:h,blocks:y,description:j.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=U.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(c.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(c.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(C.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(c.Input,{id:"name",placeholder:"Enter block name",value:p,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ne,{value:h,onChange:r}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(c.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:j,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(ae,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(se,{blockId:t,libBlockId:u,blockName:p,className:"mr-auto",close:l}),e.jsx(c.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(c.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=oe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),I=require("@tanstack/react-query"),k=require("sonner"),x=require("./index-CffopOpP.cjs"),E=require("@chaibuilder/sdk"),c=require("@chaibuilder/sdk/ui"),C=require("lucide-react"),i=require("react"),X=require("./image-compression-DZ9WMmyn.cjs"),R=require("lodash-es"),J=n=>{const s=x.useApiUrl(),l=x.useFetch();return I.useMutation({mutationFn:async t=>l(s,{action:x.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{n(t)},onError:t=>{console.error("Error saving block:",t),k.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},Z=n=>{const s=x.useApiUrl(),l=x.useFetch();return I.useQuery({staleTime:"static",queryKey:[x.ACTIONS.GET_LIBRARY_ITEM,n],enabled:!!n,queryFn:async()=>{if(!n)return null;try{return await l(s,{action:x.ACTIONS.GET_LIBRARY_ITEM,data:{id:n}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},ee=n=>{const s=x.useApiUrl(),l=x.useFetch();return I.useMutation({mutationFn:async t=>l(s,{action:x.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:t}}),onSuccess:()=>{n()},onError:t=>{console.error("Error deleting block:",t),k.toast.error("Failed to delete block",{description:t instanceof Error?t.message:"Unknown error"})}})},te=({blockId:n,libBlockId:s,isOpen:l,onClose:t,blockName:m,trigger:f})=>{const[u,o]=i.useState(!1),d=E.useUpdateBlocksPropsRealtime(),b=ee(()=>{d([n],{_libBlockId:void 0}),k.toast.success("Block deleted successfully"),o(!1),t()}),p=()=>{o(!0),b.mutate(s)},g=e.jsxs(c.Button,{type:"button",variant:"destructive",size:"sm",onClick:h=>h.preventDefault(),disabled:u,children:[e.jsx(C.Trash2,{className:"h-4 w-4 mr-2"}),"Delete"]});return e.jsxs(c.Popover,{open:l,onOpenChange:h=>!h&&t(),children:[e.jsx(c.PopoverTrigger,{asChild:!0,children:f||g}),e.jsx(c.PopoverContent,{className:"w-72 p-4 z-[9999]",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',m,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(c.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(c.Button,{type:"button",variant:"destructive",size:"sm",onClick:p,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},se=({blockId:n,libBlockId:s,blockName:l,size:t="sm",className:m="",close:f})=>{const[u,o]=i.useState(!1);return e.jsx(te,{blockId:n,libBlockId:s,isOpen:u,onClose:()=>{o(!1),f()},blockName:l,trigger:e.jsxs(c.Button,{type:"button",variant:"destructive",size:t,className:m,onClick:()=>o(!0),children:[e.jsx(C.Trash2,{className:"h-4 w-4 mr-2"}),"Delete"]})})},re=()=>{const n=x.useApiUrl(),s=x.useFetch(),l=I.useQueryClient(),{data:t=[],isLoading:m,error:f}=I.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await s(n,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=I.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return s(n,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),k.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),k.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:m,error:f,createGroup:u,isCreating:o}},ne=({value:n,onChange:s})=>{const[l,t]=i.useState(!1),[m,f]=i.useState(""),u=i.useRef(null),{groups:o}=re(),[d,b]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),p=i.useMemo(()=>[...o,...d.filter(r=>!o.some(j=>j.id===r.id))],[o,d]),g=()=>{const r=m.trim();if(!r)return;const j={id:r,name:r};b(w=>[...w,j]),s(j.id),f(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const h=r=>{r.key==="Enter"&&(r.preventDefault(),g())};return i.useEffect(()=>{n&&!p.some(r=>r.id===n)&&s("")},[n,p,s]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Input,{ref:u,placeholder:"Enter new group name",value:m,onChange:r=>f(r.target.value),onKeyDown:h}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(c.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(c.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:n,onChange:r=>s(r.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(r=>e.jsx("option",{value:r.id,children:r.name},`lib-${r.id}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.filter(r=>!o.some(j=>j.id===r.id)).map(r=>e.jsx("option",{value:r.id,children:r.name},`local-${r.id}`))})]}),e.jsx(c.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(C.Plus,{className:"h-4 w-4"})})]})},ae=({value:n,onChange:s})=>{const[l,t]=i.useState(!1),m=i.useRef(null),f=i.useCallback(async d=>{var p;const b=(p=d.target.files)==null?void 0:p[0];if(b)try{t(!0);let g=b;b.type.startsWith("image/")&&(g=await X.compressImageIfNeeded(b));const h=new FileReader;h.onloadend=()=>{s(h.result),t(!1)},h.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),k.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[s]),u=()=>{s(""),m.current&&(m.current.value="")},o=()=>{var d;(d=m.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c.Input,{type:"file",ref:m,onChange:f,accept:"image/*",className:"hidden"}),e.jsx(c.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(C.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),n&&e.jsx(c.Button,{type:"button",variant:"outline",size:"icon",onClick:u,children:e.jsx(C.X,{className:"h-4 w-4"})})]}),n&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:n,alt:"Preview",className:"h-full w-full object-contain"})})]})},oe=n=>{const{blocks:s,close:l,blockId:t}=n,{getPartailBlocks:m}=E.usePartailBlocksStore(),f=s.find(a=>a._id===t),u=f==null?void 0:f._libBlockId,o=!!u,d=i.useMemo(()=>s.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[s]),b=i.useMemo(()=>{let a=[];for(const y of s)if(y._type==="PartialBlock"||y._type==="GlobalBlock"){let v=m(y.partialBlockId);y._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",y._parent),T))),a=[...a,...v]}else a.push(y);return a},[s,m]),[p,g]=i.useState(""),[h,r]=i.useState(""),[j,w]=i.useState(""),[S,_]=i.useState(""),[N,A]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=E.usePermissions(),Q=Y(x.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=E.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),k.toast.success("Block delinked from library"),l()},{data:B,isLoading:P,isError:G}=Z(u);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{B&&!P&&(g(B.name||""),r(B.group||""),w(B.description||""),_(B.preview||""),F(!1))},[B,P]),i.useEffect(()=>{const a=p.trim().length>=2,y=h.trim()!=="";M(a&&y)},[p,h]);const W=()=>{const a={};return p.trim()?p.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",h||(a.group="Group is required"),A(a),Object.keys(a).length===0},{resetLibrary:$}=E.useLibraryBlocks({id:""}),U=J(a=>{o||D([t],{_libBlockId:a.id}),k.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const y=b.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));U.mutate({name:p.trim(),group:h,blocks:y,description:j.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=U.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(c.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(c.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(C.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(c.Input,{id:"name",placeholder:"Enter block name",value:p,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ne,{value:h,onChange:r}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(c.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:j,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(ae,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(se,{blockId:t,libBlockId:u,blockName:p,className:"mr-auto",close:l}),e.jsx(c.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(c.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=oe;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-Qnh8Lkr0.cjs"),P=require("@chaibuilder/sdk"),d=require("lodash-es"),v=require("react"),a=require("@chaibuilder/sdk/ui"),L=require("sonner"),ce=require("@tanstack/react-query"),K=require("lucide-react"),M=require("./get-seo-defaults-Cw7vFt-B.cjs"),de=()=>{const{selectedLang:t}=P.useLanguages(),{data:x,isFetching:u}=i.useLanguagePages();return{data:v.useMemo(()=>d.find(x,{lang:t||""})||{},[x,t]),isFetching:u}},ue=()=>{var p;const x=(p=document.getElementById("canvas-iframe").contentDocument)==null?void 0:p.body.innerHTML;if(!x)return null;const c=new DOMParser().parseFromString(x,"text/html");c.querySelectorAll("style, script, link, svg, [data-block-type='PartialBlock']").forEach(g=>g.remove()),c.querySelectorAll("*").forEach(g=>{Array.from(g.attributes).forEach(m=>g.removeAttribute(m.name))});const r=c.querySelectorAll("h1, h2, h3, h4, h5, h6, p");return Array.from(r).map(g=>`<${g.tagName.toLowerCase()}>${g.innerHTML}</${g.tagName.toLowerCase()}>`).join(" ").replace(/<p>Partial block. Double click to edit.<\/p>/,"")},F=({keyword:t,onComplete:x,field:u})=>{const c=i.useFetch(),r=i.useApiUrl(),{selectedLang:N,fallbackLang:p}=P.useLanguages(),{mutate:g,isPending:m}=ce.useMutation({mutationFn:async()=>{const D=ue();return await c(r,{action:i.ACTIONS.GENERATE_SEO_FIELD,data:{pageContext:"",dynamic:!1,field:u,lang:N||p,pageContent:D,keyword:t}})},onSuccess:D=>{x({fieldValue:D.field})},onError:D=>{x({fieldValue:null,error:D.message})}});return e.jsx(a.Button,{disabled:m,type:"button",className:"h-5 w-5",variant:"ghost",size:"sm",onClick:()=>g(),children:m?e.jsx(K.Loader,{className:"h-3 w-3 animate-spin text-yellow-500"}):e.jsx(K.Wand2Icon,{className:"text-yellow-500"})})},ge=({isOpen:t,onClose:x,onSave:u,onDiscard:c,isSaving:r=!1,fromLanguage:N,toLanguage:p})=>{const g=i.LANGUAGES[N]||N,m=i.LANGUAGES[p]||p;return e.jsx(a.Dialog,{open:t,onOpenChange:x,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Unsaved SEO Changes"}),e.jsxs(a.DialogDescription,{children:['You have unsaved changes in the SEO for "',g,'" version. Do you want to save these changes before switching to "',m,'" version?']})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(a.Button,{variant:"outline",onClick:c,disabled:r,children:"Discard Changes"}),e.jsx(a.Button,{onClick:u,disabled:r,children:r?"Saving...":"Save & Switch"})]})]})})},me=t=>{if(!t)return!0;try{return JSON.parse(t),!0}catch{return!1}},he=(t,x)=>{const u=t.selectionStart||0,c=t.selectionEnd||0,r=t.value,N=r.substring(0,u),p=r.substring(c),g=`{{${x}}}`,m=N+""+g+p,D=u+0+g.length;return{value:m,newCursorPos:D}},Q=()=>{const{t}=P.useTranslation(),[,x]=P.useSidebarActivePanel(),{data:u}=i.useCurrentPage(),{data:c}=i.useBuilderPageData(),{data:r,isFetching:N}=de(),p=r==null?void 0:r.seo,g=v.useRef(null),[m,D]=v.useState("seo"),R=u==null?void 0:u.id,W=u==null?void 0:u.pageType,I=i.usePageType(W),{selectedLang:$,fallbackLang:X}=P.useLanguages(),h=$||X,[H,J]=v.useState(!1),[Z,_]=v.useState(!1),[ee,V]=v.useState(!1),[S,U]=v.useState(null),[n,w]=v.useState({keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"{}",metaOther:"{}",...p}),E=v.useRef({}),{mutate:se,isPending:q}=i.useUpdatePage(),f=q||H||Z,{hasPermission:te}=P.usePermissions(),o=te(i.PAGES_PERMISSIONS.EDIT_SEO),[ae]=i.usePagesProps(),ne=d.get(ae,"features.canResetSeoToDefault",!1),z=!$||n.jsonLD!=="{}";v.useEffect(()=>{if(!N&&p&&R){const s={keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"",metaOther:"",...p};w(s),E.current[h]=s}},[N,p,h,R]),v.useEffect(()=>{const s=l=>{const{fromLang:b,toLang:A,switchHandler:y}=l.detail,G=E.current[h];(G?!d.isEqual(G,n):!1)?(U({fromLang:b,toLang:A,switchHandler:y}),V(!0)):y()};return window.addEventListener("seo-language-switch-check",s),()=>{window.removeEventListener("seo-language-switch-check",s)}},[R,n,h]);const oe=async()=>{if(!(!I||!h))try{J(!0);const s=M.getSeoDefaults(I,h),l={...n,keyword:d.get(s,"seo.keyword",""),title:d.get(s,"seo.title",""),description:d.get(s,"seo.description",""),cononicalUrl:d.get(s,"seo.canonicalUrl",""),noIndex:d.get(s,"seo.noIndex",!1),noFollow:d.get(s,"seo.noFollow",!1),ogTitle:d.get(s,"seo.ogTitle",""),ogDescription:d.get(s,"seo.ogDescription","")};w(l),L.toast.success(t("SEO fields reset to defaults"))}catch(s){L.toast.error(t("Failed to reset SEO fields")),console.error("Reset SEO error:",s)}finally{J(!1)}},le=async()=>{if(!(!I||!h))try{_(!0);const s=M.getSeoDefaults(I,h),l={...n,jsonLD:d.get(s,"seo.jsonLD","")};w(l),L.toast.success(t("JSON-LD reset to default"))}catch(s){L.toast.error(t("Failed to reset JSON-LD")),console.error("Reset JSON-LD error:",s)}finally{_(!1)}},re=async()=>{if(!(!I||!h))try{J(!0);const s=M.getSeoDefaults(I,h),l={...n,ogTitle:d.get(s,"seo.ogTitle",""),ogDescription:d.get(s,"seo.ogDescription",""),ogImage:d.get(s,"seo.ogImage",""),ogImageId:d.get(s,"seo.ogImageId",""),metaOther:d.get(s,"seo.metaOther","{}")};w(l),L.toast.success(t("Meta Tag fields reset to defaults"))}catch(s){L.toast.error(t("Failed to reset Meta Tag fields")),console.error("Reset Meta Tag error:",s)}finally{J(!1)}},Y=async()=>{se({id:r==null?void 0:r.id,seo:n,primaryPage:R},{onSuccess:()=>{console.log("SEO & JSON-LD updated successfully",n),E.current[h]=n,L.toast.success("SEO & JSON-LD updated successfully")}})},O=(s,l)=>{const b=document.getElementById(l);if(b){const{value:A,newCursorPos:y}=he(b,s);g.current={id:l,position:y},b.tagName.toLowerCase()==="input"?(b.value=A,w(C=>({...C,[b.name]:A})),b.focus(),b.setSelectionRange(y,y),[0,10,50,100,200].forEach(C=>{setTimeout(()=>{const B=document.getElementById(l);B&&(B.focus(),B.setSelectionRange(y,y))},C)})):(w(T=>({...T,[b.name]:A})),requestAnimationFrame(()=>{const T=document.getElementById(l);T&&(T.focus(),T.setSelectionRange(y,y),setTimeout(()=>{const C=document.getElementById(l);C&&(C.focus(),C.setSelectionRange(y,y))},50))}))}},j=s=>{const l={...n,[s.target.name]:s.target.name==="noIndex"||s.target.name==="noFollow"?s.target.checked:s.target.value};w(l)},k=s=>l=>{d.isEmpty(l.fieldValue)||j({target:{name:s,value:typeof l.fieldValue=="string"?l.fieldValue.replace(/^"(.*)"$/,"$1"):l.fieldValue}}),l.error&&L.toast.error(e.jsxs("div",{children:[e.jsx("h2",{children:"Failed to generate:"}),e.jsx("p",{children:l.error})]}))},ie=()=>{const s=d.get(u,"seo.jsonLD","{}");if((s==null?void 0:s.trim())==="{}"){L.toast.error("Default page JSON-LD is empty");return}j({target:{name:"jsonLD",value:s}})};return e.jsxs("div",{className:"relative flex h-full flex-col","data-panel-id":"seo",children:[!o&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center backdrop-blur-sm",children:e.jsx(a.Alert,{variant:"default",className:"w-[80%] max-w-md text-xs",children:e.jsx(a.AlertDescription,{children:t("You don't have permission to edit SEO settings. Contact your administrator for access.")})})}),e.jsxs("div",{className:"no-scrollbar flex-grow overflow-y-auto px-2 pb-20",children:[e.jsxs("div",{className:"mb-4 flex w-full items-center justify-between rounded-md bg-gray-100 px-2 py-1 text-left text-sm",children:[e.jsxs("span",{children:[e.jsx("div",{className:"font-medium",children:r==null?void 0:r.name}),e.jsx("span",{className:"font-mono text-xs leading-tight text-gray-500",children:r==null?void 0:r.slug})]}),e.jsx(i.LanguageSwitcher,{variant:"outline",showAdd:!1})]}),e.jsx("form",{className:"space-y-8",children:e.jsxs(a.Tabs,{value:m,onValueChange:D,className:"w-full",children:[e.jsxs(a.TabsList,{className:"mb-4 grid w-full grid-cols-3",children:[e.jsx(a.TabsTrigger,{value:"seo",children:t("SEO")}),e.jsx(a.TabsTrigger,{value:"opengraph",children:t("Meta Tags")}),e.jsx(a.TabsTrigger,{value:"jsonld",children:t("JSON-LD")})]}),e.jsx("div",{className:m==="seo"?"":"sr-only",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"keyword",children:t("Keyword")}),o&&e.jsx(i.NestedPathSelector,{dataType:"value",data:c??{},onSelect:s=>O(s,"keyword")})]}),e.jsx(a.Input,{type:"text",id:"keyword",name:"keyword",value:n.keyword,onChange:j,disabled:f||!o,placeholder:t("Enter keyword"),readOnly:!o})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"title",children:t("SEO Title")}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(F,{keyword:n.keyword,onComplete:k("title"),field:"title"}),o&&e.jsx(i.NestedPathSelector,{dataType:"value",data:c??{},onSelect:s=>O(s,"title")})]})]}),e.jsx(a.Input,{type:"text",id:"title",name:"title",value:n.title,onChange:j,disabled:f||!o,placeholder:t("Enter SEO title"),readOnly:!o})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"description",children:t("SEO Description")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{keyword:n.keyword,onComplete:k("description"),field:"description"}),o&&e.jsx(i.NestedPathSelector,{data:c??{},onSelect:s=>O(s,"description")})]})]}),e.jsx(a.Textarea,{id:"description",name:"description",rows:5,value:n.description,onChange:j,disabled:f||!o,placeholder:t("Enter SEO description"),readOnly:!o})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"title",children:t("Canonical URL")}),o&&e.jsx(i.NestedPathSelector,{dataType:"value",data:c??{},onSelect:s=>O(s,"canonicalUrl")})]}),e.jsx(a.Input,{type:"text",id:"canonicalUrl",name:"canonicalUrl",value:n.canonicalUrl,onChange:j,disabled:f||!o,placeholder:t("Enter Canonical URL"),readOnly:!o})]}),e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(a.Input,{type:"checkbox",id:"noIndex",name:"noIndex",checked:n.noIndex,onChange:j,disabled:f||!o,className:"h-4 w-4"}),e.jsx(a.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:t("No Index")})]}),e.jsx("p",{className:"mt-0 text-[10px] font-light leading-4 text-gray-400",children:t("Check this if you don't want search engines to index this page.")})]}),e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(a.Input,{type:"checkbox",id:"noFollow",name:"noFollow",checked:n.noFollow,onChange:j,disabled:f||!o,className:"h-4 w-4"}),e.jsx(a.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:t("No Follow")})]}),e.jsx("p",{className:"text-[10px] font-light leading-4 text-gray-400",children:t("Check this if you don't want search engines to follow links on this page.")})]})]})}),e.jsx("div",{className:m==="opengraph"?"":"sr-only",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"mb-4 font-semibold text-slate-700",children:t("Open Graph")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"ogTitle",children:t("OG Title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{keyword:n.keyword,onComplete:k("ogTitle"),field:"ogTitle"}),o&&e.jsx(i.NestedPathSelector,{dataType:"value",data:c??{},onSelect:s=>O(s,"ogTitle")})]})]}),e.jsx(a.Input,{type:"text",id:"ogTitle",name:"ogTitle",value:n.ogTitle,onChange:j,disabled:f||!o,placeholder:t("Enter OG title"),readOnly:!o})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"ogDescription",children:t("OG Description")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{keyword:n.keyword,onComplete:k("ogDescription"),field:"ogDescription"}),o&&e.jsx(i.NestedPathSelector,{dataType:"value",data:c??{},onSelect:s=>O(s,"ogDescription")})]})]}),e.jsx(a.Textarea,{id:"ogDescription",name:"ogDescription",rows:5,value:n.ogDescription,onChange:j,disabled:f||!o,placeholder:t("Enter OG description"),readOnly:!o})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"ogImage",children:t("OG Image")}),o&&e.jsx(i.NestedPathSelector,{dataType:"value",data:c??{},onSelect:s=>{w({...n,ogImage:`{{${s}}}`,ogImageId:""})}})]}),e.jsx(i.ImagePicker,{assetId:n.ogImageId,assetUrl:n.ogImage,onChange:s=>{w({...n,ogImage:s.url,ogImageId:s.id})},disabled:f||!o,placeholder:t("Select OG image"),className:"mb-2"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"metaOther",children:t("Meta Tags")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(F,{keyword:n.keyword,onComplete:k("metaOther"),field:"metaOther"})})]}),e.jsx(i.SmartJsonInput,{id:"metaOther",value:n.metaOther,onChange:s=>{j({target:{name:"metaOther",value:s}})},placeholder:t("Enter Meta Tags JSON"),disabled:f||!o,readOnly:!o,pageData:c||{},rows:8,handleFieldInsert:O})]})]})]})})}),e.jsx("div",{className:m==="jsonld"?"":"sr-only",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"jsonLD",children:t("JSON-LD")}),z&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(F,{keyword:n.keyword,onComplete:k("jsonLD"),field:"jsonLD"})})]}),e.jsx("div",{className:"hidden",children:JSON.stringify(c)}),e.jsx(i.SmartJsonInput,{id:"jsonLD",value:n.jsonLD,onChange:s=>{j({target:{name:"jsonLD",value:s}})},placeholder:t("Enter JSON-LD"),disabled:f||!o,readOnly:!o,pageData:c||{},rows:12,handleFieldInsert:O,hasJsonLdForSelectedLang:z,copyJsonLDFromDefaultPage:ie})]})})})]})})]}),o&&e.jsxs("div",{className:"fixed bottom-0 left-0 right-0 flex w-full flex-shrink-0 items-center justify-between border-t bg-background p-4",children:[ne?e.jsx(a.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>{m==="jsonld"?le():m==="opengraph"?re():oe()},disabled:f||!o||!I,children:t(H?"Resetting...":`Reset to ${m==="jsonld"?"Default JSON-LD":m==="opengraph"?"Default Open Graph":"Default SEO"}`)}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(a.Button,{onClick:Y,disabled:!me(n==null?void 0:n.jsonLD)||(E.current[h]?d.isEqual(E.current[h],n):!1)||f||!o,children:t(q?"Saving...":"Save")}),e.jsx(a.Button,{variant:"link",className:"text-gray-500 hover:text-gray-700",onClick:()=>x("outline"),children:t("Cancel")})]})]}),e.jsx(ge,{isOpen:ee,onClose:()=>{V(!1),U(null)},onSave:async()=>{S&&(await Y(),S.switchHandler(),V(!1),U(null))},onDiscard:()=>{if(S){const s=E.current[h];s&&w(s),S.switchHandler(),V(!1),U(null)}},isSaving:q,fromLanguage:(S==null?void 0:S.fromLang)||h,toLanguage:(S==null?void 0:S.toLang)||""})]})};Q.displayName="SeoPanel";exports.default=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-CffopOpP.cjs"),P=require("@chaibuilder/sdk"),d=require("lodash-es"),v=require("react"),a=require("@chaibuilder/sdk/ui"),L=require("sonner"),ce=require("@tanstack/react-query"),K=require("lucide-react"),M=require("./get-seo-defaults-Cw7vFt-B.cjs"),de=()=>{const{selectedLang:t}=P.useLanguages(),{data:x,isFetching:u}=i.useLanguagePages();return{data:v.useMemo(()=>d.find(x,{lang:t||""})||{},[x,t]),isFetching:u}},ue=()=>{var p;const x=(p=document.getElementById("canvas-iframe").contentDocument)==null?void 0:p.body.innerHTML;if(!x)return null;const c=new DOMParser().parseFromString(x,"text/html");c.querySelectorAll("style, script, link, svg, [data-block-type='PartialBlock']").forEach(g=>g.remove()),c.querySelectorAll("*").forEach(g=>{Array.from(g.attributes).forEach(m=>g.removeAttribute(m.name))});const r=c.querySelectorAll("h1, h2, h3, h4, h5, h6, p");return Array.from(r).map(g=>`<${g.tagName.toLowerCase()}>${g.innerHTML}</${g.tagName.toLowerCase()}>`).join(" ").replace(/<p>Partial block. Double click to edit.<\/p>/,"")},F=({keyword:t,onComplete:x,field:u})=>{const c=i.useFetch(),r=i.useApiUrl(),{selectedLang:N,fallbackLang:p}=P.useLanguages(),{mutate:g,isPending:m}=ce.useMutation({mutationFn:async()=>{const D=ue();return await c(r,{action:i.ACTIONS.GENERATE_SEO_FIELD,data:{pageContext:"",dynamic:!1,field:u,lang:N||p,pageContent:D,keyword:t}})},onSuccess:D=>{x({fieldValue:D.field})},onError:D=>{x({fieldValue:null,error:D.message})}});return e.jsx(a.Button,{disabled:m,type:"button",className:"h-5 w-5",variant:"ghost",size:"sm",onClick:()=>g(),children:m?e.jsx(K.Loader,{className:"h-3 w-3 animate-spin text-yellow-500"}):e.jsx(K.Wand2Icon,{className:"text-yellow-500"})})},ge=({isOpen:t,onClose:x,onSave:u,onDiscard:c,isSaving:r=!1,fromLanguage:N,toLanguage:p})=>{const g=i.LANGUAGES[N]||N,m=i.LANGUAGES[p]||p;return e.jsx(a.Dialog,{open:t,onOpenChange:x,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Unsaved SEO Changes"}),e.jsxs(a.DialogDescription,{children:['You have unsaved changes in the SEO for "',g,'" version. Do you want to save these changes before switching to "',m,'" version?']})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(a.Button,{variant:"outline",onClick:c,disabled:r,children:"Discard Changes"}),e.jsx(a.Button,{onClick:u,disabled:r,children:r?"Saving...":"Save & Switch"})]})]})})},me=t=>{if(!t)return!0;try{return JSON.parse(t),!0}catch{return!1}},he=(t,x)=>{const u=t.selectionStart||0,c=t.selectionEnd||0,r=t.value,N=r.substring(0,u),p=r.substring(c),g=`{{${x}}}`,m=N+""+g+p,D=u+0+g.length;return{value:m,newCursorPos:D}},Q=()=>{const{t}=P.useTranslation(),[,x]=P.useSidebarActivePanel(),{data:u}=i.useCurrentPage(),{data:c}=i.useBuilderPageData(),{data:r,isFetching:N}=de(),p=r==null?void 0:r.seo,g=v.useRef(null),[m,D]=v.useState("seo"),R=u==null?void 0:u.id,W=u==null?void 0:u.pageType,I=i.usePageType(W),{selectedLang:$,fallbackLang:X}=P.useLanguages(),h=$||X,[H,J]=v.useState(!1),[Z,_]=v.useState(!1),[ee,V]=v.useState(!1),[S,U]=v.useState(null),[n,w]=v.useState({keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"{}",metaOther:"{}",...p}),E=v.useRef({}),{mutate:se,isPending:q}=i.useUpdatePage(),f=q||H||Z,{hasPermission:te}=P.usePermissions(),o=te(i.PAGES_PERMISSIONS.EDIT_SEO),[ae]=i.usePagesProps(),ne=d.get(ae,"features.canResetSeoToDefault",!1),z=!$||n.jsonLD!=="{}";v.useEffect(()=>{if(!N&&p&&R){const s={keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"",metaOther:"",...p};w(s),E.current[h]=s}},[N,p,h,R]),v.useEffect(()=>{const s=l=>{const{fromLang:b,toLang:A,switchHandler:y}=l.detail,G=E.current[h];(G?!d.isEqual(G,n):!1)?(U({fromLang:b,toLang:A,switchHandler:y}),V(!0)):y()};return window.addEventListener("seo-language-switch-check",s),()=>{window.removeEventListener("seo-language-switch-check",s)}},[R,n,h]);const oe=async()=>{if(!(!I||!h))try{J(!0);const s=M.getSeoDefaults(I,h),l={...n,keyword:d.get(s,"seo.keyword",""),title:d.get(s,"seo.title",""),description:d.get(s,"seo.description",""),cononicalUrl:d.get(s,"seo.canonicalUrl",""),noIndex:d.get(s,"seo.noIndex",!1),noFollow:d.get(s,"seo.noFollow",!1),ogTitle:d.get(s,"seo.ogTitle",""),ogDescription:d.get(s,"seo.ogDescription","")};w(l),L.toast.success(t("SEO fields reset to defaults"))}catch(s){L.toast.error(t("Failed to reset SEO fields")),console.error("Reset SEO error:",s)}finally{J(!1)}},le=async()=>{if(!(!I||!h))try{_(!0);const s=M.getSeoDefaults(I,h),l={...n,jsonLD:d.get(s,"seo.jsonLD","")};w(l),L.toast.success(t("JSON-LD reset to default"))}catch(s){L.toast.error(t("Failed to reset JSON-LD")),console.error("Reset JSON-LD error:",s)}finally{_(!1)}},re=async()=>{if(!(!I||!h))try{J(!0);const s=M.getSeoDefaults(I,h),l={...n,ogTitle:d.get(s,"seo.ogTitle",""),ogDescription:d.get(s,"seo.ogDescription",""),ogImage:d.get(s,"seo.ogImage",""),ogImageId:d.get(s,"seo.ogImageId",""),metaOther:d.get(s,"seo.metaOther","{}")};w(l),L.toast.success(t("Meta Tag fields reset to defaults"))}catch(s){L.toast.error(t("Failed to reset Meta Tag fields")),console.error("Reset Meta Tag error:",s)}finally{J(!1)}},Y=async()=>{se({id:r==null?void 0:r.id,seo:n,primaryPage:R},{onSuccess:()=>{console.log("SEO & JSON-LD updated successfully",n),E.current[h]=n,L.toast.success("SEO & JSON-LD updated successfully")}})},O=(s,l)=>{const b=document.getElementById(l);if(b){const{value:A,newCursorPos:y}=he(b,s);g.current={id:l,position:y},b.tagName.toLowerCase()==="input"?(b.value=A,w(C=>({...C,[b.name]:A})),b.focus(),b.setSelectionRange(y,y),[0,10,50,100,200].forEach(C=>{setTimeout(()=>{const B=document.getElementById(l);B&&(B.focus(),B.setSelectionRange(y,y))},C)})):(w(T=>({...T,[b.name]:A})),requestAnimationFrame(()=>{const T=document.getElementById(l);T&&(T.focus(),T.setSelectionRange(y,y),setTimeout(()=>{const C=document.getElementById(l);C&&(C.focus(),C.setSelectionRange(y,y))},50))}))}},j=s=>{const l={...n,[s.target.name]:s.target.name==="noIndex"||s.target.name==="noFollow"?s.target.checked:s.target.value};w(l)},k=s=>l=>{d.isEmpty(l.fieldValue)||j({target:{name:s,value:typeof l.fieldValue=="string"?l.fieldValue.replace(/^"(.*)"$/,"$1"):l.fieldValue}}),l.error&&L.toast.error(e.jsxs("div",{children:[e.jsx("h2",{children:"Failed to generate:"}),e.jsx("p",{children:l.error})]}))},ie=()=>{const s=d.get(u,"seo.jsonLD","{}");if((s==null?void 0:s.trim())==="{}"){L.toast.error("Default page JSON-LD is empty");return}j({target:{name:"jsonLD",value:s}})};return e.jsxs("div",{className:"relative flex h-full flex-col","data-panel-id":"seo",children:[!o&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center backdrop-blur-sm",children:e.jsx(a.Alert,{variant:"default",className:"w-[80%] max-w-md text-xs",children:e.jsx(a.AlertDescription,{children:t("You don't have permission to edit SEO settings. Contact your administrator for access.")})})}),e.jsxs("div",{className:"no-scrollbar flex-grow overflow-y-auto px-2 pb-20",children:[e.jsxs("div",{className:"mb-4 flex w-full items-center justify-between rounded-md bg-gray-100 px-2 py-1 text-left text-sm",children:[e.jsxs("span",{children:[e.jsx("div",{className:"font-medium",children:r==null?void 0:r.name}),e.jsx("span",{className:"font-mono text-xs leading-tight text-gray-500",children:r==null?void 0:r.slug})]}),e.jsx(i.LanguageSwitcher,{variant:"outline",showAdd:!1})]}),e.jsx("form",{className:"space-y-8",children:e.jsxs(a.Tabs,{value:m,onValueChange:D,className:"w-full",children:[e.jsxs(a.TabsList,{className:"mb-4 grid w-full grid-cols-3",children:[e.jsx(a.TabsTrigger,{value:"seo",children:t("SEO")}),e.jsx(a.TabsTrigger,{value:"opengraph",children:t("Meta Tags")}),e.jsx(a.TabsTrigger,{value:"jsonld",children:t("JSON-LD")})]}),e.jsx("div",{className:m==="seo"?"":"sr-only",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"keyword",children:t("Keyword")}),o&&e.jsx(i.NestedPathSelector,{dataType:"value",data:c??{},onSelect:s=>O(s,"keyword")})]}),e.jsx(a.Input,{type:"text",id:"keyword",name:"keyword",value:n.keyword,onChange:j,disabled:f||!o,placeholder:t("Enter keyword"),readOnly:!o})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"title",children:t("SEO Title")}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(F,{keyword:n.keyword,onComplete:k("title"),field:"title"}),o&&e.jsx(i.NestedPathSelector,{dataType:"value",data:c??{},onSelect:s=>O(s,"title")})]})]}),e.jsx(a.Input,{type:"text",id:"title",name:"title",value:n.title,onChange:j,disabled:f||!o,placeholder:t("Enter SEO title"),readOnly:!o})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"description",children:t("SEO Description")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{keyword:n.keyword,onComplete:k("description"),field:"description"}),o&&e.jsx(i.NestedPathSelector,{data:c??{},onSelect:s=>O(s,"description")})]})]}),e.jsx(a.Textarea,{id:"description",name:"description",rows:5,value:n.description,onChange:j,disabled:f||!o,placeholder:t("Enter SEO description"),readOnly:!o})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"title",children:t("Canonical URL")}),o&&e.jsx(i.NestedPathSelector,{dataType:"value",data:c??{},onSelect:s=>O(s,"canonicalUrl")})]}),e.jsx(a.Input,{type:"text",id:"canonicalUrl",name:"canonicalUrl",value:n.canonicalUrl,onChange:j,disabled:f||!o,placeholder:t("Enter Canonical URL"),readOnly:!o})]}),e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(a.Input,{type:"checkbox",id:"noIndex",name:"noIndex",checked:n.noIndex,onChange:j,disabled:f||!o,className:"h-4 w-4"}),e.jsx(a.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:t("No Index")})]}),e.jsx("p",{className:"mt-0 text-[10px] font-light leading-4 text-gray-400",children:t("Check this if you don't want search engines to index this page.")})]}),e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(a.Input,{type:"checkbox",id:"noFollow",name:"noFollow",checked:n.noFollow,onChange:j,disabled:f||!o,className:"h-4 w-4"}),e.jsx(a.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:t("No Follow")})]}),e.jsx("p",{className:"text-[10px] font-light leading-4 text-gray-400",children:t("Check this if you don't want search engines to follow links on this page.")})]})]})}),e.jsx("div",{className:m==="opengraph"?"":"sr-only",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"mb-4 font-semibold text-slate-700",children:t("Open Graph")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"ogTitle",children:t("OG Title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{keyword:n.keyword,onComplete:k("ogTitle"),field:"ogTitle"}),o&&e.jsx(i.NestedPathSelector,{dataType:"value",data:c??{},onSelect:s=>O(s,"ogTitle")})]})]}),e.jsx(a.Input,{type:"text",id:"ogTitle",name:"ogTitle",value:n.ogTitle,onChange:j,disabled:f||!o,placeholder:t("Enter OG title"),readOnly:!o})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"ogDescription",children:t("OG Description")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{keyword:n.keyword,onComplete:k("ogDescription"),field:"ogDescription"}),o&&e.jsx(i.NestedPathSelector,{dataType:"value",data:c??{},onSelect:s=>O(s,"ogDescription")})]})]}),e.jsx(a.Textarea,{id:"ogDescription",name:"ogDescription",rows:5,value:n.ogDescription,onChange:j,disabled:f||!o,placeholder:t("Enter OG description"),readOnly:!o})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"ogImage",children:t("OG Image")}),o&&e.jsx(i.NestedPathSelector,{dataType:"value",data:c??{},onSelect:s=>{w({...n,ogImage:`{{${s}}}`,ogImageId:""})}})]}),e.jsx(i.ImagePicker,{assetId:n.ogImageId,assetUrl:n.ogImage,onChange:s=>{w({...n,ogImage:s.url,ogImageId:s.id})},disabled:f||!o,placeholder:t("Select OG image"),className:"mb-2"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"metaOther",children:t("Meta Tags")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(F,{keyword:n.keyword,onComplete:k("metaOther"),field:"metaOther"})})]}),e.jsx(i.SmartJsonInput,{id:"metaOther",value:n.metaOther,onChange:s=>{j({target:{name:"metaOther",value:s}})},placeholder:t("Enter Meta Tags JSON"),disabled:f||!o,readOnly:!o,pageData:c||{},rows:8,handleFieldInsert:O})]})]})]})})}),e.jsx("div",{className:m==="jsonld"?"":"sr-only",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{className:"text-xs",htmlFor:"jsonLD",children:t("JSON-LD")}),z&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(F,{keyword:n.keyword,onComplete:k("jsonLD"),field:"jsonLD"})})]}),e.jsx("div",{className:"hidden",children:JSON.stringify(c)}),e.jsx(i.SmartJsonInput,{id:"jsonLD",value:n.jsonLD,onChange:s=>{j({target:{name:"jsonLD",value:s}})},placeholder:t("Enter JSON-LD"),disabled:f||!o,readOnly:!o,pageData:c||{},rows:12,handleFieldInsert:O,hasJsonLdForSelectedLang:z,copyJsonLDFromDefaultPage:ie})]})})})]})})]}),o&&e.jsxs("div",{className:"fixed bottom-0 left-0 right-0 flex w-full flex-shrink-0 items-center justify-between border-t bg-background p-4",children:[ne?e.jsx(a.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>{m==="jsonld"?le():m==="opengraph"?re():oe()},disabled:f||!o||!I,children:t(H?"Resetting...":`Reset to ${m==="jsonld"?"Default JSON-LD":m==="opengraph"?"Default Open Graph":"Default SEO"}`)}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(a.Button,{onClick:Y,disabled:!me(n==null?void 0:n.jsonLD)||(E.current[h]?d.isEqual(E.current[h],n):!1)||f||!o,children:t(q?"Saving...":"Save")}),e.jsx(a.Button,{variant:"link",className:"text-gray-500 hover:text-gray-700",onClick:()=>x("outline"),children:t("Cancel")})]})]}),e.jsx(ge,{isOpen:ee,onClose:()=>{V(!1),U(null)},onSave:async()=>{S&&(await Y(),S.switchHandler(),V(!1),U(null))},onDiscard:()=>{if(S){const s=E.current[h];s&&w(s),S.switchHandler(),V(!1),U(null)}},isSaving:q,fromLanguage:(S==null?void 0:S.fromLang)||h,toLanguage:(S==null?void 0:S.toLang)||""})]})};Q.displayName="SeoPanel";exports.default=Q;
@@ -1,6 +1,6 @@
1
1
  import { jsx as e, jsxs as s } from "react/jsx-runtime";
2
- import { g as ye, al as ve, ak as xe, A as Ne, L as Z, am as we, aC as Se, aD as De, d as be, aw as Oe, aE as Le, aF as Ce, aG as E, aH as Ie, aI as ee } from "./index-DFvsMFVH.js";
3
- import { useLanguages as z, useTranslation as ke, useSidebarActivePanel as Ee, usePermissions as Te } from "@chaibuilder/sdk";
2
+ import { g as ye, am as ve, al as xe, A as Ne, L as Z, aq as we, aF as Se, aG as De, d as be, as as Oe, aH as Le, aI as Ie, aJ as T, aK as Ce, aL as ee } from "./index-CguzNa4U.js";
3
+ import { useLanguages as z, useTranslation as ke, useSidebarActivePanel as Te, usePermissions as Ee } from "@chaibuilder/sdk";
4
4
  import { find as Fe, get as h, isEqual as te, isEmpty as je } from "lodash-es";
5
5
  import { useMemo as Re, useRef as ae, useState as j, useEffect as se } from "react";
6
6
  import { Button as P, Dialog as Ae, DialogContent as Pe, DialogHeader as Je, DialogTitle as Ve, DialogDescription as Ue, Alert as Ge, AlertDescription as Me, Tabs as Be, TabsList as $e, TabsTrigger as q, Label as N, Input as R, Textarea as ne } from "@chaibuilder/sdk/ui";
@@ -11,7 +11,7 @@ import { g as _ } from "./get-seo-defaults-9zHebckY.js";
11
11
  const ze = () => {
12
12
  const { selectedLang: a } = z(), { data: u, isFetching: c } = ye();
13
13
  return { data: Re(() => Fe(u, { lang: a || "" }) || {}, [u, a]), isFetching: c };
14
- }, Ye = () => {
14
+ }, Ke = () => {
15
15
  var p;
16
16
  const u = (p = document.getElementById("canvas-iframe").contentDocument) == null ? void 0 : p.body.innerHTML;
17
17
  if (!u) return null;
@@ -28,7 +28,7 @@ const ze = () => {
28
28
  }) => {
29
29
  const i = ve(), r = xe(), { selectedLang: x, fallbackLang: p } = z(), { mutate: d, isPending: m } = He({
30
30
  mutationFn: async () => {
31
- const b = Ye();
31
+ const b = Ke();
32
32
  return await i(r, {
33
33
  action: Ne.GENERATE_SEO_FIELD,
34
34
  data: {
@@ -60,7 +60,7 @@ const ze = () => {
60
60
  children: m ? /* @__PURE__ */ e(qe, { className: "h-3 w-3 animate-spin text-yellow-500" }) : /* @__PURE__ */ e(_e, { className: "text-yellow-500" })
61
61
  }
62
62
  );
63
- }, Ke = ({
63
+ }, Ye = ({
64
64
  isOpen: a,
65
65
  onClose: u,
66
66
  onSave: c,
@@ -101,7 +101,7 @@ const ze = () => {
101
101
  newCursorPos: b
102
102
  };
103
103
  }, Xe = () => {
104
- const { t: a } = ke(), [, u] = Ee(), { data: c } = we(), { data: i } = Se(), { data: r, isFetching: x } = ze(), p = r == null ? void 0 : r.seo, d = ae(null), [m, b] = j("seo"), J = c == null ? void 0 : c.id, oe = c == null ? void 0 : c.pageType, C = De(oe), { selectedLang: Y, fallbackLang: le } = z(), g = Y || le, [K, U] = j(!1), [re, W] = j(!1), [ie, G] = j(!1), [w, M] = j(null), [n, S] = j({
104
+ const { t: a } = ke(), [, u] = Te(), { data: c } = we(), { data: i } = Se(), { data: r, isFetching: x } = ze(), p = r == null ? void 0 : r.seo, d = ae(null), [m, b] = j("seo"), J = c == null ? void 0 : c.id, oe = c == null ? void 0 : c.pageType, I = De(oe), { selectedLang: K, fallbackLang: le } = z(), g = K || le, [Y, U] = j(!1), [re, W] = j(!1), [ie, G] = j(!1), [w, M] = j(null), [n, S] = j({
105
105
  keyword: "",
106
106
  title: "",
107
107
  description: "",
@@ -117,7 +117,7 @@ const ze = () => {
117
117
  jsonLD: "{}",
118
118
  metaOther: "{}",
119
119
  ...p
120
- }), T = ae({}), { mutate: ce, isPending: B } = be(), f = B || K || re, { hasPermission: de } = Te(), o = de(Oe.EDIT_SEO), [me] = Le(), he = h(me, "features.canResetSeoToDefault", !1), Q = !Y || n.jsonLD !== "{}";
120
+ }), E = ae({}), { mutate: ce, isPending: B } = be(), f = B || Y || re, { hasPermission: de } = Ee(), o = de(Oe.EDIT_SEO), [me] = Le(), he = h(me, "features.canResetSeoToDefault", !1), Q = !K || n.jsonLD !== "{}";
121
121
  se(() => {
122
122
  if (!x && p && J) {
123
123
  const t = {
@@ -137,11 +137,11 @@ const ze = () => {
137
137
  metaOther: "",
138
138
  ...p
139
139
  };
140
- S(t), T.current[g] = t;
140
+ S(t), E.current[g] = t;
141
141
  }
142
142
  }, [x, p, g, J]), se(() => {
143
143
  const t = (l) => {
144
- const { fromLang: D, toLang: V, switchHandler: v } = l.detail, $ = T.current[g];
144
+ const { fromLang: D, toLang: V, switchHandler: v } = l.detail, $ = E.current[g];
145
145
  ($ ? !te($, n) : !1) ? (M({ fromLang: D, toLang: V, switchHandler: v }), G(!0)) : v();
146
146
  };
147
147
  return window.addEventListener("seo-language-switch-check", t), () => {
@@ -149,10 +149,10 @@ const ze = () => {
149
149
  };
150
150
  }, [J, n, g]);
151
151
  const ge = async () => {
152
- if (!(!C || !g))
152
+ if (!(!I || !g))
153
153
  try {
154
154
  U(!0);
155
- const t = _(C, g), l = {
155
+ const t = _(I, g), l = {
156
156
  ...n,
157
157
  keyword: h(t, "seo.keyword", ""),
158
158
  title: h(t, "seo.title", ""),
@@ -171,10 +171,10 @@ const ze = () => {
171
171
  U(!1);
172
172
  }
173
173
  }, ue = async () => {
174
- if (!(!C || !g))
174
+ if (!(!I || !g))
175
175
  try {
176
176
  W(!0);
177
- const t = _(C, g), l = {
177
+ const t = _(I, g), l = {
178
178
  ...n,
179
179
  jsonLD: h(t, "seo.jsonLD", "")
180
180
  };
@@ -185,10 +185,10 @@ const ze = () => {
185
185
  W(!1);
186
186
  }
187
187
  }, pe = async () => {
188
- if (!(!C || !g))
188
+ if (!(!I || !g))
189
189
  try {
190
190
  U(!0);
191
- const t = _(C, g), l = {
191
+ const t = _(I, g), l = {
192
192
  ...n,
193
193
  ogTitle: h(t, "seo.ogTitle", ""),
194
194
  ogDescription: h(t, "seo.ogDescription", ""),
@@ -207,7 +207,7 @@ const ze = () => {
207
207
  { id: r == null ? void 0 : r.id, seo: n, primaryPage: J },
208
208
  {
209
209
  onSuccess: () => {
210
- console.log("SEO & JSON-LD updated successfully", n), T.current[g] = n, O.success("SEO & JSON-LD updated successfully");
210
+ console.log("SEO & JSON-LD updated successfully", n), E.current[g] = n, O.success("SEO & JSON-LD updated successfully");
211
211
  }
212
212
  }
213
213
  );
@@ -226,12 +226,12 @@ const ze = () => {
226
226
  const H = document.getElementById(l);
227
227
  H && (H.focus(), H.setSelectionRange(v, v));
228
228
  }, k);
229
- })) : (S((I) => ({
230
- ...I,
229
+ })) : (S((C) => ({
230
+ ...C,
231
231
  [D.name]: V
232
232
  })), requestAnimationFrame(() => {
233
- const I = document.getElementById(l);
234
- I && (I.focus(), I.setSelectionRange(v, v), setTimeout(() => {
233
+ const C = document.getElementById(l);
234
+ C && (C.focus(), C.setSelectionRange(v, v), setTimeout(() => {
235
235
  const k = document.getElementById(l);
236
236
  k && (k.focus(), k.setSelectionRange(v, v));
237
237
  }, 50));
@@ -271,7 +271,7 @@ const ze = () => {
271
271
  /* @__PURE__ */ e("div", { className: "font-medium", children: r == null ? void 0 : r.name }),
272
272
  /* @__PURE__ */ e("span", { className: "font-mono text-xs leading-tight text-gray-500", children: r == null ? void 0 : r.slug })
273
273
  ] }),
274
- /* @__PURE__ */ e(Ce, { variant: "outline", showAdd: !1 })
274
+ /* @__PURE__ */ e(Ie, { variant: "outline", showAdd: !1 })
275
275
  ] }),
276
276
  /* @__PURE__ */ e("form", { className: "space-y-8", children: /* @__PURE__ */ s(Be, { value: m, onValueChange: b, className: "w-full", children: [
277
277
  /* @__PURE__ */ s($e, { className: "mb-4 grid w-full grid-cols-3", children: [
@@ -284,7 +284,7 @@ const ze = () => {
284
284
  /* @__PURE__ */ s("div", { className: "flex items-center justify-between", children: [
285
285
  /* @__PURE__ */ e(N, { className: "text-xs", htmlFor: "keyword", children: a("Keyword") }),
286
286
  o && /* @__PURE__ */ e(
287
- E,
287
+ T,
288
288
  {
289
289
  dataType: "value",
290
290
  data: i ?? {},
@@ -312,7 +312,7 @@ const ze = () => {
312
312
  /* @__PURE__ */ s("div", { className: "flex items-center justify-end gap-2", children: [
313
313
  /* @__PURE__ */ e(A, { keyword: n.keyword, onComplete: F("title"), field: "title" }),
314
314
  o && /* @__PURE__ */ e(
315
- E,
315
+ T,
316
316
  {
317
317
  dataType: "value",
318
318
  data: i ?? {},
@@ -348,7 +348,7 @@ const ze = () => {
348
348
  }
349
349
  ),
350
350
  o && /* @__PURE__ */ e(
351
- E,
351
+ T,
352
352
  {
353
353
  data: i ?? {},
354
354
  onSelect: (t) => L(t, "description")
@@ -374,7 +374,7 @@ const ze = () => {
374
374
  /* @__PURE__ */ s("div", { className: "flex items-center justify-between", children: [
375
375
  /* @__PURE__ */ e(N, { className: "text-xs", htmlFor: "title", children: a("Canonical URL") }),
376
376
  o && /* @__PURE__ */ e(
377
- E,
377
+ T,
378
378
  {
379
379
  dataType: "value",
380
380
  data: i ?? {},
@@ -449,7 +449,7 @@ const ze = () => {
449
449
  }
450
450
  ),
451
451
  o && /* @__PURE__ */ e(
452
- E,
452
+ T,
453
453
  {
454
454
  dataType: "value",
455
455
  data: i ?? {},
@@ -485,7 +485,7 @@ const ze = () => {
485
485
  }
486
486
  ),
487
487
  o && /* @__PURE__ */ e(
488
- E,
488
+ T,
489
489
  {
490
490
  dataType: "value",
491
491
  data: i ?? {},
@@ -512,7 +512,7 @@ const ze = () => {
512
512
  /* @__PURE__ */ s("div", { className: "flex items-center justify-between", children: [
513
513
  /* @__PURE__ */ e(N, { className: "text-xs", htmlFor: "ogImage", children: a("OG Image") }),
514
514
  o && /* @__PURE__ */ e(
515
- E,
515
+ T,
516
516
  {
517
517
  dataType: "value",
518
518
  data: i ?? {},
@@ -527,7 +527,7 @@ const ze = () => {
527
527
  )
528
528
  ] }),
529
529
  /* @__PURE__ */ e(
530
- Ie,
530
+ Ce,
531
531
  {
532
532
  assetId: n.ogImageId,
533
533
  assetUrl: n.ogImage,
@@ -614,8 +614,8 @@ const ze = () => {
614
614
  onClick: () => {
615
615
  m === "jsonld" ? ue() : m === "opengraph" ? pe() : ge();
616
616
  },
617
- disabled: f || !o || !C,
618
- children: a(K ? "Resetting..." : `Reset to ${m === "jsonld" ? "Default JSON-LD" : m === "opengraph" ? "Default Open Graph" : "Default SEO"}`)
617
+ disabled: f || !o || !I,
618
+ children: a(Y ? "Resetting..." : `Reset to ${m === "jsonld" ? "Default JSON-LD" : m === "opengraph" ? "Default Open Graph" : "Default SEO"}`)
619
619
  }
620
620
  ) : /* @__PURE__ */ e("div", {}),
621
621
  /* @__PURE__ */ s("div", { className: "flex items-center gap-4", children: [
@@ -623,7 +623,7 @@ const ze = () => {
623
623
  P,
624
624
  {
625
625
  onClick: X,
626
- disabled: !We(n == null ? void 0 : n.jsonLD) || (T.current[g] ? te(T.current[g], n) : !1) || f || !o,
626
+ disabled: !We(n == null ? void 0 : n.jsonLD) || (E.current[g] ? te(E.current[g], n) : !1) || f || !o,
627
627
  children: a(B ? "Saving..." : "Save")
628
628
  }
629
629
  ),
@@ -639,7 +639,7 @@ const ze = () => {
639
639
  ] })
640
640
  ] }),
641
641
  /* @__PURE__ */ e(
642
- Ke,
642
+ Ye,
643
643
  {
644
644
  isOpen: ie,
645
645
  onClose: () => {
@@ -650,7 +650,7 @@ const ze = () => {
650
650
  },
651
651
  onDiscard: () => {
652
652
  if (w) {
653
- const t = T.current[g];
653
+ const t = E.current[g];
654
654
  t && S(t), w.switchHandler(), G(!1), M(null);
655
655
  }
656
656
  },
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),E=require("@chaibuilder/sdk"),I=require("@tanstack/react-query"),c=require("./index-CffopOpP.cjs"),s=require("@chaibuilder/sdk/ui"),u=require("lucide-react"),i=require("react"),J=require("sonner"),O=()=>{const d=c.useApiUrl(),h=c.useFetch();return I.useQuery({queryKey:[c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS],queryFn:async()=>h(d,{action:c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS})})},k=({show:d,onClose:h,initialData:x})=>e.jsx(s.Dialog,{open:d,onOpenChange:()=>h(),children:d&&e.jsx(B,{show:d,onClose:h,initialData:x})}),B=({show:d,onClose:h,initialData:x})=>{const[v,g]=i.useState("edit"),[p,n]=i.useState(""),[t,m]=i.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[j,N]=i.useState(!1),{data:l}=c.useCurrentPage(),{mutateAsync:f,isPending:w}=c.useAddGlobalSchema(),{mutateAsync:S}=c.useTogglePageGlobalSchema();i.useEffect(()=>{g("edit"),m(x?{name:x.name,description:x.description,content:JSON.stringify(x.jsonld,null,2),enabledByDefaultForNewPages:!1}:{name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),N(!1)},[d,x]),i.useEffect(()=>{const o=c.parseJSONWithPlaceholders(t.content);n(o.isValid?JSON.stringify(o.parsed,null,2):"")},[t.content]);const y=async()=>{if(!t.name||!t.content){J.toast.error("Please enter a name and content");return}const o=c.parseJSONWithPlaceholders(t.content);if(!o.isValid){J.toast.error("Invalid JSON-LD content");return}const A={name:t.name,jsonld:o.parsed,addToExistingPages:j,addToNewPages:t.enabledByDefaultForNewPages,description:t.description},b=await f(A);l!=null&&l.id&&(b!=null&&b.id)&&await S({schemaId:b.id,pageId:l.id,enabled:!0}),h()};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{children:["Add New Shared JSON-LD Schema",(x==null?void 0:x.languageCode)&&e.jsxs("span",{className:"ml-2 text-sm font-normal text-muted-foreground",children:["(",x.languageCode,")"]})]})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(s.Input,{id:"new-name",value:t.name,onChange:o=>m({...t,name:o.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:t.description||"",onChange:o=>m({...t,description:o.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-content",children:"JSON-LD Content"}),e.jsxs(s.Tabs,{value:v,onValueChange:g,className:"w-full",children:[e.jsxs("div",{className:"mb-2 flex w-full items-center justify-between",children:[e.jsxs(s.TabsList,{className:"w-max",children:[e.jsxs(s.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[e.jsx(u.Code,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]}),e.jsxs(s.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!p,children:[e.jsx(u.Eye,{className:"h-4 w-4"}),e.jsx("span",{children:"Preview"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:v==="edit"&&e.jsx(s.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>m({...t,content:p}),disabled:!p,children:"Format"})})]}),e.jsxs(s.TabsContent,{value:"edit",children:[e.jsx(s.Textarea,{id:"new-content",value:t.content||"{}",onChange:o=>m({...t,content:o.target.value}),className:"font-mono text-sm",placeholder:"Enter JSON-LD markup...",rows:10}),!p&&t.content?e.jsx("p",{className:"pt-px text-xs text-red-500",children:"Invalid JSON-LD"}):e.jsx("p",{})]}),e.jsx(s.TabsContent,{value:"preview",children:e.jsx(s.Textarea,{id:"new-content",value:p||"{}",className:"bg-muted font-mono text-sm",placeholder:"{}",rows:10,readOnly:!0})})]})]}),!x&&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(s.Switch,{id:"add-to-all-existing",checked:j,onCheckedChange:o=>N(o)}),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(s.Switch,{id:"new-enabled",checked:t.enabledByDefaultForNewPages,onCheckedChange:o=>m({...t,enabledByDefaultForNewPages:o})}),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.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(s.Button,{disabled:w,variant:"outline",type:"button",size:"sm",onClick:()=>h(),children:"Cancel"}),e.jsx(s.Button,{disabled:w||!p,type:"button",size:"sm",onClick:y,children:w?e.jsxs(e.Fragment,{children:[e.jsx(u.Loader,{className:"h-4 w-4 animate-spin"})," Adding"]}):"Add Schema"})]})]})]})]})},G=({id:d,onClose:h})=>e.jsx(s.Dialog,{open:!!d,onOpenChange:()=>h(),children:d&&e.jsx(z,{id:d,onClose:h})}),z=({id:d,onClose:h})=>{const[x,v]=i.useState("edit"),[g,p]=i.useState(""),[n,t]=i.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[m,j]=i.useState(!1),[N,l]=i.useState(!1),{data:f}=O(),{mutateAsync:w,isPending:S}=c.useUpdateGlobalSchema(),{mutateAsync:y}=c.useApplySchemaToAllPages(),{mutateAsync:o}=c.useRemoveSchemaFromAllPages();i.useEffect(()=>{var r,D;if(v("edit"),d&&f){const a=f.find(T=>T.id===d);a&&t({name:a.name,description:((r=a.metadata)==null?void 0:r.description)||"",content:JSON.stringify(a.jsonld,null,2),enabledByDefaultForNewPages:((D=a.metadata)==null?void 0:D.addToNewPages)||!1})}},[d,f]),i.useEffect(()=>{const r=c.parseJSONWithPlaceholders(n.content);p(r.isValid?JSON.stringify(r.parsed,null,2):"")},[n.content]);const A=async()=>{if(!n.name||!n.content){J.toast.error("Please enter a name and content");return}const r=c.parseJSONWithPlaceholders(n.content);if(!r.isValid){J.toast.error("Invalid JSON-LD content");return}const D={id:d,name:n.name,jsonld:r.parsed,addToNewPages:n.enabledByDefaultForNewPages,description:n.description};await w(D),h()},b=async()=>{try{await y(d)}finally{j(!1)}},C=async()=>{try{await o(d)}finally{l(!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:[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:r=>t({...n,name:r.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:r=>t({...n,description:r.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-content",children:"JSON-LD Content"}),e.jsxs(s.Tabs,{value:x,onValueChange:v,className:"w-full",children:[e.jsxs("div",{className:"mb-2 flex w-full items-center justify-between",children:[e.jsxs(s.TabsList,{className:"w-max",children:[e.jsxs(s.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[e.jsx(u.Code,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]}),e.jsxs(s.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!g,children:[e.jsx(u.Eye,{className:"h-4 w-4"}),e.jsx("span",{children:"Preview"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:x==="edit"&&e.jsx(s.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>t({...n,content:g}),disabled:!g,children:"Format"})})]}),e.jsxs(s.TabsContent,{value:"edit",children:[e.jsx(s.Textarea,{id:"edit-content",value:n.content||"{}",onChange:r=>t({...n,content:r.target.value}),className:"font-mono text-sm",placeholder:"Enter JSON-LD markup...",rows:10}),!g&&n.content?e.jsx("p",{className:"pt-px text-xs text-red-500",children:"Invalid JSON-LD"}):e.jsx("p",{})]}),e.jsx(s.TabsContent,{value:"preview",children:e.jsx(s.Textarea,{id:"edit-content-preview",value:g||"{}",className:"bg-muted font-mono text-sm",placeholder:"{}",rows:10,readOnly:!0})})]})]}),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",variant:"outline",onClick:()=>j(!0),children:"Add to all existing"}),e.jsx(s.Button,{size:"sm",variant:"ghost",onClick:()=>l(!0),children:"Remove from all"})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Switch,{id:"edit-enabled",checked:n.enabledByDefaultForNewPages,onCheckedChange:r=>t({...n,enabledByDefaultForNewPages:r})}),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.jsxs("div",{className:"flex gap-2",children:[e.jsx(s.Button,{disabled:S,variant:"outline",type:"button",size:"sm",onClick:()=>h(),children:"Cancel"}),e.jsx(s.Button,{disabled:S||!g,type:"button",size:"sm",onClick:A,children:S?e.jsxs(e.Fragment,{children:[e.jsx(u.Loader,{className:"h-4 w-4 animate-spin"})," Updating"]}):"Update Schema"})]})]})]}),e.jsx(s.AlertDialog,{open:m,onOpenChange:j,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:b,children:"Add to All"})]})]})}),e.jsx(s.AlertDialog,{open:N,onOpenChange:l,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:C,className:"bg-red-500 hover:bg-red-600",children:"Remove from All"})]})]})})]})};function q(){const[d,h]=i.useState(!1),[x,v]=i.useState(void 0),[g,p]=i.useState(null),[n,t]=i.useState(null),{data:m,isLoading:j}=O(),{selectedLang:N}=E.useLanguages(),{data:l}=c.useCurrentPage(),{data:f}=c.useLanguagePages(),{mutateAsync:w}=c.useDeleteGlobalSchema(),{mutateAsync:S}=c.useTogglePageGlobalSchema(),y=i.useMemo(()=>f==null?void 0:f.find(a=>a.primaryPage===!0),[f]),o=i.useMemo(()=>(y==null?void 0:y.globalJsonLds)||[],[y]),[A,b]=i.useState([]),C=A.length>0?A:(l==null?void 0:l.globalJsonLds)||[];i.useEffect(()=>{l!=null&&l.globalJsonLds&&b(l.globalJsonLds)},[l==null?void 0:l.globalJsonLds]);const r=async a=>{if(!(l!=null&&l.id))return;t(a);const T=C.includes(a),L=T?C.filter(P=>P!==a):[...C,a];b(L);try{await S({schemaId:a,pageId:l.id,enabled:!T})}catch{b(l.globalJsonLds)}finally{t(null)}},D=async a=>{t(a);try{await w(a)}finally{t(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"})]}),!N&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:j,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:a=>{a.stopPropagation(),h(!0)},children:j?e.jsx(u.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(u.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:[(!m||(m==null?void 0:m.length)===0)&&!j&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),m==null?void 0:m.map(a=>{const T=a.jsonld,L=!N,P=C.includes(a.id),F=o.includes(a.id);return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${n===a.id?"pointer-events-none":""}`,children:[n===a.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(u.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:[L&&e.jsx(s.Switch,{checked:P,onCheckedChange:()=>r(a.id)}),e.jsxs("div",{children:[e.jsx(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:a.name}),(a==null?void 0:a.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:a==null?void 0:a.description})]})]}),L&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>p(a.id),children:e.jsx(u.Edit,{className:"h-4 w-4"})}),e.jsxs(s.AlertDialog,{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(u.Trash,{className:"h-4 w-4"})}),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:a.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:()=>D(a.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})}),e.jsx(s.CardContent,{className:"px-2 pb-2",children:L?e.jsx(s.Textarea,{id:a.id,rows:1,readOnly:!0,value:JSON.stringify(T,null,2),className:"no-scrollbar cursor-text overflow-hidden rounded-md border-none bg-gray-100/80 text-xs"}):e.jsxs("div",{className:"flex h-20 w-full flex-col items-center justify-center rounded-lg border bg-gray-100",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"max-w-xl text-center text-xs text-gray-500",children:"Not available in selected language, but available in default language."}),F&&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:()=>{v({name:a.name,description:a.description||"",jsonld:a.jsonld,languageCode:N}),h(!0)},children:"Copy & Edit from default language"})]})})]},a.id)})]}),j&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(u.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(k,{show:d,onClose:()=>{h(!1),v(void 0)},initialData:x}),e.jsx(G,{id:g,onClose:()=>p(null)})]})}exports.default=q;