@chaibuilder/sdk 3.2.13 → 4.0.0-beta.10

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 (193) hide show
  1. package/README.md +88 -61
  2. package/dist/2SSKDMRQ-CfHqXEo6.cjs +1 -0
  3. package/dist/2SSKDMRQ-KxbQMSQF.js +42 -0
  4. package/dist/AP7HFJJL-B3bVbF4b.cjs +1228 -0
  5. package/dist/AP7HFJJL-DJe0zNfP.js +9214 -0
  6. package/dist/IconPicker-7YKi0cvf.cjs +1 -0
  7. package/dist/IconPicker-CaEjFuuU.js +60 -0
  8. package/dist/STRINGS-BExFecZW.js +8 -0
  9. package/dist/STRINGS-FNnfjF5H.cjs +1 -0
  10. package/dist/WDYDFRGG-4MvQxrrE.cjs +1 -0
  11. package/dist/WDYDFRGG-DesO-YVt.js +33 -0
  12. package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
  13. package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
  14. package/dist/actions-registery-BRgseJas.cjs +418 -0
  15. package/dist/actions-registery-DRV8xywr.js +15540 -0
  16. package/dist/actions.cjs +1 -0
  17. package/dist/actions.d.ts +3229 -0
  18. package/dist/actions.js +216 -0
  19. package/dist/active-in-another-tab-BraPCVHD.js +35 -0
  20. package/dist/active-in-another-tab-DmiLcoHl.cjs +1 -0
  21. package/dist/add-new-language-page-BiS0BJFh.cjs +1 -0
  22. package/dist/add-new-language-page-DaNJhujm.js +402 -0
  23. package/dist/add-new-page-BavGPTWz.js +31 -0
  24. package/dist/add-new-page-dbDUyekW.cjs +1 -0
  25. package/dist/ai-panel-content-4Cv-ufXL.js +62 -0
  26. package/dist/ai-panel-content-ClQ5alrF.cjs +1 -0
  27. package/dist/ai-panel-default-lang-BVgCW7Iu.cjs +3 -0
  28. package/dist/ai-panel-default-lang-CByGoNp5.js +341 -0
  29. package/dist/ai-panel-other-lang-BXuiVjMR.cjs +1 -0
  30. package/dist/ai-panel-other-lang-DznZUrL7.js +162 -0
  31. package/dist/ai-prompt-input--MqeAtTu.cjs +1 -0
  32. package/dist/ai-prompt-input-DbNqAJmK.js +656 -0
  33. package/dist/ai-translation-prompt-CqZE5xvG.js +28 -0
  34. package/dist/ai-translation-prompt-yU9T98gu.cjs +1 -0
  35. package/dist/{apply-binding-DLaiD20q.js → apply-binding-CLU6Xp4K.js} +251 -257
  36. package/dist/apply-binding-NvZX_rJe.cjs +1 -0
  37. package/dist/code-display-9Onx6RCq.cjs +1 -0
  38. package/dist/{code-display-DuH-UOhl.js → code-display-oa1j0ri7.js} +1 -1
  39. package/dist/code-editor-DI5chGQy.js +51 -0
  40. package/dist/code-editor-eJ-ha21X.cjs +1 -0
  41. package/dist/continue-editing-in-this-client-BIPyGnqp.cjs +1 -0
  42. package/dist/continue-editing-in-this-client-Bs9Q2ase.js +25 -0
  43. package/dist/core-8lkXy4lC.cjs +1 -0
  44. package/dist/core-BvsZwF26.js +52 -0
  45. package/dist/core.cjs +1 -1
  46. package/dist/core.d.ts +145 -565
  47. package/dist/core.js +24 -103
  48. package/dist/css-import-modal-Cwq__qKK.cjs +13 -0
  49. package/dist/{css-import-modal-CFB2YjDT.js → css-import-modal-D-_jby_w.js} +40 -38
  50. package/dist/{delete-design-token-BjMakV-b.js → delete-design-token-BowiWJOb.js} +3 -3
  51. package/dist/delete-design-token-DjHXH5dg.cjs +1 -0
  52. package/dist/delete-page-Cs0cenoN.js +71 -0
  53. package/dist/delete-page-DqBuzcBW.cjs +1 -0
  54. package/dist/design-token-usage-DDqd3J3T.cjs +1 -0
  55. package/dist/design-token-usage-cjJe9KUU.js +114 -0
  56. package/dist/digital-asset-manager-DjPTwqCP.cjs +1 -0
  57. package/dist/digital-asset-manager-rw_FW-e4.js +877 -0
  58. package/dist/duplicate-page-B19XZEEh.js +134 -0
  59. package/dist/duplicate-page-CpgDT34h.cjs +1 -0
  60. package/dist/dynamic-page-selector-CJXMaEu0.cjs +1 -0
  61. package/dist/dynamic-page-selector-D1pcyyIi.js +86 -0
  62. package/dist/fonts-B-Xt29pe.cjs +1 -0
  63. package/dist/fonts-DRly3Wzd.js +78 -0
  64. package/dist/get-chai-builder-tailwind-config-DNp8Vhme.cjs +1 -0
  65. package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +14 -11
  66. package/dist/get-chai-builder-theme-BApShjRz.cjs +1 -0
  67. package/dist/get-chai-builder-theme-DDVRJQ6Z.js +24 -0
  68. package/dist/get-seo-defaults-9zHebckY.js +65 -0
  69. package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
  70. package/dist/image-compression-DZ9WMmyn.cjs +1 -0
  71. package/dist/image-compression-DsZ1oqpb.js +37 -0
  72. package/dist/image-editor-BihtCpkn.cjs +1 -0
  73. package/dist/image-editor-lztBulYI.js +108 -0
  74. package/dist/index-BEldAI1n.cjs +160 -0
  75. package/dist/index-BqlDf5fg.js +18418 -0
  76. package/dist/index-CsChke2B.js +4741 -0
  77. package/dist/index-DTz1hNwi.cjs +5 -0
  78. package/dist/json-diff-viewer-BDbS64LG.cjs +8 -0
  79. package/dist/json-diff-viewer-DI6nPbs8.js +259 -0
  80. package/dist/lang-panel-B51V4-PX.js +216 -0
  81. package/dist/lang-panel-DFttT_MB.cjs +1 -0
  82. package/dist/manage-design-tokens-D8GDkdB2.cjs +1 -0
  83. package/dist/{manage-design-tokens-BHCCrWFS.js → manage-design-tokens-DCPswHMS.js} +24 -24
  84. package/dist/mark-as-template-DBF2r7aW.js +157 -0
  85. package/dist/mark-as-template-rI-cx5-B.cjs +1 -0
  86. package/dist/models-5gOsRC56.cjs +1 -0
  87. package/dist/models-D95ZYr_x.js +70 -0
  88. package/dist/nested-path-selector-content-BQhK20BE.js +88 -0
  89. package/dist/nested-path-selector-content-o7k86m-q.cjs +1 -0
  90. package/dist/no-language-page-content-C2hLFt7A.js +43 -0
  91. package/dist/no-language-page-content-DmgQLhac.cjs +1 -0
  92. package/dist/no-language-page-dialog-BmB5fz92.js +10 -0
  93. package/dist/no-language-page-dialog-D2Ijv2V4.cjs +1 -0
  94. package/dist/page-creator-CGxrkmut.js +796 -0
  95. package/dist/page-creator-jlPEOhfz.cjs +1 -0
  96. package/dist/page-lock-CnOS_qxc.js +30 -0
  97. package/dist/page-lock-CoAmLhTA.cjs +1 -0
  98. package/dist/page-locked-dialog-B2L9yqX1.js +136 -0
  99. package/dist/page-locked-dialog-BNHr0OAi.cjs +1 -0
  100. package/dist/page-manager-new-CkNowPYt.cjs +1 -0
  101. package/dist/page-manager-new-D_TxW1yk.js +395 -0
  102. package/dist/page-manager-search-and-filter-Bme84N1w.js +202 -0
  103. package/dist/page-manager-search-and-filter-CpjNOQqF.cjs +1 -0
  104. package/dist/page-revisions-content-B_EkI6eN.js +456 -0
  105. package/dist/page-revisions-content-DYt-0IJ3.cjs +1 -0
  106. package/dist/pages.cjs +1 -0
  107. package/dist/pages.d.ts +545 -0
  108. package/dist/pages.js +27 -0
  109. package/dist/plugin-BGlQf0iy.cjs +22 -0
  110. package/dist/{plugin-BOcGV_IY.js → plugin-C-ht41UZ.js} +31 -45
  111. package/dist/publish-pages-content-1_-8jO3C.cjs +1 -0
  112. package/dist/publish-pages-content-Ct-rYFXD.js +179 -0
  113. package/dist/register-chai-top-bar-CX_JkRJn.js +237 -0
  114. package/dist/register-chai-top-bar-DWTuRU53.cjs +1 -0
  115. package/dist/register-partial-type-BjtdfKHE.js +36 -0
  116. package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
  117. package/dist/render.cjs +2 -2
  118. package/dist/render.d.ts +25 -23
  119. package/dist/render.js +108 -103
  120. package/dist/rte-widget-modal-88x3Ag4b.cjs +1 -0
  121. package/dist/rte-widget-modal-BpjTwrAJ.js +39 -0
  122. package/dist/runtime-client.cjs +1 -0
  123. package/dist/runtime-client.d.ts +158 -0
  124. package/dist/runtime-client.js +32 -0
  125. package/dist/runtime.cjs +1 -1
  126. package/dist/runtime.d.ts +322 -7
  127. package/dist/runtime.js +74 -1
  128. package/dist/save-to-lib-B5ggugo6.js +423 -0
  129. package/dist/save-to-lib-BSCJSBw9.cjs +1 -0
  130. package/dist/sdk.css +1 -1
  131. package/dist/selected-block-display-DrMFz5_U.js +320 -0
  132. package/dist/selected-block-display-wHwP16Pz.cjs +16 -0
  133. package/dist/seo-panel-Bktda7aV.cjs +2 -0
  134. package/dist/seo-panel-Dzx-sUAi.js +799 -0
  135. package/dist/shared-json-ld-BMt3lSVf.js +566 -0
  136. package/dist/shared-json-ld-RDvoItXK.cjs +1 -0
  137. package/dist/slug-input-BtbW6w7B.cjs +1 -0
  138. package/dist/slug-input-CyKRaEV_.js +87 -0
  139. package/dist/supabase-actions.cjs +1 -0
  140. package/dist/supabase-actions.d.ts +289 -0
  141. package/dist/supabase-actions.js +524 -0
  142. package/dist/take-over-request-BA_e938L.js +64 -0
  143. package/dist/take-over-request-DsDWVplQ.cjs +1 -0
  144. package/dist/theme-panel-footer-6iHKSeON.cjs +1 -0
  145. package/dist/theme-panel-footer-v8PRUzwR.js +26 -0
  146. package/dist/translation-warning-modal-B1tAPMx7.js +27 -0
  147. package/dist/translation-warning-modal-DA7Vj_9F.cjs +1 -0
  148. package/dist/types.cjs +1 -0
  149. package/dist/types.d.ts +598 -0
  150. package/dist/types.js +1 -0
  151. package/dist/unmark-as-template-Bdg5nLBS.cjs +1 -0
  152. package/dist/unmark-as-template-C6pllRk5.js +40 -0
  153. package/dist/unpublish-page-BOrfamLs.cjs +1 -0
  154. package/dist/unpublish-page-C3Wub7gR.js +28 -0
  155. package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
  156. package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
  157. package/dist/utils.cjs +1 -0
  158. package/dist/{tailwind.d.ts → utils.d.ts} +12 -12
  159. package/dist/utils.js +7 -0
  160. package/dist/web-blocks.cjs +1 -1
  161. package/dist/web-blocks.d.ts +0 -6
  162. package/dist/web-blocks.js +240 -239
  163. package/dist/web-preview-869kgvNU.cjs +1 -0
  164. package/dist/web-preview-CVAQ53g_.js +73 -0
  165. package/package.json +152 -76
  166. package/dist/IconPicker-6JSublJp.js +0 -64
  167. package/dist/IconPicker-DpQQDK_Q.cjs +0 -1
  168. package/dist/apply-binding-Bn1KC8uC.cjs +0 -1
  169. package/dist/code-display-Dw1tAwiJ.cjs +0 -1
  170. package/dist/code-editor-CEsA4Nlq.cjs +0 -1
  171. package/dist/code-editor-DPr4HDOV.js +0 -59
  172. package/dist/css-import-modal-bGWZSlqv.cjs +0 -13
  173. package/dist/delete-design-token-Bzxspf8D.cjs +0 -1
  174. package/dist/design-token-usage-DyQcFypc.cjs +0 -1
  175. package/dist/design-token-usage-_FBnvL92.js +0 -120
  176. package/dist/get-chai-builder-tailwind-config-C6MHaUM0.cjs +0 -1
  177. package/dist/get-chai-builder-theme-B1tr_NJB.cjs +0 -1
  178. package/dist/get-chai-builder-theme-BarMkcGH.js +0 -12
  179. package/dist/index-CIez6R-d.js +0 -18327
  180. package/dist/index-zLw6cVaV.cjs +0 -160
  181. package/dist/manage-design-tokens-Cfjg_at9.cjs +0 -1
  182. package/dist/mockServiceWorker.js +0 -349
  183. package/dist/plugin-CSgw-f78.cjs +0 -22
  184. package/dist/rte-widget-modal-CsBCpJSY.js +0 -41
  185. package/dist/rte-widget-modal-Dif3ZoFQ.cjs +0 -1
  186. package/dist/tailwind.cjs +0 -1
  187. package/dist/tailwind.js +0 -8
  188. package/dist/tooltip-Ba1-8jmj.cjs +0 -1
  189. package/dist/tooltip-DUosa-uC.js +0 -1067
  190. package/dist/ui.cjs +0 -1
  191. package/dist/ui.d.ts +0 -415
  192. package/dist/ui.js +0 -129
  193. package/dist/vite.svg +0 -1
