@chaibuilder/pages 0.16.13 → 0.16.15

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 (104) hide show
  1. package/dist/{2AITGKQY-D1mM4eEh.js → 2AITGKQY-2rt9M99C.js} +5 -5
  2. package/dist/{2AITGKQY-AK2WgbeT.cjs → 2AITGKQY-Cs6RBSPQ.cjs} +1 -1
  3. package/dist/{NCMVHL6D-DItDf9IY.cjs → NCMVHL6D-CsC6nsSQ.cjs} +1 -1
  4. package/dist/{NCMVHL6D-BeRsWdGV.js → NCMVHL6D-vUfYKc6i.js} +2 -2
  5. package/dist/{ZDWCUMSJ-COSBY-at.cjs → ZDWCUMSJ-B2OZjsr6.cjs} +1 -1
  6. package/dist/{ZDWCUMSJ-D6caRaY7.js → ZDWCUMSJ-CzEWKlEU.js} +1 -1
  7. package/dist/active-in-another-tab-B0N5S-Bh.js +34 -0
  8. package/dist/active-in-another-tab-BK3cZf-x.cjs +1 -0
  9. package/dist/{add-new-language-page-CQcFi0Tp.cjs → add-new-language-page-Dt1j-8Zg.cjs} +1 -1
  10. package/dist/{add-new-language-page-nnaUe-qk.js → add-new-language-page-YlqcCdlK.js} +20 -20
  11. package/dist/{add-new-page-DxObnvo_.cjs → add-new-page-DqhQUQBz.cjs} +1 -1
  12. package/dist/{add-new-page-Ba1fq6LH.js → add-new-page-aYomeid4.js} +1 -1
  13. package/dist/ai-panel-content-C6cH9rrC.js +123 -0
  14. package/dist/ai-panel-content-MOZmNIKP.cjs +1 -0
  15. package/dist/ai-panel-default-lang-BZHkFsox.js +317 -0
  16. package/dist/ai-panel-default-lang-DOk_Q0IO.cjs +3 -0
  17. package/dist/{ai-panel-other-lang-B4euTuod.js → ai-panel-other-lang-D2A46FTg.js} +10 -9
  18. package/dist/ai-panel-other-lang-qHrdvAMa.cjs +1 -0
  19. package/dist/ai-prompt-input-BZSjjNJd.cjs +1 -0
  20. package/dist/ai-prompt-input-C6gDvvLQ.js +1071 -0
  21. package/dist/{ai-translation-prompt-Ip7w2_Ey.cjs → ai-translation-prompt-BqXo2CLp.cjs} +1 -1
  22. package/dist/{ai-translation-prompt-CVuPbgXw.js → ai-translation-prompt-DTR0wbGt.js} +1 -1
  23. package/dist/continue-editing-in-this-client-C3T6Jzhi.cjs +1 -0
  24. package/dist/continue-editing-in-this-client-D2S1yCOM.js +24 -0
  25. package/dist/delete-page-BF1k60U2.js +70 -0
  26. package/dist/delete-page-x0DWKzsR.cjs +1 -0
  27. package/dist/{digital-asset-manager-CIMo79Di.cjs → digital-asset-manager-BmlFt2T_.cjs} +1 -1
  28. package/dist/{digital-asset-manager-SAFNO_mx.js → digital-asset-manager-C8udwDBW.js} +1 -1
  29. package/dist/{duplicate-page-CXK2HcxD.cjs → duplicate-page-Dt_QZkTk.cjs} +1 -1
  30. package/dist/{duplicate-page-5SwLvmkX.js → duplicate-page-u_6vUVo1.js} +7 -7
  31. package/dist/{dynamic-page-selector-Crd3y4Hk.cjs → dynamic-page-selector-Cgs_Y_Kl.cjs} +1 -1
  32. package/dist/{dynamic-page-selector-DfcuTqRN.js → dynamic-page-selector-DxBHmglP.js} +1 -1
  33. package/dist/index-BeWL6Sj6.cjs +5 -0
  34. package/dist/index-DI2Rwk5v.js +4820 -0
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.d.ts +1 -34
  37. package/dist/index.js +21 -22
  38. package/dist/{json-diff-viewer-D34kDA_c.cjs → json-diff-viewer-D2g0Yab2.cjs} +1 -1
  39. package/dist/{json-diff-viewer-CDwpbuag.js → json-diff-viewer-QdUwk7yF.js} +6 -6
  40. package/dist/{lang-panel-CUIeO5bb.js → lang-panel-B8OD0GiA.js} +24 -24
  41. package/dist/{lang-panel-CaFrYllL.cjs → lang-panel-M2Zb01lF.cjs} +1 -1
  42. package/dist/{mark-as-template-D0dLQaIB.js → mark-as-template-CJ1mlxYT.js} +7 -7
  43. package/dist/{mark-as-template-v182tmN6.cjs → mark-as-template-DONU52b1.cjs} +1 -1
  44. package/dist/{no-language-page-content-Bk4fEx_p.cjs → no-language-page-content-DD9Ok2Ku.cjs} +1 -1
  45. package/dist/{no-language-page-content-ByRFD_qA.js → no-language-page-content-Dtm37LTJ.js} +1 -1
  46. package/dist/no-language-page-dialog-D3dvenZ7.cjs +1 -0
  47. package/dist/no-language-page-dialog-Dj_z2_hF.js +10 -0
  48. package/dist/{page-creator-Bh0IUGR3.js → page-creator-DIMFISo4.js} +52 -52
  49. package/dist/{page-creator-BnvaGZVI.cjs → page-creator-DTC66ujU.cjs} +1 -1
  50. package/dist/page-lock-CI6BYvF_.cjs +1 -0
  51. package/dist/page-lock-DUlNr3os.js +30 -0
  52. package/dist/page-locked-dialog-BKwULMV7.js +133 -0
  53. package/dist/page-locked-dialog-DorIbva0.cjs +1 -0
  54. package/dist/page-manager-new-lNVrLOJp.cjs +1 -0
  55. package/dist/page-manager-new-znvqI9_L.js +354 -0
  56. package/dist/{page-manager-search-and-filter-BETHSa3y.js → page-manager-search-and-filter-C-_w7N27.js} +1 -1
  57. package/dist/{page-manager-search-and-filter-hyUIHOD_.cjs → page-manager-search-and-filter-pe0q0qnZ.cjs} +1 -1
  58. package/dist/{page-revisions-content-BCMjvZRZ.cjs → page-revisions-content-Caaj5TEI.cjs} +1 -1
  59. package/dist/{page-revisions-content-VWthKL7O.js → page-revisions-content-CyLjyxNU.js} +16 -16
  60. package/dist/pages.css +1 -1
  61. package/dist/publish-pages-content-Bih1W9C4.js +178 -0
  62. package/dist/publish-pages-content-D5beVcQI.cjs +1 -0
  63. package/dist/{save-to-lib-YYBxY7MV.js → save-to-lib-BwpkJcT2.js} +1 -1
  64. package/dist/{save-to-lib-CtGpDkC6.cjs → save-to-lib-DPAERsi4.cjs} +1 -1
  65. package/dist/{selected-block-display-DdW-DWF1.js → selected-block-display-GXSf3y2s.js} +1 -1
  66. package/dist/{selected-block-display-BEbuJn0l.cjs → selected-block-display-s99Y91qI.cjs} +1 -1
  67. package/dist/{seo-panel-CqJDhbj-.js → seo-panel-BurZA566.js} +61 -61
  68. package/dist/{seo-panel-B9P7fXjo.cjs → seo-panel-BxUfalVy.cjs} +1 -1
  69. package/dist/server.cjs +1 -1
  70. package/dist/server.js +39 -39
  71. package/dist/{shared-json-ld-CyxmC9y5.cjs → shared-json-ld-BYAdrPeC.cjs} +1 -1
  72. package/dist/{shared-json-ld-DxEPILj_.js → shared-json-ld-DHWdJvQd.js} +39 -39
  73. package/dist/{slug-input-RNiSrU3p.cjs → slug-input-CR2B1kDJ.cjs} +1 -1
  74. package/dist/{slug-input-j5z5ZQn9.js → slug-input-Z_ny7bgX.js} +1 -1
  75. package/dist/take-over-request-CnEpToCM.cjs +1 -0
  76. package/dist/take-over-request-DF2JsIes.js +63 -0
  77. package/dist/{theme-panel-footer-DD2yalfG.js → theme-panel-footer-5mxFeEua.js} +4 -4
  78. package/dist/{theme-panel-footer-CCsiDIVl.cjs → theme-panel-footer-C2CjHoBu.cjs} +1 -1
  79. package/dist/{unmark-as-template-DXjLbqOM.cjs → unmark-as-template-Dn90g1eh.cjs} +1 -1
  80. package/dist/{unmark-as-template-B2hKhAHn.js → unmark-as-template-JRRUYTOY.js} +1 -1
  81. package/dist/{unpublish-page-BdJScWMX.cjs → unpublish-page-C3C_rTRd.cjs} +1 -1
  82. package/dist/{unpublish-page-BvB1PGSz.js → unpublish-page-FZ8rbi7u.js} +9 -9
  83. package/dist/{web-preview-CwVpkcwU.js → web-preview-CGBKG162.js} +1 -1
  84. package/dist/{web-preview-BI4jd0O7.cjs → web-preview-NdxC92Fk.cjs} +1 -1
  85. package/package.json +3 -3
  86. package/dist/ai-panel-content-B2AgBWqo.cjs +0 -1
  87. package/dist/ai-panel-content-M1UnzG_f.js +0 -54
  88. package/dist/ai-panel-default-lang-CHOFEwmV.js +0 -313
  89. package/dist/ai-panel-default-lang-sy6vkQJh.cjs +0 -3
  90. package/dist/ai-panel-other-lang-BwjSDD3L.cjs +0 -1
  91. package/dist/ai-prompt-input-B_NRADBT.js +0 -988
  92. package/dist/ai-prompt-input-DcyVXcLG.cjs +0 -1
  93. package/dist/delete-page-CbY8q5M3.cjs +0 -1
  94. package/dist/delete-page-SX9X35nA.js +0 -40
  95. package/dist/index-Bz7smSC0.cjs +0 -5
  96. package/dist/index-EnM7J19_.js +0 -4960
  97. package/dist/page-lock-request-C2b1kqyA.cjs +0 -1
  98. package/dist/page-lock-request-CaNqxfD6.js +0 -75
  99. package/dist/page-locked-by-dialog--WLDdkw9.js +0 -68
  100. package/dist/page-locked-by-dialog-90ElC8aG.cjs +0 -1
  101. package/dist/page-manager-new-Bo4-zwfW.js +0 -354
  102. package/dist/page-manager-new-SNRQn7Az.cjs +0 -1
  103. package/dist/publish-pages-content-6N7aEcM1.js +0 -178
  104. package/dist/publish-pages-content-CaBwfekc.cjs +0 -1
