11 lines
46 KiB
JavaScript
11 lines
46 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-4174ddea"],{"145b":function(t,e,i){},"273e":function(t,e,i){t.exports=i.p+"img/xls_logo.2e70dc19.jpg"},"291e":function(t,e,i){t.exports=i.p+"img/doc_logo.4f9ade81.jpg"},"39a4":function(t,e,i){t.exports=i.p+"img/others_logo.79210fe5.jpg"},"5a9c":function(t,e,i){t.exports=i.p+"img/headImg.8b4031b9.jpg"},"850f":function(t,e,i){},"973c":function(t,e,i){"use strict";i("145b")},a0f2:function(t,e,i){},a421:function(t,e,i){"use strict";i.r(e);var a=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"content-layer account-settings min-h"},[i("h3",[t._v(t._s(t.$t("developer_info_alter")))]),i("div",{staticClass:"content"},[i("div",{staticClass:"form"},[i("Form",{ref:"formCustom",attrs:{model:t.info,rules:t.ruleCustom,"label-width":80}},[i("p",{staticClass:"username"},[t._v(t._s(t.$t("developer_type"))+":"),i("span",[t._v(t._s(t.info.member_level_name))])]),i("p",{staticClass:"username"},[t._v(t._s(t.$t("developer_account"))+":"),i("span",[t._v(t._s(t.info.username))])]),i("FormItem",{attrs:{label:t.$t("name")+":",prop:"nickname"}},[i("Input",{model:{value:t.info.nickname,callback:function(e){t.$set(t.info,"nickname",e)},expression:"info.nickname"}})],1),i("FormItem",{attrs:{label:t.$t("tel")+":",prop:"moblie"}},[i("Input",{model:{value:t.info.mobile,callback:function(e){t.$set(t.info,"mobile",e)},expression:"info.mobile"}})],1),i("FormItem",{attrs:{label:t.$t("email")+":",prop:"email"}},[i("Input",{attrs:{type:"text",number:""},model:{value:t.info.email,callback:function(e){t.$set(t.info,"email",e)},expression:"info.email"}})],1),i("FormItem",[i("Button",{staticClass:"btn",attrs:{type:"primary"},on:{click:function(e){return t.handleSubmit("formCustom")}}},[t._v(t._s(t.$t("save")))])],1)],1)],1),i("div",{staticClass:"header"},[i("img",{attrs:{src:t.info.avatar||t.defaultHead}}),i("Button",{on:{click:t.editHead}},[t._v(t._s(t.$t("alter_avatar")))]),i("Modal",{attrs:{title:t.$t("edit_avatar"),width:"50%",closable:!0},model:{value:t.modal,callback:function(e){t.modal=e},expression:"modal"}},[t.modal?i("cropper",{ref:"info",attrs:{"crop-button-text":t.$t("confirm")},on:{transmitInfo:t.handleCroped}}):t._e(),i("div",{attrs:{slot:"footer"},slot:"footer"})],1)],1)])])},n=[],o=(i("ac67"),i("1bc7"),i("32ea"),i("3612")),r=i("5a9c"),s=i.n(r),h=i("7736"),c=i("5723"),l=i("7e1e"),d=i("c276"),p=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"cropper-wrapper"},[i("div",{directives:[{name:"show",rawName:"v-show",value:1==t.isImage,expression:"isImage == 1"}],staticClass:"cropper-box"},[i("div",{staticClass:"img-box"},[i("img",{staticClass:"cropper-image",attrs:{id:t.imgId}})])]),i("div",{staticClass:"button-box"},[i("div",{directives:[{name:"show",rawName:"v-show",value:1==t.isImage,expression:"isImage == 1"}]},[i("Button",{attrs:{type:"primary"},on:{click:t.rotate}},[i("Icon",{attrs:{type:"md-refresh",size:18}})],1),i("Button",{attrs:{type:"primary"},on:{click:function(e){return t.scale("X")}}},[i("Icon",{attrs:{custom:"iconfont icon-shuipingfanzhuan",size:18}})],1),i("Button",{attrs:{type:"primary"},on:{click:function(e){return t.scale("Y")}}},[i("Icon",{attrs:{custom:"iconfont icon-chuizhifanzhuan",size:18}})],1),i("Button",{attrs:{type:"primary"},on:{click:t.startCrop}},[i("Icon",{attrs:{type:"md-crop",size:18}})],1),i("Button",{attrs:{type:"primary"},on:{click:t.cancelCrop}},[t._v("\n "+t._s(t.$t("use_origin_size"))+"}\n ")])],1)]),i("div",{directives:[{name:"show",rawName:"v-show",value:2==t.isImage,expression:"isImage == 2"}],staticClass:"file_logo"},[i("img",{attrs:{src:t.fileLogo}}),i("div",{staticClass:"file_name"},[t._v(t._s(t.fileName))])]),i("div",{staticClass:"underline"},[i("Upload",{directives:[{name:"show",rawName:"v-show",value:!t.insideSrc,expression:"!insideSrc"}],attrs:{type:"drag","before-upload":t.beforeUpload,action:"image/upload"}},[i("div",{staticStyle:{padding:"30px 180px"}},[i("Icon",{staticStyle:{color:"#ffa000"},attrs:{type:"ios-cloud-upload",size:"52"}}),i("p",[t._v(t._s(t.$t("select_or_drag_img")))])],1)]),i("Upload",{directives:[{name:"show",rawName:"v-show",value:t.insideSrc,expression:"insideSrc"}],attrs:{action:"image/upload","before-upload":t.beforeUpload}},[i("Button",{staticStyle:{width:"150px"},attrs:{icon:"ios-cloud-upload-outline"}},[t._v(t._s(t.$t("reupload")))])],1),i("Button",{directives:[{name:"show",rawName:"v-show",value:t.insideSrc,expression:"insideSrc"}],staticStyle:{width:"150px","margin-left":"10px",height:"31.9px"},attrs:{type:"primary"},on:{click:t.comfirm}},[t._v(t._s(t.cropButtonText))])],1)])},u=[],m=(i("a450"),i("8dee"),i("db0e")),f=i.n(m),g=(i("a0f2"),i("850f"),{name:"Cropper",props:{cropButtonText:{type:String,default:"确定"}},data:function(){return{cropper:null,fileSize:0,updataFile:{},insideSrc:"",infoFile:"",fileName:"",fileType:"",isImage:"",fileLogo:""}},computed:{imgId:function(){return"cropper".concat(this._uid)}},watch:{insideSrc:function(t){this.replace(t)}},methods:{beforeUpload:function(t){var e=this;this.updataFile=t,this.fileSize=t.size;var a=new FileReader;return a.readAsDataURL(t),a.onload=function(i){e.insideSrc=i.srcElement.result,e.fileName=t.name,e.fileType=t.type},this.fileName=t.name,this.fileType=t.type,/\.(jpe?g|png|gif)$/i.test(t.name)?this.isImage=1:/\.(xlsx?)$/i.test(t.name)?(this.isImage=2,this.fileLogo=i("273e")):/\.(docx?)$/i.test(t.name)?(this.isImage=2,this.fileLogo=i("291e")):/\.(pptx?)$/i.test(t.name)?(this.isImage=2,this.fileLogo=i("c555")):/\.(html)$/i.test(t.name)?(this.isImage=2,this.fileLogo=i("bc0e")):(this.isImage=2,this.fileLogo=i("39a4")),!1},replace:function(t){this.cropper.replace(t),this.insideSrc=t},rotate:function(){this.cropper.rotate(90)},scale:function(t){this.cropper["scale".concat(t)](-this.cropper.getData()["scale".concat(t)])},move:function(){var t;(t=this.cropper).move.apply(t,arguments)},startCrop:function(){this.cropper.crop()},cancelCrop:function(){this.cropper.clear()},comfirm:function(){var t;1===this.isImage?t=this.cropper.getCroppedCanvas().toDataURL():2===this.isImage&&(t=this.insideSrc);var e=this.fileName,i=this.fileType,a=this.fileSize,n=this.updataFile,o={fileSize:a,updataFile:n,dataUrl:t,name:e,type:i};this.$emit("transmitInfo",o),this.insideSrc="",this.isImage=0}},mounted:function(){var t=this;this.$nextTick((function(){var e=document.getElementById(t.imgId);t.cropper=new f.a(e,{checkCrossOrigin:!0,autoCrop:!1})}))}}),v=g,w=i("4ac2"),b=Object(w["a"])(v,p,u,!1,null,null,null),y=b.exports,x=y;function C(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,a)}return i}function M(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?C(Object(i),!0).forEach((function(e){Object(o["a"])(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):C(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}var D={components:{Cropper:x},name:"accountSettings",data:function(){return{modal:!1,defaultHead:s.a,token:Object(d["g"])(),info:{username:"",nickname:"",moblie:"",email:"",avatar:"",member_level_name:""},ruleCustom:{nickname:[{type:"string",min:1,max:20,message:this.$t("nickname_length_error_tips")}],phone:[],email:[]}}},created:function(){this.getInfo()},computed:M({},Object(h["e"])({userProfile:function(t){return t.user.userProfile}})),methods:M(M({},Object(h["b"])(["GetAccountData"])),{},{handleSubmit:function(){var t=this;if(this.info.moblie&&!/^1[3-9]\d{9}$/.test(this.info.moblie))return this.$Message.error(this.$t("tel_input_error"));if(this.info.email&&!/^\w+@[a-zA-Z0-9]{2,10}(?:\.[a-z]{2,4}){1,3}$/.test(this.info.email))return this.$Message.error(this.$t("email_input_error"));var e=new FormData;for(var i in e.append("access_token",this.token),this.info)this.info[i]&&e.append(i,this.info[i]);Object(c["i"])(e).then((function(e){200===e.ret?e.data.is_update?(t.$Message.success(t.$t("successfully_altered")),t.GetAccountData(),setTimeout((function(){t.$router.push({name:"accountInfo"},(function(t){console.log("error:",t)}))}),1e3)):(t.$Message.success(t.$t("nothing_altered")),t.$router.push({name:"accountInfo"},(function(t){console.log("error:",t)}))):(t.$Message.error(t.$t("fail_altered")),t.$router.push({name:"accountInfo"},(function(t){console.log("error:",t)})))}))},getInfo:function(){this.info=this.userProfile},editHead:function(){this.modal=!0},handleCroped:function(t){var e=this;if(/image/i.test(t.type)){var i=new FormData;i.append("access_token",this.token),i.append("file",t.updataFile),Object(l["d"])(i).then((function(t){200===t.ret?(e.modal=!1,e.info.avatar=t.data.url||defaultHead):(e.modal=!1,e.$Message.error(e.$t("file_too_large_error_content")))}))}else this.$Message.error(this.$t("document_format_error_content")),this.modal=!1},modalCanel:function(){this.modal=!1}})},k=D,O=(i("973c"),Object(w["a"])(k,a,n,!1,null,"0e6f680c",null));e["default"]=O.exports},bc0e:function(t,e,i){t.exports=i.p+"img/html_logo.8469259c.jpg"},c555:function(t,e,i){t.exports=i.p+"img/ppt_logo.db17f613.jpg"},db0e:function(t,e,i){
|
||
/*!
|
||
* Cropper.js v1.5.11
|
||
* https://fengyuanchen.github.io/cropperjs
|
||
*
|
||
* Copyright 2015-present Chen Fengyuan
|
||
* Released under the MIT license
|
||
*
|
||
* Date: 2021-02-17T11:53:27.572Z
|
||
*/
|
||
(function(e,i){t.exports=i()})(0,(function(){"use strict";function t(e){return t="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function a(t,e,a){return e&&i(t.prototype,e),a&&i(t,a),t}function n(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function o(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,a)}return i}function r(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?o(Object(i),!0).forEach((function(e){n(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):o(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function s(t){return h(t)||c(t)||l(t)||p()}function h(t){if(Array.isArray(t))return d(t)}function c(t){if("undefined"!==typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}function l(t,e){if(t){if("string"===typeof t)return d(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?d(t,e):void 0}}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,a=new Array(e);i<e;i++)a[i]=t[i];return a}function p(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u="undefined"!==typeof window&&"undefined"!==typeof window.document,m=u?window:{},f=!(!u||!m.document.documentElement)&&"ontouchstart"in m.document.documentElement,g=!!u&&"PointerEvent"in m,v="cropper",w="all",b="crop",y="move",x="zoom",C="e",M="w",D="s",k="n",O="ne",B="nw",_="se",T="sw",E="".concat(v,"-crop"),I="".concat(v,"-disabled"),N="".concat(v,"-hidden"),S="".concat(v,"-hide"),z="".concat(v,"-invisible"),j="".concat(v,"-modal"),H="".concat(v,"-move"),L="".concat(v,"Action"),W="".concat(v,"Preview"),$="crop",R="move",Y="none",X="crop",A="cropend",P="cropmove",U="cropstart",F="dblclick",q=f?"touchstart":"mousedown",Q=f?"touchmove":"mousemove",Z=f?"touchend touchcancel":"mouseup",G=g?"pointerdown":q,K=g?"pointermove":Q,J=g?"pointerup pointercancel":Z,V="ready",tt="resize",et="wheel",it="zoom",at="image/jpeg",nt=/^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/,ot=/^data:/,rt=/^data:image\/jpeg;base64,/,st=/^img|canvas$/i,ht=200,ct=100,lt={viewMode:0,dragMode:$,initialAspectRatio:NaN,aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:ht,minContainerHeight:ct,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},dt='<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>',pt=Number.isNaN||m.isNaN;function ut(t){return"number"===typeof t&&!pt(t)}var mt=function(t){return t>0&&t<1/0};function ft(t){return"undefined"===typeof t}function gt(e){return"object"===t(e)&&null!==e}var vt=Object.prototype.hasOwnProperty;function wt(t){if(!gt(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&&vt.call(i,"isPrototypeOf")}catch(a){return!1}}function bt(t){return"function"===typeof t}var yt=Array.prototype.slice;function xt(t){return Array.from?Array.from(t):yt.call(t)}function Ct(t,e){return t&&bt(e)&&(Array.isArray(t)||ut(t.length)?xt(t).forEach((function(i,a){e.call(t,i,a,t)})):gt(t)&&Object.keys(t).forEach((function(i){e.call(t,t[i],i,t)}))),t}var Mt=Object.assign||function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),a=1;a<e;a++)i[a-1]=arguments[a];return gt(t)&&i.length>0&&i.forEach((function(e){gt(e)&&Object.keys(e).forEach((function(i){t[i]=e[i]}))})),t},Dt=/\.\d*(?:0|9){12}\d*$/;function kt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e11;return Dt.test(t)?Math.round(t*e)/e:t}var Ot=/^width|height|left|top|marginLeft|marginTop$/;function Bt(t,e){var i=t.style;Ct(e,(function(t,e){Ot.test(e)&&ut(t)&&(t="".concat(t,"px")),i[e]=t}))}function _t(t,e){return t.classList?t.classList.contains(e):t.className.indexOf(e)>-1}function Tt(t,e){if(e)if(ut(t.length))Ct(t,(function(t){Tt(t,e)}));else if(t.classList)t.classList.add(e);else{var i=t.className.trim();i?i.indexOf(e)<0&&(t.className="".concat(i," ").concat(e)):t.className=e}}function Et(t,e){e&&(ut(t.length)?Ct(t,(function(t){Et(t,e)})):t.classList?t.classList.remove(e):t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function It(t,e,i){e&&(ut(t.length)?Ct(t,(function(t){It(t,e,i)})):i?Tt(t,e):Et(t,e))}var Nt=/([a-z\d])([A-Z])/g;function St(t){return t.replace(Nt,"$1-$2").toLowerCase()}function zt(t,e){return gt(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(St(e)))}function jt(t,e,i){gt(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-".concat(St(e)),i)}function Ht(t,e){if(gt(t[e]))try{delete t[e]}catch(i){t[e]=void 0}else if(t.dataset)try{delete t.dataset[e]}catch(i){t.dataset[e]=void 0}else t.removeAttribute("data-".concat(St(e)))}var Lt=/\s\s*/,Wt=function(){var t=!1;if(u){var e=!1,i=function(){},a=Object.defineProperty({},"once",{get:function(){return t=!0,e},set:function(t){e=t}});m.addEventListener("test",i,a),m.removeEventListener("test",i,a)}return t}();function $t(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(Lt).forEach((function(e){if(!Wt){var o=t.listeners;o&&o[e]&&o[e][i]&&(n=o[e][i],delete o[e][i],0===Object.keys(o[e]).length&&delete o[e],0===Object.keys(o).length&&delete t.listeners)}t.removeEventListener(e,n,a)}))}function Rt(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(Lt).forEach((function(e){if(a.once&&!Wt){var o=t.listeners,r=void 0===o?{}:o;n=function(){delete r[e][i],t.removeEventListener(e,n,a);for(var o=arguments.length,s=new Array(o),h=0;h<o;h++)s[h]=arguments[h];i.apply(t,s)},r[e]||(r[e]={}),r[e][i]&&t.removeEventListener(e,r[e][i],a),r[e][i]=n,t.listeners=r}t.addEventListener(e,n,a)}))}function Yt(t,e,i){var a;return bt(Event)&&bt(CustomEvent)?a=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}):(a=document.createEvent("CustomEvent"),a.initCustomEvent(e,!0,!0,i)),t.dispatchEvent(a)}function Xt(t){var e=t.getBoundingClientRect();return{left:e.left+(window.pageXOffset-document.documentElement.clientLeft),top:e.top+(window.pageYOffset-document.documentElement.clientTop)}}var At=m.location,Pt=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function Ut(t){var e=t.match(Pt);return null!==e&&(e[1]!==At.protocol||e[2]!==At.hostname||e[3]!==At.port)}function Ft(t){var e="timestamp=".concat((new Date).getTime());return t+(-1===t.indexOf("?")?"?":"&")+e}function qt(t){var e=t.rotate,i=t.scaleX,a=t.scaleY,n=t.translateX,o=t.translateY,r=[];ut(n)&&0!==n&&r.push("translateX(".concat(n,"px)")),ut(o)&&0!==o&&r.push("translateY(".concat(o,"px)")),ut(e)&&0!==e&&r.push("rotate(".concat(e,"deg)")),ut(i)&&1!==i&&r.push("scaleX(".concat(i,")")),ut(a)&&1!==a&&r.push("scaleY(".concat(a,")"));var s=r.length?r.join(" "):"none";return{WebkitTransform:s,msTransform:s,transform:s}}function Qt(t){var e=r({},t),i=0;return Ct(t,(function(t,a){delete e[a],Ct(e,(function(e){var a=Math.abs(t.startX-e.startX),n=Math.abs(t.startY-e.startY),o=Math.abs(t.endX-e.endX),r=Math.abs(t.endY-e.endY),s=Math.sqrt(a*a+n*n),h=Math.sqrt(o*o+r*r),c=(h-s)/s;Math.abs(c)>Math.abs(i)&&(i=c)}))})),i}function Zt(t,e){var i=t.pageX,a=t.pageY,n={endX:i,endY:a};return e?n:r({startX:i,startY:a},n)}function Gt(t){var e=0,i=0,a=0;return Ct(t,(function(t){var n=t.startX,o=t.startY;e+=n,i+=o,a+=1})),e/=a,i/=a,{pageX:e,pageY:i}}function Kt(t){var e=t.aspectRatio,i=t.height,a=t.width,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"contain",o=mt(a),r=mt(i);if(o&&r){var s=i*e;"contain"===n&&s>a||"cover"===n&&s<a?i=a/e:a=i*e}else o?i=a/e:r&&(a=i*e);return{width:a,height:i}}function Jt(t){var e=t.width,i=t.height,a=t.degree;if(a=Math.abs(a)%180,90===a)return{width:i,height:e};var n=a%90*Math.PI/180,o=Math.sin(n),r=Math.cos(n),s=e*r+i*o,h=e*o+i*r;return a>90?{width:h,height:s}:{width:s,height:h}}function Vt(t,e,i,a){var n=e.aspectRatio,o=e.naturalWidth,r=e.naturalHeight,h=e.rotate,c=void 0===h?0:h,l=e.scaleX,d=void 0===l?1:l,p=e.scaleY,u=void 0===p?1:p,m=i.aspectRatio,f=i.naturalWidth,g=i.naturalHeight,v=a.fillColor,w=void 0===v?"transparent":v,b=a.imageSmoothingEnabled,y=void 0===b||b,x=a.imageSmoothingQuality,C=void 0===x?"low":x,M=a.maxWidth,D=void 0===M?1/0:M,k=a.maxHeight,O=void 0===k?1/0:k,B=a.minWidth,_=void 0===B?0:B,T=a.minHeight,E=void 0===T?0:T,I=document.createElement("canvas"),N=I.getContext("2d"),S=Kt({aspectRatio:m,width:D,height:O}),z=Kt({aspectRatio:m,width:_,height:E},"cover"),j=Math.min(S.width,Math.max(z.width,f)),H=Math.min(S.height,Math.max(z.height,g)),L=Kt({aspectRatio:n,width:D,height:O}),W=Kt({aspectRatio:n,width:_,height:E},"cover"),$=Math.min(L.width,Math.max(W.width,o)),R=Math.min(L.height,Math.max(W.height,r)),Y=[-$/2,-R/2,$,R];return I.width=kt(j),I.height=kt(H),N.fillStyle=w,N.fillRect(0,0,j,H),N.save(),N.translate(j/2,H/2),N.rotate(c*Math.PI/180),N.scale(d,u),N.imageSmoothingEnabled=y,N.imageSmoothingQuality=C,N.drawImage.apply(N,[t].concat(s(Y.map((function(t){return Math.floor(kt(t))}))))),N.restore(),I}var te=String.fromCharCode;function ee(t,e,i){var a="";i+=e;for(var n=e;n<i;n+=1)a+=te(t.getUint8(n));return a}var ie=/^data:.*,/;function ae(t){var e=t.replace(ie,""),i=atob(e),a=new ArrayBuffer(i.length),n=new Uint8Array(a);return Ct(n,(function(t,e){n[e]=i.charCodeAt(e)})),a}function ne(t,e){var i=[],a=8192,n=new Uint8Array(t);while(n.length>0)i.push(te.apply(null,xt(n.subarray(0,a)))),n=n.subarray(a);return"data:".concat(e,";base64,").concat(btoa(i.join("")))}function oe(t){var e,i=new DataView(t);try{var a,n,o;if(255===i.getUint8(0)&&216===i.getUint8(1)){var r=i.byteLength,s=2;while(s+1<r){if(255===i.getUint8(s)&&225===i.getUint8(s+1)){n=s;break}s+=1}}if(n){var h=n+4,c=n+10;if("Exif"===ee(i,h,4)){var l=i.getUint16(c);if(a=18761===l,(a||19789===l)&&42===i.getUint16(c+2,a)){var d=i.getUint32(c+4,a);d>=8&&(o=c+d)}}}if(o){var p,u,m=i.getUint16(o,a);for(u=0;u<m;u+=1)if(p=o+12*u+2,274===i.getUint16(p,a)){p+=8,e=i.getUint16(p,a),i.setUint16(p,1,a);break}}}catch(f){e=1}return e}function re(t){var e=0,i=1,a=1;switch(t){case 2:i=-1;break;case 3:e=-180;break;case 4:a=-1;break;case 5:e=90,a=-1;break;case 6:e=90;break;case 7:e=90,i=-1;break;case 8:e=-90;break}return{rotate:e,scaleX:i,scaleY:a}}var se={render:function(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function(){var t=this.element,e=this.options,i=this.container,a=this.cropper,n=Number(e.minContainerWidth),o=Number(e.minContainerHeight);Tt(a,N),Et(t,N);var r={width:Math.max(i.offsetWidth,n>=0?n:ht),height:Math.max(i.offsetHeight,o>=0?o:ct)};this.containerData=r,Bt(a,{width:r.width,height:r.height}),Tt(t,N),Et(a,N)},initCanvas:function(){var t=this.containerData,e=this.imageData,i=this.options.viewMode,a=Math.abs(e.rotate)%180===90,n=a?e.naturalHeight:e.naturalWidth,o=a?e.naturalWidth:e.naturalHeight,r=n/o,s=t.width,h=t.height;t.height*r>t.width?3===i?s=t.height*r:h=t.width/r:3===i?h=t.width/r:s=t.height*r;var c={aspectRatio:r,naturalWidth:n,naturalHeight:o,width:s,height:h};this.canvasData=c,this.limited=1===i||2===i,this.limitCanvas(!0,!0),c.width=Math.min(Math.max(c.width,c.minWidth),c.maxWidth),c.height=Math.min(Math.max(c.height,c.minHeight),c.maxHeight),c.left=(t.width-c.width)/2,c.top=(t.height-c.height)/2,c.oldLeft=c.left,c.oldTop=c.top,this.initialCanvasData=Mt({},c)},limitCanvas:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,r=i.viewMode,s=n.aspectRatio,h=this.cropped&&o;if(t){var c=Number(i.minCanvasWidth)||0,l=Number(i.minCanvasHeight)||0;r>1?(c=Math.max(c,a.width),l=Math.max(l,a.height),3===r&&(l*s>c?c=l*s:l=c/s)):r>0&&(c?c=Math.max(c,h?o.width:0):l?l=Math.max(l,h?o.height:0):h&&(c=o.width,l=o.height,l*s>c?c=l*s:l=c/s));var d=Kt({aspectRatio:s,width:c,height:l});c=d.width,l=d.height,n.minWidth=c,n.minHeight=l,n.maxWidth=1/0,n.maxHeight=1/0}if(e)if(r>(h?0:1)){var p=a.width-n.width,u=a.height-n.height;n.minLeft=Math.min(0,p),n.minTop=Math.min(0,u),n.maxLeft=Math.max(0,p),n.maxTop=Math.max(0,u),h&&this.limited&&(n.minLeft=Math.min(o.left,o.left+(o.width-n.width)),n.minTop=Math.min(o.top,o.top+(o.height-n.height)),n.maxLeft=o.left,n.maxTop=o.top,2===r&&(n.width>=a.width&&(n.minLeft=Math.min(0,p),n.maxLeft=Math.max(0,p)),n.height>=a.height&&(n.minTop=Math.min(0,u),n.maxTop=Math.max(0,u))))}else n.minLeft=-n.width,n.minTop=-n.height,n.maxLeft=a.width,n.maxTop=a.height},renderCanvas:function(t,e){var i=this.canvasData,a=this.imageData;if(e){var n=Jt({width:a.naturalWidth*Math.abs(a.scaleX||1),height:a.naturalHeight*Math.abs(a.scaleY||1),degree:a.rotate||0}),o=n.width,r=n.height,s=i.width*(o/i.naturalWidth),h=i.height*(r/i.naturalHeight);i.left-=(s-i.width)/2,i.top-=(h-i.height)/2,i.width=s,i.height=h,i.aspectRatio=o/r,i.naturalWidth=o,i.naturalHeight=r,this.limitCanvas(!0,!1)}(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCanvas(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,Bt(this.canvas,Mt({width:i.width,height:i.height},qt({translateX:i.left,translateY:i.top}))),this.renderImage(t),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function(t){var e=this.canvasData,i=this.imageData,a=i.naturalWidth*(e.width/e.naturalWidth),n=i.naturalHeight*(e.height/e.naturalHeight);Mt(i,{width:a,height:n,left:(e.width-a)/2,top:(e.height-n)/2}),Bt(this.image,Mt({width:i.width,height:i.height},qt(Mt({translateX:i.left,translateY:i.top},i)))),t&&this.output()},initCropBox:function(){var t=this.options,e=this.canvasData,i=t.aspectRatio||t.initialAspectRatio,a=Number(t.autoCropArea)||.8,n={width:e.width,height:e.height};i&&(e.height*i>e.width?n.height=n.width/i:n.width=n.height*i),this.cropBoxData=n,this.limitCropBox(!0,!0),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),n.width=Math.max(n.minWidth,n.width*a),n.height=Math.max(n.minHeight,n.height*a),n.left=e.left+(e.width-n.width)/2,n.top=e.top+(e.height-n.height)/2,n.oldLeft=n.left,n.oldTop=n.top,this.initialCropBoxData=Mt({},n)},limitCropBox:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,r=this.limited,s=i.aspectRatio;if(t){var h=Number(i.minCropBoxWidth)||0,c=Number(i.minCropBoxHeight)||0,l=r?Math.min(a.width,n.width,n.width+n.left,a.width-n.left):a.width,d=r?Math.min(a.height,n.height,n.height+n.top,a.height-n.top):a.height;h=Math.min(h,a.width),c=Math.min(c,a.height),s&&(h&&c?c*s>h?c=h/s:h=c*s:h?c=h/s:c&&(h=c*s),d*s>l?d=l/s:l=d*s),o.minWidth=Math.min(h,l),o.minHeight=Math.min(c,d),o.maxWidth=l,o.maxHeight=d}e&&(r?(o.minLeft=Math.max(0,n.left),o.minTop=Math.max(0,n.top),o.maxLeft=Math.min(a.width,n.left+n.width)-o.width,o.maxTop=Math.min(a.height,n.top+n.height)-o.height):(o.minLeft=0,o.minTop=0,o.maxLeft=a.width-o.width,o.maxTop=a.height-o.height))},renderCropBox:function(){var t=this.options,e=this.containerData,i=this.cropBoxData;(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCropBox(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,t.movable&&t.cropBoxMovable&&jt(this.face,L,i.width>=e.width&&i.height>=e.height?y:w),Bt(this.cropBox,Mt({width:i.width,height:i.height},qt({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),Yt(this.element,X,this.getData())}},he={initPreview:function(){var t=this.element,e=this.crossOrigin,i=this.options.preview,a=e?this.crossOriginUrl:this.url,n=t.alt||"The image to preview",o=document.createElement("img");if(e&&(o.crossOrigin=e),o.src=a,o.alt=n,this.viewBox.appendChild(o),this.viewBoxImage=o,i){var r=i;"string"===typeof i?r=t.ownerDocument.querySelectorAll(i):i.querySelector&&(r=[i]),this.previews=r,Ct(r,(function(t){var i=document.createElement("img");jt(t,W,{width:t.offsetWidth,height:t.offsetHeight,html:t.innerHTML}),e&&(i.crossOrigin=e),i.src=a,i.alt=n,i.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',t.innerHTML="",t.appendChild(i)}))}},resetPreview:function(){Ct(this.previews,(function(t){var e=zt(t,W);Bt(t,{width:e.width,height:e.height}),t.innerHTML=e.html,Ht(t,W)}))},preview:function(){var t=this.imageData,e=this.canvasData,i=this.cropBoxData,a=i.width,n=i.height,o=t.width,r=t.height,s=i.left-e.left-t.left,h=i.top-e.top-t.top;this.cropped&&!this.disabled&&(Bt(this.viewBoxImage,Mt({width:o,height:r},qt(Mt({translateX:-s,translateY:-h},t)))),Ct(this.previews,(function(e){var i=zt(e,W),c=i.width,l=i.height,d=c,p=l,u=1;a&&(u=c/a,p=n*u),n&&p>l&&(u=l/n,d=a*u,p=l),Bt(e,{width:d,height:p}),Bt(e.getElementsByTagName("img")[0],Mt({width:o*u,height:r*u},qt(Mt({translateX:-s*u,translateY:-h*u},t))))})))}},ce={bind:function(){var t=this.element,e=this.options,i=this.cropper;bt(e.cropstart)&&Rt(t,U,e.cropstart),bt(e.cropmove)&&Rt(t,P,e.cropmove),bt(e.cropend)&&Rt(t,A,e.cropend),bt(e.crop)&&Rt(t,X,e.crop),bt(e.zoom)&&Rt(t,it,e.zoom),Rt(i,G,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&Rt(i,et,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&Rt(i,F,this.onDblclick=this.dblclick.bind(this)),Rt(t.ownerDocument,K,this.onCropMove=this.cropMove.bind(this)),Rt(t.ownerDocument,J,this.onCropEnd=this.cropEnd.bind(this)),e.responsive&&Rt(window,tt,this.onResize=this.resize.bind(this))},unbind:function(){var t=this.element,e=this.options,i=this.cropper;bt(e.cropstart)&&$t(t,U,e.cropstart),bt(e.cropmove)&&$t(t,P,e.cropmove),bt(e.cropend)&&$t(t,A,e.cropend),bt(e.crop)&&$t(t,X,e.crop),bt(e.zoom)&&$t(t,it,e.zoom),$t(i,G,this.onCropStart),e.zoomable&&e.zoomOnWheel&&$t(i,et,this.onWheel,{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&$t(i,F,this.onDblclick),$t(t.ownerDocument,K,this.onCropMove),$t(t.ownerDocument,J,this.onCropEnd),e.responsive&&$t(window,tt,this.onResize)}},le={resize:function(){if(!this.disabled){var t,e,i=this.options,a=this.container,n=this.containerData,o=a.offsetWidth/n.width;if(1!==o||a.offsetHeight!==n.height)i.restore&&(t=this.getCanvasData(),e=this.getCropBoxData()),this.render(),i.restore&&(this.setCanvasData(Ct(t,(function(e,i){t[i]=e*o}))),this.setCropBoxData(Ct(e,(function(t,i){e[i]=t*o}))))}},dblclick:function(){this.disabled||this.options.dragMode===Y||this.setDragMode(_t(this.dragBox,E)?R:$)},wheel:function(t){var e=this,i=Number(this.options.wheelZoomRatio)||.1,a=1;this.disabled||(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout((function(){e.wheeling=!1}),50),t.deltaY?a=t.deltaY>0?1:-1:t.wheelDelta?a=-t.wheelDelta/120:t.detail&&(a=t.detail>0?1:-1),this.zoom(-a*i,t)))},cropStart:function(t){var e=t.buttons,i=t.button;if(!(this.disabled||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(ut(e)&&1!==e||ut(i)&&0!==i||t.ctrlKey))){var a,n=this.options,o=this.pointers;t.changedTouches?Ct(t.changedTouches,(function(t){o[t.identifier]=Zt(t)})):o[t.pointerId||0]=Zt(t),a=Object.keys(o).length>1&&n.zoomable&&n.zoomOnTouch?x:zt(t.target,L),nt.test(a)&&!1!==Yt(this.element,U,{originalEvent:t,action:a})&&(t.preventDefault(),this.action=a,this.cropping=!1,a===b&&(this.cropping=!0,Tt(this.dragBox,j)))}},cropMove:function(t){var e=this.action;if(!this.disabled&&e){var i=this.pointers;t.preventDefault(),!1!==Yt(this.element,P,{originalEvent:t,action:e})&&(t.changedTouches?Ct(t.changedTouches,(function(t){Mt(i[t.identifier]||{},Zt(t,!0))})):Mt(i[t.pointerId||0]||{},Zt(t,!0)),this.change(t))}},cropEnd:function(t){if(!this.disabled){var e=this.action,i=this.pointers;t.changedTouches?Ct(t.changedTouches,(function(t){delete i[t.identifier]})):delete i[t.pointerId||0],e&&(t.preventDefault(),Object.keys(i).length||(this.action=""),this.cropping&&(this.cropping=!1,It(this.dragBox,j,this.cropped&&this.options.modal)),Yt(this.element,A,{originalEvent:t,action:e}))}}},de={change:function(t){var e,i=this.options,a=this.canvasData,n=this.containerData,o=this.cropBoxData,r=this.pointers,s=this.action,h=i.aspectRatio,c=o.left,l=o.top,d=o.width,p=o.height,u=c+d,m=l+p,f=0,g=0,v=n.width,E=n.height,I=!0;!h&&t.shiftKey&&(h=d&&p?d/p:1),this.limited&&(f=o.minLeft,g=o.minTop,v=f+Math.min(n.width,a.width,a.left+a.width),E=g+Math.min(n.height,a.height,a.top+a.height));var S=r[Object.keys(r)[0]],z={x:S.endX-S.startX,y:S.endY-S.startY},j=function(t){switch(t){case C:u+z.x>v&&(z.x=v-u);break;case M:c+z.x<f&&(z.x=f-c);break;case k:l+z.y<g&&(z.y=g-l);break;case D:m+z.y>E&&(z.y=E-m);break}};switch(s){case w:c+=z.x,l+=z.y;break;case C:if(z.x>=0&&(u>=v||h&&(l<=g||m>=E))){I=!1;break}j(C),d+=z.x,d<0&&(s=M,d=-d,c-=d),h&&(p=d/h,l+=(o.height-p)/2);break;case k:if(z.y<=0&&(l<=g||h&&(c<=f||u>=v))){I=!1;break}j(k),p-=z.y,l+=z.y,p<0&&(s=D,p=-p,l-=p),h&&(d=p*h,c+=(o.width-d)/2);break;case M:if(z.x<=0&&(c<=f||h&&(l<=g||m>=E))){I=!1;break}j(M),d-=z.x,c+=z.x,d<0&&(s=C,d=-d,c-=d),h&&(p=d/h,l+=(o.height-p)/2);break;case D:if(z.y>=0&&(m>=E||h&&(c<=f||u>=v))){I=!1;break}j(D),p+=z.y,p<0&&(s=k,p=-p,l-=p),h&&(d=p*h,c+=(o.width-d)/2);break;case O:if(h){if(z.y<=0&&(l<=g||u>=v)){I=!1;break}j(k),p-=z.y,l+=z.y,d=p*h}else j(k),j(C),z.x>=0?u<v?d+=z.x:z.y<=0&&l<=g&&(I=!1):d+=z.x,z.y<=0?l>g&&(p-=z.y,l+=z.y):(p-=z.y,l+=z.y);d<0&&p<0?(s=T,p=-p,d=-d,l-=p,c-=d):d<0?(s=B,d=-d,c-=d):p<0&&(s=_,p=-p,l-=p);break;case B:if(h){if(z.y<=0&&(l<=g||c<=f)){I=!1;break}j(k),p-=z.y,l+=z.y,d=p*h,c+=o.width-d}else j(k),j(M),z.x<=0?c>f?(d-=z.x,c+=z.x):z.y<=0&&l<=g&&(I=!1):(d-=z.x,c+=z.x),z.y<=0?l>g&&(p-=z.y,l+=z.y):(p-=z.y,l+=z.y);d<0&&p<0?(s=_,p=-p,d=-d,l-=p,c-=d):d<0?(s=O,d=-d,c-=d):p<0&&(s=T,p=-p,l-=p);break;case T:if(h){if(z.x<=0&&(c<=f||m>=E)){I=!1;break}j(M),d-=z.x,c+=z.x,p=d/h}else j(D),j(M),z.x<=0?c>f?(d-=z.x,c+=z.x):z.y>=0&&m>=E&&(I=!1):(d-=z.x,c+=z.x),z.y>=0?m<E&&(p+=z.y):p+=z.y;d<0&&p<0?(s=O,p=-p,d=-d,l-=p,c-=d):d<0?(s=_,d=-d,c-=d):p<0&&(s=B,p=-p,l-=p);break;case _:if(h){if(z.x>=0&&(u>=v||m>=E)){I=!1;break}j(C),d+=z.x,p=d/h}else j(D),j(C),z.x>=0?u<v?d+=z.x:z.y>=0&&m>=E&&(I=!1):d+=z.x,z.y>=0?m<E&&(p+=z.y):p+=z.y;d<0&&p<0?(s=B,p=-p,d=-d,l-=p,c-=d):d<0?(s=T,d=-d,c-=d):p<0&&(s=O,p=-p,l-=p);break;case y:this.move(z.x,z.y),I=!1;break;case x:this.zoom(Qt(r),t),I=!1;break;case b:if(!z.x||!z.y){I=!1;break}e=Xt(this.cropper),c=S.startX-e.left,l=S.startY-e.top,d=o.minWidth,p=o.minHeight,z.x>0?s=z.y>0?_:O:z.x<0&&(c-=d,s=z.y>0?T:B),z.y<0&&(l-=p),this.cropped||(Et(this.cropBox,N),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0));break}I&&(o.width=d,o.height=p,o.left=c,o.top=l,this.action=s,this.renderCropBox()),Ct(r,(function(t){t.startX=t.endX,t.startY=t.endY}))}},pe={crop:function(){return!this.ready||this.cropped||this.disabled||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&Tt(this.dragBox,j),Et(this.cropBox,N),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=Mt({},this.initialImageData),this.canvasData=Mt({},this.initialCanvasData),this.cropBoxData=Mt({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(Mt(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),Et(this.dragBox,j),Tt(this.cropBox,N)),this},replace:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&t&&(this.isImg&&(this.element.src=t),e?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,Ct(this.previews,(function(e){e.getElementsByTagName("img")[0].src=t})))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function(){return this.ready&&this.disabled&&(this.disabled=!1,Et(this.cropper,I)),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,Tt(this.cropper,I)),this},destroy:function(){var t=this.element;return t[v]?(t[v]=void 0,this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),this):this},move:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=i.left,n=i.top;return this.moveTo(ft(t)?t:a+Number(t),ft(e)?e:n+Number(e))},moveTo:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(ut(t)&&(i.left=t,a=!0),ut(e)&&(i.top=e,a=!0),a&&this.renderCanvas(!0)),this},zoom:function(t,e){var i=this.canvasData;return t=Number(t),t=t<0?1/(1-t):1+t,this.zoomTo(i.width*t/i.naturalWidth,null,e)},zoomTo:function(t,e,i){var a=this.options,n=this.canvasData,o=n.width,r=n.height,s=n.naturalWidth,h=n.naturalHeight;if(t=Number(t),t>=0&&this.ready&&!this.disabled&&a.zoomable){var c=s*t,l=h*t;if(!1===Yt(this.element,it,{ratio:t,oldRatio:o/s,originalEvent:i}))return this;if(i){var d=this.pointers,p=Xt(this.cropper),u=d&&Object.keys(d).length?Gt(d):{pageX:i.pageX,pageY:i.pageY};n.left-=(c-o)*((u.pageX-p.left-n.left)/o),n.top-=(l-r)*((u.pageY-p.top-n.top)/r)}else wt(e)&&ut(e.x)&&ut(e.y)?(n.left-=(c-o)*((e.x-n.left)/o),n.top-=(l-r)*((e.y-n.top)/r)):(n.left-=(c-o)/2,n.top-=(l-r)/2);n.width=c,n.height=l,this.renderCanvas(!0)}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function(t){return t=Number(t),ut(t)&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function(t){var e=this.imageData.scaleY;return this.scale(t,ut(e)?e:1)},scaleY:function(t){var e=this.imageData.scaleX;return this.scale(ut(e)?e:1,t)},scale:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(ut(t)&&(i.scaleX=t,a=!0),ut(e)&&(i.scaleY=e,a=!0),a&&this.renderCanvas(!0,!0)),this},getData:function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=this.options,a=this.imageData,n=this.canvasData,o=this.cropBoxData;if(this.ready&&this.cropped){t={x:o.left-n.left,y:o.top-n.top,width:o.width,height:o.height};var r=a.width/a.naturalWidth;if(Ct(t,(function(e,i){t[i]=e/r})),e){var s=Math.round(t.y+t.height),h=Math.round(t.x+t.width);t.x=Math.round(t.x),t.y=Math.round(t.y),t.width=h-t.x,t.height=s-t.y}}else t={x:0,y:0,width:0,height:0};return i.rotatable&&(t.rotate=a.rotate||0),i.scalable&&(t.scaleX=a.scaleX||1,t.scaleY=a.scaleY||1),t},setData:function(t){var e=this.options,i=this.imageData,a=this.canvasData,n={};if(this.ready&&!this.disabled&&wt(t)){var o=!1;e.rotatable&&ut(t.rotate)&&t.rotate!==i.rotate&&(i.rotate=t.rotate,o=!0),e.scalable&&(ut(t.scaleX)&&t.scaleX!==i.scaleX&&(i.scaleX=t.scaleX,o=!0),ut(t.scaleY)&&t.scaleY!==i.scaleY&&(i.scaleY=t.scaleY,o=!0)),o&&this.renderCanvas(!0,!0);var r=i.width/i.naturalWidth;ut(t.x)&&(n.left=t.x*r+a.left),ut(t.y)&&(n.top=t.y*r+a.top),ut(t.width)&&(n.width=t.width*r),ut(t.height)&&(n.height=t.height*r),this.setCropBoxData(n)}return this},getContainerData:function(){return this.ready?Mt({},this.containerData):{}},getImageData:function(){return this.sized?Mt({},this.imageData):{}},getCanvasData:function(){var t=this.canvasData,e={};return this.ready&&Ct(["left","top","width","height","naturalWidth","naturalHeight"],(function(i){e[i]=t[i]})),e},setCanvasData:function(t){var e=this.canvasData,i=e.aspectRatio;return this.ready&&!this.disabled&&wt(t)&&(ut(t.left)&&(e.left=t.left),ut(t.top)&&(e.top=t.top),ut(t.width)?(e.width=t.width,e.height=t.width/i):ut(t.height)&&(e.height=t.height,e.width=t.height*i),this.renderCanvas(!0)),this},getCropBoxData:function(){var t,e=this.cropBoxData;return this.ready&&this.cropped&&(t={left:e.left,top:e.top,width:e.width,height:e.height}),t||{}},setCropBoxData:function(t){var e,i,a=this.cropBoxData,n=this.options.aspectRatio;return this.ready&&this.cropped&&!this.disabled&&wt(t)&&(ut(t.left)&&(a.left=t.left),ut(t.top)&&(a.top=t.top),ut(t.width)&&t.width!==a.width&&(e=!0,a.width=t.width),ut(t.height)&&t.height!==a.height&&(i=!0,a.height=t.height),n&&(e?a.height=a.width/n:i&&(a.width=a.height*n)),this.renderCropBox()),this},getCroppedCanvas:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e=this.canvasData,i=Vt(this.image,this.imageData,e,t);if(!this.cropped)return i;var a=this.getData(),n=a.x,o=a.y,r=a.width,h=a.height,c=i.width/Math.floor(e.naturalWidth);1!==c&&(n*=c,o*=c,r*=c,h*=c);var l=r/h,d=Kt({aspectRatio:l,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),p=Kt({aspectRatio:l,width:t.minWidth||0,height:t.minHeight||0},"cover"),u=Kt({aspectRatio:l,width:t.width||(1!==c?i.width:r),height:t.height||(1!==c?i.height:h)}),m=u.width,f=u.height;m=Math.min(d.width,Math.max(p.width,m)),f=Math.min(d.height,Math.max(p.height,f));var g=document.createElement("canvas"),v=g.getContext("2d");g.width=kt(m),g.height=kt(f),v.fillStyle=t.fillColor||"transparent",v.fillRect(0,0,m,f);var w=t.imageSmoothingEnabled,b=void 0===w||w,y=t.imageSmoothingQuality;v.imageSmoothingEnabled=b,y&&(v.imageSmoothingQuality=y);var x,C,M,D,k,O,B=i.width,_=i.height,T=n,E=o;T<=-r||T>B?(T=0,x=0,M=0,k=0):T<=0?(M=-T,T=0,x=Math.min(B,r+T),k=x):T<=B&&(M=0,x=Math.min(r,B-T),k=x),x<=0||E<=-h||E>_?(E=0,C=0,D=0,O=0):E<=0?(D=-E,E=0,C=Math.min(_,h+E),O=C):E<=_&&(D=0,C=Math.min(h,_-E),O=C);var I=[T,E,x,C];if(k>0&&O>0){var N=m/r;I.push(M*N,D*N,k*N,O*N)}return v.drawImage.apply(v,[i].concat(s(I.map((function(t){return Math.floor(kt(t))}))))),g},setAspectRatio:function(t){var e=this.options;return this.disabled||ft(t)||(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(t){var e=this.options,i=this.dragBox,a=this.face;if(this.ready&&!this.disabled){var n=t===$,o=e.movable&&t===R;t=n||o?t:Y,e.dragMode=t,jt(i,L,t),It(i,E,n),It(i,H,o),e.cropBoxMovable||(jt(a,L,t),It(a,E,n),It(a,H,o))}return this}},ue=m.Cropper,me=function(){function t(i){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e(this,t),!i||!st.test(i.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=i,this.options=Mt({},lt,wt(a)&&a),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return a(t,[{key:"init",value:function(){var t,e=this.element,i=e.tagName.toLowerCase();if(!e[v]){if(e[v]=this,"img"===i){if(this.isImg=!0,t=e.getAttribute("src")||"",this.originalUrl=t,!t)return;t=e.src}else"canvas"===i&&window.HTMLCanvasElement&&(t=e.toDataURL());this.load(t)}}},{key:"load",value:function(t){var e=this;if(t){this.url=t,this.imageData={};var i=this.element,a=this.options;if(a.rotatable||a.scalable||(a.checkOrientation=!1),a.checkOrientation&&window.ArrayBuffer)if(ot.test(t))rt.test(t)?this.read(ae(t)):this.clone();else{var n=new XMLHttpRequest,o=this.clone.bind(this);this.reloading=!0,this.xhr=n,n.onabort=o,n.onerror=o,n.ontimeout=o,n.onprogress=function(){n.getResponseHeader("content-type")!==at&&n.abort()},n.onload=function(){e.read(n.response)},n.onloadend=function(){e.reloading=!1,e.xhr=null},a.checkCrossOrigin&&Ut(t)&&i.crossOrigin&&(t=Ft(t)),n.open("GET",t,!0),n.responseType="arraybuffer",n.withCredentials="use-credentials"===i.crossOrigin,n.send()}else this.clone()}}},{key:"read",value:function(t){var e=this.options,i=this.imageData,a=oe(t),n=0,o=1,r=1;if(a>1){this.url=ne(t,at);var s=re(a);n=s.rotate,o=s.scaleX,r=s.scaleY}e.rotatable&&(i.rotate=n),e.scalable&&(i.scaleX=o,i.scaleY=r),this.clone()}},{key:"clone",value:function(){var t=this.element,e=this.url,i=t.crossOrigin,a=e;this.options.checkCrossOrigin&&Ut(e)&&(i||(i="anonymous"),a=Ft(e)),this.crossOrigin=i,this.crossOriginUrl=a;var n=document.createElement("img");i&&(n.crossOrigin=i),n.src=a||e,n.alt=t.alt||"The image to crop",this.image=n,n.onload=this.start.bind(this),n.onerror=this.stop.bind(this),Tt(n,S),t.parentNode.insertBefore(n,t.nextSibling)}},{key:"start",value:function(){var t=this,e=this.image;e.onload=null,e.onerror=null,this.sizing=!0;var i=m.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(m.navigator.userAgent),a=function(e,i){Mt(t.imageData,{naturalWidth:e,naturalHeight:i,aspectRatio:e/i}),t.initialImageData=Mt({},t.imageData),t.sizing=!1,t.sized=!0,t.build()};if(!e.naturalWidth||i){var n=document.createElement("img"),o=document.body||document.documentElement;this.sizingImage=n,n.onload=function(){a(n.width,n.height),i||o.removeChild(n)},n.src=e.src,i||(n.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",o.appendChild(n))}else a(e.naturalWidth,e.naturalHeight)}},{key:"stop",value:function(){var t=this.image;t.onload=null,t.onerror=null,t.parentNode.removeChild(t),this.image=null}},{key:"build",value:function(){if(this.sized&&!this.ready){var t=this.element,e=this.options,i=this.image,a=t.parentNode,n=document.createElement("div");n.innerHTML=dt;var o=n.querySelector(".".concat(v,"-container")),r=o.querySelector(".".concat(v,"-canvas")),s=o.querySelector(".".concat(v,"-drag-box")),h=o.querySelector(".".concat(v,"-crop-box")),c=h.querySelector(".".concat(v,"-face"));this.container=a,this.cropper=o,this.canvas=r,this.dragBox=s,this.cropBox=h,this.viewBox=o.querySelector(".".concat(v,"-view-box")),this.face=c,r.appendChild(i),Tt(t,N),a.insertBefore(o,t.nextSibling),this.isImg||Et(i,S),this.initPreview(),this.bind(),e.initialAspectRatio=Math.max(0,e.initialAspectRatio)||NaN,e.aspectRatio=Math.max(0,e.aspectRatio)||NaN,e.viewMode=Math.max(0,Math.min(3,Math.round(e.viewMode)))||0,Tt(h,N),e.guides||Tt(h.getElementsByClassName("".concat(v,"-dashed")),N),e.center||Tt(h.getElementsByClassName("".concat(v,"-center")),N),e.background&&Tt(o,"".concat(v,"-bg")),e.highlight||Tt(c,z),e.cropBoxMovable&&(Tt(c,H),jt(c,L,w)),e.cropBoxResizable||(Tt(h.getElementsByClassName("".concat(v,"-line")),N),Tt(h.getElementsByClassName("".concat(v,"-point")),N)),this.render(),this.ready=!0,this.setDragMode(e.dragMode),e.autoCrop&&this.crop(),this.setData(e.data),bt(e.ready)&&Rt(t,V,e.ready,{once:!0}),Yt(t,V)}}},{key:"unbuild",value:function(){this.ready&&(this.ready=!1,this.unbind(),this.resetPreview(),this.cropper.parentNode.removeChild(this.cropper),Et(this.element,N))}},{key:"uncreate",value:function(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}],[{key:"noConflict",value:function(){return window.Cropper=ue,t}},{key:"setDefaults",value:function(t){Mt(lt,wt(t)&&t)}}]),t}();return Mt(me.prototype,se,he,ce,le,de,pe),me}))}}]); |