import{d as K,r as C,b as q,e as R,y as oe,p as W,a$ as b,f as e,k as y,L as z,b0 as H,C as le,j as w,w as P,Q as J,S as X,N as ne,v as Q,aC as se,g as $,h as ue,F as ie,l as re,B as ce,b1 as de,P as Y}from"./index-27f38392-1715840129614.js";import{u as pe}from"./catchData-ee7bbce5-1715840129614.js";import{v as fe,x as me,y as Z,z as ge,A as ye,B as ve,D as be}from"./api-4261a394-1715840129614.js";import{C as Ae,g as V,a as ee,o as he}from"./index-53b18b72-1715840129614.js";import{i as Fe}from"./index-28ccaf7b-1715840129614.js";import{N as Ce}from"./Scrollbar-b72aeac2-1715840129614.js";import{N as Be}from"./Cascader-1e2d657d-1715840129614.js";const Ie="_uploadModal_eir1m_1",Se="_formModal_eir1m_4",_e="_formSpace_eir1m_8",we="_previewModal_eir1m_11",Ee="_image_eir1m_23",Ue="_titleType_eir1m_32",ke="_iconUploadDelete_eir1m_40",De="_commonType_eir1m_55",Ne="_changeCover_eir1m_74",Me="_formItem_eir1m_91",Ge="_btnGroup_eir1m_116",Te="_uploadFile_eir1m_123",xe="_uploadBtn_eir1m_130",Oe="_iconUploadAdd_eir1m_147",Re="_uploadCover_eir1m_152",F={uploadModal:Ie,formModal:Se,formSpace:_e,previewModal:we,image:Ee,titleType:Ue,iconUploadDelete:ke,commonType:De,changeCover:Ne,formItem:Me,btnGroup:Ge,uploadFile:Te,uploadBtn:xe,iconUploadAdd:Oe,uploadCover:Re},Pe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAAAXNSR0IArs4c6QAAA3xJREFUaEPdmk1oE1EQgL/8qQVRVATxoCIqRURBBIsHKQZqTqJgIR4EPUgbf+6Fpoq2hd79IUWwggcDFRRPsRApHkRBBEVEVEQ9iCAqilBt/syE3bJds9l922xa38Ke9r2Z+d6bmZ15uyE0u0It4BEdUUNPEagEqbPZQG3AemAtsNy4F9kApoEfxv0J+ABMNQuyGUBLgY3ABmCNT8M+A++Bd8AvnzJq0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_headerItem_t4tbc_42",Qe="_uploadContainer_t4tbc_59",$e="_imgCropperSection_t4tbc_85",Ye="_uploadBtnGroup_t4tbc_92",_={uploadFile:je,uploadBtn:Ve,iconUploadAdd:Le,uploadHeader:Ke,headerItem:qe,uploadContainer:Qe,imgCropperSection:$e,uploadBtnGroup:Ye},Ze=K({name:"upload-file",props:{img:{type:String,default:""},accept:{type:String,default:".jpg,.png,.jpeg,.gif"},bucketName:{type:String,default:"gyt"},path:{type:String,default:""},fileName:{type:String,default:""},options:{type:Object,default:()=>({viewMode:0,autoCrop:!0,enlarge:1,autoCropWidth:640,autoCropHeight:360,fixedBox:!1,previewsCircle:!0,title:"上传图片"})}},emits:["close","confirm"],setup(a,{emit:A}){const I=C(),E="https://".concat(a.bucketName,".ks3-cn-beijing.ksyuncs.com/"),k=q(),n=C(!1),m=C(!1),M=C(),h=C({img:"",autoCrop:!0,autoCropWidth:180,autoCropHeight:180,fixedBox:!0,full:!1,enlarge:1,previewsCircle:!0,centerBox:!0,outputType:"png",title:"修改头像",name:null}),v=R({myCropper:null,cropperReady:!1}),S=async f=>{const d=f.file;let g=!0;if((d.type.includes("image")?b.IMG:d.type.includes("audio")?b.SONG:b.VIDEO)!==b.IMG)return k.error("上传文件格式错误"),!1;const N=10;return g=d.file.size/1024/1024{p(T,d.file.name)}),!1):(k.error("图片大小不能超过".concat(N,"M")),!1)},G=async(f,d)=>{const g=new FileReader;g.addEventListener("load",()=>d(g.result)),g.readAsDataURL(f)},p=(f,d)=>{const g=Object.assign({},a.options,{img:f,name:d});n.value=!0,h.value=Object.assign({},h.value,g),J(()=>{o()})},o=()=>{try{v.cropperReady=!0,v.myCropper=new Ae(I.value,{viewMode:1,dragMode:"move",aspectRatio:h.value.autoCropWidth/h.value.autoCropHeight,initialAspectRatio:1,autoCropArea:1,cropBoxMovable:!0,cropBoxResizable:!0,background:!0,movable:!1,modal:!0,preview:".before",ready:()=>{v.cropperReady=!1}})}catch(f){}},l=()=>{v.myCropper.getCroppedCanvas({imageSmoothingQuality:"high"}).toBlob(f=>{m.value=!0,r(f)})},r=async f=>{try{const d="".concat(a.path).concat(a.fileName||new Date().getTime()+".png"),g={filename:d,bucketName:a.bucketName,postData:{filename:d,acl:"public-read",key:d}},{data:D}=await V(g),N={policy:D.policy,signature:D.signature,acl:"public-read",key:d,KSSAccessKeyId:D.kssAccessKeyId,name:d,file:f},T=await ee(E,N);A("confirm",T),A("close")}catch(d){}m.value=!1};return oe(()=>a.img,()=>{a.img&&L(a.img)===b.IMG&&p(a.img)}),W(()=>{a.img&&L(a.img)===b.IMG&&p(a.img)}),()=>e("div",{class:_.uploadFile},[e("div",{class:_.uploadHeader},[e("div",{class:_.headerItem},[y("上传封面")])]),n.value?e("div",{class:_.uploadContainer},[e(le,{show:v.cropperReady},{default:()=>{var f,d,g;return[e("div",{class:_.imgCropperSection},[((f=h.value)==null?void 0:f.img)&&e("img",{ref:I,src:(d=h.value)==null?void 0:d.img,style:{opacity:(g=v.myCropper)!=null&&g.ready?"1":"0"},alt:""},null)])]}})]):e("div",{class:_.uploadContainer},[e(z,{ref:M,accept:a.accept,multiple:!1,max:1,showFileList:!1,showPreviewButton:!0,onBeforeUpload:f=>S(f)},{default:()=>[e(H,null,{default:()=>[e("div",{class:_.uploadBtn},[e("img",{src:Fe,class:_.iconUploadAdd},null),e("p",null,[y("点击或将图片拖至此区域")]),e("span",null,[y("(建议比例16:9)")])])]})]})]),e("div",{class:_.uploadBtnGroup},[n.value?e(w,{type:"default",onClick:()=>{h.value.img="",n.value=!1}},{default:()=>[y("重新选择")]}):e("span",null,null),e(P,null,{default:()=>[e(w,{type:"default",onClick:()=>A("close")},{default:()=>[y("取消")]}),e(w,{type:"primary",onClick:()=>l(),disabled:!n.value,loading:m.value},{default:()=>[y("保存封面")]})]})])])}});function We(a){return typeof a=="function"||Object.prototype.toString.call(a)==="[object Object]"&&!ce(a)}const L=a=>a?(a==null?void 0:a.indexOf(".mp3"))>-1?b.SONG:(a==null?void 0:a.indexOf(".mp4"))>-1?b.VIDEO:(a==null?void 0:a.indexOf(".ppt"))>-1?b.PPT:b.IMG:"",ut=K({name:"upload-modal",props:{list:{type:Array,default:()=>[]},showDelete:{type:Boolean,default:!1},editStatus:{type:Boolean,default:!0}},emits:["close","confirm","editAll"],setup(a,{emit:A}){const I=pe(),E=C(),k=q(),n=R({list:[],uploading:!1,uploadUrl:"",name:"",instrumentIds:[]}),m=R({uploadCoverStatus:!1,uploadType:"",uploadImg:null,uploadIndex:0}),M=p=>{let o=Z;switch(p){case"IMG":o=Z;break;case"VIDEO":o=be;break;case"SONG":o=ve;break;case"MUSIC":o=ye;break;case"PPT":o=ge;break}return o},h=async()=>{var p;(p=E.value)==null||p.validate(async o=>{if(o){J(de);return}n.uploading=!0;try{const l=[];if(n.list.forEach(r=>{l.push({instrumentIds:r.instrumentIds.join(","),openFlag:r.openFlag,coverImg:r.coverImg,name:r.name,type:r.type,enableFlag:1,content:r.content,id:r.id||null})}),S.value){if(a.editStatus)A("editAll",l);else{const{data:r}=await fe(l);k.success("保存成功"),n.list=[],A("close",!0),A("confirm",r)}n.list=[]}else await me(l),k.success("保存成功"),n.list=[],A("close",!0),A("confirm")}catch(l){}n.uploading=!1})},v=p=>{n.list.splice(p,1)},S=X(()=>a.list.length>0);W(async()=>{const p=a.list||[],o=[];p.forEach(l=>{o.push({instrumentIds:l.instrumentIds?l.instrumentIds.split(",").map(r=>r):[],openFlag:l.openFlag,coverImg:l.coverImg,name:l.title,type:l.type,sourceFrom:l.sourceFrom,enableFlag:l.enableFlag,content:l.content,id:l.id})}),n.list=o||[],await I.getSubjects()});const G=(p,o)=>{const l=[];o.map(r=>{Array.isArray(r.instruments)&&r.instruments.forEach(f=>{l.push(f.value)})}),p.instrumentIds=l};return()=>{let p;return e("div",{class:F.uploadModal},[e(Ce,{style:{"max-height":"55vh"}},{default:()=>[e(ne,{ref:E,labelPlacement:"left",labelWidth:120,model:n,class:F.formModal},{default:()=>[e(P,{class:F.formSpace},We(p=n.list.map((o,l)=>e("div",{class:F.formItem,key:l},[e("div",{class:F.previewModal},[e(Q,{class:[F.titleType],src:M(o.type),previewDisabled:!0,objectFit:"cover"},null),(!S.value||a.showDelete)&&e("img",{class:[F.iconUploadDelete],src:Pe,onClick:()=>v(l)},null),e(Q,{class:[F.cover,F.image],lazy:!0,previewDisabled:!0,src:o.coverImg,objectFit:"cover"},null),e("div",{class:F.commonType},[o.type!=="IMG"?e(w,{class:F.changeCover,type:"default",bordered:!1,onClick:()=>{m.uploadIndex=l,m.uploadImg=o.coverImg,m.uploadType=o.type,m.uploadCoverStatus=!0}},{default:()=>[y("更换封面")]}):e("span",null,null),e("div",null,[y("是否公开"),e(se,{size:"small",value:o.openFlag,"onUpdate:value":r=>o.openFlag=r,disabled:o.sourceFrom==="TEACHER"&&o.type==="MUSIC"},null)])])]),e($,{showFeedback:!1,path:"list.".concat(l,".name"),rule:[{required:!0,message:"请输入资源名称",trigger:["input","blur"]}]},{default:()=>[e(ue,{value:o.name,"onUpdate:value":r=>o.name=r,placeholder:"请输入资源名称",maxlength:25,clearable:!0},null)]}),e($,{path:"list[".concat(l,"].instrumentIds"),showFeedback:!1,rule:[{required:!0,message:"请选择素材可用乐器",trigger:"change",type:"array"}]},{default:()=>[e(Be,{value:o.instrumentIds,"onUpdate:value":r=>o.instrumentIds=r,placeholder:"请选择素材可用乐器(可多选)",options:I.getEnableSubjects,checkStrategy:"child",showPath:!1,childrenField:"instruments",expandTrigger:"hover",labelField:"name",valueField:"id",clearable:!0,filterable:!0,multiple:!0,maxTagCount:"responsive"},{action:()=>e(ie,null,[e(w,{text:!0,style:" --n-width: 100% ",onClick:()=>G(o,I.getEnableSubjects)},{default:()=>[y("全选")]})])})]})])))?p:{default:()=>[p]})]})]}),e(P,{class:F.btnGroup,justify:"center"},{default:()=>[e(w,{round:!0,onClick:()=>A("close")},{default:()=>[a.editStatus?"取消":"上一步"]}),e(w,{round:!0,type:"primary",loading:n.uploading,disabled:n.list.length===0,onClick:h},{default:()=>[y("确定")]})]}),e(re,{show:m.uploadCoverStatus,"onUpdate:show":o=>m.uploadCoverStatus=o,preset:"card",showIcon:!1,class:["modalTitle ",F.uploadCover],blockScroll:!1},{default:()=>[e(Ze,{img:m.uploadImg,onClose:()=>m.uploadCoverStatus=!1,onConfirm:o=>{m.uploadType==="IMG"&&(n.list[m.uploadIndex].content=o),n.list[m.uploadIndex].coverImg=o}},null)]})])}}}),ze="_saveModal_ulplg_1",He="_uploadBtn_ulplg_25",Je="_iconUploadAdd_ulplg_47",Xe="_btnGroup_ulplg_57",O={saveModal:ze,uploadBtn:He,iconUploadAdd:Je,btnGroup:Xe},it=K({name:"save-modal",props:{fileList:{type:String,default:""},imageList:{type:Array,default:()=>[]},accept:{type:String,default:".jpg,.png,.jpeg,.gif"},showType:{type:String,default:"default"},showFileList:{type:Boolean,default:!0},max:{type:Number,default:1},multiple:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},bucketName:{type:String,default:"gyt"},directoryDnd:{type:Boolean,default:!1},path:{type:String,default:""},fileName:{type:String,default:""}},emits:["close","confrim"],setup(a,{emit:A}){const I="https://".concat(a.bucketName,".ks3-cn-beijing.ksyuncs.com/"),E=q(),k=C(!1),n=C(!1),m=C(),M=C(),h=R([]),v=C([]),S=C([]);function G(t){return t.slice((t.lastIndexOf(".")-1>>>0)+2)}function p(t,s){const i=G(t).toLowerCase();return s.includes(i)}const o=async t=>{const s=t.file;let i=!0;const u=["jpg","jpeg","png","mp4","ppt","pptx","mp3"];if(!p(s.file.name,u))return E.error("文件格式不支持"),!1;const c=s.type.includes("image")?b.IMG:s.type.includes("audio")?b.SONG:s.type.includes("video")?b.VIDEO:s.type.includes("vnd.openxmlformats-officedocument.presentationml.presentation")||s.type.includes("vnd.ms-powerpoint")?b.PPT:"other";if(c==="other")return E.error("文件格式不支持"),!1;const B=c==="IMG"?2:c==="SONG"?20:500;if(B&&(i=s.file.size/1024/1024{r(t)},r=async t=>{console.log(t,"onFinishAfter");const s=h.find(c=>c.id==t.file.id),i=L(t.file.url);let u="";i==="IMG"?u=t.file.url:i==="SONG"?u=Y.SONG_DEFAULT_COVER:i==="PPT"?u=Y.PPT_DEFAULT_COVER:i==="VIDEO"&&(u=await d(s.tempFiileBuffer)),S.value.push({coverImg:u,content:t.file.url,id:t.file.id,name:t.file.name?t.file.name.slice(0,t.file.name.lastIndexOf(".")):""}),k.value=!1,n.value=!1},f=t=>new Promise((s,i)=>{const u=document.createElement("video");u.setAttribute("crossOrigin","Anonymous"),u.setAttribute("preload","auto"),u.muted=!0,u.autoplay=!0,u.src=URL.createObjectURL(t),u.addEventListener("loadedmetadata",()=>{u.play(),setTimeout(()=>{u.currentTime=0,u.pause();const c=document.createElement("canvas");c.width=u.videoWidth,c.height=u.videoHeight,c.getContext("2d").drawImage(u,0,0,c.width,c.height),c.toBlob(B=>{s(B)})},500)}),u.addEventListener("error",c=>{i(c)})}),d=async t=>{try{n.value=!0;const s=await f(t||m.value),i="".concat(a.path).concat(Date.now()+".png"),u={filename:i,bucketName:a.bucketName,postData:{filename:i,acl:"public-read",key:i,unknowValueField:[]}},{data:c}=await V(u),B={policy:c.policy,signature:c.signature,key:i,acl:"public-read",KSSAccessKeyId:c.kssAccessKeyId,name:i,file:s};return await ee(I,B)}finally{n.value=!1}},g=async t=>{const s=S.value.findIndex(i=>i.id===t.file.id);return S.value.splice(s,1),n.value=!1,!0},D=X(()=>{let t=!1;return v.value.forEach(s=>{s.status!=="finished"&&(t=!0)}),t||v.value.length<=0}),N=({file:t,action:s,onFinish:i,onError:u,onProgress:c})=>{const B=h.find(U=>U.id==t.id);B.file=t,he({file:t,action:s,data:B,onProgress:c,onFinish:i,onError:u})},T=async()=>{const t=[];v.value.forEach(s=>{const i=S.value.find(u=>u.id===s.id);i&&t.push(i)}),A("confrim",t)};return()=>e("div",{class:O.saveModal},[e(z,{ref:M,action:I,customRequest:N,fileList:v.value,"onUpdate:fileList":t=>v.value=t,accept:".jpg,jpeg,.png,audio/mp3,video/mp4,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation",multiple:!0,max:10,showFileList:!0,showPreviewButton:!0,onBeforeUpload:t=>o(t),onFinish:t=>{l(t)},onRemove:t=>g(t)},{default:()=>[e(H,null,{default:()=>[e("div",{class:O.uploadBtn},[e("div",{class:O.iconUploadAdd},null),e("h3",null,[y("点击或者拖动文件到该区域来上传")]),e("p",null,[y("仅支持JPG、PNG、MP3、MP4、PPT格式文件,单次最多支持"),e("br",null,null),y("上传10个文件")])])]})]}),e(P,{class:O.btnGroup,justify:"center"},{default:()=>[e(w,{round:!0,onClick:()=>A("close")},{default:()=>[y("取消")]}),e(w,{round:!0,type:"primary",disabled:D.value||n.value,onClick:T},{default:()=>[y("确定")]})]})])}});export{it as S,ut as U,L as f};