1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2400,16233,22517,30731],{16233:(e,t,a)=>{a.r(t),a.d(t,{__iconNode:()=>r,default:()=>s});var l=a(20728);let r=[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]],s=(0,l.A)("component",r)},22517:(e,t,a)=>{a.r(t),a.d(t,{__iconNode:()=>r,default:()=>s});var l=a(20728);let r=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],s=(0,l.A)("pen",r)},30731:(e,t,a)=>{a.r(t),a.d(t,{__iconNode:()=>r,default:()=>s});var l=a(20728);let r=[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]],s=(0,l.A)("folder-input",r)},45951:(e,t,a)=>{a.d(t,{Vs:()=>e6});var l=a(37876),r=a(14232),s=a(26424),n=a(91636),i=a(99974),o=a(51589),d=a(59688),c=a(88992),u=a(28508),m=a(56654),h=a(10680),g=a(87858),x=a(71604),f=a(18500),p=a(36535),j=a(38942);let v=e=>{let{mode:t,initialData:a,onSubmit:s,onCancel:n,isSubmitting:i=!1,showDeleteButton:o=!1,onDelete:d,isDeleting:v=!1}=e,y=(0,c.mN)({resolver:(0,u.u)(j.W),defaultValues:{name:(null==a?void 0:a.name)||"",description:(null==a?void 0:a.description)||""}});return(0,r.useEffect)(()=>{a&&y.reset({name:a.name,description:a.description||""})},[a,y]),(0,l.jsx)(m.lV,{...y,children:(0,l.jsxs)("form",{onSubmit:y.handleSubmit(e=>{s(e)}),className:"space-y-4",children:[(0,l.jsx)(m.zB,{control:y.control,name:"name",render:e=>{let{field:t}=e;return(0,l.jsxs)(m.eI,{children:[(0,l.jsx)(m.lR,{children:"Category Name"}),(0,l.jsx)(m.MJ,{children:(0,l.jsx)(h.p,{placeholder:"Enter category name",disabled:i,...t})}),(0,l.jsx)(m.C5,{})]})}}),(0,l.jsx)(m.zB,{control:y.control,name:"description",render:e=>{let{field:t}=e;return(0,l.jsxs)(m.eI,{children:[(0,l.jsx)(m.lR,{children:"Description (Optional)"}),(0,l.jsx)(m.MJ,{children:(0,l.jsx)(g.T,{placeholder:"Enter category description",disabled:i,rows:3,...t})}),(0,l.jsx)(m.C5,{})]})}}),(0,l.jsxs)("div",{className:"flex justify-between items-center pt-4",children:[o&&d?(0,l.jsxs)(x.$,{type:"button",variant:"destructive",onClick:d,disabled:i||v,children:[v&&(0,l.jsx)(f.default,{className:"mr-2 h-4 w-4 animate-spin"}),(0,l.jsx)(p.default,{className:"mr-2 h-4 w-4"}),"Delete"]}):(0,l.jsx)("div",{}),(0,l.jsxs)("div",{className:"flex space-x-2",children:[(0,l.jsx)(x.$,{type:"button",variant:"outline",onClick:n,disabled:i||v,children:"Cancel"}),(0,l.jsxs)(x.$,{type:"submit",disabled:i||v,children:[i&&(0,l.jsx)(f.default,{className:"mr-2 h-4 w-4 animate-spin"}),"create"===t?"Create":"Update"]})]})]})]})})};v.displayName="CategoryForm";let y=(0,r.memo)(v);var b=a(52417);let w=e=>{let{state:t,onConfirm:a,onCancel:r,isDeleting:s=!1}=e;return(0,l.jsx)(i.Lt,{open:t.isOpen,onOpenChange:r,children:(0,l.jsxs)(i.EO,{children:[(0,l.jsxs)(i.wd,{children:[(0,l.jsxs)(i.r7,{className:"flex items-center gap-2",children:[(0,l.jsx)(b.default,{className:"h-5 w-5 text-destructive"}),"Delete Category"]}),(0,l.jsx)(i.$v,{children:(0,l.jsx)("div",{className:"space-y-2",children:t.hasContent?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("p",{children:['The category "',t.categoryName,'" cannot be deleted because it contains files and folders.']}),(0,l.jsx)("p",{className:"text-sm text-muted-foreground",children:"Please remove all content from this category before attempting to delete it."})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("p",{children:['Are you sure you want to delete the category "',t.categoryName,'"?']}),(0,l.jsx)("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone."})]})})})]}),(0,l.jsx)(i.ck,{children:t.hasContent?(0,l.jsx)(i.Zr,{onClick:r,children:"Close"}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(i.Zr,{onClick:r,disabled:s,children:"Cancel"}),(0,l.jsx)(i.Rx,{asChild:!0,children:(0,l.jsx)(x.$,{variant:"destructive",onClick:a,disabled:s,className:"bg-red-600 hover:bg-red-700 text-white",children:s?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(f.default,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting..."]}):"Delete"})})]})})]})})};w.displayName="DeleteConfirmation";let C=(0,r.memo)(w);var N=a(67768),k=a(33090),I=a(50741),F=a(12035);let D=e=>{let{state:t,onClose:a,onSave:s}=e,{user:c}=(0,F.As)(),[u,m]=(0,r.useState)({isOpen:!1,categoryId:0,categoryName:"",hasContent:!1}),[h,g]=(0,r.useState)({isOpen:!1,title:"",message:""}),[x,f]=(0,r.useState)(!1),[p,j]=(0,r.useState)(!1),{data:v}=(0,k.Zu)(!1),{data:b}=(0,I.Pi)({categoryId:"edit"===t.mode&&t.categoryId?t.categoryId:void 0,type:"template"}),{data:w}=(0,k.uE)(!1),D=(0,N.jE)(),S=(0,r.useCallback)(e=>((null==w?void 0:w.data)||[]).some(a=>a.attributes.name.toLowerCase()===e.toLowerCase()&&a.id!==String(t.categoryId)),[w,t.categoryId]),A=(0,r.useCallback)(async e=>{f(!0);try{if(S(e.name)){g({isOpen:!0,title:"Category Already Exists",message:"Category name already exists. Please choose a different name."}),f(!1);return}if("create"===t.mode){console.log("userIduserId",c);let t=await fetch("/api/artwork/categories/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,description:e.description||void 0,userId:null==c?void 0:c.id})});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to create category")}d.oR.success("Category created successfully");let a=await t.json();D.invalidateQueries({queryKey:["artwork-categories"]}
1),console.log("RESPONSE",t),s(a.attributes.name,a.id)}else if("edit"===t.mode&&t.categoryId){let a=await fetch("/api/artwork/categories/".concat(t.categoryId),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,description:e.description||void 0})});if(!a.ok){let e=await a.json();throw Error(e.error||"Failed to update category")}d.oR.success("Category updated successfully"),console.log("state ",t),console.log("response ",a.json()),D.invalidateQueries({queryKey:["artwork-categories"]}),s(e.name,t.categoryId)}}catch(a){let e=a instanceof Error?a.message:"An error occurred";d.oR.error("Failed to ".concat(t.mode," category: ").concat(e))}finally{f(!1)}},[t,D,s,c,S]),E=(0,r.useCallback)(()=>{var e,a,l;if(!t.categoryId||!t.categoryData)return;let r=(null==v||null==(e=v.data)?void 0:e.filter(e=>{var a,l,r;return(null==(r=e.relationships)||null==(l=r.categories)||null==(a=l.data)?void 0:a.id)===t.categoryId}))||[],s=((null==b||null==(a=b.data)?void 0:a.pages)?b.data.pages.flatMap(e=>(null==e?void 0:e.data)||[]):(null==b||null==(l=b.data)?void 0:l.data)||[]).filter(e=>{var a,l,r;return(null==(r=e.relationships)||null==(l=r.categories)||null==(a=l.data)?void 0:a.id)==t.categoryId})||[],n=r.length>0||s.length>0;m({isOpen:!0,categoryId:t.categoryId,categoryName:t.categoryData.name,hasContent:n})},[t.categoryId,t.categoryData,v,b]),O=(0,r.useCallback)(async()=>{let e=u.categoryId;j(!0);try{let t=await fetch("/api/artwork/categories/".concat(e),{method:"DELETE"});if(!t.ok){let e=await t.json();g({isOpen:!0,title:"Delete Category Failed",message:e.detail||e.error||"An unexpected error occurred while deleting the category"}),m(e=>({...e,isOpen:!1}));return}d.oR.success("Category deleted successfully"),await D.invalidateQueries({queryKey:["artwork-categories"]}),m(e=>({...e,isOpen:!1})),a(e)}catch(t){let e=t instanceof Error?t.message:"An error occurred";d.oR.error("Failed to delete category: ".concat(e))}finally{j(!1)}},[u.categoryId,D,a]),R=(0,r.useCallback)(()=>{m(e=>({...e,isOpen:!1}))},[]),T=(0,r.useCallback)(()=>{g({isOpen:!1,title:"",message:""})},[]),L=(0,r.useCallback)(e=>{e||a()},[a]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.lG,{open:t.isOpen,onOpenChange:L,children:(0,l.jsxs)(n.Cf,{className:"sm:max-w-[500px]",children:[(0,l.jsx)(n.c7,{children:(0,l.jsx)(n.L3,{children:"create"===t.mode?"Create Category":"Edit Category"})}),(0,l.jsx)(o.w,{}),(0,l.jsx)(y,{mode:t.mode,initialData:t.categoryData,onSubmit:A,onCancel:a,isSubmitting:x,showDeleteButton:"edit"===t.mode,onDelete:E,isDeleting:p})]})}),(0,l.jsx)(C,{state:u,onConfirm:O,onCancel:R,isDeleting:p}),(0,l.jsx)(i.Lt,{open:h.isOpen,onOpenChange:T,children:(0,l.jsxs)(i.EO,{children:[(0,l.jsxs)(i.wd,{children:[(0,l.jsx)(i.r7,{children:h.title}),(0,l.jsx)(i.$v,{children:h.message})]}),(0,l.jsx)(i.ck,{children:(0,l.jsx)(i.Rx,{onClick:T,children:"OK"})})]})})]})};D.displayName="CategoryDialog";let S=(0,r.memo)(D);var A=a(51802);let E=A.Ik({name:A.Yj().min(1,"Folder name is required").max(255,"Folder name must be less than 255 characters").trim(),categoryId:A.ai().min(1,"Category is required"),parentFolderId:A.ai().nullable().optional()});A.Ik({name:A.Yj().min(1,"Folder name is required").max(255,"Folder name must be less than 255 characters").trim().optional(),categoryId:A.ai().min(1,"Category is required").optional(),parentFolderId:A.ai().nullable().optional()});var O=a(33924);function R(e){let{value:t,onValueChange:a,disabled:r}=e,{data:s,isLoading:n}=(0,k.uE)(),i=[...(null==s?void 0:s.data)||[]].sort((e,t)=>e.attributes.name.localeCompare(t.attributes.name));return(0,l.jsxs)(O.l6,{value:t?String(t):void 0,onValueChange:e=>{let t=parseInt(e,10);isNaN(t)||a(t)},disabled:r||n,children:[(0,l.jsx)(O.bq,{className:"w-full",children:(0,l.jsx)(O.yv,{placeholder:n?"Loading categories...":"Select a category"})}),(0,l.jsx)(O.gC,{children:i.map(e=>(0,l.jsx)(O.eb,{value:e.id,children:e.attributes.name},e.id))})]})}var T=a(19873);function L(e){let{isOpen:t,onClose:a,onConfirm:r,folderName:s,hasContent:n}=e;return n?(0,l.jsx)(i.Lt,{open:t,onOpenChange:a,children:(0,l.jsxs)(i.EO,{children:[(0,l.jsxs)(i.wd,{children:[(0,l.jsx)(i.r7,{children:"Cannot Delete Folder"}),(0,l.jsxs)(i.$v,{children:['The folder "',s,'" cannot be deleted because it c
1ontains subfolders or files. Please remove all contents before deleting the folder.']})]}),(0,l.jsx)(i.ck,{children:(0,l.jsx)(i.Zr,{onClick:a,children:"Close"})})]})}):(0,l.jsx)(i.Lt,{open:t,onOpenChange:a,children:(0,l.jsxs)(i.EO,{children:[(0,l.jsxs)(i.wd,{children:[(0,l.jsx)(i.r7,{children:"Delete Folder"}),(0,l.jsxs)(i.$v,{children:['Are you sure you want to delete the folder "',s,'"? This action cannot be undone.']})]}),(0,l.jsxs)(i.ck,{children:[(0,l.jsx)(i.Zr,{onClick:a,children:"Cancel"}),(0,l.jsx)(i.Rx,{onClick:r,className:"bg-red-600 hover:bg-red-700 text-white",children:"Delete"})]})]})})}var P=a(846),_=a(63184),U=a(94047);function M(e){let{state:t,onClose:s}=e,{user:i}=(0,F.As)(),g=(0,_.u)(),j=(0,N.jE)(),{data:v}=(0,k.uE)(),y=(0,r.useMemo)(()=>(null==v?void 0:v.data)||[],[v]),b=(0,c.mN)({resolver:(0,u.u)(E),mode:"onSubmit",defaultValues:{name:"",categoryId:void 0,parentFolderId:null}}),w=b.watch("categoryId"),{data:C}=(0,k.Zu)(!1,w?Number(w):null),{data:I}=(0,k.Zu)(!1,null),{data:D}=(0,k.Zu)(!0,null),S=(0,r.useMemo)(()=>(null==C?void 0:C.data)||[],[C]),A=(0,r.useMemo)(()=>[...((null==I?void 0:I.data)||[]).map(e=>({...e,_isArchived:!1})),...((null==D?void 0:D.data)||[]).map(e=>({...e,_isArchived:!0}))],[I,D]),[O,M]=(0,r.useState)({isOpen:!1,folderId:"",folderName:"",hasContent:!1,isDeleting:!1}),[B,z]=(0,r.useState)(!1);(0,r.useEffect)(()=>{var e,a;if(t.isOpen&&"create"===t.mode)b.reset({name:"",categoryId:t.defaultCategoryId,parentFolderId:null!=(a=t.defaultParentId)?a:null}),M({isOpen:!1,folderId:"",folderName:"",hasContent:!1,isDeleting:!1});else if(t.isOpen&&"edit"===t.mode&&(null==(e=t.folderData)?void 0:e.attributes)){let e=t.folderData.attributes.parentFolderId?+t.folderData.attributes.parentFolderId:null;b.reset({name:t.folderData.attributes.name,categoryId:+t.folderData.attributes.categoryId,parentFolderId:e}),M({isOpen:!1,folderId:"",folderName:"",hasContent:!1,isDeleting:!1})}},[t.isOpen,t.mode,t.folderData,t.defaultCategoryId,t.defaultParentId,b]);let q=(0,r.useCallback)(async()=>{var e,l,r,s,n,i;if(!t.folderId||!t.folderData)return;let o=(null==(r=t.folderData.relationships)||null==(l=r.categories)||null==(e=l.data)?void 0:e.id)||(null==(s=t.folderData.attributes)?void 0:s.categoryId),c=A;if(o)try{let{AuthClientService:e}=await Promise.resolve().then(a.bind(a,30277)),[t,l]=await Promise.all([j.fetchQuery({queryKey:["artwork-folders",g,{archive:!1,categoryId:Number(o)}],queryFn:async()=>{let t=new URL("/api/artwork/folders",window.location.origin);return t.searchParams.set("archive","false"),t.searchParams.set("category_id",o.toString()),await e.makeAuthenticatedRequest(t.toString())},staleTime:3e4}),j.fetchQuery({queryKey:["artwork-folders",g,{archive:!0,categoryId:Number(o)}],queryFn:async()=>{let t=new URL("/api/artwork/folders",window.location.origin);return t.searchParams.set("archive","true"),t.searchParams.set("category_id",o.toString()),await e.makeAuthenticatedRequest(t.toString())},staleTime:3e4})]),r=[...((null==t?void 0:t.data)||[]).map(e=>({...e,_isArchived:!1})),...((null==l?void 0:l.data)||[]).map(e=>({...e,_isArchived:!0}))],s=new Set(A.map(e=>String(e.id))),n=r.filter(e=>!s.has(String(e.id)));c=[...A,...n]}catch(t){console.error("Failed to fetch category-specific folders for deletion validation:",t);let e=t instanceof Error?t.message:"Unknown error";d.oR.error("Failed to validate folder contents: ".concat(e,". Proceeding with available data."))}let u=(0,P.WH)(t.folderId,c),m=!1;try{m=((await U._.getFiles({type:"template",folderId:Number(t.folderId),includeArchived:!1,pageSize:1})).data||[]).some(e=>{let t=e.attributes||{};return!t.deletedAt&&!t.deleted_at&&!t.soft_deleted})}catch(e){m=(t.folderData.templatesAmount||(null==(i=t.folderData)||null==(n=i.attributes)?void 0:n.itemCount)||0)>0}let h=u.length>0||m;M({isOpen:!0,folderId:t.folderId,folderName:t.folderData.attributes.name,hasContent:h,isDeleting:!1})},[t.folderId,t.folderData,A,j,g]),$=(0,r.useCallback)(async()=>{let e=O.folderId;M(e=>({...e,isOpen:!1,isDeleting:!0}));try{let t=await fetch("/api/artwork/folders/".concat(e),{method:"DELETE"});if(!t.ok){let e="Failed to delete folder";try{let a=await t.text();if(a.trim())try{let t=JSON.parse(a);e=t.detail||t.error||e}catch(t){e=a||e}}catch(e){}throw Error(e)}d.oR.success("Folder deleted successfully"),await j.invalidateQueries({queryKey:["artwork-folders"]}),s(e)}catch(t){let e=t instanceof Error?t.message:"An error occurred";d.oR.error("Failed to delete folder: ".concat(e)),M(e=>({...e,isDeleting:!1}))}},[O.folderId,j,s]),K=(0,r.useCallback)(()=>{M(e=>({...e,isOpen:!1}))},[]),Z=(0,r.useCallback)(async e=>{z(!0);try{var a;let l="create"===t.mode?"/api/artwork/folders/create":"/api/artwork/folders/".concat(t.folderId),r="create"===t.mode?"POST":"PATCH",n=await fetch(l,{method:r,headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,userId:null==i?void 0:i.id})});if(!n.ok){let e="Failed to ".concat(t.mode," folder");try{let t=await n.text();e=t.trim().startsWith("{")||t.trim().startsWith("[")?JSON.parse(t).error||e:t||e}catch(e){}throw Error(e)}let o=await n.json();d.oR.success("Folder ".concat("create"===t.mode?"created":"updated"," successfully")),await Promise.all([j.invalidateQueries({queryKey:["artwork-folders"]}),j.invalidateQueries({queryKey:["artwork-categories"]}),j.refetchQueries({queryKey:["artwork-folders"]}),j.refetchQueries({queryKey:["artwork-categories"]})]),s(null==(a=o.data)?void 0:a.id)}catch(a){let e=a instanceof Error?a.message:"An error occurred";d.oR.error("Failed to ".concat(t.mode," folder: ").concat(e))}finally{z(!1)}},[t.mode,t.folderId,j,s,null==i?void 0:i.id]),Y=(0,r.useMemo)(()=>
1{if(!w)return;let e=y.find(e=>parseInt(e.id)==w);return null==e?void 0:e.attributes.name},[w,y]),W="create"===t.mode?"Create Folder":"Edit Folder",Q="create"===t.mode?"Create Folder":"Update";return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.lG,{open:t.isOpen,onOpenChange:()=>s(),children:(0,l.jsxs)(n.Cf,{className:"sm:max-w-[500px]",children:[(0,l.jsx)(n.c7,{children:(0,l.jsx)(n.L3,{children:W})}),(0,l.jsx)(o.w,{}),(0,l.jsx)(m.lV,{...b,children:(0,l.jsxs)("form",{onSubmit:b.handleSubmit(Z),className:"space-y-6",children:[(0,l.jsx)(m.zB,{control:b.control,name:"name",render:e=>{let{field:t}=e;return(0,l.jsxs)(m.eI,{children:[(0,l.jsx)(m.lR,{children:"Folder Name"}),(0,l.jsx)(m.MJ,{children:(0,l.jsx)(h.p,{placeholder:"Enter folder name",...t})}),(0,l.jsx)(m.C5,{})]})}}),(0,l.jsx)(m.zB,{control:b.control,name:"categoryId",render:e=>{let{field:t}=e;return(0,l.jsxs)(m.eI,{children:[(0,l.jsx)(m.lR,{children:"Category"}),(0,l.jsx)(m.MJ,{children:(0,l.jsx)(R,{value:t.value,onValueChange:t.onChange,disabled:b.formState.isSubmitting})}),(0,l.jsx)(m.C5,{})]})}}),(0,l.jsx)(m.zB,{control:b.control,name:"parentFolderId",render:e=>{let{field:a}=e;return(0,l.jsxs)(m.eI,{children:[(0,l.jsx)(m.lR,{children:"Parent Folder"}),(0,l.jsx)(m.MJ,{children:(0,l.jsx)("div",{className:"h-[300px] border rounded-md",children:w?(0,l.jsx)(T.Q,{folders:S,categoryId:w,categoryName:Y,selectedFolderId:a.value,onSelectFolder:a.onChange,excludeFolderId:"edit"===t.mode?t.folderId:void 0,disabled:b.formState.isSubmitting}):(0,l.jsx)("div",{className:"h-full flex items-center justify-center bg-gray-50 text-gray-500 text-sm",children:"Please select a category first to choose a parent folder"})})}),(0,l.jsx)(m.C5,{})]})}}),(0,l.jsxs)(n.Es,{className:"flex justify-between",children:["edit"===t.mode&&(0,l.jsx)(x.$,{type:"button",variant:"destructive",onClick:q,disabled:B||O.isDeleting,className:"flex items-center gap-2",children:O.isDeleting?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(f.default,{className:"h-4 w-4 animate-spin"}),"Deleting..."]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(p.default,{className:"h-4 w-4"}),"Delete"]})}),(0,l.jsxs)("div",{className:"flex gap-2 ml-auto",children:[(0,l.jsx)(x.$,{type:"button",variant:"outline",onClick:()=>s(),disabled:B||O.isDeleting,children:"Cancel"}),(0,l.jsx)(x.$,{type:"submit",disabled:B||O.isDeleting,children:B?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(f.default,{className:"mr-2 h-4 w-4 animate-spin"}),"create"===t.mode?"Creating...":"Updating..."]}):Q})]})]})]})})]})}),(0,l.jsx)(L,{isOpen:O.isOpen,onClose:K,onConfirm:$,folderName:O.folderName,hasContent:O.hasContent})]})}var B=a(82093);function z(e){let{state:t,onClose:a,onConfirm:s,selectedCount:i,categoryId:o}=e,[d,c]=(0,r.useState)(o),[u,m]=(0,r.useState)(null),[h,g]=(0,r.useState)(!1);(0,r.useEffect)(()=>{t.isOpen&&(c(o),m(null),g(!1))},[t.isOpen,o]);let{data:f}=(0,k.uE)(),{data:p}=(0,k.Zu)(!1,d),j=(0,r.useMemo)(()=>(null==f?void 0:f.data)||[],[f]),v=(0,r.useMemo)(()=>(null==p?void 0:p.data)||[],[p]),y=(0,r.useMemo)(()=>{if(null===d)return;let e=j.find(e=>parseInt(e.id,10)===d);return null==e?void 0:e.attributes.name},[d,j]),b=()=>{m(null),g(!1),a()};return(0,l.jsx)(n.lG,{open:t.isOpen,onOpenChange:b,children:(0,l.jsxs)(n.Cf,{className:"sm:max-w-[500px]",children:[(0,l.jsx)(n.c7,{children:(0,l.jsxs)(n.L3,{children:["Move ",i," Templates"]})}),(0,l.jsx)(R,{value:null!=d?d:void 0,onValueChange:e=>{c(e),m(null),g(!1)}}),(0,l.jsx)("div",{className:"h-[300px] border rounded-md",children:null!==d?(0,l.jsx)(T.Q,{folders:v,categoryId:d.toString(),categoryName:y,selectedFolderId:u,onSelectFolder:e=>{m(e),g(!0)}}):(0,l.jsx)("div",{className:"h-full flex items-center justify-center bg-gray-50 text-gray-500 text-sm",children:"Select a category to choose a destination folder"})}),(0,l.jsxs)(n.Es,{children:[(0,l.jsx)(x.$,{type:"button",variant:"outline",onClick:b,children:"Cancel"}),(0,l.jsxs)(x.$,{type:"button",onClick:()=>{s(u),m(null),g(!1)},disabled:!h,children:["Move ",i," templates"]})]})]})})}function q(e){let{isOpen:t,onClose:a,onConfirm:r,selectedCount:s,isPending:n}=e;return(0,l.jsx)(i.Lt,{open:t,onOpenChange:e=>{e||n||a()},children:(0,l.jsxs)(i.EO,{children:[(0,l.jsxs)(i.wd,{children:[(0,l.jsx)(i.r7,{children:"Duplicate Templates"}),(0,l.jsxs)(i.$v,{children:["Are you sure you want to duplicate ",s," templates? This will create ",s," copies."]})]}),(0,l.jsxs)(i.ck,{children:[(0,l.jsx)(i.Zr,{onClick:a,disabled:n,children:"Cancel"}),(0,l.jsx)(i.Rx,{onClick:r,disabled:n,className:"bg-primary hover:bg-primary/90 text-primary-foreground",children:n?"Duplicatingâ¦":"Duplicate"})]})]})})}var $=a(48336),K=a(9531),Z=a(89099),Y=a(84449),W=a(16233),Q=a(97730),G=a(38129),V=a(22517),X=a(95316),H=a(69718),J=a(7342),ee=a(6847),et=a(18024),ea=a(30512),el=a(93786),er=a(28364);let es=[{icon:J.default,label:"Folders",value:"folders"},{icon:ee.default,label:"View all",value:"view-all"},{icon:et.default,label:"Recent",value:"recent"},{icon:ea.default,label:"Archived",value:"archived"}],en=[{icon:ee.default,label:"View all",value:"view-all"},{icon:et.default,label:"Recent",value:"recent"},{icon:ea.default,label:"Archived",value:"archived"}],ei={ALL_CATEGORIES:el.default,USER_CATEGORY:er.default};var eo=a(46926),ed=a(70899),ec=a(69668),eu=a(48230),em=a.n(eu);let eh=()=>{let e=(0,Z.useRouter)(),{state:t,actions:a,handlers:n}=(0,H.ff)(),i=(0,r.useRef)(null),{showTopIndicator:o,showBottomIndicator:d,scrollUp:c,scrollDown:u,checkScrollIndicators:m}=(e=>
1{let[t,a]=(0,r.useState)(!1),[l,s]=(0,r.useState)(!1),n=(0,r.useCallback)(()=>{if(!e.current)return;let{scrollTop:t,scrollHeight:l,clientHeight:r}=e.current;a(t>10),s(l>r&&t<l-r-10)},[e]);return(0,r.useEffect)(()=>{let t=e.current;if(!t)return;n(),t.addEventListener("scroll",n);let a=new ResizeObserver(n);return a.observe(t),()=>{t.removeEventListener("scroll",n),a.disconnect()}},[e,n]),{showTopIndicator:t,showBottomIndicator:l,scrollUp:()=>{e.current&&e.current.scrollBy({top:-100,behavior:"smooth"})},scrollDown:()=>{e.current&&e.current.scrollBy({top:100,behavior:"smooth"})},checkScrollIndicators:n}})(i),{canCreateCategories:h,canEditCategories:g}=(0,ed.Sk)(),{isLoading:x}=(0,F.As)(),p=(0,ec.u)(),j=e.pathname.includes("/templates"),v=e.pathname.includes("/artworks"),{data:y}=(0,k.uE)(),b=(null==y?void 0:y.data)||[],{categoryItems:w}=(e=>{let{isLoading:t,categories:a}=e;return{categoryItems:(0,r.useMemo)(()=>t?[]:[...(a||[]).filter(e=>e&&e.id&&e.attributes).map(eo.v).filter(e=>!e.deletedAt).sort((e,t)=>e.name||t.name?e.name?t.name?e.name.localeCompare(t.name,"en",{numeric:!0,sensitivity:"base"}):-1:1:0).map(e=>({icon:ei.USER_CATEGORY,label:e.name,value:e.name.toLowerCase().replace(/\s+/g,"-"),categoryData:e,isSystem:!1}))],[a,t]),isLoading:t}})({categories:b,isLoading:t.isInitialLoading}),C=w.filter(e=>!e.isSystem),N=w.filter(e=>e.isSystem),{handleTabChange:I,handleCategoryChange:D,handleEditCategory:S}=(e=>{let{activeTab:t,activeCategory:a,onTabChange:l,onCategoryChange:s,onEditCategory:n}=e,i=(0,r.useCallback)(e=>{null==l||l(e)},[l]),o=(0,r.useCallback)(e=>{null==s||s(e)},[s]),d=(0,r.useCallback)(e=>{if(n){var t;n(parseInt(e.id),e.name,null!=(t=e.description)?t:void 0)}},[n]),c=(0,r.useCallback)(e=>"all-categories"!==a||"folders"!==e,[a]);return(0,r.useEffect)(()=>{"folders"!==t||c("folders")||i("view-all")},[t,c,i]),{activeTab:t,activeCategory:a,handleTabChange:i,handleCategoryChange:o,handleEditCategory:d,shouldShowTab:c}})({activeTab:t.activeTab,activeCategory:t.activeCategory,onTabChange:a.setActiveTab,onCategoryChange:n.handleCategoryChange,onEditCategory:n.handleEditCategory});(0,r.useEffect)(()=>{b.length>0&&i.current&&setTimeout(()=>{m()},100)},[b.length,m]);let A=p?"h-screen":"h-[calc(100vh-70px)]";return x?(0,l.jsx)(s.Bx,{variant:"floating",side:"left",className:"relative ".concat(A," [&>[data-sidebar='sidebar']]:bg-muted"),children:(0,l.jsx)(s.Yv,{children:(0,l.jsx)("div",{className:"p-4",children:(0,l.jsxs)("div",{className:"animate-pulse",children:[(0,l.jsx)("div",{className:"h-4 bg-gray-200 rounded w-3/4 mb-2"}),(0,l.jsx)("div",{className:"h-4 bg-gray-200 rounded w-1/2"})]})})})}):(0,l.jsx)(s.Bx,{variant:"floating",side:"left",className:"relative ".concat(A," [&>[data-sidebar='sidebar']]:bg-muted"),children:(0,l.jsxs)(s.Yv,{children:[(0,l.jsx)("div",{className:"px-2 py-2",children:(0,l.jsxs)(s.wZ,{children:[(0,l.jsx)(s.FX,{children:(0,l.jsx)(s.Uj,{asChild:!0,className:"h-10 rounded-md",children:(0,l.jsxs)(em(),{href:"/marketing-hub",children:[(0,l.jsx)(W.default,{className:"h-4 w-4"}),(0,l.jsx)("span",{children:"Marketing Hub"})]})})}),v&&(0,l.jsx)(s.FX,{children:(0,l.jsx)(s.Uj,{asChild:!0,className:"h-10 rounded-md",children:(0,l.jsxs)(em(),{href:"/marketing-hub/templates",children:[(0,l.jsx)(W.default,{className:"h-4 w-4"}),(0,l.jsx)("span",{children:"Templates"})]})})}),j&&(0,l.jsx)(s.FX,{children:(0,l.jsx)(s.Uj,{asChild:!0,className:"h-10 rounded-md",children:(0,l.jsxs)(em(),{href:"/marketing-hub/artworks",children:[(0,l.jsx)(W.default,{className:"h-4 w-4"}),(0,l.jsx)("span",{children:"Artwork"})]})})})]})}),(0,l.jsx)("div",{className:"pl-1 pr-5",children:(0,l.jsx)(s.GX,{})}),(0,l.jsx)("div",{className:"px-2 py-2",children:(0,l.jsx)(s.wZ,{children:en.map((e,a)=>(0,l.jsx)(s.FX,{children:(0,l.jsxs)(s.Uj,{className:"h-10 rounded-md",isActive:t.activeTab===e.value&&"all-categories"===t.activeCategory,onClick:()=>{n.handleCategoryChange("all-categories"),I(e.value)},children:[(0,l.jsx)(e.icon,{className:"h-4 w-4"}),(0,l.jsx)("span",{children:e.label})]})},"top-".concat(e.label,"-").concat(a)))})}),(0,l.jsx)("div",{className:"pl-1 pr-5",children:(0,l.jsx)(s.GX,{})}),(0,l.jsxs)("div",{className:"px-2 overflow-y-hidden relative flex-1",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between pl-3 py-2",children:[(0,l.jsx)("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Categories"}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[t.isRefreshing&&(0,l.jsx)(f.default,{className:"h-3 w-3 animate-spin text-muted-foreground"}),h()&&(0,l.jsx)("button",{onClick:n.handleCreateCategory,className:"p-2 rounded-md hover:bg-accent/50 text-muted-foreground hover:text-foreground transition-colors cursor-pointer focus:outline-none focus:ring-1 focus:ring-ring",title:"Create new category",children:(0,l.jsx)(Q.default,{className:"h-5 w-5"})})]})]}),o&&(0,l.jsx)("button",{onClick:c,className:"absolute top-12 left-2 right-2 z-10 h-4 bg-background/90 hover:bg-background border border-border/50 rounded-md flex items-center justify-center transition-colors shadow-sm",children:(0,l.jsx)(G.default,{className:"h-4 w-4 text-muted-foreground"})}),(0,l.jsx)("div",{ref:i,className:"overflow-y-auto scrollbar-hide",style:{height:"calc(100% - 48px - ".concat(o?"24px":"0px"," - ").concat(d?"24px":"0px",")"),marginTop:o?"24px":"0",marginBottom:
1d?"24px":"0"},children:(0,l.jsx)(s.wZ,{children:t.isInitialLoading?Array.from({length:3}).map((e,t)=>(0,l.jsx)(s.FX,{children:(0,l.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2",children:[(0,l.jsx)(Y.E,{className:"h-4 w-4"}),(0,l.jsx)(Y.E,{className:"h-4 flex-1"})]})},"skeleton-".concat(t))):(0,l.jsxs)(l.Fragment,{children:[N.map(e=>(0,l.jsx)(s.FX,{children:(0,l.jsx)(s.Uj,{className:"h-10 rounded-md w-full justify-between",isActive:t.activeCategory===e.value,onClick:()=>n.handleCategoryChange(e.value),children:(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(e.icon,{className:"h-4 w-4"}),(0,l.jsx)("span",{children:e.label})]})})},e.value)),C.map((e,a)=>(0,l.jsx)(s.FX,{children:(0,l.jsxs)(s.Uj,{className:"h-10 rounded-md w-full justify-between",isActive:t.activeCategory==e.value,onClick:()=>D(e.value),children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(e.icon,{className:"h-4 w-4"}),(0,l.jsx)("span",{children:e.label})]}),!e.isSystem&&t.activeCategory==e.value&&g()&&(0,l.jsx)("div",{role:"button",tabIndex:0,onClick:t=>{t.stopPropagation(),e.categoryData&&S(e.categoryData)},onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),t.stopPropagation(),e.categoryData&&S(e.categoryData))},className:"p-1 rounded-md hover:bg-accent/50 opacity-60 hover:opacity-100 transition-opacity ml-auto cursor-pointer focus:outline-none focus:ring-1 focus:ring-ring",title:"Edit category",children:(0,l.jsx)(V.default,{className:"h-3 w-3"})})]})},e.label+a))]})})}),d&&(0,l.jsx)("button",{onClick:u,className:"absolute bottom-2 left-2 right-2 z-10 h-4 bg-background/90 hover:bg-background border border-border/50 rounded-md flex items-center justify-center transition-colors shadow-sm",children:(0,l.jsx)(X.default,{className:"h-4 w-4 text-muted-foreground"})})]})]})})};eh.displayName="FileBrowserSidebar";let eg=(0,r.memo)(eh);var ex=a(82987),ef=a(3738),ep=a(39284);function ej(e){let{...t}=e;return(0,l.jsx)("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...t})}function ev(e){let{className:t,...a}=e;return(0,l.jsx)("ol",{"data-slot":"breadcrumb-list",className:(0,ep.cn)("text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",t),...a})}function ey(e){let{className:t,...a}=e;return(0,l.jsx)("li",{"data-slot":"breadcrumb-item",className:(0,ep.cn)("inline-flex items-center gap-1.5",t),...a})}function eb(e){let{asChild:t,className:a,...r}=e,s=t?ex.DX:"a";return(0,l.jsx)(s,{"data-slot":"breadcrumb-link",className:(0,ep.cn)("hover:text-foreground transition-colors",a),...r})}function ew(e){let{className:t,...a}=e;return(0,l.jsx)("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:(0,ep.cn)("text-foreground font-normal",t),...a})}function eC(e){let{children:t,className:a,...r}=e;return(0,l.jsx)("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:(0,ep.cn)("[&>svg]:size-3.5",a),...r,children:null!=t?t:(0,l.jsx)(ef.default,{})})}var eN=a(17734),ek=a(99762),eI=a(45060),eF=a(96500);async function eD(e){var t;if("undefined"!=typeof navigator&&(null==(t=navigator.clipboard)?void 0:t.writeText))try{return await navigator.clipboard.writeText(e),!0}catch(e){}if("undefined"==typeof document)return!1;let a=document.createElement("textarea");a.value=e,a.setAttribute("readonly",""),a.style.top="0",a.style.left="0",a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a);try{return a.focus(),a.select(),a.setSelectionRange(0,e.length),document.execCommand("copy")}catch(e){return!1}finally{document.body.removeChild(a)}}var eS=a(32267),eA=a(20227),eE=a(30731),eO=a(22319),eR=a(96753);function eT(){let{state:e,handlers:t,contentType:a}=(0,H.ff)(),{isHeadOffice:r}=(0,ed.Sk)(),s=e.selectedFiles.length,n=String(a||"").toLowerCase(),i="template"===n||n.includes("template"),o="artwork"===n||n.includes("artwork");return 0!==s&&(i||o)?(0,l.jsx)("div",{className:"flex items-center gap-2",children:(0,l.jsxs)("div",{className:"bg-secondary text-secondary-foreground rounded-lg shadow-sm px-3 py-1.5 flex items-center gap-3",children:[(0,l.jsxs)("span",{className:"font-medium text-sm",children:["Selected Items (",s,")"]}),i&&(0,l.jsxs)(l.Fragment,{children:[r()&&(0,l.jsxs)(x.$,{onClick:()=>{t.handleBulkMoveFiles(e.selectedFiles)},size:"sm",variant:"outline",className:"min-h-11 min-w-11 text-foreground",children:[(0,l.jsx)(eE.default,{className:"h-3.5 w-3.5 mr-1.5"}),"Move"]}),(0,l.jsxs)(x.$,{onClick:()=>{t.handleBulkDuplicateFiles(e.selectedFiles)},size:"sm",variant:"outline",className:"min-h-11 min-w-11 text-foreground",children:[(0,l.jsx)(eO.default,{className:"h-3.5 w-3.5 mr-1.5"}),"Duplicate"]}),(0,l.jsxs)(x.$,{onClick:()=>{t.handleUseForArtworkMulti(e.selectedFiles)},size:"sm",className:"bg-primary text-primary-foreground hover:bg-primary/90 h-7",children:[(0,l.jsx)(eR.default,{className:"h-3.5 w-3.5 mr-1.5"}),"Use for Artwork"]})]})]})}):null}var eL=a(17869);function eP(){let{state:e,data:t,actions:a,contentType:s}=(0,H.ff)(),{selectedFiles:n,activeTab:i}=e,{artworkFiles:o}=t,d=(0,r.useMemo)(()=>o&&0!==o.length?o.map(e=>e.id):[],[o]),c=String(s||"").toLowerCase();
1if(!("template"===c||c.includes("template"))||"archived"===i||0===d.length)return null;let u=n.filter(e=>d.includes(e)).length,m=d.length>0&&u===d.length,h=u>0&&u<d.length,g=()=>{m?d.forEach(e=>{n.includes(e)&&a.toggleFileSelection(e)}):a.selectAllFiles(d)},f=h&&!m;return(0,l.jsx)("div",{className:"flex items-center gap-2",children:(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 rounded-md hover:bg-secondary/50 transition-colors",children:[f?(0,l.jsx)("div",{className:"relative h-4 w-4",children:(0,l.jsx)("input",{type:"checkbox",checked:!1,ref:e=>{e&&(e.indeterminate=!0)},onChange:g,className:"h-4 w-4 cursor-pointer rounded border-input"})}):(0,l.jsx)(eL.S,{checked:m,onCheckedChange:g,className:"h-4 w-4"}),(0,l.jsx)(x.$,{variant:"ghost",size:"sm",onClick:g,className:"h-7 px-2 text-sm font-normal hover:bg-transparent",children:m?"Deselect All":"Select All"})]})})}let e_=e=>{var t;let{activeTab:a,activeCategory:s,currentCategoryId:n,categories:i,folderPath:o,searchTerm:c,isArtwork:u,onSearchChange:m,onFolderClick:h,onCategoryClick:g,onTabChange:f}=e,{state:p,actions:j}=(0,H.ff)(),v=(0,Z.useRouter)(),y=(null==(t=i.find(e=>e.id==n))?void 0:t.name)||"Category",[b,w]=(0,r.useState)(!1),C=(0,r.useRef)(null),N=(0,r.useRef)(a),k=(0,r.useRef)(!0);(0,r.useEffect)(()=>{if(k.current){k.current=!1;return}N.current!==a&&(N.current=a,c&&m(""),["view-all","archived"].includes(a)||null===p.displayFor||j.setDisplayFor(null))},[a,c,m,p.displayFor,j]);let I=(0,r.useCallback)(async()=>{let e="".concat(window.location.origin).concat(v.asPath),t=(0,ec.$q)()?(0,eS.HL)(e):e;await eD(t)?d.oR.success("Folder link copied"):d.oR.error("Could not copy folder link",{description:t,duration:1e4})},[v.asPath]),F=b||c&&c.length>0;return(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)("div",{className:"mt-2 mb-4 flex items-center justify-between",children:[(0,l.jsx)("div",{children:"folders"===a?(0,l.jsx)(ej,{children:(0,l.jsxs)(ev,{children:[(0,l.jsx)(ey,{children:(0,l.jsx)(eb,{onClick:g,className:"cursor-pointer text-lg font-medium text-foreground hover:text-foreground",children:"all-categories"===s?"All Categories":y})}),o.map((e,t)=>(0,l.jsxs)(r.Fragment,{children:[(0,l.jsx)(eC,{className:"text-muted-foreground"}),(0,l.jsx)(ey,{children:t===o.length-1?(0,l.jsx)(ew,{className:"text-lg font-medium text-muted-foreground",children:e.name}):(0,l.jsx)(eb,{onClick:()=>{h(parseInt(e.id),e.categoryId)},className:"cursor-pointer text-lg font-medium text-foreground hover:text-foreground",children:e.name})})]},e.id))]})}):(0,l.jsxs)("div",{className:"flex items-center gap-2 text-lg font-medium text-foreground",children:[(0,l.jsx)("span",{children:"all-categories"===s?"All Categories":y}),(0,l.jsx)(ef.default,{className:"h-4 w-4 text-muted-foreground"}),(0,l.jsx)("span",{className:"text-muted-foreground capitalize",children:"view-all"===a?"View All":"recent"===a?"Recent":"archived"===a?"Archived":"Folders"})]})}),(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)(eP,{}),(0,l.jsx)(eT,{}),"view-all"===a&&(0,l.jsx)(eA.qH,{value:p.displayFor,onChange:j.setDisplayFor,selectedUserId:p.selectedUserId,selectedOrganisationId:p.selectedOrganisationId,onSelectedUserIdChange:j.setSelectedUserId,onSelectedOrganisationIdChange:j.setSelectedOrganisationId}),("view-all"===a||"archived"===a)&&(0,l.jsxs)("div",{className:"relative transition-all duration-200 ".concat(F?"w-64":"w-32"),children:[(0,l.jsx)(eN.default,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground z-10"}),(0,l.jsx)("input",{ref:C,type:"text",placeholder:"Search...",value:c,onChange:e=>m(e.target.value),onFocus:()=>w(!0),onBlur:()=>w(!1),className:"h-8 w-full pl-10 pr-3 border rounded-md bg-background text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"})]}),"folders"===a&&null!=p.currentFolderId&&(0,l.jsxs)(eF.m_,{children:[(0,l.jsx)(eF.k$,{asChild:!0,children:(0,l.jsx)(x.$,{variant:"ghost",size:"icon",className:"h-11 w-11",onClick:I,"aria-label":"Copy folder link",children:(0,l.jsx)(ek.default,{className:"h-4 w-4"})})}),(0,l.jsx)(eF.ZI,{children:"Copy folder link"})]}),(0,l.jsxs)(eI.rI,{children:[(0,l.jsx)(eI.ty,{asChild:!0,children:(0,l.jsx)(x.$,{variant:"outline",size:"sm",className:"h-8 gap-2 w-32",children:(()=>{let e=es.find(e=>e.value===a),t=null==e?void 0:e.icon;return(0,l.jsxs)(l.Fragment,{children:[t&&(0,l.jsx)(t,{className:"h-4 w-4"}),(0,l.jsx)("span",{children:(()=>{let e=es.find(e=>e.value===a);return e?e.label:"Folders"})()}),(0,l.jsx)(X.default,{className:"h-3 w-3"})]})})()})}),(0,l.jsx)(eI.SQ,{align:"end",className:"w-40",children:("all-categories"===s?es.filter(e=>"folders"!==e.value):(console.log("isArtwork isArtwork",u),u?es.filter(e=>"folders"!==e.value):es)).map(e=>{let t=e.icon;return(0,l.jsxs)(eI._2,{onClick:()=>f(e.value),className:"flex items-center gap-2 cursor-pointer",children:[(0,l.jsx)(t,{className:"h-4 w-4"}),(0,l.jsx)("span",{children:e.label})]},e.value)})})]})]})]})})};e_.displayName="FileBrowserNavigation";let eU=(0,r.memo)(e_);var eM=a(65422),eB=a(62226),ez=a(19538),eq=a(41001);function e$(e){let{isOpen:t,onClose:a,onConfirm:r,folderName:s,isPending:n}=e;return(0,l.jsx)(i.Lt,{open:t,onOpenChange:e=>{e||n||a()},children:(0,l.jsxs)(i.EO,{children:[(0,l.jsxs)(i.wd,{children:[(0,l.jsx)(i.r7,{children:"Duplicate Folder"}),(0,l.jsxs)(i.$v,{children:['Are you sure you want to duplicate the folder "',s,'"? This will create a copy of the folder along with all of its sub-folders, templates and artworks.']})]}),(0,l.jsxs)(i.ck,{children:[(0,l.jsx)(i.Zr,{onClick:a,disabled:n,children:"Cancel"}),(0,l.jsxs)(i.Rx,{onClick:e=>{e.preventDefault(),r()},disabled:n,className:"bg-primary hover:bg-primary/90 text-primary-foreground",children:[n&&(0,l.jsx)(f.default,{className:"mr-2 h-4 w-4 animate-spin"}),n?"Duplicatingâ¦":"Duplicate"]})]})]})})}let eK=(0,r.memo)(e=>{let{folder:t,onClick:a,onEdit:s,onCopyLink:n,onDuplicate:i}=e,{canEditFolders:o,canDuplicateFolders:d}=(0,ed.Sk)(),[c,u]=(0,r.useState)(!1),[m,h]=(0,r.useState)(!1),g=(0,r.useCallback)(()=>{null==a||a(t)},[t,a]),f=(0,r.useCallback)(e=>{e.stopPropagation(),null==s||s(t.id,t)},[t,s]),p=(0,r.useCallback)(e=>{e.stopPropagation(),null==n||n(t)},[t,n]),j=(0,r.useCallback)(e=>{e.stopPropagation(),u(!0)},[]),v=(0,r.useCallback)(()=>{u(!1)},[]),y=(0,r.useCallback)(async()=>
1{if(i){h(!0);try{await i(t)}finally{h(!1),u(!1)}}},[t,i]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(ez.Zp,{className:"group cursor-pointer hover:shadow-md transition-shadow duration-200 py-1 gap-1 relative",onClick:g,children:(0,l.jsxs)(ez.Wu,{className:"py-1 px-3",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,l.jsx)(J.default,{className:"h-4 w-4 text-blue-500"}),(0,l.jsx)("span",{className:"font-medium text-sm truncate",children:t.name})]}),(0,l.jsx)("div",{className:"text-xs text-muted-foreground",children:void 0!==t.itemCount?"".concat(t.itemCount," items"):"Folder"}),(0,l.jsxs)("div",{className:"absolute top-2 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[n&&(0,l.jsx)(x.$,{variant:"ghost",size:"sm",onClick:p,"aria-label":"Copy folder link",title:"Copy folder link",className:"h-6 w-6 p-0 bg-white/90 hover:bg-white shadow-sm",children:(0,l.jsx)(ek.default,{className:"h-3 w-3"})}),o()&&(0,l.jsx)(x.$,{variant:"ghost",size:"sm",onClick:f,"aria-label":"Edit folder",className:"h-6 w-6 p-0 bg-white/90 hover:bg-white shadow-sm",children:(0,l.jsx)(V.default,{className:"h-3 w-3"})}),i&&d()&&(0,l.jsx)(x.$,{variant:"ghost",size:"sm",onClick:j,"aria-label":"Duplicate folder",title:"Duplicate folder",className:"h-6 w-6 p-0 bg-white/90 hover:bg-white shadow-sm",children:(0,l.jsx)(eO.default,{className:"h-3 w-3"})})]})]})}),(0,l.jsx)(e$,{isOpen:c,onClose:v,onConfirm:y,folderName:t.name,isPending:m})]})});var eZ=a(66327);let eY=()=>(0,l.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 3xl:grid-cols-7 gap-4",children:Array.from({length:12}).map((e,t)=>(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsx)(Y.E,{className:"h-32 w-full rounded-lg"}),(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)(Y.E,{className:"h-4 w-full"}),(0,l.jsx)(Y.E,{className:"h-3 w-1/2"})]})]},t))}),eW=()=>{var e,t;let a=(0,Z.useRouter)(),{canCreateFolders:s}=(0,ed.Sk)(),{state:n,data:i,handlers:o,ui:c}=(0,H.ff)(),{activeTab:u,isInitialLoading:m,filesLoading:h,categoriesLoading:g,foldersLoading:x,error:p,searchTerm:j,currentCategoryId:v}=n,y=(0,r.useCallback)(async e=>{var t;let l=function(e){let{origin:t,pathname:a,query:l,categoryId:r,folderId:s}=e,n=new URLSearchParams;return Object.entries(l).forEach(e=>{let[t,a]=e;"category"!==t&&"folder"!==t&&"string"==typeof a&&n.set(t,a)}),null!=r&&n.set("category",String(r)),n.set("folder",String(s)),"".concat(t).concat(a,"?").concat(n.toString())}({origin:window.location.origin,pathname:a.pathname,query:a.query,categoryId:null!=(t=e.categoryId)?t:v,folderId:e.id}),r=(0,ec.$q)()?(0,eS.HL)(l):l;await eD(r)?d.oR.success("Folder link copied"):d.oR.error("Could not copy folder link",{description:r,duration:1e4})},[a.pathname,a.query,v]),{filteredFolders:b,artworkFiles:w=[],fetchNextPage:C,hasNextPage:N,loadedPagesCount:k=0}=i;console.log("PAGE DATA ",i);let I=null!=(t=null==(e=c.features)?void 0:e.hideCreate)&&t,{handleFolderClick:F,handleEditFolder:D,handleDuplicateFolder:S,handlePreviewFile:A,handleUseForArtwork:E,handleEditFile:O,handleDetailsFile:R,handleDownloadPDF:T,handleDuplicateFile:L,handleUnarchiveFile:P}=o;return p?(0,l.jsxs)(eB.Fc,{variant:"destructive",className:"mb-6",children:[(0,l.jsx)(eq.default,{className:"h-4 w-4"}),(0,l.jsxs)(eB.TN,{children:["Failed to load artwork data: ",p]})]}):m||g||x||h?(0,l.jsx)(eY,{}):(0,l.jsx)(l.Fragment,{children:(0,l.jsx)("main",{className:"pb-5",children:"folders"===u?(0,l.jsxs)("div",{className:"space-y-6",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 3xl:grid-cols-7 gap-4",children:[b.map(e=>(0,l.jsx)(eK,{folder:e,onClick:F,onEdit:D,onCopyLink:y,onDuplicate:S},e.id)),s()&&!I&&(0,l.jsx)(ez.Zp,{className:"cursor-pointer border border-dashed border-muted-foreground/30 hover:border-muted-foreground/50 transition-colors bg-muted/20 hover:bg-muted/40 py-1 gap-1",onClick:()=>o.handleCreateFolder(n.currentCategoryId,n.currentFolderId),children:(0,l.jsxs)(ez.Wu,{className:"py-1 px-3",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,l.jsx)(eR.default,{className:"h-4 w-4 text-muted-foreground"}),(0,l.jsx)("span",{className:"font-medium text-sm text-muted-foreground",children:"New Folder"})]}),(0,l.jsx)("div",{className:"text-xs text-muted-foreground",children:"Create new folder"})]})})]}),w.length>0?(0,l.jsx)(eM.A,{dataLength:w.length,next:C||(()=>{}),hasMore:null!=N&&N,loader:void 0!==N?(0,l.jsx)("div",{className:"flex justify-center py-4",children:(0,l.jsx)(f.default,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):null,endMessage:!N&&k>1?(0,l.jsx)("div",{className:"text-center py-4 text-sm text-muted-foreground",children:(0,l.jsx)("p",{children:"No more files to load"})}
1):null,scrollableTarget:"file-browser-scroll-container",children:(0,l.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 3xl:grid-cols-7 gap-4",children:[!I&&(0,l.jsx)(eZ.t,{isNewTemplate:!0,onCreateNew:()=>{var e;return null==(e=o.handleCreateFile)?void 0:e.call(o,n.currentCategoryId,n.currentFolderId)}}),w.map(e=>(0,l.jsx)(eZ.t,{file:e,onPreview:A,onUseForArtwork:E,onEdit:O,onDetails:R,onDownloadPDF:T,onDuplicate:L,onUnarchive:P},e.id))]})}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 3xl:grid-cols-7 gap-4",children:!I&&(0,l.jsx)(eZ.t,{isNewTemplate:!0,onCreateNew:()=>{var e;return null==(e=o.handleCreateFile)?void 0:e.call(o,n.currentCategoryId,n.currentFolderId)}})}),(0,l.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground min-h-[200px]",children:[(0,l.jsx)(f.default,{className:"h-12 w-12 mb-4"}),(0,l.jsx)("p",{className:"text-lg font-medium",children:"No files found"}),(0,l.jsx)("p",{className:"text-sm",children:j?"Try adjusting your search terms":"No templates or artwork files available"})]})]}),0===b.length&&0===w.length&&I&&(0,l.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,l.jsx)(eR.default,{className:"h-12 w-12 mb-4"}),(0,l.jsx)("p",{className:"text-lg font-medium",children:"No files or folders found"}),(0,l.jsx)("p",{className:"text-sm",children:j?"Try adjusting your search terms":"Create your first file or folder to get started"})]})]}):(0,l.jsx)(l.Fragment,{children:w.length>0?(0,l.jsx)(eM.A,{dataLength:w.length,next:C||(()=>{}),hasMore:null!=N&&N,loader:void 0!==N?(0,l.jsx)("div",{className:"flex justify-center py-4",children:(0,l.jsx)(f.default,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):null,endMessage:!N&&k>1?(0,l.jsx)("div",{className:"text-center py-4 text-sm text-muted-foreground",children:(0,l.jsx)("p",{children:"No more files to load"})}):null,scrollableTarget:"file-browser-scroll-container",children:(0,l.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 3xl:grid-cols-7 gap-4",children:[!I&&"archived"!==u&&(0,l.jsx)(eZ.t,{isNewTemplate:!0,onCreateNew:()=>{var e;return null==(e=o.handleCreateFile)?void 0:e.call(o,n.currentCategoryId,n.currentFolderId)}}),w.map(e=>(0,l.jsx)(eZ.t,{file:e,onPreview:A,onEdit:O,onUseForArtwork:E,onDetails:R,onDownloadPDF:T,onDuplicate:L,onUnarchive:P},e.id))]})}):(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 3xl:grid-cols-7 gap-4 mb-8",children:!I&&"archived"!==u&&(0,l.jsx)(eZ.t,{isNewTemplate:!0,onCreateNew:()=>{var e;return null==(e=o.handleCreateFile)?void 0:e.call(o,n.currentCategoryId,n.currentFolderId)}})}),(0,l.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground min-h-[300px]",children:[(0,l.jsx)(f.default,{className:"h-12 w-12 mb-4"}),(0,l.jsx)("p",{className:"text-lg font-medium",children:"No files found"}),(0,l.jsx)("p",{className:"text-sm",children:j?"Try adjusting your search terms":"No templates or artwork files available"})]})]})})})})};eW.displayName="FileBrowserContent";let eQ=(0,r.memo)(eW),eG=()=>{let{state:e,data:t,ui:a,handlers:r,contentType:s}=(0,H.ff)(),n=(0,ec.u)(),i=s===K.ur.ARTWORK||s.includes(K.ur.ARTWORK);return(0,l.jsxs)("div",{className:"flex flex-col ".concat(n?"h-screen":"h-[calc(100vh-70px)]"),children:[a.showHeader&&(0,l.jsx)("div",{className:"flex-shrink-0 px-4 pt-4 pb-2 border-b",children:(0,l.jsx)("h1",{className:"text-2xl font-semibold",children:a.title})}),(0,l.jsx)("div",{id:"file-browser-scroll-container",className:"flex-1 overflow-y-auto min-h-0",children:(0,l.jsxs)("div",{className:"px-4 py-2",children:[a.showNavigation&&(0,l.jsx)(eU,{activeTab:e.activeTab,activeCategory:e.activeCategory,currentCategoryId:e.currentCategoryId,categories:t.categories,folderPath:t.folderPath,searchTerm:e.searchTerm,isArtwork:i,searchPlaceholder:a.searchPlaceholder,onSearchChange:r.handleSearchChange,onFolderClick:r.handleNavigationFolderClick,onCategoryClick:r.handleCategoryClick,onTabChange:r.handleTabChange}),(0,l.jsx)(eQ,{})]})})]})};eG.displayName="FileBrowserMain";let eV=(0,r.memo)(eG);var eX=a(19878);class eH extends r.Component{static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("ErrorBoundary caught an error:",e,t)}
1render(){if(this.state.hasError){if(this.props.fallback){let e=this.props.fallback;return(0,l.jsx)(e,{error:this.state.error,resetError:this.resetError})}return(0,l.jsxs)(eB.Fc,{variant:"destructive",children:[(0,l.jsx)(eq.default,{className:"h-4 w-4"}),(0,l.jsxs)(eB.TN,{className:"flex items-center justify-between",children:[(0,l.jsx)("span",{children:"Something went wrong loading the folder browser."}),(0,l.jsxs)(x.$,{variant:"outline",size:"sm",onClick:this.resetError,children:[(0,l.jsx)(eX.default,{className:"h-4 w-4 mr-2"}),"Retry"]})]})]})}return this.props.children}constructor(e){super(e),this.resetError=()=>{this.setState({hasError:!1,error:void 0})},this.state={hasError:!1}}}var eJ=a(99553),e0=a(80071),e1=a(58469),e2=a(30599),e4=a(30566);let e3=()=>{let{dialogs:e,contentType:t,actions:a,state:s}=(0,H.ff)(),{user:n}=(0,F.As)(),i=(0,Z.useRouter)(),o=t===K.ur.ARTWORK||t.includes(K.ur.ARTWORK),[d,c]=(0,r.useState)(!1),{data:u}=(0,e4.os)(),{data:m}=(0,e4.YS)(),[h,g]=(0,r.useState)({isOpen:!1,previewUrl:null,fileName:""});r.useEffect(()=>{let e=e=>{let t=e.detail;g({isOpen:!0,previewUrl:t.attributes.preview_image_link,fileName:t.attributes.name})};return window.addEventListener("preview-file",e),()=>{window.removeEventListener("preview-file",e)}},[]);let x=o?e1.ArtworkArtworkClientService:e0.ArtworkFilesClientService;return(0,l.jsxs)(eH,{children:[(0,l.jsx)(e7,{}),(0,l.jsx)(S,{state:e.categoryDialog,onClose:e.handleCloseCategoryDialog,onSave:e.handleSaveCategoryDialog}),(0,l.jsx)(M,{state:e.folderDialog,onClose:e.handleCloseFolderDialog}),(0,l.jsx)(B.f,{isOpen:e.fileDialog.isOpen,isLoading:d,onClose:e.handleCloseFileDialog,contentType:e.fileDialog.fileType||t,templateId:e.fileDialog.templateId,templateData:e.fileDialog.templateData,onSubmit:async t=>{c(!0);try{var l,r,s,o,d,h,g,f,p,j;if(e.fileDialog.selectedFileIds&&e.fileDialog.selectedFileIds.length>0){let x=(null==u?void 0:u.data)||[],p=(null==m?void 0:m.data)||[],j=(0,e4.zt)(x),v=(0,e4.e6)(p);for(let a of(j["All Countries"]="",e.fileDialog.selectedFileIds))try{let e=await e0.ArtworkFilesClientService.getById(parseInt(a),"categories,folder,user,createdBy,updatedBy,deletedBy,displayForUser,displayForOrganisation,displayForCountries,displayForStates"),i=t.displayFor||e2.Lp.DISPLAY_FOR_ALL_USERS,c="Artwork for ".concat(e.data.attributes.name),u=e.data.attributes.merge_type||"property_marketing",m={name:c,status:t.status,categoryId:(null==(s=e.data.relationships)||null==(r=s.categories)||null==(l=r.data)?void 0:l.id)||t.categoryId||0,folderId:0,templateId:parseInt(a),listingId:t.listingId||0,linkedId:t.linkedId||null,linkedType:t.linkedType||null,displayFor:i,merge_type:u,data:e.data.attributes.data||"",preview_image_link:e.data.attributes.preview_image_link||"",userId:(null==n?void 0:n.id)||"",organisationId:(null==n||null==(o=n.organisation)?void 0:o.id)||"",createdBy:(null==n?void 0:n.id)||"",updatedBy:(null==n?void 0:n.id)||"",...i===e2.Lp.DISPLAY_FOR_SPECIFIC_USER&&t.selectedUserId?{selectedUserId:t.selectedUserId,displayForUser:t.selectedUserId,userOrganisationId:t.userOrganisationId||(null==n||null==(d=n.organisation)?void 0:d.id)||""}:{},...i===e2.Lp.DISPLAY_FOR_SPECIFIC_ORGANISATION&&t.selectedOrganisationId?{selectedOrganisationId:t.selectedOrganisationId,displayForOrganisation:t.selectedOrganisationId}:{},...i===e2.Lp.DISPLAY_FOR_ALL_USERS||i===e2.Lp.DISPLAY_FOR_REALTY_USERS||i===e2.Lp.DISPLAY_FOR_OASIS_USERS?{country:t.country||null,states:t.states&&t.states.length>0?t.states:null,displayForCountries:"All Countries"===t.country?null:t.country&&j[t.country]?[j[t.country]]:null,displayForStates:"All Countries"===t.country||"New Zealand"===t.country?null:t.states&&t.states.length>0?t.states.map(e=>v[e]).filter(Boolean):null}:{country:null,states:null,displayForCountries:null,displayForStates:null}};i!==e2.Lp.DISPLAY_FOR_SPECIFIC_ORGANISATION||t.selectedOrganisationId||(null==n||null==(h=n.organisation)?void 0:h.isAdminAccess)!==1||(m.selectedOrganisationId=(null==n||null==(g=n.organisation)?void 0:g.id)||"",m.displayForOrganisation=(null==n||null==(f=n.organisation)?void 0:f.id)||""),await e1.ArtworkArtworkClientService.create(m)}catch(e){console.error("Error creating artwork for template ".concat(a,":"),e)}a.clearSelection(),c(!1),e.handleCloseFileDialog(),i.push("/marketing-hub/artworks");return}if("edit"===e.fileDialog.mode&&e.fileDialog.fileId)e.fileDialog.fileType===K.ur.ARTWORK&&(x=e1.ArtworkArtworkClientService),await x.update(parseInt(e.fileDialog.fileId),t),console.log("routerrouter ",i.route),"/marketing-hub/templates"===i.route&&e.fileDialog.fileType===K.ur.ARTWORK&&i.push("/marketing-hub/artworks");else{console.log("useruser ",n);let a=e.fileDialog.templateId&&"artwork"===e.fileDialog.fileType?e1.ArtworkArtworkClientService:x,l=await a.create({...t,userId:null==n?void 0:n.id});if(console.log("ARTWOKR ID",null==(p=l.data)?void 0:p.id),e.fileDialog.templateId&&"artwork"===e.fileDialog.fileType){let e=null==(j=l.data)?void 0:j.id;e&&i.push("/marketing-hub/creative-editor/".concat(e,"?type=artwork"))}}await a.refreshData(),e.handleCloseFileDialog()}catch(e){console.error("Error saving file:",e)}finally{c(!1)}},onDelete:async t=>{c(!0);try{e.fileDialog.fileType===K.ur.ARTWORK&&(x=e1.ArtworkArtworkClientService),await x.delete(parseInt(t.id)),e.handleCloseFileDialog()}catch(e){console.error("Error archiving file:",e),alert((null==e?void 0:e.message)||"Failed to archive file. Please try again.")}finally{c(!1)}},file:e.fileDialog.fileData,defaultCategoryId:e.fileDialog.defaultCategoryId,defaultFolderId:e.fileDialog.defaultFolderId,selectedFileIds:e.fileDialog.selectedFileIds}),(0,l.jsx)($.M,{isOpen:h.isOpen,onClose:()=>{g({isOpen:!1,previewUrl:null,fileName:""})},previewUrl:h.previewUrl,fileName:h.fileName}),(0,l.jsx)(z,{state:e.bulkMoveDialog,onClose:e.handleCloseBulkMoveDialog,onConfirm:e.handleBulkMoveConfirm,selectedCount:s.selectedFiles.length,categoryId:s.currentCategoryId}),(0,l.jsx)(q,{isOpen:e.bulkDuplicateDialog.isOpen,onClose:e.handleCloseBulkDuplicateDialog,onConfirm:e.handleBulkDuplicateConfirm,selectedCount:s.selectedFiles.length,isPending:e.isBulkDuplicatePending})]})},e7=()=>{let{ui:e}=(0,H.ff)(),t=(0,ec.u)();return e.showSidebar?(0,l.jsxs)(s.GB,{className:"bg-background ".concat(t?"!min-h-screen":"!min-h-[calc(100vh-70px)]"),children:[(0,l.jsx)(eg,{}),(0,l.jsx)(s.sF,{className:t?"h-screen":"h-[calc(100vh-70px)]",children:(0,l.jsx)(eV,{})})]}):(0,l.jsx)(eV,{})},e5=e=>(0,l.jsx)(eJ.m,{...e,children:(0,l.jsx)(e3,{})});e5.displayName="FileBrowser";let e6=(0,r.memo)(e5)},65944:(e,t,a)=>{a.d(t,{w:()=>m});var l=a(37876),r=a(14232),s=a(97842),n=a(39284);let i=e=>!!e&&!!(e.closest(".bp6-popover-transition-container")||e.closest(".bp6-popover")||e.closest(".bp6-overlay-content")||e.closest("[data-radix-popper-content-wrapper]")||e.closest("[data-radix-popover-content]")||e.closest("[data-radix-select-content]")||e.closest("[data-radix-dropdown-menu-content]")||e.closest("[data-radix-portal]")||e.closest('[role="listbox"]')||e.closest('[role="menu"]')||e.closest('[role="option"]')||e.closest('[role="dialog"]')||e.hasAttribute("data-radix-popper-content-wrapper")||e.hasAttribute("data-radix-select-content")||e.hasAttribute("data-radix-popover-content")||e.classList.contains("bp6-popover-transition-container")||e.classList.contains("bp6-popover"));function o(e){let{open:t,onOpenChange:a,children:s}=e;return(r.useEffect(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&a(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,a]),t)?(0,l.jsxs)("div",{"data-slot":"fullscreen-dialog",className:"fixed inset-0 z-[100]",style:{isolation:"isolate"},children:[(0,l.jsx)("div",{"data-slot":"fullscreen-dialog-overlay",className:"fixed inset-0 bg-black/80 animate-in fade-in-0",onClick:e=>{if(i(document.elementFromPoint(e.clientX,e.clientY))||i(e.target)){e.preventDefault(),e.stopPropagation();return}a(!1)},style:{pointerEvents:"auto"}}),(0,l.jsx)("div",{"data-slot":"fullscreen-dialog-content",className:"fixed inset-0 z-10 flex h-screen w-screen flex-col overflow-hidden bg-background",onClick:e=>{e.stopPropagation()},children:s})]}):null}function d(e){let{onClick:t,className:a,...r}=e;return(0,l.jsxs)("button",{onClick:t,className:(0,n.cn)("absolute top-4 right-4 z-[300] rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",a),...r,children:[(0,l.jsx)(s.default,{className:"size-4"}),(0,l.jsx)("span",{className:"sr-only",children:"Close"})]})}function c(e){let{className:t,children:a,hideDefaultClose:r=!1,onClose:s,onOpenChange:i,...o}=e;return(0,l.jsxs)("div",{className:(0,n.cn)("h-full w-full",t),...o,children:[a,!r&&(0,l.jsx)(d,{onClick:()=>{s?s():i&&i(!1)}})]})}var u=a(52370);function m(e){let{isOpen:t,onClose:a,editorId:s,editorType:n,onRestoreUrl:i}=e,d=(0,r.useRef)(null),[m,h]=(0,r.useState)(t),[g,x]=(0,r.useState)(s),[f,p]=(0,r.useState)(n),j=(0,r.useRef)(t);(0,r.useEffect)(()=>{s&&(x(s),p(n))},[s,n]),(0,r.useEffect)(()=>{t&&!m&&g&&h(!0)},[t,m,g]),(0,r.useEffect)(()=>{let e=j.current;if(j.current=t,e&&!t&&m&&g&&f){var a;i&&i(g,f),null==(a=d.current)||a.requestClose()}},[t,m,g,f,i]);let v=e=>{if(!e){var t;null==(t=d.current)||t.requestClose()}};return g?(0,l.jsx)(o,{open:m,onOpenChange:v,children:(0,l.jsx)(c,{hideDefaultClose:!0,className:"p-0",onOpenChange:v,children:(0,l.jsx)(u.X,{ref:d,id:g,type:f,onClose:()=>{h(!1),x(null),p(void 0),a()}})})}):null}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.