@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.
- package/dist/{2AITGKQY-D1mM4eEh.js → 2AITGKQY-2rt9M99C.js} +5 -5
- package/dist/{2AITGKQY-AK2WgbeT.cjs → 2AITGKQY-Cs6RBSPQ.cjs} +1 -1
- package/dist/{NCMVHL6D-DItDf9IY.cjs → NCMVHL6D-CsC6nsSQ.cjs} +1 -1
- package/dist/{NCMVHL6D-BeRsWdGV.js → NCMVHL6D-vUfYKc6i.js} +2 -2
- package/dist/{ZDWCUMSJ-COSBY-at.cjs → ZDWCUMSJ-B2OZjsr6.cjs} +1 -1
- package/dist/{ZDWCUMSJ-D6caRaY7.js → ZDWCUMSJ-CzEWKlEU.js} +1 -1
- package/dist/active-in-another-tab-B0N5S-Bh.js +34 -0
- package/dist/active-in-another-tab-BK3cZf-x.cjs +1 -0
- package/dist/{add-new-language-page-CQcFi0Tp.cjs → add-new-language-page-Dt1j-8Zg.cjs} +1 -1
- package/dist/{add-new-language-page-nnaUe-qk.js → add-new-language-page-YlqcCdlK.js} +20 -20
- package/dist/{add-new-page-DxObnvo_.cjs → add-new-page-DqhQUQBz.cjs} +1 -1
- package/dist/{add-new-page-Ba1fq6LH.js → add-new-page-aYomeid4.js} +1 -1
- package/dist/ai-panel-content-C6cH9rrC.js +123 -0
- package/dist/ai-panel-content-MOZmNIKP.cjs +1 -0
- package/dist/ai-panel-default-lang-BZHkFsox.js +317 -0
- package/dist/ai-panel-default-lang-DOk_Q0IO.cjs +3 -0
- package/dist/{ai-panel-other-lang-B4euTuod.js → ai-panel-other-lang-D2A46FTg.js} +10 -9
- package/dist/ai-panel-other-lang-qHrdvAMa.cjs +1 -0
- package/dist/ai-prompt-input-BZSjjNJd.cjs +1 -0
- package/dist/ai-prompt-input-C6gDvvLQ.js +1071 -0
- package/dist/{ai-translation-prompt-Ip7w2_Ey.cjs → ai-translation-prompt-BqXo2CLp.cjs} +1 -1
- package/dist/{ai-translation-prompt-CVuPbgXw.js → ai-translation-prompt-DTR0wbGt.js} +1 -1
- package/dist/continue-editing-in-this-client-C3T6Jzhi.cjs +1 -0
- package/dist/continue-editing-in-this-client-D2S1yCOM.js +24 -0
- package/dist/delete-page-BF1k60U2.js +70 -0
- package/dist/delete-page-x0DWKzsR.cjs +1 -0
- package/dist/{digital-asset-manager-CIMo79Di.cjs → digital-asset-manager-BmlFt2T_.cjs} +1 -1
- package/dist/{digital-asset-manager-SAFNO_mx.js → digital-asset-manager-C8udwDBW.js} +1 -1
- package/dist/{duplicate-page-CXK2HcxD.cjs → duplicate-page-Dt_QZkTk.cjs} +1 -1
- package/dist/{duplicate-page-5SwLvmkX.js → duplicate-page-u_6vUVo1.js} +7 -7
- package/dist/{dynamic-page-selector-Crd3y4Hk.cjs → dynamic-page-selector-Cgs_Y_Kl.cjs} +1 -1
- package/dist/{dynamic-page-selector-DfcuTqRN.js → dynamic-page-selector-DxBHmglP.js} +1 -1
- package/dist/index-BeWL6Sj6.cjs +5 -0
- package/dist/index-DI2Rwk5v.js +4820 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -34
- package/dist/index.js +21 -22
- package/dist/{json-diff-viewer-D34kDA_c.cjs → json-diff-viewer-D2g0Yab2.cjs} +1 -1
- package/dist/{json-diff-viewer-CDwpbuag.js → json-diff-viewer-QdUwk7yF.js} +6 -6
- package/dist/{lang-panel-CUIeO5bb.js → lang-panel-B8OD0GiA.js} +24 -24
- package/dist/{lang-panel-CaFrYllL.cjs → lang-panel-M2Zb01lF.cjs} +1 -1
- package/dist/{mark-as-template-D0dLQaIB.js → mark-as-template-CJ1mlxYT.js} +7 -7
- package/dist/{mark-as-template-v182tmN6.cjs → mark-as-template-DONU52b1.cjs} +1 -1
- package/dist/{no-language-page-content-Bk4fEx_p.cjs → no-language-page-content-DD9Ok2Ku.cjs} +1 -1
- package/dist/{no-language-page-content-ByRFD_qA.js → no-language-page-content-Dtm37LTJ.js} +1 -1
- package/dist/no-language-page-dialog-D3dvenZ7.cjs +1 -0
- package/dist/no-language-page-dialog-Dj_z2_hF.js +10 -0
- package/dist/{page-creator-Bh0IUGR3.js → page-creator-DIMFISo4.js} +52 -52
- package/dist/{page-creator-BnvaGZVI.cjs → page-creator-DTC66ujU.cjs} +1 -1
- package/dist/page-lock-CI6BYvF_.cjs +1 -0
- package/dist/page-lock-DUlNr3os.js +30 -0
- package/dist/page-locked-dialog-BKwULMV7.js +133 -0
- package/dist/page-locked-dialog-DorIbva0.cjs +1 -0
- package/dist/page-manager-new-lNVrLOJp.cjs +1 -0
- package/dist/page-manager-new-znvqI9_L.js +354 -0
- package/dist/{page-manager-search-and-filter-BETHSa3y.js → page-manager-search-and-filter-C-_w7N27.js} +1 -1
- package/dist/{page-manager-search-and-filter-hyUIHOD_.cjs → page-manager-search-and-filter-pe0q0qnZ.cjs} +1 -1
- package/dist/{page-revisions-content-BCMjvZRZ.cjs → page-revisions-content-Caaj5TEI.cjs} +1 -1
- package/dist/{page-revisions-content-VWthKL7O.js → page-revisions-content-CyLjyxNU.js} +16 -16
- package/dist/pages.css +1 -1
- package/dist/publish-pages-content-Bih1W9C4.js +178 -0
- package/dist/publish-pages-content-D5beVcQI.cjs +1 -0
- package/dist/{save-to-lib-YYBxY7MV.js → save-to-lib-BwpkJcT2.js} +1 -1
- package/dist/{save-to-lib-CtGpDkC6.cjs → save-to-lib-DPAERsi4.cjs} +1 -1
- package/dist/{selected-block-display-DdW-DWF1.js → selected-block-display-GXSf3y2s.js} +1 -1
- package/dist/{selected-block-display-BEbuJn0l.cjs → selected-block-display-s99Y91qI.cjs} +1 -1
- package/dist/{seo-panel-CqJDhbj-.js → seo-panel-BurZA566.js} +61 -61
- package/dist/{seo-panel-B9P7fXjo.cjs → seo-panel-BxUfalVy.cjs} +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +39 -39
- package/dist/{shared-json-ld-CyxmC9y5.cjs → shared-json-ld-BYAdrPeC.cjs} +1 -1
- package/dist/{shared-json-ld-DxEPILj_.js → shared-json-ld-DHWdJvQd.js} +39 -39
- package/dist/{slug-input-RNiSrU3p.cjs → slug-input-CR2B1kDJ.cjs} +1 -1
- package/dist/{slug-input-j5z5ZQn9.js → slug-input-Z_ny7bgX.js} +1 -1
- package/dist/take-over-request-CnEpToCM.cjs +1 -0
- package/dist/take-over-request-DF2JsIes.js +63 -0
- package/dist/{theme-panel-footer-DD2yalfG.js → theme-panel-footer-5mxFeEua.js} +4 -4
- package/dist/{theme-panel-footer-CCsiDIVl.cjs → theme-panel-footer-C2CjHoBu.cjs} +1 -1
- package/dist/{unmark-as-template-DXjLbqOM.cjs → unmark-as-template-Dn90g1eh.cjs} +1 -1
- package/dist/{unmark-as-template-B2hKhAHn.js → unmark-as-template-JRRUYTOY.js} +1 -1
- package/dist/{unpublish-page-BdJScWMX.cjs → unpublish-page-C3C_rTRd.cjs} +1 -1
- package/dist/{unpublish-page-BvB1PGSz.js → unpublish-page-FZ8rbi7u.js} +9 -9
- package/dist/{web-preview-CwVpkcwU.js → web-preview-CGBKG162.js} +1 -1
- package/dist/{web-preview-BI4jd0O7.cjs → web-preview-NdxC92Fk.cjs} +1 -1
- package/package.json +3 -3
- package/dist/ai-panel-content-B2AgBWqo.cjs +0 -1
- package/dist/ai-panel-content-M1UnzG_f.js +0 -54
- package/dist/ai-panel-default-lang-CHOFEwmV.js +0 -313
- package/dist/ai-panel-default-lang-sy6vkQJh.cjs +0 -3
- package/dist/ai-panel-other-lang-BwjSDD3L.cjs +0 -1
- package/dist/ai-prompt-input-B_NRADBT.js +0 -988
- package/dist/ai-prompt-input-DcyVXcLG.cjs +0 -1
- package/dist/delete-page-CbY8q5M3.cjs +0 -1
- package/dist/delete-page-SX9X35nA.js +0 -40
- package/dist/index-Bz7smSC0.cjs +0 -5
- package/dist/index-EnM7J19_.js +0 -4960
- package/dist/page-lock-request-C2b1kqyA.cjs +0 -1
- package/dist/page-lock-request-CaNqxfD6.js +0 -75
- package/dist/page-locked-by-dialog--WLDdkw9.js +0 -68
- package/dist/page-locked-by-dialog-90ElC8aG.cjs +0 -1
- package/dist/page-manager-new-Bo4-zwfW.js +0 -354
- package/dist/page-manager-new-SNRQn7Az.cjs +0 -1
- package/dist/publish-pages-content-6N7aEcM1.js +0 -178
- package/dist/publish-pages-content-CaBwfekc.cjs +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./selected-block-display-BEbuJn0l.cjs"),d=require("react"),k=require("cmdk"),g=require("lucide-react"),me=require("@radix-ui/react-dialog"),pe=require("@radix-ui/react-dropdown-menu"),fe=require("@radix-ui/react-hover-card"),Y=require("class-variance-authority"),xe=require("@radix-ui/react-select"),ge=require("@chaibuilder/sdk");function O(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(a,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return a.default=t,Object.freeze(a)}const u=O(d),P=O(me),v=O(pe),F=O(fe),N=O(xe),he=P.Portal,J=u.forwardRef(({className:t,...a},s)=>e.jsx(P.Overlay,{ref:s,className:o.cn("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a}));J.displayName=P.Overlay.displayName;const be=u.forwardRef(({className:t,children:a,...s},n)=>e.jsxs(he,{children:[e.jsx(J,{}),e.jsxs(P.Content,{ref:n,className:o.cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s,children:[a,e.jsxs(P.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(g.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));be.displayName=P.Content.displayName;const ve=u.forwardRef(({className:t,...a},s)=>e.jsx(P.Title,{ref:s,className:o.cn("text-lg font-semibold leading-none tracking-tight",t),...a}));ve.displayName=P.Title.displayName;const ye=u.forwardRef(({className:t,...a},s)=>e.jsx(P.Description,{ref:s,className:o.cn("text-sm text-muted-foreground",t),...a}));ye.displayName=P.Description.displayName;const je=u.forwardRef(({className:t,...a},s)=>e.jsx(k.Command,{ref:s,className:o.cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...a}));je.displayName=k.Command.displayName;const we=u.forwardRef(({className:t,...a},s)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(g.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(k.Command.Input,{ref:s,className:o.cn("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...a})]}));we.displayName=k.Command.Input.displayName;const Ne=u.forwardRef(({className:t,...a},s)=>e.jsx(k.Command.List,{ref:s,className:o.cn("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...a}));Ne.displayName=k.Command.List.displayName;const Ie=u.forwardRef((t,a)=>e.jsx(k.Command.Empty,{ref:a,className:"py-6 text-center text-sm",...t}));Ie.displayName=k.Command.Empty.displayName;const Ce=u.forwardRef(({className:t,...a},s)=>e.jsx(k.Command.Group,{ref:s,className:o.cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...a}));Ce.displayName=k.Command.Group.displayName;const Se=u.forwardRef(({className:t,...a},s)=>e.jsx(k.Command.Separator,{ref:s,className:o.cn("-mx-1 h-px bg-border",t),...a}));Se.displayName=k.Command.Separator.displayName;const ke=u.forwardRef(({className:t,...a},s)=>e.jsx(k.Command.Item,{ref:s,className:o.cn("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t),...a}));ke.displayName=k.Command.Item.displayName;const Re=v.Root,De=v.Trigger,ze=u.forwardRef(({className:t,inset:a,children:s,...n},i)=>e.jsxs(v.SubTrigger,{ref:i,className:o.cn("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a&&"pl-8",t),...n,children:[s,e.jsx(g.ChevronRight,{className:"ml-auto"})]}));ze.displayName=v.SubTrigger.displayName;const Pe=u.forwardRef(({className:t,...a},s)=>e.jsx(v.SubContent,{ref:s,className:o.cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...a}));Pe.displayName=v.SubContent.displayName;const Q=u.forwardRef(({className:t,sideOffset:a=4,...s},n)=>e.jsx(v.Portal,{children:e.jsx(v.Content,{ref:n,sideOffset:a,className:o.cn("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...s})}));Q.displayName=v.Content.displayName;const Z=u.forwardRef(({className:t,inset:a,...s},n)=>e.jsx(v.Item,{ref:n,className:o.cn("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a&&"pl-8",t),...s}));Z.displayName=v.Item.displayName;const Te=u.forwardRef(({className:t,children:a,checked:s,...n},i)=>e.jsxs(v.CheckboxItem,{ref:i,className:o.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(v.ItemIndicator,{children:e.jsx(g.Check,{className:"h-4 w-4"})})}),a]}));Te.displayName=v.CheckboxItem.displayName;const _e=u.forwardRef(({className:t,children:a,...s},n)=>e.jsxs(v.RadioItem,{ref:n,className:o.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(v.ItemIndicator,{children:e.jsx(g.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));_e.displayName=v.RadioItem.displayName;const Ae=u.forwardRef(({className:t,inset:a,...s},n)=>e.jsx(v.Label,{ref:n,className:o.cn("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...s}));Ae.displayName=v.Label.displayName;const Le=u.forwardRef(({className:t,...a},s)=>e.jsx(v.Separator,{ref:s,className:o.cn("-mx-1 my-1 h-px bg-muted",t),...a}));Le.displayName=v.Separator.displayName;const Me=F.Root,Ue=F.Trigger,$=u.forwardRef(({className:t,align:a="center",sideOffset:s=4,...n},i)=>e.jsx(F.Content,{ref:i,align:a,sideOffset:s,className:o.cn("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-hover-card-content-transform-origin]",t),...n}));$.displayName=F.Content.displayName;const Oe=u.forwardRef(({className:t,type:a,...s},n)=>e.jsx("input",{type:a,className:o.cn("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...s}));Oe.displayName="Input";const ee=u.forwardRef(({className:t,...a},s)=>e.jsx("textarea",{className:o.cn("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:s,...a}));ee.displayName="Textarea";function qe({className:t,...a}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:o.cn("group/input-group border-input dark:bg-input/30 shadow-xs relative flex w-full items-center rounded-md border outline-none transition-[color,box-shadow]","h-9 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:ring-ring has-[[data-slot=input-group-control]:focus-visible]:ring-1","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...a})}const Ee=Y.cva("text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5","block-end":"[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function te({className:t,align:a="inline-start",...s}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":a,className:o.cn(Ee({align:a}),t),onClick:n=>{var i,y;n.target.closest("button")||(y=(i=n.currentTarget.parentElement)==null?void 0:i.querySelector("input"))==null||y.focus()},...s})}const Be=Y.cva("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function ae({className:t,type:a="button",variant:s="ghost",size:n="xs",...i}){return e.jsx(o.Button,{type:a,"data-size":n,variant:s,className:o.cn(Be({size:n}),t),...i})}function Fe({className:t,...a}){return e.jsx(ee,{"data-slot":"input-group-control",className:o.cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",t),...a})}const Ge=u.forwardRef(({className:t,children:a,...s},n)=>e.jsxs(N.Trigger,{ref:n,className:o.cn("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[a,e.jsx(N.Icon,{asChild:!0,children:e.jsx(g.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ge.displayName=N.Trigger.displayName;const se=u.forwardRef(({className:t,...a},s)=>e.jsx(N.ScrollUpButton,{ref:s,className:o.cn("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(g.ChevronUp,{className:"h-4 w-4"})}));se.displayName=N.ScrollUpButton.displayName;const ne=u.forwardRef(({className:t,...a},s)=>e.jsx(N.ScrollDownButton,{ref:s,className:o.cn("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(g.ChevronDown,{className:"h-4 w-4"})}));ne.displayName=N.ScrollDownButton.displayName;const Ve=u.forwardRef(({className:t,children:a,position:s="popper",...n},i)=>e.jsx(N.Portal,{children:e.jsxs(N.Content,{ref:i,className:o.cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,...n,children:[e.jsx(se,{}),e.jsx(N.Viewport,{className:o.cn("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),e.jsx(ne,{})]})}));Ve.displayName=N.Content.displayName;const He=u.forwardRef(({className:t,...a},s)=>e.jsx(N.Label,{ref:s,className:o.cn("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...a}));He.displayName=N.Label.displayName;const We=u.forwardRef(({className:t,children:a,...s},n)=>e.jsxs(N.Item,{ref:n,className:o.cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(N.ItemIndicator,{children:e.jsx(g.Check,{className:"h-4 w-4"})})}),e.jsx(N.ItemText,{children:a})]}));We.displayName=N.Item.displayName;const Ke=u.forwardRef(({className:t,...a},s)=>e.jsx(N.Separator,{ref:s,className:o.cn("-mx-1 my-1 h-px bg-muted",t),...a}));Ke.displayName=N.Separator.displayName;const Xe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ye=(t=21)=>{let a="",s=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)a+=Xe[s[t]&63];return a};const Je=d.createContext(null),Qe=d.createContext(null),oe=()=>d.useContext(Je),Ze=()=>d.useContext(Qe),re=d.createContext(null),G=()=>{const t=Ze(),a=d.useContext(re),s=t??a;if(!s)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return s};function $e({data:t,className:a,...s}){var S;const n=G(),i=t.filename||"",p=((S=t.mediaType)!=null&&S.startsWith("image/")&&t.url?"image":"file")==="image",w=i||(p?"Image":"Attachment");return e.jsxs(mt,{children:[e.jsx(Ue,{asChild:!0,children:e.jsxs("div",{className:o.cn("group relative flex h-8 cursor-default select-none items-center gap-1.5 rounded-md border border-border px-1.5 text-sm font-medium transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",a),...s,children:[e.jsxs("div",{className:"relative size-5 shrink-0",children:[e.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:p?e.jsx("img",{alt:i||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20}):e.jsx("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:e.jsx(g.PaperclipIcon,{className:"size-3"})})}),e.jsxs(o.Button,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:R=>{R.stopPropagation(),n.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(g.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:w})]},t.id)}),e.jsx(pt,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[p&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:i||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),e.jsx("div",{className:"flex items-center gap-2.5",children:e.jsxs("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[e.jsx("h4",{className:"truncate text-sm font-semibold leading-none",children:i||(p?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function et({children:t,className:a,...s}){const n=G();return n.files.length?e.jsx("div",{className:o.cn("flex flex-wrap items-center gap-2 p-3",a),...s,children:n.files.map(i=>e.jsx(d.Fragment,{children:t(i)},i.id))}):null}const tt=({label:t="Add photos or files",...a})=>{const s=G();return e.jsxs(Z,{...a,onSelect:n=>{n.preventDefault(),s.openFileDialog()},children:[e.jsx(g.ImageIcon,{className:"mr-2 size-4"})," ",t]})},at=({className:t,accept:a,multiple:s,globalDrop:n,syncHiddenInput:i,maxFiles:y,maxFileSize:p,onError:w,onSubmit:S,children:R,...A})=>{const l=oe(),c=!!l,h=d.useRef(null),z=d.useRef(null),C=d.useRef(null);d.useEffect(()=>{var b;const r=(b=z.current)==null?void 0:b.closest("form");r instanceof HTMLFormElement&&(C.current=r)},[]);const[D,_]=d.useState([]),I=c?l.attachments.files:D,M=d.useCallback(()=>{var r;(r=h.current)==null||r.click()},[]),q=d.useCallback(r=>!a||a.trim()===""?!0:a.includes("image/*")?r.type.startsWith("image/"):!0,[a]),E=d.useCallback(r=>{const b=Array.from(r),x=b.filter(j=>q(j));if(b.length&&x.length===0){w==null||w({code:"accept",message:"No files match the accepted types."});return}const f=j=>p?j.size<=p:!0,m=x.filter(f);if(x.length>0&&m.length===0){w==null||w({code:"max_file_size",message:"All files exceed the maximum size."});return}_(j=>{const L=typeof y=="number"?Math.max(0,y-j.length):void 0,ue=typeof L=="number"?m.slice(0,L):m;typeof L=="number"&&m.length>L&&(w==null||w({code:"max_files",message:"Too many files. Some were not added."}));const X=[];for(const V of ue)X.push({id:Ye(),type:"file",url:URL.createObjectURL(V),mediaType:V.type,filename:V.name});return j.concat(X)})},[q,y,p,w]),T=c?r=>l.attachments.add(r):E,U=c?r=>l.attachments.remove(r):r=>_(b=>{const x=b.find(f=>f.id===r);return x!=null&&x.url&&URL.revokeObjectURL(x.url),b.filter(f=>f.id!==r)}),B=c?()=>l.attachments.clear():()=>_(r=>{for(const b of r)b.url&&URL.revokeObjectURL(b.url);return[]}),W=c?()=>l.attachments.openFileDialog():M;d.useEffect(()=>{c&&l.__registerFileInput(h,()=>{var r;return(r=h.current)==null?void 0:r.click()})},[c,l]),d.useEffect(()=>{i&&h.current&&I.length===0&&(h.current.value="")},[I,i]),d.useEffect(()=>{const r=C.current;if(!r)return;const b=f=>{var m,j;(j=(m=f.dataTransfer)==null?void 0:m.types)!=null&&j.includes("Files")&&f.preventDefault()},x=f=>{var m,j,L;(j=(m=f.dataTransfer)==null?void 0:m.types)!=null&&j.includes("Files")&&f.preventDefault(),(L=f.dataTransfer)!=null&&L.files&&f.dataTransfer.files.length>0&&T(f.dataTransfer.files)};return r.addEventListener("dragover",b),r.addEventListener("drop",x),()=>{r.removeEventListener("dragover",b),r.removeEventListener("drop",x)}},[T]),d.useEffect(()=>{if(!n)return;const r=x=>{var f,m;(m=(f=x.dataTransfer)==null?void 0:f.types)!=null&&m.includes("Files")&&x.preventDefault()},b=x=>{var f,m,j;(m=(f=x.dataTransfer)==null?void 0:f.types)!=null&&m.includes("Files")&&x.preventDefault(),(j=x.dataTransfer)!=null&&j.files&&x.dataTransfer.files.length>0&&T(x.dataTransfer.files)};return document.addEventListener("dragover",r),document.addEventListener("drop",b),()=>{document.removeEventListener("dragover",r),document.removeEventListener("drop",b)}},[T,n]),d.useEffect(()=>()=>{if(!c)for(const r of I)r.url&&URL.revokeObjectURL(r.url)},[c,I]);const ie=r=>{r.currentTarget.files&&T(r.currentTarget.files)},le=async r=>{const x=await(await fetch(r)).blob();return new Promise((f,m)=>{const j=new FileReader;j.onloadend=()=>f(j.result),j.onerror=m,j.readAsDataURL(x)})},ce=d.useMemo(()=>({files:I.map(r=>({...r,id:r.id})),add:T,remove:U,clear:B,openFileDialog:W,fileInputRef:h}),[I,T,U,B,W]),de=r=>{r.preventDefault();const b=r.currentTarget,x=c?l.textInput.value:new FormData(b).get("message")||"";c||b.reset(),Promise.all(I.map(async({id:f,...m})=>m.url&&m.url.startsWith("blob:")?{...m,url:await le(m.url)}:m)).then(f=>{try{const m=S({text:x,files:f},r);m instanceof Promise?m.then(()=>{B(),c&&l.textInput.clear()}).catch(()=>{}):(B(),c&&l.textInput.clear())}catch{}})},K=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:z}),e.jsx("input",{accept:a,"aria-label":"Upload files",className:"hidden",multiple:s,onChange:ie,ref:h,title:"Upload files",type:"file"}),e.jsx("form",{className:o.cn("w-full",t),onSubmit:de,...A,children:e.jsx(qe,{className:"overflow-hidden",children:R})})]});return c?K:e.jsx(re.Provider,{value:ce,children:K})},st=({onChange:t,className:a,placeholder:s="What would you like to know?",...n})=>{const i=oe(),y=G(),[p,w]=d.useState(!1),S=l=>{if(l.key==="Enter"){if(p||l.nativeEvent.isComposing||l.shiftKey)return;l.preventDefault();const c=l.currentTarget.form,h=c==null?void 0:c.querySelector('button[type="submit"]');if(h!=null&&h.disabled)return;c==null||c.requestSubmit()}if(l.key==="Backspace"&&l.currentTarget.value===""&&y.files.length>0){l.preventDefault();const c=y.files.at(-1);c&&y.remove(c.id)}},R=l=>{var z;const c=(z=l.clipboardData)==null?void 0:z.items;if(!c)return;const h=[];for(const C of c)if(C.kind==="file"){const D=C.getAsFile();D&&h.push(D)}h.length>0&&(l.preventDefault(),y.add(h))},A=i?{value:i.textInput.value,onChange:l=>{i.textInput.setInput(l.currentTarget.value),t==null||t(l)}}:{onChange:t};return e.jsx(Fe,{className:o.cn("field-sizing-content max-h-48 min-h-16",a),name:"message",onCompositionEnd:()=>w(!1),onCompositionStart:()=>w(!0),onKeyDown:S,onPaste:R,placeholder:s,...n,...A})},nt=({className:t,...a})=>e.jsx(te,{align:"block-end",className:o.cn("order-first flex-wrap gap-1",t),...a}),ot=({className:t,...a})=>e.jsx(te,{align:"block-end",className:o.cn("justify-between gap-1",t),...a}),rt=({className:t,...a})=>e.jsx("div",{className:o.cn("flex items-center gap-1",t),...a}),H=({variant:t="ghost",className:a,size:s,...n})=>{const i=s??(d.Children.count(n.children)>1?"sm":"icon-sm");return e.jsx(ae,{className:o.cn(a),size:i,type:"button",variant:t,...n})},it=t=>e.jsx(Re,{...t}),lt=({className:t,children:a,...s})=>e.jsx(De,{asChild:!0,children:e.jsx(H,{className:t,...s,children:a??e.jsx(g.PlusIcon,{className:"size-4"})})}),ct=({className:t,...a})=>e.jsx(Q,{align:"start",className:o.cn(t),...a}),dt=({className:t,variant:a="default",size:s="icon-sm",status:n,children:i,...y})=>{let p=e.jsx(g.CornerDownLeftIcon,{className:"size-4"});return n==="submitted"?p=e.jsx(g.Loader2Icon,{className:"size-4 animate-spin"}):n==="streaming"?p=e.jsx(g.SquareIcon,{className:"size-4"}):n==="error"&&(p=e.jsx(g.XIcon,{className:"size-4"})),e.jsx(ae,{"aria-label":"Submit",className:o.cn(t),size:s,type:"submit",variant:a,...y,children:i??p})},ut=({className:t,textareaRef:a,onTranscriptionChange:s,...n})=>{const[i,y]=d.useState(!1),[p,w]=d.useState(null),S=d.useRef(null);d.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const A=window.SpeechRecognition||window.webkitSpeechRecognition,l=new A;l.continuous=!0,l.interimResults=!0,l.lang="en-US",l.onstart=()=>{y(!0)},l.onend=()=>{y(!1)},l.onresult=c=>{var z;let h="";for(let C=c.resultIndex;C<c.results.length;C++){const D=c.results[C];D.isFinal&&(h+=((z=D[0])==null?void 0:z.transcript)??"")}if(h&&(a!=null&&a.current)){const C=a.current,D=C.value,_=D+(D?" ":"")+h;C.value=_,C.dispatchEvent(new Event("input",{bubbles:!0})),s==null||s(_)}},l.onerror=c=>{console.error("Speech recognition error:",c.error),y(!1)},S.current=l,w(l)}return()=>{S.current&&S.current.stop()}},[a,s]);const R=d.useCallback(()=>{p&&(i?p.stop():p.start())},[p,i]);return e.jsx(H,{className:o.cn("relative transition-all duration-200",i&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!p,onClick:R,...n,children:e.jsx(g.MicIcon,{className:"size-4"})})},mt=({openDelay:t=0,closeDelay:a=0,...s})=>e.jsx(Me,{closeDelay:a,openDelay:t,...s}),pt=({align:t="start",...a})=>e.jsx($,{align:t,...a}),ft="chai-ai-selected-model",xt=({input:t,setInput:a,onSend:s,onStop:n,isLoading:i,disabled:y,selectedLang:p,selectedModel:w="google/gemini-2.5-flash",onModelChange:S})=>{const{t:R}=ge.useTranslation(),[A,l]=d.useState(w),[c,h]=d.useState(null),z=d.useRef(null),[C,D]=d.useState(!1);d.useEffect(()=>{if(!p){const I=localStorage.getItem(ft);I&&(l(I),S==null||S(I))}},[p,S]);const _=I=>{var E;const M=I.files.find(T=>{var U;return(U=T.mediaType)==null?void 0:U.startsWith("image/")}),q=(M==null?void 0:M.url)||c;s((E=I.text)==null?void 0:E.trim(),void 0,q,A),h(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(at,{onSubmit:_,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(nt,{className:"p-0",children:e.jsx(et,{className:"pb-0",children:I=>e.jsx($e,{className:"text-xs",data:I})})}),e.jsx(st,{ref:z,value:t,onChange:I=>a(I.target.value),placeholder:R(p?"Ask to update content":"Ask me anything..."),disabled:i,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(ot,{children:[p?e.jsx("div",{}):e.jsxs(rt,{children:[e.jsxs(it,{children:[e.jsx(lt,{disabled:i,children:e.jsx(g.Paperclip,{size:16})}),e.jsx(ct,{children:e.jsx(tt,{})})]}),e.jsx(ut,{textareaRef:z,onTranscriptionChange:a,disabled:i}),e.jsxs(H,{className:"hidden",size:"sm",onClick:()=>D(!C),variant:C?"default":"ghost",children:[e.jsx(g.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),i?e.jsxs("button",{onClick:n,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:R("Stop generation"),children:[e.jsx(g.Square,{size:16})," ",e.jsx("span",{className:"text-xs",children:R("Stop")})]}):e.jsx(dt,{disabled:!t.trim()||y,children:e.jsx(g.Send,{size:16})})]})]})})})};exports.default=xt;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),r=require("./index-Bz7smSC0.cjs"),c=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),y=require("lodash-es");function S({page:e,onClose:l}){const{t}=c.useTranslation(),[,d]=r.useSearchParams(),{mutate:u,isPending:a}=r.useDeletePage(),{data:o}=r.usePageTypes(),{setSelectedLang:h,fallbackLang:m}=c.useLanguages(),[,x]=c.useSidebarActivePanel(),P=()=>{a||u(e,{onSuccess:()=>{e!=null&&e.primaryPage?(window.history.replaceState({},"",`/?page=${e.primaryPage}`),d(new URLSearchParams({page:e.primaryPage}))):(window.history.replaceState({},"","/"),d(new URLSearchParams)),window.dispatchEvent(new PopStateEvent("popstate")),h(m),x("outline"),l()}})},i=o==null?void 0:o.find(D=>D.key===(e==null?void 0:e.pageType));return n.jsx(s.Dialog,{open:!!e,onOpenChange:l,children:n.jsxs(s.DialogContent,{children:[n.jsxs(s.DialogHeader,{children:[n.jsx(s.DialogTitle,{children:t("Confirm Deletion")}),n.jsxs(s.DialogDescription,{className:"py-4 text-slate-500",children:[n.jsxs("div",{children:[t("Are you sure you want to remove")," ",n.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)})," ",i!=null&&i.hasSlug?(i==null?void 0:i.name)+"?":`${t("page?")} ${e!=null&&e.primaryPage?"":t("This will also delete all associated language pages.")}`]}),e.lang&&n.jsxs("div",{className:"py-2 text-sm",children:[t("Language"),": ",n.jsx("span",{className:"font-medium text-gray-500",children:y.get(r.LANGUAGES,e.lang,e.lang)})]})]})]}),n.jsxs(s.DialogFooter,{children:[n.jsx(s.Button,{variant:"outline",onClick:l,children:t("Cancel")}),n.jsx(s.Button,{variant:"destructive",disabled:a,onClick:P,children:t(a?"Deleting...":"Delete")})]})]})})}exports.default=S;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { jsx as i, jsxs as r } from "react/jsx-runtime";
|
|
2
|
-
import { i as f, m as w, h as y, L as S } from "./index-EnM7J19_.js";
|
|
3
|
-
import { useTranslation as v, useLanguages as L, useSidebarActivePanel as x } from "@chaibuilder/sdk";
|
|
4
|
-
import { Dialog as A, DialogContent as k, DialogHeader as C, DialogTitle as N, DialogDescription as g, DialogFooter as E, Button as c } from "@chaibuilder/sdk/ui";
|
|
5
|
-
import { get as U } from "lodash-es";
|
|
6
|
-
function F({ page: e, onClose: a }) {
|
|
7
|
-
const { t } = v(), [, o] = f(), { mutate: d, isPending: l } = w(), { data: s } = y(), { setSelectedLang: m, fallbackLang: u } = L(), [, h] = x(), P = () => {
|
|
8
|
-
l || d(e, {
|
|
9
|
-
onSuccess: () => {
|
|
10
|
-
e != null && e.primaryPage ? (window.history.replaceState({}, "", `/?page=${e.primaryPage}`), o(new URLSearchParams({ page: e.primaryPage }))) : (window.history.replaceState({}, "", "/"), o(new URLSearchParams())), window.dispatchEvent(new PopStateEvent("popstate")), m(u), h("outline"), a();
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
}, n = s == null ? void 0 : s.find((D) => D.key === (e == null ? void 0 : e.pageType));
|
|
14
|
-
return /* @__PURE__ */ i(A, { open: !!e, onOpenChange: a, children: /* @__PURE__ */ r(k, { children: [
|
|
15
|
-
/* @__PURE__ */ r(C, { children: [
|
|
16
|
-
/* @__PURE__ */ i(N, { children: t("Confirm Deletion") }),
|
|
17
|
-
/* @__PURE__ */ r(g, { className: "py-4 text-slate-500", children: [
|
|
18
|
-
/* @__PURE__ */ r("div", { children: [
|
|
19
|
-
t("Are you sure you want to remove"),
|
|
20
|
-
" ",
|
|
21
|
-
/* @__PURE__ */ i("b", { children: (e == null ? void 0 : e.name) ?? (e == null ? void 0 : e.slug) }),
|
|
22
|
-
" ",
|
|
23
|
-
n != null && n.hasSlug ? (n == null ? void 0 : n.name) + "?" : `${t("page?")} ${e != null && e.primaryPage ? "" : t("This will also delete all associated language pages.")}`
|
|
24
|
-
] }),
|
|
25
|
-
e.lang && /* @__PURE__ */ r("div", { className: "py-2 text-sm", children: [
|
|
26
|
-
t("Language"),
|
|
27
|
-
": ",
|
|
28
|
-
/* @__PURE__ */ i("span", { className: "font-medium text-gray-500", children: U(S, e.lang, e.lang) })
|
|
29
|
-
] })
|
|
30
|
-
] })
|
|
31
|
-
] }),
|
|
32
|
-
/* @__PURE__ */ r(E, { children: [
|
|
33
|
-
/* @__PURE__ */ i(c, { variant: "outline", onClick: a, children: t("Cancel") }),
|
|
34
|
-
/* @__PURE__ */ i(c, { variant: "destructive", disabled: l, onClick: P, children: t(l ? "Deleting..." : "Delete") })
|
|
35
|
-
] })
|
|
36
|
-
] }) });
|
|
37
|
-
}
|
|
38
|
-
export {
|
|
39
|
-
F as default
|
|
40
|
-
};
|
package/dist/index-Bz7smSC0.cjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";var Wn=Object.defineProperty;var Es=e=>{throw TypeError(e)};var Yn=(e,t,s)=>t in e?Wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var he=(e,t,s)=>Yn(e,typeof t!="symbol"?t+"":t,s),ps=(e,t,s)=>t.has(e)||Es("Cannot "+s);var w=(e,t,s)=>(ps(e,t,"read from private field"),s?s.call(e):t.get(e)),M=(e,t,s)=>t.has(e)?Es("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),R=(e,t,s,n)=>(ps(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);const o=require("react/jsx-runtime"),p=require("lodash-es"),h=require("react"),V=require("jotai"),T=require("@tanstack/react-query"),v=require("@chaibuilder/sdk"),q=require("sonner"),m=require("@chaibuilder/sdk/ui"),b=require("lucide-react"),js=require("@chaibuilder/runtime"),Jn=require("@chaibuilder/sdk/web-blocks");function Zn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const z=Zn(h),y={GET_GLOBAL_JSONLD_ITEMS:"GET_GLOBAL_JSONLD_ITEMS",GENERATE_SEO_FIELD:"GENERATE_SEO_FIELD",UPDATE_PAGE_METADATA:"UPDATE_PAGE_METADATA",GET_BLOCK_ASYNC_PROPS:"GET_BLOCK_ASYNC_PROPS",ASK_AI:"ASK_AI",GET_DRAFT_PAGE:"GET_DRAFT_PAGE",CREATE_PAGE:"CREATE_PAGE",UPDATE_PAGE:"UPDATE_PAGE",DELETE_PAGE:"DELETE_PAGE",DUPLICATE_PAGE:"DUPLICATE_PAGE",CHANGE_SLUG:"CHANGE_SLUG",TAKE_OFFLINE:"TAKE_OFFLINE",PUBLISH_PAGE:"PUBLISH_PAGE",PUBLISH_CHANGES:"PUBLISH_CHANGES",ADD_NEW_LANGUAGE:"ADD_NEW_LANGUAGE",EDIT_LANGUAGE:"EDIT_LANGUAGE",DELETE_LANGUAGE:"DELETE_LANGUAGE",GET_CHANGES:"GET_CHANGES",GET_SERVER_BLOCK:"GET_SERVER_BLOCK",GET_LANGUAGE_PAGES:"GET_LANGUAGE_PAGES",GET_PROJECT_PAGES:"GET_PROJECT_PAGES",GET_WEBSITE_PAGES:"GET_WEBSITE_PAGES",UPDATE_WEBSITE_SETTINGS:"UPDATE_WEBSITE_SETTINGS",GET_COLLECTIONS:"GET_COLLECTIONS",GET_PAGE_TYPES:"GET_PAGE_TYPES",SEARCH_PAGES:"SEARCH_PAGES",GET_WEBSITE_DRAFT_SETTINGS:"GET_WEBSITE_DRAFT_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",UPDATE_WEBSITE_DATA:"UPDATE_WEBSITE_DATA",GET_CHAI_USER:"GET_CHAI_USER",GET_SEO_FIELDS:"GET_SEO_FIELDS",GET_BUILDER_PAGE_DATA:"GET_BUILDER_PAGE_DATA",GET_PAGE_REVISIONS:"GET_PAGE_REVISIONS",DELETE_PAGE_REVISION:"DELETE_PAGE_REVISION",RESTORE_PAGE_REVISION:"RESTORE_PAGE_REVISION",GET_REVISION_DATA:"GET_REVISION_DATA",GET_PAGE_DATA:"GET_PAGE_DATA",GET_COMPARE_DATA:"GET_COMPARE_DATA",GET_ROLE_AND_PERMISSIONS:"GET_ROLE_AND_PERMISSIONS",UPSERT_LIBRARY_ITEM:"UPSERT_LIBRARY_ITEM",GET_LIBRARIES:"GET_LIBRARIES",GET_LIBRARY_ITEM:"GET_LIBRARY_ITEM",GET_LIBRARY_ITEMS:"GET_LIBRARY_ITEMS",DELETE_LIBRARY_ITEM:"DELETE_LIBRARY_ITEM",MARK_AS_TEMPLATE:"MARK_AS_TEMPLATE",UNMARK_AS_TEMPLATE:"UNMARK_AS_TEMPLATE",GET_TEMPLATES_BY_TYPE:"GET_TEMPLATES_BY_TYPE",GET_DYNAMIC_PAGES:"GET_DYNAMIC_PAGES",GET_APP_SHARED_JSONLD:"GET_APP_SHARED_JSONLD",UPDATE_APP_SHARED_JSONLD:"UPDATE_APP_SHARED_JSONLD",ADD_GLOBAL_SCHEMA:"ADD_GLOBAL_SCHEMA",UPDATE_GLOBAL_SCHEMA:"UPDATE_GLOBAL_SCHEMA",DELETE_GLOBAL_SCHEMA:"DELETE_GLOBAL_SCHEMA",TOGGLE_PAGE_GLOBAL_SCHEMA:"TOGGLE_PAGE_GLOBAL_SCHEMA",APPLY_SCHEMA_TO_ALL_PAGES:"APPLY_SCHEMA_TO_ALL_PAGES",REMOVE_SCHEMA_FROM_ALL_PAGES:"REMOVE_SCHEMA_FROM_ALL_PAGES",UPLOAD_ASSET:"UPLOAD_ASSET",DELETE_ASSET:"DELETE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",GET_ASSETS:"GET_ASSETS",GET_ASSET:"GET_ASSET"},Xn=V.atom({}),jt=()=>V.useAtom(Xn),se=(e,t)=>{const[s]=jt();return h.useMemo(()=>p.get(s,e,t),[s,e,t])},D=()=>se("apiUrl","/chai/api"),ks=()=>se("usersApiUrl","/chai/users"),er=()=>se("assetsApiUrl","/chai/assets"),tr=()=>se("websocket",null),sr=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),nr=()=>{const e=k(),t=D();return h.useCallback(async({body:s,headers:n={},url:r=t,streamResponse:a=!1})=>e(r,s,n,a),[e])},k=()=>{const e=se("onLogout"),t=se("getAccessToken"),s=D();return h.useCallback(async(n=s,r,a={},i=!1)=>{const l=await t();if(!l)return console.error("No auth token found"),null;try{const c=p.get(r,"action","").toLowerCase(),u=await sr(n+(c?`?action=${c}`:""),r,{...a,Authorization:`Bearer ${l}`});if(i)return u;if(u.status===401)return console.log("401 Response",u),e(),window.location.reload(),null;if(!u.ok){const d=await u.json();throw console.error(`API Error (${u.status}):`,d),{status:u.status,statusText:u.statusText,...d,message:d.error||d.message||`Server error: ${u.status}`}}return await u.json()}catch(c){throw console.error("API request failed:",r,c),c}},[e,t])};function ee(){const[e,t]=h.useState(new URLSearchParams(window.location.search));return h.useEffect(()=>{const s=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[]),[e,t]}const pe=e=>{const t=D(),[s]=ee(),n=e??s.get("page"),r=k();return T.useQuery({queryKey:[y.GET_LANGUAGE_PAGES,n],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!n)return null;const a=await r(t,{action:y.GET_LANGUAGE_PAGES,data:{id:n}});return p.reverse(p.sortBy(a,"primaryPage"))},enabled:!!n})},ye=()=>{const e=D(),t=k();return T.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:5*60*1e3,placeholderData:{languages:[],theme:{fontFamily:"",borderRadius:"",colors:{}},appKey:"",fallbackLang:""},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})},ts=e=>{const{fallbackLang:t}=v.useLanguages(),{data:s}=ye(),{data:n,isFetching:r}=pe(),a=h.useMemo(()=>{const i={[t]:!0};return p.each(p.get(s,"languages"),l=>{const c=p.find(n,{lang:l});i[l]=!!c}),i},[t,n,s]);return r||p.isEmpty(e)||e&&a[e]};class Ds{constructor(t,s,n,r){he(this,"channelId");he(this,"websocket");he(this,"channel",null);he(this,"userId",null);he(this,"clientId",null);he(this,"pageId",null);he(this,"callback");var a,i,l,c,u,d;this.userId=n,this.websocket=t,this.clientId=this.getClientId(),this.channelId=`WEBSITE:${s}`,this.callback=r,this.channel=this.websocket.channel(this.channelId,{config:{presence:{key:this.clientId}}}),(d=(u=(c=(l=(i=(a=this.channel)==null?void 0:a.on("presence",{event:"sync"},f=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",f)}))==null?void 0:i.on("presence",{event:"leave"},f=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",f)}))==null?void 0:l.on("presence",{event:"join"},f=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",f)}))==null?void 0:c.on("broadcast",{event:"TAKE_OVER_REQUESTED"},({payload:f})=>this.onReceiveEvent("TAKE_OVER_REQUESTED",f)))==null?void 0:u.on("broadcast",{event:"TAKE_OVER_REQUEST_ACCEPTED"},({payload:f})=>this.onReceiveEvent("TAKE_OVER_REQUEST_ACCEPTED",f)))==null||d.on("broadcast",{event:"TAKE_OVER_REQUEST_REJECTED"},({payload:f})=>this.onReceiveEvent("TAKE_OVER_REQUEST_REJECTED",f)).subscribe()}getClientId(){return crypto.randomUUID()}getOnlineUsers({pageId:t,userId:s}){var a;const n=(a=this.channel)==null?void 0:a.presenceState();let r=Object.values(n||{}).map(i=>i[0]).filter(Boolean);return t?r=r.filter(i=>i.pageId===t):s&&(r=r.filter(i=>i.userId===s)),r.sort((i,l)=>i.onlineAt-l.onlineAt)}getPageOwner(){const t=this.getOnlineUsers({pageId:this.pageId});return t.length>0?t[0]:null}getPageUserMapping(){const t=this.getOnlineUsers({}),s=p.groupBy(t,"pageId"),n={};return Object.keys(s).forEach(r=>{var i;const a=(i=p.minBy(s[r],"onlineAt"))==null?void 0:i.userId;a!==this.userId&&(n[r]=a)}),n}onReceiveEvent(t,s){if(!this.pageId)return;const n=this.getPageOwner();if(!n||n.clientId===this.clientId?this.callback("USER_JOINED",{isActiveInOtherTab:!1}):this.callback("PAGE_LOCKED",{isActiveInOtherTab:(n==null?void 0:n.userId)===this.userId&&(n==null?void 0:n.clientId)!==this.clientId}),s.targetClientId===this.clientId)switch(t){case"TAKE_OVER_REQUESTED":this.callback("TAKE_OVER_REQUESTED",{requestedBy:s==null?void 0:s.userId,requestingClientId:s==null?void 0:s.senderClientId,isRequestedFromAnotherTab:(s==null?void 0:s.senderClientId)!==this.clientId&&(s==null?void 0:s.userId)===this.userId});break;case"TAKE_OVER_REQUEST_ACCEPTED":this.channel.track({pageId:this.pageId,userId:this.userId,clientId:this.clientId,onlineAt:n?n.onlineAt-10:+new Date}),this.callback("TAKE_OVER_REQUEST_ACCEPTED",{isTakingOverFromAnotherTab:(s==null?void 0:s.senderClientId)!==this.clientId&&(s==null?void 0:s.userId)===this.userId});break;case"TAKE_OVER_REQUEST_REJECTED":this.callback("TAKE_OVER_REQUEST_REJECTED");break}}async joinPage(t){var s;this.pageId=t,(s=this.channel)==null||s.track({pageId:this.pageId,userId:this.userId,clientId:this.clientId,onlineAt:+new Date})}async leavePage(){var t;this.channel&&((t=this.channel)==null||t.untrack())}async sendEvent(t,s){var n,r;if(this.channel){const a={pageId:this.pageId,userId:this.userId,senderClientId:this.clientId};t==="TAKE_OVER_REQUESTED"?a.targetClientId=(n=this.getPageOwner())==null?void 0:n.clientId:(t==="TAKE_OVER_REQUEST_ACCEPTED"||t==="TAKE_OVER_REQUEST_REJECTED")&&(a.targetClientId=s==null?void 0:s.requestingClientId),await((r=this.channel)==null?void 0:r.send({event:t,payload:a,type:"broadcast"}))}}}const rr=V.atom(null),Os=()=>V.useAtom(rr),ss=()=>{const[e]=Os();return(e==null?void 0:e.slug)||""};function ar(e,t){const[s,n]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const ir=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=v.useLanguages(),{data:r}=Z(),a=r==null?void 0:r.pageType,i=D(),l=k(),{data:c,isFetching:u}=T.useQuery({queryKey:[y.GET_DYNAMIC_PAGES,e,a,t],staleTime:60*60*1e3,placeholderData:[],queryFn:async()=>await l(i,{action:y.GET_DYNAMIC_PAGES,data:{query:e,pageType:a,uuid:t}})||[],enabled:!!a}),d=h.useMemo(()=>s===""?c.filter(f=>f.lang===""||f.lang===n):c.filter(f=>f.lang===s),[s,n,c]);return{allLangPages:c,data:d,isFetching:u}},Gs=()=>{const{selectedLang:e,fallbackLang:t}=v.useLanguages(),[s,n]=Os(),[r,a]=h.useState(""),i=ar(r,500),{allLangPages:l,data:c,isFetching:u}=ir({query:i}),d=h.useCallback(E=>n(E),[n]),f=h.useCallback(E=>a(E),[a]),g=h.useCallback(()=>{if(!s)return;const E=!(s!=null&&s.primaryPage),A=e.length===0,_=E?s==null?void 0:s.id:s==null?void 0:s.primaryPage,x=l.filter(S=>(S==null?void 0:S.primaryPage)===_||S.id===_).find(S=>A?S.lang===e||S.lang===t:S.lang===e);n(x||s)},[s,e,l,n,t]);return{isFetching:u,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:d,updateSearchQuery:f,onChangeLanguage:g}},or=V.atom({lastSaved:void 0}),kt=()=>V.useAtom(or),Z=()=>{const[e]=ee(),t=e.get("page"),{data:s,isFetching:n}=pe();return{data:h.useMemo(()=>({...p.find(s,{id:t})||{}}),[s,t]),isFetching:n}},ue=()=>{const[e]=ee(),t=e.get("lang")??"",{data:s,isFetching:n}=pe();return{data:h.useMemo(()=>p.find(s,{lang:t})||{},[s,t]),isFetching:n}},lr=V.atom({}),cr=()=>V.useAtom(lr),ur=()=>{const{data:e}=ue(),t=ss(),s=se("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},gt=()=>{const e=se("currentUser"),t=se("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},Rs=e=>{const t=ks(),s=k();return T.useQuery({queryKey:[y.GET_CHAI_USER,e],queryFn:async()=>{const r=await s(t,{action:y.GET_CHAI_USER,data:{userId:e}});return{...r,name:r.name||r.email}},enabled:!p.isEmpty(e),staleTime:"static"})},dr=V.atom({status:"checking",requestedBy:"",isTakeOverRequested:!1,requestingClientId:"",isActiveInOtherTab:!1}),fr=V.atom(""),hr=V.atom(null),ns=V.atom({}),gr=()=>V.useAtom(ns),Ae=()=>{const[e]=ee(),t=e.get("page"),[s,n]=V.useAtom(dr),[r,a]=V.useAtom(hr),[i,l]=V.useAtom(fr),[c]=V.useAtom(ns);return{pageLock:s,pageToUser:c,lockingStatus:i,realtimeInstance:r,setPageLock:n,setLockingStatus:l,setRealtimeInstance:a,realtimePageLockEnabled:!!r,currentEditor:c[t||""],isLocked:t&&s.status==="locked"}},mr=()=>{const e=tr(),{data:t}=Z(),{user:s}=gt(),n=t==null?void 0:t.id,{data:r}=ye(),{pageLock:a,setPageLock:i,setLockingStatus:l,realtimeInstance:c,setRealtimeInstance:u}=Ae(),[,d]=V.useAtom(ns),f=h.useRef(!1),g=h.useRef(a),E=h.useRef(!1);return h.useEffect(()=>{if(s!=null&&s.id&&e&&!c&&(r!=null&&r.appKey)&&!E.current){E.current=!0;const A=async(C,x)=>{var S,P;switch(C){case"UPDATE_ONLINE_USERS":d((x==null?void 0:x.pageToUser)||{});break;case"PAGE_LOCKED":i({...g==null?void 0:g.current,requestedBy:"",status:"locked",isActiveInOtherTab:x==null?void 0:x.isActiveInOtherTab});break;case"USER_JOINED":if(((S=g==null?void 0:g.current)==null?void 0:S.status)==="editing")return;((P=g==null?void 0:g.current)==null?void 0:P.status)==="locked"&&l("can_edit_now"),i({...g==null?void 0:g.current,requestedBy:"",status:"editing",isActiveInOtherTab:x==null?void 0:x.isActiveInOtherTab});break;case"TAKE_OVER_REQUESTED":i({...g==null?void 0:g.current,requestingClientId:x==null?void 0:x.requestingClientId,requestedBy:x!=null&&x.isRequestedFromAnotherTab?"ANOTHER_TAB":x==null?void 0:x.requestedBy});break;case"TAKE_OVER_REQUEST_ACCEPTED":x!=null&&x.isTakingOverFromAnotherTab||(l("take_over_request_accepted"),q.toast.success("Your Page Take Over Request Accepted",{position:"top-center"})),i({...g==null?void 0:g.current,status:"editing",requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break;case"TAKE_OVER_REQUEST_REJECTED":l("take_over_request_rejected"),i({...g==null?void 0:g.current,requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break}},_=new Ds(e,r==null?void 0:r.appKey,s==null?void 0:s.id,A);u(_)}},[u,e,r==null?void 0:r.appKey]),h.useEffect(()=>{g.current=a},[a]),h.useEffect(()=>{if(!(!c||!n||!(s!=null&&s.id)||f.current))return f.current=!0,c==null||c.joinPage(n),()=>{c&&f.current&&(f.current=!1,g.current={requestedBy:"",status:"checking",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1},l(""),i(g.current),c==null||c.leavePage())}},[n,c]),a==null?void 0:a.status},Ms=()=>{const{data:e}=Z(),{user:t}=gt(),s=e==null?void 0:e.id,{pageLock:n,setPageLock:r,realtimeInstance:a}=Ae(),{savePageAsync:i}=v.useSavePage(),l=h.useCallback(()=>{!a||!s||!(t!=null&&t.id)||(r({...n,isTakeOverRequested:!0}),a==null||a.sendEvent("TAKE_OVER_REQUESTED"))},[a,s,t==null?void 0:t.id,r,n]),c=h.useCallback(async()=>{!a||!s||!(t!=null&&t.id)||(await i(),a==null||a.sendEvent("TAKE_OVER_REQUEST_ACCEPTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({requestedBy:"",status:"locked",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,a,t==null?void 0:t.id,r,i,n]),u=h.useCallback(()=>{!a||!s||!(t!=null&&t.id)||(a==null||a.sendEvent("TAKE_OVER_REQUEST_REJECTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({...n,requestedBy:"",status:"editing",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,a,t==null?void 0:t.id,r,n]);return{pageLock:n,acceptTakeOver:c,rejectTakeOver:u,requestTakeOver:l}},Er=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content-Bk4fEx_p.cjs"))),pr=h.lazy(()=>Promise.resolve().then(()=>require("./page-locked-by-dialog-90ElC8aG.cjs"))),Ut=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-request-C2b1kqyA.cjs"))),yr=({isFetchingPage:e})=>{const{pageLock:t,requestTakeOver:s}=Ms(),{currentEditor:n,lockingStatus:r,setLockingStatus:a,realtimePageLockEnabled:i}=Ae(),{data:l,isFetching:c}=Rs(n),[u]=ee(),d=u.get("page"),[f]=kt(),g=T.useQueryClient(),E=h.useCallback(()=>{s()},[s]);return!d||e||!i||(t==null?void 0:t.status)==="checking"?null:t!=null&&t.requestedBy?o.jsx(h.Suspense,{children:o.jsx(Ut,{lockingStatus:"",onContinue:()=>{s()}})}):(t==null?void 0:t.status)!=="locked"?r==="take_over_request_accepted"||r==="can_edit_now"?o.jsx(h.Suspense,{children:o.jsx(Ut,{lockingStatus:r,onContinue:()=>{g.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),a("")}})}):null:t!=null&&t.isActiveInOtherTab?o.jsx(h.Suspense,{children:o.jsx(Ut,{lockingStatus:"page_is_active_in_other_tab",onContinue:s})}):o.jsx(h.Suspense,{children:o.jsx(pr,{...l,isFetchingUserInfo:c,name:(l==null?void 0:l.name)||"Unknown User",email:(l==null?void 0:l.email)||"",lastSaved:(f==null?void 0:f.lastSaved)||"",onTakeOver:E,realtimePageLockEnabled:i,isRequestRejected:r==="take_over_request_rejected"})})},Ar=()=>{const[e]=ee(),t=e.get("lang");return ts(t)?null:o.jsx(h.Suspense,{children:o.jsx(Er,{})})},Ve={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"};function rs(e,t,s=!1){const n=e.toString()?`?${e.toString()}`:"/";s?window.history.replaceState(null,"",n):window.history.pushState({},"",n),t(e),window.dispatchEvent(new PopStateEvent("popstate"))}const Dt=V.atom(null),Ot=()=>{const{data:e}=ye();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},as=()=>{const e=k(),t=D();return T.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},Sr=e=>{const t=k(),s=D(),n=Ot();return T.useQuery({queryKey:[y.GET_WEBSITE_PAGES,e,n],staleTime:1e3*60*5,enabled:!!e,queryFn:async()=>{if(n===e)return{};const r=await t(s,{action:y.GET_WEBSITE_PAGES,data:{lang:e}})||[];return p.keyBy(p.map(r,a=>({...a,lang:e})),"primaryPage")},placeholderData:r=>r||{}})},Tr=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-SNRQn7Az.cjs"))),Bs=({children:e})=>{const{t}=v.useTranslation(),[s,n]=ee(),r=s.get("page"),{data:a,isFetching:i}=Z(),{data:l,isFetching:c}=as(),[u,d]=h.useState(!1),[f,g]=h.useState(!0),{savePage:E}=v.useSavePage(),A=!!r&&!p.isEmpty(a),_=h.useMemo(()=>{if(!l||c)return!1;const P=l.find(N=>N.slug==="/");return P==null?void 0:P.id},[l,c]);h.useEffect(()=>{if(c||!_||l.some(K=>K.id===r))return;const N=new URLSearchParams({page:_});rs(N,n),!c&&l&&g(!1)},[r,c,l,_,n]);const C=!f&&!r,x=!f&&!i&&p.isEmpty(a),S=u||C||x;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex items-center gap-x-1",children:o.jsx("div",{className:"relative",children:o.jsxs(m.Tooltip,{children:[o.jsx(m.TooltipTrigger,{asChild:!0,onClick:()=>{E(),d(!0)},children:e||o.jsx(m.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:o.jsx(b.LogsIcon,{className:"h-4 w-4"})},"template-viewer")}),o.jsx(m.TooltipContent,{side:"right",children:o.jsx("p",{children:t("Open pages manager")})})]})})}),o.jsx(m.Sheet,{open:S,onOpenChange:P=>!P&&A&&d(!1),children:o.jsxs(m.SheetContent,{side:"left","aria-describedby":"pages-manager-description",className:`z-50 !min-w-[50vh] !max-w-[800px] border-border p-0 ${A?"":"sheet-hide-close-btn"}`,children:[o.jsxs(m.SheetHeader,{className:"mb-3 px-4 pt-4",children:[o.jsxs(m.SheetTitle,{className:"flex items-center gap-2 text-sm font-semibold",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:o.jsx(b.Folder,{className:"h-4 w-4"})}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-semibold",children:t("Pages")}),o.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:t("Manage your site structure")})]})]}),o.jsx(m.SheetDescription,{className:"sr-only",children:t("Manage your site structure")})]}),o.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:S&&o.jsx(h.Suspense,{children:o.jsx(Tr,{close:()=>d(!1)})})})]})})]})},Pr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-CQcFi0Tp.cjs"))),xr=()=>{const e=se("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},Us=({showAdd:e=!0,variant:t="ghost",goToDefaultLang:s=!1})=>{const{fallbackLang:n,languages:r,selectedLang:a,setSelectedLang:i}=v.useLanguages(),l=p.isEmpty(a)?n:a,[,c]=ee(),{isLocked:u}=Ae(),{t:d}=v.useTranslation();h.useEffect(()=>{const S=new URLSearchParams(window.location.search),P=S.get("lang");P&&(r.includes(P)?i(P):(S.delete("lang"),c(S),i("")))},[r,c,i]);const[,f]=V.useAtom(Dt),{data:g}=Z(),{data:E}=ye(),{data:A}=pe(),_=h.useMemo(()=>{const S=p.compact(p.map(p.get(E,"languages"),P=>{const N=p.find(A,{lang:P});return{key:P,value:p.get(Ve,P,P),isLangPageAdded:!!N}})).filter(Boolean);return[{key:n,value:p.get(Ve,n),isLangPageAdded:!0},...S]},[n,A,E]),C=S=>{if(document.querySelector('[data-panel-id="seo"]')){const N=new CustomEvent("seo-language-switch-check",{detail:{fromLang:l,toLang:S,switchHandler:()=>x(S)}});window.dispatchEvent(N);return}x(S)},x=S=>{i(S);const P=new URLSearchParams(window.location.search);S===n?P.delete("lang"):P.set("lang",S),rs(P,c)};return p.isEmpty(r)?null:u?o.jsxs(m.Button,{variant:"ghost",size:"sm",className:"ml-px h-max cursor-not-allowed gap-2 py-1.5 opacity-50",children:[o.jsx(b.Languages,{className:"h-4 w-4"}),p.get(Ve,l,l),o.jsx(b.ChevronDown,{className:"h-4 w-4"})]}):s?o.jsx(m.Button,{onClick:()=>x(n),variant:"link",size:"sm",children:d("Switch to default language")}):o.jsx(o.Fragment,{children:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:o.jsxs(m.Button,{disabled:!!u,variant:t,size:"sm",className:"ml-px h-max gap-2 py-1.5",children:[o.jsx(b.Languages,{className:"h-4 w-4"}),p.get(Ve,l,l),o.jsx(b.ChevronDown,{className:"h-4 w-4"})]})}),o.jsxs(m.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(_.filter(S=>S.isLangPageAdded),S=>o.jsxs(m.DropdownMenuItem,{className:v.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",S.key===l&&"!bg-gray-200 text-gray-700"),onClick:()=>C(S.key),children:[o.jsx("div",{className:"text-slate-600",children:S.value}),S.key===n&&o.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[o.jsx(b.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},S.value)),e&&!p.isEmpty(_.filter(S=>!S.isLangPageAdded))&&o.jsxs(o.Fragment,{children:[o.jsx(m.Separator,{}),o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:()=>{g&&f({edit:!1,primaryPage:g.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[o.jsx(b.Plus,{className:"mr-1 h-3 w-3"})," Add Langauge"]})]})]})]})})};function _r(){const[e,t]=V.useAtom(Dt);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(xr,{}),o.jsx(Bs,{}),e&&o.jsx(h.Suspense,{children:o.jsx(Pr,{isOpen:!0,id:e==null?void 0:e.id,edit:!!(e!=null&&e.id),primaryPage:e==null?void 0:e.primaryPage,preselectedLang:e==null?void 0:e.preselectedLang,onClose:()=>t(null)})})]})}function vr(){return o.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((e,t)=>o.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[o.jsxs("div",{className:"flex-1 space-y-1",children:[o.jsx(m.Skeleton,{className:"h-4 w-3/4"}),o.jsx(m.Skeleton,{className:"h-3 w-1/2"}),o.jsx(m.Skeleton,{className:"mt-1 h-5 w-20"})]}),o.jsx(m.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}const wr=z.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-BCMjvZRZ.cjs")));function br(){const[e,t]=z.useState(!1);return o.jsx(m.TooltipProvider,{children:o.jsxs(m.Tooltip,{delayDuration:0,children:[o.jsxs(m.Sheet,{open:e,onOpenChange:t,children:[o.jsx(m.SheetTrigger,{asChild:!0,children:o.jsx(m.TooltipTrigger,{asChild:!0,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsxs(m.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[o.jsx(b.History,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"View revision history"})]}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})})}),o.jsx(m.SheetContent,{className:"flex h-[100vh] flex-col",children:e&&o.jsx(h.Suspense,{fallback:o.jsx(vr,{}),children:o.jsx(wr,{isOpen:e})})})]}),o.jsx(m.TooltipContent,{side:"bottom",children:o.jsx("p",{children:"Revision history"})})]})})}const St=({permission:e,permissions:t,children:s,fallback:n=null})=>{const{hasPermission:r}=v.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?n:s},Cr={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},de=()=>{const e=D(),t=k();return T.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},qs=e=>{const{data:t}=de();return h.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},Ir=()=>{const e=D(),t=k();return T.useMutation({mutationFn:async({pageType:s,query:n})=>{try{return t(e,{action:y.SEARCH_PAGES,data:{pageType:s,query:Array.isArray(n)&&n.length>0?n[0]:n}})||[]}catch(r){return console.error(r),[]}}})},Lr=()=>{const e=D(),t=T.useQueryClient(),s=k(),{data:n}=de();return T.useMutation({mutationFn:async r=>await s(e,{action:y.CREATE_PAGE,data:r}),onSuccess:(r,a)=>{var l;a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES,a==null?void 0:a.lang]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const i=a.template?`Page created from "${a.template.name}" template`:a.hasSlug===!1?"New "+((l=p.find(n,{key:a.pageType}))==null?void 0:l.name)+" added successfully":"New page added successfully";q.toast.success(i)},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});q.toast.error(`Failed to add new ${i!=null&&i.hasSlug?"page":i.name}.`,{description:p.get(Cr,r.message,r.message)})}})},Nr=()=>{const e=D(),t=T.useQueryClient(),s=k(),{data:n}=ue(),{data:r}=de();return T.useMutation({mutationFn:async a=>await s(e,{action:y.UPDATE_PAGE,data:a}),onSuccess:(a,i)=>{(n==null?void 0:n.id)===(i==null?void 0:i.id)&&t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]}),i&&(i!=null&&i.primaryPage||i!=null&&i.seo)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(a,i)=>{const l=p.find(r,{key:i.pageType});q.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:a.message})}})},jr=()=>{const e=D(),t=T.useQueryClient(),s=k(),{data:n}=de();return T.useMutation({mutationFn:async r=>s(e,{action:y.DELETE_PAGE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{if(r.code==="PAGE_LOCKED"){q.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});q.toast.error(`Failed to delete ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},kr=()=>{const e=D(),t=T.useQueryClient(),s=k(),{data:n}=de();return T.useMutation({mutationFn:async r=>s(e,{action:y.TAKE_OFFLINE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const i=p.find(n,{key:a.pageType});q.toast.success(i!=null&&i.hasSlug?"Page unpublished successfully.":"New "+i.name+" added successfully.")},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});q.toast.error(`Failed to take offline ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},is=()=>{const e=D(),t=k(),s=T.useQueryClient(),{data:n}=Z(),{savePageAsync:r}=v.useSavePage();return T.useMutation({mutationFn:async({ids:a})=>(await r(),t(e,{action:y.PUBLISH_CHANGES,data:{ids:a}})),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_CHANGES]}),s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,n==null?void 0:n.id]})},onError:a=>{console.log("##",a),q.toast.error("Failed to publish pages.")}})},Dr=()=>{const e=D(),t=k(),s=T.useQueryClient();return T.useMutation({mutationFn:async n=>{var r;return t(e,{action:y.MARK_AS_TEMPLATE,data:{id:(r=n.page)==null?void 0:r.id,name:n.name,description:n.description,pageType:n.pageType,previewImage:n.previewImage}})},onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),q.toast.success("Page marked as template successfully.")},onError:()=>{q.toast.error("Failed to mark page as template.")}})},Or=()=>{const e=D(),t=k(),s=T.useQueryClient();return T.useMutation({mutationFn:async n=>t(e,{action:y.UNMARK_AS_TEMPLATE,data:{id:n==null?void 0:n.id}}),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),q.toast.success("Page unmarked as template successfully.")},onError:()=>{q.toast.error("Failed to unmark page as template.")}})},Gr=()=>{const e=D(),t=k(),s=T.useQueryClient();return T.useMutation({mutationFn:async({id:n,slug:r})=>t(e,{action:y.CHANGE_SLUG,data:{id:n,slug:r}}),onSuccess:(n,{primaryPage:r})=>{q.toast.success("Slug changed successfully."),r?s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{q.toast.error("Failed to change slug")}})},Rr=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-CaBwfekc.cjs")));function Mr({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:s,isPending:n}=is();return o.jsx(m.Dialog,{open:e,onOpenChange:n?()=>{}:t,children:e&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:o.jsx(Rr,{onClose:t,isPending:n,publishPage:s})})})}const te={...v.PERMISSIONS,ADD_PAGE:"add_page",EDIT_PAGE:"edit_page",EDIT_SLUG:"edit_slug",DELETE_PAGE:"delete_page",CHANGE_PAGE_TYPE:"change_page_type",PUBLISH_PAGE:"publish_page",UNPUBLISH_PAGE:"unpublish_page",MARK_AS_TEMPLATE:"mark_as_template",UNMARK_AS_TEMPLATE:"unmark_as_template",ADD_PARTIAL:"add_partial",EDIT_PARTIAL:"edit_partial",DELETE_PARTIAL:"delete_partial",PUBLISH_PARTIAL:"publish_partial",UNPUBLISH_PARTIAL:"unpublish_partial",EDIT_SEO:"edit_seo",RESTORE_REVISION:"restore_revision",DELETE_REVISION:"delete_revision",PUBLISH_THEME:"publish_theme",EDIT_SETTINGS:"edit_settings",ADD_LIBRARY_BLOCK:"create_library_block",ADD_LIBRARY_TEMPLATE:"add_library_template",EDIT_LIBRARY_BLOCK:"edit_library_block",EDIT_LIBRARY_TEMPLATE:"edit_library_template",DELETE_LIBRARY_BLOCK:"delete_library_block",DELETE_LIBRARY_TEMPLATE:"delete_library_template",ADD_MEDIA:"add_media",EDIT_MEDIA:"edit_media",DELETE_MEDIA:"delete_media"},Br={particleCount:350,spread:120,origin:{y:.6},angle:90},Ur={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},qr=async()=>{const{default:e}=await Promise.resolve().then(()=>require("./confetti.module-BuUnQuWk.cjs"));return e},Tt=e=>{let t=Ur[e];t||(t={});const s={...Br,...t};qr().then(n=>n(s))};function Gt({children:e,content:t,side:s="bottom",delayDuration:n=700,showTooltip:r=!0}){return r?o.jsx(m.TooltipProvider,{children:o.jsxs(m.Tooltip,{delayDuration:n,children:[o.jsx(m.TooltipTrigger,{asChild:!0,children:e}),o.jsx(m.TooltipContent,{side:s,sideOffset:10,children:o.jsx("p",{children:t})})]})}):e}const Fr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BdJScWMX.cjs"))),Kr=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-Kctu12rQ.cjs"))),Qr=()=>{const{t:e}=v.useTranslation(),{selectedLang:t,fallbackLang:s}=v.useLanguages(),n=se("getPreviewUrl",async g=>g),[r,a]=h.useState(""),{data:i}=Z(),{data:l}=pe(),{data:c}=de(),u=h.useMemo(()=>{var g;return(g=l==null?void 0:l.find(E=>(E==null?void 0:E.lang)===t))==null?void 0:g.slug},[t,l]),d=h.useCallback(g=>{var E;return(E=p.find(c,{key:g}))==null?void 0:E.hasSlug},[c]),f=t===s?"":t;return h.useEffect(()=>{(async()=>{if(typeof n=="function"){const g=!d(i==null?void 0:i.pageType),E=await n(g?`${f!==""?f+"/":""}${i==null?void 0:i.id}`:u||"");a(E)}else a("")})()},[n,u,i==null?void 0:i.pageType,d,i==null?void 0:i.id,f]),o.jsx(o.Fragment,{children:o.jsx(Gt,{content:e("Open preview in new tab"),delayDuration:0,children:o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:o.jsx(m.Button,{variant:"ghost",size:"sm",className:"gap-2",children:o.jsx(b.Play,{className:"h-4 w-4"})})})})})},Vr=()=>{const{t:e}=v.useTranslation(),[t,s]=v.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Gt,{content:e("Theme"),delayDuration:0,children:o.jsx(m.Button,{variant:t==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>s(t==="theme"?"block":"theme"),children:o.jsx(b.Palette,{className:"h-4 w-4"})})}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},Hr=()=>{const{t:e}=v.useTranslation(),[t,s]=h.useState(!1),{isLocked:n}=Ae(),{savePageAsync:r,saveState:a}=v.useSavePage();h.useEffect(()=>{const d=f=>{a==="UNSAVED"&&(f.preventDefault(),f.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",d),()=>{window.removeEventListener("beforeunload",d)}},[a]);const i=h.useCallback(async()=>{t||(s(!0),await r(),s(!1))},[r,t]),{buttonIcon:l,buttonClass:c,tooltipContent:u}=h.useMemo(()=>{switch(a){case"UNSAVED":return{tooltipContent:e("Save draft"),buttonIcon:o.jsx(b.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:e("Saving"),buttonIcon:o.jsx(b.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:e("Saved"),buttonIcon:o.jsx(b.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[a,e]);return n?null:o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:i,className:`${c} w-24 max-w-24`,children:[l," ",u]})},zr=()=>{const{t:e}=v.useTranslation(),{selectedLang:t}=v.useLanguages(),{data:s}=ue(),{data:n}=pe(),[r,a]=h.useState(!1),[i,l]=h.useState(!1),[c,u]=h.useState(null),{savePageAsync:d}=v.useSavePage(),[f,g]=h.useState(!1),{data:E}=Z(),{mutate:A,isPending:_}=is(),{needTranslations:C}=v.useSavePage(),x=C(),{buttonText:S,buttonClassName:P,isPublished:N}=h.useMemo(()=>{const L=E&&(E==null?void 0:E.online);return{buttonClassName:L?"hover:bg-green-600 bg-green-500":"",isPublished:L,buttonText:e(L?"Published":"Publish")}},[E,e]),K=async()=>{if(x){g(!0);return}G()},G=()=>{const L=[s==null?void 0:s.id,s==null?void 0:s.primaryPage];A({ids:p.compact(L)},{onSuccess:()=>Tt("TOP_RIGHT")})},ie=()=>{g(!1),G()},oe=async()=>{g(!1),await d()},F=h.useMemo(()=>p.map(n??[],"id"),[n]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex",children:[o.jsxs(m.Button,{size:"sm",onClick:K,disabled:_||!(E!=null&&E.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${P}`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[o.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${i?"-translate-y-10":""}`,children:N?o.jsx(b.Send,{className:"h-4 w-4"}):o.jsx(b.Rocket,{className:"h-4 w-4"})}),o.jsx("span",{className:`absolute inset-0 left-3 flex items-center transition-transform duration-300 ease-in-out ${i?"":"translate-y-10"}`,children:N?o.jsx(b.Rocket,{className:"h-4 w-4"}):o.jsx(b.Send,{className:"h-4 w-4"})}),o.jsx("span",{children:S}),t?`(${p.upperCase(t)})`:""]}),o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",disabled:_||!(E!=null&&E.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${P}`,children:o.jsx(b.ChevronDown,{className:"h-4 w-4"})})}),o.jsxs(m.DropdownMenuContent,{align:"end",className:"w-52",children:[o.jsxs(m.DropdownMenuItem,{disabled:_,className:"cursor-pointer text-xs",onClick:()=>A({ids:F},{onSuccess:()=>Tt("TOP_RIGHT")}),children:[e("Publish")," with translation pages"]}),!N&&o.jsxs(m.DropdownMenuItem,{disabled:_,className:"cursor-pointer text-xs",onClick:()=>A({ids:[E==null?void 0:E.id]},{onSuccess:()=>Tt("TOP_RIGHT")}),children:[e("Publish")," page"]}),o.jsxs(m.DropdownMenuItem,{onClick:()=>a(!0),className:"cursor-pointer text-xs",children:[e("Open")," publish menu"]}),N&&o.jsxs(m.DropdownMenuItem,{onClick:()=>u(s),className:"cursor-pointer text-xs",children:[e("Unpublish")," page ",t?`(${p.upperCase(t)})`:""]})]})]})]}),o.jsx(Mr,{showModal:r,onClose:()=>a(!1)}),c&&o.jsx(h.Suspense,{children:o.jsx(Fr,{page:c,onClose:()=>u(null)})}),f&&o.jsx(h.Suspense,{children:o.jsx(Kr,{isOpen:f,onClose:oe,onContinue:ie,isPending:_})})]})};function $r(){const{isLocked:e}=Ae(),[t]=ee(),s=t.get("lang"),n=ts(s);return e||!n?o.jsx("div",{}):o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o.jsx(br,{}),o.jsx(St,{permission:te.EDIT_THEME,children:o.jsx(Vr,{})}),o.jsx(Qr,{}),o.jsx(St,{permission:te.SAVE_PAGE,children:o.jsx(Hr,{})}),o.jsx(St,{permission:te.PUBLISH_PAGE,children:o.jsx(zr,{})})]})}const Fs=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:i,children:l,isLanguagePage:c})=>{const{t:u}=v.useTranslation(),{hasPermission:d}=v.usePermissions(),{data:f}=de(),g=h.useMemo(()=>p.find(f,{key:e.pageType}),[f,e.pageType]),E=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),A=h.useMemo(()=>!!(g!=null&&g.hasSlug),[g==null?void 0:g.hasSlug]);return!d(te.EDIT_PAGE)&&!d(te.DELETE_PAGE)&&!d(te.UNPUBLISH_PAGE)||!e?null:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,onClick:C=>C.stopPropagation(),children:l}),o.jsxs(m.DropdownMenuContent,{align:"center",className:"text-sm",children:[d(te.ADD_PAGE)&&!c&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:C=>{C.stopPropagation(),t(e)},children:[o.jsx(b.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),d(te.EDIT_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:C=>{C.stopPropagation(),s({...e,global:!(g!=null&&g.hasSlug)})},children:[o.jsx(b.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&d(te.UNPUBLISH_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:C=>{C.stopPropagation(),n(e)},children:[o.jsx(b.Power,{className:"size-3"}),u("Unpublish")]}),d(te.DELETE_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:C=>{C.stopPropagation(),r(e)},children:[o.jsx(b.Trash,{className:"size-3"}),u("Delete")]}),d(te.MARK_AS_TEMPLATE)&&A&&!c&&o.jsx(o.Fragment,{children:E?o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:C=>{C.stopPropagation(),i(e)},children:[o.jsx(b.SquareLibrary,{className:"size-3"}),u("Unmark as template")]}):o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:C=>{C.stopPropagation(),a(e)},children:[o.jsx(b.SquareLibrary,{className:"size-3"}),u("Mark as template")]})})]})]})},Wr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-DxObnvo_.cjs"))),Yr=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-CbY8q5M3.cjs"))),Jr=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-CXK2HcxD.cjs"))),Zr=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-v182tmN6.cjs"))),Xr=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-DXjLbqOM.cjs"))),ea=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BdJScWMX.cjs"))),ta=()=>{const[e,t]=h.useState(null),[s,n]=h.useState(null),[r,a]=h.useState(null),[i,l]=h.useState(null),[c,u]=h.useState(null),[d,f]=h.useState(null),{data:g,isFetching:E}=ue(),{selectedLang:A,fallbackLang:_}=v.useLanguages(),{data:C}=pe(),x=C==null?void 0:C.find(G=>G.lang===A),{isLocked:S}=Ae(),P=!(g!=null&&g.slug),[,N]=V.useAtom(Dt);if(!g)return null;const K=G=>{A.length>0&&A!==_?N({edit:!0,id:G==null?void 0:G.id,primaryPage:G==null?void 0:G.primaryPage}):f(G)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between rounded px-[2px] transition-colors duration-200",children:[o.jsx(Bs,{children:o.jsx(m.Button,{className:"flex h-7 max-w-[200px] cursor-pointer items-center truncate rounded px-1 text-xs font-medium",variant:"ghost",children:E?o.jsx(b.Loader,{className:"h-4 w-4 animate-spin text-slate-400"}):o.jsxs("span",{className:"flex w-full cursor-pointer items-end overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-xs font-medium",children:[P?o.jsx(b.Hash,{className:"mr-1 h-4 w-4"}):o.jsx(b.File,{className:"mr-1 h-4 w-4"}),p.get(x||g,"name")??""]})})}),S?o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 cursor-not-allowed rounded opacity-50 hover:bg-transparent",children:o.jsx(b.MoreHorizontal,{className:"h-4 w-4"})}):o.jsx(Fs,{page:g,setDuplicatePage:G=>u(G),setAddEditPage:G=>K(G),setUnpublishPage:G=>n(G),setDeletePage:G=>t(G),setMarkAsTemplate:G=>a(G),setUnmarkAsTemplate:G=>l(G),isLanguagePage:A.length>0&&A!==_,children:o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:o.jsx(b.MoreHorizontal,{className:"h-4 w-4"})})})]}),d&&o.jsx(h.Suspense,{children:o.jsx(Wr,{closePanel:()=>f(null),editPage:()=>{},addEditPage:d,setAddEditPage:f})}),e&&o.jsx(h.Suspense,{children:o.jsx(Yr,{page:e,onClose:()=>t(null)})}),s&&o.jsx(h.Suspense,{children:o.jsx(ea,{page:s,onClose:()=>n(null)})}),r&&o.jsx(h.Suspense,{children:o.jsx(Zr,{page:r,onClose:()=>a(null)})}),i&&o.jsx(h.Suspense,{children:o.jsx(Xr,{page:i,onClose:()=>l(null)})}),c&&o.jsx(h.Suspense,{children:o.jsx(Jr,{page:c,onClose:()=>u(null),closePanel:()=>f(null)})})]})},os=({children:e,className:t=""})=>o.jsx("div",{className:v.mergeClasses("fixed bottom-0 left-0 right-0 top-[50px] z-[20] flex w-screen flex-col items-center justify-center bg-black/40 transition-all",t),children:e}),sa=({hasDynamicPage:e})=>o.jsx(os,{children:o.jsxs("div",{className:"flex min-w-[300px] max-w-[400px] flex-col items-center justify-center rounded-lg border bg-white p-4 shadow-lg",children:[o.jsx("h1",{className:"text-lg font-medium",children:e?"Select a page":"No pages found"}),o.jsx("p",{className:"pt-2 text-center text-sm font-light text-gray-600",children:e?"Please select a page from the list in the top header. This will enable you to edit the page.":"Please add a new page"})]})}),na=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-Crd3y4Hk.cjs"))),ra=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=Gs(),n=t.length>0;return s?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx(sa,{hasDynamicPage:n}),o.jsx(h.Suspense,{children:o.jsx(na,{})})]})},aa=()=>{const{data:e,isFetching:t}=ue(),{data:s,isFetching:n}=Z(),r=p.get(s,"dynamic",!1),a=ss(),i=v.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,u=ur(),d=t||n,g=(c?`Partial: ${e==null?void 0:e.name} `:`${l}${a}`).replace(window.location.host,"");return o.jsxs("div",{className:"relative flex items-center gap-x-1",children:[o.jsx("div",{className:v.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",d&&"max-w-0 overflow-hidden opacity-0"),children:o.jsx(ta,{})}),o.jsxs("div",{className:v.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800"+(c?" pr-2":""),d&&"max-w-0 overflow-hidden opacity-0"),children:[o.jsx(Us,{}),o.jsxs("div",{className:"flex w-full items-center overflow-hidden",children:[o.jsx("div",{className:`w-full max-w-[200px] overflow-hidden overflow-ellipsis whitespace-nowrap pl-1 text-xs ${c?"italic text-gray-400":"font-mono text-gray-500"}`,children:g==="/"?o.jsxs("span",{className:"text-gray-900",children:["/",o.jsx("span",{className:"text-[11px] font-light italic text-gray-400",children:"(Homepage)"})]}):g}),!c&&o.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:o.jsx("div",{className:"ml-2 mr-px flex-shrink-0 rounded-sm p-1.5 text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",children:o.jsx(b.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&i&&o.jsx(ra,{})]})},ia=()=>o.jsxs("div",{className:"flex h-full w-full items-center justify-between px-2",children:[o.jsx(_r,{}),o.jsx(aa,{}),o.jsx($r,{})]}),Ks=()=>{const e=T.useQueryClient(),{data:t}=T.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(n=>{e.setQueryData([y.AI_CONTEXT],n)},[e]),aiContext:t}},oa=()=>{const e=D(),{aiContext:t}=Ks(),s=k();return h.useCallback(async(n,r,a,i)=>s(e,{action:y.ASK_AI,data:{type:n,prompt:r,blocks:a,context:t,lang:i}}),[e,t,s])},la=(e,t)=>t.map(s=>{if(p.has(e,s._type)){const n=js.getDefaultBlockProps(s._type);return{...n,...p.pick(s,[...p.keys(n),"_type","_id","_name","_parent","_bindings"]),...p.pickBy(s,(r,a)=>p.endsWith(a,"_attrs")),...s}}return s}),ca=e=>{const t=js.useRegisteredChaiBlocks();return h.useMemo(()=>{if(!e||p.isEmpty(e))return{blocks:[]};const s=p.filter(e,n=>!p.includes(n==null?void 0:n._type,"@chai/"));return{blocks:la(t,s)}},[e,t])},ua=()=>{const[e]=ee(),t=e.get("page"),s=D(),{setAiContext:n}=Ks(),[,r]=kt(),[,a]=cr(),[,i]=v.useIsPageLoaded(),l=k();return T.useQuery({queryKey:[y.GET_DRAFT_PAGE,t],staleTime:1/0,gcTime:0,queryFn:async()=>{i(!1);const c=await l(s,{action:y.GET_DRAFT_PAGE,data:{id:t,draft:!0}}),u=c.blocks??[],d=p.find(u,{_type:"@chai/ai-context"});return n(p.get(d,"_value","")||""),r(f=>({...f,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>i(!0),500),u},enabled:!!t})},Qs=()=>{const{data:e}=Z(),{data:t}=ue(),s=D(),n=k(),r=Ot(),a=ss();return T.useQuery({queryKey:[y.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,a],staleTime:1/0,gcTime:0,queryFn:async()=>n(s,{action:y.GET_BUILDER_PAGE_DATA,data:{pageType:e==null?void 0:e.pageType,lang:(t==null?void 0:t.lang)||r,dynamic:e==null?void 0:e.dynamic,pageProps:{slug:(t==null?void 0:t.slug)+a,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:r,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id,metadata:e.metadata||{}}}}),enabled:!!(e!=null&&e.pageType)&&!!t.id})},Vs=()=>{const e=D(),t=T.useQueryClient(),s=k();return T.useMutation({mutationFn:async n=>s(e,{action:y.UPDATE_WEBSITE_SETTINGS,data:n}),onSuccess:(n,r)=>{var a;t.invalidateQueries({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS]}),(a=r==null?void 0:r.settings)!=null&&a.theme||q.toast.success("Website settings updated successfully.")},onError:n=>{q.toast.error("Failed to update website settings",{description:n.message})}})},da=()=>{const e=D(),t=T.useQueryClient(),s=k(),{selectedLang:n}=v.useLanguages();return T.useMutation({mutationFn:async r=>s(e,{action:y.ADD_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),q.toast.success("Schema added successfully.")},onError:r=>{q.toast.error("Failed to add schema",{description:r.message})}})},fa=()=>{const e=D(),t=T.useQueryClient(),s=k(),{selectedLang:n}=v.useLanguages();return T.useMutation({mutationFn:async r=>s(e,{action:y.UPDATE_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),q.toast.success("Schema updated successfully.")},onError:r=>{q.toast.error("Failed to update schema",{description:r.message})}})},ha=()=>{const e=D(),t=T.useQueryClient(),s=k();return T.useMutation({mutationFn:async n=>s(e,{action:y.DELETE_GLOBAL_SCHEMA,data:{id:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),q.toast.success("Schema deleted successfully.")},onError:n=>{q.toast.error("Failed to delete schema",{description:n.message})}})},ga=()=>{const e=D(),t=k();return T.useMutation({mutationFn:async s=>t(e,{action:y.TOGGLE_PAGE_GLOBAL_SCHEMA,data:s}),onError:s=>{q.toast.error("Failed to toggle schema",{description:s.message})}})},ma=()=>{const e=D(),t=k();return T.useMutation({mutationFn:async s=>t(e,{action:y.APPLY_SCHEMA_TO_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{q.toast.success(`Schema applied to ${s.count} page(s)`)},onError:s=>{q.toast.error("Failed to apply schema to all pages",{description:s.message})}})},Ea=()=>{const e=D(),t=k();return T.useMutation({mutationFn:async s=>t(e,{action:y.REMOVE_SCHEMA_FROM_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{q.toast.success(`Schema removed from ${s.count} page(s)`)},onError:s=>{q.toast.error("Failed to remove schema from all pages",{description:s.message})}})},ys={async getUILibraryBlock(e,t,s){const n=await t(s,{action:"GET_LIBRARY_ITEM",data:{id:e.id}}),r=p.get(n,"html",""),a=p.get(n,"blocks",[]);return p.isArray(a)?a:v.getBlocksFromHTML(r)},async getUILibraryBlocks(e,t,s){try{return(await t(s,{action:"GET_LIBRARY_ITEMS",data:{id:e.id}})).map(r=>({...r}))}catch(n){return console.error(n),[]}}},pa=()=>{const e=D(),t=k();return T.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const n=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return n.forEach(r=>{v.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>ys.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>ys.getUILibraryBlock(a,t,e)})}),n}})},Hs=()=>{const e=ks(),t=k(),{user:s}=gt(),n=s==null?void 0:s.id;return T.useQuery({queryKey:[y.GET_ROLE_AND_PERMISSIONS,n],queryFn:()=>t(e,{action:y.GET_ROLE_AND_PERMISSIONS,data:{userId:n}}),enabled:!!n,staleTime:1/0})},ya=()=>{const e=D(),t=k(),[,s]=kt();return{onSave:async({page:r,blocks:a,needTranslations:i})=>{try{const l=await t(e,{action:"UPDATE_PAGE",data:{id:r,blocks:a,needTranslations:i}});return l.code==="PAGE_LOCKED"?!0:(s(c=>({...c,lastSaved:new Date().toISOString()})),l)}catch(l){return console.error(l),new Error("Failed to save blocks")}}}},Aa=()=>{const{data:e}=as(),t=D(),s=k();return{getPartialBlocks:h.useCallback(async()=>{const n={};for(const r of e??[])p.isEmpty(r==null?void 0:r.slug)&&(n[r.id]={type:r.pageType,name:p.startCase(r.name??r.slug),description:""});return n},[e]),getPartialBlockBlocks:h.useCallback(async n=>{if(!n)return[];try{const r=await s(t,{action:"GET_DRAFT_PAGE",data:{id:n,draft:!0,editor:!1}});return p.filter(r.blocks,a=>p.has(a,"_id"))}catch(r){return console.error(r),[]}},[s,t])}},Sa=h.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-content-B2AgBWqo.cjs"))),zs="chai-chat-panel",Ta=({className:e="h-full w-full"})=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",version:"1.1",className:e,children:[o.jsx("title",{children:"ai"}),o.jsx("g",{id:"Page-1",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:o.jsx("g",{id:"icon",fill:"currentColor",transform:"translate(64.000000, 64.000000)",children:o.jsx("path",{d:"M320,64 L320,320 L64,320 L64,64 L320,64 Z M171.749388,128 L146.817842,128 L99.4840387,256 L121.976629,256 L130.913039,230.977 L187.575039,230.977 L196.319607,256 L220.167172,256 L171.749388,128 Z M260.093778,128 L237.691519,128 L237.691519,256 L260.093778,256 L260.093778,128 Z M159.094727,149.47526 L181.409039,213.333 L137.135039,213.333 L159.094727,149.47526 Z M341.333333,256 L384,256 L384,298.666667 L341.333333,298.666667 L341.333333,256 Z M85.3333333,341.333333 L128,341.333333 L128,384 L85.3333333,384 L85.3333333,341.333333 Z M170.666667,341.333333 L213.333333,341.333333 L213.333333,384 L170.666667,384 L170.666667,341.333333 Z M85.3333333,0 L128,0 L128,42.6666667 L85.3333333,42.6666667 L85.3333333,0 Z M256,341.333333 L298.666667,341.333333 L298.666667,384 L256,384 L256,341.333333 Z M170.666667,0 L213.333333,0 L213.333333,42.6666667 L170.666667,42.6666667 L170.666667,0 Z M256,0 L298.666667,0 L298.666667,42.6666667 L256,42.6666667 L256,0 Z M341.333333,170.666667 L384,170.666667 L384,213.333333 L341.333333,213.333333 L341.333333,170.666667 Z M0,256 L42.6666667,256 L42.6666667,298.666667 L0,298.666667 L0,256 Z M341.333333,85.3333333 L384,85.3333333 L384,128 L341.333333,128 L341.333333,85.3333333 Z M0,170.666667 L42.6666667,170.666667 L42.6666667,213.333333 L0,213.333333 L0,170.666667 Z M0,85.3333333 L42.6666667,85.3333333 L42.6666667,128 L0,128 L0,85.3333333 Z",id:"Combined-Shape"})})})]}),Pa=({isActive:e,show:t})=>o.jsx(m.Button,{size:"icon",className:"p-0 [&_svg]:size-6",onClick:t,variant:e?"default":"ghost",children:o.jsx(Ta,{className:e?"h-5 w-5 text-white":"h-5 w-5 text-primary"})}),xa={id:zs,label:"AI Assistant",button:Pa,panel:Sa,position:"top"},_a=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-CaFrYllL.cjs"))),va=({isActive:e,show:t})=>{const{data:s}=ye();return!p.has(s,"languages")||!p.get(s,"languages",[]).length?null:o.jsx(m.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:o.jsx(b.LanguagesIcon,{className:"h-4 w-4"})})},$s="lang",wa={id:$s,label:"Languages",position:"top",panel:_a,button:va,view:"modal",width:400},ba=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-B9P7fXjo.cjs"))),Ws="seo",Ca=({isActive:e,show:t})=>{const{data:s}=Z(),n=qs(s==null?void 0:s.pageType);return!p.has(n,"hasSlug")||!n.hasSlug?null:o.jsx(m.Button,{size:"icon",className:"my-1 p-0",onClick:t,variant:e?"default":"ghost",children:o.jsxs("svg",{stroke:"currentColor",fill:"none",style:{height:"20px",width:"20px"},strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M7 8h-3a1 1 0 0 0 -1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-3"}),o.jsx("path",{d:"M14 16h-4v-8h4"}),o.jsx("path",{d:"M11 12h2"}),o.jsx("path",{d:"M17 8m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]})})},Ia={id:Ws,label:"SEO",panel:ba,button:Ca,position:"top",width:600,view:"modal"},Ys="user-info",La=()=>{const{t:e}=v.useTranslation(),{user:t,logout:s}=gt(),n=se("onLogout",p.noop);return t?o.jsxs(m.HoverCard,{children:[o.jsx(m.HoverCardTrigger,{asChild:!0,children:o.jsx(m.Button,{variant:"ghost",className:"text-sm font-medium",children:o.jsx(b.User,{className:"h-4 w-4"})})}),o.jsxs(m.HoverCardContent,{className:"w-auto space-y-2 p-4",children:[o.jsx("div",{className:"text-sm font-medium",children:t.name??t.email}),o.jsx("div",{className:"text-xs text-muted-foreground",children:t.email}),o.jsxs(m.AlertDialog,{children:[o.jsx(m.AlertDialogTrigger,{asChild:!0,children:o.jsx(m.Button,{variant:"outline",size:"sm",className:"w-full",children:e("Logout")})}),o.jsxs(m.AlertDialogContent,{children:[o.jsxs(m.AlertDialogHeader,{children:[o.jsx(m.AlertDialogTitle,{children:e("Are you sure you want to logout?")}),o.jsx(m.AlertDialogDescription,{children:e("You will be redirected to the login page.")})]}),o.jsxs(m.AlertDialogFooter,{children:[o.jsx(m.AlertDialogCancel,{children:e("Cancel")}),o.jsx(m.AlertDialogAction,{onClick:()=>{s(),p.isFunction(n)&&n()},children:e("Logout")})]})]})]})]})]}):null},Na={id:Ys,label:"User Info",button:La,position:"bottom"},ja=()=>{v.registerChaiSidebarPanel(Ws,Ia),v.registerChaiSidebarPanel($s,wa),v.registerChaiSidebarPanel(Ys,Na),(localStorage.getItem("chai-feature-flags")??"").includes("enable-ai-chat-panel")&&v.registerChaiSidebarPanel(zs,xa)};var I={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return As(this.context.count)},getNextContextId(){return As(this.context.count++)}};function As(e){const t=String(e),s=t.length-1;return I.context.id+(s?String.fromCharCode(96+s):"")+t}function He(e){I.context=e}var Js=!1,ka=(e,t)=>e===t,_t=Symbol("solid-proxy"),Zs=typeof Proxy=="function",ls=Symbol("solid-track"),vt={equals:ka},Xs=ln,fe=1,wt=2,en={owned:null,cleanups:null,context:null,owner:null},qt={},O=null,Ft=null,Da=null,B=null,J=null,ce=null,Rt=0;function ge(e,t){const s=B,n=O,r=e.length===0,a=t===void 0?n:t,i=r?en:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>Y(()=>Je(i)));O=i,B=null;try{return ae(l,!0)}finally{B=s,O=n}}function Q(e,t){t=t?Object.assign({},vt,t):vt;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=r=>(typeof r=="function"&&(r=r(s.value)),on(s,r));return[an.bind(s),n]}function tn(e,t,s){const n=Mt(e,t,!0,fe);Qe(n)}function me(e,t,s){const n=Mt(e,t,!1,fe);Qe(n)}function cs(e,t,s){Xs=za;const n=Mt(e,t,!1,fe);(!s||!s.render)&&(n.user=!0),ce?ce.push(n):Qe(n)}function $(e,t,s){s=s?Object.assign({},vt,s):vt;const n=Mt(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,Qe(n),an.bind(n)}function Oa(e){return e&&typeof e=="object"&&"then"in e}function Ga(e,t,s){let n,r,a;n=!0,r=e,a={};let i=null,l=qt,c=null,u=!1,d="initialValue"in a,f=typeof n=="function"&&$(n);const g=new Set,[E,A]=(a.storage||Q)(a.initialValue),[_,C]=Q(void 0),[x,S]=Q(void 0,{equals:!1}),[P,N]=Q(d?"ready":"unresolved");I.context&&(c=I.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:I.load&&I.has(c)&&(l=I.load(c)));function K(L,j,W,H){return i===L&&(i=null,H!==void 0&&(d=!0),(L===l||j===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(H,{value:j})),l=qt,G(j,W)),j}function G(L,j){ae(()=>{j===void 0&&A(()=>L),N(j!==void 0?"errored":d?"ready":"unresolved"),C(j);for(const W of g.keys())W.decrement();g.clear()},!1)}function ie(){const L=Qa,j=E(),W=_();if(W!==void 0&&!i)throw W;return B&&B.user,j}function oe(L=!0){if(L!==!1&&u)return;u=!1;const j=f?f():n;if(j==null||j===!1){K(i,Y(E));return}let W;const H=l!==qt?l:Y(()=>{try{return r(j,{value:E(),refetching:L})}catch(ne){W=ne}});if(W!==void 0){K(i,void 0,Pt(W),j);return}else if(!Oa(H))return K(i,H,void 0,j),H;return i=H,"v"in H?(H.s===1?K(i,H.v,void 0,j):K(i,void 0,Pt(H.v),j),H):(u=!0,queueMicrotask(()=>u=!1),ae(()=>{N(d?"refreshing":"pending"),S()},!1),H.then(ne=>K(H,ne,void 0,j),ne=>K(H,void 0,Pt(ne),j)))}Object.defineProperties(ie,{state:{get:()=>P()},error:{get:()=>_()},loading:{get(){const L=P();return L==="pending"||L==="refreshing"}},latest:{get(){if(!d)return ie();const L=_();if(L&&!i)throw L;return E()}}});let F=O;return f?tn(()=>(F=O,oe(!1))):oe(!1),[ie,{refetch:L=>nn(F,()=>oe(L)),mutate:A}]}function Ra(e){return ae(e,!1)}function Y(e){if(B===null)return e();const t=B;B=null;try{return e()}finally{B=t}}function Ma(e,t,s){const n=Array.isArray(e);let r,a=s&&s.defer;return i=>{let l;if(n){l=Array(e.length);for(let u=0;u<e.length;u++)l[u]=e[u]()}else l=e();if(a)return a=!1,i;const c=Y(()=>t(l,r,i));return r=l,c}}function sn(e){cs(()=>Y(e))}function Fe(e){return O===null||(O.cleanups===null?O.cleanups=[e]:O.cleanups.push(e)),e}function Ss(){return O}function nn(e,t){const s=O,n=B;O=e,B=null;try{return ae(t,!0)}catch(r){us(r)}finally{O=s,B=n}}function Ba(e){const t=B,s=O;return Promise.resolve().then(()=>{B=t,O=s;let n;return ae(e,!1),B=O=null,n?n.done:void 0})}var[Ua,$o]=Q(!1);function qa(){return[Ua,Ba]}function Fa(e,t){const s=Symbol("context");return{id:s,Provider:$a(s),defaultValue:e}}function Ka(e){let t;return O&&O.context&&(t=O.context[e.id])!==void 0?t:e.defaultValue}function rn(e){const t=$(e),s=$(()=>Ht(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var Qa;function an(){if(this.sources&&this.state)if(this.state===fe)Qe(this);else{const e=J;J=null,ae(()=>Ct(this),!1),J=e}if(B){const e=this.observers?this.observers.length:0;B.sources?(B.sources.push(this),B.sourceSlots.push(e)):(B.sources=[this],B.sourceSlots=[e]),this.observers?(this.observers.push(B),this.observerSlots.push(B.sources.length-1)):(this.observers=[B],this.observerSlots=[B.sources.length-1])}return this.value}function on(e,t,s){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&ae(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],i=Ft&&Ft.running;i&&Ft.disposed.has(a),(i?!a.tState:!a.state)&&(a.pure?J.push(a):ce.push(a),a.observers&&cn(a)),i||(a.state=fe)}if(J.length>1e6)throw J=[],new Error},!1)),t}function Qe(e){if(!e.fn)return;Je(e);const t=Rt;Va(e,e.value,t)}function Va(e,t,s){let n;const r=O,a=B;B=O=e;try{n=e.fn(t)}catch(i){return e.pure&&(e.state=fe,e.owned&&e.owned.forEach(Je),e.owned=null),e.updatedAt=s+1,us(i)}finally{B=a,O=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?on(e,n):e.value=n,e.updatedAt=s)}function Mt(e,t,s,n=fe,r){const a={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:O,context:O?O.context:null,pure:s};return O===null||O!==en&&(O.owned?O.owned.push(a):O.owned=[a]),a}function bt(e){if(e.state===0)return;if(e.state===wt)return Ct(e);if(e.suspense&&Y(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Rt);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===fe)Qe(e);else if(e.state===wt){const n=J;J=null,ae(()=>Ct(e,t[0]),!1),J=n}}function ae(e,t){if(J)return e();let s=!1;t||(J=[]),ce?s=!0:ce=[],Rt++;try{const n=e();return Ha(s),n}catch(n){s||(ce=null),J=null,us(n)}}function Ha(e){if(J&&(ln(J),J=null),e)return;const t=ce;ce=null,t.length&&ae(()=>Xs(t),!1)}function ln(e){for(let t=0;t<e.length;t++)bt(e[t])}function za(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:bt(n)}if(I.context){if(I.count){I.effects||(I.effects=[]),I.effects.push(...e.slice(0,s));return}He()}for(I.effects&&(I.done||!I.count)&&(e=[...I.effects,...e],s+=I.effects.length,delete I.effects),t=0;t<s;t++)bt(e[t])}function Ct(e,t){e.state=0;for(let s=0;s<e.sources.length;s+=1){const n=e.sources[s];if(n.sources){const r=n.state;r===fe?n!==t&&(!n.updatedAt||n.updatedAt<Rt)&&bt(n):r===wt&&Ct(n,t)}}}function cn(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=wt,s.pure?J.push(s):ce.push(s),s.observers&&cn(s))}}function Je(e){let t;if(e.sources)for(;e.sources.length;){const s=e.sources.pop(),n=e.sourceSlots.pop(),r=s.observers;if(r&&r.length){const a=r.pop(),i=s.observerSlots.pop();n<r.length&&(a.sourceSlots[i]=n,r[n]=a,s.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)Je(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)Je(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function Pt(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function us(e,t=O){throw Pt(e)}function Ht(e){if(typeof e=="function"&&!e.length)return Ht(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=Ht(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function $a(e,t){return function(n){let r;return me(()=>r=Y(()=>(O.context={...O.context,[e]:n.value},rn(()=>n.children))),void 0),r}}var zt=Symbol("fallback");function It(e){for(let t=0;t<e.length;t++)e[t]()}function Wa(e,t,s={}){let n=[],r=[],a=[],i=0,l=t.length>1?[]:null;return Fe(()=>It(a)),()=>{let c=e()||[],u=c.length,d,f;return c[ls],Y(()=>{let E,A,_,C,x,S,P,N,K;if(u===0)i!==0&&(It(a),a=[],n=[],r=[],i=0,l&&(l=[])),s.fallback&&(n=[zt],r[0]=ge(G=>(a[0]=G,s.fallback())),i=1);else if(i===0){for(r=new Array(u),f=0;f<u;f++)n[f]=c[f],r[f]=ge(g);i=u}else{for(_=new Array(u),C=new Array(u),l&&(x=new Array(u)),S=0,P=Math.min(i,u);S<P&&n[S]===c[S];S++);for(P=i-1,N=u-1;P>=S&&N>=S&&n[P]===c[N];P--,N--)_[N]=r[P],C[N]=a[P],l&&(x[N]=l[P]);for(E=new Map,A=new Array(N+1),f=N;f>=S;f--)K=c[f],d=E.get(K),A[f]=d===void 0?-1:d,E.set(K,f);for(d=S;d<=P;d++)K=n[d],f=E.get(K),f!==void 0&&f!==-1?(_[f]=r[d],C[f]=a[d],l&&(x[f]=l[d]),f=A[f],E.set(K,f)):a[d]();for(f=S;f<u;f++)f in _?(r[f]=_[f],a[f]=C[f],l&&(l[f]=x[f],l[f](f))):r[f]=ge(g);r=r.slice(0,i=u),n=c.slice(0)}return r});function g(E){if(a[f]=E,l){const[A,_]=Q(f);return l[f]=_,t(c[f],A)}return t(c[f])}}}function Ya(e,t,s={}){let n=[],r=[],a=[],i=[],l=0,c;return Fe(()=>It(a)),()=>{const u=e()||[],d=u.length;return u[ls],Y(()=>{if(d===0)return l!==0&&(It(a),a=[],n=[],r=[],l=0,i=[]),s.fallback&&(n=[zt],r[0]=ge(g=>(a[0]=g,s.fallback())),l=1),r;for(n[0]===zt&&(a[0](),a=[],n=[],r=[],l=0),c=0;c<d;c++)c<n.length&&n[c]!==u[c]?i[c](()=>u[c]):c>=n.length&&(r[c]=ge(f));for(;c<n.length;c++)a[c]();return l=i.length=a.length=d,n=u.slice(0),r=r.slice(0,l)});function f(g){a[c]=g;const[E,A]=Q(u[c]);return i[c]=A,t(E,c)}}}function ds(e,t){return Y(()=>e(t||{}))}function pt(){return!0}var $t={get(e,t,s){return t===_t?s:e.get(t)},has(e,t){return t===_t?!0:e.has(t)},set:pt,deleteProperty:pt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:pt,deleteProperty:pt}},ownKeys(e){return e.keys()}};function Kt(e){return(e=typeof e=="function"?e():e)?e:{}}function Ja(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function fs(...e){let t=!1;for(let i=0;i<e.length;i++){const l=e[i];t=t||!!l&&_t in l,e[i]=typeof l=="function"?(t=!0,$(l)):l}if(Zs&&t)return new Proxy({get(i){for(let l=e.length-1;l>=0;l--){const c=Kt(e[l])[i];if(c!==void 0)return c}},has(i){for(let l=e.length-1;l>=0;l--)if(i in Kt(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l<e.length;l++)i.push(...Object.keys(Kt(e[l])));return[...new Set(i)]}},$t);const s={},n=Object.create(null);for(let i=e.length-1;i>=0;i--){const l=e[i];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let u=c.length-1;u>=0;u--){const d=c[u];if(d==="__proto__"||d==="constructor")continue;const f=Object.getOwnPropertyDescriptor(l,d);if(!n[d])n[d]=f.get?{enumerable:!0,configurable:!0,get:Ja.bind(s[d]=[f.get.bind(l)])}:f.value!==void 0?f:void 0;else{const g=s[d];g&&(f.get?g.push(f.get.bind(l)):f.value!==void 0&&g.push(()=>f.value))}}}const r={},a=Object.keys(n);for(let i=a.length-1;i>=0;i--){const l=a[i],c=n[l];c&&c.get?Object.defineProperty(r,l,c):r[l]=c?c.value:void 0}return r}function un(e,...t){if(Zs&&_t in e){const r=new Set(t.length>1?t.flat():t[0]),a=t.map(i=>new Proxy({get(l){return i.includes(l)?e[l]:void 0},has(l){return i.includes(l)&&l in e},keys(){return i.filter(l=>l in e)}},$t));return a.push(new Proxy({get(i){return r.has(i)?void 0:e[i]},has(i){return r.has(i)?!1:i in e},keys(){return Object.keys(e).filter(i=>!r.has(i))}},$t)),a}const s={},n=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const a=Object.getOwnPropertyDescriptor(e,r),i=!a.get&&!a.set&&a.enumerable&&a.writable&&a.configurable;let l=!1,c=0;for(const u of t)u.includes(r)&&(l=!0,i?n[c][r]=a.value:Object.defineProperty(n[c],r,a)),++c;l||(i?s[r]=a.value:Object.defineProperty(s,r,a))}return[...n,s]}function dn(e){let t,s;const n=r=>{const a=I.context;if(a){const[l,c]=Q();I.count||(I.count=0),I.count++,(s||(s=e())).then(u=>{!I.done&&He(a),I.count--,c(()=>u.default),He()}),t=l}else if(!t){const[l]=Ga(()=>(s||(s=e())).then(c=>c.default));t=l}let i;return $(()=>(i=t())?Y(()=>{if(!a||I.done)return i(r);const l=I.context;He(a);const c=i(r);return He(l),c}):"")};return n.preload=()=>s||((s=e()).then(r=>t=()=>r.default),s),n}var Za=0;function Xa(){return I.context?I.getNextContextId():`cl-${Za++}`}var fn=e=>`Stale read from <${e}>.`;function ei(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(Wa(()=>e.each,e.children,t||void 0))}function ti(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(Ya(()=>e.each,e.children,t||void 0))}function si(e){const t=e.keyed,s=$(()=>e.when,void 0,void 0),n=t?s:$(s,void 0,{equals:(r,a)=>!r==!a});return $(()=>{const r=n();if(r){const a=e.children;return typeof a=="function"&&a.length>0?Y(()=>a(t?r:()=>{if(!Y(n))throw fn("Show");return s()})):a}return e.fallback},void 0,void 0)}function ni(e){const t=rn(()=>e.children),s=$(()=>{const n=t(),r=Array.isArray(n)?n:[n];let a=()=>{};for(let i=0;i<r.length;i++){const l=i,c=r[i],u=a,d=$(()=>u()?void 0:c.when,void 0,void 0),f=c.keyed?d:$(d,void 0,{equals:(g,E)=>!g==!E});a=()=>u()||(f()?[l,d,c]:void 0)}return a});return $(()=>{const n=s()();if(!n)return e.fallback;const[r,a,i]=n,l=i.children;return typeof l=="function"&&l.length>0?Y(()=>l(i.keyed?a():()=>{var u;if(((u=Y(s)())==null?void 0:u[0])!==r)throw fn("Match");return a()})):l},void 0,void 0)}function ri(e){return e}var ai=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],ii=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...ai]),oi=new Set(["innerHTML","textContent","innerText","children"]),li=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),ci=Object.assign(Object.create(null),{class:"className",novalidate:{$:"noValidate",FORM:1},formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});function ui(e,t){const s=ci[e];return typeof s=="object"?s[t]?s.$:void 0:s}var di=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),fi=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),hi={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},gi=e=>$(()=>e());function mi(e,t,s){let n=s.length,r=t.length,a=n,i=0,l=0,c=t[r-1].nextSibling,u=null;for(;i<r||l<a;){if(t[i]===s[l]){i++,l++;continue}for(;t[r-1]===s[a-1];)r--,a--;if(r===i){const d=a<n?l?s[l-1].nextSibling:s[a-l]:c;for(;l<a;)e.insertBefore(s[l++],d)}else if(a===l)for(;i<r;)(!u||!u.has(t[i]))&&t[i].remove(),i++;else if(t[i]===s[a-1]&&s[l]===t[r-1]){const d=t[--r].nextSibling;e.insertBefore(s[l++],t[i++].nextSibling),e.insertBefore(s[--a],d),t[r]=s[a]}else{if(!u){u=new Map;let f=l;for(;f<a;)u.set(s[f],f++)}const d=u.get(t[i]);if(d!=null)if(l<d&&d<a){let f=i,g=1,E;for(;++f<r&&f<a&&!((E=u.get(t[f]))==null||E!==d+g);)g++;if(g>d-l){const A=t[i];for(;l<d;)e.insertBefore(s[l++],A)}else e.replaceChild(s[l++],t[i++])}else i++;else t[i++].remove()}}}var We="_$DX_DELEGATE";function hn(e,t,s,n={}){let r;return ge(a=>{r=a,t===document?e():Nt(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function Ei(e,t,s,n){let r;const a=()=>{const l=document.createElement("template");return l.innerHTML=e,l.content.firstChild},i=()=>(r||(r=a())).cloneNode(!0);return i.cloneNode=i,i}function gn(e,t=window.document){const s=t[We]||(t[We]=new Set);for(let n=0,r=e.length;n<r;n++){const a=e[n];s.has(a)||(s.add(a),t.addEventListener(a,An))}}function pi(e=window.document){if(e[We]){for(let t of e[We].keys())e.removeEventListener(t,An);delete e[We]}}function Lt(e,t,s){xe(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function yi(e,t,s,n){xe(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function Ai(e,t,s){xe(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function mn(e,t){xe(e)||(t==null?e.removeAttribute("class"):e.className=t)}function En(e,t,s,n){if(n)Array.isArray(s)?(e[`$$${t}`]=s[0],e[`$$${t}Data`]=s[1]):e[`$$${t}`]=s;else if(Array.isArray(s)){const r=s[0];e.addEventListener(t,s[0]=a=>r.call(e,s[1],a))}else e.addEventListener(t,s,typeof s!="function"&&s)}function Si(e,t,s={}){const n=Object.keys(t||{}),r=Object.keys(s);let a,i;for(a=0,i=r.length;a<i;a++){const l=r[a];!l||l==="undefined"||t[l]||(Ts(e,l,!1),delete s[l])}for(a=0,i=n.length;a<i;a++){const l=n[a],c=!!t[l];!l||l==="undefined"||s[l]===c||!c||(Ts(e,l,!0),s[l]=c)}return s}function Ti(e,t,s){if(!t)return s?Lt(e,"style"):t;const n=e.style;if(typeof t=="string")return n.cssText=t;typeof s=="string"&&(n.cssText=s=void 0),s||(s={}),t||(t={});let r,a;for(a in s)t[a]==null&&n.removeProperty(a),delete s[a];for(a in t)r=t[a],r!==s[a]&&(n.setProperty(a,r),s[a]=r);return s}function pn(e,t={},s,n){const r={};return n||me(()=>r.children=Ze(e,t.children,r.children)),me(()=>typeof t.ref=="function"&&yn(t.ref,e)),me(()=>Pi(e,t,s,!0,r,!0)),r}function yn(e,t,s){return Y(()=>e(t,s))}function Nt(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return Ze(e,t,n,s);me(r=>Ze(e,t(),r,s),n)}function Pi(e,t,s,n,r={},a=!1){t||(t={});for(const i in r)if(!(i in t)){if(i==="children")continue;r[i]=Ps(e,i,null,r[i],s,a,t)}for(const i in t){if(i==="children")continue;const l=t[i];r[i]=Ps(e,i,l,r[i],s,a,t)}}function xi(e){let t,s;return!xe()||!(t=I.registry.get(s=vi()))?e():(I.completed&&I.completed.add(t),I.registry.delete(s),t)}function xe(e){return!!I.context&&!I.done&&(!e||e.isConnected)}function _i(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Ts(e,t,s){const n=t.trim().split(/\s+/);for(let r=0,a=n.length;r<a;r++)e.classList.toggle(n[r],s)}function Ps(e,t,s,n,r,a,i){let l,c,u,d,f;if(t==="style")return Ti(e,s,n);if(t==="classList")return Si(e,s,n);if(s===n)return n;if(t==="ref")a||s(e);else if(t.slice(0,3)==="on:"){const g=t.slice(3);n&&e.removeEventListener(g,n,typeof n!="function"&&n),s&&e.addEventListener(g,s,typeof s!="function"&&s)}else if(t.slice(0,10)==="oncapture:"){const g=t.slice(10);n&&e.removeEventListener(g,n,!0),s&&e.addEventListener(g,s,!0)}else if(t.slice(0,2)==="on"){const g=t.slice(2).toLowerCase(),E=di.has(g);if(!E&&n){const A=Array.isArray(n)?n[0]:n;e.removeEventListener(g,A)}(E||s)&&(En(e,g,s,E),E&&gn([g]))}else if(t.slice(0,5)==="attr:")Lt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")Ai(e,t.slice(5),s);else if((f=t.slice(0,5)==="prop:")||(u=oi.has(t))||!r&&((d=ui(t,e.tagName))||(c=ii.has(t)))||(l=e.nodeName.includes("-")||"is"in i)){if(f)t=t.slice(5),c=!0;else if(xe(e))return s;t==="class"||t==="className"?mn(e,s):l&&!c&&!u?e[_i(t)]=s:e[d||t]=s}else{const g=r&&t.indexOf(":")>-1&&hi[t.split(":")[0]];g?yi(e,g,t,s):Lt(e,li[t]||t,s)}return s}function An(e){if(I.registry&&I.events&&I.events.find(([c,u])=>u===e))return;let t=e.target;const s=`$$${e.type}`,n=e.target,r=e.currentTarget,a=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),i=()=>{const c=t[s];if(c&&!t.disabled){const u=t[`${s}Data`];if(u!==void 0?c.call(t,u,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&a(t.host),!0},l=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),I.registry&&!I.done&&(I.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();a(c[0]);for(let u=0;u<c.length-2&&(t=c[u],!!i());u++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(n)}function Ze(e,t,s,n,r){const a=xe(e);if(a){!s&&(s=[...e.childNodes]);let c=[];for(let u=0;u<s.length;u++){const d=s[u];d.nodeType===8&&d.data.slice(0,2)==="!$"?d.remove():c.push(d)}s=c}for(;typeof s=="function";)s=s();if(t===s)return s;const i=typeof t,l=n!==void 0;if(e=l&&s[0]&&s[0].parentNode||e,i==="string"||i==="number"){if(a||i==="number"&&(t=t.toString(),t===s))return s;if(l){let c=s[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),s=ve(e,s,n,c)}else s!==""&&typeof s=="string"?s=e.firstChild.data=t:s=e.textContent=t}else if(t==null||i==="boolean"){if(a)return s;s=ve(e,s,n)}else{if(i==="function")return me(()=>{let c=t();for(;typeof c=="function";)c=c();s=Ze(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],u=s&&Array.isArray(s);if(Wt(c,t,s,r))return me(()=>s=Ze(e,c,s,n,!0)),()=>s;if(a){if(!c.length)return s;if(n===void 0)return s=[...e.childNodes];let d=c[0];if(d.parentNode!==e)return s;const f=[d];for(;(d=d.nextSibling)!==n;)f.push(d);return s=f}if(c.length===0){if(s=ve(e,s,n),l)return s}else u?s.length===0?xs(e,c,n):mi(e,s,c):(s&&ve(e),xs(e,c));s=c}else if(t.nodeType){if(a&&t.parentNode)return s=l?[t]:t;if(Array.isArray(s)){if(l)return s=ve(e,s,n,t);ve(e,s,null,t)}else s==null||s===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);s=t}}return s}function Wt(e,t,s,n){let r=!1;for(let a=0,i=t.length;a<i;a++){let l=t[a],c=s&&s[e.length],u;if(!(l==null||l===!0||l===!1))if((u=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=Wt(e,l,c)||r;else if(u==="function")if(n){for(;typeof l=="function";)l=l();r=Wt(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const d=String(l);c&&c.nodeType===3&&c.data===d?e.push(c):e.push(document.createTextNode(d))}}return r}function xs(e,t,s=null){for(let n=0,r=t.length;n<r;n++)e.insertBefore(t[n],s)}function ve(e,t,s,n){if(s===void 0)return e.textContent="";const r=n||document.createTextNode("");if(t.length){let a=!1;for(let i=t.length-1;i>=0;i--){const l=t[i];if(r!==l){const c=l.parentNode===e;!a&&!i?c?e.replaceChild(r,l):e.insertBefore(r,s):c&&l.remove()}else a=!0}}else e.insertBefore(r,s);return[r]}function vi(){return I.getNextContextId()}var wi="http://www.w3.org/2000/svg";function Sn(e,t=!1){return t?document.createElementNS(wi,e):document.createElement(e)}function bi(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,r=Ss();let a,i=!!I.context;return cs(()=>{i&&(Ss().user=i=!1),a||(a=nn(r,()=>$(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,u]=Q(!1),d=()=>u(!0);ge(f=>Nt(l,()=>c()?f():a(),null)),Fe(d)}else{const c=Sn(e.isSVG?"g":"div",e.isSVG),u=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),Nt(u,a),l.appendChild(c),e.ref&&e.ref(c),Fe(()=>l.removeChild(c))}},void 0,{render:!i}),s}function Ci(e,t){const s=$(e);return $(()=>{const n=s();switch(typeof n){case"function":return Y(()=>n(t));case"string":const r=fi.has(n),a=I.context?xi():Sn(n,r);return pn(a,t,r),a}})}function Ii(e){const[,t]=un(e,["component"]);return Ci(()=>e.component,t)}var Li=class{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}},Tn=class{constructor(e){this.generateIdentifier=e,this.kv=new Li}register(e,t){this.kv.getByValue(e)||(t||(t=this.generateIdentifier(e)),this.kv.set(t,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}},Ni=class extends Tn{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,t){typeof t=="object"?(t.allowProps&&this.classToAllowedProps.set(e,t.allowProps),super.register(e,t.identifier)):super.register(e,t)}getAllowedProps(e){return this.classToAllowedProps.get(e)}};function ji(e){if("values"in Object)return Object.values(e);const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push(e[s]);return t}function ki(e,t){const s=ji(e);if("find"in s)return s.find(t);const n=s;for(let r=0;r<n.length;r++){const a=n[r];if(t(a))return a}}function Ke(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function xt(e,t){return e.indexOf(t)!==-1}function _s(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var Di=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return ki(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},Oi=e=>Object.prototype.toString.call(e).slice(8,-1),Pn=e=>typeof e>"u",Gi=e=>e===null,Xe=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,Yt=e=>Xe(e)&&Object.keys(e).length===0,Ee=e=>Array.isArray(e),Ri=e=>typeof e=="string",Mi=e=>typeof e=="number"&&!isNaN(e),Bi=e=>typeof e=="boolean",Ui=e=>e instanceof RegExp,et=e=>e instanceof Map,tt=e=>e instanceof Set,xn=e=>Oi(e)==="Symbol",qi=e=>e instanceof Date&&!isNaN(e.valueOf()),Fi=e=>e instanceof Error,vs=e=>typeof e=="number"&&isNaN(e),Ki=e=>Bi(e)||Gi(e)||Pn(e)||Mi(e)||Ri(e)||xn(e),Qi=e=>typeof e=="bigint",Vi=e=>e===1/0||e===-1/0,Hi=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),zi=e=>e instanceof URL,_n=e=>e.replace(/\./g,"\\."),Qt=e=>e.map(String).map(_n).join("."),Ye=e=>{const t=[];let s="";for(let r=0;r<e.length;r++){let a=e.charAt(r);if(a==="\\"&&e.charAt(r+1)==="."){s+=".",r++;continue}if(a==="."){t.push(s),s="";continue}s+=a}const n=s;return t.push(n),t};function re(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var vn=[re(Pn,"undefined",()=>null,()=>{}),re(Qi,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),re(qi,"Date",e=>e.toISOString(),e=>new Date(e)),re(Fi,"Error",(e,t)=>{const s={name:e.name,message:e.message};return t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s},(e,t)=>{const s=new Error(e.message);return s.name=e.name,s.stack=e.stack,t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s}),re(Ui,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),re(tt,"set",e=>[...e.values()],e=>new Set(e)),re(et,"map",e=>[...e.entries()],e=>new Map(e)),re(e=>vs(e)||Vi(e),"number",e=>vs(e)?"NaN":e>0?"Infinity":"-Infinity",Number),re(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),re(zi,"URL",e=>e.toString(),e=>new URL(e))];function Bt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var wn=Bt((e,t)=>xn(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,s)=>{const n=s.symbolRegistry.getValue(t[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),$i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),bn=Bt(Hi,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=$i[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function Cn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var In=Bt(Cn,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const s=t.classRegistry.getAllowedProps(e.constructor);if(!s)return{...e};const n={};return s.forEach(r=>{n[r]=e[r]}),n},(e,t,s)=>{const n=s.classRegistry.getValue(t[1]);if(!n)throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(n.prototype),e)}),Ln=Bt((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,s)=>{const n=s.customTransformerRegistry.findByName(t[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(e)}),Wi=[In,wn,Ln,bn],ws=(e,t)=>{const s=_s(Wi,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=_s(vn,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},Nn={};vn.forEach(e=>{Nn[e.annotation]=e});var Yi=(e,t,s)=>{if(Ee(t))switch(t[0]){case"symbol":return wn.untransform(e,t,s);case"class":return In.untransform(e,t,s);case"custom":return Ln.untransform(e,t,s);case"typed-array":return bn.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=Nn[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},we=(e,t)=>{if(t>e.size)throw new Error("index out of bounds");const s=e.keys();for(;t>0;)s.next(),t--;return s.next().value};function jn(e){if(xt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(xt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(xt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var Ji=(e,t)=>{jn(t);for(let s=0;s<t.length;s++){const n=t[s];if(tt(e))e=we(e,+n);else if(et(e)){const r=+n,a=+t[++s]==0?"key":"value",i=we(e,r);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},Jt=(e,t,s)=>{if(jn(t),t.length===0)return s(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(Ee(n)){const l=+i;n=n[l]}else if(Xe(n))n=n[i];else if(tt(n)){const l=+i;n=we(n,l)}else if(et(n)){if(a===t.length-2)break;const c=+i,u=+t[++a]==0?"key":"value",d=we(n,c);switch(u){case"key":n=d;break;case"value":n=n.get(d);break}}}const r=t[t.length-1];if(Ee(n)?n[+r]=s(n[+r]):Xe(n)&&(n[r]=s(n[r])),tt(n)){const a=we(n,+r),i=s(a);a!==i&&(n.delete(a),n.add(i))}if(et(n)){const a=+t[t.length-2],i=we(n,a);switch(+r==0?"key":"value"){case"key":{const c=s(i);n.set(c,n.get(i)),c!==i&&n.delete(i);break}case"value":{n.set(i,s(n.get(i)));break}}}return e};function Zt(e,t,s=[]){if(!e)return;if(!Ee(e)){Ke(e,(a,i)=>Zt(a,t,[...s,...Ye(i)]));return}const[n,r]=e;r&&Ke(r,(a,i)=>{Zt(a,t,[...s,...Ye(i)])}),t(n,s)}function Zi(e,t,s){return Zt(t,(n,r)=>{e=Jt(e,r,a=>Yi(a,n,s))}),e}function Xi(e,t){function s(n,r){const a=Ji(e,Ye(r));n.map(Ye).forEach(i=>{e=Jt(e,i,()=>a)})}if(Ee(t)){const[n,r]=t;n.forEach(a=>{e=Jt(e,Ye(a),()=>e)}),r&&Ke(r,s)}else Ke(t,s);return e}var eo=(e,t)=>Xe(e)||Ee(e)||et(e)||tt(e)||Cn(e,t);function to(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function so(e,t){const s={};let n;return e.forEach(r=>{if(r.length<=1)return;t||(r=r.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[a,...i]=r;a.length===0?n=i.map(Qt):s[Qt(a)]=i.map(Qt)}),n?Yt(s)?[n]:[n,s]:Yt(s)?void 0:s}var kn=(e,t,s,n,r=[],a=[],i=new Map)=>{const l=Ki(e);if(!l){to(e,r,t);const E=i.get(e);if(E)return n?{transformedValue:null}:E}if(!eo(e,s)){const E=ws(e,s),A=E?{transformedValue:E.value,annotations:[E.type]}:{transformedValue:e};return l||i.set(e,A),A}if(xt(a,e))return{transformedValue:null};const c=ws(e,s),u=(c==null?void 0:c.value)??e,d=Ee(u)?[]:{},f={};Ke(u,(E,A)=>{if(A==="__proto__"||A==="constructor"||A==="prototype")throw new Error(`Detected property ${A}. This is a prototype pollution risk, please remove it from your object.`);const _=kn(E,t,s,n,[...r,A],[...a,e],i);d[A]=_.transformedValue,Ee(_.annotations)?f[A]=_.annotations:Xe(_.annotations)&&Ke(_.annotations,(C,x)=>{f[_n(A)+"."+x]=C})});const g=Yt(f)?{transformedValue:d,annotations:c?[c.type]:void 0}:{transformedValue:d,annotations:c?[c.type,f]:f};return l||i.set(e,g),g};function Dn(e){return Object.prototype.toString.call(e).slice(8,-1)}function bs(e){return Dn(e)==="Array"}function no(e){if(Dn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function ro(e,t,s,n,r){const a={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";a==="enumerable"&&(e[t]=s),r&&a==="nonenumerable"&&Object.defineProperty(e,t,{value:s,enumerable:!1,writable:!0,configurable:!0})}function Xt(e,t={}){if(bs(e))return e.map(r=>Xt(r,t));if(!no(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,a)=>{if(bs(t.props)&&!t.props.includes(a))return r;const i=e[a],l=Xt(i,t);return ro(r,a,l,e,t.nonenumerable),r},{})}var U=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Ni,this.symbolRegistry=new Tn(t=>t.description??""),this.customTransformerRegistry=new Di,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=kn(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const r=so(t,this.dedupe);return r&&(n.meta={...n.meta,referentialEqualities:r}),n}deserialize(e){const{json:t,meta:s}=e;let n=Xt(t);return s!=null&&s.values&&(n=Zi(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=Xi(n,s.referentialEqualities)),n}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};U.defaultInstance=new U;U.serialize=U.defaultInstance.serialize.bind(U.defaultInstance);U.deserialize=U.defaultInstance.deserialize.bind(U.defaultInstance);U.stringify=U.defaultInstance.stringify.bind(U.defaultInstance);U.parse=U.defaultInstance.parse.bind(U.defaultInstance);U.registerClass=U.defaultInstance.registerClass.bind(U.defaultInstance);U.registerSymbol=U.defaultInstance.registerSymbol.bind(U.defaultInstance);U.registerCustom=U.defaultInstance.registerCustom.bind(U.defaultInstance);U.allowErrorProps=U.defaultInstance.allowErrorProps.bind(U.defaultInstance);var On=U.serialize,ao=U.stringify;function io(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function oo(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function lo({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function co({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function uo(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var fo=(e,t=!1)=>{const{json:s}=On(e);return JSON.stringify(s,null,t?2:void 0)},yt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,ho=(e,t)=>e.queryHash.localeCompare(t.queryHash),Gn=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,go=(e,t)=>yt(e)===yt(t)?Gn(e,t):yt(e)>yt(t)?1:-1,mo={status:go,"query hash":ho,"last updated":Gn},At=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,Rn=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,Eo=(e,t)=>At(e)===At(t)?Rn(e,t):At(e)>At(t)?1:-1,po={status:Eo,"last updated":Rn},yo=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),Ao=()=>{const[e,t]=Q("dark");return sn(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)");t(s.matches?"dark":"light");const n=r=>{t(r.matches?"dark":"light")};s.addEventListener("change",n),Fe(()=>s.removeEventListener("change",n))}),e},ze=(e,t,s)=>{if(t.length===0)return s;if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.set(t[0],s),n;const[r,...a]=t;return n.set(r,ze(n.get(r),a,s)),n}if(e instanceof Set){const n=ze(Array.from(e),t,s);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=ze(n[r],a,s),n}if(e instanceof Object){const n={...e};if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=ze(n[r],a,s),n}return e},$e=(e,t)=>{if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.delete(t[0]),s;const[n,...r]=t;return s.set(n,$e(s.get(n),r)),s}if(e instanceof Set){const s=$e(Array.from(e),t);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s.filter((a,i)=>i.toString()!==t[0]);const[n,...r]=t;return s[n]=$e(s[n],r),s}if(e instanceof Object){const s={...e};if(t.length===1)return delete s[t[0]],s;const[n,...r]=t;return s[n]=$e(s[n],r),s}return e},Mn=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const n=document.createElement("style"),r=document.createTextNode("");n.appendChild(r),n.id="_goober",n.setAttribute("nonce",e),t?t.appendChild(n):document.head.appendChild(n)},be,st,nt,rt,Te,at,Ce,Ie,Le,Ne,je,it,ke,ot,Ls,So=(Ls=class{constructor(e){M(this,be);M(this,st);M(this,nt);M(this,rt);M(this,Te,!1);M(this,at);M(this,Ce);M(this,Ie);M(this,Le);M(this,Ne);M(this,je);M(this,it);M(this,ke);M(this,ot);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:u,shadowDOMTarget:d,hideDisabledQueries:f}=e;R(this,be,Q(t)),R(this,nt,s),R(this,rt,n),R(this,st,r),R(this,at,u),R(this,Ce,d),R(this,Ie,Q(a)),R(this,Le,Q(i)),R(this,Ne,Q(l)),R(this,je,Q(c)),R(this,it,Q(f))}setButtonPosition(e){w(this,Ie)[1](e)}setPosition(e){w(this,Le)[1](e)}setInitialIsOpen(e){w(this,Ne)[1](e)}setErrorTypes(e){w(this,je)[1](e)}setClient(e){w(this,be)[1](e)}mount(e){if(w(this,Te))throw new Error("Devtools is already mounted");const t=hn(()=>{const s=this,[n]=w(this,Ie),[r]=w(this,Le),[a]=w(this,Ne),[i]=w(this,je),[l]=w(this,it),[c]=w(this,be);let u;return w(this,ke)?u=w(this,ke):(u=dn(()=>Promise.resolve().then(()=>require("./NCMVHL6D-DItDf9IY.cjs"))),R(this,ke,u)),Mn(w(this,at),w(this,Ce)),ds(u,fs({get queryFlavor(){return w(s,nt)},get version(){return w(s,rt)},get onlineManager(){return w(s,st)},get shadowDOMTarget(){return w(s,Ce)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()}}))},e);R(this,Te,!0),R(this,ot,t)}unmount(){var e;if(!w(this,Te))throw new Error("Devtools is not mounted");(e=w(this,ot))==null||e.call(this),R(this,Te,!1)}},be=new WeakMap,st=new WeakMap,nt=new WeakMap,rt=new WeakMap,Te=new WeakMap,at=new WeakMap,Ce=new WeakMap,Ie=new WeakMap,Le=new WeakMap,Ne=new WeakMap,je=new WeakMap,it=new WeakMap,ke=new WeakMap,ot=new WeakMap,Ls),De,lt,ct,ut,Pe,dt,Oe,Ge,Re,Me,Be,ft,Ue,qe,ht,Ns,To=(Ns=class{constructor(e){M(this,De);M(this,lt);M(this,ct);M(this,ut);M(this,Pe,!1);M(this,dt);M(this,Oe);M(this,Ge);M(this,Re);M(this,Me);M(this,Be);M(this,ft);M(this,Ue);M(this,qe);M(this,ht);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:u,shadowDOMTarget:d,onClose:f,hideDisabledQueries:g}=e;R(this,De,Q(t)),R(this,ct,s),R(this,ut,n),R(this,lt,r),R(this,dt,u),R(this,Oe,d),R(this,Ge,Q(a)),R(this,Re,Q(i)),R(this,Me,Q(l)),R(this,Be,Q(c)),R(this,ft,Q(g)),R(this,Ue,Q(f))}setButtonPosition(e){w(this,Ge)[1](e)}setPosition(e){w(this,Re)[1](e)}setInitialIsOpen(e){w(this,Me)[1](e)}setErrorTypes(e){w(this,Be)[1](e)}setClient(e){w(this,De)[1](e)}setOnClose(e){w(this,Ue)[1](()=>e)}mount(e){if(w(this,Pe))throw new Error("Devtools is already mounted");const t=hn(()=>{const s=this,[n]=w(this,Ge),[r]=w(this,Re),[a]=w(this,Me),[i]=w(this,Be),[l]=w(this,ft),[c]=w(this,De),[u]=w(this,Ue);let d;return w(this,qe)?d=w(this,qe):(d=dn(()=>Promise.resolve().then(()=>require("./2AITGKQY-AK2WgbeT.cjs"))),R(this,qe,d)),Mn(w(this,dt),w(this,Oe)),ds(d,fs({get queryFlavor(){return w(s,ct)},get version(){return w(s,ut)},get onlineManager(){return w(s,lt)},get shadowDOMTarget(){return w(s,Oe)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()},get onClose(){return u()}}))},e);R(this,Pe,!0),R(this,ht,t)}unmount(){var e;if(!w(this,Pe))throw new Error("Devtools is not mounted");(e=w(this,ht))==null||e.call(this),R(this,Pe,!1)}},De=new WeakMap,lt=new WeakMap,ct=new WeakMap,ut=new WeakMap,Pe=new WeakMap,dt=new WeakMap,Oe=new WeakMap,Ge=new WeakMap,Re=new WeakMap,Me=new WeakMap,Be=new WeakMap,ft=new WeakMap,Ue=new WeakMap,qe=new WeakMap,ht=new WeakMap,Ns);function Po(e){const t=T.useQueryClient(e.client),s=z.useRef(null),{buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:u}=e,[d]=z.useState(new So({client:t,queryFlavor:"React Query",version:"5",onlineManager:T.onlineManager,buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:u}));return z.useEffect(()=>{d.setClient(t)},[t,d]),z.useEffect(()=>{n&&d.setButtonPosition(n)},[n,d]),z.useEffect(()=>{r&&d.setPosition(r)},[r,d]),z.useEffect(()=>{d.setInitialIsOpen(a||!1)},[a,d]),z.useEffect(()=>{d.setErrorTypes(i||[])},[i,d]),z.useEffect(()=>(s.current&&d.mount(s.current),()=>{d.unmount()}),[d]),o.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:s})}function xo(e){const t=T.useQueryClient(e.client),s=z.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:i}=e,[l]=z.useState(new To({client:t,queryFlavor:"React Query",version:"5",onlineManager:T.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:n,styleNonce:r,shadowDOMTarget:a,onClose:e.onClose,hideDisabledQueries:i}));return z.useEffect(()=>{l.setClient(t)},[t,l]),z.useEffect(()=>{l.setOnClose(e.onClose??(()=>{}))},[e.onClose,l]),z.useEffect(()=>{l.setErrorTypes(n||[])},[n,l]),z.useEffect(()=>(s.current&&l.mount(s.current),()=>{l.unmount()}),[l]),o.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:s})}var Cs=process.env.NODE_ENV!=="development"?function(){return null}:Po;process.env.NODE_ENV;const Bn=V.atom(""),_o=()=>{v.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),v.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"}),v.registerChaiFeatureFlag("enable-ai-chat-panel",{description:"Enable AI chat panel"})},vo=()=>{const e=D(),t=k();return T.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},wo=()=>{const{data:e}=Z(),{data:t}=ue(),{data:s}=ye(),n=D(),r=k(),a=h.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]),i=h.useRef(new Map);return T.useMutation({mutationFn:async({block:l})=>{const c=l._id,u=(t==null?void 0:t.lang)||a,d=`${c}:${u}`;if(i.current.has(d))return i.current.get(d);const f=r(n,{action:y.GET_BLOCK_ASYNC_PROPS,data:{block:l,lang:u,pageProps:{slug:t==null?void 0:t.slug,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:a,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id}}});return i.current.set(d,f),f.finally(()=>{i.current.delete(d)}),f}})},Un=()=>{const[,e]=ee();return h.useCallback((t,s)=>{const r=new URLSearchParams(window.location.search).get("lang"),a=new URLSearchParams({page:t});r&&a.set("lang",r),window.history.pushState({},"",`?${a.toString()}`),e(a),window.dispatchEvent(new PopStateEvent("popstate")),s==null||s()},[e])},qn=()=>{const e=Un();return h.useCallback(({pageId:t})=>{e(t)},[e])},bo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-CIMo79Di.cjs"))),Co=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-CtGpDkC6.cjs"))),Io=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-CCsiDIVl.cjs"))),Lo=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-BI4jd0O7.cjs")));_o();Jn.loadWebBlocks();v.registerChaiTopBar(ia);ja();v.registerChaiMediaManager(bo);v.registerChaiSaveToLibrary(Co);const No={role:"",permissions:null},Is=e=>{const{data:t}=pa();mr();const s=Ot(),{data:n=No,isFetching:r}=Hs(),{data:a,isFetching:i}=de(),{data:l,isFetching:c}=vo(),{data:u,isFetching:d}=ye(),f=r||i||c||d,[g]=ee(),E=g.get("page"),{data:A}=Z(),{data:_,isFetching:C}=ua(),{blocks:x}=ca(_),{lockingStatus:S,pageLock:P}=Ae(),{data:N,isFetching:K}=Qs(),G=oa(),{onSave:ie}=ya(),{mutateAsync:oe}=wo(),{getPartialBlocks:F,getPartialBlockBlocks:L}=Aa(),{mutateAsync:j}=Ir(),{mutateAsync:W}=Vs(),H=qn(),[ne,mt]=h.useState(!1),le=h.useRef([]),_e=h.useMemo(()=>p.get(u,"theme",{})||{},[u]),Se=p.isEmpty(S)&&(P==null?void 0:P.status)==="editing",Qn=(P==null?void 0:P.status)==="checking",hs=C||Qn||K;le.current=x;const[Vn]=V.useAtom(Bn);h.useEffect(()=>{const X=()=>{document.hidden?mt(!0):mt(!1)};return window.addEventListener("visibilitychange",X),()=>window.removeEventListener("visibilitychange",X)},[]);const Hn=h.useMemo(()=>{const X={};return n&&(X.permissions=p.get(n,"permissions",null),X.role=p.get(n,"role","user")),X},[n]),gs=h.useMemo(()=>t==null?void 0:t.some(X=>X.isSiteLibrary),[t]),zn=h.useCallback(async(X,Et)=>await j({pageType:X,query:Et}),[j]);return o.jsxs(o.Fragment,{children:[hs&&o.jsx(os,{className:f?"fixed inset-0 bg-white":"bg-white/75",children:o.jsx(b.Loader,{className:`animate-spin text-primary ${f?"h-6 w-6":"h-5 w-5"}`})}),Vn&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"absolute inset-0 z-[999999] flex min-h-screen w-screen items-center justify-center bg-gray-100",children:o.jsx(b.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:o.jsx(Lo,{})}),o.jsx(v.ChaiBuilderEditor,{flags:e.flags?{...e.flags,librarySite:gs}:{librarySite:gs},gotoPage:H,collections:l??[],getBlockAsyncProps:oe,pageExternalData:N,themePresets:e.themePresets??[],pageId:A==null?void 0:A.id,loading:C,fallbackLang:s,languages:(u==null?void 0:u.languages)||[],brandingOptions:(u==null?void 0:u.theme)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!ne&&Se&&(e.autoSave??!0),autoSaveInterval:e.autoSaveInterval??15,onError:e.onError||console.error,getPartialBlockBlocks:L,getPartialBlocks:F,blocks:C?[]:x,theme:p.cloneDeep(_e),pageTypes:a,searchPageTypeItems:zn,askAiCallBack:G,onSave:async({blocks:X,theme:Et,needTranslations:$n})=>{if(!E)return!0;le.current=X;const ms=[...X];return await ie({page:E,blocks:ms,needTranslations:$n}),le.current=ms,p.isEqual(Et,_e)||await W({settings:{theme:Et}}),!0},themePanelComponent:Io,...Hn}),o.jsxs("div",{children:[o.jsx(yr,{isFetchingPage:hs}),o.jsx(Ar,{})]})]})},jo=new T.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),ko=e=>{const[,t]=jt(),[s,n]=h.useState(!1);return h.useEffect(()=>(t(p.pick(e,["apiUrl","usersApiUrl","assetsApiUrl","getPreviewUrl","getLiveUrl","topLeftCorner","onLogout","getAccessToken","websocket","getLoggedInUser","features","currentUser"])),setTimeout(()=>{n(!0)},200),()=>{n(!1),t({})}),[e,t]),s?p.get(e,"hasReactQueryProvider",!1)===!0?o.jsxs(o.Fragment,{children:[o.jsx(Is,{...e}),o.jsx(Cs,{})]}):o.jsxs(T.QueryClientProvider,{client:jo,children:[o.jsx(Is,{...e}),o.jsx(Cs,{})]}):o.jsx("div",{})},Do=z.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-D_iF9Sm3.cjs")));function Fn({data:e,onSelect:t,dataType:s="value",disabled:n=!1}){const[r,a]=z.useState(!1);return o.jsxs(m.Popover,{open:r,onOpenChange:a,children:[o.jsxs(m.Tooltip,{children:[o.jsx(m.TooltipTrigger,{asChild:!0,children:o.jsx(m.PopoverTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",variant:"outline",className:"h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,disabled:n,children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:o.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),o.jsx(m.TooltipContent,{children:"Add field"})]}),r&&o.jsx(z.Suspense,{children:o.jsx(Do,{data:e,onSelect:t,dataType:s,open:r,setOpen:a})})]})}const Oo=()=>{const{savePageAsync:e}=v.useSavePage(),t=T.useQueryClient();return h.useCallback(async()=>{await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t])},Go=()=>{const e=T.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},Ro=()=>{const e=D(),t=k(),{data:s}=ue(),n=T.useQueryClient();return T.useMutation({mutationFn:async r=>{if(!(s!=null&&s.id))throw new Error("No active page found");return await t(`${e}`,{action:y.UPDATE_PAGE_METADATA,data:{id:s.id,metadata:r}})},onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]}),n.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]})},onError:()=>{console.error("Failed to update metadata")}})},Mo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-CIMo79Di.cjs"))),Bo=({assetId:e,assetUrl:t,onChange:s,className:n="",placeholder:r="Select an image",disabled:a=!1})=>{const{t:i}=v.useTranslation(),[l,c]=h.useState(!1),u=()=>{a||c(!0)},d=()=>{c(!1)},f=A=>{const _=Array.isArray(A)?A[0]:A;_!=null&&_.url&&s(p.pick(_,["url","id"])),c(!1)},g=()=>{s({url:"",id:""})},E=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return o.jsxs("div",{className:`w-full ${n}`,children:[t?o.jsxs("div",{className:"relative overflow-hidden rounded-md border",children:[E?o.jsx("div",{className:"flex h-12 items-center bg-gray-100 px-4",children:o.jsx("p",{className:"text-xs text-gray-500",children:t})}):o.jsx("img",{onClick:u,src:t,alt:i("Selected image"),className:"h-auto max-h-[100px] w-full bg-gray-100 object-contain"}),o.jsxs("div",{className:"absolute right-2 top-2 flex gap-2",children:[o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white text-red-500",onClick:g,disabled:a,children:E?o.jsx(b.X,{className:"h-4 w-4"}):o.jsx(b.Trash2,{className:"h-4 w-4"})}),!E&&o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white/80 hover:bg-white/90",onClick:u,disabled:a,children:o.jsx(b.ImageIcon,{className:"h-4 w-4"})})]})]}):o.jsx("div",{className:`flex cursor-pointer items-center justify-center rounded-md border border-dashed p-6 ${a?"cursor-not-allowed opacity-50":"hover:border-gray-400"}`,onClick:u,children:o.jsxs("div",{className:"flex flex-col items-center gap-2",children:[o.jsx(b.ImageIcon,{className:"h-10 w-10 text-gray-400"}),o.jsx("p",{className:"text-sm text-gray-500",children:r})]})}),o.jsx(m.Dialog,{open:l,onOpenChange:c,children:o.jsxs(m.DialogContent,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[o.jsxs(m.DialogHeader,{className:"hidden border-b px-4 py-2",children:[o.jsx(m.DialogTitle,{children:i("Select Image")}),o.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:d,children:o.jsx(b.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"h-full flex-1 p-4",children:o.jsx(h.Suspense,{children:o.jsx(Mo,{close:d,onSelect:f,mode:"image",assetId:e})})})]})})]})},Uo=h.createContext(null),Vt={didCatch:!1,error:null};class Kn extends h.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Vt}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var s,n,r=arguments.length,a=new Array(r),i=0;i<r;i++)a[i]=arguments[i];(s=(n=this.props).onReset)===null||s===void 0||s.call(n,{args:a,reason:"imperative-api"}),this.setState(Vt)}}componentDidCatch(t,s){var n,r;(n=(r=this.props).onError)===null||n===void 0||n.call(r,t,s)}componentDidUpdate(t,s){const{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&s.error!==null&&qo(t.resetKeys,r)){var a,i;(a=(i=this.props).onReset)===null||a===void 0||a.call(i,{next:r,prev:t.resetKeys,reason:"keys"}),this.setState(Vt)}}render(){const{children:t,fallbackRender:s,FallbackComponent:n,fallback:r}=this.props,{didCatch:a,error:i}=this.state;let l=t;if(a){const c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof s=="function")l=s(c);else if(n)l=h.createElement(n,c);else if(r!==void 0)l=r;else throw i}return h.createElement(Uo.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},l)}}function qo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((s,n)=>!Object.is(s,t[n]))}const Fo=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),es=e=>{if(!e.trim())return{isValid:!1,parsed:null,placeholders:[],error:{message:"JSON is empty"}};try{return{isValid:!0,parsed:JSON.parse(e),error:null,placeholders:[]}}catch{}const t=/{{([^{}]+)}}/g,s=[];let n=e,r;for(;(r=t.exec(e))!==null;){const a=r[0],i=r.index,l=`"__placeholder_${s.length}__"`;s.push({original:a,replaced:l,position:i}),n=n.replace(a,l)}try{return{isValid:!0,parsed:JSON.parse(n),error:null,placeholders:s}}catch(a){const i=a,l=i.message.match(/position (\d+)/),c=l?parseInt(l[1]):void 0;let u,d;if(c!==void 0){const f=n.substring(0,c).split(`
|
|
2
|
-
`);u=f.length,d=f[f.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:i.message,line:u,column:d,position:c}}}},Ko=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const i=`"__placeholder_${a}__"`,l=new RegExp(Fo(i),"g");n=n.replace(l,r)}),n},Qo=(e,t)=>{if(!e)return"";let s=JSON.stringify(e,null,2);const n=/{{([^{}]+)}}/g;let r;for(;(r=n.exec(s))!==null;){const a=r[1],i=p.get(t,a,null);s=s.replace(r[0],i)}return s},Vo=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-CyxmC9y5.cjs"))),Ho=({value:e,onChange:t,disabled:s=!1,readOnly:n=!1,placeholder:r="Enter JSON",rows:a=6,id:i="json-input",pageData:l={},handleFieldInsert:c,hasJsonLdForSelectedLang:u,copyJsonLDFromDefaultPage:d})=>{const[f,g]=h.useState("edit"),[E,A]=h.useState(null),[_,C]=h.useState(""),x=h.useRef(null),[S]=jt(),P=i==="jsonLD"&&p.get(S,"features.sharedJsonLD",!1),N=i==="jsonLD"&&!u&&!!d;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const K=F=>{if(n)return;const L=F.target.value;t(L)},G=F=>{if(F.key==="Tab"){F.preventDefault();const L=F.currentTarget,j=L.selectionStart,W=L.selectionEnd;if(j!==W){const ne=e.substring(j,W).split(`
|
|
3
|
-
`);if(F.shiftKey){const le=ne.map(Se=>Se.startsWith(" ")?Se.substring(2):Se).join(`
|
|
4
|
-
`),_e=e.substring(0,j)+le+e.substring(W);t(_e),setTimeout(()=>{L.selectionStart=j,L.selectionEnd=j+le.length},0)}else{const le=ne.map(Se=>` ${Se}`).join(`
|
|
5
|
-
`),_e=e.substring(0,j)+le+e.substring(W);t(_e),setTimeout(()=>{L.selectionStart=j,L.selectionEnd=j+le.length},0)}}else{const H=e.substring(0,j)+" "+e.substring(W);t(H),setTimeout(()=>{L.selectionStart=L.selectionEnd=j+2},0)}}};h.useEffect(()=>{const F=es(e);if(F.isValid)if(A(null),F.parsed){const L=Qo(F.parsed,l);C(L)}else C("");else A(F.error),C("")},[e,l]);const ie=()=>{const F=es(e);if(F.isValid&&F.parsed){const L=Ko(F.parsed,F.placeholders);t(L)}},oe=()=>{E!=null&&E.position&&x.current&&(x.current.focus(),x.current.setSelectionRange(E.position,E.position+1))};return o.jsx(Kn,{fallback:o.jsx("div",{children:"Some error"}),children:o.jsx("div",{className:"space-y-2",children:o.jsxs(m.Tabs,{value:f,onValueChange:g,className:"w-full",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsxs(m.TabsList,{className:"w-max",children:[o.jsxs(m.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[o.jsx(b.Code,{className:"h-4 w-4"}),o.jsx("span",{children:"Edit"})]}),o.jsxs(m.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!e.trim()||E!==null||N,children:[o.jsx(b.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),P&&o.jsxs(m.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||E!==null,children:[o.jsx(b.Share2,{className:"h-4 w-4"}),o.jsx("span",{children:"Shared"})]})]}),N?null:f==="edit"&&!n&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(Fn,{dataType:"value",data:l??{},onSelect:F=>c&&c(F,i)})})]}),o.jsxs(m.TabsContent,{value:"edit",className:"relative mt-0",children:[!N&&f==="edit"&&o.jsx(Gt,{content:"Format JSON",side:"right",showTooltip:!s&&!E,children:o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",onClick:ie,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||s||E!==null,children:o.jsx(b.FileCode2,{})})}),N?o.jsx("div",{className:"flex h-40 items-center justify-center rounded-md bg-black/20",children:o.jsxs("div",{className:"flex max-w-[400px] flex-col items-center gap-2 rounded-md bg-white p-4 shadow-lg",children:[o.jsx("div",{className:"max-w-xl text-center text-xs text-gray-500",children:"JSON-LD for is not added for selected language. JSON LD will be used from default language."}),o.jsxs(m.Button,{type:"button",variant:"default",size:"sm",onClick:d,children:[o.jsx(b.Plus,{}),"Copy & Edit from default language"]})]})}):o.jsx(m.Textarea,{ref:x,id:i,name:i,className:`rounded-md border border-input text-xs ${E?"border-red-500":""}`,onChange:K,onKeyDown:G,value:e,placeholder:r,rows:a,disabled:s,readOnly:n}),E&&o.jsxs(m.Alert,{variant:"destructive",className:"mt-2",children:[o.jsx(b.AlertTriangle,{className:"h-4 w-4"}),o.jsxs(m.AlertDescription,{className:"flex flex-col",children:[o.jsx("span",{className:"font-medium",children:"Invalid JSON"}),o.jsx("span",{className:"text-sm",children:E.message}),E.line&&E.column&&o.jsxs("span",{className:"text-sm",children:["Error at line ",E.line,", column ",E.column]}),o.jsx(m.Button,{type:"button",variant:"link",size:"sm",className:"mt-1 h-auto self-start p-0 text-sm",onClick:oe,children:"Show position"})]})]})]}),o.jsxs(m.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(m.Textarea,{rows:a,value:_,readOnly:!0,className:"cursor-default bg-muted font-mono text-sm"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This is how the JSON will look after placeholder substitution."})]}),P&&o.jsx(m.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(h.Suspense,{children:o.jsx(Vo,{})})})]})})})};if(typeof window>"u")throw new Error("@chaibuilder/pages is not available on the server");exports.$TRACK=ls;exports.ACTIONS=y;exports.BlurContainer=os;exports.ChaiBuilderPages=ko;exports.ChaiBuilderPagesRealtime=Ds;exports.Dynamic=Ii;exports.ErrorBoundary=Kn;exports.For=ei;exports.ImagePicker=Bo;exports.Index=ti;exports.LANGUAGES=Ve;exports.LanguageSwitcher=Us;exports.Match=ri;exports.NestedPathSelector=Fn;exports.PAGES_PERMISSIONS=te;exports.PageActionsDropdown=Fs;exports.PermissionChecker=St;exports.Portal=bi;exports.Show=si;exports.SmartJsonInput=Ho;exports.Switch=ni;exports.Tooltip=Gt;exports.addEventListener=En;exports.addNewLangAtom=Dt;exports.batch=Ra;exports.className=mn;exports.clearDelegatedEvents=pi;exports.convertRemToPixels=yo;exports.createComponent=ds;exports.createComputed=tn;exports.createContext=Fa;exports.createEffect=cs;exports.createMemo=$;exports.createRenderEffect=me;exports.createRoot=ge;exports.createSignal=Q;exports.createUniqueId=Xa;exports.delegateEvents=gn;exports.deleteNestedDataByPath=$e;exports.displayValue=fo;exports.getMutationStatusColor=co;exports.getPreferredColorScheme=Ao;exports.getQueryStatusColor=lo;exports.getQueryStatusColorByLabel=uo;exports.getQueryStatusLabel=io;exports.getSidedProp=oo;exports.insert=Nt;exports.memo=gi;exports.mergeProps=fs;exports.mutationSortFns=po;exports.navigateToPage=rs;exports.on=Ma;exports.onCleanup=Fe;exports.onMount=sn;exports.parseJSONWithPlaceholders=es;exports.previewUrlAtom=Bn;exports.serialize=On;exports.setAttribute=Lt;exports.sortFns=mo;exports.splitProps=un;exports.spread=pn;exports.stringify=ao;exports.template=Ei;exports.throwConfetti=Tt;exports.untrack=Y;exports.updateNestedDataByPath=ze;exports.use=yn;exports.useActivePage=ue;exports.useAddGlobalSchema=da;exports.useApiUrl=D;exports.useApplySchemaToAllPages=ma;exports.useAssetsApiUrl=er;exports.useBuilderFetch=nr;exports.useBuilderPageData=Qs;exports.useChaiAuth=gt;exports.useChaiUserInfo=Rs;exports.useChangePage=Un;exports.useChangeSlug=Gr;exports.useClearAll=Go;exports.useContext=Ka;exports.useCreatePage=Lr;exports.useCurrentPage=Z;exports.useDeleteGlobalSchema=ha;exports.useDeletePage=jr;exports.useDynamicPageSelector=Gs;exports.useFallbackLang=Ot;exports.useFetch=k;exports.useGotoPage=qn;exports.useIsLanguagePageCreated=ts;exports.useLanguagePages=pe;exports.useMarkAsTemplate=Dr;exports.usePageEditInfo=kt;exports.usePageLockRequestTakeOver=Ms;exports.usePageType=qs;exports.usePageTypes=de;exports.usePageUserMapping=gr;exports.usePagesProps=jt;exports.usePublishPages=is;exports.useReloadPage=Oo;exports.useRemoveSchemaFromAllPages=Ea;exports.useSearchParams=ee;exports.useTogglePageGlobalSchema=ga;exports.useTransition=qa;exports.useUnmarkAsTemplate=Or;exports.useUnpublishPage=kr;exports.useUpdateActivePageMetadata=Ro;exports.useUpdateGlobalSchema=fa;exports.useUpdatePage=Nr;exports.useUpdateWebsiteSettings=Vs;exports.useUserRoleAndPermissions=Hs;exports.useWebsiteLanguagePages=Sr;exports.useWebsitePages=as;exports.useWebsiteSetting=ye;
|