@chaibuilder/pages 0.16.1 → 0.16.3

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 (86) hide show
  1. package/dist/{2AITGKQY-CD9A6oc6.cjs → 2AITGKQY-8xBkB8Pv.cjs} +1 -1
  2. package/dist/{2AITGKQY-Z1XcJ6Q7.js → 2AITGKQY-DI5Po2Nc.js} +2 -2
  3. package/dist/{NCMVHL6D-CkpM-3og.cjs → NCMVHL6D-B4xqJIpr.cjs} +1 -1
  4. package/dist/{NCMVHL6D-DoK0XoIo.js → NCMVHL6D-kHUQxG8D.js} +2 -2
  5. package/dist/{ZDWCUMSJ-D32swpGV.cjs → ZDWCUMSJ-CjlhoCfQ.cjs} +1 -1
  6. package/dist/{ZDWCUMSJ-hGXNxbOK.js → ZDWCUMSJ-DRgY2Er1.js} +1 -1
  7. package/dist/{add-new-language-page-BZPoqdX-.js → add-new-language-page-DSB8ohdj.js} +2 -2
  8. package/dist/{add-new-language-page-D65TpIwK.cjs → add-new-language-page-noBKABVx.cjs} +1 -1
  9. package/dist/{add-new-page-DK25Y0zS.js → add-new-page-BYkFbQvH.js} +1 -1
  10. package/dist/{add-new-page-CQ0aj4RJ.cjs → add-new-page-CByS9KqS.cjs} +1 -1
  11. package/dist/ai-panel-content-BBnzp4fO.cjs +1 -0
  12. package/dist/ai-panel-content-DET3HjIR.js +54 -0
  13. package/dist/ai-panel-default-lang-BYfcAA8u.js +178 -0
  14. package/dist/ai-panel-default-lang-D-RS6z5I.cjs +1 -0
  15. package/dist/ai-panel-other-lang-BoD4FsoG.cjs +1 -0
  16. package/dist/{ai-panel-other-lang-CCyiE6ha.js → ai-panel-other-lang-TVjNYPRK.js} +76 -71
  17. package/dist/{ai-panel-quick-prompts-DeS7L1f0.cjs → ai-panel-quick-prompts-BGBdrdP7.cjs} +1 -1
  18. package/dist/{ai-panel-quick-prompts-Ds0Ndz7g.js → ai-panel-quick-prompts-BPrA9nvg.js} +1 -1
  19. package/dist/ai-prompt-input-DB1FpA_q.cjs +1 -0
  20. package/dist/ai-prompt-input-qegCvwnu.js +222 -0
  21. package/dist/{ai-translation-prompt-BiJ5B_an.js → ai-translation-prompt--HB1UAhC.js} +1 -1
  22. package/dist/{ai-translation-prompt-BUFjo_om.cjs → ai-translation-prompt-Bj-AM4xK.cjs} +1 -1
  23. package/dist/{delete-page-B95T2Prd.js → delete-page-C7xfkDN5.js} +1 -1
  24. package/dist/{delete-page-BSop1jNg.cjs → delete-page-DJLNpUxo.cjs} +1 -1
  25. package/dist/{digital-asset-manager-Bn58WzM6.cjs → digital-asset-manager-BblMbig0.cjs} +1 -1
  26. package/dist/{digital-asset-manager-BQNSwfKs.js → digital-asset-manager-INrgGoC0.js} +1 -1
  27. package/dist/{duplicate-page-CrzzObAj.js → duplicate-page-B8k4yZxa.js} +2 -2
  28. package/dist/{duplicate-page-BLxkSiug.cjs → duplicate-page-C9XewuHN.cjs} +1 -1
  29. package/dist/{dynamic-page-selector-D6wQnNfH.js → dynamic-page-selector-C7Vos5-l.js} +1 -1
  30. package/dist/{dynamic-page-selector-D8UZ63LW.cjs → dynamic-page-selector-CYYnEngT.cjs} +1 -1
  31. package/dist/index-CyHmr87X.cjs +5 -0
  32. package/dist/{index-yhKyIbgs.js → index-DRQI9rlW.js} +461 -452
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/{json-diff-viewer-ISJS7lHK.js → json-diff-viewer-8vUwU0Sk.js} +1 -1
  36. package/dist/{json-diff-viewer-ZeJ3Rp2y.cjs → json-diff-viewer-DVskWjAL.cjs} +1 -1
  37. package/dist/{lang-panel-Bj11IL7k.js → lang-panel-B8SeKnwN.js} +2 -2
  38. package/dist/{lang-panel-DqN_J3vz.cjs → lang-panel-BeyCHr4u.cjs} +1 -1
  39. package/dist/{mark-as-template-CmCCMaQg.js → mark-as-template-CpNHtyfB.js} +1 -1
  40. package/dist/{mark-as-template-CcwAAdrd.cjs → mark-as-template-DTEF_hyN.cjs} +1 -1
  41. package/dist/{no-language-page-content-Cme-zo4R.js → no-language-page-content-BPiFDGJr.js} +1 -1
  42. package/dist/{no-language-page-content-BXm1k1Aa.cjs → no-language-page-content-DnAP2ICP.cjs} +1 -1
  43. package/dist/{page-creator-ByhjXyHP.cjs → page-creator-BawPgFIv.cjs} +1 -1
  44. package/dist/{page-creator-Zbv4d4H8.js → page-creator-BiDN-rLc.js} +2 -2
  45. package/dist/{page-lock-request-DDQJb8IA.js → page-lock-request-BVYclE6H.js} +1 -1
  46. package/dist/{page-lock-request-Cln-EE6Z.cjs → page-lock-request-wIw-W5qT.cjs} +1 -1
  47. package/dist/{page-locked-by-dialog-Csn56a3n.js → page-locked-by-dialog-CuHvd48D.js} +1 -1
  48. package/dist/{page-locked-by-dialog-BIXYITEu.cjs → page-locked-by-dialog-jZDY0omZ.cjs} +1 -1
  49. package/dist/{page-manager-new-BJaTBpih.cjs → page-manager-new-BmZlPcpL.cjs} +1 -1
  50. package/dist/{page-manager-new-BrRxZDfT.js → page-manager-new-kMwd9hkH.js} +2 -2
  51. package/dist/{page-manager-search-and-filter-_Hvk3bU3.js → page-manager-search-and-filter-BU-1wFbM.js} +1 -1
  52. package/dist/{page-manager-search-and-filter-Bk3PUjha.cjs → page-manager-search-and-filter-DMauRN5Y.cjs} +1 -1
  53. package/dist/{page-revisions-content-C_Ha3tFu.cjs → page-revisions-content-BH0Xy_k9.cjs} +1 -1
  54. package/dist/{page-revisions-content-B6fRCBX_.js → page-revisions-content-c32By7XR.js} +2 -2
  55. package/dist/{prompt-helper-DgI1lgGV.cjs → prompt-helper-BLBZjr5q.cjs} +1 -1
  56. package/dist/{prompt-helper-Csgu8Rfb.js → prompt-helper-Bh7WyDYo.js} +1 -1
  57. package/dist/{publish-pages-content-DQDNxwHD.cjs → publish-pages-content-B5UqPZy0.cjs} +1 -1
  58. package/dist/{publish-pages-content-CFEIxKQD.js → publish-pages-content-BB6l92oG.js} +2 -2
  59. package/dist/{save-to-lib-Bl22umTa.cjs → save-to-lib-DM1MzZTb.cjs} +1 -1
  60. package/dist/{save-to-lib-YyYkF6c6.js → save-to-lib-NvQZll63.js} +1 -1
  61. package/dist/{seo-panel-BZlMea1L.js → seo-panel-BsMBb5Ep.js} +1 -1
  62. package/dist/{seo-panel-BhxikAkG.cjs → seo-panel-C20m5SFc.cjs} +1 -1
  63. package/dist/server.cjs +8 -8
  64. package/dist/server.d.ts +1 -0
  65. package/dist/server.js +141 -141
  66. package/dist/{shared-json-ld-E4Ckwlbr.js → shared-json-ld-BVqIgANo.js} +1 -1
  67. package/dist/{shared-json-ld-BfkH76U3.cjs → shared-json-ld-CfWO90c0.cjs} +1 -1
  68. package/dist/{slug-input--VmQG0S1.cjs → slug-input-BewLv-d8.cjs} +1 -1
  69. package/dist/{slug-input-CKKkqGj4.js → slug-input-RCGUFL2T.js} +1 -1
  70. package/dist/{theme-panel-footer-CagxEZEO.cjs → theme-panel-footer-8oSQtfZ5.cjs} +1 -1
  71. package/dist/{theme-panel-footer-2ERfMsET.js → theme-panel-footer-BJB36k8A.js} +1 -1
  72. package/dist/{unmark-as-template-BJ5CTNAe.js → unmark-as-template-CGZ0CCI2.js} +1 -1
  73. package/dist/{unmark-as-template-CeWpo9wD.cjs → unmark-as-template-DLNmyum3.cjs} +1 -1
  74. package/dist/{unpublish-page-DmZSVxFj.cjs → unpublish-page-B_xQPGsZ.cjs} +1 -1
  75. package/dist/{unpublish-page-DvOWVBIf.js → unpublish-page-CEtpcrvc.js} +1 -1
  76. package/dist/{web-preview-DTkIggV7.js → web-preview-CCGkTRU3.js} +1 -1
  77. package/dist/{web-preview-DlSKpPUZ.cjs → web-preview-Cifi0bwK.cjs} +1 -1
  78. package/package.json +12 -12
  79. package/dist/ai-panel-content-BSGJqnTM.cjs +0 -1
  80. package/dist/ai-panel-content-DYRZnMgV.js +0 -52
  81. package/dist/ai-panel-default-lang-BOZrL5Xe.cjs +0 -1
  82. package/dist/ai-panel-default-lang-DZUqC79y.js +0 -173
  83. package/dist/ai-panel-other-lang-CNtlT5dM.cjs +0 -1
  84. package/dist/ai-prompt-input-Ch_PLEPN.js +0 -133
  85. package/dist/ai-prompt-input-Zg6lN1Lo.cjs +0 -1
  86. package/dist/index-W0r4o5Ro.cjs +0 -5