@@ -0,0 +1,63 @@
1
+ import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
+ import { an as N, b as C, a as b, ao as v, B as E, E as d, P as m } from "./index-DI2Rwk5v.js";
3
+ import { useSavePage as T, useTranslation as w } from "@chaibuilder/sdk";
4
+ import { Card as I, CardHeader as k, CardTitle as y, CardContent as R, CardFooter as S, Button as u } from "@chaibuilder/sdk/ui";
5
+ import { AlertCircle as A, UserIcon as P, Check as _, X as q } from "lucide-react";
6
+ import { useState as U } from "react";
7
+ const H = () => {
8
+ const l = N(), { pageLockMeta: r } = C(), { setPageStatus: c } = b(), { savePageAsync: h } = T(), x = r == null ? void 0 : r.requestingUserId, { data: e, isFetching: f } = v(x || ""), i = f ? "Fetching user..." : (e == null ? void 0 : e.name) || "Current editor", [o, n] = U(!1), p = async () => {
9
+ n(!0), await h(), l(d.CONTINUE_EDITING_IN_THIS_CLIENT, r), c(m.CHECKING), setTimeout(() => n(!1), 2e3);
10
+ }, g = () => {
11
+ n(!0), l(d.TAKE_OVER_REJECTED, r), c(m.EDITING), setTimeout(() => n(!1), 2e3);
12
+ }, { t: s } = w();
13
+ return /* @__PURE__ */ t(E, { children: /* @__PURE__ */ a(I, { className: "mx-auto w-full max-w-md", children: [
14
+ /* @__PURE__ */ t(k, { className: "space-y-1", children: /* @__PURE__ */ a(y, { className: "flex items-center gap-2 text-xl", children: [
15
+ /* @__PURE__ */ t(A, { className: "h-8 w-8 rounded-md bg-amber-500/20 p-1.5 text-amber-500" }),
16
+ s("Take Over Requested")
17
+ ] }) }),
18
+ /* @__PURE__ */ a(R, { className: "space-y-4", children: [
19
+ /* @__PURE__ */ a("div", { className: "relative rounded-md border border-green-500 px-2 pb-2 pt-4", children: [
20
+ /* @__PURE__ */ t("div", { className: "absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white", children: "Requested by" }),
21
+ /* @__PURE__ */ a("div", { className: "flex items-center space-x-4 p-1", children: [
22
+ e != null && e.avatar ? /* @__PURE__ */ t(
23
+ "img",
24
+ {
25
+ src: e.avatar,
26
+ alt: e.name,
27
+ className: "h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"
28
+ }
29
+ ) : /* @__PURE__ */ t(P, { className: "h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white" }),
30
+ /* @__PURE__ */ a("div", { className: "flex-1 space-y-0", children: [
31
+ /* @__PURE__ */ t("div", { className: "truncate font-medium leading-tight text-black", children: i }),
32
+ (e == null ? void 0 : e.email) && /* @__PURE__ */ t("p", { className: "truncate text-sm leading-tight text-muted-foreground", children: e.email })
33
+ ] })
34
+ ] })
35
+ ] }),
36
+ /* @__PURE__ */ a("p", { className: "text-sm text-muted-foreground", children: [
37
+ /* @__PURE__ */ t("span", { className: "font-medium text-gray-700", children: i }),
38
+ " ",
39
+ s("has requested to"),
40
+ " ",
41
+ /* @__PURE__ */ t("span", { className: "font-medium text-gray-500", children: "take over" }),
42
+ " ",
43
+ s("editing this page."),
44
+ ".",
45
+ " ",
46
+ s("Do you want to allow them to continue?")
47
+ ] })
48
+ ] }),
49
+ /* @__PURE__ */ a(S, { className: "flex gap-2", children: [
50
+ /* @__PURE__ */ a(u, { disabled: o, variant: "default", onClick: p, className: "flex-1 gap-2", children: [
51
+ /* @__PURE__ */ t(_, { className: "h-4 w-4" }),
52
+ s("Accept")
53
+ ] }),
54
+ /* @__PURE__ */ a(u, { disabled: o, variant: "outline", onClick: g, className: "flex-1 gap-2", children: [
55
+ /* @__PURE__ */ t(q, { className: "h-4 w-4" }),
56
+ s("Reject")
57
+ ] })
58
+ ] })
59
+ ] }) });
60
+ };
61
+ export {
62
+ H as default
63
+ };
@@ -1,16 +1,16 @@
1
1
  import { jsxs as c, jsx as a } from "react/jsx-runtime";
2
- import { u, a as d, t as h } from "./index-EnM7J19_.js";
3
- import { useTheme as b, useTranslation as g } from "@chaibuilder/sdk";
2
+ import { e as d, f as h, t as u } from "./index-DI2Rwk5v.js";
3
+ import { useTheme as b, useTranslation as f } from "@chaibuilder/sdk";
4
4
  import { Button as o } from "@chaibuilder/sdk/ui";
