import{e3 as w,aI as b,ao as r,ck as S,L as P,bk as k,bU as c,b0 as y,bc as C,az as F,f7 as D,aF as M,v as j,f as E,e as I,t as A,hL as L,o as T,p as H,W as V,r as R,E as U}from"./app-k0jcl5PQ.js";import{F as W}from"./C3DvQ1wU.chunk.js";import{u as _}from"./BCc8At9P.chunk.js";import{T as p,D as N}from"./CXQbE3g_.chunk.js";import{M as x}from"./BKH_iZiB.chunk.js";import{u as q}from"./DADIK7sb.chunk.js";import{l as g}from"./DLmnDxSd.chunk.js";import{F as O}from"./DV1GpLCe.chunk.js";import{T as $}from"./CxXrZYi8.chunk.js";import"./CW7x8M-z.chunk.js";import"./Di9d6zcy.chunk.js";import"./CKctgafI.chunk.js";import"./BDviDDog.chunk.js";import"./wCY37Ze3.chunk.js";import"./sncKO62z.chunk.js";import"./Bdp-qhf0.chunk.js";const B="myVideos.moveFolder",m=P.encloseNamespace(B),X=g.object().shape({folder:g.object().required()});function z(e){const a=w(),l=b.useMemo(()=>p.getParent(e.folders,e.folderId),[e.folders,e.folderId]);return r.jsxs(S,{children:[r.jsx(O,{label:m("parentFolder"),name:"folder",children:()=>{var t;return r.jsx(k.Scrollbars,{autoHeight:!0,autoHeightMax:300,className:"border rounded-3",children:r.jsx($,{tree:e.folders,onSelect:o=>{o&&a.setFieldValue("folder",o)},selectedIds:(t=a.values.folder)!=null&&t.id?[a.values.folder.id]:void 0,selectedLinkClassName:"bg-light",openDepth:1,isDisabled:o=>o.id===l.id,isClickDisabled:o=>o.id===e.folderId,disabledTooltip:o=>m(o.id===e.folderId?"sameFolder":"parentFolderWarning"),maxDisplayDepth:6})})}}),r.jsxs(c,{children:[r.jsx(c.Cancel,{onClick:e.onClickCancel}),r.jsx(c.Submit,{variant:"dark",showSpinner:e.showSpinner,text:m("moveFolder")})]})]})}const G="myVideos.moveFolder",u=P.encloseNamespace(G);function me(e){const[a,l]=b.useState(!1),t=y(),o=C(),s=F(D.folder(e.id)),i=F(x.workspaceWithCategories()),f=q(i.data);_(s.statusCode,i.statusCode);async function v(d){if(p.isMaxDepth(i.data,s.data.id,d.folder.id)){j.trigger({application:I.MY_VIDEOS,action:E.MyVideos.MAX_FOLDER_DEPTH,args:[N]}),e.closePopup();return}l(!0);const n=p.getParent(f,e.id);if(!n){A.throw(new L);return}try{await t(x.moveFolder({moveFolderId:s.data.id,newFolderId:d.folder.id,oldFolderId:n.id})),o.success(u("success")),e.closePopup(),T.logUserAction({id:s.data.id,name:s.data.name,newFolderId:d.folder.id,oldFolderId:n.id},{entity:U.Folder,actionType:R.Move,workflowPhase:V.Complete,location:H.Popup})}catch{o.error(u("error")),e.closePopup()}}const h=!!s.data&&!!i.data;return r.jsx(M,{title:u("title"),closePopup:e.closePopup,showLoadingSpinner:!h,children:h&&r.jsx(W,{initialValues:{folder:null},validationSchema:X,onSubmit:v,validateOnMount:!0,children:r.jsx(z,{folderId:e.id,onClickCancel:e.closePopup,folders:f,showSpinner:a})})})}export{me as MoveFolderView};
//# sourceMappingURL=DfW0WlCX.chunk.js.map