@@ -1,7 +1,7 @@
1
1
  var xs = Object.defineProperty;
2
2
  var ws = (e, t, n) => t in e ? xs(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var _e = (e, t, n) => ws(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { w as Vn, x as jn, y as K, z as sr, C as H, v as y, D as W, E as oe, S as R, s as O, F as $e, G as Ce, H as G, I as A, J as He, K as ft, M as ve, P as Ro, N as V, O as $s, Q as P, R as wt, U as un, V as k, W as T, X as Cs, Y as Kt, Z as Ss, _ as ks, $ as Cn, a0 as Es, a1 as Ds, a2 as Ms, a3 as Nt, a4 as As, a5 as Ts, a6 as Fs, a7 as ar, a8 as Hr, a9 as qs, aa as _t, ab as Ko, ac as Ur, ad as Is, ae as Os, af as Kn, ag as Ls, ah as Ps, ai as _s } from "./index-yhKyIbgs.js";
4
+ import { w as Vn, x as jn, y as K, z as sr, C as H, v as y, D as W, E as oe, S as R, s as O, F as $e, G as Ce, H as G, I as A, J as He, K as ft, M as ve, P as Ro, N as V, O as $s, Q as P, R as wt, U as un, V as k, W as T, X as Cs, Y as Kt, Z as Ss, _ as ks, $ as Cn, a0 as Es, a1 as Ds, a2 as Ms, a3 as Nt, a4 as As, a5 as Ts, a6 as Fs, a7 as ar, a8 as Hr, a9 as qs, aa as _t, ab as Ko, ac as Ur, ad as Is, ae as Os, af as Kn, ag as Ls, ah as Ps, ai as _s } from "./index-DRQI9rlW.js";
5
5
  var zs = (e) => e != null, Rs = (e) => e.filter(zs);
6
6
  function Ks(e) {
7
7
  return (...t) => {
@@ -1,6 +1,6 @@
1
1
  import { jsx as t, jsxs as g, Fragment as hn } from "react/jsx-runtime";
2
- import { p as fn, r as gn, S as mn } from "./slug-input-CKKkqGj4.js";
3
- import { b as xn, c as vn, d as Sn, e as pn, f as Nn, g as Z, h as Fn, i as wn, L as A } from "./index-yhKyIbgs.js";
2
+ import { p as fn, r as gn, S as mn } from "./slug-input-RCGUFL2T.js";
3
+ import { b as xn, c as vn, d as Sn, e as pn, f as Nn, g as Z, h as Fn, i as wn, L as A } from "./index-DRQI9rlW.js";
4
4
  import { useLanguages as An, useTranslation as T, useSidebarActivePanel as Cn } from "@chaibuilder/sdk";
5
5
  import { Dialog as En, DialogContent as $n, DialogHeader as Dn, DialogTitle as Ln, DialogDescription as Tn, Label as I, Input as Un, Alert as H, DialogFooter as kn, Button as Rn } from "@chaibuilder/sdk/ui";
6
6
  import { filter as Wn, find as Bn, startsWith as In } from "lodash-es";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),V=require("./slug-input--VmQG0S1.cjs"),f=require("./index-W0r4o5Ro.cjs"),w=require("@chaibuilder/sdk"),S=require("@chaibuilder/sdk/ui"),Y=require("lodash-es"),is=require("lucide-react"),N=require("react"),X=({edit:c,lang:h,languages:a,name:u,setLang:t,setName:i,primaryPageObject:o})=>{const{t:s}=w.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(S.Label,{htmlFor:"lang",children:s("Language")}),e.jsxs("select",{value:c?"":h,disabled:c||!a.length,onChange:l=>{const x=l.target.value;t(x),!c&&(Y.startsWith(u,o==null?void 0:o.name)||u.length===0)&&i(`${o==null?void 0:o.name} - ${f.LANGUAGES[x]}`)},className:"col-span-3 flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("option",{value:"",disabled:!0,children:c?f.LANGUAGES[h]||h:a.length?s("Choose language"):s("All available language page is created.")}),a.map(l=>e.jsx("option",{value:l,children:f.LANGUAGES[l]||l},l))]})]})},Z=({lang:c,name:h,setName:a,parentHasSelectedLanguagePage:u})=>{const{t}=w.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(S.Label,{htmlFor:"name",children:t("Page Name")}),e.jsx(S.Input,{id:"name",value:c?h:"",onChange:i=>a(i.target.value),required:!0,placeholder:t(c?"Enter page name":"Choose language to add slug"),disabled:!u||!c})]})},ds=({dynamic:c,isNonSlugPageType:h,isRootPage:a,lang:u,useLanguagePrefix:t,setUseLanguagePrefix:i,isHomePage:o,parentSlug:s,parentHasSelectedLanguagePage:l,slug:x,setSlug:d,setIsSlugValid:m,getSlug:g})=>{const{t:r}=w.useTranslation();return h?null:e.jsxs("div",{className:"space-y-1",children:[a&&u&&e.jsxs("div",{className:"flex items-center space-x-2 pb-1",children:[e.jsx("input",{type:"checkbox",id:"useLanguagePrefix",checked:t,onChange:A=>i(A.target.checked),className:"rounded border-gray-300"}),e.jsxs(S.Label,{htmlFor:"useLanguagePrefix",className:"text-sm font-normal leading-tight",children:["Add language code (",e.jsxs("span",{className:"font-mono text-gray-900",children:["/",u]}),") as slug prefix"]})]}),e.jsx(S.Label,{htmlFor:"slug",children:r("Slug")}),c?e.jsx(S.Alert,{variant:"default",className:"p-2 text-xs font-medium italic text-muted-foreground",children:r("This page will use dynamic slug as defined in primary page")}):e.jsx(V.SlugInput,{disabled:!u||!l,value:x,onChange:d,placeholder:r(u?o&&t?"Leave empty for home page":"Enter page slug":"Choose language to add slug"),parentSlug:s,onValidationChange:m,fullSlug:g()})]})},_=({parentHasSelectedLanguagePage:c,name:h,lang:a,slug:u,edit:t,id:i,primaryPageObject:o,pages:s,isNonSlugPageType:l,isHomePage:x,useLanguagePrefix:d,isSlugValid:m,isPending:g})=>{const{t:r}=w.useTranslation(),A=g||!h||!a||s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)||!l&&!(x&&d)&&(!m||!u);return e.jsx(S.DialogFooter,{children:c?e.jsxs(e.Fragment,{children:[e.jsx(S.Button,{type:"submit",disabled:A&&!o.dynamic,children:g?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"loader mr-2"}),r(t?"Updating...":"Adding...")]}):r(t?"Update":"Add new language page")}),s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)&&e.jsx("p",{className:"mt-2 text-xs text-red-500",children:r("A page for this language already exists.")})]}):a&&e.jsx(S.Alert,{variant:"destructive",children:e.jsxs("p",{className:"mx-auto w-5/6 text-center",children:[r("You need to create the")," ",e.jsx("span",{className:"font-medium",children:f.LANGUAGES[a]})," ",r("page in the parent to add here.")]})})})},cs=({onSubmit:c,edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s,parentHasSelectedLanguagePage:l,id:x,pages:d,isNonSlugPageType:m,isHomePage:g,useLanguagePrefix:r,slug:A,isSlugValid:v,isPending:E})=>e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s}),e.jsx(Z,{lang:a,name:t,setName:o,parentHasSelectedLanguagePage:l})]}),e.jsx(_,{parentHasSelectedLanguagePage:l,name:t,lang:a,slug:A,edit:h,id:x,primaryPageObject:s,pages:d,isNonSlugPageType:m,isHomePage:g,useLanguagePrefix:r,isSlugValid:v,isPending:E})]}),rs=({loading:c,onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,isNonSlugPageType:d,isRootPage:m,useLanguagePrefix:g,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,slug:E,setSlug:C,isSlugValid:T,setIsSlugValid:R,getSlug:M,isPending:$,id:D,pages:L})=>c?e.jsx("div",{className:"flex h-80 items-center justify-center",children:e.jsx(is.Loader,{className:"animate-spin"})}):d?e.jsx(cs,{onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,id:D,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:g,slug:E,isSlugValid:T,isPending:$}):e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l}),e.jsx(Z,{lang:u,name:i,setName:s,parentHasSelectedLanguagePage:x}),e.jsx(ds,{dynamic:l==null?void 0:l.dynamic,isNonSlugPageType:d,isRootPage:m,lang:u,useLanguagePrefix:g,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,parentHasSelectedLanguagePage:x,slug:E,setSlug:C,isSlugValid:T,setIsSlugValid:R,getSlug:M})]}),e.jsx(_,{parentHasSelectedLanguagePage:x,name:i,lang:u,slug:E,edit:a,id:D,primaryPageObject:l,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:g,isSlugValid:T,isPending:$})]}),hs=({id:c,isOpen:h,onClose:a,primaryPage:u,edit:t=!1,preselectedLang:i})=>{const{data:o=[]}=f.useWebsitePages(),s=N.useMemo(()=>o.find(n=>n.id===u),[o,u]),[l,x]=N.useState(""),[d,m]=N.useState(""),[g,r]=N.useState(""),[A,v]=N.useState(!0),[E,C]=N.useState(!0),{mutate:T,isPending:R}=f.useCreatePage(),{mutate:M,isPending:$}=f.useUpdatePage(),D=R||$,{data:L,isFetching:H}=f.useWebsiteSetting(),j=f.useFallbackLang(),{data:G,isFetching:b}=f.useLanguagePages(u),{data:F=[],isFetching:y}=f.useLanguagePages(s==null?void 0:s.parent),{data:z=[],isFetching:P}=f.usePageTypes(),{setSelectedLang:O}=w.useLanguages(),{t:I}=w.useTranslation(),[,ss]=f.useSearchParams(),[,es]=w.useSidebarActivePanel(),ns=H||b||y||P,U=N.useMemo(()=>Y.filter(L==null?void 0:L.languages,n=>!Y.find(G,{lang:n})),[L,G]),W=N.useMemo(()=>z.find(n=>n.key===(s==null?void 0:s.pageType)),[z,s==null?void 0:s.pageType]),J=!(W!=null&&W.hasSlug),B=(s==null?void 0:s.slug)==="/";N.useEffect(()=>{if(!t&&s&&i&&(m(i),x(`${s.name} - ${f.LANGUAGES[i]}`)),!t||!s)return;const n=G==null?void 0:G.find(us=>us.id===c);if(!n)return;x(n.name),m(n.lang);const p=n.slug||"",{initSlug:k,prefix:as}=V.parseSlugForEdit(p,s);r(k),C(as)},[t,c,G,s,i]),N.useEffect(()=>{if(i)m(i);else if((U==null?void 0:U.length)===1&&!t){const n=U[0];if(!n||!f.LANGUAGES[n])return;m(n),(!l||l===(s==null?void 0:s.name))&&x(`${s==null?void 0:s.name} - ${f.LANGUAGES[n]}`)}},[i,U,t,l,s]);const{parentSlug:K,isRootPage:q}=N.useMemo(()=>{if(B||!d)return{parentSlug:void 0,isRootPage:!(s!=null&&s.parent)};if(!(s!=null&&s.parent))return{parentSlug:E?`/${d}`:void 0,isRootPage:!0};const n=F==null?void 0:F.find(p=>p.lang===d);return{parentSlug:n==null?void 0:n.slug,isRootPage:!1}},[s==null?void 0:s.parent,F,E,d,B]),ts=N.useMemo(()=>q?!0:!!(F!=null&&F.some(n=>(n==null?void 0:n.lang)===d)),[d,F,q]),Q=()=>{let n="";return q?n=`/${E?[d,g].filter(Boolean).join("/"):g}`:n=`${V.removeSlugExtension(K)}/${g}`,n.replace(/\/{2,}/g,"/").replace(/\/$/,"")},os=n=>{const p=new URLSearchParams(window.location.search);j&&n===j?p.delete("lang"):p.set("lang",n),ss(p),window.dispatchEvent(new PopStateEvent("popstate"))},ls=n=>{n.preventDefault();const p={name:l,lang:d,primaryPage:s==null?void 0:s.id,slug:J?"":Q(),pageType:s==null?void 0:s.pageType,...t&&{id:c}},k=()=>{!t&&d&&(O(d),os(d)),es("outline"),a()};t?M(p,{onSuccess:k}):T(p,{onSuccess:k})};return e.jsx(S.Dialog,{open:h,onOpenChange:a,children:h&&e.jsxs(S.DialogContent,{className:"text-slate-600 sm:max-w-[425px]",children:[e.jsxs(S.DialogHeader,{children:[e.jsx(S.DialogTitle,{children:I(t?"Edit language":"Add new language page")}),e.jsx(S.DialogDescription,{className:"font-light",children:I("Enter the details for the language")})]}),e.jsx(rs,{id:c,pages:o,loading:ns,onSubmit:ls,edit:t,lang:d,languages:U,name:l,setLang:m,setName:x,primaryPageObject:s,parentHasSelectedLanguagePage:ts,isNonSlugPageType:J,isRootPage:q,useLanguagePrefix:E,setUseLanguagePrefix:C,isHomePage:B,parentSlug:K,slug:g,setSlug:r,isSlugValid:A,setIsSlugValid:v,getSlug:Q,isPending:D})]})})};exports.default=hs;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),V=require("./slug-input-BewLv-d8.cjs"),f=require("./index-CyHmr87X.cjs"),w=require("@chaibuilder/sdk"),S=require("@chaibuilder/sdk/ui"),Y=require("lodash-es"),is=require("lucide-react"),N=require("react"),X=({edit:c,lang:h,languages:a,name:u,setLang:t,setName:i,primaryPageObject:o})=>{const{t:s}=w.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(S.Label,{htmlFor:"lang",children:s("Language")}),e.jsxs("select",{value:c?"":h,disabled:c||!a.length,onChange:l=>{const x=l.target.value;t(x),!c&&(Y.startsWith(u,o==null?void 0:o.name)||u.length===0)&&i(`${o==null?void 0:o.name} - ${f.LANGUAGES[x]}`)},className:"col-span-3 flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("option",{value:"",disabled:!0,children:c?f.LANGUAGES[h]||h:a.length?s("Choose language"):s("All available language page is created.")}),a.map(l=>e.jsx("option",{value:l,children:f.LANGUAGES[l]||l},l))]})]})},Z=({lang:c,name:h,setName:a,parentHasSelectedLanguagePage:u})=>{const{t}=w.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(S.Label,{htmlFor:"name",children:t("Page Name")}),e.jsx(S.Input,{id:"name",value:c?h:"",onChange:i=>a(i.target.value),required:!0,placeholder:t(c?"Enter page name":"Choose language to add slug"),disabled:!u||!c})]})},ds=({dynamic:c,isNonSlugPageType:h,isRootPage:a,lang:u,useLanguagePrefix:t,setUseLanguagePrefix:i,isHomePage:o,parentSlug:s,parentHasSelectedLanguagePage:l,slug:x,setSlug:d,setIsSlugValid:m,getSlug:g})=>{const{t:r}=w.useTranslation();return h?null:e.jsxs("div",{className:"space-y-1",children:[a&&u&&e.jsxs("div",{className:"flex items-center space-x-2 pb-1",children:[e.jsx("input",{type:"checkbox",id:"useLanguagePrefix",checked:t,onChange:A=>i(A.target.checked),className:"rounded border-gray-300"}),e.jsxs(S.Label,{htmlFor:"useLanguagePrefix",className:"text-sm font-normal leading-tight",children:["Add language code (",e.jsxs("span",{className:"font-mono text-gray-900",children:["/",u]}),") as slug prefix"]})]}),e.jsx(S.Label,{htmlFor:"slug",children:r("Slug")}),c?e.jsx(S.Alert,{variant:"default",className:"p-2 text-xs font-medium italic text-muted-foreground",children:r("This page will use dynamic slug as defined in primary page")}):e.jsx(V.SlugInput,{disabled:!u||!l,value:x,onChange:d,placeholder:r(u?o&&t?"Leave empty for home page":"Enter page slug":"Choose language to add slug"),parentSlug:s,onValidationChange:m,fullSlug:g()})]})},_=({parentHasSelectedLanguagePage:c,name:h,lang:a,slug:u,edit:t,id:i,primaryPageObject:o,pages:s,isNonSlugPageType:l,isHomePage:x,useLanguagePrefix:d,isSlugValid:m,isPending:g})=>{const{t:r}=w.useTranslation(),A=g||!h||!a||s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)||!l&&!(x&&d)&&(!m||!u);return e.jsx(S.DialogFooter,{children:c?e.jsxs(e.Fragment,{children:[e.jsx(S.Button,{type:"submit",disabled:A&&!o.dynamic,children:g?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"loader mr-2"}),r(t?"Updating...":"Adding...")]}):r(t?"Update":"Add new language page")}),s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)&&e.jsx("p",{className:"mt-2 text-xs text-red-500",children:r("A page for this language already exists.")})]}):a&&e.jsx(S.Alert,{variant:"destructive",children:e.jsxs("p",{className:"mx-auto w-5/6 text-center",children:[r("You need to create the")," ",e.jsx("span",{className:"font-medium",children:f.LANGUAGES[a]})," ",r("page in the parent to add here.")]})})})},cs=({onSubmit:c,edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s,parentHasSelectedLanguagePage:l,id:x,pages:d,isNonSlugPageType:m,isHomePage:g,useLanguagePrefix:r,slug:A,isSlugValid:v,isPending:E})=>e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s}),e.jsx(Z,{lang:a,name:t,setName:o,parentHasSelectedLanguagePage:l})]}),e.jsx(_,{parentHasSelectedLanguagePage:l,name:t,lang:a,slug:A,edit:h,id:x,primaryPageObject:s,pages:d,isNonSlugPageType:m,isHomePage:g,useLanguagePrefix:r,isSlugValid:v,isPending:E})]}),rs=({loading:c,onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,isNonSlugPageType:d,isRootPage:m,useLanguagePrefix:g,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,slug:E,setSlug:C,isSlugValid:T,setIsSlugValid:R,getSlug:M,isPending:$,id:D,pages:L})=>c?e.jsx("div",{className:"flex h-80 items-center justify-center",children:e.jsx(is.Loader,{className:"animate-spin"})}):d?e.jsx(cs,{onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,id:D,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:g,slug:E,isSlugValid:T,isPending:$}):e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l}),e.jsx(Z,{lang:u,name:i,setName:s,parentHasSelectedLanguagePage:x}),e.jsx(ds,{dynamic:l==null?void 0:l.dynamic,isNonSlugPageType:d,isRootPage:m,lang:u,useLanguagePrefix:g,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,parentHasSelectedLanguagePage:x,slug:E,setSlug:C,isSlugValid:T,setIsSlugValid:R,getSlug:M})]}),e.jsx(_,{parentHasSelectedLanguagePage:x,name:i,lang:u,slug:E,edit:a,id:D,primaryPageObject:l,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:g,isSlugValid:T,isPending:$})]}),hs=({id:c,isOpen:h,onClose:a,primaryPage:u,edit:t=!1,preselectedLang:i})=>{const{data:o=[]}=f.useWebsitePages(),s=N.useMemo(()=>o.find(n=>n.id===u),[o,u]),[l,x]=N.useState(""),[d,m]=N.useState(""),[g,r]=N.useState(""),[A,v]=N.useState(!0),[E,C]=N.useState(!0),{mutate:T,isPending:R}=f.useCreatePage(),{mutate:M,isPending:$}=f.useUpdatePage(),D=R||$,{data:L,isFetching:H}=f.useWebsiteSetting(),j=f.useFallbackLang(),{data:G,isFetching:b}=f.useLanguagePages(u),{data:F=[],isFetching:y}=f.useLanguagePages(s==null?void 0:s.parent),{data:z=[],isFetching:P}=f.usePageTypes(),{setSelectedLang:O}=w.useLanguages(),{t:I}=w.useTranslation(),[,ss]=f.useSearchParams(),[,es]=w.useSidebarActivePanel(),ns=H||b||y||P,U=N.useMemo(()=>Y.filter(L==null?void 0:L.languages,n=>!Y.find(G,{lang:n})),[L,G]),W=N.useMemo(()=>z.find(n=>n.key===(s==null?void 0:s.pageType)),[z,s==null?void 0:s.pageType]),J=!(W!=null&&W.hasSlug),B=(s==null?void 0:s.slug)==="/";N.useEffect(()=>{if(!t&&s&&i&&(m(i),x(`${s.name} - ${f.LANGUAGES[i]}`)),!t||!s)return;const n=G==null?void 0:G.find(us=>us.id===c);if(!n)return;x(n.name),m(n.lang);const p=n.slug||"",{initSlug:k,prefix:as}=V.parseSlugForEdit(p,s);r(k),C(as)},[t,c,G,s,i]),N.useEffect(()=>{if(i)m(i);else if((U==null?void 0:U.length)===1&&!t){const n=U[0];if(!n||!f.LANGUAGES[n])return;m(n),(!l||l===(s==null?void 0:s.name))&&x(`${s==null?void 0:s.name} - ${f.LANGUAGES[n]}`)}},[i,U,t,l,s]);const{parentSlug:K,isRootPage:q}=N.useMemo(()=>{if(B||!d)return{parentSlug:void 0,isRootPage:!(s!=null&&s.parent)};if(!(s!=null&&s.parent))return{parentSlug:E?`/${d}`:void 0,isRootPage:!0};const n=F==null?void 0:F.find(p=>p.lang===d);return{parentSlug:n==null?void 0:n.slug,isRootPage:!1}},[s==null?void 0:s.parent,F,E,d,B]),ts=N.useMemo(()=>q?!0:!!(F!=null&&F.some(n=>(n==null?void 0:n.lang)===d)),[d,F,q]),Q=()=>{let n="";return q?n=`/${E?[d,g].filter(Boolean).join("/"):g}`:n=`${V.removeSlugExtension(K)}/${g}`,n.replace(/\/{2,}/g,"/").replace(/\/$/,"")},os=n=>{const p=new URLSearchParams(window.location.search);j&&n===j?p.delete("lang"):p.set("lang",n),ss(p),window.dispatchEvent(new PopStateEvent("popstate"))},ls=n=>{n.preventDefault();const p={name:l,lang:d,primaryPage:s==null?void 0:s.id,slug:J?"":Q(),pageType:s==null?void 0:s.pageType,...t&&{id:c}},k=()=>{!t&&d&&(O(d),os(d)),es("outline"),a()};t?M(p,{onSuccess:k}):T(p,{onSuccess:k})};return e.jsx(S.Dialog,{open:h,onOpenChange:a,children:h&&e.jsxs(S.DialogContent,{className:"text-slate-600 sm:max-w-[425px]",children:[e.jsxs(S.DialogHeader,{children:[e.jsx(S.DialogTitle,{children:I(t?"Edit language":"Add new language page")}),e.jsx(S.DialogDescription,{className:"font-light",children:I("Enter the details for the language")})]}),e.jsx(rs,{id:c,pages:o,loading:ns,onSubmit:ls,edit:t,lang:d,languages:U,name:l,setLang:m,setName:x,primaryPageObject:s,parentHasSelectedLanguagePage:ts,isNonSlugPageType:J,isRootPage:q,useLanguagePrefix:E,setUseLanguagePrefix:C,isHomePage:B,parentSlug:K,slug:g,setSlug:r,isSlugValid:A,setIsSlugValid:v,getSlug:Q,isPending:D})]})})};exports.default=hs;
