@hprint/core 0.0.1-alpha.2 → 0.0.1-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function _r(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}function yr(f){if(Object.prototype.hasOwnProperty.call(f,"__esModule"))return f;var r=f.default;if(typeof r=="function"){var p=function _(){var y=!1;try{y=this instanceof _}catch{}return y?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};p.prototype=r.prototype}else p={};return Object.defineProperty(p,"__esModule",{value:!0}),Object.keys(f).forEach(function(_){var y=Object.getOwnPropertyDescriptor(f,_);Object.defineProperty(p,_,y.get?y:{enumerable:!0,get:function(){return f[_]}})}),p}var Ee={exports:{}},Ui;function Cr(){if(Ui)return Ee.exports;Ui=1;var f=typeof Reflect=="object"?Reflect:null,r=f&&typeof f.apply=="function"?f.apply:function(v,b,S){return Function.prototype.apply.call(v,b,S)},p;f&&typeof f.ownKeys=="function"?p=f.ownKeys:Object.getOwnPropertySymbols?p=function(v){return Object.getOwnPropertyNames(v).concat(Object.getOwnPropertySymbols(v))}:p=function(v){return Object.getOwnPropertyNames(v)};function _(g){console&&console.warn&&console.warn(g)}var y=Number.isNaN||function(v){return v!==v};function C(){C.init.call(this)}Ee.exports=C,Ee.exports.once=u,C.EventEmitter=C,C.prototype._events=void 0,C.prototype._eventsCount=0,C.prototype._maxListeners=void 0;var T=10;function c(g){if(typeof g!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof g)}Object.defineProperty(C,"defaultMaxListeners",{enumerable:!0,get:function(){return T},set:function(g){if(typeof g!="number"||g<0||y(g))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+g+".");T=g}}),C.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},C.prototype.setMaxListeners=function(v){if(typeof v!="number"||v<0||y(v))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+v+".");return this._maxListeners=v,this};function i(g){return g._maxListeners===void 0?C.defaultMaxListeners:g._maxListeners}C.prototype.getMaxListeners=function(){return i(this)},C.prototype.emit=function(v){for(var b=[],S=1;S<arguments.length;S++)b.push(arguments[S]);var E=v==="error",F=this._events;if(F!==void 0)E=E&&F.error===void 0;else if(!E)return!1;if(E){var R;if(b.length>0&&(R=b[0]),R instanceof Error)throw R;var z=new Error("Unhandled error."+(R?" ("+R.message+")":""));throw z.context=R,z}var q=F[v];if(q===void 0)return!1;if(typeof q=="function")r(q,this,b);else for(var Z=q.length,K=o(q,Z),S=0;S<Z;++S)r(K[S],this,b);return!0};function l(g,v,b,S){var E,F,R;if(c(b),F=g._events,F===void 0?(F=g._events=Object.create(null),g._eventsCount=0):(F.newListener!==void 0&&(g.emit("newListener",v,b.listener?b.listener:b),F=g._events),R=F[v]),R===void 0)R=F[v]=b,++g._eventsCount;else if(typeof R=="function"?R=F[v]=S?[b,R]:[R,b]:S?R.unshift(b):R.push(b),E=i(g),E>0&&R.length>E&&!R.warned){R.warned=!0;var z=new Error("Possible EventEmitter memory leak detected. "+R.length+" "+String(v)+" listeners added. Use emitter.setMaxListeners() to increase limit");z.name="MaxListenersExceededWarning",z.emitter=g,z.type=v,z.count=R.length,_(z)}return g}C.prototype.addListener=function(v,b){return l(this,v,b,!1)},C.prototype.on=C.prototype.addListener,C.prototype.prependListener=function(v,b){return l(this,v,b,!0)};function a(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function t(g,v,b){var S={fired:!1,wrapFn:void 0,target:g,type:v,listener:b},E=a.bind(S);return E.listener=b,S.wrapFn=E,E}C.prototype.once=function(v,b){return c(b),this.on(v,t(this,v,b)),this},C.prototype.prependOnceListener=function(v,b){return c(b),this.prependListener(v,t(this,v,b)),this},C.prototype.removeListener=function(v,b){var S,E,F,R,z;if(c(b),E=this._events,E===void 0)return this;if(S=E[v],S===void 0)return this;if(S===b||S.listener===b)--this._eventsCount===0?this._events=Object.create(null):(delete E[v],E.removeListener&&this.emit("removeListener",v,S.listener||b));else if(typeof S!="function"){for(F=-1,R=S.length-1;R>=0;R--)if(S[R]===b||S[R].listener===b){z=S[R].listener,F=R;break}if(F<0)return this;F===0?S.shift():h(S,F),S.length===1&&(E[v]=S[0]),E.removeListener!==void 0&&this.emit("removeListener",v,z||b)}return this},C.prototype.off=C.prototype.removeListener,C.prototype.removeAllListeners=function(v){var b,S,E;if(S=this._events,S===void 0)return this;if(S.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):S[v]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete S[v]),this;if(arguments.length===0){var F=Object.keys(S),R;for(E=0;E<F.length;++E)R=F[E],R!=="removeListener"&&this.removeAllListeners(R);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(b=S[v],typeof b=="function")this.removeListener(v,b);else if(b!==void 0)for(E=b.length-1;E>=0;E--)this.removeListener(v,b[E]);return this};function n(g,v,b){var S=g._events;if(S===void 0)return[];var E=S[v];return E===void 0?[]:typeof E=="function"?b?[E.listener||E]:[E]:b?s(E):o(E,E.length)}C.prototype.listeners=function(v){return n(this,v,!0)},C.prototype.rawListeners=function(v){return n(this,v,!1)},C.listenerCount=function(g,v){return typeof g.listenerCount=="function"?g.listenerCount(v):e.call(g,v)},C.prototype.listenerCount=e;function e(g){var v=this._events;if(v!==void 0){var b=v[g];if(typeof b=="function")return 1;if(b!==void 0)return b.length}return 0}C.prototype.eventNames=function(){return this._eventsCount>0?p(this._events):[]};function o(g,v){for(var b=new Array(v),S=0;S<v;++S)b[S]=g[S];return b}function h(g,v){for(;v+1<g.length;v++)g[v]=g[v+1];g.pop()}function s(g){for(var v=new Array(g.length),b=0;b<v.length;++b)v[b]=g[b].listener||g[b];return v}function u(g,v){return new Promise(function(b,S){function E(R){g.removeListener(v,F),S(R)}function F(){typeof g.removeListener=="function"&&g.removeListener("error",E),b([].slice.call(arguments))}m(g,v,F,{once:!0}),v!=="error"&&d(g,E,{once:!0})})}function d(g,v,b){typeof g.on=="function"&&m(g,"error",v,b)}function m(g,v,b,S){if(typeof g.on=="function")S.once?g.once(v,b):g.on(v,b);else if(typeof g.addEventListener=="function")g.addEventListener(v,function E(F){S.once&&g.removeEventListener(v,E),b(F)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof g)}return Ee.exports}var br=Cr();const Sr=_r(br);var ze=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function Ge(f,r,p){f.addEventListener?f.addEventListener(r,p,!1):f.attachEvent&&f.attachEvent("on".concat(r),function(){p(window.event)})}function Cn(f,r){for(var p=r.slice(0,r.length-1),_=0;_<p.length;_++)p[_]=f[p[_].toLowerCase()];return p}function bn(f){typeof f!="string"&&(f=""),f=f.replace(/\s/g,"");for(var r=f.split(","),p=r.lastIndexOf("");p>=0;)r[p-1]+=",",r.splice(p,1),p=r.lastIndexOf("");return r}function wr(f,r){for(var p=f.length>=r.length?f:r,_=f.length>=r.length?r:f,y=!0,C=0;C<p.length;C++)_.indexOf(p[C])===-1&&(y=!1);return y}var Sn={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":ze?173:189,"=":ze?61:187,";":ze?59:186,"'":222,"[":219,"]":221,"\\":220},$t={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},zi={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},vt={16:!1,18:!1,17:!1,91:!1},pt={};for(var Pe=1;Pe<20;Pe++)Sn["f".concat(Pe)]=111+Pe;var ft=[],Gi=!1,wn="all",xn=[],Xe=function(r){return Sn[r.toLowerCase()]||$t[r.toLowerCase()]||r.toUpperCase().charCodeAt(0)};function Tn(f){wn=f||"all"}function pe(){return wn||"all"}function xr(){return ft.slice(0)}function Tr(f){var r=f.target||f.srcElement,p=r.tagName,_=!0;return(r.isContentEditable||(p==="INPUT"||p==="TEXTAREA"||p==="SELECT")&&!r.readOnly)&&(_=!1),_}function Or(f){return typeof f=="string"&&(f=Xe(f)),ft.indexOf(f)!==-1}function Er(f,r){var p,_;f||(f=pe());for(var y in pt)if(Object.prototype.hasOwnProperty.call(pt,y))for(p=pt[y],_=0;_<p.length;)p[_].scope===f?p.splice(_,1):_++;pe()===f&&Tn(r||"all")}function Pr(f){var r=f.keyCode||f.which||f.charCode,p=ft.indexOf(r);if(p>=0&&ft.splice(p,1),f.key&&f.key.toLowerCase()==="meta"&&ft.splice(0,ft.length),(r===93||r===224)&&(r=91),r in vt){vt[r]=!1;for(var _ in $t)$t[_]===r&&(It[_]=!1)}}function kr(f){if(!f)Object.keys(pt).forEach(function(T){return delete pt[T]});else if(Array.isArray(f))f.forEach(function(T){T.key&&Ke(T)});else if(typeof f=="object")f.key&&Ke(f);else if(typeof f=="string"){for(var r=arguments.length,p=new Array(r>1?r-1:0),_=1;_<r;_++)p[_-1]=arguments[_];var y=p[0],C=p[1];typeof y=="function"&&(C=y,y=""),Ke({key:f,scope:y,method:C,splitKey:"+"})}}var Ke=function(r){var p=r.key,_=r.scope,y=r.method,C=r.splitKey,T=C===void 0?"+":C,c=bn(p);c.forEach(function(i){var l=i.split(T),a=l.length,t=l[a-1],n=t==="*"?"*":Xe(t);if(pt[n]){_||(_=pe());var e=a>1?Cn($t,l):[];pt[n]=pt[n].filter(function(o){var h=y?o.method===y:!0;return!(h&&o.scope===_&&wr(o.mods,e))})}})};function Ki(f,r,p,_){if(r.element===_){var y;if(r.scope===p||r.scope==="all"){y=r.mods.length>0;for(var C in vt)Object.prototype.hasOwnProperty.call(vt,C)&&(!vt[C]&&r.mods.indexOf(+C)>-1||vt[C]&&r.mods.indexOf(+C)===-1)&&(y=!1);(r.mods.length===0&&!vt[16]&&!vt[18]&&!vt[17]&&!vt[91]||y||r.shortcut==="*")&&r.method(f,r)===!1&&(f.preventDefault?f.preventDefault():f.returnValue=!1,f.stopPropagation&&f.stopPropagation(),f.cancelBubble&&(f.cancelBubble=!0))}}}function qi(f,r){var p=pt["*"],_=f.keyCode||f.which||f.charCode;if(It.filter.call(this,f)){if((_===93||_===224)&&(_=91),ft.indexOf(_)===-1&&_!==229&&ft.push(_),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(o){var h=zi[o];f[o]&&ft.indexOf(h)===-1?ft.push(h):!f[o]&&ft.indexOf(h)>-1?ft.splice(ft.indexOf(h),1):o==="metaKey"&&f[o]&&ft.length===3&&(f.ctrlKey||f.shiftKey||f.altKey||(ft=ft.slice(ft.indexOf(h))))}),_ in vt){vt[_]=!0;for(var y in $t)$t[y]===_&&(It[y]=!0);if(!p)return}for(var C in vt)Object.prototype.hasOwnProperty.call(vt,C)&&(vt[C]=f[zi[C]]);f.getModifierState&&!(f.altKey&&!f.ctrlKey)&&f.getModifierState("AltGraph")&&(ft.indexOf(17)===-1&&ft.push(17),ft.indexOf(18)===-1&&ft.push(18),vt[17]=!0,vt[18]=!0);var T=pe();if(p)for(var c=0;c<p.length;c++)p[c].scope===T&&(f.type==="keydown"&&p[c].keydown||f.type==="keyup"&&p[c].keyup)&&Ki(f,p[c],T,r);if(_ in pt){for(var i=0;i<pt[_].length;i++)if((f.type==="keydown"&&pt[_][i].keydown||f.type==="keyup"&&pt[_][i].keyup)&&pt[_][i].key){for(var l=pt[_][i],a=l.splitKey,t=l.key.split(a),n=[],e=0;e<t.length;e++)n.push(Xe(t[e]));n.sort().join("")===ft.sort().join("")&&Ki(f,l,T,r)}}}}function Ar(f){return xn.indexOf(f)>-1}function It(f,r,p){ft=[];var _=bn(f),y=[],C="all",T=document,c=0,i=!1,l=!0,a="+";for(p===void 0&&typeof r=="function"&&(p=r),Object.prototype.toString.call(r)==="[object Object]"&&(r.scope&&(C=r.scope),r.element&&(T=r.element),r.keyup&&(i=r.keyup),r.keydown!==void 0&&(l=r.keydown),typeof r.splitKey=="string"&&(a=r.splitKey)),typeof r=="string"&&(C=r);c<_.length;c++)f=_[c].split(a),y=[],f.length>1&&(y=Cn($t,f)),f=f[f.length-1],f=f==="*"?"*":Xe(f),f in pt||(pt[f]=[]),pt[f].push({keyup:i,keydown:l,scope:C,mods:y,shortcut:_[c],method:p,key:_[c],splitKey:a,element:T});typeof T<"u"&&!Ar(T)&&window&&(xn.push(T),Ge(T,"keydown",function(t){qi(t,T)}),Gi||(Gi=!0,Ge(window,"focus",function(){ft=[]})),Ge(T,"keyup",function(t){qi(t,T),Pr(t)}))}var qe={setScope:Tn,getScope:pe,deleteScope:Er,getPressedKeyCodes:xr,isPressed:Or,filter:Tr,unbind:kr};for(var $e in qe)Object.prototype.hasOwnProperty.call(qe,$e)&&(It[$e]=qe[$e]);if(typeof window<"u"){var Dr=window.hotkeys;It.noConflict=function(f){return f&&window.hotkeys===It&&(window.hotkeys=Dr),It},window.hotkeys=It}class Ie{constructor(r,p){this.container=r,this.dom=null,this.shown=!1,this.root=!0,this.parent=null,this.submenus=[],this.items=p,this._onclick=_=>{this.dom&&_.target!=this.dom&&_.target.parentElement!=this.dom&&!_.target.classList.contains("item")&&!_.target.parentElement.classList.contains("item")&&this.hideAll()},this._oncontextmenu=_=>{_.preventDefault(),_.target!=this.dom&&_.target.parentElement!=this.dom&&!_.target.classList.contains("item")&&!_.target.parentElement.classList.contains("item")&&(this.hideAll(),this.show(_.clientX,_.clientY))},this._oncontextmenu_keydown=_=>{_.keyCode==93&&(_.preventDefault(),this.hideAll(),this.show(_.clientX,_.clientY))},this._onblur=()=>{this.hideAll()}}getMenuDom(){const r=document.createElement("div");r.classList.add("context");for(const p of this.items)r.appendChild(this.itemToDomEl(p));return r}itemToDomEl(r){const p=document.createElement("div");if(r===null)return p.classList="separator",p;r.hasOwnProperty("color")&&/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r.color.toString())&&(p.style.cssText=`color: ${r.color}`),p.classList.add("item");const _=document.createElement("span");_.classList="label",_.innerText=r.hasOwnProperty("text")?r.text.toString():"",p.appendChild(_),r.hasOwnProperty("disabled")&&r.disabled?p.classList.add("disabled"):p.classList.add("enabled");const y=document.createElement("span");if(y.classList="hotkey",y.innerText=r.hasOwnProperty("hotkey")?r.hotkey.toString():"",p.appendChild(y),r.hasOwnProperty("subitems")&&Array.isArray(r.subitems)&&r.subitems.length>0){const C=new Ie(this.container,r.subitems);C.root=!1,C.parent=this;const T=()=>{if(r.hasOwnProperty("disabled")&&r.disabled==!0)return;this.hideSubMenus();const c=this.dom.offsetLeft+this.dom.clientWidth+p.offsetLeft,i=this.dom.offsetTop+p.offsetTop;C.shown?C.hide():C.show(c,i)};this.submenus.push(C),p.classList.add("has-subitems"),p.addEventListener("click",T),p.addEventListener("mousemove",T)}else if(r.hasOwnProperty("submenu")&&r.submenu instanceof Ie){const C=r.submenu;C.root=!1,C.parent=this;const T=()=>{if(r.hasOwnProperty("disabled")&&r.disabled==!0)return;this.hideSubMenus();const c=this.dom.offsetLeft+this.dom.clientWidth+p.offsetLeft,i=this.dom.offsetTop+p.offsetTop;C.shown?C.hide():C.show(c,i)};this.submenus.push(C),p.classList.add("has-subitems"),p.addEventListener("click",T),p.addEventListener("mousemove",T)}else p.addEventListener("click",()=>{if(this.hideSubMenus(),!p.classList.contains("disabled"))if(r.hasOwnProperty("onclick")&&typeof r.onclick=="function"){const C={handled:!1,item:p,label:_,hotkey:y,items:this.items,data:r};r.onclick(C),C.handled||this.hide()}else this.hide()}),p.addEventListener("mousemove",()=>{this.hideSubMenus()});return p}hideAll(){if(this.root&&!this.parent){this.shown&&(this.hideSubMenus(),this.shown=!1,this.container.removeChild(this.dom),this.parent&&this.parent.shown&&this.parent.hide());return}this.parent.hide()}hide(){this.dom&&this.shown&&(this.shown=!1,this.hideSubMenus(),this.container.removeChild(this.dom),this.parent&&this.parent.shown&&this.parent.hide())}hideSubMenus(){for(const r of this.submenus)r.shown&&(r.shown=!1,r.container.removeChild(r.dom)),r.hideSubMenus()}show(r,p){this.dom=this.getMenuDom(),this.dom.style.left=`${r}px`,this.dom.style.top=`${p}px`,this.shown=!0,this.container.appendChild(this.dom)}install(){this.container.addEventListener("contextmenu",this._oncontextmenu),this.container.addEventListener("keydown",this._oncontextmenu_keydown),this.container.addEventListener("click",this._onclick),window.addEventListener("blur",this._onblur)}setData(r){this.items=r}uninstall(){this.dom=null,this.container.removeEventListener("keydown",this._oncontextmenu_keydown),this.container.removeEventListener("click",this._onclick),window.removeEventListener("blur",this._onblur)}}var ke,Mr=new Uint8Array(16);function Lr(){if(!ke&&(ke=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!ke))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ke(Mr)}const Fr=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Rr(f){return typeof f=="string"&&Fr.test(f)}var mt=[];for(var Je=0;Je<256;++Je)mt.push((Je+256).toString(16).substr(1));function Ir(f){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,p=(mt[f[r+0]]+mt[f[r+1]]+mt[f[r+2]]+mt[f[r+3]]+"-"+mt[f[r+4]]+mt[f[r+5]]+"-"+mt[f[r+6]]+mt[f[r+7]]+"-"+mt[f[r+8]]+mt[f[r+9]]+"-"+mt[f[r+10]]+mt[f[r+11]]+mt[f[r+12]]+mt[f[r+13]]+mt[f[r+14]]+mt[f[r+15]]).toLowerCase();if(!Rr(p))throw TypeError("Stringified UUID is invalid");return p}function On(f,r,p){f=f||{};var _=f.random||(f.rng||Lr)();return _[6]=_[6]&15|64,_[8]=_[8]&63|128,Ir(_)}function jr(f){const r=Object.create(null);for(const p of f.split(","))r[p]=1;return p=>p in r}const me=process.env.NODE_ENV!=="production"?Object.freeze({}):{};process.env.NODE_ENV!=="production"&&Object.freeze([]);const ee=()=>{},Br=f=>f.charCodeAt(0)===111&&f.charCodeAt(1)===110&&(f.charCodeAt(2)>122||f.charCodeAt(2)<97),Vt=Object.assign,Hr=Object.prototype.hasOwnProperty,Si=(f,r)=>Hr.call(f,r),gt=Array.isArray,ie=f=>Ye(f)==="[object Map]",Nr=f=>Ye(f)==="[object Set]",Ct=f=>typeof f=="function",jt=f=>typeof f=="string",xe=f=>typeof f=="symbol",xt=f=>f!==null&&typeof f=="object",Wr=f=>(xt(f)||Ct(f))&&Ct(f.then)&&Ct(f.catch),Xr=Object.prototype.toString,Ye=f=>Xr.call(f),En=f=>Ye(f).slice(8,-1),Yr=f=>Ye(f)==="[object Object]",Di=f=>jt(f)&&f!=="NaN"&&f[0]!=="-"&&""+parseInt(f,10)===f,Pn=f=>{const r=Object.create(null);return(p=>r[p]||(r[p]=f(p)))},kn=Pn(f=>f.charAt(0).toUpperCase()+f.slice(1)),Vr=Pn(f=>f?`on${kn(f)}`:""),Yt=(f,r)=>!Object.is(f,r);let $i;const Ve=()=>$i||($i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Mi(f){if(gt(f)){const r={};for(let p=0;p<f.length;p++){const _=f[p],y=jt(_)?Kr(_):Mi(_);if(y)for(const C in y)r[C]=y[C]}return r}else if(jt(f)||xt(f))return f}const Ur=/;(?![^(]*\))/g,zr=/:([^]+)/,Gr=/\/\*[^]*?\*\//g;function Kr(f){const r={};return f.replace(Gr,"").split(Ur).forEach(p=>{if(p){const _=p.split(zr);_.length>1&&(r[_[0].trim()]=_[1].trim())}}),r}function Li(f){let r="";if(jt(f))r=f;else if(gt(f))for(let p=0;p<f.length;p++){const _=Li(f[p]);_&&(r+=_+" ")}else if(xt(f))for(const p in f)f[p]&&(r+=p+" ");return r.trim()}function At(f,...r){console.warn(`[Vue warn] ${f}`,...r)}let ct;const Qe=new WeakSet;class qr{constructor(r){this.fn=r,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,Qe.has(this)&&(Qe.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||Dn(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,Ji(this),Mn(this);const r=ct,p=Pt;ct=this,Pt=!0;try{return this.fn()}finally{process.env.NODE_ENV!=="production"&&ct!==this&&At("Active effect was not restored correctly - this is likely a Vue internal bug."),Ln(this),ct=r,Pt=p,this.flags&=-3}}stop(){if(this.flags&1){for(let r=this.deps;r;r=r.nextDep)Ii(r);this.deps=this.depsTail=void 0,Ji(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?Qe.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){wi(this)&&this.run()}get dirty(){return wi(this)}}let An=0,fe,de;function Dn(f,r=!1){if(f.flags|=8,r){f.next=de,de=f;return}f.next=fe,fe=f}function Fi(){An++}function Ri(){if(--An>0)return;if(de){let r=de;for(de=void 0;r;){const p=r.next;r.next=void 0,r.flags&=-9,r=p}}let f;for(;fe;){let r=fe;for(fe=void 0;r;){const p=r.next;if(r.next=void 0,r.flags&=-9,r.flags&1)try{r.trigger()}catch(_){f||(f=_)}r=p}}if(f)throw f}function Mn(f){for(let r=f.deps;r;r=r.nextDep)r.version=-1,r.prevActiveLink=r.dep.activeLink,r.dep.activeLink=r}function Ln(f){let r,p=f.depsTail,_=p;for(;_;){const y=_.prevDep;_.version===-1?(_===p&&(p=y),Ii(_),$r(_)):r=_,_.dep.activeLink=_.prevActiveLink,_.prevActiveLink=void 0,_=y}f.deps=r,f.depsTail=p}function wi(f){for(let r=f.deps;r;r=r.nextDep)if(r.dep.version!==r.version||r.dep.computed&&(Fn(r.dep.computed)||r.dep.version!==r.version))return!0;return!!f._dirty}function Fn(f){if(f.flags&4&&!(f.flags&16)||(f.flags&=-17,f.globalVersion===ve)||(f.globalVersion=ve,!f.isSSR&&f.flags&128&&(!f.deps&&!f._dirty||!wi(f))))return;f.flags|=2;const r=f.dep,p=ct,_=Pt;ct=f,Pt=!0;try{Mn(f);const y=f.fn(f._value);(r.version===0||Yt(y,f._value))&&(f.flags|=128,f._value=y,r.version++)}catch(y){throw r.version++,y}finally{ct=p,Pt=_,Ln(f),f.flags&=-3}}function Ii(f,r=!1){const{dep:p,prevSub:_,nextSub:y}=f;if(_&&(_.nextSub=y,f.prevSub=void 0),y&&(y.prevSub=_,f.nextSub=void 0),process.env.NODE_ENV!=="production"&&p.subsHead===f&&(p.subsHead=y),p.subs===f&&(p.subs=_,!_&&p.computed)){p.computed.flags&=-5;for(let C=p.computed.deps;C;C=C.nextDep)Ii(C,!0)}!r&&!--p.sc&&p.map&&p.map.delete(p.key)}function $r(f){const{prevDep:r,nextDep:p}=f;r&&(r.nextDep=p,f.prevDep=void 0),p&&(p.prevDep=r,f.nextDep=void 0)}let Pt=!0;const Rn=[];function se(){Rn.push(Pt),Pt=!1}function oe(){const f=Rn.pop();Pt=f===void 0?!0:f}function Ji(f){const{cleanup:r}=f;if(f.cleanup=void 0,r){const p=ct;ct=void 0;try{r()}finally{ct=p}}}let ve=0;class Jr{constructor(r,p){this.sub=r,this.dep=p,this.version=p.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class ji{constructor(r){this.computed=r,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0,process.env.NODE_ENV!=="production"&&(this.subsHead=void 0)}track(r){if(!ct||!Pt||ct===this.computed)return;let p=this.activeLink;if(p===void 0||p.sub!==ct)p=this.activeLink=new Jr(ct,this),ct.deps?(p.prevDep=ct.depsTail,ct.depsTail.nextDep=p,ct.depsTail=p):ct.deps=ct.depsTail=p,In(p);else if(p.version===-1&&(p.version=this.version,p.nextDep)){const _=p.nextDep;_.prevDep=p.prevDep,p.prevDep&&(p.prevDep.nextDep=_),p.prevDep=ct.depsTail,p.nextDep=void 0,ct.depsTail.nextDep=p,ct.depsTail=p,ct.deps===p&&(ct.deps=_)}return process.env.NODE_ENV!=="production"&&ct.onTrack&&ct.onTrack(Vt({effect:ct},r)),p}trigger(r){this.version++,ve++,this.notify(r)}notify(r){Fi();try{if(process.env.NODE_ENV!=="production")for(let p=this.subsHead;p;p=p.nextSub)p.sub.onTrigger&&!(p.sub.flags&8)&&p.sub.onTrigger(Vt({effect:p.sub},r));for(let p=this.subs;p;p=p.prevSub)p.sub.notify()&&p.sub.dep.notify()}finally{Ri()}}}function In(f){if(f.dep.sc++,f.sub.flags&4){const r=f.dep.computed;if(r&&!f.dep.subs){r.flags|=20;for(let _=r.deps;_;_=_.nextDep)In(_)}const p=f.dep.subs;p!==f&&(f.prevSub=p,p&&(p.nextSub=f)),process.env.NODE_ENV!=="production"&&f.dep.subsHead===void 0&&(f.dep.subsHead=f),f.dep.subs=f}}const xi=new WeakMap,Kt=Symbol(process.env.NODE_ENV!=="production"?"Object iterate":""),Ti=Symbol(process.env.NODE_ENV!=="production"?"Map keys iterate":""),_e=Symbol(process.env.NODE_ENV!=="production"?"Array iterate":"");function wt(f,r,p){if(Pt&&ct){let _=xi.get(f);_||xi.set(f,_=new Map);let y=_.get(p);y||(_.set(p,y=new ji),y.map=_,y.key=p),process.env.NODE_ENV!=="production"?y.track({target:f,type:r,key:p}):y.track()}}function Wt(f,r,p,_,y,C){const T=xi.get(f);if(!T){ve++;return}const c=i=>{i&&(process.env.NODE_ENV!=="production"?i.trigger({target:f,type:r,key:p,newValue:_,oldValue:y,oldTarget:C}):i.trigger())};if(Fi(),r==="clear")T.forEach(c);else{const i=gt(f),l=i&&Di(p);if(i&&p==="length"){const a=Number(_);T.forEach((t,n)=>{(n==="length"||n===_e||!xe(n)&&n>=a)&&c(t)})}else switch((p!==void 0||T.has(void 0))&&c(T.get(p)),l&&c(T.get(_e)),r){case"add":i?l&&c(T.get("length")):(c(T.get(Kt)),ie(f)&&c(T.get(Ti)));break;case"delete":i||(c(T.get(Kt)),ie(f)&&c(T.get(Ti)));break;case"set":ie(f)&&c(T.get(Kt));break}}Ri()}function Jt(f){const r=at(f);return r===f?r:(wt(r,"iterate",_e),Tt(f)?r:r.map(Bt))}function Bi(f){return wt(f=at(f),"iterate",_e),f}function Ht(f,r){return Dt(f)?ne(f)?Ce(Bt(r)):Ce(r):Bt(r)}const Qr={__proto__:null,[Symbol.iterator](){return Ze(this,Symbol.iterator,f=>Ht(this,f))},concat(...f){return Jt(this).concat(...f.map(r=>gt(r)?Jt(r):r))},entries(){return Ze(this,"entries",f=>(f[1]=Ht(this,f[1]),f))},every(f,r){return Ft(this,"every",f,r,void 0,arguments)},filter(f,r){return Ft(this,"filter",f,r,p=>p.map(_=>Ht(this,_)),arguments)},find(f,r){return Ft(this,"find",f,r,p=>Ht(this,p),arguments)},findIndex(f,r){return Ft(this,"findIndex",f,r,void 0,arguments)},findLast(f,r){return Ft(this,"findLast",f,r,p=>Ht(this,p),arguments)},findLastIndex(f,r){return Ft(this,"findLastIndex",f,r,void 0,arguments)},forEach(f,r){return Ft(this,"forEach",f,r,void 0,arguments)},includes(...f){return ti(this,"includes",f)},indexOf(...f){return ti(this,"indexOf",f)},join(f){return Jt(this).join(f)},lastIndexOf(...f){return ti(this,"lastIndexOf",f)},map(f,r){return Ft(this,"map",f,r,void 0,arguments)},pop(){return ce(this,"pop")},push(...f){return ce(this,"push",f)},reduce(f,...r){return Qi(this,"reduce",f,r)},reduceRight(f,...r){return Qi(this,"reduceRight",f,r)},shift(){return ce(this,"shift")},some(f,r){return Ft(this,"some",f,r,void 0,arguments)},splice(...f){return ce(this,"splice",f)},toReversed(){return Jt(this).toReversed()},toSorted(f){return Jt(this).toSorted(f)},toSpliced(...f){return Jt(this).toSpliced(...f)},unshift(...f){return ce(this,"unshift",f)},values(){return Ze(this,"values",f=>Ht(this,f))}};function Ze(f,r,p){const _=Bi(f),y=_[r]();return _!==f&&!Tt(f)&&(y._next=y.next,y.next=()=>{const C=y._next();return C.done||(C.value=p(C.value)),C}),y}const Zr=Array.prototype;function Ft(f,r,p,_,y,C){const T=Bi(f),c=T!==f&&!Tt(f),i=T[r];if(i!==Zr[r]){const t=i.apply(f,C);return c?Bt(t):t}let l=p;T!==f&&(c?l=function(t,n){return p.call(this,Ht(f,t),n,f)}:p.length>2&&(l=function(t,n){return p.call(this,t,n,f)}));const a=i.call(T,l,_);return c&&y?y(a):a}function Qi(f,r,p,_){const y=Bi(f);let C=p;return y!==f&&(Tt(f)?p.length>3&&(C=function(T,c,i){return p.call(this,T,c,i,f)}):C=function(T,c,i){return p.call(this,T,Ht(f,c),i,f)}),y[r](C,..._)}function ti(f,r,p){const _=at(f);wt(_,"iterate",_e);const y=_[r](...p);return(y===-1||y===!1)&&je(p[0])?(p[0]=at(p[0]),_[r](...p)):y}function ce(f,r,p=[]){se(),Fi();const _=at(f)[r].apply(f,p);return Ri(),oe(),_}const ts=jr("__proto__,__v_isRef,__isVue"),jn=new Set(Object.getOwnPropertyNames(Symbol).filter(f=>f!=="arguments"&&f!=="caller").map(f=>Symbol[f]).filter(xe));function es(f){xe(f)||(f=String(f));const r=at(this);return wt(r,"has",f),r.hasOwnProperty(f)}class Bn{constructor(r=!1,p=!1){this._isReadonly=r,this._isShallow=p}get(r,p,_){if(p==="__v_skip")return r.__v_skip;const y=this._isReadonly,C=this._isShallow;if(p==="__v_isReactive")return!y;if(p==="__v_isReadonly")return y;if(p==="__v_isShallow")return C;if(p==="__v_raw")return _===(y?C?us:Wn:C?hs:Nn).get(r)||Object.getPrototypeOf(r)===Object.getPrototypeOf(_)?r:void 0;const T=gt(r);if(!y){let i;if(T&&(i=Qr[p]))return i;if(p==="hasOwnProperty")return es}const c=Reflect.get(r,p,Ot(r)?r:_);if((xe(p)?jn.has(p):ts(p))||(y||wt(r,"get",p),C))return c;if(Ot(c)){const i=T&&Di(p)?c:c.value;return y&&xt(i)?ye(i):i}return xt(c)?y?ye(c):Xn(c):c}}class is extends Bn{constructor(r=!1){super(!1,r)}set(r,p,_,y){let C=r[p];const T=gt(r)&&Di(p);if(!this._isShallow){const l=Dt(C);if(!Tt(_)&&!Dt(_)&&(C=at(C),_=at(_)),!T&&Ot(C)&&!Ot(_))return l?(process.env.NODE_ENV!=="production"&&At(`Set operation on key "${String(p)}" failed: target is readonly.`,r[p]),!0):(C.value=_,!0)}const c=T?Number(p)<r.length:Si(r,p),i=Reflect.set(r,p,_,Ot(r)?r:y);return r===at(y)&&(c?Yt(_,C)&&Wt(r,"set",p,_,C):Wt(r,"add",p,_)),i}deleteProperty(r,p){const _=Si(r,p),y=r[p],C=Reflect.deleteProperty(r,p);return C&&_&&Wt(r,"delete",p,void 0,y),C}has(r,p){const _=Reflect.has(r,p);return(!xe(p)||!jn.has(p))&&wt(r,"has",p),_}ownKeys(r){return wt(r,"iterate",gt(r)?"length":Kt),Reflect.ownKeys(r)}}class ns extends Bn{constructor(r=!1){super(!0,r)}set(r,p){return process.env.NODE_ENV!=="production"&&At(`Set operation on key "${String(p)}" failed: target is readonly.`,r),!0}deleteProperty(r,p){return process.env.NODE_ENV!=="production"&&At(`Delete operation on key "${String(p)}" failed: target is readonly.`,r),!0}}const rs=new is,ss=new ns,Oi=f=>f,Ae=f=>Reflect.getPrototypeOf(f);function os(f,r,p){return function(..._){const y=this.__v_raw,C=at(y),T=ie(C),c=f==="entries"||f===Symbol.iterator&&T,i=f==="keys"&&T,l=y[f](..._),a=p?Oi:r?Ce:Bt;return!r&&wt(C,"iterate",i?Ti:Kt),{next(){const{value:t,done:n}=l.next();return n?{value:t,done:n}:{value:c?[a(t[0]),a(t[1])]:a(t),done:n}},[Symbol.iterator](){return this}}}}function De(f){return function(...r){if(process.env.NODE_ENV!=="production"){const p=r[0]?`on key "${r[0]}" `:"";At(`${kn(f)} operation ${p}failed: target is readonly.`,at(this))}return f==="delete"?!1:f==="clear"?void 0:this}}function as(f,r){const p={get(y){const C=this.__v_raw,T=at(C),c=at(y);f||(Yt(y,c)&&wt(T,"get",y),wt(T,"get",c));const{has:i}=Ae(T),l=r?Oi:f?Ce:Bt;if(i.call(T,y))return l(C.get(y));if(i.call(T,c))return l(C.get(c));C!==T&&C.get(y)},get size(){const y=this.__v_raw;return!f&&wt(at(y),"iterate",Kt),y.size},has(y){const C=this.__v_raw,T=at(C),c=at(y);return f||(Yt(y,c)&&wt(T,"has",y),wt(T,"has",c)),y===c?C.has(y):C.has(y)||C.has(c)},forEach(y,C){const T=this,c=T.__v_raw,i=at(c),l=r?Oi:f?Ce:Bt;return!f&&wt(i,"iterate",Kt),c.forEach((a,t)=>y.call(C,l(a),l(t),T))}};return Vt(p,f?{add:De("add"),set:De("set"),delete:De("delete"),clear:De("clear")}:{add(y){!r&&!Tt(y)&&!Dt(y)&&(y=at(y));const C=at(this);return Ae(C).has.call(C,y)||(C.add(y),Wt(C,"add",y,y)),this},set(y,C){!r&&!Tt(C)&&!Dt(C)&&(C=at(C));const T=at(this),{has:c,get:i}=Ae(T);let l=c.call(T,y);l?process.env.NODE_ENV!=="production"&&Zi(T,c,y):(y=at(y),l=c.call(T,y));const a=i.call(T,y);return T.set(y,C),l?Yt(C,a)&&Wt(T,"set",y,C,a):Wt(T,"add",y,C),this},delete(y){const C=at(this),{has:T,get:c}=Ae(C);let i=T.call(C,y);i?process.env.NODE_ENV!=="production"&&Zi(C,T,y):(y=at(y),i=T.call(C,y));const l=c?c.call(C,y):void 0,a=C.delete(y);return i&&Wt(C,"delete",y,void 0,l),a},clear(){const y=at(this),C=y.size!==0,T=process.env.NODE_ENV!=="production"?ie(y)?new Map(y):new Set(y):void 0,c=y.clear();return C&&Wt(y,"clear",void 0,void 0,T),c}}),["keys","values","entries",Symbol.iterator].forEach(y=>{p[y]=os(y,f,r)}),p}function Hn(f,r){const p=as(f,r);return(_,y,C)=>y==="__v_isReactive"?!f:y==="__v_isReadonly"?f:y==="__v_raw"?_:Reflect.get(Si(p,y)&&y in _?p:_,y,C)}const ls={get:Hn(!1,!1)},cs={get:Hn(!0,!1)};function Zi(f,r,p){const _=at(p);if(_!==p&&r.call(f,_)){const y=En(f);At(`Reactive ${y} contains both the raw and reactive versions of the same object${y==="Map"?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}const Nn=new WeakMap,hs=new WeakMap,Wn=new WeakMap,us=new WeakMap;function fs(f){switch(f){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function ds(f){return f.__v_skip||!Object.isExtensible(f)?0:fs(En(f))}function Xn(f){return Dt(f)?f:Yn(f,!1,rs,ls,Nn)}function ye(f){return Yn(f,!0,ss,cs,Wn)}function Yn(f,r,p,_,y){if(!xt(f))return process.env.NODE_ENV!=="production"&&At(`value cannot be made ${r?"readonly":"reactive"}: ${String(f)}`),f;if(f.__v_raw&&!(r&&f.__v_isReactive))return f;const C=ds(f);if(C===0)return f;const T=y.get(f);if(T)return T;const c=new Proxy(f,C===2?_:p);return y.set(f,c),c}function ne(f){return Dt(f)?ne(f.__v_raw):!!(f&&f.__v_isReactive)}function Dt(f){return!!(f&&f.__v_isReadonly)}function Tt(f){return!!(f&&f.__v_isShallow)}function je(f){return f?!!f.__v_raw:!1}function at(f){const r=f&&f.__v_raw;return r?at(r):f}const Bt=f=>xt(f)?Xn(f):f,Ce=f=>xt(f)?ye(f):f;function Ot(f){return f?f.__v_isRef===!0:!1}function Ut(f){return gs(f,!1)}function gs(f,r){return Ot(f)?f:new ps(f,r)}class ps{constructor(r,p){this.dep=new ji,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=p?r:at(r),this._value=p?r:Bt(r),this.__v_isShallow=p}get value(){return process.env.NODE_ENV!=="production"?this.dep.track({target:this,type:"get",key:"value"}):this.dep.track(),this._value}set value(r){const p=this._rawValue,_=this.__v_isShallow||Tt(r)||Dt(r);r=_?r:at(r),Yt(r,p)&&(this._rawValue=r,this._value=_?r:Bt(r),process.env.NODE_ENV!=="production"?this.dep.trigger({target:this,type:"set",key:"value",newValue:r,oldValue:p}):this.dep.trigger())}}function ms(f){return Ot(f)?f.value:f}class vs{constructor(r,p,_){this.fn=r,this.setter=p,this._value=void 0,this.dep=new ji(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=ve-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!p,this.isSSR=_}notify(){if(this.flags|=16,!(this.flags&8)&&ct!==this)return Dn(this,!0),!0;process.env.NODE_ENV}get value(){const r=process.env.NODE_ENV!=="production"?this.dep.track({target:this,type:"get",key:"value"}):this.dep.track();return Fn(this),r&&(r.version=this.dep.version),this._value}set value(r){this.setter?this.setter(r):process.env.NODE_ENV!=="production"&&At("Write operation failed: computed value is readonly")}}function _s(f,r,p=!1){let _,y;Ct(f)?_=f:(_=f.get,y=f.set);const C=new vs(_,y,p);return process.env.NODE_ENV,C}const Me={},Be=new WeakMap;let Gt;function ys(f,r=!1,p=Gt){if(p){let _=Be.get(p);_||Be.set(p,_=[]),_.push(f)}else process.env.NODE_ENV!=="production"&&!r&&At("onWatcherCleanup() was called when there was no active watcher to associate with.")}function Cs(f,r,p=me){const{immediate:_,deep:y,once:C,scheduler:T,augmentJob:c,call:i}=p,l=g=>{(p.onWarn||At)("Invalid watch source: ",g,"A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.")},a=g=>y?g:Tt(g)||y===!1||y===0?Xt(g,1):Xt(g);let t,n,e,o,h=!1,s=!1;if(Ot(f)?(n=()=>f.value,h=Tt(f)):ne(f)?(n=()=>a(f),h=!0):gt(f)?(s=!0,h=f.some(g=>ne(g)||Tt(g)),n=()=>f.map(g=>{if(Ot(g))return g.value;if(ne(g))return a(g);if(Ct(g))return i?i(g,2):g();process.env.NODE_ENV!=="production"&&l(g)})):Ct(f)?r?n=i?()=>i(f,2):f:n=()=>{if(e){se();try{e()}finally{oe()}}const g=Gt;Gt=t;try{return i?i(f,3,[o]):f(o)}finally{Gt=g}}:(n=ee,process.env.NODE_ENV!=="production"&&l(f)),r&&y){const g=n,v=y===!0?1/0:y;n=()=>Xt(g(),v)}const u=()=>{t.stop()};if(C&&r){const g=r;r=(...v)=>{g(...v),u()}}let d=s?new Array(f.length).fill(Me):Me;const m=g=>{if(!(!(t.flags&1)||!t.dirty&&!g))if(r){const v=t.run();if(y||h||(s?v.some((b,S)=>Yt(b,d[S])):Yt(v,d))){e&&e();const b=Gt;Gt=t;try{const S=[v,d===Me?void 0:s&&d[0]===Me?[]:d,o];d=v,i?i(r,3,S):r(...S)}finally{Gt=b}}}else t.run()};return c&&c(m),t=new qr(n),t.scheduler=T?()=>T(m,!1):m,o=g=>ys(g,!1,t),e=t.onStop=()=>{const g=Be.get(t);if(g){if(i)i(g,4);else for(const v of g)v();Be.delete(t)}},process.env.NODE_ENV!=="production"&&(t.onTrack=p.onTrack,t.onTrigger=p.onTrigger),r?_?m(!0):d=t.run():T?T(m.bind(null,!0),!0):t.run(),u.pause=t.pause.bind(t),u.resume=t.resume.bind(t),u.stop=u,u}function Xt(f,r=1/0,p){if(r<=0||!xt(f)||f.__v_skip||(p=p||new Map,(p.get(f)||0)>=r))return f;if(p.set(f,r),r--,Ot(f))Xt(f.value,r,p);else if(gt(f))for(let _=0;_<f.length;_++)Xt(f[_],r,p);else if(Nr(f)||ie(f))f.forEach(_=>{Xt(_,r,p)});else if(Yr(f)){for(const _ in f)Xt(f[_],r,p);for(const _ of Object.getOwnPropertySymbols(f))Object.prototype.propertyIsEnumerable.call(f,_)&&Xt(f[_],r,p)}return f}const qt=[];function bs(f){qt.push(f)}function Ss(){qt.pop()}let ei=!1;function yt(f,...r){if(ei)return;ei=!0,se();const p=qt.length?qt[qt.length-1].component:null,_=p&&p.appContext.config.warnHandler,y=ws();if(_)Ue(_,p,11,[f+r.map(C=>{var T,c;return(c=(T=C.toString)==null?void 0:T.call(C))!=null?c:JSON.stringify(C)}).join(""),p&&p.proxy,y.map(({vnode:C})=>`at <${sr(p,C.type)}>`).join(`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function _r(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}function yr(f){if(Object.prototype.hasOwnProperty.call(f,"__esModule"))return f;var r=f.default;if(typeof r=="function"){var g=function _(){var y=!1;try{y=this instanceof _}catch{}return y?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};g.prototype=r.prototype}else g={};return Object.defineProperty(g,"__esModule",{value:!0}),Object.keys(f).forEach(function(_){var y=Object.getOwnPropertyDescriptor(f,_);Object.defineProperty(g,_,y.get?y:{enumerable:!0,get:function(){return f[_]}})}),g}var Ee={exports:{}},Ui;function Cr(){if(Ui)return Ee.exports;Ui=1;var f=typeof Reflect=="object"?Reflect:null,r=f&&typeof f.apply=="function"?f.apply:function(v,b,S){return Function.prototype.apply.call(v,b,S)},g;f&&typeof f.ownKeys=="function"?g=f.ownKeys:Object.getOwnPropertySymbols?g=function(v){return Object.getOwnPropertyNames(v).concat(Object.getOwnPropertySymbols(v))}:g=function(v){return Object.getOwnPropertyNames(v)};function _(p){console&&console.warn&&console.warn(p)}var y=Number.isNaN||function(v){return v!==v};function C(){C.init.call(this)}Ee.exports=C,Ee.exports.once=u,C.EventEmitter=C,C.prototype._events=void 0,C.prototype._eventsCount=0,C.prototype._maxListeners=void 0;var T=10;function c(p){if(typeof p!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof p)}Object.defineProperty(C,"defaultMaxListeners",{enumerable:!0,get:function(){return T},set:function(p){if(typeof p!="number"||p<0||y(p))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+p+".");T=p}}),C.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},C.prototype.setMaxListeners=function(v){if(typeof v!="number"||v<0||y(v))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+v+".");return this._maxListeners=v,this};function i(p){return p._maxListeners===void 0?C.defaultMaxListeners:p._maxListeners}C.prototype.getMaxListeners=function(){return i(this)},C.prototype.emit=function(v){for(var b=[],S=1;S<arguments.length;S++)b.push(arguments[S]);var E=v==="error",F=this._events;if(F!==void 0)E=E&&F.error===void 0;else if(!E)return!1;if(E){var R;if(b.length>0&&(R=b[0]),R instanceof Error)throw R;var z=new Error("Unhandled error."+(R?" ("+R.message+")":""));throw z.context=R,z}var K=F[v];if(K===void 0)return!1;if(typeof K=="function")r(K,this,b);else for(var Z=K.length,q=o(K,Z),S=0;S<Z;++S)r(q[S],this,b);return!0};function l(p,v,b,S){var E,F,R;if(c(b),F=p._events,F===void 0?(F=p._events=Object.create(null),p._eventsCount=0):(F.newListener!==void 0&&(p.emit("newListener",v,b.listener?b.listener:b),F=p._events),R=F[v]),R===void 0)R=F[v]=b,++p._eventsCount;else if(typeof R=="function"?R=F[v]=S?[b,R]:[R,b]:S?R.unshift(b):R.push(b),E=i(p),E>0&&R.length>E&&!R.warned){R.warned=!0;var z=new Error("Possible EventEmitter memory leak detected. "+R.length+" "+String(v)+" listeners added. Use emitter.setMaxListeners() to increase limit");z.name="MaxListenersExceededWarning",z.emitter=p,z.type=v,z.count=R.length,_(z)}return p}C.prototype.addListener=function(v,b){return l(this,v,b,!1)},C.prototype.on=C.prototype.addListener,C.prototype.prependListener=function(v,b){return l(this,v,b,!0)};function a(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function t(p,v,b){var S={fired:!1,wrapFn:void 0,target:p,type:v,listener:b},E=a.bind(S);return E.listener=b,S.wrapFn=E,E}C.prototype.once=function(v,b){return c(b),this.on(v,t(this,v,b)),this},C.prototype.prependOnceListener=function(v,b){return c(b),this.prependListener(v,t(this,v,b)),this},C.prototype.removeListener=function(v,b){var S,E,F,R,z;if(c(b),E=this._events,E===void 0)return this;if(S=E[v],S===void 0)return this;if(S===b||S.listener===b)--this._eventsCount===0?this._events=Object.create(null):(delete E[v],E.removeListener&&this.emit("removeListener",v,S.listener||b));else if(typeof S!="function"){for(F=-1,R=S.length-1;R>=0;R--)if(S[R]===b||S[R].listener===b){z=S[R].listener,F=R;break}if(F<0)return this;F===0?S.shift():h(S,F),S.length===1&&(E[v]=S[0]),E.removeListener!==void 0&&this.emit("removeListener",v,z||b)}return this},C.prototype.off=C.prototype.removeListener,C.prototype.removeAllListeners=function(v){var b,S,E;if(S=this._events,S===void 0)return this;if(S.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):S[v]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete S[v]),this;if(arguments.length===0){var F=Object.keys(S),R;for(E=0;E<F.length;++E)R=F[E],R!=="removeListener"&&this.removeAllListeners(R);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(b=S[v],typeof b=="function")this.removeListener(v,b);else if(b!==void 0)for(E=b.length-1;E>=0;E--)this.removeListener(v,b[E]);return this};function n(p,v,b){var S=p._events;if(S===void 0)return[];var E=S[v];return E===void 0?[]:typeof E=="function"?b?[E.listener||E]:[E]:b?s(E):o(E,E.length)}C.prototype.listeners=function(v){return n(this,v,!0)},C.prototype.rawListeners=function(v){return n(this,v,!1)},C.listenerCount=function(p,v){return typeof p.listenerCount=="function"?p.listenerCount(v):e.call(p,v)},C.prototype.listenerCount=e;function e(p){var v=this._events;if(v!==void 0){var b=v[p];if(typeof b=="function")return 1;if(b!==void 0)return b.length}return 0}C.prototype.eventNames=function(){return this._eventsCount>0?g(this._events):[]};function o(p,v){for(var b=new Array(v),S=0;S<v;++S)b[S]=p[S];return b}function h(p,v){for(;v+1<p.length;v++)p[v]=p[v+1];p.pop()}function s(p){for(var v=new Array(p.length),b=0;b<v.length;++b)v[b]=p[b].listener||p[b];return v}function u(p,v){return new Promise(function(b,S){function E(R){p.removeListener(v,F),S(R)}function F(){typeof p.removeListener=="function"&&p.removeListener("error",E),b([].slice.call(arguments))}m(p,v,F,{once:!0}),v!=="error"&&d(p,E,{once:!0})})}function d(p,v,b){typeof p.on=="function"&&m(p,"error",v,b)}function m(p,v,b,S){if(typeof p.on=="function")S.once?p.once(v,b):p.on(v,b);else if(typeof p.addEventListener=="function")p.addEventListener(v,function E(F){S.once&&p.removeEventListener(v,E),b(F)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof p)}return Ee.exports}var br=Cr();const Sr=_r(br);var ze=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function Ge(f,r,g){f.addEventListener?f.addEventListener(r,g,!1):f.attachEvent&&f.attachEvent("on".concat(r),function(){g(window.event)})}function Cn(f,r){for(var g=r.slice(0,r.length-1),_=0;_<g.length;_++)g[_]=f[g[_].toLowerCase()];return g}function bn(f){typeof f!="string"&&(f=""),f=f.replace(/\s/g,"");for(var r=f.split(","),g=r.lastIndexOf("");g>=0;)r[g-1]+=",",r.splice(g,1),g=r.lastIndexOf("");return r}function wr(f,r){for(var g=f.length>=r.length?f:r,_=f.length>=r.length?r:f,y=!0,C=0;C<g.length;C++)_.indexOf(g[C])===-1&&(y=!1);return y}var Sn={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":ze?173:189,"=":ze?61:187,";":ze?59:186,"'":222,"[":219,"]":221,"\\":220},$t={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},zi={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},vt={16:!1,18:!1,17:!1,91:!1},pt={};for(var Pe=1;Pe<20;Pe++)Sn["f".concat(Pe)]=111+Pe;var ft=[],Gi=!1,wn="all",xn=[],Xe=function(r){return Sn[r.toLowerCase()]||$t[r.toLowerCase()]||r.toUpperCase().charCodeAt(0)};function Tn(f){wn=f||"all"}function pe(){return wn||"all"}function xr(){return ft.slice(0)}function Tr(f){var r=f.target||f.srcElement,g=r.tagName,_=!0;return(r.isContentEditable||(g==="INPUT"||g==="TEXTAREA"||g==="SELECT")&&!r.readOnly)&&(_=!1),_}function Or(f){return typeof f=="string"&&(f=Xe(f)),ft.indexOf(f)!==-1}function Er(f,r){var g,_;f||(f=pe());for(var y in pt)if(Object.prototype.hasOwnProperty.call(pt,y))for(g=pt[y],_=0;_<g.length;)g[_].scope===f?g.splice(_,1):_++;pe()===f&&Tn(r||"all")}function Pr(f){var r=f.keyCode||f.which||f.charCode,g=ft.indexOf(r);if(g>=0&&ft.splice(g,1),f.key&&f.key.toLowerCase()==="meta"&&ft.splice(0,ft.length),(r===93||r===224)&&(r=91),r in vt){vt[r]=!1;for(var _ in $t)$t[_]===r&&(It[_]=!1)}}function kr(f){if(!f)Object.keys(pt).forEach(function(T){return delete pt[T]});else if(Array.isArray(f))f.forEach(function(T){T.key&&qe(T)});else if(typeof f=="object")f.key&&qe(f);else if(typeof f=="string"){for(var r=arguments.length,g=new Array(r>1?r-1:0),_=1;_<r;_++)g[_-1]=arguments[_];var y=g[0],C=g[1];typeof y=="function"&&(C=y,y=""),qe({key:f,scope:y,method:C,splitKey:"+"})}}var qe=function(r){var g=r.key,_=r.scope,y=r.method,C=r.splitKey,T=C===void 0?"+":C,c=bn(g);c.forEach(function(i){var l=i.split(T),a=l.length,t=l[a-1],n=t==="*"?"*":Xe(t);if(pt[n]){_||(_=pe());var e=a>1?Cn($t,l):[];pt[n]=pt[n].filter(function(o){var h=y?o.method===y:!0;return!(h&&o.scope===_&&wr(o.mods,e))})}})};function qi(f,r,g,_){if(r.element===_){var y;if(r.scope===g||r.scope==="all"){y=r.mods.length>0;for(var C in vt)Object.prototype.hasOwnProperty.call(vt,C)&&(!vt[C]&&r.mods.indexOf(+C)>-1||vt[C]&&r.mods.indexOf(+C)===-1)&&(y=!1);(r.mods.length===0&&!vt[16]&&!vt[18]&&!vt[17]&&!vt[91]||y||r.shortcut==="*")&&r.method(f,r)===!1&&(f.preventDefault?f.preventDefault():f.returnValue=!1,f.stopPropagation&&f.stopPropagation(),f.cancelBubble&&(f.cancelBubble=!0))}}}function Ki(f,r){var g=pt["*"],_=f.keyCode||f.which||f.charCode;if(It.filter.call(this,f)){if((_===93||_===224)&&(_=91),ft.indexOf(_)===-1&&_!==229&&ft.push(_),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(o){var h=zi[o];f[o]&&ft.indexOf(h)===-1?ft.push(h):!f[o]&&ft.indexOf(h)>-1?ft.splice(ft.indexOf(h),1):o==="metaKey"&&f[o]&&ft.length===3&&(f.ctrlKey||f.shiftKey||f.altKey||(ft=ft.slice(ft.indexOf(h))))}),_ in vt){vt[_]=!0;for(var y in $t)$t[y]===_&&(It[y]=!0);if(!g)return}for(var C in vt)Object.prototype.hasOwnProperty.call(vt,C)&&(vt[C]=f[zi[C]]);f.getModifierState&&!(f.altKey&&!f.ctrlKey)&&f.getModifierState("AltGraph")&&(ft.indexOf(17)===-1&&ft.push(17),ft.indexOf(18)===-1&&ft.push(18),vt[17]=!0,vt[18]=!0);var T=pe();if(g)for(var c=0;c<g.length;c++)g[c].scope===T&&(f.type==="keydown"&&g[c].keydown||f.type==="keyup"&&g[c].keyup)&&qi(f,g[c],T,r);if(_ in pt){for(var i=0;i<pt[_].length;i++)if((f.type==="keydown"&&pt[_][i].keydown||f.type==="keyup"&&pt[_][i].keyup)&&pt[_][i].key){for(var l=pt[_][i],a=l.splitKey,t=l.key.split(a),n=[],e=0;e<t.length;e++)n.push(Xe(t[e]));n.sort().join("")===ft.sort().join("")&&qi(f,l,T,r)}}}}function Ar(f){return xn.indexOf(f)>-1}function It(f,r,g){ft=[];var _=bn(f),y=[],C="all",T=document,c=0,i=!1,l=!0,a="+";for(g===void 0&&typeof r=="function"&&(g=r),Object.prototype.toString.call(r)==="[object Object]"&&(r.scope&&(C=r.scope),r.element&&(T=r.element),r.keyup&&(i=r.keyup),r.keydown!==void 0&&(l=r.keydown),typeof r.splitKey=="string"&&(a=r.splitKey)),typeof r=="string"&&(C=r);c<_.length;c++)f=_[c].split(a),y=[],f.length>1&&(y=Cn($t,f)),f=f[f.length-1],f=f==="*"?"*":Xe(f),f in pt||(pt[f]=[]),pt[f].push({keyup:i,keydown:l,scope:C,mods:y,shortcut:_[c],method:g,key:_[c],splitKey:a,element:T});typeof T<"u"&&!Ar(T)&&window&&(xn.push(T),Ge(T,"keydown",function(t){Ki(t,T)}),Gi||(Gi=!0,Ge(window,"focus",function(){ft=[]})),Ge(T,"keyup",function(t){Ki(t,T),Pr(t)}))}var Ke={setScope:Tn,getScope:pe,deleteScope:Er,getPressedKeyCodes:xr,isPressed:Or,filter:Tr,unbind:kr};for(var $e in Ke)Object.prototype.hasOwnProperty.call(Ke,$e)&&(It[$e]=Ke[$e]);if(typeof window<"u"){var Dr=window.hotkeys;It.noConflict=function(f){return f&&window.hotkeys===It&&(window.hotkeys=Dr),It},window.hotkeys=It}class Ie{constructor(r,g){this.container=r,this.dom=null,this.shown=!1,this.root=!0,this.parent=null,this.submenus=[],this.items=g,this._onclick=_=>{this.dom&&_.target!=this.dom&&_.target.parentElement!=this.dom&&!_.target.classList.contains("item")&&!_.target.parentElement.classList.contains("item")&&this.hideAll()},this._oncontextmenu=_=>{_.preventDefault(),_.target!=this.dom&&_.target.parentElement!=this.dom&&!_.target.classList.contains("item")&&!_.target.parentElement.classList.contains("item")&&(this.hideAll(),this.show(_.clientX,_.clientY))},this._oncontextmenu_keydown=_=>{_.keyCode==93&&(_.preventDefault(),this.hideAll(),this.show(_.clientX,_.clientY))},this._onblur=()=>{this.hideAll()}}getMenuDom(){const r=document.createElement("div");r.classList.add("context");for(const g of this.items)r.appendChild(this.itemToDomEl(g));return r}itemToDomEl(r){const g=document.createElement("div");if(r===null)return g.classList="separator",g;r.hasOwnProperty("color")&&/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r.color.toString())&&(g.style.cssText=`color: ${r.color}`),g.classList.add("item");const _=document.createElement("span");_.classList="label",_.innerText=r.hasOwnProperty("text")?r.text.toString():"",g.appendChild(_),r.hasOwnProperty("disabled")&&r.disabled?g.classList.add("disabled"):g.classList.add("enabled");const y=document.createElement("span");if(y.classList="hotkey",y.innerText=r.hasOwnProperty("hotkey")?r.hotkey.toString():"",g.appendChild(y),r.hasOwnProperty("subitems")&&Array.isArray(r.subitems)&&r.subitems.length>0){const C=new Ie(this.container,r.subitems);C.root=!1,C.parent=this;const T=()=>{if(r.hasOwnProperty("disabled")&&r.disabled==!0)return;this.hideSubMenus();const c=this.dom.offsetLeft+this.dom.clientWidth+g.offsetLeft,i=this.dom.offsetTop+g.offsetTop;C.shown?C.hide():C.show(c,i)};this.submenus.push(C),g.classList.add("has-subitems"),g.addEventListener("click",T),g.addEventListener("mousemove",T)}else if(r.hasOwnProperty("submenu")&&r.submenu instanceof Ie){const C=r.submenu;C.root=!1,C.parent=this;const T=()=>{if(r.hasOwnProperty("disabled")&&r.disabled==!0)return;this.hideSubMenus();const c=this.dom.offsetLeft+this.dom.clientWidth+g.offsetLeft,i=this.dom.offsetTop+g.offsetTop;C.shown?C.hide():C.show(c,i)};this.submenus.push(C),g.classList.add("has-subitems"),g.addEventListener("click",T),g.addEventListener("mousemove",T)}else g.addEventListener("click",()=>{if(this.hideSubMenus(),!g.classList.contains("disabled"))if(r.hasOwnProperty("onclick")&&typeof r.onclick=="function"){const C={handled:!1,item:g,label:_,hotkey:y,items:this.items,data:r};r.onclick(C),C.handled||this.hide()}else this.hide()}),g.addEventListener("mousemove",()=>{this.hideSubMenus()});return g}hideAll(){if(this.root&&!this.parent){this.shown&&(this.hideSubMenus(),this.shown=!1,this.container.removeChild(this.dom),this.parent&&this.parent.shown&&this.parent.hide());return}this.parent.hide()}hide(){this.dom&&this.shown&&(this.shown=!1,this.hideSubMenus(),this.container.removeChild(this.dom),this.parent&&this.parent.shown&&this.parent.hide())}hideSubMenus(){for(const r of this.submenus)r.shown&&(r.shown=!1,r.container.removeChild(r.dom)),r.hideSubMenus()}show(r,g){this.dom=this.getMenuDom(),this.dom.style.left=`${r}px`,this.dom.style.top=`${g}px`,this.shown=!0,this.container.appendChild(this.dom)}install(){this.container.addEventListener("contextmenu",this._oncontextmenu),this.container.addEventListener("keydown",this._oncontextmenu_keydown),this.container.addEventListener("click",this._onclick),window.addEventListener("blur",this._onblur)}setData(r){this.items=r}uninstall(){this.dom=null,this.container.removeEventListener("keydown",this._oncontextmenu_keydown),this.container.removeEventListener("click",this._onclick),window.removeEventListener("blur",this._onblur)}}var ke,Mr=new Uint8Array(16);function Lr(){if(!ke&&(ke=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!ke))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ke(Mr)}const Fr=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Rr(f){return typeof f=="string"&&Fr.test(f)}var mt=[];for(var Je=0;Je<256;++Je)mt.push((Je+256).toString(16).substr(1));function Ir(f){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,g=(mt[f[r+0]]+mt[f[r+1]]+mt[f[r+2]]+mt[f[r+3]]+"-"+mt[f[r+4]]+mt[f[r+5]]+"-"+mt[f[r+6]]+mt[f[r+7]]+"-"+mt[f[r+8]]+mt[f[r+9]]+"-"+mt[f[r+10]]+mt[f[r+11]]+mt[f[r+12]]+mt[f[r+13]]+mt[f[r+14]]+mt[f[r+15]]).toLowerCase();if(!Rr(g))throw TypeError("Stringified UUID is invalid");return g}function On(f,r,g){f=f||{};var _=f.random||(f.rng||Lr)();return _[6]=_[6]&15|64,_[8]=_[8]&63|128,Ir(_)}function jr(f){const r=Object.create(null);for(const g of f.split(","))r[g]=1;return g=>g in r}const me=process.env.NODE_ENV!=="production"?Object.freeze({}):{};process.env.NODE_ENV!=="production"&&Object.freeze([]);const ee=()=>{},Br=f=>f.charCodeAt(0)===111&&f.charCodeAt(1)===110&&(f.charCodeAt(2)>122||f.charCodeAt(2)<97),Vt=Object.assign,Hr=Object.prototype.hasOwnProperty,Si=(f,r)=>Hr.call(f,r),gt=Array.isArray,ie=f=>Ye(f)==="[object Map]",Nr=f=>Ye(f)==="[object Set]",Ct=f=>typeof f=="function",jt=f=>typeof f=="string",xe=f=>typeof f=="symbol",xt=f=>f!==null&&typeof f=="object",Wr=f=>(xt(f)||Ct(f))&&Ct(f.then)&&Ct(f.catch),Xr=Object.prototype.toString,Ye=f=>Xr.call(f),En=f=>Ye(f).slice(8,-1),Yr=f=>Ye(f)==="[object Object]",Di=f=>jt(f)&&f!=="NaN"&&f[0]!=="-"&&""+parseInt(f,10)===f,Pn=f=>{const r=Object.create(null);return(g=>r[g]||(r[g]=f(g)))},kn=Pn(f=>f.charAt(0).toUpperCase()+f.slice(1)),Vr=Pn(f=>f?`on${kn(f)}`:""),Yt=(f,r)=>!Object.is(f,r);let $i;const Ve=()=>$i||($i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Mi(f){if(gt(f)){const r={};for(let g=0;g<f.length;g++){const _=f[g],y=jt(_)?qr(_):Mi(_);if(y)for(const C in y)r[C]=y[C]}return r}else if(jt(f)||xt(f))return f}const Ur=/;(?![^(]*\))/g,zr=/:([^]+)/,Gr=/\/\*[^]*?\*\//g;function qr(f){const r={};return f.replace(Gr,"").split(Ur).forEach(g=>{if(g){const _=g.split(zr);_.length>1&&(r[_[0].trim()]=_[1].trim())}}),r}function Li(f){let r="";if(jt(f))r=f;else if(gt(f))for(let g=0;g<f.length;g++){const _=Li(f[g]);_&&(r+=_+" ")}else if(xt(f))for(const g in f)f[g]&&(r+=g+" ");return r.trim()}function At(f,...r){console.warn(`[Vue warn] ${f}`,...r)}let ct;const Qe=new WeakSet;class Kr{constructor(r){this.fn=r,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,Qe.has(this)&&(Qe.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||Dn(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,Ji(this),Mn(this);const r=ct,g=Pt;ct=this,Pt=!0;try{return this.fn()}finally{process.env.NODE_ENV!=="production"&&ct!==this&&At("Active effect was not restored correctly - this is likely a Vue internal bug."),Ln(this),ct=r,Pt=g,this.flags&=-3}}stop(){if(this.flags&1){for(let r=this.deps;r;r=r.nextDep)Ii(r);this.deps=this.depsTail=void 0,Ji(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?Qe.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){wi(this)&&this.run()}get dirty(){return wi(this)}}let An=0,fe,de;function Dn(f,r=!1){if(f.flags|=8,r){f.next=de,de=f;return}f.next=fe,fe=f}function Fi(){An++}function Ri(){if(--An>0)return;if(de){let r=de;for(de=void 0;r;){const g=r.next;r.next=void 0,r.flags&=-9,r=g}}let f;for(;fe;){let r=fe;for(fe=void 0;r;){const g=r.next;if(r.next=void 0,r.flags&=-9,r.flags&1)try{r.trigger()}catch(_){f||(f=_)}r=g}}if(f)throw f}function Mn(f){for(let r=f.deps;r;r=r.nextDep)r.version=-1,r.prevActiveLink=r.dep.activeLink,r.dep.activeLink=r}function Ln(f){let r,g=f.depsTail,_=g;for(;_;){const y=_.prevDep;_.version===-1?(_===g&&(g=y),Ii(_),$r(_)):r=_,_.dep.activeLink=_.prevActiveLink,_.prevActiveLink=void 0,_=y}f.deps=r,f.depsTail=g}function wi(f){for(let r=f.deps;r;r=r.nextDep)if(r.dep.version!==r.version||r.dep.computed&&(Fn(r.dep.computed)||r.dep.version!==r.version))return!0;return!!f._dirty}function Fn(f){if(f.flags&4&&!(f.flags&16)||(f.flags&=-17,f.globalVersion===ve)||(f.globalVersion=ve,!f.isSSR&&f.flags&128&&(!f.deps&&!f._dirty||!wi(f))))return;f.flags|=2;const r=f.dep,g=ct,_=Pt;ct=f,Pt=!0;try{Mn(f);const y=f.fn(f._value);(r.version===0||Yt(y,f._value))&&(f.flags|=128,f._value=y,r.version++)}catch(y){throw r.version++,y}finally{ct=g,Pt=_,Ln(f),f.flags&=-3}}function Ii(f,r=!1){const{dep:g,prevSub:_,nextSub:y}=f;if(_&&(_.nextSub=y,f.prevSub=void 0),y&&(y.prevSub=_,f.nextSub=void 0),process.env.NODE_ENV!=="production"&&g.subsHead===f&&(g.subsHead=y),g.subs===f&&(g.subs=_,!_&&g.computed)){g.computed.flags&=-5;for(let C=g.computed.deps;C;C=C.nextDep)Ii(C,!0)}!r&&!--g.sc&&g.map&&g.map.delete(g.key)}function $r(f){const{prevDep:r,nextDep:g}=f;r&&(r.nextDep=g,f.prevDep=void 0),g&&(g.prevDep=r,f.nextDep=void 0)}let Pt=!0;const Rn=[];function se(){Rn.push(Pt),Pt=!1}function oe(){const f=Rn.pop();Pt=f===void 0?!0:f}function Ji(f){const{cleanup:r}=f;if(f.cleanup=void 0,r){const g=ct;ct=void 0;try{r()}finally{ct=g}}}let ve=0;class Jr{constructor(r,g){this.sub=r,this.dep=g,this.version=g.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class ji{constructor(r){this.computed=r,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0,process.env.NODE_ENV!=="production"&&(this.subsHead=void 0)}track(r){if(!ct||!Pt||ct===this.computed)return;let g=this.activeLink;if(g===void 0||g.sub!==ct)g=this.activeLink=new Jr(ct,this),ct.deps?(g.prevDep=ct.depsTail,ct.depsTail.nextDep=g,ct.depsTail=g):ct.deps=ct.depsTail=g,In(g);else if(g.version===-1&&(g.version=this.version,g.nextDep)){const _=g.nextDep;_.prevDep=g.prevDep,g.prevDep&&(g.prevDep.nextDep=_),g.prevDep=ct.depsTail,g.nextDep=void 0,ct.depsTail.nextDep=g,ct.depsTail=g,ct.deps===g&&(ct.deps=_)}return process.env.NODE_ENV!=="production"&&ct.onTrack&&ct.onTrack(Vt({effect:ct},r)),g}trigger(r){this.version++,ve++,this.notify(r)}notify(r){Fi();try{if(process.env.NODE_ENV!=="production")for(let g=this.subsHead;g;g=g.nextSub)g.sub.onTrigger&&!(g.sub.flags&8)&&g.sub.onTrigger(Vt({effect:g.sub},r));for(let g=this.subs;g;g=g.prevSub)g.sub.notify()&&g.sub.dep.notify()}finally{Ri()}}}function In(f){if(f.dep.sc++,f.sub.flags&4){const r=f.dep.computed;if(r&&!f.dep.subs){r.flags|=20;for(let _=r.deps;_;_=_.nextDep)In(_)}const g=f.dep.subs;g!==f&&(f.prevSub=g,g&&(g.nextSub=f)),process.env.NODE_ENV!=="production"&&f.dep.subsHead===void 0&&(f.dep.subsHead=f),f.dep.subs=f}}const xi=new WeakMap,qt=Symbol(process.env.NODE_ENV!=="production"?"Object iterate":""),Ti=Symbol(process.env.NODE_ENV!=="production"?"Map keys iterate":""),_e=Symbol(process.env.NODE_ENV!=="production"?"Array iterate":"");function wt(f,r,g){if(Pt&&ct){let _=xi.get(f);_||xi.set(f,_=new Map);let y=_.get(g);y||(_.set(g,y=new ji),y.map=_,y.key=g),process.env.NODE_ENV!=="production"?y.track({target:f,type:r,key:g}):y.track()}}function Wt(f,r,g,_,y,C){const T=xi.get(f);if(!T){ve++;return}const c=i=>{i&&(process.env.NODE_ENV!=="production"?i.trigger({target:f,type:r,key:g,newValue:_,oldValue:y,oldTarget:C}):i.trigger())};if(Fi(),r==="clear")T.forEach(c);else{const i=gt(f),l=i&&Di(g);if(i&&g==="length"){const a=Number(_);T.forEach((t,n)=>{(n==="length"||n===_e||!xe(n)&&n>=a)&&c(t)})}else switch((g!==void 0||T.has(void 0))&&c(T.get(g)),l&&c(T.get(_e)),r){case"add":i?l&&c(T.get("length")):(c(T.get(qt)),ie(f)&&c(T.get(Ti)));break;case"delete":i||(c(T.get(qt)),ie(f)&&c(T.get(Ti)));break;case"set":ie(f)&&c(T.get(qt));break}}Ri()}function Jt(f){const r=at(f);return r===f?r:(wt(r,"iterate",_e),Tt(f)?r:r.map(Bt))}function Bi(f){return wt(f=at(f),"iterate",_e),f}function Ht(f,r){return Dt(f)?ne(f)?Ce(Bt(r)):Ce(r):Bt(r)}const Qr={__proto__:null,[Symbol.iterator](){return Ze(this,Symbol.iterator,f=>Ht(this,f))},concat(...f){return Jt(this).concat(...f.map(r=>gt(r)?Jt(r):r))},entries(){return Ze(this,"entries",f=>(f[1]=Ht(this,f[1]),f))},every(f,r){return Ft(this,"every",f,r,void 0,arguments)},filter(f,r){return Ft(this,"filter",f,r,g=>g.map(_=>Ht(this,_)),arguments)},find(f,r){return Ft(this,"find",f,r,g=>Ht(this,g),arguments)},findIndex(f,r){return Ft(this,"findIndex",f,r,void 0,arguments)},findLast(f,r){return Ft(this,"findLast",f,r,g=>Ht(this,g),arguments)},findLastIndex(f,r){return Ft(this,"findLastIndex",f,r,void 0,arguments)},forEach(f,r){return Ft(this,"forEach",f,r,void 0,arguments)},includes(...f){return ti(this,"includes",f)},indexOf(...f){return ti(this,"indexOf",f)},join(f){return Jt(this).join(f)},lastIndexOf(...f){return ti(this,"lastIndexOf",f)},map(f,r){return Ft(this,"map",f,r,void 0,arguments)},pop(){return ce(this,"pop")},push(...f){return ce(this,"push",f)},reduce(f,...r){return Qi(this,"reduce",f,r)},reduceRight(f,...r){return Qi(this,"reduceRight",f,r)},shift(){return ce(this,"shift")},some(f,r){return Ft(this,"some",f,r,void 0,arguments)},splice(...f){return ce(this,"splice",f)},toReversed(){return Jt(this).toReversed()},toSorted(f){return Jt(this).toSorted(f)},toSpliced(...f){return Jt(this).toSpliced(...f)},unshift(...f){return ce(this,"unshift",f)},values(){return Ze(this,"values",f=>Ht(this,f))}};function Ze(f,r,g){const _=Bi(f),y=_[r]();return _!==f&&!Tt(f)&&(y._next=y.next,y.next=()=>{const C=y._next();return C.done||(C.value=g(C.value)),C}),y}const Zr=Array.prototype;function Ft(f,r,g,_,y,C){const T=Bi(f),c=T!==f&&!Tt(f),i=T[r];if(i!==Zr[r]){const t=i.apply(f,C);return c?Bt(t):t}let l=g;T!==f&&(c?l=function(t,n){return g.call(this,Ht(f,t),n,f)}:g.length>2&&(l=function(t,n){return g.call(this,t,n,f)}));const a=i.call(T,l,_);return c&&y?y(a):a}function Qi(f,r,g,_){const y=Bi(f);let C=g;return y!==f&&(Tt(f)?g.length>3&&(C=function(T,c,i){return g.call(this,T,c,i,f)}):C=function(T,c,i){return g.call(this,T,Ht(f,c),i,f)}),y[r](C,..._)}function ti(f,r,g){const _=at(f);wt(_,"iterate",_e);const y=_[r](...g);return(y===-1||y===!1)&&je(g[0])?(g[0]=at(g[0]),_[r](...g)):y}function ce(f,r,g=[]){se(),Fi();const _=at(f)[r].apply(f,g);return Ri(),oe(),_}const ts=jr("__proto__,__v_isRef,__isVue"),jn=new Set(Object.getOwnPropertyNames(Symbol).filter(f=>f!=="arguments"&&f!=="caller").map(f=>Symbol[f]).filter(xe));function es(f){xe(f)||(f=String(f));const r=at(this);return wt(r,"has",f),r.hasOwnProperty(f)}class Bn{constructor(r=!1,g=!1){this._isReadonly=r,this._isShallow=g}get(r,g,_){if(g==="__v_skip")return r.__v_skip;const y=this._isReadonly,C=this._isShallow;if(g==="__v_isReactive")return!y;if(g==="__v_isReadonly")return y;if(g==="__v_isShallow")return C;if(g==="__v_raw")return _===(y?C?us:Wn:C?hs:Nn).get(r)||Object.getPrototypeOf(r)===Object.getPrototypeOf(_)?r:void 0;const T=gt(r);if(!y){let i;if(T&&(i=Qr[g]))return i;if(g==="hasOwnProperty")return es}const c=Reflect.get(r,g,Ot(r)?r:_);if((xe(g)?jn.has(g):ts(g))||(y||wt(r,"get",g),C))return c;if(Ot(c)){const i=T&&Di(g)?c:c.value;return y&&xt(i)?ye(i):i}return xt(c)?y?ye(c):Xn(c):c}}class is extends Bn{constructor(r=!1){super(!1,r)}set(r,g,_,y){let C=r[g];const T=gt(r)&&Di(g);if(!this._isShallow){const l=Dt(C);if(!Tt(_)&&!Dt(_)&&(C=at(C),_=at(_)),!T&&Ot(C)&&!Ot(_))return l?(process.env.NODE_ENV!=="production"&&At(`Set operation on key "${String(g)}" failed: target is readonly.`,r[g]),!0):(C.value=_,!0)}const c=T?Number(g)<r.length:Si(r,g),i=Reflect.set(r,g,_,Ot(r)?r:y);return r===at(y)&&(c?Yt(_,C)&&Wt(r,"set",g,_,C):Wt(r,"add",g,_)),i}deleteProperty(r,g){const _=Si(r,g),y=r[g],C=Reflect.deleteProperty(r,g);return C&&_&&Wt(r,"delete",g,void 0,y),C}has(r,g){const _=Reflect.has(r,g);return(!xe(g)||!jn.has(g))&&wt(r,"has",g),_}ownKeys(r){return wt(r,"iterate",gt(r)?"length":qt),Reflect.ownKeys(r)}}class ns extends Bn{constructor(r=!1){super(!0,r)}set(r,g){return process.env.NODE_ENV!=="production"&&At(`Set operation on key "${String(g)}" failed: target is readonly.`,r),!0}deleteProperty(r,g){return process.env.NODE_ENV!=="production"&&At(`Delete operation on key "${String(g)}" failed: target is readonly.`,r),!0}}const rs=new is,ss=new ns,Oi=f=>f,Ae=f=>Reflect.getPrototypeOf(f);function os(f,r,g){return function(..._){const y=this.__v_raw,C=at(y),T=ie(C),c=f==="entries"||f===Symbol.iterator&&T,i=f==="keys"&&T,l=y[f](..._),a=g?Oi:r?Ce:Bt;return!r&&wt(C,"iterate",i?Ti:qt),{next(){const{value:t,done:n}=l.next();return n?{value:t,done:n}:{value:c?[a(t[0]),a(t[1])]:a(t),done:n}},[Symbol.iterator](){return this}}}}function De(f){return function(...r){if(process.env.NODE_ENV!=="production"){const g=r[0]?`on key "${r[0]}" `:"";At(`${kn(f)} operation ${g}failed: target is readonly.`,at(this))}return f==="delete"?!1:f==="clear"?void 0:this}}function as(f,r){const g={get(y){const C=this.__v_raw,T=at(C),c=at(y);f||(Yt(y,c)&&wt(T,"get",y),wt(T,"get",c));const{has:i}=Ae(T),l=r?Oi:f?Ce:Bt;if(i.call(T,y))return l(C.get(y));if(i.call(T,c))return l(C.get(c));C!==T&&C.get(y)},get size(){const y=this.__v_raw;return!f&&wt(at(y),"iterate",qt),y.size},has(y){const C=this.__v_raw,T=at(C),c=at(y);return f||(Yt(y,c)&&wt(T,"has",y),wt(T,"has",c)),y===c?C.has(y):C.has(y)||C.has(c)},forEach(y,C){const T=this,c=T.__v_raw,i=at(c),l=r?Oi:f?Ce:Bt;return!f&&wt(i,"iterate",qt),c.forEach((a,t)=>y.call(C,l(a),l(t),T))}};return Vt(g,f?{add:De("add"),set:De("set"),delete:De("delete"),clear:De("clear")}:{add(y){!r&&!Tt(y)&&!Dt(y)&&(y=at(y));const C=at(this);return Ae(C).has.call(C,y)||(C.add(y),Wt(C,"add",y,y)),this},set(y,C){!r&&!Tt(C)&&!Dt(C)&&(C=at(C));const T=at(this),{has:c,get:i}=Ae(T);let l=c.call(T,y);l?process.env.NODE_ENV!=="production"&&Zi(T,c,y):(y=at(y),l=c.call(T,y));const a=i.call(T,y);return T.set(y,C),l?Yt(C,a)&&Wt(T,"set",y,C,a):Wt(T,"add",y,C),this},delete(y){const C=at(this),{has:T,get:c}=Ae(C);let i=T.call(C,y);i?process.env.NODE_ENV!=="production"&&Zi(C,T,y):(y=at(y),i=T.call(C,y));const l=c?c.call(C,y):void 0,a=C.delete(y);return i&&Wt(C,"delete",y,void 0,l),a},clear(){const y=at(this),C=y.size!==0,T=process.env.NODE_ENV!=="production"?ie(y)?new Map(y):new Set(y):void 0,c=y.clear();return C&&Wt(y,"clear",void 0,void 0,T),c}}),["keys","values","entries",Symbol.iterator].forEach(y=>{g[y]=os(y,f,r)}),g}function Hn(f,r){const g=as(f,r);return(_,y,C)=>y==="__v_isReactive"?!f:y==="__v_isReadonly"?f:y==="__v_raw"?_:Reflect.get(Si(g,y)&&y in _?g:_,y,C)}const ls={get:Hn(!1,!1)},cs={get:Hn(!0,!1)};function Zi(f,r,g){const _=at(g);if(_!==g&&r.call(f,_)){const y=En(f);At(`Reactive ${y} contains both the raw and reactive versions of the same object${y==="Map"?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}const Nn=new WeakMap,hs=new WeakMap,Wn=new WeakMap,us=new WeakMap;function fs(f){switch(f){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function ds(f){return f.__v_skip||!Object.isExtensible(f)?0:fs(En(f))}function Xn(f){return Dt(f)?f:Yn(f,!1,rs,ls,Nn)}function ye(f){return Yn(f,!0,ss,cs,Wn)}function Yn(f,r,g,_,y){if(!xt(f))return process.env.NODE_ENV!=="production"&&At(`value cannot be made ${r?"readonly":"reactive"}: ${String(f)}`),f;if(f.__v_raw&&!(r&&f.__v_isReactive))return f;const C=ds(f);if(C===0)return f;const T=y.get(f);if(T)return T;const c=new Proxy(f,C===2?_:g);return y.set(f,c),c}function ne(f){return Dt(f)?ne(f.__v_raw):!!(f&&f.__v_isReactive)}function Dt(f){return!!(f&&f.__v_isReadonly)}function Tt(f){return!!(f&&f.__v_isShallow)}function je(f){return f?!!f.__v_raw:!1}function at(f){const r=f&&f.__v_raw;return r?at(r):f}const Bt=f=>xt(f)?Xn(f):f,Ce=f=>xt(f)?ye(f):f;function Ot(f){return f?f.__v_isRef===!0:!1}function Ut(f){return gs(f,!1)}function gs(f,r){return Ot(f)?f:new ps(f,r)}class ps{constructor(r,g){this.dep=new ji,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=g?r:at(r),this._value=g?r:Bt(r),this.__v_isShallow=g}get value(){return process.env.NODE_ENV!=="production"?this.dep.track({target:this,type:"get",key:"value"}):this.dep.track(),this._value}set value(r){const g=this._rawValue,_=this.__v_isShallow||Tt(r)||Dt(r);r=_?r:at(r),Yt(r,g)&&(this._rawValue=r,this._value=_?r:Bt(r),process.env.NODE_ENV!=="production"?this.dep.trigger({target:this,type:"set",key:"value",newValue:r,oldValue:g}):this.dep.trigger())}}function ms(f){return Ot(f)?f.value:f}class vs{constructor(r,g,_){this.fn=r,this.setter=g,this._value=void 0,this.dep=new ji(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=ve-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!g,this.isSSR=_}notify(){if(this.flags|=16,!(this.flags&8)&&ct!==this)return Dn(this,!0),!0;process.env.NODE_ENV}get value(){const r=process.env.NODE_ENV!=="production"?this.dep.track({target:this,type:"get",key:"value"}):this.dep.track();return Fn(this),r&&(r.version=this.dep.version),this._value}set value(r){this.setter?this.setter(r):process.env.NODE_ENV!=="production"&&At("Write operation failed: computed value is readonly")}}function _s(f,r,g=!1){let _,y;Ct(f)?_=f:(_=f.get,y=f.set);const C=new vs(_,y,g);return process.env.NODE_ENV,C}const Me={},Be=new WeakMap;let Gt;function ys(f,r=!1,g=Gt){if(g){let _=Be.get(g);_||Be.set(g,_=[]),_.push(f)}else process.env.NODE_ENV!=="production"&&!r&&At("onWatcherCleanup() was called when there was no active watcher to associate with.")}function Cs(f,r,g=me){const{immediate:_,deep:y,once:C,scheduler:T,augmentJob:c,call:i}=g,l=p=>{(g.onWarn||At)("Invalid watch source: ",p,"A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.")},a=p=>y?p:Tt(p)||y===!1||y===0?Xt(p,1):Xt(p);let t,n,e,o,h=!1,s=!1;if(Ot(f)?(n=()=>f.value,h=Tt(f)):ne(f)?(n=()=>a(f),h=!0):gt(f)?(s=!0,h=f.some(p=>ne(p)||Tt(p)),n=()=>f.map(p=>{if(Ot(p))return p.value;if(ne(p))return a(p);if(Ct(p))return i?i(p,2):p();process.env.NODE_ENV!=="production"&&l(p)})):Ct(f)?r?n=i?()=>i(f,2):f:n=()=>{if(e){se();try{e()}finally{oe()}}const p=Gt;Gt=t;try{return i?i(f,3,[o]):f(o)}finally{Gt=p}}:(n=ee,process.env.NODE_ENV!=="production"&&l(f)),r&&y){const p=n,v=y===!0?1/0:y;n=()=>Xt(p(),v)}const u=()=>{t.stop()};if(C&&r){const p=r;r=(...v)=>{p(...v),u()}}let d=s?new Array(f.length).fill(Me):Me;const m=p=>{if(!(!(t.flags&1)||!t.dirty&&!p))if(r){const v=t.run();if(y||h||(s?v.some((b,S)=>Yt(b,d[S])):Yt(v,d))){e&&e();const b=Gt;Gt=t;try{const S=[v,d===Me?void 0:s&&d[0]===Me?[]:d,o];d=v,i?i(r,3,S):r(...S)}finally{Gt=b}}}else t.run()};return c&&c(m),t=new Kr(n),t.scheduler=T?()=>T(m,!1):m,o=p=>ys(p,!1,t),e=t.onStop=()=>{const p=Be.get(t);if(p){if(i)i(p,4);else for(const v of p)v();Be.delete(t)}},process.env.NODE_ENV!=="production"&&(t.onTrack=g.onTrack,t.onTrigger=g.onTrigger),r?_?m(!0):d=t.run():T?T(m.bind(null,!0),!0):t.run(),u.pause=t.pause.bind(t),u.resume=t.resume.bind(t),u.stop=u,u}function Xt(f,r=1/0,g){if(r<=0||!xt(f)||f.__v_skip||(g=g||new Map,(g.get(f)||0)>=r))return f;if(g.set(f,r),r--,Ot(f))Xt(f.value,r,g);else if(gt(f))for(let _=0;_<f.length;_++)Xt(f[_],r,g);else if(Nr(f)||ie(f))f.forEach(_=>{Xt(_,r,g)});else if(Yr(f)){for(const _ in f)Xt(f[_],r,g);for(const _ of Object.getOwnPropertySymbols(f))Object.prototype.propertyIsEnumerable.call(f,_)&&Xt(f[_],r,g)}return f}const Kt=[];function bs(f){Kt.push(f)}function Ss(){Kt.pop()}let ei=!1;function yt(f,...r){if(ei)return;ei=!0,se();const g=Kt.length?Kt[Kt.length-1].component:null,_=g&&g.appContext.config.warnHandler,y=ws();if(_)Ue(_,g,11,[f+r.map(C=>{var T,c;return(c=(T=C.toString)==null?void 0:T.call(C))!=null?c:JSON.stringify(C)}).join(""),g&&g.proxy,y.map(({vnode:C})=>`at <${sr(g,C.type)}>`).join(`
2
2
  `),y]);else{const C=[`[Vue warn]: ${f}`,...r];y.length&&C.push(`
3
- `,...xs(y)),console.warn(...C)}oe(),ei=!1}function ws(){let f=qt[qt.length-1];if(!f)return[];const r=[];for(;f;){const p=r[0];p&&p.vnode===f?p.recurseCount++:r.push({vnode:f,recurseCount:0});const _=f.component&&f.component.parent;f=_&&_.vnode}return r}function xs(f){const r=[];return f.forEach((p,_)=>{r.push(..._===0?[]:[`
4
- `],...Ts(p))}),r}function Ts({vnode:f,recurseCount:r}){const p=r>0?`... (${r} recursive calls)`:"",_=f.component?f.component.parent==null:!1,y=` at <${sr(f.component,f.type,_)}`,C=">"+p;return f.props?[y,...Os(f.props),C]:[y+C]}function Os(f){const r=[],p=Object.keys(f);return p.slice(0,3).forEach(_=>{r.push(...Vn(_,f[_]))}),p.length>3&&r.push(" ..."),r}function Vn(f,r,p){return jt(r)?(r=JSON.stringify(r),p?r:[`${f}=${r}`]):typeof r=="number"||typeof r=="boolean"||r==null?p?r:[`${f}=${r}`]:Ot(r)?(r=Vn(f,at(r.value),!0),p?r:[`${f}=Ref<`,r,">"]):Ct(r)?[`${f}=fn${r.name?`<${r.name}>`:""}`]:(r=at(r),p?r:[`${f}=`,r])}const Hi={sp:"serverPrefetch hook",bc:"beforeCreate hook",c:"created hook",bm:"beforeMount hook",m:"mounted hook",bu:"beforeUpdate hook",u:"updated",bum:"beforeUnmount hook",um:"unmounted hook",a:"activated hook",da:"deactivated hook",ec:"errorCaptured hook",rtc:"renderTracked hook",rtg:"renderTriggered hook",0:"setup function",1:"render function",2:"watcher getter",3:"watcher callback",4:"watcher cleanup function",5:"native event handler",6:"component event handler",7:"vnode hook",8:"directive hook",9:"transition hook",10:"app errorHandler",11:"app warnHandler",12:"ref function",13:"async component loader",14:"scheduler flush",15:"component update",16:"app unmount cleanup function"};function Ue(f,r,p,_){try{return _?f(..._):f()}catch(y){Wi(y,r,p)}}function Ni(f,r,p,_){if(Ct(f)){const y=Ue(f,r,p,_);return y&&Wr(y)&&y.catch(C=>{Wi(C,r,p)}),y}if(gt(f)){const y=[];for(let C=0;C<f.length;C++)y.push(Ni(f[C],r,p,_));return y}else process.env.NODE_ENV!=="production"&&yt(`Invalid value type passed to callWithAsyncErrorHandling(): ${typeof f}`)}function Wi(f,r,p,_=!0){const y=r?r.vnode:null,{errorHandler:C,throwUnhandledErrorInProduction:T}=r&&r.appContext.config||me;if(r){let c=r.parent;const i=r.proxy,l=process.env.NODE_ENV!=="production"?Hi[p]:`https://vuejs.org/error-reference/#runtime-${p}`;for(;c;){const a=c.ec;if(a){for(let t=0;t<a.length;t++)if(a[t](f,i,l)===!1)return}c=c.parent}if(C){se(),Ue(C,null,10,[f,i,l]),oe();return}}Es(f,p,y,_,T)}function Es(f,r,p,_=!0,y=!1){if(process.env.NODE_ENV!=="production"){const C=Hi[r];if(p&&bs(p),yt(`Unhandled error${C?` during execution of ${C}`:""}`),p&&Ss(),_)throw f;console.error(f)}else{if(y)throw f;console.error(f)}}const Et=[];let Rt=-1;const re=[];let Nt=null,Qt=0;const Ps=Promise.resolve();let Ei=null;const ks=100;function As(f){let r=Rt+1,p=Et.length;for(;r<p;){const _=r+p>>>1,y=Et[_],C=be(y);C<f||C===f&&y.flags&2?r=_+1:p=_}return r}function Un(f){if(!(f.flags&1)){const r=be(f),p=Et[Et.length-1];!p||!(f.flags&2)&&r>=be(p)?Et.push(f):Et.splice(As(r),0,f),f.flags|=1,zn()}}function zn(){Ei||(Ei=Ps.then(Kn))}function Gn(f){gt(f)?re.push(...f):Nt&&f.id===-1?Nt.splice(Qt+1,0,f):f.flags&1||(re.push(f),f.flags|=1),zn()}function Ds(f){if(re.length){const r=[...new Set(re)].sort((p,_)=>be(p)-be(_));if(re.length=0,Nt){Nt.push(...r);return}for(Nt=r,process.env.NODE_ENV!=="production"&&(f=f||new Map),Qt=0;Qt<Nt.length;Qt++){const p=Nt[Qt];process.env.NODE_ENV!=="production"&&qn(f,p)||(p.flags&4&&(p.flags&=-2),p.flags&8||p(),p.flags&=-2)}Nt=null,Qt=0}}const be=f=>f.id==null?f.flags&2?-1:1/0:f.id;function Kn(f){process.env.NODE_ENV!=="production"&&(f=f||new Map);const r=process.env.NODE_ENV!=="production"?p=>qn(f,p):ee;try{for(Rt=0;Rt<Et.length;Rt++){const p=Et[Rt];if(p&&!(p.flags&8)){if(process.env.NODE_ENV!=="production"&&r(p))continue;p.flags&4&&(p.flags&=-2),Ue(p,p.i,p.i?15:14),p.flags&4||(p.flags&=-2)}}}finally{for(;Rt<Et.length;Rt++){const p=Et[Rt];p&&(p.flags&=-2)}Rt=-1,Et.length=0,Ds(f),Ei=null,(Et.length||re.length)&&Kn(f)}}function qn(f,r){const p=f.get(r)||0;if(p>ks){const _=r.i,y=_&&rr(_.type);return Wi(`Maximum recursive updates exceeded${y?` in component <${y}>`:""}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,null,10),!0}return f.set(r,p+1),!1}const ii=new Map;process.env.NODE_ENV!=="production"&&(Ve().__VUE_HMR_RUNTIME__={createRecord:ni(Ms),rerender:ni(Ls),reload:ni(Fs)});const He=new Map;function Ms(f,r){return He.has(f)?!1:(He.set(f,{initialDef:Ne(r),instances:new Set}),!0)}function Ne(f){return or(f)?f.__vccOpts:f}function Ls(f,r){const p=He.get(f);p&&(p.initialDef.render=r,[...p.instances].forEach(_=>{r&&(_.render=r,Ne(_.type).render=r),_.renderCache=[],_.job.flags&8||_.update()}))}function Fs(f,r){const p=He.get(f);if(!p)return;r=Ne(r),tn(p.initialDef,r);const _=[...p.instances];for(let y=0;y<_.length;y++){const C=_[y],T=Ne(C.type);let c=ii.get(T);c||(T!==p.initialDef&&tn(T,r),ii.set(T,c=new Set)),c.add(C),C.appContext.propsCache.delete(C.type),C.appContext.emitsCache.delete(C.type),C.appContext.optionsCache.delete(C.type),C.ceReload?(c.add(C),C.ceReload(r.styles),c.delete(C)):C.parent?Un(()=>{C.job.flags&8||(C.parent.update(),c.delete(C))}):C.appContext.reload?C.appContext.reload():typeof window<"u"?window.location.reload():console.warn("[HMR] Root or manually mounted instance modified. Full reload required."),C.root.ce&&C!==C.root&&C.root.ce._removeChildStyle(T)}Gn(()=>{ii.clear()})}function tn(f,r){Vt(f,r);for(const p in f)p!=="__file"&&!(p in r)&&delete f[p]}function ni(f){return(r,p)=>{try{return f(r,p)}catch(_){console.error(_),console.warn("[HMR] Something went wrong during Vue component hot-reload. Full reload required.")}}}let Zt,Le=[];function $n(f,r){var p,_;Zt=f,Zt?(Zt.enabled=!0,Le.forEach(({event:y,args:C})=>Zt.emit(y,...C)),Le=[]):typeof window<"u"&&window.HTMLElement&&!((_=(p=window.navigator)==null?void 0:p.userAgent)!=null&&_.includes("jsdom"))?((r.__VUE_DEVTOOLS_HOOK_REPLAY__=r.__VUE_DEVTOOLS_HOOK_REPLAY__||[]).push(C=>{$n(C,r)}),setTimeout(()=>{Zt||(r.__VUE_DEVTOOLS_HOOK_REPLAY__=null,Le=[])},3e3)):Le=[]}let Se=null,Rs=null;const Is=f=>f.__isTeleport;function Jn(f,r){f.shapeFlag&6&&f.component?(f.transition=r,Jn(f.component.subTree,r)):f.shapeFlag&128?(f.ssContent.transition=r.clone(f.ssContent),f.ssFallback.transition=r.clone(f.ssFallback)):f.transition=r}Ve().requestIdleCallback;Ve().cancelIdleCallback;function js(f,r,p=ae,_=!1){if(p){const y=p[f]||(p[f]=[]),C=r.__weh||(r.__weh=(...T)=>{se();const c=oo(p),i=Ni(r,p,f,T);return c(),oe(),i});return _?y.unshift(C):y.push(C),C}else if(process.env.NODE_ENV!=="production"){const y=Vr(Hi[f].replace(/ hook$/,""));yt(`${y} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`)}}const Bs=f=>(r,p=ae)=>{(!we||f==="sp")&&js(f,(..._)=>r(..._),p)},Hs=Bs("m"),Ns=Symbol.for("v-ndc"),Ws={};process.env.NODE_ENV!=="production"&&(Ws.ownKeys=f=>(yt("Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead."),Reflect.ownKeys(f)));let Xs=null;function Ys(f,r,p=!1){const _=Yi();if(_||Xs){let y=_?_.parent==null||_.ce?_.vnode.appContext&&_.vnode.appContext.provides:_.parent.provides:void 0;if(y&&f in y)return y[f];if(arguments.length>1)return p&&Ct(r)?r.call(_&&_.proxy):r;process.env.NODE_ENV!=="production"&&yt(`injection "${String(f)}" not found.`)}else process.env.NODE_ENV!=="production"&&yt("inject() can only be used inside setup() or functional components.")}const Vs=Symbol.for("v-scx"),Us=()=>{{const f=Ys(Vs);return f||process.env.NODE_ENV!=="production"&&yt("Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build."),f}};function Qn(f,r,p){return process.env.NODE_ENV!=="production"&&!Ct(r)&&yt("`watch(fn, options?)` signature has been moved to a separate API. Use `watchEffect(fn, options?)` instead. `watch` now only supports `watch(source, cb, options?) signature."),zs(f,r,p)}function zs(f,r,p=me){const{immediate:_,deep:y,flush:C,once:T}=p;process.env.NODE_ENV!=="production"&&!r&&(_!==void 0&&yt('watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.'),y!==void 0&&yt('watch() "deep" option is only respected when using the watch(source, callback, options?) signature.'),T!==void 0&&yt('watch() "once" option is only respected when using the watch(source, callback, options?) signature.'));const c=Vt({},p);process.env.NODE_ENV!=="production"&&(c.onWarn=yt);const i=r&&_||!r&&C!=="post";let l;if(we){if(C==="sync"){const e=Us();l=e.__watcherHandles||(e.__watcherHandles=[])}else if(!i){const e=()=>{};return e.stop=ee,e.resume=ee,e.pause=ee,e}}const a=ae;c.call=(e,o,h)=>Ni(e,a,o,h);let t=!1;C==="post"?c.scheduler=e=>{Ks(e,a&&a.suspense)}:C!=="sync"&&(t=!0,c.scheduler=(e,o)=>{o?e():Un(e)}),c.augmentJob=e=>{r&&(e.flags|=4),t&&(e.flags|=2,a&&(e.id=a.uid,e.i=a))};const n=Cs(f,r,c);return we&&(l?l.push(n):i&&n()),n}const Gs={},Zn=f=>Object.getPrototypeOf(f)===Gs,Ks=$s,qs=f=>f.__isSuspense;function $s(f,r){r&&r.pendingBranch?gt(f)?r.effects.push(...f):r.effects.push(f):Gn(f)}const tr=Symbol.for("v-fgt"),Js=Symbol.for("v-txt"),Qs=Symbol.for("v-cmt");function Zs(f){return f?f.__v_isVNode===!0:!1}const to=(...f)=>ir(...f),er=({key:f})=>f??null,Fe=({ref:f,ref_key:r,ref_for:p})=>(typeof f=="number"&&(f=""+f),f!=null?jt(f)||Ot(f)||Ct(f)?{i:Se,r:f,k:r,f:!!p}:f:null);function eo(f,r=null,p=null,_=0,y=null,C=f===tr?0:1,T=!1,c=!1){const i={__v_isVNode:!0,__v_skip:!0,type:f,props:r,key:r&&er(r),ref:r&&Fe(r),scopeId:Rs,slotScopeIds:null,children:p,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:C,patchFlag:_,dynamicProps:y,dynamicChildren:null,appContext:null,ctx:Se};return c?(Xi(i,p),C&128&&f.normalize(i)):p&&(i.shapeFlag|=jt(p)?8:16),process.env.NODE_ENV!=="production"&&i.key!==i.key&&yt("VNode created with invalid key (NaN). VNode type:",i.type),i}const io=process.env.NODE_ENV!=="production"?to:ir;function ir(f,r=null,p=null,_=0,y=null,C=!1){if((!f||f===Ns)&&(process.env.NODE_ENV!=="production"&&!f&&yt(`Invalid vnode type when creating vnode: ${f}.`),f=Qs),Zs(f)){const c=We(f,r,!0);return p&&Xi(c,p),c.patchFlag=-2,c}if(or(f)&&(f=f.__vccOpts),r){r=no(r);let{class:c,style:i}=r;c&&!jt(c)&&(r.class=Li(c)),xt(i)&&(je(i)&&!gt(i)&&(i=Vt({},i)),r.style=Mi(i))}const T=jt(f)?1:qs(f)?128:Is(f)?64:xt(f)?4:Ct(f)?2:0;return process.env.NODE_ENV!=="production"&&T&4&&je(f)&&(f=at(f),yt("Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.",`
5
- Component that was made reactive: `,f)),eo(f,r,p,_,y,T,C,!0)}function no(f){return f?je(f)||Zn(f)?Vt({},f):f:null}function We(f,r,p=!1,_=!1){const{props:y,ref:C,patchFlag:T,children:c,transition:i}=f,l=r?so(y||{},r):y,a={__v_isVNode:!0,__v_skip:!0,type:f.type,props:l,key:l&&er(l),ref:r&&r.ref?p&&C?gt(C)?C.concat(Fe(r)):[C,Fe(r)]:Fe(r):C,scopeId:f.scopeId,slotScopeIds:f.slotScopeIds,children:process.env.NODE_ENV!=="production"&&T===-1&&gt(c)?c.map(nr):c,target:f.target,targetStart:f.targetStart,targetAnchor:f.targetAnchor,staticCount:f.staticCount,shapeFlag:f.shapeFlag,patchFlag:r&&f.type!==tr?T===-1?16:T|16:T,dynamicProps:f.dynamicProps,dynamicChildren:f.dynamicChildren,appContext:f.appContext,dirs:f.dirs,transition:i,component:f.component,suspense:f.suspense,ssContent:f.ssContent&&We(f.ssContent),ssFallback:f.ssFallback&&We(f.ssFallback),placeholder:f.placeholder,el:f.el,anchor:f.anchor,ctx:f.ctx,ce:f.ce};return i&&_&&Jn(a,i.clone(a)),a}function nr(f){const r=We(f);return gt(f.children)&&(r.children=f.children.map(nr)),r}function ro(f=" ",r=0){return io(Js,null,f,r)}function Xi(f,r){let p=0;const{shapeFlag:_}=f;if(r==null)r=null;else if(gt(r))p=16;else if(typeof r=="object")if(_&65){const y=r.default;y&&(y._c&&(y._d=!1),Xi(f,y()),y._c&&(y._d=!0));return}else p=32,!r._&&!Zn(r)&&(r._ctx=Se);else Ct(r)?(r={default:r,_ctx:Se},p=32):(r=String(r),_&64?(p=16,r=[ro(r)]):p=8);f.children=r,f.shapeFlag|=p}function so(...f){const r={};for(let p=0;p<f.length;p++){const _=f[p];for(const y in _)if(y==="class")r.class!==_.class&&(r.class=Li([r.class,_.class]));else if(y==="style")r.style=Mi([r.style,_.style]);else if(Br(y)){const C=r[y],T=_[y];T&&C!==T&&!(gt(C)&&C.includes(T))&&(r[y]=C?[].concat(C,T):T)}else y!==""&&(r[y]=_[y])}return r}let ae=null;const Yi=()=>ae||Se;let Pi;{const f=Ve(),r=(p,_)=>{let y;return(y=f[p])||(y=f[p]=[]),y.push(_),C=>{y.length>1?y.forEach(T=>T(C)):y[0](C)}};Pi=r("__VUE_INSTANCE_SETTERS__",p=>ae=p),r("__VUE_SSR_SETTERS__",p=>we=p)}const oo=f=>{const r=ae;return Pi(f),f.scope.on(),()=>{f.scope.off(),Pi(r)}};let we=!1;process.env.NODE_ENV;const ao=/(?:^|[-_])\w/g,lo=f=>f.replace(ao,r=>r.toUpperCase()).replace(/[-_]/g,"");function rr(f,r=!0){return Ct(f)?f.displayName||f.name:f.name||r&&f.__name}function sr(f,r,p=!1){let _=rr(r);if(!_&&r.__file){const y=r.__file.match(/([^/\\]+)\.\w+$/);y&&(_=y[1])}if(!_&&f){const y=C=>{for(const T in C)if(C[T]===r)return T};_=y(f.components)||f.parent&&y(f.parent.type.components)||y(f.appContext.components)}return _?lo(_):p?"App":"Anonymous"}function or(f){return Ct(f)&&"__vccOpts"in f}const ar=(f,r)=>{const p=_s(f,r,we);if(process.env.NODE_ENV!=="production"){const _=Yi();_&&_.appContext.config.warnRecursiveComputed&&(p._warnRecursive=!0)}return p};function co(){if(process.env.NODE_ENV==="production"||typeof window>"u")return;const f={style:"color:#3ba776"},r={style:"color:#1677ff"},p={style:"color:#f5222d"},_={style:"color:#eb2f96"},y={__vue_custom_formatter:!0,header(t){if(!xt(t))return null;if(t.__isVue)return["div",f,"VueInstance"];if(Ot(t)){se();const n=t.value;return oe(),["div",{},["span",f,a(t)],"<",c(n),">"]}else{if(ne(t))return["div",{},["span",f,Tt(t)?"ShallowReactive":"Reactive"],"<",c(t),`>${Dt(t)?" (readonly)":""}`];if(Dt(t))return["div",{},["span",f,Tt(t)?"ShallowReadonly":"Readonly"],"<",c(t),">"]}return null},hasBody(t){return t&&t.__isVue},body(t){if(t&&t.__isVue)return["div",{},...C(t.$)]}};function C(t){const n=[];t.type.props&&t.props&&n.push(T("props",at(t.props))),t.setupState!==me&&n.push(T("setup",t.setupState)),t.data!==me&&n.push(T("data",at(t.data)));const e=i(t,"computed");e&&n.push(T("computed",e));const o=i(t,"inject");return o&&n.push(T("injected",o)),n.push(["div",{},["span",{style:_.style+";opacity:0.66"},"$ (internal): "],["object",{object:t}]]),n}function T(t,n){return n=Vt({},n),Object.keys(n).length?["div",{style:"line-height:1.25em;margin-bottom:0.6em"},["div",{style:"color:#476582"},t],["div",{style:"padding-left:1.25em"},...Object.keys(n).map(e=>["div",{},["span",_,e+": "],c(n[e],!1)])]]:["span",{}]}function c(t,n=!0){return typeof t=="number"?["span",r,t]:typeof t=="string"?["span",p,JSON.stringify(t)]:typeof t=="boolean"?["span",_,t]:xt(t)?["object",{object:n?at(t):t}]:["span",p,String(t)]}function i(t,n){const e=t.type;if(Ct(e))return;const o={};for(const h in t.ctx)l(e,h,n)&&(o[h]=t.ctx[h]);return o}function l(t,n,e){const o=t[e];if(gt(o)&&o.includes(n)||xt(o)&&n in o||t.extends&&l(t.extends,n,e)||t.mixins&&t.mixins.some(h=>l(h,n,e)))return!0}function a(t){return Tt(t)?"ShallowRef":t.effect?"ComputedRef":"Ref"}window.devtoolsFormatters?window.devtoolsFormatters.push(y):window.devtoolsFormatters=[y]}process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;function ho(){co()}process.env.NODE_ENV!=="production"&&ho();function uo(){const f=new Set,r=y=>{f.delete(y)};return{on:y=>(f.add(y),{off:()=>r(y)}),off:r,trigger:(...y)=>Promise.all(Array.from(f).map(C=>C(...y)))}}function Te(f){return typeof f=="function"?f():ms(f)}const Oe=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const fo=Object.prototype.toString,go=f=>fo.call(f)==="[object Object]",po=()=>{},mo=(f,r)=>Object.prototype.hasOwnProperty.call(f,r);function vo(f){let r;function p(){return r||(r=f()),r}return p.reset=async()=>{const _=r;r=void 0,_&&await _},p}function _o(f,r,p={}){const{immediate:_=!0}=p,y=Ut(!1);let C=null;function T(){C&&(clearTimeout(C),C=null)}function c(){y.value=!1,T()}function i(...l){T(),y.value=!0,C=setTimeout(()=>{y.value=!1,C=null,f(...l)},Te(r))}return _&&(y.value=!0,Oe&&i()),{isPending:ye(y),start:i,stop:c}}function yo(f){var r;const p=Te(f);return(r=p?.$el)!=null?r:p}const Co=Oe?window:void 0,bo=Oe?window.document:void 0,lr=Oe?window.navigator:void 0;function cr(...f){let r,p,_,y;if(typeof f[0]=="string"||Array.isArray(f[0])?([p,_,y]=f,r=Co):[r,p,_,y]=f,!r)return po;Array.isArray(p)||(p=[p]),Array.isArray(_)||(_=[_]);const C=[],T=()=>{C.forEach(a=>a()),C.length=0},c=(a,t,n,e)=>(a.addEventListener(t,n,e),()=>a.removeEventListener(t,n,e)),i=Qn(()=>[yo(r),Te(y)],([a,t])=>{if(T(),!a)return;const n=go(t)?{...t}:t;C.push(...p.flatMap(e=>_.map(o=>c(a,e,o,n))))},{immediate:!0,flush:"post"});return()=>{i(),T()}}function So(){const f=Ut(!1),r=Yi();return r&&Hs(()=>{f.value=!0},r),f}function hr(f){const r=So();return ar(()=>(r.value,!!f()))}const he={array:f=>JSON.stringify(f),object:f=>JSON.stringify(f),set:f=>JSON.stringify(Array.from(f)),map:f=>JSON.stringify(Object.fromEntries(f)),null:()=>""};function wo(f){return f?f instanceof Map?he.map:f instanceof Set?he.set:Array.isArray(f)?he.array:he.object:he.null}function xo(f,r){const p=Ut(""),_=Ut();function y(){if(Oe)return _.value=new Promise((C,T)=>{try{const c=Te(f);if(c==null)C("");else if(typeof c=="string")C(ri(new Blob([c],{type:"text/plain"})));else if(c instanceof Blob)C(ri(c));else if(c instanceof ArrayBuffer)C(window.btoa(String.fromCharCode(...new Uint8Array(c))));else if(c instanceof HTMLCanvasElement)C(c.toDataURL(r?.type,r?.quality));else if(c instanceof HTMLImageElement){const i=c.cloneNode(!1);i.crossOrigin="Anonymous",To(i).then(()=>{const l=document.createElement("canvas"),a=l.getContext("2d");l.width=i.width,l.height=i.height,a.drawImage(i,0,0,l.width,l.height),C(l.toDataURL(r?.type,r?.quality))}).catch(T)}else if(typeof c=="object"){const l=(r?.serializer||wo(c))(c);return C(ri(new Blob([l],{type:"application/json"})))}else T(new Error("target is unsupported types"))}catch(c){T(c)}}),_.value.then(C=>p.value=C),_.value}return Ot(f)||typeof f=="function"?Qn(f,y,{immediate:!0}):y(),{base64:p,promise:_,execute:y}}function To(f){return new Promise((r,p)=>{f.complete?r():(f.onload=()=>{r()},f.onerror=p)})}function ri(f){return new Promise((r,p)=>{const _=new FileReader;_.onload=y=>{r(y.target.result)},_.onerror=p,_.readAsDataURL(f)})}function en(f,r={}){const{controls:p=!1,navigator:_=lr}=r,y=hr(()=>_&&"permissions"in _);let C;const T=typeof f=="string"?{name:f}:f,c=Ut(),i=()=>{C&&(c.value=C.state)},l=vo(async()=>{if(y.value){if(!C)try{C=await _.permissions.query(T),cr(C,"change",i),i()}catch{c.value="prompt"}return C}});return l(),p?{state:c,isSupported:y,query:l}:c}function Oo(f={}){const{navigator:r=lr,read:p=!1,source:_,copiedDuring:y=1500,legacy:C=!1}=f,T=hr(()=>r&&"clipboard"in r),c=en("clipboard-read"),i=en("clipboard-write"),l=ar(()=>T.value||C),a=Ut(""),t=Ut(!1),n=_o(()=>t.value=!1,y);function e(){T.value&&u(c.value)?r.clipboard.readText().then(d=>{a.value=d}):a.value=s()}l.value&&p&&cr(["copy","cut"],e);async function o(d=Te(_)){l.value&&d!=null&&(T.value&&u(i.value)?await r.clipboard.writeText(d):h(d),a.value=d,t.value=!0,n.start())}function h(d){const m=document.createElement("textarea");m.value=d??"",m.style.position="absolute",m.style.opacity="0",document.body.appendChild(m),m.select(),document.execCommand("copy"),m.remove()}function s(){var d,m,g;return(g=(m=(d=document?.getSelection)==null?void 0:d.call(document))==null?void 0:m.toString())!=null?g:""}function u(d){return d==="granted"||d==="prompt"}return{isSupported:l,text:a,copied:t,copy:o}}const Eo={multiple:!0,accept:"*",reset:!1,directory:!1};function Po(f={}){const{document:r=bo}=f,p=Ut(null),{on:_,trigger:y}=uo();let C;r&&(C=r.createElement("input"),C.type="file",C.onchange=i=>{const l=i.target;p.value=l.files,y(p.value)});const T=()=>{p.value=null,C&&C.value&&(C.value="",y(null))},c=i=>{if(!C)return;const l={...Eo,...f,...i};C.multiple=l.multiple,C.accept=l.accept,C.webkitdirectory=l.directory,mo(l,"capture")&&(C.capture=l.capture),l.reset&&T(),C.click()};return{files:ye(p),open:c,reset:T,onChange:_}}function ko(f){return xo(f).promise.value}function ur(f){return new Promise(r=>{const{onChange:p,open:_}=Po(f);p(y=>{r(y)}),_()})}function Ao(f){return new Promise(r=>{const p=document.createElement("img");p.src=f,document.body.appendChild(p),p.onload=()=>{r(p)}})}const ki=(f,r)=>Oo({source:f,...r}).copy();function Re(f,r){const p=document.createElement("a");p.href=f,p.download=`${On()}.${r}`,document.body.appendChild(p),p.click(),p.remove()}function Do(f,r,p,_,y,C,T){T!==void 0&&(f.save(),f.translate(r,p),f.rotate(T),f.drawImage(_,-y/2,-C/2,y,C),f.restore())}const Mo=f=>f instanceof fabric.Image,Lo=f=>f instanceof fabric.Group,Fo=f=>f instanceof fabric.IText,Ro=f=>f instanceof fabric.ActiveSelection;function Io(f){return new Promise(r=>{const p=new FileReader;p.addEventListener("load",()=>{r(p.result)}),p.readAsDataURL(f)})}function jo(f){if(!f)return null;const r=f.split(","),p=r[0].match(/:(.*?);/)[1],_=window.atob(r[1]),y=new ArrayBuffer(_.length),C=new Uint8Array(y);for(let T=0;T<_.length;T++)C[T]=_.charCodeAt(T);return[new Blob([y],{type:p}),p.slice(6)]}const fr={getImgStr:ko,downFile:Re,selectFiles:ur,insertImgFile:Ao,clipboardText:ki,drawImg:Do,isImage:Mo,isGroup:Lo,isIText:Fo,isActiveSelection:Ro,blobToBase64:Io,base64ToBlob:jo};var si={};const Bo={},Ho=Object.freeze(Object.defineProperty({__proto__:null,default:Bo},Symbol.toStringTag,{value:"Module"})),oi=yr(Ho);var nn;function No(){return nn||(nn=1,(function(f){var r=r||{version:"5.3.0"};if(f.fabric=r,typeof document<"u"&&typeof window<"u")document instanceof(typeof HTMLDocument<"u"?HTMLDocument:Document)?r.document=document:r.document=document.implementation.createHTMLDocument(""),r.window=window;else{var p=oi,_=new p.JSDOM(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;r.document=_.document,r.jsdomImplForWrapper=oi.implForWrapper,r.nodeCanvas=oi.Canvas,r.window=_,DOMParser=r.window.DOMParser}r.isTouchSupported="ontouchstart"in r.window||"ontouchstart"in r.document||r.window&&r.window.navigator&&r.window.navigator.maxTouchPoints>0,r.isLikelyNode=typeof Buffer<"u"&&typeof window>"u",r.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],r.DPI=96,r.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",r.commaWsp="(?:\\s+,?\\s*|,\\s*)",r.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/ig,r.reNonWord=/[ \n\.,;!\?\-]/,r.fontPaths={},r.iMatrix=[1,0,0,1,0,0],r.svgNS="http://www.w3.org/2000/svg",r.perfLimitSizeTotal=2097152,r.maxCacheSideLimit=4096,r.minCacheSideLimit=256,r.charWidthsCache={},r.textureSize=2048,r.disableStyleCopyPaste=!1,r.enableGLFiltering=!0,r.devicePixelRatio=r.window.devicePixelRatio||r.window.webkitDevicePixelRatio||r.window.mozDevicePixelRatio||1,r.browserShadowBlurConstant=1,r.arcToSegmentsCache={},r.boundsOfCurveCache={},r.cachesBoundsOfCurve=!0,r.forceGLPutImageData=!1,r.initFilterBackend=function(){if(r.enableGLFiltering&&r.isWebglSupported&&r.isWebglSupported(r.textureSize))return console.log("max texture size: "+r.maxTextureSize),new r.WebglFilterBackend({tileSize:r.textureSize});if(r.Canvas2dFilterBackend)return new r.Canvas2dFilterBackend},typeof document<"u"&&typeof window<"u"&&(window.fabric=r),(function(){function c(e,o){if(this.__eventListeners[e]){var h=this.__eventListeners[e];o?h[h.indexOf(o)]=!1:r.util.array.fill(h,!1)}}function i(e,o){if(this.__eventListeners||(this.__eventListeners={}),arguments.length===1)for(var h in e)this.on(h,e[h]);else this.__eventListeners[e]||(this.__eventListeners[e]=[]),this.__eventListeners[e].push(o);return this}function l(e,o){var h=(function(){o.apply(this,arguments),this.off(e,h)}).bind(this);this.on(e,h)}function a(e,o){if(arguments.length===1)for(var h in e)l.call(this,h,e[h]);else l.call(this,e,o);return this}function t(e,o){if(!this.__eventListeners)return this;if(arguments.length===0)for(e in this.__eventListeners)c.call(this,e);else if(arguments.length===1&&typeof arguments[0]=="object")for(var h in e)c.call(this,h,e[h]);else c.call(this,e,o);return this}function n(e,o){if(!this.__eventListeners)return this;var h=this.__eventListeners[e];if(!h)return this;for(var s=0,u=h.length;s<u;s++)h[s]&&h[s].call(this,o||{});return this.__eventListeners[e]=h.filter(function(d){return d!==!1}),this}r.Observable={fire:n,on:i,once:a,off:t}})(),r.Collection={_objects:[],add:function(){if(this._objects.push.apply(this._objects,arguments),this._onObjectAdded)for(var c=0,i=arguments.length;c<i;c++)this._onObjectAdded(arguments[c]);return this.renderOnAddRemove&&this.requestRenderAll(),this},insertAt:function(c,i,l){var a=this._objects;return l?a[i]=c:a.splice(i,0,c),this._onObjectAdded&&this._onObjectAdded(c),this.renderOnAddRemove&&this.requestRenderAll(),this},remove:function(){for(var c=this._objects,i,l=!1,a=0,t=arguments.length;a<t;a++)i=c.indexOf(arguments[a]),i!==-1&&(l=!0,c.splice(i,1),this._onObjectRemoved&&this._onObjectRemoved(arguments[a]));return this.renderOnAddRemove&&l&&this.requestRenderAll(),this},forEachObject:function(c,i){for(var l=this.getObjects(),a=0,t=l.length;a<t;a++)c.call(i,l[a],a,l);return this},getObjects:function(c){return typeof c>"u"?this._objects.concat():this._objects.filter(function(i){return i.type===c})},item:function(c){return this._objects[c]},isEmpty:function(){return this._objects.length===0},size:function(){return this._objects.length},contains:function(c,i){return this._objects.indexOf(c)>-1?!0:i?this._objects.some(function(l){return typeof l.contains=="function"&&l.contains(c,!0)}):!1},complexity:function(){return this._objects.reduce(function(c,i){return c+=i.complexity?i.complexity():0,c},0)}},r.CommonMethods={_setOptions:function(c){for(var i in c)this.set(i,c[i])},_initGradient:function(c,i){c&&c.colorStops&&!(c instanceof r.Gradient)&&this.set(i,new r.Gradient(c))},_initPattern:function(c,i,l){c&&c.source&&!(c instanceof r.Pattern)?this.set(i,new r.Pattern(c,l)):l&&l()},_setObject:function(c){for(var i in c)this._set(i,c[i])},set:function(c,i){return typeof c=="object"?this._setObject(c):this._set(c,i),this},_set:function(c,i){this[c]=i},toggle:function(c){var i=this.get(c);return typeof i=="boolean"&&this.set(c,!i),this},get:function(c){return this[c]}},(function(c){var i=Math.sqrt,l=Math.atan2,a=Math.pow,t=Math.PI/180,n=Math.PI/2;r.util={cos:function(e){if(e===0)return 1;e<0&&(e=-e);var o=e/n;switch(o){case 1:case 3:return 0;case 2:return-1}return Math.cos(e)},sin:function(e){if(e===0)return 0;var o=e/n,h=1;switch(e<0&&(h=-1),o){case 1:return h;case 2:return 0;case 3:return-h}return Math.sin(e)},removeFromArray:function(e,o){var h=e.indexOf(o);return h!==-1&&e.splice(h,1),e},getRandomInt:function(e,o){return Math.floor(Math.random()*(o-e+1))+e},degreesToRadians:function(e){return e*t},radiansToDegrees:function(e){return e/t},rotatePoint:function(e,o,h){var s=new r.Point(e.x-o.x,e.y-o.y),u=r.util.rotateVector(s,h);return new r.Point(u.x,u.y).addEquals(o)},rotateVector:function(e,o){var h=r.util.sin(o),s=r.util.cos(o),u=e.x*s-e.y*h,d=e.x*h+e.y*s;return{x:u,y:d}},createVector:function(e,o){return new r.Point(o.x-e.x,o.y-e.y)},calcAngleBetweenVectors:function(e,o){return Math.acos((e.x*o.x+e.y*o.y)/(Math.hypot(e.x,e.y)*Math.hypot(o.x,o.y)))},getHatVector:function(e){return new r.Point(e.x,e.y).multiply(1/Math.hypot(e.x,e.y))},getBisector:function(e,o,h){var s=r.util.createVector(e,o),u=r.util.createVector(e,h),d=r.util.calcAngleBetweenVectors(s,u),m=r.util.calcAngleBetweenVectors(r.util.rotateVector(s,d),u),g=d*(m===0?1:-1)/2;return{vector:r.util.getHatVector(r.util.rotateVector(s,g)),angle:d}},projectStrokeOnPoints:function(e,o,h){var s=[],u=o.strokeWidth/2,d=o.strokeUniform?new r.Point(1/o.scaleX,1/o.scaleY):new r.Point(1,1),m=function(g){var v=u/Math.hypot(g.x,g.y);return new r.Point(g.x*v*d.x,g.y*v*d.y)};return e.length<=1||e.forEach(function(g,v){var b=new r.Point(g.x,g.y),S,E;v===0?(E=e[v+1],S=h?m(r.util.createVector(E,b)).addEquals(b):e[e.length-1]):v===e.length-1?(S=e[v-1],E=h?m(r.util.createVector(S,b)).addEquals(b):e[0]):(S=e[v-1],E=e[v+1]);var F=r.util.getBisector(b,S,E),R=F.vector,z=F.angle,q,Z;if(o.strokeLineJoin==="miter"&&(q=-u/Math.sin(z/2),Z=new r.Point(R.x*q*d.x,R.y*q*d.y),Math.hypot(Z.x,Z.y)/u<=o.strokeMiterLimit)){s.push(b.add(Z)),s.push(b.subtract(Z));return}q=-u*Math.SQRT2,Z=new r.Point(R.x*q*d.x,R.y*q*d.y),s.push(b.add(Z)),s.push(b.subtract(Z))}),s},transformPoint:function(e,o,h){return h?new r.Point(o[0]*e.x+o[2]*e.y,o[1]*e.x+o[3]*e.y):new r.Point(o[0]*e.x+o[2]*e.y+o[4],o[1]*e.x+o[3]*e.y+o[5])},makeBoundingBoxFromPoints:function(e,o){if(o)for(var h=0;h<e.length;h++)e[h]=r.util.transformPoint(e[h],o);var s=[e[0].x,e[1].x,e[2].x,e[3].x],u=r.util.array.min(s),d=r.util.array.max(s),m=d-u,g=[e[0].y,e[1].y,e[2].y,e[3].y],v=r.util.array.min(g),b=r.util.array.max(g),S=b-v;return{left:u,top:v,width:m,height:S}},invertTransform:function(e){var o=1/(e[0]*e[3]-e[1]*e[2]),h=[o*e[3],-o*e[1],-o*e[2],o*e[0]],s=r.util.transformPoint({x:e[4],y:e[5]},h,!0);return h[4]=-s.x,h[5]=-s.y,h},toFixed:function(e,o){return parseFloat(Number(e).toFixed(o))},parseUnit:function(e,o){var h=/\D{0,2}$/.exec(e),s=parseFloat(e);switch(o||(o=r.Text.DEFAULT_SVG_FONT_SIZE),h[0]){case"mm":return s*r.DPI/25.4;case"cm":return s*r.DPI/2.54;case"in":return s*r.DPI;case"pt":return s*r.DPI/72;case"pc":return s*r.DPI/72*12;case"em":return s*o;default:return s}},falseFunction:function(){return!1},getKlass:function(e,o){return e=r.util.string.camelize(e.charAt(0).toUpperCase()+e.slice(1)),r.util.resolveNamespace(o)[e]},getSvgAttributes:function(e){var o=["instantiated_by_use","style","id","class"];switch(e){case"linearGradient":o=o.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);break;case"radialGradient":o=o.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);break;case"stop":o=o.concat(["offset","stop-color","stop-opacity"]);break}return o},resolveNamespace:function(e){if(!e)return r;var o=e.split("."),h=o.length,s,u=c||r.window;for(s=0;s<h;++s)u=u[o[s]];return u},loadImage:function(e,o,h,s){if(!e){o&&o.call(h,e);return}var u=r.util.createImage(),d=function(){o&&o.call(h,u,!1),u=u.onload=u.onerror=null};u.onload=d,u.onerror=function(){r.log("Error loading "+u.src),o&&o.call(h,null,!0),u=u.onload=u.onerror=null},e.indexOf("data")!==0&&s!==void 0&&s!==null&&(u.crossOrigin=s),e.substring(0,14)==="data:image/svg"&&(u.onload=null,r.util.loadImageInDom(u,d)),u.src=e},loadImageInDom:function(e,o){var h=r.document.createElement("div");h.style.width=h.style.height="1px",h.style.left=h.style.top="-100%",h.style.position="absolute",h.appendChild(e),r.document.querySelector("body").appendChild(h),e.onload=function(){o(),h.parentNode.removeChild(h),h=null}},enlivenObjects:function(e,o,h,s){e=e||[];var u=[],d=0,m=e.length;function g(){++d===m&&o&&o(u.filter(function(v){return v}))}if(!m){o&&o(u);return}e.forEach(function(v,b){if(!v||!v.type){g();return}var S=r.util.getKlass(v.type,h);S.fromObject(v,function(E,F){F||(u[b]=E),s&&s(v,E,F),g()})})},enlivenObjectEnlivables:function(e,o,h){var s=r.Object.ENLIVEN_PROPS.filter(function(u){return!!e[u]});r.util.enlivenObjects(s.map(function(u){return e[u]}),function(u){var d={};s.forEach(function(m,g){d[m]=u[g],o&&(o[m]=u[g])}),h&&h(d)})},enlivenPatterns:function(e,o){e=e||[];function h(){++u===d&&o&&o(s)}var s=[],u=0,d=e.length;if(!d){o&&o(s);return}e.forEach(function(m,g){m&&m.source?new r.Pattern(m,function(v){s[g]=v,h()}):(s[g]=m,h())})},groupSVGElements:function(e,o,h){var s;return e&&e.length===1?(typeof h<"u"&&(e[0].sourcePath=h),e[0]):(o&&(o.width&&o.height?o.centerPoint={x:o.width/2,y:o.height/2}:(delete o.width,delete o.height)),s=new r.Group(e,o),typeof h<"u"&&(s.sourcePath=h),s)},populateWithProperties:function(e,o,h){if(h&&Array.isArray(h))for(var s=0,u=h.length;s<u;s++)h[s]in e&&(o[h[s]]=e[h[s]])},createCanvasElement:function(){return r.document.createElement("canvas")},copyCanvasElement:function(e){var o=r.util.createCanvasElement();return o.width=e.width,o.height=e.height,o.getContext("2d").drawImage(e,0,0),o},toDataURL:function(e,o,h){return e.toDataURL("image/"+o,h)},createImage:function(){return r.document.createElement("img")},multiplyTransformMatrices:function(e,o,h){return[e[0]*o[0]+e[2]*o[1],e[1]*o[0]+e[3]*o[1],e[0]*o[2]+e[2]*o[3],e[1]*o[2]+e[3]*o[3],h?0:e[0]*o[4]+e[2]*o[5]+e[4],h?0:e[1]*o[4]+e[3]*o[5]+e[5]]},qrDecompose:function(e){var o=l(e[1],e[0]),h=a(e[0],2)+a(e[1],2),s=i(h),u=(e[0]*e[3]-e[2]*e[1])/s,d=l(e[0]*e[2]+e[1]*e[3],h);return{angle:o/t,scaleX:s,scaleY:u,skewX:d/t,skewY:0,translateX:e[4],translateY:e[5]}},calcRotateMatrix:function(e){if(!e.angle)return r.iMatrix.concat();var o=r.util.degreesToRadians(e.angle),h=r.util.cos(o),s=r.util.sin(o);return[h,s,-s,h,0,0]},calcDimensionsMatrix:function(e){var o=typeof e.scaleX>"u"?1:e.scaleX,h=typeof e.scaleY>"u"?1:e.scaleY,s=[e.flipX?-o:o,0,0,e.flipY?-h:h,0,0],u=r.util.multiplyTransformMatrices,d=r.util.degreesToRadians;return e.skewX&&(s=u(s,[1,0,Math.tan(d(e.skewX)),1],!0)),e.skewY&&(s=u(s,[1,Math.tan(d(e.skewY)),0,1],!0)),s},composeMatrix:function(e){var o=[1,0,0,1,e.translateX||0,e.translateY||0],h=r.util.multiplyTransformMatrices;return e.angle&&(o=h(o,r.util.calcRotateMatrix(e))),(e.scaleX!==1||e.scaleY!==1||e.skewX||e.skewY||e.flipX||e.flipY)&&(o=h(o,r.util.calcDimensionsMatrix(e))),o},resetObjectTransform:function(e){e.scaleX=1,e.scaleY=1,e.skewX=0,e.skewY=0,e.flipX=!1,e.flipY=!1,e.rotate(0)},saveObjectTransform:function(e){return{scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,angle:e.angle,left:e.left,flipX:e.flipX,flipY:e.flipY,top:e.top}},isTransparent:function(e,o,h,s){s>0&&(o>s?o-=s:o=0,h>s?h-=s:h=0);var u=!0,d,m,g=e.getImageData(o,h,s*2||1,s*2||1),v=g.data.length;for(d=3;d<v&&(m=g.data[d],u=m<=0,u!==!1);d+=4);return g=null,u},parsePreserveAspectRatioAttribute:function(e){var o="meet",h="Mid",s="Mid",u=e.split(" "),d;return u&&u.length&&(o=u.pop(),o!=="meet"&&o!=="slice"?(d=o,o="meet"):u.length&&(d=u.pop())),h=d!=="none"?d.slice(1,4):"none",s=d!=="none"?d.slice(5,8):"none",{meetOrSlice:o,alignX:h,alignY:s}},clearFabricFontCache:function(e){e=(e||"").toLowerCase(),e?r.charWidthsCache[e]&&delete r.charWidthsCache[e]:r.charWidthsCache={}},limitDimsByArea:function(e,o){var h=Math.sqrt(o*e),s=Math.floor(o/h);return{x:Math.floor(h),y:s}},capValue:function(e,o,h){return Math.max(e,Math.min(o,h))},findScaleToFit:function(e,o){return Math.min(o.width/e.width,o.height/e.height)},findScaleToCover:function(e,o){return Math.max(o.width/e.width,o.height/e.height)},matrixToSVG:function(e){return"matrix("+e.map(function(o){return r.util.toFixed(o,r.Object.NUM_FRACTION_DIGITS)}).join(" ")+")"},removeTransformFromObject:function(e,o){var h=r.util.invertTransform(o),s=r.util.multiplyTransformMatrices(h,e.calcOwnMatrix());r.util.applyTransformToObject(e,s)},addTransformToObject:function(e,o){r.util.applyTransformToObject(e,r.util.multiplyTransformMatrices(o,e.calcOwnMatrix()))},applyTransformToObject:function(e,o){var h=r.util.qrDecompose(o),s=new r.Point(h.translateX,h.translateY);e.flipX=!1,e.flipY=!1,e.set("scaleX",h.scaleX),e.set("scaleY",h.scaleY),e.skewX=h.skewX,e.skewY=h.skewY,e.angle=h.angle,e.setPositionByOrigin(s,"center","center")},sizeAfterTransform:function(e,o,h){var s=e/2,u=o/2,d=[{x:-s,y:-u},{x:s,y:-u},{x:-s,y:u},{x:s,y:u}],m=r.util.calcDimensionsMatrix(h),g=r.util.makeBoundingBoxFromPoints(d,m);return{x:g.width,y:g.height}},mergeClipPaths:function(e,o){var h=e,s=o;h.inverted&&!s.inverted&&(h=o,s=e),r.util.applyTransformToObject(s,r.util.multiplyTransformMatrices(r.util.invertTransform(h.calcTransformMatrix()),s.calcTransformMatrix()));var u=h.inverted&&s.inverted;return u&&(h.inverted=s.inverted=!1),new r.Group([h],{clipPath:s,inverted:u})},hasStyleChanged:function(e,o,h){return h=h||!1,e.fill!==o.fill||e.stroke!==o.stroke||e.strokeWidth!==o.strokeWidth||e.fontSize!==o.fontSize||e.fontFamily!==o.fontFamily||e.fontWeight!==o.fontWeight||e.fontStyle!==o.fontStyle||e.textBackgroundColor!==o.textBackgroundColor||e.deltaY!==o.deltaY||h&&(e.overline!==o.overline||e.underline!==o.underline||e.linethrough!==o.linethrough)},stylesToArray:function(h,o){for(var h=r.util.object.clone(h,!0),s=o.split(`
6
- `),u=-1,d={},m=[],g=0;g<s.length;g++){if(!h[g]){u+=s[g].length;continue}for(var v=0;v<s[g].length;v++){u++;var b=h[g][v];if(b&&Object.keys(b).length>0){var S=r.util.hasStyleChanged(d,b,!0);S?m.push({start:u,end:u+1,style:b}):m[m.length-1].end++}d=b||{}}}return m},stylesFromArray:function(e,o){if(!Array.isArray(e))return e;for(var h=o.split(`
7
- `),s=-1,u=0,d={},m=0;m<h.length;m++)for(var g=0;g<h[m].length;g++)s++,e[u]&&e[u].start<=s&&s<e[u].end&&(d[m]=d[m]||{},d[m][g]=Object.assign({},e[u].style),s===e[u].end-1&&u++);return d}}})(f),(function(){var c=Array.prototype.join,i={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},l={m:"l",M:"L"};function a(w,k,A,P,I,O,x,D,L,N,j){var V=r.util.cos(w),G=r.util.sin(w),J=r.util.cos(k),B=r.util.sin(k),M=A*I*J-P*O*B+x,X=P*I*J+A*O*B+D,Y=N+L*(-A*I*G-P*O*V),H=j+L*(-P*I*G+A*O*V),U=M+L*(A*I*B+P*O*J),Q=X+L*(P*I*B-A*O*J);return["C",Y,H,U,Q,M,X]}function t(w,k,A,P,I,O,x){var D=Math.PI,L=x*D/180,N=r.util.sin(L),j=r.util.cos(L),V=0,G=0;A=Math.abs(A),P=Math.abs(P);var J=-j*w*.5-N*k*.5,B=-j*k*.5+N*w*.5,M=A*A,X=P*P,Y=B*B,H=J*J,U=M*X-M*Y-X*H,Q=0;if(U<0){var st=Math.sqrt(1-U/(M*X));A*=st,P*=st}else Q=(I===O?-1:1)*Math.sqrt(U/(M*Y+X*H));var nt=Q*A*B/P,W=-Q*P*J/A,rt=j*nt-N*W+w*.5,ot=N*nt+j*W+k*.5,lt=n(1,0,(J-nt)/A,(B-W)/P),ut=n((J-nt)/A,(B-W)/P,(-J-nt)/A,(-B-W)/P);O===0&&ut>0?ut-=2*D:O===1&&ut<0&&(ut+=2*D);for(var ht=Math.ceil(Math.abs(ut/D*2)),bt=[],dt=ut/ht,zt=8/3*Math.sin(dt/4)*Math.sin(dt/4)/Math.sin(dt/2),le=lt+dt,kt=0;kt<ht;kt++)bt[kt]=a(lt,le,j,N,A,P,rt,ot,zt,V,G),V=bt[kt][5],G=bt[kt][6],lt=le,le+=dt;return bt}function n(w,k,A,P){var I=Math.atan2(k,w),O=Math.atan2(P,A);return O>=I?O-I:2*Math.PI-(I-O)}function e(w,k,A,P,I,O,x,D){var L;if(r.cachesBoundsOfCurve&&(L=c.call(arguments),r.boundsOfCurveCache[L]))return r.boundsOfCurveCache[L];var N=Math.sqrt,j=Math.min,V=Math.max,G=Math.abs,J=[],B=[[],[]],M,X,Y,H,U,Q,st,nt;X=6*w-12*A+6*I,M=-3*w+9*A-9*I+3*x,Y=3*A-3*w;for(var W=0;W<2;++W){if(W>0&&(X=6*k-12*P+6*O,M=-3*k+9*P-9*O+3*D,Y=3*P-3*k),G(M)<1e-12){if(G(X)<1e-12)continue;H=-Y/X,0<H&&H<1&&J.push(H);continue}st=X*X-4*Y*M,!(st<0)&&(nt=N(st),U=(-X+nt)/(2*M),0<U&&U<1&&J.push(U),Q=(-X-nt)/(2*M),0<Q&&Q<1&&J.push(Q))}for(var rt,ot,lt=J.length,ut=lt,ht;lt--;)H=J[lt],ht=1-H,rt=ht*ht*ht*w+3*ht*ht*H*A+3*ht*H*H*I+H*H*H*x,B[0][lt]=rt,ot=ht*ht*ht*k+3*ht*ht*H*P+3*ht*H*H*O+H*H*H*D,B[1][lt]=ot;B[0][ut]=w,B[1][ut]=k,B[0][ut+1]=x,B[1][ut+1]=D;var bt=[{x:j.apply(null,B[0]),y:j.apply(null,B[1])},{x:V.apply(null,B[0]),y:V.apply(null,B[1])}];return r.cachesBoundsOfCurve&&(r.boundsOfCurveCache[L]=bt),bt}function o(w,k,A){for(var P=A[1],I=A[2],O=A[3],x=A[4],D=A[5],L=A[6],N=A[7],j=t(L-w,N-k,P,I,x,D,O),V=0,G=j.length;V<G;V++)j[V][1]+=w,j[V][2]+=k,j[V][3]+=w,j[V][4]+=k,j[V][5]+=w,j[V][6]+=k;return j}function h(w){var k=0,A=0,P=w.length,I=0,O=0,x,D,L,N=[],j,V,G;for(D=0;D<P;++D){switch(L=!1,x=w[D].slice(0),x[0]){case"l":x[0]="L",x[1]+=k,x[2]+=A;case"L":k=x[1],A=x[2];break;case"h":x[1]+=k;case"H":x[0]="L",x[2]=A,k=x[1];break;case"v":x[1]+=A;case"V":x[0]="L",A=x[1],x[1]=k,x[2]=A;break;case"m":x[0]="M",x[1]+=k,x[2]+=A;case"M":k=x[1],A=x[2],I=x[1],O=x[2];break;case"c":x[0]="C",x[1]+=k,x[2]+=A,x[3]+=k,x[4]+=A,x[5]+=k,x[6]+=A;case"C":V=x[3],G=x[4],k=x[5],A=x[6];break;case"s":x[0]="S",x[1]+=k,x[2]+=A,x[3]+=k,x[4]+=A;case"S":j==="C"?(V=2*k-V,G=2*A-G):(V=k,G=A),k=x[3],A=x[4],x[0]="C",x[5]=x[3],x[6]=x[4],x[3]=x[1],x[4]=x[2],x[1]=V,x[2]=G,V=x[3],G=x[4];break;case"q":x[0]="Q",x[1]+=k,x[2]+=A,x[3]+=k,x[4]+=A;case"Q":V=x[1],G=x[2],k=x[3],A=x[4];break;case"t":x[0]="T",x[1]+=k,x[2]+=A;case"T":j==="Q"?(V=2*k-V,G=2*A-G):(V=k,G=A),x[0]="Q",k=x[1],A=x[2],x[1]=V,x[2]=G,x[3]=k,x[4]=A;break;case"a":x[0]="A",x[6]+=k,x[7]+=A;case"A":L=!0,N=N.concat(o(k,A,x)),k=x[6],A=x[7];break;case"z":case"Z":k=I,A=O;break}L||N.push(x),j=x[0]}return N}function s(w,k,A,P){return Math.sqrt((A-w)*(A-w)+(P-k)*(P-k))}function u(w){return w*w*w}function d(w){return 3*w*w*(1-w)}function m(w){return 3*w*(1-w)*(1-w)}function g(w){return(1-w)*(1-w)*(1-w)}function v(w,k,A,P,I,O,x,D){return function(L){var N=u(L),j=d(L),V=m(L),G=g(L);return{x:x*N+I*j+A*V+w*G,y:D*N+O*j+P*V+k*G}}}function b(w,k,A,P,I,O,x,D){return function(L){var N=1-L,j=3*N*N*(A-w)+6*N*L*(I-A)+3*L*L*(x-I),V=3*N*N*(P-k)+6*N*L*(O-P)+3*L*L*(D-O);return Math.atan2(V,j)}}function S(w){return w*w}function E(w){return 2*w*(1-w)}function F(w){return(1-w)*(1-w)}function R(w,k,A,P,I,O){return function(x){var D=S(x),L=E(x),N=F(x);return{x:I*D+A*L+w*N,y:O*D+P*L+k*N}}}function z(w,k,A,P,I,O){return function(x){var D=1-x,L=2*D*(A-w)+2*x*(I-A),N=2*D*(P-k)+2*x*(O-P);return Math.atan2(N,L)}}function q(w,k,A){var P={x:k,y:A},I,O=0,x;for(x=1;x<=100;x+=1)I=w(x/100),O+=s(P.x,P.y,I.x,I.y),P=I;return O}function Z(w,k){for(var A=0,P=0,I=w.iterator,O={x:w.x,y:w.y},x,D,L=.01,N=w.angleFinder,j;P<k&&L>1e-4;)x=I(A),j=A,D=s(O.x,O.y,x.x,x.y),D+P>k?(A-=L,L/=2):(O=x,A+=L,P+=D);return x.angle=N(j),x}function K(w){for(var k=0,A=w.length,P,I=0,O=0,x=0,D=0,L=[],N,j,V,G=0;G<A;G++){switch(P=w[G],j={x:I,y:O,command:P[0]},P[0]){case"M":j.length=0,x=I=P[1],D=O=P[2];break;case"L":j.length=s(I,O,P[1],P[2]),I=P[1],O=P[2];break;case"C":N=v(I,O,P[1],P[2],P[3],P[4],P[5],P[6]),V=b(I,O,P[1],P[2],P[3],P[4],P[5],P[6]),j.iterator=N,j.angleFinder=V,j.length=q(N,I,O),I=P[5],O=P[6];break;case"Q":N=R(I,O,P[1],P[2],P[3],P[4]),V=z(I,O,P[1],P[2],P[3],P[4]),j.iterator=N,j.angleFinder=V,j.length=q(N,I,O),I=P[3],O=P[4];break;case"Z":case"z":j.destX=x,j.destY=D,j.length=s(I,O,x,D),I=x,O=D;break}k+=j.length,L.push(j)}return L.push({length:k,x:I,y:O}),L}function $(w,k,A){A||(A=K(w));for(var P=0;k-A[P].length>0&&P<A.length-2;)k-=A[P].length,P++;var I=A[P],O=k/I.length,x=I.command,D=w[P],L;switch(x){case"M":return{x:I.x,y:I.y,angle:0};case"Z":case"z":return L=new r.Point(I.x,I.y).lerp(new r.Point(I.destX,I.destY),O),L.angle=Math.atan2(I.destY-I.y,I.destX-I.x),L;case"L":return L=new r.Point(I.x,I.y).lerp(new r.Point(D[1],D[2]),O),L.angle=Math.atan2(D[2]-I.y,D[1]-I.x),L;case"C":return Z(I,k);case"Q":return Z(I,k)}}function tt(w){var k=[],A=[],P,I,O=r.rePathCommand,x="[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?\\s*",D="("+x+")"+r.commaWsp,L="([01])"+r.commaWsp+"?",N=D+"?"+D+"?"+D+L+L+D+"?("+x+")",j=new RegExp(N,"g"),V,G,J;if(!w||!w.match)return k;J=w.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi);for(var B=0,M,X=J.length;B<X;B++){P=J[B],G=P.slice(1).trim(),A.length=0;var Y=P.charAt(0);if(M=[Y],Y.toLowerCase()==="a")for(var H;H=j.exec(G);)for(var U=1;U<H.length;U++)A.push(H[U]);else for(;V=O.exec(G);)A.push(V[0]);for(var U=0,Q=A.length;U<Q;U++)I=parseFloat(A[U]),isNaN(I)||M.push(I);var st=i[Y.toLowerCase()],nt=l[Y]||Y;if(M.length-1>st)for(var W=1,rt=M.length;W<rt;W+=st)k.push([Y].concat(M.slice(W,W+st))),Y=nt;else k.push(M)}return k}function it(w,k){var A=[],P,I=new r.Point(w[0].x,w[0].y),O=new r.Point(w[1].x,w[1].y),x=w.length,D=1,L=0,N=x>2;for(k=k||0,N&&(D=w[2].x<O.x?-1:w[2].x===O.x?0:1,L=w[2].y<O.y?-1:w[2].y===O.y?0:1),A.push(["M",I.x-D*k,I.y-L*k]),P=1;P<x;P++){if(!I.eq(O)){var j=I.midPointFrom(O);A.push(["Q",I.x,I.y,j.x,j.y])}I=w[P],P+1<w.length&&(O=w[P+1])}return N&&(D=I.x>w[P-2].x?1:I.x===w[P-2].x?0:-1,L=I.y>w[P-2].y?1:I.y===w[P-2].y?0:-1),A.push(["L",I.x+D*k,I.y+L*k]),A}function et(w,k,A){return A&&(k=r.util.multiplyTransformMatrices(k,[1,0,0,1,-A.x,-A.y])),w.map(function(P){for(var I=P.slice(0),O={},x=1;x<P.length-1;x+=2)O.x=P[x],O.y=P[x+1],O=r.util.transformPoint(O,k),I[x]=O.x,I[x+1]=O.y;return I})}r.util.joinPath=function(w){return w.map(function(k){return k.join(" ")}).join(" ")},r.util.parsePath=tt,r.util.makePathSimpler=h,r.util.getSmoothPathFromPoints=it,r.util.getPathSegmentsInfo=K,r.util.getBoundsOfCurve=e,r.util.getPointOnPath=$,r.util.transformPath=et})(),(function(){var c=Array.prototype.slice;function i(e,o){for(var h=c.call(arguments,2),s=[],u=0,d=e.length;u<d;u++)s[u]=h.length?e[u][o].apply(e[u],h):e[u][o].call(e[u]);return s}function l(e,o){return n(e,o,function(h,s){return h>=s})}function a(e,o){return n(e,o,function(h,s){return h<s})}function t(e,o){for(var h=e.length;h--;)e[h]=o;return e}function n(e,o,h){if(!(!e||e.length===0)){var s=e.length-1,u=o?e[s][o]:e[s];if(o)for(;s--;)h(e[s][o],u)&&(u=e[s][o]);else for(;s--;)h(e[s],u)&&(u=e[s]);return u}}r.util.array={fill:t,invoke:i,min:a,max:l}})(),(function(){function c(l,a,t){if(t)if(!r.isLikelyNode&&a instanceof Element)l=a;else if(a instanceof Array){l=[];for(var n=0,e=a.length;n<e;n++)l[n]=c({},a[n],t)}else if(a&&typeof a=="object")for(var o in a)o==="canvas"||o==="group"?l[o]=null:a.hasOwnProperty(o)&&(l[o]=c({},a[o],t));else l=a;else for(var o in a)l[o]=a[o];return l}function i(l,a){return c({},l,a)}r.util.object={extend:c,clone:i},r.util.object.extend(r.util,r.Observable)})(),(function(){function c(n){return n.replace(/-+(.)?/g,function(e,o){return o?o.toUpperCase():""})}function i(n,e){return n.charAt(0).toUpperCase()+(e?n.slice(1):n.slice(1).toLowerCase())}function l(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function a(n){var e=0,o,h=[];for(e=0,o;e<n.length;e++)(o=t(n,e))!==!1&&h.push(o);return h}function t(n,e){var o=n.charCodeAt(e);if(isNaN(o))return"";if(o<55296||o>57343)return n.charAt(e);if(55296<=o&&o<=56319){if(n.length<=e+1)throw"High surrogate without following low surrogate";var h=n.charCodeAt(e+1);if(56320>h||h>57343)throw"High surrogate without following low surrogate";return n.charAt(e)+n.charAt(e+1)}if(e===0)throw"Low surrogate without preceding high surrogate";var s=n.charCodeAt(e-1);if(55296>s||s>56319)throw"Low surrogate without preceding high surrogate";return!1}r.util.string={camelize:c,capitalize:i,escapeXml:l,graphemeSplit:a}})(),(function(){var c=Array.prototype.slice,i=function(){},l=(function(){for(var o in{toString:1})if(o==="toString")return!1;return!0})(),a=function(o,h,s){for(var u in h)u in o.prototype&&typeof o.prototype[u]=="function"&&(h[u]+"").indexOf("callSuper")>-1?o.prototype[u]=(function(d){return function(){var m=this.constructor.superclass;this.constructor.superclass=s;var g=h[d].apply(this,arguments);if(this.constructor.superclass=m,d!=="initialize")return g}})(u):o.prototype[u]=h[u],l&&(h.toString!==Object.prototype.toString&&(o.prototype.toString=h.toString),h.valueOf!==Object.prototype.valueOf&&(o.prototype.valueOf=h.valueOf))};function t(){}function n(o){for(var h=null,s=this;s.constructor.superclass;){var u=s.constructor.superclass.prototype[o];if(s[o]!==u){h=u;break}s=s.constructor.superclass.prototype}return h?arguments.length>1?h.apply(this,c.call(arguments,1)):h.call(this):console.log("tried to callSuper "+o+", method not found in prototype chain",this)}function e(){var o=null,h=c.call(arguments,0);typeof h[0]=="function"&&(o=h.shift());function s(){this.initialize.apply(this,arguments)}s.superclass=o,s.subclasses=[],o&&(t.prototype=o.prototype,s.prototype=new t,o.subclasses.push(s));for(var u=0,d=h.length;u<d;u++)a(s,h[u],o);return s.prototype.initialize||(s.prototype.initialize=i),s.prototype.constructor=s,s.prototype.callSuper=n,s}r.util.createClass=e})(),(function(){var c=!!r.document.createElement("div").attachEvent,i=["touchstart","touchmove","touchend"];r.util.addListener=function(a,t,n,e){a&&a.addEventListener(t,n,c?!1:e)},r.util.removeListener=function(a,t,n,e){a&&a.removeEventListener(t,n,c?!1:e)};function l(a){var t=a.changedTouches;return t&&t[0]?t[0]:a}r.util.getPointer=function(a){var t=a.target,n=r.util.getScrollLeftTop(t),e=l(a);return{x:e.clientX+n.left,y:e.clientY+n.top}},r.util.isTouchEvent=function(a){return i.indexOf(a.type)>-1||a.pointerType==="touch"}})(),(function(){function c(e,o){var h=e.style;if(!h)return e;if(typeof o=="string")return e.style.cssText+=";"+o,o.indexOf("opacity")>-1?n(e,o.match(/opacity:\s*(\d?\.?\d*)/)[1]):e;for(var s in o)if(s==="opacity")n(e,o[s]);else{var u=s==="float"||s==="cssFloat"?typeof h.styleFloat>"u"?"cssFloat":"styleFloat":s;h.setProperty(u,o[s])}return e}var i=r.document.createElement("div"),l=typeof i.style.opacity=="string",a=typeof i.style.filter=="string",t=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,n=function(e){return e};l?n=function(e,o){return e.style.opacity=o,e}:a&&(n=function(e,o){var h=e.style;return e.currentStyle&&!e.currentStyle.hasLayout&&(h.zoom=1),t.test(h.filter)?(o=o>=.9999?"":"alpha(opacity="+o*100+")",h.filter=h.filter.replace(t,o)):h.filter+=" alpha(opacity="+o*100+")",e}),r.util.setStyle=c})(),(function(){var c=Array.prototype.slice;function i(g){return typeof g=="string"?r.document.getElementById(g):g}var l,a=function(g){return c.call(g,0)};try{l=a(r.document.childNodes)instanceof Array}catch{}l||(a=function(g){for(var v=new Array(g.length),b=g.length;b--;)v[b]=g[b];return v});function t(g,v){var b=r.document.createElement(g);for(var S in v)S==="class"?b.className=v[S]:S==="for"?b.htmlFor=v[S]:b.setAttribute(S,v[S]);return b}function n(g,v){g&&(" "+g.className+" ").indexOf(" "+v+" ")===-1&&(g.className+=(g.className?" ":"")+v)}function e(g,v,b){return typeof v=="string"&&(v=t(v,b)),g.parentNode&&g.parentNode.replaceChild(v,g),v.appendChild(g),v}function o(g){for(var v=0,b=0,S=r.document.documentElement,E=r.document.body||{scrollLeft:0,scrollTop:0};g&&(g.parentNode||g.host)&&(g=g.parentNode||g.host,g===r.document?(v=E.scrollLeft||S.scrollLeft||0,b=E.scrollTop||S.scrollTop||0):(v+=g.scrollLeft||0,b+=g.scrollTop||0),!(g.nodeType===1&&g.style.position==="fixed")););return{left:v,top:b}}function h(g){var v,b=g&&g.ownerDocument,S={left:0,top:0},E={left:0,top:0},F,R={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!b)return E;for(var z in R)E[R[z]]+=parseInt(s(g,z),10)||0;return v=b.documentElement,typeof g.getBoundingClientRect<"u"&&(S=g.getBoundingClientRect()),F=o(g),{left:S.left+F.left-(v.clientLeft||0)+E.left,top:S.top+F.top-(v.clientTop||0)+E.top}}var s;r.document.defaultView&&r.document.defaultView.getComputedStyle?s=function(g,v){var b=r.document.defaultView.getComputedStyle(g,null);return b?b[v]:void 0}:s=function(g,v){var b=g.style[v];return!b&&g.currentStyle&&(b=g.currentStyle[v]),b},(function(){var g=r.document.documentElement.style,v="userSelect"in g?"userSelect":"MozUserSelect"in g?"MozUserSelect":"WebkitUserSelect"in g?"WebkitUserSelect":"KhtmlUserSelect"in g?"KhtmlUserSelect":"";function b(E){return typeof E.onselectstart<"u"&&(E.onselectstart=r.util.falseFunction),v?E.style[v]="none":typeof E.unselectable=="string"&&(E.unselectable="on"),E}function S(E){return typeof E.onselectstart<"u"&&(E.onselectstart=null),v?E.style[v]="":typeof E.unselectable=="string"&&(E.unselectable=""),E}r.util.makeElementUnselectable=b,r.util.makeElementSelectable=S})();function u(g){var v=r.jsdomImplForWrapper(g);return v._canvas||v._image}function d(g){if(r.isLikelyNode){var v=r.jsdomImplForWrapper(g);v&&(v._image=null,v._canvas=null,v._currentSrc=null,v._attributes=null,v._classList=null)}}function m(g,v){g.imageSmoothingEnabled=g.imageSmoothingEnabled||g.webkitImageSmoothingEnabled||g.mozImageSmoothingEnabled||g.msImageSmoothingEnabled||g.oImageSmoothingEnabled,g.imageSmoothingEnabled=v}r.util.setImageSmoothing=m,r.util.getById=i,r.util.toArray=a,r.util.addClass=n,r.util.makeElement=t,r.util.wrapElement=e,r.util.getScrollLeftTop=o,r.util.getElementOffset=h,r.util.getNodeCanvas=u,r.util.cleanUpJsdomNode=d})(),(function(){function c(a,t){return a+(/\?/.test(a)?"&":"?")+t}function i(){}function l(a,t){t||(t={});var n=t.method?t.method.toUpperCase():"GET",e=t.onComplete||function(){},o=new r.window.XMLHttpRequest,h=t.body||t.parameters;return o.onreadystatechange=function(){o.readyState===4&&(e(o),o.onreadystatechange=i)},n==="GET"&&(h=null,typeof t.parameters=="string"&&(a=c(a,t.parameters))),o.open(n,a,!0),(n==="POST"||n==="PUT")&&o.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),o.send(h),o}r.util.request=l})(),r.log=console.log,r.warn=console.warn,(function(){var c=r.util.object.extend,i=r.util.object.clone,l=[];r.util.object.extend(l,{cancelAll:function(){var u=this.splice(0);return u.forEach(function(d){d.cancel()}),u},cancelByCanvas:function(u){if(!u)return[];var d=this.filter(function(m){return typeof m.target=="object"&&m.target.canvas===u});return d.forEach(function(m){m.cancel()}),d},cancelByTarget:function(u){var d=this.findAnimationsByTarget(u);return d.forEach(function(m){m.cancel()}),d},findAnimationIndex:function(u){return this.indexOf(this.findAnimation(u))},findAnimation:function(u){return this.find(function(d){return d.cancel===u})},findAnimationsByTarget:function(u){return u?this.filter(function(d){return d.target===u}):[]}});function a(){return!1}function t(u,d,m,g){return-m*Math.cos(u/g*(Math.PI/2))+m+d}function n(u){u||(u={});var d=!1,m,g=function(){var v=r.runningAnimations.indexOf(m);return v>-1&&r.runningAnimations.splice(v,1)[0]};return m=c(i(u),{cancel:function(){return d=!0,g()},currentValue:"startValue"in u?u.startValue:0,completionRate:0,durationRate:0}),r.runningAnimations.push(m),h(function(v){var b=v||+new Date,S=u.duration||500,E=b+S,F,R=u.onChange||a,z=u.abort||a,q=u.onComplete||a,Z=u.easing||t,K="startValue"in u?u.startValue.length>0:!1,$="startValue"in u?u.startValue:0,tt="endValue"in u?u.endValue:100,it=u.byValue||(K?$.map(function(et,w){return tt[w]-$[w]}):tt-$);u.onStart&&u.onStart(),(function et(w){F=w||+new Date;var k=F>E?S:F-b,A=k/S,P=K?$.map(function(O,x){return Z(k,$[x],it[x],S)}):Z(k,$,it,S),I=Math.abs(K?(P[0]-$[0])/it[0]:(P-$)/it);if(m.currentValue=K?P.slice():P,m.completionRate=I,m.durationRate=A,!d){if(z(P,I,A)){g();return}if(F>E){m.currentValue=K?tt.slice():tt,m.completionRate=1,m.durationRate=1,R(K?tt.slice():tt,1,1),q(tt,1,1),g();return}else R(P,I,A),h(et)}})(b)}),m.cancel}var e=r.window.requestAnimationFrame||r.window.webkitRequestAnimationFrame||r.window.mozRequestAnimationFrame||r.window.oRequestAnimationFrame||r.window.msRequestAnimationFrame||function(u){return r.window.setTimeout(u,1e3/60)},o=r.window.cancelAnimationFrame||r.window.clearTimeout;function h(){return e.apply(r.window,arguments)}function s(){return o.apply(r.window,arguments)}r.util.animate=n,r.util.requestAnimFrame=h,r.util.cancelAnimFrame=s,r.runningAnimations=l})(),(function(){function c(l,a,t){var n="rgba("+parseInt(l[0]+t*(a[0]-l[0]),10)+","+parseInt(l[1]+t*(a[1]-l[1]),10)+","+parseInt(l[2]+t*(a[2]-l[2]),10);return n+=","+(l&&a?parseFloat(l[3]+t*(a[3]-l[3])):1),n+=")",n}function i(l,a,t,n){var e=new r.Color(l).getSource(),o=new r.Color(a).getSource(),h=n.onComplete,s=n.onChange;return n=n||{},r.util.animate(r.util.object.extend(n,{duration:t||500,startValue:e,endValue:o,byValue:o,easing:function(u,d,m,g){var v=n.colorEasing?n.colorEasing(u,g):1-Math.cos(u/g*(Math.PI/2));return c(d,m,v)},onComplete:function(u,d,m){if(h)return h(c(o,o,0),d,m)},onChange:function(u,d,m){if(s){if(Array.isArray(u))return s(c(u,u,0),d,m);s(u,d,m)}}}))}r.util.animateColor=i})(),(function(){function c(w,k,A,P){return w<Math.abs(k)?(w=k,P=A/4):k===0&&w===0?P=A/(2*Math.PI)*Math.asin(1):P=A/(2*Math.PI)*Math.asin(k/w),{a:w,c:k,p:A,s:P}}function i(w,k,A){return w.a*Math.pow(2,10*(k-=1))*Math.sin((k*A-w.s)*(2*Math.PI)/w.p)}function l(w,k,A,P){return A*((w=w/P-1)*w*w+1)+k}function a(w,k,A,P){return w/=P/2,w<1?A/2*w*w*w+k:A/2*((w-=2)*w*w+2)+k}function t(w,k,A,P){return A*(w/=P)*w*w*w+k}function n(w,k,A,P){return-A*((w=w/P-1)*w*w*w-1)+k}function e(w,k,A,P){return w/=P/2,w<1?A/2*w*w*w*w+k:-A/2*((w-=2)*w*w*w-2)+k}function o(w,k,A,P){return A*(w/=P)*w*w*w*w+k}function h(w,k,A,P){return A*((w=w/P-1)*w*w*w*w+1)+k}function s(w,k,A,P){return w/=P/2,w<1?A/2*w*w*w*w*w+k:A/2*((w-=2)*w*w*w*w+2)+k}function u(w,k,A,P){return-A*Math.cos(w/P*(Math.PI/2))+A+k}function d(w,k,A,P){return A*Math.sin(w/P*(Math.PI/2))+k}function m(w,k,A,P){return-A/2*(Math.cos(Math.PI*w/P)-1)+k}function g(w,k,A,P){return w===0?k:A*Math.pow(2,10*(w/P-1))+k}function v(w,k,A,P){return w===P?k+A:A*(-Math.pow(2,-10*w/P)+1)+k}function b(w,k,A,P){return w===0?k:w===P?k+A:(w/=P/2,w<1?A/2*Math.pow(2,10*(w-1))+k:A/2*(-Math.pow(2,-10*--w)+2)+k)}function S(w,k,A,P){return-A*(Math.sqrt(1-(w/=P)*w)-1)+k}function E(w,k,A,P){return A*Math.sqrt(1-(w=w/P-1)*w)+k}function F(w,k,A,P){return w/=P/2,w<1?-A/2*(Math.sqrt(1-w*w)-1)+k:A/2*(Math.sqrt(1-(w-=2)*w)+1)+k}function R(w,k,A,P){var I=1.70158,O=0,x=A;if(w===0)return k;if(w/=P,w===1)return k+A;O||(O=P*.3);var D=c(x,A,O,I);return-i(D,w,P)+k}function z(w,k,A,P){var I=1.70158,O=0,x=A;if(w===0)return k;if(w/=P,w===1)return k+A;O||(O=P*.3);var D=c(x,A,O,I);return D.a*Math.pow(2,-10*w)*Math.sin((w*P-D.s)*(2*Math.PI)/D.p)+D.c+k}function q(w,k,A,P){var I=1.70158,O=0,x=A;if(w===0)return k;if(w/=P/2,w===2)return k+A;O||(O=P*(.3*1.5));var D=c(x,A,O,I);return w<1?-.5*i(D,w,P)+k:D.a*Math.pow(2,-10*(w-=1))*Math.sin((w*P-D.s)*(2*Math.PI)/D.p)*.5+D.c+k}function Z(w,k,A,P,I){return I===void 0&&(I=1.70158),A*(w/=P)*w*((I+1)*w-I)+k}function K(w,k,A,P,I){return I===void 0&&(I=1.70158),A*((w=w/P-1)*w*((I+1)*w+I)+1)+k}function $(w,k,A,P,I){return I===void 0&&(I=1.70158),w/=P/2,w<1?A/2*(w*w*(((I*=1.525)+1)*w-I))+k:A/2*((w-=2)*w*(((I*=1.525)+1)*w+I)+2)+k}function tt(w,k,A,P){return A-it(P-w,0,A,P)+k}function it(w,k,A,P){return(w/=P)<1/2.75?A*(7.5625*w*w)+k:w<2/2.75?A*(7.5625*(w-=1.5/2.75)*w+.75)+k:w<2.5/2.75?A*(7.5625*(w-=2.25/2.75)*w+.9375)+k:A*(7.5625*(w-=2.625/2.75)*w+.984375)+k}function et(w,k,A,P){return w<P/2?tt(w*2,0,A,P)*.5+k:it(w*2-P,0,A,P)*.5+A*.5+k}r.util.ease={easeInQuad:function(w,k,A,P){return A*(w/=P)*w+k},easeOutQuad:function(w,k,A,P){return-A*(w/=P)*(w-2)+k},easeInOutQuad:function(w,k,A,P){return w/=P/2,w<1?A/2*w*w+k:-A/2*(--w*(w-2)-1)+k},easeInCubic:function(w,k,A,P){return A*(w/=P)*w*w+k},easeOutCubic:l,easeInOutCubic:a,easeInQuart:t,easeOutQuart:n,easeInOutQuart:e,easeInQuint:o,easeOutQuint:h,easeInOutQuint:s,easeInSine:u,easeOutSine:d,easeInOutSine:m,easeInExpo:g,easeOutExpo:v,easeInOutExpo:b,easeInCirc:S,easeOutCirc:E,easeInOutCirc:F,easeInElastic:R,easeOutElastic:z,easeInOutElastic:q,easeInBack:Z,easeOutBack:K,easeInOutBack:$,easeInBounce:tt,easeOutBounce:it,easeInOutBounce:et}})(),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.object.extend,a=i.util.object.clone,t=i.util.toFixed,n=i.util.parseUnit,e=i.util.multiplyTransformMatrices,o=["path","circle","polygon","polyline","ellipse","rect","line","image","text"],h=["symbol","image","marker","pattern","view","svg"],s=["pattern","defs","symbol","metadata","clipPath","mask","desc"],u=["symbol","g","a","svg","clipPath","defs"],d={cx:"left",x:"left",r:"radius",cy:"top",y:"top",display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing"},m={stroke:"strokeOpacity",fill:"fillOpacity"},g="font-size",v="clip-path";i.svgValidTagNamesRegEx=E(o),i.svgViewBoxElementsRegEx=E(h),i.svgInvalidAncestorsRegEx=E(s),i.svgValidParentsRegEx=E(u),i.cssRules={},i.gradientDefs={},i.clipPaths={};function b(O){return O in d?d[O]:O}function S(O,x,D,L){var N=Array.isArray(x),j;if((O==="fill"||O==="stroke")&&x==="none")x="";else{if(O==="strokeUniform")return x==="non-scaling-stroke";if(O==="strokeDashArray")x==="none"?x=null:x=x.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(O==="transformMatrix")D&&D.transformMatrix?x=e(D.transformMatrix,i.parseTransformAttribute(x)):x=i.parseTransformAttribute(x);else if(O==="visible")x=x!=="none"&&x!=="hidden",D&&D.visible===!1&&(x=!1);else if(O==="opacity")x=parseFloat(x),D&&typeof D.opacity<"u"&&(x*=D.opacity);else if(O==="textAnchor")x=x==="start"?"left":x==="end"?"right":"center";else if(O==="charSpacing")j=n(x,L)/L*1e3;else if(O==="paintFirst"){var V=x.indexOf("fill"),G=x.indexOf("stroke"),x="fill";(V>-1&&G>-1&&G<V||V===-1&&G>-1)&&(x="stroke")}else{if(O==="href"||O==="xlink:href"||O==="font")return x;if(O==="imageSmoothing")return x==="optimizeQuality";j=N?x.map(n):n(x,L)}}return!N&&isNaN(j)?x:j}function E(O){return new RegExp("^("+O.join("|")+")\\b","i")}function F(O){for(var x in m)if(!(typeof O[m[x]]>"u"||O[x]==="")){if(typeof O[x]>"u"){if(!i.Object.prototype[x])continue;O[x]=i.Object.prototype[x]}if(O[x].indexOf("url(")!==0){var D=new i.Color(O[x]);O[x]=D.setAlpha(t(D.getAlpha()*O[m[x]],2)).toRgba()}}return O}function R(O,x){var D,L=[],N,j,V;for(j=0,V=x.length;j<V;j++)D=x[j],N=O.getElementsByTagName(D),L=L.concat(Array.prototype.slice.call(N));return L}i.parseTransformAttribute=(function(){function O(W,rt){var ot=i.util.cos(rt[0]),lt=i.util.sin(rt[0]),ut=0,ht=0;rt.length===3&&(ut=rt[1],ht=rt[2]),W[0]=ot,W[1]=lt,W[2]=-lt,W[3]=ot,W[4]=ut-(ot*ut-lt*ht),W[5]=ht-(lt*ut+ot*ht)}function x(W,rt){var ot=rt[0],lt=rt.length===2?rt[1]:rt[0];W[0]=ot,W[3]=lt}function D(W,rt,ot){W[ot]=Math.tan(i.util.degreesToRadians(rt[0]))}function L(W,rt){W[4]=rt[0],rt.length===2&&(W[5]=rt[1])}var N=i.iMatrix,j=i.reNum,V=i.commaWsp,G="(?:(skewX)\\s*\\(\\s*("+j+")\\s*\\))",J="(?:(skewY)\\s*\\(\\s*("+j+")\\s*\\))",B="(?:(rotate)\\s*\\(\\s*("+j+")(?:"+V+"("+j+")"+V+"("+j+"))?\\s*\\))",M="(?:(scale)\\s*\\(\\s*("+j+")(?:"+V+"("+j+"))?\\s*\\))",X="(?:(translate)\\s*\\(\\s*("+j+")(?:"+V+"("+j+"))?\\s*\\))",Y="(?:(matrix)\\s*\\(\\s*("+j+")"+V+"("+j+")"+V+"("+j+")"+V+"("+j+")"+V+"("+j+")"+V+"("+j+")\\s*\\))",H="(?:"+Y+"|"+X+"|"+M+"|"+B+"|"+G+"|"+J+")",U="(?:"+H+"(?:"+V+"*"+H+")*)",Q="^\\s*(?:"+U+"?)\\s*$",st=new RegExp(Q),nt=new RegExp(H,"g");return function(W){var rt=N.concat(),ot=[];if(!W||W&&!st.test(W))return rt;W.replace(nt,function(ut){var ht=new RegExp(H).exec(ut).filter(function(zt){return!!zt}),bt=ht[1],dt=ht.slice(2).map(parseFloat);switch(bt){case"translate":L(rt,dt);break;case"rotate":dt[0]=i.util.degreesToRadians(dt[0]),O(rt,dt);break;case"scale":x(rt,dt);break;case"skewX":D(rt,dt,2);break;case"skewY":D(rt,dt,1);break;case"matrix":rt=dt;break}ot.push(rt.concat()),rt=N.concat()});for(var lt=ot[0];ot.length>1;)ot.shift(),lt=i.util.multiplyTransformMatrices(lt,ot[0]);return lt}})();function z(O,x){var D,L;O.replace(/;\s*$/,"").split(";").forEach(function(N){var j=N.split(":");D=j[0].trim().toLowerCase(),L=j[1].trim(),x[D]=L})}function q(O,x){var D,L;for(var N in O)typeof O[N]>"u"||(D=N.toLowerCase(),L=O[N],x[D]=L)}function Z(O,x){var D={};for(var L in i.cssRules[x])if(K(O,L.split(" ")))for(var N in i.cssRules[x][L])D[N]=i.cssRules[x][L][N];return D}function K(O,x){var D,L=!0;return D=tt(O,x.pop()),D&&x.length&&(L=$(O,x)),D&&L&&x.length===0}function $(O,x){for(var D,L=!0;O.parentNode&&O.parentNode.nodeType===1&&x.length;)L&&(D=x.pop()),O=O.parentNode,L=tt(O,D);return x.length===0}function tt(O,x){var D=O.nodeName,L=O.getAttribute("class"),N=O.getAttribute("id"),j,V;if(j=new RegExp("^"+D,"i"),x=x.replace(j,""),N&&x.length&&(j=new RegExp("#"+N+"(?![a-zA-Z\\-]+)","i"),x=x.replace(j,"")),L&&x.length)for(L=L.split(" "),V=L.length;V--;)j=new RegExp("\\."+L[V]+"(?![a-zA-Z\\-]+)","i"),x=x.replace(j,"");return x.length===0}function it(O,x){var D;if(O.getElementById&&(D=O.getElementById(x)),D)return D;var L,N,j,V=O.getElementsByTagName("*");for(N=0,j=V.length;N<j;N++)if(L=V[N],x===L.getAttribute("id"))return L}function et(O){for(var x=R(O,["use","svg:use"]),D=0;x.length&&D<x.length;){var L=x[D],N=L.getAttribute("xlink:href")||L.getAttribute("href");if(N===null)return;var j=N.slice(1),V=L.getAttribute("x")||0,G=L.getAttribute("y")||0,J=it(O,j).cloneNode(!0),B=(J.getAttribute("transform")||"")+" translate("+V+", "+G+")",M,X=x.length,Y,H,U,Q,st=i.svgNS;if(k(J),/^svg$/i.test(J.nodeName)){var nt=J.ownerDocument.createElementNS(st,"g");for(H=0,U=J.attributes,Q=U.length;H<Q;H++)Y=U.item(H),nt.setAttributeNS(st,Y.nodeName,Y.nodeValue);for(;J.firstChild;)nt.appendChild(J.firstChild);J=nt}for(H=0,U=L.attributes,Q=U.length;H<Q;H++)Y=U.item(H),!(Y.nodeName==="x"||Y.nodeName==="y"||Y.nodeName==="xlink:href"||Y.nodeName==="href")&&(Y.nodeName==="transform"?B=Y.nodeValue+" "+B:J.setAttribute(Y.nodeName,Y.nodeValue));J.setAttribute("transform",B),J.setAttribute("instantiated_by_use","1"),J.removeAttribute("id"),M=L.parentNode,M.replaceChild(J,L),x.length===X&&D++}}var w=new RegExp("^\\s*("+i.reNum+"+)\\s*,?\\s*("+i.reNum+"+)\\s*,?\\s*("+i.reNum+"+)\\s*,?\\s*("+i.reNum+"+)\\s*$");function k(O){if(!i.svgViewBoxElementsRegEx.test(O.nodeName))return{};var x=O.getAttribute("viewBox"),D=1,L=1,N=0,j=0,V,G,J,B,M=O.getAttribute("width"),X=O.getAttribute("height"),Y=O.getAttribute("x")||0,H=O.getAttribute("y")||0,U=O.getAttribute("preserveAspectRatio")||"",Q=!x||!(x=x.match(w)),st=!M||!X||M==="100%"||X==="100%",nt=Q&&st,W={},rt="",ot=0,lt=0;if(W.width=0,W.height=0,W.toBeParsed=nt,Q&&(Y||H)&&O.parentNode&&O.parentNode.nodeName!=="#document"&&(rt=" translate("+n(Y)+" "+n(H)+") ",J=(O.getAttribute("transform")||"")+rt,O.setAttribute("transform",J),O.removeAttribute("x"),O.removeAttribute("y")),nt)return W;if(Q)return W.width=n(M),W.height=n(X),W;if(N=-parseFloat(x[1]),j=-parseFloat(x[2]),V=parseFloat(x[3]),G=parseFloat(x[4]),W.minX=N,W.minY=j,W.viewBoxWidth=V,W.viewBoxHeight=G,st?(W.width=V,W.height=G):(W.width=n(M),W.height=n(X),D=W.width/V,L=W.height/G),U=i.util.parsePreserveAspectRatioAttribute(U),U.alignX!=="none"&&(U.meetOrSlice==="meet"&&(L=D=D>L?L:D),U.meetOrSlice==="slice"&&(L=D=D>L?D:L),ot=W.width-V*D,lt=W.height-G*D,U.alignX==="Mid"&&(ot/=2),U.alignY==="Mid"&&(lt/=2),U.alignX==="Min"&&(ot=0),U.alignY==="Min"&&(lt=0)),D===1&&L===1&&N===0&&j===0&&Y===0&&H===0)return W;if((Y||H)&&O.parentNode.nodeName!=="#document"&&(rt=" translate("+n(Y)+" "+n(H)+") "),J=rt+" matrix("+D+" 0 0 "+L+" "+(N*D+ot)+" "+(j*L+lt)+") ",O.nodeName==="svg"){for(B=O.ownerDocument.createElementNS(i.svgNS,"g");O.firstChild;)B.appendChild(O.firstChild);O.appendChild(B)}else B=O,B.removeAttribute("x"),B.removeAttribute("y"),J=B.getAttribute("transform")+J;return B.setAttribute("transform",J),W}function A(O,x){for(;O&&(O=O.parentNode);)if(O.nodeName&&x.test(O.nodeName.replace("svg:",""))&&!O.getAttribute("instantiated_by_use"))return!0;return!1}i.parseSVGDocument=function(O,x,D,L){if(O){et(O);var N=i.Object.__uid++,j,V,G=k(O),J=i.util.toArray(O.getElementsByTagName("*"));if(G.crossOrigin=L&&L.crossOrigin,G.svgUid=N,J.length===0&&i.isLikelyNode){J=O.selectNodes('//*[name(.)!="svg"]');var B=[];for(j=0,V=J.length;j<V;j++)B[j]=J[j];J=B}var M=J.filter(function(Y){return k(Y),i.svgValidTagNamesRegEx.test(Y.nodeName.replace("svg:",""))&&!A(Y,i.svgInvalidAncestorsRegEx)});if(!M||M&&!M.length){x&&x([],{});return}var X={};J.filter(function(Y){return Y.nodeName.replace("svg:","")==="clipPath"}).forEach(function(Y){var H=Y.getAttribute("id");X[H]=i.util.toArray(Y.getElementsByTagName("*")).filter(function(U){return i.svgValidTagNamesRegEx.test(U.nodeName.replace("svg:",""))})}),i.gradientDefs[N]=i.getGradientDefs(O),i.cssRules[N]=i.getCSSRules(O),i.clipPaths[N]=X,i.parseElements(M,function(Y,H){x&&(x(Y,G,H,J),delete i.gradientDefs[N],delete i.cssRules[N],delete i.clipPaths[N])},a(G),D,L)}};function P(O,x){var D=["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"],L="xlink:href",N=x.getAttribute(L).slice(1),j=it(O,N);if(j&&j.getAttribute(L)&&P(O,j),D.forEach(function(G){j&&!x.hasAttribute(G)&&j.hasAttribute(G)&&x.setAttribute(G,j.getAttribute(G))}),!x.children.length)for(var V=j.cloneNode(!0);V.firstChild;)x.appendChild(V.firstChild);x.removeAttribute(L)}var I=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+i.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+i.reNum+"))?\\s+(.*)");l(i,{parseFontDeclaration:function(O,x){var D=O.match(I);if(D){var L=D[1],N=D[3],j=D[4],V=D[5],G=D[6];L&&(x.fontStyle=L),N&&(x.fontWeight=isNaN(parseFloat(N))?N:parseFloat(N)),j&&(x.fontSize=n(j)),G&&(x.fontFamily=G),V&&(x.lineHeight=V==="normal"?1:V)}},getGradientDefs:function(O){var x=["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"],D=R(O,x),L,N=0,j={};for(N=D.length;N--;)L=D[N],L.getAttribute("xlink:href")&&P(O,L),j[L.getAttribute("id")]=L;return j},parseAttributes:function(O,x,D){if(O){var L,N={},j,V;typeof D>"u"&&(D=O.getAttribute("svgUid")),O.parentNode&&i.svgValidParentsRegEx.test(O.parentNode.nodeName)&&(N=i.parseAttributes(O.parentNode,x,D));var G=x.reduce(function(U,Q){return L=O.getAttribute(Q),L&&(U[Q]=L),U},{}),J=l(Z(O,D),i.parseStyleAttribute(O));G=l(G,J),J[v]&&O.setAttribute(v,J[v]),j=V=N.fontSize||i.Text.DEFAULT_SVG_FONT_SIZE,G[g]&&(G[g]=j=n(G[g],V));var B,M,X={};for(var Y in G)B=b(Y),M=S(B,G[Y],N,j),X[B]=M;X&&X.font&&i.parseFontDeclaration(X.font,X);var H=l(N,X);return i.svgValidParentsRegEx.test(O.nodeName)?H:F(H)}},parseElements:function(O,x,D,L,N){new i.ElementsParser(O,x,D,L,N).parse()},parseStyleAttribute:function(O){var x={},D=O.getAttribute("style");return D&&(typeof D=="string"?z(D,x):q(D,x)),x},parsePointsAttribute:function(O){if(!O)return null;O=O.replace(/,/g," ").trim(),O=O.split(/\s+/);var x=[],D,L;for(D=0,L=O.length;D<L;D+=2)x.push({x:parseFloat(O[D]),y:parseFloat(O[D+1])});return x},getCSSRules:function(O){var x=O.getElementsByTagName("style"),D,L,N={},j;for(D=0,L=x.length;D<L;D++){var V=x[D].textContent;V=V.replace(/\/\*[\s\S]*?\*\//g,""),V.trim()!==""&&(j=V.split("}"),j=j.filter(function(G){return G.trim()}),j.forEach(function(G){var J=G.split("{"),B={},M=J[1].trim(),X=M.split(";").filter(function(Q){return Q.trim()});for(D=0,L=X.length;D<L;D++){var Y=X[D].split(":"),H=Y[0].trim(),U=Y[1].trim();B[H]=U}G=J[0].trim(),G.split(",").forEach(function(Q){Q=Q.replace(/^svg/i,"").trim(),Q!==""&&(N[Q]?i.util.object.extend(N[Q],B):N[Q]=i.util.object.clone(B))})}))}return N},loadSVGFromURL:function(O,x,D,L){O=O.replace(/^\n\s*/,"").trim(),new i.util.request(O,{method:"get",onComplete:N});function N(j){var V=j.responseXML;if(!V||!V.documentElement)return x&&x(null),!1;i.parseSVGDocument(V.documentElement,function(G,J,B,M){x&&x(G,J,B,M)},D,L)}},loadSVGFromString:function(O,x,D,L){var N=new i.window.DOMParser,j=N.parseFromString(O.trim(),"text/xml");i.parseSVGDocument(j.documentElement,function(V,G,J,B){x(V,G,J,B)},D,L)}})})(f),r.ElementsParser=function(c,i,l,a,t,n){this.elements=c,this.callback=i,this.options=l,this.reviver=a,this.svgUid=l&&l.svgUid||0,this.parsingOptions=t,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=n},(function(c){c.parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},c.createObjects=function(){var i=this;this.elements.forEach(function(l,a){l.setAttribute("svgUid",i.svgUid),i.createObject(l,a)})},c.findTag=function(i){return r[r.util.string.capitalize(i.tagName.replace("svg:",""))]},c.createObject=function(i,l){var a=this.findTag(i);if(a&&a.fromElement)try{a.fromElement(i,this.createCallback(l,i),this.options)}catch(t){r.log(t)}else this.checkIfDone()},c.createCallback=function(i,l){var a=this;return function(t){var n;a.resolveGradient(t,l,"fill"),a.resolveGradient(t,l,"stroke"),t instanceof r.Image&&t._originalElement&&(n=t.parsePreserveAspectRatioAttribute(l)),t._removeTransformMatrix(n),a.resolveClipPath(t,l),a.reviver&&a.reviver(l,t),a.instances[i]=t,a.checkIfDone()}},c.extractPropertyDefinition=function(i,l,a){var t=i[l],n=this.regexUrl;if(n.test(t)){n.lastIndex=0;var e=n.exec(t)[1];return n.lastIndex=0,r[a][this.svgUid][e]}},c.resolveGradient=function(i,l,a){var t=this.extractPropertyDefinition(i,a,"gradientDefs");if(t){var n=l.getAttribute(a+"-opacity"),e=r.Gradient.fromElement(t,i,n,this.options);i.set(a,e)}},c.createClipPathCallback=function(i,l){return function(a){a._removeTransformMatrix(),a.fillRule=a.clipRule,l.push(a)}},c.resolveClipPath=function(i,l){var a=this.extractPropertyDefinition(i,"clipPath","clipPaths"),t,n,e,o,h,s;if(a){o=[],e=r.util.invertTransform(i.calcTransformMatrix());for(var u=a[0].parentNode,d=l;d.parentNode&&d.getAttribute("clip-path")!==i.clipPath;)d=d.parentNode;d.parentNode.appendChild(u);for(var m=0;m<a.length;m++)t=a[m],n=this.findTag(t),n.fromElement(t,this.createClipPathCallback(i,o),this.options);o.length===1?a=o[0]:a=new r.Group(o),h=r.util.multiplyTransformMatrices(e,a.calcTransformMatrix()),a.clipPath&&this.resolveClipPath(a,d);var s=r.util.qrDecompose(h);a.flipX=!1,a.flipY=!1,a.set("scaleX",s.scaleX),a.set("scaleY",s.scaleY),a.angle=s.angle,a.skewX=s.skewX,a.skewY=0,a.setPositionByOrigin({x:s.translateX,y:s.translateY},"center","center"),i.clipPath=a}else delete i.clipPath},c.checkIfDone=function(){--this.numElements===0&&(this.instances=this.instances.filter(function(i){return i!=null}),this.callback(this.instances,this.elements))}})(r.ElementsParser.prototype),(function(c){var i=c.fabric||(c.fabric={});if(i.Point){i.warn("fabric.Point is already defined");return}i.Point=l;function l(a,t){this.x=a,this.y=t}l.prototype={type:"point",constructor:l,add:function(a){return new l(this.x+a.x,this.y+a.y)},addEquals:function(a){return this.x+=a.x,this.y+=a.y,this},scalarAdd:function(a){return new l(this.x+a,this.y+a)},scalarAddEquals:function(a){return this.x+=a,this.y+=a,this},subtract:function(a){return new l(this.x-a.x,this.y-a.y)},subtractEquals:function(a){return this.x-=a.x,this.y-=a.y,this},scalarSubtract:function(a){return new l(this.x-a,this.y-a)},scalarSubtractEquals:function(a){return this.x-=a,this.y-=a,this},multiply:function(a){return new l(this.x*a,this.y*a)},multiplyEquals:function(a){return this.x*=a,this.y*=a,this},divide:function(a){return new l(this.x/a,this.y/a)},divideEquals:function(a){return this.x/=a,this.y/=a,this},eq:function(a){return this.x===a.x&&this.y===a.y},lt:function(a){return this.x<a.x&&this.y<a.y},lte:function(a){return this.x<=a.x&&this.y<=a.y},gt:function(a){return this.x>a.x&&this.y>a.y},gte:function(a){return this.x>=a.x&&this.y>=a.y},lerp:function(a,t){return typeof t>"u"&&(t=.5),t=Math.max(Math.min(1,t),0),new l(this.x+(a.x-this.x)*t,this.y+(a.y-this.y)*t)},distanceFrom:function(a){var t=this.x-a.x,n=this.y-a.y;return Math.sqrt(t*t+n*n)},midPointFrom:function(a){return this.lerp(a)},min:function(a){return new l(Math.min(this.x,a.x),Math.min(this.y,a.y))},max:function(a){return new l(Math.max(this.x,a.x),Math.max(this.y,a.y))},toString:function(){return this.x+","+this.y},setXY:function(a,t){return this.x=a,this.y=t,this},setX:function(a){return this.x=a,this},setY:function(a){return this.y=a,this},setFromPoint:function(a){return this.x=a.x,this.y=a.y,this},swap:function(a){var t=this.x,n=this.y;this.x=a.x,this.y=a.y,a.x=t,a.y=n},clone:function(){return new l(this.x,this.y)}}})(f),(function(c){var i=c.fabric||(c.fabric={});if(i.Intersection){i.warn("fabric.Intersection is already defined");return}function l(a){this.status=a,this.points=[]}i.Intersection=l,i.Intersection.prototype={constructor:l,appendPoint:function(a){return this.points.push(a),this},appendPoints:function(a){return this.points=this.points.concat(a),this}},i.Intersection.intersectLineLine=function(a,t,n,e){var o,h=(e.x-n.x)*(a.y-n.y)-(e.y-n.y)*(a.x-n.x),s=(t.x-a.x)*(a.y-n.y)-(t.y-a.y)*(a.x-n.x),u=(e.y-n.y)*(t.x-a.x)-(e.x-n.x)*(t.y-a.y);if(u!==0){var d=h/u,m=s/u;0<=d&&d<=1&&0<=m&&m<=1?(o=new l("Intersection"),o.appendPoint(new i.Point(a.x+d*(t.x-a.x),a.y+d*(t.y-a.y)))):o=new l}else h===0||s===0?o=new l("Coincident"):o=new l("Parallel");return o},i.Intersection.intersectLinePolygon=function(a,t,n){var e=new l,o=n.length,h,s,u,d;for(d=0;d<o;d++)h=n[d],s=n[(d+1)%o],u=l.intersectLineLine(a,t,h,s),e.appendPoints(u.points);return e.points.length>0&&(e.status="Intersection"),e},i.Intersection.intersectPolygonPolygon=function(a,t){var n=new l,e=a.length,o;for(o=0;o<e;o++){var h=a[o],s=a[(o+1)%e],u=l.intersectLinePolygon(h,s,t);n.appendPoints(u.points)}return n.points.length>0&&(n.status="Intersection"),n},i.Intersection.intersectPolygonRectangle=function(a,t,n){var e=t.min(n),o=t.max(n),h=new i.Point(o.x,e.y),s=new i.Point(e.x,o.y),u=l.intersectLinePolygon(e,h,a),d=l.intersectLinePolygon(h,o,a),m=l.intersectLinePolygon(o,s,a),g=l.intersectLinePolygon(s,e,a),v=new l;return v.appendPoints(u.points),v.appendPoints(d.points),v.appendPoints(m.points),v.appendPoints(g.points),v.points.length>0&&(v.status="Intersection"),v}})(f),(function(c){var i=c.fabric||(c.fabric={});if(i.Color){i.warn("fabric.Color is already defined.");return}function l(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}i.Color=l,i.Color.prototype={_tryParsingColor:function(t){var n;t in l.colorNameMap&&(t=l.colorNameMap[t]),t==="transparent"&&(n=[255,255,255,0]),n||(n=l.sourceFromHex(t)),n||(n=l.sourceFromRgb(t)),n||(n=l.sourceFromHsl(t)),n||(n=[0,0,0,1]),n&&this.setSource(n)},_rgbToHsl:function(t,n,e){t/=255,n/=255,e/=255;var o,h,s,u=i.util.array.max([t,n,e]),d=i.util.array.min([t,n,e]);if(s=(u+d)/2,u===d)o=h=0;else{var m=u-d;switch(h=s>.5?m/(2-u-d):m/(u+d),u){case t:o=(n-e)/m+(n<e?6:0);break;case n:o=(e-t)/m+2;break;case e:o=(t-n)/m+4;break}o/=6}return[Math.round(o*360),Math.round(h*100),Math.round(s*100)]},getSource:function(){return this._source},setSource:function(t){this._source=t},toRgb:function(){var t=this.getSource();return"rgb("+t[0]+","+t[1]+","+t[2]+")"},toRgba:function(){var t=this.getSource();return"rgba("+t[0]+","+t[1]+","+t[2]+","+t[3]+")"},toHsl:function(){var t=this.getSource(),n=this._rgbToHsl(t[0],t[1],t[2]);return"hsl("+n[0]+","+n[1]+"%,"+n[2]+"%)"},toHsla:function(){var t=this.getSource(),n=this._rgbToHsl(t[0],t[1],t[2]);return"hsla("+n[0]+","+n[1]+"%,"+n[2]+"%,"+t[3]+")"},toHex:function(){var t=this.getSource(),n,e,o;return n=t[0].toString(16),n=n.length===1?"0"+n:n,e=t[1].toString(16),e=e.length===1?"0"+e:e,o=t[2].toString(16),o=o.length===1?"0"+o:o,n.toUpperCase()+e.toUpperCase()+o.toUpperCase()},toHexa:function(){var t=this.getSource(),n;return n=Math.round(t[3]*255),n=n.toString(16),n=n.length===1?"0"+n:n,this.toHex()+n.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(t){var n=this.getSource();return n[3]=t,this.setSource(n),this},toGrayscale:function(){var t=this.getSource(),n=parseInt((t[0]*.3+t[1]*.59+t[2]*.11).toFixed(0),10),e=t[3];return this.setSource([n,n,n,e]),this},toBlackWhite:function(t){var n=this.getSource(),e=(n[0]*.3+n[1]*.59+n[2]*.11).toFixed(0),o=n[3];return t=t||127,e=Number(e)<Number(t)?0:255,this.setSource([e,e,e,o]),this},overlayWith:function(t){t instanceof l||(t=new l(t));var n=[],e=this.getAlpha(),o=.5,h=this.getSource(),s=t.getSource(),u;for(u=0;u<3;u++)n.push(Math.round(h[u]*(1-o)+s[u]*o));return n[3]=e,this.setSource(n),this}},i.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/i,i.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/i,i.Color.reHex=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,i.Color.colorNameMap={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};function a(t,n,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+(n-t)*6*e:e<1/2?n:e<2/3?t+(n-t)*(2/3-e)*6:t}i.Color.fromRgb=function(t){return l.fromSource(l.sourceFromRgb(t))},i.Color.sourceFromRgb=function(t){var n=t.match(l.reRGBa);if(n){var e=parseInt(n[1],10)/(/%$/.test(n[1])?100:1)*(/%$/.test(n[1])?255:1),o=parseInt(n[2],10)/(/%$/.test(n[2])?100:1)*(/%$/.test(n[2])?255:1),h=parseInt(n[3],10)/(/%$/.test(n[3])?100:1)*(/%$/.test(n[3])?255:1);return[parseInt(e,10),parseInt(o,10),parseInt(h,10),n[4]?parseFloat(n[4]):1]}},i.Color.fromRgba=l.fromRgb,i.Color.fromHsl=function(t){return l.fromSource(l.sourceFromHsl(t))},i.Color.sourceFromHsl=function(t){var n=t.match(l.reHSLa);if(n){var e=(parseFloat(n[1])%360+360)%360/360,o=parseFloat(n[2])/(/%$/.test(n[2])?100:1),h=parseFloat(n[3])/(/%$/.test(n[3])?100:1),s,u,d;if(o===0)s=u=d=h;else{var m=h<=.5?h*(o+1):h+o-h*o,g=h*2-m;s=a(g,m,e+1/3),u=a(g,m,e),d=a(g,m,e-1/3)}return[Math.round(s*255),Math.round(u*255),Math.round(d*255),n[4]?parseFloat(n[4]):1]}},i.Color.fromHsla=l.fromHsl,i.Color.fromHex=function(t){return l.fromSource(l.sourceFromHex(t))},i.Color.sourceFromHex=function(t){if(t.match(l.reHex)){var n=t.slice(t.indexOf("#")+1),e=n.length===3||n.length===4,o=n.length===8||n.length===4,h=e?n.charAt(0)+n.charAt(0):n.substring(0,2),s=e?n.charAt(1)+n.charAt(1):n.substring(2,4),u=e?n.charAt(2)+n.charAt(2):n.substring(4,6),d=o?e?n.charAt(3)+n.charAt(3):n.substring(6,8):"FF";return[parseInt(h,16),parseInt(s,16),parseInt(u,16),parseFloat((parseInt(d,16)/255).toFixed(2))]}},i.Color.fromSource=function(t){var n=new l;return n.setSource(t),n}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=["e","se","s","sw","w","nw","n","ne","e"],a=["ns","nesw","ew","nwse"],t={},n="left",e="top",o="right",h="bottom",s="center",u={top:h,bottom:e,left:o,right:n,center:s},d=i.util.radiansToDegrees,m=Math.sign||function(B){return(B>0)-(B<0)||+B};function g(B,M){var X=B.angle+d(Math.atan2(M.y,M.x))+360;return Math.round(X%360/45)}function v(B,M){var X=M.transform.target,Y=X.canvas,H=i.util.object.clone(M);H.target=X,Y&&Y.fire("object:"+B,H),X.fire(B,M)}function b(B,M){var X=M.canvas,Y=X.uniScaleKey,H=B[Y];return X.uniformScaling&&!H||!X.uniformScaling&&H}function S(B){return B.originX===s&&B.originY===s}function E(B,M,X){var Y=B.lockScalingX,H=B.lockScalingY;return!!(Y&&H||!M&&(Y||H)&&X||Y&&M==="x"||H&&M==="y")}function F(B,M,X){var Y="not-allowed",H=b(B,X),U="";if(M.x!==0&&M.y===0?U="x":M.x===0&&M.y!==0&&(U="y"),E(X,U,H))return Y;var Q=g(X,M);return l[Q]+"-resize"}function R(B,M,X){var Y="not-allowed";if(M.x!==0&&X.lockSkewingY||M.y!==0&&X.lockSkewingX)return Y;var H=g(X,M)%4;return a[H]+"-resize"}function z(B,M,X){return B[X.canvas.altActionKey]?t.skewCursorStyleHandler(B,M,X):t.scaleCursorStyleHandler(B,M,X)}function q(B,M,X){var Y=B[X.canvas.altActionKey];if(M.x===0)return Y?"skewX":"scaleY";if(M.y===0)return Y?"skewY":"scaleX"}function Z(B,M,X){return X.lockRotation?"not-allowed":M.cursorStyle}function K(B,M,X,Y){return{e:B,transform:M,pointer:{x:X,y:Y}}}function $(B){return function(M,X,Y,H){var U=X.target,Q=U.getCenterPoint(),st=U.translateToOriginPoint(Q,X.originX,X.originY),nt=B(M,X,Y,H);return U.setPositionByOrigin(st,X.originX,X.originY),nt}}function tt(B,M){return function(X,Y,H,U){var Q=M(X,Y,H,U);return Q&&v(B,K(X,Y,H,U)),Q}}function it(B,M,X,Y,H){var U=B.target,Q=U.controls[B.corner],st=U.canvas.getZoom(),nt=U.padding/st,W=U.toLocalPoint(new i.Point(Y,H),M,X);return W.x>=nt&&(W.x-=nt),W.x<=-nt&&(W.x+=nt),W.y>=nt&&(W.y-=nt),W.y<=nt&&(W.y+=nt),W.x-=Q.offsetX,W.y-=Q.offsetY,W}function et(B){return B.flipX!==B.flipY}function w(B,M,X,Y,H){if(B[M]!==0){var U=B._getTransformedDimensions()[Y],Q=H/U*B[X];B.set(X,Q)}}function k(B,M,X,Y){var H=M.target,U=H._getTransformedDimensions(0,H.skewY),Q=it(M,M.originX,M.originY,X,Y),st=Math.abs(Q.x*2)-U.x,nt=H.skewX,W;st<2?W=0:(W=d(Math.atan2(st/H.scaleX,U.y/H.scaleY)),M.originX===n&&M.originY===h&&(W=-W),M.originX===o&&M.originY===e&&(W=-W),et(H)&&(W=-W));var rt=nt!==W;if(rt){var ot=H._getTransformedDimensions().y;H.set("skewX",W),w(H,"skewY","scaleY","y",ot)}return rt}function A(B,M,X,Y){var H=M.target,U=H._getTransformedDimensions(H.skewX,0),Q=it(M,M.originX,M.originY,X,Y),st=Math.abs(Q.y*2)-U.y,nt=H.skewY,W;st<2?W=0:(W=d(Math.atan2(st/H.scaleY,U.x/H.scaleX)),M.originX===n&&M.originY===h&&(W=-W),M.originX===o&&M.originY===e&&(W=-W),et(H)&&(W=-W));var rt=nt!==W;if(rt){var ot=H._getTransformedDimensions().x;H.set("skewY",W),w(H,"skewX","scaleX","x",ot)}return rt}function P(B,M,X,Y){var H=M.target,U=H.skewX,Q,st=M.originY;if(H.lockSkewingX)return!1;if(U===0){var nt=it(M,s,s,X,Y);nt.x>0?Q=n:Q=o}else U>0&&(Q=st===e?n:o),U<0&&(Q=st===e?o:n),et(H)&&(Q=Q===n?o:n);M.originX=Q;var W=tt("skewing",$(k));return W(B,M,X,Y)}function I(B,M,X,Y){var H=M.target,U=H.skewY,Q,st=M.originX;if(H.lockSkewingY)return!1;if(U===0){var nt=it(M,s,s,X,Y);nt.y>0?Q=e:Q=h}else U>0&&(Q=st===n?e:h),U<0&&(Q=st===n?h:e),et(H)&&(Q=Q===e?h:e);M.originY=Q;var W=tt("skewing",$(A));return W(B,M,X,Y)}function O(B,M,X,Y){var H=M,U=H.target,Q=U.translateToOriginPoint(U.getCenterPoint(),H.originX,H.originY);if(U.lockRotation)return!1;var st=Math.atan2(H.ey-Q.y,H.ex-Q.x),nt=Math.atan2(Y-Q.y,X-Q.x),W=d(nt-st+H.theta),rt=!0;if(U.snapAngle>0){var ot=U.snapAngle,lt=U.snapThreshold||ot,ut=Math.ceil(W/ot)*ot,ht=Math.floor(W/ot)*ot;Math.abs(W-ht)<lt?W=ht:Math.abs(W-ut)<lt&&(W=ut)}return W<0&&(W=360+W),W%=360,rt=U.angle!==W,U.angle=W,rt}function x(B,M,X,Y,H){H=H||{};var U=M.target,Q=U.lockScalingX,st=U.lockScalingY,nt=H.by,W,rt,ot,lt,ut=b(B,U),ht=E(U,nt,ut),bt,dt,zt=M.gestureScale;if(ht)return!1;if(zt)rt=M.scaleX*zt,ot=M.scaleY*zt;else{if(W=it(M,M.originX,M.originY,X,Y),bt=nt!=="y"?m(W.x):1,dt=nt!=="x"?m(W.y):1,M.signX||(M.signX=bt),M.signY||(M.signY=dt),U.lockScalingFlip&&(M.signX!==bt||M.signY!==dt))return!1;if(lt=U._getTransformedDimensions(),ut&&!nt){var le=Math.abs(W.x)+Math.abs(W.y),kt=M.original,pr=Math.abs(lt.x*kt.scaleX/U.scaleX)+Math.abs(lt.y*kt.scaleY/U.scaleY),Vi=le/pr;rt=kt.scaleX*Vi,ot=kt.scaleY*Vi}else rt=Math.abs(W.x*U.scaleX/lt.x),ot=Math.abs(W.y*U.scaleY/lt.y);S(M)&&(rt*=2,ot*=2),M.signX!==bt&&nt!=="y"&&(M.originX=u[M.originX],rt*=-1,M.signX=bt),M.signY!==dt&&nt!=="x"&&(M.originY=u[M.originY],ot*=-1,M.signY=dt)}var mr=U.scaleX,vr=U.scaleY;return nt?(nt==="x"&&U.set("scaleX",rt),nt==="y"&&U.set("scaleY",ot)):(!Q&&U.set("scaleX",rt),!st&&U.set("scaleY",ot)),mr!==U.scaleX||vr!==U.scaleY}function D(B,M,X,Y){return x(B,M,X,Y)}function L(B,M,X,Y){return x(B,M,X,Y,{by:"x"})}function N(B,M,X,Y){return x(B,M,X,Y,{by:"y"})}function j(B,M,X,Y){return B[M.target.canvas.altActionKey]?t.skewHandlerX(B,M,X,Y):t.scalingY(B,M,X,Y)}function V(B,M,X,Y){return B[M.target.canvas.altActionKey]?t.skewHandlerY(B,M,X,Y):t.scalingX(B,M,X,Y)}function G(B,M,X,Y){var H=M.target,U=it(M,M.originX,M.originY,X,Y),Q=H.strokeWidth/(H.strokeUniform?H.scaleX:1),st=S(M)?2:1,nt=H.width,W=Math.abs(U.x*st/H.scaleX)-Q;return H.set("width",Math.max(W,0)),nt!==W}function J(B,M,X,Y){var H=M.target,U=X-M.offsetX,Q=Y-M.offsetY,st=!H.get("lockMovementX")&&H.left!==U,nt=!H.get("lockMovementY")&&H.top!==Q;return st&&H.set("left",U),nt&&H.set("top",Q),(st||nt)&&v("moving",K(B,M,X,Y)),st||nt}t.scaleCursorStyleHandler=F,t.skewCursorStyleHandler=R,t.scaleSkewCursorStyleHandler=z,t.rotationWithSnapping=tt("rotating",$(O)),t.scalingEqually=tt("scaling",$(D)),t.scalingX=tt("scaling",$(L)),t.scalingY=tt("scaling",$(N)),t.scalingYOrSkewingX=j,t.scalingXOrSkewingY=V,t.changeWidth=tt("resizing",$(G)),t.skewHandlerX=P,t.skewHandlerY=I,t.dragHandler=J,t.scaleOrSkewActionName=q,t.rotationStyleHandler=Z,t.fireEvent=v,t.wrapWithFixedAnchor=$,t.wrapWithFireEvent=tt,t.getLocalPoint=it,i.controlsUtils=t})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.degreesToRadians,a=i.controlsUtils;function t(e,o,h,s,u){s=s||{};var d=this.sizeX||s.cornerSize||u.cornerSize,m=this.sizeY||s.cornerSize||u.cornerSize,g=typeof s.transparentCorners<"u"?s.transparentCorners:u.transparentCorners,v=g?"stroke":"fill",b=!g&&(s.cornerStrokeColor||u.cornerStrokeColor),S=o,E=h,F;e.save(),e.fillStyle=s.cornerColor||u.cornerColor,e.strokeStyle=s.cornerStrokeColor||u.cornerStrokeColor,d>m?(F=d,e.scale(1,m/d),E=h*d/m):m>d?(F=m,e.scale(d/m,1),S=o*m/d):F=d,e.lineWidth=1,e.beginPath(),e.arc(S,E,F/2,0,2*Math.PI,!1),e[v](),b&&e.stroke(),e.restore()}function n(e,o,h,s,u){s=s||{};var d=this.sizeX||s.cornerSize||u.cornerSize,m=this.sizeY||s.cornerSize||u.cornerSize,g=typeof s.transparentCorners<"u"?s.transparentCorners:u.transparentCorners,v=g?"stroke":"fill",b=!g&&(s.cornerStrokeColor||u.cornerStrokeColor),S=d/2,E=m/2;e.save(),e.fillStyle=s.cornerColor||u.cornerColor,e.strokeStyle=s.cornerStrokeColor||u.cornerStrokeColor,e.lineWidth=1,e.translate(o,h),e.rotate(l(u.angle)),e[v+"Rect"](-S,-E,d,m),b&&e.strokeRect(-S,-E,d,m),e.restore()}a.renderCircleControl=t,a.renderSquareControl=n})(f),(function(c){var i=c.fabric||(c.fabric={});function l(a){for(var t in a)this[t]=a[t]}i.Control=l,i.Control.prototype={visible:!0,actionName:"scale",angle:0,x:0,y:0,offsetX:0,offsetY:0,sizeX:null,sizeY:null,touchSizeX:null,touchSizeY:null,cursorStyle:"crosshair",withConnection:!1,actionHandler:function(){},mouseDownHandler:function(){},mouseUpHandler:function(){},getActionHandler:function(){return this.actionHandler},getMouseDownHandler:function(){return this.mouseDownHandler},getMouseUpHandler:function(){return this.mouseUpHandler},cursorStyleHandler:function(a,t){return t.cursorStyle},getActionName:function(a,t){return t.actionName},getVisibility:function(a,t){var n=a._controlsVisibility;return n&&typeof n[t]<"u"?n[t]:this.visible},setVisibility:function(a){this.visible=a},positionHandler:function(a,t){var n=i.util.transformPoint({x:this.x*a.x+this.offsetX,y:this.y*a.y+this.offsetY},t);return n},calcCornerCoords:function(a,t,n,e,o){var h,s,u,d,m=o?this.touchSizeX:this.sizeX,g=o?this.touchSizeY:this.sizeY;if(m&&g&&m!==g){var v=Math.atan2(g,m),b=Math.sqrt(m*m+g*g)/2,S=v-i.util.degreesToRadians(a),E=Math.PI/2-v-i.util.degreesToRadians(a);h=b*i.util.cos(S),s=b*i.util.sin(S),u=b*i.util.cos(E),d=b*i.util.sin(E)}else{var F=m&&g?m:t;b=F*.7071067812;var S=i.util.degreesToRadians(45-a);h=u=b*i.util.cos(S),s=d=b*i.util.sin(S)}return{tl:{x:n-d,y:e-u},tr:{x:n+h,y:e-s},bl:{x:n-h,y:e+s},br:{x:n+d,y:e+u}}},render:function(a,t,n,e,o){switch(e=e||{},e.cornerStyle||o.cornerStyle){case"circle":i.controlsUtils.renderCircleControl.call(this,a,t,n,e,o);break;default:i.controlsUtils.renderSquareControl.call(this,a,t,n,e,o)}}}})(f),(function(){function c(n,e){var o=n.getAttribute("style"),h=n.getAttribute("offset")||0,s,u,d,m;if(h=parseFloat(h)/(/%$/.test(h)?100:1),h=h<0?0:h>1?1:h,o){var g=o.split(/\s*;\s*/);for(g[g.length-1]===""&&g.pop(),m=g.length;m--;){var v=g[m].split(/\s*:\s*/),b=v[0].trim(),S=v[1].trim();b==="stop-color"?s=S:b==="stop-opacity"&&(d=S)}}return s||(s=n.getAttribute("stop-color")||"rgb(0,0,0)"),d||(d=n.getAttribute("stop-opacity")),s=new r.Color(s),u=s.getAlpha(),d=isNaN(parseFloat(d))?1:parseFloat(d),d*=u*e,{offset:h,color:s.toRgb(),opacity:d}}function i(n){return{x1:n.getAttribute("x1")||0,y1:n.getAttribute("y1")||0,x2:n.getAttribute("x2")||"100%",y2:n.getAttribute("y2")||0}}function l(n){return{x1:n.getAttribute("fx")||n.getAttribute("cx")||"50%",y1:n.getAttribute("fy")||n.getAttribute("cy")||"50%",r1:0,x2:n.getAttribute("cx")||"50%",y2:n.getAttribute("cy")||"50%",r2:n.getAttribute("r")||"50%"}}var a=r.util.object.clone;r.Gradient=r.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(n){n||(n={}),n.coords||(n.coords={});var e,o=this;Object.keys(n).forEach(function(h){o[h]=n[h]}),this.id?this.id+="_"+r.Object.__uid++:this.id=r.Object.__uid++,e={x1:n.coords.x1||0,y1:n.coords.y1||0,x2:n.coords.x2||0,y2:n.coords.y2||0},this.type==="radial"&&(e.r1=n.coords.r1||0,e.r2=n.coords.r2||0),this.coords=e,this.colorStops=n.colorStops.slice()},addColorStop:function(n){for(var e in n){var o=new r.Color(n[e]);this.colorStops.push({offset:parseFloat(e),color:o.toRgb(),opacity:o.getAlpha()})}return this},toObject:function(n){var e={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return r.util.populateWithProperties(this,e,n),e},toSVG:function(n,u){var o=a(this.coords,!0),h,s,u=u||{},d,m,g=a(this.colorStops,!0),v=o.r1>o.r2,b=this.gradientTransform?this.gradientTransform.concat():r.iMatrix.concat(),S=-this.offsetX,E=-this.offsetY,F=!!u.additionalTransform,R=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox";if(g.sort(function($,tt){return $.offset-tt.offset}),R==="objectBoundingBox"?(S/=n.width,E/=n.height):(S+=n.width/2,E+=n.height/2),n.type==="path"&&this.gradientUnits!=="percentage"&&(S-=n.pathOffset.x,E-=n.pathOffset.y),b[4]-=S,b[5]-=E,m='id="SVGID_'+this.id+'" gradientUnits="'+R+'"',m+=' gradientTransform="'+(F?u.additionalTransform+" ":"")+r.util.matrixToSVG(b)+'" ',this.type==="linear"?d=["<linearGradient ",m,' x1="',o.x1,'" y1="',o.y1,'" x2="',o.x2,'" y2="',o.y2,`">
3
+ `,...xs(y)),console.warn(...C)}oe(),ei=!1}function ws(){let f=Kt[Kt.length-1];if(!f)return[];const r=[];for(;f;){const g=r[0];g&&g.vnode===f?g.recurseCount++:r.push({vnode:f,recurseCount:0});const _=f.component&&f.component.parent;f=_&&_.vnode}return r}function xs(f){const r=[];return f.forEach((g,_)=>{r.push(..._===0?[]:[`
4
+ `],...Ts(g))}),r}function Ts({vnode:f,recurseCount:r}){const g=r>0?`... (${r} recursive calls)`:"",_=f.component?f.component.parent==null:!1,y=` at <${sr(f.component,f.type,_)}`,C=">"+g;return f.props?[y,...Os(f.props),C]:[y+C]}function Os(f){const r=[],g=Object.keys(f);return g.slice(0,3).forEach(_=>{r.push(...Vn(_,f[_]))}),g.length>3&&r.push(" ..."),r}function Vn(f,r,g){return jt(r)?(r=JSON.stringify(r),g?r:[`${f}=${r}`]):typeof r=="number"||typeof r=="boolean"||r==null?g?r:[`${f}=${r}`]:Ot(r)?(r=Vn(f,at(r.value),!0),g?r:[`${f}=Ref<`,r,">"]):Ct(r)?[`${f}=fn${r.name?`<${r.name}>`:""}`]:(r=at(r),g?r:[`${f}=`,r])}const Hi={sp:"serverPrefetch hook",bc:"beforeCreate hook",c:"created hook",bm:"beforeMount hook",m:"mounted hook",bu:"beforeUpdate hook",u:"updated",bum:"beforeUnmount hook",um:"unmounted hook",a:"activated hook",da:"deactivated hook",ec:"errorCaptured hook",rtc:"renderTracked hook",rtg:"renderTriggered hook",0:"setup function",1:"render function",2:"watcher getter",3:"watcher callback",4:"watcher cleanup function",5:"native event handler",6:"component event handler",7:"vnode hook",8:"directive hook",9:"transition hook",10:"app errorHandler",11:"app warnHandler",12:"ref function",13:"async component loader",14:"scheduler flush",15:"component update",16:"app unmount cleanup function"};function Ue(f,r,g,_){try{return _?f(..._):f()}catch(y){Wi(y,r,g)}}function Ni(f,r,g,_){if(Ct(f)){const y=Ue(f,r,g,_);return y&&Wr(y)&&y.catch(C=>{Wi(C,r,g)}),y}if(gt(f)){const y=[];for(let C=0;C<f.length;C++)y.push(Ni(f[C],r,g,_));return y}else process.env.NODE_ENV!=="production"&&yt(`Invalid value type passed to callWithAsyncErrorHandling(): ${typeof f}`)}function Wi(f,r,g,_=!0){const y=r?r.vnode:null,{errorHandler:C,throwUnhandledErrorInProduction:T}=r&&r.appContext.config||me;if(r){let c=r.parent;const i=r.proxy,l=process.env.NODE_ENV!=="production"?Hi[g]:`https://vuejs.org/error-reference/#runtime-${g}`;for(;c;){const a=c.ec;if(a){for(let t=0;t<a.length;t++)if(a[t](f,i,l)===!1)return}c=c.parent}if(C){se(),Ue(C,null,10,[f,i,l]),oe();return}}Es(f,g,y,_,T)}function Es(f,r,g,_=!0,y=!1){if(process.env.NODE_ENV!=="production"){const C=Hi[r];if(g&&bs(g),yt(`Unhandled error${C?` during execution of ${C}`:""}`),g&&Ss(),_)throw f;console.error(f)}else{if(y)throw f;console.error(f)}}const Et=[];let Rt=-1;const re=[];let Nt=null,Qt=0;const Ps=Promise.resolve();let Ei=null;const ks=100;function As(f){let r=Rt+1,g=Et.length;for(;r<g;){const _=r+g>>>1,y=Et[_],C=be(y);C<f||C===f&&y.flags&2?r=_+1:g=_}return r}function Un(f){if(!(f.flags&1)){const r=be(f),g=Et[Et.length-1];!g||!(f.flags&2)&&r>=be(g)?Et.push(f):Et.splice(As(r),0,f),f.flags|=1,zn()}}function zn(){Ei||(Ei=Ps.then(qn))}function Gn(f){gt(f)?re.push(...f):Nt&&f.id===-1?Nt.splice(Qt+1,0,f):f.flags&1||(re.push(f),f.flags|=1),zn()}function Ds(f){if(re.length){const r=[...new Set(re)].sort((g,_)=>be(g)-be(_));if(re.length=0,Nt){Nt.push(...r);return}for(Nt=r,process.env.NODE_ENV!=="production"&&(f=f||new Map),Qt=0;Qt<Nt.length;Qt++){const g=Nt[Qt];process.env.NODE_ENV!=="production"&&Kn(f,g)||(g.flags&4&&(g.flags&=-2),g.flags&8||g(),g.flags&=-2)}Nt=null,Qt=0}}const be=f=>f.id==null?f.flags&2?-1:1/0:f.id;function qn(f){process.env.NODE_ENV!=="production"&&(f=f||new Map);const r=process.env.NODE_ENV!=="production"?g=>Kn(f,g):ee;try{for(Rt=0;Rt<Et.length;Rt++){const g=Et[Rt];if(g&&!(g.flags&8)){if(process.env.NODE_ENV!=="production"&&r(g))continue;g.flags&4&&(g.flags&=-2),Ue(g,g.i,g.i?15:14),g.flags&4||(g.flags&=-2)}}}finally{for(;Rt<Et.length;Rt++){const g=Et[Rt];g&&(g.flags&=-2)}Rt=-1,Et.length=0,Ds(f),Ei=null,(Et.length||re.length)&&qn(f)}}function Kn(f,r){const g=f.get(r)||0;if(g>ks){const _=r.i,y=_&&rr(_.type);return Wi(`Maximum recursive updates exceeded${y?` in component <${y}>`:""}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,null,10),!0}return f.set(r,g+1),!1}const ii=new Map;process.env.NODE_ENV!=="production"&&(Ve().__VUE_HMR_RUNTIME__={createRecord:ni(Ms),rerender:ni(Ls),reload:ni(Fs)});const He=new Map;function Ms(f,r){return He.has(f)?!1:(He.set(f,{initialDef:Ne(r),instances:new Set}),!0)}function Ne(f){return or(f)?f.__vccOpts:f}function Ls(f,r){const g=He.get(f);g&&(g.initialDef.render=r,[...g.instances].forEach(_=>{r&&(_.render=r,Ne(_.type).render=r),_.renderCache=[],_.job.flags&8||_.update()}))}function Fs(f,r){const g=He.get(f);if(!g)return;r=Ne(r),tn(g.initialDef,r);const _=[...g.instances];for(let y=0;y<_.length;y++){const C=_[y],T=Ne(C.type);let c=ii.get(T);c||(T!==g.initialDef&&tn(T,r),ii.set(T,c=new Set)),c.add(C),C.appContext.propsCache.delete(C.type),C.appContext.emitsCache.delete(C.type),C.appContext.optionsCache.delete(C.type),C.ceReload?(c.add(C),C.ceReload(r.styles),c.delete(C)):C.parent?Un(()=>{C.job.flags&8||(C.parent.update(),c.delete(C))}):C.appContext.reload?C.appContext.reload():typeof window<"u"?window.location.reload():console.warn("[HMR] Root or manually mounted instance modified. Full reload required."),C.root.ce&&C!==C.root&&C.root.ce._removeChildStyle(T)}Gn(()=>{ii.clear()})}function tn(f,r){Vt(f,r);for(const g in f)g!=="__file"&&!(g in r)&&delete f[g]}function ni(f){return(r,g)=>{try{return f(r,g)}catch(_){console.error(_),console.warn("[HMR] Something went wrong during Vue component hot-reload. Full reload required.")}}}let Zt,Le=[];function $n(f,r){var g,_;Zt=f,Zt?(Zt.enabled=!0,Le.forEach(({event:y,args:C})=>Zt.emit(y,...C)),Le=[]):typeof window<"u"&&window.HTMLElement&&!((_=(g=window.navigator)==null?void 0:g.userAgent)!=null&&_.includes("jsdom"))?((r.__VUE_DEVTOOLS_HOOK_REPLAY__=r.__VUE_DEVTOOLS_HOOK_REPLAY__||[]).push(C=>{$n(C,r)}),setTimeout(()=>{Zt||(r.__VUE_DEVTOOLS_HOOK_REPLAY__=null,Le=[])},3e3)):Le=[]}let Se=null,Rs=null;const Is=f=>f.__isTeleport;function Jn(f,r){f.shapeFlag&6&&f.component?(f.transition=r,Jn(f.component.subTree,r)):f.shapeFlag&128?(f.ssContent.transition=r.clone(f.ssContent),f.ssFallback.transition=r.clone(f.ssFallback)):f.transition=r}Ve().requestIdleCallback;Ve().cancelIdleCallback;function js(f,r,g=ae,_=!1){if(g){const y=g[f]||(g[f]=[]),C=r.__weh||(r.__weh=(...T)=>{se();const c=oo(g),i=Ni(r,g,f,T);return c(),oe(),i});return _?y.unshift(C):y.push(C),C}else if(process.env.NODE_ENV!=="production"){const y=Vr(Hi[f].replace(/ hook$/,""));yt(`${y} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`)}}const Bs=f=>(r,g=ae)=>{(!we||f==="sp")&&js(f,(..._)=>r(..._),g)},Hs=Bs("m"),Ns=Symbol.for("v-ndc"),Ws={};process.env.NODE_ENV!=="production"&&(Ws.ownKeys=f=>(yt("Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead."),Reflect.ownKeys(f)));let Xs=null;function Ys(f,r,g=!1){const _=Yi();if(_||Xs){let y=_?_.parent==null||_.ce?_.vnode.appContext&&_.vnode.appContext.provides:_.parent.provides:void 0;if(y&&f in y)return y[f];if(arguments.length>1)return g&&Ct(r)?r.call(_&&_.proxy):r;process.env.NODE_ENV!=="production"&&yt(`injection "${String(f)}" not found.`)}else process.env.NODE_ENV!=="production"&&yt("inject() can only be used inside setup() or functional components.")}const Vs=Symbol.for("v-scx"),Us=()=>{{const f=Ys(Vs);return f||process.env.NODE_ENV!=="production"&&yt("Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build."),f}};function Qn(f,r,g){return process.env.NODE_ENV!=="production"&&!Ct(r)&&yt("`watch(fn, options?)` signature has been moved to a separate API. Use `watchEffect(fn, options?)` instead. `watch` now only supports `watch(source, cb, options?) signature."),zs(f,r,g)}function zs(f,r,g=me){const{immediate:_,deep:y,flush:C,once:T}=g;process.env.NODE_ENV!=="production"&&!r&&(_!==void 0&&yt('watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.'),y!==void 0&&yt('watch() "deep" option is only respected when using the watch(source, callback, options?) signature.'),T!==void 0&&yt('watch() "once" option is only respected when using the watch(source, callback, options?) signature.'));const c=Vt({},g);process.env.NODE_ENV!=="production"&&(c.onWarn=yt);const i=r&&_||!r&&C!=="post";let l;if(we){if(C==="sync"){const e=Us();l=e.__watcherHandles||(e.__watcherHandles=[])}else if(!i){const e=()=>{};return e.stop=ee,e.resume=ee,e.pause=ee,e}}const a=ae;c.call=(e,o,h)=>Ni(e,a,o,h);let t=!1;C==="post"?c.scheduler=e=>{qs(e,a&&a.suspense)}:C!=="sync"&&(t=!0,c.scheduler=(e,o)=>{o?e():Un(e)}),c.augmentJob=e=>{r&&(e.flags|=4),t&&(e.flags|=2,a&&(e.id=a.uid,e.i=a))};const n=Cs(f,r,c);return we&&(l?l.push(n):i&&n()),n}const Gs={},Zn=f=>Object.getPrototypeOf(f)===Gs,qs=$s,Ks=f=>f.__isSuspense;function $s(f,r){r&&r.pendingBranch?gt(f)?r.effects.push(...f):r.effects.push(f):Gn(f)}const tr=Symbol.for("v-fgt"),Js=Symbol.for("v-txt"),Qs=Symbol.for("v-cmt");function Zs(f){return f?f.__v_isVNode===!0:!1}const to=(...f)=>ir(...f),er=({key:f})=>f??null,Fe=({ref:f,ref_key:r,ref_for:g})=>(typeof f=="number"&&(f=""+f),f!=null?jt(f)||Ot(f)||Ct(f)?{i:Se,r:f,k:r,f:!!g}:f:null);function eo(f,r=null,g=null,_=0,y=null,C=f===tr?0:1,T=!1,c=!1){const i={__v_isVNode:!0,__v_skip:!0,type:f,props:r,key:r&&er(r),ref:r&&Fe(r),scopeId:Rs,slotScopeIds:null,children:g,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:C,patchFlag:_,dynamicProps:y,dynamicChildren:null,appContext:null,ctx:Se};return c?(Xi(i,g),C&128&&f.normalize(i)):g&&(i.shapeFlag|=jt(g)?8:16),process.env.NODE_ENV!=="production"&&i.key!==i.key&&yt("VNode created with invalid key (NaN). VNode type:",i.type),i}const io=process.env.NODE_ENV!=="production"?to:ir;function ir(f,r=null,g=null,_=0,y=null,C=!1){if((!f||f===Ns)&&(process.env.NODE_ENV!=="production"&&!f&&yt(`Invalid vnode type when creating vnode: ${f}.`),f=Qs),Zs(f)){const c=We(f,r,!0);return g&&Xi(c,g),c.patchFlag=-2,c}if(or(f)&&(f=f.__vccOpts),r){r=no(r);let{class:c,style:i}=r;c&&!jt(c)&&(r.class=Li(c)),xt(i)&&(je(i)&&!gt(i)&&(i=Vt({},i)),r.style=Mi(i))}const T=jt(f)?1:Ks(f)?128:Is(f)?64:xt(f)?4:Ct(f)?2:0;return process.env.NODE_ENV!=="production"&&T&4&&je(f)&&(f=at(f),yt("Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.",`
5
+ Component that was made reactive: `,f)),eo(f,r,g,_,y,T,C,!0)}function no(f){return f?je(f)||Zn(f)?Vt({},f):f:null}function We(f,r,g=!1,_=!1){const{props:y,ref:C,patchFlag:T,children:c,transition:i}=f,l=r?so(y||{},r):y,a={__v_isVNode:!0,__v_skip:!0,type:f.type,props:l,key:l&&er(l),ref:r&&r.ref?g&&C?gt(C)?C.concat(Fe(r)):[C,Fe(r)]:Fe(r):C,scopeId:f.scopeId,slotScopeIds:f.slotScopeIds,children:process.env.NODE_ENV!=="production"&&T===-1&&gt(c)?c.map(nr):c,target:f.target,targetStart:f.targetStart,targetAnchor:f.targetAnchor,staticCount:f.staticCount,shapeFlag:f.shapeFlag,patchFlag:r&&f.type!==tr?T===-1?16:T|16:T,dynamicProps:f.dynamicProps,dynamicChildren:f.dynamicChildren,appContext:f.appContext,dirs:f.dirs,transition:i,component:f.component,suspense:f.suspense,ssContent:f.ssContent&&We(f.ssContent),ssFallback:f.ssFallback&&We(f.ssFallback),placeholder:f.placeholder,el:f.el,anchor:f.anchor,ctx:f.ctx,ce:f.ce};return i&&_&&Jn(a,i.clone(a)),a}function nr(f){const r=We(f);return gt(f.children)&&(r.children=f.children.map(nr)),r}function ro(f=" ",r=0){return io(Js,null,f,r)}function Xi(f,r){let g=0;const{shapeFlag:_}=f;if(r==null)r=null;else if(gt(r))g=16;else if(typeof r=="object")if(_&65){const y=r.default;y&&(y._c&&(y._d=!1),Xi(f,y()),y._c&&(y._d=!0));return}else g=32,!r._&&!Zn(r)&&(r._ctx=Se);else Ct(r)?(r={default:r,_ctx:Se},g=32):(r=String(r),_&64?(g=16,r=[ro(r)]):g=8);f.children=r,f.shapeFlag|=g}function so(...f){const r={};for(let g=0;g<f.length;g++){const _=f[g];for(const y in _)if(y==="class")r.class!==_.class&&(r.class=Li([r.class,_.class]));else if(y==="style")r.style=Mi([r.style,_.style]);else if(Br(y)){const C=r[y],T=_[y];T&&C!==T&&!(gt(C)&&C.includes(T))&&(r[y]=C?[].concat(C,T):T)}else y!==""&&(r[y]=_[y])}return r}let ae=null;const Yi=()=>ae||Se;let Pi;{const f=Ve(),r=(g,_)=>{let y;return(y=f[g])||(y=f[g]=[]),y.push(_),C=>{y.length>1?y.forEach(T=>T(C)):y[0](C)}};Pi=r("__VUE_INSTANCE_SETTERS__",g=>ae=g),r("__VUE_SSR_SETTERS__",g=>we=g)}const oo=f=>{const r=ae;return Pi(f),f.scope.on(),()=>{f.scope.off(),Pi(r)}};let we=!1;process.env.NODE_ENV;const ao=/(?:^|[-_])\w/g,lo=f=>f.replace(ao,r=>r.toUpperCase()).replace(/[-_]/g,"");function rr(f,r=!0){return Ct(f)?f.displayName||f.name:f.name||r&&f.__name}function sr(f,r,g=!1){let _=rr(r);if(!_&&r.__file){const y=r.__file.match(/([^/\\]+)\.\w+$/);y&&(_=y[1])}if(!_&&f){const y=C=>{for(const T in C)if(C[T]===r)return T};_=y(f.components)||f.parent&&y(f.parent.type.components)||y(f.appContext.components)}return _?lo(_):g?"App":"Anonymous"}function or(f){return Ct(f)&&"__vccOpts"in f}const ar=(f,r)=>{const g=_s(f,r,we);if(process.env.NODE_ENV!=="production"){const _=Yi();_&&_.appContext.config.warnRecursiveComputed&&(g._warnRecursive=!0)}return g};function co(){if(process.env.NODE_ENV==="production"||typeof window>"u")return;const f={style:"color:#3ba776"},r={style:"color:#1677ff"},g={style:"color:#f5222d"},_={style:"color:#eb2f96"},y={__vue_custom_formatter:!0,header(t){if(!xt(t))return null;if(t.__isVue)return["div",f,"VueInstance"];if(Ot(t)){se();const n=t.value;return oe(),["div",{},["span",f,a(t)],"<",c(n),">"]}else{if(ne(t))return["div",{},["span",f,Tt(t)?"ShallowReactive":"Reactive"],"<",c(t),`>${Dt(t)?" (readonly)":""}`];if(Dt(t))return["div",{},["span",f,Tt(t)?"ShallowReadonly":"Readonly"],"<",c(t),">"]}return null},hasBody(t){return t&&t.__isVue},body(t){if(t&&t.__isVue)return["div",{},...C(t.$)]}};function C(t){const n=[];t.type.props&&t.props&&n.push(T("props",at(t.props))),t.setupState!==me&&n.push(T("setup",t.setupState)),t.data!==me&&n.push(T("data",at(t.data)));const e=i(t,"computed");e&&n.push(T("computed",e));const o=i(t,"inject");return o&&n.push(T("injected",o)),n.push(["div",{},["span",{style:_.style+";opacity:0.66"},"$ (internal): "],["object",{object:t}]]),n}function T(t,n){return n=Vt({},n),Object.keys(n).length?["div",{style:"line-height:1.25em;margin-bottom:0.6em"},["div",{style:"color:#476582"},t],["div",{style:"padding-left:1.25em"},...Object.keys(n).map(e=>["div",{},["span",_,e+": "],c(n[e],!1)])]]:["span",{}]}function c(t,n=!0){return typeof t=="number"?["span",r,t]:typeof t=="string"?["span",g,JSON.stringify(t)]:typeof t=="boolean"?["span",_,t]:xt(t)?["object",{object:n?at(t):t}]:["span",g,String(t)]}function i(t,n){const e=t.type;if(Ct(e))return;const o={};for(const h in t.ctx)l(e,h,n)&&(o[h]=t.ctx[h]);return o}function l(t,n,e){const o=t[e];if(gt(o)&&o.includes(n)||xt(o)&&n in o||t.extends&&l(t.extends,n,e)||t.mixins&&t.mixins.some(h=>l(h,n,e)))return!0}function a(t){return Tt(t)?"ShallowRef":t.effect?"ComputedRef":"Ref"}window.devtoolsFormatters?window.devtoolsFormatters.push(y):window.devtoolsFormatters=[y]}process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;function ho(){co()}process.env.NODE_ENV!=="production"&&ho();function uo(){const f=new Set,r=y=>{f.delete(y)};return{on:y=>(f.add(y),{off:()=>r(y)}),off:r,trigger:(...y)=>Promise.all(Array.from(f).map(C=>C(...y)))}}function Te(f){return typeof f=="function"?f():ms(f)}const Oe=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const fo=Object.prototype.toString,go=f=>fo.call(f)==="[object Object]",po=()=>{},mo=(f,r)=>Object.prototype.hasOwnProperty.call(f,r);function vo(f){let r;function g(){return r||(r=f()),r}return g.reset=async()=>{const _=r;r=void 0,_&&await _},g}function _o(f,r,g={}){const{immediate:_=!0}=g,y=Ut(!1);let C=null;function T(){C&&(clearTimeout(C),C=null)}function c(){y.value=!1,T()}function i(...l){T(),y.value=!0,C=setTimeout(()=>{y.value=!1,C=null,f(...l)},Te(r))}return _&&(y.value=!0,Oe&&i()),{isPending:ye(y),start:i,stop:c}}function yo(f){var r;const g=Te(f);return(r=g?.$el)!=null?r:g}const Co=Oe?window:void 0,bo=Oe?window.document:void 0,lr=Oe?window.navigator:void 0;function cr(...f){let r,g,_,y;if(typeof f[0]=="string"||Array.isArray(f[0])?([g,_,y]=f,r=Co):[r,g,_,y]=f,!r)return po;Array.isArray(g)||(g=[g]),Array.isArray(_)||(_=[_]);const C=[],T=()=>{C.forEach(a=>a()),C.length=0},c=(a,t,n,e)=>(a.addEventListener(t,n,e),()=>a.removeEventListener(t,n,e)),i=Qn(()=>[yo(r),Te(y)],([a,t])=>{if(T(),!a)return;const n=go(t)?{...t}:t;C.push(...g.flatMap(e=>_.map(o=>c(a,e,o,n))))},{immediate:!0,flush:"post"});return()=>{i(),T()}}function So(){const f=Ut(!1),r=Yi();return r&&Hs(()=>{f.value=!0},r),f}function hr(f){const r=So();return ar(()=>(r.value,!!f()))}const he={array:f=>JSON.stringify(f),object:f=>JSON.stringify(f),set:f=>JSON.stringify(Array.from(f)),map:f=>JSON.stringify(Object.fromEntries(f)),null:()=>""};function wo(f){return f?f instanceof Map?he.map:f instanceof Set?he.set:Array.isArray(f)?he.array:he.object:he.null}function xo(f,r){const g=Ut(""),_=Ut();function y(){if(Oe)return _.value=new Promise((C,T)=>{try{const c=Te(f);if(c==null)C("");else if(typeof c=="string")C(ri(new Blob([c],{type:"text/plain"})));else if(c instanceof Blob)C(ri(c));else if(c instanceof ArrayBuffer)C(window.btoa(String.fromCharCode(...new Uint8Array(c))));else if(c instanceof HTMLCanvasElement)C(c.toDataURL(r?.type,r?.quality));else if(c instanceof HTMLImageElement){const i=c.cloneNode(!1);i.crossOrigin="Anonymous",To(i).then(()=>{const l=document.createElement("canvas"),a=l.getContext("2d");l.width=i.width,l.height=i.height,a.drawImage(i,0,0,l.width,l.height),C(l.toDataURL(r?.type,r?.quality))}).catch(T)}else if(typeof c=="object"){const l=(r?.serializer||wo(c))(c);return C(ri(new Blob([l],{type:"application/json"})))}else T(new Error("target is unsupported types"))}catch(c){T(c)}}),_.value.then(C=>g.value=C),_.value}return Ot(f)||typeof f=="function"?Qn(f,y,{immediate:!0}):y(),{base64:g,promise:_,execute:y}}function To(f){return new Promise((r,g)=>{f.complete?r():(f.onload=()=>{r()},f.onerror=g)})}function ri(f){return new Promise((r,g)=>{const _=new FileReader;_.onload=y=>{r(y.target.result)},_.onerror=g,_.readAsDataURL(f)})}function en(f,r={}){const{controls:g=!1,navigator:_=lr}=r,y=hr(()=>_&&"permissions"in _);let C;const T=typeof f=="string"?{name:f}:f,c=Ut(),i=()=>{C&&(c.value=C.state)},l=vo(async()=>{if(y.value){if(!C)try{C=await _.permissions.query(T),cr(C,"change",i),i()}catch{c.value="prompt"}return C}});return l(),g?{state:c,isSupported:y,query:l}:c}function Oo(f={}){const{navigator:r=lr,read:g=!1,source:_,copiedDuring:y=1500,legacy:C=!1}=f,T=hr(()=>r&&"clipboard"in r),c=en("clipboard-read"),i=en("clipboard-write"),l=ar(()=>T.value||C),a=Ut(""),t=Ut(!1),n=_o(()=>t.value=!1,y);function e(){T.value&&u(c.value)?r.clipboard.readText().then(d=>{a.value=d}):a.value=s()}l.value&&g&&cr(["copy","cut"],e);async function o(d=Te(_)){l.value&&d!=null&&(T.value&&u(i.value)?await r.clipboard.writeText(d):h(d),a.value=d,t.value=!0,n.start())}function h(d){const m=document.createElement("textarea");m.value=d??"",m.style.position="absolute",m.style.opacity="0",document.body.appendChild(m),m.select(),document.execCommand("copy"),m.remove()}function s(){var d,m,p;return(p=(m=(d=document?.getSelection)==null?void 0:d.call(document))==null?void 0:m.toString())!=null?p:""}function u(d){return d==="granted"||d==="prompt"}return{isSupported:l,text:a,copied:t,copy:o}}const Eo={multiple:!0,accept:"*",reset:!1,directory:!1};function Po(f={}){const{document:r=bo}=f,g=Ut(null),{on:_,trigger:y}=uo();let C;r&&(C=r.createElement("input"),C.type="file",C.onchange=i=>{const l=i.target;g.value=l.files,y(g.value)});const T=()=>{g.value=null,C&&C.value&&(C.value="",y(null))},c=i=>{if(!C)return;const l={...Eo,...f,...i};C.multiple=l.multiple,C.accept=l.accept,C.webkitdirectory=l.directory,mo(l,"capture")&&(C.capture=l.capture),l.reset&&T(),C.click()};return{files:ye(g),open:c,reset:T,onChange:_}}function ko(f){return xo(f).promise.value}function ur(f){return new Promise(r=>{const{onChange:g,open:_}=Po(f);g(y=>{r(y)}),_()})}function Ao(f){return new Promise(r=>{const g=document.createElement("img");g.src=f,document.body.appendChild(g),g.onload=()=>{r(g)}})}const ki=(f,r)=>Oo({source:f,...r}).copy();function Re(f,r){const g=document.createElement("a");g.href=f,g.download=`${On()}.${r}`,document.body.appendChild(g),g.click(),g.remove()}function Do(f,r,g,_,y,C,T){T!==void 0&&(f.save(),f.translate(r,g),f.rotate(T),f.drawImage(_,-y/2,-C/2,y,C),f.restore())}const Mo=f=>f instanceof fabric.Image,Lo=f=>f instanceof fabric.Group,Fo=f=>f instanceof fabric.IText,Ro=f=>f instanceof fabric.ActiveSelection;function Io(f){return new Promise(r=>{const g=new FileReader;g.addEventListener("load",()=>{r(g.result)}),g.readAsDataURL(f)})}function jo(f){if(!f)return null;const r=f.split(","),g=r[0].match(/:(.*?);/)[1],_=window.atob(r[1]),y=new ArrayBuffer(_.length),C=new Uint8Array(y);for(let T=0;T<_.length;T++)C[T]=_.charCodeAt(T);return[new Blob([y],{type:g}),g.slice(6)]}const fr={getImgStr:ko,downFile:Re,selectFiles:ur,insertImgFile:Ao,clipboardText:ki,drawImg:Do,isImage:Mo,isGroup:Lo,isIText:Fo,isActiveSelection:Ro,blobToBase64:Io,base64ToBlob:jo};var si={};const Bo={},Ho=Object.freeze(Object.defineProperty({__proto__:null,default:Bo},Symbol.toStringTag,{value:"Module"})),oi=yr(Ho);var nn;function No(){return nn||(nn=1,(function(f){var r=r||{version:"5.3.0"};if(f.fabric=r,typeof document<"u"&&typeof window<"u")document instanceof(typeof HTMLDocument<"u"?HTMLDocument:Document)?r.document=document:r.document=document.implementation.createHTMLDocument(""),r.window=window;else{var g=oi,_=new g.JSDOM(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;r.document=_.document,r.jsdomImplForWrapper=oi.implForWrapper,r.nodeCanvas=oi.Canvas,r.window=_,DOMParser=r.window.DOMParser}r.isTouchSupported="ontouchstart"in r.window||"ontouchstart"in r.document||r.window&&r.window.navigator&&r.window.navigator.maxTouchPoints>0,r.isLikelyNode=typeof Buffer<"u"&&typeof window>"u",r.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],r.DPI=96,r.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",r.commaWsp="(?:\\s+,?\\s*|,\\s*)",r.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/ig,r.reNonWord=/[ \n\.,;!\?\-]/,r.fontPaths={},r.iMatrix=[1,0,0,1,0,0],r.svgNS="http://www.w3.org/2000/svg",r.perfLimitSizeTotal=2097152,r.maxCacheSideLimit=4096,r.minCacheSideLimit=256,r.charWidthsCache={},r.textureSize=2048,r.disableStyleCopyPaste=!1,r.enableGLFiltering=!0,r.devicePixelRatio=r.window.devicePixelRatio||r.window.webkitDevicePixelRatio||r.window.mozDevicePixelRatio||1,r.browserShadowBlurConstant=1,r.arcToSegmentsCache={},r.boundsOfCurveCache={},r.cachesBoundsOfCurve=!0,r.forceGLPutImageData=!1,r.initFilterBackend=function(){if(r.enableGLFiltering&&r.isWebglSupported&&r.isWebglSupported(r.textureSize))return console.log("max texture size: "+r.maxTextureSize),new r.WebglFilterBackend({tileSize:r.textureSize});if(r.Canvas2dFilterBackend)return new r.Canvas2dFilterBackend},typeof document<"u"&&typeof window<"u"&&(window.fabric=r),(function(){function c(e,o){if(this.__eventListeners[e]){var h=this.__eventListeners[e];o?h[h.indexOf(o)]=!1:r.util.array.fill(h,!1)}}function i(e,o){if(this.__eventListeners||(this.__eventListeners={}),arguments.length===1)for(var h in e)this.on(h,e[h]);else this.__eventListeners[e]||(this.__eventListeners[e]=[]),this.__eventListeners[e].push(o);return this}function l(e,o){var h=(function(){o.apply(this,arguments),this.off(e,h)}).bind(this);this.on(e,h)}function a(e,o){if(arguments.length===1)for(var h in e)l.call(this,h,e[h]);else l.call(this,e,o);return this}function t(e,o){if(!this.__eventListeners)return this;if(arguments.length===0)for(e in this.__eventListeners)c.call(this,e);else if(arguments.length===1&&typeof arguments[0]=="object")for(var h in e)c.call(this,h,e[h]);else c.call(this,e,o);return this}function n(e,o){if(!this.__eventListeners)return this;var h=this.__eventListeners[e];if(!h)return this;for(var s=0,u=h.length;s<u;s++)h[s]&&h[s].call(this,o||{});return this.__eventListeners[e]=h.filter(function(d){return d!==!1}),this}r.Observable={fire:n,on:i,once:a,off:t}})(),r.Collection={_objects:[],add:function(){if(this._objects.push.apply(this._objects,arguments),this._onObjectAdded)for(var c=0,i=arguments.length;c<i;c++)this._onObjectAdded(arguments[c]);return this.renderOnAddRemove&&this.requestRenderAll(),this},insertAt:function(c,i,l){var a=this._objects;return l?a[i]=c:a.splice(i,0,c),this._onObjectAdded&&this._onObjectAdded(c),this.renderOnAddRemove&&this.requestRenderAll(),this},remove:function(){for(var c=this._objects,i,l=!1,a=0,t=arguments.length;a<t;a++)i=c.indexOf(arguments[a]),i!==-1&&(l=!0,c.splice(i,1),this._onObjectRemoved&&this._onObjectRemoved(arguments[a]));return this.renderOnAddRemove&&l&&this.requestRenderAll(),this},forEachObject:function(c,i){for(var l=this.getObjects(),a=0,t=l.length;a<t;a++)c.call(i,l[a],a,l);return this},getObjects:function(c){return typeof c>"u"?this._objects.concat():this._objects.filter(function(i){return i.type===c})},item:function(c){return this._objects[c]},isEmpty:function(){return this._objects.length===0},size:function(){return this._objects.length},contains:function(c,i){return this._objects.indexOf(c)>-1?!0:i?this._objects.some(function(l){return typeof l.contains=="function"&&l.contains(c,!0)}):!1},complexity:function(){return this._objects.reduce(function(c,i){return c+=i.complexity?i.complexity():0,c},0)}},r.CommonMethods={_setOptions:function(c){for(var i in c)this.set(i,c[i])},_initGradient:function(c,i){c&&c.colorStops&&!(c instanceof r.Gradient)&&this.set(i,new r.Gradient(c))},_initPattern:function(c,i,l){c&&c.source&&!(c instanceof r.Pattern)?this.set(i,new r.Pattern(c,l)):l&&l()},_setObject:function(c){for(var i in c)this._set(i,c[i])},set:function(c,i){return typeof c=="object"?this._setObject(c):this._set(c,i),this},_set:function(c,i){this[c]=i},toggle:function(c){var i=this.get(c);return typeof i=="boolean"&&this.set(c,!i),this},get:function(c){return this[c]}},(function(c){var i=Math.sqrt,l=Math.atan2,a=Math.pow,t=Math.PI/180,n=Math.PI/2;r.util={cos:function(e){if(e===0)return 1;e<0&&(e=-e);var o=e/n;switch(o){case 1:case 3:return 0;case 2:return-1}return Math.cos(e)},sin:function(e){if(e===0)return 0;var o=e/n,h=1;switch(e<0&&(h=-1),o){case 1:return h;case 2:return 0;case 3:return-h}return Math.sin(e)},removeFromArray:function(e,o){var h=e.indexOf(o);return h!==-1&&e.splice(h,1),e},getRandomInt:function(e,o){return Math.floor(Math.random()*(o-e+1))+e},degreesToRadians:function(e){return e*t},radiansToDegrees:function(e){return e/t},rotatePoint:function(e,o,h){var s=new r.Point(e.x-o.x,e.y-o.y),u=r.util.rotateVector(s,h);return new r.Point(u.x,u.y).addEquals(o)},rotateVector:function(e,o){var h=r.util.sin(o),s=r.util.cos(o),u=e.x*s-e.y*h,d=e.x*h+e.y*s;return{x:u,y:d}},createVector:function(e,o){return new r.Point(o.x-e.x,o.y-e.y)},calcAngleBetweenVectors:function(e,o){return Math.acos((e.x*o.x+e.y*o.y)/(Math.hypot(e.x,e.y)*Math.hypot(o.x,o.y)))},getHatVector:function(e){return new r.Point(e.x,e.y).multiply(1/Math.hypot(e.x,e.y))},getBisector:function(e,o,h){var s=r.util.createVector(e,o),u=r.util.createVector(e,h),d=r.util.calcAngleBetweenVectors(s,u),m=r.util.calcAngleBetweenVectors(r.util.rotateVector(s,d),u),p=d*(m===0?1:-1)/2;return{vector:r.util.getHatVector(r.util.rotateVector(s,p)),angle:d}},projectStrokeOnPoints:function(e,o,h){var s=[],u=o.strokeWidth/2,d=o.strokeUniform?new r.Point(1/o.scaleX,1/o.scaleY):new r.Point(1,1),m=function(p){var v=u/Math.hypot(p.x,p.y);return new r.Point(p.x*v*d.x,p.y*v*d.y)};return e.length<=1||e.forEach(function(p,v){var b=new r.Point(p.x,p.y),S,E;v===0?(E=e[v+1],S=h?m(r.util.createVector(E,b)).addEquals(b):e[e.length-1]):v===e.length-1?(S=e[v-1],E=h?m(r.util.createVector(S,b)).addEquals(b):e[0]):(S=e[v-1],E=e[v+1]);var F=r.util.getBisector(b,S,E),R=F.vector,z=F.angle,K,Z;if(o.strokeLineJoin==="miter"&&(K=-u/Math.sin(z/2),Z=new r.Point(R.x*K*d.x,R.y*K*d.y),Math.hypot(Z.x,Z.y)/u<=o.strokeMiterLimit)){s.push(b.add(Z)),s.push(b.subtract(Z));return}K=-u*Math.SQRT2,Z=new r.Point(R.x*K*d.x,R.y*K*d.y),s.push(b.add(Z)),s.push(b.subtract(Z))}),s},transformPoint:function(e,o,h){return h?new r.Point(o[0]*e.x+o[2]*e.y,o[1]*e.x+o[3]*e.y):new r.Point(o[0]*e.x+o[2]*e.y+o[4],o[1]*e.x+o[3]*e.y+o[5])},makeBoundingBoxFromPoints:function(e,o){if(o)for(var h=0;h<e.length;h++)e[h]=r.util.transformPoint(e[h],o);var s=[e[0].x,e[1].x,e[2].x,e[3].x],u=r.util.array.min(s),d=r.util.array.max(s),m=d-u,p=[e[0].y,e[1].y,e[2].y,e[3].y],v=r.util.array.min(p),b=r.util.array.max(p),S=b-v;return{left:u,top:v,width:m,height:S}},invertTransform:function(e){var o=1/(e[0]*e[3]-e[1]*e[2]),h=[o*e[3],-o*e[1],-o*e[2],o*e[0]],s=r.util.transformPoint({x:e[4],y:e[5]},h,!0);return h[4]=-s.x,h[5]=-s.y,h},toFixed:function(e,o){return parseFloat(Number(e).toFixed(o))},parseUnit:function(e,o){var h=/\D{0,2}$/.exec(e),s=parseFloat(e);switch(o||(o=r.Text.DEFAULT_SVG_FONT_SIZE),h[0]){case"mm":return s*r.DPI/25.4;case"cm":return s*r.DPI/2.54;case"in":return s*r.DPI;case"pt":return s*r.DPI/72;case"pc":return s*r.DPI/72*12;case"em":return s*o;default:return s}},falseFunction:function(){return!1},getKlass:function(e,o){return e=r.util.string.camelize(e.charAt(0).toUpperCase()+e.slice(1)),r.util.resolveNamespace(o)[e]},getSvgAttributes:function(e){var o=["instantiated_by_use","style","id","class"];switch(e){case"linearGradient":o=o.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);break;case"radialGradient":o=o.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);break;case"stop":o=o.concat(["offset","stop-color","stop-opacity"]);break}return o},resolveNamespace:function(e){if(!e)return r;var o=e.split("."),h=o.length,s,u=c||r.window;for(s=0;s<h;++s)u=u[o[s]];return u},loadImage:function(e,o,h,s){if(!e){o&&o.call(h,e);return}var u=r.util.createImage(),d=function(){o&&o.call(h,u,!1),u=u.onload=u.onerror=null};u.onload=d,u.onerror=function(){r.log("Error loading "+u.src),o&&o.call(h,null,!0),u=u.onload=u.onerror=null},e.indexOf("data")!==0&&s!==void 0&&s!==null&&(u.crossOrigin=s),e.substring(0,14)==="data:image/svg"&&(u.onload=null,r.util.loadImageInDom(u,d)),u.src=e},loadImageInDom:function(e,o){var h=r.document.createElement("div");h.style.width=h.style.height="1px",h.style.left=h.style.top="-100%",h.style.position="absolute",h.appendChild(e),r.document.querySelector("body").appendChild(h),e.onload=function(){o(),h.parentNode.removeChild(h),h=null}},enlivenObjects:function(e,o,h,s){e=e||[];var u=[],d=0,m=e.length;function p(){++d===m&&o&&o(u.filter(function(v){return v}))}if(!m){o&&o(u);return}e.forEach(function(v,b){if(!v||!v.type){p();return}var S=r.util.getKlass(v.type,h);S.fromObject(v,function(E,F){F||(u[b]=E),s&&s(v,E,F),p()})})},enlivenObjectEnlivables:function(e,o,h){var s=r.Object.ENLIVEN_PROPS.filter(function(u){return!!e[u]});r.util.enlivenObjects(s.map(function(u){return e[u]}),function(u){var d={};s.forEach(function(m,p){d[m]=u[p],o&&(o[m]=u[p])}),h&&h(d)})},enlivenPatterns:function(e,o){e=e||[];function h(){++u===d&&o&&o(s)}var s=[],u=0,d=e.length;if(!d){o&&o(s);return}e.forEach(function(m,p){m&&m.source?new r.Pattern(m,function(v){s[p]=v,h()}):(s[p]=m,h())})},groupSVGElements:function(e,o,h){var s;return e&&e.length===1?(typeof h<"u"&&(e[0].sourcePath=h),e[0]):(o&&(o.width&&o.height?o.centerPoint={x:o.width/2,y:o.height/2}:(delete o.width,delete o.height)),s=new r.Group(e,o),typeof h<"u"&&(s.sourcePath=h),s)},populateWithProperties:function(e,o,h){if(h&&Array.isArray(h))for(var s=0,u=h.length;s<u;s++)h[s]in e&&(o[h[s]]=e[h[s]])},createCanvasElement:function(){return r.document.createElement("canvas")},copyCanvasElement:function(e){var o=r.util.createCanvasElement();return o.width=e.width,o.height=e.height,o.getContext("2d").drawImage(e,0,0),o},toDataURL:function(e,o,h){return e.toDataURL("image/"+o,h)},createImage:function(){return r.document.createElement("img")},multiplyTransformMatrices:function(e,o,h){return[e[0]*o[0]+e[2]*o[1],e[1]*o[0]+e[3]*o[1],e[0]*o[2]+e[2]*o[3],e[1]*o[2]+e[3]*o[3],h?0:e[0]*o[4]+e[2]*o[5]+e[4],h?0:e[1]*o[4]+e[3]*o[5]+e[5]]},qrDecompose:function(e){var o=l(e[1],e[0]),h=a(e[0],2)+a(e[1],2),s=i(h),u=(e[0]*e[3]-e[2]*e[1])/s,d=l(e[0]*e[2]+e[1]*e[3],h);return{angle:o/t,scaleX:s,scaleY:u,skewX:d/t,skewY:0,translateX:e[4],translateY:e[5]}},calcRotateMatrix:function(e){if(!e.angle)return r.iMatrix.concat();var o=r.util.degreesToRadians(e.angle),h=r.util.cos(o),s=r.util.sin(o);return[h,s,-s,h,0,0]},calcDimensionsMatrix:function(e){var o=typeof e.scaleX>"u"?1:e.scaleX,h=typeof e.scaleY>"u"?1:e.scaleY,s=[e.flipX?-o:o,0,0,e.flipY?-h:h,0,0],u=r.util.multiplyTransformMatrices,d=r.util.degreesToRadians;return e.skewX&&(s=u(s,[1,0,Math.tan(d(e.skewX)),1],!0)),e.skewY&&(s=u(s,[1,Math.tan(d(e.skewY)),0,1],!0)),s},composeMatrix:function(e){var o=[1,0,0,1,e.translateX||0,e.translateY||0],h=r.util.multiplyTransformMatrices;return e.angle&&(o=h(o,r.util.calcRotateMatrix(e))),(e.scaleX!==1||e.scaleY!==1||e.skewX||e.skewY||e.flipX||e.flipY)&&(o=h(o,r.util.calcDimensionsMatrix(e))),o},resetObjectTransform:function(e){e.scaleX=1,e.scaleY=1,e.skewX=0,e.skewY=0,e.flipX=!1,e.flipY=!1,e.rotate(0)},saveObjectTransform:function(e){return{scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,angle:e.angle,left:e.left,flipX:e.flipX,flipY:e.flipY,top:e.top}},isTransparent:function(e,o,h,s){s>0&&(o>s?o-=s:o=0,h>s?h-=s:h=0);var u=!0,d,m,p=e.getImageData(o,h,s*2||1,s*2||1),v=p.data.length;for(d=3;d<v&&(m=p.data[d],u=m<=0,u!==!1);d+=4);return p=null,u},parsePreserveAspectRatioAttribute:function(e){var o="meet",h="Mid",s="Mid",u=e.split(" "),d;return u&&u.length&&(o=u.pop(),o!=="meet"&&o!=="slice"?(d=o,o="meet"):u.length&&(d=u.pop())),h=d!=="none"?d.slice(1,4):"none",s=d!=="none"?d.slice(5,8):"none",{meetOrSlice:o,alignX:h,alignY:s}},clearFabricFontCache:function(e){e=(e||"").toLowerCase(),e?r.charWidthsCache[e]&&delete r.charWidthsCache[e]:r.charWidthsCache={}},limitDimsByArea:function(e,o){var h=Math.sqrt(o*e),s=Math.floor(o/h);return{x:Math.floor(h),y:s}},capValue:function(e,o,h){return Math.max(e,Math.min(o,h))},findScaleToFit:function(e,o){return Math.min(o.width/e.width,o.height/e.height)},findScaleToCover:function(e,o){return Math.max(o.width/e.width,o.height/e.height)},matrixToSVG:function(e){return"matrix("+e.map(function(o){return r.util.toFixed(o,r.Object.NUM_FRACTION_DIGITS)}).join(" ")+")"},removeTransformFromObject:function(e,o){var h=r.util.invertTransform(o),s=r.util.multiplyTransformMatrices(h,e.calcOwnMatrix());r.util.applyTransformToObject(e,s)},addTransformToObject:function(e,o){r.util.applyTransformToObject(e,r.util.multiplyTransformMatrices(o,e.calcOwnMatrix()))},applyTransformToObject:function(e,o){var h=r.util.qrDecompose(o),s=new r.Point(h.translateX,h.translateY);e.flipX=!1,e.flipY=!1,e.set("scaleX",h.scaleX),e.set("scaleY",h.scaleY),e.skewX=h.skewX,e.skewY=h.skewY,e.angle=h.angle,e.setPositionByOrigin(s,"center","center")},sizeAfterTransform:function(e,o,h){var s=e/2,u=o/2,d=[{x:-s,y:-u},{x:s,y:-u},{x:-s,y:u},{x:s,y:u}],m=r.util.calcDimensionsMatrix(h),p=r.util.makeBoundingBoxFromPoints(d,m);return{x:p.width,y:p.height}},mergeClipPaths:function(e,o){var h=e,s=o;h.inverted&&!s.inverted&&(h=o,s=e),r.util.applyTransformToObject(s,r.util.multiplyTransformMatrices(r.util.invertTransform(h.calcTransformMatrix()),s.calcTransformMatrix()));var u=h.inverted&&s.inverted;return u&&(h.inverted=s.inverted=!1),new r.Group([h],{clipPath:s,inverted:u})},hasStyleChanged:function(e,o,h){return h=h||!1,e.fill!==o.fill||e.stroke!==o.stroke||e.strokeWidth!==o.strokeWidth||e.fontSize!==o.fontSize||e.fontFamily!==o.fontFamily||e.fontWeight!==o.fontWeight||e.fontStyle!==o.fontStyle||e.textBackgroundColor!==o.textBackgroundColor||e.deltaY!==o.deltaY||h&&(e.overline!==o.overline||e.underline!==o.underline||e.linethrough!==o.linethrough)},stylesToArray:function(h,o){for(var h=r.util.object.clone(h,!0),s=o.split(`
6
+ `),u=-1,d={},m=[],p=0;p<s.length;p++){if(!h[p]){u+=s[p].length;continue}for(var v=0;v<s[p].length;v++){u++;var b=h[p][v];if(b&&Object.keys(b).length>0){var S=r.util.hasStyleChanged(d,b,!0);S?m.push({start:u,end:u+1,style:b}):m[m.length-1].end++}d=b||{}}}return m},stylesFromArray:function(e,o){if(!Array.isArray(e))return e;for(var h=o.split(`
7
+ `),s=-1,u=0,d={},m=0;m<h.length;m++)for(var p=0;p<h[m].length;p++)s++,e[u]&&e[u].start<=s&&s<e[u].end&&(d[m]=d[m]||{},d[m][p]=Object.assign({},e[u].style),s===e[u].end-1&&u++);return d}}})(f),(function(){var c=Array.prototype.join,i={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},l={m:"l",M:"L"};function a(w,k,A,P,I,O,x,D,L,N,j){var V=r.util.cos(w),G=r.util.sin(w),J=r.util.cos(k),B=r.util.sin(k),M=A*I*J-P*O*B+x,X=P*I*J+A*O*B+D,Y=N+L*(-A*I*G-P*O*V),H=j+L*(-P*I*G+A*O*V),U=M+L*(A*I*B+P*O*J),Q=X+L*(P*I*B-A*O*J);return["C",Y,H,U,Q,M,X]}function t(w,k,A,P,I,O,x){var D=Math.PI,L=x*D/180,N=r.util.sin(L),j=r.util.cos(L),V=0,G=0;A=Math.abs(A),P=Math.abs(P);var J=-j*w*.5-N*k*.5,B=-j*k*.5+N*w*.5,M=A*A,X=P*P,Y=B*B,H=J*J,U=M*X-M*Y-X*H,Q=0;if(U<0){var st=Math.sqrt(1-U/(M*X));A*=st,P*=st}else Q=(I===O?-1:1)*Math.sqrt(U/(M*Y+X*H));var nt=Q*A*B/P,W=-Q*P*J/A,rt=j*nt-N*W+w*.5,ot=N*nt+j*W+k*.5,lt=n(1,0,(J-nt)/A,(B-W)/P),ut=n((J-nt)/A,(B-W)/P,(-J-nt)/A,(-B-W)/P);O===0&&ut>0?ut-=2*D:O===1&&ut<0&&(ut+=2*D);for(var ht=Math.ceil(Math.abs(ut/D*2)),bt=[],dt=ut/ht,zt=8/3*Math.sin(dt/4)*Math.sin(dt/4)/Math.sin(dt/2),le=lt+dt,kt=0;kt<ht;kt++)bt[kt]=a(lt,le,j,N,A,P,rt,ot,zt,V,G),V=bt[kt][5],G=bt[kt][6],lt=le,le+=dt;return bt}function n(w,k,A,P){var I=Math.atan2(k,w),O=Math.atan2(P,A);return O>=I?O-I:2*Math.PI-(I-O)}function e(w,k,A,P,I,O,x,D){var L;if(r.cachesBoundsOfCurve&&(L=c.call(arguments),r.boundsOfCurveCache[L]))return r.boundsOfCurveCache[L];var N=Math.sqrt,j=Math.min,V=Math.max,G=Math.abs,J=[],B=[[],[]],M,X,Y,H,U,Q,st,nt;X=6*w-12*A+6*I,M=-3*w+9*A-9*I+3*x,Y=3*A-3*w;for(var W=0;W<2;++W){if(W>0&&(X=6*k-12*P+6*O,M=-3*k+9*P-9*O+3*D,Y=3*P-3*k),G(M)<1e-12){if(G(X)<1e-12)continue;H=-Y/X,0<H&&H<1&&J.push(H);continue}st=X*X-4*Y*M,!(st<0)&&(nt=N(st),U=(-X+nt)/(2*M),0<U&&U<1&&J.push(U),Q=(-X-nt)/(2*M),0<Q&&Q<1&&J.push(Q))}for(var rt,ot,lt=J.length,ut=lt,ht;lt--;)H=J[lt],ht=1-H,rt=ht*ht*ht*w+3*ht*ht*H*A+3*ht*H*H*I+H*H*H*x,B[0][lt]=rt,ot=ht*ht*ht*k+3*ht*ht*H*P+3*ht*H*H*O+H*H*H*D,B[1][lt]=ot;B[0][ut]=w,B[1][ut]=k,B[0][ut+1]=x,B[1][ut+1]=D;var bt=[{x:j.apply(null,B[0]),y:j.apply(null,B[1])},{x:V.apply(null,B[0]),y:V.apply(null,B[1])}];return r.cachesBoundsOfCurve&&(r.boundsOfCurveCache[L]=bt),bt}function o(w,k,A){for(var P=A[1],I=A[2],O=A[3],x=A[4],D=A[5],L=A[6],N=A[7],j=t(L-w,N-k,P,I,x,D,O),V=0,G=j.length;V<G;V++)j[V][1]+=w,j[V][2]+=k,j[V][3]+=w,j[V][4]+=k,j[V][5]+=w,j[V][6]+=k;return j}function h(w){var k=0,A=0,P=w.length,I=0,O=0,x,D,L,N=[],j,V,G;for(D=0;D<P;++D){switch(L=!1,x=w[D].slice(0),x[0]){case"l":x[0]="L",x[1]+=k,x[2]+=A;case"L":k=x[1],A=x[2];break;case"h":x[1]+=k;case"H":x[0]="L",x[2]=A,k=x[1];break;case"v":x[1]+=A;case"V":x[0]="L",A=x[1],x[1]=k,x[2]=A;break;case"m":x[0]="M",x[1]+=k,x[2]+=A;case"M":k=x[1],A=x[2],I=x[1],O=x[2];break;case"c":x[0]="C",x[1]+=k,x[2]+=A,x[3]+=k,x[4]+=A,x[5]+=k,x[6]+=A;case"C":V=x[3],G=x[4],k=x[5],A=x[6];break;case"s":x[0]="S",x[1]+=k,x[2]+=A,x[3]+=k,x[4]+=A;case"S":j==="C"?(V=2*k-V,G=2*A-G):(V=k,G=A),k=x[3],A=x[4],x[0]="C",x[5]=x[3],x[6]=x[4],x[3]=x[1],x[4]=x[2],x[1]=V,x[2]=G,V=x[3],G=x[4];break;case"q":x[0]="Q",x[1]+=k,x[2]+=A,x[3]+=k,x[4]+=A;case"Q":V=x[1],G=x[2],k=x[3],A=x[4];break;case"t":x[0]="T",x[1]+=k,x[2]+=A;case"T":j==="Q"?(V=2*k-V,G=2*A-G):(V=k,G=A),x[0]="Q",k=x[1],A=x[2],x[1]=V,x[2]=G,x[3]=k,x[4]=A;break;case"a":x[0]="A",x[6]+=k,x[7]+=A;case"A":L=!0,N=N.concat(o(k,A,x)),k=x[6],A=x[7];break;case"z":case"Z":k=I,A=O;break}L||N.push(x),j=x[0]}return N}function s(w,k,A,P){return Math.sqrt((A-w)*(A-w)+(P-k)*(P-k))}function u(w){return w*w*w}function d(w){return 3*w*w*(1-w)}function m(w){return 3*w*(1-w)*(1-w)}function p(w){return(1-w)*(1-w)*(1-w)}function v(w,k,A,P,I,O,x,D){return function(L){var N=u(L),j=d(L),V=m(L),G=p(L);return{x:x*N+I*j+A*V+w*G,y:D*N+O*j+P*V+k*G}}}function b(w,k,A,P,I,O,x,D){return function(L){var N=1-L,j=3*N*N*(A-w)+6*N*L*(I-A)+3*L*L*(x-I),V=3*N*N*(P-k)+6*N*L*(O-P)+3*L*L*(D-O);return Math.atan2(V,j)}}function S(w){return w*w}function E(w){return 2*w*(1-w)}function F(w){return(1-w)*(1-w)}function R(w,k,A,P,I,O){return function(x){var D=S(x),L=E(x),N=F(x);return{x:I*D+A*L+w*N,y:O*D+P*L+k*N}}}function z(w,k,A,P,I,O){return function(x){var D=1-x,L=2*D*(A-w)+2*x*(I-A),N=2*D*(P-k)+2*x*(O-P);return Math.atan2(N,L)}}function K(w,k,A){var P={x:k,y:A},I,O=0,x;for(x=1;x<=100;x+=1)I=w(x/100),O+=s(P.x,P.y,I.x,I.y),P=I;return O}function Z(w,k){for(var A=0,P=0,I=w.iterator,O={x:w.x,y:w.y},x,D,L=.01,N=w.angleFinder,j;P<k&&L>1e-4;)x=I(A),j=A,D=s(O.x,O.y,x.x,x.y),D+P>k?(A-=L,L/=2):(O=x,A+=L,P+=D);return x.angle=N(j),x}function q(w){for(var k=0,A=w.length,P,I=0,O=0,x=0,D=0,L=[],N,j,V,G=0;G<A;G++){switch(P=w[G],j={x:I,y:O,command:P[0]},P[0]){case"M":j.length=0,x=I=P[1],D=O=P[2];break;case"L":j.length=s(I,O,P[1],P[2]),I=P[1],O=P[2];break;case"C":N=v(I,O,P[1],P[2],P[3],P[4],P[5],P[6]),V=b(I,O,P[1],P[2],P[3],P[4],P[5],P[6]),j.iterator=N,j.angleFinder=V,j.length=K(N,I,O),I=P[5],O=P[6];break;case"Q":N=R(I,O,P[1],P[2],P[3],P[4]),V=z(I,O,P[1],P[2],P[3],P[4]),j.iterator=N,j.angleFinder=V,j.length=K(N,I,O),I=P[3],O=P[4];break;case"Z":case"z":j.destX=x,j.destY=D,j.length=s(I,O,x,D),I=x,O=D;break}k+=j.length,L.push(j)}return L.push({length:k,x:I,y:O}),L}function $(w,k,A){A||(A=q(w));for(var P=0;k-A[P].length>0&&P<A.length-2;)k-=A[P].length,P++;var I=A[P],O=k/I.length,x=I.command,D=w[P],L;switch(x){case"M":return{x:I.x,y:I.y,angle:0};case"Z":case"z":return L=new r.Point(I.x,I.y).lerp(new r.Point(I.destX,I.destY),O),L.angle=Math.atan2(I.destY-I.y,I.destX-I.x),L;case"L":return L=new r.Point(I.x,I.y).lerp(new r.Point(D[1],D[2]),O),L.angle=Math.atan2(D[2]-I.y,D[1]-I.x),L;case"C":return Z(I,k);case"Q":return Z(I,k)}}function tt(w){var k=[],A=[],P,I,O=r.rePathCommand,x="[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?\\s*",D="("+x+")"+r.commaWsp,L="([01])"+r.commaWsp+"?",N=D+"?"+D+"?"+D+L+L+D+"?("+x+")",j=new RegExp(N,"g"),V,G,J;if(!w||!w.match)return k;J=w.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi);for(var B=0,M,X=J.length;B<X;B++){P=J[B],G=P.slice(1).trim(),A.length=0;var Y=P.charAt(0);if(M=[Y],Y.toLowerCase()==="a")for(var H;H=j.exec(G);)for(var U=1;U<H.length;U++)A.push(H[U]);else for(;V=O.exec(G);)A.push(V[0]);for(var U=0,Q=A.length;U<Q;U++)I=parseFloat(A[U]),isNaN(I)||M.push(I);var st=i[Y.toLowerCase()],nt=l[Y]||Y;if(M.length-1>st)for(var W=1,rt=M.length;W<rt;W+=st)k.push([Y].concat(M.slice(W,W+st))),Y=nt;else k.push(M)}return k}function it(w,k){var A=[],P,I=new r.Point(w[0].x,w[0].y),O=new r.Point(w[1].x,w[1].y),x=w.length,D=1,L=0,N=x>2;for(k=k||0,N&&(D=w[2].x<O.x?-1:w[2].x===O.x?0:1,L=w[2].y<O.y?-1:w[2].y===O.y?0:1),A.push(["M",I.x-D*k,I.y-L*k]),P=1;P<x;P++){if(!I.eq(O)){var j=I.midPointFrom(O);A.push(["Q",I.x,I.y,j.x,j.y])}I=w[P],P+1<w.length&&(O=w[P+1])}return N&&(D=I.x>w[P-2].x?1:I.x===w[P-2].x?0:-1,L=I.y>w[P-2].y?1:I.y===w[P-2].y?0:-1),A.push(["L",I.x+D*k,I.y+L*k]),A}function et(w,k,A){return A&&(k=r.util.multiplyTransformMatrices(k,[1,0,0,1,-A.x,-A.y])),w.map(function(P){for(var I=P.slice(0),O={},x=1;x<P.length-1;x+=2)O.x=P[x],O.y=P[x+1],O=r.util.transformPoint(O,k),I[x]=O.x,I[x+1]=O.y;return I})}r.util.joinPath=function(w){return w.map(function(k){return k.join(" ")}).join(" ")},r.util.parsePath=tt,r.util.makePathSimpler=h,r.util.getSmoothPathFromPoints=it,r.util.getPathSegmentsInfo=q,r.util.getBoundsOfCurve=e,r.util.getPointOnPath=$,r.util.transformPath=et})(),(function(){var c=Array.prototype.slice;function i(e,o){for(var h=c.call(arguments,2),s=[],u=0,d=e.length;u<d;u++)s[u]=h.length?e[u][o].apply(e[u],h):e[u][o].call(e[u]);return s}function l(e,o){return n(e,o,function(h,s){return h>=s})}function a(e,o){return n(e,o,function(h,s){return h<s})}function t(e,o){for(var h=e.length;h--;)e[h]=o;return e}function n(e,o,h){if(!(!e||e.length===0)){var s=e.length-1,u=o?e[s][o]:e[s];if(o)for(;s--;)h(e[s][o],u)&&(u=e[s][o]);else for(;s--;)h(e[s],u)&&(u=e[s]);return u}}r.util.array={fill:t,invoke:i,min:a,max:l}})(),(function(){function c(l,a,t){if(t)if(!r.isLikelyNode&&a instanceof Element)l=a;else if(a instanceof Array){l=[];for(var n=0,e=a.length;n<e;n++)l[n]=c({},a[n],t)}else if(a&&typeof a=="object")for(var o in a)o==="canvas"||o==="group"?l[o]=null:a.hasOwnProperty(o)&&(l[o]=c({},a[o],t));else l=a;else for(var o in a)l[o]=a[o];return l}function i(l,a){return c({},l,a)}r.util.object={extend:c,clone:i},r.util.object.extend(r.util,r.Observable)})(),(function(){function c(n){return n.replace(/-+(.)?/g,function(e,o){return o?o.toUpperCase():""})}function i(n,e){return n.charAt(0).toUpperCase()+(e?n.slice(1):n.slice(1).toLowerCase())}function l(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function a(n){var e=0,o,h=[];for(e=0,o;e<n.length;e++)(o=t(n,e))!==!1&&h.push(o);return h}function t(n,e){var o=n.charCodeAt(e);if(isNaN(o))return"";if(o<55296||o>57343)return n.charAt(e);if(55296<=o&&o<=56319){if(n.length<=e+1)throw"High surrogate without following low surrogate";var h=n.charCodeAt(e+1);if(56320>h||h>57343)throw"High surrogate without following low surrogate";return n.charAt(e)+n.charAt(e+1)}if(e===0)throw"Low surrogate without preceding high surrogate";var s=n.charCodeAt(e-1);if(55296>s||s>56319)throw"Low surrogate without preceding high surrogate";return!1}r.util.string={camelize:c,capitalize:i,escapeXml:l,graphemeSplit:a}})(),(function(){var c=Array.prototype.slice,i=function(){},l=(function(){for(var o in{toString:1})if(o==="toString")return!1;return!0})(),a=function(o,h,s){for(var u in h)u in o.prototype&&typeof o.prototype[u]=="function"&&(h[u]+"").indexOf("callSuper")>-1?o.prototype[u]=(function(d){return function(){var m=this.constructor.superclass;this.constructor.superclass=s;var p=h[d].apply(this,arguments);if(this.constructor.superclass=m,d!=="initialize")return p}})(u):o.prototype[u]=h[u],l&&(h.toString!==Object.prototype.toString&&(o.prototype.toString=h.toString),h.valueOf!==Object.prototype.valueOf&&(o.prototype.valueOf=h.valueOf))};function t(){}function n(o){for(var h=null,s=this;s.constructor.superclass;){var u=s.constructor.superclass.prototype[o];if(s[o]!==u){h=u;break}s=s.constructor.superclass.prototype}return h?arguments.length>1?h.apply(this,c.call(arguments,1)):h.call(this):console.log("tried to callSuper "+o+", method not found in prototype chain",this)}function e(){var o=null,h=c.call(arguments,0);typeof h[0]=="function"&&(o=h.shift());function s(){this.initialize.apply(this,arguments)}s.superclass=o,s.subclasses=[],o&&(t.prototype=o.prototype,s.prototype=new t,o.subclasses.push(s));for(var u=0,d=h.length;u<d;u++)a(s,h[u],o);return s.prototype.initialize||(s.prototype.initialize=i),s.prototype.constructor=s,s.prototype.callSuper=n,s}r.util.createClass=e})(),(function(){var c=!!r.document.createElement("div").attachEvent,i=["touchstart","touchmove","touchend"];r.util.addListener=function(a,t,n,e){a&&a.addEventListener(t,n,c?!1:e)},r.util.removeListener=function(a,t,n,e){a&&a.removeEventListener(t,n,c?!1:e)};function l(a){var t=a.changedTouches;return t&&t[0]?t[0]:a}r.util.getPointer=function(a){var t=a.target,n=r.util.getScrollLeftTop(t),e=l(a);return{x:e.clientX+n.left,y:e.clientY+n.top}},r.util.isTouchEvent=function(a){return i.indexOf(a.type)>-1||a.pointerType==="touch"}})(),(function(){function c(e,o){var h=e.style;if(!h)return e;if(typeof o=="string")return e.style.cssText+=";"+o,o.indexOf("opacity")>-1?n(e,o.match(/opacity:\s*(\d?\.?\d*)/)[1]):e;for(var s in o)if(s==="opacity")n(e,o[s]);else{var u=s==="float"||s==="cssFloat"?typeof h.styleFloat>"u"?"cssFloat":"styleFloat":s;h.setProperty(u,o[s])}return e}var i=r.document.createElement("div"),l=typeof i.style.opacity=="string",a=typeof i.style.filter=="string",t=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,n=function(e){return e};l?n=function(e,o){return e.style.opacity=o,e}:a&&(n=function(e,o){var h=e.style;return e.currentStyle&&!e.currentStyle.hasLayout&&(h.zoom=1),t.test(h.filter)?(o=o>=.9999?"":"alpha(opacity="+o*100+")",h.filter=h.filter.replace(t,o)):h.filter+=" alpha(opacity="+o*100+")",e}),r.util.setStyle=c})(),(function(){var c=Array.prototype.slice;function i(p){return typeof p=="string"?r.document.getElementById(p):p}var l,a=function(p){return c.call(p,0)};try{l=a(r.document.childNodes)instanceof Array}catch{}l||(a=function(p){for(var v=new Array(p.length),b=p.length;b--;)v[b]=p[b];return v});function t(p,v){var b=r.document.createElement(p);for(var S in v)S==="class"?b.className=v[S]:S==="for"?b.htmlFor=v[S]:b.setAttribute(S,v[S]);return b}function n(p,v){p&&(" "+p.className+" ").indexOf(" "+v+" ")===-1&&(p.className+=(p.className?" ":"")+v)}function e(p,v,b){return typeof v=="string"&&(v=t(v,b)),p.parentNode&&p.parentNode.replaceChild(v,p),v.appendChild(p),v}function o(p){for(var v=0,b=0,S=r.document.documentElement,E=r.document.body||{scrollLeft:0,scrollTop:0};p&&(p.parentNode||p.host)&&(p=p.parentNode||p.host,p===r.document?(v=E.scrollLeft||S.scrollLeft||0,b=E.scrollTop||S.scrollTop||0):(v+=p.scrollLeft||0,b+=p.scrollTop||0),!(p.nodeType===1&&p.style.position==="fixed")););return{left:v,top:b}}function h(p){var v,b=p&&p.ownerDocument,S={left:0,top:0},E={left:0,top:0},F,R={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!b)return E;for(var z in R)E[R[z]]+=parseInt(s(p,z),10)||0;return v=b.documentElement,typeof p.getBoundingClientRect<"u"&&(S=p.getBoundingClientRect()),F=o(p),{left:S.left+F.left-(v.clientLeft||0)+E.left,top:S.top+F.top-(v.clientTop||0)+E.top}}var s;r.document.defaultView&&r.document.defaultView.getComputedStyle?s=function(p,v){var b=r.document.defaultView.getComputedStyle(p,null);return b?b[v]:void 0}:s=function(p,v){var b=p.style[v];return!b&&p.currentStyle&&(b=p.currentStyle[v]),b},(function(){var p=r.document.documentElement.style,v="userSelect"in p?"userSelect":"MozUserSelect"in p?"MozUserSelect":"WebkitUserSelect"in p?"WebkitUserSelect":"KhtmlUserSelect"in p?"KhtmlUserSelect":"";function b(E){return typeof E.onselectstart<"u"&&(E.onselectstart=r.util.falseFunction),v?E.style[v]="none":typeof E.unselectable=="string"&&(E.unselectable="on"),E}function S(E){return typeof E.onselectstart<"u"&&(E.onselectstart=null),v?E.style[v]="":typeof E.unselectable=="string"&&(E.unselectable=""),E}r.util.makeElementUnselectable=b,r.util.makeElementSelectable=S})();function u(p){var v=r.jsdomImplForWrapper(p);return v._canvas||v._image}function d(p){if(r.isLikelyNode){var v=r.jsdomImplForWrapper(p);v&&(v._image=null,v._canvas=null,v._currentSrc=null,v._attributes=null,v._classList=null)}}function m(p,v){p.imageSmoothingEnabled=p.imageSmoothingEnabled||p.webkitImageSmoothingEnabled||p.mozImageSmoothingEnabled||p.msImageSmoothingEnabled||p.oImageSmoothingEnabled,p.imageSmoothingEnabled=v}r.util.setImageSmoothing=m,r.util.getById=i,r.util.toArray=a,r.util.addClass=n,r.util.makeElement=t,r.util.wrapElement=e,r.util.getScrollLeftTop=o,r.util.getElementOffset=h,r.util.getNodeCanvas=u,r.util.cleanUpJsdomNode=d})(),(function(){function c(a,t){return a+(/\?/.test(a)?"&":"?")+t}function i(){}function l(a,t){t||(t={});var n=t.method?t.method.toUpperCase():"GET",e=t.onComplete||function(){},o=new r.window.XMLHttpRequest,h=t.body||t.parameters;return o.onreadystatechange=function(){o.readyState===4&&(e(o),o.onreadystatechange=i)},n==="GET"&&(h=null,typeof t.parameters=="string"&&(a=c(a,t.parameters))),o.open(n,a,!0),(n==="POST"||n==="PUT")&&o.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),o.send(h),o}r.util.request=l})(),r.log=console.log,r.warn=console.warn,(function(){var c=r.util.object.extend,i=r.util.object.clone,l=[];r.util.object.extend(l,{cancelAll:function(){var u=this.splice(0);return u.forEach(function(d){d.cancel()}),u},cancelByCanvas:function(u){if(!u)return[];var d=this.filter(function(m){return typeof m.target=="object"&&m.target.canvas===u});return d.forEach(function(m){m.cancel()}),d},cancelByTarget:function(u){var d=this.findAnimationsByTarget(u);return d.forEach(function(m){m.cancel()}),d},findAnimationIndex:function(u){return this.indexOf(this.findAnimation(u))},findAnimation:function(u){return this.find(function(d){return d.cancel===u})},findAnimationsByTarget:function(u){return u?this.filter(function(d){return d.target===u}):[]}});function a(){return!1}function t(u,d,m,p){return-m*Math.cos(u/p*(Math.PI/2))+m+d}function n(u){u||(u={});var d=!1,m,p=function(){var v=r.runningAnimations.indexOf(m);return v>-1&&r.runningAnimations.splice(v,1)[0]};return m=c(i(u),{cancel:function(){return d=!0,p()},currentValue:"startValue"in u?u.startValue:0,completionRate:0,durationRate:0}),r.runningAnimations.push(m),h(function(v){var b=v||+new Date,S=u.duration||500,E=b+S,F,R=u.onChange||a,z=u.abort||a,K=u.onComplete||a,Z=u.easing||t,q="startValue"in u?u.startValue.length>0:!1,$="startValue"in u?u.startValue:0,tt="endValue"in u?u.endValue:100,it=u.byValue||(q?$.map(function(et,w){return tt[w]-$[w]}):tt-$);u.onStart&&u.onStart(),(function et(w){F=w||+new Date;var k=F>E?S:F-b,A=k/S,P=q?$.map(function(O,x){return Z(k,$[x],it[x],S)}):Z(k,$,it,S),I=Math.abs(q?(P[0]-$[0])/it[0]:(P-$)/it);if(m.currentValue=q?P.slice():P,m.completionRate=I,m.durationRate=A,!d){if(z(P,I,A)){p();return}if(F>E){m.currentValue=q?tt.slice():tt,m.completionRate=1,m.durationRate=1,R(q?tt.slice():tt,1,1),K(tt,1,1),p();return}else R(P,I,A),h(et)}})(b)}),m.cancel}var e=r.window.requestAnimationFrame||r.window.webkitRequestAnimationFrame||r.window.mozRequestAnimationFrame||r.window.oRequestAnimationFrame||r.window.msRequestAnimationFrame||function(u){return r.window.setTimeout(u,1e3/60)},o=r.window.cancelAnimationFrame||r.window.clearTimeout;function h(){return e.apply(r.window,arguments)}function s(){return o.apply(r.window,arguments)}r.util.animate=n,r.util.requestAnimFrame=h,r.util.cancelAnimFrame=s,r.runningAnimations=l})(),(function(){function c(l,a,t){var n="rgba("+parseInt(l[0]+t*(a[0]-l[0]),10)+","+parseInt(l[1]+t*(a[1]-l[1]),10)+","+parseInt(l[2]+t*(a[2]-l[2]),10);return n+=","+(l&&a?parseFloat(l[3]+t*(a[3]-l[3])):1),n+=")",n}function i(l,a,t,n){var e=new r.Color(l).getSource(),o=new r.Color(a).getSource(),h=n.onComplete,s=n.onChange;return n=n||{},r.util.animate(r.util.object.extend(n,{duration:t||500,startValue:e,endValue:o,byValue:o,easing:function(u,d,m,p){var v=n.colorEasing?n.colorEasing(u,p):1-Math.cos(u/p*(Math.PI/2));return c(d,m,v)},onComplete:function(u,d,m){if(h)return h(c(o,o,0),d,m)},onChange:function(u,d,m){if(s){if(Array.isArray(u))return s(c(u,u,0),d,m);s(u,d,m)}}}))}r.util.animateColor=i})(),(function(){function c(w,k,A,P){return w<Math.abs(k)?(w=k,P=A/4):k===0&&w===0?P=A/(2*Math.PI)*Math.asin(1):P=A/(2*Math.PI)*Math.asin(k/w),{a:w,c:k,p:A,s:P}}function i(w,k,A){return w.a*Math.pow(2,10*(k-=1))*Math.sin((k*A-w.s)*(2*Math.PI)/w.p)}function l(w,k,A,P){return A*((w=w/P-1)*w*w+1)+k}function a(w,k,A,P){return w/=P/2,w<1?A/2*w*w*w+k:A/2*((w-=2)*w*w+2)+k}function t(w,k,A,P){return A*(w/=P)*w*w*w+k}function n(w,k,A,P){return-A*((w=w/P-1)*w*w*w-1)+k}function e(w,k,A,P){return w/=P/2,w<1?A/2*w*w*w*w+k:-A/2*((w-=2)*w*w*w-2)+k}function o(w,k,A,P){return A*(w/=P)*w*w*w*w+k}function h(w,k,A,P){return A*((w=w/P-1)*w*w*w*w+1)+k}function s(w,k,A,P){return w/=P/2,w<1?A/2*w*w*w*w*w+k:A/2*((w-=2)*w*w*w*w+2)+k}function u(w,k,A,P){return-A*Math.cos(w/P*(Math.PI/2))+A+k}function d(w,k,A,P){return A*Math.sin(w/P*(Math.PI/2))+k}function m(w,k,A,P){return-A/2*(Math.cos(Math.PI*w/P)-1)+k}function p(w,k,A,P){return w===0?k:A*Math.pow(2,10*(w/P-1))+k}function v(w,k,A,P){return w===P?k+A:A*(-Math.pow(2,-10*w/P)+1)+k}function b(w,k,A,P){return w===0?k:w===P?k+A:(w/=P/2,w<1?A/2*Math.pow(2,10*(w-1))+k:A/2*(-Math.pow(2,-10*--w)+2)+k)}function S(w,k,A,P){return-A*(Math.sqrt(1-(w/=P)*w)-1)+k}function E(w,k,A,P){return A*Math.sqrt(1-(w=w/P-1)*w)+k}function F(w,k,A,P){return w/=P/2,w<1?-A/2*(Math.sqrt(1-w*w)-1)+k:A/2*(Math.sqrt(1-(w-=2)*w)+1)+k}function R(w,k,A,P){var I=1.70158,O=0,x=A;if(w===0)return k;if(w/=P,w===1)return k+A;O||(O=P*.3);var D=c(x,A,O,I);return-i(D,w,P)+k}function z(w,k,A,P){var I=1.70158,O=0,x=A;if(w===0)return k;if(w/=P,w===1)return k+A;O||(O=P*.3);var D=c(x,A,O,I);return D.a*Math.pow(2,-10*w)*Math.sin((w*P-D.s)*(2*Math.PI)/D.p)+D.c+k}function K(w,k,A,P){var I=1.70158,O=0,x=A;if(w===0)return k;if(w/=P/2,w===2)return k+A;O||(O=P*(.3*1.5));var D=c(x,A,O,I);return w<1?-.5*i(D,w,P)+k:D.a*Math.pow(2,-10*(w-=1))*Math.sin((w*P-D.s)*(2*Math.PI)/D.p)*.5+D.c+k}function Z(w,k,A,P,I){return I===void 0&&(I=1.70158),A*(w/=P)*w*((I+1)*w-I)+k}function q(w,k,A,P,I){return I===void 0&&(I=1.70158),A*((w=w/P-1)*w*((I+1)*w+I)+1)+k}function $(w,k,A,P,I){return I===void 0&&(I=1.70158),w/=P/2,w<1?A/2*(w*w*(((I*=1.525)+1)*w-I))+k:A/2*((w-=2)*w*(((I*=1.525)+1)*w+I)+2)+k}function tt(w,k,A,P){return A-it(P-w,0,A,P)+k}function it(w,k,A,P){return(w/=P)<1/2.75?A*(7.5625*w*w)+k:w<2/2.75?A*(7.5625*(w-=1.5/2.75)*w+.75)+k:w<2.5/2.75?A*(7.5625*(w-=2.25/2.75)*w+.9375)+k:A*(7.5625*(w-=2.625/2.75)*w+.984375)+k}function et(w,k,A,P){return w<P/2?tt(w*2,0,A,P)*.5+k:it(w*2-P,0,A,P)*.5+A*.5+k}r.util.ease={easeInQuad:function(w,k,A,P){return A*(w/=P)*w+k},easeOutQuad:function(w,k,A,P){return-A*(w/=P)*(w-2)+k},easeInOutQuad:function(w,k,A,P){return w/=P/2,w<1?A/2*w*w+k:-A/2*(--w*(w-2)-1)+k},easeInCubic:function(w,k,A,P){return A*(w/=P)*w*w+k},easeOutCubic:l,easeInOutCubic:a,easeInQuart:t,easeOutQuart:n,easeInOutQuart:e,easeInQuint:o,easeOutQuint:h,easeInOutQuint:s,easeInSine:u,easeOutSine:d,easeInOutSine:m,easeInExpo:p,easeOutExpo:v,easeInOutExpo:b,easeInCirc:S,easeOutCirc:E,easeInOutCirc:F,easeInElastic:R,easeOutElastic:z,easeInOutElastic:K,easeInBack:Z,easeOutBack:q,easeInOutBack:$,easeInBounce:tt,easeOutBounce:it,easeInOutBounce:et}})(),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.object.extend,a=i.util.object.clone,t=i.util.toFixed,n=i.util.parseUnit,e=i.util.multiplyTransformMatrices,o=["path","circle","polygon","polyline","ellipse","rect","line","image","text"],h=["symbol","image","marker","pattern","view","svg"],s=["pattern","defs","symbol","metadata","clipPath","mask","desc"],u=["symbol","g","a","svg","clipPath","defs"],d={cx:"left",x:"left",r:"radius",cy:"top",y:"top",display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing"},m={stroke:"strokeOpacity",fill:"fillOpacity"},p="font-size",v="clip-path";i.svgValidTagNamesRegEx=E(o),i.svgViewBoxElementsRegEx=E(h),i.svgInvalidAncestorsRegEx=E(s),i.svgValidParentsRegEx=E(u),i.cssRules={},i.gradientDefs={},i.clipPaths={};function b(O){return O in d?d[O]:O}function S(O,x,D,L){var N=Array.isArray(x),j;if((O==="fill"||O==="stroke")&&x==="none")x="";else{if(O==="strokeUniform")return x==="non-scaling-stroke";if(O==="strokeDashArray")x==="none"?x=null:x=x.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(O==="transformMatrix")D&&D.transformMatrix?x=e(D.transformMatrix,i.parseTransformAttribute(x)):x=i.parseTransformAttribute(x);else if(O==="visible")x=x!=="none"&&x!=="hidden",D&&D.visible===!1&&(x=!1);else if(O==="opacity")x=parseFloat(x),D&&typeof D.opacity<"u"&&(x*=D.opacity);else if(O==="textAnchor")x=x==="start"?"left":x==="end"?"right":"center";else if(O==="charSpacing")j=n(x,L)/L*1e3;else if(O==="paintFirst"){var V=x.indexOf("fill"),G=x.indexOf("stroke"),x="fill";(V>-1&&G>-1&&G<V||V===-1&&G>-1)&&(x="stroke")}else{if(O==="href"||O==="xlink:href"||O==="font")return x;if(O==="imageSmoothing")return x==="optimizeQuality";j=N?x.map(n):n(x,L)}}return!N&&isNaN(j)?x:j}function E(O){return new RegExp("^("+O.join("|")+")\\b","i")}function F(O){for(var x in m)if(!(typeof O[m[x]]>"u"||O[x]==="")){if(typeof O[x]>"u"){if(!i.Object.prototype[x])continue;O[x]=i.Object.prototype[x]}if(O[x].indexOf("url(")!==0){var D=new i.Color(O[x]);O[x]=D.setAlpha(t(D.getAlpha()*O[m[x]],2)).toRgba()}}return O}function R(O,x){var D,L=[],N,j,V;for(j=0,V=x.length;j<V;j++)D=x[j],N=O.getElementsByTagName(D),L=L.concat(Array.prototype.slice.call(N));return L}i.parseTransformAttribute=(function(){function O(W,rt){var ot=i.util.cos(rt[0]),lt=i.util.sin(rt[0]),ut=0,ht=0;rt.length===3&&(ut=rt[1],ht=rt[2]),W[0]=ot,W[1]=lt,W[2]=-lt,W[3]=ot,W[4]=ut-(ot*ut-lt*ht),W[5]=ht-(lt*ut+ot*ht)}function x(W,rt){var ot=rt[0],lt=rt.length===2?rt[1]:rt[0];W[0]=ot,W[3]=lt}function D(W,rt,ot){W[ot]=Math.tan(i.util.degreesToRadians(rt[0]))}function L(W,rt){W[4]=rt[0],rt.length===2&&(W[5]=rt[1])}var N=i.iMatrix,j=i.reNum,V=i.commaWsp,G="(?:(skewX)\\s*\\(\\s*("+j+")\\s*\\))",J="(?:(skewY)\\s*\\(\\s*("+j+")\\s*\\))",B="(?:(rotate)\\s*\\(\\s*("+j+")(?:"+V+"("+j+")"+V+"("+j+"))?\\s*\\))",M="(?:(scale)\\s*\\(\\s*("+j+")(?:"+V+"("+j+"))?\\s*\\))",X="(?:(translate)\\s*\\(\\s*("+j+")(?:"+V+"("+j+"))?\\s*\\))",Y="(?:(matrix)\\s*\\(\\s*("+j+")"+V+"("+j+")"+V+"("+j+")"+V+"("+j+")"+V+"("+j+")"+V+"("+j+")\\s*\\))",H="(?:"+Y+"|"+X+"|"+M+"|"+B+"|"+G+"|"+J+")",U="(?:"+H+"(?:"+V+"*"+H+")*)",Q="^\\s*(?:"+U+"?)\\s*$",st=new RegExp(Q),nt=new RegExp(H,"g");return function(W){var rt=N.concat(),ot=[];if(!W||W&&!st.test(W))return rt;W.replace(nt,function(ut){var ht=new RegExp(H).exec(ut).filter(function(zt){return!!zt}),bt=ht[1],dt=ht.slice(2).map(parseFloat);switch(bt){case"translate":L(rt,dt);break;case"rotate":dt[0]=i.util.degreesToRadians(dt[0]),O(rt,dt);break;case"scale":x(rt,dt);break;case"skewX":D(rt,dt,2);break;case"skewY":D(rt,dt,1);break;case"matrix":rt=dt;break}ot.push(rt.concat()),rt=N.concat()});for(var lt=ot[0];ot.length>1;)ot.shift(),lt=i.util.multiplyTransformMatrices(lt,ot[0]);return lt}})();function z(O,x){var D,L;O.replace(/;\s*$/,"").split(";").forEach(function(N){var j=N.split(":");D=j[0].trim().toLowerCase(),L=j[1].trim(),x[D]=L})}function K(O,x){var D,L;for(var N in O)typeof O[N]>"u"||(D=N.toLowerCase(),L=O[N],x[D]=L)}function Z(O,x){var D={};for(var L in i.cssRules[x])if(q(O,L.split(" ")))for(var N in i.cssRules[x][L])D[N]=i.cssRules[x][L][N];return D}function q(O,x){var D,L=!0;return D=tt(O,x.pop()),D&&x.length&&(L=$(O,x)),D&&L&&x.length===0}function $(O,x){for(var D,L=!0;O.parentNode&&O.parentNode.nodeType===1&&x.length;)L&&(D=x.pop()),O=O.parentNode,L=tt(O,D);return x.length===0}function tt(O,x){var D=O.nodeName,L=O.getAttribute("class"),N=O.getAttribute("id"),j,V;if(j=new RegExp("^"+D,"i"),x=x.replace(j,""),N&&x.length&&(j=new RegExp("#"+N+"(?![a-zA-Z\\-]+)","i"),x=x.replace(j,"")),L&&x.length)for(L=L.split(" "),V=L.length;V--;)j=new RegExp("\\."+L[V]+"(?![a-zA-Z\\-]+)","i"),x=x.replace(j,"");return x.length===0}function it(O,x){var D;if(O.getElementById&&(D=O.getElementById(x)),D)return D;var L,N,j,V=O.getElementsByTagName("*");for(N=0,j=V.length;N<j;N++)if(L=V[N],x===L.getAttribute("id"))return L}function et(O){for(var x=R(O,["use","svg:use"]),D=0;x.length&&D<x.length;){var L=x[D],N=L.getAttribute("xlink:href")||L.getAttribute("href");if(N===null)return;var j=N.slice(1),V=L.getAttribute("x")||0,G=L.getAttribute("y")||0,J=it(O,j).cloneNode(!0),B=(J.getAttribute("transform")||"")+" translate("+V+", "+G+")",M,X=x.length,Y,H,U,Q,st=i.svgNS;if(k(J),/^svg$/i.test(J.nodeName)){var nt=J.ownerDocument.createElementNS(st,"g");for(H=0,U=J.attributes,Q=U.length;H<Q;H++)Y=U.item(H),nt.setAttributeNS(st,Y.nodeName,Y.nodeValue);for(;J.firstChild;)nt.appendChild(J.firstChild);J=nt}for(H=0,U=L.attributes,Q=U.length;H<Q;H++)Y=U.item(H),!(Y.nodeName==="x"||Y.nodeName==="y"||Y.nodeName==="xlink:href"||Y.nodeName==="href")&&(Y.nodeName==="transform"?B=Y.nodeValue+" "+B:J.setAttribute(Y.nodeName,Y.nodeValue));J.setAttribute("transform",B),J.setAttribute("instantiated_by_use","1"),J.removeAttribute("id"),M=L.parentNode,M.replaceChild(J,L),x.length===X&&D++}}var w=new RegExp("^\\s*("+i.reNum+"+)\\s*,?\\s*("+i.reNum+"+)\\s*,?\\s*("+i.reNum+"+)\\s*,?\\s*("+i.reNum+"+)\\s*$");function k(O){if(!i.svgViewBoxElementsRegEx.test(O.nodeName))return{};var x=O.getAttribute("viewBox"),D=1,L=1,N=0,j=0,V,G,J,B,M=O.getAttribute("width"),X=O.getAttribute("height"),Y=O.getAttribute("x")||0,H=O.getAttribute("y")||0,U=O.getAttribute("preserveAspectRatio")||"",Q=!x||!(x=x.match(w)),st=!M||!X||M==="100%"||X==="100%",nt=Q&&st,W={},rt="",ot=0,lt=0;if(W.width=0,W.height=0,W.toBeParsed=nt,Q&&(Y||H)&&O.parentNode&&O.parentNode.nodeName!=="#document"&&(rt=" translate("+n(Y)+" "+n(H)+") ",J=(O.getAttribute("transform")||"")+rt,O.setAttribute("transform",J),O.removeAttribute("x"),O.removeAttribute("y")),nt)return W;if(Q)return W.width=n(M),W.height=n(X),W;if(N=-parseFloat(x[1]),j=-parseFloat(x[2]),V=parseFloat(x[3]),G=parseFloat(x[4]),W.minX=N,W.minY=j,W.viewBoxWidth=V,W.viewBoxHeight=G,st?(W.width=V,W.height=G):(W.width=n(M),W.height=n(X),D=W.width/V,L=W.height/G),U=i.util.parsePreserveAspectRatioAttribute(U),U.alignX!=="none"&&(U.meetOrSlice==="meet"&&(L=D=D>L?L:D),U.meetOrSlice==="slice"&&(L=D=D>L?D:L),ot=W.width-V*D,lt=W.height-G*D,U.alignX==="Mid"&&(ot/=2),U.alignY==="Mid"&&(lt/=2),U.alignX==="Min"&&(ot=0),U.alignY==="Min"&&(lt=0)),D===1&&L===1&&N===0&&j===0&&Y===0&&H===0)return W;if((Y||H)&&O.parentNode.nodeName!=="#document"&&(rt=" translate("+n(Y)+" "+n(H)+") "),J=rt+" matrix("+D+" 0 0 "+L+" "+(N*D+ot)+" "+(j*L+lt)+") ",O.nodeName==="svg"){for(B=O.ownerDocument.createElementNS(i.svgNS,"g");O.firstChild;)B.appendChild(O.firstChild);O.appendChild(B)}else B=O,B.removeAttribute("x"),B.removeAttribute("y"),J=B.getAttribute("transform")+J;return B.setAttribute("transform",J),W}function A(O,x){for(;O&&(O=O.parentNode);)if(O.nodeName&&x.test(O.nodeName.replace("svg:",""))&&!O.getAttribute("instantiated_by_use"))return!0;return!1}i.parseSVGDocument=function(O,x,D,L){if(O){et(O);var N=i.Object.__uid++,j,V,G=k(O),J=i.util.toArray(O.getElementsByTagName("*"));if(G.crossOrigin=L&&L.crossOrigin,G.svgUid=N,J.length===0&&i.isLikelyNode){J=O.selectNodes('//*[name(.)!="svg"]');var B=[];for(j=0,V=J.length;j<V;j++)B[j]=J[j];J=B}var M=J.filter(function(Y){return k(Y),i.svgValidTagNamesRegEx.test(Y.nodeName.replace("svg:",""))&&!A(Y,i.svgInvalidAncestorsRegEx)});if(!M||M&&!M.length){x&&x([],{});return}var X={};J.filter(function(Y){return Y.nodeName.replace("svg:","")==="clipPath"}).forEach(function(Y){var H=Y.getAttribute("id");X[H]=i.util.toArray(Y.getElementsByTagName("*")).filter(function(U){return i.svgValidTagNamesRegEx.test(U.nodeName.replace("svg:",""))})}),i.gradientDefs[N]=i.getGradientDefs(O),i.cssRules[N]=i.getCSSRules(O),i.clipPaths[N]=X,i.parseElements(M,function(Y,H){x&&(x(Y,G,H,J),delete i.gradientDefs[N],delete i.cssRules[N],delete i.clipPaths[N])},a(G),D,L)}};function P(O,x){var D=["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"],L="xlink:href",N=x.getAttribute(L).slice(1),j=it(O,N);if(j&&j.getAttribute(L)&&P(O,j),D.forEach(function(G){j&&!x.hasAttribute(G)&&j.hasAttribute(G)&&x.setAttribute(G,j.getAttribute(G))}),!x.children.length)for(var V=j.cloneNode(!0);V.firstChild;)x.appendChild(V.firstChild);x.removeAttribute(L)}var I=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+i.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+i.reNum+"))?\\s+(.*)");l(i,{parseFontDeclaration:function(O,x){var D=O.match(I);if(D){var L=D[1],N=D[3],j=D[4],V=D[5],G=D[6];L&&(x.fontStyle=L),N&&(x.fontWeight=isNaN(parseFloat(N))?N:parseFloat(N)),j&&(x.fontSize=n(j)),G&&(x.fontFamily=G),V&&(x.lineHeight=V==="normal"?1:V)}},getGradientDefs:function(O){var x=["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"],D=R(O,x),L,N=0,j={};for(N=D.length;N--;)L=D[N],L.getAttribute("xlink:href")&&P(O,L),j[L.getAttribute("id")]=L;return j},parseAttributes:function(O,x,D){if(O){var L,N={},j,V;typeof D>"u"&&(D=O.getAttribute("svgUid")),O.parentNode&&i.svgValidParentsRegEx.test(O.parentNode.nodeName)&&(N=i.parseAttributes(O.parentNode,x,D));var G=x.reduce(function(U,Q){return L=O.getAttribute(Q),L&&(U[Q]=L),U},{}),J=l(Z(O,D),i.parseStyleAttribute(O));G=l(G,J),J[v]&&O.setAttribute(v,J[v]),j=V=N.fontSize||i.Text.DEFAULT_SVG_FONT_SIZE,G[p]&&(G[p]=j=n(G[p],V));var B,M,X={};for(var Y in G)B=b(Y),M=S(B,G[Y],N,j),X[B]=M;X&&X.font&&i.parseFontDeclaration(X.font,X);var H=l(N,X);return i.svgValidParentsRegEx.test(O.nodeName)?H:F(H)}},parseElements:function(O,x,D,L,N){new i.ElementsParser(O,x,D,L,N).parse()},parseStyleAttribute:function(O){var x={},D=O.getAttribute("style");return D&&(typeof D=="string"?z(D,x):K(D,x)),x},parsePointsAttribute:function(O){if(!O)return null;O=O.replace(/,/g," ").trim(),O=O.split(/\s+/);var x=[],D,L;for(D=0,L=O.length;D<L;D+=2)x.push({x:parseFloat(O[D]),y:parseFloat(O[D+1])});return x},getCSSRules:function(O){var x=O.getElementsByTagName("style"),D,L,N={},j;for(D=0,L=x.length;D<L;D++){var V=x[D].textContent;V=V.replace(/\/\*[\s\S]*?\*\//g,""),V.trim()!==""&&(j=V.split("}"),j=j.filter(function(G){return G.trim()}),j.forEach(function(G){var J=G.split("{"),B={},M=J[1].trim(),X=M.split(";").filter(function(Q){return Q.trim()});for(D=0,L=X.length;D<L;D++){var Y=X[D].split(":"),H=Y[0].trim(),U=Y[1].trim();B[H]=U}G=J[0].trim(),G.split(",").forEach(function(Q){Q=Q.replace(/^svg/i,"").trim(),Q!==""&&(N[Q]?i.util.object.extend(N[Q],B):N[Q]=i.util.object.clone(B))})}))}return N},loadSVGFromURL:function(O,x,D,L){O=O.replace(/^\n\s*/,"").trim(),new i.util.request(O,{method:"get",onComplete:N});function N(j){var V=j.responseXML;if(!V||!V.documentElement)return x&&x(null),!1;i.parseSVGDocument(V.documentElement,function(G,J,B,M){x&&x(G,J,B,M)},D,L)}},loadSVGFromString:function(O,x,D,L){var N=new i.window.DOMParser,j=N.parseFromString(O.trim(),"text/xml");i.parseSVGDocument(j.documentElement,function(V,G,J,B){x(V,G,J,B)},D,L)}})})(f),r.ElementsParser=function(c,i,l,a,t,n){this.elements=c,this.callback=i,this.options=l,this.reviver=a,this.svgUid=l&&l.svgUid||0,this.parsingOptions=t,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=n},(function(c){c.parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},c.createObjects=function(){var i=this;this.elements.forEach(function(l,a){l.setAttribute("svgUid",i.svgUid),i.createObject(l,a)})},c.findTag=function(i){return r[r.util.string.capitalize(i.tagName.replace("svg:",""))]},c.createObject=function(i,l){var a=this.findTag(i);if(a&&a.fromElement)try{a.fromElement(i,this.createCallback(l,i),this.options)}catch(t){r.log(t)}else this.checkIfDone()},c.createCallback=function(i,l){var a=this;return function(t){var n;a.resolveGradient(t,l,"fill"),a.resolveGradient(t,l,"stroke"),t instanceof r.Image&&t._originalElement&&(n=t.parsePreserveAspectRatioAttribute(l)),t._removeTransformMatrix(n),a.resolveClipPath(t,l),a.reviver&&a.reviver(l,t),a.instances[i]=t,a.checkIfDone()}},c.extractPropertyDefinition=function(i,l,a){var t=i[l],n=this.regexUrl;if(n.test(t)){n.lastIndex=0;var e=n.exec(t)[1];return n.lastIndex=0,r[a][this.svgUid][e]}},c.resolveGradient=function(i,l,a){var t=this.extractPropertyDefinition(i,a,"gradientDefs");if(t){var n=l.getAttribute(a+"-opacity"),e=r.Gradient.fromElement(t,i,n,this.options);i.set(a,e)}},c.createClipPathCallback=function(i,l){return function(a){a._removeTransformMatrix(),a.fillRule=a.clipRule,l.push(a)}},c.resolveClipPath=function(i,l){var a=this.extractPropertyDefinition(i,"clipPath","clipPaths"),t,n,e,o,h,s;if(a){o=[],e=r.util.invertTransform(i.calcTransformMatrix());for(var u=a[0].parentNode,d=l;d.parentNode&&d.getAttribute("clip-path")!==i.clipPath;)d=d.parentNode;d.parentNode.appendChild(u);for(var m=0;m<a.length;m++)t=a[m],n=this.findTag(t),n.fromElement(t,this.createClipPathCallback(i,o),this.options);o.length===1?a=o[0]:a=new r.Group(o),h=r.util.multiplyTransformMatrices(e,a.calcTransformMatrix()),a.clipPath&&this.resolveClipPath(a,d);var s=r.util.qrDecompose(h);a.flipX=!1,a.flipY=!1,a.set("scaleX",s.scaleX),a.set("scaleY",s.scaleY),a.angle=s.angle,a.skewX=s.skewX,a.skewY=0,a.setPositionByOrigin({x:s.translateX,y:s.translateY},"center","center"),i.clipPath=a}else delete i.clipPath},c.checkIfDone=function(){--this.numElements===0&&(this.instances=this.instances.filter(function(i){return i!=null}),this.callback(this.instances,this.elements))}})(r.ElementsParser.prototype),(function(c){var i=c.fabric||(c.fabric={});if(i.Point){i.warn("fabric.Point is already defined");return}i.Point=l;function l(a,t){this.x=a,this.y=t}l.prototype={type:"point",constructor:l,add:function(a){return new l(this.x+a.x,this.y+a.y)},addEquals:function(a){return this.x+=a.x,this.y+=a.y,this},scalarAdd:function(a){return new l(this.x+a,this.y+a)},scalarAddEquals:function(a){return this.x+=a,this.y+=a,this},subtract:function(a){return new l(this.x-a.x,this.y-a.y)},subtractEquals:function(a){return this.x-=a.x,this.y-=a.y,this},scalarSubtract:function(a){return new l(this.x-a,this.y-a)},scalarSubtractEquals:function(a){return this.x-=a,this.y-=a,this},multiply:function(a){return new l(this.x*a,this.y*a)},multiplyEquals:function(a){return this.x*=a,this.y*=a,this},divide:function(a){return new l(this.x/a,this.y/a)},divideEquals:function(a){return this.x/=a,this.y/=a,this},eq:function(a){return this.x===a.x&&this.y===a.y},lt:function(a){return this.x<a.x&&this.y<a.y},lte:function(a){return this.x<=a.x&&this.y<=a.y},gt:function(a){return this.x>a.x&&this.y>a.y},gte:function(a){return this.x>=a.x&&this.y>=a.y},lerp:function(a,t){return typeof t>"u"&&(t=.5),t=Math.max(Math.min(1,t),0),new l(this.x+(a.x-this.x)*t,this.y+(a.y-this.y)*t)},distanceFrom:function(a){var t=this.x-a.x,n=this.y-a.y;return Math.sqrt(t*t+n*n)},midPointFrom:function(a){return this.lerp(a)},min:function(a){return new l(Math.min(this.x,a.x),Math.min(this.y,a.y))},max:function(a){return new l(Math.max(this.x,a.x),Math.max(this.y,a.y))},toString:function(){return this.x+","+this.y},setXY:function(a,t){return this.x=a,this.y=t,this},setX:function(a){return this.x=a,this},setY:function(a){return this.y=a,this},setFromPoint:function(a){return this.x=a.x,this.y=a.y,this},swap:function(a){var t=this.x,n=this.y;this.x=a.x,this.y=a.y,a.x=t,a.y=n},clone:function(){return new l(this.x,this.y)}}})(f),(function(c){var i=c.fabric||(c.fabric={});if(i.Intersection){i.warn("fabric.Intersection is already defined");return}function l(a){this.status=a,this.points=[]}i.Intersection=l,i.Intersection.prototype={constructor:l,appendPoint:function(a){return this.points.push(a),this},appendPoints:function(a){return this.points=this.points.concat(a),this}},i.Intersection.intersectLineLine=function(a,t,n,e){var o,h=(e.x-n.x)*(a.y-n.y)-(e.y-n.y)*(a.x-n.x),s=(t.x-a.x)*(a.y-n.y)-(t.y-a.y)*(a.x-n.x),u=(e.y-n.y)*(t.x-a.x)-(e.x-n.x)*(t.y-a.y);if(u!==0){var d=h/u,m=s/u;0<=d&&d<=1&&0<=m&&m<=1?(o=new l("Intersection"),o.appendPoint(new i.Point(a.x+d*(t.x-a.x),a.y+d*(t.y-a.y)))):o=new l}else h===0||s===0?o=new l("Coincident"):o=new l("Parallel");return o},i.Intersection.intersectLinePolygon=function(a,t,n){var e=new l,o=n.length,h,s,u,d;for(d=0;d<o;d++)h=n[d],s=n[(d+1)%o],u=l.intersectLineLine(a,t,h,s),e.appendPoints(u.points);return e.points.length>0&&(e.status="Intersection"),e},i.Intersection.intersectPolygonPolygon=function(a,t){var n=new l,e=a.length,o;for(o=0;o<e;o++){var h=a[o],s=a[(o+1)%e],u=l.intersectLinePolygon(h,s,t);n.appendPoints(u.points)}return n.points.length>0&&(n.status="Intersection"),n},i.Intersection.intersectPolygonRectangle=function(a,t,n){var e=t.min(n),o=t.max(n),h=new i.Point(o.x,e.y),s=new i.Point(e.x,o.y),u=l.intersectLinePolygon(e,h,a),d=l.intersectLinePolygon(h,o,a),m=l.intersectLinePolygon(o,s,a),p=l.intersectLinePolygon(s,e,a),v=new l;return v.appendPoints(u.points),v.appendPoints(d.points),v.appendPoints(m.points),v.appendPoints(p.points),v.points.length>0&&(v.status="Intersection"),v}})(f),(function(c){var i=c.fabric||(c.fabric={});if(i.Color){i.warn("fabric.Color is already defined.");return}function l(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}i.Color=l,i.Color.prototype={_tryParsingColor:function(t){var n;t in l.colorNameMap&&(t=l.colorNameMap[t]),t==="transparent"&&(n=[255,255,255,0]),n||(n=l.sourceFromHex(t)),n||(n=l.sourceFromRgb(t)),n||(n=l.sourceFromHsl(t)),n||(n=[0,0,0,1]),n&&this.setSource(n)},_rgbToHsl:function(t,n,e){t/=255,n/=255,e/=255;var o,h,s,u=i.util.array.max([t,n,e]),d=i.util.array.min([t,n,e]);if(s=(u+d)/2,u===d)o=h=0;else{var m=u-d;switch(h=s>.5?m/(2-u-d):m/(u+d),u){case t:o=(n-e)/m+(n<e?6:0);break;case n:o=(e-t)/m+2;break;case e:o=(t-n)/m+4;break}o/=6}return[Math.round(o*360),Math.round(h*100),Math.round(s*100)]},getSource:function(){return this._source},setSource:function(t){this._source=t},toRgb:function(){var t=this.getSource();return"rgb("+t[0]+","+t[1]+","+t[2]+")"},toRgba:function(){var t=this.getSource();return"rgba("+t[0]+","+t[1]+","+t[2]+","+t[3]+")"},toHsl:function(){var t=this.getSource(),n=this._rgbToHsl(t[0],t[1],t[2]);return"hsl("+n[0]+","+n[1]+"%,"+n[2]+"%)"},toHsla:function(){var t=this.getSource(),n=this._rgbToHsl(t[0],t[1],t[2]);return"hsla("+n[0]+","+n[1]+"%,"+n[2]+"%,"+t[3]+")"},toHex:function(){var t=this.getSource(),n,e,o;return n=t[0].toString(16),n=n.length===1?"0"+n:n,e=t[1].toString(16),e=e.length===1?"0"+e:e,o=t[2].toString(16),o=o.length===1?"0"+o:o,n.toUpperCase()+e.toUpperCase()+o.toUpperCase()},toHexa:function(){var t=this.getSource(),n;return n=Math.round(t[3]*255),n=n.toString(16),n=n.length===1?"0"+n:n,this.toHex()+n.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(t){var n=this.getSource();return n[3]=t,this.setSource(n),this},toGrayscale:function(){var t=this.getSource(),n=parseInt((t[0]*.3+t[1]*.59+t[2]*.11).toFixed(0),10),e=t[3];return this.setSource([n,n,n,e]),this},toBlackWhite:function(t){var n=this.getSource(),e=(n[0]*.3+n[1]*.59+n[2]*.11).toFixed(0),o=n[3];return t=t||127,e=Number(e)<Number(t)?0:255,this.setSource([e,e,e,o]),this},overlayWith:function(t){t instanceof l||(t=new l(t));var n=[],e=this.getAlpha(),o=.5,h=this.getSource(),s=t.getSource(),u;for(u=0;u<3;u++)n.push(Math.round(h[u]*(1-o)+s[u]*o));return n[3]=e,this.setSource(n),this}},i.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/i,i.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/i,i.Color.reHex=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,i.Color.colorNameMap={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};function a(t,n,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+(n-t)*6*e:e<1/2?n:e<2/3?t+(n-t)*(2/3-e)*6:t}i.Color.fromRgb=function(t){return l.fromSource(l.sourceFromRgb(t))},i.Color.sourceFromRgb=function(t){var n=t.match(l.reRGBa);if(n){var e=parseInt(n[1],10)/(/%$/.test(n[1])?100:1)*(/%$/.test(n[1])?255:1),o=parseInt(n[2],10)/(/%$/.test(n[2])?100:1)*(/%$/.test(n[2])?255:1),h=parseInt(n[3],10)/(/%$/.test(n[3])?100:1)*(/%$/.test(n[3])?255:1);return[parseInt(e,10),parseInt(o,10),parseInt(h,10),n[4]?parseFloat(n[4]):1]}},i.Color.fromRgba=l.fromRgb,i.Color.fromHsl=function(t){return l.fromSource(l.sourceFromHsl(t))},i.Color.sourceFromHsl=function(t){var n=t.match(l.reHSLa);if(n){var e=(parseFloat(n[1])%360+360)%360/360,o=parseFloat(n[2])/(/%$/.test(n[2])?100:1),h=parseFloat(n[3])/(/%$/.test(n[3])?100:1),s,u,d;if(o===0)s=u=d=h;else{var m=h<=.5?h*(o+1):h+o-h*o,p=h*2-m;s=a(p,m,e+1/3),u=a(p,m,e),d=a(p,m,e-1/3)}return[Math.round(s*255),Math.round(u*255),Math.round(d*255),n[4]?parseFloat(n[4]):1]}},i.Color.fromHsla=l.fromHsl,i.Color.fromHex=function(t){return l.fromSource(l.sourceFromHex(t))},i.Color.sourceFromHex=function(t){if(t.match(l.reHex)){var n=t.slice(t.indexOf("#")+1),e=n.length===3||n.length===4,o=n.length===8||n.length===4,h=e?n.charAt(0)+n.charAt(0):n.substring(0,2),s=e?n.charAt(1)+n.charAt(1):n.substring(2,4),u=e?n.charAt(2)+n.charAt(2):n.substring(4,6),d=o?e?n.charAt(3)+n.charAt(3):n.substring(6,8):"FF";return[parseInt(h,16),parseInt(s,16),parseInt(u,16),parseFloat((parseInt(d,16)/255).toFixed(2))]}},i.Color.fromSource=function(t){var n=new l;return n.setSource(t),n}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=["e","se","s","sw","w","nw","n","ne","e"],a=["ns","nesw","ew","nwse"],t={},n="left",e="top",o="right",h="bottom",s="center",u={top:h,bottom:e,left:o,right:n,center:s},d=i.util.radiansToDegrees,m=Math.sign||function(B){return(B>0)-(B<0)||+B};function p(B,M){var X=B.angle+d(Math.atan2(M.y,M.x))+360;return Math.round(X%360/45)}function v(B,M){var X=M.transform.target,Y=X.canvas,H=i.util.object.clone(M);H.target=X,Y&&Y.fire("object:"+B,H),X.fire(B,M)}function b(B,M){var X=M.canvas,Y=X.uniScaleKey,H=B[Y];return X.uniformScaling&&!H||!X.uniformScaling&&H}function S(B){return B.originX===s&&B.originY===s}function E(B,M,X){var Y=B.lockScalingX,H=B.lockScalingY;return!!(Y&&H||!M&&(Y||H)&&X||Y&&M==="x"||H&&M==="y")}function F(B,M,X){var Y="not-allowed",H=b(B,X),U="";if(M.x!==0&&M.y===0?U="x":M.x===0&&M.y!==0&&(U="y"),E(X,U,H))return Y;var Q=p(X,M);return l[Q]+"-resize"}function R(B,M,X){var Y="not-allowed";if(M.x!==0&&X.lockSkewingY||M.y!==0&&X.lockSkewingX)return Y;var H=p(X,M)%4;return a[H]+"-resize"}function z(B,M,X){return B[X.canvas.altActionKey]?t.skewCursorStyleHandler(B,M,X):t.scaleCursorStyleHandler(B,M,X)}function K(B,M,X){var Y=B[X.canvas.altActionKey];if(M.x===0)return Y?"skewX":"scaleY";if(M.y===0)return Y?"skewY":"scaleX"}function Z(B,M,X){return X.lockRotation?"not-allowed":M.cursorStyle}function q(B,M,X,Y){return{e:B,transform:M,pointer:{x:X,y:Y}}}function $(B){return function(M,X,Y,H){var U=X.target,Q=U.getCenterPoint(),st=U.translateToOriginPoint(Q,X.originX,X.originY),nt=B(M,X,Y,H);return U.setPositionByOrigin(st,X.originX,X.originY),nt}}function tt(B,M){return function(X,Y,H,U){var Q=M(X,Y,H,U);return Q&&v(B,q(X,Y,H,U)),Q}}function it(B,M,X,Y,H){var U=B.target,Q=U.controls[B.corner],st=U.canvas.getZoom(),nt=U.padding/st,W=U.toLocalPoint(new i.Point(Y,H),M,X);return W.x>=nt&&(W.x-=nt),W.x<=-nt&&(W.x+=nt),W.y>=nt&&(W.y-=nt),W.y<=nt&&(W.y+=nt),W.x-=Q.offsetX,W.y-=Q.offsetY,W}function et(B){return B.flipX!==B.flipY}function w(B,M,X,Y,H){if(B[M]!==0){var U=B._getTransformedDimensions()[Y],Q=H/U*B[X];B.set(X,Q)}}function k(B,M,X,Y){var H=M.target,U=H._getTransformedDimensions(0,H.skewY),Q=it(M,M.originX,M.originY,X,Y),st=Math.abs(Q.x*2)-U.x,nt=H.skewX,W;st<2?W=0:(W=d(Math.atan2(st/H.scaleX,U.y/H.scaleY)),M.originX===n&&M.originY===h&&(W=-W),M.originX===o&&M.originY===e&&(W=-W),et(H)&&(W=-W));var rt=nt!==W;if(rt){var ot=H._getTransformedDimensions().y;H.set("skewX",W),w(H,"skewY","scaleY","y",ot)}return rt}function A(B,M,X,Y){var H=M.target,U=H._getTransformedDimensions(H.skewX,0),Q=it(M,M.originX,M.originY,X,Y),st=Math.abs(Q.y*2)-U.y,nt=H.skewY,W;st<2?W=0:(W=d(Math.atan2(st/H.scaleY,U.x/H.scaleX)),M.originX===n&&M.originY===h&&(W=-W),M.originX===o&&M.originY===e&&(W=-W),et(H)&&(W=-W));var rt=nt!==W;if(rt){var ot=H._getTransformedDimensions().x;H.set("skewY",W),w(H,"skewX","scaleX","x",ot)}return rt}function P(B,M,X,Y){var H=M.target,U=H.skewX,Q,st=M.originY;if(H.lockSkewingX)return!1;if(U===0){var nt=it(M,s,s,X,Y);nt.x>0?Q=n:Q=o}else U>0&&(Q=st===e?n:o),U<0&&(Q=st===e?o:n),et(H)&&(Q=Q===n?o:n);M.originX=Q;var W=tt("skewing",$(k));return W(B,M,X,Y)}function I(B,M,X,Y){var H=M.target,U=H.skewY,Q,st=M.originX;if(H.lockSkewingY)return!1;if(U===0){var nt=it(M,s,s,X,Y);nt.y>0?Q=e:Q=h}else U>0&&(Q=st===n?e:h),U<0&&(Q=st===n?h:e),et(H)&&(Q=Q===e?h:e);M.originY=Q;var W=tt("skewing",$(A));return W(B,M,X,Y)}function O(B,M,X,Y){var H=M,U=H.target,Q=U.translateToOriginPoint(U.getCenterPoint(),H.originX,H.originY);if(U.lockRotation)return!1;var st=Math.atan2(H.ey-Q.y,H.ex-Q.x),nt=Math.atan2(Y-Q.y,X-Q.x),W=d(nt-st+H.theta),rt=!0;if(U.snapAngle>0){var ot=U.snapAngle,lt=U.snapThreshold||ot,ut=Math.ceil(W/ot)*ot,ht=Math.floor(W/ot)*ot;Math.abs(W-ht)<lt?W=ht:Math.abs(W-ut)<lt&&(W=ut)}return W<0&&(W=360+W),W%=360,rt=U.angle!==W,U.angle=W,rt}function x(B,M,X,Y,H){H=H||{};var U=M.target,Q=U.lockScalingX,st=U.lockScalingY,nt=H.by,W,rt,ot,lt,ut=b(B,U),ht=E(U,nt,ut),bt,dt,zt=M.gestureScale;if(ht)return!1;if(zt)rt=M.scaleX*zt,ot=M.scaleY*zt;else{if(W=it(M,M.originX,M.originY,X,Y),bt=nt!=="y"?m(W.x):1,dt=nt!=="x"?m(W.y):1,M.signX||(M.signX=bt),M.signY||(M.signY=dt),U.lockScalingFlip&&(M.signX!==bt||M.signY!==dt))return!1;if(lt=U._getTransformedDimensions(),ut&&!nt){var le=Math.abs(W.x)+Math.abs(W.y),kt=M.original,pr=Math.abs(lt.x*kt.scaleX/U.scaleX)+Math.abs(lt.y*kt.scaleY/U.scaleY),Vi=le/pr;rt=kt.scaleX*Vi,ot=kt.scaleY*Vi}else rt=Math.abs(W.x*U.scaleX/lt.x),ot=Math.abs(W.y*U.scaleY/lt.y);S(M)&&(rt*=2,ot*=2),M.signX!==bt&&nt!=="y"&&(M.originX=u[M.originX],rt*=-1,M.signX=bt),M.signY!==dt&&nt!=="x"&&(M.originY=u[M.originY],ot*=-1,M.signY=dt)}var mr=U.scaleX,vr=U.scaleY;return nt?(nt==="x"&&U.set("scaleX",rt),nt==="y"&&U.set("scaleY",ot)):(!Q&&U.set("scaleX",rt),!st&&U.set("scaleY",ot)),mr!==U.scaleX||vr!==U.scaleY}function D(B,M,X,Y){return x(B,M,X,Y)}function L(B,M,X,Y){return x(B,M,X,Y,{by:"x"})}function N(B,M,X,Y){return x(B,M,X,Y,{by:"y"})}function j(B,M,X,Y){return B[M.target.canvas.altActionKey]?t.skewHandlerX(B,M,X,Y):t.scalingY(B,M,X,Y)}function V(B,M,X,Y){return B[M.target.canvas.altActionKey]?t.skewHandlerY(B,M,X,Y):t.scalingX(B,M,X,Y)}function G(B,M,X,Y){var H=M.target,U=it(M,M.originX,M.originY,X,Y),Q=H.strokeWidth/(H.strokeUniform?H.scaleX:1),st=S(M)?2:1,nt=H.width,W=Math.abs(U.x*st/H.scaleX)-Q;return H.set("width",Math.max(W,0)),nt!==W}function J(B,M,X,Y){var H=M.target,U=X-M.offsetX,Q=Y-M.offsetY,st=!H.get("lockMovementX")&&H.left!==U,nt=!H.get("lockMovementY")&&H.top!==Q;return st&&H.set("left",U),nt&&H.set("top",Q),(st||nt)&&v("moving",q(B,M,X,Y)),st||nt}t.scaleCursorStyleHandler=F,t.skewCursorStyleHandler=R,t.scaleSkewCursorStyleHandler=z,t.rotationWithSnapping=tt("rotating",$(O)),t.scalingEqually=tt("scaling",$(D)),t.scalingX=tt("scaling",$(L)),t.scalingY=tt("scaling",$(N)),t.scalingYOrSkewingX=j,t.scalingXOrSkewingY=V,t.changeWidth=tt("resizing",$(G)),t.skewHandlerX=P,t.skewHandlerY=I,t.dragHandler=J,t.scaleOrSkewActionName=K,t.rotationStyleHandler=Z,t.fireEvent=v,t.wrapWithFixedAnchor=$,t.wrapWithFireEvent=tt,t.getLocalPoint=it,i.controlsUtils=t})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.degreesToRadians,a=i.controlsUtils;function t(e,o,h,s,u){s=s||{};var d=this.sizeX||s.cornerSize||u.cornerSize,m=this.sizeY||s.cornerSize||u.cornerSize,p=typeof s.transparentCorners<"u"?s.transparentCorners:u.transparentCorners,v=p?"stroke":"fill",b=!p&&(s.cornerStrokeColor||u.cornerStrokeColor),S=o,E=h,F;e.save(),e.fillStyle=s.cornerColor||u.cornerColor,e.strokeStyle=s.cornerStrokeColor||u.cornerStrokeColor,d>m?(F=d,e.scale(1,m/d),E=h*d/m):m>d?(F=m,e.scale(d/m,1),S=o*m/d):F=d,e.lineWidth=1,e.beginPath(),e.arc(S,E,F/2,0,2*Math.PI,!1),e[v](),b&&e.stroke(),e.restore()}function n(e,o,h,s,u){s=s||{};var d=this.sizeX||s.cornerSize||u.cornerSize,m=this.sizeY||s.cornerSize||u.cornerSize,p=typeof s.transparentCorners<"u"?s.transparentCorners:u.transparentCorners,v=p?"stroke":"fill",b=!p&&(s.cornerStrokeColor||u.cornerStrokeColor),S=d/2,E=m/2;e.save(),e.fillStyle=s.cornerColor||u.cornerColor,e.strokeStyle=s.cornerStrokeColor||u.cornerStrokeColor,e.lineWidth=1,e.translate(o,h),e.rotate(l(u.angle)),e[v+"Rect"](-S,-E,d,m),b&&e.strokeRect(-S,-E,d,m),e.restore()}a.renderCircleControl=t,a.renderSquareControl=n})(f),(function(c){var i=c.fabric||(c.fabric={});function l(a){for(var t in a)this[t]=a[t]}i.Control=l,i.Control.prototype={visible:!0,actionName:"scale",angle:0,x:0,y:0,offsetX:0,offsetY:0,sizeX:null,sizeY:null,touchSizeX:null,touchSizeY:null,cursorStyle:"crosshair",withConnection:!1,actionHandler:function(){},mouseDownHandler:function(){},mouseUpHandler:function(){},getActionHandler:function(){return this.actionHandler},getMouseDownHandler:function(){return this.mouseDownHandler},getMouseUpHandler:function(){return this.mouseUpHandler},cursorStyleHandler:function(a,t){return t.cursorStyle},getActionName:function(a,t){return t.actionName},getVisibility:function(a,t){var n=a._controlsVisibility;return n&&typeof n[t]<"u"?n[t]:this.visible},setVisibility:function(a){this.visible=a},positionHandler:function(a,t){var n=i.util.transformPoint({x:this.x*a.x+this.offsetX,y:this.y*a.y+this.offsetY},t);return n},calcCornerCoords:function(a,t,n,e,o){var h,s,u,d,m=o?this.touchSizeX:this.sizeX,p=o?this.touchSizeY:this.sizeY;if(m&&p&&m!==p){var v=Math.atan2(p,m),b=Math.sqrt(m*m+p*p)/2,S=v-i.util.degreesToRadians(a),E=Math.PI/2-v-i.util.degreesToRadians(a);h=b*i.util.cos(S),s=b*i.util.sin(S),u=b*i.util.cos(E),d=b*i.util.sin(E)}else{var F=m&&p?m:t;b=F*.7071067812;var S=i.util.degreesToRadians(45-a);h=u=b*i.util.cos(S),s=d=b*i.util.sin(S)}return{tl:{x:n-d,y:e-u},tr:{x:n+h,y:e-s},bl:{x:n-h,y:e+s},br:{x:n+d,y:e+u}}},render:function(a,t,n,e,o){switch(e=e||{},e.cornerStyle||o.cornerStyle){case"circle":i.controlsUtils.renderCircleControl.call(this,a,t,n,e,o);break;default:i.controlsUtils.renderSquareControl.call(this,a,t,n,e,o)}}}})(f),(function(){function c(n,e){var o=n.getAttribute("style"),h=n.getAttribute("offset")||0,s,u,d,m;if(h=parseFloat(h)/(/%$/.test(h)?100:1),h=h<0?0:h>1?1:h,o){var p=o.split(/\s*;\s*/);for(p[p.length-1]===""&&p.pop(),m=p.length;m--;){var v=p[m].split(/\s*:\s*/),b=v[0].trim(),S=v[1].trim();b==="stop-color"?s=S:b==="stop-opacity"&&(d=S)}}return s||(s=n.getAttribute("stop-color")||"rgb(0,0,0)"),d||(d=n.getAttribute("stop-opacity")),s=new r.Color(s),u=s.getAlpha(),d=isNaN(parseFloat(d))?1:parseFloat(d),d*=u*e,{offset:h,color:s.toRgb(),opacity:d}}function i(n){return{x1:n.getAttribute("x1")||0,y1:n.getAttribute("y1")||0,x2:n.getAttribute("x2")||"100%",y2:n.getAttribute("y2")||0}}function l(n){return{x1:n.getAttribute("fx")||n.getAttribute("cx")||"50%",y1:n.getAttribute("fy")||n.getAttribute("cy")||"50%",r1:0,x2:n.getAttribute("cx")||"50%",y2:n.getAttribute("cy")||"50%",r2:n.getAttribute("r")||"50%"}}var a=r.util.object.clone;r.Gradient=r.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(n){n||(n={}),n.coords||(n.coords={});var e,o=this;Object.keys(n).forEach(function(h){o[h]=n[h]}),this.id?this.id+="_"+r.Object.__uid++:this.id=r.Object.__uid++,e={x1:n.coords.x1||0,y1:n.coords.y1||0,x2:n.coords.x2||0,y2:n.coords.y2||0},this.type==="radial"&&(e.r1=n.coords.r1||0,e.r2=n.coords.r2||0),this.coords=e,this.colorStops=n.colorStops.slice()},addColorStop:function(n){for(var e in n){var o=new r.Color(n[e]);this.colorStops.push({offset:parseFloat(e),color:o.toRgb(),opacity:o.getAlpha()})}return this},toObject:function(n){var e={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return r.util.populateWithProperties(this,e,n),e},toSVG:function(n,u){var o=a(this.coords,!0),h,s,u=u||{},d,m,p=a(this.colorStops,!0),v=o.r1>o.r2,b=this.gradientTransform?this.gradientTransform.concat():r.iMatrix.concat(),S=-this.offsetX,E=-this.offsetY,F=!!u.additionalTransform,R=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox";if(p.sort(function($,tt){return $.offset-tt.offset}),R==="objectBoundingBox"?(S/=n.width,E/=n.height):(S+=n.width/2,E+=n.height/2),n.type==="path"&&this.gradientUnits!=="percentage"&&(S-=n.pathOffset.x,E-=n.pathOffset.y),b[4]-=S,b[5]-=E,m='id="SVGID_'+this.id+'" gradientUnits="'+R+'"',m+=' gradientTransform="'+(F?u.additionalTransform+" ":"")+r.util.matrixToSVG(b)+'" ',this.type==="linear"?d=["<linearGradient ",m,' x1="',o.x1,'" y1="',o.y1,'" x2="',o.x2,'" y2="',o.y2,`">
8
8
  `]:this.type==="radial"&&(d=["<radialGradient ",m,' cx="',v?o.x1:o.x2,'" cy="',v?o.y1:o.y2,'" r="',v?o.r1:o.r2,'" fx="',v?o.x2:o.x1,'" fy="',v?o.y2:o.y1,`">
9
- `]),this.type==="radial"){if(v)for(g=g.concat(),g.reverse(),h=0,s=g.length;h<s;h++)g[h].offset=1-g[h].offset;var z=Math.min(o.r1,o.r2);if(z>0){var q=Math.max(o.r1,o.r2),Z=z/q;for(h=0,s=g.length;h<s;h++)g[h].offset+=Z*(1-g[h].offset)}}for(h=0,s=g.length;h<s;h++){var K=g[h];d.push("<stop ",'offset="',K.offset*100+"%",'" style="stop-color:',K.color,typeof K.opacity<"u"?";stop-opacity: "+K.opacity:";",`"/>
9
+ `]),this.type==="radial"){if(v)for(p=p.concat(),p.reverse(),h=0,s=p.length;h<s;h++)p[h].offset=1-p[h].offset;var z=Math.min(o.r1,o.r2);if(z>0){var K=Math.max(o.r1,o.r2),Z=z/K;for(h=0,s=p.length;h<s;h++)p[h].offset+=Z*(1-p[h].offset)}}for(h=0,s=p.length;h<s;h++){var q=p[h];d.push("<stop ",'offset="',q.offset*100+"%",'" style="stop-color:',q.color,typeof q.opacity<"u"?";stop-opacity: "+q.opacity:";",`"/>
10
10
  `)}return d.push(this.type==="linear"?`</linearGradient>
11
11
  `:`</radialGradient>
12
- `),d.join("")},toLive:function(n){var e,o=r.util.object.clone(this.coords),h,s;if(this.type){for(this.type==="linear"?e=n.createLinearGradient(o.x1,o.y1,o.x2,o.y2):this.type==="radial"&&(e=n.createRadialGradient(o.x1,o.y1,o.r1,o.x2,o.y2,o.r2)),h=0,s=this.colorStops.length;h<s;h++){var u=this.colorStops[h].color,d=this.colorStops[h].opacity,m=this.colorStops[h].offset;typeof d<"u"&&(u=new r.Color(u).setAlpha(d).toRgba()),e.addColorStop(m,u)}return e}}}),r.util.object.extend(r.Gradient,{fromElement:function(n,e,o,h){var s=parseFloat(o)/(/%$/.test(o)?100:1);s=s<0?0:s>1?1:s,isNaN(s)&&(s=1);var u=n.getElementsByTagName("stop"),d,m=n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage",g=n.getAttribute("gradientTransform")||"",v=[],b,S,E=0,F=0,R;for(n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?(d="linear",b=i(n)):(d="radial",b=l(n)),S=u.length;S--;)v.push(c(u[S],s));R=r.parseTransformAttribute(g),t(e,b,h,m),m==="pixels"&&(E=-e.left,F=-e.top);var z=new r.Gradient({id:n.getAttribute("id"),type:d,coords:b,colorStops:v,gradientUnits:m,gradientTransform:R,offsetX:E,offsetY:F});return z}});function t(n,e,o,h){var s,u;Object.keys(e).forEach(function(d){s=e[d],s==="Infinity"?u=1:s==="-Infinity"?u=0:(u=parseFloat(e[d],10),typeof s=="string"&&/^(\d+\.\d+)%|(\d+)%$/.test(s)&&(u*=.01,h==="pixels"&&((d==="x1"||d==="x2"||d==="r2")&&(u*=o.viewBoxWidth||o.width),(d==="y1"||d==="y2")&&(u*=o.viewBoxHeight||o.height)))),e[d]=u})}})(),(function(){var c=r.util.toFixed;r.Pattern=r.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(i,l){if(i||(i={}),this.id=r.Object.__uid++,this.setOptions(i),!i.source||i.source&&typeof i.source!="string"){l&&l(this);return}else{var a=this;this.source=r.util.createImage(),r.util.loadImage(i.source,function(t,n){a.source=t,l&&l(a,n)},null,this.crossOrigin)}},toObject:function(i){var l=r.Object.NUM_FRACTION_DIGITS,a,t;return typeof this.source.src=="string"?a=this.source.src:typeof this.source=="object"&&this.source.toDataURL&&(a=this.source.toDataURL()),t={type:"pattern",source:a,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:c(this.offsetX,l),offsetY:c(this.offsetY,l),patternTransform:this.patternTransform?this.patternTransform.concat():null},r.util.populateWithProperties(this,t,i),t},toSVG:function(i){var l=typeof this.source=="function"?this.source():this.source,a=l.width/i.width,t=l.height/i.height,n=this.offsetX/i.width,e=this.offsetY/i.height,o="";return(this.repeat==="repeat-x"||this.repeat==="no-repeat")&&(t=1,e&&(t+=Math.abs(e))),(this.repeat==="repeat-y"||this.repeat==="no-repeat")&&(a=1,n&&(a+=Math.abs(n))),l.src?o=l.src:l.toDataURL&&(o=l.toDataURL()),'<pattern id="SVGID_'+this.id+'" x="'+n+'" y="'+e+'" width="'+a+'" height="'+t+`">
12
+ `),d.join("")},toLive:function(n){var e,o=r.util.object.clone(this.coords),h,s;if(this.type){for(this.type==="linear"?e=n.createLinearGradient(o.x1,o.y1,o.x2,o.y2):this.type==="radial"&&(e=n.createRadialGradient(o.x1,o.y1,o.r1,o.x2,o.y2,o.r2)),h=0,s=this.colorStops.length;h<s;h++){var u=this.colorStops[h].color,d=this.colorStops[h].opacity,m=this.colorStops[h].offset;typeof d<"u"&&(u=new r.Color(u).setAlpha(d).toRgba()),e.addColorStop(m,u)}return e}}}),r.util.object.extend(r.Gradient,{fromElement:function(n,e,o,h){var s=parseFloat(o)/(/%$/.test(o)?100:1);s=s<0?0:s>1?1:s,isNaN(s)&&(s=1);var u=n.getElementsByTagName("stop"),d,m=n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage",p=n.getAttribute("gradientTransform")||"",v=[],b,S,E=0,F=0,R;for(n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?(d="linear",b=i(n)):(d="radial",b=l(n)),S=u.length;S--;)v.push(c(u[S],s));R=r.parseTransformAttribute(p),t(e,b,h,m),m==="pixels"&&(E=-e.left,F=-e.top);var z=new r.Gradient({id:n.getAttribute("id"),type:d,coords:b,colorStops:v,gradientUnits:m,gradientTransform:R,offsetX:E,offsetY:F});return z}});function t(n,e,o,h){var s,u;Object.keys(e).forEach(function(d){s=e[d],s==="Infinity"?u=1:s==="-Infinity"?u=0:(u=parseFloat(e[d],10),typeof s=="string"&&/^(\d+\.\d+)%|(\d+)%$/.test(s)&&(u*=.01,h==="pixels"&&((d==="x1"||d==="x2"||d==="r2")&&(u*=o.viewBoxWidth||o.width),(d==="y1"||d==="y2")&&(u*=o.viewBoxHeight||o.height)))),e[d]=u})}})(),(function(){var c=r.util.toFixed;r.Pattern=r.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(i,l){if(i||(i={}),this.id=r.Object.__uid++,this.setOptions(i),!i.source||i.source&&typeof i.source!="string"){l&&l(this);return}else{var a=this;this.source=r.util.createImage(),r.util.loadImage(i.source,function(t,n){a.source=t,l&&l(a,n)},null,this.crossOrigin)}},toObject:function(i){var l=r.Object.NUM_FRACTION_DIGITS,a,t;return typeof this.source.src=="string"?a=this.source.src:typeof this.source=="object"&&this.source.toDataURL&&(a=this.source.toDataURL()),t={type:"pattern",source:a,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:c(this.offsetX,l),offsetY:c(this.offsetY,l),patternTransform:this.patternTransform?this.patternTransform.concat():null},r.util.populateWithProperties(this,t,i),t},toSVG:function(i){var l=typeof this.source=="function"?this.source():this.source,a=l.width/i.width,t=l.height/i.height,n=this.offsetX/i.width,e=this.offsetY/i.height,o="";return(this.repeat==="repeat-x"||this.repeat==="no-repeat")&&(t=1,e&&(t+=Math.abs(e))),(this.repeat==="repeat-y"||this.repeat==="no-repeat")&&(a=1,n&&(a+=Math.abs(n))),l.src?o=l.src:l.toDataURL&&(o=l.toDataURL()),'<pattern id="SVGID_'+this.id+'" x="'+n+'" y="'+e+'" width="'+a+'" height="'+t+`">
13
13
  <image x="0" y="0" width="`+l.width+'" height="'+l.height+'" xlink:href="'+o+`"></image>
14
14
  </pattern>
15
15
  `},setOptions:function(i){for(var l in i)this[l]=i[l]},toLive:function(i){var l=this.source;return!l||typeof l.src<"u"&&(!l.complete||l.naturalWidth===0||l.naturalHeight===0)?"":i.createPattern(l,this.repeat)}})})(),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.toFixed;if(i.Shadow){i.warn("fabric.Shadow is already defined.");return}i.Shadow=i.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(a){typeof a=="string"&&(a=this._parseShadow(a));for(var t in a)this[t]=a[t];this.id=i.Object.__uid++},_parseShadow:function(a){var t=a.trim(),n=i.Shadow.reOffsetsAndBlur.exec(t)||[],e=t.replace(i.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)";return{color:e.trim(),offsetX:parseFloat(n[1],10)||0,offsetY:parseFloat(n[2],10)||0,blur:parseFloat(n[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(a){var t=40,n=40,e=i.Object.NUM_FRACTION_DIGITS,o=i.util.rotateVector({x:this.offsetX,y:this.offsetY},i.util.degreesToRadians(-a.angle)),h=20,s=new i.Color(this.color);return a.width&&a.height&&(t=l((Math.abs(o.x)+this.blur)/a.width,e)*100+h,n=l((Math.abs(o.y)+this.blur)/a.height,e)*100+h),a.flipX&&(o.x*=-1),a.flipY&&(o.y*=-1),'<filter id="SVGID_'+this.id+'" y="-'+n+'%" height="'+(100+2*n)+'%" x="-'+t+'%" width="'+(100+2*t)+`%" >
@@ -22,47 +22,47 @@ Component that was made reactive: `,f)),eo(f,r,p,_,y,T,C,!0)}function no(f){retu
22
22
  <feMergeNode in="SourceGraphic"></feMergeNode>
23
23
  </feMerge>
24
24
  </filter>
25
- `},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var a={},t=i.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach(function(n){this[n]!==t[n]&&(a[n]=this[n])},this),a}}),i.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/})(f),(function(){if(r.StaticCanvas){r.warn("fabric.StaticCanvas is already defined.");return}var c=r.util.object.extend,i=r.util.getElementOffset,l=r.util.removeFromArray,a=r.util.toFixed,t=r.util.transformPoint,n=r.util.invertTransform,e=r.util.getNodeCanvas,o=r.util.createCanvasElement,h=new Error("Could not initialize `canvas` element");r.StaticCanvas=r.util.createClass(r.CommonMethods,{initialize:function(s,u){u||(u={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(s,u)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:r.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(s,u){var d=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(s),this._initOptions(u),this.interactive||this._initRetinaScaling(),u.overlayImage&&this.setOverlayImage(u.overlayImage,d),u.backgroundImage&&this.setBackgroundImage(u.backgroundImage,d),u.backgroundColor&&this.setBackgroundColor(u.backgroundColor,d),u.overlayColor&&this.setOverlayColor(u.overlayColor,d),this.calcOffset()},_isRetinaScaling:function(){return r.devicePixelRatio>1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?Math.max(1,r.devicePixelRatio):1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var s=r.devicePixelRatio;this.__initRetinaScaling(s,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(s,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(s,u,d){u.setAttribute("width",this.width*s),u.setAttribute("height",this.height*s),d.scale(s,s)},calcOffset:function(){return this._offset=i(this.lowerCanvasEl),this},setOverlayImage:function(s,u,d){return this.__setBgOverlayImage("overlayImage",s,u,d)},setBackgroundImage:function(s,u,d){return this.__setBgOverlayImage("backgroundImage",s,u,d)},setOverlayColor:function(s,u){return this.__setBgOverlayColor("overlayColor",s,u)},setBackgroundColor:function(s,u){return this.__setBgOverlayColor("backgroundColor",s,u)},__setBgOverlayImage:function(s,u,d,m){return typeof u=="string"?r.util.loadImage(u,function(g,v){if(g){var b=new r.Image(g,m);this[s]=b,b.canvas=this}d&&d(g,v)},this,m&&m.crossOrigin):(m&&u.setOptions(m),this[s]=u,u&&(u.canvas=this),d&&d(u,!1)),this},__setBgOverlayColor:function(s,u,d){return this[s]=u,this._initGradient(u,s),this._initPattern(u,s,d),this},_createCanvasElement:function(){var s=o();if(!s||(s.style||(s.style={}),typeof s.getContext>"u"))throw h;return s},_initOptions:function(s){var u=this.lowerCanvasEl;this._setOptions(s),this.width=this.width||parseInt(u.width,10)||0,this.height=this.height||parseInt(u.height,10)||0,this.lowerCanvasEl.style&&(u.width=this.width,u.height=this.height,u.style.width=this.width+"px",u.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(s){s&&s.getContext?this.lowerCanvasEl=s:this.lowerCanvasEl=r.util.getById(s)||this._createCanvasElement(),r.util.addClass(this.lowerCanvasEl,"lower-canvas"),this._originalCanvasStyle=this.lowerCanvasEl.style,this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(s,u){return this.setDimensions({width:s},u)},setHeight:function(s,u){return this.setDimensions({height:s},u)},setDimensions:function(s,u){var d;u=u||{};for(var m in s)d=s[m],u.cssOnly||(this._setBackstoreDimension(m,s[m]),d+="px",this.hasLostContext=!0),u.backstoreOnly||this._setCssDimension(m,d);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop),this._initRetinaScaling(),this.calcOffset(),u.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(s,u){return this.lowerCanvasEl[s]=u,this.upperCanvasEl&&(this.upperCanvasEl[s]=u),this.cacheCanvasEl&&(this.cacheCanvasEl[s]=u),this[s]=u,this},_setCssDimension:function(s,u){return this.lowerCanvasEl.style[s]=u,this.upperCanvasEl&&(this.upperCanvasEl.style[s]=u),this.wrapperEl&&(this.wrapperEl.style[s]=u),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(s){var u=this._activeObject,d=this.backgroundImage,m=this.overlayImage,g,v,b;for(this.viewportTransform=s,v=0,b=this._objects.length;v<b;v++)g=this._objects[v],g.group||g.setCoords(!0);return u&&u.setCoords(),d&&d.setCoords(!0),m&&m.setCoords(!0),this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll(),this},zoomToPoint:function(s,u){var d=s,m=this.viewportTransform.slice(0);s=t(s,n(this.viewportTransform)),m[0]=u,m[3]=u;var g=t(s,m);return m[4]+=d.x-g.x,m[5]+=d.y-g.y,this.setViewportTransform(m)},setZoom:function(s){return this.zoomToPoint(new r.Point(0,0),s),this},absolutePan:function(s){var u=this.viewportTransform.slice(0);return u[4]=-s.x,u[5]=-s.y,this.setViewportTransform(u)},relativePan:function(s){return this.absolutePan(new r.Point(-s.x-this.viewportTransform[4],-s.y-this.viewportTransform[5]))},getElement:function(){return this.lowerCanvasEl},_onObjectAdded:function(s){this.stateful&&s.setupState(),s._set("canvas",this),s.setCoords(),this.fire("object:added",{target:s}),s.fire("added")},_onObjectRemoved:function(s){this.fire("object:removed",{target:s}),s.fire("removed"),delete s.canvas},clearContext:function(s){return s.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this.remove.apply(this,this.getObjects()),this.backgroundImage=null,this.overlayImage=null,this.backgroundColor="",this.overlayColor="",this._hasITextHandlers&&(this.off("mouse:up",this._mouseUpITextHandler),this._iTextInstances=null,this._hasITextHandlers=!1),this.clearContext(this.contextContainer),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll(),this},renderAll:function(){var s=this.contextContainer;return this.renderCanvas(s,this._objects),this},renderAndReset:function(){this.isRendering=0,this.renderAll()},requestRenderAll:function(){return this.isRendering||(this.isRendering=r.util.requestAnimFrame(this.renderAndResetBound)),this},calcViewportBoundaries:function(){var s={},u=this.width,d=this.height,m=n(this.viewportTransform);return s.tl=t({x:0,y:0},m),s.br=t({x:u,y:d},m),s.tr=new r.Point(s.br.x,s.tl.y),s.bl=new r.Point(s.tl.x,s.br.y),this.vptCoords=s,s},cancelRequestedRender:function(){this.isRendering&&(r.util.cancelAnimFrame(this.isRendering),this.isRendering=0)},renderCanvas:function(s,u){var d=this.viewportTransform,m=this.clipPath;this.cancelRequestedRender(),this.calcViewportBoundaries(),this.clearContext(s),r.util.setImageSmoothing(s,this.imageSmoothingEnabled),this.fire("before:render",{ctx:s}),this._renderBackground(s),s.save(),s.transform(d[0],d[1],d[2],d[3],d[4],d[5]),this._renderObjects(s,u),s.restore(),!this.controlsAboveOverlay&&this.interactive&&this.drawControls(s),m&&(m.canvas=this,m.shouldCache(),m._transformDone=!0,m.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(s)),this._renderOverlay(s),this.controlsAboveOverlay&&this.interactive&&this.drawControls(s),this.fire("after:render",{ctx:s})},drawClipPathOnCanvas:function(s){var u=this.viewportTransform,d=this.clipPath;s.save(),s.transform(u[0],u[1],u[2],u[3],u[4],u[5]),s.globalCompositeOperation="destination-in",d.transform(s),s.scale(1/d.zoomX,1/d.zoomY),s.drawImage(d._cacheCanvas,-d.cacheTranslationX,-d.cacheTranslationY),s.restore()},_renderObjects:function(s,u){var d,m;for(d=0,m=u.length;d<m;++d)u[d]&&u[d].render(s)},_renderBackgroundOrOverlay:function(s,u){var d=this[u+"Color"],m=this[u+"Image"],g=this.viewportTransform,v=this[u+"Vpt"];if(!(!d&&!m)){if(d){s.save(),s.beginPath(),s.moveTo(0,0),s.lineTo(this.width,0),s.lineTo(this.width,this.height),s.lineTo(0,this.height),s.closePath(),s.fillStyle=d.toLive?d.toLive(s,this):d,v&&s.transform(g[0],g[1],g[2],g[3],g[4],g[5]),s.transform(1,0,0,1,d.offsetX||0,d.offsetY||0);var b=d.gradientTransform||d.patternTransform;b&&s.transform(b[0],b[1],b[2],b[3],b[4],b[5]),s.fill(),s.restore()}m&&(s.save(),v&&s.transform(g[0],g[1],g[2],g[3],g[4],g[5]),m.render(s),s.restore())}},_renderBackground:function(s){this._renderBackgroundOrOverlay(s,"background")},_renderOverlay:function(s){this._renderBackgroundOrOverlay(s,"overlay")},getCenter:function(){return{top:this.height/2,left:this.width/2}},getCenterPoint:function(){return new r.Point(this.width/2,this.height/2)},centerObjectH:function(s){return this._centerObject(s,new r.Point(this.getCenterPoint().x,s.getCenterPoint().y))},centerObjectV:function(s){return this._centerObject(s,new r.Point(s.getCenterPoint().x,this.getCenterPoint().y))},centerObject:function(s){var u=this.getCenterPoint();return this._centerObject(s,u)},viewportCenterObject:function(s){var u=this.getVpCenter();return this._centerObject(s,u)},viewportCenterObjectH:function(s){var u=this.getVpCenter();return this._centerObject(s,new r.Point(u.x,s.getCenterPoint().y)),this},viewportCenterObjectV:function(s){var u=this.getVpCenter();return this._centerObject(s,new r.Point(s.getCenterPoint().x,u.y))},getVpCenter:function(){var s=this.getCenterPoint(),u=n(this.viewportTransform);return t(s,u)},_centerObject:function(s,u){return s.setPositionByOrigin(u,"center","center"),s.setCoords(),this.renderOnAddRemove&&this.requestRenderAll(),this},toDatalessJSON:function(s){return this.toDatalessObject(s)},toObject:function(s){return this._toObjectMethod("toObject",s)},toDatalessObject:function(s){return this._toObjectMethod("toDatalessObject",s)},_toObjectMethod:function(s,u){var d=this.clipPath,m={version:r.version,objects:this._toObjects(s,u)};return d&&!d.excludeFromExport&&(m.clipPath=this._toObject(this.clipPath,s,u)),c(m,this.__serializeBgOverlay(s,u)),r.util.populateWithProperties(this,m,u),m},_toObjects:function(s,u){return this._objects.filter(function(d){return!d.excludeFromExport}).map(function(d){return this._toObject(d,s,u)},this)},_toObject:function(s,u,d){var m;this.includeDefaultValues||(m=s.includeDefaultValues,s.includeDefaultValues=!1);var g=s[u](d);return this.includeDefaultValues||(s.includeDefaultValues=m),g},__serializeBgOverlay:function(s,u){var d={},m=this.backgroundImage,g=this.overlayImage,v=this.backgroundColor,b=this.overlayColor;return v&&v.toObject?v.excludeFromExport||(d.background=v.toObject(u)):v&&(d.background=v),b&&b.toObject?b.excludeFromExport||(d.overlay=b.toObject(u)):b&&(d.overlay=b),m&&!m.excludeFromExport&&(d.backgroundImage=this._toObject(m,s,u)),g&&!g.excludeFromExport&&(d.overlayImage=this._toObject(g,s,u)),d},svgViewportTransformation:!0,toSVG:function(s,u){s||(s={}),s.reviver=u;var d=[];return this._setSVGPreamble(d,s),this._setSVGHeader(d,s),this.clipPath&&d.push('<g clip-path="url(#'+this.clipPath.clipPathId+`)" >
25
+ `},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var a={},t=i.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach(function(n){this[n]!==t[n]&&(a[n]=this[n])},this),a}}),i.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/})(f),(function(){if(r.StaticCanvas){r.warn("fabric.StaticCanvas is already defined.");return}var c=r.util.object.extend,i=r.util.getElementOffset,l=r.util.removeFromArray,a=r.util.toFixed,t=r.util.transformPoint,n=r.util.invertTransform,e=r.util.getNodeCanvas,o=r.util.createCanvasElement,h=new Error("Could not initialize `canvas` element");r.StaticCanvas=r.util.createClass(r.CommonMethods,{initialize:function(s,u){u||(u={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(s,u)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:r.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(s,u){var d=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(s),this._initOptions(u),this.interactive||this._initRetinaScaling(),u.overlayImage&&this.setOverlayImage(u.overlayImage,d),u.backgroundImage&&this.setBackgroundImage(u.backgroundImage,d),u.backgroundColor&&this.setBackgroundColor(u.backgroundColor,d),u.overlayColor&&this.setOverlayColor(u.overlayColor,d),this.calcOffset()},_isRetinaScaling:function(){return r.devicePixelRatio>1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?Math.max(1,r.devicePixelRatio):1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var s=r.devicePixelRatio;this.__initRetinaScaling(s,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(s,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(s,u,d){u.setAttribute("width",this.width*s),u.setAttribute("height",this.height*s),d.scale(s,s)},calcOffset:function(){return this._offset=i(this.lowerCanvasEl),this},setOverlayImage:function(s,u,d){return this.__setBgOverlayImage("overlayImage",s,u,d)},setBackgroundImage:function(s,u,d){return this.__setBgOverlayImage("backgroundImage",s,u,d)},setOverlayColor:function(s,u){return this.__setBgOverlayColor("overlayColor",s,u)},setBackgroundColor:function(s,u){return this.__setBgOverlayColor("backgroundColor",s,u)},__setBgOverlayImage:function(s,u,d,m){return typeof u=="string"?r.util.loadImage(u,function(p,v){if(p){var b=new r.Image(p,m);this[s]=b,b.canvas=this}d&&d(p,v)},this,m&&m.crossOrigin):(m&&u.setOptions(m),this[s]=u,u&&(u.canvas=this),d&&d(u,!1)),this},__setBgOverlayColor:function(s,u,d){return this[s]=u,this._initGradient(u,s),this._initPattern(u,s,d),this},_createCanvasElement:function(){var s=o();if(!s||(s.style||(s.style={}),typeof s.getContext>"u"))throw h;return s},_initOptions:function(s){var u=this.lowerCanvasEl;this._setOptions(s),this.width=this.width||parseInt(u.width,10)||0,this.height=this.height||parseInt(u.height,10)||0,this.lowerCanvasEl.style&&(u.width=this.width,u.height=this.height,u.style.width=this.width+"px",u.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(s){s&&s.getContext?this.lowerCanvasEl=s:this.lowerCanvasEl=r.util.getById(s)||this._createCanvasElement(),r.util.addClass(this.lowerCanvasEl,"lower-canvas"),this._originalCanvasStyle=this.lowerCanvasEl.style,this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(s,u){return this.setDimensions({width:s},u)},setHeight:function(s,u){return this.setDimensions({height:s},u)},setDimensions:function(s,u){var d;u=u||{};for(var m in s)d=s[m],u.cssOnly||(this._setBackstoreDimension(m,s[m]),d+="px",this.hasLostContext=!0),u.backstoreOnly||this._setCssDimension(m,d);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop),this._initRetinaScaling(),this.calcOffset(),u.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(s,u){return this.lowerCanvasEl[s]=u,this.upperCanvasEl&&(this.upperCanvasEl[s]=u),this.cacheCanvasEl&&(this.cacheCanvasEl[s]=u),this[s]=u,this},_setCssDimension:function(s,u){return this.lowerCanvasEl.style[s]=u,this.upperCanvasEl&&(this.upperCanvasEl.style[s]=u),this.wrapperEl&&(this.wrapperEl.style[s]=u),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(s){var u=this._activeObject,d=this.backgroundImage,m=this.overlayImage,p,v,b;for(this.viewportTransform=s,v=0,b=this._objects.length;v<b;v++)p=this._objects[v],p.group||p.setCoords(!0);return u&&u.setCoords(),d&&d.setCoords(!0),m&&m.setCoords(!0),this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll(),this},zoomToPoint:function(s,u){var d=s,m=this.viewportTransform.slice(0);s=t(s,n(this.viewportTransform)),m[0]=u,m[3]=u;var p=t(s,m);return m[4]+=d.x-p.x,m[5]+=d.y-p.y,this.setViewportTransform(m)},setZoom:function(s){return this.zoomToPoint(new r.Point(0,0),s),this},absolutePan:function(s){var u=this.viewportTransform.slice(0);return u[4]=-s.x,u[5]=-s.y,this.setViewportTransform(u)},relativePan:function(s){return this.absolutePan(new r.Point(-s.x-this.viewportTransform[4],-s.y-this.viewportTransform[5]))},getElement:function(){return this.lowerCanvasEl},_onObjectAdded:function(s){this.stateful&&s.setupState(),s._set("canvas",this),s.setCoords(),this.fire("object:added",{target:s}),s.fire("added")},_onObjectRemoved:function(s){this.fire("object:removed",{target:s}),s.fire("removed"),delete s.canvas},clearContext:function(s){return s.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this.remove.apply(this,this.getObjects()),this.backgroundImage=null,this.overlayImage=null,this.backgroundColor="",this.overlayColor="",this._hasITextHandlers&&(this.off("mouse:up",this._mouseUpITextHandler),this._iTextInstances=null,this._hasITextHandlers=!1),this.clearContext(this.contextContainer),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll(),this},renderAll:function(){var s=this.contextContainer;return this.renderCanvas(s,this._objects),this},renderAndReset:function(){this.isRendering=0,this.renderAll()},requestRenderAll:function(){return this.isRendering||(this.isRendering=r.util.requestAnimFrame(this.renderAndResetBound)),this},calcViewportBoundaries:function(){var s={},u=this.width,d=this.height,m=n(this.viewportTransform);return s.tl=t({x:0,y:0},m),s.br=t({x:u,y:d},m),s.tr=new r.Point(s.br.x,s.tl.y),s.bl=new r.Point(s.tl.x,s.br.y),this.vptCoords=s,s},cancelRequestedRender:function(){this.isRendering&&(r.util.cancelAnimFrame(this.isRendering),this.isRendering=0)},renderCanvas:function(s,u){var d=this.viewportTransform,m=this.clipPath;this.cancelRequestedRender(),this.calcViewportBoundaries(),this.clearContext(s),r.util.setImageSmoothing(s,this.imageSmoothingEnabled),this.fire("before:render",{ctx:s}),this._renderBackground(s),s.save(),s.transform(d[0],d[1],d[2],d[3],d[4],d[5]),this._renderObjects(s,u),s.restore(),!this.controlsAboveOverlay&&this.interactive&&this.drawControls(s),m&&(m.canvas=this,m.shouldCache(),m._transformDone=!0,m.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(s)),this._renderOverlay(s),this.controlsAboveOverlay&&this.interactive&&this.drawControls(s),this.fire("after:render",{ctx:s})},drawClipPathOnCanvas:function(s){var u=this.viewportTransform,d=this.clipPath;s.save(),s.transform(u[0],u[1],u[2],u[3],u[4],u[5]),s.globalCompositeOperation="destination-in",d.transform(s),s.scale(1/d.zoomX,1/d.zoomY),s.drawImage(d._cacheCanvas,-d.cacheTranslationX,-d.cacheTranslationY),s.restore()},_renderObjects:function(s,u){var d,m;for(d=0,m=u.length;d<m;++d)u[d]&&u[d].render(s)},_renderBackgroundOrOverlay:function(s,u){var d=this[u+"Color"],m=this[u+"Image"],p=this.viewportTransform,v=this[u+"Vpt"];if(!(!d&&!m)){if(d){s.save(),s.beginPath(),s.moveTo(0,0),s.lineTo(this.width,0),s.lineTo(this.width,this.height),s.lineTo(0,this.height),s.closePath(),s.fillStyle=d.toLive?d.toLive(s,this):d,v&&s.transform(p[0],p[1],p[2],p[3],p[4],p[5]),s.transform(1,0,0,1,d.offsetX||0,d.offsetY||0);var b=d.gradientTransform||d.patternTransform;b&&s.transform(b[0],b[1],b[2],b[3],b[4],b[5]),s.fill(),s.restore()}m&&(s.save(),v&&s.transform(p[0],p[1],p[2],p[3],p[4],p[5]),m.render(s),s.restore())}},_renderBackground:function(s){this._renderBackgroundOrOverlay(s,"background")},_renderOverlay:function(s){this._renderBackgroundOrOverlay(s,"overlay")},getCenter:function(){return{top:this.height/2,left:this.width/2}},getCenterPoint:function(){return new r.Point(this.width/2,this.height/2)},centerObjectH:function(s){return this._centerObject(s,new r.Point(this.getCenterPoint().x,s.getCenterPoint().y))},centerObjectV:function(s){return this._centerObject(s,new r.Point(s.getCenterPoint().x,this.getCenterPoint().y))},centerObject:function(s){var u=this.getCenterPoint();return this._centerObject(s,u)},viewportCenterObject:function(s){var u=this.getVpCenter();return this._centerObject(s,u)},viewportCenterObjectH:function(s){var u=this.getVpCenter();return this._centerObject(s,new r.Point(u.x,s.getCenterPoint().y)),this},viewportCenterObjectV:function(s){var u=this.getVpCenter();return this._centerObject(s,new r.Point(s.getCenterPoint().x,u.y))},getVpCenter:function(){var s=this.getCenterPoint(),u=n(this.viewportTransform);return t(s,u)},_centerObject:function(s,u){return s.setPositionByOrigin(u,"center","center"),s.setCoords(),this.renderOnAddRemove&&this.requestRenderAll(),this},toDatalessJSON:function(s){return this.toDatalessObject(s)},toObject:function(s){return this._toObjectMethod("toObject",s)},toDatalessObject:function(s){return this._toObjectMethod("toDatalessObject",s)},_toObjectMethod:function(s,u){var d=this.clipPath,m={version:r.version,objects:this._toObjects(s,u)};return d&&!d.excludeFromExport&&(m.clipPath=this._toObject(this.clipPath,s,u)),c(m,this.__serializeBgOverlay(s,u)),r.util.populateWithProperties(this,m,u),m},_toObjects:function(s,u){return this._objects.filter(function(d){return!d.excludeFromExport}).map(function(d){return this._toObject(d,s,u)},this)},_toObject:function(s,u,d){var m;this.includeDefaultValues||(m=s.includeDefaultValues,s.includeDefaultValues=!1);var p=s[u](d);return this.includeDefaultValues||(s.includeDefaultValues=m),p},__serializeBgOverlay:function(s,u){var d={},m=this.backgroundImage,p=this.overlayImage,v=this.backgroundColor,b=this.overlayColor;return v&&v.toObject?v.excludeFromExport||(d.background=v.toObject(u)):v&&(d.background=v),b&&b.toObject?b.excludeFromExport||(d.overlay=b.toObject(u)):b&&(d.overlay=b),m&&!m.excludeFromExport&&(d.backgroundImage=this._toObject(m,s,u)),p&&!p.excludeFromExport&&(d.overlayImage=this._toObject(p,s,u)),d},svgViewportTransformation:!0,toSVG:function(s,u){s||(s={}),s.reviver=u;var d=[];return this._setSVGPreamble(d,s),this._setSVGHeader(d,s),this.clipPath&&d.push('<g clip-path="url(#'+this.clipPath.clipPathId+`)" >
26
26
  `),this._setSVGBgOverlayColor(d,"background"),this._setSVGBgOverlayImage(d,"backgroundImage",u),this._setSVGObjects(d,u),this.clipPath&&d.push(`</g>
27
27
  `),this._setSVGBgOverlayColor(d,"overlay"),this._setSVGBgOverlayImage(d,"overlayImage",u),d.push("</svg>"),d.join("")},_setSVGPreamble:function(s,u){u.suppressPreamble||s.push('<?xml version="1.0" encoding="',u.encoding||"UTF-8",`" standalone="no" ?>
28
28
  `,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
29
- `)},_setSVGHeader:function(s,u){var d=u.width||this.width,m=u.height||this.height,g,v='viewBox="0 0 '+this.width+" "+this.height+'" ',b=r.Object.NUM_FRACTION_DIGITS;u.viewBox?v='viewBox="'+u.viewBox.x+" "+u.viewBox.y+" "+u.viewBox.width+" "+u.viewBox.height+'" ':this.svgViewportTransformation&&(g=this.viewportTransform,v='viewBox="'+a(-g[4]/g[0],b)+" "+a(-g[5]/g[3],b)+" "+a(this.width/g[0],b)+" "+a(this.height/g[3],b)+'" '),s.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',d,'" ','height="',m,'" ',v,`xml:space="preserve">
29
+ `)},_setSVGHeader:function(s,u){var d=u.width||this.width,m=u.height||this.height,p,v='viewBox="0 0 '+this.width+" "+this.height+'" ',b=r.Object.NUM_FRACTION_DIGITS;u.viewBox?v='viewBox="'+u.viewBox.x+" "+u.viewBox.y+" "+u.viewBox.width+" "+u.viewBox.height+'" ':this.svgViewportTransformation&&(p=this.viewportTransform,v='viewBox="'+a(-p[4]/p[0],b)+" "+a(-p[5]/p[3],b)+" "+a(this.width/p[0],b)+" "+a(this.height/p[3],b)+'" '),s.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',d,'" ','height="',m,'" ',v,`xml:space="preserve">
30
30
  `,"<desc>Created with Fabric.js ",r.version,`</desc>
31
31
  `,`<defs>
32
32
  `,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(u),`</defs>
33
33
  `)},createSVGClipPathMarkup:function(s){var u=this.clipPath;return u?(u.clipPathId="CLIPPATH_"+r.Object.__uid++,'<clipPath id="'+u.clipPathId+`" >
34
34
  `+this.clipPath.toClipPathSVG(s.reviver)+`</clipPath>
35
- `):""},createSVGRefElementsMarkup:function(){var s=this,u=["background","overlay"].map(function(d){var m=s[d+"Color"];if(m&&m.toLive){var g=s[d+"Vpt"],v=s.viewportTransform,b={width:s.width/(g?v[0]:1),height:s.height/(g?v[3]:1)};return m.toSVG(b,{additionalTransform:g?r.util.matrixToSVG(v):""})}});return u.join("")},createSVGFontFacesMarkup:function(){var s="",u={},d,m,g,v,b,S,E,F,R,z=r.fontPaths,q=[];for(this._objects.forEach(function K($){q.push($),$._objects&&$._objects.forEach(K)}),F=0,R=q.length;F<R;F++)if(d=q[F],m=d.fontFamily,!(d.type.indexOf("text")===-1||u[m]||!z[m])&&(u[m]=!0,!!d.styles)){g=d.styles;for(b in g){v=g[b];for(E in v)S=v[E],m=S.fontFamily,!u[m]&&z[m]&&(u[m]=!0)}}for(var Z in u)s+=[` @font-face {
35
+ `):""},createSVGRefElementsMarkup:function(){var s=this,u=["background","overlay"].map(function(d){var m=s[d+"Color"];if(m&&m.toLive){var p=s[d+"Vpt"],v=s.viewportTransform,b={width:s.width/(p?v[0]:1),height:s.height/(p?v[3]:1)};return m.toSVG(b,{additionalTransform:p?r.util.matrixToSVG(v):""})}});return u.join("")},createSVGFontFacesMarkup:function(){var s="",u={},d,m,p,v,b,S,E,F,R,z=r.fontPaths,K=[];for(this._objects.forEach(function q($){K.push($),$._objects&&$._objects.forEach(q)}),F=0,R=K.length;F<R;F++)if(d=K[F],m=d.fontFamily,!(d.type.indexOf("text")===-1||u[m]||!z[m])&&(u[m]=!0,!!d.styles)){p=d.styles;for(b in p){v=p[b];for(E in v)S=v[E],m=S.fontFamily,!u[m]&&z[m]&&(u[m]=!0)}}for(var Z in u)s+=[` @font-face {
36
36
  `," font-family: '",Z,`';
37
37
  `," src: url('",z[Z],`');
38
38
  `,` }
39
39
  `].join("");return s&&(s=[' <style type="text/css">',`<![CDATA[
40
40
  `,s,"]]>",`</style>
41
- `].join("")),s},_setSVGObjects:function(s,u){var d,m,g,v=this._objects;for(m=0,g=v.length;m<g;m++)d=v[m],!d.excludeFromExport&&this._setSVGObject(s,d,u)},_setSVGObject:function(s,u,d){s.push(u.toSVG(d))},_setSVGBgOverlayImage:function(s,u,d){this[u]&&!this[u].excludeFromExport&&this[u].toSVG&&s.push(this[u].toSVG(d))},_setSVGBgOverlayColor:function(s,u){var d=this[u+"Color"],m=this.viewportTransform,g=this.width,v=this.height;if(d)if(d.toLive){var b=d.repeat,S=r.util.invertTransform(m),E=this[u+"Vpt"],F=E?r.util.matrixToSVG(S):"";s.push('<rect transform="'+F+" translate(",g/2,",",v/2,')"',' x="',d.offsetX-g/2,'" y="',d.offsetY-v/2,'" ','width="',b==="repeat-y"||b==="no-repeat"?d.source.width:g,'" height="',b==="repeat-x"||b==="no-repeat"?d.source.height:v,'" fill="url(#SVGID_'+d.id+')"',`></rect>
41
+ `].join("")),s},_setSVGObjects:function(s,u){var d,m,p,v=this._objects;for(m=0,p=v.length;m<p;m++)d=v[m],!d.excludeFromExport&&this._setSVGObject(s,d,u)},_setSVGObject:function(s,u,d){s.push(u.toSVG(d))},_setSVGBgOverlayImage:function(s,u,d){this[u]&&!this[u].excludeFromExport&&this[u].toSVG&&s.push(this[u].toSVG(d))},_setSVGBgOverlayColor:function(s,u){var d=this[u+"Color"],m=this.viewportTransform,p=this.width,v=this.height;if(d)if(d.toLive){var b=d.repeat,S=r.util.invertTransform(m),E=this[u+"Vpt"],F=E?r.util.matrixToSVG(S):"";s.push('<rect transform="'+F+" translate(",p/2,",",v/2,')"',' x="',d.offsetX-p/2,'" y="',d.offsetY-v/2,'" ','width="',b==="repeat-y"||b==="no-repeat"?d.source.width:p,'" height="',b==="repeat-x"||b==="no-repeat"?d.source.height:v,'" fill="url(#SVGID_'+d.id+')"',`></rect>
42
42
  `)}else s.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',d,'"',`></rect>
43
- `)},sendToBack:function(s){if(!s)return this;var u=this._activeObject,d,m,g;if(s===u&&s.type==="activeSelection")for(g=u._objects,d=g.length;d--;)m=g[d],l(this._objects,m),this._objects.unshift(m);else l(this._objects,s),this._objects.unshift(s);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(s){if(!s)return this;var u=this._activeObject,d,m,g;if(s===u&&s.type==="activeSelection")for(g=u._objects,d=0;d<g.length;d++)m=g[d],l(this._objects,m),this._objects.push(m);else l(this._objects,s),this._objects.push(s);return this.renderOnAddRemove&&this.requestRenderAll(),this},sendBackwards:function(s,u){if(!s)return this;var d=this._activeObject,m,g,v,b,S,E=0;if(s===d&&s.type==="activeSelection")for(S=d._objects,m=0;m<S.length;m++)g=S[m],v=this._objects.indexOf(g),v>0+E&&(b=v-1,l(this._objects,g),this._objects.splice(b,0,g)),E++;else v=this._objects.indexOf(s),v!==0&&(b=this._findNewLowerIndex(s,v,u),l(this._objects,s),this._objects.splice(b,0,s));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(s,u,d){var m,g;if(d)for(m=u,g=u-1;g>=0;--g){var v=s.intersectsWithObject(this._objects[g])||s.isContainedWithinObject(this._objects[g])||this._objects[g].isContainedWithinObject(s);if(v){m=g;break}}else m=u-1;return m},bringForward:function(s,u){if(!s)return this;var d=this._activeObject,m,g,v,b,S,E=0;if(s===d&&s.type==="activeSelection")for(S=d._objects,m=S.length;m--;)g=S[m],v=this._objects.indexOf(g),v<this._objects.length-1-E&&(b=v+1,l(this._objects,g),this._objects.splice(b,0,g)),E++;else v=this._objects.indexOf(s),v!==this._objects.length-1&&(b=this._findNewUpperIndex(s,v,u),l(this._objects,s),this._objects.splice(b,0,s));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewUpperIndex:function(s,u,d){var m,g,v;if(d)for(m=u,g=u+1,v=this._objects.length;g<v;++g){var b=s.intersectsWithObject(this._objects[g])||s.isContainedWithinObject(this._objects[g])||this._objects[g].isContainedWithinObject(s);if(b){m=g;break}}else m=u+1;return m},moveTo:function(s,u){return l(this._objects,s),this._objects.splice(u,0,s),this.renderOnAddRemove&&this.requestRenderAll()},dispose:function(){return this.isRendering&&(r.util.cancelAnimFrame(this.isRendering),this.isRendering=0),this.forEachObject(function(s){s.dispose&&s.dispose()}),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,this.lowerCanvasEl.classList.remove("lower-canvas"),r.util.setStyle(this.lowerCanvasEl,this._originalCanvasStyle),delete this._originalCanvasStyle,this.lowerCanvasEl.setAttribute("width",this.width),this.lowerCanvasEl.setAttribute("height",this.height),r.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},toString:function(){return"#<fabric.Canvas ("+this.complexity()+"): { objects: "+this._objects.length+" }>"}}),c(r.StaticCanvas.prototype,r.Observable),c(r.StaticCanvas.prototype,r.Collection),c(r.StaticCanvas.prototype,r.DataURLExporter),c(r.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(s){var u=o();if(!u||!u.getContext)return null;var d=u.getContext("2d");if(!d)return null;switch(s){case"setLineDash":return typeof d.setLineDash<"u";default:return null}}}),r.StaticCanvas.prototype.toJSON=r.StaticCanvas.prototype.toObject,r.isLikelyNode&&(r.StaticCanvas.prototype.createPNGStream=function(){var s=e(this.lowerCanvasEl);return s&&s.createPNGStream()},r.StaticCanvas.prototype.createJPEGStream=function(s){var u=e(this.lowerCanvasEl);return u&&u.createJPEGStream(s)})})(),r.BaseBrush=r.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,limitedToCanvasSize:!1,_setBrushStyles:function(c){c.strokeStyle=this.color,c.lineWidth=this.width,c.lineCap=this.strokeLineCap,c.miterLimit=this.strokeMiterLimit,c.lineJoin=this.strokeLineJoin,c.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(c){var i=this.canvas.viewportTransform;c.save(),c.transform(i[0],i[1],i[2],i[3],i[4],i[5])},_setShadow:function(){if(this.shadow){var c=this.canvas,i=this.shadow,l=c.contextTop,a=c.getZoom();c&&c._isRetinaScaling()&&(a*=r.devicePixelRatio),l.shadowColor=i.color,l.shadowBlur=i.blur*a,l.shadowOffsetX=i.offsetX*a,l.shadowOffsetY=i.offsetY*a}},needsFullRender:function(){var c=new r.Color(this.color);return c.getAlpha()<1||!!this.shadow},_resetShadow:function(){var c=this.canvas.contextTop;c.shadowColor="",c.shadowBlur=c.shadowOffsetX=c.shadowOffsetY=0},_isOutSideCanvas:function(c){return c.x<0||c.x>this.canvas.getWidth()||c.y<0||c.y>this.canvas.getHeight()}}),(function(){r.PencilBrush=r.util.createClass(r.BaseBrush,{decimate:.4,drawStraightLine:!1,straightLineKey:"shiftKey",initialize:function(c){this.canvas=c,this._points=[]},needsFullRender:function(){return this.callSuper("needsFullRender")||this._hasStraightLine},_drawSegment:function(c,i,l){var a=i.midPointFrom(l);return c.quadraticCurveTo(i.x,i.y,a.x,a.y),a},onMouseDown:function(c,i){this.canvas._isMainEvent(i.e)&&(this.drawStraightLine=i.e[this.straightLineKey],this._prepareForDrawing(c),this._captureDrawingPath(c),this._render())},onMouseMove:function(c,i){if(this.canvas._isMainEvent(i.e)&&(this.drawStraightLine=i.e[this.straightLineKey],!(this.limitedToCanvasSize===!0&&this._isOutSideCanvas(c))&&this._captureDrawingPath(c)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var l=this._points,a=l.length,t=this.canvas.contextTop;this._saveAndTransform(t),this.oldEnd&&(t.beginPath(),t.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(t,l[a-2],l[a-1],!0),t.stroke(),t.restore()}},onMouseUp:function(c){return this.canvas._isMainEvent(c.e)?(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1):!0},_prepareForDrawing:function(c){var i=new r.Point(c.x,c.y);this._reset(),this._addPoint(i),this.canvas.contextTop.moveTo(i.x,i.y)},_addPoint:function(c){return this._points.length>1&&c.eq(this._points[this._points.length-1])?!1:(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(c),!0)},_reset:function(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1},_captureDrawingPath:function(c){var i=new r.Point(c.x,c.y);return this._addPoint(i)},_render:function(c){var i,l,a=this._points[0],t=this._points[1];if(c=c||this.canvas.contextTop,this._saveAndTransform(c),c.beginPath(),this._points.length===2&&a.x===t.x&&a.y===t.y){var n=this.width/1e3;a=new r.Point(a.x,a.y),t=new r.Point(t.x,t.y),a.x-=n,t.x+=n}for(c.moveTo(a.x,a.y),i=1,l=this._points.length;i<l;i++)this._drawSegment(c,a,t),a=this._points[i],t=this._points[i+1];c.lineTo(a.x,a.y),c.stroke(),c.restore()},convertPointsToSVGPath:function(c){var i=this.width/1e3;return r.util.getSmoothPathFromPoints(c,i)},_isEmptySVGPath:function(c){var i=r.util.joinPath(c);return i==="M 0 0 Q 0 0 0 0 L 0 0"},createPath:function(c){var i=new r.Path(c,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeMiterLimit:this.strokeMiterLimit,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray});return this.shadow&&(this.shadow.affectStroke=!0,i.shadow=new r.Shadow(this.shadow)),i},decimatePoints:function(c,i){if(c.length<=2)return c;var l=this.canvas.getZoom(),a=Math.pow(i/l,2),t,n=c.length-1,e=c[0],o=[e],h;for(t=1;t<n-1;t++)h=Math.pow(e.x-c[t].x,2)+Math.pow(e.y-c[t].y,2),h>=a&&(e=c[t],o.push(e));return o.push(c[n]),o},_finalizeAndAddPath:function(){var c=this.canvas.contextTop;c.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var i=this.convertPointsToSVGPath(this._points);if(this._isEmptySVGPath(i)){this.canvas.requestRenderAll();return}var l=this.createPath(i);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:l}),this.canvas.add(l),this.canvas.requestRenderAll(),l.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:l})}})})(),r.CircleBrush=r.util.createClass(r.BaseBrush,{width:10,initialize:function(c){this.canvas=c,this.points=[]},drawDot:function(c){var i=this.addPoint(c),l=this.canvas.contextTop;this._saveAndTransform(l),this.dot(l,i),l.restore()},dot:function(c,i){c.fillStyle=i.fill,c.beginPath(),c.arc(i.x,i.y,i.radius,0,Math.PI*2,!1),c.closePath(),c.fill()},onMouseDown:function(c){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(c)},_render:function(){var c=this.canvas.contextTop,i,l,a=this.points;for(this._saveAndTransform(c),i=0,l=a.length;i<l;i++)this.dot(c,a[i]);c.restore()},onMouseMove:function(c){this.limitedToCanvasSize===!0&&this._isOutSideCanvas(c)||(this.needsFullRender()?(this.canvas.clearContext(this.canvas.contextTop),this.addPoint(c),this._render()):this.drawDot(c))},onMouseUp:function(){var c=this.canvas.renderOnAddRemove,i,l;this.canvas.renderOnAddRemove=!1;var a=[];for(i=0,l=this.points.length;i<l;i++){var t=this.points[i],n=new r.Circle({radius:t.radius,left:t.x,top:t.y,originX:"center",originY:"center",fill:t.fill});this.shadow&&(n.shadow=new r.Shadow(this.shadow)),a.push(n)}var e=new r.Group(a);e.canvas=this.canvas,this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.fire("path:created",{path:e}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=c,this.canvas.requestRenderAll()},addPoint:function(c){var i=new r.Point(c.x,c.y),l=r.util.getRandomInt(Math.max(0,this.width-20),this.width+20)/2,a=new r.Color(this.color).setAlpha(r.util.getRandomInt(0,100)/100).toRgba();return i.radius=l,i.fill=a,this.points.push(i),i}}),r.SprayBrush=r.util.createClass(r.BaseBrush,{width:10,density:20,dotWidth:1,dotWidthVariance:1,randomOpacity:!1,optimizeOverlapping:!0,initialize:function(c){this.canvas=c,this.sprayChunks=[]},onMouseDown:function(c){this.sprayChunks.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(c),this.render(this.sprayChunkPoints)},onMouseMove:function(c){this.limitedToCanvasSize===!0&&this._isOutSideCanvas(c)||(this.addSprayChunk(c),this.render(this.sprayChunkPoints))},onMouseUp:function(){var c=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;for(var i=[],l=0,a=this.sprayChunks.length;l<a;l++)for(var t=this.sprayChunks[l],n=0,e=t.length;n<e;n++){var o=new r.Rect({width:t[n].width,height:t[n].width,left:t[n].x+1,top:t[n].y+1,originX:"center",originY:"center",fill:this.color});i.push(o)}this.optimizeOverlapping&&(i=this._getOptimizedRects(i));var h=new r.Group(i);this.shadow&&h.set("shadow",new r.Shadow(this.shadow)),this.canvas.fire("before:path:created",{path:h}),this.canvas.add(h),this.canvas.fire("path:created",{path:h}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=c,this.canvas.requestRenderAll()},_getOptimizedRects:function(c){var i={},l,a,t;for(a=0,t=c.length;a<t;a++)l=c[a].left+""+c[a].top,i[l]||(i[l]=c[a]);var n=[];for(l in i)n.push(i[l]);return n},render:function(c){var i=this.canvas.contextTop,l,a;for(i.fillStyle=this.color,this._saveAndTransform(i),l=0,a=c.length;l<a;l++){var t=c[l];typeof t.opacity<"u"&&(i.globalAlpha=t.opacity),i.fillRect(t.x,t.y,t.width,t.width)}i.restore()},_render:function(){var c=this.canvas.contextTop,i,l;for(c.fillStyle=this.color,this._saveAndTransform(c),i=0,l=this.sprayChunks.length;i<l;i++)this.render(this.sprayChunks[i]);c.restore()},addSprayChunk:function(c){this.sprayChunkPoints=[];var i,l,a,t=this.width/2,n;for(n=0;n<this.density;n++){i=r.util.getRandomInt(c.x-t,c.x+t),l=r.util.getRandomInt(c.y-t,c.y+t),this.dotWidthVariance?a=r.util.getRandomInt(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):a=this.dotWidth;var e=new r.Point(i,l);e.width=a,this.randomOpacity&&(e.opacity=r.util.getRandomInt(0,100)/100),this.sprayChunkPoints.push(e)}this.sprayChunks.push(this.sprayChunkPoints)}}),r.PatternBrush=r.util.createClass(r.PencilBrush,{getPatternSrc:function(){var c=20,i=5,l=r.util.createCanvasElement(),a=l.getContext("2d");return l.width=l.height=c+i,a.fillStyle=this.color,a.beginPath(),a.arc(c/2,c/2,c/2,0,Math.PI*2,!1),a.closePath(),a.fill(),l},getPatternSrcFunction:function(){return String(this.getPatternSrc).replace("this.color",'"'+this.color+'"')},getPattern:function(c){return c.createPattern(this.source||this.getPatternSrc(),"repeat")},_setBrushStyles:function(c){this.callSuper("_setBrushStyles",c),c.strokeStyle=this.getPattern(c)},createPath:function(c){var i=this.callSuper("createPath",c),l=i._getLeftTopCoords().scalarAdd(i.strokeWidth/2);return i.stroke=new r.Pattern({source:this.source||this.getPatternSrcFunction(),offsetX:-l.x,offsetY:-l.y}),i}}),(function(){var c=r.util.getPointer,i=r.util.degreesToRadians,l=r.util.isTouchEvent;r.Canvas=r.util.createClass(r.StaticCanvas,{initialize:function(t,n){n||(n={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,n),this._initInteractive(),this._createCacheCanvas()},uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",interactive:!0,selection:!0,selectionKey:"shiftKey",altSelectionKey:null,selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",containerClass:"canvas-container",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,isDrawingMode:!1,preserveObjectStacking:!1,snapAngle:0,snapThreshold:null,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,targets:[],enablePointerEvents:!1,_hoveredTarget:null,_hoveredTargets:[],_initInteractive:function(){this._currentTransform=null,this._groupSelector=null,this._initWrapperElement(),this._createUpperCanvas(),this._initEventListeners(),this._initRetinaScaling(),this.freeDrawingBrush=r.PencilBrush&&new r.PencilBrush(this),this.calcOffset()},_chooseObjectsToRender:function(){var t=this.getActiveObjects(),n,e,o;if(t.length>0&&!this.preserveObjectStacking){e=[],o=[];for(var h=0,s=this._objects.length;h<s;h++)n=this._objects[h],t.indexOf(n)===-1?e.push(n):o.push(n);t.length>1&&(this._activeObject._objects=o),e.push.apply(e,o)}else e=this._objects;return e},renderAll:function(){this.contextTopDirty&&!this._groupSelector&&!this.isDrawingMode&&(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1);var t=this.contextContainer;return this.renderCanvas(t,this._chooseObjectsToRender()),this},renderTopLayer:function(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()},renderTop:function(){var t=this.contextTop;return this.clearContext(t),this.renderTopLayer(t),this.fire("after:render"),this},_normalizePointer:function(t,n){var e=t.calcTransformMatrix(),o=r.util.invertTransform(e),h=this.restorePointerVpt(n);return r.util.transformPoint(h,o)},isTargetTransparent:function(t,n,e){if(t.shouldCache()&&t._cacheCanvas&&t!==this._activeObject){var o=this._normalizePointer(t,{x:n,y:e}),h=Math.max(t.cacheTranslationX+o.x*t.zoomX,0),s=Math.max(t.cacheTranslationY+o.y*t.zoomY,0),g=r.util.isTransparent(t._cacheContext,Math.round(h),Math.round(s),this.targetFindTolerance);return g}var u=this.contextCache,d=t.selectionBackgroundColor,m=this.viewportTransform;t.selectionBackgroundColor="",this.clearContext(u),u.save(),u.transform(m[0],m[1],m[2],m[3],m[4],m[5]),t.render(u),u.restore(),t.selectionBackgroundColor=d;var g=r.util.isTransparent(u,n,e,this.targetFindTolerance);return g},_isSelectionKeyPressed:function(t){var n=!1;return Array.isArray(this.selectionKey)?n=!!this.selectionKey.find(function(e){return t[e]===!0}):n=t[this.selectionKey],n},_shouldClearSelection:function(t,n){var e=this.getActiveObjects(),o=this._activeObject;return!n||n&&o&&e.length>1&&e.indexOf(n)===-1&&o!==n&&!this._isSelectionKeyPressed(t)||n&&!n.evented||n&&!n.selectable&&o&&o!==n},_shouldCenterTransform:function(t,n,e){if(t){var o;return n==="scale"||n==="scaleX"||n==="scaleY"||n==="resizing"?o=this.centeredScaling||t.centeredScaling:n==="rotate"&&(o=this.centeredRotation||t.centeredRotation),o?!e:e}},_getOriginFromCorner:function(t,n){var e={x:t.originX,y:t.originY};return n==="ml"||n==="tl"||n==="bl"?e.x="right":(n==="mr"||n==="tr"||n==="br")&&(e.x="left"),n==="tl"||n==="mt"||n==="tr"?e.y="bottom":(n==="bl"||n==="mb"||n==="br")&&(e.y="top"),e},_getActionFromCorner:function(t,n,e,o){if(!n||!t)return"drag";var h=o.controls[n];return h.getActionName(e,h,o)},_setupCurrentTransform:function(t,n,e){if(n){var o=this.getPointer(t),h=n.__corner,s=n.controls[h],u=e&&h?s.getActionHandler(t,n,s):r.controlsUtils.dragHandler,d=this._getActionFromCorner(e,h,t,n),m=this._getOriginFromCorner(n,h),g=t[this.centeredKey],v={target:n,action:d,actionHandler:u,corner:h,scaleX:n.scaleX,scaleY:n.scaleY,skewX:n.skewX,skewY:n.skewY,offsetX:o.x-n.left,offsetY:o.y-n.top,originX:m.x,originY:m.y,ex:o.x,ey:o.y,lastX:o.x,lastY:o.y,theta:i(n.angle),width:n.width*n.scaleX,shiftKey:t.shiftKey,altKey:g,original:r.util.saveObjectTransform(n)};this._shouldCenterTransform(n,d,g)&&(v.originX="center",v.originY="center"),v.original.originX=m.x,v.original.originY=m.y,this._currentTransform=v,this._beforeTransform(t)}},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_drawSelection:function(t){var n=this._groupSelector,e=new r.Point(n.ex,n.ey),o=r.util.transformPoint(e,this.viewportTransform),h=new r.Point(n.ex+n.left,n.ey+n.top),s=r.util.transformPoint(h,this.viewportTransform),u=Math.min(o.x,s.x),d=Math.min(o.y,s.y),m=Math.max(o.x,s.x),g=Math.max(o.y,s.y),v=this.selectionLineWidth/2;this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(u,d,m-u,g-d)),!(!this.selectionLineWidth||!this.selectionBorderColor)&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,u+=v,d+=v,m-=v,g-=v,r.Object.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(u,d,m-u,g-d))},findTarget:function(t,n){if(!this.skipTargetFind){var e=!0,o=this.getPointer(t,e),h=this._activeObject,s=this.getActiveObjects(),u,d,m=l(t),g=s.length>1&&!n||s.length===1;if(this.targets=[],g&&h._findTargetCorner(o,m)||s.length>1&&!n&&h===this._searchPossibleTargets([h],o))return h;if(s.length===1&&h===this._searchPossibleTargets([h],o))if(this.preserveObjectStacking)u=h,d=this.targets,this.targets=[];else return h;var v=this._searchPossibleTargets(this._objects,o);return t[this.altSelectionKey]&&v&&u&&v!==u&&(v=u,this.targets=d),v}},_checkTarget:function(t,n,e){if(n&&n.visible&&n.evented&&n.containsPoint(t))if((this.perPixelTargetFind||n.perPixelTargetFind)&&!n.isEditing){var o=this.isTargetTransparent(n,e.x,e.y);if(!o)return!0}else return!0},_searchPossibleTargets:function(t,n){for(var e,o=t.length,h;o--;){var s=t[o],u=s.group?this._normalizePointer(s.group,n):n;if(this._checkTarget(u,s,n)){e=t[o],e.subTargetCheck&&e instanceof r.Group&&(h=this._searchPossibleTargets(e._objects,n),h&&this.targets.push(h));break}}return e},restorePointerVpt:function(t){return r.util.transformPoint(t,r.util.invertTransform(this.viewportTransform))},getPointer:function(t,n){if(this._absolutePointer&&!n)return this._absolutePointer;if(this._pointer&&n)return this._pointer;var e=c(t),o=this.upperCanvasEl,h=o.getBoundingClientRect(),s=h.width||0,u=h.height||0,d;(!s||!u)&&("top"in h&&"bottom"in h&&(u=Math.abs(h.top-h.bottom)),"right"in h&&"left"in h&&(s=Math.abs(h.right-h.left))),this.calcOffset(),e.x=e.x-this._offset.left,e.y=e.y-this._offset.top,n||(e=this.restorePointerVpt(e));var m=this.getRetinaScaling();return m!==1&&(e.x/=m,e.y/=m),s===0||u===0?d={width:1,height:1}:d={width:o.width/s,height:o.height/u},{x:e.x*d.width,y:e.y*d.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),n=this.lowerCanvasEl,e=this.upperCanvasEl;e?e.className="":(e=this._createCanvasElement(),this.upperCanvasEl=e),r.util.addClass(e,"upper-canvas "+t),this.wrapperEl.appendChild(e),this._copyCanvasStyle(n,e),this._applyCanvasStyle(e),this.contextTop=e.getContext("2d")},getTopContext:function(){return this.contextTop},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=r.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),r.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),r.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var n=this.width||t.width,e=this.height||t.height;r.util.setStyle(t,{position:"absolute",width:n+"px",height:e+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),t.width=n,t.height=e,r.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,n){n.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var t=this._activeObject;return t?t.type==="activeSelection"&&t._objects?t._objects.slice(0):[t]:[]},_onObjectRemoved:function(t){t===this._activeObject&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared",{target:t}),t.fire("deselected")),t===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",t)},_fireSelectionEvents:function(t,n){var e=!1,o=this.getActiveObjects(),h=[],s=[];t.forEach(function(u){o.indexOf(u)===-1&&(e=!0,u.fire("deselected",{e:n,target:u}),s.push(u))}),o.forEach(function(u){t.indexOf(u)===-1&&(e=!0,u.fire("selected",{e:n,target:u}),h.push(u))}),t.length>0&&o.length>0?e&&this.fire("selection:updated",{e:n,selected:h,deselected:s}):o.length>0?this.fire("selection:created",{e:n,selected:h}):t.length>0&&this.fire("selection:cleared",{e:n,deselected:s})},setActiveObject:function(t,n){var e=this.getActiveObjects();return this._setActiveObject(t,n),this._fireSelectionEvents(e,n),this},_setActiveObject:function(t,n){return this._activeObject===t||!this._discardActiveObject(n,t)||t.onSelect({e:n})?!1:(this._activeObject=t,!0)},_discardActiveObject:function(t,n){var e=this._activeObject;if(e){if(e.onDeselect({e:t,object:n}))return!1;this._activeObject=null}return!0},discardActiveObject:function(t){var n=this.getActiveObjects(),e=this.getActiveObject();return n.length&&this.fire("before:selection:cleared",{target:e,e:t}),this._discardActiveObject(t),this._fireSelectionEvents(n,t),this},dispose:function(){var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach((function(n){r.util.cleanUpJsdomNode(this[n]),this[n]=void 0}).bind(this)),t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,r.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(t){var n=this._activeObject;n&&n._renderControls(t)},_toObject:function(t,n,e){var o=this._realizeGroupTransformOnObject(t),h=this.callSuper("_toObject",t,n,e);return this._unwindGroupTransformOnObject(t,o),h},_realizeGroupTransformOnObject:function(t){if(t.group&&t.group.type==="activeSelection"&&this._activeObject===t.group){var n=["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"],e={};return n.forEach(function(o){e[o]=t[o]}),r.util.addTransformToObject(t,this._activeObject.calcOwnMatrix()),e}else return null},_unwindGroupTransformOnObject:function(t,n){n&&t.set(n)},_setSVGObject:function(t,n,e){var o=this._realizeGroupTransformOnObject(n);this.callSuper("_setSVGObject",t,n,e),this._unwindGroupTransformOnObject(n,o)},setViewportTransform:function(t){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),r.StaticCanvas.prototype.setViewportTransform.call(this,t)}});for(var a in r.StaticCanvas)a!=="prototype"&&(r.Canvas[a]=r.StaticCanvas[a])})(),(function(){var c=r.util.addListener,i=r.util.removeListener,l=3,a=2,t=1,n={passive:!1};function e(o,h){return o.button&&o.button===h-1}r.util.object.extend(r.Canvas.prototype,{mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(c,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(o,h){var s=this.upperCanvasEl,u=this._getEventPrefix();o(r.window,"resize",this._onResize),o(s,u+"down",this._onMouseDown),o(s,u+"move",this._onMouseMove,n),o(s,u+"out",this._onMouseOut),o(s,u+"enter",this._onMouseEnter),o(s,"wheel",this._onMouseWheel),o(s,"contextmenu",this._onContextMenu),o(s,"dblclick",this._onDoubleClick),o(s,"dragover",this._onDragOver),o(s,"dragenter",this._onDragEnter),o(s,"dragleave",this._onDragLeave),o(s,"drop",this._onDrop),this.enablePointerEvents||o(s,"touchstart",this._onTouchStart,n),typeof eventjs<"u"&&h in eventjs&&(eventjs[h](s,"gesture",this._onGesture),eventjs[h](s,"drag",this._onDrag),eventjs[h](s,"orientation",this._onOrientationChange),eventjs[h](s,"shake",this._onShake),eventjs[h](s,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(i,"remove");var o=this._getEventPrefix();i(r.document,o+"up",this._onMouseUp),i(r.document,"touchend",this._onTouchEnd,n),i(r.document,o+"move",this._onMouseMove,n),i(r.document,"touchmove",this._onMouseMove,n)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._onDrop.bind(this),this.eventsBound=!0)},_onGesture:function(o,h){this.__onTransformGesture&&this.__onTransformGesture(o,h)},_onDrag:function(o,h){this.__onDrag&&this.__onDrag(o,h)},_onMouseWheel:function(o){this.__onMouseWheel(o)},_onMouseOut:function(o){var h=this._hoveredTarget;this.fire("mouse:out",{target:h,e:o}),this._hoveredTarget=null,h&&h.fire("mouseout",{e:o});var s=this;this._hoveredTargets.forEach(function(u){s.fire("mouse:out",{target:h,e:o}),u&&h.fire("mouseout",{e:o})}),this._hoveredTargets=[]},_onMouseEnter:function(o){!this._currentTransform&&!this.findTarget(o)&&(this.fire("mouse:over",{target:null,e:o}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(o,h){this.__onOrientationChange&&this.__onOrientationChange(o,h)},_onShake:function(o,h){this.__onShake&&this.__onShake(o,h)},_onLongPress:function(o,h){this.__onLongPress&&this.__onLongPress(o,h)},_onDragOver:function(o){o.preventDefault();var h=this._simpleEventHandler("dragover",o);this._fireEnterLeaveEvents(h,o)},_onDrop:function(o){return this._simpleEventHandler("drop:before",o),this._simpleEventHandler("drop",o)},_onContextMenu:function(o){return this.stopContextMenu&&(o.stopPropagation(),o.preventDefault()),!1},_onDoubleClick:function(o){this._cacheTransformEventData(o),this._handleEvent(o,"dblclick"),this._resetTransformEventData(o)},getPointerId:function(o){var h=o.changedTouches;return h?h[0]&&h[0].identifier:this.enablePointerEvents?o.pointerId:-1},_isMainEvent:function(o){return o.isPrimary===!0?!0:o.isPrimary===!1?!1:o.type==="touchend"&&o.touches.length===0?!0:o.changedTouches?o.changedTouches[0].identifier===this.mainTouchId:!0},_onTouchStart:function(o){o.preventDefault(),this.mainTouchId===null&&(this.mainTouchId=this.getPointerId(o)),this.__onMouseDown(o),this._resetTransformEventData();var h=this.upperCanvasEl,s=this._getEventPrefix();c(r.document,"touchend",this._onTouchEnd,n),c(r.document,"touchmove",this._onMouseMove,n),i(h,s+"down",this._onMouseDown)},_onMouseDown:function(o){this.__onMouseDown(o),this._resetTransformEventData();var h=this.upperCanvasEl,s=this._getEventPrefix();i(h,s+"move",this._onMouseMove,n),c(r.document,s+"up",this._onMouseUp),c(r.document,s+"move",this._onMouseMove,n)},_onTouchEnd:function(o){if(!(o.touches.length>0)){this.__onMouseUp(o),this._resetTransformEventData(),this.mainTouchId=null;var h=this._getEventPrefix();i(r.document,"touchend",this._onTouchEnd,n),i(r.document,"touchmove",this._onMouseMove,n);var s=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(function(){c(s.upperCanvasEl,h+"down",s._onMouseDown),s._willAddMouseDown=0},400)}},_onMouseUp:function(o){this.__onMouseUp(o),this._resetTransformEventData();var h=this.upperCanvasEl,s=this._getEventPrefix();this._isMainEvent(o)&&(i(r.document,s+"up",this._onMouseUp),i(r.document,s+"move",this._onMouseMove,n),c(h,s+"move",this._onMouseMove,n))},_onMouseMove:function(o){!this.allowTouchScrolling&&o.preventDefault&&o.preventDefault(),this.__onMouseMove(o)},_onResize:function(){this.calcOffset()},_shouldRender:function(o){var h=this._activeObject;return!!h!=!!o||h&&o&&h!==o?!0:(h&&h.isEditing,!1)},__onMouseUp:function(o){var h,s=this._currentTransform,u=this._groupSelector,d=!1,m=!u||u.left===0&&u.top===0;if(this._cacheTransformEventData(o),h=this._target,this._handleEvent(o,"up:before"),e(o,l)){this.fireRightClick&&this._handleEvent(o,"up",l,m);return}if(e(o,a)){this.fireMiddleClick&&this._handleEvent(o,"up",a,m),this._resetTransformEventData();return}if(this.isDrawingMode&&this._isCurrentlyDrawing){this._onMouseUpInDrawingMode(o);return}if(this._isMainEvent(o)){if(s&&(this._finalizeCurrentTransform(o),d=s.actionPerformed),!m){var g=h===this._activeObject;this._maybeGroupObjects(o),d||(d=this._shouldRender(h)||!g&&h===this._activeObject)}var v,b;if(h){if(v=h._findTargetCorner(this.getPointer(o,!0),r.util.isTouchEvent(o)),h.selectable&&h!==this._activeObject&&h.activeOn==="up")this.setActiveObject(h,o),d=!0;else{var S=h.controls[v],E=S&&S.getMouseUpHandler(o,h,S);E&&(b=this.getPointer(o),E(o,s,b.x,b.y))}h.isMoving=!1}if(s&&(s.target!==h||s.corner!==v)){var F=s.target&&s.target.controls[s.corner],R=F&&F.getMouseUpHandler(o,h,S);b=b||this.getPointer(o),R&&R(o,s,b.x,b.y)}this._setCursorFromEvent(o,h),this._handleEvent(o,"up",t,m),this._groupSelector=null,this._currentTransform=null,h&&(h.__corner=0),d?this.requestRenderAll():m||this.renderTop()}},_simpleEventHandler:function(o,h){var s=this.findTarget(h),u=this.targets,d={e:h,target:s,subTargets:u};if(this.fire(o,d),s&&s.fire(o,d),!u)return s;for(var m=0;m<u.length;m++)u[m].fire(o,d);return s},_handleEvent:function(o,h,s,u){var d=this._target,m=this.targets||[],g={e:o,target:d,subTargets:m,button:s||t,isClick:u||!1,pointer:this._pointer,absolutePointer:this._absolutePointer,transform:this._currentTransform};h==="up"&&(g.currentTarget=this.findTarget(o),g.currentSubTargets=this.targets),this.fire("mouse:"+h,g),d&&d.fire("mouse"+h,g);for(var v=0;v<m.length;v++)m[v].fire("mouse"+h,g)},_finalizeCurrentTransform:function(o){var h=this._currentTransform,s=h.target,u={e:o,target:s,transform:h,action:h.action};s._scaling&&(s._scaling=!1),s.setCoords(),(h.actionPerformed||this.stateful&&s.hasStateChanged())&&this._fire("modified",u)},_onMouseDownInDrawingMode:function(o){this._isCurrentlyDrawing=!0,this.getActiveObject()&&this.discardActiveObject(o).requestRenderAll();var h=this.getPointer(o);this.freeDrawingBrush.onMouseDown(h,{e:o,pointer:h}),this._handleEvent(o,"down")},_onMouseMoveInDrawingMode:function(o){if(this._isCurrentlyDrawing){var h=this.getPointer(o);this.freeDrawingBrush.onMouseMove(h,{e:o,pointer:h})}this.setCursor(this.freeDrawingCursor),this._handleEvent(o,"move")},_onMouseUpInDrawingMode:function(o){var h=this.getPointer(o);this._isCurrentlyDrawing=this.freeDrawingBrush.onMouseUp({e:o,pointer:h}),this._handleEvent(o,"up")},__onMouseDown:function(o){this._cacheTransformEventData(o),this._handleEvent(o,"down:before");var h=this._target;if(e(o,l)){this.fireRightClick&&this._handleEvent(o,"down",l);return}if(e(o,a)){this.fireMiddleClick&&this._handleEvent(o,"down",a);return}if(this.isDrawingMode){this._onMouseDownInDrawingMode(o);return}if(this._isMainEvent(o)&&!this._currentTransform){var s=this._pointer;this._previousPointer=s;var u=this._shouldRender(h),d=this._shouldGroup(o,h);if(this._shouldClearSelection(o,h)?this.discardActiveObject(o):d&&(this._handleGrouping(o,h),h=this._activeObject),this.selection&&(!h||!h.selectable&&!h.isEditing&&h!==this._activeObject)&&(this._groupSelector={ex:this._absolutePointer.x,ey:this._absolutePointer.y,top:0,left:0}),h){var m=h===this._activeObject;h.selectable&&h.activeOn==="down"&&this.setActiveObject(h,o);var g=h._findTargetCorner(this.getPointer(o,!0),r.util.isTouchEvent(o));if(h.__corner=g,h===this._activeObject&&(g||!d)){this._setupCurrentTransform(o,h,m);var v=h.controls[g],s=this.getPointer(o),b=v&&v.getMouseDownHandler(o,h,v);b&&b(o,this._currentTransform,s.x,s.y)}}this._handleEvent(o,"down"),(u||d)&&this.requestRenderAll()}},_resetTransformEventData:function(){this._target=null,this._pointer=null,this._absolutePointer=null},_cacheTransformEventData:function(o){this._resetTransformEventData(),this._pointer=this.getPointer(o,!0),this._absolutePointer=this.restorePointerVpt(this._pointer),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(o)||null},_beforeTransform:function(o){var h=this._currentTransform;this.stateful&&h.target.saveState(),this.fire("before:transform",{e:o,transform:h})},__onMouseMove:function(o){this._handleEvent(o,"move:before"),this._cacheTransformEventData(o);var h,s;if(this.isDrawingMode){this._onMouseMoveInDrawingMode(o);return}if(this._isMainEvent(o)){var u=this._groupSelector;u?(s=this._absolutePointer,u.left=s.x-u.ex,u.top=s.y-u.ey,this.renderTop()):this._currentTransform?this._transformObject(o):(h=this.findTarget(o)||null,this._setCursorFromEvent(o,h),this._fireOverOutEvents(h,o)),this._handleEvent(o,"move"),this._resetTransformEventData()}},_fireOverOutEvents:function(o,h){var s=this._hoveredTarget,u=this._hoveredTargets,d=this.targets,m=Math.max(u.length,d.length);this.fireSyntheticInOutEvents(o,h,{oldTarget:s,evtOut:"mouseout",canvasEvtOut:"mouse:out",evtIn:"mouseover",canvasEvtIn:"mouse:over"});for(var g=0;g<m;g++)this.fireSyntheticInOutEvents(d[g],h,{oldTarget:u[g],evtOut:"mouseout",evtIn:"mouseover"});this._hoveredTarget=o,this._hoveredTargets=this.targets.concat()},_fireEnterLeaveEvents:function(o,h){var s=this._draggedoverTarget,u=this._hoveredTargets,d=this.targets,m=Math.max(u.length,d.length);this.fireSyntheticInOutEvents(o,h,{oldTarget:s,evtOut:"dragleave",evtIn:"dragenter"});for(var g=0;g<m;g++)this.fireSyntheticInOutEvents(d[g],h,{oldTarget:u[g],evtOut:"dragleave",evtIn:"dragenter"});this._draggedoverTarget=o},fireSyntheticInOutEvents:function(o,h,s){var u,d,m=s.oldTarget,g,v,b=m!==o,S=s.canvasEvtIn,E=s.canvasEvtOut;b&&(u={e:h,target:o,previousTarget:m},d={e:h,target:m,nextTarget:o}),v=o&&b,g=m&&b,g&&(E&&this.fire(E,d),m.fire(s.evtOut,d)),v&&(S&&this.fire(S,u),o.fire(s.evtIn,u))},__onMouseWheel:function(o){this._cacheTransformEventData(o),this._handleEvent(o,"wheel"),this._resetTransformEventData()},_transformObject:function(o){var h=this.getPointer(o),s=this._currentTransform;s.reset=!1,s.shiftKey=o.shiftKey,s.altKey=o[this.centeredKey],this._performTransformAction(o,s,h),s.actionPerformed&&this.requestRenderAll()},_performTransformAction:function(o,h,s){var u=s.x,d=s.y,m=h.action,g=!1,v=h.actionHandler;v&&(g=v(o,h,u,d)),m==="drag"&&g&&(h.target.isMoving=!0,this.setCursor(h.target.moveCursor||this.moveCursor)),h.actionPerformed=h.actionPerformed||g},_fire:r.controlsUtils.fireEvent,_setCursorFromEvent:function(o,h){if(!h)return this.setCursor(this.defaultCursor),!1;var s=h.hoverCursor||this.hoverCursor,u=this._activeObject&&this._activeObject.type==="activeSelection"?this._activeObject:null,d=(!u||!u.contains(h))&&h._findTargetCorner(this.getPointer(o,!0));d?this.setCursor(this.getCornerCursor(d,h,o)):(h.subTargetCheck&&this.targets.concat().reverse().map(function(m){s=m.hoverCursor||s}),this.setCursor(s))},getCornerCursor:function(o,h,s){var u=h.controls[o];return u.cursorStyleHandler(s,u,h)}})})(),(function(){var c=Math.min,i=Math.max;r.util.object.extend(r.Canvas.prototype,{_shouldGroup:function(l,a){var t=this._activeObject;return t&&this._isSelectionKeyPressed(l)&&a&&a.selectable&&this.selection&&(t!==a||t.type==="activeSelection")&&!a.onSelect({e:l})},_handleGrouping:function(l,a){var t=this._activeObject;t.__corner||a===t&&(a=this.findTarget(l,!0),!a||!a.selectable)||(t&&t.type==="activeSelection"?this._updateActiveSelection(a,l):this._createActiveSelection(a,l))},_updateActiveSelection:function(l,a){var t=this._activeObject,n=t._objects.slice(0);t.contains(l)?(t.removeWithUpdate(l),this._hoveredTarget=l,this._hoveredTargets=this.targets.concat(),t.size()===1&&this._setActiveObject(t.item(0),a)):(t.addWithUpdate(l),this._hoveredTarget=t,this._hoveredTargets=this.targets.concat()),this._fireSelectionEvents(n,a)},_createActiveSelection:function(l,a){var t=this.getActiveObjects(),n=this._createGroup(l);this._hoveredTarget=n,this._setActiveObject(n,a),this._fireSelectionEvents(t,a)},_createGroup:function(l){var a=this._objects,t=a.indexOf(this._activeObject)<a.indexOf(l),n=t?[this._activeObject,l]:[l,this._activeObject];return this._activeObject.isEditing&&this._activeObject.exitEditing(),new r.ActiveSelection(n,{canvas:this})},_groupSelectedObjects:function(l){var a=this._collectObjects(l),t;a.length===1?this.setActiveObject(a[0],l):a.length>1&&(t=new r.ActiveSelection(a.reverse(),{canvas:this}),this.setActiveObject(t,l))},_collectObjects:function(l){for(var a=[],t,n=this._groupSelector.ex,e=this._groupSelector.ey,o=n+this._groupSelector.left,h=e+this._groupSelector.top,s=new r.Point(c(n,o),c(e,h)),u=new r.Point(i(n,o),i(e,h)),d=!this.selectionFullyContained,m=n===o&&e===h,g=this._objects.length;g--&&(t=this._objects[g],!(!(!t||!t.selectable||!t.visible)&&(d&&t.intersectsWithRect(s,u,!0)||t.isContainedWithinRect(s,u,!0)||d&&t.containsPoint(s,null,!0)||d&&t.containsPoint(u,null,!0))&&(a.push(t),m))););return a.length>1&&(a=a.filter(function(v){return!v.onSelect({e:l})})),a},_maybeGroupObjects:function(l){this.selection&&this._groupSelector&&this._groupSelectedObjects(l),this.setCursor(this.defaultCursor),this._groupSelector=null}})})(),(function(){r.util.object.extend(r.StaticCanvas.prototype,{toDataURL:function(c){c||(c={});var i=c.format||"png",l=c.quality||1,a=(c.multiplier||1)*(c.enableRetinaScaling?this.getRetinaScaling():1),t=this.toCanvasElement(a,c);return r.util.toDataURL(t,i,l)},toCanvasElement:function(c,i){c=c||1,i=i||{};var l=(i.width||this.width)*c,a=(i.height||this.height)*c,t=this.getZoom(),n=this.width,e=this.height,o=t*c,h=this.viewportTransform,s=(h[4]-(i.left||0))*c,u=(h[5]-(i.top||0))*c,d=this.interactive,m=[o,0,0,o,s,u],g=this.enableRetinaScaling,v=r.util.createCanvasElement(),b=this.contextTop;return v.width=l,v.height=a,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=m,this.width=l,this.height=a,this.calcViewportBoundaries(),this.renderCanvas(v.getContext("2d"),this._objects),this.viewportTransform=h,this.width=n,this.height=e,this.calcViewportBoundaries(),this.interactive=d,this.enableRetinaScaling=g,this.contextTop=b,v}})})(),r.util.object.extend(r.StaticCanvas.prototype,{loadFromJSON:function(c,i,l){if(c){var a=typeof c=="string"?JSON.parse(c):r.util.object.clone(c),t=this,n=a.clipPath,e=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete a.clipPath,this._enlivenObjects(a.objects,function(o){t.clear(),t._setBgOverlay(a,function(){n?t._enlivenObjects([n],function(h){t.clipPath=h[0],t.__setupCanvas.call(t,a,o,e,i)}):t.__setupCanvas.call(t,a,o,e,i)})},l),this}},__setupCanvas:function(c,i,l,a){var t=this;i.forEach(function(n,e){t.insertAt(n,e)}),this.renderOnAddRemove=l,delete c.objects,delete c.backgroundImage,delete c.overlayImage,delete c.background,delete c.overlay,this._setOptions(c),this.renderAll(),a&&a()},_setBgOverlay:function(c,i){var l={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(!c.backgroundImage&&!c.overlayImage&&!c.background&&!c.overlay){i&&i();return}var a=function(){l.backgroundImage&&l.overlayImage&&l.backgroundColor&&l.overlayColor&&i&&i()};this.__setBgOverlay("backgroundImage",c.backgroundImage,l,a),this.__setBgOverlay("overlayImage",c.overlayImage,l,a),this.__setBgOverlay("backgroundColor",c.background,l,a),this.__setBgOverlay("overlayColor",c.overlay,l,a)},__setBgOverlay:function(c,i,l,a){var t=this;if(!i){l[c]=!0,a&&a();return}c==="backgroundImage"||c==="overlayImage"?r.util.enlivenObjects([i],function(n){t[c]=n[0],l[c]=!0,a&&a()}):this["set"+r.util.string.capitalize(c,!0)](i,function(){l[c]=!0,a&&a()})},_enlivenObjects:function(c,i,l){if(!c||c.length===0){i&&i([]);return}r.util.enlivenObjects(c,function(a){i&&i(a)},null,l)},_toDataURL:function(c,i){this.clone(function(l){i(l.toDataURL(c))})},_toDataURLWithMultiplier:function(c,i,l){this.clone(function(a){l(a.toDataURLWithMultiplier(c,i))})},clone:function(c,i){var l=JSON.stringify(this.toJSON(i));this.cloneWithoutData(function(a){a.loadFromJSON(l,function(){c&&c(a)})})},cloneWithoutData:function(c){var i=r.util.createCanvasElement();i.width=this.width,i.height=this.height;var l=new r.Canvas(i);this.backgroundImage?(l.setBackgroundImage(this.backgroundImage.src,function(){l.renderAll(),c&&c(l)}),l.backgroundImageOpacity=this.backgroundImageOpacity,l.backgroundImageStretch=this.backgroundImageStretch):c&&c(l)}}),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.object.extend,a=i.util.object.clone,t=i.util.toFixed,n=i.util.string.capitalize,e=i.util.degreesToRadians,o=!i.isLikelyNode,h=2;i.Object||(i.Object=i.util.createClass(i.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,touchCornerSize:24,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgb(178,204,255)",borderDashArray:null,cornerColor:"rgb(178,204,255)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,perPixelTargetFind:!1,includeDefaultValues:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:o,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",activeOn:"down",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),colorProperties:"fill stroke backgroundColor".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(s){s&&this.setOptions(s)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=i.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(s){var u=i.perfLimitSizeTotal,d=s.width,m=s.height,g=i.maxCacheSideLimit,v=i.minCacheSideLimit;if(d<=g&&m<=g&&d*m<=u)return d<v&&(s.width=v),m<v&&(s.height=v),s;var b=d/m,S=i.util.limitDimsByArea(b,u),E=i.util.capValue,F=E(v,S.x,g),R=E(v,S.y,g);return d>F&&(s.zoomX/=d/F,s.width=F,s.capped=!0),m>R&&(s.zoomY/=m/R,s.height=R,s.capped=!0),s},_getCacheCanvasDimensions:function(){var s=this.getTotalObjectScaling(),u=this._getTransformedDimensions(0,0),d=u.x*s.scaleX/this.scaleX,m=u.y*s.scaleY/this.scaleY;return{width:d+h,height:m+h,zoomX:s.scaleX,zoomY:s.scaleY,x:d,y:m}},_updateCacheCanvas:function(){var s=this.canvas;if(this.noScaleCache&&s&&s._currentTransform){var u=s._currentTransform.target,d=s._currentTransform.action;if(this===u&&d.slice&&d.slice(0,5)==="scale")return!1}var m=this._cacheCanvas,g=this._limitCacheSize(this._getCacheCanvasDimensions()),v=i.minCacheSideLimit,b=g.width,S=g.height,E,F,R=g.zoomX,z=g.zoomY,q=b!==this.cacheWidth||S!==this.cacheHeight,Z=this.zoomX!==R||this.zoomY!==z,K=q||Z,$=0,tt=0,it=!1;if(q){var et=this._cacheCanvas.width,w=this._cacheCanvas.height,k=b>et||S>w,A=(b<et*.9||S<w*.9)&&et>v&&w>v;it=k||A,k&&!g.capped&&(b>v||S>v)&&($=b*.1,tt=S*.1)}return this instanceof i.Text&&this.path&&(K=!0,it=!0,$+=this.getHeightOfLine(0)*this.zoomX,tt+=this.getHeightOfLine(0)*this.zoomY),K?(it?(m.width=Math.ceil(b+$),m.height=Math.ceil(S+tt)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,m.width,m.height)),E=g.x/2,F=g.y/2,this.cacheTranslationX=Math.round(m.width/2-E)+E,this.cacheTranslationY=Math.round(m.height/2-F)+F,this.cacheWidth=b,this.cacheHeight=S,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(R,z),this.zoomX=R,this.zoomY=z,!0):!1},setOptions:function(s){this._setOptions(s),this._initGradient(s.fill,"fill"),this._initGradient(s.stroke,"stroke"),this._initPattern(s.fill,"fill"),this._initPattern(s.stroke,"stroke")},transform:function(s){var u=this.group&&!this.group._transformDone||this.group&&this.canvas&&s===this.canvas.contextTop,d=this.calcTransformMatrix(!u);s.transform(d[0],d[1],d[2],d[3],d[4],d[5])},toObject:function(s){var u=i.Object.NUM_FRACTION_DIGITS,d={type:this.type,version:i.version,originX:this.originX,originY:this.originY,left:t(this.left,u),top:t(this.top,u),width:t(this.width,u),height:t(this.height,u),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:t(this.strokeWidth,u),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeUniform:this.strokeUniform,strokeMiterLimit:t(this.strokeMiterLimit,u),scaleX:t(this.scaleX,u),scaleY:t(this.scaleY,u),angle:t(this.angle,u),flipX:this.flipX,flipY:this.flipY,opacity:t(this.opacity,u),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,skewX:t(this.skewX,u),skewY:t(this.skewY,u)};return this.clipPath&&!this.clipPath.excludeFromExport&&(d.clipPath=this.clipPath.toObject(s),d.clipPath.inverted=this.clipPath.inverted,d.clipPath.absolutePositioned=this.clipPath.absolutePositioned),i.util.populateWithProperties(this,d,s),this.includeDefaultValues||(d=this._removeDefaultValues(d)),d},toDatalessObject:function(s){return this.toObject(s)},_removeDefaultValues:function(s){var u=i.util.getKlass(s.type).prototype,d=u.stateProperties;return d.forEach(function(m){m==="left"||m==="top"||(s[m]===u[m]&&delete s[m],Array.isArray(s[m])&&Array.isArray(u[m])&&s[m].length===0&&u[m].length===0&&delete s[m])}),s},toString:function(){return"#<fabric."+n(this.type)+">"},getObjectScaling:function(){if(!this.group)return{scaleX:this.scaleX,scaleY:this.scaleY};var s=i.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(s.scaleX),scaleY:Math.abs(s.scaleY)}},getTotalObjectScaling:function(){var s=this.getObjectScaling(),u=s.scaleX,d=s.scaleY;if(this.canvas){var m=this.canvas.getZoom(),g=this.canvas.getRetinaScaling();u*=m*g,d*=m*g}return{scaleX:u,scaleY:d}},getObjectOpacity:function(){var s=this.opacity;return this.group&&(s*=this.group.getObjectOpacity()),s},_set:function(s,u){var d=s==="scaleX"||s==="scaleY",m=this[s]!==u,g=!1;return d&&(u=this._constrainScale(u)),s==="scaleX"&&u<0?(this.flipX=!this.flipX,u*=-1):s==="scaleY"&&u<0?(this.flipY=!this.flipY,u*=-1):s==="shadow"&&u&&!(u instanceof i.Shadow)?u=new i.Shadow(u):s==="dirty"&&this.group&&this.group.set("dirty",u),this[s]=u,m&&(g=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(s)>-1?(this.dirty=!0,g&&this.group.set("dirty",!0)):g&&this.stateProperties.indexOf(s)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:i.iMatrix.concat()},isNotVisible:function(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible},render:function(s){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(s.save(),this._setupCompositeOperation(s),this.drawSelectionBackground(s),this.transform(s),this._setOpacity(s),this._setShadow(s,this),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(s)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(s),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),s.restore())},renderCache:function(s){s=s||{},(!this._cacheCanvas||!this._cacheContext)&&this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,s.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this._cacheContext=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0},hasFill:function(){return this.fill&&this.fill!=="transparent"},needsItsOwnCache:function(){return!!(this.paintFirst==="stroke"&&this.hasFill()&&this.hasStroke()&&typeof this.shadow=="object"||this.clipPath)},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)},drawClipPathOnCache:function(s,u){if(s.save(),u.inverted?s.globalCompositeOperation="destination-out":s.globalCompositeOperation="destination-in",u.absolutePositioned){var d=i.util.invertTransform(this.calcTransformMatrix());s.transform(d[0],d[1],d[2],d[3],d[4],d[5])}u.transform(s),s.scale(1/u.zoomX,1/u.zoomY),s.drawImage(u._cacheCanvas,-u.cacheTranslationX,-u.cacheTranslationY),s.restore()},drawObject:function(s,u){var d=this.fill,m=this.stroke;u?(this.fill="black",this.stroke="",this._setClippingProperties(s)):this._renderBackground(s),this._render(s),this._drawClipPath(s,this.clipPath),this.fill=d,this.stroke=m},_drawClipPath:function(s,u){u&&(u.canvas=this.canvas,u.shouldCache(),u._transformDone=!0,u.renderCache({forClipping:!0}),this.drawClipPathOnCache(s,u))},drawCacheOnCanvas:function(s){s.scale(1/this.zoomX,1/this.zoomY),s.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(s){if(this.isNotVisible())return!1;if(this._cacheCanvas&&this._cacheContext&&!s&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&this._cacheContext&&!s){var u=this.cacheWidth/this.zoomX,d=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-u/2,-d/2,u,d)}return!0}return!1},_renderBackground:function(s){if(this.backgroundColor){var u=this._getNonTransformedDimensions();s.fillStyle=this.backgroundColor,s.fillRect(-u.x/2,-u.y/2,u.x,u.y),this._removeShadow(s)}},_setOpacity:function(s){this.group&&!this.group._transformDone?s.globalAlpha=this.getObjectOpacity():s.globalAlpha*=this.opacity},_setStrokeStyles:function(s,u){var d=u.stroke;d&&(s.lineWidth=u.strokeWidth,s.lineCap=u.strokeLineCap,s.lineDashOffset=u.strokeDashOffset,s.lineJoin=u.strokeLineJoin,s.miterLimit=u.strokeMiterLimit,d.toLive?d.gradientUnits==="percentage"||d.gradientTransform||d.patternTransform?this._applyPatternForTransformedGradient(s,d):(s.strokeStyle=d.toLive(s,this),this._applyPatternGradientTransform(s,d)):s.strokeStyle=u.stroke)},_setFillStyles:function(s,u){var d=u.fill;d&&(d.toLive?(s.fillStyle=d.toLive(s,this),this._applyPatternGradientTransform(s,u.fill)):s.fillStyle=d)},_setClippingProperties:function(s){s.globalAlpha=1,s.strokeStyle="transparent",s.fillStyle="#000000"},_setLineDash:function(s,u){!u||u.length===0||(1&u.length&&u.push.apply(u,u),s.setLineDash(u))},_renderControls:function(s,u){var d=this.getViewportTransform(),m=this.calcTransformMatrix(),g,v,b;u=u||{},v=typeof u.hasBorders<"u"?u.hasBorders:this.hasBorders,b=typeof u.hasControls<"u"?u.hasControls:this.hasControls,m=i.util.multiplyTransformMatrices(d,m),g=i.util.qrDecompose(m),s.save(),s.translate(g.translateX,g.translateY),s.lineWidth=1*this.borderScaleFactor,this.group||(s.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(g.angle-=180),s.rotate(e(this.group?g.angle:this.angle)),u.forActiveSelection||this.group?v&&this.drawBordersInGroup(s,g,u):v&&this.drawBorders(s,u),b&&this.drawControls(s,u),s.restore()},_setShadow:function(s){if(this.shadow){var u=this.shadow,d=this.canvas,m,g=d&&d.viewportTransform[0]||1,v=d&&d.viewportTransform[3]||1;u.nonScaling?m={scaleX:1,scaleY:1}:m=this.getObjectScaling(),d&&d._isRetinaScaling()&&(g*=i.devicePixelRatio,v*=i.devicePixelRatio),s.shadowColor=u.color,s.shadowBlur=u.blur*i.browserShadowBlurConstant*(g+v)*(m.scaleX+m.scaleY)/4,s.shadowOffsetX=u.offsetX*g*m.scaleX,s.shadowOffsetY=u.offsetY*v*m.scaleY}},_removeShadow:function(s){this.shadow&&(s.shadowColor="",s.shadowBlur=s.shadowOffsetX=s.shadowOffsetY=0)},_applyPatternGradientTransform:function(s,u){if(!u||!u.toLive)return{offsetX:0,offsetY:0};var d=u.gradientTransform||u.patternTransform,m=-this.width/2+u.offsetX||0,g=-this.height/2+u.offsetY||0;return u.gradientUnits==="percentage"?s.transform(this.width,0,0,this.height,m,g):s.transform(1,0,0,1,m,g),d&&s.transform(d[0],d[1],d[2],d[3],d[4],d[5]),{offsetX:m,offsetY:g}},_renderPaintInOrder:function(s){this.paintFirst==="stroke"?(this._renderStroke(s),this._renderFill(s)):(this._renderFill(s),this._renderStroke(s))},_render:function(){},_renderFill:function(s){this.fill&&(s.save(),this._setFillStyles(s,this),this.fillRule==="evenodd"?s.fill("evenodd"):s.fill(),s.restore())},_renderStroke:function(s){if(!(!this.stroke||this.strokeWidth===0)){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(s),s.save(),this.strokeUniform&&this.group){var u=this.getObjectScaling();s.scale(1/u.scaleX,1/u.scaleY)}else this.strokeUniform&&s.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(s,this.strokeDashArray),this._setStrokeStyles(s,this),s.stroke(),s.restore()}},_applyPatternForTransformedGradient:function(s,u){var d=this._limitCacheSize(this._getCacheCanvasDimensions()),m=i.util.createCanvasElement(),g,v=this.canvas.getRetinaScaling(),b=d.x/this.scaleX/v,S=d.y/this.scaleY/v;m.width=b,m.height=S,g=m.getContext("2d"),g.beginPath(),g.moveTo(0,0),g.lineTo(b,0),g.lineTo(b,S),g.lineTo(0,S),g.closePath(),g.translate(b/2,S/2),g.scale(d.zoomX/this.scaleX/v,d.zoomY/this.scaleY/v),this._applyPatternGradientTransform(g,u),g.fillStyle=u.toLive(s),g.fill(),s.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),s.scale(v*this.scaleX/d.zoomX,v*this.scaleY/d.zoomY),s.strokeStyle=g.createPattern(m,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var s=i.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",s.scaleX),this.set("scaleY",s.scaleY),this.angle=s.angle,this.skewX=s.skewX,this.skewY=0}},_removeTransformMatrix:function(s){var u=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),u=i.util.transformPoint(u,this.transformMatrix)),this.transformMatrix=null,s&&(this.scaleX*=s.scaleX,this.scaleY*=s.scaleY,this.cropX=s.cropX,this.cropY=s.cropY,u.x+=s.offsetLeft,u.y+=s.offsetTop,this.width=s.width,this.height=s.height),this.setPositionByOrigin(u,"center","center")},clone:function(s,u){var d=this.toObject(u);this.constructor.fromObject?this.constructor.fromObject(d,s):i.Object._fromObject("Object",d,s)},cloneAsImage:function(s,u){var d=this.toCanvasElement(u);return s&&s(new i.Image(d)),this},toCanvasElement:function(s){s||(s={});var u=i.util,d=u.saveObjectTransform(this),m=this.group,g=this.shadow,v=Math.abs,b=(s.multiplier||1)*(s.enableRetinaScaling?i.devicePixelRatio:1);delete this.group,s.withoutTransform&&u.resetObjectTransform(this),s.withoutShadow&&(this.shadow=null);var S=i.util.createCanvasElement(),E=this.getBoundingRect(!0,!0),F=this.shadow,R,z={x:0,y:0},q,Z,K;F&&(q=F.blur,F.nonScaling?R={scaleX:1,scaleY:1}:R=this.getObjectScaling(),z.x=2*Math.round(v(F.offsetX)+q)*v(R.scaleX),z.y=2*Math.round(v(F.offsetY)+q)*v(R.scaleY)),Z=E.width+z.x,K=E.height+z.y,S.width=Math.ceil(Z),S.height=Math.ceil(K);var $=new i.StaticCanvas(S,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});s.format==="jpeg"&&($.backgroundColor="#fff"),this.setPositionByOrigin(new i.Point($.width/2,$.height/2),"center","center");var tt=this.canvas;$.add(this);var it=$.toCanvasElement(b||1,s);return this.shadow=g,this.set("canvas",tt),m&&(this.group=m),this.set(d).setCoords(),$._objects=[],$.dispose(),$=null,it},toDataURL:function(s){return s||(s={}),i.util.toDataURL(this.toCanvasElement(s),s.format||"png",s.quality||1)},isType:function(s){return arguments.length>1?Array.from(arguments).includes(this.type):this.type===s},complexity:function(){return 1},toJSON:function(s){return this.toObject(s)},rotate:function(s){var u=(this.originX!=="center"||this.originY!=="center")&&this.centeredRotation;return u&&this._setOriginToCenter(),this.set("angle",s),u&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(s,u){u=u||this.canvas.getPointer(s);var d=new i.Point(u.x,u.y),m=this._getLeftTopCoords();return this.angle&&(d=i.util.rotatePoint(d,m,e(-this.angle))),{x:d.x-m.x,y:d.y-m.y}},_setupCompositeOperation:function(s){this.globalCompositeOperation&&(s.globalCompositeOperation=this.globalCompositeOperation)},dispose:function(){i.runningAnimations&&i.runningAnimations.cancelByTarget(this)}}),i.util.createAccessors&&i.util.createAccessors(i.Object),l(i.Object.prototype,i.Observable),i.Object.NUM_FRACTION_DIGITS=2,i.Object.ENLIVEN_PROPS=["clipPath"],i.Object._fromObject=function(s,u,d,m){var g=i[s];u=a(u,!0),i.util.enlivenPatterns([u.fill,u.stroke],function(v){typeof v[0]<"u"&&(u.fill=v[0]),typeof v[1]<"u"&&(u.stroke=v[1]),i.util.enlivenObjectEnlivables(u,u,function(){var b=m?new g(u[m],u):new g(u);d&&d(b)})})},i.Object.__uid=0)})(f),(function(){var c=r.util.degreesToRadians,i={left:-.5,center:0,right:.5},l={top:-.5,center:0,bottom:.5};r.util.object.extend(r.Object.prototype,{translateToGivenOrigin:function(a,t,n,e,o){var h=a.x,s=a.y,u,d,m;return typeof t=="string"?t=i[t]:t-=.5,typeof e=="string"?e=i[e]:e-=.5,u=e-t,typeof n=="string"?n=l[n]:n-=.5,typeof o=="string"?o=l[o]:o-=.5,d=o-n,(u||d)&&(m=this._getTransformedDimensions(),h=a.x+u*m.x,s=a.y+d*m.y),new r.Point(h,s)},translateToCenterPoint:function(a,t,n){var e=this.translateToGivenOrigin(a,t,n,"center","center");return this.angle?r.util.rotatePoint(e,a,c(this.angle)):e},translateToOriginPoint:function(a,t,n){var e=this.translateToGivenOrigin(a,"center","center",t,n);return this.angle?r.util.rotatePoint(e,a,c(this.angle)):e},getCenterPoint:function(){var a=new r.Point(this.left,this.top);return this.translateToCenterPoint(a,this.originX,this.originY)},getPointByOrigin:function(a,t){var n=this.getCenterPoint();return this.translateToOriginPoint(n,a,t)},toLocalPoint:function(a,t,n){var e=this.getCenterPoint(),o,h;return typeof t<"u"&&typeof n<"u"?o=this.translateToGivenOrigin(e,"center","center",t,n):o=new r.Point(this.left,this.top),h=new r.Point(a.x,a.y),this.angle&&(h=r.util.rotatePoint(h,e,-c(this.angle))),h.subtractEquals(o)},setPositionByOrigin:function(a,t,n){var e=this.translateToCenterPoint(a,t,n),o=this.translateToOriginPoint(e,this.originX,this.originY);this.set("left",o.x),this.set("top",o.y)},adjustPosition:function(a){var t=c(this.angle),n=this.getScaledWidth(),e=r.util.cos(t)*n,o=r.util.sin(t)*n,h,s;typeof this.originX=="string"?h=i[this.originX]:h=this.originX-.5,typeof a=="string"?s=i[a]:s=a-.5,this.left+=e*(s-h),this.top+=o*(s-h),this.setCoords(),this.originX=a},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var a=this.getCenterPoint();this.originX="center",this.originY="center",this.left=a.x,this.top=a.y},_resetOrigin:function(){var a=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=a.x,this.top=a.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}})})(),(function(){function c(n){return[new r.Point(n.tl.x,n.tl.y),new r.Point(n.tr.x,n.tr.y),new r.Point(n.br.x,n.br.y),new r.Point(n.bl.x,n.bl.y)]}var i=r.util,l=i.degreesToRadians,a=i.multiplyTransformMatrices,t=i.transformPoint;i.object.extend(r.Object.prototype,{oCoords:null,aCoords:null,lineCoords:null,ownMatrixCache:null,matrixCache:null,controls:{},_getCoords:function(n,e){return e?n?this.calcACoords():this.calcLineCoords():((!this.aCoords||!this.lineCoords)&&this.setCoords(!0),n?this.aCoords:this.lineCoords)},getCoords:function(n,e){return c(this._getCoords(n,e))},intersectsWithRect:function(n,e,o,h){var s=this.getCoords(o,h),u=r.Intersection.intersectPolygonRectangle(s,n,e);return u.status==="Intersection"},intersectsWithObject:function(n,e,o){var h=r.Intersection.intersectPolygonPolygon(this.getCoords(e,o),n.getCoords(e,o));return h.status==="Intersection"||n.isContainedWithinObject(this,e,o)||this.isContainedWithinObject(n,e,o)},isContainedWithinObject:function(n,e,o){for(var h=this.getCoords(e,o),s=e?n.aCoords:n.lineCoords,u=0,d=n._getImageLines(s);u<4;u++)if(!n.containsPoint(h[u],d))return!1;return!0},isContainedWithinRect:function(n,e,o,h){var s=this.getBoundingRect(o,h);return s.left>=n.x&&s.left+s.width<=e.x&&s.top>=n.y&&s.top+s.height<=e.y},containsPoint:function(n,u,o,h){var s=this._getCoords(o,h),u=u||this._getImageLines(s),d=this._findCrossPoints(n,u);return d!==0&&d%2===1},isOnScreen:function(n){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,o=this.canvas.vptCoords.br,h=this.getCoords(!0,n);return h.some(function(s){return s.x<=o.x&&s.x>=e.x&&s.y<=o.y&&s.y>=e.y})||this.intersectsWithRect(e,o,!0,n)?!0:this._containsCenterOfCanvas(e,o,n)},_containsCenterOfCanvas:function(n,e,o){var h={x:(n.x+e.x)/2,y:(n.y+e.y)/2};return!!this.containsPoint(h,null,!0,o)},isPartiallyOnScreen:function(n){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,o=this.canvas.vptCoords.br;if(this.intersectsWithRect(e,o,!0,n))return!0;var h=this.getCoords(!0,n).every(function(s){return(s.x>=o.x||s.x<=e.x)&&(s.y>=o.y||s.y<=e.y)});return h&&this._containsCenterOfCanvas(e,o,n)},_getImageLines:function(n){var e={topline:{o:n.tl,d:n.tr},rightline:{o:n.tr,d:n.br},bottomline:{o:n.br,d:n.bl},leftline:{o:n.bl,d:n.tl}};return e},_findCrossPoints:function(n,e){var o,h,s,u,d,m=0,g;for(var v in e)if(g=e[v],!(g.o.y<n.y&&g.d.y<n.y)&&!(g.o.y>=n.y&&g.d.y>=n.y)&&(g.o.x===g.d.x&&g.o.x>=n.x?d=g.o.x:(o=0,h=(g.d.y-g.o.y)/(g.d.x-g.o.x),s=n.y-o*n.x,u=g.o.y-h*g.o.x,d=-(s-u)/(o-h)),d>=n.x&&(m+=1),m===2))break;return m},getBoundingRect:function(n,e){var o=this.getCoords(n,e);return i.makeBoundingBoxFromPoints(o)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(n){return Math.abs(n)<this.minScaleLimit?n<0?-this.minScaleLimit:this.minScaleLimit:n===0?1e-4:n},scale:function(n){return this._set("scaleX",n),this._set("scaleY",n),this.setCoords()},scaleToWidth:function(n,e){var o=this.getBoundingRect(e).width/this.getScaledWidth();return this.scale(n/this.width/o)},scaleToHeight:function(n,e){var o=this.getBoundingRect(e).height/this.getScaledHeight();return this.scale(n/this.height/o)},calcLineCoords:function(){var n=this.getViewportTransform(),e=this.padding,o=l(this.angle),h=i.cos(o),s=i.sin(o),u=h*e,d=s*e,m=u+d,g=u-d,v=this.calcACoords(),b={tl:t(v.tl,n),tr:t(v.tr,n),bl:t(v.bl,n),br:t(v.br,n)};return e&&(b.tl.x-=g,b.tl.y-=m,b.tr.x+=m,b.tr.y-=g,b.bl.x-=m,b.bl.y+=g,b.br.x+=g,b.br.y+=m),b},calcOCoords:function(){var n=this._calcRotateMatrix(),e=this._calcTranslateMatrix(),o=this.getViewportTransform(),h=a(o,e),s=a(h,n),s=a(s,[1/o[0],0,0,1/o[3],0,0]),u=this._calculateCurrentDimensions(),d={};return this.forEachControl(function(m,g,v){d[g]=m.positionHandler(u,s,v)}),d},calcACoords:function(){var n=this._calcRotateMatrix(),e=this._calcTranslateMatrix(),o=a(e,n),h=this._getTransformedDimensions(),s=h.x/2,u=h.y/2;return{tl:t({x:-s,y:-u},o),tr:t({x:s,y:-u},o),bl:t({x:-s,y:u},o),br:t({x:s,y:u},o)}},setCoords:function(n){return this.aCoords=this.calcACoords(),this.lineCoords=this.group?this.aCoords:this.calcLineCoords(),n?this:(this.oCoords=this.calcOCoords(),this._setCornerCoords&&this._setCornerCoords(),this)},_calcRotateMatrix:function(){return i.calcRotateMatrix(this)},_calcTranslateMatrix:function(){var n=this.getCenterPoint();return[1,0,0,1,n.x,n.y]},transformMatrixKey:function(n){var e="_",o="";return!n&&this.group&&(o=this.group.transformMatrixKey(n)+e),o+this.top+e+this.left+e+this.scaleX+e+this.scaleY+e+this.skewX+e+this.skewY+e+this.angle+e+this.originX+e+this.originY+e+this.width+e+this.height+e+this.strokeWidth+this.flipX+this.flipY},calcTransformMatrix:function(n){var e=this.calcOwnMatrix();if(n||!this.group)return e;var o=this.transformMatrixKey(n),h=this.matrixCache||(this.matrixCache={});return h.key===o?h.value:(this.group&&(e=a(this.group.calcTransformMatrix(!1),e)),h.key=o,h.value=e,e)},calcOwnMatrix:function(){var n=this.transformMatrixKey(!0),e=this.ownMatrixCache||(this.ownMatrixCache={});if(e.key===n)return e.value;var o=this._calcTranslateMatrix(),h={angle:this.angle,translateX:o[4],translateY:o[5],scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY};return e.key=n,e.value=i.composeMatrix(h),e.value},_getNonTransformedDimensions:function(){var n=this.strokeWidth,e=this.width+n,o=this.height+n;return{x:e,y:o}},_getTransformedDimensions:function(n,e){typeof n>"u"&&(n=this.skewX),typeof e>"u"&&(e=this.skewY);var o,h,s,u=n===0&&e===0;if(this.strokeUniform?(h=this.width,s=this.height):(o=this._getNonTransformedDimensions(),h=o.x,s=o.y),u)return this._finalizeDimensions(h*this.scaleX,s*this.scaleY);var d=i.sizeAfterTransform(h,s,{scaleX:this.scaleX,scaleY:this.scaleY,skewX:n,skewY:e});return this._finalizeDimensions(d.x,d.y)},_finalizeDimensions:function(n,e){return this.strokeUniform?{x:n+this.strokeWidth,y:e+this.strokeWidth}:{x:n,y:e}},_calculateCurrentDimensions:function(){var n=this.getViewportTransform(),e=this._getTransformedDimensions(),o=t(e,n,!0);return o.scalarAdd(2*this.padding)}})})(),r.util.object.extend(r.Object.prototype,{sendToBack:function(){return this.group?r.StaticCanvas.prototype.sendToBack.call(this.group,this):this.canvas&&this.canvas.sendToBack(this),this},bringToFront:function(){return this.group?r.StaticCanvas.prototype.bringToFront.call(this.group,this):this.canvas&&this.canvas.bringToFront(this),this},sendBackwards:function(c){return this.group?r.StaticCanvas.prototype.sendBackwards.call(this.group,this,c):this.canvas&&this.canvas.sendBackwards(this,c),this},bringForward:function(c){return this.group?r.StaticCanvas.prototype.bringForward.call(this.group,this,c):this.canvas&&this.canvas.bringForward(this,c),this},moveTo:function(c){return this.group&&this.group.type!=="activeSelection"?r.StaticCanvas.prototype.moveTo.call(this.group,this,c):this.canvas&&this.canvas.moveTo(this,c),this}}),(function(){function c(l,a){if(a){if(a.toLive)return l+": url(#SVGID_"+a.id+"); ";var t=new r.Color(a),n=l+": "+t.toRgb()+"; ",e=t.getAlpha();return e!==1&&(n+=l+"-opacity: "+e.toString()+"; "),n}else return l+": none; "}var i=r.util.toFixed;r.util.object.extend(r.Object.prototype,{getSvgStyles:function(l){var a=this.fillRule?this.fillRule:"nonzero",t=this.strokeWidth?this.strokeWidth:"0",n=this.strokeDashArray?this.strokeDashArray.join(" "):"none",e=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",h=this.strokeLineJoin?this.strokeLineJoin:"miter",s=this.strokeMiterLimit?this.strokeMiterLimit:"4",u=typeof this.opacity<"u"?this.opacity:"1",d=this.visible?"":" visibility: hidden;",m=l?"":this.getSvgFilter(),g=c("fill",this.fill),v=c("stroke",this.stroke);return[v,"stroke-width: ",t,"; ","stroke-dasharray: ",n,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",e,"; ","stroke-linejoin: ",h,"; ","stroke-miterlimit: ",s,"; ",g,"fill-rule: ",a,"; ","opacity: ",u,";",m,d].join("")},getSvgSpanStyles:function(l,a){var t="; ",e=l.fontFamily?"font-family: "+(l.fontFamily.indexOf("'")===-1&&l.fontFamily.indexOf('"')===-1?"'"+l.fontFamily+"'":l.fontFamily)+t:"",n=l.strokeWidth?"stroke-width: "+l.strokeWidth+t:"",e=e,o=l.fontSize?"font-size: "+l.fontSize+"px"+t:"",h=l.fontStyle?"font-style: "+l.fontStyle+t:"",s=l.fontWeight?"font-weight: "+l.fontWeight+t:"",u=l.fill?c("fill",l.fill):"",d=l.stroke?c("stroke",l.stroke):"",m=this.getSvgTextDecoration(l),g=l.deltaY?"baseline-shift: "+-l.deltaY+"; ":"";return m&&(m="text-decoration: "+m+t),[d,n,e,o,h,s,m,u,g,a?"white-space: pre; ":""].join("")},getSvgTextDecoration:function(l){return["overline","underline","line-through"].filter(function(a){return l[a.replace("-","")]}).join(" ")},getSvgFilter:function(){return this.shadow?"filter: url(#SVGID_"+this.shadow.id+");":""},getSvgCommons:function(){return[this.id?'id="'+this.id+'" ':"",this.clipPath?'clip-path="url(#'+this.clipPath.clipPathId+')" ':""].join("")},getSvgTransform:function(l,a){var t=l?this.calcTransformMatrix():this.calcOwnMatrix(),n='transform="'+r.util.matrixToSVG(t);return n+(a||"")+'" '},_setSVGBg:function(l){if(this.backgroundColor){var a=r.Object.NUM_FRACTION_DIGITS;l.push(" <rect ",this._getFillAttributes(this.backgroundColor),' x="',i(-this.width/2,a),'" y="',i(-this.height/2,a),'" width="',i(this.width,a),'" height="',i(this.height,a),`"></rect>
44
- `)}},toSVG:function(l){return this._createBaseSVGMarkup(this._toSVG(l),{reviver:l})},toClipPathSVG:function(l){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(l),{reviver:l})},_createBaseClipPathSVGMarkup:function(l,a){a=a||{};var t=a.reviver,n=a.additionalTransform||"",e=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(""),o=l.indexOf("COMMON_PARTS");return l[o]=e,t?t(l.join("")):l.join("")},_createBaseSVGMarkup:function(l,a){a=a||{};var t=a.noStyle,n=a.reviver,e=t?"":'style="'+this.getSvgStyles()+'" ',o=a.withShadow?'style="'+this.getSvgFilter()+'" ':"",h=this.clipPath,s=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",u=h&&h.absolutePositioned,d=this.stroke,m=this.fill,g=this.shadow,v,b=[],S,E=l.indexOf("COMMON_PARTS"),F=a.additionalTransform;return h&&(h.clipPathId="CLIPPATH_"+r.Object.__uid++,S='<clipPath id="'+h.clipPathId+`" >
43
+ `)},sendToBack:function(s){if(!s)return this;var u=this._activeObject,d,m,p;if(s===u&&s.type==="activeSelection")for(p=u._objects,d=p.length;d--;)m=p[d],l(this._objects,m),this._objects.unshift(m);else l(this._objects,s),this._objects.unshift(s);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(s){if(!s)return this;var u=this._activeObject,d,m,p;if(s===u&&s.type==="activeSelection")for(p=u._objects,d=0;d<p.length;d++)m=p[d],l(this._objects,m),this._objects.push(m);else l(this._objects,s),this._objects.push(s);return this.renderOnAddRemove&&this.requestRenderAll(),this},sendBackwards:function(s,u){if(!s)return this;var d=this._activeObject,m,p,v,b,S,E=0;if(s===d&&s.type==="activeSelection")for(S=d._objects,m=0;m<S.length;m++)p=S[m],v=this._objects.indexOf(p),v>0+E&&(b=v-1,l(this._objects,p),this._objects.splice(b,0,p)),E++;else v=this._objects.indexOf(s),v!==0&&(b=this._findNewLowerIndex(s,v,u),l(this._objects,s),this._objects.splice(b,0,s));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(s,u,d){var m,p;if(d)for(m=u,p=u-1;p>=0;--p){var v=s.intersectsWithObject(this._objects[p])||s.isContainedWithinObject(this._objects[p])||this._objects[p].isContainedWithinObject(s);if(v){m=p;break}}else m=u-1;return m},bringForward:function(s,u){if(!s)return this;var d=this._activeObject,m,p,v,b,S,E=0;if(s===d&&s.type==="activeSelection")for(S=d._objects,m=S.length;m--;)p=S[m],v=this._objects.indexOf(p),v<this._objects.length-1-E&&(b=v+1,l(this._objects,p),this._objects.splice(b,0,p)),E++;else v=this._objects.indexOf(s),v!==this._objects.length-1&&(b=this._findNewUpperIndex(s,v,u),l(this._objects,s),this._objects.splice(b,0,s));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewUpperIndex:function(s,u,d){var m,p,v;if(d)for(m=u,p=u+1,v=this._objects.length;p<v;++p){var b=s.intersectsWithObject(this._objects[p])||s.isContainedWithinObject(this._objects[p])||this._objects[p].isContainedWithinObject(s);if(b){m=p;break}}else m=u+1;return m},moveTo:function(s,u){return l(this._objects,s),this._objects.splice(u,0,s),this.renderOnAddRemove&&this.requestRenderAll()},dispose:function(){return this.isRendering&&(r.util.cancelAnimFrame(this.isRendering),this.isRendering=0),this.forEachObject(function(s){s.dispose&&s.dispose()}),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,this.lowerCanvasEl.classList.remove("lower-canvas"),r.util.setStyle(this.lowerCanvasEl,this._originalCanvasStyle),delete this._originalCanvasStyle,this.lowerCanvasEl.setAttribute("width",this.width),this.lowerCanvasEl.setAttribute("height",this.height),r.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},toString:function(){return"#<fabric.Canvas ("+this.complexity()+"): { objects: "+this._objects.length+" }>"}}),c(r.StaticCanvas.prototype,r.Observable),c(r.StaticCanvas.prototype,r.Collection),c(r.StaticCanvas.prototype,r.DataURLExporter),c(r.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(s){var u=o();if(!u||!u.getContext)return null;var d=u.getContext("2d");if(!d)return null;switch(s){case"setLineDash":return typeof d.setLineDash<"u";default:return null}}}),r.StaticCanvas.prototype.toJSON=r.StaticCanvas.prototype.toObject,r.isLikelyNode&&(r.StaticCanvas.prototype.createPNGStream=function(){var s=e(this.lowerCanvasEl);return s&&s.createPNGStream()},r.StaticCanvas.prototype.createJPEGStream=function(s){var u=e(this.lowerCanvasEl);return u&&u.createJPEGStream(s)})})(),r.BaseBrush=r.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,limitedToCanvasSize:!1,_setBrushStyles:function(c){c.strokeStyle=this.color,c.lineWidth=this.width,c.lineCap=this.strokeLineCap,c.miterLimit=this.strokeMiterLimit,c.lineJoin=this.strokeLineJoin,c.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(c){var i=this.canvas.viewportTransform;c.save(),c.transform(i[0],i[1],i[2],i[3],i[4],i[5])},_setShadow:function(){if(this.shadow){var c=this.canvas,i=this.shadow,l=c.contextTop,a=c.getZoom();c&&c._isRetinaScaling()&&(a*=r.devicePixelRatio),l.shadowColor=i.color,l.shadowBlur=i.blur*a,l.shadowOffsetX=i.offsetX*a,l.shadowOffsetY=i.offsetY*a}},needsFullRender:function(){var c=new r.Color(this.color);return c.getAlpha()<1||!!this.shadow},_resetShadow:function(){var c=this.canvas.contextTop;c.shadowColor="",c.shadowBlur=c.shadowOffsetX=c.shadowOffsetY=0},_isOutSideCanvas:function(c){return c.x<0||c.x>this.canvas.getWidth()||c.y<0||c.y>this.canvas.getHeight()}}),(function(){r.PencilBrush=r.util.createClass(r.BaseBrush,{decimate:.4,drawStraightLine:!1,straightLineKey:"shiftKey",initialize:function(c){this.canvas=c,this._points=[]},needsFullRender:function(){return this.callSuper("needsFullRender")||this._hasStraightLine},_drawSegment:function(c,i,l){var a=i.midPointFrom(l);return c.quadraticCurveTo(i.x,i.y,a.x,a.y),a},onMouseDown:function(c,i){this.canvas._isMainEvent(i.e)&&(this.drawStraightLine=i.e[this.straightLineKey],this._prepareForDrawing(c),this._captureDrawingPath(c),this._render())},onMouseMove:function(c,i){if(this.canvas._isMainEvent(i.e)&&(this.drawStraightLine=i.e[this.straightLineKey],!(this.limitedToCanvasSize===!0&&this._isOutSideCanvas(c))&&this._captureDrawingPath(c)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var l=this._points,a=l.length,t=this.canvas.contextTop;this._saveAndTransform(t),this.oldEnd&&(t.beginPath(),t.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(t,l[a-2],l[a-1],!0),t.stroke(),t.restore()}},onMouseUp:function(c){return this.canvas._isMainEvent(c.e)?(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1):!0},_prepareForDrawing:function(c){var i=new r.Point(c.x,c.y);this._reset(),this._addPoint(i),this.canvas.contextTop.moveTo(i.x,i.y)},_addPoint:function(c){return this._points.length>1&&c.eq(this._points[this._points.length-1])?!1:(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(c),!0)},_reset:function(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1},_captureDrawingPath:function(c){var i=new r.Point(c.x,c.y);return this._addPoint(i)},_render:function(c){var i,l,a=this._points[0],t=this._points[1];if(c=c||this.canvas.contextTop,this._saveAndTransform(c),c.beginPath(),this._points.length===2&&a.x===t.x&&a.y===t.y){var n=this.width/1e3;a=new r.Point(a.x,a.y),t=new r.Point(t.x,t.y),a.x-=n,t.x+=n}for(c.moveTo(a.x,a.y),i=1,l=this._points.length;i<l;i++)this._drawSegment(c,a,t),a=this._points[i],t=this._points[i+1];c.lineTo(a.x,a.y),c.stroke(),c.restore()},convertPointsToSVGPath:function(c){var i=this.width/1e3;return r.util.getSmoothPathFromPoints(c,i)},_isEmptySVGPath:function(c){var i=r.util.joinPath(c);return i==="M 0 0 Q 0 0 0 0 L 0 0"},createPath:function(c){var i=new r.Path(c,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeMiterLimit:this.strokeMiterLimit,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray});return this.shadow&&(this.shadow.affectStroke=!0,i.shadow=new r.Shadow(this.shadow)),i},decimatePoints:function(c,i){if(c.length<=2)return c;var l=this.canvas.getZoom(),a=Math.pow(i/l,2),t,n=c.length-1,e=c[0],o=[e],h;for(t=1;t<n-1;t++)h=Math.pow(e.x-c[t].x,2)+Math.pow(e.y-c[t].y,2),h>=a&&(e=c[t],o.push(e));return o.push(c[n]),o},_finalizeAndAddPath:function(){var c=this.canvas.contextTop;c.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var i=this.convertPointsToSVGPath(this._points);if(this._isEmptySVGPath(i)){this.canvas.requestRenderAll();return}var l=this.createPath(i);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:l}),this.canvas.add(l),this.canvas.requestRenderAll(),l.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:l})}})})(),r.CircleBrush=r.util.createClass(r.BaseBrush,{width:10,initialize:function(c){this.canvas=c,this.points=[]},drawDot:function(c){var i=this.addPoint(c),l=this.canvas.contextTop;this._saveAndTransform(l),this.dot(l,i),l.restore()},dot:function(c,i){c.fillStyle=i.fill,c.beginPath(),c.arc(i.x,i.y,i.radius,0,Math.PI*2,!1),c.closePath(),c.fill()},onMouseDown:function(c){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(c)},_render:function(){var c=this.canvas.contextTop,i,l,a=this.points;for(this._saveAndTransform(c),i=0,l=a.length;i<l;i++)this.dot(c,a[i]);c.restore()},onMouseMove:function(c){this.limitedToCanvasSize===!0&&this._isOutSideCanvas(c)||(this.needsFullRender()?(this.canvas.clearContext(this.canvas.contextTop),this.addPoint(c),this._render()):this.drawDot(c))},onMouseUp:function(){var c=this.canvas.renderOnAddRemove,i,l;this.canvas.renderOnAddRemove=!1;var a=[];for(i=0,l=this.points.length;i<l;i++){var t=this.points[i],n=new r.Circle({radius:t.radius,left:t.x,top:t.y,originX:"center",originY:"center",fill:t.fill});this.shadow&&(n.shadow=new r.Shadow(this.shadow)),a.push(n)}var e=new r.Group(a);e.canvas=this.canvas,this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.fire("path:created",{path:e}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=c,this.canvas.requestRenderAll()},addPoint:function(c){var i=new r.Point(c.x,c.y),l=r.util.getRandomInt(Math.max(0,this.width-20),this.width+20)/2,a=new r.Color(this.color).setAlpha(r.util.getRandomInt(0,100)/100).toRgba();return i.radius=l,i.fill=a,this.points.push(i),i}}),r.SprayBrush=r.util.createClass(r.BaseBrush,{width:10,density:20,dotWidth:1,dotWidthVariance:1,randomOpacity:!1,optimizeOverlapping:!0,initialize:function(c){this.canvas=c,this.sprayChunks=[]},onMouseDown:function(c){this.sprayChunks.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(c),this.render(this.sprayChunkPoints)},onMouseMove:function(c){this.limitedToCanvasSize===!0&&this._isOutSideCanvas(c)||(this.addSprayChunk(c),this.render(this.sprayChunkPoints))},onMouseUp:function(){var c=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;for(var i=[],l=0,a=this.sprayChunks.length;l<a;l++)for(var t=this.sprayChunks[l],n=0,e=t.length;n<e;n++){var o=new r.Rect({width:t[n].width,height:t[n].width,left:t[n].x+1,top:t[n].y+1,originX:"center",originY:"center",fill:this.color});i.push(o)}this.optimizeOverlapping&&(i=this._getOptimizedRects(i));var h=new r.Group(i);this.shadow&&h.set("shadow",new r.Shadow(this.shadow)),this.canvas.fire("before:path:created",{path:h}),this.canvas.add(h),this.canvas.fire("path:created",{path:h}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=c,this.canvas.requestRenderAll()},_getOptimizedRects:function(c){var i={},l,a,t;for(a=0,t=c.length;a<t;a++)l=c[a].left+""+c[a].top,i[l]||(i[l]=c[a]);var n=[];for(l in i)n.push(i[l]);return n},render:function(c){var i=this.canvas.contextTop,l,a;for(i.fillStyle=this.color,this._saveAndTransform(i),l=0,a=c.length;l<a;l++){var t=c[l];typeof t.opacity<"u"&&(i.globalAlpha=t.opacity),i.fillRect(t.x,t.y,t.width,t.width)}i.restore()},_render:function(){var c=this.canvas.contextTop,i,l;for(c.fillStyle=this.color,this._saveAndTransform(c),i=0,l=this.sprayChunks.length;i<l;i++)this.render(this.sprayChunks[i]);c.restore()},addSprayChunk:function(c){this.sprayChunkPoints=[];var i,l,a,t=this.width/2,n;for(n=0;n<this.density;n++){i=r.util.getRandomInt(c.x-t,c.x+t),l=r.util.getRandomInt(c.y-t,c.y+t),this.dotWidthVariance?a=r.util.getRandomInt(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):a=this.dotWidth;var e=new r.Point(i,l);e.width=a,this.randomOpacity&&(e.opacity=r.util.getRandomInt(0,100)/100),this.sprayChunkPoints.push(e)}this.sprayChunks.push(this.sprayChunkPoints)}}),r.PatternBrush=r.util.createClass(r.PencilBrush,{getPatternSrc:function(){var c=20,i=5,l=r.util.createCanvasElement(),a=l.getContext("2d");return l.width=l.height=c+i,a.fillStyle=this.color,a.beginPath(),a.arc(c/2,c/2,c/2,0,Math.PI*2,!1),a.closePath(),a.fill(),l},getPatternSrcFunction:function(){return String(this.getPatternSrc).replace("this.color",'"'+this.color+'"')},getPattern:function(c){return c.createPattern(this.source||this.getPatternSrc(),"repeat")},_setBrushStyles:function(c){this.callSuper("_setBrushStyles",c),c.strokeStyle=this.getPattern(c)},createPath:function(c){var i=this.callSuper("createPath",c),l=i._getLeftTopCoords().scalarAdd(i.strokeWidth/2);return i.stroke=new r.Pattern({source:this.source||this.getPatternSrcFunction(),offsetX:-l.x,offsetY:-l.y}),i}}),(function(){var c=r.util.getPointer,i=r.util.degreesToRadians,l=r.util.isTouchEvent;r.Canvas=r.util.createClass(r.StaticCanvas,{initialize:function(t,n){n||(n={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,n),this._initInteractive(),this._createCacheCanvas()},uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",interactive:!0,selection:!0,selectionKey:"shiftKey",altSelectionKey:null,selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",containerClass:"canvas-container",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,isDrawingMode:!1,preserveObjectStacking:!1,snapAngle:0,snapThreshold:null,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,targets:[],enablePointerEvents:!1,_hoveredTarget:null,_hoveredTargets:[],_initInteractive:function(){this._currentTransform=null,this._groupSelector=null,this._initWrapperElement(),this._createUpperCanvas(),this._initEventListeners(),this._initRetinaScaling(),this.freeDrawingBrush=r.PencilBrush&&new r.PencilBrush(this),this.calcOffset()},_chooseObjectsToRender:function(){var t=this.getActiveObjects(),n,e,o;if(t.length>0&&!this.preserveObjectStacking){e=[],o=[];for(var h=0,s=this._objects.length;h<s;h++)n=this._objects[h],t.indexOf(n)===-1?e.push(n):o.push(n);t.length>1&&(this._activeObject._objects=o),e.push.apply(e,o)}else e=this._objects;return e},renderAll:function(){this.contextTopDirty&&!this._groupSelector&&!this.isDrawingMode&&(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1);var t=this.contextContainer;return this.renderCanvas(t,this._chooseObjectsToRender()),this},renderTopLayer:function(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()},renderTop:function(){var t=this.contextTop;return this.clearContext(t),this.renderTopLayer(t),this.fire("after:render"),this},_normalizePointer:function(t,n){var e=t.calcTransformMatrix(),o=r.util.invertTransform(e),h=this.restorePointerVpt(n);return r.util.transformPoint(h,o)},isTargetTransparent:function(t,n,e){if(t.shouldCache()&&t._cacheCanvas&&t!==this._activeObject){var o=this._normalizePointer(t,{x:n,y:e}),h=Math.max(t.cacheTranslationX+o.x*t.zoomX,0),s=Math.max(t.cacheTranslationY+o.y*t.zoomY,0),p=r.util.isTransparent(t._cacheContext,Math.round(h),Math.round(s),this.targetFindTolerance);return p}var u=this.contextCache,d=t.selectionBackgroundColor,m=this.viewportTransform;t.selectionBackgroundColor="",this.clearContext(u),u.save(),u.transform(m[0],m[1],m[2],m[3],m[4],m[5]),t.render(u),u.restore(),t.selectionBackgroundColor=d;var p=r.util.isTransparent(u,n,e,this.targetFindTolerance);return p},_isSelectionKeyPressed:function(t){var n=!1;return Array.isArray(this.selectionKey)?n=!!this.selectionKey.find(function(e){return t[e]===!0}):n=t[this.selectionKey],n},_shouldClearSelection:function(t,n){var e=this.getActiveObjects(),o=this._activeObject;return!n||n&&o&&e.length>1&&e.indexOf(n)===-1&&o!==n&&!this._isSelectionKeyPressed(t)||n&&!n.evented||n&&!n.selectable&&o&&o!==n},_shouldCenterTransform:function(t,n,e){if(t){var o;return n==="scale"||n==="scaleX"||n==="scaleY"||n==="resizing"?o=this.centeredScaling||t.centeredScaling:n==="rotate"&&(o=this.centeredRotation||t.centeredRotation),o?!e:e}},_getOriginFromCorner:function(t,n){var e={x:t.originX,y:t.originY};return n==="ml"||n==="tl"||n==="bl"?e.x="right":(n==="mr"||n==="tr"||n==="br")&&(e.x="left"),n==="tl"||n==="mt"||n==="tr"?e.y="bottom":(n==="bl"||n==="mb"||n==="br")&&(e.y="top"),e},_getActionFromCorner:function(t,n,e,o){if(!n||!t)return"drag";var h=o.controls[n];return h.getActionName(e,h,o)},_setupCurrentTransform:function(t,n,e){if(n){var o=this.getPointer(t),h=n.__corner,s=n.controls[h],u=e&&h?s.getActionHandler(t,n,s):r.controlsUtils.dragHandler,d=this._getActionFromCorner(e,h,t,n),m=this._getOriginFromCorner(n,h),p=t[this.centeredKey],v={target:n,action:d,actionHandler:u,corner:h,scaleX:n.scaleX,scaleY:n.scaleY,skewX:n.skewX,skewY:n.skewY,offsetX:o.x-n.left,offsetY:o.y-n.top,originX:m.x,originY:m.y,ex:o.x,ey:o.y,lastX:o.x,lastY:o.y,theta:i(n.angle),width:n.width*n.scaleX,shiftKey:t.shiftKey,altKey:p,original:r.util.saveObjectTransform(n)};this._shouldCenterTransform(n,d,p)&&(v.originX="center",v.originY="center"),v.original.originX=m.x,v.original.originY=m.y,this._currentTransform=v,this._beforeTransform(t)}},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_drawSelection:function(t){var n=this._groupSelector,e=new r.Point(n.ex,n.ey),o=r.util.transformPoint(e,this.viewportTransform),h=new r.Point(n.ex+n.left,n.ey+n.top),s=r.util.transformPoint(h,this.viewportTransform),u=Math.min(o.x,s.x),d=Math.min(o.y,s.y),m=Math.max(o.x,s.x),p=Math.max(o.y,s.y),v=this.selectionLineWidth/2;this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(u,d,m-u,p-d)),!(!this.selectionLineWidth||!this.selectionBorderColor)&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,u+=v,d+=v,m-=v,p-=v,r.Object.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(u,d,m-u,p-d))},findTarget:function(t,n){if(!this.skipTargetFind){var e=!0,o=this.getPointer(t,e),h=this._activeObject,s=this.getActiveObjects(),u,d,m=l(t),p=s.length>1&&!n||s.length===1;if(this.targets=[],p&&h._findTargetCorner(o,m)||s.length>1&&!n&&h===this._searchPossibleTargets([h],o))return h;if(s.length===1&&h===this._searchPossibleTargets([h],o))if(this.preserveObjectStacking)u=h,d=this.targets,this.targets=[];else return h;var v=this._searchPossibleTargets(this._objects,o);return t[this.altSelectionKey]&&v&&u&&v!==u&&(v=u,this.targets=d),v}},_checkTarget:function(t,n,e){if(n&&n.visible&&n.evented&&n.containsPoint(t))if((this.perPixelTargetFind||n.perPixelTargetFind)&&!n.isEditing){var o=this.isTargetTransparent(n,e.x,e.y);if(!o)return!0}else return!0},_searchPossibleTargets:function(t,n){for(var e,o=t.length,h;o--;){var s=t[o],u=s.group?this._normalizePointer(s.group,n):n;if(this._checkTarget(u,s,n)){e=t[o],e.subTargetCheck&&e instanceof r.Group&&(h=this._searchPossibleTargets(e._objects,n),h&&this.targets.push(h));break}}return e},restorePointerVpt:function(t){return r.util.transformPoint(t,r.util.invertTransform(this.viewportTransform))},getPointer:function(t,n){if(this._absolutePointer&&!n)return this._absolutePointer;if(this._pointer&&n)return this._pointer;var e=c(t),o=this.upperCanvasEl,h=o.getBoundingClientRect(),s=h.width||0,u=h.height||0,d;(!s||!u)&&("top"in h&&"bottom"in h&&(u=Math.abs(h.top-h.bottom)),"right"in h&&"left"in h&&(s=Math.abs(h.right-h.left))),this.calcOffset(),e.x=e.x-this._offset.left,e.y=e.y-this._offset.top,n||(e=this.restorePointerVpt(e));var m=this.getRetinaScaling();return m!==1&&(e.x/=m,e.y/=m),s===0||u===0?d={width:1,height:1}:d={width:o.width/s,height:o.height/u},{x:e.x*d.width,y:e.y*d.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),n=this.lowerCanvasEl,e=this.upperCanvasEl;e?e.className="":(e=this._createCanvasElement(),this.upperCanvasEl=e),r.util.addClass(e,"upper-canvas "+t),this.wrapperEl.appendChild(e),this._copyCanvasStyle(n,e),this._applyCanvasStyle(e),this.contextTop=e.getContext("2d")},getTopContext:function(){return this.contextTop},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=r.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),r.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),r.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var n=this.width||t.width,e=this.height||t.height;r.util.setStyle(t,{position:"absolute",width:n+"px",height:e+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),t.width=n,t.height=e,r.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,n){n.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var t=this._activeObject;return t?t.type==="activeSelection"&&t._objects?t._objects.slice(0):[t]:[]},_onObjectRemoved:function(t){t===this._activeObject&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared",{target:t}),t.fire("deselected")),t===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",t)},_fireSelectionEvents:function(t,n){var e=!1,o=this.getActiveObjects(),h=[],s=[];t.forEach(function(u){o.indexOf(u)===-1&&(e=!0,u.fire("deselected",{e:n,target:u}),s.push(u))}),o.forEach(function(u){t.indexOf(u)===-1&&(e=!0,u.fire("selected",{e:n,target:u}),h.push(u))}),t.length>0&&o.length>0?e&&this.fire("selection:updated",{e:n,selected:h,deselected:s}):o.length>0?this.fire("selection:created",{e:n,selected:h}):t.length>0&&this.fire("selection:cleared",{e:n,deselected:s})},setActiveObject:function(t,n){var e=this.getActiveObjects();return this._setActiveObject(t,n),this._fireSelectionEvents(e,n),this},_setActiveObject:function(t,n){return this._activeObject===t||!this._discardActiveObject(n,t)||t.onSelect({e:n})?!1:(this._activeObject=t,!0)},_discardActiveObject:function(t,n){var e=this._activeObject;if(e){if(e.onDeselect({e:t,object:n}))return!1;this._activeObject=null}return!0},discardActiveObject:function(t){var n=this.getActiveObjects(),e=this.getActiveObject();return n.length&&this.fire("before:selection:cleared",{target:e,e:t}),this._discardActiveObject(t),this._fireSelectionEvents(n,t),this},dispose:function(){var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach((function(n){r.util.cleanUpJsdomNode(this[n]),this[n]=void 0}).bind(this)),t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,r.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(t){var n=this._activeObject;n&&n._renderControls(t)},_toObject:function(t,n,e){var o=this._realizeGroupTransformOnObject(t),h=this.callSuper("_toObject",t,n,e);return this._unwindGroupTransformOnObject(t,o),h},_realizeGroupTransformOnObject:function(t){if(t.group&&t.group.type==="activeSelection"&&this._activeObject===t.group){var n=["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"],e={};return n.forEach(function(o){e[o]=t[o]}),r.util.addTransformToObject(t,this._activeObject.calcOwnMatrix()),e}else return null},_unwindGroupTransformOnObject:function(t,n){n&&t.set(n)},_setSVGObject:function(t,n,e){var o=this._realizeGroupTransformOnObject(n);this.callSuper("_setSVGObject",t,n,e),this._unwindGroupTransformOnObject(n,o)},setViewportTransform:function(t){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),r.StaticCanvas.prototype.setViewportTransform.call(this,t)}});for(var a in r.StaticCanvas)a!=="prototype"&&(r.Canvas[a]=r.StaticCanvas[a])})(),(function(){var c=r.util.addListener,i=r.util.removeListener,l=3,a=2,t=1,n={passive:!1};function e(o,h){return o.button&&o.button===h-1}r.util.object.extend(r.Canvas.prototype,{mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(c,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(o,h){var s=this.upperCanvasEl,u=this._getEventPrefix();o(r.window,"resize",this._onResize),o(s,u+"down",this._onMouseDown),o(s,u+"move",this._onMouseMove,n),o(s,u+"out",this._onMouseOut),o(s,u+"enter",this._onMouseEnter),o(s,"wheel",this._onMouseWheel),o(s,"contextmenu",this._onContextMenu),o(s,"dblclick",this._onDoubleClick),o(s,"dragover",this._onDragOver),o(s,"dragenter",this._onDragEnter),o(s,"dragleave",this._onDragLeave),o(s,"drop",this._onDrop),this.enablePointerEvents||o(s,"touchstart",this._onTouchStart,n),typeof eventjs<"u"&&h in eventjs&&(eventjs[h](s,"gesture",this._onGesture),eventjs[h](s,"drag",this._onDrag),eventjs[h](s,"orientation",this._onOrientationChange),eventjs[h](s,"shake",this._onShake),eventjs[h](s,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(i,"remove");var o=this._getEventPrefix();i(r.document,o+"up",this._onMouseUp),i(r.document,"touchend",this._onTouchEnd,n),i(r.document,o+"move",this._onMouseMove,n),i(r.document,"touchmove",this._onMouseMove,n)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._onDrop.bind(this),this.eventsBound=!0)},_onGesture:function(o,h){this.__onTransformGesture&&this.__onTransformGesture(o,h)},_onDrag:function(o,h){this.__onDrag&&this.__onDrag(o,h)},_onMouseWheel:function(o){this.__onMouseWheel(o)},_onMouseOut:function(o){var h=this._hoveredTarget;this.fire("mouse:out",{target:h,e:o}),this._hoveredTarget=null,h&&h.fire("mouseout",{e:o});var s=this;this._hoveredTargets.forEach(function(u){s.fire("mouse:out",{target:h,e:o}),u&&h.fire("mouseout",{e:o})}),this._hoveredTargets=[]},_onMouseEnter:function(o){!this._currentTransform&&!this.findTarget(o)&&(this.fire("mouse:over",{target:null,e:o}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(o,h){this.__onOrientationChange&&this.__onOrientationChange(o,h)},_onShake:function(o,h){this.__onShake&&this.__onShake(o,h)},_onLongPress:function(o,h){this.__onLongPress&&this.__onLongPress(o,h)},_onDragOver:function(o){o.preventDefault();var h=this._simpleEventHandler("dragover",o);this._fireEnterLeaveEvents(h,o)},_onDrop:function(o){return this._simpleEventHandler("drop:before",o),this._simpleEventHandler("drop",o)},_onContextMenu:function(o){return this.stopContextMenu&&(o.stopPropagation(),o.preventDefault()),!1},_onDoubleClick:function(o){this._cacheTransformEventData(o),this._handleEvent(o,"dblclick"),this._resetTransformEventData(o)},getPointerId:function(o){var h=o.changedTouches;return h?h[0]&&h[0].identifier:this.enablePointerEvents?o.pointerId:-1},_isMainEvent:function(o){return o.isPrimary===!0?!0:o.isPrimary===!1?!1:o.type==="touchend"&&o.touches.length===0?!0:o.changedTouches?o.changedTouches[0].identifier===this.mainTouchId:!0},_onTouchStart:function(o){o.preventDefault(),this.mainTouchId===null&&(this.mainTouchId=this.getPointerId(o)),this.__onMouseDown(o),this._resetTransformEventData();var h=this.upperCanvasEl,s=this._getEventPrefix();c(r.document,"touchend",this._onTouchEnd,n),c(r.document,"touchmove",this._onMouseMove,n),i(h,s+"down",this._onMouseDown)},_onMouseDown:function(o){this.__onMouseDown(o),this._resetTransformEventData();var h=this.upperCanvasEl,s=this._getEventPrefix();i(h,s+"move",this._onMouseMove,n),c(r.document,s+"up",this._onMouseUp),c(r.document,s+"move",this._onMouseMove,n)},_onTouchEnd:function(o){if(!(o.touches.length>0)){this.__onMouseUp(o),this._resetTransformEventData(),this.mainTouchId=null;var h=this._getEventPrefix();i(r.document,"touchend",this._onTouchEnd,n),i(r.document,"touchmove",this._onMouseMove,n);var s=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(function(){c(s.upperCanvasEl,h+"down",s._onMouseDown),s._willAddMouseDown=0},400)}},_onMouseUp:function(o){this.__onMouseUp(o),this._resetTransformEventData();var h=this.upperCanvasEl,s=this._getEventPrefix();this._isMainEvent(o)&&(i(r.document,s+"up",this._onMouseUp),i(r.document,s+"move",this._onMouseMove,n),c(h,s+"move",this._onMouseMove,n))},_onMouseMove:function(o){!this.allowTouchScrolling&&o.preventDefault&&o.preventDefault(),this.__onMouseMove(o)},_onResize:function(){this.calcOffset()},_shouldRender:function(o){var h=this._activeObject;return!!h!=!!o||h&&o&&h!==o?!0:(h&&h.isEditing,!1)},__onMouseUp:function(o){var h,s=this._currentTransform,u=this._groupSelector,d=!1,m=!u||u.left===0&&u.top===0;if(this._cacheTransformEventData(o),h=this._target,this._handleEvent(o,"up:before"),e(o,l)){this.fireRightClick&&this._handleEvent(o,"up",l,m);return}if(e(o,a)){this.fireMiddleClick&&this._handleEvent(o,"up",a,m),this._resetTransformEventData();return}if(this.isDrawingMode&&this._isCurrentlyDrawing){this._onMouseUpInDrawingMode(o);return}if(this._isMainEvent(o)){if(s&&(this._finalizeCurrentTransform(o),d=s.actionPerformed),!m){var p=h===this._activeObject;this._maybeGroupObjects(o),d||(d=this._shouldRender(h)||!p&&h===this._activeObject)}var v,b;if(h){if(v=h._findTargetCorner(this.getPointer(o,!0),r.util.isTouchEvent(o)),h.selectable&&h!==this._activeObject&&h.activeOn==="up")this.setActiveObject(h,o),d=!0;else{var S=h.controls[v],E=S&&S.getMouseUpHandler(o,h,S);E&&(b=this.getPointer(o),E(o,s,b.x,b.y))}h.isMoving=!1}if(s&&(s.target!==h||s.corner!==v)){var F=s.target&&s.target.controls[s.corner],R=F&&F.getMouseUpHandler(o,h,S);b=b||this.getPointer(o),R&&R(o,s,b.x,b.y)}this._setCursorFromEvent(o,h),this._handleEvent(o,"up",t,m),this._groupSelector=null,this._currentTransform=null,h&&(h.__corner=0),d?this.requestRenderAll():m||this.renderTop()}},_simpleEventHandler:function(o,h){var s=this.findTarget(h),u=this.targets,d={e:h,target:s,subTargets:u};if(this.fire(o,d),s&&s.fire(o,d),!u)return s;for(var m=0;m<u.length;m++)u[m].fire(o,d);return s},_handleEvent:function(o,h,s,u){var d=this._target,m=this.targets||[],p={e:o,target:d,subTargets:m,button:s||t,isClick:u||!1,pointer:this._pointer,absolutePointer:this._absolutePointer,transform:this._currentTransform};h==="up"&&(p.currentTarget=this.findTarget(o),p.currentSubTargets=this.targets),this.fire("mouse:"+h,p),d&&d.fire("mouse"+h,p);for(var v=0;v<m.length;v++)m[v].fire("mouse"+h,p)},_finalizeCurrentTransform:function(o){var h=this._currentTransform,s=h.target,u={e:o,target:s,transform:h,action:h.action};s._scaling&&(s._scaling=!1),s.setCoords(),(h.actionPerformed||this.stateful&&s.hasStateChanged())&&this._fire("modified",u)},_onMouseDownInDrawingMode:function(o){this._isCurrentlyDrawing=!0,this.getActiveObject()&&this.discardActiveObject(o).requestRenderAll();var h=this.getPointer(o);this.freeDrawingBrush.onMouseDown(h,{e:o,pointer:h}),this._handleEvent(o,"down")},_onMouseMoveInDrawingMode:function(o){if(this._isCurrentlyDrawing){var h=this.getPointer(o);this.freeDrawingBrush.onMouseMove(h,{e:o,pointer:h})}this.setCursor(this.freeDrawingCursor),this._handleEvent(o,"move")},_onMouseUpInDrawingMode:function(o){var h=this.getPointer(o);this._isCurrentlyDrawing=this.freeDrawingBrush.onMouseUp({e:o,pointer:h}),this._handleEvent(o,"up")},__onMouseDown:function(o){this._cacheTransformEventData(o),this._handleEvent(o,"down:before");var h=this._target;if(e(o,l)){this.fireRightClick&&this._handleEvent(o,"down",l);return}if(e(o,a)){this.fireMiddleClick&&this._handleEvent(o,"down",a);return}if(this.isDrawingMode){this._onMouseDownInDrawingMode(o);return}if(this._isMainEvent(o)&&!this._currentTransform){var s=this._pointer;this._previousPointer=s;var u=this._shouldRender(h),d=this._shouldGroup(o,h);if(this._shouldClearSelection(o,h)?this.discardActiveObject(o):d&&(this._handleGrouping(o,h),h=this._activeObject),this.selection&&(!h||!h.selectable&&!h.isEditing&&h!==this._activeObject)&&(this._groupSelector={ex:this._absolutePointer.x,ey:this._absolutePointer.y,top:0,left:0}),h){var m=h===this._activeObject;h.selectable&&h.activeOn==="down"&&this.setActiveObject(h,o);var p=h._findTargetCorner(this.getPointer(o,!0),r.util.isTouchEvent(o));if(h.__corner=p,h===this._activeObject&&(p||!d)){this._setupCurrentTransform(o,h,m);var v=h.controls[p],s=this.getPointer(o),b=v&&v.getMouseDownHandler(o,h,v);b&&b(o,this._currentTransform,s.x,s.y)}}this._handleEvent(o,"down"),(u||d)&&this.requestRenderAll()}},_resetTransformEventData:function(){this._target=null,this._pointer=null,this._absolutePointer=null},_cacheTransformEventData:function(o){this._resetTransformEventData(),this._pointer=this.getPointer(o,!0),this._absolutePointer=this.restorePointerVpt(this._pointer),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(o)||null},_beforeTransform:function(o){var h=this._currentTransform;this.stateful&&h.target.saveState(),this.fire("before:transform",{e:o,transform:h})},__onMouseMove:function(o){this._handleEvent(o,"move:before"),this._cacheTransformEventData(o);var h,s;if(this.isDrawingMode){this._onMouseMoveInDrawingMode(o);return}if(this._isMainEvent(o)){var u=this._groupSelector;u?(s=this._absolutePointer,u.left=s.x-u.ex,u.top=s.y-u.ey,this.renderTop()):this._currentTransform?this._transformObject(o):(h=this.findTarget(o)||null,this._setCursorFromEvent(o,h),this._fireOverOutEvents(h,o)),this._handleEvent(o,"move"),this._resetTransformEventData()}},_fireOverOutEvents:function(o,h){var s=this._hoveredTarget,u=this._hoveredTargets,d=this.targets,m=Math.max(u.length,d.length);this.fireSyntheticInOutEvents(o,h,{oldTarget:s,evtOut:"mouseout",canvasEvtOut:"mouse:out",evtIn:"mouseover",canvasEvtIn:"mouse:over"});for(var p=0;p<m;p++)this.fireSyntheticInOutEvents(d[p],h,{oldTarget:u[p],evtOut:"mouseout",evtIn:"mouseover"});this._hoveredTarget=o,this._hoveredTargets=this.targets.concat()},_fireEnterLeaveEvents:function(o,h){var s=this._draggedoverTarget,u=this._hoveredTargets,d=this.targets,m=Math.max(u.length,d.length);this.fireSyntheticInOutEvents(o,h,{oldTarget:s,evtOut:"dragleave",evtIn:"dragenter"});for(var p=0;p<m;p++)this.fireSyntheticInOutEvents(d[p],h,{oldTarget:u[p],evtOut:"dragleave",evtIn:"dragenter"});this._draggedoverTarget=o},fireSyntheticInOutEvents:function(o,h,s){var u,d,m=s.oldTarget,p,v,b=m!==o,S=s.canvasEvtIn,E=s.canvasEvtOut;b&&(u={e:h,target:o,previousTarget:m},d={e:h,target:m,nextTarget:o}),v=o&&b,p=m&&b,p&&(E&&this.fire(E,d),m.fire(s.evtOut,d)),v&&(S&&this.fire(S,u),o.fire(s.evtIn,u))},__onMouseWheel:function(o){this._cacheTransformEventData(o),this._handleEvent(o,"wheel"),this._resetTransformEventData()},_transformObject:function(o){var h=this.getPointer(o),s=this._currentTransform;s.reset=!1,s.shiftKey=o.shiftKey,s.altKey=o[this.centeredKey],this._performTransformAction(o,s,h),s.actionPerformed&&this.requestRenderAll()},_performTransformAction:function(o,h,s){var u=s.x,d=s.y,m=h.action,p=!1,v=h.actionHandler;v&&(p=v(o,h,u,d)),m==="drag"&&p&&(h.target.isMoving=!0,this.setCursor(h.target.moveCursor||this.moveCursor)),h.actionPerformed=h.actionPerformed||p},_fire:r.controlsUtils.fireEvent,_setCursorFromEvent:function(o,h){if(!h)return this.setCursor(this.defaultCursor),!1;var s=h.hoverCursor||this.hoverCursor,u=this._activeObject&&this._activeObject.type==="activeSelection"?this._activeObject:null,d=(!u||!u.contains(h))&&h._findTargetCorner(this.getPointer(o,!0));d?this.setCursor(this.getCornerCursor(d,h,o)):(h.subTargetCheck&&this.targets.concat().reverse().map(function(m){s=m.hoverCursor||s}),this.setCursor(s))},getCornerCursor:function(o,h,s){var u=h.controls[o];return u.cursorStyleHandler(s,u,h)}})})(),(function(){var c=Math.min,i=Math.max;r.util.object.extend(r.Canvas.prototype,{_shouldGroup:function(l,a){var t=this._activeObject;return t&&this._isSelectionKeyPressed(l)&&a&&a.selectable&&this.selection&&(t!==a||t.type==="activeSelection")&&!a.onSelect({e:l})},_handleGrouping:function(l,a){var t=this._activeObject;t.__corner||a===t&&(a=this.findTarget(l,!0),!a||!a.selectable)||(t&&t.type==="activeSelection"?this._updateActiveSelection(a,l):this._createActiveSelection(a,l))},_updateActiveSelection:function(l,a){var t=this._activeObject,n=t._objects.slice(0);t.contains(l)?(t.removeWithUpdate(l),this._hoveredTarget=l,this._hoveredTargets=this.targets.concat(),t.size()===1&&this._setActiveObject(t.item(0),a)):(t.addWithUpdate(l),this._hoveredTarget=t,this._hoveredTargets=this.targets.concat()),this._fireSelectionEvents(n,a)},_createActiveSelection:function(l,a){var t=this.getActiveObjects(),n=this._createGroup(l);this._hoveredTarget=n,this._setActiveObject(n,a),this._fireSelectionEvents(t,a)},_createGroup:function(l){var a=this._objects,t=a.indexOf(this._activeObject)<a.indexOf(l),n=t?[this._activeObject,l]:[l,this._activeObject];return this._activeObject.isEditing&&this._activeObject.exitEditing(),new r.ActiveSelection(n,{canvas:this})},_groupSelectedObjects:function(l){var a=this._collectObjects(l),t;a.length===1?this.setActiveObject(a[0],l):a.length>1&&(t=new r.ActiveSelection(a.reverse(),{canvas:this}),this.setActiveObject(t,l))},_collectObjects:function(l){for(var a=[],t,n=this._groupSelector.ex,e=this._groupSelector.ey,o=n+this._groupSelector.left,h=e+this._groupSelector.top,s=new r.Point(c(n,o),c(e,h)),u=new r.Point(i(n,o),i(e,h)),d=!this.selectionFullyContained,m=n===o&&e===h,p=this._objects.length;p--&&(t=this._objects[p],!(!(!t||!t.selectable||!t.visible)&&(d&&t.intersectsWithRect(s,u,!0)||t.isContainedWithinRect(s,u,!0)||d&&t.containsPoint(s,null,!0)||d&&t.containsPoint(u,null,!0))&&(a.push(t),m))););return a.length>1&&(a=a.filter(function(v){return!v.onSelect({e:l})})),a},_maybeGroupObjects:function(l){this.selection&&this._groupSelector&&this._groupSelectedObjects(l),this.setCursor(this.defaultCursor),this._groupSelector=null}})})(),(function(){r.util.object.extend(r.StaticCanvas.prototype,{toDataURL:function(c){c||(c={});var i=c.format||"png",l=c.quality||1,a=(c.multiplier||1)*(c.enableRetinaScaling?this.getRetinaScaling():1),t=this.toCanvasElement(a,c);return r.util.toDataURL(t,i,l)},toCanvasElement:function(c,i){c=c||1,i=i||{};var l=(i.width||this.width)*c,a=(i.height||this.height)*c,t=this.getZoom(),n=this.width,e=this.height,o=t*c,h=this.viewportTransform,s=(h[4]-(i.left||0))*c,u=(h[5]-(i.top||0))*c,d=this.interactive,m=[o,0,0,o,s,u],p=this.enableRetinaScaling,v=r.util.createCanvasElement(),b=this.contextTop;return v.width=l,v.height=a,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=m,this.width=l,this.height=a,this.calcViewportBoundaries(),this.renderCanvas(v.getContext("2d"),this._objects),this.viewportTransform=h,this.width=n,this.height=e,this.calcViewportBoundaries(),this.interactive=d,this.enableRetinaScaling=p,this.contextTop=b,v}})})(),r.util.object.extend(r.StaticCanvas.prototype,{loadFromJSON:function(c,i,l){if(c){var a=typeof c=="string"?JSON.parse(c):r.util.object.clone(c),t=this,n=a.clipPath,e=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete a.clipPath,this._enlivenObjects(a.objects,function(o){t.clear(),t._setBgOverlay(a,function(){n?t._enlivenObjects([n],function(h){t.clipPath=h[0],t.__setupCanvas.call(t,a,o,e,i)}):t.__setupCanvas.call(t,a,o,e,i)})},l),this}},__setupCanvas:function(c,i,l,a){var t=this;i.forEach(function(n,e){t.insertAt(n,e)}),this.renderOnAddRemove=l,delete c.objects,delete c.backgroundImage,delete c.overlayImage,delete c.background,delete c.overlay,this._setOptions(c),this.renderAll(),a&&a()},_setBgOverlay:function(c,i){var l={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(!c.backgroundImage&&!c.overlayImage&&!c.background&&!c.overlay){i&&i();return}var a=function(){l.backgroundImage&&l.overlayImage&&l.backgroundColor&&l.overlayColor&&i&&i()};this.__setBgOverlay("backgroundImage",c.backgroundImage,l,a),this.__setBgOverlay("overlayImage",c.overlayImage,l,a),this.__setBgOverlay("backgroundColor",c.background,l,a),this.__setBgOverlay("overlayColor",c.overlay,l,a)},__setBgOverlay:function(c,i,l,a){var t=this;if(!i){l[c]=!0,a&&a();return}c==="backgroundImage"||c==="overlayImage"?r.util.enlivenObjects([i],function(n){t[c]=n[0],l[c]=!0,a&&a()}):this["set"+r.util.string.capitalize(c,!0)](i,function(){l[c]=!0,a&&a()})},_enlivenObjects:function(c,i,l){if(!c||c.length===0){i&&i([]);return}r.util.enlivenObjects(c,function(a){i&&i(a)},null,l)},_toDataURL:function(c,i){this.clone(function(l){i(l.toDataURL(c))})},_toDataURLWithMultiplier:function(c,i,l){this.clone(function(a){l(a.toDataURLWithMultiplier(c,i))})},clone:function(c,i){var l=JSON.stringify(this.toJSON(i));this.cloneWithoutData(function(a){a.loadFromJSON(l,function(){c&&c(a)})})},cloneWithoutData:function(c){var i=r.util.createCanvasElement();i.width=this.width,i.height=this.height;var l=new r.Canvas(i);this.backgroundImage?(l.setBackgroundImage(this.backgroundImage.src,function(){l.renderAll(),c&&c(l)}),l.backgroundImageOpacity=this.backgroundImageOpacity,l.backgroundImageStretch=this.backgroundImageStretch):c&&c(l)}}),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.object.extend,a=i.util.object.clone,t=i.util.toFixed,n=i.util.string.capitalize,e=i.util.degreesToRadians,o=!i.isLikelyNode,h=2;i.Object||(i.Object=i.util.createClass(i.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,touchCornerSize:24,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgb(178,204,255)",borderDashArray:null,cornerColor:"rgb(178,204,255)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,perPixelTargetFind:!1,includeDefaultValues:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:o,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",activeOn:"down",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),colorProperties:"fill stroke backgroundColor".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(s){s&&this.setOptions(s)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=i.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(s){var u=i.perfLimitSizeTotal,d=s.width,m=s.height,p=i.maxCacheSideLimit,v=i.minCacheSideLimit;if(d<=p&&m<=p&&d*m<=u)return d<v&&(s.width=v),m<v&&(s.height=v),s;var b=d/m,S=i.util.limitDimsByArea(b,u),E=i.util.capValue,F=E(v,S.x,p),R=E(v,S.y,p);return d>F&&(s.zoomX/=d/F,s.width=F,s.capped=!0),m>R&&(s.zoomY/=m/R,s.height=R,s.capped=!0),s},_getCacheCanvasDimensions:function(){var s=this.getTotalObjectScaling(),u=this._getTransformedDimensions(0,0),d=u.x*s.scaleX/this.scaleX,m=u.y*s.scaleY/this.scaleY;return{width:d+h,height:m+h,zoomX:s.scaleX,zoomY:s.scaleY,x:d,y:m}},_updateCacheCanvas:function(){var s=this.canvas;if(this.noScaleCache&&s&&s._currentTransform){var u=s._currentTransform.target,d=s._currentTransform.action;if(this===u&&d.slice&&d.slice(0,5)==="scale")return!1}var m=this._cacheCanvas,p=this._limitCacheSize(this._getCacheCanvasDimensions()),v=i.minCacheSideLimit,b=p.width,S=p.height,E,F,R=p.zoomX,z=p.zoomY,K=b!==this.cacheWidth||S!==this.cacheHeight,Z=this.zoomX!==R||this.zoomY!==z,q=K||Z,$=0,tt=0,it=!1;if(K){var et=this._cacheCanvas.width,w=this._cacheCanvas.height,k=b>et||S>w,A=(b<et*.9||S<w*.9)&&et>v&&w>v;it=k||A,k&&!p.capped&&(b>v||S>v)&&($=b*.1,tt=S*.1)}return this instanceof i.Text&&this.path&&(q=!0,it=!0,$+=this.getHeightOfLine(0)*this.zoomX,tt+=this.getHeightOfLine(0)*this.zoomY),q?(it?(m.width=Math.ceil(b+$),m.height=Math.ceil(S+tt)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,m.width,m.height)),E=p.x/2,F=p.y/2,this.cacheTranslationX=Math.round(m.width/2-E)+E,this.cacheTranslationY=Math.round(m.height/2-F)+F,this.cacheWidth=b,this.cacheHeight=S,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(R,z),this.zoomX=R,this.zoomY=z,!0):!1},setOptions:function(s){this._setOptions(s),this._initGradient(s.fill,"fill"),this._initGradient(s.stroke,"stroke"),this._initPattern(s.fill,"fill"),this._initPattern(s.stroke,"stroke")},transform:function(s){var u=this.group&&!this.group._transformDone||this.group&&this.canvas&&s===this.canvas.contextTop,d=this.calcTransformMatrix(!u);s.transform(d[0],d[1],d[2],d[3],d[4],d[5])},toObject:function(s){var u=i.Object.NUM_FRACTION_DIGITS,d={type:this.type,version:i.version,originX:this.originX,originY:this.originY,left:t(this.left,u),top:t(this.top,u),width:t(this.width,u),height:t(this.height,u),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:t(this.strokeWidth,u),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeUniform:this.strokeUniform,strokeMiterLimit:t(this.strokeMiterLimit,u),scaleX:t(this.scaleX,u),scaleY:t(this.scaleY,u),angle:t(this.angle,u),flipX:this.flipX,flipY:this.flipY,opacity:t(this.opacity,u),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,skewX:t(this.skewX,u),skewY:t(this.skewY,u)};return this.clipPath&&!this.clipPath.excludeFromExport&&(d.clipPath=this.clipPath.toObject(s),d.clipPath.inverted=this.clipPath.inverted,d.clipPath.absolutePositioned=this.clipPath.absolutePositioned),i.util.populateWithProperties(this,d,s),this.includeDefaultValues||(d=this._removeDefaultValues(d)),d},toDatalessObject:function(s){return this.toObject(s)},_removeDefaultValues:function(s){var u=i.util.getKlass(s.type).prototype,d=u.stateProperties;return d.forEach(function(m){m==="left"||m==="top"||(s[m]===u[m]&&delete s[m],Array.isArray(s[m])&&Array.isArray(u[m])&&s[m].length===0&&u[m].length===0&&delete s[m])}),s},toString:function(){return"#<fabric."+n(this.type)+">"},getObjectScaling:function(){if(!this.group)return{scaleX:this.scaleX,scaleY:this.scaleY};var s=i.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(s.scaleX),scaleY:Math.abs(s.scaleY)}},getTotalObjectScaling:function(){var s=this.getObjectScaling(),u=s.scaleX,d=s.scaleY;if(this.canvas){var m=this.canvas.getZoom(),p=this.canvas.getRetinaScaling();u*=m*p,d*=m*p}return{scaleX:u,scaleY:d}},getObjectOpacity:function(){var s=this.opacity;return this.group&&(s*=this.group.getObjectOpacity()),s},_set:function(s,u){var d=s==="scaleX"||s==="scaleY",m=this[s]!==u,p=!1;return d&&(u=this._constrainScale(u)),s==="scaleX"&&u<0?(this.flipX=!this.flipX,u*=-1):s==="scaleY"&&u<0?(this.flipY=!this.flipY,u*=-1):s==="shadow"&&u&&!(u instanceof i.Shadow)?u=new i.Shadow(u):s==="dirty"&&this.group&&this.group.set("dirty",u),this[s]=u,m&&(p=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(s)>-1?(this.dirty=!0,p&&this.group.set("dirty",!0)):p&&this.stateProperties.indexOf(s)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:i.iMatrix.concat()},isNotVisible:function(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible},render:function(s){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(s.save(),this._setupCompositeOperation(s),this.drawSelectionBackground(s),this.transform(s),this._setOpacity(s),this._setShadow(s,this),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(s)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(s),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),s.restore())},renderCache:function(s){s=s||{},(!this._cacheCanvas||!this._cacheContext)&&this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,s.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this._cacheContext=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0},hasFill:function(){return this.fill&&this.fill!=="transparent"},needsItsOwnCache:function(){return!!(this.paintFirst==="stroke"&&this.hasFill()&&this.hasStroke()&&typeof this.shadow=="object"||this.clipPath)},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)},drawClipPathOnCache:function(s,u){if(s.save(),u.inverted?s.globalCompositeOperation="destination-out":s.globalCompositeOperation="destination-in",u.absolutePositioned){var d=i.util.invertTransform(this.calcTransformMatrix());s.transform(d[0],d[1],d[2],d[3],d[4],d[5])}u.transform(s),s.scale(1/u.zoomX,1/u.zoomY),s.drawImage(u._cacheCanvas,-u.cacheTranslationX,-u.cacheTranslationY),s.restore()},drawObject:function(s,u){var d=this.fill,m=this.stroke;u?(this.fill="black",this.stroke="",this._setClippingProperties(s)):this._renderBackground(s),this._render(s),this._drawClipPath(s,this.clipPath),this.fill=d,this.stroke=m},_drawClipPath:function(s,u){u&&(u.canvas=this.canvas,u.shouldCache(),u._transformDone=!0,u.renderCache({forClipping:!0}),this.drawClipPathOnCache(s,u))},drawCacheOnCanvas:function(s){s.scale(1/this.zoomX,1/this.zoomY),s.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(s){if(this.isNotVisible())return!1;if(this._cacheCanvas&&this._cacheContext&&!s&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&this._cacheContext&&!s){var u=this.cacheWidth/this.zoomX,d=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-u/2,-d/2,u,d)}return!0}return!1},_renderBackground:function(s){if(this.backgroundColor){var u=this._getNonTransformedDimensions();s.fillStyle=this.backgroundColor,s.fillRect(-u.x/2,-u.y/2,u.x,u.y),this._removeShadow(s)}},_setOpacity:function(s){this.group&&!this.group._transformDone?s.globalAlpha=this.getObjectOpacity():s.globalAlpha*=this.opacity},_setStrokeStyles:function(s,u){var d=u.stroke;d&&(s.lineWidth=u.strokeWidth,s.lineCap=u.strokeLineCap,s.lineDashOffset=u.strokeDashOffset,s.lineJoin=u.strokeLineJoin,s.miterLimit=u.strokeMiterLimit,d.toLive?d.gradientUnits==="percentage"||d.gradientTransform||d.patternTransform?this._applyPatternForTransformedGradient(s,d):(s.strokeStyle=d.toLive(s,this),this._applyPatternGradientTransform(s,d)):s.strokeStyle=u.stroke)},_setFillStyles:function(s,u){var d=u.fill;d&&(d.toLive?(s.fillStyle=d.toLive(s,this),this._applyPatternGradientTransform(s,u.fill)):s.fillStyle=d)},_setClippingProperties:function(s){s.globalAlpha=1,s.strokeStyle="transparent",s.fillStyle="#000000"},_setLineDash:function(s,u){!u||u.length===0||(1&u.length&&u.push.apply(u,u),s.setLineDash(u))},_renderControls:function(s,u){var d=this.getViewportTransform(),m=this.calcTransformMatrix(),p,v,b;u=u||{},v=typeof u.hasBorders<"u"?u.hasBorders:this.hasBorders,b=typeof u.hasControls<"u"?u.hasControls:this.hasControls,m=i.util.multiplyTransformMatrices(d,m),p=i.util.qrDecompose(m),s.save(),s.translate(p.translateX,p.translateY),s.lineWidth=1*this.borderScaleFactor,this.group||(s.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(p.angle-=180),s.rotate(e(this.group?p.angle:this.angle)),u.forActiveSelection||this.group?v&&this.drawBordersInGroup(s,p,u):v&&this.drawBorders(s,u),b&&this.drawControls(s,u),s.restore()},_setShadow:function(s){if(this.shadow){var u=this.shadow,d=this.canvas,m,p=d&&d.viewportTransform[0]||1,v=d&&d.viewportTransform[3]||1;u.nonScaling?m={scaleX:1,scaleY:1}:m=this.getObjectScaling(),d&&d._isRetinaScaling()&&(p*=i.devicePixelRatio,v*=i.devicePixelRatio),s.shadowColor=u.color,s.shadowBlur=u.blur*i.browserShadowBlurConstant*(p+v)*(m.scaleX+m.scaleY)/4,s.shadowOffsetX=u.offsetX*p*m.scaleX,s.shadowOffsetY=u.offsetY*v*m.scaleY}},_removeShadow:function(s){this.shadow&&(s.shadowColor="",s.shadowBlur=s.shadowOffsetX=s.shadowOffsetY=0)},_applyPatternGradientTransform:function(s,u){if(!u||!u.toLive)return{offsetX:0,offsetY:0};var d=u.gradientTransform||u.patternTransform,m=-this.width/2+u.offsetX||0,p=-this.height/2+u.offsetY||0;return u.gradientUnits==="percentage"?s.transform(this.width,0,0,this.height,m,p):s.transform(1,0,0,1,m,p),d&&s.transform(d[0],d[1],d[2],d[3],d[4],d[5]),{offsetX:m,offsetY:p}},_renderPaintInOrder:function(s){this.paintFirst==="stroke"?(this._renderStroke(s),this._renderFill(s)):(this._renderFill(s),this._renderStroke(s))},_render:function(){},_renderFill:function(s){this.fill&&(s.save(),this._setFillStyles(s,this),this.fillRule==="evenodd"?s.fill("evenodd"):s.fill(),s.restore())},_renderStroke:function(s){if(!(!this.stroke||this.strokeWidth===0)){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(s),s.save(),this.strokeUniform&&this.group){var u=this.getObjectScaling();s.scale(1/u.scaleX,1/u.scaleY)}else this.strokeUniform&&s.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(s,this.strokeDashArray),this._setStrokeStyles(s,this),s.stroke(),s.restore()}},_applyPatternForTransformedGradient:function(s,u){var d=this._limitCacheSize(this._getCacheCanvasDimensions()),m=i.util.createCanvasElement(),p,v=this.canvas.getRetinaScaling(),b=d.x/this.scaleX/v,S=d.y/this.scaleY/v;m.width=b,m.height=S,p=m.getContext("2d"),p.beginPath(),p.moveTo(0,0),p.lineTo(b,0),p.lineTo(b,S),p.lineTo(0,S),p.closePath(),p.translate(b/2,S/2),p.scale(d.zoomX/this.scaleX/v,d.zoomY/this.scaleY/v),this._applyPatternGradientTransform(p,u),p.fillStyle=u.toLive(s),p.fill(),s.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),s.scale(v*this.scaleX/d.zoomX,v*this.scaleY/d.zoomY),s.strokeStyle=p.createPattern(m,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var s=i.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",s.scaleX),this.set("scaleY",s.scaleY),this.angle=s.angle,this.skewX=s.skewX,this.skewY=0}},_removeTransformMatrix:function(s){var u=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),u=i.util.transformPoint(u,this.transformMatrix)),this.transformMatrix=null,s&&(this.scaleX*=s.scaleX,this.scaleY*=s.scaleY,this.cropX=s.cropX,this.cropY=s.cropY,u.x+=s.offsetLeft,u.y+=s.offsetTop,this.width=s.width,this.height=s.height),this.setPositionByOrigin(u,"center","center")},clone:function(s,u){var d=this.toObject(u);this.constructor.fromObject?this.constructor.fromObject(d,s):i.Object._fromObject("Object",d,s)},cloneAsImage:function(s,u){var d=this.toCanvasElement(u);return s&&s(new i.Image(d)),this},toCanvasElement:function(s){s||(s={});var u=i.util,d=u.saveObjectTransform(this),m=this.group,p=this.shadow,v=Math.abs,b=(s.multiplier||1)*(s.enableRetinaScaling?i.devicePixelRatio:1);delete this.group,s.withoutTransform&&u.resetObjectTransform(this),s.withoutShadow&&(this.shadow=null);var S=i.util.createCanvasElement(),E=this.getBoundingRect(!0,!0),F=this.shadow,R,z={x:0,y:0},K,Z,q;F&&(K=F.blur,F.nonScaling?R={scaleX:1,scaleY:1}:R=this.getObjectScaling(),z.x=2*Math.round(v(F.offsetX)+K)*v(R.scaleX),z.y=2*Math.round(v(F.offsetY)+K)*v(R.scaleY)),Z=E.width+z.x,q=E.height+z.y,S.width=Math.ceil(Z),S.height=Math.ceil(q);var $=new i.StaticCanvas(S,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});s.format==="jpeg"&&($.backgroundColor="#fff"),this.setPositionByOrigin(new i.Point($.width/2,$.height/2),"center","center");var tt=this.canvas;$.add(this);var it=$.toCanvasElement(b||1,s);return this.shadow=p,this.set("canvas",tt),m&&(this.group=m),this.set(d).setCoords(),$._objects=[],$.dispose(),$=null,it},toDataURL:function(s){return s||(s={}),i.util.toDataURL(this.toCanvasElement(s),s.format||"png",s.quality||1)},isType:function(s){return arguments.length>1?Array.from(arguments).includes(this.type):this.type===s},complexity:function(){return 1},toJSON:function(s){return this.toObject(s)},rotate:function(s){var u=(this.originX!=="center"||this.originY!=="center")&&this.centeredRotation;return u&&this._setOriginToCenter(),this.set("angle",s),u&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(s,u){u=u||this.canvas.getPointer(s);var d=new i.Point(u.x,u.y),m=this._getLeftTopCoords();return this.angle&&(d=i.util.rotatePoint(d,m,e(-this.angle))),{x:d.x-m.x,y:d.y-m.y}},_setupCompositeOperation:function(s){this.globalCompositeOperation&&(s.globalCompositeOperation=this.globalCompositeOperation)},dispose:function(){i.runningAnimations&&i.runningAnimations.cancelByTarget(this)}}),i.util.createAccessors&&i.util.createAccessors(i.Object),l(i.Object.prototype,i.Observable),i.Object.NUM_FRACTION_DIGITS=2,i.Object.ENLIVEN_PROPS=["clipPath"],i.Object._fromObject=function(s,u,d,m){var p=i[s];u=a(u,!0),i.util.enlivenPatterns([u.fill,u.stroke],function(v){typeof v[0]<"u"&&(u.fill=v[0]),typeof v[1]<"u"&&(u.stroke=v[1]),i.util.enlivenObjectEnlivables(u,u,function(){var b=m?new p(u[m],u):new p(u);d&&d(b)})})},i.Object.__uid=0)})(f),(function(){var c=r.util.degreesToRadians,i={left:-.5,center:0,right:.5},l={top:-.5,center:0,bottom:.5};r.util.object.extend(r.Object.prototype,{translateToGivenOrigin:function(a,t,n,e,o){var h=a.x,s=a.y,u,d,m;return typeof t=="string"?t=i[t]:t-=.5,typeof e=="string"?e=i[e]:e-=.5,u=e-t,typeof n=="string"?n=l[n]:n-=.5,typeof o=="string"?o=l[o]:o-=.5,d=o-n,(u||d)&&(m=this._getTransformedDimensions(),h=a.x+u*m.x,s=a.y+d*m.y),new r.Point(h,s)},translateToCenterPoint:function(a,t,n){var e=this.translateToGivenOrigin(a,t,n,"center","center");return this.angle?r.util.rotatePoint(e,a,c(this.angle)):e},translateToOriginPoint:function(a,t,n){var e=this.translateToGivenOrigin(a,"center","center",t,n);return this.angle?r.util.rotatePoint(e,a,c(this.angle)):e},getCenterPoint:function(){var a=new r.Point(this.left,this.top);return this.translateToCenterPoint(a,this.originX,this.originY)},getPointByOrigin:function(a,t){var n=this.getCenterPoint();return this.translateToOriginPoint(n,a,t)},toLocalPoint:function(a,t,n){var e=this.getCenterPoint(),o,h;return typeof t<"u"&&typeof n<"u"?o=this.translateToGivenOrigin(e,"center","center",t,n):o=new r.Point(this.left,this.top),h=new r.Point(a.x,a.y),this.angle&&(h=r.util.rotatePoint(h,e,-c(this.angle))),h.subtractEquals(o)},setPositionByOrigin:function(a,t,n){var e=this.translateToCenterPoint(a,t,n),o=this.translateToOriginPoint(e,this.originX,this.originY);this.set("left",o.x),this.set("top",o.y)},adjustPosition:function(a){var t=c(this.angle),n=this.getScaledWidth(),e=r.util.cos(t)*n,o=r.util.sin(t)*n,h,s;typeof this.originX=="string"?h=i[this.originX]:h=this.originX-.5,typeof a=="string"?s=i[a]:s=a-.5,this.left+=e*(s-h),this.top+=o*(s-h),this.setCoords(),this.originX=a},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var a=this.getCenterPoint();this.originX="center",this.originY="center",this.left=a.x,this.top=a.y},_resetOrigin:function(){var a=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=a.x,this.top=a.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}})})(),(function(){function c(n){return[new r.Point(n.tl.x,n.tl.y),new r.Point(n.tr.x,n.tr.y),new r.Point(n.br.x,n.br.y),new r.Point(n.bl.x,n.bl.y)]}var i=r.util,l=i.degreesToRadians,a=i.multiplyTransformMatrices,t=i.transformPoint;i.object.extend(r.Object.prototype,{oCoords:null,aCoords:null,lineCoords:null,ownMatrixCache:null,matrixCache:null,controls:{},_getCoords:function(n,e){return e?n?this.calcACoords():this.calcLineCoords():((!this.aCoords||!this.lineCoords)&&this.setCoords(!0),n?this.aCoords:this.lineCoords)},getCoords:function(n,e){return c(this._getCoords(n,e))},intersectsWithRect:function(n,e,o,h){var s=this.getCoords(o,h),u=r.Intersection.intersectPolygonRectangle(s,n,e);return u.status==="Intersection"},intersectsWithObject:function(n,e,o){var h=r.Intersection.intersectPolygonPolygon(this.getCoords(e,o),n.getCoords(e,o));return h.status==="Intersection"||n.isContainedWithinObject(this,e,o)||this.isContainedWithinObject(n,e,o)},isContainedWithinObject:function(n,e,o){for(var h=this.getCoords(e,o),s=e?n.aCoords:n.lineCoords,u=0,d=n._getImageLines(s);u<4;u++)if(!n.containsPoint(h[u],d))return!1;return!0},isContainedWithinRect:function(n,e,o,h){var s=this.getBoundingRect(o,h);return s.left>=n.x&&s.left+s.width<=e.x&&s.top>=n.y&&s.top+s.height<=e.y},containsPoint:function(n,u,o,h){var s=this._getCoords(o,h),u=u||this._getImageLines(s),d=this._findCrossPoints(n,u);return d!==0&&d%2===1},isOnScreen:function(n){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,o=this.canvas.vptCoords.br,h=this.getCoords(!0,n);return h.some(function(s){return s.x<=o.x&&s.x>=e.x&&s.y<=o.y&&s.y>=e.y})||this.intersectsWithRect(e,o,!0,n)?!0:this._containsCenterOfCanvas(e,o,n)},_containsCenterOfCanvas:function(n,e,o){var h={x:(n.x+e.x)/2,y:(n.y+e.y)/2};return!!this.containsPoint(h,null,!0,o)},isPartiallyOnScreen:function(n){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,o=this.canvas.vptCoords.br;if(this.intersectsWithRect(e,o,!0,n))return!0;var h=this.getCoords(!0,n).every(function(s){return(s.x>=o.x||s.x<=e.x)&&(s.y>=o.y||s.y<=e.y)});return h&&this._containsCenterOfCanvas(e,o,n)},_getImageLines:function(n){var e={topline:{o:n.tl,d:n.tr},rightline:{o:n.tr,d:n.br},bottomline:{o:n.br,d:n.bl},leftline:{o:n.bl,d:n.tl}};return e},_findCrossPoints:function(n,e){var o,h,s,u,d,m=0,p;for(var v in e)if(p=e[v],!(p.o.y<n.y&&p.d.y<n.y)&&!(p.o.y>=n.y&&p.d.y>=n.y)&&(p.o.x===p.d.x&&p.o.x>=n.x?d=p.o.x:(o=0,h=(p.d.y-p.o.y)/(p.d.x-p.o.x),s=n.y-o*n.x,u=p.o.y-h*p.o.x,d=-(s-u)/(o-h)),d>=n.x&&(m+=1),m===2))break;return m},getBoundingRect:function(n,e){var o=this.getCoords(n,e);return i.makeBoundingBoxFromPoints(o)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(n){return Math.abs(n)<this.minScaleLimit?n<0?-this.minScaleLimit:this.minScaleLimit:n===0?1e-4:n},scale:function(n){return this._set("scaleX",n),this._set("scaleY",n),this.setCoords()},scaleToWidth:function(n,e){var o=this.getBoundingRect(e).width/this.getScaledWidth();return this.scale(n/this.width/o)},scaleToHeight:function(n,e){var o=this.getBoundingRect(e).height/this.getScaledHeight();return this.scale(n/this.height/o)},calcLineCoords:function(){var n=this.getViewportTransform(),e=this.padding,o=l(this.angle),h=i.cos(o),s=i.sin(o),u=h*e,d=s*e,m=u+d,p=u-d,v=this.calcACoords(),b={tl:t(v.tl,n),tr:t(v.tr,n),bl:t(v.bl,n),br:t(v.br,n)};return e&&(b.tl.x-=p,b.tl.y-=m,b.tr.x+=m,b.tr.y-=p,b.bl.x-=m,b.bl.y+=p,b.br.x+=p,b.br.y+=m),b},calcOCoords:function(){var n=this._calcRotateMatrix(),e=this._calcTranslateMatrix(),o=this.getViewportTransform(),h=a(o,e),s=a(h,n),s=a(s,[1/o[0],0,0,1/o[3],0,0]),u=this._calculateCurrentDimensions(),d={};return this.forEachControl(function(m,p,v){d[p]=m.positionHandler(u,s,v)}),d},calcACoords:function(){var n=this._calcRotateMatrix(),e=this._calcTranslateMatrix(),o=a(e,n),h=this._getTransformedDimensions(),s=h.x/2,u=h.y/2;return{tl:t({x:-s,y:-u},o),tr:t({x:s,y:-u},o),bl:t({x:-s,y:u},o),br:t({x:s,y:u},o)}},setCoords:function(n){return this.aCoords=this.calcACoords(),this.lineCoords=this.group?this.aCoords:this.calcLineCoords(),n?this:(this.oCoords=this.calcOCoords(),this._setCornerCoords&&this._setCornerCoords(),this)},_calcRotateMatrix:function(){return i.calcRotateMatrix(this)},_calcTranslateMatrix:function(){var n=this.getCenterPoint();return[1,0,0,1,n.x,n.y]},transformMatrixKey:function(n){var e="_",o="";return!n&&this.group&&(o=this.group.transformMatrixKey(n)+e),o+this.top+e+this.left+e+this.scaleX+e+this.scaleY+e+this.skewX+e+this.skewY+e+this.angle+e+this.originX+e+this.originY+e+this.width+e+this.height+e+this.strokeWidth+this.flipX+this.flipY},calcTransformMatrix:function(n){var e=this.calcOwnMatrix();if(n||!this.group)return e;var o=this.transformMatrixKey(n),h=this.matrixCache||(this.matrixCache={});return h.key===o?h.value:(this.group&&(e=a(this.group.calcTransformMatrix(!1),e)),h.key=o,h.value=e,e)},calcOwnMatrix:function(){var n=this.transformMatrixKey(!0),e=this.ownMatrixCache||(this.ownMatrixCache={});if(e.key===n)return e.value;var o=this._calcTranslateMatrix(),h={angle:this.angle,translateX:o[4],translateY:o[5],scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY};return e.key=n,e.value=i.composeMatrix(h),e.value},_getNonTransformedDimensions:function(){var n=this.strokeWidth,e=this.width+n,o=this.height+n;return{x:e,y:o}},_getTransformedDimensions:function(n,e){typeof n>"u"&&(n=this.skewX),typeof e>"u"&&(e=this.skewY);var o,h,s,u=n===0&&e===0;if(this.strokeUniform?(h=this.width,s=this.height):(o=this._getNonTransformedDimensions(),h=o.x,s=o.y),u)return this._finalizeDimensions(h*this.scaleX,s*this.scaleY);var d=i.sizeAfterTransform(h,s,{scaleX:this.scaleX,scaleY:this.scaleY,skewX:n,skewY:e});return this._finalizeDimensions(d.x,d.y)},_finalizeDimensions:function(n,e){return this.strokeUniform?{x:n+this.strokeWidth,y:e+this.strokeWidth}:{x:n,y:e}},_calculateCurrentDimensions:function(){var n=this.getViewportTransform(),e=this._getTransformedDimensions(),o=t(e,n,!0);return o.scalarAdd(2*this.padding)}})})(),r.util.object.extend(r.Object.prototype,{sendToBack:function(){return this.group?r.StaticCanvas.prototype.sendToBack.call(this.group,this):this.canvas&&this.canvas.sendToBack(this),this},bringToFront:function(){return this.group?r.StaticCanvas.prototype.bringToFront.call(this.group,this):this.canvas&&this.canvas.bringToFront(this),this},sendBackwards:function(c){return this.group?r.StaticCanvas.prototype.sendBackwards.call(this.group,this,c):this.canvas&&this.canvas.sendBackwards(this,c),this},bringForward:function(c){return this.group?r.StaticCanvas.prototype.bringForward.call(this.group,this,c):this.canvas&&this.canvas.bringForward(this,c),this},moveTo:function(c){return this.group&&this.group.type!=="activeSelection"?r.StaticCanvas.prototype.moveTo.call(this.group,this,c):this.canvas&&this.canvas.moveTo(this,c),this}}),(function(){function c(l,a){if(a){if(a.toLive)return l+": url(#SVGID_"+a.id+"); ";var t=new r.Color(a),n=l+": "+t.toRgb()+"; ",e=t.getAlpha();return e!==1&&(n+=l+"-opacity: "+e.toString()+"; "),n}else return l+": none; "}var i=r.util.toFixed;r.util.object.extend(r.Object.prototype,{getSvgStyles:function(l){var a=this.fillRule?this.fillRule:"nonzero",t=this.strokeWidth?this.strokeWidth:"0",n=this.strokeDashArray?this.strokeDashArray.join(" "):"none",e=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",h=this.strokeLineJoin?this.strokeLineJoin:"miter",s=this.strokeMiterLimit?this.strokeMiterLimit:"4",u=typeof this.opacity<"u"?this.opacity:"1",d=this.visible?"":" visibility: hidden;",m=l?"":this.getSvgFilter(),p=c("fill",this.fill),v=c("stroke",this.stroke);return[v,"stroke-width: ",t,"; ","stroke-dasharray: ",n,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",e,"; ","stroke-linejoin: ",h,"; ","stroke-miterlimit: ",s,"; ",p,"fill-rule: ",a,"; ","opacity: ",u,";",m,d].join("")},getSvgSpanStyles:function(l,a){var t="; ",e=l.fontFamily?"font-family: "+(l.fontFamily.indexOf("'")===-1&&l.fontFamily.indexOf('"')===-1?"'"+l.fontFamily+"'":l.fontFamily)+t:"",n=l.strokeWidth?"stroke-width: "+l.strokeWidth+t:"",e=e,o=l.fontSize?"font-size: "+l.fontSize+"px"+t:"",h=l.fontStyle?"font-style: "+l.fontStyle+t:"",s=l.fontWeight?"font-weight: "+l.fontWeight+t:"",u=l.fill?c("fill",l.fill):"",d=l.stroke?c("stroke",l.stroke):"",m=this.getSvgTextDecoration(l),p=l.deltaY?"baseline-shift: "+-l.deltaY+"; ":"";return m&&(m="text-decoration: "+m+t),[d,n,e,o,h,s,m,u,p,a?"white-space: pre; ":""].join("")},getSvgTextDecoration:function(l){return["overline","underline","line-through"].filter(function(a){return l[a.replace("-","")]}).join(" ")},getSvgFilter:function(){return this.shadow?"filter: url(#SVGID_"+this.shadow.id+");":""},getSvgCommons:function(){return[this.id?'id="'+this.id+'" ':"",this.clipPath?'clip-path="url(#'+this.clipPath.clipPathId+')" ':""].join("")},getSvgTransform:function(l,a){var t=l?this.calcTransformMatrix():this.calcOwnMatrix(),n='transform="'+r.util.matrixToSVG(t);return n+(a||"")+'" '},_setSVGBg:function(l){if(this.backgroundColor){var a=r.Object.NUM_FRACTION_DIGITS;l.push(" <rect ",this._getFillAttributes(this.backgroundColor),' x="',i(-this.width/2,a),'" y="',i(-this.height/2,a),'" width="',i(this.width,a),'" height="',i(this.height,a),`"></rect>
44
+ `)}},toSVG:function(l){return this._createBaseSVGMarkup(this._toSVG(l),{reviver:l})},toClipPathSVG:function(l){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(l),{reviver:l})},_createBaseClipPathSVGMarkup:function(l,a){a=a||{};var t=a.reviver,n=a.additionalTransform||"",e=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(""),o=l.indexOf("COMMON_PARTS");return l[o]=e,t?t(l.join("")):l.join("")},_createBaseSVGMarkup:function(l,a){a=a||{};var t=a.noStyle,n=a.reviver,e=t?"":'style="'+this.getSvgStyles()+'" ',o=a.withShadow?'style="'+this.getSvgFilter()+'" ':"",h=this.clipPath,s=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",u=h&&h.absolutePositioned,d=this.stroke,m=this.fill,p=this.shadow,v,b=[],S,E=l.indexOf("COMMON_PARTS"),F=a.additionalTransform;return h&&(h.clipPathId="CLIPPATH_"+r.Object.__uid++,S='<clipPath id="'+h.clipPathId+`" >
45
45
  `+h.toClipPathSVG(n)+`</clipPath>
46
46
  `),u&&b.push("<g ",o,this.getSvgCommons(),` >
47
47
  `),b.push("<g ",this.getSvgTransform(!1),u?"":o+this.getSvgCommons(),` >
48
- `),v=[e,s,t?"":this.addPaintOrder()," ",F?'transform="'+F+'" ':""].join(""),l[E]=v,m&&m.toLive&&b.push(m.toSVG(this)),d&&d.toLive&&b.push(d.toSVG(this)),g&&b.push(g.toSVG(this)),h&&b.push(S),b.push(l.join("")),b.push(`</g>
48
+ `),v=[e,s,t?"":this.addPaintOrder()," ",F?'transform="'+F+'" ':""].join(""),l[E]=v,m&&m.toLive&&b.push(m.toSVG(this)),d&&d.toLive&&b.push(d.toSVG(this)),p&&b.push(p.toSVG(this)),h&&b.push(S),b.push(l.join("")),b.push(`</g>
49
49
  `),u&&b.push(`</g>
50
50
  `),n?n(b.join("")):b.join("")},addPaintOrder:function(){return this.paintFirst!=="fill"?' paint-order="'+this.paintFirst+'" ':""}})})(),(function(){var c=r.util.object.extend,i="stateProperties";function l(t,n,e){var o={},h=!0;e.forEach(function(s){o[s]=t[s]}),c(t[n],o,h)}function a(t,n,e){if(t===n)return!0;if(Array.isArray(t)){if(!Array.isArray(n)||t.length!==n.length)return!1;for(var o=0,h=t.length;o<h;o++)if(!a(t[o],n[o]))return!1;return!0}else if(t&&typeof t=="object"){var s=Object.keys(t),u;if(!n||typeof n!="object"||!e&&s.length!==Object.keys(n).length)return!1;for(var o=0,h=s.length;o<h;o++)if(u=s[o],!(u==="canvas"||u==="group")&&!a(t[u],n[u]))return!1;return!0}}r.util.object.extend(r.Object.prototype,{hasStateChanged:function(t){t=t||i;var n="_"+t;return Object.keys(this[n]).length<this[t].length?!0:!a(this[n],this,!0)},saveState:function(t){var n=t&&t.propertySet||i,e="_"+n;return this[e]?(l(this,e,this[n]),t&&t.stateProperties&&l(this,e,t.stateProperties),this):this.setupState(t)},setupState:function(t){t=t||{};var n=t.propertySet||i;return t.propertySet=n,this["_"+n]={},this.saveState(t),this}})})(),(function(){var c=r.util.degreesToRadians;r.util.object.extend(r.Object.prototype,{_findTargetCorner:function(i,l){if(!this.hasControls||this.group||!this.canvas||this.canvas._activeObject!==this)return!1;var a=i.x,t=i.y,n,e,o=Object.keys(this.oCoords),h=o.length-1,s;for(this.__corner=0;h>=0;h--)if(s=o[h],!!this.isControlVisible(s)&&(e=this._getImageLines(l?this.oCoords[s].touchCorner:this.oCoords[s].corner),n=this._findCrossPoints({x:a,y:t},e),n!==0&&n%2===1))return this.__corner=s,s;return!1},forEachControl:function(i){for(var l in this.controls)i(this.controls[l],l,this)},_setCornerCoords:function(){var i=this.oCoords;for(var l in i){var a=this.controls[l];i[l].corner=a.calcCornerCoords(this.angle,this.cornerSize,i[l].x,i[l].y,!1),i[l].touchCorner=a.calcCornerCoords(this.angle,this.touchCornerSize,i[l].x,i[l].y,!0)}},drawSelectionBackground:function(i){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;i.save();var l=this.getCenterPoint(),a=this._calculateCurrentDimensions(),t=this.canvas.viewportTransform;return i.translate(l.x,l.y),i.scale(1/t[0],1/t[3]),i.rotate(c(this.angle)),i.fillStyle=this.selectionBackgroundColor,i.fillRect(-a.x/2,-a.y/2,a.x,a.y),i.restore(),this},drawBorders:function(i,l){l=l||{};var a=this._calculateCurrentDimensions(),t=this.borderScaleFactor,n=a.x+t,e=a.y+t,o=typeof l.hasControls<"u"?l.hasControls:this.hasControls,h=!1;return i.save(),i.strokeStyle=l.borderColor||this.borderColor,this._setLineDash(i,l.borderDashArray||this.borderDashArray),i.strokeRect(-n/2,-e/2,n,e),o&&(i.beginPath(),this.forEachControl(function(s,u,d){s.withConnection&&s.getVisibility(d,u)&&(h=!0,i.moveTo(s.x*n,s.y*e),i.lineTo(s.x*n+s.offsetX,s.y*e+s.offsetY))}),h&&i.stroke()),i.restore(),this},drawBordersInGroup:function(i,l,a){a=a||{};var t=r.util.sizeAfterTransform(this.width,this.height,l),n=this.strokeWidth,e=this.strokeUniform,o=this.borderScaleFactor,h=t.x+n*(e?this.canvas.getZoom():l.scaleX)+o,s=t.y+n*(e?this.canvas.getZoom():l.scaleY)+o;return i.save(),this._setLineDash(i,a.borderDashArray||this.borderDashArray),i.strokeStyle=a.borderColor||this.borderColor,i.strokeRect(-h/2,-s/2,h,s),i.restore(),this},drawControls:function(i,l){l=l||{},i.save();var a=this.canvas.getRetinaScaling(),t,n;return i.setTransform(a,0,0,a,0,0),i.strokeStyle=i.fillStyle=l.cornerColor||this.cornerColor,this.transparentCorners||(i.strokeStyle=l.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(i,l.cornerDashArray||this.cornerDashArray),this.setCoords(),this.group&&(t=this.group.calcTransformMatrix()),this.forEachControl(function(e,o,h){n=h.oCoords[o],e.getVisibility(h,o)&&(t&&(n=r.util.transformPoint(n,t)),e.render(i,n.x,n.y,l,h))}),i.restore(),this},isControlVisible:function(i){return this.controls[i]&&this.controls[i].getVisibility(this,i)},setControlVisible:function(i,l){return this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[i]=l,this},setControlsVisibility:function(i){i||(i={});for(var l in i)this.setControlVisible(l,i[l]);return this},onDeselect:function(){},onSelect:function(){}})})(),r.util.object.extend(r.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(c,i){i=i||{};var l=function(){},a=i.onComplete||l,t=i.onChange||l,n=this;return r.util.animate({target:this,startValue:c.left,endValue:this.getCenterPoint().x,duration:this.FX_DURATION,onChange:function(e){c.set("left",e),n.requestRenderAll(),t()},onComplete:function(){c.setCoords(),a()}})},fxCenterObjectV:function(c,i){i=i||{};var l=function(){},a=i.onComplete||l,t=i.onChange||l,n=this;return r.util.animate({target:this,startValue:c.top,endValue:this.getCenterPoint().y,duration:this.FX_DURATION,onChange:function(e){c.set("top",e),n.requestRenderAll(),t()},onComplete:function(){c.setCoords(),a()}})},fxRemove:function(c,i){i=i||{};var l=function(){},a=i.onComplete||l,t=i.onChange||l,n=this;return r.util.animate({target:this,startValue:c.opacity,endValue:0,duration:this.FX_DURATION,onChange:function(e){c.set("opacity",e),n.requestRenderAll(),t()},onComplete:function(){n.remove(c),a()}})}}),r.util.object.extend(r.Object.prototype,{animate:function(){if(arguments[0]&&typeof arguments[0]=="object"){var c=[],i,l,a=[];for(i in arguments[0])c.push(i);for(var t=0,n=c.length;t<n;t++)i=c[t],l=t!==n-1,a.push(this._animate(i,arguments[0][i],arguments[1],l));return a}else return this._animate.apply(this,arguments)},_animate:function(c,i,l,a){var t=this,n;i=i.toString(),l?l=r.util.object.clone(l):l={},~c.indexOf(".")&&(n=c.split("."));var e=t.colorProperties.indexOf(c)>-1||n&&t.colorProperties.indexOf(n[1])>-1,o=n?this.get(n[0])[n[1]]:this.get(c);"from"in l||(l.from=o),e||(~i.indexOf("=")?i=o+parseFloat(i.replace("=","")):i=parseFloat(i));var h={target:this,startValue:l.from,endValue:i,byValue:l.by,easing:l.easing,duration:l.duration,abort:l.abort&&function(s,u,d){return l.abort.call(t,s,u,d)},onChange:function(s,u,d){n?t[n[0]][n[1]]=s:t.set(c,s),!a&&l.onChange&&l.onChange(s,u,d)},onComplete:function(s,u,d){a||(t.setCoords(),l.onComplete&&l.onComplete(s,u,d))}};return e?r.util.animateColor(h.startValue,h.endValue,h.duration,h):r.util.animate(h)}}),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.object.extend,a=i.util.object.clone,t={x1:1,x2:1,y1:1,y2:1};if(i.Line){i.warn("fabric.Line is already defined");return}i.Line=i.util.createClass(i.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:i.Object.prototype.cacheProperties.concat("x1","x2","y1","y2"),initialize:function(e,o){e||(e=[0,0,0,0]),this.callSuper("initialize",o),this.set("x1",e[0]),this.set("y1",e[1]),this.set("x2",e[2]),this.set("y2",e[3]),this._setWidthHeight(o)},_setWidthHeight:function(e){e||(e={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in e?e.left:this._getLeftToOriginX(),this.top="top"in e?e.top:this._getTopToOriginY()},_set:function(e,o){return this.callSuper("_set",e,o),typeof t[e]<"u"&&this._setWidthHeight(),this},_getLeftToOriginX:n({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:n({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(e){e.beginPath();var o=this.calcLinePoints();e.moveTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineWidth=this.strokeWidth;var h=e.strokeStyle;e.strokeStyle=this.stroke||e.fillStyle,this.stroke&&this._renderStroke(e),e.strokeStyle=h},_findCenterFromElement:function(){return{x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2}},toObject:function(e){return l(this.callSuper("toObject",e),this.calcLinePoints())},_getNonTransformedDimensions:function(){var e=this.callSuper("_getNonTransformedDimensions");return this.strokeLineCap==="butt"&&(this.width===0&&(e.y-=this.strokeWidth),this.height===0&&(e.x-=this.strokeWidth)),e},calcLinePoints:function(){var e=this.x1<=this.x2?-1:1,o=this.y1<=this.y2?-1:1,h=e*this.width*.5,s=o*this.height*.5,u=e*this.width*-.5,d=o*this.height*-.5;return{x1:h,x2:u,y1:s,y2:d}},_toSVG:function(){var e=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="',e.x1,'" y1="',e.y1,'" x2="',e.x2,'" y2="',e.y2,`" />
51
- `]}}),i.Line.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),i.Line.fromElement=function(e,o,h){h=h||{};var s=i.parseAttributes(e,i.Line.ATTRIBUTE_NAMES),u=[s.x1||0,s.y1||0,s.x2||0,s.y2||0];o(new i.Line(u,l(s,h)))},i.Line.fromObject=function(e,o){function h(u){delete u.points,o&&o(u)}var s=a(e,!0);s.points=[e.x1,e.y1,e.x2,e.y2],i.Object._fromObject("Line",s,h,"points")};function n(e,o){var h=e.origin,s=e.axis1,u=e.axis2,d=e.dimension,m=o.nearest,g=o.center,v=o.farthest;return function(){switch(this.get(h)){case m:return Math.min(this.get(s),this.get(u));case g:return Math.min(this.get(s),this.get(u))+.5*this.get(d);case v:return Math.max(this.get(s),this.get(u))}}}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.degreesToRadians;if(i.Circle){i.warn("fabric.Circle is already defined.");return}i.Circle=i.util.createClass(i.Object,{type:"circle",radius:0,startAngle:0,endAngle:360,cacheProperties:i.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(t,n){return this.callSuper("_set",t,n),t==="radius"&&this.setRadius(n),this},toObject:function(t){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(t))},_toSVG:function(){var t,n=0,e=0,o=(this.endAngle-this.startAngle)%360;if(o===0)t=["<circle ","COMMON_PARTS",'cx="'+n+'" cy="'+e+'" ','r="',this.radius,`" />
52
- `];else{var h=l(this.startAngle),s=l(this.endAngle),u=this.radius,d=i.util.cos(h)*u,m=i.util.sin(h)*u,g=i.util.cos(s)*u,v=i.util.sin(s)*u,b=o>180?"1":"0";t=['<path d="M '+d+" "+m," A "+u+" "+u," 0 ",+b+" 1"," "+g+" "+v,'" ',"COMMON_PARTS",` />
51
+ `]}}),i.Line.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),i.Line.fromElement=function(e,o,h){h=h||{};var s=i.parseAttributes(e,i.Line.ATTRIBUTE_NAMES),u=[s.x1||0,s.y1||0,s.x2||0,s.y2||0];o(new i.Line(u,l(s,h)))},i.Line.fromObject=function(e,o){function h(u){delete u.points,o&&o(u)}var s=a(e,!0);s.points=[e.x1,e.y1,e.x2,e.y2],i.Object._fromObject("Line",s,h,"points")};function n(e,o){var h=e.origin,s=e.axis1,u=e.axis2,d=e.dimension,m=o.nearest,p=o.center,v=o.farthest;return function(){switch(this.get(h)){case m:return Math.min(this.get(s),this.get(u));case p:return Math.min(this.get(s),this.get(u))+.5*this.get(d);case v:return Math.max(this.get(s),this.get(u))}}}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.degreesToRadians;if(i.Circle){i.warn("fabric.Circle is already defined.");return}i.Circle=i.util.createClass(i.Object,{type:"circle",radius:0,startAngle:0,endAngle:360,cacheProperties:i.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(t,n){return this.callSuper("_set",t,n),t==="radius"&&this.setRadius(n),this},toObject:function(t){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(t))},_toSVG:function(){var t,n=0,e=0,o=(this.endAngle-this.startAngle)%360;if(o===0)t=["<circle ","COMMON_PARTS",'cx="'+n+'" cy="'+e+'" ','r="',this.radius,`" />
52
+ `];else{var h=l(this.startAngle),s=l(this.endAngle),u=this.radius,d=i.util.cos(h)*u,m=i.util.sin(h)*u,p=i.util.cos(s)*u,v=i.util.sin(s)*u,b=o>180?"1":"0";t=['<path d="M '+d+" "+m," A "+u+" "+u," 0 ",+b+" 1"," "+p+" "+v,'" ',"COMMON_PARTS",` />
53
53
  `]}return t},_render:function(t){t.beginPath(),t.arc(0,0,this.radius,l(this.startAngle),l(this.endAngle),!1),this._renderPaintInOrder(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){return this.radius=t,this.set("width",t*2).set("height",t*2)}}),i.Circle.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),i.Circle.fromElement=function(t,n){var e=i.parseAttributes(t,i.Circle.ATTRIBUTE_NAMES);if(!a(e))throw new Error("value of `r` attribute is required and can not be negative");e.left=(e.left||0)-e.radius,e.top=(e.top||0)-e.radius,n(new i.Circle(e))};function a(t){return"radius"in t&&t.radius>=0}i.Circle.fromObject=function(t,n){i.Object._fromObject("Circle",t,n)}})(f),(function(c){var i=c.fabric||(c.fabric={});if(i.Triangle){i.warn("fabric.Triangle is already defined");return}i.Triangle=i.util.createClass(i.Object,{type:"triangle",width:100,height:100,_render:function(l){var a=this.width/2,t=this.height/2;l.beginPath(),l.moveTo(-a,t),l.lineTo(0,-t),l.lineTo(a,t),l.closePath(),this._renderPaintInOrder(l)},_toSVG:function(){var l=this.width/2,a=this.height/2,t=[-l+" "+a,"0 "+-a,l+" "+a].join(",");return["<polygon ","COMMON_PARTS",'points="',t,'" />']}}),i.Triangle.fromObject=function(l,a){return i.Object._fromObject("Triangle",l,a)}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=Math.PI*2;if(i.Ellipse){i.warn("fabric.Ellipse is already defined.");return}i.Ellipse=i.util.createClass(i.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:i.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(a){this.callSuper("initialize",a),this.set("rx",a&&a.rx||0),this.set("ry",a&&a.ry||0)},_set:function(a,t){switch(this.callSuper("_set",a,t),a){case"rx":this.rx=t,this.set("width",t*2);break;case"ry":this.ry=t,this.set("height",t*2);break}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(a){return this.callSuper("toObject",["rx","ry"].concat(a))},_toSVG:function(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" ','rx="',this.rx,'" ry="',this.ry,`" />
54
54
  `]},_render:function(a){a.beginPath(),a.save(),a.transform(1,0,0,this.ry/this.rx,0,0),a.arc(0,0,this.rx,0,l,!1),a.restore(),this._renderPaintInOrder(a)}}),i.Ellipse.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),i.Ellipse.fromElement=function(a,t){var n=i.parseAttributes(a,i.Ellipse.ATTRIBUTE_NAMES);n.left=(n.left||0)-n.rx,n.top=(n.top||0)-n.ry,t(new i.Ellipse(n))},i.Ellipse.fromObject=function(a,t){i.Object._fromObject("Ellipse",a,t)}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.object.extend;if(i.Rect){i.warn("fabric.Rect is already defined");return}i.Rect=i.util.createClass(i.Object,{stateProperties:i.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:i.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(a){this.callSuper("initialize",a),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(a){var t=this.rx?Math.min(this.rx,this.width/2):0,n=this.ry?Math.min(this.ry,this.height/2):0,e=this.width,o=this.height,h=-this.width/2,s=-this.height/2,u=t!==0||n!==0,d=1-.5522847498;a.beginPath(),a.moveTo(h+t,s),a.lineTo(h+e-t,s),u&&a.bezierCurveTo(h+e-d*t,s,h+e,s+d*n,h+e,s+n),a.lineTo(h+e,s+o-n),u&&a.bezierCurveTo(h+e,s+o-d*n,h+e-d*t,s+o,h+e-t,s+o),a.lineTo(h+t,s+o),u&&a.bezierCurveTo(h+d*t,s+o,h,s+o-d*n,h,s+o-n),a.lineTo(h,s+n),u&&a.bezierCurveTo(h,s+d*n,h+d*t,s,h+t,s),a.closePath(),this._renderPaintInOrder(a)},toObject:function(a){return this.callSuper("toObject",["rx","ry"].concat(a))},_toSVG:function(){var a=-this.width/2,t=-this.height/2;return["<rect ","COMMON_PARTS",'x="',a,'" y="',t,'" rx="',this.rx,'" ry="',this.ry,'" width="',this.width,'" height="',this.height,`" />
55
- `]}}),i.Rect.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),i.Rect.fromElement=function(a,t,n){if(!a)return t(null);n=n||{};var e=i.parseAttributes(a,i.Rect.ATTRIBUTE_NAMES);e.left=e.left||0,e.top=e.top||0,e.height=e.height||0,e.width=e.width||0;var o=new i.Rect(l(n?i.util.object.clone(n):{},e));o.visible=o.visible&&o.width>0&&o.height>0,t(o)},i.Rect.fromObject=function(a,t){return i.Object._fromObject("Rect",a,t)}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.object.extend,a=i.util.array.min,t=i.util.array.max,n=i.util.toFixed,e=i.util.projectStrokeOnPoints;if(i.Polyline){i.warn("fabric.Polyline is already defined");return}i.Polyline=i.util.createClass(i.Object,{type:"polyline",points:null,exactBoundingBox:!1,cacheProperties:i.Object.prototype.cacheProperties.concat("points"),initialize:function(o,h){h=h||{},this.points=o||[],this.callSuper("initialize",h),this._setPositionDimensions(h)},_projectStrokeOnPoints:function(){return e(this.points,this,!0)},_setPositionDimensions:function(o){var h=this._calcDimensions(o),s,u=this.exactBoundingBox?this.strokeWidth:0;this.width=h.width-u,this.height=h.height-u,o.fromSVG||(s=this.translateToGivenOrigin({x:h.left-this.strokeWidth/2+u/2,y:h.top-this.strokeWidth/2+u/2},"left","top",this.originX,this.originY)),typeof o.left>"u"&&(this.left=o.fromSVG?h.left:s.x),typeof o.top>"u"&&(this.top=o.fromSVG?h.top:s.y),this.pathOffset={x:h.left+this.width/2+u/2,y:h.top+this.height/2+u/2}},_calcDimensions:function(){var o=this.exactBoundingBox?this._projectStrokeOnPoints():this.points,h=a(o,"x")||0,s=a(o,"y")||0,u=t(o,"x")||0,d=t(o,"y")||0,m=u-h,g=d-s;return{left:h,top:s,width:m,height:g}},toObject:function(o){return l(this.callSuper("toObject",o),{points:this.points.concat()})},_toSVG:function(){for(var o=[],h=this.pathOffset.x,s=this.pathOffset.y,u=i.Object.NUM_FRACTION_DIGITS,d=0,m=this.points.length;d<m;d++)o.push(n(this.points[d].x-h,u),",",n(this.points[d].y-s,u)," ");return["<"+this.type+" ","COMMON_PARTS",'points="',o.join(""),`" />
56
- `]},commonRender:function(o){var h,s=this.points.length,u=this.pathOffset.x,d=this.pathOffset.y;if(!s||isNaN(this.points[s-1].y))return!1;o.beginPath(),o.moveTo(this.points[0].x-u,this.points[0].y-d);for(var m=0;m<s;m++)h=this.points[m],o.lineTo(h.x-u,h.y-d);return!0},_render:function(o){this.commonRender(o)&&this._renderPaintInOrder(o)},complexity:function(){return this.get("points").length}}),i.Polyline.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat(),i.Polyline.fromElementGenerator=function(o){return function(h,s,u){if(!h)return s(null);u||(u={});var d=i.parsePointsAttribute(h.getAttribute("points")),m=i.parseAttributes(h,i[o].ATTRIBUTE_NAMES);m.fromSVG=!0,s(new i[o](d,l(m,u)))}},i.Polyline.fromElement=i.Polyline.fromElementGenerator("Polyline"),i.Polyline.fromObject=function(o,h){return i.Object._fromObject("Polyline",o,h,"points")}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.projectStrokeOnPoints;if(i.Polygon){i.warn("fabric.Polygon is already defined");return}i.Polygon=i.util.createClass(i.Polyline,{type:"polygon",_projectStrokeOnPoints:function(){return l(this.points,this)},_render:function(a){this.commonRender(a)&&(a.closePath(),this._renderPaintInOrder(a))}}),i.Polygon.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat(),i.Polygon.fromElement=i.Polyline.fromElementGenerator("Polygon"),i.Polygon.fromObject=function(a,t){i.Object._fromObject("Polygon",a,t,"points")}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.array.min,a=i.util.array.max,t=i.util.object.extend,n=i.util.object.clone,e=i.util.toFixed;if(i.Path){i.warn("fabric.Path is already defined");return}i.Path=i.util.createClass(i.Object,{type:"path",path:null,cacheProperties:i.Object.prototype.cacheProperties.concat("path","fillRule"),stateProperties:i.Object.prototype.stateProperties.concat("path"),initialize:function(o,h){h=n(h||{}),delete h.path,this.callSuper("initialize",h),this._setPath(o||[],h)},_setPath:function(o,h){this.path=i.util.makePathSimpler(Array.isArray(o)?o:i.util.parsePath(o)),i.Polyline.prototype._setPositionDimensions.call(this,h||{})},_renderPathCommands:function(o){var h,s=0,u=0,d=0,m=0,g=0,v=0,b=-this.pathOffset.x,S=-this.pathOffset.y;o.beginPath();for(var E=0,F=this.path.length;E<F;++E)switch(h=this.path[E],h[0]){case"L":d=h[1],m=h[2],o.lineTo(d+b,m+S);break;case"M":d=h[1],m=h[2],s=d,u=m,o.moveTo(d+b,m+S);break;case"C":d=h[5],m=h[6],g=h[3],v=h[4],o.bezierCurveTo(h[1]+b,h[2]+S,g+b,v+S,d+b,m+S);break;case"Q":o.quadraticCurveTo(h[1]+b,h[2]+S,h[3]+b,h[4]+S),d=h[3],m=h[4],g=h[1],v=h[2];break;case"z":case"Z":d=s,m=u,o.closePath();break}},_render:function(o){this._renderPathCommands(o),this._renderPaintInOrder(o)},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(o){return t(this.callSuper("toObject",o),{path:this.path.map(function(h){return h.slice()})})},toDatalessObject:function(o){var h=this.toObject(["sourcePath"].concat(o));return h.sourcePath&&delete h.path,h},_toSVG:function(){var o=i.util.joinPath(this.path);return["<path ","COMMON_PARTS",'d="',o,'" stroke-linecap="round" ',`/>
57
- `]},_getOffsetTransform:function(){var o=i.Object.NUM_FRACTION_DIGITS;return" translate("+e(-this.pathOffset.x,o)+", "+e(-this.pathOffset.y,o)+")"},toClipPathSVG:function(o){var h=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:o,additionalTransform:h})},toSVG:function(o){var h=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:o,additionalTransform:h})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var o=[],h=[],s,u=0,d=0,m=0,g=0,v,b=0,S=this.path.length;b<S;++b){switch(s=this.path[b],s[0]){case"L":m=s[1],g=s[2],v=[];break;case"M":m=s[1],g=s[2],u=m,d=g,v=[];break;case"C":v=i.util.getBoundsOfCurve(m,g,s[1],s[2],s[3],s[4],s[5],s[6]),m=s[5],g=s[6];break;case"Q":v=i.util.getBoundsOfCurve(m,g,s[1],s[2],s[1],s[2],s[3],s[4]),m=s[3],g=s[4];break;case"z":case"Z":m=u,g=d;break}v.forEach(function(K){o.push(K.x),h.push(K.y)}),o.push(m),h.push(g)}var E=l(o)||0,F=l(h)||0,R=a(o)||0,z=a(h)||0,q=R-E,Z=z-F;return{left:E,top:F,width:q,height:Z}}}),i.Path.fromObject=function(o,h){if(typeof o.sourcePath=="string"){var s=o.sourcePath;i.loadSVGFromURL(s,function(u){var d=u[0];d.setOptions(o),o.clipPath?i.util.enlivenObjects([o.clipPath],function(m){d.clipPath=m[0],h&&h(d)}):h&&h(d)})}else i.Object._fromObject("Path",o,h,"path")},i.Path.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat(["d"]),i.Path.fromElement=function(o,h,s){var u=i.parseAttributes(o,i.Path.ATTRIBUTE_NAMES);u.fromSVG=!0,h(new i.Path(u.d,t(u,s)))}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.array.min,a=i.util.array.max;i.Group||(i.Group=i.util.createClass(i.Object,i.Collection,{type:"group",strokeWidth:0,subTargetCheck:!1,cacheProperties:[],useSetOnGroup:!1,initialize:function(t,n,e){n=n||{},this._objects=[],e&&this.callSuper("initialize",n),this._objects=t||[];for(var o=this._objects.length;o--;)this._objects[o].group=this;if(e)this._updateObjectsACoords();else{var h=n&&n.centerPoint;n.originX!==void 0&&(this.originX=n.originX),n.originY!==void 0&&(this.originY=n.originY),h||this._calcBounds(),this._updateObjectsCoords(h),delete n.centerPoint,this.callSuper("initialize",n)}this.setCoords()},_updateObjectsACoords:function(){for(var t=!0,n=this._objects.length;n--;)this._objects[n].setCoords(t)},_updateObjectsCoords:function(n){for(var n=n||this.getCenterPoint(),e=this._objects.length;e--;)this._updateObjectCoords(this._objects[e],n)},_updateObjectCoords:function(t,n){var e=t.left,o=t.top,h=!0;t.set({left:e-n.x,top:o-n.y}),t.group=this,t.setCoords(h)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},addWithUpdate:function(t){var n=!!this.group;return this._restoreObjectsState(),i.util.resetObjectTransform(this),t&&(n&&i.util.removeTransformFromObject(t,this.group.calcTransformMatrix()),this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.dirty=!0,n?this.group.addWithUpdate():this.setCoords(),this},removeWithUpdate:function(t){return this._restoreObjectsState(),i.util.resetObjectTransform(this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(t){this.dirty=!0,t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){this.dirty=!0,delete t.group},_set:function(t,n){var e=this._objects.length;if(this.useSetOnGroup)for(;e--;)this._objects[e].setOnGroup(t,n);if(t==="canvas")for(;e--;)this._objects[e]._set(t,n);i.Object.prototype._set.call(this,t,n)},toObject:function(t){var n=this.includeDefaultValues,e=this._objects.filter(function(h){return!h.excludeFromExport}).map(function(h){var s=h.includeDefaultValues;h.includeDefaultValues=n;var u=h.toObject(t);return h.includeDefaultValues=s,u}),o=i.Object.prototype.toObject.call(this,t);return o.objects=e,o},toDatalessObject:function(t){var n,e=this.sourcePath;if(e)n=e;else{var o=this.includeDefaultValues;n=this._objects.map(function(s){var u=s.includeDefaultValues;s.includeDefaultValues=o;var d=s.toDatalessObject(t);return s.includeDefaultValues=u,d})}var h=i.Object.prototype.toDatalessObject.call(this,t);return h.objects=n,h},render:function(t){this._transformDone=!0,this.callSuper("render",t),this._transformDone=!1},shouldCache:function(){var t=i.Object.prototype.shouldCache.call(this);if(t){for(var n=0,e=this._objects.length;n<e;n++)if(this._objects[n].willDrawShadow())return this.ownCaching=!1,!1}return t},willDrawShadow:function(){if(i.Object.prototype.willDrawShadow.call(this))return!0;for(var t=0,n=this._objects.length;t<n;t++)if(this._objects[t].willDrawShadow())return!0;return!1},isOnACache:function(){return this.ownCaching||this.group&&this.group.isOnACache()},drawObject:function(t){for(var n=0,e=this._objects.length;n<e;n++)this._objects[n].render(t);this._drawClipPath(t,this.clipPath)},isCacheDirty:function(t){if(this.callSuper("isCacheDirty",t))return!0;if(!this.statefullCache)return!1;for(var n=0,e=this._objects.length;n<e;n++)if(this._objects[n].isCacheDirty(!0)){if(this._cacheCanvas){var o=this.cacheWidth/this.zoomX,h=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-o/2,-h/2,o,h)}return!0}return!1},_restoreObjectsState:function(){var t=this.calcOwnMatrix();return this._objects.forEach(function(n){i.util.addTransformToObject(n,t),delete n.group,n.setCoords()}),this},destroy:function(){return this._objects.forEach(function(t){t.set("dirty",!0)}),this._restoreObjectsState()},dispose:function(){this.callSuper("dispose"),this.forEachObject(function(t){t.dispose&&t.dispose()}),this._objects=[]},toActiveSelection:function(){if(this.canvas){var t=this._objects,n=this.canvas;this._objects=[];var e=this.toObject();delete e.objects;var o=new i.ActiveSelection([]);return o.set(e),o.type="activeSelection",n.remove(this),t.forEach(function(h){h.group=o,h.dirty=!0,n.add(h)}),o.canvas=n,o._objects=t,n._activeObject=o,o.setCoords(),o}},ungroupOnCanvas:function(){return this._restoreObjectsState()},setObjectsCoords:function(){var t=!0;return this.forEachObject(function(n){n.setCoords(t)}),this},_calcBounds:function(t){for(var n=[],e=[],o,h,s,u=["tr","br","bl","tl"],d=0,m=this._objects.length,g,v=u.length;d<m;++d){for(o=this._objects[d],s=o.calcACoords(),g=0;g<v;g++)h=u[g],n.push(s[h].x),e.push(s[h].y);o.aCoords=s}this._getBounds(n,e,t)},_getBounds:function(t,n,e){var o=new i.Point(l(t),l(n)),h=new i.Point(a(t),a(n)),s=o.y||0,u=o.x||0,d=h.x-o.x||0,m=h.y-o.y||0;this.width=d,this.height=m,e||this.setPositionByOrigin({x:u,y:s},"left","top")},_toSVG:function(t){for(var n=["<g ","COMMON_PARTS",` >
55
+ `]}}),i.Rect.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),i.Rect.fromElement=function(a,t,n){if(!a)return t(null);n=n||{};var e=i.parseAttributes(a,i.Rect.ATTRIBUTE_NAMES);e.left=e.left||0,e.top=e.top||0,e.height=e.height||0,e.width=e.width||0;var o=new i.Rect(l(n?i.util.object.clone(n):{},e));o.visible=o.visible&&o.width>0&&o.height>0,t(o)},i.Rect.fromObject=function(a,t){return i.Object._fromObject("Rect",a,t)}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.object.extend,a=i.util.array.min,t=i.util.array.max,n=i.util.toFixed,e=i.util.projectStrokeOnPoints;if(i.Polyline){i.warn("fabric.Polyline is already defined");return}i.Polyline=i.util.createClass(i.Object,{type:"polyline",points:null,exactBoundingBox:!1,cacheProperties:i.Object.prototype.cacheProperties.concat("points"),initialize:function(o,h){h=h||{},this.points=o||[],this.callSuper("initialize",h),this._setPositionDimensions(h)},_projectStrokeOnPoints:function(){return e(this.points,this,!0)},_setPositionDimensions:function(o){var h=this._calcDimensions(o),s,u=this.exactBoundingBox?this.strokeWidth:0;this.width=h.width-u,this.height=h.height-u,o.fromSVG||(s=this.translateToGivenOrigin({x:h.left-this.strokeWidth/2+u/2,y:h.top-this.strokeWidth/2+u/2},"left","top",this.originX,this.originY)),typeof o.left>"u"&&(this.left=o.fromSVG?h.left:s.x),typeof o.top>"u"&&(this.top=o.fromSVG?h.top:s.y),this.pathOffset={x:h.left+this.width/2+u/2,y:h.top+this.height/2+u/2}},_calcDimensions:function(){var o=this.exactBoundingBox?this._projectStrokeOnPoints():this.points,h=a(o,"x")||0,s=a(o,"y")||0,u=t(o,"x")||0,d=t(o,"y")||0,m=u-h,p=d-s;return{left:h,top:s,width:m,height:p}},toObject:function(o){return l(this.callSuper("toObject",o),{points:this.points.concat()})},_toSVG:function(){for(var o=[],h=this.pathOffset.x,s=this.pathOffset.y,u=i.Object.NUM_FRACTION_DIGITS,d=0,m=this.points.length;d<m;d++)o.push(n(this.points[d].x-h,u),",",n(this.points[d].y-s,u)," ");return["<"+this.type+" ","COMMON_PARTS",'points="',o.join(""),`" />
56
+ `]},commonRender:function(o){var h,s=this.points.length,u=this.pathOffset.x,d=this.pathOffset.y;if(!s||isNaN(this.points[s-1].y))return!1;o.beginPath(),o.moveTo(this.points[0].x-u,this.points[0].y-d);for(var m=0;m<s;m++)h=this.points[m],o.lineTo(h.x-u,h.y-d);return!0},_render:function(o){this.commonRender(o)&&this._renderPaintInOrder(o)},complexity:function(){return this.get("points").length}}),i.Polyline.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat(),i.Polyline.fromElementGenerator=function(o){return function(h,s,u){if(!h)return s(null);u||(u={});var d=i.parsePointsAttribute(h.getAttribute("points")),m=i.parseAttributes(h,i[o].ATTRIBUTE_NAMES);m.fromSVG=!0,s(new i[o](d,l(m,u)))}},i.Polyline.fromElement=i.Polyline.fromElementGenerator("Polyline"),i.Polyline.fromObject=function(o,h){return i.Object._fromObject("Polyline",o,h,"points")}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.projectStrokeOnPoints;if(i.Polygon){i.warn("fabric.Polygon is already defined");return}i.Polygon=i.util.createClass(i.Polyline,{type:"polygon",_projectStrokeOnPoints:function(){return l(this.points,this)},_render:function(a){this.commonRender(a)&&(a.closePath(),this._renderPaintInOrder(a))}}),i.Polygon.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat(),i.Polygon.fromElement=i.Polyline.fromElementGenerator("Polygon"),i.Polygon.fromObject=function(a,t){i.Object._fromObject("Polygon",a,t,"points")}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.array.min,a=i.util.array.max,t=i.util.object.extend,n=i.util.object.clone,e=i.util.toFixed;if(i.Path){i.warn("fabric.Path is already defined");return}i.Path=i.util.createClass(i.Object,{type:"path",path:null,cacheProperties:i.Object.prototype.cacheProperties.concat("path","fillRule"),stateProperties:i.Object.prototype.stateProperties.concat("path"),initialize:function(o,h){h=n(h||{}),delete h.path,this.callSuper("initialize",h),this._setPath(o||[],h)},_setPath:function(o,h){this.path=i.util.makePathSimpler(Array.isArray(o)?o:i.util.parsePath(o)),i.Polyline.prototype._setPositionDimensions.call(this,h||{})},_renderPathCommands:function(o){var h,s=0,u=0,d=0,m=0,p=0,v=0,b=-this.pathOffset.x,S=-this.pathOffset.y;o.beginPath();for(var E=0,F=this.path.length;E<F;++E)switch(h=this.path[E],h[0]){case"L":d=h[1],m=h[2],o.lineTo(d+b,m+S);break;case"M":d=h[1],m=h[2],s=d,u=m,o.moveTo(d+b,m+S);break;case"C":d=h[5],m=h[6],p=h[3],v=h[4],o.bezierCurveTo(h[1]+b,h[2]+S,p+b,v+S,d+b,m+S);break;case"Q":o.quadraticCurveTo(h[1]+b,h[2]+S,h[3]+b,h[4]+S),d=h[3],m=h[4],p=h[1],v=h[2];break;case"z":case"Z":d=s,m=u,o.closePath();break}},_render:function(o){this._renderPathCommands(o),this._renderPaintInOrder(o)},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(o){return t(this.callSuper("toObject",o),{path:this.path.map(function(h){return h.slice()})})},toDatalessObject:function(o){var h=this.toObject(["sourcePath"].concat(o));return h.sourcePath&&delete h.path,h},_toSVG:function(){var o=i.util.joinPath(this.path);return["<path ","COMMON_PARTS",'d="',o,'" stroke-linecap="round" ',`/>
57
+ `]},_getOffsetTransform:function(){var o=i.Object.NUM_FRACTION_DIGITS;return" translate("+e(-this.pathOffset.x,o)+", "+e(-this.pathOffset.y,o)+")"},toClipPathSVG:function(o){var h=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:o,additionalTransform:h})},toSVG:function(o){var h=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:o,additionalTransform:h})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var o=[],h=[],s,u=0,d=0,m=0,p=0,v,b=0,S=this.path.length;b<S;++b){switch(s=this.path[b],s[0]){case"L":m=s[1],p=s[2],v=[];break;case"M":m=s[1],p=s[2],u=m,d=p,v=[];break;case"C":v=i.util.getBoundsOfCurve(m,p,s[1],s[2],s[3],s[4],s[5],s[6]),m=s[5],p=s[6];break;case"Q":v=i.util.getBoundsOfCurve(m,p,s[1],s[2],s[1],s[2],s[3],s[4]),m=s[3],p=s[4];break;case"z":case"Z":m=u,p=d;break}v.forEach(function(q){o.push(q.x),h.push(q.y)}),o.push(m),h.push(p)}var E=l(o)||0,F=l(h)||0,R=a(o)||0,z=a(h)||0,K=R-E,Z=z-F;return{left:E,top:F,width:K,height:Z}}}),i.Path.fromObject=function(o,h){if(typeof o.sourcePath=="string"){var s=o.sourcePath;i.loadSVGFromURL(s,function(u){var d=u[0];d.setOptions(o),o.clipPath?i.util.enlivenObjects([o.clipPath],function(m){d.clipPath=m[0],h&&h(d)}):h&&h(d)})}else i.Object._fromObject("Path",o,h,"path")},i.Path.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat(["d"]),i.Path.fromElement=function(o,h,s){var u=i.parseAttributes(o,i.Path.ATTRIBUTE_NAMES);u.fromSVG=!0,h(new i.Path(u.d,t(u,s)))}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.array.min,a=i.util.array.max;i.Group||(i.Group=i.util.createClass(i.Object,i.Collection,{type:"group",strokeWidth:0,subTargetCheck:!1,cacheProperties:[],useSetOnGroup:!1,initialize:function(t,n,e){n=n||{},this._objects=[],e&&this.callSuper("initialize",n),this._objects=t||[];for(var o=this._objects.length;o--;)this._objects[o].group=this;if(e)this._updateObjectsACoords();else{var h=n&&n.centerPoint;n.originX!==void 0&&(this.originX=n.originX),n.originY!==void 0&&(this.originY=n.originY),h||this._calcBounds(),this._updateObjectsCoords(h),delete n.centerPoint,this.callSuper("initialize",n)}this.setCoords()},_updateObjectsACoords:function(){for(var t=!0,n=this._objects.length;n--;)this._objects[n].setCoords(t)},_updateObjectsCoords:function(n){for(var n=n||this.getCenterPoint(),e=this._objects.length;e--;)this._updateObjectCoords(this._objects[e],n)},_updateObjectCoords:function(t,n){var e=t.left,o=t.top,h=!0;t.set({left:e-n.x,top:o-n.y}),t.group=this,t.setCoords(h)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},addWithUpdate:function(t){var n=!!this.group;return this._restoreObjectsState(),i.util.resetObjectTransform(this),t&&(n&&i.util.removeTransformFromObject(t,this.group.calcTransformMatrix()),this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.dirty=!0,n?this.group.addWithUpdate():this.setCoords(),this},removeWithUpdate:function(t){return this._restoreObjectsState(),i.util.resetObjectTransform(this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(t){this.dirty=!0,t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){this.dirty=!0,delete t.group},_set:function(t,n){var e=this._objects.length;if(this.useSetOnGroup)for(;e--;)this._objects[e].setOnGroup(t,n);if(t==="canvas")for(;e--;)this._objects[e]._set(t,n);i.Object.prototype._set.call(this,t,n)},toObject:function(t){var n=this.includeDefaultValues,e=this._objects.filter(function(h){return!h.excludeFromExport}).map(function(h){var s=h.includeDefaultValues;h.includeDefaultValues=n;var u=h.toObject(t);return h.includeDefaultValues=s,u}),o=i.Object.prototype.toObject.call(this,t);return o.objects=e,o},toDatalessObject:function(t){var n,e=this.sourcePath;if(e)n=e;else{var o=this.includeDefaultValues;n=this._objects.map(function(s){var u=s.includeDefaultValues;s.includeDefaultValues=o;var d=s.toDatalessObject(t);return s.includeDefaultValues=u,d})}var h=i.Object.prototype.toDatalessObject.call(this,t);return h.objects=n,h},render:function(t){this._transformDone=!0,this.callSuper("render",t),this._transformDone=!1},shouldCache:function(){var t=i.Object.prototype.shouldCache.call(this);if(t){for(var n=0,e=this._objects.length;n<e;n++)if(this._objects[n].willDrawShadow())return this.ownCaching=!1,!1}return t},willDrawShadow:function(){if(i.Object.prototype.willDrawShadow.call(this))return!0;for(var t=0,n=this._objects.length;t<n;t++)if(this._objects[t].willDrawShadow())return!0;return!1},isOnACache:function(){return this.ownCaching||this.group&&this.group.isOnACache()},drawObject:function(t){for(var n=0,e=this._objects.length;n<e;n++)this._objects[n].render(t);this._drawClipPath(t,this.clipPath)},isCacheDirty:function(t){if(this.callSuper("isCacheDirty",t))return!0;if(!this.statefullCache)return!1;for(var n=0,e=this._objects.length;n<e;n++)if(this._objects[n].isCacheDirty(!0)){if(this._cacheCanvas){var o=this.cacheWidth/this.zoomX,h=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-o/2,-h/2,o,h)}return!0}return!1},_restoreObjectsState:function(){var t=this.calcOwnMatrix();return this._objects.forEach(function(n){i.util.addTransformToObject(n,t),delete n.group,n.setCoords()}),this},destroy:function(){return this._objects.forEach(function(t){t.set("dirty",!0)}),this._restoreObjectsState()},dispose:function(){this.callSuper("dispose"),this.forEachObject(function(t){t.dispose&&t.dispose()}),this._objects=[]},toActiveSelection:function(){if(this.canvas){var t=this._objects,n=this.canvas;this._objects=[];var e=this.toObject();delete e.objects;var o=new i.ActiveSelection([]);return o.set(e),o.type="activeSelection",n.remove(this),t.forEach(function(h){h.group=o,h.dirty=!0,n.add(h)}),o.canvas=n,o._objects=t,n._activeObject=o,o.setCoords(),o}},ungroupOnCanvas:function(){return this._restoreObjectsState()},setObjectsCoords:function(){var t=!0;return this.forEachObject(function(n){n.setCoords(t)}),this},_calcBounds:function(t){for(var n=[],e=[],o,h,s,u=["tr","br","bl","tl"],d=0,m=this._objects.length,p,v=u.length;d<m;++d){for(o=this._objects[d],s=o.calcACoords(),p=0;p<v;p++)h=u[p],n.push(s[h].x),e.push(s[h].y);o.aCoords=s}this._getBounds(n,e,t)},_getBounds:function(t,n,e){var o=new i.Point(l(t),l(n)),h=new i.Point(a(t),a(n)),s=o.y||0,u=o.x||0,d=h.x-o.x||0,m=h.y-o.y||0;this.width=d,this.height=m,e||this.setPositionByOrigin({x:u,y:s},"left","top")},_toSVG:function(t){for(var n=["<g ","COMMON_PARTS",` >
58
58
  `],e=0,o=this._objects.length;e<o;e++)n.push(" ",this._objects[e].toSVG(t));return n.push(`</g>
59
59
  `),n},getSvgStyles:function(){var t=typeof this.opacity<"u"&&this.opacity!==1?"opacity: "+this.opacity+";":"",n=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),n].join("")},toClipPathSVG:function(t){for(var n=[],e=0,o=this._objects.length;e<o;e++)n.push(" ",this._objects[e].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(n,{reviver:t})}}),i.Group.fromObject=function(t,n){var e=t.objects,o=i.util.object.clone(t,!0);if(delete o.objects,typeof e=="string"){i.loadSVGFromURL(e,function(h){var s=i.util.groupSVGElements(h,t,e),u=o.clipPath;delete o.clipPath,s.set(o),u?i.util.enlivenObjects([u],function(d){s.clipPath=d[0],n&&n(s)}):n&&n(s)});return}i.util.enlivenObjects(e,function(h){i.util.enlivenObjectEnlivables(t,o,function(){n&&n(new i.Group(h,o,!0))})})})})(f),(function(c){var i=c.fabric||(c.fabric={});i.ActiveSelection||(i.ActiveSelection=i.util.createClass(i.Group,{type:"activeSelection",initialize:function(l,a){a=a||{},this._objects=l||[];for(var t=this._objects.length;t--;)this._objects[t].group=this;a.originX&&(this.originX=a.originX),a.originY&&(this.originY=a.originY),this._calcBounds(),this._updateObjectsCoords(),i.Object.prototype.initialize.call(this,a),this.setCoords()},toGroup:function(){var l=this._objects.concat();this._objects=[];var a=i.Object.prototype.toObject.call(this),t=new i.Group([]);if(delete a.type,t.set(a),l.forEach(function(e){e.canvas.remove(e),e.group=t}),t._objects=l,!this.canvas)return t;var n=this.canvas;return n.add(t),n._activeObject=t,t.setCoords(),t},onDeselect:function(){return this.destroy(),!1},toString:function(){return"#<fabric.ActiveSelection: ("+this.complexity()+")>"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(l,a,t){l.save(),l.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.callSuper("_renderControls",l,a),t=t||{},typeof t.hasControls>"u"&&(t.hasControls=!1),t.forActiveSelection=!0;for(var n=0,e=this._objects.length;n<e;n++)this._objects[n]._renderControls(l,t);l.restore()}}),i.ActiveSelection.fromObject=function(l,a){i.util.enlivenObjects(l.objects,function(t){delete l.objects,a&&a(new i.ActiveSelection(t,l,!0))})})})(f),(function(c){var i=r.util.object.extend;if(c.fabric||(c.fabric={}),c.fabric.Image){r.warn("fabric.Image is already defined.");return}r.Image=r.util.createClass(r.Object,{type:"image",strokeWidth:0,srcFromAttribute:!1,_lastScaleX:1,_lastScaleY:1,_filterScalingX:1,_filterScalingY:1,minimumScaleTrigger:.5,stateProperties:r.Object.prototype.stateProperties.concat("cropX","cropY"),cacheProperties:r.Object.prototype.cacheProperties.concat("cropX","cropY"),cacheKey:"",cropX:0,cropY:0,imageSmoothing:!0,initialize:function(l,a){a||(a={}),this.filters=[],this.cacheKey="texture"+r.Object.__uid++,this.callSuper("initialize",a),this._initElement(l,a)},getElement:function(){return this._element||{}},setElement:function(l,a){return this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._element=l,this._originalElement=l,this._initConfig(a),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters(),this},removeTexture:function(l){var a=r.filterBackend;a&&a.evictCachesForKey&&a.evictCachesForKey(l)},dispose:function(){this.callSuper("dispose"),this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._cacheContext=void 0,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach((function(l){r.util.cleanUpJsdomNode(this[l]),this[l]=void 0}).bind(this))},getCrossOrigin:function(){return this._originalElement&&(this._originalElement.crossOrigin||null)},getOriginalSize:function(){var l=this.getElement();return{width:l.naturalWidth||l.width,height:l.naturalHeight||l.height}},_stroke:function(l){if(!(!this.stroke||this.strokeWidth===0)){var a=this.width/2,t=this.height/2;l.beginPath(),l.moveTo(-a,-t),l.lineTo(a,-t),l.lineTo(a,t),l.lineTo(-a,t),l.lineTo(-a,-t),l.closePath()}},toObject:function(l){var a=[];this.filters.forEach(function(n){n&&a.push(n.toObject())});var t=i(this.callSuper("toObject",["cropX","cropY"].concat(l)),{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:a});return this.resizeFilter&&(t.resizeFilter=this.resizeFilter.toObject()),t},hasCrop:function(){return this.cropX||this.cropY||this.width<this._element.width||this.height<this._element.height},_toSVG:function(){var l=[],a=[],t,n=this._element,e=-this.width/2,o=-this.height/2,h="",s="";if(!n)return[];if(this.hasCrop()){var u=r.Object.__uid++;l.push('<clipPath id="imageCrop_'+u+`">
60
60
  `,' <rect x="'+e+'" y="'+o+'" width="'+this.width+'" height="'+this.height+`" />
61
61
  `,`</clipPath>
62
62
  `),h=' clip-path="url(#imageCrop_'+u+')" '}if(this.imageSmoothing||(s='" image-rendering="optimizeSpeed'),a.push(" <image ","COMMON_PARTS",'xlink:href="',this.getSvgSrc(!0),'" x="',e-this.cropX,'" y="',o-this.cropY,'" width="',n.width||n.naturalWidth,'" height="',n.height||n.height,s,'"',h,`></image>
63
63
  `),this.stroke||this.strokeDashArray){var d=this.fill;this.fill=null,t=[" <rect ",'x="',e,'" y="',o,'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),`"/>
64
- `],this.fill=d}return this.paintFirst!=="fill"?l=l.concat(t,a):l=l.concat(a,t),l},getSrc:function(l){var a=l?this._element:this._originalElement;return a?a.toDataURL?a.toDataURL():this.srcFromAttribute?a.getAttribute("src"):a.src:this.src||""},setSrc:function(l,a,t){return r.util.loadImage(l,function(n,e){this.setElement(n,t),this._setWidthHeight(),a&&a(this,e)},this,t&&t.crossOrigin),this},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},applyResizeFilters:function(){var l=this.resizeFilter,a=this.minimumScaleTrigger,t=this.getTotalObjectScaling(),n=t.scaleX,e=t.scaleY,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!l||n>a&&e>a){this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=n,this._lastScaleY=e;return}r.filterBackend||(r.filterBackend=r.initFilterBackend());var h=r.util.createCanvasElement(),s=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,u=o.width,d=o.height;h.width=u,h.height=d,this._element=h,this._lastScaleX=l.scaleX=n,this._lastScaleY=l.scaleY=e,r.filterBackend.applyFilters([l],o,u,d,this._element,s),this._filterScalingX=h.width/this._originalElement.width,this._filterScalingY=h.height/this._originalElement.height},applyFilters:function(l){if(l=l||this.filters||[],l=l.filter(function(o){return o&&!o.isNeutralState()}),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),l.length===0)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var a=this._originalElement,t=a.naturalWidth||a.width,n=a.naturalHeight||a.height;if(this._element===this._originalElement){var e=r.util.createCanvasElement();e.width=t,e.height=n,this._element=e,this._filteredEl=e}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,t,n),this._lastScaleX=1,this._lastScaleY=1;return r.filterBackend||(r.filterBackend=r.initFilterBackend()),r.filterBackend.applyFilters(l,this._originalElement,t,n,this._element,this.cacheKey),(this._originalElement.width!==this._element.width||this._originalElement.height!==this._element.height)&&(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height),this},_render:function(l){r.util.setImageSmoothing(l,this.imageSmoothing),this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(l),this._renderPaintInOrder(l)},drawCacheOnCanvas:function(l){r.util.setImageSmoothing(l,this.imageSmoothing),r.Object.prototype.drawCacheOnCanvas.call(this,l)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(l){var a=this._element;if(a){var t=this._filterScalingX,n=this._filterScalingY,e=this.width,o=this.height,h=Math.min,s=Math.max,u=s(this.cropX,0),d=s(this.cropY,0),m=a.naturalWidth||a.width,g=a.naturalHeight||a.height,v=u*t,b=d*n,S=h(e*t,m-v),E=h(o*n,g-b),F=-e/2,R=-o/2,z=h(e,m/t-u),q=h(o,g/n-d);a&&l.drawImage(a,v,b,S,E,F,R,z,q)}},_needsResize:function(){var l=this.getTotalObjectScaling();return l.scaleX!==this._lastScaleX||l.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(l,a){this.setElement(r.util.getById(l),a),r.util.addClass(this.getElement(),r.Image.CSS_CANVAS)},_initConfig:function(l){l||(l={}),this.setOptions(l),this._setWidthHeight(l)},_initFilters:function(l,a){l&&l.length?r.util.enlivenObjects(l,function(t){a&&a(t)},"fabric.Image.filters"):a&&a()},_setWidthHeight:function(l){l||(l={});var a=this.getElement();this.width=l.width||a.naturalWidth||a.width||0,this.height=l.height||a.naturalHeight||a.height||0},parsePreserveAspectRatioAttribute:function(){var l=r.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),a=this._element.width,t=this._element.height,n=1,e=1,o=0,h=0,s=0,u=0,d,m=this.width,g=this.height,v={width:m,height:g};return l&&(l.alignX!=="none"||l.alignY!=="none")?(l.meetOrSlice==="meet"&&(n=e=r.util.findScaleToFit(this._element,v),d=(m-a*n)/2,l.alignX==="Min"&&(o=-d),l.alignX==="Max"&&(o=d),d=(g-t*e)/2,l.alignY==="Min"&&(h=-d),l.alignY==="Max"&&(h=d)),l.meetOrSlice==="slice"&&(n=e=r.util.findScaleToCover(this._element,v),d=a-m/n,l.alignX==="Mid"&&(s=d/2),l.alignX==="Max"&&(s=d),d=t-g/e,l.alignY==="Mid"&&(u=d/2),l.alignY==="Max"&&(u=d),a=m/n,t=g/e)):(n=m/a,e=g/t),{width:a,height:t,scaleX:n,scaleY:e,offsetLeft:o,offsetTop:h,cropX:s,cropY:u}}}),r.Image.CSS_CANVAS="canvas-img",r.Image.prototype.getSvgSrc=r.Image.prototype.getSrc,r.Image.fromObject=function(l,a){var t=r.util.object.clone(l);r.util.loadImage(t.src,function(n,e){if(e){a&&a(null,!0);return}r.Image.prototype._initFilters.call(t,t.filters,function(o){t.filters=o||[],r.Image.prototype._initFilters.call(t,[t.resizeFilter],function(h){t.resizeFilter=h[0],r.util.enlivenObjectEnlivables(t,t,function(){var s=new r.Image(n,t);a(s,!1)})})})},null,t.crossOrigin)},r.Image.fromURL=function(l,a,t){r.util.loadImage(l,function(n,e){a&&a(new r.Image(n,t),e)},null,t&&t.crossOrigin)},r.Image.ATTRIBUTE_NAMES=r.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")),r.Image.fromElement=function(l,a,t){var n=r.parseAttributes(l,r.Image.ATTRIBUTE_NAMES);r.Image.fromURL(n["xlink:href"],a,i(t?r.util.object.clone(t):{},n))}})(f),r.util.object.extend(r.Object.prototype,{_getAngleValueForStraighten:function(){var c=this.angle%360;return c>0?Math.round((c-1)/90)*90:Math.round(c/90)*90},straighten:function(){return this.rotate(this._getAngleValueForStraighten())},fxStraighten:function(c){c=c||{};var i=function(){},l=c.onComplete||i,a=c.onChange||i,t=this;return r.util.animate({target:this,startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(n){t.rotate(n),a()},onComplete:function(){t.setCoords(),l()}})}}),r.util.object.extend(r.StaticCanvas.prototype,{straightenObject:function(c){return c.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(c){return c.fxStraighten({onChange:this.requestRenderAllBound})}}),(function(){function c(l,a){var t="precision "+a+` float;
65
- void main(){}`,n=l.createShader(l.FRAGMENT_SHADER);return l.shaderSource(n,t),l.compileShader(n),!!l.getShaderParameter(n,l.COMPILE_STATUS)}r.isWebglSupported=function(l){if(r.isLikelyNode)return!1;l=l||r.WebglFilterBackend.prototype.tileSize;var a=document.createElement("canvas"),t=a.getContext("webgl")||a.getContext("experimental-webgl"),n=!1;if(t){r.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),n=r.maxTextureSize>=l;for(var e=["highp","mediump","lowp"],o=0;o<3;o++)if(c(t,e[o])){r.webGlPrecision=e[o];break}}return this.isSupported=n,n},r.WebglFilterBackend=i;function i(l){l&&l.tileSize&&(this.tileSize=l.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}i.prototype={tileSize:2048,resources:{},setupGLContext:function(l,a){this.dispose(),this.createWebGLCanvas(l,a),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(l,a)},chooseFastestCopyGLTo2DMethod:function(l,a){var t=typeof window.performance<"u",n;try{new ImageData(1,1),n=!0}catch{n=!1}var e=typeof ArrayBuffer<"u",o=typeof Uint8ClampedArray<"u";if(t&&n&&e&&o){var h=r.util.createCanvasElement(),s=new ArrayBuffer(l*a*4);if(r.forceGLPutImageData){this.imageBuffer=s,this.copyGLTo2D=T;return}var u={imageBuffer:s,destinationWidth:l,destinationHeight:a,targetCanvas:h},d,m,g;h.width=l,h.height=a,d=window.performance.now(),C.call(u,this.gl,u),m=window.performance.now()-d,d=window.performance.now(),T.call(u,this.gl,u),g=window.performance.now()-d,m>g?(this.imageBuffer=s,this.copyGLTo2D=T):this.copyGLTo2D=C}},createWebGLCanvas:function(l,a){var t=r.util.createCanvasElement();t.width=l,t.height=a;var n={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},e=t.getContext("webgl",n);e||(e=t.getContext("experimental-webgl",n)),e&&(e.clearColor(0,0,0,0),this.canvas=t,this.gl=e)},applyFilters:function(l,a,t,n,e,o){var h=this.gl,s;o&&(s=this.getCachedTexture(o,a));var u={originalWidth:a.width||a.originalWidth,originalHeight:a.height||a.originalHeight,sourceWidth:t,sourceHeight:n,destinationWidth:t,destinationHeight:n,context:h,sourceTexture:this.createTexture(h,t,n,!s&&a),targetTexture:this.createTexture(h,t,n),originalTexture:s||this.createTexture(h,t,n,!s&&a),passes:l.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:e},d=h.createFramebuffer();return h.bindFramebuffer(h.FRAMEBUFFER,d),l.forEach(function(m){m&&m.applyTo(u)}),y(u),this.copyGLTo2D(h,u),h.bindTexture(h.TEXTURE_2D,null),h.deleteTexture(u.sourceTexture),h.deleteTexture(u.targetTexture),h.deleteFramebuffer(d),e.getContext("2d").setTransform(1,0,0,1,0,0),u},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(l,a,t,n,e){var o=l.createTexture();return l.bindTexture(l.TEXTURE_2D,o),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,e||l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,e||l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),n?l.texImage2D(l.TEXTURE_2D,0,l.RGBA,l.RGBA,l.UNSIGNED_BYTE,n):l.texImage2D(l.TEXTURE_2D,0,l.RGBA,a,t,0,l.RGBA,l.UNSIGNED_BYTE,null),o},getCachedTexture:function(l,a){if(this.textureCache[l])return this.textureCache[l];var t=this.createTexture(this.gl,a.width,a.height,a);return this.textureCache[l]=t,t},evictCachesForKey:function(l){this.textureCache[l]&&(this.gl.deleteTexture(this.textureCache[l]),delete this.textureCache[l])},copyGLTo2D:C,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var l=this.gl,a={renderer:"",vendor:""};if(!l)return a;var t=l.getExtension("WEBGL_debug_renderer_info");if(t){var n=l.getParameter(t.UNMASKED_RENDERER_WEBGL),e=l.getParameter(t.UNMASKED_VENDOR_WEBGL);n&&(a.renderer=n.toLowerCase()),e&&(a.vendor=e.toLowerCase())}return this.gpuInfo=a,a}}})();function y(c){var i=c.targetCanvas,l=i.width,a=i.height,t=c.destinationWidth,n=c.destinationHeight;(l!==t||a!==n)&&(i.width=t,i.height=n)}function C(c,i){var l=c.canvas,a=i.targetCanvas,t=a.getContext("2d");t.translate(0,a.height),t.scale(1,-1);var n=l.height-a.height;t.drawImage(l,0,n,a.width,a.height,0,0,a.width,a.height)}function T(c,i){var l=i.targetCanvas,a=l.getContext("2d"),t=i.destinationWidth,n=i.destinationHeight,e=t*n*4,o=new Uint8Array(this.imageBuffer,0,e),h=new Uint8ClampedArray(this.imageBuffer,0,e);c.readPixels(0,0,t,n,c.RGBA,c.UNSIGNED_BYTE,o);var s=new ImageData(h,t,n);a.putImageData(s,0,0)}(function(){var c=function(){};r.Canvas2dFilterBackend=i;function i(){}i.prototype={evictCachesForKey:c,dispose:c,clearWebGLCaches:c,resources:{},applyFilters:function(l,a,t,n,e){var o=e.getContext("2d");o.drawImage(a,0,0,t,n);var h=o.getImageData(0,0,t,n),s=o.getImageData(0,0,t,n),u={sourceWidth:t,sourceHeight:n,imageData:h,originalEl:a,originalImageData:s,canvasEl:e,ctx:o,filterBackend:this};return l.forEach(function(d){d.applyTo(u)}),(u.imageData.width!==t||u.imageData.height!==n)&&(e.width=u.imageData.width,e.height=u.imageData.height),o.putImageData(u.imageData,0,0),u}}})(),r.Image=r.Image||{},r.Image.filters=r.Image.filters||{},r.Image.filters.BaseFilter=r.util.createClass({type:"BaseFilter",vertexSource:`attribute vec2 aPosition;
64
+ `],this.fill=d}return this.paintFirst!=="fill"?l=l.concat(t,a):l=l.concat(a,t),l},getSrc:function(l){var a=l?this._element:this._originalElement;return a?a.toDataURL?a.toDataURL():this.srcFromAttribute?a.getAttribute("src"):a.src:this.src||""},setSrc:function(l,a,t){return r.util.loadImage(l,function(n,e){this.setElement(n,t),this._setWidthHeight(),a&&a(this,e)},this,t&&t.crossOrigin),this},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},applyResizeFilters:function(){var l=this.resizeFilter,a=this.minimumScaleTrigger,t=this.getTotalObjectScaling(),n=t.scaleX,e=t.scaleY,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!l||n>a&&e>a){this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=n,this._lastScaleY=e;return}r.filterBackend||(r.filterBackend=r.initFilterBackend());var h=r.util.createCanvasElement(),s=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,u=o.width,d=o.height;h.width=u,h.height=d,this._element=h,this._lastScaleX=l.scaleX=n,this._lastScaleY=l.scaleY=e,r.filterBackend.applyFilters([l],o,u,d,this._element,s),this._filterScalingX=h.width/this._originalElement.width,this._filterScalingY=h.height/this._originalElement.height},applyFilters:function(l){if(l=l||this.filters||[],l=l.filter(function(o){return o&&!o.isNeutralState()}),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),l.length===0)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var a=this._originalElement,t=a.naturalWidth||a.width,n=a.naturalHeight||a.height;if(this._element===this._originalElement){var e=r.util.createCanvasElement();e.width=t,e.height=n,this._element=e,this._filteredEl=e}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,t,n),this._lastScaleX=1,this._lastScaleY=1;return r.filterBackend||(r.filterBackend=r.initFilterBackend()),r.filterBackend.applyFilters(l,this._originalElement,t,n,this._element,this.cacheKey),(this._originalElement.width!==this._element.width||this._originalElement.height!==this._element.height)&&(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height),this},_render:function(l){r.util.setImageSmoothing(l,this.imageSmoothing),this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(l),this._renderPaintInOrder(l)},drawCacheOnCanvas:function(l){r.util.setImageSmoothing(l,this.imageSmoothing),r.Object.prototype.drawCacheOnCanvas.call(this,l)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(l){var a=this._element;if(a){var t=this._filterScalingX,n=this._filterScalingY,e=this.width,o=this.height,h=Math.min,s=Math.max,u=s(this.cropX,0),d=s(this.cropY,0),m=a.naturalWidth||a.width,p=a.naturalHeight||a.height,v=u*t,b=d*n,S=h(e*t,m-v),E=h(o*n,p-b),F=-e/2,R=-o/2,z=h(e,m/t-u),K=h(o,p/n-d);a&&l.drawImage(a,v,b,S,E,F,R,z,K)}},_needsResize:function(){var l=this.getTotalObjectScaling();return l.scaleX!==this._lastScaleX||l.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(l,a){this.setElement(r.util.getById(l),a),r.util.addClass(this.getElement(),r.Image.CSS_CANVAS)},_initConfig:function(l){l||(l={}),this.setOptions(l),this._setWidthHeight(l)},_initFilters:function(l,a){l&&l.length?r.util.enlivenObjects(l,function(t){a&&a(t)},"fabric.Image.filters"):a&&a()},_setWidthHeight:function(l){l||(l={});var a=this.getElement();this.width=l.width||a.naturalWidth||a.width||0,this.height=l.height||a.naturalHeight||a.height||0},parsePreserveAspectRatioAttribute:function(){var l=r.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),a=this._element.width,t=this._element.height,n=1,e=1,o=0,h=0,s=0,u=0,d,m=this.width,p=this.height,v={width:m,height:p};return l&&(l.alignX!=="none"||l.alignY!=="none")?(l.meetOrSlice==="meet"&&(n=e=r.util.findScaleToFit(this._element,v),d=(m-a*n)/2,l.alignX==="Min"&&(o=-d),l.alignX==="Max"&&(o=d),d=(p-t*e)/2,l.alignY==="Min"&&(h=-d),l.alignY==="Max"&&(h=d)),l.meetOrSlice==="slice"&&(n=e=r.util.findScaleToCover(this._element,v),d=a-m/n,l.alignX==="Mid"&&(s=d/2),l.alignX==="Max"&&(s=d),d=t-p/e,l.alignY==="Mid"&&(u=d/2),l.alignY==="Max"&&(u=d),a=m/n,t=p/e)):(n=m/a,e=p/t),{width:a,height:t,scaleX:n,scaleY:e,offsetLeft:o,offsetTop:h,cropX:s,cropY:u}}}),r.Image.CSS_CANVAS="canvas-img",r.Image.prototype.getSvgSrc=r.Image.prototype.getSrc,r.Image.fromObject=function(l,a){var t=r.util.object.clone(l);r.util.loadImage(t.src,function(n,e){if(e){a&&a(null,!0);return}r.Image.prototype._initFilters.call(t,t.filters,function(o){t.filters=o||[],r.Image.prototype._initFilters.call(t,[t.resizeFilter],function(h){t.resizeFilter=h[0],r.util.enlivenObjectEnlivables(t,t,function(){var s=new r.Image(n,t);a(s,!1)})})})},null,t.crossOrigin)},r.Image.fromURL=function(l,a,t){r.util.loadImage(l,function(n,e){a&&a(new r.Image(n,t),e)},null,t&&t.crossOrigin)},r.Image.ATTRIBUTE_NAMES=r.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")),r.Image.fromElement=function(l,a,t){var n=r.parseAttributes(l,r.Image.ATTRIBUTE_NAMES);r.Image.fromURL(n["xlink:href"],a,i(t?r.util.object.clone(t):{},n))}})(f),r.util.object.extend(r.Object.prototype,{_getAngleValueForStraighten:function(){var c=this.angle%360;return c>0?Math.round((c-1)/90)*90:Math.round(c/90)*90},straighten:function(){return this.rotate(this._getAngleValueForStraighten())},fxStraighten:function(c){c=c||{};var i=function(){},l=c.onComplete||i,a=c.onChange||i,t=this;return r.util.animate({target:this,startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(n){t.rotate(n),a()},onComplete:function(){t.setCoords(),l()}})}}),r.util.object.extend(r.StaticCanvas.prototype,{straightenObject:function(c){return c.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(c){return c.fxStraighten({onChange:this.requestRenderAllBound})}}),(function(){function c(l,a){var t="precision "+a+` float;
65
+ void main(){}`,n=l.createShader(l.FRAGMENT_SHADER);return l.shaderSource(n,t),l.compileShader(n),!!l.getShaderParameter(n,l.COMPILE_STATUS)}r.isWebglSupported=function(l){if(r.isLikelyNode)return!1;l=l||r.WebglFilterBackend.prototype.tileSize;var a=document.createElement("canvas"),t=a.getContext("webgl")||a.getContext("experimental-webgl"),n=!1;if(t){r.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),n=r.maxTextureSize>=l;for(var e=["highp","mediump","lowp"],o=0;o<3;o++)if(c(t,e[o])){r.webGlPrecision=e[o];break}}return this.isSupported=n,n},r.WebglFilterBackend=i;function i(l){l&&l.tileSize&&(this.tileSize=l.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}i.prototype={tileSize:2048,resources:{},setupGLContext:function(l,a){this.dispose(),this.createWebGLCanvas(l,a),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(l,a)},chooseFastestCopyGLTo2DMethod:function(l,a){var t=typeof window.performance<"u",n;try{new ImageData(1,1),n=!0}catch{n=!1}var e=typeof ArrayBuffer<"u",o=typeof Uint8ClampedArray<"u";if(t&&n&&e&&o){var h=r.util.createCanvasElement(),s=new ArrayBuffer(l*a*4);if(r.forceGLPutImageData){this.imageBuffer=s,this.copyGLTo2D=T;return}var u={imageBuffer:s,destinationWidth:l,destinationHeight:a,targetCanvas:h},d,m,p;h.width=l,h.height=a,d=window.performance.now(),C.call(u,this.gl,u),m=window.performance.now()-d,d=window.performance.now(),T.call(u,this.gl,u),p=window.performance.now()-d,m>p?(this.imageBuffer=s,this.copyGLTo2D=T):this.copyGLTo2D=C}},createWebGLCanvas:function(l,a){var t=r.util.createCanvasElement();t.width=l,t.height=a;var n={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},e=t.getContext("webgl",n);e||(e=t.getContext("experimental-webgl",n)),e&&(e.clearColor(0,0,0,0),this.canvas=t,this.gl=e)},applyFilters:function(l,a,t,n,e,o){var h=this.gl,s;o&&(s=this.getCachedTexture(o,a));var u={originalWidth:a.width||a.originalWidth,originalHeight:a.height||a.originalHeight,sourceWidth:t,sourceHeight:n,destinationWidth:t,destinationHeight:n,context:h,sourceTexture:this.createTexture(h,t,n,!s&&a),targetTexture:this.createTexture(h,t,n),originalTexture:s||this.createTexture(h,t,n,!s&&a),passes:l.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:e},d=h.createFramebuffer();return h.bindFramebuffer(h.FRAMEBUFFER,d),l.forEach(function(m){m&&m.applyTo(u)}),y(u),this.copyGLTo2D(h,u),h.bindTexture(h.TEXTURE_2D,null),h.deleteTexture(u.sourceTexture),h.deleteTexture(u.targetTexture),h.deleteFramebuffer(d),e.getContext("2d").setTransform(1,0,0,1,0,0),u},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(l,a,t,n,e){var o=l.createTexture();return l.bindTexture(l.TEXTURE_2D,o),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,e||l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,e||l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),n?l.texImage2D(l.TEXTURE_2D,0,l.RGBA,l.RGBA,l.UNSIGNED_BYTE,n):l.texImage2D(l.TEXTURE_2D,0,l.RGBA,a,t,0,l.RGBA,l.UNSIGNED_BYTE,null),o},getCachedTexture:function(l,a){if(this.textureCache[l])return this.textureCache[l];var t=this.createTexture(this.gl,a.width,a.height,a);return this.textureCache[l]=t,t},evictCachesForKey:function(l){this.textureCache[l]&&(this.gl.deleteTexture(this.textureCache[l]),delete this.textureCache[l])},copyGLTo2D:C,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var l=this.gl,a={renderer:"",vendor:""};if(!l)return a;var t=l.getExtension("WEBGL_debug_renderer_info");if(t){var n=l.getParameter(t.UNMASKED_RENDERER_WEBGL),e=l.getParameter(t.UNMASKED_VENDOR_WEBGL);n&&(a.renderer=n.toLowerCase()),e&&(a.vendor=e.toLowerCase())}return this.gpuInfo=a,a}}})();function y(c){var i=c.targetCanvas,l=i.width,a=i.height,t=c.destinationWidth,n=c.destinationHeight;(l!==t||a!==n)&&(i.width=t,i.height=n)}function C(c,i){var l=c.canvas,a=i.targetCanvas,t=a.getContext("2d");t.translate(0,a.height),t.scale(1,-1);var n=l.height-a.height;t.drawImage(l,0,n,a.width,a.height,0,0,a.width,a.height)}function T(c,i){var l=i.targetCanvas,a=l.getContext("2d"),t=i.destinationWidth,n=i.destinationHeight,e=t*n*4,o=new Uint8Array(this.imageBuffer,0,e),h=new Uint8ClampedArray(this.imageBuffer,0,e);c.readPixels(0,0,t,n,c.RGBA,c.UNSIGNED_BYTE,o);var s=new ImageData(h,t,n);a.putImageData(s,0,0)}(function(){var c=function(){};r.Canvas2dFilterBackend=i;function i(){}i.prototype={evictCachesForKey:c,dispose:c,clearWebGLCaches:c,resources:{},applyFilters:function(l,a,t,n,e){var o=e.getContext("2d");o.drawImage(a,0,0,t,n);var h=o.getImageData(0,0,t,n),s=o.getImageData(0,0,t,n),u={sourceWidth:t,sourceHeight:n,imageData:h,originalEl:a,originalImageData:s,canvasEl:e,ctx:o,filterBackend:this};return l.forEach(function(d){d.applyTo(u)}),(u.imageData.width!==t||u.imageData.height!==n)&&(e.width=u.imageData.width,e.height=u.imageData.height),o.putImageData(u.imageData,0,0),u}}})(),r.Image=r.Image||{},r.Image.filters=r.Image.filters||{},r.Image.filters.BaseFilter=r.util.createClass({type:"BaseFilter",vertexSource:`attribute vec2 aPosition;
66
66
  varying vec2 vTexCoord;
67
67
  void main() {
68
68
  vTexCoord = aPosition;
@@ -82,7 +82,7 @@ vec4 color = texture2D(uTexture, vTexCoord);
82
82
  color *= uColorMatrix;
83
83
  color += uConstants;
84
84
  gl_FragColor = color;
85
- }`,matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(t){this.callSuper("initialize",t),this.matrix=this.matrix.slice(0)},applyTo2d:function(t){var n=t.imageData,e=n.data,o=e.length,h=this.matrix,s,u,d,m,g,v=this.colorsOnly;for(g=0;g<o;g+=4)s=e[g],u=e[g+1],d=e[g+2],v?(e[g]=s*h[0]+u*h[1]+d*h[2]+h[4]*255,e[g+1]=s*h[5]+u*h[6]+d*h[7]+h[9]*255,e[g+2]=s*h[10]+u*h[11]+d*h[12]+h[14]*255):(m=e[g+3],e[g]=s*h[0]+u*h[1]+d*h[2]+m*h[3]+h[4]*255,e[g+1]=s*h[5]+u*h[6]+d*h[7]+m*h[8]+h[9]*255,e[g+2]=s*h[10]+u*h[11]+d*h[12]+m*h[13]+h[14]*255,e[g+3]=s*h[15]+u*h[16]+d*h[17]+m*h[18]+h[19]*255)},getUniformLocations:function(t,n){return{uColorMatrix:t.getUniformLocation(n,"uColorMatrix"),uConstants:t.getUniformLocation(n,"uConstants")}},sendUniformData:function(t,n){var e=this.matrix,o=[e[0],e[1],e[2],e[3],e[5],e[6],e[7],e[8],e[10],e[11],e[12],e[13],e[15],e[16],e[17],e[18]],h=[e[4],e[9],e[14],e[19]];t.uniformMatrix4fv(n.uColorMatrix,!1,o),t.uniform4fv(n.uConstants,h)}}),i.Image.filters.ColorMatrix.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass;l.Brightness=a(l.BaseFilter,{type:"Brightness",fragmentSource:`precision highp float;
85
+ }`,matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(t){this.callSuper("initialize",t),this.matrix=this.matrix.slice(0)},applyTo2d:function(t){var n=t.imageData,e=n.data,o=e.length,h=this.matrix,s,u,d,m,p,v=this.colorsOnly;for(p=0;p<o;p+=4)s=e[p],u=e[p+1],d=e[p+2],v?(e[p]=s*h[0]+u*h[1]+d*h[2]+h[4]*255,e[p+1]=s*h[5]+u*h[6]+d*h[7]+h[9]*255,e[p+2]=s*h[10]+u*h[11]+d*h[12]+h[14]*255):(m=e[p+3],e[p]=s*h[0]+u*h[1]+d*h[2]+m*h[3]+h[4]*255,e[p+1]=s*h[5]+u*h[6]+d*h[7]+m*h[8]+h[9]*255,e[p+2]=s*h[10]+u*h[11]+d*h[12]+m*h[13]+h[14]*255,e[p+3]=s*h[15]+u*h[16]+d*h[17]+m*h[18]+h[19]*255)},getUniformLocations:function(t,n){return{uColorMatrix:t.getUniformLocation(n,"uColorMatrix"),uConstants:t.getUniformLocation(n,"uConstants")}},sendUniformData:function(t,n){var e=this.matrix,o=[e[0],e[1],e[2],e[3],e[5],e[6],e[7],e[8],e[10],e[11],e[12],e[13],e[15],e[16],e[17],e[18]],h=[e[4],e[9],e[14],e[19]];t.uniformMatrix4fv(n.uColorMatrix,!1,o),t.uniform4fv(n.uConstants,h)}}),i.Image.filters.ColorMatrix.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass;l.Brightness=a(l.BaseFilter,{type:"Brightness",fragmentSource:`precision highp float;
86
86
  uniform sampler2D uTexture;
87
87
  uniform float uBrightness;
88
88
  varying vec2 vTexCoord;
@@ -218,7 +218,7 @@ color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.
218
218
  float alpha = texture2D(uTexture, vTexCoord).a;
219
219
  gl_FragColor = color;
220
220
  gl_FragColor.a = alpha;
221
- }`},retrieveShader:function(n){var e=Math.sqrt(this.matrix.length),o=this.type+"_"+e+"_"+(this.opaque?1:0),h=this.fragmentSource[o];return n.programCache.hasOwnProperty(o)||(n.programCache[o]=this.createProgram(n.context,h)),n.programCache[o]},applyTo2d:function(n){var e=n.imageData,o=e.data,h=this.matrix,s=Math.round(Math.sqrt(h.length)),u=Math.floor(s/2),d=e.width,m=e.height,g=n.ctx.createImageData(d,m),v=g.data,b=this.opaque?1:0,S,E,F,R,z,q,Z,K,$,tt,it,et,w;for(it=0;it<m;it++)for(tt=0;tt<d;tt++){for(z=(it*d+tt)*4,S=0,E=0,F=0,R=0,w=0;w<s;w++)for(et=0;et<s;et++)Z=it+w-u,q=tt+et-u,!(Z<0||Z>=m||q<0||q>=d)&&(K=(Z*d+q)*4,$=h[w*s+et],S+=o[K]*$,E+=o[K+1]*$,F+=o[K+2]*$,b||(R+=o[K+3]*$));v[z]=S,v[z+1]=E,v[z+2]=F,b?v[z+3]=o[z+3]:v[z+3]=R}n.imageData=g},getUniformLocations:function(n,e){return{uMatrix:n.getUniformLocation(e,"uMatrix"),uOpaque:n.getUniformLocation(e,"uOpaque"),uHalfSize:n.getUniformLocation(e,"uHalfSize"),uSize:n.getUniformLocation(e,"uSize")}},sendUniformData:function(n,e){n.uniform1fv(e.uMatrix,this.matrix)},toObject:function(){return l(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),i.Image.filters.Convolute.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass;l.Grayscale=a(l.BaseFilter,{type:"Grayscale",fragmentSource:{average:`precision highp float;
221
+ }`},retrieveShader:function(n){var e=Math.sqrt(this.matrix.length),o=this.type+"_"+e+"_"+(this.opaque?1:0),h=this.fragmentSource[o];return n.programCache.hasOwnProperty(o)||(n.programCache[o]=this.createProgram(n.context,h)),n.programCache[o]},applyTo2d:function(n){var e=n.imageData,o=e.data,h=this.matrix,s=Math.round(Math.sqrt(h.length)),u=Math.floor(s/2),d=e.width,m=e.height,p=n.ctx.createImageData(d,m),v=p.data,b=this.opaque?1:0,S,E,F,R,z,K,Z,q,$,tt,it,et,w;for(it=0;it<m;it++)for(tt=0;tt<d;tt++){for(z=(it*d+tt)*4,S=0,E=0,F=0,R=0,w=0;w<s;w++)for(et=0;et<s;et++)Z=it+w-u,K=tt+et-u,!(Z<0||Z>=m||K<0||K>=d)&&(q=(Z*d+K)*4,$=h[w*s+et],S+=o[q]*$,E+=o[q+1]*$,F+=o[q+2]*$,b||(R+=o[q+3]*$));v[z]=S,v[z+1]=E,v[z+2]=F,b?v[z+3]=o[z+3]:v[z+3]=R}n.imageData=p},getUniformLocations:function(n,e){return{uMatrix:n.getUniformLocation(e,"uMatrix"),uOpaque:n.getUniformLocation(e,"uOpaque"),uHalfSize:n.getUniformLocation(e,"uHalfSize"),uSize:n.getUniformLocation(e,"uSize")}},sendUniformData:function(n,e){n.uniform1fv(e.uMatrix,this.matrix)},toObject:function(){return l(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),i.Image.filters.Convolute.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass;l.Grayscale=a(l.BaseFilter,{type:"Grayscale",fragmentSource:{average:`precision highp float;
222
222
  uniform sampler2D uTexture;
223
223
  varying vec2 vTexCoord;
224
224
  void main() {
@@ -281,7 +281,7 @@ float fposY = float(posY);
281
281
  vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);
282
282
  vec4 color = texture2D(uTexture, squareCoords);
283
283
  gl_FragColor = color;
284
- }`,applyTo2d:function(t){var n=t.imageData,e=n.data,o=n.height,h=n.width,s,u,d,m,g,v,b,S,E,F,R;for(u=0;u<o;u+=this.blocksize)for(d=0;d<h;d+=this.blocksize)for(s=u*4*h+d*4,m=e[s],g=e[s+1],v=e[s+2],b=e[s+3],F=Math.min(u+this.blocksize,o),R=Math.min(d+this.blocksize,h),S=u;S<F;S++)for(E=d;E<R;E++)s=S*4*h+E*4,e[s]=m,e[s+1]=g,e[s+2]=v,e[s+3]=b},isNeutralState:function(){return this.blocksize===1},getUniformLocations:function(t,n){return{uBlocksize:t.getUniformLocation(n,"uBlocksize"),uStepW:t.getUniformLocation(n,"uStepW"),uStepH:t.getUniformLocation(n,"uStepH")}},sendUniformData:function(t,n){t.uniform1f(n.uBlocksize,this.blocksize)}}),i.Image.filters.Pixelate.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.object.extend,a=i.Image.filters,t=i.util.createClass;a.RemoveColor=t(a.BaseFilter,{type:"RemoveColor",color:"#FFFFFF",fragmentSource:`precision highp float;
284
+ }`,applyTo2d:function(t){var n=t.imageData,e=n.data,o=n.height,h=n.width,s,u,d,m,p,v,b,S,E,F,R;for(u=0;u<o;u+=this.blocksize)for(d=0;d<h;d+=this.blocksize)for(s=u*4*h+d*4,m=e[s],p=e[s+1],v=e[s+2],b=e[s+3],F=Math.min(u+this.blocksize,o),R=Math.min(d+this.blocksize,h),S=u;S<F;S++)for(E=d;E<R;E++)s=S*4*h+E*4,e[s]=m,e[s+1]=p,e[s+2]=v,e[s+3]=b},isNeutralState:function(){return this.blocksize===1},getUniformLocations:function(t,n){return{uBlocksize:t.getUniformLocation(n,"uBlocksize"),uStepW:t.getUniformLocation(n,"uStepW"),uStepH:t.getUniformLocation(n,"uStepH")}},sendUniformData:function(t,n){t.uniform1f(n.uBlocksize,this.blocksize)}}),i.Image.filters.Pixelate.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.object.extend,a=i.Image.filters,t=i.util.createClass;a.RemoveColor=t(a.BaseFilter,{type:"RemoveColor",color:"#FFFFFF",fragmentSource:`precision highp float;
285
285
  uniform sampler2D uTexture;
286
286
  uniform vec4 uLow;
287
287
  uniform vec4 uHigh;
@@ -291,7 +291,7 @@ gl_FragColor = texture2D(uTexture, vTexCoord);
291
291
  if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {
292
292
  gl_FragColor.a = 0.0;
293
293
  }
294
- }`,distance:.02,useAlpha:!1,applyTo2d:function(n){var e=n.imageData,o=e.data,h,s=this.distance*255,u,d,m,g=new i.Color(this.color).getSource(),v=[g[0]-s,g[1]-s,g[2]-s],b=[g[0]+s,g[1]+s,g[2]+s];for(h=0;h<o.length;h+=4)u=o[h],d=o[h+1],m=o[h+2],u>v[0]&&d>v[1]&&m>v[2]&&u<b[0]&&d<b[1]&&m<b[2]&&(o[h+3]=0)},getUniformLocations:function(n,e){return{uLow:n.getUniformLocation(e,"uLow"),uHigh:n.getUniformLocation(e,"uHigh")}},sendUniformData:function(n,e){var o=new i.Color(this.color).getSource(),h=parseFloat(this.distance),s=[0+o[0]/255-h,0+o[1]/255-h,0+o[2]/255-h,1],u=[o[0]/255+h,o[1]/255+h,o[2]/255+h,1];n.uniform4fv(e.uLow,s),n.uniform4fv(e.uHigh,u)},toObject:function(){return l(this.callSuper("toObject"),{color:this.color,distance:this.distance})}}),i.Image.filters.RemoveColor.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass,t={Brownie:[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0],Vintage:[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0],Kodachrome:[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0],Technicolor:[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0],Polaroid:[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],Sepia:[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0],BlackWhite:[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]};for(var n in t)l[n]=a(l.ColorMatrix,{type:n,matrix:t[n],mainParameter:!1,colorsOnly:!0}),i.Image.filters[n].fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric,l=i.Image.filters,a=i.util.createClass;l.BlendColor=a(l.BaseFilter,{type:"BlendColor",color:"#F95C63",mode:"multiply",alpha:1,fragmentSource:{multiply:`gl_FragColor.rgb *= uColor.rgb;
294
+ }`,distance:.02,useAlpha:!1,applyTo2d:function(n){var e=n.imageData,o=e.data,h,s=this.distance*255,u,d,m,p=new i.Color(this.color).getSource(),v=[p[0]-s,p[1]-s,p[2]-s],b=[p[0]+s,p[1]+s,p[2]+s];for(h=0;h<o.length;h+=4)u=o[h],d=o[h+1],m=o[h+2],u>v[0]&&d>v[1]&&m>v[2]&&u<b[0]&&d<b[1]&&m<b[2]&&(o[h+3]=0)},getUniformLocations:function(n,e){return{uLow:n.getUniformLocation(e,"uLow"),uHigh:n.getUniformLocation(e,"uHigh")}},sendUniformData:function(n,e){var o=new i.Color(this.color).getSource(),h=parseFloat(this.distance),s=[0+o[0]/255-h,0+o[1]/255-h,0+o[2]/255-h,1],u=[o[0]/255+h,o[1]/255+h,o[2]/255+h,1];n.uniform4fv(e.uLow,s),n.uniform4fv(e.uHigh,u)},toObject:function(){return l(this.callSuper("toObject"),{color:this.color,distance:this.distance})}}),i.Image.filters.RemoveColor.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass,t={Brownie:[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0],Vintage:[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0],Kodachrome:[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0],Technicolor:[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0],Polaroid:[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],Sepia:[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0],BlackWhite:[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]};for(var n in t)l[n]=a(l.ColorMatrix,{type:n,matrix:t[n],mainParameter:!1,colorsOnly:!0}),i.Image.filters[n].fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric,l=i.Image.filters,a=i.util.createClass;l.BlendColor=a(l.BaseFilter,{type:"BlendColor",color:"#F95C63",mode:"multiply",alpha:1,fragmentSource:{multiply:`gl_FragColor.rgb *= uColor.rgb;
295
295
  `,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
296
296
  `,add:`gl_FragColor.rgb += uColor.rgb;
297
297
  `,diff:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
@@ -325,7 +325,7 @@ vec4 color = texture2D(uTexture, vTexCoord);
325
325
  gl_FragColor = color;
326
326
  if (color.a > 0.0) {
327
327
  `+this.fragmentSource[t]+`}
328
- }`},retrieveShader:function(t){var n=this.type+"_"+this.mode,e;return t.programCache.hasOwnProperty(n)||(e=this.buildSource(this.mode),t.programCache[n]=this.createProgram(t.context,e)),t.programCache[n]},applyTo2d:function(t){var n=t.imageData,e=n.data,o=e.length,h,s,u,d,m,g,v,b=1-this.alpha;v=new i.Color(this.color).getSource(),h=v[0]*this.alpha,s=v[1]*this.alpha,u=v[2]*this.alpha;for(var S=0;S<o;S+=4)switch(d=e[S],m=e[S+1],g=e[S+2],this.mode){case"multiply":e[S]=d*h/255,e[S+1]=m*s/255,e[S+2]=g*u/255;break;case"screen":e[S]=255-(255-d)*(255-h)/255,e[S+1]=255-(255-m)*(255-s)/255,e[S+2]=255-(255-g)*(255-u)/255;break;case"add":e[S]=d+h,e[S+1]=m+s,e[S+2]=g+u;break;case"diff":case"difference":e[S]=Math.abs(d-h),e[S+1]=Math.abs(m-s),e[S+2]=Math.abs(g-u);break;case"subtract":e[S]=d-h,e[S+1]=m-s,e[S+2]=g-u;break;case"darken":e[S]=Math.min(d,h),e[S+1]=Math.min(m,s),e[S+2]=Math.min(g,u);break;case"lighten":e[S]=Math.max(d,h),e[S+1]=Math.max(m,s),e[S+2]=Math.max(g,u);break;case"overlay":e[S]=h<128?2*d*h/255:255-2*(255-d)*(255-h)/255,e[S+1]=s<128?2*m*s/255:255-2*(255-m)*(255-s)/255,e[S+2]=u<128?2*g*u/255:255-2*(255-g)*(255-u)/255;break;case"exclusion":e[S]=h+d-2*h*d/255,e[S+1]=s+m-2*s*m/255,e[S+2]=u+g-2*u*g/255;break;case"tint":e[S]=h+d*b,e[S+1]=s+m*b,e[S+2]=u+g*b}},getUniformLocations:function(t,n){return{uColor:t.getUniformLocation(n,"uColor")}},sendUniformData:function(t,n){var e=new i.Color(this.color).getSource();e[0]=this.alpha*e[0]/255,e[1]=this.alpha*e[1]/255,e[2]=this.alpha*e[2]/255,e[3]=this.alpha,t.uniform4fv(n.uColor,e)},toObject:function(){return{type:this.type,color:this.color,mode:this.mode,alpha:this.alpha}}}),i.Image.filters.BlendColor.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric,l=i.Image.filters,a=i.util.createClass;l.BlendImage=a(l.BaseFilter,{type:"BlendImage",image:null,mode:"multiply",alpha:1,vertexSource:`attribute vec2 aPosition;
328
+ }`},retrieveShader:function(t){var n=this.type+"_"+this.mode,e;return t.programCache.hasOwnProperty(n)||(e=this.buildSource(this.mode),t.programCache[n]=this.createProgram(t.context,e)),t.programCache[n]},applyTo2d:function(t){var n=t.imageData,e=n.data,o=e.length,h,s,u,d,m,p,v,b=1-this.alpha;v=new i.Color(this.color).getSource(),h=v[0]*this.alpha,s=v[1]*this.alpha,u=v[2]*this.alpha;for(var S=0;S<o;S+=4)switch(d=e[S],m=e[S+1],p=e[S+2],this.mode){case"multiply":e[S]=d*h/255,e[S+1]=m*s/255,e[S+2]=p*u/255;break;case"screen":e[S]=255-(255-d)*(255-h)/255,e[S+1]=255-(255-m)*(255-s)/255,e[S+2]=255-(255-p)*(255-u)/255;break;case"add":e[S]=d+h,e[S+1]=m+s,e[S+2]=p+u;break;case"diff":case"difference":e[S]=Math.abs(d-h),e[S+1]=Math.abs(m-s),e[S+2]=Math.abs(p-u);break;case"subtract":e[S]=d-h,e[S+1]=m-s,e[S+2]=p-u;break;case"darken":e[S]=Math.min(d,h),e[S+1]=Math.min(m,s),e[S+2]=Math.min(p,u);break;case"lighten":e[S]=Math.max(d,h),e[S+1]=Math.max(m,s),e[S+2]=Math.max(p,u);break;case"overlay":e[S]=h<128?2*d*h/255:255-2*(255-d)*(255-h)/255,e[S+1]=s<128?2*m*s/255:255-2*(255-m)*(255-s)/255,e[S+2]=u<128?2*p*u/255:255-2*(255-p)*(255-u)/255;break;case"exclusion":e[S]=h+d-2*h*d/255,e[S+1]=s+m-2*s*m/255,e[S+2]=u+p-2*u*p/255;break;case"tint":e[S]=h+d*b,e[S+1]=s+m*b,e[S+2]=u+p*b}},getUniformLocations:function(t,n){return{uColor:t.getUniformLocation(n,"uColor")}},sendUniformData:function(t,n){var e=new i.Color(this.color).getSource();e[0]=this.alpha*e[0]/255,e[1]=this.alpha*e[1]/255,e[2]=this.alpha*e[2]/255,e[3]=this.alpha,t.uniform4fv(n.uColor,e)},toObject:function(){return{type:this.type,color:this.color,mode:this.mode,alpha:this.alpha}}}),i.Image.filters.BlendColor.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric,l=i.Image.filters,a=i.util.createClass;l.BlendImage=a(l.BaseFilter,{type:"BlendImage",image:null,mode:"multiply",alpha:1,vertexSource:`attribute vec2 aPosition;
329
329
  varying vec2 vTexCoord;
330
330
  varying vec2 vTexCoord2;
331
331
  uniform mat3 uTransformMatrix;
@@ -355,19 +355,19 @@ vec4 color = texture2D(uTexture, vTexCoord);
355
355
  vec4 color2 = texture2D(uImage, vTexCoord2);
356
356
  color.a = color2.a;
357
357
  gl_FragColor = color;
358
- }`},retrieveShader:function(t){var n=this.type+"_"+this.mode,e=this.fragmentSource[this.mode];return t.programCache.hasOwnProperty(n)||(t.programCache[n]=this.createProgram(t.context,e)),t.programCache[n]},applyToWebGL:function(t){var n=t.context,e=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(n,e,n.TEXTURE1),this.callSuper("applyToWebGL",t),this.unbindAdditionalTexture(n,n.TEXTURE1)},createTexture:function(t,n){return t.getCachedTexture(n.cacheKey,n._element)},calculateMatrix:function(){var t=this.image,n=t._element.width,e=t._element.height;return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/n,-t.top/e,1]},applyTo2d:function(t){var n=t.imageData,e=t.filterBackend.resources,o=n.data,h=o.length,s=n.width,u=n.height,d,m,g,v,b,S,E,F,R,z,q=this.image,Z;e.blendImage||(e.blendImage=i.util.createCanvasElement()),R=e.blendImage,z=R.getContext("2d"),R.width!==s||R.height!==u?(R.width=s,R.height=u):z.clearRect(0,0,s,u),z.setTransform(q.scaleX,0,0,q.scaleY,q.left,q.top),z.drawImage(q._element,0,0,s,u),Z=z.getImageData(0,0,s,u).data;for(var K=0;K<h;K+=4)switch(b=o[K],S=o[K+1],E=o[K+2],F=o[K+3],d=Z[K],m=Z[K+1],g=Z[K+2],v=Z[K+3],this.mode){case"multiply":o[K]=b*d/255,o[K+1]=S*m/255,o[K+2]=E*g/255,o[K+3]=F*v/255;break;case"mask":o[K+3]=v;break}},getUniformLocations:function(t,n){return{uTransformMatrix:t.getUniformLocation(n,"uTransformMatrix"),uImage:t.getUniformLocation(n,"uImage")}},sendUniformData:function(t,n){var e=this.calculateMatrix();t.uniform1i(n.uImage,1),t.uniformMatrix3fv(n.uTransformMatrix,!1,e)},toObject:function(){return{type:this.type,image:this.image&&this.image.toObject(),mode:this.mode,alpha:this.alpha}}}),i.Image.filters.BlendImage.fromObject=function(t,n){i.Image.fromObject(t.image,function(e){var o=i.util.object.clone(t);o.image=e,n(new i.Image.filters.BlendImage(o))})}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=Math.pow,a=Math.floor,t=Math.sqrt,n=Math.abs,e=Math.round,o=Math.sin,h=Math.ceil,s=i.Image.filters,u=i.util.createClass;s.Resize=u(s.BaseFilter,{type:"Resize",resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3,getUniformLocations:function(d,m){return{uDelta:d.getUniformLocation(m,"uDelta"),uTaps:d.getUniformLocation(m,"uTaps")}},sendUniformData:function(d,m){d.uniform2fv(m.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),d.uniform1fv(m.uTaps,this.taps)},retrieveShader:function(d){var m=this.getFilterWindow(),g=this.type+"_"+m;if(!d.programCache.hasOwnProperty(g)){var v=this.generateShader(m);d.programCache[g]=this.createProgram(d.context,v)}return d.programCache[g]},getFilterWindow:function(){var d=this.tempScale;return Math.ceil(this.lanczosLobes/d)},getTaps:function(){for(var d=this.lanczosCreate(this.lanczosLobes),m=this.tempScale,g=this.getFilterWindow(),v=new Array(g),b=1;b<=g;b++)v[b-1]=d(b*m);return v},generateShader:function(v){for(var m=new Array(v),g=this.fragmentSourceTOP,v,b=1;b<=v;b++)m[b-1]=b+".0 * uDelta";return g+="uniform float uTaps["+v+`];
359
- `,g+=`void main() {
360
- `,g+=` vec4 color = texture2D(uTexture, vTexCoord);
361
- `,g+=` float sum = 1.0;
362
- `,m.forEach(function(S,E){g+=" color += texture2D(uTexture, vTexCoord + "+S+") * uTaps["+E+`];
363
- `,g+=" color += texture2D(uTexture, vTexCoord - "+S+") * uTaps["+E+`];
364
- `,g+=" sum += 2.0 * uTaps["+E+`];
365
- `}),g+=` gl_FragColor = color / sum;
366
- `,g+="}",g},fragmentSourceTOP:`precision highp float;
358
+ }`},retrieveShader:function(t){var n=this.type+"_"+this.mode,e=this.fragmentSource[this.mode];return t.programCache.hasOwnProperty(n)||(t.programCache[n]=this.createProgram(t.context,e)),t.programCache[n]},applyToWebGL:function(t){var n=t.context,e=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(n,e,n.TEXTURE1),this.callSuper("applyToWebGL",t),this.unbindAdditionalTexture(n,n.TEXTURE1)},createTexture:function(t,n){return t.getCachedTexture(n.cacheKey,n._element)},calculateMatrix:function(){var t=this.image,n=t._element.width,e=t._element.height;return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/n,-t.top/e,1]},applyTo2d:function(t){var n=t.imageData,e=t.filterBackend.resources,o=n.data,h=o.length,s=n.width,u=n.height,d,m,p,v,b,S,E,F,R,z,K=this.image,Z;e.blendImage||(e.blendImage=i.util.createCanvasElement()),R=e.blendImage,z=R.getContext("2d"),R.width!==s||R.height!==u?(R.width=s,R.height=u):z.clearRect(0,0,s,u),z.setTransform(K.scaleX,0,0,K.scaleY,K.left,K.top),z.drawImage(K._element,0,0,s,u),Z=z.getImageData(0,0,s,u).data;for(var q=0;q<h;q+=4)switch(b=o[q],S=o[q+1],E=o[q+2],F=o[q+3],d=Z[q],m=Z[q+1],p=Z[q+2],v=Z[q+3],this.mode){case"multiply":o[q]=b*d/255,o[q+1]=S*m/255,o[q+2]=E*p/255,o[q+3]=F*v/255;break;case"mask":o[q+3]=v;break}},getUniformLocations:function(t,n){return{uTransformMatrix:t.getUniformLocation(n,"uTransformMatrix"),uImage:t.getUniformLocation(n,"uImage")}},sendUniformData:function(t,n){var e=this.calculateMatrix();t.uniform1i(n.uImage,1),t.uniformMatrix3fv(n.uTransformMatrix,!1,e)},toObject:function(){return{type:this.type,image:this.image&&this.image.toObject(),mode:this.mode,alpha:this.alpha}}}),i.Image.filters.BlendImage.fromObject=function(t,n){i.Image.fromObject(t.image,function(e){var o=i.util.object.clone(t);o.image=e,n(new i.Image.filters.BlendImage(o))})}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=Math.pow,a=Math.floor,t=Math.sqrt,n=Math.abs,e=Math.round,o=Math.sin,h=Math.ceil,s=i.Image.filters,u=i.util.createClass;s.Resize=u(s.BaseFilter,{type:"Resize",resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3,getUniformLocations:function(d,m){return{uDelta:d.getUniformLocation(m,"uDelta"),uTaps:d.getUniformLocation(m,"uTaps")}},sendUniformData:function(d,m){d.uniform2fv(m.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),d.uniform1fv(m.uTaps,this.taps)},retrieveShader:function(d){var m=this.getFilterWindow(),p=this.type+"_"+m;if(!d.programCache.hasOwnProperty(p)){var v=this.generateShader(m);d.programCache[p]=this.createProgram(d.context,v)}return d.programCache[p]},getFilterWindow:function(){var d=this.tempScale;return Math.ceil(this.lanczosLobes/d)},getTaps:function(){for(var d=this.lanczosCreate(this.lanczosLobes),m=this.tempScale,p=this.getFilterWindow(),v=new Array(p),b=1;b<=p;b++)v[b-1]=d(b*m);return v},generateShader:function(v){for(var m=new Array(v),p=this.fragmentSourceTOP,v,b=1;b<=v;b++)m[b-1]=b+".0 * uDelta";return p+="uniform float uTaps["+v+`];
359
+ `,p+=`void main() {
360
+ `,p+=` vec4 color = texture2D(uTexture, vTexCoord);
361
+ `,p+=` float sum = 1.0;
362
+ `,m.forEach(function(S,E){p+=" color += texture2D(uTexture, vTexCoord + "+S+") * uTaps["+E+`];
363
+ `,p+=" color += texture2D(uTexture, vTexCoord - "+S+") * uTaps["+E+`];
364
+ `,p+=" sum += 2.0 * uTaps["+E+`];
365
+ `}),p+=` gl_FragColor = color / sum;
366
+ `,p+="}",p},fragmentSourceTOP:`precision highp float;
367
367
  uniform sampler2D uTexture;
368
368
  uniform vec2 uDelta;
369
369
  varying vec2 vTexCoord;
370
- `,applyTo:function(d){d.webgl?(d.passes++,this.width=d.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=d.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),d.destinationWidth=this.dW,this._setupFrameBuffer(d),this.applyToWebGL(d),this._swapTextures(d),d.sourceWidth=d.destinationWidth,this.height=d.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),d.destinationHeight=this.dH,this._setupFrameBuffer(d),this.applyToWebGL(d),this._swapTextures(d),d.sourceHeight=d.destinationHeight):this.applyTo2d(d)},isNeutralState:function(){return this.scaleX===1&&this.scaleY===1},lanczosCreate:function(d){return function(m){if(m>=d||m<=-d)return 0;if(m<11920929e-14&&m>-11920929e-14)return 1;m*=Math.PI;var g=m/d;return o(m)/m*o(g)/g}},applyTo2d:function(d){var m=d.imageData,g=this.scaleX,v=this.scaleY;this.rcpScaleX=1/g,this.rcpScaleY=1/v;var b=m.width,S=m.height,E=e(b*g),F=e(S*v),R;this.resizeType==="sliceHack"?R=this.sliceByTwo(d,b,S,E,F):this.resizeType==="hermite"?R=this.hermiteFastResize(d,b,S,E,F):this.resizeType==="bilinear"?R=this.bilinearFiltering(d,b,S,E,F):this.resizeType==="lanczos"&&(R=this.lanczosResize(d,b,S,E,F)),d.imageData=R},sliceByTwo:function(d,m,g,v,b){var S=d.imageData,E=.5,F=!1,R=!1,z=m*E,q=g*E,Z=i.filterBackend.resources,K,$,tt=0,it=0,et=m,w=0;for(Z.sliceByTwo||(Z.sliceByTwo=document.createElement("canvas")),K=Z.sliceByTwo,(K.width<m*1.5||K.height<g)&&(K.width=m*1.5,K.height=g),$=K.getContext("2d"),$.clearRect(0,0,m*1.5,g),$.putImageData(S,0,0),v=a(v),b=a(b);!F||!R;)m=z,g=q,v<a(z*E)?z=a(z*E):(z=v,F=!0),b<a(q*E)?q=a(q*E):(q=b,R=!0),$.drawImage(K,tt,it,m,g,et,w,z,q),tt=et,it=w,w+=q;return $.getImageData(tt,it,v,b)},lanczosResize:function(d,m,g,v,b){function S(A){var P,I,O,x,D,L,N,j,V,G,J;for(w.x=(A+.5)*q,k.x=a(w.x),P=0;P<b;P++){for(w.y=(P+.5)*Z,k.y=a(w.y),D=0,L=0,N=0,j=0,V=0,I=k.x-tt;I<=k.x+tt;I++)if(!(I<0||I>=m)){G=a(1e3*n(I-w.x)),et[G]||(et[G]={});for(var B=k.y-it;B<=k.y+it;B++)B<0||B>=g||(J=a(1e3*n(B-w.y)),et[G][J]||(et[G][J]=z(t(l(G*K,2)+l(J*$,2))/1e3)),O=et[G][J],O>0&&(x=(B*m+I)*4,D+=O,L+=O*E[x],N+=O*E[x+1],j+=O*E[x+2],V+=O*E[x+3]))}x=(P*v+A)*4,R[x]=L/D,R[x+1]=N/D,R[x+2]=j/D,R[x+3]=V/D}return++A<v?S(A):F}var E=d.imageData.data,F=d.ctx.createImageData(v,b),R=F.data,z=this.lanczosCreate(this.lanczosLobes),q=this.rcpScaleX,Z=this.rcpScaleY,K=2/this.rcpScaleX,$=2/this.rcpScaleY,tt=h(q*this.lanczosLobes/2),it=h(Z*this.lanczosLobes/2),et={},w={},k={};return S(0)},bilinearFiltering:function(d,m,g,v,b){var S,E,F,R,z,q,Z,K,$,tt,it,et,w=0,k,A=this.rcpScaleX,P=this.rcpScaleY,I=4*(m-1),O=d.imageData,x=O.data,D=d.ctx.createImageData(v,b),L=D.data;for(Z=0;Z<b;Z++)for(K=0;K<v;K++)for(z=a(A*K),q=a(P*Z),$=A*K-z,tt=P*Z-q,k=4*(q*m+z),it=0;it<4;it++)S=x[k+it],E=x[k+4+it],F=x[k+I+it],R=x[k+I+4+it],et=S*(1-$)*(1-tt)+E*$*(1-tt)+F*tt*(1-$)+R*$*tt,L[w++]=et;return D},hermiteFastResize:function(d,m,g,v,b){for(var S=this.rcpScaleX,E=this.rcpScaleY,F=h(S/2),R=h(E/2),z=d.imageData,q=z.data,Z=d.ctx.createImageData(v,b),K=Z.data,$=0;$<b;$++)for(var tt=0;tt<v;tt++){for(var it=(tt+$*v)*4,et=0,w=0,k=0,A=0,P=0,I=0,O=0,x=($+.5)*E,D=a($*E);D<($+1)*E;D++)for(var L=n(x-(D+.5))/R,N=(tt+.5)*S,j=L*L,V=a(tt*S);V<(tt+1)*S;V++){var G=n(N-(V+.5))/F,J=t(j+G*G);J>1&&J<-1||(et=2*J*J*J-3*J*J+1,et>0&&(G=4*(V+D*m),O+=et*q[G+3],k+=et,q[G+3]<255&&(et=et*q[G+3]/250),A+=et*q[G],P+=et*q[G+1],I+=et*q[G+2],w+=et))}K[it]=A/w,K[it+1]=P/w,K[it+2]=I/w,K[it+3]=O/k}return Z},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),i.Image.filters.Resize.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass;l.Contrast=a(l.BaseFilter,{type:"Contrast",fragmentSource:`precision highp float;
370
+ `,applyTo:function(d){d.webgl?(d.passes++,this.width=d.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=d.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),d.destinationWidth=this.dW,this._setupFrameBuffer(d),this.applyToWebGL(d),this._swapTextures(d),d.sourceWidth=d.destinationWidth,this.height=d.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),d.destinationHeight=this.dH,this._setupFrameBuffer(d),this.applyToWebGL(d),this._swapTextures(d),d.sourceHeight=d.destinationHeight):this.applyTo2d(d)},isNeutralState:function(){return this.scaleX===1&&this.scaleY===1},lanczosCreate:function(d){return function(m){if(m>=d||m<=-d)return 0;if(m<11920929e-14&&m>-11920929e-14)return 1;m*=Math.PI;var p=m/d;return o(m)/m*o(p)/p}},applyTo2d:function(d){var m=d.imageData,p=this.scaleX,v=this.scaleY;this.rcpScaleX=1/p,this.rcpScaleY=1/v;var b=m.width,S=m.height,E=e(b*p),F=e(S*v),R;this.resizeType==="sliceHack"?R=this.sliceByTwo(d,b,S,E,F):this.resizeType==="hermite"?R=this.hermiteFastResize(d,b,S,E,F):this.resizeType==="bilinear"?R=this.bilinearFiltering(d,b,S,E,F):this.resizeType==="lanczos"&&(R=this.lanczosResize(d,b,S,E,F)),d.imageData=R},sliceByTwo:function(d,m,p,v,b){var S=d.imageData,E=.5,F=!1,R=!1,z=m*E,K=p*E,Z=i.filterBackend.resources,q,$,tt=0,it=0,et=m,w=0;for(Z.sliceByTwo||(Z.sliceByTwo=document.createElement("canvas")),q=Z.sliceByTwo,(q.width<m*1.5||q.height<p)&&(q.width=m*1.5,q.height=p),$=q.getContext("2d"),$.clearRect(0,0,m*1.5,p),$.putImageData(S,0,0),v=a(v),b=a(b);!F||!R;)m=z,p=K,v<a(z*E)?z=a(z*E):(z=v,F=!0),b<a(K*E)?K=a(K*E):(K=b,R=!0),$.drawImage(q,tt,it,m,p,et,w,z,K),tt=et,it=w,w+=K;return $.getImageData(tt,it,v,b)},lanczosResize:function(d,m,p,v,b){function S(A){var P,I,O,x,D,L,N,j,V,G,J;for(w.x=(A+.5)*K,k.x=a(w.x),P=0;P<b;P++){for(w.y=(P+.5)*Z,k.y=a(w.y),D=0,L=0,N=0,j=0,V=0,I=k.x-tt;I<=k.x+tt;I++)if(!(I<0||I>=m)){G=a(1e3*n(I-w.x)),et[G]||(et[G]={});for(var B=k.y-it;B<=k.y+it;B++)B<0||B>=p||(J=a(1e3*n(B-w.y)),et[G][J]||(et[G][J]=z(t(l(G*q,2)+l(J*$,2))/1e3)),O=et[G][J],O>0&&(x=(B*m+I)*4,D+=O,L+=O*E[x],N+=O*E[x+1],j+=O*E[x+2],V+=O*E[x+3]))}x=(P*v+A)*4,R[x]=L/D,R[x+1]=N/D,R[x+2]=j/D,R[x+3]=V/D}return++A<v?S(A):F}var E=d.imageData.data,F=d.ctx.createImageData(v,b),R=F.data,z=this.lanczosCreate(this.lanczosLobes),K=this.rcpScaleX,Z=this.rcpScaleY,q=2/this.rcpScaleX,$=2/this.rcpScaleY,tt=h(K*this.lanczosLobes/2),it=h(Z*this.lanczosLobes/2),et={},w={},k={};return S(0)},bilinearFiltering:function(d,m,p,v,b){var S,E,F,R,z,K,Z,q,$,tt,it,et,w=0,k,A=this.rcpScaleX,P=this.rcpScaleY,I=4*(m-1),O=d.imageData,x=O.data,D=d.ctx.createImageData(v,b),L=D.data;for(Z=0;Z<b;Z++)for(q=0;q<v;q++)for(z=a(A*q),K=a(P*Z),$=A*q-z,tt=P*Z-K,k=4*(K*m+z),it=0;it<4;it++)S=x[k+it],E=x[k+4+it],F=x[k+I+it],R=x[k+I+4+it],et=S*(1-$)*(1-tt)+E*$*(1-tt)+F*tt*(1-$)+R*$*tt,L[w++]=et;return D},hermiteFastResize:function(d,m,p,v,b){for(var S=this.rcpScaleX,E=this.rcpScaleY,F=h(S/2),R=h(E/2),z=d.imageData,K=z.data,Z=d.ctx.createImageData(v,b),q=Z.data,$=0;$<b;$++)for(var tt=0;tt<v;tt++){for(var it=(tt+$*v)*4,et=0,w=0,k=0,A=0,P=0,I=0,O=0,x=($+.5)*E,D=a($*E);D<($+1)*E;D++)for(var L=n(x-(D+.5))/R,N=(tt+.5)*S,j=L*L,V=a(tt*S);V<(tt+1)*S;V++){var G=n(N-(V+.5))/F,J=t(j+G*G);J>1&&J<-1||(et=2*J*J*J-3*J*J+1,et>0&&(G=4*(V+D*m),O+=et*K[G+3],k+=et,K[G+3]<255&&(et=et*K[G+3]/250),A+=et*K[G],P+=et*K[G+1],I+=et*K[G+2],w+=et))}q[it]=A/w,q[it+1]=P/w,q[it+2]=I/w,q[it+3]=O/k}return Z},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),i.Image.filters.Resize.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass;l.Contrast=a(l.BaseFilter,{type:"Contrast",fragmentSource:`precision highp float;
371
371
  uniform sampler2D uTexture;
372
372
  uniform float uContrast;
373
373
  varying vec2 vTexCoord;
@@ -421,7 +421,7 @@ color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;
421
421
  total += weight;
422
422
  }
423
423
  gl_FragColor = color / total;
424
- }`,blur:0,mainParameter:"blur",applyTo:function(t){t.webgl?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},applyTo2d:function(t){t.imageData=this.simpleBlur(t)},simpleBlur:function(t){var n=t.filterBackend.resources,e,o,h=t.imageData.width,s=t.imageData.height;n.blurLayer1||(n.blurLayer1=i.util.createCanvasElement(),n.blurLayer2=i.util.createCanvasElement()),e=n.blurLayer1,o=n.blurLayer2,(e.width!==h||e.height!==s)&&(o.width=e.width=h,o.height=e.height=s);var u=e.getContext("2d"),d=o.getContext("2d"),m=15,g,v,b,S,E=this.blur*.06*.5;for(u.putImageData(t.imageData,0,0),d.clearRect(0,0,h,s),S=-m;S<=m;S++)g=(Math.random()-.5)/4,v=S/m,b=E*v*h+g,d.globalAlpha=1-Math.abs(v),d.drawImage(e,b,g),u.drawImage(o,0,0),d.globalAlpha=1,d.clearRect(0,0,o.width,o.height);for(S=-m;S<=m;S++)g=(Math.random()-.5)/4,v=S/m,b=E*v*s+g,d.globalAlpha=1-Math.abs(v),d.drawImage(e,g,b),u.drawImage(o,0,0),d.globalAlpha=1,d.clearRect(0,0,o.width,o.height);t.ctx.drawImage(e,0,0);var F=t.ctx.getImageData(0,0,e.width,e.height);return u.globalAlpha=1,u.clearRect(0,0,e.width,e.height),F},getUniformLocations:function(t,n){return{delta:t.getUniformLocation(n,"uDelta")}},sendUniformData:function(t,n){var e=this.chooseRightDelta();t.uniform2fv(n.delta,e)},chooseRightDelta:function(){var t=1,n=[0,0],e;return this.horizontal?this.aspectRatio>1&&(t=1/this.aspectRatio):this.aspectRatio<1&&(t=this.aspectRatio),e=t*this.blur*.12,this.horizontal?n[0]=e:n[1]=e,n}}),l.Blur.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass;l.Gamma=a(l.BaseFilter,{type:"Gamma",fragmentSource:`precision highp float;
424
+ }`,blur:0,mainParameter:"blur",applyTo:function(t){t.webgl?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},applyTo2d:function(t){t.imageData=this.simpleBlur(t)},simpleBlur:function(t){var n=t.filterBackend.resources,e,o,h=t.imageData.width,s=t.imageData.height;n.blurLayer1||(n.blurLayer1=i.util.createCanvasElement(),n.blurLayer2=i.util.createCanvasElement()),e=n.blurLayer1,o=n.blurLayer2,(e.width!==h||e.height!==s)&&(o.width=e.width=h,o.height=e.height=s);var u=e.getContext("2d"),d=o.getContext("2d"),m=15,p,v,b,S,E=this.blur*.06*.5;for(u.putImageData(t.imageData,0,0),d.clearRect(0,0,h,s),S=-m;S<=m;S++)p=(Math.random()-.5)/4,v=S/m,b=E*v*h+p,d.globalAlpha=1-Math.abs(v),d.drawImage(e,b,p),u.drawImage(o,0,0),d.globalAlpha=1,d.clearRect(0,0,o.width,o.height);for(S=-m;S<=m;S++)p=(Math.random()-.5)/4,v=S/m,b=E*v*s+p,d.globalAlpha=1-Math.abs(v),d.drawImage(e,p,b),u.drawImage(o,0,0),d.globalAlpha=1,d.clearRect(0,0,o.width,o.height);t.ctx.drawImage(e,0,0);var F=t.ctx.getImageData(0,0,e.width,e.height);return u.globalAlpha=1,u.clearRect(0,0,e.width,e.height),F},getUniformLocations:function(t,n){return{delta:t.getUniformLocation(n,"uDelta")}},sendUniformData:function(t,n){var e=this.chooseRightDelta();t.uniform2fv(n.delta,e)},chooseRightDelta:function(){var t=1,n=[0,0],e;return this.horizontal?this.aspectRatio>1&&(t=1/this.aspectRatio):this.aspectRatio<1&&(t=this.aspectRatio),e=t*this.blur*.12,this.horizontal?n[0]=e:n[1]=e,n}}),l.Blur.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass;l.Gamma=a(l.BaseFilter,{type:"Gamma",fragmentSource:`precision highp float;
425
425
  uniform sampler2D uTexture;
426
426
  uniform vec3 uGamma;
427
427
  varying vec2 vTexCoord;
@@ -433,12 +433,12 @@ color.g = pow(color.g, correction.g);
433
433
  color.b = pow(color.b, correction.b);
434
434
  gl_FragColor = color;
435
435
  gl_FragColor.rgb *= color.a;
436
- }`,gamma:[1,1,1],mainParameter:"gamma",initialize:function(t){this.gamma=[1,1,1],l.BaseFilter.prototype.initialize.call(this,t)},applyTo2d:function(t){var n=t.imageData,e=n.data,o=this.gamma,h=e.length,s=1/o[0],u=1/o[1],d=1/o[2],m;for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),m=0,h=256;m<h;m++)this.rVals[m]=Math.pow(m/255,s)*255,this.gVals[m]=Math.pow(m/255,u)*255,this.bVals[m]=Math.pow(m/255,d)*255;for(m=0,h=e.length;m<h;m+=4)e[m]=this.rVals[e[m]],e[m+1]=this.gVals[e[m+1]],e[m+2]=this.bVals[e[m+2]]},getUniformLocations:function(t,n){return{uGamma:t.getUniformLocation(n,"uGamma")}},sendUniformData:function(t,n){t.uniform3fv(n.uGamma,this.gamma)}}),i.Image.filters.Gamma.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass;l.Composed=a(l.BaseFilter,{type:"Composed",subFilters:[],initialize:function(t){this.callSuper("initialize",t),this.subFilters=this.subFilters.slice(0)},applyTo:function(t){t.passes+=this.subFilters.length-1,this.subFilters.forEach(function(n){n.applyTo(t)})},toObject:function(){return i.util.object.extend(this.callSuper("toObject"),{subFilters:this.subFilters.map(function(t){return t.toObject()})})},isNeutralState:function(){return!this.subFilters.some(function(t){return!t.isNeutralState()})}}),i.Image.filters.Composed.fromObject=function(t,n){var e=t.subFilters||[],o=e.map(function(s){return new i.Image.filters[s.type](s)}),h=new i.Image.filters.Composed({subFilters:o});return n&&n(h),h}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass;l.HueRotation=a(l.ColorMatrix,{type:"HueRotation",rotation:0,mainParameter:"rotation",calculateMatrix:function(){var t=this.rotation*Math.PI,n=i.util.cos(t),e=i.util.sin(t),o=1/3,h=Math.sqrt(o)*e,s=1-n;this.matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],this.matrix[0]=n+s/3,this.matrix[1]=o*s-h,this.matrix[2]=o*s+h,this.matrix[5]=o*s+h,this.matrix[6]=n+o*s,this.matrix[7]=o*s-h,this.matrix[10]=o*s-h,this.matrix[11]=o*s+h,this.matrix[12]=n+o*s},isNeutralState:function(t){return this.calculateMatrix(),l.BaseFilter.prototype.isNeutralState.call(this,t)},applyTo:function(t){this.calculateMatrix(),l.BaseFilter.prototype.applyTo.call(this,t)}}),i.Image.filters.HueRotation.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.object.clone;if(i.Text){i.warn("fabric.Text is already defined");return}var a="fontFamily fontWeight fontSize text underline overline linethrough textAlign fontStyle lineHeight textBackgroundColor charSpacing styles direction path pathStartOffset pathSide pathAlign".split(" ");i.Text=i.util.createClass(i.Object,{_dimensionAffectingProps:["fontSize","fontWeight","fontFamily","fontStyle","lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],_reNewline:/\r?\n/,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,type:"text",fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:"left",fontStyle:"normal",lineHeight:1.16,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},textBackgroundColor:"",stateProperties:i.Object.prototype.stateProperties.concat(a),cacheProperties:i.Object.prototype.cacheProperties.concat(a),stroke:null,shadow:null,path:null,pathStartOffset:0,pathSide:"left",pathAlign:"baseline",_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.315,overline:-.88},_fontSizeMult:1.13,charSpacing:0,styles:null,_measuringContext:null,deltaY:0,direction:"ltr",_styleProperties:["stroke","strokeWidth","fill","fontFamily","fontSize","fontWeight","fontStyle","underline","overline","linethrough","deltaY","textBackgroundColor"],__charBounds:[],CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,initialize:function(t,n){this.styles=n?n.styles||{}:{},this.text=t,this.__skipDimension=!0,this.callSuper("initialize",n),this.path&&this.setPathInfo(),this.__skipDimension=!1,this.initDimensions(),this.setCoords(),this.setupState({propertySet:"_dimensionAffectingProps"})},setPathInfo:function(){var t=this.path;t&&(t.segmentsInfo=i.util.getPathSegmentsInfo(t.path))},getMeasuringContext:function(){return i._measuringContext||(i._measuringContext=this.canvas&&this.canvas.contextCache||i.util.createCanvasElement().getContext("2d")),i._measuringContext},_splitText:function(){var t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t},initDimensions:function(){this.__skipDimension||(this._splitText(),this._clearCache(),this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.indexOf("justify")!==-1&&this.enlargeSpaces(),this.saveState({propertySet:"_dimensionAffectingProps"}))},enlargeSpaces:function(){for(var t,n,e,o,h,s,u,d=0,m=this._textLines.length;d<m;d++)if(!(this.textAlign!=="justify"&&(d===m-1||this.isEndOfWrapping(d)))&&(o=0,h=this._textLines[d],n=this.getLineWidth(d),n<this.width&&(u=this.textLines[d].match(this._reSpacesAndTabs)))){e=u.length,t=(this.width-n)/e;for(var g=0,v=h.length;g<=v;g++)s=this.__charBounds[d][g],this._reSpaceAndTab.test(h[g])?(s.width+=t,s.kernedWidth+=t,s.left+=o,o+=t):s.left+=o}},isEndOfWrapping:function(t){return t===this._textLines.length-1},missingNewlineOffset:function(){return 1},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_getCacheCanvasDimensions:function(){var t=this.callSuper("_getCacheCanvasDimensions"),n=this.fontSize;return t.width+=n*t.zoomX,t.height+=n*t.zoomY,t},_render:function(t){var n=this.path;n&&!n.isNotVisible()&&n._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")},_renderText:function(t){this.paintFirst==="stroke"?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))},_setTextStyles:function(t,n,e){if(t.textBaseline="alphabetical",this.path)switch(this.pathAlign){case"center":t.textBaseline="middle";break;case"ascender":t.textBaseline="top";break;case"descender":t.textBaseline="bottom";break}t.font=this._getFontDeclaration(n,e)},calcTextWidth:function(){for(var t=this.getLineWidth(0),n=1,e=this._textLines.length;n<e;n++){var o=this.getLineWidth(n);o>t&&(t=o)}return t},_renderTextLine:function(t,n,e,o,h,s){this._renderChars(t,n,e,o,h,s)},_renderTextLinesBackground:function(t){if(!(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))){for(var n,e,o=t.fillStyle,h,s,u=this._getLeftOffset(),d=this._getTopOffset(),m=0,g=0,v,b,S=this.path,E,F=0,R=this._textLines.length;F<R;F++){if(n=this.getHeightOfLine(F),!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",F)){d+=n;continue}h=this._textLines[F],e=this._getLineLeftOffset(F),g=0,m=0,s=this.getValueOfPropertyAt(F,0,"textBackgroundColor");for(var z=0,q=h.length;z<q;z++)v=this.__charBounds[F][z],b=this.getValueOfPropertyAt(F,z,"textBackgroundColor"),S?(t.save(),t.translate(v.renderLeft,v.renderTop),t.rotate(v.angle),t.fillStyle=b,b&&t.fillRect(-v.width/2,-n/this.lineHeight*(1-this._fontSizeFraction),v.width,n/this.lineHeight),t.restore()):b!==s?(E=u+e+m,this.direction==="rtl"&&(E=this.width-E-g),t.fillStyle=s,s&&t.fillRect(E,d,g,n/this.lineHeight),m=v.left,g=v.width,s=b):g+=v.kernedWidth;b&&!S&&(E=u+e+m,this.direction==="rtl"&&(E=this.width-E-g),t.fillStyle=b,t.fillRect(E,d,g,n/this.lineHeight)),d+=n}t.fillStyle=o,this._removeShadow(t)}},getFontCache:function(t){var n=t.fontFamily.toLowerCase();i.charWidthsCache[n]||(i.charWidthsCache[n]={});var e=i.charWidthsCache[n],o=t.fontStyle.toLowerCase()+"_"+(t.fontWeight+"").toLowerCase();return e[o]||(e[o]={}),e[o]},_measureChar:function(t,n,e,o){var h=this.getFontCache(n),s=this._getFontDeclaration(n),u=this._getFontDeclaration(o),d=e+t,m=s===u,g,v,b,S=n.fontSize/this.CACHE_FONT_SIZE,E;if(e&&h[e]!==void 0&&(b=h[e]),h[t]!==void 0&&(E=g=h[t]),m&&h[d]!==void 0&&(v=h[d],E=v-b),g===void 0||b===void 0||v===void 0){var F=this.getMeasuringContext();this._setTextStyles(F,n,!0)}return g===void 0&&(E=g=F.measureText(t).width,h[t]=g),b===void 0&&m&&e&&(b=F.measureText(e).width,h[e]=b),m&&v===void 0&&(v=F.measureText(d).width,h[d]=v,E=v-b),{width:g*S,kernedWidth:E*S}},getHeightOfChar:function(t,n){return this.getValueOfPropertyAt(t,n,"fontSize")},measureLine:function(t){var n=this._measureLine(t);return this.charSpacing!==0&&(n.width-=this._getWidthOfCharSpacing()),n.width<0&&(n.width=0),n},_measureLine:function(t){var n=0,e,o,h=this._textLines[t],s,u,d=0,m=new Array(h.length),g=0,v,b,S=this.path,E=this.pathSide==="right";for(this.__charBounds[t]=m,e=0;e<h.length;e++)o=h[e],u=this._getGraphemeBox(o,t,e,s),m[e]=u,n+=u.kernedWidth,s=o;if(m[e]={left:u?u.left+u.width:0,width:0,kernedWidth:0,height:this.fontSize},S){switch(b=S.segmentsInfo[S.segmentsInfo.length-1].length,v=i.util.getPointOnPath(S.path,0,S.segmentsInfo),v.x+=S.pathOffset.x,v.y+=S.pathOffset.y,this.textAlign){case"left":g=E?b-n:0;break;case"center":g=(b-n)/2;break;case"right":g=E?0:b-n;break}for(g+=this.pathStartOffset*(E?-1:1),e=E?h.length-1:0;E?e>=0:e<h.length;E?e--:e++)u=m[e],g>b?g%=b:g<0&&(g+=b),this._setGraphemeOnPath(g,u,v),g+=u.kernedWidth}return{width:n,numOfSpaces:d}},_setGraphemeOnPath:function(t,n,e){var o=t+n.kernedWidth/2,h=this.path,s=i.util.getPointOnPath(h.path,o,h.segmentsInfo);n.renderLeft=s.x-e.x,n.renderTop=s.y-e.y,n.angle=s.angle+(this.pathSide==="right"?Math.PI:0)},_getGraphemeBox:function(t,n,e,o,h){var s=this.getCompleteStyleDeclaration(n,e),u=o?this.getCompleteStyleDeclaration(n,e-1):{},d=this._measureChar(t,s,o,u),m=d.kernedWidth,g=d.width,v;this.charSpacing!==0&&(v=this._getWidthOfCharSpacing(),g+=v,m+=v);var b={width:g,left:0,height:s.fontSize,kernedWidth:m,deltaY:s.deltaY};if(e>0&&!h){var S=this.__charBounds[n][e-1];b.left=S.left+S.width+d.kernedWidth-d.width}return b},getHeightOfLine:function(t){if(this.__lineHeights[t])return this.__lineHeights[t];for(var n=this._textLines[t],e=this.getHeightOfChar(t,0),o=1,h=n.length;o<h;o++)e=Math.max(this.getHeightOfChar(t,o),e);return this.__lineHeights[t]=e*this.lineHeight*this._fontSizeMult},calcTextHeight:function(){for(var t,n=0,e=0,o=this._textLines.length;e<o;e++)t=this.getHeightOfLine(e),n+=e===o-1?t/this.lineHeight:t;return n},_getLeftOffset:function(){return this.direction==="ltr"?-this.width/2:this.width/2},_getTopOffset:function(){return-this.height/2},_renderTextCommon:function(t,n){t.save();for(var e=0,o=this._getLeftOffset(),h=this._getTopOffset(),s=0,u=this._textLines.length;s<u;s++){var d=this.getHeightOfLine(s),m=d/this.lineHeight,g=this._getLineLeftOffset(s);this._renderTextLine(n,t,this._textLines[s],o+g,h+e+m,s),e+=d}t.restore()},_renderTextFill:function(t){!this.fill&&!this.styleHas("fill")||this._renderTextCommon(t,"fillText")},_renderTextStroke:function(t){(!this.stroke||this.strokeWidth===0)&&this.isEmptyStyles()||(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())},_renderChars:function(t,n,e,o,h,s){var u=this.getHeightOfLine(s),d=this.textAlign.indexOf("justify")!==-1,m,g,v="",b,S=0,E,F=this.path,R=!d&&this.charSpacing===0&&this.isEmptyStyles(s)&&!F,z=this.direction==="ltr",q=this.direction==="ltr"?1:-1,Z,K=n.canvas.getAttribute("dir");if(n.save(),K!==this.direction&&(n.canvas.setAttribute("dir",z?"ltr":"rtl"),n.direction=z?"ltr":"rtl",n.textAlign=z?"left":"right"),h-=u*this._fontSizeFraction/this.lineHeight,R){this._renderChar(t,n,s,0,e.join(""),o,h,u),n.restore();return}for(var $=0,tt=e.length-1;$<=tt;$++)E=$===tt||this.charSpacing||F,v+=e[$],b=this.__charBounds[s][$],S===0?(o+=q*(b.kernedWidth-b.width),S+=b.width):S+=b.kernedWidth,d&&!E&&this._reSpaceAndTab.test(e[$])&&(E=!0),E||(m=m||this.getCompleteStyleDeclaration(s,$),g=this.getCompleteStyleDeclaration(s,$+1),E=i.util.hasStyleChanged(m,g,!1)),E&&(F?(n.save(),n.translate(b.renderLeft,b.renderTop),n.rotate(b.angle),this._renderChar(t,n,s,$,v,-S/2,0,u),n.restore()):(Z=o,this._renderChar(t,n,s,$,v,Z,h,u)),v="",m=g,o+=q*S,S=0);n.restore()},_applyPatternGradientTransformText:function(t){var n=i.util.createCanvasElement(),e,o=this.width+this.strokeWidth,h=this.height+this.strokeWidth;return n.width=o,n.height=h,e=n.getContext("2d"),e.beginPath(),e.moveTo(0,0),e.lineTo(o,0),e.lineTo(o,h),e.lineTo(0,h),e.closePath(),e.translate(o/2,h/2),e.fillStyle=t.toLive(e),this._applyPatternGradientTransform(e,t),e.fill(),e.createPattern(n,"no-repeat")},handleFiller:function(t,n,e){var o,h;return e.toLive?e.gradientUnits==="percentage"||e.gradientTransform||e.patternTransform?(o=-this.width/2,h=-this.height/2,t.translate(o,h),t[n]=this._applyPatternGradientTransformText(e),{offsetX:o,offsetY:h}):(t[n]=e.toLive(t,this),this._applyPatternGradientTransform(t,e)):(t[n]=e,{offsetX:0,offsetY:0})},_setStrokeStyles:function(t,n){return t.lineWidth=n.strokeWidth,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",n.stroke)},_setFillStyles:function(t,n){return this.handleFiller(t,"fillStyle",n.fill)},_renderChar:function(t,n,e,o,h,s,u){var d=this._getStyleDeclaration(e,o),m=this.getCompleteStyleDeclaration(e,o),g=t==="fillText"&&m.fill,v=t==="strokeText"&&m.stroke&&m.strokeWidth,b,S;!v&&!g||(n.save(),g&&(b=this._setFillStyles(n,m)),v&&(S=this._setStrokeStyles(n,m)),n.font=this._getFontDeclaration(m),d&&d.textBackgroundColor&&this._removeShadow(n),d&&d.deltaY&&(u+=d.deltaY),g&&n.fillText(h,s-b.offsetX,u-b.offsetY),v&&n.strokeText(h,s-S.offsetX,u-S.offsetY),n.restore())},setSuperscript:function(t,n){return this._setScript(t,n,this.superscript)},setSubscript:function(t,n){return this._setScript(t,n,this.subscript)},_setScript:function(t,n,e){var o=this.get2DCursorLocation(t,!0),h=this.getValueOfPropertyAt(o.lineIndex,o.charIndex,"fontSize"),s=this.getValueOfPropertyAt(o.lineIndex,o.charIndex,"deltaY"),u={fontSize:h*e.size,deltaY:s+h*e.baseline};return this.setSelectionStyles(u,t,n),this},_getLineLeftOffset:function(t){var n=this.getLineWidth(t),e=this.width-n,o=this.textAlign,h=this.direction,u,s=0,u=this.isEndOfWrapping(t);return o==="justify"||o==="justify-center"&&!u||o==="justify-right"&&!u||o==="justify-left"&&!u?0:(o==="center"&&(s=e/2),o==="right"&&(s=e),o==="justify-center"&&(s=e/2),o==="justify-right"&&(s=e),h==="rtl"&&(s-=e),s)},_clearCache:function(){this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]},_shouldClearDimensionCache:function(){var t=this._forceClearCache;return t||(t=this.hasStateChanged("_dimensionAffectingProps")),t&&(this.dirty=!0,this._forceClearCache=!1),t},getLineWidth:function(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];var n=this.measureLine(t),e=n.width;return this.__lineWidths[t]=e,e},_getWidthOfCharSpacing:function(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0},getValueOfPropertyAt:function(t,n,e){var o=this._getStyleDeclaration(t,n);return o&&typeof o[e]<"u"?o[e]:this[e]},_renderTextDecoration:function(t,n){if(!(!this[n]&&!this.styleHas(n))){for(var e,o,h,s,u,d,m,g,v=this._getLeftOffset(),b=this._getTopOffset(),S,E,F,R,z,q,Z,K,$=this.path,tt=this._getWidthOfCharSpacing(),it=this.offsets[n],et=0,w=this._textLines.length;et<w;et++){if(e=this.getHeightOfLine(et),!this[n]&&!this.styleHas(n,et)){b+=e;continue}m=this._textLines[et],q=e/this.lineHeight,s=this._getLineLeftOffset(et),E=0,F=0,g=this.getValueOfPropertyAt(et,0,n),K=this.getValueOfPropertyAt(et,0,"fill"),S=b+q*(1-this._fontSizeFraction),o=this.getHeightOfChar(et,0),u=this.getValueOfPropertyAt(et,0,"deltaY");for(var k=0,A=m.length;k<A;k++)if(R=this.__charBounds[et][k],z=this.getValueOfPropertyAt(et,k,n),Z=this.getValueOfPropertyAt(et,k,"fill"),h=this.getHeightOfChar(et,k),d=this.getValueOfPropertyAt(et,k,"deltaY"),$&&z&&Z)t.save(),t.fillStyle=K,t.translate(R.renderLeft,R.renderTop),t.rotate(R.angle),t.fillRect(-R.kernedWidth/2,it*h+d,R.kernedWidth,this.fontSize/15),t.restore();else if((z!==g||Z!==K||h!==o||d!==u)&&F>0){var P=v+s+E;this.direction==="rtl"&&(P=this.width-P-F),g&&K&&(t.fillStyle=K,t.fillRect(P,S+it*o+u,F,this.fontSize/15)),E=R.left,F=R.width,g=z,K=Z,o=h,u=d}else F+=R.kernedWidth;var P=v+s+E;this.direction==="rtl"&&(P=this.width-P-F),t.fillStyle=Z,z&&Z&&t.fillRect(P,S+it*o+u,F-tt,this.fontSize/15),b+=e}this._removeShadow(t)}},_getFontDeclaration:function(t,n){var e=t||this,o=this.fontFamily,h=i.Text.genericFonts.indexOf(o.toLowerCase())>-1,s=o===void 0||o.indexOf("'")>-1||o.indexOf(",")>-1||o.indexOf('"')>-1||h?e.fontFamily:'"'+e.fontFamily+'"';return[i.isLikelyNode?e.fontWeight:e.fontStyle,i.isLikelyNode?e.fontStyle:e.fontWeight,n?this.CACHE_FONT_SIZE+"px":e.fontSize+"px",s].join(" ")},render:function(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",t)))},_splitTextIntoLines:function(t){for(var n=t.split(this._reNewline),e=new Array(n.length),o=[`
437
- `],h=[],s=0;s<n.length;s++)e[s]=i.util.string.graphemeSplit(n[s]),h=h.concat(e[s],o);return h.pop(),{_unwrappedLines:e,lines:n,graphemeText:h,graphemeLines:e}},toObject:function(t){var n=a.concat(t),e=this.callSuper("toObject",n);return e.styles=i.util.stylesToArray(this.styles,this.text),e.path&&(e.path=this.path.toObject()),e},set:function(t,n){this.callSuper("set",t,n);var e=!1,o=!1;if(typeof t=="object")for(var h in t)h==="path"&&this.setPathInfo(),e=e||this._dimensionAffectingProps.indexOf(h)!==-1,o=o||h==="path";else e=this._dimensionAffectingProps.indexOf(t)!==-1,o=t==="path";return o&&this.setPathInfo(),e&&(this.initDimensions(),this.setCoords()),this},complexity:function(){return 1}}),i.Text.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("x y dx dy font-family font-style font-weight font-size letter-spacing text-decoration text-anchor".split(" ")),i.Text.DEFAULT_SVG_FONT_SIZE=16,i.Text.fromElement=function(t,n,e){if(!t)return n(null);var o=i.parseAttributes(t,i.Text.ATTRIBUTE_NAMES),h=o.textAnchor||"left";if(e=i.util.object.extend(e?l(e):{},o),e.top=e.top||0,e.left=e.left||0,o.textDecoration){var s=o.textDecoration;s.indexOf("underline")!==-1&&(e.underline=!0),s.indexOf("overline")!==-1&&(e.overline=!0),s.indexOf("line-through")!==-1&&(e.linethrough=!0),delete e.textDecoration}"dx"in o&&(e.left+=o.dx),"dy"in o&&(e.top+=o.dy),"fontSize"in e||(e.fontSize=i.Text.DEFAULT_SVG_FONT_SIZE);var u="";"textContent"in t?u=t.textContent:"firstChild"in t&&t.firstChild!==null&&"data"in t.firstChild&&t.firstChild.data!==null&&(u=t.firstChild.data),u=u.replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," ");var d=e.strokeWidth;e.strokeWidth=0;var m=new i.Text(u,e),g=m.getScaledHeight()/m.height,v=(m.height+m.strokeWidth)*m.lineHeight-m.height,b=v*g,S=m.getScaledHeight()+b,E=0;h==="center"&&(E=m.getScaledWidth()/2),h==="right"&&(E=m.getScaledWidth()),m.set({left:m.left-E,top:m.top-(S-m.fontSize*(.07+m._fontSizeFraction))/m.lineHeight,strokeWidth:typeof d<"u"?d:1}),n(m)},i.Text.fromObject=function(t,n){var e=l(t),o=t.path;return delete e.path,i.Object._fromObject("Text",e,function(h){h.styles=i.util.stylesFromArray(t.styles,t.text),o?i.Object._fromObject("Path",o,function(s){h.set("path",s),n(h)},"path"):n(h)},"text")},i.Text.genericFonts=["sans-serif","serif","cursive","fantasy","monospace"],i.util.createAccessors&&i.util.createAccessors(i.Text)})(f),(function(){r.util.object.extend(r.Text.prototype,{isEmptyStyles:function(c){if(!this.styles||typeof c<"u"&&!this.styles[c])return!0;var i=typeof c>"u"?this.styles:{line:this.styles[c]};for(var l in i)for(var a in i[l])for(var t in i[l][a])return!1;return!0},styleHas:function(c,i){if(!this.styles||!c||c===""||typeof i<"u"&&!this.styles[i])return!1;var l=typeof i>"u"?this.styles:{0:this.styles[i]};for(var a in l)for(var t in l[a])if(typeof l[a][t][c]<"u")return!0;return!1},cleanStyle:function(c){if(!this.styles||!c||c==="")return!1;var i=this.styles,l=0,a,t,n=!0,e=0,o;for(var h in i){a=0;for(var s in i[h]){var o=i[h][s],u=o.hasOwnProperty(c);l++,u?(t?o[c]!==t&&(n=!1):t=o[c],o[c]===this[c]&&delete o[c]):n=!1,Object.keys(o).length!==0?a++:delete i[h][s]}a===0&&delete i[h]}for(var d=0;d<this._textLines.length;d++)e+=this._textLines[d].length;n&&l===e&&(this[c]=t,this.removeStyle(c))},removeStyle:function(c){if(!(!this.styles||!c||c==="")){var i=this.styles,l,a,t;for(a in i){l=i[a];for(t in l)delete l[t][c],Object.keys(l[t]).length===0&&delete l[t];Object.keys(l).length===0&&delete i[a]}}},_extendStyles:function(c,i){var l=this.get2DCursorLocation(c);this._getLineStyle(l.lineIndex)||this._setLineStyle(l.lineIndex),this._getStyleDeclaration(l.lineIndex,l.charIndex)||this._setStyleDeclaration(l.lineIndex,l.charIndex,{}),r.util.object.extend(this._getStyleDeclaration(l.lineIndex,l.charIndex),i)},get2DCursorLocation:function(c,i){typeof c>"u"&&(c=this.selectionStart);for(var l=i?this._unwrappedTextLines:this._textLines,a=l.length,t=0;t<a;t++){if(c<=l[t].length)return{lineIndex:t,charIndex:c};c-=l[t].length+this.missingNewlineOffset(t)}return{lineIndex:t-1,charIndex:l[t-1].length<c?l[t-1].length:c}},getSelectionStyles:function(c,i,l){typeof c>"u"&&(c=this.selectionStart||0),typeof i>"u"&&(i=this.selectionEnd||c);for(var a=[],t=c;t<i;t++)a.push(this.getStyleAtPosition(t,l));return a},getStyleAtPosition:function(c,i){var l=this.get2DCursorLocation(c),a=i?this.getCompleteStyleDeclaration(l.lineIndex,l.charIndex):this._getStyleDeclaration(l.lineIndex,l.charIndex);return a||{}},setSelectionStyles:function(c,i,l){typeof i>"u"&&(i=this.selectionStart||0),typeof l>"u"&&(l=this.selectionEnd||i);for(var a=i;a<l;a++)this._extendStyles(a,c);return this._forceClearCache=!0,this},_getStyleDeclaration:function(c,i){var l=this.styles&&this.styles[c];return l?l[i]:null},getCompleteStyleDeclaration:function(c,i){for(var l=this._getStyleDeclaration(c,i)||{},a={},t,n=0;n<this._styleProperties.length;n++)t=this._styleProperties[n],a[t]=typeof l[t]>"u"?this[t]:l[t];return a},_setStyleDeclaration:function(c,i,l){this.styles[c][i]=l},_deleteStyleDeclaration:function(c,i){delete this.styles[c][i]},_getLineStyle:function(c){return!!this.styles[c]},_setLineStyle:function(c){this.styles[c]={}},_deleteLineStyle:function(c){delete this.styles[c]}})})(),(function(){function c(i){i.textDecoration&&(i.textDecoration.indexOf("underline")>-1&&(i.underline=!0),i.textDecoration.indexOf("line-through")>-1&&(i.linethrough=!0),i.textDecoration.indexOf("overline")>-1&&(i.overline=!0),delete i.textDecoration)}r.IText=r.util.createClass(r.Text,r.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(i,l){this.callSuper("initialize",i,l),this.initBehavior()},setSelectionStart:function(i){i=Math.max(i,0),this._updateAndFire("selectionStart",i)},setSelectionEnd:function(i){i=Math.min(i,this.text.length),this._updateAndFire("selectionEnd",i)},_updateAndFire:function(i,l){this[i]!==l&&(this._fireSelectionChanged(),this[i]=l),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(i){this.clearContextTop(),this.callSuper("render",i),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(i){this.callSuper("_render",i)},clearContextTop:function(i){if(!(!this.isEditing||!this.canvas||!this.canvas.contextTop)){var l=this.canvas.contextTop,a=this.canvas.viewportTransform;l.save(),l.transform(a[0],a[1],a[2],a[3],a[4],a[5]),this.transform(l),this._clearTextArea(l),i||l.restore()}},renderCursorOrSelection:function(){if(!(!this.isEditing||!this.canvas||!this.canvas.contextTop)){var i=this._getCursorBoundaries(),l=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(i,l):this.renderSelection(i,l),l.restore()}},_clearTextArea:function(i){var l=this.width+4,a=this.height+4;i.clearRect(-l/2,-a/2,l,a)},_getCursorBoundaries:function(i){typeof i>"u"&&(i=this.selectionStart);var l=this._getLeftOffset(),a=this._getTopOffset(),t=this._getCursorBoundariesOffsets(i);return{left:l,top:a,leftOffset:t.left,topOffset:t.top}},_getCursorBoundariesOffsets:function(i){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var l,a,t,n=0,e=0,o,h=this.get2DCursorLocation(i);t=h.charIndex,a=h.lineIndex;for(var s=0;s<a;s++)n+=this.getHeightOfLine(s);l=this._getLineLeftOffset(a);var u=this.__charBounds[a][t];return u&&(e=u.left),this.charSpacing!==0&&t===this._textLines[a].length&&(e-=this._getWidthOfCharSpacing()),o={top:n,left:l+(e>0?e:0)},this.direction==="rtl"&&(o.left*=-1),this.cursorOffsetCache=o,this.cursorOffsetCache},renderCursor:function(i,l){var a=this.get2DCursorLocation(),t=a.lineIndex,n=a.charIndex>0?a.charIndex-1:0,e=this.getValueOfPropertyAt(t,n,"fontSize"),o=this.scaleX*this.canvas.getZoom(),h=this.cursorWidth/o,s=i.topOffset,u=this.getValueOfPropertyAt(t,n,"deltaY");s+=(1-this._fontSizeFraction)*this.getHeightOfLine(t)/this.lineHeight-e*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(i,l),l.fillStyle=this.cursorColor||this.getValueOfPropertyAt(t,n,"fill"),l.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,l.fillRect(i.left+i.leftOffset-h/2,s+i.top+u,h,e)},renderSelection:function(i,l){for(var a=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,t=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,n=this.textAlign.indexOf("justify")!==-1,e=this.get2DCursorLocation(a),o=this.get2DCursorLocation(t),h=e.lineIndex,s=o.lineIndex,u=e.charIndex<0?0:e.charIndex,d=o.charIndex<0?0:o.charIndex,m=h;m<=s;m++){var g=this._getLineLeftOffset(m)||0,v=this.getHeightOfLine(m),b=0,S=0,E=0;if(m===h&&(S=this.__charBounds[h][u].left),m>=h&&m<s)E=n&&!this.isEndOfWrapping(m)?this.width:this.getLineWidth(m)||5;else if(m===s)if(d===0)E=this.__charBounds[s][d].left;else{var F=this._getWidthOfCharSpacing();E=this.__charBounds[s][d-1].left+this.__charBounds[s][d-1].width-F}b=v,(this.lineHeight<1||m===s&&this.lineHeight>1)&&(v/=this.lineHeight);var R=i.left+g+S,z=E-S,q=v,Z=0;this.inCompositionMode?(l.fillStyle=this.compositionColor||"black",q=1,Z=v):l.fillStyle=this.selectionColor,this.direction==="rtl"&&(R=this.width-R-z),l.fillRect(R,i.top+i.topOffset+Z,z,q),i.topOffset+=b}},getCurrentCharFontSize:function(){var i=this._getCurrentCharIndex();return this.getValueOfPropertyAt(i.l,i.c,"fontSize")},getCurrentCharColor:function(){var i=this._getCurrentCharIndex();return this.getValueOfPropertyAt(i.l,i.c,"fill")},_getCurrentCharIndex:function(){var i=this.get2DCursorLocation(this.selectionStart,!0),l=i.charIndex>0?i.charIndex-1:0;return{l:i.lineIndex,c:l}}}),r.IText.fromObject=function(i,l){var a=r.util.stylesFromArray(i.styles,i.text),t=Object.assign({},i,{styles:a});if(c(t),t.styles)for(var n in t.styles)for(var e in t.styles[n])c(t.styles[n][e]);r.Object._fromObject("IText",t,l,"text")}})(),(function(){var c=r.util.object.clone;r.util.object.extend(r.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var i=this;this.on("added",function(){var l=i.canvas;l&&(l._hasITextHandlers||(l._hasITextHandlers=!0,i._initCanvasHandlers(l)),l._iTextInstances=l._iTextInstances||[],l._iTextInstances.push(i))})},initRemovedHandler:function(){var i=this;this.on("removed",function(){var l=i.canvas;l&&(l._iTextInstances=l._iTextInstances||[],r.util.removeFromArray(l._iTextInstances,i),l._iTextInstances.length===0&&(l._hasITextHandlers=!1,i._removeCanvasHandlers(l)))})},_initCanvasHandlers:function(i){i._mouseUpITextHandler=function(){i._iTextInstances&&i._iTextInstances.forEach(function(l){l.__isMousedown=!1})},i.on("mouse:up",i._mouseUpITextHandler)},_removeCanvasHandlers:function(i){i.off("mouse:up",i._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(i,l,a,t){var n;return n={isAborted:!1,abort:function(){this.isAborted=!0}},i.animate("_currentCursorOpacity",l,{duration:a,onComplete:function(){n.isAborted||i[t]()},onChange:function(){i.canvas&&i.selectionStart===i.selectionEnd&&i.renderCursorOrSelection()},abort:function(){return n.isAborted}}),n},_onTickComplete:function(){var i=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout(function(){i._currentTickCompleteState=i._animateCursor(i,0,this.cursorDuration/2,"_tick")},100)},initDelayedCursor:function(i){var l=this,a=i?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout(function(){l._tick()},a)},abortCursorAnimation:function(){var i=this._currentTickState||this._currentTickCompleteState,l=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,i&&l&&l.clearContext(l.contextTop||l.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(i){var l=0,a=i-1;if(this._reSpace.test(this._text[a]))for(;this._reSpace.test(this._text[a]);)l++,a--;for(;/\S/.test(this._text[a])&&a>-1;)l++,a--;return i-l},findWordBoundaryRight:function(i){var l=0,a=i;if(this._reSpace.test(this._text[a]))for(;this._reSpace.test(this._text[a]);)l++,a++;for(;/\S/.test(this._text[a])&&a<this._text.length;)l++,a++;return i+l},findLineBoundaryLeft:function(i){for(var l=0,a=i-1;!/\n/.test(this._text[a])&&a>-1;)l++,a--;return i-l},findLineBoundaryRight:function(i){for(var l=0,a=i;!/\n/.test(this._text[a])&&a<this._text.length;)l++,a++;return i+l},searchWordBoundary:function(i,l){for(var a=this._text,t=this._reSpace.test(a[i])?i-1:i,n=a[t],e=r.reNonWord;!e.test(n)&&t>0&&t<a.length;)t+=l,n=a[t];return e.test(n)&&(t+=l===1?0:1),t},selectWord:function(i){i=i||this.selectionStart;var l=this.searchWordBoundary(i,-1),a=this.searchWordBoundary(i,1);this.selectionStart=l,this.selectionEnd=a,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()},selectLine:function(i){i=i||this.selectionStart;var l=this.findLineBoundaryLeft(i),a=this.findLineBoundaryRight(i);return this.selectionStart=l,this.selectionEnd=a,this._fireSelectionChanged(),this._updateTextarea(),this},enterEditing:function(i){if(!(this.isEditing||!this.editable))return this.canvas&&(this.canvas.calcOffset(),this.exitEditingOnOthers(this.canvas)),this.isEditing=!0,this.initHiddenTextarea(i),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick(),this.fire("editing:entered"),this._fireSelectionChanged(),this.canvas?(this.canvas.fire("text:editing:entered",{target:this}),this.initMouseMoveHandler(),this.canvas.requestRenderAll(),this):this},exitEditingOnOthers:function(i){i._iTextInstances&&i._iTextInstances.forEach(function(l){l.selected=!1,l.isEditing&&l.exitEditing()})},initMouseMoveHandler:function(){this.canvas.on("mouse:move",this.mouseMoveHandler)},mouseMoveHandler:function(i){if(!(!this.__isMousedown||!this.isEditing)){document.activeElement!==this.hiddenTextarea&&this.hiddenTextarea.focus();var l=this.getSelectionStartFromPointer(i.e),a=this.selectionStart,t=this.selectionEnd;(l!==this.__selectionStartOnMouseDown||a===t)&&(a===l||t===l)||(l>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=l):(this.selectionStart=l,this.selectionEnd=this.__selectionStartOnMouseDown),(this.selectionStart!==a||this.selectionEnd!==t)&&(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},fromStringToGraphemeSelection:function(i,l,a){var t=a.slice(0,i),n=r.util.string.graphemeSplit(t).length;if(i===l)return{selectionStart:n,selectionEnd:n};var e=a.slice(i,l),o=r.util.string.graphemeSplit(e).length;return{selectionStart:n,selectionEnd:n+o}},fromGraphemeToStringSelection:function(i,l,a){var t=a.slice(0,i),n=t.join("").length;if(i===l)return{selectionStart:n,selectionEnd:n};var e=a.slice(i,l),o=e.join("").length;return{selectionStart:n,selectionEnd:n+o}},_updateTextarea:function(){if(this.cursorOffsetCache={},!!this.hiddenTextarea){if(!this.inCompositionMode){var i=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=i.selectionStart,this.hiddenTextarea.selectionEnd=i.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var i=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=i.selectionEnd,this.inCompositionMode||(this.selectionStart=i.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var i=this._calcTextareaPosition();this.hiddenTextarea.style.left=i.left,this.hiddenTextarea.style.top=i.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var i=this.inCompositionMode?this.compositionStart:this.selectionStart,l=this._getCursorBoundaries(i),a=this.get2DCursorLocation(i),t=a.lineIndex,n=a.charIndex,e=this.getValueOfPropertyAt(t,n,"fontSize")*this.lineHeight,o=l.leftOffset,h=this.calcTransformMatrix(),s={x:l.left+o,y:l.top+l.topOffset+e},u=this.canvas.getRetinaScaling(),d=this.canvas.upperCanvasEl,m=d.width/u,g=d.height/u,v=m-e,b=g-e,S=d.clientWidth/m,E=d.clientHeight/g;return s=r.util.transformPoint(s,h),s=r.util.transformPoint(s,this.canvas.viewportTransform),s.x*=S,s.y*=E,s.x<0&&(s.x=0),s.x>v&&(s.x=v),s.y<0&&(s.y=0),s.y>b&&(s.y=b),s.x+=this.canvas._offset.left,s.y+=this.canvas._offset.top,{left:s.x+"px",top:s.y+"px",fontSize:e+"px",charHeight:e}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var i=this._textBeforeEdit!==this.text,l=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,l&&(l.blur&&l.blur(),l.parentNode&&l.parentNode.removeChild(l)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),i&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),i&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var i in this.styles)this._textLines[i]||delete this.styles[i]},removeStyleFromTo:function(i,l){var a=this.get2DCursorLocation(i,!0),t=this.get2DCursorLocation(l,!0),n=a.lineIndex,e=a.charIndex,o=t.lineIndex,h=t.charIndex,s,u;if(n!==o){if(this.styles[n])for(s=e;s<this._unwrappedTextLines[n].length;s++)delete this.styles[n][s];if(this.styles[o])for(s=h;s<this._unwrappedTextLines[o].length;s++)u=this.styles[o][s],u&&(this.styles[n]||(this.styles[n]={}),this.styles[n][e+s-h]=u);for(s=n+1;s<=o;s++)delete this.styles[s];this.shiftLineStyles(o,n-o)}else if(this.styles[n]){u=this.styles[n];var d=h-e,m,g;for(s=e;s<h;s++)delete u[s];for(g in this.styles[n])m=parseInt(g,10),m>=h&&(u[m-d]=u[g],delete u[g])}},shiftLineStyles:function(i,l){var a=c(this.styles);for(var t in this.styles){var n=parseInt(t,10);n>i&&(this.styles[n+l]=a[n],a[n-l]||delete this.styles[n])}},restartCursorIfNeeded:function(){(!this._currentTickState||this._currentTickState.isAborted||!this._currentTickCompleteState||this._currentTickCompleteState.isAborted)&&this.initDelayedCursor()},insertNewlineStyleObject:function(i,l,a,t){var n,e={},o=!1,h=this._unwrappedTextLines[i].length===l;a||(a=1),this.shiftLineStyles(i,a),this.styles[i]&&(n=this.styles[i][l===0?l:l-1]);for(var s in this.styles[i]){var u=parseInt(s,10);u>=l&&(o=!0,e[u-l]=this.styles[i][s],h&&l===0||delete this.styles[i][s])}var d=!1;for(o&&!h&&(this.styles[i+a]=e,d=!0),d&&a--;a>0;)t&&t[a-1]?this.styles[i+a]={0:c(t[a-1])}:n?this.styles[i+a]={0:c(n)}:delete this.styles[i+a],a--;this._forceClearCache=!0},insertCharStyleObject:function(i,l,a,t){this.styles||(this.styles={});var n=this.styles[i],e=n?c(n):{};a||(a=1);for(var o in e){var h=parseInt(o,10);h>=l&&(n[h+a]=e[h],e[h-a]||delete n[h])}if(this._forceClearCache=!0,t){for(;a--;)Object.keys(t[a]).length&&(this.styles[i]||(this.styles[i]={}),this.styles[i][l+a]=c(t[a]));return}if(n)for(var s=n[l?l-1:1];s&&a--;)this.styles[i][l+a]=c(s)},insertNewStyleBlock:function(i,l,a){for(var t=this.get2DCursorLocation(l,!0),n=[0],e=0,o=0;o<i.length;o++)i[o]===`
438
- `?(e++,n[e]=0):n[e]++;n[0]>0&&(this.insertCharStyleObject(t.lineIndex,t.charIndex,n[0],a),a=a&&a.slice(n[0]+1)),e&&this.insertNewlineStyleObject(t.lineIndex,t.charIndex+n[0],e);for(var o=1;o<e;o++)n[o]>0?this.insertCharStyleObject(t.lineIndex+o,0,n[o],a):a&&this.styles[t.lineIndex+o]&&a[0]&&(this.styles[t.lineIndex+o][0]=a[0]),a=a&&a.slice(n[o]+1);n[o]>0&&this.insertCharStyleObject(t.lineIndex+o,0,n[o],a)},setSelectionStartEndWithShift:function(i,l,a){a<=i?(l===i?this._selectionDirection="left":this._selectionDirection==="right"&&(this._selectionDirection="left",this.selectionEnd=i),this.selectionStart=a):a>i&&a<l?this._selectionDirection==="right"?this.selectionEnd=a:this.selectionStart=a:(l===i?this._selectionDirection="right":this._selectionDirection==="left"&&(this._selectionDirection="right",this.selectionStart=l),this.selectionEnd=a)},setSelectionInBoundaries:function(){var i=this.text.length;this.selectionStart>i?this.selectionStart=i:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>i?this.selectionEnd=i:this.selectionEnd<0&&(this.selectionEnd=0)}})})(),r.util.object.extend(r.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(c){if(this.canvas){this.__newClickTime=+new Date;var i=c.pointer;this.isTripleClick(i)&&(this.fire("tripleclick",c),this._stopEvent(c.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=i,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(c){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===c.x&&this.__lastPointer.y===c.y},_stopEvent:function(c){c.preventDefault&&c.preventDefault(),c.stopPropagation&&c.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(c){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(c.e))},tripleClickHandler:function(c){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(c.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(c){!this.canvas||!this.editable||c.e.button&&c.e.button!==1||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(c.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(c){!this.canvas||!this.editable||c.e.button&&c.e.button!==1||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(c){if(this.__isMousedown=!1,!(!this.editable||this.group||c.transform&&c.transform.actionPerformed||c.e.button&&c.e.button!==1)){if(this.canvas){var i=this.canvas._activeObject;if(i&&i!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(c.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(c){var i=this.getSelectionStartFromPointer(c),l=this.selectionStart,a=this.selectionEnd;c.shiftKey?this.setSelectionStartEndWithShift(l,a,i):(this.selectionStart=i,this.selectionEnd=i),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(c){for(var i=this.getLocalPointer(c),l=0,a=0,t=0,n=0,e=0,o,h,s=0,u=this._textLines.length;s<u&&t<=i.y;s++)t+=this.getHeightOfLine(s)*this.scaleY,e=s,s>0&&(n+=this._textLines[s-1].length+this.missingNewlineOffset(s-1));o=this._getLineLeftOffset(e),a=o*this.scaleX,h=this._textLines[e],this.direction==="rtl"&&(i.x=this.width*this.scaleX-i.x+a);for(var d=0,m=h.length;d<m&&(l=a,a+=this.__charBounds[e][d].kernedWidth*this.scaleX,a<=i.x);d++)n++;return this._getNewSelectionStartFromOffset(i,l,a,n,m)},_getNewSelectionStartFromOffset:function(c,i,l,a,t){var n=c.x-i,e=l-c.x,o=e>n||e<0?0:1,h=a+o;return this.flipX&&(h=t-h),h>this._text.length&&(h=this._text.length),h}}),r.util.object.extend(r.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=r.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var c=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+c.top+"; left: "+c.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: "+c.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):r.document.body.appendChild(this.hiddenTextarea),r.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),r.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),r.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),r.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),r.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),r.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),r.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),r.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),r.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(r.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(c){if(this.isEditing){var i=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(c.keyCode in i)this[i[c.keyCode]](c);else if(c.keyCode in this.ctrlKeysMapDown&&(c.ctrlKey||c.metaKey))this[this.ctrlKeysMapDown[c.keyCode]](c);else return;c.stopImmediatePropagation(),c.preventDefault(),c.keyCode>=33&&c.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(c){if(!this.isEditing||this._copyDone||this.inCompositionMode){this._copyDone=!1;return}if(c.keyCode in this.ctrlKeysMapUp&&(c.ctrlKey||c.metaKey))this[this.ctrlKeysMapUp[c.keyCode]](c);else return;c.stopImmediatePropagation(),c.preventDefault(),this.canvas&&this.canvas.requestRenderAll()},onInput:function(c){var i=this.fromPaste;if(this.fromPaste=!1,c&&c.stopPropagation(),!!this.isEditing){var l=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,a=this._text.length,t=l.length,n,e,o=t-a,h=this.selectionStart,s=this.selectionEnd,u=h!==s,d,m,g;if(this.hiddenTextarea.value===""){this.styles={},this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll());return}var v=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),b=h>v.selectionStart;u?(n=this._text.slice(h,s),o+=s-h):t<a&&(b?n=this._text.slice(s+o,s):n=this._text.slice(h,h-o)),e=l.slice(v.selectionEnd-o,v.selectionEnd),n&&n.length&&(e.length&&(d=this.getSelectionStyles(h,h+1,!1),d=e.map(function(){return d[0]})),u?(m=h,g=s):b?(m=s-n.length,g=s):(m=s,g=s+n.length),this.removeStyleFromTo(m,g)),e.length&&(i&&e.join("")===r.copiedText&&!r.disableStyleCopyPaste&&(d=r.copiedTextStyle),this.insertNewStyleBlock(e,h,d)),this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())}},onCompositionStart:function(){this.inCompositionMode=!0},onCompositionEnd:function(){this.inCompositionMode=!1},onCompositionUpdate:function(c){this.compositionStart=c.target.selectionStart,this.compositionEnd=c.target.selectionEnd,this.updateTextareaPosition()},copy:function(){this.selectionStart!==this.selectionEnd&&(r.copiedText=this.getSelectedText(),r.disableStyleCopyPaste?r.copiedTextStyle=null:r.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0)},paste:function(){this.fromPaste=!0},_getClipboardData:function(c){return c&&c.clipboardData||r.window.clipboardData},_getWidthBeforeCursor:function(c,i){var l=this._getLineLeftOffset(c),a;return i>0&&(a=this.__charBounds[c][i-1],l+=a.left+a.width),l},getDownCursorOffset:function(c,i){var l=this._getSelectionForOffset(c,i),a=this.get2DCursorLocation(l),t=a.lineIndex;if(t===this._textLines.length-1||c.metaKey||c.keyCode===34)return this._text.length-l;var n=a.charIndex,e=this._getWidthBeforeCursor(t,n),o=this._getIndexOnLine(t+1,e),h=this._textLines[t].slice(n);return h.length+o+1+this.missingNewlineOffset(t)},_getSelectionForOffset:function(c,i){return c.shiftKey&&this.selectionStart!==this.selectionEnd&&i?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(c,i){var l=this._getSelectionForOffset(c,i),a=this.get2DCursorLocation(l),t=a.lineIndex;if(t===0||c.metaKey||c.keyCode===33)return-l;var n=a.charIndex,e=this._getWidthBeforeCursor(t,n),o=this._getIndexOnLine(t-1,e),h=this._textLines[t].slice(0,n),s=this.missingNewlineOffset(t-1);return-this._textLines[t-1].length+o-h.length+(1-s)},_getIndexOnLine:function(c,i){for(var l=this._textLines[c],a=this._getLineLeftOffset(c),t=a,n=0,e,o,h=0,s=l.length;h<s;h++)if(e=this.__charBounds[c][h].width,t+=e,t>i){o=!0;var u=t-e,d=t,m=Math.abs(u-i),g=Math.abs(d-i);n=g<m?h:h-1;break}return o||(n=l.length-1),n},moveCursorDown:function(c){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",c)},moveCursorUp:function(c){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",c)},_moveCursorUpOrDown:function(c,i){var l="get"+c+"CursorOffset",a=this[l](i,this._selectionDirection==="right");i.shiftKey?this.moveCursorWithShift(a):this.moveCursorWithoutShift(a),a!==0&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(c){var i=this._selectionDirection==="left"?this.selectionStart+c:this.selectionEnd+c;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,i),c!==0},moveCursorWithoutShift:function(c){return c<0?(this.selectionStart+=c,this.selectionEnd=this.selectionStart):(this.selectionEnd+=c,this.selectionStart=this.selectionEnd),c!==0},moveCursorLeft:function(c){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",c)},_move:function(c,i,l){var a;if(c.altKey)a=this["findWordBoundary"+l](this[i]);else if(c.metaKey||c.keyCode===35||c.keyCode===36)a=this["findLineBoundary"+l](this[i]);else return this[i]+=l==="Left"?-1:1,!0;if(typeof a<"u"&&this[i]!==a)return this[i]=a,!0},_moveLeft:function(c,i){return this._move(c,i,"Left")},_moveRight:function(c,i){return this._move(c,i,"Right")},moveCursorLeftWithoutShift:function(c){var i=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(i=this._moveLeft(c,"selectionStart")),this.selectionEnd=this.selectionStart,i},moveCursorLeftWithShift:function(c){if(this._selectionDirection==="right"&&this.selectionStart!==this.selectionEnd)return this._moveLeft(c,"selectionEnd");if(this.selectionStart!==0)return this._selectionDirection="left",this._moveLeft(c,"selectionStart")},moveCursorRight:function(c){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",c)},_moveCursorLeftOrRight:function(c,i){var l="moveCursor"+c+"With";this._currentCursorOpacity=1,i.shiftKey?l+="Shift":l+="outShift",this[l](i)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(c){if(this._selectionDirection==="left"&&this.selectionStart!==this.selectionEnd)return this._moveRight(c,"selectionStart");if(this.selectionEnd!==this._text.length)return this._selectionDirection="right",this._moveRight(c,"selectionEnd")},moveCursorRightWithoutShift:function(c){var i=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(i=this._moveRight(c,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,i},removeChars:function(c,i){typeof i>"u"&&(i=c+1),this.removeStyleFromTo(c,i),this._text.splice(c,i-c),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(c,i,l,a){typeof a>"u"&&(a=l),a>l&&this.removeStyleFromTo(l,a);var t=r.util.string.graphemeSplit(c);this.insertNewStyleBlock(t,l,i),this._text=[].concat(this._text.slice(0,l),t,this._text.slice(a)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),(function(){var c=r.util.toFixed,i=/ +/g;r.util.object.extend(r.Text.prototype,{_toSVG:function(){var l=this._getSVGLeftTopOffsets(),a=this._getSVGTextAndBg(l.textTop,l.textLeft);return this._wrapSVGTextAndBg(a)},toSVG:function(l){return this._createBaseSVGMarkup(this._toSVG(),{reviver:l,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(l){var a=!0,t=this.getSvgTextDecoration(this);return[l.textBgRects.join(""),' <text xml:space="preserve" ',this.fontFamily?'font-family="'+this.fontFamily.replace(/"/g,"'")+'" ':"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",t?'text-decoration="'+t+'" ':"",'style="',this.getSvgStyles(a),'"',this.addPaintOrder()," >",l.textSpans.join(""),`</text>
439
- `]},_getSVGTextAndBg:function(l,a){var t=[],n=[],e=l,o;this._setSVGBg(n);for(var h=0,s=this._textLines.length;h<s;h++)o=this._getLineLeftOffset(h),(this.textBackgroundColor||this.styleHas("textBackgroundColor",h))&&this._setSVGTextLineBg(n,h,a+o,e),this._setSVGTextLineText(t,h,a+o,e),e+=this.getHeightOfLine(h);return{textSpans:t,textBgRects:n}},_createTextCharSpan:function(l,a,t,n){var e=l!==l.trim()||l.match(i),o=this.getSvgSpanStyles(a,e),h=o?'style="'+o+'"':"",s=a.deltaY,u="",d=r.Object.NUM_FRACTION_DIGITS;return s&&(u=' dy="'+c(s,d)+'" '),['<tspan x="',c(t,d),'" y="',c(n,d),'" ',u,h,">",r.util.string.escapeXml(l),"</tspan>"].join("")},_setSVGTextLineText:function(l,a,t,n){var e=this.getHeightOfLine(a),o=this.textAlign.indexOf("justify")!==-1,h,s,u="",d,m,g=0,v=this._textLines[a],b;n+=e*(1-this._fontSizeFraction)/this.lineHeight;for(var S=0,E=v.length-1;S<=E;S++)b=S===E||this.charSpacing,u+=v[S],d=this.__charBounds[a][S],g===0?(t+=d.kernedWidth-d.width,g+=d.width):g+=d.kernedWidth,o&&!b&&this._reSpaceAndTab.test(v[S])&&(b=!0),b||(h=h||this.getCompleteStyleDeclaration(a,S),s=this.getCompleteStyleDeclaration(a,S+1),b=r.util.hasStyleChanged(h,s,!0)),b&&(m=this._getStyleDeclaration(a,S)||{},l.push(this._createTextCharSpan(u,m,t,n)),u="",h=s,t+=g,g=0)},_pushTextBgRect:function(l,a,t,n,e,o){var h=r.Object.NUM_FRACTION_DIGITS;l.push(" <rect ",this._getFillAttributes(a),' x="',c(t,h),'" y="',c(n,h),'" width="',c(e,h),'" height="',c(o,h),`"></rect>
440
- `)},_setSVGTextLineBg:function(l,a,t,n){for(var e=this._textLines[a],o=this.getHeightOfLine(a)/this.lineHeight,h=0,s=0,u,d,m=this.getValueOfPropertyAt(a,0,"textBackgroundColor"),g=0,v=e.length;g<v;g++)u=this.__charBounds[a][g],d=this.getValueOfPropertyAt(a,g,"textBackgroundColor"),d!==m?(m&&this._pushTextBgRect(l,m,t+s,n,h,o),s=u.left,h=u.width,m=d):h+=u.kernedWidth;d&&this._pushTextBgRect(l,d,t+s,n,h,o)},_getFillAttributes:function(l){var a=l&&typeof l=="string"?new r.Color(l):"";return!a||!a.getSource()||a.getAlpha()===1?'fill="'+l+'"':'opacity="'+a.getAlpha()+'" fill="'+a.setAlpha(1).toRgb()+'"'},_getSVGLineTopOffset:function(l){for(var a=0,t=0,n=0;n<l;n++)a+=this.getHeightOfLine(n);return t=this.getHeightOfLine(n),{lineTop:a,offset:(this._fontSizeMult-this._fontSizeFraction)*t/(this.lineHeight*this._fontSizeMult)}},getSvgStyles:function(l){var a=r.Object.prototype.getSvgStyles.call(this,l);return a+" white-space: pre;"}})})(),(function(c){var i=c.fabric||(c.fabric={});i.Textbox=i.util.createClass(i.IText,i.Observable,{type:"textbox",minWidth:20,dynamicMinWidth:2,__cachedLines:null,lockScalingFlip:!0,noScaleCache:!1,_dimensionAffectingProps:i.Text.prototype._dimensionAffectingProps.concat("width"),_wordJoiners:/[ \t\r]/,splitByGrapheme:!1,initDimensions:function(){this.__skipDimension||(this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.indexOf("justify")!==-1&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(l){for(var a=0,t=0,n=0,e={},o=0;o<l.graphemeLines.length;o++)l.graphemeText[n]===`
441
- `&&o>0?(t=0,n++,a++):!this.splitByGrapheme&&this._reSpaceAndTab.test(l.graphemeText[n])&&o>0&&(t++,n++),e[o]={line:a,offset:t},n+=l.graphemeLines[o].length,t+=l.graphemeLines[o].length;return e},styleHas:function(l,a){if(this._styleMap&&!this.isWrapping){var t=this._styleMap[a];t&&(a=t.line)}return i.Text.prototype.styleHas.call(this,l,a)},isEmptyStyles:function(l){if(!this.styles)return!0;var a=0,t=l+1,n,e,o=!1,h=this._styleMap[l],s=this._styleMap[l+1];h&&(l=h.line,a=h.offset),s&&(t=s.line,o=t===l,n=s.offset),e=typeof l>"u"?this.styles:{line:this.styles[l]};for(var u in e)for(var d in e[u])if(d>=a&&(!o||d<n))for(var m in e[u][d])return!1;return!0},_getStyleDeclaration:function(l,a){if(this._styleMap&&!this.isWrapping){var t=this._styleMap[l];if(!t)return null;l=t.line,a=t.offset+a}return this.callSuper("_getStyleDeclaration",l,a)},_setStyleDeclaration:function(l,a,t){var n=this._styleMap[l];l=n.line,a=n.offset+a,this.styles[l][a]=t},_deleteStyleDeclaration:function(l,a){var t=this._styleMap[l];l=t.line,a=t.offset+a,delete this.styles[l][a]},_getLineStyle:function(l){var a=this._styleMap[l];return!!this.styles[a.line]},_setLineStyle:function(l){var a=this._styleMap[l];this.styles[a.line]={}},_wrapText:function(l,a){var t=[],n;for(this.isWrapping=!0,n=0;n<l.length;n++)t=t.concat(this._wrapLine(l[n],n,a));return this.isWrapping=!1,t},_measureWord:function(l,a,t){var n=0,e,o=!0;t=t||0;for(var h=0,s=l.length;h<s;h++){var u=this._getGraphemeBox(l[h],a,h+t,e,o);n+=u.kernedWidth,e=l[h]}return n},_wrapLine:function(l,a,t,R){var e=0,o=this.splitByGrapheme,h=[],s=[],u=o?i.util.string.graphemeSplit(l):l.split(this._wordJoiners),d="",m=0,g=o?"":" ",v=0,b=0,S=0,E=!0,F=this._getWidthOfCharSpacing(),R=R||0;u.length===0&&u.push([]),t-=R;for(var z=0;z<u.length;z++)d=o?u[z]:i.util.string.graphemeSplit(u[z]),v=this._measureWord(d,a,m),m+=d.length,e+=b+v-F,e>t&&!E?(h.push(s),s=[],e=v,E=!0):e+=F,!E&&!o&&s.push(g),s=s.concat(d),b=o?0:this._measureWord([g],a,m),m++,E=!1,v>S&&(S=v);return z&&h.push(s),S+R>this.dynamicMinWidth&&(this.dynamicMinWidth=S-F+R),h},isEndOfWrapping:function(l){return!this._styleMap[l+1]||this._styleMap[l+1].line!==this._styleMap[l].line},missingNewlineOffset:function(l){return this.splitByGrapheme?this.isEndOfWrapping(l)?1:0:1},_splitTextIntoLines:function(l){for(var a=i.Text.prototype._splitTextIntoLines.call(this,l),t=this._wrapText(a.lines,this.width),n=new Array(t.length),e=0;e<t.length;e++)n[e]=t[e].join("");return a.lines=n,a.graphemeLines=t,a},getMinWidth:function(){return Math.max(this.minWidth,this.dynamicMinWidth)},_removeExtraneousStyles:function(){var l={};for(var a in this._styleMap)this._textLines[a]&&(l[this._styleMap[a].line]=1);for(var a in this.styles)l[a]||delete this.styles[a]},toObject:function(l){return this.callSuper("toObject",["minWidth","splitByGrapheme"].concat(l))}}),i.Textbox.fromObject=function(l,a){var t=i.util.stylesFromArray(l.styles,l.text),n=Object.assign({},l,{styles:t});return i.Object._fromObject("Textbox",n,a,"text")}})(f),(function(){var c=r.controlsUtils,i=c.scaleSkewCursorStyleHandler,l=c.scaleCursorStyleHandler,a=c.scalingEqually,t=c.scalingYOrSkewingX,n=c.scalingXOrSkewingY,e=c.scaleOrSkewActionName,o=r.Object.prototype.controls;if(o.ml=new r.Control({x:-.5,y:0,cursorStyleHandler:i,actionHandler:n,getActionName:e}),o.mr=new r.Control({x:.5,y:0,cursorStyleHandler:i,actionHandler:n,getActionName:e}),o.mb=new r.Control({x:0,y:.5,cursorStyleHandler:i,actionHandler:t,getActionName:e}),o.mt=new r.Control({x:0,y:-.5,cursorStyleHandler:i,actionHandler:t,getActionName:e}),o.tl=new r.Control({x:-.5,y:-.5,cursorStyleHandler:l,actionHandler:a}),o.tr=new r.Control({x:.5,y:-.5,cursorStyleHandler:l,actionHandler:a}),o.bl=new r.Control({x:-.5,y:.5,cursorStyleHandler:l,actionHandler:a}),o.br=new r.Control({x:.5,y:.5,cursorStyleHandler:l,actionHandler:a}),o.mtr=new r.Control({x:0,y:-.5,actionHandler:c.rotationWithSnapping,cursorStyleHandler:c.rotationStyleHandler,offsetY:-40,withConnection:!0,actionName:"rotate"}),r.Textbox){var h=r.Textbox.prototype.controls={};h.mtr=o.mtr,h.tr=o.tr,h.br=o.br,h.tl=o.tl,h.bl=o.bl,h.mt=o.mt,h.mb=o.mb,h.mr=new r.Control({x:.5,y:0,actionHandler:c.changeWidth,cursorStyleHandler:i,actionName:"resizing"}),h.ml=new r.Control({x:-.5,y:0,actionHandler:c.changeWidth,cursorStyleHandler:i,actionName:"resizing"})}})()})(si)),si}var _t=No(),ue=(f=>(f.ONE="selectOne",f.MULTI="selectMultiple",f.CANCEL="selectCancel",f))(ue||{}),te=(f=>(f.EMPTY="",f.ONE="one",f.MULTI="multiple",f))(te||{});function dr(f){f&&f.forEach(r=>{r.objects?dr(r.objects):r.type==="text"&&(r.type="textbox")})}const ge=class ge{constructor(r,p){this.canvas=r,this.editor=p,this.selectedMode=te.EMPTY,this._initSelectEvent()}_initSelectEvent(){this.canvas.on("selection:created",()=>this._emitSelectEvent()),this.canvas.on("selection:updated",()=>this._emitSelectEvent()),this.canvas.on("selection:cleared",()=>this._emitSelectEvent())}_emitSelectEvent(){if(!this.canvas)throw TypeError("还未初始化");const r=this.canvas.getActiveObjects().filter(p=>!(p instanceof _t.fabric.GuideLine));r&&r.length===1?(this.selectedMode=te.ONE,this.editor.emit(ue.ONE,r)):r&&r.length>1?(this.selectedMode=te.MULTI,this.editor.emit(ue.MULTI,r)):this.editor.emit(ue.CANCEL)}getSelectMode(){return String(this.selectedMode)}insert(r){ur({accept:".json"}).then(p=>{if(p&&p.length>0){const _=p[0],y=new FileReader;y.readAsText(_,"UTF-8"),y.onload=()=>{this.loadJSON(y.result,r)}}})}renderITextPath(r){r.forEach(p=>{const _=this.canvas.getObjects().find(y=>y.id===p.id);_&&_t.fabric.Path.fromObject(p.path,y=>{_.set("path",y)})})}async loadJSON(r,p){const _=typeof r=="string"?JSON.parse(r):r,y=[];_.objects.forEach(T=>{!T.id&&(T.id=On()),T.type==="i-text"&&T.path&&(y.push({id:T.id,path:T.path}),T.path=null)});const C=await this._transform(_);r=JSON.stringify(C),this.editor.hooksEntity.hookImportBefore.callAsync(r,()=>{this.canvas.loadFromJSON(r,()=>{this.renderITextPath(y),this.canvas.renderAll(),this.editor.hooksEntity.hookImportAfter.callAsync(r,()=>{this.editor?.updateDrawStatus&&typeof this.editor.updateDrawStatus=="function"&&this.editor.updateDrawStatus(!!_.overlayImage),this.canvas.renderAll(),p&&p(),this.editor.emit("loadJson")})},(T,c)=>{this.editor.hooksEntity.hookTransformObjectEnd.callAsync({originObject:T,fabricObject:c},()=>{this.canvas.renderAll()})})})}async _transform(r){if(await this.promiseCallAsync(r),r.objects){const p=r.objects.map(_=>this._transform(_));await Promise.all(p)}return r}promiseCallAsync(r){return new Promise(p=>{this.editor.hooksEntity.hookTransform.callAsync(r,()=>{p(r)})})}getJson(){const r=this.getExtensionKey();return this.canvas.toJSON(r)}getExtensionKey(){return["id","gradientAngle","selectable","hasControls","linkData","editable","extensionType","extension","verticalAlign","roundValue","getBase64","_originSize"]}dragAddItem(r,p){if(p){const{left:y,top:C}=this.canvas.getSelectionElement().getBoundingClientRect();if(p.x<y||p.y<C||r.width===void 0)return;const T={x:p.x-y,y:p.y-C},c=this.canvas.restorePointerVpt(T);r.left=c.x-r.width/2,r.top=c.y}const{width:_}=this._getSaveOption();_&&r.scaleToWidth(_/2),this.canvas.add(r),this.canvas.setActiveObject(r),!p&&this.editor.position("center"),this.canvas.requestRenderAll()}clipboard(){const r=this.getJson();return ki(JSON.stringify(r,null," "))}async clipboardBase64(){const r=await this.preview();return ki(r)}async saveJson(){const r=this.getJson();await dr(r.objects);const p=`data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r,null," "))}`;Re(p,"json")}saveSvg(){this.editor.hooksEntity.hookSaveBefore.callAsync("",()=>{const{fontOption:r,svgOption:p}=this._getSaveSvgOption();_t.fabric.fontPaths={...r};const _=this.canvas.toSVG(p),y=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(_)}`;this.editor.hooksEntity.hookSaveAfter.callAsync(y,()=>{Re(y,"svg")})})}saveImg(){this.editor.hooksEntity.hookSaveBefore.callAsync("",()=>{const r=this._getSaveOption();this.canvas.setViewportTransform([1,0,0,1,0,0]);const p=this.canvas.toDataURL(r);this.editor.hooksEntity.hookSaveAfter.callAsync(p,()=>{Re(p,"png")})})}getBase64(){return new Promise(r=>{this.editor.hooksEntity.hookSaveBefore.callAsync("",()=>{const p=this._getSaveOption();this.canvas.setViewportTransform([1,0,0,1,0,0]);const _=this.canvas.toDataURL(p);this.editor.hooksEntity.hookSaveAfter.callAsync(_,()=>r(_))})})}preview(){return new Promise(r=>{this.editor.hooksEntity.hookSaveBefore.callAsync("",()=>{const p=this._getSaveOption();this.canvas.setViewportTransform([1,0,0,1,0,0]),this.canvas.renderAll();const _=this.canvas.toDataURL(p);this.editor.hooksEntity.hookSaveAfter.callAsync(_,()=>{r(_)})})})}staticPreview(){return new Promise(r=>{})}_getSaveSvgOption(){const r=this.canvas.getObjects().find(l=>l.id==="workspace");let p=this.canvas.getObjects().filter(l=>l.type=="textbox").map(l=>l.fontFamily);p=Array.from(new Set(p));const _=this.editor.getPlugin("FontPlugin").cacheList,y={};for(const l of p){const a=_.find(t=>t.name===l);y[l]=a.file}console.log("_getSaveSvgOption",y);const{left:C,top:T,width:c,height:i}=r;return{fontOption:y,svgOption:{width:c,height:i,viewBox:{x:C,y:T,width:c,height:i}}}}_getSaveOption(){const r=this.canvas.getObjects().find(c=>c.id==="workspace"),{left:p,top:_,width:y,height:C}=r;return{name:"New Image",format:"jpeg",quality:1,multiplier:5,width:y,height:C,left:p,top:_}}clear(){this.canvas.getObjects().forEach(r=>{r.id!=="workspace"&&this.canvas.remove(r)}),this.editor?.setWorkspaseBg("#fff"),this.canvas.discardActiveObject(),this.canvas.renderAll()}destroy(){console.log("pluginDestroy")}};ge.pluginName="ServersPlugin",ge.apis=["insert","loadJSON","getJson","dragAddItem","clipboard","clipboardBase64","saveJson","saveSvg","saveImg","getBase64","clear","preview","staticPreview","getSelectMode","getExtensionKey"],ge.events=[te.ONE,te.MULTI,ue.CANCEL];let Ai=ge;var St={},ai={},rn;function gr(){return rn||(rn=1,ai.deprecate=(f,r)=>{let p=!0;return function(){return p&&(console.warn(`DeprecationWarning: ${r}`),p=!1),f.apply(this,arguments)}}),ai}var li,sn;function Mt(){if(sn)return li;sn=1;const r=gr().deprecate(()=>{},"Hook.context is deprecated and will be removed");function p(...T){return this.call=this._createCall("sync"),this.call(...T)}function _(...T){return this.callAsync=this._createCall("async"),this.callAsync(...T)}function y(...T){return this.promise=this._createCall("promise"),this.promise(...T)}class C{constructor(c=[],i=void 0){this._args=c,this.name=i,this.taps=[],this.interceptors=[],this._call=p,this.call=p,this._callAsync=_,this.callAsync=_,this._promise=y,this.promise=y,this._x=void 0,this.compile=this.compile,this.tap=this.tap,this.tapAsync=this.tapAsync,this.tapPromise=this.tapPromise}compile(c){throw new Error("Abstract: should be overridden")}_createCall(c){return this.compile({taps:this.taps,interceptors:this.interceptors,args:this._args,type:c})}_tap(c,i,l){if(typeof i=="string")i={name:i.trim()};else if(typeof i!="object"||i===null)throw new Error("Invalid tap options");if(typeof i.name!="string"||i.name==="")throw new Error("Missing name for tap");typeof i.context<"u"&&r(),i=Object.assign({type:c,fn:l},i),i=this._runRegisterInterceptors(i),this._insert(i)}tap(c,i){this._tap("sync",c,i)}tapAsync(c,i){this._tap("async",c,i)}tapPromise(c,i){this._tap("promise",c,i)}_runRegisterInterceptors(c){for(const i of this.interceptors)if(i.register){const l=i.register(c);l!==void 0&&(c=l)}return c}withOptions(c){const i=l=>Object.assign({},c,typeof l=="string"?{name:l}:l);return{name:this.name,tap:(l,a)=>this.tap(i(l),a),tapAsync:(l,a)=>this.tapAsync(i(l),a),tapPromise:(l,a)=>this.tapPromise(i(l),a),intercept:l=>this.intercept(l),isUsed:()=>this.isUsed(),withOptions:l=>this.withOptions(i(l))}}isUsed(){return this.taps.length>0||this.interceptors.length>0}intercept(c){if(this._resetCompilation(),this.interceptors.push(Object.assign({},c)),c.register)for(let i=0;i<this.taps.length;i++)this.taps[i]=c.register(this.taps[i])}_resetCompilation(){this.call=this._call,this.callAsync=this._callAsync,this.promise=this._promise}_insert(c){this._resetCompilation();let i;typeof c.before=="string"?i=new Set([c.before]):Array.isArray(c.before)&&(i=new Set(c.before));let l=0;typeof c.stage=="number"&&(l=c.stage);let a=this.taps.length;for(;a>0;){a--;const t=this.taps[a];this.taps[a+1]=t;const n=t.stage||0;if(i){if(i.has(t.name)){i.delete(t.name);continue}if(i.size>0)continue}if(!(n>l)){a++;break}}this.taps[a]=c}}return Object.setPrototypeOf(C.prototype,null),li=C,li}var ci,on;function Lt(){if(on)return ci;on=1;class f{constructor(p){this.config=p,this.options=void 0,this._args=void 0}create(p){this.init(p);let _;switch(this.options.type){case"sync":_=new Function(this.args(),`"use strict";
436
+ }`,gamma:[1,1,1],mainParameter:"gamma",initialize:function(t){this.gamma=[1,1,1],l.BaseFilter.prototype.initialize.call(this,t)},applyTo2d:function(t){var n=t.imageData,e=n.data,o=this.gamma,h=e.length,s=1/o[0],u=1/o[1],d=1/o[2],m;for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),m=0,h=256;m<h;m++)this.rVals[m]=Math.pow(m/255,s)*255,this.gVals[m]=Math.pow(m/255,u)*255,this.bVals[m]=Math.pow(m/255,d)*255;for(m=0,h=e.length;m<h;m+=4)e[m]=this.rVals[e[m]],e[m+1]=this.gVals[e[m+1]],e[m+2]=this.bVals[e[m+2]]},getUniformLocations:function(t,n){return{uGamma:t.getUniformLocation(n,"uGamma")}},sendUniformData:function(t,n){t.uniform3fv(n.uGamma,this.gamma)}}),i.Image.filters.Gamma.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass;l.Composed=a(l.BaseFilter,{type:"Composed",subFilters:[],initialize:function(t){this.callSuper("initialize",t),this.subFilters=this.subFilters.slice(0)},applyTo:function(t){t.passes+=this.subFilters.length-1,this.subFilters.forEach(function(n){n.applyTo(t)})},toObject:function(){return i.util.object.extend(this.callSuper("toObject"),{subFilters:this.subFilters.map(function(t){return t.toObject()})})},isNeutralState:function(){return!this.subFilters.some(function(t){return!t.isNeutralState()})}}),i.Image.filters.Composed.fromObject=function(t,n){var e=t.subFilters||[],o=e.map(function(s){return new i.Image.filters[s.type](s)}),h=new i.Image.filters.Composed({subFilters:o});return n&&n(h),h}})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.Image.filters,a=i.util.createClass;l.HueRotation=a(l.ColorMatrix,{type:"HueRotation",rotation:0,mainParameter:"rotation",calculateMatrix:function(){var t=this.rotation*Math.PI,n=i.util.cos(t),e=i.util.sin(t),o=1/3,h=Math.sqrt(o)*e,s=1-n;this.matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],this.matrix[0]=n+s/3,this.matrix[1]=o*s-h,this.matrix[2]=o*s+h,this.matrix[5]=o*s+h,this.matrix[6]=n+o*s,this.matrix[7]=o*s-h,this.matrix[10]=o*s-h,this.matrix[11]=o*s+h,this.matrix[12]=n+o*s},isNeutralState:function(t){return this.calculateMatrix(),l.BaseFilter.prototype.isNeutralState.call(this,t)},applyTo:function(t){this.calculateMatrix(),l.BaseFilter.prototype.applyTo.call(this,t)}}),i.Image.filters.HueRotation.fromObject=i.Image.filters.BaseFilter.fromObject})(f),(function(c){var i=c.fabric||(c.fabric={}),l=i.util.object.clone;if(i.Text){i.warn("fabric.Text is already defined");return}var a="fontFamily fontWeight fontSize text underline overline linethrough textAlign fontStyle lineHeight textBackgroundColor charSpacing styles direction path pathStartOffset pathSide pathAlign".split(" ");i.Text=i.util.createClass(i.Object,{_dimensionAffectingProps:["fontSize","fontWeight","fontFamily","fontStyle","lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],_reNewline:/\r?\n/,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,type:"text",fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:"left",fontStyle:"normal",lineHeight:1.16,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},textBackgroundColor:"",stateProperties:i.Object.prototype.stateProperties.concat(a),cacheProperties:i.Object.prototype.cacheProperties.concat(a),stroke:null,shadow:null,path:null,pathStartOffset:0,pathSide:"left",pathAlign:"baseline",_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.315,overline:-.88},_fontSizeMult:1.13,charSpacing:0,styles:null,_measuringContext:null,deltaY:0,direction:"ltr",_styleProperties:["stroke","strokeWidth","fill","fontFamily","fontSize","fontWeight","fontStyle","underline","overline","linethrough","deltaY","textBackgroundColor"],__charBounds:[],CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,initialize:function(t,n){this.styles=n?n.styles||{}:{},this.text=t,this.__skipDimension=!0,this.callSuper("initialize",n),this.path&&this.setPathInfo(),this.__skipDimension=!1,this.initDimensions(),this.setCoords(),this.setupState({propertySet:"_dimensionAffectingProps"})},setPathInfo:function(){var t=this.path;t&&(t.segmentsInfo=i.util.getPathSegmentsInfo(t.path))},getMeasuringContext:function(){return i._measuringContext||(i._measuringContext=this.canvas&&this.canvas.contextCache||i.util.createCanvasElement().getContext("2d")),i._measuringContext},_splitText:function(){var t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t},initDimensions:function(){this.__skipDimension||(this._splitText(),this._clearCache(),this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.indexOf("justify")!==-1&&this.enlargeSpaces(),this.saveState({propertySet:"_dimensionAffectingProps"}))},enlargeSpaces:function(){for(var t,n,e,o,h,s,u,d=0,m=this._textLines.length;d<m;d++)if(!(this.textAlign!=="justify"&&(d===m-1||this.isEndOfWrapping(d)))&&(o=0,h=this._textLines[d],n=this.getLineWidth(d),n<this.width&&(u=this.textLines[d].match(this._reSpacesAndTabs)))){e=u.length,t=(this.width-n)/e;for(var p=0,v=h.length;p<=v;p++)s=this.__charBounds[d][p],this._reSpaceAndTab.test(h[p])?(s.width+=t,s.kernedWidth+=t,s.left+=o,o+=t):s.left+=o}},isEndOfWrapping:function(t){return t===this._textLines.length-1},missingNewlineOffset:function(){return 1},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_getCacheCanvasDimensions:function(){var t=this.callSuper("_getCacheCanvasDimensions"),n=this.fontSize;return t.width+=n*t.zoomX,t.height+=n*t.zoomY,t},_render:function(t){var n=this.path;n&&!n.isNotVisible()&&n._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")},_renderText:function(t){this.paintFirst==="stroke"?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))},_setTextStyles:function(t,n,e){if(t.textBaseline="alphabetical",this.path)switch(this.pathAlign){case"center":t.textBaseline="middle";break;case"ascender":t.textBaseline="top";break;case"descender":t.textBaseline="bottom";break}t.font=this._getFontDeclaration(n,e)},calcTextWidth:function(){for(var t=this.getLineWidth(0),n=1,e=this._textLines.length;n<e;n++){var o=this.getLineWidth(n);o>t&&(t=o)}return t},_renderTextLine:function(t,n,e,o,h,s){this._renderChars(t,n,e,o,h,s)},_renderTextLinesBackground:function(t){if(!(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))){for(var n,e,o=t.fillStyle,h,s,u=this._getLeftOffset(),d=this._getTopOffset(),m=0,p=0,v,b,S=this.path,E,F=0,R=this._textLines.length;F<R;F++){if(n=this.getHeightOfLine(F),!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",F)){d+=n;continue}h=this._textLines[F],e=this._getLineLeftOffset(F),p=0,m=0,s=this.getValueOfPropertyAt(F,0,"textBackgroundColor");for(var z=0,K=h.length;z<K;z++)v=this.__charBounds[F][z],b=this.getValueOfPropertyAt(F,z,"textBackgroundColor"),S?(t.save(),t.translate(v.renderLeft,v.renderTop),t.rotate(v.angle),t.fillStyle=b,b&&t.fillRect(-v.width/2,-n/this.lineHeight*(1-this._fontSizeFraction),v.width,n/this.lineHeight),t.restore()):b!==s?(E=u+e+m,this.direction==="rtl"&&(E=this.width-E-p),t.fillStyle=s,s&&t.fillRect(E,d,p,n/this.lineHeight),m=v.left,p=v.width,s=b):p+=v.kernedWidth;b&&!S&&(E=u+e+m,this.direction==="rtl"&&(E=this.width-E-p),t.fillStyle=b,t.fillRect(E,d,p,n/this.lineHeight)),d+=n}t.fillStyle=o,this._removeShadow(t)}},getFontCache:function(t){var n=t.fontFamily.toLowerCase();i.charWidthsCache[n]||(i.charWidthsCache[n]={});var e=i.charWidthsCache[n],o=t.fontStyle.toLowerCase()+"_"+(t.fontWeight+"").toLowerCase();return e[o]||(e[o]={}),e[o]},_measureChar:function(t,n,e,o){var h=this.getFontCache(n),s=this._getFontDeclaration(n),u=this._getFontDeclaration(o),d=e+t,m=s===u,p,v,b,S=n.fontSize/this.CACHE_FONT_SIZE,E;if(e&&h[e]!==void 0&&(b=h[e]),h[t]!==void 0&&(E=p=h[t]),m&&h[d]!==void 0&&(v=h[d],E=v-b),p===void 0||b===void 0||v===void 0){var F=this.getMeasuringContext();this._setTextStyles(F,n,!0)}return p===void 0&&(E=p=F.measureText(t).width,h[t]=p),b===void 0&&m&&e&&(b=F.measureText(e).width,h[e]=b),m&&v===void 0&&(v=F.measureText(d).width,h[d]=v,E=v-b),{width:p*S,kernedWidth:E*S}},getHeightOfChar:function(t,n){return this.getValueOfPropertyAt(t,n,"fontSize")},measureLine:function(t){var n=this._measureLine(t);return this.charSpacing!==0&&(n.width-=this._getWidthOfCharSpacing()),n.width<0&&(n.width=0),n},_measureLine:function(t){var n=0,e,o,h=this._textLines[t],s,u,d=0,m=new Array(h.length),p=0,v,b,S=this.path,E=this.pathSide==="right";for(this.__charBounds[t]=m,e=0;e<h.length;e++)o=h[e],u=this._getGraphemeBox(o,t,e,s),m[e]=u,n+=u.kernedWidth,s=o;if(m[e]={left:u?u.left+u.width:0,width:0,kernedWidth:0,height:this.fontSize},S){switch(b=S.segmentsInfo[S.segmentsInfo.length-1].length,v=i.util.getPointOnPath(S.path,0,S.segmentsInfo),v.x+=S.pathOffset.x,v.y+=S.pathOffset.y,this.textAlign){case"left":p=E?b-n:0;break;case"center":p=(b-n)/2;break;case"right":p=E?0:b-n;break}for(p+=this.pathStartOffset*(E?-1:1),e=E?h.length-1:0;E?e>=0:e<h.length;E?e--:e++)u=m[e],p>b?p%=b:p<0&&(p+=b),this._setGraphemeOnPath(p,u,v),p+=u.kernedWidth}return{width:n,numOfSpaces:d}},_setGraphemeOnPath:function(t,n,e){var o=t+n.kernedWidth/2,h=this.path,s=i.util.getPointOnPath(h.path,o,h.segmentsInfo);n.renderLeft=s.x-e.x,n.renderTop=s.y-e.y,n.angle=s.angle+(this.pathSide==="right"?Math.PI:0)},_getGraphemeBox:function(t,n,e,o,h){var s=this.getCompleteStyleDeclaration(n,e),u=o?this.getCompleteStyleDeclaration(n,e-1):{},d=this._measureChar(t,s,o,u),m=d.kernedWidth,p=d.width,v;this.charSpacing!==0&&(v=this._getWidthOfCharSpacing(),p+=v,m+=v);var b={width:p,left:0,height:s.fontSize,kernedWidth:m,deltaY:s.deltaY};if(e>0&&!h){var S=this.__charBounds[n][e-1];b.left=S.left+S.width+d.kernedWidth-d.width}return b},getHeightOfLine:function(t){if(this.__lineHeights[t])return this.__lineHeights[t];for(var n=this._textLines[t],e=this.getHeightOfChar(t,0),o=1,h=n.length;o<h;o++)e=Math.max(this.getHeightOfChar(t,o),e);return this.__lineHeights[t]=e*this.lineHeight*this._fontSizeMult},calcTextHeight:function(){for(var t,n=0,e=0,o=this._textLines.length;e<o;e++)t=this.getHeightOfLine(e),n+=e===o-1?t/this.lineHeight:t;return n},_getLeftOffset:function(){return this.direction==="ltr"?-this.width/2:this.width/2},_getTopOffset:function(){return-this.height/2},_renderTextCommon:function(t,n){t.save();for(var e=0,o=this._getLeftOffset(),h=this._getTopOffset(),s=0,u=this._textLines.length;s<u;s++){var d=this.getHeightOfLine(s),m=d/this.lineHeight,p=this._getLineLeftOffset(s);this._renderTextLine(n,t,this._textLines[s],o+p,h+e+m,s),e+=d}t.restore()},_renderTextFill:function(t){!this.fill&&!this.styleHas("fill")||this._renderTextCommon(t,"fillText")},_renderTextStroke:function(t){(!this.stroke||this.strokeWidth===0)&&this.isEmptyStyles()||(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())},_renderChars:function(t,n,e,o,h,s){var u=this.getHeightOfLine(s),d=this.textAlign.indexOf("justify")!==-1,m,p,v="",b,S=0,E,F=this.path,R=!d&&this.charSpacing===0&&this.isEmptyStyles(s)&&!F,z=this.direction==="ltr",K=this.direction==="ltr"?1:-1,Z,q=n.canvas.getAttribute("dir");if(n.save(),q!==this.direction&&(n.canvas.setAttribute("dir",z?"ltr":"rtl"),n.direction=z?"ltr":"rtl",n.textAlign=z?"left":"right"),h-=u*this._fontSizeFraction/this.lineHeight,R){this._renderChar(t,n,s,0,e.join(""),o,h,u),n.restore();return}for(var $=0,tt=e.length-1;$<=tt;$++)E=$===tt||this.charSpacing||F,v+=e[$],b=this.__charBounds[s][$],S===0?(o+=K*(b.kernedWidth-b.width),S+=b.width):S+=b.kernedWidth,d&&!E&&this._reSpaceAndTab.test(e[$])&&(E=!0),E||(m=m||this.getCompleteStyleDeclaration(s,$),p=this.getCompleteStyleDeclaration(s,$+1),E=i.util.hasStyleChanged(m,p,!1)),E&&(F?(n.save(),n.translate(b.renderLeft,b.renderTop),n.rotate(b.angle),this._renderChar(t,n,s,$,v,-S/2,0,u),n.restore()):(Z=o,this._renderChar(t,n,s,$,v,Z,h,u)),v="",m=p,o+=K*S,S=0);n.restore()},_applyPatternGradientTransformText:function(t){var n=i.util.createCanvasElement(),e,o=this.width+this.strokeWidth,h=this.height+this.strokeWidth;return n.width=o,n.height=h,e=n.getContext("2d"),e.beginPath(),e.moveTo(0,0),e.lineTo(o,0),e.lineTo(o,h),e.lineTo(0,h),e.closePath(),e.translate(o/2,h/2),e.fillStyle=t.toLive(e),this._applyPatternGradientTransform(e,t),e.fill(),e.createPattern(n,"no-repeat")},handleFiller:function(t,n,e){var o,h;return e.toLive?e.gradientUnits==="percentage"||e.gradientTransform||e.patternTransform?(o=-this.width/2,h=-this.height/2,t.translate(o,h),t[n]=this._applyPatternGradientTransformText(e),{offsetX:o,offsetY:h}):(t[n]=e.toLive(t,this),this._applyPatternGradientTransform(t,e)):(t[n]=e,{offsetX:0,offsetY:0})},_setStrokeStyles:function(t,n){return t.lineWidth=n.strokeWidth,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",n.stroke)},_setFillStyles:function(t,n){return this.handleFiller(t,"fillStyle",n.fill)},_renderChar:function(t,n,e,o,h,s,u){var d=this._getStyleDeclaration(e,o),m=this.getCompleteStyleDeclaration(e,o),p=t==="fillText"&&m.fill,v=t==="strokeText"&&m.stroke&&m.strokeWidth,b,S;!v&&!p||(n.save(),p&&(b=this._setFillStyles(n,m)),v&&(S=this._setStrokeStyles(n,m)),n.font=this._getFontDeclaration(m),d&&d.textBackgroundColor&&this._removeShadow(n),d&&d.deltaY&&(u+=d.deltaY),p&&n.fillText(h,s-b.offsetX,u-b.offsetY),v&&n.strokeText(h,s-S.offsetX,u-S.offsetY),n.restore())},setSuperscript:function(t,n){return this._setScript(t,n,this.superscript)},setSubscript:function(t,n){return this._setScript(t,n,this.subscript)},_setScript:function(t,n,e){var o=this.get2DCursorLocation(t,!0),h=this.getValueOfPropertyAt(o.lineIndex,o.charIndex,"fontSize"),s=this.getValueOfPropertyAt(o.lineIndex,o.charIndex,"deltaY"),u={fontSize:h*e.size,deltaY:s+h*e.baseline};return this.setSelectionStyles(u,t,n),this},_getLineLeftOffset:function(t){var n=this.getLineWidth(t),e=this.width-n,o=this.textAlign,h=this.direction,u,s=0,u=this.isEndOfWrapping(t);return o==="justify"||o==="justify-center"&&!u||o==="justify-right"&&!u||o==="justify-left"&&!u?0:(o==="center"&&(s=e/2),o==="right"&&(s=e),o==="justify-center"&&(s=e/2),o==="justify-right"&&(s=e),h==="rtl"&&(s-=e),s)},_clearCache:function(){this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]},_shouldClearDimensionCache:function(){var t=this._forceClearCache;return t||(t=this.hasStateChanged("_dimensionAffectingProps")),t&&(this.dirty=!0,this._forceClearCache=!1),t},getLineWidth:function(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];var n=this.measureLine(t),e=n.width;return this.__lineWidths[t]=e,e},_getWidthOfCharSpacing:function(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0},getValueOfPropertyAt:function(t,n,e){var o=this._getStyleDeclaration(t,n);return o&&typeof o[e]<"u"?o[e]:this[e]},_renderTextDecoration:function(t,n){if(!(!this[n]&&!this.styleHas(n))){for(var e,o,h,s,u,d,m,p,v=this._getLeftOffset(),b=this._getTopOffset(),S,E,F,R,z,K,Z,q,$=this.path,tt=this._getWidthOfCharSpacing(),it=this.offsets[n],et=0,w=this._textLines.length;et<w;et++){if(e=this.getHeightOfLine(et),!this[n]&&!this.styleHas(n,et)){b+=e;continue}m=this._textLines[et],K=e/this.lineHeight,s=this._getLineLeftOffset(et),E=0,F=0,p=this.getValueOfPropertyAt(et,0,n),q=this.getValueOfPropertyAt(et,0,"fill"),S=b+K*(1-this._fontSizeFraction),o=this.getHeightOfChar(et,0),u=this.getValueOfPropertyAt(et,0,"deltaY");for(var k=0,A=m.length;k<A;k++)if(R=this.__charBounds[et][k],z=this.getValueOfPropertyAt(et,k,n),Z=this.getValueOfPropertyAt(et,k,"fill"),h=this.getHeightOfChar(et,k),d=this.getValueOfPropertyAt(et,k,"deltaY"),$&&z&&Z)t.save(),t.fillStyle=q,t.translate(R.renderLeft,R.renderTop),t.rotate(R.angle),t.fillRect(-R.kernedWidth/2,it*h+d,R.kernedWidth,this.fontSize/15),t.restore();else if((z!==p||Z!==q||h!==o||d!==u)&&F>0){var P=v+s+E;this.direction==="rtl"&&(P=this.width-P-F),p&&q&&(t.fillStyle=q,t.fillRect(P,S+it*o+u,F,this.fontSize/15)),E=R.left,F=R.width,p=z,q=Z,o=h,u=d}else F+=R.kernedWidth;var P=v+s+E;this.direction==="rtl"&&(P=this.width-P-F),t.fillStyle=Z,z&&Z&&t.fillRect(P,S+it*o+u,F-tt,this.fontSize/15),b+=e}this._removeShadow(t)}},_getFontDeclaration:function(t,n){var e=t||this,o=this.fontFamily,h=i.Text.genericFonts.indexOf(o.toLowerCase())>-1,s=o===void 0||o.indexOf("'")>-1||o.indexOf(",")>-1||o.indexOf('"')>-1||h?e.fontFamily:'"'+e.fontFamily+'"';return[i.isLikelyNode?e.fontWeight:e.fontStyle,i.isLikelyNode?e.fontStyle:e.fontWeight,n?this.CACHE_FONT_SIZE+"px":e.fontSize+"px",s].join(" ")},render:function(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",t)))},_splitTextIntoLines:function(t){for(var n=t.split(this._reNewline),e=new Array(n.length),o=[`
437
+ `],h=[],s=0;s<n.length;s++)e[s]=i.util.string.graphemeSplit(n[s]),h=h.concat(e[s],o);return h.pop(),{_unwrappedLines:e,lines:n,graphemeText:h,graphemeLines:e}},toObject:function(t){var n=a.concat(t),e=this.callSuper("toObject",n);return e.styles=i.util.stylesToArray(this.styles,this.text),e.path&&(e.path=this.path.toObject()),e},set:function(t,n){this.callSuper("set",t,n);var e=!1,o=!1;if(typeof t=="object")for(var h in t)h==="path"&&this.setPathInfo(),e=e||this._dimensionAffectingProps.indexOf(h)!==-1,o=o||h==="path";else e=this._dimensionAffectingProps.indexOf(t)!==-1,o=t==="path";return o&&this.setPathInfo(),e&&(this.initDimensions(),this.setCoords()),this},complexity:function(){return 1}}),i.Text.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("x y dx dy font-family font-style font-weight font-size letter-spacing text-decoration text-anchor".split(" ")),i.Text.DEFAULT_SVG_FONT_SIZE=16,i.Text.fromElement=function(t,n,e){if(!t)return n(null);var o=i.parseAttributes(t,i.Text.ATTRIBUTE_NAMES),h=o.textAnchor||"left";if(e=i.util.object.extend(e?l(e):{},o),e.top=e.top||0,e.left=e.left||0,o.textDecoration){var s=o.textDecoration;s.indexOf("underline")!==-1&&(e.underline=!0),s.indexOf("overline")!==-1&&(e.overline=!0),s.indexOf("line-through")!==-1&&(e.linethrough=!0),delete e.textDecoration}"dx"in o&&(e.left+=o.dx),"dy"in o&&(e.top+=o.dy),"fontSize"in e||(e.fontSize=i.Text.DEFAULT_SVG_FONT_SIZE);var u="";"textContent"in t?u=t.textContent:"firstChild"in t&&t.firstChild!==null&&"data"in t.firstChild&&t.firstChild.data!==null&&(u=t.firstChild.data),u=u.replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," ");var d=e.strokeWidth;e.strokeWidth=0;var m=new i.Text(u,e),p=m.getScaledHeight()/m.height,v=(m.height+m.strokeWidth)*m.lineHeight-m.height,b=v*p,S=m.getScaledHeight()+b,E=0;h==="center"&&(E=m.getScaledWidth()/2),h==="right"&&(E=m.getScaledWidth()),m.set({left:m.left-E,top:m.top-(S-m.fontSize*(.07+m._fontSizeFraction))/m.lineHeight,strokeWidth:typeof d<"u"?d:1}),n(m)},i.Text.fromObject=function(t,n){var e=l(t),o=t.path;return delete e.path,i.Object._fromObject("Text",e,function(h){h.styles=i.util.stylesFromArray(t.styles,t.text),o?i.Object._fromObject("Path",o,function(s){h.set("path",s),n(h)},"path"):n(h)},"text")},i.Text.genericFonts=["sans-serif","serif","cursive","fantasy","monospace"],i.util.createAccessors&&i.util.createAccessors(i.Text)})(f),(function(){r.util.object.extend(r.Text.prototype,{isEmptyStyles:function(c){if(!this.styles||typeof c<"u"&&!this.styles[c])return!0;var i=typeof c>"u"?this.styles:{line:this.styles[c]};for(var l in i)for(var a in i[l])for(var t in i[l][a])return!1;return!0},styleHas:function(c,i){if(!this.styles||!c||c===""||typeof i<"u"&&!this.styles[i])return!1;var l=typeof i>"u"?this.styles:{0:this.styles[i]};for(var a in l)for(var t in l[a])if(typeof l[a][t][c]<"u")return!0;return!1},cleanStyle:function(c){if(!this.styles||!c||c==="")return!1;var i=this.styles,l=0,a,t,n=!0,e=0,o;for(var h in i){a=0;for(var s in i[h]){var o=i[h][s],u=o.hasOwnProperty(c);l++,u?(t?o[c]!==t&&(n=!1):t=o[c],o[c]===this[c]&&delete o[c]):n=!1,Object.keys(o).length!==0?a++:delete i[h][s]}a===0&&delete i[h]}for(var d=0;d<this._textLines.length;d++)e+=this._textLines[d].length;n&&l===e&&(this[c]=t,this.removeStyle(c))},removeStyle:function(c){if(!(!this.styles||!c||c==="")){var i=this.styles,l,a,t;for(a in i){l=i[a];for(t in l)delete l[t][c],Object.keys(l[t]).length===0&&delete l[t];Object.keys(l).length===0&&delete i[a]}}},_extendStyles:function(c,i){var l=this.get2DCursorLocation(c);this._getLineStyle(l.lineIndex)||this._setLineStyle(l.lineIndex),this._getStyleDeclaration(l.lineIndex,l.charIndex)||this._setStyleDeclaration(l.lineIndex,l.charIndex,{}),r.util.object.extend(this._getStyleDeclaration(l.lineIndex,l.charIndex),i)},get2DCursorLocation:function(c,i){typeof c>"u"&&(c=this.selectionStart);for(var l=i?this._unwrappedTextLines:this._textLines,a=l.length,t=0;t<a;t++){if(c<=l[t].length)return{lineIndex:t,charIndex:c};c-=l[t].length+this.missingNewlineOffset(t)}return{lineIndex:t-1,charIndex:l[t-1].length<c?l[t-1].length:c}},getSelectionStyles:function(c,i,l){typeof c>"u"&&(c=this.selectionStart||0),typeof i>"u"&&(i=this.selectionEnd||c);for(var a=[],t=c;t<i;t++)a.push(this.getStyleAtPosition(t,l));return a},getStyleAtPosition:function(c,i){var l=this.get2DCursorLocation(c),a=i?this.getCompleteStyleDeclaration(l.lineIndex,l.charIndex):this._getStyleDeclaration(l.lineIndex,l.charIndex);return a||{}},setSelectionStyles:function(c,i,l){typeof i>"u"&&(i=this.selectionStart||0),typeof l>"u"&&(l=this.selectionEnd||i);for(var a=i;a<l;a++)this._extendStyles(a,c);return this._forceClearCache=!0,this},_getStyleDeclaration:function(c,i){var l=this.styles&&this.styles[c];return l?l[i]:null},getCompleteStyleDeclaration:function(c,i){for(var l=this._getStyleDeclaration(c,i)||{},a={},t,n=0;n<this._styleProperties.length;n++)t=this._styleProperties[n],a[t]=typeof l[t]>"u"?this[t]:l[t];return a},_setStyleDeclaration:function(c,i,l){this.styles[c][i]=l},_deleteStyleDeclaration:function(c,i){delete this.styles[c][i]},_getLineStyle:function(c){return!!this.styles[c]},_setLineStyle:function(c){this.styles[c]={}},_deleteLineStyle:function(c){delete this.styles[c]}})})(),(function(){function c(i){i.textDecoration&&(i.textDecoration.indexOf("underline")>-1&&(i.underline=!0),i.textDecoration.indexOf("line-through")>-1&&(i.linethrough=!0),i.textDecoration.indexOf("overline")>-1&&(i.overline=!0),delete i.textDecoration)}r.IText=r.util.createClass(r.Text,r.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(i,l){this.callSuper("initialize",i,l),this.initBehavior()},setSelectionStart:function(i){i=Math.max(i,0),this._updateAndFire("selectionStart",i)},setSelectionEnd:function(i){i=Math.min(i,this.text.length),this._updateAndFire("selectionEnd",i)},_updateAndFire:function(i,l){this[i]!==l&&(this._fireSelectionChanged(),this[i]=l),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(i){this.clearContextTop(),this.callSuper("render",i),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(i){this.callSuper("_render",i)},clearContextTop:function(i){if(!(!this.isEditing||!this.canvas||!this.canvas.contextTop)){var l=this.canvas.contextTop,a=this.canvas.viewportTransform;l.save(),l.transform(a[0],a[1],a[2],a[3],a[4],a[5]),this.transform(l),this._clearTextArea(l),i||l.restore()}},renderCursorOrSelection:function(){if(!(!this.isEditing||!this.canvas||!this.canvas.contextTop)){var i=this._getCursorBoundaries(),l=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(i,l):this.renderSelection(i,l),l.restore()}},_clearTextArea:function(i){var l=this.width+4,a=this.height+4;i.clearRect(-l/2,-a/2,l,a)},_getCursorBoundaries:function(i){typeof i>"u"&&(i=this.selectionStart);var l=this._getLeftOffset(),a=this._getTopOffset(),t=this._getCursorBoundariesOffsets(i);return{left:l,top:a,leftOffset:t.left,topOffset:t.top}},_getCursorBoundariesOffsets:function(i){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var l,a,t,n=0,e=0,o,h=this.get2DCursorLocation(i);t=h.charIndex,a=h.lineIndex;for(var s=0;s<a;s++)n+=this.getHeightOfLine(s);l=this._getLineLeftOffset(a);var u=this.__charBounds[a][t];return u&&(e=u.left),this.charSpacing!==0&&t===this._textLines[a].length&&(e-=this._getWidthOfCharSpacing()),o={top:n,left:l+(e>0?e:0)},this.direction==="rtl"&&(o.left*=-1),this.cursorOffsetCache=o,this.cursorOffsetCache},renderCursor:function(i,l){var a=this.get2DCursorLocation(),t=a.lineIndex,n=a.charIndex>0?a.charIndex-1:0,e=this.getValueOfPropertyAt(t,n,"fontSize"),o=this.scaleX*this.canvas.getZoom(),h=this.cursorWidth/o,s=i.topOffset,u=this.getValueOfPropertyAt(t,n,"deltaY");s+=(1-this._fontSizeFraction)*this.getHeightOfLine(t)/this.lineHeight-e*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(i,l),l.fillStyle=this.cursorColor||this.getValueOfPropertyAt(t,n,"fill"),l.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,l.fillRect(i.left+i.leftOffset-h/2,s+i.top+u,h,e)},renderSelection:function(i,l){for(var a=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,t=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,n=this.textAlign.indexOf("justify")!==-1,e=this.get2DCursorLocation(a),o=this.get2DCursorLocation(t),h=e.lineIndex,s=o.lineIndex,u=e.charIndex<0?0:e.charIndex,d=o.charIndex<0?0:o.charIndex,m=h;m<=s;m++){var p=this._getLineLeftOffset(m)||0,v=this.getHeightOfLine(m),b=0,S=0,E=0;if(m===h&&(S=this.__charBounds[h][u].left),m>=h&&m<s)E=n&&!this.isEndOfWrapping(m)?this.width:this.getLineWidth(m)||5;else if(m===s)if(d===0)E=this.__charBounds[s][d].left;else{var F=this._getWidthOfCharSpacing();E=this.__charBounds[s][d-1].left+this.__charBounds[s][d-1].width-F}b=v,(this.lineHeight<1||m===s&&this.lineHeight>1)&&(v/=this.lineHeight);var R=i.left+p+S,z=E-S,K=v,Z=0;this.inCompositionMode?(l.fillStyle=this.compositionColor||"black",K=1,Z=v):l.fillStyle=this.selectionColor,this.direction==="rtl"&&(R=this.width-R-z),l.fillRect(R,i.top+i.topOffset+Z,z,K),i.topOffset+=b}},getCurrentCharFontSize:function(){var i=this._getCurrentCharIndex();return this.getValueOfPropertyAt(i.l,i.c,"fontSize")},getCurrentCharColor:function(){var i=this._getCurrentCharIndex();return this.getValueOfPropertyAt(i.l,i.c,"fill")},_getCurrentCharIndex:function(){var i=this.get2DCursorLocation(this.selectionStart,!0),l=i.charIndex>0?i.charIndex-1:0;return{l:i.lineIndex,c:l}}}),r.IText.fromObject=function(i,l){var a=r.util.stylesFromArray(i.styles,i.text),t=Object.assign({},i,{styles:a});if(c(t),t.styles)for(var n in t.styles)for(var e in t.styles[n])c(t.styles[n][e]);r.Object._fromObject("IText",t,l,"text")}})(),(function(){var c=r.util.object.clone;r.util.object.extend(r.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var i=this;this.on("added",function(){var l=i.canvas;l&&(l._hasITextHandlers||(l._hasITextHandlers=!0,i._initCanvasHandlers(l)),l._iTextInstances=l._iTextInstances||[],l._iTextInstances.push(i))})},initRemovedHandler:function(){var i=this;this.on("removed",function(){var l=i.canvas;l&&(l._iTextInstances=l._iTextInstances||[],r.util.removeFromArray(l._iTextInstances,i),l._iTextInstances.length===0&&(l._hasITextHandlers=!1,i._removeCanvasHandlers(l)))})},_initCanvasHandlers:function(i){i._mouseUpITextHandler=function(){i._iTextInstances&&i._iTextInstances.forEach(function(l){l.__isMousedown=!1})},i.on("mouse:up",i._mouseUpITextHandler)},_removeCanvasHandlers:function(i){i.off("mouse:up",i._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(i,l,a,t){var n;return n={isAborted:!1,abort:function(){this.isAborted=!0}},i.animate("_currentCursorOpacity",l,{duration:a,onComplete:function(){n.isAborted||i[t]()},onChange:function(){i.canvas&&i.selectionStart===i.selectionEnd&&i.renderCursorOrSelection()},abort:function(){return n.isAborted}}),n},_onTickComplete:function(){var i=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout(function(){i._currentTickCompleteState=i._animateCursor(i,0,this.cursorDuration/2,"_tick")},100)},initDelayedCursor:function(i){var l=this,a=i?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout(function(){l._tick()},a)},abortCursorAnimation:function(){var i=this._currentTickState||this._currentTickCompleteState,l=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,i&&l&&l.clearContext(l.contextTop||l.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(i){var l=0,a=i-1;if(this._reSpace.test(this._text[a]))for(;this._reSpace.test(this._text[a]);)l++,a--;for(;/\S/.test(this._text[a])&&a>-1;)l++,a--;return i-l},findWordBoundaryRight:function(i){var l=0,a=i;if(this._reSpace.test(this._text[a]))for(;this._reSpace.test(this._text[a]);)l++,a++;for(;/\S/.test(this._text[a])&&a<this._text.length;)l++,a++;return i+l},findLineBoundaryLeft:function(i){for(var l=0,a=i-1;!/\n/.test(this._text[a])&&a>-1;)l++,a--;return i-l},findLineBoundaryRight:function(i){for(var l=0,a=i;!/\n/.test(this._text[a])&&a<this._text.length;)l++,a++;return i+l},searchWordBoundary:function(i,l){for(var a=this._text,t=this._reSpace.test(a[i])?i-1:i,n=a[t],e=r.reNonWord;!e.test(n)&&t>0&&t<a.length;)t+=l,n=a[t];return e.test(n)&&(t+=l===1?0:1),t},selectWord:function(i){i=i||this.selectionStart;var l=this.searchWordBoundary(i,-1),a=this.searchWordBoundary(i,1);this.selectionStart=l,this.selectionEnd=a,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()},selectLine:function(i){i=i||this.selectionStart;var l=this.findLineBoundaryLeft(i),a=this.findLineBoundaryRight(i);return this.selectionStart=l,this.selectionEnd=a,this._fireSelectionChanged(),this._updateTextarea(),this},enterEditing:function(i){if(!(this.isEditing||!this.editable))return this.canvas&&(this.canvas.calcOffset(),this.exitEditingOnOthers(this.canvas)),this.isEditing=!0,this.initHiddenTextarea(i),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick(),this.fire("editing:entered"),this._fireSelectionChanged(),this.canvas?(this.canvas.fire("text:editing:entered",{target:this}),this.initMouseMoveHandler(),this.canvas.requestRenderAll(),this):this},exitEditingOnOthers:function(i){i._iTextInstances&&i._iTextInstances.forEach(function(l){l.selected=!1,l.isEditing&&l.exitEditing()})},initMouseMoveHandler:function(){this.canvas.on("mouse:move",this.mouseMoveHandler)},mouseMoveHandler:function(i){if(!(!this.__isMousedown||!this.isEditing)){document.activeElement!==this.hiddenTextarea&&this.hiddenTextarea.focus();var l=this.getSelectionStartFromPointer(i.e),a=this.selectionStart,t=this.selectionEnd;(l!==this.__selectionStartOnMouseDown||a===t)&&(a===l||t===l)||(l>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=l):(this.selectionStart=l,this.selectionEnd=this.__selectionStartOnMouseDown),(this.selectionStart!==a||this.selectionEnd!==t)&&(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},fromStringToGraphemeSelection:function(i,l,a){var t=a.slice(0,i),n=r.util.string.graphemeSplit(t).length;if(i===l)return{selectionStart:n,selectionEnd:n};var e=a.slice(i,l),o=r.util.string.graphemeSplit(e).length;return{selectionStart:n,selectionEnd:n+o}},fromGraphemeToStringSelection:function(i,l,a){var t=a.slice(0,i),n=t.join("").length;if(i===l)return{selectionStart:n,selectionEnd:n};var e=a.slice(i,l),o=e.join("").length;return{selectionStart:n,selectionEnd:n+o}},_updateTextarea:function(){if(this.cursorOffsetCache={},!!this.hiddenTextarea){if(!this.inCompositionMode){var i=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=i.selectionStart,this.hiddenTextarea.selectionEnd=i.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var i=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=i.selectionEnd,this.inCompositionMode||(this.selectionStart=i.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var i=this._calcTextareaPosition();this.hiddenTextarea.style.left=i.left,this.hiddenTextarea.style.top=i.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var i=this.inCompositionMode?this.compositionStart:this.selectionStart,l=this._getCursorBoundaries(i),a=this.get2DCursorLocation(i),t=a.lineIndex,n=a.charIndex,e=this.getValueOfPropertyAt(t,n,"fontSize")*this.lineHeight,o=l.leftOffset,h=this.calcTransformMatrix(),s={x:l.left+o,y:l.top+l.topOffset+e},u=this.canvas.getRetinaScaling(),d=this.canvas.upperCanvasEl,m=d.width/u,p=d.height/u,v=m-e,b=p-e,S=d.clientWidth/m,E=d.clientHeight/p;return s=r.util.transformPoint(s,h),s=r.util.transformPoint(s,this.canvas.viewportTransform),s.x*=S,s.y*=E,s.x<0&&(s.x=0),s.x>v&&(s.x=v),s.y<0&&(s.y=0),s.y>b&&(s.y=b),s.x+=this.canvas._offset.left,s.y+=this.canvas._offset.top,{left:s.x+"px",top:s.y+"px",fontSize:e+"px",charHeight:e}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var i=this._textBeforeEdit!==this.text,l=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,l&&(l.blur&&l.blur(),l.parentNode&&l.parentNode.removeChild(l)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),i&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),i&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var i in this.styles)this._textLines[i]||delete this.styles[i]},removeStyleFromTo:function(i,l){var a=this.get2DCursorLocation(i,!0),t=this.get2DCursorLocation(l,!0),n=a.lineIndex,e=a.charIndex,o=t.lineIndex,h=t.charIndex,s,u;if(n!==o){if(this.styles[n])for(s=e;s<this._unwrappedTextLines[n].length;s++)delete this.styles[n][s];if(this.styles[o])for(s=h;s<this._unwrappedTextLines[o].length;s++)u=this.styles[o][s],u&&(this.styles[n]||(this.styles[n]={}),this.styles[n][e+s-h]=u);for(s=n+1;s<=o;s++)delete this.styles[s];this.shiftLineStyles(o,n-o)}else if(this.styles[n]){u=this.styles[n];var d=h-e,m,p;for(s=e;s<h;s++)delete u[s];for(p in this.styles[n])m=parseInt(p,10),m>=h&&(u[m-d]=u[p],delete u[p])}},shiftLineStyles:function(i,l){var a=c(this.styles);for(var t in this.styles){var n=parseInt(t,10);n>i&&(this.styles[n+l]=a[n],a[n-l]||delete this.styles[n])}},restartCursorIfNeeded:function(){(!this._currentTickState||this._currentTickState.isAborted||!this._currentTickCompleteState||this._currentTickCompleteState.isAborted)&&this.initDelayedCursor()},insertNewlineStyleObject:function(i,l,a,t){var n,e={},o=!1,h=this._unwrappedTextLines[i].length===l;a||(a=1),this.shiftLineStyles(i,a),this.styles[i]&&(n=this.styles[i][l===0?l:l-1]);for(var s in this.styles[i]){var u=parseInt(s,10);u>=l&&(o=!0,e[u-l]=this.styles[i][s],h&&l===0||delete this.styles[i][s])}var d=!1;for(o&&!h&&(this.styles[i+a]=e,d=!0),d&&a--;a>0;)t&&t[a-1]?this.styles[i+a]={0:c(t[a-1])}:n?this.styles[i+a]={0:c(n)}:delete this.styles[i+a],a--;this._forceClearCache=!0},insertCharStyleObject:function(i,l,a,t){this.styles||(this.styles={});var n=this.styles[i],e=n?c(n):{};a||(a=1);for(var o in e){var h=parseInt(o,10);h>=l&&(n[h+a]=e[h],e[h-a]||delete n[h])}if(this._forceClearCache=!0,t){for(;a--;)Object.keys(t[a]).length&&(this.styles[i]||(this.styles[i]={}),this.styles[i][l+a]=c(t[a]));return}if(n)for(var s=n[l?l-1:1];s&&a--;)this.styles[i][l+a]=c(s)},insertNewStyleBlock:function(i,l,a){for(var t=this.get2DCursorLocation(l,!0),n=[0],e=0,o=0;o<i.length;o++)i[o]===`
438
+ `?(e++,n[e]=0):n[e]++;n[0]>0&&(this.insertCharStyleObject(t.lineIndex,t.charIndex,n[0],a),a=a&&a.slice(n[0]+1)),e&&this.insertNewlineStyleObject(t.lineIndex,t.charIndex+n[0],e);for(var o=1;o<e;o++)n[o]>0?this.insertCharStyleObject(t.lineIndex+o,0,n[o],a):a&&this.styles[t.lineIndex+o]&&a[0]&&(this.styles[t.lineIndex+o][0]=a[0]),a=a&&a.slice(n[o]+1);n[o]>0&&this.insertCharStyleObject(t.lineIndex+o,0,n[o],a)},setSelectionStartEndWithShift:function(i,l,a){a<=i?(l===i?this._selectionDirection="left":this._selectionDirection==="right"&&(this._selectionDirection="left",this.selectionEnd=i),this.selectionStart=a):a>i&&a<l?this._selectionDirection==="right"?this.selectionEnd=a:this.selectionStart=a:(l===i?this._selectionDirection="right":this._selectionDirection==="left"&&(this._selectionDirection="right",this.selectionStart=l),this.selectionEnd=a)},setSelectionInBoundaries:function(){var i=this.text.length;this.selectionStart>i?this.selectionStart=i:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>i?this.selectionEnd=i:this.selectionEnd<0&&(this.selectionEnd=0)}})})(),r.util.object.extend(r.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(c){if(this.canvas){this.__newClickTime=+new Date;var i=c.pointer;this.isTripleClick(i)&&(this.fire("tripleclick",c),this._stopEvent(c.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=i,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(c){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===c.x&&this.__lastPointer.y===c.y},_stopEvent:function(c){c.preventDefault&&c.preventDefault(),c.stopPropagation&&c.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(c){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(c.e))},tripleClickHandler:function(c){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(c.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(c){!this.canvas||!this.editable||c.e.button&&c.e.button!==1||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(c.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(c){!this.canvas||!this.editable||c.e.button&&c.e.button!==1||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(c){if(this.__isMousedown=!1,!(!this.editable||this.group||c.transform&&c.transform.actionPerformed||c.e.button&&c.e.button!==1)){if(this.canvas){var i=this.canvas._activeObject;if(i&&i!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(c.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(c){var i=this.getSelectionStartFromPointer(c),l=this.selectionStart,a=this.selectionEnd;c.shiftKey?this.setSelectionStartEndWithShift(l,a,i):(this.selectionStart=i,this.selectionEnd=i),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(c){for(var i=this.getLocalPointer(c),l=0,a=0,t=0,n=0,e=0,o,h,s=0,u=this._textLines.length;s<u&&t<=i.y;s++)t+=this.getHeightOfLine(s)*this.scaleY,e=s,s>0&&(n+=this._textLines[s-1].length+this.missingNewlineOffset(s-1));o=this._getLineLeftOffset(e),a=o*this.scaleX,h=this._textLines[e],this.direction==="rtl"&&(i.x=this.width*this.scaleX-i.x+a);for(var d=0,m=h.length;d<m&&(l=a,a+=this.__charBounds[e][d].kernedWidth*this.scaleX,a<=i.x);d++)n++;return this._getNewSelectionStartFromOffset(i,l,a,n,m)},_getNewSelectionStartFromOffset:function(c,i,l,a,t){var n=c.x-i,e=l-c.x,o=e>n||e<0?0:1,h=a+o;return this.flipX&&(h=t-h),h>this._text.length&&(h=this._text.length),h}}),r.util.object.extend(r.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=r.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var c=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+c.top+"; left: "+c.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: "+c.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):r.document.body.appendChild(this.hiddenTextarea),r.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),r.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),r.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),r.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),r.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),r.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),r.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),r.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),r.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(r.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(c){if(this.isEditing){var i=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(c.keyCode in i)this[i[c.keyCode]](c);else if(c.keyCode in this.ctrlKeysMapDown&&(c.ctrlKey||c.metaKey))this[this.ctrlKeysMapDown[c.keyCode]](c);else return;c.stopImmediatePropagation(),c.preventDefault(),c.keyCode>=33&&c.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(c){if(!this.isEditing||this._copyDone||this.inCompositionMode){this._copyDone=!1;return}if(c.keyCode in this.ctrlKeysMapUp&&(c.ctrlKey||c.metaKey))this[this.ctrlKeysMapUp[c.keyCode]](c);else return;c.stopImmediatePropagation(),c.preventDefault(),this.canvas&&this.canvas.requestRenderAll()},onInput:function(c){var i=this.fromPaste;if(this.fromPaste=!1,c&&c.stopPropagation(),!!this.isEditing){var l=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,a=this._text.length,t=l.length,n,e,o=t-a,h=this.selectionStart,s=this.selectionEnd,u=h!==s,d,m,p;if(this.hiddenTextarea.value===""){this.styles={},this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll());return}var v=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),b=h>v.selectionStart;u?(n=this._text.slice(h,s),o+=s-h):t<a&&(b?n=this._text.slice(s+o,s):n=this._text.slice(h,h-o)),e=l.slice(v.selectionEnd-o,v.selectionEnd),n&&n.length&&(e.length&&(d=this.getSelectionStyles(h,h+1,!1),d=e.map(function(){return d[0]})),u?(m=h,p=s):b?(m=s-n.length,p=s):(m=s,p=s+n.length),this.removeStyleFromTo(m,p)),e.length&&(i&&e.join("")===r.copiedText&&!r.disableStyleCopyPaste&&(d=r.copiedTextStyle),this.insertNewStyleBlock(e,h,d)),this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())}},onCompositionStart:function(){this.inCompositionMode=!0},onCompositionEnd:function(){this.inCompositionMode=!1},onCompositionUpdate:function(c){this.compositionStart=c.target.selectionStart,this.compositionEnd=c.target.selectionEnd,this.updateTextareaPosition()},copy:function(){this.selectionStart!==this.selectionEnd&&(r.copiedText=this.getSelectedText(),r.disableStyleCopyPaste?r.copiedTextStyle=null:r.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0)},paste:function(){this.fromPaste=!0},_getClipboardData:function(c){return c&&c.clipboardData||r.window.clipboardData},_getWidthBeforeCursor:function(c,i){var l=this._getLineLeftOffset(c),a;return i>0&&(a=this.__charBounds[c][i-1],l+=a.left+a.width),l},getDownCursorOffset:function(c,i){var l=this._getSelectionForOffset(c,i),a=this.get2DCursorLocation(l),t=a.lineIndex;if(t===this._textLines.length-1||c.metaKey||c.keyCode===34)return this._text.length-l;var n=a.charIndex,e=this._getWidthBeforeCursor(t,n),o=this._getIndexOnLine(t+1,e),h=this._textLines[t].slice(n);return h.length+o+1+this.missingNewlineOffset(t)},_getSelectionForOffset:function(c,i){return c.shiftKey&&this.selectionStart!==this.selectionEnd&&i?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(c,i){var l=this._getSelectionForOffset(c,i),a=this.get2DCursorLocation(l),t=a.lineIndex;if(t===0||c.metaKey||c.keyCode===33)return-l;var n=a.charIndex,e=this._getWidthBeforeCursor(t,n),o=this._getIndexOnLine(t-1,e),h=this._textLines[t].slice(0,n),s=this.missingNewlineOffset(t-1);return-this._textLines[t-1].length+o-h.length+(1-s)},_getIndexOnLine:function(c,i){for(var l=this._textLines[c],a=this._getLineLeftOffset(c),t=a,n=0,e,o,h=0,s=l.length;h<s;h++)if(e=this.__charBounds[c][h].width,t+=e,t>i){o=!0;var u=t-e,d=t,m=Math.abs(u-i),p=Math.abs(d-i);n=p<m?h:h-1;break}return o||(n=l.length-1),n},moveCursorDown:function(c){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",c)},moveCursorUp:function(c){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",c)},_moveCursorUpOrDown:function(c,i){var l="get"+c+"CursorOffset",a=this[l](i,this._selectionDirection==="right");i.shiftKey?this.moveCursorWithShift(a):this.moveCursorWithoutShift(a),a!==0&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(c){var i=this._selectionDirection==="left"?this.selectionStart+c:this.selectionEnd+c;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,i),c!==0},moveCursorWithoutShift:function(c){return c<0?(this.selectionStart+=c,this.selectionEnd=this.selectionStart):(this.selectionEnd+=c,this.selectionStart=this.selectionEnd),c!==0},moveCursorLeft:function(c){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",c)},_move:function(c,i,l){var a;if(c.altKey)a=this["findWordBoundary"+l](this[i]);else if(c.metaKey||c.keyCode===35||c.keyCode===36)a=this["findLineBoundary"+l](this[i]);else return this[i]+=l==="Left"?-1:1,!0;if(typeof a<"u"&&this[i]!==a)return this[i]=a,!0},_moveLeft:function(c,i){return this._move(c,i,"Left")},_moveRight:function(c,i){return this._move(c,i,"Right")},moveCursorLeftWithoutShift:function(c){var i=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(i=this._moveLeft(c,"selectionStart")),this.selectionEnd=this.selectionStart,i},moveCursorLeftWithShift:function(c){if(this._selectionDirection==="right"&&this.selectionStart!==this.selectionEnd)return this._moveLeft(c,"selectionEnd");if(this.selectionStart!==0)return this._selectionDirection="left",this._moveLeft(c,"selectionStart")},moveCursorRight:function(c){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",c)},_moveCursorLeftOrRight:function(c,i){var l="moveCursor"+c+"With";this._currentCursorOpacity=1,i.shiftKey?l+="Shift":l+="outShift",this[l](i)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(c){if(this._selectionDirection==="left"&&this.selectionStart!==this.selectionEnd)return this._moveRight(c,"selectionStart");if(this.selectionEnd!==this._text.length)return this._selectionDirection="right",this._moveRight(c,"selectionEnd")},moveCursorRightWithoutShift:function(c){var i=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(i=this._moveRight(c,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,i},removeChars:function(c,i){typeof i>"u"&&(i=c+1),this.removeStyleFromTo(c,i),this._text.splice(c,i-c),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(c,i,l,a){typeof a>"u"&&(a=l),a>l&&this.removeStyleFromTo(l,a);var t=r.util.string.graphemeSplit(c);this.insertNewStyleBlock(t,l,i),this._text=[].concat(this._text.slice(0,l),t,this._text.slice(a)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),(function(){var c=r.util.toFixed,i=/ +/g;r.util.object.extend(r.Text.prototype,{_toSVG:function(){var l=this._getSVGLeftTopOffsets(),a=this._getSVGTextAndBg(l.textTop,l.textLeft);return this._wrapSVGTextAndBg(a)},toSVG:function(l){return this._createBaseSVGMarkup(this._toSVG(),{reviver:l,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(l){var a=!0,t=this.getSvgTextDecoration(this);return[l.textBgRects.join(""),' <text xml:space="preserve" ',this.fontFamily?'font-family="'+this.fontFamily.replace(/"/g,"'")+'" ':"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",t?'text-decoration="'+t+'" ':"",'style="',this.getSvgStyles(a),'"',this.addPaintOrder()," >",l.textSpans.join(""),`</text>
439
+ `]},_getSVGTextAndBg:function(l,a){var t=[],n=[],e=l,o;this._setSVGBg(n);for(var h=0,s=this._textLines.length;h<s;h++)o=this._getLineLeftOffset(h),(this.textBackgroundColor||this.styleHas("textBackgroundColor",h))&&this._setSVGTextLineBg(n,h,a+o,e),this._setSVGTextLineText(t,h,a+o,e),e+=this.getHeightOfLine(h);return{textSpans:t,textBgRects:n}},_createTextCharSpan:function(l,a,t,n){var e=l!==l.trim()||l.match(i),o=this.getSvgSpanStyles(a,e),h=o?'style="'+o+'"':"",s=a.deltaY,u="",d=r.Object.NUM_FRACTION_DIGITS;return s&&(u=' dy="'+c(s,d)+'" '),['<tspan x="',c(t,d),'" y="',c(n,d),'" ',u,h,">",r.util.string.escapeXml(l),"</tspan>"].join("")},_setSVGTextLineText:function(l,a,t,n){var e=this.getHeightOfLine(a),o=this.textAlign.indexOf("justify")!==-1,h,s,u="",d,m,p=0,v=this._textLines[a],b;n+=e*(1-this._fontSizeFraction)/this.lineHeight;for(var S=0,E=v.length-1;S<=E;S++)b=S===E||this.charSpacing,u+=v[S],d=this.__charBounds[a][S],p===0?(t+=d.kernedWidth-d.width,p+=d.width):p+=d.kernedWidth,o&&!b&&this._reSpaceAndTab.test(v[S])&&(b=!0),b||(h=h||this.getCompleteStyleDeclaration(a,S),s=this.getCompleteStyleDeclaration(a,S+1),b=r.util.hasStyleChanged(h,s,!0)),b&&(m=this._getStyleDeclaration(a,S)||{},l.push(this._createTextCharSpan(u,m,t,n)),u="",h=s,t+=p,p=0)},_pushTextBgRect:function(l,a,t,n,e,o){var h=r.Object.NUM_FRACTION_DIGITS;l.push(" <rect ",this._getFillAttributes(a),' x="',c(t,h),'" y="',c(n,h),'" width="',c(e,h),'" height="',c(o,h),`"></rect>
440
+ `)},_setSVGTextLineBg:function(l,a,t,n){for(var e=this._textLines[a],o=this.getHeightOfLine(a)/this.lineHeight,h=0,s=0,u,d,m=this.getValueOfPropertyAt(a,0,"textBackgroundColor"),p=0,v=e.length;p<v;p++)u=this.__charBounds[a][p],d=this.getValueOfPropertyAt(a,p,"textBackgroundColor"),d!==m?(m&&this._pushTextBgRect(l,m,t+s,n,h,o),s=u.left,h=u.width,m=d):h+=u.kernedWidth;d&&this._pushTextBgRect(l,d,t+s,n,h,o)},_getFillAttributes:function(l){var a=l&&typeof l=="string"?new r.Color(l):"";return!a||!a.getSource()||a.getAlpha()===1?'fill="'+l+'"':'opacity="'+a.getAlpha()+'" fill="'+a.setAlpha(1).toRgb()+'"'},_getSVGLineTopOffset:function(l){for(var a=0,t=0,n=0;n<l;n++)a+=this.getHeightOfLine(n);return t=this.getHeightOfLine(n),{lineTop:a,offset:(this._fontSizeMult-this._fontSizeFraction)*t/(this.lineHeight*this._fontSizeMult)}},getSvgStyles:function(l){var a=r.Object.prototype.getSvgStyles.call(this,l);return a+" white-space: pre;"}})})(),(function(c){var i=c.fabric||(c.fabric={});i.Textbox=i.util.createClass(i.IText,i.Observable,{type:"textbox",minWidth:20,dynamicMinWidth:2,__cachedLines:null,lockScalingFlip:!0,noScaleCache:!1,_dimensionAffectingProps:i.Text.prototype._dimensionAffectingProps.concat("width"),_wordJoiners:/[ \t\r]/,splitByGrapheme:!1,initDimensions:function(){this.__skipDimension||(this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.indexOf("justify")!==-1&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(l){for(var a=0,t=0,n=0,e={},o=0;o<l.graphemeLines.length;o++)l.graphemeText[n]===`
441
+ `&&o>0?(t=0,n++,a++):!this.splitByGrapheme&&this._reSpaceAndTab.test(l.graphemeText[n])&&o>0&&(t++,n++),e[o]={line:a,offset:t},n+=l.graphemeLines[o].length,t+=l.graphemeLines[o].length;return e},styleHas:function(l,a){if(this._styleMap&&!this.isWrapping){var t=this._styleMap[a];t&&(a=t.line)}return i.Text.prototype.styleHas.call(this,l,a)},isEmptyStyles:function(l){if(!this.styles)return!0;var a=0,t=l+1,n,e,o=!1,h=this._styleMap[l],s=this._styleMap[l+1];h&&(l=h.line,a=h.offset),s&&(t=s.line,o=t===l,n=s.offset),e=typeof l>"u"?this.styles:{line:this.styles[l]};for(var u in e)for(var d in e[u])if(d>=a&&(!o||d<n))for(var m in e[u][d])return!1;return!0},_getStyleDeclaration:function(l,a){if(this._styleMap&&!this.isWrapping){var t=this._styleMap[l];if(!t)return null;l=t.line,a=t.offset+a}return this.callSuper("_getStyleDeclaration",l,a)},_setStyleDeclaration:function(l,a,t){var n=this._styleMap[l];l=n.line,a=n.offset+a,this.styles[l][a]=t},_deleteStyleDeclaration:function(l,a){var t=this._styleMap[l];l=t.line,a=t.offset+a,delete this.styles[l][a]},_getLineStyle:function(l){var a=this._styleMap[l];return!!this.styles[a.line]},_setLineStyle:function(l){var a=this._styleMap[l];this.styles[a.line]={}},_wrapText:function(l,a){var t=[],n;for(this.isWrapping=!0,n=0;n<l.length;n++)t=t.concat(this._wrapLine(l[n],n,a));return this.isWrapping=!1,t},_measureWord:function(l,a,t){var n=0,e,o=!0;t=t||0;for(var h=0,s=l.length;h<s;h++){var u=this._getGraphemeBox(l[h],a,h+t,e,o);n+=u.kernedWidth,e=l[h]}return n},_wrapLine:function(l,a,t,R){var e=0,o=this.splitByGrapheme,h=[],s=[],u=o?i.util.string.graphemeSplit(l):l.split(this._wordJoiners),d="",m=0,p=o?"":" ",v=0,b=0,S=0,E=!0,F=this._getWidthOfCharSpacing(),R=R||0;u.length===0&&u.push([]),t-=R;for(var z=0;z<u.length;z++)d=o?u[z]:i.util.string.graphemeSplit(u[z]),v=this._measureWord(d,a,m),m+=d.length,e+=b+v-F,e>t&&!E?(h.push(s),s=[],e=v,E=!0):e+=F,!E&&!o&&s.push(p),s=s.concat(d),b=o?0:this._measureWord([p],a,m),m++,E=!1,v>S&&(S=v);return z&&h.push(s),S+R>this.dynamicMinWidth&&(this.dynamicMinWidth=S-F+R),h},isEndOfWrapping:function(l){return!this._styleMap[l+1]||this._styleMap[l+1].line!==this._styleMap[l].line},missingNewlineOffset:function(l){return this.splitByGrapheme?this.isEndOfWrapping(l)?1:0:1},_splitTextIntoLines:function(l){for(var a=i.Text.prototype._splitTextIntoLines.call(this,l),t=this._wrapText(a.lines,this.width),n=new Array(t.length),e=0;e<t.length;e++)n[e]=t[e].join("");return a.lines=n,a.graphemeLines=t,a},getMinWidth:function(){return Math.max(this.minWidth,this.dynamicMinWidth)},_removeExtraneousStyles:function(){var l={};for(var a in this._styleMap)this._textLines[a]&&(l[this._styleMap[a].line]=1);for(var a in this.styles)l[a]||delete this.styles[a]},toObject:function(l){return this.callSuper("toObject",["minWidth","splitByGrapheme"].concat(l))}}),i.Textbox.fromObject=function(l,a){var t=i.util.stylesFromArray(l.styles,l.text),n=Object.assign({},l,{styles:t});return i.Object._fromObject("Textbox",n,a,"text")}})(f),(function(){var c=r.controlsUtils,i=c.scaleSkewCursorStyleHandler,l=c.scaleCursorStyleHandler,a=c.scalingEqually,t=c.scalingYOrSkewingX,n=c.scalingXOrSkewingY,e=c.scaleOrSkewActionName,o=r.Object.prototype.controls;if(o.ml=new r.Control({x:-.5,y:0,cursorStyleHandler:i,actionHandler:n,getActionName:e}),o.mr=new r.Control({x:.5,y:0,cursorStyleHandler:i,actionHandler:n,getActionName:e}),o.mb=new r.Control({x:0,y:.5,cursorStyleHandler:i,actionHandler:t,getActionName:e}),o.mt=new r.Control({x:0,y:-.5,cursorStyleHandler:i,actionHandler:t,getActionName:e}),o.tl=new r.Control({x:-.5,y:-.5,cursorStyleHandler:l,actionHandler:a}),o.tr=new r.Control({x:.5,y:-.5,cursorStyleHandler:l,actionHandler:a}),o.bl=new r.Control({x:-.5,y:.5,cursorStyleHandler:l,actionHandler:a}),o.br=new r.Control({x:.5,y:.5,cursorStyleHandler:l,actionHandler:a}),o.mtr=new r.Control({x:0,y:-.5,actionHandler:c.rotationWithSnapping,cursorStyleHandler:c.rotationStyleHandler,offsetY:-40,withConnection:!0,actionName:"rotate"}),r.Textbox){var h=r.Textbox.prototype.controls={};h.mtr=o.mtr,h.tr=o.tr,h.br=o.br,h.tl=o.tl,h.bl=o.bl,h.mt=o.mt,h.mb=o.mb,h.mr=new r.Control({x:.5,y:0,actionHandler:c.changeWidth,cursorStyleHandler:i,actionName:"resizing"}),h.ml=new r.Control({x:-.5,y:0,actionHandler:c.changeWidth,cursorStyleHandler:i,actionName:"resizing"})}})()})(si)),si}var _t=No(),ue=(f=>(f.ONE="selectOne",f.MULTI="selectMultiple",f.CANCEL="selectCancel",f))(ue||{}),te=(f=>(f.EMPTY="",f.ONE="one",f.MULTI="multiple",f))(te||{});function dr(f){f&&f.forEach(r=>{r.objects?dr(r.objects):r.type==="text"&&(r.type="textbox")})}const ge=class ge{constructor(r,g){this.canvas=r,this.editor=g,this.selectedMode=te.EMPTY,this._initSelectEvent()}_initSelectEvent(){this.canvas.on("selection:created",()=>this._emitSelectEvent()),this.canvas.on("selection:updated",()=>this._emitSelectEvent()),this.canvas.on("selection:cleared",()=>this._emitSelectEvent())}_emitSelectEvent(){if(!this.canvas)throw TypeError("还未初始化");const r=this.canvas.getActiveObjects().filter(g=>!(g instanceof _t.fabric.GuideLine));r&&r.length===1?(this.selectedMode=te.ONE,this.editor.emit(ue.ONE,r)):r&&r.length>1?(this.selectedMode=te.MULTI,this.editor.emit(ue.MULTI,r)):this.editor.emit(ue.CANCEL)}getSelectMode(){return String(this.selectedMode)}insert(r){ur({accept:".json"}).then(g=>{if(g&&g.length>0){const _=g[0],y=new FileReader;y.readAsText(_,"UTF-8"),y.onload=()=>{this.loadJSON(y.result,r)}}})}renderITextPath(r){r.forEach(g=>{const _=this.canvas.getObjects().find(y=>y.id===g.id);_&&_t.fabric.Path.fromObject(g.path,y=>{_.set("path",y)})})}async loadJSON(r,g){const _=typeof r=="string"?JSON.parse(r):r,y=[];_.objects.forEach(T=>{!T.id&&(T.id=On()),T.type==="i-text"&&T.path&&(y.push({id:T.id,path:T.path}),T.path=null)});const C=await this._transform(_);r=JSON.stringify(C),this.editor.hooksEntity.hookImportBefore.callAsync(r,()=>{this.canvas.loadFromJSON(r,()=>{this.renderITextPath(y),this.canvas.renderAll(),this.editor.hooksEntity.hookImportAfter.callAsync(r,()=>{this.editor?.updateDrawStatus&&typeof this.editor.updateDrawStatus=="function"&&this.editor.updateDrawStatus(!!_.overlayImage),this.canvas.renderAll(),g&&g(),this.editor.emit("loadJson")})},(T,c)=>{this.editor.hooksEntity.hookTransformObjectEnd.callAsync({originObject:T,fabricObject:c},()=>{this.canvas.renderAll()})})})}async _transform(r){if(await this.promiseCallAsync(r),r.objects){const g=r.objects.map(_=>this._transform(_));await Promise.all(g)}return r}promiseCallAsync(r){return new Promise(g=>{this.editor.hooksEntity.hookTransform.callAsync(r,()=>{g(r)})})}getJson(r){const g=this.getExtensionKey(),_=this.canvas.toJSON(g);return r?.clearSrc&&_.objects.forEach(y=>{["qrcode","barcode"].includes(y.extensionType)&&(y.src="")}),_}getExtensionKey(){return["id","gradientAngle","selectable","hasControls","linkData","editable","extensionType","extension","verticalAlign","roundValue","getBase64","_originSize"]}dragAddItem(r,g){if(g){const{left:y,top:C}=this.canvas.getSelectionElement().getBoundingClientRect();if(g.x<y||g.y<C||r.width===void 0)return;const T={x:g.x-y,y:g.y-C},c=this.canvas.restorePointerVpt(T);r.left=c.x-r.width/2,r.top=c.y}const{width:_}=this._getSaveOption();_&&r.scaleToWidth(_/2),this.canvas.add(r),this.canvas.setActiveObject(r),!g&&this.editor.position("center"),this.canvas.requestRenderAll()}clipboard(){const r=this.getJson();return ki(JSON.stringify(r,null," "))}async clipboardBase64(){const r=await this.preview();return ki(r)}async saveJson(){const r=this.getJson();await dr(r.objects);const g=`data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r,null," "))}`;Re(g,"json")}saveSvg(){this.editor.hooksEntity.hookSaveBefore.callAsync("",()=>{const{fontOption:r,svgOption:g}=this._getSaveSvgOption();_t.fabric.fontPaths={...r};const _=this.canvas.toSVG(g),y=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(_)}`;this.editor.hooksEntity.hookSaveAfter.callAsync(y,()=>{Re(y,"svg")})})}saveImg(){this.editor.hooksEntity.hookSaveBefore.callAsync("",()=>{const r=this._getSaveOption();this.canvas.setViewportTransform([1,0,0,1,0,0]);const g=this.canvas.toDataURL(r);this.editor.hooksEntity.hookSaveAfter.callAsync(g,()=>{Re(g,"png")})})}getBase64(){return new Promise(r=>{this.editor.hooksEntity.hookSaveBefore.callAsync("",()=>{const g=this._getSaveOption();this.canvas.setViewportTransform([1,0,0,1,0,0]);const _=this.canvas.toDataURL(g);this.editor.hooksEntity.hookSaveAfter.callAsync(_,()=>r(_))})})}preview(){return new Promise(r=>{this.editor.hooksEntity.hookSaveBefore.callAsync("",()=>{const g=this._getSaveOption();this.canvas.setViewportTransform([1,0,0,1,0,0]),this.canvas.renderAll();const _=this.canvas.toDataURL(g);this.editor.hooksEntity.hookSaveAfter.callAsync(_,()=>{r(_)})})})}staticPreview(){return new Promise(r=>{})}_getSaveSvgOption(){const r=this.canvas.getObjects().find(l=>l.id==="workspace");let g=this.canvas.getObjects().filter(l=>l.type=="textbox").map(l=>l.fontFamily);g=Array.from(new Set(g));const _=this.editor.getPlugin("FontPlugin").cacheList,y={};for(const l of g){const a=_.find(t=>t.name===l);y[l]=a.file}console.log("_getSaveSvgOption",y);const{left:C,top:T,width:c,height:i}=r;return{fontOption:y,svgOption:{width:c,height:i,viewBox:{x:C,y:T,width:c,height:i}}}}_getSaveOption(){const r=this.canvas.getObjects().find(c=>c.id==="workspace"),{left:g,top:_,width:y,height:C}=r;return{name:"New Image",format:"jpeg",quality:1,multiplier:5,width:y,height:C,left:g,top:_}}clear(){this.canvas.getObjects().forEach(r=>{r.id!=="workspace"&&this.canvas.remove(r)}),this.editor?.setWorkspaseBg("#fff"),this.canvas.discardActiveObject(),this.canvas.renderAll()}destroy(){console.log("pluginDestroy")}};ge.pluginName="ServersPlugin",ge.apis=["insert","loadJSON","getJson","dragAddItem","clipboard","clipboardBase64","saveJson","saveSvg","saveImg","getBase64","clear","preview","staticPreview","getSelectMode","getExtensionKey"],ge.events=[te.ONE,te.MULTI,ue.CANCEL];let Ai=ge;var St={},ai={},rn;function gr(){return rn||(rn=1,ai.deprecate=(f,r)=>{let g=!0;return function(){return g&&(console.warn(`DeprecationWarning: ${r}`),g=!1),f.apply(this,arguments)}}),ai}var li,sn;function Mt(){if(sn)return li;sn=1;const r=gr().deprecate(()=>{},"Hook.context is deprecated and will be removed");function g(...T){return this.call=this._createCall("sync"),this.call(...T)}function _(...T){return this.callAsync=this._createCall("async"),this.callAsync(...T)}function y(...T){return this.promise=this._createCall("promise"),this.promise(...T)}class C{constructor(c=[],i=void 0){this._args=c,this.name=i,this.taps=[],this.interceptors=[],this._call=g,this.call=g,this._callAsync=_,this.callAsync=_,this._promise=y,this.promise=y,this._x=void 0,this.compile=this.compile,this.tap=this.tap,this.tapAsync=this.tapAsync,this.tapPromise=this.tapPromise}compile(c){throw new Error("Abstract: should be overridden")}_createCall(c){return this.compile({taps:this.taps,interceptors:this.interceptors,args:this._args,type:c})}_tap(c,i,l){if(typeof i=="string")i={name:i.trim()};else if(typeof i!="object"||i===null)throw new Error("Invalid tap options");if(typeof i.name!="string"||i.name==="")throw new Error("Missing name for tap");typeof i.context<"u"&&r(),i=Object.assign({type:c,fn:l},i),i=this._runRegisterInterceptors(i),this._insert(i)}tap(c,i){this._tap("sync",c,i)}tapAsync(c,i){this._tap("async",c,i)}tapPromise(c,i){this._tap("promise",c,i)}_runRegisterInterceptors(c){for(const i of this.interceptors)if(i.register){const l=i.register(c);l!==void 0&&(c=l)}return c}withOptions(c){const i=l=>Object.assign({},c,typeof l=="string"?{name:l}:l);return{name:this.name,tap:(l,a)=>this.tap(i(l),a),tapAsync:(l,a)=>this.tapAsync(i(l),a),tapPromise:(l,a)=>this.tapPromise(i(l),a),intercept:l=>this.intercept(l),isUsed:()=>this.isUsed(),withOptions:l=>this.withOptions(i(l))}}isUsed(){return this.taps.length>0||this.interceptors.length>0}intercept(c){if(this._resetCompilation(),this.interceptors.push(Object.assign({},c)),c.register)for(let i=0;i<this.taps.length;i++)this.taps[i]=c.register(this.taps[i])}_resetCompilation(){this.call=this._call,this.callAsync=this._callAsync,this.promise=this._promise}_insert(c){this._resetCompilation();let i;typeof c.before=="string"?i=new Set([c.before]):Array.isArray(c.before)&&(i=new Set(c.before));let l=0;typeof c.stage=="number"&&(l=c.stage);let a=this.taps.length;for(;a>0;){a--;const t=this.taps[a];this.taps[a+1]=t;const n=t.stage||0;if(i){if(i.has(t.name)){i.delete(t.name);continue}if(i.size>0)continue}if(!(n>l)){a++;break}}this.taps[a]=c}}return Object.setPrototypeOf(C.prototype,null),li=C,li}var ci,on;function Lt(){if(on)return ci;on=1;class f{constructor(g){this.config=g,this.options=void 0,this._args=void 0}create(g){this.init(g);let _;switch(this.options.type){case"sync":_=new Function(this.args(),`"use strict";
442
442
  ${this.header()}${this.contentWithInterceptors({onError:y=>`throw ${y};
443
443
  `,onResult:y=>`return ${y};
444
444
  `,resultReturns:!0,onDone:()=>"",rethrowIfPossible:!0})}`);break;case"async":_=new Function(this.args({after:"_callback"}),`"use strict";
@@ -459,52 +459,52 @@ ${this.header()}${this.contentWithInterceptors({onError:y=>`_callback(${y});
459
459
  `,T+=`};
460
460
  `),T+=C,y&&(T+=`_sync = false;
461
461
  `),T+=`}));
462
- `,_=new Function(this.args(),T);break}}return this.deinit(),_}setup(p,_){p._x=_.taps.map(y=>y.fn)}init(p){this.options=p,this._args=[...p.args]}deinit(){this.options=void 0,this._args=void 0}contentWithInterceptors(p){if(this.options.interceptors.length>0){const{onError:_,onResult:y,onDone:C}=p;let T="";for(let c=0;c<this.options.interceptors.length;c++){const i=this.options.interceptors[c];i.call&&(T+=`${this.getInterceptor(c)}.call(${this.args({before:i.context?"_context":void 0})});
463
- `)}return T+=this.content(Object.assign(p,{onError:_&&(c=>{let i="";for(let l=0;l<this.options.interceptors.length;l++)this.options.interceptors[l].error&&(i+=`${this.getInterceptor(l)}.error(${c});
462
+ `,_=new Function(this.args(),T);break}}return this.deinit(),_}setup(g,_){g._x=_.taps.map(y=>y.fn)}init(g){this.options=g,this._args=[...g.args]}deinit(){this.options=void 0,this._args=void 0}contentWithInterceptors(g){if(this.options.interceptors.length>0){const{onError:_,onResult:y,onDone:C}=g;let T="";for(let c=0;c<this.options.interceptors.length;c++){const i=this.options.interceptors[c];i.call&&(T+=`${this.getInterceptor(c)}.call(${this.args({before:i.context?"_context":void 0})});
463
+ `)}return T+=this.content(Object.assign(g,{onError:_&&(c=>{let i="";for(let l=0;l<this.options.interceptors.length;l++)this.options.interceptors[l].error&&(i+=`${this.getInterceptor(l)}.error(${c});
464
464
  `);return i+=_(c),i}),onResult:y&&(c=>{let i="";for(let l=0;l<this.options.interceptors.length;l++)this.options.interceptors[l].result&&(i+=`${this.getInterceptor(l)}.result(${c});
465
465
  `);return i+=y(c),i}),onDone:C&&(()=>{let c="";for(let i=0;i<this.options.interceptors.length;i++)this.options.interceptors[i].done&&(c+=`${this.getInterceptor(i)}.done();
466
- `);return c+=C(),c})})),T}return this.content(p)}header(){let p="";return p+=this.needContext()?`var _context = {};
466
+ `);return c+=C(),c})})),T}return this.content(g)}header(){let g="";return g+=this.needContext()?`var _context = {};
467
467
  `:`var _context;
468
- `,p+=`var _x = this._x;
469
- `,this.options.interceptors.length>0&&(p+=`var _taps = this.taps;
470
- `,p+=`var _interceptors = this.interceptors;
471
- `),p}needContext(){for(const p of this.options.taps)if(p.context)return!0;return!1}callTap(p,{onError:_,onResult:y,onDone:C,rethrowIfPossible:T}){let c="",i=!1;for(let a=0;a<this.options.interceptors.length;a++){const t=this.options.interceptors[a];t.tap&&(i||(c+=`var _tap${p} = ${this.getTap(p)};
472
- `,i=!0),c+=`${this.getInterceptor(a)}.tap(${t.context?"_context, ":""}_tap${p});
473
- `)}c+=`var _fn${p} = ${this.getTapFn(p)};
474
- `;const l=this.options.taps[p];switch(l.type){case"sync":T||(c+=`var _hasError${p} = false;
468
+ `,g+=`var _x = this._x;
469
+ `,this.options.interceptors.length>0&&(g+=`var _taps = this.taps;
470
+ `,g+=`var _interceptors = this.interceptors;
471
+ `),g}needContext(){for(const g of this.options.taps)if(g.context)return!0;return!1}callTap(g,{onError:_,onResult:y,onDone:C,rethrowIfPossible:T}){let c="",i=!1;for(let a=0;a<this.options.interceptors.length;a++){const t=this.options.interceptors[a];t.tap&&(i||(c+=`var _tap${g} = ${this.getTap(g)};
472
+ `,i=!0),c+=`${this.getInterceptor(a)}.tap(${t.context?"_context, ":""}_tap${g});
473
+ `)}c+=`var _fn${g} = ${this.getTapFn(g)};
474
+ `;const l=this.options.taps[g];switch(l.type){case"sync":T||(c+=`var _hasError${g} = false;
475
475
  `,c+=`try {
476
- `),y?c+=`var _result${p} = _fn${p}(${this.args({before:l.context?"_context":void 0})});
477
- `:c+=`_fn${p}(${this.args({before:l.context?"_context":void 0})});
476
+ `),y?c+=`var _result${g} = _fn${g}(${this.args({before:l.context?"_context":void 0})});
477
+ `:c+=`_fn${g}(${this.args({before:l.context?"_context":void 0})});
478
478
  `,T||(c+=`} catch(_err) {
479
- `,c+=`_hasError${p} = true;
479
+ `,c+=`_hasError${g} = true;
480
480
  `,c+=_("_err"),c+=`}
481
- `,c+=`if(!_hasError${p}) {
482
- `),y&&(c+=y(`_result${p}`)),C&&(c+=C()),T||(c+=`}
483
- `);break;case"async":{let a="";a+=y?`(function(_err${p}, _result${p}) {
484
- `:`(function(_err${p}) {
485
- `,a+=`if(_err${p}) {
486
- `,a+=_(`_err${p}`),a+=`} else {
487
- `,y&&(a+=y(`_result${p}`)),C&&(a+=C()),a+=`}
488
- `,a+="})",c+=`_fn${p}(${this.args({before:l.context?"_context":void 0,after:a})});
489
- `;break}case"promise":c+=`var _hasResult${p} = false;
490
- `,c+=`var _promise${p} = _fn${p}(${this.args({before:l.context?"_context":void 0})});
491
- `,c+=`if (!_promise${p} || !_promise${p}.then)
492
- `,c+=` throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise${p} + ')');
493
- `,c+=`_promise${p}.then((function(_result${p}) {
494
- `,c+=`_hasResult${p} = true;
495
- `,y&&(c+=y(`_result${p}`)),C&&(c+=C()),c+=`}), function(_err${p}) {
496
- `,c+=`if(_hasResult${p}) throw _err${p};
497
- `,c+=_(`!_err${p} ? new Error('Tap function (tapPromise) rejects "' + _err${p} + '" value') : _err${p}`),c+=`});
498
- `;break}return c}callTapsSeries({onError:p,onResult:_,resultReturns:y,onDone:C,doneReturns:T,rethrowIfPossible:c}){if(this.options.taps.length===0)return C();const i=this.options.taps.findIndex(e=>e.type!=="sync"),l=y||T;let a="",t=C,n=0;for(let e=this.options.taps.length-1;e>=0;e--){const o=e;t!==C&&(this.options.taps[o].type!=="sync"||n++>20)&&(n=0,a+=`function _next${o}() {
481
+ `,c+=`if(!_hasError${g}) {
482
+ `),y&&(c+=y(`_result${g}`)),C&&(c+=C()),T||(c+=`}
483
+ `);break;case"async":{let a="";a+=y?`(function(_err${g}, _result${g}) {
484
+ `:`(function(_err${g}) {
485
+ `,a+=`if(_err${g}) {
486
+ `,a+=_(`_err${g}`),a+=`} else {
487
+ `,y&&(a+=y(`_result${g}`)),C&&(a+=C()),a+=`}
488
+ `,a+="})",c+=`_fn${g}(${this.args({before:l.context?"_context":void 0,after:a})});
489
+ `;break}case"promise":c+=`var _hasResult${g} = false;
490
+ `,c+=`var _promise${g} = _fn${g}(${this.args({before:l.context?"_context":void 0})});
491
+ `,c+=`if (!_promise${g} || !_promise${g}.then)
492
+ `,c+=` throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise${g} + ')');
493
+ `,c+=`_promise${g}.then((function(_result${g}) {
494
+ `,c+=`_hasResult${g} = true;
495
+ `,y&&(c+=y(`_result${g}`)),C&&(c+=C()),c+=`}), function(_err${g}) {
496
+ `,c+=`if(_hasResult${g}) throw _err${g};
497
+ `,c+=_(`!_err${g} ? new Error('Tap function (tapPromise) rejects "' + _err${g} + '" value') : _err${g}`),c+=`});
498
+ `;break}return c}callTapsSeries({onError:g,onResult:_,resultReturns:y,onDone:C,doneReturns:T,rethrowIfPossible:c}){if(this.options.taps.length===0)return C();const i=this.options.taps.findIndex(e=>e.type!=="sync"),l=y||T;let a="",t=C,n=0;for(let e=this.options.taps.length-1;e>=0;e--){const o=e;t!==C&&(this.options.taps[o].type!=="sync"||n++>20)&&(n=0,a+=`function _next${o}() {
499
499
  `,a+=t(),a+=`}
500
500
  `,t=()=>`${l?"return ":""}_next${o}();
501
- `);const s=t,u=m=>m?"":C(),d=this.callTap(o,{onError:m=>p(o,m,s,u),onResult:_&&(m=>_(o,m,s,u)),onDone:!_&&s,rethrowIfPossible:c&&(i<0||o<i)});t=()=>d}return a+=t(),a}callTapsLooping({onError:p,onDone:_,rethrowIfPossible:y}){if(this.options.taps.length===0)return _();const C=this.options.taps.every(c=>c.type==="sync");let T="";C||(T+=`var _looper = (function() {
501
+ `);const s=t,u=m=>m?"":C(),d=this.callTap(o,{onError:m=>g(o,m,s,u),onResult:_&&(m=>_(o,m,s,u)),onDone:!_&&s,rethrowIfPossible:c&&(i<0||o<i)});t=()=>d}return a+=t(),a}callTapsLooping({onError:g,onDone:_,rethrowIfPossible:y}){if(this.options.taps.length===0)return _();const C=this.options.taps.every(c=>c.type==="sync");let T="";C||(T+=`var _looper = (function() {
502
502
  `,T+=`var _loopAsync = false;
503
503
  `),T+=`var _loop;
504
504
  `,T+=`do {
505
505
  `,T+=`_loop = false;
506
506
  `;for(let c=0;c<this.options.interceptors.length;c++){const i=this.options.interceptors[c];i.loop&&(T+=`${this.getInterceptor(c)}.loop(${this.args({before:i.context?"_context":void 0})});
507
- `)}return T+=this.callTapsSeries({onError:p,onResult:(c,i,l,a)=>{let t="";return t+=`if(${i} !== undefined) {
507
+ `)}return T+=this.callTapsSeries({onError:g,onResult:(c,i,l,a)=>{let t="";return t+=`if(${i} !== undefined) {
508
508
  `,t+=`_loop = true;
509
509
  `,C||(t+=`if(_loopAsync) _looper();
510
510
  `),t+=a(!0),t+=`} else {
@@ -515,7 +515,7 @@ ${this.header()}${this.contentWithInterceptors({onError:y=>`_callback(${y});
515
515
  `,C||(T+=`_loopAsync = true;
516
516
  `,T+=`});
517
517
  `,T+=`_looper();
518
- `),T}callTapsParallel({onError:p,onResult:_,onDone:y,rethrowIfPossible:C,onTap:T=(c,i)=>i()}){if(this.options.taps.length<=1)return this.callTapsSeries({onError:p,onResult:_,onDone:y,rethrowIfPossible:C});let c="";c+=`do {
518
+ `),T}callTapsParallel({onError:g,onResult:_,onDone:y,rethrowIfPossible:C,onTap:T=(c,i)=>i()}){if(this.options.taps.length<=1)return this.callTapsSeries({onError:g,onResult:_,onDone:y,rethrowIfPossible:C});let c="";c+=`do {
519
519
  `,c+=`var _counter = ${this.options.taps.length};
520
520
  `,y&&(c+=`var _done = (function() {
521
521
  `,c+=y(),c+=`});
@@ -525,11 +525,11 @@ ${this.header()}${this.contentWithInterceptors({onError:y=>`_callback(${y});
525
525
  _done();
526
526
  `;c+=`if(_counter <= 0) break;
527
527
  `,c+=T(i,()=>this.callTap(i,{onError:t=>{let n="";return n+=`if(_counter > 0) {
528
- `,n+=p(i,t,l,a),n+=`}
528
+ `,n+=g(i,t,l,a),n+=`}
529
529
  `,n},onResult:_&&(t=>{let n="";return n+=`if(_counter > 0) {
530
530
  `,n+=_(i,t,l,a),n+=`}
531
531
  `,n}),onDone:!_&&(()=>l()),rethrowIfPossible:C}),l,a)}return c+=`} while(false);
532
- `,c}args({before:p,after:_}={}){let y=this._args;return p&&(y=[p,...y]),_&&(y=[...y,_]),y.length===0?"":y.join(", ")}getTapFn(p){return`_x[${p}]`}getTap(p){return`_taps[${p}]`}getInterceptor(p){return`_interceptors[${p}]`}}return ci=f,ci}var hi,an;function Wo(){if(an)return hi;an=1;const f=Mt(),r=Lt();class p extends r{content({onError:c,onResult:i,onDone:l}){let a="";return a+=`var _results = new Array(${this.options.taps.length});
532
+ `,c}args({before:g,after:_}={}){let y=this._args;return g&&(y=[g,...y]),_&&(y=[...y,_]),y.length===0?"":y.join(", ")}getTapFn(g){return`_x[${g}]`}getTap(g){return`_taps[${g}]`}getInterceptor(g){return`_interceptors[${g}]`}}return ci=f,ci}var hi,an;function Wo(){if(an)return hi;an=1;const f=Mt(),r=Lt();class g extends r{content({onError:c,onResult:i,onDone:l}){let a="";return a+=`var _results = new Array(${this.options.taps.length});
533
533
  `,a+=`var _checkDone = function() {
534
534
  `,a+=`for(var i = 0; i < _results.length; i++) {
535
535
  `,a+=`var item = _results[i];
@@ -552,18 +552,18 @@ _done();
552
552
  `,h},onTap:(t,n,e,o)=>{let h="";return t>0&&(h+=`if(${t} >= _results.length) {
553
553
  `,h+=e(),h+=`} else {
554
554
  `),h+=n(),t>0&&(h+=`}
555
- `),h},onDone:l}),a}}const _=new p;function y(T){return _.setup(this,T),_.create(T)}function C(T=[],c=void 0){const i=new f(T,c);return i.constructor=C,i.compile=y,i._call=void 0,i.call=void 0,i}return C.prototype=null,hi=C,hi}var ui,ln;function Xo(){if(ln)return ui;ln=1;const f=Mt(),r=Lt();class p extends r{content({onError:c,onDone:i}){return this.callTapsParallel({onError:(l,a,t,n)=>c(a)+n(!0),onDone:i})}}const _=new p;function y(T){return _.setup(this,T),_.create(T)}function C(T=[],c=void 0){const i=new f(T,c);return i.constructor=C,i.compile=y,i._call=void 0,i.call=void 0,i}return C.prototype=null,ui=C,ui}var fi,cn;function Yo(){if(cn)return fi;cn=1;const f=Mt(),r=Lt();class p extends r{content({onError:c,onResult:i,resultReturns:l,onDone:a}){return this.callTapsSeries({onError:(t,n,e,o)=>c(n)+o(!0),onResult:(t,n,e)=>`if(${n} !== undefined) {
555
+ `),h},onDone:l}),a}}const _=new g;function y(T){return _.setup(this,T),_.create(T)}function C(T=[],c=void 0){const i=new f(T,c);return i.constructor=C,i.compile=y,i._call=void 0,i.call=void 0,i}return C.prototype=null,hi=C,hi}var ui,ln;function Xo(){if(ln)return ui;ln=1;const f=Mt(),r=Lt();class g extends r{content({onError:c,onDone:i}){return this.callTapsParallel({onError:(l,a,t,n)=>c(a)+n(!0),onDone:i})}}const _=new g;function y(T){return _.setup(this,T),_.create(T)}function C(T=[],c=void 0){const i=new f(T,c);return i.constructor=C,i.compile=y,i._call=void 0,i.call=void 0,i}return C.prototype=null,ui=C,ui}var fi,cn;function Yo(){if(cn)return fi;cn=1;const f=Mt(),r=Lt();class g extends r{content({onError:c,onResult:i,resultReturns:l,onDone:a}){return this.callTapsSeries({onError:(t,n,e,o)=>c(n)+o(!0),onResult:(t,n,e)=>`if(${n} !== undefined) {
556
556
  ${i(n)}
557
557
  } else {
558
558
  ${e()}}
559
- `,resultReturns:l,onDone:a})}}const _=new p;function y(T){return _.setup(this,T),_.create(T)}function C(T=[],c=void 0){const i=new f(T,c);return i.constructor=C,i.compile=y,i._call=void 0,i.call=void 0,i}return C.prototype=null,fi=C,fi}var di,hn;function Vo(){if(hn)return di;hn=1;const f=Mt(),r=Lt();class p extends r{content({onError:c,onDone:i}){return this.callTapsSeries({onError:(l,a,t,n)=>c(a)+n(!0),onDone:i})}}const _=new p;function y(T){return _.setup(this,T),_.create(T)}function C(T=[],c=void 0){const i=new f(T,c);return i.constructor=C,i.compile=y,i._call=void 0,i.call=void 0,i}return C.prototype=null,di=C,di}var gi,un;function Uo(){if(un)return gi;un=1;const f=Mt(),r=Lt();class p extends r{content({onError:c,onDone:i}){return this.callTapsLooping({onError:(l,a,t,n)=>c(a)+n(!0),onDone:i})}}const _=new p;function y(T){return _.setup(this,T),_.create(T)}function C(T=[],c=void 0){const i=new f(T,c);return i.constructor=C,i.compile=y,i._call=void 0,i.call=void 0,i}return C.prototype=null,gi=C,gi}var pi,fn;function zo(){if(fn)return pi;fn=1;const f=Mt(),r=Lt();class p extends r{content({onError:c,onResult:i,_onDone:l}){return this.callTapsSeries({onError:(a,t,n,e)=>c(t)+e(!0),onResult:(a,t,n)=>{let e="";return e+=`if(${t} !== undefined) {
559
+ `,resultReturns:l,onDone:a})}}const _=new g;function y(T){return _.setup(this,T),_.create(T)}function C(T=[],c=void 0){const i=new f(T,c);return i.constructor=C,i.compile=y,i._call=void 0,i.call=void 0,i}return C.prototype=null,fi=C,fi}var di,hn;function Vo(){if(hn)return di;hn=1;const f=Mt(),r=Lt();class g extends r{content({onError:c,onDone:i}){return this.callTapsSeries({onError:(l,a,t,n)=>c(a)+n(!0),onDone:i})}}const _=new g;function y(T){return _.setup(this,T),_.create(T)}function C(T=[],c=void 0){const i=new f(T,c);return i.constructor=C,i.compile=y,i._call=void 0,i.call=void 0,i}return C.prototype=null,di=C,di}var gi,un;function Uo(){if(un)return gi;un=1;const f=Mt(),r=Lt();class g extends r{content({onError:c,onDone:i}){return this.callTapsLooping({onError:(l,a,t,n)=>c(a)+n(!0),onDone:i})}}const _=new g;function y(T){return _.setup(this,T),_.create(T)}function C(T=[],c=void 0){const i=new f(T,c);return i.constructor=C,i.compile=y,i._call=void 0,i.call=void 0,i}return C.prototype=null,gi=C,gi}var pi,fn;function zo(){if(fn)return pi;fn=1;const f=Mt(),r=Lt();class g extends r{content({onError:c,onResult:i,_onDone:l}){return this.callTapsSeries({onError:(a,t,n,e)=>c(t)+e(!0),onResult:(a,t,n)=>{let e="";return e+=`if(${t} !== undefined) {
560
560
  `,e+=`${this._args[0]} = ${t};
561
561
  `,e+=`}
562
- `,e+=n(),e},onDone:()=>i(this._args[0])})}}const _=new p;function y(T){return _.setup(this,T),_.create(T)}function C(T=[],c=void 0){if(T.length<1)throw new Error("Waterfall hooks must have at least one argument");const i=new f(T,c);return i.constructor=C,i.compile=y,i._call=void 0,i.call=void 0,i}return C.prototype=null,pi=C,pi}var mi,dn;function Go(){if(dn)return mi;dn=1;const f=gr(),r=(_,y)=>y;class p{constructor(y,C=void 0){this._map=new Map,this.name=C,this._factory=y,this._interceptors=[]}get(y){return this._map.get(y)}for(y){const C=this.get(y);if(C!==void 0)return C;let T=this._factory(y);const c=this._interceptors;for(let i=0;i<c.length;i++)T=c[i].factory(y,T);return this._map.set(y,T),T}intercept(y){this._interceptors.push(Object.assign({factory:r},y))}}return p.prototype.tap=f.deprecate(function(y,C,T){return this.for(y).tap(C,T)},"HookMap#tap(key,…) is deprecated. Use HookMap#for(key).tap(…) instead."),p.prototype.tapAsync=f.deprecate(function(y,C,T){return this.for(y).tapAsync(C,T)},"HookMap#tapAsync(key,…) is deprecated. Use HookMap#for(key).tapAsync(…) instead."),p.prototype.tapPromise=f.deprecate(function(y,C,T){return this.for(y).tapPromise(C,T)},"HookMap#tapPromise(key,…) is deprecated. Use HookMap#for(key).tapPromise(…) instead."),mi=p,mi}var vi,gn;function Ko(){if(gn)return vi;gn=1;class f{constructor(p,_=void 0){this.hooks=p,this.name=_}tap(p,_){for(const y of this.hooks)y.tap(p,_)}tapAsync(p,_){for(const y of this.hooks)y.tapAsync(p,_)}tapPromise(p,_){for(const y of this.hooks)y.tapPromise(p,_)}isUsed(){for(const p of this.hooks)if(p.isUsed())return!0;return!1}intercept(p){for(const _ of this.hooks)_.intercept(p)}withOptions(p){return new f(this.hooks.map(_=>_.withOptions(p)),this.name)}}return vi=f,vi}var _i,pn;function qo(){if(pn)return _i;pn=1;const f=Mt(),r=Lt();class p extends r{content({onError:l,onResult:a,resultReturns:t,onDone:n,rethrowIfPossible:e}){return this.callTapsSeries({onError:(o,h)=>l(h),onResult:(o,h,s)=>`if(${h} !== undefined) {
562
+ `,e+=n(),e},onDone:()=>i(this._args[0])})}}const _=new g;function y(T){return _.setup(this,T),_.create(T)}function C(T=[],c=void 0){if(T.length<1)throw new Error("Waterfall hooks must have at least one argument");const i=new f(T,c);return i.constructor=C,i.compile=y,i._call=void 0,i.call=void 0,i}return C.prototype=null,pi=C,pi}var mi,dn;function Go(){if(dn)return mi;dn=1;const f=gr(),r=(_,y)=>y;class g{constructor(y,C=void 0){this._map=new Map,this.name=C,this._factory=y,this._interceptors=[]}get(y){return this._map.get(y)}for(y){const C=this.get(y);if(C!==void 0)return C;let T=this._factory(y);const c=this._interceptors;for(let i=0;i<c.length;i++)T=c[i].factory(y,T);return this._map.set(y,T),T}intercept(y){this._interceptors.push(Object.assign({factory:r},y))}}return g.prototype.tap=f.deprecate(function(y,C,T){return this.for(y).tap(C,T)},"HookMap#tap(key,…) is deprecated. Use HookMap#for(key).tap(…) instead."),g.prototype.tapAsync=f.deprecate(function(y,C,T){return this.for(y).tapAsync(C,T)},"HookMap#tapAsync(key,…) is deprecated. Use HookMap#for(key).tapAsync(…) instead."),g.prototype.tapPromise=f.deprecate(function(y,C,T){return this.for(y).tapPromise(C,T)},"HookMap#tapPromise(key,…) is deprecated. Use HookMap#for(key).tapPromise(…) instead."),mi=g,mi}var vi,gn;function qo(){if(gn)return vi;gn=1;class f{constructor(g,_=void 0){this.hooks=g,this.name=_}tap(g,_){for(const y of this.hooks)y.tap(g,_)}tapAsync(g,_){for(const y of this.hooks)y.tapAsync(g,_)}tapPromise(g,_){for(const y of this.hooks)y.tapPromise(g,_)}isUsed(){for(const g of this.hooks)if(g.isUsed())return!0;return!1}intercept(g){for(const _ of this.hooks)_.intercept(g)}withOptions(g){return new f(this.hooks.map(_=>_.withOptions(g)),this.name)}}return vi=f,vi}var _i,pn;function Ko(){if(pn)return _i;pn=1;const f=Mt(),r=Lt();class g extends r{content({onError:l,onResult:a,resultReturns:t,onDone:n,rethrowIfPossible:e}){return this.callTapsSeries({onError:(o,h)=>l(h),onResult:(o,h,s)=>`if(${h} !== undefined) {
563
563
  ${a(h)};
564
564
  } else {
565
565
  ${s()}}
566
- `,resultReturns:t,onDone:n,rethrowIfPossible:e})}}const _=new p,y=()=>{throw new Error("tapAsync is not supported on a SyncBailHook")},C=()=>{throw new Error("tapPromise is not supported on a SyncBailHook")};function T(i){return _.setup(this,i),_.create(i)}function c(i=[],l=void 0){const a=new f(i,l);return a.constructor=c,a.tapAsync=y,a.tapPromise=C,a.compile=T,a}return c.prototype=null,_i=c,_i}var yi,mn;function $o(){if(mn)return yi;mn=1;const f=Mt(),r=Lt();class p extends r{content({onError:l,onDone:a,rethrowIfPossible:t}){return this.callTapsSeries({onError:(n,e)=>l(e),onDone:a,rethrowIfPossible:t})}}const _=new p,y=()=>{throw new Error("tapAsync is not supported on a SyncHook")},C=()=>{throw new Error("tapPromise is not supported on a SyncHook")};function T(i){return _.setup(this,i),_.create(i)}function c(i=[],l=void 0){const a=new f(i,l);return a.constructor=c,a.tapAsync=y,a.tapPromise=C,a.compile=T,a}return c.prototype=null,yi=c,yi}var Ci,vn;function Jo(){if(vn)return Ci;vn=1;const f=Mt(),r=Lt();class p extends r{content({onError:l,onDone:a,rethrowIfPossible:t}){return this.callTapsLooping({onError:(n,e)=>l(e),onDone:a,rethrowIfPossible:t})}}const _=new p,y=()=>{throw new Error("tapAsync is not supported on a SyncLoopHook")},C=()=>{throw new Error("tapPromise is not supported on a SyncLoopHook")};function T(i){return _.setup(this,i),_.create(i)}function c(i=[],l=void 0){const a=new f(i,l);return a.constructor=c,a.tapAsync=y,a.tapPromise=C,a.compile=T,a}return c.prototype=null,Ci=c,Ci}var bi,_n;function Qo(){if(_n)return bi;_n=1;const f=Mt(),r=Lt();class p extends r{content({onError:l,onResult:a,resultReturns:t,rethrowIfPossible:n}){return this.callTapsSeries({onError:(e,o)=>l(o),onResult:(e,o,h)=>{let s="";return s+=`if(${o} !== undefined) {
566
+ `,resultReturns:t,onDone:n,rethrowIfPossible:e})}}const _=new g,y=()=>{throw new Error("tapAsync is not supported on a SyncBailHook")},C=()=>{throw new Error("tapPromise is not supported on a SyncBailHook")};function T(i){return _.setup(this,i),_.create(i)}function c(i=[],l=void 0){const a=new f(i,l);return a.constructor=c,a.tapAsync=y,a.tapPromise=C,a.compile=T,a}return c.prototype=null,_i=c,_i}var yi,mn;function $o(){if(mn)return yi;mn=1;const f=Mt(),r=Lt();class g extends r{content({onError:l,onDone:a,rethrowIfPossible:t}){return this.callTapsSeries({onError:(n,e)=>l(e),onDone:a,rethrowIfPossible:t})}}const _=new g,y=()=>{throw new Error("tapAsync is not supported on a SyncHook")},C=()=>{throw new Error("tapPromise is not supported on a SyncHook")};function T(i){return _.setup(this,i),_.create(i)}function c(i=[],l=void 0){const a=new f(i,l);return a.constructor=c,a.tapAsync=y,a.tapPromise=C,a.compile=T,a}return c.prototype=null,yi=c,yi}var Ci,vn;function Jo(){if(vn)return Ci;vn=1;const f=Mt(),r=Lt();class g extends r{content({onError:l,onDone:a,rethrowIfPossible:t}){return this.callTapsLooping({onError:(n,e)=>l(e),onDone:a,rethrowIfPossible:t})}}const _=new g,y=()=>{throw new Error("tapAsync is not supported on a SyncLoopHook")},C=()=>{throw new Error("tapPromise is not supported on a SyncLoopHook")};function T(i){return _.setup(this,i),_.create(i)}function c(i=[],l=void 0){const a=new f(i,l);return a.constructor=c,a.tapAsync=y,a.tapPromise=C,a.compile=T,a}return c.prototype=null,Ci=c,Ci}var bi,_n;function Qo(){if(_n)return bi;_n=1;const f=Mt(),r=Lt();class g extends r{content({onError:l,onResult:a,resultReturns:t,rethrowIfPossible:n}){return this.callTapsSeries({onError:(e,o)=>l(o),onResult:(e,o,h)=>{let s="";return s+=`if(${o} !== undefined) {
567
567
  `,s+=`${this._args[0]} = ${o};
568
568
  `,s+=`}
569
- `,s+=h(),s},onDone:()=>a(this._args[0]),doneReturns:t,rethrowIfPossible:n})}}const _=new p,y=()=>{throw new Error("tapAsync is not supported on a SyncWaterfallHook")},C=()=>{throw new Error("tapPromise is not supported on a SyncWaterfallHook")};function T(i){return _.setup(this,i),_.create(i)}function c(i=[],l=void 0){if(i.length<1)throw new Error("Waterfall hooks must have at least one argument");const a=new f(i,l);return a.constructor=c,a.tapAsync=y,a.tapPromise=C,a.compile=T,a}return c.prototype=null,bi=c,bi}var yn;function Zo(){return yn||(yn=1,St.AsyncParallelBailHook=Wo(),St.AsyncParallelHook=Xo(),St.AsyncSeriesBailHook=Yo(),St.AsyncSeriesHook=Vo(),St.AsyncSeriesLoopHook=Uo(),St.AsyncSeriesWaterfallHook=zo(),St.HookMap=Go(),St.MultiHook=Ko(),St.SyncBailHook=qo(),St.SyncHook=$o(),St.SyncLoopHook=Jo(),St.SyncWaterfallHook=Qo(),St.__esModule=!0),St}var ta=Zo();class ea extends Sr{constructor(){super(...arguments),this.canvas=null,this.contextMenu=null,this.pluginMap={},this.customEvents=[],this.customApis=[],this.hooks=["hookImportBefore","hookImportAfter","hookSaveBefore","hookSaveAfter","hookTransform","hookTransformObjectEnd"],this.hooksEntity={}}init(r){this.canvas=r,this._initContextMenu(),this._bindContextMenu(),this._initActionHooks(),this._initServersPlugin(),this.Utils=fr}get fabricCanvas(){return this.canvas}use(r,p){if(this._checkPlugin(r)&&this.canvas){this._saveCustomAttr(r);const _=new r(this.canvas,this,p||{});_.pluginName=r.pluginName,this.pluginMap[r.pluginName]=_,this._bindingHooks(_),this._bindingHotkeys(_),this._bindingApis(_)}return this}destory(){this.canvas=null,this.contextMenu=null,this.pluginMap={},this.customEvents=[],this.customApis=[],this.hooksEntity={}}getPlugin(r){if(this.pluginMap[r])return this.pluginMap[r]}_checkPlugin(r){const{pluginName:p,events:_=[],apis:y=[]}=r;if(this.pluginMap[p])throw new Error(p+"插件重复初始化");return _.forEach(C=>{if(this.customEvents.find(T=>T===C))throw new Error(p+"插件中"+C+"重复")}),y.forEach(C=>{if(this.customApis.find(T=>T===C))throw new Error(p+"插件中"+C+"重复")}),!0}_bindingHooks(r){this.hooks.forEach(p=>{const _=r[p];_&&this.hooksEntity[p].tapPromise(r.pluginName+p,function(){const y=_.apply(r,[...arguments]);return y instanceof Promise?y:Promise.resolve(y)})})}_bindingHotkeys(r){r?.hotkeys?.forEach(p=>{It(p,{keyup:!0},_=>{r.hotkeyEvent&&r.hotkeyEvent(p,_)})})}_saveCustomAttr(r){const{events:p=[],apis:_=[]}=r;this.customApis=this.customApis.concat(_),this.customEvents=this.customEvents.concat(p)}_bindingApis(r){const{apis:p=[]}=r.constructor||{};p.forEach(_=>{this[_]=function(){return r[_].apply(r,[...arguments])}})}_bindContextMenu(){this.canvas&&this.canvas.on("mouse:down",r=>{if(r.button===3){let p=[];Object.keys(this.pluginMap).forEach(_=>{const y=this.pluginMap[_],C=y.contextMenu&&y.contextMenu();C&&(p=p.concat(C))}),this._renderMenu(r,p)}})}_renderMenu(r,p){p.length!==0&&this.contextMenu&&(this.contextMenu.hideAll(),this.contextMenu.setData(p),this.contextMenu.show(r.e.clientX,r.e.clientY))}_initActionHooks(){this.hooks.forEach(r=>{this.hooksEntity[r]=new ta.AsyncSeriesHook(["data"])})}_initContextMenu(){this.contextMenu=new Ie(this.canvas.wrapperEl,[]),this.contextMenu.install()}_initServersPlugin(){this.use(Ai)}off(r,p){return p?super.off(r,p):this}}_t.fabric.Rect=_t.fabric.util.createClass(_t.fabric.Rect,{type:"rect",initialize:function(f){f||(f={}),this.callSuper("initialize",f)},_render(f){const r=this.roundValue||0;this.rx=1/this.scaleX*r,this.ry=1/this.scaleY*r,this.callSuper("_render",f)}});_t.fabric.Rect.fromObject=function(f,r){return _t.fabric.Object._fromObject("Rect",f,r)};const ia=_t.fabric.Rect;_t.fabric.Textbox=_t.fabric.util.createClass(_t.fabric.Textbox,{type:"textbox",_renderChars:function(f,r,p,_,y,C){var T=this.getHeightOfLine(C),c=this.textAlign.indexOf("justify")!==-1,i,l,a="",t,n=0,e,o=this.path,h=!c&&this.charSpacing===0&&this.isEmptyStyles(C)&&!o,s=this.direction==="ltr",u=this.direction==="ltr"?1:-1,d,m=r.canvas.getAttribute("dir");if(r.save(),m!==this.direction&&(r.canvas.setAttribute("dir",s?"ltr":"rtl"),r.direction=s?"ltr":"rtl",r.textAlign=s?"left":"right"),y-=T*this._fontSizeFraction/this.lineHeight,h){this._renderChar(f,r,C,0,p.join(""),_,y,T),r.restore();return}for(var g=0,v=p.length-1;g<=v;g++)e=g===v||this.charSpacing||o,a+=p[g],t=this.__charBounds[C][g],n===0?(_+=u*(t.kernedWidth-t.width),n+=t.width):n+=t.kernedWidth,c&&!e&&this._reSpaceAndTab.test(p[g])&&(e=!0),e||(i=i||this.getCompleteStyleDeclaration(C,g),l=this.getCompleteStyleDeclaration(C,g+1),e=_t.fabric.util.hasStyleChanged(i,l,!1)),o?(r.save(),r.translate(t.renderLeft,t.renderTop),r.rotate(t.angle),this._renderChar(f,r,C,g,a,-n/2,0,T),r.restore()):(d=_,this._renderChar(f,r,C,g,a,d,y,T)),a="",i=l,_+=u*n,n=0;r.restore()},enlargeSpaces:function(){for(var f,r,p,_,y,C,T,c=0,i=this._textLines.length;c<i;c++)if(!(this.textAlign!=="justify"&&(c===i-1||this.isEndOfWrapping(c)))&&(_=0,y=this._textLines[c],r=this.getLineWidth(c),r<this.width&&(T=this.textLines[c].split(""))&&T.length>1)){p=T.length,f=(this.width-r)/(p-1);for(var l=0,a=y.length;l<=a;l++)C=this.__charBounds[c][l],C.left+=_,l<a-1&&(C.width+=f,C.kernedWidth+=f,_+=f)}}});_t.fabric.Textbox.fromObject=function(f,r){const{text:p}=f;return r(new _t.fabric.Textbox(p,f))};const na=_t.fabric.Rect;exports.CustomRect=ia;exports.CustomTextbox=na;exports.Utils=fr;exports.default=ea;exports.fabric=_t.fabric;
569
+ `,s+=h(),s},onDone:()=>a(this._args[0]),doneReturns:t,rethrowIfPossible:n})}}const _=new g,y=()=>{throw new Error("tapAsync is not supported on a SyncWaterfallHook")},C=()=>{throw new Error("tapPromise is not supported on a SyncWaterfallHook")};function T(i){return _.setup(this,i),_.create(i)}function c(i=[],l=void 0){if(i.length<1)throw new Error("Waterfall hooks must have at least one argument");const a=new f(i,l);return a.constructor=c,a.tapAsync=y,a.tapPromise=C,a.compile=T,a}return c.prototype=null,bi=c,bi}var yn;function Zo(){return yn||(yn=1,St.AsyncParallelBailHook=Wo(),St.AsyncParallelHook=Xo(),St.AsyncSeriesBailHook=Yo(),St.AsyncSeriesHook=Vo(),St.AsyncSeriesLoopHook=Uo(),St.AsyncSeriesWaterfallHook=zo(),St.HookMap=Go(),St.MultiHook=qo(),St.SyncBailHook=Ko(),St.SyncHook=$o(),St.SyncLoopHook=Jo(),St.SyncWaterfallHook=Qo(),St.__esModule=!0),St}var ta=Zo();class ea extends Sr{constructor(){super(...arguments),this.canvas=null,this.contextMenu=null,this.pluginMap={},this.customEvents=[],this.customApis=[],this.hooks=["hookImportBefore","hookImportAfter","hookSaveBefore","hookSaveAfter","hookTransform","hookTransformObjectEnd"],this.hooksEntity={}}init(r,g){this.canvas=r,g?.contextMenu!==!1&&(this._initContextMenu(),this._bindContextMenu()),this._initActionHooks(),this._initServersPlugin(),this.Utils=fr}get fabricCanvas(){return this.canvas}use(r,g){if(this._checkPlugin(r)&&this.canvas){this._saveCustomAttr(r);const _=new r(this.canvas,this,g||{});_.pluginName=r.pluginName,this.pluginMap[r.pluginName]=_,this._bindingHooks(_),this._bindingHotkeys(_),this._bindingApis(_)}return this}destory(){this.canvas=null,this.contextMenu=null,this.pluginMap={},this.customEvents=[],this.customApis=[],this.hooksEntity={}}getPlugin(r){if(this.pluginMap[r])return this.pluginMap[r]}_checkPlugin(r){const{pluginName:g,events:_=[],apis:y=[]}=r;if(this.pluginMap[g])throw new Error(g+"插件重复初始化");return _.forEach(C=>{if(this.customEvents.find(T=>T===C))throw new Error(g+"插件中"+C+"重复")}),y.forEach(C=>{if(this.customApis.find(T=>T===C))throw new Error(g+"插件中"+C+"重复")}),!0}_bindingHooks(r){this.hooks.forEach(g=>{const _=r[g];_&&this.hooksEntity[g].tapPromise(r.pluginName+g,function(){const y=_.apply(r,[...arguments]);return y instanceof Promise?y:Promise.resolve(y)})})}_bindingHotkeys(r){r?.hotkeys?.forEach(g=>{It(g,{keyup:!0},_=>{r.hotkeyEvent&&r.hotkeyEvent(g,_)})})}_saveCustomAttr(r){const{events:g=[],apis:_=[]}=r;this.customApis=this.customApis.concat(_),this.customEvents=this.customEvents.concat(g)}_bindingApis(r){const{apis:g=[]}=r.constructor||{};g.forEach(_=>{this[_]=function(){return r[_].apply(r,[...arguments])}})}_bindContextMenu(){this.canvas&&this.canvas.on("mouse:down",r=>{if(r.button===3){let g=[];Object.keys(this.pluginMap).forEach(_=>{const y=this.pluginMap[_],C=y.contextMenu&&y.contextMenu();C&&(g=g.concat(C))}),this._renderMenu(r,g)}})}_renderMenu(r,g){g.length!==0&&this.contextMenu&&(this.contextMenu.hideAll(),this.contextMenu.setData(g),this.contextMenu.show(r.e.clientX,r.e.clientY))}_initActionHooks(){this.hooks.forEach(r=>{this.hooksEntity[r]=new ta.AsyncSeriesHook(["data"])})}_initContextMenu(){this.contextMenu=new Ie(this.canvas.wrapperEl,[]),this.contextMenu.install()}_initServersPlugin(){this.use(Ai)}off(r,g){return g?super.off(r,g):this}}_t.fabric.Rect=_t.fabric.util.createClass(_t.fabric.Rect,{type:"rect",initialize:function(f){f||(f={}),this.callSuper("initialize",f)},_render(f){const r=this.roundValue||0;this.rx=1/this.scaleX*r,this.ry=1/this.scaleY*r,this.callSuper("_render",f)}});_t.fabric.Rect.fromObject=function(f,r){return _t.fabric.Object._fromObject("Rect",f,r)};const ia=_t.fabric.Rect;_t.fabric.Textbox=_t.fabric.util.createClass(_t.fabric.Textbox,{type:"textbox",_renderChars:function(f,r,g,_,y,C){var T=this.getHeightOfLine(C),c=this.textAlign.indexOf("justify")!==-1,i,l,a="",t,n=0,e,o=this.path,h=!c&&this.charSpacing===0&&this.isEmptyStyles(C)&&!o,s=this.direction==="ltr",u=this.direction==="ltr"?1:-1,d,m=r.canvas.getAttribute("dir");if(r.save(),m!==this.direction&&(r.canvas.setAttribute("dir",s?"ltr":"rtl"),r.direction=s?"ltr":"rtl",r.textAlign=s?"left":"right"),y-=T*this._fontSizeFraction/this.lineHeight,h){this._renderChar(f,r,C,0,g.join(""),_,y,T),r.restore();return}for(var p=0,v=g.length-1;p<=v;p++)e=p===v||this.charSpacing||o,a+=g[p],t=this.__charBounds[C][p],n===0?(_+=u*(t.kernedWidth-t.width),n+=t.width):n+=t.kernedWidth,c&&!e&&this._reSpaceAndTab.test(g[p])&&(e=!0),e||(i=i||this.getCompleteStyleDeclaration(C,p),l=this.getCompleteStyleDeclaration(C,p+1),e=_t.fabric.util.hasStyleChanged(i,l,!1)),o?(r.save(),r.translate(t.renderLeft,t.renderTop),r.rotate(t.angle),this._renderChar(f,r,C,p,a,-n/2,0,T),r.restore()):(d=_,this._renderChar(f,r,C,p,a,d,y,T)),a="",i=l,_+=u*n,n=0;r.restore()},enlargeSpaces:function(){for(var f,r,g,_,y,C,T,c=0,i=this._textLines.length;c<i;c++)if(!(this.textAlign!=="justify"&&(c===i-1||this.isEndOfWrapping(c)))&&(_=0,y=this._textLines[c],r=this.getLineWidth(c),r<this.width&&(T=this.textLines[c].split(""))&&T.length>1)){g=T.length,f=(this.width-r)/(g-1);for(var l=0,a=y.length;l<=a;l++)C=this.__charBounds[c][l],C.left+=_,l<a-1&&(C.width+=f,C.kernedWidth+=f,_+=f)}}});_t.fabric.Textbox.fromObject=function(f,r){const{text:g}=f;return r(new _t.fabric.Textbox(g,f))};const na=_t.fabric.Rect;exports.CustomRect=ia;exports.CustomTextbox=na;exports.Utils=fr;exports.default=ea;exports.fabric=_t.fabric;