@chaibuilder/sdk 4.0.0-beta.33 → 4.0.0-beta.34

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 (132) hide show
  1. package/dist/{2SSKDMRQ-BqOsh3tf.cjs → 2SSKDMRQ-BM-tJzJS.cjs} +1 -1
  2. package/dist/{2SSKDMRQ-BXAXoR9y.js → 2SSKDMRQ-hkjhJNfh.js} +2 -2
  3. package/dist/{AP7HFJJL-Cv6sqAAd.cjs → AP7HFJJL-MEqeM2Ns.cjs} +1 -1
  4. package/dist/{AP7HFJJL-B78LfetW.js → AP7HFJJL-XRxLnRog.js} +1 -1
  5. package/dist/{IconPicker-D4yq_b-k.cjs → IconPicker-Bl4iY4Cu.cjs} +1 -1
  6. package/dist/{IconPicker-BlO5Pnyu.js → IconPicker-D5wIkgWK.js} +1 -1
  7. package/dist/{WDYDFRGG-BE7jgVqa.js → WDYDFRGG-8UgG1Mx8.js} +2 -2
  8. package/dist/{WDYDFRGG-Dz9d3cVW.cjs → WDYDFRGG-BitFxd1K.cjs} +1 -1
  9. package/dist/{actions-registery-vPaY-3dZ.cjs → actions-registery-Byid-s6S.cjs} +28 -28
  10. package/dist/{actions-registery-D3-4Yha7.js → actions-registery-CKEzH855.js} +1622 -1491
  11. package/dist/actions.cjs +1 -1
  12. package/dist/actions.js +2 -2
  13. package/dist/{active-in-another-tab-CA47uafJ.js → active-in-another-tab-BBrqPDfn.js} +2 -2
  14. package/dist/{active-in-another-tab-CNn_R-55.cjs → active-in-another-tab-BsdNjSxr.cjs} +1 -1
  15. package/dist/{add-new-language-page-QAZbAFQe.cjs → add-new-language-page-BJUHnI7Z.cjs} +1 -1
  16. package/dist/{add-new-language-page-B-kPbhFd.js → add-new-language-page-DvSZenkC.js} +3 -3
  17. package/dist/{add-new-page-D4nbAHOp.cjs → add-new-page-BI7qCsmh.cjs} +1 -1
  18. package/dist/{add-new-page-Y0d9tHh0.js → add-new-page-Dd16d2mC.js} +2 -2
  19. package/dist/{ai-panel-content-WMOeK5pF.js → ai-panel-content-CLNgM3Td.js} +3 -3
  20. package/dist/{ai-panel-content-DXbebC-m.cjs → ai-panel-content-CcqF0I9F.cjs} +1 -1
  21. package/dist/{ai-panel-default-lang-CM_psX_h.js → ai-panel-default-lang-BooHb2pz.js} +4 -4
  22. package/dist/{ai-panel-default-lang-hmfyAYPM.cjs → ai-panel-default-lang-XPtfrifL.cjs} +2 -2
  23. package/dist/{ai-panel-other-lang-D4GL1b-W.cjs → ai-panel-other-lang-BwnRUTSF.cjs} +1 -1
  24. package/dist/{ai-panel-other-lang-BKANRJAb.js → ai-panel-other-lang-CcgIMR3N.js} +3 -3
  25. package/dist/{ai-prompt-input-mxXtWptn.js → ai-prompt-input-AUdUYGNa.js} +1 -1
  26. package/dist/{ai-prompt-input-Dwd0-pcD.cjs → ai-prompt-input-CQ5SJPkx.cjs} +1 -1
  27. package/dist/{ai-translation-prompt-7M2aEZ1w.cjs → ai-translation-prompt-BTNGNtbf.cjs} +1 -1
  28. package/dist/{ai-translation-prompt-C_Pb7BE4.js → ai-translation-prompt-BYUh4Mnb.js} +1 -1
  29. package/dist/apply-binding-Bu5W9YFY.js +940 -0
  30. package/dist/apply-binding-C0xIYKCN.cjs +41 -0
  31. package/dist/{change-password-modal-BYZoefwT.cjs → change-password-modal-CYkUXUa5.cjs} +1 -1
  32. package/dist/{change-password-modal-Dqf_mleR.js → change-password-modal-DCd1gdCm.js} +2 -2
  33. package/dist/{code-editor-uN7W7KMD.cjs → code-editor-BC6Z10dU.cjs} +1 -1
  34. package/dist/{code-editor-1fSEocLK.js → code-editor-DWrVXxeA.js} +1 -1
  35. package/dist/{continue-editing-in-this-client-DD7bBhjD.js → continue-editing-in-this-client-Bdd5Ls6t.js} +2 -2
  36. package/dist/{continue-editing-in-this-client-DDM65ror.cjs → continue-editing-in-this-client-D6Wc8hEK.cjs} +1 -1
  37. package/dist/core.cjs +1 -1
  38. package/dist/core.js +2 -2
  39. package/dist/{css-import-modal-pBNRVmGj.js → css-import-modal-Cpwll5L-.js} +1 -1
  40. package/dist/{css-import-modal-BU7bJAaT.cjs → css-import-modal-FHeYoxo2.cjs} +1 -1
  41. package/dist/{delete-page-B53nkF74.js → delete-page-DyP68v_N.js} +20 -20
  42. package/dist/delete-page-PQGa6Am5.cjs +1 -0
  43. package/dist/{design-token-usage-Cm9m4AMz.cjs → design-token-usage-CoaLw6EJ.cjs} +1 -1
  44. package/dist/{design-token-usage-DzWav2ip.js → design-token-usage-dR3UlfIC.js} +1 -1
  45. package/dist/{digital-asset-manager-1yLYGPuf.js → digital-asset-manager-BNj96Pnh.js} +3 -3
  46. package/dist/{digital-asset-manager-BaTvMY8Q.cjs → digital-asset-manager-Bxkm-jdI.cjs} +1 -1
  47. package/dist/{duplicate-page-DCRVR-kF.js → duplicate-page-Cg6WnFeY.js} +3 -3
  48. package/dist/{duplicate-page-C2DZI4U0.cjs → duplicate-page-DV_lZ8jF.cjs} +1 -1
  49. package/dist/{dynamic-page-selector-CZJQnc-Q.cjs → dynamic-page-selector-C8ax7W_D.cjs} +1 -1
  50. package/dist/{dynamic-page-selector-DCGWkLVV.js → dynamic-page-selector-DcQiWgiL.js} +2 -2
  51. package/dist/{image-editor-DkgZrSGr.cjs → image-editor-C5rYU8Ic.cjs} +1 -1
  52. package/dist/{image-editor-C0EYZJY_.js → image-editor-DGp2-ImI.js} +1 -1
  53. package/dist/{index-C7bidKtE.js → index-94oA-Cgl.js} +3429 -3412
  54. package/dist/index-Bg3Prrc_.cjs +5 -0
  55. package/dist/index-BsloTOgy.cjs +160 -0
  56. package/dist/{index-BDrc0HJQ.js → index-CDUCqK5V.js} +1694 -1751
  57. package/dist/{json-diff-viewer-88jEhq8D.cjs → json-diff-viewer-CdU-gKRr.cjs} +1 -1
  58. package/dist/{json-diff-viewer-wmzIZcuQ.js → json-diff-viewer-CniMcSHL.js} +2 -2
  59. package/dist/lang-panel-Dg7eZqIm.cjs +1 -0
  60. package/dist/{lang-panel--kWBnU_W.js → lang-panel-YLNZisL2.js} +9 -9
  61. package/dist/{manage-design-tokens-JdVKj09s.js → manage-design-tokens-Bct88PT-.js} +4 -3
  62. package/dist/{manage-design-tokens-CslCEOXU.cjs → manage-design-tokens-CMf-Vk72.cjs} +1 -1
  63. package/dist/{manage-design-tokens-modal-xKxC72Bc.js → manage-design-tokens-modal-CeSW9VV_.js} +2 -2
  64. package/dist/{manage-design-tokens-modal-DA15ou0u.cjs → manage-design-tokens-modal-YPEBybz3.cjs} +1 -1
  65. package/dist/{mark-as-template-ClQjC2p2.cjs → mark-as-template-C5rPp_PV.cjs} +1 -1
  66. package/dist/{mark-as-template-AbZrkEYl.js → mark-as-template-WJ4kUyZK.js} +2 -2
  67. package/dist/{nested-path-selector-content-dFwZaM1r.cjs → nested-path-selector-content-COErdW8f.cjs} +1 -1
  68. package/dist/{nested-path-selector-content-B04k-PPB.js → nested-path-selector-content-D0hfMLC6.js} +1 -1
  69. package/dist/{no-language-page-content-CbUqxuC4.js → no-language-page-content-BLnpbzwT.js} +2 -2
  70. package/dist/{no-language-page-content-pzkWJAg6.cjs → no-language-page-content-CK_K6fh9.cjs} +1 -1
  71. package/dist/{no-language-page-dialog-DhlOVXUm.cjs → no-language-page-dialog-BI55QXS_.cjs} +1 -1
  72. package/dist/{no-language-page-dialog-AavD_Mmc.js → no-language-page-dialog-gZGw3Uzp.js} +2 -2
  73. package/dist/page-creator-C2ZwuF6M.cjs +1 -0
  74. package/dist/{page-creator-2OZveMsR.js → page-creator-hHpEaVpS.js} +101 -101
  75. package/dist/{page-lock-B3CpoFTs.cjs → page-lock-BN8BI4J8.cjs} +1 -1
  76. package/dist/{page-lock-5MwwTWe8.js → page-lock-DMzAREda.js} +2 -2
  77. package/dist/{page-locked-dialog-ZOvjnxRI.cjs → page-locked-dialog-B_2Hy4PJ.cjs} +1 -1
  78. package/dist/{page-locked-dialog-BhNZC9wZ.js → page-locked-dialog-CZiVFSGf.js} +2 -2
  79. package/dist/page-manager-new-74gQK_vK.js +408 -0
  80. package/dist/page-manager-new-DLVIuTY7.cjs +1 -0
  81. package/dist/{page-manager-search-and-filter-BOpne6v-.cjs → page-manager-search-and-filter-C6XNDRT7.cjs} +1 -1
  82. package/dist/{page-manager-search-and-filter-DJn98D02.js → page-manager-search-and-filter-DYXCod2G.js} +2 -2
  83. package/dist/page-revisions-content-44SecMak.cjs +1 -0
  84. package/dist/{page-revisions-content-Bqp-9bae.js → page-revisions-content-BWLkqXrw.js} +20 -20
  85. package/dist/pages.cjs +1 -1
  86. package/dist/pages.d.ts +21 -2
  87. package/dist/pages.js +11 -10
  88. package/dist/{publish-pages-content-CtZLSG6O.js → publish-pages-content-COHFXR-v.js} +3 -3
  89. package/dist/{publish-pages-content-DfYG0biw.cjs → publish-pages-content-msfUAXJy.cjs} +1 -1
  90. package/dist/render.cjs +1 -1
  91. package/dist/render.js +2 -2
  92. package/dist/{rte-widget-modal-DX66uSPv.cjs → rte-widget-modal-ck2hWBPv.cjs} +1 -1
  93. package/dist/{rte-widget-modal-DGEWoQ1b.js → rte-widget-modal-muaFxwH1.js} +1 -1
  94. package/dist/{save-to-lib-CCxX5ZmQ.js → save-to-lib-JBs4ml12.js} +2 -2
  95. package/dist/{save-to-lib-DmAjdhzU.cjs → save-to-lib-NHLFZR6b.cjs} +1 -1
  96. package/dist/sdk.css +1 -1
  97. package/dist/{selected-block-display-Cv6jBhJD.js → selected-block-display-0rlYn5jN.js} +2 -2
  98. package/dist/{selected-block-display-Csce27bR.cjs → selected-block-display-BhnCoV28.cjs} +1 -1
  99. package/dist/seo-panel-BLTekCWH.cjs +2 -0
  100. package/dist/{seo-panel-Ctstjs-d.js → seo-panel-D8QdAKVh.js} +2 -2
  101. package/dist/shared-json-ld-CDYobqPW.cjs +1 -0
  102. package/dist/{shared-json-ld-BNHGmUBd.js → shared-json-ld-DclZXKU6.js} +15 -15
  103. package/dist/{slug-input-Bui1Qmvh.js → slug-input-BOaNz0te.js} +1 -1
  104. package/dist/{slug-input-IAl_jfHr.cjs → slug-input-D3pjtp5_.cjs} +1 -1
  105. package/dist/supabase-actions.cjs +1 -1
  106. package/dist/supabase-actions.d.ts +6 -0
  107. package/dist/supabase-actions.js +1 -1
  108. package/dist/{take-over-request-Bl6jS1cK.cjs → take-over-request-CF3ubryV.cjs} +1 -1
  109. package/dist/{take-over-request-Ceuqyk5K.js → take-over-request-CbQfdDOW.js} +2 -2
  110. package/dist/{translation-warning-modal-DA5dt2FA.js → translation-warning-modal-Bs5qTh3p.js} +1 -1
  111. package/dist/{translation-warning-modal-CCmmwz1C.cjs → translation-warning-modal-Bseflnj4.cjs} +1 -1
  112. package/dist/{unmark-as-template-OEUqo0uc.cjs → unmark-as-template-CtiOyF4c.cjs} +1 -1
  113. package/dist/{unmark-as-template-CKVMibvu.js → unmark-as-template-rGzNVgFR.js} +2 -2
  114. package/dist/{unpublish-page-C81bYHLI.cjs → unpublish-page-CNR43LxM.cjs} +1 -1
  115. package/dist/{unpublish-page-A5qn6E6g.js → unpublish-page-DhtGUDXp.js} +2 -2
  116. package/dist/{unpublished-partials-modal-af5uDL7Y.cjs → unpublished-partials-modal-BmKRB4Tl.cjs} +1 -1
  117. package/dist/{unpublished-partials-modal-FqzTp5el.js → unpublished-partials-modal-j0zuOxDo.js} +1 -1
  118. package/dist/{web-preview-vge6uUSa.js → web-preview-BCWqRDBW.js} +1 -1
  119. package/dist/{web-preview-xtKkQOXy.cjs → web-preview-DYyGglxW.cjs} +1 -1
  120. package/package.json +2 -1
  121. package/dist/apply-binding-BYCW1k2l.js +0 -846
  122. package/dist/apply-binding-xiigK7eK.cjs +0 -1
  123. package/dist/delete-page-8oEYsHPE.cjs +0 -1
  124. package/dist/index-BuXfCtgR.cjs +0 -5
  125. package/dist/index-DKjYF53r.cjs +0 -160
  126. package/dist/lang-panel-I_ABfjOZ.cjs +0 -1
  127. package/dist/page-creator-DMjnStPf.cjs +0 -1
  128. package/dist/page-manager-new-BcI-1Dms.cjs +0 -1
  129. package/dist/page-manager-new-l68-Lc9h.js +0 -415
  130. package/dist/page-revisions-content-B00tDCzu.cjs +0 -1
  131. package/dist/seo-panel-BZYXeYzE.cjs +0 -2
  132. package/dist/shared-json-ld-BDWtjHgw.cjs +0 -1
