1import{aE as P,aF as i,aC as e,b2 as le,aX as _,b3 as W,bl as ae,ei as se,dO as O,bn as y,aG as L,aD as ie,aQ as z,bV as oe,by as M,bz as B,ie as ne,c8 as de,bL as re,bi as ce,aZ as ue,aH as me,e9 as pe,b4 as N,aJ as fe,aY as he,aW as be,ig as ge,bt as xe,aN as ve,d7 as Fe,cM as je,cN as Te,cO as Ee,hW as Se,aK as ye,cr as we}from"./index-BzJG125e.js";import{d as Ie,j as De,i as Ae}from"./edit-profile-CMlm62jS.js";import{D as Ce}from"./Dropzone-CT4iAX8H.js";import{d as ke}from"./InsertDriveFileOutlined-gWxfTopV.js";import{T as _e}from"./ThemeProvider-R_WUQ_oo.js";import"./aws-D25WchR8.js";try{let s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new s.Error().stack;o&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[o]="33bcf16c-26d7-437b-92fc-d97bd73304fb",s._sentryDebugIdIdentifier="sentry-dbid-33bcf16c-26d7-437b-92fc-d97bd73304fb")}catch{}const Me={showManualFlow:!0,showTemplatePicker:!1,selectedTemplateId:null,templateSaveDisabled:!1};function Pe({enabled:s,templates:o,forceTemplateSelection:f,onStateChange:h}){const{t:b}=P(),[u,v]=i.useState("manual"),[c,g]=i.useState(null),t=s&&o.length>0,m=!!(f&&t),r=t&&(m||u==="template"),p=!t||!m&&u==="manual",j=r&&!c;return i.useEffect(()=>{(m||t)&&v("template")},[t,m]),i.useEffect(()=>{h({showManualFlow:p,showTemplatePicker:r,selectedTemplateId:c,templateSaveDisabled:j})},[p,r,c,j,h]),!s||!t?null:e.jsxs(e.Fragment,{children:[!m&&e.jsxs(le,{row:!0,value:u,onChange:a=>{v(a.target.value),g(null)},sx:{mb:2},children:[e.jsx(_,{value:"template",control:e.jsx(W,{}),label:b("file.useTemplate")}),e.jsx(_,{value:"manual",control:e.jsx(W,{}),label:b("file.enterManually")})]}),r&&e.jsxs(ae,{fullWidth:!0,sx:{mb:2},children:[e.jsx(se,{id:"file-template-label",children:b("file.selectFile")}),e.jsxs(O,{value:c??"",labelId:"file-template-label",label:b("file.selectFile"),onChange:a=>g(a.target.value),children:[e.jsx(y,{sx:{display:"none"},value:"",children:b("file.selectFile")}),o.map(a=>e.jsx(y,{value:a.id,children:e.jsx(L,{display:"flex",alignItems:"center",gap:1,children:a.fileName||a.link})},a.id))]})]})]})}function Le({onCloseClick:s,fileTemplates:o=[],templateSelectionAllowed:f,forceTemplateSelection:h,loading:b,requiresApproval:u}){const{getAccessTokenSilently:v}=ie(),{notify:c}=z(),g=oe(),{t}=P(),m=M(l=>l.account),r=M(l=>l.editProfile.apiResponse),[p,j]=i.useState(""),[a,F]=i.useState(null),[T,q]=i.useState(!1),[G,U]=i.useState(!1),[H,K]=i.useState(null),[E,w]=i.useState(!1),[I,D]=i.useState(""),[n,Y]=i.useState("file"),[S,$]=i.useState(""),[x,J]=i.useState(Me),Q=B("videoEmbed_url")||!0,A=B("videoEmbed_uploadFile")||!0,C=!!S&&!ne(S),{config:k}=de(re.HELP_RESOURCE_URLS),R=k==null?void 0:k["video-embed"],X=async l=>{const d=l[0];d&&(U(!0),ge(d).then(te=>{K(te),U(!1)}),F(d),w(!0))},Z=()=>{w(!1),F(null)},V=l=>{c.dismiss("fileuploadprogress"),c.success(t(u?"changeRequests.requestSuccess":"fileUploaded"),{id:"fileupload"}),s(),l&&je(v,Ee.PROFILE_EDIT,{type:Te.FILE_ADD},l)},ee=()=>{if(x.showTemplatePicker&&x.selectedTemplateId){const l=o.find(d=>d.id===x.selectedTemplateId);if(!l)return;g(De(l,v,d=>V(d)));return}if(n==="file"&&!T&&p.trim().length<1){D(t("nameFileerror"));return}if(E||n==="videoLink"){const l=a??new File([],"");g(Ae(m.username||"",l,p,n==="videoLink"?S:void 0,n==="videoLink"?!0:T,H,v,()=>{},d=>V(d),d=>{c.loading(`${Math.round(d*100)}%`,{id:"fileuploadprogress"})}))}};return i.useEffect(()=>{!r||r.isSuccess!==!1||(D(r.error.message||""),g(Ie()))},[r,g]),i.useEffect(()=>{n==="file"?(F(null),w(!1)):n==="videoLink"&&F(new File([],""))},[n]),e.jsxs(e.Fragment,{children:[G&&e.jsx(ce,{delayedShow:500}),e.jsxs(ue,{open:!0,onClose:s,onCancel:s,title:t("addFile"),saveAction:{text:t(u?"requestApproval":"save"),onClick:ee},withActionDivider:!0,disabled:x.templateSaveDisabled||x.showManualFlow&&(n==="file"&&(!E||!T&&p.trim().length<1)||n==="videoLink"&&(!S||C)),loading:b,children:[e.jsx(Pe,{enabled:!!f,templates:o,forceTemplateSelection:h,onStateChange:J}),x.showManualFlow&&Q&&e.jsxs(e.Fragment,{children:[e.jsxs(O,{value:n,onChange:l=>Y(l.target.value),sx:{mb:2,width:"100%"},children:[e.jsx(y,{value:"file",children:t("addFileDialog.modeFile")}),e.jsx(y,{value:"videoLink",children:t("addFileDialog.modeVideoLink")})]}),n==="videoLink"&&e.jsxs(me,{title:t("addFileDialog.embedVideoAlert.title"),variant:"outlined",severity:"info",sx:{mb:2},children:[t("addFileDialog.embedVideoAlert.content"),R?e.jsxs(e.Fragment,{children:[" ",e.jsx(pe,{i18nKey:"addFileDialog.embedVideoAlert.helpReference",components:[e.jsx("a",{href:R,target:"_blank",rel:"noreferrer",style:{color:"currentcolor",textDecoration:"underline"}},"helpArticleUrl")]})]}):null]})]}),x.showManualFlow&&e.jsx(N,{sx:{mb:2.4},label:t("addFileDialog.title"),fullWidth:!0,value:p,onChange:l=>{I&&D(""),j(l.target.value)},required:n==="file"&&!T,error:!!I,helperText:I}),x.showManualFlow&&n==="file"&&e.jsxs(e.Fragment,{children:[!E&&e.jsx(Ce,{types:A?["mp4","mov","webm","pdf","jpg","png"]:["pdf","jpg","png"],onChange:X,maxSize:A?l=>l.startsWith("video/")?500:10:10,fullWidth:!0}),E&&e.jsx(Re,{onRemove:Z,children:e.jsx(fe,{variant:"body1",children:a==null?void 0:a.name})}),A&&E&&a&&Ue(a)&&e.jsxs(L,{mt:4,display:"flex",alignItems:"center",children:[e.jsx(_,{control:e.jsx(he,{checked:T,onChange:(l,d)=>q(d)}),label:t("addFileDialog.embedVideo.label")}),e.jsx(be,{text:t("addFileDialog.embedVideo.tooltip"),icon:{color:"#111456"}})]})]}),x.showManualFlow&&n==="videoLink"&&e.jsx(N,{sx:{mb:2.4},label:t("addFileDialog.videoUrl"),fullWidth:!0,value:S,onChange:l=>$(l.target.value),required:!0,error:!!C,helperText:C?t("addFileDialog.error.invali
1dEmbedUrl"):void 0,placeholder:t("addFileDialog.embedVideo.placeholder")})]})]})}const Ue=s=>{var o;return!!((o=s.type)!=null&&o.startsWith("video/"))},Re=({onRemove:s,children:o})=>e.jsxs(xe,{sx:{py:2,px:4.5,borderStyle:"dashed",mb:1,display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",cursor:"pointer",position:"relative",width:"max-content",minWidth:"30rem",maxWidth:"100%",m:"auto",wordBreak:"break-word"},elevation:0,variant:"outlined",children:[e.jsx(ve,{size:"small",onClick:s,sx:f=>({border:`1px solid ${f.palette.divider}`,position:"absolute",top:"0.5rem",right:"0.5rem",bgcolor:f.palette.background.paper}),children:e.jsx(Fe,{fontSize:"small"})}),e.jsx(L,{mb:1.6,children:e.jsx(ke,{})}),o]});function qe({editRightAllowed:s,templateSelectionAllowed:o,forceTemplateSelection:f,fileTemplates:h,requiresApproval:b}){const{t:u}=P(),{notifyInfo:v}=z(),{theme:c}=Se(),[g,t]=i.useState(!1),m=M(a=>{var F;return(F=a.account)==null?void 0:F.files}),r=i.useMemo(()=>new Set((m??[]).map(a=>a.fileTemplateId).filter(Boolean)),[m]),p=i.useMemo(()=>(h==null?void 0:h.filter(a=>!r.has(a.id)))??[],[h,r]),j=s||f&&p.length>0;return e.jsxs(e.Fragment,{children:[e.jsx(ye,{onClick:()=>j?t(!0):v(u("adminDisabledEditRight")),startIcon:e.jsx(we,{}),"aria-label":u("ariaAddFile"),children:u("add")}),g&&c&&e.jsx(_e,{theme:c,children:e.jsx(Le,{onCloseClick:()=>t(!1),fileTemplates:p,templateSelectionAllowed:o,forceTemplateSelection:f,requiresApproval:b})})]})}export{qe as default}; 2//# sourceMappingURL=AddFileButton-CzYk1QAC.js.map
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.