5
5
  const x = () => {
6
- const [e] = b(), { mutate: r, isPending: s } = u(), { mutateAsync: t, isPending: i } = d(), { t: n } = g(), l = () => {
6
+ const [e] = b(), { mutate: r, isPending: s } = d(), { mutateAsync: t, isPending: i } = h(), { t: n } = f(), l = () => {
7
7
  t({ settings: { theme: e } });
8
8
  }, m = async () => {
9
9
  await t({ settings: { theme: e } }), r(
10
10
  { ids: ["THEME"] },
11
11
  {
12
12
  onSuccess: () => {
13
- h("BOTTOM_RIGHT");
13
+ u("BOTTOM_RIGHT");
14
14
  }
15
15
  }
16
16
  );
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-Bz7smSC0.cjs"),o=require("@chaibuilder/sdk"),r=require("@chaibuilder/sdk/ui"),h=()=>{const[t]=o.useTheme(),{mutate:c,isPending:i}=s.usePublishPages(),{mutateAsync:n,isPending:u}=s.useUpdateWebsiteSettings(),{t:a}=o.useTranslation(),l=()=>{n({settings:{theme:t}})},d=async()=>{await n({settings:{theme:t}}),c({ids:["THEME"]},{onSuccess:()=>{s.throwConfetti("BOTTOM_RIGHT")}})};return e.jsxs("div",{className:"flex items-center justify-center gap-x-3 border-t bg-white py-3",children:[e.jsx(r.Button,{size:"sm",variant:"outline",disabled:i||u,onClick:l,children:a("Save draft")}),e.jsx(r.Button,{size:"sm",disabled:i||u,onClick:d,children:a("Publish")})]})};exports.default=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-BeWL6Sj6.cjs"),o=require("@chaibuilder/sdk"),r=require("@chaibuilder/sdk/ui"),h=()=>{const[t]=o.useTheme(),{mutate:c,isPending:i}=s.usePublishPages(),{mutateAsync:n,isPending:u}=s.useUpdateWebsiteSettings(),{t:a}=o.useTranslation(),l=()=>{n({settings:{theme:t}})},d=async()=>{await n({settings:{theme:t}}),c({ids:["THEME"]},{onSuccess:()=>{s.throwConfetti("BOTTOM_RIGHT")}})};return e.jsxs("div",{className:"flex items-center justify-center gap-x-3 border-t bg-white py-3",children:[e.jsx(r.Button,{size:"sm",variant:"outline",disabled:i||u,onClick:l,children:a("Save draft")}),e.jsx(r.Button,{size:"sm",disabled:i||u,onClick:d,children:a("Publish")})]})};exports.default=h;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-Bz7smSC0.cjs"),d=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),m=require("react"),p=({page:i,onClose:n})=>{const{t:a}=d.useTranslation(),[r,s]=m.useState(!1),o=u.useUnmarkAsTemplate(),l=()=>{s(!0),o.mutate(i,{onSuccess:()=>{s(!1),n()},onError:()=>{s(!1)}})};return e.jsx(t.Dialog,{open:!0,onOpenChange:n,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:a("Unmark as template")}),e.jsx(t.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:a("Are you sure you want to unmark this page as a template?")})]}),e.jsxs(t.DialogFooter,{className:r?"pointer-events-none opacity-75":"",children:[e.jsx(t.Button,{variant:"outline",onClick:c=>{c.stopPropagation(),n()},children:a("Cancel")}),e.jsx(t.Button,{variant:"default",disabled:r,onClick:l,children:a("Unmark as template")})]})]})})};exports.default=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-BeWL6Sj6.cjs"),d=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),m=require("react"),p=({page:i,onClose:n})=>{const{t:a}=d.useTranslation(),[r,s]=m.useState(!1),o=u.useUnmarkAsTemplate(),l=()=>{s(!0),o.mutate(i,{onSuccess:()=>{s(!1),n()},onError:()=>{s(!1)}})};return e.jsx(t.Dialog,{open:!0,onOpenChange:n,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:a("Unmark as template")}),e.jsx(t.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:a("Are you sure you want to unmark this page as a template?")})]}),e.jsxs(t.DialogFooter,{className:r?"pointer-events-none opacity-75":"",children:[e.jsx(t.Button,{variant:"outline",onClick:c=>{c.stopPropagation(),n()},children:a("Cancel")}),e.jsx(t.Button,{variant:"default",disabled:r,onClick:l,children:a("Unmark as template")})]})]})})};exports.default=p;
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as o } from "react/jsx-runtime";
2
- import { o as p } from "./index-EnM7J19_.js";
2
+ import { s as p } from "./index-DI2Rwk5v.js";
3
3
  import { useTranslation as u } from "@chaibuilder/sdk";
4
4
  import { Dialog as d, DialogContent as g, DialogHeader as h, DialogTitle as f, DialogDescription as k, DialogFooter as D, Button as s } from "@chaibuilder/sdk/ui";
5
5
  import { useState as x } from "react";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),u=require("./index-Bz7smSC0.cjs"),c=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),d=({page:i,onClose:t})=>{const{t:e}=c.useTranslation(),{mutate:r,isPending:l}=u.useUnpublishPage(),o=async()=>{r(i,{onSuccess:t})};return n.jsx(s.Dialog,{open:!!i,onOpenChange:t,children:n.jsxs(s.DialogContent,{children:[n.jsxs(s.DialogHeader,{children:[n.jsx(s.DialogTitle,{children:e("Confirm action")}),n.jsxs(s.DialogDescription,{children:[e("Are you sure you want to unpublish")," ",n.jsx("b",{children:(i==null?void 0:i.name)??(i==null?void 0:i.slug)}),"?"]})]}),n.jsxs(s.DialogFooter,{children:[n.jsx(s.Button,{variant:"outline",onClick:t,children:e("Cancel")}),n.jsx(s.Button,{variant:"destructive",disabled:l,onClick:o,children:e(l?"Updating...":"Unpublish")})]})]})})};exports.default=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),u=require("./index-BeWL6Sj6.cjs"),c=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),d=({page:i,onClose:t})=>{const{t:e}=c.useTranslation(),{mutate:r,isPending:l}=u.useUnpublishPage(),o=async()=>{r(i,{onSuccess:t})};return n.jsx(s.Dialog,{open:!!i,onOpenChange:t,children:n.jsxs(s.DialogContent,{children:[n.jsxs(s.DialogHeader,{children:[n.jsx(s.DialogTitle,{children:e("Confirm action")}),n.jsxs(s.DialogDescription,{children:[e("Are you sure you want to unpublish")," ",n.jsx("b",{children:(i==null?void 0:i.name)??(i==null?void 0:i.slug)}),"?"]})]}),n.jsxs(s.DialogFooter,{children:[n.jsx(s.Button,{variant:"outline",onClick:t,children:e("Cancel")}),n.jsx(s.Button,{variant:"destructive",disabled:l,onClick:o,children:e(l?"Updating...":"Unpublish")})]})]})})};exports.default=d;
@@ -1,23 +1,23 @@
1
- import { jsx as o, jsxs as l } from "react/jsx-runtime";
2
- import { l as u } from "./index-EnM7J19_.js";
1
+ import { jsx as o, jsxs as t } from "react/jsx-runtime";
2
+ import { o as u } from "./index-DI2Rwk5v.js";
3
3
  import { useTranslation as a } from "@chaibuilder/sdk";
4
4
  import { Dialog as h, DialogContent as d, DialogHeader as m, DialogTitle as b, DialogDescription as D, DialogFooter as f, Button as s } from "@chaibuilder/sdk/ui";
