| 1234567 |
- import{d as rt,o as Y,h as k,a3 as lt,a7 as ut,i as y,F as L,N as G,V as Xt,t as J,c as tt,r as et,f as Q,k as H,u as Ht,l as M,p as st,b9 as dt,_ as It,a5 as Mt,j as wt,y as Z,aY as ot,ba as Yt,a0 as Ct,bb as gt,bc as kt,bd as Lt,a8 as mt,K as Et,w as _t,a as Nt}from"./index-32c39055.js";import{c as ht,d as yt,S as it}from"./upload-8c2ee168.js";import{n as xt,S as $t,e as bt}from"./case-de2e9213.js";import{S as b,b as Tt}from"./scene-3c8ec63c.js";import{c as Pt}from"./index-343523a6.js";import{_ as At,u as zt}from"./pagging-58a38392.js";const St={};St.getData=t=>new Promise((e,s)=>{let i={};Rt(t).then(r=>{i.arrayBuffer=r;try{i.orientation=Dt(r)}catch{i.orientation=-1}e(i)}).catch(r=>{s(r)})});function Rt(t){let e=null;return new Promise((s,i)=>{if(t.src)if(/^data\:/i.test(t.src))e=Ut(t.src),s(e);else if(/^blob\:/i.test(t.src)){var r=new FileReader;r.onload=function(h){e=h.target.result,s(e)},Bt(t.src,function(h){r.readAsArrayBuffer(h)})}else{var o=new XMLHttpRequest;o.onload=function(){if(this.status==200||this.status===0)e=o.response,s(e);else throw"Could not load image";o=null},o.open("GET",t.src,!0),o.responseType="arraybuffer",o.send(null)}else i("img error")})}function Bt(t,e){var s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=function(i){(this.status==200||this.status===0)&&e(this.response)},s.send()}function Ut(t,e){e=e||t.match(/^data\:([^\;]+)\;base64,/mi)[1]||"",t=t.replace(/^data\:([^\;]+)\;base64,/gmi,"");for(var s=atob(t),i=s.length%2==0?s.length:s.length+1,r=new ArrayBuffer(i),o=new Uint16Array(r),h=0;h<i;h++)o[h]=s.charCodeAt(h);return r}function qt(t,e,s){var i="",r;for(r=e,s+=e;r<s;r++)i+=String.fromCharCode(t.getUint8(r));return i}function Dt(t){var e=new DataView(t),s=e.byteLength,i,r,o,h,a,n,c,p,l,u;if(e.getUint8(0)===255&&e.getUint8(1)===216)for(l=2;l<s;){if(e.getUint8(l)===255&&e.getUint8(l+1)===225){c=l;break}l++}if(c&&(r=c+4,o=c+10,qt(e,r,4)==="Exif"&&(n=e.getUint16(o),a=n===18761,(a||n===19789)&&e.getUint16(o+2,a)===42&&(h=e.getUint32(o+4,a),h>=8&&(p=o+h)))),p){for(s=e.getUint16(p,a),u=0;u<s;u++)if(l=p+u*12+2,e.getUint16(l,a)===274){l+=8,i=e.getUint16(l,a);break}}return i}const Kt=(t,e)=>{const s=t.__vccOpts||t;for(const[i,r]of e)s[i]=r;return s},Ft=rt({data:function(){return{w:0,h:0,scale:1,x:0,y:0,loading:!0,trueWidth:0,trueHeight:0,move:!0,moveX:0,moveY:0,crop:!1,cropping:!1,cropW:0,cropH:0,cropOldW:0,cropOldH:0,canChangeX:!1,canChangeY:!1,changeCropTypeX:1,changeCropTypeY:1,cropX:0,cropY:0,cropChangeX:0,cropChangeY:0,cropOffsertX:0,cropOffsertY:0,support:"",touches:[],touchNow:!1,rotate:0,isIos:!1,orientation:0,imgs:"",coe:.2,scaling:!1,scalingSet:"",coeStatus:"",isCanShow:!0,imgIsQqualCrop:!1}},props:{img:{type:[String,Blob,null,File],default:""},outputSize:{type:Number,default:1},outputType:{type:String,default:"jpeg"},info:{type:Boolean,default:!0},canScale:{type:Boolean,default:!0},autoCrop:{type:Boolean,default:!1},autoCropWidth:{type:[Number,String],default:0},autoCropHeight:{type:[Number,String],default:0},fixed:{type:Boolean,default:!1},fixedNumber:{type:Array,default:()=>[1,1]},fixedBox:{type:Boolean,default:!1},full:{type:Boolean,default:!1},canMove:{type:Boolean,default:!0},canMoveBox:{type:Boolean,default:!0},original:{type:Boolean,default:!1},centerBox:{type:Boolean,default:!1},high:{type:Boolean,default:!0},infoTrue:{type:Boolean,default:!1},maxImgSize:{type:[Number,String],default:2e3},enlarge:{type:[Number,String],default:1},preW:{type:[Number,String],default:0},mode:{type:String,default:"contain"},limitMinSize:{type:[Number,Array,String],default:()=>10,validator:function(t){return Array.isArray(t)?Number(t[0])>=0&&Number(t[1])>=0:Number(t)>=0}},fillColor:{type:String,default:""}},computed:{cropInfo(){let t={};if(t.top=this.cropOffsertY>21?"-21px":"0px",t.width=this.cropW>0?this.cropW:0,t.height=this.cropH>0?this.cropH:0,this.infoTrue){let e=1;this.high&&!this.full&&(e=window.devicePixelRatio),this.enlarge!==1&!this.full&&(e=Math.abs(Number(this.enlarge))),t.width=t.width*e,t.height=t.height*e,this.full&&(t.width=t.width/this.scale,t.height=t.height/this.scale)}return t.width=t.width.toFixed(0),t.height=t.height.toFixed(0),t},isIE(){return!!window.ActiveXObject||"ActiveXObject"in window},passive(){return this.isIE?null:{passive:!1}},isRotateRightOrLeft(){return[1,-1,3,-3].includes(this.rotate)}},watch:{img(){this.checkedImg()},imgs(t){t!==""&&this.reload()},cropW(){this.showPreview()},cropH(){this.showPreview()},cropOffsertX(){this.showPreview()},cropOffsertY(){this.showPreview()},scale(t,e){this.showPreview()},x(){this.showPreview()},y(){this.showPreview()},autoCrop(t){t&&this.goAutoCrop()},autoCropWidth(){this.autoCrop&&this.goAutoCrop()},autoCropHeight(){this.autoCrop&&this.goAutoCrop()},mode(){this.checkedImg()},rotate(){this.showPreview(),this.autoCrop?this.goAutoCrop(this.cropW,this.cropH):(this.cropW>0||this.cropH>0)&&this.goAutoCrop(this.cropW,this.cropH)}},methods:{getVersion(t){var e=navigator.userAgent.split(" "),s="";let i=0;const r=new RegExp(t,"i");for(var o=0;o<e.length;o++)r.test(e[o])&&(s=e[o]);return s?i=s.split("/")[1].split("."):i=["0","0","0"],i},checkOrientationImage(t,e,s,i){if(this.getVersion("chrome")[0]>=81)e=-1;else if(this.getVersion("safari")[0]>=605){const h=this.getVersion("version");h[0]>13&&h[1]>1&&(e=-1)}else{const h=navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?) like mac os/);if(h){let a=h[1];a=a.split("_"),(a[0]>13||a[0]>=13&&a[1]>=4)&&(e=-1)}}let r=document.createElement("canvas"),o=r.getContext("2d");switch(o.save(),e){case 2:r.width=s,r.height=i,o.translate(s,0),o.scale(-1,1);break;case 3:r.width=s,r.height=i,o.translate(s/2,i/2),o.rotate(180*Math.PI/180),o.translate(-s/2,-i/2);break;case 4:r.width=s,r.height=i,o.translate(0,i),o.scale(1,-1);break;case 5:r.height=s,r.width=i,o.rotate(.5*Math.PI),o.scale(1,-1);break;case 6:r.width=i,r.height=s,o.translate(i/2,s/2),o.rotate(90*Math.PI/180),o.translate(-s/2,-i/2);break;case 7:r.height=s,r.width=i,o.rotate(.5*Math.PI),o.translate(s,-i),o.scale(-1,1);break;case 8:r.height=s,r.width=i,o.translate(i/2,s/2),o.rotate(-90*Math.PI/180),o.translate(-s/2,-i/2);break;default:r.width=s,r.height=i}o.drawImage(t,0,0,s,i),o.restore(),r.toBlob(h=>{let a=URL.createObjectURL(h);URL.revokeObjectURL(this.imgs),this.imgs=a},"image/"+this.outputType,1)},checkedImg(){if(this.img===null||this.img===""){this.imgs="",this.clearCrop();return}this.loading=!0,this.scale=1,this.rotate=0,this.imgIsQqualCrop=!1,this.clearCrop();let t=new Image;if(t.onload=()=>{if(this.img==="")return this.$emit("img-load",new Error("图片不能为空")),!1;let s=t.width,i=t.height;St.getData(t).then(r=>{this.orientation=r.orientation||1;let o=Number(this.maxImgSize);if(!this.orientation&&s<o&i<o){this.imgs=this.img;return}s>o&&(i=i/s*o,s=o),i>o&&(s=s/i*o,i=o),this.checkOrientationImage(t,this.orientation,s,i)}).catch(r=>{this.$emit("img-load","error"),this.$emit("img-load-error",r)})},t.onerror=s=>{this.$emit("img-load","error"),this.$emit("img-load-error",s)},this.img.substr(0,4)!=="data"&&(t.crossOrigin=""),this.isIE){var e=new XMLHttpRequest;e.onload=function(){var s=URL.createObjectURL(this.response);t.src=s},e.open("GET",this.img,!0),e.responseType="blob",e.send()}else t.src=this.img},startMove(t){if(t.preventDefault(),this.move&&!this.crop){if(!this.canMove)return!1;this.moveX=("clientX"in t?t.clientX:t.touches[0].clientX)-this.x,this.moveY=("clientY"in t?t.clientY:t.touches[0].clientY)-this.y,t.touches?(window.addEventListener("touchmove",this.moveImg),window.addEventListener("touchend",this.leaveImg),t.touches.length==2&&(this.touches=t.touches,window.addEventListener("touchmove",this.touchScale),window.addEventListener("touchend",this.cancelTouchScale))):(window.addEventListener("mousemove",this.moveImg),window.addEventListener("mouseup",this.leaveImg)),this.$emit("img-moving",{moving:!0,axis:this.getImgAxis()})}else this.cropping=!0,window.addEventListener("mousemove",this.createCrop),window.addEventListener("mouseup",this.endCrop),window.addEventListener("touchmove",this.createCrop),window.addEventListener("touchend",this.endCrop),this.cropOffsertX=t.offsetX?t.offsetX:t.touches[0].pageX-this.$refs.cropper.offsetLeft,this.cropOffsertY=t.offsetY?t.offsetY:t.touches[0].pageY-this.$refs.cropper.offsetTop,this.cropX="clientX"in t?t.clientX:t.touches[0].clientX,this.cropY="clientY"in t?t.clientY:t.touches[0].clientY,this.cropChangeX=this.cropOffsertX,this.cropChangeY=this.cropOffsertY,this.cropW=0,this.cropH=0},touchScale(t){t.preventDefault();let e=this.scale;var s={x:this.touches[0].clientX,y:this.touches[0].clientY},i={x:t.touches[0].clientX,y:t.touches[0].clientY},r={x:this.touches[1].clientX,y:this.touches[1].clientY},o={x:t.touches[1].clientX,y:t.touches[1].clientY},h=Math.sqrt(Math.pow(s.x-r.x,2)+Math.pow(s.y-r.y,2)),a=Math.sqrt(Math.pow(i.x-o.x,2)+Math.pow(i.y-o.y,2)),n=a-h,c=1;c=c/this.trueWidth>c/this.trueHeight?c/this.trueHeight:c/this.trueWidth,c=c>.1?.1:c;var p=c*n;if(!this.touchNow){if(this.touchNow=!0,n>0?e+=Math.abs(p):n<0&&e>Math.abs(p)&&(e-=Math.abs(p)),this.touches=t.touches,setTimeout(()=>{this.touchNow=!1},8),!this.checkoutImgAxis(this.x,this.y,e))return!1;this.scale=e}},cancelTouchScale(t){window.removeEventListener("touchmove",this.touchScale)},moveImg(t){if(t.preventDefault(),t.touches&&t.touches.length===2)return this.touches=t.touches,window.addEventListener("touchmove",this.touchScale),window.addEventListener("touchend",this.cancelTouchScale),window.removeEventListener("touchmove",this.moveImg),!1;let e="clientX"in t?t.clientX:t.touches[0].clientX,s="clientY"in t?t.clientY:t.touches[0].clientY,i,r;i=e-this.moveX,r=s-this.moveY,this.$nextTick(()=>{if(this.centerBox){let o=this.getImgAxis(i,r,this.scale),h=this.getCropAxis(),a=this.trueHeight*this.scale,n=this.trueWidth*this.scale,c,p,l,u;switch(this.rotate){case 1:case-1:case 3:case-3:c=this.cropOffsertX-this.trueWidth*(1-this.scale)/2+(a-n)/2,p=this.cropOffsertY-this.trueHeight*(1-this.scale)/2+(n-a)/2,l=c-a+this.cropW,u=p-n+this.cropH;break;default:c=this.cropOffsertX-this.trueWidth*(1-this.scale)/2,p=this.cropOffsertY-this.trueHeight*(1-this.scale)/2,l=c-n+this.cropW,u=p-a+this.cropH;break}o.x1>=h.x1&&(i=c),o.y1>=h.y1&&(r=p),o.x2<=h.x2&&(i=l),o.y2<=h.y2&&(r=u)}this.x=i,this.y=r,this.$emit("img-moving",{moving:!0,axis:this.getImgAxis()})})},leaveImg(t){window.removeEventListener("mousemove",this.moveImg),window.removeEventListener("touchmove",this.moveImg),window.removeEventListener("mouseup",this.leaveImg),window.removeEventListener("touchend",this.leaveImg),this.$emit("img-moving",{moving:!1,axis:this.getImgAxis()})},scaleImg(){this.canScale&&window.addEventListener(this.support,this.changeSize,this.passive)},cancelScale(){this.canScale&&window.removeEventListener(this.support,this.changeSize)},changeSize(t){t.preventDefault();let e=this.scale;var s=t.deltaY||t.wheelDelta,i=navigator.userAgent.indexOf("Firefox");s=i>0?s*30:s,this.isIE&&(s=-s);var r=this.coe;r=r/this.trueWidth>r/this.trueHeight?r/this.trueHeight:r/this.trueWidth;var o=r*s;o<0?e+=Math.abs(o):e>Math.abs(o)&&(e-=Math.abs(o));let h=o<0?"add":"reduce";if(h!==this.coeStatus&&(this.coeStatus=h,this.coe=.2),this.scaling||(this.scalingSet=setTimeout(()=>{this.scaling=!1,this.coe=this.coe+=.01},50)),this.scaling=!0,!this.checkoutImgAxis(this.x,this.y,e))return!1;this.scale=e},changeScale(t){let e=this.scale;t=t||1;var s=20;if(s=s/this.trueWidth>s/this.trueHeight?s/this.trueHeight:s/this.trueWidth,t=t*s,t>0?e+=Math.abs(t):e>Math.abs(t)&&(e-=Math.abs(t)),!this.checkoutImgAxis(this.x,this.y,e))return!1;this.scale=e},createCrop(t){t.preventDefault();var e="clientX"in t?t.clientX:t.touches?t.touches[0].clientX:0,s="clientY"in t?t.clientY:t.touches?t.touches[0].clientY:0;this.$nextTick(()=>{var i=e-this.cropX,r=s-this.cropY;if(i>0?(this.cropW=i+this.cropChangeX>this.w?this.w-this.cropChangeX:i,this.cropOffsertX=this.cropChangeX):(this.cropW=this.w-this.cropChangeX+Math.abs(i)>this.w?this.cropChangeX:Math.abs(i),this.cropOffsertX=this.cropChangeX+i>0?this.cropChangeX+i:0),!this.fixed)r>0?(this.cropH=r+this.cropChangeY>this.h?this.h-this.cropChangeY:r,this.cropOffsertY=this.cropChangeY):(this.cropH=this.h-this.cropChangeY+Math.abs(r)>this.h?this.cropChangeY:Math.abs(r),this.cropOffsertY=this.cropChangeY+r>0?this.cropChangeY+r:0);else{var o=this.cropW/this.fixedNumber[0]*this.fixedNumber[1];o+this.cropOffsertY>this.h?(this.cropH=this.h-this.cropOffsertY,this.cropW=this.cropH/this.fixedNumber[1]*this.fixedNumber[0],i>0?this.cropOffsertX=this.cropChangeX:this.cropOffsertX=this.cropChangeX-this.cropW):this.cropH=o,this.cropOffsertY=this.cropOffsertY}})},changeCropSize(t,e,s,i,r){t.preventDefault(),window.addEventListener("mousemove",this.changeCropNow),window.addEventListener("mouseup",this.changeCropEnd),window.addEventListener("touchmove",this.changeCropNow),window.addEventListener("touchend",this.changeCropEnd),this.canChangeX=e,this.canChangeY=s,this.changeCropTypeX=i,this.changeCropTypeY=r,this.cropX="clientX"in t?t.clientX:t.touches[0].clientX,this.cropY="clientY"in t?t.clientY:t.touches[0].clientY,this.cropOldW=this.cropW,this.cropOldH=this.cropH,this.cropChangeX=this.cropOffsertX,this.cropChangeY=this.cropOffsertY,this.fixed&&this.canChangeX&&this.canChangeY&&(this.canChangeY=0),this.$emit("change-crop-size",{width:this.cropW,height:this.cropH})},changeCropNow(t){t.preventDefault();var e="clientX"in t?t.clientX:t.touches?t.touches[0].clientX:0,s="clientY"in t?t.clientY:t.touches?t.touches[0].clientY:0;let i=this.w,r=this.h,o=0,h=0;if(this.centerBox){let c=this.getImgAxis(),p=c.x2,l=c.y2;o=c.x1>0?c.x1:0,h=c.y1>0?c.y1:0,i>p&&(i=p),r>l&&(r=l)}const[a,n]=this.checkCropLimitSize();this.$nextTick(()=>{var c=e-this.cropX,p=s-this.cropY;if(this.canChangeX&&(this.changeCropTypeX===1?this.cropOldW-c<a?(this.cropW=a,this.cropOffsertX=this.cropOldW+this.cropChangeX-o-a):this.cropOldW-c>0?(this.cropW=i-this.cropChangeX-c<=i-o?this.cropOldW-c:this.cropOldW+this.cropChangeX-o,this.cropOffsertX=i-this.cropChangeX-c<=i-o?this.cropChangeX+c:o):(this.cropW=Math.abs(c)+this.cropChangeX<=i?Math.abs(c)-this.cropOldW:i-this.cropOldW-this.cropChangeX,this.cropOffsertX=this.cropChangeX+this.cropOldW):this.changeCropTypeX===2&&(this.cropOldW+c<a?this.cropW=a:this.cropOldW+c>0?(this.cropW=this.cropOldW+c+this.cropOffsertX<=i?this.cropOldW+c:i-this.cropOffsertX,this.cropOffsertX=this.cropChangeX):(this.cropW=i-this.cropChangeX+Math.abs(c+this.cropOldW)<=i-o?Math.abs(c+this.cropOldW):this.cropChangeX-o,this.cropOffsertX=i-this.cropChangeX+Math.abs(c+this.cropOldW)<=i-o?this.cropChangeX-Math.abs(c+this.cropOldW):o))),this.canChangeY&&(this.changeCropTypeY===1?this.cropOldH-p<n?(this.cropH=n,this.cropOffsertY=this.cropOldH+this.cropChangeY-h-n):this.cropOldH-p>0?(this.cropH=r-this.cropChangeY-p<=r-h?this.cropOldH-p:this.cropOldH+this.cropChangeY-h,this.cropOffsertY=r-this.cropChangeY-p<=r-h?this.cropChangeY+p:h):(this.cropH=Math.abs(p)+this.cropChangeY<=r?Math.abs(p)-this.cropOldH:r-this.cropOldH-this.cropChangeY,this.cropOffsertY=this.cropChangeY+this.cropOldH):this.changeCropTypeY===2&&(this.cropOldH+p<n?this.cropH=n:this.cropOldH+p>0?(this.cropH=this.cropOldH+p+this.cropOffsertY<=r?this.cropOldH+p:r-this.cropOffsertY,this.cropOffsertY=this.cropChangeY):(this.cropH=r-this.cropChangeY+Math.abs(p+this.cropOldH)<=r-h?Math.abs(p+this.cropOldH):this.cropChangeY-h,this.cropOffsertY=r-this.cropChangeY+Math.abs(p+this.cropOldH)<=r-h?this.cropChangeY-Math.abs(p+this.cropOldH):h))),this.canChangeX&&this.fixed){var l=this.cropW/this.fixedNumber[0]*this.fixedNumber[1];l<n?(this.cropH=n,this.cropW=this.fixedNumber[0]*n/this.fixedNumber[1],this.changeCropTypeX===1&&(this.cropOffsertX=this.cropChangeX+(this.cropOldW-this.cropW))):l+this.cropOffsertY>r?(this.cropH=r-this.cropOffsertY,this.cropW=this.cropH/this.fixedNumber[1]*this.fixedNumber[0],this.changeCropTypeX===1&&(this.cropOffsertX=this.cropChangeX+(this.cropOldW-this.cropW))):this.cropH=l}if(this.canChangeY&&this.fixed){var u=this.cropH/this.fixedNumber[1]*this.fixedNumber[0];u<a?(this.cropW=a,this.cropH=this.fixedNumber[1]*a/this.fixedNumber[0],this.cropOffsertY=this.cropOldH+this.cropChangeY-this.cropH):u+this.cropOffsertX>i?(this.cropW=i-this.cropOffsertX,this.cropH=this.cropW/this.fixedNumber[0]*this.fixedNumber[1]):this.cropW=u}})},checkCropLimitSize(){let{cropW:t,cropH:e,limitMinSize:s}=this,i=new Array;return Array.isArray(s)?i=s:i=[s,s],t=parseFloat(i[0]),e=parseFloat(i[1]),[t,e]},changeCropEnd(t){window.removeEventListener("mousemove",this.changeCropNow),window.removeEventListener("mouseup",this.changeCropEnd),window.removeEventListener("touchmove",this.changeCropNow),window.removeEventListener("touchend",this.changeCropEnd)},calculateSize(t,e,s,i,r,o){const h=t/e;let a=r,n=o;return a<s&&(a=s,n=Math.ceil(a/h)),n<i&&(n=i,a=Math.ceil(n*h),a<s&&(a=s,n=Math.ceil(a/h))),a<r&&(a=r,n=Math.ceil(a/h)),n<o&&(n=o,a=Math.ceil(n*h)),{width:a,height:n}},endCrop(){this.cropW===0&&this.cropH===0&&(this.cropping=!1);let[t,e]=this.checkCropLimitSize();const{width:s,height:i}=this.fixed?this.calculateSize(this.fixedNumber[0],this.fixedNumber[1],t,e,this.cropW,this.cropH):{width:t,height:e};s>this.cropW&&(this.cropW=s,this.cropOffsertX+s>this.w&&(this.cropOffsertX=this.w-s)),i>this.cropH&&(this.cropH=i,this.cropOffsertY+i>this.h&&(this.cropOffsertY=this.h-i)),window.removeEventListener("mousemove",this.createCrop),window.removeEventListener("mouseup",this.endCrop),window.removeEventListener("touchmove",this.createCrop),window.removeEventListener("touchend",this.endCrop)},startCrop(){this.crop=!0},stopCrop(){this.crop=!1},clearCrop(){this.cropping=!1,this.cropW=0,this.cropH=0},cropMove(t){if(t.preventDefault(),!this.canMoveBox)return this.crop=!1,this.startMove(t),!1;if(t.touches&&t.touches.length===2)return this.crop=!1,this.startMove(t),this.leaveCrop(),!1;window.addEventListener("mousemove",this.moveCrop),window.addEventListener("mouseup",this.leaveCrop),window.addEventListener("touchmove",this.moveCrop),window.addEventListener("touchend",this.leaveCrop);let e="clientX"in t?t.clientX:t.touches[0].clientX,s="clientY"in t?t.clientY:t.touches[0].clientY,i,r;i=e-this.cropOffsertX,r=s-this.cropOffsertY,this.cropX=i,this.cropY=r,this.$emit("crop-moving",{moving:!0,axis:this.getCropAxis()})},moveCrop(t,e){let s=0,i=0;t&&(t.preventDefault(),s="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY),this.$nextTick(()=>{let r,o,h=s-this.cropX,a=i-this.cropY;if(e&&(h=this.cropOffsertX,a=this.cropOffsertY),h<=0?r=0:h+this.cropW>this.w?r=this.w-this.cropW:r=h,a<=0?o=0:a+this.cropH>this.h?o=this.h-this.cropH:o=a,this.centerBox){let n=this.getImgAxis();r<=n.x1&&(r=n.x1),r+this.cropW>n.x2&&(r=n.x2-this.cropW),o<=n.y1&&(o=n.y1),o+this.cropH>n.y2&&(o=n.y2-this.cropH)}this.cropOffsertX=r,this.cropOffsertY=o,this.$emit("crop-moving",{moving:!0,axis:this.getCropAxis()})})},getImgAxis(t,e,s){t=t||this.x,e=e||this.y,s=s||this.scale;let i={x1:0,x2:0,y1:0,y2:0},r=this.trueWidth*s,o=this.trueHeight*s;switch(this.rotate){case 0:i.x1=t+this.trueWidth*(1-s)/2,i.x2=i.x1+this.trueWidth*s,i.y1=e+this.trueHeight*(1-s)/2,i.y2=i.y1+this.trueHeight*s;break;case 1:case-1:case 3:case-3:i.x1=t+this.trueWidth*(1-s)/2+(r-o)/2,i.x2=i.x1+this.trueHeight*s,i.y1=e+this.trueHeight*(1-s)/2+(o-r)/2,i.y2=i.y1+this.trueWidth*s;break;default:i.x1=t+this.trueWidth*(1-s)/2,i.x2=i.x1+this.trueWidth*s,i.y1=e+this.trueHeight*(1-s)/2,i.y2=i.y1+this.trueHeight*s;break}return i},getCropAxis(){let t={x1:0,x2:0,y1:0,y2:0};return t.x1=this.cropOffsertX,t.x2=t.x1+this.cropW,t.y1=this.cropOffsertY,t.y2=t.y1+this.cropH,t},leaveCrop(t){window.removeEventListener("mousemove",this.moveCrop),window.removeEventListener("mouseup",this.leaveCrop),window.removeEventListener("touchmove",this.moveCrop),window.removeEventListener("touchend",this.leaveCrop),this.$emit("crop-moving",{moving:!1,axis:this.getCropAxis()})},getCropChecked(t){let e=document.createElement("canvas"),s=e.getContext("2d"),i=new Image,r=this.rotate,o=this.trueWidth,h=this.trueHeight,a=this.cropOffsertX,n=this.cropOffsertY;i.onload=()=>{if(this.cropW!==0){let u=1;this.high&!this.full&&(u=window.devicePixelRatio),this.enlarge!==1&!this.full&&(u=Math.abs(Number(this.enlarge)));let d=this.cropW*u,f=this.cropH*u,m=o*this.scale*u,g=h*this.scale*u,w=(this.x-a+this.trueWidth*(1-this.scale)/2)*u,v=(this.y-n+this.trueHeight*(1-this.scale)/2)*u;switch(l(d,f),s.save(),r){case 0:this.full?(l(d/this.scale,f/this.scale),s.drawImage(i,w/this.scale,v/this.scale,m/this.scale,g/this.scale)):s.drawImage(i,w,v,m,g);break;case 1:case-3:this.full?(l(d/this.scale,f/this.scale),w=w/this.scale+(m/this.scale-g/this.scale)/2,v=v/this.scale+(g/this.scale-m/this.scale)/2,s.rotate(r*90*Math.PI/180),s.drawImage(i,v,-w-g/this.scale,m/this.scale,g/this.scale)):(w=w+(m-g)/2,v=v+(g-m)/2,s.rotate(r*90*Math.PI/180),s.drawImage(i,v,-w-g,m,g));break;case 2:case-2:this.full?(l(d/this.scale,f/this.scale),s.rotate(r*90*Math.PI/180),w=w/this.scale,v=v/this.scale,s.drawImage(i,-w-m/this.scale,-v-g/this.scale,m/this.scale,g/this.scale)):(s.rotate(r*90*Math.PI/180),s.drawImage(i,-w-m,-v-g,m,g));break;case 3:case-1:this.full?(l(d/this.scale,f/this.scale),w=w/this.scale+(m/this.scale-g/this.scale)/2,v=v/this.scale+(g/this.scale-m/this.scale)/2,s.rotate(r*90*Math.PI/180),s.drawImage(i,-v-m/this.scale,w,m/this.scale,g/this.scale)):(w=w+(m-g)/2,v=v+(g-m)/2,s.rotate(r*90*Math.PI/180),s.drawImage(i,-v-m,w,m,g));break;default:this.full?(l(d/this.scale,f/this.scale),s.drawImage(i,w/this.scale,v/this.scale,m/this.scale,g/this.scale)):s.drawImage(i,w,v,m,g)}s.restore()}else{let u=o*this.scale,d=h*this.scale;switch(s.save(),r){case 0:l(u,d),s.drawImage(i,0,0,u,d);break;case 1:case-3:l(d,u),s.rotate(r*90*Math.PI/180),s.drawImage(i,0,-d,u,d);break;case 2:case-2:l(u,d),s.rotate(r*90*Math.PI/180),s.drawImage(i,-u,-d,u,d);break;case 3:case-1:l(d,u),s.rotate(r*90*Math.PI/180),s.drawImage(i,-u,0,u,d);break;default:l(u,d),s.drawImage(i,0,0,u,d)}s.restore()}t(e)};var c=this.img.substr(0,4);c!=="data"&&(i.crossOrigin="Anonymous"),i.src=this.imgs;const p=this.fillColor;function l(u,d){e.width=Math.round(u),e.height=Math.round(d),p&&(s.fillStyle=p,s.fillRect(0,0,e.width,e.height))}},getCropData(t){this.getCropChecked(e=>{t(e.toDataURL("image/"+this.outputType,this.outputSize))})},getCropBlob(t){this.getCropChecked(e=>{e.toBlob(s=>t(s),"image/"+this.outputType,this.outputSize)})},showPreview(){if(this.isCanShow)this.isCanShow=!1,setTimeout(()=>{this.isCanShow=!0},16);else return!1;let t=this.cropW,e=this.cropH,s=this.scale;var i={};i.div={width:`${t}px`,height:`${e}px`};let r=(this.x-this.cropOffsertX)/s,o=(this.y-this.cropOffsertY)/s,h=0;i.w=t,i.h=e,i.url=this.imgs,i.img={width:`${this.trueWidth}px`,height:`${this.trueHeight}px`,transform:`scale(${s})translate3d(${r}px, ${o}px, ${h}px)rotateZ(${this.rotate*90}deg)`},i.html=`
- <div class="show-preview" style="width: ${i.w}px; height: ${i.h}px,; overflow: hidden">
- <div style="width: ${t}px; height: ${e}px">
- <img src=${i.url} style="width: ${this.trueWidth}px; height: ${this.trueHeight}px; transform:
- scale(${s})translate3d(${r}px, ${o}px, ${h}px)rotateZ(${this.rotate*90}deg)">
- </div>
- </div>`,this.$emit("real-time",i)},reload(){let t=new Image;t.onload=()=>{this.w=parseFloat(window.getComputedStyle(this.$refs.cropper).width),this.h=parseFloat(window.getComputedStyle(this.$refs.cropper).height),this.trueWidth=t.width,this.trueHeight=t.height,this.original?this.scale=1:this.scale=this.checkedMode(),this.$nextTick(()=>{this.x=-(this.trueWidth-this.trueWidth*this.scale)/2+(this.w-this.trueWidth*this.scale)/2,this.y=-(this.trueHeight-this.trueHeight*this.scale)/2+(this.h-this.trueHeight*this.scale)/2,this.loading=!1,this.autoCrop&&this.goAutoCrop(),this.$emit("img-load","success"),setTimeout(()=>{this.showPreview()},20)})},t.onerror=()=>{this.$emit("img-load","error")},t.src=this.imgs},checkedMode(){let t=1,e=this.trueWidth,s=this.trueHeight;const i=this.mode.split(" ");switch(i[0]){case"contain":this.trueWidth>this.w&&(t=this.w/this.trueWidth),this.trueHeight*t>this.h&&(t=this.h/this.trueHeight);break;case"cover":e=this.w,t=e/this.trueWidth,s=s*t,s<this.h&&(s=this.h,t=s/this.trueHeight);break;default:try{let r=i[0];if(r.search("px")!==-1){r=r.replace("px",""),e=parseFloat(r);const o=e/this.trueWidth;let h=1,a=i[1];a.search("px")!==-1&&(a=a.replace("px",""),s=parseFloat(a),h=s/this.trueHeight),t=Math.min(o,h)}if(r.search("%")!==-1&&(r=r.replace("%",""),e=parseFloat(r)/100*this.w,t=e/this.trueWidth),i.length===2&&r==="auto"){let o=i[1];o.search("px")!==-1&&(o=o.replace("px",""),s=parseFloat(o),t=s/this.trueHeight),o.search("%")!==-1&&(o=o.replace("%",""),s=parseFloat(o)/100*this.h,t=s/this.trueHeight)}}catch{t=1}}return t},goAutoCrop(t,e){if(this.imgs===""||this.imgs===null)return;this.clearCrop(),this.cropping=!0;let s=this.w,i=this.h;if(this.centerBox){const h=Math.abs(this.rotate)%2>0;let a=(h?this.trueHeight:this.trueWidth)*this.scale,n=(h?this.trueWidth:this.trueHeight)*this.scale;s=a<s?a:s,i=n<i?n:i}var r=t||parseFloat(this.autoCropWidth),o=e||parseFloat(this.autoCropHeight);(r===0||o===0)&&(r=s*.8,o=i*.8),r=r>s?s:r,o=o>i?i:o,this.fixed&&(o=r/this.fixedNumber[0]*this.fixedNumber[1]),o>this.h&&(o=this.h,r=o/this.fixedNumber[1]*this.fixedNumber[0]),this.changeCrop(r,o)},changeCrop(t,e){if(this.centerBox){let s=this.getImgAxis();t>s.x2-s.x1&&(t=s.x2-s.x1,e=t/this.fixedNumber[0]*this.fixedNumber[1]),e>s.y2-s.y1&&(e=s.y2-s.y1,t=e/this.fixedNumber[1]*this.fixedNumber[0])}this.cropW=t,this.cropH=e,this.checkCropLimitSize(),this.$nextTick(()=>{this.cropOffsertX=(this.w-this.cropW)/2,this.cropOffsertY=(this.h-this.cropH)/2,this.centerBox&&this.moveCrop(null,!0)})},refresh(){this.img,this.imgs="",this.scale=1,this.crop=!1,this.rotate=0,this.w=0,this.h=0,this.trueWidth=0,this.trueHeight=0,this.imgIsQqualCrop=!1,this.clearCrop(),this.$nextTick(()=>{this.checkedImg()})},rotateLeft(){this.rotate=this.rotate<=-3?0:this.rotate-1},rotateRight(){this.rotate=this.rotate>=3?0:this.rotate+1},rotateClear(){this.rotate=0},checkoutImgAxis(t,e,s){t=t||this.x,e=e||this.y,s=s||this.scale;let i=!0;if(this.centerBox){let r=this.getImgAxis(t,e,s),o=this.getCropAxis();r.x1>=o.x1&&(i=!1),r.x2<=o.x2&&(i=!1),r.y1>=o.y1&&(i=!1),r.y2<=o.y2&&(i=!1),i||this.changeImgScale(r,o,s)}return i},changeImgScale(t,e,s){let i=this.trueWidth,r=this.trueHeight,o=i*s,h=r*s;if(o>=this.cropW&&h>=this.cropH)this.scale=s;else{const a=this.cropW/i,n=this.cropH/r,c=this.cropH<=r*a?a:n;this.scale=c,o=i*c,h=r*c}this.imgIsQqualCrop||(t.x1>=e.x1&&(this.isRotateRightOrLeft?this.x=e.x1-(i-o)/2-(o-h)/2:this.x=e.x1-(i-o)/2),t.x2<=e.x2&&(this.isRotateRightOrLeft?this.x=e.x1-(i-o)/2-(o-h)/2-h+this.cropW:this.x=e.x2-(i-o)/2-o),t.y1>=e.y1&&(this.isRotateRightOrLeft?this.y=e.y1-(r-h)/2-(h-o)/2:this.y=e.y1-(r-h)/2),t.y2<=e.y2&&(this.isRotateRightOrLeft?this.y=e.y2-(r-h)/2-(h-o)/2-o:this.y=e.y2-(r-h)/2-h)),(o<this.cropW||h<this.cropH)&&(this.imgIsQqualCrop=!0)}},mounted(){this.support="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";let t=this;var e=navigator.userAgent;this.isIOS=!!e.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(s,i,r){for(var o=atob(this.toDataURL(i,r).split(",")[1]),h=o.length,a=new Uint8Array(h),n=0;n<h;n++)a[n]=o.charCodeAt(n);s(new Blob([a],{type:t.type||"image/png"}))}}),this.showPreview(),this.checkedImg()},unmounted(){window.removeEventListener("mousemove",this.moveCrop),window.removeEventListener("mouseup",this.leaveCrop),window.removeEventListener("touchmove",this.moveCrop),window.removeEventListener("touchend",this.leaveCrop),this.cancelScale()}}),jt={key:0,class:"cropper-box"},Vt=["src"],Qt={class:"cropper-view-box"},Zt=["src"],Jt={key:1};function Gt(t,e,s,i,r,o){return Y(),k("div",{class:"vue-cropper",ref:"cropper",onMouseover:e[28]||(e[28]=(...h)=>t.scaleImg&&t.scaleImg(...h)),onMouseout:e[29]||(e[29]=(...h)=>t.cancelScale&&t.cancelScale(...h))},[t.imgs?(Y(),k("div",jt,[lt(y("div",{class:"cropper-box-canvas",style:L({width:t.trueWidth+"px",height:t.trueHeight+"px",transform:"scale("+t.scale+","+t.scale+") translate3d("+t.x/t.scale+"px,"+t.y/t.scale+"px,0)rotateZ("+t.rotate*90+"deg)"})},[y("img",{src:t.imgs,alt:"cropper-img",ref:"cropperImg"},null,8,Vt)],4),[[ut,!t.loading]])])):G("",!0),y("div",{class:Xt(["cropper-drag-box",{"cropper-move":t.move&&!t.crop,"cropper-crop":t.crop,"cropper-modal":t.cropping}]),onMousedown:e[0]||(e[0]=(...h)=>t.startMove&&t.startMove(...h)),onTouchstart:e[1]||(e[1]=(...h)=>t.startMove&&t.startMove(...h))},null,34),lt(y("div",{class:"cropper-crop-box",style:L({width:t.cropW+"px",height:t.cropH+"px",transform:"translate3d("+t.cropOffsertX+"px,"+t.cropOffsertY+"px,0)"})},[y("span",Qt,[y("img",{style:L({width:t.trueWidth+"px",height:t.trueHeight+"px",transform:"scale("+t.scale+","+t.scale+") translate3d("+(t.x-t.cropOffsertX)/t.scale+"px,"+(t.y-t.cropOffsertY)/t.scale+"px,0)rotateZ("+t.rotate*90+"deg)"}),src:t.imgs,alt:"cropper-img"},null,12,Zt)]),y("span",{class:"cropper-face cropper-move",onMousedown:e[2]||(e[2]=(...h)=>t.cropMove&&t.cropMove(...h)),onTouchstart:e[3]||(e[3]=(...h)=>t.cropMove&&t.cropMove(...h))},null,32),t.info?(Y(),k("span",{key:0,class:"crop-info",style:L({top:t.cropInfo.top})},J(t.cropInfo.width)+" × "+J(t.cropInfo.height),5)):G("",!0),t.fixedBox?G("",!0):(Y(),k("span",Jt,[y("span",{class:"crop-line line-w",onMousedown:e[4]||(e[4]=h=>t.changeCropSize(h,!1,!0,0,1)),onTouchstart:e[5]||(e[5]=h=>t.changeCropSize(h,!1,!0,0,1))},null,32),y("span",{class:"crop-line line-a",onMousedown:e[6]||(e[6]=h=>t.changeCropSize(h,!0,!1,1,0)),onTouchstart:e[7]||(e[7]=h=>t.changeCropSize(h,!0,!1,1,0))},null,32),y("span",{class:"crop-line line-s",onMousedown:e[8]||(e[8]=h=>t.changeCropSize(h,!1,!0,0,2)),onTouchstart:e[9]||(e[9]=h=>t.changeCropSize(h,!1,!0,0,2))},null,32),y("span",{class:"crop-line line-d",onMousedown:e[10]||(e[10]=h=>t.changeCropSize(h,!0,!1,2,0)),onTouchstart:e[11]||(e[11]=h=>t.changeCropSize(h,!0,!1,2,0))},null,32),y("span",{class:"crop-point point1",onMousedown:e[12]||(e[12]=h=>t.changeCropSize(h,!0,!0,1,1)),onTouchstart:e[13]||(e[13]=h=>t.changeCropSize(h,!0,!0,1,1))},null,32),y("span",{class:"crop-point point2",onMousedown:e[14]||(e[14]=h=>t.changeCropSize(h,!1,!0,0,1)),onTouchstart:e[15]||(e[15]=h=>t.changeCropSize(h,!1,!0,0,1))},null,32),y("span",{class:"crop-point point3",onMousedown:e[16]||(e[16]=h=>t.changeCropSize(h,!0,!0,2,1)),onTouchstart:e[17]||(e[17]=h=>t.changeCropSize(h,!0,!0,2,1))},null,32),y("span",{class:"crop-point point4",onMousedown:e[18]||(e[18]=h=>t.changeCropSize(h,!0,!1,1,0)),onTouchstart:e[19]||(e[19]=h=>t.changeCropSize(h,!0,!1,1,0))},null,32),y("span",{class:"crop-point point5",onMousedown:e[20]||(e[20]=h=>t.changeCropSize(h,!0,!1,2,0)),onTouchstart:e[21]||(e[21]=h=>t.changeCropSize(h,!0,!1,2,0))},null,32),y("span",{class:"crop-point point6",onMousedown:e[22]||(e[22]=h=>t.changeCropSize(h,!0,!0,1,2)),onTouchstart:e[23]||(e[23]=h=>t.changeCropSize(h,!0,!0,1,2))},null,32),y("span",{class:"crop-point point7",onMousedown:e[24]||(e[24]=h=>t.changeCropSize(h,!1,!0,0,2)),onTouchstart:e[25]||(e[25]=h=>t.changeCropSize(h,!1,!0,0,2))},null,32),y("span",{class:"crop-point point8",onMousedown:e[26]||(e[26]=h=>t.changeCropSize(h,!0,!0,2,2)),onTouchstart:e[27]||(e[27]=h=>t.changeCropSize(h,!0,!0,2,2))},null,32)]))],4),[[ut,t.cropping]])],544)}const te=Kt(Ft,[["render",Gt],["__scopeId","data-v-a742df44"]]),ft=(t,e,s)=>[1,0,0,0,0,1,0,0,0,0,1,0,t,e,s,1],ee=t=>{const e=Math.sin(t),s=Math.cos(t);return[s,e,0,0,-e,s,0,0,0,0,1,0,0,0,0,1]},Wt=(...t)=>{if(t.length===1)return t[0];const e=4,s=e*e,i=[];for(let r=0;r<s;r++){const o=Math.floor(r/e),h=r%e;let a=0;for(let n=0;n<e;n++){const c=o*e+n,p=h+n*e;a+=t[1][c]*t[0][p]}i[r]=a}return t.length===2?i:Wt(i,...t.slice(2))},I=(t,e)=>{const i=t[0]*e[3]+t[1]*e[7]+t[2]*e[11]+e[15];return[(t[0]*e[0]+t[1]*e[4]+t[2]*e[4*2]+e[4*3])/i,(t[0]*e[1]+t[1]*e[4+1]+t[2]*e[4*2+1]+e[4*3+1])/i,(t[0]*e[2]+t[1]*e[4+2]+t[2]*e[4*2+2]+e[4*3+2])/i]},se=t=>{var e=t[0],s=t[0*4+1],i=t[0*4+2],r=t[0*4+3],o=t[1*4+0],h=t[1*4+1],a=t[1*4+2],n=t[1*4+3],c=t[2*4+0],p=t[2*4+1],l=t[2*4+2],u=t[2*4+3],d=t[3*4+0],f=t[3*4+1],m=t[3*4+2],g=t[3*4+3],w=l*g,v=m*u,S=a*g,W=m*n,C=a*u,O=l*n,X=i*g,E=m*r,_=i*u,N=l*r,$=i*n,T=a*r,P=c*f,A=d*p,z=o*f,R=d*h,B=o*p,U=c*h,q=e*f,D=d*s,K=e*p,F=c*s,j=e*h,V=o*s,at=w*h+W*p+C*f-(v*h+S*p+O*f),nt=v*s+X*p+N*f-(w*s+E*p+_*f),ct=S*s+E*h+$*f-(W*s+X*h+T*f),pt=O*s+_*h+T*p-(C*s+N*h+$*p),x=1/(e*at+o*nt+c*ct+d*pt);return[x*at,x*nt,x*ct,x*pt,x*(v*o+S*c+O*d-(w*o+W*c+C*d)),x*(w*e+E*c+_*d-(v*e+X*c+N*d)),x*(W*e+X*o+T*d-(S*e+E*o+$*d)),x*(C*e+N*o+$*c-(O*e+_*o+T*c)),x*(P*n+R*u+B*g-(A*n+z*u+U*g)),x*(A*r+q*u+F*g-(P*r+D*u+K*g)),x*(z*r+D*n+j*g-(R*r+q*n+V*g)),x*(U*r+K*n+V*u-(B*r+F*n+j*u)),x*(z*l+U*m+A*a-(B*m+P*a+R*l)),x*(K*m+P*i+D*l-(q*l+F*m+A*i)),x*(q*a+V*m+R*i-(j*m+z*i+D*a)),x*(j*l+B*i+F*a-(K*a+V*l+U*i))]},ie={class:"control"},vt=500,re=rt({__name:"imageCropper",props:{img:{},fixed:{}},setup(t,{expose:e}){const s=t,i=s.fixed[1]/s.fixed[0]*vt,r=new Image,o=tt(()=>{const p=typeof s.img=="string"?s.img:URL.createObjectURL(s.img);return r.src=p,p}),h=et(),a=et(),n=()=>{var O,X;const p=(O=h.value)==null?void 0:O.querySelector(".cropper-box-canvas"),l=(X=h.value)==null?void 0:X.querySelector(".cropper-crop-box"),u=dt(p),d=dt(l),f=[a.value.cropW,a.value.cropH],m=[I([-f[0]/2,-f[1]/2,0],d),I([f[0]/2,f[1]/2,0],d)],g=[r.width/p.offsetWidth,r.height/p.offsetHeight],w=se(u),v=I(m[0],w),S=I(m[1],w),W=[v[0]*g[0]+r.width/2,v[1]*g[1]+r.height/2,S[0]*g[0]+r.width/2,S[1]*g[1]+r.height/2],C={left:Math.round(W[0]),top:Math.round(W[1]),right:Math.round(W[2]),bottom:Math.round(W[3])};return C.left>C.right&&([C.left,C.right]=[C.right,C.left]),C.top>C.bottom&&([C.top,C.bottom]=[C.bottom,C.top]),{...C,rotate:a.value.rotate*Math.PI/2}};return e({submit:()=>{const p=n(),l=document.createElement("canvas"),u=l.getContext("2d"),d=p.right-p.left,f=p.bottom-p.top,m=Wt(ft(-d/2,-f/2,0),ee(p.rotate),ft(d/2,f/2,0)),g=I([0,0,0],m),w=I([d,f,0],m),v=l.width=Math.abs(w[0]-g[0]),S=l.height=Math.abs(w[1]-g[1]);return u.translate(v/2,S/2),u.rotate(p.rotate),u.drawImage(r,p.left,p.top,d,f,-d/2,-f/2,d,f),new Promise(W=>l.toBlob(W))}}),(p,l)=>{const u=Q("el-button");return Y(),k("div",null,[y("div",{class:"vue-crop-layout",ref_key:"layoutRef",ref:h,style:L({width:vt+"px",height:i+"px"})},[H(Ht(te),{class:"cropper-cls",ref_key:"cropperRef",ref:a,img:o.value,outputSize:1,canScale:"",autoCrop:"",centerBox:"",fixed:!!p.fixed,fixedNumber:p.fixed},null,8,["img","fixed","fixedNumber"])],4),y("div",ie,[H(u,{type:"primary",onClick:l[0]||(l[0]=d=>a.value.rotateRight())},{default:M(()=>l[1]||(l[1]=[st(" 旋转 ")])),_:1})])])}}});const oe=It(re,[["__scopeId","data-v-5c7991f7"]]),he=Mt(oe,{title:"图片裁剪",width:600}),Ce=(t,e)=>{const s={caseId:t.toString(),app:wt.deptId.toString()};e||(s.token=Z.value.token);const i=new URL(ht[b.SWMX][0],yt[b.SWMX]);for(const[r,o]of Object.entries(s))i.searchParams.append(r,o||"");return i.href},ye=async t=>{const e=await xt(t),s=[b.SWKK,b.SWKJ,b.SWSSMX,b.SWYDMX],i=e.filter(n=>s.includes(n.type));let r=null;if(e.length?i.length||(r=`带看仅支持${s.map(n=>it[n]).join("、")}类型场景,请添加此类型场景。`):r="当前案件下无场景,请先添加场景。",r)throw ot(r),r;const o=new URL(ht[b.SWKK][2],yt[b.SWKK]),h=await $t(t),a={vruserId:Z.value.info.userName,roomId:h,role:"leader",avatar:Z.value.info.avatar,redirect:encodeURIComponent(location.href),name:Z.value.info.userName,m:i[0].num};for(const[n,c]of Object.entries(a))o.searchParams.append(n,c||"");return o},ae=async(t,e)=>{(await xt(t)).length?window.open(e):ot("当前案件下无场景,请先添加场景。")},ne=(t,e=!1,s=!1)=>bt({type:99},t),xe=t=>{ae(t,ne(t,!0))};var ce=(t=>(t[t.FUSE=0]="FUSE",t[t.KANKAN=1]="KANKAN",t[t.LASER=2]="LASER",t))(ce||{});const pe=t=>{var i;const e=(i=t.contentWindow)==null?void 0:i.document.documentElement;return e?e.querySelector(".external")||t:null},Ot=async t=>{const e=pe(t);if(!e)return null;const s=e.contentWindow;return s.document.querySelector(".scene-canvas > canvas")?{type:0,sdk:s.sdk}:{type:s.document.querySelector(".laser-layer")?2:1,sdk:await s.__sdk}},be=t=>{const e=et(),s=setInterval(async()=>{const r=await Ot(t);e.value=r==null?void 0:r.type},100),i=Ct(r=>{});return()=>{clearInterval(s),i()}},Se=async(t,e=500,s=390)=>{var h,a,n;const i=await Ot(t);let r=null,o=null;switch(i==null?void 0:i.type){case 0:console.error(e,s);const c=await i.sdk.screenshot(e,s,0);r=await(await fetch(c)).blob();break;case 1:if(console.error("截图尺寸",e,s),i.sdk.Camera.mode=="floorplan")if((a=(h=i.sdk.store)==null?void 0:h.getValue("metadata"))!=null&&a.floorPlanUser){let l=(n=i.sdk.store)==null?void 0:n.getValue("metadata").num,u=i.sdk.core.get("Player").model.currentFloor.floorIndex,d="";i.sdk.store.getValue("flooruser").type==="image"?d=`floor-upload-${u}.jpg`:d=`cad-style-3-${u}.jpg`,o=`${bt({type:102})}/profile/scene_view_data/${l}/user/${d}?t=${Date.now()}`;let f=await kt(o);f.type!="text/html"&&(r=await he({img:f,fixed:[e,s]})),console.error("截图尺寸2",r)}else ot("暂未获取到平面图,请前往三维场景制作并保存");else{const l=await i.sdk.Camera.screenshot([{width:e,height:s,name:"2k",bgOpacity:0}],!1);r=gt(l[0].data)}break;case 2:r=await new Promise(l=>{i.sdk.scene.screenshot(e,s,0).done(u=>l(gt(u.dataUrl)))});break}return{type:i==null?void 0:i.type,blob:r,ognFilesUrl:o}},We=async(t,e,s,i=500,r=390,o=1)=>{console.log(i,s);const h=new Image;h.src=URL.createObjectURL(e),await new Promise(f=>h.onload=f);const a=document.createElement("canvas");a.width=h.width,a.height=h.height;const n=a.getContext("2d");n.drawImage(h,0,0,h.width,h.height);const c=t.contentWindow.document;Array.from(c.querySelectorAll(".hot-item")).forEach(f=>{var w;const m=(w=f.querySelector(".tip"))==null?void 0:w.innerText,g=s.findIndex(v=>v.tagTitle.trim()===(m==null?void 0:m.trim()));if(g!==-1){const v=f.getBoundingClientRect(),S=h.width/c.body.offsetWidth,W=S*32,C=S*32,O=v.left*S+W/2,X=v.top*S+C/2;n.save(),n.translate(O,X),n.beginPath(),n.arc(0,0,C/2,0,2*Math.PI),n.strokeStyle="#000",n.fillStyle="#fff",n.stroke(),n.fill(),n.beginPath(),n.fillStyle="#000",n.textAlign="center",n.textBaseline="middle",n.font=`normal ${C/2}px serif`,n.fillText((g+1).toString(),0,0),n.restore()}});const l=document.createElement("canvas");l.width=i,l.height=r;const u=l.getContext("2d");return Lt(u,l.width,l.height,a,h.width,h.height,0,0),await new Promise(f=>l.toBlob(f,"png"))};var le=(t=>(t[t.query=0]="query",t[t.edit=1]="edit",t))(le||{});const Oe=async(t,e)=>{const s=ht[t.type][e],i=new URL(s||"",window.location.href);t.type===b.SWMX?(i.searchParams.append("modelId",t.modelId.toString()),i.hash="#sign-model",i.searchParams.append("share","1"),i.searchParams.append("app",wt.deptId.toString())):(i.searchParams.append("m",t.num),e===1&&i.searchParams.append("token",await Yt(t))),window.open(i)},ue={class:"body-layer"},Xe=rt({__name:"list",props:{params:{}},setup(t){const e=[{value:b.SWKK,name:it[b.SWKK]},{value:b.SWKJ,name:it[b.SWKJ]}];return(s,i)=>{const r=Q("el-button"),o=Q("el-form-item"),h=Q("el-form");return Y(),k(Et,null,[H(Pt,{options:e,modelValue:s.params.pagging.state.query.isObj,"onUpdate:modelValue":i[0]||(i[0]=a=>s.params.pagging.state.query.isObj=a)},{default:M(()=>[H(h,{"label-width":"84px",inline:""},{default:M(()=>[mt(s.$slots,"header"),H(o,{class:"searh-btns",style:{"grid-area":"1 / 5 / 2 / 7"}},{default:M(()=>[H(r,{type:"primary",onClick:s.params.pagging.refresh},{default:M(()=>[st(J(s.$t("program.case.query")),1)]),_:1},8,["onClick"]),H(r,{type:"primary",plain:"",onClick:s.params.pagging.queryReset},{default:M(()=>[st(J(s.$t("sys.reset")),1)]),_:1},8,["onClick"])]),_:1})]),_:3})]),_:3},8,["modelValue"]),y("div",ue,[mt(s.$slots,"content"),H(At,{onSizeChange:s.params.pagging.changPageSize,onCurrentChange:s.params.pagging.changPageCurrent,"current-page":s.params.pagging.state.pag.currentPage,"page-size":s.params.pagging.state.pag.size,total:s.params.pagging.state.pag.total},null,8,["onSizeChange","onCurrentChange","current-page","page-size","total"])])],64)}}}),He=()=>{const t=zt({get:Tt,paramsTemlate:{isObj:b.SWKK,sceneName:"",modelTitle:"",deptId:"",snCode:""}}),e=tt(()=>t.state.query.type===b.SWMX),s=tt({get:()=>e.value?t.state.query.modelTitle:t.state.query.sceneName,set:o=>{t.state.query.modelTitle=o,t.state.query.sceneName=o}});let i=t.state.query.snCode;Ct(()=>{e.value?(i=t.state.query.snCode,t.state.query.snCode=""):t.state.query.snCode=i}),_t(()=>t.state.query.type,()=>{t.state.pag.currentPage=1});const r=t.queryReset;return t.queryReset=()=>{const o=t.state.query.type;r(),t.state.query.type=o},Nt({pagging:t,keyword:s,isSwmx:e})};export{ce as F,le as O,Xe as _,ye as a,xe as b,ae as c,ne as d,Se as e,be as f,Ce as g,We as h,he as i,Oe as o,He as u};
|