@@ -0,0 +1,408 @@
1
+ import { jsxs as w, Fragment as q, jsx as t } from "react/jsx-runtime";
2
+ import { d as ie } from "./index-94oA-Cgl.js";
3
+ import { s as be, t as ge, w as ke, i as de, T as D, aQ as ve, L as Ne, k as Se, e as Le, c as Ce, aw as Ae, aR as Ee, aS as $e } from "./index-CDUCqK5V.js";
4
+ import { u as J } from "./use-page-expand-manager-Cf4MUEJw.js";
5
+ import { compact as ue, filter as z, isEmpty as k, uniqBy as Te, keyBy as me, mapValues as Me, startCase as Ue, toLower as T, includes as _, get as R, find as W, map as Ie } from "lodash-es";
6
+ import { atom as Fe, useAtom as ze, useSetAtom as Be } from "jotai";
7
+ import { ExternalLink as Oe, Pencil as je, MoreHorizontal as Ge, Lock as De, Plus as Re, ChevronRight as We, StarsIcon as He, Hash as _e, File as he } from "lucide-react";
8
+ import { useRef as qe, useEffect as $, useMemo as H, useState as N, useCallback as le, startTransition as Qe, Suspense as E, lazy as M } from "react";
9
+ import { useTranslation as Ve } from "react-i18next";
10
+ import { B as Xe } from "./register-chai-top-bar-D6GjnauV.js";
11
+ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
12
+ z(e, (r) => {
13
+ const n = T(s);
14
+ return _(T((r == null ? void 0 : r.name) || ""), n) || _(T((r == null ? void 0 : r.slug) || ""), n);
15
+ })
16
+ ), Ye = (e, s) => {
17
+ const r = /* @__PURE__ */ new Set(), n = me(e, "id");
18
+ return s.forEach((i) => {
19
+ let o = i;
20
+ for (; o.parent && n[o.parent]; )
21
+ r.add(o.parent), o = n[o.parent];
22
+ }), Array.from(r).map((i) => n[i]);
23
+ }, Y = (e, s, r) => k(s) ? e : e.map((n) => {
24
+ if (!r(n.pageType))
25
+ return {
26
+ ...n,
27
+ shouldExpandOnSearch: !0,
28
+ children: n.children ? Y(n.children, s, r) : []
29
+ };
30
+ const i = n.children && n.children.some(
31
+ (o) => _(T(o.name || ""), T(s)) || _(T(o.slug || ""), T(s))
32
+ );
33
+ return {
34
+ ...n,
35
+ shouldExpandOnSearch: i,
36
+ children: n.children ? Y(n.children, s, r) : []
37
+ };
38
+ }), Je = (e) => {
39
+ if (!e || !e.length) return [];
40
+ const s = {};
41
+ e.forEach((n) => {
42
+ s[n.id] = { ...n, children: [] };
43
+ });
44
+ const r = [];
45
+ return Object.values(s).forEach((n) => {
46
+ n.parent && s[n.parent] ? s[n.parent].children.push(n) : r.push(n);
47
+ }), r;
48
+ }, fe = (e) => !e || !e.length ? [] : [...e].sort((r, n) => (r.name || "").localeCompare(n.name || "")).map((r) => ({
49
+ ...r,
50
+ children: r.children ? fe(r.children) : []
51
+ })), Ke = (e, s, r, n) => {
52
+ if (!e || !e.length) return [];
53
+ let i = e;
54
+ if (r !== "all" && (i = ue(z(e, { pageType: r }))), k(s))
55
+ i = ce(i, s);
56
+ else {
57
+ const m = ce(i, s), l = Ye(e, m);
58
+ i = Te([...m, ...l], "id");
59
+ }
60
+ const o = fe(Je(i)), f = Y(o, s, n), y = z(f, (m) => n(m.pageType)).sort(
61
+ (m, l) => (m.name || "").localeCompare(l.name || "")
62
+ ), c = z(f, (m) => !n(m.pageType));
63
+ let x = [];
64
+ if (r === "all") {
65
+ const m = me(c, "pageType");
66
+ x = Object.values(
67
+ Me(m, (l, p) => ({
68
+ ...l,
69
+ id: p,
70
+ name: Ue(p),
71
+ isPartialGroup: !0,
72
+ children: f.filter((v) => v.pageType === p)
73
+ }))
74
+ );
75
+ } else
76
+ x = c.sort((m, l) => (m.name || "").localeCompare(l.name || ""));
77
+ return [...y, ...x];
78
+ }, Ze = Fe({
79
+ pageId: null,
80
+ position: { x: 0, y: 0 }
81
+ }), et = ({ pageId: e, children: s }) => {
82
+ const [r, n] = ze(Ze), i = qe(null), o = r.pageId === e;
83
+ $(() => {
84
+ const c = () => n({ pageId: null, position: { x: 0, y: 0 } });
85
+ if (o)
86
+ return document.addEventListener("click", c), () => document.removeEventListener("click", c);
87
+ }, [o, n]);
88
+ const f = (c) => {
89
+ c.preventDefault(), c.stopPropagation(), n({ pageId: e, position: { x: c.clientX, y: c.clientY } });
90
+ }, y = () => {
91
+ const c = `${window.location.pathname}?page=${e}`;
92
+ window.open(c, "_blank"), n({ pageId: null, position: { x: 0, y: 0 } });
93
+ };
94
+ return /* @__PURE__ */ w(q, { children: [
95
+ /* @__PURE__ */ t("span", { onContextMenu: f, children: s }),
96
+ o && /* @__PURE__ */ t(
97
+ "div",
98
+ {
99
+ ref: i,
100
+ className: "fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",
101
+ style: { top: r.position.y, left: r.position.x },
102
+ children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ w(
103
+ Xe,
104
+ {
105
+ variant: "ghost",
106
+ onClick: y,
107
+ className: "w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",
108
+ children: [
109
+ /* @__PURE__ */ t(Oe, { className: "h-4 w-4" }),
110
+ "Open in new tab"
111
+ ]
112
+ }
113
+ ) })
114
+ }
115
+ )
116
+ ] });
117
+ }, tt = ({ page: e }) => {
118
+ var n, i;
119
+ const { isExpanded: s, toggleExpanded: r } = J(e == null ? void 0 : e.id);
120
+ return /* @__PURE__ */ t(
121
+ "button",
122
+ {
123
+ onClick: (o) => {
124
+ o.stopPropagation(), r();
125
+ },
126
+ disabled: !((n = e == null ? void 0 : e.children) != null && n.length),
127
+ className: `flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(i = e == null ? void 0 : e.children) != null && i.length ? "hover:text-blue-400" : "opacity-0"}`,
128
+ children: /* @__PURE__ */ t(
129
+ We,
130
+ {
131
+ size: 12,
132
+ className: `stroke-[4] transition-transform duration-200 ${s ? "rotate-90" : ""}`
133
+ }
134
+ )
135
+ }
136
+ );
137
+ }, nt = ({ page: e, pageType: s }) => /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center gap-x-1", children: e.dynamic ? /* @__PURE__ */ t(He, { size: 12, className: "text-yellow-400" }) : s != null && s.icon ? /* @__PURE__ */ t(
138
+ "div",
139
+ {
140
+ className: "flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",
141
+ dangerouslySetInnerHTML: { __html: s.icon }
142
+ }
143
+ ) : s != null && s.hasSlug ? /* @__PURE__ */ t(he, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(_e, { size: 12, className: "stroke-[1] text-slate-500" }) }), st = ({ isOnline: e }) => /* @__PURE__ */ t("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), rt = ({
144
+ page: e,
145
+ pageTypes: s,
146
+ currentPage: r,
147
+ onClickAction: n,
148
+ languagePages: i,
149
+ selectedLanguage: o,
150
+ showUntranslatedPages: f
151
+ }) => {
152
+ const y = be(), { pageToUser: c } = ge(), x = R(c, [e == null ? void 0 : e.id, "userId"]), { data: m } = ke(x), l = m && y !== x ? m == null ? void 0 : m.name : null, p = de(), v = r === e.id, P = H(() => W(s, { key: e.pageType }), [s, e.pageType]);
153
+ let d = R(i, e == null ? void 0 : e.id);
154
+ d = R(d, "lang") === o ? d : null;
155
+ const L = o === p || !!d, U = (d == null ? void 0 : d.name) || (e == null ? void 0 : e.name) || "No name";
156
+ let g = (d == null ? void 0 : d.slug) || (e == null ? void 0 : e.slug) || "";
157
+ const B = g + (e != null && e.dynamic ? `/${P == null ? void 0 : P.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
158
+ if (g.startsWith("/") && !f) {
159
+ const h = g.split("/").pop();
160
+ g = g.endsWith(h) && e.dynamic ? "" : `/${h}`;
161
+ }
162
+ const O = H(() => {
163
+ const h = "flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]", A = `${v ? "border-primary/30 bg-primary/5" : "border-transparent hover:border-gray-200 hover:bg-gray-100"}`;
164
+ return L ? `${h} ${A} ${l ? "opacity-60" : ""}` : `${h} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`;
165
+ }, [L, v, l]), j = H(() => {
166
+ if (e.isPartialGroup) return !1;
167
+ if (d) {
168
+ if (!d.online || k(d.changes)) return !1;
169
+ } else if (e && (!e.online || k(e.changes)))
170
+ return !1;
171
+ return !0;
172
+ }, [d, e]);
173
+ return /* @__PURE__ */ w("div", { className: "group relative", children: [
174
+ /* @__PURE__ */ t(et, { pageId: e.id, children: /* @__PURE__ */ w(
175
+ "div",
176
+ {
177
+ onClick: () => !e.isPartialGroup && L && n("select", e == null ? void 0 : e.id),
178
+ className: O,
179
+ children: [
180
+ /* @__PURE__ */ t(tt, { page: e }),
181
+ !e.isPartialGroup && /* @__PURE__ */ t(st, { isOnline: d ? d.online : e.online }),
182
+ !e.isPartialGroup && /* @__PURE__ */ t(nt, { page: e, pageType: P }),
183
+ /* @__PURE__ */ t(D, { content: U, side: "top", showTooltip: U.length > 35, children: /* @__PURE__ */ t("span", { className: "max-w-[40%] truncate font-medium text-black", children: U }) }),
184
+ (g || e.dynamic) && /* @__PURE__ */ t(D, { content: B, side: "top", showTooltip: !0, children: /* @__PURE__ */ w("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
185
+ g,
186
+ e.dynamic && (P == null ? void 0 : P.dynamicSlug) && /* @__PURE__ */ w("span", { className: "text-xs text-gray-500", children: [
187
+ "/",
188
+ P == null ? void 0 : P.dynamicSlug,
189
+ e.dynamicSlugCustom
190
+ ] })
191
+ ] }) }),
192
+ j && /* @__PURE__ */ t(D, { content: "Has unpublished changes", side: "top", children: /* @__PURE__ */ t("span", { className: "text-amber-500", children: /* @__PURE__ */ t(je, { size: 12, className: "stroke-[2]" }) }) }),
193
+ !e.isPartialGroup && L && !l ? /* @__PURE__ */ t("div", { className: "duration absolute right-0.5 top-[3px]", children: /* @__PURE__ */ t(
194
+ ve,
195
+ {
196
+ isLanguagePage: !!d,
197
+ page: d || e,
198
+ setDuplicatePage: (h) => n("duplicate", h),
199
+ setAddEditPage: (h) => n("edit", d || h),
200
+ setUnpublishPage: (h) => n("unpublish", h),
201
+ setDeletePage: (h) => n("delete", d || h),
202
+ children: /* @__PURE__ */ t("div", { className: "m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white", children: /* @__PURE__ */ t(Ge, { className: "h-4 w-4", onClick: (h) => h.stopPropagation() }) })
203
+ }
204
+ ) }) : l ? /* @__PURE__ */ w("span", { className: "duration absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-x-1 text-xs text-red-500", children: [
205
+ /* @__PURE__ */ t(De, { className: "h-3 w-3 fill-red-200 text-red-500" }),
206
+ /* @__PURE__ */ t(D, { content: `${l} is editing this page`, children: /* @__PURE__ */ t("span", { className: "font-bold", children: l }) })
207
+ ] }) : null
208
+ ]
209
+ }
210
+ ) }),
211
+ /* @__PURE__ */ t(q, { children: !L && !e.isPartialGroup && !l && /* @__PURE__ */ w(
212
+ "button",
213
+ {
214
+ onClick: (h) => {
215
+ h.stopPropagation(), n("addLanguagePage", { language: o, page: e });
216
+ },
217
+ className: "absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",
218
+ children: [
219
+ /* @__PURE__ */ t(Re, { size: 12, className: "stroke-[3]" }),
220
+ " ",
221
+ /* @__PURE__ */ w("span", { className: "text-[10px]", children: [
222
+ "Add ",
223
+ R(Ne, o),
224
+ " Page"
225
+ ] })
226
+ ]
227
+ }
228
+ ) })
229
+ ] });
230
+ }, xe = ({
231
+ pages: e,
232
+ tier: s,
233
+ pageTypes: r,
234
+ currentPage: n,
235
+ onClickAction: i,
236
+ languagePages: o,
237
+ selectedLanguage: f,
238
+ showUntranslatedPages: y
239
+ }) => {
240
+ const { expandedPages: c } = J();
241
+ return /* @__PURE__ */ t("div", { className: "space-y-0.5", style: { paddingLeft: `${s * 10}px` }, children: e.map((x) => /* @__PURE__ */ w(q, { children: [
242
+ /* @__PURE__ */ t(
243
+ rt,
244
+ {
245
+ page: x,
246
+ pageTypes: r,
247
+ currentPage: n,
248
+ onClickAction: i,
249
+ languagePages: o,
250
+ selectedLanguage: f,
251
+ showUntranslatedPages: y
252
+ }
253
+ ),
254
+ x.children && x.children.length > 0 && (c == null ? void 0 : c.includes(x.id)) && /* @__PURE__ */ t(
255
+ xe,
256
+ {
257
+ pages: x.children,
258
+ tier: s + 1,
259
+ pageTypes: r,
260
+ currentPage: n,
261
+ onClickAction: i,
262
+ languagePages: o,
263
+ selectedLanguage: f,
264
+ showUntranslatedPages: y
265
+ }
266
+ )
267
+ ] }, x.id)) });
268
+ }, at = M(() => import("./page-manager-search-and-filter-DYXCod2G.js")), ot = M(() => import("./add-new-page-Dd16d2mC.js")), it = M(() => import("./delete-page-DyP68v_N.js")), lt = M(() => import("./duplicate-page-Cg6WnFeY.js")), ct = M(() => import("./mark-as-template-WJ4kUyZK.js")), dt = M(() => import("./unmark-as-template-rGzNVgFR.js")), ut = M(() => import("./unpublish-page-DhtGUDXp.js")), kt = ({ close: e }) => {
269
+ const { t: s } = Ve(), { languages: r, setSelectedLang: n } = ie(), { data: i } = Se(), { data: o, isFetching: f } = Le(), [y, c] = Ce(), { updateForSelectedPage: x, expandPagesOnSearch: m } = J(null), l = de(), p = y.get("page"), [v, P] = N(""), [d, L] = N(null), [U, g] = N(null), [B, O] = N(null), [j, h] = N(null), [A, Q] = N(""), [K, Z] = N(null), [ee, te] = N(null), [b, V] = N(l), [pe, we] = N(!1), ne = Be(Ae), G = pe && b !== l, { data: I, isFetching: ye } = Ee(b), se = le(
270
+ (u) => {
271
+ var a;
272
+ return (a = W(i, { key: u })) == null ? void 0 : a.hasSlug;
273
+ },
274
+ [i]
275
+ ), S = H(() => o ? G ? z(o, (u) => !(I != null && I[u.id])) : Ke(o, v, A, se) : [], [o, se, v, A, I, G]);
276
+ $(() => {
277
+ n(l);
278
+ }, [l, n]), $(() => {
279
+ const u = y.get("lang");
280
+ if (u) {
281
+ const a = r, C = r[0] ?? l, F = a.includes(u);
282
+ Qe(() => {
283
+ F && b !== u ? V(u) : !F && b !== C && V(C);
284
+ });
285
+ }
286
+ }, []), $(() => {
287
+ if (!k(A)) return;
288
+ const u = sessionStorage.getItem("pageTypeFilter") || "all";
289
+ !k(i) && u && (W(i, { key: u }) ? Q(u) : Q("all"));
290
+ }, [i, A]), $(() => {
291
+ if (p && !f && !W(o, { id: p })) {
292
+ const a = new URLSearchParams(y.toString());
293
+ if (a.delete("page"), [...a.keys()].length > 0) {
294
+ if (typeof window < "u" && window.history && window.location) {
295
+ const C = a.toString(), F = window.location.hash || "", oe = window.location.pathname, Pe = C ? `${oe}?${C}${F}` : `${oe}${F}`;
296
+ window.history.replaceState(window.history.state, "", Pe);
297
+ }
298
+ c(a);
299
+ } else
300
+ typeof window < "u" && window.history && window.location && (window.history.replaceState(window.history.state, "", window.location.pathname + window.location.hash), window.dispatchEvent(new PopStateEvent("popstate", { state: window.history.state }))), c(a);
301
+ }
302
+ }, [o, p, f, c]), $(() => {
303
+ p && !f && !k(S) && x(S, p);
304
+ }, [p, f, S, x]), $(() => {
305
+ !k(v) && !k(S) && m(S);
306
+ }, [v, S, m]);
307
+ const { setSelectedLang: X } = ie(), re = le(
308
+ (u) => {
309
+ const a = new URLSearchParams({ page: u });
310
+ b !== l ? (a.set("lang", b), X(b)) : X(""), $e(a, c), e();
311
+ },
312
+ [e, c, X, b, l]
313
+ ), ae = (u, a) => {
314
+ var C;
315
+ if (a)
316
+ switch (u) {
317
+ case "add":
318
+ g(a);
319
+ break;
320
+ case "select":
321
+ re(a);
322
+ break;
323
+ case "edit":
324
+ b !== l ? ne({
325
+ edit: !0,
326
+ id: a == null ? void 0 : a.id,
327
+ primaryPage: a == null ? void 0 : a.primaryPage
328
+ }) : g(a);
329
+ break;
330
+ case "delete":
331
+ L(a);
332
+ break;
333
+ case "unpublish":
334
+ O(a);
335
+ break;
336
+ case "markAsTemplate":
337
+ h(a);
338
+ break;
339
+ case "unmarkAsTemplate":
340
+ te(a);
341
+ break;
342
+ case "duplicate":
343
+ Z(a);
344
+ break;
345
+ case "addLanguagePage":
346
+ ne({
347
+ edit: !1,
348
+ primaryPage: ((C = a == null ? void 0 : a.page) == null ? void 0 : C.id) || "",
349
+ preselectedLang: (a == null ? void 0 : a.language) || b
350
+ });
351
+ break;
352
+ }
353
+ };
354
+ return /* @__PURE__ */ w(q, { children: [
355
+ /* @__PURE__ */ w("div", { className: "flex h-full flex-col justify-between", children: [
356
+ /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(
357
+ at,
358
+ {
359
+ pages: S,
360
+ search: v,
361
+ setSearch: P,
362
+ languages: [l, ...r],
363
+ selectedLanguage: b,
364
+ setSelectedLanguage: V,
365
+ selectedPageType: A,
366
+ setSelectedPageType: Q,
367
+ onAddPage: (u) => ae("add", u),
368
+ showUntranslatedPages: G,
369
+ setShowUntranslatedPages: we
370
+ }
371
+ ) }),
372
+ /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: f || ye ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Ie([...Array(15).keys()], (u) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, u)) }) : k(S) ? /* @__PURE__ */ w("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
373
+ /* @__PURE__ */ t(he, { className: "h-6 w-6 stroke-[1]" }),
374
+ s("Empty List!"),
375
+ /* @__PURE__ */ t("span", { className: "font-light", children: s("Add new page to start") })
376
+ ] }) : /* @__PURE__ */ t(
377
+ xe,
378
+ {
379
+ tier: 0,
380
+ pages: S,
381
+ pageTypes: i,
382
+ currentPage: p || "",
383
+ onClickAction: ae,
384
+ languagePages: I,
385
+ selectedLanguage: b,
386
+ showUntranslatedPages: G
387
+ }
388
+ ) })
389
+ ] }),
390
+ U && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(
391
+ ot,
392
+ {
393
+ closePanel: e,
394
+ editPage: re,
395
+ addEditPage: U,
396
+ setAddEditPage: g
397
+ }
398
+ ) }),
399
+ d && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(it, { page: d, onClose: () => L(null) }) }),
400
+ B && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(ut, { page: B, onClose: () => O(null) }) }),
401
+ j && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(ct, { page: j, onClose: () => h(null) }) }),
402
+ ee && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(dt, { page: ee, onClose: () => te(null) }) }),
403
+ K && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(lt, { page: K, onClose: () => Z(null), closePanel: e }) })
404
+ ] });
405
+ };
406
+ export {
407
+ kt as default
408
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),K=require("./index-BsloTOgy.cjs"),y=require("./index-Bg3Prrc_.cjs"),G=require("./use-page-expand-manager-B6XTvk0E.cjs"),n=require("lodash-es"),R=require("jotai"),k=require("lucide-react"),o=require("react"),oe=require("react-i18next"),ie=require("./register-chai-top-bar-DyW9GPzV.cjs"),Z=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const s=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),s)||n.includes(n.toLower((a==null?void 0:a.slug)||""),s)})),le=(e,r)=>{const a=new Set,s=n.keyBy(e,"id");return r.forEach(c=>{let l=c;for(;l.parent&&s[l.parent];)a.add(l.parent),l=s[l.parent]}),Array.from(a).map(c=>s[c])},O=(e,r,a)=>n.isEmpty(r)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?O(s.children,r,a):[]};const c=s.children&&s.children.some(l=>n.includes(n.toLower(l.name||""),n.toLower(r))||n.includes(n.toLower(l.slug||""),n.toLower(r)));return{...s,shouldExpandOnSearch:c,children:s.children?O(s.children,r,a):[]}}),ce=e=>{if(!e||!e.length)return[];const r={};e.forEach(s=>{r[s.id]={...s,children:[]}});const a=[];return Object.values(r).forEach(s=>{s.parent&&r[s.parent]?r[s.parent].children.push(s):a.push(s)}),a},ee=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?ee(a.children):[]})),de=(e,r,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))c=Z(c,r);else{const x=Z(c,r),d=le(e,x);c=n.uniqBy([...x,...d],"id")}const l=ee(ce(c)),p=O(l,r,s),g=n.filter(p,x=>s(x.pageType)).sort((x,d)=>(x.name||"").localeCompare(d.name||"")),u=n.filter(p,x=>!s(x.pageType));let P=[];if(a==="all"){const x=n.keyBy(u,"pageType");P=Object.values(n.mapValues(x,(d,w)=>({...d,id:w,name:n.startCase(w),isPartialGroup:!0,children:p.filter(v=>v.pageType===w)})))}else P=u.sort((x,d)=>(x.name||"").localeCompare(d.name||""));return[...g,...P]},ue=R.atom({pageId:null,position:{x:0,y:0}}),me=({pageId:e,children:r})=>{const[a,s]=R.useAtom(ue),c=o.useRef(null),l=a.pageId===e;o.useEffect(()=>{const u=()=>s({pageId:null,position:{x:0,y:0}});if(l)return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[l,s]);const p=u=>{u.preventDefault(),u.stopPropagation(),s({pageId:e,position:{x:u.clientX,y:u.clientY}})},g=()=>{const u=`${window.location.pathname}?page=${e}`;window.open(u,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:p,children:r}),l&&t.jsx("div",{ref:c,className:"fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",style:{top:a.position.y,left:a.position.x},children:t.jsx("div",{className:"",children:t.jsxs(ie.Button,{variant:"ghost",onClick:g,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(k.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},he=({page:e})=>{var s,c;const{isExpanded:r,toggleExpanded:a}=G.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:l=>{l.stopPropagation(),a()},disabled:!((s=e==null?void 0:e.children)!=null&&s.length),className:`flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(c=e==null?void 0:e.children)!=null&&c.length?"hover:text-blue-400":"opacity-0"}`,children:t.jsx(k.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},xe=({page:e,pageType:r})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(k.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?t.jsx("div",{className:"flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",dangerouslySetInnerHTML:{__html:r.icon}}):r!=null&&r.hasSlug?t.jsx(k.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(k.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),fe=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),ye=({page:e,pageTypes:r,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:l,showUntranslatedPages:p})=>{const g=y.useUserId(),{pageToUser:u}=y.usePageToUser(),P=n.get(u,[e==null?void 0:e.id,"userId"]),{data:x}=y.useChaiUserInfo(P),d=x&&g!==P?x==null?void 0:x.name:null,w=y.useFallbackLang(),v=a===e.id,j=o.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]);let m=n.get(c,e==null?void 0:e.id);m=n.get(m,"lang")===l?m:null;const E=l===w||!!m,A=(m==null?void 0:m.name)||(e==null?void 0:e.name)||"No name";let S=(m==null?void 0:m.slug)||(e==null?void 0:e.slug)||"";const $=S+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!p){const f=S.split("/").pop();S=S.endsWith(f)&&e.dynamic?"":`/${f}`}const q=o.useMemo(()=>{const f="flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]",C=`${v?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${f} ${C} ${d?"opacity-60":""}`:`${f} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,v,d]),I=o.useMemo(()=>{if(e.isPartialGroup)return!1;if(m){if(!m.online||n.isEmpty(m.changes))return!1}else if(e&&(!e.online||n.isEmpty(e.changes)))return!1;return!0},[m,e]);return t.jsxs("div",{className:"group relative",children:[t.jsx(me,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:q,children:[t.jsx(he,{page:e}),!e.isPartialGroup&&t.jsx(fe,{isOnline:m?m.online:e.online}),!e.isPartialGroup&&t.jsx(xe,{page:e,pageType:j}),t.jsx(y.Tooltip,{content:A,side:"top",showTooltip:A.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:A})}),(S||e.dynamic)&&t.jsx(y.Tooltip,{content:$,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[S,e.dynamic&&(j==null?void 0:j.dynamicSlug)&&t.jsxs("span",{className:"text-xs text-gray-500",children:["/",j==null?void 0:j.dynamicSlug,e.dynamicSlugCustom]})]})}),I&&t.jsx(y.Tooltip,{content:"Has unpublished changes",side:"top",children:t.jsx("span",{className:"text-amber-500",children:t.jsx(k.Pencil,{size:12,className:"stroke-[2]"})})}),!e.isPartialGroup&&E&&!d?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(y.PageActionsDropdown,{isLanguagePage:!!m,page:m||e,setDuplicatePage:f=>s("duplicate",f),setAddEditPage:f=>s("edit",m||f),setUnpublishPage:f=>s("unpublish",f),setDeletePage:f=>s("delete",m||f),children:t.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:t.jsx(k.MoreHorizontal,{className:"h-4 w-4",onClick:f=>f.stopPropagation()})})})}):d?t.jsxs("span",{className:"duration absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-x-1 text-xs text-red-500",children:[t.jsx(k.Lock,{className:"h-3 w-3 fill-red-200 text-red-500"}),t.jsx(y.Tooltip,{content:`${d} is editing this page`,children:t.jsx("span",{className:"font-bold",children:d})})]}):null]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!d&&t.jsxs("button",{onClick:f=>{f.stopPropagation(),s("addLanguagePage",{language:l,page:e})},className:"absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",children:[t.jsx(k.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(y.LANGUAGES,l)," Page"]})]})})]})},te=({pages:e,tier:r,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})=>{const{expandedPages:u}=G.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(P=>t.jsxs(t.Fragment,{children:[t.jsx(ye,{page:P,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g}),P.children&&P.children.length>0&&(u==null?void 0:u.includes(P.id))&&t.jsx(te,{pages:P.children,tier:r+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})]},P.id))})},pe=o.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-C6XNDRT7.cjs"))),Pe=o.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-BI7qCsmh.cjs"))),we=o.lazy(()=>Promise.resolve().then(()=>require("./delete-page-PQGa6Am5.cjs"))),ge=o.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-DV_lZ8jF.cjs"))),je=o.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-C5rPp_PV.cjs"))),be=o.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-CtiOyF4c.cjs"))),Se=o.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-CNR43LxM.cjs"))),ve=({close:e})=>{const{t:r}=oe.useTranslation(),{languages:a,setSelectedLang:s}=K.useLanguages(),{data:c}=y.usePageTypes(),{data:l,isFetching:p}=y.useWebsitePrimaryPages(),[g,u]=y.useSearchParams(),{updateForSelectedPage:P,expandPagesOnSearch:x}=G.usePageExpandManager(null),d=y.useFallbackLang(),w=g.get("page"),[v,j]=o.useState(""),[m,E]=o.useState(null),[A,S]=o.useState(null),[$,q]=o.useState(null),[I,f]=o.useState(null),[C,z]=o.useState(""),[D,W]=o.useState(null),[H,_]=o.useState(null),[b,F]=o.useState(d),[se,ne]=o.useState(!1),V=R.useSetAtom(y.addNewLangAtom),U=se&&b!==d,{data:M,isFetching:re}=y.useWebsiteLanguagePages(b),Q=o.useCallback(h=>{var i;return(i=n.find(c,{key:h}))==null?void 0:i.hasSlug},[c]),N=o.useMemo(()=>l?U?n.filter(l,h=>!(M!=null&&M[h.id])):de(l,v,C,Q):[],[l,Q,v,C,M,U]);o.useEffect(()=>{s(d)},[d,s]),o.useEffect(()=>{const h=g.get("lang");if(h){const i=a,L=a[0]??d,T=i.includes(h);o.startTransition(()=>{T&&b!==h?F(h):!T&&b!==L&&F(L)})}},[]),o.useEffect(()=>{if(!n.isEmpty(C))return;const h=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&h&&(n.find(c,{key:h})?z(h):z("all"))},[c,C]),o.useEffect(()=>{if(w&&!p&&!n.find(l,{id:w})){const i=new URLSearchParams(g.toString());if(i.delete("page"),[...i.keys()].length>0){if(typeof window<"u"&&window.history&&window.location){const L=i.toString(),T=window.location.hash||"",J=window.location.pathname,ae=L?`${J}?${L}${T}`:`${J}${T}`;window.history.replaceState(window.history.state,"",ae)}u(i)}else typeof window<"u"&&window.history&&window.location&&(window.history.replaceState(window.history.state,"",window.location.pathname+window.location.hash),window.dispatchEvent(new PopStateEvent("popstate",{state:window.history.state}))),u(i)}},[l,w,p,u]),o.useEffect(()=>{w&&!p&&!n.isEmpty(N)&&P(N,w)},[w,p,N,P]),o.useEffect(()=>{!n.isEmpty(v)&&!n.isEmpty(N)&&x(N)},[v,N,x]);const{setSelectedLang:B}=K.useLanguages(),X=o.useCallback(h=>{const i=new URLSearchParams({page:h});b!==d?(i.set("lang",b),B(b)):B(""),y.navigateToPage(i,u),e()},[e,u,B,b,d]),Y=(h,i)=>{var L;if(i)switch(h){case"add":S(i);break;case"select":X(i);break;case"edit":b!==d?V({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):S(i);break;case"delete":E(i);break;case"unpublish":q(i);break;case"markAsTemplate":f(i);break;case"unmarkAsTemplate":_(i);break;case"duplicate":W(i);break;case"addLanguagePage":V({edit:!1,primaryPage:((L=i==null?void 0:i.page)==null?void 0:L.id)||"",preselectedLang:(i==null?void 0:i.language)||b});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(o.Suspense,{children:t.jsx(pe,{pages:N,search:v,setSearch:j,languages:[d,...a],selectedLanguage:b,setSelectedLanguage:F,selectedPageType:C,setSelectedPageType:z,onAddPage:h=>Y("add",h),showUntranslatedPages:U,setShowUntranslatedPages:ne})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:p||re?t.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],h=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},h))}):n.isEmpty(N)?t.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[t.jsx(k.File,{className:"h-6 w-6 stroke-[1]"}),r("Empty List!"),t.jsx("span",{className:"font-light",children:r("Add new page to start")})]}):t.jsx(te,{tier:0,pages:N,pageTypes:c,currentPage:w||"",onClickAction:Y,languagePages:M,selectedLanguage:b,showUntranslatedPages:U})})]}),A&&t.jsx(o.Suspense,{children:t.jsx(Pe,{closePanel:e,editPage:X,addEditPage:A,setAddEditPage:S})}),m&&t.jsx(o.Suspense,{children:t.jsx(we,{page:m,onClose:()=>E(null)})}),$&&t.jsx(o.Suspense,{children:t.jsx(Se,{page:$,onClose:()=>q(null)})}),I&&t.jsx(o.Suspense,{children:t.jsx(je,{page:I,onClose:()=>f(null)})}),H&&t.jsx(o.Suspense,{children:t.jsx(be,{page:H,onClose:()=>_(null)})}),D&&t.jsx(o.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null),closePanel:e})})]})};exports.default=ve;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-DKjYF53r.cjs"),f=require("./index-BuXfCtgR.cjs"),w=require("./use-page-expand-manager-B6XTvk0E.cjs"),C=require("@tanstack/react-query"),s=require("lodash-es"),d=require("lucide-react"),S=require("react"),g=require("react-i18next"),k=({selectedPageType:l,setSelectedPageType:i})=>{const{t:a}=g.useTranslation(),[r,o]=S.useState(""),{data:c}=f.usePageTypes(),u=t=>{if(!r)return!0;const x=r.toLowerCase(),m=j=>String(s.get(t,j,"")).toLowerCase().includes(x);return m("name")||m("key")},p=c.find(t=>t.key===l);return e.jsxs(n.Select,{onValueChange:i,value:l,children:[e.jsx(n.SelectTrigger,{className:`${l==="all"?"bg-gray-100/30 hover:bg-gray-100":"gap-x-1 border bg-gray-100/30 hover:bg-gray-100"} h-9 w-max min-w-[150px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-gray-600 shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-1.5",children:[e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight",children:(p==null?void 0:p.name)||a("All")}),e.jsx(d.ListFilter,{className:`${l!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(n.SelectContent,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white pb-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(d.Search,{strokeWidth:2,className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400"}),e.jsx(h.Input,{placeholder:a("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:r,onChange:t=>o(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(n.SelectItem,{value:"all",children:a("All")}),!s.isEmpty(s.filter(c,t=>t.hasSlug&&u(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Pages")}),s.map([...s.filter(c,t=>t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),!s.isEmpty(s.filter(c,t=>!t.hasSlug&&u(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Partials")}),s.map([...s.filter(c,t=>!t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),s.isEmpty(s.filter(c,u))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:a("No matching page types found")})]})]})},T=({search:l,setSearch:i})=>{const{t:a}=g.useTranslation();return e.jsxs("div",{className:"relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5",children:[e.jsx("label",{htmlFor:"page-search-input",className:"sr-only",children:a("Search Pages")}),e.jsx(d.Search,{className:`${l?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(h.Input,{id:"page-search-input",placeholder:a("Search pages"),value:l,onChange:r=>i(r.target.value),className:"border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",autoComplete:"off",autoFocus:!0})]})},E=({pages:l})=>{const{t:i}=g.useTranslation(),{expandAll:a,collapseAll:r,expandedPages:o}=w.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"outline",size:"icon",onClick:()=>a(l),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsUpDown,{})})}),e.jsx(n.TooltipContent,{children:i("Expand All")})]}),e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{disabled:o.length===0,variant:"outline",size:"icon",onClick:()=>r(),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsDownUp,{})})}),e.jsx(n.TooltipContent,{children:i("Collapse All")})]})]})},b=({languages:l,selectedLanguage:i,setSelectedLanguage:a})=>{const r=f.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:l.map(o=>e.jsxs(h.Button,{variant:i===o?"default":"outline",size:"sm",className:`h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${i===o?"bg-black text-white hover:bg-black":"text-gray-500"}`,onClick:()=>a(o.toLowerCase()),children:[o===r&&e.jsx(d.Star,{size:4,className:`p-0.5 ${i===r?"fill-white":"fill-black"}`}),f.LANGUAGES[o]||""]},o))})},y=()=>{const{t:l}=g.useTranslation(),i=C.useQueryClient();return e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{size:"sm",variant:"ghost",onClick:()=>i.invalidateQueries({queryKey:[f.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(d.RefreshCw,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:l("Refresh pages list")})]})},q=({pages:l,search:i,setSearch:a,languages:r,onAddPage:o,selectedLanguage:c,setSelectedLanguage:u,selectedPageType:p,setSelectedPageType:t,showUntranslatedPages:x,setShowUntranslatedPages:m})=>{const{t:j}=g.useTranslation(),v=r.length>1;return e.jsxs("div",{className:"space-y-3 border-b border-b-gray-200 px-4 pb-1",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(k,{selectedPageType:p,setSelectedPageType:t}),e.jsx(T,{search:i,setSearch:a}),e.jsx(E,{pages:l}),e.jsxs(h.Button,{variant:"default",onClick:o,className:"rounded px-3 font-normal",children:[e.jsx(d.Plus,{strokeWidth:2,className:"stroke-white stroke-[3]"}),e.jsx("span",{className:"font-normal text-white",children:j("Add Page")})]}),!v&&e.jsx(y,{})]}),v?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(b,{languages:r,selectedLanguage:c,setSelectedLanguage:N=>{u(N),m(x&&(r==null?void 0:r[0])!==c)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(r==null?void 0:r[0])!==c&&e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"ghost",onClick:()=>m(!x),className:"h-6 rounded px-3 py-1 text-xs font-normal",children:x?e.jsx(d.FilterXIcon,{}):e.jsx(d.Filter,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:j("Toggle Untranslated Pages")})]}),e.jsx(y,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=b;exports.default=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-BsloTOgy.cjs"),f=require("./index-Bg3Prrc_.cjs"),w=require("./use-page-expand-manager-B6XTvk0E.cjs"),C=require("@tanstack/react-query"),s=require("lodash-es"),d=require("lucide-react"),S=require("react"),g=require("react-i18next"),k=({selectedPageType:l,setSelectedPageType:i})=>{const{t:a}=g.useTranslation(),[r,o]=S.useState(""),{data:c}=f.usePageTypes(),u=t=>{if(!r)return!0;const x=r.toLowerCase(),m=j=>String(s.get(t,j,"")).toLowerCase().includes(x);return m("name")||m("key")},p=c.find(t=>t.key===l);return e.jsxs(n.Select,{onValueChange:i,value:l,children:[e.jsx(n.SelectTrigger,{className:`${l==="all"?"bg-gray-100/30 hover:bg-gray-100":"gap-x-1 border bg-gray-100/30 hover:bg-gray-100"} h-9 w-max min-w-[150px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-gray-600 shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-1.5",children:[e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight",children:(p==null?void 0:p.name)||a("All")}),e.jsx(d.ListFilter,{className:`${l!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(n.SelectContent,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white pb-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(d.Search,{strokeWidth:2,className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400"}),e.jsx(h.Input,{placeholder:a("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:r,onChange:t=>o(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(n.SelectItem,{value:"all",children:a("All")}),!s.isEmpty(s.filter(c,t=>t.hasSlug&&u(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Pages")}),s.map([...s.filter(c,t=>t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),!s.isEmpty(s.filter(c,t=>!t.hasSlug&&u(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Partials")}),s.map([...s.filter(c,t=>!t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),s.isEmpty(s.filter(c,u))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:a("No matching page types found")})]})]})},T=({search:l,setSearch:i})=>{const{t:a}=g.useTranslation();return e.jsxs("div",{className:"relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5",children:[e.jsx("label",{htmlFor:"page-search-input",className:"sr-only",children:a("Search Pages")}),e.jsx(d.Search,{className:`${l?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(h.Input,{id:"page-search-input",placeholder:a("Search pages"),value:l,onChange:r=>i(r.target.value),className:"border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",autoComplete:"off",autoFocus:!0})]})},E=({pages:l})=>{const{t:i}=g.useTranslation(),{expandAll:a,collapseAll:r,expandedPages:o}=w.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"outline",size:"icon",onClick:()=>a(l),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsUpDown,{})})}),e.jsx(n.TooltipContent,{children:i("Expand All")})]}),e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{disabled:o.length===0,variant:"outline",size:"icon",onClick:()=>r(),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsDownUp,{})})}),e.jsx(n.TooltipContent,{children:i("Collapse All")})]})]})},b=({languages:l,selectedLanguage:i,setSelectedLanguage:a})=>{const r=f.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:l.map(o=>e.jsxs(h.Button,{variant:i===o?"default":"outline",size:"sm",className:`h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${i===o?"bg-black text-white hover:bg-black":"text-gray-500"}`,onClick:()=>a(o.toLowerCase()),children:[o===r&&e.jsx(d.Star,{size:4,className:`p-0.5 ${i===r?"fill-white":"fill-black"}`}),f.LANGUAGES[o]||""]},o))})},y=()=>{const{t:l}=g.useTranslation(),i=C.useQueryClient();return e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{size:"sm",variant:"ghost",onClick:()=>i.invalidateQueries({queryKey:[f.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(d.RefreshCw,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:l("Refresh pages list")})]})},q=({pages:l,search:i,setSearch:a,languages:r,onAddPage:o,selectedLanguage:c,setSelectedLanguage:u,selectedPageType:p,setSelectedPageType:t,showUntranslatedPages:x,setShowUntranslatedPages:m})=>{const{t:j}=g.useTranslation(),v=r.length>1;return e.jsxs("div",{className:"space-y-3 border-b border-b-gray-200 px-4 pb-1",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(k,{selectedPageType:p,setSelectedPageType:t}),e.jsx(T,{search:i,setSearch:a}),e.jsx(E,{pages:l}),e.jsxs(h.Button,{variant:"default",onClick:o,className:"rounded px-3 font-normal",children:[e.jsx(d.Plus,{strokeWidth:2,className:"stroke-white stroke-[3]"}),e.jsx("span",{className:"font-normal text-white",children:j("Add Page")})]}),!v&&e.jsx(y,{})]}),v?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(b,{languages:r,selectedLanguage:c,setSelectedLanguage:N=>{u(N),m(x&&(r==null?void 0:r[0])!==c)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(r==null?void 0:r[0])!==c&&e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"ghost",onClick:()=>m(!x),className:"h-6 rounded px-3 py-1 text-xs font-normal",children:x?e.jsx(d.FilterXIcon,{}):e.jsx(d.Filter,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:j("Toggle Untranslated Pages")})]}),e.jsx(y,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=b;exports.default=q;
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as a, Fragment as k } from "react/jsx-runtime";
2
2
  import { B as m, z as E } from "./register-chai-top-bar-D6GjnauV.js";
3
- import { w as g, x as b, y, S as F, z as L, A as I, B as w } from "./index-C7bidKtE.js";
4
- import { i as j, L as T, k as $, A as B } from "./index-BDrc0HJQ.js";
3
+ import { w as g, x as b, y, S as F, z as L, A as I, B as w } from "./index-94oA-Cgl.js";
4
+ import { i as j, L as T, k as $, A as B } from "./index-CDUCqK5V.js";
5
5
  import { u as G } from "./use-page-expand-manager-Cf4MUEJw.js";
6
6
  import { useQueryClient as D } from "@tanstack/react-query";
7
7
  import { isEmpty as N, filter as x, map as S, get as i } from "lodash-es";
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-DyW9GPzV.cjs"),i=require("./index-BsloTOgy.cjs"),c=require("./index-Bg3Prrc_.cjs"),y=require("@tanstack/react-query"),S=require("date-fns"),B=require("lodash-es"),f=require("lucide-react"),g=require("react");function L(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const w=L(g);function Q(s){const n=c.useApiUrl(),t=c.useFetch();return y.useQuery({queryKey:[c.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:c.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const z=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async r=>await n(s,{action:c.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async({revisionId:r,discardCurrent:l,pageId:d})=>await n(s,{action:c.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:r,discardCurrent:l,...d&&{pageId:d}}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=g.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-CdU-gKRr.cjs"))),b=({tag:s})=>s==="draft"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Draft"})]}):s==="live"?e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Live"})]}):s==="published"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-green-500/10 px-1.5 py-0.5 text-xs text-green-600",children:[e.jsx(f.Rocket,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Published"})]}):s==="unsaved"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[e.jsx(f.Save,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Unsaved changes"})]}):e.jsx("span",{className:"rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600",children:s});function J({compare:s,setCompare:n}){const{data:t}=c.usePrimaryPage(),{saveState:r}=i.useSavePage(),[l]=c.usePageEditInfo();if(!t)return null;const d=!!s.find(x=>{var a;return(a=x==null?void 0:x.uid)==null?void 0:a.startsWith("draft:")}),u=s.length>=2&&!d,m=r==="UNSAVED";return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border bg-primary/5 p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium leading-none",children:[e.jsx(b,{tag:"draft"}),e.jsx("span",{className:"text-xs font-bold",children:"Currently editing"})]})}),e.jsx("div",{className:"flex items-center pl-2 text-[11px] text-muted-foreground",children:!B.isEmpty(l.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",S.formatDistanceToNow(new Date(l.lastSaved),{addSuffix:!0})]})}),e.jsx("div",{className:"flex items-center gap-2 pt-0.5",children:m?e.jsx(b,{tag:"unsaved"}):null})]}),e.jsx(O,{checked:d,disabled:u,onChange:()=>{n(d?s.filter(x=>x.uid!==`draft:${t==null?void 0:t.id}`):[...s,{uid:`draft:${t==null?void 0:t.id}`,label:"draft",item:{createdAt:Date.now()}}])}})]})}function K(){return e.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((s,n)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(i.Skeleton,{className:"h-4 w-3/4"}),e.jsx(i.Skeleton,{className:"h-3 w-1/2"}),e.jsx(i.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(i.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function I({revision:s,isLatest:n,onRestore:t,onDelete:r,revisionNumber:l,compare:d,setCompare:u,pageId:m}){const{data:x}=c.useChaiUserInfo(s.currentEditor),a=(x==null?void 0:x.name)||"Unknown",p=!!d.find(h=>{var j;return n?(j=h==null?void 0:h.uid)==null?void 0:j.startsWith("live"):(h==null?void 0:h.uid)===s.uid}),D=d.length>=2&&!p;return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"flex items-center gap-1 text-xs leading-none",children:[e.jsx(b,{tag:n?"live":`#${l}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:a})]})}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s.type==="published"?e.jsx(b,{tag:"published"}):e.jsx(b,{tag:"draft"})}),e.jsx("div",{className:"flex items-center text-[10px] text-muted-foreground",children:e.jsx("span",{className:"leading-tight",children:S.format(s.createdAt,"MMM d, yyyy, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(c.PermissionChecker,{permissions:[c.PAGES_PERMISSIONS.RESTORE_REVISION,c.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:r})})}),e.jsx(O,{checked:p,disabled:D,onChange:()=>{u(p?d.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...d,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${l}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function A({tab:s,onRemove:n}){return e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(b,{tag:s.label}),e.jsx("button",{className:"z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",style:{lineHeight:1},onClick:()=>n(s.uid),"aria-label":"Remove selection",children:e.jsx(f.X,{className:"h-3 w-3"})})]})}function W({compare:s,setCompare:n,pageId:t}){const[r,l]=g.useState(!1),[d,u]=s;if(s.length===0)return null;const m=x=>n(s.filter(a=>a.uid!==x));return e.jsxs("div",{className:"mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-xs",children:[e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"Compare"}),d&&e.jsx(A,{tab:d,onRemove:m}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),u?e.jsx(A,{tab:u,onRemove:m}):e.jsx("span",{className:"rounded border px-1 text-xs text-muted-foreground",children:"Choose another"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-0.5 pt-2",children:[e.jsx(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none text-gray-500",variant:"outline",onClick:()=>n([]),children:e.jsx("span",{children:" Clear"})}),e.jsxs(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none",variant:"default",onClick:()=>l(!0),disabled:s.length<2,children:[e.jsx(f.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),r&&(s==null?void 0:s.length)>1&&t&&e.jsx(g.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx("span",{className:"text-sm",children:"Loading diff viewer..."})}),children:e.jsx($,{open:r,onOpenChange:l,compare:s})})]})}function O({checked:s,disabled:n,onChange:t,label:r="Compare"}){return e.jsx("div",{className:"absolute bottom-2 right-2",children:e.jsxs("label",{className:`flex cursor-pointer items-center gap-x-1 text-[11px] ${n?"opacity-50":""}`,children:[e.jsx("input",{type:"checkbox",className:"h-3 w-3 cursor-pointer rounded focus:ring-0 focus:ring-offset-0",checked:s,disabled:n,onChange:t}),e.jsx("span",{className:"select-none leading-tight",children:r})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(N.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(f.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(i.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(f.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(i.DropdownMenuSeparator,{}),e.jsxs(i.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(f.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function X({open:s,onOpenChange:n,revision:t,onRestore:r,isRestoring:l}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{l||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Restore Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",S.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>r(!1),disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(N.Button,{variant:"default",className:"sm:flex-1",onClick:()=>r(!0),disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Z({open:s,onOpenChange:n,revision:t,onDelete:r,isDeleting:l}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{l||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Delete Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",S.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>n(!1),disabled:l,children:"Cancel"}),e.jsx(N.Button,{variant:"destructive",className:"sm:flex-1",onClick:r,disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function ee({isOpen:s}){var R;const[n,t]=w.useState([]),[r,l]=w.useState(null),[d,u]=w.useState(!1),[m,x]=w.useState(!1),{data:a}=c.usePrimaryPage(),{data:p,isFetching:D,error:h,refetch:j}=Q(a==null?void 0:a.id),{mutate:T,isPending:M}=z(),{mutate:k,isPending:F}=H(),_=y.useQueryClient(),{selectedLang:P,fallbackLang:q}=i.useLanguages(),U=P||q;g.useEffect(()=>{g.startTransition(()=>t([]))},[a==null?void 0:a.id]);const G=o=>{r&&k({revisionId:r.uid,discardCurrent:o,...r.uid==="current"&&(a==null?void 0:a.id)&&{pageId:a.id}},{onSuccess:()=>{u(!1),l(null),_.invalidateQueries({queryKey:[c.ACTIONS.GET_DRAFT_PAGE]})}})},C=o=>{l(o),u(!0)},E=o=>{l(o),x(!0)},V=()=>{r&&T(r.uid,{onSuccess:()=>{x(!1),l(null)}})};return g.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(i.SheetHeader,{children:[e.jsx(i.SheetTitle,{children:"Revision History"}),(a==null?void 0:a.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",S.format(new Date(a.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),D?e.jsx(K,{}):h?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Failed to load revisions. Please try again."}):e.jsxs("div",{className:"mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2",children:[e.jsx(W,{lang:U,compare:n,setCompare:t,pageId:a==null?void 0:a.id}),e.jsx(J,{compare:n,setCompare:t}),(R=p==null?void 0:p.filter(o=>o.uid==="current"))==null?void 0:R.map((o,v)=>e.jsx(I,{pageId:a==null?void 0:a.id,revision:o,isLatest:!0,onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:v,compare:n,setCompare:t},o.uid)),e.jsx(i.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:[...p??[]].filter(o=>o.uid!=="current").sort((o,v)=>new Date(v.createdAt).getTime()-new Date(o.createdAt).getTime()).map((o,v)=>e.jsx(I,{pageId:a==null?void 0:a.id,revision:o,isLatest:o.uid==="current",onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:v+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(X,{open:d,onOpenChange:u,revision:r,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:x,revision:r,onDelete:V,isDeleting:M})]})}exports.default=ee;