5
- const g = ({ page: n, onClose: t }) => {
5
+ const g = ({ page: n, onClose: l }) => {
6
6
  const { t: i } = a(), { mutate: e, isPending: r } = u(), c = async () => {
7
- e(n, { onSuccess: t });
7
+ e(n, { onSuccess: l });
8
8
  };
9
- return /* @__PURE__ */ o(h, { open: !!n, onOpenChange: t, children: /* @__PURE__ */ l(d, { children: [
10
- /* @__PURE__ */ l(m, { children: [
9
+ return /* @__PURE__ */ o(h, { open: !!n, onOpenChange: l, children: /* @__PURE__ */ t(d, { children: [
10
+ /* @__PURE__ */ t(m, { children: [
11
11
  /* @__PURE__ */ o(b, { children: i("Confirm action") }),
12
- /* @__PURE__ */ l(D, { children: [
12
+ /* @__PURE__ */ t(D, { children: [
13
13
  i("Are you sure you want to unpublish"),
14
14
  " ",
15
15
  /* @__PURE__ */ o("b", { children: (n == null ? void 0 : n.name) ?? (n == null ? void 0 : n.slug) }),
16
16
  "?"
17
17
  ] })
18
18
  ] }),
19
- /* @__PURE__ */ l(f, { children: [
20
- /* @__PURE__ */ o(s, { variant: "outline", onClick: t, children: i("Cancel") }),
19
+ /* @__PURE__ */ t(f, { children: [
20
+ /* @__PURE__ */ o(s, { variant: "outline", onClick: l, children: i("Cancel") }),
21
21
  /* @__PURE__ */ o(s, { variant: "destructive", disabled: r, onClick: c, children: i(r ? "Updating..." : "Unpublish") })
22
22
  ] })
23
23
  ] }) });
@@ -4,7 +4,7 @@ import { Button as s } from "@chaibuilder/sdk/ui";
4
4
  import { useAtom as h } from "jotai";
5
5
  import { map as p } from "lodash-es";
6
6
  import { Smartphone as w, Tablet as f, Laptop as u, LaptopMinimal as x } from "lucide-react";
7
- import { p as v, T as _ } from "./index-EnM7J19_.js";
7
+ import { p as v, T as _ } from "./index-DI2Rwk5v.js";
8
8
  const b = [
9
9
  {
10
10
  title: "mobile_xs_title",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),a=require("@chaibuilder/sdk/ui"),h=require("jotai"),x=require("lodash-es"),n=require("lucide-react"),c=require("./index-Bz7smSC0.cjs"),m=[{title:"mobile_xs_title",content:"mobile_xs_content",icon:e.jsx(n.Smartphone,{className:"h-4 w-4"}),width:400},{title:"tablet_md_title",content:"tablet_md_content",icon:e.jsx(n.Tablet,{className:"h-4 w-4"}),width:800},{title:"desktop_xl_title",content:"desktop_xl_content",icon:e.jsx(n.Laptop,{className:"h-4 w-4"}),width:1200},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",icon:e.jsx(n.LaptopMinimal,{className:"h-4 w-4"}),width:1600}],w=({currentWidth:t,width:s,icon:l,setIframeWidth:i})=>e.jsx(a.Button,{className:"px-3 py-3",onClick:()=>i(s),variant:s===t?"default":"ghost",children:l}),p=()=>{const[t,s]=o.useState(1200),l=r=>s(r),[i,d]=h.useAtom(c.previewUrlAtom);if(!i)return null;const u=()=>{d("")};return e.jsxs("div",{className:"absolute inset-0 z-[999999] flex h-screen w-screen flex-col overflow-hidden bg-gray-100",children:[e.jsxs("div",{className:"flex h-[50px] items-center justify-center border-b border-gray-200 px-4 shadow-sm",children:[e.jsx("div",{className:"flex items-center justify-center rounded-md border border-gray-300",children:x.map(m,r=>o.createElement(w,{...r,setIframeWidth:l,key:r.title,currentWidth:t}))})," ",e.jsx(c.Tooltip,{content:"Exit Preview",delayDuration:0,children:e.jsx(a.Button,{variant:"destructive",size:"sm",onClick:u,children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M2 3C2 2.44772 2.44772 2 3 2H12C12.5523 2 13 2.44772 13 3V12C13 12.5523 12.5523 13 12 13H3C2.44772 13 2 12.5523 2 12V3ZM12 3H3V12H12V3Z",fill:"currentColor",fillRule:"evenodd","clip-rule":"evenodd"})})})})]}),e.jsx("iframe",{style:{width:`${t}px`,transition:"width 0.3s ease-in-out"},className:"no-scrollbar mx-auto h-full overflow-y-auto border bg-white",src:i})]})};exports.default=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),a=require("@chaibuilder/sdk/ui"),h=require("jotai"),x=require("lodash-es"),n=require("lucide-react"),c=require("./index-BeWL6Sj6.cjs"),m=[{title:"mobile_xs_title",content:"mobile_xs_content",icon:e.jsx(n.Smartphone,{className:"h-4 w-4"}),width:400},{title:"tablet_md_title",content:"tablet_md_content",icon:e.jsx(n.Tablet,{className:"h-4 w-4"}),width:800},{title:"desktop_xl_title",content:"desktop_xl_content",icon:e.jsx(n.Laptop,{className:"h-4 w-4"}),width:1200},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",icon:e.jsx(n.LaptopMinimal,{className:"h-4 w-4"}),width:1600}],w=({currentWidth:t,width:s,icon:l,setIframeWidth:i})=>e.jsx(a.Button,{className:"px-3 py-3",onClick:()=>i(s),variant:s===t?"default":"ghost",children:l}),p=()=>{const[t,s]=o.useState(1200),l=r=>s(r),[i,d]=h.useAtom(c.previewUrlAtom);if(!i)return null;const u=()=>{d("")};return e.jsxs("div",{className:"absolute inset-0 z-[999999] flex h-screen w-screen flex-col overflow-hidden bg-gray-100",children:[e.jsxs("div",{className:"flex h-[50px] items-center justify-center border-b border-gray-200 px-4 shadow-sm",children:[e.jsx("div",{className:"flex items-center justify-center rounded-md border border-gray-300",children:x.map(m,r=>o.createElement(w,{...r,setIframeWidth:l,key:r.title,currentWidth:t}))})," ",e.jsx(c.Tooltip,{content:"Exit Preview",delayDuration:0,children:e.jsx(a.Button,{variant:"destructive",size:"sm",onClick:u,children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M2 3C2 2.44772 2.44772 2 3 2H12C12.5523 2 13 2.44772 13 3V12C13 12.5523 12.5523 13 12 13H3C2.44772 13 2 12.5523 2 12V3ZM12 3H3V12H12V3Z",fill:"currentColor",fillRule:"evenodd","clip-rule":"evenodd"})})})})]}),e.jsx("iframe",{style:{width:`${t}px`,transition:"width 0.3s ease-in-out"},className:"no-scrollbar mx-auto h-full overflow-y-auto border bg-white",src:i})]})};exports.default=p;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Suraj Air",
4
4
  "license": "Private",
5
5
  "homepage": "https://chaibuilder.com",
6
- "version": "0.16.13",
6
+ "version": "0.16.15",
7
7
  "type": "module",
