@chaibuilder/sdk 4.0.0-beta.49 → 4.0.0-beta.51

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 (156) hide show
  1. package/README.md +35 -52
  2. package/dist/{2SSKDMRQ-CjvuNdPo.cjs → 2SSKDMRQ-BSYe_xPq.cjs} +1 -1
  3. package/dist/{2SSKDMRQ-Dvf9zadl.js → 2SSKDMRQ-Dv-C_YAA.js} +3 -3
  4. package/dist/{AP7HFJJL-DYFttFoI.cjs → AP7HFJJL-BJolKJBt.cjs} +1 -1
  5. package/dist/{AP7HFJJL-q4dJdyFs.js → AP7HFJJL-DhdVstVC.js} +1 -1
  6. package/dist/{IconPicker-Bf163F7t.js → IconPicker-BBkl0T8b.js} +13 -13
  7. package/dist/{IconPicker-JWhYq2Gp.cjs → IconPicker-C0WWlb8t.cjs} +1 -1
  8. package/dist/{WDYDFRGG-O9GIrtX0.js → WDYDFRGG-CJs2MxSq.js} +4 -4
  9. package/dist/{WDYDFRGG-BEksfGMC.cjs → WDYDFRGG-DRt6Zg7Q.cjs} +1 -1
  10. package/dist/{actions-registery-BHbZHkE3.cjs → actions-registery-CLL3KrNv.cjs} +2 -2
  11. package/dist/{actions-registery-gJb_wq2F.js → actions-registery-CrGIlqUX.js} +88 -88
  12. package/dist/actions.cjs +1 -1
  13. package/dist/actions.js +2 -2
  14. package/dist/{add-new-language-page-BfUp5Ua2.cjs → add-new-language-page-ByMSfRcN.cjs} +1 -1
  15. package/dist/{add-new-language-page-CRR93tLq.js → add-new-language-page-DtVoDNfI.js} +35 -35
  16. package/dist/{add-new-page-B8NGK6WS.cjs → add-new-page-CnuChfJz.cjs} +1 -1
  17. package/dist/add-new-page-DanzzvYo.js +31 -0
  18. package/dist/{ai-panel-default-lang-BXYQye3N.js → ai-panel-default-lang-BaPz2d_6.js} +35 -35
  19. package/dist/{ai-panel-default-lang-VhgmHFoQ.cjs → ai-panel-default-lang-CoIQSz_Y.cjs} +2 -2
  20. package/dist/{ai-panel-other-lang-DaCf-cq4.js → ai-panel-other-lang--i-5z4e2.js} +22 -22
  21. package/dist/{ai-panel-other-lang-Ds0EXeUC.cjs → ai-panel-other-lang-ChlMVodg.cjs} +1 -1
  22. package/dist/{ai-prompt-input-7iWk72w5.js → ai-prompt-input-BQi0VDJC.js} +77 -77
  23. package/dist/{ai-prompt-input-nZ5_Dm7X.cjs → ai-prompt-input-BT5426AB.cjs} +1 -1
  24. package/dist/{ai-translation-prompt-1OUs1P7n.js → ai-translation-prompt-BN78s33t.js} +8 -8
  25. package/dist/{ai-translation-prompt-B16cK-1Q.cjs → ai-translation-prompt-BQPaekp3.cjs} +1 -1
  26. package/dist/{apply-binding-CBSjMYSk.cjs → apply-binding-Cjh1kqMO.cjs} +1 -1
  27. package/dist/{apply-binding-vAuN-TGV.js → apply-binding-v_W4uR3U.js} +28 -28
  28. package/dist/{plugin-BSjgGgwo.js → chai-theme-helpers-BEf2rwE4.js} +83 -83
  29. package/dist/chai-theme-helpers-q3nwoNht.cjs +22 -0
  30. package/dist/{change-password-modal-D5eXjiYq.cjs → change-password-modal-DHUrrKw7.cjs} +1 -1
  31. package/dist/{change-password-modal-CdvJR1Ln.js → change-password-modal-pEp-nMNb.js} +30 -30
  32. package/dist/{code-display-DdWcOQ_i.js → code-display-BaLKScgW.js} +5 -5
  33. package/dist/{code-display-BR-gij5j.cjs → code-display-i7jb2kmw.cjs} +1 -1
  34. package/dist/{code-editor-CyLjDiEp.js → code-editor-CRoniyP0.js} +12 -12
  35. package/dist/{code-editor-SWbfFj1E.cjs → code-editor-gwFRjQ2_.cjs} +1 -1
  36. package/dist/core.cjs +1 -1
  37. package/dist/core.d.ts +0 -5
  38. package/dist/core.js +49 -49
  39. package/dist/{css-import-modal-Be47CBJn.js → css-import-modal-B3qxX9Iv.js} +14 -14
  40. package/dist/{css-import-modal-Bdwgd05S.cjs → css-import-modal-nAB5FSwn.cjs} +2 -2
  41. package/dist/{delete-page-C99K2qzS.js → delete-page-DbawNFf7.js} +13 -13
  42. package/dist/{delete-page-DLohaU-U.cjs → delete-page-YP1HEAoD.cjs} +1 -1
  43. package/dist/{digital-asset-manager-BZMb6sC7.js → digital-asset-manager-DTD5mf24.js} +388 -357
  44. package/dist/digital-asset-manager-kJnuMqpw.cjs +1 -0
  45. package/dist/{duplicate-page-D5Gtvqdv.cjs → duplicate-page-CxqW_EO7.cjs} +1 -1
  46. package/dist/{duplicate-page-CDc2X0eW.js → duplicate-page-DnRb1y6K.js} +19 -19
  47. package/dist/{dynamic-page-selector-DZHhX008.cjs → dynamic-page-selector-2EqJhUrB.cjs} +1 -1
  48. package/dist/{dynamic-page-selector-DvNBXo6o.js → dynamic-page-selector-D6VLDIN9.js} +17 -17
  49. package/dist/{get-chai-builder-tailwind-config-7CxFxEYL.cjs → get-chai-builder-tailwind-config-DNp8Vhme.cjs} +1 -1
  50. package/dist/{get-chai-builder-tailwind-config-DC4sDOYK.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +3 -3
  51. package/dist/{get-chai-builder-theme-BpuwSLeS.js → get-chai-builder-theme-DLpviqPJ.js} +1 -1
  52. package/dist/get-chai-builder-theme-Du4ARJlw.cjs +1 -0
  53. package/dist/{image-editor-DwhTYkVR.cjs → image-editor-BQcOGsli.cjs} +1 -1
  54. package/dist/{image-editor-BBvvi9Vm.js → image-editor-CMf731xL.js} +15 -15
  55. package/dist/index-BYrRPW_c.cjs +5 -0
  56. package/dist/index-D-r_K4yA.cjs +160 -0
  57. package/dist/{index-OuHV9Ann.js → index-DPV6NiJ-.js} +5894 -6049
  58. package/dist/index-DqzFD1CG.js +4861 -0
  59. package/dist/{mark-as-template-CP_F9ZQ4.js → mark-as-template-D7jqSCXw.js} +28 -28
  60. package/dist/{mark-as-template-B9yLcasI.cjs → mark-as-template-DyB56HzI.cjs} +1 -1
  61. package/dist/{nested-path-selector-content-DmtCI3q9.js → nested-path-selector-content-dwSikrsV.js} +2 -2
  62. package/dist/{nested-path-selector-content-aTdu-o0e.cjs → nested-path-selector-content-g9_Tq_sR.cjs} +1 -1
  63. package/dist/no-language-page-content-BRITuyfN.js +43 -0
  64. package/dist/{no-language-page-content-C-MCdPXt.cjs → no-language-page-content-ZvMNVY-Y.cjs} +1 -1
  65. package/dist/{no-language-page-dialog-D4QIAHnE.cjs → no-language-page-dialog-Cndq8xRP.cjs} +1 -1
  66. package/dist/no-language-page-dialog-D7L9nVb9.js +10 -0
  67. package/dist/page-creator-BAIbU14q.js +652 -0
  68. package/dist/page-creator-qL3-M8g3.cjs +1 -0
  69. package/dist/{page-manager-new-ah6QYar2.cjs → page-manager-new-By3eGO3i.cjs} +1 -1
  70. package/dist/{page-manager-new-ttsrxdW9.js → page-manager-new-YRG89y4f.js} +63 -63
  71. package/dist/page-manager-search-and-filter-BbdgOU9V.cjs +1 -0
  72. package/dist/page-manager-search-and-filter-Cllju4CV.js +184 -0
  73. package/dist/pages.cjs +1 -1
  74. package/dist/pages.d.ts +0 -15
  75. package/dist/pages.js +20 -21
  76. package/dist/{publish-pages-content-KZVMHT6V.js → publish-pages-content-CG5LBUnY.js} +48 -48
  77. package/dist/{publish-pages-content-BrajJUcP.cjs → publish-pages-content-DxMiBxNU.cjs} +1 -1
  78. package/dist/{register-chai-top-bar-DyW9GPzV.cjs → register-chai-top-bar-CCssW5dL.cjs} +1 -1
  79. package/dist/{register-chai-top-bar-D6GjnauV.js → register-chai-top-bar-DWmJ2efT.js} +11 -11
  80. package/dist/render.cjs +1 -1
  81. package/dist/render.js +54 -54
  82. package/dist/{rte-widget-modal-CiTwsXTr.cjs → rte-widget-modal-CsTqFJc_.cjs} +1 -1
  83. package/dist/{rte-widget-modal-IU8JzPuZ.js → rte-widget-modal-DoeTMRtX.js} +2 -2
  84. package/dist/runtime-client.cjs +1 -1
  85. package/dist/runtime-client.js +1 -1
  86. package/dist/runtime.cjs +1 -1
  87. package/dist/runtime.js +1 -1
  88. package/dist/sdk.css +1 -1
  89. package/dist/{selected-block-display-CidmQ-wz.js → selected-block-display-Ck1kkNEi.js} +17 -28
  90. package/dist/{selected-block-display-CAFEOrLV.cjs → selected-block-display-DSow6N4b.cjs} +1 -1
  91. package/dist/seo-panel---mYZmLD.js +559 -0
  92. package/dist/seo-panel-mfX63fua.cjs +1 -0
  93. package/dist/{shared-json-ld-uvMmwCYp.js → shared-json-ld-B3I_RLE2.js} +46 -46
  94. package/dist/{shared-json-ld-CMH-eRUq.cjs → shared-json-ld-CGgwUOlW.cjs} +1 -1
  95. package/dist/{slug-input-DLWTMTsO.js → slug-input-DQ4t3-Tt.js} +5 -5
  96. package/dist/{slug-input-CiHC5l3r.cjs → slug-input-DaNbl597.cjs} +1 -1
  97. package/dist/supabase-actions.cjs +1 -1
  98. package/dist/supabase-actions.js +2 -2
  99. package/dist/types.d.ts +0 -96
  100. package/dist/{unmark-as-template-F7TdgWjI.cjs → unmark-as-template-CZ65AE4v.cjs} +1 -1
  101. package/dist/{unmark-as-template-C5ovsEBP.js → unmark-as-template-DvmoTbVu.js} +11 -11
  102. package/dist/unpublish-page-3--vO5b0.js +28 -0
  103. package/dist/{unpublish-page-CUr8Xub6.cjs → unpublish-page-B46TiWlU.cjs} +1 -1
  104. package/dist/{unpublished-partials-modal-BhNAub_z.js → unpublished-partials-modal-DVMz3q83.js} +18 -15
  105. package/dist/{unpublished-partials-modal-Cv5R9-hi.cjs → unpublished-partials-modal-U5lKBOSR.cjs} +1 -1
  106. package/dist/utils.cjs +1 -1
  107. package/dist/utils.js +2 -2
  108. package/dist/web-blocks.cjs +1 -1
  109. package/dist/web-blocks.js +2 -2
  110. package/dist/{web-preview-D9pXonAv.js → web-preview-D5o5XQo0.js} +2 -2
  111. package/dist/{web-preview-CuMYekVJ.cjs → web-preview-Da3RhcjQ.cjs} +1 -1
  112. package/package.json +1 -1
  113. package/dist/active-in-another-tab-B4Ur0JP7.js +0 -35
  114. package/dist/active-in-another-tab-BPdx4lWh.cjs +0 -1
  115. package/dist/add-new-page-Ppy5-y5j.js +0 -31
  116. package/dist/continue-editing-in-this-client-BrSvK-Ay.js +0 -25
  117. package/dist/continue-editing-in-this-client-Cmi-GkYZ.cjs +0 -1
  118. package/dist/design-token-usage-D1lWCJ3L.js +0 -114
  119. package/dist/design-token-usage-eY2wQ0l3.cjs +0 -1
  120. package/dist/digital-asset-manager-Z5aJxkq0.cjs +0 -1
  121. package/dist/get-chai-builder-theme-B5RkBTsB.cjs +0 -1
  122. package/dist/image-compression-DPFITwOL.js +0 -37
  123. package/dist/image-compression-UaU7Bwqe.cjs +0 -1
  124. package/dist/index-BVwFJWDq.cjs +0 -5
  125. package/dist/index-DCJDQs1a.cjs +0 -160
  126. package/dist/index-LBTm1Jmk.js +0 -5199
  127. package/dist/json-diff-viewer-Cb1CmRqP.cjs +0 -8
  128. package/dist/json-diff-viewer-DG6qMOBS.js +0 -261
  129. package/dist/lang-panel-B3USOxGq.js +0 -216
  130. package/dist/lang-panel-DxoJ0v4y.cjs +0 -1
  131. package/dist/manage-design-tokens-6YGIctip.js +0 -446
  132. package/dist/manage-design-tokens-modal-BSSCXH8Y.cjs +0 -1
  133. package/dist/manage-design-tokens-modal-CzsnN49F.js +0 -161
  134. package/dist/manage-design-tokens-udLBvkHA.cjs +0 -1
  135. package/dist/no-language-page-content-D8t5dfgh.js +0 -43
  136. package/dist/no-language-page-dialog-C_fHI2zI.js +0 -10
  137. package/dist/page-creator-Cz_ah-qE.cjs +0 -1
  138. package/dist/page-creator-DKEkuGCO.js +0 -796
  139. package/dist/page-lock-CwZKJ4IE.js +0 -30
  140. package/dist/page-lock-DdCvtA-I.cjs +0 -1
  141. package/dist/page-locked-dialog-CrTDBoC4.cjs +0 -1
  142. package/dist/page-locked-dialog-DqLlooUz.js +0 -136
  143. package/dist/page-manager-search-and-filter-D7AupT6_.cjs +0 -1
  144. package/dist/page-manager-search-and-filter-bsqZ6wnI.js +0 -210
  145. package/dist/page-revisions-content-B6hsIla7.cjs +0 -1
  146. package/dist/page-revisions-content-C5O8_Fms.js +0 -459
  147. package/dist/plugin-DHpuZZXz.cjs +0 -22
  148. package/dist/save-to-lib-DMnv7ENo.js +0 -429
  149. package/dist/save-to-lib-Dc700Aop.cjs +0 -1
  150. package/dist/seo-panel-Br8gxDxu.js +0 -789
  151. package/dist/seo-panel-CMY-adM-.cjs +0 -2
  152. package/dist/take-over-request-IRLgF1dG.cjs +0 -1
  153. package/dist/take-over-request-KdR1_h_K.js +0 -64
  154. package/dist/translation-warning-modal-CLZ9tC1F.cjs +0 -1
  155. package/dist/translation-warning-modal-CzNt6LDO.js +0 -27
  156. package/dist/unpublish-page-0fR1o0b7.js +0 -28
@@ -1,15 +1,15 @@
1
1
  import { jsx as e, jsxs as n, Fragment as j } from "react/jsx-runtime";
2
- import { D as $, e as W, f as Y, g as X, p as y, a1 as U, a2 as _, at as R, a3 as M, a4 as q, au as H, a5 as K, a6 as Q, d as me, z as L, A as J, E as F, a7 as he, J as ue, K as ge, M as fe, av as pe, O as xe, T as Ne } from "./index-OuHV9Ann.js";
3
- import { D as be, F as ye, z as G, B as v } from "./register-chai-top-bar-D6GjnauV.js";
4
- import { aq as ve, ar as we, A as V, av as le, aD as Ae, aE as se, aF as re, aG as de, aH as Se, aI as Ce, aJ as Pe, j as Te, aK as De } from "./index-LBTm1Jmk.js";
5
- import { useQuery as Ee, useQueryClient as Le } from "@tanstack/react-query";
6
- import { filter as Je, find as Fe } from "lodash-es";
7
- import { Info as Oe, Loader as O, Plus as ke, Eye as je, Edit as Ge, Trash as Be } from "lucide-react";
8
- import { useState as g, useEffect as Z, useMemo as z } from "react";
2
+ import { filter as me, find as he } from "lodash-es";
3
+ import { Info as ue, Loader as O, Plus as ge, Eye as fe, Edit as pe, Trash as xe } from "lucide-react";
4
+ import { useState as g, useEffect as $, useMemo as z } from "react";
5
+ import { D as W, e as Y, f as X, g as Z, p as y, a0 as U, a1 as _, a2 as R, a3 as M, a4 as q, a5 as H, a6 as K, a7 as Q, d as Ne, F as L, G as J, H as F, a8 as be, I as ye, J as ve, K as we, a9 as Ae, M as Ce, T as Se } from "./index-DPV6NiJ-.js";
6
+ import { D as Pe, E as Te, z as G, B as v } from "./register-chai-top-bar-DWmJ2efT.js";
7
+ import { ai as De, aj as Ee, ag as V, aq as le, ay as Le, az as se, ax as re, aA as de, aB as Je, aC as Fe, aD as Oe, g as ke, aE as je } from "./index-DqzFD1CG.js";
8
+ import { useQuery as Ge, useQueryClient as Be } from "@tanstack/react-query";
9
9
  import { toast as B } from "sonner";
10
10
  const oe = () => {
11
- const t = ve(), i = we();
12
- return Ee({
11
+ const t = De(), i = Ee();
12
+ return Ge({
13
13
  queryKey: [V.GET_GLOBAL_JSONLD_ITEMS],
14
14
  queryFn: async () => i(t, { action: V.GET_GLOBAL_JSONLD_ITEMS })
15
15
  });
@@ -17,7 +17,7 @@ const oe = () => {
17
17
  show: t,
18
18
  onClose: i,
19
19
  initialData: a
20
- }) => /* @__PURE__ */ e($, { open: t, onOpenChange: () => i(), children: t && /* @__PURE__ */ e(ze, { show: t, onClose: i, initialData: a }) }), ze = ({
20
+ }) => /* @__PURE__ */ e(W, { open: t, onOpenChange: () => i(), children: t && /* @__PURE__ */ e(ze, { show: t, onClose: i, initialData: a }) }), ze = ({
21
21
  show: t,
22
22
  onClose: i,
23
23
  initialData: a
@@ -27,14 +27,14 @@ const oe = () => {
27
27
  content: "",
28
28
  description: "",
29
29
  enabledByDefaultForNewPages: !1
30
- }), [x, C] = g(!1), { data: u } = le(), { mutateAsync: S, isPending: p } = Ae(), { mutateAsync: c } = se(), w = Le();
31
- Z(() => {
30
+ }), [x, S] = g(!1), { data: u } = le(), { mutateAsync: C, isPending: p } = Le(), { mutateAsync: c } = se(), w = Be();
31
+ $(() => {
32
32
  f(a ? {
33
33
  name: a.name,
34
34
  description: a.description,
35
35
  content: JSON.stringify(a.jsonld, null, 2),
36
36
  enabledByDefaultForNewPages: !1
37
- } : { name: "", description: "", content: "", enabledByDefaultForNewPages: !1 }), C(!1);
37
+ } : { name: "", description: "", content: "", enabledByDefaultForNewPages: !1 }), S(!1);
38
38
  }, [t, a]);
39
39
  const o = async () => {
40
40
  if (!d.name || !d.content) {
@@ -54,7 +54,7 @@ const oe = () => {
54
54
  description: d.description
55
55
  };
56
56
  a != null && a.primaryPageId && (N.primaryPage = a.primaryPageId);
57
- const A = await S(N);
57
+ const A = await C(N);
58
58
  u != null && u.id && (A != null && A.id) && !(a != null && a.primaryPageId) && (await c({
59
59
  schemaId: A.id,
60
60
  pageId: u.id,
@@ -63,12 +63,12 @@ const oe = () => {
63
63
  queryKey: [V.GET_LANGUAGE_PAGES, u.id]
64
64
  })), i();
65
65
  };
66
- return /* @__PURE__ */ n(W, { className: "flex max-w-xl flex-col overflow-y-auto", children: [
67
- /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ e(X, { children: "Add New Shared JSON-LD Schema" }) }),
66
+ return /* @__PURE__ */ n(Y, { className: "flex max-w-xl flex-col overflow-y-auto", children: [
67
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(Z, { children: "Add New Shared JSON-LD Schema" }) }),
68
68
  /* @__PURE__ */ n("div", { className: "flex max-h-[75vh] flex-col space-y-2 overflow-y-auto", children: [
69
- (a == null ? void 0 : a.languageCode) && /* @__PURE__ */ n(be, { className: "border-blue-200 bg-blue-50", children: [
70
- /* @__PURE__ */ e(Oe, { className: "h-4 w-4 text-blue-600" }),
71
- /* @__PURE__ */ n(ye, { className: "text-sm text-blue-800", children: [
69
+ (a == null ? void 0 : a.languageCode) && /* @__PURE__ */ n(Pe, { className: "border-blue-200 bg-blue-50", children: [
70
+ /* @__PURE__ */ e(ue, { className: "h-4 w-4 text-blue-600" }),
71
+ /* @__PURE__ */ n(Te, { className: "text-sm text-blue-800", children: [
72
72
  "You are creating a ",
73
73
  /* @__PURE__ */ e("span", { className: "font-semibold", children: a.languageCode }),
74
74
  " language version of this schema. This will be linked to the default language schema."
@@ -120,7 +120,7 @@ const oe = () => {
120
120
  type: "checkbox",
121
121
  id: "add-to-all-existing",
122
122
  checked: x,
123
- onChange: (l) => C(l.target.checked),
123
+ onChange: (l) => S(l.target.checked),
124
124
  className: "h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"
125
125
  }
126
126
  ),
@@ -158,14 +158,14 @@ const oe = () => {
158
158
  ] }) })
159
159
  ] })
160
160
  ] });
161
- }, Ue = ({ id: t, onClose: i }) => /* @__PURE__ */ e($, { open: !!t, onOpenChange: () => i(), children: t && /* @__PURE__ */ e(_e, { id: t, onClose: i }) }), _e = ({ id: t, onClose: i }) => {
161
+ }, Ue = ({ id: t, onClose: i }) => /* @__PURE__ */ e(W, { open: !!t, onOpenChange: () => i(), children: t && /* @__PURE__ */ e(_e, { id: t, onClose: i }) }), _e = ({ id: t, onClose: i }) => {
162
162
  const [a, d] = g({
163
163
  name: "",
164
164
  content: "",
165
165
  description: "",
166
166
  enabledByDefaultForNewPages: !1
167
- }), [f, x] = g(!1), [C, u] = g(!1), [S, p] = g(!1), { data: c } = oe(), { mutateAsync: w, isPending: o } = Se(), { mutateAsync: l } = Ce(), { mutateAsync: N } = Pe();
168
- Z(() => {
167
+ }), [f, x] = g(!1), [S, u] = g(!1), [C, p] = g(!1), { data: c } = oe(), { mutateAsync: w, isPending: o } = Je(), { mutateAsync: l } = Fe(), { mutateAsync: N } = Oe();
168
+ $(() => {
169
169
  var m, T;
170
170
  if (t && c) {
171
171
  const b = c.find((E) => E.id === t);
@@ -208,10 +208,10 @@ const oe = () => {
208
208
  u(!1);
209
209
  }
210
210
  };
211
- return /* @__PURE__ */ n(W, { className: "flex max-w-xl flex-col overflow-y-auto", children: [
212
- /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ e(X, { children: "Edit Shared JSON-LD Schema" }) }),
211
+ return /* @__PURE__ */ n(Y, { className: "flex max-w-xl flex-col overflow-y-auto", children: [
212
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(Z, { children: "Edit Shared JSON-LD Schema" }) }),
213
213
  /* @__PURE__ */ n("div", { className: "flex max-h-[75vh] flex-col space-y-2 overflow-y-auto", children: [
214
- !S && /* @__PURE__ */ n("div", { className: "flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2", children: [
214
+ !C && /* @__PURE__ */ n("div", { className: "flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2", children: [
215
215
  /* @__PURE__ */ n("div", { children: [
216
216
  /* @__PURE__ */ e("div", { className: "text-sm font-medium text-blue-900", children: "Manage Existing Pages" }),
217
217
  /* @__PURE__ */ e("div", { className: "text-xs text-blue-700", children: "Add or remove this schema from all existing pages on your site" })
@@ -259,7 +259,7 @@ const oe = () => {
259
259
  }
260
260
  )
261
261
  ] }),
262
- !S && /* @__PURE__ */ n("div", { className: "flex items-center space-x-2", children: [
262
+ !C && /* @__PURE__ */ n("div", { className: "flex items-center space-x-2", children: [
263
263
  /* @__PURE__ */ e(
264
264
  "input",
265
265
  {
@@ -297,7 +297,7 @@ const oe = () => {
297
297
  /* @__PURE__ */ e(Q, { onClick: I, children: "Add to All" })
298
298
  ] })
299
299
  ] }) }),
300
- /* @__PURE__ */ e(U, { open: C, onOpenChange: u, children: /* @__PURE__ */ n(_, { children: [
300
+ /* @__PURE__ */ e(U, { open: S, onOpenChange: u, children: /* @__PURE__ */ n(_, { children: [
301
301
  /* @__PURE__ */ n(R, { children: [
302
302
  /* @__PURE__ */ e(M, { children: "Remove from All Pages?" }),
303
303
  /* @__PURE__ */ n(q, { children: [
@@ -314,8 +314,8 @@ const oe = () => {
314
314
  ] });
315
315
  };
316
316
  function Xe() {
317
- const [t, i] = g(!1), [a, d] = g(void 0), [f, x] = g(null), [C, u] = g(null), [S, p] = g(null), { data: c, isLoading: w } = oe(), { selectedLang: o } = me(), { data: l } = le(), { data: N } = Te(), { mutateAsync: A } = De(), { mutateAsync: I } = se(), P = z(() => N == null ? void 0 : N.find((s) => !s.primaryPage && s.lang === ""), [N]), m = z(() => (P == null ? void 0 : P.globalJsonLds) || [], [P]), T = z(() => c ? Je(c, (r) => r.primaryPage === null && r.lang === "").map((r) => {
318
- const h = o ? Fe(c, (D) => D.primaryPage === r.id && D.lang === o) : null;
317
+ const [t, i] = g(!1), [a, d] = g(void 0), [f, x] = g(null), [S, u] = g(null), [C, p] = g(null), { data: c, isLoading: w } = oe(), { selectedLang: o } = Ne(), { data: l } = le(), { data: N } = ke(), { mutateAsync: A } = je(), { mutateAsync: I } = se(), P = z(() => N == null ? void 0 : N.find((s) => !s.primaryPage && s.lang === ""), [N]), m = z(() => (P == null ? void 0 : P.globalJsonLds) || [], [P]), T = z(() => c ? me(c, (r) => r.primaryPage === null && r.lang === "").map((r) => {
318
+ const h = o ? he(c, (D) => D.primaryPage === r.id && D.lang === o) : null;
319
319
  return {
320
320
  defaultSchema: r,
321
321
  languageVersion: h,
@@ -324,7 +324,7 @@ function Xe() {
324
324
  hasLanguageVersion: !!h
325
325
  };
326
326
  }) : [], [c, o]), [b, E] = g([]), k = b.length > 0 ? b : (l == null ? void 0 : l.globalJsonLds) || [];
327
- Z(() => {
327
+ $(() => {
328
328
  l != null && l.globalJsonLds && E(l.globalJsonLds);
329
329
  }, [l == null ? void 0 : l.globalJsonLds]);
330
330
  const ie = async (s) => {
@@ -367,25 +367,25 @@ function Xe() {
367
367
  onClick: (s) => {
368
368
  s.stopPropagation(), i(!0);
369
369
  },
370
- children: w ? /* @__PURE__ */ e(O, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(ke, { className: "h-4 w-4" })
370
+ children: w ? /* @__PURE__ */ e(O, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(ge, { className: "h-4 w-4" })
371
371
  }
372
372
  ),
373
373
  /* @__PURE__ */ e(F, { children: "Add new schema" })
374
374
  ] })
375
375
  ] }),
376
- /* @__PURE__ */ n(he, { className: "max-h-96 overflow-y-auto", children: [
376
+ /* @__PURE__ */ n(be, { className: "max-h-96 overflow-y-auto", children: [
377
377
  /* @__PURE__ */ n("div", { className: "space-y-2", children: [
378
378
  (!c || (c == null ? void 0 : c.length) === 0) && !w && /* @__PURE__ */ e("div", { className: "flex items-center justify-center px-2 py-4 text-xs", children: "No shared JSON-LD found" }),
379
379
  T.map(({ defaultSchema: s, displayItem: r, hasLanguageVersion: h }) => {
380
380
  var ae, te;
381
381
  const D = k.includes(r.id), ee = m.includes(s.id), ne = h && o ? ee : D;
382
382
  return /* @__PURE__ */ n(
383
- ue,
383
+ ye,
384
384
  {
385
- className: `relative border-gray-300 p-0 shadow-none transition-all ${S === r.id ? "pointer-events-none" : ""}`,
385
+ className: `relative border-gray-300 p-0 shadow-none transition-all ${C === r.id ? "pointer-events-none" : ""}`,
386
386
  children: [
387
- S === r.id && /* @__PURE__ */ e("div", { className: "absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80", children: /* @__PURE__ */ e(O, { className: "h-5 w-5 animate-spin text-primary" }) }),
388
- /* @__PURE__ */ e(ge, { className: "p-2", children: /* @__PURE__ */ n("div", { className: "flex items-center justify-between", children: [
387
+ C === r.id && /* @__PURE__ */ e("div", { className: "absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80", children: /* @__PURE__ */ e(O, { className: "h-5 w-5 animate-spin text-primary" }) }),
388
+ /* @__PURE__ */ e(ve, { className: "p-2", children: /* @__PURE__ */ n("div", { className: "flex items-center justify-between", children: [
389
389
  /* @__PURE__ */ n("div", { className: "flex items-center gap-3", children: [
390
390
  (h || !o) && /* @__PURE__ */ n(L, { delayDuration: 0, children: [
391
391
  /* @__PURE__ */ e(J, { asChild: !0, children: /* @__PURE__ */ e(
@@ -401,7 +401,7 @@ function Xe() {
401
401
  h && o && /* @__PURE__ */ e(F, { children: "Using the default language state" })
402
402
  ] }),
403
403
  /* @__PURE__ */ n("div", { children: [
404
- /* @__PURE__ */ n(fe, { className: "flex items-center gap-2 text-sm leading-none", children: [
404
+ /* @__PURE__ */ n(we, { className: "flex items-center gap-2 text-sm leading-none", children: [
405
405
  r.name,
406
406
  h && o && /* @__PURE__ */ n("span", { className: "text-xs font-normal text-muted-foreground", children: [
407
407
  "(",
@@ -424,7 +424,7 @@ function Xe() {
424
424
  size: "icon",
425
425
  className: "h-5 w-5 p-0",
426
426
  onClick: () => u(r.id),
427
- children: /* @__PURE__ */ e(je, { className: "h-4 w-4" })
427
+ children: /* @__PURE__ */ e(fe, { className: "h-4 w-4" })
428
428
  }
429
429
  ) }),
430
430
  /* @__PURE__ */ e(F, { children: "View schema" })
@@ -439,14 +439,14 @@ function Xe() {
439
439
  size: "icon",
440
440
  className: "h-5 w-5 p-0",
441
441
  onClick: () => x(r.id),
442
- children: /* @__PURE__ */ e(Ge, { className: "h-4 w-4" })
442
+ children: /* @__PURE__ */ e(pe, { className: "h-4 w-4" })
443
443
  }
444
444
  ) }),
445
445
  /* @__PURE__ */ e(F, { children: "Edit schema" })
446
446
  ] }),
447
447
  /* @__PURE__ */ n(U, { children: [
448
448
  /* @__PURE__ */ n(L, { delayDuration: 0, children: [
449
- /* @__PURE__ */ e(J, { asChild: !0, children: /* @__PURE__ */ e(pe, { className: "flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800", children: /* @__PURE__ */ e(Be, { className: "h-4 w-4" }) }) }),
449
+ /* @__PURE__ */ e(J, { asChild: !0, children: /* @__PURE__ */ e(Ae, { className: "flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800", children: /* @__PURE__ */ e(xe, { className: "h-4 w-4" }) }) }),
450
450
  /* @__PURE__ */ e(F, { children: "Delete schema" })
451
451
  ] }),
452
452
  /* @__PURE__ */ n(_, { children: [
@@ -476,7 +476,7 @@ function Xe() {
476
476
  ] })
477
477
  ] })
478
478
  ] }) }),
479
- !h && o && /* @__PURE__ */ e(xe, { className: "px-2 pb-2", children: /* @__PURE__ */ n("div", { className: "flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3", children: [
479
+ !h && o && /* @__PURE__ */ e(Ce, { className: "px-2 pb-2", children: /* @__PURE__ */ n("div", { className: "flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3", children: [
480
480
  /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
481
481
  /* @__PURE__ */ n("div", { className: "max-w-xl text-center text-xs text-gray-500", children: [
482
482
  "Not available in '",
@@ -527,14 +527,14 @@ function Xe() {
527
527
  /* @__PURE__ */ e(
528
528
  Re,
529
529
  {
530
- schema: c == null ? void 0 : c.find((s) => s.id === C),
530
+ schema: c == null ? void 0 : c.find((s) => s.id === S),
531
531
  onClose: () => u(null)
532
532
  }
533
533
  )
534
534
  ] });
535
535
  }
536
- const Re = ({ schema: t, onClose: i }) => /* @__PURE__ */ e($, { open: !!t, onOpenChange: i, children: /* @__PURE__ */ n(W, { className: "max-w-2xl", children: [
537
- /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ n(X, { className: "flex items-center gap-2", children: [
536
+ const Re = ({ schema: t, onClose: i }) => /* @__PURE__ */ e(W, { open: !!t, onOpenChange: i, children: /* @__PURE__ */ n(Y, { className: "max-w-2xl", children: [
537
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ n(Z, { className: "flex items-center gap-2", children: [
538
538
  t == null ? void 0 : t.name,
539
539
  (t == null ? void 0 : t.lang) && /* @__PURE__ */ n("span", { className: "text-sm font-normal text-muted-foreground", children: [
540
540
  "(",
@@ -550,7 +550,7 @@ const Re = ({ schema: t, onClose: i }) => /* @__PURE__ */ e($, { open: !!t, onOp
550
550
  /* @__PURE__ */ n("div", { children: [
551
551
  /* @__PURE__ */ e("div", { className: "mb-2 text-xs font-medium text-muted-foreground", children: "JSON-LD Schema" }),
552
552
  /* @__PURE__ */ e(
553
- Ne,
553
+ Se,
554
554
  {
555
555
  value: JSON.stringify(t == null ? void 0 : t.jsonld, null, 2),
556
556
  readOnly: !0,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-DCJDQs1a.cjs"),h=require("./register-chai-top-bar-DyW9GPzV.cjs"),c=require("./index-BVwFJWDq.cjs"),q=require("@tanstack/react-query"),I=require("lodash-es"),N=require("lucide-react"),x=require("react"),F=require("sonner"),z=()=>{const t=c.useApiUrl(),d=c.useFetch();return q.useQuery({queryKey:[c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS],queryFn:async()=>d(t,{action:c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS})})},U=({show:t,onClose:d,initialData:n})=>e.jsx(s.Dialog,{open:t,onOpenChange:()=>d(),children:t&&e.jsx(_,{show:t,onClose:d,initialData:n})}),_=({show:t,onClose:d,initialData:n})=>{const[r,j]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[b,C]=x.useState(!1),{data:p}=c.usePrimaryPage(),{mutateAsync:S,isPending:f}=c.useAddGlobalSchema(),{mutateAsync:u}=c.useTogglePageGlobalSchema(),w=q.useQueryClient();x.useEffect(()=>{j(n?{name:n.name,description:n.description,content:JSON.stringify(n.jsonld,null,2),enabledByDefaultForNewPages:!1}:{name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),C(!1)},[t,n]);const i=async()=>{if(!r.name||!r.content){F.toast.error("Please enter a name and content");return}const l=c.parseJSONWithPlaceholders(r.content);if(!l.isValid){F.toast.error("Invalid JSON-LD content");return}const y={name:r.name,jsonld:l.parsed,addToExistingPages:b,addToNewPages:r.enabledByDefaultForNewPages,description:r.description};n!=null&&n.primaryPageId&&(y.primaryPage=n.primaryPageId);const A=await S(y);p!=null&&p.id&&(A!=null&&A.id)&&!(n!=null&&n.primaryPageId)&&(await u({schemaId:A.id,pageId:p.id,enabled:!0}),w.invalidateQueries({queryKey:[c.ACTIONS.GET_LANGUAGE_PAGES,p.id]})),d()};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Add New Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[(n==null?void 0:n.languageCode)&&e.jsxs(h.Alert,{className:"border-blue-200 bg-blue-50",children:[e.jsx(N.Info,{className:"h-4 w-4 text-blue-600"}),e.jsxs(h.AlertDescription,{className:"text-sm text-blue-800",children:["You are creating a ",e.jsx("span",{className:"font-semibold",children:n.languageCode})," language version of this schema. This will be linked to the default language schema."]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(h.Input,{id:"new-name",value:r.name,onChange:l=>j({...r,name:l.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-description",children:"Description"}),e.jsx(h.Input,{id:"new-description",value:r.description||"",onChange:l=>j({...r,description:l.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"new-content",value:r.content||"{}",onChange:l=>j({...r,content:l}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!(n!=null&&n.primaryPageId)&&e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"add-to-all-existing",checked:b,onChange:l=>C(l.target.checked),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"add-to-all-existing",children:[e.jsx("div",{children:"Add to all existing pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"This schema will be added to all existing pages on your site"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-enabled",checked:r.enabledByDefaultForNewPages,onChange:l=>j({...r,enabledByDefaultForNewPages:l.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"new-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(h.Button,{disabled:f,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(h.Button,{disabled:f,type:"button",size:"sm",onClick:i,children:f?e.jsxs(e.Fragment,{children:[e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"})," Adding"]}):e.jsxs(e.Fragment,{children:["Add Schema",(n==null?void 0:n.languageCode)&&` (${n.languageCode})`]})})]})})]})]})},H=({id:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:()=>d(),children:t&&e.jsx(Q,{id:t,onClose:d})}),Q=({id:t,onClose:d})=>{const[n,r]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[j,b]=x.useState(!1),[C,p]=x.useState(!1),[S,f]=x.useState(!1),{data:u}=z(),{mutateAsync:w,isPending:i}=c.useUpdateGlobalSchema(),{mutateAsync:l}=c.useApplySchemaToAllPages(),{mutateAsync:y}=c.useRemoveSchemaFromAllPages();x.useEffect(()=>{var m,D;if(t&&u){const v=u.find(L=>L.id===t);v&&(r({name:v.name,description:((m=v.metadata)==null?void 0:m.description)||"",content:JSON.stringify(v.jsonld,null,2),enabledByDefaultForNewPages:((D=v.metadata)==null?void 0:D.addToNewPages)||!1}),f(!!v.primaryPage))}},[t,u]);const A=async()=>{if(!n.name||!n.content){F.toast.error("Please enter a name and content");return}const m=c.parseJSONWithPlaceholders(n.content);if(!m.isValid){F.toast.error("Invalid JSON-LD content");return}const D={id:t,name:n.name,jsonld:m.parsed,addToNewPages:n.enabledByDefaultForNewPages,description:n.description};await w(D),d()},O=async()=>{try{await l(t)}finally{b(!1)}},T=async()=>{try{await y(t)}finally{p(!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:[!S&&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(h.Button,{size:"sm",className:"text-xs",variant:"outline",onClick:()=>b(!0),children:"Add to all existing"}),e.jsx(h.Button,{size:"sm",variant:"ghost",className:"text-xs",onClick:()=>p(!0),children:"Remove from all"})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-name",children:"Schema Name"}),e.jsx(h.Input,{id:"edit-name",value:n.name,onChange:m=>r({...n,name:m.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-description",children:"Description"}),e.jsx(h.Input,{id:"edit-description",value:n.description||"",onChange:m=>r({...n,description:m.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"edit-content",value:n.content||"{}",onChange:m=>r({...n,content:m}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!S&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"edit-enabled",checked:n.enabledByDefaultForNewPages,onChange:m=>r({...n,enabledByDefaultForNewPages:m.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"edit-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(h.Button,{disabled:i,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(h.Button,{disabled:i,type:"button",size:"sm",onClick:A,children:i?e.jsxs(e.Fragment,{children:[e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"})," Updating"]}):"Update Schema"})]})})]}),e.jsx(s.AlertDialog,{open:j,onOpenChange:b,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:O,children:"Add to All"})]})]})}),e.jsx(s.AlertDialog,{open:C,onOpenChange:p,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Remove from All Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will remove the schema ",e.jsx("span",{className:"font-medium",children:n.name})," from all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:T,className:"bg-red-500 hover:bg-red-600",children:"Remove from All"})]})]})})]})};function V(){const[t,d]=x.useState(!1),[n,r]=x.useState(void 0),[j,b]=x.useState(null),[C,p]=x.useState(null),[S,f]=x.useState(null),{data:u,isLoading:w}=z(),{selectedLang:i}=s.useLanguages(),{data:l}=c.usePrimaryPage(),{data:y}=c.useLanguagePages(),{mutateAsync:A}=c.useDeleteGlobalSchema(),{mutateAsync:O}=c.useTogglePageGlobalSchema(),T=x.useMemo(()=>y==null?void 0:y.find(a=>!a.primaryPage&&a.lang===""),[y]),m=x.useMemo(()=>(T==null?void 0:T.globalJsonLds)||[],[T]),D=x.useMemo(()=>u?I.filter(u,o=>o.primaryPage===null&&o.lang==="").map(o=>{const g=i?I.find(u,P=>P.primaryPage===o.id&&P.lang===i):null;return{defaultSchema:o,languageVersion:g,displayItem:g||o,hasLanguageVersion:!!g}}):[],[u,i]),[v,L]=x.useState([]),E=v.length>0?v:(l==null?void 0:l.globalJsonLds)||[];x.useEffect(()=>{l!=null&&l.globalJsonLds&&L(l.globalJsonLds)},[l==null?void 0:l.globalJsonLds]);const R=async a=>{if(!(l!=null&&l.id))return;f(a);const o=E.includes(a),g=o?E.filter(P=>P!==a):[...E,a];L(g);try{await O({schemaId:a,pageId:l.id,enabled:!o})}catch{L(l.globalJsonLds)}finally{f(null)}},M=async a=>{f(a);try{await A(a)}finally{f(null)}};return e.jsxs("div",{className:"rounded border bg-muted p-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:"Shared JSON-LD Templates"}),e.jsx("div",{className:"w-full text-xs text-gray-500",children:"Manage reusable JSON-LD schemas that can be applied across multiple pages"})]}),!i&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:w,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:a=>{a.stopPropagation(),d(!0)},children:w?e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(N.Plus,{className:"h-4 w-4"})}),e.jsx(s.TooltipContent,{children:"Add new schema"})]})]}),e.jsxs(s.ScrollArea,{className:"max-h-96 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[(!u||(u==null?void 0:u.length)===0)&&!w&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),D.map(({defaultSchema:a,displayItem:o,hasLanguageVersion:g})=>{var B,G;const P=E.includes(o.id),J=m.includes(a.id),k=g&&i?J:P;return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${S===o.id?"pointer-events-none":""}`,children:[S===o.id&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80",children:e.jsx(N.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:[(g||!i)&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("input",{type:"checkbox",checked:k,onChange:()=>R(a.id),disabled:!!(g&&i),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"})}),g&&i&&e.jsx(s.TooltipContent,{children:"Using the default language state"})]}),e.jsxs("div",{children:[e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:[o.name,g&&i&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(",i,")"]}),k&&e.jsx("span",{className:"sr-only text-xs font-normal text-muted-foreground",children:"Enabled"})]}),((B=o==null?void 0:o.metadata)==null?void 0:B.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:(G=o==null?void 0:o.metadata)==null?void 0:G.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"mx-2 h-6 w-px bg-border"}),e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>p(o.id),children:e.jsx(N.Eye,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"View schema"})]}),(g||!i)&&e.jsxs(e.Fragment,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>b(o.id),children:e.jsx(N.Edit,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Edit schema"})]}),e.jsxs(s.AlertDialog,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.AlertDialogTrigger,{className:"flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800",children:e.jsx(N.Trash,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Delete schema"})]}),e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Schema"}),e.jsxs(s.AlertDialogDescription,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium",children:o.name}),"? This action cannot be undone."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{type:"button",children:"Cancel"}),e.jsx(s.AlertDialogAction,{type:"button",onClick:()=>M(o.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})]})}),!g&&i&&e.jsx(s.CardContent,{className:"px-2 pb-2",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"max-w-xl text-center text-xs text-gray-500",children:["Not available in '",i,"' language. Default language JSONLD will be used."]}),J&&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(h.Button,{type:"button",size:"sm",variant:"outline",className:"mt-2",onClick:()=>{r({name:a.name,description:a.description||"",jsonld:a.jsonld,languageCode:i,primaryPageId:a.id}),d(!0)},children:"Copy & Edit from default language"})]})})]},a.id)})]}),w&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(N.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(U,{show:t,onClose:()=>{d(!1),r(void 0)},initialData:n}),e.jsx(H,{id:j,onClose:()=>b(null)}),e.jsx(K,{schema:u==null?void 0:u.find(a=>a.id===C),onClose:()=>p(null)})]})}const K=({schema:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:d,children:e.jsxs(s.DialogContent,{className:"max-w-2xl",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[t==null?void 0:t.name,(t==null?void 0:t.lang)&&e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",t.lang,")"]})]})}),e.jsxs("div",{className:"space-y-3",children:[(t==null?void 0:t.description)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Description"}),e.jsx("div",{className:"text-sm",children:t.description})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"JSON-LD Schema"}),e.jsx(s.Textarea,{value:JSON.stringify(t==null?void 0:t.jsonld,null,2),readOnly:!0,className:"font-mono text-xs",rows:15})]})]})]})});exports.default=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),I=require("lodash-es"),N=require("lucide-react"),x=require("react"),s=require("./index-D-r_K4yA.cjs"),h=require("./register-chai-top-bar-CCssW5dL.cjs"),c=require("./index-BYrRPW_c.cjs"),q=require("@tanstack/react-query"),F=require("sonner"),z=()=>{const t=c.useApiUrl(),d=c.useFetch();return q.useQuery({queryKey:[c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS],queryFn:async()=>d(t,{action:c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS})})},U=({show:t,onClose:d,initialData:n})=>e.jsx(s.Dialog,{open:t,onOpenChange:()=>d(),children:t&&e.jsx(_,{show:t,onClose:d,initialData:n})}),_=({show:t,onClose:d,initialData:n})=>{const[r,j]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[b,C]=x.useState(!1),{data:p}=c.usePrimaryPage(),{mutateAsync:S,isPending:f}=c.useAddGlobalSchema(),{mutateAsync:u}=c.useTogglePageGlobalSchema(),w=q.useQueryClient();x.useEffect(()=>{j(n?{name:n.name,description:n.description,content:JSON.stringify(n.jsonld,null,2),enabledByDefaultForNewPages:!1}:{name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),C(!1)},[t,n]);const i=async()=>{if(!r.name||!r.content){F.toast.error("Please enter a name and content");return}const l=c.parseJSONWithPlaceholders(r.content);if(!l.isValid){F.toast.error("Invalid JSON-LD content");return}const y={name:r.name,jsonld:l.parsed,addToExistingPages:b,addToNewPages:r.enabledByDefaultForNewPages,description:r.description};n!=null&&n.primaryPageId&&(y.primaryPage=n.primaryPageId);const A=await S(y);p!=null&&p.id&&(A!=null&&A.id)&&!(n!=null&&n.primaryPageId)&&(await u({schemaId:A.id,pageId:p.id,enabled:!0}),w.invalidateQueries({queryKey:[c.ACTIONS.GET_LANGUAGE_PAGES,p.id]})),d()};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Add New Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[(n==null?void 0:n.languageCode)&&e.jsxs(h.Alert,{className:"border-blue-200 bg-blue-50",children:[e.jsx(N.Info,{className:"h-4 w-4 text-blue-600"}),e.jsxs(h.AlertDescription,{className:"text-sm text-blue-800",children:["You are creating a ",e.jsx("span",{className:"font-semibold",children:n.languageCode})," language version of this schema. This will be linked to the default language schema."]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(h.Input,{id:"new-name",value:r.name,onChange:l=>j({...r,name:l.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-description",children:"Description"}),e.jsx(h.Input,{id:"new-description",value:r.description||"",onChange:l=>j({...r,description:l.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"new-content",value:r.content||"{}",onChange:l=>j({...r,content:l}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!(n!=null&&n.primaryPageId)&&e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"add-to-all-existing",checked:b,onChange:l=>C(l.target.checked),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"add-to-all-existing",children:[e.jsx("div",{children:"Add to all existing pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"This schema will be added to all existing pages on your site"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-enabled",checked:r.enabledByDefaultForNewPages,onChange:l=>j({...r,enabledByDefaultForNewPages:l.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"new-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(h.Button,{disabled:f,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(h.Button,{disabled:f,type:"button",size:"sm",onClick:i,children:f?e.jsxs(e.Fragment,{children:[e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"})," Adding"]}):e.jsxs(e.Fragment,{children:["Add Schema",(n==null?void 0:n.languageCode)&&` (${n.languageCode})`]})})]})})]})]})},H=({id:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:()=>d(),children:t&&e.jsx(Q,{id:t,onClose:d})}),Q=({id:t,onClose:d})=>{const[n,r]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[j,b]=x.useState(!1),[C,p]=x.useState(!1),[S,f]=x.useState(!1),{data:u}=z(),{mutateAsync:w,isPending:i}=c.useUpdateGlobalSchema(),{mutateAsync:l}=c.useApplySchemaToAllPages(),{mutateAsync:y}=c.useRemoveSchemaFromAllPages();x.useEffect(()=>{var m,D;if(t&&u){const v=u.find(L=>L.id===t);v&&(r({name:v.name,description:((m=v.metadata)==null?void 0:m.description)||"",content:JSON.stringify(v.jsonld,null,2),enabledByDefaultForNewPages:((D=v.metadata)==null?void 0:D.addToNewPages)||!1}),f(!!v.primaryPage))}},[t,u]);const A=async()=>{if(!n.name||!n.content){F.toast.error("Please enter a name and content");return}const m=c.parseJSONWithPlaceholders(n.content);if(!m.isValid){F.toast.error("Invalid JSON-LD content");return}const D={id:t,name:n.name,jsonld:m.parsed,addToNewPages:n.enabledByDefaultForNewPages,description:n.description};await w(D),d()},O=async()=>{try{await l(t)}finally{b(!1)}},T=async()=>{try{await y(t)}finally{p(!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:[!S&&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(h.Button,{size:"sm",className:"text-xs",variant:"outline",onClick:()=>b(!0),children:"Add to all existing"}),e.jsx(h.Button,{size:"sm",variant:"ghost",className:"text-xs",onClick:()=>p(!0),children:"Remove from all"})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-name",children:"Schema Name"}),e.jsx(h.Input,{id:"edit-name",value:n.name,onChange:m=>r({...n,name:m.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-description",children:"Description"}),e.jsx(h.Input,{id:"edit-description",value:n.description||"",onChange:m=>r({...n,description:m.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"edit-content",value:n.content||"{}",onChange:m=>r({...n,content:m}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!S&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"edit-enabled",checked:n.enabledByDefaultForNewPages,onChange:m=>r({...n,enabledByDefaultForNewPages:m.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"edit-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(h.Button,{disabled:i,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(h.Button,{disabled:i,type:"button",size:"sm",onClick:A,children:i?e.jsxs(e.Fragment,{children:[e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"})," Updating"]}):"Update Schema"})]})})]}),e.jsx(s.AlertDialog,{open:j,onOpenChange:b,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:O,children:"Add to All"})]})]})}),e.jsx(s.AlertDialog,{open:C,onOpenChange:p,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Remove from All Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will remove the schema ",e.jsx("span",{className:"font-medium",children:n.name})," from all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:T,className:"bg-red-500 hover:bg-red-600",children:"Remove from All"})]})]})})]})};function V(){const[t,d]=x.useState(!1),[n,r]=x.useState(void 0),[j,b]=x.useState(null),[C,p]=x.useState(null),[S,f]=x.useState(null),{data:u,isLoading:w}=z(),{selectedLang:i}=s.useLanguages(),{data:l}=c.usePrimaryPage(),{data:y}=c.useLanguagePages(),{mutateAsync:A}=c.useDeleteGlobalSchema(),{mutateAsync:O}=c.useTogglePageGlobalSchema(),T=x.useMemo(()=>y==null?void 0:y.find(a=>!a.primaryPage&&a.lang===""),[y]),m=x.useMemo(()=>(T==null?void 0:T.globalJsonLds)||[],[T]),D=x.useMemo(()=>u?I.filter(u,o=>o.primaryPage===null&&o.lang==="").map(o=>{const g=i?I.find(u,P=>P.primaryPage===o.id&&P.lang===i):null;return{defaultSchema:o,languageVersion:g,displayItem:g||o,hasLanguageVersion:!!g}}):[],[u,i]),[v,L]=x.useState([]),E=v.length>0?v:(l==null?void 0:l.globalJsonLds)||[];x.useEffect(()=>{l!=null&&l.globalJsonLds&&L(l.globalJsonLds)},[l==null?void 0:l.globalJsonLds]);const R=async a=>{if(!(l!=null&&l.id))return;f(a);const o=E.includes(a),g=o?E.filter(P=>P!==a):[...E,a];L(g);try{await O({schemaId:a,pageId:l.id,enabled:!o})}catch{L(l.globalJsonLds)}finally{f(null)}},M=async a=>{f(a);try{await A(a)}finally{f(null)}};return e.jsxs("div",{className:"rounded border bg-muted p-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:"Shared JSON-LD Templates"}),e.jsx("div",{className:"w-full text-xs text-gray-500",children:"Manage reusable JSON-LD schemas that can be applied across multiple pages"})]}),!i&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:w,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:a=>{a.stopPropagation(),d(!0)},children:w?e.jsx(N.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(N.Plus,{className:"h-4 w-4"})}),e.jsx(s.TooltipContent,{children:"Add new schema"})]})]}),e.jsxs(s.ScrollArea,{className:"max-h-96 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[(!u||(u==null?void 0:u.length)===0)&&!w&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),D.map(({defaultSchema:a,displayItem:o,hasLanguageVersion:g})=>{var B,G;const P=E.includes(o.id),J=m.includes(a.id),k=g&&i?J:P;return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${S===o.id?"pointer-events-none":""}`,children:[S===o.id&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80",children:e.jsx(N.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:[(g||!i)&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("input",{type:"checkbox",checked:k,onChange:()=>R(a.id),disabled:!!(g&&i),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"})}),g&&i&&e.jsx(s.TooltipContent,{children:"Using the default language state"})]}),e.jsxs("div",{children:[e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:[o.name,g&&i&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(",i,")"]}),k&&e.jsx("span",{className:"sr-only text-xs font-normal text-muted-foreground",children:"Enabled"})]}),((B=o==null?void 0:o.metadata)==null?void 0:B.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:(G=o==null?void 0:o.metadata)==null?void 0:G.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"mx-2 h-6 w-px bg-border"}),e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>p(o.id),children:e.jsx(N.Eye,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"View schema"})]}),(g||!i)&&e.jsxs(e.Fragment,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>b(o.id),children:e.jsx(N.Edit,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Edit schema"})]}),e.jsxs(s.AlertDialog,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.AlertDialogTrigger,{className:"flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800",children:e.jsx(N.Trash,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Delete schema"})]}),e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Schema"}),e.jsxs(s.AlertDialogDescription,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium",children:o.name}),"? This action cannot be undone."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{type:"button",children:"Cancel"}),e.jsx(s.AlertDialogAction,{type:"button",onClick:()=>M(o.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})]})}),!g&&i&&e.jsx(s.CardContent,{className:"px-2 pb-2",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"max-w-xl text-center text-xs text-gray-500",children:["Not available in '",i,"' language. Default language JSONLD will be used."]}),J&&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(h.Button,{type:"button",size:"sm",variant:"outline",className:"mt-2",onClick:()=>{r({name:a.name,description:a.description||"",jsonld:a.jsonld,languageCode:i,primaryPageId:a.id}),d(!0)},children:"Copy & Edit from default language"})]})})]},a.id)})]}),w&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(N.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(U,{show:t,onClose:()=>{d(!1),r(void 0)},initialData:n}),e.jsx(H,{id:j,onClose:()=>b(null)}),e.jsx(K,{schema:u==null?void 0:u.find(a=>a.id===C),onClose:()=>p(null)})]})}const K=({schema:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:d,children:e.jsxs(s.DialogContent,{className:"max-w-2xl",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[t==null?void 0:t.name,(t==null?void 0:t.lang)&&e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",t.lang,")"]})]})}),e.jsxs("div",{className:"space-y-3",children:[(t==null?void 0:t.description)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Description"}),e.jsx("div",{className:"text-sm",children:t.description})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"JSON-LD Schema"}),e.jsx(s.Textarea,{value:JSON.stringify(t==null?void 0:t.jsonld,null,2),readOnly:!0,className:"font-mono text-xs",rows:15})]})]})]})});exports.default=V;
@@ -1,7 +1,7 @@
1
1
  import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
- import { z as v } from "./register-chai-top-bar-D6GjnauV.js";
3
- import { L as d } from "./index-OuHV9Ann.js";
4
- import { useState as x, useEffect as C } from "react";
2
+ import { useState as x, useEffect as v } from "react";
3
+ import { z as C } from "./register-chai-top-bar-DWmJ2efT.js";
4
+ import { L as d } from "./index-DPV6NiJ-.js";
5
5
  const y = (e) => {
6
6
  if (!e) return { base: e, extension: null };
7
7
  const n = e.lastIndexOf(".");
@@ -48,7 +48,7 @@ function D({
48
48
  fullSlug: l
49
49
  }) {
50
50
  const [h, u] = x(e), [c, f] = x(null);
51
- C(() => {
51
+ v(() => {
52
52
  u(e);
53
53
  }, [e]);
54
54
  const N = (b) => {
@@ -62,7 +62,7 @@ function D({
62
62
  ] }) }),
63
63
  /* @__PURE__ */ i("div", { className: "relative", children: [
64
64
  /* @__PURE__ */ o(
65
- v,
65
+ C,
66
66
  {
67
67
  disabled: a,
68
68
  value: h,
@@ -1 +1 @@
1
- "use strict";const s=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),u=require("./index-DCJDQs1a.cjs"),d=require("react"),j=e=>{if(!e)return{base:e,extension:null};const n=e.lastIndexOf(".");if(n<=0)return{base:e,extension:null};const t=e.substring(n);return{base:e.substring(0,n),extension:t}},x=e=>{if(!e)return e;const{base:n}=j(e);return n};function E(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const i=t.pop()||"";if(u.LANGUAGES[i])a=!0;else{r=i;const o=t.pop()||"";a=!!u.LANGUAGES[o]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const i=t.pop()||"";a=!!u.LANGUAGES[i]}return{initSlug:r,prefix:a}}const v=e=>e&&x(e),C=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function A({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:i=!1,fullSlug:o}){const[g,p]=d.useState(e),[l,f]=d.useState(null);d.useEffect(()=>{p(e)},[e]);const h=S=>{const c=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(c.match(/\./g)||[]).length,N=m<=1;m>1?f("Invalid slug. Only one dot (.) is allowed in the slug"):f(null),a&&a(N),p(c),n(c)};return s.jsxs("div",{children:[r&&s.jsx("div",{className:"mb-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Parent: ",s.jsx("span",{className:"font-mono text-gray-900",children:v(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(b.Input,{disabled:i,value:g,onChange:h,placeholder:t,className:l?"border-red-500":""}),l&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:l})]}),o&&o!=="undefined"&&s.jsx("div",{className:"mt-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Complete Slug: ",s.jsx("span",{className:"font-mono text-gray-900",children:o})]})})]})}exports.SlugInput=A;exports.combineParentChildSlugs=C;exports.parseSlugForEdit=E;exports.removeSlugExtension=x;
1
+ "use strict";const s=require("react/jsx-runtime"),u=require("react"),b=require("./register-chai-top-bar-CCssW5dL.cjs"),d=require("./index-D-r_K4yA.cjs"),j=e=>{if(!e)return{base:e,extension:null};const n=e.lastIndexOf(".");if(n<=0)return{base:e,extension:null};const t=e.substring(n);return{base:e.substring(0,n),extension:t}},x=e=>{if(!e)return e;const{base:n}=j(e);return n};function E(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const i=t.pop()||"";if(d.LANGUAGES[i])a=!0;else{r=i;const o=t.pop()||"";a=!!d.LANGUAGES[o]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const i=t.pop()||"";a=!!d.LANGUAGES[i]}return{initSlug:r,prefix:a}}const v=e=>e&&x(e),C=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function A({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:i=!1,fullSlug:o}){const[g,p]=u.useState(e),[l,f]=u.useState(null);u.useEffect(()=>{p(e)},[e]);const h=S=>{const c=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(c.match(/\./g)||[]).length,N=m<=1;m>1?f("Invalid slug. Only one dot (.) is allowed in the slug"):f(null),a&&a(N),p(c),n(c)};return s.jsxs("div",{children:[r&&s.jsx("div",{className:"mb-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Parent: ",s.jsx("span",{className:"font-mono text-gray-900",children:v(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(b.Input,{disabled:i,value:g,onChange:h,placeholder:t,className:l?"border-red-500":""}),l&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:l})]}),o&&o!=="undefined"&&s.jsx("div",{className:"mt-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Complete Slug: ",s.jsx("span",{className:"font-mono text-gray-900",children:o})]})})]})}exports.SlugInput=A;exports.combineParentChildSlugs=C;exports.parseSlugForEdit=E;exports.removeSlugExtension=x;
@@ -1 +1 @@
1
- "use strict";var x=Object.defineProperty;var k=(u,t,e)=>t in u?x(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var E=(u,t,e)=>k(u,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./actions-registery-BHbZHkE3.cjs"),A=require("lodash-es"),n=require("zod"),p=class p{constructor(t,e,r){this.appId=t,this.userId=e,this.supabase=r}appendUpdatedAtToUrl(t,e){if(A.isEmpty(t))return"";const r=new URL(t),a=new Date(e).getTime();return r.searchParams.set("t",a.toString()),`${r.origin}${r.pathname}${r.search}${r.hash}`}getBufferFromBase64(t){try{const e=t.split(",")[1]||t;return Buffer.from(e,"base64")}catch{throw new Error("Invalid base64 string format")}}getMimeType(t){var a;const e=((a=t.split(".").pop())==null?void 0:a.toLowerCase())||"";return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",webp:"image/webp",gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"}[e]||"application/octet-stream"}getImageDimensions(t){if(t.length>=p.MIN_PNG_LENGTH&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71)return{width:t.readUInt32BE(16),height:t.readUInt32BE(20)};if(t.length>=p.MIN_GIF_LENGTH&&t[0]===71&&t[1]===73&&t[2]===70)return{width:t.readUInt16LE(6),height:t.readUInt16LE(8)};if(t.length>=12&&t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80){if(t.length>=p.MIN_WEBP_VP8L_LENGTH&&t[12]===86&&t[13]===80&&t[14]===56&&t[15]===76){const e=t.readUInt32LE(21);return{width:(e&16383)+1,height:(e>>14&16383)+1}}if(t.length>=p.MIN_WEBP_VP8X_LENGTH&&t[12]===86&&t[13]===80&&t[14]===56&&t[15]===88)return{width:1+(t[24]|t[25]<<8|t[26]<<16),height:1+(t[27]|t[28]<<8|t[29]<<16)};if(t.length>=p.MIN_WEBP_VP8_LENGTH&&t[12]===86&&t[13]===80&&t[14]===56&&t[15]===32)return{width:t.readUInt16LE(26)&16383,height:t.readUInt16LE(28)&16383}}if(t.length>=2&&t[0]===255&&t[1]===216){let e=2;for(;e<t.length-1;){if(t[e]!==255){e++;continue}const r=t[e+1];if(r>=192&&r<=195||r>=197&&r<=199||r>=201&&r<=203||r>=205&&r<=207){if(e+p.MIN_JPEG_SOF_BYTES_FROM_MARKER<=t.length)return{width:t.readUInt16BE(e+7),height:t.readUInt16BE(e+5)};break}if(e+4>t.length)break;const a=t.readUInt16BE(e+2);e+=2+a}}return{width:0,height:0}}async uploadImageFile(t,e,r,a){try{const s=this.getBufferFromBase64(t),i=this.getMimeType(r);if(!["image/jpeg","image/png","image/webp","image/gif","image/tiff"].includes(i))throw new Error(`Invalid image format: ${i}`);const d=r.split("."),o=d.length>1?d.slice(0,-1).join("."):r,l=d.length>1?d[d.length-1].toLowerCase():"png",w=`${A.kebabCase(o)}.${l}`,h=this.appId,m=e?`${h}/${e}`:h,S=g.getChaiAction("UPLOAD_TO_STORAGE");if(!S)throw new Error("UPLOAD_TO_STORAGE action not found");S.setContext({appId:this.appId,userId:this.userId});const U=await S.execute({file:s.toString("base64"),fileName:w,contentType:i,folder:m});if(U.error)throw new Error(U.error);const{width:T,height:b}=this.getImageDimensions(s);return{url:U.data.url,thumbnailUrl:U.data.url,size:s.length,width:T,height:b,mimeType:i}}catch(s){return console.error("Upload image error:",s),{error:s instanceof Error?s.message:"Unknown error"}}}async uploadSvgFile(t,e,r){try{const a=this.getBufferFromBase64(t);let s,i;try{const S=a.toString("utf-8"),U=S.match(/\bwidth=["'](\d+)/),T=S.match(/\bheight=["'](\d+)/);U&&(s=parseInt(U[1],10)),T&&(i=parseInt(T[1],10))}catch{}const c=r.split("."),d=c.length>1?c.slice(0,-1).join("."):r,o=`${A.kebabCase(d)}.svg`,l=this.appId,w=e?`${l}/${e}`:l,h=g.getChaiAction("UPLOAD_TO_STORAGE");if(!h)throw new Error("UPLOAD_TO_STORAGE action not found");h.setContext({appId:this.appId,userId:this.userId});const m=await h.execute({file:a.toString("base64"),fileName:o,contentType:"image/svg+xml",folder:w});if(m.error)throw new Error(m.error);return{url:m.data.url,thumbnailUrl:m.data.url,size:a.length,width:s,height:i,mimeType:"image/svg+xml"}}catch(a){return console.error("SVG upload error:",a),{error:a instanceof Error?a.message:"Unknown error"}}}async upload({file:t,folderId:e,name:r,optimize:a=!0}){var s;try{const c=r.toLowerCase().endsWith(".svg")||t.includes("data:image/svg+xml")?await this.uploadSvgFile(t,e,r):await this.uploadImageFile(t,e,r,a??!0);if("error"in c)return c;const d={name:r,app:this.appId,url:c.url,thumbnailUrl:c.thumbnailUrl,size:(s=c.size)==null?void 0:s.toString(),width:c.width,height:c.height,format:c.mimeType.split("/")[1],folderId:e,type:c.mimeType.startsWith("image/")?"image":"file",createdBy:this.userId,updatedAt:new Date().toISOString()},{data:o,error:l}=await this.supabase.from("app_assets").insert(d).select("*").single();if(l)throw new Error(`Failed to store asset in database: ${l.message}`);return{id:o.id,name:o.name,type:o.type,url:this.appendUpdatedAtToUrl(o.url,o.updatedAt),size:o.size,thumbnailUrl:this.appendUpdatedAtToUrl(o.thumbnailUrl||"",o.updatedAt),width:o.width,height:o.height,format:o.format,folderId:o.folderId,createdBy:o.createdBy||"",createdAt:o.createdAt,updatedAt:o.updatedAt}}catch(i){return{error:i instanceof Error?i.message:"Unknown error occurred"}}}async getAsset({id:t}){try{const{data:e,error:r}=await this.supabase.from("app_assets").select("*").eq("id",t).eq("app",this.appId).single();if(r)throw new Error(`Failed to fetch asset: ${r.message}`);return A.set(e,"url",this.appendUpdatedAtToUrl(e.url,e.updatedAt)),A.set(e,"thumbnailUrl",this.appendUpdatedAtToUrl(e.thumbnailUrl||"",e.updatedAt)),e}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async getAssets({search:t="",page:e=1,limit:r=20}={}){try{const a=(e-1)*r;let s=this.supabase.from("app_assets").select("*",{count:"exact"}).eq("app",this.appId).order("updatedAt",{ascending:!1});t&&(s=s.or(`name.ilike.%${t}%,description.ilike.%${t}%`));const{data:i,error:c,count:d}=await s.range(a,a+r-1);if(c)throw new Error(c.message);return{assets:i.map(l=>(A.set(l,"url",this.appendUpdatedAtToUrl(l.url,l.updatedAt)),A.set(l,"thsupabaseumbnailUrl",this.appendUpdatedAtToUrl(l.thumbnailUrl||"",l.updatedAt)),l)),total:d||0,page:e,pageSize:r}}catch(a){throw console.error("Error fetching assets:",a),a}}async deleteAsset({id:t}){try{const{data:e,error:r}=await this.supabase.from("app_assets").select("*").eq("id",t).eq("app",this.appId).single();if(r)throw new Error(`Failed to fetch asset: ${r.message}`);if(e.url)try{const i=new URL(e.url).pathname.split("/"),c=i.indexOf("dam-assets");if(c!==-1){const d=i.slice(c+1).join("/"),o=g.getChaiAction("DELETE_FROM_STORAGE");if(o&&(o.setContext({appId:this.appId,userId:this.userId}),await o.execute({key:d})),e.thumbnailUrl&&e.thumbnailUrl!==e.url){const w=new URL(e.thumbnailUrl).pathname.split("/"),h=w.indexOf("dam-assets");if(h!==-1){const m=w.slice(h+1).join("/");o&&await o.execute({key:m})}}}}catch(s){console.warn("Failed to delete from storage, continuing with database deletion:",s)}const{error:a}=await this.supabase.from("app_assets").delete().eq("id",t);if(a)throw new Error(`Failed to delete asset: ${a.message}`);return{success:!0}}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async updateAsset({id:t,file:e,description:r}){var a,s;try{const{data:i,error:c}=await this.supabase.from("app_assets").select("*").eq("id",t).single();if(c)throw new Error(`Failed to fetch asset: ${c.message}`);const d={};if(r!==void 0&&(d.description=r,d.updatedAt=new Date().toISOString()),e){const h=((a=i.format)==null?void 0:a.toLowerCase())==="svg"||e.includes("data:image/svg+xml")?await this.uploadSvgFile(e,i.folderId,i.name):await this.uploadImageFile(e,i.folderId,i.name,!0);if("error"in h)return h;d.url=h.url,d.thumbnailUrl=h.thumbnailUrl,d.size=(s=h.size)==null?void 0:s.toString(),d.width=h.width,d.height=h.height,d.format=h.mimeType.split("/")[1],d.updatedAt=new Date().toISOString()}const{data:o,error:l}=await this.supabase.from("app_assets").update(d).eq("id",t).select().single();if(l)throw new Error(`Failed to update asset: ${l.message}`);return A.set(o,"url",this.appendUpdatedAtToUrl(o.url,o.updatedAt)),A.set(o,"thumbnailUrl",this.appendUpdatedAtToUrl(o.thumbnailUrl||"",o.updatedAt)),o}catch(i){return{error:i instanceof Error?i.message:"Unknown error occurred"}}}};E(p,"MIN_PNG_LENGTH",24),E(p,"MIN_GIF_LENGTH",10),E(p,"MIN_WEBP_VP8L_LENGTH",25),E(p,"MIN_WEBP_VP8X_LENGTH",30),E(p,"MIN_WEBP_VP8_LENGTH",30),E(p,"MIN_JPEG_SOF_BYTES_FROM_MARKER",9);let I=p;const P=n.z.object({name:n.z.string(),file:n.z.string(),folderId:n.z.string().optional().nullable(),optimize:n.z.boolean().optional()});class z extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return P}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).upload(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPLOAD_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const f=n.z.object({id:n.z.string()});class O extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return f}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).getAsset(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const D=n.z.object({search:n.z.string().optional(),page:n.z.number().optional(),limit:n.z.number().optional()});class L extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return D}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).getAssets(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSETS error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const G=n.z.object({id:n.z.string()});class N extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return G}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).deleteAsset(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("DELETE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const F=n.z.object({id:n.z.string(),file:n.z.string().optional(),description:n.z.string().optional()});class B extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return F}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).updateAsset(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPDATE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const M=n.z.object({userId:n.z.string()});class C extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return M}async execute(t){var e,r,a,s,i,c;try{const{userId:d}=t,{data:o,error:l}=await this.supabase.auth.admin.getUserById(d);return l?{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}:{data:{id:((e=o.user)==null?void 0:e.id)||"unknown",email:((r=o.user)==null?void 0:r.email)||"unknown@chaibuilder.com",name:((s=(a=o.user)==null?void 0:a.user_metadata)==null?void 0:s.name)||"Unknown",avatar:((c=(i=o.user)==null?void 0:i.user_metadata)==null?void 0:c.avatar_url)||""},status:200}}catch{return{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}}}}const v=n.z.object({email:n.z.string().email(),oldPassword:n.z.string().min(1,"Old password is required"),newPassword:n.z.string().min(8,"New password must be at least 8 characters"),confirmPassword:n.z.string().min(1,"Confirm password is required")}).refine(u=>u.newPassword===u.confirmPassword,{message:"Confirm password does not match",path:["confirmPassword"]});class R extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return v}async execute(t){try{const{email:e,oldPassword:r,newPassword:a}=t,{error:s}=await this.supabase.auth.signInWithPassword({email:e,password:r});if(s)throw new g.ActionError("Current password is incorrect","INVALID_PASSWORD",400);const{error:i}=await this.supabase.auth.updateUser({password:a});if(i)throw new g.ActionError(i.message||"Failed to update password","UPDATE_FAILED",400);return{data:{message:"Password changed successfully"},status:200}}catch(e){throw e}}}const $=n.z.object({key:n.z.string()});class y extends g.ChaiBaseAction{constructor(e){super();E(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return $}async execute(e){try{const{key:r}=e,{error:a}=await this.supabase.storage.from(this.bucketName).remove([r]);return a?{error:`Failed to delete from Supabase Storage: ${a.message}`,status:500}:{data:{success:!0},status:200}}catch(r){return console.error("DELETE_FROM_STORAGE error:",r),{error:r instanceof Error?r.message:"Unknown error",status:500}}}}const j=n.z.object({file:n.z.string(),fileName:n.z.string(),contentType:n.z.string().optional(),folder:n.z.string().optional(),metadata:n.z.record(n.z.string(),n.z.any()).optional()});class _ extends g.ChaiBaseAction{constructor(e){super();E(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return j}async execute(e){try{if(!this.context)return{error:"Context not set",status:400};const{appId:r}=this.context,{file:a,fileName:s,contentType:i,folder:c,metadata:d}=e;let o;if(typeof a=="string"){const S=a.split(",")[1]||a;o=Buffer.from(S,"base64")}else o=a;const l=c?`${c}/${s}`:`${r}/${s}`,{data:w,error:h}=await this.supabase.storage.from(this.bucketName).upload(l,o,{contentType:i||"application/octet-stream",upsert:!0,...d&&{metadata:d}});if(h)return{error:`Failed to upload to Supabase Storage: ${h.message}`,status:500};const{data:{publicUrl:m}}=this.supabase.storage.from(this.bucketName).getPublicUrl(l);return{data:{url:m,key:w.path,size:o.length,metadata:d},status:200}}catch(r){return console.error("UPLOAD_TO_STORAGE error:",r),{error:r instanceof Error?r.message:"Unknown error",status:500}}}}const q=u=>({GET_CHAI_USER:new C(u),CHANGE_PASSWORD:new R(u)}),V=u=>({UPLOAD_ASSET:new z(u),GET_ASSET:new O(u),GET_ASSETS:new L(u),DELETE_ASSET:new N(u),UPDATE_ASSET:new B(u),UPLOAD_TO_STORAGE:new _(u),DELETE_FROM_STORAGE:new y(u)});exports.DeleteFromStorageAction=y;exports.SupabaseAuthActions=q;exports.SupabaseStorageActions=V;exports.UploadToStorageAction=_;
1
+ "use strict";var x=Object.defineProperty;var k=(u,t,e)=>t in u?x(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var E=(u,t,e)=>k(u,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("zod"),g=require("./actions-registery-CLL3KrNv.cjs"),A=require("lodash-es"),p=class p{constructor(t,e,r){this.appId=t,this.userId=e,this.supabase=r}appendUpdatedAtToUrl(t,e){if(A.isEmpty(t))return"";const r=new URL(t),a=new Date(e).getTime();return r.searchParams.set("t",a.toString()),`${r.origin}${r.pathname}${r.search}${r.hash}`}getBufferFromBase64(t){try{const e=t.split(",")[1]||t;return Buffer.from(e,"base64")}catch{throw new Error("Invalid base64 string format")}}getMimeType(t){var a;const e=((a=t.split(".").pop())==null?void 0:a.toLowerCase())||"";return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",webp:"image/webp",gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"}[e]||"application/octet-stream"}getImageDimensions(t){if(t.length>=p.MIN_PNG_LENGTH&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71)return{width:t.readUInt32BE(16),height:t.readUInt32BE(20)};if(t.length>=p.MIN_GIF_LENGTH&&t[0]===71&&t[1]===73&&t[2]===70)return{width:t.readUInt16LE(6),height:t.readUInt16LE(8)};if(t.length>=12&&t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80){if(t.length>=p.MIN_WEBP_VP8L_LENGTH&&t[12]===86&&t[13]===80&&t[14]===56&&t[15]===76){const e=t.readUInt32LE(21);return{width:(e&16383)+1,height:(e>>14&16383)+1}}if(t.length>=p.MIN_WEBP_VP8X_LENGTH&&t[12]===86&&t[13]===80&&t[14]===56&&t[15]===88)return{width:1+(t[24]|t[25]<<8|t[26]<<16),height:1+(t[27]|t[28]<<8|t[29]<<16)};if(t.length>=p.MIN_WEBP_VP8_LENGTH&&t[12]===86&&t[13]===80&&t[14]===56&&t[15]===32)return{width:t.readUInt16LE(26)&16383,height:t.readUInt16LE(28)&16383}}if(t.length>=2&&t[0]===255&&t[1]===216){let e=2;for(;e<t.length-1;){if(t[e]!==255){e++;continue}const r=t[e+1];if(r>=192&&r<=195||r>=197&&r<=199||r>=201&&r<=203||r>=205&&r<=207){if(e+p.MIN_JPEG_SOF_BYTES_FROM_MARKER<=t.length)return{width:t.readUInt16BE(e+7),height:t.readUInt16BE(e+5)};break}if(e+4>t.length)break;const a=t.readUInt16BE(e+2);e+=2+a}}return{width:0,height:0}}async uploadImageFile(t,e,r,a){try{const s=this.getBufferFromBase64(t),i=this.getMimeType(r);if(!["image/jpeg","image/png","image/webp","image/gif","image/tiff"].includes(i))throw new Error(`Invalid image format: ${i}`);const d=r.split("."),o=d.length>1?d.slice(0,-1).join("."):r,l=d.length>1?d[d.length-1].toLowerCase():"png",w=`${A.kebabCase(o)}.${l}`,h=this.appId,m=e?`${h}/${e}`:h,S=g.getChaiAction("UPLOAD_TO_STORAGE");if(!S)throw new Error("UPLOAD_TO_STORAGE action not found");S.setContext({appId:this.appId,userId:this.userId});const U=await S.execute({file:s.toString("base64"),fileName:w,contentType:i,folder:m});if(U.error)throw new Error(U.error);const{width:T,height:b}=this.getImageDimensions(s);return{url:U.data.url,thumbnailUrl:U.data.url,size:s.length,width:T,height:b,mimeType:i}}catch(s){return console.error("Upload image error:",s),{error:s instanceof Error?s.message:"Unknown error"}}}async uploadSvgFile(t,e,r){try{const a=this.getBufferFromBase64(t);let s,i;try{const S=a.toString("utf-8"),U=S.match(/\bwidth=["'](\d+)/),T=S.match(/\bheight=["'](\d+)/);U&&(s=parseInt(U[1],10)),T&&(i=parseInt(T[1],10))}catch{}const c=r.split("."),d=c.length>1?c.slice(0,-1).join("."):r,o=`${A.kebabCase(d)}.svg`,l=this.appId,w=e?`${l}/${e}`:l,h=g.getChaiAction("UPLOAD_TO_STORAGE");if(!h)throw new Error("UPLOAD_TO_STORAGE action not found");h.setContext({appId:this.appId,userId:this.userId});const m=await h.execute({file:a.toString("base64"),fileName:o,contentType:"image/svg+xml",folder:w});if(m.error)throw new Error(m.error);return{url:m.data.url,thumbnailUrl:m.data.url,size:a.length,width:s,height:i,mimeType:"image/svg+xml"}}catch(a){return console.error("SVG upload error:",a),{error:a instanceof Error?a.message:"Unknown error"}}}async upload({file:t,folderId:e,name:r,optimize:a=!0}){var s;try{const c=r.toLowerCase().endsWith(".svg")||t.includes("data:image/svg+xml")?await this.uploadSvgFile(t,e,r):await this.uploadImageFile(t,e,r,a??!0);if("error"in c)return c;const d={name:r,app:this.appId,url:c.url,thumbnailUrl:c.thumbnailUrl,size:(s=c.size)==null?void 0:s.toString(),width:c.width,height:c.height,format:c.mimeType.split("/")[1],folderId:e,type:c.mimeType.startsWith("image/")?"image":"file",createdBy:this.userId,updatedAt:new Date().toISOString()},{data:o,error:l}=await this.supabase.from("app_assets").insert(d).select("*").single();if(l)throw new Error(`Failed to store asset in database: ${l.message}`);return{id:o.id,name:o.name,type:o.type,url:this.appendUpdatedAtToUrl(o.url,o.updatedAt),size:o.size,thumbnailUrl:this.appendUpdatedAtToUrl(o.thumbnailUrl||"",o.updatedAt),width:o.width,height:o.height,format:o.format,folderId:o.folderId,createdBy:o.createdBy||"",createdAt:o.createdAt,updatedAt:o.updatedAt}}catch(i){return{error:i instanceof Error?i.message:"Unknown error occurred"}}}async getAsset({id:t}){try{const{data:e,error:r}=await this.supabase.from("app_assets").select("*").eq("id",t).eq("app",this.appId).single();if(r)throw new Error(`Failed to fetch asset: ${r.message}`);return A.set(e,"url",this.appendUpdatedAtToUrl(e.url,e.updatedAt)),A.set(e,"thumbnailUrl",this.appendUpdatedAtToUrl(e.thumbnailUrl||"",e.updatedAt)),e}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async getAssets({search:t="",page:e=1,limit:r=20}={}){try{const a=(e-1)*r;let s=this.supabase.from("app_assets").select("*",{count:"exact"}).eq("app",this.appId).order("updatedAt",{ascending:!1});t&&(s=s.or(`name.ilike.%${t}%,description.ilike.%${t}%`));const{data:i,error:c,count:d}=await s.range(a,a+r-1);if(c)throw new Error(c.message);return{assets:i.map(l=>(A.set(l,"url",this.appendUpdatedAtToUrl(l.url,l.updatedAt)),A.set(l,"thsupabaseumbnailUrl",this.appendUpdatedAtToUrl(l.thumbnailUrl||"",l.updatedAt)),l)),total:d||0,page:e,pageSize:r}}catch(a){throw console.error("Error fetching assets:",a),a}}async deleteAsset({id:t}){try{const{data:e,error:r}=await this.supabase.from("app_assets").select("*").eq("id",t).eq("app",this.appId).single();if(r)throw new Error(`Failed to fetch asset: ${r.message}`);if(e.url)try{const i=new URL(e.url).pathname.split("/"),c=i.indexOf("dam-assets");if(c!==-1){const d=i.slice(c+1).join("/"),o=g.getChaiAction("DELETE_FROM_STORAGE");if(o&&(o.setContext({appId:this.appId,userId:this.userId}),await o.execute({key:d})),e.thumbnailUrl&&e.thumbnailUrl!==e.url){const w=new URL(e.thumbnailUrl).pathname.split("/"),h=w.indexOf("dam-assets");if(h!==-1){const m=w.slice(h+1).join("/");o&&await o.execute({key:m})}}}}catch(s){console.warn("Failed to delete from storage, continuing with database deletion:",s)}const{error:a}=await this.supabase.from("app_assets").delete().eq("id",t);if(a)throw new Error(`Failed to delete asset: ${a.message}`);return{success:!0}}catch(e){return{error:e instanceof Error?e.message:"Unknown error occurred"}}}async updateAsset({id:t,file:e,description:r}){var a,s;try{const{data:i,error:c}=await this.supabase.from("app_assets").select("*").eq("id",t).single();if(c)throw new Error(`Failed to fetch asset: ${c.message}`);const d={};if(r!==void 0&&(d.description=r,d.updatedAt=new Date().toISOString()),e){const h=((a=i.format)==null?void 0:a.toLowerCase())==="svg"||e.includes("data:image/svg+xml")?await this.uploadSvgFile(e,i.folderId,i.name):await this.uploadImageFile(e,i.folderId,i.name,!0);if("error"in h)return h;d.url=h.url,d.thumbnailUrl=h.thumbnailUrl,d.size=(s=h.size)==null?void 0:s.toString(),d.width=h.width,d.height=h.height,d.format=h.mimeType.split("/")[1],d.updatedAt=new Date().toISOString()}const{data:o,error:l}=await this.supabase.from("app_assets").update(d).eq("id",t).select().single();if(l)throw new Error(`Failed to update asset: ${l.message}`);return A.set(o,"url",this.appendUpdatedAtToUrl(o.url,o.updatedAt)),A.set(o,"thumbnailUrl",this.appendUpdatedAtToUrl(o.thumbnailUrl||"",o.updatedAt)),o}catch(i){return{error:i instanceof Error?i.message:"Unknown error occurred"}}}};E(p,"MIN_PNG_LENGTH",24),E(p,"MIN_GIF_LENGTH",10),E(p,"MIN_WEBP_VP8L_LENGTH",25),E(p,"MIN_WEBP_VP8X_LENGTH",30),E(p,"MIN_WEBP_VP8_LENGTH",30),E(p,"MIN_JPEG_SOF_BYTES_FROM_MARKER",9);let I=p;const P=n.z.object({name:n.z.string(),file:n.z.string(),folderId:n.z.string().optional().nullable(),optimize:n.z.boolean().optional()});class z extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return P}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).upload(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPLOAD_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const f=n.z.object({id:n.z.string()});class O extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return f}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).getAsset(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const D=n.z.object({search:n.z.string().optional(),page:n.z.number().optional(),limit:n.z.number().optional()});class L extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return D}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).getAssets(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("GET_ASSETS error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const G=n.z.object({id:n.z.string()});class N extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return G}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).deleteAsset(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("DELETE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const F=n.z.object({id:n.z.string(),file:n.z.string().optional(),description:n.z.string().optional()});class B extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return F}async execute(t){try{if(!this.context)return{error:"Context not set",status:400};const{appId:e,userId:r}=this.context;if(!r)return{error:"User ID is required",status:401};const s=await new I(e,r,this.supabase).updateAsset(t);return"error"in s?{error:s.error,status:400}:s}catch(e){return console.error("UPDATE_ASSET error:",e),{error:e instanceof Error?e.message:"Unknown error",status:500}}}}const M=n.z.object({userId:n.z.string()});class C extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return M}async execute(t){var e,r,a,s,i,c;try{const{userId:d}=t,{data:o,error:l}=await this.supabase.auth.admin.getUserById(d);return l?{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}:{data:{id:((e=o.user)==null?void 0:e.id)||"unknown",email:((r=o.user)==null?void 0:r.email)||"unknown@chaibuilder.com",name:((s=(a=o.user)==null?void 0:a.user_metadata)==null?void 0:s.name)||"Unknown",avatar:((c=(i=o.user)==null?void 0:i.user_metadata)==null?void 0:c.avatar_url)||""},status:200}}catch{return{data:{id:"unknown",email:"unknown@chaibuilder.com",name:"Unknown",avatar:""},status:200}}}}const v=n.z.object({email:n.z.string().email(),oldPassword:n.z.string().min(1,"Old password is required"),newPassword:n.z.string().min(8,"New password must be at least 8 characters"),confirmPassword:n.z.string().min(1,"Confirm password is required")}).refine(u=>u.newPassword===u.confirmPassword,{message:"Confirm password does not match",path:["confirmPassword"]});class R extends g.ChaiBaseAction{constructor(t){super(),this.supabase=t}getValidationSchema(){return v}async execute(t){try{const{email:e,oldPassword:r,newPassword:a}=t,{error:s}=await this.supabase.auth.signInWithPassword({email:e,password:r});if(s)throw new g.ActionError("Current password is incorrect","INVALID_PASSWORD",400);const{error:i}=await this.supabase.auth.updateUser({password:a});if(i)throw new g.ActionError(i.message||"Failed to update password","UPDATE_FAILED",400);return{data:{message:"Password changed successfully"},status:200}}catch(e){throw e}}}const $=n.z.object({key:n.z.string()});class y extends g.ChaiBaseAction{constructor(e){super();E(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return $}async execute(e){try{const{key:r}=e,{error:a}=await this.supabase.storage.from(this.bucketName).remove([r]);return a?{error:`Failed to delete from Supabase Storage: ${a.message}`,status:500}:{data:{success:!0},status:200}}catch(r){return console.error("DELETE_FROM_STORAGE error:",r),{error:r instanceof Error?r.message:"Unknown error",status:500}}}}const j=n.z.object({file:n.z.string(),fileName:n.z.string(),contentType:n.z.string().optional(),folder:n.z.string().optional(),metadata:n.z.record(n.z.string(),n.z.any()).optional()});class _ extends g.ChaiBaseAction{constructor(e){super();E(this,"bucketName","dam-assets");this.supabase=e}getValidationSchema(){return j}async execute(e){try{if(!this.context)return{error:"Context not set",status:400};const{appId:r}=this.context,{file:a,fileName:s,contentType:i,folder:c,metadata:d}=e;let o;if(typeof a=="string"){const S=a.split(",")[1]||a;o=Buffer.from(S,"base64")}else o=a;const l=c?`${c}/${s}`:`${r}/${s}`,{data:w,error:h}=await this.supabase.storage.from(this.bucketName).upload(l,o,{contentType:i||"application/octet-stream",upsert:!0,...d&&{metadata:d}});if(h)return{error:`Failed to upload to Supabase Storage: ${h.message}`,status:500};const{data:{publicUrl:m}}=this.supabase.storage.from(this.bucketName).getPublicUrl(l);return{data:{url:m,key:w.path,size:o.length,metadata:d},status:200}}catch(r){return console.error("UPLOAD_TO_STORAGE error:",r),{error:r instanceof Error?r.message:"Unknown error",status:500}}}}const q=u=>({GET_CHAI_USER:new C(u),CHANGE_PASSWORD:new R(u)}),V=u=>({UPLOAD_ASSET:new z(u),GET_ASSET:new O(u),GET_ASSETS:new L(u),DELETE_ASSET:new N(u),UPDATE_ASSET:new B(u),UPLOAD_TO_STORAGE:new _(u),DELETE_FROM_STORAGE:new y(u)});exports.DeleteFromStorageAction=y;exports.SupabaseAuthActions=q;exports.SupabaseStorageActions=V;exports.UploadToStorageAction=_;
@@ -1,9 +1,9 @@
1
1
  var k = Object.defineProperty;
2
2
  var P = (u, t, e) => t in u ? k(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[t] = e;
3
3
  var w = (u, t, e) => P(u, typeof t != "symbol" ? t + "" : t, e);
4
- import { g as y, C as E, A as _ } from "./actions-registery-gJb_wq2F.js";
5
- import { isEmpty as f, kebabCase as x, set as I } from "lodash-es";
6
4
  import { z as o } from "zod";
5
+ import { g as y, C as E, A as _ } from "./actions-registery-CrGIlqUX.js";
6
+ import { isEmpty as f, kebabCase as x, set as I } from "lodash-es";
7
7
  const h = class h {
8
8
  // SOF marker (2) + segment length (2) + precision (1) + height (2) + width (2) = 9 bytes from marker
9
9
  constructor(t, e, r) {
package/dist/types.d.ts CHANGED
@@ -300,7 +300,6 @@ export declare interface ChaiBuilderEditorProps {
300
300
  * temporary props. Not to be used in production
301
301
  */
302
302
  flags?: {
303
- librarySite?: boolean;
304
303
  copyPaste?: boolean;
305
304
  exportCode?: boolean;
306
305
  darkMode?: boolean;
@@ -310,11 +309,7 @@ export declare interface ChaiBuilderEditorProps {
310
309
  gotoSettings?: boolean;
311
310
  dragAndDrop?: boolean;
312
311
  validateStructure?: boolean;
313
- designTokens?: boolean;
314
312
  ai?: boolean;
315
- revisions?: boolean;
316
- sharedJsonLD?: boolean;
317
- resetSeoToDefault?: boolean;
318
313
  };
319
314
  structureRules?: StructureRule[];
320
315
  designTokens?: ChaiDesignTokens;
@@ -613,8 +608,6 @@ export declare type ChaiWebsiteBuilderProps = {
613
608
  onLogout?: (reason?: string) => void;
614
609
  getAccessToken?: () => Promise<string>;
615
610
  currentUser: LoggedInUser | null;
616
- websocket?: any;
617
- realtimeAdapter?: RealtimeAdapter;
618
611
  } & Pick<ChaiBuilderEditorProps, "onError" | "translations" | "locale" | "htmlDir" | "autoSave" | "autoSaveActionsCount" | "fallbackLang" | "languages" | "themePresets" | "flags" | "structureRules">;
619
612
 
620
613
  export declare type ChaiWebsiteSetting = {
@@ -627,19 +620,6 @@ export declare type ChaiWebsiteSetting = {
627
620
  appChanges?: string[];
628
621
  };
629
622
 
630
- declare type CHANNEL_STATES = "JOINED" | "LEFT" | "ERROR" | "CLOSED" | "JOINING" | "LEAVING";
631
-
632
- /**
633
- * Realtime Adapter Interface
634
- *
635
- * This interface abstracts the realtime functionality to support multiple
636
- * realtime service providers (Supabase, Pusher, Ably, etc.)
637
- */
638
- /**
639
- * Represents the status of a channel subscription
640
- */
641
- declare type ChannelStatus = "SUBSCRIBED" | "CHANNEL_ERROR" | "TIMED_OUT" | "CLOSED";
642
-
643
623
  declare type CSSVariableName = string;
644
624
 
645
625
  declare type FilterOptions = {
@@ -660,84 +640,8 @@ declare type LoggedInUser = {
660
640
  metadata?: Record<string, any>;
661
641
  };
662
642
 
663
- /**
664
- * Presence state structure
665
- */
666
- declare interface PresenceState {
667
- [key: string]: any[];
668
- }
669
-
670
643
  declare type ReactComponentType = default_2.ComponentType<any>;
671
644
 
672
- /**
673
- * Main realtime adapter interface for creating channels
674
- */
675
- declare interface RealtimeAdapter {
676
- /**
677
- * Create or get a channel
678
- * @param channelId - Unique identifier for the channel
679
- * @param options - Provider-specific channel options
680
- * @returns Channel adapter instance
681
- */
682
- channel(channelId: string, options?: any): RealtimeChannelAdapter;
683
- }
684
-
685
- /**
686
- * Channel interface that wraps provider-specific channel implementations
687
- */
688
- declare interface RealtimeChannelAdapter {
689
- /**
690
- * The topic/name of the channel
691
- */
692
- topic: string;
693
- /**
694
- * The state of the channel
695
- */
696
- getState(): CHANNEL_STATES;
697
- /**
698
- * Subscribe to the channel
699
- * @param callback - Called when subscription status changes
700
- * @returns Promise that resolves when subscription is complete
701
- */
702
- subscribe(callback: (status: ChannelStatus) => void): Promise<void>;
703
- /**
704
- * Unsubscribe from the channel
705
- */
706
- unsubscribe(): void;
707
- /**
708
- * Listen for broadcast events
709
- * @param event - Event name to listen for
710
- * @param callback - Function to call when event is received
711
- */
712
- onBroadcast(event: string, callback: (payload: any) => void): void;
713
- /**
714
- * Listen for presence events (sync, join, leave)
715
- * @param event - Presence event type
716
- * @param callback - Function to call when event occurs
717
- */
718
- onPresence(event: string, callback: () => void): void;
719
- /**
720
- * Send a broadcast message to the channel
721
- * @param event - Event name
722
- * @param payload - Data to send
723
- */
724
- send(event: string, payload: any): Promise<void>;
725
- /**
726
- * Track presence in the channel
727
- * @param state - Presence state to track
728
- */
729
- track(state: any): Promise<void>;
730
- /**
731
- * Stop tracking presence in the channel
732
- */
733
- untrack(): void;
734
- /**
735
- * Get the current presence state
736
- * @returns Current presence state
737
- */
738
- presenceState(): PresenceState;
739
- }
740
-
741
645
  declare type SortOptions = {
742
646
  id: string;
743
647
  name: string;