@chaibuilder/pages 0.16.22 → 0.16.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/{2AITGKQY-BuWtti7-.js → 2AITGKQY-Ir_ZXu1s.js} +2 -2
  2. package/dist/{2AITGKQY-BH_4lP5P.cjs → 2AITGKQY-UndKMj-X.cjs} +1 -1
  3. package/dist/{NCMVHL6D-DbC9VYfW.js → NCMVHL6D-B3xcD0Vz.js} +2 -2
  4. package/dist/{NCMVHL6D-CfRPe-3L.cjs → NCMVHL6D-taGMv4he.cjs} +1 -1
  5. package/dist/{ZDWCUMSJ-CE0Md3aC.js → ZDWCUMSJ-B1vApR00.js} +1 -1
  6. package/dist/{ZDWCUMSJ-BxhCnC2U.cjs → ZDWCUMSJ-Cot4ixKZ.cjs} +1 -1
  7. package/dist/{active-in-another-tab-SSCyhy2-.cjs → active-in-another-tab-DYU7aCUa.cjs} +1 -1
  8. package/dist/{active-in-another-tab-C4o8FQXv.js → active-in-another-tab-Kp8LaYW5.js} +1 -1
  9. package/dist/{add-new-language-page-BCu4Npk2.js → add-new-language-page-0J2KTKg6.js} +2 -2
  10. package/dist/{add-new-language-page-DUkVmwsT.cjs → add-new-language-page-CkyPkpzC.cjs} +1 -1
  11. package/dist/{add-new-page-D1pc9kLA.js → add-new-page-BjxHUGIo.js} +1 -1
  12. package/dist/{add-new-page-BDpRUueB.cjs → add-new-page-DPtVHa8m.cjs} +1 -1
  13. package/dist/{ai-panel-content-Dg6P7vk7.js → ai-panel-content-CMfopU0G.js} +2 -2
  14. package/dist/{ai-panel-content-Bq3BC1Dm.cjs → ai-panel-content-nmbQV7rT.cjs} +1 -1
  15. package/dist/{ai-panel-default-lang-BxYd_6VF.js → ai-panel-default-lang-7L9rURdC.js} +3 -3
  16. package/dist/{ai-panel-default-lang-C0X_Srso.cjs → ai-panel-default-lang-B5eNybL4.cjs} +2 -2
  17. package/dist/{ai-panel-other-lang-BOu1wJ5J.cjs → ai-panel-other-lang-DLn89TFE.cjs} +1 -1
  18. package/dist/{ai-panel-other-lang-CBAP_iX-.js → ai-panel-other-lang-U5XRqxbF.js} +3 -3
  19. package/dist/{ai-prompt-input-bqLGbsQ2.cjs → ai-prompt-input-6LzuYu5L.cjs} +1 -1
  20. package/dist/{ai-prompt-input-CiZCB6jc.js → ai-prompt-input-B24vn-LG.js} +2 -2
  21. package/dist/{ai-translation-prompt-Cas13J-r.cjs → ai-translation-prompt-CB67Sqo9.cjs} +1 -1
  22. package/dist/{ai-translation-prompt-D3XU5z3f.js → ai-translation-prompt-cym054ja.js} +1 -1
  23. package/dist/{continue-editing-in-this-client-DIpi2ZSi.js → continue-editing-in-this-client-BDYiQrbE.js} +1 -1
  24. package/dist/{continue-editing-in-this-client-DbHzW_zt.cjs → continue-editing-in-this-client-BYJaymOL.cjs} +1 -1
  25. package/dist/{delete-page-DPHNAOC6.cjs → delete-page-BXEQB0Si.cjs} +1 -1
  26. package/dist/{delete-page-CODOstkw.js → delete-page-CvSN4E4V.js} +1 -1
  27. package/dist/{digital-asset-manager-BuYVjKfQ.js → digital-asset-manager-BxbX7ji1.js} +1 -1
  28. package/dist/{digital-asset-manager-BllbsemN.cjs → digital-asset-manager-CF1Lyc5K.cjs} +1 -1
  29. package/dist/{duplicate-page-DfH67AsW.js → duplicate-page-BFnuk1nL.js} +2 -2
  30. package/dist/{duplicate-page-Dc6_UBNZ.cjs → duplicate-page-C32_9H41.cjs} +1 -1
  31. package/dist/{dynamic-page-selector-Dd8Orls1.cjs → dynamic-page-selector-CLxpglyO.cjs} +1 -1
  32. package/dist/{dynamic-page-selector-C2UK6qGj.js → dynamic-page-selector-CSTuQhej.js} +1 -1
  33. package/dist/index-Bre43r-W.cjs +5 -0
  34. package/dist/{index-B_T6ZeA4.js → index-tgsBai_8.js} +783 -779
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.d.ts +8 -0
  37. package/dist/index.js +1 -1
  38. package/dist/{json-diff-viewer-D8uyTokS.js → json-diff-viewer-2gVCV5T-.js} +1 -1
  39. package/dist/{json-diff-viewer-1IHmR_Nt.cjs → json-diff-viewer-34Sqd4il.cjs} +1 -1
  40. package/dist/{lang-panel-D-Pbw2bR.cjs → lang-panel-CXIcTGVk.cjs} +1 -1
  41. package/dist/{lang-panel-d7376A7w.js → lang-panel-Cj0axCpE.js} +2 -2
  42. package/dist/{mark-as-template-Bx-MAB5M.js → mark-as-template-1TuznHtx.js} +1 -1
  43. package/dist/{mark-as-template-DHFkkBvV.cjs → mark-as-template-DKBwTiMJ.cjs} +1 -1
  44. package/dist/{no-language-page-content-DkK7mBnG.cjs → no-language-page-content-B8udZsi2.cjs} +1 -1
  45. package/dist/{no-language-page-content-if-qlxZz.js → no-language-page-content-C265--no.js} +1 -1
  46. package/dist/{no-language-page-dialog-49fBehZo.cjs → no-language-page-dialog-CctilPnb.cjs} +1 -1
  47. package/dist/{no-language-page-dialog-CCLWQP1E.js → no-language-page-dialog-DgaP74-Y.js} +2 -2
  48. package/dist/{page-creator-DRDoy3nM.js → page-creator-Cer7L7dg.js} +2 -2
  49. package/dist/{page-creator-DlJXKAhw.cjs → page-creator-NkF29o0S.cjs} +1 -1
  50. package/dist/{page-lock-DOnPhjGp.cjs → page-lock-0qEG4sLX.cjs} +1 -1
  51. package/dist/{page-lock-pwxPivz-.js → page-lock-DNrP3AhL.js} +2 -2
  52. package/dist/{page-locked-dialog-DKn93bBu.cjs → page-locked-dialog-B9p5gIGE.cjs} +1 -1
  53. package/dist/{page-locked-dialog-238NohyB.js → page-locked-dialog-U5eDKeBc.js} +1 -1
  54. package/dist/{page-manager-new-Ch0UNJM1.cjs → page-manager-new-BL5S9ccS.cjs} +1 -1
  55. package/dist/{page-manager-new-hEQwUorR.js → page-manager-new-DGaBkeJp.js} +2 -2
  56. package/dist/{page-manager-search-and-filter-B86rQEO4.js → page-manager-search-and-filter-DDdYtDF7.js} +1 -1
  57. package/dist/{page-manager-search-and-filter-4JatGyBT.cjs → page-manager-search-and-filter-DKrQdcb0.cjs} +1 -1
  58. package/dist/{page-revisions-content-V9S1rPUy.js → page-revisions-content-CoVYI0hI.js} +2 -2
  59. package/dist/{page-revisions-content-ChOACVs4.cjs → page-revisions-content-NE8Y5DrC.cjs} +1 -1
  60. package/dist/pages.css +1 -1
  61. package/dist/{publish-pages-content-CXKknMnI.cjs → publish-pages-content-CCUKnVTH.cjs} +1 -1
  62. package/dist/{publish-pages-content-GKnG7R5W.js → publish-pages-content-KgbEbRVV.js} +2 -2
  63. package/dist/{save-to-lib-BderZ0Qz.cjs → save-to-lib-C06RQn4k.cjs} +1 -1
  64. package/dist/{save-to-lib-BO3WEr-u.js → save-to-lib-CQmcDI5w.js} +1 -1
  65. package/dist/{selected-block-display-DAe0XQgw.js → selected-block-display-7n8S3vf1.js} +1 -1
  66. package/dist/{selected-block-display-yB5bvo9w.cjs → selected-block-display-DDC1_UC8.cjs} +1 -1
  67. package/dist/{seo-panel-DuC3gQQy.js → seo-panel-C-dqg-1A.js} +1 -1
  68. package/dist/{seo-panel-C2WY1dTf.cjs → seo-panel-hwJUoGfJ.cjs} +1 -1
  69. package/dist/server.d.ts +8 -0
  70. package/dist/{shared-json-ld-ChfktUpf.cjs → shared-json-ld-BP2l89h2.cjs} +1 -1
  71. package/dist/{shared-json-ld-DMpCm3M4.js → shared-json-ld-BUPafGh_.js} +1 -1
  72. package/dist/{slug-input-CrjrFrxP.cjs → slug-input-91_G-ww1.cjs} +1 -1
  73. package/dist/{slug-input-CO6AGAQD.js → slug-input-hcJHNszn.js} +1 -1
  74. package/dist/{take-over-request-Du7grW5x.js → take-over-request-Dw2P9U_Q.js} +1 -1
  75. package/dist/{take-over-request-mNydSSFX.cjs → take-over-request-kRGwkXvv.cjs} +1 -1
  76. package/dist/{theme-panel-footer-CSC6DpWO.js → theme-panel-footer-2qsvp4AM.js} +1 -1
  77. package/dist/{theme-panel-footer-eZ1bbLzq.cjs → theme-panel-footer-DmO4-lci.cjs} +1 -1
  78. package/dist/{unmark-as-template-DzU6-XK7.cjs → unmark-as-template-BBzZqNJt.cjs} +1 -1
  79. package/dist/{unmark-as-template-dEb6wFT9.js → unmark-as-template-DbXx3l6p.js} +1 -1
  80. package/dist/{unpublish-page-CxAB3-Cj.js → unpublish-page-BKQqPk_e.js} +1 -1
  81. package/dist/{unpublish-page-DGd2Kktq.cjs → unpublish-page-CHYNjTFU.cjs} +1 -1
  82. package/dist/{web-preview-yBF4EXzm.js → web-preview-BKoPv6AO.js} +1 -1
  83. package/dist/{web-preview-B6G0vdiq.cjs → web-preview-D4KdtUYp.cjs} +1 -1
  84. package/package.json +3 -3
  85. package/dist/index--Lu_Q_nO.cjs +0 -5
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),F=require("lodash-es"),f=require("lucide-react"),u=require("react"),fe=require("react-dropzone"),g=require("./index--Lu_Q_nO.cjs"),w=require("sonner"),Y=require("./image-compression-DZ9WMmyn.cjs"),z=require("@tanstack/react-query"),pe=()=>{const n=g.useAssetsApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>{const o=i.map(async l=>x(n,{action:g.ACTIONS.UPLOAD_ASSET,data:l}));return await Promise.all(o)},onSuccess:i=>{var o;if(i!=null&&i.some(s=>s.error))throw new Error(((o=i==null?void 0:i.find(s=>s.error))==null?void 0:o.error)||"Failed to upload asset");{r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]});const s=i==null?void 0:i.length;w.toast.success(`${s===1?"Asset":s+" Assets"} uploaded successfully`)}},onError:()=>{w.toast.error("Failed to upload asset")}})},ge=()=>{const n=g.useAssetsApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>x(n,{action:g.ACTIONS.DELETE_ASSET,data:{id:i}}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]}),w.toast.success("Asset deleted successfully")},onError:()=>{w.toast.error("Failed to delete asset")}})},je=()=>{const n=g.useAssetsApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>x(n,{action:g.ACTIONS.UPDATE_ASSET,data:i}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]}),i!=null&&i.id&&r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSET,i.id]}),w.toast.success("Asset updated successfully")},onError:()=>{w.toast.error("Failed to update asset")}})};function ve({currentPage:n,totalPages:r,onPageChange:x,pageRangeDisplayed:i=3,showPageInput:o=!0,className:s=""}){const[l,E]=u.useState(String(n)),N=u.useMemo(()=>{const c=Math.floor(i/2);let m=Math.max(1,n-c),d=Math.min(r,n+c);d-m+1<i&&(m===1?d=Math.min(r,m+i-1):d===r&&(m=Math.max(1,d-i+1)));const p=[];m>1&&(p.push(1),m>2&&p.push("..."));for(let y=m;y<=d;y++)p.push(y);return d<r&&(d<r-1&&p.push("..."),p.push(r)),p},[n,r,i]),v=c=>{c!==n&&c>=1&&c<=r&&(x(c),E(String(c)))},j=()=>{n>1&&v(n-1)},b=()=>{n<r&&v(n+1)},C=()=>{const c=Number(l);!isNaN(c)&&c>=1&&c<=r&&v(c)},A=c=>{c.key==="Enter"&&C()};return r<=1?null:e.jsxs("div",{className:`flex flex-wrap items-center justify-center gap-3 ${s}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:j,disabled:n===1,className:"px-2 py-1 text-sm hover:bg-gray-50",children:[e.jsx(f.ChevronLeft,{className:" h-4 w-4"}),"Previous"]}),e.jsx("div",{className:"flex items-center gap-2",children:N.map((c,m)=>{if(c==="...")return e.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${m}`);const d=c,p=d===n;return e.jsx(a.Button,{variant:p?"default":"outline",size:"sm",onClick:()=>v(d),className:p?"border-blue-600 bg-blue-600 px-3 py-1 text-sm text-white":"border px-3 py-1 text-sm hover:bg-gray-50 hover:text-black",children:d},d)})}),e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:b,disabled:n===r,className:"px-2 py-1 text-sm hover:bg-gray-50",children:["Next",e.jsx(f.ChevronRight,{className:" h-4 w-4"})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Go to"}),e.jsx(a.Input,{type:"number",min:1,max:r,value:l,onChange:c=>{const m=c.target.value.replace(/[^\d]/g,"");E(m)},onKeyDown:A,className:"h-8 w-16 px-2 py-1"}),e.jsx(a.Button,{variant:"outline",size:"sm",onClick:C,disabled:l===""||Number(l)<1||Number(l)>r,children:"Go"})]})]})}const ye=(n={})=>{const r=g.useAssetsApiUrl(),x=g.useFetch(),{search:i,page:o=1,limit:s=30}=n;return z.useQuery({queryKey:[g.ACTIONS.GET_ASSETS,i,o,s],queryFn:async()=>{const l=await x(r,{action:g.ACTIONS.GET_ASSETS,data:{search:i,page:o,limit:s}});return l.page=o,l.limit=s,l},staleTime:1/0,retry:1})},Ne=n=>{const r=g.useAssetsApiUrl(),x=g.useFetch();return z.useQuery({queryKey:[g.ACTIONS.GET_ASSET,n],queryFn:async()=>n?await x(r,{action:g.ACTIONS.GET_ASSET,data:{id:n}}):null,staleTime:1/0,retry:1})};function be(n){const r=isNaN(n)?0:typeof n=="number"?n:parseInt(n);return r?r<1024?`${r.toFixed(2)} B`:r<1024*1024?`${(r/1024).toFixed(2)} KB`:`${(r/(1024*1024)).toFixed(2)} MB`:"0 B"}function Z(n){if(!n)return"N/A";const r=new Date(n);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}function J(n,r){let x=n,i=r==null?void 0:r.description;return(!i||typeof i!="string")&&(i=""),(!x||typeof x!="string")&&(x=""),x!==i}const we=({assetId:n,onBack:r,onEdit:x,onSave:i,isSaving:o})=>{var c,m;const{t:s}=M.useTranslation(),{data:l,isLoading:E,isError:N}=Ne(n||""),[v,j]=u.useState(""),[b,C]=u.useState(!1);u.useEffect(()=>{const d=new Image;return d.src=(l==null?void 0:l.url)||"",d.onload=()=>C(!0),()=>{d.onload=null}},[l]);const A=async(d,p)=>{try{await navigator.clipboard.writeText(d),w.toast.success(s("{{type}} copied to clipboard",{type:p}))}catch(y){w.toast.error(s("Failed to copy {{type}}",{type:p}),{description:y==null?void 0:y.message})}};return u.useEffect(()=>{l!=null&&l.description&&j(l.description)},[l]),E||!b?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}):N||!(l!=null&&l.id)?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto p-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(f.AlertCircle,{className:"h-12 w-12 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:s("No Asset Found")}),e.jsx("p",{className:"text-sm text-gray-500 mb-6",children:s(N?"There was an error loading the asset. Please try again later.":"The asset you're looking for doesn't exist or has been removed.")}),e.jsxs("div",{className:"flex justify-center gap-4",children:[e.jsx(a.Button,{variant:"outline",onClick:r,children:s("Back to Assets")}),N&&e.jsx(a.Button,{variant:"default",onClick:()=>window.location.reload(),children:s("Try Again")})]})]})}):e.jsxs("div",{className:"flex-1 flex flex-col gap-y-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:r,disabled:o,children:[e.jsx(f.ChevronLeft,{className:"h-4 w-4"}),s("Back to Assets")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a.Button,{variant:"outline",onClick:r,disabled:o,children:s("Cancel")}),e.jsxs(a.Button,{variant:"outline",onClick:()=>A(l.url,s("Asset URL")),disabled:o,children:[e.jsx(f.Copy,{className:"h-4 w-4 mr-2"}),s("Copy URL")]}),e.jsxs(a.Button,{variant:"default",onClick:()=>x(l),disabled:o,children:[e.jsx(f.Pencil,{className:"h-4 w-4"}),s("Edit Image")]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 items-start gap-6 flex-1 overflow-hidden",children:[e.jsx("div",{className:"relative h-[calc(80vh-200px)] w-full flex items-start justify-center",children:e.jsx("img",{src:l.url,alt:l.name,className:"w-full h-full object-contain rounded-lg max-h-max max-w-max"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100",children:[e.jsx(a.Label,{className:"w-full text-center",children:s("Details")}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2 bg-white",children:[{label:s("File Name"),value:l.name},{label:s("Type"),value:l.type,capitalize:!0},{label:s("Format"),value:((c=l.metadata)==null?void 0:c.format)||l.type,capitalize:!0},{label:s("Size"),value:be(l.size)},{label:s("Dimensions"),value:`${l.width||0} × ${l.height||0}`},{label:s("Created"),value:Z(l.createdAt)},{label:s("Updated"),value:Z(((m=l.metadata)==null?void 0:m.updatedAt)||(l==null?void 0:l.updatedAt)||l.createdAt)},{label:s("URL"),value:l.url,copyable:!0}].map(d=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:d.label}),":",e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900"+(d.capitalize?" capitalize":""),children:d.value}),d.copyable&&e.jsx(a.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>A(d.value,d.label),children:e.jsx(f.Link,{className:"h-3 w-3"})})]})]},d.label))})]}),l.usedOn&&l.usedOn.length>0&&e.jsxs("div",{className:"grid gap-3",children:[e.jsx(a.Label,{children:s("Used On")}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:l.usedOn.map((d,p)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900",children:d.name}),e.jsxs("div",{className:"text-gray-500",children:["(",d.slug,")"]})]},p))})]}),e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100 relative",children:[e.jsx(a.Label,{className:"w-full text-center",children:s("Description")}),e.jsx(a.Textarea,{id:"description",value:v,placeholder:s("Enter a description for the asset"),onChange:d=>j(d.target.value),rows:3,disabled:o,className:"hover:border-black/40 bg-white"}),e.jsx("div",{className:"flex justify-end items-start absolute top-1.5 right-2",children:e.jsx("button",{type:"button",onClick:()=>i(v),disabled:o||!J(v,l),className:`py-0 bg-blue-500 text-white px-3 py-0.5 rounded-md text-sm ${o||!J(v,l)?"opacity-50 cursor-not-allowed":""}`,children:o?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 mr-2 animate-spin"}),s("Saving...")]}):s("Save")})})]})]})]})]})},Ce=u.lazy(()=>Promise.resolve().then(()=>require("./image-editor-CnDnY97s.cjs"))),Ae=25*1024*1024,Se=({isUpdatingAsset:n,allowedTypes:r,uploadAssets:x,isUploadingAsset:i,onUploaded:o})=>{const{t:s}=M.useTranslation(),[l,E]=u.useState(()=>{const c=localStorage.getItem("chai_optimize_images");return c!==null?c==="true":!0});u.useEffect(()=>{localStorage.setItem("chai_optimize_images",l.toString())},[l]);const N=n||i,v=u.useCallback(async c=>{try{const m=c;if(!m.every(S=>S.type.startsWith("image/")))return w.toast.error(s("Invalid file type. Please upload a valid file.")),Promise.reject(new Error("Invalid file type"));const d=m.map(async S=>{let U=S;return S.type.startsWith("image/")&&(U=await Y.compressImageIfNeeded(S)),new Promise((_,B)=>{const L=new FileReader;L.readAsDataURL(U),L.onload=async()=>{_({file:L.result,folderId:void 0,name:S.name,optimize:l})},L.onerror=()=>B(null)})}),p=await Promise.all(d),y=await x(p);return(y==null?void 0:y.length)===1&&o(y[0]),y}catch(m){return Promise.reject(m)}},[x,l,o,s]),j=c=>{const m=[];let d=0;return c.forEach(p=>{p.size>Ae?d++:m.push(p)}),d>0&&w.toast.error(`${d===1&&c.length===1?s("File"):d+s(d===1?" file":" files")} ${s("exceed the maximum size limit of 10MB.")}`),F.isEmpty(m)?[]:v(m)},{getRootProps:b,getInputProps:C,isDragActive:A}=fe.useDropzone({onDrop:j,accept:{"image/*":r.includes("image")?[]:[]},disabled:n||i,multiple:!0});return e.jsx("div",{className:`flex h-[60px] w-full flex-col items-center justify-center rounded-lg border-2 border-dashed border-slate-300 p-0 py-2 hover:border-black/50 ${N?"pointer-events-none bg-gray-100 opacity-90":"bg-gray-100 hover:border-black/50 hover:bg-gray-100"}`,children:e.jsxs("div",{...b(),className:M.mergeClasses("flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",N?"items-start":"items-center",A?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...C()}),N?e.jsx("div",{className:"flex flex-col items-center px-6",children:e.jsxs("div",{className:"flex items-center justify-center gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full bg-indigo-100 p-2",children:e.jsx(f.Loader,{className:"h-4 w-4 animate-spin text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:s(n?"Updating file...":"Uploading file...")}),e.jsxs("div",{className:"text-xs font-light text-muted-foreground",children:[s("Please wait while we")," ",s(n?"update":"upload")," ",s("your file...")]})]})]})}):e.jsxs("div",{className:"flex w-full items-center justify-between px-6",children:[e.jsx("div",{className:"flex flex-col items-center",children:e.jsxs("div",{className:"flex items-center justify-between gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full border border-indigo-500 bg-indigo-100 p-2",children:e.jsx(f.Upload,{className:"h-4 w-4 text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsxs("div",{className:"font-medium",children:[s("Drop your file here or")," ",e.jsx("span",{className:"cursor-pointer text-indigo-500 hover:underline",children:s("browse")})]}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:e.jsxs("span",{className:"",children:[s("Accepted file types:")," ",e.jsx("span",{className:"capitalize text-indigo-400",children:r.join(", ")})]})})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs",children:[s("Optimization:")," "," ",e.jsx("span",{className:l?"text-indigo-600":"text-gray-400",children:s(l?"On":"Off")})]}),e.jsx(a.Switch,{checked:l,onCheckedChange:c=>{E(c)},onClick:c=>{c.stopPropagation()},className:"data-[state=checked]:bg-indigo-500"})]}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:`flex cursor-help items-center text-amber-500 ${l?"invisible":""}`,children:e.jsx(f.AlertTriangle,{className:"mr-1 h-4 w-4"})})}),e.jsx(a.TooltipContent,{side:"top",children:e.jsx("p",{className:"text-xs text-white",children:s("Warning: Unoptimized images may affect performance and page load times")})})]})})]})]})]})})};function Te({close:n,onSelect:r,mode:x="image",assetId:i}){const{t:o}=M.useTranslation(),s=!1,l=10,E=u.useMemo(()=>[x],[x]),[N,v]=u.useState(null),[j,b]=u.useState(null),[C,A]=u.useState(null),[c,m]=u.useState({show:!1,file:""}),[d,p]=u.useState(!1),[y,S]=u.useState(i?"details":"grid"),[U,_]=u.useState(""),[B,L]=u.useState(""),[P,Q]=u.useState(1),[R]=u.useState(30),[T,G]=u.useState([]);u.useEffect(()=>{i&&(v(i),S("details"))},[i]),u.useEffect(()=>{const t=setTimeout(()=>{_(B),Q(1)},300);return()=>clearTimeout(t)},[B]);const{data:q,isLoading:$,refetch:ee}=ye({search:U.toLowerCase().trim(),page:P,limit:R}),D=(q==null?void 0:q.assets)||[],te=(q==null?void 0:q.total)||0,I=Math.ceil(te/R);u.useEffect(()=>{$||I<=0||Q(t=>t>I?I:t<1?1:t)},[$,I]);const se=(D==null?void 0:D.length)>0,{mutate:ie}=ge(),{mutateAsync:K,isPending:le}=pe(),{mutateAsync:W,isPending:ae}=je(),V=u.useCallback(t=>{const h=Math.min(Math.max(1,t),Math.max(1,I));h!==P&&Q(h)},[I,P]),re=t=>{L(t.target.value)},ne=u.useCallback(t=>{G(h=>F.find(h,{id:t.id})?[]:[t])},[s]),oe=u.useCallback(()=>{G([])},[]),H=t=>{(t==null?void 0:t.length)!==0&&(r(F.pick(F.first(t||T),["id","url","width","height","description"])),n())},ce=async t=>{b(t)},de=async()=>{j&&(A(j==null?void 0:j.id),await ie(j.id,{onSuccess:()=>{A(null),b(null)},onError:()=>{A(null)}}),b(null))},ue=t=>{v(t.id),S("details")},me=async(t,h)=>{try{const O=localStorage.getItem("chai_optimize_images")!=="false";if(h){const k=await K([{file:t,folderId:void 0,name:c.name||"",optimize:O}]);if((k==null?void 0:k.length)>0){const X=k[0];r({...F.pick(X,["id","width","height","description"]),url:X.url})}}else{const k=await W({id:c.id||"",file:t});k&&r({...F.pick(k,["id","width","height","description"]),url:k.url})}m({show:!1,file:""}),n()}catch(O){console.error(o("Error saving edited image:"),O)}},he=u.useCallback(t=>{G([t])},[]),xe=u.useCallback(t=>{V(t)},[V]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4",children:[e.jsx("h1",{className:"text-lg font-medium",children:o("Digital Asset Manager")}),y==="grid"?e.jsxs(e.Fragment,{children:[e.jsx(Se,{maxFileSize:l,allowedTypes:E,uploadAssets:K,isUpdatingAsset:ae,isUploadingAsset:le,onUploaded:he}),e.jsxs("div",{className:"relative flex flex-1 flex-col gap-y-3 overflow-hidden rounded-lg border p-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"relative w-1/2",children:[e.jsx(f.Search,{strokeWidth:3,className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground ${B.length>0?"text-indigo-800":""}`}),e.jsx(a.Input,{placeholder:o("Search assets..."),onChange:re,value:B,className:"pl-8"})]}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[T.length>0?e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[T.length>0&&e.jsx(e.Fragment,{children:e.jsx(a.Button,{variant:"outline",size:"sm",onClick:()=>oe(),title:o("Clear selection"),children:o("Clear")})}),e.jsx(a.Button,{size:"sm",onClick:()=>H(T),disabled:T.length===0,children:o("Select Asset")})]})}):null,e.jsx(a.Button,{variant:"ghost",size:"icon",onClick:()=>ee(),children:e.jsx(f.RefreshCwIcon,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pb-[66px]",children:$?e.jsxs("div",{className:"columns-1 gap-3 space-y-3 sm:columns-3 md:columns-5",children:[e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"})]}):!$&&!se?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center rounded-lg border",children:[e.jsx("div",{className:"text-muted-foreground",children:e.jsx(f.Archive,{className:"h-9 w-9 text-indigo-500"})}),e.jsx("div",{className:"text-lg text-muted-foreground",children:o("No assets found")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:U.length>0?o("No assets found for your search: {{query}}",{query:U}):o("Start uploading assets to get started")}),e.jsx("br",{})]}):e.jsx("div",{className:"flex flex-wrap gap-3 p-1",children:D==null?void 0:D.map(t=>e.jsxs("div",{className:M.mergeClasses("group relative flex max-h-[180px] max-w-[180px] cursor-pointer flex-col justify-between overflow-hidden rounded-lg border-2 transition-all",T.some(h=>h.id===t.id)?"border-blue-500":"hover:border-black/90",C&&(j==null?void 0:j.id)===t.id?"pointer-events-none opacity-50":"",C===t.id?"pointer-events-none opacity-50":""),onClick:()=>ne(t),onDoubleClick:()=>H([t]),children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden",children:[C===t.id?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin text-white"})}):null,t.type==="image"?e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:`h-full min-h-[80px] w-full object-contain ${T.some(h=>h.id===t.id)?"":"group-hover:blur group-hover:contrast-50"}`}):e.jsxs("div",{className:"flex h-full items-center justify-center",children:[e.jsx(f.Film,{className:"h-12 w-12 text-muted-foreground"}),t.thumbnailUrl&&e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:"absolute inset-0 h-full w-full object-cover"})]})]}),e.jsxs("div",{className:"flex items-end justify-between border-t-[1px] border-black/10 bg-white px-2 py-1",children:[e.jsx("div",{className:"truncate text-xs leading-tight",title:t.name,children:t.name}),e.jsx("div",{className:"flex items-center justify-between whitespace-nowrap text-[9px] font-light text-muted-foreground",children:e.jsx("span",{children:Y.formatFileSize((t==null?void 0:t.size)||0)})})]}),!T.some(h=>h.id===t.id)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100",children:e.jsxs("div",{className:"grid grid-cols-4 gap-2 p-2",children:[e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),ue(t)},children:e.jsx(f.ImageIcon,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("View Details")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),navigator.clipboard.writeText(t.url),w.toast.success(o("Asset URL copied to clipboard"))},children:e.jsx(f.Copy,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Copy URL")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),m({id:t.id,show:!0,file:t.url,name:t.name})},children:e.jsx(f.Edit,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Edit Image")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"destructive",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),ce(t)},children:e.jsx(f.Trash2,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Delete Asset")})})]})})]})}),T.some(h=>h.id===t.id)&&e.jsx("div",{className:"absolute right-1 top-1 h-max rounded-full border border-white bg-blue-500 p-1",children:e.jsx(f.Check,{className:"h-3 w-3 text-white",strokeWidth:5})})]},t.id))})}),I>1&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 border-t bg-white p-4",children:e.jsx(g.ErrorBoundary,{fallback:e.jsx("div",{className:"text-red-500",children:o("Error loading pagination")}),children:e.jsx(ve,{currentPage:P,totalPages:I,onPageChange:xe,pageRangeDisplayed:3,showPageInput:!0})})})]})]}):e.jsx(we,{assetId:N||i||"",onBack:()=>{S("grid"),v(null)},onEdit:t=>{m({id:t.id,show:!0,file:t.url,name:t.name})},onSave:async t=>{if(N){p(!0);try{const h=D.find(O=>O.id===N);h&&await W(F.merge(h,{description:t}))}finally{p(!1)}}},isSaving:d})]}),c.show&&e.jsx(u.Suspense,{fallback:e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}),children:e.jsx(Ce,{imageUrl:c.file,onSave:me,onClose:()=>m({show:!1,file:""}),defaultSavedImageName:c.name,isEditing:!!c.id})}),j&&e.jsx(a.Dialog,{open:!!j,onOpenChange:()=>b(null),children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:o("Delete Asset")}),e.jsx(a.DialogDescription,{children:o('Are you sure you want to delete "{{name}}"? This action cannot be undone.',{name:j.name})})]}),e.jsxs(a.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(a.Button,{variant:"outline",onClick:()=>b(null),children:o("Cancel")}),e.jsx(a.Button,{variant:"destructive",onClick:de,children:o("Delete")})]})]})})]})}exports.default=Te;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),F=require("lodash-es"),f=require("lucide-react"),u=require("react"),fe=require("react-dropzone"),g=require("./index-Bre43r-W.cjs"),w=require("sonner"),Y=require("./image-compression-DZ9WMmyn.cjs"),z=require("@tanstack/react-query"),pe=()=>{const n=g.useAssetsApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>{const o=i.map(async l=>x(n,{action:g.ACTIONS.UPLOAD_ASSET,data:l}));return await Promise.all(o)},onSuccess:i=>{var o;if(i!=null&&i.some(s=>s.error))throw new Error(((o=i==null?void 0:i.find(s=>s.error))==null?void 0:o.error)||"Failed to upload asset");{r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]});const s=i==null?void 0:i.length;w.toast.success(`${s===1?"Asset":s+" Assets"} uploaded successfully`)}},onError:()=>{w.toast.error("Failed to upload asset")}})},ge=()=>{const n=g.useAssetsApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>x(n,{action:g.ACTIONS.DELETE_ASSET,data:{id:i}}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]}),w.toast.success("Asset deleted successfully")},onError:()=>{w.toast.error("Failed to delete asset")}})},je=()=>{const n=g.useAssetsApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>x(n,{action:g.ACTIONS.UPDATE_ASSET,data:i}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]}),i!=null&&i.id&&r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSET,i.id]}),w.toast.success("Asset updated successfully")},onError:()=>{w.toast.error("Failed to update asset")}})};function ve({currentPage:n,totalPages:r,onPageChange:x,pageRangeDisplayed:i=3,showPageInput:o=!0,className:s=""}){const[l,E]=u.useState(String(n)),N=u.useMemo(()=>{const c=Math.floor(i/2);let m=Math.max(1,n-c),d=Math.min(r,n+c);d-m+1<i&&(m===1?d=Math.min(r,m+i-1):d===r&&(m=Math.max(1,d-i+1)));const p=[];m>1&&(p.push(1),m>2&&p.push("..."));for(let y=m;y<=d;y++)p.push(y);return d<r&&(d<r-1&&p.push("..."),p.push(r)),p},[n,r,i]),v=c=>{c!==n&&c>=1&&c<=r&&(x(c),E(String(c)))},j=()=>{n>1&&v(n-1)},b=()=>{n<r&&v(n+1)},C=()=>{const c=Number(l);!isNaN(c)&&c>=1&&c<=r&&v(c)},A=c=>{c.key==="Enter"&&C()};return r<=1?null:e.jsxs("div",{className:`flex flex-wrap items-center justify-center gap-3 ${s}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:j,disabled:n===1,className:"px-2 py-1 text-sm hover:bg-gray-50",children:[e.jsx(f.ChevronLeft,{className:" h-4 w-4"}),"Previous"]}),e.jsx("div",{className:"flex items-center gap-2",children:N.map((c,m)=>{if(c==="...")return e.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${m}`);const d=c,p=d===n;return e.jsx(a.Button,{variant:p?"default":"outline",size:"sm",onClick:()=>v(d),className:p?"border-blue-600 bg-blue-600 px-3 py-1 text-sm text-white":"border px-3 py-1 text-sm hover:bg-gray-50 hover:text-black",children:d},d)})}),e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:b,disabled:n===r,className:"px-2 py-1 text-sm hover:bg-gray-50",children:["Next",e.jsx(f.ChevronRight,{className:" h-4 w-4"})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Go to"}),e.jsx(a.Input,{type:"number",min:1,max:r,value:l,onChange:c=>{const m=c.target.value.replace(/[^\d]/g,"");E(m)},onKeyDown:A,className:"h-8 w-16 px-2 py-1"}),e.jsx(a.Button,{variant:"outline",size:"sm",onClick:C,disabled:l===""||Number(l)<1||Number(l)>r,children:"Go"})]})]})}const ye=(n={})=>{const r=g.useAssetsApiUrl(),x=g.useFetch(),{search:i,page:o=1,limit:s=30}=n;return z.useQuery({queryKey:[g.ACTIONS.GET_ASSETS,i,o,s],queryFn:async()=>{const l=await x(r,{action:g.ACTIONS.GET_ASSETS,data:{search:i,page:o,limit:s}});return l.page=o,l.limit=s,l},staleTime:1/0,retry:1})},Ne=n=>{const r=g.useAssetsApiUrl(),x=g.useFetch();return z.useQuery({queryKey:[g.ACTIONS.GET_ASSET,n],queryFn:async()=>n?await x(r,{action:g.ACTIONS.GET_ASSET,data:{id:n}}):null,staleTime:1/0,retry:1})};function be(n){const r=isNaN(n)?0:typeof n=="number"?n:parseInt(n);return r?r<1024?`${r.toFixed(2)} B`:r<1024*1024?`${(r/1024).toFixed(2)} KB`:`${(r/(1024*1024)).toFixed(2)} MB`:"0 B"}function Z(n){if(!n)return"N/A";const r=new Date(n);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}function J(n,r){let x=n,i=r==null?void 0:r.description;return(!i||typeof i!="string")&&(i=""),(!x||typeof x!="string")&&(x=""),x!==i}const we=({assetId:n,onBack:r,onEdit:x,onSave:i,isSaving:o})=>{var c,m;const{t:s}=M.useTranslation(),{data:l,isLoading:E,isError:N}=Ne(n||""),[v,j]=u.useState(""),[b,C]=u.useState(!1);u.useEffect(()=>{const d=new Image;return d.src=(l==null?void 0:l.url)||"",d.onload=()=>C(!0),()=>{d.onload=null}},[l]);const A=async(d,p)=>{try{await navigator.clipboard.writeText(d),w.toast.success(s("{{type}} copied to clipboard",{type:p}))}catch(y){w.toast.error(s("Failed to copy {{type}}",{type:p}),{description:y==null?void 0:y.message})}};return u.useEffect(()=>{l!=null&&l.description&&j(l.description)},[l]),E||!b?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}):N||!(l!=null&&l.id)?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto p-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(f.AlertCircle,{className:"h-12 w-12 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:s("No Asset Found")}),e.jsx("p",{className:"text-sm text-gray-500 mb-6",children:s(N?"There was an error loading the asset. Please try again later.":"The asset you're looking for doesn't exist or has been removed.")}),e.jsxs("div",{className:"flex justify-center gap-4",children:[e.jsx(a.Button,{variant:"outline",onClick:r,children:s("Back to Assets")}),N&&e.jsx(a.Button,{variant:"default",onClick:()=>window.location.reload(),children:s("Try Again")})]})]})}):e.jsxs("div",{className:"flex-1 flex flex-col gap-y-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:r,disabled:o,children:[e.jsx(f.ChevronLeft,{className:"h-4 w-4"}),s("Back to Assets")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a.Button,{variant:"outline",onClick:r,disabled:o,children:s("Cancel")}),e.jsxs(a.Button,{variant:"outline",onClick:()=>A(l.url,s("Asset URL")),disabled:o,children:[e.jsx(f.Copy,{className:"h-4 w-4 mr-2"}),s("Copy URL")]}),e.jsxs(a.Button,{variant:"default",onClick:()=>x(l),disabled:o,children:[e.jsx(f.Pencil,{className:"h-4 w-4"}),s("Edit Image")]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 items-start gap-6 flex-1 overflow-hidden",children:[e.jsx("div",{className:"relative h-[calc(80vh-200px)] w-full flex items-start justify-center",children:e.jsx("img",{src:l.url,alt:l.name,className:"w-full h-full object-contain rounded-lg max-h-max max-w-max"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100",children:[e.jsx(a.Label,{className:"w-full text-center",children:s("Details")}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2 bg-white",children:[{label:s("File Name"),value:l.name},{label:s("Type"),value:l.type,capitalize:!0},{label:s("Format"),value:((c=l.metadata)==null?void 0:c.format)||l.type,capitalize:!0},{label:s("Size"),value:be(l.size)},{label:s("Dimensions"),value:`${l.width||0} × ${l.height||0}`},{label:s("Created"),value:Z(l.createdAt)},{label:s("Updated"),value:Z(((m=l.metadata)==null?void 0:m.updatedAt)||(l==null?void 0:l.updatedAt)||l.createdAt)},{label:s("URL"),value:l.url,copyable:!0}].map(d=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:d.label}),":",e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900"+(d.capitalize?" capitalize":""),children:d.value}),d.copyable&&e.jsx(a.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>A(d.value,d.label),children:e.jsx(f.Link,{className:"h-3 w-3"})})]})]},d.label))})]}),l.usedOn&&l.usedOn.length>0&&e.jsxs("div",{className:"grid gap-3",children:[e.jsx(a.Label,{children:s("Used On")}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:l.usedOn.map((d,p)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900",children:d.name}),e.jsxs("div",{className:"text-gray-500",children:["(",d.slug,")"]})]},p))})]}),e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100 relative",children:[e.jsx(a.Label,{className:"w-full text-center",children:s("Description")}),e.jsx(a.Textarea,{id:"description",value:v,placeholder:s("Enter a description for the asset"),onChange:d=>j(d.target.value),rows:3,disabled:o,className:"hover:border-black/40 bg-white"}),e.jsx("div",{className:"flex justify-end items-start absolute top-1.5 right-2",children:e.jsx("button",{type:"button",onClick:()=>i(v),disabled:o||!J(v,l),className:`py-0 bg-blue-500 text-white px-3 py-0.5 rounded-md text-sm ${o||!J(v,l)?"opacity-50 cursor-not-allowed":""}`,children:o?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 mr-2 animate-spin"}),s("Saving...")]}):s("Save")})})]})]})]})]})},Ce=u.lazy(()=>Promise.resolve().then(()=>require("./image-editor-CnDnY97s.cjs"))),Ae=25*1024*1024,Se=({isUpdatingAsset:n,allowedTypes:r,uploadAssets:x,isUploadingAsset:i,onUploaded:o})=>{const{t:s}=M.useTranslation(),[l,E]=u.useState(()=>{const c=localStorage.getItem("chai_optimize_images");return c!==null?c==="true":!0});u.useEffect(()=>{localStorage.setItem("chai_optimize_images",l.toString())},[l]);const N=n||i,v=u.useCallback(async c=>{try{const m=c;if(!m.every(S=>S.type.startsWith("image/")))return w.toast.error(s("Invalid file type. Please upload a valid file.")),Promise.reject(new Error("Invalid file type"));const d=m.map(async S=>{let U=S;return S.type.startsWith("image/")&&(U=await Y.compressImageIfNeeded(S)),new Promise((_,B)=>{const L=new FileReader;L.readAsDataURL(U),L.onload=async()=>{_({file:L.result,folderId:void 0,name:S.name,optimize:l})},L.onerror=()=>B(null)})}),p=await Promise.all(d),y=await x(p);return(y==null?void 0:y.length)===1&&o(y[0]),y}catch(m){return Promise.reject(m)}},[x,l,o,s]),j=c=>{const m=[];let d=0;return c.forEach(p=>{p.size>Ae?d++:m.push(p)}),d>0&&w.toast.error(`${d===1&&c.length===1?s("File"):d+s(d===1?" file":" files")} ${s("exceed the maximum size limit of 10MB.")}`),F.isEmpty(m)?[]:v(m)},{getRootProps:b,getInputProps:C,isDragActive:A}=fe.useDropzone({onDrop:j,accept:{"image/*":r.includes("image")?[]:[]},disabled:n||i,multiple:!0});return e.jsx("div",{className:`flex h-[60px] w-full flex-col items-center justify-center rounded-lg border-2 border-dashed border-slate-300 p-0 py-2 hover:border-black/50 ${N?"pointer-events-none bg-gray-100 opacity-90":"bg-gray-100 hover:border-black/50 hover:bg-gray-100"}`,children:e.jsxs("div",{...b(),className:M.mergeClasses("flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",N?"items-start":"items-center",A?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...C()}),N?e.jsx("div",{className:"flex flex-col items-center px-6",children:e.jsxs("div",{className:"flex items-center justify-center gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full bg-indigo-100 p-2",children:e.jsx(f.Loader,{className:"h-4 w-4 animate-spin text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:s(n?"Updating file...":"Uploading file...")}),e.jsxs("div",{className:"text-xs font-light text-muted-foreground",children:[s("Please wait while we")," ",s(n?"update":"upload")," ",s("your file...")]})]})]})}):e.jsxs("div",{className:"flex w-full items-center justify-between px-6",children:[e.jsx("div",{className:"flex flex-col items-center",children:e.jsxs("div",{className:"flex items-center justify-between gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full border border-indigo-500 bg-indigo-100 p-2",children:e.jsx(f.Upload,{className:"h-4 w-4 text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsxs("div",{className:"font-medium",children:[s("Drop your file here or")," ",e.jsx("span",{className:"cursor-pointer text-indigo-500 hover:underline",children:s("browse")})]}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:e.jsxs("span",{className:"",children:[s("Accepted file types:")," ",e.jsx("span",{className:"capitalize text-indigo-400",children:r.join(", ")})]})})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs",children:[s("Optimization:")," "," ",e.jsx("span",{className:l?"text-indigo-600":"text-gray-400",children:s(l?"On":"Off")})]}),e.jsx(a.Switch,{checked:l,onCheckedChange:c=>{E(c)},onClick:c=>{c.stopPropagation()},className:"data-[state=checked]:bg-indigo-500"})]}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:`flex cursor-help items-center text-amber-500 ${l?"invisible":""}`,children:e.jsx(f.AlertTriangle,{className:"mr-1 h-4 w-4"})})}),e.jsx(a.TooltipContent,{side:"top",children:e.jsx("p",{className:"text-xs text-white",children:s("Warning: Unoptimized images may affect performance and page load times")})})]})})]})]})]})})};function Te({close:n,onSelect:r,mode:x="image",assetId:i}){const{t:o}=M.useTranslation(),s=!1,l=10,E=u.useMemo(()=>[x],[x]),[N,v]=u.useState(null),[j,b]=u.useState(null),[C,A]=u.useState(null),[c,m]=u.useState({show:!1,file:""}),[d,p]=u.useState(!1),[y,S]=u.useState(i?"details":"grid"),[U,_]=u.useState(""),[B,L]=u.useState(""),[P,Q]=u.useState(1),[R]=u.useState(30),[T,G]=u.useState([]);u.useEffect(()=>{i&&(v(i),S("details"))},[i]),u.useEffect(()=>{const t=setTimeout(()=>{_(B),Q(1)},300);return()=>clearTimeout(t)},[B]);const{data:q,isLoading:$,refetch:ee}=ye({search:U.toLowerCase().trim(),page:P,limit:R}),D=(q==null?void 0:q.assets)||[],te=(q==null?void 0:q.total)||0,I=Math.ceil(te/R);u.useEffect(()=>{$||I<=0||Q(t=>t>I?I:t<1?1:t)},[$,I]);const se=(D==null?void 0:D.length)>0,{mutate:ie}=ge(),{mutateAsync:K,isPending:le}=pe(),{mutateAsync:W,isPending:ae}=je(),V=u.useCallback(t=>{const h=Math.min(Math.max(1,t),Math.max(1,I));h!==P&&Q(h)},[I,P]),re=t=>{L(t.target.value)},ne=u.useCallback(t=>{G(h=>F.find(h,{id:t.id})?[]:[t])},[s]),oe=u.useCallback(()=>{G([])},[]),H=t=>{(t==null?void 0:t.length)!==0&&(r(F.pick(F.first(t||T),["id","url","width","height","description"])),n())},ce=async t=>{b(t)},de=async()=>{j&&(A(j==null?void 0:j.id),await ie(j.id,{onSuccess:()=>{A(null),b(null)},onError:()=>{A(null)}}),b(null))},ue=t=>{v(t.id),S("details")},me=async(t,h)=>{try{const O=localStorage.getItem("chai_optimize_images")!=="false";if(h){const k=await K([{file:t,folderId:void 0,name:c.name||"",optimize:O}]);if((k==null?void 0:k.length)>0){const X=k[0];r({...F.pick(X,["id","width","height","description"]),url:X.url})}}else{const k=await W({id:c.id||"",file:t});k&&r({...F.pick(k,["id","width","height","description"]),url:k.url})}m({show:!1,file:""}),n()}catch(O){console.error(o("Error saving edited image:"),O)}},he=u.useCallback(t=>{G([t])},[]),xe=u.useCallback(t=>{V(t)},[V]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4",children:[e.jsx("h1",{className:"text-lg font-medium",children:o("Digital Asset Manager")}),y==="grid"?e.jsxs(e.Fragment,{children:[e.jsx(Se,{maxFileSize:l,allowedTypes:E,uploadAssets:K,isUpdatingAsset:ae,isUploadingAsset:le,onUploaded:he}),e.jsxs("div",{className:"relative flex flex-1 flex-col gap-y-3 overflow-hidden rounded-lg border p-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"relative w-1/2",children:[e.jsx(f.Search,{strokeWidth:3,className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground ${B.length>0?"text-indigo-800":""}`}),e.jsx(a.Input,{placeholder:o("Search assets..."),onChange:re,value:B,className:"pl-8"})]}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[T.length>0?e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[T.length>0&&e.jsx(e.Fragment,{children:e.jsx(a.Button,{variant:"outline",size:"sm",onClick:()=>oe(),title:o("Clear selection"),children:o("Clear")})}),e.jsx(a.Button,{size:"sm",onClick:()=>H(T),disabled:T.length===0,children:o("Select Asset")})]})}):null,e.jsx(a.Button,{variant:"ghost",size:"icon",onClick:()=>ee(),children:e.jsx(f.RefreshCwIcon,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pb-[66px]",children:$?e.jsxs("div",{className:"columns-1 gap-3 space-y-3 sm:columns-3 md:columns-5",children:[e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"})]}):!$&&!se?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center rounded-lg border",children:[e.jsx("div",{className:"text-muted-foreground",children:e.jsx(f.Archive,{className:"h-9 w-9 text-indigo-500"})}),e.jsx("div",{className:"text-lg text-muted-foreground",children:o("No assets found")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:U.length>0?o("No assets found for your search: {{query}}",{query:U}):o("Start uploading assets to get started")}),e.jsx("br",{})]}):e.jsx("div",{className:"flex flex-wrap gap-3 p-1",children:D==null?void 0:D.map(t=>e.jsxs("div",{className:M.mergeClasses("group relative flex max-h-[180px] max-w-[180px] cursor-pointer flex-col justify-between overflow-hidden rounded-lg border-2 transition-all",T.some(h=>h.id===t.id)?"border-blue-500":"hover:border-black/90",C&&(j==null?void 0:j.id)===t.id?"pointer-events-none opacity-50":"",C===t.id?"pointer-events-none opacity-50":""),onClick:()=>ne(t),onDoubleClick:()=>H([t]),children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden",children:[C===t.id?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin text-white"})}):null,t.type==="image"?e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:`h-full min-h-[80px] w-full object-contain ${T.some(h=>h.id===t.id)?"":"group-hover:blur group-hover:contrast-50"}`}):e.jsxs("div",{className:"flex h-full items-center justify-center",children:[e.jsx(f.Film,{className:"h-12 w-12 text-muted-foreground"}),t.thumbnailUrl&&e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:"absolute inset-0 h-full w-full object-cover"})]})]}),e.jsxs("div",{className:"flex items-end justify-between border-t-[1px] border-black/10 bg-white px-2 py-1",children:[e.jsx("div",{className:"truncate text-xs leading-tight",title:t.name,children:t.name}),e.jsx("div",{className:"flex items-center justify-between whitespace-nowrap text-[9px] font-light text-muted-foreground",children:e.jsx("span",{children:Y.formatFileSize((t==null?void 0:t.size)||0)})})]}),!T.some(h=>h.id===t.id)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100",children:e.jsxs("div",{className:"grid grid-cols-4 gap-2 p-2",children:[e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),ue(t)},children:e.jsx(f.ImageIcon,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("View Details")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),navigator.clipboard.writeText(t.url),w.toast.success(o("Asset URL copied to clipboard"))},children:e.jsx(f.Copy,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Copy URL")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),m({id:t.id,show:!0,file:t.url,name:t.name})},children:e.jsx(f.Edit,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Edit Image")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"destructive",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),ce(t)},children:e.jsx(f.Trash2,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Delete Asset")})})]})})]})}),T.some(h=>h.id===t.id)&&e.jsx("div",{className:"absolute right-1 top-1 h-max rounded-full border border-white bg-blue-500 p-1",children:e.jsx(f.Check,{className:"h-3 w-3 text-white",strokeWidth:5})})]},t.id))})}),I>1&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 border-t bg-white p-4",children:e.jsx(g.ErrorBoundary,{fallback:e.jsx("div",{className:"text-red-500",children:o("Error loading pagination")}),children:e.jsx(ve,{currentPage:P,totalPages:I,onPageChange:xe,pageRangeDisplayed:3,showPageInput:!0})})})]})]}):e.jsx(we,{assetId:N||i||"",onBack:()=>{S("grid"),v(null)},onEdit:t=>{m({id:t.id,show:!0,file:t.url,name:t.name})},onSave:async t=>{if(N){p(!0);try{const h=D.find(O=>O.id===N);h&&await W(F.merge(h,{description:t}))}finally{p(!1)}}},isSaving:d})]}),c.show&&e.jsx(u.Suspense,{fallback:e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}),children:e.jsx(Ce,{imageUrl:c.file,onSave:me,onClose:()=>m({show:!1,file:""}),defaultSavedImageName:c.name,isEditing:!!c.id})}),j&&e.jsx(a.Dialog,{open:!!j,onOpenChange:()=>b(null),children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:o("Delete Asset")}),e.jsx(a.DialogDescription,{children:o('Are you sure you want to delete "{{name}}"? This action cannot be undone.',{name:j.name})})]}),e.jsxs(a.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(a.Button,{variant:"outline",onClick:()=>b(null),children:o("Cancel")}),e.jsx(a.Button,{variant:"destructive",onClick:de,children:o("Delete")})]})]})})]})}exports.default=Te;
@@ -1,5 +1,5 @@
1
1
  import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
- import { aq as C, ar as A, A as T, as as w } from "./index-B_T6ZeA4.js";
2
+ import { aq as C, ar as A, A as T, as as w } from "./index-tgsBai_8.js";
3
3
  import { useQueryClient as q, useMutation as F } from "@tanstack/react-query";
4
4
  import { toast as v } from "sonner";
5
5
  import { useTranslation as _ } from "@chaibuilder/sdk";
@@ -7,7 +7,7 @@ import { Dialog as G, DialogContent as L, DialogHeader as U, DialogTitle as j, D
7
7
  import { isEmpty as M, initial as Q } from "lodash-es";
8
8
  import { AlertCircle as V } from "lucide-react";
9
9
  import { useState as p } from "react";
10
- import { S as k } from "./slug-input-CO6AGAQD.js";
10
+ import { S as k } from "./slug-input-hcJHNszn.js";
11
11
  const H = () => {
12
12
  const s = C(), o = q(), g = A();
13
13
  return F({
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./index--Lu_Q_nO.cjs"),N=require("@tanstack/react-query"),v=require("sonner"),E=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),P=require("lodash-es"),C=require("lucide-react"),g=require("react"),A=require("./slug-input-CrjrFrxP.cjs"),T=()=>{const t=p.useApiUrl(),u=N.useQueryClient(),h=p.useFetch();return N.useMutation({mutationFn:async({pageId:s,name:x,slug:r})=>{const o={pageId:s,name:x};return r&&(o.slug=r),await h(t,{action:"DUPLICATE_PAGE",data:o})},onSuccess:()=>{u.invalidateQueries({queryKey:[p.ACTIONS.GET_WEBSITE_PAGES]}),v.toast.success("Page duplicated successfully")},onError:s=>{v.toast.error("Failed to duplicate page",{description:s.message||"An error occurred while duplicating the page"})}})},w=({page:t,onClose:u,closePanel:h=()=>{}})=>{const{t:s}=E.useTranslation(),{mutate:x,isPending:r}=T(),[o,i]=g.useState(null),[d,D]=g.useState(`${t.name} (Copy)`),b=p.useChangePage(),n=P.isEmpty(t.slug),[m,I]=g.useState(n?"":`${t.slug.split("/").pop()}-copy`),f=n?"":P.initial(t.slug.split("/")).join("/"),[y,j]=g.useState(!1),q=l=>{if(l.preventDefault(),!d.trim()){i(s("Name is required"));return}if(!n&&!m.trim()){i(s("Slug is required"));return}i(null),j(!0);const S={pageId:t.id,name:d};n||(S.slug=`${f}/${m}`),x(S,{onSuccess:c=>{j(!1),u(),b(c.id,h)},onError:c=>{j(!1),c.code==="SLUG_EXISTS"?i(s("A page with this slug already exists. Please choose a different slug.")):c.code==="INVALID_SLUG"?i(s("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens.")):c.code==="PERMISSION_DENIED"?i(s("You don't have permission to duplicate this page.")):i(c.message||s("Failed to duplicate page. Please try again later."))}})};return e.jsx(a.Dialog,{open:!!t,onOpenChange:u,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:s("Duplicate Page")}),e.jsx(a.DialogDescription,{children:s("Create a copy of the page with a new name and slug")})]}),e.jsxs("div",{className:"mb-4 rounded-md bg-gray-50 p-3",children:[e.jsxs("h3",{className:"mb-1 text-sm font-medium",children:[s("Duplicating:"),":"]}),e.jsxs("div",{className:"flex flex-col gap-1 text-sm text-gray-700",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Name"),":"]})," ",t.name]}),!n&&e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Slug"),":"]})," ",t.slug]}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Type"),":"]})," ",t.pageType]})]})]}),e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:s("Name")}),e.jsx(a.Input,{id:"name",value:d,onChange:l=>D(l.target.value),required:!0})]}),!n&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:s("Slug")}),e.jsx(A.SlugInput,{value:m,onChange:l=>I(l),parentSlug:f,onValidationChange:l=>{i(l?null:s("Invalid slug"))}})]}),o&&e.jsxs(a.Alert,{variant:"destructive",className:"py-2",children:[e.jsx(C.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(a.Button,{type:"button",variant:"outline",onClick:u,disabled:r,children:s("Cancel")}),e.jsx(a.Button,{type:"submit",disabled:!d.trim()||!n&&!m.trim()||r||y,children:s(r||y?"Duplicating...":"Duplicate")})]})]})]})})};exports.default=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./index-Bre43r-W.cjs"),N=require("@tanstack/react-query"),v=require("sonner"),E=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),P=require("lodash-es"),C=require("lucide-react"),g=require("react"),A=require("./slug-input-91_G-ww1.cjs"),T=()=>{const t=p.useApiUrl(),u=N.useQueryClient(),h=p.useFetch();return N.useMutation({mutationFn:async({pageId:s,name:x,slug:r})=>{const o={pageId:s,name:x};return r&&(o.slug=r),await h(t,{action:"DUPLICATE_PAGE",data:o})},onSuccess:()=>{u.invalidateQueries({queryKey:[p.ACTIONS.GET_WEBSITE_PAGES]}),v.toast.success("Page duplicated successfully")},onError:s=>{v.toast.error("Failed to duplicate page",{description:s.message||"An error occurred while duplicating the page"})}})},w=({page:t,onClose:u,closePanel:h=()=>{}})=>{const{t:s}=E.useTranslation(),{mutate:x,isPending:r}=T(),[o,i]=g.useState(null),[d,D]=g.useState(`${t.name} (Copy)`),b=p.useChangePage(),n=P.isEmpty(t.slug),[m,I]=g.useState(n?"":`${t.slug.split("/").pop()}-copy`),f=n?"":P.initial(t.slug.split("/")).join("/"),[y,j]=g.useState(!1),q=l=>{if(l.preventDefault(),!d.trim()){i(s("Name is required"));return}if(!n&&!m.trim()){i(s("Slug is required"));return}i(null),j(!0);const S={pageId:t.id,name:d};n||(S.slug=`${f}/${m}`),x(S,{onSuccess:c=>{j(!1),u(),b(c.id,h)},onError:c=>{j(!1),c.code==="SLUG_EXISTS"?i(s("A page with this slug already exists. Please choose a different slug.")):c.code==="INVALID_SLUG"?i(s("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens.")):c.code==="PERMISSION_DENIED"?i(s("You don't have permission to duplicate this page.")):i(c.message||s("Failed to duplicate page. Please try again later."))}})};return e.jsx(a.Dialog,{open:!!t,onOpenChange:u,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:s("Duplicate Page")}),e.jsx(a.DialogDescription,{children:s("Create a copy of the page with a new name and slug")})]}),e.jsxs("div",{className:"mb-4 rounded-md bg-gray-50 p-3",children:[e.jsxs("h3",{className:"mb-1 text-sm font-medium",children:[s("Duplicating:"),":"]}),e.jsxs("div",{className:"flex flex-col gap-1 text-sm text-gray-700",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Name"),":"]})," ",t.name]}),!n&&e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Slug"),":"]})," ",t.slug]}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Type"),":"]})," ",t.pageType]})]})]}),e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:s("Name")}),e.jsx(a.Input,{id:"name",value:d,onChange:l=>D(l.target.value),required:!0})]}),!n&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:s("Slug")}),e.jsx(A.SlugInput,{value:m,onChange:l=>I(l),parentSlug:f,onValidationChange:l=>{i(l?null:s("Invalid slug"))}})]}),o&&e.jsxs(a.Alert,{variant:"destructive",className:"py-2",children:[e.jsx(C.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(a.Button,{type:"button",variant:"outline",onClick:u,disabled:r,children:s("Cancel")}),e.jsx(a.Button,{type:"submit",disabled:!d.trim()||!n&&!m.trim()||r||y,children:s(r||y?"Duplicating...":"Duplicate")})]})]})]})})};exports.default=w;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),h=require("lodash-es"),p=require("lucide-react"),d=require("react"),g=require("./index--Lu_Q_nO.cjs"),f=({isDefaultLang:r,searchQuery:l,setSearchQuery:c})=>e.jsx(a.Input,{type:"text",autoFocus:!0,value:r?l:"",onChange:t=>c(t.target.value),placeholder:r?"Search pages...":"To search select default language",disabled:!r,onKeyDown:t=>t.stopPropagation()}),m=({dynamicPage:r,setDynamicPage:l,searchQuery:c,setSearchQuery:t,dynamicPages:n})=>{const{selectedLang:o,fallbackLang:i}=x.useLanguages(),u=(o==null?void 0:o.length)===0;return e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"ghost",className:"w-max focus:outline-none focus:ring-0 border-[0px] rounded-md py-1 text-sm h-max border border-gray-200 hover:bg-gray-100 pl-4",children:[r?h.get(r,"name"):"Select Page",e.jsx(p.ChevronDown,{className:"ml-2 h-4 w-4"})]})}),e.jsxs(a.DropdownMenuContent,{className:"w-96 divide-y shadow-xl p-0 max-h-[75vh]",children:[e.jsx("div",{className:"p-1.5 bg-gray-50/30",children:e.jsx(f,{isDefaultLang:u,searchQuery:c,setSearchQuery:t})}),(n==null?void 0:n.length)===0?e.jsx("div",{className:"h-24 text-xs flex items-center justify-center",children:"No pages found"}):n==null?void 0:n.map(s=>e.jsx(a.DropdownMenuItem,{onClick:()=>l(s),disabled:u?i!==s.lang:o!==s.lang,className:`flex flex-col justify-start cursor-pointer overflow-x-auto whitespace-nowrap no-scrollbar ${s.id===(r==null?void 0:r.id)?"bg-blue-50":"hover:bg-gray-50"}`,children:e.jsx("div",{className:"w-full text-xs whitespace-nowrap px-2 py-[2px]",children:e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsx("span",{className:"font-mono font-medium text-gray-500 text-xs rounded-full px-2 py-[1px] border border-gray-300 truncate",children:s.slug})]})})},s.id))]})]})},j=()=>{const{dynamicPage:r,dynamicPages:l,allLangPages:c,selectedLang:t,searchQuery:n,updateDynamicPage:o,updateSearchQuery:i,onChangeLanguage:u}=g.useDynamicPageSelector(),s=d.useRef(void 0);return d.useEffect(()=>{s.current!==t&&r&&(u(),s.current=t)},[t,l]),e.jsx("div",{className:"relative",children:e.jsx(m,{dynamicPage:r,setDynamicPage:o,searchQuery:n,setSearchQuery:i,dynamicPages:c})})};exports.default=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),h=require("lodash-es"),p=require("lucide-react"),d=require("react"),g=require("./index-Bre43r-W.cjs"),f=({isDefaultLang:r,searchQuery:l,setSearchQuery:c})=>e.jsx(a.Input,{type:"text",autoFocus:!0,value:r?l:"",onChange:t=>c(t.target.value),placeholder:r?"Search pages...":"To search select default language",disabled:!r,onKeyDown:t=>t.stopPropagation()}),m=({dynamicPage:r,setDynamicPage:l,searchQuery:c,setSearchQuery:t,dynamicPages:n})=>{const{selectedLang:o,fallbackLang:i}=x.useLanguages(),u=(o==null?void 0:o.length)===0;return e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"ghost",className:"w-max focus:outline-none focus:ring-0 border-[0px] rounded-md py-1 text-sm h-max border border-gray-200 hover:bg-gray-100 pl-4",children:[r?h.get(r,"name"):"Select Page",e.jsx(p.ChevronDown,{className:"ml-2 h-4 w-4"})]})}),e.jsxs(a.DropdownMenuContent,{className:"w-96 divide-y shadow-xl p-0 max-h-[75vh]",children:[e.jsx("div",{className:"p-1.5 bg-gray-50/30",children:e.jsx(f,{isDefaultLang:u,searchQuery:c,setSearchQuery:t})}),(n==null?void 0:n.length)===0?e.jsx("div",{className:"h-24 text-xs flex items-center justify-center",children:"No pages found"}):n==null?void 0:n.map(s=>e.jsx(a.DropdownMenuItem,{onClick:()=>l(s),disabled:u?i!==s.lang:o!==s.lang,className:`flex flex-col justify-start cursor-pointer overflow-x-auto whitespace-nowrap no-scrollbar ${s.id===(r==null?void 0:r.id)?"bg-blue-50":"hover:bg-gray-50"}`,children:e.jsx("div",{className:"w-full text-xs whitespace-nowrap px-2 py-[2px]",children:e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsx("span",{className:"font-mono font-medium text-gray-500 text-xs rounded-full px-2 py-[1px] border border-gray-300 truncate",children:s.slug})]})})},s.id))]})]})},j=()=>{const{dynamicPage:r,dynamicPages:l,allLangPages:c,selectedLang:t,searchQuery:n,updateDynamicPage:o,updateSearchQuery:i,onChangeLanguage:u}=g.useDynamicPageSelector(),s=d.useRef(void 0);return d.useEffect(()=>{s.current!==t&&r&&(u(),s.current=t)},[t,l]),e.jsx("div",{className:"relative",children:e.jsx(m,{dynamicPage:r,setDynamicPage:o,searchQuery:n,setSearchQuery:i,dynamicPages:c})})};exports.default=j;
@@ -4,7 +4,7 @@ import { DropdownMenu as h, DropdownMenuTrigger as p, Button as m, DropdownMenuC
4
4
  import { get as v } from "lodash-es";
5
5
  import { ChevronDown as w } from "lucide-react";
6
6
  import { useRef as b, useEffect as N } from "react";
7
- import { n as y } from "./index-B_T6ZeA4.js";
7
+ import { n as y } from "./index-tgsBai_8.js";
8
8
  const D = ({
9
9
  isDefaultLang: e,
10
10
  searchQuery: l,
@@ -0,0 +1,5 @@
1
+ "use strict";var xs=e=>{throw TypeError(e)};var _s=(e,t,s)=>t.has(e)||xs("Cannot "+s);var x=(e,t,s)=>(_s(e,t,"read from private field"),s?s.call(e):t.get(e)),R=(e,t,s)=>t.has(e)?xs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),O=(e,t,s,n)=>(_s(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"),H=require("jotai"),S=require("@tanstack/react-query"),P=require("@chaibuilder/sdk"),g=require("@chaibuilder/sdk/ui"),_=require("lucide-react"),F=require("sonner"),Us=require("@chaibuilder/runtime"),nr=require("@chaibuilder/sdk/web-blocks");function rr(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=rr(h),$e={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"},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"},ar=H.atom({}),kt=()=>H.useAtom(ar),ne=(e,t)=>{const[s]=kt();return h.useMemo(()=>p.get(s,e,t),[s,e,t])},G=()=>ne("apiUrl","/chai/api"),Bs=()=>ne("usersApiUrl","/chai/users"),ir=()=>ne("assetsApiUrl","/chai/assets"),Fs=()=>ne("websocket",null),or=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),lr=()=>{const e=N(),t=G();return h.useCallback(async({body:s,headers:n={},url:r=t,streamResponse:a=!1})=>e(r,s,n,a),[e])},N=()=>{const e=ne("onLogout"),t=ne("getAccessToken"),s=G();return h.useCallback(async(n=s,r,a={},i=!1)=>{const l=await t();try{const c=p.get(r,"action","").toLowerCase(),d=await or(n+(c?`?action=${c}`:""),r,{...a,Authorization:`Bearer ${l}`});if(i)return d;if(d.status===401)return console.log("401 Response",d),e(),window.location.reload(),null;if(!d.ok){const u=await d.json();throw console.error(`API Error (${d.status}):`,u),{status:d.status,statusText:d.statusText,...u,message:u.error||u.message||`Server error: ${d.status}`}}return await d.json()}catch(c){throw console.error("API request failed:",r,c),c}},[e,t])};function le(){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 Ae=e=>{const t=G(),[s]=le(),n=e??s.get("page"),r=N();return S.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})},cr=H.atom(null),qs=()=>H.useAtom(cr),as=()=>{const[e]=qs();return(e==null?void 0:e.slug)||""};function ur(e,t){const[s,n]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const dr=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=P.useLanguages(),{data:r}=te(),a=r==null?void 0:r.pageType,i=G(),l=N(),{data:c,isFetching:d}=S.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}),u=h.useMemo(()=>s===""?c.filter(f=>f.lang===""||f.lang===n):c.filter(f=>f.lang===s),[s,n,c]);return{allLangPages:c,data:u,isFetching:d}},Ks=()=>{const{selectedLang:e,fallbackLang:t}=P.useLanguages(),[s,n]=qs(),[r,a]=h.useState(""),i=ur(r,500),{allLangPages:l,data:c,isFetching:d}=dr({query:i}),u=h.useCallback(m=>n(m),[n]),f=h.useCallback(m=>a(m),[a]),E=h.useCallback(()=>{if(!s)return;const m=!(s!=null&&s.primaryPage),A=e.length===0,w=m?s==null?void 0:s.id:s==null?void 0:s.primaryPage,M=l.filter(T=>(T==null?void 0:T.primaryPage)===w||T.id===w).find(T=>A?T.lang===e||T.lang===t:T.lang===e);n(M||s)},[s,e,l,n,t]);return{isFetching:d,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:u,updateSearchQuery:f,onChangeLanguage:E}},fr=H.atom({lastSaved:void 0}),is=()=>H.useAtom(fr),te=()=>{const[e]=le(),t=e.get("page"),{data:s,isFetching:n}=Ae();return{data:h.useMemo(()=>({...p.find(s,{id:t})||{}}),[s,t]),isFetching:n}},fe=()=>{const[e]=le(),t=e.get("lang")??"",{data:s,isFetching:n}=Ae();return{data:h.useMemo(()=>p.find(s,{lang:t})||{},[s,t]),isFetching:n}},hr=H.atom({}),gr=()=>H.useAtom(hr),mr=()=>{const{data:e}=fe(),t=as(),s=ne("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},Te=()=>{const e=G(),t=N();return S.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:5*60*1e3,placeholderData:{languages:[],theme:{fontFamily:"",borderRadius:"",colors:{}},appKey:"",fallbackLang:"",designTokens:{}},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})};function os(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 Ot=H.atom(null),Rt=()=>{const e=ne("currentUser"),t=ne("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},J={LOCKED:"LOCKED",EDITING:"EDITING",CHECKING:"CHECKING",TAKE_OVER_REQUESTED:"TAKE_OVER_REQUESTED",ACTIVE_IN_ANOTHER_TAB:"ACTIVE_IN_ANOTHER_TAB",FORCE_TAKE_OVER:"FORCE_TAKE_OVER",CONNECTION_LOST:"CONNECTION_LOST"},X={FORCE_TAKE_OVER:"FORCE_TAKE_OVER",TAKE_OVER_REQUEST:"TAKE_OVER_REQUEST",TAKE_OVER_APPROVED:"TAKE_OVER_APPROVED",TAKE_OVER_REJECTED:"TAKE_OVER_REJECTED",FORCE_TAKE_OVER_REQUEST:"FORCE_TAKE_OVER_REQUEST",CONTINUE_EDITING_IN_THIS_CLIENT:"CONTINUE_EDITING_IN_THIS_CLIENT",CONTINUE_EDITING_IN_THIS_TAB_REQUEST:"CONTINUE_EDITING_IN_THIS_TAB_REQUEST"},Er=["sync","join","leave"],pr=[X.FORCE_TAKE_OVER,X.TAKE_OVER_REQUEST,X.TAKE_OVER_APPROVED,X.TAKE_OVER_REJECTED,X.FORCE_TAKE_OVER_REQUEST,X.CONTINUE_EDITING_IN_THIS_CLIENT,X.CONTINUE_EDITING_IN_THIS_TAB_REQUEST],yr=H.atom({}),Vs=H.atom(null),Ar=H.atom(J.CHECKING),Tr=H.atom({}),Sr=e=>{const t={},s=p.groupBy(p.values(e).map(p.first).filter(Boolean),"pageId");return Object.entries(s).forEach(([n,r])=>t[n]=p.minBy(r,"onlineAt")),t},Pr=e=>{const t=p.minBy(p.values(e).map(p.first).filter(Boolean),"onlineAt"),s=t==null?void 0:t.onlineAt;return s?s-100:+new Date-1e3*60*60*4},pt=()=>{const{user:e}=Rt();return e==null?void 0:e.id},xr=()=>{const{data:e}=Te();return`WEBSITE:${e==null?void 0:e.appKey}`},yt=()=>{const{data:e}=te();return e==null?void 0:e.id},_e=crypto.randomUUID();let Vt=null;const ls=()=>{const[e,t]=H.useAtom(yr);return{pageToUser:e,setPageToUser:t}},ae=()=>{const[e,t]=H.useAtom(Ar),s=[J.LOCKED,J.ACTIVE_IN_ANOTHER_TAB].includes(e),n=[J.EDITING].includes(e);return{pageStatus:e,setPageStatus:t,isLocked:s,isEditing:n}},cs=()=>{const[e,t]=H.useAtom(Tr);return{pageLockMeta:e,setPageLockMeta:t}},Hs=()=>{const e=yt(),{pageToUser:t}=ls();return h.useMemo(()=>t[e],[t,e])},us=()=>{const e=Fs(),{setPageStatus:t}=ae(),[s]=H.useAtom(Vs);return h.useEffect(()=>{if(clearTimeout(Vt),!e)return Vt=setTimeout(()=>{e||t(J.EDITING)},500),()=>clearTimeout(Vt)},[e,t]),s},_r=()=>{const e=yt(),t=pt(),s=us(),{setPageToUser:n}=ls(),{setPageStatus:r,pageStatus:a}=ae(),i=h.useRef(e);return i.current=e,h.useCallback(l=>{const c=l||s;if(!c)return[];const d=c==null?void 0:c.presenceState(),u=Sr(d);n(u);const f=u[i.current];if(!f)r(J.CHECKING);else if(!t)r(J.CHECKING);else if(f.userId===t&&f.clientId===_e){if(a===J.TAKE_OVER_REQUESTED)return;r(J.EDITING)}else f.userId===t&&f.clientId!==_e?r(J.ACTIVE_IN_ANOTHER_TAB):r(J.LOCKED)},[s,n,r,t,a])},Qs=()=>{const e=pt(),t=yt(),s=us(),n=Hs(),{setPageLockMeta:r}=cs(),a=h.useRef(t);return a.current=t,h.useCallback(async(i,l)=>{if(!s)return;const c=l||{};c.userId=e,c.pageId=a.current,c.senderClientId=_e,c.receiverClientId=(l==null?void 0:l.requestingClientId)||(n==null?void 0:n.clientId),await s.send({event:i,payload:c,type:"broadcast"}),r({})},[s,e,n,r])},wr=()=>{const e=pt(),t=yt(),s=us(),{setPageStatus:n}=ae(),{setPageLockMeta:r}=cs(),a=Qs(),i=h.useRef(t),{savePageAsync:l}=P.useSavePage();return i.current=t,h.useCallback(c=>async({payload:d})=>{const u=d||{};if(!(!(u!=null&&u.pageId)||(u==null?void 0:u.pageId)!==i.current||(u==null?void 0:u.receiverClientId)!==_e))switch(r({}),c){case X.FORCE_TAKE_OVER_REQUEST:case X.CONTINUE_EDITING_IN_THIS_TAB_REQUEST:{try{await l(!0)}catch(f){console.error("Failed to save page before releasing lock:",f)}await a(X.CONTINUE_EDITING_IN_THIS_CLIENT,{requestingClientId:u==null?void 0:u.senderClientId}),setTimeout(()=>r({type:c}),0);break}case X.TAKE_OVER_REQUEST:{r({requestingUserId:u==null?void 0:u.userId,requestingClientId:u==null?void 0:u.senderClientId}),n(J.TAKE_OVER_REQUESTED);break}case X.CONTINUE_EDITING_IN_THIS_CLIENT:{const f=Pr(s==null?void 0:s.presenceState());n(J.CHECKING),await(s==null?void 0:s.track({onlineAt:f,pageId:i.current,userId:e,clientId:_e}));break}case X.TAKE_OVER_REJECTED:{r({type:X.TAKE_OVER_REJECTED});break}}},[a,r,n,s,e,l])},vr=()=>{const e=Fs(),t=pt(),s=yt(),n=xr(),[r,a]=H.useAtom(Vs),i=wr(),l=_r(),c=h.useRef(i),d=h.useRef(l);h.useEffect(()=>{c.current=i,d.current=l},[i,l]),h.useEffect(()=>{const u=()=>{document.visibilityState==="visible"&&r&&r.subscribe()};return document.addEventListener("visibilitychange",u),()=>{document.removeEventListener("visibilitychange",u)}},[r]),h.useEffect(()=>{if(!e||!t||!n||r&&r.topic===n)return;const u=e.channel(n,{config:{presence:{key:_e}}});return pr.forEach(f=>{u.on("broadcast",{event:f},E=>{c.current(f)(E)})}),Er.forEach(f=>{u.on("presence",{event:f},()=>{d.current(u)})}),u.subscribe(async f=>{f==="SUBSCRIBED"?a(u):(f==="CHANNEL_ERROR"||f==="TIMED_OUT")&&console.log("Realtime connection failed",f)}),()=>{u.unsubscribe()}},[e,t,n,a]),h.useEffect(()=>(r&&s&&t&&r.track({pageId:s,userId:t,clientId:_e,onlineAt:+new Date}),()=>{r&&s&&r.untrack()}),[r,s,t])},Mt=()=>{const{data:e}=Te();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},ds=()=>{const e=N(),t=G();return S.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},br=e=>{const t=N(),s=G(),n=Mt();return S.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||{}})},Ir=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-BL5S9ccS.cjs"))),zs=({children:e})=>{const{t}=P.useTranslation(),[s,n]=le(),r=s.get("page"),{data:a,isFetching:i}=te(),{data:l,isFetching:c}=ds(),[d,u]=h.useState(!1),[f,E]=h.useState(!0),{savePage:m}=P.useSavePage(),A=!!r&&!p.isEmpty(a),{isLocked:w}=ae(),v=h.useMemo(()=>{if(!l||c)return!1;const L=l.find(q=>q.slug==="/");return L==null?void 0:L.id},[l,c]);h.useEffect(()=>{if(c||!v||l.some(j=>j.id===r))return;const q=new URLSearchParams({page:v});os(q,n),!c&&l&&E(!1)},[r,c,l,v,n]);const M=!f&&!r,T=!f&&!i&&p.isEmpty(a),C=d||M||T;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(g.Tooltip,{children:[o.jsx(g.TooltipTrigger,{asChild:!0,onClick:()=>{w||m(),u(!0)},children:e||o.jsx(g.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:o.jsx(_.LogsIcon,{className:"h-4 w-4"})},"template-viewer")}),o.jsx(g.TooltipContent,{side:"right",children:o.jsx("p",{children:t("Open pages manager")})})]})})}),o.jsx(g.Sheet,{open:C,onOpenChange:L=>!L&&A&&u(!1),children:o.jsxs(g.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(g.SheetHeader,{className:"mb-3 px-4 pt-4",children:[o.jsxs(g.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(_.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(g.SheetDescription,{className:"sr-only",children:t("Manage your site structure")})]}),o.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:C&&o.jsx(h.Suspense,{children:o.jsx(Ir,{close:()=>u(!1)})})})]})})]})},Cr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-CkyPkpzC.cjs"))),Lr=()=>{const e=ne("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},$s=({showAdd:e=!0,variant:t="ghost",goToDefaultLang:s=!1})=>{const{fallbackLang:n,languages:r,selectedLang:a,setSelectedLang:i}=P.useLanguages(),l=p.isEmpty(a)?n:a,[,c]=le(),{isLocked:d}=ae(),{t:u}=P.useTranslation();h.useEffect(()=>{const T=new URLSearchParams(window.location.search),C=T.get("lang");C&&(r.includes(C)?i(C):(T.delete("lang"),c(T),i("")))},[r,c,i]);const[,f]=H.useAtom(Ot),{data:E}=te(),{data:m}=Te(),{data:A}=Ae(),w=h.useMemo(()=>{const T=p.compact(p.map(p.get(m,"languages"),C=>{const L=p.find(A,{lang:C});return{key:C,value:p.get($e,C,C),isLangPageAdded:!!L}})).filter(Boolean);return[{key:n,value:p.get($e,n),isLangPageAdded:!0},...T]},[n,A,m]),v=T=>{if(document.querySelector('[data-panel-id="seo"]')){const L=new CustomEvent("seo-language-switch-check",{detail:{fromLang:l,toLang:T,switchHandler:()=>M(T)}});window.dispatchEvent(L);return}M(T)},M=T=>{i(T);const C=new URLSearchParams(window.location.search);T===n?C.delete("lang"):C.set("lang",T),os(C,c)};return p.isEmpty(r)?null:d?o.jsxs(g.Button,{variant:"ghost",size:"sm",className:"ml-px h-max cursor-not-allowed gap-2 py-1.5 opacity-50",children:[o.jsx(_.Languages,{className:"h-4 w-4"}),p.get($e,l,l),o.jsx(_.ChevronDown,{className:"h-4 w-4"})]}):s?o.jsx(g.Button,{onClick:()=>M(n),variant:"link",size:"sm",children:u("Switch to default language")}):o.jsx(o.Fragment,{children:o.jsxs(g.DropdownMenu,{children:[o.jsx(g.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:o.jsxs(g.Button,{disabled:!!d,variant:t,size:"sm",className:"ml-px h-max gap-2 py-1.5",children:[o.jsx(_.Languages,{className:"h-4 w-4"}),p.get($e,l,l),o.jsx(_.ChevronDown,{className:"h-4 w-4"})]})}),o.jsxs(g.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(w.filter(T=>T.isLangPageAdded),T=>o.jsxs(g.DropdownMenuItem,{className:P.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",T.key===l&&"!bg-gray-200 text-gray-700"),onClick:()=>v(T.key),children:[o.jsx("div",{className:"text-slate-600",children:T.value}),T.key===n&&o.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[o.jsx(_.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},T.value)),e&&!p.isEmpty(w.filter(T=>!T.isLangPageAdded))&&o.jsxs(o.Fragment,{children:[o.jsx(g.Separator,{}),o.jsxs(g.Button,{size:"sm",variant:"ghost",onClick:()=>{E&&f({edit:!1,primaryPage:E.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[o.jsx(_.Plus,{className:"mr-1 h-3 w-3"})," Add Langauge"]})]})]})]})})};function Nr(){const[e,t]=H.useAtom(Ot);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(Lr,{}),o.jsx(zs,{}),e&&o.jsx(h.Suspense,{children:o.jsx(Cr,{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 jr(){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(g.Skeleton,{className:"h-4 w-3/4"}),o.jsx(g.Skeleton,{className:"h-3 w-1/2"}),o.jsx(g.Skeleton,{className:"mt-1 h-5 w-20"})]}),o.jsx(g.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}const Dr=z.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-NE8Y5DrC.cjs")));function Gr(){const[e,t]=z.useState(!1);return o.jsx(g.TooltipProvider,{children:o.jsxs(g.Tooltip,{delayDuration:0,children:[o.jsxs(g.Sheet,{open:e,onOpenChange:t,children:[o.jsx(g.SheetTrigger,{asChild:!0,children:o.jsx(g.TooltipTrigger,{asChild:!0,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsxs(g.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[o.jsx(_.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(g.SheetContent,{className:"flex h-[100vh] flex-col",children:e&&o.jsx(h.Suspense,{fallback:o.jsx(jr,{}),children:o.jsx(Dr,{isOpen:e})})})]}),o.jsx(g.TooltipContent,{side:"bottom",children:o.jsx("p",{children:"Revision history"})})]})})}const xt=({permission:e,permissions:t,children:s,fallback:n=null})=>{const{hasPermission:r}=P.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?n:s},kr={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},he=()=>{const e=G(),t=N();return S.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},Ws=e=>{const{data:t}=he();return h.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},Or=()=>{const e=G(),t=N();return S.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),[]}}})},Rr=()=>{const e=G(),t=S.useQueryClient(),s=N(),{data:n}=he();return S.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";F.toast.success(i)},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to add new ${i!=null&&i.hasSlug?"page":i.name}.`,{description:p.get(kr,r.message,r.message)})}})},Mr=()=>{const e=G(),t=S.useQueryClient(),s=N(),{data:n}=fe(),{data:r}=he();return S.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});F.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:a.message})}})},Ur=()=>{const e=G(),t=S.useQueryClient(),s=N(),{data:n}=he();return S.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"){F.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});F.toast.error(`Failed to delete ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},Br=()=>{const e=G(),t=S.useQueryClient(),s=N(),{data:n}=he();return S.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});F.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});F.toast.error(`Failed to take offline ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},fs=()=>{const e=G(),t=N(),s=S.useQueryClient(),{data:n}=te(),{savePageAsync:r}=P.useSavePage();return S.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),F.toast.error("Failed to publish pages.")}})},Fr=()=>{const e=G(),t=N(),s=S.useQueryClient();return S.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]}),F.toast.success("Page marked as template successfully.")},onError:()=>{F.toast.error("Failed to mark page as template.")}})},qr=()=>{const e=G(),t=N(),s=S.useQueryClient();return S.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]}),F.toast.success("Page unmarked as template successfully.")},onError:()=>{F.toast.error("Failed to unmark page as template.")}})},Kr=()=>{const e=G(),t=N(),s=S.useQueryClient();return S.useMutation({mutationFn:async({id:n,slug:r})=>t(e,{action:y.CHANGE_SLUG,data:{id:n,slug:r}}),onSuccess:(n,{primaryPage:r})=>{F.toast.success("Slug changed successfully."),r?s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{F.toast.error("Failed to change slug")}})},Vr=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-CCUKnVTH.cjs")));function Hr({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:s,isPending:n}=fs();return o.jsx(g.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(Vr,{onClose:t,isPending:n,publishPage:s})})})}const se={...P.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"},Ys=e=>{const{fallbackLang:t}=P.useLanguages(),{data:s}=Te(),{data:n,isFetching:r}=Ae(),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]},Qr={particleCount:350,spread:120,origin:{y:.6},angle:90},zr={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},$r=async()=>{const{default:e}=await Promise.resolve().then(()=>require("./confetti.module-BuUnQuWk.cjs"));return e},_t=e=>{let t=zr[e];t||(t={});const s={...Qr,...t};$r().then(n=>n(s))};function Ut({children:e,content:t,side:s="bottom",delayDuration:n=700,showTooltip:r=!0}){return r?o.jsx(g.TooltipProvider,{children:o.jsxs(g.Tooltip,{delayDuration:n,children:[o.jsx(g.TooltipTrigger,{asChild:!0,children:e}),o.jsx(g.TooltipContent,{side:s,sideOffset:10,children:o.jsx("p",{children:t})})]})}):e}const Wr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-CHYNjTFU.cjs"))),Yr=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-Kctu12rQ.cjs"))),Jr=()=>{const{t:e}=P.useTranslation(),{selectedLang:t,fallbackLang:s}=P.useLanguages(),n=ne("getPreviewUrl",async E=>E),[r,a]=h.useState(""),{data:i}=te(),{data:l}=Ae(),{data:c}=he(),d=h.useMemo(()=>{var E;return(E=l==null?void 0:l.find(m=>(m==null?void 0:m.lang)===t))==null?void 0:E.slug},[t,l]),u=h.useCallback(E=>{var m;return(m=p.find(c,{key:E}))==null?void 0:m.hasSlug},[c]),f=t===s?"":t;return h.useEffect(()=>{(async()=>{if(typeof n=="function"){const E=!u(i==null?void 0:i.pageType),m=await n(E?`${f!==""?f+"/":""}${i==null?void 0:i.id}`:d||"");a(m)}else a("")})()},[n,d,i==null?void 0:i.pageType,u,i==null?void 0:i.id,f]),o.jsx(o.Fragment,{children:o.jsx(Ut,{content:e("Open preview in new tab"),delayDuration:0,children:o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:o.jsx(g.Button,{variant:"ghost",size:"sm",className:"gap-2",children:o.jsx(_.Play,{className:"h-4 w-4"})})})})})},Zr=()=>{const{t:e}=P.useTranslation(),[t,s]=P.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Ut,{content:e("Theme"),delayDuration:0,children:o.jsx(g.Button,{variant:t==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>s(t==="theme"?"block":"theme"),children:o.jsx(_.Palette,{className:"h-4 w-4"})})}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},Xr=()=>{const{t:e}=P.useTranslation(),[t,s]=h.useState(!1),{isLocked:n}=ae(),{savePageAsync:r,saveState:a}=P.useSavePage();h.useEffect(()=>{const u=f=>{a==="UNSAVED"&&(f.preventDefault(),f.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",u),()=>{window.removeEventListener("beforeunload",u)}},[a]);const i=h.useCallback(async()=>{t||(s(!0),await r(),s(!1))},[r,t]),{buttonIcon:l,buttonClass:c,tooltipContent:d}=h.useMemo(()=>{switch(a){case"UNSAVED":return{tooltipContent:e("Save draft"),buttonIcon:o.jsx(_.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:e("Saving"),buttonIcon:o.jsx(_.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:e("Saved"),buttonIcon:o.jsx(_.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[a,e]);return n?null:o.jsxs(g.Button,{size:"sm",variant:"ghost",onClick:i,className:`${c} w-24 max-w-24`,children:[l," ",d]})},ea=()=>{const{t:e}=P.useTranslation(),{selectedLang:t}=P.useLanguages(),{data:s}=fe(),{data:n}=Ae(),[r,a]=h.useState(!1),[i,l]=h.useState(!1),[c,d]=h.useState(null),{savePageAsync:u}=P.useSavePage(),[f,E]=h.useState(!1),{data:m}=te(),{mutate:A,isPending:w}=fs(),{needTranslations:v}=P.useSavePage(),M=v(),{buttonText:T,buttonClassName:C,isPublished:L}=h.useMemo(()=>{const I=m&&(m==null?void 0:m.online);return{buttonClassName:I?"hover:bg-green-600 bg-green-500":"",isPublished:I,buttonText:e(I?"Published":"Publish")}},[m,e]),q=async()=>{if(M){E(!0);return}j()},j=()=>{const I=[s==null?void 0:s.id,s==null?void 0:s.primaryPage];A({ids:p.compact(I)},{onSuccess:()=>_t("TOP_RIGHT")})},ce=()=>{E(!1),j()},ue=async()=>{E(!1),await u()},K=h.useMemo(()=>p.map(n??[],"id"),[n]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex",children:[o.jsxs(g.Button,{size:"sm",onClick:q,disabled:w||!(m!=null&&m.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${C}`,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:L?o.jsx(_.Send,{className:"h-4 w-4"}):o.jsx(_.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:L?o.jsx(_.Rocket,{className:"h-4 w-4"}):o.jsx(_.Send,{className:"h-4 w-4"})}),o.jsx("span",{children:T}),t?`(${p.upperCase(t)})`:""]}),o.jsxs(g.DropdownMenu,{children:[o.jsx(g.DropdownMenuTrigger,{asChild:!0,children:o.jsx(g.Button,{size:"sm",disabled:w||!(m!=null&&m.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${C}`,children:o.jsx(_.ChevronDown,{className:"h-4 w-4"})})}),o.jsxs(g.DropdownMenuContent,{align:"end",className:"w-52",children:[o.jsxs(g.DropdownMenuItem,{disabled:w,className:"cursor-pointer text-xs",onClick:()=>A({ids:K},{onSuccess:()=>_t("TOP_RIGHT")}),children:[e("Publish")," with translation pages"]}),!L&&o.jsxs(g.DropdownMenuItem,{disabled:w,className:"cursor-pointer text-xs",onClick:()=>A({ids:[m==null?void 0:m.id]},{onSuccess:()=>_t("TOP_RIGHT")}),children:[e("Publish")," page"]}),o.jsxs(g.DropdownMenuItem,{onClick:()=>a(!0),className:"cursor-pointer text-xs",children:[e("Open")," publish menu"]}),L&&o.jsxs(g.DropdownMenuItem,{onClick:()=>d(s),className:"cursor-pointer text-xs",children:[e("Unpublish")," page ",t?`(${p.upperCase(t)})`:""]})]})]})]}),o.jsx(Hr,{showModal:r,onClose:()=>a(!1)}),c&&o.jsx(h.Suspense,{children:o.jsx(Wr,{page:c,onClose:()=>d(null)})}),f&&o.jsx(h.Suspense,{children:o.jsx(Yr,{isOpen:f,onClose:ue,onContinue:ce,isPending:w})})]})};function ta(){const{isLocked:e}=ae(),[t]=le(),s=t.get("lang"),n=Ys(s);return e||!n?o.jsx("div",{}):o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o.jsx(Gr,{}),o.jsx(xt,{permission:se.EDIT_THEME,children:o.jsx(Zr,{})}),o.jsx(Jr,{}),o.jsx(xt,{permission:se.SAVE_PAGE,children:o.jsx(Xr,{})}),o.jsx(xt,{permission:se.PUBLISH_PAGE,children:o.jsx(ea,{})})]})}const Js=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:i,children:l,isLanguagePage:c})=>{const{t:d}=P.useTranslation(),{hasPermission:u}=P.usePermissions(),{data:f}=he(),E=h.useMemo(()=>p.find(f,{key:e.pageType}),[f,e.pageType]),m=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),A=h.useMemo(()=>!!(E!=null&&E.hasSlug),[E==null?void 0:E.hasSlug]);return!u(se.EDIT_PAGE)&&!u(se.DELETE_PAGE)&&!u(se.UNPUBLISH_PAGE)||!e?null:o.jsxs(g.DropdownMenu,{children:[o.jsx(g.DropdownMenuTrigger,{asChild:!0,onClick:v=>v.stopPropagation(),children:l}),o.jsxs(g.DropdownMenuContent,{align:"center",className:"text-sm",children:[u(se.ADD_PAGE)&&!c&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:v=>{v.stopPropagation(),t(e)},children:[o.jsx(_.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),u(se.EDIT_PAGE)&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:v=>{v.stopPropagation(),s({...e,global:!(E!=null&&E.hasSlug)})},children:[o.jsx(_.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&u(se.UNPUBLISH_PAGE)&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:v=>{v.stopPropagation(),n(e)},children:[o.jsx(_.Power,{className:"size-3"}),d("Unpublish")]}),u(se.DELETE_PAGE)&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:v=>{v.stopPropagation(),r(e)},children:[o.jsx(_.Trash,{className:"size-3"}),d("Delete")]}),u(se.MARK_AS_TEMPLATE)&&A&&!c&&o.jsx(o.Fragment,{children:m?o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:v=>{v.stopPropagation(),i(e)},children:[o.jsx(_.SquareLibrary,{className:"size-3"}),d("Unmark as template")]}):o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:v=>{v.stopPropagation(),a(e)},children:[o.jsx(_.SquareLibrary,{className:"size-3"}),d("Mark as template")]})})]})]})},sa=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-DPtVHa8m.cjs"))),na=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-BXEQB0Si.cjs"))),ra=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-C32_9H41.cjs"))),aa=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-DKBwTiMJ.cjs"))),ia=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-BBzZqNJt.cjs"))),oa=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-CHYNjTFU.cjs"))),la=()=>{const[e,t]=h.useState(null),[s,n]=h.useState(null),[r,a]=h.useState(null),[i,l]=h.useState(null),[c,d]=h.useState(null),[u,f]=h.useState(null),{data:E,isFetching:m}=fe(),{selectedLang:A,fallbackLang:w}=P.useLanguages(),{data:v}=Ae(),M=v==null?void 0:v.find(j=>j.lang===A),{isLocked:T}=ae(),C=!(E!=null&&E.slug),[,L]=H.useAtom(Ot);if(!E)return null;const q=j=>{A.length>0&&A!==w?L({edit:!0,id:j==null?void 0:j.id,primaryPage:j==null?void 0:j.primaryPage}):f(j)};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(zs,{children:o.jsx(g.Button,{className:"flex h-7 max-w-[200px] cursor-pointer items-center truncate rounded px-1 text-xs font-medium",variant:"ghost",children:m?o.jsx(_.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:[C?o.jsx(_.Hash,{className:"mr-1 h-4 w-4"}):o.jsx(_.File,{className:"mr-1 h-4 w-4"}),p.get(M||E,"name")??""]})})}),T?o.jsx(g.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 cursor-not-allowed rounded opacity-50 hover:bg-transparent",children:o.jsx(_.MoreHorizontal,{className:"h-4 w-4"})}):o.jsx(Js,{page:E,setDuplicatePage:j=>d(j),setAddEditPage:j=>q(j),setUnpublishPage:j=>n(j),setDeletePage:j=>t(j),setMarkAsTemplate:j=>a(j),setUnmarkAsTemplate:j=>l(j),isLanguagePage:A.length>0&&A!==w,children:o.jsx(g.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:o.jsx(_.MoreHorizontal,{className:"h-4 w-4"})})})]}),u&&o.jsx(h.Suspense,{children:o.jsx(sa,{closePanel:()=>f(null),editPage:()=>{},addEditPage:u,setAddEditPage:f})}),e&&o.jsx(h.Suspense,{children:o.jsx(na,{page:e,onClose:()=>t(null)})}),s&&o.jsx(h.Suspense,{children:o.jsx(oa,{page:s,onClose:()=>n(null)})}),r&&o.jsx(h.Suspense,{children:o.jsx(aa,{page:r,onClose:()=>a(null)})}),i&&o.jsx(h.Suspense,{children:o.jsx(ia,{page:i,onClose:()=>l(null)})}),c&&o.jsx(h.Suspense,{children:o.jsx(ra,{page:c,onClose:()=>d(null),closePanel:()=>f(null)})})]})},hs=({children:e,className:t=""})=>o.jsx("div",{className:P.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}),ca=({hasDynamicPage:e})=>o.jsx(hs,{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"})]})}),ua=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-CLxpglyO.cjs"))),da=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=Ks(),n=t.length>0;return s?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx(ca,{hasDynamicPage:n}),o.jsx(h.Suspense,{children:o.jsx(ua,{})})]})},fa=()=>{const{data:e,isFetching:t}=fe(),{data:s,isFetching:n}=te(),r=p.get(s,"dynamic",!1),a=as(),i=P.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,d=mr(),u=t||n,E=(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:P.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",u&&"max-w-0 overflow-hidden opacity-0"),children:o.jsx(la,{})}),o.jsxs("div",{className:P.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":""),u&&"max-w-0 overflow-hidden opacity-0"),children:[o.jsx($s,{}),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:E==="/"?o.jsxs("span",{className:"text-gray-900",children:["/",o.jsx("span",{className:"text-[11px] font-light italic text-gray-400",children:"(Homepage)"})]}):E}),!c&&o.jsx("a",{href:d,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(_.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&i&&o.jsx(da,{})]})},ha=()=>o.jsxs("div",{className:"flex h-full w-full items-center justify-between px-2",children:[o.jsx(Nr,{}),o.jsx(fa,{}),o.jsx(ta,{})]}),Zs=()=>{const e=S.useQueryClient(),{data:t}=S.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(n=>{e.setQueryData([y.AI_CONTEXT],n)},[e]),aiContext:t}},ga=()=>{const e=G(),{aiContext:t}=Zs(),s=N();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])},ma=(e,t)=>t.map(s=>{if(p.has(e,s._type)){const n=Us.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}),Ea=e=>{const t=Us.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:ma(t,s)}},[e,t])},pa=()=>{const[e]=le(),t=e.get("page"),s=G(),{setAiContext:n}=Zs(),[,r]=is(),[,a]=gr(),[,i]=P.useIsPageLoaded(),l=N();return S.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}}),d=c.blocks??[],u=p.find(d,{_type:"@chai/ai-context"});return n(p.get(u,"_value","")||""),r(f=>({...f,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>i(!0),500),d},enabled:!!t})},Xs=()=>{const{data:e}=te(),{data:t}=fe(),s=G(),n=N(),r=Mt(),a=as();return S.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})},en=()=>{const e=G(),t=S.useQueryClient(),s=N();return S.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||F.toast.success("Website settings updated successfully.")},onError:n=>{F.toast.error("Failed to update website settings",{description:n.message})}})},ya=()=>{const e=G(),t=S.useQueryClient(),s=N(),{selectedLang:n}=P.useLanguages();return S.useMutation({mutationFn:async r=>s(e,{action:y.ADD_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema added successfully.")},onError:r=>{F.toast.error("Failed to add schema",{description:r.message})}})},Aa=()=>{const e=G(),t=S.useQueryClient(),s=N(),{selectedLang:n}=P.useLanguages();return S.useMutation({mutationFn:async r=>s(e,{action:y.UPDATE_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema updated successfully.")},onError:r=>{F.toast.error("Failed to update schema",{description:r.message})}})},Ta=()=>{const e=G(),t=S.useQueryClient(),s=N();return S.useMutation({mutationFn:async n=>s(e,{action:y.DELETE_GLOBAL_SCHEMA,data:{id:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema deleted successfully.")},onError:n=>{F.toast.error("Failed to delete schema",{description:n.message})}})},Sa=()=>{const e=G(),t=N();return S.useMutation({mutationFn:async s=>t(e,{action:y.TOGGLE_PAGE_GLOBAL_SCHEMA,data:s}),onError:s=>{F.toast.error("Failed to toggle schema",{description:s.message})}})},Pa=()=>{const e=G(),t=N();return S.useMutation({mutationFn:async s=>t(e,{action:y.APPLY_SCHEMA_TO_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{F.toast.success(`Schema applied to ${s.count} page(s)`)},onError:s=>{F.toast.error("Failed to apply schema to all pages",{description:s.message})}})},xa=()=>{const e=G(),t=N();return S.useMutation({mutationFn:async s=>t(e,{action:y.REMOVE_SCHEMA_FROM_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{F.toast.success(`Schema removed from ${s.count} page(s)`)},onError:s=>{F.toast.error("Failed to remove schema from all pages",{description:s.message})}})},ws={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:P.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),[]}}},_a=()=>{const e=G(),t=N();return S.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const n=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return n.forEach(r=>{P.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>ws.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>ws.getUILibraryBlock(a,t,e)})}),n}})},tn=()=>{const e=Bs(),t=N(),{user:s}=Rt(),n=s==null?void 0:s.id;return S.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})},wa=()=>{const e=G(),t=N(),[,s]=is();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")}}}},va=()=>{const{data:e}=ds(),t=G(),s=N();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])}},ba=h.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-content-nmbQV7rT.cjs")).then(e=>e.aiPanelContent)),sn="chai-chat-panel",Ia=({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"})})})]}),Ca=({isActive:e,show:t})=>o.jsx(g.Button,{size:"icon",className:"p-0 [&_svg]:size-6",onClick:t,variant:e?"default":"ghost",children:o.jsx(Ia,{className:e?"h-5 w-5 text-white":"h-5 w-5 text-primary"})}),La={id:sn,label:"AI Assistant",button:Ca,panel:ba,position:"top"},Na=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-CXIcTGVk.cjs"))),ja=({isActive:e,show:t})=>{const{data:s}=Te();return!p.has(s,"languages")||!p.get(s,"languages",[]).length?null:o.jsx(g.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:o.jsx(_.LanguagesIcon,{className:"h-4 w-4"})})},nn="lang",Da={id:nn,label:"Languages",position:"top",panel:Na,button:ja,view:"modal",width:400},Ga=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-hwJUoGfJ.cjs"))),rn="seo",ka=({isActive:e,show:t})=>{const{data:s}=te(),n=Ws(s==null?void 0:s.pageType);return!p.has(n,"hasSlug")||!n.hasSlug?null:o.jsx(g.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"})]})})},Oa={id:rn,label:"SEO",panel:Ga,button:ka,position:"top",width:600,view:"modal"},an="user-info",Ra=()=>{const{t:e}=P.useTranslation(),{user:t,logout:s}=Rt(),n=ne("onLogout",p.noop);return t?o.jsxs(g.HoverCard,{children:[o.jsx(g.HoverCardTrigger,{asChild:!0,children:o.jsx(g.Button,{variant:"ghost",className:"text-sm font-medium",children:o.jsx(_.User,{className:"h-4 w-4"})})}),o.jsxs(g.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(g.AlertDialog,{children:[o.jsx(g.AlertDialogTrigger,{asChild:!0,children:o.jsx(g.Button,{variant:"outline",size:"sm",className:"w-full",children:e("Logout")})}),o.jsxs(g.AlertDialogContent,{children:[o.jsxs(g.AlertDialogHeader,{children:[o.jsx(g.AlertDialogTitle,{children:e("Are you sure you want to logout?")}),o.jsx(g.AlertDialogDescription,{children:e("You will be redirected to the login page.")})]}),o.jsxs(g.AlertDialogFooter,{children:[o.jsx(g.AlertDialogCancel,{children:e("Cancel")}),o.jsx(g.AlertDialogAction,{onClick:()=>{s(),p.isFunction(n)&&n()},children:e("Logout")})]})]})]})]})]}):null},Ma={id:an,label:"User Info",button:Ra,position:"bottom"},Ua=()=>{P.registerChaiSidebarPanel(rn,Oa),P.registerChaiSidebarPanel(nn,Da),P.registerChaiSidebarPanel(an,Ma),(localStorage.getItem("chai-feature-flags")??"").includes("enable-ai-chat-panel")&&P.registerChaiSidebarPanel(sn,La)};var b={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return vs(this.context.count)},getNextContextId(){return vs(this.context.count++)}};function vs(e){const t=String(e),s=t.length-1;return b.context.id+(s?String.fromCharCode(96+s):"")+t}function We(e){b.context=e}var on=!1,Ba=(e,t)=>e===t,bt=Symbol("solid-proxy"),ln=typeof Proxy=="function",gs=Symbol("solid-track"),It={equals:Ba},cn=pn,ge=1,Ct=2,un={owned:null,cleanups:null,context:null,owner:null},Ht={},k=null,Qt=null,Fa=null,U=null,Z=null,de=null,Bt=0;function Ee(e,t){const s=U,n=k,r=e.length===0,a=t===void 0?n:t,i=r?un:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>Y(()=>et(i)));k=i,U=null;try{return oe(l,!0)}finally{U=s,k=n}}function V(e,t){t=t?Object.assign({},It,t):It;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=r=>(typeof r=="function"&&(r=r(s.value)),En(s,r));return[mn.bind(s),n]}function dn(e,t,s){const n=Ft(e,t,!0,ge);He(n)}function pe(e,t,s){const n=Ft(e,t,!1,ge);He(n)}function ms(e,t,s){cn=ei;const n=Ft(e,t,!1,ge);(!s||!s.render)&&(n.user=!0),de?de.push(n):He(n)}function $(e,t,s){s=s?Object.assign({},It,s):It;const n=Ft(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,He(n),mn.bind(n)}function qa(e){return e&&typeof e=="object"&&"then"in e}function Ka(e,t,s){let n,r,a;n=!0,r=e,a={};let i=null,l=Ht,c=null,d=!1,u="initialValue"in a,f=typeof n=="function"&&$(n);const E=new Set,[m,A]=(a.storage||V)(a.initialValue),[w,v]=V(void 0),[M,T]=V(void 0,{equals:!1}),[C,L]=V(u?"ready":"unresolved");b.context&&(c=b.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:b.load&&b.has(c)&&(l=b.load(c)));function q(I,D,W,Q){return i===I&&(i=null,Q!==void 0&&(u=!0),(I===l||D===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(Q,{value:D})),l=Ht,j(D,W)),D}function j(I,D){oe(()=>{D===void 0&&A(()=>I),L(D!==void 0?"errored":u?"ready":"unresolved"),v(D);for(const W of E.keys())W.decrement();E.clear()},!1)}function ce(){const I=Ja,D=m(),W=w();if(W!==void 0&&!i)throw W;return U&&U.user,D}function ue(I=!0){if(I!==!1&&d)return;d=!1;const D=f?f():n;if(D==null||D===!1){q(i,Y(m));return}let W;const Q=l!==Ht?l:Y(()=>{try{return r(D,{value:m(),refetching:I})}catch(re){W=re}});if(W!==void 0){q(i,void 0,wt(W),D);return}else if(!qa(Q))return q(i,Q,void 0,D),Q;return i=Q,"v"in Q?(Q.s===1?q(i,Q.v,void 0,D):q(i,void 0,wt(Q.v),D),Q):(d=!0,queueMicrotask(()=>d=!1),oe(()=>{L(u?"refreshing":"pending"),T()},!1),Q.then(re=>q(Q,re,void 0,D),re=>q(Q,void 0,wt(re),D)))}Object.defineProperties(ce,{state:{get:()=>C()},error:{get:()=>w()},loading:{get(){const I=C();return I==="pending"||I==="refreshing"}},latest:{get(){if(!u)return ce();const I=w();if(I&&!i)throw I;return m()}}});let K=k;return f?dn(()=>(K=k,ue(!1))):ue(!1),[ce,{refetch:I=>hn(K,()=>ue(I)),mutate:A}]}function Va(e){return oe(e,!1)}function Y(e){if(U===null)return e();const t=U;U=null;try{return e()}finally{U=t}}function Ha(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 d=0;d<e.length;d++)l[d]=e[d]()}else l=e();if(a)return a=!1,i;const c=Y(()=>t(l,r,i));return r=l,c}}function fn(e){ms(()=>Y(e))}function Ke(e){return k===null||(k.cleanups===null?k.cleanups=[e]:k.cleanups.push(e)),e}function bs(){return k}function hn(e,t){const s=k,n=U;k=e,U=null;try{return oe(t,!0)}catch(r){Es(r)}finally{k=s,U=n}}function Qa(e){const t=U,s=k;return Promise.resolve().then(()=>{U=t,k=s;let n;return oe(e,!1),U=k=null,n?n.done:void 0})}var[za,rl]=V(!1);function $a(){return[za,Qa]}function Wa(e,t){const s=Symbol("context");return{id:s,Provider:ti(s),defaultValue:e}}function Ya(e){let t;return k&&k.context&&(t=k.context[e.id])!==void 0?t:e.defaultValue}function gn(e){const t=$(e),s=$(()=>Yt(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var Ja;function mn(){if(this.sources&&this.state)if(this.state===ge)He(this);else{const e=Z;Z=null,oe(()=>Nt(this),!1),Z=e}if(U){const e=this.observers?this.observers.length:0;U.sources?(U.sources.push(this),U.sourceSlots.push(e)):(U.sources=[this],U.sourceSlots=[e]),this.observers?(this.observers.push(U),this.observerSlots.push(U.sources.length-1)):(this.observers=[U],this.observerSlots=[U.sources.length-1])}return this.value}function En(e,t,s){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&oe(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],i=Qt&&Qt.running;i&&Qt.disposed.has(a),(i?!a.tState:!a.state)&&(a.pure?Z.push(a):de.push(a),a.observers&&yn(a)),i||(a.state=ge)}if(Z.length>1e6)throw Z=[],new Error},!1)),t}function He(e){if(!e.fn)return;et(e);const t=Bt;Za(e,e.value,t)}function Za(e,t,s){let n;const r=k,a=U;U=k=e;try{n=e.fn(t)}catch(i){return e.pure&&(e.state=ge,e.owned&&e.owned.forEach(et),e.owned=null),e.updatedAt=s+1,Es(i)}finally{U=a,k=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?En(e,n):e.value=n,e.updatedAt=s)}function Ft(e,t,s,n=ge,r){const a={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:k,context:k?k.context:null,pure:s};return k===null||k!==un&&(k.owned?k.owned.push(a):k.owned=[a]),a}function Lt(e){if(e.state===0)return;if(e.state===Ct)return Nt(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<Bt);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===ge)He(e);else if(e.state===Ct){const n=Z;Z=null,oe(()=>Nt(e,t[0]),!1),Z=n}}function oe(e,t){if(Z)return e();let s=!1;t||(Z=[]),de?s=!0:de=[],Bt++;try{const n=e();return Xa(s),n}catch(n){s||(de=null),Z=null,Es(n)}}function Xa(e){if(Z&&(pn(Z),Z=null),e)return;const t=de;de=null,t.length&&oe(()=>cn(t),!1)}function pn(e){for(let t=0;t<e.length;t++)Lt(e[t])}function ei(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:Lt(n)}if(b.context){if(b.count){b.effects||(b.effects=[]),b.effects.push(...e.slice(0,s));return}We()}for(b.effects&&(b.done||!b.count)&&(e=[...b.effects,...e],s+=b.effects.length,delete b.effects),t=0;t<s;t++)Lt(e[t])}function Nt(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===ge?n!==t&&(!n.updatedAt||n.updatedAt<Bt)&&Lt(n):r===Ct&&Nt(n,t)}}}function yn(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=Ct,s.pure?Z.push(s):de.push(s),s.observers&&yn(s))}}function et(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--)et(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)et(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 wt(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function Es(e,t=k){throw wt(e)}function Yt(e){if(typeof e=="function"&&!e.length)return Yt(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=Yt(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function ti(e,t){return function(n){let r;return pe(()=>r=Y(()=>(k.context={...k.context,[e]:n.value},gn(()=>n.children))),void 0),r}}var Jt=Symbol("fallback");function jt(e){for(let t=0;t<e.length;t++)e[t]()}function si(e,t,s={}){let n=[],r=[],a=[],i=0,l=t.length>1?[]:null;return Ke(()=>jt(a)),()=>{let c=e()||[],d=c.length,u,f;return c[gs],Y(()=>{let m,A,w,v,M,T,C,L,q;if(d===0)i!==0&&(jt(a),a=[],n=[],r=[],i=0,l&&(l=[])),s.fallback&&(n=[Jt],r[0]=Ee(j=>(a[0]=j,s.fallback())),i=1);else if(i===0){for(r=new Array(d),f=0;f<d;f++)n[f]=c[f],r[f]=Ee(E);i=d}else{for(w=new Array(d),v=new Array(d),l&&(M=new Array(d)),T=0,C=Math.min(i,d);T<C&&n[T]===c[T];T++);for(C=i-1,L=d-1;C>=T&&L>=T&&n[C]===c[L];C--,L--)w[L]=r[C],v[L]=a[C],l&&(M[L]=l[C]);for(m=new Map,A=new Array(L+1),f=L;f>=T;f--)q=c[f],u=m.get(q),A[f]=u===void 0?-1:u,m.set(q,f);for(u=T;u<=C;u++)q=n[u],f=m.get(q),f!==void 0&&f!==-1?(w[f]=r[u],v[f]=a[u],l&&(M[f]=l[u]),f=A[f],m.set(q,f)):a[u]();for(f=T;f<d;f++)f in w?(r[f]=w[f],a[f]=v[f],l&&(l[f]=M[f],l[f](f))):r[f]=Ee(E);r=r.slice(0,i=d),n=c.slice(0)}return r});function E(m){if(a[f]=m,l){const[A,w]=V(f);return l[f]=w,t(c[f],A)}return t(c[f])}}}function ni(e,t,s={}){let n=[],r=[],a=[],i=[],l=0,c;return Ke(()=>jt(a)),()=>{const d=e()||[],u=d.length;return d[gs],Y(()=>{if(u===0)return l!==0&&(jt(a),a=[],n=[],r=[],l=0,i=[]),s.fallback&&(n=[Jt],r[0]=Ee(E=>(a[0]=E,s.fallback())),l=1),r;for(n[0]===Jt&&(a[0](),a=[],n=[],r=[],l=0),c=0;c<u;c++)c<n.length&&n[c]!==d[c]?i[c](()=>d[c]):c>=n.length&&(r[c]=Ee(f));for(;c<n.length;c++)a[c]();return l=i.length=a.length=u,n=d.slice(0),r=r.slice(0,l)});function f(E){a[c]=E;const[m,A]=V(d[c]);return i[c]=A,t(m,c)}}}function ps(e,t){return Y(()=>e(t||{}))}function Tt(){return!0}var Zt={get(e,t,s){return t===bt?s:e.get(t)},has(e,t){return t===bt?!0:e.has(t)},set:Tt,deleteProperty:Tt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:Tt,deleteProperty:Tt}},ownKeys(e){return e.keys()}};function zt(e){return(e=typeof e=="function"?e():e)?e:{}}function ri(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function ys(...e){let t=!1;for(let i=0;i<e.length;i++){const l=e[i];t=t||!!l&&bt in l,e[i]=typeof l=="function"?(t=!0,$(l)):l}if(ln&&t)return new Proxy({get(i){for(let l=e.length-1;l>=0;l--){const c=zt(e[l])[i];if(c!==void 0)return c}},has(i){for(let l=e.length-1;l>=0;l--)if(i in zt(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l<e.length;l++)i.push(...Object.keys(zt(e[l])));return[...new Set(i)]}},Zt);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 d=c.length-1;d>=0;d--){const u=c[d];if(u==="__proto__"||u==="constructor")continue;const f=Object.getOwnPropertyDescriptor(l,u);if(!n[u])n[u]=f.get?{enumerable:!0,configurable:!0,get:ri.bind(s[u]=[f.get.bind(l)])}:f.value!==void 0?f:void 0;else{const E=s[u];E&&(f.get?E.push(f.get.bind(l)):f.value!==void 0&&E.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 An(e,...t){if(ln&&bt 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)}},Zt));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))}},Zt)),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 d of t)d.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 Tn(e){let t,s;const n=r=>{const a=b.context;if(a){const[l,c]=V();b.count||(b.count=0),b.count++,(s||(s=e())).then(d=>{!b.done&&We(a),b.count--,c(()=>d.default),We()}),t=l}else if(!t){const[l]=Ka(()=>(s||(s=e())).then(c=>c.default));t=l}let i;return $(()=>(i=t())?Y(()=>{if(!a||b.done)return i(r);const l=b.context;We(a);const c=i(r);return We(l),c}):"")};return n.preload=()=>s||((s=e()).then(r=>t=()=>r.default),s),n}var ai=0;function ii(){return b.context?b.getNextContextId():`cl-${ai++}`}var Sn=e=>`Stale read from <${e}>.`;function oi(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(si(()=>e.each,e.children,t||void 0))}function li(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(ni(()=>e.each,e.children,t||void 0))}function ci(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 Sn("Show");return s()})):a}return e.fallback},void 0,void 0)}function ui(e){const t=gn(()=>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],d=a,u=$(()=>d()?void 0:c.when,void 0,void 0),f=c.keyed?u:$(u,void 0,{equals:(E,m)=>!E==!m});a=()=>d()||(f()?[l,u,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 d;if(((d=Y(s)())==null?void 0:d[0])!==r)throw Sn("Match");return a()})):l},void 0,void 0)}function di(e){return e}var fi=["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"],hi=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...fi]),gi=new Set(["innerHTML","textContent","innerText","children"]),mi=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),Ei=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 pi(e,t){const s=Ei[e];return typeof s=="object"?s[t]?s.$:void 0:s}var yi=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),Ai=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"]),Ti={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},Si=e=>$(()=>e());function Pi(e,t,s){let n=s.length,r=t.length,a=n,i=0,l=0,c=t[r-1].nextSibling,d=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 u=a<n?l?s[l-1].nextSibling:s[a-l]:c;for(;l<a;)e.insertBefore(s[l++],u)}else if(a===l)for(;i<r;)(!d||!d.has(t[i]))&&t[i].remove(),i++;else if(t[i]===s[a-1]&&s[l]===t[r-1]){const u=t[--r].nextSibling;e.insertBefore(s[l++],t[i++].nextSibling),e.insertBefore(s[--a],u),t[r]=s[a]}else{if(!d){d=new Map;let f=l;for(;f<a;)d.set(s[f],f++)}const u=d.get(t[i]);if(u!=null)if(l<u&&u<a){let f=i,E=1,m;for(;++f<r&&f<a&&!((m=d.get(t[f]))==null||m!==u+E);)E++;if(E>u-l){const A=t[i];for(;l<u;)e.insertBefore(s[l++],A)}else e.replaceChild(s[l++],t[i++])}else i++;else t[i++].remove()}}}var Ze="_$DX_DELEGATE";function Pn(e,t,s,n={}){let r;return Ee(a=>{r=a,t===document?e():Gt(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function xi(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 xn(e,t=window.document){const s=t[Ze]||(t[Ze]=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,In))}}function _i(e=window.document){if(e[Ze]){for(let t of e[Ze].keys())e.removeEventListener(t,In);delete e[Ze]}}function Dt(e,t,s){we(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function wi(e,t,s,n){we(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function vi(e,t,s){we(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function _n(e,t){we(e)||(t==null?e.removeAttribute("class"):e.className=t)}function wn(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 bi(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]||(Is(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||(Is(e,l,!0),s[l]=c)}return s}function Ii(e,t,s){if(!t)return s?Dt(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 vn(e,t={},s,n){const r={};return n||pe(()=>r.children=tt(e,t.children,r.children)),pe(()=>typeof t.ref=="function"&&bn(t.ref,e)),pe(()=>Ci(e,t,s,!0,r,!0)),r}function bn(e,t,s){return Y(()=>e(t,s))}function Gt(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return tt(e,t,n,s);pe(r=>tt(e,t(),r,s),n)}function Ci(e,t,s,n,r={},a=!1){t||(t={});for(const i in r)if(!(i in t)){if(i==="children")continue;r[i]=Cs(e,i,null,r[i],s,a,t)}for(const i in t){if(i==="children")continue;const l=t[i];r[i]=Cs(e,i,l,r[i],s,a,t)}}function Li(e){let t,s;return!we()||!(t=b.registry.get(s=ji()))?e():(b.completed&&b.completed.add(t),b.registry.delete(s),t)}function we(e){return!!b.context&&!b.done&&(!e||e.isConnected)}function Ni(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Is(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 Cs(e,t,s,n,r,a,i){let l,c,d,u,f;if(t==="style")return Ii(e,s,n);if(t==="classList")return bi(e,s,n);if(s===n)return n;if(t==="ref")a||s(e);else if(t.slice(0,3)==="on:"){const E=t.slice(3);n&&e.removeEventListener(E,n,typeof n!="function"&&n),s&&e.addEventListener(E,s,typeof s!="function"&&s)}else if(t.slice(0,10)==="oncapture:"){const E=t.slice(10);n&&e.removeEventListener(E,n,!0),s&&e.addEventListener(E,s,!0)}else if(t.slice(0,2)==="on"){const E=t.slice(2).toLowerCase(),m=yi.has(E);if(!m&&n){const A=Array.isArray(n)?n[0]:n;e.removeEventListener(E,A)}(m||s)&&(wn(e,E,s,m),m&&xn([E]))}else if(t.slice(0,5)==="attr:")Dt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")vi(e,t.slice(5),s);else if((f=t.slice(0,5)==="prop:")||(d=gi.has(t))||!r&&((u=pi(t,e.tagName))||(c=hi.has(t)))||(l=e.nodeName.includes("-")||"is"in i)){if(f)t=t.slice(5),c=!0;else if(we(e))return s;t==="class"||t==="className"?_n(e,s):l&&!c&&!d?e[Ni(t)]=s:e[u||t]=s}else{const E=r&&t.indexOf(":")>-1&&Ti[t.split(":")[0]];E?wi(e,E,t,s):Dt(e,mi[t]||t,s)}return s}function In(e){if(b.registry&&b.events&&b.events.find(([c,d])=>d===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 d=t[`${s}Data`];if(d!==void 0?c.call(t,d,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}}),b.registry&&!b.done&&(b.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();a(c[0]);for(let d=0;d<c.length-2&&(t=c[d],!!i());d++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(n)}function tt(e,t,s,n,r){const a=we(e);if(a){!s&&(s=[...e.childNodes]);let c=[];for(let d=0;d<s.length;d++){const u=s[d];u.nodeType===8&&u.data.slice(0,2)==="!$"?u.remove():c.push(u)}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 pe(()=>{let c=t();for(;typeof c=="function";)c=c();s=tt(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],d=s&&Array.isArray(s);if(Xt(c,t,s,r))return pe(()=>s=tt(e,c,s,n,!0)),()=>s;if(a){if(!c.length)return s;if(n===void 0)return s=[...e.childNodes];let u=c[0];if(u.parentNode!==e)return s;const f=[u];for(;(u=u.nextSibling)!==n;)f.push(u);return s=f}if(c.length===0){if(s=ve(e,s,n),l)return s}else d?s.length===0?Ls(e,c,n):Pi(e,s,c):(s&&ve(e),Ls(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 Xt(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],d;if(!(l==null||l===!0||l===!1))if((d=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=Xt(e,l,c)||r;else if(d==="function")if(n){for(;typeof l=="function";)l=l();r=Xt(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const u=String(l);c&&c.nodeType===3&&c.data===u?e.push(c):e.push(document.createTextNode(u))}}return r}function Ls(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 ji(){return b.getNextContextId()}var Di="http://www.w3.org/2000/svg";function Cn(e,t=!1){return t?document.createElementNS(Di,e):document.createElement(e)}function Gi(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,r=bs();let a,i=!!b.context;return ms(()=>{i&&(bs().user=i=!1),a||(a=hn(r,()=>$(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,d]=V(!1),u=()=>d(!0);Ee(f=>Gt(l,()=>c()?f():a(),null)),Ke(u)}else{const c=Cn(e.isSVG?"g":"div",e.isSVG),d=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),Gt(d,a),l.appendChild(c),e.ref&&e.ref(c),Ke(()=>l.removeChild(c))}},void 0,{render:!i}),s}function ki(e,t){const s=$(e);return $(()=>{const n=s();switch(typeof n){case"function":return Y(()=>n(t));case"string":const r=Ai.has(n),a=b.context?Li():Cn(n,r);return vn(a,t,r),a}})}function Oi(e){const[,t]=An(e,["component"]);return ki(()=>e.component,t)}var Ri=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()}},Ln=class{constructor(e){this.generateIdentifier=e,this.kv=new Ri}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)}},Mi=class extends Ln{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 Ui(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 Bi(e,t){const s=Ui(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 Ve(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function vt(e,t){return e.indexOf(t)!==-1}function Ns(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var Fi=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return Bi(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},qi=e=>Object.prototype.toString.call(e).slice(8,-1),Nn=e=>typeof e>"u",Ki=e=>e===null,st=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,es=e=>st(e)&&Object.keys(e).length===0,ye=e=>Array.isArray(e),Vi=e=>typeof e=="string",Hi=e=>typeof e=="number"&&!isNaN(e),Qi=e=>typeof e=="boolean",zi=e=>e instanceof RegExp,nt=e=>e instanceof Map,rt=e=>e instanceof Set,jn=e=>qi(e)==="Symbol",$i=e=>e instanceof Date&&!isNaN(e.valueOf()),Wi=e=>e instanceof Error,js=e=>typeof e=="number"&&isNaN(e),Yi=e=>Qi(e)||Ki(e)||Nn(e)||Hi(e)||Vi(e)||jn(e),Ji=e=>typeof e=="bigint",Zi=e=>e===1/0||e===-1/0,Xi=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),eo=e=>e instanceof URL,Dn=e=>e.replace(/\./g,"\\."),$t=e=>e.map(String).map(Dn).join("."),Xe=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 ie(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var Gn=[ie(Nn,"undefined",()=>null,()=>{}),ie(Ji,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),ie($i,"Date",e=>e.toISOString(),e=>new Date(e)),ie(Wi,"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}),ie(zi,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),ie(rt,"set",e=>[...e.values()],e=>new Set(e)),ie(nt,"map",e=>[...e.entries()],e=>new Map(e)),ie(e=>js(e)||Zi(e),"number",e=>js(e)?"NaN":e>0?"Infinity":"-Infinity",Number),ie(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),ie(eo,"URL",e=>e.toString(),e=>new URL(e))];function qt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var kn=qt((e,t)=>jn(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}),to=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),On=qt(Xi,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=to[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function Rn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var Mn=qt(Rn,(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)}),Un=qt((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)}),so=[Mn,kn,Un,On],Ds=(e,t)=>{const s=Ns(so,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=Ns(Gn,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},Bn={};Gn.forEach(e=>{Bn[e.annotation]=e});var no=(e,t,s)=>{if(ye(t))switch(t[0]){case"symbol":return kn.untransform(e,t,s);case"class":return Mn.untransform(e,t,s);case"custom":return Un.untransform(e,t,s);case"typed-array":return On.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=Bn[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},be=(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 Fn(e){if(vt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(vt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(vt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var ro=(e,t)=>{Fn(t);for(let s=0;s<t.length;s++){const n=t[s];if(rt(e))e=be(e,+n);else if(nt(e)){const r=+n,a=+t[++s]==0?"key":"value",i=be(e,r);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},ts=(e,t,s)=>{if(Fn(t),t.length===0)return s(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(ye(n)){const l=+i;n=n[l]}else if(st(n))n=n[i];else if(rt(n)){const l=+i;n=be(n,l)}else if(nt(n)){if(a===t.length-2)break;const c=+i,d=+t[++a]==0?"key":"value",u=be(n,c);switch(d){case"key":n=u;break;case"value":n=n.get(u);break}}}const r=t[t.length-1];if(ye(n)?n[+r]=s(n[+r]):st(n)&&(n[r]=s(n[r])),rt(n)){const a=be(n,+r),i=s(a);a!==i&&(n.delete(a),n.add(i))}if(nt(n)){const a=+t[t.length-2],i=be(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 ss(e,t,s=[]){if(!e)return;if(!ye(e)){Ve(e,(a,i)=>ss(a,t,[...s,...Xe(i)]));return}const[n,r]=e;r&&Ve(r,(a,i)=>{ss(a,t,[...s,...Xe(i)])}),t(n,s)}function ao(e,t,s){return ss(t,(n,r)=>{e=ts(e,r,a=>no(a,n,s))}),e}function io(e,t){function s(n,r){const a=ro(e,Xe(r));n.map(Xe).forEach(i=>{e=ts(e,i,()=>a)})}if(ye(t)){const[n,r]=t;n.forEach(a=>{e=ts(e,Xe(a),()=>e)}),r&&Ve(r,s)}else Ve(t,s);return e}var oo=(e,t)=>st(e)||ye(e)||nt(e)||rt(e)||Rn(e,t);function lo(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function co(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($t):s[$t(a)]=i.map($t)}),n?es(s)?[n]:[n,s]:es(s)?void 0:s}var qn=(e,t,s,n,r=[],a=[],i=new Map)=>{const l=Yi(e);if(!l){lo(e,r,t);const m=i.get(e);if(m)return n?{transformedValue:null}:m}if(!oo(e,s)){const m=Ds(e,s),A=m?{transformedValue:m.value,annotations:[m.type]}:{transformedValue:e};return l||i.set(e,A),A}if(vt(a,e))return{transformedValue:null};const c=Ds(e,s),d=(c==null?void 0:c.value)??e,u=ye(d)?[]:{},f={};Ve(d,(m,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 w=qn(m,t,s,n,[...r,A],[...a,e],i);u[A]=w.transformedValue,ye(w.annotations)?f[A]=w.annotations:st(w.annotations)&&Ve(w.annotations,(v,M)=>{f[Dn(A)+"."+M]=v})});const E=es(f)?{transformedValue:u,annotations:c?[c.type]:void 0}:{transformedValue:u,annotations:c?[c.type,f]:f};return l||i.set(e,E),E};function Kn(e){return Object.prototype.toString.call(e).slice(8,-1)}function Gs(e){return Kn(e)==="Array"}function uo(e){if(Kn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function fo(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 ns(e,t={}){if(Gs(e))return e.map(r=>ns(r,t));if(!uo(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,a)=>{if(Gs(t.props)&&!t.props.includes(a))return r;const i=e[a],l=ns(i,t);return fo(r,a,l,e,t.nonenumerable),r},{})}var B=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Mi,this.symbolRegistry=new Ln(t=>t.description??""),this.customTransformerRegistry=new Fi,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=qn(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const r=co(t,this.dedupe);return r&&(n.meta={...n.meta,referentialEqualities:r}),n}deserialize(e){const{json:t,meta:s}=e;let n=ns(t);return s!=null&&s.values&&(n=ao(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=io(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)}};B.defaultInstance=new B;B.serialize=B.defaultInstance.serialize.bind(B.defaultInstance);B.deserialize=B.defaultInstance.deserialize.bind(B.defaultInstance);B.stringify=B.defaultInstance.stringify.bind(B.defaultInstance);B.parse=B.defaultInstance.parse.bind(B.defaultInstance);B.registerClass=B.defaultInstance.registerClass.bind(B.defaultInstance);B.registerSymbol=B.defaultInstance.registerSymbol.bind(B.defaultInstance);B.registerCustom=B.defaultInstance.registerCustom.bind(B.defaultInstance);B.allowErrorProps=B.defaultInstance.allowErrorProps.bind(B.defaultInstance);var Vn=B.serialize,ho=B.stringify;function go(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function mo(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function Eo({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function po({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function yo(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var Ao=(e,t=!1)=>{const{json:s}=Vn(e);return JSON.stringify(s,null,t?2:void 0)},St=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,To=(e,t)=>e.queryHash.localeCompare(t.queryHash),Hn=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,So=(e,t)=>St(e)===St(t)?Hn(e,t):St(e)>St(t)?1:-1,Po={status:So,"query hash":To,"last updated":Hn},Pt=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,Qn=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,xo=(e,t)=>Pt(e)===Pt(t)?Qn(e,t):Pt(e)>Pt(t)?1:-1,_o={status:xo,"last updated":Qn},wo=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),vo=()=>{const[e,t]=V("dark");return fn(()=>{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),Ke(()=>s.removeEventListener("change",n))}),e},Ye=(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,Ye(n.get(r),a,s)),n}if(e instanceof Set){const n=Ye(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]=Ye(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]=Ye(n[r],a,s),n}return e},Je=(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,Je(s.get(n),r)),s}if(e instanceof Set){const s=Je(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]=Je(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]=Je(s[n],r),s}return e},zn=(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)},Ie,at,it,ot,Pe,lt,Ce,Le,Ne,je,De,ct,Ge,ut,Rs,bo=(Rs=class{constructor(e){R(this,Ie);R(this,at);R(this,it);R(this,ot);R(this,Pe,!1);R(this,lt);R(this,Ce);R(this,Le);R(this,Ne);R(this,je);R(this,De);R(this,ct);R(this,Ge);R(this,ut);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:u,hideDisabledQueries:f}=e;O(this,Ie,V(t)),O(this,it,s),O(this,ot,n),O(this,at,r),O(this,lt,d),O(this,Ce,u),O(this,Le,V(a)),O(this,Ne,V(i)),O(this,je,V(l)),O(this,De,V(c)),O(this,ct,V(f))}setButtonPosition(e){x(this,Le)[1](e)}setPosition(e){x(this,Ne)[1](e)}setInitialIsOpen(e){x(this,je)[1](e)}setErrorTypes(e){x(this,De)[1](e)}setClient(e){x(this,Ie)[1](e)}mount(e){if(x(this,Pe))throw new Error("Devtools is already mounted");const t=Pn(()=>{const s=this,[n]=x(this,Le),[r]=x(this,Ne),[a]=x(this,je),[i]=x(this,De),[l]=x(this,ct),[c]=x(this,Ie);let d;return x(this,Ge)?d=x(this,Ge):(d=Tn(()=>Promise.resolve().then(()=>require("./NCMVHL6D-taGMv4he.cjs"))),O(this,Ge,d)),zn(x(this,lt),x(this,Ce)),ps(d,ys({get queryFlavor(){return x(s,it)},get version(){return x(s,ot)},get onlineManager(){return x(s,at)},get shadowDOMTarget(){return x(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);O(this,Pe,!0),O(this,ut,t)}unmount(){var e;if(!x(this,Pe))throw new Error("Devtools is not mounted");(e=x(this,ut))==null||e.call(this),O(this,Pe,!1)}},Ie=new WeakMap,at=new WeakMap,it=new WeakMap,ot=new WeakMap,Pe=new WeakMap,lt=new WeakMap,Ce=new WeakMap,Le=new WeakMap,Ne=new WeakMap,je=new WeakMap,De=new WeakMap,ct=new WeakMap,Ge=new WeakMap,ut=new WeakMap,Rs),ke,dt,ft,ht,xe,gt,Oe,Re,Me,Ue,Be,mt,Fe,qe,Et,Ms,Io=(Ms=class{constructor(e){R(this,ke);R(this,dt);R(this,ft);R(this,ht);R(this,xe,!1);R(this,gt);R(this,Oe);R(this,Re);R(this,Me);R(this,Ue);R(this,Be);R(this,mt);R(this,Fe);R(this,qe);R(this,Et);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:u,onClose:f,hideDisabledQueries:E}=e;O(this,ke,V(t)),O(this,ft,s),O(this,ht,n),O(this,dt,r),O(this,gt,d),O(this,Oe,u),O(this,Re,V(a)),O(this,Me,V(i)),O(this,Ue,V(l)),O(this,Be,V(c)),O(this,mt,V(E)),O(this,Fe,V(f))}setButtonPosition(e){x(this,Re)[1](e)}setPosition(e){x(this,Me)[1](e)}setInitialIsOpen(e){x(this,Ue)[1](e)}setErrorTypes(e){x(this,Be)[1](e)}setClient(e){x(this,ke)[1](e)}setOnClose(e){x(this,Fe)[1](()=>e)}mount(e){if(x(this,xe))throw new Error("Devtools is already mounted");const t=Pn(()=>{const s=this,[n]=x(this,Re),[r]=x(this,Me),[a]=x(this,Ue),[i]=x(this,Be),[l]=x(this,mt),[c]=x(this,ke),[d]=x(this,Fe);let u;return x(this,qe)?u=x(this,qe):(u=Tn(()=>Promise.resolve().then(()=>require("./2AITGKQY-UndKMj-X.cjs"))),O(this,qe,u)),zn(x(this,gt),x(this,Oe)),ps(u,ys({get queryFlavor(){return x(s,ft)},get version(){return x(s,ht)},get onlineManager(){return x(s,dt)},get shadowDOMTarget(){return x(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 d()}}))},e);O(this,xe,!0),O(this,Et,t)}unmount(){var e;if(!x(this,xe))throw new Error("Devtools is not mounted");(e=x(this,Et))==null||e.call(this),O(this,xe,!1)}},ke=new WeakMap,dt=new WeakMap,ft=new WeakMap,ht=new WeakMap,xe=new WeakMap,gt=new WeakMap,Oe=new WeakMap,Re=new WeakMap,Me=new WeakMap,Ue=new WeakMap,Be=new WeakMap,mt=new WeakMap,Fe=new WeakMap,qe=new WeakMap,Et=new WeakMap,Ms);function Co(e){const t=S.useQueryClient(e.client),s=z.useRef(null),{buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d}=e,[u]=z.useState(new bo({client:t,queryFlavor:"React Query",version:"5",onlineManager:S.onlineManager,buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d}));return z.useEffect(()=>{u.setClient(t)},[t,u]),z.useEffect(()=>{n&&u.setButtonPosition(n)},[n,u]),z.useEffect(()=>{r&&u.setPosition(r)},[r,u]),z.useEffect(()=>{u.setInitialIsOpen(a||!1)},[a,u]),z.useEffect(()=>{u.setErrorTypes(i||[])},[i,u]),z.useEffect(()=>(s.current&&u.mount(s.current),()=>{u.unmount()}),[u]),o.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:s})}function Lo(e){const t=S.useQueryClient(e.client),s=z.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:i}=e,[l]=z.useState(new Io({client:t,queryFlavor:"React Query",version:"5",onlineManager:S.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 ks=process.env.NODE_ENV!=="development"?function(){return null}:Co;process.env.NODE_ENV;const $n=H.atom(""),No=()=>{P.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),P.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"}),P.registerChaiFeatureFlag("enable-ai-chat-panel",{description:"Enable AI chat panel"})},jo=()=>{const e=G(),t=N();return S.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},Do=()=>{const{data:e}=te(),{data:t}=fe(),{data:s}=Te(),n=G(),r=N(),a=h.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]),i=h.useRef(new Map);return S.useMutation({mutationFn:async({block:l})=>{const c=l._id,d=(t==null?void 0:t.lang)||a,u=`${c}:${d}`;if(i.current.has(u))return i.current.get(u);const f=r(n,{action:y.GET_BLOCK_ASYNC_PROPS,data:{block:l,lang:d,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(u,f),f.finally(()=>{i.current.delete(u)}),f}})},Wn=()=>{const[,e]=le();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])},Yn=()=>{const e=Wn();return h.useCallback(({pageId:t})=>{e(t)},[e])},Go=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-0qEG4sLX.cjs"))),ko=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-dialog-CctilPnb.cjs"))),Oo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-CF1Lyc5K.cjs"))),Ro=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-C06RQn4k.cjs"))),Mo=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-DmO4-lci.cjs"))),Uo=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-D4KdtUYp.cjs")));No();nr.loadWebBlocks();P.registerChaiTopBar(ha);Ua();P.registerChaiMediaManager(Oo);P.registerChaiSaveToLibrary(Ro);const Bo={role:"",permissions:null},Os=e=>{const{data:t}=_a(),s=Mt(),{data:n=Bo,isFetching:r}=tn(),{data:a,isFetching:i}=he(),{data:l,isFetching:c}=jo(),{data:d,isFetching:u}=Te(),f=r||i||c||u,[E]=le(),m=E.get("page"),{data:A}=te(),{data:w,isFetching:v}=pa(),{blocks:M}=Ea(w),{data:T,isFetching:C}=Xs(),{pageStatus:L}=ae(),q=ga(),{onSave:j}=wa(),{mutateAsync:ce}=Do(),{getPartialBlocks:ue,getPartialBlockBlocks:K}=va(),{mutateAsync:I}=Or(),{mutateAsync:D}=en(),W=Yn(),[Q,re]=h.useState(!1),Qe=h.useRef([]),me=h.useMemo(()=>p.get(d,"theme",{})||{},[d]),ze=L===J.EDITING,Se=L===J.CHECKING,As=v||Se||C;Qe.current=M;const[Xn]=H.useAtom($n);h.useEffect(()=>{const ee=()=>{document.hidden?re(!0):re(!1)};return window.addEventListener("visibilitychange",ee),()=>window.removeEventListener("visibilitychange",ee)},[]);const er=h.useMemo(()=>{const ee={};return n&&(ee.permissions=p.get(n,"permissions",null),ee.role=p.get(n,"role","user")),ee},[n]),Ts=h.useMemo(()=>t==null?void 0:t.some(ee=>ee.isSiteLibrary),[t]),tr=h.useCallback(async(ee,At)=>await I({pageType:ee,query:At}),[I]);return o.jsxs(o.Fragment,{children:[As&&o.jsx(hs,{className:f?"fixed inset-0 bg-white":"bg-white/75",children:o.jsx(_.Loader,{className:`animate-spin text-primary ${f?"h-6 w-6":"h-5 w-5"}`})}),Xn&&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(_.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:o.jsx(Uo,{})}),o.jsx(P.ChaiBuilderEditor,{flags:e.flags?{...e.flags,librarySite:Ts}:{librarySite:Ts},gotoPage:W,collections:l??[],getBlockAsyncProps:ce,pageExternalData:T,themePresets:e.themePresets??[],pageId:A==null?void 0:A.id,loading:v,fallbackLang:s,languages:(d==null?void 0:d.languages)||[],brandingOptions:(d==null?void 0:d.theme)||{},designTokens:(d==null?void 0:d.designTokens)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!Q&&ze&&(e.autoSave??!0),autoSaveInterval:e.autoSaveInterval??15,onError:e.onError||console.error,getPartialBlockBlocks:K,getPartialBlocks:ue,blocks:v?[]:M,theme:p.cloneDeep(me),pageTypes:a,searchPageTypeItems:tr,askAiCallBack:q,onSave:async({blocks:ee,theme:At,needTranslations:sr,designTokens:Ss})=>{if(!m)return!0;Qe.current=ee;const Ps=[...ee];await j({page:m,blocks:Ps,needTranslations:sr}),Qe.current=Ps;const Kt={};return p.isEqual(At,me)||(Kt.theme=At),p.isEqual(Ss,d==null?void 0:d.designTokens)||(Kt.designTokens=Ss),await D({settings:Kt}),!0},themePanelComponent:Mo,...er,children:o.jsx(Go,{isFetchingPageData:As})}),o.jsx("div",{children:o.jsx(ko,{})})]})},Fo=new S.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),qo=e=>{const[,t]=kt(),[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(Os,{...e}),o.jsx(ks,{})]}):o.jsxs(S.QueryClientProvider,{client:Fo,children:[o.jsx(Os,{...e}),o.jsx(ks,{})]}):o.jsx("div",{})},Ko=z.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-D_iF9Sm3.cjs")));function Jn({data:e,onSelect:t,dataType:s="value",disabled:n=!1}){const[r,a]=z.useState(!1);return o.jsxs(g.Popover,{open:r,onOpenChange:a,children:[o.jsxs(g.Tooltip,{children:[o.jsx(g.TooltipTrigger,{asChild:!0,children:o.jsx(g.PopoverTrigger,{asChild:!0,children:o.jsx(g.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(g.TooltipContent,{children:"Add field"})]}),r&&o.jsx(z.Suspense,{children:o.jsx(Ko,{data:e,onSelect:t,dataType:s,open:r,setOpen:a})})]})}const Vo=()=>{const{savePageAsync:e}=P.useSavePage(),t=S.useQueryClient(),{isLocked:s}=ae();return h.useCallback(async()=>{s||await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t,s])},Ho=()=>{const e=S.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},Qo=()=>{const e=G(),t=N(),{data:s}=fe(),n=S.useQueryClient();return S.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")}})},zo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-CF1Lyc5K.cjs"))),$o=({assetId:e,assetUrl:t,onChange:s,className:n="",placeholder:r="Select an image",disabled:a=!1})=>{const{t:i}=P.useTranslation(),[l,c]=h.useState(!1),d=()=>{a||c(!0)},u=()=>{c(!1)},f=A=>{const w=Array.isArray(A)?A[0]:A;w!=null&&w.url&&s(p.pick(w,["url","id"])),c(!1)},E=()=>{s({url:"",id:""})},m=(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:[m?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:d,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(g.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white text-red-500",onClick:E,disabled:a,children:m?o.jsx(_.X,{className:"h-4 w-4"}):o.jsx(_.Trash2,{className:"h-4 w-4"})}),!m&&o.jsx(g.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white/80 hover:bg-white/90",onClick:d,disabled:a,children:o.jsx(_.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:d,children:o.jsxs("div",{className:"flex flex-col items-center gap-2",children:[o.jsx(_.ImageIcon,{className:"h-10 w-10 text-gray-400"}),o.jsx("p",{className:"text-sm text-gray-500",children:r})]})}),o.jsx(g.Dialog,{open:l,onOpenChange:c,children:o.jsxs(g.DialogContent,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[o.jsxs(g.DialogHeader,{className:"hidden border-b px-4 py-2",children:[o.jsx(g.DialogTitle,{children:i("Select Image")}),o.jsx(g.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:u,children:o.jsx(_.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"h-full flex-1 p-4",children:o.jsx(h.Suspense,{children:o.jsx(zo,{close:u,onSelect:f,mode:"image",assetId:e})})})]})})]})},Wo=h.createContext(null),Wt={didCatch:!1,error:null};class Zn extends h.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Wt}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(Wt)}}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&&Yo(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(Wt)}}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(Wo.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},l)}}function Yo(){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 Jo=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),rs=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 d,u;if(c!==void 0){const f=n.substring(0,c).split(`
2
+ `);d=f.length,u=f[f.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:i.message,line:d,column:u,position:c}}}},Zo=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const i=`"__placeholder_${a}__"`,l=new RegExp(Jo(i),"g");n=n.replace(l,r)}),n},Xo=(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},el=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-BP2l89h2.cjs"))),tl=({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:d,copyJsonLDFromDefaultPage:u})=>{const[f,E]=h.useState("edit"),[m,A]=h.useState(null),[w,v]=h.useState(""),M=h.useRef(null),[T]=kt(),C=i==="jsonLD"&&p.get(T,"features.sharedJsonLD",!1),L=i==="jsonLD"&&!d&&!!u;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const q=K=>{if(n)return;const I=K.target.value;t(I)},j=K=>{if(K.key==="Tab"){K.preventDefault();const I=K.currentTarget,D=I.selectionStart,W=I.selectionEnd;if(D!==W){const re=e.substring(D,W).split(`
3
+ `);if(K.shiftKey){const me=re.map(Se=>Se.startsWith(" ")?Se.substring(2):Se).join(`
4
+ `),ze=e.substring(0,D)+me+e.substring(W);t(ze),setTimeout(()=>{I.selectionStart=D,I.selectionEnd=D+me.length},0)}else{const me=re.map(Se=>` ${Se}`).join(`
5
+ `),ze=e.substring(0,D)+me+e.substring(W);t(ze),setTimeout(()=>{I.selectionStart=D,I.selectionEnd=D+me.length},0)}}else{const Q=e.substring(0,D)+" "+e.substring(W);t(Q),setTimeout(()=>{I.selectionStart=I.selectionEnd=D+2},0)}}};h.useEffect(()=>{const K=rs(e);if(K.isValid)if(A(null),K.parsed){const I=Xo(K.parsed,l);v(I)}else v("");else A(K.error),v("")},[e,l]);const ce=()=>{const K=rs(e);if(K.isValid&&K.parsed){const I=Zo(K.parsed,K.placeholders);t(I)}},ue=()=>{m!=null&&m.position&&M.current&&(M.current.focus(),M.current.setSelectionRange(m.position,m.position+1))};return o.jsx(Zn,{fallback:o.jsx("div",{children:"Some error"}),children:o.jsx("div",{className:"space-y-2",children:o.jsxs(g.Tabs,{value:f,onValueChange:E,className:"w-full",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsxs(g.TabsList,{className:"w-max",children:[o.jsxs(g.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[o.jsx(_.Code,{className:"h-4 w-4"}),o.jsx("span",{children:"Edit"})]}),o.jsxs(g.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!e.trim()||m!==null||L,children:[o.jsx(_.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),C&&o.jsxs(g.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||m!==null,children:[o.jsx(_.Share2,{className:"h-4 w-4"}),o.jsx("span",{children:"Shared"})]})]}),L?null:f==="edit"&&!n&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(Jn,{dataType:"value",data:l??{},onSelect:K=>c&&c(K,i)})})]}),o.jsxs(g.TabsContent,{value:"edit",className:"relative mt-0",children:[!L&&f==="edit"&&o.jsx(Ut,{content:"Format JSON",side:"right",showTooltip:!s&&!m,children:o.jsx(g.Button,{type:"button",variant:"outline",size:"icon",onClick:ce,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||s||m!==null,children:o.jsx(_.FileCode2,{})})}),L?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(g.Button,{type:"button",variant:"default",size:"sm",onClick:u,children:[o.jsx(_.Plus,{}),"Copy & Edit from default language"]})]})}):o.jsx(g.Textarea,{ref:M,id:i,name:i,className:`rounded-md border border-input text-xs ${m?"border-red-500":""}`,onChange:q,onKeyDown:j,value:e,placeholder:r,rows:a,disabled:s,readOnly:n}),m&&o.jsxs(g.Alert,{variant:"destructive",className:"mt-2",children:[o.jsx(_.AlertTriangle,{className:"h-4 w-4"}),o.jsxs(g.AlertDescription,{className:"flex flex-col",children:[o.jsx("span",{className:"font-medium",children:"Invalid JSON"}),o.jsx("span",{className:"text-sm",children:m.message}),m.line&&m.column&&o.jsxs("span",{className:"text-sm",children:["Error at line ",m.line,", column ",m.column]}),o.jsx(g.Button,{type:"button",variant:"link",size:"sm",className:"mt-1 h-auto self-start p-0 text-sm",onClick:ue,children:"Show position"})]})]})]}),o.jsxs(g.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(g.Textarea,{rows:a,value:w,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."})]}),C&&o.jsx(g.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(h.Suspense,{children:o.jsx(el,{})})})]})})})},sl=e=>{const t=Bs(),s=N();return S.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"})};if(typeof window>"u")throw new Error("@chaibuilder/pages is not available on the server");exports.$TRACK=gs;exports.ACTIONS=y;exports.BlurContainer=hs;exports.ChaiBuilderPages=qo;exports.Dynamic=Oi;exports.EVENT=X;exports.ErrorBoundary=Zn;exports.For=oi;exports.ImagePicker=$o;exports.Index=li;exports.LANGUAGES=$e;exports.LanguageSwitcher=$s;exports.Match=di;exports.NestedPathSelector=Jn;exports.PAGES_PERMISSIONS=se;exports.PAGE_STATUS=J;exports.PageActionsDropdown=Js;exports.PermissionChecker=xt;exports.Portal=Gi;exports.Show=ci;exports.SmartJsonInput=tl;exports.Switch=ui;exports.Tooltip=Ut;exports.addEventListener=wn;exports.addNewLangAtom=Ot;exports.batch=Va;exports.className=_n;exports.clearDelegatedEvents=_i;exports.convertRemToPixels=wo;exports.createComponent=ps;exports.createComputed=dn;exports.createContext=Wa;exports.createEffect=ms;exports.createMemo=$;exports.createRenderEffect=pe;exports.createRoot=Ee;exports.createSignal=V;exports.createUniqueId=ii;exports.delegateEvents=xn;exports.deleteNestedDataByPath=Je;exports.displayValue=Ao;exports.getMutationStatusColor=po;exports.getPreferredColorScheme=vo;exports.getQueryStatusColor=Eo;exports.getQueryStatusColorByLabel=yo;exports.getQueryStatusLabel=go;exports.getSidedProp=mo;exports.insert=Gt;exports.memo=Si;exports.mergeProps=ys;exports.mutationSortFns=_o;exports.navigateToPage=os;exports.on=Ha;exports.onCleanup=Ke;exports.onMount=fn;exports.parseJSONWithPlaceholders=rs;exports.previewUrlAtom=$n;exports.serialize=Vn;exports.setAttribute=Dt;exports.sortFns=Po;exports.splitProps=An;exports.spread=vn;exports.stringify=ho;exports.template=xi;exports.throwConfetti=_t;exports.untrack=Y;exports.updateNestedDataByPath=Ye;exports.use=bn;exports.useActivePage=fe;exports.useAddGlobalSchema=ya;exports.useApiUrl=G;exports.useApplySchemaToAllPages=Pa;exports.useAssetsApiUrl=ir;exports.useBuilderFetch=lr;exports.useBuilderPageData=Xs;exports.useChaiAuth=Rt;exports.useChaiUserInfo=sl;exports.useChaibuilderRealtime=vr;exports.useChangePage=Wn;exports.useChangeSlug=Kr;exports.useClearAll=Ho;exports.useContext=Ya;exports.useCreatePage=Rr;exports.useCurrentPage=te;exports.useCurrentPageOwner=Hs;exports.useDeleteGlobalSchema=Ta;exports.useDeletePage=Ur;exports.useDynamicPageSelector=Ks;exports.useFallbackLang=Mt;exports.useFetch=N;exports.useGotoPage=Yn;exports.useIsLanguagePageCreated=Ys;exports.useLanguagePages=Ae;exports.useMarkAsTemplate=Fr;exports.usePageEditInfo=is;exports.usePageLockMeta=cs;exports.usePageLockStatus=ae;exports.usePageToUser=ls;exports.usePageType=Ws;exports.usePageTypes=he;exports.usePagesProps=kt;exports.usePublishPages=fs;exports.useReloadPage=Vo;exports.useRemoveSchemaFromAllPages=xa;exports.useSearchParams=le;exports.useSendRealtimeEvent=Qs;exports.useTogglePageGlobalSchema=Sa;exports.useTransition=$a;exports.useUnmarkAsTemplate=qr;exports.useUnpublishPage=Br;exports.useUpdateActivePageMetadata=Qo;exports.useUpdateGlobalSchema=Aa;exports.useUpdatePage=Mr;exports.useUpdateWebsiteSettings=en;exports.useUserId=pt;exports.useUserRoleAndPermissions=tn;exports.useWebsiteLanguagePages=br;exports.useWebsitePages=ds;exports.useWebsiteSetting=Te;