@chaibuilder/pages 0.15.5 → 0.15.6

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 (96) hide show
  1. package/dist/{2AITGKQY-D4uLyw6-.cjs → 2AITGKQY-BnzAO102.cjs} +1 -1
  2. package/dist/{2AITGKQY-DYwNjBFe.js → 2AITGKQY-tXLat8E2.js} +2 -2
  3. package/dist/{NCMVHL6D-DVB60g_2.js → NCMVHL6D-BwDANa-N.js} +2 -2
  4. package/dist/{NCMVHL6D-C-L7-X3f.cjs → NCMVHL6D-DooF4Fqf.cjs} +1 -1
  5. package/dist/{ZDWCUMSJ-Dp6ML_tn.js → ZDWCUMSJ-DWeYRRkj.js} +1 -1
  6. package/dist/{ZDWCUMSJ-BORULBXb.cjs → ZDWCUMSJ-DiH9kc7o.cjs} +1 -1
  7. package/dist/add-new-language-page-BCUrfgTy.cjs +1 -0
  8. package/dist/add-new-language-page-DZhjVBBf.js +401 -0
  9. package/dist/add-new-page-DWHANcUx.cjs +1 -0
  10. package/dist/add-new-page-DYuuentN.js +31 -0
  11. package/dist/delete-page-1dSWwUBg.js +40 -0
  12. package/dist/delete-page-m-Cuz7rG.cjs +1 -0
  13. package/dist/digital-asset-manager-BWZlrwFf.js +913 -0
  14. package/dist/digital-asset-manager-By_JTIbb.cjs +1 -0
  15. package/dist/duplicate-page-Dzs8ya8l.cjs +1 -0
  16. package/dist/duplicate-page-fUuBTAs7.js +133 -0
  17. package/dist/{dynamic-page-selector-Cz6zWaKo.cjs → dynamic-page-selector-CwhL4z6F.cjs} +1 -1
  18. package/dist/{dynamic-page-selector-8g1-84iW.js → dynamic-page-selector-X2qgdiNQ.js} +1 -1
  19. package/dist/image-editor-CeSSNbFY.js +108 -0
  20. package/dist/image-editor-CnDnY97s.cjs +1 -0
  21. package/dist/index-0cMGDekp.cjs +5 -0
  22. package/dist/{index-zaGKeGBW.js → index-Bk8tPO5R.js} +1168 -1219
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +10 -10
  25. package/dist/{json-diff-viewer-c3ft4c4A.cjs → json-diff-viewer-Cfa9BjZ6.cjs} +1 -1
  26. package/dist/{json-diff-viewer-BF0qFBif.js → json-diff-viewer-Cm84g19X.js} +1 -1
  27. package/dist/lang-panel-CaSKOJ8G.js +225 -0
  28. package/dist/lang-panel-CkSfJqr8.cjs +1 -0
  29. package/dist/mark-as-template-Ci82hbOm.cjs +1 -0
  30. package/dist/mark-as-template-CwsW86Zv.js +153 -0
  31. package/dist/no-language-page-content-CPt4aPy9.cjs +1 -0
  32. package/dist/no-language-page-content-DDz81nqg.js +42 -0
  33. package/dist/{page-creator-CsZpQ7Gy.cjs → page-creator-Cd2LrG4u.cjs} +1 -1
  34. package/dist/{page-creator-Crc5BzeB.js → page-creator-Dr566_Yf.js} +2 -2
  35. package/dist/page-lock-request-Bw_Wye1t.cjs +1 -0
  36. package/dist/page-lock-request-ECxkQMdS.js +75 -0
  37. package/dist/page-locked-by-dialog-AbutJT_V.cjs +1 -0
  38. package/dist/page-locked-by-dialog-CnkVUpjt.js +68 -0
  39. package/dist/page-manager-new-DLMvOata.cjs +1 -0
  40. package/dist/page-manager-new-DkqNLZ5C.js +354 -0
  41. package/dist/page-manager-search-and-filter-B98nz9xS.js +201 -0
  42. package/dist/page-manager-search-and-filter-CfEfWFeo.cjs +1 -0
  43. package/dist/{page-revisions-content-PRgwV04S.js → page-revisions-content-CBQPYFZI.js} +18 -18
  44. package/dist/{page-revisions-content-dSFvGFEO.cjs → page-revisions-content-D12GEp8C.cjs} +1 -1
  45. package/dist/{publish-pages-content-C24iBibw.js → publish-pages-content-BF5yMo_L.js} +6 -6
  46. package/dist/{publish-pages-content-akIgltlm.cjs → publish-pages-content-LNCr9tKv.cjs} +1 -1
  47. package/dist/{save-to-lib-C3H1ZPb-.cjs → save-to-lib-C1B6tWEF.cjs} +1 -1
  48. package/dist/{save-to-lib-DSPvtFSd.js → save-to-lib-SpilaoOL.js} +1 -1
  49. package/dist/{seo-panel-Ce6aTIyt.cjs → seo-panel-DkgkJUT6.cjs} +1 -1
  50. package/dist/{seo-panel-rZ8s88c0.js → seo-panel-sbYoo746.js} +17 -17
  51. package/dist/{shared-json-ld-hCiviuBf.cjs → shared-json-ld-CEUgLAev.cjs} +1 -1
  52. package/dist/{shared-json-ld-DMYOwp6B.js → shared-json-ld-D_YyVPk3.js} +27 -27
  53. package/dist/{slug-input-BN8eQgxP.cjs → slug-input-Cqj9EBju.cjs} +1 -1
  54. package/dist/{slug-input-Dhzaobv6.js → slug-input-Df-BG6xl.js} +1 -1
  55. package/dist/theme-panel-footer-B6leVWSV.js +25 -0
  56. package/dist/theme-panel-footer-Ca1UF5DA.cjs +1 -0
  57. package/dist/unmark-as-template-BOE-nKOb.cjs +1 -0
  58. package/dist/unmark-as-template-Cho9B4RN.js +39 -0
  59. package/dist/unpublish-page-BcxxZ8pr.cjs +1 -0
  60. package/dist/unpublish-page-Dr4qbwUx.js +27 -0
  61. package/dist/{web-preview-BEyjKFDL.js → web-preview-Cq82TNaS.js} +1 -1
  62. package/dist/{web-preview-TTKtpSUi.cjs → web-preview-ued-fdxs.cjs} +1 -1
  63. package/package.json +3 -3
  64. package/dist/add-new-language-page-D4VPifNs.cjs +0 -1
  65. package/dist/add-new-language-page-DENCjC_f.js +0 -390
  66. package/dist/add-new-page-BuK6We-q.cjs +0 -1
  67. package/dist/add-new-page-CD-9ppdS.js +0 -30
  68. package/dist/delete-page-B-TP6nJ7.cjs +0 -1
  69. package/dist/delete-page-CatRlDfx.js +0 -38
  70. package/dist/digital-asset-manager-DL2nAqUC.cjs +0 -1
  71. package/dist/digital-asset-manager-KakxBkBC.js +0 -917
  72. package/dist/duplicate-page-D4Oiy71Q.cjs +0 -1
  73. package/dist/duplicate-page-DEmh0df0.js +0 -120
  74. package/dist/image-editor-D9MPdtxC.js +0 -107
  75. package/dist/image-editor-Da6lrqkL.cjs +0 -1
  76. package/dist/index-Blg1T7nL.cjs +0 -5
  77. package/dist/lang-panel-D1FKTNui.js +0 -218
  78. package/dist/lang-panel-ExS97Zgk.cjs +0 -1
  79. package/dist/mark-as-template-CcnkROAU.cjs +0 -1
  80. package/dist/mark-as-template-v-I05xcZ.js +0 -146
  81. package/dist/no-language-page-content-Bm5CcsUo.js +0 -35
  82. package/dist/no-language-page-content-Ddz2hnYs.cjs +0 -1
  83. package/dist/page-lock-request-Dx6OrOwM.cjs +0 -1
  84. package/dist/page-lock-request-WKfG7Sd3.js +0 -64
  85. package/dist/page-locked-by-dialog-BvdAXZPw.cjs +0 -1
  86. package/dist/page-locked-by-dialog-jy3lYV3l.js +0 -63
  87. package/dist/page-manager-new-CNHlSwfe.js +0 -354
  88. package/dist/page-manager-new-CUlpwqpH.cjs +0 -1
  89. package/dist/page-manager-search-and-filter-CuAn82Db.js +0 -197
  90. package/dist/page-manager-search-and-filter-eFsGtm5W.cjs +0 -1
  91. package/dist/theme-panel-footer-0GrdOHO_.cjs +0 -1
  92. package/dist/theme-panel-footer-BzEy5bsg.js +0 -25
  93. package/dist/unmark-as-template-DXEs6foh.cjs +0 -1
  94. package/dist/unmark-as-template-Dsiyocm9.js +0 -38
  95. package/dist/unpublish-page-c1mqQEa_.cjs +0 -1
  96. package/dist/unpublish-page-yGyz2jiw.js +0 -26
