import{s as n,r as A,p as h,b}from"./index.9e4b607f.js";import{d as v,T as c,af as U,ao as D,a,K as p,F as w,a9 as y}from"./vendor.3506a68e.js";/* empty css               *//* empty css              *//* empty css                */import"./index.dc64d189.js";const z="_uploader_22hbs_1",V="_uploaderText_22hbs_53",k="_uploadImg_22hbs_58";var d={"uploader-section":"_uploader-section_22hbs_1","img-close":"_img-close_22hbs_9","col-uploader":"_col-uploader_22hbs_24",uploader:z,uploaderText:V,uploadImg:k},g="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAAAyCAMAAAAz3ZgNAAAAAXNSR0IArs4c6QAAAV9QTFRFAAAA////////qqqq////v7+/29vb39/fzMzM5ubm6Ojo1dXV6urq6+vr39/f4+Pj5OTk3t7e4ODg4eHh29vb4+Pj3d3d4+Pj4eHh4uLi3d3d3t7e3t7e39/f4ODg3d3d3t7e39/f4ODg39/f3Nzc3d3d39/f4ODg3t7e4eHh39/f3t7e39/f3t7e3t7e4ODg3t7e3d3d39/f39/f39/f4ODg39/f3d3d3t7e39/f3d3d3t7e4ODg3t7e39/f3t7e3t7e3d3d4ODg39/f3d3d3t7e3t7e39/f3d3d39/f3t7e3t7e39/f3d3d3t7e3t7e3t7e39/f3t7e3d3d39/f3t7e3t7e39/f39/f39/f3t7e3t7e3t7e3t7e39/f3t7e39/f3t7e39/f3t7e3t7e3d3d39/f39/f3t7e3t7e3t7e3t7e3t7e3t7e3t7e3d3d3t7e3t7e3t7e39/f3t7eiTfdtAAAAHR0Uk5TAAECAwMEBwgKCgsMDA0QEhMXISIjJCUlKiwtLi8wMTQ2Nzk/QUxPU1RUWF5gY2RrbG9vcHFydnh7f4CCi5GRkpWYoqWnqaqur6+ztLW2t7i5ubq9vr/BxsfW2Nna293e3uPk5+nr7e7x8/X29/j5+vr9/v6jM+nnAAABy0lEQVRIx+3WZ1PCQBAG4AURG6gQu6goIPaGvVcQewEbYi9YUND9/2M4owFySS7nB8cZ309LZp/hkmxmFsBY/PGH7RrgjSeNiBdlOddq5+NJ1Mzb3U6XKdO6TH62Z+vhV2TJll3sjZCyP0sPIWOOCgGi+Vx4YeU4SuGzzBpDFH7C4BJTDSVms9lE4c/6Oub87lZwff0kjonQN0BySq4ESd3fUSrz5EJbua11jjIAMwDd9Lk4r/7iV+7PwzRdKpq84HhUOdiuxJPur5tpUvyRAD61+0pKfEF+GHP5Pc3gUuNxibfJvDW/JwCwRNdpv8TLZW7LbzqzgmVoLRrJ5P7zTWbKaGTFAwwcFwv03rvW4RH3G3S41qMT8368EVoNj8ncHM7hWi+O9slYMHdoNcaGhWsMrZIPKDlDNgG2SNEDxRw8BjBIDloFdRwcG8Eizt9jN8AkD98X58flcwA4EzwcF63E1MSQi+NZoFnwzjwhJ5fzz/8QD17+iHcVjdxKZYqHA9gnEqQ84OMAldPizF7X83IAR19vBfDz7PwufzbAO5X8xABvUXIDi9lNoZIbWAvHaUtygFUfWqlL9nCKSe9VqCzp+gt5+mbdb6LRD+7pAfpKTznkAAAAAElFTkSuQmCC",x=v({name:"ColUploadVideo",props:{modelValue:String,posterUrl:String,tips:{type:String,default:"\u70B9\u51FB\u4E0A\u4F20"},nativeUpload:{type:Boolean,default:!0},size:{type:Number,default:30},deletable:{type:Boolean,default:!0},bucket:{type:String,default:"daya"}},methods:{beforeRead(t){return t.size/1024/1024<this.size?!0:(c(`\u4E0A\u4F20\u89C6\u9891\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${this.size}MB`),!1)},beforeDelete(t,r){return!0},async afterRead(t,r){try{t.status="uploading",t.message="\u4E0A\u4F20\u4E2D...";const l=n.platformType==="TEACHER"?"/api-teacher/getUploadSign":"/api-student/getUploadSign",e=t.file.name.replaceAll(" ","_"),o=new Date().getTime()+e;console.log(t);const s=await A.post(l,{data:{filename:e,bucketName:this.bucket,postData:{filename:e,acl:"public-read",key:o,unknowValueField:[]}}});c.loading({message:"\u52A0\u8F7D\u4E2D...",forbidClick:!0,loadingType:"spinner",duration:0});const i={policy:s.data.policy,signature:s.data.signature,key:o,KSSAccessKeyId:s.data.kssAccessKeyId,acl:"public-read",name:e};let u=new FormData;for(let f in i)u.append(f,i[f]);u.append("file",t.file),await U(n.ossUploadUrl+this.bucket,{method:"POST",data:u}),console.log(n.ossUploadUrl+this.bucket+"/"+o);const m=n.ossUploadUrl+this.bucket+"/"+o;c.clear(),this.$emit("update:modelValue",m)}catch(l){console.log(l)}},onClose(t){this.$emit("update:modelValue",null),t.stopPropagation()},onNativeUpload(){h({api:"chooseFile",content:{type:"video",bucket:this.bucket}},t=>{this.$emit("update:modelValue",t.fileUrl)})},getVideoBase64(t){return new Promise(function(r){let l="";const e=document.createElement("video");e.setAttribute("crossOrigin","anonymous"),e.setAttribute("src",t),e.setAttribute("preload","auto"),e.addEventListener("loadeddata",function(){console.log(e,"video loadeddata");const o=document.createElement("canvas");console.log("video.clientWidth",e.videoWidth),console.log("video.clientHeight",e.videoHeight);const s=e.videoWidth||750,i=e.videoHeight||500;o.width=s,o.height=i,o.getContext("2d").drawImage(e,0,0,s,i),l=o.toDataURL("image/jpeg"),r(l)})})}},render(){return D(()=>this.modelValue),a("div",{class:d["uploader-section"]},[this.modelValue&&this.deletable?a(p,{name:"cross",onClick:this.onClose,class:d["img-close"]},null):null,b().isApp&&this.nativeUpload?a("div",{onClick:this.onNativeUpload,style:{height:"100%"}},[this.modelValue?a("video",{ref:"videoUpload",class:d.uploadImg,src:this.modelValue+"#t=1,4"},null):a("div",{class:d.uploader},[a(p,{name:g,size:"32"},null),a("p",{class:d.uploaderText},[this.tips])])]):a(w,null,[a(y,{accept:".mp4",afterRead:this.afterRead,beforeRead:this.beforeRead,beforeDelete:this.beforeDelete},{default:()=>this.modelValue?a("video",{ref:"videoUpload",class:d.uploadImg,src:this.modelValue+"#t=1,4"},null):a("div",{class:d.uploader},[a(p,{name:g,size:"32"},null),a("p",{class:d.uploaderText},[this.tips])])})])])}});export{x as C};
