1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1430],{2691:(e,t,o)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/my-storage/clean-up",function(){return o(32375)}])},12413:(e,t,o)=>{"use strict";o.d(t,{A:()=>g});var l=o(37876);o(14232);var a=o(81003),r=o(79270),n=o(80553),i=o(72907),s=o(6907),p=o(55425),d=o(65010),c=o(37830),x=o(35573);let u=e=>{let{imageUrl:t,onClose:o}=e,r=(0,s.u)(),u=(0,a.A)(e=>e.breakpoints.down("sm")),m=async e=>{try{if(!e)return;if(e.startsWith("blob:")){let t="".concat(crypto.randomUUID(),"_promptsai.png"),o=document.createElement("a");o.href=e,o.download=t,o.rel="noopener",document.body.appendChild(o),o.click(),document.body.removeChild(o);return}await (0,x.nQ)({fileUrl:e,filename:"",onSuccess:async()=>{console.log("Download success")}})}catch(e){console.error("Download failed:",e)}};return(0,l.jsxs)(n.A,{onClick:o,sx:{position:"relative","&.MuiDialogContent-root":{padding:"0 !important",borderRadius:"6px",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:u?"100dvh":"fit-content"}},children:[(0,l.jsx)(p.A,{src:t,alt:"Preview",width:600,height:600,layout:"responsive",unoptimized:!0,style:{width:"100%",height:"auto",maxWidth:"100%",maxHeight:"90vh",objectFit:"contain"}}),(0,l.jsx)(i.A,{sx:{position:"absolute",bottom:"14px",left:"0",right:"0",margin:"0 auto",width:"40px",height:"40px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:(0,d.z)(r.palette.promptsColorPalette.darkbg||"#000",.5),borderRadius:"50%",padding:"5px",zIndex:10,svg:{width:"30px",height:"30px"}},onClick:e=>{e.stopPropagation(),m(t)},children:(0,l.jsx)(c.A,{icon:"downloadStorageIcon",color:r.palette.promptsColorPalette.alwaysWhite})})]})},m=e=>{let{videoUrl:t,onClose:o}=e,r=(0,s.u)(),p=(0,a.A)(e=>e.breakpoints.down("sm")),u=async e=>{try{if(!e)return;if(e.startsWith("blob:")){let t="".concat(crypto.randomUUID(),"_promptsai.mp4"),o=document.createElement("a");o.href=e,o.download=t,o.rel="noopener",document.body.appendChild(o),o.click(),document.body.removeChild(o);return}await (0,x.nQ)({fileUrl:e,filename:"",onSuccess:async()=>{console.log("Download success")}})}catch(e){console.error("Download failed:",e)}};return(0,l.jsxs)(n.A,{onClick:o,sx:{position:"relative","&.MuiDialogContent-root":{padding:"0 !important",borderRadius:"6px",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:p?"100dvh":"fit-content"}},children:[(0,l.jsx)("video",{src:t,controls:!0,autoPlay:!0,style:{width:"100%",height:"auto",maxWidth:"100%",maxHeight:"90vh",objectFit:"contain",borderRadius:"6px"},onClick:e=>e.stopPropagation()}),(0,l.jsx)(i.A,{sx:{position:"absolute",bottom:"14px",left:"0",right:"0",margin:"0 auto",width:"40px",height:"40px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:(0,d.z)(r.palette.promptsColorPalette.darkbg||"#000",.5),borderRadius:"50%",padding:"5px",zIndex:10,svg:{width:"30px",height:"30px"}},onClick:e=>{e.stopPropagation(),u(t)},children:(0,l.jsx)(c.A,{icon:"downloadStorageIcon",color:r.palette.promptsColorPalette.alwaysWhite})})]})};var h=o(19346);let g=e=>{let{open:t,imageUrl:o,onClose:n}=e,i=(0,a.A)(e=>e.breakpoints.down("sm"));return(0,l.jsx)(r.A,{open:t,onClose:n,"aria-labelledby":"media-preview-dialog","aria-describedby":"media-preview-description",maxWidth:"sm",fullWidth:"sm",sx:{"& .MuiPaper-root":{maxWidth:i?"100dvw":"90dvw",maxHeight:i?"100dvh":"90dvh",backgroundColor:"transparent",borderRadius:"0",boxShadow:"none",display:"flex",alignItems:"center",justifyContent:"center"}},children:o&&((0,h._f)(o).startsWith("video")?(0,l.jsx)(m,{videoUrl:o,onClose:n}):(0,l.jsx)(u,{imageUrl:o,onClose:n}))})}},32375:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>G});var l=o(37876),a=o(14232),r=o(72907),n=o(84812),i=o(35003),s=o(60595),p=o(95389),d=o(66703),c=o(89099),x=o(4389),u=o(75452),m=o(54227),h=o(81003),g=o(62712),f=o(1912),C=o(39467),b=o(18952),w=o(3061),A=o(52782),j=o(60230),y=o(64266),v=o(72147),S=o(1992),P=o(24960),I=o(53206),k=o(53612),z=o(35610),D=o(35573),T=o(37830),_=o(8306
17),N=o(77898),U=o(86541),W=o(65675),R=o(22208),B=o(35705),E=o(12413),M=o(19346);function O(e){var t;let{orgId:o}=e,r=(0,u.A)(),s=(0,h.A)(e=>e.breakpoints.down("sm")),[p,d]=(0,a.useState)([]),[c,x]=(0,a.useState)(!0),[O,L]=(0,a.useState)(""),[F,G]=(0,a.useState)(""),[H,Q]=(0,a.useState)("size DESC"),[X,Y]=(0,a.useState)([]),[Z,K]=(0,a.useState)(!1),[V,q]=(0,a.useState)([]),[J,$]=(0,a.useState)({open:!1,url:""}),[ee,et]=(0,a.useState)({totalStorage:0,totalUsage:0,availableStorage:0}),[eo,el]=(0,a.useState)(0),ea=async()=>{var e;if(!o)return null;let t=await (0,I.api)({endpoint:N.p4,params:{organizationId:o}});return(0,D.lA)(t)&&(null==t||null==(e=t.data)?void 0:e.data)?t.data.data:null},{refetch:er}=(0,S.useQuery)(["ORG_STORAGE_STATS_".concat(o)],ea,{enabled:!!o,onSuccess:e=>{e&&et({totalStorage:e.totalStorage||0,totalUsage:e.totalUsage||0,availableStorage:e.availableStorage||0})}}),en=(0,a.useMemo)(()=>ee.totalStorage?ee.totalUsage/ee.totalStorage*100:0,[ee.totalStorage,ee.totalUsage]),ei=(0,a.useMemo)(()=>en>=100?r.palette.error.main:en>=85?r.palette.warning.main:r.palette.promptsColorPalette.primary,[en,r]),es=async e=>{if(null==e?void 0:e.s3Url)try{let t=await (0,D.KN)({fileUrl:e.s3Url});if(t){let o=e.s3Url.split("?")[0].split(".").pop(),l=e.fileName||"download";l.toLowerCase().endsWith(".".concat(o.toLowerCase()))&&(l=l.substring(0,l.length-o.length-1)),await (0,D.Kt)(t,l,o)}}catch(e){console.error("Download failed:",e)}},{paginationData:ep,nextPage:ed,clearPagination:ec}=(0,z.W)({perPageData:20});(0,a.useEffect)(()=>{let e=setTimeout(()=>{G(O),ec()},400);return()=>{clearTimeout(e)}},[O]);let ex=(0,a.useMemo)(()=>"MY_STORAGE_CLEANUP_".concat(o,"_").concat(F,"_").concat(H),[o,F,H]);async function eu(){var e;if(!o)return[];let t={organizationId:o,limit:20,skip:0,sort:H};F&&(t.search=F);let l=await (0,I.api)({endpoint:N.Dr,params:t});if(!(0,D.lA)(l))return ec(),[];if(l&&(null==(e=l.data)?void 0:e.data)){let e=l.data.data.listData||[];return d(e),el(l.data.data.total||0),e.length<20?x(!1):x(!0),ec(),e}}let{isFetching:em,refetch:eh}=(0,S.useQuery)([ex],eu);async function eg(){if(!o||ep.page<=1)return;let e={organizationId:o,limit:(null==p?void 0:p.length)>=20?null==ep?void 0:ep.pageSize:20,skip:(0,D.kn)(ep.page,ep.pageSize),sort:H};F&&(e.search=F);let t=await (0,I.api)({endpoint:N.Dr,params:e});if(!(0,D.lA)(t))return[];{var l,a,r,n;let e=(null==t||null==(a=t.data)||null==(l=a.data)?void 0:l.listData)||[];return d(t=>[...t,...e]),el((null==t||null==(n=t.data)||null==(r=n.data)?void 0:r.total)||0),e.length<ep.pageSize?x(!1):x(!0),e}}let{isFetching:ef}=(0,S.useQuery)(["MY_STORAGE_CLEANUP_PAGINATION_".concat(ex),null==ep?void 0:ep.page,null==ep?void 0:ep.pageSize],eg),eC=e=>{Y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},eb=async()=>{let e=V.map(e=>e.id),t=await (0,I.api)({endpoint:N.jT,payloadData:{fileIds:e,organizationId:o}});(0,D.lA)(t)&&(Y(t=>t.filter(t=>!e.includes(t))),eh(),er())};return(0,l.jsxs)(m.A,{sx:{display:"flex",flexDirection:"column",height:"100%",mt:"12px"},children:[em&&0===p.length?(0,l.jsx)(g.A,{variant:"rounded",height:"100px",sx:{mb:"24px",borderRadius:"12px"}}):(0,l.jsxs)(m.A,{sx:{p:"20px",mb:"24px",borderRadius:"12px",backgroundColor:r.palette.promptsColorPalette.newFinalBg,border:"1px solid ".concat(r.palette.promptsColorPalette.newBgColor3),display:"flex",flexDirection:"column",gap:"12px"},children:[(0,l.jsxs)(m.A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:"8px"},children:[(0,l.jsxs)(m.A,{sx:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,l.jsx)(U.A,{icon:"tabler:database",width:"20",height:"20",style:{color:r.palette.promptsColorPalette.primary}}),(0,l.jsx)(i.A,{sx:{fontWeight:600,fontSize:"15px",color:r.palette.promptsColorPalette.mainText2},children:"Storage Space Used"})]}),(0,l.jsxs)(i.A,{sx:{fontWeight:600,fontSize:"15px",color:r.palette.promptsColorPalette.mainText2},children:[(0,_.z3)(ee.totalUsage)," of ",(0,_.z3)(ee.totalStorage)," (",en.toFixed(2),"%)"]})]}),(0,l.jsx)(m.A,{sx:{width:"100%",height:"10px",borderRadius:"5px",backgroundColor:r.palette.promptsColorPalette.newBgColor3,overflow:"hidden",position:"relative"},children:(0,l.jsx)(m.A,{sx:{width:"".concat(Math.min(en,100),"%"),height:"100%",backgroundColor:ei,borderRadius:"5px",transition:"width 0.4s cubic-bezier(0.4, 0, 0.2, 1)"}})}),(0,l.jsxs)(m.A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,l.jsx)(i.A,{sx:{fontSize:"12px",color:r.palette.promptsColorPalette.subText},children:ee.availableStorage>0?"".concat((0,_.z3)(ee.availableStorage)," remaining"):"No space remaining"}),(0,l.jsxs)(i.A,{sx:{fontSize:"12px",color:r.palette.promptsColorPalette.subText},children:[eo," files"]})]})]}),(0,l.jsxs)(m.A,{sx:{display:"flex",gap:"12px",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",mb:"16px"},children:[(0,l.jsx)(m.A,{sx:{display:"flex",gap:"12px",flex:1,minWidth:s?"100%":"300px",maxWidth:s?"100%":"300px"},children:(0,l.jsx)(f.A,{size:"small",fullWidth:!0,value:O,onChange:e=>{L(e.target.value)}
1,placeholder:"Search files...",InputProps:{startAdornment:(0,l.jsx)(C.A,{position:"start",children:(0,l.jsx)(U.A,{icon:"bx:search",width:"20",height:"20",style:{color:r.palette.promptsColorPalette.subText}})}),endAdornment:O&&(0,l.jsx)(C.A,{position:"end",children:(0,l.jsx)(U.A,{icon:"bx:x",width:"20",height:"20",style:{cursor:"pointer",color:r.palette.promptsColorPalette.subText},onClick:()=>L("")})})},sx:{"& .MuiOutlinedInput-root":{borderRadius:"8px",backgroundColor:r.palette.promptsColorPalette.newFinalBg,border:"1px solid ".concat(r.palette.promptsColorPalette.newBgColor3),"& fieldset":{border:"none"},"&:hover":{border:"1px solid ".concat(r.palette.promptsColorPalette.primary)},"&.Mui-focused":{border:"1px solid ".concat(r.palette.promptsColorPalette.primary)}},"& .MuiInputBase-input":{color:r.palette.promptsColorPalette.mainText2}}})}),(0,l.jsxs)(m.A,{sx:{display:"flex",gap:"12px",alignItems:"center",width:s?"100%":"auto"},children:[(0,l.jsxs)(b.A,{size:"small",sx:{minWidth:"150px"},children:[(0,l.jsx)(w.A,{id:"sort-select-label",sx:{color:r.palette.promptsColorPalette.subText},children:"Sort By"}),(0,l.jsxs)(A.A,{labelId:"sort-select-label",value:H,label:"Sort By",onChange:e=>{Q(e.target.value),ec()},sx:{borderRadius:"8px",backgroundColor:r.palette.promptsColorPalette.newFinalBg,color:r.palette.promptsColorPalette.mainText2,"& .MuiOutlinedInput-notchedOutline":{borderColor:r.palette.promptsColorPalette.newBgColor3},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:r.palette.promptsColorPalette.primary},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:r.palette.promptsColorPalette.primary}},children:[(0,l.jsx)(j.A,{value:"size DESC",children:"Size (Large - Small)"}),(0,l.jsx)(j.A,{value:"size ASC",children:"Size (Small - Large)"}),(0,l.jsx)(j.A,{value:"fileName ASC",children:"Name (A - Z)"}),(0,l.jsx)(j.A,{value:"fileName DESC",children:"Name (Z - A)"}),(0,l.jsx)(j.A,{value:"createdAt DESC",children:"Date (Newest - Oldest)"}),(0,l.jsx)(j.A,{value:"createdAt ASC",children:"Date (Oldest - Newest)"})]})]}),p.length>0&&X.length?(0,l.jsx)(n.A,{variant:"outlined",size:"medium",onClick:()=>{X.length?Y([]):Y(p.map(e=>e.id))},sx:{borderRadius:"8px",borderColor:r.palette.promptsColorPalette.newBgColor3,color:r.palette.promptsColorPalette.mainText2,textTransform:"none","&:hover":{borderColor:r.palette.promptsColorPalette.primary,backgroundColor:r.palette.promptsColorPalette.newBgColor3}},children:"Cancel"}):null,X.length>0&&(0,l.jsxs)(n.A,{variant:"contained",color:"error",size:"medium",onClick:()=>{q(p.filter(e=>X.includes(e.id))),K(!0)},startIcon:(0,l.jsx)(U.A,{icon:"tabler:trash"}),sx:{borderRadius:"8px",textTransform:"none",boxShadow:"none","&:hover":{boxShadow:"none"}},children:["Delete Selected (",X.length,")"]})]})]}),em?(0,l.jsx)(m.A,{sx:{display:"flex",flexDirection:"column",gap:"8px"},children:Array.from({length:6}).map((e,t)=>(0,l.jsx)(g.A,{variant:"rounded",height:"64px",width:"100%"},t))}):(0,l.jsxs)(m.A,{className:"common-scroll",sx:{display:"flex",flexDirection:"column",flex:"1",overflowX:"hidden",maxHeight:"calc(100dvh - 240px)",minHeight:"calc(100dvh - 240px)"},children:[p&&p.length>0?(0,l.jsx)(m.A,{sx:{display:"flex",flexDirection:"column",gap:"8px"},children:p.map((e,t)=>{let o=X.includes(e.id),a=e.createdAt?new Date(1e3*e.createdAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"N/A";return(0,l.jsxs)(m.A,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",borderRadius:"8px",border:o?"1px solid ".concat(r.palette.promptsColorPalette.primary," !important"):"1px solid ".concat(r.palette.promptsColorPalette.newBgColor3," !important"),background:o?"".concat(r.palette.promptsColorPalette.newBgColor3," !important"):"".concat(r.palette.promptsColorPalette.newFinalBg," !important"),padding:"10px 14px",transition:"all 0.2s ease-in-out","&:hover":{border:"1px solid ".concat(r.palette.promptsColorPalette.primary," !important"),transform:"translateX(4px)"}},children:[(0,l.jsxs)(m.A,{sx:{display:"flex",alignItems:"center",gap:"12px",overflow:"hidden",flex:1},children:[(0,l.jsx)(y.A,{checked:o,onChange:()=>eC(e.id),size:"small",sx:{color:r.palette.promptsColorPalette.newBgColor3,"&.Mui-checked":{color:r.palette.promptsColorPalette.primary}}}),(0,l.jsx)(m.A,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:"36px",height:"36px",borderRadius:"6px",backgroundColor:o?"rgba(0, 0, 0, 0.15)":"rgba(0, 0, 0, 0.05)","& svg":{width:"22px",height:"22px"}},children:(0,l.jsx)(T.A,{icon:(0,_.RG)((0,M._f)(null==e?void 0:e.s3Url)),color:o?r.palette.promptsColorPalette.primary:r.palette.promptsColorPalette.mainText2})}),(0,l.jsxs)(m.A,{sx:{display:"flex",flexDirection:"column",overflow:"hidden",flex:1},children:[(0,l.jsx)(W.A,{title:null==e?void 0:e.fileName,children:(0,l.jsx)(i.A,{sx:{maxWidth:"100%",width:"fit-content",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"14px",fontWeight:"600",display:"inline-block",color:r.palette.promptsColorPalette.mainText2},children:e.fileName||"file_".concat(t)})}),(0,l.jsxs)(i.A,{sx:{fontSize:"11px",color:r.palette.promptsColorPalette.subText,display:"flex",gap:"6px",alignItems:"center",mt:"2px",flexWrap:"wrap"},children:[(0,l.jsx)("span",{style:{textTransform:"uppercase",fontWeight:"600"},children:(0,D.D4)(null==e?void 0:e.s3Url,13,"FILE")}),(0,l.jsx)("span",{children:"â¢"}),(0,l.jsx)("span",{children:(0,_.z3)((null==e?void 0:e.size)||0)}),(0,l.jsx)("span",{children:"â¢"}),(0,l.jsxs)("span",{children:["Uploaded: ",a]}),(null==e?void 0:e.userId)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("span",{children:"â¢"}),(0,l.jsxs)("span",{children:["By: ",e.userId.firstName," ",e.userId.lastName]})]})]})]})]}),(0,l.jsx)(m.A,{sx:{display:"flex",alignItems:"center"},children:(0,l.jsx)(B.A,{iconButtonProps:{size:"small",sx:{color:r.palette.promptsColorPalette.mainText2}},options:[...(e=>{if(!(null==e?void 0:e.s3Url))return!1;let t=(0,M._f)(e.s3Url);return t.startsWith("image")||t.startsWith("video")})(e)?[{text:"View",menuItemProps:{onClick:()=>$({open:!0,url:e.s3Url})}}]:[],{text:"Download",menuItemProps:{onClick:()=>es(e)}},{text:o?"Deselect":"Select",menuItemProps:{onClick:()=>eC(e.id)}},{text:"Delete",menuItemProps:{sx:{color:"error.main"},onClick:()=>{q([e]),K(!0)}}}]})})]},e.id||t)})}):(0,l.jsx)(m.A,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,minHeight:"200px"},children:(0,l.jsx)(k.A,{img:"light"===r.palette.mode?"/images/emptyImage/auditLog-Light.svg":"/images/emptyImage/auditLog.svg",title:"No documents found"})}),(0,l.jsx)(P.Y,{bottomOffset:-50,onEnter:()=>{p.length>=ep.pageSize&&!ef&&!em&&c&&ed()}}),ef&&(0,l.jsx)(m.A,{sx:{justifyContent:"center",display:"flex",alignItems:"center",pt:"10px"},children:(0,l.jsx)(v.A,{size:24,color:"secondary"})})]}),(0,l.jsx)(R.A,{isShowDelete:Z,setIsShowDelete:K,submitEvent:eb,headingText:"Delete Storage Files",modalTitleName:1===V.length?'Are you sure you want to delete the file "'.concat(null==(t=V[0])?void 0:t.fileName,'"? This action is permanent and cannot be undone.'):"Are you sure you want to delete the ".concat(V.length," selected files? This action is permanent and cannot be undone.")}),(0,l.jsx)(E.A,{open:J.open,imageUrl:J.url,onClose:()=>$({open:!1,url:""})})]})}var L=o(59456);let F=()=>{let e=(0,d.A)(),t=(0,c.useRouter)(),{defaultOrganizationId:o}=(0,x.Z)();return(0,l.jsxs)(r.A,{sx:{p:6},children:[(0,l.jsxs)(r.A,{sx:{display:"flex",alignItems:"center",gap:"12px",mb:"24px"},children:[(0,l.jsx)(n.A,{variant:"outlined",size:"small",onClick:()=>t.back(),sx:{minWidth:"40px",width:"40px",height:"40px",borderRadius:"8px",borderColor:e.palette.promptsColorPalette.newBgColor3,color:e.palette.promptsColorPalette.mainText2,p:0,"&:hover":{borderColor:e.palette.promptsColorPalette.primary,backgroundColor:e.palette.promptsColorPalette.newBgColor3}},children:(0,l.jsx)(U.A,{icon:"tabler:arrow-left"})}),(0,l.jsxs)(r.A,{children:[(0,l.jsx)(i.A,{variant:"h5",sx:{fontWeight:700,fontSize:"24px",color:e.palette.promptsColorPalette.mainText},children:"Cleanup Storage"}),(0,l.jsx)(i.A,{variant:"body2",sx:{color:e.palette.promptsColorPalette.subText,fontSize:"14px",mt:"4px"},children:"Manage and clean up your organization storage by deleting unwanted or large files."})]})]}),(0,l.jsx)(s.A,{sx:{borderRadius:"12px",backgroundColor:e.palette.promptsColorPalette.cardBg,border:"1px solid ".concat(e.palette.promptsColorPalette.borderColor),boxShadow:"0px 4px 18px 0px rgba(0, 0, 0, 0.03)"},children:(0,l.jsx)(p.A,{sx:{p:"24px !important"},children:o?(0,l.jsx)(O,{orgId:o}):(0,l.jsx)(i.A,{sx:{color:e.palette.promptsColorPalette.subText},children:"No active organization found."})})})]})};F.acl={action:"read",subject:L.eu.ALL_PROMPT_ENG};let G=F}},e=>{e.O(0,[636,6593,8792],()=>
1e(e.s=2691)),_N_E=e.O()}]);
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.