canvas_erd 0.1.0

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.
@@ -0,0 +1,473 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.fabric={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r};function r(e){"@babel/helpers - typeof";return r=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},r(e)}function i(e,t){if(r(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t||`default`);if(r(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function a(e){var t=i(e,`string`);return r(t)==`symbol`?t:t+``}function o(e,t,n){return(t=a(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=class{constructor(){o(this,`browserShadowBlurConstant`,1),o(this,`DPI`,96),o(this,`devicePixelRatio`,void 0),o(this,`perfLimitSizeTotal`,2097152),o(this,`maxCacheSideLimit`,4096),o(this,`minCacheSideLimit`,256),o(this,`disableStyleCopyPaste`,!1),o(this,`enableGLFiltering`,!0),o(this,`textureSize`,4096),o(this,`forceGLPutImageData`,!1),o(this,`cachesBoundsOfCurve`,!1),o(this,`fontPaths`,{}),o(this,`NUM_FRACTION_DIGITS`,4)}};let c=new class extends s{constructor(e){super(),this.configure(e)}configure(e={}){Object.assign(this,e)}addFonts(e={}){this.fontPaths={...this.fontPaths,...e}}removeFonts(e=[]){e.forEach(e=>{delete this.fontPaths[e]})}clearFonts(){this.fontPaths={}}restoreDefaults(e){let t=new s,n=(e==null?void 0:e.reduce((e,n)=>(e[n]=t[n],e),{}))||t;this.configure(n)}},l=(e,...t)=>console[e](`fabric`,...t);var u=class extends Error{constructor(e,t){super(`fabric: ${e}`,t)}},d=class extends u{constructor(e){super(`${e} 'options.signal' is in 'aborted' state`)}};let f,p,m=e=>{f=e},h=e=>{p=e},g=()=>{if(f)return f;if(p)return f=p();throw new u(`Fabric env was not initialized. Import fabric, fabric/node, @fabricjs/browser, or @fabricjs/node before using environment-dependent APIs, or call setEnv/setEnvFactory.`)},_=()=>g().document,v=()=>g().window,y=()=>{var e,t;return Math.max((e=(t=c.devicePixelRatio)==null?v().devicePixelRatio:t)==null?1:e,1)},b=new class{constructor(){o(this,`boundsOfCurveCache`,{}),this.charWidthsCache=new Map}getFontCache({fontFamily:e,fontStyle:t,fontWeight:n}){e=e.toLowerCase();let r=this.charWidthsCache;r.has(e)||r.set(e,new Map);let i=r.get(e),a=`${t.toLowerCase()}_${(n+``).toLowerCase()}`;return i.has(a)||i.set(a,new Map),i.get(a)}clearFontCache(e){e?this.charWidthsCache.delete((e||``).toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(e){let{perfLimitSizeTotal:t}=c,n=Math.sqrt(t*e);return[Math.floor(n),Math.floor(t/n)]}},x=`7.4.0`;function S(){}let C=Math.PI/2,w=Math.PI/4,T=Math.PI*2,ee=Math.PI/180,E=Object.freeze([1,0,0,1,0,0]),D=`center`,O=`left`,te=`bottom`,k=`right`,ne=`none`,re=/\r?\n/,ie=`moving`,ae=`scaling`,oe=`rotating`,A=`rotate`,se=`skewing`,ce=`resizing`,le=`modifyPoly`,ue=`changed`,de=`scale`,fe=`scaleX`,pe=`scaleY`,me=`skewX`,he=`skewY`,j=`fill`,ge=`stroke`,_e=`modified`,ve=`normal`,ye=`json`,M=new class{constructor(){this[ye]=new Map,this.svg=new Map}has(e){return this[ye].has(e)}getClass(e){let t=this[ye].get(e);if(!t)throw new u(`No class registered for ${e}`);return t}setClass(e,t){t?this[ye].set(t,e):(this[ye].set(e.type,e),this[ye].set(e.type.toLowerCase(),e))}getSVGClass(e){return this.svg.get(e)}setSVGClass(e,t){this.svg.set(t==null?e.type.toLowerCase():t,e)}},be=new class extends Array{remove(e){let t=this.indexOf(e);t>-1&&this.splice(t,1)}cancelAll(){let e=this.splice(0);return e.forEach(e=>e.abort()),e}cancelByCanvas(e){if(!e)return[];let t=this.filter(t=>{var n;return t.target===e||typeof t.target==`object`&&((n=t.target)==null?void 0:n.canvas)===e});return t.forEach(e=>e.abort()),t}cancelByTarget(e){if(!e)return[];let t=this.filter(t=>t.target===e);return t.forEach(e=>e.abort()),t}};var xe=class{constructor(){o(this,`__eventListeners`,{})}on(e,t){if(this.__eventListeners||(this.__eventListeners={}),typeof e==`object`)return Object.entries(e).forEach(([e,t])=>{this.on(e,t)}),()=>this.off(e);if(t){let n=e;return this.__eventListeners[n]||(this.__eventListeners[n]=[]),this.__eventListeners[n].push(t),()=>this.off(n,t)}else return()=>!1}once(e,t){if(typeof e==`object`){let t=[];return Object.entries(e).forEach(([e,n])=>{t.push(this.once(e,n))}),()=>t.forEach(e=>e())}else if(t){let n=this.on(e,function(...e){t.call(this,...e),n()});return n}else return()=>!1}_removeEventListener(e,t){if(this.__eventListeners[e])if(t){let n=this.__eventListeners[e],r=n.indexOf(t);r>-1&&n.splice(r,1)}else this.__eventListeners[e]=[]}off(e,t){if(this.__eventListeners)if(e===void 0)for(let e in this.__eventListeners)this._removeEventListener(e);else typeof e==`object`?Object.entries(e).forEach(([e,t])=>{this._removeEventListener(e,t)}):this._removeEventListener(e,t)}fire(e,t){var n;if(!this.__eventListeners)return;let r=(n=this.__eventListeners[e])==null?void 0:n.concat();if(r)for(let e=0;e<r.length;e++)r[e].call(this,t||{})}};let Se=(e,t)=>{let n=e.indexOf(t);return n!==-1&&e.splice(n,1),e},Ce=e=>{if(e===0)return 1;switch(Math.abs(e)/C){case 1:case 3:return 0;case 2:return-1}return Math.cos(e)},N=e=>{if(e===0)return 0;let t=e/C,n=Math.sign(e);switch(t){case 1:return n;case 2:return 0;case 3:return-n}return Math.sin(e)};var P=class e{constructor(e=0,t=0){typeof e==`object`?(this.x=e.x,this.y=e.y):(this.x=e,this.y=t)}add(t){return new e(this.x+t.x,this.y+t.y)}addEquals(e){return this.x+=e.x,this.y+=e.y,this}scalarAdd(t){return new e(this.x+t,this.y+t)}scalarAddEquals(e){return this.x+=e,this.y+=e,this}subtract(t){return new e(this.x-t.x,this.y-t.y)}subtractEquals(e){return this.x-=e.x,this.y-=e.y,this}scalarSubtract(t){return new e(this.x-t,this.y-t)}scalarSubtractEquals(e){return this.x-=e,this.y-=e,this}multiply(t){return new e(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new e(this.x*t,this.y*t)}scalarMultiplyEquals(e){return this.x*=e,this.y*=e,this}divide(t){return new e(this.x/t.x,this.y/t.y)}scalarDivide(t){return new e(this.x/t,this.y/t)}scalarDivideEquals(e){return this.x/=e,this.y/=e,this}eq(e){return this.x===e.x&&this.y===e.y}lt(e){return this.x<e.x&&this.y<e.y}lte(e){return this.x<=e.x&&this.y<=e.y}gt(e){return this.x>e.x&&this.y>e.y}gte(e){return this.x>=e.x&&this.y>=e.y}lerp(t,n=.5){return n=Math.max(Math.min(1,n),0),new e(this.x+(t.x-this.x)*n,this.y+(t.y-this.y)*n)}distanceFrom(e){let t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}midPointFrom(e){return this.lerp(e)}min(t){return new e(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new e(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return`${this.x},${this.y}`}setXY(e,t){return this.x=e,this.y=t,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setFromPoint(e){return this.x=e.x,this.y=e.y,this}swap(e){let t=this.x,n=this.y;this.x=e.x,this.y=e.y,e.x=t,e.y=n}clone(){return new e(this.x,this.y)}rotate(t,n=we){let r=N(t),i=Ce(t),a=this.subtract(n);return new e(a.x*i-a.y*r,a.x*r+a.y*i).add(n)}transform(t,n=!1){return new e(t[0]*this.x+t[2]*this.y+(n?0:t[4]),t[1]*this.x+t[3]*this.y+(n?0:t[5]))}};let we=new P(0,0),Te=e=>!!e&&Array.isArray(e._objects);function Ee(e){class t extends e{constructor(...e){super(...e),o(this,`_objects`,[])}_onObjectAdded(e){}_onObjectRemoved(e){}_onStackOrderChanged(e){}add(...e){let t=this._objects.push(...e);return e.forEach(e=>this._onObjectAdded(e)),t}insertAt(e,...t){return this._objects.splice(e,0,...t),t.forEach(e=>this._onObjectAdded(e)),this._objects.length}remove(...e){let t=this._objects,n=[];return e.forEach(e=>{let r=t.indexOf(e);r!==-1&&(t.splice(r,1),n.push(e),this._onObjectRemoved(e))}),n}forEachObject(e){this.getObjects().forEach((t,n,r)=>e(t,n,r))}getObjects(...e){return e.length===0?[...this._objects]:this._objects.filter(t=>t.isType(...e))}item(e){return this._objects[e]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(e,n){return this._objects.includes(e)?!0:n?this._objects.some(n=>n instanceof t&&n.contains(e,!0)):!1}complexity(){return this._objects.reduce((e,t)=>(e+=t.complexity?t.complexity():0,e),0)}sendObjectToBack(e){return!e||e===this._objects[0]?!1:(Se(this._objects,e),this._objects.unshift(e),this._onStackOrderChanged(e),!0)}bringObjectToFront(e){return!e||e===this._objects[this._objects.length-1]?!1:(Se(this._objects,e),this._objects.push(e),this._onStackOrderChanged(e),!0)}sendObjectBackwards(e,t){if(!e)return!1;let n=this._objects.indexOf(e);if(n!==0){let r=this.findNewLowerIndex(e,n,t);return Se(this._objects,e),this._objects.splice(r,0,e),this._onStackOrderChanged(e),!0}return!1}bringObjectForward(e,t){if(!e)return!1;let n=this._objects.indexOf(e);if(n!==this._objects.length-1){let r=this.findNewUpperIndex(e,n,t);return Se(this._objects,e),this._objects.splice(r,0,e),this._onStackOrderChanged(e),!0}return!1}moveObjectTo(e,t){return e===this._objects[t]?!1:(Se(this._objects,e),this._objects.splice(t,0,e),this._onStackOrderChanged(e),!0)}findNewLowerIndex(e,t,n){let r;if(n){r=t;for(let n=t-1;n>=0;--n)if(e.isOverlapping(this._objects[n])){r=n;break}}else r=t-1;return r}findNewUpperIndex(e,t,n){let r;if(n){r=t;for(let n=t+1;n<this._objects.length;++n)if(e.isOverlapping(this._objects[n])){r=n;break}}else r=t+1;return r}collectObjects({left:e,top:t,width:n,height:r},{includeIntersecting:i=!0}={}){let a=[],o=new P(e,t),s=o.add(new P(n,r));for(let e=this._objects.length-1;e>=0;e--){let t=this._objects[e];t.selectable&&t.visible&&(i&&t.intersectsWithRect(o,s)||t.isContainedWithinRect(o,s)||i&&t.containsPoint(o)||i&&t.containsPoint(s))&&a.push(t)}return a}}return t}var De=class extends xe{_setOptions(e={}){for(let t in e)this.set(t,e[t])}_setObject(e){for(let t in e)this._set(t,e[t])}set(e,t){return typeof e==`object`?this._setObject(e):this._set(e,t),this}_set(e,t){this[e]=t}toggle(e){let t=this.get(e);return typeof t==`boolean`&&this.set(e,!t),this}get(e){return this[e]}};function Oe(e){return v().requestAnimationFrame(e)}function ke(e){return v().cancelAnimationFrame(e)}let Ae=0,je=()=>Ae++,F=()=>{let e=_().createElement(`canvas`);if(!e||e.getContext===void 0)throw new u("Failed to create `canvas` element");return e},Me=()=>_().createElement(`img`),Ne=e=>{var t;let n=I(e);return(t=n.getContext(`2d`))==null||t.drawImage(e,0,0),n},I=e=>{let t=F();return t.width=e.width,t.height=e.height,t},Pe=(e,t,n)=>e.toDataURL(`image/${t}`,n),Fe=e=>!!e&&e.getContext!==void 0,Ie=(e,t,n)=>new Promise((r,i)=>{e.toBlob(r,`image/${t}`,n)}),L=e=>e*ee,Le=e=>e/ee,Re=e=>e.every((e,t)=>e===E[t]),R=(e,t,n)=>new P(e).transform(t,n),z=e=>{let t=1/(e[0]*e[3]-e[1]*e[2]),n=[t*e[3],-t*e[1],-t*e[2],t*e[0],0,0],{x:r,y:i}=new P(e[4],e[5]).transform(n,!0);return n[4]=-r,n[5]=-i,n},B=(e,t,n)=>[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],n?0:e[0]*t[4]+e[2]*t[5]+e[4],n?0:e[1]*t[4]+e[3]*t[5]+e[5]],ze=(e,t)=>e.reduceRight((e,n)=>n&&e?B(n,e,t):n||e,void 0)||E.concat(),Be=([e,t])=>Math.atan2(t,e),Ve=([e,t])=>Math.sqrt(e*e+t*t),He=([,,e,t])=>Math.sqrt(e*e+t*t),Ue=e=>{let t=Be(e),n=e[0]**2+e[1]**2,r=Math.sqrt(n),i=(e[0]*e[3]-e[2]*e[1])/r,a=Math.atan2(e[0]*e[2]+e[1]*e[3],n);return{angle:Le(t),scaleX:r,scaleY:i,skewX:Le(a),skewY:0,translateX:e[4]||0,translateY:e[5]||0}},We=(e,t=0)=>[1,0,0,1,e,t];function Ge({angle:e=0}={},{x:t=0,y:n=0}={}){let r=L(e),i=Ce(r),a=N(r);return[i,a,-a,i,t?t-(i*t-a*n):0,n?n-(a*t+i*n):0]}let Ke=(e,t=e)=>[e,0,0,t,0,0],qe=e=>Math.tan(L(e)),Je=e=>[1,0,qe(e),1,0,0],Ye=e=>[1,qe(e),0,1,0,0],Xe=({scaleX:e=1,scaleY:t=1,flipX:n=!1,flipY:r=!1,skewX:i=0,skewY:a=0})=>{let o=Ke(n?-e:e,r?-t:t);return i&&(o=B(o,Je(i),!0)),a&&(o=B(o,Ye(a),!0)),o},Ze=e=>{let{translateX:t=0,translateY:n=0,angle:r=0}=e,i=We(t,n);r&&(i=B(i,Ge({angle:r})));let a=Xe(e);return Re(a)||(i=B(i,a)),i},Qe=(e,{signal:t,crossOrigin:n=null}={})=>new Promise(function(r,i){if(t&&t.aborted)return i(new d(`loadImage`));let a=Me(),o;t&&(o=function(e){a.src=``,i(e)},t.addEventListener(`abort`,o,{once:!0}));let s=function(){a.onload=a.onerror=null,o&&(t==null||t.removeEventListener(`abort`,o)),r(a)};if(!e){s();return}a.onload=s,a.onerror=function(){o&&(t==null||t.removeEventListener(`abort`,o)),i(new u(`Error loading ${a.src}`))},n&&(a.crossOrigin=n),a.src=e}),$e=(e,{signal:t,reviver:n=S}={})=>new Promise((r,i)=>{let a=[];t&&t.addEventListener(`abort`,i,{once:!0}),Promise.allSettled(e.map(e=>M.getClass(e.type).fromObject(e,{signal:t}))).then(async t=>{for(let[r,i]of t.entries())if(i.status===`fulfilled`&&(await n(e[r],i.value),a.push(i.value)),i.status===`rejected`){let t=await n(e[r],void 0,i.reason);t&&a.push(t)}r(a)}).catch(e=>{a.forEach(e=>{e.dispose&&e.dispose()}),i(e)}).finally(()=>{t&&t.removeEventListener(`abort`,i)})}),et=(e,{signal:t}={})=>new Promise((n,r)=>{let i=[];t&&t.addEventListener(`abort`,r,{once:!0});let a=Object.values(e).map(e=>e&&(e.type&&M.has(e.type)?$e([e],{signal:t}).then(([e])=>(i.push(e),e)):e)),o=Object.keys(e);Promise.all(a).then(e=>e.reduce((e,t,n)=>(e[o[n]]=t,e),{})).then(n).catch(e=>{i.forEach(e=>{e.dispose&&e.dispose()}),r(e)}).finally(()=>{t&&t.removeEventListener(`abort`,r)})}),tt=(e,t=[])=>t.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{}),nt=(e,t)=>Object.keys(e).reduce((n,r)=>(t(e[r],r,e)&&(n[r]=e[r]),n),{}),V=(e,t)=>parseFloat(Number(e).toFixed(t)),rt=e=>`matrix(`+e.map(e=>V(e,c.NUM_FRACTION_DIGITS)).join(` `)+`)`,H=e=>!!e&&e.toLive!==void 0,it=e=>!!e&&typeof e.toObject==`function`,at=e=>!!e&&e.offsetX!==void 0&&`source`in e,ot=e=>!!e&&typeof e._renderText==`function`,st=e=>!!e&&typeof e._renderPathCommands==`function`,ct=e=>!!e&&`multiSelectionStacking`in e;function lt(e){let t=e&&ut(e),n=0,r=0;if(!e||!t)return{left:n,top:r};let i=e,a=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;i&&(i.parentNode||i.host)&&(i=i.parentNode||i.host,i===t?(n=o.scrollLeft||a.scrollLeft||0,r=o.scrollTop||a.scrollTop||0):(n+=i.scrollLeft||0,r+=i.scrollTop||0),!(i.nodeType===1&&i.style.position===`fixed`)););return{left:n,top:r}}let ut=e=>e.ownerDocument||null,dt=e=>{var t;return((t=e.ownerDocument)==null?void 0:t.defaultView)||null},ft=(e,t,{width:n,height:r},i=1)=>{e.width=n,e.height=r,i>1&&(e.setAttribute(`width`,(n*i).toString()),e.setAttribute(`height`,(r*i).toString()),t.scale(i,i))},pt=(e,{width:t,height:n})=>{t&&(e.style.width=typeof t==`number`?`${t}px`:t),n&&(e.style.height=typeof n==`number`?`${n}px`:n)};function mt(e){var t;let n=e&&ut(e),r={left:0,top:0};if(!n)return r;let i=((t=dt(e))==null?void 0:t.getComputedStyle(e,null))||{};r.left+=parseInt(i.borderLeftWidth,10)||0,r.top+=parseInt(i.borderTopWidth,10)||0,r.left+=parseInt(i.paddingLeft,10)||0,r.top+=parseInt(i.paddingTop,10)||0;let a={left:0,top:0},o=n.documentElement;e.getBoundingClientRect!==void 0&&(a=e.getBoundingClientRect());let s=lt(e);return{left:a.left+s.left-(o.clientLeft||0)+r.left,top:a.top+s.top-(o.clientTop||0)+r.top}}function ht(e){return e.onselectstart!==void 0&&(e.onselectstart=()=>!1),e.style.userSelect=ne,e}var gt=class{constructor(e){o(this,`_originalCanvasStyle`,void 0),o(this,`lower`,void 0);let t=this.createLowerCanvas(e);this.lower={el:t,ctx:t.getContext(`2d`)}}createLowerCanvas(e){let t=Fe(e)?e:e&&_().getElementById(e)||F();if(t.hasAttribute(`data-fabric`))throw new u(`Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?`);return this._originalCanvasStyle=t.style.cssText,t.setAttribute(`data-fabric`,`main`),t.classList.add(`lower-canvas`),t}cleanupDOM({width:e,height:t}){let{el:n}=this.lower;n.classList.remove(`lower-canvas`),n.removeAttribute(`data-fabric`),n.setAttribute(`width`,`${e}`),n.setAttribute(`height`,`${t}`),n.style.cssText=this._originalCanvasStyle||``,this._originalCanvasStyle=void 0}setDimensions(e,t){let{el:n,ctx:r}=this.lower;ft(n,r,e,t)}setCSSDimensions(e){pt(this.lower.el,e)}calcOffset(){return mt(this.lower.el)}dispose(){g().dispose(this.lower.el),delete this.lower}};let _t={backgroundVpt:!0,backgroundColor:``,overlayVpt:!0,overlayColor:``,includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...E],patternQuality:`best`};var vt=n({capitalize:()=>yt,escapeXml:()=>U,graphemeSplit:()=>St});let yt=(e,t=!1)=>`${e.charAt(0).toUpperCase()}${t?e.slice(1):e.slice(1).toLowerCase()}`,U=e=>e.toString().replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/'/g,`&apos;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),bt,xt=()=>(bt||(bt=`Intl`in v()&&`Segmenter`in Intl&&new Intl.Segmenter(void 0,{granularity:`grapheme`})),bt),St=e=>{if(bt||xt(),bt){let t=bt.segment(e);return Array.from(t).map(({segment:e})=>e)}return Ct(e)},Ct=e=>{let t=[];for(let n=0,r;n<e.length;n++)(r=wt(e,n))!==!1&&t.push(r);return t},wt=(e,t)=>{let n=e.charCodeAt(t);if(isNaN(n))return``;if(n<55296||n>57343)return e.charAt(t);if(55296<=n&&n<=56319){if(e.length<=t+1)throw`High surrogate without following low surrogate`;let n=e.charCodeAt(t+1);if(56320>n||n>57343)throw`High surrogate without following low surrogate`;return e.charAt(t)+e.charAt(t+1)}if(t===0)throw`Low surrogate without preceding high surrogate`;let r=e.charCodeAt(t-1);if(55296>r||r>56319)throw`Low surrogate without preceding high surrogate`;return!1};var Tt=class e extends Ee(De){get lowerCanvasEl(){var e;return(e=this.elements.lower)==null?void 0:e.el}get contextContainer(){var e;return(e=this.elements.lower)==null?void 0:e.ctx}static getDefaults(){return e.ownDefaults}constructor(e,t={}){super(),Object.assign(this,this.constructor.getDefaults()),this.set(t),this.initElements(e),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(e){this.elements=new gt(e)}add(...e){let t=super.add(...e);return e.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(e,...t){let n=super.insertAt(e,...t);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),n}remove(...e){let t=super.remove(...e);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(e){e.canvas&&e.canvas!==this&&(l(`warn`,`Canvas is trying to add an object that belongs to a different canvas.
2
+ Resulting to default behavior: removing object from previous canvas and adding to new canvas`),e.canvas.remove(e)),e._set(`canvas`,this),e.setCoords(),this.fire(`object:added`,{target:e}),e.fire(`added`,{target:this})}_onObjectRemoved(e){e._set(`canvas`,void 0),this.fire(`object:removed`,{target:e}),e.fire(`removed`,{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?y():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}_setDimensionsImpl(e,{cssOnly:t=!1,backstoreOnly:n=!1}={}){if(!t){let t={width:this.width,height:this.height,...e};this.elements.setDimensions(t,this.getRetinaScaling()),this.hasLostContext=!0,this.width=t.width,this.height=t.height}n||this.elements.setCSSDimensions(e),this.calcOffset()}setDimensions(e,t){this._setDimensionsImpl(e,t),(!t||!t.cssOnly)&&this.requestRenderAll()}getZoom(){return Ve(this.viewportTransform)}setViewportTransform(e){this.viewportTransform=e,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(e,t){let n=e,r=[...this.viewportTransform],i=R(e,z(r));r[0]=t,r[3]=t;let a=R(i,r);r[4]+=n.x-a.x,r[5]+=n.y-a.y,this.setViewportTransform(r)}setZoom(e){this.zoomToPoint(new P(0,0),e)}absolutePan(e){let t=[...this.viewportTransform];return t[4]=-e.x,t[5]=-e.y,this.setViewportTransform(t)}relativePan(e){return this.absolutePan(new P(-e.x-this.viewportTransform[4],-e.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(e){e.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor=``,this.overlayColor=``,this.clearContext(this.getContext()),this.fire(`canvas:cleared`),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),!this.destroyed&&this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){!this.nextRenderHandle&&!this.disposed&&!this.destroyed&&(this.nextRenderHandle=Oe(()=>this.renderAndReset()))}calcViewportBoundaries(){let e=this.width,t=this.height,n=z(this.viewportTransform),r=R({x:0,y:0},n),i=R({x:e,y:t},n),a=r.min(i),o=r.max(i);return this.vptCoords={tl:a,tr:new P(o.x,a.y),bl:new P(a.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&(ke(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(e){}renderCanvas(e,t){if(this.destroyed)return;let n=this.viewportTransform,r=this.clipPath;this.calcViewportBoundaries(),this.clearContext(e),e.imageSmoothingEnabled=this.imageSmoothingEnabled,e.patternQuality=this.patternQuality,this.fire(`before:render`,{ctx:e}),this._renderBackground(e),e.save(),e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this._renderObjects(e,t),e.restore(),!this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(e),r&&(r._set(`canvas`,this),r.shouldCache(),r._transformDone=!0,r.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(e,r)),this._renderOverlay(e),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(e),this.fire(`after:render`,{ctx:e}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(e,t){let n=this.viewportTransform;e.save(),e.transform(...n),e.globalCompositeOperation=`destination-in`,t.transform(e),e.scale(1/t.zoomX,1/t.zoomY),e.drawImage(t._cacheCanvas,-t.cacheTranslationX,-t.cacheTranslationY),e.restore()}_renderObjects(e,t){for(let n=0,r=t.length;n<r;++n)t[n]&&t[n].render(e)}_renderBackgroundOrOverlay(e,t){let n=this[`${t}Color`],r=this[`${t}Image`],i=this.viewportTransform,a=this[`${t}Vpt`];if(!n&&!r)return;let o=H(n);if(n){if(e.save(),e.beginPath(),e.moveTo(0,0),e.lineTo(this.width,0),e.lineTo(this.width,this.height),e.lineTo(0,this.height),e.closePath(),e.fillStyle=o?n.toLive(e):n,a&&e.transform(...i),o){e.transform(1,0,0,1,n.offsetX||0,n.offsetY||0);let t=n.gradientTransform||n.patternTransform;t&&e.transform(...t)}e.fill(),e.restore()}if(r){e.save();let{skipOffscreen:t}=this;this.skipOffscreen=a,a&&e.transform(...i),r.render(e),this.skipOffscreen=t,e.restore()}}_renderBackground(e){this._renderBackgroundOrOverlay(e,`background`)}_renderOverlay(e){this._renderBackgroundOrOverlay(e,`overlay`)}getCenterPoint(){return new P(this.width/2,this.height/2)}centerObjectH(e){return this._centerObject(e,new P(this.getCenterPoint().x,e.getCenterPoint().y))}centerObjectV(e){return this._centerObject(e,new P(e.getCenterPoint().x,this.getCenterPoint().y))}centerObject(e){return this._centerObject(e,this.getCenterPoint())}viewportCenterObject(e){return this._centerObject(e,this.getVpCenter())}viewportCenterObjectH(e){return this._centerObject(e,new P(this.getVpCenter().x,e.getCenterPoint().y))}viewportCenterObjectV(e){return this._centerObject(e,new P(e.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return R(this.getCenterPoint(),z(this.viewportTransform))}_centerObject(e,t){e.setXY(t,D,D),e.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(e){return this.toDatalessObject(e)}toObject(e){return this._toObjectMethod(`toObject`,e)}toJSON(){return this.toObject()}toDatalessObject(e){return this._toObjectMethod(`toDatalessObject`,e)}_toObjectMethod(e,t){let n=this.clipPath,r=n&&!n.excludeFromExport?this._toObject(n,e,t):null;return{version:x,...tt(this,t),objects:this._objects.filter(e=>!e.excludeFromExport).map(n=>this._toObject(n,e,t)),...this.__serializeBgOverlay(e,t),...r?{clipPath:r}:null}}_toObject(e,t,n){let r;this.includeDefaultValues||(r=e.includeDefaultValues,e.includeDefaultValues=!1);let i=e[t](n);return this.includeDefaultValues||(e.includeDefaultValues=!!r),i}__serializeBgOverlay(e,t){let n={},r=this.backgroundImage,i=this.overlayImage,a=this.backgroundColor,o=this.overlayColor;return H(a)?a.excludeFromExport||(n.background=a.toObject(t)):a&&(n.background=a),H(o)?o.excludeFromExport||(n.overlay=o.toObject(t)):o&&(n.overlay=o),r&&!r.excludeFromExport&&(n.backgroundImage=this._toObject(r,e,t)),i&&!i.excludeFromExport&&(n.overlayImage=this._toObject(i,e,t)),n}toSVG(e={},t){e.reviver=t;let n=[];if(this._setSVGPreamble(n,e),this._setSVGHeader(n,e),this.clipPath){var r;n.push(`<g clip-path="url(#${U((r=this.clipPath.clipPathId)==null?``:r)})" >\n`)}return this._setSVGBgOverlayColor(n,`background`),this._setSVGBgOverlayImage(n,`backgroundImage`,t),this._setSVGObjects(n,t),this.clipPath&&n.push(`</g>
3
+ `),this._setSVGBgOverlayColor(n,`overlay`),this._setSVGBgOverlayImage(n,`overlayImage`,t),n.push(`</svg>`),n.join(``)}_setSVGPreamble(e,t){t.suppressPreamble||e.push(`<?xml version="1.0" encoding="`,t.encoding||`UTF-8`,`" standalone="no" ?>
4
+ `,`<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" `,`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
5
+ `)}_setSVGHeader(e,t){let n=t.width||`${this.width}`,r=t.height||`${this.height}`,i=c.NUM_FRACTION_DIGITS,a=t.viewBox,o;if(a)o=`viewBox="${a.x} ${a.y} ${a.width} ${a.height}" `;else if(this.svgViewportTransformation){let e=this.viewportTransform;o=`viewBox="${V(-e[4]/e[0],i)} ${V(-e[5]/e[3],i)} ${V(this.width/e[0],i)} ${V(this.height/e[3],i)}" `}else o=`viewBox="0 0 ${this.width} ${this.height}" `;e.push(`<svg `,`xmlns="http://www.w3.org/2000/svg" `,`xmlns:xlink="http://www.w3.org/1999/xlink" `,`version="1.1" `,`width="`,n,`" `,`height="`,r,`" `,o,`xml:space="preserve">
6
+ `,`<desc>Created with Fabric.js `,x,`</desc>
7
+ `,`<defs>
8
+ `,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(t),`</defs>
9
+ `)}createSVGClipPathMarkup(e){let t=this.clipPath;return t?(t.clipPathId=`CLIPPATH_${je()}`,`<clipPath id="${t.clipPathId}" >\n${t.toClipPathSVG(e.reviver)}</clipPath>\n`):``}createSVGRefElementsMarkup(){return[`background`,`overlay`].map(e=>{let t=this[`${e}Color`];if(H(t)){let n=this[`${e}Vpt`],r=this.viewportTransform,i={isType:()=>!1,width:this.width/(n?r[0]:1),height:this.height/(n?r[3]:1)};return t.toSVG(i,{additionalTransform:n?rt(r):``})}}).join(``)}createSVGFontFacesMarkup(){let e=[],t={},n=c.fontPaths;this._objects.forEach(function t(n){e.push(n),Te(n)&&n._objects.forEach(t)}),e.forEach(e=>{if(!ot(e))return;let{styles:r,fontFamily:i}=e;t[i]||!n[i]||(t[i]=!0,r&&Object.values(r).forEach(e=>{Object.values(e).forEach(({fontFamily:e=``})=>{!t[e]&&n[e]&&(t[e]=!0)})}))});let r=Object.keys(t).map(e=>`\t\t@font-face {\n\t\t\tfont-family: '${e}';\n\t\t\tsrc: url('${n[e]}');\n\t\t}\n`).join(``);return r?`\t<style type="text/css"><![CDATA[\n${r}]]></style>\n`:``}_setSVGObjects(e,t){this.forEachObject(n=>{n.excludeFromExport||this._setSVGObject(e,n,t)})}_setSVGObject(e,t,n){e.push(t.toSVG(n))}_setSVGBgOverlayImage(e,t,n){let r=this[t];r&&!r.excludeFromExport&&r.toSVG&&e.push(r.toSVG(n))}_setSVGBgOverlayColor(e,t){let n=this[`${t}Color`];if(n)if(H(n)){let r=n.repeat||``,i=this.width,a=this.height,o=this[`${t}Vpt`]?rt(z(this.viewportTransform)):``;e.push(`<rect transform="${o} translate(${i/2},${a/2})" x="${n.offsetX-i/2}" y="${n.offsetY-a/2}" width="${(r===`repeat-y`||r===`no-repeat`)&&at(n)?n.source.width:i}" height="${(r===`repeat-x`||r===`no-repeat`)&&at(n)?n.source.height:a}" fill="url(#SVGID_${n.id})"></rect>\n`)}else e.push(`<rect x="0" y="0" width="100%" height="100%" `,`fill="`,n,`"`,`></rect>
10
+ `)}loadFromJSON(e,t,{signal:n}={}){if(!e)return Promise.reject(new u("`json` is undefined"));let{objects:r=[],...i}=typeof e==`string`?JSON.parse(e):e,{backgroundImage:a,background:o,overlayImage:s,overlay:c,clipPath:l}=i,d=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([$e(r,{reviver:t,signal:n}),et({backgroundImage:a,backgroundColor:o,overlayImage:s,overlayColor:c,clipPath:l},{signal:n})]).then(([e,t])=>(this.clear(),this.add(...e),this.set(i),this.set(t),this.renderOnAddRemove=d,this))}clone(e){let t=this.toObject(e);return this.cloneWithoutData().loadFromJSON(t)}cloneWithoutData(){let e=I(this);return new this.constructor(e)}toDataURL(e={}){let{format:t=`png`,quality:n=1,multiplier:r=1,enableRetinaScaling:i=!1}=e,a=r*(i?this.getRetinaScaling():1);return Pe(this.toCanvasElement(a,e),t,n)}toBlob(e={}){let{format:t=`png`,quality:n=1,multiplier:r=1,enableRetinaScaling:i=!1}=e,a=r*(i?this.getRetinaScaling():1);return Ie(this.toCanvasElement(a,e),t,n)}toCanvasElement(e=1,{width:t,height:n,left:r,top:i,filter:a}={}){let o=(t||this.width)*e,s=(n||this.height)*e,c=this.getZoom(),l=this.width,u=this.height,d=this.skipControlsDrawing,f=c*e,p=this.viewportTransform,m=[f,0,0,f,(p[4]-(r||0))*e,(p[5]-(i||0))*e],h=this.enableRetinaScaling,g=I({width:o,height:s}),_=a?this._objects.filter(e=>a(e)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=m,this.width=o,this.height=s,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(g.getContext(`2d`),_),this.viewportTransform=p,this.width=l,this.height=u,this.calcViewportBoundaries(),this.enableRetinaScaling=h,this.skipControlsDrawing=d,g}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),be.cancelByCanvas(this),this.disposed=!0,new Promise((e,t)=>{let n=()=>{this.destroy(),e(!0)};n.kill=t,this.__cleanupTask&&this.__cleanupTask.kill(`aborted`),this.destroyed?e(!1):this.nextRenderHandle?this.__cleanupTask=n:n()})}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject(e=>e.dispose()),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return`#<Canvas (${this.complexity()}): { objects: ${this._objects.length} }>`}};o(Tt,`ownDefaults`,_t);let Et=[`touchstart`,`touchmove`,`touchend`];function Dt(e){let t=e.changedTouches;return t&&t[0]?t[0]:e}let Ot=e=>{let t=e.target,n=lt(t),r=Dt(e);return new P(r.clientX+n.left,r.clientY+n.top)},kt=e=>Et.includes(e.type)||e.pointerType===`touch`,At=e=>{e.preventDefault(),e.stopPropagation()},jt=e=>{let t=0,n=0,r=0,i=0;for(let a=0,o=e.length;a<o;a++){let{x:o,y:s}=e[a];(o>r||!a)&&(r=o),(o<t||!a)&&(t=o),(s>i||!a)&&(i=s),(s<n||!a)&&(n=s)}return{left:t,top:n,width:r-t,height:i-n}},Mt=(e,t)=>{Pt(e,B(z(t),e.calcOwnMatrix()))},Nt=(e,t)=>Pt(e,B(t,e.calcOwnMatrix())),Pt=(e,t)=>{let{translateX:n,translateY:r,scaleX:i,scaleY:a,...o}=Ue(t),s=new P(n,r);e.flipX=!1,e.flipY=!1,Object.assign(e,o),e.set({scaleX:i,scaleY:a}),e.setPositionByOrigin(s,D,D)},Ft=e=>{e.scaleX=1,e.scaleY=1,e.skewX=0,e.skewY=0,e.flipX=!1,e.flipY=!1,e.rotate(0)},It=e=>({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}),Lt=(e,t,n)=>{let r=e/2,i=t/2,a=jt([new P(-r,-i),new P(r,-i),new P(-r,i),new P(r,i)].map(e=>e.transform(n)));return new P(a.width,a.height)},Rt=(e=E,t=E)=>B(z(t),e),zt=(e,t=E,n=E)=>e.transform(Rt(t,n)),Bt=(e,t=E,n=E)=>e.transform(Rt(t,n),!0),Vt=(e,t,n)=>{let r=Rt(t,n);return Pt(e,B(r,e.calcOwnMatrix())),r},Ht={left:-.5,top:-.5,center:0,bottom:.5,right:.5},W=e=>typeof e==`string`?Ht[e]:e-.5,Ut=new P(1,0),Wt=new P,Gt=(e,t)=>e.rotate(t),Kt=(e,t)=>new P(t).subtract(e),qt=e=>e.distanceFrom(Wt),Jt=(e,t)=>Math.atan2(Qt(e,t),$t(e,t)),Yt=e=>Jt(Ut,e),Xt=e=>e.eq(Wt)?e:e.scalarDivide(qt(e)),Zt=(e,t=!0)=>Xt(new P(-e.y,e.x).scalarMultiply(t?1:-1)),Qt=(e,t)=>e.x*t.y-e.y*t.x,$t=(e,t)=>e.x*t.x+e.y*t.y,en=(e,t,n)=>{if(e.eq(t)||e.eq(n))return!0;let r=Qt(t,n),i=Qt(t,e),a=Qt(n,e);return r>=0?i>=0&&a<=0:!(i<=0&&a>=0)},tn=`not-allowed`,nn=(e,t,n,r)=>{if(!t||!e)return`drag`;let i=r.controls[t];return i.getActionName(n,i,r)};function rn(e){return W(e.originX)===W(`center`)&&W(e.originY)===W(`center`)}function an(e){return-W(e)+.5}let on=(e,t)=>e[t],sn=(e,t,n,r)=>({e,transform:t,pointer:new P(n,r)});function cn(e,t,n){let r=n,i=Yt(Kt(zt(e.getCenterPoint(),e.canvas.viewportTransform),r))+T;return Math.round(i%T/w)}function ln(e,t,n,r){let i=e.getRelativeCenterPoint(),a=n!==void 0&&r!==void 0?e.translateToGivenOrigin(i,D,D,n,r):new P(e.left,e.top);return(e.angle?t.rotate(-L(e.angle),i):t).subtract(a)}function un({target:e,corner:t},n,r,i,a){var o;let s=e.controls[t],c=((o=e.canvas)==null?void 0:o.getZoom())||1,l=e.padding/c,u=ln(e,new P(i,a),n,r);return u.x>=l&&(u.x-=l),u.x<=-l&&(u.x+=l),u.y>=l&&(u.y-=l),u.y<=l&&(u.y+=l),u.x-=s.offsetX,u.y-=s.offsetY,u}let dn=new RegExp(String.raw`[\0-\x1F\x7F;<>\\]|\/\*|\*\/|url\s*\(|expression\s*\(|(?:java|vb)script\s*:|data\s*:|@import\b`,`iu`),fn=e=>typeof e==`string`&&e.trim().length>0&&!dn.test(e),pn=(e,t=``)=>{let n=Number(e);return Number.isFinite(n)?`${n}`:t},mn=(e,t=``)=>typeof e==`string`&&fn(e)?e:t,hn=e=>e.replace(/\s+/g,` `),gn={aliceblue:`#F0F8FF`,antiquewhite:`#FAEBD7`,aqua:`#0FF`,aquamarine:`#7FFFD4`,azure:`#F0FFFF`,beige:`#F5F5DC`,bisque:`#FFE4C4`,black:`#000`,blanchedalmond:`#FFEBCD`,blue:`#00F`,blueviolet:`#8A2BE2`,brown:`#A52A2A`,burlywood:`#DEB887`,cadetblue:`#5F9EA0`,chartreuse:`#7FFF00`,chocolate:`#D2691E`,coral:`#FF7F50`,cornflowerblue:`#6495ED`,cornsilk:`#FFF8DC`,crimson:`#DC143C`,cyan:`#0FF`,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:`#F0F`,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:`#789`,lightslategrey:`#789`,lightsteelblue:`#B0C4DE`,lightyellow:`#FFFFE0`,lime:`#0F0`,limegreen:`#32CD32`,linen:`#FAF0E6`,magenta:`#F0F`,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:`#639`,red:`#F00`,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:`#FFF`,whitesmoke:`#F5F5F5`,yellow:`#FF0`,yellowgreen:`#9ACD32`},_n=()=>/^rgba?\(\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d{0,3}(?:\.\d+)?%?)\s?)?\)$/i,vn=()=>/^hsla?\(\s?([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d*(?:\.\d+)?%?)\s?)?\)$/i,yn=()=>/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i,bn=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),xn=(e,t,n,r)=>{e/=255,t/=255,n/=255;let i=Math.max(e,t,n),a=Math.min(e,t,n),o,s,c=(i+a)/2;if(i===a)o=s=0;else{let r=i-a;switch(s=c>.5?r/(2-i-a):r/(i+a),i){case e:o=(t-n)/r+(t<n?6:0);break;case t:o=(n-e)/r+2;break;case n:o=(e-t)/r+4;break}o/=6}return[Math.round(o*360),Math.round(s*100),Math.round(c*100),r]},Sn=(e=`1`)=>parseFloat(e)/(e.endsWith(`%`)?100:1),Cn=e=>Math.min(Math.round(e),255).toString(16).toUpperCase().padStart(2,`0`),wn=([e,t,n,r=1])=>{let i=Math.round(e*.3+t*.59+n*.11);return[i,i,i,r]};var G=class e{constructor(t){if(o(this,`isUnrecognised`,!1),!t)this.setSource([0,0,0,1]);else if(t instanceof e)this.setSource([...t._source]);else if(Array.isArray(t)){let[e,n,r,i=1]=t;this.setSource([e,n,r,i])}else this.setSource(this._tryParsingColor(t))}_tryParsingColor(t){return t=t.toLowerCase(),t in gn&&(t=gn[t]),t===`transparent`?[255,255,255,0]:e.sourceFromHex(t)||e.sourceFromRgb(t)||e.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(e){this._source=e}toRgb(){let[e,t,n]=this.getSource();return`rgb(${e},${t},${n})`}toRgba(){return`rgba(${this.getSource().join(`,`)})`}toHsl(){let[e,t,n]=xn(...this.getSource());return`hsl(${e},${t}%,${n}%)`}toHsla(){let[e,t,n,r]=xn(...this.getSource());return`hsla(${e},${t}%,${n}%,${r})`}toHex(){return this.toHexa().slice(0,6)}toHexa(){let[e,t,n,r]=this.getSource();return`${Cn(e)}${Cn(t)}${Cn(n)}${Cn(Math.round(r*255))}`}getAlpha(){return this.getSource()[3]}setAlpha(e){return this._source[3]=e,this}toGrayscale(){return this.setSource(wn(this.getSource())),this}toBlackWhite(e){let[t,,,n]=wn(this.getSource()),r=t<(e||127)?0:255;return this.setSource([r,r,r,n]),this}overlayWith(t){t instanceof e||(t=new e(t));let n=this.getSource(),r=.5,i=t.getSource(),[a,o,s]=n.map((e,t)=>Math.round(e*(1-r)+i[t]*r));return this.setSource([a,o,s,n[3]]),this}static fromRgb(t){return e.fromRgba(t)}static fromRgba(t){return new e(e.sourceFromRgb(t))}static sourceFromRgb(e){let t=hn(e).match(_n());if(t){let[e,n,r]=t.slice(1,4).map(e=>{let t=parseFloat(e);return e.endsWith(`%`)?Math.round(t*2.55):t});return[e,n,r,Sn(t[4])]}}static fromHsl(t){return e.fromHsla(t)}static fromHsla(t){return new e(e.sourceFromHsl(t))}static sourceFromHsl(t){let n=hn(t).match(vn());if(!n)return;let r=(e.parseAngletoDegrees(n[1])%360+360)%360/360,i=parseFloat(n[2])/100,a=parseFloat(n[3])/100,o,s,c;if(i===0)o=s=c=a;else{let e=a<=.5?a*(i+1):a+i-a*i,t=a*2-e;o=bn(t,e,r+1/3),s=bn(t,e,r),c=bn(t,e,r-1/3)}return[Math.round(o*255),Math.round(s*255),Math.round(c*255),Sn(n[4])]}static fromHex(t){return new e(e.sourceFromHex(t))}static sourceFromHex(e){if(e.match(yn())){let t=e.slice(e.indexOf(`#`)+1),n=t.length<=4,r;r=n?t.split(``).map(e=>e+e):t.match(/.{2}/g);let[i,a,o,s=255]=r.map(e=>parseInt(e,16));return[i,a,o,s/255]}}static parseAngletoDegrees(e){let t=e.toLowerCase(),n=parseFloat(t);return t.includes(`rad`)?Le(n):t.includes(`turn`)?n*360:n}};let Tn=e=>{let t=[`instantiated_by_use`,`style`,`id`,`class`];switch(e){case`linearGradient`:return t.concat([`x1`,`y1`,`x2`,`y2`,`gradientUnits`,`gradientTransform`]);case`radialGradient`:return t.concat([`gradientUnits`,`gradientTransform`,`cx`,`cy`,`r`,`fx`,`fy`,`fr`]);case`stop`:return t.concat([`offset`,`stop-color`,`stop-opacity`])}return t},K=(e,t=16)=>{let n=/\D{0,2}$/.exec(e),r=parseFloat(e),i=c.DPI;switch(n==null?void 0:n[0]){case`mm`:return r*i/25.4;case`cm`:return r*i/2.54;case`in`:return r*i;case`pt`:return r*i/72;case`pc`:return r*i/72*12;case`em`:return r*t;default:return r}},En=e=>e&&e!==`none`?[e.slice(1,4),e.slice(5,8)]:e===`none`?[e,e]:[`Mid`,`Mid`],Dn=e=>{let[t,n]=e.trim().split(` `),[r,i]=En(t);return{meetOrSlice:n||`meet`,alignX:r,alignY:i}},On=(e,t,n=!0)=>{let r,i;if(!t)r=`none`;else if(t.toLive)r=`url(#SVGID_${U(t.id)})`;else{let e=String(t);if(fn(e)){let t=new G(e),n=t.getAlpha();r=t.toRgb(),n!==1&&(i=n.toString())}else r=new G(`black`).toRgb()}return n?`${e}: ${r}; ${i?`${e}-opacity: ${i}; `:``}`:`${e}="${r}" ${i?`${e}-opacity="${i}" `:``}`},kn=(e,{left:t,top:n,width:r,height:i},a=c.NUM_FRACTION_DIGITS)=>{let o=On(j,e,!1),[s,l,u,d]=[t,n,r,i].map(e=>V(e,a));return`<rect ${o} x="${s}" y="${l}" width="${u}" height="${d}"></rect>`};var An=class{getSvgStyles(e){let t=this.fillRule==null?`nonzero`:mn(this.fillRule),n=this.strokeWidth==null?`0`:pn(this.strokeWidth),r=this.strokeDashArray==null?ne:this.strokeDashArray.every(e=>Number.isFinite(Number(e)))?this.strokeDashArray.join(` `):``,i=this.strokeDashOffset==null?`0`:pn(this.strokeDashOffset),a=this.strokeLineCap==null?`butt`:mn(this.strokeLineCap),o=this.strokeLineJoin==null?`miter`:mn(this.strokeLineJoin),s=this.strokeMiterLimit==null?`4`:pn(this.strokeMiterLimit),c=this.opacity==null?`1`:pn(this.opacity),l=this.visible?``:` visibility: hidden;`,u=e?``:this.getSvgFilter(),d=On(j,this.fill);return[On(ge,this.stroke),n?`stroke-width: ${n}; `:``,r?`stroke-dasharray: ${r}; `:``,a?`stroke-linecap: ${a}; `:``,i?`stroke-dashoffset: ${i}; `:``,o?`stroke-linejoin: ${o}; `:``,s?`stroke-miterlimit: ${s}; `:``,d,t?`fill-rule: ${t}; `:``,c?`opacity: ${c};`:``,u,l].map(e=>U(e)).join(``)}getSvgFilter(){return this.shadow?`filter: url(#SVGID_${U(this.shadow.id)});`:``}getSvgCommons(){return[this.id?`id="${U(String(this.id))}" `:``,this.clipPath?`clip-path="url(#${U(this.clipPath.clipPathId)})" `:``].join(``)}getSvgTransform(e,t=``){return`${`transform="${rt(e?this.calcTransformMatrix():this.calcOwnMatrix())}`}${t}" `}_toSVG(e){return[``]}toSVG(e){return this._createBaseSVGMarkup(this._toSVG(e),{reviver:e})}toClipPathSVG(e){return` `+this._createBaseClipPathSVGMarkup(this._toSVG(e),{reviver:e})}_createBaseClipPathSVGMarkup(e,{reviver:t,additionalTransform:n=``}={}){let r=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(``),i=e.indexOf(`COMMON_PARTS`);return e[i]=r,t?t(e.join(``)):e.join(``)}_createBaseSVGMarkup(e,{noStyle:t,reviver:n,withShadow:r,additionalTransform:i}={}){let a=t?``:`style="${this.getSvgStyles()}" `,o=r?`style="${this.getSvgFilter()}" `:``,s=this.clipPath,c=this.strokeUniform?`vector-effect="non-scaling-stroke" `:``,l=s&&s.absolutePositioned,u=this.stroke,d=this.fill,f=this.shadow,p=[],m=e.indexOf(`COMMON_PARTS`),h;return s&&(s.clipPathId=`CLIPPATH_${je()}`,h=`<clipPath id="${s.clipPathId}" >\n${s.toClipPathSVG(n)}</clipPath>\n`),l&&p.push(`<g `,o,this.getSvgCommons(),` >
11
+ `),p.push(`<g `,this.getSvgTransform(!1),l?``:o+this.getSvgCommons(),` >
12
+ `),e[m]=[a,c,t?``:this.addPaintOrder(),` `,i?`transform="${i}" `:``].join(``),H(d)&&p.push(d.toSVG(this)),H(u)&&p.push(u.toSVG(this)),f&&p.push(f.toSVG(this)),s&&p.push(h),p.push(e.join(``)),p.push(`</g>
13
+ `),l&&p.push(`</g>
14
+ `),n?n(p.join(``)):p.join(``)}addPaintOrder(){return this.paintFirst===`fill`?``:` paint-order="${U(this.paintFirst)}" `}};function jn(e){return RegExp(`^(`+e.join(`|`)+`)\\b`,`i`)}let Mn=`textDecorationThickness`,Nn=`textDecorationColor`,Pn=[`fontSize`,`fontWeight`,`fontFamily`,`fontStyle`],Fn=[`underline`,`overline`,`linethrough`],In=[...Pn,`lineHeight`,`text`,`charSpacing`,`textAlign`,`styles`,`path`,`pathStartOffset`,`pathSide`,`pathAlign`],Ln=[...In,...Fn,`textBackgroundColor`,`direction`,Mn,Nn],Rn=[...Pn,...Fn,ge,`strokeWidth`,j,`deltaY`,`textBackgroundColor`,Mn,Nn],zn={_reNewline:re,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:ve,fontFamily:`Times New Roman`,underline:!1,overline:!1,linethrough:!1,textAlign:O,fontStyle:ve,lineHeight:1.16,textBackgroundColor:``,stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:O,pathAlign:`baseline`,charSpacing:0,deltaY:0,direction:`ltr`,CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.28167,overline:-.81333},_fontSizeMult:1.13,[Mn]:66.667},Bn=`justify`,Vn=String.raw`[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?`,Hn=String.raw`(?:\s*,?\s+|\s*,\s*)`,Un=`http://www.w3.org/2000/svg`,Wn=RegExp(`(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*(`+Vn+`(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|`+Vn+`))?\\s+(.*)`),Gn=[`path`,`circle`,`polygon`,`polyline`,`ellipse`,`rect`,`line`,`image`,`text`],Kn=[`symbol`,`image`,`marker`,`pattern`,`view`,`svg`],qn=[`pattern`,`defs`,`symbol`,`metadata`,`clipPath`,`mask`,`desc`],Jn=[`symbol`,`g`,`a`,`svg`,`clipPath`,`defs`],Yn={cx:O,x:O,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`,"text-decoration-thickness":Mn,"text-decoration-color":Nn},Xn=`font-size`,Zn=`clip-path`,Qn=jn(Gn),$n=jn(Kn),er=jn(Jn),tr=new RegExp(String.raw`^\s*(${Vn})${Hn}(${Vn})${Hn}(${Vn})${Hn}(${Vn})\s*$`),nr=RegExp(`(?:\\s|^)(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?(`+Vn+`?(?:px)?)?(?:\\s?|$)(?:$|\\s)`),rr={color:`rgb(0,0,0)`,blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1};var ir=class e{constructor(t={}){let n=typeof t==`string`?e.parseShadow(t):t;Object.assign(this,e.ownDefaults,n),this.id=je()}static parseShadow(e){let t=e.trim(),[,n=0,r=0,i=0]=(nr.exec(t)||[]).map(e=>parseFloat(e)||0);return{color:(t.replace(nr,``)||`rgb(0,0,0)`).trim(),offsetX:n,offsetY:r,blur:i}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join(`px `)}toSVG(e){let t=Gt(new P(this.offsetX,this.offsetY),L(-e.angle)),n=c.NUM_FRACTION_DIGITS,r=new G(this.color),i=40,a=40;return e.width&&e.height&&(i=V((Math.abs(t.x)+this.blur)/e.width,n)*100+20,a=V((Math.abs(t.y)+this.blur)/e.height,n)*100+20),e.flipX&&(t.x*=-1),e.flipY&&(t.y*=-1),`<filter id="SVGID_${U(this.id)}" y="-${a}%" height="${100+2*a}%" x="-${i}%" width="${100+2*i}%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="${V(this.blur?this.blur/2:0,n)}"></feGaussianBlur>\n\t<feOffset dx="${V(t.x,n)}" dy="${V(t.y,n)}" result="oBlur" ></feOffset>\n\t<feFlood flood-color="${r.toRgb()}" flood-opacity="${r.getAlpha()}"/>\n\t<feComposite in2="oBlur" operator="in" />\n\t<feMerge>\n\t\t<feMergeNode></feMergeNode>\n\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n\t</feMerge>\n</filter>\n`}toObject(){let t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},n=e.ownDefaults;return this.includeDefaultValues?t:nt(t,(e,t)=>e!==n[t])}static async fromObject(e){return new this(e)}};o(ir,`ownDefaults`,rr),o(ir,`type`,`shadow`),M.setClass(ir,`shadow`);let ar=(e,t,n)=>Math.max(e,Math.min(t,n)),or=[`top`,O,fe,pe,`flipX`,`flipY`,`originX`,`originY`,`angle`,`opacity`,`globalCompositeOperation`,`shadow`,`visible`,me,he],sr=[j,ge,`strokeWidth`,`strokeDashArray`,`width`,`height`,`paintFirst`,`strokeUniform`,`strokeLineCap`,`strokeDashOffset`,`strokeLineJoin`,`strokeMiterLimit`,`backgroundColor`,`clipPath`],cr={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:D,originY:D,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:j,fill:`rgb(0,0,0)`,fillRule:`nonzero`,stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:`butt`,strokeLineJoin:`miter`,strokeMiterLimit:4,globalCompositeOperation:`source-over`,backgroundColor:``,shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},lr={noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:`rgb(178,204,255)`,cornerStrokeColor:``,cornerStyle:`rect`,cornerDashArray:null,hasControls:!0,borderColor:`rgb(178,204,255)`,borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:``,selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:`down`,hoverCursor:null,moveCursor:null};var ur=n({defaultEasing:()=>pr,easeInBack:()=>Fr,easeInBounce:()=>zr,easeInCirc:()=>kr,easeInCubic:()=>mr,easeInElastic:()=>Mr,easeInExpo:()=>Er,easeInOutBack:()=>Lr,easeInOutBounce:()=>Br,easeInOutCirc:()=>jr,easeInOutCubic:()=>gr,easeInOutElastic:()=>Pr,easeInOutExpo:()=>Or,easeInOutQuad:()=>Ur,easeInOutQuart:()=>yr,easeInOutQuint:()=>Sr,easeInOutSine:()=>Tr,easeInQuad:()=>Vr,easeInQuart:()=>_r,easeInQuint:()=>br,easeInSine:()=>Cr,easeOutBack:()=>Ir,easeOutBounce:()=>Rr,easeOutCirc:()=>Ar,easeOutCubic:()=>hr,easeOutElastic:()=>Nr,easeOutExpo:()=>Dr,easeOutQuad:()=>Hr,easeOutQuart:()=>vr,easeOutQuint:()=>xr,easeOutSine:()=>wr});let dr=(e,t,n,r)=>(e<Math.abs(t)?(e=t,r=n/4):r=t===0&&e===0?n/T*Math.asin(1):n/T*Math.asin(t/e),{a:e,c:t,p:n,s:r}),fr=(e,t,n,r,i)=>e*2**(10*--r)*Math.sin((r*i-t)*T/n),pr=(e,t,n,r)=>-n*Math.cos(e/r*C)+n+t,mr=(e,t,n,r)=>n*(e/r)**3+t,hr=(e,t,n,r)=>n*((e/r-1)**3+1)+t,gr=(e,t,n,r)=>(e/=r/2,e<1?n/2*e**3+t:n/2*((e-2)**3+2)+t),_r=(e,t,n,r)=>n*(e/=r)*e**3+t,vr=(e,t,n,r)=>-n*((e=e/r-1)*e**3-1)+t,yr=(e,t,n,r)=>(e/=r/2,e<1?n/2*e**4+t:-n/2*((e-=2)*e**3-2)+t),br=(e,t,n,r)=>n*(e/r)**5+t,xr=(e,t,n,r)=>n*((e/r-1)**5+1)+t,Sr=(e,t,n,r)=>(e/=r/2,e<1?n/2*e**5+t:n/2*((e-2)**5+2)+t),Cr=(e,t,n,r)=>-n*Math.cos(e/r*C)+n+t,wr=(e,t,n,r)=>n*Math.sin(e/r*C)+t,Tr=(e,t,n,r)=>-n/2*(Math.cos(Math.PI*e/r)-1)+t,Er=(e,t,n,r)=>e===0?t:n*2**(10*(e/r-1))+t,Dr=(e,t,n,r)=>e===r?t+n:n*-(2**(-10*e/r)+1)+t,Or=(e,t,n,r)=>e===0?t:e===r?t+n:(e/=r/2,e<1?n/2*2**(10*(e-1))+t:n/2*-(2**(-10*(e-1))+2)+t),kr=(e,t,n,r)=>-n*(Math.sqrt(1-(e/=r)*e)-1)+t,Ar=(e,t,n,r)=>n*Math.sqrt(1-(e=e/r-1)*e)+t,jr=(e,t,n,r)=>(e/=r/2,e<1?-n/2*(Math.sqrt(1-e**2)-1)+t:n/2*(Math.sqrt(1-(e-=2)*e)+1)+t),Mr=(e,t,n,r)=>{let i=n,a=0;if(e===0)return t;if(e/=r,e===1)return t+n;a||(a=r*.3);let{a:o,s,p:c}=dr(i,n,a,1.70158);return-fr(o,s,c,e,r)+t},Nr=(e,t,n,r)=>{let i=n,a=0;if(e===0)return t;if(e/=r,e===1)return t+n;a||(a=r*.3);let{a:o,s,p:c,c:l}=dr(i,n,a,1.70158);return o*2**(-10*e)*Math.sin((e*r-s)*T/c)+l+t},Pr=(e,t,n,r)=>{let i=n,a=0;if(e===0)return t;if(e/=r/2,e===2)return t+n;a||(a=.3*1.5*r);let{a:o,s,p:c,c:l}=dr(i,n,a,1.70158);return e<1?-.5*fr(o,s,c,e,r)+t:o*2**(-10*--e)*Math.sin((e*r-s)*T/c)*.5+l+t},Fr=(e,t,n,r,i=1.70158)=>n*(e/=r)*e*((i+1)*e-i)+t,Ir=(e,t,n,r,i=1.70158)=>n*((e=e/r-1)*e*((i+1)*e+i)+1)+t,Lr=(e,t,n,r,i=1.70158)=>(e/=r/2,e<1?n/2*(e*e*(((i*=1.525)+1)*e-i))+t:n/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+t),Rr=(e,t,n,r)=>(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t,zr=(e,t,n,r)=>n-Rr(r-e,0,n,r)+t,Br=(e,t,n,r)=>e<r/2?zr(e*2,0,n,r)*.5+t:Rr(e*2-r,0,n,r)*.5+n*.5+t,Vr=(e,t,n,r)=>n*(e/=r)*e+t,Hr=(e,t,n,r)=>-n*(e/=r)*(e-2)+t,Ur=(e,t,n,r)=>(e/=r/2,e<1?n/2*e**2+t:-n/2*(--e*(e-2)-1)+t),Wr=()=>!1;var Gr=class{constructor({startValue:e,byValue:t,duration:n=500,delay:r=0,easing:i=pr,onStart:a=S,onChange:s=S,onComplete:c=S,abort:l=Wr,target:u}){o(this,`_state`,`pending`),o(this,`durationProgress`,0),o(this,`valueProgress`,0),this.tick=this.tick.bind(this),this.duration=n,this.delay=r,this.easing=i,this._onStart=a,this._onChange=s,this._onComplete=c,this._abort=l,this.target=u,this.startValue=e,this.byValue=t,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state===`aborted`||this._state===`completed`}start(){let e=e=>{this._state===`pending`&&(this.startTime=e||+new Date,this._state=`running`,this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?this.timeout=v().setTimeout(()=>Oe(e),this.delay):Oe(e)}tick(e){let t=(e||+new Date)-this.startTime,n=Math.min(t,this.duration);this.durationProgress=n/this.duration;let{value:r,valueProgress:i}=this.calculate(n);this.value=Object.freeze(r),this.valueProgress=i,this._state!==`aborted`&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state=`aborted`,this.unregister()):t>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state=`completed`,this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister(),this.timeout=null):(this._onChange(this.value,this.valueProgress,this.durationProgress),Oe(this.tick)))}register(){be.push(this)}unregister(){be.remove(this)}abort(){this._state=`aborted`,this.unregister(),this.timeout&&v().clearTimeout(this.timeout)}},Kr=class extends Gr{constructor({startValue:e=0,endValue:t=100,...n}){super({...n,startValue:e,byValue:t-e})}calculate(e){let t=this.easing(e,this.startValue,this.byValue,this.duration);return{value:t,valueProgress:Math.abs((t-this.startValue)/this.byValue)}}},qr=class extends Gr{constructor({startValue:e=[0],endValue:t=[100],...n}){super({...n,startValue:e,byValue:t.map((t,n)=>t-e[n])})}calculate(e){let t=this.startValue.map((t,n)=>this.easing(e,t,this.byValue[n],this.duration,n));return{value:t,valueProgress:Math.abs((t[0]-this.startValue[0])/this.byValue[0])}}};let Jr=(e,t,n,r)=>t+n*(1-Math.cos(e/r*C)),Yr=e=>e&&((t,n,r)=>e(new G(t).toRgba(),n,r));var Xr=class extends Gr{constructor({startValue:e,endValue:t,easing:n=Jr,onChange:r,onComplete:i,abort:a,...o}){let s=new G(e).getSource(),c=new G(t).getSource();super({...o,startValue:s,byValue:c.map((e,t)=>e-s[t]),easing:n,onChange:Yr(r),onComplete:Yr(i),abort:Yr(a)})}calculate(e){let[t,n,r,i]=this.startValue.map((t,n)=>this.easing(e,t,this.byValue[n],this.duration,n)),a=[...[t,n,r].map(Math.round),ar(0,i,1)];return{value:a,valueProgress:a.map((e,t)=>this.byValue[t]===0?0:Math.abs((e-this.startValue[t])/this.byValue[t])).find(e=>e!==0)||0}}};let Zr=e=>Array.isArray(e.startValue)||Array.isArray(e.endValue);function Qr(e){let t=Zr(e)?new qr(e):new Kr(e);return t.start(),t}function $r(e){let t=new Xr(e);return t.start(),t}var ei=class e{constructor(e){this.status=e,this.points=[]}includes(e){return this.points.some(t=>t.eq(e))}append(...e){return this.points=this.points.concat(e.filter(e=>!this.includes(e))),this}static isPointContained(e,t,n,r=!1){if(t.eq(n))return e.eq(t);if(t.x===n.x)return e.x===t.x&&(r||e.y>=Math.min(t.y,n.y)&&e.y<=Math.max(t.y,n.y));if(t.y===n.y)return e.y===t.y&&(r||e.x>=Math.min(t.x,n.x)&&e.x<=Math.max(t.x,n.x));{let i=Kt(t,n),a=Kt(t,e).divide(i);return r?Math.abs(a.x)===Math.abs(a.y):a.x===a.y&&a.x>=0&&a.x<=1}}static isPointInPolygon(e,t){let n=new P(e).setX(Math.min(e.x-1,...t.map(e=>e.x))),r=0;for(let i=0;i<t.length;i++){let a=this.intersectSegmentSegment(t[i],t[(i+1)%t.length],e,n);if(a.includes(e))return!0;r+=Number(a.status===`Intersection`)}return r%2==1}static intersectLineLine(t,n,r,i,a=!0,o=!0){let s=n.x-t.x,c=n.y-t.y,l=i.x-r.x,u=i.y-r.y,d=t.x-r.x,f=t.y-r.y,p=l*f-u*d,m=s*f-c*d,h=u*s-l*c;if(h===0)return p===0||m===0?new e(a||o||e.isPointContained(t,r,i)||e.isPointContained(n,r,i)||e.isPointContained(r,t,n)||e.isPointContained(i,t,n)?`Coincident`:void 0):new e(`Parallel`);{let n=p/h,r=m/h;return(a||0<=n&&n<=1)&&(o||0<=r&&r<=1)?new e(`Intersection`).append(new P(t.x+n*s,t.y+n*c)):new e}}static intersectSegmentLine(t,n,r,i){return e.intersectLineLine(t,n,r,i,!1,!0)}static intersectSegmentSegment(t,n,r,i){return e.intersectLineLine(t,n,r,i,!1,!1)}static intersectLinePolygon(t,n,r,i=!0){let a=new e,o=r.length;for(let s=0,c,l,u;s<o;s++){if(c=r[s],l=r[(s+1)%o],u=e.intersectLineLine(t,n,c,l,i,!1),u.status===`Coincident`)return u;a.append(...u.points)}return a.points.length>0&&(a.status=`Intersection`),a}static intersectSegmentPolygon(t,n,r){return e.intersectLinePolygon(t,n,r,!1)}static intersectPolygonPolygon(t,n){let r=new e,i=t.length,a=[];for(let o=0;o<i;o++){let s=t[o],c=t[(o+1)%i],l=e.intersectSegmentPolygon(s,c,n);l.status===`Coincident`?(a.push(l),r.append(s,c)):r.append(...l.points)}return a.length>0&&a.length===t.length?new e(`Coincident`):(r.points.length>0&&(r.status=`Intersection`),r)}static intersectPolygonRectangle(t,n,r){let i=n.min(r),a=n.max(r),o=new P(a.x,i.y),s=new P(i.x,a.y);return e.intersectPolygonPolygon(t,[i,o,a,s])}},ti=class extends De{getX(){return this.getXY().x}setX(e){this.setXY(this.getXY().setX(e))}getY(){return this.getXY().y}setY(e){this.setXY(this.getXY().setY(e))}getRelativeX(){return this.left}setRelativeX(e){this.left=e}getRelativeY(){return this.top}setRelativeY(e){this.top=e}getXY(){let e=this.getRelativeXY();return this.group?R(e,this.group.calcTransformMatrix()):e}setXY(e,t,n){this.group&&(e=R(e,z(this.group.calcTransformMatrix()))),this.setRelativeXY(e,t,n)}getRelativeXY(){return new P(this.left,this.top)}setRelativeXY(e,t=this.originX,n=this.originY){this.setPositionByOrigin(e,t,n)}isStrokeAccountedForInDimensions(){return!1}getCoords(){let{tl:e,tr:t,br:n,bl:r}=this.aCoords||(this.aCoords=this.calcACoords()),i=[e,t,n,r];if(this.group){let e=this.group.calcTransformMatrix();return i.map(t=>R(t,e))}return i}intersectsWithRect(e,t){return ei.intersectPolygonRectangle(this.getCoords(),e,t).status===`Intersection`}intersectsWithObject(e){let t=ei.intersectPolygonPolygon(this.getCoords(),e.getCoords());return t.status===`Intersection`||t.status===`Coincident`||e.isContainedWithinObject(this)||this.isContainedWithinObject(e)}isContainedWithinObject(e){return this.getCoords().every(t=>e.containsPoint(t))}isContainedWithinRect(e,t){let{left:n,top:r,width:i,height:a}=this.getBoundingRect();return n>=e.x&&n+i<=t.x&&r>=e.y&&r+a<=t.y}isOverlapping(e){return this.intersectsWithObject(e)||this.isContainedWithinObject(e)||e.isContainedWithinObject(this)}containsPoint(e){return ei.isPointInPolygon(e,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;let{tl:e,br:t}=this.canvas.vptCoords;return this.getCoords().some(n=>n.x<=t.x&&n.x>=e.x&&n.y<=t.y&&n.y>=e.y)||this.intersectsWithRect(e,t)?!0:this.containsPoint(e.midPointFrom(t))}isPartiallyOnScreen(){if(!this.canvas)return!1;let{tl:e,br:t}=this.canvas.vptCoords;return this.intersectsWithRect(e,t)?!0:this.getCoords().every(n=>(n.x>=t.x||n.x<=e.x)&&(n.y>=t.y||n.y<=e.y))&&this.containsPoint(e.midPointFrom(t))}getBoundingRect(){return jt(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(e){this._set(fe,e),this._set(pe,e),this.setCoords()}scaleToWidth(e){let t=this.getBoundingRect().width/this.getScaledWidth();return this.scale(e/this.width/t)}scaleToHeight(e){let t=this.getBoundingRect().height/this.getScaledHeight();return this.scale(e/this.height/t)}getCanvasRetinaScaling(){var e;return((e=this.canvas)==null?void 0:e.getRetinaScaling())||1}getTotalAngle(){return this.group?Le(Be(this.calcTransformMatrix())):this.angle}getViewportTransform(){var e;return((e=this.canvas)==null?void 0:e.viewportTransform)||E.concat()}calcACoords(){let e=Ge({angle:this.angle}),{x:t,y:n}=this.getRelativeCenterPoint(),r=B(We(t,n),e),i=this._getTransformedDimensions(),a=i.x/2,o=i.y/2;return{tl:R({x:-a,y:-o},r),tr:R({x:a,y:-o},r),bl:R({x:-a,y:o},r),br:R({x:a,y:o},r)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(e=!1){let t=[];return!e&&this.group&&(t=this.group.transformMatrixKey(e)),t.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,W(this.originX),W(this.originY)),t}calcTransformMatrix(e=!1){let t=this.calcOwnMatrix();if(e||!this.group)return t;let n=this.transformMatrixKey(e),r=this.matrixCache;return r&&r.key.every((e,t)=>e===n[t])?r.value:(this.group&&(t=B(this.group.calcTransformMatrix(!1),t)),this.matrixCache={key:n,value:t},t)}calcOwnMatrix(){let e=this.transformMatrixKey(!0),t=this.ownMatrixCache;if(t&&t.key.every((t,n)=>t===e[n]))return t.value;let n=this.getRelativeCenterPoint(),r=Ze({angle:this.angle,translateX:n.x,translateY:n.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY});return this.ownMatrixCache={key:e,value:r},r}_getNonTransformedDimensions(){return new P(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(e){var t;let n=(t=this.canvas)==null?void 0:t.viewportTransform,r=this._getTransformedDimensions(e);return n?r.multiply(new P(Ve(n),He(n))).scalarAdd(2*this.padding):r.scalarAdd(2*this.padding)}_getTransformedDimensions(e={}){let t={scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth,...e},n=t.strokeWidth,r=n,i=0;this.strokeUniform&&(r=0,i=n);let a=t.width+r,o=t.height+r,s=t.skewX===0&&t.skewY===0,c;return c=s?new P(a*t.scaleX,o*t.scaleY):Lt(a,o,Xe(t)),c.scalarAdd(i)}translateToGivenOrigin(e,t,n,r,i){let a=e.x,o=e.y,s=W(r)-W(t),c=W(i)-W(n);if(s||c){let e=this._getTransformedDimensions();a+=s*e.x,o+=c*e.y}return new P(a,o)}translateToCenterPoint(e,t,n){if(t===`center`&&n===`center`)return e;let r=this.translateToGivenOrigin(e,t,n,D,D);return this.angle?r.rotate(L(this.angle),e):r}translateToOriginPoint(e,t,n){let r=this.translateToGivenOrigin(e,D,D,t,n);return this.angle?r.rotate(L(this.angle),e):r}getCenterPoint(){let e=this.getRelativeCenterPoint();return this.group?R(e,this.group.calcTransformMatrix()):e}getRelativeCenterPoint(){return this.translateToCenterPoint(new P(this.left,this.top),this.originX,this.originY)}getPointByOrigin(e,t){return this.getPositionByOrigin(e,t)}getPositionByOrigin(e,t){return this.translateToOriginPoint(this.getRelativeCenterPoint(),e,t)}setPositionByOrigin(e,t,n){let r=this.translateToCenterPoint(e,t,n),i=this.translateToOriginPoint(r,this.originX,this.originY);this.set({left:i.x,top:i.y})}_getLeftTopCoords(){return this.getPositionByOrigin(O,`top`)}positionByLeftTop(e){return this.setPositionByOrigin(e,O,`top`)}},ni=class e extends ti{static getDefaults(){return e.ownDefaults}get type(){let e=this.constructor.type;return e===`FabricObject`?`object`:e.toLowerCase()}set type(e){l(`warn`,`Setting type has no effect`,e)}constructor(t){super(),o(this,`_cacheContext`,null),Object.assign(this,e.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=F(),this._cacheContext=this._cacheCanvas.getContext(`2d`),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(e){let t=e.width,n=e.height,r=c.maxCacheSideLimit,i=c.minCacheSideLimit;if(t<=r&&n<=r&&t*n<=c.perfLimitSizeTotal)return t<i&&(e.width=i),n<i&&(e.height=i),e;let a=t/n,[o,s]=b.limitDimsByArea(a),l=ar(i,o,r),u=ar(i,s,r);return t>l&&(e.zoomX/=t/l,e.width=l,e.capped=!0),n>u&&(e.zoomY/=n/u,e.height=u,e.capped=!0),e}_getCacheCanvasDimensions(){let e=this.getTotalObjectScaling(),t=this._getTransformedDimensions({skewX:0,skewY:0}),n=t.x*e.x/this.scaleX,r=t.y*e.y/this.scaleY;return{width:Math.ceil(n+2),height:Math.ceil(r+2),zoomX:e.x,zoomY:e.y,x:n,y:r}}_updateCacheCanvas(){let e=this._cacheCanvas,t=this._cacheContext,{width:n,height:r,zoomX:i,zoomY:a,x:o,y:s}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=n!==e.width||r!==e.height,l=this.zoomX!==i||this.zoomY!==a;if(!e||!t)return!1;if(c||l){n!==e.width||r!==e.height?(e.width=n,e.height=r):(t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.width,e.height));let c=o/2,l=s/2;return this.cacheTranslationX=Math.round(e.width/2-c)+c,this.cacheTranslationY=Math.round(e.height/2-l)+l,t.translate(this.cacheTranslationX,this.cacheTranslationY),t.scale(i,a),this.zoomX=i,this.zoomY=a,!0}return!1}setOptions(e={}){this._setOptions(e)}transform(e){let t=this.group&&!this.group._transformDone||this.group&&this.canvas&&e===this.canvas.contextTop,n=this.calcTransformMatrix(!t);e.transform(n[0],n[1],n[2],n[3],n[4],n[5])}getObjectScaling(){if(!this.group)return new P(Math.abs(this.scaleX),Math.abs(this.scaleY));let e=Ue(this.calcTransformMatrix());return new P(Math.abs(e.scaleX),Math.abs(e.scaleY))}getTotalObjectScaling(){let e=this.getObjectScaling();if(this.canvas){let t=this.canvas.getZoom(),n=this.getCanvasRetinaScaling();return e.scalarMultiply(t*n)}return e}getObjectOpacity(){let e=this.opacity;return this.group&&(e*=this.group.getObjectOpacity()),e}_constrainScale(e){return Math.abs(e)<this.minScaleLimit?e<0?-this.minScaleLimit:this.minScaleLimit:e===0?1e-4:e}_set(e,t){(e===`scaleX`||e===`scaleY`)&&(t=this._constrainScale(t)),e===`scaleX`&&t<0?(this.flipX=!this.flipX,t*=-1):e===`scaleY`&&t<0?(this.flipY=!this.flipY,t*=-1):e===`shadow`&&t&&!(t instanceof ir)&&(t=new ir(t));let n=this[e]!==t;return this[e]=t,n&&this.constructor.cacheProperties.includes(e)&&(this.dirty=!0),this.parent&&(this.dirty||n&&this.constructor.stateProperties.includes(e))&&this.parent._set(`dirty`,!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(e){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(e.save(),this._setupCompositeOperation(e),this.drawSelectionBackground(e),this.transform(e),this._setOpacity(e),this._setShadow(e),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(e)):(this._removeCacheCanvas(),this.drawObject(e,!1,{}),this.dirty=!1),e.restore())}drawSelectionBackground(e){}renderCache(e){if(e=e||{},(!this._cacheCanvas||!this._cacheContext)&&this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){let{zoomX:t,zoomY:n,cacheTranslationX:r,cacheTranslationY:i}=this,{width:a,height:o}=this._cacheCanvas;this.drawObject(this._cacheContext,e.forClipping,{zoomX:t,zoomY:n,cacheTranslationX:r,cacheTranslationY:i,width:a,height:o,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return!!this.stroke&&this.stroke!==`transparent`&&this.strokeWidth!==0}hasFill(){return!!this.fill&&this.fill!==`transparent`}needsItsOwnCache(){return!!(this.paintFirst===`stroke`&&this.hasFill()&&this.hasStroke()&&this.shadow||this.clipPath)}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(e,t,n){e.save(),t.inverted?e.globalCompositeOperation=`destination-out`:e.globalCompositeOperation=`destination-in`,e.setTransform(1,0,0,1,0,0),e.drawImage(n,0,0),e.restore()}drawObject(e,t,n){let r=this.fill,i=this.stroke;t?(this.fill=`black`,this.stroke=``,this._setClippingProperties(e)):this._renderBackground(e),this.fire(`before:render`,{ctx:e}),this._render(e),this._drawClipPath(e,this.clipPath,n),this.fill=r,this.stroke=i}createClipPathLayer(e,t){let n=I(t),r=n.getContext(`2d`);if(r.translate(t.cacheTranslationX,t.cacheTranslationY),r.scale(t.zoomX,t.zoomY),e._cacheCanvas=n,t.parentClipPaths.forEach(e=>{e.transform(r)}),t.parentClipPaths.push(e),e.absolutePositioned){let e=z(this.calcTransformMatrix());r.transform(e[0],e[1],e[2],e[3],e[4],e[5])}return e.transform(r),e.drawObject(r,!0,t),n}_drawClipPath(e,t,n){if(!t)return;t._transformDone=!0;let r=this.createClipPathLayer(t,n);this.drawClipPathOnCache(e,t,r)}drawCacheOnCanvas(e){e.scale(1/this.zoomX,1/this.zoomY),e.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(e=!1){if(this.isNotVisible())return!1;let t=this._cacheCanvas,n=this._cacheContext;return t&&n&&!e&&this._updateCacheCanvas()?!0:this.dirty||this.clipPath&&this.clipPath.absolutePositioned?(t&&n&&!e&&(n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,t.width,t.height),n.restore()),!0):!1}_renderBackground(e){if(!this.backgroundColor)return;let t=this._getNonTransformedDimensions();e.fillStyle=this.backgroundColor,e.fillRect(-t.x/2,-t.y/2,t.x,t.y),this._removeShadow(e)}_setOpacity(e){this.group&&!this.group._transformDone?e.globalAlpha=this.getObjectOpacity():e.globalAlpha*=this.opacity}_setStrokeStyles(e,t){let n=t.stroke;n&&(e.lineWidth=t.strokeWidth,e.lineCap=t.strokeLineCap,e.lineDashOffset=t.strokeDashOffset,e.lineJoin=t.strokeLineJoin,e.miterLimit=t.strokeMiterLimit,H(n)?n.gradientUnits===`percentage`||n.gradientTransform||n.patternTransform?this._applyPatternForTransformedGradient(e,n):(e.strokeStyle=n.toLive(e),this._applyPatternGradientTransform(e,n)):e.strokeStyle=t.stroke)}_setFillStyles(e,{fill:t}){t&&(H(t)?(e.fillStyle=t.toLive(e),this._applyPatternGradientTransform(e,t)):e.fillStyle=t)}_setClippingProperties(e){e.globalAlpha=1,e.strokeStyle=`transparent`,e.fillStyle=`#000000`}_setLineDash(e,t){!t||t.length===0||e.setLineDash(t)}_setShadow(e){if(!this.shadow)return;let t=this.shadow,n=this.canvas,r=this.getCanvasRetinaScaling(),[i,,,a]=(n==null?void 0:n.viewportTransform)||E,o=i*r,s=a*r,l=t.nonScaling?new P(1,1):this.getObjectScaling();e.shadowColor=t.color,e.shadowBlur=t.blur*c.browserShadowBlurConstant*(o+s)*(l.x+l.y)/4,e.shadowOffsetX=t.offsetX*o*l.x,e.shadowOffsetY=t.offsetY*s*l.y}_removeShadow(e){this.shadow&&(e.shadowColor=``,e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0)}_applyPatternGradientTransform(e,t){if(!H(t))return{offsetX:0,offsetY:0};let n=t.gradientTransform||t.patternTransform,r=-this.width/2+t.offsetX||0,i=-this.height/2+t.offsetY||0;return t.gradientUnits===`percentage`?e.transform(this.width,0,0,this.height,r,i):e.transform(1,0,0,1,r,i),n&&e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),{offsetX:r,offsetY:i}}_renderPaintInOrder(e){this.paintFirst===`stroke`?(this._renderStroke(e),this._renderFill(e)):(this._renderFill(e),this._renderStroke(e))}_render(e){}_renderFill(e){this.fill&&(e.save(),this._setFillStyles(e,this),this.fillRule===`evenodd`?e.fill(`evenodd`):e.fill(),e.restore())}_renderStroke(e){if(!(!this.stroke||this.strokeWidth===0)){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(e),e.save(),this.strokeUniform){let t=this.getObjectScaling();e.scale(1/t.x,1/t.y)}this._setLineDash(e,this.strokeDashArray),this._setStrokeStyles(e,this),e.stroke(),e.restore()}}_applyPatternForTransformedGradient(e,t){var n;let r=this._limitCacheSize(this._getCacheCanvasDimensions()),i=this.getCanvasRetinaScaling(),a=r.x/this.scaleX/i,o=r.y/this.scaleY/i,s=I({width:Math.ceil(a),height:Math.ceil(o)}),c=s.getContext(`2d`);c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(a,0),c.lineTo(a,o),c.lineTo(0,o),c.closePath(),c.translate(a/2,o/2),c.scale(r.zoomX/this.scaleX/i,r.zoomY/this.scaleY/i),this._applyPatternGradientTransform(c,t),c.fillStyle=t.toLive(e),c.fill(),e.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),e.scale(i*this.scaleX/r.zoomX,i*this.scaleY/r.zoomY),e.strokeStyle=(n=c.createPattern(s,`no-repeat`))==null?``:n)}_findCenterFromElement(){return new P(this.left+this.width/2,this.top+this.height/2)}clone(e){let t=this.toObject(e);return this.constructor.fromObject(t)}cloneAsImage(e){let t=this.toCanvasElement(e);return new(M.getClass(`image`))(t)}toCanvasElement(e={}){let t=It(this),n=this.group,r=this.shadow,i=Math.abs,a=e.enableRetinaScaling?y():1,o=(e.multiplier||1)*a,s=e.canvasProvider||(e=>new Tt(e,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,e.withoutTransform&&Ft(this),e.withoutShadow&&(this.shadow=null),e.viewportTransform&&Vt(this,this.getViewportTransform()),this.setCoords();let c=F(),l=this.getBoundingRect(),u=this.shadow,d=new P;if(u){let e=u.blur,t=u.nonScaling?new P(1,1):this.getObjectScaling();d.x=2*Math.round(i(u.offsetX)+e)*i(t.x),d.y=2*Math.round(i(u.offsetY)+e)*i(t.y)}let f=l.width+d.x,p=l.height+d.y;c.width=Math.ceil(f),c.height=Math.ceil(p);let m=s(c);e.format===`jpeg`&&(m.backgroundColor=`#fff`),this.setPositionByOrigin(new P(m.width/2,m.height/2),D,D);let h=this.canvas;m._objects=[this],this.set(`canvas`,m),this.setCoords();let g=m.toCanvasElement(o||1,e);return this.set(`canvas`,h),this.shadow=r,n&&(this.group=n),this.set(t),this.setCoords(),m._objects=[],m.destroy(),g}toDataURL(e={}){return Pe(this.toCanvasElement(e),e.format||`png`,e.quality||1)}toBlob(e={}){return Ie(this.toCanvasElement(e),e.format||`png`,e.quality||1)}isType(...e){return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(e){let{centeredRotation:t,originX:n,originY:r}=this;if(t){let{x:e,y:t}=this.getRelativeCenterPoint();this.originX=D,this.originY=D,this.left=e,this.top=t}if(this.set(`angle`,e),t){let{x:e,y:t}=this.getPositionByOrigin(n,r);this.left=e,this.top=t,this.originX=n,this.originY=r}}setOnGroup(){}_setupCompositeOperation(e){this.globalCompositeOperation&&(e.globalCompositeOperation=this.globalCompositeOperation)}dispose(){be.cancelByTarget(this),this.off(),this._set(`canvas`,void 0),this._cacheCanvas&&g().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(e,t){return Object.entries(e).reduce((e,[n,r])=>(e[n]=this._animate(n,r,t),e),{})}_animate(e,t,n={}){let r=e.split(`.`),i=this.constructor.colorProperties.includes(r[r.length-1]),{abort:a,startValue:o,onChange:s,onComplete:c}=n,l={...n,target:this,startValue:o==null?r.reduce((e,t)=>e[t],this):o,endValue:t,abort:a==null?void 0:a.bind(this),onChange:(e,t,n)=>{r.reduce((t,n,i)=>(i===r.length-1&&(t[n]=e),t[n]),this),s&&s(e,t,n)},onComplete:(e,t,n)=>{this.setCoords(),c&&c(e,t,n)}};return i?$r(l):Qr(l)}isDescendantOf(e){let{parent:t,group:n}=this;return t===e||n===e||!!t&&t.isDescendantOf(e)||!!n&&n!==t&&n.isDescendantOf(e)}getAncestors(){let e=[],t=this;do t=t.parent,t&&e.push(t);while(t);return e}findCommonAncestors(e){if(this===e)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};let t=this.getAncestors(),n=e.getAncestors();if(t.length===0&&n.length>0&&this===n[n.length-1])return{fork:[],otherFork:[e,...n.slice(0,n.length-1)],common:[this]};for(let r=0,i;r<t.length;r++){if(i=t[r],i===e)return{fork:[this,...t.slice(0,r)],otherFork:[],common:t.slice(r)};for(let a=0;a<n.length;a++){if(this===n[a])return{fork:[],otherFork:[e,...n.slice(0,a)],common:[this,...t]};if(i===n[a])return{fork:[this,...t.slice(0,r)],otherFork:[e,...n.slice(0,a)],common:t.slice(r)}}}return{fork:[this,...t],otherFork:[e,...n],common:[]}}hasCommonAncestors(e){let t=this.findCommonAncestors(e);return t&&!!t.common.length}isInFrontOf(e){if(this===e)return;let t=this.findCommonAncestors(e);if(t.fork.includes(e))return!0;if(t.otherFork.includes(this))return!1;let n=t.common[0]||this.canvas;if(!n)return;let r=t.fork.pop(),i=t.otherFork.pop(),a=n._objects.indexOf(r),o=n._objects.indexOf(i);return a>-1&&a>o}toObject(t=[]){let n=t.concat(e.customProperties,this.constructor.customProperties||[]),r,i=c.NUM_FRACTION_DIGITS,{clipPath:a,fill:o,stroke:s,shadow:l,strokeDashArray:u,left:d,top:f,originX:p,originY:m,width:h,height:g,strokeWidth:_,strokeLineCap:v,strokeDashOffset:y,strokeLineJoin:b,strokeUniform:S,strokeMiterLimit:C,scaleX:w,scaleY:T,angle:ee,flipX:E,flipY:D,opacity:O,visible:te,backgroundColor:k,fillRule:ne,paintFirst:re,globalCompositeOperation:ie,skewX:ae,skewY:oe}=this;a&&!a.excludeFromExport&&(r=a.toObject(n.concat(`inverted`,`absolutePositioned`)));let A=e=>V(e,i),se={...tt(this,n),type:this.constructor.type,version:x,originX:p,originY:m,left:A(d),top:A(f),width:A(h),height:A(g),fill:it(o)?o.toObject():o,stroke:it(s)?s.toObject():s,strokeWidth:A(_),strokeDashArray:u&&u.concat(),strokeLineCap:v,strokeDashOffset:y,strokeLineJoin:b,strokeUniform:S,strokeMiterLimit:A(C),scaleX:A(w),scaleY:A(T),angle:A(ee),flipX:E,flipY:D,opacity:A(O),shadow:l&&l.toObject(),visible:te,backgroundColor:k,fillRule:ne,paintFirst:re,globalCompositeOperation:ie,skewX:A(ae),skewY:A(oe),...r?{clipPath:r}:null};return this.includeDefaultValues?se:this._removeDefaultValues(se)}toDatalessObject(e){return this.toObject(e)}_removeDefaultValues(e){let t=this.constructor.getDefaults(),n=Object.keys(t).length>0?t:Object.getPrototypeOf(this);return nt(e,(e,t)=>{if(t===`left`||t===`top`||t===`type`)return!0;let r=n[t];return e!==r&&!(Array.isArray(e)&&Array.isArray(r)&&e.length===0&&r.length===0)})}toString(){return`#<${this.constructor.type}>`}static _fromObject({type:e,...t},{extraParam:n,...r}={}){return et(t,r).then(e=>n?(delete e[n],new this(t[n],e)):new this(e))}static fromObject(e,t){return this._fromObject(e,t)}};o(ni,`stateProperties`,or),o(ni,`cacheProperties`,sr),o(ni,`ownDefaults`,cr),o(ni,`type`,`FabricObject`),o(ni,`colorProperties`,[j,ge,`backgroundColor`]),o(ni,`customProperties`,[]),M.setClass(ni),M.setClass(ni,`object`);let ri=(e,t)=>{var n;let{transform:{target:r}}=t;(n=r.canvas)==null||n.fire(`object:${e}`,{...t,target:r}),r.fire(e,t)},ii=(e,t,n)=>((r,i,a,o)=>{let s=t(r,i,a,o);return s&&ri(e,{...sn(r,i,a,o),...n}),s});function ai(e){return((t,n,r,i)=>{let{target:a,originX:o,originY:s}=n,c=a.getPositionByOrigin(o,s),l=e(t,n,r,i);return a.setPositionByOrigin(c,n.originX,n.originY),l})}let oi=(e,t,n,r)=>(i,a,o,s)=>{let c=un(a,a.originX,a.originY,o,s)[n],l=W(a[t]);if(l===0||l>0&&c<0||l<0&&c>0){let{target:t}=a,n=t.strokeWidth/(t.strokeUniform?t[r]:1),i=rn(a)?2:1,o=t[e],s=Math.abs(c*i/t[r])-n;return t.set(e,Math.max(s,1)),o!==t[e]}return!1},si=oi(`width`,`originX`,`x`,`scaleX`),ci=oi(`height`,`originY`,`y`,`scaleY`),li=ii(ce,ai(si)),ui=ii(ce,ai(ci));function di(e,t,n,r,i){e.save();let{stroke:a,xSize:o,ySize:s,opName:c}=this.commonRenderProps(e,t,n,i,r),l=o;o>s?e.scale(1,s/o):s>o&&(l=s,e.scale(o/s,1)),e.beginPath(),e.arc(0,0,l/2,0,T,!1),e[c](),a&&e.stroke(),e.restore()}function fi(e,t,n,r,i){e.save();let{stroke:a,xSize:o,ySize:s,opName:c}=this.commonRenderProps(e,t,n,i,r),l=o/2,u=s/2;e[`${c}Rect`](-l,-u,o,s),a&&e.strokeRect(-l,-u,o,s),e.restore()}var q=class{constructor(e){o(this,`visible`,!0),o(this,`actionName`,de),o(this,`angle`,0),o(this,`x`,0),o(this,`y`,0),o(this,`offsetX`,0),o(this,`offsetY`,0),o(this,`sizeX`,0),o(this,`sizeY`,0),o(this,`touchSizeX`,0),o(this,`touchSizeY`,0),o(this,`cursorStyle`,`crosshair`),o(this,`withConnection`,!1),Object.assign(this,e)}getTransformAnchorPoint(){var e;return(e=this.transformAnchorPoint)==null?new P(-this.x+.5,-this.y+.5):e}shouldActivate(e,t,n,{tl:r,tr:i,br:a,bl:o}){var s;return((s=t.canvas)==null?void 0:s.getActiveObject())===t&&t.isControlVisible(e)&&ei.isPointInPolygon(n,[r,i,a,o])}getActionHandler(e,t,n){return this.actionHandler}getMouseDownHandler(e,t,n){return this.mouseDownHandler}getMouseUpHandler(e,t,n){return this.mouseUpHandler}cursorStyleHandler(e,t,n,r){return t.cursorStyle}getActionName(e,t,n){return t.actionName}getVisibility(e,t){var n,r;return(n=(r=e._controlsVisibility)==null?void 0:r[t])==null?this.visible:n}setVisibility(e,t,n){this.visible=e}positionHandler(e,t,n,r){return new P(this.x*e.x+this.offsetX,this.y*e.y+this.offsetY).transform(t)}calcCornerCoords(e,t,n,r,i,a){let o=ze([We(n,r),Ge({angle:e}),Ke((i?this.touchSizeX:this.sizeX)||t,(i?this.touchSizeY:this.sizeY)||t)]);return{tl:new P(-.5,-.5).transform(o),tr:new P(.5,-.5).transform(o),br:new P(.5,.5).transform(o),bl:new P(-.5,.5).transform(o)}}commonRenderProps(e,t,n,r,i={}){let{cornerSize:a,cornerColor:o,transparentCorners:s,cornerStrokeColor:c}=i,l=a||r.cornerSize,u=this.sizeX||l,d=this.sizeY||l,f=s===void 0?r.transparentCorners:s,p=f?ge:j,m=c||r.cornerStrokeColor,h=!f&&!!m;return e.fillStyle=o||r.cornerColor||``,e.strokeStyle=m||``,e.translate(t,n),e.rotate(L(r.getTotalAngle())),{stroke:h,xSize:u,ySize:d,transparentCorners:f,opName:p}}render(e,t,n,r,i){switch(r=r||{},r.cornerStyle||i.cornerStyle){case`circle`:di.call(this,e,t,n,r,i);break;default:fi.call(this,e,t,n,r,i)}}};let pi=(e,t,n)=>n.lockRotation?tn:t.cursorStyle,mi=ii(oe,ai((e,{target:t,ex:n,ey:r,theta:i,originX:a,originY:o},s,c)=>{let l=t.getPositionByOrigin(a,o);if(on(t,`lockRotation`))return!1;let u=Math.atan2(r-l.y,n-l.x),d=Le(Math.atan2(c-l.y,s-l.x)-u+i);if(t.snapAngle&&t.snapAngle>0){let e=t.snapAngle,n=t.snapThreshold||e,r=Math.ceil(d/e)*e,i=Math.floor(d/e)*e;Math.abs(d-i)<n?d=i:Math.abs(d-r)<n&&(d=r)}d<0&&(d=360+d),d%=360;let f=t.angle!==d;return t.angle=d,f}));function hi(e,t){let n=t.canvas,r=e[n.uniScaleKey];return n.uniformScaling&&!r||!n.uniformScaling&&r}function gi(e,t,n){let r=on(e,`lockScalingX`),i=on(e,`lockScalingY`);if(r&&i||!t&&(r||i)&&n||r&&t===`x`||i&&t===`y`)return!0;let{width:a,height:o,strokeWidth:s}=e;return a===0&&s===0&&t!==`y`||o===0&&s===0&&t!==`x`}let _i=[`e`,`se`,`s`,`sw`,`w`,`nw`,`n`,`ne`,`e`],vi=(e,t,n,r)=>{let i=hi(e,n);return gi(n,t.x!==0&&t.y===0?`x`:t.x===0&&t.y!==0?`y`:``,i)?tn:`${_i[cn(n,t,r)]}-resize`};function yi(e,t,n,r,i={}){let a=t.target,o=i.by,s=hi(e,a),c=gi(a,o,s),l,u,d,f,p,m;if(c)return!1;if(t.gestureScale)u=t.scaleX*t.gestureScale,d=t.scaleY*t.gestureScale;else{if(l=un(t,t.originX,t.originY,n,r),p=o===`y`?1:Math.sign(l.x||t.signX||1),m=o===`x`?1:Math.sign(l.y||t.signY||1),t.signX||(t.signX=p),t.signY||(t.signY=m),on(a,`lockScalingFlip`)&&(t.signX!==p||t.signY!==m))return!1;if(f=a._getTransformedDimensions(),s&&!o){let e=Math.abs(l.x)+Math.abs(l.y),{original:n}=t,r=e/(Math.abs(f.x*n.scaleX/a.scaleX)+Math.abs(f.y*n.scaleY/a.scaleY));u=n.scaleX*r,d=n.scaleY*r}else u=Math.abs(l.x*a.scaleX/f.x),d=Math.abs(l.y*a.scaleY/f.y);rn(t)&&(u*=2,d*=2),t.signX!==p&&o!==`y`&&(t.originX=an(t.originX),u*=-1,t.signX=p),t.signY!==m&&o!==`x`&&(t.originY=an(t.originY),d*=-1,t.signY=m)}let h=a.scaleX,g=a.scaleY;return o?(o===`x`&&a.set(`scaleX`,u),o===`y`&&a.set(`scaleY`,d)):(!on(a,`lockScalingX`)&&a.set(`scaleX`,u),!on(a,`lockScalingY`)&&a.set(`scaleY`,d)),h!==a.scaleX||g!==a.scaleY}let bi=(e,t,n,r)=>yi(e,t,n,r),xi=(e,t,n,r)=>yi(e,t,n,r,{by:`x`}),Si=(e,t,n,r)=>yi(e,t,n,r,{by:`y`}),Ci=ii(ae,ai(bi)),wi=ii(ae,ai(xi)),Ti=ii(ae,ai(Si)),Ei={x:{counterAxis:`y`,scale:fe,skew:me,lockSkewing:`lockSkewingX`,origin:`originX`,flip:`flipX`},y:{counterAxis:`x`,scale:pe,skew:he,lockSkewing:`lockSkewingY`,origin:`originY`,flip:`flipY`}},Di=[`ns`,`nesw`,`ew`,`nwse`],Oi=(e,t,n,r)=>t.x!==0&&on(n,`lockSkewingY`)||t.y!==0&&on(n,`lockSkewingX`)?tn:`${Di[cn(n,t,r)%4]}-resize`;function ki(e,{target:t,ex:n,ey:r,skewingSide:i,...a},o){let{skew:s}=Ei[e],c=o.subtract(new P(n,r)).divide(new P(t.scaleX,t.scaleY))[e],l=t[s],u=a[s],d=Math.tan(L(u)),f=e===`y`?t._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:t._getTransformedDimensions({scaleX:1,scaleY:1}).y,p=2*c*i/Math.max(f,1)+d,m=Le(Math.atan(p));t.set(s,m);let h=l!==t[s];if(h&&e===`y`){let{skewX:e,scaleX:n}=t,r=t._getTransformedDimensions({skewY:l}),i=t._getTransformedDimensions(),a=e===0?1:r.x/i.x;a!==1&&t.set(`scaleX`,a*n)}return h}function Ai(e,t,n,r,i){let{target:a}=n,{counterAxis:o,origin:s,lockSkewing:c,skew:l,flip:u}=Ei[e];if(on(a,c))return!1;let{origin:d,flip:f}=Ei[o],p=W(n[d])*(a[f]?-1:1),m=-Math.sign(p)*(a[u]?-1:1),h=-((a[l]===0&&un(n,`center`,`center`,r,i)[e]>0||a[l]>0?1:-1)*m)*.5+.5;return ii(se,ai((t,n,r,i)=>ki(e,n,new P(r,i))))(t,{...n,[s]:h,skewingSide:m},r,i)}let ji=(e,t,n,r)=>Ai(`x`,e,t,n,r),Mi=(e,t,n,r)=>Ai(`y`,e,t,n,r);function Ni(e,t){return e[t.canvas.altActionKey]}let Pi=(e,t,n)=>{let r=Ni(e,n);return t.x===0?r?me:pe:t.y===0?r?he:fe:``},Fi=(e,t,n,r)=>Ni(e,n)?Oi(e,t,n,r):vi(e,t,n,r),Ii=(e,t,n,r)=>Ni(e,t.target)?Mi(e,t,n,r):wi(e,t,n,r),Li=(e,t,n,r)=>Ni(e,t.target)?ji(e,t,n,r):Ti(e,t,n,r),Ri=()=>({ml:new q({x:-.5,y:0,cursorStyleHandler:Fi,actionHandler:Ii,getActionName:Pi}),mr:new q({x:.5,y:0,cursorStyleHandler:Fi,actionHandler:Ii,getActionName:Pi}),mb:new q({x:0,y:.5,cursorStyleHandler:Fi,actionHandler:Li,getActionName:Pi}),mt:new q({x:0,y:-.5,cursorStyleHandler:Fi,actionHandler:Li,getActionName:Pi}),tl:new q({x:-.5,y:-.5,cursorStyleHandler:vi,actionHandler:Ci}),tr:new q({x:.5,y:-.5,cursorStyleHandler:vi,actionHandler:Ci}),bl:new q({x:-.5,y:.5,cursorStyleHandler:vi,actionHandler:Ci}),br:new q({x:.5,y:.5,cursorStyleHandler:vi,actionHandler:Ci}),mtr:new q({x:0,y:-.5,actionHandler:mi,cursorStyleHandler:pi,offsetY:-40,withConnection:!0,actionName:A})}),zi=()=>({mr:new q({x:.5,y:0,actionHandler:li,cursorStyleHandler:Fi,actionName:ce}),ml:new q({x:-.5,y:0,actionHandler:li,cursorStyleHandler:Fi,actionName:ce})}),Bi=()=>({...Ri(),...zi()});var Vi=class e extends ni{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t){super(),Object.assign(this,this.constructor.createControls(),e.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Ri()}}_updateCacheCanvas(){let e=this.canvas;if(this.noScaleCache&&e&&e._currentTransform){let t=e._currentTransform,n=t.target,r=t.action;if(this===n&&r&&r.startsWith(`scale`))return!1}return super._updateCacheCanvas()}getActiveControl(){let e=this.__corner;return e?{key:e,control:this.controls[e],coord:this.oCoords[e]}:void 0}findControl(e,t=!1){if(!this.hasControls||!this.canvas)return;this.__corner=void 0;let n=Object.entries(this.oCoords);for(let r=n.length-1;r>=0;r--){let[i,a]=n[r],o=this.controls[i];if(o.shouldActivate(i,this,e,t?a.touchCorner:a.corner))return this.__corner=i,{key:i,control:o,coord:this.oCoords[i]}}}calcOCoords(){let e=this.getViewportTransform(),t=Ve(e),n=He(e),r=this.getCenterPoint(),i=B(B(e,B(We(r.x,r.y),Ge({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}))),[1/t,0,0,1/n,0,0]),a=this.group?Ue(this.calcTransformMatrix()):void 0;a&&(a.scaleX=Math.abs(a.scaleX),a.scaleY=Math.abs(a.scaleY));let o=this._calculateCurrentDimensions(a),s={};return this.forEachControl((e,t)=>{let n=e.positionHandler(o,i,this,e);s[t]=Object.assign(n,this._calcCornerCoords(e,n))}),s}_calcCornerCoords(e,t){let n=this.getTotalAngle();return{corner:e.calcCornerCoords(n,this.cornerSize,t.x,t.y,!1,this),touchCorner:e.calcCornerCoords(n,this.touchCornerSize,t.x,t.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(e){for(let t in this.controls)e(this.controls[t],t,this)}drawSelectionBackground(e){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;e.save();let t=this.getRelativeCenterPoint(),n=this._calculateCurrentDimensions(),r=this.getViewportTransform();e.translate(t.x,t.y),e.scale(1/r[0],1/r[3]),e.rotate(L(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-n.x/2,-n.y/2,n.x,n.y),e.restore()}strokeBorders(e,t){e.strokeRect(-t.x/2,-t.y/2,t.x,t.y)}_drawBorders(e,t,n={}){let r={hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray,...n};e.save(),e.strokeStyle=r.borderColor,this._setLineDash(e,r.borderDashArray),this.strokeBorders(e,t),r.hasControls&&this.drawControlsConnectingLines(e,t),e.restore()}_renderControls(e,t={}){let{hasBorders:n,hasControls:r}=this,i={hasBorders:n,hasControls:r,...t},a=this.getViewportTransform(),o=i.hasBorders,s=i.hasControls,c=Ue(B(a,this.calcTransformMatrix()));e.save(),e.translate(c.translateX,c.translateY),e.lineWidth=this.borderScaleFactor,this.group===this.parent&&(e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(c.angle-=180);let l=Be(a);e.rotate(this.group?L(c.angle):L(this.angle)+l),o&&this.drawBorders(e,c,t),s&&this.drawControls(e,t),e.restore()}drawBorders(e,t,n){let r;if(n&&n.forActiveSelection||this.group){let e=Lt(this.width,this.height,Xe(t)),n=this.isStrokeAccountedForInDimensions()?we:(this.strokeUniform?new P().scalarAdd(this.canvas?this.canvas.getZoom():1):new P(t.scaleX,t.scaleY)).scalarMultiply(this.strokeWidth);r=e.add(n).scalarAdd(this.borderScaleFactor).scalarAdd(this.padding*2)}else r=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(e,r,n)}drawControlsConnectingLines(e,t){let n=!1;e.beginPath(),this.forEachControl((r,i)=>{r.withConnection&&r.getVisibility(this,i)&&(n=!0,e.moveTo(r.x*t.x,r.y*t.y),e.lineTo(r.x*t.x+r.offsetX,r.y*t.y+r.offsetY))}),n&&e.stroke()}drawControls(e,t={}){e.save();let n=this.getCanvasRetinaScaling(),{cornerStrokeColor:r,cornerDashArray:i,cornerColor:a}=this,o={cornerStrokeColor:r,cornerDashArray:i,cornerColor:a,...t};e.setTransform(n,0,0,n,0,0),e.strokeStyle=e.fillStyle=o.cornerColor,this.transparentCorners||(e.strokeStyle=o.cornerStrokeColor),this._setLineDash(e,o.cornerDashArray),this.forEachControl((t,n)=>{if(t.getVisibility(this,n)){let r=this.oCoords[n];t.render(e,r.x,r.y,o,this)}}),e.restore()}isControlVisible(e){return this.controls[e]&&this.controls[e].getVisibility(this,e)}setControlVisible(e,t){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[e]=t}setControlsVisibility(e={}){Object.entries(e).forEach(([e,t])=>this.setControlVisible(e,t))}clearContextTop(e){if(!this.canvas)return;let t=this.canvas.contextTop;if(!t)return;let n=this.canvas.viewportTransform;t.save(),t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this.transform(t);let r=this.width+4,i=this.height+4;return t.clearRect(-r/2,-i/2,r,i),e||t.restore(),t}onDeselect(e){return!1}onSelect(e){return!1}shouldStartDragging(e){return!1}onDragStart(e){return!1}canDrop(e){return!1}renderDragSourceEffect(e){}renderDropTargetEffect(e){}};o(Vi,`ownDefaults`,lr);function Hi(e,t){return t.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!==`constructor`&&Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n)||Object.create(null))})}),e}var J=class extends Vi{};Hi(J,[An]),M.setClass(J),M.setClass(J,`object`);let Ui=(e,t,n,r)=>{r=Math.round(r);let i=r*2+1,{data:a}=e.getImageData(t-r,n-r,i,i);for(let e=3;e<a.length;e+=4)if(a[e]>0)return!1;return!0},Wi=(e,t)=>{for(let n=e.length-1;n>=0;n--)if(t(e[n],n,e))return n;return-1};var Gi=class{constructor(e){this.options=e,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new P(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new P(1/this.options.scaleX,1/this.options.scaleY):new P(1,1)}createSideVector(e,t){let n=Kt(e,t);return this.options.strokeUniform?n.multiply(this.scale):n}projectOrthogonally(e,t,n){return this.applySkew(e.add(this.calcOrthogonalProjection(e,t,n)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(e){let t=new P(e);return t.y+=t.x*Math.tan(L(this.options.skewY)),t.x+=t.y*Math.tan(L(this.options.skewX)),t}scaleUnitVector(e,t){return e.multiply(this.strokeUniformScalar).scalarMultiply(t)}};let Ki=new P;var qi=class e extends Gi{static getOrthogonalRotationFactor(e,t){let n=t?Jt(e,t):Yt(e);return Math.abs(n)<C?-1:1}constructor(e,t,n,r){super(r),o(this,`AB`,void 0),o(this,`AC`,void 0),o(this,`alpha`,void 0),o(this,`bisector`,void 0),this.A=new P(e),this.B=new P(t),this.C=new P(n),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=Jt(this.AB,this.AC),this.bisector=Xt(Gt(this.AB.eq(Ki)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,n,r=this.strokeProjectionMagnitude){let i=Zt(this.createSideVector(t,n)),a=e.getOrthogonalRotationFactor(i,this.bisector);return this.scaleUnitVector(i,r*a)}projectBevel(){let e=[];return(this.alpha%T===0?[this.B]:[this.B,this.C]).forEach(t=>{e.push(this.projectOrthogonally(this.A,t)),e.push(this.projectOrthogonally(this.A,t,-this.strokeProjectionMagnitude))}),e}projectMiter(){let e=[],t=Math.abs(this.alpha),n=1/Math.sin(t/2),r=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*n),i=this.options.strokeUniform?qt(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return qt(r)/this.strokeProjectionMagnitude<=i&&e.push(this.applySkew(this.A.add(r))),e.push(...this.projectBevel()),e}projectRoundNoSkew(t,n){let r=[],i=new P(e.getOrthogonalRotationFactor(this.bisector),e.getOrthogonalRotationFactor(new P(this.bisector.y,this.bisector.x)));return[new P(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new P(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach(e=>{en(e,t,n)&&r.push(this.A.add(e))}),r}projectRoundWithSkew(e,t){let n=[],{skewX:r,skewY:i,scaleX:a,scaleY:o,strokeUniform:s}=this.options,c=new P(Math.tan(L(r)),Math.tan(L(i))),l=this.strokeProjectionMagnitude,u=s?l/o/Math.sqrt(1/o**2+1/a**2*c.y**2):l/Math.sqrt(1+c.y**2),d=new P(Math.sqrt(Math.max(l**2-u**2,0)),u),f=s?l/Math.sqrt(1+c.x**2*(1/o)**2/(1/a+1/a*c.x*c.y)**2):l/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),p=new P(f,Math.sqrt(Math.max(l**2-f**2,0)));return[p,p.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(e=>this.applySkew(s?e.multiply(this.strokeUniformScalar):e)).forEach(r=>{en(r,e,t)&&n.push(this.applySkew(this.A).add(r))}),n}projectRound(){let e=[];e.push(...this.projectBevel());let t=this.alpha%T===0,n=this.applySkew(this.A),r=e[t?0:2].subtract(n),i=e[+!!t].subtract(n),a=Qt(r,t?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)))>0,o=a?r:i,s=a?i:r;return this.isSkewed()?e.push(...this.projectRoundWithSkew(o,s)):e.push(...this.projectRoundNoSkew(o,s)),e}projectPoints(){switch(this.options.strokeLineJoin){case`miter`:return this.projectMiter();case`round`:return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(e=>({originPoint:this.A,projectedPoint:e,angle:this.alpha,bisector:this.bisector}))}},Ji=class extends Gi{constructor(e,t,n){super(n),this.A=new P(e),this.T=new P(t)}calcOrthogonalProjection(e,t,n=this.strokeProjectionMagnitude){let r=this.createSideVector(e,t);return this.scaleUnitVector(Zt(r),n)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){let e=[];if(!this.isSkewed()&&this.A.eq(this.T)){let t=new P(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);e.push(this.applySkew(this.A.add(t)),this.applySkew(this.A.subtract(t)))}else e.push(...new qi(this.A,this.T,this.T,this.options).projectRound());return e}projectSquare(){let e=[];if(this.A.eq(this.T)){let t=new P(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);e.push(this.A.add(t),this.A.subtract(t))}else{let t=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),n=this.scaleUnitVector(Xt(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),r=this.A.add(n);e.push(r.add(t),r.subtract(t))}return e.map(e=>this.applySkew(e))}projectPoints(){switch(this.options.strokeLineCap){case`round`:return this.projectRound();case`square`:return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(e=>({originPoint:this.A,projectedPoint:e}))}};let Yi=(e,t,n=!1)=>{let r=[];if(e.length===0)return r;let i=e.reduce((e,t)=>(e[e.length-1].eq(t)||e.push(new P(t)),e),[new P(e[0])]);if(i.length===1)n=!0;else if(!n){let e=i[0],t=Wi(i,t=>!t.eq(e));i.splice(t+1)}return i.forEach((e,i,a)=>{let o,s;i===0?(s=a[1],o=n?e:a[a.length-1]):i===a.length-1?(o=a[i-1],s=n?e:a[0]):(o=a[i-1],s=a[i+1]),n&&a.length===1?r.push(...new Ji(e,e,t).project()):n&&(i===0||i===a.length-1)?r.push(...new Ji(e,i===0?s:o,t).project()):r.push(...new qi(e,o,s,t).project())}),r},Xi=e=>{let t={};return Object.keys(e).forEach(n=>{t[n]={},Object.keys(e[n]).forEach(r=>{t[n][r]={...e[n][r]}})}),t},Zi=(e,t,n=!1)=>e.fill!==t.fill||e.stroke!==t.stroke||e.strokeWidth!==t.strokeWidth||e.fontSize!==t.fontSize||e.fontFamily!==t.fontFamily||e.fontWeight!==t.fontWeight||e.fontStyle!==t.fontStyle||e.textDecorationThickness!==t.textDecorationThickness||e.textDecorationColor!==t.textDecorationColor||e.textBackgroundColor!==t.textBackgroundColor||e.deltaY!==t.deltaY||n&&(e.overline!==t.overline||e.underline!==t.underline||e.linethrough!==t.linethrough),Qi=(e,t)=>{let n=t.split(`
15
+ `),r=[],i=-1,a={};e=Xi(e);for(let t=0;t<n.length;t++){let o=St(n[t]);if(!e[t]){i+=o.length,a={};continue}for(let n=0;n<o.length;n++){i++;let o=e[t][n];o&&Object.keys(o).length>0&&(Zi(a,o,!0)?r.push({start:i,end:i+1,style:o}):r[r.length-1].end++),a=o||{}}}return r},$i=(e,t)=>{if(!Array.isArray(e))return Xi(e);let n=t.split(re),r={},i=-1,a=0;for(let t=0;t<n.length;t++){let o=St(n[t]);for(let n=0;n<o.length;n++)i++,e[a]&&e[a].start<=i&&i<e[a].end&&(r[t]=r[t]||{},r[t][n]={...e[a].style},i===e[a].end-1&&a++)}return r},ea=[`display`,`transform`,j,`fill-opacity`,`fill-rule`,`opacity`,ge,`stroke-dasharray`,`stroke-linecap`,`stroke-dashoffset`,`stroke-linejoin`,`stroke-miterlimit`,`stroke-opacity`,`stroke-width`,`id`,`paint-order`,`vector-effect`,`instantiated_by_use`,`clip-path`];function ta(e,t){let n=e.nodeName,r=e.getAttribute(`class`),i=e.getAttribute(`id`),a=`(?![a-zA-Z\\-]+)`,o;if(o=RegExp(`^`+n,`i`),t=t.replace(o,``),i&&t.length&&(o=RegExp(`#`+i+a,`i`),t=t.replace(o,``)),r&&t.length){let e=r.split(` `);for(let n=e.length;n--;)o=RegExp(`\\.`+e[n]+a,`i`),t=t.replace(o,``)}return t.length===0}function na(e,t){let n,r=!0;for(;e.parentElement&&e.parentElement.nodeType===1&&t.length;)r&&(n=t.pop()),e=e.parentElement,r=ta(e,n);return t.length===0}function ra(e,t){let n=!0,r=ta(e,t.pop());return r&&t.length&&(n=na(e,t)),r&&n&&t.length===0}function ia(e,t={}){let n={};for(let r in t)ra(e,r.split(` `))&&(n={...n,...t[r]});return n}let aa=e=>{var t;return(t=Yn[e])==null?e:t},oa=RegExp(`(${Vn})`,`gi`),sa=e=>hn(e.replace(oa,` $1 `).replace(/,/gi,` `)),Y=`(${Vn})`,ca=String.raw`(skewX)\(${Y}\)`,la=String.raw`(skewY)\(${Y}\)`,ua=String.raw`(rotate)\(${Y}(?: ${Y} ${Y})?\)`,da=String.raw`(scale)\(${Y}(?: ${Y})?\)`,fa=String.raw`(translate)\(${Y}(?: ${Y})?\)`,pa=`(?:${String.raw`(matrix)\(${Y} ${Y} ${Y} ${Y} ${Y} ${Y}\)`}|${fa}|${ua}|${da}|${ca}|${la})`,ma=`(?:${pa}*)`,ha=String.raw`^\s*(?:${ma}?)\s*$`,ga=new RegExp(ha),_a=new RegExp(pa),va=new RegExp(pa,`g`);function ya(e){e=sa(e).replace(/\s*([()])\s*/gi,`$1`);let t=[];if(!e||e&&!ga.test(e))return[...E];for(let n of e.matchAll(va)){let e=_a.exec(n[0]);if(!e)continue;let r=E,[,i,...a]=e.filter(e=>!!e),[o,s,c,l,u,d]=a.map(e=>parseFloat(e));switch(i){case`translate`:r=We(o,s);break;case A:r=Ge({angle:o},{x:s,y:c});break;case de:r=Ke(o,s);break;case me:r=Je(o);break;case he:r=Ye(o);break;case`matrix`:r=[o,s,c,l,u,d];break}t.push(r)}return ze(t)}function ba(e,t,n,r){let i=Array.isArray(t),a,o=t;if((e===`fill`||e===`stroke`)&&t===`none`)o=``;else if(e===`strokeUniform`)return t===`non-scaling-stroke`;else if(e===`strokeDashArray`)o=t===`none`?null:t.replace(/,/g,` `).split(/\s+/).map(parseFloat);else if(e===`transformMatrix`)o=n&&n.transformMatrix?B(n.transformMatrix,ya(t)):ya(t);else if(e===`visible`)o=t!==`none`&&t!==`hidden`,n&&n.visible===!1&&(o=!1);else if(e===`opacity`)o=parseFloat(t),n&&n.opacity!==void 0&&(o*=n.opacity);else if(e===`textAnchor`)o=t===`start`?O:t===`end`?k:D;else if(e===`charSpacing`||e===`textDecorationThickness`)a=K(t,r)/r*1e3;else if(e===`paintFirst`){let e=t.indexOf(j),n=t.indexOf(ge);o=j,(e>-1&&n>-1&&n<e||e===-1&&n>-1)&&(o=ge)}else if(e===`href`||e===`xlink:href`||e===`font`||e===`id`)return t;else if(e===`imageSmoothing`)return t===`optimizeQuality`;else a=i?t.map(K):K(t,r);return!i&&isNaN(a)?o:a}function xa(e,t){let n=e.match(Wn);if(!n)return;let r=n[1],i=n[3],a=n[4],o=n[5],s=n[6];r&&(t.fontStyle=r),i&&(t.fontWeight=isNaN(parseFloat(i))?i:parseFloat(i)),a&&(t.fontSize=K(a)),s&&(t.fontFamily=s),o&&(t.lineHeight=o===`normal`?1:o)}function Sa(e,t){Object.entries(e).forEach(([e,n])=>{n!==void 0&&(t[e.toLowerCase()]=n)})}function Ca(e,t){e.replace(/;\s*$/,``).split(`;`).forEach(e=>{if(!e)return;let[n,r]=e.split(`:`);t[n.trim().toLowerCase()]=r.trim()})}function wa(e){let t={},n=e.getAttribute(`style`);return n&&(typeof n==`string`?Ca(n,t):Sa(n,t)),t}let Ta={stroke:`strokeOpacity`,fill:`fillOpacity`};function Ea(e){let t=J.getDefaults();return Object.entries(Ta).forEach(([n,r])=>{if(e[r]===void 0||e[n]===``)return;if(e[n]===void 0){if(!t[n])return;e[n]=t[n]}if(e[n].indexOf(`url(`)===0)return;let i=new G(e[n]);e[n]=i.setAlpha(V(i.getAlpha()*e[r],2)).toRgba()}),e}function Da(e,t,n){if(!e)return{};let r={},i,a=16;e.parentNode&&er.test(e.parentNode.nodeName)&&(r=Da(e.parentElement,t,n),r.fontSize&&(i=a=K(r.fontSize)));let o={...t.reduce((t,n)=>{let r=e.getAttribute(n);return r&&(t[n]=r),t},{}),...ia(e,n),...wa(e)};o[`clip-path`]&&e.setAttribute(Zn,o[Zn]),o[`font-size`]&&(i=K(o[Xn],a),o[Xn]=`${i}`);let s={};for(let e in o){let t=aa(e);s[t]=ba(t,o[e],r,i)}s&&s.font&&xa(s.font,s);let c={...r,...s};return er.test(e.nodeName)?c:Ea(c)}let Oa={rx:0,ry:0},ka=[`rx`,`ry`];var Aa=class e extends J{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t){super(),Object.assign(this,e.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){let{rx:e,ry:t}=this;e&&!t?this.ry=e:t&&!e&&(this.rx=t)}_render(e){let{width:t,height:n}=this,r=-t/2,i=-n/2,a=this.rx?Math.min(this.rx,t/2):0,o=this.ry?Math.min(this.ry,n/2):0,s=a!==0||o!==0;e.beginPath(),e.moveTo(r+a,i),e.lineTo(r+t-a,i),s&&e.bezierCurveTo(r+t-.4477152502*a,i,r+t,i+.4477152502*o,r+t,i+o),e.lineTo(r+t,i+n-o),s&&e.bezierCurveTo(r+t,i+n-.4477152502*o,r+t-.4477152502*a,i+n,r+t-a,i+n),e.lineTo(r+a,i+n),s&&e.bezierCurveTo(r+.4477152502*a,i+n,r,i+n-.4477152502*o,r,i+n-o),e.lineTo(r,i+o),s&&e.bezierCurveTo(r,i+.4477152502*o,r+.4477152502*a,i,r+a,i),e.closePath(),this._renderPaintInOrder(e)}toObject(e=[]){return super.toObject([...ka,...e])}_toSVG(){let{width:e,height:t,rx:n,ry:r}=this;return[`<rect `,`COMMON_PARTS`,`x="${-e/2}" y="${-t/2}" rx="${U(n)}" ry="${U(r)}" width="${U(e)}" height="${U(t)}" />\n`]}static async fromElement(e,t,n){let{left:r=0,top:i=0,width:a=0,height:o=0,visible:s=!0,...c}=Da(e,this.ATTRIBUTE_NAMES,n);return new this({...t,...c,left:r,top:i,width:a,height:o,visible:!!(s&&a&&o)})}};o(Aa,`type`,`Rect`),o(Aa,`cacheProperties`,[...sr,...ka]),o(Aa,`ownDefaults`,Oa),o(Aa,`ATTRIBUTE_NAMES`,[...ea,`x`,`y`,`rx`,`ry`,`width`,`height`]),M.setClass(Aa),M.setSVGClass(Aa);let ja=`initialization`,Ma=`added`,Na=(e,t)=>{let{strokeUniform:n,strokeWidth:r,width:i,height:a,group:o}=t,s=o&&o!==e?Rt(o.calcTransformMatrix(),e.calcTransformMatrix()):null,c=s?t.getRelativeCenterPoint().transform(s):t.getRelativeCenterPoint(),l=!t.isStrokeAccountedForInDimensions(),u=n&&l?Bt(new P(r,r),void 0,e.calcTransformMatrix()):we,d=!n&&l?r:0,f=Lt(i+d,a+d,ze([s,t.calcOwnMatrix()],!0)).add(u).scalarDivide(2);return[c.subtract(f),c.add(f)]};var Pa=class{calcLayoutResult(e,t){if(this.shouldPerformLayout(e))return this.calcBoundingBox(t,e)}shouldPerformLayout({type:e,prevStrategy:t,strategy:n}){return e===`initialization`||e===`imperative`||!!t&&n!==t}shouldLayoutClipPath({type:e,target:{clipPath:t}}){return e!==`initialization`&&t&&!t.absolutePositioned}getInitialSize(e,t){return t.size}calcBoundingBox(e,t){let{type:n,target:r}=t;if(n===`imperative`&&t.overrides)return t.overrides;if(e.length===0)return;let{left:i,top:a,width:o,height:s}=jt(e.map(e=>Na(r,e)).reduce((e,t)=>e.concat(t),[])),c=new P(o,s),l=new P(i,a).add(c.scalarDivide(2));if(n===`initialization`){let e=this.getInitialSize(t,{size:c,center:l});return{center:l,relativeCorrection:new P(0,0),size:e}}else return{center:l.transform(r.calcOwnMatrix()),size:c}}};o(Pa,`type`,`strategy`);var Fa=class extends Pa{shouldPerformLayout(e){return!0}};o(Fa,`type`,`fit-content`),M.setClass(Fa);let Ia=`layoutManager`;var La=class{constructor(e=new Fa){o(this,`strategy`,void 0),this.strategy=e,this._subscriptions=new Map}performLayout(e){let t={bubbles:!0,strategy:this.strategy,...e,prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}};this.onBeforeLayout(t);let n=this.getLayoutResult(t);n&&this.commitLayout(t,n),this.onAfterLayout(t,n),this._prevLayoutStrategy=t.strategy}attachHandlers(e,t){let{target:n}=t;return[_e,ie,ce,oe,ae,se,ue,le,`modifyPath`].map(t=>e.on(t,e=>this.performLayout(t===`modified`?{type:`object_modified`,trigger:t,e,target:n}:{type:`object_modifying`,trigger:t,e,target:n})))}subscribe(e,t){this.unsubscribe(e,t);let n=this.attachHandlers(e,t);this._subscriptions.set(e,n)}unsubscribe(e,t){(this._subscriptions.get(e)||[]).forEach(e=>e()),this._subscriptions.delete(e)}unsubscribeTargets(e){e.targets.forEach(t=>this.unsubscribe(t,e))}subscribeTargets(e){e.targets.forEach(t=>this.subscribe(t,e))}onBeforeLayout(e){let{target:t,type:n}=e,{canvas:r}=t;if(n===`initialization`||n===`added`?this.subscribeTargets(e):n===`removed`&&this.unsubscribeTargets(e),t.fire(`layout:before`,{context:e}),r&&r.fire(`object:layout:before`,{target:t,context:e}),n===`imperative`&&e.deep){let{strategy:n,...r}=e;t.forEachObject(e=>e.layoutManager&&e.layoutManager.performLayout({...r,bubbles:!1,target:e}))}}getLayoutResult(e){let{target:t,strategy:n,type:r}=e,i=n.calcLayoutResult(e,t.getObjects());if(!i)return;let a=r===`initialization`?new P:t.getRelativeCenterPoint(),{center:o,correction:s=new P,relativeCorrection:c=new P}=i;return{result:i,prevCenter:a,nextCenter:o,offset:a.subtract(o).add(s).transform(r===`initialization`?E:z(t.calcOwnMatrix()),!0).add(c)}}commitLayout(e,t){let{target:n}=e,{result:{size:r},nextCenter:i}=t;if(n.set({width:r.x,height:r.y}),this.layoutObjects(e,t),e.type===`initialization`){var a,o;n.set({left:(a=e.x)==null?i.x+r.x*W(n.originX):a,top:(o=e.y)==null?i.y+r.y*W(n.originY):o})}else n.setPositionByOrigin(i,D,D),n.setCoords(),n.set(`dirty`,!0)}layoutObjects(e,t){let{target:n}=e;n.forEachObject(r=>{r.group===n&&this.layoutObject(e,t,r)}),e.strategy.shouldLayoutClipPath(e)&&this.layoutObject(e,t,n.clipPath)}layoutObject(e,{offset:t},n){n.set({left:n.left+t.x,top:n.top+t.y})}onAfterLayout(e,t){let{target:n,strategy:r,bubbles:i,prevStrategy:a,...o}=e,{canvas:s}=n;n.fire(`layout:after`,{context:e,result:t}),s&&s.fire(`object:layout:after`,{context:e,result:t,target:n});let c=n.parent;i&&c!=null&&c.layoutManager&&((o.path||(o.path=[])).push(n),c.layoutManager.performLayout({...o,target:c})),n.set(`dirty`,!0)}dispose(){let{_subscriptions:e}=this;e.forEach(e=>e.forEach(e=>e())),e.clear()}toObject(){return{type:Ia,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}};M.setClass(La,Ia);var Ra=class extends La{performLayout(){}};let za={strokeWidth:0,subTargetCheck:!1,interactive:!1};var Ba=class e extends Ee(J){static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t=[],n={}){super(),o(this,`_activeObjects`,[]),o(this,`__objectSelectionTracker`,void 0),o(this,`__objectSelectionDisposer`,void 0),Object.assign(this,e.ownDefaults),this.setOptions(n),this.groupInit(t,n)}groupInit(e,t){var n;this._objects=[...e],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(e=>{this.enterGroup(e,!1)}),this.layoutManager=(n=t.layoutManager)==null?new La:n,this.layoutManager.performLayout({type:ja,target:this,targets:[...e],x:t.left,y:t.top})}canEnterGroup(e){return e===this||this.isDescendantOf(e)?(l(`error`,`Group: circular object trees are not supported, this call has no effect`),!1):this._objects.indexOf(e)===-1?!0:(l(`error`,`Group: duplicate objects are not supported inside group, this call has no effect`),!1)}_filterObjectsBeforeEnteringGroup(e){return e.filter((e,t,n)=>this.canEnterGroup(e)&&n.indexOf(e)===t)}add(...e){let t=this._filterObjectsBeforeEnteringGroup(e),n=super.add(...t);return this._onAfterObjectsChange(Ma,t),n}insertAt(e,...t){let n=this._filterObjectsBeforeEnteringGroup(t),r=super.insertAt(e,...n);return this._onAfterObjectsChange(Ma,n),r}remove(...e){let t=super.remove(...e);return this._onAfterObjectsChange(`removed`,t),t}_onObjectAdded(e){this.enterGroup(e,!0),this.fire(`object:added`,{target:e}),e.fire(`added`,{target:this})}_onObjectRemoved(e,t){this.exitGroup(e,t),this.fire(`object:removed`,{target:e}),e.fire(`removed`,{target:this})}_onAfterObjectsChange(e,t){this.layoutManager.performLayout({type:e,targets:t,target:this})}_onStackOrderChanged(){this._set(`dirty`,!0)}_set(e,t){let n=this[e];return super._set(e,t),e===`canvas`&&n!==t&&(this._objects||[]).forEach(n=>{n._set(e,t)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(e,{target:t}){let n=this._activeObjects;if(e)n.push(t),this._set(`dirty`,!0);else if(n.length>0){let e=n.indexOf(t);e>-1&&(n.splice(e,1),this._set(`dirty`,!0))}}_watchObject(e,t){e&&this._watchObject(!1,t),e?(t.on(`selected`,this.__objectSelectionTracker),t.on(`deselected`,this.__objectSelectionDisposer)):(t.off(`selected`,this.__objectSelectionTracker),t.off(`deselected`,this.__objectSelectionDisposer))}enterGroup(e,t){e.group&&e.group.remove(e),e._set(`parent`,this),this._enterGroup(e,t)}_enterGroup(e,t){t&&Pt(e,B(z(this.calcTransformMatrix()),e.calcTransformMatrix())),this._shouldSetNestedCoords()&&e.setCoords(),e._set(`group`,this),e._set(`canvas`,this.canvas),this._watchObject(!0,e);let n=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();n&&(n===e||e.isDescendantOf(n))&&this._activeObjects.push(e)}exitGroup(e,t){this._exitGroup(e,t),e._set(`parent`,void 0),e._set(`canvas`,void 0)}_exitGroup(e,t){e._set(`group`,void 0),t||(Pt(e,B(this.calcTransformMatrix(),e.calcTransformMatrix())),e.setCoords()),this._watchObject(!1,e);let n=this._activeObjects.length>0?this._activeObjects.indexOf(e):-1;n>-1&&this._activeObjects.splice(n,1)}shouldCache(){let e=J.prototype.shouldCache.call(this);if(e){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return e}willDrawShadow(){if(super.willDrawShadow())return!0;for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(e,t,n){this._renderBackground(e);for(let t=0;t<this._objects.length;t++){var r;let n=this._objects[t];(r=this.canvas)!=null&&r.preserveObjectStacking&&n.group!==this?(e.save(),e.transform(...z(this.calcTransformMatrix())),n.render(e),e.restore()):n.group===this&&n.render(e)}this._drawClipPath(e,this.clipPath,n)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(e=>e.setCoords())}triggerLayout(e={}){this.layoutManager.performLayout({target:this,type:`imperative`,...e})}render(e){this._transformDone=!0,super.render(e),this._transformDone=!1}__serializeObjects(e,t){let n=this.includeDefaultValues;return this._objects.filter(function(e){return!e.excludeFromExport}).map(function(r){let i=r.includeDefaultValues;r.includeDefaultValues=n;let a=r[e||`toObject`](t);return r.includeDefaultValues=i,a})}toObject(e=[]){let t=this.layoutManager.toObject();return{...super.toObject([`subTargetCheck`,`interactive`,...e]),...t.strategy!==`fit-content`||this.includeDefaultValues?{layoutManager:t}:{},objects:this.__serializeObjects(`toObject`,e)}}toString(){return`#<Group: (${this.complexity()})>`}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject(e=>{this._watchObject(!1,e),e.dispose()}),super.dispose()}_createSVGBgRect(e){if(!this.backgroundColor)return``;let t=Aa.prototype._toSVG.call(this),n=t.indexOf(`COMMON_PARTS`);t[n]=`for="group" `;let r=t.join(``);return e?e(r):r}_toSVG(e){let t=[`<g `,`COMMON_PARTS`,` >
16
+ `],n=this._createSVGBgRect(e);n&&t.push(` `,n);for(let n=0;n<this._objects.length;n++)t.push(` `,this._objects[n].toSVG(e));return t.push(`</g>
17
+ `),t}getSvgStyles(){let e=this.opacity!==void 0&&this.opacity!==1?`opacity: ${U(this.opacity)};`:``,t=this.visible?``:` visibility: hidden;`;return[e,this.getSvgFilter(),t].join(``)}toClipPathSVG(e){let t=[],n=this._createSVGBgRect(e);n&&t.push(` `,n);for(let n=0;n<this._objects.length;n++)t.push(` `,this._objects[n].toClipPathSVG(e));return this._createBaseClipPathSVGMarkup(t,{reviver:e})}static fromObject({type:e,objects:t=[],layoutManager:n,...r},i){return Promise.all([$e(t,i),et(r,i)]).then(([e,t])=>{let i=new this(e,{...r,...t,layoutManager:new Ra});return n?i.layoutManager=new(M.getClass(n.type))(new(M.getClass(n.strategy))):i.layoutManager=new La,i.layoutManager.subscribeTargets({type:ja,target:i,targets:i.getObjects()}),i.setCoords(),i})}};o(Ba,`type`,`Group`),o(Ba,`ownDefaults`,za),M.setClass(Ba);let Va=(e,t)=>e&&e.length===1?e[0]:new Ba(e,t),Ha=(e,t)=>Math.min(t.width/e.width,t.height/e.height),Ua=(e,t)=>Math.max(t.width/e.width,t.height/e.height),Wa=`\\s*,?\\s*`,Ga=`${Wa}(${Vn})`,Ka=`${Ga}${Ga}${Ga}${Wa}([01])${Wa}([01])${Ga}${Ga}`,qa={m:`l`,M:`L`},Ja=(e,t,n,r,i,a,o,s,c,l,u)=>{let d=Ce(e),f=N(e),p=Ce(t),m=N(t),h=n*i*p-r*a*m+o,g=r*i*p+n*a*m+s;return[`C`,l+c*(-n*i*f-r*a*d),u+c*(-r*i*f+n*a*d),h+c*(n*i*m+r*a*p),g+c*(r*i*m-n*a*p),h,g]},Ya=(e,t,n,r,i,a,o)=>{if(n===0||r===0)return[];let s=0,c=0,l=0,u=Math.PI,d=o*ee,f=N(d),p=Ce(d),m=.5*(-p*e-f*t),h=.5*(-p*t+f*e),g=n**2,_=r**2,v=h**2,y=m**2,b=g*_-g*v-_*y,x=Math.abs(n),S=Math.abs(r);if(b<0){let e=Math.sqrt(1-b/(g*_));x*=e,S*=e}else l=(i===a?-1:1)*Math.sqrt(b/(g*v+_*y));let C=l*x*h/S,w=-l*S*m/x,T=p*C-f*w+e*.5,E=f*C+p*w+t*.5,D=Xa(1,0,(m-C)/x,(h-w)/S),O=Xa((m-C)/x,(h-w)/S,(-m-C)/x,(-h-w)/S);a===0&&O>0?O-=2*u:a===1&&O<0&&(O+=2*u);let te=Math.ceil(Math.abs(O/u*2)),k=[],ne=O/te,re=8/3*Math.sin(ne/4)*Math.sin(ne/4)/Math.sin(ne/2),ie=D+ne;for(let e=0;e<te;e++)k[e]=Ja(D,ie,p,f,x,S,T,E,re,s,c),s=k[e][5],c=k[e][6],D=ie,ie+=ne;return k},Xa=(e,t,n,r)=>{let i=Math.atan2(t,e),a=Math.atan2(r,n);return a>=i?a-i:2*Math.PI-(i-a)},Za=e=>e**3,Qa=e=>3*e**2*(1-e),$a=e=>3*e*(1-e)**2,eo=e=>(1-e)**3;function to(e,t,n,r,i,a,o,s){let l;if(c.cachesBoundsOfCurve&&(l=[...arguments].join(),b.boundsOfCurveCache[l]))return b.boundsOfCurveCache[l];let u=Math.sqrt,d=Math.abs,f=[],p=[[0,0],[0,0]],m=6*e-12*n+6*i,h=-3*e+9*n-9*i+3*o,g=3*n-3*e;for(let e=0;e<2;++e){if(e>0&&(m=6*t-12*r+6*a,h=-3*t+9*r-9*a+3*s,g=3*r-3*t),d(h)<1e-12){if(d(m)<1e-12)continue;let e=-g/m;0<e&&e<1&&f.push(e);continue}let n=m*m-4*g*h;if(n<0)continue;let i=u(n),o=(-m+i)/(2*h);0<o&&o<1&&f.push(o);let c=(-m-i)/(2*h);0<c&&c<1&&f.push(c)}let _=f.length,v=_,y=ao(e,t,n,r,i,a,o,s);for(;_--;){let{x:e,y:t}=y(f[_]);p[0][_]=e,p[1][_]=t}p[0][v]=e,p[1][v]=t,p[0][v+1]=o,p[1][v+1]=s;let x=[new P(Math.min(...p[0]),Math.min(...p[1])),new P(Math.max(...p[0]),Math.max(...p[1]))];return c.cachesBoundsOfCurve&&(b.boundsOfCurveCache[l]=x),x}let no=(e,t,[n,r,i,a,o,s,c,l])=>{let u=Ya(c-e,l-t,r,i,o,s,a);for(let n=0,r=u.length;n<r;n++)u[n][1]+=e,u[n][2]+=t,u[n][3]+=e,u[n][4]+=t,u[n][5]+=e,u[n][6]+=t;return u},ro=e=>{let t=0,n=0,r=0,i=0,a=[],o,s=0,c=0;for(let l of e){let e=[...l],u;switch(e[0]){case`l`:e[1]+=t,e[2]+=n;case`L`:t=e[1],n=e[2],u=[`L`,t,n];break;case`h`:e[1]+=t;case`H`:t=e[1],u=[`L`,t,n];break;case`v`:e[1]+=n;case`V`:n=e[1],u=[`L`,t,n];break;case`m`:e[1]+=t,e[2]+=n;case`M`:t=e[1],n=e[2],r=e[1],i=e[2],u=[`M`,t,n];break;case`c`:e[1]+=t,e[2]+=n,e[3]+=t,e[4]+=n,e[5]+=t,e[6]+=n;case`C`:s=e[3],c=e[4],t=e[5],n=e[6],u=[`C`,e[1],e[2],s,c,t,n];break;case`s`:e[1]+=t,e[2]+=n,e[3]+=t,e[4]+=n;case`S`:o===`C`?(s=2*t-s,c=2*n-c):(s=t,c=n),t=e[3],n=e[4],u=[`C`,s,c,e[1],e[2],t,n],s=u[3],c=u[4];break;case`q`:e[1]+=t,e[2]+=n,e[3]+=t,e[4]+=n;case`Q`:s=e[1],c=e[2],t=e[3],n=e[4],u=[`Q`,s,c,t,n];break;case`t`:e[1]+=t,e[2]+=n;case`T`:o===`Q`?(s=2*t-s,c=2*n-c):(s=t,c=n),t=e[1],n=e[2],u=[`Q`,s,c,t,n];break;case`a`:e[6]+=t,e[7]+=n;case`A`:no(t,n,e).forEach(e=>a.push(e)),t=e[6],n=e[7];break;case`z`:case`Z`:t=r,n=i,u=[`Z`];break;default:}u?(a.push(u),o=u[0]):o=``}return a},io=(e,t,n,r)=>Math.sqrt((n-e)**2+(r-t)**2),ao=(e,t,n,r,i,a,o,s)=>c=>{let l=Za(c),u=Qa(c),d=$a(c),f=eo(c);return new P(o*l+i*u+n*d+e*f,s*l+a*u+r*d+t*f)},oo=e=>e**2,so=e=>2*e*(1-e),co=e=>(1-e)**2,lo=(e,t,n,r,i,a,o,s)=>c=>{let l=oo(c),u=so(c),d=co(c),f=3*(d*(n-e)+u*(i-n)+l*(o-i)),p=3*(d*(r-t)+u*(a-r)+l*(s-a));return Math.atan2(p,f)},uo=(e,t,n,r,i,a)=>o=>{let s=oo(o),c=so(o),l=co(o);return new P(i*s+n*c+e*l,a*s+r*c+t*l)},fo=(e,t,n,r,i,a)=>o=>{let s=1-o,c=2*(s*(n-e)+o*(i-n)),l=2*(s*(r-t)+o*(a-r));return Math.atan2(l,c)},po=(e,t,n)=>{let r=new P(t,n),i=0;for(let t=1;t<=100;t+=1){let n=e(t/100);i+=io(r.x,r.y,n.x,n.y),r=n}return i},mo=(e,t)=>{let n=0,r=0,i={x:e.x,y:e.y},a={...i},o,s=.01,c=0,l=e.iterator,u=e.angleFinder;for(;r<t&&s>1e-4;)a=l(n),c=n,o=io(i.x,i.y,a.x,a.y),o+r>t?(n-=s,s/=2):(i=a,n+=s,r+=o);return{...a,angle:u(c)}},ho=e=>{let t=0,n=0,r=0,i=0,a=0,o,s,c=[];for(let l of e){let e={x:n,y:r,command:l[0],length:0};switch(l[0]){case`M`:s=e,s.x=i=n=l[1],s.y=a=r=l[2];break;case`L`:s=e,s.length=io(n,r,l[1],l[2]),n=l[1],r=l[2];break;case`C`:o=ao(n,r,l[1],l[2],l[3],l[4],l[5],l[6]),s=e,s.iterator=o,s.angleFinder=lo(n,r,l[1],l[2],l[3],l[4],l[5],l[6]),s.length=po(o,n,r),n=l[5],r=l[6];break;case`Q`:o=uo(n,r,l[1],l[2],l[3],l[4]),s=e,s.iterator=o,s.angleFinder=fo(n,r,l[1],l[2],l[3],l[4]),s.length=po(o,n,r),n=l[3],r=l[4];break;case`Z`:s=e,s.destX=i,s.destY=a,s.length=io(n,r,i,a),n=i,r=a;break}t+=s.length,c.push(s)}return c.push({length:t,x:n,y:r}),c},go=(e,t,n=ho(e))=>{let r=0;for(;t-n[r].length>0&&r<n.length-2;)t-=n[r].length,r++;let i=n[r],a=t/i.length,o=e[r];switch(i.command){case`M`:return{x:i.x,y:i.y,angle:0};case`Z`:return{...new P(i.x,i.y).lerp(new P(i.destX,i.destY),a),angle:Math.atan2(i.destY-i.y,i.destX-i.x)};case`L`:return{...new P(i.x,i.y).lerp(new P(o[1],o[2]),a),angle:Math.atan2(o[2]-i.y,o[1]-i.x)};case`C`:return mo(i,t);case`Q`:return mo(i,t);default:}},_o=RegExp(`[mzlhvcsqta][^mzlhvcsqta]*`,`gi`),vo=new RegExp(Ka,`g`),yo=new RegExp(Vn,`gi`),bo={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},xo=e=>{var t;let n=[],r=(t=e.match(_o))==null?[]:t;for(let e of r){let t=e[0];if(t===`z`||t===`Z`){n.push([t]);continue}let r=bo[t.toLowerCase()],i=[];if(t===`a`||t===`A`){vo.lastIndex=0;let t;for(;t=vo.exec(e);)i.push(...t.slice(1))}else i=e.match(yo)||[];for(let e=0;e<i.length;e+=r){let a=Array(r),o=qa[t];a[0]=e>0&&o?o:t;for(let t=0;t<r;t++)a[t+1]=parseFloat(i[e+t]);n.push(a)}}return n},So=(e,t=0)=>{let n=new P(e[0]),r=new P(e[1]),i=1,a=0,o=[],s=e.length,c=s>2;c&&(i=e[2].x<r.x?-1:e[2].x===r.x?0:1,a=e[2].y<r.y?-1:e[2].y===r.y?0:1),o.push([`M`,n.x-i*t,n.y-a*t]);let l;for(l=1;l<s;l++){if(!n.eq(r)){let e=n.midPointFrom(r);o.push([`Q`,n.x,n.y,e.x,e.y])}n=e[l],l+1<e.length&&(r=e[l+1])}return c&&(i=n.x>e[l-2].x?1:n.x===e[l-2].x?0:-1,a=n.y>e[l-2].y?1:n.y===e[l-2].y?0:-1),o.push([`L`,n.x+i*t,n.y+a*t]),o},Co=(e,t,n)=>(n&&(t=B(t,[1,0,0,1,-n.x,-n.y])),e.map(e=>{let n=[...e];for(let r=1;r<e.length-1;r+=2){let{x:i,y:a}=R({x:e[r],y:e[r+1]},t);n[r]=i,n[r+1]=a}return n})),wo=(e,t)=>{let n=Math.PI*2/e,r=-C;e%2==0&&(r+=n/2);let i=Array(e+1);for(let a=0;a<e;a++){let e=a*n+r,{x:o,y:s}=new P(Ce(e),N(e)).scalarMultiply(t);i[a]=[a===0?`M`:`L`,o,s]}return i[e]=[`Z`],i},To=(e,t)=>e.map(e=>e.map((e,n)=>n===0||t===void 0?e:V(e,t)).join(` `)).join(` `),Eo=(e,t)=>{var n;let r=e,i=t;r.inverted&&!i.inverted&&(r=t,i=e),Vt(i,(n=i.group)==null?void 0:n.calcTransformMatrix(),r.calcTransformMatrix());let a=r.inverted&&i.inverted;return a&&(r.inverted=i.inverted=!1),new Ba([r],{clipPath:i,inverted:a})},Do=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,Oo=e=>{if(e.transformMatrix){let{scaleX:t,scaleY:n,angle:r,skewX:i}=Ue(e.transformMatrix);e.flipX=!1,e.flipY=!1,e.set(fe,t),e.set(pe,n),e.angle=r,e.skewX=i,e.skewY=0}},ko=(e,t)=>{let n=e._findCenterFromElement();e.transformMatrix&&(Oo(e),n=n.transform(e.transformMatrix)),delete e.transformMatrix,t&&(e.scaleX*=t.scaleX,e.scaleY*=t.scaleY,e.cropX=t.cropX,e.cropY=t.cropY,n.x+=t.offsetLeft,n.y+=t.offsetTop,e.width=t.width,e.height=t.height),e.setPositionByOrigin(n,D,D)};var Ao=n({addTransformToObject:()=>Nt,animate:()=>Qr,animateColor:()=>$r,applyTransformToObject:()=>Pt,calcAngleBetweenVectors:()=>Jt,calcDimensionsMatrix:()=>Xe,calcPlaneChangeMatrix:()=>Rt,calcVectorRotation:()=>Yt,cancelAnimFrame:()=>ke,capValue:()=>ar,composeMatrix:()=>Ze,copyCanvasElement:()=>Ne,cos:()=>Ce,createCanvasElement:()=>F,createImage:()=>Me,createRotateMatrix:()=>Ge,createScaleMatrix:()=>Ke,createSkewXMatrix:()=>Je,createSkewYMatrix:()=>Ye,createTranslateMatrix:()=>We,createVector:()=>Kt,crossProduct:()=>Qt,degreesToRadians:()=>L,dotProduct:()=>$t,ease:()=>ur,enlivenObjectEnlivables:()=>et,enlivenObjects:()=>$e,findScaleToCover:()=>Ua,findScaleToFit:()=>Ha,getBoundsOfCurve:()=>to,getOrthonormalVector:()=>Zt,getPathSegmentsInfo:()=>ho,getPointOnPath:()=>go,getPointer:()=>Ot,getRandomInt:()=>Do,getRegularPolygonPath:()=>wo,getSmoothPathFromPoints:()=>So,getSvgAttributes:()=>Tn,getUnitVector:()=>Xt,groupSVGElements:()=>Va,hasStyleChanged:()=>Zi,invertTransform:()=>z,isBetweenVectors:()=>en,isIdentityMatrix:()=>Re,isTouchEvent:()=>kt,isTransparent:()=>Ui,joinPath:()=>To,loadImage:()=>Qe,magnitude:()=>qt,makeBoundingBoxFromPoints:()=>jt,makePathSimpler:()=>ro,matrixToSVG:()=>rt,mergeClipPaths:()=>Eo,multiplyTransformMatrices:()=>B,multiplyTransformMatrixArray:()=>ze,parsePath:()=>xo,parsePreserveAspectRatioAttribute:()=>Dn,parseUnit:()=>K,pick:()=>tt,projectStrokeOnPoints:()=>Yi,qrDecompose:()=>Ue,radiansToDegrees:()=>Le,removeFromArray:()=>Se,removeTransformFromObject:()=>Mt,removeTransformMatrixForSvgParsing:()=>ko,requestAnimFrame:()=>Oe,resetObjectTransform:()=>Ft,rotateVector:()=>Gt,saveObjectTransform:()=>It,sendObjectToPlane:()=>Vt,sendPointToPlane:()=>zt,sendVectorToPlane:()=>Bt,sin:()=>N,sizeAfterTransform:()=>Lt,string:()=>vt,stylesFromArray:()=>$i,stylesToArray:()=>Qi,toBlob:()=>Ie,toDataURL:()=>Pe,toFixed:()=>V,transformPath:()=>Co,transformPoint:()=>R});function jo(e,t){let n=e.style;n&&Object.entries(t).forEach(([e,t])=>n.setProperty(e,t))}var Mo=class extends gt{constructor(e,{allowTouchScrolling:t=!1,containerClass:n=``}={}){super(e),o(this,`upper`,void 0),o(this,`container`,void 0);let{el:r}=this.lower,i=this.createUpperCanvas();this.upper={el:i,ctx:i.getContext(`2d`)},this.applyCanvasStyle(r,{allowTouchScrolling:t}),this.applyCanvasStyle(i,{allowTouchScrolling:t,styles:{position:`absolute`,left:`0`,top:`0`}});let a=this.createContainerElement();a.classList.add(n),r.parentNode&&r.parentNode.replaceChild(a,r),a.append(r,i),this.container=a}createUpperCanvas(){let{el:e}=this.lower,t=F();return t.className=e.className,t.classList.remove(`lower-canvas`),t.classList.add(`upper-canvas`),t.setAttribute(`data-fabric`,`top`),t.style.cssText=e.style.cssText,t.setAttribute(`draggable`,`true`),t}createContainerElement(){let e=_().createElement(`div`);return e.setAttribute(`data-fabric`,`wrapper`),jo(e,{position:`relative`}),ht(e),e}applyCanvasStyle(e,t){let{styles:n,allowTouchScrolling:r}=t;jo(e,{...n,"touch-action":r?`manipulation`:ne}),ht(e)}setDimensions(e,t){super.setDimensions(e,t);let{el:n,ctx:r}=this.upper;ft(n,r,e,t)}setCSSDimensions(e){super.setCSSDimensions(e),pt(this.upper.el,e),pt(this.container,e)}cleanupDOM(e){let t=this.container,{el:n}=this.lower,{el:r}=this.upper;super.cleanupDOM(e),t.removeChild(r),t.removeChild(n),t.parentNode&&t.parentNode.replaceChild(n,t)}dispose(){super.dispose(),g().dispose(this.upper.el),delete this.upper,delete this.container}};let No={uniformScaling:!0,uniScaleKey:`shiftKey`,centeredScaling:!1,centeredRotation:!1,centeredKey:`altKey`,altActionKey:`shiftKey`,selection:!0,selectionKey:`shiftKey`,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`,perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!0,fireRightClick:!0,fireMiddleClick:!0,enablePointerEvents:!1,containerClass:`canvas-container`,preserveObjectStacking:!0},Po=(e,t,n,r)=>{let{target:i,offsetX:a,offsetY:o}=t,s=n-a,c=r-o,l=!on(i,`lockMovementX`)&&i.left!==s,u=!on(i,`lockMovementY`)&&i.top!==c;return l&&i.set(`left`,s),u&&i.set(`top`,c),(l||u)&&ri(ie,sn(e,t,n,r)),l||u},Fo=le,Io=e=>function(t,n,r){let{points:i,pathOffset:a}=r;return new P(i[e]).subtract(a).transform(B(r.getViewportTransform(),r.calcTransformMatrix()))},Lo=(e,t,n,r)=>{let{target:i,pointIndex:a}=t,o=i,s=zt(new P(n,r),void 0,o.calcOwnMatrix());return o.points[a]=s.add(o.pathOffset),o.setDimensions(),o.set(`dirty`,!0),!0},Ro=(e,t)=>function(n,r,i,a){let o=r.target,s=new P(o.points[(e>0?e:o.points.length)-1]),c=s.subtract(o.pathOffset).transform(o.calcOwnMatrix()),l=t(n,{...r,pointIndex:e},i,a),u=s.subtract(o.pathOffset).transform(o.calcOwnMatrix()).subtract(c);return o.left-=u.x,o.top-=u.y,l},zo=e=>ii(Fo,Ro(e,Lo));function Bo(e,t={}){let n={};for(let r=0;r<(typeof e==`number`?e:e.points.length);r++)n[`p${r}`]=new q({actionName:Fo,positionHandler:Io(r),actionHandler:zo(r),...t});return n}let Vo=(e,t,n)=>{let{path:r,pathOffset:i}=e,a=r[t];return new P(a[n]-i.x,a[n+1]-i.y).transform(B(e.getViewportTransform(),e.calcTransformMatrix()))},Ho=(e,t,n,r,i)=>{let{path:a,pathOffset:o}=e,s=a[(r>0?r:a.length)-1],c=new P(s[i],s[i+1]),l=c.subtract(o).transform(e.calcOwnMatrix()),u=zt(new P(t,n),void 0,e.calcOwnMatrix());a[r][i]=u.x+o.x,a[r][i+1]=u.y+o.y,e.setDimensions();let d=c.subtract(e.pathOffset).transform(e.calcOwnMatrix()).subtract(l);return e.left-=d.x,e.top-=d.y,e.set(`dirty`,!0),!0};function Uo(e,t,n){let{commandIndex:r,pointIndex:i}=this;return Vo(n,r,i)}function Wo(e,t,n,r){let{target:i}=t,{commandIndex:a,pointIndex:o}=this,s=Ho(i,n,r,a,o);return s&&ri(this.actionName,{...sn(e,t,n,r),commandIndex:a,pointIndex:o}),s}let Go=e=>e===`C`?5:e===`Q`?3:1;var Ko=class extends q{constructor(e){super(e)}render(e,t,n,r,i){let a={...r,cornerColor:this.controlFill,cornerStrokeColor:this.controlStroke,transparentCorners:!this.controlFill};super.render(e,t,n,a,i)}},qo=class extends Ko{constructor(e){super(e)}render(e,t,n,r,i){let{path:a}=i,{commandIndex:o,pointIndex:s,connectToCommandIndex:c,connectToPointIndex:l}=this;e.save(),e.strokeStyle=this.controlStroke,this.connectionDashArray&&e.setLineDash(this.connectionDashArray);let[u]=a[o],d=Vo(i,c,l);if(u===`Q`){let r=Vo(i,o,s+2);e.moveTo(r.x,r.y),e.lineTo(t,n)}else e.moveTo(t,n);e.lineTo(d.x,d.y),e.stroke(),e.restore(),super.render(e,t,n,r,i)}};let Jo=(e,t,n,r,i,a)=>new(n?qo:Ko)({commandIndex:e,pointIndex:t,actionName:`modifyPath`,positionHandler:Uo,actionHandler:Wo,connectToCommandIndex:i,connectToPointIndex:a,...r,...n?r.controlPointStyle:r.pointStyle});function Yo(e,t={}){let n={},r=`M`;return e.path.forEach((e,i)=>{let a=e[0];switch(a!==`Z`&&(n[`c_${i}_${a}`]=Jo(i,e.length-2,!1,t)),a){case`C`:n[`c_${i}_C_CP_1`]=Jo(i,1,!0,t,i-1,Go(r)),n[`c_${i}_C_CP_2`]=Jo(i,3,!0,t,i,5);break;case`Q`:n[`c_${i}_Q_CP_1`]=Jo(i,1,!0,t,i,3);break}r=a}),n}var Xo=n({changeHeight:()=>ui,changeObjectHeight:()=>ci,changeObjectWidth:()=>si,changeWidth:()=>li,createObjectDefaultControls:()=>Ri,createPathControls:()=>Yo,createPolyActionHandler:()=>zo,createPolyControls:()=>Bo,createPolyPositionHandler:()=>Io,createResizeControls:()=>zi,createTextboxDefaultControls:()=>Bi,dragHandler:()=>Po,factoryPolyActionHandler:()=>Ro,getLocalPoint:()=>un,polyActionHandler:()=>Lo,renderCircleControl:()=>di,renderSquareControl:()=>fi,rotationStyleHandler:()=>pi,rotationWithSnapping:()=>mi,scaleCursorStyleHandler:()=>vi,scaleOrSkewActionName:()=>Pi,scaleSkewCursorStyleHandler:()=>Fi,scalingEqually:()=>Ci,scalingX:()=>wi,scalingXOrSkewingY:()=>Ii,scalingY:()=>Ti,scalingYOrSkewingX:()=>Li,skewCursorStyleHandler:()=>Oi,skewHandlerX:()=>ji,skewHandlerY:()=>Mi,wrapWithFireEvent:()=>ii,wrapWithFixedAnchor:()=>ai}),Zo=class e extends Tt{constructor(...e){super(...e),o(this,`_hoveredTargets`,[]),o(this,`_currentTransform`,null),o(this,`_groupSelector`,null),o(this,`contextTopDirty`,!1)}static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}get upperCanvasEl(){var e;return(e=this.elements.upper)==null?void 0:e.el}get contextTop(){var e;return(e=this.elements.upper)==null?void 0:e.ctx}get wrapperEl(){return this.elements.container}initElements(e){this.elements=new Mo(e,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(e){this._objectsToRender=void 0,super._onObjectAdded(e)}_onObjectRemoved(e){this._objectsToRender=void 0,e===this._activeObject&&(this.fire(`before:selection:cleared`,{deselected:[e]}),this._discardActiveObject(),this.fire(`selection:cleared`,{deselected:[e]}),e.fire(`deselected`,{target:e})),e===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(e)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){let e=this._activeObject;return!this.preserveObjectStacking&&e?this._objects.filter(t=>!t.group&&t!==e).concat(e):this._objects}renderAll(){this.cancelRequestedRender(),!this.destroyed&&(this.contextTopDirty&&!this._groupSelector&&!this.isDrawingMode&&(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(e){e.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(e),this.contextTopDirty=!0),e.restore()}renderTop(){let e=this.contextTop;this.clearContext(e),this.renderTopLayer(e),this.fire(`after:render`,{ctx:e})}setTargetFindTolerance(e){e=Math.round(e),this.targetFindTolerance=e;let t=this.getRetinaScaling(),n=Math.ceil((e*2+1)*t);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=n,this.pixelFindContext.scale(t,t)}isTargetTransparent(e,t,n){let r=this.targetFindTolerance,i=this.pixelFindContext;this.clearContext(i),i.save(),i.translate(-t+r,-n+r),i.transform(...this.viewportTransform);let a=e.selectionBackgroundColor;e.selectionBackgroundColor=``,e.render(i),e.selectionBackgroundColor=a,i.restore();let o=Math.round(r*this.getRetinaScaling());return Ui(i,o,o,o)}_isSelectionKeyPressed(e){let t=this.selectionKey;return t?Array.isArray(t)?!!t.find(t=>!!t&&e[t]===!0):e[t]:!1}_shouldClearSelection(e,t){let n=this.getActiveObjects(),r=this._activeObject;return!!(!t||t&&r&&n.length>1&&n.indexOf(t)===-1&&r!==t&&!this._isSelectionKeyPressed(e)||t&&!t.evented||t&&!t.selectable&&r&&r!==t)}_shouldCenterTransform(e,t,n){if(!e)return;let r;return t===`scale`||t===`scaleX`||t===`scaleY`||t===`resizing`?r=this.centeredScaling||e.centeredScaling:t===`rotate`&&(r=this.centeredRotation||e.centeredRotation),r?!n:n}_getOriginFromCorner(e,t){let n=t?e.controls[t].getTransformAnchorPoint():{x:e.originX,y:e.originY};return t?([`ml`,`tl`,`bl`].includes(t)?n.x=k:[`mr`,`tr`,`br`].includes(t)&&(n.x=O),[`tl`,`mt`,`tr`].includes(t)?n.y=te:[`bl`,`mb`,`br`].includes(t)&&(n.y=`top`),n):n}_setupCurrentTransform(e,t,n){var r;let i=t.group?zt(this.getScenePoint(e),void 0,t.group.calcTransformMatrix()):this.getScenePoint(e),{key:a=``,control:o}=t.getActiveControl()||{},s=n&&o?(r=o.getActionHandler(e,t,o))==null?void 0:r.bind(o):Po,c=nn(n,a,e,t),l=e[this.centeredKey],u=this._shouldCenterTransform(t,c,l)?{x:D,y:D}:this._getOriginFromCorner(t,a),{scaleX:d,scaleY:f,skewX:p,skewY:m,left:h,top:g,angle:_,width:v,height:y,cropX:b,cropY:x}=t,S={target:t,action:c,actionHandler:s,actionPerformed:!1,corner:a,scaleX:d,scaleY:f,skewX:p,skewY:m,offsetX:i.x-h,offsetY:i.y-g,originX:u.x,originY:u.y,ex:i.x,ey:i.y,lastX:i.x,lastY:i.y,theta:L(_),width:v,height:y,shiftKey:e.shiftKey,altKey:l,original:{...It(t),originX:u.x,originY:u.y,cropX:b,cropY:x}};this._currentTransform=S,this.fire(`before:transform`,{e,transform:S})}setCursor(e){this.upperCanvasEl.style.cursor=e}_drawSelection(e){let{x:t,y:n,deltaX:r,deltaY:i}=this._groupSelector,a=new P(t,n).transform(this.viewportTransform),o=new P(t+r,n+i).transform(this.viewportTransform),s=this.selectionLineWidth/2,c=Math.min(a.x,o.x),l=Math.min(a.y,o.y),u=Math.max(a.x,o.x),d=Math.max(a.y,o.y);this.selectionColor&&(e.fillStyle=this.selectionColor,e.fillRect(c,l,u-c,d-l)),!(!this.selectionLineWidth||!this.selectionBorderColor)&&(e.lineWidth=this.selectionLineWidth,e.strokeStyle=this.selectionBorderColor,c+=s,l+=s,u-=s,d-=s,J.prototype._setLineDash.call(this,e,this.selectionDashArray),e.strokeRect(c,l,u-c,d-l))}findTarget(e){if(this._targetInfo)return this._targetInfo;if(this.skipTargetFind)return{subTargets:[],currentSubTargets:[]};let t=this.getScenePoint(e),n=this._activeObject,r=this.getActiveObjects(),i=this.searchPossibleTargets(this._objects,t),{subTargets:a,container:o,target:s}=i,c={...i,currentSubTargets:a,currentContainer:o,currentTarget:s};if(!n)return c;let l={...this.searchPossibleTargets([n],t),currentSubTargets:a,currentContainer:o,currentTarget:s};return n.findControl(this.getViewportPoint(e),kt(e))?{...l,target:n}:l.target&&(r.length>1||!this.preserveObjectStacking||this.preserveObjectStacking&&e[this.altSelectionKey])?l:c}_pointIsInObjectSelectionArea(e,t){let n=e.getCoords(),r=this.getZoom(),i=e.padding/r;if(i){let[e,t,r,a]=n,o=Math.atan2(t.y-e.y,t.x-e.x),s=Ce(o)*i,c=N(o)*i,l=s+c,u=s-c;n=[new P(e.x-u,e.y-l),new P(t.x+l,t.y-u),new P(r.x+u,r.y+l),new P(a.x-l,a.y+u)]}return ei.isPointInPolygon(t,n)}_checkTarget(e,t){if(e&&e.visible&&e.evented&&this._pointIsInObjectSelectionArea(e,t))if((this.perPixelTargetFind||e.perPixelTargetFind)&&!e.isEditing){let n=t.transform(this.viewportTransform);if(!this.isTargetTransparent(e,n.x,n.y))return!0}else return!0;return!1}_searchPossibleTargets(e,t,n){let r=e.length;for(;r--;){let i=e[r];if(this._checkTarget(i,t)){if(Te(i)&&i.subTargetCheck){let{target:e}=this._searchPossibleTargets(i._objects,t,n);e&&n.push(e)}return{target:i,subTargets:n}}}return{subTargets:[]}}searchPossibleTargets(e,t){let n=this._searchPossibleTargets(e,t,[]);n.container=n.target;let{container:r,subTargets:i}=n;if(r&&Te(r)&&r.interactive&&i[0]){for(let e=i.length-1;e>0;e--){let t=i[e];if(!(Te(t)&&t.interactive))return n.target=t,n}return n.target=i[0],n}return n}getViewportPoint(e){return this._viewportPoint?this._viewportPoint:this._getPointerImpl(e,!0)}getScenePoint(e){return this._scenePoint?this._scenePoint:this._getPointerImpl(e)}_getPointerImpl(e,t=!1){let n=this.upperCanvasEl,r=n.getBoundingClientRect(),i=Ot(e),a=r.width||0,o=r.height||0;(!a||!o)&&(`top`in r&&`bottom`in r&&(o=Math.abs(r.top-r.bottom)),`right`in r&&`left`in r&&(a=Math.abs(r.right-r.left))),this.calcOffset(),i.x-=this._offset.left,i.y-=this._offset.top,t||(i=zt(i,void 0,this.viewportTransform));let s=this.getRetinaScaling();s!==1&&(i.x/=s,i.y/=s);let c=a===0||o===0?new P(1,1):new P(n.width/a,n.height/o);return i.multiply(c)}_setDimensionsImpl(e,t){this._resetTransformEventData(),super._setDimensionsImpl(e,t),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=F(),this.pixelFindContext=this.pixelFindCanvasEl.getContext(`2d`,{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){let e=this._activeObject;return ct(e)?e.getObjects():e?[e]:[]}_fireSelectionEvents(e,t){let n=!1,r=!1,i=this.getActiveObjects(),a=[],o=[];e.forEach(e=>{i.includes(e)||(n=!0,e.fire(`deselected`,{e:t,target:e}),o.push(e))}),i.forEach(r=>{e.includes(r)||(n=!0,r.fire(`selected`,{e:t,target:r}),a.push(r))}),e.length>0&&i.length>0?(r=!0,n&&this.fire(`selection:updated`,{e:t,selected:a,deselected:o})):i.length>0?(r=!0,this.fire(`selection:created`,{e:t,selected:a})):e.length>0&&(r=!0,this.fire(`selection:cleared`,{e:t,deselected:o})),r&&(this._objectsToRender=void 0)}setActiveObject(e,t){let n=this.getActiveObjects(),r=this._setActiveObject(e,t);return this._fireSelectionEvents(n,t),r}_setActiveObject(e,t){let n=this._activeObject;return n===e||!this._discardActiveObject(t,e)&&this._activeObject||e.onSelect({e:t})?!1:(this._activeObject=e,ct(e)&&n!==e&&e.set(`canvas`,this),e.setCoords(),!0)}_discardActiveObject(e,t){let n=this._activeObject;return n?n.onDeselect({e,object:t})?!1:(this._currentTransform&&this._currentTransform.target===n&&this.endCurrentTransform(e),ct(n)&&n===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0):!1}discardActiveObject(e){let t=this.getActiveObjects(),n=this.getActiveObject();t.length&&this.fire(`before:selection:cleared`,{e,deselected:[n]});let r=this._discardActiveObject(e);return this._fireSelectionEvents(t,e),r}endCurrentTransform(e){let t=this._currentTransform;this._finalizeCurrentTransform(e),t&&t.target&&(t.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(e){let t=this._currentTransform,n=t.target,r={e,target:n,transform:t,action:t.action};n._scaling&&(n._scaling=!1),n.setCoords(),t.actionPerformed&&(this.fire(`object:modified`,r),n.fire(_e,r))}setViewportTransform(e){super.setViewportTransform(e);let t=this._activeObject;t&&t.setCoords()}destroy(){let e=this._activeObject;ct(e)&&(e.removeAll(),e.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(e){let t=this._activeObject;t&&t._renderControls(e)}_toObject(e,t,n){let r=this._realizeGroupTransformOnObject(e),i=super._toObject(e,t,n);return e.set(r),i}_realizeGroupTransformOnObject(e){let{group:t}=e;if(t&&ct(t)&&this._activeObject===t){let n=tt(e,[`angle`,`flipX`,`flipY`,O,fe,pe,me,he,`top`]);return Nt(e,t.calcOwnMatrix()),n}else return{}}_setSVGObject(e,t,n){let r=this._realizeGroupTransformOnObject(t);super._setSVGObject(e,t,n),t.set(r)}};o(Zo,`ownDefaults`,No);var Qo=class{constructor(e){o(this,`targets`,[]),o(this,`__disposer`,void 0);let t=()=>{let{hiddenTextarea:t}=e.getActiveObject()||{};t&&t.focus()},n=e.upperCanvasEl;n.addEventListener(`click`,t),this.__disposer=()=>n.removeEventListener(`click`,t)}exitTextEditing(){this.target=void 0,this.targets.forEach(e=>{e.isEditing&&e.exitEditing()})}add(e){this.targets.push(e)}remove(e){this.unregister(e),Se(this.targets,e)}register(e){this.target=e}unregister(e){e===this.target&&(this.target=void 0)}onMouseMove(e){var t;(t=this.target)!=null&&t.isEditing&&this.target.updateSelectionOnMouseMove(e)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}};let X={passive:!1},$o=(e,t)=>({viewportPoint:e.getViewportPoint(t),scenePoint:e.getScenePoint(t)}),es=(e,...t)=>e.addEventListener(...t),Z=(e,...t)=>e.removeEventListener(...t),ts={mouse:{in:`over`,out:`out`,targetIn:`mouseover`,targetOut:`mouseout`,canvasIn:`mouse:over`,canvasOut:`mouse:out`},drag:{in:`enter`,out:`leave`,targetIn:`dragenter`,targetOut:`dragleave`,canvasIn:`drag:enter`,canvasOut:`drag:leave`}};var ns=class extends Zo{constructor(e,t={}){super(e,t),o(this,`_isClick`,void 0),o(this,`textEditingManager`,new Qo(this)),[`_onMouseDown`,`_onTouchStart`,`_onMouseMove`,`_onMouseUp`,`_onTouchEnd`,`_onResize`,`_onMouseWheel`,`_onMouseOut`,`_onMouseEnter`,`_onContextMenu`,`_onClick`,`_onDragStart`,`_onDragEnd`,`_onDragProgress`,`_onDragOver`,`_onDragEnter`,`_onDragLeave`,`_onDrop`].forEach(e=>{this[e]=this[e].bind(this)}),this.addOrRemove(es)}_getEventPrefix(){return this.enablePointerEvents?`pointer`:`mouse`}addOrRemove(e,t=!1){let n=this.upperCanvasEl,r=this._getEventPrefix();e(dt(n),`resize`,this._onResize),e(n,r+`down`,this._onMouseDown),e(n,`${r}move`,this._onMouseMove,X),e(n,`${r}out`,this._onMouseOut),e(n,`${r}enter`,this._onMouseEnter),e(n,`wheel`,this._onMouseWheel,{passive:!1}),e(n,`contextmenu`,this._onContextMenu),t||(e(n,`click`,this._onClick),e(n,`dblclick`,this._onClick)),e(n,`dragstart`,this._onDragStart),e(n,`dragend`,this._onDragEnd),e(n,`dragover`,this._onDragOver),e(n,`dragenter`,this._onDragEnter),e(n,`dragleave`,this._onDragLeave),e(n,`drop`,this._onDrop),this.enablePointerEvents||e(n,`touchstart`,this._onTouchStart,X)}removeListeners(){this.addOrRemove(Z);let e=this._getEventPrefix(),t=ut(this.upperCanvasEl);Z(t,`${e}up`,this._onMouseUp),Z(t,`touchend`,this._onTouchEnd,X),Z(t,`${e}move`,this._onMouseMove,X),Z(t,`touchmove`,this._onMouseMove,X),clearTimeout(this._willAddMouseDown)}_onMouseWheel(e){this._cacheTransformEventData(e),this._handleEvent(e,`wheel`),this._resetTransformEventData()}_onMouseOut(e){let t=this._hoveredTarget,n={e,...$o(this,e)};this.fire(`mouse:out`,{...n,target:t}),this._hoveredTarget=void 0,t&&t.fire(`mouseout`,{...n}),this._hoveredTargets.forEach(e=>{this.fire(`mouse:out`,{...n,target:e}),e&&e.fire(`mouseout`,{...n})}),this._hoveredTargets=[]}_onMouseEnter(e){let{target:t}=this.findTarget(e);!this._currentTransform&&!t&&(this.fire(`mouse:over`,{e,...$o(this,e)}),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(e){this._isClick=!1;let t=this.getActiveObject();if(t&&t.onDragStart(e)){this._dragSource=t;let n={e,target:t};this.fire(`dragstart`,n),t.fire(`dragstart`,n),es(this.upperCanvasEl,`drag`,this._onDragProgress);return}At(e)}_renderDragEffects(e,t,n){let r=!1,i=this._dropTarget;i&&i!==t&&i!==n&&(i.clearContextTop(),r=!0),t==null||t.clearContextTop(),n!==t&&(n==null||n.clearContextTop());let a=this.contextTop;a.save(),a.transform(...this.viewportTransform),t&&(a.save(),t.transform(a),t.renderDragSourceEffect(e),a.restore(),r=!0),n&&(a.save(),n.transform(a),n.renderDropTargetEffect(e),a.restore(),r=!0),a.restore(),r&&(this.contextTopDirty=!0)}_onDragEnd(e){let{currentSubTargets:t}=this.findTarget(e),n=!!e.dataTransfer&&e.dataTransfer.dropEffect!==`none`,r=n?this._activeObject:void 0,i={e,target:this._dragSource,subTargets:t,dragSource:this._dragSource,didDrop:n,dropTarget:r};Z(this.upperCanvasEl,`drag`,this._onDragProgress),this.fire(`dragend`,i),this._dragSource&&this._dragSource.fire(`dragend`,i),delete this._dragSource,this._onMouseUp(e)}_onDragProgress(e){let t={e,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire(`drag`,t),this._dragSource&&this._dragSource.fire(`drag`,t)}_onDragOver(e){let t=`dragover`,{currentContainer:n,currentSubTargets:r}=this.findTarget(e),i=this._dragSource,a={e,target:n,subTargets:r,dragSource:i,canDrop:!1,dropTarget:void 0},o;this.fire(t,a),this._fireEnterLeaveEvents(e,n,a),n&&(n.canDrop(e)&&(o=n),n.fire(t,a));for(let n=0;n<r.length;n++){let i=r[n];i.canDrop(e)&&(o=i),i.fire(t,a)}this._renderDragEffects(e,i,o),this._dropTarget=o}_onDragEnter(e){let{currentContainer:t,currentSubTargets:n}=this.findTarget(e),r={e,target:t,subTargets:n,dragSource:this._dragSource};this.fire(`dragenter`,r),this._fireEnterLeaveEvents(e,t,r)}_onDragLeave(e){let{currentSubTargets:t}=this.findTarget(e),n={e,target:this._draggedoverTarget,subTargets:t,dragSource:this._dragSource};this.fire(`dragleave`,n),this._fireEnterLeaveEvents(e,void 0,n),this._renderDragEffects(e,this._dragSource),this._dropTarget=void 0,this._hoveredTargets=[]}_onDrop(e){let{currentContainer:t,currentSubTargets:n}=this.findTarget(e),r=this._basicEventHandler(`drop:before`,{e,target:t,subTargets:n,dragSource:this._dragSource,...$o(this,e)});r.didDrop=!1,r.dropTarget=void 0,this._basicEventHandler(`drop`,r),this.fire(`drop:after`,r)}_onContextMenu(e){let{target:t,subTargets:n}=this.findTarget(e),r=this._basicEventHandler(`contextmenu:before`,{e,target:t,subTargets:n});return this.stopContextMenu&&At(e),this._basicEventHandler(`contextmenu`,r),!1}_onClick(e){let t=e.detail;t>3||t<2||(this._cacheTransformEventData(e),t==2&&e.type===`dblclick`&&this._handleEvent(e,`dblclick`),t==3&&this._handleEvent(e,`tripleclick`),this._resetTransformEventData())}fireEventFromPointerEvent(e,t,n,r={}){this._cacheTransformEventData(e);let{target:i,subTargets:a}=this.findTarget(e),o={e,target:i,subTargets:a,...$o(this,e),transform:this._currentTransform,...r};this.fire(t,o),i&&i.fire(n,o);for(let e=0;e<a.length;e++)a[e]!==i&&a[e].fire(n,o);this._resetTransformEventData()}getPointerId(e){let t=e.changedTouches;return t?t[0]&&t[0].identifier:this.enablePointerEvents?e.pointerId:-1}_isMainEvent(e){return e.isPrimary===!0?!0:e.isPrimary===!1?!1:e.type===`touchend`&&e.touches.length===0?!0:e.changedTouches?e.changedTouches[0].identifier===this.mainTouchId:!0}_onTouchStart(e){this._cacheTransformEventData(e);let t=!this.allowTouchScrolling,n=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(e)),this.__onMouseDown(e);let{target:r}=this.findTarget(e);(this.isDrawingMode||n&&r===n)&&(t=!0),t&&e.preventDefault();let i=this.upperCanvasEl,a=this._getEventPrefix(),o=ut(i);es(o,`touchend`,this._onTouchEnd,X),t&&es(o,`touchmove`,this._onMouseMove,X),Z(i,`${a}down`,this._onMouseDown),this._resetTransformEventData()}_onMouseDown(e){this._cacheTransformEventData(e),this.__onMouseDown(e);let t=this.upperCanvasEl,n=this._getEventPrefix();Z(t,`${n}move`,this._onMouseMove,X);let r=ut(t);es(r,`${n}up`,this._onMouseUp),es(r,`${n}move`,this._onMouseMove,X),this._resetTransformEventData()}_onTouchEnd(e){if(e.touches.length>0)return;this._cacheTransformEventData(e),this.__onMouseUp(e),this._resetTransformEventData(),delete this.mainTouchId;let t=this._getEventPrefix(),n=ut(this.upperCanvasEl);Z(n,`touchend`,this._onTouchEnd,X),Z(n,`touchmove`,this._onMouseMove,X),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{es(this.upperCanvasEl,`${t}down`,this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(e){this._cacheTransformEventData(e),this.__onMouseUp(e);let t=this.upperCanvasEl,n=this._getEventPrefix();if(this._isMainEvent(e)){let e=ut(this.upperCanvasEl);Z(e,`${n}up`,this._onMouseUp),Z(e,`${n}move`,this._onMouseMove,X),es(t,`${n}move`,this._onMouseMove,X)}this._resetTransformEventData()}_onMouseMove(e){this._cacheTransformEventData(e);let t=this.getActiveObject();!this.allowTouchScrolling&&(!t||!t.shouldStartDragging(e))&&e.preventDefault&&e.preventDefault(),this.__onMouseMove(e),this._resetTransformEventData()}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(e){let t=this.getActiveObject();return!!t!=!!e||t&&e&&t!==e}__onMouseUp(e){var t;this._handleEvent(e,`up:before`);let n=this._currentTransform,r=this._isClick,{target:i}=this.findTarget(e),{button:a}=e;if(a){(this.fireMiddleClick&&a===1||this.fireRightClick&&a===2)&&this._handleEvent(e,`up`);return}if(this.isDrawingMode&&this._isCurrentlyDrawing){this._onMouseUpInDrawingMode(e);return}if(!this._isMainEvent(e))return;let o=!1;if(n&&(this._finalizeCurrentTransform(e),o=n.actionPerformed),!r){let t=i===this._activeObject;this.handleSelection(e),o||(o=this._shouldRender(i)||!t&&i===this._activeObject)}let s,c;if(i){let{key:t,control:r}=i.findControl(this.getViewportPoint(e),kt(e))||{};if(c=t,i.selectable&&i!==this._activeObject&&i.activeOn===`up`)this.setActiveObject(i,e),o=!0;else if(r){let t=r.getMouseUpHandler(e,i,r);t&&(s=this.getScenePoint(e),t.call(r,e,n,s.x,s.y))}i.isMoving=!1}if(n&&(n.target!==i||n.corner!==c)){let t=n.target&&n.target.controls[n.corner],r=t&&t.getMouseUpHandler(e,n.target,t);s=s||this.getScenePoint(e),r&&r.call(t,e,n,s.x,s.y)}this._setCursorFromEvent(e,i),this._handleEvent(e,`up`),this._groupSelector=null,this._currentTransform=null,i&&(i.__corner=void 0),o?this.requestRenderAll():!r&&!((t=this._activeObject)!=null&&t.isEditing)&&this.renderTop()}_basicEventHandler(e,t){let{target:n,subTargets:r=[]}=t;this.fire(e,t),n&&n.fire(e,t);for(let i=0;i<r.length;i++)r[i]!==n&&r[i].fire(e,t);return t}_handleEvent(e,t,n){let{target:r,subTargets:i}=this.findTarget(e),a={e,target:r,subTargets:i,...$o(this,e),transform:this._currentTransform,...t===`down:before`||t===`down`?n:{}};(t===`up:before`||t===`up`)&&(a.isClick=this._isClick),this.fire(`mouse:${t}`,a),r&&r.fire(`mouse${t}`,a);for(let e=0;e<i.length;e++)i[e]!==r&&i[e].fire(`mouse${t}`,a)}_onMouseDownInDrawingMode(e){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(e),this.requestRenderAll());let t=this.getScenePoint(e);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(t,{e,pointer:t}),this._handleEvent(e,`down`,{alreadySelected:!1})}_onMouseMoveInDrawingMode(e){if(this._isCurrentlyDrawing){let t=this.getScenePoint(e);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(t,{e,pointer:t})}this.setCursor(this.freeDrawingCursor),this._handleEvent(e,`move`)}_onMouseUpInDrawingMode(e){let t=this.getScenePoint(e);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e,pointer:t}):this._isCurrentlyDrawing=!1,this._handleEvent(e,`up`)}__onMouseDown(e){this._isClick=!0,this._handleEvent(e,`down:before`);let{target:t}=this.findTarget(e),n=!!t&&t===this._activeObject,{button:r}=e;if(r){(this.fireMiddleClick&&r===1||this.fireRightClick&&r===2)&&this._handleEvent(e,`down`,{alreadySelected:n});return}if(this.isDrawingMode){this._onMouseDownInDrawingMode(e);return}if(!this._isMainEvent(e)||this._currentTransform)return;let i=this._shouldRender(t),a=!1;if(this.handleMultiSelection(e,t)?(t=this._activeObject,a=!0,i=!0):this._shouldClearSelection(e,t)&&this.discardActiveObject(e),this.selection&&(!t||!t.selectable&&!t.isEditing&&t!==this._activeObject)){let t=this.getScenePoint(e);this._groupSelector={x:t.x,y:t.y,deltaY:0,deltaX:0}}if(n=!!t&&t===this._activeObject,t){t.selectable&&t.activeOn===`down`&&this.setActiveObject(t,e);let r=t.findControl(this.getViewportPoint(e),kt(e));if(t===this._activeObject&&(r||!a)){this._setupCurrentTransform(e,t,n);let i=r?r.control:void 0,a=this.getScenePoint(e),o=i&&i.getMouseDownHandler(e,t,i);o&&o.call(i,e,this._currentTransform,a.x,a.y)}}i&&(this._objectsToRender=void 0),this._handleEvent(e,`down`,{alreadySelected:n}),i&&this.requestRenderAll()}_resetTransformEventData(){this._targetInfo=this._viewportPoint=this._scenePoint=void 0}_cacheTransformEventData(e){this._resetTransformEventData(),this._viewportPoint=this.getViewportPoint(e),this._scenePoint=zt(this._viewportPoint,void 0,this.viewportTransform),this._targetInfo=this.findTarget(e),this._currentTransform&&(this._targetInfo.target=this._currentTransform.target)}__onMouseMove(e){if(this._isClick=!1,this._handleEvent(e,`move:before`),this.isDrawingMode){this._onMouseMoveInDrawingMode(e);return}if(!this._isMainEvent(e))return;let t=this._groupSelector;if(t){let n=this.getScenePoint(e);t.deltaX=n.x-t.x,t.deltaY=n.y-t.y,this.renderTop()}else if(this._currentTransform)this._transformObject(e);else{let{target:t}=this.findTarget(e);this._setCursorFromEvent(e,t),this._fireOverOutEvents(e,t)}this.textEditingManager.onMouseMove(e),this._handleEvent(e,`move`)}_fireOverOutEvents(e,t){let{_hoveredTarget:n,_hoveredTargets:r}=this,{subTargets:i,currentTarget:a}=this.findTarget(e),o=Math.max(r.length,i.length);this.fireSyntheticInOutEvents(`mouse`,{e,target:t,oldTarget:n,actualTarget:a,oldActualTarget:this._hoveredActualTarget,fireCanvas:!0});for(let a=0;a<o;a++)i[a]===t||r[a]&&r[a]===n||this.fireSyntheticInOutEvents(`mouse`,{e,target:i[a],oldTarget:r[a]});this._hoveredActualTarget=a,this._hoveredTarget=t,this._hoveredTargets=i}_fireEnterLeaveEvents(e,t,n){let r=this._draggedoverTarget,i=this._hoveredTargets,{subTargets:a}=this.findTarget(e),o=Math.max(i.length,a.length);this.fireSyntheticInOutEvents(`drag`,{...n,target:t,oldTarget:r,fireCanvas:!0});for(let e=0;e<o;e++)this.fireSyntheticInOutEvents(`drag`,{...n,target:a[e],oldTarget:i[e]});this._draggedoverTarget=t}fireSyntheticInOutEvents(e,{target:t,oldTarget:n,actualTarget:r,oldActualTarget:i,fireCanvas:a,e:o,...s}){let{targetIn:c,targetOut:l,canvasIn:u,canvasOut:d}=ts[e],f=n!==t,p=i!==r,m=t&&f,h=r&&p,g=n&&f,_=i&&p,v={...s,e:o,...$o(this,o)},y={...v,target:n,nextTarget:t,actualTarget:i,nextActualTarget:r};(g||_)&&a&&this.fire(d,y),g&&n.fire(l,y),_&&n!==i&&i.fire(l,y);let b={...v,target:t,previousTarget:n,actualTarget:r,previousActualTarget:i};(m||h)&&a&&this.fire(u,b),m&&t.fire(c,b),h&&r!==t&&r.fire(c,b)}_transformObject(e){let t=this.getScenePoint(e),n=this._currentTransform,r=n.target,i=r.group?zt(t,void 0,r.group.calcTransformMatrix()):t;n.shiftKey=e.shiftKey,n.altKey=!!this.centeredKey&&e[this.centeredKey],this._performTransformAction(e,n,i),n.actionPerformed&&this.requestRenderAll()}_performTransformAction(e,t,n){let{action:r,actionHandler:i,target:a}=t,o=!!i&&i(e,t,n.x,n.y);o&&a.setCoords(),r===`drag`&&o&&(t.target.isMoving=!0,this.setCursor(t.target.moveCursor||this.moveCursor)),t.actionPerformed=t.actionPerformed||o}_setCursorFromEvent(e,t){if(!t){this.setCursor(this.defaultCursor);return}let n=t.hoverCursor||this.hoverCursor,r=ct(this._activeObject)?this._activeObject:null,i=(!r||t.group!==r)&&t.findControl(this.getViewportPoint(e));if(i){let{control:n,coord:r}=i;this.setCursor(n.cursorStyleHandler(e,n,t,r))}else{if(t.subTargetCheck){let{subTargets:t}=this.findTarget(e);t.concat().reverse().forEach(e=>{n=e.hoverCursor||n})}this.setCursor(n)}}handleMultiSelection(e,t){let n=this._activeObject,r=ct(n);if(n&&this._isSelectionKeyPressed(e)&&this.selection&&t&&t.selectable&&(n!==t||r)&&(r||!t.isDescendantOf(n)&&!n.isDescendantOf(t))&&!t.onSelect({e})&&!n.getActiveControl()){if(r){let r=n.getObjects(),i=[];if(t===n){let n=this.getScenePoint(e),a=this.searchPossibleTargets(r,n);if(a.target?(t=a.target,i=a.subTargets):(a=this.searchPossibleTargets(this._objects,n),t=a.target,i=a.subTargets),!t||!t.selectable)return!1}t.group===n?(n.remove(t),this._hoveredTarget=t,this._hoveredTargets=i,n.size()===1&&this._setActiveObject(n.item(0),e)):(n.multiSelectAdd(t),this._hoveredTarget=n,this._hoveredTargets=i),this._fireSelectionEvents(r,e)}else{n.isEditing&&n.exitEditing();let r=new(M.getClass(`ActiveSelection`))([],{canvas:this});r.multiSelectAdd(n,t),this._hoveredTarget=r,this._setActiveObject(r,e),this._fireSelectionEvents([n],e)}return!0}return!1}handleSelection(e){if(!this.selection||!this._groupSelector)return!1;let{x:t,y:n,deltaX:r,deltaY:i}=this._groupSelector,a=new P(t,n),o=a.add(new P(r,i)),s=a.min(o),c=a.max(o).subtract(s),l=this.collectObjects({left:s.x,top:s.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),u=a.eq(o)?l[0]?[l[0]]:[]:l.length>1?l.filter(t=>!t.onSelect({e})).reverse():l;if(u.length===1)this.setActiveObject(u[0],e);else if(u.length>1){let t=M.getClass(`ActiveSelection`);this.setActiveObject(new t(u,{canvas:this}),e)}return this._groupSelector=null,!0}toCanvasElement(e=1,t){let{upper:n}=this.elements;n.ctx=void 0;let r=super.toCanvasElement(e,t);return n.ctx=n.el.getContext(`2d`),r}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}};let rs={x1:0,y1:0,x2:0,y2:0},is={...rs,r1:0,r2:0},as=(e,t)=>isNaN(e)&&typeof t==`number`?t:e;function os(e){return e&&/%$/.test(e)&&Number.isFinite(parseFloat(e))}function ss(e,t){return ar(0,as(typeof e==`number`?e:typeof e==`string`?parseFloat(e)/(os(e)?100:1):NaN,t),1)}let cs=/\s*;\s*/,ls=/\s*:\s*/;function us(e,t){let n,r,i=e.getAttribute(`style`);if(i){let e=i.split(cs);e[e.length-1]===``&&e.pop();for(let t=e.length;t--;){let[i,a]=e[t].split(ls).map(e=>e.trim());i===`stop-color`?n=a:i===`stop-opacity`&&(r=a)}}n=n||e.getAttribute(`stop-color`)||`rgb(0,0,0)`,r=as(parseFloat(r||e.getAttribute(`stop-opacity`)||``),1);let a=new G(n);return a.setAlpha(a.getAlpha()*r*t),{offset:ss(e.getAttribute(`offset`),0),color:a.toRgba()}}function ds(e,t){let n=[],r=e.getElementsByTagName(`stop`),i=ss(t,1);for(let e=r.length;e--;)n.push(us(r[e],i));return n}function fs(e){return e.nodeName===`linearGradient`||e.nodeName===`LINEARGRADIENT`?`linear`:`radial`}function ps(e){return e.getAttribute(`gradientUnits`)===`userSpaceOnUse`?`pixels`:`percentage`}function ms(e,{width:t,height:n,gradientUnits:r}){let i;return Object.entries(e).reduce((e,[a,o])=>{if(o===`Infinity`)i=1;else if(o===`-Infinity`)i=0;else{let e=typeof o==`string`;i=e?parseFloat(o):o,e&&os(o)&&(i*=.01,r===`pixels`&&((a===`x1`||a===`x2`||a===`r2`)&&(i*=t),(a===`y1`||a===`y2`)&&(i*=n)))}return e[a]=i,e},{})}function hs(e,t){return e.getAttribute(t)}function gs(e){return{x1:hs(e,`x1`)||0,y1:hs(e,`y1`)||0,x2:hs(e,`x2`)||`100%`,y2:hs(e,`y2`)||0}}function _s(e){return{x1:hs(e,`fx`)||hs(e,`cx`)||`50%`,y1:hs(e,`fy`)||hs(e,`cy`)||`50%`,r1:0,x2:hs(e,`cx`)||`50%`,y2:hs(e,`cy`)||`50%`,r2:hs(e,`r`)||`50%`}}function vs(e,t){return ms(fs(e)===`linear`?gs(e):_s(e),{...t,gradientUnits:ps(e)})}var ys=class{constructor(e){let{type:t=`linear`,gradientUnits:n=`pixels`,coords:r={},colorStops:i=[],offsetX:a=0,offsetY:o=0,gradientTransform:s,id:c}=e||{};Object.assign(this,{type:t,gradientUnits:n,coords:{...t===`radial`?is:rs,...r},colorStops:i,offsetX:a,offsetY:o,gradientTransform:s,id:c?`${c}_${je()}`:je()})}addColorStop(e){for(let t in e)this.colorStops.push({offset:parseFloat(t),color:e[t]});return this}toObject(e){return{...tt(this,e),type:this.type,coords:{...this.coords},colorStops:this.colorStops.map(e=>({...e})),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0}}toSVG(e,{additionalTransform:t}={}){let n=[],r=this.gradientTransform?this.gradientTransform.concat():E.concat(),i=this.gradientUnits===`pixels`?`userSpaceOnUse`:`objectBoundingBox`,a=this.colorStops.map(e=>({...e})).sort((e,t)=>e.offset-t.offset),o=-this.offsetX,s=-this.offsetY;i===`objectBoundingBox`?(o/=e.width,s/=e.height):(o+=e.width/2,s+=e.height/2),st(e)&&this.gradientUnits!==`percentage`&&(o-=e.pathOffset.x,s-=e.pathOffset.y),r[4]-=o,r[5]-=s;let c=[`id="SVGID_${U(String(this.id))}"`,`gradientUnits="${i}"`,`gradientTransform="${t?t+` `:``}${rt(r)}"`,``].join(` `),l=e=>parseFloat(String(e));if(this.type===`linear`){let{x1:e,y1:t,x2:r,y2:i}=this.coords,a=l(e),o=l(t),s=l(r),u=l(i);n.push(`<linearGradient `,c,` x1="`,a,`" y1="`,o,`" x2="`,s,`" y2="`,u,`">
18
+ `)}else if(this.type===`radial`){let{x1:e,y1:t,x2:r,y2:i,r1:o,r2:s}=this.coords,u=l(e),d=l(t),f=l(r),p=l(i),m=l(o),h=l(s),g=m>h;n.push(`<radialGradient `,c,` cx="`,g?u:f,`" cy="`,g?d:p,`" r="`,g?m:h,`" fx="`,g?f:u,`" fy="`,g?p:d,`">
19
+ `),g&&(a.reverse(),a.forEach(e=>{e.offset=1-e.offset}));let _=Math.min(m,h);if(_>0){let e=_/Math.max(m,h);a.forEach(t=>{t.offset+=e*(1-t.offset)})}}return a.forEach(({color:e,offset:t})=>{let r=String(e),i=fn(r)?r:new G(r).toRgba();n.push(`<stop offset="${t*100}%" style="stop-color:${U(i)};"/>\n`)}),n.push(this.type===`linear`?`</linearGradient>`:`</radialGradient>`,`
20
+ `),n.join(``)}toLive(e){let{x1:t,y1:n,x2:r,y2:i,r1:a,r2:o}=this.coords,s=this.type===`linear`?e.createLinearGradient(t,n,r,i):e.createRadialGradient(t,n,a,r,i,o);return this.colorStops.forEach(({color:e,offset:t})=>{s.addColorStop(t,e)}),s}static async fromObject(e){let{colorStops:t,gradientTransform:n}=e;return new this({...e,colorStops:t?t.map(e=>({...e})):void 0,gradientTransform:n?[...n]:void 0})}static fromElement(e,t,n){let r=ps(e),i=t._findCenterFromElement();return new this({id:e.getAttribute(`id`)||void 0,type:fs(e),coords:vs(e,{width:n.viewBoxWidth||n.width,height:n.viewBoxHeight||n.height}),colorStops:ds(e,n.opacity),gradientUnits:r,gradientTransform:ya(e.getAttribute(`gradientTransform`)||``),...r===`pixels`?{offsetX:t.width/2-i.x,offsetY:t.height/2-i.y}:{offsetX:0,offsetY:0}})}};o(ys,`type`,`Gradient`),M.setClass(ys,`gradient`),M.setClass(ys,`linear`),M.setClass(ys,`radial`);var bs=class{get type(){return`pattern`}set type(e){l(`warn`,`Setting type has no effect`,e)}constructor(e){o(this,`repeat`,`repeat`),o(this,`offsetX`,0),o(this,`offsetY`,0),o(this,`crossOrigin`,``),this.id=je(),Object.assign(this,e)}isImageSource(){return!!this.source&&typeof this.source.src==`string`}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():``}toLive(e){return!this.source||this.isImageSource()&&(!this.source.complete||this.source.naturalWidth===0||this.source.naturalHeight===0)?null:e.createPattern(this.source,this.repeat)}toObject(e=[]){let{repeat:t,crossOrigin:n}=this;return{...tt(this,e),type:`pattern`,source:this.sourceToString(),repeat:t,crossOrigin:n,offsetX:V(this.offsetX,c.NUM_FRACTION_DIGITS),offsetY:V(this.offsetY,c.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null}}toSVG({width:e,height:t}){let{source:n,repeat:r,id:i}=this,a=as(this.offsetX/e,0),o=as(this.offsetY/t,0),s=r===`repeat-y`||r===`no-repeat`?1+Math.abs(a||0):as(n.width/e,0),c=r===`repeat-x`||r===`no-repeat`?1+Math.abs(o||0):as(n.height/t,0);return[`<pattern id="SVGID_${U(i)}" x="${a}" y="${o}" width="${s}" height="${c}">`,`<image x="0" y="0" width="${n.width}" height="${n.height}" xlink:href="${U(this.sourceToString())}"></image>`,`</pattern>`,``].join(`
21
+ `)}static async fromObject({type:e,source:t,patternTransform:n,...r},i){let a=await Qe(t,{...i,crossOrigin:r.crossOrigin});return new this({...r,patternTransform:n&&n.slice(0),source:a})}};o(bs,`type`,`Pattern`),M.setClass(bs),M.setClass(bs,`pattern`);var xs=class{constructor(e){o(this,`color`,`rgb(0, 0, 0)`),o(this,`width`,1),o(this,`shadow`,null),o(this,`strokeLineCap`,`round`),o(this,`strokeLineJoin`,`round`),o(this,`strokeMiterLimit`,10),o(this,`strokeDashArray`,null),o(this,`limitedToCanvasSize`,!1),this.canvas=e}_setBrushStyles(e){e.strokeStyle=this.color,e.lineWidth=this.width,e.lineCap=this.strokeLineCap,e.miterLimit=this.strokeMiterLimit,e.lineJoin=this.strokeLineJoin,e.setLineDash(this.strokeDashArray||[])}_saveAndTransform(e){let t=this.canvas.viewportTransform;e.save(),e.transform(t[0],t[1],t[2],t[3],t[4],t[5])}needsFullRender(){return new G(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;let e=this.canvas,t=this.shadow,n=e.contextTop,r=e.getZoom()*e.getRetinaScaling();n.shadowColor=t.color,n.shadowBlur=t.blur*r,n.shadowOffsetX=t.offsetX*r,n.shadowOffsetY=t.offsetY*r}_resetShadow(){let e=this.canvas.contextTop;e.shadowColor=``,e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0}_isOutSideCanvas(e){return e.x<0||e.x>this.canvas.getWidth()||e.y<0||e.y>this.canvas.getHeight()}},Ss=class e extends J{constructor(t,{path:n,left:r,top:i,...a}={}){super(),Object.assign(this,e.ownDefaults),this.setOptions(a),this._setPath(t||[],!0),typeof r==`number`&&this.set(`left`,r),typeof i==`number`&&this.set(`top`,i)}_setPath(e,t){this.path=ro(Array.isArray(e)?e:xo(e)),this.setBoundingBox(t)}_findCenterFromElement(){let e=this._calcBoundsFromPath();return new P(e.left+e.width/2,e.top+e.height/2)}_renderPathCommands(e){let t=-this.pathOffset.x,n=-this.pathOffset.y;e.beginPath();for(let r of this.path)switch(r[0]){case`L`:e.lineTo(r[1]+t,r[2]+n);break;case`M`:e.moveTo(r[1]+t,r[2]+n);break;case`C`:e.bezierCurveTo(r[1]+t,r[2]+n,r[3]+t,r[4]+n,r[5]+t,r[6]+n);break;case`Q`:e.quadraticCurveTo(r[1]+t,r[2]+n,r[3]+t,r[4]+n);break;case`Z`:e.closePath();break}}_render(e){this._renderPathCommands(e),this._renderPaintInOrder(e)}toString(){return`#<Path (${this.complexity()}): { "top": ${this.top}, "left": ${this.left} }>`}toObject(e=[]){return{...super.toObject(e),path:this.path.map(e=>e.slice())}}toDatalessObject(e=[]){let t=this.toObject(e);return this.sourcePath&&(delete t.path,t.sourcePath=this.sourcePath),t}_toSVG(){return[`<path `,`COMMON_PARTS`,`d="${To(this.path,c.NUM_FRACTION_DIGITS)}" stroke-linecap="round" />\n`]}_getOffsetTransform(){let e=c.NUM_FRACTION_DIGITS;return` translate(${V(-this.pathOffset.x,e)}, ${V(-this.pathOffset.y,e)})`}toClipPathSVG(e){let t=this._getOffsetTransform();return` `+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})}toSVG(e){let t=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(e){let{width:t,height:n,pathOffset:r}=this._calcDimensions();this.set({width:t,height:n,pathOffset:r}),e&&this.setPositionByOrigin(r,`center`,`center`)}_calcBoundsFromPath(){let e=[],t=0,n=0,r=0,i=0;for(let a of this.path)switch(a[0]){case`L`:r=a[1],i=a[2],e.push({x:t,y:n},{x:r,y:i});break;case`M`:r=a[1],i=a[2],t=r,n=i;break;case`C`:e.push(...to(r,i,a[1],a[2],a[3],a[4],a[5],a[6])),r=a[5],i=a[6];break;case`Q`:e.push(...to(r,i,a[1],a[2],a[1],a[2],a[3],a[4])),r=a[3],i=a[4];break;case`Z`:r=t,i=n;break}return jt(e)}_calcDimensions(){let e=this._calcBoundsFromPath();return{...e,pathOffset:new P(e.left+e.width/2,e.top+e.height/2)}}static fromObject(e){return this._fromObject(e,{extraParam:`path`})}static async fromElement(e,t,n){let{d:r,...i}=Da(e,this.ATTRIBUTE_NAMES,n);return new this(r,{...i,...t,left:void 0,top:void 0})}};o(Ss,`type`,`Path`),o(Ss,`cacheProperties`,[...sr,`path`,`fillRule`]),o(Ss,`ATTRIBUTE_NAMES`,[...ea,`d`]),M.setClass(Ss),M.setSVGClass(Ss);function Cs(e){return To(e)===`M 0 0 Q 0 0 0 0 L 0 0`}var ws=class e extends xs{constructor(e){super(e),o(this,`decimate`,.4),o(this,`drawStraightLine`,!1),o(this,`straightLineKey`,`shiftKey`),this._points=[],this._hasStraightLine=!1}needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(e,t,n){let r=t.midPointFrom(n);return e.quadraticCurveTo(t.x,t.y,r.x,r.y),r}onMouseDown(e,{e:t}){this.canvas._isMainEvent(t)&&(this.drawStraightLine=!!this.straightLineKey&&t[this.straightLineKey],this._prepareForDrawing(e),this._addPoint(e),this._render())}onMouseMove(t,{e:n}){if(this.canvas._isMainEvent(n)&&(this.drawStraightLine=!!this.straightLineKey&&n[this.straightLineKey],!(this.limitedToCanvasSize===!0&&this._isOutSideCanvas(t))&&this._addPoint(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{let t=this._points,n=t.length,r=this.canvas.contextTop;this._saveAndTransform(r),this.oldEnd&&(r.beginPath(),r.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=e.drawSegment(r,t[n-2],t[n-1]),r.stroke(),r.restore()}}onMouseUp({e}){return this.canvas._isMainEvent(e)?(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1):!0}_prepareForDrawing(e){this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)}_addPoint(e){return this._points.length>1&&e.eq(this._points[this._points.length-1])?!1:(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(e),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(t=this.canvas.contextTop){let n=this._points[0],r=this._points[1];if(this._saveAndTransform(t),t.beginPath(),this._points.length===2&&n.x===r.x&&n.y===r.y){let e=this.width/1e3;n.x-=e,r.x+=e}t.moveTo(n.x,n.y);for(let i=1;i<this._points.length;i++)e.drawSegment(t,n,r),n=this._points[i],r=this._points[i+1];t.lineTo(n.x,n.y),t.stroke(),t.restore()}convertPointsToSVGPath(e){return So(e,this.width/1e3)}createPath(e){let t=new Ss(e,{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,t.shadow=new ir(this.shadow)),t}decimatePoints(e,t){if(e.length<=2)return e;let n=e[0],r,i=(t/this.canvas.getZoom())**2,a=e.length-1,o=[n];for(let t=1;t<a-1;t++)r=(n.x-e[t].x)**2+(n.y-e[t].y)**2,r>=i&&(n=e[t],o.push(n));return o.push(e[a]),o}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));let e=this.convertPointsToSVGPath(this._points);if(Cs(e)){this.canvas.requestRenderAll();return}let t=this.createPath(e);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire(`before:path:created`,{path:t}),this.canvas.add(t),this.canvas.requestRenderAll(),t.setCoords(),this._resetShadow(),this.canvas.fire(`path:created`,{path:t})}};let Ts=[`radius`,`startAngle`,`endAngle`,`counterClockwise`],Es={radius:0,startAngle:0,endAngle:360,counterClockwise:!1};var Ds=class e extends J{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t){super(),Object.assign(this,e.ownDefaults),this.setOptions(t)}_set(e,t){return super._set(e,t),e===`radius`&&this.setRadius(t),this}_render(e){e.beginPath(),e.arc(0,0,this.radius,L(this.startAngle),L(this.endAngle),this.counterClockwise),this._renderPaintInOrder(e)}getRadiusX(){return this.get(`radius`)*this.get(fe)}getRadiusY(){return this.get(`radius`)*this.get(pe)}setRadius(e){this.radius=e,this.set({width:e*2,height:e*2})}toObject(e=[]){return super.toObject([...Ts,...e])}_toSVG(){let{radius:e,startAngle:t,endAngle:n}=this,r=(n-t)%360;if(r===0)return[`<circle `,`COMMON_PARTS`,`cx="0" cy="0" `,`r="`,`${U(e)}`,`" />
22
+ `];{let i=L(t),a=L(n),o=Ce(i)*e,s=N(i)*e,c=Ce(a)*e,l=N(a)*e;return[`<path d="M ${o} ${s} A ${e} ${e} 0 ${+(r>180)} ${+!this.counterClockwise} ${c} ${l}" `,`COMMON_PARTS`,` />
23
+ `]}}static async fromElement(e,t,n){let{left:r=0,top:i=0,radius:a=0,...o}=Da(e,this.ATTRIBUTE_NAMES,n);return new this({...o,radius:a,left:r-a,top:i-a})}static fromObject(e){return super._fromObject(e)}};o(Ds,`type`,`Circle`),o(Ds,`cacheProperties`,[...sr,...Ts]),o(Ds,`ownDefaults`,Es),o(Ds,`ATTRIBUTE_NAMES`,[`cx`,`cy`,`r`,...ea]),M.setClass(Ds),M.setSVGClass(Ds);var Os=class extends xs{constructor(e){super(e),o(this,`width`,10),this.points=[]}drawDot(e){let t=this.addPoint(e),n=this.canvas.contextTop;this._saveAndTransform(n),this.dot(n,t),n.restore()}dot(e,t){e.fillStyle=t.fill,e.beginPath(),e.arc(t.x,t.y,t.radius,0,Math.PI*2,!1),e.closePath(),e.fill()}onMouseDown(e){this.points=[],this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(e)}_render(){let e=this.canvas.contextTop,t=this.points;this._saveAndTransform(e);for(let n=0;n<t.length;n++)this.dot(e,t[n]);e.restore()}onMouseMove(e){this.limitedToCanvasSize===!0&&this._isOutSideCanvas(e)||(this.needsFullRender()?(this.canvas.clearContext(this.canvas.contextTop),this.addPoint(e),this._render()):this.drawDot(e))}onMouseUp(){let e=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;let t=[];for(let e=0;e<this.points.length;e++){let n=this.points[e],r=new Ds({radius:n.radius,left:n.x,top:n.y,originX:D,originY:D,fill:n.fill});this.shadow&&(r.shadow=new ir(this.shadow)),t.push(r)}let n=new Ba(t,{canvas:this.canvas});this.canvas.fire(`before:path:created`,{path:n}),this.canvas.add(n),this.canvas.fire(`path:created`,{path:n}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=e,this.canvas.requestRenderAll()}addPoint({x:e,y:t}){let n={x:e,y:t,radius:Do(Math.max(0,this.width-20),this.width+20)/2,fill:new G(this.color).setAlpha(Do(0,100)/100).toRgba()};return this.points.push(n),n}};function ks(e){let t={},n=[];for(let r=0,i;r<e.length;r++)i=`${e[r].left}${e[r].top}`,t[i]||(t[i]=!0,n.push(e[r]));return n}var As=class extends xs{constructor(e){super(e),o(this,`width`,10),o(this,`density`,20),o(this,`dotWidth`,1),o(this,`dotWidthVariance`,1),o(this,`randomOpacity`,!1),o(this,`optimizeOverlapping`,!0),this.sprayChunks=[],this.sprayChunk=[]}onMouseDown(e){this.sprayChunks=[],this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(e),this.renderChunck(this.sprayChunk)}onMouseMove(e){this.limitedToCanvasSize===!0&&this._isOutSideCanvas(e)||(this.addSprayChunk(e),this.renderChunck(this.sprayChunk))}onMouseUp(){let e=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;let t=[];for(let e=0;e<this.sprayChunks.length;e++){let n=this.sprayChunks[e];for(let e=0;e<n.length;e++){let r=n[e],i=new Aa({width:r.width,height:r.width,left:r.x+1,top:r.y+1,originX:D,originY:D,fill:this.color});t.push(i)}}let n=new Ba(this.optimizeOverlapping?ks(t):t,{objectCaching:!0,subTargetCheck:!1,interactive:!1});this.shadow&&n.set(`shadow`,new ir(this.shadow)),this.canvas.fire(`before:path:created`,{path:n}),this.canvas.add(n),this.canvas.fire(`path:created`,{path:n}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=e,this.canvas.requestRenderAll()}renderChunck(e){let t=this.canvas.contextTop;t.fillStyle=this.color,this._saveAndTransform(t);for(let n=0;n<e.length;n++){let r=e[n];t.globalAlpha=r.opacity,t.fillRect(r.x,r.y,r.width,r.width)}t.restore()}_render(){let e=this.canvas.contextTop;e.fillStyle=this.color,this._saveAndTransform(e);for(let e=0;e<this.sprayChunks.length;e++)this.renderChunck(this.sprayChunks[e]);e.restore()}addSprayChunk(e){this.sprayChunk=[];let t=this.width/2;for(let n=0;n<this.density;n++)this.sprayChunk.push({x:Do(e.x-t,e.x+t),y:Do(e.y-t,e.y+t),width:this.dotWidthVariance?Do(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):this.dotWidth,opacity:this.randomOpacity?Do(0,100)/100:1});this.sprayChunks.push(this.sprayChunk)}},js=class extends ws{constructor(e){super(e)}getPatternSrc(){let e=F(),t=e.getContext(`2d`);return e.width=e.height=25,t&&(t.fillStyle=this.color,t.beginPath(),t.arc(20/2,20/2,20/2,0,Math.PI*2,!1),t.closePath(),t.fill()),e}getPattern(e){return e.createPattern(this.source||this.getPatternSrc(),`repeat`)}_setBrushStyles(e){super._setBrushStyles(e);let t=this.getPattern(e);t&&(e.strokeStyle=t)}createPath(e){let t=super.createPath(e),n=t._getLeftTopCoords().scalarAdd(t.strokeWidth/2);return t.stroke=new bs({source:this.source||this.getPatternSrc(),offsetX:-n.x,offsetY:-n.y}),t}},Ms=class{},Ns=class extends Ms{testPrecision(e,t){let n=`precision ${t} float;\nvoid main(){}`,r=e.createShader(e.FRAGMENT_SHADER);return r?(e.shaderSource(r,n),e.compileShader(r),!!e.getShaderParameter(r,e.COMPILE_STATUS)):!1}queryWebGL(e){let t=e.getContext(`webgl`);t&&(this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.GLPrecision=[`highp`,`mediump`,`lowp`].find(e=>this.testPrecision(t,e)),t.getExtension(`WEBGL_lose_context`).loseContext(),l(`log`,`WebGL: max texture size ${this.maxTextureSize}`))}isSupported(e){return!!this.maxTextureSize&&this.maxTextureSize>=e}};let Ps=[`x1`,`x2`,`y1`,`y2`];var Fs=class e extends J{constructor([t,n,r,i]=[0,0,0,0],a={}){super(),Object.assign(this,e.ownDefaults),this.setOptions(a),this.x1=t,this.x2=r,this.y1=n,this.y2=i,this._setWidthHeight();let{left:o,top:s}=a;typeof o==`number`&&this.set(`left`,o),typeof s==`number`&&this.set(`top`,s)}_setWidthHeight(){let{x1:e,y1:t,x2:n,y2:r}=this;this.width=Math.abs(n-e),this.height=Math.abs(r-t);let{left:i,top:a,width:o,height:s}=jt([{x:e,y:t},{x:n,y:r}]),c=new P(i+o/2,a+s/2);this.setPositionByOrigin(c,D,D)}_set(e,t){return super._set(e,t),Ps.includes(e)&&this._setWidthHeight(),this}_render(e){e.beginPath();let t=this.calcLinePoints();e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.lineWidth=this.strokeWidth;let n=e.strokeStyle;if(H(this.stroke))e.strokeStyle=this.stroke.toLive(e);else{var r;e.strokeStyle=(r=this.stroke)==null?e.fillStyle:r}this.stroke&&this._renderStroke(e),e.strokeStyle=n}_findCenterFromElement(){return new P((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(e=[]){return{...super.toObject(e),...this.calcLinePoints()}}_getNonTransformedDimensions(){let e=super._getNonTransformedDimensions();return this.strokeLineCap===`butt`&&(this.width===0&&(e.y-=this.strokeWidth),this.height===0&&(e.x-=this.strokeWidth)),e}calcLinePoints(){let{x1:e,x2:t,y1:n,y2:r,width:i,height:a}=this,o=e<=t?-.5:.5,s=n<=r?-.5:.5;return{x1:o*i,x2:o*-i,y1:s*a,y2:s*-a}}_toSVG(){let{x1:e,x2:t,y1:n,y2:r}=this.calcLinePoints();return[`<line `,`COMMON_PARTS`,`x1="${e}" y1="${n}" x2="${t}" y2="${r}" />\n`]}static async fromElement(e,t,n){let{x1:r=0,y1:i=0,x2:a=0,y2:o=0,...s}=Da(e,this.ATTRIBUTE_NAMES,n);return new this([r,i,a,o],s)}static fromObject({x1:e,y1:t,x2:n,y2:r,...i}){return this._fromObject({...i,points:[e,t,n,r]},{extraParam:`points`})}};o(Fs,`type`,`Line`),o(Fs,`cacheProperties`,[...sr,...Ps]),o(Fs,`ATTRIBUTE_NAMES`,ea.concat(Ps)),M.setClass(Fs),M.setSVGClass(Fs);let Is={width:100,height:100};var Ls=class e extends J{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t){super(),Object.assign(this,e.ownDefaults),this.setOptions(t)}_render(e){let t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,n),e.lineTo(0,-n),e.lineTo(t,n),e.closePath(),this._renderPaintInOrder(e)}_toSVG(){let e=this.width/2,t=this.height/2;return[`<polygon `,`COMMON_PARTS`,`points="`,`${-e} ${t},0 ${-t},${e} ${t}`,`" />`]}};o(Ls,`type`,`Triangle`),o(Ls,`ownDefaults`,Is),M.setClass(Ls),M.setSVGClass(Ls);let Rs={rx:0,ry:0},zs=[`rx`,`ry`];var Bs=class e extends J{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t){super(),Object.assign(this,e.ownDefaults),this.setOptions(t)}_set(e,t){switch(super._set(e,t),e){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(){return this.get(`rx`)*this.get(fe)}getRy(){return this.get(`ry`)*this.get(pe)}toObject(e=[]){return super.toObject([...zs,...e])}_toSVG(){return[`<ellipse `,`COMMON_PARTS`,`cx="0" cy="0" rx="${U(this.rx)}" ry="${U(this.ry)}" />\n`]}_render(e){e.beginPath(),e.save(),e.transform(1,0,0,this.ry/this.rx,0,0),e.arc(0,0,this.rx,0,T,!1),e.restore(),this._renderPaintInOrder(e)}static async fromElement(e,t,n){let r=Da(e,this.ATTRIBUTE_NAMES,n);return r.left=(r.left||0)-r.rx,r.top=(r.top||0)-r.ry,new this(r)}};o(Bs,`type`,`Ellipse`),o(Bs,`cacheProperties`,[...sr,...zs]),o(Bs,`ownDefaults`,Rs),o(Bs,`ATTRIBUTE_NAMES`,[...ea,`cx`,`cy`,`rx`,`ry`]),M.setClass(Bs),M.setSVGClass(Bs);function Vs(e){if(!e)return[];let t=e.replace(/,/g,` `).trim().split(/\s+/),n=[];for(let e=0;e<t.length;e+=2)n.push({x:parseFloat(t[e]),y:parseFloat(t[e+1])});return n}let Hs={exactBoundingBox:!1};var Us=class e extends J{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t=[],n={}){super(),o(this,`strokeDiff`,void 0),Object.assign(this,e.ownDefaults),this.setOptions(n),this.points=t;let{left:r,top:i}=n;this.initialized=!0,this.setBoundingBox(!0),typeof r==`number`&&this.set(`left`,r),typeof i==`number`&&this.set(`top`,i)}isOpen(){return!0}_projectStrokeOnPoints(e){return Yi(this.points,e,this.isOpen())}_calcDimensions(e){e={scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth,...e||{}};let t=this.exactBoundingBox?this._projectStrokeOnPoints(e).map(e=>e.projectedPoint):this.points;if(t.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new P,strokeOffset:new P,strokeDiff:new P};let n=jt(t),r=Xe({...e,scaleX:1,scaleY:1}),i=jt(this.points.map(e=>R(e,r,!0))),a=new P(this.scaleX,this.scaleY),o=n.left+n.width/2,s=n.top+n.height/2;return this.exactBoundingBox&&(o-=s*Math.tan(L(this.skewX)),s-=o*Math.tan(L(this.skewY))),{...n,pathOffset:new P(o,s),strokeOffset:new P(i.left,i.top).subtract(new P(n.left,n.top)).multiply(a),strokeDiff:new P(n.width,n.height).subtract(new P(i.width,i.height)).multiply(a)}}_findCenterFromElement(){let e=jt(this.points);return new P(e.left+e.width/2,e.top+e.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(e){let{left:t,top:n,width:r,height:i,pathOffset:a,strokeOffset:o,strokeDiff:s}=this._calcDimensions();this.set({width:r,height:i,pathOffset:a,strokeOffset:o,strokeDiff:s}),e&&this.setPositionByOrigin(new P(t+r/2,n+i/2),`center`,`center`)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new P(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(e={}){if(this.exactBoundingBox){let a;if(Object.keys(e).some(e=>this.strokeUniform||this.constructor.layoutProperties.includes(e))){var t,n;let{width:r,height:i}=this._calcDimensions(e);a=new P((t=e.width)==null?r:t,(n=e.height)==null?i:n)}else{var r,i;a=new P((r=e.width)==null?this.width:r,(i=e.height)==null?this.height:i)}return a.multiply(new P(e.scaleX||this.scaleX,e.scaleY||this.scaleY))}else return super._getTransformedDimensions(e)}_set(e,t){let n=this.initialized&&this[e]!==t,r=super._set(e,t);return this.exactBoundingBox&&n&&((e===`scaleX`||e===`scaleY`)&&this.strokeUniform&&this.constructor.layoutProperties.includes(`strokeUniform`)||this.constructor.layoutProperties.includes(e))&&this.setDimensions(),r}toObject(e=[]){return{...super.toObject(e),points:this.points.map(({x:e,y:t})=>({x:e,y:t}))}}_toSVG(){let e=this.pathOffset.x,t=this.pathOffset.y,n=c.NUM_FRACTION_DIGITS,r=this.points.map(({x:r,y:i})=>`${V(r-e,n)},${V(i-t,n)}`).join(` `);return[`<${U(this.constructor.type).toLowerCase()} `,`COMMON_PARTS`,`points="${r}" />\n`]}_render(e){let t=this.points.length,n=this.pathOffset.x,r=this.pathOffset.y;if(!(!t||isNaN(this.points[t-1].y))){e.beginPath(),e.moveTo(this.points[0].x-n,this.points[0].y-r);for(let i=0;i<t;i++){let t=this.points[i];e.lineTo(t.x-n,t.y-r)}!this.isOpen()&&e.closePath(),this._renderPaintInOrder(e)}}complexity(){return this.points.length}static async fromElement(e,t,n){let r=Vs(e.getAttribute(`points`)),{left:i,top:a,...o}=Da(e,this.ATTRIBUTE_NAMES,n);return new this(r,{...o,...t})}static fromObject(e){return this._fromObject(e,{extraParam:`points`})}};o(Us,`ownDefaults`,Hs),o(Us,`type`,`Polyline`),o(Us,`layoutProperties`,[me,he,`strokeLineCap`,`strokeLineJoin`,`strokeMiterLimit`,`strokeWidth`,`strokeUniform`,`points`]),o(Us,`cacheProperties`,[...sr,`points`]),o(Us,`ATTRIBUTE_NAMES`,[...ea]),M.setClass(Us),M.setSVGClass(Us);var Ws=class extends Us{isOpen(){return!1}};o(Ws,`ownDefaults`,Hs),o(Ws,`type`,`Polygon`),M.setClass(Ws),M.setSVGClass(Ws);var Gs=class extends J{isEmptyStyles(e){if(!this.styles||e!==void 0&&!this.styles[e])return!0;let t=e===void 0?this.styles:{line:this.styles[e]};for(let e in t)for(let n in t[e])for(let r in t[e][n])return!1;return!0}styleHas(e,t){if(!this.styles||t!==void 0&&!this.styles[t])return!1;let n=t===void 0?this.styles:{0:this.styles[t]};for(let t in n)for(let r in n[t])if(n[t][r][e]!==void 0)return!0;return!1}cleanStyle(e){if(!this.styles)return!1;let t=this.styles,n=0,r,i,a=!0,o=0;for(let o in t){r=0;for(let s in t[o]){let c=t[o][s]||{},l=c[e]!==void 0;n++,l?(i?c[e]!==i&&(a=!1):i=c[e],c[e]===this[e]&&delete c[e]):a=!1,Object.keys(c).length===0?delete t[o][s]:r++}r===0&&delete t[o]}for(let e=0;e<this._textLines.length;e++)o+=this._textLines[e].length;a&&n===o&&(this[e]=i,this.removeStyle(e))}removeStyle(e){if(!this.styles)return;let t=this.styles,n,r,i;for(r in t){for(i in n=t[r],n)delete n[i][e],Object.keys(n[i]).length===0&&delete n[i];Object.keys(n).length===0&&delete t[r]}}_extendStyles(e,t){let{lineIndex:n,charIndex:r}=this.get2DCursorLocation(e);this._getLineStyle(n)||this._setLineStyle(n);let i=nt({...this._getStyleDeclaration(n,r),...t},e=>e!==void 0);this._setStyleDeclaration(n,r,i)}getSelectionStyles(e,t,n){let r=[];for(let i=e;i<(t||e);i++)r.push(this.getStyleAtPosition(i,n));return r}getStyleAtPosition(e,t){let{lineIndex:n,charIndex:r}=this.get2DCursorLocation(e);return t?this.getCompleteStyleDeclaration(n,r):this._getStyleDeclaration(n,r)}setSelectionStyles(e,t,n){for(let r=t;r<(n||t);r++)this._extendStyles(r,e);this._forceClearCache=!0}_getStyleDeclaration(e,t){var n;let r=this.styles&&this.styles[e];return r?(n=r[t])==null?{}:n:{}}getCompleteStyleDeclaration(e,t){return{...tt(this,this.constructor._styleProperties),...this._getStyleDeclaration(e,t)}}_setStyleDeclaration(e,t,n){this.styles[e][t]=n}_deleteStyleDeclaration(e,t){delete this.styles[e][t]}_getLineStyle(e){return!!this.styles[e]}_setLineStyle(e){this.styles[e]={}}_deleteLineStyle(e){delete this.styles[e]}};o(Gs,`_styleProperties`,Rn);let Ks=/ +/g,qs=/"/g;function Js(e,t,n,r,i){return`\t\t${kn(e,{left:t,top:n,width:r,height:i})}\n`}var Ys=class extends An{_toSVG(){let e=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(e.textTop,e.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(e){let t=this._createBaseSVGMarkup(this._toSVG(),{reviver:e,noStyle:!0,withShadow:!0}),n=this.path;return n?t+n._createBaseSVGMarkup(n._toSVG(),{reviver:e,withShadow:!0,additionalTransform:rt(this.calcOwnMatrix())}):t}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg({textBgRects:e,textSpans:t}){let n=this.getSvgTextDecoration(this);return[e.join(``),` <text xml:space="preserve" `,`font-family="${U(this.fontFamily.replace(qs,`'`))}" `,`font-size="${U(this.fontSize)}" `,this.fontStyle?`font-style="${U(this.fontStyle)}" `:``,this.fontWeight?`font-weight="${U(this.fontWeight)}" `:``,n?`text-decoration="${n}" `:``,this.direction===`rtl`?`direction="rtl" `:``,`style="`,this.getSvgStyles(!0),`"`,this.addPaintOrder(),` >`,t.join(``),`</text>
24
+ `]}_getSVGTextAndBg(e,t){let n=[],r=[],i=e,a;this.backgroundColor&&r.push(Js(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let e=0,o=this._textLines.length;e<o;e++)a=this._getLineLeftOffset(e),this.direction===`rtl`&&(a+=this.width),(this.textBackgroundColor||this.styleHas(`textBackgroundColor`,e))&&this._setSVGTextLineBg(r,e,t+a,i),this._setSVGTextLineText(n,e,t+a,i),i+=this.getHeightOfLine(e);return{textSpans:n,textBgRects:r}}_createTextCharSpan(e,t,n,r,i){let a=c.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,e!==e.trim()||!!e.match(Ks)),s=o?`style="${o}"`:``,l=t.deltaY,u=l?` dy="${V(l,a)}" `:``,{angle:d,renderLeft:f,renderTop:p,width:m}=i,h=``;if(f!==void 0){let e=m/2;d&&(h=` rotate="${V(Le(d),a)}"`);let t=Ge({angle:Le(d)});t[4]=f,t[5]=p;let i=new P(-e,0).transform(t);n=i.x,r=i.y}return`<tspan x="${V(n,a)}" y="${V(r,a)}" ${u}${h}${s}>${U(e)}</tspan>`}_setSVGTextLineText(e,t,n,r){let i=this.getHeightOfLine(t),a=this.textAlign.includes(Bn),o=this._textLines[t],s,c,l=``,u,d,f=0,p;r+=i*(1-this._fontSizeFraction)/this.lineHeight;for(let i=0,m=o.length-1;i<=m;i++)p=i===m||this.charSpacing||this.path,l+=o[i],u=this.__charBounds[t][i],f===0?(n+=u.kernedWidth-u.width,f+=u.width):f+=u.kernedWidth,a&&!p&&this._reSpaceAndTab.test(o[i])&&(p=!0),p||(s=s||this.getCompleteStyleDeclaration(t,i),c=this.getCompleteStyleDeclaration(t,i+1),p=Zi(s,c,!0)),p&&(d=this._getStyleDeclaration(t,i),e.push(this._createTextCharSpan(l,d,n,r,u)),l=``,s=c,this.direction===`rtl`?n-=f:n+=f,f=0)}_setSVGTextLineBg(e,t,n,r){let i=this._textLines[t],a=this.getHeightOfLine(t)/this.lineHeight,o=0,s=0,c,l=this.getValueOfPropertyAt(t,0,`textBackgroundColor`);for(let u=0;u<i.length;u++){let{left:i,width:d,kernedWidth:f}=this.__charBounds[t][u];c=this.getValueOfPropertyAt(t,u,`textBackgroundColor`),c===l?o+=f:(l&&e.push(Js(l,n+s,r,o,a)),s=i,o=d,l=c)}c&&e.push(Js(l,n+s,r,o,a))}getSvgStyles(e){let t=fn(this.textDecorationColor)?` text-decoration-color: ${U(this[Nn])};`:``;return`${super.getSvgStyles(e)} text-decoration-thickness: ${V(this.textDecorationThickness*this.getObjectScaling().y/10,c.NUM_FRACTION_DIGITS)}%;${t} white-space: pre;`}getSvgSpanStyles(e,t){let{fontFamily:n,strokeWidth:r,stroke:i,fill:a,fontSize:o,fontStyle:s,fontWeight:l,textDecorationThickness:u,textDecorationColor:d,linethrough:f,overline:p,underline:m}=e,h=this.getSvgTextDecoration({underline:m==null?this.underline:m,overline:p==null?this.overline:p,linethrough:f==null?this.linethrough:f}),g=u||this.textDecorationThickness,_=d||this.textDecorationColor,v=pn(r),y=mn(n),b=pn(o),x=mn(s),S=pn(l)||mn(l),C=mn(_);return[i?On(ge,i):``,v?`stroke-width: ${U(v)}; `:``,y?`font-family: ${!y.includes(`'`)&&!y.includes(`"`)?`'${U(y)}'`:U(y)}; `:``,b?`font-size: ${U(b)}px; `:``,x?`font-style: ${U(x)}; `:``,S?`font-weight: ${U(S)}; `:``,h?`text-decoration: ${h}; text-decoration-thickness: ${V(g*this.getObjectScaling().y/10,c.NUM_FRACTION_DIGITS)}%;${C?` text-decoration-color: ${U(C)};`:``} `:``,a?On(j,a):``,t?`white-space: pre; `:``].join(``)}getSvgTextDecoration(e){return[`overline`,`underline`,`line-through`].filter(t=>e[t.replace(`-`,``)]).join(` `)}};let Xs;function Zs(){return Xs||(Xs=I({width:0,height:0}).getContext(`2d`)),Xs}var Q=class e extends Gs{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t,n){super(),o(this,`__charBounds`,[]),Object.assign(this,e.ownDefaults),this.setOptions(n),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){let e=this.path;e&&(e.segmentsInfo=ho(e.path))}_splitText(){let e=this._splitTextIntoLines(this.text);return this.textLines=e.lines,this._textLines=e.graphemeLines,this._unwrappedTextLines=e._unwrappedLines,this._text=e.graphemeText,e}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,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.includes(`justify`)&&this.enlargeSpaces()}enlargeSpaces(){let e,t,n,r,i,a,o;for(let s=0,c=this._textLines.length;s<c;s++)if(!(this.textAlign!==`justify`&&(s===c-1||this.isEndOfWrapping(s)))&&(r=0,i=this._textLines[s],t=this.getLineWidth(s),t<this.width&&(o=this.textLines[s].match(this._reSpacesAndTabs)))){n=o.length,e=(this.width-t)/n;for(let t=0;t<=i.length;t++)a=this.__charBounds[s][t],this._reSpaceAndTab.test(i[t])?(a.width+=e,a.kernedWidth+=e,a.left+=r,r+=e):a.left+=r}}isEndOfWrapping(e){return e===this._textLines.length-1}missingNewlineOffset(e){return 1}get2DCursorLocation(e,t){let n=t?this._unwrappedTextLines:this._textLines,r;for(r=0;r<n.length;r++){if(e<=n[r].length)return{lineIndex:r,charIndex:e};e-=n[r].length+this.missingNewlineOffset(r,t)}return{lineIndex:r-1,charIndex:n[r-1].length<e?n[r-1].length:e}}toString(){return`#<Text (${this.complexity()}): { "text": "${this.text}", "fontFamily": "${this.fontFamily}" }>`}_getCacheCanvasDimensions(){let e=super._getCacheCanvasDimensions(),t=this.fontSize;return e.width+=t*e.zoomX,e.height+=t*e.zoomY,e}_render(e){let t=this.path;t&&!t.isNotVisible()&&t._render(e),this._setTextStyles(e),this._renderTextLinesBackground(e),this._renderTextDecoration(e,`underline`),this._renderText(e),this._renderTextDecoration(e,`overline`),this._renderTextDecoration(e,`linethrough`)}_renderText(e){this.paintFirst===`stroke`?(this._renderTextStroke(e),this._renderTextFill(e)):(this._renderTextFill(e),this._renderTextStroke(e))}_setTextStyles(e,t,n){if(e.textBaseline=`alphabetic`,this.path)switch(this.pathAlign){case D:e.textBaseline=`middle`;break;case`ascender`:e.textBaseline=`top`;break;case`descender`:e.textBaseline=te;break}e.font=this._getFontDeclaration(t,n)}calcTextWidth(){let e=this.getLineWidth(0);for(let t=1,n=this._textLines.length;t<n;t++){let n=this.getLineWidth(t);n>e&&(e=n)}return e}_renderTextLine(e,t,n,r,i,a){this._renderChars(e,t,n,r,i,a)}_renderTextLinesBackground(e){if(!this.textBackgroundColor&&!this.styleHas(`textBackgroundColor`))return;let t=e.fillStyle,n=this._getLeftOffset(),r=this._getTopOffset();for(let t=0,i=this._textLines.length;t<i;t++){let i=this.getHeightOfLine(t);if(!this.textBackgroundColor&&!this.styleHas(`textBackgroundColor`,t)){r+=i;continue}let a=this._textLines[t].length,o=this._getLineLeftOffset(t),s=0,c=0,l,u,d=this.getValueOfPropertyAt(t,0,`textBackgroundColor`),f=this.getHeightOfLineImpl(t);for(let i=0;i<a;i++){let a=this.__charBounds[t][i];u=this.getValueOfPropertyAt(t,i,`textBackgroundColor`),this.path?(e.save(),e.translate(a.renderLeft,a.renderTop),e.rotate(a.angle),e.fillStyle=u,u&&e.fillRect(-a.width/2,-f*(1-this._fontSizeFraction),a.width,f),e.restore()):u===d?s+=a.kernedWidth:(l=n+o+c,this.direction===`rtl`&&(l=this.width-l-s),e.fillStyle=d,d&&e.fillRect(l,r,s,f),c=a.left,s=a.width,d=u)}u&&!this.path&&(l=n+o+c,this.direction===`rtl`&&(l=this.width-l-s),e.fillStyle=u,e.fillRect(l,r,s,f)),r+=i}e.fillStyle=t,this._removeShadow(e)}_measureChar(e,t,n,r){let i=b.getFontCache(t),a=this._getFontDeclaration(t),o=n?n+e:e,s=n&&a===this._getFontDeclaration(r),c=t.fontSize/this.CACHE_FONT_SIZE,l,u,d,f;if(n&&i.has(n)&&(d=i.get(n)),i.has(e)&&(f=l=i.get(e)),s&&i.has(o)&&(u=i.get(o),f=u-d),l===void 0||d===void 0||u===void 0){let r=Zs();this._setTextStyles(r,t,!0),l===void 0&&(f=l=r.measureText(e).width,i.set(e,l)),d===void 0&&s&&n&&(d=r.measureText(n).width,i.set(n,d)),s&&u===void 0&&(u=r.measureText(o).width,i.set(o,u),f=u-d)}return{width:l*c,kernedWidth:f*c}}getHeightOfChar(e,t){return this.getValueOfPropertyAt(e,t,`fontSize`)}measureLine(e){let t=this._measureLine(e);return this.charSpacing!==0&&(t.width-=this._getWidthOfCharSpacing()),t.width<0&&(t.width=0),t}_measureLine(e){let t=0,n,r,i=this.pathSide===k,a=this.path,o=this._textLines[e],s=o.length,c=Array(s);this.__charBounds[e]=c;for(let i=0;i<s;i++){let a=o[i];r=this._getGraphemeBox(a,e,i,n),c[i]=r,t+=r.kernedWidth,n=a}if(c[s]={left:r?r.left+r.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},a&&a.segmentsInfo){let e=0,n=a.segmentsInfo[a.segmentsInfo.length-1].length;switch(this.textAlign){case O:e=i?n-t:0;break;case D:e=(n-t)/2;break;case k:e=i?0:n-t;break}e+=this.pathStartOffset*(i?-1:1);for(let t=i?s-1:0;i?t>=0:t<s;i?t--:t++)r=c[t],e>n?e%=n:e<0&&(e+=n),this._setGraphemeOnPath(e,r),e+=r.kernedWidth}return{width:t,numOfSpaces:0}}_setGraphemeOnPath(e,t){let n=e+t.kernedWidth/2,r=this.path,i=go(r.path,n,r.segmentsInfo);t.renderLeft=i.x-r.pathOffset.x,t.renderTop=i.y-r.pathOffset.y,t.angle=i.angle+(this.pathSide===`right`?Math.PI:0)}_getGraphemeBox(e,t,n,r,i){let a=this.getCompleteStyleDeclaration(t,n),o=r?this.getCompleteStyleDeclaration(t,n-1):{},s=this._measureChar(e,a,r,o),c=s.kernedWidth,l=s.width,u;this.charSpacing!==0&&(u=this._getWidthOfCharSpacing(),l+=u,c+=u);let d={width:l,left:0,height:a.fontSize,kernedWidth:c,deltaY:a.deltaY};if(n>0&&!i){let e=this.__charBounds[t][n-1];d.left=e.left+e.width+s.kernedWidth-s.width}return d}getHeightOfLineImpl(e){let t=this.__lineHeights;if(t[e])return t[e];let n=this.getHeightOfChar(e,0);for(let t=1,r=this._textLines[e].length;t<r;t++)n=Math.max(this.getHeightOfChar(e,t),n);return t[e]=n*this._fontSizeMult}getHeightOfLine(e){return this.getHeightOfLineImpl(e)*this.lineHeight}calcTextHeight(){let e=0;for(let t=0,n=this._textLines.length;t<n;t++)e+=t===n-1?this.getHeightOfLineImpl(t):this.getHeightOfLine(t);return e}_getLeftOffset(){return this.direction===`ltr`?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(e,t){e.save();let n=0,r=this._getLeftOffset(),i=this._getTopOffset();for(let a=0,o=this._textLines.length;a<o;a++)this._renderTextLine(t,e,this._textLines[a],r+this._getLineLeftOffset(a),i+n+this.getHeightOfLineImpl(a),a),n+=this.getHeightOfLine(a);e.restore()}_renderTextFill(e){!this.fill&&!this.styleHas(`fill`)||this._renderTextCommon(e,`fillText`)}_renderTextStroke(e){(!this.stroke||this.strokeWidth===0)&&this.isEmptyStyles()||(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(e),e.save(),this._setLineDash(e,this.strokeDashArray),e.beginPath(),this._renderTextCommon(e,`strokeText`),e.closePath(),e.restore())}_renderChars(e,t,n,r,i,a){let o=this.textAlign.includes(Bn),s=this.path,c=!o&&this.charSpacing===0&&this.isEmptyStyles(a)&&!s,l=this.direction===`ltr`,u=this.direction===`ltr`?1:-1,d=t.direction,f,p,m=``,h,g=0,_,v;if(t.save(),d!==this.direction&&(t.canvas.setAttribute(`dir`,l?`ltr`:`rtl`),t.direction=l?`ltr`:`rtl`,t.textAlign=l?O:k),i-=this.getHeightOfLineImpl(a)*this._fontSizeFraction,c){this._renderChar(e,t,a,0,n.join(``),r,i),t.restore();return}for(let c=0,l=n.length-1;c<=l;c++)_=c===l||this.charSpacing||s,m+=n[c],h=this.__charBounds[a][c],g===0?(r+=u*(h.kernedWidth-h.width),g+=h.width):g+=h.kernedWidth,o&&!_&&this._reSpaceAndTab.test(n[c])&&(_=!0),_||(f=f||this.getCompleteStyleDeclaration(a,c),p=this.getCompleteStyleDeclaration(a,c+1),_=Zi(f,p,!1)),_&&(s?(t.save(),t.translate(h.renderLeft,h.renderTop),t.rotate(h.angle),this._renderChar(e,t,a,c,m,-g/2,0),t.restore()):(v=r,this._renderChar(e,t,a,c,m,v,i)),m=``,f=p,r+=u*g,g=0);t.restore()}_applyPatternGradientTransformText(e){let t=this.width+this.strokeWidth,n=this.height+this.strokeWidth,r=I({width:t,height:n}),i=r.getContext(`2d`);return r.width=t,r.height=n,i.beginPath(),i.moveTo(0,0),i.lineTo(t,0),i.lineTo(t,n),i.lineTo(0,n),i.closePath(),i.translate(t/2,n/2),i.fillStyle=e.toLive(i),this._applyPatternGradientTransform(i,e),i.fill(),i.createPattern(r,`no-repeat`)}handleFiller(e,t,n){let r,i;return H(n)?n.gradientUnits===`percentage`||n.gradientTransform||n.patternTransform?(r=-this.width/2,i=-this.height/2,e.translate(r,i),e[t]=this._applyPatternGradientTransformText(n),{offsetX:r,offsetY:i}):(e[t]=n.toLive(e),this._applyPatternGradientTransform(e,n)):(e[t]=n,{offsetX:0,offsetY:0})}_setStrokeStyles(e,{stroke:t,strokeWidth:n}){return e.lineWidth=n,e.lineCap=this.strokeLineCap,e.lineDashOffset=this.strokeDashOffset,e.lineJoin=this.strokeLineJoin,e.miterLimit=this.strokeMiterLimit,this.handleFiller(e,`strokeStyle`,t)}_setFillStyles(e,{fill:t}){return this.handleFiller(e,`fillStyle`,t)}_renderChar(e,t,n,r,i,a,o){let s=this._getStyleDeclaration(n,r),c=this.getCompleteStyleDeclaration(n,r),l=e===`fillText`&&c.fill,u=e===`strokeText`&&c.stroke&&c.strokeWidth;if(!(!u&&!l)){if(t.save(),t.font=this._getFontDeclaration(c),s.textBackgroundColor&&this._removeShadow(t),s.deltaY&&(o+=s.deltaY),l){let e=this._setFillStyles(t,c);t.fillText(i,a-e.offsetX,o-e.offsetY)}if(u){let e=this._setStrokeStyles(t,c);t.strokeText(i,a-e.offsetX,o-e.offsetY)}t.restore()}}setSuperscript(e,t){this._setScript(e,t,this.superscript)}setSubscript(e,t){this._setScript(e,t,this.subscript)}_setScript(e,t,n){let r=this.get2DCursorLocation(e,!0),i=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,`fontSize`),a=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,`deltaY`),o={fontSize:i*n.size,deltaY:a+i*n.baseline};this.setSelectionStyles(o,e,t)}_getLineLeftOffset(e){let t=this.getLineWidth(e),n=this.width-t,r=this.textAlign,i=this.direction,a=this.isEndOfWrapping(e),o=0;return r===`justify`||r===`justify-center`&&!a||r===`justify-right`&&!a||r===`justify-left`&&!a?0:(r===`center`&&(o=n/2),r===`right`&&(o=n),r===`justify-center`&&(o=n/2),r===`justify-right`&&(o=n),i===`rtl`&&(r===`right`||r===`justify-right`?o=0:r===`left`||r===`justify-left`?o=-n:(r===`center`||r===`justify-center`)&&(o=-n/2)),o)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(e){if(this.__lineWidths[e]!==void 0)return this.__lineWidths[e];let{width:t}=this.measureLine(e);return this.__lineWidths[e]=t,t}_getWidthOfCharSpacing(){return this.charSpacing===0?0:this.fontSize*this.charSpacing/1e3}getValueOfPropertyAt(e,t,n){var r;return(r=this._getStyleDeclaration(e,t)[n])==null?this[n]:r}_renderTextDecoration(e,t){if(!this[t]&&!this.styleHas(t))return;let n=this._getTopOffset(),r=this._getLeftOffset(),i=this.path,a=this._getWidthOfCharSpacing(),o=t===`linethrough`?.5:+(t===`overline`),s=this.offsets[t];for(let c=0,l=this._textLines.length;c<l;c++){let l=this.getHeightOfLine(c);if(!this[t]&&!this.styleHas(t,c)){n+=l;continue}let u=this._textLines[c],d=l/this.lineHeight,f=this._getLineLeftOffset(c),p=0,m=0,h=this.getValueOfPropertyAt(c,0,t),g=this.getValueOfPropertyAt(c,0,j),_=this.getValueOfPropertyAt(c,0,`textDecorationColor`)||g,v=this.getValueOfPropertyAt(c,0,Mn),y=h,b,x=_,S=v,C=n+d*(1-this._fontSizeFraction),w=this.getHeightOfChar(c,0),T=this.getValueOfPropertyAt(c,0,`deltaY`);for(let n=0,a=u.length;n<a;n++){let a=this.__charBounds[c][n];y=this.getValueOfPropertyAt(c,n,t),b=this.getValueOfPropertyAt(c,n,j),x=this.getValueOfPropertyAt(c,n,`textDecorationColor`)||b,S=this.getValueOfPropertyAt(c,n,Mn);let l=this.getHeightOfChar(c,n),u=this.getValueOfPropertyAt(c,n,`deltaY`);if(i&&y&&b){let t=this.fontSize*S/1e3;e.save(),e.fillStyle=x,e.translate(a.renderLeft,a.renderTop),e.rotate(a.angle),e.fillRect(-a.kernedWidth/2,s*l+u-o*t,a.kernedWidth,t),e.restore()}else if((y!==h||b!==g||x!==_||l!==w||S!==v||u!==T)&&m>0){let t=this.fontSize*v/1e3,n=r+f+p;this.direction===`rtl`&&(n=this.width-n-m),h&&_&&v&&(e.fillStyle=_,e.fillRect(n,C+s*w+T-o*t,m,t)),p=a.left,m=a.width,h=y,_=x,v=S,g=b,w=l,T=u}else m+=a.kernedWidth}let ee=r+f+p;this.direction===`rtl`&&(ee=this.width-ee-m),e.fillStyle=x;let E=this.fontSize*S/1e3;y&&x&&S&&e.fillRect(ee,C+s*w+T-o*E,m-a,E),n+=l}this._removeShadow(e)}_getFontDeclaration({fontFamily:t=this.fontFamily,fontStyle:n=this.fontStyle,fontWeight:r=this.fontWeight,fontSize:i=this.fontSize}={},a){let o=t.includes(`'`)||t.includes(`"`)||t.includes(`,`)||e.genericFonts.includes(t.toLowerCase())?t:`"${t}"`;return[n,r,`${a?this.CACHE_FONT_SIZE:i}px`,o].join(` `)}render(e){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(e)))}graphemeSplit(e){return St(e)}_splitTextIntoLines(e){let t=e.split(this._reNewline),n=Array(t.length),r=[`
25
+ `],i=[];for(let e=0;e<t.length;e++)n[e]=this.graphemeSplit(t[e]),i=i.concat(n[e],r);return i.pop(),{_unwrappedLines:n,lines:t,graphemeText:i,graphemeLines:n}}toObject(e=[]){return{...super.toObject([...Ln,...e]),styles:Qi(this.styles,this.text),...this.path?{path:this.path.toObject()}:{}}}set(e,t){let{textLayoutProperties:n}=this.constructor;super.set(e,t);let r=!1,i=!1;if(typeof e==`object`)for(let t in e)t===`path`&&this.setPathInfo(),r=r||n.includes(t),i=i||t===`path`;else r=n.includes(e),i=e===`path`;return i&&this.setPathInfo(),r&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,n,r){let i=Da(t,e.ATTRIBUTE_NAMES,r),{textAnchor:a=O,textDecoration:o=``,dx:s=0,dy:c=0,top:l=0,left:u=0,fontSize:d=16,strokeWidth:f=1,...p}={...n,...i},m=hn(t.textContent||``).trim(),h=new this(m,{left:u+s,top:l+c,underline:o.includes(`underline`),overline:o.includes(`overline`),linethrough:o.includes(`line-through`),strokeWidth:0,fontSize:d,...p}),g=h.getScaledHeight()/h.height,_=((h.height+h.strokeWidth)*h.lineHeight-h.height)*g,v=h.getScaledHeight()+_,y=0;return a===`center`&&(y=h.getScaledWidth()/2),a===`right`&&(y=h.getScaledWidth()),h.set({left:h.left-y,top:h.top-(v-h.fontSize*(.07+h._fontSizeFraction))/h.lineHeight,strokeWidth:f}),h}static fromObject(e){return this._fromObject({...e,styles:$i(e.styles||{},e.text)},{extraParam:`text`})}};o(Q,`textLayoutProperties`,In),o(Q,`cacheProperties`,[...sr,...Ln]),o(Q,`ownDefaults`,zn),o(Q,`type`,`Text`),o(Q,`genericFonts`,[`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`,`ui-serif`,`ui-sans-serif`,`ui-monospace`,`ui-rounded`,`math`,`emoji`,`fangsong`]),o(Q,`ATTRIBUTE_NAMES`,ea.concat(`x`,`y`,`dx`,`dy`,`font-family`,`font-style`,`font-weight`,`font-size`,`letter-spacing`,`text-decoration`,`text-decoration-thickness`,`text-decoration-color`,`text-anchor`)),Hi(Q,[Ys]),M.setClass(Q),M.setSVGClass(Q);var Qs=class{constructor(e){o(this,`target`,void 0),o(this,`__mouseDownInPlace`,!1),o(this,`__dragStartFired`,!1),o(this,`__isDraggingOver`,!1),o(this,`__dragStartSelection`,void 0),o(this,`__dragImageDisposer`,void 0),o(this,`_dispose`,void 0),this.target=e;let t=[this.target.on(`dragenter`,this.dragEnterHandler.bind(this)),this.target.on(`dragover`,this.dragOverHandler.bind(this)),this.target.on(`dragleave`,this.dragLeaveHandler.bind(this)),this.target.on(`dragend`,this.dragEndHandler.bind(this)),this.target.on(`drop`,this.dropHandler.bind(this))];this._dispose=()=>{t.forEach(e=>e()),this._dispose=void 0}}isPointerOverSelection(e){let t=this.target,n=t.getSelectionStartFromPointer(e);return t.isEditing&&n>=t.selectionStart&&n<=t.selectionEnd&&t.selectionStart<t.selectionEnd}start(e){return this.__mouseDownInPlace=this.isPointerOverSelection(e)}isActive(){return this.__mouseDownInPlace}end(e){let t=this.isActive();return t&&!this.__dragStartFired&&(this.target.setCursorByClick(e),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,t}getDragStartSelection(){return this.__dragStartSelection}setDragImage(e,{selectionStart:t,selectionEnd:n}){var r;let i=this.target,a=i.canvas,o=new P(i.flipX?-1:1,i.flipY?-1:1),s=i._getCursorBoundaries(t),c=new P(s.left+s.leftOffset,s.top+s.topOffset).multiply(o).transform(i.calcTransformMatrix()),l=a.getScenePoint(e).subtract(c),u=i.getCanvasRetinaScaling(),d=i.getBoundingRect(),f=c.subtract(new P(d.left,d.top)),p=a.viewportTransform,m=f.add(l).transform(p,!0),h=i.backgroundColor,g=Xi(i.styles);i.backgroundColor=``;let _={stroke:`transparent`,fill:`transparent`,textBackgroundColor:`transparent`};i.setSelectionStyles(_,0,t),i.setSelectionStyles(_,n,i.text.length),i.dirty=!0;let v=i.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});i.backgroundColor=h,i.styles=g,i.dirty=!0,jo(v,{position:`fixed`,left:`${-v.width}px`,border:ne,width:`${v.width/u}px`,height:`${v.height/u}px`}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{v.remove()},ut(e.target||this.target.hiddenTextarea).body.appendChild(v),(r=e.dataTransfer)==null||r.setDragImage(v,m.x,m.y)}onDragStart(e){this.__dragStartFired=!0;let t=this.target,n=this.isActive();if(n&&e.dataTransfer){let n=this.__dragStartSelection={selectionStart:t.selectionStart,selectionEnd:t.selectionEnd},r=t._text.slice(n.selectionStart,n.selectionEnd).join(``),i={text:t.text,value:r,...n};e.dataTransfer.setData(`text/plain`,r),e.dataTransfer.setData(`application/fabric`,JSON.stringify({value:r,styles:t.getSelectionStyles(n.selectionStart,n.selectionEnd,!0)})),e.dataTransfer.effectAllowed=`copyMove`,this.setDragImage(e,i)}return t.abortCursorAnimation(),n}canDrop(e){if(this.target.editable&&!this.target.getActiveControl()&&!e.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){let t=this.target.getSelectionStartFromPointer(e),n=this.__dragStartSelection;return t<n.selectionStart||t>n.selectionEnd}return!0}return!1}targetCanDrop(e){return this.target.canDrop(e)}dragEnterHandler({e}){let t=this.targetCanDrop(e);!this.__isDraggingOver&&t&&(this.__isDraggingOver=!0)}dragOverHandler(e){let{e:t}=e,n=this.targetCanDrop(t);!this.__isDraggingOver&&n?this.__isDraggingOver=!0:this.__isDraggingOver&&!n&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(t.preventDefault(),e.canDrop=!0,e.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(e){var t;let{e:n}=e,r=n.defaultPrevented;this.__isDraggingOver=!1,n.preventDefault();let i=(t=n.dataTransfer)==null?void 0:t.getData(`text/plain`);if(i&&!r){let t=this.target,r=t.canvas,a=t.getSelectionStartFromPointer(n),{styles:o}=n.dataTransfer.types.includes(`application/fabric`)?JSON.parse(n.dataTransfer.getData(`application/fabric`)):{},s=i[Math.max(0,i.length-1)];if(this.__dragStartSelection){let e=this.__dragStartSelection.selectionStart,n=this.__dragStartSelection.selectionEnd;a>e&&a<=n?a=e:a>n&&(a-=n-e),t.removeChars(e,n),delete this.__dragStartSelection}t._reNewline.test(s)&&(t._reNewline.test(t._text[a])||a===t._text.length)&&(i=i.trimEnd()),e.didDrop=!0,e.dropTarget=t,t.insertChars(i,o,a),r.setActiveObject(t),t.enterEditing(n),t.selectionStart=Math.min(a+0,t._text.length),t.selectionEnd=Math.min(t.selectionStart+i.length,t._text.length),t.hiddenTextarea.value=t.text,t._updateTextarea(),t.hiddenTextarea.focus(),t.fire(ue,{index:a+0,action:`drop`}),r.fire(`text:changed`,{target:t}),r.contextTopDirty=!0,r.requestRenderAll()}}dragEndHandler({e}){if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var t;let n=this.target,r=this.target.canvas,{selectionStart:i,selectionEnd:a}=this.__dragStartSelection,o=((t=e.dataTransfer)==null?void 0:t.dropEffect)||`none`;o===`none`?(n.selectionStart=i,n.selectionEnd=a,n._updateTextarea(),n.hiddenTextarea.focus()):(n.clearContextTop(),o===`move`&&(n.removeChars(i,a),n.selectionStart=n.selectionEnd=i,n.hiddenTextarea&&(n.hiddenTextarea.value=n.text),n._updateTextarea(),n.fire(ue,{index:i,action:`dragend`}),r.fire(`text:changed`,{target:n}),r.requestRenderAll()),n.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}};let $s=/[ \n\.,;!\?\-]/;var ec=class extends Q{constructor(...e){super(...e),o(this,`_currentCursorOpacity`,1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(e){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(e)}_animateCursor({toValue:e,duration:t,delay:n,onComplete:r}){return Qr({startValue:this._currentCursorOpacity,endValue:e,duration:t,delay:n,onComplete:r,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:e=>{this._currentCursorOpacity=e,this.renderCursorOrSelection()}})}_tick(e){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(e||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var e;(e=this._currentTickCompleteState)==null||e.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(e){this.abortCursorAnimation(),this._tick(e?0:this.cursorDelay)}abortCursorAnimation(){let e=!1;[this._currentTickState,this._currentTickCompleteState].forEach(t=>{t&&!t.isDone()&&(e=!0,t.abort())}),this._currentCursorOpacity=1,e&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(e=>!e||e.isDone())&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join(``)}findWordBoundaryLeft(e){let t=0,n=e-1;if(this._reSpace.test(this._text[n]))for(;this._reSpace.test(this._text[n]);)t++,n--;for(;/\S/.test(this._text[n])&&n>-1;)t++,n--;return e-t}findWordBoundaryRight(e){let t=0,n=e;if(this._reSpace.test(this._text[n]))for(;this._reSpace.test(this._text[n]);)t++,n++;for(;/\S/.test(this._text[n])&&n<this._text.length;)t++,n++;return e+t}findLineBoundaryLeft(e){let t=0,n=e-1;for(;!/\n/.test(this._text[n])&&n>-1;)t++,n--;return e-t}findLineBoundaryRight(e){let t=0,n=e;for(;!/\n/.test(this._text[n])&&n<this._text.length;)t++,n++;return e+t}searchWordBoundary(e,t){let n=this._text,r=e>0&&this._reSpace.test(n[e])&&(t===-1||!re.test(n[e-1]))?e-1:e,i=n[r];for(;r>0&&r<n.length&&!$s.test(i);)r+=t,i=n[r];return t===-1&&$s.test(i)&&r++,r}selectWord(e){var t;e=(t=e)==null?this.selectionStart:t;let n=this.searchWordBoundary(e,-1),r=Math.max(n,this.searchWordBoundary(e,1));this.selectionStart=n,this.selectionEnd=r,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(e){var t;e=(t=e)==null?this.selectionStart:t;let n=this.findLineBoundaryLeft(e),r=this.findLineBoundaryRight(e);this.selectionStart=n,this.selectionEnd=r,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(e){this.isEditing||!this.editable||(this.enterEditingImpl(),this.fire(`editing:entered`,e?{e}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire(`text:editing:entered`,{target:this,e}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(e){if(this.getActiveControl())return;let t=this.hiddenTextarea;ut(t).activeElement!==t&&t.focus();let n=this.getSelectionStartFromPointer(e),r=this.selectionStart,i=this.selectionEnd;(n!==this.__selectionStartOnMouseDown||r===i)&&(r===n||i===n)||(n>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=n):(this.selectionStart=n,this.selectionEnd=this.__selectionStartOnMouseDown),(this.selectionStart!==r||this.selectionEnd!==i)&&(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){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(e,t,n){let r=n.slice(0,e),i=this.graphemeSplit(r).length;if(e===t)return{selectionStart:i,selectionEnd:i};let a=n.slice(e,t);return{selectionStart:i,selectionEnd:i+this.graphemeSplit(a).length}}fromGraphemeToStringSelection(e,t,n){let r=n.slice(0,e).join(``).length;return e===t?{selectionStart:r,selectionEnd:r}:{selectionStart:r,selectionEnd:r+n.slice(e,t).join(``).length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){let e=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=e.selectionStart,this.hiddenTextarea.selectionEnd=e.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){let{hiddenTextarea:e,direction:t,textAlign:n,inCompositionMode:r}=this;if(!e)return;let i=n===`justify`?t===`ltr`?O:k:n.replace(`justify-`,``),a=this.getPositionByOrigin(i,`top`);this.cursorOffsetCache={},this.text=e.value,this.set(`dirty`,!0),this.initDimensions(),this.setPositionByOrigin(a,i,`top`),this.setCoords();let o=this.fromStringToGraphemeSelection(e.selectionStart,e.selectionEnd,e.value);this.selectionEnd=this.selectionStart=o.selectionEnd,r||(this.selectionStart=o.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){let e=this._calcTextareaPosition();this.hiddenTextarea.style.left=e.left,this.hiddenTextarea.style.top=e.top}}_calcTextareaPosition(){if(!this.canvas)return{left:`1px`,top:`1px`};let e=this.inCompositionMode?this.compositionStart:this.selectionStart,t=this._getCursorBoundaries(e),n=this.get2DCursorLocation(e),r=n.lineIndex,i=n.charIndex,a=this.getValueOfPropertyAt(r,i,`fontSize`)*this.lineHeight,o=t.leftOffset,s=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,l=c.width/s,u=c.height/s,d=l-a,f=u-a,p=new P(t.left+o,t.top+t.topOffset+a).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new P(c.clientWidth/l,c.clientHeight/u));return p.x<0&&(p.x=0),p.x>d&&(p.x=d),p.y<0&&(p.y=0),p.y>f&&(p.y=f),p.x+=this.canvas._offset.left,p.y+=this.canvas._offset.top,{left:`${p.x}px`,top:`${p.y}px`,fontSize:`${a}px`,charHeight:a}}_saveEditingProps(){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(){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.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}exitEditingImpl(){let e=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,e&&(e.blur&&e.blur(),e.parentNode&&e.parentNode.removeChild(e)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){let e=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire(`editing:exited`),e&&this.fire(`modified`),this.canvas&&(this.canvas.fire(`text:editing:exited`,{target:this}),e&&this.canvas.fire(`object:modified`,{target:this})),this}_removeExtraneousStyles(){for(let e in this.styles)this._textLines[e]||delete this.styles[e]}removeStyleFromTo(e,t){let{lineIndex:n,charIndex:r}=this.get2DCursorLocation(e,!0),{lineIndex:i,charIndex:a}=this.get2DCursorLocation(t,!0);if(n===i){if(this.styles[n]){let e=this.styles[n],t=a-r;for(let t=r;t<a;t++)delete e[t];for(let r in this.styles[n]){let n=parseInt(r,10);n>=a&&(e[n-t]=e[r],delete e[r])}}}else{if(this.styles[n])for(let e=r;e<this._unwrappedTextLines[n].length;e++)delete this.styles[n][e];if(this.styles[i])for(let e=a;e<this._unwrappedTextLines[i].length;e++){let t=this.styles[i][e];t&&(this.styles[n]||(this.styles[n]={}),this.styles[n][r+e-a]=t)}for(let e=n+1;e<=i;e++)delete this.styles[e];this.shiftLineStyles(i,n-i)}}shiftLineStyles(e,t){let n=Object.assign({},this.styles);for(let r in this.styles){let i=parseInt(r,10);i>e&&(this.styles[i+t]=n[i],n[i-t]||delete this.styles[i])}}insertNewlineStyleObject(e,t,n,r){let i={},a=this._unwrappedTextLines[e].length,o=a===t,s=!1;n||(n=1),this.shiftLineStyles(e,n);let c=this.styles[e]?this.styles[e][t===0?t:t-1]:void 0;for(let n in this.styles[e]){let r=parseInt(n,10);r>=t&&(s=!0,i[r-t]=this.styles[e][n],o&&t===0||delete this.styles[e][n])}let l=!1;for(s&&!o&&(this.styles[e+n]=i,l=!0),(l||a>t)&&n--;n>0;)r&&r[n-1]?this.styles[e+n]={0:{...r[n-1]}}:c?this.styles[e+n]={0:{...c}}:delete this.styles[e+n],n--;this._forceClearCache=!0}insertCharStyleObject(e,t,n,r){this.styles||(this.styles={});let i=this.styles[e],a=i?{...i}:{};n||(n=1);for(let e in a){let r=parseInt(e,10);r>=t&&(i[r+n]=a[r],a[r-n]||delete i[r])}if(this._forceClearCache=!0,r){for(;n--;)Object.keys(r[n]).length&&(this.styles[e]||(this.styles[e]={}),this.styles[e][t+n]={...r[n]});return}if(!i)return;let o=i[t?t-1:1];for(;o&&n--;)this.styles[e][t+n]={...o}}insertNewStyleBlock(e,t,n){let r=this.get2DCursorLocation(t,!0),i=[0],a=0;for(let t=0;t<e.length;t++)e[t]===`
26
+ `?(a++,i[a]=0):i[a]++;i[0]>0&&(this.insertCharStyleObject(r.lineIndex,r.charIndex,i[0],n),n=n&&n.slice(i[0]+1)),a&&this.insertNewlineStyleObject(r.lineIndex,r.charIndex+i[0],a);let o;for(o=1;o<a;o++)i[o]>0?this.insertCharStyleObject(r.lineIndex+o,0,i[o],n):n&&this.styles[r.lineIndex+o]&&n[0]&&(this.styles[r.lineIndex+o][0]=n[0]),n=n&&n.slice(i[o]+1);i[o]>0&&this.insertCharStyleObject(r.lineIndex+o,0,i[o],n)}removeChars(e,t=e+1){this.removeStyleFromTo(e,t),this._text.splice(e,t-e),this.text=this._text.join(``),this.set(`dirty`,!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(e,t,n,r=n){r>n&&this.removeStyleFromTo(n,r);let i=this.graphemeSplit(e);this.insertNewStyleBlock(i,n,t),this._text=[...this._text.slice(0,n),...i,...this._text.slice(r)],this.text=this._text.join(``),this.set(`dirty`,!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(e,t,n){n<=e?(t===e?this._selectionDirection=O:this._selectionDirection===`right`&&(this._selectionDirection=O,this.selectionEnd=e),this.selectionStart=n):n>e&&n<t?this._selectionDirection===`right`?this.selectionEnd=n:this.selectionStart=n:(t===e?this._selectionDirection=k:this._selectionDirection===`left`&&(this._selectionDirection=k,this.selectionStart=t),this.selectionEnd=n)}},tc=class extends ec{initHiddenTextarea(){let e=this.canvas&&ut(this.canvas.getElement())||_(),t=e.createElement(`textarea`);Object.entries({autocapitalize:`off`,autocorrect:`off`,autocomplete:`off`,spellcheck:`false`,"data-fabric":`textarea`,wrap:`off`,name:`fabricTextarea`}).forEach(([e,n])=>t.setAttribute(e,n));let{top:n,left:r,fontSize:i}=this._calcTextareaPosition();t.style.cssText=`position: absolute; top: ${n}; left: ${r}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${i};`,(this.hiddenTextareaContainer||e.body).appendChild(t),Object.entries({blur:`blur`,keydown:`onKeyDown`,keyup:`onKeyUp`,input:`onInput`,copy:`copy`,cut:`copy`,paste:`paste`,compositionstart:`onCompositionStart`,compositionupdate:`onCompositionUpdate`,compositionend:`onCompositionEnd`}).forEach(([e,n])=>t.addEventListener(e,this[n].bind(this))),this.hiddenTextarea=t}blur(){this.abortCursorAnimation()}onKeyDown(e){if(!this.isEditing)return;let t=this.direction===`rtl`?this.keysMapRtl:this.keysMap;if(e.keyCode in t)this[t[e.keyCode]](e);else if(e.keyCode in this.ctrlKeysMapDown&&(e.ctrlKey||e.metaKey))this[this.ctrlKeysMapDown[e.keyCode]](e);else return;e.stopImmediatePropagation(),e.preventDefault(),e.keyCode>=33&&e.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(e){if(!this.isEditing||this._copyDone||this.inCompositionMode){this._copyDone=!1;return}if(e.keyCode in this.ctrlKeysMapUp&&(e.ctrlKey||e.metaKey))this[this.ctrlKeysMapUp[e.keyCode]](e);else return;e.stopImmediatePropagation(),e.preventDefault(),this.canvas&&this.canvas.requestRenderAll()}onInput(e){let t=this.fromPaste,{value:n,selectionStart:r,selectionEnd:i}=this.hiddenTextarea;if(this.fromPaste=!1,e&&e.stopPropagation(),!this.isEditing)return;let a=()=>{this.updateFromTextArea(),this.fire(ue),this.canvas&&(this.canvas.fire(`text:changed`,{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value===``){this.styles={},a();return}let o=this._splitTextIntoLines(n).graphemeText,s=this._text.length,l=o.length,u=this.selectionStart,d=this.selectionEnd,f=u!==d,p,m,h=l-s,_,v,y=this.fromStringToGraphemeSelection(r,i,n),b=u>y.selectionStart;f?(m=this._text.slice(u,d),h+=d-u):l<s&&(m=b?this._text.slice(d+h,d):this._text.slice(u,u-h));let x=o.slice(y.selectionEnd-h,y.selectionEnd);if(m&&m.length&&(x.length&&(p=this.getSelectionStyles(u,u+1,!1),p=x.map(()=>p[0])),f?(_=u,v=d):b?(_=d-m.length,v=d):(_=d,v=d+m.length),this.removeStyleFromTo(_,v)),x.length){let{copyPasteData:e}=g();t&&x.join(``)===e.copiedText&&!c.disableStyleCopyPaste&&(p=e.copiedTextStyle),this.insertNewStyleBlock(x,u,p)}a()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate({target:e}){let{selectionStart:t,selectionEnd:n}=e;this.compositionStart=t,this.compositionEnd=n,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;let{copyPasteData:e}=g();e.copiedText=this.getSelectedText(),c.disableStyleCopyPaste?e.copiedTextStyle=void 0:e.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(e,t){let n=this._getLineLeftOffset(e),r;return t>0&&(r=this.__charBounds[e][t-1],n+=r.left+r.width),n}getDownCursorOffset(e,t){let n=this._getSelectionForOffset(e,t),r=this.get2DCursorLocation(n),i=r.lineIndex;if(i===this._textLines.length-1||e.metaKey||e.keyCode===34)return this._text.length-n;let a=r.charIndex,o=this._getWidthBeforeCursor(i,a),s=this._getIndexOnLine(i+1,o);return this._textLines[i].slice(a).length+s+1+this.missingNewlineOffset(i)}_getSelectionForOffset(e,t){return e.shiftKey&&this.selectionStart!==this.selectionEnd&&t?this.selectionEnd:this.selectionStart}getUpCursorOffset(e,t){let n=this._getSelectionForOffset(e,t),r=this.get2DCursorLocation(n),i=r.lineIndex;if(i===0||e.metaKey||e.keyCode===33)return-n;let a=r.charIndex,o=this._getWidthBeforeCursor(i,a),s=this._getIndexOnLine(i-1,o),c=this._textLines[i].slice(0,a),l=this.missingNewlineOffset(i-1);return-this._textLines[i-1].length+s-c.length+(1-l)}_getIndexOnLine(e,t){let n=this._textLines[e],r=this._getLineLeftOffset(e),i=0,a,o;for(let s=0,c=n.length;s<c;s++)if(a=this.__charBounds[e][s].width,r+=a,r>t){o=!0;let e=r-a,n=r,c=Math.abs(e-t);i=Math.abs(n-t)<c?s:s-1;break}return o||(i=n.length-1),i}moveCursorDown(e){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown(`Down`,e)}moveCursorUp(e){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown(`Up`,e)}_moveCursorUpOrDown(e,t){let n=this[`get${e}CursorOffset`](t,this._selectionDirection===k);if(t.shiftKey?this.moveCursorWithShift(n):this.moveCursorWithoutShift(n),n!==0){let e=this.text.length;this.selectionStart=ar(0,this.selectionStart,e),this.selectionEnd=ar(0,this.selectionEnd,e),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(e){let t=this._selectionDirection===`left`?this.selectionStart+e:this.selectionEnd+e;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,t),e!==0}moveCursorWithoutShift(e){return e<0?(this.selectionStart+=e,this.selectionEnd=this.selectionStart):(this.selectionEnd+=e,this.selectionStart=this.selectionEnd),e!==0}moveCursorLeft(e){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight(`Left`,e)}_move(e,t,n){let r;if(e.altKey)r=this[`findWordBoundary${n}`](this[t]);else if(e.metaKey||e.keyCode===35||e.keyCode===36)r=this[`findLineBoundary${n}`](this[t]);else return this[t]+=n===`Left`?-1:1,!0;return r!==void 0&&this[t]!==r?(this[t]=r,!0):!1}_moveLeft(e,t){return this._move(e,t,`Left`)}_moveRight(e,t){return this._move(e,t,`Right`)}moveCursorLeftWithoutShift(e){let t=!0;return this._selectionDirection=O,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(t=this._moveLeft(e,`selectionStart`)),this.selectionEnd=this.selectionStart,t}moveCursorLeftWithShift(e){if(this._selectionDirection===`right`&&this.selectionStart!==this.selectionEnd)return this._moveLeft(e,`selectionEnd`);if(this.selectionStart!==0)return this._selectionDirection=O,this._moveLeft(e,`selectionStart`)}moveCursorRight(e){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight(`Right`,e)}_moveCursorLeftOrRight(e,t){let n=`moveCursor${e}${t.shiftKey?`WithShift`:`WithoutShift`}`;this._currentCursorOpacity=1,this[n](t)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(e){if(this._selectionDirection===`left`&&this.selectionStart!==this.selectionEnd)return this._moveRight(e,`selectionStart`);if(this.selectionEnd!==this._text.length)return this._selectionDirection=k,this._moveRight(e,`selectionEnd`)}moveCursorRightWithoutShift(e){let t=!0;return this._selectionDirection=k,this.selectionStart===this.selectionEnd?(t=this._moveRight(e,`selectionStart`),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,t}};let nc=e=>!!e.button;var rc=class extends tc{constructor(...e){super(...e),o(this,`draggableTextDelegate`,void 0)}initBehavior(){this.on(`mousedown`,this._mouseDownHandler),this.on(`mouseup`,this.mouseUpHandler),this.on(`mousedblclick`,this.doubleClickHandler),this.on(`mousetripleclick`,this.tripleClickHandler),this.draggableTextDelegate=new Qs(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(e){return this.draggableTextDelegate.onDragStart(e)}canDrop(e){return this.draggableTextDelegate.canDrop(e)}doubleClickHandler(e){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(e.e)),this.renderCursorOrSelection())}tripleClickHandler(e){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(e.e)),this.renderCursorOrSelection())}_mouseDownHandler({e,alreadySelected:t}){!this.canvas||!this.editable||nc(e)||this.getActiveControl()||this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),t&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=t||this.isEditing))}mouseUpHandler({e,transform:t}){let n=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);let e=this.canvas._activeObject;if(e&&e!==this)return}!this.editable||this.group&&!this.group.interactive||t&&t.actionPerformed||nc(e)||n||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(e){let t=this.getSelectionStartFromPointer(e),n=this.selectionStart,r=this.selectionEnd;e.shiftKey?this.setSelectionStartEndWithShift(n,r,t):(this.selectionStart=t,this.selectionEnd=t),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(e){let t=this.canvas.getScenePoint(e).transform(z(this.calcTransformMatrix())).add(new P(-this._getLeftOffset(),-this._getTopOffset())),n=0,r=0,i=0;for(let e=0;e<this._textLines.length&&n<=t.y;e++)n+=this.getHeightOfLine(e),i=e,e>0&&(r+=this._textLines[e-1].length+this.missingNewlineOffset(e-1));let a=this._textLines[i].length,o=this._getLineLeftOffset(i),s=this.__charBounds[i],c=this.direction===`rtl`,l=c?o-t.x:t.x,u=c?0:Math.abs(o);for(let e=0;e<a;e++){let t=s[e].kernedWidth,n=u+t;if(l<=n){Math.abs(l-n)<=Math.abs(l-u)&&r++;break}u=n,r++}return Math.min(this.flipX?a-r:r,this._text.length)}};let ic=`moveCursorUp`,ac=`moveCursorDown`,oc=`moveCursorLeft`,sc=`moveCursorRight`,cc=`exitEditing`,lc={9:cc,27:cc,33:ic,34:ac,35:sc,36:oc,37:oc,38:ic,39:sc,40:ac},uc={9:cc,27:cc,33:ic,34:ac,35:oc,36:sc,37:sc,38:ic,39:oc,40:ac},dc={67:`copy`,88:`cut`},fc={65:`cmdAll`},pc=(e,t)=>{let n=t.getRetinaScaling();e.setTransform(n,0,0,n,0,0);let r=t.viewportTransform;e.transform(r[0],r[1],r[2],r[3],r[4],r[5])},mc={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,keysMap:lc,keysMapRtl:uc,ctrlKeysMapDown:fc,ctrlKeysMapUp:dc,_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1};var hc=class e extends rc{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}get type(){let e=super.type;return e===`itext`?`i-text`:e}constructor(t,n){super(t,{...e.ownDefaults,...n}),this.initBehavior()}_set(e,t){return this.isEditing&&this._savedProps&&e in this._savedProps?(this._savedProps[e]=t,this):(e===`canvas`&&(this.canvas instanceof ns&&this.canvas.textEditingManager.remove(this),t instanceof ns&&t.textEditingManager.add(this)),super._set(e,t))}setSelectionStart(e){e=Math.max(e,0),this._updateAndFire(`selectionStart`,e)}setSelectionEnd(e){e=Math.min(e,this.text.length),this._updateAndFire(`selectionEnd`,e)}_updateAndFire(e,t){this[e]!==t&&(this._fireSelectionChanged(),this[e]=t),this._updateTextarea()}_fireSelectionChanged(){this.fire(`selection:changed`),this.canvas&&this.canvas.fire(`text:selection:changed`,{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(e=this.selectionStart||0,t=this.selectionEnd,n){return super.getSelectionStyles(e,t,n)}setSelectionStyles(e,t=this.selectionStart||0,n=this.selectionEnd){return super.setSelectionStyles(e,t,n)}get2DCursorLocation(e=this.selectionStart,t){return super.get2DCursorLocation(e,t)}render(e){super.render(e),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(e){let t=this.isEditing;this.isEditing=!1;let n=super.toCanvasElement(e);return this.isEditing=t,n}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;let e=this.clearContextTop(!0);if(!e)return;let t=this._getCursorBoundaries(),n=this.findAncestorsWithClipPath(),r=n.length>0,i=e,a;if(r){a=I(e.canvas),i=a.getContext(`2d`),pc(i,this.canvas);let t=this.calcTransformMatrix();i.transform(t[0],t[1],t[2],t[3],t[4],t[5])}if(this.selectionStart===this.selectionEnd&&!this.inCompositionMode?this.renderCursor(i,t):this.renderSelection(i,t),r)for(let t of n){let n=t.clipPath,r=I(e.canvas),a=r.getContext(`2d`);if(pc(a,this.canvas),!n.absolutePositioned){let e=t.calcTransformMatrix();a.transform(e[0],e[1],e[2],e[3],e[4],e[5])}n.transform(a),n.drawObject(a,!0,{}),this.drawClipPathOnCache(i,n,r)}r&&(e.setTransform(1,0,0,1,0,0),e.drawImage(a,0,0)),this.canvas.contextTopDirty=!0,e.restore()}findAncestorsWithClipPath(){let e=[],t=this;for(;t;)t.clipPath&&e.push(t),t=t.parent;return e}_getCursorBoundaries(e=this.selectionStart,t){let n=this._getLeftOffset(),r=this._getTopOffset(),i=this._getCursorBoundariesOffsets(e,t);return{left:n,top:r,leftOffset:i.left,topOffset:i.top}}_getCursorBoundariesOffsets(e,t){return t?this.__getCursorBoundariesOffsets(e):this.cursorOffsetCache&&`top`in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(e)}__getCursorBoundariesOffsets(e){let t=0,n=0,{charIndex:r,lineIndex:i}=this.get2DCursorLocation(e),{textAlign:a,direction:o}=this;for(let e=0;e<i;e++)t+=this.getHeightOfLine(e);let s=this._getLineLeftOffset(i),c=this.__charBounds[i][r];c&&(n=c.left),this.charSpacing!==0&&r===this._textLines[i].length&&(n-=this._getWidthOfCharSpacing());let l=s+(n>0?n:0);return o===`rtl`&&(a===`right`||a===`justify`||a===`justify-right`?l*=-1:(a===`left`||a===`justify-left`||a===`center`||a===`justify-center`)&&(l=s-(n>0?n:0))),{top:t,left:l}}renderCursorAt(e){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(e,!0),e)}renderCursor(e,t){this._renderCursor(e,t,this.selectionStart)}getCursorRenderingData(e=this.selectionStart,t=this._getCursorBoundaries(e)){let n=this.get2DCursorLocation(e),r=n.lineIndex,i=n.charIndex>0?n.charIndex-1:0,a=this.getValueOfPropertyAt(r,i,`fontSize`),o=this.getObjectScaling().x*this.canvas.getZoom(),s=this.cursorWidth/o,c=this.getValueOfPropertyAt(r,i,`deltaY`),l=t.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(r)/this.lineHeight-a*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(r,i,`fill`),opacity:this._currentCursorOpacity,left:t.left+t.leftOffset-s/2,top:l+t.top+c,width:s,height:a}}_renderCursor(e,t,n){let{color:r,opacity:i,left:a,top:o,width:s,height:c}=this.getCursorRenderingData(n,t);e.fillStyle=r,e.globalAlpha=i,e.fillRect(a,o,s,c)}renderSelection(e,t){let n={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(e,n,t)}renderDragSourceEffect(){let e=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,e,this._getCursorBoundaries(e.selectionStart,!0))}renderDropTargetEffect(e){let t=this.getSelectionStartFromPointer(e);this.renderCursorAt(t)}_renderSelection(e,t,n){let{textAlign:r,direction:i}=this,a=t.selectionStart,o=t.selectionEnd,s=r.includes(Bn),c=this.get2DCursorLocation(a),l=this.get2DCursorLocation(o),u=c.lineIndex,d=l.lineIndex,f=c.charIndex<0?0:c.charIndex,p=l.charIndex<0?0:l.charIndex;for(let t=u;t<=d;t++){let a=this._getLineLeftOffset(t)||0,o=this.getHeightOfLine(t),c=0,l=0;if(t===u&&(c=this.__charBounds[u][f].left),t>=u&&t<d)l=s&&!this.isEndOfWrapping(t)?this.width:this.getLineWidth(t)||5;else if(t===d)if(p===0)l=this.__charBounds[d][p].left;else{let e=this._getWidthOfCharSpacing();l=this.__charBounds[d][p-1].left+this.__charBounds[d][p-1].width-e}let m=o;(this.lineHeight<1||t===d&&this.lineHeight>1)&&(o/=this.lineHeight);let h=n.left+a+c,g=o,_=0,v=l-c;this.inCompositionMode?(e.fillStyle=this.compositionColor||`black`,g=1,_=o):e.fillStyle=this.selectionColor,i===`rtl`&&(r===`right`||r===`justify`||r===`justify-right`?h=this.width-h-v:(r===`left`||r===`justify-left`||r===`center`||r===`justify-center`)&&(h=n.left+a-l)),e.fillRect(h,n.top+n.topOffset+_,v,g),n.topOffset+=m}}getCurrentCharFontSize(){let e=this._getCurrentCharIndex();return this.getValueOfPropertyAt(e.l,e.c,`fontSize`)}getCurrentCharColor(){let e=this._getCurrentCharIndex();return this.getValueOfPropertyAt(e.l,e.c,j)}_getCurrentCharIndex(){let e=this.get2DCursorLocation(this.selectionStart,!0),t=e.charIndex>0?e.charIndex-1:0;return{l:e.lineIndex,c:t}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}};o(hc,`ownDefaults`,mc),o(hc,`type`,`IText`),M.setClass(hc),M.setClass(hc,`i-text`);let gc={minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1};var _c=class e extends hc{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t,n){super(t,{...e.ownDefaults,...n})}static createControls(){return{controls:Bi()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set(`width`,this.dynamicMinWidth),this.textAlign.includes(`justify`)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(e){let t=0,n=0,r=0,i={};for(let a=0;a<e.graphemeLines.length;a++)e.graphemeText[r]===`
27
+ `&&a>0?(n=0,r++,t++):!this.splitByGrapheme&&this._reSpaceAndTab.test(e.graphemeText[r])&&a>0&&(n++,r++),i[a]={line:t,offset:n},r+=e.graphemeLines[a].length,n+=e.graphemeLines[a].length;return i}styleHas(e,t){if(this._styleMap&&!this.isWrapping){let e=this._styleMap[t];e&&(t=e.line)}return super.styleHas(e,t)}isEmptyStyles(e){if(!this.styles)return!0;let t=0,n,r,i=!1,a=this._styleMap[e],o=this._styleMap[e+1];a&&(e=a.line,t=a.offset),o&&(n=o.line,i=n===e,r=o.offset);let s=e===void 0?this.styles:{line:this.styles[e]};for(let e in s)for(let n in s[e]){let a=parseInt(n,10);if(a>=t&&(!i||a<r))for(let t in s[e][n])return!1}return!0}_getStyleDeclaration(e,t){if(this._styleMap&&!this.isWrapping){let n=this._styleMap[e];if(!n)return{};e=n.line,t=n.offset+t}return super._getStyleDeclaration(e,t)}_setStyleDeclaration(e,t,n){let r=this._styleMap[e];super._setStyleDeclaration(r.line,r.offset+t,n)}_deleteStyleDeclaration(e,t){let n=this._styleMap[e];super._deleteStyleDeclaration(n.line,n.offset+t)}_getLineStyle(e){let t=this._styleMap[e];return!!this.styles[t.line]}_setLineStyle(e){let t=this._styleMap[e];super._setLineStyle(t.line)}_wrapText(e,t){this.isWrapping=!0;let n=this.getGraphemeDataForRender(e),r=[];for(let e=0;e<n.wordsData.length;e++)r.push(...this._wrapLine(e,t,n));return this.isWrapping=!1,r}getGraphemeDataForRender(e){let t=this.splitByGrapheme,n=t?``:` `,r=0;return{wordsData:e.map((e,i)=>{let a=0,o=t?this.graphemeSplit(e):this.wordSplit(e);return o.length===0?[{word:[],width:0}]:o.map(e=>{let o=t?[e]:this.graphemeSplit(e),s=this._measureWord(o,i,a);return r=Math.max(s,r),a+=o.length+n.length,{word:o,width:s}})}),largestWordWidth:r}}_measureWord(e,t,n=0){let r=0,i;for(let a=0,o=e.length;a<o;a++){let o=this._getGraphemeBox(e[a],t,a+n,i,!0);r+=o.kernedWidth,i=e[a]}return r}wordSplit(e){return e.split(this._wordJoiners)}_wrapLine(e,t,{largestWordWidth:n,wordsData:r},i=0){let a=this._getWidthOfCharSpacing(),o=this.splitByGrapheme,s=[],c=o?``:` `,l=0,u=[],d=0,f=0,p=!0;t-=i;let m=Math.max(t,n,this.dynamicMinWidth),h=r[e],g;for(g=0;g<h.length;g++){let{word:t,width:n}=h[g];d+=t.length,l+=f+n-a,l>m&&!p?(s.push(u),u=[],l=n,p=!0):l+=a,!p&&!o&&u.push(c),u=u.concat(t),f=o?0:this._measureWord([c],e,d),d++,p=!1}return g&&s.push(u),n+i>this.dynamicMinWidth&&(this.dynamicMinWidth=n-a+i),s}isEndOfWrapping(e){return!this._styleMap[e+1]||this._styleMap[e+1].line!==this._styleMap[e].line}missingNewlineOffset(e,t){return this.splitByGrapheme&&!t?+!!this.isEndOfWrapping(e):1}_splitTextIntoLines(e){let t=super._splitTextIntoLines(e),n=this._wrapText(t.lines,this.width),r=Array(n.length);for(let e=0;e<n.length;e++)r[e]=n[e].join(``);return t.lines=r,t.graphemeLines=n,t}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){let e=new Map;for(let t in this._styleMap){let n=parseInt(t,10);if(this._textLines[n]){let n=this._styleMap[t].line;e.set(`${n}`,!0)}}for(let t in this.styles)e.has(t)||delete this.styles[t]}toObject(e=[]){return super.toObject([`minWidth`,`splitByGrapheme`,...e])}};o(_c,`type`,`Textbox`),o(_c,`textLayoutProperties`,[...hc.textLayoutProperties,`width`]),o(_c,`ownDefaults`,gc),M.setClass(_c);var vc=class extends Pa{shouldPerformLayout(e){return!!e.target.clipPath&&super.shouldPerformLayout(e)}shouldLayoutClipPath(){return!1}calcLayoutResult(e,t){let{target:n}=e,{clipPath:r,group:i}=n;if(!r||!this.shouldPerformLayout(e))return;let{width:a,height:o}=jt(Na(n,r)),s=new P(a,o);if(r.absolutePositioned)return{center:zt(r.getRelativeCenterPoint(),void 0,i?i.calcTransformMatrix():void 0),size:s};{let i=r.getRelativeCenterPoint().transform(n.calcOwnMatrix(),!0);if(this.shouldPerformLayout(e)){let{center:n=new P,correction:r=new P}=this.calcBoundingBox(t,e)||{};return{center:n.add(i),correction:r.subtract(i),size:s}}else return{center:n.getRelativeCenterPoint().add(i),size:s}}}};o(vc,`type`,`clip-path`),M.setClass(vc);var yc=class extends Pa{getInitialSize({target:e},{size:t}){return new P(e.width||t.x,e.height||t.y)}};o(yc,`type`,`fixed`),M.setClass(yc);var bc=class extends La{subscribeTargets(e){let t=e.target;e.targets.reduce((e,t)=>(t.parent&&e.add(t.parent),e),new Set).forEach(e=>{e.layoutManager.subscribeTargets({target:e,targets:[t]})})}unsubscribeTargets(e){let t=e.target,n=t.getObjects();e.targets.reduce((e,t)=>(t.parent&&e.add(t.parent),e),new Set).forEach(e=>{!n.some(t=>t.parent===e)&&e.layoutManager.unsubscribeTargets({target:e,targets:[t]})})}};let xc={multiSelectionStacking:`canvas-stacking`};var Sc=class e extends Ba{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t=[],n={}){super(),Object.assign(this,e.ownDefaults),this.setOptions(n);let{left:r,top:i,layoutManager:a}=n;this.groupInit(t,{left:r,top:i,layoutManager:a==null?new bc:a})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(...e){this.multiSelectionStacking===`selection-order`?this.add(...e):e.forEach(e=>{let t=this._objects.findIndex(t=>t.isInFrontOf(e)),n=t===-1?this.size():t;this.insertAt(n,e)})}canEnterGroup(e){return this.getObjects().some(t=>t.isDescendantOf(e)||e.isDescendantOf(t))?(l(`error`,`ActiveSelection: circular object trees are not supported, this call has no effect`),!1):super.canEnterGroup(e)}enterGroup(e,t){e.parent&&e.parent===e.group?e.parent._exitGroup(e):e.group&&e.parent!==e.group&&e.group.remove(e),this._enterGroup(e,t)}exitGroup(e,t){this._exitGroup(e,t),e.parent&&e.parent._enterGroup(e,!0)}_onAfterObjectsChange(e,t){super._onAfterObjectsChange(e,t);let n=new Set;t.forEach(e=>{let{parent:t}=e;t&&n.add(t)}),e===`removed`?n.forEach(e=>{e._onAfterObjectsChange(Ma,t)}):n.forEach(e=>{e._set(`dirty`,!0)})}onDeselect(){return this.removeAll(),!1}toString(){return`#<ActiveSelection: (${this.complexity()})>`}shouldCache(){return!1}isOnACache(){return!1}_renderControls(e,t,n){e.save(),e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;let r={hasControls:!1,...n,forActiveSelection:!0};for(let t=0;t<this._objects.length;t++)this._objects[t]._renderControls(e,r);super._renderControls(e,t),e.restore()}};o(Sc,`type`,`ActiveSelection`),o(Sc,`ownDefaults`,xc),M.setClass(Sc),M.setClass(Sc,`activeSelection`);var Cc=class{constructor(){o(this,`resources`,{})}applyFilters(e,t,n,r,i){let a=i.getContext(`2d`,{willReadFrequently:!0,desynchronized:!0});if(!a)return;a.drawImage(t,0,0,n,r);let o={sourceWidth:n,sourceHeight:r,imageData:a.getImageData(0,0,n,r),originalEl:t,originalImageData:a.getImageData(0,0,n,r),canvasEl:i,ctx:a,filterBackend:this};e.forEach(e=>{e.applyTo(o)});let{imageData:s}=o;return(s.width!==n||s.height!==r)&&(i.width=s.width,i.height=s.height),a.putImageData(s,0,0),o}},wc=class{constructor({tileSize:e=c.textureSize}={}){o(this,`aPosition`,new Float32Array([0,0,0,1,1,0,1,1])),o(this,`resources`,{}),this.tileSize=e,this.setupGLContext(e,e),this.captureGPUInfo()}setupGLContext(e,t){this.dispose(),this.createWebGLCanvas(e,t)}createWebGLCanvas(e,t){let n=I({width:e,height:t}),r=n.getContext(`webgl`,{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});r&&(r.clearColor(0,0,0,0),this.canvas=n,this.gl=r)}applyFilters(e,t,n,r,i,a){let o=this.gl,s=i.getContext(`2d`);if(!o||!s)return;let c;a&&(c=this.getCachedTexture(a,t));let l={originalWidth:t.width||t.naturalWidth||0,originalHeight:t.height||t.naturalHeight||0,sourceWidth:n,sourceHeight:r,destinationWidth:n,destinationHeight:r,context:o,sourceTexture:this.createTexture(o,n,r,c?void 0:t),targetTexture:this.createTexture(o,n,r),originalTexture:c||this.createTexture(o,n,r,c?void 0:t),passes:e.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:i},u=o.createFramebuffer();return o.bindFramebuffer(o.FRAMEBUFFER,u),e.forEach(e=>{e&&e.applyTo(l)}),Tc(l),this.copyGLTo2D(o,l),o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(l.sourceTexture),o.deleteTexture(l.targetTexture),o.deleteFramebuffer(u),s.setTransform(1,0,0,1,0,0),l}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(e,t,n,r,i){let{NEAREST:a,TEXTURE_2D:o,RGBA:s,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:l,TEXTURE_MAG_FILTER:u,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:f,TEXTURE_WRAP_T:p}=e,m=e.createTexture();return e.bindTexture(o,m),e.texParameteri(o,u,i||a),e.texParameteri(o,d,i||a),e.texParameteri(o,f,l),e.texParameteri(o,p,l),r?e.texImage2D(o,0,s,s,c,r):e.texImage2D(o,0,s,t,n,0,s,c,null),m}getCachedTexture(e,t,n){let{textureCache:r}=this;if(r[e])return r[e];{let i=this.createTexture(this.gl,t.width,t.height,t,n);return i&&(r[e]=i),i}}evictCachesForKey(e){this.textureCache[e]&&(this.gl.deleteTexture(this.textureCache[e]),delete this.textureCache[e])}copyGLTo2D(e,t){let n=e.canvas,r=t.targetCanvas,i=r.getContext(`2d`);if(!i)return;i.translate(0,r.height),i.scale(1,-1);let a=n.height-r.height;i.drawImage(n,0,a,r.width,r.height,0,0,r.width,r.height)}copyGLTo2DPutImageData(e,t){let n=t.targetCanvas.getContext(`2d`),r=t.destinationWidth,i=t.destinationHeight,a=r*i*4;if(!n)return;let o=new Uint8Array(this.imageBuffer,0,a),s=new Uint8ClampedArray(this.imageBuffer,0,a);e.readPixels(0,0,r,i,e.RGBA,e.UNSIGNED_BYTE,o);let c=new ImageData(s,r,i);n.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;let e=this.gl,t={renderer:``,vendor:``};if(!e)return t;let n=e.getExtension(`WEBGL_debug_renderer_info`);if(n){let r=e.getParameter(n.UNMASKED_RENDERER_WEBGL),i=e.getParameter(n.UNMASKED_VENDOR_WEBGL);r&&(t.renderer=r.toLowerCase()),i&&(t.vendor=i.toLowerCase())}return this.gpuInfo=t,t}};function Tc(e){let t=e.targetCanvas,n=t.width,r=t.height,i=e.destinationWidth,a=e.destinationHeight;(n!==i||r!==a)&&(t.width=i,t.height=a)}let Ec;function Dc(){let{WebGLProbe:e}=g();return e.queryWebGL(F()),c.enableGLFiltering&&e.isSupported(c.textureSize)?new wc({tileSize:c.textureSize}):new Cc}function Oc(e=!0){return!Ec&&e&&(Ec=Dc()),Ec}function kc(e){Ec=e}let Ac={strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0},jc=[`cropX`,`cropY`];var Mc=class e extends J{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t,n){super(),o(this,`_lastScaleX`,1),o(this,`_lastScaleY`,1),o(this,`_filterScalingX`,1),o(this,`_filterScalingY`,1),this.filters=[],Object.assign(this,e.ownDefaults),this.setOptions(n),this.cacheKey=`texture${je()}`,this.setElement(typeof t==`string`?(this.canvas&&ut(this.canvas.getElement())||_()).getElementById(t):t,n)}getElement(){return this._element}setElement(e,t={}){this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._element=e,this._originalElement=e,this._setWidthHeight(t),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(e){let t=Oc(!1);t instanceof wc&&t.evictCachesForKey(e)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._cacheContext=null,[`_originalElement`,`_element`,`_filteredEl`,`_cacheCanvas`].forEach(e=>{let t=this[e];t&&g().dispose(t),this[e]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){let e=this.getElement();return e?{width:e.naturalWidth||e.width,height:e.naturalHeight||e.height}:{width:0,height:0}}_stroke(e){if(!this.stroke||this.strokeWidth===0)return;let t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,-n),e.lineTo(t,-n),e.lineTo(t,n),e.lineTo(-t,n),e.lineTo(-t,-n),e.closePath()}toObject(e=[]){let t=[];return this.filters.forEach(e=>{e&&t.push(e.toObject())}),{...super.toObject([...jc,...e]),src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:t,...this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{}}}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){let e=[],t=this._element,n=-this.width/2,r=-this.height/2,i=[],a=[],o=``,s=``;if(!t)return[];if(this.hasCrop()){let e=je();i.push(`<clipPath id="imageCrop_`+e+`">
28
+ `,` <rect x="`+n+`" y="`+r+`" width="`+U(this.width)+`" height="`+U(this.height)+`" />
29
+ `,`</clipPath>
30
+ `),o=` clip-path="url(#imageCrop_`+e+`)" `}if(this.imageSmoothing||(s=` image-rendering="optimizeSpeed"`),e.push(` <image `,`COMMON_PARTS`,`xlink:href="${U(this.getSrc(!0))}" x="${n-this.cropX}" y="${r-this.cropY}" width="${t.width||t.naturalWidth}" height="${t.height||t.naturalHeight}"${s}${o}></image>\n`),this.stroke||this.strokeDashArray){let e=this.fill;this.fill=null,a=[`\t<rect x="${n}" y="${r}" width="${U(this.width)}" height="${U(this.height)}" style="${this.getSvgStyles()}" />\n`],this.fill=e}return i=this.paintFirst===`fill`?i.concat(e,a):i.concat(a,e),i}getSrc(e){let t=e?this._element:this._originalElement;return t?t.toDataURL?t.toDataURL():this.srcFromAttribute?t.getAttribute(`src`)||``:t.src:this.src||``}getSvgSrc(e){return this.getSrc(e)}setSrc(e,{crossOrigin:t,signal:n}={}){return Qe(e,{crossOrigin:t,signal:n}).then(e=>{t!==void 0&&this.set({crossOrigin:t}),this.setElement(e)})}toString(){return`#<Image: { src: "${this.getSrc()}" }>`}applyResizeFilters(){let e=this.resizeFilter,t=this.minimumScaleTrigger,n=this.getTotalObjectScaling(),r=n.x,i=n.y,a=this._filteredEl||this._originalElement;if(this.group&&this.set(`dirty`,!0),!e||r>t&&i>t){this._element=a,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=r,this._lastScaleY=i;return}let o=I(a),{width:s,height:c}=a;this._element=o,this._lastScaleX=e.scaleX=r,this._lastScaleY=e.scaleY=i,Oc().applyFilters([e],a,s,c,this._element),this._filterScalingX=o.width/this._originalElement.width,this._filterScalingY=o.height/this._originalElement.height}applyFilters(e=this.filters||[]){if(e=e.filter(e=>e&&!e.isNeutralState()),this.set(`dirty`,!0),this.removeTexture(`${this.cacheKey}_filtered`),e.length===0){this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,this._filterScalingY=1;return}let t=this._originalElement,n=t.naturalWidth||t.width,r=t.naturalHeight||t.height;if(this._element===this._originalElement){let e=I({width:n,height:r});this._element=e,this._filteredEl=e}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext(`2d`).clearRect(0,0,n,r),this._lastScaleX=1,this._lastScaleY=1);Oc().applyFilters(e,this._originalElement,n,r,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)}_render(e){e.imageSmoothingEnabled=this.imageSmoothing,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(e),this._renderPaintInOrder(e)}drawCacheOnCanvas(e){e.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(e)}shouldCache(){return this.needsItsOwnCache()}_renderFill(e){let t=this._element;if(!t)return;let n=this._filterScalingX,r=this._filterScalingY,i=this.width,a=this.height,o=Math.max(this.cropX,0),s=Math.max(this.cropY,0),c=t.naturalWidth||t.width,l=t.naturalHeight||t.height,u=o*n,d=s*r,f=Math.min(i*n,c-u),p=Math.min(a*r,l-d),m=-i/2,h=-a/2,g=Math.min(i,c/n-o),_=Math.min(a,l/r-s);t&&e.drawImage(t,u,d,f,p,m,h,g,_)}_needsResize(){let e=this.getTotalObjectScaling();return e.x!==this._lastScaleX||e.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight({width:e,height:t}={}){let n=this.getOriginalSize();this.width=e||n.width,this.height=t||n.height}parsePreserveAspectRatioAttribute(){let e=Dn(this.preserveAspectRatio||``),t=this.width,n=this.height,r={width:t,height:n},i=this._element.width,a=this._element.height,o=1,s=1,c=0,l=0,u=0,d=0,f;return e&&(e.alignX!==`none`||e.alignY!==`none`)?(e.meetOrSlice===`meet`&&(o=s=Ha(this._element,r),f=(t-i*o)/2,e.alignX===`Min`&&(c=-f),e.alignX===`Max`&&(c=f),f=(n-a*s)/2,e.alignY===`Min`&&(l=-f),e.alignY===`Max`&&(l=f)),e.meetOrSlice===`slice`&&(o=s=Ua(this._element,r),f=i-t/o,e.alignX===`Mid`&&(u=f/2),e.alignX===`Max`&&(u=f),f=a-n/s,e.alignY===`Mid`&&(d=f/2),e.alignY===`Max`&&(d=f),i=t/o,a=n/s)):(o=t/i,s=n/a),{width:i,height:a,scaleX:o,scaleY:s,offsetLeft:c,offsetTop:l,cropX:u,cropY:d}}static fromObject({filters:e,resizeFilter:t,src:n,crossOrigin:r,type:i,...a},o){return Promise.all([Qe(n,{...o,crossOrigin:r}),e&&$e(e,o),t?$e([t],o):[],et(a,o)]).then(([e,t=[],[r],i={}])=>new this(e,{...a,src:n,filters:t,resizeFilter:r,...i}))}static fromURL(e,{crossOrigin:t=null,signal:n}={},r){return Qe(e,{crossOrigin:t,signal:n}).then(e=>new this(e,r))}static async fromElement(e,t={},n){let r=Da(e,this.ATTRIBUTE_NAMES,n);return this.fromURL(r[`xlink:href`]||r.href,t,r).catch(e=>(l(`log`,`Unable to parse Image`,e),null))}};o(Mc,`type`,`Image`),o(Mc,`cacheProperties`,[...sr,...jc]),o(Mc,`ownDefaults`,Ac),o(Mc,`ATTRIBUTE_NAMES`,[...ea,`x`,`y`,`width`,`height`,`preserveAspectRatio`,`xlink:href`,`href`,`crossOrigin`,`image-rendering`]),M.setClass(Mc),M.setSVGClass(Mc);function Nc(e){if(!$n.test(e.nodeName))return{};let t=e.getAttribute(`viewBox`),n=1,r=1,i,a,o=e.getAttribute(`width`),s=e.getAttribute(`height`),c=e.getAttribute(`x`)||0,l=e.getAttribute(`y`)||0,u=!(t&&tr.test(t)),d=!o||!s||o===`100%`||s===`100%`,f=``,p=0,m=0;if(u&&(c||l)&&e.parentNode&&e.parentNode.nodeName!==`#document`&&(f=` translate(`+K(c||`0`)+` `+K(l||`0`)+`) `,i=(e.getAttribute(`transform`)||``)+f,e.setAttribute(`transform`,i),e.removeAttribute(`x`),e.removeAttribute(`y`)),u&&d)return{width:0,height:0};let h={width:0,height:0};if(u)return h.width=K(o),h.height=K(s),h;let g=t.match(tr),_=-parseFloat(g[1]),v=-parseFloat(g[2]),y=parseFloat(g[3]),b=parseFloat(g[4]);h.minX=_,h.minY=v,h.viewBoxWidth=y,h.viewBoxHeight=b,d?(h.width=y,h.height=b):(h.width=K(o),h.height=K(s),n=h.width/y,r=h.height/b);let x=Dn(e.getAttribute(`preserveAspectRatio`)||``);if(x.alignX!==`none`&&(x.meetOrSlice===`meet`&&(r=n=n>r?r:n),x.meetOrSlice===`slice`&&(r=n=n>r?n:r),p=h.width-y*n,m=h.height-b*n,x.alignX===`Mid`&&(p/=2),x.alignY===`Mid`&&(m/=2),x.alignX===`Min`&&(p=0),x.alignY===`Min`&&(m=0)),n===1&&r===1&&_===0&&v===0&&c===0&&l===0)return h;if((c||l)&&e.parentNode.nodeName!==`#document`&&(f=` translate(`+K(c||`0`)+` `+K(l||`0`)+`) `),i=f+` matrix(`+n+` 0 0 `+r+` `+(_*n+p)+` `+(v*r+m)+`) `,e.nodeName===`svg`){for(a=e.ownerDocument.createElementNS(Un,`g`);e.firstChild;)a.appendChild(e.firstChild);e.appendChild(a)}else a=e,a.removeAttribute(`x`),a.removeAttribute(`y`),i=a.getAttribute(`transform`)+i;return a.setAttribute(`transform`,i),h}let Pc=e=>e.tagName.replace(`svg:`,``),Fc=jn(qn);function Ic(e){let t=e;for(;t&&(t=t.parentElement);)if(t&&t.nodeName&&Fc.test(Pc(t))&&!t.getAttribute(`instantiated_by_use`))return!0;return!1}function Lc(e,t){let n,r=[],i,a,o;for(a=0,o=t.length;a<o;a++)n=t[a],i=e.getElementsByTagNameNS(`http://www.w3.org/2000/svg`,n),r=r.concat(Array.from(i));return r}function Rc(e){let t=Lc(e,[`use`,`svg:use`]),n=[`x`,`y`,`xlink:href`,`href`,`transform`];for(let r of t){let t=r.attributes,i={};for(let e of t)e.value&&(i[e.name]=e.value);let a=(i[`xlink:href`]||i.href||``).slice(1);if(a===``)return;let o=e.getElementById(a);if(o===null)return;let s=o.cloneNode(!0),c=s.attributes,l={};for(let e of c)e.value&&(l[e.name]=e.value);let{x:u=0,y:d=0,transform:f=``}=i,p=`${f} ${l.transform||``} translate(${u}, ${d})`;if(Nc(s),/^svg$/i.test(s.nodeName)){let e=s.ownerDocument.createElementNS(Un,`g`);Object.entries(l).forEach(([t,n])=>e.setAttributeNS(Un,t,n)),e.append(...s.childNodes),s=e}for(let e of t){if(!e)continue;let{name:t,value:r}=e;if(!n.includes(t))if(t===`style`){let e={};Ca(r,e),Object.entries(l).forEach(([t,n])=>{e[t]=n}),Ca(l.style||``,e);let n=Object.entries(e).map(e=>e.join(`:`)).join(`;`);s.setAttribute(t,n)}else!l[t]&&s.setAttribute(t,r)}s.setAttribute(`transform`,p),s.setAttribute(`instantiated_by_use`,`1`),s.removeAttribute(`id`),r.parentNode.replaceChild(s,r)}}let zc=[`gradientTransform`,`x1`,`x2`,`y1`,`y2`,`gradientUnits`,`cx`,`cy`,`r`,`fx`,`fy`],Bc=`xlink:href`;function Vc(e,t){var n;let r=((n=t.getAttribute(Bc))==null?void 0:n.slice(1))||``,i=e.getElementById(r);if(i&&i.getAttribute(Bc)&&Vc(e,i),i&&(zc.forEach(e=>{let n=i.getAttribute(e);!t.hasAttribute(e)&&n&&t.setAttribute(e,n)}),!t.children.length)){let e=i.cloneNode(!0);for(;e.firstChild;)t.appendChild(e.firstChild)}t.removeAttribute(Bc)}let Hc=[`linearGradient`,`radialGradient`,`svg:linearGradient`,`svg:radialGradient`];function Uc(e){let t=Lc(e,Hc),n={},r=t.length;for(;r--;){let i=t[r];i.getAttribute(`xlink:href`)&&Vc(e,i);let a=i.getAttribute(`id`);a&&(n[a]=i)}return n}function Wc(e){let t=e.getElementsByTagName(`style`),n={};for(let e=0;e<t.length;e++){let r=(t[e].textContent||``).replace(/\/\*[\s\S]*?\*\//g,``);r.trim()!==``&&r.split(`}`).filter((e,t,n)=>n.length>1&&e.trim()).forEach(e=>{if((e.match(/{/g)||[]).length>1&&e.trim().startsWith(`@`))return;let t=e.split(`{`),r={},i=t[1].trim().split(`;`).filter(function(e){return e.trim()});for(let e=0;e<i.length;e++){let t=i[e].split(`:`),n=t[0].trim();r[n]=t[1].trim()}e=t[0].trim(),e.split(`,`).forEach(e=>{e=e.replace(/^svg/i,``).trim(),e!==``&&(n[e]={...n[e]||{},...r})})})}return n}let Gc=e=>M.getSVGClass(Pc(e).toLowerCase());var Kc=class{constructor(e,t,n,r,i){this.elements=e,this.options=t,this.reviver=n,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=r,this.clipPaths=i,this.gradientDefs=Uc(r),this.cssRules=Wc(r)}parse(){return Promise.all(this.elements.map(e=>this.createObject(e)))}async createObject(e){let t=Gc(e);if(t){let n=await t.fromElement(e,this.options,this.cssRules);return this.resolveGradient(n,e,j),this.resolveGradient(n,e,ge),n instanceof Mc&&n._originalElement?ko(n,n.parsePreserveAspectRatioAttribute()):ko(n),await this.resolveClipPath(n,e),this.reviver&&this.reviver(e,n),n}return null}extractPropertyDefinition(e,t,n){let r=e[t];if(typeof r!=`string`)return;let i=this.regexUrl;if(!i.test(r))return;i.lastIndex=0;let a=i.exec(r)[1];return i.lastIndex=0,n[a]?{def:n[a],id:a}:void 0}resolveGradient(e,t,n){let r=this.extractPropertyDefinition(e,n,this.gradientDefs);if(r){let i=t.getAttribute(n+`-opacity`),a=ys.fromElement(r.def,e,{...this.options,opacity:i});e.set(n,a)}}async resolveClipPath(e,t,n,r=new Set){if(typeof e.clipPath!=`string`)return;let i=this.extractPropertyDefinition(e,`clipPath`,this.clipPaths);if(i&&!r.has(i.id)){let s=i.def,c=z(e.calcTransformMatrix()),l=s[0].parentElement,u=t;for(;!n&&u.parentElement&&u.getAttribute(`clip-path`)!==e.clipPath;)u=u.parentElement;u.parentElement.appendChild(l);let d=ya(`${u.getAttribute(`transform`)||``} ${l.getAttribute(`originalTransform`)||``}`);l.setAttribute(`transform`,`matrix(${d.join(`,`)})`);let f=new Set(r);f.add(i.id);let p=await Promise.all(s.map(async e=>{let t=await Gc(e).fromElement(e,this.options,this.cssRules);return ko(t),t.fillRule=t.clipRule,delete t.clipRule,await this.resolveClipPath(t,e,void 0,f),t})),m=p.length===1?p[0]:new Ba(p),h=B(c,m.calcTransformMatrix()),g=u.parentElement;for(;g&&g.getAttribute(`clip-path`)!==e.clipPath;)g=g.parentElement;if(g&&!m.clipPath&&(m.clipPath=e.clipPath),m.clipPath){var a,o;await this.resolveClipPath(m,(a=g)==null?u:a,(o=g)==null?l.getAttribute(`clip-path`)?u:void 0:o,g?r:f)}let{scaleX:_,scaleY:v,angle:y,skewX:b,translateX:x,translateY:S}=Ue(h);m.set({flipX:!1,flipY:!1}),m.set({scaleX:_,scaleY:v,angle:y,skewX:b,skewY:0}),m.setPositionByOrigin(new P(x,S),D,D),e.clipPath=m}else{delete e.clipPath;return}}};let qc=e=>Qn.test(Pc(e)),Jc=()=>({objects:[],elements:[],options:{},allElements:[]});async function Yc(e,t,{crossOrigin:n,signal:r}={}){if(r&&r.aborted)return l(`log`,new d(`parseSVGDocument`)),Jc();let i=e.documentElement;Rc(e);let a=Array.from(i.getElementsByTagName(`*`)),o={...Nc(i),crossOrigin:n,signal:r},s=a.filter(e=>(Nc(e),qc(e)&&!Ic(e)));if(!s||s&&!s.length)return{...Jc(),options:o,allElements:a};let c={};return a.filter(e=>Pc(e)===`clipPath`).forEach(e=>{e.setAttribute(`originalTransform`,e.getAttribute(`transform`)||``);let t=e.getAttribute(`id`);c[t]=Array.from(e.getElementsByTagName(`*`)).filter(e=>qc(e))}),{objects:await new Kc(s,o,t,e,c).parse(),elements:s,options:o,allElements:a}}function Xc(e,t,n){return Yc(new(v()).DOMParser().parseFromString(e.trim(),`text/xml`),t,n)}function Zc(e,t,n={}){return fetch(e.replace(/^\n\s*/,``).trim(),{signal:n.signal}).then(e=>{if(!e.ok)throw new u(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>Xc(e,t,n)).catch(()=>Jc())}let Qc=e=>e.webgl!==void 0,$c=(e,t)=>{let n=I({width:e,height:t}),r=F().getContext(`webgl`),i={imageBuffer:new ArrayBuffer(e*t*4)},a={destinationWidth:e,destinationHeight:t,targetCanvas:n},o;o=v().performance.now(),wc.prototype.copyGLTo2D.call(i,r,a);let s=v().performance.now()-o;return o=v().performance.now(),wc.prototype.copyGLTo2DPutImageData.call(i,r,a),s>v().performance.now()-o},el=`precision highp float`,tl=`
31
+ ${el};
32
+ varying vec2 vTexCoord;
33
+ uniform sampler2D uTexture;
34
+ void main() {
35
+ gl_FragColor = texture2D(uTexture, vTexCoord);
36
+ }`,nl=RegExp(el,`g`);var $=class{get type(){return this.constructor.type}constructor({type:e,...t}={}){Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return tl}getVertexSource(){return`
37
+ attribute vec2 aPosition;
38
+ varying vec2 vTexCoord;
39
+ void main() {
40
+ vTexCoord = aPosition;
41
+ gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
42
+ }`}createProgram(e,t=this.getFragmentSource(),n=this.getVertexSource()){let{WebGLProbe:{GLPrecision:r=`highp`}}=g();r!==`highp`&&(t=t.replace(nl,el.replace(`highp`,r)));let i=e.createShader(e.VERTEX_SHADER),a=e.createShader(e.FRAGMENT_SHADER),o=e.createProgram();if(!i||!a||!o)throw new u(`Vertex, fragment shader or program creation error`);if(e.shaderSource(i,n),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS))throw new u(`Vertex shader compile error for ${this.type}: ${e.getShaderInfoLog(i)}`);if(e.shaderSource(a,t),e.compileShader(a),!e.getShaderParameter(a,e.COMPILE_STATUS))throw new u(`Fragment shader compile error for ${this.type}: ${e.getShaderInfoLog(a)}`);if(e.attachShader(o,i),e.attachShader(o,a),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw new u(`Shader link error for "${this.type}" ${e.getProgramInfoLog(o)}`);let s=this.getUniformLocations(e,o)||{};return s.uStepW=e.getUniformLocation(o,`uStepW`),s.uStepH=e.getUniformLocation(o,`uStepH`),{program:o,attributeLocations:this.getAttributeLocations(e,o),uniformLocations:s}}getAttributeLocations(e,t){return{aPosition:e.getAttribLocation(t,`aPosition`)}}getUniformLocations(e,t){let n=this.constructor.uniformLocations,r={};for(let i=0;i<n.length;i++)r[n[i]]=e.getUniformLocation(t,n[i]);return r}sendAttributeData(e,t,n){let r=t.aPosition,i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(r),e.vertexAttribPointer(r,2,e.FLOAT,!1,0,0),e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW)}_setupFrameBuffer(e){let t=e.context;if(e.passes>1){let n=e.destinationWidth,r=e.destinationHeight;(e.sourceWidth!==n||e.sourceHeight!==r)&&(t.deleteTexture(e.targetTexture),e.targetTexture=e.filterBackend.createTexture(t,n,r)),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e.targetTexture,0)}else t.bindFramebuffer(t.FRAMEBUFFER,null),t.finish()}_swapTextures(e){e.passes--,e.pass++;let t=e.targetTexture;e.targetTexture=e.sourceTexture,e.sourceTexture=t}isNeutralState(e){return!1}applyTo(e){Qc(e)?(this._setupFrameBuffer(e),this.applyToWebGL(e),this._swapTextures(e)):this.applyTo2d(e)}applyTo2d(e){}getCacheKey(){return this.type}retrieveShader(e){let t=this.getCacheKey();return e.programCache[t]||(e.programCache[t]=this.createProgram(e.context)),e.programCache[t]}applyToWebGL(e){let t=e.context,n=this.retrieveShader(e);e.pass===0&&e.originalTexture?t.bindTexture(t.TEXTURE_2D,e.originalTexture):t.bindTexture(t.TEXTURE_2D,e.sourceTexture),t.useProgram(n.program),this.sendAttributeData(t,n.attributeLocations,e.aPosition),t.uniform1f(n.uniformLocations.uStepW,1/e.sourceWidth),t.uniform1f(n.uniformLocations.uStepH,1/e.sourceHeight),this.sendUniformData(t,n.uniformLocations),t.viewport(0,0,e.destinationWidth,e.destinationHeight),t.drawArrays(t.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(e,t,n){e.activeTexture(n),e.bindTexture(e.TEXTURE_2D,t),e.activeTexture(e.TEXTURE0)}unbindAdditionalTexture(e,t){e.activeTexture(t),e.bindTexture(e.TEXTURE_2D,null),e.activeTexture(e.TEXTURE0)}sendUniformData(e,t){}createHelpLayer(e){if(!e.helpLayer){let{sourceWidth:t,sourceHeight:n}=e;e.helpLayer=I({width:t,height:n})}}toObject(){let e=Object.keys(this.constructor.defaults||{});return{type:this.type,...e.reduce((e,t)=>(e[t]=this[t],e),{})}}toJSON(){return this.toObject()}static async fromObject({type:e,...t},n){return new this(t)}};o($,`type`,`BaseFilter`),o($,`uniformLocations`,[]);let rl={multiply:`gl_FragColor.rgb *= uColor.rgb;
43
+ `,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
44
+ `,add:`gl_FragColor.rgb += uColor.rgb;
45
+ `,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
46
+ `,subtract:`gl_FragColor.rgb -= uColor.rgb;
47
+ `,lighten:`gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);
48
+ `,darken:`gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);
49
+ `,exclusion:`gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);
50
+ `,overlay:`
51
+ if (uColor.r < 0.5) {
52
+ gl_FragColor.r *= 2.0 * uColor.r;
53
+ } else {
54
+ gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);
55
+ }
56
+ if (uColor.g < 0.5) {
57
+ gl_FragColor.g *= 2.0 * uColor.g;
58
+ } else {
59
+ gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);
60
+ }
61
+ if (uColor.b < 0.5) {
62
+ gl_FragColor.b *= 2.0 * uColor.b;
63
+ } else {
64
+ gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);
65
+ }
66
+ `,tint:`
67
+ gl_FragColor.rgb *= (1.0 - uColor.a);
68
+ gl_FragColor.rgb += uColor.rgb;
69
+ `},il={color:`#F95C63`,mode:`multiply`,alpha:1};var al=class extends ${getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return`
70
+ precision highp float;
71
+ uniform sampler2D uTexture;
72
+ uniform vec4 uColor;
73
+ varying vec2 vTexCoord;
74
+ void main() {
75
+ vec4 color = texture2D(uTexture, vTexCoord);
76
+ gl_FragColor = color;
77
+ if (color.a > 0.0) {
78
+ ${rl[this.mode]}
79
+ }
80
+ }
81
+ `}applyTo2d({imageData:{data:e}}){let t=new G(this.color).getSource(),n=this.alpha,r=t[0]*n,i=t[1]*n,a=t[2]*n,o=1-n;for(let t=0;t<e.length;t+=4){let n=e[t],s=e[t+1],c=e[t+2],l,u,d;switch(this.mode){case`multiply`:l=n*r/255,u=s*i/255,d=c*a/255;break;case`screen`:l=255-(255-n)*(255-r)/255,u=255-(255-s)*(255-i)/255,d=255-(255-c)*(255-a)/255;break;case`add`:l=n+r,u=s+i,d=c+a;break;case`difference`:l=Math.abs(n-r),u=Math.abs(s-i),d=Math.abs(c-a);break;case`subtract`:l=n-r,u=s-i,d=c-a;break;case`darken`:l=Math.min(n,r),u=Math.min(s,i),d=Math.min(c,a);break;case`lighten`:l=Math.max(n,r),u=Math.max(s,i),d=Math.max(c,a);break;case`overlay`:l=r<128?2*n*r/255:255-2*(255-n)*(255-r)/255,u=i<128?2*s*i/255:255-2*(255-s)*(255-i)/255,d=a<128?2*c*a/255:255-2*(255-c)*(255-a)/255;break;case`exclusion`:l=r+n-2*r*n/255,u=i+s-2*i*s/255,d=a+c-2*a*c/255;break;case`tint`:l=r+n*o,u=i+s*o,d=a+c*o}e[t]=l,e[t+1]=u,e[t+2]=d}}sendUniformData(e,t){let n=new G(this.color).getSource();n[0]=this.alpha*n[0]/255,n[1]=this.alpha*n[1]/255,n[2]=this.alpha*n[2]/255,n[3]=this.alpha,e.uniform4fv(t.uColor,n)}};o(al,`defaults`,il),o(al,`type`,`BlendColor`),o(al,`uniformLocations`,[`uColor`]),M.setClass(al);let ol={multiply:`
82
+ precision highp float;
83
+ uniform sampler2D uTexture;
84
+ uniform sampler2D uImage;
85
+ uniform vec4 uColor;
86
+ varying vec2 vTexCoord;
87
+ varying vec2 vTexCoord2;
88
+ void main() {
89
+ vec4 color = texture2D(uTexture, vTexCoord);
90
+ vec4 color2 = texture2D(uImage, vTexCoord2);
91
+ color.rgba *= color2.rgba;
92
+ gl_FragColor = color;
93
+ }
94
+ `,mask:`
95
+ precision highp float;
96
+ uniform sampler2D uTexture;
97
+ uniform sampler2D uImage;
98
+ uniform vec4 uColor;
99
+ varying vec2 vTexCoord;
100
+ varying vec2 vTexCoord2;
101
+ void main() {
102
+ vec4 color = texture2D(uTexture, vTexCoord);
103
+ vec4 color2 = texture2D(uImage, vTexCoord2);
104
+ color.a = color2.a;
105
+ gl_FragColor = color;
106
+ }
107
+ `},sl={mode:`multiply`,alpha:1};var cl=class extends ${getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return ol[this.mode]}getVertexSource(){return`
108
+ attribute vec2 aPosition;
109
+ varying vec2 vTexCoord;
110
+ varying vec2 vTexCoord2;
111
+ uniform mat3 uTransformMatrix;
112
+ void main() {
113
+ vTexCoord = aPosition;
114
+ vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
115
+ gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
116
+ }
117
+ `}applyToWebGL(e){let t=e.context,n=this.createTexture(e.filterBackend,this.image);this.bindAdditionalTexture(t,n,t.TEXTURE1),super.applyToWebGL(e),this.unbindAdditionalTexture(t,t.TEXTURE1)}createTexture(e,t){return e.getCachedTexture(t.cacheKey,t.getElement())}calculateMatrix(){let e=this.image,{width:t,height:n}=e.getElement();return[1/e.scaleX,0,0,0,1/e.scaleY,0,-e.left/t,-e.top/n,1]}applyTo2d({imageData:{data:e,width:t,height:n},filterBackend:{resources:r}}){let i=this.image;r.blendImage||(r.blendImage=F());let a=r.blendImage,o=a.getContext(`2d`);a.width!==t||a.height!==n?(a.width=t,a.height=n):o.clearRect(0,0,t,n),o.setTransform(i.scaleX,0,0,i.scaleY,i.left,i.top),o.drawImage(i.getElement(),0,0,t,n);let s=o.getImageData(0,0,t,n).data;for(let t=0;t<e.length;t+=4){let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3],o=s[t],c=s[t+1],l=s[t+2],u=s[t+3];switch(this.mode){case`multiply`:e[t]=n*o/255,e[t+1]=r*c/255,e[t+2]=i*l/255,e[t+3]=a*u/255;break;case`mask`:e[t+3]=u;break}}}sendUniformData(e,t){let n=this.calculateMatrix();e.uniform1i(t.uImage,1),e.uniformMatrix3fv(t.uTransformMatrix,!1,n)}toObject(){return{...super.toObject(),image:this.image&&this.image.toObject()}}static async fromObject({type:e,image:t,...n},r){return Mc.fromObject(t,r).then(e=>new this({...n,image:e}))}};o(cl,`type`,`BlendImage`),o(cl,`defaults`,sl),o(cl,`uniformLocations`,[`uTransformMatrix`,`uImage`]),M.setClass(cl);let ll={blur:0};var ul=class extends ${getFragmentSource(){return`
118
+ precision highp float;
119
+ uniform sampler2D uTexture;
120
+ uniform vec2 uDelta;
121
+ varying vec2 vTexCoord;
122
+ const float nSamples = 15.0;
123
+ vec3 v3offset = vec3(12.9898, 78.233, 151.7182);
124
+ float random(vec3 scale) {
125
+ /* use the fragment position for a different seed per-pixel */
126
+ return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);
127
+ }
128
+ void main() {
129
+ vec4 color = vec4(0.0);
130
+ float totalC = 0.0;
131
+ float totalA = 0.0;
132
+ float offset = random(v3offset);
133
+ for (float t = -nSamples; t <= nSamples; t++) {
134
+ float percent = (t + offset - 0.5) / nSamples;
135
+ vec4 sample = texture2D(uTexture, vTexCoord + uDelta * percent);
136
+ float weight = 1.0 - abs(percent);
137
+ float alpha = weight * sample.a;
138
+ color.rgb += sample.rgb * alpha;
139
+ color.a += alpha;
140
+ totalA += weight;
141
+ totalC += alpha;
142
+ }
143
+ gl_FragColor.rgb = color.rgb / totalC;
144
+ gl_FragColor.a = color.a / totalA;
145
+ }
146
+ `}applyTo(e){Qc(e)?(this.aspectRatio=e.sourceWidth/e.sourceHeight,e.passes++,this._setupFrameBuffer(e),this.horizontal=!0,this.applyToWebGL(e),this._swapTextures(e),this._setupFrameBuffer(e),this.horizontal=!1,this.applyToWebGL(e),this._swapTextures(e)):this.applyTo2d(e)}applyTo2d({imageData:{data:e,width:t,height:n}}){this.aspectRatio=t/n,this.horizontal=!0;let r=this.getBlurValue()*t,i=new Uint8ClampedArray(e),a=4*t;for(let t=0;t<e.length;t+=4){let n=0,o=0,s=0,c=0,l=0,u=t-t%a,d=u+a;for(let i=-14;i<15;i++){let a=i/15,f=Math.floor(r*a)*4,p=1-Math.abs(a),m=t+f;m<u?m=u:m>d&&(m=d);let h=e[m+3]*p;n+=e[m]*h,o+=e[m+1]*h,s+=e[m+2]*h,c+=h,l+=p}i[t]=n/c,i[t+1]=o/c,i[t+2]=s/c,i[t+3]=c/l}this.horizontal=!1,r=this.getBlurValue()*n;for(let t=0;t<i.length;t+=4){let n=0,o=0,s=0,c=0,l=0,u=t%a,d=i.length-a+u;for(let e=-14;e<15;e++){let f=e/15,p=Math.floor(r*f)*a,m=1-Math.abs(f),h=t+p;h<u?h=u:h>d&&(h=d);let g=i[h+3]*m;n+=i[h]*g,o+=i[h+1]*g,s+=i[h+2]*g,c+=g,l+=m}e[t]=n/c,e[t+1]=o/c,e[t+2]=s/c,e[t+3]=c/l}}sendUniformData(e,t){let n=this.chooseRightDelta();e.uniform2fv(t.uDelta,n)}isNeutralState(){return this.blur===0}getBlurValue(){let e=1,{horizontal:t,aspectRatio:n}=this;return t?n>1&&(e=1/n):n<1&&(e=n),e*this.blur*.12}chooseRightDelta(){let e=this.getBlurValue();return this.horizontal?[e,0]:[0,e]}};o(ul,`type`,`Blur`),o(ul,`defaults`,ll),o(ul,`uniformLocations`,[`uDelta`]),M.setClass(ul);let dl={brightness:0};var fl=class extends ${getFragmentSource(){return`
147
+ precision highp float;
148
+ uniform sampler2D uTexture;
149
+ uniform float uBrightness;
150
+ varying vec2 vTexCoord;
151
+ void main() {
152
+ vec4 color = texture2D(uTexture, vTexCoord);
153
+ color.rgb += uBrightness;
154
+ gl_FragColor = color;
155
+ }
156
+ `}applyTo2d({imageData:{data:e}}){let t=Math.round(this.brightness*255);for(let n=0;n<e.length;n+=4)e[n]+=t,e[n+1]+=t,e[n+2]+=t}isNeutralState(){return this.brightness===0}sendUniformData(e,t){e.uniform1f(t.uBrightness,this.brightness)}};o(fl,`type`,`Brightness`),o(fl,`defaults`,dl),o(fl,`uniformLocations`,[`uBrightness`]),M.setClass(fl);let pl={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};var ml=class extends ${getFragmentSource(){return`
157
+ precision highp float;
158
+ uniform sampler2D uTexture;
159
+ varying vec2 vTexCoord;
160
+ uniform mat4 uColorMatrix;
161
+ uniform vec4 uConstants;
162
+ void main() {
163
+ vec4 color = texture2D(uTexture, vTexCoord);
164
+ color *= uColorMatrix;
165
+ color += uConstants;
166
+ gl_FragColor = color;
167
+ }`}applyTo2d(e){let t=e.imageData.data,n=this.matrix,r=this.colorsOnly;for(let e=0;e<t.length;e+=4){let i=t[e],a=t[e+1],o=t[e+2];if(t[e]=i*n[0]+a*n[1]+o*n[2]+n[4]*255,t[e+1]=i*n[5]+a*n[6]+o*n[7]+n[9]*255,t[e+2]=i*n[10]+a*n[11]+o*n[12]+n[14]*255,!r){let r=t[e+3];t[e]+=r*n[3],t[e+1]+=r*n[8],t[e+2]+=r*n[13],t[e+3]=i*n[15]+a*n[16]+o*n[17]+r*n[18]+n[19]*255}}}sendUniformData(e,t){let n=this.matrix,r=[n[0],n[1],n[2],n[3],n[5],n[6],n[7],n[8],n[10],n[11],n[12],n[13],n[15],n[16],n[17],n[18]],i=[n[4],n[9],n[14],n[19]];e.uniformMatrix4fv(t.uColorMatrix,!1,r),e.uniform4fv(t.uConstants,i)}toObject(){return{...super.toObject(),matrix:[...this.matrix]}}};o(ml,`type`,`ColorMatrix`),o(ml,`defaults`,pl),o(ml,`uniformLocations`,[`uColorMatrix`,`uConstants`]),M.setClass(ml);function hl(e,t){var n;let r=(n=class extends ml{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},o(n,`type`,e),o(n,`defaults`,{colorsOnly:!1,matrix:t}),n);return M.setClass(r,e),r}let gl=hl(`Brownie`,[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),_l=hl(`Vintage`,[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),vl=hl(`Kodachrome`,[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),yl=hl(`Technicolor`,[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),bl=hl(`Polaroid`,[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),xl=hl(`Sepia`,[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),Sl=hl(`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]);var Cl=class extends ${constructor(e={}){super(e),this.subFilters=e.subFilters||[]}applyTo(e){Qc(e)&&(e.passes+=this.subFilters.length-1),this.subFilters.forEach(t=>{t.applyTo(e)})}toObject(){return{type:this.type,subFilters:this.subFilters.map(e=>e.toObject())}}isNeutralState(){return!this.subFilters.some(e=>!e.isNeutralState())}static fromObject(e,t){return Promise.all((e.subFilters||[]).map(e=>M.getClass(e.type).fromObject(e,t))).then(e=>new this({subFilters:e}))}};o(Cl,`type`,`Composed`),M.setClass(Cl);let wl={contrast:0};var Tl=class extends ${getFragmentSource(){return`
168
+ precision highp float;
169
+ uniform sampler2D uTexture;
170
+ uniform float uContrast;
171
+ varying vec2 vTexCoord;
172
+ void main() {
173
+ vec4 color = texture2D(uTexture, vTexCoord);
174
+ float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
175
+ color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
176
+ gl_FragColor = color;
177
+ }`}isNeutralState(){return this.contrast===0}applyTo2d({imageData:{data:e}}){let t=Math.floor(this.contrast*255),n=259*(t+255)/(255*(259-t));for(let t=0;t<e.length;t+=4)e[t]=n*(e[t]-128)+128,e[t+1]=n*(e[t+1]-128)+128,e[t+2]=n*(e[t+2]-128)+128}sendUniformData(e,t){e.uniform1f(t.uContrast,this.contrast)}};o(Tl,`type`,`Contrast`),o(Tl,`defaults`,wl),o(Tl,`uniformLocations`,[`uContrast`]),M.setClass(Tl);let El={Convolute_3_1:`
178
+ precision highp float;
179
+ uniform sampler2D uTexture;
180
+ uniform float uMatrix[9];
181
+ uniform float uStepW;
182
+ uniform float uStepH;
183
+ varying vec2 vTexCoord;
184
+ void main() {
185
+ vec4 color = vec4(0, 0, 0, 0);
186
+ for (float h = 0.0; h < 3.0; h+=1.0) {
187
+ for (float w = 0.0; w < 3.0; w+=1.0) {
188
+ vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));
189
+ color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];
190
+ }
191
+ }
192
+ gl_FragColor = color;
193
+ }
194
+ `,Convolute_3_0:`
195
+ precision highp float;
196
+ uniform sampler2D uTexture;
197
+ uniform float uMatrix[9];
198
+ uniform float uStepW;
199
+ uniform float uStepH;
200
+ varying vec2 vTexCoord;
201
+ void main() {
202
+ vec4 color = vec4(0, 0, 0, 1);
203
+ for (float h = 0.0; h < 3.0; h+=1.0) {
204
+ for (float w = 0.0; w < 3.0; w+=1.0) {
205
+ vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));
206
+ color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];
207
+ }
208
+ }
209
+ float alpha = texture2D(uTexture, vTexCoord).a;
210
+ gl_FragColor = color;
211
+ gl_FragColor.a = alpha;
212
+ }
213
+ `,Convolute_5_1:`
214
+ precision highp float;
215
+ uniform sampler2D uTexture;
216
+ uniform float uMatrix[25];
217
+ uniform float uStepW;
218
+ uniform float uStepH;
219
+ varying vec2 vTexCoord;
220
+ void main() {
221
+ vec4 color = vec4(0, 0, 0, 0);
222
+ for (float h = 0.0; h < 5.0; h+=1.0) {
223
+ for (float w = 0.0; w < 5.0; w+=1.0) {
224
+ vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
225
+ color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];
226
+ }
227
+ }
228
+ gl_FragColor = color;
229
+ }
230
+ `,Convolute_5_0:`
231
+ precision highp float;
232
+ uniform sampler2D uTexture;
233
+ uniform float uMatrix[25];
234
+ uniform float uStepW;
235
+ uniform float uStepH;
236
+ varying vec2 vTexCoord;
237
+ void main() {
238
+ vec4 color = vec4(0, 0, 0, 1);
239
+ for (float h = 0.0; h < 5.0; h+=1.0) {
240
+ for (float w = 0.0; w < 5.0; w+=1.0) {
241
+ vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
242
+ color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];
243
+ }
244
+ }
245
+ float alpha = texture2D(uTexture, vTexCoord).a;
246
+ gl_FragColor = color;
247
+ gl_FragColor.a = alpha;
248
+ }
249
+ `,Convolute_7_1:`
250
+ precision highp float;
251
+ uniform sampler2D uTexture;
252
+ uniform float uMatrix[49];
253
+ uniform float uStepW;
254
+ uniform float uStepH;
255
+ varying vec2 vTexCoord;
256
+ void main() {
257
+ vec4 color = vec4(0, 0, 0, 0);
258
+ for (float h = 0.0; h < 7.0; h+=1.0) {
259
+ for (float w = 0.0; w < 7.0; w+=1.0) {
260
+ vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
261
+ color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];
262
+ }
263
+ }
264
+ gl_FragColor = color;
265
+ }
266
+ `,Convolute_7_0:`
267
+ precision highp float;
268
+ uniform sampler2D uTexture;
269
+ uniform float uMatrix[49];
270
+ uniform float uStepW;
271
+ uniform float uStepH;
272
+ varying vec2 vTexCoord;
273
+ void main() {
274
+ vec4 color = vec4(0, 0, 0, 1);
275
+ for (float h = 0.0; h < 7.0; h+=1.0) {
276
+ for (float w = 0.0; w < 7.0; w+=1.0) {
277
+ vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
278
+ color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];
279
+ }
280
+ }
281
+ float alpha = texture2D(uTexture, vTexCoord).a;
282
+ gl_FragColor = color;
283
+ gl_FragColor.a = alpha;
284
+ }
285
+ `,Convolute_9_1:`
286
+ precision highp float;
287
+ uniform sampler2D uTexture;
288
+ uniform float uMatrix[81];
289
+ uniform float uStepW;
290
+ uniform float uStepH;
291
+ varying vec2 vTexCoord;
292
+ void main() {
293
+ vec4 color = vec4(0, 0, 0, 0);
294
+ for (float h = 0.0; h < 9.0; h+=1.0) {
295
+ for (float w = 0.0; w < 9.0; w+=1.0) {
296
+ vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
297
+ color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];
298
+ }
299
+ }
300
+ gl_FragColor = color;
301
+ }
302
+ `,Convolute_9_0:`
303
+ precision highp float;
304
+ uniform sampler2D uTexture;
305
+ uniform float uMatrix[81];
306
+ uniform float uStepW;
307
+ uniform float uStepH;
308
+ varying vec2 vTexCoord;
309
+ void main() {
310
+ vec4 color = vec4(0, 0, 0, 1);
311
+ for (float h = 0.0; h < 9.0; h+=1.0) {
312
+ for (float w = 0.0; w < 9.0; w+=1.0) {
313
+ vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
314
+ color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];
315
+ }
316
+ }
317
+ float alpha = texture2D(uTexture, vTexCoord).a;
318
+ gl_FragColor = color;
319
+ gl_FragColor.a = alpha;
320
+ }
321
+ `},Dl={opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]};var Ol=class extends ${getCacheKey(){return`${this.type}_${Math.sqrt(this.matrix.length)}_${+!!this.opaque}`}getFragmentSource(){return El[this.getCacheKey()]}applyTo2d(e){let t=e.imageData,n=t.data,r=this.matrix,i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=t.width,s=t.height,c=e.ctx.createImageData(o,s),l=c.data,u=+!!this.opaque,d,f,p,m,h,g,_,v,y,b,x,S,C;for(x=0;x<s;x++)for(b=0;b<o;b++){for(h=(x*o+b)*4,d=0,f=0,p=0,m=0,C=0;C<i;C++)for(S=0;S<i;S++)_=x+C-a,g=b+S-a,!(_<0||_>=s||g<0||g>=o)&&(v=(_*o+g)*4,y=r[C*i+S],d+=n[v]*y,f+=n[v+1]*y,p+=n[v+2]*y,u||(m+=n[v+3]*y));l[h]=d,l[h+1]=f,l[h+2]=p,u?l[h+3]=n[h+3]:l[h+3]=m}e.imageData=c}sendUniformData(e,t){e.uniform1fv(t.uMatrix,this.matrix)}toObject(){return{...super.toObject(),opaque:this.opaque,matrix:[...this.matrix]}}};o(Ol,`type`,`Convolute`),o(Ol,`defaults`,Dl),o(Ol,`uniformLocations`,[`uMatrix`,`uOpaque`,`uHalfSize`,`uSize`]),M.setClass(Ol);let kl=`Gamma`,Al={gamma:[1,1,1]};var jl=class extends ${getFragmentSource(){return`
322
+ precision highp float;
323
+ uniform sampler2D uTexture;
324
+ uniform vec3 uGamma;
325
+ varying vec2 vTexCoord;
326
+ void main() {
327
+ vec4 color = texture2D(uTexture, vTexCoord);
328
+ vec3 correction = (1.0 / uGamma);
329
+ color.r = pow(color.r, correction.r);
330
+ color.g = pow(color.g, correction.g);
331
+ color.b = pow(color.b, correction.b);
332
+ gl_FragColor = color;
333
+ gl_FragColor.rgb *= color.a;
334
+ }
335
+ `}constructor(e={}){super(e),this.gamma=e.gamma||this.constructor.defaults.gamma.concat()}applyTo2d({imageData:{data:e}}){let t=this.gamma,n=1/t[0],r=1/t[1],i=1/t[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});let a=this.rgbValues;for(let e=0;e<256;e++)a.r[e]=(e/255)**n*255,a.g[e]=(e/255)**r*255,a.b[e]=(e/255)**i*255;for(let t=0;t<e.length;t+=4)e[t]=a.r[e[t]],e[t+1]=a.g[e[t+1]],e[t+2]=a.b[e[t+2]]}sendUniformData(e,t){e.uniform3fv(t.uGamma,this.gamma)}isNeutralState(){let{gamma:e}=this;return e[0]===1&&e[1]===1&&e[2]===1}toObject(){return{type:kl,gamma:this.gamma.concat()}}};o(jl,`type`,kl),o(jl,`defaults`,Al),o(jl,`uniformLocations`,[`uGamma`]),M.setClass(jl);let Ml={average:`
336
+ precision highp float;
337
+ uniform sampler2D uTexture;
338
+ varying vec2 vTexCoord;
339
+ void main() {
340
+ vec4 color = texture2D(uTexture, vTexCoord);
341
+ float average = (color.r + color.b + color.g) / 3.0;
342
+ gl_FragColor = vec4(average, average, average, color.a);
343
+ }
344
+ `,lightness:`
345
+ precision highp float;
346
+ uniform sampler2D uTexture;
347
+ uniform int uMode;
348
+ varying vec2 vTexCoord;
349
+ void main() {
350
+ vec4 col = texture2D(uTexture, vTexCoord);
351
+ float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;
352
+ gl_FragColor = vec4(average, average, average, col.a);
353
+ }
354
+ `,luminosity:`
355
+ precision highp float;
356
+ uniform sampler2D uTexture;
357
+ uniform int uMode;
358
+ varying vec2 vTexCoord;
359
+ void main() {
360
+ vec4 col = texture2D(uTexture, vTexCoord);
361
+ float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
362
+ gl_FragColor = vec4(average, average, average, col.a);
363
+ }
364
+ `},Nl={mode:`average`};var Pl=class extends ${applyTo2d({imageData:{data:e}}){for(let t=0,n;t<e.length;t+=4){let r=e[t],i=e[t+1],a=e[t+2];switch(this.mode){case`average`:n=(r+i+a)/3;break;case`lightness`:n=(Math.min(r,i,a)+Math.max(r,i,a))/2;break;case`luminosity`:n=.21*r+.72*i+.07*a;break}e[t+2]=e[t+1]=e[t]=n}}getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return Ml[this.mode]}sendUniformData(e,t){e.uniform1i(t.uMode,1)}isNeutralState(){return!1}};o(Pl,`type`,`Grayscale`),o(Pl,`defaults`,Nl),o(Pl,`uniformLocations`,[`uMode`]),M.setClass(Pl);let Fl={...pl,rotation:0};var Il=class extends ml{calculateMatrix(){let e=this.rotation*Math.PI,t=Ce(e),n=N(e),r=1/3,i=Math.sqrt(r)*n,a=1-t;this.matrix=[t+a/3,r*a-i,r*a+i,0,0,r*a+i,t+r*a,r*a-i,0,0,r*a-i,r*a+i,t+r*a,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(e){this.calculateMatrix(),super.applyTo(e)}toObject(){return{type:this.type,rotation:this.rotation}}};o(Il,`type`,`HueRotation`),o(Il,`defaults`,Fl),M.setClass(Il);let Ll={alpha:!1,invert:!0};var Rl=class extends ${applyTo2d({imageData:{data:e}}){for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2],this.alpha&&(e[t+3]=255-e[t+3])}getFragmentSource(){return`
365
+ precision highp float;
366
+ uniform sampler2D uTexture;
367
+ uniform int uInvert;
368
+ uniform int uAlpha;
369
+ varying vec2 vTexCoord;
370
+ void main() {
371
+ vec4 color = texture2D(uTexture, vTexCoord);
372
+ if (uInvert == 1) {
373
+ if (uAlpha == 1) {
374
+ gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a);
375
+ } else {
376
+ gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);
377
+ }
378
+ } else {
379
+ gl_FragColor = color;
380
+ }
381
+ }
382
+ `}isNeutralState(){return!this.invert}sendUniformData(e,t){e.uniform1i(t.uInvert,Number(this.invert)),e.uniform1i(t.uAlpha,Number(this.alpha))}};o(Rl,`type`,`Invert`),o(Rl,`defaults`,Ll),o(Rl,`uniformLocations`,[`uInvert`,`uAlpha`]),M.setClass(Rl);let zl={noise:0};var Bl=class extends ${getFragmentSource(){return`
383
+ precision highp float;
384
+ uniform sampler2D uTexture;
385
+ uniform float uStepH;
386
+ uniform float uNoise;
387
+ uniform float uSeed;
388
+ varying vec2 vTexCoord;
389
+ float rand(vec2 co, float seed, float vScale) {
390
+ return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);
391
+ }
392
+ void main() {
393
+ vec4 color = texture2D(uTexture, vTexCoord);
394
+ color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
395
+ gl_FragColor = color;
396
+ }
397
+ `}applyTo2d({imageData:{data:e}}){let t=this.noise;for(let n=0;n<e.length;n+=4){let r=(.5-Math.random())*t;e[n]+=r,e[n+1]+=r,e[n+2]+=r}}sendUniformData(e,t){e.uniform1f(t.uNoise,this.noise/255),e.uniform1f(t.uSeed,Math.random())}isNeutralState(){return this.noise===0}};o(Bl,`type`,`Noise`),o(Bl,`defaults`,zl),o(Bl,`uniformLocations`,[`uNoise`,`uSeed`]),M.setClass(Bl);let Vl={blocksize:4};var Hl=class extends ${applyTo2d({imageData:{data:e,width:t,height:n}}){for(let r=0;r<n;r+=this.blocksize)for(let i=0;i<t;i+=this.blocksize){let a=r*4*t+i*4,o=e[a],s=e[a+1],c=e[a+2],l=e[a+3];for(let a=r;a<Math.min(r+this.blocksize,n);a++)for(let n=i;n<Math.min(i+this.blocksize,t);n++){let r=a*4*t+n*4;e[r]=o,e[r+1]=s,e[r+2]=c,e[r+3]=l}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
398
+ precision highp float;
399
+ uniform sampler2D uTexture;
400
+ uniform float uBlocksize;
401
+ uniform float uStepW;
402
+ uniform float uStepH;
403
+ varying vec2 vTexCoord;
404
+ void main() {
405
+ float blockW = uBlocksize * uStepW;
406
+ float blockH = uBlocksize * uStepH;
407
+ int posX = int(vTexCoord.x / blockW);
408
+ int posY = int(vTexCoord.y / blockH);
409
+ float fposX = float(posX);
410
+ float fposY = float(posY);
411
+ vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);
412
+ vec4 color = texture2D(uTexture, squareCoords);
413
+ gl_FragColor = color;
414
+ }
415
+ `}sendUniformData(e,t){e.uniform1f(t.uBlocksize,this.blocksize)}};o(Hl,`type`,`Pixelate`),o(Hl,`defaults`,Vl),o(Hl,`uniformLocations`,[`uBlocksize`]),M.setClass(Hl);let Ul={color:`#FFFFFF`,distance:.02,useAlpha:!1};var Wl=class extends ${getFragmentSource(){return`
416
+ precision highp float;
417
+ uniform sampler2D uTexture;
418
+ uniform vec4 uLow;
419
+ uniform vec4 uHigh;
420
+ varying vec2 vTexCoord;
421
+ void main() {
422
+ gl_FragColor = texture2D(uTexture, vTexCoord);
423
+ if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {
424
+ gl_FragColor.a = 0.0;
425
+ }
426
+ }
427
+ `}applyTo2d({imageData:{data:e}}){let t=this.distance*255,n=new G(this.color).getSource(),r=[n[0]-t,n[1]-t,n[2]-t],i=[n[0]+t,n[1]+t,n[2]+t];for(let t=0;t<e.length;t+=4){let n=e[t],a=e[t+1],o=e[t+2];n>r[0]&&a>r[1]&&o>r[2]&&n<i[0]&&a<i[1]&&o<i[2]&&(e[t+3]=0)}}sendUniformData(e,t){let n=new G(this.color).getSource(),r=this.distance,i=[0+n[0]/255-r,0+n[1]/255-r,0+n[2]/255-r,1],a=[n[0]/255+r,n[1]/255+r,n[2]/255+r,1];e.uniform4fv(t.uLow,i),e.uniform4fv(t.uHigh,a)}};o(Wl,`type`,`RemoveColor`),o(Wl,`defaults`,Ul),o(Wl,`uniformLocations`,[`uLow`,`uHigh`]),M.setClass(Wl);let Gl={resizeType:`hermite`,scaleX:1,scaleY:1,lanczosLobes:3};var Kl=class extends ${sendUniformData(e,t){e.uniform2fv(t.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),e.uniform1fv(t.uTaps,this.taps)}getFilterWindow(){let e=this.tempScale;return Math.ceil(this.lanczosLobes/e)}getCacheKey(){let e=this.getFilterWindow();return`${this.type}_${e}`}getFragmentSource(){let e=this.getFilterWindow();return this.generateShader(e)}getTaps(){let e=this.lanczosCreate(this.lanczosLobes),t=this.tempScale,n=this.getFilterWindow(),r=Array(n);for(let i=1;i<=n;i++)r[i-1]=e(i*t);return r}generateShader(e){let t=Array(e);for(let n=1;n<=e;n++)t[n-1]=`${n}.0 * uDelta`;return`
428
+ precision highp float;
429
+ uniform sampler2D uTexture;
430
+ uniform vec2 uDelta;
431
+ varying vec2 vTexCoord;
432
+ uniform float uTaps[${e}];
433
+ void main() {
434
+ vec4 color = texture2D(uTexture, vTexCoord);
435
+ float sum = 1.0;
436
+ ${t.map((e,t)=>`
437
+ color += texture2D(uTexture, vTexCoord + ${e}) * uTaps[${t}] + texture2D(uTexture, vTexCoord - ${e}) * uTaps[${t}];
438
+ sum += 2.0 * uTaps[${t}];
439
+ `).join(`
440
+ `)}
441
+ gl_FragColor = color / sum;
442
+ }
443
+ `}applyToForWebgl(e){e.passes++,this.width=e.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=e.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),e.destinationWidth=this.dW,super.applyTo(e),e.sourceWidth=e.destinationWidth,this.height=e.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),e.destinationHeight=this.dH,super.applyTo(e),e.sourceHeight=e.destinationHeight}applyTo(e){Qc(e)?this.applyToForWebgl(e):this.applyTo2d(e)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(e){return t=>{if(t>=e||t<=-e)return 0;if(t<1.1920929e-7&&t>-1.1920929e-7)return 1;t*=Math.PI;let n=t/e;return Math.sin(t)/t*Math.sin(n)/n}}applyTo2d(e){let t=e.imageData,n=this.scaleX,r=this.scaleY;this.rcpScaleX=1/n,this.rcpScaleY=1/r;let i=t.width,a=t.height,o=Math.round(i*n),s=Math.round(a*r),c;c=this.resizeType===`sliceHack`?this.sliceByTwo(e,i,a,o,s):this.resizeType===`hermite`?this.hermiteFastResize(e,i,a,o,s):this.resizeType===`bilinear`?this.bilinearFiltering(e,i,a,o,s):this.resizeType===`lanczos`?this.lanczosResize(e,i,a,o,s):new ImageData(o,s),e.imageData=c}sliceByTwo(e,t,n,r,i){let a=e.imageData,o=.5,s=!1,c=!1,l=t*o,u=n*o,d=e.filterBackend.resources,f=0,p=0,m=t,h=0;d.sliceByTwo||(d.sliceByTwo=F());let g=d.sliceByTwo;(g.width<t*1.5||g.height<n)&&(g.width=t*1.5,g.height=n);let _=g.getContext(`2d`);for(_.clearRect(0,0,t*1.5,n),_.putImageData(a,0,0),r=Math.floor(r),i=Math.floor(i);!s||!c;)t=l,n=u,r<Math.floor(l*o)?l=Math.floor(l*o):(l=r,s=!0),i<Math.floor(u*o)?u=Math.floor(u*o):(u=i,c=!0),_.drawImage(g,f,p,t,n,m,h,l,u),f=m,p=h,h+=u;return _.getImageData(f,p,r,i)}lanczosResize(e,t,n,r,i){function a(e){let y,b,x,S,C,w,T,ee,E,D,O;for(_.x=(e+.5)*u,v.x=Math.floor(_.x),y=0;y<i;y++){for(_.y=(y+.5)*d,v.y=Math.floor(_.y),C=0,w=0,T=0,ee=0,E=0,b=v.x-m;b<=v.x+m;b++)if(!(b<0||b>=t)){D=Math.floor(1e3*Math.abs(b-_.x)),g[D]||(g[D]={});for(let e=v.y-h;e<=v.y+h;e++)e<0||e>=n||(O=Math.floor(1e3*Math.abs(e-_.y)),g[D][O]||(g[D][O]=l(Math.sqrt((D*f)**2+(O*p)**2)/1e3)),x=g[D][O],x>0&&(S=(e*t+b)*4,C+=x,w+=x*o[S],T+=x*o[S+1],ee+=x*o[S+2],E+=x*o[S+3]))}S=(y*r+e)*4,c[S]=w/C,c[S+1]=T/C,c[S+2]=ee/C,c[S+3]=E/C}return++e<r?a(e):s}let o=e.imageData.data,s=e.ctx.createImageData(r,i),c=s.data,l=this.lanczosCreate(this.lanczosLobes),u=this.rcpScaleX,d=this.rcpScaleY,f=2/this.rcpScaleX,p=2/this.rcpScaleY,m=Math.ceil(u*this.lanczosLobes/2),h=Math.ceil(d*this.lanczosLobes/2),g={},_={x:0,y:0},v={x:0,y:0};return a(0)}bilinearFiltering(e,t,n,r,i){let a,o,s,c,l,u,d,f,p,m,h,g,_=0,v,y=this.rcpScaleX,b=this.rcpScaleY,x=4*(t-1),S=e.imageData.data,C=e.ctx.createImageData(r,i),w=C.data;for(d=0;d<i;d++)for(f=0;f<r;f++)for(l=Math.floor(y*f),u=Math.floor(b*d),p=y*f-l,m=b*d-u,v=4*(u*t+l),h=0;h<4;h++)a=S[v+h],o=S[v+4+h],s=S[v+x+h],c=S[v+x+4+h],g=a*(1-p)*(1-m)+o*p*(1-m)+s*m*(1-p)+c*p*m,w[_++]=g;return C}hermiteFastResize(e,t,n,r,i){let a=this.rcpScaleX,o=this.rcpScaleY,s=Math.ceil(a/2),c=Math.ceil(o/2),l=e.imageData.data,u=e.ctx.createImageData(r,i),d=u.data;for(let e=0;e<i;e++)for(let n=0;n<r;n++){let i=(n+e*r)*4,u,f=0,p=0,m=0,h=0,g=0,_=0,v=(e+.5)*o;for(let r=Math.floor(e*o);r<(e+1)*o;r++){let e=Math.abs(v-(r+.5))/c,i=(n+.5)*a,o=e*e;for(let e=Math.floor(n*a);e<(n+1)*a;e++){let n=Math.abs(i-(e+.5))/s,a=Math.sqrt(o+n*n);a>1&&a<-1||(u=2*a*a*a-3*a*a+1,u>0&&(n=4*(e+r*t),_+=u*l[n+3],p+=u,l[n+3]<255&&(u=u*l[n+3]/250),m+=u*l[n],h+=u*l[n+1],g+=u*l[n+2],f+=u))}}d[i]=m/f,d[i+1]=h/f,d[i+2]=g/f,d[i+3]=_/p}return u}};o(Kl,`type`,`Resize`),o(Kl,`defaults`,Gl),o(Kl,`uniformLocations`,[`uDelta`,`uTaps`]),M.setClass(Kl);let ql={saturation:0};var Jl=class extends ${getFragmentSource(){return`
444
+ precision highp float;
445
+ uniform sampler2D uTexture;
446
+ uniform float uSaturation;
447
+ varying vec2 vTexCoord;
448
+ void main() {
449
+ vec4 color = texture2D(uTexture, vTexCoord);
450
+ float rgMax = max(color.r, color.g);
451
+ float rgbMax = max(rgMax, color.b);
452
+ color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;
453
+ color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;
454
+ color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
455
+ gl_FragColor = color;
456
+ }
457
+ `}applyTo2d({imageData:{data:e}}){let t=-this.saturation;for(let n=0;n<e.length;n+=4){let r=e[n],i=e[n+1],a=e[n+2],o=Math.max(r,i,a);e[n]+=o===r?0:(o-r)*t,e[n+1]+=o===i?0:(o-i)*t,e[n+2]+=o===a?0:(o-a)*t}}sendUniformData(e,t){e.uniform1f(t.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}};o(Jl,`type`,`Saturation`),o(Jl,`defaults`,ql),o(Jl,`uniformLocations`,[`uSaturation`]),M.setClass(Jl);let Yl={vibrance:0};var Xl=class extends ${getFragmentSource(){return`
458
+ precision highp float;
459
+ uniform sampler2D uTexture;
460
+ uniform float uVibrance;
461
+ varying vec2 vTexCoord;
462
+ void main() {
463
+ vec4 color = texture2D(uTexture, vTexCoord);
464
+ float max = max(color.r, max(color.g, color.b));
465
+ float avg = (color.r + color.g + color.b) / 3.0;
466
+ float amt = (abs(max - avg) * 2.0) * uVibrance;
467
+ color.r += max != color.r ? (max - color.r) * amt : 0.00;
468
+ color.g += max != color.g ? (max - color.g) * amt : 0.00;
469
+ color.b += max != color.b ? (max - color.b) * amt : 0.00;
470
+ gl_FragColor = color;
471
+ }
472
+ `}applyTo2d({imageData:{data:e}}){let t=-this.vibrance;for(let n=0;n<e.length;n+=4){let r=e[n],i=e[n+1],a=e[n+2],o=Math.max(r,i,a),s=(r+i+a)/3,c=Math.abs(o-s)*2/255*t;e[n]+=o===r?0:(o-r)*c,e[n+1]+=o===i?0:(o-i)*c,e[n+2]+=o===a?0:(o-a)*c}}sendUniformData(e,t){e.uniform1f(t.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}};o(Xl,`type`,`Vibrance`),o(Xl,`defaults`,Yl),o(Xl,`uniformLocations`,[`uVibrance`]),M.setClass(Xl);var Zl=n({BaseFilter:()=>$,BlackWhite:()=>Sl,BlendColor:()=>al,BlendImage:()=>cl,Blur:()=>ul,Brightness:()=>fl,Brownie:()=>gl,ColorMatrix:()=>ml,Composed:()=>Cl,Contrast:()=>Tl,Convolute:()=>Ol,Gamma:()=>jl,Grayscale:()=>Pl,HueRotation:()=>Il,Invert:()=>Rl,Kodachrome:()=>vl,Noise:()=>Bl,Pixelate:()=>Hl,Polaroid:()=>bl,RemoveColor:()=>Wl,Resize:()=>Kl,Saturation:()=>Jl,Sepia:()=>xl,Technicolor:()=>yl,Vibrance:()=>Xl,Vintage:()=>_l});let Ql={};h(()=>({document,window,isTouchSupported:`ontouchstart`in window||`ontouchstart`in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Ns,dispose(){},copyPasteData:Ql})),e.ActiveSelection=Sc,e.BaseBrush=xs,e.BaseFabricObject=ni,e.Canvas=ns,e.Canvas2dFilterBackend=Cc,e.CanvasDOMManager=Mo,e.Circle=Ds,e.CircleBrush=Os,e.ClipPathLayout=vc,e.Color=G,e.Control=q,e.Ellipse=Bs,e.FabricImage=Mc,e.Image=Mc,e.FabricObject=J,e.Object=J,e.FabricText=Q,e.Text=Q,e.FitContentLayout=Fa,e.FixedLayout=yc,e.GLProbe=Ms,e.Gradient=ys,e.Group=Ba,e.IText=hc,e.InteractiveFabricObject=Vi,e.Intersection=ei,e.LayoutManager=La,e.LayoutStrategy=Pa,e.Line=Fs,e.Observable=xe,e.Path=Ss,e.Pattern=bs,e.PatternBrush=js,e.PencilBrush=ws,e.Point=P,e.Polygon=Ws,e.Polyline=Us,e.Rect=Aa,e.Shadow=ir,e.SprayBrush=As,e.StaticCanvas=Tt,e.StaticCanvasDOMManager=gt,e.Textbox=_c,e.Triangle=Ls,e.WebGLFilterBackend=wc,e.WebGLProbe=Ns,e.cache=b,e.classRegistry=M,e.config=c,Object.defineProperty(e,"controlsUtils",{enumerable:!0,get:function(){return Xo}}),e.createCollectionMixin=Ee,Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return Zl}}),e.getDevicePixelRatio=y,e.getEnv=g,e.getFabricDocument=_,e.getFabricWindow=v,e.getFilterBackend=Oc,e.iMatrix=E,e.initFilterBackend=Dc,e.isPutImageFaster=$c,e.isWebGLPipelineState=Qc,e.loadSVGFromString=Xc,e.loadSVGFromURL=Zc,e.parseSVGDocument=Yc,e.runningAnimations=be,e.setEnv=m,e.setEnvFactory=h,e.setFilterBackend=kc,Object.defineProperty(e,"util",{enumerable:!0,get:function(){return Ao}}),e.version=x});
473
+ //# sourceMappingURL=index.min.js.map