@@ -0,0 +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-0cMGDekp.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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./index-0cMGDekp.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-Cqj9EBju.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;
@@ -0,0 +1,133 @@
1
+ import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
+ import { ak as C, al as A, A as T, am as w } from "./index-Bk8tPO5R.js";
3
+ import { useQueryClient as F, useMutation as _ } from "@tanstack/react-query";
4
+ import { toast as v } from "sonner";
5
+ import { useTranslation as q } from "@chaibuilder/sdk";
6
+ import { Dialog as G, DialogContent as L, DialogHeader as U, DialogTitle as j, DialogDescription as $, Label as D, Input as O, Alert as k, Button as P } from "@chaibuilder/sdk/ui";
7
+ import { isEmpty as B, initial as M } from "lodash-es";
8
+ import { AlertCircle as Q } from "lucide-react";
9
+ import { useState as p } from "react";
10
+ import { S as V } from "./slug-input-Df-BG6xl.js";
11
+ const H = () => {
12
+ const s = C(), o = F(), g = A();
13
+ return _({
14
+ mutationFn: async ({ pageId: e, name: h, slug: r }) => {
15
+ const u = {
16
+ pageId: e,
17
+ name: h
18
+ };
19
+ return r && (u.slug = r), await g(s, {
20
+ action: "DUPLICATE_PAGE",
21
+ data: u
22
+ });
23
+ },
24
+ onSuccess: () => {
25
+ o.invalidateQueries({
26
+ queryKey: [T.GET_WEBSITE_PAGES]
27
+ }), v.success("Page duplicated successfully");
28
+ },
29
+ onError: (e) => {
30
+ v.error("Failed to duplicate page", {
31
+ description: e.message || "An error occurred while duplicating the page"
32
+ });
33
+ }
34
+ });
35
+ }, se = ({
36
+ page: s,
37
+ onClose: o,
38
+ closePanel: g = () => {
39
+ }
40
+ }) => {
41
+ const { t: e } = q(), { mutate: h, isPending: r } = H(), [u, i] = p(null), [m, x] = p(`${s.name} (Copy)`), I = w(), l = B(s.slug), [d, E] = p(l ? "" : `${s.slug.split("/").pop()}-copy`), y = l ? "" : M(s.slug.split("/")).join("/"), [N, f] = p(!1), b = (n) => {
42
+ if (n.preventDefault(), !m.trim()) {
43
+ i(e("Name is required"));
44
+ return;
45
+ }
46
+ if (!l && !d.trim()) {
47
+ i(e("Slug is required"));
48
+ return;
49
+ }
50
+ i(null), f(!0);
51
+ const S = {
52
+ pageId: s.id,
53
+ name: m
54
+ };
55
+ l || (S.slug = `${y}/${d}`), h(S, {
56
+ onSuccess: (c) => {
57
+ f(!1), o(), I(c.id, g);
58
+ },
59
+ onError: (c) => {
60
+ f(!1), c.code === "SLUG_EXISTS" ? i(e("A page with this slug already exists. Please choose a different slug.")) : c.code === "INVALID_SLUG" ? i(e("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens.")) : c.code === "PERMISSION_DENIED" ? i(e("You don't have permission to duplicate this page.")) : i(c.message || e("Failed to duplicate page. Please try again later."));
61
+ }
62
+ });
63
+ };
64
+ return /* @__PURE__ */ t(G, { open: !!s, onOpenChange: o, children: /* @__PURE__ */ a(L, { className: "sm:max-w-[425px]", children: [
65
+ /* @__PURE__ */ a(U, { children: [
66
+ /* @__PURE__ */ t(j, { children: e("Duplicate Page") }),
67
+ /* @__PURE__ */ t($, { children: e("Create a copy of the page with a new name and slug") })
68
+ ] }),
69
+ /* @__PURE__ */ a("div", { className: "mb-4 rounded-md bg-gray-50 p-3", children: [
70
+ /* @__PURE__ */ a("h3", { className: "mb-1 text-sm font-medium", children: [
71
+ e("Duplicating:"),
72
+ ":"
73
+ ] }),
74
+ /* @__PURE__ */ a("div", { className: "flex flex-col gap-1 text-sm text-gray-700", children: [
75
+ /* @__PURE__ */ a("div", { children: [
76
+ /* @__PURE__ */ a("span", { className: "font-medium", children: [
77
+ e("Name"),
78
+ ":"
79
+ ] }),
80
+ " ",
81
+ s.name
82
+ ] }),
83
+ !l && /* @__PURE__ */ a("div", { children: [
84
+ /* @__PURE__ */ a("span", { className: "font-medium", children: [
85
+ e("Slug"),
86
+ ":"
87
+ ] }),
88
+ " ",
89
+ s.slug
90
+ ] }),
91
+ /* @__PURE__ */ a("div", { children: [
92
+ /* @__PURE__ */ a("span", { className: "font-medium", children: [
93
+ e("Type"),
94
+ ":"
95
+ ] }),
96
+ " ",
97
+ s.pageType
98
+ ] })
99
+ ] })
100
+ ] }),
101
+ /* @__PURE__ */ a("form", { onSubmit: b, className: "space-y-4", children: [
102
+ /* @__PURE__ */ a("div", { className: "space-y-2", children: [
103
+ /* @__PURE__ */ t(D, { htmlFor: "name", className: "text-sm", children: e("Name") }),
104
+ /* @__PURE__ */ t(O, { id: "name", value: m, onChange: (n) => x(n.target.value), required: !0 })
105
+ ] }),
106
+ !l && /* @__PURE__ */ a("div", { className: "space-y-2", children: [
107
+ /* @__PURE__ */ t(D, { htmlFor: "slug", className: "text-sm", children: e("Slug") }),
108
+ /* @__PURE__ */ t(
109
+ V,
110
+ {
111
+ value: d,
112
+ onChange: (n) => E(n),
113
+ parentSlug: y,
114
+ onValidationChange: (n) => {
115
+ i(n ? null : e("Invalid slug"));
116
+ }
117
+ }
118
+ )
119
+ ] }),
120
+ u && /* @__PURE__ */ a(k, { variant: "destructive", className: "py-2", children: [
121
+ /* @__PURE__ */ t(Q, { className: "h-4 w-4" }),
122
+ /* @__PURE__ */ t("span", { className: "text-sm", children: u })
123
+ ] }),
124
+ /* @__PURE__ */ a("div", { className: "flex justify-end gap-2", children: [
125
+ /* @__PURE__ */ t(P, { type: "button", variant: "outline", onClick: o, disabled: r, children: e("Cancel") }),
126
+ /* @__PURE__ */ t(P, { type: "submit", disabled: !m.trim() || !l && !d.trim() || r || N, children: e(r || N ? "Duplicating..." : "Duplicate") })
127
+ ] })
128
+ ] })
129
+ ] }) });
130
+ };
131
+ export {
132
+ se as default
133
+ };
@@ -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-Blg1T7nL.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-0cMGDekp.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 { k as y } from "./index-zaGKeGBW.js";
7
+ import { k as y } from "./index-Bk8tPO5R.js";
8
8
  const D = ({
9
9
  isDefaultLang: e,
10
10
  searchQuery: l,
@@ -0,0 +1,108 @@
1
+ import { jsx as i, jsxs as E } from "react/jsx-runtime";
2
+ import { useTranslation as L } from "@chaibuilder/sdk";
3
+ import { Dialog as R, DialogContent as S } from "@chaibuilder/sdk/ui";
4
+ import { debounce as j } from "lodash-es";
5
+ import { Save as O, Copy as P, Loader as A } from "lucide-react";
6
+ import { memo as D, useState as m, useEffect as x, useMemo as r, useCallback as b } from "react";
7
+ import N from "react-filerobot-image-editor";
8
+ const F = D(
9
+ ({ imageUrl: d, onSave: c, onClose: u, defaultSavedImageName: y, isEditing: f = !1 }) => {
10
+ const { t: a } = L(), [v, s] = m(!1), [p, I] = m(!0), [w, C] = m(!1);
11
+ x(() => {
12
+ const e = new Image();
13
+ return e.src = d, e.onload = () => C(!0), () => {
14
+ e.onload = null;
15
+ };
16
+ }, [d]), x(() => {
17
+ const e = (t) => {
18
+ t.key === "Escape" && p && (t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation());
19
+ };
20
+ return document.addEventListener("keydown", e, !0), () => {
21
+ document.removeEventListener("keydown", e, !0);
22
+ };
23
+ }, []);
24
+ const g = r(
25
+ () => j(async (e, t = !1) => {
26
+ s(!0);
27
+ const o = e.imageBase64;
28
+ await c(o, t), I(!1), s(!1);
29
+ }, 300),
30
+ [c]
31
+ ), n = b(
32
+ (e, t = !1) => {
33
+ g(e, t);
34
+ },
35
+ [g]
36
+ ), h = b(() => {
37
+ I(!1), u();
38
+ }, [u]), l = r(
39
+ () => ({
40
+ tabsIds: ["Adjust", "Annotate", "Watermark", "Finetune", "Resize", "Filters"],
41
+ toolsIds: ["Rotate"],
42
+ defaultTabId: "Adjust",
43
+ defaultToolId: "Rotate"
44
+ }),
45
+ []
46
+ ), T = r(
47
+ () => ({
48
+ colors: {
49
+ primary: "#000000",
50
+ secondary: "#000000",
51
+ tertiary: "#000000"
52
+ }
53
+ }),
54
+ []
55
+ ), k = r(
56
+ () => f ? [
57
+ {
58
+ label: a("Update this file"),
59
+ onClick: (e, t) => t((...o) => {
60
+ s(!0), n(o[0], !1);
61
+ }),
62
+ icon: O
63
+ },
64
+ {
65
+ label: a("Save as new file"),
66
+ onClick: (e, t) => t((...o) => {
67
+ s(!0), n(o[0], !0);
68
+ }),
69
+ icon: P
70
+ }
71
+ ] : [],
72
+ [f, n, a]
73
+ );
74
+ return /* @__PURE__ */ i(R, { open: !0, onOpenChange: (e) => !e && h(), children: /* @__PURE__ */ E(
75
+ S,
76
+ {
77
+ id: "chai-image-editor-container",
78
+ className: "flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4 p-0",
79
+ children: [
80
+ v && /* @__PURE__ */ i("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 text-white", children: /* @__PURE__ */ i(A, { className: "h-4 w-4 animate-spin" }) }),
81
+ p && w && /* @__PURE__ */ i(
82
+ N,
83
+ {
84
+ theme: T,
85
+ source: d,
86
+ onSave: n,
87
+ onClose: h,
88
+ Text: { text: a("Add text here") },
89
+ Rotate: { angle: 90, componentType: "slider" },
90
+ tabsIds: l.tabsIds,
91
+ defaultTabId: l.defaultTabId,
92
+ defaultToolId: l.defaultToolId,
93
+ savingPixelRatio: 20,
94
+ previewPixelRatio: 6,
95
+ defaultSavedImageName: y,
96
+ moreSaveOptions: k,
97
+ useZoomPresetsMenu: !0
98
+ }
99
+ )
100
+ ]
101
+ }
102
+ ) });
103
+ }
104
+ );
105
+ F.displayName = "ImageEditor";
106
+ export {
107
+ F as default
108
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),E=require("@chaibuilder/sdk"),b=require("@chaibuilder/sdk/ui"),S=require("lodash-es"),c=require("lucide-react"),s=require("react"),T=require("react-filerobot-image-editor"),h=s.memo(({imageUrl:l,onSave:u,onClose:m,defaultSavedImageName:y,isEditing:f=!1})=>{const{t:n}=E.useTranslation(),[v,i]=s.useState(!1),[p,g]=s.useState(!0),[w,j]=s.useState(!1);s.useEffect(()=>{const e=new Image;return e.src=l,e.onload=()=>j(!0),()=>{e.onload=null}},[l]),s.useEffect(()=>{const e=t=>{t.key==="Escape"&&p&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}},[]);const I=s.useMemo(()=>S.debounce(async(e,t=!1)=>{i(!0);const a=e.imageBase64;await u(a,t),g(!1),i(!1)},300),[u]),r=s.useCallback((e,t=!1)=>{I(e,t)},[I]),x=s.useCallback(()=>{g(!1),m()},[m]),d=s.useMemo(()=>({tabsIds:["Adjust","Annotate","Watermark","Finetune","Resize","Filters"],toolsIds:["Rotate"],defaultTabId:"Adjust",defaultToolId:"Rotate"}),[]),k=s.useMemo(()=>({colors:{primary:"#000000",secondary:"#000000",tertiary:"#000000"}}),[]),C=s.useMemo(()=>f?[{label:n("Update this file"),onClick:(e,t)=>t((...a)=>{i(!0),r(a[0],!1)}),icon:c.Save},{label:n("Save as new file"),onClick:(e,t)=>t((...a)=>{i(!0),r(a[0],!0)}),icon:c.Copy}]:[],[f,r,n]);return o.jsx(b.Dialog,{open:!0,onOpenChange:e=>!e&&x(),children:o.jsxs(b.DialogContent,{id:"chai-image-editor-container",className:"flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4 p-0",children:[v&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 text-white",children:o.jsx(c.Loader,{className:"h-4 w-4 animate-spin"})}),p&&w&&o.jsx(T,{theme:k,source:l,onSave:r,onClose:x,Text:{text:n("Add text here")},Rotate:{angle:90,componentType:"slider"},tabsIds:d.tabsIds,defaultTabId:d.defaultTabId,defaultToolId:d.defaultToolId,savingPixelRatio:20,previewPixelRatio:6,defaultSavedImageName:y,moreSaveOptions:C,useZoomPresetsMenu:!0})]})})});h.displayName="ImageEditor";exports.default=h;