8
8
  "files": [
9
9
  "dist"
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@chaibuilder/runtime": "2.2.0",
61
- "@chaibuilder/sdk": "3.1.19",
61
+ "@chaibuilder/sdk": "3.1.20",
62
62
  "@types/react": "*",
63
63
  "@types/react-dom": "*",
64
64
  "jotai": "2.14.0",
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "@chaibuilder/runtime": "2.2.0",
78
- "@chaibuilder/sdk": "3.1.19",
78
+ "@chaibuilder/sdk": "3.1.20",
79
79
  "@mhsdesign/jit-browser-tailwindcss": "^0.4.2",
80
80
  "@radix-ui/react-collapsible": "^1.1.12",
81
81
  "@radix-ui/react-dialog": "^1.1.15",
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("./index-Bz7smSC0.cjs"),S=require("@chaibuilder/sdk"),N=require("@chaibuilder/sdk/ui"),k=require("lucide-react"),n=require("react"),M=require("sonner"),A=n.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-default-lang-sy6vkQJh.cjs"))),R=n.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-other-lang-BwjSDD3L.cjs"))),z=()=>{const{t:r}=S.useTranslation(),[m,a]=n.useState(""),[t,l]=n.useState([]),[c,i]=n.useState(!1),[u,d]=n.useState(null),[b,f]=n.useState(null),[p,P]=n.useState("google/gemini-2.5-pro"),{selectedLang:g,fallbackLang:q}=S.useLanguages(),v=j.useBuilderFetch(),[w]=j.useSearchParams(),C=w.get("page"),L=(t==null?void 0:t.filter(s=>s.role==="user").length)>=4,y=(t==null?void 0:t.filter(s=>s.role==="user").length)>=10;n.useEffect(()=>{l([])},[g,C]);const h=()=>{l([]),a(""),f(null),d(null),i(!1)},x={t:r,fetch:v,input:m,messages:t,setInput:a,isLoading:c,handleStop:()=>{u&&(u.abort(),d(null)),i(!1),a(""),f(null),l(s=>{const o=s[s.length-1];return o&&o.role==="assistant"&&o.isReasoning&&o.isStreaming?s.slice(0,-1):s}),M.toast.info(r("Generation stopped"))},handleReset:h,setMessages:l,setIsLoading:i,currentBlock:b,fallbackLang:q,abortController:u,setCurrentBlock:f,setAbortController:d,forceNewConversation:y,suggestNewConversation:L,selectedModel:p,onModelChange:P};return e.jsxs(e.Fragment,{children:[c&&e.jsx("div",{className:"fixed inset-0 left-0 top-0 z-40 flex h-screen w-screen flex-col items-center justify-center bg-transparent"}),e.jsxs("div",{className:"flex h-full w-full flex-col bg-white",children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("p",{className:"text-xs text-gray-500",children:r("Your conversation will not be saved")}),(t==null?void 0:t.length)>0&&e.jsx(N.Button,{variant:"outline",size:"icon",onClick:h,className:"h-6 w-6",disabled:c,children:e.jsx(k.Plus,{})})]}),e.jsx(n.Suspense,{fallback:e.jsx("div",{children:"Loading AI Panel..."}),children:g?e.jsx(R,{...x,selectedLang:g}):e.jsx(A,{...x})})]})]})};exports.default=z;
@@ -1,54 +0,0 @@
1
- import { jsxs as m, Fragment as M, jsx as n } from "react/jsx-runtime";
2
- import { q as j, i as y } from "./index-EnM7J19_.js";
3
- import { useTranslation as B, useLanguages as F } from "@chaibuilder/sdk";
4
- import { Button as z } from "@chaibuilder/sdk/ui";
5
- import { Plus as I } from "lucide-react";
6
- import { lazy as x, useState as o, useEffect as R, Suspense as q } from "react";
7
- import { toast as D } from "sonner";
8
- const E = x(() => import("./ai-panel-default-lang-CHOFEwmV.js")), G = x(() => import("./ai-panel-other-lang-B4euTuod.js")), V = () => {
9
- const { t: r } = B(), [b, a] = o(""), [e, l] = o([]), [i, c] = o(!1), [u, f] = o(null), [w, d] = o(null), [C, L] = o("google/gemini-2.5-pro"), { selectedLang: g, fallbackLang: P } = F(), N = j(), [S] = y(), v = S.get("page"), k = (e == null ? void 0 : e.filter((t) => t.role === "user").length) >= 4, A = (e == null ? void 0 : e.filter((t) => t.role === "user").length) >= 10;
10
- R(() => {
11
- l([]);
12
- }, [g, v]);
13
- const h = () => {
14
- l([]), a(""), d(null), f(null), c(!1);
15
- }, p = {
16
- t: r,
17
- fetch: N,
18
- input: b,
19
- messages: e,
20
- setInput: a,
21
- isLoading: i,
22
- handleStop: () => {
23
- u && (u.abort(), f(null)), c(!1), a(""), d(null), l((t) => {
24
- const s = t[t.length - 1];
25
- return s && s.role === "assistant" && s.isReasoning && s.isStreaming ? t.slice(0, -1) : t;
26
- }), D.info(r("Generation stopped"));
27
- },
28
- handleReset: h,
29
- setMessages: l,
30
- setIsLoading: c,
31
- currentBlock: w,
32
- fallbackLang: P,
33
- abortController: u,
34
- setCurrentBlock: d,
35
- setAbortController: f,
36
- forceNewConversation: A,
37
- suggestNewConversation: k,
38
- selectedModel: C,
39
- onModelChange: L
40
- };
41
- return /* @__PURE__ */ m(M, { children: [
42
- i && /* @__PURE__ */ n("div", { className: "fixed inset-0 left-0 top-0 z-40 flex h-screen w-screen flex-col items-center justify-center bg-transparent" }),
43
- /* @__PURE__ */ m("div", { className: "flex h-full w-full flex-col bg-white", children: [
44
- /* @__PURE__ */ m("div", { className: "flex w-full items-center justify-between", children: [
45
- /* @__PURE__ */ n("p", { className: "text-xs text-gray-500", children: r("Your conversation will not be saved") }),
46
- (e == null ? void 0 : e.length) > 0 && /* @__PURE__ */ n(z, { variant: "outline", size: "icon", onClick: h, className: "h-6 w-6", disabled: i, children: /* @__PURE__ */ n(I, {}) })
47
- ] }),
48
- /* @__PURE__ */ n(q, { fallback: /* @__PURE__ */ n("div", { children: "Loading AI Panel..." }), children: g ? /* @__PURE__ */ n(G, { ...p, selectedLang: g }) : /* @__PURE__ */ n(E, { ...p }) })
49
- ] })
50
- ] });
51
- };
52
- export {
53
- V as default
54
- };
@@ -1,313 +0,0 @@
1
- import { jsxs as S, Fragment as F, jsx as m } from "react/jsx-runtime";
2
- import { C as P, a as W, b as O, R as $, c as V, d as q, T as j, M as K, e as _, f as z, h as G, S as U, i as J } from "./selected-block-display-DdW-DWF1.js";
3
- import { useAddBlock as Q, useReplaceBlock as X, useRemoveBlocks as Y, getBlocksFromHTML as L, useSelectedBlock as Z, useSelectedBlockIds as tt, useBlocksHtmlForAi as et } from "@chaibuilder/sdk";
4
- import { Bot as nt } from "lucide-react";
5
- import { useCallback as rt, lazy as st, Fragment as ot, Suspense as it } from "react";
6
- import { toast as at } from "sonner";
7
- const ct = () => {
8
- const { addPredefinedBlock: A } = Q(), x = X(), k = Y(), B = async (r, e) => {
9
- if (!e) return;
10
- const o = L(e);
11
- await A(o, r.parentId, r.position);
12
- }, v = async (r, e) => {
13
- if (!r.blockId || !e) return;
14
- const o = L(e);
15
- await x(r.blockId, o);
16
- }, y = async (r) => {
17
- !r.ids || r.ids.length === 0 || await k(r.ids);
18
- };
19
- let u = null;
20
- const N = (r, e) => {
21
- const o = document.getElementById("canvas-iframe");
22
- if (!o)
23
- return null;
24
- const a = o == null ? void 0 : o.contentDocument;
25
- if (!a)
26
- return null;
27
- a.querySelectorAll("[data-stream-canvas]").forEach((f) => f.remove());
28
- let n = null;
29
- if (r && r !== "undefined" && (n = a.querySelector(`[data-block-id="${r}"]`)), n || (n = a.body), !n)
30
- return null;
31
- if (u = a.createElement("div"), u.setAttribute("data-stream-canvas", "true"), e !== void 0 && e >= 0 && n.children) {
32
- const f = Math.min(e, n.children.length);
33
- f < n.children.length ? n.insertBefore(u, n.children[f]) : n.appendChild(u);
34
- } else
35
- n.appendChild(u);
36
- return u;
37
- }, C = (r) => {
38
- var n;
39
- const e = document.getElementById("canvas-iframe");
40
- if (!e)
41
- return null;
42
- const o = e == null ? void 0 : e.contentDocument;
43
- if (!o)
44
- return null;
45
- o.querySelectorAll("[data-stream-canvas]").forEach((f) => f.remove());
46
- const d = o.querySelector(`[data-block-id="${r}"]`);
47
- return d ? (u = o.createElement("div"), u.setAttribute("data-stream-canvas", "true"), (n = d.parentNode) == null || n.insertBefore(u, d.nextSibling), d.style.display = "none", u) : null;
48
- }, w = (r, e, o) => {
49
- const a = N(e, o);
50
- if (a) {
51
- a.innerHTML = r;
52
- const d = a.getBoundingClientRect(), n = document.getElementById("canvas-iframe"), f = n == null ? void 0 : n.contentWindow;
53
- f && (d.top >= 0 && d.bottom <= f.innerHeight || a.scrollIntoView({ behavior: "smooth", block: "nearest" }));
54
- }
55
- }, T = (r, e) => {
56
- const o = C(e);
57
- o && (o.innerHTML = r);
58
- }, E = (r) => {
59
- const e = r.match(/^--ACTION=(.+)--$/);
60
- if (!e) return null;
61
- let a = e[1].replace(/--/g, "").split("|");
62
- const n = { type: a[0] };
63
- return a.forEach((f) => {
64
- const t = f.trim();
65
- if (t.startsWith("PARENT=")) {
66
- const s = t.substring(7);
67
- n.parentId = s === "undefined" ? void 0 : s;
68
- } else t.startsWith("POS=") ? n.position = parseInt(t.substring(4)) : t.startsWith("ID=") ? n.blockId = t.substring(3) : t.startsWith("IDS=") && (n.ids = t.substring(4).split(",").map((s) => s.trim()));
69
- }), n;
70
- };
71
- return rt(
72
- async (r, e) => {
73
- const o = new TextDecoder();
74
- let a = "", d = "", n = !1, f = null;
75
- const t = {
76
- isInAction: !1,
77
- currentAction: null,
78
- htmlBuffer: "",
79
- isCapturingHtml: !1
80
- }, s = async (g) => {
81
- const i = g.trim();
82
- if (i === "--START--") {
83
- n = !0;
84
- return;
85
- }
86
- if (n) {
87
- if (i === "--END--") {
88
- t.currentAction && (t.htmlBuffer || t.currentAction.type === "REMOVE") && await I(t.currentAction, t.htmlBuffer), u && (u.remove(), u = null);
89
- return;
90
- }
91
- if (i.startsWith("--THINKING=")) {
92
- const c = i.substring(11);
93
- e((l) => {
94
- const h = [...l], p = h[h.length - 1];
95
- if (p && p.role === "assistant" && p.isReasoning)
96
- p.content = c, p.isStreaming = !1;
97
- else {
98
- const M = {
99
- id: Date.now().toString(),
100
- role: "assistant",
101
- content: c,
102
- isReasoning: !0,
103
- isStreaming: !1
104
- };
105
- h.push(M);
106
- }
107
- return h;
108
- });
109
- return;
110
- }
111
- if (i.startsWith("--TASK=")) {
112
- const c = i.substring(7), l = `task-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, h = {
113
- id: l,
114
- role: "assistant",
115
- content: c.replace(/--$/, ""),
116
- isTask: !0,
117
- isTaskLoading: !0,
118
- isTaskCompleted: !1
119
- };
120
- f = l, e((p) => [...p, h]);
121
- return;
122
- }
123
- if (i.startsWith("--MSG=")) {
124
- const c = i.substring(6), l = {
125
- id: Date.now().toString(),
126
- role: "assistant",
127
- content: c.replace(/--$/g, ""),
128
- isReasoning: !1,
129
- isStreaming: !1
130
- };
131
- e((h) => [...h, l]);
132
- return;
133
- }
134
- if (i.startsWith("--ACTION=")) {
135
- t.currentAction && (t.htmlBuffer || t.currentAction.type === "REMOVE") && await I(t.currentAction, t.htmlBuffer), t.currentAction = E(i), t.htmlBuffer = "", t.isInAction = !0;
136
- return;
137
- }
138
- if (i === "--ENDACTION--") {
139
- t.currentAction && (t.htmlBuffer || t.currentAction.type === "REMOVE") && await I(t.currentAction, t.htmlBuffer), f && (e((c) => c.map((l) => l.isTask ? { ...l, isTaskCompleted: !0 } : l)), f = null), t.currentAction = null, t.htmlBuffer = "", t.isInAction = !1;
140
- return;
141
- }
142
- if (i === "--HTML--") {
143
- t.isCapturingHtml = !0;
144
- return;
145
- }
146
- if (i === "--ENDHTML--") {
147
- t.isCapturingHtml = !1;
148
- return;
149
- }
150
- if (i.startsWith("--HTML--") && i.includes("--ENDHTML--")) {
151
- const c = i.match(/^--HTML--(.+?)--ENDHTML--$/);
152
- if (c && t.currentAction) {
153
- const l = c[1];
154
- t.htmlBuffer += l, t.currentAction.type === "ADD" ? w(t.htmlBuffer, t.currentAction.parentId, t.currentAction.position) : t.currentAction.type === "EDIT" && t.currentAction.blockId && T(t.htmlBuffer, t.currentAction.blockId);
155
- }
156
- return;
157
- }
158
- t.isCapturingHtml && t.currentAction && (t.htmlBuffer += g + `
159
- `, t.currentAction.type === "ADD" ? w(t.htmlBuffer, t.currentAction.parentId, t.currentAction.position) : t.currentAction.type === "EDIT" && t.currentAction.blockId && T(t.htmlBuffer, t.currentAction.blockId));
160
- }
161
- }, I = async (g, i) => {
162
- try {
163
- switch (g.type) {
164
- case "ADD":
165
- await B(g, i);
166
- break;
167
- case "EDIT":
168
- await v(g, i);
169
- break;
170
- case "REMOVE":
171
- await y(g);
172
- break;
173
- }
174
- e((c) => c.filter((l) => !l.isTask));
175
- } catch (c) {
176
- console.log(c);
177
- }
178
- };
179
- try {
180
- for (; ; ) {
181
- const { done: g, value: i } = await r.read();
182
- if (g) break;
183
- const c = o.decode(i, { stream: !0 });
184
- a += c, d += c;
185
- const l = d.split(`
186
- `);
187
- d = l.pop() || "";
188
- for (const h of l)
189
- await s(h);
190
- }
191
- d && await s(d);
192
- } catch (g) {
193
- console.log(g);
194
- }
195
- },
196
- [k]
197
- );
198
- }, lt = st(() => import("./ai-prompt-input-B_NRADBT.js")), pt = ({
199
- t: A,
200
- fetch: x,
201
- input: k,
202
- messages: B,
203
- setInput: v,
204
- isLoading: y,
205
- setMessages: u,
206
- handleStop: N,
207
- setIsLoading: C,
208
- currentBlock: w,
209
- fallbackLang: T,
210
- setCurrentBlock: E,
211
- setAbortController: r,
212
- selectedModel: e = "google/gemini-2.5-pro",
213
- onModelChange: o
214
- }) => {
215
- const a = Z(), [, d] = tt(), n = et(), f = ct(), t = async (s, I, g, i) => {
216
- var M;
217
- if (!s || y) return;
218
- E(a);
219
- const c = n(a ? { blockId: a._id, additionalCoreBlocks: ["Icon"] } : { additionalCoreBlocks: ["Icon"] });
220
- if (a && !c) {
221
- at.error(A("Something went wrong. Please try again."));
222
- return;
223
- }
224
- const l = {
225
- id: Date.now().toString(),
226
- role: "user",
227
- content: J({
228
- language: T,
229
- userInput: I || s,
230
- currentHtml: c
231
- }),
232
- userMessage: s
233
- }, h = {
234
- id: (Date.now() + 1).toString(),
235
- role: "assistant",
236
- content: "",
237
- isReasoning: !0,
238
- isStreaming: !0
239
- };
240
- u((b) => [...b, l, h]), C(!0);
241
- const p = new AbortController();
242
- r(p);
243
- try {
244
- const b = {
245
- messages: [l].map((H) => ({
246
- role: H.role,
247
- content: H.content
248
- })),
249
- model: i || e
250
- };
251
- g && (b.image = g);
252
- const D = await x({ body: { action: "ASK_AI", data: b }, streamResponse: !0 });
253
- if (!D.ok)
254
- throw new Error(A("Failed to get AI response"));
255
- const R = (M = D.body) == null ? void 0 : M.getReader();
256
- if (!R) throw new Error(A("Response body is not readable"));
257
- await f(R, u);
258
- } catch (b) {
259
- if (b.name !== "AbortError") {
260
- const D = {
261
- id: (Date.now() + 1).toString(),
262
- role: "assistant",
263
- content: A("Sorry, I encountered an error. Please try again.")
264
- };
265
- u((R) => [...R, D]);
266
- }
267
- } finally {
268
- v(""), C(!1), E(null), r(null);
269
- }
270
- };
271
- return /* @__PURE__ */ S(F, { children: [
272
- /* @__PURE__ */ S(P, { className: "no-scrollbar", children: [
273
- /* @__PURE__ */ S(W, { className: "gap-2 px-0", children: [
274
- B.length === 0 && /* @__PURE__ */ m(
275
- O,
276
- {
277
- icon: /* @__PURE__ */ m(nt, { size: 48, className: "text-gray-300" }),
278
- title: "Start a conversation",
279
- description: A("Start a conversation with the AI assistant to add/edit current page")
280
- }
281
- ),
282
- B.map(
283
- (s) => s.role !== "system" && /* @__PURE__ */ m(ot, { children: s.isReasoning ? /* @__PURE__ */ S($, { isStreaming: s.isStreaming, defaultOpen: !0, children: [
284
- /* @__PURE__ */ m(V, { className: "text-xs [&_p]:text-muted-foreground" }),
285
- /* @__PURE__ */ m(q, { className: "p-0 text-xs", children: s.content })
286
- ] }) : s.isTask && !s.isTaskCompleted ? /* @__PURE__ */ m(j, { content: s.content, isLoading: s.isTaskLoading }) : /* @__PURE__ */ m(K, { from: s.role, children: /* @__PURE__ */ m(_, { className: "p-0", children: s.role === "assistant" ? /* @__PURE__ */ m(z, { className: "p-0 text-xs", children: s.content }) : /* @__PURE__ */ m("div", { className: "p-0 text-xs", children: s.userMessage || s.content }) }) }) }, s.id)
287
- )
288
- ] }),
289
- /* @__PURE__ */ m(G, {})
290
- ] }),
291
- /* @__PURE__ */ S("div", { className: "border-gray-200 pb-2", children: [
292
- /* @__PURE__ */ m(U, { onRemove: () => d([]), isLoading: y }),
293
- /* @__PURE__ */ m(it, { fallback: /* @__PURE__ */ m("div", { children: "Loading..." }), children: /* @__PURE__ */ m(
294
- lt,
295
- {
296
- input: k,
297
- setInput: v,
298
- onSend: t,
299
- onStop: N,
300
- isLoading: y,
301
- selectedLang: "",
302
- currentBlock: a || w,
303
- disabled: (k == null ? void 0 : k.length) === 0,
304
- selectedModel: e,
305
- onModelChange: o
306
- }
307
- ) })
308
- ] })
309
- ] });
310
- };
311
- export {
312
- pt as default
313
- };
@@ -1,3 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),h=require("./selected-block-display-BEbuJn0l.cjs"),k=require("@chaibuilder/sdk"),P=require("lucide-react"),j=require("react"),q=require("sonner"),F=()=>{const{addPredefinedBlock:b}=k.useAddBlock(),H=k.useReplaceBlock(),y=k.useRemoveBlocks(),v=async(r,e)=>{if(!e)return;const o=k.getBlocksFromHTML(e);await b(o,r.parentId,r.position)},x=async(r,e)=>{if(!r.blockId||!e)return;const o=k.getBlocksFromHTML(e);await H(r.blockId,o)},I=async r=>{!r.ids||r.ids.length===0||await y(r.ids)};let d=null;const N=(r,e)=>{const o=document.getElementById("canvas-iframe");if(!o)return null;const a=o==null?void 0:o.contentDocument;if(!a)return null;a.querySelectorAll("[data-stream-canvas]").forEach(m=>m.remove());let n=null;if(r&&r!=="undefined"&&(n=a.querySelector(`[data-block-id="${r}"]`)),n||(n=a.body),!n)return null;if(d=a.createElement("div"),d.setAttribute("data-stream-canvas","true"),e!==void 0&&e>=0&&n.children){const m=Math.min(e,n.children.length);m<n.children.length?n.insertBefore(d,n.children[m]):n.appendChild(d)}else n.appendChild(d);return d},T=r=>{var n;const e=document.getElementById("canvas-iframe");if(!e)return null;const o=e==null?void 0:e.contentDocument;if(!o)return null;o.querySelectorAll("[data-stream-canvas]").forEach(m=>m.remove());const f=o.querySelector(`[data-block-id="${r}"]`);return f?(d=o.createElement("div"),d.setAttribute("data-stream-canvas","true"),(n=f.parentNode)==null||n.insertBefore(d,f.nextSibling),f.style.display="none",d):null},w=(r,e,o)=>{const a=N(e,o);if(a){a.innerHTML=r;const f=a.getBoundingClientRect(),n=document.getElementById("canvas-iframe"),m=n==null?void 0:n.contentWindow;m&&(f.top>=0&&f.bottom<=m.innerHeight||a.scrollIntoView({behavior:"smooth",block:"nearest"}))}},C=(r,e)=>{const o=T(e);o&&(o.innerHTML=r)},E=r=>{const e=r.match(/^--ACTION=(.+)--$/);if(!e)return null;let a=e[1].replace(/--/g,"").split("|");const n={type:a[0]};return a.forEach(m=>{const t=m.trim();if(t.startsWith("PARENT=")){const s=t.substring(7);n.parentId=s==="undefined"?void 0:s}else t.startsWith("POS=")?n.position=parseInt(t.substring(4)):t.startsWith("ID=")?n.blockId=t.substring(3):t.startsWith("IDS=")&&(n.ids=t.substring(4).split(",").map(s=>s.trim()))}),n};return j.useCallback(async(r,e)=>{const o=new TextDecoder;let a="",f="",n=!1,m=null;const t={isInAction:!1,currentAction:null,htmlBuffer:"",isCapturingHtml:!1},s=async g=>{const i=g.trim();if(i==="--START--"){n=!0;return}if(n){if(i==="--END--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await S(t.currentAction,t.htmlBuffer),d&&(d.remove(),d=null);return}if(i.startsWith("--THINKING=")){const c=i.substring(11);e(u=>{const p=[...u],A=p[p.length-1];if(A&&A.role==="assistant"&&A.isReasoning)A.content=c,A.isStreaming=!1;else{const M={id:Date.now().toString(),role:"assistant",content:c,isReasoning:!0,isStreaming:!1};p.push(M)}return p});return}if(i.startsWith("--TASK=")){const c=i.substring(7),u=`task-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,p={id:u,role:"assistant",content:c.replace(/--$/,""),isTask:!0,isTaskLoading:!0,isTaskCompleted:!1};m=u,e(A=>[...A,p]);return}if(i.startsWith("--MSG=")){const c=i.substring(6),u={id:Date.now().toString(),role:"assistant",content:c.replace(/--$/g,""),isReasoning:!1,isStreaming:!1};e(p=>[...p,u]);return}if(i.startsWith("--ACTION=")){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await S(t.currentAction,t.htmlBuffer),t.currentAction=E(i),t.htmlBuffer="",t.isInAction=!0;return}if(i==="--ENDACTION--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await S(t.currentAction,t.htmlBuffer),m&&(e(c=>c.map(u=>u.isTask?{...u,isTaskCompleted:!0}:u)),m=null),t.currentAction=null,t.htmlBuffer="",t.isInAction=!1;return}if(i==="--HTML--"){t.isCapturingHtml=!0;return}if(i==="--ENDHTML--"){t.isCapturingHtml=!1;return}if(i.startsWith("--HTML--")&&i.includes("--ENDHTML--")){const c=i.match(/^--HTML--(.+?)--ENDHTML--$/);if(c&&t.currentAction){const u=c[1];t.htmlBuffer+=u,t.currentAction.type==="ADD"?w(t.htmlBuffer,t.currentAction.parentId,t.currentAction.position):t.currentAction.type==="EDIT"&&t.currentAction.blockId&&C(t.htmlBuffer,t.currentAction.blockId)}return}t.isCapturingHtml&&t.currentAction&&(t.htmlBuffer+=g+`
2
- `,t.currentAction.type==="ADD"?w(t.htmlBuffer,t.currentAction.parentId,t.currentAction.position):t.currentAction.type==="EDIT"&&t.currentAction.blockId&&C(t.htmlBuffer,t.currentAction.blockId))}},S=async(g,i)=>{try{switch(g.type){case"ADD":await v(g,i);break;case"EDIT":await x(g,i);break;case"REMOVE":await I(g);break}e(c=>c.filter(u=>!u.isTask))}catch(c){console.log(c)}};try{for(;;){const{done:g,value:i}=await r.read();if(g)break;const c=o.decode(i,{stream:!0});a+=c,f+=c;const u=f.split(`
3
- `);f=u.pop()||"";for(const p of u)await s(p)}f&&await s(f)}catch(g){console.log(g)}},[y])},O=j.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-DcyVXcLG.cjs"))),W=({t:b,fetch:H,input:y,messages:v,setInput:x,isLoading:I,setMessages:d,handleStop:N,setIsLoading:T,currentBlock:w,fallbackLang:C,setCurrentBlock:E,setAbortController:r,selectedModel:e="google/gemini-2.5-pro",onModelChange:o})=>{const a=k.useSelectedBlock(),[,f]=k.useSelectedBlockIds(),n=k.useBlocksHtmlForAi(),m=F(),t=async(s,S,g,i)=>{var M;if(!s||I)return;E(a);const c=n(a?{blockId:a._id,additionalCoreBlocks:["Icon"]}:{additionalCoreBlocks:["Icon"]});if(a&&!c){q.toast.error(b("Something went wrong. Please try again."));return}const u={id:Date.now().toString(),role:"user",content:h.getUserPrompt({language:C,userInput:S||s,currentHtml:c}),userMessage:s},p={id:(Date.now()+1).toString(),role:"assistant",content:"",isReasoning:!0,isStreaming:!0};d(B=>[...B,u,p]),T(!0);const A=new AbortController;r(A);try{const B={messages:[u].map(L=>({role:L.role,content:L.content})),model:i||e};g&&(B.image=g);const D=await H({body:{action:"ASK_AI",data:B},streamResponse:!0});if(!D.ok)throw new Error(b("Failed to get AI response"));const R=(M=D.body)==null?void 0:M.getReader();if(!R)throw new Error(b("Response body is not readable"));await m(R,d)}catch(B){if(B.name!=="AbortError"){const D={id:(Date.now()+1).toString(),role:"assistant",content:b("Sorry, I encountered an error. Please try again.")};d(R=>[...R,D])}}finally{x(""),T(!1),E(null),r(null)}};return l.jsxs(l.Fragment,{children:[l.jsxs(h.Conversation,{className:"no-scrollbar",children:[l.jsxs(h.ConversationContent,{className:"gap-2 px-0",children:[v.length===0&&l.jsx(h.ConversationEmptyState,{icon:l.jsx(P.Bot,{size:48,className:"text-gray-300"}),title:"Start a conversation",description:b("Start a conversation with the AI assistant to add/edit current page")}),v.map(s=>s.role!=="system"&&l.jsx(j.Fragment,{children:s.isReasoning?l.jsxs(h.Reasoning,{isStreaming:s.isStreaming,defaultOpen:!0,children:[l.jsx(h.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),l.jsx(h.ReasoningContent,{className:"p-0 text-xs",children:s.content})]}):s.isTask&&!s.isTaskCompleted?l.jsx(h.TaskMessage,{content:s.content,isLoading:s.isTaskLoading}):l.jsx(h.Message,{from:s.role,children:l.jsx(h.MessageContent,{className:"p-0",children:s.role==="assistant"?l.jsx(h.MessageResponse,{className:"p-0 text-xs",children:s.content}):l.jsx("div",{className:"p-0 text-xs",children:s.userMessage||s.content})})})},s.id))]}),l.jsx(h.ConversationScrollButton,{})]}),l.jsxs("div",{className:"border-gray-200 pb-2",children:[l.jsx(h.SelectedBlockDisplay,{onRemove:()=>f([]),isLoading:I}),l.jsx(j.Suspense,{fallback:l.jsx("div",{children:"Loading..."}),children:l.jsx(O,{input:y,setInput:x,onSend:t,onStop:N,isLoading:I,selectedLang:"",currentBlock:a||w,disabled:(y==null?void 0:y.length)===0,selectedModel:e,onModelChange:o})})]})]})};exports.default=W;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./selected-block-display-BEbuJn0l.cjs"),a=require("@chaibuilder/sdk"),G=require("lucide-react"),o=require("react"),H=o.lazy(()=>Promise.resolve().then(()=>require("./ai-translation-prompt-Ip7w2_Ey.cjs"))),Q=o.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-DcyVXcLG.cjs"))),X=({fetch:v,input:c,messages:u,setInput:j,isLoading:i,handleStop:A,setMessages:y,setIsLoading:h,selectedLang:l,currentBlock:P,fallbackLang:q,abortController:x,setAbortController:E,setCurrentBlock:k,selectedModel:S="google/gemini-2.5-pro",onModelChange:M})=>{const{t:n}=a.useTranslation(),O=o.useRef(null),d=a.useSelectedBlock(),[,C]=a.useSelectedBlockIds(),T=a.useI18nBlocks(),D=a.useStreamMultipleBlocksProps(),I=()=>{var t;(t=O.current)==null||t.scrollIntoView({behavior:"smooth"})};o.useEffect(()=>{I()},[u,i]);const f=async(t,m,F)=>{var b;d&&k(d);const p=(t==null?void 0:t.toLowerCase())==="translate",R={id:Date.now().toString(),role:"user",content:s.getTranslationUserPrompt({fallbackLang:q,userInput:m||t,language:l,blocks:p?T():T(l)}),userMessage:m||t||n("Translate the content")},_={id:(Date.now()+1).toString(),role:"assistant",content:"Thinking...",isReasoning:!0,isStreaming:!0};h(!0);const z=new AbortController;E(z),y(w=>[...w,R,_]),h(!0);try{const N=await v({body:{action:"ASK_AI",data:{messages:[R],initiator:p?"TRANSLATE_CONTENT":"UPDATE_CONTENT",model:F||S}},streamResponse:!0});if(!N.ok)throw new Error(n("Failed to get AI response"));const B=(b=N.body)==null?void 0:b.getReader(),U=new TextDecoder;let r="";if(!B)throw new Error(n("Response body is not readable"));for(;;){const{done:K,value:V}=await B.read();if(K)break;const W=U.decode(V,{stream:!0});r+=W,y(g=>(g[g.length-1].content=r,[...g]))}const J=JSON.parse(r==null?void 0:r.replace("```json","").replace("```",""));D(J)}catch{x==null||x.abort()}finally{h(!1),j(""),k(null)}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx(o.Suspense,{fallback:e.jsx("div",{children:n("Loading...")}),children:e.jsx(H,{isLoading:i,selectedBlock:d,selectedLang:l,onClick:f})})}),e.jsx(s.Conversation,{children:e.jsxs(s.ConversationContent,{className:"gap-4 px-0",children:[u.length===0&&e.jsx(s.ConversationEmptyState,{icon:e.jsx(G.Bot,{size:48,className:"text-gray-300"}),title:n("Start a conversation with the AI assistant to translate/edit your content"),description:n("Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language.")}),u.map(t=>t.role!=="system"&&e.jsx(o.Fragment,{children:t.isReasoning?e.jsxs(s.Reasoning,{isStreaming:t.isStreaming,defaultOpen:!0,children:[e.jsx(s.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),e.jsx(s.ReasoningContent,{className:"p-0 text-xs",children:t.content})]}):t.isTask?e.jsx(s.TaskMessage,{content:t.content,isLoading:t.isTaskLoading}):e.jsx(s.Message,{from:t.role,children:e.jsx(s.MessageContent,{className:"p-0",children:t.role==="assistant"?e.jsx(s.MessageResponse,{className:"p-0 text-xs",children:t.content}):e.jsx("div",{className:"p-0 text-xs",children:t.userMessage||t.content})})})},t.id))]})}),e.jsxs("div",{className:"border-gray-200 pb-2",children:[e.jsx(s.SelectedBlockDisplay,{onRemove:()=>C([]),isLoading:i}),e.jsx(o.Suspense,{fallback:e.jsx("div",{children:n("Loading...")}),children:e.jsx(Q,{input:c,setInput:j,onSend:f,onStop:A,isLoading:i,selectedLang:l,currentBlock:d||P,disabled:(c==null?void 0:c.length)===0,selectedModel:S,onModelChange:M})})]})]})};exports.default=X;