@@ -2,7 +2,7 @@ import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
2
  import { useTranslation as a } from "@chaibuilder/sdk";
3
3
  import { Dialog as c, DialogContent as m, DialogHeader as p, DialogTitle as h, DialogDescription as f } from "@chaibuilder/sdk/ui";
4
4
  import { lazy as D, Suspense as u } from "react";
5
- const x = D(() => import("./page-creator-Zbv4d4H8.js")), C = ({
5
+ const x = D(() => import("./page-creator-BiDN-rLc.js")), C = ({
6
6
  addEditPage: o,
7
7
  setAddEditPage: i,
8
8
  closePanel: t
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk"),n=require("@chaibuilder/sdk/ui"),t=require("react"),u=t.lazy(()=>Promise.resolve().then(()=>require("./page-creator-ByhjXyHP.cjs"))),x=({addEditPage:s,setAddEditPage:r,closePanel:c})=>{const{t:o}=a.useTranslation(),i=!!(s!=null&&s.id),l=!!s;return e.jsx(n.Dialog,{open:l,onOpenChange:()=>r(void 0),children:l&&e.jsxs(n.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(n.DialogHeader,{children:[e.jsxs(n.DialogTitle,{children:[o(i?"Edit":"Add New")," "]}),e.jsx(n.DialogDescription,{children:o(i?"Update your page name":"Enter details to create a new page")})]}),e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"min-h-40"}),children:e.jsx(u,{closePanel:c,addEditPage:s,close:()=>r(void 0)})})]})})};exports.default=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk"),n=require("@chaibuilder/sdk/ui"),t=require("react"),u=t.lazy(()=>Promise.resolve().then(()=>require("./page-creator-BawPgFIv.cjs"))),x=({addEditPage:s,setAddEditPage:r,closePanel:c})=>{const{t:o}=a.useTranslation(),i=!!(s!=null&&s.id),l=!!s;return e.jsx(n.Dialog,{open:l,onOpenChange:()=>r(void 0),children:l&&e.jsxs(n.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(n.DialogHeader,{children:[e.jsxs(n.DialogTitle,{children:[o(i?"Edit":"Add New")," "]}),e.jsx(n.DialogDescription,{children:o(i?"Update your page name":"Enter details to create a new page")})]}),e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"min-h-40"}),children:e.jsx(u,{closePanel:c,addEditPage:s,close:()=>r(void 0)})})]})})};exports.default=x;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("./index-CyHmr87X.cjs"),m=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-D-RS6z5I.cjs"))),z=n.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-other-lang-BoD4FsoG.cjs"))),B=()=>{const{t:o}=m.useTranslation(),[S,r]=n.useState(""),[t,l]=n.useState([]),[a,c]=n.useState(!1),[i,u]=n.useState(null),[b,d]=n.useState(null),[p,P]=n.useState("google/gemini-2.5-flash"),{selectedLang:f,fallbackLang:q}=m.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([])},[f,C]);const g=()=>{l([]),r(""),d(null),u(null),c(!1)},x={t:o,fetch:v,input:S,messages:t,setInput:r,isLoading:a,handleStop:()=>{i&&(i.abort(),u(null)),c(!1),r(""),d(null),l(s=>{const h=s[s.length-1];return h&&h.role==="assistant"&&!h.content.trim()?s.slice(0,-1):s}),M.toast.info(o("Generation stopped"))},handleReset:g,setMessages:l,setIsLoading:c,currentBlock:b,fallbackLang:q,abortController:i,setCurrentBlock:d,setAbortController:u,forceNewConversation:y,suggestNewConversation:L,selectedModel:p,onModelChange:P};return e.jsxs(e.Fragment,{children:[a&&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:o("Your conversation will not be saved")}),(t==null?void 0:t.length)>0&&e.jsx(N.Button,{variant:"outline",size:"icon",onClick:g,className:"h-6 w-6",disabled:a,children:e.jsx(k.Plus,{})})]}),e.jsx(n.Suspense,{fallback:e.jsx("div",{children:"Loading AI Panel..."}),children:f?e.jsx(z,{...x,selectedLang:f}):e.jsx(A,{...x})})]})]})};exports.default=B;
@@ -0,0 +1,54 @@
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-DRQI9rlW.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 l, useEffect as q, Suspense as D } from "react";
7
+ import { toast as E } from "sonner";
8
+ const G = x(() => import("./ai-panel-default-lang-BYfcAA8u.js")), O = x(() => import("./ai-panel-other-lang-TVjNYPRK.js")), V = () => {
9
+ const { t: s } = B(), [b, r] = l(""), [e, o] = l([]), [a, c] = l(!1), [i, f] = l(null), [w, u] = l(null), [C, L] = l("google/gemini-2.5-flash"), { selectedLang: d, fallbackLang: P } = F(), N = j(), [v] = y(), S = v.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
+ q(() => {
11
+ o([]);
12
+ }, [d, S]);
13
+ const g = () => {
14
+ o([]), r(""), u(null), f(null), c(!1);
15
+ }, p = {
16
+ t: s,
17
+ fetch: N,
18
+ input: b,
19
+ messages: e,
20
+ setInput: r,
21
+ isLoading: a,
22
+ handleStop: () => {
23
+ i && (i.abort(), f(null)), c(!1), r(""), u(null), o((t) => {
24
+ const h = t[t.length - 1];
25
+ return h && h.role === "assistant" && !h.content.trim() ? t.slice(0, -1) : t;
26
+ }), E.info(s("Generation stopped"));
27
+ },
28
+ handleReset: g,
29
+ setMessages: o,
30
+ setIsLoading: c,
31
+ currentBlock: w,
32
+ fallbackLang: P,
33
+ abortController: i,
34
+ setCurrentBlock: u,
35
+ setAbortController: f,
36
+ forceNewConversation: A,
37
+ suggestNewConversation: k,
38
+ selectedModel: C,
39
+ onModelChange: L
40
+ };
41
+ return /* @__PURE__ */ m(M, { children: [
42
+ a && /* @__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: s("Your conversation will not be saved") }),
46
+ (e == null ? void 0 : e.length) > 0 && /* @__PURE__ */ n(z, { variant: "outline", size: "icon", onClick: g, className: "h-6 w-6", disabled: a, children: /* @__PURE__ */ n(I, {}) })
47
+ ] }),
48
+ /* @__PURE__ */ n(D, { fallback: /* @__PURE__ */ n("div", { children: "Loading AI Panel..." }), children: d ? /* @__PURE__ */ n(O, { ...p, selectedLang: d }) : /* @__PURE__ */ n(G, { ...p }) })
49
+ ] })
50
+ ] });
51
+ };
52
+ export {
53
+ V as default
54
+ };
@@ -0,0 +1,178 @@
1
+ import { jsxs as g, Fragment as ee, jsx as r } from "react/jsx-runtime";
2
+ import { useAddBlock as te, useReplaceBlock as ne, useSelectedBlock as re, useBlocksHtmlForAi as oe, useHtmlToBlocks as le } from "@chaibuilder/sdk";
3
+ import { Bot as se, Plus as ae } from "lucide-react";
4
+ import { lazy as D, useRef as ce, useEffect as ie, Suspense as _ } from "react";
5
+ import { toast as de } from "sonner";
6
+ import { a as ue } from "./prompt-helper-Bh7WyDYo.js";
7
+ function me(t) {
8
+ if (!t) return "";
9
+ let e = t.trim();
10
+ return e = e.replace(/^```html\n?/i, ""), e = e.replace(/^```\n?/, ""), e = e.replace(/\n?```$/, ""), e = e.trim(), e;
11
+ }
12
+ function fe(t) {
13
+ if (!t) return "";
14
+ const e = me(t);
15
+ return e.length === 0 || !e.includes("<") || !e.includes(">") ? "" : e;
16
+ }
17
+ const he = (t) => {
18
+ const e = document.getElementById("canvas-iframe");
19
+ if (!e) return null;
20
+ const s = e == null ? void 0 : e.contentDocument;
21
+ if (!s) return null;
22
+ const l = s.querySelector(`[data-block-id="${t}"]`);
23
+ if (!l) return null;
24
+ if (t === "canvas") {
25
+ const c = s.createElement("div");
26
+ return c.style.height = "100vh", l.appendChild(c), c;
27
+ }
28
+ return l;
29
+ }, pe = D(() => import("./ai-panel-message-bubble-DPAaAMAZ.js")), be = D(() => import("./ai-prompt-input-qegCvwnu.js")), Ee = ({
30
+ t,
31
+ fetch: e,
32
+ input: s,
33
+ messages: l,
34
+ setInput: c,
35
+ isLoading: u,
36
+ setMessages: w,
37
+ handleReset: j,
38
+ handleStop: V,
39
+ setIsLoading: k,
40
+ currentBlock: z,
41
+ fallbackLang: M,
42
+ setCurrentBlock: E,
43
+ setAbortController: A,
44
+ forceNewConversation: v,
45
+ suggestNewConversation: q,
46
+ selectedModel: N = "google/gemini-2.5-flash",
47
+ onModelChange: U
48
+ }) => {
49
+ const B = ce(null), { addPredefinedBlock: W } = te(), $ = ne(), m = re(), C = oe(), K = le(), L = () => {
50
+ var o;
51
+ (o = B.current) == null || o.scrollIntoView({ behavior: "smooth" });
52
+ };
53
+ ie(() => {
54
+ L();
55
+ }, [l, u]);
56
+ const O = async (o, f, H, G) => {
57
+ var P;
58
+ if (!o || u) return;
59
+ const n = m;
60
+ E(m);
61
+ const I = C();
62
+ if (m && !I) {
63
+ de.error(t("Something went wrong. Please try again."));
64
+ return;
65
+ }
66
+ const R = {
67
+ id: Date.now().toString(),
68
+ role: "user",
69
+ content: ue({
70
+ language: M,
71
+ userInput: f || o,
72
+ currentHtml: m ? I : ""
73
+ }),
74
+ userMessage: o
75
+ }, F = { id: Date.now().toString(), role: "assistant", content: "" };
76
+ w((i) => [...i, R, F]), k(!0);
77
+ const J = new AbortController();
78
+ A(J);
79
+ try {
80
+ const i = {
81
+ messages: [...l, R].map((x) => ({
82
+ role: x.role,
83
+ content: x.content
84
+ })),
85
+ model: G || N
86
+ };
87
+ H && (i.image = H);
88
+ const h = await e({ body: { action: "ASK_AI", data: i }, streamResponse: !0 });
89
+ if (!h.ok)
90
+ throw new Error(t("Failed to get AI response"));
91
+ const p = (P = h.body) == null ? void 0 : P.getReader(), Q = new TextDecoder();
92
+ let b = "";
93
+ if (!p) throw new Error(t("Response body is not readable"));
94
+ const d = he(n ? n == null ? void 0 : n._id : "canvas");
95
+ for (; ; ) {
96
+ const { done: x, value: Y } = await p.read();
97
+ if (x) {
98
+ d && !n && d.remove();
99
+ break;
100
+ }
101
+ const Z = Q.decode(Y, { stream: !0 });
102
+ if (b += Z, d) {
103
+ d.innerHTML = b;
104
+ const y = d.getBoundingClientRect(), a = document.getElementById("canvas-iframe"), T = a == null ? void 0 : a.contentWindow;
105
+ T && (y.top >= 0 && y.bottom <= T.innerHeight || d.scrollIntoView({ behavior: "smooth", block: "nearest" }));
106
+ }
107
+ w(
108
+ (y) => y.map((a) => a.id === F.id ? { ...a, content: b } : a)
109
+ );
110
+ }
111
+ const X = fe(b), S = K(X);
112
+ n != null && n._id ? (console.log("Editing block", n == null ? void 0 : n._id, S), $(n == null ? void 0 : n._id, S)) : W([...S], n == null ? void 0 : n._parent, -1);
113
+ } catch (i) {
114
+ if (i.name !== "AbortError") {
115
+ const h = {
116
+ id: (Date.now() + 1).toString(),
117
+ role: "assistant",
118
+ content: t("Sorry, I encountered an error. Please try again.")
119
+ };
120
+ w((p) => [...p, h]);
121
+ }
122
+ } finally {
123
+ c(""), k(!1), E(null), A(null);
124
+ }
125
+ };
126
+ return /* @__PURE__ */ g(ee, { children: [
127
+ /* @__PURE__ */ g("div", { className: "flex-1 space-y-3 overflow-y-auto py-4", children: [
128
+ l.length === 0 && /* @__PURE__ */ r("div", { className: "flex-1 space-y-3 overflow-y-auto py-4", children: /* @__PURE__ */ g("div", { className: "mx-auto mt-8 text-center text-gray-500", children: [
129
+ /* @__PURE__ */ r(se, { size: 48, className: "mx-auto mb-4 text-gray-300" }),
130
+ /* @__PURE__ */ r("p", { className: "mx-auto max-w-[75%] text-sm", children: t("Start a conversation with the AI assistant to generate and update your sections") })
131
+ ] }) }),
132
+ l.map(
133
+ (o, f) => o.role !== "system" && /* @__PURE__ */ r(_, { fallback: /* @__PURE__ */ r("div", { children: "Loading..." }), children: /* @__PURE__ */ r(
134
+ pe,
135
+ {
136
+ message: o,
137
+ isUser: o.role === "user",
138
+ isLoading: o.role === "assistant" && u && f === l.length - 1
139
+ }
140
+ ) }, f)
141
+ ),
142
+ q && !u && /* @__PURE__ */ r(
143
+ "button",
144
+ {
145
+ onClick: j,
146
+ className: "flex w-full items-center justify-center gap-2 rounded-lg border border-blue-200 bg-blue-50 p-1.5 text-left transition-colors hover:bg-blue-100",
147
+ children: /* @__PURE__ */ r("div", { className: "flex flex-col", children: /* @__PURE__ */ g("span", { className: "flex items-center gap-1 text-xs font-medium text-blue-700", children: [
148
+ /* @__PURE__ */ r(ae, { className: "h-4 w-4 capitalize text-blue-600" }),
149
+ t(v ? "Start" : "New"),
150
+ " ",
151
+ t("Conversation"),
152
+ " ",
153
+ !v && /* @__PURE__ */ r("span", { className: "text-[10px] font-extralight text-blue-600", children: t("For best results") })
154
+ ] }) })
155
+ }
156
+ ),
157
+ /* @__PURE__ */ r("div", { ref: B })
158
+ ] }),
159
+ !v && /* @__PURE__ */ r("div", { className: "border-gray-200 pb-2", children: /* @__PURE__ */ r(_, { fallback: /* @__PURE__ */ r("div", { children: "Loading..." }), children: /* @__PURE__ */ r(
160
+ be,
161
+ {
162
+ input: s,
163
+ setInput: c,
164
+ onSend: O,
165
+ onStop: V,
166
+ isLoading: u,
167
+ selectedLang: "",
168
+ currentBlock: m || z,
169
+ disabled: (s == null ? void 0 : s.length) === 0,
170
+ selectedModel: N,
171
+ onModelChange: U
172
+ }
173
+ ) }) })
174
+ ] });
175
+ };
176
+ export {
177
+ Ee as default
178
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),h=require("@chaibuilder/sdk"),T=require("lucide-react"),d=require("react"),ee=require("sonner"),te=require("./prompt-helper-BLBZjr5q.cjs");function ne(n){if(!n)return"";let e=n.trim();return e=e.replace(/^```html\n?/i,""),e=e.replace(/^```\n?/,""),e=e.replace(/\n?```$/,""),e=e.trim(),e}function re(n){if(!n)return"";const e=ne(n);return e.length===0||!e.includes("<")||!e.includes(">")?"":e}const oe=n=>{const e=document.getElementById("canvas-iframe");if(!e)return null;const l=e==null?void 0:e.contentDocument;if(!l)return null;const s=l.querySelector(`[data-block-id="${n}"]`);if(!s)return null;if(n==="canvas"){const a=l.createElement("div");return a.style.height="100vh",s.appendChild(a),a}return s},se=d.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-message-bubble-Bl-aUeU4.cjs"))),le=d.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-DB1FpA_q.cjs"))),ce=({t:n,fetch:e,input:l,messages:s,setInput:a,isLoading:m,setMessages:v,handleReset:_,handleStop:D,setIsLoading:k,currentBlock:z,fallbackLang:M,setCurrentBlock:R,setAbortController:E,forceNewConversation:j,suggestNewConversation:V,selectedModel:q="google/gemini-2.5-flash",onModelChange:O})=>{const A=d.useRef(null),{addPredefinedBlock:U}=h.useAddBlock(),W=h.useReplaceBlock(),f=h.useSelectedBlock(),$=h.useBlocksHtmlForAi(),C=h.useHtmlToBlocks(),K=()=>{var o;(o=A.current)==null||o.scrollIntoView({behavior:"smooth"})};d.useEffect(()=>{K()},[s,m]);const L=async(o,x,H,G)=>{var I;if(!o||m)return;const r=f;R(f);const N=$();if(f&&!N){ee.toast.error(n("Something went wrong. Please try again."));return}const P={id:Date.now().toString(),role:"user",content:te.getUserPrompt({language:M,userInput:x||o,currentHtml:f?N:""}),userMessage:o},B={id:Date.now().toString(),role:"assistant",content:""};v(i=>[...i,P,B]),k(!0);const J=new AbortController;E(J);try{const i={messages:[...s,P].map(g=>({role:g.role,content:g.content})),model:G||q};H&&(i.image=H);const b=await e({body:{action:"ASK_AI",data:i},streamResponse:!0});if(!b.ok)throw new Error(n("Failed to get AI response"));const p=(I=b.body)==null?void 0:I.getReader(),Q=new TextDecoder;let y="";if(!p)throw new Error(n("Response body is not readable"));const u=oe(r?r==null?void 0:r._id:"canvas");for(;;){const{done:g,value:Y}=await p.read();if(g){u&&!r&&u.remove();break}const Z=Q.decode(Y,{stream:!0});if(y+=Z,u){u.innerHTML=y;const w=u.getBoundingClientRect(),c=document.getElementById("canvas-iframe"),F=c==null?void 0:c.contentWindow;F&&(w.top>=0&&w.bottom<=F.innerHeight||u.scrollIntoView({behavior:"smooth",block:"nearest"}))}v(w=>w.map(c=>c.id===B.id?{...c,content:y}:c))}const X=re(y),S=C(X);r!=null&&r._id?(console.log("Editing block",r==null?void 0:r._id,S),W(r==null?void 0:r._id,S)):U([...S],r==null?void 0:r._parent,-1)}catch(i){if(i.name!=="AbortError"){const b={id:(Date.now()+1).toString(),role:"assistant",content:n("Sorry, I encountered an error. Please try again.")};v(p=>[...p,b])}}finally{a(""),k(!1),R(null),E(null)}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto py-4",children:[s.length===0&&t.jsx("div",{className:"flex-1 space-y-3 overflow-y-auto py-4",children:t.jsxs("div",{className:"mx-auto mt-8 text-center text-gray-500",children:[t.jsx(T.Bot,{size:48,className:"mx-auto mb-4 text-gray-300"}),t.jsx("p",{className:"mx-auto max-w-[75%] text-sm",children:n("Start a conversation with the AI assistant to generate and update your sections")})]})}),s.map((o,x)=>o.role!=="system"&&t.jsx(d.Suspense,{fallback:t.jsx("div",{children:"Loading..."}),children:t.jsx(se,{message:o,isUser:o.role==="user",isLoading:o.role==="assistant"&&m&&x===s.length-1})},x)),V&&!m&&t.jsx("button",{onClick:_,className:"flex w-full items-center justify-center gap-2 rounded-lg border border-blue-200 bg-blue-50 p-1.5 text-left transition-colors hover:bg-blue-100",children:t.jsx("div",{className:"flex flex-col",children:t.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-blue-700",children:[t.jsx(T.Plus,{className:"h-4 w-4 capitalize text-blue-600"}),n(j?"Start":"New")," ",n("Conversation")," ",!j&&t.jsx("span",{className:"text-[10px] font-extralight text-blue-600",children:n("For best results")})]})})}),t.jsx("div",{ref:A})]}),!j&&t.jsx("div",{className:"border-gray-200 pb-2",children:t.jsx(d.Suspense,{fallback:t.jsx("div",{children:"Loading..."}),children:t.jsx(le,{input:l,setInput:a,onSend:L,onStop:D,isLoading:m,selectedLang:"",currentBlock:f||z,disabled:(l==null?void 0:l.length)===0,selectedModel:q,onModelChange:O})})})]})};exports.default=ce;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),G=require("./index-CyHmr87X.cjs"),d=require("@chaibuilder/sdk"),j=require("lucide-react"),r=require("react"),L=require("./prompt-helper-BLBZjr5q.cjs"),Q=r.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-message-bubble-Bl-aUeU4.cjs"))),X=r.lazy(()=>Promise.resolve().then(()=>require("./ai-translation-prompt-Bj-AM4xK.cjs"))),Y=r.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-DB1FpA_q.cjs"))),Z=({fetch:q,input:o,messages:c,setInput:f,isLoading:n,handleStop:A,handleReset:R,setMessages:b,setIsLoading:u,selectedLang:i,currentBlock:E,fallbackLang:O,abortController:x,setAbortController:I,forceNewConversation:h,suggestNewConversation:z,selectedModel:g="google/gemini-2.5-flash",onModelChange:D})=>{const{t}=d.useTranslation(),y=r.useRef(null),p=d.useSelectedBlock(),v=d.useI18nBlocks(),F=d.useStreamMultipleBlocksProps(),M=()=>{var s;(s=y.current)==null||s.scrollIntoView({behavior:"smooth"})};r.useEffect(()=>{M()},[c,n]);const w=async(s,a,U)=>{var S;const N=(s==null?void 0:s.toLowerCase())==="translate",k={id:Date.now().toString(),role:"user",content:L.getTranslationUserPrompt({fallbackLang:O,userInput:a||s,language:i,blocks:N?v():v(i)}),userMessage:a||s||t("Translate the content")};u(!0);const _=new AbortController;I(_);const C={id:Date.now().toString(),role:"assistant",content:""};b(T=>[...T,k,C]),u(!0);try{const B=await q({body:{action:"ASK_AI",data:{messages:[k],initiator:N?"TRANSLATE_CONTENT":"UPDATE_CONTENT",model:U||g}},streamResponse:!0});if(!B.ok)throw new Error(t("Failed to get AI response"));const P=(S=B.body)==null?void 0:S.getReader(),H=new TextDecoder;let l="";if(!P)throw new Error(t("Response body is not readable"));for(;;){const{done:K,value:V}=await P.read();if(K)break;const W=H.decode(V,{stream:!0});l+=W,b(m=>(m[m.length-1].content=l,[...m]))}const J=JSON.parse(l==null?void 0:l.replace("```json","").replace("```",""));F(J)}catch{x==null||x.abort()}finally{u(!1),f("")}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{children:t("Loading...")}),children:e.jsx(X,{isLoading:n,selectedBlock:p,selectedLang:i,onClick:w})})}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto py-4",children:[c.length===0&&e.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto py-4",children:[e.jsxs("div",{className:"mx-auto mt-8 text-center text-gray-500",children:[e.jsx(j.Bot,{size:48,className:"mx-auto mb-4 text-gray-300"}),e.jsx("p",{className:"mx-auto max-w-[75%] text-sm",children:t("Start a conversation with the AI assistant to translate/edit your content")})]}),e.jsxs("div",{className:"relative rounded-lg border px-3 py-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j.InfoIcon,{className:"h-3 w-3"}),e.jsx("span",{className:"text-xs",children:t("Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language.")})]}),e.jsx("div",{className:"mt-1",children:e.jsx(G.LanguageSwitcher,{showAdd:!1,variant:"outline",goToDefaultLang:!0})})]})]}),c.map((s,a)=>s.role!=="system"&&e.jsx(r.Suspense,{fallback:e.jsx("div",{children:t("Loading...")}),children:e.jsx(Q,{message:s,isUser:s.role==="user",isLoading:s.role==="assistant"&&n&&a===c.length-1})},a)),z&&!n&&e.jsx("button",{onClick:R,className:"flex w-full items-center justify-center gap-2 rounded-lg border border-blue-200 bg-blue-50 p-1.5 text-left transition-colors hover:bg-blue-100",children:e.jsx("div",{className:"flex flex-col",children:e.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-blue-700",children:[e.jsx(j.Plus,{className:"h-4 w-4 capitalize text-blue-600"}),h?t("Start "):""," ",t("New Conversation")," ",!h&&e.jsx("span",{className:"text-[10px] font-extralight text-blue-600",children:t("For best results")})]})})}),e.jsx("div",{ref:y})]}),!h&&e.jsx("div",{className:"border-gray-200 pb-2",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{children:t("Loading...")}),children:e.jsx(Y,{input:o,setInput:f,onSend:w,onStop:A,isLoading:n,selectedLang:i,currentBlock:p||E,disabled:(o==null?void 0:o.length)===0,selectedModel:g,onModelChange:D})})})]})};exports.default=Z;
@@ -1,120 +1,123 @@
1
- import { jsxs as a, Fragment as V, jsx as e } from "react/jsx-runtime";
2
- import { aj as W } from "./index-yhKyIbgs.js";
3
- import { useTranslation as G, useSelectedBlock as H, useI18nBlocks as L, useStreamMultipleBlocksProps as Q } from "@chaibuilder/sdk";
4
- import { Bot as X, InfoIcon as Y, Plus as Z } from "lucide-react";
5
- import { lazy as x, useRef as $, useEffect as ee, Suspense as f } from "react";
6
- import { g as te } from "./prompt-helper-Csgu8Rfb.js";
7
- const se = x(() => import("./ai-panel-message-bubble-DPAaAMAZ.js")), ae = x(() => import("./ai-translation-prompt-BiJ5B_an.js")), re = x(() => import("./ai-prompt-input-Ch_PLEPN.js")), ue = ({
8
- fetch: E,
1
+ import { jsxs as a, Fragment as H, jsx as e } from "react/jsx-runtime";
2
+ import { aj as L } from "./index-DRQI9rlW.js";
3
+ import { useTranslation as Q, useSelectedBlock as X, useI18nBlocks as Y, useStreamMultipleBlocksProps as Z } from "@chaibuilder/sdk";
4
+ import { Bot as $, InfoIcon as ee, Plus as te } from "lucide-react";
5
+ import { lazy as g, useRef as se, useEffect as ae, Suspense as f } from "react";
6
+ import { g as oe } from "./prompt-helper-Bh7WyDYo.js";
7
+ const re = g(() => import("./ai-panel-message-bubble-DPAaAMAZ.js")), ne = g(() => import("./ai-translation-prompt--HB1UAhC.js")), le = g(() => import("./ai-prompt-input-qegCvwnu.js")), fe = ({
8
+ fetch: P,
9
9
  input: l,
10
10
  messages: c,
11
- setInput: b,
12
- isLoading: r,
13
- handleStop: P,
14
- handleReset: j,
15
- setMessages: g,
11
+ setInput: x,
12
+ isLoading: o,
13
+ handleStop: j,
14
+ handleReset: I,
15
+ setMessages: b,
16
16
  setIsLoading: d,
17
17
  selectedLang: i,
18
- currentBlock: I,
19
- fallbackLang: O,
18
+ currentBlock: O,
19
+ fallbackLang: R,
20
20
  abortController: u,
21
- setAbortController: R,
21
+ setAbortController: D,
22
22
  forceNewConversation: m,
23
- suggestNewConversation: D
23
+ suggestNewConversation: F,
24
+ selectedModel: p = "google/gemini-2.5-flash",
25
+ onModelChange: z
24
26
  }) => {
25
- const { t: s } = G(), p = $(null), y = H(), w = L(), F = Q(), M = () => {
27
+ const { t: s } = Q(), y = se(null), w = X(), N = Y(), M = Z(), U = () => {
26
28
  var t;
27
- (t = p.current) == null || t.scrollIntoView({ behavior: "smooth" });
29
+ (t = y.current) == null || t.scrollIntoView({ behavior: "smooth" });
28
30
  };
29
- ee(() => {
30
- M();
31
- }, [c, r]);
32
- const N = async (t, o) => {
33
- var T;
34
- const v = (t == null ? void 0 : t.toLowerCase()) === "translate", k = {
31
+ ae(() => {
32
+ U();
33
+ }, [c, o]);
34
+ const v = async (t, r, _) => {
35
+ var S;
36
+ const k = (t == null ? void 0 : t.toLowerCase()) === "translate", T = {
35
37
  id: Date.now().toString(),
36
38
  role: "user",
37
- content: te({
38
- fallbackLang: O,
39
- userInput: o || t,
39
+ content: oe({
40
+ fallbackLang: R,
41
+ userInput: r || t,
40
42
  language: i,
41
- blocks: v ? w() : w(i)
43
+ blocks: k ? N() : N(i)
42
44
  }),
43
- userMessage: o || t || s("Translate the content")
45
+ userMessage: r || t || s("Translate the content")
44
46
  };
45
47
  d(!0);
46
- const z = new AbortController();
47
- R(z);
48
- const U = { id: Date.now().toString(), role: "assistant", content: "" };
49
- g((S) => [...S, k, U]), d(!0);
48
+ const q = new AbortController();
49
+ D(q);
50
+ const C = { id: Date.now().toString(), role: "assistant", content: "" };
51
+ b((B) => [...B, T, C]), d(!0);
50
52
  try {
51
- const B = await E({ body: { action: "ASK_AI", data: {
52
- messages: [k],
53
- initiator: v ? "TRANSLATE_CONTENT" : "UPDATE_CONTENT"
53
+ const A = await P({ body: { action: "ASK_AI", data: {
54
+ messages: [T],
55
+ initiator: k ? "TRANSLATE_CONTENT" : "UPDATE_CONTENT",
56
+ model: _ || p
54
57
  } }, streamResponse: !0 });
55
- if (!B.ok)
58
+ if (!A.ok)
56
59
  throw new Error(s("Failed to get AI response"));
57
- const A = (T = B.body) == null ? void 0 : T.getReader(), _ = new TextDecoder();
60
+ const E = (S = A.body) == null ? void 0 : S.getReader(), J = new TextDecoder();
58
61
  let n = "";
59
- if (!A) throw new Error(s("Response body is not readable"));
62
+ if (!E) throw new Error(s("Response body is not readable"));
60
63
  for (; ; ) {
61
- const { done: C, value: J } = await A.read();
62
- if (C)
64
+ const { done: V, value: W } = await E.read();
65
+ if (V)
63
66
  break;
64
- const K = _.decode(J, { stream: !0 });
65
- n += K, g((h) => (h[h.length - 1].content = n, [...h]));
67
+ const G = J.decode(W, { stream: !0 });
68
+ n += G, b((h) => (h[h.length - 1].content = n, [...h]));
66
69
  }
67
- const q = JSON.parse(n == null ? void 0 : n.replace("```json", "").replace("```", ""));
68
- F(q);
70
+ const K = JSON.parse(n == null ? void 0 : n.replace("```json", "").replace("```", ""));
71
+ M(K);
69
72
  } catch {
70
73
  u == null || u.abort();
71
74
  } finally {
72
- d(!1), b("");
75
+ d(!1), x("");
73
76
  }
74
77
  };
75
- return /* @__PURE__ */ a(V, { children: [
78
+ return /* @__PURE__ */ a(H, { children: [
76
79
  /* @__PURE__ */ e("div", { className: "py-2", children: /* @__PURE__ */ e(f, { fallback: /* @__PURE__ */ e("div", { children: s("Loading...") }), children: /* @__PURE__ */ e(
77
- ae,
80
+ ne,
78
81
  {
79
- isLoading: r,
80
- selectedBlock: y,
82
+ isLoading: o,
83
+ selectedBlock: w,
81
84
  selectedLang: i,
82
- onClick: N
85
+ onClick: v
83
86
  }
84
87
  ) }) }),
85
88
  /* @__PURE__ */ a("div", { className: "flex-1 space-y-3 overflow-y-auto py-4", children: [
86
89
  c.length === 0 && /* @__PURE__ */ a("div", { className: "flex-1 space-y-3 overflow-y-auto py-4", children: [
87
90
  /* @__PURE__ */ a("div", { className: "mx-auto mt-8 text-center text-gray-500", children: [
88
- /* @__PURE__ */ e(X, { size: 48, className: "mx-auto mb-4 text-gray-300" }),
91
+ /* @__PURE__ */ e($, { size: 48, className: "mx-auto mb-4 text-gray-300" }),
89
92
  /* @__PURE__ */ e("p", { className: "mx-auto max-w-[75%] text-sm", children: s("Start a conversation with the AI assistant to translate/edit your content") })
90
93
  ] }),
91
94
  /* @__PURE__ */ a("div", { className: "relative rounded-lg border px-3 py-2 text-sm text-muted-foreground", children: [
92
95
  /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
93
- /* @__PURE__ */ e(Y, { className: "h-3 w-3" }),
96
+ /* @__PURE__ */ e(ee, { className: "h-3 w-3" }),
94
97
  /* @__PURE__ */ e("span", { className: "text-xs", children: s(
95
98
  "Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language."
96
99
  ) })
97
100
  ] }),
98
- /* @__PURE__ */ e("div", { className: "mt-1", children: /* @__PURE__ */ e(W, { showAdd: !1, variant: "outline", goToDefaultLang: !0 }) })
101
+ /* @__PURE__ */ e("div", { className: "mt-1", children: /* @__PURE__ */ e(L, { showAdd: !1, variant: "outline", goToDefaultLang: !0 }) })
99
102
  ] })
100
103
  ] }),
101
104
  c.map(
102
- (t, o) => t.role !== "system" && /* @__PURE__ */ e(f, { fallback: /* @__PURE__ */ e("div", { children: s("Loading...") }), children: /* @__PURE__ */ e(
103
- se,
105
+ (t, r) => t.role !== "system" && /* @__PURE__ */ e(f, { fallback: /* @__PURE__ */ e("div", { children: s("Loading...") }), children: /* @__PURE__ */ e(
106
+ re,
104
107
  {
105
108
  message: t,
106
109
  isUser: t.role === "user",
107
- isLoading: t.role === "assistant" && r && o === c.length - 1
110
+ isLoading: t.role === "assistant" && o && r === c.length - 1
108
111
  }
109
- ) }, o)
112
+ ) }, r)
110
113
  ),
111
- D && !r && /* @__PURE__ */ e(
114
+ F && !o && /* @__PURE__ */ e(
112
115
  "button",
113
116
  {
114
- onClick: j,
117
+ onClick: I,
115
118
  className: "flex w-full items-center justify-center gap-2 rounded-lg border border-blue-200 bg-blue-50 p-1.5 text-left transition-colors hover:bg-blue-100",
116
119
  children: /* @__PURE__ */ e("div", { className: "flex flex-col", children: /* @__PURE__ */ a("span", { className: "flex items-center gap-1 text-xs font-medium text-blue-700", children: [
117
- /* @__PURE__ */ e(Z, { className: "h-4 w-4 capitalize text-blue-600" }),
120
+ /* @__PURE__ */ e(te, { className: "h-4 w-4 capitalize text-blue-600" }),
118
121
  m ? s("Start ") : "",
119
122
  " ",
120
123
  s("New Conversation"),
@@ -123,23 +126,25 @@ const se = x(() => import("./ai-panel-message-bubble-DPAaAMAZ.js")), ae = x(() =
123
126
  ] }) })
124
127
  }
125
128
  ),
126
- /* @__PURE__ */ e("div", { ref: p })
129
+ /* @__PURE__ */ e("div", { ref: y })
127
130
  ] }),
128
131
  !m && /* @__PURE__ */ e("div", { className: "border-gray-200 pb-2", children: /* @__PURE__ */ e(f, { fallback: /* @__PURE__ */ e("div", { children: s("Loading...") }), children: /* @__PURE__ */ e(
129
- re,
132
+ le,
130
133
  {
131
134
  input: l,
132
- setInput: b,
133
- onSend: N,
134
- onStop: P,
135
- isLoading: r,
135
+ setInput: x,
136
+ onSend: v,
137
+ onStop: j,
138
+ isLoading: o,
136
139
  selectedLang: i,
137
- currentBlock: y || I,
138
- disabled: (l == null ? void 0 : l.length) === 0
140
+ currentBlock: w || O,
141
+ disabled: (l == null ? void 0 : l.length) === 0,
142
+ selectedModel: p,
143
+ onModelChange: z
139
144
  }
140
145
  ) }) })
141
146
  ] });
142
147
  };
143
148
  export {
144
- ue as default
149
+ fe as default
145
150
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("@chaibuilder/sdk"),m=require("lucide-react"),x=require("react"),r=require("./prompt-helper-DgI1lgGV.cjs"),u=({onSelect:p,currentBlock:s,selectedLang:a})=>{const{t}=l.useTranslation(),[i,o]=x.useState(!1),c=a?r.LANGUAGE_CONTENT_ACTIONS:s?r.UPDATE_ACTIONS:r.ADD_NEW_SECTIONS;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:()=>o(!i),className:l.mergeClasses("flex h-6 w-full cursor-pointer items-center justify-between gap-2 px-2",s?"bg-green-50/80 text-green-500 hover:bg-green-50":"bg-primary/5 text-primary hover:bg-primary/10"),children:[e.jsx("span",{className:"truncate whitespace-nowrap text-xs font-medium leading-none",children:s?e.jsxs("span",{children:[e.jsx("span",{className:"font-extralight",children:t(a?"Edit Content:":"Edit:")})," ",s._name||s._type]}):t("Quick Prompts")}),e.jsx(m.ChevronsUpDown,{className:"h-3 w-3"})]}),i&&e.jsx("div",{className:"max-h-60 w-full overflow-y-auto bg-white px-1 pb-1",children:c.map((n,d)=>e.jsx("div",{className:"flex cursor-pointer items-center gap-x-1 p-1 text-xs leading-none hover:text-blue-700",onClick:()=>{p(`${t(a||s?"Update":"Add New")} ${n.label}`,n.prompt),o(!1)},children:e.jsxs("span",{className:"truncate whitespace-nowrap",children:[s?null:e.jsx("span",{className:"font-thin text-muted-foreground",children:t("Add New")})," ",n.label]})},d))})]})};exports.default=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("@chaibuilder/sdk"),m=require("lucide-react"),x=require("react"),r=require("./prompt-helper-BLBZjr5q.cjs"),u=({onSelect:p,currentBlock:s,selectedLang:a})=>{const{t}=l.useTranslation(),[i,o]=x.useState(!1),c=a?r.LANGUAGE_CONTENT_ACTIONS:s?r.UPDATE_ACTIONS:r.ADD_NEW_SECTIONS;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:()=>o(!i),className:l.mergeClasses("flex h-6 w-full cursor-pointer items-center justify-between gap-2 px-2",s?"bg-green-50/80 text-green-500 hover:bg-green-50":"bg-primary/5 text-primary hover:bg-primary/10"),children:[e.jsx("span",{className:"truncate whitespace-nowrap text-xs font-medium leading-none",children:s?e.jsxs("span",{children:[e.jsx("span",{className:"font-extralight",children:t(a?"Edit Content:":"Edit:")})," ",s._name||s._type]}):t("Quick Prompts")}),e.jsx(m.ChevronsUpDown,{className:"h-3 w-3"})]}),i&&e.jsx("div",{className:"max-h-60 w-full overflow-y-auto bg-white px-1 pb-1",children:c.map((n,d)=>e.jsx("div",{className:"flex cursor-pointer items-center gap-x-1 p-1 text-xs leading-none hover:text-blue-700",onClick:()=>{p(`${t(a||s?"Update":"Add New")} ${n.label}`,n.prompt),o(!1)},children:e.jsxs("span",{className:"truncate whitespace-nowrap",children:[s?null:e.jsx("span",{className:"font-thin text-muted-foreground",children:t("Add New")})," ",n.label]})},d))})]})};exports.default=u;
@@ -2,7 +2,7 @@ import { jsxs as s, Fragment as d, jsx as a } from "react/jsx-runtime";
2
2
  import { useTranslation as h, mergeClasses as c } from "@chaibuilder/sdk";
3
3
  import { ChevronsUpDown as f } from "lucide-react";
4
4
  import { useState as x } from "react";
5
- import { L as N, U as w, A as g } from "./prompt-helper-Csgu8Rfb.js";
5
+ import { L as N, U as w, A as g } from "./prompt-helper-Bh7WyDYo.js";
6
6
  const E = ({ onSelect: p, currentBlock: e, selectedLang: r }) => {
7
7
  const { t } = h(), [o, i] = x(!1), l = r ? N : e ? w : g;
8
8
  return /* @__PURE__ */ s(d, { children: [
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),z=require("@chaibuilder/sdk"),d=require("lucide-react"),l=require("react"),g=require("@chaibuilder/sdk/ui"),v=[{id:"google/gemini-2.5-flash",name:"Gemini 2.5 Flash",creditsPer1000Tokens:1},{id:"openai/gpt-5",name:"GPT-5",creditsPer1000Tokens:3},{id:"openai/gpt-4o",name:"GPT-4o",creditsPer1000Tokens:2.5},{id:"anthropic/claude-3-5-haiku-20241022",name:"Haiku 4.5",creditsPer1000Tokens:1.5},{id:"anthropic/claude-3-5-sonnet-20241022",name:"Sonnet 4.5",creditsPer1000Tokens:2.8},{id:"anthropic/claude-3-5-sonnet-20240620",name:"Sonnet 4",creditsPer1000Tokens:2.5},{id:"google/gemini-pro",name:"Gemini Pro",creditsPer1000Tokens:1.2},{id:"xai/grok-4",name:"Grok 4",creditsPer1000Tokens:2.2}],K=s=>`${Math.ceil(s)}x`,O=({selectedModel:s,onModelChange:c,disabled:m})=>{const b=v.find(r=>r.id===s)||v[0],a=r=>{c(r)};return e.jsxs(g.DropdownMenu,{children:[e.jsx(g.DropdownMenuTrigger,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:m,className:`flex !hidden items-center gap-1 rounded border border-gray-200 bg-white px-2 py-1 text-xs transition-colors ${m?"cursor-not-allowed opacity-50":"cursor-pointer hover:border-gray-300"}`,children:[e.jsx(d.Zap,{className:"h-3 w-3 text-blue-500"}),e.jsx("span",{className:"max-w-20 truncate font-medium",children:b.name})]})}),e.jsx(g.DropdownMenuContent,{className:"w-64",align:"start",children:v.map(r=>e.jsxs(g.DropdownMenuItem,{onClick:()=>a(r.id),className:`flex items-center justify-between ${s===r.id?"bg-blue-50":""}`,children:[e.jsx("span",{className:"text-sm font-medium",children:r.name}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(d.Zap,{className:"h-3 w-3 text-blue-500"}),e.jsx("span",{className:"text-xs font-medium text-gray-700",children:K(r.creditsPer1000Tokens)})]})]},r.id))})]})},_=l.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-quick-prompts-BGBdrdP7.cjs"))),T="chai-ai-selected-model",C=({input:s,setInput:c,onSend:m,onStop:b,isLoading:a,disabled:r,currentBlock:w,selectedLang:n,selectedModel:R="google/gemini-2.5-flash",onModelChange:o})=>{const{t:i}=z.useTranslation(),f=l.useRef(null),y=l.useRef(null),[u,p]=l.useState(null),[j,k]=l.useState(R);l.useEffect(()=>{if(!n){const t=localStorage.getItem(T);t&&(k(t),o==null||o(t))}},[n,o]);const D=t=>{k(t),o==null||o(t),n||localStorage.setItem(T,t)},A=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),s.trim()&&!a&&(m(s==null?void 0:s.trim(),void 0,u||void 0,j),p(null)))},I=()=>{const t=f.current;t&&(t.style.height="auto",t.style.height=Math.min(t.scrollHeight,120)+"px")},M=t=>{var h;const x=(h=t.target.files)==null?void 0:h[0];if(x&&x.type.startsWith("image/")){const N=new FileReader;N.onload=G=>{var S,P;const $=(S=G.target)==null?void 0:S.result;p($),c(i("Generate UI based on given image ")),(P=f.current)==null||P.focus()},N.readAsDataURL(x)}t.target.value=""},q=()=>{var t;(t=y.current)==null||t.click()},E=()=>{m(s==null?void 0:s.trim(),void 0,u||void 0,j),p(null)};return l.useEffect(()=>{I()},[s]),e.jsxs("div",{className:"relative",children:[!u&&!(n&&!w)&&e.jsx("div",{className:`mx-auto flex w-full max-w-[95%] flex-col items-center overflow-hidden rounded-t-md border-x border-t border-gray-200 ${a?"pointer-events-none opacity-50":""}`,children:e.jsx(_,{currentBlock:w,selectedLang:n,onSelect:(t,x)=>{var h;c(x+" "),(h=f.current)==null||h.focus()}})}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white",children:[u&&e.jsxs("div",{className:"relative flex w-max items-center justify-start gap-x-2 px-2 pt-2",children:[e.jsx("img",{src:u,alt:"Selected attachment",className:"max-h-16 max-w-full rounded-md border"}),e.jsx("button",{onClick:()=>p(null),className:"absolute -right-0 -top-0 flex items-center rounded-full bg-red-400 p-1 text-xs text-white hover:bg-red-500",title:i("Remove image"),children:e.jsx(d.X,{className:"h-2 w-2"})})]}),e.jsx("textarea",{ref:f,value:s,onChange:t=>c(t.target.value),onKeyDown:A,placeholder:i(n?"Ask to update content":"Ask me anything..."),className:`max-h-[200px] min-h-[60px] w-full resize-none rounded-lg border-none px-3 py-2 text-sm outline-none ${a?"cursor-not-allowed opacity-50":""}`,rows:3,disabled:a}),e.jsxs("div",{className:"flex items-center justify-between p-2",children:[n?e.jsx("div",{}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{disabled:a,onClick:q,className:`p-1.5 text-gray-400 hover:text-gray-500 ${a||n?"cursor-not-allowed opacity-50":""}`,title:i("Attach Image"),children:e.jsx(d.Paperclip,{size:16})}),e.jsx(O,{selectedModel:j,onModelChange:D,disabled:a})]}),e.jsx("input",{disabled:a,ref:y,type:"file",accept:"image/*",onChange:M,className:"hidden"}),a?e.jsxs("button",{onClick:b,className:"z-50 flex items-center gap-x-1 rounded-md bg-red-500 p-1.5 text-white transition-colors hover:bg-red-600",title:i("Stop generation"),children:[e.jsx(d.Square,{size:16})," ",e.jsx("span",{className:"text-xs",children:i("Stop")})]}):e.jsx("button",{onClick:E,disabled:!s.trim()||r,className:`rounded-md bg-blue-500 p-1.5 text-white ${!s.trim()||r?"cursor-not-allowed opacity-50":"transition-colors hover:bg-blue-600"}`,children:e.jsx(d.Send,{size:16})})]})]})]})};exports.default=C;