@@ -0,0 +1,796 @@
1
+ import { jsx as s, jsxs as l, Fragment as We } from "react/jsx-runtime";
2
+ import { z as M, h as ye, B as W } from "./register-chai-top-bar-CX_JkRJn.js";
3
+ import { j as os, L as z, a6 as ee, a7 as se, P as ae, C as le, k as ne, l as G, m as I, ai as cs, n as us } from "./index-BqlDf5fg.js";
4
+ import { useState as y, useRef as ms, useEffect as ze, useMemo as B, startTransition as Oe } from "react";
5
+ import { r as te, S as hs, c as Be } from "./slug-input-CyKRaEV_.js";
6
+ import { isEmpty as Ie, startCase as de, filter as ps, find as ge, groupBy as ds, pick as fs, set as P } from "lodash-es";
7
+ import { ChevronDown as re, Search as ie, Check as R } from "lucide-react";
8
+ import { ar as Re, as as Ue, A as oe, m as gs, at as ys, g as vs, h as Ns, i as Ss, ay as bs, L as ws } from "./index-CsChke2B.js";
9
+ import { useQuery as _e } from "@tanstack/react-query";
10
+ import { toast as E } from "sonner";
11
+ import { g as $e } from "./get-seo-defaults-9zHebckY.js";
12
+ function xs({
13
+ value: a,
14
+ onChange: o,
15
+ placeholder: v = "Enter custom slug part",
16
+ dynamicPattern: p,
17
+ onValidationChange: i
18
+ }) {
19
+ const [g, u] = y(null), m = ms(null), [f, C] = y(p + a);
20
+ ze(() => {
21
+ C(p + a);
22
+ }, [a, p]);
23
+ const F = (S) => {
24
+ const b = S.target.value;
25
+ if (!b.startsWith(p)) {
26
+ const O = b.replace(p, ""), U = p + O;
27
+ C(U), o(O);
28
+ return;
29
+ }
30
+ const t = b.substring(p.length).replace(/\//g, "").replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-_.]/g, "-").replace(/-+/g, "-").replace(/^-+/, "").toLowerCase(), n = (t.match(/\./g) || []).length, d = n <= 1;
31
+ n > 1 ? u("Invalid slug. Only one dot (.) is allowed in the slug") : u(null), i && i(d);
32
+ const N = p + t;
33
+ C(N), o(t);
34
+ }, w = () => {
35
+ if (m.current) {
36
+ const S = m.current;
37
+ setTimeout(() => {
38
+ const b = p.length;
39
+ S.setSelectionRange(b, b);
40
+ }, 0);
41
+ }
42
+ }, $ = (S) => {
43
+ const b = S.currentTarget;
44
+ (b.selectionStart || 0) <= p.length && setTimeout(() => {
45
+ const t = p.length;
46
+ b.setSelectionRange(t, t);
47
+ }, 0);
48
+ };
49
+ return /* @__PURE__ */ s("div", { children: /* @__PURE__ */ l("div", { className: "relative", children: [
50
+ /* @__PURE__ */ l("p", { className: "mb-2 text-xs text-gray-500", children: [
51
+ `${p}`,
52
+ " is a dynamic segment of slug"
53
+ ] }),
54
+ /* @__PURE__ */ s(
55
+ M,
56
+ {
57
+ ref: m,
58
+ value: f,
59
+ onChange: F,
60
+ onFocus: w,
61
+ onClick: $,
62
+ placeholder: v,
63
+ className: g ? "border-red-500" : ""
64
+ }
65
+ ),
66
+ g && /* @__PURE__ */ s("div", { className: "mt-1 text-xs text-red-500", children: g })
67
+ ] }) });
68
+ }
69
+ const ce = ({ children: a, onWheel: o, ...v }) => /* @__PURE__ */ s(os, { ...v, onWheel: (i) => {
70
+ try {
71
+ i.preventDefault();
72
+ const g = i.currentTarget;
73
+ g.scrollTop += i.deltaY;
74
+ } catch {
75
+ i.preventDefault();
76
+ }
77
+ o && o(i);
78
+ }, children: a }), fe = (...a) => a.filter(Boolean).join(" ");
79
+ function Cs({
80
+ pages: a,
81
+ selectedParentId: o,
82
+ onChange: v,
83
+ className: p,
84
+ id: i = "parentPage",
85
+ currentPage: g
86
+ }) {
87
+ const [u, m] = y(!1), [f, C] = y(""), F = ye("enable-add-page-dropdown");
88
+ F || (p = "w-full rounded-md border border-gray-300 px-3 py-2");
89
+ const w = B(() => !a || a.length === 0 ? [] : a.filter((d) => !Ie(d.slug)).filter((d) => d.slug !== "/").sort((d, N) => d.slug.localeCompare(N.slug)), [a]), $ = B(() => {
90
+ if (!f.trim()) return w;
91
+ const n = f.toLowerCase();
92
+ return w.filter(
93
+ (d) => d.name.toLowerCase().includes(n) || d.slug.toLowerCase().includes(n)
94
+ );
95
+ }, [w, f]), S = (n) => Math.max(0, (n.match(/\//g) || []).length - 1), b = (n) => "    ".repeat(n), h = (n) => {
96
+ if (n === "/") return "/";
97
+ const d = n.split("/").filter(Boolean);
98
+ if (d.length <= 1) {
99
+ const N = d[0] || "";
100
+ return `/${te(N)}`;
101
+ }
102
+ return `/${te(d[d.length - 1])}`;
103
+ }, t = () => {
104
+ if (!o || o === "none") return "None";
105
+ const n = w.find((d) => d.id === o);
106
+ return n ? `${n.name} (${h(n.slug)})` : "None";
107
+ };
108
+ return /* @__PURE__ */ l("div", { className: "space-y-0.5", children: [
109
+ /* @__PURE__ */ s(z, { htmlFor: i, className: "text-sm", children: "Parent" }),
110
+ F ? /* @__PURE__ */ l(ee, { open: u, onOpenChange: m, children: [
111
+ /* @__PURE__ */ s(se, { asChild: !0, children: /* @__PURE__ */ l(
112
+ W,
113
+ {
114
+ id: i,
115
+ variant: "outline",
116
+ role: "combobox",
117
+ className: fe("w-full justify-between", p),
118
+ "data-testid": "parent-page-selector",
119
+ children: [
120
+ t(),
121
+ /* @__PURE__ */ s(re, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
122
+ ]
123
+ }
124
+ ) }),
125
+ /* @__PURE__ */ s(ae, { className: "w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: /* @__PURE__ */ l(le, { shouldFilter: !1, children: [
126
+ /* @__PURE__ */ s("div", { className: "relative border-none py-2", children: /* @__PURE__ */ s("div", { className: "sticky top-0 z-10 bg-white px-3 py-2", children: /* @__PURE__ */ l("div", { className: "relative", children: [
127
+ /* @__PURE__ */ s(ie, { strokeWidth: 2, className: "absolute left-2 top-2 h-4 w-4 text-gray-400" }),
128
+ /* @__PURE__ */ s(
129
+ M,
130
+ {
131
+ placeholder: "Search pages...",
132
+ className: "h-8 pl-8 text-xs",
133
+ value: f,
134
+ onChange: (n) => C(n.target.value)
135
+ }
136
+ )
137
+ ] }) }) }),
138
+ /* @__PURE__ */ l(ce, { className: "max-h-[300px] overflow-y-auto", children: [
139
+ /* @__PURE__ */ s(ne, { children: "No pages found." }),
140
+ /* @__PURE__ */ l(G, { children: [
141
+ /* @__PURE__ */ l(
142
+ I,
143
+ {
144
+ value: "none",
145
+ onSelect: () => {
146
+ v(""), m(!1), C("");
147
+ },
148
+ className: "flex cursor-pointer items-center justify-between",
149
+ children: [
150
+ /* @__PURE__ */ s("span", { children: "None" }),
151
+ /* @__PURE__ */ s(R, { className: fe("mr-2 h-4 w-4", o ? "opacity-0" : "opacity-100") })
152
+ ]
153
+ }
154
+ ),
155
+ $.map((n) => {
156
+ const d = b(S(n.slug)), N = h(n.slug), O = /* @__PURE__ */ l("span", { className: "flex items-center text-sm", children: [
157
+ d,
158
+ n.name,
159
+ /* @__PURE__ */ l("span", { className: "text-xs text-gray-500", children: [
160
+ " (",
161
+ N,
162
+ ")"
163
+ ] })
164
+ ] });
165
+ return /* @__PURE__ */ l(
166
+ I,
167
+ {
168
+ value: n.id,
169
+ onSelect: () => {
170
+ v(n.id), m(!1), C("");
171
+ },
172
+ className: "flex cursor-pointer items-center justify-between whitespace-pre-wrap",
173
+ children: [
174
+ /* @__PURE__ */ s("span", { children: O }),
175
+ /* @__PURE__ */ s(
176
+ R,
177
+ {
178
+ className: fe(
179
+ "mr-2 h-4 w-4 shrink-0",
180
+ o === n.id ? "opacity-100" : "opacity-0"
181
+ )
182
+ }
183
+ )
184
+ ]
185
+ },
186
+ n.id
187
+ );
188
+ })
189
+ ] })
190
+ ] })
191
+ ] }) })
192
+ ] }) : /* @__PURE__ */ l(
193
+ "select",
194
+ {
195
+ id: i,
196
+ value: o || "none",
197
+ onChange: (n) => v(n.target.value),
198
+ className: p,
199
+ "data-testid": "parent-page-selector",
200
+ children: [
201
+ /* @__PURE__ */ s("option", { value: "none", children: "None" }),
202
+ w.map((n) => {
203
+ const d = S(n.slug), N = d > 0 ? b(d) : "", O = h(n.slug);
204
+ return (g == null ? void 0 : g.id) === n.id || n.slug.startsWith(g == null ? void 0 : g.slug) ? null : /* @__PURE__ */ l("option", { value: n.id, children: [
205
+ N,
206
+ n.name,
207
+ " (",
208
+ O,
209
+ ")"
210
+ ] }, n.id);
211
+ })
212
+ ]
213
+ }
214
+ )
215
+ ] });
216
+ }
217
+ const ks = (...a) => a.filter(Boolean).join(" "), Ls = ({
218
+ templates: a,
219
+ selectedTemplateId: o,
220
+ onSelectTemplate: v,
221
+ isLoading: p = !1
222
+ }) => {
223
+ const [i, g] = y(""), [u, m] = y(!1), [f, C] = y(""), F = ye("enable-add-page-dropdown");
224
+ if (ze(() => {
225
+ if (o) {
226
+ const h = a.find((t) => t.id === o);
227
+ Oe(() => g((h == null ? void 0 : h.preview) || ""));
228
+ } else
229
+ Oe(() => g(""));
230
+ }, [o, a]), p)
231
+ return /* @__PURE__ */ s("div", { className: "flex h-fit items-center justify-center text-sm text-gray-500", children: "Loading templates..." });
232
+ if (a.length === 0)
233
+ return null;
234
+ const w = {};
235
+ a.forEach((h) => {
236
+ const t = h.libraryName;
237
+ w[t] || (w[t] = []), w[t].push(h);
238
+ });
239
+ const $ = Object.entries(w).reduce(
240
+ (h, [t, n]) => {
241
+ const d = n.filter(
242
+ (N) => N.name.toLowerCase().includes(f.toLowerCase()) || t.toLowerCase().includes(f.toLowerCase())
243
+ );
244
+ return d.length > 0 && (h[t] = d), h;
245
+ },
246
+ {}
247
+ ), S = a.find((h) => h.id === o), b = S ? de(S.name) : "No Template";
248
+ return /* @__PURE__ */ l("div", { className: "space-y-4", children: [
249
+ F ? /* @__PURE__ */ l(ee, { open: u, onOpenChange: m, children: [
250
+ /* @__PURE__ */ s(se, { asChild: !0, children: /* @__PURE__ */ l(W, { variant: "outline", role: "combobox", className: "w-full justify-between", children: [
251
+ b,
252
+ /* @__PURE__ */ s(re, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
253
+ ] }) }),
254
+ /* @__PURE__ */ s(ae, { className: "w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: /* @__PURE__ */ l(le, { shouldFilter: !1, children: [
255
+ /* @__PURE__ */ s("div", { className: "sticky top-0 z-10 bg-white px-3 py-2", children: /* @__PURE__ */ l("div", { className: "relative", children: [
256
+ /* @__PURE__ */ s(ie, { strokeWidth: 2, className: "absolute left-2 top-2 h-4 w-4 text-gray-400" }),
257
+ /* @__PURE__ */ s(
258
+ M,
259
+ {
260
+ placeholder: "Search templates...",
261
+ className: "h-8 pl-8 text-xs",
262
+ value: f,
263
+ onChange: (h) => C(h.target.value)
264
+ }
265
+ )
266
+ ] }) }),
267
+ /* @__PURE__ */ l(ce, { className: "max-h-[300px] overflow-y-auto", children: [
268
+ /* @__PURE__ */ s(ne, { children: "No templates found." }),
269
+ Object.entries($).map(([h, t]) => /* @__PURE__ */ s(G, { heading: h, children: t.map((n) => /* @__PURE__ */ l(
270
+ I,
271
+ {
272
+ value: n.id,
273
+ onSelect: () => {
274
+ v(n.id), m(!1), C("");
275
+ },
276
+ className: "flex cursor-pointer items-center justify-between",
277
+ children: [
278
+ de(n.name),
279
+ /* @__PURE__ */ s(
280
+ R,
281
+ {
282
+ className: ks(
283
+ "mr-2 h-4 w-4",
284
+ o === n.id ? "opacity-100" : "opacity-0"
285
+ )
286
+ }
287
+ )
288
+ ]
289
+ },
290
+ n.id
291
+ )) }, h))
292
+ ] })
293
+ ] }) })
294
+ ] }) : /* @__PURE__ */ l(
295
+ "select",
296
+ {
297
+ className: "w-full rounded-md border border-gray-300 px-3 py-2",
298
+ value: o,
299
+ onChange: (h) => v(h.target.value),
300
+ children: [
301
+ /* @__PURE__ */ s("option", { value: "", children: "No Template" }),
302
+ Object.entries(w).map(([h, t]) => /* @__PURE__ */ s("optgroup", { label: h, children: t.map((n) => /* @__PURE__ */ s("option", { value: n.id, children: de(n.name) }, n.id)) }, h))
303
+ ]
304
+ }
305
+ ),
306
+ i && /* @__PURE__ */ l("div", { className: "mt-3 overflow-hidden rounded border", children: [
307
+ /* @__PURE__ */ s("div", { className: "max-h-[200px] overflow-auto", children: /* @__PURE__ */ s("img", { src: i, alt: "Template Preview", className: "w-full object-contain" }) }),
308
+ /* @__PURE__ */ s("div", { className: "border-t bg-gray-50 p-2 text-xs text-gray-500", children: "Template preview" })
309
+ ] })
310
+ ] });
311
+ }, Ts = () => {
312
+ const a = Re(), o = Ue();
313
+ return _e({
314
+ queryKey: [oe.GET_LIBRARIES],
315
+ staleTime: "static",
316
+ queryFn: async () => await o(a, { action: oe.GET_LIBRARIES }) || []
317
+ });
318
+ }, js = (a) => {
319
+ const o = Re(), v = Ue();
320
+ return _e({
321
+ queryKey: [oe.GET_TEMPLATES_BY_TYPE, a],
322
+ staleTime: "static",
323
+ enabled: !!a,
324
+ queryFn: async () => {
325
+ const p = await v(o, {
326
+ action: oe.GET_TEMPLATES_BY_TYPE,
327
+ data: { pageType: a }
328
+ });
329
+ return (a ? ps(p, { pageType: a }) : p) || [];
330
+ }
331
+ });
332
+ }, Ds = (a) => {
333
+ const { data: o = [], isLoading: v } = js(a), { data: p = [], isLoading: i } = Ts(), g = B(() => v || i ? [] : o.map((m) => {
334
+ const f = ge(p, { id: m.library });
335
+ return {
336
+ ...m,
337
+ libraryName: (f == null ? void 0 : f.type) !== "shared" ? "Site Library" : (f == null ? void 0 : f.name) + " Library",
338
+ libraryType: f == null ? void 0 : f.type
339
+ };
340
+ }), [o, p, v, i]), u = B(() => ds(g, "libraryName"), [g]);
341
+ return {
342
+ data: g,
343
+ groupedData: u,
344
+ isLoading: v || i
345
+ };
346
+ }, V = (...a) => a.filter(Boolean).join(" ");
347
+ function qs({ addEditPage: a, close: o, closePanel: v }) {
348
+ var Ae, Fe;
349
+ const { data: p } = gs(), i = B(() => p ?? [], [p]), g = ys(), u = !!(a != null && a.id), { data: m } = vs(), { mutate: f, isPending: C } = Ns(), { mutate: F, isPending: w } = Ss(), [$, S] = y(null), [b, h] = y(!0), [t, n] = y((a == null ? void 0 : a.pageType) ?? "page"), { hasPermission: d } = cs(), N = d(bs.CHANGE_PAGE_TYPE), [O, U] = y(!1), [qe, Ve] = y(""), { selectedLang: Ge, fallbackLang: Me } = us(), ve = Ge || Me, [Y, Z] = y(""), [Ne, H] = y(!1), Se = B(() => {
350
+ const e = i.find((c) => c.key === t);
351
+ return (e == null ? void 0 : e.hasSlug) === !1;
352
+ }, [t, i]), [k, Ye] = y((a == null ? void 0 : a.parent) ?? ""), [_, be] = y((a == null ? void 0 : a.name) ?? ""), [T, we] = y((a == null ? void 0 : a.dynamic) ?? !1), [j, K] = y(T ? "" : ((a == null ? void 0 : a.slug) ?? "").split("/").pop() || ""), [xe, Ce] = y((a == null ? void 0 : a.dynamicSlugCustom) ?? ""), [ke, Qe] = y(!0), [He, ue] = y(!1), [me, Ke] = y(""), { data: Le, isLoading: Ze } = Ds(t), Q = C || w, Te = ye("enable-add-page-dropdown"), he = B(() => !u || !(a != null && a.id) || !m ? null : m.find((e) => e.id === a.id), [u, a == null ? void 0 : a.id, m]), Je = (he == null ? void 0 : he.online) || !1, Xe = B(() => !u || !(a != null && a.id) || !m ? !1 : m.some((e) => e.parent === a.id), [u, a == null ? void 0 : a.id, m]), r = i.find((e) => e.key === t), q = (e) => {
353
+ if (u && t !== e) {
354
+ Ve(e), U(!0), Z(""), H(!1);
355
+ return;
356
+ }
357
+ n(e), Z(""), H(!1);
358
+ }, je = () => {
359
+ n(qe), U(!1), we(!1);
360
+ }, Pe = (e) => {
361
+ we(e), e ? K("") : Ce("");
362
+ }, Ee = (e) => {
363
+ if (Ye(e), e && e !== "none") {
364
+ const c = m == null ? void 0 : m.find((x) => x.id === e), D = (c == null ? void 0 : c.slug) || "";
365
+ if (j.startsWith(D)) {
366
+ const x = j.slice(D.length).replace(/^\/+/, "");
367
+ K(x);
368
+ } else
369
+ K(j.replace(/^\/+/, ""));
370
+ } else
371
+ K(j ? `${j}` : "");
372
+ }, es = (e) => {
373
+ Ke(e);
374
+ }, ss = () => _.trim() ? T && !Ie(j) ? (S("Slug must be empty when using dynamic slug"), !1) : T && !ke ? (S("Dynamic slug is invalid"), !1) : !0 : (E.error("Name is required"), !1), as = () => {
375
+ const e = {
376
+ pageType: r == null ? void 0 : r.key,
377
+ name: _,
378
+ slug: "",
379
+ hasSlug: !1
380
+ };
381
+ u ? F(
382
+ { id: a == null ? void 0 : a.id, name: _ },
383
+ {
384
+ onSuccess: () => {
385
+ E.success((r == null ? void 0 : r.name) + " updated successfully"), o();
386
+ }
387
+ }
388
+ ) : f(e, {
389
+ onSuccess: (c) => {
390
+ o(), g(c.page.id, v);
391
+ }
392
+ });
393
+ }, ls = (e, c) => {
394
+ if (!e.trim() && !T)
395
+ return S("Child page slug is required"), !1;
396
+ const D = te(c), x = Be(D, e);
397
+ return Object.keys(ws).some((X) => x === `/${X}` || (x == null ? void 0 : x.startsWith(`/${X}/`))) ? (S("Slugs cannot start with a language code for primary page"), !1) : !0;
398
+ }, ns = (e, c) => {
399
+ const D = te(c), x = Be(D, e), L = {
400
+ pageType: t,
401
+ name: _,
402
+ slug: x.replace(/\/$/, ""),
403
+ // remove trailing slashes
404
+ parent: k,
405
+ dynamic: T,
406
+ hasSlug: !0,
407
+ template: me || void 0,
408
+ tracking: {},
409
+ seo: {},
410
+ jsonLD: {}
411
+ };
412
+ if (T && (L.dynamicSlugCustom = xe), u) {
413
+ const A = fs(L, ["pageType", "parent", "name", "slug", "dynamic", "dynamicSlugCustom"]);
414
+ F(
415
+ { id: a == null ? void 0 : a.id, ...A },
416
+ {
417
+ onSuccess: () => {
418
+ E.success("Page updated successfully"), o();
419
+ }
420
+ }
421
+ );
422
+ } else {
423
+ const A = ge(i, { key: t });
424
+ A != null && A.trackingDefault && (L.tracking = A.trackingDefault);
425
+ const { seo: X, jsonLD: rs } = $e(A, ve);
426
+ P(L, "seo", X), P(L, "jsonLD", rs), f(L, {
427
+ onSuccess: (is) => {
428
+ o(), g(is.page.id, v);
429
+ }
430
+ });
431
+ }
432
+ }, ts = () => {
433
+ const e = {
434
+ pageType: t,
435
+ name: _,
436
+ slug: j === "" ? "/" : `/${j.replace(/\/$/, "")}`,
437
+ template: me || void 0,
438
+ parent: null,
439
+ tracking: {}
440
+ };
441
+ if (u)
442
+ F(
443
+ { id: a == null ? void 0 : a.id, ...e },
444
+ {
445
+ onSuccess: () => {
446
+ E.success("Page updated successfully"), o();
447
+ }
448
+ }
449
+ );
450
+ else {
451
+ const c = ge(i, { key: t });
452
+ c != null && c.trackingDefault && (e.tracking = c.trackingDefault);
453
+ const { seo: D, jsonLD: x } = $e(c, ve);
454
+ P(e, "seo", D), P(e, "jsonLD", x), f(e, {
455
+ onSuccess: (L) => {
456
+ var A;
457
+ (A = L == null ? void 0 : L.page) != null && A.id && g(L.page.id, v), o();
458
+ }
459
+ });
460
+ }
461
+ }, De = (e) => {
462
+ if (e.preventDefault(), S(null), !!ss()) {
463
+ if (!(r != null && r.hasSlug)) {
464
+ as();
465
+ return;
466
+ }
467
+ if (k && k !== "none") {
468
+ const c = m == null ? void 0 : m.find((x) => x.id === k), D = (c == null ? void 0 : c.slug) || "";
469
+ if (!ls(j, D))
470
+ return;
471
+ ns(j, D);
472
+ } else
473
+ ts();
474
+ }
475
+ }, { pagesType: pe, partialsType: J } = B(() => {
476
+ const e = (c) => Y ? c.name.toLowerCase().includes(Y.toLowerCase()) || c.key.toLowerCase().includes(Y.toLowerCase()) : !0;
477
+ return {
478
+ pagesType: i.filter((c) => c.hasSlug !== !1 && e(c)),
479
+ partialsType: i.filter((c) => c.hasSlug === !1 && e(c))
480
+ };
481
+ }, [i, Y]);
482
+ return r != null && r.hasSlug ? /* @__PURE__ */ l("form", { onSubmit: De, className: "mx-auto w-full max-w-md space-y-4", children: [
483
+ /* @__PURE__ */ l("div", { className: "space-y-0.5", children: [
484
+ /* @__PURE__ */ s(z, { htmlFor: "pageType", className: "text-sm", children: "Type" }),
485
+ Te ? /* @__PURE__ */ l(ee, { open: Ne, onOpenChange: H, children: [
486
+ /* @__PURE__ */ s(se, { asChild: !0, children: /* @__PURE__ */ l(
487
+ W,
488
+ {
489
+ variant: "outline",
490
+ role: "combobox",
491
+ disabled: u && !N,
492
+ className: V(
493
+ "w-full justify-between",
494
+ u && !N ? "cursor-not-allowed text-gray-500" : ""
495
+ ),
496
+ children: [
497
+ (r == null ? void 0 : r.name) || "Select page type",
498
+ /* @__PURE__ */ s(re, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
499
+ ]
500
+ }
501
+ ) }),
502
+ /* @__PURE__ */ s(ae, { className: "w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: /* @__PURE__ */ l(le, { shouldFilter: !1, children: [
503
+ /* @__PURE__ */ s("div", { className: "sticky top-0 z-10 bg-white px-3 py-2", children: /* @__PURE__ */ l("div", { className: "relative", children: [
504
+ /* @__PURE__ */ s(ie, { strokeWidth: 2, className: "absolute left-2 top-2 h-4 w-4 text-gray-400" }),
505
+ /* @__PURE__ */ s(
506
+ M,
507
+ {
508
+ placeholder: "Search page types...",
509
+ className: "h-8 pl-8 text-xs",
510
+ value: Y,
511
+ onChange: (e) => Z(e.target.value)
512
+ }
513
+ )
514
+ ] }) }),
515
+ /* @__PURE__ */ l(ce, { className: "overflow-y-auto", children: [
516
+ /* @__PURE__ */ s(ne, { children: "No page type found." }),
517
+ u ? Se ? /* @__PURE__ */ s(G, { heading: "Partials", children: J.map((e) => /* @__PURE__ */ l(
518
+ I,
519
+ {
520
+ value: e.key,
521
+ onSelect: () => q(e.key),
522
+ className: "flex cursor-pointer items-center justify-between",
523
+ children: [
524
+ e.name,
525
+ /* @__PURE__ */ s(
526
+ R,
527
+ {
528
+ className: V("mr-2 h-4 w-4", t === e.key ? "opacity-100" : "opacity-0")
529
+ }
530
+ )
531
+ ]
532
+ },
533
+ e.key
534
+ )) }) : /* @__PURE__ */ s(G, { heading: "Pages", children: pe.map((e) => /* @__PURE__ */ l(
535
+ I,
536
+ {
537
+ value: e.key,
538
+ onSelect: () => q(e.key),
539
+ className: "flex cursor-pointer items-center justify-between",
540
+ children: [
541
+ e.name,
542
+ /* @__PURE__ */ s(
543
+ R,
544
+ {
545
+ className: V("mr-2 h-4 w-4", t === e.key ? "opacity-100" : "opacity-0")
546
+ }
547
+ )
548
+ ]
549
+ },
550
+ e.key
551
+ )) }) : /* @__PURE__ */ l(We, { children: [
552
+ pe.length > 0 && /* @__PURE__ */ s(G, { heading: "Pages", children: pe.map((e) => /* @__PURE__ */ l(
553
+ I,
554
+ {
555
+ value: e.key,
556
+ onSelect: () => q(e.key),
557
+ className: "flex cursor-pointer items-center justify-between",
558
+ children: [
559
+ e.name,
560
+ /* @__PURE__ */ s(
561
+ R,
562
+ {
563
+ className: V("mr-2 h-4 w-4", t === e.key ? "opacity-100" : "opacity-0")
564
+ }
565
+ )
566
+ ]
567
+ },
568
+ e.key
569
+ )) }),
570
+ J.length > 0 && /* @__PURE__ */ s(G, { heading: "Partials", children: J.map((e) => /* @__PURE__ */ l(
571
+ I,
572
+ {
573
+ value: e.key,
574
+ onSelect: () => q(e.key),
575
+ className: "flex cursor-pointer items-center justify-between",
576
+ children: [
577
+ e.name,
578
+ /* @__PURE__ */ s(
579
+ R,
580
+ {
581
+ className: V("mr-2 h-4 w-4", t === e.key ? "opacity-100" : "opacity-0")
582
+ }
583
+ )
584
+ ]
585
+ },
586
+ e.key
587
+ )) })
588
+ ] })
589
+ ] })
590
+ ] }) })
591
+ ] }) : /* @__PURE__ */ s(
592
+ "select",
593
+ {
594
+ id: "pageType",
595
+ value: t,
596
+ disabled: u && !N,
597
+ onChange: (e) => q(e.target.value),
598
+ className: `w-full rounded-md border border-gray-300 px-3 py-2 ${u && !N ? "cursor-not-allowed text-gray-500" : ""}`,
599
+ children: u ? Se ? /* @__PURE__ */ s("optgroup", { label: "Partials", children: i.filter((e) => e.hasSlug === !1).map((e) => /* @__PURE__ */ s("option", { value: e.key, children: e.name }, e.key)) }) : /* @__PURE__ */ s("optgroup", { label: "Pages", children: i.filter((e) => e.hasSlug !== !1).map((e) => /* @__PURE__ */ s("option", { value: e.key, children: e.name }, e.key)) }) : /* @__PURE__ */ l(We, { children: [
600
+ /* @__PURE__ */ s("optgroup", { label: "Pages", children: i.filter((e) => e.hasSlug !== !1).map((e) => /* @__PURE__ */ s("option", { value: e.key, children: e.name }, e.key)) }),
601
+ /* @__PURE__ */ s("optgroup", { label: "Partials", children: i.filter((e) => e.hasSlug === !1).map((e) => /* @__PURE__ */ s("option", { value: e.key, children: e.name }, e.key)) })
602
+ ] })
603
+ }
604
+ ),
605
+ O && /* @__PURE__ */ l("div", { className: "mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3", children: [
606
+ /* @__PURE__ */ s("p", { className: "text-sm text-yellow-800", children: "Changing the page type may impact the page data. Are you sure you want to proceed?" }),
607
+ /* @__PURE__ */ l("div", { className: "mt-2 flex gap-2", children: [
608
+ /* @__PURE__ */ s(W, { variant: "outline", size: "sm", onClick: () => U(!1), children: "Cancel" }),
609
+ /* @__PURE__ */ s(W, { variant: "default", size: "sm", onClick: je, children: "Confirm" })
610
+ ] })
611
+ ] })
612
+ ] }),
613
+ !u && (r == null ? void 0 : r.hasSlug) && Le.length > 0 && /* @__PURE__ */ l("div", { className: "space-y-1", children: [
614
+ /* @__PURE__ */ s(z, { className: "mb-1 block text-sm", children: "Template" }),
615
+ /* @__PURE__ */ s(
616
+ Ls,
617
+ {
618
+ templates: Le,
619
+ selectedTemplateId: me,
620
+ onSelectTemplate: es,
621
+ isLoading: Ze
622
+ }
623
+ )
624
+ ] }),
625
+ /* @__PURE__ */ s(
626
+ Cs,
627
+ {
628
+ pages: m,
629
+ selectedParentId: k,
630
+ onChange: Ee,
631
+ currentPage: a
632
+ }
633
+ ),
634
+ /* @__PURE__ */ l("div", { className: "space-y-0.5", children: [
635
+ /* @__PURE__ */ s(z, { htmlFor: "name", className: "text-sm", children: "Name" }),
636
+ /* @__PURE__ */ s(
637
+ M,
638
+ {
639
+ id: "name",
640
+ value: _,
641
+ onChange: (e) => be(e.target.value),
642
+ required: !0,
643
+ "aria-required": "true",
644
+ placeholder: "Enter page name"
645
+ }
646
+ )
647
+ ] }),
648
+ (r == null ? void 0 : r.dynamicSegments) && k && k !== "none" && /* @__PURE__ */ l("div", { className: "space-y-2", children: [
649
+ /* @__PURE__ */ l("div", { className: "flex items-center space-x-2", children: [
650
+ /* @__PURE__ */ s(
651
+ "input",
652
+ {
653
+ type: "checkbox",
654
+ id: "useDynamicSlug",
655
+ checked: T,
656
+ onChange: (e) => Pe(e.target.checked),
657
+ className: "rounded border-gray-300"
658
+ }
659
+ ),
660
+ /* @__PURE__ */ s(z, { htmlFor: "useDynamicSlug", className: "text-sm", children: "Use Dynamic Slug" })
661
+ ] }),
662
+ T && /* @__PURE__ */ s("div", { className: "space-y-2", children: /* @__PURE__ */ s("div", { className: "space-y-0.5", children: /* @__PURE__ */ s(
663
+ xs,
664
+ {
665
+ value: xe,
666
+ onChange: Ce,
667
+ dynamicPattern: (r == null ? void 0 : r.dynamicSlug) || "{{id}}",
668
+ placeholder: "Enter custom slug part (optional)",
669
+ onValidationChange: Qe
670
+ }
671
+ ) }) })
672
+ ] }),
673
+ (!(r != null && r.dynamicSegments) || !T) && /* @__PURE__ */ l("div", { className: "space-y-0.5", children: [
674
+ /* @__PURE__ */ s(z, { htmlFor: "slug", className: "text-sm", children: "Slug" }),
675
+ /* @__PURE__ */ s(
676
+ hs,
677
+ {
678
+ value: j,
679
+ onChange: (e) => {
680
+ var c;
681
+ K(e), u && e !== (((c = a == null ? void 0 : a.slug) == null ? void 0 : c.split("/").pop()) || "") ? ue(!!(Je || Xe)) : ue(!1);
682
+ },
683
+ placeholder: k && k !== "none" ? "Enter page slug" : t === "page" ? "Leave empty for home page" : "Required - e.g. your-slug",
684
+ parentSlug: k && k !== "none" ? (Fe = m == null ? void 0 : m.find((e) => e.id === k)) == null ? void 0 : Fe.slug : void 0,
685
+ onValidationChange: h
686
+ }
687
+ ),
688
+ $ && /* @__PURE__ */ s("p", { className: "text-xs text-red-500", children: $ }),
689
+ He && /* @__PURE__ */ s("div", { className: "mt-4 rounded-md border border-amber-200 bg-amber-50 p-3", children: /* @__PURE__ */ l("div", { className: "flex items-start space-x-2", children: [
690
+ /* @__PURE__ */ s("div", { className: "flex-shrink-0", children: /* @__PURE__ */ s("svg", { className: "h-5 w-5 text-amber-400", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ s(
691
+ "path",
692
+ {
693
+ fillRule: "evenodd",
694
+ d: "M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",
695
+ clipRule: "evenodd"
696
+ }
697
+ ) }) }),
698
+ /* @__PURE__ */ l("div", { className: "flex-1", children: [
699
+ /* @__PURE__ */ s("h3", { className: "text-sm font-medium text-amber-800", children: "Slug Change Warning" }),
700
+ /* @__PURE__ */ s("div", { className: "mt-1 text-sm text-amber-700", children: /* @__PURE__ */ s("p", { children: "The previous URL and any child pages will become inaccessible. You may want to set up a redirect to avoid broken links." }) })
701
+ ] })
702
+ ] }) })
703
+ ] }),
704
+ /* @__PURE__ */ s(
705
+ W,
706
+ {
707
+ disabled: Q || // Disable if regular slug is invalid and we're not using dynamic slug
708
+ !b && (!(r != null && r.dynamicSegments) || !T) || // Disable if dynamic slug is invalid and we are using dynamic slug
709
+ T && !ke,
710
+ type: "submit",
711
+ className: "w-full",
712
+ children: u ? Q ? "Updating..." : "Update page" : Q ? "Creating..." : "Create Page"
713
+ }
714
+ )
715
+ ] }) : /* @__PURE__ */ l("form", { onSubmit: De, className: "mx-auto w-full max-w-md space-y-4", children: [
716
+ /* @__PURE__ */ l("div", { className: "space-y-0.5", children: [
717
+ /* @__PURE__ */ s(z, { htmlFor: "pageType", className: "text-sm", children: "Type" }),
718
+ Te ? /* @__PURE__ */ l(ee, { open: Ne, onOpenChange: H, children: [
719
+ /* @__PURE__ */ s(se, { asChild: !0, children: /* @__PURE__ */ l(
720
+ W,
721
+ {
722
+ variant: "outline",
723
+ role: "combobox",
724
+ disabled: u && !N,
725
+ className: V(
726
+ "w-full justify-between",
727
+ u && !N ? "cursor-not-allowed text-gray-500" : ""
728
+ ),
729
+ children: [
730
+ (r == null ? void 0 : r.name) || "Select page type",
731
+ /* @__PURE__ */ s(re, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
732
+ ]
733
+ }
734
+ ) }),
735
+ /* @__PURE__ */ s(ae, { className: "w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: /* @__PURE__ */ l(le, { shouldFilter: !1, children: [
736
+ /* @__PURE__ */ s("div", { className: "sticky top-0 z-10 bg-white px-3 py-2", children: /* @__PURE__ */ l("div", { className: "relative", children: [
737
+ /* @__PURE__ */ s(ie, { strokeWidth: 2, className: "absolute left-2 top-2 h-4 w-4 text-gray-400" }),
738
+ /* @__PURE__ */ s(
739
+ M,
740
+ {
741
+ placeholder: "Search page types...",
742
+ className: "h-8 pl-8 text-xs",
743
+ value: Y,
744
+ onChange: (e) => Z(e.target.value)
745
+ }
746
+ )
747
+ ] }) }),
748
+ /* @__PURE__ */ l(ce, { className: "max-h-[200px] overflow-y-auto", children: [
749
+ /* @__PURE__ */ s(ne, { children: "No page type found." }),
750
+ /* @__PURE__ */ s(G, { heading: "Partials", children: J.map((e) => /* @__PURE__ */ l(
751
+ I,
752
+ {
753
+ value: e.key,
754
+ onSelect: () => {
755
+ q(e.key), H(!1);
756
+ },
757
+ className: "flex cursor-pointer items-center justify-between",
758
+ children: [
759
+ e.name,
760
+ /* @__PURE__ */ s(R, { className: V("mr-2 h-4 w-4", t === e.key ? "opacity-100" : "opacity-0") })
761
+ ]
762
+ },
763
+ e.key
764
+ )) })
765
+ ] })
766
+ ] }) })
767
+ ] }) : /* @__PURE__ */ s(
768
+ "select",
769
+ {
770
+ id: "pageType",
771
+ value: t,
772
+ disabled: u && !N,
773
+ onChange: (e) => q(e.target.value),
774
+ className: `w-full rounded-md border border-gray-300 px-3 py-2 ${u && !N ? "cursor-not-allowed text-gray-500" : ""}`,
775
+ children: /* @__PURE__ */ s("optgroup", { label: "Partials", children: i.filter((e) => e.hasSlug === !1).map((e) => /* @__PURE__ */ s("option", { value: e.key, children: e.name }, e.key)) })
776
+ }
777
+ ),
778
+ O && /* @__PURE__ */ l("div", { className: "mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3", children: [
779
+ /* @__PURE__ */ s("p", { className: "text-sm text-yellow-800", children: "Changing the page type may impact the page data. Are you sure you want to proceed?" }),
780
+ /* @__PURE__ */ l("div", { className: "mt-2 flex gap-2", children: [
781
+ /* @__PURE__ */ s(W, { variant: "outline", size: "sm", onClick: () => U(!1), children: "Cancel" }),
782
+ /* @__PURE__ */ s(W, { variant: "default", size: "sm", onClick: je, children: "Confirm" })
783
+ ] })
784
+ ] }),
785
+ /* @__PURE__ */ s("p", { className: "text-xs text-gray-500", children: (Ae = i.find((e) => e.key === t)) == null ? void 0 : Ae.helpText })
786
+ ] }),
787
+ /* @__PURE__ */ l("div", { className: "space-y-0.5", children: [
788
+ /* @__PURE__ */ s(z, { htmlFor: "name", className: "text-sm", children: "Name" }),
789
+ /* @__PURE__ */ s(M, { id: "name", value: _, onChange: (e) => be(e.target.value), required: !0, "aria-required": "true" })
790
+ ] }),
791
+ /* @__PURE__ */ s(W, { disabled: Q, type: "submit", className: "w-full", children: u ? Q ? "Updating..." : "Update " + (r == null ? void 0 : r.name) : Q ? "Creating..." : "Create " + (r == null ? void 0 : r.name) })
792
+ ] });
793
+ }
794
+ export {
795
+ qs as default
796
+ };